changed to new functions
All checks were successful
Deploy Docs to Synology / deploy (push) Successful in 3s
All checks were successful
Deploy Docs to Synology / deploy (push) Successful in 3s
This commit is contained in:
@@ -1,22 +1,22 @@
|
||||
// components/Select.js
|
||||
import { Tag, For } from "sigpro";
|
||||
import { h, each } from "sigpro";
|
||||
|
||||
export const Select = (props, children) => {
|
||||
children === undefined && (children = props, props = {});
|
||||
return Tag("select", { ...props, class: `select ${props.class ?? ''}` }, children);
|
||||
return h("select", { ...props, class: `select ${props.class ?? ''}` }, children);
|
||||
};
|
||||
|
||||
export const SelectItems = (props) => {
|
||||
const placeholderOption = props.placeholder
|
||||
? Tag("option", { disabled: props.placeholderDisabled ?? true, selected: true }, props.placeholder)
|
||||
? h("option", { disabled: props.placeholderDisabled ?? true, selected: true }, props.placeholder)
|
||||
: null;
|
||||
|
||||
const dynamicOptions = For(
|
||||
const dynamicOptions = each(
|
||||
() => [...(typeof props.items === "function" ? props.items() : props.items || [])],
|
||||
(item) => {
|
||||
const val = typeof item === "string" ? item : item.value;
|
||||
const label = typeof item === "string" ? item : item.label;
|
||||
return Tag("option", { value: val }, label);
|
||||
return h("option", { value: val }, label);
|
||||
},
|
||||
props.keyFn || ((item) => (typeof item === "string" ? item : item.value))
|
||||
);
|
||||
@@ -24,11 +24,11 @@ export const SelectItems = (props) => {
|
||||
return placeholderOption ? [placeholderOption, dynamicOptions] : dynamicOptions;
|
||||
};
|
||||
|
||||
export const SelectLabel = (props, children) => Tag("label", { class: `${props.float ? 'floating-label' : 'select'}` },
|
||||
export const SelectLabel = (props, children) => h("label", { class: `${props.float ? 'floating-label' : 'select'}` },
|
||||
[
|
||||
Tag("span", { class: props.float ? '' : 'label opacity-50' }, props.label),
|
||||
h("span", { class: props.float ? '' : 'label opacity-50' }, props.label),
|
||||
props.left ?? null,
|
||||
Tag("select", { ...props, class: `${props.float ? 'select' : ''} ${props.class ?? ''}` }, children),
|
||||
h("select", { ...props, class: `${props.float ? 'select' : ''} ${props.class ?? ''}` }, children),
|
||||
props.right ?? null
|
||||
]
|
||||
);
|
||||
Reference in New Issue
Block a user