@proyecto-viviana/solidaria 0.3.0 → 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/_chunk/actiongroup.js +207 -0
- package/dist/_chunk/actiongroup.js.map +1 -0
- package/dist/_chunk/actiongroup.jsx +207 -0
- package/dist/_chunk/actiongroup.jsx.map +1 -0
- package/dist/_chunk/ariaHideOutside.js +122 -0
- package/dist/_chunk/ariaHideOutside.js.map +1 -0
- package/dist/_chunk/ariaHideOutside.jsx +122 -0
- package/dist/_chunk/ariaHideOutside.jsx.map +1 -0
- package/dist/_chunk/autocomplete.js +196 -0
- package/dist/_chunk/autocomplete.js.map +1 -0
- package/dist/_chunk/autocomplete.jsx +196 -0
- package/dist/_chunk/autocomplete.jsx.map +1 -0
- package/dist/_chunk/breadcrumbs.js +119 -0
- package/dist/_chunk/breadcrumbs.js.map +1 -0
- package/dist/_chunk/breadcrumbs.jsx +119 -0
- package/dist/_chunk/breadcrumbs.jsx.map +1 -0
- package/dist/_chunk/button.js +276 -0
- package/dist/_chunk/button.js.map +1 -0
- package/dist/_chunk/button.jsx +276 -0
- package/dist/_chunk/button.jsx.map +1 -0
- package/dist/_chunk/calendar.js +1036 -0
- package/dist/_chunk/calendar.js.map +1 -0
- package/dist/_chunk/calendar.jsx +1036 -0
- package/dist/_chunk/calendar.jsx.map +1 -0
- package/dist/_chunk/checkbox.js +234 -0
- package/dist/_chunk/checkbox.js.map +1 -0
- package/dist/_chunk/checkbox.jsx +234 -0
- package/dist/_chunk/checkbox.jsx.map +1 -0
- package/dist/_chunk/color.js +1174 -0
- package/dist/_chunk/color.js.map +1 -0
- package/dist/_chunk/color.jsx +1174 -0
- package/dist/_chunk/color.jsx.map +1 -0
- package/dist/_chunk/combobox.js +436 -0
- package/dist/_chunk/combobox.js.map +1 -0
- package/dist/_chunk/combobox.jsx +436 -0
- package/dist/_chunk/combobox.jsx.map +1 -0
- package/dist/_chunk/createCollator.js +229 -0
- package/dist/_chunk/createCollator.js.map +1 -0
- package/dist/_chunk/createCollator.jsx +223 -0
- package/dist/_chunk/createCollator.jsx.map +1 -0
- package/dist/_chunk/createCollectionRowInteraction.js +133 -0
- package/dist/_chunk/createCollectionRowInteraction.js.map +1 -0
- package/dist/_chunk/createCollectionRowInteraction.jsx +133 -0
- package/dist/_chunk/createCollectionRowInteraction.jsx.map +1 -0
- package/dist/_chunk/createField.js +54 -0
- package/dist/_chunk/createField.js.map +1 -0
- package/dist/_chunk/createField.jsx +54 -0
- package/dist/_chunk/createField.jsx.map +1 -0
- package/dist/_chunk/createFocus.js +101 -0
- package/dist/_chunk/createFocus.js.map +1 -0
- package/dist/_chunk/createFocus.jsx +101 -0
- package/dist/_chunk/createFocus.jsx.map +1 -0
- package/dist/_chunk/createFocusRing.js +54 -0
- package/dist/_chunk/createFocusRing.js.map +1 -0
- package/dist/_chunk/createFocusRing.jsx +54 -0
- package/dist/_chunk/createFocusRing.jsx.map +1 -0
- package/dist/_chunk/createFocusWithin.js +121 -0
- package/dist/_chunk/createFocusWithin.js.map +1 -0
- package/dist/_chunk/createFocusWithin.jsx +121 -0
- package/dist/_chunk/createFocusWithin.jsx.map +1 -0
- package/dist/_chunk/createFocusable.js +131 -0
- package/dist/_chunk/createFocusable.js.map +1 -0
- package/dist/_chunk/createFocusable.jsx +131 -0
- package/dist/_chunk/createFocusable.jsx.map +1 -0
- package/dist/_chunk/createFormValidation.js +135 -0
- package/dist/_chunk/createFormValidation.js.map +1 -0
- package/dist/_chunk/createFormValidation.jsx +135 -0
- package/dist/_chunk/createFormValidation.jsx.map +1 -0
- package/dist/_chunk/createHover.js +130 -0
- package/dist/_chunk/createHover.js.map +1 -0
- package/dist/_chunk/createHover.jsx +130 -0
- package/dist/_chunk/createHover.jsx.map +1 -0
- package/dist/_chunk/createInteractionModality.js +269 -0
- package/dist/_chunk/createInteractionModality.js.map +1 -0
- package/dist/_chunk/createInteractionModality.jsx +269 -0
- package/dist/_chunk/createInteractionModality.jsx.map +1 -0
- package/dist/_chunk/createLabel.js +46 -0
- package/dist/_chunk/createLabel.js.map +1 -0
- package/dist/_chunk/createLabel.jsx +46 -0
- package/dist/_chunk/createLabel.jsx.map +1 -0
- package/dist/_chunk/createLabels.js +31 -0
- package/dist/_chunk/createLabels.js.map +1 -0
- package/dist/_chunk/createLabels.jsx +31 -0
- package/dist/_chunk/createLabels.jsx.map +1 -0
- package/dist/_chunk/createLandmark.js +198 -0
- package/dist/_chunk/createLandmark.js.map +1 -0
- package/dist/_chunk/createLandmark.jsx +198 -0
- package/dist/_chunk/createLandmark.jsx.map +1 -0
- package/dist/_chunk/createLongPress.js +91 -0
- package/dist/_chunk/createLongPress.js.map +1 -0
- package/dist/_chunk/createLongPress.jsx +91 -0
- package/dist/_chunk/createLongPress.jsx.map +1 -0
- package/dist/_chunk/createOverlay.js +327 -0
- package/dist/_chunk/createOverlay.js.map +1 -0
- package/dist/_chunk/createOverlay.jsx +327 -0
- package/dist/_chunk/createOverlay.jsx.map +1 -0
- package/dist/_chunk/createPress.js +526 -0
- package/dist/_chunk/createPress.js.map +1 -0
- package/dist/_chunk/createPress.jsx +526 -0
- package/dist/_chunk/createPress.jsx.map +1 -0
- package/dist/_chunk/createProgressBar.js +81 -0
- package/dist/_chunk/createProgressBar.js.map +1 -0
- package/dist/_chunk/createProgressBar.jsx +81 -0
- package/dist/_chunk/createProgressBar.jsx.map +1 -0
- package/dist/_chunk/createSelectableItem.js +298 -0
- package/dist/_chunk/createSelectableItem.js.map +1 -0
- package/dist/_chunk/createSelectableItem.jsx +298 -0
- package/dist/_chunk/createSelectableItem.jsx.map +1 -0
- package/dist/_chunk/createToggle.js +158 -0
- package/dist/_chunk/createToggle.js.map +1 -0
- package/dist/_chunk/createToggle.jsx +158 -0
- package/dist/_chunk/createToggle.jsx.map +1 -0
- package/dist/_chunk/createTypeSelect.js +125 -0
- package/dist/_chunk/createTypeSelect.js.map +1 -0
- package/dist/_chunk/createTypeSelect.jsx +125 -0
- package/dist/_chunk/createTypeSelect.jsx.map +1 -0
- package/dist/_chunk/datepicker.js +1393 -0
- package/dist/_chunk/datepicker.js.map +1 -0
- package/dist/_chunk/datepicker.jsx +1393 -0
- package/dist/_chunk/datepicker.jsx.map +1 -0
- package/dist/_chunk/dialog.js +62 -0
- package/dist/_chunk/dialog.js.map +1 -0
- package/dist/_chunk/dialog.jsx +62 -0
- package/dist/_chunk/dialog.jsx.map +1 -0
- package/dist/_chunk/disclosure.js +185 -0
- package/dist/_chunk/disclosure.js.map +1 -0
- package/dist/_chunk/disclosure.jsx +185 -0
- package/dist/_chunk/disclosure.jsx.map +1 -0
- package/dist/_chunk/dnd.js +1304 -0
- package/dist/_chunk/dnd.js.map +1 -0
- package/dist/_chunk/dnd.jsx +1304 -0
- package/dist/_chunk/dnd.jsx.map +1 -0
- package/dist/_chunk/env.js +105 -0
- package/dist/_chunk/env.js.map +1 -0
- package/dist/_chunk/env.jsx +105 -0
- package/dist/_chunk/env.jsx.map +1 -0
- package/dist/_chunk/filterDOMProps.js +82 -0
- package/dist/_chunk/filterDOMProps.js.map +1 -0
- package/dist/_chunk/filterDOMProps.jsx +82 -0
- package/dist/_chunk/filterDOMProps.jsx.map +1 -0
- package/dist/_chunk/focus.js +399 -0
- package/dist/_chunk/focus.js.map +1 -0
- package/dist/_chunk/focus.jsx +399 -0
- package/dist/_chunk/focus.jsx.map +1 -0
- package/dist/_chunk/focus2.js +895 -0
- package/dist/_chunk/focus2.js.map +1 -0
- package/dist/_chunk/focus2.jsx +870 -0
- package/dist/_chunk/focus2.jsx.map +1 -0
- package/dist/_chunk/form.js +39 -0
- package/dist/_chunk/form.js.map +1 -0
- package/dist/_chunk/form.jsx +39 -0
- package/dist/_chunk/form.jsx.map +1 -0
- package/dist/_chunk/grid.js +623 -0
- package/dist/_chunk/grid.js.map +1 -0
- package/dist/_chunk/grid.jsx +623 -0
- package/dist/_chunk/grid.jsx.map +1 -0
- package/dist/_chunk/gridlist.js +364 -0
- package/dist/_chunk/gridlist.js.map +1 -0
- package/dist/_chunk/gridlist.jsx +364 -0
- package/dist/_chunk/gridlist.jsx.map +1 -0
- package/dist/_chunk/i18n.js +254 -0
- package/dist/_chunk/i18n.js.map +1 -0
- package/dist/_chunk/i18n.jsx +254 -0
- package/dist/_chunk/i18n.jsx.map +1 -0
- package/dist/_chunk/interactions.js +241 -0
- package/dist/_chunk/interactions.js.map +1 -0
- package/dist/_chunk/interactions.jsx +237 -0
- package/dist/_chunk/interactions.jsx.map +1 -0
- package/dist/_chunk/link.js +96 -0
- package/dist/_chunk/link.js.map +1 -0
- package/dist/_chunk/link.jsx +96 -0
- package/dist/_chunk/link.jsx.map +1 -0
- package/dist/_chunk/listbox.js +324 -0
- package/dist/_chunk/listbox.js.map +1 -0
- package/dist/_chunk/listbox.jsx +324 -0
- package/dist/_chunk/listbox.jsx.map +1 -0
- package/dist/_chunk/live-announcer.js +207 -0
- package/dist/_chunk/live-announcer.js.map +1 -0
- package/dist/_chunk/live-announcer.jsx +207 -0
- package/dist/_chunk/live-announcer.jsx.map +1 -0
- package/dist/_chunk/menu.js +518 -0
- package/dist/_chunk/menu.js.map +1 -0
- package/dist/_chunk/menu.jsx +518 -0
- package/dist/_chunk/menu.jsx.map +1 -0
- package/dist/_chunk/meter.js +33 -0
- package/dist/_chunk/meter.js.map +1 -0
- package/dist/_chunk/meter.jsx +33 -0
- package/dist/_chunk/meter.jsx.map +1 -0
- package/dist/_chunk/numberfield.js +258 -0
- package/dist/_chunk/numberfield.js.map +1 -0
- package/dist/_chunk/numberfield.jsx +258 -0
- package/dist/_chunk/numberfield.jsx.map +1 -0
- package/dist/_chunk/overlays.js +186 -0
- package/dist/_chunk/overlays.js.map +1 -0
- package/dist/_chunk/overlays.jsx +162 -0
- package/dist/_chunk/overlays.jsx.map +1 -0
- package/dist/_chunk/popover.js +574 -0
- package/dist/_chunk/popover.js.map +1 -0
- package/dist/_chunk/popover.jsx +574 -0
- package/dist/_chunk/popover.jsx.map +1 -0
- package/dist/_chunk/radio.js +319 -0
- package/dist/_chunk/radio.js.map +1 -0
- package/dist/_chunk/radio.jsx +319 -0
- package/dist/_chunk/radio.jsx.map +1 -0
- package/dist/_chunk/searchfield.js +209 -0
- package/dist/_chunk/searchfield.js.map +1 -0
- package/dist/_chunk/searchfield.jsx +209 -0
- package/dist/_chunk/searchfield.jsx.map +1 -0
- package/dist/_chunk/select.js +403 -0
- package/dist/_chunk/select.js.map +1 -0
- package/dist/_chunk/select.jsx +394 -0
- package/dist/_chunk/select.jsx.map +1 -0
- package/dist/_chunk/selection.js +679 -0
- package/dist/_chunk/selection.js.map +1 -0
- package/dist/_chunk/selection.jsx +679 -0
- package/dist/_chunk/selection.jsx.map +1 -0
- package/dist/_chunk/separator.js +29 -0
- package/dist/_chunk/separator.js.map +1 -0
- package/dist/_chunk/separator.jsx +29 -0
- package/dist/_chunk/separator.jsx.map +1 -0
- package/dist/_chunk/slider.js +255 -0
- package/dist/_chunk/slider.js.map +1 -0
- package/dist/_chunk/slider.jsx +255 -0
- package/dist/_chunk/slider.jsx.map +1 -0
- package/dist/_chunk/steplist.js +66 -0
- package/dist/_chunk/steplist.js.map +1 -0
- package/dist/_chunk/steplist.jsx +66 -0
- package/dist/_chunk/steplist.jsx.map +1 -0
- package/dist/_chunk/switch.js +34 -0
- package/dist/_chunk/switch.js.map +1 -0
- package/dist/_chunk/switch.jsx +34 -0
- package/dist/_chunk/switch.jsx.map +1 -0
- package/dist/_chunk/table.js +1051 -0
- package/dist/_chunk/table.js.map +1 -0
- package/dist/_chunk/table.jsx +1051 -0
- package/dist/_chunk/table.jsx.map +1 -0
- package/dist/_chunk/tabs.js +260 -0
- package/dist/_chunk/tabs.js.map +1 -0
- package/dist/_chunk/tabs.jsx +260 -0
- package/dist/_chunk/tabs.jsx.map +1 -0
- package/dist/_chunk/tag.js +286 -0
- package/dist/_chunk/tag.js.map +1 -0
- package/dist/_chunk/tag.jsx +286 -0
- package/dist/_chunk/tag.jsx.map +1 -0
- package/dist/_chunk/textfield.js +109 -0
- package/dist/_chunk/textfield.js.map +1 -0
- package/dist/_chunk/textfield.jsx +109 -0
- package/dist/_chunk/textfield.jsx.map +1 -0
- package/dist/_chunk/toast.js +250 -0
- package/dist/_chunk/toast.js.map +1 -0
- package/dist/_chunk/toast.jsx +250 -0
- package/dist/_chunk/toast.jsx.map +1 -0
- package/dist/_chunk/toolbar.js +258 -0
- package/dist/_chunk/toolbar.js.map +1 -0
- package/dist/_chunk/toolbar.jsx +258 -0
- package/dist/_chunk/toolbar.jsx.map +1 -0
- package/dist/_chunk/tooltip.js +185 -0
- package/dist/_chunk/tooltip.js.map +1 -0
- package/dist/_chunk/tooltip.jsx +185 -0
- package/dist/_chunk/tooltip.jsx.map +1 -0
- package/dist/_chunk/tree.js +424 -0
- package/dist/_chunk/tree.js.map +1 -0
- package/dist/_chunk/tree.jsx +424 -0
- package/dist/_chunk/tree.jsx.map +1 -0
- package/dist/_chunk/utils.js +665 -0
- package/dist/_chunk/utils.js.map +1 -0
- package/dist/_chunk/utils.jsx +665 -0
- package/dist/_chunk/utils.jsx.map +1 -0
- package/dist/_chunk/visually-hidden.js +92 -0
- package/dist/_chunk/visually-hidden.js.map +1 -0
- package/dist/_chunk/visually-hidden.jsx +92 -0
- package/dist/_chunk/visually-hidden.jsx.map +1 -0
- package/dist/actiongroup/index.js +2 -0
- package/dist/actiongroup/index.jsx +2 -0
- package/dist/autocomplete/createAutocomplete.d.ts +2 -0
- package/dist/autocomplete/createAutocomplete.d.ts.map +1 -1
- package/dist/autocomplete/index.js +2 -0
- package/dist/autocomplete/index.jsx +2 -0
- package/dist/breadcrumbs/index.js +2 -0
- package/dist/breadcrumbs/index.jsx +2 -0
- package/dist/button/index.js +2 -0
- package/dist/button/index.jsx +2 -0
- package/dist/calendar/createCalendar.d.ts.map +1 -1
- package/dist/calendar/createCalendarCell.d.ts.map +1 -1
- package/dist/calendar/createCalendarGrid.d.ts.map +1 -1
- package/dist/calendar/createCalendarMonthPicker.d.ts +41 -0
- package/dist/calendar/createCalendarMonthPicker.d.ts.map +1 -0
- package/dist/calendar/createCalendarYearPicker.d.ts +49 -0
- package/dist/calendar/createCalendarYearPicker.d.ts.map +1 -0
- package/dist/calendar/createRangeCalendar.d.ts.map +1 -1
- package/dist/calendar/index.d.ts +2 -0
- package/dist/calendar/index.d.ts.map +1 -1
- package/dist/calendar/index.js +2 -0
- package/dist/calendar/index.jsx +2 -0
- package/dist/calendar/utils.d.ts +4 -0
- package/dist/calendar/utils.d.ts.map +1 -1
- package/dist/checkbox/createCheckbox.d.ts +4 -0
- package/dist/checkbox/createCheckbox.d.ts.map +1 -1
- package/dist/checkbox/createCheckboxGroupItem.d.ts.map +1 -1
- package/dist/checkbox/index.js +2 -0
- package/dist/checkbox/index.jsx +2 -0
- package/dist/collections/index.js +160 -0
- package/dist/collections/index.js.map +1 -0
- package/dist/collections/index.jsx +160 -0
- package/dist/collections/index.jsx.map +1 -0
- package/dist/color/index.js +2 -0
- package/dist/color/index.jsx +2 -0
- package/dist/combobox/index.js +2 -0
- package/dist/combobox/index.jsx +2 -0
- package/dist/datepicker/createDateSegment.d.ts.map +1 -1
- package/dist/datepicker/index.js +2 -0
- package/dist/datepicker/index.jsx +2 -0
- package/dist/dialog/index.js +2 -0
- package/dist/dialog/index.jsx +2 -0
- package/dist/disclosure/index.js +2 -0
- package/dist/disclosure/index.jsx +2 -0
- package/dist/dnd/createDroppableCollection.d.ts.map +1 -1
- package/dist/dnd/index.js +2 -0
- package/dist/dnd/index.jsx +2 -0
- package/dist/dnd/utils.d.ts +2 -2
- package/dist/dnd/utils.d.ts.map +1 -1
- package/dist/focus/FocusScope.d.ts.map +1 -1
- package/dist/focus/index.js +2 -0
- package/dist/focus/index.jsx +2 -0
- package/dist/form/createFormValidation.d.ts.map +1 -1
- package/dist/form/index.js +3 -0
- package/dist/form/index.jsx +3 -0
- package/dist/grid/index.js +2 -0
- package/dist/grid/index.jsx +2 -0
- package/dist/gridlist/createGridList.d.ts +7 -1
- package/dist/gridlist/createGridList.d.ts.map +1 -1
- package/dist/gridlist/createGridListItem.d.ts +1 -1
- package/dist/gridlist/createGridListItem.d.ts.map +1 -1
- package/dist/gridlist/createGridListSection.d.ts +15 -0
- package/dist/gridlist/createGridListSection.d.ts.map +1 -0
- package/dist/gridlist/index.d.ts +2 -1
- package/dist/gridlist/index.d.ts.map +1 -1
- package/dist/gridlist/index.js +2 -0
- package/dist/gridlist/index.jsx +2 -0
- package/dist/gridlist/types.d.ts +50 -0
- package/dist/gridlist/types.d.ts.map +1 -1
- package/dist/i18n/index.js +3 -0
- package/dist/i18n/index.jsx +3 -0
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +71 -18311
- package/dist/index.jsx +71 -18242
- package/dist/interactions/PressEvent.d.ts +11 -0
- package/dist/interactions/PressEvent.d.ts.map +1 -1
- package/dist/interactions/createInteractionModality.d.ts +0 -1
- package/dist/interactions/createInteractionModality.d.ts.map +1 -1
- package/dist/interactions/createKeyboard.d.ts.map +1 -1
- package/dist/interactions/createPress.d.ts.map +1 -1
- package/dist/interactions/index.js +10 -0
- package/dist/interactions/index.jsx +10 -0
- package/dist/label/index.js +4 -0
- package/dist/label/index.jsx +4 -0
- package/dist/landmark/index.js +2 -0
- package/dist/landmark/index.jsx +2 -0
- package/dist/link/index.js +2 -0
- package/dist/link/index.jsx +2 -0
- package/dist/listbox/createListBox.d.ts +37 -0
- package/dist/listbox/createListBox.d.ts.map +1 -1
- package/dist/listbox/createOption.d.ts +6 -0
- package/dist/listbox/createOption.d.ts.map +1 -1
- package/dist/listbox/index.js +2 -0
- package/dist/listbox/index.jsx +2 -0
- package/dist/live-announcer/index.js +2 -0
- package/dist/live-announcer/index.jsx +2 -0
- package/dist/menu/createMenu.d.ts +7 -4
- package/dist/menu/createMenu.d.ts.map +1 -1
- package/dist/menu/createMenuItem.d.ts +9 -1
- package/dist/menu/createMenuItem.d.ts.map +1 -1
- package/dist/menu/index.js +2 -0
- package/dist/menu/index.jsx +2 -0
- package/dist/meter/index.js +2 -0
- package/dist/meter/index.jsx +2 -0
- package/dist/numberfield/createNumberField.d.ts.map +1 -1
- package/dist/numberfield/index.js +2 -0
- package/dist/numberfield/index.jsx +2 -0
- package/dist/overlays/index.js +4 -0
- package/dist/overlays/index.jsx +4 -0
- package/dist/popover/calculatePosition.d.ts +2 -0
- package/dist/popover/calculatePosition.d.ts.map +1 -1
- package/dist/popover/createOverlayPosition.d.ts +8 -0
- package/dist/popover/createOverlayPosition.d.ts.map +1 -1
- package/dist/popover/index.js +2 -0
- package/dist/popover/index.jsx +2 -0
- package/dist/progress/index.js +2 -0
- package/dist/progress/index.jsx +2 -0
- package/dist/radio/createRadio.d.ts +2 -0
- package/dist/radio/createRadio.d.ts.map +1 -1
- package/dist/radio/index.js +2 -0
- package/dist/radio/index.jsx +2 -0
- package/dist/searchfield/index.js +2 -0
- package/dist/searchfield/index.jsx +2 -0
- package/dist/select/createSelect.d.ts.map +1 -1
- package/dist/select/index.js +2 -0
- package/dist/select/index.jsx +2 -0
- package/dist/selection/DOMLayoutDelegate.d.ts +58 -0
- package/dist/selection/DOMLayoutDelegate.d.ts.map +1 -0
- package/dist/selection/ListKeyboardDelegate.d.ts +95 -0
- package/dist/selection/ListKeyboardDelegate.d.ts.map +1 -0
- package/dist/selection/constants.d.ts +15 -0
- package/dist/selection/constants.d.ts.map +1 -0
- package/dist/selection/createCollectionRowInteraction.d.ts +13 -0
- package/dist/selection/createCollectionRowInteraction.d.ts.map +1 -0
- package/dist/selection/createScrollIntoViewOnFocus.d.ts +31 -0
- package/dist/selection/createScrollIntoViewOnFocus.d.ts.map +1 -0
- package/dist/selection/createSelectableCollection.d.ts +69 -0
- package/dist/selection/createSelectableCollection.d.ts.map +1 -0
- package/dist/selection/createSelectableItem.d.ts +154 -0
- package/dist/selection/createSelectableItem.d.ts.map +1 -0
- package/dist/selection/createSelectableList.d.ts +43 -0
- package/dist/selection/createSelectableList.d.ts.map +1 -0
- package/dist/selection/createTypeSelect.d.ts.map +1 -1
- package/dist/selection/index.d.ts +9 -0
- package/dist/selection/index.d.ts.map +1 -1
- package/dist/selection/index.js +4 -0
- package/dist/selection/index.jsx +4 -0
- package/dist/selection/selectItem.d.ts +29 -0
- package/dist/selection/selectItem.d.ts.map +1 -0
- package/dist/selection/utils.d.ts +40 -0
- package/dist/selection/utils.d.ts.map +1 -0
- package/dist/separator/index.js +2 -0
- package/dist/separator/index.jsx +2 -0
- package/dist/slider/createSlider.d.ts.map +1 -1
- package/dist/slider/index.js +2 -0
- package/dist/slider/index.jsx +2 -0
- package/dist/ssr/index.d.ts +17 -0
- package/dist/ssr/index.d.ts.map +1 -1
- package/dist/ssr/index.js +299 -0
- package/dist/ssr/index.js.map +1 -0
- package/dist/ssr/index.jsx +292 -0
- package/dist/ssr/index.jsx.map +1 -0
- package/dist/steplist/index.js +2 -0
- package/dist/steplist/index.jsx +2 -0
- package/dist/switch/createSwitch.d.ts +4 -0
- package/dist/switch/createSwitch.d.ts.map +1 -1
- package/dist/switch/index.js +2 -0
- package/dist/switch/index.jsx +2 -0
- package/dist/table/createTable.d.ts.map +1 -1
- package/dist/table/createTableRow.d.ts +1 -1
- package/dist/table/createTableRow.d.ts.map +1 -1
- package/dist/table/createTableSelectAllCheckbox.d.ts.map +1 -1
- package/dist/table/index.js +2 -0
- package/dist/table/index.jsx +2 -0
- package/dist/table/types.d.ts +27 -1
- package/dist/table/types.d.ts.map +1 -1
- package/dist/tabs/createTabs.d.ts +4 -3
- package/dist/tabs/createTabs.d.ts.map +1 -1
- package/dist/tabs/index.js +2 -0
- package/dist/tabs/index.jsx +2 -0
- package/dist/tag/createTag.d.ts +2 -0
- package/dist/tag/createTag.d.ts.map +1 -1
- package/dist/tag/index.js +2 -0
- package/dist/tag/index.jsx +2 -0
- package/dist/textfield/index.js +2 -0
- package/dist/textfield/index.jsx +2 -0
- package/dist/toast/createToast.d.ts.map +1 -1
- package/dist/toast/index.js +2 -0
- package/dist/toast/index.jsx +2 -0
- package/dist/toggle/createToggle.d.ts +4 -0
- package/dist/toggle/createToggle.d.ts.map +1 -1
- package/dist/toggle/index.js +3 -0
- package/dist/toggle/index.jsx +3 -0
- package/dist/toolbar/createToolbar.d.ts +1 -1
- package/dist/toolbar/createToolbar.d.ts.map +1 -1
- package/dist/toolbar/index.js +2 -0
- package/dist/toolbar/index.jsx +2 -0
- package/dist/tooltip/index.js +2 -0
- package/dist/tooltip/index.jsx +2 -0
- package/dist/tree/createTree.d.ts +5 -1
- package/dist/tree/createTree.d.ts.map +1 -1
- package/dist/tree/createTreeItem.d.ts +1 -1
- package/dist/tree/createTreeItem.d.ts.map +1 -1
- package/dist/tree/index.js +2 -0
- package/dist/tree/index.jsx +2 -0
- package/dist/tree/types.d.ts +10 -0
- package/dist/tree/types.d.ts.map +1 -1
- package/dist/utils/animation.d.ts +60 -0
- package/dist/utils/animation.d.ts.map +1 -0
- package/dist/utils/dom.d.ts +48 -2
- package/dist/utils/dom.d.ts.map +1 -1
- package/dist/utils/index.d.ts +4 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.jsx +5 -0
- package/dist/utils/keyboard.d.ts +17 -0
- package/dist/utils/keyboard.d.ts.map +1 -0
- package/dist/utils/mergeProps.d.ts.map +1 -1
- package/dist/utils/scrollIntoView.d.ts +30 -0
- package/dist/utils/scrollIntoView.d.ts.map +1 -0
- package/dist/visually-hidden/index.js +2 -0
- package/dist/visually-hidden/index.jsx +2 -0
- package/package.json +304 -3
- package/src/autocomplete/createAutocomplete.ts +67 -21
- package/src/calendar/createCalendar.ts +2 -0
- package/src/calendar/createCalendarCell.ts +19 -2
- package/src/calendar/createCalendarGrid.ts +43 -9
- package/src/calendar/createCalendarMonthPicker.ts +105 -0
- package/src/calendar/createCalendarYearPicker.ts +144 -0
- package/src/calendar/createRangeCalendar.ts +2 -0
- package/src/calendar/index.ts +17 -0
- package/src/calendar/utils.ts +4 -0
- package/src/checkbox/createCheckbox.ts +10 -0
- package/src/checkbox/createCheckboxGroupItem.ts +12 -16
- package/src/datepicker/createDateSegment.ts +6 -1
- package/src/dnd/createDroppableCollection.ts +4 -1
- package/src/dnd/utils.ts +27 -3
- package/src/focus/FocusScope.tsx +152 -18
- package/src/form/createFormValidation.ts +8 -1
- package/src/gridlist/createGridList.ts +145 -42
- package/src/gridlist/createGridListItem.ts +87 -155
- package/src/gridlist/createGridListSection.ts +54 -0
- package/src/gridlist/index.ts +3 -0
- package/src/gridlist/types.ts +47 -0
- package/src/index.ts +40 -0
- package/src/interactions/PressEvent.ts +14 -0
- package/src/interactions/createInteractionModality.ts +21 -12
- package/src/interactions/createKeyboard.ts +10 -0
- package/src/interactions/createPress.ts +29 -6
- package/src/listbox/createListBox.ts +129 -8
- package/src/listbox/createOption.ts +68 -73
- package/src/menu/createMenu.ts +93 -16
- package/src/menu/createMenuItem.ts +253 -41
- package/src/numberfield/createNumberField.ts +82 -14
- package/src/popover/calculatePosition.ts +19 -7
- package/src/popover/createOverlayPosition.ts +9 -0
- package/src/radio/createRadio.ts +19 -2
- package/src/select/createSelect.ts +18 -2
- package/src/selection/DOMLayoutDelegate.ts +102 -0
- package/src/selection/ListKeyboardDelegate.ts +398 -0
- package/src/selection/constants.ts +16 -0
- package/src/selection/createCollectionRowInteraction.ts +209 -0
- package/src/selection/createScrollIntoViewOnFocus.ts +65 -0
- package/src/selection/createSelectableCollection.ts +645 -0
- package/src/selection/createSelectableItem.ts +498 -0
- package/src/selection/createSelectableList.ts +93 -0
- package/src/selection/createTypeSelect.ts +112 -51
- package/src/selection/index.ts +31 -0
- package/src/selection/selectItem.ts +80 -0
- package/src/selection/utils.ts +82 -0
- package/src/slider/createSlider.ts +48 -1
- package/src/ssr/index.tsx +31 -0
- package/src/switch/createSwitch.ts +10 -0
- package/src/table/createTable.ts +56 -26
- package/src/table/createTableRow.ts +198 -203
- package/src/table/createTableSelectAllCheckbox.ts +3 -4
- package/src/table/types.ts +29 -1
- package/src/tabs/createTabs.ts +50 -20
- package/src/tag/createTag.ts +9 -4
- package/src/toast/createToast.ts +1 -0
- package/src/toggle/createToggle.ts +20 -0
- package/src/toolbar/createToolbar.ts +43 -42
- package/src/tree/createTree.ts +100 -42
- package/src/tree/createTreeItem.ts +105 -120
- package/src/tree/types.ts +10 -0
- package/src/utils/animation.ts +151 -0
- package/src/utils/dom.ts +215 -25
- package/src/utils/index.ts +8 -0
- package/src/utils/keyboard.ts +25 -0
- package/src/utils/mergeProps.ts +8 -1
- package/src/utils/scrollIntoView.ts +181 -0
- package/dist/index.js.map +0 -1
- package/dist/index.jsx.map +0 -1
package/dist/ssr/index.d.ts
CHANGED
|
@@ -47,6 +47,23 @@ export declare const canUseDOM: boolean;
|
|
|
47
47
|
* ```
|
|
48
48
|
*/
|
|
49
49
|
export declare function createId(defaultId?: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Generates an id, but only resolves to it once an element with that id is
|
|
52
|
+
* actually present in the DOM. Returns `undefined` otherwise.
|
|
53
|
+
*
|
|
54
|
+
* This is a 1:1 port of @react-aria/utils's `useSlotId`. It exists so that an
|
|
55
|
+
* `aria-labelledby` can point at an optional slot (e.g. a section header) and
|
|
56
|
+
* automatically fall back to `undefined` when the slot is not rendered, instead
|
|
57
|
+
* of leaving a dangling reference to a non-existent id.
|
|
58
|
+
*
|
|
59
|
+
* The initial value is the generated id so that server and first client render
|
|
60
|
+
* agree (no hydration mismatch); a client-only effect then probes the DOM and
|
|
61
|
+
* clears the value when no matching element exists.
|
|
62
|
+
*
|
|
63
|
+
* @param deps - Accessors re-probed when their values change (mirrors the
|
|
64
|
+
* dependency array of the upstream hook).
|
|
65
|
+
*/
|
|
66
|
+
export declare function createSlotId(deps?: Array<Accessor<unknown>>): Accessor<string | undefined>;
|
|
50
67
|
/**
|
|
51
68
|
* Provides SSR context to the component tree.
|
|
52
69
|
*
|
package/dist/ssr/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ssr/index.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,GAAG,EACR,KAAK,WAAW,EASjB,MAAM,UAAU,CAAC;AAGlB,MAAM,WAAW,gBAAiB,SAAQ,WAAW;CAAG;AAExD,MAAM,WAAW,eAAe;IAC9B,iDAAiD;IACjD,KAAK,EAAE,OAAO,CAAC;IACf,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC;CAChB;AAOD;;;;;;GAMG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,SAAY,CAAC;AAEnC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAOnD;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,GAAG,CAAC,OAAO,CAatF;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,IAAI,QAAQ,CAAC,OAAO,CAAC,CAcxD;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,QAAQ,IAAI,QAAQ,CAAC,OAAO,CAAC,CAE5C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAWvE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAY3E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,IAAI,MAAM,GAAG,SAAS,CAK9C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,IAAI,QAAQ,GAAG,SAAS,CAKlD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAErF;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAEjF;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAK3E"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ssr/index.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,GAAG,EACR,KAAK,WAAW,EASjB,MAAM,UAAU,CAAC;AAGlB,MAAM,WAAW,gBAAiB,SAAQ,WAAW;CAAG;AAExD,MAAM,WAAW,eAAe;IAC9B,iDAAiD;IACjD,KAAK,EAAE,OAAO,CAAC;IACf,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC;CAChB;AAOD;;;;;;GAMG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,SAAY,CAAC;AAEnC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAOnD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAM,GAAG,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC,CAa9F;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,GAAG,CAAC,OAAO,CAatF;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,IAAI,QAAQ,CAAC,OAAO,CAAC,CAcxD;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,QAAQ,IAAI,QAAQ,CAAC,OAAO,CAAC,CAE5C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAWvE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAY3E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,IAAI,MAAM,GAAG,SAAS,CAK9C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,IAAI,QAAQ,GAAG,SAAS,CAKlD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAErF;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAEjF;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAK3E"}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { createContext, createEffect, createMemo, createSignal, createUniqueId, onCleanup, onMount, useContext } from "solid-js";
|
|
2
|
+
import { createComponent, isServer } from "solid-js/web";
|
|
3
|
+
//#region src/ssr/index.tsx
|
|
4
|
+
/**
|
|
5
|
+
* SSR utilities for Solidaria
|
|
6
|
+
*
|
|
7
|
+
* SolidJS has built-in SSR support with `isServer` and `createUniqueId()`.
|
|
8
|
+
* These utilities provide a consistent API matching React-Aria's patterns
|
|
9
|
+
* with additional features for hydration management.
|
|
10
|
+
*/
|
|
11
|
+
const SSRContext = createContext({
|
|
12
|
+
isSSR: isServer,
|
|
13
|
+
prefix: ""
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* Returns whether the component is currently being server side rendered.
|
|
17
|
+
* Can be used to delay browser-specific rendering until after hydration.
|
|
18
|
+
*
|
|
19
|
+
* Note: This returns a static boolean. For reactive hydration detection,
|
|
20
|
+
* use `createHydrationState()`.
|
|
21
|
+
*/
|
|
22
|
+
function createIsSSR() {
|
|
23
|
+
return isServer;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Check if we can use DOM APIs.
|
|
27
|
+
* This is useful for code that needs to run only in the browser.
|
|
28
|
+
*/
|
|
29
|
+
const canUseDOM = !isServer;
|
|
30
|
+
/**
|
|
31
|
+
* Generate a unique ID that is stable across server and client.
|
|
32
|
+
* Uses SolidJS's built-in createUniqueId which handles SSR correctly.
|
|
33
|
+
*
|
|
34
|
+
* @param defaultId - Optional default ID to use instead of generating one.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* function TextField(props) {
|
|
39
|
+
* const inputId = createId(props.id);
|
|
40
|
+
* return (
|
|
41
|
+
* <>
|
|
42
|
+
* <label for={inputId}>{props.label}</label>
|
|
43
|
+
* <input id={inputId} />
|
|
44
|
+
* </>
|
|
45
|
+
* );
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
function createId(defaultId) {
|
|
50
|
+
if (defaultId) return defaultId;
|
|
51
|
+
const ctx = useContext(SSRContext);
|
|
52
|
+
const uniqueId = createUniqueId();
|
|
53
|
+
return ctx.prefix ? `solidaria-${ctx.prefix}-${uniqueId}` : `solidaria-${uniqueId}`;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Generates an id, but only resolves to it once an element with that id is
|
|
57
|
+
* actually present in the DOM. Returns `undefined` otherwise.
|
|
58
|
+
*
|
|
59
|
+
* This is a 1:1 port of @react-aria/utils's `useSlotId`. It exists so that an
|
|
60
|
+
* `aria-labelledby` can point at an optional slot (e.g. a section header) and
|
|
61
|
+
* automatically fall back to `undefined` when the slot is not rendered, instead
|
|
62
|
+
* of leaving a dangling reference to a non-existent id.
|
|
63
|
+
*
|
|
64
|
+
* The initial value is the generated id so that server and first client render
|
|
65
|
+
* agree (no hydration mismatch); a client-only effect then probes the DOM and
|
|
66
|
+
* clears the value when no matching element exists.
|
|
67
|
+
*
|
|
68
|
+
* @param deps - Accessors re-probed when their values change (mirrors the
|
|
69
|
+
* dependency array of the upstream hook).
|
|
70
|
+
*/
|
|
71
|
+
function createSlotId(deps = []) {
|
|
72
|
+
const id = createId();
|
|
73
|
+
const [resolvedId, setResolvedId] = createSignal(id);
|
|
74
|
+
createEffect(() => {
|
|
75
|
+
for (const dep of deps) dep();
|
|
76
|
+
setResolvedId(document.getElementById(id) ? id : void 0);
|
|
77
|
+
});
|
|
78
|
+
return resolvedId;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Provides SSR context to the component tree.
|
|
82
|
+
*
|
|
83
|
+
* While SolidJS handles most SSR scenarios automatically, this provider
|
|
84
|
+
* can be useful for:
|
|
85
|
+
* - Nested ID prefixes to avoid collisions in micro-frontends
|
|
86
|
+
* - Explicit hydration boundary markers
|
|
87
|
+
* - Testing SSR behavior
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```tsx
|
|
91
|
+
* // Root of your app
|
|
92
|
+
* <SSRProvider>
|
|
93
|
+
* <App />
|
|
94
|
+
* </SSRProvider>
|
|
95
|
+
*
|
|
96
|
+
* // With custom prefix for micro-frontend
|
|
97
|
+
* <SSRProvider prefix="widget">
|
|
98
|
+
* <Widget />
|
|
99
|
+
* </SSRProvider>
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
function SSRProvider(props) {
|
|
103
|
+
const parentContext = useContext(SSRContext);
|
|
104
|
+
const value = createMemo(() => ({
|
|
105
|
+
isSSR: isServer,
|
|
106
|
+
prefix: props.prefix ? parentContext.prefix ? `${parentContext.prefix}-${props.prefix}` : props.prefix : parentContext.prefix
|
|
107
|
+
}));
|
|
108
|
+
return createComponent(SSRContext.Provider, {
|
|
109
|
+
get value() {
|
|
110
|
+
return value();
|
|
111
|
+
},
|
|
112
|
+
get children() {
|
|
113
|
+
return props.children;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Tracks whether the component is currently hydrating.
|
|
119
|
+
*
|
|
120
|
+
* During server-side rendering, this returns `true`. After hydration
|
|
121
|
+
* completes on the client, it switches to `false`. This is useful for
|
|
122
|
+
* components that need to show different content during hydration.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```tsx
|
|
126
|
+
* function ClientOnlyComponent() {
|
|
127
|
+
* const isHydrating = createHydrationState();
|
|
128
|
+
*
|
|
129
|
+
* return (
|
|
130
|
+
* <Show when={!isHydrating()} fallback={<LoadingPlaceholder />}>
|
|
131
|
+
* <InteractiveWidget />
|
|
132
|
+
* </Show>
|
|
133
|
+
* );
|
|
134
|
+
* }
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
function createHydrationState() {
|
|
138
|
+
if (isServer) return () => true;
|
|
139
|
+
const [isHydrating, setIsHydrating] = createSignal(true);
|
|
140
|
+
onMount(() => {
|
|
141
|
+
setIsHydrating(false);
|
|
142
|
+
});
|
|
143
|
+
return isHydrating;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Hook that returns `true` during SSR and initial hydration.
|
|
147
|
+
* Use this to delay browser-specific code until hydration is complete.
|
|
148
|
+
*
|
|
149
|
+
* Unlike `createIsSSR()` which is static, this updates reactively
|
|
150
|
+
* after hydration completes.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```tsx
|
|
154
|
+
* function BrowserOnlyFeature() {
|
|
155
|
+
* const isSSR = useIsSSR();
|
|
156
|
+
*
|
|
157
|
+
* createEffect(() => {
|
|
158
|
+
* if (!isSSR()) {
|
|
159
|
+
* // Safe to access browser APIs here
|
|
160
|
+
* window.localStorage.getItem('key');
|
|
161
|
+
* }
|
|
162
|
+
* });
|
|
163
|
+
*
|
|
164
|
+
* return <Show when={!isSSR()}>...</Show>;
|
|
165
|
+
* }
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
function useIsSSR() {
|
|
169
|
+
return createHydrationState();
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Creates an effect that only runs on the client after hydration.
|
|
173
|
+
* This is a convenience wrapper that ensures browser-specific code
|
|
174
|
+
* doesn't run during SSR.
|
|
175
|
+
*
|
|
176
|
+
* @param fn - The effect function to run
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```tsx
|
|
180
|
+
* function Analytics() {
|
|
181
|
+
* createBrowserEffect(() => {
|
|
182
|
+
* // Safe to access window, document, localStorage, etc.
|
|
183
|
+
* window.analytics.track('page_view');
|
|
184
|
+
* });
|
|
185
|
+
*
|
|
186
|
+
* return null;
|
|
187
|
+
* }
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
function createBrowserEffect(fn) {
|
|
191
|
+
if (isServer) return;
|
|
192
|
+
createEffect(() => {
|
|
193
|
+
const cleanup = fn();
|
|
194
|
+
if (typeof cleanup === "function") onCleanup(cleanup);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Creates a value that is computed only on the client.
|
|
199
|
+
* On the server, returns the fallback value.
|
|
200
|
+
*
|
|
201
|
+
* @param fn - Function to compute the value on the client
|
|
202
|
+
* @param fallback - Value to return during SSR
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```tsx
|
|
206
|
+
* function WindowSize() {
|
|
207
|
+
* const width = createBrowserValue(
|
|
208
|
+
* () => window.innerWidth,
|
|
209
|
+
* 0
|
|
210
|
+
* );
|
|
211
|
+
*
|
|
212
|
+
* return <span>Width: {width()}</span>;
|
|
213
|
+
* }
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
function createBrowserValue(fn, fallback) {
|
|
217
|
+
if (isServer) return () => fallback;
|
|
218
|
+
const [value, setValue] = createSignal(fallback);
|
|
219
|
+
onMount(() => {
|
|
220
|
+
setValue(() => fn());
|
|
221
|
+
});
|
|
222
|
+
return value;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Returns the window object if available, or undefined during SSR.
|
|
226
|
+
* Useful for accessing browser globals safely.
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```tsx
|
|
230
|
+
* const win = getWindow();
|
|
231
|
+
* if (win) {
|
|
232
|
+
* win.addEventListener('resize', handler);
|
|
233
|
+
* }
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
function getWindow() {
|
|
237
|
+
if (typeof window !== "undefined") return window;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Returns the document object if available, or undefined during SSR.
|
|
241
|
+
* Useful for accessing document safely.
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```tsx
|
|
245
|
+
* const doc = getDocument();
|
|
246
|
+
* if (doc) {
|
|
247
|
+
* doc.addEventListener('keydown', handler);
|
|
248
|
+
* }
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
function getDocument() {
|
|
252
|
+
if (typeof document !== "undefined") return document;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Returns the owner document of an element, with SSR safety.
|
|
256
|
+
*
|
|
257
|
+
* @param el - The element to get the owner document from
|
|
258
|
+
*/
|
|
259
|
+
function getOwnerDocument(el) {
|
|
260
|
+
return el?.ownerDocument ?? getDocument();
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Returns the owner window of an element, with SSR safety.
|
|
264
|
+
*
|
|
265
|
+
* @param el - The element to get the owner window from
|
|
266
|
+
*/
|
|
267
|
+
function getOwnerWindow(el) {
|
|
268
|
+
return getOwnerDocument(el)?.defaultView ?? getWindow();
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Gets the appropriate container for portals, with SSR safety.
|
|
272
|
+
* Returns the specified container, or document.body on the client,
|
|
273
|
+
* or undefined during SSR.
|
|
274
|
+
*
|
|
275
|
+
* @param container - Optional custom container element
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```tsx
|
|
279
|
+
* function Modal(props) {
|
|
280
|
+
* const container = getPortalContainer(props.container);
|
|
281
|
+
*
|
|
282
|
+
* return (
|
|
283
|
+
* <Show when={container}>
|
|
284
|
+
* <Portal mount={container}>
|
|
285
|
+
* {props.children}
|
|
286
|
+
* </Portal>
|
|
287
|
+
* </Show>
|
|
288
|
+
* );
|
|
289
|
+
* }
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
function getPortalContainer(container) {
|
|
293
|
+
if (container) return container;
|
|
294
|
+
return getDocument()?.body;
|
|
295
|
+
}
|
|
296
|
+
//#endregion
|
|
297
|
+
export { SSRProvider, canUseDOM, createBrowserEffect, createBrowserValue, createHydrationState, createId, createIsSSR, createSlotId, getDocument, getOwnerDocument, getOwnerWindow, getPortalContainer, getWindow, useIsSSR };
|
|
298
|
+
|
|
299
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["Accessor","JSX","ParentProps","createContext","createEffect","createMemo","createSignal","onCleanup","onMount","useContext","createUniqueId","isServer","SSRProviderProps","SSRContextValue","isSSR","prefix","SSRContext","createIsSSR","canUseDOM","createId","defaultId","ctx","uniqueId","createSlotId","deps","Array","id","resolvedId","setResolvedId","dep","document","getElementById","undefined","SSRProvider","props","Element","parentContext","value","_$createComponent","Provider","children","createHydrationState","isHydrating","setIsHydrating","useIsSSR","createBrowserEffect","fn","cleanup","createBrowserValue","T","fallback","setValue","getWindow","Window","window","getDocument","Document","getOwnerDocument","el","ownerDocument","getOwnerWindow","defaultView","getPortalContainer","container","body"],"sources":["../../src/ssr/index.tsx"],"sourcesContent":["/**\n * SSR utilities for Solidaria\n *\n * SolidJS has built-in SSR support with `isServer` and `createUniqueId()`.\n * These utilities provide a consistent API matching React-Aria's patterns\n * with additional features for hydration management.\n */\n\nimport {\n type Accessor,\n type JSX,\n type ParentProps,\n createContext,\n createEffect,\n createMemo,\n createSignal,\n onCleanup,\n onMount,\n useContext,\n createUniqueId,\n} from \"solid-js\";\nimport { isServer } from \"solid-js/web\";\n\nexport interface SSRProviderProps extends ParentProps {}\n\nexport interface SSRContextValue {\n /** Whether currently rendering on the server. */\n isSSR: boolean;\n /** Prefix for generated IDs, allowing nested providers. */\n prefix: string;\n}\n\nconst SSRContext = createContext<SSRContextValue>({\n isSSR: isServer,\n prefix: \"\",\n});\n\n/**\n * Returns whether the component is currently being server side rendered.\n * Can be used to delay browser-specific rendering until after hydration.\n *\n * Note: This returns a static boolean. For reactive hydration detection,\n * use `createHydrationState()`.\n */\nexport function createIsSSR(): boolean {\n return isServer;\n}\n\n/**\n * Check if we can use DOM APIs.\n * This is useful for code that needs to run only in the browser.\n */\nexport const canUseDOM = !isServer;\n\n/**\n * Generate a unique ID that is stable across server and client.\n * Uses SolidJS's built-in createUniqueId which handles SSR correctly.\n *\n * @param defaultId - Optional default ID to use instead of generating one.\n *\n * @example\n * ```tsx\n * function TextField(props) {\n * const inputId = createId(props.id);\n * return (\n * <>\n * <label for={inputId}>{props.label}</label>\n * <input id={inputId} />\n * </>\n * );\n * }\n * ```\n */\nexport function createId(defaultId?: string): string {\n if (defaultId) {\n return defaultId;\n }\n const ctx = useContext(SSRContext);\n const uniqueId = createUniqueId();\n return ctx.prefix ? `solidaria-${ctx.prefix}-${uniqueId}` : `solidaria-${uniqueId}`;\n}\n\n/**\n * Generates an id, but only resolves to it once an element with that id is\n * actually present in the DOM. Returns `undefined` otherwise.\n *\n * This is a 1:1 port of @react-aria/utils's `useSlotId`. It exists so that an\n * `aria-labelledby` can point at an optional slot (e.g. a section header) and\n * automatically fall back to `undefined` when the slot is not rendered, instead\n * of leaving a dangling reference to a non-existent id.\n *\n * The initial value is the generated id so that server and first client render\n * agree (no hydration mismatch); a client-only effect then probes the DOM and\n * clears the value when no matching element exists.\n *\n * @param deps - Accessors re-probed when their values change (mirrors the\n * dependency array of the upstream hook).\n */\nexport function createSlotId(deps: Array<Accessor<unknown>> = []): Accessor<string | undefined> {\n const id = createId();\n const [resolvedId, setResolvedId] = createSignal<string | undefined>(id);\n\n createEffect(() => {\n // Re-probe when any explicit dependency changes.\n for (const dep of deps) {\n dep();\n }\n setResolvedId(document.getElementById(id) ? id : undefined);\n });\n\n return resolvedId;\n}\n\n/**\n * Provides SSR context to the component tree.\n *\n * While SolidJS handles most SSR scenarios automatically, this provider\n * can be useful for:\n * - Nested ID prefixes to avoid collisions in micro-frontends\n * - Explicit hydration boundary markers\n * - Testing SSR behavior\n *\n * @example\n * ```tsx\n * // Root of your app\n * <SSRProvider>\n * <App />\n * </SSRProvider>\n *\n * // With custom prefix for micro-frontend\n * <SSRProvider prefix=\"widget\">\n * <Widget />\n * </SSRProvider>\n * ```\n */\nexport function SSRProvider(props: SSRProviderProps & { prefix?: string }): JSX.Element {\n const parentContext = useContext(SSRContext);\n\n const value = createMemo<SSRContextValue>(() => ({\n isSSR: isServer,\n prefix: props.prefix\n ? parentContext.prefix\n ? `${parentContext.prefix}-${props.prefix}`\n : props.prefix\n : parentContext.prefix,\n }));\n\n return <SSRContext.Provider value={value()}>{props.children}</SSRContext.Provider>;\n}\n\n/**\n * Tracks whether the component is currently hydrating.\n *\n * During server-side rendering, this returns `true`. After hydration\n * completes on the client, it switches to `false`. This is useful for\n * components that need to show different content during hydration.\n *\n * @example\n * ```tsx\n * function ClientOnlyComponent() {\n * const isHydrating = createHydrationState();\n *\n * return (\n * <Show when={!isHydrating()} fallback={<LoadingPlaceholder />}>\n * <InteractiveWidget />\n * </Show>\n * );\n * }\n * ```\n */\nexport function createHydrationState(): Accessor<boolean> {\n // On the server, always return true\n if (isServer) {\n return () => true;\n }\n\n // On the client, track hydration state\n const [isHydrating, setIsHydrating] = createSignal(true);\n\n onMount(() => {\n setIsHydrating(false);\n });\n\n return isHydrating;\n}\n\n/**\n * Hook that returns `true` during SSR and initial hydration.\n * Use this to delay browser-specific code until hydration is complete.\n *\n * Unlike `createIsSSR()` which is static, this updates reactively\n * after hydration completes.\n *\n * @example\n * ```tsx\n * function BrowserOnlyFeature() {\n * const isSSR = useIsSSR();\n *\n * createEffect(() => {\n * if (!isSSR()) {\n * // Safe to access browser APIs here\n * window.localStorage.getItem('key');\n * }\n * });\n *\n * return <Show when={!isSSR()}>...</Show>;\n * }\n * ```\n */\nexport function useIsSSR(): Accessor<boolean> {\n return createHydrationState();\n}\n\n/**\n * Creates an effect that only runs on the client after hydration.\n * This is a convenience wrapper that ensures browser-specific code\n * doesn't run during SSR.\n *\n * @param fn - The effect function to run\n *\n * @example\n * ```tsx\n * function Analytics() {\n * createBrowserEffect(() => {\n * // Safe to access window, document, localStorage, etc.\n * window.analytics.track('page_view');\n * });\n *\n * return null;\n * }\n * ```\n */\nexport function createBrowserEffect(fn: () => void | (() => void)): void {\n if (isServer) {\n return;\n }\n\n createEffect(() => {\n const cleanup = fn();\n if (typeof cleanup === \"function\") {\n onCleanup(cleanup);\n }\n });\n}\n\n/**\n * Creates a value that is computed only on the client.\n * On the server, returns the fallback value.\n *\n * @param fn - Function to compute the value on the client\n * @param fallback - Value to return during SSR\n *\n * @example\n * ```tsx\n * function WindowSize() {\n * const width = createBrowserValue(\n * () => window.innerWidth,\n * 0\n * );\n *\n * return <span>Width: {width()}</span>;\n * }\n * ```\n */\nexport function createBrowserValue<T>(fn: () => T, fallback: T): Accessor<T> {\n if (isServer) {\n return () => fallback;\n }\n\n const [value, setValue] = createSignal<T>(fallback);\n\n onMount(() => {\n setValue(() => fn());\n });\n\n return value;\n}\n\n/**\n * Returns the window object if available, or undefined during SSR.\n * Useful for accessing browser globals safely.\n *\n * @example\n * ```tsx\n * const win = getWindow();\n * if (win) {\n * win.addEventListener('resize', handler);\n * }\n * ```\n */\nexport function getWindow(): Window | undefined {\n if (typeof window !== \"undefined\") {\n return window;\n }\n return undefined;\n}\n\n/**\n * Returns the document object if available, or undefined during SSR.\n * Useful for accessing document safely.\n *\n * @example\n * ```tsx\n * const doc = getDocument();\n * if (doc) {\n * doc.addEventListener('keydown', handler);\n * }\n * ```\n */\nexport function getDocument(): Document | undefined {\n if (typeof document !== \"undefined\") {\n return document;\n }\n return undefined;\n}\n\n/**\n * Returns the owner document of an element, with SSR safety.\n *\n * @param el - The element to get the owner document from\n */\nexport function getOwnerDocument(el: Element | null | undefined): Document | undefined {\n return el?.ownerDocument ?? getDocument();\n}\n\n/**\n * Returns the owner window of an element, with SSR safety.\n *\n * @param el - The element to get the owner window from\n */\nexport function getOwnerWindow(el: Element | null | undefined): Window | undefined {\n return getOwnerDocument(el)?.defaultView ?? getWindow();\n}\n\n/**\n * Gets the appropriate container for portals, with SSR safety.\n * Returns the specified container, or document.body on the client,\n * or undefined during SSR.\n *\n * @param container - Optional custom container element\n *\n * @example\n * ```tsx\n * function Modal(props) {\n * const container = getPortalContainer(props.container);\n *\n * return (\n * <Show when={container}>\n * <Portal mount={container}>\n * {props.children}\n * </Portal>\n * </Show>\n * );\n * }\n * ```\n */\nexport function getPortalContainer(container?: Element): Element | undefined {\n if (container) {\n return container;\n }\n return getDocument()?.body;\n}\n"],"mappings":";;;;;;;;;;AAgCA,MAAMgB,aAAab,cAA+B;CAChDW,OAAOH;CACPI,QAAQ;AACV,CAAC;;;;;;;;AASD,SAAgBE,cAAuB;CACrC,OAAON;AACT;;;;;AAMA,MAAaO,YAAY,CAACP;;;;;;;;;;;;;;;;;;;;AAqB1B,SAAgBQ,SAASC,WAA4B;CACnD,IAAIA,WACF,OAAOA;CAET,MAAMC,MAAMZ,WAAWO,UAAU;CACjC,MAAMM,WAAWZ,eAAe;CAChC,OAAOW,IAAIN,SAAS,aAAaM,IAAIN,OAAM,GAAIO,aAAa,aAAaA;AAC3E;;;;;;;;;;;;;;;;;AAkBA,SAAgBC,aAAaC,OAAiC,CAAA,GAAkC;CAC9F,MAAME,KAAKP,SAAS;CACpB,MAAM,CAACQ,YAAYC,iBAAiBtB,aAAiCoB,EAAE;CAEvEtB,mBAAmB;EAEjB,KAAK,MAAMyB,OAAOL,MAChBK,IAAI;EAEND,cAAcE,SAASC,eAAeL,EAAE,IAAIA,KAAKM,KAAAA,CAAS;CAC5D,CAAC;CAED,OAAOL;AACT;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgBM,YAAYC,OAA4D;CACtF,MAAME,gBAAgB3B,WAAWO,UAAU;CAE3C,MAAMqB,QAAQhC,kBAAmC;EAC/CS,OAAOH;EACPI,QAAQmB,MAAMnB,SACVqB,cAAcrB,SACZ,GAAGqB,cAAcrB,OAAM,GAAImB,MAAMnB,WACjCmB,MAAMnB,SACRqB,cAAcrB;CACpB,EAAE;CAEF,OAAAuB,gBAAQtB,WAAWuB,UAAQ;EAAA,IAACF,QAAK;GAAA,OAAEA,MAAM;EAAC;EAAA,IAAAG,WAAA;GAAA,OAAGN,MAAMM;EAAQ;CAAA,CAAA;AAC7D;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgBC,uBAA0C;CAExD,IAAI9B,UACF,aAAa;CAIf,MAAM,CAAC+B,aAAaC,kBAAkBrC,aAAa,IAAI;CAEvDE,cAAc;EACZmC,eAAe,KAAK;CACtB,CAAC;CAED,OAAOD;AACT;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgBE,WAA8B;CAC5C,OAAOH,qBAAqB;AAC9B;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgBI,oBAAoBC,IAAqC;CACvE,IAAInC,UACF;CAGFP,mBAAmB;EACjB,MAAM2C,UAAUD,GAAG;EACnB,IAAI,OAAOC,YAAY,YACrBxC,UAAUwC,OAAO;CAErB,CAAC;AACH;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgBC,mBAAsBF,IAAaI,UAA0B;CAC3E,IAAIvC,UACF,aAAauC;CAGf,MAAM,CAACb,OAAOc,YAAY7C,aAAgB4C,QAAQ;CAElD1C,cAAc;EACZ2C,eAAeL,GAAG,CAAC;CACrB,CAAC;CAED,OAAOT;AACT;;;;;;;;;;;;;AAcA,SAAgBe,YAAgC;CAC9C,IAAI,OAAOE,WAAW,aACpB,OAAOA;AAGX;;;;;;;;;;;;;AAcA,SAAgBC,cAAoC;CAClD,IAAI,OAAOzB,aAAa,aACtB,OAAOA;AAGX;;;;;;AAOA,SAAgB2B,iBAAiBC,IAAsD;CACrF,OAAOA,IAAIC,iBAAiBJ,YAAY;AAC1C;;;;;;AAOA,SAAgBK,eAAeF,IAAoD;CACjF,OAAOD,iBAAiBC,EAAE,CAAC,EAAEG,eAAeT,UAAU;AACxD;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgBU,mBAAmBC,WAA0C;CAC3E,IAAIA,WACF,OAAOA;CAET,OAAOR,YAAY,CAAC,EAAES;AACxB"}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { createContext, createEffect, createMemo, createSignal, createUniqueId, onCleanup, onMount, useContext } from "solid-js";
|
|
2
|
+
import { isServer } from "solid-js/web";
|
|
3
|
+
//#region src/ssr/index.tsx
|
|
4
|
+
/**
|
|
5
|
+
* SSR utilities for Solidaria
|
|
6
|
+
*
|
|
7
|
+
* SolidJS has built-in SSR support with `isServer` and `createUniqueId()`.
|
|
8
|
+
* These utilities provide a consistent API matching React-Aria's patterns
|
|
9
|
+
* with additional features for hydration management.
|
|
10
|
+
*/
|
|
11
|
+
const SSRContext = createContext({
|
|
12
|
+
isSSR: isServer,
|
|
13
|
+
prefix: ""
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* Returns whether the component is currently being server side rendered.
|
|
17
|
+
* Can be used to delay browser-specific rendering until after hydration.
|
|
18
|
+
*
|
|
19
|
+
* Note: This returns a static boolean. For reactive hydration detection,
|
|
20
|
+
* use `createHydrationState()`.
|
|
21
|
+
*/
|
|
22
|
+
function createIsSSR() {
|
|
23
|
+
return isServer;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Check if we can use DOM APIs.
|
|
27
|
+
* This is useful for code that needs to run only in the browser.
|
|
28
|
+
*/
|
|
29
|
+
const canUseDOM = !isServer;
|
|
30
|
+
/**
|
|
31
|
+
* Generate a unique ID that is stable across server and client.
|
|
32
|
+
* Uses SolidJS's built-in createUniqueId which handles SSR correctly.
|
|
33
|
+
*
|
|
34
|
+
* @param defaultId - Optional default ID to use instead of generating one.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* function TextField(props) {
|
|
39
|
+
* const inputId = createId(props.id);
|
|
40
|
+
* return (
|
|
41
|
+
* <>
|
|
42
|
+
* <label for={inputId}>{props.label}</label>
|
|
43
|
+
* <input id={inputId} />
|
|
44
|
+
* </>
|
|
45
|
+
* );
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
function createId(defaultId) {
|
|
50
|
+
if (defaultId) return defaultId;
|
|
51
|
+
const ctx = useContext(SSRContext);
|
|
52
|
+
const uniqueId = createUniqueId();
|
|
53
|
+
return ctx.prefix ? `solidaria-${ctx.prefix}-${uniqueId}` : `solidaria-${uniqueId}`;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Generates an id, but only resolves to it once an element with that id is
|
|
57
|
+
* actually present in the DOM. Returns `undefined` otherwise.
|
|
58
|
+
*
|
|
59
|
+
* This is a 1:1 port of @react-aria/utils's `useSlotId`. It exists so that an
|
|
60
|
+
* `aria-labelledby` can point at an optional slot (e.g. a section header) and
|
|
61
|
+
* automatically fall back to `undefined` when the slot is not rendered, instead
|
|
62
|
+
* of leaving a dangling reference to a non-existent id.
|
|
63
|
+
*
|
|
64
|
+
* The initial value is the generated id so that server and first client render
|
|
65
|
+
* agree (no hydration mismatch); a client-only effect then probes the DOM and
|
|
66
|
+
* clears the value when no matching element exists.
|
|
67
|
+
*
|
|
68
|
+
* @param deps - Accessors re-probed when their values change (mirrors the
|
|
69
|
+
* dependency array of the upstream hook).
|
|
70
|
+
*/
|
|
71
|
+
function createSlotId(deps = []) {
|
|
72
|
+
const id = createId();
|
|
73
|
+
const [resolvedId, setResolvedId] = createSignal(id);
|
|
74
|
+
createEffect(() => {
|
|
75
|
+
for (const dep of deps) dep();
|
|
76
|
+
setResolvedId(document.getElementById(id) ? id : void 0);
|
|
77
|
+
});
|
|
78
|
+
return resolvedId;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Provides SSR context to the component tree.
|
|
82
|
+
*
|
|
83
|
+
* While SolidJS handles most SSR scenarios automatically, this provider
|
|
84
|
+
* can be useful for:
|
|
85
|
+
* - Nested ID prefixes to avoid collisions in micro-frontends
|
|
86
|
+
* - Explicit hydration boundary markers
|
|
87
|
+
* - Testing SSR behavior
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```tsx
|
|
91
|
+
* // Root of your app
|
|
92
|
+
* <SSRProvider>
|
|
93
|
+
* <App />
|
|
94
|
+
* </SSRProvider>
|
|
95
|
+
*
|
|
96
|
+
* // With custom prefix for micro-frontend
|
|
97
|
+
* <SSRProvider prefix="widget">
|
|
98
|
+
* <Widget />
|
|
99
|
+
* </SSRProvider>
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
function SSRProvider(props) {
|
|
103
|
+
const parentContext = useContext(SSRContext);
|
|
104
|
+
const value = createMemo(() => ({
|
|
105
|
+
isSSR: isServer,
|
|
106
|
+
prefix: props.prefix ? parentContext.prefix ? `${parentContext.prefix}-${props.prefix}` : props.prefix : parentContext.prefix
|
|
107
|
+
}));
|
|
108
|
+
return <SSRContext.Provider value={value()}>{props.children}</SSRContext.Provider>;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Tracks whether the component is currently hydrating.
|
|
112
|
+
*
|
|
113
|
+
* During server-side rendering, this returns `true`. After hydration
|
|
114
|
+
* completes on the client, it switches to `false`. This is useful for
|
|
115
|
+
* components that need to show different content during hydration.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```tsx
|
|
119
|
+
* function ClientOnlyComponent() {
|
|
120
|
+
* const isHydrating = createHydrationState();
|
|
121
|
+
*
|
|
122
|
+
* return (
|
|
123
|
+
* <Show when={!isHydrating()} fallback={<LoadingPlaceholder />}>
|
|
124
|
+
* <InteractiveWidget />
|
|
125
|
+
* </Show>
|
|
126
|
+
* );
|
|
127
|
+
* }
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
function createHydrationState() {
|
|
131
|
+
if (isServer) return () => true;
|
|
132
|
+
const [isHydrating, setIsHydrating] = createSignal(true);
|
|
133
|
+
onMount(() => {
|
|
134
|
+
setIsHydrating(false);
|
|
135
|
+
});
|
|
136
|
+
return isHydrating;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Hook that returns `true` during SSR and initial hydration.
|
|
140
|
+
* Use this to delay browser-specific code until hydration is complete.
|
|
141
|
+
*
|
|
142
|
+
* Unlike `createIsSSR()` which is static, this updates reactively
|
|
143
|
+
* after hydration completes.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```tsx
|
|
147
|
+
* function BrowserOnlyFeature() {
|
|
148
|
+
* const isSSR = useIsSSR();
|
|
149
|
+
*
|
|
150
|
+
* createEffect(() => {
|
|
151
|
+
* if (!isSSR()) {
|
|
152
|
+
* // Safe to access browser APIs here
|
|
153
|
+
* window.localStorage.getItem('key');
|
|
154
|
+
* }
|
|
155
|
+
* });
|
|
156
|
+
*
|
|
157
|
+
* return <Show when={!isSSR()}>...</Show>;
|
|
158
|
+
* }
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
function useIsSSR() {
|
|
162
|
+
return createHydrationState();
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Creates an effect that only runs on the client after hydration.
|
|
166
|
+
* This is a convenience wrapper that ensures browser-specific code
|
|
167
|
+
* doesn't run during SSR.
|
|
168
|
+
*
|
|
169
|
+
* @param fn - The effect function to run
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```tsx
|
|
173
|
+
* function Analytics() {
|
|
174
|
+
* createBrowserEffect(() => {
|
|
175
|
+
* // Safe to access window, document, localStorage, etc.
|
|
176
|
+
* window.analytics.track('page_view');
|
|
177
|
+
* });
|
|
178
|
+
*
|
|
179
|
+
* return null;
|
|
180
|
+
* }
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
function createBrowserEffect(fn) {
|
|
184
|
+
if (isServer) return;
|
|
185
|
+
createEffect(() => {
|
|
186
|
+
const cleanup = fn();
|
|
187
|
+
if (typeof cleanup === "function") onCleanup(cleanup);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Creates a value that is computed only on the client.
|
|
192
|
+
* On the server, returns the fallback value.
|
|
193
|
+
*
|
|
194
|
+
* @param fn - Function to compute the value on the client
|
|
195
|
+
* @param fallback - Value to return during SSR
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```tsx
|
|
199
|
+
* function WindowSize() {
|
|
200
|
+
* const width = createBrowserValue(
|
|
201
|
+
* () => window.innerWidth,
|
|
202
|
+
* 0
|
|
203
|
+
* );
|
|
204
|
+
*
|
|
205
|
+
* return <span>Width: {width()}</span>;
|
|
206
|
+
* }
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
function createBrowserValue(fn, fallback) {
|
|
210
|
+
if (isServer) return () => fallback;
|
|
211
|
+
const [value, setValue] = createSignal(fallback);
|
|
212
|
+
onMount(() => {
|
|
213
|
+
setValue(() => fn());
|
|
214
|
+
});
|
|
215
|
+
return value;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Returns the window object if available, or undefined during SSR.
|
|
219
|
+
* Useful for accessing browser globals safely.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```tsx
|
|
223
|
+
* const win = getWindow();
|
|
224
|
+
* if (win) {
|
|
225
|
+
* win.addEventListener('resize', handler);
|
|
226
|
+
* }
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
function getWindow() {
|
|
230
|
+
if (typeof window !== "undefined") return window;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Returns the document object if available, or undefined during SSR.
|
|
234
|
+
* Useful for accessing document safely.
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```tsx
|
|
238
|
+
* const doc = getDocument();
|
|
239
|
+
* if (doc) {
|
|
240
|
+
* doc.addEventListener('keydown', handler);
|
|
241
|
+
* }
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
function getDocument() {
|
|
245
|
+
if (typeof document !== "undefined") return document;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Returns the owner document of an element, with SSR safety.
|
|
249
|
+
*
|
|
250
|
+
* @param el - The element to get the owner document from
|
|
251
|
+
*/
|
|
252
|
+
function getOwnerDocument(el) {
|
|
253
|
+
return el?.ownerDocument ?? getDocument();
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Returns the owner window of an element, with SSR safety.
|
|
257
|
+
*
|
|
258
|
+
* @param el - The element to get the owner window from
|
|
259
|
+
*/
|
|
260
|
+
function getOwnerWindow(el) {
|
|
261
|
+
return getOwnerDocument(el)?.defaultView ?? getWindow();
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Gets the appropriate container for portals, with SSR safety.
|
|
265
|
+
* Returns the specified container, or document.body on the client,
|
|
266
|
+
* or undefined during SSR.
|
|
267
|
+
*
|
|
268
|
+
* @param container - Optional custom container element
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```tsx
|
|
272
|
+
* function Modal(props) {
|
|
273
|
+
* const container = getPortalContainer(props.container);
|
|
274
|
+
*
|
|
275
|
+
* return (
|
|
276
|
+
* <Show when={container}>
|
|
277
|
+
* <Portal mount={container}>
|
|
278
|
+
* {props.children}
|
|
279
|
+
* </Portal>
|
|
280
|
+
* </Show>
|
|
281
|
+
* );
|
|
282
|
+
* }
|
|
283
|
+
* ```
|
|
284
|
+
*/
|
|
285
|
+
function getPortalContainer(container) {
|
|
286
|
+
if (container) return container;
|
|
287
|
+
return getDocument()?.body;
|
|
288
|
+
}
|
|
289
|
+
//#endregion
|
|
290
|
+
export { SSRProvider, canUseDOM, createBrowserEffect, createBrowserValue, createHydrationState, createId, createIsSSR, createSlotId, getDocument, getOwnerDocument, getOwnerWindow, getPortalContainer, getWindow, useIsSSR };
|
|
291
|
+
|
|
292
|
+
//# sourceMappingURL=index.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.jsx","names":[],"sources":["../../src/ssr/index.tsx"],"sourcesContent":["/**\n * SSR utilities for Solidaria\n *\n * SolidJS has built-in SSR support with `isServer` and `createUniqueId()`.\n * These utilities provide a consistent API matching React-Aria's patterns\n * with additional features for hydration management.\n */\n\nimport {\n type Accessor,\n type JSX,\n type ParentProps,\n createContext,\n createEffect,\n createMemo,\n createSignal,\n onCleanup,\n onMount,\n useContext,\n createUniqueId,\n} from \"solid-js\";\nimport { isServer } from \"solid-js/web\";\n\nexport interface SSRProviderProps extends ParentProps {}\n\nexport interface SSRContextValue {\n /** Whether currently rendering on the server. */\n isSSR: boolean;\n /** Prefix for generated IDs, allowing nested providers. */\n prefix: string;\n}\n\nconst SSRContext = createContext<SSRContextValue>({\n isSSR: isServer,\n prefix: \"\",\n});\n\n/**\n * Returns whether the component is currently being server side rendered.\n * Can be used to delay browser-specific rendering until after hydration.\n *\n * Note: This returns a static boolean. For reactive hydration detection,\n * use `createHydrationState()`.\n */\nexport function createIsSSR(): boolean {\n return isServer;\n}\n\n/**\n * Check if we can use DOM APIs.\n * This is useful for code that needs to run only in the browser.\n */\nexport const canUseDOM = !isServer;\n\n/**\n * Generate a unique ID that is stable across server and client.\n * Uses SolidJS's built-in createUniqueId which handles SSR correctly.\n *\n * @param defaultId - Optional default ID to use instead of generating one.\n *\n * @example\n * ```tsx\n * function TextField(props) {\n * const inputId = createId(props.id);\n * return (\n * <>\n * <label for={inputId}>{props.label}</label>\n * <input id={inputId} />\n * </>\n * );\n * }\n * ```\n */\nexport function createId(defaultId?: string): string {\n if (defaultId) {\n return defaultId;\n }\n const ctx = useContext(SSRContext);\n const uniqueId = createUniqueId();\n return ctx.prefix ? `solidaria-${ctx.prefix}-${uniqueId}` : `solidaria-${uniqueId}`;\n}\n\n/**\n * Generates an id, but only resolves to it once an element with that id is\n * actually present in the DOM. Returns `undefined` otherwise.\n *\n * This is a 1:1 port of @react-aria/utils's `useSlotId`. It exists so that an\n * `aria-labelledby` can point at an optional slot (e.g. a section header) and\n * automatically fall back to `undefined` when the slot is not rendered, instead\n * of leaving a dangling reference to a non-existent id.\n *\n * The initial value is the generated id so that server and first client render\n * agree (no hydration mismatch); a client-only effect then probes the DOM and\n * clears the value when no matching element exists.\n *\n * @param deps - Accessors re-probed when their values change (mirrors the\n * dependency array of the upstream hook).\n */\nexport function createSlotId(deps: Array<Accessor<unknown>> = []): Accessor<string | undefined> {\n const id = createId();\n const [resolvedId, setResolvedId] = createSignal<string | undefined>(id);\n\n createEffect(() => {\n // Re-probe when any explicit dependency changes.\n for (const dep of deps) {\n dep();\n }\n setResolvedId(document.getElementById(id) ? id : undefined);\n });\n\n return resolvedId;\n}\n\n/**\n * Provides SSR context to the component tree.\n *\n * While SolidJS handles most SSR scenarios automatically, this provider\n * can be useful for:\n * - Nested ID prefixes to avoid collisions in micro-frontends\n * - Explicit hydration boundary markers\n * - Testing SSR behavior\n *\n * @example\n * ```tsx\n * // Root of your app\n * <SSRProvider>\n * <App />\n * </SSRProvider>\n *\n * // With custom prefix for micro-frontend\n * <SSRProvider prefix=\"widget\">\n * <Widget />\n * </SSRProvider>\n * ```\n */\nexport function SSRProvider(props: SSRProviderProps & { prefix?: string }): JSX.Element {\n const parentContext = useContext(SSRContext);\n\n const value = createMemo<SSRContextValue>(() => ({\n isSSR: isServer,\n prefix: props.prefix\n ? parentContext.prefix\n ? `${parentContext.prefix}-${props.prefix}`\n : props.prefix\n : parentContext.prefix,\n }));\n\n return <SSRContext.Provider value={value()}>{props.children}</SSRContext.Provider>;\n}\n\n/**\n * Tracks whether the component is currently hydrating.\n *\n * During server-side rendering, this returns `true`. After hydration\n * completes on the client, it switches to `false`. This is useful for\n * components that need to show different content during hydration.\n *\n * @example\n * ```tsx\n * function ClientOnlyComponent() {\n * const isHydrating = createHydrationState();\n *\n * return (\n * <Show when={!isHydrating()} fallback={<LoadingPlaceholder />}>\n * <InteractiveWidget />\n * </Show>\n * );\n * }\n * ```\n */\nexport function createHydrationState(): Accessor<boolean> {\n // On the server, always return true\n if (isServer) {\n return () => true;\n }\n\n // On the client, track hydration state\n const [isHydrating, setIsHydrating] = createSignal(true);\n\n onMount(() => {\n setIsHydrating(false);\n });\n\n return isHydrating;\n}\n\n/**\n * Hook that returns `true` during SSR and initial hydration.\n * Use this to delay browser-specific code until hydration is complete.\n *\n * Unlike `createIsSSR()` which is static, this updates reactively\n * after hydration completes.\n *\n * @example\n * ```tsx\n * function BrowserOnlyFeature() {\n * const isSSR = useIsSSR();\n *\n * createEffect(() => {\n * if (!isSSR()) {\n * // Safe to access browser APIs here\n * window.localStorage.getItem('key');\n * }\n * });\n *\n * return <Show when={!isSSR()}>...</Show>;\n * }\n * ```\n */\nexport function useIsSSR(): Accessor<boolean> {\n return createHydrationState();\n}\n\n/**\n * Creates an effect that only runs on the client after hydration.\n * This is a convenience wrapper that ensures browser-specific code\n * doesn't run during SSR.\n *\n * @param fn - The effect function to run\n *\n * @example\n * ```tsx\n * function Analytics() {\n * createBrowserEffect(() => {\n * // Safe to access window, document, localStorage, etc.\n * window.analytics.track('page_view');\n * });\n *\n * return null;\n * }\n * ```\n */\nexport function createBrowserEffect(fn: () => void | (() => void)): void {\n if (isServer) {\n return;\n }\n\n createEffect(() => {\n const cleanup = fn();\n if (typeof cleanup === \"function\") {\n onCleanup(cleanup);\n }\n });\n}\n\n/**\n * Creates a value that is computed only on the client.\n * On the server, returns the fallback value.\n *\n * @param fn - Function to compute the value on the client\n * @param fallback - Value to return during SSR\n *\n * @example\n * ```tsx\n * function WindowSize() {\n * const width = createBrowserValue(\n * () => window.innerWidth,\n * 0\n * );\n *\n * return <span>Width: {width()}</span>;\n * }\n * ```\n */\nexport function createBrowserValue<T>(fn: () => T, fallback: T): Accessor<T> {\n if (isServer) {\n return () => fallback;\n }\n\n const [value, setValue] = createSignal<T>(fallback);\n\n onMount(() => {\n setValue(() => fn());\n });\n\n return value;\n}\n\n/**\n * Returns the window object if available, or undefined during SSR.\n * Useful for accessing browser globals safely.\n *\n * @example\n * ```tsx\n * const win = getWindow();\n * if (win) {\n * win.addEventListener('resize', handler);\n * }\n * ```\n */\nexport function getWindow(): Window | undefined {\n if (typeof window !== \"undefined\") {\n return window;\n }\n return undefined;\n}\n\n/**\n * Returns the document object if available, or undefined during SSR.\n * Useful for accessing document safely.\n *\n * @example\n * ```tsx\n * const doc = getDocument();\n * if (doc) {\n * doc.addEventListener('keydown', handler);\n * }\n * ```\n */\nexport function getDocument(): Document | undefined {\n if (typeof document !== \"undefined\") {\n return document;\n }\n return undefined;\n}\n\n/**\n * Returns the owner document of an element, with SSR safety.\n *\n * @param el - The element to get the owner document from\n */\nexport function getOwnerDocument(el: Element | null | undefined): Document | undefined {\n return el?.ownerDocument ?? getDocument();\n}\n\n/**\n * Returns the owner window of an element, with SSR safety.\n *\n * @param el - The element to get the owner window from\n */\nexport function getOwnerWindow(el: Element | null | undefined): Window | undefined {\n return getOwnerDocument(el)?.defaultView ?? getWindow();\n}\n\n/**\n * Gets the appropriate container for portals, with SSR safety.\n * Returns the specified container, or document.body on the client,\n * or undefined during SSR.\n *\n * @param container - Optional custom container element\n *\n * @example\n * ```tsx\n * function Modal(props) {\n * const container = getPortalContainer(props.container);\n *\n * return (\n * <Show when={container}>\n * <Portal mount={container}>\n * {props.children}\n * </Portal>\n * </Show>\n * );\n * }\n * ```\n */\nexport function getPortalContainer(container?: Element): Element | undefined {\n if (container) {\n return container;\n }\n return getDocument()?.body;\n}\n"],"mappings":";;;;;;;;;;AAgCA,MAAM,aAAa,cAA+B;CAChD,OAAO;CACP,QAAQ;AACV,CAAC;;;;;;;;AASD,SAAgB,cAAuB;CACrC,OAAO;AACT;;;;;AAMA,MAAa,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;AAqB1B,SAAgB,SAAS,WAA4B;CACnD,IAAI,WACF,OAAO;CAET,MAAM,MAAM,WAAW,UAAU;CACjC,MAAM,WAAW,eAAe;CAChC,OAAO,IAAI,SAAS,aAAa,IAAI,OAAO,GAAG,aAAa,aAAa;AAC3E;;;;;;;;;;;;;;;;;AAkBA,SAAgB,aAAa,OAAiC,CAAC,GAAiC;CAC9F,MAAM,KAAK,SAAS;CACpB,MAAM,CAAC,YAAY,iBAAiB,aAAiC,EAAE;CAEvE,mBAAmB;EAEjB,KAAK,MAAM,OAAO,MAChB,IAAI;EAEN,cAAc,SAAS,eAAe,EAAE,IAAI,KAAK,KAAA,CAAS;CAC5D,CAAC;CAED,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,YAAY,OAA4D;CACtF,MAAM,gBAAgB,WAAW,UAAU;CAE3C,MAAM,QAAQ,kBAAmC;EAC/C,OAAO;EACP,QAAQ,MAAM,SACV,cAAc,SACZ,GAAG,cAAc,OAAO,GAAG,MAAM,WACjC,MAAM,SACR,cAAc;CACpB,EAAE;CAEF,OAAO,CAAC,WAAW,SAAS,OAAO,MAAM,IAAI,MAAM,SAAS,EAAE,WAAW;AAC3E;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,uBAA0C;CAExD,IAAI,UACF,aAAa;CAIf,MAAM,CAAC,aAAa,kBAAkB,aAAa,IAAI;CAEvD,cAAc;EACZ,eAAe,KAAK;CACtB,CAAC;CAED,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,WAA8B;CAC5C,OAAO,qBAAqB;AAC9B;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,oBAAoB,IAAqC;CACvE,IAAI,UACF;CAGF,mBAAmB;EACjB,MAAM,UAAU,GAAG;EACnB,IAAI,OAAO,YAAY,YACrB,UAAU,OAAO;CAErB,CAAC;AACH;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,mBAAsB,IAAa,UAA0B;CAC3E,IAAI,UACF,aAAa;CAGf,MAAM,CAAC,OAAO,YAAY,aAAgB,QAAQ;CAElD,cAAc;EACZ,eAAe,GAAG,CAAC;CACrB,CAAC;CAED,OAAO;AACT;;;;;;;;;;;;;AAcA,SAAgB,YAAgC;CAC9C,IAAI,OAAO,WAAW,aACpB,OAAO;AAGX;;;;;;;;;;;;;AAcA,SAAgB,cAAoC;CAClD,IAAI,OAAO,aAAa,aACtB,OAAO;AAGX;;;;;;AAOA,SAAgB,iBAAiB,IAAsD;CACrF,OAAO,IAAI,iBAAiB,YAAY;AAC1C;;;;;;AAOA,SAAgB,eAAe,IAAoD;CACjF,OAAO,iBAAiB,EAAE,CAAC,EAAE,eAAe,UAAU;AACxD;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,mBAAmB,WAA0C;CAC3E,IAAI,WACF,OAAO;CAET,OAAO,YAAY,CAAC,EAAE;AACxB"}
|