@proyecto-viviana/solidaria-components 0.3.2 → 0.4.0
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/ActionBar.js +184 -0
- package/dist/ActionBar.js.map +1 -0
- package/dist/ActionBar.jsx +128 -0
- package/dist/ActionBar.jsx.map +1 -0
- package/dist/ActionGroup.js +179 -0
- package/dist/ActionGroup.js.map +1 -0
- package/dist/ActionGroup.jsx +129 -0
- package/dist/ActionGroup.jsx.map +1 -0
- package/dist/Alert.js +111 -0
- package/dist/Alert.js.map +1 -0
- package/dist/Alert.jsx +82 -0
- package/dist/Alert.jsx.map +1 -0
- package/dist/Autocomplete.js +130 -0
- package/dist/Autocomplete.js.map +1 -0
- package/dist/Autocomplete.jsx +116 -0
- package/dist/Autocomplete.jsx.map +1 -0
- package/dist/Breadcrumbs.d.ts.map +1 -1
- package/dist/Breadcrumbs.js +334 -0
- package/dist/Breadcrumbs.js.map +1 -0
- package/dist/Breadcrumbs.jsx +266 -0
- package/dist/Breadcrumbs.jsx.map +1 -0
- package/dist/Button.d.ts.map +1 -1
- package/dist/Button.js +348 -0
- package/dist/Button.js.map +1 -0
- package/dist/Button.jsx +314 -0
- package/dist/Button.jsx.map +1 -0
- package/dist/Calendar.d.ts +4 -4
- package/dist/Calendar.d.ts.map +1 -1
- package/dist/Calendar.js +538 -0
- package/dist/Calendar.js.map +1 -0
- package/dist/Calendar.jsx +333 -0
- package/dist/Calendar.jsx.map +1 -0
- package/dist/CalendarPicker.d.ts +33 -0
- package/dist/CalendarPicker.d.ts.map +1 -0
- package/dist/CalendarPicker.js +44 -0
- package/dist/CalendarPicker.js.map +1 -0
- package/dist/CalendarPicker.jsx +44 -0
- package/dist/CalendarPicker.jsx.map +1 -0
- package/dist/Checkbox.d.ts +83 -4
- package/dist/Checkbox.d.ts.map +1 -1
- package/dist/Checkbox.js +923 -0
- package/dist/Checkbox.js.map +1 -0
- package/dist/Checkbox.jsx +707 -0
- package/dist/Checkbox.jsx.map +1 -0
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +202 -0
- package/dist/Collection.js.map +1 -0
- package/dist/Collection.jsx +152 -0
- package/dist/Collection.jsx.map +1 -0
- package/dist/Color.d.ts.map +1 -1
- package/dist/Color.js +1720 -0
- package/dist/Color.js.map +1 -0
- package/dist/Color.jsx +1344 -0
- package/dist/Color.jsx.map +1 -0
- package/dist/ColorEditor.js +208 -0
- package/dist/ColorEditor.js.map +1 -0
- package/dist/ColorEditor.jsx +120 -0
- package/dist/ColorEditor.jsx.map +1 -0
- package/dist/ComboBox.d.ts +4 -4
- package/dist/ComboBox.d.ts.map +1 -1
- package/dist/ComboBox.js +992 -0
- package/dist/ComboBox.js.map +1 -0
- package/dist/ComboBox.jsx +714 -0
- package/dist/ComboBox.jsx.map +1 -0
- package/dist/ContextualHelpTrigger.js +146 -0
- package/dist/ContextualHelpTrigger.js.map +1 -0
- package/dist/ContextualHelpTrigger.jsx +109 -0
- package/dist/ContextualHelpTrigger.jsx.map +1 -0
- package/dist/DateField.d.ts +3 -3
- package/dist/DateField.d.ts.map +1 -1
- package/dist/DateField.js +4 -0
- package/dist/DateField.jsx +4 -0
- package/dist/DateField2.js +499 -0
- package/dist/DateField2.js.map +1 -0
- package/dist/DateField2.jsx +317 -0
- package/dist/DateField2.jsx.map +1 -0
- package/dist/DatePicker.d.ts +4 -4
- package/dist/DatePicker.d.ts.map +1 -1
- package/dist/DatePicker.js +991 -0
- package/dist/DatePicker.js.map +1 -0
- package/dist/DatePicker.jsx +682 -0
- package/dist/DatePicker.jsx.map +1 -0
- package/dist/Dialog.d.ts.map +1 -1
- package/dist/Dialog.js +337 -0
- package/dist/Dialog.js.map +1 -0
- package/dist/Dialog.jsx +192 -0
- package/dist/Dialog.jsx.map +1 -0
- package/dist/Disclosure.d.ts.map +1 -1
- package/dist/Disclosure.js +328 -0
- package/dist/Disclosure.js.map +1 -0
- package/dist/Disclosure.jsx +230 -0
- package/dist/Disclosure.jsx.map +1 -0
- package/dist/DragAndDrop.d.ts.map +1 -1
- package/dist/DragAndDrop.js +176 -0
- package/dist/DragAndDrop.js.map +1 -0
- package/dist/DragAndDrop.jsx +160 -0
- package/dist/DragAndDrop.jsx.map +1 -0
- package/dist/DropZone.d.ts.map +1 -1
- package/dist/DropZone.js +189 -0
- package/dist/DropZone.js.map +1 -0
- package/dist/DropZone.jsx +144 -0
- package/dist/DropZone.jsx.map +1 -0
- package/dist/FieldError.js +66 -0
- package/dist/FieldError.js.map +1 -0
- package/dist/FieldError.jsx +47 -0
- package/dist/FieldError.jsx.map +1 -0
- package/dist/FileTrigger.js +79 -0
- package/dist/FileTrigger.js.map +1 -0
- package/dist/FileTrigger.jsx +49 -0
- package/dist/FileTrigger.jsx.map +1 -0
- package/dist/Focusable.js +70 -0
- package/dist/Focusable.js.map +1 -0
- package/dist/Focusable.jsx +69 -0
- package/dist/Focusable.jsx.map +1 -0
- package/dist/Form.js +99 -0
- package/dist/Form.js.map +1 -0
- package/dist/Form.jsx +73 -0
- package/dist/Form.jsx.map +1 -0
- package/dist/GridList.d.ts +34 -2
- package/dist/GridList.d.ts.map +1 -1
- package/dist/GridList.js +723 -0
- package/dist/GridList.js.map +1 -0
- package/dist/GridList.jsx +552 -0
- package/dist/GridList.jsx.map +1 -0
- package/dist/HiddenTimeInput.js +104 -0
- package/dist/HiddenTimeInput.js.map +1 -0
- package/dist/HiddenTimeInput.jsx +69 -0
- package/dist/HiddenTimeInput.jsx.map +1 -0
- package/dist/Icon.d.ts.map +1 -1
- package/dist/Icon.js +127 -0
- package/dist/Icon.js.map +1 -0
- package/dist/Icon.jsx +72 -0
- package/dist/Icon.jsx.map +1 -0
- package/dist/Keyboard.js +30 -0
- package/dist/Keyboard.js.map +1 -0
- package/dist/Keyboard.jsx +24 -0
- package/dist/Keyboard.jsx.map +1 -0
- package/dist/Landmark.js +134 -0
- package/dist/Landmark.js.map +1 -0
- package/dist/Landmark.jsx +118 -0
- package/dist/Landmark.jsx.map +1 -0
- package/dist/Link.d.ts.map +1 -1
- package/dist/Link.js +219 -0
- package/dist/Link.js.map +1 -0
- package/dist/Link.jsx +189 -0
- package/dist/Link.jsx.map +1 -0
- package/dist/ListBox.d.ts.map +1 -1
- package/dist/ListBox.js +670 -0
- package/dist/ListBox.js.map +1 -0
- package/dist/ListBox.jsx +508 -0
- package/dist/ListBox.jsx.map +1 -0
- package/dist/Menu.d.ts +27 -9
- package/dist/Menu.d.ts.map +1 -1
- package/dist/Menu.js +1254 -0
- package/dist/Menu.js.map +1 -0
- package/dist/Menu.jsx +1042 -0
- package/dist/Menu.jsx.map +1 -0
- package/dist/Meter.d.ts.map +1 -1
- package/dist/Meter.js +123 -0
- package/dist/Meter.js.map +1 -0
- package/dist/Meter.jsx +107 -0
- package/dist/Meter.jsx.map +1 -0
- package/dist/Modal.d.ts.map +1 -1
- package/dist/Modal.js +380 -0
- package/dist/Modal.js.map +1 -0
- package/dist/Modal.jsx +314 -0
- package/dist/Modal.jsx.map +1 -0
- package/dist/NumberField.d.ts +3 -3
- package/dist/NumberField.d.ts.map +1 -1
- package/dist/NumberField.js +573 -0
- package/dist/NumberField.js.map +1 -0
- package/dist/NumberField.jsx +443 -0
- package/dist/NumberField.jsx.map +1 -0
- package/dist/Popover.d.ts +10 -2
- package/dist/Popover.d.ts.map +1 -1
- package/dist/Popover.js +464 -0
- package/dist/Popover.js.map +1 -0
- package/dist/Popover.jsx +333 -0
- package/dist/Popover.jsx.map +1 -0
- package/dist/Pressable.js +69 -0
- package/dist/Pressable.js.map +1 -0
- package/dist/Pressable.jsx +68 -0
- package/dist/Pressable.jsx.map +1 -0
- package/dist/ProgressBar.d.ts.map +1 -1
- package/dist/ProgressBar.js +130 -0
- package/dist/ProgressBar.js.map +1 -0
- package/dist/ProgressBar.jsx +114 -0
- package/dist/ProgressBar.jsx.map +1 -0
- package/dist/RadioGroup.d.ts +82 -4
- package/dist/RadioGroup.d.ts.map +1 -1
- package/dist/RadioGroup.js +931 -0
- package/dist/RadioGroup.js.map +1 -0
- package/dist/RadioGroup.jsx +681 -0
- package/dist/RadioGroup.jsx.map +1 -0
- package/dist/RangeCalendar.d.ts.map +1 -1
- package/dist/RangeCalendar.js +410 -0
- package/dist/RangeCalendar.js.map +1 -0
- package/dist/RangeCalendar.jsx +253 -0
- package/dist/RangeCalendar.jsx.map +1 -0
- package/dist/RouterProvider.js +118 -0
- package/dist/RouterProvider.js.map +1 -0
- package/dist/RouterProvider.jsx +112 -0
- package/dist/RouterProvider.jsx.map +1 -0
- package/dist/SearchField.d.ts +2 -2
- package/dist/SearchField.d.ts.map +1 -1
- package/dist/SearchField.js +643 -0
- package/dist/SearchField.js.map +1 -0
- package/dist/SearchField.jsx +526 -0
- package/dist/SearchField.jsx.map +1 -0
- package/dist/Select.d.ts.map +1 -1
- package/dist/Select.js +1031 -0
- package/dist/Select.js.map +1 -0
- package/dist/Select.jsx +744 -0
- package/dist/Select.jsx.map +1 -0
- package/dist/SelectionIndicator.d.ts.map +1 -1
- package/dist/SelectionIndicator.js +86 -0
- package/dist/SelectionIndicator.js.map +1 -0
- package/dist/SelectionIndicator.jsx +50 -0
- package/dist/SelectionIndicator.jsx.map +1 -0
- package/dist/Separator.js +97 -0
- package/dist/Separator.js.map +1 -0
- package/dist/Separator.jsx +85 -0
- package/dist/Separator.jsx.map +1 -0
- package/dist/SharedElementTransition.d.ts.map +1 -1
- package/dist/SharedElementTransition.js +165 -0
- package/dist/SharedElementTransition.js.map +1 -0
- package/dist/SharedElementTransition.jsx +138 -0
- package/dist/SharedElementTransition.jsx.map +1 -0
- package/dist/Slider.d.ts +33 -1
- package/dist/Slider.d.ts.map +1 -1
- package/dist/Slider.js +515 -0
- package/dist/Slider.js.map +1 -0
- package/dist/Slider.jsx +403 -0
- package/dist/Slider.jsx.map +1 -0
- package/dist/StepList.js +198 -0
- package/dist/StepList.js.map +1 -0
- package/dist/StepList.jsx +141 -0
- package/dist/StepList.jsx.map +1 -0
- package/dist/Switch.d.ts +65 -2
- package/dist/Switch.d.ts.map +1 -1
- package/dist/Switch.js +534 -0
- package/dist/Switch.js.map +1 -0
- package/dist/Switch.jsx +393 -0
- package/dist/Switch.jsx.map +1 -0
- package/dist/Table.d.ts +48 -0
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js +1759 -0
- package/dist/Table.js.map +1 -0
- package/dist/Table.jsx +1348 -0
- package/dist/Table.jsx.map +1 -0
- package/dist/Tabs.d.ts +0 -4
- package/dist/Tabs.d.ts.map +1 -1
- package/dist/Tabs.js +595 -0
- package/dist/Tabs.js.map +1 -0
- package/dist/Tabs.jsx +367 -0
- package/dist/Tabs.jsx.map +1 -0
- package/dist/TagGroup.d.ts.map +1 -1
- package/dist/TagGroup.js +378 -0
- package/dist/TagGroup.js.map +1 -0
- package/dist/TagGroup.jsx +270 -0
- package/dist/TagGroup.jsx.map +1 -0
- package/dist/Text.d.ts +18 -6
- package/dist/Text.d.ts.map +1 -1
- package/dist/Text.js +42 -0
- package/dist/Text.js.map +1 -0
- package/dist/Text.jsx +35 -0
- package/dist/Text.jsx.map +1 -0
- package/dist/TextField.d.ts +6 -6
- package/dist/TextField.d.ts.map +1 -1
- package/dist/TextField.js +436 -0
- package/dist/TextField.js.map +1 -0
- package/dist/TextField.jsx +403 -0
- package/dist/TextField.jsx.map +1 -0
- package/dist/TimeField.d.ts +3 -3
- package/dist/TimeField.d.ts.map +1 -1
- package/dist/TimeField.js +372 -0
- package/dist/TimeField.js.map +1 -0
- package/dist/TimeField.jsx +224 -0
- package/dist/TimeField.jsx.map +1 -0
- package/dist/Toast.d.ts +14 -0
- package/dist/Toast.d.ts.map +1 -1
- package/dist/Toast.js +551 -0
- package/dist/Toast.js.map +1 -0
- package/dist/Toast.jsx +361 -0
- package/dist/Toast.jsx.map +1 -0
- package/dist/ToggleButton.d.ts.map +1 -1
- package/dist/ToggleButton.js +123 -0
- package/dist/ToggleButton.js.map +1 -0
- package/dist/ToggleButton.jsx +88 -0
- package/dist/ToggleButton.jsx.map +1 -0
- package/dist/ToggleButtonGroup.d.ts.map +1 -1
- package/dist/ToggleButtonGroup.js +114 -0
- package/dist/ToggleButtonGroup.js.map +1 -0
- package/dist/ToggleButtonGroup.jsx +85 -0
- package/dist/ToggleButtonGroup.jsx.map +1 -0
- package/dist/Toolbar.js +112 -0
- package/dist/Toolbar.js.map +1 -0
- package/dist/Toolbar.jsx +92 -0
- package/dist/Toolbar.jsx.map +1 -0
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/Tooltip.js +539 -0
- package/dist/Tooltip.js.map +1 -0
- package/dist/Tooltip.jsx +465 -0
- package/dist/Tooltip.jsx.map +1 -0
- package/dist/Tree.d.ts +14 -2
- package/dist/Tree.d.ts.map +1 -1
- package/dist/Tree.js +1424 -0
- package/dist/Tree.js.map +1 -0
- package/dist/Tree.jsx +1172 -0
- package/dist/Tree.jsx.map +1 -0
- package/dist/Virtualizer.d.ts +16 -2
- package/dist/Virtualizer.d.ts.map +1 -1
- package/dist/Virtualizer.js +2 -0
- package/dist/Virtualizer.jsx +2 -0
- package/dist/Virtualizer2.js +751 -0
- package/dist/Virtualizer2.js.map +1 -0
- package/dist/Virtualizer2.jsx +730 -0
- package/dist/Virtualizer2.jsx.map +1 -0
- package/dist/VirtualizerLayouts.d.ts +18 -0
- package/dist/VirtualizerLayouts.d.ts.map +1 -1
- package/dist/VisuallyHidden.js +42 -0
- package/dist/VisuallyHidden.js.map +1 -0
- package/dist/VisuallyHidden.jsx +35 -0
- package/dist/VisuallyHidden.jsx.map +1 -0
- package/dist/contexts.js +33 -0
- package/dist/contexts.js.map +1 -0
- package/dist/contexts.jsx +33 -0
- package/dist/contexts.jsx.map +1 -0
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +70 -23932
- package/dist/index.jsx +70 -18337
- package/dist/useDragAndDrop.js +2 -0
- package/dist/useDragAndDrop.jsx +2 -0
- package/dist/useDragAndDrop2.js +395 -0
- package/dist/useDragAndDrop2.js.map +1 -0
- package/dist/useDragAndDrop2.jsx +395 -0
- package/dist/useDragAndDrop2.jsx.map +1 -0
- package/dist/utils.d.ts +83 -11
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +285 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.jsx +277 -0
- package/dist/utils.jsx.map +1 -0
- package/dist/virtualizer/Layout.js +144 -0
- package/dist/virtualizer/Layout.js.map +1 -0
- package/dist/virtualizer/Layout.jsx +144 -0
- package/dist/virtualizer/Layout.jsx.map +1 -0
- package/package.json +401 -4
- package/src/Breadcrumbs.tsx +3 -1
- package/src/Button.tsx +22 -2
- package/src/Calendar.tsx +27 -10
- package/src/CalendarPicker.tsx +73 -0
- package/src/Checkbox.tsx +539 -3
- package/src/Collection.tsx +9 -3
- package/src/Color.tsx +42 -14
- package/src/ComboBox.tsx +50 -6
- package/src/DateField.tsx +20 -2
- package/src/DatePicker.tsx +57 -5
- package/src/Dialog.tsx +13 -5
- package/src/Disclosure.tsx +3 -1
- package/src/DragAndDrop.tsx +3 -1
- package/src/DropZone.tsx +3 -1
- package/src/GridList.tsx +125 -24
- package/src/Icon.tsx +3 -1
- package/src/Link.tsx +3 -1
- package/src/ListBox.tsx +31 -4
- package/src/Menu.tsx +252 -128
- package/src/Meter.tsx +3 -1
- package/src/Modal.tsx +100 -52
- package/src/NumberField.tsx +51 -8
- package/src/Popover.tsx +40 -10
- package/src/ProgressBar.tsx +3 -1
- package/src/RadioGroup.tsx +468 -4
- package/src/RangeCalendar.tsx +3 -1
- package/src/SearchField.tsx +27 -3
- package/src/Select.tsx +22 -7
- package/src/SelectionIndicator.tsx +3 -1
- package/src/SharedElementTransition.tsx +3 -1
- package/src/Slider.tsx +159 -13
- package/src/Switch.tsx +395 -2
- package/src/Table.tsx +409 -95
- package/src/Tabs.tsx +16 -45
- package/src/TagGroup.tsx +3 -1
- package/src/Text.tsx +31 -10
- package/src/TextField.tsx +43 -5
- package/src/TimeField.tsx +20 -2
- package/src/Toast.tsx +79 -14
- package/src/ToggleButton.tsx +3 -1
- package/src/ToggleButtonGroup.tsx +3 -1
- package/src/Tooltip.tsx +3 -1
- package/src/Tree.tsx +77 -9
- package/src/Virtualizer.tsx +180 -31
- package/src/VirtualizerLayouts.ts +45 -10
- package/src/index.ts +50 -0
- package/src/utils.tsx +243 -27
- package/dist/index.js.map +0 -1
- package/dist/index.jsx.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldError.js","names":["JSX","Show","createContext","createMemo","splitProps","useContext","DEFAULT_VALIDATION_RESULT","ValidationResult","ClassNameOrFunction","StyleOrFunction","RenderChildren","SlotProps","useRenderProps","filterDOMProps","FieldErrorRenderProps","FieldErrorContextValue","validation","errorMessageProps","HTMLAttributes","HTMLElement","FieldErrorProps","Omit","children","class","style","FieldErrorContext","FieldError","props","Element","contextValue","contextValidation","contextErrorMessageProps","local","domProps","renderProps","currentValidation","validationErrors","join","defaultClassName","filteredDomProps","global","renderChildren","_$createComponent","when","_$memo","isInvalid","_el$","_$getNextElement","_tmpl$","_$spread","_$mergeProps","HTMLDivElement","slot","_$insert","_$runHydrationEvents"],"sources":["../src/FieldError.tsx"],"sourcesContent":["/**\n * FieldError primitive for solidaria-components.\n *\n * Displays validation errors for a field from context or explicit validation prop.\n * Port direction: react-aria-components/src/FieldError.tsx\n */\n\nimport { type JSX, Show, createContext, createMemo, splitProps, useContext } from \"solid-js\";\nimport { DEFAULT_VALIDATION_RESULT, type ValidationResult } from \"@proyecto-viviana/solid-stately\";\nimport {\n type ClassNameOrFunction,\n type StyleOrFunction,\n type RenderChildren,\n type SlotProps,\n useRenderProps,\n filterDOMProps,\n} from \"./utils\";\n\nexport type FieldErrorRenderProps = ValidationResult;\n\nexport interface FieldErrorContextValue {\n validation: ValidationResult | null;\n errorMessageProps?: JSX.HTMLAttributes<HTMLElement>;\n}\n\nexport interface FieldErrorProps\n extends Omit<JSX.HTMLAttributes<HTMLElement>, \"children\" | \"class\" | \"style\">, SlotProps {\n /** Validation result. Falls back to context when omitted. */\n validation?: ValidationResult | null;\n /** The children of the component. */\n children?: RenderChildren<FieldErrorRenderProps>;\n /** The CSS className for the element. */\n class?: ClassNameOrFunction<FieldErrorRenderProps>;\n /** The inline style for the element. */\n style?: StyleOrFunction<FieldErrorRenderProps>;\n}\n\nexport const FieldErrorContext = createContext<ValidationResult | FieldErrorContextValue | null>(\n null,\n);\n\nexport function FieldError(props: FieldErrorProps): JSX.Element | null {\n const contextValue = useContext(FieldErrorContext);\n const contextValidation = () => {\n if (contextValue && \"validation\" in contextValue) {\n return contextValue.validation;\n }\n return contextValue;\n };\n const contextErrorMessageProps = () => {\n if (contextValue && \"validation\" in contextValue) {\n return contextValue.errorMessageProps ?? {};\n }\n return {};\n };\n const [local, domProps] = splitProps(props, [\"validation\", \"children\", \"class\", \"style\", \"slot\"]);\n\n const validation = createMemo<ValidationResult | null>(\n () => local.validation ?? contextValidation(),\n );\n\n const renderProps = useRenderProps(\n {\n children:\n local.children ?? ((currentValidation) => currentValidation.validationErrors.join(\" \")),\n class: local.class,\n style: local.style,\n defaultClassName: \"solidaria-FieldError\",\n },\n () => validation() ?? DEFAULT_VALIDATION_RESULT,\n );\n\n const filteredDomProps = filterDOMProps(domProps, { global: true });\n const children = () => renderProps.renderChildren();\n\n return (\n <Show when={validation()?.isInvalid && children()}>\n <div\n {...(contextErrorMessageProps() as unknown as JSX.HTMLAttributes<HTMLDivElement>)}\n {...(filteredDomProps as JSX.HTMLAttributes<HTMLDivElement>)}\n slot={local.slot ?? \"errorMessage\"}\n class={renderProps.class()}\n style={renderProps.style()}\n >\n {children()}\n </div>\n </Show>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAqCA,MAAayB,oBAAoBvB,cAC/B,IACF;AAEA,SAAgBwB,WAAWC,OAA4C;CACrE,MAAME,eAAexB,WAAWoB,iBAAiB;CACjD,MAAMK,0BAA0B;EAC9B,IAAID,gBAAgB,gBAAgBA,cAClC,OAAOA,aAAab;EAEtB,OAAOa;CACT;CACA,MAAME,iCAAiC;EACrC,IAAIF,gBAAgB,gBAAgBA,cAClC,OAAOA,aAAaZ,qBAAqB,CAAC;EAE5C,OAAO,CAAC;CACV;CACA,MAAM,CAACe,OAAOC,YAAY7B,WAAWuB,OAAO;EAAC;EAAc;EAAY;EAAS;EAAS;CAAM,CAAC;CAEhG,MAAMX,aAAab,iBACX6B,MAAMhB,cAAcc,kBAAkB,CAC9C;CAEA,MAAMI,cAActB,eAClB;EACEU,UACEU,MAAMV,cAAca,sBAAsBA,kBAAkBC,iBAAiBC,KAAK,GAAG;EACvFd,OAAOS,MAAMT;EACbC,OAAOQ,MAAMR;EACbc,kBAAkB;CACpB,SACMtB,WAAW,KAAKV,yBACxB;CAEA,MAAMiC,mBAAmB1B,eAAeoB,UAAU,EAAEO,QAAQ,KAAK,CAAC;CAClE,MAAMlB,iBAAiBY,YAAYO,eAAe;CAElD,OAAAC,gBACGzC,MAAI;EAAA,IAAC0C,OAAI;GAAA,OAAEC,WAAA,CAAA,CAAA5B,WAAW,CAAC,EAAE6B,SAAS,CAAA,CAAA,KAAIvB,SAAS;EAAC;EAAA,IAAAA,WAAA;GAAA,IAAAwB,OAAAC,eAAAC,MAAA;GAAAC,OAAAH,MAAAI,iBAExCnB,yBAAyB,GACzBQ,kBAAsD;IAAA,IAC3Da,OAAI;KAAA,OAAEpB,MAAMoB,QAAQ;IAAc;IAAA,KAAA,WAAA;KAAA,OAC3BlB,YAAYX,MAAM;IAAC;IAAA,IAC1BC,QAAK;KAAA,OAAEU,YAAYV,MAAM;IAAC;GAAA,CAAA,GAAA,OAAA,IAAA;GAAA6B,OAAAP,MAEzBxB,QAAQ;GAAAgC,mBAAA;GAAA,OAAAR;EAAA;CAAA,CAAA;AAIjB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { filterDOMProps, useRenderProps } from "./utils.jsx";
|
|
2
|
+
import { Show, createContext, createMemo, splitProps, useContext } from "solid-js";
|
|
3
|
+
import { DEFAULT_VALIDATION_RESULT } from "@proyecto-viviana/solid-stately";
|
|
4
|
+
//#region src/FieldError.tsx
|
|
5
|
+
/**
|
|
6
|
+
* FieldError primitive for solidaria-components.
|
|
7
|
+
*
|
|
8
|
+
* Displays validation errors for a field from context or explicit validation prop.
|
|
9
|
+
* Port direction: react-aria-components/src/FieldError.tsx
|
|
10
|
+
*/
|
|
11
|
+
const FieldErrorContext = createContext(null);
|
|
12
|
+
function FieldError(props) {
|
|
13
|
+
const contextValue = useContext(FieldErrorContext);
|
|
14
|
+
const contextValidation = () => {
|
|
15
|
+
if (contextValue && "validation" in contextValue) return contextValue.validation;
|
|
16
|
+
return contextValue;
|
|
17
|
+
};
|
|
18
|
+
const contextErrorMessageProps = () => {
|
|
19
|
+
if (contextValue && "validation" in contextValue) return contextValue.errorMessageProps ?? {};
|
|
20
|
+
return {};
|
|
21
|
+
};
|
|
22
|
+
const [local, domProps] = splitProps(props, [
|
|
23
|
+
"validation",
|
|
24
|
+
"children",
|
|
25
|
+
"class",
|
|
26
|
+
"style",
|
|
27
|
+
"slot"
|
|
28
|
+
]);
|
|
29
|
+
const validation = createMemo(() => local.validation ?? contextValidation());
|
|
30
|
+
const renderProps = useRenderProps({
|
|
31
|
+
children: local.children ?? ((currentValidation) => currentValidation.validationErrors.join(" ")),
|
|
32
|
+
class: local.class,
|
|
33
|
+
style: local.style,
|
|
34
|
+
defaultClassName: "solidaria-FieldError"
|
|
35
|
+
}, () => validation() ?? DEFAULT_VALIDATION_RESULT);
|
|
36
|
+
const filteredDomProps = filterDOMProps(domProps, { global: true });
|
|
37
|
+
const children = () => renderProps.renderChildren();
|
|
38
|
+
return <Show when={validation()?.isInvalid && children()}>
|
|
39
|
+
<div {...contextErrorMessageProps()} {...filteredDomProps} slot={local.slot ?? "errorMessage"} class={renderProps.class()} style={renderProps.style()}>
|
|
40
|
+
{children()}
|
|
41
|
+
</div>
|
|
42
|
+
</Show>;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { FieldError, FieldErrorContext };
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=FieldError.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldError.jsx","names":[],"sources":["../src/FieldError.tsx"],"sourcesContent":["/**\n * FieldError primitive for solidaria-components.\n *\n * Displays validation errors for a field from context or explicit validation prop.\n * Port direction: react-aria-components/src/FieldError.tsx\n */\n\nimport { type JSX, Show, createContext, createMemo, splitProps, useContext } from \"solid-js\";\nimport { DEFAULT_VALIDATION_RESULT, type ValidationResult } from \"@proyecto-viviana/solid-stately\";\nimport {\n type ClassNameOrFunction,\n type StyleOrFunction,\n type RenderChildren,\n type SlotProps,\n useRenderProps,\n filterDOMProps,\n} from \"./utils\";\n\nexport type FieldErrorRenderProps = ValidationResult;\n\nexport interface FieldErrorContextValue {\n validation: ValidationResult | null;\n errorMessageProps?: JSX.HTMLAttributes<HTMLElement>;\n}\n\nexport interface FieldErrorProps\n extends Omit<JSX.HTMLAttributes<HTMLElement>, \"children\" | \"class\" | \"style\">, SlotProps {\n /** Validation result. Falls back to context when omitted. */\n validation?: ValidationResult | null;\n /** The children of the component. */\n children?: RenderChildren<FieldErrorRenderProps>;\n /** The CSS className for the element. */\n class?: ClassNameOrFunction<FieldErrorRenderProps>;\n /** The inline style for the element. */\n style?: StyleOrFunction<FieldErrorRenderProps>;\n}\n\nexport const FieldErrorContext = createContext<ValidationResult | FieldErrorContextValue | null>(\n null,\n);\n\nexport function FieldError(props: FieldErrorProps): JSX.Element | null {\n const contextValue = useContext(FieldErrorContext);\n const contextValidation = () => {\n if (contextValue && \"validation\" in contextValue) {\n return contextValue.validation;\n }\n return contextValue;\n };\n const contextErrorMessageProps = () => {\n if (contextValue && \"validation\" in contextValue) {\n return contextValue.errorMessageProps ?? {};\n }\n return {};\n };\n const [local, domProps] = splitProps(props, [\"validation\", \"children\", \"class\", \"style\", \"slot\"]);\n\n const validation = createMemo<ValidationResult | null>(\n () => local.validation ?? contextValidation(),\n );\n\n const renderProps = useRenderProps(\n {\n children:\n local.children ?? ((currentValidation) => currentValidation.validationErrors.join(\" \")),\n class: local.class,\n style: local.style,\n defaultClassName: \"solidaria-FieldError\",\n },\n () => validation() ?? DEFAULT_VALIDATION_RESULT,\n );\n\n const filteredDomProps = filterDOMProps(domProps, { global: true });\n const children = () => renderProps.renderChildren();\n\n return (\n <Show when={validation()?.isInvalid && children()}>\n <div\n {...(contextErrorMessageProps() as unknown as JSX.HTMLAttributes<HTMLDivElement>)}\n {...(filteredDomProps as JSX.HTMLAttributes<HTMLDivElement>)}\n slot={local.slot ?? \"errorMessage\"}\n class={renderProps.class()}\n style={renderProps.style()}\n >\n {children()}\n </div>\n </Show>\n );\n}\n"],"mappings":";;;;;;;;;;AAqCA,MAAa,oBAAoB,cAC/B,IACF;AAEA,SAAgB,WAAW,OAA4C;CACrE,MAAM,eAAe,WAAW,iBAAiB;CACjD,MAAM,0BAA0B;EAC9B,IAAI,gBAAgB,gBAAgB,cAClC,OAAO,aAAa;EAEtB,OAAO;CACT;CACA,MAAM,iCAAiC;EACrC,IAAI,gBAAgB,gBAAgB,cAClC,OAAO,aAAa,qBAAqB,CAAC;EAE5C,OAAO,CAAC;CACV;CACA,MAAM,CAAC,OAAO,YAAY,WAAW,OAAO;EAAC;EAAc;EAAY;EAAS;EAAS;CAAM,CAAC;CAEhG,MAAM,aAAa,iBACX,MAAM,cAAc,kBAAkB,CAC9C;CAEA,MAAM,cAAc,eAClB;EACE,UACE,MAAM,cAAc,sBAAsB,kBAAkB,iBAAiB,KAAK,GAAG;EACvF,OAAO,MAAM;EACb,OAAO,MAAM;EACb,kBAAkB;CACpB,SACM,WAAW,KAAK,yBACxB;CAEA,MAAM,mBAAmB,eAAe,UAAU,EAAE,QAAQ,KAAK,CAAC;CAClE,MAAM,iBAAiB,YAAY,eAAe;CAElD,OACE,CAAC,KAAK,MAAM,WAAW,CAAC,EAAE,aAAa,SAAS,GAAG;MACjD,CAAC,QACM,yBAAyB,OACzB,kBACL,MAAM,MAAM,QAAQ,gBACpB,OAAO,YAAY,MAAM,GACzB,OAAO,YAAY,MAAM,GAC1B;SACE,SAAS,EAAE;MACd,EAAE,IAAI;IACR,EAAE;AAEN"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { getNextElement, insert, mergeProps, runHydrationEvents, spread, template, use } from "solid-js/web";
|
|
2
|
+
import { createSignal, splitProps } from "solid-js";
|
|
3
|
+
import { createPress } from "@proyecto-viviana/solidaria";
|
|
4
|
+
//#region src/FileTrigger.tsx
|
|
5
|
+
/**
|
|
6
|
+
* FileTrigger primitive for solidaria-components.
|
|
7
|
+
*
|
|
8
|
+
* Opens the native file picker from any pressable child.
|
|
9
|
+
* Parity target: react-aria-components/src/FileTrigger.tsx
|
|
10
|
+
*/
|
|
11
|
+
var _tmpl$ = /*#__PURE__*/ template(`<span>`), _tmpl$2 = /*#__PURE__*/ template(`<input>`);
|
|
12
|
+
/**
|
|
13
|
+
* A FileTrigger allows a user to access the file system using a custom trigger.
|
|
14
|
+
*/
|
|
15
|
+
function FileTrigger(props) {
|
|
16
|
+
const [local, inputProps] = splitProps(props, [
|
|
17
|
+
"acceptedFileTypes",
|
|
18
|
+
"allowsMultiple",
|
|
19
|
+
"defaultCamera",
|
|
20
|
+
"acceptDirectory",
|
|
21
|
+
"onSelect",
|
|
22
|
+
"children",
|
|
23
|
+
"disabled"
|
|
24
|
+
]);
|
|
25
|
+
const [inputRef, setInputRef] = createSignal(null);
|
|
26
|
+
const openFilePicker = () => {
|
|
27
|
+
const input = inputRef();
|
|
28
|
+
if (!input) return;
|
|
29
|
+
if (input.value) input.value = "";
|
|
30
|
+
input.click();
|
|
31
|
+
};
|
|
32
|
+
const { pressProps } = createPress({
|
|
33
|
+
get isDisabled() {
|
|
34
|
+
return !!local.disabled;
|
|
35
|
+
},
|
|
36
|
+
onPress: (_e) => {
|
|
37
|
+
openFilePicker();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const onInputChange = (e) => {
|
|
41
|
+
local.onSelect?.(e.currentTarget.files);
|
|
42
|
+
};
|
|
43
|
+
return [(() => {
|
|
44
|
+
var _el$ = getNextElement(_tmpl$);
|
|
45
|
+
spread(_el$, pressProps, false, true);
|
|
46
|
+
insert(_el$, () => local.children);
|
|
47
|
+
runHydrationEvents();
|
|
48
|
+
return _el$;
|
|
49
|
+
})(), (() => {
|
|
50
|
+
var _el$2 = getNextElement(_tmpl$2);
|
|
51
|
+
use(setInputRef, _el$2);
|
|
52
|
+
spread(_el$2, mergeProps(inputProps, {
|
|
53
|
+
"type": "file",
|
|
54
|
+
"style": { display: "none" },
|
|
55
|
+
get accept() {
|
|
56
|
+
return local.acceptedFileTypes?.join(",");
|
|
57
|
+
},
|
|
58
|
+
get multiple() {
|
|
59
|
+
return local.allowsMultiple;
|
|
60
|
+
},
|
|
61
|
+
get capture() {
|
|
62
|
+
return local.defaultCamera;
|
|
63
|
+
},
|
|
64
|
+
get disabled() {
|
|
65
|
+
return local.disabled;
|
|
66
|
+
},
|
|
67
|
+
get webkitdirectory() {
|
|
68
|
+
return local.acceptDirectory ? "" : void 0;
|
|
69
|
+
},
|
|
70
|
+
"onChange": onInputChange
|
|
71
|
+
}), false, false);
|
|
72
|
+
runHydrationEvents();
|
|
73
|
+
return _el$2;
|
|
74
|
+
})()];
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
export { FileTrigger };
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=FileTrigger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileTrigger.js","names":["JSX","createSignal","splitProps","createPress","PressEvent","FileTriggerProps","Omit","InputHTMLAttributes","HTMLInputElement","acceptedFileTypes","ReadonlyArray","allowsMultiple","defaultCamera","acceptDirectory","onSelect","files","FileList","children","Element","FileTrigger","props","local","inputProps","inputRef","setInputRef","openFilePicker","input","value","click","pressProps","isDisabled","disabled","onPress","_e","onInputChange","EventHandler","Event","e","currentTarget","_el$","_$getNextElement","_tmpl$","_$spread","_$insert","_$runHydrationEvents","_el$2","_tmpl$2","_$use","_$mergeProps","display","accept","join","multiple","capture","webkitdirectory","undefined"],"sources":["../src/FileTrigger.tsx"],"sourcesContent":["/**\n * FileTrigger primitive for solidaria-components.\n *\n * Opens the native file picker from any pressable child.\n * Parity target: react-aria-components/src/FileTrigger.tsx\n */\n\nimport { type JSX, createSignal, splitProps } from \"solid-js\";\nimport { createPress, type PressEvent } from \"@proyecto-viviana/solidaria\";\n\nexport interface FileTriggerProps extends Omit<\n JSX.InputHTMLAttributes<HTMLInputElement>,\n \"type\" | \"onChange\" | \"children\" | \"onSelect\"\n> {\n /** Mime types accepted by the file picker. */\n acceptedFileTypes?: ReadonlyArray<string>;\n /** Whether multiple files can be selected. */\n allowsMultiple?: boolean;\n /** Default camera capture mode for mobile devices. */\n defaultCamera?: \"user\" | \"environment\";\n /** Enables directory selection in supported browsers. */\n acceptDirectory?: boolean;\n /** Called when user selection changes. */\n onSelect?: (files: FileList | null) => void;\n /** Trigger content (typically a button). */\n children?: JSX.Element;\n}\n\n/**\n * A FileTrigger allows a user to access the file system using a custom trigger.\n */\nexport function FileTrigger(props: FileTriggerProps): JSX.Element {\n const [local, inputProps] = splitProps(props, [\n \"acceptedFileTypes\",\n \"allowsMultiple\",\n \"defaultCamera\",\n \"acceptDirectory\",\n \"onSelect\",\n \"children\",\n \"disabled\",\n ]);\n\n const [inputRef, setInputRef] = createSignal<HTMLInputElement | null>(null);\n\n const openFilePicker = () => {\n const input = inputRef();\n if (!input) return;\n if (input.value) input.value = \"\";\n input.click();\n };\n\n const { pressProps } = createPress({\n get isDisabled() {\n return !!local.disabled;\n },\n onPress: (_e: PressEvent) => {\n openFilePicker();\n },\n });\n\n const onInputChange: JSX.EventHandler<HTMLInputElement, Event> = (e) => {\n local.onSelect?.(e.currentTarget.files);\n };\n\n return (\n <>\n <span {...pressProps}>{local.children}</span>\n <input\n {...inputProps}\n ref={setInputRef}\n type=\"file\"\n style={{ display: \"none\" }}\n accept={local.acceptedFileTypes?.join(\",\")}\n multiple={local.allowsMultiple}\n capture={local.defaultCamera}\n disabled={local.disabled}\n // @ts-expect-error Non-standard attribute supported by WebKit browsers.\n webkitdirectory={local.acceptDirectory ? \"\" : undefined}\n onChange={onInputChange}\n />\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AA+BA,SAAgBmB,YAAYC,OAAsC;CAChE,MAAM,CAACC,OAAOC,cAAcpB,WAAWkB,OAAO;EAC5C;EACA;EACA;EACA;EACA;EACA;EACA;CAAU,CACX;CAED,MAAM,CAACG,UAAUC,eAAevB,aAAsC,IAAI;CAE1E,MAAMwB,uBAAuB;EAC3B,MAAMC,QAAQH,SAAS;EACvB,IAAI,CAACG,OAAO;EACZ,IAAIA,MAAMC,OAAOD,MAAMC,QAAQ;EAC/BD,MAAME,MAAM;CACd;CAEA,MAAM,EAAEC,eAAe1B,YAAY;EACjC,IAAI2B,aAAa;GACf,OAAO,CAAC,CAACT,MAAMU;EACjB;EACAC,UAAUC,OAAmB;GAC3BR,eAAe;EACjB;CACF,CAAC;CAED,MAAMS,iBAA4DG,MAAM;EACtEhB,MAAMP,WAAWuB,EAAEC,cAAcvB,KAAK;CACxC;CAEA,OAAA,QAAA;EAAA,IAAAwB,OAAAC,eAAAC,MAAA;EAAAC,OAAAH,MAEcV,YAAU,OAAA,IAAA;EAAAc,OAAAJ,YAAGlB,MAAMJ,QAAQ;EAAA2B,mBAAA;EAAA,OAAAL;CAAA,EAAA,CAAA,UAAA;EAAA,IAAAM,QAAAL,eAAAM,OAAA;EAAAC,IAG9BvB,aAAWqB,KAAA;EAAAH,OAAAG,OAAAG,WADZ1B,YAAU;GAAA,QAET;GAAM,SACJ,EAAE2B,SAAS,OAAO;GAAC,IAC1BC,SAAM;IAAA,OAAE7B,MAAMZ,mBAAmB0C,KAAK,GAAG;GAAC;GAAA,IAC1CC,WAAQ;IAAA,OAAE/B,MAAMV;GAAc;GAAA,IAC9B0C,UAAO;IAAA,OAAEhC,MAAMT;GAAa;GAAA,IAC5BmB,WAAQ;IAAA,OAAEV,MAAMU;GAAQ;GAAA,IAExBuB,kBAAe;IAAA,OAAEjC,MAAMR,kBAAkB,KAAK0C,KAAAA;GAAS;GAAA,YAC7CrB;EAAa,CAAA,GAAA,OAAA,KAAA;EAAAU,mBAAA;EAAA,OAAAC;CAAA,EAAA,CAAA,CAAA;AAI/B"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { createSignal, splitProps } from "solid-js";
|
|
2
|
+
import { createPress } from "@proyecto-viviana/solidaria";
|
|
3
|
+
//#region src/FileTrigger.tsx
|
|
4
|
+
/**
|
|
5
|
+
* FileTrigger primitive for solidaria-components.
|
|
6
|
+
*
|
|
7
|
+
* Opens the native file picker from any pressable child.
|
|
8
|
+
* Parity target: react-aria-components/src/FileTrigger.tsx
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* A FileTrigger allows a user to access the file system using a custom trigger.
|
|
12
|
+
*/
|
|
13
|
+
function FileTrigger(props) {
|
|
14
|
+
const [local, inputProps] = splitProps(props, [
|
|
15
|
+
"acceptedFileTypes",
|
|
16
|
+
"allowsMultiple",
|
|
17
|
+
"defaultCamera",
|
|
18
|
+
"acceptDirectory",
|
|
19
|
+
"onSelect",
|
|
20
|
+
"children",
|
|
21
|
+
"disabled"
|
|
22
|
+
]);
|
|
23
|
+
const [inputRef, setInputRef] = createSignal(null);
|
|
24
|
+
const openFilePicker = () => {
|
|
25
|
+
const input = inputRef();
|
|
26
|
+
if (!input) return;
|
|
27
|
+
if (input.value) input.value = "";
|
|
28
|
+
input.click();
|
|
29
|
+
};
|
|
30
|
+
const { pressProps } = createPress({
|
|
31
|
+
get isDisabled() {
|
|
32
|
+
return !!local.disabled;
|
|
33
|
+
},
|
|
34
|
+
onPress: (_e) => {
|
|
35
|
+
openFilePicker();
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const onInputChange = (e) => {
|
|
39
|
+
local.onSelect?.(e.currentTarget.files);
|
|
40
|
+
};
|
|
41
|
+
return <>
|
|
42
|
+
<span {...pressProps}>{local.children}</span>
|
|
43
|
+
<input {...inputProps} ref={setInputRef} type="file" style={{ display: "none" }} accept={local.acceptedFileTypes?.join(",")} multiple={local.allowsMultiple} capture={local.defaultCamera} disabled={local.disabled} webkitdirectory={local.acceptDirectory ? "" : void 0} onChange={onInputChange} />
|
|
44
|
+
</>;
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { FileTrigger };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=FileTrigger.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileTrigger.jsx","names":[],"sources":["../src/FileTrigger.tsx"],"sourcesContent":["/**\n * FileTrigger primitive for solidaria-components.\n *\n * Opens the native file picker from any pressable child.\n * Parity target: react-aria-components/src/FileTrigger.tsx\n */\n\nimport { type JSX, createSignal, splitProps } from \"solid-js\";\nimport { createPress, type PressEvent } from \"@proyecto-viviana/solidaria\";\n\nexport interface FileTriggerProps extends Omit<\n JSX.InputHTMLAttributes<HTMLInputElement>,\n \"type\" | \"onChange\" | \"children\" | \"onSelect\"\n> {\n /** Mime types accepted by the file picker. */\n acceptedFileTypes?: ReadonlyArray<string>;\n /** Whether multiple files can be selected. */\n allowsMultiple?: boolean;\n /** Default camera capture mode for mobile devices. */\n defaultCamera?: \"user\" | \"environment\";\n /** Enables directory selection in supported browsers. */\n acceptDirectory?: boolean;\n /** Called when user selection changes. */\n onSelect?: (files: FileList | null) => void;\n /** Trigger content (typically a button). */\n children?: JSX.Element;\n}\n\n/**\n * A FileTrigger allows a user to access the file system using a custom trigger.\n */\nexport function FileTrigger(props: FileTriggerProps): JSX.Element {\n const [local, inputProps] = splitProps(props, [\n \"acceptedFileTypes\",\n \"allowsMultiple\",\n \"defaultCamera\",\n \"acceptDirectory\",\n \"onSelect\",\n \"children\",\n \"disabled\",\n ]);\n\n const [inputRef, setInputRef] = createSignal<HTMLInputElement | null>(null);\n\n const openFilePicker = () => {\n const input = inputRef();\n if (!input) return;\n if (input.value) input.value = \"\";\n input.click();\n };\n\n const { pressProps } = createPress({\n get isDisabled() {\n return !!local.disabled;\n },\n onPress: (_e: PressEvent) => {\n openFilePicker();\n },\n });\n\n const onInputChange: JSX.EventHandler<HTMLInputElement, Event> = (e) => {\n local.onSelect?.(e.currentTarget.files);\n };\n\n return (\n <>\n <span {...pressProps}>{local.children}</span>\n <input\n {...inputProps}\n ref={setInputRef}\n type=\"file\"\n style={{ display: \"none\" }}\n accept={local.acceptedFileTypes?.join(\",\")}\n multiple={local.allowsMultiple}\n capture={local.defaultCamera}\n disabled={local.disabled}\n // @ts-expect-error Non-standard attribute supported by WebKit browsers.\n webkitdirectory={local.acceptDirectory ? \"\" : undefined}\n onChange={onInputChange}\n />\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA+BA,SAAgB,YAAY,OAAsC;CAChE,MAAM,CAAC,OAAO,cAAc,WAAW,OAAO;EAC5C;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,MAAM,CAAC,UAAU,eAAe,aAAsC,IAAI;CAE1E,MAAM,uBAAuB;EAC3B,MAAM,QAAQ,SAAS;EACvB,IAAI,CAAC,OAAO;EACZ,IAAI,MAAM,OAAO,MAAM,QAAQ;EAC/B,MAAM,MAAM;CACd;CAEA,MAAM,EAAE,eAAe,YAAY;EACjC,IAAI,aAAa;GACf,OAAO,CAAC,CAAC,MAAM;EACjB;EACA,UAAU,OAAmB;GAC3B,eAAe;EACjB;CACF,CAAC;CAED,MAAM,iBAA4D,MAAM;EACtE,MAAM,WAAW,EAAE,cAAc,KAAK;CACxC;CAEA,OACE,EAAE;MACA,CAAC,SAAS,aAAa,MAAM,SAAS,EAAE,KAAK;MAC7C,CAAC,UACK,YACJ,KAAK,aACL,YACA,OAAO,EAAE,SAAS,OAAO,GACzB,QAAQ,MAAM,mBAAmB,KAAK,GAAG,GACzC,UAAU,MAAM,gBAChB,SAAS,MAAM,eACf,UAAU,MAAM,UAEhB,iBAAiB,MAAM,kBAAkB,KAAK,KAAA,GAC9C,UAAU,iBACV;IACJ;AAEJ"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { memo } from "solid-js/web";
|
|
2
|
+
import { children, createEffect, onCleanup, splitProps } from "solid-js";
|
|
3
|
+
import { createFocusable } from "@proyecto-viviana/solidaria";
|
|
4
|
+
//#region src/Focusable.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Focusable component for solidaria-components
|
|
7
|
+
*
|
|
8
|
+
* A render-prop component that wraps createFocusable to make an element
|
|
9
|
+
* focusable and capable of auto focus. Port of React Aria's Focusable.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Makes its child element focusable and capable of auto focus.
|
|
13
|
+
* Applies focus and keyboard event handlers from createFocusable.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* <Focusable onFocus={() => console.log('focused')}>
|
|
18
|
+
* <div tabIndex={0}>Focusable content</div>
|
|
19
|
+
* </Focusable>
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
function Focusable(props) {
|
|
23
|
+
const [local, focusableProps] = splitProps(props, ["children", "ref"]);
|
|
24
|
+
let ref;
|
|
25
|
+
const { focusableProps: domProps } = createFocusable(focusableProps, () => ref);
|
|
26
|
+
const resolved = children(() => local.children);
|
|
27
|
+
createEffect(() => {
|
|
28
|
+
const child = resolved();
|
|
29
|
+
if (child instanceof HTMLElement) {
|
|
30
|
+
ref = child;
|
|
31
|
+
if (typeof local.ref === "function") local.ref(child);
|
|
32
|
+
const props = domProps;
|
|
33
|
+
const listeners = [];
|
|
34
|
+
const addListener = (eventName, handler) => {
|
|
35
|
+
if (typeof handler === "function") {
|
|
36
|
+
const listener = handler;
|
|
37
|
+
child.addEventListener(eventName, listener);
|
|
38
|
+
listeners.push([eventName, listener]);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
addListener("focus", props.onFocus);
|
|
42
|
+
addListener("blur", props.onBlur);
|
|
43
|
+
addListener("keydown", props.onKeyDown);
|
|
44
|
+
addListener("keyup", props.onKeyUp);
|
|
45
|
+
for (const [key, value] of Object.entries(props)) {
|
|
46
|
+
if (key === "ref" || key.startsWith("on") && typeof value === "function") continue;
|
|
47
|
+
if (key === "tabIndex") {
|
|
48
|
+
if (child.hasAttribute("tabindex")) continue;
|
|
49
|
+
if (value == null || value === false) child.removeAttribute("tabindex");
|
|
50
|
+
else child.tabIndex = Number(value);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (key.startsWith("aria-") || key.startsWith("data-") || key === "id" || key === "role") {
|
|
54
|
+
if (child.hasAttribute(key)) continue;
|
|
55
|
+
if (value == null || value === false) child.removeAttribute(key);
|
|
56
|
+
else if (value === true) child.setAttribute(key, "");
|
|
57
|
+
else child.setAttribute(key, String(value));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
onCleanup(() => {
|
|
61
|
+
for (const [eventName, listener] of listeners) child.removeEventListener(eventName, listener);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return memo(resolved);
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
export { Focusable };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=Focusable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Focusable.js","names":["JSX","children","resolveChildren","createEffect","onCleanup","splitProps","createFocusable","CreateFocusableProps","FocusableProps","Element","ref","HTMLElement","el","Focusable","props","local","focusableProps","domProps","resolved","child","listeners","Array","EventListener","addListener","eventName","handler","listener","addEventListener","push","onFocus","onBlur","onKeyDown","onKeyUp","key","value","Object","entries","startsWith","hasAttribute","removeAttribute","tabIndex","Number","setAttribute","String","removeEventListener","_$memo"],"sources":["../src/Focusable.tsx"],"sourcesContent":["/**\n * Focusable component for solidaria-components\n *\n * A render-prop component that wraps createFocusable to make an element\n * focusable and capable of auto focus. Port of React Aria's Focusable.\n */\n\nimport {\n type JSX,\n children as resolveChildren,\n createEffect,\n onCleanup,\n splitProps,\n} from \"solid-js\";\nimport { createFocusable, type CreateFocusableProps } from \"@proyecto-viviana/solidaria\";\n\nexport interface FocusableProps extends CreateFocusableProps {\n /** A single child element to make focusable. */\n children: JSX.Element;\n /** Ref callback. */\n ref?: HTMLElement | ((el: HTMLElement) => void);\n}\n\n/**\n * Makes its child element focusable and capable of auto focus.\n * Applies focus and keyboard event handlers from createFocusable.\n *\n * @example\n * ```tsx\n * <Focusable onFocus={() => console.log('focused')}>\n * <div tabIndex={0}>Focusable content</div>\n * </Focusable>\n * ```\n */\nexport function Focusable(props: FocusableProps): JSX.Element {\n const [local, focusableProps] = splitProps(props, [\"children\", \"ref\"]);\n\n let ref!: HTMLElement;\n const { focusableProps: domProps } = createFocusable(focusableProps, () => ref);\n\n const resolved = resolveChildren(() => local.children);\n\n createEffect(() => {\n const child = resolved() as HTMLElement;\n if (child instanceof HTMLElement) {\n ref = child;\n if (typeof local.ref === \"function\") {\n local.ref(child);\n }\n\n // Apply focusable props to the child element\n const props = domProps;\n const listeners: Array<[string, EventListener]> = [];\n const addListener = (eventName: string, handler: unknown) => {\n if (typeof handler === \"function\") {\n const listener = handler as EventListener;\n child.addEventListener(eventName, listener);\n listeners.push([eventName, listener]);\n }\n };\n\n addListener(\"focus\", props.onFocus);\n addListener(\"blur\", props.onBlur);\n addListener(\"keydown\", props.onKeyDown);\n addListener(\"keyup\", props.onKeyUp);\n\n // Apply non-event focusable props (e.g. tabIndex/aria/data attrs).\n // Keep explicit child tabIndex to mirror mergeProps(child.props precedence).\n for (const [key, value] of Object.entries(props)) {\n if (key === \"ref\" || (key.startsWith(\"on\") && typeof value === \"function\")) continue;\n\n if (key === \"tabIndex\") {\n if (child.hasAttribute(\"tabindex\")) continue;\n if (value == null || value === false) {\n child.removeAttribute(\"tabindex\");\n } else {\n child.tabIndex = Number(value);\n }\n continue;\n }\n\n if (key.startsWith(\"aria-\") || key.startsWith(\"data-\") || key === \"id\" || key === \"role\") {\n if (child.hasAttribute(key)) continue;\n if (value == null || value === false) {\n child.removeAttribute(key);\n } else if (value === true) {\n child.setAttribute(key, \"\");\n } else {\n child.setAttribute(key, String(value));\n }\n }\n }\n\n onCleanup(() => {\n for (const [eventName, listener] of listeners) {\n child.removeEventListener(eventName, listener);\n }\n });\n }\n });\n\n return <>{resolved()}</>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkCA,SAAgBa,UAAUC,OAAoC;CAC5D,MAAM,CAACC,OAAOC,kBAAkBX,WAAWS,OAAO,CAAC,YAAY,KAAK,CAAC;CAErE,IAAIJ;CACJ,MAAM,EAAEM,gBAAgBC,aAAaX,gBAAgBU,sBAAsBN,GAAG;CAE9E,MAAMQ,WAAWhB,eAAsBa,MAAMd,QAAQ;CAErDE,mBAAmB;EACjB,MAAMgB,QAAQD,SAAS;EACvB,IAAIC,iBAAiBR,aAAa;GAChCD,MAAMS;GACN,IAAI,OAAOJ,MAAML,QAAQ,YACvBK,MAAML,IAAIS,KAAK;GAIjB,MAAML,QAAQG;GACd,MAAMG,YAA4C,CAAA;GAClD,MAAMG,eAAeC,WAAmBC,YAAqB;IAC3D,IAAI,OAAOA,YAAY,YAAY;KACjC,MAAMC,WAAWD;KACjBN,MAAMQ,iBAAiBH,WAAWE,QAAQ;KAC1CN,UAAUQ,KAAK,CAACJ,WAAWE,QAAQ,CAAC;IACtC;GACF;GAEAH,YAAY,SAAST,MAAMe,OAAO;GAClCN,YAAY,QAAQT,MAAMgB,MAAM;GAChCP,YAAY,WAAWT,MAAMiB,SAAS;GACtCR,YAAY,SAAST,MAAMkB,OAAO;GAIlC,KAAK,MAAM,CAACC,KAAKC,UAAUC,OAAOC,QAAQtB,KAAK,GAAG;IAChD,IAAImB,QAAQ,SAAUA,IAAII,WAAW,IAAI,KAAK,OAAOH,UAAU,YAAa;IAE5E,IAAID,QAAQ,YAAY;KACtB,IAAId,MAAMmB,aAAa,UAAU,GAAG;KACpC,IAAIJ,SAAS,QAAQA,UAAU,OAC7Bf,MAAMoB,gBAAgB,UAAU;UAEhCpB,MAAMqB,WAAWC,OAAOP,KAAK;KAE/B;IACF;IAEA,IAAID,IAAII,WAAW,OAAO,KAAKJ,IAAII,WAAW,OAAO,KAAKJ,QAAQ,QAAQA,QAAQ,QAAQ;KACxF,IAAId,MAAMmB,aAAaL,GAAG,GAAG;KAC7B,IAAIC,SAAS,QAAQA,UAAU,OAC7Bf,MAAMoB,gBAAgBN,GAAG;UACpB,IAAIC,UAAU,MACnBf,MAAMuB,aAAaT,KAAK,EAAE;UAE1Bd,MAAMuB,aAAaT,KAAKU,OAAOT,KAAK,CAAC;IAEzC;GACF;GAEA9B,gBAAgB;IACd,KAAK,MAAM,CAACoB,WAAWE,aAAaN,WAClCD,MAAMyB,oBAAoBpB,WAAWE,QAAQ;GAEjD,CAAC;EACH;CACF,CAAC;CAED,OAAAmB,KAAU3B,QAAQ;AACpB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { children, createEffect, onCleanup, splitProps } from "solid-js";
|
|
2
|
+
import { createFocusable } from "@proyecto-viviana/solidaria";
|
|
3
|
+
//#region src/Focusable.tsx
|
|
4
|
+
/**
|
|
5
|
+
* Focusable component for solidaria-components
|
|
6
|
+
*
|
|
7
|
+
* A render-prop component that wraps createFocusable to make an element
|
|
8
|
+
* focusable and capable of auto focus. Port of React Aria's Focusable.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Makes its child element focusable and capable of auto focus.
|
|
12
|
+
* Applies focus and keyboard event handlers from createFocusable.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* <Focusable onFocus={() => console.log('focused')}>
|
|
17
|
+
* <div tabIndex={0}>Focusable content</div>
|
|
18
|
+
* </Focusable>
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
function Focusable(props) {
|
|
22
|
+
const [local, focusableProps] = splitProps(props, ["children", "ref"]);
|
|
23
|
+
let ref;
|
|
24
|
+
const { focusableProps: domProps } = createFocusable(focusableProps, () => ref);
|
|
25
|
+
const resolved = children(() => local.children);
|
|
26
|
+
createEffect(() => {
|
|
27
|
+
const child = resolved();
|
|
28
|
+
if (child instanceof HTMLElement) {
|
|
29
|
+
ref = child;
|
|
30
|
+
if (typeof local.ref === "function") local.ref(child);
|
|
31
|
+
const props = domProps;
|
|
32
|
+
const listeners = [];
|
|
33
|
+
const addListener = (eventName, handler) => {
|
|
34
|
+
if (typeof handler === "function") {
|
|
35
|
+
const listener = handler;
|
|
36
|
+
child.addEventListener(eventName, listener);
|
|
37
|
+
listeners.push([eventName, listener]);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
addListener("focus", props.onFocus);
|
|
41
|
+
addListener("blur", props.onBlur);
|
|
42
|
+
addListener("keydown", props.onKeyDown);
|
|
43
|
+
addListener("keyup", props.onKeyUp);
|
|
44
|
+
for (const [key, value] of Object.entries(props)) {
|
|
45
|
+
if (key === "ref" || key.startsWith("on") && typeof value === "function") continue;
|
|
46
|
+
if (key === "tabIndex") {
|
|
47
|
+
if (child.hasAttribute("tabindex")) continue;
|
|
48
|
+
if (value == null || value === false) child.removeAttribute("tabindex");
|
|
49
|
+
else child.tabIndex = Number(value);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (key.startsWith("aria-") || key.startsWith("data-") || key === "id" || key === "role") {
|
|
53
|
+
if (child.hasAttribute(key)) continue;
|
|
54
|
+
if (value == null || value === false) child.removeAttribute(key);
|
|
55
|
+
else if (value === true) child.setAttribute(key, "");
|
|
56
|
+
else child.setAttribute(key, String(value));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
onCleanup(() => {
|
|
60
|
+
for (const [eventName, listener] of listeners) child.removeEventListener(eventName, listener);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return <>{resolved()}</>;
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
export { Focusable };
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=Focusable.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Focusable.jsx","names":["resolveChildren"],"sources":["../src/Focusable.tsx"],"sourcesContent":["/**\n * Focusable component for solidaria-components\n *\n * A render-prop component that wraps createFocusable to make an element\n * focusable and capable of auto focus. Port of React Aria's Focusable.\n */\n\nimport {\n type JSX,\n children as resolveChildren,\n createEffect,\n onCleanup,\n splitProps,\n} from \"solid-js\";\nimport { createFocusable, type CreateFocusableProps } from \"@proyecto-viviana/solidaria\";\n\nexport interface FocusableProps extends CreateFocusableProps {\n /** A single child element to make focusable. */\n children: JSX.Element;\n /** Ref callback. */\n ref?: HTMLElement | ((el: HTMLElement) => void);\n}\n\n/**\n * Makes its child element focusable and capable of auto focus.\n * Applies focus and keyboard event handlers from createFocusable.\n *\n * @example\n * ```tsx\n * <Focusable onFocus={() => console.log('focused')}>\n * <div tabIndex={0}>Focusable content</div>\n * </Focusable>\n * ```\n */\nexport function Focusable(props: FocusableProps): JSX.Element {\n const [local, focusableProps] = splitProps(props, [\"children\", \"ref\"]);\n\n let ref!: HTMLElement;\n const { focusableProps: domProps } = createFocusable(focusableProps, () => ref);\n\n const resolved = resolveChildren(() => local.children);\n\n createEffect(() => {\n const child = resolved() as HTMLElement;\n if (child instanceof HTMLElement) {\n ref = child;\n if (typeof local.ref === \"function\") {\n local.ref(child);\n }\n\n // Apply focusable props to the child element\n const props = domProps;\n const listeners: Array<[string, EventListener]> = [];\n const addListener = (eventName: string, handler: unknown) => {\n if (typeof handler === \"function\") {\n const listener = handler as EventListener;\n child.addEventListener(eventName, listener);\n listeners.push([eventName, listener]);\n }\n };\n\n addListener(\"focus\", props.onFocus);\n addListener(\"blur\", props.onBlur);\n addListener(\"keydown\", props.onKeyDown);\n addListener(\"keyup\", props.onKeyUp);\n\n // Apply non-event focusable props (e.g. tabIndex/aria/data attrs).\n // Keep explicit child tabIndex to mirror mergeProps(child.props precedence).\n for (const [key, value] of Object.entries(props)) {\n if (key === \"ref\" || (key.startsWith(\"on\") && typeof value === \"function\")) continue;\n\n if (key === \"tabIndex\") {\n if (child.hasAttribute(\"tabindex\")) continue;\n if (value == null || value === false) {\n child.removeAttribute(\"tabindex\");\n } else {\n child.tabIndex = Number(value);\n }\n continue;\n }\n\n if (key.startsWith(\"aria-\") || key.startsWith(\"data-\") || key === \"id\" || key === \"role\") {\n if (child.hasAttribute(key)) continue;\n if (value == null || value === false) {\n child.removeAttribute(key);\n } else if (value === true) {\n child.setAttribute(key, \"\");\n } else {\n child.setAttribute(key, String(value));\n }\n }\n }\n\n onCleanup(() => {\n for (const [eventName, listener] of listeners) {\n child.removeEventListener(eventName, listener);\n }\n });\n }\n });\n\n return <>{resolved()}</>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkCA,SAAgB,UAAU,OAAoC;CAC5D,MAAM,CAAC,OAAO,kBAAkB,WAAW,OAAO,CAAC,YAAY,KAAK,CAAC;CAErE,IAAI;CACJ,MAAM,EAAE,gBAAgB,aAAa,gBAAgB,sBAAsB,GAAG;CAE9E,MAAM,WAAWA,eAAsB,MAAM,QAAQ;CAErD,mBAAmB;EACjB,MAAM,QAAQ,SAAS;EACvB,IAAI,iBAAiB,aAAa;GAChC,MAAM;GACN,IAAI,OAAO,MAAM,QAAQ,YACvB,MAAM,IAAI,KAAK;GAIjB,MAAM,QAAQ;GACd,MAAM,YAA4C,CAAC;GACnD,MAAM,eAAe,WAAmB,YAAqB;IAC3D,IAAI,OAAO,YAAY,YAAY;KACjC,MAAM,WAAW;KACjB,MAAM,iBAAiB,WAAW,QAAQ;KAC1C,UAAU,KAAK,CAAC,WAAW,QAAQ,CAAC;IACtC;GACF;GAEA,YAAY,SAAS,MAAM,OAAO;GAClC,YAAY,QAAQ,MAAM,MAAM;GAChC,YAAY,WAAW,MAAM,SAAS;GACtC,YAAY,SAAS,MAAM,OAAO;GAIlC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,GAAG;IAChD,IAAI,QAAQ,SAAU,IAAI,WAAW,IAAI,KAAK,OAAO,UAAU,YAAa;IAE5E,IAAI,QAAQ,YAAY;KACtB,IAAI,MAAM,aAAa,UAAU,GAAG;KACpC,IAAI,SAAS,QAAQ,UAAU,OAC7B,MAAM,gBAAgB,UAAU;UAEhC,MAAM,WAAW,OAAO,KAAK;KAE/B;IACF;IAEA,IAAI,IAAI,WAAW,OAAO,KAAK,IAAI,WAAW,OAAO,KAAK,QAAQ,QAAQ,QAAQ,QAAQ;KACxF,IAAI,MAAM,aAAa,GAAG,GAAG;KAC7B,IAAI,SAAS,QAAQ,UAAU,OAC7B,MAAM,gBAAgB,GAAG;UACpB,IAAI,UAAU,MACnB,MAAM,aAAa,KAAK,EAAE;UAE1B,MAAM,aAAa,KAAK,OAAO,KAAK,CAAC;IAEzC;GACF;GAEA,gBAAgB;IACd,KAAK,MAAM,CAAC,WAAW,aAAa,WAClC,MAAM,oBAAoB,WAAW,QAAQ;GAEjD,CAAC;EACH;CACF,CAAC;CAED,OAAO,GAAG,SAAS,EAAE;AACvB"}
|
package/dist/Form.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { filterDOMProps, useRenderProps } from "./utils.js";
|
|
2
|
+
import { createComponent, getNextElement, insert, mergeProps, runHydrationEvents, spread, template, use } from "solid-js/web";
|
|
3
|
+
import { createContext, splitProps } from "solid-js";
|
|
4
|
+
import { FormValidationContext } from "@proyecto-viviana/solid-stately";
|
|
5
|
+
//#region src/Form.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Form primitive for solidaria-components.
|
|
8
|
+
*
|
|
9
|
+
* Provides form-level validation behavior and server validation context.
|
|
10
|
+
* Port direction: react-aria-components/src/Form.tsx
|
|
11
|
+
*/
|
|
12
|
+
var _tmpl$ = /*#__PURE__*/ template(`<form>`);
|
|
13
|
+
function assignRef(ref, el) {
|
|
14
|
+
if (!ref) return;
|
|
15
|
+
if (typeof ref === "function") ref(el);
|
|
16
|
+
else ref.current = el;
|
|
17
|
+
}
|
|
18
|
+
const FormContext = createContext(null);
|
|
19
|
+
const formDOMPropNames = new Set([
|
|
20
|
+
"accept-charset",
|
|
21
|
+
"acceptCharset",
|
|
22
|
+
"action",
|
|
23
|
+
"autocapitalize",
|
|
24
|
+
"autoCapitalize",
|
|
25
|
+
"autocomplete",
|
|
26
|
+
"autoComplete",
|
|
27
|
+
"encoding",
|
|
28
|
+
"enctype",
|
|
29
|
+
"encType",
|
|
30
|
+
"method",
|
|
31
|
+
"name",
|
|
32
|
+
"rel",
|
|
33
|
+
"target"
|
|
34
|
+
]);
|
|
35
|
+
function filterFormDOMProps(props) {
|
|
36
|
+
const filtered = filterDOMProps(props, { global: true });
|
|
37
|
+
for (const key in props) if (Object.prototype.hasOwnProperty.call(props, key) && formDOMPropNames.has(key)) filtered[key] = props[key];
|
|
38
|
+
return filtered;
|
|
39
|
+
}
|
|
40
|
+
function Form(props) {
|
|
41
|
+
const [local, domProps] = splitProps(props, [
|
|
42
|
+
"validationErrors",
|
|
43
|
+
"validationBehavior",
|
|
44
|
+
"children",
|
|
45
|
+
"class",
|
|
46
|
+
"style",
|
|
47
|
+
"ref",
|
|
48
|
+
"slot"
|
|
49
|
+
]);
|
|
50
|
+
const validationBehavior = local.validationBehavior ?? "native";
|
|
51
|
+
const errors = local.validationErrors ?? {};
|
|
52
|
+
const renderProps = useRenderProps({
|
|
53
|
+
get children() {
|
|
54
|
+
return local.children;
|
|
55
|
+
},
|
|
56
|
+
class: local.class,
|
|
57
|
+
style: local.style,
|
|
58
|
+
defaultClassName: "solidaria-Form"
|
|
59
|
+
}, () => ({ validationBehavior }));
|
|
60
|
+
const filteredDomProps = filterFormDOMProps(domProps);
|
|
61
|
+
return (() => {
|
|
62
|
+
var _el$ = getNextElement(_tmpl$);
|
|
63
|
+
use((el) => assignRef(local.ref, el), _el$);
|
|
64
|
+
spread(_el$, mergeProps(filteredDomProps, {
|
|
65
|
+
"noValidate": validationBehavior !== "native",
|
|
66
|
+
get ["class"]() {
|
|
67
|
+
return renderProps.class();
|
|
68
|
+
},
|
|
69
|
+
get style() {
|
|
70
|
+
return renderProps.style();
|
|
71
|
+
},
|
|
72
|
+
get slot() {
|
|
73
|
+
return local.slot;
|
|
74
|
+
}
|
|
75
|
+
}), false, true);
|
|
76
|
+
insert(_el$, createComponent(FormContext.Provider, {
|
|
77
|
+
get value() {
|
|
78
|
+
return {
|
|
79
|
+
...props,
|
|
80
|
+
validationBehavior
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
get children() {
|
|
84
|
+
return createComponent(FormValidationContext.Provider, {
|
|
85
|
+
value: errors,
|
|
86
|
+
get children() {
|
|
87
|
+
return renderProps.renderChildren();
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
92
|
+
runHydrationEvents();
|
|
93
|
+
return _el$;
|
|
94
|
+
})();
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
export { Form, FormContext };
|
|
98
|
+
|
|
99
|
+
//# sourceMappingURL=Form.js.map
|
package/dist/Form.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Form.js","names":["JSX","createContext","splitProps","FormValidationContext","ValidationErrors","ValidationBehavior","ClassNameOrFunction","StyleOrFunction","RenderChildren","SlotProps","useRenderProps","filterDOMProps","RefLike","el","T","current","assignRef","ref","FormRenderProps","validationBehavior","FormProps","Omit","FormHTMLAttributes","HTMLFormElement","validationErrors","acceptCharset","autoCapitalize","HTMLAttributes","autoComplete","encType","children","class","style","FormContext","formDOMPropNames","Set","filterFormDOMProps","props","Record","filtered","global","key","Object","prototype","hasOwnProperty","call","has","Form","Element","local","domProps","errors","renderProps","defaultClassName","filteredDomProps","_el$","_$getNextElement","_tmpl$","_$use","_$spread","_$mergeProps","slot","_$insert","_$createComponent","Provider","value","renderChildren","_$runHydrationEvents"],"sources":["../src/Form.tsx"],"sourcesContent":["/**\n * Form primitive for solidaria-components.\n *\n * Provides form-level validation behavior and server validation context.\n * Port direction: react-aria-components/src/Form.tsx\n */\n\nimport { type JSX, createContext, splitProps } from \"solid-js\";\nimport {\n FormValidationContext,\n type ValidationErrors,\n type ValidationBehavior,\n} from \"@proyecto-viviana/solid-stately\";\nimport {\n type ClassNameOrFunction,\n type StyleOrFunction,\n type RenderChildren,\n type SlotProps,\n useRenderProps,\n filterDOMProps,\n} from \"./utils\";\n\ntype RefLike<T> = ((el: T) => void) | { current?: T | null } | undefined;\n\nfunction assignRef<T>(ref: RefLike<T>, el: T): void {\n if (!ref) return;\n if (typeof ref === \"function\") {\n ref(el);\n } else {\n ref.current = el;\n }\n}\n\nexport interface FormRenderProps {\n validationBehavior: ValidationBehavior;\n}\n\nexport interface FormProps\n extends\n Omit<JSX.FormHTMLAttributes<HTMLFormElement>, \"children\" | \"class\" | \"style\" | \"ref\">,\n SlotProps {\n /** Server-side validation errors keyed by field name. */\n validationErrors?: ValidationErrors;\n /** Validation behavior mode. */\n validationBehavior?: ValidationBehavior;\n /** Character encodings accepted by the server. React-style alias for Solid's `accept-charset`. */\n acceptCharset?: string;\n /** Browser auto-capitalization hint. React-style alias for Solid's `autocapitalize`. */\n autoCapitalize?: JSX.HTMLAttributes<HTMLFormElement>[\"autoCapitalize\"];\n /** Browser autocomplete behavior. React-style alias for Solid's `autocomplete`. */\n autoComplete?: JSX.FormHTMLAttributes<HTMLFormElement>[\"autocomplete\"];\n /** Form encoding type. React-style alias for Solid's `enctype`. */\n encType?: JSX.FormHTMLAttributes<HTMLFormElement>[\"enctype\"];\n /** The children of the component. */\n children?: RenderChildren<FormRenderProps>;\n /** The CSS className for the element. */\n class?: ClassNameOrFunction<FormRenderProps>;\n /** The inline style for the element. */\n style?: StyleOrFunction<FormRenderProps>;\n /** Ref for the underlying form element. */\n ref?: RefLike<HTMLFormElement>;\n}\n\nexport const FormContext = createContext<FormProps | null>(null);\n\nconst formDOMPropNames = new Set([\n \"accept-charset\",\n \"acceptCharset\",\n \"action\",\n \"autocapitalize\",\n \"autoCapitalize\",\n \"autocomplete\",\n \"autoComplete\",\n \"encoding\",\n \"enctype\",\n \"encType\",\n \"method\",\n \"name\",\n \"rel\",\n \"target\",\n]);\n\nfunction filterFormDOMProps(props: object): Record<string, unknown> {\n const filtered = filterDOMProps<Record<string, unknown>>(props, { global: true });\n\n for (const key in props) {\n if (Object.prototype.hasOwnProperty.call(props, key) && formDOMPropNames.has(key)) {\n filtered[key] = (props as Record<string, unknown>)[key];\n }\n }\n\n return filtered;\n}\n\nexport function Form(props: FormProps): JSX.Element {\n const [local, domProps] = splitProps(props, [\n \"validationErrors\",\n \"validationBehavior\",\n \"children\",\n \"class\",\n \"style\",\n \"ref\",\n \"slot\",\n ]);\n\n const validationBehavior: ValidationBehavior = local.validationBehavior ?? \"native\";\n const errors = local.validationErrors ?? {};\n const renderProps = useRenderProps(\n {\n get children() {\n return local.children;\n },\n class: local.class,\n style: local.style,\n defaultClassName: \"solidaria-Form\",\n },\n () => ({\n validationBehavior,\n }),\n );\n\n const filteredDomProps = filterFormDOMProps(domProps);\n\n return (\n <form\n {...filteredDomProps}\n ref={(el) => assignRef(local.ref, el)}\n noValidate={validationBehavior !== \"native\"}\n class={renderProps.class()}\n style={renderProps.style()}\n slot={local.slot}\n >\n <FormContext.Provider value={{ ...props, validationBehavior }}>\n <FormValidationContext.Provider value={errors}>\n {renderProps.renderChildren()}\n </FormValidationContext.Provider>\n </FormContext.Provider>\n </form>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAwBA,SAASgB,UAAaC,KAAiBJ,IAAa;CAClD,IAAI,CAACI,KAAK;CACV,IAAI,OAAOA,QAAQ,YACjBA,IAAIJ,EAAE;MAENI,IAAIF,UAAUF;AAElB;AAgCA,MAAaoB,cAAchC,cAAgC,IAAI;AAE/D,MAAMiC,mBAAmB,IAAIC,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAAQ,CACT;AAED,SAASC,mBAAmBC,OAAwC;CAClE,MAAME,WAAW5B,eAAwC0B,OAAO,EAAEG,QAAQ,KAAK,CAAC;CAEhF,KAAK,MAAMC,OAAOJ,OAChB,IAAIK,OAAOC,UAAUC,eAAeC,KAAKR,OAAOI,GAAG,KAAKP,iBAAiBY,IAAIL,GAAG,GAC9EF,SAASE,OAAQJ,MAAkCI;CAIvD,OAAOF;AACT;AAEA,SAAgBQ,KAAKV,OAA+B;CAClD,MAAM,CAACY,OAAOC,YAAYhD,WAAWmC,OAAO;EAC1C;EACA;EACA;EACA;EACA;EACA;EACA;CAAM,CACP;CAED,MAAMlB,qBAAyC8B,MAAM9B,sBAAsB;CAC3E,MAAMgC,SAASF,MAAMzB,oBAAoB,CAAC;CAC1C,MAAM4B,cAAc1C,eAClB;EACE,IAAIoB,WAAW;GACb,OAAOmB,MAAMnB;EACf;EACAC,OAAOkB,MAAMlB;EACbC,OAAOiB,MAAMjB;EACbqB,kBAAkB;CACpB,UACO,EACLlC,mBACF,EACF;CAEA,MAAMmC,mBAAmBlB,mBAAmBc,QAAQ;CAEpD,cAAA;EAAA,IAAAK,OAAAC,eAAAC,MAAA;EAAAC,KAGU7C,OAAOG,UAAUiC,MAAMhC,KAAKJ,EAAE,GAAC0C,IAAA;EAAAI,OAAAJ,MAAAK,WADjCN,kBAAgB;GAAA,cAERnC,uBAAuB;GAAQ,KAAA,WAAA;IAAA,OACpCiC,YAAYrB,MAAM;GAAC;GAAA,IAC1BC,QAAK;IAAA,OAAEoB,YAAYpB,MAAM;GAAC;GAAA,IAC1B6B,OAAI;IAAA,OAAEZ,MAAMY;GAAI;EAAA,CAAA,GAAA,OAAA,IAAA;EAAAC,OAAAP,MAAAQ,gBAEf9B,YAAY+B,UAAQ;GAAA,IAACC,QAAK;IAAA,OAAE;KAAE,GAAG5B;KAAOlB;IAAmB;GAAC;GAAA,IAAAW,WAAA;IAAA,OAAAiC,gBAC1D5D,sBAAsB6D,UAAQ;KAACC,OAAOd;KAAM,IAAArB,WAAA;MAAA,OAC1CsB,YAAYc,eAAe;KAAC;IAAA,CAAA;GAAA;EAAA,CAAA,CAAA;EAAAC,mBAAA;EAAA,OAAAZ;CAAA,EAAA,CAAA;AAKvC"}
|
package/dist/Form.jsx
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { filterDOMProps, useRenderProps } from "./utils.jsx";
|
|
2
|
+
import { createContext, splitProps } from "solid-js";
|
|
3
|
+
import { FormValidationContext } from "@proyecto-viviana/solid-stately";
|
|
4
|
+
//#region src/Form.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Form primitive for solidaria-components.
|
|
7
|
+
*
|
|
8
|
+
* Provides form-level validation behavior and server validation context.
|
|
9
|
+
* Port direction: react-aria-components/src/Form.tsx
|
|
10
|
+
*/
|
|
11
|
+
function assignRef(ref, el) {
|
|
12
|
+
if (!ref) return;
|
|
13
|
+
if (typeof ref === "function") ref(el);
|
|
14
|
+
else ref.current = el;
|
|
15
|
+
}
|
|
16
|
+
const FormContext = createContext(null);
|
|
17
|
+
const formDOMPropNames = new Set([
|
|
18
|
+
"accept-charset",
|
|
19
|
+
"acceptCharset",
|
|
20
|
+
"action",
|
|
21
|
+
"autocapitalize",
|
|
22
|
+
"autoCapitalize",
|
|
23
|
+
"autocomplete",
|
|
24
|
+
"autoComplete",
|
|
25
|
+
"encoding",
|
|
26
|
+
"enctype",
|
|
27
|
+
"encType",
|
|
28
|
+
"method",
|
|
29
|
+
"name",
|
|
30
|
+
"rel",
|
|
31
|
+
"target"
|
|
32
|
+
]);
|
|
33
|
+
function filterFormDOMProps(props) {
|
|
34
|
+
const filtered = filterDOMProps(props, { global: true });
|
|
35
|
+
for (const key in props) if (Object.prototype.hasOwnProperty.call(props, key) && formDOMPropNames.has(key)) filtered[key] = props[key];
|
|
36
|
+
return filtered;
|
|
37
|
+
}
|
|
38
|
+
function Form(props) {
|
|
39
|
+
const [local, domProps] = splitProps(props, [
|
|
40
|
+
"validationErrors",
|
|
41
|
+
"validationBehavior",
|
|
42
|
+
"children",
|
|
43
|
+
"class",
|
|
44
|
+
"style",
|
|
45
|
+
"ref",
|
|
46
|
+
"slot"
|
|
47
|
+
]);
|
|
48
|
+
const validationBehavior = local.validationBehavior ?? "native";
|
|
49
|
+
const errors = local.validationErrors ?? {};
|
|
50
|
+
const renderProps = useRenderProps({
|
|
51
|
+
get children() {
|
|
52
|
+
return local.children;
|
|
53
|
+
},
|
|
54
|
+
class: local.class,
|
|
55
|
+
style: local.style,
|
|
56
|
+
defaultClassName: "solidaria-Form"
|
|
57
|
+
}, () => ({ validationBehavior }));
|
|
58
|
+
const filteredDomProps = filterFormDOMProps(domProps);
|
|
59
|
+
return <form {...filteredDomProps} ref={(el) => assignRef(local.ref, el)} noValidate={validationBehavior !== "native"} class={renderProps.class()} style={renderProps.style()} slot={local.slot}>
|
|
60
|
+
<FormContext.Provider value={{
|
|
61
|
+
...props,
|
|
62
|
+
validationBehavior
|
|
63
|
+
}}>
|
|
64
|
+
<FormValidationContext.Provider value={errors}>
|
|
65
|
+
{renderProps.renderChildren()}
|
|
66
|
+
</FormValidationContext.Provider>
|
|
67
|
+
</FormContext.Provider>
|
|
68
|
+
</form>;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { Form, FormContext };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=Form.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Form.jsx","names":[],"sources":["../src/Form.tsx"],"sourcesContent":["/**\n * Form primitive for solidaria-components.\n *\n * Provides form-level validation behavior and server validation context.\n * Port direction: react-aria-components/src/Form.tsx\n */\n\nimport { type JSX, createContext, splitProps } from \"solid-js\";\nimport {\n FormValidationContext,\n type ValidationErrors,\n type ValidationBehavior,\n} from \"@proyecto-viviana/solid-stately\";\nimport {\n type ClassNameOrFunction,\n type StyleOrFunction,\n type RenderChildren,\n type SlotProps,\n useRenderProps,\n filterDOMProps,\n} from \"./utils\";\n\ntype RefLike<T> = ((el: T) => void) | { current?: T | null } | undefined;\n\nfunction assignRef<T>(ref: RefLike<T>, el: T): void {\n if (!ref) return;\n if (typeof ref === \"function\") {\n ref(el);\n } else {\n ref.current = el;\n }\n}\n\nexport interface FormRenderProps {\n validationBehavior: ValidationBehavior;\n}\n\nexport interface FormProps\n extends\n Omit<JSX.FormHTMLAttributes<HTMLFormElement>, \"children\" | \"class\" | \"style\" | \"ref\">,\n SlotProps {\n /** Server-side validation errors keyed by field name. */\n validationErrors?: ValidationErrors;\n /** Validation behavior mode. */\n validationBehavior?: ValidationBehavior;\n /** Character encodings accepted by the server. React-style alias for Solid's `accept-charset`. */\n acceptCharset?: string;\n /** Browser auto-capitalization hint. React-style alias for Solid's `autocapitalize`. */\n autoCapitalize?: JSX.HTMLAttributes<HTMLFormElement>[\"autoCapitalize\"];\n /** Browser autocomplete behavior. React-style alias for Solid's `autocomplete`. */\n autoComplete?: JSX.FormHTMLAttributes<HTMLFormElement>[\"autocomplete\"];\n /** Form encoding type. React-style alias for Solid's `enctype`. */\n encType?: JSX.FormHTMLAttributes<HTMLFormElement>[\"enctype\"];\n /** The children of the component. */\n children?: RenderChildren<FormRenderProps>;\n /** The CSS className for the element. */\n class?: ClassNameOrFunction<FormRenderProps>;\n /** The inline style for the element. */\n style?: StyleOrFunction<FormRenderProps>;\n /** Ref for the underlying form element. */\n ref?: RefLike<HTMLFormElement>;\n}\n\nexport const FormContext = createContext<FormProps | null>(null);\n\nconst formDOMPropNames = new Set([\n \"accept-charset\",\n \"acceptCharset\",\n \"action\",\n \"autocapitalize\",\n \"autoCapitalize\",\n \"autocomplete\",\n \"autoComplete\",\n \"encoding\",\n \"enctype\",\n \"encType\",\n \"method\",\n \"name\",\n \"rel\",\n \"target\",\n]);\n\nfunction filterFormDOMProps(props: object): Record<string, unknown> {\n const filtered = filterDOMProps<Record<string, unknown>>(props, { global: true });\n\n for (const key in props) {\n if (Object.prototype.hasOwnProperty.call(props, key) && formDOMPropNames.has(key)) {\n filtered[key] = (props as Record<string, unknown>)[key];\n }\n }\n\n return filtered;\n}\n\nexport function Form(props: FormProps): JSX.Element {\n const [local, domProps] = splitProps(props, [\n \"validationErrors\",\n \"validationBehavior\",\n \"children\",\n \"class\",\n \"style\",\n \"ref\",\n \"slot\",\n ]);\n\n const validationBehavior: ValidationBehavior = local.validationBehavior ?? \"native\";\n const errors = local.validationErrors ?? {};\n const renderProps = useRenderProps(\n {\n get children() {\n return local.children;\n },\n class: local.class,\n style: local.style,\n defaultClassName: \"solidaria-Form\",\n },\n () => ({\n validationBehavior,\n }),\n );\n\n const filteredDomProps = filterFormDOMProps(domProps);\n\n return (\n <form\n {...filteredDomProps}\n ref={(el) => assignRef(local.ref, el)}\n noValidate={validationBehavior !== \"native\"}\n class={renderProps.class()}\n style={renderProps.style()}\n slot={local.slot}\n >\n <FormContext.Provider value={{ ...props, validationBehavior }}>\n <FormValidationContext.Provider value={errors}>\n {renderProps.renderChildren()}\n </FormValidationContext.Provider>\n </FormContext.Provider>\n </form>\n );\n}\n"],"mappings":";;;;;;;;;;AAwBA,SAAS,UAAa,KAAiB,IAAa;CAClD,IAAI,CAAC,KAAK;CACV,IAAI,OAAO,QAAQ,YACjB,IAAI,EAAE;MAEN,IAAI,UAAU;AAElB;AAgCA,MAAa,cAAc,cAAgC,IAAI;AAE/D,MAAM,mBAAmB,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,mBAAmB,OAAwC;CAClE,MAAM,WAAW,eAAwC,OAAO,EAAE,QAAQ,KAAK,CAAC;CAEhF,KAAK,MAAM,OAAO,OAChB,IAAI,OAAO,UAAU,eAAe,KAAK,OAAO,GAAG,KAAK,iBAAiB,IAAI,GAAG,GAC9E,SAAS,OAAQ,MAAkC;CAIvD,OAAO;AACT;AAEA,SAAgB,KAAK,OAA+B;CAClD,MAAM,CAAC,OAAO,YAAY,WAAW,OAAO;EAC1C;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,MAAM,qBAAyC,MAAM,sBAAsB;CAC3E,MAAM,SAAS,MAAM,oBAAoB,CAAC;CAC1C,MAAM,cAAc,eAClB;EACE,IAAI,WAAW;GACb,OAAO,MAAM;EACf;EACA,OAAO,MAAM;EACb,OAAO,MAAM;EACb,kBAAkB;CACpB,UACO,EACL,mBACF,EACF;CAEA,MAAM,mBAAmB,mBAAmB,QAAQ;CAEpD,OACE,CAAC,SACK,kBACJ,MAAM,OAAO,UAAU,MAAM,KAAK,EAAE,GACpC,YAAY,uBAAuB,UACnC,OAAO,YAAY,MAAM,GACzB,OAAO,YAAY,MAAM,GACzB,MAAM,MAAM,MACb;MACC,CAAC,YAAY,SAAS,OAAO;EAAE,GAAG;EAAO;CAAmB,GAAG;QAC7D,CAAC,sBAAsB,SAAS,OAAO,QAAQ;WAC5C,YAAY,eAAe,EAAE;QAChC,EAAE,sBAAsB,SAAS;MACnC,EAAE,YAAY,SAAS;IACzB,EAAE;AAEN"}
|