@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":"TimeField.jsx","names":[],"sources":["../src/TimeField.tsx"],"sourcesContent":["/**\n * TimeField component for solidaria-components\n *\n * Pre-wired headless time field component with segment-based editing.\n * Port of react-aria-components/src/TimeField.tsx\n */\n\nimport {\n type JSX,\n type Context,\n createContext,\n createMemo,\n createSignal,\n splitProps,\n useContext,\n For,\n Show,\n} from \"solid-js\";\nimport {\n createTimeField,\n createTimeSegment,\n type AriaTimeFieldProps,\n} from \"@proyecto-viviana/solidaria\";\nimport {\n createTimeFieldState,\n access,\n type TimeFieldState,\n type TimeFieldStateProps,\n type TimeSegment as TimeSegmentType,\n type TimeValue,\n} from \"@proyecto-viviana/solid-stately\";\nimport {\n type RenderChildren,\n type ClassNameOrFunction,\n type StyleOrFunction,\n type SlotProps,\n useRenderProps,\n dataAttr,\n useIsHydrated,\n Provider,\n} from \"./utils\";\nimport { TextContext } from \"./Text\";\nimport { HiddenTimeInput } from \"./HiddenTimeInput\";\nimport { FormContext, type FormProps } from \"./Form\";\n\nexport interface TimeFieldRenderProps {\n /** Whether the field is disabled. */\n isDisabled: boolean;\n /** Whether the field is read-only. */\n isReadOnly: boolean;\n /** Whether the field is required. */\n isRequired: boolean;\n /** Whether the field is invalid. */\n isInvalid: boolean;\n}\n\nexport interface TimeFieldProps<T extends TimeValue = TimeValue>\n extends\n Omit<AriaTimeFieldProps, \"id\" | \"isDisabled\" | \"isReadOnly\" | \"isRequired\">,\n Omit<TimeFieldStateProps<T>, \"locale\">,\n SlotProps {\n /** The children of the component. */\n children?: JSX.Element | ((segment: TimeSegmentType) => JSX.Element);\n /** The CSS className for the element. */\n class?: ClassNameOrFunction<TimeFieldRenderProps>;\n /** The inline style for the element. */\n style?: StyleOrFunction<TimeFieldRenderProps>;\n /** The locale to use for formatting. */\n locale?: string;\n}\n\nexport interface TimeInputRenderProps {\n /** Whether the input is disabled. */\n isDisabled: boolean;\n /** Whether the input is focused. */\n isFocused: boolean;\n}\n\nexport interface TimeInputProps extends SlotProps {\n /** The children of the component (render function receiving segments). */\n children?: (segment: TimeSegmentType) => JSX.Element;\n /** The CSS className for the element. */\n class?: ClassNameOrFunction<TimeInputRenderProps>;\n /** The inline style for the element. */\n style?: StyleOrFunction<TimeInputRenderProps>;\n}\n\nexport interface TimeSegmentRenderProps {\n /** Whether the segment is focused. */\n isFocused: boolean;\n /** Whether the segment is editable. */\n isEditable: boolean;\n /** Whether the segment is a placeholder. */\n isPlaceholder: boolean;\n /** The segment type. */\n type: TimeSegmentType[\"type\"];\n /** The text to display. */\n text: string;\n}\n\nexport interface TimeSegmentProps extends SlotProps {\n /** The segment data. */\n segment: TimeSegmentType;\n /** The children of the component. A function may be provided to receive render props. */\n children?: RenderChildren<TimeSegmentRenderProps>;\n /** The CSS className for the element. */\n class?: ClassNameOrFunction<TimeSegmentRenderProps>;\n /** The inline style for the element. */\n style?: StyleOrFunction<TimeSegmentRenderProps>;\n}\n\nexport interface TimeFieldContextValue {\n state: TimeFieldState<TimeValue>;\n aria: {\n labelProps: Record<string, unknown>;\n inputProps: Record<string, unknown>;\n descriptionProps: Record<string, unknown>;\n errorMessageProps: Record<string, unknown>;\n };\n}\n\nexport const TimeFieldContext = createContext<TimeFieldContextValue | null>(null);\nexport const TimeFieldStateContext = createContext<TimeFieldState<TimeValue> | null>(null);\n\nfunction withFormValidationBehavior<P extends object>(props: P, formContext: FormProps | null): P {\n if (!formContext?.validationBehavior) {\n return props;\n }\n\n return new Proxy(props, {\n get(target, property, receiver) {\n const localValue = Reflect.get(target, property, receiver);\n if (property === \"validationBehavior\" && localValue === undefined) {\n return formContext.validationBehavior;\n }\n\n return localValue;\n },\n has(target, property) {\n return (\n Reflect.has(target, property) ||\n (property === \"validationBehavior\" && formContext.validationBehavior !== undefined)\n );\n },\n ownKeys(target) {\n const keys = new Set(Reflect.ownKeys(target));\n if (formContext.validationBehavior !== undefined) {\n keys.add(\"validationBehavior\");\n }\n\n return Array.from(keys);\n },\n getOwnPropertyDescriptor(target, property) {\n const descriptor = Reflect.getOwnPropertyDescriptor(target, property);\n if (descriptor) {\n return descriptor;\n }\n\n if (property === \"validationBehavior\" && formContext.validationBehavior !== undefined) {\n return {\n enumerable: true,\n configurable: true,\n get: () => formContext.validationBehavior,\n };\n }\n\n return undefined;\n },\n });\n}\n\nfunction useTimeFieldContextValue(): TimeFieldContextValue {\n const context = useContext(TimeFieldContext);\n if (!context) {\n throw new Error(\"TimeField components must be used within a TimeField\");\n }\n return context;\n}\n\nexport function useTimeFieldContext(): TimeFieldState<TimeValue> {\n return useTimeFieldContextValue().state;\n}\n\n/**\n * A time field allows users to enter and edit time values using a keyboard.\n *\n * @example\n * ```tsx\n * <TimeField label=\"Time\">\n * <Label>Time</Label>\n * <TimeInput>\n * {(segment) => <TimeSegment segment={segment} />}\n * </TimeInput>\n * </TimeField>\n * ```\n */\nexport function TimeField<T extends TimeValue = TimeValue>(props: TimeFieldProps<T>): JSX.Element {\n // Use hydration-safe pattern for client-only rendering\n const isHydrated = useIsHydrated();\n const formContext = useContext(FormContext);\n\n return (\n <Show\n when={isHydrated()}\n fallback={\n <div class=\"solidaria-TimeField solidaria-TimeField--placeholder\" aria-hidden=\"true\" />\n }\n >\n <TimeFieldInner {...props} __formContext={formContext} />\n </Show>\n );\n}\n\ntype TimeFieldInnerProps<T extends TimeValue = TimeValue> = TimeFieldProps<T> & {\n __formContext?: FormProps | null;\n};\n\n/**\n * Internal TimeField component that renders after client mount.\n */\nfunction TimeFieldInner<T extends TimeValue = TimeValue>(\n props: TimeFieldInnerProps<T>,\n): JSX.Element {\n const formContext = props.__formContext ?? useContext(FormContext);\n const mergedProps = withFormValidationBehavior(props, formContext);\n const [local, stateProps, rest] = splitProps(\n mergedProps,\n [\"children\", \"class\", \"style\", \"slot\", \"__formContext\"],\n [\n \"value\",\n \"defaultValue\",\n \"onChange\",\n \"minValue\",\n \"maxValue\",\n \"isInvalid\",\n \"isDisabled\",\n \"isReadOnly\",\n \"isRequired\",\n \"locale\",\n \"granularity\",\n \"hourCycle\",\n \"shouldForceLeadingZeros\",\n \"validationState\",\n \"validationBehavior\",\n \"validate\",\n \"description\",\n \"errorMessage\",\n \"placeholderValue\",\n ],\n );\n\n const [fieldRef, setFieldRef] = createSignal<HTMLDivElement | null>(null);\n\n const state = createTimeFieldState(stateProps);\n\n const fieldAria = createTimeField(\n () => ({\n ...(rest as Record<string, unknown>),\n description: stateProps.description,\n errorMessage: stateProps.errorMessage,\n }),\n state as unknown as TimeFieldState<TimeValue>,\n fieldRef,\n );\n\n const renderValues = createMemo<TimeFieldRenderProps>(() => ({\n isDisabled: state.isDisabled(),\n isReadOnly: state.isReadOnly(),\n isRequired: state.isRequired(),\n isInvalid: state.isInvalid(),\n }));\n\n const renderProps = useRenderProps(\n {\n class: local.class,\n style: local.style,\n defaultClassName: \"solidaria-TimeField\",\n },\n renderValues,\n );\n\n const validationBehavior = () =>\n (stateProps as { validationBehavior?: \"aria\" | \"native\" }).validationBehavior ??\n formContext?.validationBehavior ??\n \"native\";\n\n const textSlots = {\n slots: {\n get description() {\n return fieldAria.descriptionProps;\n },\n get errorMessage() {\n return fieldAria.errorMessageProps;\n },\n },\n };\n\n return (\n <TimeFieldStateContext.Provider value={state as unknown as TimeFieldState<TimeValue>}>\n <TimeFieldContext.Provider\n value={{\n state: state as unknown as TimeFieldState<TimeValue>,\n aria: {\n labelProps: fieldAria.labelProps,\n inputProps: fieldAria.inputProps,\n descriptionProps: fieldAria.descriptionProps,\n errorMessageProps: fieldAria.errorMessageProps,\n },\n }}\n >\n <div\n ref={setFieldRef}\n {...fieldAria.fieldProps}\n class={renderProps.class()}\n style={renderProps.style()}\n data-disabled={dataAttr(state.isDisabled())}\n data-readonly={dataAttr(state.isReadOnly())}\n data-required={dataAttr(state.isRequired())}\n data-invalid={dataAttr(state.isInvalid())}\n >\n <Provider values={[[TextContext, textSlots]] as Array<[Context<unknown>, unknown]>}>\n {local.children as JSX.Element}\n </Provider>\n </div>\n <Show when={(rest as Record<string, unknown>).name}>\n <HiddenTimeInput\n name={(rest as Record<string, unknown>).name as string | undefined}\n form={(rest as Record<string, unknown>).form as string | undefined}\n value={state.value()}\n autoComplete={(rest as Record<string, unknown>).autoComplete as string | undefined}\n isDisabled={state.isDisabled()}\n isRequired={state.isRequired()}\n validationBehavior={validationBehavior()}\n validationState={state}\n focus={() => {\n fieldRef()?.querySelector<HTMLElement>('[role=\"spinbutton\"]')?.focus();\n }}\n minValue={access(stateProps.minValue) as TimeValue | undefined}\n maxValue={access(stateProps.maxValue) as TimeValue | undefined}\n granularity={state.granularity}\n />\n </Show>\n </TimeFieldContext.Provider>\n </TimeFieldStateContext.Provider>\n );\n}\n\n/**\n * The input area containing time segments.\n */\nexport function TimeInput(props: TimeInputProps): JSX.Element {\n const { state, aria } = useTimeFieldContextValue();\n const [isFocused, setIsFocused] = createSignal(false);\n\n const renderValues = createMemo<TimeInputRenderProps>(() => ({\n isDisabled: state.isDisabled(),\n isFocused: isFocused(),\n }));\n\n const renderProps = useRenderProps(\n {\n class: props.class,\n style: props.style,\n defaultClassName: \"solidaria-TimeInput\",\n },\n renderValues,\n );\n\n return (\n <div\n {...aria.inputProps}\n class={renderProps.class()}\n style={renderProps.style()}\n data-disabled={dataAttr(state.isDisabled())}\n data-focused={dataAttr(isFocused())}\n onFocusIn={() => setIsFocused(true)}\n onFocusOut={() => setIsFocused(false)}\n >\n <For each={state.segments()}>{(segment) => props.children?.(segment)}</For>\n </div>\n );\n}\n\n/**\n * A segment of a time field (hour, minute, second, AM/PM).\n */\nexport function TimeSegment(props: TimeSegmentProps): JSX.Element {\n const state = useTimeFieldContext();\n const [segmentRef, setSegmentRef] = createSignal<HTMLDivElement | null>(null);\n\n const segmentAria = createTimeSegment(\n { segment: props.segment },\n state as unknown as TimeFieldState,\n segmentRef,\n );\n\n const renderValues = createMemo<TimeSegmentRenderProps>(() => ({\n isFocused: segmentAria.isFocused,\n isEditable: segmentAria.isEditable,\n isPlaceholder: segmentAria.isPlaceholder,\n type: props.segment.type,\n text: segmentAria.text,\n }));\n\n const renderProps = useRenderProps(\n {\n get children() {\n return props.children;\n },\n class: props.class,\n style: props.style,\n defaultClassName: \"solidaria-TimeSegment\",\n },\n renderValues,\n );\n\n // Determine children content - avoid Show for SSR hydration compatibility\n const getChildren = () => {\n if (typeof props.children === \"function\") {\n return renderProps.renderChildren();\n }\n return segmentAria.text;\n };\n\n return (\n <div\n ref={setSegmentRef}\n {...segmentAria.segmentProps}\n class={renderProps.class()}\n style={renderProps.style()}\n data-focused={dataAttr(segmentAria.isFocused)}\n data-editable={dataAttr(segmentAria.isEditable)}\n data-placeholder={dataAttr(segmentAria.isPlaceholder)}\n data-type={props.segment.type}\n >\n {getChildren()}\n </div>\n );\n}\n\nexport interface TimeFieldLabelProps {\n children?: JSX.Element;\n class?: string;\n}\n\nexport function TimeFieldLabel(props: TimeFieldLabelProps): JSX.Element {\n const { aria } = useTimeFieldContextValue();\n return (\n <span {...aria.labelProps} class={props.class}>\n {props.children}\n </span>\n );\n}\n\nexport interface TimeFieldDescriptionProps {\n children?: JSX.Element;\n class?: string;\n}\n\nexport function TimeFieldDescription(props: TimeFieldDescriptionProps): JSX.Element {\n const { aria } = useTimeFieldContextValue();\n return (\n <p {...aria.descriptionProps} class={props.class}>\n {props.children}\n </p>\n );\n}\n\nexport interface TimeFieldErrorMessageProps {\n children?: JSX.Element;\n class?: string;\n}\n\nexport function TimeFieldErrorMessage(props: TimeFieldErrorMessageProps): JSX.Element {\n const { aria } = useTimeFieldContextValue();\n return (\n <p {...aria.errorMessageProps} class={props.class}>\n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MAAM,KAAK,mBAAmB,OAAO,MAAM,OAAO;OAChD,MAAM,SAAS;IAClB,EAAE;AAEN"}
|
package/dist/Toast.d.ts
CHANGED
|
@@ -158,6 +158,20 @@ export interface ToastDescriptionProps {
|
|
|
158
158
|
* ToastDescription renders the toast description with proper accessibility attributes.
|
|
159
159
|
*/
|
|
160
160
|
export declare function ToastDescription(props: ToastDescriptionProps): JSX.Element;
|
|
161
|
+
export interface ToastContentProps {
|
|
162
|
+
children: JSX.Element;
|
|
163
|
+
class?: string;
|
|
164
|
+
style?: JSX.CSSProperties;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* ToastContent wraps the toast message (title + description) in the live region
|
|
168
|
+
* announced to screen readers. It carries `role="alert"` / `aria-live="assertive"`
|
|
169
|
+
* from createToast's contentProps so the toast text is announced when it appears.
|
|
170
|
+
*
|
|
171
|
+
* It is rendered as a sibling of the close button (never wrapping it) so screen
|
|
172
|
+
* readers announce the message without reading the close button first.
|
|
173
|
+
*/
|
|
174
|
+
export declare function ToastContent(props: ToastContentProps): JSX.Element;
|
|
161
175
|
export interface ToastCloseButtonProps {
|
|
162
176
|
/** The toast to close. */
|
|
163
177
|
toast: QueuedToast<ToastContent>;
|
package/dist/Toast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../src/Toast.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,KAAK,GAAG,EACR,KAAK,QAAQ,EASd,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,UAAU,EAEX,MAAM,iCAAiC,CAAC;AAMzC,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EAIrB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,YAAY;IAC3B,oFAAoF;IACpF,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E;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,GAAG,CAAC,OAAO,CAiBlE;AAED,MAAM,WAAW,qBAAqB;IACpC,0BAA0B;IAC1B,KAAK,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;IACjC,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,GAAG,CAAC,OAAO,CAsB1E;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;CAClC;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,GAAG,CAAC,OAAO,CAoClE"}
|
package/dist/Toast.js
ADDED
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
import { filterDOMProps, useIsHydrated, useRenderProps } from "./utils.js";
|
|
2
|
+
import { Portal, addEventListener, className, createComponent, delegateEvents, effect, getNextElement, getNextMarker, insert, memo, mergeProps, runHydrationEvents, setAttribute, spread, style, template, use } from "solid-js/web";
|
|
3
|
+
import { Show, createContext, createEffect, createMemo, createSignal, onCleanup, splitProps, useContext } from "solid-js";
|
|
4
|
+
import { createToast, createToastRegion, useUNSAFE_PortalContext } from "@proyecto-viviana/solidaria";
|
|
5
|
+
import { ToastQueue, createToastState } from "@proyecto-viviana/solid-stately";
|
|
6
|
+
//#region src/Toast.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Toast components for solidaria-components
|
|
9
|
+
*
|
|
10
|
+
* Toast notifications with auto-dismiss, pause on hover/focus, and accessibility.
|
|
11
|
+
* Port of react-aria-components Toast.
|
|
12
|
+
*/
|
|
13
|
+
var _tmpl$ = /*#__PURE__*/ template(`<div>`), _tmpl$2 = /*#__PURE__*/ template(`<span data-solidaria-toast-title>`), _tmpl$3 = /*#__PURE__*/ template(`<span data-solidaria-toast-description>`), _tmpl$4 = /*#__PURE__*/ template(`<div data-solidaria-toast-content>`), _tmpl$5 = /*#__PURE__*/ template(`<button type=button data-solidaria-toast-close-button>`), _tmpl$6 = /*#__PURE__*/ template(`<button type=button style=margin-top:8px>`), _tmpl$7 = /*#__PURE__*/ template(`<div style=display:flex;align-items:flex-start;gap:12px><!$><!/><!$><!/>`);
|
|
14
|
+
const ToastContext = createContext(null);
|
|
15
|
+
const ToastAriaContext = createContext(null);
|
|
16
|
+
const toastStateByKey = /* @__PURE__ */ new Map();
|
|
17
|
+
function useToastContext() {
|
|
18
|
+
const context = useContext(ToastContext);
|
|
19
|
+
if (!context) throw new Error("Toast components must be used within a ToastProvider");
|
|
20
|
+
return context;
|
|
21
|
+
}
|
|
22
|
+
/** Default global toast queue that can be used for app-wide toasts. */
|
|
23
|
+
const globalToastQueue = new ToastQueue({
|
|
24
|
+
maxVisibleToasts: Infinity,
|
|
25
|
+
hasExitAnimation: true
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Add a toast to the global queue.
|
|
29
|
+
* Convenience function for adding toasts from anywhere in the app.
|
|
30
|
+
*/
|
|
31
|
+
function addToast(content, options) {
|
|
32
|
+
return globalToastQueue.add(content, options);
|
|
33
|
+
}
|
|
34
|
+
function normalizeToastPlacement(placement) {
|
|
35
|
+
return (placement ?? "bottom").replace("-", " ");
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* ToastProvider creates a toast queue context for descendant components.
|
|
39
|
+
* Use this to wrap your app or a section that needs toast notifications.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```tsx
|
|
43
|
+
* <ToastProvider>
|
|
44
|
+
* <App />
|
|
45
|
+
* <ToastRegion />
|
|
46
|
+
* </ToastProvider>
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
function ToastProvider(props) {
|
|
50
|
+
const state = createToastState({ queue: props.useGlobalQueue ? globalToastQueue : new ToastQueue(props.queueOptions) });
|
|
51
|
+
return createComponent(ToastContext.Provider, {
|
|
52
|
+
value: state,
|
|
53
|
+
get children() {
|
|
54
|
+
return props.children;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* ToastRegion is a container that displays all visible toasts.
|
|
60
|
+
* It handles pause on hover/focus and provides the landmark region.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```tsx
|
|
64
|
+
* <ToastRegion placement="bottom-end">
|
|
65
|
+
* {(renderProps) => (
|
|
66
|
+
* <For each={renderProps.visibleToasts}>
|
|
67
|
+
* {(toast) => <Toast toast={toast} />}
|
|
68
|
+
* </For>
|
|
69
|
+
* )}
|
|
70
|
+
* </ToastRegion>
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
function ToastRegion(props) {
|
|
74
|
+
const isHydrated = useIsHydrated();
|
|
75
|
+
const [local, rest] = splitProps(props, [
|
|
76
|
+
"children",
|
|
77
|
+
"class",
|
|
78
|
+
"style",
|
|
79
|
+
"state",
|
|
80
|
+
"aria-label",
|
|
81
|
+
"portal",
|
|
82
|
+
"placement"
|
|
83
|
+
]);
|
|
84
|
+
const portalContext = useUNSAFE_PortalContext();
|
|
85
|
+
const portalContainer = () => portalContext.getContainer?.() ?? void 0;
|
|
86
|
+
const [regionElement, setRegionElement] = createSignal();
|
|
87
|
+
const contextState = useContext(ToastContext);
|
|
88
|
+
const state = () => local.state ?? contextState;
|
|
89
|
+
const regionAria = createToastRegion({
|
|
90
|
+
state: {
|
|
91
|
+
visibleToasts: () => state()?.visibleToasts() ?? [],
|
|
92
|
+
add: (content, options) => state()?.add(content, options) ?? "",
|
|
93
|
+
close: (key) => state()?.close(key),
|
|
94
|
+
remove: (key) => state()?.remove(key),
|
|
95
|
+
clear: () => state()?.clear(),
|
|
96
|
+
pauseAll: () => state()?.pauseAll(),
|
|
97
|
+
resumeAll: () => state()?.resumeAll()
|
|
98
|
+
},
|
|
99
|
+
ref: regionElement,
|
|
100
|
+
get "aria-label"() {
|
|
101
|
+
return local["aria-label"];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
const renderValues = createMemo(() => ({ visibleToasts: () => state()?.visibleToasts() ?? [] }));
|
|
105
|
+
const renderProps = useRenderProps({
|
|
106
|
+
get children() {
|
|
107
|
+
return props.children;
|
|
108
|
+
},
|
|
109
|
+
class: local.class,
|
|
110
|
+
style: local.style,
|
|
111
|
+
defaultClassName: "solidaria-ToastRegion"
|
|
112
|
+
}, renderValues);
|
|
113
|
+
const domProps = createMemo(() => filterDOMProps(rest, { global: true }));
|
|
114
|
+
const placementStyles = createMemo(() => {
|
|
115
|
+
const [edge, align = "center"] = normalizeToastPlacement(local.placement).split(" ");
|
|
116
|
+
const base = {
|
|
117
|
+
position: "fixed",
|
|
118
|
+
"z-index": 100001,
|
|
119
|
+
display: "flex",
|
|
120
|
+
"flex-direction": edge === "top" ? "column" : "column-reverse",
|
|
121
|
+
gap: "8px",
|
|
122
|
+
padding: "16px",
|
|
123
|
+
"pointer-events": "none"
|
|
124
|
+
};
|
|
125
|
+
if (edge === "top") {
|
|
126
|
+
if (align === "end") return {
|
|
127
|
+
...base,
|
|
128
|
+
top: "16px",
|
|
129
|
+
right: "16px"
|
|
130
|
+
};
|
|
131
|
+
if (align === "start") return {
|
|
132
|
+
...base,
|
|
133
|
+
top: "16px",
|
|
134
|
+
left: "16px"
|
|
135
|
+
};
|
|
136
|
+
return {
|
|
137
|
+
...base,
|
|
138
|
+
top: "16px",
|
|
139
|
+
left: "50%",
|
|
140
|
+
transform: "translateX(-50%)"
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
if (align === "end") return {
|
|
144
|
+
...base,
|
|
145
|
+
bottom: "16px",
|
|
146
|
+
right: "16px"
|
|
147
|
+
};
|
|
148
|
+
if (align === "start") return {
|
|
149
|
+
...base,
|
|
150
|
+
bottom: "16px",
|
|
151
|
+
left: "16px"
|
|
152
|
+
};
|
|
153
|
+
return {
|
|
154
|
+
...base,
|
|
155
|
+
bottom: "16px",
|
|
156
|
+
left: "50%",
|
|
157
|
+
transform: "translateX(-50%)"
|
|
158
|
+
};
|
|
159
|
+
});
|
|
160
|
+
const normalizedPlacement = () => normalizeToastPlacement(local.placement);
|
|
161
|
+
const visibleToasts = () => state()?.visibleToasts() ?? [];
|
|
162
|
+
const hasToasts = () => visibleToasts().length > 0;
|
|
163
|
+
const hasAuthoredRegionStyle = () => local.class != null || local.style != null;
|
|
164
|
+
const regionContent = () => {
|
|
165
|
+
if (!state()) return null;
|
|
166
|
+
const mergedStyle = () => {
|
|
167
|
+
const custom = renderProps.style();
|
|
168
|
+
if (hasAuthoredRegionStyle()) return custom;
|
|
169
|
+
const placement = placementStyles();
|
|
170
|
+
if (!custom) return placement;
|
|
171
|
+
return {
|
|
172
|
+
...placement,
|
|
173
|
+
...custom
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
const { ref: _ref, ...cleanRegionProps } = regionAria.regionProps;
|
|
177
|
+
return (() => {
|
|
178
|
+
var _el$ = getNextElement(_tmpl$);
|
|
179
|
+
use(setRegionElement, _el$);
|
|
180
|
+
spread(_el$, mergeProps(domProps, cleanRegionProps, {
|
|
181
|
+
get ["class"]() {
|
|
182
|
+
return renderProps.class();
|
|
183
|
+
},
|
|
184
|
+
get style() {
|
|
185
|
+
return mergedStyle();
|
|
186
|
+
},
|
|
187
|
+
get ["data-placement"]() {
|
|
188
|
+
return normalizedPlacement();
|
|
189
|
+
}
|
|
190
|
+
}), false, true);
|
|
191
|
+
insert(_el$, () => renderProps.renderChildren());
|
|
192
|
+
runHydrationEvents();
|
|
193
|
+
return _el$;
|
|
194
|
+
})();
|
|
195
|
+
};
|
|
196
|
+
return createComponent(Show, {
|
|
197
|
+
get when() {
|
|
198
|
+
return memo(() => !!isHydrated())() && hasToasts();
|
|
199
|
+
},
|
|
200
|
+
get children() {
|
|
201
|
+
return createComponent(Show, {
|
|
202
|
+
get when() {
|
|
203
|
+
return local.portal !== false;
|
|
204
|
+
},
|
|
205
|
+
get fallback() {
|
|
206
|
+
return regionContent();
|
|
207
|
+
},
|
|
208
|
+
get children() {
|
|
209
|
+
return createComponent(Portal, {
|
|
210
|
+
get mount() {
|
|
211
|
+
return portalContainer();
|
|
212
|
+
},
|
|
213
|
+
get children() {
|
|
214
|
+
return regionContent();
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Toast is an individual notification component.
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```tsx
|
|
227
|
+
* <Toast toast={toast}>
|
|
228
|
+
* {(renderProps) => (
|
|
229
|
+
* <div class={renderProps.isExiting ? 'fade-out' : 'fade-in'}>
|
|
230
|
+
* <h3>{renderProps.toast.content.title}</h3>
|
|
231
|
+
* <p>{renderProps.toast.content.description}</p>
|
|
232
|
+
* </div>
|
|
233
|
+
* )}
|
|
234
|
+
* </Toast>
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
function Toast(props) {
|
|
238
|
+
const [local, rest] = splitProps(props, [
|
|
239
|
+
"toast",
|
|
240
|
+
"children",
|
|
241
|
+
"class",
|
|
242
|
+
"style"
|
|
243
|
+
]);
|
|
244
|
+
let toastRef;
|
|
245
|
+
const state = useToastContext();
|
|
246
|
+
createEffect(() => {
|
|
247
|
+
const key = local.toast.key;
|
|
248
|
+
toastStateByKey.set(key, state);
|
|
249
|
+
onCleanup(() => {
|
|
250
|
+
if (toastStateByKey.get(key) === state) toastStateByKey.delete(key);
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
const hasTitle = () => !!(local.toast.content.children ?? local.toast.content.title);
|
|
254
|
+
const toastAria = createToast({
|
|
255
|
+
toast: local.toast,
|
|
256
|
+
state,
|
|
257
|
+
hasTitle: hasTitle(),
|
|
258
|
+
hasDescription: !!local.toast.content.description
|
|
259
|
+
});
|
|
260
|
+
const renderValues = createMemo(() => ({
|
|
261
|
+
isEntering: local.toast.animation === "entering",
|
|
262
|
+
isExiting: local.toast.animation === "exiting",
|
|
263
|
+
animation: local.toast.animation,
|
|
264
|
+
toast: local.toast
|
|
265
|
+
}));
|
|
266
|
+
const renderProps = useRenderProps({
|
|
267
|
+
get children() {
|
|
268
|
+
return props.children;
|
|
269
|
+
},
|
|
270
|
+
class: local.class,
|
|
271
|
+
style: local.style,
|
|
272
|
+
defaultClassName: "solidaria-Toast"
|
|
273
|
+
}, renderValues);
|
|
274
|
+
const domProps = createMemo(() => filterDOMProps(rest, { global: true }));
|
|
275
|
+
const mergedStyle = () => {
|
|
276
|
+
const custom = renderProps.style();
|
|
277
|
+
if (!custom) return { "pointer-events": "auto" };
|
|
278
|
+
return {
|
|
279
|
+
"pointer-events": "auto",
|
|
280
|
+
...custom
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
const handleRootClick = (event) => {
|
|
284
|
+
const target = event.target;
|
|
285
|
+
if (!(target instanceof Element)) return;
|
|
286
|
+
if (target.closest("[data-solidaria-toast-close-button]")) {
|
|
287
|
+
state.close(local.toast.key);
|
|
288
|
+
state.remove(local.toast.key);
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
createEffect(() => {
|
|
292
|
+
if (local.toast.animation !== "exiting") return;
|
|
293
|
+
if (!toastRef) {
|
|
294
|
+
state.remove(local.toast.key);
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (!("getAnimations" in toastRef)) {
|
|
298
|
+
state.remove(local.toast.key);
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
const animations = toastRef.getAnimations();
|
|
302
|
+
if (animations.length === 0) {
|
|
303
|
+
state.remove(local.toast.key);
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
let canceled = false;
|
|
307
|
+
Promise.all(animations.map((a) => a.finished)).then(() => {
|
|
308
|
+
if (!canceled) state.remove(local.toast.key);
|
|
309
|
+
}).catch(() => {
|
|
310
|
+
if (!canceled) state.remove(local.toast.key);
|
|
311
|
+
});
|
|
312
|
+
onCleanup(() => {
|
|
313
|
+
canceled = true;
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
const { ref: _ref, ...cleanToastProps } = toastAria.toastProps;
|
|
317
|
+
createEffect(() => {
|
|
318
|
+
if (!toastRef) return;
|
|
319
|
+
const titleId = toastAria.titleProps.id;
|
|
320
|
+
const descriptionId = toastAria.descriptionProps.id;
|
|
321
|
+
const contentProps = toastAria.contentProps;
|
|
322
|
+
if (titleId) {
|
|
323
|
+
const titleEl = toastRef.querySelector("[data-solidaria-toast-title]");
|
|
324
|
+
if (titleEl instanceof HTMLElement) titleEl.id = titleId;
|
|
325
|
+
}
|
|
326
|
+
if (descriptionId) {
|
|
327
|
+
const descriptionEl = toastRef.querySelector("[data-solidaria-toast-description]");
|
|
328
|
+
if (descriptionEl instanceof HTMLElement) descriptionEl.id = descriptionId;
|
|
329
|
+
}
|
|
330
|
+
const contentEl = toastRef.querySelector("[data-solidaria-toast-content]");
|
|
331
|
+
if (contentEl instanceof HTMLElement) {
|
|
332
|
+
const role = contentProps.role;
|
|
333
|
+
const ariaLive = contentProps["aria-live"];
|
|
334
|
+
const ariaAtomic = contentProps["aria-atomic"];
|
|
335
|
+
if (role) contentEl.setAttribute("role", role);
|
|
336
|
+
if (ariaLive) contentEl.setAttribute("aria-live", ariaLive);
|
|
337
|
+
if (ariaAtomic) contentEl.setAttribute("aria-atomic", ariaAtomic);
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
return createComponent(ToastAriaContext.Provider, {
|
|
341
|
+
get value() {
|
|
342
|
+
return {
|
|
343
|
+
titleProps: toastAria.titleProps,
|
|
344
|
+
descriptionProps: toastAria.descriptionProps,
|
|
345
|
+
contentProps: toastAria.contentProps
|
|
346
|
+
};
|
|
347
|
+
},
|
|
348
|
+
get children() {
|
|
349
|
+
var _el$2 = getNextElement(_tmpl$);
|
|
350
|
+
var _ref$ = toastRef;
|
|
351
|
+
typeof _ref$ === "function" ? use(_ref$, _el$2) : toastRef = _el$2;
|
|
352
|
+
spread(_el$2, mergeProps(domProps, cleanToastProps, {
|
|
353
|
+
get ["class"]() {
|
|
354
|
+
return renderProps.class();
|
|
355
|
+
},
|
|
356
|
+
get style() {
|
|
357
|
+
return mergedStyle();
|
|
358
|
+
},
|
|
359
|
+
get ["data-animation"]() {
|
|
360
|
+
return local.toast.animation;
|
|
361
|
+
},
|
|
362
|
+
get ["data-type"]() {
|
|
363
|
+
return local.toast.content.type ?? local.toast.content.variant;
|
|
364
|
+
},
|
|
365
|
+
get ["data-variant"]() {
|
|
366
|
+
return local.toast.content.variant;
|
|
367
|
+
},
|
|
368
|
+
"on:click": handleRootClick
|
|
369
|
+
}), false, true);
|
|
370
|
+
insert(_el$2, () => renderProps.renderChildren());
|
|
371
|
+
runHydrationEvents();
|
|
372
|
+
return _el$2;
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* ToastTitle renders the toast title with proper accessibility attributes.
|
|
378
|
+
*/
|
|
379
|
+
function ToastTitle(props) {
|
|
380
|
+
const { ref: _ref, ...ariaTitleProps } = useContext(ToastAriaContext)?.titleProps ?? {};
|
|
381
|
+
return (() => {
|
|
382
|
+
var _el$3 = getNextElement(_tmpl$2);
|
|
383
|
+
spread(_el$3, mergeProps(ariaTitleProps, {
|
|
384
|
+
get ["class"]() {
|
|
385
|
+
return props.class;
|
|
386
|
+
},
|
|
387
|
+
get style() {
|
|
388
|
+
return props.style;
|
|
389
|
+
}
|
|
390
|
+
}), false, true);
|
|
391
|
+
insert(_el$3, () => props.children);
|
|
392
|
+
runHydrationEvents();
|
|
393
|
+
return _el$3;
|
|
394
|
+
})();
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* ToastDescription renders the toast description with proper accessibility attributes.
|
|
398
|
+
*/
|
|
399
|
+
function ToastDescription(props) {
|
|
400
|
+
const { ref: _ref, ...ariaDescriptionProps } = useContext(ToastAriaContext)?.descriptionProps ?? {};
|
|
401
|
+
return (() => {
|
|
402
|
+
var _el$4 = getNextElement(_tmpl$3);
|
|
403
|
+
spread(_el$4, mergeProps(ariaDescriptionProps, {
|
|
404
|
+
get ["class"]() {
|
|
405
|
+
return props.class;
|
|
406
|
+
},
|
|
407
|
+
get style() {
|
|
408
|
+
return props.style;
|
|
409
|
+
}
|
|
410
|
+
}), false, true);
|
|
411
|
+
insert(_el$4, () => props.children);
|
|
412
|
+
runHydrationEvents();
|
|
413
|
+
return _el$4;
|
|
414
|
+
})();
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* ToastContent wraps the toast message (title + description) in the live region
|
|
418
|
+
* announced to screen readers. It carries `role="alert"` / `aria-live="assertive"`
|
|
419
|
+
* from createToast's contentProps so the toast text is announced when it appears.
|
|
420
|
+
*
|
|
421
|
+
* It is rendered as a sibling of the close button (never wrapping it) so screen
|
|
422
|
+
* readers announce the message without reading the close button first.
|
|
423
|
+
*/
|
|
424
|
+
function ToastContent(props) {
|
|
425
|
+
const { ref: _ref, ...ariaContentProps } = useContext(ToastAriaContext)?.contentProps ?? {};
|
|
426
|
+
return (() => {
|
|
427
|
+
var _el$5 = getNextElement(_tmpl$4);
|
|
428
|
+
spread(_el$5, mergeProps(ariaContentProps, {
|
|
429
|
+
get ["class"]() {
|
|
430
|
+
return props.class;
|
|
431
|
+
},
|
|
432
|
+
get style() {
|
|
433
|
+
return props.style;
|
|
434
|
+
}
|
|
435
|
+
}), false, true);
|
|
436
|
+
insert(_el$5, () => props.children);
|
|
437
|
+
runHydrationEvents();
|
|
438
|
+
return _el$5;
|
|
439
|
+
})();
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* ToastCloseButton is a button that closes the toast.
|
|
443
|
+
*/
|
|
444
|
+
function ToastCloseButton(props) {
|
|
445
|
+
const contextState = useContext(ToastContext);
|
|
446
|
+
const handleClose = () => {
|
|
447
|
+
const key = props.toast.key;
|
|
448
|
+
const state = contextState ?? toastStateByKey.get(key);
|
|
449
|
+
state?.close(key);
|
|
450
|
+
state?.remove(key);
|
|
451
|
+
};
|
|
452
|
+
return (() => {
|
|
453
|
+
var _el$6 = getNextElement(_tmpl$5);
|
|
454
|
+
_el$6.$$click = handleClose;
|
|
455
|
+
addEventListener(_el$6, "click", handleClose);
|
|
456
|
+
insert(_el$6, () => props.children ?? "×");
|
|
457
|
+
effect((_p$) => {
|
|
458
|
+
var _v$ = props.class, _v$2 = props.style, _v$3 = props["aria-label"] ?? "Close";
|
|
459
|
+
_v$ !== _p$.e && className(_el$6, _p$.e = _v$);
|
|
460
|
+
_p$.t = style(_el$6, _v$2, _p$.t);
|
|
461
|
+
_v$3 !== _p$.a && setAttribute(_el$6, "aria-label", _p$.a = _v$3);
|
|
462
|
+
return _p$;
|
|
463
|
+
}, {
|
|
464
|
+
e: void 0,
|
|
465
|
+
t: void 0,
|
|
466
|
+
a: void 0
|
|
467
|
+
});
|
|
468
|
+
runHydrationEvents();
|
|
469
|
+
return _el$6;
|
|
470
|
+
})();
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* DefaultToast provides a basic toast layout with title, description, and close button.
|
|
474
|
+
* Use this as a starting point or as-is for simple toast needs.
|
|
475
|
+
*/
|
|
476
|
+
function DefaultToast(props) {
|
|
477
|
+
const content = () => props.toast.content;
|
|
478
|
+
const title = () => content().children ?? content().title;
|
|
479
|
+
const actionLabel = () => content().actionLabel ?? content().action?.label;
|
|
480
|
+
const actionHandler = () => content().onAction ?? content().action?.onAction;
|
|
481
|
+
const state = useToastContext();
|
|
482
|
+
const handleAction = () => {
|
|
483
|
+
actionHandler()?.();
|
|
484
|
+
if (content().shouldCloseOnAction) {
|
|
485
|
+
state.close(props.toast.key);
|
|
486
|
+
state.remove(props.toast.key);
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
return createComponent(Toast, {
|
|
490
|
+
get toast() {
|
|
491
|
+
return props.toast;
|
|
492
|
+
},
|
|
493
|
+
get children() {
|
|
494
|
+
var _el$7 = getNextElement(_tmpl$7), _el$9 = _el$7.firstChild, [_el$0, _co$] = getNextMarker(_el$9.nextSibling), _el$1 = _el$0.nextSibling, [_el$10, _co$2] = getNextMarker(_el$1.nextSibling);
|
|
495
|
+
insert(_el$7, createComponent(ToastContent, {
|
|
496
|
+
style: { flex: 1 },
|
|
497
|
+
get children() {
|
|
498
|
+
return [
|
|
499
|
+
createComponent(Show, {
|
|
500
|
+
get when() {
|
|
501
|
+
return title();
|
|
502
|
+
},
|
|
503
|
+
get children() {
|
|
504
|
+
return createComponent(ToastTitle, {
|
|
505
|
+
style: {
|
|
506
|
+
"font-weight": "bold",
|
|
507
|
+
"margin-bottom": "4px"
|
|
508
|
+
},
|
|
509
|
+
get children() {
|
|
510
|
+
return title();
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
}),
|
|
515
|
+
createComponent(Show, {
|
|
516
|
+
get when() {
|
|
517
|
+
return content().description;
|
|
518
|
+
},
|
|
519
|
+
get children() {
|
|
520
|
+
return createComponent(ToastDescription, { get children() {
|
|
521
|
+
return content().description;
|
|
522
|
+
} });
|
|
523
|
+
}
|
|
524
|
+
}),
|
|
525
|
+
createComponent(Show, {
|
|
526
|
+
get when() {
|
|
527
|
+
return actionLabel();
|
|
528
|
+
},
|
|
529
|
+
get children() {
|
|
530
|
+
var _el$8 = getNextElement(_tmpl$6);
|
|
531
|
+
_el$8.$$click = handleAction;
|
|
532
|
+
insert(_el$8, actionLabel);
|
|
533
|
+
runHydrationEvents();
|
|
534
|
+
return _el$8;
|
|
535
|
+
}
|
|
536
|
+
})
|
|
537
|
+
];
|
|
538
|
+
}
|
|
539
|
+
}), _el$0, _co$);
|
|
540
|
+
insert(_el$7, createComponent(ToastCloseButton, { get toast() {
|
|
541
|
+
return props.toast;
|
|
542
|
+
} }), _el$10, _co$2);
|
|
543
|
+
return _el$7;
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
delegateEvents(["click"]);
|
|
548
|
+
//#endregion
|
|
549
|
+
export { DefaultToast, Toast, ToastCloseButton, ToastContent, ToastContext, ToastDescription, ToastProvider, ToastRegion, ToastTitle, addToast, globalToastQueue, useToastContext };
|
|
550
|
+
|
|
551
|
+
//# sourceMappingURL=Toast.js.map
|