@proyecto-viviana/solidaria-components 0.3.1 → 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 +8 -5
- 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 +7 -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 -23711
- package/dist/index.jsx +70 -18116
- 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 +90 -23
- 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 +126 -14
- package/src/DateField.tsx +20 -2
- package/src/DatePicker.tsx +117 -10
- 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 +298 -131
- package/src/Meter.tsx +3 -1
- package/src/Modal.tsx +100 -52
- package/src/NumberField.tsx +73 -10
- package/src/Popover.tsx +49 -11
- 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 +4 -1
- package/src/Text.tsx +31 -10
- package/src/TextField.tsx +73 -10
- 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 +55 -8
- 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":"Toast.js","names":["JSX","Accessor","createContext","createMemo","createEffect","createSignal","onCleanup","splitProps","Show","useContext","Portal","ToastState","QueuedToast","ToastQueueOptions","ToastOptions","ToastQueue","createToastState","createToast","createToastRegion","useUNSAFE_PortalContext","RenderChildren","ClassNameOrFunction","StyleOrFunction","useRenderProps","filterDOMProps","useIsHydrated","ToastContent","id","dataAttribute","children","title","description","variant","type","actionLabel","onAction","shouldCloseOnAction","action","label","ToastRenderProps","isEntering","isExiting","animation","toast","ToastRegionRenderProps","visibleToasts","ToastRegionProps","class","style","state","portal","placement","ToastProps","ToastContext","ToastAriaContextValue","titleProps","HTMLAttributes","HTMLElement","descriptionProps","contentProps","ToastAriaContext","toastStateByKey","Map","useToastContext","context","Error","globalToastQueue","maxVisibleToasts","Infinity","hasExitAnimation","addToast","content","options","add","normalizeToastPlacement","replace","NonNullable","ToastProviderProps","Element","queueOptions","useGlobalQueue","ToastProvider","props","queue","_$createComponent","Provider","value","ToastRegion","isHydrated","local","rest","portalContext","portalContainer","getContainer","undefined","regionElement","setRegionElement","contextState","regionAria","close","key","remove","clear","pauseAll","resumeAll","ref","aria-label","renderValues","renderProps","defaultClassName","domProps","Record","global","placementStyles","CSSProperties","edge","align","split","base","position","display","gap","padding","top","right","left","transform","bottom","normalizedPlacement","hasToasts","length","hasAuthoredRegionStyle","regionContent","mergedStyle","custom","_ref","cleanRegionProps","regionProps","_el$","_$getNextElement","_tmpl$","_$use","_$spread","_$mergeProps","data-placement","_$insert","renderChildren","_$runHydrationEvents","when","_$memo","fallback","mount","Toast","toastRef","HTMLDivElement","set","get","delete","hasTitle","toastAria","hasDescription","const","handleRootClick","event","MouseEvent","target","closest","animations","getAnimations","canceled","Promise","all","map","a","finished","then","catch","cleanToastProps","toastProps","titleId","descriptionId","titleEl","querySelector","descriptionEl","contentEl","role","ariaLive","ariaAtomic","setAttribute","_el$2","_ref$","data-animation","data-type","data-variant","ToastTitleProps","ToastTitle","ariaTitleProps","_el$3","_tmpl$2","ToastDescriptionProps","ToastDescription","ariaDescriptionProps","_el$4","_tmpl$3","ToastContentProps","ariaContentProps","_el$5","_tmpl$4","ToastCloseButtonProps","ToastCloseButton","handleClose","_el$6","_tmpl$5","$$click","_$addEventListener","_$effect","_p$","_v$","_v$2","_v$3","e","_$className","t","_$style","_$setAttribute","DefaultToastProps","DefaultToast","actionHandler","handleAction","_el$7","_tmpl$7","_el$9","firstChild","_el$0","_co$","_$getNextMarker","nextSibling","_el$1","_el$10","_co$2","flex","_el$8","_tmpl$6","_$delegateEvents"],"sources":["../src/Toast.tsx"],"sourcesContent":["/**\n * Toast components for solidaria-components\n *\n * Toast notifications with auto-dismiss, pause on hover/focus, and accessibility.\n * Port of react-aria-components Toast.\n */\n\nimport {\n type JSX,\n type Accessor,\n createContext,\n createMemo,\n createEffect,\n createSignal,\n onCleanup,\n splitProps,\n Show,\n useContext,\n} from \"solid-js\";\nimport { Portal } from \"solid-js/web\";\nimport {\n type ToastState,\n type QueuedToast,\n type ToastQueueOptions,\n type ToastOptions,\n ToastQueue,\n createToastState,\n} from \"@proyecto-viviana/solid-stately\";\nimport {\n createToast,\n createToastRegion,\n useUNSAFE_PortalContext,\n} from \"@proyecto-viviana/solidaria\";\nimport {\n type RenderChildren,\n type ClassNameOrFunction,\n type StyleOrFunction,\n useRenderProps,\n filterDOMProps,\n useIsHydrated,\n} from \"./utils\";\n\nexport interface ToastContent {\n /** DOM id for the toast root when content is queued through Spectrum ToastQueue. */\n id?: string;\n /** Data attributes for the toast root when content is queued through Spectrum ToastQueue. */\n [dataAttribute: `data-${string}`]: string | number | boolean | undefined;\n /** Spectrum Toast message content. */\n children?: string;\n /** The title of the toast. */\n title?: string;\n /** The description/body of the toast. */\n description?: string;\n /** Spectrum variant. */\n variant?: \"info\" | \"positive\" | \"negative\" | \"neutral\";\n /** Backward-compatible type/variant of the toast. */\n type?: \"info\" | \"success\" | \"warning\" | \"error\" | \"positive\" | \"negative\" | \"neutral\";\n /** Spectrum action button label. */\n actionLabel?: string;\n /** Handler called when the Spectrum action button is pressed. */\n onAction?: () => void;\n /** Whether the toast should close when the Spectrum action is performed. */\n shouldCloseOnAction?: boolean;\n /** Custom action button. */\n action?: {\n label: string;\n onAction: () => void;\n };\n}\n\nexport interface ToastRenderProps {\n /** Whether the toast is currently animating in. */\n isEntering: boolean;\n /** Whether the toast is currently animating out. */\n isExiting: boolean;\n /** The animation state (entering, exiting, queued). */\n animation: \"entering\" | \"exiting\" | \"queued\" | undefined;\n /** The toast data. */\n toast: QueuedToast<ToastContent>;\n}\n\nexport interface ToastRegionRenderProps {\n /** The visible toasts. */\n visibleToasts: Accessor<QueuedToast<ToastContent>[]>;\n}\n\nexport interface ToastRegionProps {\n /** The children of the component - can be JSX or render function. */\n children?: RenderChildren<ToastRegionRenderProps>;\n /** The CSS className for the element. */\n class?: ClassNameOrFunction<ToastRegionRenderProps>;\n /** The inline style for the element. */\n style?: StyleOrFunction<ToastRegionRenderProps>;\n /** The toast state to display. If not provided, uses ToastContext. */\n state?: ToastState<ToastContent>;\n /** Accessible label for the region. */\n \"aria-label\"?: string;\n /** Whether to render in a portal. */\n portal?: boolean;\n /** Placement of the toast region. */\n placement?:\n | \"top\"\n | \"top start\"\n | \"top end\"\n | \"top-start\"\n | \"top-end\"\n | \"bottom\"\n | \"bottom start\"\n | \"bottom end\"\n | \"bottom-start\"\n | \"bottom-end\";\n}\n\nexport interface ToastProps {\n /** DOM id for the toast root. */\n id?: string;\n /** Data attributes for the toast root. */\n [dataAttribute: `data-${string}`]: string | number | boolean | undefined;\n /** The toast data. */\n toast: QueuedToast<ToastContent>;\n /** The children of the component - can be JSX or render function. */\n children?: RenderChildren<ToastRenderProps>;\n /** The CSS className for the element. */\n class?: ClassNameOrFunction<ToastRenderProps>;\n /** The inline style for the element. */\n style?: StyleOrFunction<ToastRenderProps>;\n}\n\nexport const ToastContext = createContext<ToastState<ToastContent> | null>(null);\n\ninterface ToastAriaContextValue {\n titleProps: JSX.HTMLAttributes<HTMLElement>;\n descriptionProps: JSX.HTMLAttributes<HTMLElement>;\n contentProps: JSX.HTMLAttributes<HTMLElement>;\n}\n\nconst ToastAriaContext = createContext<ToastAriaContextValue | null>(null);\nconst toastStateByKey = new Map<string, ToastState<ToastContent>>();\n\nexport function useToastContext(): ToastState<ToastContent> {\n const context = useContext(ToastContext);\n if (!context) {\n throw new Error(\"Toast components must be used within a ToastProvider\");\n }\n return context;\n}\n\n/** Default global toast queue that can be used for app-wide toasts. */\nexport const globalToastQueue = new ToastQueue<ToastContent>({\n maxVisibleToasts: Infinity,\n hasExitAnimation: true,\n});\n\n/**\n * Add a toast to the global queue.\n * Convenience function for adding toasts from anywhere in the app.\n */\nexport function addToast(content: ToastContent, options?: ToastOptions): string {\n return globalToastQueue.add(content, options);\n}\n\nfunction normalizeToastPlacement(placement?: ToastRegionProps[\"placement\"]) {\n return (placement ?? \"bottom\").replace(\"-\", \" \") as NonNullable<ToastRegionProps[\"placement\"]>;\n}\n\nexport interface ToastProviderProps {\n /** The children of the provider. */\n children: JSX.Element;\n /** Custom toast queue options. */\n queueOptions?: ToastQueueOptions;\n /** Use global queue instead of creating a new one. */\n useGlobalQueue?: boolean;\n}\n\n/**\n * ToastProvider creates a toast queue context for descendant components.\n * Use this to wrap your app or a section that needs toast notifications.\n *\n * @example\n * ```tsx\n * <ToastProvider>\n * <App />\n * <ToastRegion />\n * </ToastProvider>\n * ```\n */\nexport function ToastProvider(props: ToastProviderProps): JSX.Element {\n const queue = props.useGlobalQueue\n ? globalToastQueue\n : new ToastQueue<ToastContent>(props.queueOptions);\n\n const state = createToastState({ queue });\n\n return <ToastContext.Provider value={state}>{props.children}</ToastContext.Provider>;\n}\n\n/**\n * ToastRegion is a container that displays all visible toasts.\n * It handles pause on hover/focus and provides the landmark region.\n *\n * @example\n * ```tsx\n * <ToastRegion placement=\"bottom-end\">\n * {(renderProps) => (\n * <For each={renderProps.visibleToasts}>\n * {(toast) => <Toast toast={toast} />}\n * </For>\n * )}\n * </ToastRegion>\n * ```\n */\nexport function ToastRegion(props: ToastRegionProps): JSX.Element {\n // Do NOT early-return on the server: returning null on the server and a <Show>\n // on the client desyncs hydration when the region is in the SSR tree. Render the\n // same structure on both and gate the Portal on useIsHydrated() (see Popover).\n const isHydrated = useIsHydrated();\n\n const [local, rest] = splitProps(props, [\n \"children\",\n \"class\",\n \"style\",\n \"state\",\n \"aria-label\",\n \"portal\",\n \"placement\",\n ]);\n const portalContext = useUNSAFE_PortalContext();\n const portalContainer = () => portalContext.getContainer?.() ?? undefined;\n const [regionElement, setRegionElement] = createSignal<HTMLElement>();\n\n const contextState = useContext(ToastContext);\n const state = () => local.state ?? contextState;\n\n const regionAria = createToastRegion<ToastContent>({\n state: {\n visibleToasts: () => state()?.visibleToasts() ?? [],\n add: (content, options) => state()?.add(content, options) ?? \"\",\n close: (key) => state()?.close(key),\n remove: (key) => state()?.remove(key),\n clear: () => state()?.clear(),\n pauseAll: () => state()?.pauseAll(),\n resumeAll: () => state()?.resumeAll(),\n },\n ref: regionElement,\n get \"aria-label\"() {\n return local[\"aria-label\"];\n },\n });\n\n const renderValues = createMemo<ToastRegionRenderProps>(() => ({\n visibleToasts: () => state()?.visibleToasts() ?? [],\n }));\n\n const renderProps = useRenderProps(\n {\n // Lazy: the region content is gated behind `<Show when={isHydrated() && …}>`\n // (Portal) below, so reading children must not instantiate templates during\n // the component body (would walk getNextElement before the gate the server\n // kept closed → hydration mismatch). See Popover for the full rationale.\n get children() {\n return props.children;\n },\n class: local.class,\n style: local.style,\n defaultClassName: \"solidaria-ToastRegion\",\n },\n renderValues,\n );\n const domProps = createMemo(() =>\n filterDOMProps(rest as Record<string, unknown>, { global: true }),\n );\n\n const placementStyles = createMemo<JSX.CSSProperties>(() => {\n const placement = normalizeToastPlacement(local.placement);\n const [edge, align = \"center\"] = placement.split(\" \");\n const base: JSX.CSSProperties = {\n position: \"fixed\",\n \"z-index\": 100001,\n display: \"flex\",\n \"flex-direction\": edge === \"top\" ? \"column\" : \"column-reverse\",\n gap: \"8px\",\n padding: \"16px\",\n \"pointer-events\": \"none\",\n };\n\n if (edge === \"top\") {\n if (align === \"end\") {\n return { ...base, top: \"16px\", right: \"16px\" } as JSX.CSSProperties;\n }\n if (align === \"start\") {\n return { ...base, top: \"16px\", left: \"16px\" } as JSX.CSSProperties;\n }\n return {\n ...base,\n top: \"16px\",\n left: \"50%\",\n transform: \"translateX(-50%)\",\n } as JSX.CSSProperties;\n }\n\n if (align === \"end\") {\n return { ...base, bottom: \"16px\", right: \"16px\" } as JSX.CSSProperties;\n }\n if (align === \"start\") {\n return { ...base, bottom: \"16px\", left: \"16px\" } as JSX.CSSProperties;\n }\n return {\n ...base,\n bottom: \"16px\",\n left: \"50%\",\n transform: \"translateX(-50%)\",\n } as JSX.CSSProperties;\n });\n\n const normalizedPlacement = () => normalizeToastPlacement(local.placement);\n\n const visibleToasts = () => state()?.visibleToasts() ?? [];\n const hasToasts = () => visibleToasts().length > 0;\n const hasAuthoredRegionStyle = () => local.class != null || local.style != null;\n\n const regionContent = () => {\n if (!state()) return null;\n\n const mergedStyle = () => {\n const custom = renderProps.style();\n // React Aria Components leaves ToastRegion unstyled. Keep this package's\n // fallback placement only for bare regions so styled layers such as S2 can\n // own fixed viewport geometry with their generated classes.\n if (hasAuthoredRegionStyle()) return custom;\n\n const placement = placementStyles();\n if (!custom) return placement;\n return { ...placement, ...custom } as JSX.CSSProperties;\n };\n\n const { ref: _ref, ...cleanRegionProps } = regionAria.regionProps as Record<string, unknown>;\n\n return (\n <div\n ref={setRegionElement}\n {...domProps()}\n {...cleanRegionProps}\n class={renderProps.class()}\n style={mergedStyle()}\n data-placement={normalizedPlacement()}\n >\n {renderProps.renderChildren()}\n </div>\n );\n };\n\n return (\n <Show when={isHydrated() && hasToasts()}>\n <Show when={local.portal !== false} fallback={regionContent()}>\n <Portal mount={portalContainer()}>{regionContent()}</Portal>\n </Show>\n </Show>\n );\n}\n\n/**\n * Toast is an individual notification component.\n *\n * @example\n * ```tsx\n * <Toast toast={toast}>\n * {(renderProps) => (\n * <div class={renderProps.isExiting ? 'fade-out' : 'fade-in'}>\n * <h3>{renderProps.toast.content.title}</h3>\n * <p>{renderProps.toast.content.description}</p>\n * </div>\n * )}\n * </Toast>\n * ```\n */\nexport function Toast(props: ToastProps): JSX.Element {\n const [local, rest] = splitProps(props, [\"toast\", \"children\", \"class\", \"style\"]);\n\n let toastRef!: HTMLDivElement;\n\n const state = useToastContext();\n\n createEffect(() => {\n const key = local.toast.key;\n toastStateByKey.set(key, state);\n onCleanup(() => {\n if (toastStateByKey.get(key) === state) {\n toastStateByKey.delete(key);\n }\n });\n });\n\n const hasTitle = () => !!(local.toast.content.children ?? local.toast.content.title);\n const toastAria = createToast({\n toast: local.toast,\n state,\n hasTitle: hasTitle(),\n hasDescription: !!local.toast.content.description,\n });\n\n const renderValues = createMemo<ToastRenderProps>(() => ({\n isEntering: local.toast.animation === \"entering\",\n isExiting: local.toast.animation === \"exiting\",\n animation: local.toast.animation,\n toast: local.toast,\n }));\n\n const renderProps = useRenderProps(\n {\n get children() {\n return props.children;\n },\n class: local.class,\n style: local.style,\n defaultClassName: \"solidaria-Toast\",\n },\n renderValues,\n );\n\n const domProps = createMemo(() =>\n filterDOMProps(rest as Record<string, unknown>, { global: true }),\n );\n\n const mergedStyle = () => {\n const custom = renderProps.style();\n if (!custom) return { \"pointer-events\": \"auto\" as const };\n return { \"pointer-events\": \"auto\" as const, ...custom } as JSX.CSSProperties;\n };\n\n const handleRootClick = (event: MouseEvent) => {\n const target = event.target;\n if (!(target instanceof Element)) return;\n if (target.closest(\"[data-solidaria-toast-close-button]\")) {\n state.close(local.toast.key);\n state.remove(local.toast.key);\n }\n };\n\n // Exit animation lifecycle:\n // When animation becomes 'exiting', wait for CSS animations/transitions to finish,\n // then call state.remove() to finalize removal from the queue.\n // In JSDOM or when no animations are running, remove immediately.\n // Reduced-motion is handled by CSS (shorter/no animations), so the lifecycle\n // naturally completes faster when the user prefers reduced motion.\n createEffect(() => {\n if (local.toast.animation !== \"exiting\") return;\n if (!toastRef) {\n state.remove(local.toast.key);\n return;\n }\n\n // Check if the element supports the Web Animations API\n if (!(\"getAnimations\" in toastRef)) {\n state.remove(local.toast.key);\n return;\n }\n\n const animations = toastRef.getAnimations();\n if (animations.length === 0) {\n // No CSS animations/transitions running - remove immediately\n state.remove(local.toast.key);\n return;\n }\n\n // Wait for all running animations to finish, then remove\n let canceled = false;\n Promise.all(animations.map((a) => a.finished))\n .then(() => {\n if (!canceled) {\n state.remove(local.toast.key);\n }\n })\n .catch(() => {\n // Animation was canceled (e.g. element removed) - still clean up\n if (!canceled) {\n state.remove(local.toast.key);\n }\n });\n\n onCleanup(() => {\n canceled = true;\n });\n });\n\n const { ref: _ref, ...cleanToastProps } = toastAria.toastProps as Record<string, unknown>;\n\n // Ensure ARIA title/description IDs and the content live-region attributes are\n // present on rendered sub-components, even when children are pre-composed outside\n // the Toast provider owner (as DefaultToast does), where useContext can't reach\n // this owner's ToastAriaContext.\n createEffect(() => {\n if (!toastRef) return;\n\n const titleId = (toastAria.titleProps as Record<string, unknown>).id as string | undefined;\n const descriptionId = (toastAria.descriptionProps as Record<string, unknown>).id as\n | string\n | undefined;\n const contentProps = toastAria.contentProps as Record<string, unknown>;\n\n if (titleId) {\n const titleEl = toastRef.querySelector(\"[data-solidaria-toast-title]\");\n if (titleEl instanceof HTMLElement) {\n titleEl.id = titleId;\n }\n }\n\n if (descriptionId) {\n const descriptionEl = toastRef.querySelector(\"[data-solidaria-toast-description]\");\n if (descriptionEl instanceof HTMLElement) {\n descriptionEl.id = descriptionId;\n }\n }\n\n // Wire the content area as a live region (role=\"alert\" / aria-live=\"assertive\")\n // so the toast message is announced to screen readers when it appears.\n const contentEl = toastRef.querySelector(\"[data-solidaria-toast-content]\");\n if (contentEl instanceof HTMLElement) {\n const role = contentProps.role as string | undefined;\n const ariaLive = contentProps[\"aria-live\"] as string | undefined;\n const ariaAtomic = contentProps[\"aria-atomic\"] as string | undefined;\n if (role) contentEl.setAttribute(\"role\", role);\n if (ariaLive) contentEl.setAttribute(\"aria-live\", ariaLive);\n if (ariaAtomic) contentEl.setAttribute(\"aria-atomic\", ariaAtomic);\n }\n });\n\n return (\n <ToastAriaContext.Provider\n value={{\n titleProps: toastAria.titleProps,\n descriptionProps: toastAria.descriptionProps,\n contentProps: toastAria.contentProps,\n }}\n >\n <div\n ref={toastRef}\n {...domProps()}\n {...cleanToastProps}\n class={renderProps.class()}\n style={mergedStyle()}\n data-animation={local.toast.animation}\n data-type={local.toast.content.type ?? local.toast.content.variant}\n data-variant={local.toast.content.variant}\n on:click={handleRootClick}\n >\n {renderProps.renderChildren()}\n </div>\n </ToastAriaContext.Provider>\n );\n}\n\nexport interface ToastTitleProps {\n children: JSX.Element;\n class?: string;\n style?: JSX.CSSProperties;\n}\n\n/**\n * ToastTitle renders the toast title with proper accessibility attributes.\n */\nexport function ToastTitle(props: ToastTitleProps): JSX.Element {\n const context = useContext(ToastAriaContext);\n const { ref: _ref, ...ariaTitleProps } = (context?.titleProps ?? {}) as Record<string, unknown>;\n\n // Upstream S2 Toast renders the title via `<Text slot=\"title\">`, and RAC `Text`\n // defaults to `elementType=\"span\"` — so the title's text-node container is a\n // `<span>`, not a `<div>`. Mirror that (the D7 contrast descriptor keys on the\n // container tag name; a `<div>` here diverged on every variant × theme). (parity rule #1/#2)\n return (\n <span data-solidaria-toast-title=\"\" {...ariaTitleProps} class={props.class} style={props.style}>\n {props.children}\n </span>\n );\n}\n\nexport interface ToastDescriptionProps {\n children: JSX.Element;\n class?: string;\n style?: JSX.CSSProperties;\n}\n\n/**\n * ToastDescription renders the toast description with proper accessibility attributes.\n */\nexport function ToastDescription(props: ToastDescriptionProps): JSX.Element {\n const context = useContext(ToastAriaContext);\n const { ref: _ref, ...ariaDescriptionProps } = (context?.descriptionProps ?? {}) as Record<\n string,\n unknown\n >;\n\n // Match the title: upstream toast text is rendered in `<span>` elements (RAC\n // `Text`). The port additionally supports a description (upstream S2 has only a\n // title); keep it as a `<span>` sibling so its text-node container tag is faithful.\n return (\n <span\n data-solidaria-toast-description=\"\"\n {...ariaDescriptionProps}\n class={props.class}\n style={props.style}\n >\n {props.children}\n </span>\n );\n}\n\nexport interface ToastContentProps {\n children: JSX.Element;\n class?: string;\n style?: JSX.CSSProperties;\n}\n\n/**\n * ToastContent wraps the toast message (title + description) in the live region\n * announced to screen readers. It carries `role=\"alert\"` / `aria-live=\"assertive\"`\n * from createToast's contentProps so the toast text is announced when it appears.\n *\n * It is rendered as a sibling of the close button (never wrapping it) so screen\n * readers announce the message without reading the close button first.\n */\nexport function ToastContent(props: ToastContentProps): JSX.Element {\n const context = useContext(ToastAriaContext);\n const { ref: _ref, ...ariaContentProps } = (context?.contentProps ?? {}) as Record<\n string,\n unknown\n >;\n\n return (\n <div\n data-solidaria-toast-content=\"\"\n {...ariaContentProps}\n class={props.class}\n style={props.style}\n >\n {props.children}\n </div>\n );\n}\n\nexport interface ToastCloseButtonProps {\n /** The toast to close. */\n toast: QueuedToast<ToastContent>;\n children?: JSX.Element;\n class?: string;\n style?: JSX.CSSProperties;\n \"aria-label\"?: string;\n}\n\n/**\n * ToastCloseButton is a button that closes the toast.\n */\nexport function ToastCloseButton(props: ToastCloseButtonProps): JSX.Element {\n const contextState = useContext(ToastContext);\n const handleClose = () => {\n const key = props.toast.key;\n const state = contextState ?? toastStateByKey.get(key);\n state?.close(key);\n state?.remove(key);\n };\n\n return (\n <button\n type=\"button\"\n class={props.class}\n style={props.style}\n aria-label={props[\"aria-label\"] ?? \"Close\"}\n data-solidaria-toast-close-button=\"\"\n on:click={handleClose}\n onClick={handleClose}\n >\n {props.children ?? \"×\"}\n </button>\n );\n}\n\nexport interface DefaultToastProps {\n toast: QueuedToast<ToastContent>;\n}\n\n/**\n * DefaultToast provides a basic toast layout with title, description, and close button.\n * Use this as a starting point or as-is for simple toast needs.\n */\nexport function DefaultToast(props: DefaultToastProps): JSX.Element {\n const content = () => props.toast.content;\n const title = () => content().children ?? content().title;\n const actionLabel = () => content().actionLabel ?? content().action?.label;\n const actionHandler = () => content().onAction ?? content().action?.onAction;\n const state = useToastContext();\n const handleAction = () => {\n actionHandler()?.();\n if (content().shouldCloseOnAction) {\n state.close(props.toast.key);\n state.remove(props.toast.key);\n }\n };\n\n return (\n <Toast toast={props.toast}>\n <div style={{ display: \"flex\", \"align-items\": \"flex-start\", gap: \"12px\" }}>\n <ToastContent style={{ flex: 1 }}>\n <Show when={title()}>\n <ToastTitle style={{ \"font-weight\": \"bold\", \"margin-bottom\": \"4px\" }}>\n {title()}\n </ToastTitle>\n </Show>\n <Show when={content().description}>\n <ToastDescription>{content().description}</ToastDescription>\n </Show>\n <Show when={actionLabel()}>\n <button type=\"button\" style={{ \"margin-top\": \"8px\" }} onClick={handleAction}>\n {actionLabel()}\n </button>\n </Show>\n </ToastContent>\n <ToastCloseButton toast={props.toast} />\n </div>\n </Toast>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAgIA,MAAaqD,eAAenD,cAA+C,IAAI;AAQ/E,MAAM0D,mBAAmB1D,cAA4C,IAAI;AACzE,MAAM2D,kCAAkB,IAAIC,IAAsC;AAElE,SAAgBC,kBAA4C;CAC1D,MAAMC,UAAUvD,WAAW4C,YAAY;CACvC,IAAI,CAACW,SACH,MAAM,IAAIC,MAAM,sDAAsD;CAExE,OAAOD;AACT;;AAGA,MAAaE,mBAAmB,IAAInD,WAAyB;CAC3DoD,kBAAkBC;CAClBC,kBAAkB;AACpB,CAAC;;;;;AAMD,SAAgBC,SAASC,SA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WAAA;QAAA,OAAAuD,gBAC9BoH,kBAAgB,EAAA,IAAA3K,WAAA;SAAA,OAAE0C,QAAQ,CAAC,CAACxC;QAAW,EAAA,CAAA;OAAA;MAAA,CAAA;MAAAqD,gBAEzC5E,MAAI;OAAA,IAAC4I,OAAI;QAAA,OAAElH,YAAY;OAAC;OAAA,IAAAL,WAAA;QAAA,IAAAoN,QAAAtG,eAAAuG,OAAA;QAAAD,MAAA5B,UACwCe;QAAYnF,OAAAgG,OACxE/M,WAAW;QAAAiH,mBAAA;QAAA,OAAA8F;OAAA;MAAA,CAAA;KAAA;IAAA;GAAA,CAAA,GAAAR,OAAAC,IAAA;GAAAzF,OAAAoF,OAAAjJ,gBAIjB6H,kBAAgB,EAAA,IAACtK,QAAK;IAAA,OAAEuC,MAAMvC;GAAK,EAAA,CAAA,GAAAmM,QAAAC,KAAA;GAAA,OAAAV;EAAA;CAAA,CAAA;AAI5C;AAACc,eAAA,CAAA,OAAA,CAAA"}
|
package/dist/Toast.jsx
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import { filterDOMProps, useIsHydrated, useRenderProps } from "./utils.jsx";
|
|
2
|
+
import { Show, createContext, createEffect, createMemo, createSignal, onCleanup, splitProps, useContext } from "solid-js";
|
|
3
|
+
import { Portal } from "solid-js/web";
|
|
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
|
+
const ToastContext = createContext(null);
|
|
14
|
+
const ToastAriaContext = createContext(null);
|
|
15
|
+
const toastStateByKey = /* @__PURE__ */ new Map();
|
|
16
|
+
function useToastContext() {
|
|
17
|
+
const context = useContext(ToastContext);
|
|
18
|
+
if (!context) throw new Error("Toast components must be used within a ToastProvider");
|
|
19
|
+
return context;
|
|
20
|
+
}
|
|
21
|
+
/** Default global toast queue that can be used for app-wide toasts. */
|
|
22
|
+
const globalToastQueue = new ToastQueue({
|
|
23
|
+
maxVisibleToasts: Infinity,
|
|
24
|
+
hasExitAnimation: true
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* Add a toast to the global queue.
|
|
28
|
+
* Convenience function for adding toasts from anywhere in the app.
|
|
29
|
+
*/
|
|
30
|
+
function addToast(content, options) {
|
|
31
|
+
return globalToastQueue.add(content, options);
|
|
32
|
+
}
|
|
33
|
+
function normalizeToastPlacement(placement) {
|
|
34
|
+
return (placement ?? "bottom").replace("-", " ");
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* ToastProvider creates a toast queue context for descendant components.
|
|
38
|
+
* Use this to wrap your app or a section that needs toast notifications.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* <ToastProvider>
|
|
43
|
+
* <App />
|
|
44
|
+
* <ToastRegion />
|
|
45
|
+
* </ToastProvider>
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
function ToastProvider(props) {
|
|
49
|
+
const state = createToastState({ queue: props.useGlobalQueue ? globalToastQueue : new ToastQueue(props.queueOptions) });
|
|
50
|
+
return <ToastContext.Provider value={state}>{props.children}</ToastContext.Provider>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* ToastRegion is a container that displays all visible toasts.
|
|
54
|
+
* It handles pause on hover/focus and provides the landmark region.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```tsx
|
|
58
|
+
* <ToastRegion placement="bottom-end">
|
|
59
|
+
* {(renderProps) => (
|
|
60
|
+
* <For each={renderProps.visibleToasts}>
|
|
61
|
+
* {(toast) => <Toast toast={toast} />}
|
|
62
|
+
* </For>
|
|
63
|
+
* )}
|
|
64
|
+
* </ToastRegion>
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
function ToastRegion(props) {
|
|
68
|
+
const isHydrated = useIsHydrated();
|
|
69
|
+
const [local, rest] = splitProps(props, [
|
|
70
|
+
"children",
|
|
71
|
+
"class",
|
|
72
|
+
"style",
|
|
73
|
+
"state",
|
|
74
|
+
"aria-label",
|
|
75
|
+
"portal",
|
|
76
|
+
"placement"
|
|
77
|
+
]);
|
|
78
|
+
const portalContext = useUNSAFE_PortalContext();
|
|
79
|
+
const portalContainer = () => portalContext.getContainer?.() ?? void 0;
|
|
80
|
+
const [regionElement, setRegionElement] = createSignal();
|
|
81
|
+
const contextState = useContext(ToastContext);
|
|
82
|
+
const state = () => local.state ?? contextState;
|
|
83
|
+
const regionAria = createToastRegion({
|
|
84
|
+
state: {
|
|
85
|
+
visibleToasts: () => state()?.visibleToasts() ?? [],
|
|
86
|
+
add: (content, options) => state()?.add(content, options) ?? "",
|
|
87
|
+
close: (key) => state()?.close(key),
|
|
88
|
+
remove: (key) => state()?.remove(key),
|
|
89
|
+
clear: () => state()?.clear(),
|
|
90
|
+
pauseAll: () => state()?.pauseAll(),
|
|
91
|
+
resumeAll: () => state()?.resumeAll()
|
|
92
|
+
},
|
|
93
|
+
ref: regionElement,
|
|
94
|
+
get "aria-label"() {
|
|
95
|
+
return local["aria-label"];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
const renderValues = createMemo(() => ({ visibleToasts: () => state()?.visibleToasts() ?? [] }));
|
|
99
|
+
const renderProps = useRenderProps({
|
|
100
|
+
get children() {
|
|
101
|
+
return props.children;
|
|
102
|
+
},
|
|
103
|
+
class: local.class,
|
|
104
|
+
style: local.style,
|
|
105
|
+
defaultClassName: "solidaria-ToastRegion"
|
|
106
|
+
}, renderValues);
|
|
107
|
+
const domProps = createMemo(() => filterDOMProps(rest, { global: true }));
|
|
108
|
+
const placementStyles = createMemo(() => {
|
|
109
|
+
const [edge, align = "center"] = normalizeToastPlacement(local.placement).split(" ");
|
|
110
|
+
const base = {
|
|
111
|
+
position: "fixed",
|
|
112
|
+
"z-index": 100001,
|
|
113
|
+
display: "flex",
|
|
114
|
+
"flex-direction": edge === "top" ? "column" : "column-reverse",
|
|
115
|
+
gap: "8px",
|
|
116
|
+
padding: "16px",
|
|
117
|
+
"pointer-events": "none"
|
|
118
|
+
};
|
|
119
|
+
if (edge === "top") {
|
|
120
|
+
if (align === "end") return {
|
|
121
|
+
...base,
|
|
122
|
+
top: "16px",
|
|
123
|
+
right: "16px"
|
|
124
|
+
};
|
|
125
|
+
if (align === "start") return {
|
|
126
|
+
...base,
|
|
127
|
+
top: "16px",
|
|
128
|
+
left: "16px"
|
|
129
|
+
};
|
|
130
|
+
return {
|
|
131
|
+
...base,
|
|
132
|
+
top: "16px",
|
|
133
|
+
left: "50%",
|
|
134
|
+
transform: "translateX(-50%)"
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
if (align === "end") return {
|
|
138
|
+
...base,
|
|
139
|
+
bottom: "16px",
|
|
140
|
+
right: "16px"
|
|
141
|
+
};
|
|
142
|
+
if (align === "start") return {
|
|
143
|
+
...base,
|
|
144
|
+
bottom: "16px",
|
|
145
|
+
left: "16px"
|
|
146
|
+
};
|
|
147
|
+
return {
|
|
148
|
+
...base,
|
|
149
|
+
bottom: "16px",
|
|
150
|
+
left: "50%",
|
|
151
|
+
transform: "translateX(-50%)"
|
|
152
|
+
};
|
|
153
|
+
});
|
|
154
|
+
const normalizedPlacement = () => normalizeToastPlacement(local.placement);
|
|
155
|
+
const visibleToasts = () => state()?.visibleToasts() ?? [];
|
|
156
|
+
const hasToasts = () => visibleToasts().length > 0;
|
|
157
|
+
const hasAuthoredRegionStyle = () => local.class != null || local.style != null;
|
|
158
|
+
const regionContent = () => {
|
|
159
|
+
if (!state()) return null;
|
|
160
|
+
const mergedStyle = () => {
|
|
161
|
+
const custom = renderProps.style();
|
|
162
|
+
if (hasAuthoredRegionStyle()) return custom;
|
|
163
|
+
const placement = placementStyles();
|
|
164
|
+
if (!custom) return placement;
|
|
165
|
+
return {
|
|
166
|
+
...placement,
|
|
167
|
+
...custom
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
const { ref: _ref, ...cleanRegionProps } = regionAria.regionProps;
|
|
171
|
+
return <div ref={setRegionElement} {...domProps()} {...cleanRegionProps} class={renderProps.class()} style={mergedStyle()} data-placement={normalizedPlacement()}>
|
|
172
|
+
{renderProps.renderChildren()}
|
|
173
|
+
</div>;
|
|
174
|
+
};
|
|
175
|
+
return <Show when={isHydrated() && hasToasts()}>
|
|
176
|
+
<Show when={local.portal !== false} fallback={regionContent()}>
|
|
177
|
+
<Portal mount={portalContainer()}>{regionContent()}</Portal>
|
|
178
|
+
</Show>
|
|
179
|
+
</Show>;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Toast is an individual notification component.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```tsx
|
|
186
|
+
* <Toast toast={toast}>
|
|
187
|
+
* {(renderProps) => (
|
|
188
|
+
* <div class={renderProps.isExiting ? 'fade-out' : 'fade-in'}>
|
|
189
|
+
* <h3>{renderProps.toast.content.title}</h3>
|
|
190
|
+
* <p>{renderProps.toast.content.description}</p>
|
|
191
|
+
* </div>
|
|
192
|
+
* )}
|
|
193
|
+
* </Toast>
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
function Toast(props) {
|
|
197
|
+
const [local, rest] = splitProps(props, [
|
|
198
|
+
"toast",
|
|
199
|
+
"children",
|
|
200
|
+
"class",
|
|
201
|
+
"style"
|
|
202
|
+
]);
|
|
203
|
+
let toastRef;
|
|
204
|
+
const state = useToastContext();
|
|
205
|
+
createEffect(() => {
|
|
206
|
+
const key = local.toast.key;
|
|
207
|
+
toastStateByKey.set(key, state);
|
|
208
|
+
onCleanup(() => {
|
|
209
|
+
if (toastStateByKey.get(key) === state) toastStateByKey.delete(key);
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
const hasTitle = () => !!(local.toast.content.children ?? local.toast.content.title);
|
|
213
|
+
const toastAria = createToast({
|
|
214
|
+
toast: local.toast,
|
|
215
|
+
state,
|
|
216
|
+
hasTitle: hasTitle(),
|
|
217
|
+
hasDescription: !!local.toast.content.description
|
|
218
|
+
});
|
|
219
|
+
const renderValues = createMemo(() => ({
|
|
220
|
+
isEntering: local.toast.animation === "entering",
|
|
221
|
+
isExiting: local.toast.animation === "exiting",
|
|
222
|
+
animation: local.toast.animation,
|
|
223
|
+
toast: local.toast
|
|
224
|
+
}));
|
|
225
|
+
const renderProps = useRenderProps({
|
|
226
|
+
get children() {
|
|
227
|
+
return props.children;
|
|
228
|
+
},
|
|
229
|
+
class: local.class,
|
|
230
|
+
style: local.style,
|
|
231
|
+
defaultClassName: "solidaria-Toast"
|
|
232
|
+
}, renderValues);
|
|
233
|
+
const domProps = createMemo(() => filterDOMProps(rest, { global: true }));
|
|
234
|
+
const mergedStyle = () => {
|
|
235
|
+
const custom = renderProps.style();
|
|
236
|
+
if (!custom) return { "pointer-events": "auto" };
|
|
237
|
+
return {
|
|
238
|
+
"pointer-events": "auto",
|
|
239
|
+
...custom
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
const handleRootClick = (event) => {
|
|
243
|
+
const target = event.target;
|
|
244
|
+
if (!(target instanceof Element)) return;
|
|
245
|
+
if (target.closest("[data-solidaria-toast-close-button]")) {
|
|
246
|
+
state.close(local.toast.key);
|
|
247
|
+
state.remove(local.toast.key);
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
createEffect(() => {
|
|
251
|
+
if (local.toast.animation !== "exiting") return;
|
|
252
|
+
state.remove(local.toast.key);
|
|
253
|
+
});
|
|
254
|
+
const { ref: _ref, ...cleanToastProps } = toastAria.toastProps;
|
|
255
|
+
createEffect(() => {});
|
|
256
|
+
return <ToastAriaContext.Provider value={{
|
|
257
|
+
titleProps: toastAria.titleProps,
|
|
258
|
+
descriptionProps: toastAria.descriptionProps,
|
|
259
|
+
contentProps: toastAria.contentProps
|
|
260
|
+
}}>
|
|
261
|
+
<div ref={toastRef} {...domProps()} {...cleanToastProps} class={renderProps.class()} style={mergedStyle()} data-animation={local.toast.animation} data-type={local.toast.content.type ?? local.toast.content.variant} data-variant={local.toast.content.variant} on:click={handleRootClick}>
|
|
262
|
+
{renderProps.renderChildren()}
|
|
263
|
+
</div>
|
|
264
|
+
</ToastAriaContext.Provider>;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* ToastTitle renders the toast title with proper accessibility attributes.
|
|
268
|
+
*/
|
|
269
|
+
function ToastTitle(props) {
|
|
270
|
+
const { ref: _ref, ...ariaTitleProps } = useContext(ToastAriaContext)?.titleProps ?? {};
|
|
271
|
+
return <span data-solidaria-toast-title="" {...ariaTitleProps} class={props.class} style={props.style}>
|
|
272
|
+
{props.children}
|
|
273
|
+
</span>;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* ToastDescription renders the toast description with proper accessibility attributes.
|
|
277
|
+
*/
|
|
278
|
+
function ToastDescription(props) {
|
|
279
|
+
const { ref: _ref, ...ariaDescriptionProps } = useContext(ToastAriaContext)?.descriptionProps ?? {};
|
|
280
|
+
return <span data-solidaria-toast-description="" {...ariaDescriptionProps} class={props.class} style={props.style}>
|
|
281
|
+
{props.children}
|
|
282
|
+
</span>;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* ToastContent wraps the toast message (title + description) in the live region
|
|
286
|
+
* announced to screen readers. It carries `role="alert"` / `aria-live="assertive"`
|
|
287
|
+
* from createToast's contentProps so the toast text is announced when it appears.
|
|
288
|
+
*
|
|
289
|
+
* It is rendered as a sibling of the close button (never wrapping it) so screen
|
|
290
|
+
* readers announce the message without reading the close button first.
|
|
291
|
+
*/
|
|
292
|
+
function ToastContent(props) {
|
|
293
|
+
const { ref: _ref, ...ariaContentProps } = useContext(ToastAriaContext)?.contentProps ?? {};
|
|
294
|
+
return <div data-solidaria-toast-content="" {...ariaContentProps} class={props.class} style={props.style}>
|
|
295
|
+
{props.children}
|
|
296
|
+
</div>;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* ToastCloseButton is a button that closes the toast.
|
|
300
|
+
*/
|
|
301
|
+
function ToastCloseButton(props) {
|
|
302
|
+
const contextState = useContext(ToastContext);
|
|
303
|
+
const handleClose = () => {
|
|
304
|
+
const key = props.toast.key;
|
|
305
|
+
const state = contextState ?? toastStateByKey.get(key);
|
|
306
|
+
state?.close(key);
|
|
307
|
+
state?.remove(key);
|
|
308
|
+
};
|
|
309
|
+
return <button type="button" class={props.class} style={props.style} aria-label={props["aria-label"] ?? "Close"} data-solidaria-toast-close-button="" on:click={handleClose} onClick={handleClose}>
|
|
310
|
+
{props.children ?? "×"}
|
|
311
|
+
</button>;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* DefaultToast provides a basic toast layout with title, description, and close button.
|
|
315
|
+
* Use this as a starting point or as-is for simple toast needs.
|
|
316
|
+
*/
|
|
317
|
+
function DefaultToast(props) {
|
|
318
|
+
const content = () => props.toast.content;
|
|
319
|
+
const title = () => content().children ?? content().title;
|
|
320
|
+
const actionLabel = () => content().actionLabel ?? content().action?.label;
|
|
321
|
+
const actionHandler = () => content().onAction ?? content().action?.onAction;
|
|
322
|
+
const state = useToastContext();
|
|
323
|
+
const handleAction = () => {
|
|
324
|
+
actionHandler()?.();
|
|
325
|
+
if (content().shouldCloseOnAction) {
|
|
326
|
+
state.close(props.toast.key);
|
|
327
|
+
state.remove(props.toast.key);
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
return <Toast toast={props.toast}>
|
|
331
|
+
<div style={{
|
|
332
|
+
display: "flex",
|
|
333
|
+
"align-items": "flex-start",
|
|
334
|
+
gap: "12px"
|
|
335
|
+
}}>
|
|
336
|
+
<ToastContent style={{ flex: 1 }}>
|
|
337
|
+
<Show when={title()}>
|
|
338
|
+
<ToastTitle style={{
|
|
339
|
+
"font-weight": "bold",
|
|
340
|
+
"margin-bottom": "4px"
|
|
341
|
+
}}>
|
|
342
|
+
{title()}
|
|
343
|
+
</ToastTitle>
|
|
344
|
+
</Show>
|
|
345
|
+
<Show when={content().description}>
|
|
346
|
+
<ToastDescription>{content().description}</ToastDescription>
|
|
347
|
+
</Show>
|
|
348
|
+
<Show when={actionLabel()}>
|
|
349
|
+
<button type="button" style={{ "margin-top": "8px" }} onClick={handleAction}>
|
|
350
|
+
{actionLabel()}
|
|
351
|
+
</button>
|
|
352
|
+
</Show>
|
|
353
|
+
</ToastContent>
|
|
354
|
+
<ToastCloseButton toast={props.toast} />
|
|
355
|
+
</div>
|
|
356
|
+
</Toast>;
|
|
357
|
+
}
|
|
358
|
+
//#endregion
|
|
359
|
+
export { DefaultToast, Toast, ToastCloseButton, ToastContent, ToastContext, ToastDescription, ToastProvider, ToastRegion, ToastTitle, addToast, globalToastQueue, useToastContext };
|
|
360
|
+
|
|
361
|
+
//# sourceMappingURL=Toast.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.jsx","names":[],"sources":["../src/Toast.tsx"],"sourcesContent":["/**\n * Toast components for solidaria-components\n *\n * Toast notifications with auto-dismiss, pause on hover/focus, and accessibility.\n * Port of react-aria-components Toast.\n */\n\nimport {\n type JSX,\n type Accessor,\n createContext,\n createMemo,\n createEffect,\n createSignal,\n onCleanup,\n splitProps,\n Show,\n useContext,\n} from \"solid-js\";\nimport { Portal } from \"solid-js/web\";\nimport {\n type ToastState,\n type QueuedToast,\n type ToastQueueOptions,\n type ToastOptions,\n ToastQueue,\n createToastState,\n} from \"@proyecto-viviana/solid-stately\";\nimport {\n createToast,\n createToastRegion,\n useUNSAFE_PortalContext,\n} from \"@proyecto-viviana/solidaria\";\nimport {\n type RenderChildren,\n type ClassNameOrFunction,\n type StyleOrFunction,\n useRenderProps,\n filterDOMProps,\n useIsHydrated,\n} from \"./utils\";\n\nexport interface ToastContent {\n /** DOM id for the toast root when content is queued through Spectrum ToastQueue. */\n id?: string;\n /** Data attributes for the toast root when content is queued through Spectrum ToastQueue. */\n [dataAttribute: `data-${string}`]: string | number | boolean | undefined;\n /** Spectrum Toast message content. */\n children?: string;\n /** The title of the toast. */\n title?: string;\n /** The description/body of the toast. */\n description?: string;\n /** Spectrum variant. */\n variant?: \"info\" | \"positive\" | \"negative\" | \"neutral\";\n /** Backward-compatible type/variant of the toast. */\n type?: \"info\" | \"success\" | \"warning\" | \"error\" | \"positive\" | \"negative\" | \"neutral\";\n /** Spectrum action button label. */\n actionLabel?: string;\n /** Handler called when the Spectrum action button is pressed. */\n onAction?: () => void;\n /** Whether the toast should close when the Spectrum action is performed. */\n shouldCloseOnAction?: boolean;\n /** Custom action button. */\n action?: {\n label: string;\n onAction: () => void;\n };\n}\n\nexport interface ToastRenderProps {\n /** Whether the toast is currently animating in. */\n isEntering: boolean;\n /** Whether the toast is currently animating out. */\n isExiting: boolean;\n /** The animation state (entering, exiting, queued). */\n animation: \"entering\" | \"exiting\" | \"queued\" | undefined;\n /** The toast data. */\n toast: QueuedToast<ToastContent>;\n}\n\nexport interface ToastRegionRenderProps {\n /** The visible toasts. */\n visibleToasts: Accessor<QueuedToast<ToastContent>[]>;\n}\n\nexport interface ToastRegionProps {\n /** The children of the component - can be JSX or render function. */\n children?: RenderChildren<ToastRegionRenderProps>;\n /** The CSS className for the element. */\n class?: ClassNameOrFunction<ToastRegionRenderProps>;\n /** The inline style for the element. */\n style?: StyleOrFunction<ToastRegionRenderProps>;\n /** The toast state to display. If not provided, uses ToastContext. */\n state?: ToastState<ToastContent>;\n /** Accessible label for the region. */\n \"aria-label\"?: string;\n /** Whether to render in a portal. */\n portal?: boolean;\n /** Placement of the toast region. */\n placement?:\n | \"top\"\n | \"top start\"\n | \"top end\"\n | \"top-start\"\n | \"top-end\"\n | \"bottom\"\n | \"bottom start\"\n | \"bottom end\"\n | \"bottom-start\"\n | \"bottom-end\";\n}\n\nexport interface ToastProps {\n /** DOM id for the toast root. */\n id?: string;\n /** Data attributes for the toast root. */\n [dataAttribute: `data-${string}`]: string | number | boolean | undefined;\n /** The toast data. */\n toast: QueuedToast<ToastContent>;\n /** The children of the component - can be JSX or render function. */\n children?: RenderChildren<ToastRenderProps>;\n /** The CSS className for the element. */\n class?: ClassNameOrFunction<ToastRenderProps>;\n /** The inline style for the element. */\n style?: StyleOrFunction<ToastRenderProps>;\n}\n\nexport const ToastContext = createContext<ToastState<ToastContent> | null>(null);\n\ninterface ToastAriaContextValue {\n titleProps: JSX.HTMLAttributes<HTMLElement>;\n descriptionProps: JSX.HTMLAttributes<HTMLElement>;\n contentProps: JSX.HTMLAttributes<HTMLElement>;\n}\n\nconst ToastAriaContext = createContext<ToastAriaContextValue | null>(null);\nconst toastStateByKey = new Map<string, ToastState<ToastContent>>();\n\nexport function useToastContext(): ToastState<ToastContent> {\n const context = useContext(ToastContext);\n if (!context) {\n throw new Error(\"Toast components must be used within a ToastProvider\");\n }\n return context;\n}\n\n/** Default global toast queue that can be used for app-wide toasts. */\nexport const globalToastQueue = new ToastQueue<ToastContent>({\n maxVisibleToasts: Infinity,\n hasExitAnimation: true,\n});\n\n/**\n * Add a toast to the global queue.\n * Convenience function for adding toasts from anywhere in the app.\n */\nexport function addToast(content: ToastContent, options?: ToastOptions): string {\n return globalToastQueue.add(content, options);\n}\n\nfunction normalizeToastPlacement(placement?: ToastRegionProps[\"placement\"]) {\n return (placement ?? \"bottom\").replace(\"-\", \" \") as NonNullable<ToastRegionProps[\"placement\"]>;\n}\n\nexport interface ToastProviderProps {\n /** The children of the provider. */\n children: JSX.Element;\n /** Custom toast queue options. */\n queueOptions?: ToastQueueOptions;\n /** Use global queue instead of creating a new one. */\n useGlobalQueue?: boolean;\n}\n\n/**\n * ToastProvider creates a toast queue context for descendant components.\n * Use this to wrap your app or a section that needs toast notifications.\n *\n * @example\n * ```tsx\n * <ToastProvider>\n * <App />\n * <ToastRegion />\n * </ToastProvider>\n * ```\n */\nexport function ToastProvider(props: ToastProviderProps): JSX.Element {\n const queue = props.useGlobalQueue\n ? globalToastQueue\n : new ToastQueue<ToastContent>(props.queueOptions);\n\n const state = createToastState({ queue });\n\n return <ToastContext.Provider value={state}>{props.children}</ToastContext.Provider>;\n}\n\n/**\n * ToastRegion is a container that displays all visible toasts.\n * It handles pause on hover/focus and provides the landmark region.\n *\n * @example\n * ```tsx\n * <ToastRegion placement=\"bottom-end\">\n * {(renderProps) => (\n * <For each={renderProps.visibleToasts}>\n * {(toast) => <Toast toast={toast} />}\n * </For>\n * )}\n * </ToastRegion>\n * ```\n */\nexport function ToastRegion(props: ToastRegionProps): JSX.Element {\n // Do NOT early-return on the server: returning null on the server and a <Show>\n // on the client desyncs hydration when the region is in the SSR tree. Render the\n // same structure on both and gate the Portal on useIsHydrated() (see Popover).\n const isHydrated = useIsHydrated();\n\n const [local, rest] = splitProps(props, [\n \"children\",\n \"class\",\n \"style\",\n \"state\",\n \"aria-label\",\n \"portal\",\n \"placement\",\n ]);\n const portalContext = useUNSAFE_PortalContext();\n const portalContainer = () => portalContext.getContainer?.() ?? undefined;\n const [regionElement, setRegionElement] = createSignal<HTMLElement>();\n\n const contextState = useContext(ToastContext);\n const state = () => local.state ?? contextState;\n\n const regionAria = createToastRegion<ToastContent>({\n state: {\n visibleToasts: () => state()?.visibleToasts() ?? [],\n add: (content, options) => state()?.add(content, options) ?? \"\",\n close: (key) => state()?.close(key),\n remove: (key) => state()?.remove(key),\n clear: () => state()?.clear(),\n pauseAll: () => state()?.pauseAll(),\n resumeAll: () => state()?.resumeAll(),\n },\n ref: regionElement,\n get \"aria-label\"() {\n return local[\"aria-label\"];\n },\n });\n\n const renderValues = createMemo<ToastRegionRenderProps>(() => ({\n visibleToasts: () => state()?.visibleToasts() ?? [],\n }));\n\n const renderProps = useRenderProps(\n {\n // Lazy: the region content is gated behind `<Show when={isHydrated() && …}>`\n // (Portal) below, so reading children must not instantiate templates during\n // the component body (would walk getNextElement before the gate the server\n // kept closed → hydration mismatch). See Popover for the full rationale.\n get children() {\n return props.children;\n },\n class: local.class,\n style: local.style,\n defaultClassName: \"solidaria-ToastRegion\",\n },\n renderValues,\n );\n const domProps = createMemo(() =>\n filterDOMProps(rest as Record<string, unknown>, { global: true }),\n );\n\n const placementStyles = createMemo<JSX.CSSProperties>(() => {\n const placement = normalizeToastPlacement(local.placement);\n const [edge, align = \"center\"] = placement.split(\" \");\n const base: JSX.CSSProperties = {\n position: \"fixed\",\n \"z-index\": 100001,\n display: \"flex\",\n \"flex-direction\": edge === \"top\" ? \"column\" : \"column-reverse\",\n gap: \"8px\",\n padding: \"16px\",\n \"pointer-events\": \"none\",\n };\n\n if (edge === \"top\") {\n if (align === \"end\") {\n return { ...base, top: \"16px\", right: \"16px\" } as JSX.CSSProperties;\n }\n if (align === \"start\") {\n return { ...base, top: \"16px\", left: \"16px\" } as JSX.CSSProperties;\n }\n return {\n ...base,\n top: \"16px\",\n left: \"50%\",\n transform: \"translateX(-50%)\",\n } as JSX.CSSProperties;\n }\n\n if (align === \"end\") {\n return { ...base, bottom: \"16px\", right: \"16px\" } as JSX.CSSProperties;\n }\n if (align === \"start\") {\n return { ...base, bottom: \"16px\", left: \"16px\" } as JSX.CSSProperties;\n }\n return {\n ...base,\n bottom: \"16px\",\n left: \"50%\",\n transform: \"translateX(-50%)\",\n } as JSX.CSSProperties;\n });\n\n const normalizedPlacement = () => normalizeToastPlacement(local.placement);\n\n const visibleToasts = () => state()?.visibleToasts() ?? [];\n const hasToasts = () => visibleToasts().length > 0;\n const hasAuthoredRegionStyle = () => local.class != null || local.style != null;\n\n const regionContent = () => {\n if (!state()) return null;\n\n const mergedStyle = () => {\n const custom = renderProps.style();\n // React Aria Components leaves ToastRegion unstyled. Keep this package's\n // fallback placement only for bare regions so styled layers such as S2 can\n // own fixed viewport geometry with their generated classes.\n if (hasAuthoredRegionStyle()) return custom;\n\n const placement = placementStyles();\n if (!custom) return placement;\n return { ...placement, ...custom } as JSX.CSSProperties;\n };\n\n const { ref: _ref, ...cleanRegionProps } = regionAria.regionProps as Record<string, unknown>;\n\n return (\n <div\n ref={setRegionElement}\n {...domProps()}\n {...cleanRegionProps}\n class={renderProps.class()}\n style={mergedStyle()}\n data-placement={normalizedPlacement()}\n >\n {renderProps.renderChildren()}\n </div>\n );\n };\n\n return (\n <Show when={isHydrated() && hasToasts()}>\n <Show when={local.portal !== false} fallback={regionContent()}>\n <Portal mount={portalContainer()}>{regionContent()}</Portal>\n </Show>\n </Show>\n );\n}\n\n/**\n * Toast is an individual notification component.\n *\n * @example\n * ```tsx\n * <Toast toast={toast}>\n * {(renderProps) => (\n * <div class={renderProps.isExiting ? 'fade-out' : 'fade-in'}>\n * <h3>{renderProps.toast.content.title}</h3>\n * <p>{renderProps.toast.content.description}</p>\n * </div>\n * )}\n * </Toast>\n * ```\n */\nexport function Toast(props: ToastProps): JSX.Element {\n const [local, rest] = splitProps(props, [\"toast\", \"children\", \"class\", \"style\"]);\n\n let toastRef!: HTMLDivElement;\n\n const state = useToastContext();\n\n createEffect(() => {\n const key = local.toast.key;\n toastStateByKey.set(key, state);\n onCleanup(() => {\n if (toastStateByKey.get(key) === state) {\n toastStateByKey.delete(key);\n }\n });\n });\n\n const hasTitle = () => !!(local.toast.content.children ?? local.toast.content.title);\n const toastAria = createToast({\n toast: local.toast,\n state,\n hasTitle: hasTitle(),\n hasDescription: !!local.toast.content.description,\n });\n\n const renderValues = createMemo<ToastRenderProps>(() => ({\n isEntering: local.toast.animation === \"entering\",\n isExiting: local.toast.animation === \"exiting\",\n animation: local.toast.animation,\n toast: local.toast,\n }));\n\n const renderProps = useRenderProps(\n {\n get children() {\n return props.children;\n },\n class: local.class,\n style: local.style,\n defaultClassName: \"solidaria-Toast\",\n },\n renderValues,\n );\n\n const domProps = createMemo(() =>\n filterDOMProps(rest as Record<string, unknown>, { global: true }),\n );\n\n const mergedStyle = () => {\n const custom = renderProps.style();\n if (!custom) return { \"pointer-events\": \"auto\" as const };\n return { \"pointer-events\": \"auto\" as const, ...custom } as JSX.CSSProperties;\n };\n\n const handleRootClick = (event: MouseEvent) => {\n const target = event.target;\n if (!(target instanceof Element)) return;\n if (target.closest(\"[data-solidaria-toast-close-button]\")) {\n state.close(local.toast.key);\n state.remove(local.toast.key);\n }\n };\n\n // Exit animation lifecycle:\n // When animation becomes 'exiting', wait for CSS animations/transitions to finish,\n // then call state.remove() to finalize removal from the queue.\n // In JSDOM or when no animations are running, remove immediately.\n // Reduced-motion is handled by CSS (shorter/no animations), so the lifecycle\n // naturally completes faster when the user prefers reduced motion.\n createEffect(() => {\n if (local.toast.animation !== \"exiting\") return;\n if (!toastRef) {\n state.remove(local.toast.key);\n return;\n }\n\n // Check if the element supports the Web Animations API\n if (!(\"getAnimations\" in toastRef)) {\n state.remove(local.toast.key);\n return;\n }\n\n const animations = toastRef.getAnimations();\n if (animations.length === 0) {\n // No CSS animations/transitions running - remove immediately\n state.remove(local.toast.key);\n return;\n }\n\n // Wait for all running animations to finish, then remove\n let canceled = false;\n Promise.all(animations.map((a) => a.finished))\n .then(() => {\n if (!canceled) {\n state.remove(local.toast.key);\n }\n })\n .catch(() => {\n // Animation was canceled (e.g. element removed) - still clean up\n if (!canceled) {\n state.remove(local.toast.key);\n }\n });\n\n onCleanup(() => {\n canceled = true;\n });\n });\n\n const { ref: _ref, ...cleanToastProps } = toastAria.toastProps as Record<string, unknown>;\n\n // Ensure ARIA title/description IDs and the content live-region attributes are\n // present on rendered sub-components, even when children are pre-composed outside\n // the Toast provider owner (as DefaultToast does), where useContext can't reach\n // this owner's ToastAriaContext.\n createEffect(() => {\n if (!toastRef) return;\n\n const titleId = (toastAria.titleProps as Record<string, unknown>).id as string | undefined;\n const descriptionId = (toastAria.descriptionProps as Record<string, unknown>).id as\n | string\n | undefined;\n const contentProps = toastAria.contentProps as Record<string, unknown>;\n\n if (titleId) {\n const titleEl = toastRef.querySelector(\"[data-solidaria-toast-title]\");\n if (titleEl instanceof HTMLElement) {\n titleEl.id = titleId;\n }\n }\n\n if (descriptionId) {\n const descriptionEl = toastRef.querySelector(\"[data-solidaria-toast-description]\");\n if (descriptionEl instanceof HTMLElement) {\n descriptionEl.id = descriptionId;\n }\n }\n\n // Wire the content area as a live region (role=\"alert\" / aria-live=\"assertive\")\n // so the toast message is announced to screen readers when it appears.\n const contentEl = toastRef.querySelector(\"[data-solidaria-toast-content]\");\n if (contentEl instanceof HTMLElement) {\n const role = contentProps.role as string | undefined;\n const ariaLive = contentProps[\"aria-live\"] as string | undefined;\n const ariaAtomic = contentProps[\"aria-atomic\"] as string | undefined;\n if (role) contentEl.setAttribute(\"role\", role);\n if (ariaLive) contentEl.setAttribute(\"aria-live\", ariaLive);\n if (ariaAtomic) contentEl.setAttribute(\"aria-atomic\", ariaAtomic);\n }\n });\n\n return (\n <ToastAriaContext.Provider\n value={{\n titleProps: toastAria.titleProps,\n descriptionProps: toastAria.descriptionProps,\n contentProps: toastAria.contentProps,\n }}\n >\n <div\n ref={toastRef}\n {...domProps()}\n {...cleanToastProps}\n class={renderProps.class()}\n style={mergedStyle()}\n data-animation={local.toast.animation}\n data-type={local.toast.content.type ?? local.toast.content.variant}\n data-variant={local.toast.content.variant}\n on:click={handleRootClick}\n >\n {renderProps.renderChildren()}\n </div>\n </ToastAriaContext.Provider>\n );\n}\n\nexport interface ToastTitleProps {\n children: JSX.Element;\n class?: string;\n style?: JSX.CSSProperties;\n}\n\n/**\n * ToastTitle renders the toast title with proper accessibility attributes.\n */\nexport function ToastTitle(props: ToastTitleProps): JSX.Element {\n const context = useContext(ToastAriaContext);\n const { ref: _ref, ...ariaTitleProps } = (context?.titleProps ?? {}) as Record<string, unknown>;\n\n // Upstream S2 Toast renders the title via `<Text slot=\"title\">`, and RAC `Text`\n // defaults to `elementType=\"span\"` — so the title's text-node container is a\n // `<span>`, not a `<div>`. Mirror that (the D7 contrast descriptor keys on the\n // container tag name; a `<div>` here diverged on every variant × theme). (parity rule #1/#2)\n return (\n <span data-solidaria-toast-title=\"\" {...ariaTitleProps} class={props.class} style={props.style}>\n {props.children}\n </span>\n );\n}\n\nexport interface ToastDescriptionProps {\n children: JSX.Element;\n class?: string;\n style?: JSX.CSSProperties;\n}\n\n/**\n * ToastDescription renders the toast description with proper accessibility attributes.\n */\nexport function ToastDescription(props: ToastDescriptionProps): JSX.Element {\n const context = useContext(ToastAriaContext);\n const { ref: _ref, ...ariaDescriptionProps } = (context?.descriptionProps ?? {}) as Record<\n string,\n unknown\n >;\n\n // Match the title: upstream toast text is rendered in `<span>` elements (RAC\n // `Text`). The port additionally supports a description (upstream S2 has only a\n // title); keep it as a `<span>` sibling so its text-node container tag is faithful.\n return (\n <span\n data-solidaria-toast-description=\"\"\n {...ariaDescriptionProps}\n class={props.class}\n style={props.style}\n >\n {props.children}\n </span>\n );\n}\n\nexport interface ToastContentProps {\n children: JSX.Element;\n class?: string;\n style?: JSX.CSSProperties;\n}\n\n/**\n * ToastContent wraps the toast message (title + description) in the live region\n * announced to screen readers. It carries `role=\"alert\"` / `aria-live=\"assertive\"`\n * from createToast's contentProps so the toast text is announced when it appears.\n *\n * It is rendered as a sibling of the close button (never wrapping it) so screen\n * readers announce the message without reading the close button first.\n */\nexport function ToastContent(props: ToastContentProps): JSX.Element {\n const context = useContext(ToastAriaContext);\n const { ref: _ref, ...ariaContentProps } = (context?.contentProps ?? {}) as Record<\n string,\n unknown\n >;\n\n return (\n <div\n data-solidaria-toast-content=\"\"\n {...ariaContentProps}\n class={props.class}\n style={props.style}\n >\n {props.children}\n </div>\n );\n}\n\nexport interface ToastCloseButtonProps {\n /** The toast to close. */\n toast: QueuedToast<ToastContent>;\n children?: JSX.Element;\n class?: string;\n style?: JSX.CSSProperties;\n \"aria-label\"?: string;\n}\n\n/**\n * ToastCloseButton is a button that closes the toast.\n */\nexport function ToastCloseButton(props: ToastCloseButtonProps): JSX.Element {\n const contextState = useContext(ToastContext);\n const handleClose = () => {\n const key = props.toast.key;\n const state = contextState ?? toastStateByKey.get(key);\n state?.close(key);\n state?.remove(key);\n };\n\n return (\n <button\n type=\"button\"\n class={props.class}\n style={props.style}\n aria-label={props[\"aria-label\"] ?? \"Close\"}\n data-solidaria-toast-close-button=\"\"\n on:click={handleClose}\n onClick={handleClose}\n >\n {props.children ?? \"×\"}\n </button>\n );\n}\n\nexport interface DefaultToastProps {\n toast: QueuedToast<ToastContent>;\n}\n\n/**\n * DefaultToast provides a basic toast layout with title, description, and close button.\n * Use this as a starting point or as-is for simple toast needs.\n */\nexport function DefaultToast(props: DefaultToastProps): JSX.Element {\n const content = () => props.toast.content;\n const title = () => content().children ?? content().title;\n const actionLabel = () => content().actionLabel ?? content().action?.label;\n const actionHandler = () => content().onAction ?? content().action?.onAction;\n const state = useToastContext();\n const handleAction = () => {\n actionHandler()?.();\n if (content().shouldCloseOnAction) {\n state.close(props.toast.key);\n state.remove(props.toast.key);\n }\n };\n\n return (\n <Toast toast={props.toast}>\n <div style={{ display: \"flex\", \"align-items\": \"flex-start\", gap: \"12px\" }}>\n <ToastContent style={{ flex: 1 }}>\n <Show when={title()}>\n <ToastTitle style={{ \"font-weight\": \"bold\", \"margin-bottom\": \"4px\" }}>\n {title()}\n </ToastTitle>\n </Show>\n <Show when={content().description}>\n <ToastDescription>{content().description}</ToastDescription>\n </Show>\n <Show when={actionLabel()}>\n <button type=\"button\" style={{ \"margin-top\": \"8px\" }} onClick={handleAction}>\n {actionLabel()}\n </button>\n </Show>\n </ToastContent>\n <ToastCloseButton toast={props.toast} />\n </div>\n </Toast>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAgIA,MAAa,eAAe,cAA+C,IAAI;AAQ/E,MAAM,mBAAmB,cAA4C,IAAI;AACzE,MAAM,kCAAkB,IAAI,IAAsC;AAElE,SAAgB,kBAA4C;CAC1D,MAAM,UAAU,WAAW,YAAY;CACvC,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,sDAAsD;CAExE,OAAO;AACT;;AAGA,MAAa,mBAAmB,IAAI,WAAyB;CAC3D,kBAAkB;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
import { getNextElement, insert, mergeProps, runHydrationEvents, spread, template, use } from "solid-js/web";
|
|
4
|
+
import { createContext, createMemo, splitProps, useContext } from "solid-js";
|
|
5
|
+
import { createFocusRing, createHover, createToggleButton, createToggleButtonGroupItem, mergeProps as mergeProps$2 } from "@proyecto-viviana/solidaria";
|
|
6
|
+
//#region src/ToggleButton.tsx
|
|
7
|
+
/**
|
|
8
|
+
* ToggleButton component for solidaria-components
|
|
9
|
+
*
|
|
10
|
+
* A pre-wired headless toggle button that combines pressed + selected state.
|
|
11
|
+
* Port direction: react-aria-components/src/ToggleButton.tsx
|
|
12
|
+
*/
|
|
13
|
+
var _tmpl$ = /*#__PURE__*/ template(`<button>`);
|
|
14
|
+
function assignRef(ref, el) {
|
|
15
|
+
if (!ref) return;
|
|
16
|
+
if (typeof ref === "function") ref(el);
|
|
17
|
+
else ref.current = el;
|
|
18
|
+
}
|
|
19
|
+
const ToggleButtonContext = createContext(null);
|
|
20
|
+
function resolveDisabledValue(isDisabled) {
|
|
21
|
+
if (typeof isDisabled === "function") return isDisabled();
|
|
22
|
+
return !!isDisabled;
|
|
23
|
+
}
|
|
24
|
+
function ToggleButton(props) {
|
|
25
|
+
const contextProps = useContext(ToggleButtonContext);
|
|
26
|
+
const [local, ariaProps] = splitProps(contextProps ? mergeProps$2(contextProps, props) : props, [
|
|
27
|
+
"children",
|
|
28
|
+
"class",
|
|
29
|
+
"style",
|
|
30
|
+
"ref",
|
|
31
|
+
"slot",
|
|
32
|
+
"toggleKey",
|
|
33
|
+
"id"
|
|
34
|
+
]);
|
|
35
|
+
const groupState = useToggleButtonGroupStateContext();
|
|
36
|
+
const groupKey = local.id ?? local.toggleKey;
|
|
37
|
+
const standaloneAriaProps = mergeProps$2(ariaProps, { get id() {
|
|
38
|
+
return local.id;
|
|
39
|
+
} });
|
|
40
|
+
const toggleAria = groupState && groupKey != null ? createToggleButtonGroupItem({
|
|
41
|
+
...ariaProps,
|
|
42
|
+
id: groupKey
|
|
43
|
+
}, groupState) : createToggleButton(standaloneAriaProps);
|
|
44
|
+
const isDisabled = () => resolveDisabledValue(ariaProps.isDisabled) || !!groupState?.isDisabled;
|
|
45
|
+
const { isFocused, isFocusVisible, focusProps } = createFocusRing();
|
|
46
|
+
const { isHovered, hoverProps } = createHover({ get isDisabled() {
|
|
47
|
+
return isDisabled();
|
|
48
|
+
} });
|
|
49
|
+
const renderValues = createMemo(() => ({
|
|
50
|
+
isHovered: isHovered(),
|
|
51
|
+
isPressed: toggleAria.isPressed(),
|
|
52
|
+
isFocused: isFocused(),
|
|
53
|
+
isFocusVisible: isFocusVisible(),
|
|
54
|
+
isDisabled: isDisabled(),
|
|
55
|
+
isSelected: toggleAria.isSelected()
|
|
56
|
+
}));
|
|
57
|
+
const renderProps = useRenderProps({
|
|
58
|
+
get children() {
|
|
59
|
+
return local.children;
|
|
60
|
+
},
|
|
61
|
+
class: local.class,
|
|
62
|
+
style: local.style,
|
|
63
|
+
defaultClassName: "solidaria-ToggleButton"
|
|
64
|
+
}, renderValues);
|
|
65
|
+
const domProps = createMemo(() => {
|
|
66
|
+
const filtered = filterDOMProps(ariaProps, { global: true });
|
|
67
|
+
delete filtered.onClick;
|
|
68
|
+
delete filtered.id;
|
|
69
|
+
return filtered;
|
|
70
|
+
});
|
|
71
|
+
const cleanButtonProps = () => {
|
|
72
|
+
const { ref: _ref1, ...rest } = toggleAria.buttonProps;
|
|
73
|
+
return rest;
|
|
74
|
+
};
|
|
75
|
+
const cleanFocusProps = () => {
|
|
76
|
+
const { ref: _ref2, ...rest } = focusProps;
|
|
77
|
+
return rest;
|
|
78
|
+
};
|
|
79
|
+
const cleanHoverProps = () => {
|
|
80
|
+
const { ref: _ref3, ...rest } = hoverProps;
|
|
81
|
+
return rest;
|
|
82
|
+
};
|
|
83
|
+
return (() => {
|
|
84
|
+
var _el$ = getNextElement(_tmpl$);
|
|
85
|
+
use((el) => assignRef(local.ref, el), _el$);
|
|
86
|
+
spread(_el$, mergeProps(domProps, cleanButtonProps, cleanFocusProps, cleanHoverProps, {
|
|
87
|
+
get ["class"]() {
|
|
88
|
+
return renderProps.class();
|
|
89
|
+
},
|
|
90
|
+
get style() {
|
|
91
|
+
return renderProps.style();
|
|
92
|
+
},
|
|
93
|
+
get slot() {
|
|
94
|
+
return local.slot;
|
|
95
|
+
},
|
|
96
|
+
get ["data-pressed"]() {
|
|
97
|
+
return toggleAria.isPressed() || void 0;
|
|
98
|
+
},
|
|
99
|
+
get ["data-hovered"]() {
|
|
100
|
+
return isHovered() || void 0;
|
|
101
|
+
},
|
|
102
|
+
get ["data-focused"]() {
|
|
103
|
+
return isFocused() || void 0;
|
|
104
|
+
},
|
|
105
|
+
get ["data-focus-visible"]() {
|
|
106
|
+
return isFocusVisible() || void 0;
|
|
107
|
+
},
|
|
108
|
+
get ["data-disabled"]() {
|
|
109
|
+
return isDisabled() || void 0;
|
|
110
|
+
},
|
|
111
|
+
get ["data-selected"]() {
|
|
112
|
+
return toggleAria.isSelected() || void 0;
|
|
113
|
+
}
|
|
114
|
+
}), false, true);
|
|
115
|
+
insert(_el$, () => renderProps.renderChildren());
|
|
116
|
+
runHydrationEvents();
|
|
117
|
+
return _el$;
|
|
118
|
+
})();
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
export { ToggleButton, ToggleButtonContext };
|
|
122
|
+
|
|
123
|
+
//# sourceMappingURL=ToggleButton.js.map
|