@proyecto-viviana/solidaria 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunk/DragManager.js.map +1 -1
- package/dist/_chunk/DragManager.jsx.map +1 -1
- package/dist/_chunk/actiongroup.js.map +1 -1
- package/dist/_chunk/actiongroup.jsx.map +1 -1
- package/dist/_chunk/datepicker.js +544 -544
- package/dist/_chunk/datepicker.js.map +1 -1
- package/dist/_chunk/datepicker.jsx +544 -544
- package/dist/_chunk/datepicker.jsx.map +1 -1
- package/dist/_chunk/dnd.js.map +1 -1
- package/dist/_chunk/dnd.jsx.map +1 -1
- package/dist/_chunk/select.js +6 -2
- package/dist/_chunk/select.js.map +1 -1
- package/dist/_chunk/select.jsx +6 -2
- package/dist/_chunk/select.jsx.map +1 -1
- package/dist/_chunk/spinbutton.js +34 -34
- package/dist/_chunk/spinbutton.js.map +1 -1
- package/dist/_chunk/spinbutton.jsx +34 -34
- package/dist/_chunk/spinbutton.jsx.map +1 -1
- package/dist/_chunk/table.js.map +1 -1
- package/dist/_chunk/table.jsx.map +1 -1
- package/dist/_chunk/tree.js.map +1 -1
- package/dist/_chunk/tree.jsx.map +1 -1
- package/dist/actiongroup/createActionGroup.d.ts.map +1 -1
- package/dist/datepicker/createDateField.d.ts.map +1 -1
- package/dist/datepicker/createDatePickerGroup.d.ts.map +1 -1
- package/dist/datepicker/createDateSegment.d.ts.map +1 -1
- package/dist/datepicker/createTimeField.d.ts.map +1 -1
- package/dist/datepicker/intl.d.ts.map +1 -1
- package/dist/dnd/DragManager.d.ts.map +1 -1
- package/dist/dnd/createDraggableItem.d.ts.map +1 -1
- package/dist/dnd/createDroppableCollection.d.ts.map +1 -1
- package/dist/select/createSelect.d.ts.map +1 -1
- package/dist/spinbutton/index.d.ts +2 -2
- package/dist/spinbutton/index.d.ts.map +1 -1
- package/dist/table/createTable.d.ts.map +1 -1
- package/dist/table/utils.d.ts.map +1 -1
- package/dist/tree/createTree.d.ts.map +1 -1
- package/package.json +4 -2
- package/src/actiongroup/createActionGroup.ts +1 -4
- package/src/datepicker/createDateField.ts +3 -1
- package/src/datepicker/createDatePickerGroup.ts +8 -4
- package/src/datepicker/createDateSegment.ts +47 -39
- package/src/datepicker/createTimeField.ts +1 -5
- package/src/datepicker/intl.ts +587 -544
- package/src/dnd/DragManager.ts +5 -5
- package/src/dnd/DropTargetKeyboardNavigation.ts +6 -4
- package/src/dnd/createDraggableItem.ts +3 -1
- package/src/dnd/createDroppableCollection.ts +7 -8
- package/src/select/createSelect.ts +19 -16
- package/src/spinbutton/index.ts +2 -10
- package/src/spinbutton/intl.ts +34 -34
- package/src/table/createTable.ts +2 -3
- package/src/table/utils.ts +1 -6
- package/src/tree/createTree.ts +1 -4
package/dist/_chunk/select.js
CHANGED
|
@@ -194,7 +194,11 @@ function createSelect(props, state, _ref) {
|
|
|
194
194
|
"aria-disabled": isDisabled || void 0,
|
|
195
195
|
"aria-required": p.isRequired || void 0,
|
|
196
196
|
"aria-describedby": p["aria-describedby"] || void 0,
|
|
197
|
-
"aria-labelledby":
|
|
197
|
+
"aria-labelledby": [
|
|
198
|
+
valueId,
|
|
199
|
+
fieldProps["aria-labelledby"],
|
|
200
|
+
fieldProps["aria-label"] && !fieldProps["aria-labelledby"] ? fieldProps.id : void 0
|
|
201
|
+
].filter(Boolean).join(" "),
|
|
198
202
|
onKeyDown,
|
|
199
203
|
onFocus: handleFocus,
|
|
200
204
|
onBlur: handleBlur,
|
|
@@ -213,7 +217,7 @@ function createSelect(props, state, _ref) {
|
|
|
213
217
|
return {
|
|
214
218
|
id: listBoxId,
|
|
215
219
|
role: "listbox",
|
|
216
|
-
"aria-labelledby": fieldProps["aria-labelledby"]
|
|
220
|
+
"aria-labelledby": [fieldProps["aria-labelledby"], fieldProps["aria-label"] && !fieldProps["aria-labelledby"] ? fieldProps.id : void 0].filter(Boolean).join(" "),
|
|
217
221
|
"aria-multiselectable": state.selectionMode() === "multiple" ? true : void 0,
|
|
218
222
|
tabIndex: -1,
|
|
219
223
|
onBlur: (e) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","names":["mergeProps","JSX","Accessor","For","createEffect","onCleanup","access","MaybeAccessor","createFormValidation","SelectState","Key","FormValidationState","ValidationBehavior","AriaHiddenSelectProps","state","T","name","isDisabled","isRequired","autoComplete","form","validationBehavior","triggerRef","HTMLElement","validationState","HiddenSelectAria","containerProps","HTMLAttributes","HTMLDivElement","selectProps","SelectHTMLAttributes","HTMLSelectElement","inputProps","InputHTMLAttributes","HTMLInputElement","createHiddenSelect","props","getProps","selectRef","p","handleReset","defaultKey","collection","getFirstKey","setSelectedKey","addEventListener","removeEventListener","focus","selectedKey","selectedKeys","Set","isMultiple","selectionMode","multipleValue","Array","from","map","item","String","key","ref","el","tabIndex","disabled","multiple","undefined","required","value","onChange","e","Event","target","setSelectedKeys","selectedOptions","o","first","style","position","top","left","width","height","opacity","border","cursor","margin","padding","useTextInput","type","display","HiddenSelectProps","label","HiddenSelect","Element","_el$","_$getNextElement","_tmpl$","_el$2","firstChild","_el$7","_el$8","_co$2","_$getNextMarker","nextSibling","_el$3","_el$4","_el$5","_el$6","_co$","_$spread","_$insert","_$createComponent","each","children","_el$9","_tmpl$2","textValue","_$effect","_$setProperty","has","_$runHydrationEvents"],"sources":["../../src/select/createSelect.ts","../../src/select/createHiddenSelect.tsx"],"sourcesContent":["/**\n * Provides the behavior and accessibility implementation for a select component.\n * A select displays a collapsible list of options and allows a user to select one of them.\n * Based on @react-aria/select useSelect.\n */\n\nimport { type JSX, type Accessor, createEffect, onCleanup } from \"solid-js\";\nimport { createPress } from \"../interactions/createPress\";\nimport { createFocusRing } from \"../interactions/createFocusRing\";\nimport { createLabel } from \"../label/createLabel\";\nimport { createTypeSelect } from \"../selection/createTypeSelect\";\nimport { filterDOMProps } from \"../utils/filterDOMProps\";\nimport { mergeProps } from \"../utils/mergeProps\";\nimport { createId } from \"../ssr\";\nimport { access, type MaybeAccessor } from \"../utils/reactivity\";\nimport type { SelectState, CollectionNode } from \"@proyecto-viviana/solid-stately\";\n\nexport interface AriaSelectProps {\n /** An ID for the select. */\n id?: string;\n /** Whether the select is disabled. */\n isDisabled?: boolean;\n /** Whether the select is required. */\n isRequired?: boolean;\n /** Whether the select is invalid. */\n isInvalid?: boolean;\n /** The label for the select. */\n label?: JSX.Element;\n /** An accessible label for the select when no visible label is provided. */\n \"aria-label\"?: string;\n /** The ID of an element that labels the select. */\n \"aria-labelledby\"?: string;\n /** The ID of an element that describes the select. */\n \"aria-describedby\"?: string;\n /** Placeholder text when no option is selected. */\n placeholder?: string;\n /** Whether the select should be auto-focused. */\n autoFocus?: boolean;\n /** Handler called when focus moves to the select. */\n onFocus?: (e: FocusEvent) => void;\n /** Handler called when focus moves away from the select. */\n onBlur?: (e: FocusEvent) => void;\n /** Handler called when the focus state changes. */\n onFocusChange?: (isFocused: boolean) => void;\n /** The name of the select, used when submitting an HTML form. */\n name?: string;\n /** Associates the hidden native select with a form element by id. */\n form?: string;\n /** Whether type-to-select is disabled. @default false */\n disallowTypeAhead?: boolean;\n /** Whether the select can open when its collection is empty. @default false */\n allowsEmptyCollection?: boolean;\n /** Whether validation should use ARIA attributes or native browser validation. */\n validationBehavior?: \"aria\" | \"native\";\n}\n\nexport interface SelectAria<T> {\n /** Props for the label element. */\n labelProps: JSX.HTMLAttributes<HTMLElement>;\n /** Props for the trigger button element. */\n triggerProps: JSX.HTMLAttributes<HTMLElement>;\n /** Props for the value display element. */\n valueProps: JSX.HTMLAttributes<HTMLElement>;\n /** Props for the listbox/menu popup. */\n menuProps: JSX.HTMLAttributes<HTMLElement>;\n /** Props for the description element, if any. */\n descriptionProps: JSX.HTMLAttributes<HTMLElement>;\n /** Props for the error message element, if any. */\n errorMessageProps: JSX.HTMLAttributes<HTMLElement>;\n /** Whether the select is currently focused. */\n isFocused: Accessor<boolean>;\n /** Whether the select has keyboard focus. */\n isFocusVisible: Accessor<boolean>;\n /** Whether the select is currently open. */\n isOpen: Accessor<boolean>;\n /** Whether the trigger button is currently pressed (for `pressScale`). */\n isPressed: Accessor<boolean>;\n /** The currently selected item. */\n selectedItem: Accessor<CollectionNode<T> | null>;\n}\n\n// Shared data between select and options\nconst selectData = new WeakMap<object, SelectData>();\n\ninterface SelectData {\n id: string;\n}\n\nexport function getSelectData(state: SelectState): SelectData | undefined {\n return selectData.get(state);\n}\n\n/**\n * Provides the behavior and accessibility implementation for a select component.\n */\nexport function createSelect<T>(\n props: MaybeAccessor<AriaSelectProps>,\n state: SelectState<T>,\n _ref?: () => HTMLElement | null,\n): SelectAria<T> {\n const getProps = () => access(props);\n const id = createId(getProps().id);\n\n // Generate IDs for associated elements\n const buttonId = `${id}-button`;\n const listBoxId = `${id}-listbox`;\n const valueId = `${id}-value`;\n const descriptionId = `${id}-description`;\n const errorMessageId = `${id}-error`;\n\n // Filter DOM props\n const domProps = () =>\n filterDOMProps(getProps() as unknown as Record<string, unknown>, { labelable: true });\n\n // Share data with child options\n createEffect(() => {\n selectData.set(state, { id });\n\n onCleanup(() => {\n selectData.delete(state);\n });\n });\n\n // Label handling\n const { labelProps, fieldProps } = createLabel({\n get id() {\n return buttonId;\n },\n get label() {\n return getProps().label;\n },\n get \"aria-label\"() {\n return getProps()[\"aria-label\"];\n },\n get \"aria-labelledby\"() {\n return getProps()[\"aria-labelledby\"];\n },\n labelElementType: \"span\",\n });\n\n // Focus ring for keyboard focus styling\n const { isFocusVisible, focusProps } = createFocusRing({\n get autoFocus() {\n return getProps().autoFocus;\n },\n });\n\n // Track focus state\n const isFocused = state.isFocused;\n\n // Handle press on trigger\n const canOpen = () =>\n getProps().allowsEmptyCollection || state.collection().getFirstKey() != null;\n\n // Helper to check if key is disabled\n const isKeyDisabled = (key: string | number): boolean => {\n const collection = state.collection();\n return state.isKeyDisabled?.(key) || collection.getItem(key)?.isDisabled || false;\n };\n\n // Helper to find the next non-disabled key.\n const findNextKey = (\n fromKey: string | number | null,\n direction: \"forward\" | \"backward\",\n ): string | number | null => {\n const collection = state.collection();\n const getAdjacent =\n direction === \"forward\"\n ? (k: string | number) => collection.getKeyAfter(k)\n : (k: string | number) => collection.getKeyBefore(k);\n const getBoundary =\n direction === \"forward\" ? () => collection.getFirstKey() : () => collection.getLastKey();\n\n let key = fromKey == null ? getBoundary() : getAdjacent(fromKey);\n while (key != null && isKeyDisabled(key)) {\n key = getAdjacent(key);\n }\n\n return key;\n };\n\n const focusKeyForOpen = (): string | number | null => {\n const selectedKey = state.selectedKey();\n if (selectedKey != null && !isKeyDisabled(selectedKey)) {\n return selectedKey;\n }\n return findNextKey(null, \"forward\");\n };\n\n const openWithFocus = () => {\n if (state.isOpen() || !canOpen()) {\n return;\n }\n state.open();\n const focusKey = focusKeyForOpen();\n if (focusKey != null) {\n state.setFocusedKey(focusKey);\n }\n };\n\n const { pressProps, isPressed } = createPress({\n get isDisabled() {\n return getProps().isDisabled ?? state.isDisabled;\n },\n onPress(e) {\n if (e.pointerType === \"keyboard\") {\n return;\n }\n\n if (state.isOpen()) {\n state.close();\n } else {\n openWithFocus();\n }\n },\n });\n\n // Type-to-select - for Select, typing directly selects items when closed\n const { typeSelectProps } = createTypeSelect({\n collection: () => state.collection(),\n focusedKey: () => state.selectedKey(), // Use selectedKey as the \"focused\" key for closed Select\n onFocusedKeyChange: (key) => {\n // When closed, type-to-select directly changes selection\n if (!state.isOpen()) {\n state.setSelectedKey(key);\n } else {\n // When open, update focused key (listbox handles selection)\n state.setFocusedKey(key);\n }\n },\n isKeyDisabled,\n get isDisabled() {\n return Boolean(\n (getProps().disallowTypeAhead ?? false) || getProps().isDisabled || state.isDisabled,\n );\n },\n });\n\n // Keyboard navigation\n const onKeyDown: JSX.EventHandler<HTMLElement, KeyboardEvent> = (e) => {\n if (getProps().isDisabled ?? state.isDisabled) return;\n\n const currentKey = state.focusedKey() ?? state.selectedKey();\n\n switch (e.key) {\n case \"Enter\":\n case \" \":\n e.preventDefault();\n if (state.isOpen()) {\n state.close();\n } else {\n openWithFocus();\n }\n break;\n\n case \"ArrowDown\":\n e.preventDefault();\n if (!state.isOpen()) {\n if (!canOpen()) {\n return;\n }\n // ArrowDown: Open the dropdown and focus first/selected item\n state.open();\n const focusKey =\n currentKey != null && !isKeyDisabled(currentKey)\n ? currentKey\n : findNextKey(currentKey, \"forward\");\n if (focusKey) {\n state.setFocusedKey(focusKey);\n }\n }\n // When open, navigation is handled by the listbox\n break;\n\n case \"ArrowUp\":\n e.preventDefault();\n if (!state.isOpen()) {\n if (!canOpen()) {\n return;\n }\n // ArrowUp: Open the dropdown and focus last/selected item\n state.open();\n const focusKey =\n currentKey != null && !isKeyDisabled(currentKey)\n ? currentKey\n : findNextKey(currentKey, \"backward\");\n if (focusKey) {\n state.setFocusedKey(focusKey);\n }\n }\n // When open, navigation is handled by the listbox\n break;\n\n case \"ArrowRight\":\n // ArrowRight: Select next option (for horizontal keyboard navigation pattern)\n if (!state.isOpen()) {\n e.preventDefault();\n const nextKey = findNextKey(currentKey, \"forward\");\n if (nextKey != null) {\n state.setSelectedKey(nextKey);\n }\n }\n break;\n\n case \"ArrowLeft\":\n // ArrowLeft: Select previous option (for horizontal keyboard navigation pattern)\n if (!state.isOpen()) {\n e.preventDefault();\n const prevKey = findNextKey(currentKey, \"backward\");\n if (prevKey != null) {\n state.setSelectedKey(prevKey);\n }\n }\n break;\n\n case \"Home\":\n // Home: Select first option\n if (!state.isOpen()) {\n e.preventDefault();\n const firstKey = findNextKey(null, \"forward\");\n if (firstKey != null) {\n state.setSelectedKey(firstKey);\n }\n }\n break;\n\n case \"End\":\n // End: Select last option\n if (!state.isOpen()) {\n e.preventDefault();\n const lastKey = findNextKey(null, \"backward\");\n if (lastKey != null) {\n state.setSelectedKey(lastKey);\n }\n }\n break;\n\n case \"Escape\":\n if (state.isOpen()) {\n e.preventDefault();\n state.close();\n }\n break;\n }\n };\n\n // Handle focus events\n const handleFocus = (e: FocusEvent) => {\n getProps().onFocus?.(e);\n getProps().onFocusChange?.(true);\n state.setFocused(true);\n };\n\n const handleBlur = (e: FocusEvent) => {\n // Focus moving into the open listbox is not a select blur; the menu's own\n // onBlur clears the state when focus leaves the listbox entirely.\n if (state.isOpen()) {\n return;\n }\n\n getProps().onBlur?.(e);\n getProps().onFocusChange?.(false);\n state.setFocused(false);\n };\n\n return {\n get labelProps() {\n return labelProps as JSX.HTMLAttributes<HTMLElement>;\n },\n get triggerProps() {\n const p = getProps();\n const isOpen = state.isOpen();\n const isDisabled = p.isDisabled ?? state.isDisabled;\n\n const baseProps = mergeProps(\n domProps(),\n pressProps as Record<string, unknown>,\n focusProps as Record<string, unknown>,\n fieldProps as Record<string, unknown>,\n {\n id: buttonId,\n type: \"button\",\n tabIndex: isDisabled ? undefined : 0,\n \"aria-haspopup\": \"listbox\",\n \"aria-expanded\": isOpen,\n \"aria-controls\": isOpen ? listBoxId : undefined,\n \"aria-disabled\": isDisabled || undefined,\n \"aria-required\": p.isRequired || undefined,\n \"aria-describedby\": p[\"aria-describedby\"] || undefined,\n // Mirror upstream `useSelect`: the trigger's accessible name folds the\n // SELECTED VALUE (\"Pro\") ahead of the field label (\"Plan\") → \"Pro Plan\"\n // via `aria-labelledby=[valueId, labelId]`. Only wire this when there is\n // a real visible label; with an `aria-label` (no `labelledby`) the field\n // props' `aria-label` stays the trigger name (label-less legacy path,\n // keeps TabsPicker/label-less Select unchanged).\n \"aria-labelledby\": fieldProps[\"aria-labelledby\"]\n ? [valueId, fieldProps[\"aria-labelledby\"]].filter(Boolean).join(\" \")\n : undefined,\n onKeyDown,\n onFocus: handleFocus,\n onBlur: handleBlur,\n \"data-open\": isOpen || undefined,\n \"data-disabled\": isDisabled || undefined,\n \"data-focus-visible\": isFocusVisible() || undefined,\n } as Record<string, unknown>,\n );\n\n // Add type-select props if enabled\n if (!p.disallowTypeAhead) {\n return mergeProps(\n baseProps,\n typeSelectProps as Record<string, unknown>,\n ) as JSX.HTMLAttributes<HTMLElement>;\n }\n\n return baseProps as JSX.HTMLAttributes<HTMLElement>;\n },\n get valueProps() {\n return {\n id: valueId,\n } as JSX.HTMLAttributes<HTMLElement>;\n },\n // Surfaced so the styled layer (S2 Picker) can apply the `pressScale` press\n // effect on the trigger button — upstream S2 wires `pressScale(buttonRef)` on\n // the RAC Button, which needs the button's live `isPressed`.\n isPressed,\n get menuProps() {\n return {\n id: listBoxId,\n role: \"listbox\",\n // Mirror upstream `useSelect`: the listbox is labelled by the FIELD LABEL\n // (`fieldProps['aria-labelledby']` → the visible \"Plan\" label), NOT the\n // trigger button — the button's own accessible name folds in the selected\n // value (\"Pro Plan\"), which must not leak onto the listbox. Only when\n // there is no visible label (an `aria-label` on the field) does it fall\n // back to the trigger id (unchanged legacy behavior for label-less use).\n \"aria-labelledby\": fieldProps[\"aria-labelledby\"] ?? buttonId,\n \"aria-multiselectable\": state.selectionMode() === \"multiple\" ? true : undefined,\n tabIndex: -1,\n onBlur: (e: FocusEvent) => {\n // Only a blur that leaves the listbox entirely blurs the select.\n if ((e.currentTarget as Node | null)?.contains(e.relatedTarget as Node)) {\n return;\n }\n\n getProps().onBlur?.(e);\n getProps().onFocusChange?.(false);\n state.setFocused(false);\n },\n } as JSX.HTMLAttributes<HTMLElement>;\n },\n get descriptionProps() {\n return {\n id: descriptionId,\n } as JSX.HTMLAttributes<HTMLElement>;\n },\n get errorMessageProps() {\n return {\n id: errorMessageId,\n } as JSX.HTMLAttributes<HTMLElement>;\n },\n isFocused,\n isFocusVisible: () => isFocused() && isFocusVisible(),\n isOpen: state.isOpen,\n selectedItem: state.selectedItem,\n };\n}\n","/**\n * Provides a hidden native select element for form integration.\n * Based on @react-aria/select useHiddenSelect.\n */\n\nimport { type JSX, type Accessor, For, createEffect, onCleanup } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils/reactivity\";\nimport { createFormValidation } from \"../form/createFormValidation\";\nimport type { SelectState, Key, FormValidationState } from \"@proyecto-viviana/solid-stately\";\n\nexport type ValidationBehavior = \"aria\" | \"native\";\n\nexport interface AriaHiddenSelectProps<T> {\n /** The state object for the select. */\n state: SelectState<T>;\n /** The name attribute for the hidden select. */\n name?: string;\n /** Whether the select is disabled. */\n isDisabled?: boolean;\n /** Whether the select is required. */\n isRequired?: boolean;\n /** Describes the type of autocomplete functionality the select should provide. */\n autoComplete?: string;\n /** The `form` attribute to associate the select with a form by ID. */\n form?: string;\n /** Validation behavior: 'aria' for realtime, 'native' for on submit. */\n validationBehavior?: ValidationBehavior;\n /** A ref to the trigger element for focus on validation error. */\n triggerRef?: Accessor<HTMLElement | null>;\n /** Form validation state (optional, for native validation). */\n validationState?: FormValidationState;\n}\n\nexport interface HiddenSelectAria {\n /** Props for the container element. */\n containerProps: JSX.HTMLAttributes<HTMLDivElement>;\n /** Props for the hidden select element. */\n selectProps: JSX.SelectHTMLAttributes<HTMLSelectElement>;\n /** Props for the hidden input element (for form submission). */\n inputProps: JSX.InputHTMLAttributes<HTMLInputElement>;\n}\n\n/**\n * Provides the accessibility implementation for a hidden select.\n * This is used for native form submission and accessibility on mobile devices.\n */\nexport function createHiddenSelect<T>(\n props: MaybeAccessor<AriaHiddenSelectProps<T>>,\n): HiddenSelectAria {\n const getProps = () => access(props);\n\n // Track the select element for form reset/validation\n let selectRef: HTMLSelectElement | undefined;\n\n // Set up form reset handler\n createEffect(() => {\n const p = getProps();\n if (!selectRef) return;\n\n const form = selectRef.form;\n if (!form) return;\n\n const handleReset = () => {\n // Reset to default selected key (first key or null)\n const defaultKey = p.state.collection().getFirstKey();\n p.state.setSelectedKey(defaultKey);\n };\n\n form.addEventListener(\"reset\", handleReset);\n\n onCleanup(() => {\n form.removeEventListener(\"reset\", handleReset);\n });\n });\n\n // Set up form validation handler for native validation\n createEffect(() => {\n const p = getProps();\n if (!selectRef || p.validationBehavior !== \"native\" || !p.validationState) return;\n\n createFormValidation(\n {\n validationBehavior: p.validationBehavior,\n focus: () => p.triggerRef?.()?.focus(),\n },\n p.validationState,\n () => selectRef,\n );\n });\n\n return {\n get containerProps() {\n return {\n \"aria-hidden\": true,\n \"data-a11y-ignore\": \"aria-hidden-focus\",\n } as JSX.HTMLAttributes<HTMLDivElement>;\n },\n get selectProps() {\n const p = getProps();\n const state = p.state;\n const selectedKey = state.selectedKey();\n const selectedKeys =\n typeof state.selectedKeys === \"function\"\n ? state.selectedKeys()\n : selectedKey != null\n ? new Set([selectedKey])\n : new Set<Key>();\n const validationBehavior = p.validationBehavior ?? \"aria\";\n const isMultiple =\n typeof state.selectionMode === \"function\" && state.selectionMode() === \"multiple\";\n const multipleValue =\n selectedKeys === \"all\"\n ? Array.from(state.collection()).map((item) => String(item.key))\n : Array.from(selectedKeys).map(String);\n\n return {\n ref: (el: HTMLSelectElement) => {\n selectRef = el;\n },\n tabIndex: -1,\n autoComplete: p.autoComplete,\n disabled: p.isDisabled ?? state.isDisabled,\n multiple: isMultiple || undefined,\n name: p.name,\n form: p.form,\n // Add required attribute for native form validation\n required: validationBehavior === \"native\" && p.isRequired,\n value: isMultiple ? multipleValue : selectedKey != null ? String(selectedKey) : \"\",\n onChange: (e: Event) => {\n const target = e.target as HTMLSelectElement;\n if (isMultiple) {\n if (typeof state.setSelectedKeys === \"function\") {\n state.setSelectedKeys(Array.from(target.selectedOptions).map((o) => o.value as Key));\n } else {\n const first = target.selectedOptions[0]?.value;\n state.setSelectedKey((first ?? null) as Key | null);\n }\n } else {\n state.setSelectedKey(target.value as Key);\n }\n },\n style: {\n position: \"absolute\",\n top: 0,\n left: 0,\n width: \"100%\",\n height: \"100%\",\n opacity: 0,\n \"font-size\": \"16px\", // Prevents zoom on iOS\n border: \"none\",\n cursor: \"default\",\n margin: 0,\n padding: 0,\n \"pointer-events\": \"none\",\n },\n } as JSX.SelectHTMLAttributes<HTMLSelectElement>;\n },\n get inputProps() {\n const p = getProps();\n const state = p.state;\n const selectedKey = state.selectedKey();\n const validationBehavior = p.validationBehavior ?? \"aria\";\n\n // For native validation with required, use type=\"text\" with display:none\n // so the browser will validate it on form submit\n const useTextInput = validationBehavior === \"native\" && p.isRequired;\n\n return {\n type: useTextInput ? \"text\" : \"hidden\",\n name: p.name,\n form: p.form,\n value: selectedKey != null ? String(selectedKey) : \"\",\n disabled: p.isDisabled ?? state.isDisabled,\n required: useTextInput ? p.isRequired : undefined,\n style: useTextInput ? { display: \"none\" } : undefined,\n } as JSX.InputHTMLAttributes<HTMLInputElement>;\n },\n };\n}\n\nexport interface HiddenSelectProps<T> {\n /** The state object for the select. */\n state: SelectState<T>;\n /** The name attribute for the hidden select. */\n name?: string;\n /** Whether the select is disabled. */\n isDisabled?: boolean;\n /** Whether the select is required. */\n isRequired?: boolean;\n /** A ref to the trigger element. */\n triggerRef?: () => HTMLElement | null;\n /** Label for the select. */\n label?: string;\n /** Describes the type of autocomplete functionality the select should provide. */\n autoComplete?: string;\n /** The `form` attribute to associate the select with a form by ID. */\n form?: string;\n /** Validation behavior: 'aria' for realtime, 'native' for on submit. */\n validationBehavior?: ValidationBehavior;\n /** Form validation state (optional, for native validation). */\n validationState?: FormValidationState;\n}\n\n/**\n * A component that renders a hidden native select for form submission.\n * This is useful on mobile devices where native select behavior is preferred.\n */\nexport function HiddenSelect<T>(props: HiddenSelectProps<T>): JSX.Element {\n const { containerProps, selectProps } = createHiddenSelect({\n get state() {\n return props.state;\n },\n get name() {\n return props.name;\n },\n get isDisabled() {\n return props.isDisabled;\n },\n get isRequired() {\n return props.isRequired;\n },\n get autoComplete() {\n return props.autoComplete;\n },\n get form() {\n return props.form;\n },\n get validationBehavior() {\n return props.validationBehavior;\n },\n get triggerRef() {\n return props.triggerRef;\n },\n get validationState() {\n return props.validationState;\n },\n });\n\n const collection = () => props.state.collection();\n const selectedKey = () => props.state.selectedKey();\n const selectedKeys = () =>\n typeof props.state.selectedKeys === \"function\"\n ? props.state.selectedKeys()\n : selectedKey() != null\n ? new Set([selectedKey() as Key])\n : new Set<Key>();\n const isMultiple = () =>\n typeof props.state.selectionMode === \"function\" && props.state.selectionMode() === \"multiple\";\n\n return (\n <div {...containerProps}>\n <label>\n {props.label}\n <select {...selectProps}>\n <option />\n <For each={Array.from(collection())}>\n {(item) => (\n <option\n value={String(item.key)}\n selected={\n isMultiple()\n ? selectedKeys() === \"all\"\n ? true\n : (selectedKeys() as Set<Key>).has(item.key)\n : item.key === selectedKey()\n }\n >\n {item.textValue}\n </option>\n )}\n </For>\n </select>\n </label>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkFA,MAAM,6BAAa,IAAI,QAA4B;AAMnD,SAAgB,cAAc,OAA4C;CACxE,OAAO,WAAW,IAAI,KAAK;AAC7B;;;;AAKA,SAAgB,aACd,OACA,OACA,MACe;CACf,MAAM,iBAAiB,OAAO,KAAK;CACnC,MAAM,KAAK,SAAS,SAAS,CAAC,CAAC,EAAE;CAGjC,MAAM,WAAW,GAAG,GAAG;CACvB,MAAM,YAAY,GAAG,GAAG;CACxB,MAAM,UAAU,GAAG,GAAG;CACtB,MAAM,gBAAgB,GAAG,GAAG;CAC5B,MAAM,iBAAiB,GAAG,GAAG;CAG7B,MAAM,iBACJ,eAAe,SAAS,GAAyC,EAAE,WAAW,KAAK,CAAC;CAGtF,mBAAmB;EACjB,WAAW,IAAI,OAAO,EAAE,GAAG,CAAC;EAE5B,gBAAgB;GACd,WAAW,OAAO,KAAK;EACzB,CAAC;CACH,CAAC;CAGD,MAAM,EAAE,YAAY,eAAe,YAAY;EAC7C,IAAI,KAAK;GACP,OAAO;EACT;EACA,IAAI,QAAQ;GACV,OAAO,SAAS,CAAC,CAAC;EACpB;EACA,IAAI,eAAe;GACjB,OAAO,SAAS,CAAC,CAAC;EACpB;EACA,IAAI,oBAAoB;GACtB,OAAO,SAAS,CAAC,CAAC;EACpB;EACA,kBAAkB;CACpB,CAAC;CAGD,MAAM,EAAE,gBAAgB,eAAe,gBAAgB,EACrD,IAAI,YAAY;EACd,OAAO,SAAS,CAAC,CAAC;CACpB,EACF,CAAC;CAGD,MAAM,YAAY,MAAM;CAGxB,MAAM,gBACJ,SAAS,CA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KE,QAAQX,YAAY,CAAC,CAAA;IAAAqE,aAAAC,YAAAJ,OAAA,SANzBxD,OAAOD,KAAKE,GAAG,CAAC,CAAA;IAAA,OAAAuD;GAAA,EAAA,CAAA;EAW1B,CAAA,GAAAP,OAAAC,IAAA;EAAAY,mBAAA;EAAA,OAAA1B;CAAA,EAAA,CAAA;AAMb"}
|
|
1
|
+
{"version":3,"file":"select.js","names":["mergeProps","JSX","Accessor","For","createEffect","onCleanup","access","MaybeAccessor","createFormValidation","SelectState","Key","FormValidationState","ValidationBehavior","AriaHiddenSelectProps","state","T","name","isDisabled","isRequired","autoComplete","form","validationBehavior","triggerRef","HTMLElement","validationState","HiddenSelectAria","containerProps","HTMLAttributes","HTMLDivElement","selectProps","SelectHTMLAttributes","HTMLSelectElement","inputProps","InputHTMLAttributes","HTMLInputElement","createHiddenSelect","props","getProps","selectRef","p","handleReset","defaultKey","collection","getFirstKey","setSelectedKey","addEventListener","removeEventListener","focus","selectedKey","selectedKeys","Set","isMultiple","selectionMode","multipleValue","Array","from","map","item","String","key","ref","el","tabIndex","disabled","multiple","undefined","required","value","onChange","e","Event","target","setSelectedKeys","selectedOptions","o","first","style","position","top","left","width","height","opacity","border","cursor","margin","padding","useTextInput","type","display","HiddenSelectProps","label","HiddenSelect","Element","_el$","_$getNextElement","_tmpl$","_el$2","firstChild","_el$7","_el$8","_co$2","_$getNextMarker","nextSibling","_el$3","_el$4","_el$5","_el$6","_co$","_$spread","_$insert","_$createComponent","each","children","_el$9","_tmpl$2","textValue","_$effect","_$setProperty","has","_$runHydrationEvents"],"sources":["../../src/select/createSelect.ts","../../src/select/createHiddenSelect.tsx"],"sourcesContent":["/**\n * Provides the behavior and accessibility implementation for a select component.\n * A select displays a collapsible list of options and allows a user to select one of them.\n * Based on @react-aria/select useSelect.\n */\n\nimport { type JSX, type Accessor, createEffect, onCleanup } from \"solid-js\";\nimport { createPress } from \"../interactions/createPress\";\nimport { createFocusRing } from \"../interactions/createFocusRing\";\nimport { createLabel } from \"../label/createLabel\";\nimport { createTypeSelect } from \"../selection/createTypeSelect\";\nimport { filterDOMProps } from \"../utils/filterDOMProps\";\nimport { mergeProps } from \"../utils/mergeProps\";\nimport { createId } from \"../ssr\";\nimport { access, type MaybeAccessor } from \"../utils/reactivity\";\nimport type { SelectState, CollectionNode } from \"@proyecto-viviana/solid-stately\";\n\nexport interface AriaSelectProps {\n /** An ID for the select. */\n id?: string;\n /** Whether the select is disabled. */\n isDisabled?: boolean;\n /** Whether the select is required. */\n isRequired?: boolean;\n /** Whether the select is invalid. */\n isInvalid?: boolean;\n /** The label for the select. */\n label?: JSX.Element;\n /** An accessible label for the select when no visible label is provided. */\n \"aria-label\"?: string;\n /** The ID of an element that labels the select. */\n \"aria-labelledby\"?: string;\n /** The ID of an element that describes the select. */\n \"aria-describedby\"?: string;\n /** Placeholder text when no option is selected. */\n placeholder?: string;\n /** Whether the select should be auto-focused. */\n autoFocus?: boolean;\n /** Handler called when focus moves to the select. */\n onFocus?: (e: FocusEvent) => void;\n /** Handler called when focus moves away from the select. */\n onBlur?: (e: FocusEvent) => void;\n /** Handler called when the focus state changes. */\n onFocusChange?: (isFocused: boolean) => void;\n /** The name of the select, used when submitting an HTML form. */\n name?: string;\n /** Associates the hidden native select with a form element by id. */\n form?: string;\n /** Whether type-to-select is disabled. @default false */\n disallowTypeAhead?: boolean;\n /** Whether the select can open when its collection is empty. @default false */\n allowsEmptyCollection?: boolean;\n /** Whether validation should use ARIA attributes or native browser validation. */\n validationBehavior?: \"aria\" | \"native\";\n}\n\nexport interface SelectAria<T> {\n /** Props for the label element. */\n labelProps: JSX.HTMLAttributes<HTMLElement>;\n /** Props for the trigger button element. */\n triggerProps: JSX.HTMLAttributes<HTMLElement>;\n /** Props for the value display element. */\n valueProps: JSX.HTMLAttributes<HTMLElement>;\n /** Props for the listbox/menu popup. */\n menuProps: JSX.HTMLAttributes<HTMLElement>;\n /** Props for the description element, if any. */\n descriptionProps: JSX.HTMLAttributes<HTMLElement>;\n /** Props for the error message element, if any. */\n errorMessageProps: JSX.HTMLAttributes<HTMLElement>;\n /** Whether the select is currently focused. */\n isFocused: Accessor<boolean>;\n /** Whether the select has keyboard focus. */\n isFocusVisible: Accessor<boolean>;\n /** Whether the select is currently open. */\n isOpen: Accessor<boolean>;\n /** Whether the trigger button is currently pressed (for `pressScale`). */\n isPressed: Accessor<boolean>;\n /** The currently selected item. */\n selectedItem: Accessor<CollectionNode<T> | null>;\n}\n\n// Shared data between select and options\nconst selectData = new WeakMap<object, SelectData>();\n\ninterface SelectData {\n id: string;\n}\n\nexport function getSelectData(state: SelectState): SelectData | undefined {\n return selectData.get(state);\n}\n\n/**\n * Provides the behavior and accessibility implementation for a select component.\n */\nexport function createSelect<T>(\n props: MaybeAccessor<AriaSelectProps>,\n state: SelectState<T>,\n _ref?: () => HTMLElement | null,\n): SelectAria<T> {\n const getProps = () => access(props);\n const id = createId(getProps().id);\n\n // Generate IDs for associated elements\n const buttonId = `${id}-button`;\n const listBoxId = `${id}-listbox`;\n const valueId = `${id}-value`;\n const descriptionId = `${id}-description`;\n const errorMessageId = `${id}-error`;\n\n // Filter DOM props\n const domProps = () =>\n filterDOMProps(getProps() as unknown as Record<string, unknown>, { labelable: true });\n\n // Share data with child options\n createEffect(() => {\n selectData.set(state, { id });\n\n onCleanup(() => {\n selectData.delete(state);\n });\n });\n\n // Label handling\n const { labelProps, fieldProps } = createLabel({\n get id() {\n return buttonId;\n },\n get label() {\n return getProps().label;\n },\n get \"aria-label\"() {\n return getProps()[\"aria-label\"];\n },\n get \"aria-labelledby\"() {\n return getProps()[\"aria-labelledby\"];\n },\n labelElementType: \"span\",\n });\n\n // Focus ring for keyboard focus styling\n const { isFocusVisible, focusProps } = createFocusRing({\n get autoFocus() {\n return getProps().autoFocus;\n },\n });\n\n // Track focus state\n const isFocused = state.isFocused;\n\n // Handle press on trigger\n const canOpen = () =>\n getProps().allowsEmptyCollection || state.collection().getFirstKey() != null;\n\n // Helper to check if key is disabled\n const isKeyDisabled = (key: string | number): boolean => {\n const collection = state.collection();\n return state.isKeyDisabled?.(key) || collection.getItem(key)?.isDisabled || false;\n };\n\n // Helper to find the next non-disabled key.\n const findNextKey = (\n fromKey: string | number | null,\n direction: \"forward\" | \"backward\",\n ): string | number | null => {\n const collection = state.collection();\n const getAdjacent =\n direction === \"forward\"\n ? (k: string | number) => collection.getKeyAfter(k)\n : (k: string | number) => collection.getKeyBefore(k);\n const getBoundary =\n direction === \"forward\" ? () => collection.getFirstKey() : () => collection.getLastKey();\n\n let key = fromKey == null ? getBoundary() : getAdjacent(fromKey);\n while (key != null && isKeyDisabled(key)) {\n key = getAdjacent(key);\n }\n\n return key;\n };\n\n const focusKeyForOpen = (): string | number | null => {\n const selectedKey = state.selectedKey();\n if (selectedKey != null && !isKeyDisabled(selectedKey)) {\n return selectedKey;\n }\n return findNextKey(null, \"forward\");\n };\n\n const openWithFocus = () => {\n if (state.isOpen() || !canOpen()) {\n return;\n }\n state.open();\n const focusKey = focusKeyForOpen();\n if (focusKey != null) {\n state.setFocusedKey(focusKey);\n }\n };\n\n const { pressProps, isPressed } = createPress({\n get isDisabled() {\n return getProps().isDisabled ?? state.isDisabled;\n },\n onPress(e) {\n if (e.pointerType === \"keyboard\") {\n return;\n }\n\n if (state.isOpen()) {\n state.close();\n } else {\n openWithFocus();\n }\n },\n });\n\n // Type-to-select - for Select, typing directly selects items when closed\n const { typeSelectProps } = createTypeSelect({\n collection: () => state.collection(),\n focusedKey: () => state.selectedKey(), // Use selectedKey as the \"focused\" key for closed Select\n onFocusedKeyChange: (key) => {\n // When closed, type-to-select directly changes selection\n if (!state.isOpen()) {\n state.setSelectedKey(key);\n } else {\n // When open, update focused key (listbox handles selection)\n state.setFocusedKey(key);\n }\n },\n isKeyDisabled,\n get isDisabled() {\n return Boolean(\n (getProps().disallowTypeAhead ?? false) || getProps().isDisabled || state.isDisabled,\n );\n },\n });\n\n // Keyboard navigation\n const onKeyDown: JSX.EventHandler<HTMLElement, KeyboardEvent> = (e) => {\n if (getProps().isDisabled ?? state.isDisabled) return;\n\n const currentKey = state.focusedKey() ?? state.selectedKey();\n\n switch (e.key) {\n case \"Enter\":\n case \" \":\n e.preventDefault();\n if (state.isOpen()) {\n state.close();\n } else {\n openWithFocus();\n }\n break;\n\n case \"ArrowDown\":\n e.preventDefault();\n if (!state.isOpen()) {\n if (!canOpen()) {\n return;\n }\n // ArrowDown: Open the dropdown and focus first/selected item\n state.open();\n const focusKey =\n currentKey != null && !isKeyDisabled(currentKey)\n ? currentKey\n : findNextKey(currentKey, \"forward\");\n if (focusKey) {\n state.setFocusedKey(focusKey);\n }\n }\n // When open, navigation is handled by the listbox\n break;\n\n case \"ArrowUp\":\n e.preventDefault();\n if (!state.isOpen()) {\n if (!canOpen()) {\n return;\n }\n // ArrowUp: Open the dropdown and focus last/selected item\n state.open();\n const focusKey =\n currentKey != null && !isKeyDisabled(currentKey)\n ? currentKey\n : findNextKey(currentKey, \"backward\");\n if (focusKey) {\n state.setFocusedKey(focusKey);\n }\n }\n // When open, navigation is handled by the listbox\n break;\n\n case \"ArrowRight\":\n // ArrowRight: Select next option (for horizontal keyboard navigation pattern)\n if (!state.isOpen()) {\n e.preventDefault();\n const nextKey = findNextKey(currentKey, \"forward\");\n if (nextKey != null) {\n state.setSelectedKey(nextKey);\n }\n }\n break;\n\n case \"ArrowLeft\":\n // ArrowLeft: Select previous option (for horizontal keyboard navigation pattern)\n if (!state.isOpen()) {\n e.preventDefault();\n const prevKey = findNextKey(currentKey, \"backward\");\n if (prevKey != null) {\n state.setSelectedKey(prevKey);\n }\n }\n break;\n\n case \"Home\":\n // Home: Select first option\n if (!state.isOpen()) {\n e.preventDefault();\n const firstKey = findNextKey(null, \"forward\");\n if (firstKey != null) {\n state.setSelectedKey(firstKey);\n }\n }\n break;\n\n case \"End\":\n // End: Select last option\n if (!state.isOpen()) {\n e.preventDefault();\n const lastKey = findNextKey(null, \"backward\");\n if (lastKey != null) {\n state.setSelectedKey(lastKey);\n }\n }\n break;\n\n case \"Escape\":\n if (state.isOpen()) {\n e.preventDefault();\n state.close();\n }\n break;\n }\n };\n\n // Handle focus events\n const handleFocus = (e: FocusEvent) => {\n getProps().onFocus?.(e);\n getProps().onFocusChange?.(true);\n state.setFocused(true);\n };\n\n const handleBlur = (e: FocusEvent) => {\n // Focus moving into the open listbox is not a select blur; the menu's own\n // onBlur clears the state when focus leaves the listbox entirely.\n if (state.isOpen()) {\n return;\n }\n\n getProps().onBlur?.(e);\n getProps().onFocusChange?.(false);\n state.setFocused(false);\n };\n\n return {\n get labelProps() {\n return labelProps as JSX.HTMLAttributes<HTMLElement>;\n },\n get triggerProps() {\n const p = getProps();\n const isOpen = state.isOpen();\n const isDisabled = p.isDisabled ?? state.isDisabled;\n\n const baseProps = mergeProps(\n domProps(),\n pressProps as Record<string, unknown>,\n focusProps as Record<string, unknown>,\n fieldProps as Record<string, unknown>,\n {\n id: buttonId,\n type: \"button\",\n tabIndex: isDisabled ? undefined : 0,\n \"aria-haspopup\": \"listbox\",\n \"aria-expanded\": isOpen,\n \"aria-controls\": isOpen ? listBoxId : undefined,\n \"aria-disabled\": isDisabled || undefined,\n \"aria-required\": p.isRequired || undefined,\n \"aria-describedby\": p[\"aria-describedby\"] || undefined,\n // Mirror upstream `useSelect` exactly: the trigger name starts with\n // the selected value, then the visible label. When only `aria-label`\n // is present, the trigger references itself so that label follows the\n // value as well (\"Pro Plan\"), rather than masking visible text.\n \"aria-labelledby\": [\n valueId,\n fieldProps[\"aria-labelledby\"],\n fieldProps[\"aria-label\"] && !fieldProps[\"aria-labelledby\"] ? fieldProps.id : undefined,\n ]\n .filter(Boolean)\n .join(\" \"),\n onKeyDown,\n onFocus: handleFocus,\n onBlur: handleBlur,\n \"data-open\": isOpen || undefined,\n \"data-disabled\": isDisabled || undefined,\n \"data-focus-visible\": isFocusVisible() || undefined,\n } as Record<string, unknown>,\n );\n\n // Add type-select props if enabled\n if (!p.disallowTypeAhead) {\n return mergeProps(\n baseProps,\n typeSelectProps as Record<string, unknown>,\n ) as JSX.HTMLAttributes<HTMLElement>;\n }\n\n return baseProps as JSX.HTMLAttributes<HTMLElement>;\n },\n get valueProps() {\n return {\n id: valueId,\n } as JSX.HTMLAttributes<HTMLElement>;\n },\n // Surfaced so the styled layer (S2 Picker) can apply the `pressScale` press\n // effect on the trigger button — upstream S2 wires `pressScale(buttonRef)` on\n // the RAC Button, which needs the button's live `isPressed`.\n isPressed,\n get menuProps() {\n return {\n id: listBoxId,\n role: \"listbox\",\n // Mirror upstream `useSelect`: a visible field label names the listbox;\n // the trigger is the fallback only for the `aria-label` branch.\n \"aria-labelledby\": [\n fieldProps[\"aria-labelledby\"],\n fieldProps[\"aria-label\"] && !fieldProps[\"aria-labelledby\"] ? fieldProps.id : undefined,\n ]\n .filter(Boolean)\n .join(\" \"),\n \"aria-multiselectable\": state.selectionMode() === \"multiple\" ? true : undefined,\n tabIndex: -1,\n onBlur: (e: FocusEvent) => {\n // Only a blur that leaves the listbox entirely blurs the select.\n if ((e.currentTarget as Node | null)?.contains(e.relatedTarget as Node)) {\n return;\n }\n\n getProps().onBlur?.(e);\n getProps().onFocusChange?.(false);\n state.setFocused(false);\n },\n } as JSX.HTMLAttributes<HTMLElement>;\n },\n get descriptionProps() {\n return {\n id: descriptionId,\n } as JSX.HTMLAttributes<HTMLElement>;\n },\n get errorMessageProps() {\n return {\n id: errorMessageId,\n } as JSX.HTMLAttributes<HTMLElement>;\n },\n isFocused,\n isFocusVisible: () => isFocused() && isFocusVisible(),\n isOpen: state.isOpen,\n selectedItem: state.selectedItem,\n };\n}\n","/**\n * Provides a hidden native select element for form integration.\n * Based on @react-aria/select useHiddenSelect.\n */\n\nimport { type JSX, type Accessor, For, createEffect, onCleanup } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils/reactivity\";\nimport { createFormValidation } from \"../form/createFormValidation\";\nimport type { SelectState, Key, FormValidationState } from \"@proyecto-viviana/solid-stately\";\n\nexport type ValidationBehavior = \"aria\" | \"native\";\n\nexport interface AriaHiddenSelectProps<T> {\n /** The state object for the select. */\n state: SelectState<T>;\n /** The name attribute for the hidden select. */\n name?: string;\n /** Whether the select is disabled. */\n isDisabled?: boolean;\n /** Whether the select is required. */\n isRequired?: boolean;\n /** Describes the type of autocomplete functionality the select should provide. */\n autoComplete?: string;\n /** The `form` attribute to associate the select with a form by ID. */\n form?: string;\n /** Validation behavior: 'aria' for realtime, 'native' for on submit. */\n validationBehavior?: ValidationBehavior;\n /** A ref to the trigger element for focus on validation error. */\n triggerRef?: Accessor<HTMLElement | null>;\n /** Form validation state (optional, for native validation). */\n validationState?: FormValidationState;\n}\n\nexport interface HiddenSelectAria {\n /** Props for the container element. */\n containerProps: JSX.HTMLAttributes<HTMLDivElement>;\n /** Props for the hidden select element. */\n selectProps: JSX.SelectHTMLAttributes<HTMLSelectElement>;\n /** Props for the hidden input element (for form submission). */\n inputProps: JSX.InputHTMLAttributes<HTMLInputElement>;\n}\n\n/**\n * Provides the accessibility implementation for a hidden select.\n * This is used for native form submission and accessibility on mobile devices.\n */\nexport function createHiddenSelect<T>(\n props: MaybeAccessor<AriaHiddenSelectProps<T>>,\n): HiddenSelectAria {\n const getProps = () => access(props);\n\n // Track the select element for form reset/validation\n let selectRef: HTMLSelectElement | undefined;\n\n // Set up form reset handler\n createEffect(() => {\n const p = getProps();\n if (!selectRef) return;\n\n const form = selectRef.form;\n if (!form) return;\n\n const handleReset = () => {\n // Reset to default selected key (first key or null)\n const defaultKey = p.state.collection().getFirstKey();\n p.state.setSelectedKey(defaultKey);\n };\n\n form.addEventListener(\"reset\", handleReset);\n\n onCleanup(() => {\n form.removeEventListener(\"reset\", handleReset);\n });\n });\n\n // Set up form validation handler for native validation\n createEffect(() => {\n const p = getProps();\n if (!selectRef || p.validationBehavior !== \"native\" || !p.validationState) return;\n\n createFormValidation(\n {\n validationBehavior: p.validationBehavior,\n focus: () => p.triggerRef?.()?.focus(),\n },\n p.validationState,\n () => selectRef,\n );\n });\n\n return {\n get containerProps() {\n return {\n \"aria-hidden\": true,\n \"data-a11y-ignore\": \"aria-hidden-focus\",\n } as JSX.HTMLAttributes<HTMLDivElement>;\n },\n get selectProps() {\n const p = getProps();\n const state = p.state;\n const selectedKey = state.selectedKey();\n const selectedKeys =\n typeof state.selectedKeys === \"function\"\n ? state.selectedKeys()\n : selectedKey != null\n ? new Set([selectedKey])\n : new Set<Key>();\n const validationBehavior = p.validationBehavior ?? \"aria\";\n const isMultiple =\n typeof state.selectionMode === \"function\" && state.selectionMode() === \"multiple\";\n const multipleValue =\n selectedKeys === \"all\"\n ? Array.from(state.collection()).map((item) => String(item.key))\n : Array.from(selectedKeys).map(String);\n\n return {\n ref: (el: HTMLSelectElement) => {\n selectRef = el;\n },\n tabIndex: -1,\n autoComplete: p.autoComplete,\n disabled: p.isDisabled ?? state.isDisabled,\n multiple: isMultiple || undefined,\n name: p.name,\n form: p.form,\n // Add required attribute for native form validation\n required: validationBehavior === \"native\" && p.isRequired,\n value: isMultiple ? multipleValue : selectedKey != null ? String(selectedKey) : \"\",\n onChange: (e: Event) => {\n const target = e.target as HTMLSelectElement;\n if (isMultiple) {\n if (typeof state.setSelectedKeys === \"function\") {\n state.setSelectedKeys(Array.from(target.selectedOptions).map((o) => o.value as Key));\n } else {\n const first = target.selectedOptions[0]?.value;\n state.setSelectedKey((first ?? null) as Key | null);\n }\n } else {\n state.setSelectedKey(target.value as Key);\n }\n },\n style: {\n position: \"absolute\",\n top: 0,\n left: 0,\n width: \"100%\",\n height: \"100%\",\n opacity: 0,\n \"font-size\": \"16px\", // Prevents zoom on iOS\n border: \"none\",\n cursor: \"default\",\n margin: 0,\n padding: 0,\n \"pointer-events\": \"none\",\n },\n } as JSX.SelectHTMLAttributes<HTMLSelectElement>;\n },\n get inputProps() {\n const p = getProps();\n const state = p.state;\n const selectedKey = state.selectedKey();\n const validationBehavior = p.validationBehavior ?? \"aria\";\n\n // For native validation with required, use type=\"text\" with display:none\n // so the browser will validate it on form submit\n const useTextInput = validationBehavior === \"native\" && p.isRequired;\n\n return {\n type: useTextInput ? \"text\" : \"hidden\",\n name: p.name,\n form: p.form,\n value: selectedKey != null ? String(selectedKey) : \"\",\n disabled: p.isDisabled ?? state.isDisabled,\n required: useTextInput ? p.isRequired : undefined,\n style: useTextInput ? { display: \"none\" } : undefined,\n } as JSX.InputHTMLAttributes<HTMLInputElement>;\n },\n };\n}\n\nexport interface HiddenSelectProps<T> {\n /** The state object for the select. */\n state: SelectState<T>;\n /** The name attribute for the hidden select. */\n name?: string;\n /** Whether the select is disabled. */\n isDisabled?: boolean;\n /** Whether the select is required. */\n isRequired?: boolean;\n /** A ref to the trigger element. */\n triggerRef?: () => HTMLElement | null;\n /** Label for the select. */\n label?: string;\n /** Describes the type of autocomplete functionality the select should provide. */\n autoComplete?: string;\n /** The `form` attribute to associate the select with a form by ID. */\n form?: string;\n /** Validation behavior: 'aria' for realtime, 'native' for on submit. */\n validationBehavior?: ValidationBehavior;\n /** Form validation state (optional, for native validation). */\n validationState?: FormValidationState;\n}\n\n/**\n * A component that renders a hidden native select for form submission.\n * This is useful on mobile devices where native select behavior is preferred.\n */\nexport function HiddenSelect<T>(props: HiddenSelectProps<T>): JSX.Element {\n const { containerProps, selectProps } = createHiddenSelect({\n get state() {\n return props.state;\n },\n get name() {\n return props.name;\n },\n get isDisabled() {\n return props.isDisabled;\n },\n get isRequired() {\n return props.isRequired;\n },\n get autoComplete() {\n return props.autoComplete;\n },\n get form() {\n return props.form;\n },\n get validationBehavior() {\n return props.validationBehavior;\n },\n get triggerRef() {\n return props.triggerRef;\n },\n get validationState() {\n return props.validationState;\n },\n });\n\n const collection = () => props.state.collection();\n const selectedKey = () => props.state.selectedKey();\n const selectedKeys = () =>\n typeof props.state.selectedKeys === \"function\"\n ? props.state.selectedKeys()\n : selectedKey() != null\n ? new Set([selectedKey() as Key])\n : new Set<Key>();\n const isMultiple = () =>\n typeof props.state.selectionMode === \"function\" && props.state.selectionMode() === \"multiple\";\n\n return (\n <div {...containerProps}>\n <label>\n {props.label}\n <select {...selectProps}>\n <option />\n <For each={Array.from(collection())}>\n {(item) => (\n <option\n value={String(item.key)}\n selected={\n isMultiple()\n ? selectedKeys() === \"all\"\n ? true\n : (selectedKeys() as Set<Key>).has(item.key)\n : item.key === selectedKey()\n }\n >\n {item.textValue}\n </option>\n )}\n </For>\n </select>\n </label>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkFA,MAAM,6BAAa,IAAI,QAA4B;AAMnD,SAAgB,cAAc,OAA4C;CACxE,OAAO,WAAW,IAAI,KAAK;AAC7B;;;;AAKA,SAAgB,aACd,OACA,OACA,MACe;CACf,MAAM,iBAAiB,OAAO,KAAK;CACnC,MAAM,KAAK,SAAS,SAAS,CAAC,CAAC,EAAE;CAGjC,MAAM,WAAW,GAAG,GAAG;CACvB,MAAM,YAAY,GAAG,GAAG;CACxB,MAAM,UAAU,GAAG,GAAG;CACtB,MAAM,gBAAgB,GAAG,GAAG;CAC5B,MAAM,iBAAiB,GAAG,GAAG;CAG7B,MAAM,iBACJ,eAAe,SAAS,GAAyC,EAAE,WAAW,KAAK,CAAC;CAGtF,mBAAmB;EACjB,WAAW,IAAI,OAAO,EAAE,GAAG,CAAC;EAE5B,gBAAgB;GACd,WAAW,OAAO,KAAK;EACzB,CAAC;CACH,CAAC;CAGD,MAAM,EAAE,YAAY,eAAe,YAAY;EAC7C,IAAI,KAAK;GACP,OAAO;EACT;EACA,IAAI,QAAQ;GACV,OAAO,SAAS,CAAC,CAAC;EACpB;EACA,IAAI,eAAe;GACjB,OAAO,SAAS,CAAC,CAAC;EACpB;EACA,IAAI,oBAAoB;GACtB,OAAO,SAAS,CAAC,CAAC;EACpB;EACA,kBAAkB;CACpB,CAAC;CAGD,MAAM,EAAE,gBAAgB,eAAe,gBAAgB,EACrD,IAAI,YAAY;EACd,OAAO,SAAS,CAAC,CAAC;CACpB,EACF,CAAC;CAGD,MAAM,YAAY,MAAM;CAGxB,MAAM,gBACJ,SAAS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K2D,SAAS;IAAAC,aAAAC,YAAAJ,OAAA,YAPb/D,WAAW,IACPF,aAAa,MAAM,QACjB,OACCA,aAAa,CAAC,CAAcsE,IAAI9D,KAAKE,GAAG,IAC3CF,KAAKE,QAAQX,YAAY,CAAC,CAAA;IAAAqE,aAAAC,YAAAJ,OAAA,SANzBxD,OAAOD,KAAKE,GAAG,CAAC,CAAA;IAAA,OAAAuD;GAAA,EAAA,CAAA;EAW1B,CAAA,GAAAP,OAAAC,IAAA;EAAAY,mBAAA;EAAA,OAAA1B;CAAA,EAAA,CAAA;AAMb"}
|
package/dist/_chunk/select.jsx
CHANGED
|
@@ -193,7 +193,11 @@ function createSelect(props, state, _ref) {
|
|
|
193
193
|
"aria-disabled": isDisabled || void 0,
|
|
194
194
|
"aria-required": p.isRequired || void 0,
|
|
195
195
|
"aria-describedby": p["aria-describedby"] || void 0,
|
|
196
|
-
"aria-labelledby":
|
|
196
|
+
"aria-labelledby": [
|
|
197
|
+
valueId,
|
|
198
|
+
fieldProps["aria-labelledby"],
|
|
199
|
+
fieldProps["aria-label"] && !fieldProps["aria-labelledby"] ? fieldProps.id : void 0
|
|
200
|
+
].filter(Boolean).join(" "),
|
|
197
201
|
onKeyDown,
|
|
198
202
|
onFocus: handleFocus,
|
|
199
203
|
onBlur: handleBlur,
|
|
@@ -212,7 +216,7 @@ function createSelect(props, state, _ref) {
|
|
|
212
216
|
return {
|
|
213
217
|
id: listBoxId,
|
|
214
218
|
role: "listbox",
|
|
215
|
-
"aria-labelledby": fieldProps["aria-labelledby"]
|
|
219
|
+
"aria-labelledby": [fieldProps["aria-labelledby"], fieldProps["aria-label"] && !fieldProps["aria-labelledby"] ? fieldProps.id : void 0].filter(Boolean).join(" "),
|
|
216
220
|
"aria-multiselectable": state.selectionMode() === "multiple" ? true : void 0,
|
|
217
221
|
tabIndex: -1,
|
|
218
222
|
onBlur: (e) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.jsx","names":["mergeProps"],"sources":["../../src/select/createSelect.ts","../../src/select/createHiddenSelect.tsx"],"sourcesContent":["/**\n * Provides the behavior and accessibility implementation for a select component.\n * A select displays a collapsible list of options and allows a user to select one of them.\n * Based on @react-aria/select useSelect.\n */\n\nimport { type JSX, type Accessor, createEffect, onCleanup } from \"solid-js\";\nimport { createPress } from \"../interactions/createPress\";\nimport { createFocusRing } from \"../interactions/createFocusRing\";\nimport { createLabel } from \"../label/createLabel\";\nimport { createTypeSelect } from \"../selection/createTypeSelect\";\nimport { filterDOMProps } from \"../utils/filterDOMProps\";\nimport { mergeProps } from \"../utils/mergeProps\";\nimport { createId } from \"../ssr\";\nimport { access, type MaybeAccessor } from \"../utils/reactivity\";\nimport type { SelectState, CollectionNode } from \"@proyecto-viviana/solid-stately\";\n\nexport interface AriaSelectProps {\n /** An ID for the select. */\n id?: string;\n /** Whether the select is disabled. */\n isDisabled?: boolean;\n /** Whether the select is required. */\n isRequired?: boolean;\n /** Whether the select is invalid. */\n isInvalid?: boolean;\n /** The label for the select. */\n label?: JSX.Element;\n /** An accessible label for the select when no visible label is provided. */\n \"aria-label\"?: string;\n /** The ID of an element that labels the select. */\n \"aria-labelledby\"?: string;\n /** The ID of an element that describes the select. */\n \"aria-describedby\"?: string;\n /** Placeholder text when no option is selected. */\n placeholder?: string;\n /** Whether the select should be auto-focused. */\n autoFocus?: boolean;\n /** Handler called when focus moves to the select. */\n onFocus?: (e: FocusEvent) => void;\n /** Handler called when focus moves away from the select. */\n onBlur?: (e: FocusEvent) => void;\n /** Handler called when the focus state changes. */\n onFocusChange?: (isFocused: boolean) => void;\n /** The name of the select, used when submitting an HTML form. */\n name?: string;\n /** Associates the hidden native select with a form element by id. */\n form?: string;\n /** Whether type-to-select is disabled. @default false */\n disallowTypeAhead?: boolean;\n /** Whether the select can open when its collection is empty. @default false */\n allowsEmptyCollection?: boolean;\n /** Whether validation should use ARIA attributes or native browser validation. */\n validationBehavior?: \"aria\" | \"native\";\n}\n\nexport interface SelectAria<T> {\n /** Props for the label element. */\n labelProps: JSX.HTMLAttributes<HTMLElement>;\n /** Props for the trigger button element. */\n triggerProps: JSX.HTMLAttributes<HTMLElement>;\n /** Props for the value display element. */\n valueProps: JSX.HTMLAttributes<HTMLElement>;\n /** Props for the listbox/menu popup. */\n menuProps: JSX.HTMLAttributes<HTMLElement>;\n /** Props for the description element, if any. */\n descriptionProps: JSX.HTMLAttributes<HTMLElement>;\n /** Props for the error message element, if any. */\n errorMessageProps: JSX.HTMLAttributes<HTMLElement>;\n /** Whether the select is currently focused. */\n isFocused: Accessor<boolean>;\n /** Whether the select has keyboard focus. */\n isFocusVisible: Accessor<boolean>;\n /** Whether the select is currently open. */\n isOpen: Accessor<boolean>;\n /** Whether the trigger button is currently pressed (for `pressScale`). */\n isPressed: Accessor<boolean>;\n /** The currently selected item. */\n selectedItem: Accessor<CollectionNode<T> | null>;\n}\n\n// Shared data between select and options\nconst selectData = new WeakMap<object, SelectData>();\n\ninterface SelectData {\n id: string;\n}\n\nexport function getSelectData(state: SelectState): SelectData | undefined {\n return selectData.get(state);\n}\n\n/**\n * Provides the behavior and accessibility implementation for a select component.\n */\nexport function createSelect<T>(\n props: MaybeAccessor<AriaSelectProps>,\n state: SelectState<T>,\n _ref?: () => HTMLElement | null,\n): SelectAria<T> {\n const getProps = () => access(props);\n const id = createId(getProps().id);\n\n // Generate IDs for associated elements\n const buttonId = `${id}-button`;\n const listBoxId = `${id}-listbox`;\n const valueId = `${id}-value`;\n const descriptionId = `${id}-description`;\n const errorMessageId = `${id}-error`;\n\n // Filter DOM props\n const domProps = () =>\n filterDOMProps(getProps() as unknown as Record<string, unknown>, { labelable: true });\n\n // Share data with child options\n createEffect(() => {\n selectData.set(state, { id });\n\n onCleanup(() => {\n selectData.delete(state);\n });\n });\n\n // Label handling\n const { labelProps, fieldProps } = createLabel({\n get id() {\n return buttonId;\n },\n get label() {\n return getProps().label;\n },\n get \"aria-label\"() {\n return getProps()[\"aria-label\"];\n },\n get \"aria-labelledby\"() {\n return getProps()[\"aria-labelledby\"];\n },\n labelElementType: \"span\",\n });\n\n // Focus ring for keyboard focus styling\n const { isFocusVisible, focusProps } = createFocusRing({\n get autoFocus() {\n return getProps().autoFocus;\n },\n });\n\n // Track focus state\n const isFocused = state.isFocused;\n\n // Handle press on trigger\n const canOpen = () =>\n getProps().allowsEmptyCollection || state.collection().getFirstKey() != null;\n\n // Helper to check if key is disabled\n const isKeyDisabled = (key: string | number): boolean => {\n const collection = state.collection();\n return state.isKeyDisabled?.(key) || collection.getItem(key)?.isDisabled || false;\n };\n\n // Helper to find the next non-disabled key.\n const findNextKey = (\n fromKey: string | number | null,\n direction: \"forward\" | \"backward\",\n ): string | number | null => {\n const collection = state.collection();\n const getAdjacent =\n direction === \"forward\"\n ? (k: string | number) => collection.getKeyAfter(k)\n : (k: string | number) => collection.getKeyBefore(k);\n const getBoundary =\n direction === \"forward\" ? () => collection.getFirstKey() : () => collection.getLastKey();\n\n let key = fromKey == null ? getBoundary() : getAdjacent(fromKey);\n while (key != null && isKeyDisabled(key)) {\n key = getAdjacent(key);\n }\n\n return key;\n };\n\n const focusKeyForOpen = (): string | number | null => {\n const selectedKey = state.selectedKey();\n if (selectedKey != null && !isKeyDisabled(selectedKey)) {\n return selectedKey;\n }\n return findNextKey(null, \"forward\");\n };\n\n const openWithFocus = () => {\n if (state.isOpen() || !canOpen()) {\n return;\n }\n state.open();\n const focusKey = focusKeyForOpen();\n if (focusKey != null) {\n state.setFocusedKey(focusKey);\n }\n };\n\n const { pressProps, isPressed } = createPress({\n get isDisabled() {\n return getProps().isDisabled ?? state.isDisabled;\n },\n onPress(e) {\n if (e.pointerType === \"keyboard\") {\n return;\n }\n\n if (state.isOpen()) {\n state.close();\n } else {\n openWithFocus();\n }\n },\n });\n\n // Type-to-select - for Select, typing directly selects items when closed\n const { typeSelectProps } = createTypeSelect({\n collection: () => state.collection(),\n focusedKey: () => state.selectedKey(), // Use selectedKey as the \"focused\" key for closed Select\n onFocusedKeyChange: (key) => {\n // When closed, type-to-select directly changes selection\n if (!state.isOpen()) {\n state.setSelectedKey(key);\n } else {\n // When open, update focused key (listbox handles selection)\n state.setFocusedKey(key);\n }\n },\n isKeyDisabled,\n get isDisabled() {\n return Boolean(\n (getProps().disallowTypeAhead ?? false) || getProps().isDisabled || state.isDisabled,\n );\n },\n });\n\n // Keyboard navigation\n const onKeyDown: JSX.EventHandler<HTMLElement, KeyboardEvent> = (e) => {\n if (getProps().isDisabled ?? state.isDisabled) return;\n\n const currentKey = state.focusedKey() ?? state.selectedKey();\n\n switch (e.key) {\n case \"Enter\":\n case \" \":\n e.preventDefault();\n if (state.isOpen()) {\n state.close();\n } else {\n openWithFocus();\n }\n break;\n\n case \"ArrowDown\":\n e.preventDefault();\n if (!state.isOpen()) {\n if (!canOpen()) {\n return;\n }\n // ArrowDown: Open the dropdown and focus first/selected item\n state.open();\n const focusKey =\n currentKey != null && !isKeyDisabled(currentKey)\n ? currentKey\n : findNextKey(currentKey, \"forward\");\n if (focusKey) {\n state.setFocusedKey(focusKey);\n }\n }\n // When open, navigation is handled by the listbox\n break;\n\n case \"ArrowUp\":\n e.preventDefault();\n if (!state.isOpen()) {\n if (!canOpen()) {\n return;\n }\n // ArrowUp: Open the dropdown and focus last/selected item\n state.open();\n const focusKey =\n currentKey != null && !isKeyDisabled(currentKey)\n ? currentKey\n : findNextKey(currentKey, \"backward\");\n if (focusKey) {\n state.setFocusedKey(focusKey);\n }\n }\n // When open, navigation is handled by the listbox\n break;\n\n case \"ArrowRight\":\n // ArrowRight: Select next option (for horizontal keyboard navigation pattern)\n if (!state.isOpen()) {\n e.preventDefault();\n const nextKey = findNextKey(currentKey, \"forward\");\n if (nextKey != null) {\n state.setSelectedKey(nextKey);\n }\n }\n break;\n\n case \"ArrowLeft\":\n // ArrowLeft: Select previous option (for horizontal keyboard navigation pattern)\n if (!state.isOpen()) {\n e.preventDefault();\n const prevKey = findNextKey(currentKey, \"backward\");\n if (prevKey != null) {\n state.setSelectedKey(prevKey);\n }\n }\n break;\n\n case \"Home\":\n // Home: Select first option\n if (!state.isOpen()) {\n e.preventDefault();\n const firstKey = findNextKey(null, \"forward\");\n if (firstKey != null) {\n state.setSelectedKey(firstKey);\n }\n }\n break;\n\n case \"End\":\n // End: Select last option\n if (!state.isOpen()) {\n e.preventDefault();\n const lastKey = findNextKey(null, \"backward\");\n if (lastKey != null) {\n state.setSelectedKey(lastKey);\n }\n }\n break;\n\n case \"Escape\":\n if (state.isOpen()) {\n e.preventDefault();\n state.close();\n }\n break;\n }\n };\n\n // Handle focus events\n const handleFocus = (e: FocusEvent) => {\n getProps().onFocus?.(e);\n getProps().onFocusChange?.(true);\n state.setFocused(true);\n };\n\n const handleBlur = (e: FocusEvent) => {\n // Focus moving into the open listbox is not a select blur; the menu's own\n // onBlur clears the state when focus leaves the listbox entirely.\n if (state.isOpen()) {\n return;\n }\n\n getProps().onBlur?.(e);\n getProps().onFocusChange?.(false);\n state.setFocused(false);\n };\n\n return {\n get labelProps() {\n return labelProps as JSX.HTMLAttributes<HTMLElement>;\n },\n get triggerProps() {\n const p = getProps();\n const isOpen = state.isOpen();\n const isDisabled = p.isDisabled ?? state.isDisabled;\n\n const baseProps = mergeProps(\n domProps(),\n pressProps as Record<string, unknown>,\n focusProps as Record<string, unknown>,\n fieldProps as Record<string, unknown>,\n {\n id: buttonId,\n type: \"button\",\n tabIndex: isDisabled ? undefined : 0,\n \"aria-haspopup\": \"listbox\",\n \"aria-expanded\": isOpen,\n \"aria-controls\": isOpen ? listBoxId : undefined,\n \"aria-disabled\": isDisabled || undefined,\n \"aria-required\": p.isRequired || undefined,\n \"aria-describedby\": p[\"aria-describedby\"] || undefined,\n // Mirror upstream `useSelect`: the trigger's accessible name folds the\n // SELECTED VALUE (\"Pro\") ahead of the field label (\"Plan\") → \"Pro Plan\"\n // via `aria-labelledby=[valueId, labelId]`. Only wire this when there is\n // a real visible label; with an `aria-label` (no `labelledby`) the field\n // props' `aria-label` stays the trigger name (label-less legacy path,\n // keeps TabsPicker/label-less Select unchanged).\n \"aria-labelledby\": fieldProps[\"aria-labelledby\"]\n ? [valueId, fieldProps[\"aria-labelledby\"]].filter(Boolean).join(\" \")\n : undefined,\n onKeyDown,\n onFocus: handleFocus,\n onBlur: handleBlur,\n \"data-open\": isOpen || undefined,\n \"data-disabled\": isDisabled || undefined,\n \"data-focus-visible\": isFocusVisible() || undefined,\n } as Record<string, unknown>,\n );\n\n // Add type-select props if enabled\n if (!p.disallowTypeAhead) {\n return mergeProps(\n baseProps,\n typeSelectProps as Record<string, unknown>,\n ) as JSX.HTMLAttributes<HTMLElement>;\n }\n\n return baseProps as JSX.HTMLAttributes<HTMLElement>;\n },\n get valueProps() {\n return {\n id: valueId,\n } as JSX.HTMLAttributes<HTMLElement>;\n },\n // Surfaced so the styled layer (S2 Picker) can apply the `pressScale` press\n // effect on the trigger button — upstream S2 wires `pressScale(buttonRef)` on\n // the RAC Button, which needs the button's live `isPressed`.\n isPressed,\n get menuProps() {\n return {\n id: listBoxId,\n role: \"listbox\",\n // Mirror upstream `useSelect`: the listbox is labelled by the FIELD LABEL\n // (`fieldProps['aria-labelledby']` → the visible \"Plan\" label), NOT the\n // trigger button — the button's own accessible name folds in the selected\n // value (\"Pro Plan\"), which must not leak onto the listbox. Only when\n // there is no visible label (an `aria-label` on the field) does it fall\n // back to the trigger id (unchanged legacy behavior for label-less use).\n \"aria-labelledby\": fieldProps[\"aria-labelledby\"] ?? buttonId,\n \"aria-multiselectable\": state.selectionMode() === \"multiple\" ? true : undefined,\n tabIndex: -1,\n onBlur: (e: FocusEvent) => {\n // Only a blur that leaves the listbox entirely blurs the select.\n if ((e.currentTarget as Node | null)?.contains(e.relatedTarget as Node)) {\n return;\n }\n\n getProps().onBlur?.(e);\n getProps().onFocusChange?.(false);\n state.setFocused(false);\n },\n } as JSX.HTMLAttributes<HTMLElement>;\n },\n get descriptionProps() {\n return {\n id: descriptionId,\n } as JSX.HTMLAttributes<HTMLElement>;\n },\n get errorMessageProps() {\n return {\n id: errorMessageId,\n } as JSX.HTMLAttributes<HTMLElement>;\n },\n isFocused,\n isFocusVisible: () => isFocused() && isFocusVisible(),\n isOpen: state.isOpen,\n selectedItem: state.selectedItem,\n };\n}\n","/**\n * Provides a hidden native select element for form integration.\n * Based on @react-aria/select useHiddenSelect.\n */\n\nimport { type JSX, type Accessor, For, createEffect, onCleanup } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils/reactivity\";\nimport { createFormValidation } from \"../form/createFormValidation\";\nimport type { SelectState, Key, FormValidationState } from \"@proyecto-viviana/solid-stately\";\n\nexport type ValidationBehavior = \"aria\" | \"native\";\n\nexport interface AriaHiddenSelectProps<T> {\n /** The state object for the select. */\n state: SelectState<T>;\n /** The name attribute for the hidden select. */\n name?: string;\n /** Whether the select is disabled. */\n isDisabled?: boolean;\n /** Whether the select is required. */\n isRequired?: boolean;\n /** Describes the type of autocomplete functionality the select should provide. */\n autoComplete?: string;\n /** The `form` attribute to associate the select with a form by ID. */\n form?: string;\n /** Validation behavior: 'aria' for realtime, 'native' for on submit. */\n validationBehavior?: ValidationBehavior;\n /** A ref to the trigger element for focus on validation error. */\n triggerRef?: Accessor<HTMLElement | null>;\n /** Form validation state (optional, for native validation). */\n validationState?: FormValidationState;\n}\n\nexport interface HiddenSelectAria {\n /** Props for the container element. */\n containerProps: JSX.HTMLAttributes<HTMLDivElement>;\n /** Props for the hidden select element. */\n selectProps: JSX.SelectHTMLAttributes<HTMLSelectElement>;\n /** Props for the hidden input element (for form submission). */\n inputProps: JSX.InputHTMLAttributes<HTMLInputElement>;\n}\n\n/**\n * Provides the accessibility implementation for a hidden select.\n * This is used for native form submission and accessibility on mobile devices.\n */\nexport function createHiddenSelect<T>(\n props: MaybeAccessor<AriaHiddenSelectProps<T>>,\n): HiddenSelectAria {\n const getProps = () => access(props);\n\n // Track the select element for form reset/validation\n let selectRef: HTMLSelectElement | undefined;\n\n // Set up form reset handler\n createEffect(() => {\n const p = getProps();\n if (!selectRef) return;\n\n const form = selectRef.form;\n if (!form) return;\n\n const handleReset = () => {\n // Reset to default selected key (first key or null)\n const defaultKey = p.state.collection().getFirstKey();\n p.state.setSelectedKey(defaultKey);\n };\n\n form.addEventListener(\"reset\", handleReset);\n\n onCleanup(() => {\n form.removeEventListener(\"reset\", handleReset);\n });\n });\n\n // Set up form validation handler for native validation\n createEffect(() => {\n const p = getProps();\n if (!selectRef || p.validationBehavior !== \"native\" || !p.validationState) return;\n\n createFormValidation(\n {\n validationBehavior: p.validationBehavior,\n focus: () => p.triggerRef?.()?.focus(),\n },\n p.validationState,\n () => selectRef,\n );\n });\n\n return {\n get containerProps() {\n return {\n \"aria-hidden\": true,\n \"data-a11y-ignore\": \"aria-hidden-focus\",\n } as JSX.HTMLAttributes<HTMLDivElement>;\n },\n get selectProps() {\n const p = getProps();\n const state = p.state;\n const selectedKey = state.selectedKey();\n const selectedKeys =\n typeof state.selectedKeys === \"function\"\n ? state.selectedKeys()\n : selectedKey != null\n ? new Set([selectedKey])\n : new Set<Key>();\n const validationBehavior = p.validationBehavior ?? \"aria\";\n const isMultiple =\n typeof state.selectionMode === \"function\" && state.selectionMode() === \"multiple\";\n const multipleValue =\n selectedKeys === \"all\"\n ? Array.from(state.collection()).map((item) => String(item.key))\n : Array.from(selectedKeys).map(String);\n\n return {\n ref: (el: HTMLSelectElement) => {\n selectRef = el;\n },\n tabIndex: -1,\n autoComplete: p.autoComplete,\n disabled: p.isDisabled ?? state.isDisabled,\n multiple: isMultiple || undefined,\n name: p.name,\n form: p.form,\n // Add required attribute for native form validation\n required: validationBehavior === \"native\" && p.isRequired,\n value: isMultiple ? multipleValue : selectedKey != null ? String(selectedKey) : \"\",\n onChange: (e: Event) => {\n const target = e.target as HTMLSelectElement;\n if (isMultiple) {\n if (typeof state.setSelectedKeys === \"function\") {\n state.setSelectedKeys(Array.from(target.selectedOptions).map((o) => o.value as Key));\n } else {\n const first = target.selectedOptions[0]?.value;\n state.setSelectedKey((first ?? null) as Key | null);\n }\n } else {\n state.setSelectedKey(target.value as Key);\n }\n },\n style: {\n position: \"absolute\",\n top: 0,\n left: 0,\n width: \"100%\",\n height: \"100%\",\n opacity: 0,\n \"font-size\": \"16px\", // Prevents zoom on iOS\n border: \"none\",\n cursor: \"default\",\n margin: 0,\n padding: 0,\n \"pointer-events\": \"none\",\n },\n } as JSX.SelectHTMLAttributes<HTMLSelectElement>;\n },\n get inputProps() {\n const p = getProps();\n const state = p.state;\n const selectedKey = state.selectedKey();\n const validationBehavior = p.validationBehavior ?? \"aria\";\n\n // For native validation with required, use type=\"text\" with display:none\n // so the browser will validate it on form submit\n const useTextInput = validationBehavior === \"native\" && p.isRequired;\n\n return {\n type: useTextInput ? \"text\" : \"hidden\",\n name: p.name,\n form: p.form,\n value: selectedKey != null ? String(selectedKey) : \"\",\n disabled: p.isDisabled ?? state.isDisabled,\n required: useTextInput ? p.isRequired : undefined,\n style: useTextInput ? { display: \"none\" } : undefined,\n } as JSX.InputHTMLAttributes<HTMLInputElement>;\n },\n };\n}\n\nexport interface HiddenSelectProps<T> {\n /** The state object for the select. */\n state: SelectState<T>;\n /** The name attribute for the hidden select. */\n name?: string;\n /** Whether the select is disabled. */\n isDisabled?: boolean;\n /** Whether the select is required. */\n isRequired?: boolean;\n /** A ref to the trigger element. */\n triggerRef?: () => HTMLElement | null;\n /** Label for the select. */\n label?: string;\n /** Describes the type of autocomplete functionality the select should provide. */\n autoComplete?: string;\n /** The `form` attribute to associate the select with a form by ID. */\n form?: string;\n /** Validation behavior: 'aria' for realtime, 'native' for on submit. */\n validationBehavior?: ValidationBehavior;\n /** Form validation state (optional, for native validation). */\n validationState?: FormValidationState;\n}\n\n/**\n * A component that renders a hidden native select for form submission.\n * This is useful on mobile devices where native select behavior is preferred.\n */\nexport function HiddenSelect<T>(props: HiddenSelectProps<T>): JSX.Element {\n const { containerProps, selectProps } = createHiddenSelect({\n get state() {\n return props.state;\n },\n get name() {\n return props.name;\n },\n get isDisabled() {\n return props.isDisabled;\n },\n get isRequired() {\n return props.isRequired;\n },\n get autoComplete() {\n return props.autoComplete;\n },\n get form() {\n return props.form;\n },\n get validationBehavior() {\n return props.validationBehavior;\n },\n get triggerRef() {\n return props.triggerRef;\n },\n get validationState() {\n return props.validationState;\n },\n });\n\n const collection = () => props.state.collection();\n const selectedKey = () => props.state.selectedKey();\n const selectedKeys = () =>\n typeof props.state.selectedKeys === \"function\"\n ? props.state.selectedKeys()\n : selectedKey() != null\n ? new Set([selectedKey() as Key])\n : new Set<Key>();\n const isMultiple = () =>\n typeof props.state.selectionMode === \"function\" && props.state.selectionMode() === \"multiple\";\n\n return (\n <div {...containerProps}>\n <label>\n {props.label}\n <select {...selectProps}>\n <option />\n <For each={Array.from(collection())}>\n {(item) => (\n <option\n value={String(item.key)}\n selected={\n isMultiple()\n ? selectedKeys() === \"all\"\n ? true\n : (selectedKeys() as Set<Key>).has(item.key)\n : item.key === selectedKey()\n }\n >\n {item.textValue}\n </option>\n )}\n </For>\n </select>\n </label>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkFA,MAAM,6BAAa,IAAI,QAA4B;AAMnD,SAAgB,cAAc,OAA4C;CACxE,OAAO,WAAW,IAAI,KAAK;AAC7B;;;;AAKA,SAAgB,aACd,OACA,OACA,MACe;CACf,MAAM,iBAAiB,OAAO,KAAK;CACnC,MAAM,KAAK,SAAS,SAAS,CAAC,CAAC,EAAE;CAGjC,MAAM,WAAW,GAAG,GAAG;CACvB,MAAM,YAAY,GAAG,GAAG;CACxB,MAAM,UAAU,GAAG,GAAG;CACtB,MAAM,gBAAgB,GAAG,GAAG;CAC5B,MAAM,iBAAiB,GAAG,GAAG;CAG7B,MAAM,iBACJ,eAAe,SAAS,GAAyC,EAAE,WAAW,KAAK,CAAC;CAGtF,mBAAmB;EACjB,WAAW,IAAI,OAAO,EAAE,GAAG,CAAC;EAE5B,gBAAgB;GACd,WAAW,OAAO,KAAK;EACzB,CAAC;CACH,CAAC;CAGD,MAAM,EAAE,YAAY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AO;GACT,OAAO,MAAM;EACf;EACA,IAAI,qBAAqB;GACvB,OAAO,MAAM;EACf;EACA,IAAI,aAAa;GACf,OAAO,MAAM;EACf;EACA,IAAI,kBAAkB;GACpB,OAAO,MAAM;EACf;CACF,CAAC;CAED,MAAM,mBAAmB,MAAM,MAAM,WAAW;CAChD,MAAM,oBAAoB,MAAM,MAAM,YAAY;CAClD,MAAM,qBACJ,OAAO,MAAM,MAAM,iBAAiB,aAChC,MAAM,MAAM,aAAa,IACzB,YAAY,KAAK,OACf,IAAI,IAAI,CAAC,YAAY,CAAQ,CAAC,oBAC9B,IAAI,IAAS;CACrB,MAAM,mBACJ,OAAO,MAAM,MAAM,kBAAkB,cAAc,MAAM,MAAM,cAAc,MAAM;CAErF,OACE,CAAC,QAAQ,gBAAgB;MACvB,CAAC,MAAM;SACJ,MAAM,MAAM;QACb,CAAC,WAAW,aAAa;UACvB,CAAC,SAAS;UACV,CAAC,IAAI,MAAM,MAAM,KAAK,WAAW,CAAC,GAAG;cACjC,SACA,CAAC,OACC,OAAO,OAAO,KAAK,GAAG,GACtB,UACE,WAAW,IACP,aAAa,MAAM,QACjB,OACC,aAAa,CAAC,CAAc,IAAI,KAAK,GAAG,IAC3C,KAAK,QAAQ,YAAY,GAEhC;iBACE,KAAK,UAAU;cAClB,EAAE,QACF;UACJ,EAAE,IAAI;QACR,EAAE,OAAO;MACX,EAAE,MAAM;IACV,EAAE;AAEN"}
|
|
1
|
+
{"version":3,"file":"select.jsx","names":["mergeProps"],"sources":["../../src/select/createSelect.ts","../../src/select/createHiddenSelect.tsx"],"sourcesContent":["/**\n * Provides the behavior and accessibility implementation for a select component.\n * A select displays a collapsible list of options and allows a user to select one of them.\n * Based on @react-aria/select useSelect.\n */\n\nimport { type JSX, type Accessor, createEffect, onCleanup } from \"solid-js\";\nimport { createPress } from \"../interactions/createPress\";\nimport { createFocusRing } from \"../interactions/createFocusRing\";\nimport { createLabel } from \"../label/createLabel\";\nimport { createTypeSelect } from \"../selection/createTypeSelect\";\nimport { filterDOMProps } from \"../utils/filterDOMProps\";\nimport { mergeProps } from \"../utils/mergeProps\";\nimport { createId } from \"../ssr\";\nimport { access, type MaybeAccessor } from \"../utils/reactivity\";\nimport type { SelectState, CollectionNode } from \"@proyecto-viviana/solid-stately\";\n\nexport interface AriaSelectProps {\n /** An ID for the select. */\n id?: string;\n /** Whether the select is disabled. */\n isDisabled?: boolean;\n /** Whether the select is required. */\n isRequired?: boolean;\n /** Whether the select is invalid. */\n isInvalid?: boolean;\n /** The label for the select. */\n label?: JSX.Element;\n /** An accessible label for the select when no visible label is provided. */\n \"aria-label\"?: string;\n /** The ID of an element that labels the select. */\n \"aria-labelledby\"?: string;\n /** The ID of an element that describes the select. */\n \"aria-describedby\"?: string;\n /** Placeholder text when no option is selected. */\n placeholder?: string;\n /** Whether the select should be auto-focused. */\n autoFocus?: boolean;\n /** Handler called when focus moves to the select. */\n onFocus?: (e: FocusEvent) => void;\n /** Handler called when focus moves away from the select. */\n onBlur?: (e: FocusEvent) => void;\n /** Handler called when the focus state changes. */\n onFocusChange?: (isFocused: boolean) => void;\n /** The name of the select, used when submitting an HTML form. */\n name?: string;\n /** Associates the hidden native select with a form element by id. */\n form?: string;\n /** Whether type-to-select is disabled. @default false */\n disallowTypeAhead?: boolean;\n /** Whether the select can open when its collection is empty. @default false */\n allowsEmptyCollection?: boolean;\n /** Whether validation should use ARIA attributes or native browser validation. */\n validationBehavior?: \"aria\" | \"native\";\n}\n\nexport interface SelectAria<T> {\n /** Props for the label element. */\n labelProps: JSX.HTMLAttributes<HTMLElement>;\n /** Props for the trigger button element. */\n triggerProps: JSX.HTMLAttributes<HTMLElement>;\n /** Props for the value display element. */\n valueProps: JSX.HTMLAttributes<HTMLElement>;\n /** Props for the listbox/menu popup. */\n menuProps: JSX.HTMLAttributes<HTMLElement>;\n /** Props for the description element, if any. */\n descriptionProps: JSX.HTMLAttributes<HTMLElement>;\n /** Props for the error message element, if any. */\n errorMessageProps: JSX.HTMLAttributes<HTMLElement>;\n /** Whether the select is currently focused. */\n isFocused: Accessor<boolean>;\n /** Whether the select has keyboard focus. */\n isFocusVisible: Accessor<boolean>;\n /** Whether the select is currently open. */\n isOpen: Accessor<boolean>;\n /** Whether the trigger button is currently pressed (for `pressScale`). */\n isPressed: Accessor<boolean>;\n /** The currently selected item. */\n selectedItem: Accessor<CollectionNode<T> | null>;\n}\n\n// Shared data between select and options\nconst selectData = new WeakMap<object, SelectData>();\n\ninterface SelectData {\n id: string;\n}\n\nexport function getSelectData(state: SelectState): SelectData | undefined {\n return selectData.get(state);\n}\n\n/**\n * Provides the behavior and accessibility implementation for a select component.\n */\nexport function createSelect<T>(\n props: MaybeAccessor<AriaSelectProps>,\n state: SelectState<T>,\n _ref?: () => HTMLElement | null,\n): SelectAria<T> {\n const getProps = () => access(props);\n const id = createId(getProps().id);\n\n // Generate IDs for associated elements\n const buttonId = `${id}-button`;\n const listBoxId = `${id}-listbox`;\n const valueId = `${id}-value`;\n const descriptionId = `${id}-description`;\n const errorMessageId = `${id}-error`;\n\n // Filter DOM props\n const domProps = () =>\n filterDOMProps(getProps() as unknown as Record<string, unknown>, { labelable: true });\n\n // Share data with child options\n createEffect(() => {\n selectData.set(state, { id });\n\n onCleanup(() => {\n selectData.delete(state);\n });\n });\n\n // Label handling\n const { labelProps, fieldProps } = createLabel({\n get id() {\n return buttonId;\n },\n get label() {\n return getProps().label;\n },\n get \"aria-label\"() {\n return getProps()[\"aria-label\"];\n },\n get \"aria-labelledby\"() {\n return getProps()[\"aria-labelledby\"];\n },\n labelElementType: \"span\",\n });\n\n // Focus ring for keyboard focus styling\n const { isFocusVisible, focusProps } = createFocusRing({\n get autoFocus() {\n return getProps().autoFocus;\n },\n });\n\n // Track focus state\n const isFocused = state.isFocused;\n\n // Handle press on trigger\n const canOpen = () =>\n getProps().allowsEmptyCollection || state.collection().getFirstKey() != null;\n\n // Helper to check if key is disabled\n const isKeyDisabled = (key: string | number): boolean => {\n const collection = state.collection();\n return state.isKeyDisabled?.(key) || collection.getItem(key)?.isDisabled || false;\n };\n\n // Helper to find the next non-disabled key.\n const findNextKey = (\n fromKey: string | number | null,\n direction: \"forward\" | \"backward\",\n ): string | number | null => {\n const collection = state.collection();\n const getAdjacent =\n direction === \"forward\"\n ? (k: string | number) => collection.getKeyAfter(k)\n : (k: string | number) => collection.getKeyBefore(k);\n const getBoundary =\n direction === \"forward\" ? () => collection.getFirstKey() : () => collection.getLastKey();\n\n let key = fromKey == null ? getBoundary() : getAdjacent(fromKey);\n while (key != null && isKeyDisabled(key)) {\n key = getAdjacent(key);\n }\n\n return key;\n };\n\n const focusKeyForOpen = (): string | number | null => {\n const selectedKey = state.selectedKey();\n if (selectedKey != null && !isKeyDisabled(selectedKey)) {\n return selectedKey;\n }\n return findNextKey(null, \"forward\");\n };\n\n const openWithFocus = () => {\n if (state.isOpen() || !canOpen()) {\n return;\n }\n state.open();\n const focusKey = focusKeyForOpen();\n if (focusKey != null) {\n state.setFocusedKey(focusKey);\n }\n };\n\n const { pressProps, isPressed } = createPress({\n get isDisabled() {\n return getProps().isDisabled ?? state.isDisabled;\n },\n onPress(e) {\n if (e.pointerType === \"keyboard\") {\n return;\n }\n\n if (state.isOpen()) {\n state.close();\n } else {\n openWithFocus();\n }\n },\n });\n\n // Type-to-select - for Select, typing directly selects items when closed\n const { typeSelectProps } = createTypeSelect({\n collection: () => state.collection(),\n focusedKey: () => state.selectedKey(), // Use selectedKey as the \"focused\" key for closed Select\n onFocusedKeyChange: (key) => {\n // When closed, type-to-select directly changes selection\n if (!state.isOpen()) {\n state.setSelectedKey(key);\n } else {\n // When open, update focused key (listbox handles selection)\n state.setFocusedKey(key);\n }\n },\n isKeyDisabled,\n get isDisabled() {\n return Boolean(\n (getProps().disallowTypeAhead ?? false) || getProps().isDisabled || state.isDisabled,\n );\n },\n });\n\n // Keyboard navigation\n const onKeyDown: JSX.EventHandler<HTMLElement, KeyboardEvent> = (e) => {\n if (getProps().isDisabled ?? state.isDisabled) return;\n\n const currentKey = state.focusedKey() ?? state.selectedKey();\n\n switch (e.key) {\n case \"Enter\":\n case \" \":\n e.preventDefault();\n if (state.isOpen()) {\n state.close();\n } else {\n openWithFocus();\n }\n break;\n\n case \"ArrowDown\":\n e.preventDefault();\n if (!state.isOpen()) {\n if (!canOpen()) {\n return;\n }\n // ArrowDown: Open the dropdown and focus first/selected item\n state.open();\n const focusKey =\n currentKey != null && !isKeyDisabled(currentKey)\n ? currentKey\n : findNextKey(currentKey, \"forward\");\n if (focusKey) {\n state.setFocusedKey(focusKey);\n }\n }\n // When open, navigation is handled by the listbox\n break;\n\n case \"ArrowUp\":\n e.preventDefault();\n if (!state.isOpen()) {\n if (!canOpen()) {\n return;\n }\n // ArrowUp: Open the dropdown and focus last/selected item\n state.open();\n const focusKey =\n currentKey != null && !isKeyDisabled(currentKey)\n ? currentKey\n : findNextKey(currentKey, \"backward\");\n if (focusKey) {\n state.setFocusedKey(focusKey);\n }\n }\n // When open, navigation is handled by the listbox\n break;\n\n case \"ArrowRight\":\n // ArrowRight: Select next option (for horizontal keyboard navigation pattern)\n if (!state.isOpen()) {\n e.preventDefault();\n const nextKey = findNextKey(currentKey, \"forward\");\n if (nextKey != null) {\n state.setSelectedKey(nextKey);\n }\n }\n break;\n\n case \"ArrowLeft\":\n // ArrowLeft: Select previous option (for horizontal keyboard navigation pattern)\n if (!state.isOpen()) {\n e.preventDefault();\n const prevKey = findNextKey(currentKey, \"backward\");\n if (prevKey != null) {\n state.setSelectedKey(prevKey);\n }\n }\n break;\n\n case \"Home\":\n // Home: Select first option\n if (!state.isOpen()) {\n e.preventDefault();\n const firstKey = findNextKey(null, \"forward\");\n if (firstKey != null) {\n state.setSelectedKey(firstKey);\n }\n }\n break;\n\n case \"End\":\n // End: Select last option\n if (!state.isOpen()) {\n e.preventDefault();\n const lastKey = findNextKey(null, \"backward\");\n if (lastKey != null) {\n state.setSelectedKey(lastKey);\n }\n }\n break;\n\n case \"Escape\":\n if (state.isOpen()) {\n e.preventDefault();\n state.close();\n }\n break;\n }\n };\n\n // Handle focus events\n const handleFocus = (e: FocusEvent) => {\n getProps().onFocus?.(e);\n getProps().onFocusChange?.(true);\n state.setFocused(true);\n };\n\n const handleBlur = (e: FocusEvent) => {\n // Focus moving into the open listbox is not a select blur; the menu's own\n // onBlur clears the state when focus leaves the listbox entirely.\n if (state.isOpen()) {\n return;\n }\n\n getProps().onBlur?.(e);\n getProps().onFocusChange?.(false);\n state.setFocused(false);\n };\n\n return {\n get labelProps() {\n return labelProps as JSX.HTMLAttributes<HTMLElement>;\n },\n get triggerProps() {\n const p = getProps();\n const isOpen = state.isOpen();\n const isDisabled = p.isDisabled ?? state.isDisabled;\n\n const baseProps = mergeProps(\n domProps(),\n pressProps as Record<string, unknown>,\n focusProps as Record<string, unknown>,\n fieldProps as Record<string, unknown>,\n {\n id: buttonId,\n type: \"button\",\n tabIndex: isDisabled ? undefined : 0,\n \"aria-haspopup\": \"listbox\",\n \"aria-expanded\": isOpen,\n \"aria-controls\": isOpen ? listBoxId : undefined,\n \"aria-disabled\": isDisabled || undefined,\n \"aria-required\": p.isRequired || undefined,\n \"aria-describedby\": p[\"aria-describedby\"] || undefined,\n // Mirror upstream `useSelect` exactly: the trigger name starts with\n // the selected value, then the visible label. When only `aria-label`\n // is present, the trigger references itself so that label follows the\n // value as well (\"Pro Plan\"), rather than masking visible text.\n \"aria-labelledby\": [\n valueId,\n fieldProps[\"aria-labelledby\"],\n fieldProps[\"aria-label\"] && !fieldProps[\"aria-labelledby\"] ? fieldProps.id : undefined,\n ]\n .filter(Boolean)\n .join(\" \"),\n onKeyDown,\n onFocus: handleFocus,\n onBlur: handleBlur,\n \"data-open\": isOpen || undefined,\n \"data-disabled\": isDisabled || undefined,\n \"data-focus-visible\": isFocusVisible() || undefined,\n } as Record<string, unknown>,\n );\n\n // Add type-select props if enabled\n if (!p.disallowTypeAhead) {\n return mergeProps(\n baseProps,\n typeSelectProps as Record<string, unknown>,\n ) as JSX.HTMLAttributes<HTMLElement>;\n }\n\n return baseProps as JSX.HTMLAttributes<HTMLElement>;\n },\n get valueProps() {\n return {\n id: valueId,\n } as JSX.HTMLAttributes<HTMLElement>;\n },\n // Surfaced so the styled layer (S2 Picker) can apply the `pressScale` press\n // effect on the trigger button — upstream S2 wires `pressScale(buttonRef)` on\n // the RAC Button, which needs the button's live `isPressed`.\n isPressed,\n get menuProps() {\n return {\n id: listBoxId,\n role: \"listbox\",\n // Mirror upstream `useSelect`: a visible field label names the listbox;\n // the trigger is the fallback only for the `aria-label` branch.\n \"aria-labelledby\": [\n fieldProps[\"aria-labelledby\"],\n fieldProps[\"aria-label\"] && !fieldProps[\"aria-labelledby\"] ? fieldProps.id : undefined,\n ]\n .filter(Boolean)\n .join(\" \"),\n \"aria-multiselectable\": state.selectionMode() === \"multiple\" ? true : undefined,\n tabIndex: -1,\n onBlur: (e: FocusEvent) => {\n // Only a blur that leaves the listbox entirely blurs the select.\n if ((e.currentTarget as Node | null)?.contains(e.relatedTarget as Node)) {\n return;\n }\n\n getProps().onBlur?.(e);\n getProps().onFocusChange?.(false);\n state.setFocused(false);\n },\n } as JSX.HTMLAttributes<HTMLElement>;\n },\n get descriptionProps() {\n return {\n id: descriptionId,\n } as JSX.HTMLAttributes<HTMLElement>;\n },\n get errorMessageProps() {\n return {\n id: errorMessageId,\n } as JSX.HTMLAttributes<HTMLElement>;\n },\n isFocused,\n isFocusVisible: () => isFocused() && isFocusVisible(),\n isOpen: state.isOpen,\n selectedItem: state.selectedItem,\n };\n}\n","/**\n * Provides a hidden native select element for form integration.\n * Based on @react-aria/select useHiddenSelect.\n */\n\nimport { type JSX, type Accessor, For, createEffect, onCleanup } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils/reactivity\";\nimport { createFormValidation } from \"../form/createFormValidation\";\nimport type { SelectState, Key, FormValidationState } from \"@proyecto-viviana/solid-stately\";\n\nexport type ValidationBehavior = \"aria\" | \"native\";\n\nexport interface AriaHiddenSelectProps<T> {\n /** The state object for the select. */\n state: SelectState<T>;\n /** The name attribute for the hidden select. */\n name?: string;\n /** Whether the select is disabled. */\n isDisabled?: boolean;\n /** Whether the select is required. */\n isRequired?: boolean;\n /** Describes the type of autocomplete functionality the select should provide. */\n autoComplete?: string;\n /** The `form` attribute to associate the select with a form by ID. */\n form?: string;\n /** Validation behavior: 'aria' for realtime, 'native' for on submit. */\n validationBehavior?: ValidationBehavior;\n /** A ref to the trigger element for focus on validation error. */\n triggerRef?: Accessor<HTMLElement | null>;\n /** Form validation state (optional, for native validation). */\n validationState?: FormValidationState;\n}\n\nexport interface HiddenSelectAria {\n /** Props for the container element. */\n containerProps: JSX.HTMLAttributes<HTMLDivElement>;\n /** Props for the hidden select element. */\n selectProps: JSX.SelectHTMLAttributes<HTMLSelectElement>;\n /** Props for the hidden input element (for form submission). */\n inputProps: JSX.InputHTMLAttributes<HTMLInputElement>;\n}\n\n/**\n * Provides the accessibility implementation for a hidden select.\n * This is used for native form submission and accessibility on mobile devices.\n */\nexport function createHiddenSelect<T>(\n props: MaybeAccessor<AriaHiddenSelectProps<T>>,\n): HiddenSelectAria {\n const getProps = () => access(props);\n\n // Track the select element for form reset/validation\n let selectRef: HTMLSelectElement | undefined;\n\n // Set up form reset handler\n createEffect(() => {\n const p = getProps();\n if (!selectRef) return;\n\n const form = selectRef.form;\n if (!form) return;\n\n const handleReset = () => {\n // Reset to default selected key (first key or null)\n const defaultKey = p.state.collection().getFirstKey();\n p.state.setSelectedKey(defaultKey);\n };\n\n form.addEventListener(\"reset\", handleReset);\n\n onCleanup(() => {\n form.removeEventListener(\"reset\", handleReset);\n });\n });\n\n // Set up form validation handler for native validation\n createEffect(() => {\n const p = getProps();\n if (!selectRef || p.validationBehavior !== \"native\" || !p.validationState) return;\n\n createFormValidation(\n {\n validationBehavior: p.validationBehavior,\n focus: () => p.triggerRef?.()?.focus(),\n },\n p.validationState,\n () => selectRef,\n );\n });\n\n return {\n get containerProps() {\n return {\n \"aria-hidden\": true,\n \"data-a11y-ignore\": \"aria-hidden-focus\",\n } as JSX.HTMLAttributes<HTMLDivElement>;\n },\n get selectProps() {\n const p = getProps();\n const state = p.state;\n const selectedKey = state.selectedKey();\n const selectedKeys =\n typeof state.selectedKeys === \"function\"\n ? state.selectedKeys()\n : selectedKey != null\n ? new Set([selectedKey])\n : new Set<Key>();\n const validationBehavior = p.validationBehavior ?? \"aria\";\n const isMultiple =\n typeof state.selectionMode === \"function\" && state.selectionMode() === \"multiple\";\n const multipleValue =\n selectedKeys === \"all\"\n ? Array.from(state.collection()).map((item) => String(item.key))\n : Array.from(selectedKeys).map(String);\n\n return {\n ref: (el: HTMLSelectElement) => {\n selectRef = el;\n },\n tabIndex: -1,\n autoComplete: p.autoComplete,\n disabled: p.isDisabled ?? state.isDisabled,\n multiple: isMultiple || undefined,\n name: p.name,\n form: p.form,\n // Add required attribute for native form validation\n required: validationBehavior === \"native\" && p.isRequired,\n value: isMultiple ? multipleValue : selectedKey != null ? String(selectedKey) : \"\",\n onChange: (e: Event) => {\n const target = e.target as HTMLSelectElement;\n if (isMultiple) {\n if (typeof state.setSelectedKeys === \"function\") {\n state.setSelectedKeys(Array.from(target.selectedOptions).map((o) => o.value as Key));\n } else {\n const first = target.selectedOptions[0]?.value;\n state.setSelectedKey((first ?? null) as Key | null);\n }\n } else {\n state.setSelectedKey(target.value as Key);\n }\n },\n style: {\n position: \"absolute\",\n top: 0,\n left: 0,\n width: \"100%\",\n height: \"100%\",\n opacity: 0,\n \"font-size\": \"16px\", // Prevents zoom on iOS\n border: \"none\",\n cursor: \"default\",\n margin: 0,\n padding: 0,\n \"pointer-events\": \"none\",\n },\n } as JSX.SelectHTMLAttributes<HTMLSelectElement>;\n },\n get inputProps() {\n const p = getProps();\n const state = p.state;\n const selectedKey = state.selectedKey();\n const validationBehavior = p.validationBehavior ?? \"aria\";\n\n // For native validation with required, use type=\"text\" with display:none\n // so the browser will validate it on form submit\n const useTextInput = validationBehavior === \"native\" && p.isRequired;\n\n return {\n type: useTextInput ? \"text\" : \"hidden\",\n name: p.name,\n form: p.form,\n value: selectedKey != null ? String(selectedKey) : \"\",\n disabled: p.isDisabled ?? state.isDisabled,\n required: useTextInput ? p.isRequired : undefined,\n style: useTextInput ? { display: \"none\" } : undefined,\n } as JSX.InputHTMLAttributes<HTMLInputElement>;\n },\n };\n}\n\nexport interface HiddenSelectProps<T> {\n /** The state object for the select. */\n state: SelectState<T>;\n /** The name attribute for the hidden select. */\n name?: string;\n /** Whether the select is disabled. */\n isDisabled?: boolean;\n /** Whether the select is required. */\n isRequired?: boolean;\n /** A ref to the trigger element. */\n triggerRef?: () => HTMLElement | null;\n /** Label for the select. */\n label?: string;\n /** Describes the type of autocomplete functionality the select should provide. */\n autoComplete?: string;\n /** The `form` attribute to associate the select with a form by ID. */\n form?: string;\n /** Validation behavior: 'aria' for realtime, 'native' for on submit. */\n validationBehavior?: ValidationBehavior;\n /** Form validation state (optional, for native validation). */\n validationState?: FormValidationState;\n}\n\n/**\n * A component that renders a hidden native select for form submission.\n * This is useful on mobile devices where native select behavior is preferred.\n */\nexport function HiddenSelect<T>(props: HiddenSelectProps<T>): JSX.Element {\n const { containerProps, selectProps } = createHiddenSelect({\n get state() {\n return props.state;\n },\n get name() {\n return props.name;\n },\n get isDisabled() {\n return props.isDisabled;\n },\n get isRequired() {\n return props.isRequired;\n },\n get autoComplete() {\n return props.autoComplete;\n },\n get form() {\n return props.form;\n },\n get validationBehavior() {\n return props.validationBehavior;\n },\n get triggerRef() {\n return props.triggerRef;\n },\n get validationState() {\n return props.validationState;\n },\n });\n\n const collection = () => props.state.collection();\n const selectedKey = () => props.state.selectedKey();\n const selectedKeys = () =>\n typeof props.state.selectedKeys === \"function\"\n ? props.state.selectedKeys()\n : selectedKey() != null\n ? new Set([selectedKey() as Key])\n : new Set<Key>();\n const isMultiple = () =>\n typeof props.state.selectionMode === \"function\" && props.state.selectionMode() === \"multiple\";\n\n return (\n <div {...containerProps}>\n <label>\n {props.label}\n <select {...selectProps}>\n <option />\n <For each={Array.from(collection())}>\n {(item) => (\n <option\n value={String(item.key)}\n selected={\n isMultiple()\n ? selectedKeys() === \"all\"\n ? true\n : (selectedKeys() as Set<Key>).has(item.key)\n : item.key === selectedKey()\n }\n >\n {item.textValue}\n </option>\n )}\n </For>\n </select>\n </label>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkFA,MAAM,6BAAa,IAAI,QAA4B;AAMnD,SAAgB,cAAc,OAA4C;CACxE,OAAO,WAAW,IAAI,KAAK;AAC7B;;;;AAKA,SAAgB,aACd,OACA,OACA,MACe;CACf,MAAM,iBAAiB,OAAO,KAAK;CACnC,MAAM,KAAK,SAAS,SAAS,CAAC,CAAC,EAAE;CAGjC,MAAM,WAAW,GAAG,GAAG;CACvB,MAAM,YAAY,GAAG,GAAG;CACxB,MAAM,UAAU,GAAG,GAAG;CACtB,MAAM,gBAAgB,GAAG,GAAG;CAC5B,MAAM,iBAAiB,GAAG,GAAG;CAG7B,MAAM,iBACJ,eAAe,SAAS,GAAyC,EAAE,WAAW,KAAK,CAAC;CAGtF,mBAAmB;EACjB,WAAW,IAAI,OAAO,EAAE,GAAG,CAAC;EAE5B,gBAAgB;GACd,WAAW,OAAO,KAAK;EACzB,CAAC;CACH,CAAC;CAGD,MAAM,EAAE,YAAY,eAAe,YAAY;EAC7C,IAAI,KAAK;GACP,OAAO;EACT;EACA,IAAI,QAAQ;GACV,OAAO,SAAS,CAAC,CAAC;EACpB;EACA,IAAI,eAAe;GACjB,OAAO,SAAS,CAAC,CAAC;EACpB;EACA,IAAI,oBAAoB;GACtB,OAAO,SAAS,CAAC,CAAC;EACpB;EACA,kBAAkB;CACpB,CAAC;CAGD,MAAM,EAAE,gBAAgB,eAAe,gBAAgB,EACrD,IAAI,YAAY;EACd,OAAO,SAAS,CAAC,CAAC;CACpB,EACF,CAAC;CAGD,MAAM,YAAY,MAAM;CAGxB,MAAM,gBACJ,SAAS,CAAC,CAAC,yBAAyB,MAAM,WAAW,CAAC,C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AM,aAAa,IACzB,YAAY,KAAK,OACf,IAAI,IAAI,CAAC,YAAY,CAAQ,CAAC,oBAC9B,IAAI,IAAS;CACrB,MAAM,mBACJ,OAAO,MAAM,MAAM,kBAAkB,cAAc,MAAM,MAAM,cAAc,MAAM;CAErF,OACE,CAAC,QAAQ,gBAAgB;MACvB,CAAC,MAAM;SACJ,MAAM,MAAM;QACb,CAAC,WAAW,aAAa;UACvB,CAAC,SAAS;UACV,CAAC,IAAI,MAAM,MAAM,KAAK,WAAW,CAAC,GAAG;cACjC,SACA,CAAC,OACC,OAAO,OAAO,KAAK,GAAG,GACtB,UACE,WAAW,IACP,aAAa,MAAM,QACjB,OACC,aAAa,CAAC,CAAc,IAAI,KAAK,GAAG,IAC3C,KAAK,QAAQ,YAAY,GAEhC;iBACE,KAAK,UAAU;cAClB,EAAE,QACF;UACJ,EAAE,IAAI;QACR,EAAE,OAAO;MACX,EAAE,MAAM;IACV,EAAE;AAEN"}
|
|
@@ -5,40 +5,40 @@ import { createEffect, createMemo } from "solid-js";
|
|
|
5
5
|
import { LocalizedStringDictionary } from "@internationalized/string";
|
|
6
6
|
//#region src/spinbutton/intl.ts
|
|
7
7
|
const spinButtonStrings = {
|
|
8
|
-
"ar-AE": {
|
|
9
|
-
"bg-BG": {
|
|
10
|
-
"cs-CZ": {
|
|
11
|
-
"da-DK": {
|
|
12
|
-
"de-DE": {
|
|
13
|
-
"el-GR": {
|
|
14
|
-
"en-US": {
|
|
15
|
-
"es-ES": {
|
|
16
|
-
"et-EE": {
|
|
17
|
-
"fi-FI": {
|
|
18
|
-
"fr-FR": {
|
|
19
|
-
"he-IL": {
|
|
20
|
-
"hr-HR": {
|
|
21
|
-
"hu-HU": {
|
|
22
|
-
"it-IT": {
|
|
23
|
-
"ja-JP": {
|
|
24
|
-
"ko-KR": {
|
|
25
|
-
"lt-LT": {
|
|
26
|
-
"lv-LV": {
|
|
27
|
-
"nb-NO": {
|
|
28
|
-
"nl-NL": {
|
|
29
|
-
"pl-PL": {
|
|
30
|
-
"pt-BR": {
|
|
31
|
-
"pt-PT": {
|
|
32
|
-
"ro-RO": {
|
|
33
|
-
"ru-RU": {
|
|
34
|
-
"sk-SK": {
|
|
35
|
-
"sl-SI": {
|
|
36
|
-
"sr-SP": {
|
|
37
|
-
"sv-SE": {
|
|
38
|
-
"tr-TR": {
|
|
39
|
-
"uk-UA": {
|
|
40
|
-
"zh-CN": {
|
|
41
|
-
"zh-TW": {
|
|
8
|
+
"ar-AE": { Empty: `\u{641}\u{627}\u{631}\u{63A}` },
|
|
9
|
+
"bg-BG": { Empty: `\u{418}\u{437}\u{43F}\u{440}\u{430}\u{437}\u{43D}\u{438}` },
|
|
10
|
+
"cs-CZ": { Empty: `Pr\xe1zdn\xe9` },
|
|
11
|
+
"da-DK": { Empty: `Tom` },
|
|
12
|
+
"de-DE": { Empty: `Leer` },
|
|
13
|
+
"el-GR": { Empty: `\u{386}\u{3B4}\u{3B5}\u{3B9}\u{3BF}` },
|
|
14
|
+
"en-US": { Empty: `Empty` },
|
|
15
|
+
"es-ES": { Empty: `Vac\xedo` },
|
|
16
|
+
"et-EE": { Empty: `T\xfchjenda` },
|
|
17
|
+
"fi-FI": { Empty: `Tyhj\xe4` },
|
|
18
|
+
"fr-FR": { Empty: `Vide` },
|
|
19
|
+
"he-IL": { Empty: `\u{5E8}\u{5D9}\u{5E7}` },
|
|
20
|
+
"hr-HR": { Empty: `Prazno` },
|
|
21
|
+
"hu-HU": { Empty: `\xdcres` },
|
|
22
|
+
"it-IT": { Empty: `Vuoto` },
|
|
23
|
+
"ja-JP": { Empty: `\u{7A7A}` },
|
|
24
|
+
"ko-KR": { Empty: `\u{BE44}\u{C5B4} \u{C788}\u{C74C}` },
|
|
25
|
+
"lt-LT": { Empty: `Tu\u{161}\u{10D}ias` },
|
|
26
|
+
"lv-LV": { Empty: `Tuk\u{161}s` },
|
|
27
|
+
"nb-NO": { Empty: `Tom` },
|
|
28
|
+
"nl-NL": { Empty: `Leeg` },
|
|
29
|
+
"pl-PL": { Empty: `Pusty` },
|
|
30
|
+
"pt-BR": { Empty: `Vazio` },
|
|
31
|
+
"pt-PT": { Empty: `Vazio` },
|
|
32
|
+
"ro-RO": { Empty: `Gol` },
|
|
33
|
+
"ru-RU": { Empty: `\u{41D}\u{435} \u{437}\u{430}\u{43F}\u{43E}\u{43B}\u{43D}\u{435}\u{43D}\u{43E}` },
|
|
34
|
+
"sk-SK": { Empty: `Pr\xe1zdne` },
|
|
35
|
+
"sl-SI": { Empty: `Prazen` },
|
|
36
|
+
"sr-SP": { Empty: `Prazno` },
|
|
37
|
+
"sv-SE": { Empty: `Tomt` },
|
|
38
|
+
"tr-TR": { Empty: `Bo\u{15F}` },
|
|
39
|
+
"uk-UA": { Empty: `\u{41F}\u{443}\u{441}\u{442}\u{43E}` },
|
|
40
|
+
"zh-CN": { Empty: `\u{7A7A}` },
|
|
41
|
+
"zh-TW": { Empty: `\u{7A7A}\u{767D}` }
|
|
42
42
|
};
|
|
43
43
|
const spinButtonDictionary = new LocalizedStringDictionary(spinButtonStrings);
|
|
44
44
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spinbutton.js","names":[],"sources":["../../src/spinbutton/intl.ts","../../src/spinbutton/createSpinButton.ts"],"sourcesContent":["// Spinbutton announcement catalog, ported verbatim from @react-aria/spinbutton's\n// intl/*.json (34 locales). Keep in sync with the vendored react-spectrum source on\n// every pin bump.\nimport { LocalizedStringDictionary } from \"@internationalized/string\";\n\nexport type SpinButtonStringKey = \"Empty\";\n\nexport const spinButtonStrings: Record<string, Record<SpinButtonStringKey, string>> = {\n \"ar-AE\": {\n \"Empty\": `\\u{641}\\u{627}\\u{631}\\u{63A}`\n },\n \"bg-BG\": {\n \"Empty\": `\\u{418}\\u{437}\\u{43F}\\u{440}\\u{430}\\u{437}\\u{43D}\\u{438}`\n },\n \"cs-CZ\": {\n \"Empty\": `Pr\\xe1zdn\\xe9`\n },\n \"da-DK\": {\n \"Empty\": `Tom`\n },\n \"de-DE\": {\n \"Empty\": `Leer`\n },\n \"el-GR\": {\n \"Empty\": `\\u{386}\\u{3B4}\\u{3B5}\\u{3B9}\\u{3BF}`\n },\n \"en-US\": {\n \"Empty\": `Empty`\n },\n \"es-ES\": {\n \"Empty\": `Vac\\xedo`\n },\n \"et-EE\": {\n \"Empty\": `T\\xfchjenda`\n },\n \"fi-FI\": {\n \"Empty\": `Tyhj\\xe4`\n },\n \"fr-FR\": {\n \"Empty\": `Vide`\n },\n \"he-IL\": {\n \"Empty\": `\\u{5E8}\\u{5D9}\\u{5E7}`\n },\n \"hr-HR\": {\n \"Empty\": `Prazno`\n },\n \"hu-HU\": {\n \"Empty\": `\\xdcres`\n },\n \"it-IT\": {\n \"Empty\": `Vuoto`\n },\n \"ja-JP\": {\n \"Empty\": `\\u{7A7A}`\n },\n \"ko-KR\": {\n \"Empty\": `\\u{BE44}\\u{C5B4} \\u{C788}\\u{C74C}`\n },\n \"lt-LT\": {\n \"Empty\": `Tu\\u{161}\\u{10D}ias`\n },\n \"lv-LV\": {\n \"Empty\": `Tuk\\u{161}s`\n },\n \"nb-NO\": {\n \"Empty\": `Tom`\n },\n \"nl-NL\": {\n \"Empty\": `Leeg`\n },\n \"pl-PL\": {\n \"Empty\": `Pusty`\n },\n \"pt-BR\": {\n \"Empty\": `Vazio`\n },\n \"pt-PT\": {\n \"Empty\": `Vazio`\n },\n \"ro-RO\": {\n \"Empty\": `Gol`\n },\n \"ru-RU\": {\n \"Empty\": `\\u{41D}\\u{435} \\u{437}\\u{430}\\u{43F}\\u{43E}\\u{43B}\\u{43D}\\u{435}\\u{43D}\\u{43E}`\n },\n \"sk-SK\": {\n \"Empty\": `Pr\\xe1zdne`\n },\n \"sl-SI\": {\n \"Empty\": `Prazen`\n },\n \"sr-SP\": {\n \"Empty\": `Prazno`\n },\n \"sv-SE\": {\n \"Empty\": `Tomt`\n },\n \"tr-TR\": {\n \"Empty\": `Bo\\u{15F}`\n },\n \"uk-UA\": {\n \"Empty\": `\\u{41F}\\u{443}\\u{441}\\u{442}\\u{43E}`\n },\n \"zh-CN\": {\n \"Empty\": `\\u{7A7A}`\n },\n \"zh-TW\": {\n \"Empty\": `\\u{7A7A}\\u{767D}`\n },\n};\n\nexport const spinButtonDictionary = new LocalizedStringDictionary<SpinButtonStringKey, string>(\n spinButtonStrings,\n);\n","/**\n * createSpinButton hook for Solidaria\n *\n * Provides the ARIA spinbutton props and live-region announcement behaviour for\n * a single spinbutton (e.g. a date-field segment). Port of the keyboard/announce\n * portion of @react-aria/spinbutton `useSpinButton`. The pointer press-and-hold\n * button machinery (increment/decrement buttons) is intentionally omitted — date\n * segments drive value changes through the keyboard only.\n */\n\nimport { createMemo, createEffect } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils/reactivity\";\nimport { createStringFormatter } from \"../i18n\";\nimport { announce, clearAnnouncer } from \"../live-announcer\";\nimport { spinButtonStrings, type SpinButtonStringKey } from \"./intl\";\n\nexport interface SpinButtonProps {\n /** The current value of the spinbutton. */\n value?: number;\n /** A human-readable text alternative for the value. */\n textValue?: string;\n /** The smallest value allowed. */\n minValue?: number;\n /** The largest value allowed. */\n maxValue?: number;\n /** Whether the spinbutton is disabled. */\n isDisabled?: boolean;\n /** Whether the spinbutton is read only. */\n isReadOnly?: boolean;\n /** Whether the spinbutton is required. */\n isRequired?: boolean;\n onIncrement?: () => void;\n onIncrementPage?: () => void;\n onDecrement?: () => void;\n onDecrementPage?: () => void;\n onDecrementToMin?: () => void;\n onIncrementToMax?: () => void;\n}\n\nexport interface SpinButtonAria {\n /** Props for the spinbutton element. */\n spinButtonProps: Record<string, unknown>;\n}\n\n/**\n * Provides the behaviour and accessibility implementation for a spinbutton.\n */\nexport function createSpinButton(props: MaybeAccessor<SpinButtonProps>): SpinButtonAria {\n const getProps = () => access(props);\n const stringFormatter = createStringFormatter<SpinButtonStringKey>(\n spinButtonStrings,\n \"@react-aria/spinbutton\",\n );\n\n const onKeyDown = (e: KeyboardEvent) => {\n const p = getProps();\n if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey || p.isReadOnly || e.isComposing) {\n return;\n }\n\n switch (e.key) {\n // Upstream deliberately falls through PageUp → ArrowUp when no page\n // handler exists; our tsconfig forbids lexical fallthrough, so the\n // PageUp case mirrors that branch inline instead.\n case \"PageUp\":\n if (p.onIncrementPage) {\n e.preventDefault();\n p.onIncrementPage();\n } else if (p.onIncrement) {\n e.preventDefault();\n p.onIncrement();\n }\n break;\n case \"ArrowUp\":\n case \"Up\":\n if (p.onIncrement) {\n e.preventDefault();\n p.onIncrement();\n }\n break;\n // Same faithful fallthrough as PageUp, mirrored inline (PageDown → ArrowDown).\n case \"PageDown\":\n if (p.onDecrementPage) {\n e.preventDefault();\n p.onDecrementPage();\n } else if (p.onDecrement) {\n e.preventDefault();\n p.onDecrement();\n }\n break;\n case \"ArrowDown\":\n case \"Down\":\n if (p.onDecrement) {\n e.preventDefault();\n p.onDecrement();\n }\n break;\n case \"Home\":\n if (p.onDecrementToMin) {\n e.preventDefault();\n p.onDecrementToMin();\n }\n break;\n case \"End\":\n if (p.onIncrementToMax) {\n e.preventDefault();\n p.onIncrementToMax();\n }\n break;\n }\n };\n\n // Non-reactive focus flag — matches upstream's `isFocused` ref. Toggling it must\n // NOT re-run the announce effect; only a change in `ariaTextValue` announces.\n let isFocused = false;\n const onFocus = () => {\n isFocused = true;\n };\n const onBlur = () => {\n isFocused = false;\n };\n\n // Replace Unicode hyphen-minus (U+002D) with minus sign (U+2212) so VoiceOver\n // announces it as \"minus\". Replace the empty string with the word \"Empty\".\n const ariaTextValue = createMemo(() => {\n const p = getProps();\n return p.textValue === \"\"\n ? stringFormatter().format(\"Empty\")\n : (p.textValue || `${p.value}`).replace(\"-\", \"−\");\n });\n\n createEffect(() => {\n const value = ariaTextValue();\n if (isFocused) {\n clearAnnouncer(\"assertive\");\n announce(value, \"assertive\");\n }\n });\n\n const spinButtonProps = createMemo(() => {\n const p = getProps();\n const value = p.value;\n return {\n role: \"spinbutton\",\n \"aria-valuenow\": value !== undefined && !isNaN(value) ? value : undefined,\n \"aria-valuetext\": ariaTextValue(),\n \"aria-valuemin\": p.minValue,\n \"aria-valuemax\": p.maxValue,\n \"aria-disabled\": p.isDisabled || undefined,\n \"aria-readonly\": p.isReadOnly || undefined,\n \"aria-required\": p.isRequired || undefined,\n onKeyDown,\n onFocus,\n onBlur,\n };\n });\n\n return {\n get spinButtonProps() {\n return spinButtonProps();\n },\n };\n}\n"],"mappings":";;;;;;AAOA,MAAa,oBAAyE;CACpF,SAAS,EACT,SAAS,+BACT;CACA,SAAS,EACT,SAAS,2DACT;CACA,SAAS,EACT,SAAS,gBACT;CACA,SAAS,EACT,SAAS,MACT;CACA,SAAS,EACT,SAAS,OACT;CACA,SAAS,EACT,SAAS,sCACT;CACA,SAAS,EACT,SAAS,QACT;CACA,SAAS,EACT,SAAS,WACT;CACA,SAAS,EACT,SAAS,cACT;CACA,SAAS,EACT,SAAS,WACT;CACA,SAAS,EACT,SAAS,OACT;CACA,SAAS,EACT,SAAS,wBACT;CACA,SAAS,EACT,SAAS,SACT;CACA,SAAS,EACT,SAAS,UACT;CACA,SAAS,EACT,SAAS,QACT;CACA,SAAS,EACT,SAAS,WACT;CACA,SAAS,EACT,SAAS,oCACT;CACA,SAAS,EACT,SAAS,sBACT;CACA,SAAS,EACT,SAAS,cACT;CACA,SAAS,EACT,SAAS,MACT;CACA,SAAS,EACT,SAAS,OACT;CACA,SAAS,EACT,SAAS,QACT;CACA,SAAS,EACT,SAAS,QACT;CACA,SAAS,EACT,SAAS,QACT;CACA,SAAS,EACT,SAAS,MACT;CACA,SAAS,EACT,SAAS,iFACT;CACA,SAAS,EACT,SAAS,aACT;CACA,SAAS,EACT,SAAS,SACT;CACA,SAAS,EACT,SAAS,SACT;CACA,SAAS,EACT,SAAS,OACT;CACA,SAAS,EACT,SAAS,YACT;CACA,SAAS,EACT,SAAS,sCACT;CACA,SAAS,EACT,SAAS,WACT;CACA,SAA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Aa,GAAG,EAAE,QAAA,CAAS,QAAQ,KAAK,GAAG;CACpD,CAAC;CAED,mBAAmB;EACjB,MAAM,QAAQ,cAAc;EAC5B,IAAI,WAAW;GACb,eAAe,WAAW;GAC1B,SAAS,OAAO,WAAW;EAC7B;CACF,CAAC;CAED,MAAM,kBAAkB,iBAAiB;EACvC,MAAM,IAAI,SAAS;EACnB,MAAM,QAAQ,EAAE;EAChB,OAAO;GACL,MAAM;GACN,iBAAiB,UAAU,KAAA,KAAa,CAAC,MAAM,KAAK,IAAI,QAAQ,KAAA;GAChE,kBAAkB,cAAc;GAChC,iBAAiB,EAAE;GACnB,iBAAiB,EAAE;GACnB,iBAAiB,EAAE,cAAc,KAAA;GACjC,iBAAiB,EAAE,cAAc,KAAA;GACjC,iBAAiB,EAAE,cAAc,KAAA;GACjC;GACA;GACA;EACF;CACF,CAAC;CAED,OAAO,EACL,IAAI,kBAAkB;EACpB,OAAO,gBAAgB;CACzB,EACF;AACF"}
|
|
1
|
+
{"version":3,"file":"spinbutton.js","names":[],"sources":["../../src/spinbutton/intl.ts","../../src/spinbutton/createSpinButton.ts"],"sourcesContent":["// Spinbutton announcement catalog, ported verbatim from @react-aria/spinbutton's\n// intl/*.json (34 locales). Keep in sync with the vendored react-spectrum source on\n// every pin bump.\nimport { LocalizedStringDictionary } from \"@internationalized/string\";\n\nexport type SpinButtonStringKey = \"Empty\";\n\nexport const spinButtonStrings: Record<string, Record<SpinButtonStringKey, string>> = {\n \"ar-AE\": {\n Empty: `\\u{641}\\u{627}\\u{631}\\u{63A}`,\n },\n \"bg-BG\": {\n Empty: `\\u{418}\\u{437}\\u{43F}\\u{440}\\u{430}\\u{437}\\u{43D}\\u{438}`,\n },\n \"cs-CZ\": {\n Empty: `Pr\\xe1zdn\\xe9`,\n },\n \"da-DK\": {\n Empty: `Tom`,\n },\n \"de-DE\": {\n Empty: `Leer`,\n },\n \"el-GR\": {\n Empty: `\\u{386}\\u{3B4}\\u{3B5}\\u{3B9}\\u{3BF}`,\n },\n \"en-US\": {\n Empty: `Empty`,\n },\n \"es-ES\": {\n Empty: `Vac\\xedo`,\n },\n \"et-EE\": {\n Empty: `T\\xfchjenda`,\n },\n \"fi-FI\": {\n Empty: `Tyhj\\xe4`,\n },\n \"fr-FR\": {\n Empty: `Vide`,\n },\n \"he-IL\": {\n Empty: `\\u{5E8}\\u{5D9}\\u{5E7}`,\n },\n \"hr-HR\": {\n Empty: `Prazno`,\n },\n \"hu-HU\": {\n Empty: `\\xdcres`,\n },\n \"it-IT\": {\n Empty: `Vuoto`,\n },\n \"ja-JP\": {\n Empty: `\\u{7A7A}`,\n },\n \"ko-KR\": {\n Empty: `\\u{BE44}\\u{C5B4} \\u{C788}\\u{C74C}`,\n },\n \"lt-LT\": {\n Empty: `Tu\\u{161}\\u{10D}ias`,\n },\n \"lv-LV\": {\n Empty: `Tuk\\u{161}s`,\n },\n \"nb-NO\": {\n Empty: `Tom`,\n },\n \"nl-NL\": {\n Empty: `Leeg`,\n },\n \"pl-PL\": {\n Empty: `Pusty`,\n },\n \"pt-BR\": {\n Empty: `Vazio`,\n },\n \"pt-PT\": {\n Empty: `Vazio`,\n },\n \"ro-RO\": {\n Empty: `Gol`,\n },\n \"ru-RU\": {\n Empty: `\\u{41D}\\u{435} \\u{437}\\u{430}\\u{43F}\\u{43E}\\u{43B}\\u{43D}\\u{435}\\u{43D}\\u{43E}`,\n },\n \"sk-SK\": {\n Empty: `Pr\\xe1zdne`,\n },\n \"sl-SI\": {\n Empty: `Prazen`,\n },\n \"sr-SP\": {\n Empty: `Prazno`,\n },\n \"sv-SE\": {\n Empty: `Tomt`,\n },\n \"tr-TR\": {\n Empty: `Bo\\u{15F}`,\n },\n \"uk-UA\": {\n Empty: `\\u{41F}\\u{443}\\u{441}\\u{442}\\u{43E}`,\n },\n \"zh-CN\": {\n Empty: `\\u{7A7A}`,\n },\n \"zh-TW\": {\n Empty: `\\u{7A7A}\\u{767D}`,\n },\n};\n\nexport const spinButtonDictionary = new LocalizedStringDictionary<SpinButtonStringKey, string>(\n spinButtonStrings,\n);\n","/**\n * createSpinButton hook for Solidaria\n *\n * Provides the ARIA spinbutton props and live-region announcement behaviour for\n * a single spinbutton (e.g. a date-field segment). Port of the keyboard/announce\n * portion of @react-aria/spinbutton `useSpinButton`. The pointer press-and-hold\n * button machinery (increment/decrement buttons) is intentionally omitted — date\n * segments drive value changes through the keyboard only.\n */\n\nimport { createMemo, createEffect } from \"solid-js\";\nimport { access, type MaybeAccessor } from \"../utils/reactivity\";\nimport { createStringFormatter } from \"../i18n\";\nimport { announce, clearAnnouncer } from \"../live-announcer\";\nimport { spinButtonStrings, type SpinButtonStringKey } from \"./intl\";\n\nexport interface SpinButtonProps {\n /** The current value of the spinbutton. */\n value?: number;\n /** A human-readable text alternative for the value. */\n textValue?: string;\n /** The smallest value allowed. */\n minValue?: number;\n /** The largest value allowed. */\n maxValue?: number;\n /** Whether the spinbutton is disabled. */\n isDisabled?: boolean;\n /** Whether the spinbutton is read only. */\n isReadOnly?: boolean;\n /** Whether the spinbutton is required. */\n isRequired?: boolean;\n onIncrement?: () => void;\n onIncrementPage?: () => void;\n onDecrement?: () => void;\n onDecrementPage?: () => void;\n onDecrementToMin?: () => void;\n onIncrementToMax?: () => void;\n}\n\nexport interface SpinButtonAria {\n /** Props for the spinbutton element. */\n spinButtonProps: Record<string, unknown>;\n}\n\n/**\n * Provides the behaviour and accessibility implementation for a spinbutton.\n */\nexport function createSpinButton(props: MaybeAccessor<SpinButtonProps>): SpinButtonAria {\n const getProps = () => access(props);\n const stringFormatter = createStringFormatter<SpinButtonStringKey>(\n spinButtonStrings,\n \"@react-aria/spinbutton\",\n );\n\n const onKeyDown = (e: KeyboardEvent) => {\n const p = getProps();\n if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey || p.isReadOnly || e.isComposing) {\n return;\n }\n\n switch (e.key) {\n // Upstream deliberately falls through PageUp → ArrowUp when no page\n // handler exists; our tsconfig forbids lexical fallthrough, so the\n // PageUp case mirrors that branch inline instead.\n case \"PageUp\":\n if (p.onIncrementPage) {\n e.preventDefault();\n p.onIncrementPage();\n } else if (p.onIncrement) {\n e.preventDefault();\n p.onIncrement();\n }\n break;\n case \"ArrowUp\":\n case \"Up\":\n if (p.onIncrement) {\n e.preventDefault();\n p.onIncrement();\n }\n break;\n // Same faithful fallthrough as PageUp, mirrored inline (PageDown → ArrowDown).\n case \"PageDown\":\n if (p.onDecrementPage) {\n e.preventDefault();\n p.onDecrementPage();\n } else if (p.onDecrement) {\n e.preventDefault();\n p.onDecrement();\n }\n break;\n case \"ArrowDown\":\n case \"Down\":\n if (p.onDecrement) {\n e.preventDefault();\n p.onDecrement();\n }\n break;\n case \"Home\":\n if (p.onDecrementToMin) {\n e.preventDefault();\n p.onDecrementToMin();\n }\n break;\n case \"End\":\n if (p.onIncrementToMax) {\n e.preventDefault();\n p.onIncrementToMax();\n }\n break;\n }\n };\n\n // Non-reactive focus flag — matches upstream's `isFocused` ref. Toggling it must\n // NOT re-run the announce effect; only a change in `ariaTextValue` announces.\n let isFocused = false;\n const onFocus = () => {\n isFocused = true;\n };\n const onBlur = () => {\n isFocused = false;\n };\n\n // Replace Unicode hyphen-minus (U+002D) with minus sign (U+2212) so VoiceOver\n // announces it as \"minus\". Replace the empty string with the word \"Empty\".\n const ariaTextValue = createMemo(() => {\n const p = getProps();\n return p.textValue === \"\"\n ? stringFormatter().format(\"Empty\")\n : (p.textValue || `${p.value}`).replace(\"-\", \"−\");\n });\n\n createEffect(() => {\n const value = ariaTextValue();\n if (isFocused) {\n clearAnnouncer(\"assertive\");\n announce(value, \"assertive\");\n }\n });\n\n const spinButtonProps = createMemo(() => {\n const p = getProps();\n const value = p.value;\n return {\n role: \"spinbutton\",\n \"aria-valuenow\": value !== undefined && !isNaN(value) ? value : undefined,\n \"aria-valuetext\": ariaTextValue(),\n \"aria-valuemin\": p.minValue,\n \"aria-valuemax\": p.maxValue,\n \"aria-disabled\": p.isDisabled || undefined,\n \"aria-readonly\": p.isReadOnly || undefined,\n \"aria-required\": p.isRequired || undefined,\n onKeyDown,\n onFocus,\n onBlur,\n };\n });\n\n return {\n get spinButtonProps() {\n return spinButtonProps();\n },\n };\n}\n"],"mappings":";;;;;;AAOA,MAAa,oBAAyE;CACpF,SAAS,EACP,OAAO,+BACT;CACA,SAAS,EACP,OAAO,2DACT;CACA,SAAS,EACP,OAAO,gBACT;CACA,SAAS,EACP,OAAO,MACT;CACA,SAAS,EACP,OAAO,OACT;CACA,SAAS,EACP,OAAO,sCACT;CACA,SAAS,EACP,OAAO,QACT;CACA,SAAS,EACP,OAAO,WACT;CACA,SAAS,EACP,OAAO,cACT;CACA,SAAS,EACP,OAAO,WACT;CACA,SAAS,EACP,OAAO,OACT;CACA,SAAS,EACP,OAAO,wBACT;CACA,SAAS,EACP,OAAO,SACT;CACA,SAAS,EACP,OAAO,UACT;CACA,SAAS,EACP,OAAO,QACT;CACA,SAAS,EACP,OAAO,WACT;CACA,SAAS,EACP,OAAO,oCACT;CACA,SAAS,EACP,OAAO,sBACT;CACA,SAAS,EACP,OAAO,cACT;CACA,SAAS,EACP,OAAO,MACT;CACA,SAAS,EACP,OAAO,OACT;CACA,SAAS,EACP,OAAO,QACT;CACA,SAAS,EACP,OAAO,QACT;CACA,SAAS,EACP,OAAO,QACT;CACA,SAAS,EACP,OAAO,MACT;CACA,SAAS,EACP,OAAO,iFACT;CACA,SAAS,EACP,OAAO,aACT;CACA,SAAS,EACP,OAAO,SACT;CACA,SAAS,EACP,OAAO,SACT;CACA,SAAS,EACP,OAAO,OACT;CACA,SAAS,EACP,OAAO,YACT;CACA,SAAS,EACP,OAAO,sCACT;CACA,SAAS,EACP,OAAO,WACT;CACA,SAAS,EACP,OAAO,mBACT;AACF;AAEA,MAAa,uBAAuB,IAAI,0BACtC,iBACF;;;;;;;;;;;;;;;ACnEA,SAAgB,iBAAiB,OAAuD;CACtF,MAAM,iBAAiB,OAAO,KAAK;CACnC,MAAM,kBAAkB,sBACtB,mBACA,wB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