feat: add preselect first config for app selects
This commit is contained in:
@@ -77,7 +77,7 @@
|
||||
let rawValue
|
||||
if (resolvedConfig.defaultValue !== undefined) {
|
||||
rawValue = resolvedConfig.defaultValue
|
||||
} else if (listItems.length > 0) {
|
||||
} else if (listItems.length > 0 && resolvedConfig?.preselectFirst) {
|
||||
rawValue = resolvedConfig.items[0].value
|
||||
}
|
||||
if (rawValue !== undefined) {
|
||||
@@ -117,6 +117,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
function onClear() {
|
||||
value = undefined
|
||||
outputs?.result.set(undefined)
|
||||
if (iterContext && listInputs) {
|
||||
listInputs(id, undefined)
|
||||
}
|
||||
}
|
||||
|
||||
$: css = concatCustomCss($app.css?.selectcomponent, customCss)
|
||||
|
||||
function handleFilter(e) {
|
||||
@@ -168,7 +176,7 @@
|
||||
--border-color="#999"
|
||||
bind:filterText
|
||||
on:filter={handleFilter}
|
||||
on:clear={onChange}
|
||||
on:clear={onClear}
|
||||
on:change={onChange}
|
||||
items={listItems}
|
||||
listAutoWidth={resolvedConfig.fullWidth}
|
||||
|
||||
@@ -1374,6 +1374,13 @@ Hello \${ctx.username}
|
||||
value: undefined,
|
||||
fieldType: 'object'
|
||||
},
|
||||
preselectFirst: {
|
||||
type: 'static',
|
||||
value: true,
|
||||
fieldType: 'boolean',
|
||||
onlyStatic: true,
|
||||
tooltip: 'Preselect first item in the options if no default value is set'
|
||||
},
|
||||
fullWidth: {
|
||||
type: 'static',
|
||||
fieldType: 'boolean',
|
||||
|
||||
Reference in New Issue
Block a user