@proyecto-viviana/solidaria-components 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ActionBar.js +184 -0
- package/dist/ActionBar.js.map +1 -0
- package/dist/ActionBar.jsx +128 -0
- package/dist/ActionBar.jsx.map +1 -0
- package/dist/ActionGroup.js +179 -0
- package/dist/ActionGroup.js.map +1 -0
- package/dist/ActionGroup.jsx +129 -0
- package/dist/ActionGroup.jsx.map +1 -0
- package/dist/Alert.js +111 -0
- package/dist/Alert.js.map +1 -0
- package/dist/Alert.jsx +82 -0
- package/dist/Alert.jsx.map +1 -0
- package/dist/Autocomplete.js +130 -0
- package/dist/Autocomplete.js.map +1 -0
- package/dist/Autocomplete.jsx +116 -0
- package/dist/Autocomplete.jsx.map +1 -0
- package/dist/Breadcrumbs.d.ts.map +1 -1
- package/dist/Breadcrumbs.js +334 -0
- package/dist/Breadcrumbs.js.map +1 -0
- package/dist/Breadcrumbs.jsx +266 -0
- package/dist/Breadcrumbs.jsx.map +1 -0
- package/dist/Button.d.ts.map +1 -1
- package/dist/Button.js +348 -0
- package/dist/Button.js.map +1 -0
- package/dist/Button.jsx +314 -0
- package/dist/Button.jsx.map +1 -0
- package/dist/Calendar.d.ts +4 -4
- package/dist/Calendar.d.ts.map +1 -1
- package/dist/Calendar.js +538 -0
- package/dist/Calendar.js.map +1 -0
- package/dist/Calendar.jsx +333 -0
- package/dist/Calendar.jsx.map +1 -0
- package/dist/CalendarPicker.d.ts +33 -0
- package/dist/CalendarPicker.d.ts.map +1 -0
- package/dist/CalendarPicker.js +44 -0
- package/dist/CalendarPicker.js.map +1 -0
- package/dist/CalendarPicker.jsx +44 -0
- package/dist/CalendarPicker.jsx.map +1 -0
- package/dist/Checkbox.d.ts +83 -4
- package/dist/Checkbox.d.ts.map +1 -1
- package/dist/Checkbox.js +923 -0
- package/dist/Checkbox.js.map +1 -0
- package/dist/Checkbox.jsx +707 -0
- package/dist/Checkbox.jsx.map +1 -0
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +202 -0
- package/dist/Collection.js.map +1 -0
- package/dist/Collection.jsx +152 -0
- package/dist/Collection.jsx.map +1 -0
- package/dist/Color.d.ts.map +1 -1
- package/dist/Color.js +1720 -0
- package/dist/Color.js.map +1 -0
- package/dist/Color.jsx +1344 -0
- package/dist/Color.jsx.map +1 -0
- package/dist/ColorEditor.js +208 -0
- package/dist/ColorEditor.js.map +1 -0
- package/dist/ColorEditor.jsx +120 -0
- package/dist/ColorEditor.jsx.map +1 -0
- package/dist/ComboBox.d.ts +4 -4
- package/dist/ComboBox.d.ts.map +1 -1
- package/dist/ComboBox.js +992 -0
- package/dist/ComboBox.js.map +1 -0
- package/dist/ComboBox.jsx +714 -0
- package/dist/ComboBox.jsx.map +1 -0
- package/dist/ContextualHelpTrigger.js +146 -0
- package/dist/ContextualHelpTrigger.js.map +1 -0
- package/dist/ContextualHelpTrigger.jsx +109 -0
- package/dist/ContextualHelpTrigger.jsx.map +1 -0
- package/dist/DateField.d.ts +3 -3
- package/dist/DateField.d.ts.map +1 -1
- package/dist/DateField.js +4 -0
- package/dist/DateField.jsx +4 -0
- package/dist/DateField2.js +499 -0
- package/dist/DateField2.js.map +1 -0
- package/dist/DateField2.jsx +317 -0
- package/dist/DateField2.jsx.map +1 -0
- package/dist/DatePicker.d.ts +4 -4
- package/dist/DatePicker.d.ts.map +1 -1
- package/dist/DatePicker.js +991 -0
- package/dist/DatePicker.js.map +1 -0
- package/dist/DatePicker.jsx +682 -0
- package/dist/DatePicker.jsx.map +1 -0
- package/dist/Dialog.d.ts.map +1 -1
- package/dist/Dialog.js +337 -0
- package/dist/Dialog.js.map +1 -0
- package/dist/Dialog.jsx +192 -0
- package/dist/Dialog.jsx.map +1 -0
- package/dist/Disclosure.d.ts.map +1 -1
- package/dist/Disclosure.js +328 -0
- package/dist/Disclosure.js.map +1 -0
- package/dist/Disclosure.jsx +230 -0
- package/dist/Disclosure.jsx.map +1 -0
- package/dist/DragAndDrop.d.ts.map +1 -1
- package/dist/DragAndDrop.js +176 -0
- package/dist/DragAndDrop.js.map +1 -0
- package/dist/DragAndDrop.jsx +160 -0
- package/dist/DragAndDrop.jsx.map +1 -0
- package/dist/DropZone.d.ts.map +1 -1
- package/dist/DropZone.js +189 -0
- package/dist/DropZone.js.map +1 -0
- package/dist/DropZone.jsx +144 -0
- package/dist/DropZone.jsx.map +1 -0
- package/dist/FieldError.js +66 -0
- package/dist/FieldError.js.map +1 -0
- package/dist/FieldError.jsx +47 -0
- package/dist/FieldError.jsx.map +1 -0
- package/dist/FileTrigger.js +79 -0
- package/dist/FileTrigger.js.map +1 -0
- package/dist/FileTrigger.jsx +49 -0
- package/dist/FileTrigger.jsx.map +1 -0
- package/dist/Focusable.js +70 -0
- package/dist/Focusable.js.map +1 -0
- package/dist/Focusable.jsx +69 -0
- package/dist/Focusable.jsx.map +1 -0
- package/dist/Form.js +99 -0
- package/dist/Form.js.map +1 -0
- package/dist/Form.jsx +73 -0
- package/dist/Form.jsx.map +1 -0
- package/dist/GridList.d.ts +34 -2
- package/dist/GridList.d.ts.map +1 -1
- package/dist/GridList.js +723 -0
- package/dist/GridList.js.map +1 -0
- package/dist/GridList.jsx +552 -0
- package/dist/GridList.jsx.map +1 -0
- package/dist/HiddenTimeInput.js +104 -0
- package/dist/HiddenTimeInput.js.map +1 -0
- package/dist/HiddenTimeInput.jsx +69 -0
- package/dist/HiddenTimeInput.jsx.map +1 -0
- package/dist/Icon.d.ts.map +1 -1
- package/dist/Icon.js +127 -0
- package/dist/Icon.js.map +1 -0
- package/dist/Icon.jsx +72 -0
- package/dist/Icon.jsx.map +1 -0
- package/dist/Keyboard.js +30 -0
- package/dist/Keyboard.js.map +1 -0
- package/dist/Keyboard.jsx +24 -0
- package/dist/Keyboard.jsx.map +1 -0
- package/dist/Landmark.js +134 -0
- package/dist/Landmark.js.map +1 -0
- package/dist/Landmark.jsx +118 -0
- package/dist/Landmark.jsx.map +1 -0
- package/dist/Link.d.ts.map +1 -1
- package/dist/Link.js +219 -0
- package/dist/Link.js.map +1 -0
- package/dist/Link.jsx +189 -0
- package/dist/Link.jsx.map +1 -0
- package/dist/ListBox.d.ts.map +1 -1
- package/dist/ListBox.js +670 -0
- package/dist/ListBox.js.map +1 -0
- package/dist/ListBox.jsx +508 -0
- package/dist/ListBox.jsx.map +1 -0
- package/dist/Menu.d.ts +27 -9
- package/dist/Menu.d.ts.map +1 -1
- package/dist/Menu.js +1254 -0
- package/dist/Menu.js.map +1 -0
- package/dist/Menu.jsx +1042 -0
- package/dist/Menu.jsx.map +1 -0
- package/dist/Meter.d.ts.map +1 -1
- package/dist/Meter.js +123 -0
- package/dist/Meter.js.map +1 -0
- package/dist/Meter.jsx +107 -0
- package/dist/Meter.jsx.map +1 -0
- package/dist/Modal.d.ts.map +1 -1
- package/dist/Modal.js +380 -0
- package/dist/Modal.js.map +1 -0
- package/dist/Modal.jsx +314 -0
- package/dist/Modal.jsx.map +1 -0
- package/dist/NumberField.d.ts +3 -3
- package/dist/NumberField.d.ts.map +1 -1
- package/dist/NumberField.js +573 -0
- package/dist/NumberField.js.map +1 -0
- package/dist/NumberField.jsx +443 -0
- package/dist/NumberField.jsx.map +1 -0
- package/dist/Popover.d.ts +10 -2
- package/dist/Popover.d.ts.map +1 -1
- package/dist/Popover.js +464 -0
- package/dist/Popover.js.map +1 -0
- package/dist/Popover.jsx +333 -0
- package/dist/Popover.jsx.map +1 -0
- package/dist/Pressable.js +69 -0
- package/dist/Pressable.js.map +1 -0
- package/dist/Pressable.jsx +68 -0
- package/dist/Pressable.jsx.map +1 -0
- package/dist/ProgressBar.d.ts.map +1 -1
- package/dist/ProgressBar.js +130 -0
- package/dist/ProgressBar.js.map +1 -0
- package/dist/ProgressBar.jsx +114 -0
- package/dist/ProgressBar.jsx.map +1 -0
- package/dist/RadioGroup.d.ts +82 -4
- package/dist/RadioGroup.d.ts.map +1 -1
- package/dist/RadioGroup.js +931 -0
- package/dist/RadioGroup.js.map +1 -0
- package/dist/RadioGroup.jsx +681 -0
- package/dist/RadioGroup.jsx.map +1 -0
- package/dist/RangeCalendar.d.ts.map +1 -1
- package/dist/RangeCalendar.js +410 -0
- package/dist/RangeCalendar.js.map +1 -0
- package/dist/RangeCalendar.jsx +253 -0
- package/dist/RangeCalendar.jsx.map +1 -0
- package/dist/RouterProvider.js +118 -0
- package/dist/RouterProvider.js.map +1 -0
- package/dist/RouterProvider.jsx +112 -0
- package/dist/RouterProvider.jsx.map +1 -0
- package/dist/SearchField.d.ts +2 -2
- package/dist/SearchField.d.ts.map +1 -1
- package/dist/SearchField.js +643 -0
- package/dist/SearchField.js.map +1 -0
- package/dist/SearchField.jsx +526 -0
- package/dist/SearchField.jsx.map +1 -0
- package/dist/Select.d.ts.map +1 -1
- package/dist/Select.js +1031 -0
- package/dist/Select.js.map +1 -0
- package/dist/Select.jsx +744 -0
- package/dist/Select.jsx.map +1 -0
- package/dist/SelectionIndicator.d.ts.map +1 -1
- package/dist/SelectionIndicator.js +86 -0
- package/dist/SelectionIndicator.js.map +1 -0
- package/dist/SelectionIndicator.jsx +50 -0
- package/dist/SelectionIndicator.jsx.map +1 -0
- package/dist/Separator.js +97 -0
- package/dist/Separator.js.map +1 -0
- package/dist/Separator.jsx +85 -0
- package/dist/Separator.jsx.map +1 -0
- package/dist/SharedElementTransition.d.ts.map +1 -1
- package/dist/SharedElementTransition.js +165 -0
- package/dist/SharedElementTransition.js.map +1 -0
- package/dist/SharedElementTransition.jsx +138 -0
- package/dist/SharedElementTransition.jsx.map +1 -0
- package/dist/Slider.d.ts +33 -1
- package/dist/Slider.d.ts.map +1 -1
- package/dist/Slider.js +515 -0
- package/dist/Slider.js.map +1 -0
- package/dist/Slider.jsx +403 -0
- package/dist/Slider.jsx.map +1 -0
- package/dist/StepList.js +198 -0
- package/dist/StepList.js.map +1 -0
- package/dist/StepList.jsx +141 -0
- package/dist/StepList.jsx.map +1 -0
- package/dist/Switch.d.ts +65 -2
- package/dist/Switch.d.ts.map +1 -1
- package/dist/Switch.js +534 -0
- package/dist/Switch.js.map +1 -0
- package/dist/Switch.jsx +393 -0
- package/dist/Switch.jsx.map +1 -0
- package/dist/Table.d.ts +48 -0
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js +1759 -0
- package/dist/Table.js.map +1 -0
- package/dist/Table.jsx +1348 -0
- package/dist/Table.jsx.map +1 -0
- package/dist/Tabs.d.ts +0 -4
- package/dist/Tabs.d.ts.map +1 -1
- package/dist/Tabs.js +595 -0
- package/dist/Tabs.js.map +1 -0
- package/dist/Tabs.jsx +367 -0
- package/dist/Tabs.jsx.map +1 -0
- package/dist/TagGroup.d.ts.map +1 -1
- package/dist/TagGroup.js +378 -0
- package/dist/TagGroup.js.map +1 -0
- package/dist/TagGroup.jsx +270 -0
- package/dist/TagGroup.jsx.map +1 -0
- package/dist/Text.d.ts +18 -6
- package/dist/Text.d.ts.map +1 -1
- package/dist/Text.js +42 -0
- package/dist/Text.js.map +1 -0
- package/dist/Text.jsx +35 -0
- package/dist/Text.jsx.map +1 -0
- package/dist/TextField.d.ts +6 -6
- package/dist/TextField.d.ts.map +1 -1
- package/dist/TextField.js +436 -0
- package/dist/TextField.js.map +1 -0
- package/dist/TextField.jsx +403 -0
- package/dist/TextField.jsx.map +1 -0
- package/dist/TimeField.d.ts +3 -3
- package/dist/TimeField.d.ts.map +1 -1
- package/dist/TimeField.js +372 -0
- package/dist/TimeField.js.map +1 -0
- package/dist/TimeField.jsx +224 -0
- package/dist/TimeField.jsx.map +1 -0
- package/dist/Toast.d.ts +14 -0
- package/dist/Toast.d.ts.map +1 -1
- package/dist/Toast.js +551 -0
- package/dist/Toast.js.map +1 -0
- package/dist/Toast.jsx +361 -0
- package/dist/Toast.jsx.map +1 -0
- package/dist/ToggleButton.d.ts.map +1 -1
- package/dist/ToggleButton.js +123 -0
- package/dist/ToggleButton.js.map +1 -0
- package/dist/ToggleButton.jsx +88 -0
- package/dist/ToggleButton.jsx.map +1 -0
- package/dist/ToggleButtonGroup.d.ts.map +1 -1
- package/dist/ToggleButtonGroup.js +114 -0
- package/dist/ToggleButtonGroup.js.map +1 -0
- package/dist/ToggleButtonGroup.jsx +85 -0
- package/dist/ToggleButtonGroup.jsx.map +1 -0
- package/dist/Toolbar.js +112 -0
- package/dist/Toolbar.js.map +1 -0
- package/dist/Toolbar.jsx +92 -0
- package/dist/Toolbar.jsx.map +1 -0
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/Tooltip.js +539 -0
- package/dist/Tooltip.js.map +1 -0
- package/dist/Tooltip.jsx +465 -0
- package/dist/Tooltip.jsx.map +1 -0
- package/dist/Tree.d.ts +14 -2
- package/dist/Tree.d.ts.map +1 -1
- package/dist/Tree.js +1424 -0
- package/dist/Tree.js.map +1 -0
- package/dist/Tree.jsx +1172 -0
- package/dist/Tree.jsx.map +1 -0
- package/dist/Virtualizer.d.ts +16 -2
- package/dist/Virtualizer.d.ts.map +1 -1
- package/dist/Virtualizer.js +2 -0
- package/dist/Virtualizer.jsx +2 -0
- package/dist/Virtualizer2.js +751 -0
- package/dist/Virtualizer2.js.map +1 -0
- package/dist/Virtualizer2.jsx +730 -0
- package/dist/Virtualizer2.jsx.map +1 -0
- package/dist/VirtualizerLayouts.d.ts +18 -0
- package/dist/VirtualizerLayouts.d.ts.map +1 -1
- package/dist/VisuallyHidden.js +42 -0
- package/dist/VisuallyHidden.js.map +1 -0
- package/dist/VisuallyHidden.jsx +35 -0
- package/dist/VisuallyHidden.jsx.map +1 -0
- package/dist/contexts.js +33 -0
- package/dist/contexts.js.map +1 -0
- package/dist/contexts.jsx +33 -0
- package/dist/contexts.jsx.map +1 -0
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +70 -23932
- package/dist/index.jsx +70 -18337
- package/dist/useDragAndDrop.js +2 -0
- package/dist/useDragAndDrop.jsx +2 -0
- package/dist/useDragAndDrop2.js +395 -0
- package/dist/useDragAndDrop2.js.map +1 -0
- package/dist/useDragAndDrop2.jsx +395 -0
- package/dist/useDragAndDrop2.jsx.map +1 -0
- package/dist/utils.d.ts +83 -11
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +285 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.jsx +277 -0
- package/dist/utils.jsx.map +1 -0
- package/dist/virtualizer/Layout.js +144 -0
- package/dist/virtualizer/Layout.js.map +1 -0
- package/dist/virtualizer/Layout.jsx +144 -0
- package/dist/virtualizer/Layout.jsx.map +1 -0
- package/package.json +401 -4
- package/src/Breadcrumbs.tsx +3 -1
- package/src/Button.tsx +22 -2
- package/src/Calendar.tsx +27 -10
- package/src/CalendarPicker.tsx +73 -0
- package/src/Checkbox.tsx +539 -3
- package/src/Collection.tsx +9 -3
- package/src/Color.tsx +42 -14
- package/src/ComboBox.tsx +50 -6
- package/src/DateField.tsx +20 -2
- package/src/DatePicker.tsx +57 -5
- package/src/Dialog.tsx +13 -5
- package/src/Disclosure.tsx +3 -1
- package/src/DragAndDrop.tsx +3 -1
- package/src/DropZone.tsx +3 -1
- package/src/GridList.tsx +125 -24
- package/src/Icon.tsx +3 -1
- package/src/Link.tsx +3 -1
- package/src/ListBox.tsx +31 -4
- package/src/Menu.tsx +252 -128
- package/src/Meter.tsx +3 -1
- package/src/Modal.tsx +100 -52
- package/src/NumberField.tsx +51 -8
- package/src/Popover.tsx +40 -10
- package/src/ProgressBar.tsx +3 -1
- package/src/RadioGroup.tsx +468 -4
- package/src/RangeCalendar.tsx +3 -1
- package/src/SearchField.tsx +27 -3
- package/src/Select.tsx +22 -7
- package/src/SelectionIndicator.tsx +3 -1
- package/src/SharedElementTransition.tsx +3 -1
- package/src/Slider.tsx +159 -13
- package/src/Switch.tsx +395 -2
- package/src/Table.tsx +409 -95
- package/src/Tabs.tsx +16 -45
- package/src/TagGroup.tsx +3 -1
- package/src/Text.tsx +31 -10
- package/src/TextField.tsx +43 -5
- package/src/TimeField.tsx +20 -2
- package/src/Toast.tsx +79 -14
- package/src/ToggleButton.tsx +3 -1
- package/src/ToggleButtonGroup.tsx +3 -1
- package/src/Tooltip.tsx +3 -1
- package/src/Tree.tsx +77 -9
- package/src/Virtualizer.tsx +180 -31
- package/src/VirtualizerLayouts.ts +45 -10
- package/src/index.ts +50 -0
- package/src/utils.tsx +243 -27
- package/dist/index.js.map +0 -1
- package/dist/index.jsx.map +0 -1
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { dataAttr, useIsHydrated, useRenderProps } from "./utils.jsx";
|
|
2
|
+
import { VisuallyHidden } from "./VisuallyHidden.jsx";
|
|
3
|
+
import { For, Index, Show, createContext, createMemo, createSignal, splitProps, useContext } from "solid-js";
|
|
4
|
+
import { createCalendarGrid, createHover, createRangeCalendar, createRangeCalendarCell } from "@proyecto-viviana/solidaria";
|
|
5
|
+
import { createRangeCalendarState, endOfMonth, isSameMonth } from "@proyecto-viviana/solid-stately";
|
|
6
|
+
//#region src/RangeCalendar.tsx
|
|
7
|
+
/**
|
|
8
|
+
* RangeCalendar component for solidaria-components
|
|
9
|
+
*
|
|
10
|
+
* Pre-wired headless range calendar component that combines aria hooks.
|
|
11
|
+
* Port of react-aria-components/src/RangeCalendar.tsx
|
|
12
|
+
*/
|
|
13
|
+
function assignRef(ref, el) {
|
|
14
|
+
if (!ref) return;
|
|
15
|
+
if (typeof ref === "function") ref(el);
|
|
16
|
+
else ref.current = el;
|
|
17
|
+
}
|
|
18
|
+
const RangeCalendarContext = createContext(null);
|
|
19
|
+
const RangeCalendarStateContext = createContext(null);
|
|
20
|
+
const RangeCalendarGridMonthContext = createContext(null);
|
|
21
|
+
const RangeCalendarGridCellPositionContext = createContext(null);
|
|
22
|
+
function useRangeCalendarContext() {
|
|
23
|
+
const context = useContext(RangeCalendarContext);
|
|
24
|
+
if (!context) throw new Error("RangeCalendar components must be used within a RangeCalendar");
|
|
25
|
+
return context;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A range calendar displays a grid of days and allows users to select a contiguous range of dates.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* <RangeCalendar aria-label="Date range">
|
|
33
|
+
* <header>
|
|
34
|
+
* <RangeCalendarButton slot="previous">◀</RangeCalendarButton>
|
|
35
|
+
* <RangeCalendarHeading />
|
|
36
|
+
* <RangeCalendarButton slot="next">▶</RangeCalendarButton>
|
|
37
|
+
* </header>
|
|
38
|
+
* <RangeCalendarGrid>
|
|
39
|
+
* {(date) => <RangeCalendarCell date={date} />}
|
|
40
|
+
* </RangeCalendarGrid>
|
|
41
|
+
* </RangeCalendar>
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
function RangeCalendar(props) {
|
|
45
|
+
const isHydrated = useIsHydrated();
|
|
46
|
+
return <Show when={isHydrated()} fallback={<div class="solidaria-RangeCalendar solidaria-RangeCalendar--placeholder" aria-hidden="true" />}>
|
|
47
|
+
<RangeCalendarInner {...props} />
|
|
48
|
+
</Show>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Internal RangeCalendar component that renders after client mount.
|
|
52
|
+
*/
|
|
53
|
+
function RangeCalendarInner(props) {
|
|
54
|
+
const [local, stateProps, rest] = splitProps(props, [
|
|
55
|
+
"children",
|
|
56
|
+
"class",
|
|
57
|
+
"style",
|
|
58
|
+
"slot",
|
|
59
|
+
"ref"
|
|
60
|
+
], [
|
|
61
|
+
"value",
|
|
62
|
+
"defaultValue",
|
|
63
|
+
"onChange",
|
|
64
|
+
"minValue",
|
|
65
|
+
"maxValue",
|
|
66
|
+
"isDisabled",
|
|
67
|
+
"isReadOnly",
|
|
68
|
+
"focusedValue",
|
|
69
|
+
"defaultFocusedValue",
|
|
70
|
+
"onFocusChange",
|
|
71
|
+
"locale",
|
|
72
|
+
"createCalendar",
|
|
73
|
+
"isDateUnavailable",
|
|
74
|
+
"visibleMonths",
|
|
75
|
+
"pageBehavior",
|
|
76
|
+
"selectionAlignment",
|
|
77
|
+
"isDateDisabled",
|
|
78
|
+
"validationState",
|
|
79
|
+
"allowsNonContiguousRanges",
|
|
80
|
+
"firstDayOfWeek"
|
|
81
|
+
]);
|
|
82
|
+
const state = createRangeCalendarState(stateProps);
|
|
83
|
+
const calendarAria = createRangeCalendar(rest, state);
|
|
84
|
+
const renderValues = createMemo(() => ({
|
|
85
|
+
isDisabled: state.isDisabled(),
|
|
86
|
+
isReadOnly: state.isReadOnly(),
|
|
87
|
+
isInvalid: state.isValueInvalid(),
|
|
88
|
+
isDragging: state.isDragging()
|
|
89
|
+
}));
|
|
90
|
+
const renderProps = useRenderProps({
|
|
91
|
+
class: local.class,
|
|
92
|
+
style: local.style,
|
|
93
|
+
defaultClassName: "solidaria-RangeCalendar"
|
|
94
|
+
}, renderValues);
|
|
95
|
+
return <RangeCalendarStateContext.Provider value={state}>
|
|
96
|
+
<RangeCalendarContext.Provider value={state}>
|
|
97
|
+
<div {...calendarAria.calendarProps} ref={(el) => assignRef(local.ref, el)} class={renderProps.class()} style={renderProps.style()} data-disabled={dataAttr(state.isDisabled())} data-readonly={dataAttr(state.isReadOnly())} data-invalid={dataAttr(state.isValueInvalid())} data-dragging={dataAttr(state.isDragging())}>
|
|
98
|
+
<VisuallyHidden>
|
|
99
|
+
<h2>{String(calendarAria.calendarProps["aria-label"] ?? "")}</h2>
|
|
100
|
+
</VisuallyHidden>
|
|
101
|
+
{props.children}
|
|
102
|
+
</div>
|
|
103
|
+
</RangeCalendarContext.Provider>
|
|
104
|
+
</RangeCalendarStateContext.Provider>;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Displays the current month and year in the range calendar.
|
|
108
|
+
*/
|
|
109
|
+
function RangeCalendarHeading(props) {
|
|
110
|
+
const state = useRangeCalendarContext();
|
|
111
|
+
return <h2 class={props.class ?? "solidaria-RangeCalendarHeading"} style={props.style} aria-live="polite">
|
|
112
|
+
{state.title()}
|
|
113
|
+
</h2>;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* A button for navigating the range calendar.
|
|
117
|
+
*/
|
|
118
|
+
function RangeCalendarButton(props) {
|
|
119
|
+
const state = useRangeCalendarContext();
|
|
120
|
+
const calendarAria = createRangeCalendar({}, state);
|
|
121
|
+
const buttonProps = createMemo(() => {
|
|
122
|
+
if (props.slot === "previous") return calendarAria.prevButtonProps;
|
|
123
|
+
return calendarAria.nextButtonProps;
|
|
124
|
+
});
|
|
125
|
+
const isDisabled = createMemo(() => props.isDisabled || Boolean(buttonProps().disabled) || state.isDisabled());
|
|
126
|
+
return <button {...buttonProps()} class={props.class ?? "solidaria-RangeCalendarButton"} style={props.style} disabled={isDisabled()}>
|
|
127
|
+
{props.children}
|
|
128
|
+
</button>;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Displays a grid of range calendar cells.
|
|
132
|
+
*/
|
|
133
|
+
function RangeCalendarGrid(props) {
|
|
134
|
+
const state = useRangeCalendarContext();
|
|
135
|
+
const [gridRef, setGridRef] = createSignal(null);
|
|
136
|
+
const startDate = createMemo(() => {
|
|
137
|
+
const offsetMonths = props.offset?.months ?? 0;
|
|
138
|
+
const baseStart = state.visibleRange().start;
|
|
139
|
+
return offsetMonths ? baseStart.add({ months: offsetMonths }) : baseStart;
|
|
140
|
+
});
|
|
141
|
+
const gridAria = createCalendarGrid({
|
|
142
|
+
startDate: startDate(),
|
|
143
|
+
endDate: endOfMonth(startDate()),
|
|
144
|
+
weekdayStyle: props.weekdayStyle
|
|
145
|
+
}, state, gridRef);
|
|
146
|
+
const renderValues = createMemo(() => ({ isDisabled: state.isDisabled() }));
|
|
147
|
+
const renderProps = useRenderProps({
|
|
148
|
+
class: props.class,
|
|
149
|
+
style: props.style,
|
|
150
|
+
defaultClassName: "solidaria-RangeCalendarGrid"
|
|
151
|
+
}, renderValues);
|
|
152
|
+
const allDates = createMemo(() => {
|
|
153
|
+
const monthStart = startDate();
|
|
154
|
+
const numWeeks = state.getWeeksInMonth(monthStart);
|
|
155
|
+
const weekDates = [];
|
|
156
|
+
for (let weekIndex = 0; weekIndex < numWeeks; weekIndex++) weekDates.push(state.getDatesInWeek(weekIndex, monthStart));
|
|
157
|
+
return weekDates;
|
|
158
|
+
});
|
|
159
|
+
return <RangeCalendarGridMonthContext.Provider value={startDate}>
|
|
160
|
+
<table ref={setGridRef} {...gridAria.gridProps} class={renderProps.class()} style={renderProps.style()}>
|
|
161
|
+
<thead {...gridAria.headerProps}>
|
|
162
|
+
<tr>
|
|
163
|
+
<For each={gridAria.weekDays}>
|
|
164
|
+
{(day) => <th scope="col" class={props.headerCellClass ?? "solidaria-RangeCalendarHeaderCell"} style={props.headerCellStyle}>
|
|
165
|
+
{day}
|
|
166
|
+
</th>}
|
|
167
|
+
</For>
|
|
168
|
+
</tr>
|
|
169
|
+
</thead>
|
|
170
|
+
<tbody>
|
|
171
|
+
<Index each={allDates()}>
|
|
172
|
+
{(weekDates, weekIndex) => <tr>
|
|
173
|
+
<Index each={weekDates()}>
|
|
174
|
+
{(date, dayIndex) => <Show when={date()} fallback={<td />}>
|
|
175
|
+
<RangeCalendarGridCellPositionContext.Provider value={() => ({
|
|
176
|
+
weekIndex,
|
|
177
|
+
dayIndex,
|
|
178
|
+
lastWeekIndex: allDates().length - 1
|
|
179
|
+
})}>
|
|
180
|
+
{props.children?.(date())}
|
|
181
|
+
</RangeCalendarGridCellPositionContext.Provider>
|
|
182
|
+
</Show>}
|
|
183
|
+
</Index>
|
|
184
|
+
</tr>}
|
|
185
|
+
</Index>
|
|
186
|
+
</tbody>
|
|
187
|
+
</table>
|
|
188
|
+
</RangeCalendarGridMonthContext.Provider>;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* A cell in the range calendar grid representing a single day.
|
|
192
|
+
*/
|
|
193
|
+
function RangeCalendarCell(props) {
|
|
194
|
+
const state = useRangeCalendarContext();
|
|
195
|
+
const currentMonthStart = useContext(RangeCalendarGridMonthContext);
|
|
196
|
+
const cellPosition = useContext(RangeCalendarGridCellPositionContext);
|
|
197
|
+
const [cellRef, setCellRef] = createSignal(null);
|
|
198
|
+
const isOutsideMonth = createMemo(() => currentMonthStart != null && !isSameMonth(currentMonthStart(), props.date));
|
|
199
|
+
const position = createMemo(() => cellPosition?.() ?? {
|
|
200
|
+
weekIndex: 0,
|
|
201
|
+
dayIndex: 0,
|
|
202
|
+
lastWeekIndex: 0
|
|
203
|
+
});
|
|
204
|
+
const cellAria = createRangeCalendarCell(() => ({
|
|
205
|
+
date: props.date,
|
|
206
|
+
isOutsideMonth: isOutsideMonth()
|
|
207
|
+
}), state, cellRef);
|
|
208
|
+
const { hoverProps, isHovered } = createHover(() => ({ isDisabled: cellAria.isDisabled || cellAria.isUnavailable }));
|
|
209
|
+
const renderValues = createMemo(() => ({
|
|
210
|
+
isSelected: cellAria.isSelected,
|
|
211
|
+
isSelectionStart: cellAria.isSelectionStart,
|
|
212
|
+
isSelectionEnd: cellAria.isSelectionEnd,
|
|
213
|
+
isFocused: cellAria.isFocused,
|
|
214
|
+
isDisabled: cellAria.isDisabled,
|
|
215
|
+
isUnavailable: cellAria.isUnavailable,
|
|
216
|
+
isInvalid: cellAria.isInvalid,
|
|
217
|
+
isOutsideMonth: cellAria.isOutsideMonth,
|
|
218
|
+
isToday: cellAria.isToday,
|
|
219
|
+
isPressed: cellAria.isPressed,
|
|
220
|
+
isHovered: isHovered(),
|
|
221
|
+
isFirstChild: position().dayIndex === 0,
|
|
222
|
+
isLastChild: position().dayIndex === 6,
|
|
223
|
+
isFirstWeek: position().weekIndex === 0,
|
|
224
|
+
isLastWeek: position().weekIndex === position().lastWeekIndex,
|
|
225
|
+
formattedDate: cellAria.formattedDate
|
|
226
|
+
}));
|
|
227
|
+
const renderProps = useRenderProps({
|
|
228
|
+
get children() {
|
|
229
|
+
return props.children;
|
|
230
|
+
},
|
|
231
|
+
class: props.class,
|
|
232
|
+
style: props.style,
|
|
233
|
+
defaultClassName: "solidaria-RangeCalendarCell"
|
|
234
|
+
}, renderValues);
|
|
235
|
+
const cellRenderProps = useRenderProps({
|
|
236
|
+
class: props.cellClass,
|
|
237
|
+
style: props.cellStyle,
|
|
238
|
+
defaultClassName: "solidaria-RangeCalendarCellWrapper"
|
|
239
|
+
}, renderValues);
|
|
240
|
+
const getChildren = () => {
|
|
241
|
+
if (typeof props.children === "function") return renderProps.renderChildren();
|
|
242
|
+
return cellAria.formattedDate;
|
|
243
|
+
};
|
|
244
|
+
return <td {...cellAria.cellProps} class={cellRenderProps.class()} style={cellRenderProps.style()}>
|
|
245
|
+
<div ref={setCellRef} {...cellAria.buttonProps} {...hoverProps} class={renderProps.class()} style={renderProps.style()} data-selected={dataAttr(cellAria.isSelected)} data-selection-start={dataAttr(cellAria.isSelectionStart)} data-selection-end={dataAttr(cellAria.isSelectionEnd)} data-focused={dataAttr(cellAria.isFocused)} data-disabled={dataAttr(cellAria.isDisabled)} data-unavailable={dataAttr(cellAria.isUnavailable)} data-invalid={dataAttr(cellAria.isInvalid)} data-outside-month={dataAttr(cellAria.isOutsideMonth)} data-today={dataAttr(cellAria.isToday)} data-pressed={dataAttr(cellAria.isPressed)} data-hovered={dataAttr(isHovered())}>
|
|
246
|
+
{getChildren()}
|
|
247
|
+
</div>
|
|
248
|
+
</td>;
|
|
249
|
+
}
|
|
250
|
+
//#endregion
|
|
251
|
+
export { RangeCalendar, RangeCalendarButton, RangeCalendarCell, RangeCalendarContext, RangeCalendarGrid, RangeCalendarHeading, RangeCalendarStateContext, useRangeCalendarContext };
|
|
252
|
+
|
|
253
|
+
//# sourceMappingURL=RangeCalendar.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RangeCalendar.jsx","names":[],"sources":["../src/RangeCalendar.tsx"],"sourcesContent":["/**\n * RangeCalendar component for solidaria-components\n *\n * Pre-wired headless range calendar component that combines aria hooks.\n * Port of react-aria-components/src/RangeCalendar.tsx\n */\n\nimport {\n type JSX,\n type Accessor,\n createContext,\n createMemo,\n createSignal,\n splitProps,\n useContext,\n For,\n Index,\n Show,\n} from \"solid-js\";\nimport {\n createRangeCalendar,\n createCalendarGrid,\n createRangeCalendarCell,\n createHover,\n type AriaRangeCalendarProps,\n type AriaCalendarGridProps,\n} from \"@proyecto-viviana/solidaria\";\nimport {\n createRangeCalendarState,\n type RangeCalendarState,\n type RangeCalendarStateProps,\n type CalendarDate,\n type DateValue,\n type RangeValue,\n endOfMonth,\n isSameMonth,\n} from \"@proyecto-viviana/solid-stately\";\nimport {\n type RenderChildren,\n type ClassNameOrFunction,\n type StyleOrFunction,\n type SlotProps,\n useRenderProps,\n dataAttr,\n useIsHydrated,\n} from \"./utils\";\nimport { VisuallyHidden } from \"./VisuallyHidden\";\n\ntype RefLike<T> = ((el: T) => void) | { current?: T | null } | undefined;\n\nfunction assignRef<T>(ref: RefLike<T>, el: T): void {\n if (!ref) {\n return;\n }\n\n if (typeof ref === \"function\") {\n ref(el);\n } else {\n ref.current = el;\n }\n}\n\nexport interface RangeCalendarRenderProps {\n /** Whether the calendar is disabled. */\n isDisabled: boolean;\n /** Whether the calendar is read-only. */\n isReadOnly: boolean;\n /** Whether the current selection is invalid. */\n isInvalid: boolean;\n /** Whether the user is currently selecting a range. */\n isDragging: boolean;\n}\n\nexport interface RangeCalendarProps<T extends DateValue = DateValue>\n extends\n Omit<AriaRangeCalendarProps, \"id\" | \"isDisabled\" | \"isReadOnly\">,\n Omit<RangeCalendarStateProps<T>, \"locale\">,\n SlotProps {\n /** The children of the component. */\n children?: JSX.Element;\n /** The CSS className for the element. */\n class?: ClassNameOrFunction<RangeCalendarRenderProps>;\n /** The inline style for the element. */\n style?: StyleOrFunction<RangeCalendarRenderProps>;\n /** The locale to use for formatting. */\n locale?: string;\n /** Ref for the range calendar root element. */\n ref?: RefLike<HTMLDivElement>;\n}\n\nexport interface RangeCalendarGridRenderProps {\n /** Whether the grid is disabled. */\n isDisabled: boolean;\n}\n\nexport interface RangeCalendarGridProps\n extends Omit<AriaCalendarGridProps, \"startDate\" | \"endDate\">, SlotProps {\n /** The children of the component (render function receiving dates). */\n children?: (date: CalendarDate) => JSX.Element;\n /** The CSS className for the element. */\n class?: ClassNameOrFunction<RangeCalendarGridRenderProps>;\n /** The inline style for the element. */\n style?: StyleOrFunction<RangeCalendarGridRenderProps>;\n /** Class name for weekday header cells. */\n headerCellClass?: string;\n /** Inline style for weekday header cells. */\n headerCellStyle?: JSX.CSSProperties;\n /** Number of months to offset from the start. */\n offset?: { months?: number };\n}\n\nexport interface RangeCalendarCellRenderProps {\n /** Whether the cell is within the selected range. */\n isSelected: boolean;\n /** Whether the cell is the start of the selection. */\n isSelectionStart: boolean;\n /** Whether the cell is the end of the selection. */\n isSelectionEnd: boolean;\n /** Whether the cell is focused. */\n isFocused: boolean;\n /** Whether the cell is disabled. */\n isDisabled: boolean;\n /** Whether the cell is unavailable. */\n isUnavailable: boolean;\n /** Whether the cell is part of an invalid selection. */\n isInvalid: boolean;\n /** Whether the cell is outside the visible month. */\n isOutsideMonth: boolean;\n /** Whether the cell represents today. */\n isToday: boolean;\n /** Whether the cell is pressed. */\n isPressed: boolean;\n /** Whether the cell is hovered. */\n isHovered: boolean;\n /** Whether the cell is the first day slot in its row. */\n isFirstChild: boolean;\n /** Whether the cell is the last day slot in its row. */\n isLastChild: boolean;\n /** Whether the cell is in the first rendered week row. */\n isFirstWeek: boolean;\n /** Whether the cell is in the last rendered week row. */\n isLastWeek: boolean;\n /** The formatted date string. */\n formattedDate: string;\n}\n\nexport interface RangeCalendarCellProps extends SlotProps {\n /** The date for this cell. */\n date: CalendarDate;\n /** The children of the component. A function may be provided to receive render props. */\n children?: RenderChildren<RangeCalendarCellRenderProps>;\n /** The CSS className for the element. */\n class?: ClassNameOrFunction<RangeCalendarCellRenderProps>;\n /** The inline style for the element. */\n style?: StyleOrFunction<RangeCalendarCellRenderProps>;\n /** Class name for the table cell wrapper. */\n cellClass?: ClassNameOrFunction<RangeCalendarCellRenderProps>;\n /** Inline style for the table cell wrapper. */\n cellStyle?: StyleOrFunction<RangeCalendarCellRenderProps>;\n}\n\nexport const RangeCalendarContext = createContext<RangeCalendarState<DateValue> | null>(null);\nexport const RangeCalendarStateContext = createContext<RangeCalendarState<DateValue> | null>(null);\nconst RangeCalendarGridMonthContext = createContext<Accessor<CalendarDate> | null>(null);\nconst RangeCalendarGridCellPositionContext = createContext<Accessor<{\n weekIndex: number;\n dayIndex: number;\n lastWeekIndex: number;\n}> | null>(null);\n\nexport function useRangeCalendarContext(): RangeCalendarState<DateValue> {\n const context = useContext(RangeCalendarContext);\n if (!context) {\n throw new Error(\"RangeCalendar components must be used within a RangeCalendar\");\n }\n return context;\n}\n\n/**\n * A range calendar displays a grid of days and allows users to select a contiguous range of dates.\n *\n * @example\n * ```tsx\n * <RangeCalendar aria-label=\"Date range\">\n * <header>\n * <RangeCalendarButton slot=\"previous\">◀</RangeCalendarButton>\n * <RangeCalendarHeading />\n * <RangeCalendarButton slot=\"next\">▶</RangeCalendarButton>\n * </header>\n * <RangeCalendarGrid>\n * {(date) => <RangeCalendarCell date={date} />}\n * </RangeCalendarGrid>\n * </RangeCalendar>\n * ```\n */\nexport function RangeCalendar<T extends DateValue = CalendarDate>(\n props: RangeCalendarProps<T>,\n): JSX.Element {\n // Use hydration-safe pattern for client-only rendering\n const isHydrated = useIsHydrated();\n\n return (\n <Show\n when={isHydrated()}\n fallback={\n <div\n class=\"solidaria-RangeCalendar solidaria-RangeCalendar--placeholder\"\n aria-hidden=\"true\"\n />\n }\n >\n <RangeCalendarInner {...props} />\n </Show>\n );\n}\n\n/**\n * Internal RangeCalendar component that renders after client mount.\n */\nfunction RangeCalendarInner<T extends DateValue = CalendarDate>(\n props: RangeCalendarProps<T>,\n): JSX.Element {\n const [local, stateProps, rest] = splitProps(\n props,\n [\"children\", \"class\", \"style\", \"slot\", \"ref\"],\n [\n \"value\",\n \"defaultValue\",\n \"onChange\",\n \"minValue\",\n \"maxValue\",\n \"isDisabled\",\n \"isReadOnly\",\n \"focusedValue\",\n \"defaultFocusedValue\",\n \"onFocusChange\",\n \"locale\",\n \"createCalendar\",\n \"isDateUnavailable\",\n \"visibleMonths\",\n \"pageBehavior\",\n \"selectionAlignment\",\n \"isDateDisabled\",\n \"validationState\",\n \"allowsNonContiguousRanges\",\n \"firstDayOfWeek\",\n ],\n );\n\n const state = createRangeCalendarState(stateProps);\n\n const calendarAria = createRangeCalendar(rest, state as unknown as RangeCalendarState<DateValue>);\n\n const renderValues = createMemo<RangeCalendarRenderProps>(() => ({\n isDisabled: state.isDisabled(),\n isReadOnly: state.isReadOnly(),\n isInvalid: state.isValueInvalid(),\n isDragging: state.isDragging(),\n }));\n\n const renderProps = useRenderProps(\n {\n class: local.class,\n style: local.style,\n defaultClassName: \"solidaria-RangeCalendar\",\n },\n renderValues,\n );\n\n return (\n <RangeCalendarStateContext.Provider value={state as unknown as RangeCalendarState<DateValue>}>\n <RangeCalendarContext.Provider value={state as unknown as RangeCalendarState<DateValue>}>\n <div\n {...calendarAria.calendarProps}\n ref={(el) => assignRef(local.ref, el)}\n class={renderProps.class()}\n style={renderProps.style()}\n data-disabled={dataAttr(state.isDisabled())}\n data-readonly={dataAttr(state.isReadOnly())}\n data-invalid={dataAttr(state.isValueInvalid())}\n data-dragging={dataAttr(state.isDragging())}\n >\n <VisuallyHidden>\n <h2>{String(calendarAria.calendarProps[\"aria-label\"] ?? \"\")}</h2>\n </VisuallyHidden>\n {props.children}\n </div>\n </RangeCalendarContext.Provider>\n </RangeCalendarStateContext.Provider>\n );\n}\n\nexport interface RangeCalendarHeadingProps extends SlotProps {\n /** The CSS className for the element. */\n class?: string;\n /** The inline style for the element. */\n style?: JSX.CSSProperties;\n}\n\n/**\n * Displays the current month and year in the range calendar.\n */\nexport function RangeCalendarHeading(props: RangeCalendarHeadingProps): JSX.Element {\n const state = useRangeCalendarContext();\n\n return (\n <h2\n class={props.class ?? \"solidaria-RangeCalendarHeading\"}\n style={props.style}\n aria-live=\"polite\"\n >\n {state.title()}\n </h2>\n );\n}\n\nexport interface RangeCalendarButtonProps extends SlotProps {\n /** The slot for this button (previous or next). */\n slot?: \"previous\" | \"next\";\n /** The children of the component. */\n children?: JSX.Element;\n /** The CSS className for the element. */\n class?: string;\n /** The inline style for the element. */\n style?: JSX.CSSProperties;\n /** Whether the button is disabled. */\n isDisabled?: boolean;\n}\n\n/**\n * A button for navigating the range calendar.\n */\nexport function RangeCalendarButton(props: RangeCalendarButtonProps): JSX.Element {\n const state = useRangeCalendarContext();\n const calendarAria = createRangeCalendar({}, state);\n\n const buttonProps = createMemo(() => {\n if (props.slot === \"previous\") {\n return calendarAria.prevButtonProps;\n }\n return calendarAria.nextButtonProps;\n });\n const isDisabled = createMemo(\n () => props.isDisabled || Boolean(buttonProps().disabled) || state.isDisabled(),\n );\n\n return (\n <button\n {...buttonProps()}\n class={props.class ?? \"solidaria-RangeCalendarButton\"}\n style={props.style}\n disabled={isDisabled()}\n >\n {props.children}\n </button>\n );\n}\n\n/**\n * Displays a grid of range calendar cells.\n */\nexport function RangeCalendarGrid(props: RangeCalendarGridProps): JSX.Element {\n const state = useRangeCalendarContext();\n const [gridRef, setGridRef] = createSignal<HTMLTableElement | null>(null);\n const startDate = createMemo(() => {\n const offsetMonths = props.offset?.months ?? 0;\n const baseStart = state.visibleRange().start;\n return offsetMonths ? baseStart.add({ months: offsetMonths }) : baseStart;\n });\n\n const gridAria = createCalendarGrid(\n {\n startDate: startDate(),\n endDate: endOfMonth(startDate()),\n weekdayStyle: props.weekdayStyle,\n },\n state as unknown as Parameters<typeof createCalendarGrid>[1],\n gridRef,\n );\n\n const renderValues = createMemo<RangeCalendarGridRenderProps>(() => ({\n isDisabled: state.isDisabled(),\n }));\n\n const renderProps = useRenderProps(\n {\n class: props.class,\n style: props.style,\n defaultClassName: \"solidaria-RangeCalendarGrid\",\n },\n renderValues,\n );\n\n // Memoize all dates for the grid to avoid reactive loops in render paths.\n const allDates = createMemo(() => {\n const monthStart = startDate();\n const numWeeks = state.getWeeksInMonth(monthStart);\n const weekDates: (CalendarDate | null)[][] = [];\n\n for (let weekIndex = 0; weekIndex < numWeeks; weekIndex++) {\n weekDates.push(state.getDatesInWeek(weekIndex, monthStart));\n }\n\n return weekDates;\n });\n\n return (\n <RangeCalendarGridMonthContext.Provider value={startDate}>\n <table\n ref={setGridRef}\n {...gridAria.gridProps}\n class={renderProps.class()}\n style={renderProps.style()}\n >\n <thead {...gridAria.headerProps}>\n <tr>\n <For each={gridAria.weekDays}>\n {(day) => (\n <th\n scope=\"col\"\n class={props.headerCellClass ?? \"solidaria-RangeCalendarHeaderCell\"}\n style={props.headerCellStyle}\n >\n {day}\n </th>\n )}\n </For>\n </tr>\n </thead>\n <tbody>\n <Index each={allDates()}>\n {(weekDates, weekIndex) => (\n <tr>\n <Index each={weekDates()}>\n {(date, dayIndex) => (\n <Show when={date()} fallback={<td />}>\n <RangeCalendarGridCellPositionContext.Provider\n value={() => ({\n weekIndex,\n dayIndex,\n lastWeekIndex: allDates().length - 1,\n })}\n >\n {props.children?.(date()!)}\n </RangeCalendarGridCellPositionContext.Provider>\n </Show>\n )}\n </Index>\n </tr>\n )}\n </Index>\n </tbody>\n </table>\n </RangeCalendarGridMonthContext.Provider>\n );\n}\n\n/**\n * A cell in the range calendar grid representing a single day.\n */\nexport function RangeCalendarCell(props: RangeCalendarCellProps): JSX.Element {\n const state = useRangeCalendarContext();\n const currentMonthStart = useContext(RangeCalendarGridMonthContext);\n const cellPosition = useContext(RangeCalendarGridCellPositionContext);\n const [cellRef, setCellRef] = createSignal<HTMLDivElement | null>(null);\n const isOutsideMonth = createMemo(\n () => currentMonthStart != null && !isSameMonth(currentMonthStart(), props.date),\n );\n const position = createMemo(\n () =>\n cellPosition?.() ?? {\n weekIndex: 0,\n dayIndex: 0,\n lastWeekIndex: 0,\n },\n );\n\n const cellAria = createRangeCalendarCell(\n () => ({\n date: props.date,\n isOutsideMonth: isOutsideMonth(),\n }),\n state,\n cellRef,\n );\n const { hoverProps, isHovered } = createHover(() => ({\n isDisabled: cellAria.isDisabled || cellAria.isUnavailable,\n }));\n\n const renderValues = createMemo<RangeCalendarCellRenderProps>(() => ({\n isSelected: cellAria.isSelected,\n isSelectionStart: cellAria.isSelectionStart,\n isSelectionEnd: cellAria.isSelectionEnd,\n isFocused: cellAria.isFocused,\n isDisabled: cellAria.isDisabled,\n isUnavailable: cellAria.isUnavailable,\n isInvalid: cellAria.isInvalid,\n isOutsideMonth: cellAria.isOutsideMonth,\n isToday: cellAria.isToday,\n isPressed: cellAria.isPressed,\n isHovered: isHovered(),\n isFirstChild: position().dayIndex === 0,\n isLastChild: position().dayIndex === 6,\n isFirstWeek: position().weekIndex === 0,\n isLastWeek: position().weekIndex === position().lastWeekIndex,\n formattedDate: cellAria.formattedDate,\n }));\n\n const renderProps = useRenderProps(\n {\n get children() {\n return props.children;\n },\n class: props.class,\n style: props.style,\n defaultClassName: \"solidaria-RangeCalendarCell\",\n },\n renderValues,\n );\n const cellRenderProps = useRenderProps(\n {\n class: props.cellClass,\n style: props.cellStyle,\n defaultClassName: \"solidaria-RangeCalendarCellWrapper\",\n },\n renderValues,\n );\n\n // Determine children content - avoid Show for SSR hydration compatibility\n const getChildren = () => {\n if (typeof props.children === \"function\") {\n return renderProps.renderChildren();\n }\n return cellAria.formattedDate;\n };\n\n return (\n <td {...cellAria.cellProps} class={cellRenderProps.class()} style={cellRenderProps.style()}>\n <div\n ref={setCellRef}\n {...cellAria.buttonProps}\n {...hoverProps}\n class={renderProps.class()}\n style={renderProps.style()}\n data-selected={dataAttr(cellAria.isSelected)}\n data-selection-start={dataAttr(cellAria.isSelectionStart)}\n data-selection-end={dataAttr(cellAria.isSelectionEnd)}\n data-focused={dataAttr(cellAria.isFocused)}\n data-disabled={dataAttr(cellAria.isDisabled)}\n data-unavailable={dataAttr(cellAria.isUnavailable)}\n data-invalid={dataAttr(cellAria.isInvalid)}\n data-outside-month={dataAttr(cellAria.isOutsideMonth)}\n data-today={dataAttr(cellAria.isToday)}\n data-pressed={dataAttr(cellAria.isPressed)}\n data-hovered={dataAttr(isHovered())}\n >\n {getChildren()}\n </div>\n </td>\n );\n}\n\nexport type { RangeCalendarState, RangeValue };\n"],"mappings":";;;;;;;;;;;;AAkDA,SAAS,UAAa,KAAiB,IAAa;CAClD,IAAI,CAAC,KACH;CAGF,IAAI,OAAO,QAAQ,YACjB,IAAI,EAAE;MAEN,IAAI,UAAU;AAElB;AAqGA,MAAa,uBAAuB,cAAoD,IAAI;AAC5F,MAAa,4BAA4B,cAAoD,IAAI;AACjG,MAAM,gCAAgC,cAA6C,IAAI;AACvF,MAAM,uCAAuC,cAIlC,IAAI;AAEf,SAAgB,0BAAyD;CACvE,MAAM,UAAU,WAAW,oBAAoB;CAC/C,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,8DAA8D;CAEhF,OAAO;AACT;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,cACd,OACa;CAEb,MAAM,aAAa,cAAc;CAEjC,OACE,CAAC,KACC,MAAM,WAAW,GACjB,UACE,CAAC,IACC,qEACA,uBAGL;MACC,CAAC,uBAAuB,SAAS;IACnC,EAAE;AAEN;;;;AAKA,SAAS,mBACP,OACa;CACb,MAAM,CAAC,OAAO,YAAY,QAAQ,WAChC,OACA;EAAC;EAAY;EAAS;EAAS;EAAQ;CAAK,GAC5C;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,MAAM,QAAQ,yBAAyB,UAAU;CAEjD,MAAM,eAAe,oBAAoB,MAAM,KAAiD;CAEhG,MAAM,eAAe,kBAA4C;EAC/D,YAAY,MAAM,WAAW;EAC7B,YAAY,MAAM,WAAW;EAC7B,WAAW,MAAM,eAAe;EAChC,YAAY,MAAM,WAAW;CAC/B,EAAE;CAEF,MAAM,cAAc,eAClB;EACE,OAAO,MAAM;EACb,OAAO,MAAM;EACb,kBAAkB;CACpB,GACA,YACF;CAEA,OACE,CAAC,0BAA0B,SAAS,OAAO,OAAmD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,MAAM;EACf;EACA,OAAO,MAAM;EACb,OAAO,MAAM;EACb,kBAAkB;CACpB,GACA,YACF;CACA,MAAM,kBAAkB,eACtB;EACE,OAAO,MAAM;EACb,OAAO,MAAM;EACb,kBAAkB;CACpB,GACA,YACF;CAGA,MAAM,oBAAoB;EACxB,IAAI,OAAO,MAAM,aAAa,YAC5B,OAAO,YAAY,eAAe;EAEpC,OAAO,SAAS;CAClB;CAEA,OACE,CAAC,OAAO,SAAS,WAAW,OAAO,gBAAgB,MAAM,GAAG,OAAO,gBAAgB,MAAM,GAAG;MAC1F,CAAC,IACC,KAAK,gBACD,SAAS,iBACT,YACJ,OAAO,YAAY,MAAM,GACzB,OAAO,YAAY,MAAM,GACzB,eAAe,SAAS,SAAS,UAAU,GAC3C,sBAAsB,SAAS,SAAS,gBAAgB,GACxD,oBAAoB,SAAS,SAAS,cAAc,GACpD,cAAc,SAAS,SAAS,SAAS,GACzC,eAAe,SAAS,SAAS,UAAU,GAC3C,kBAAkB,SAAS,SAAS,aAAa,GACjD,cAAc,SAAS,SAAS,SAAS,GACzC,oBAAoB,SAAS,SAAS,cAAc,GACpD,YAAY,SAAS,SAAS,OAAO,GACrC,cAAc,SAAS,SAAS,SAAS,GACzC,cAAc,SAAS,UAAU,CAAC,GACnC;SACE,YAAY,EAAE;MACjB,EAAE,IAAI;IACR,EAAE;AAEN"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { createComponent } from "solid-js/web";
|
|
2
|
+
import { createContext, useContext } from "solid-js";
|
|
3
|
+
const RouterContext = createContext({
|
|
4
|
+
isNative: true,
|
|
5
|
+
navigate: () => {},
|
|
6
|
+
open: (target, modifiers) => {
|
|
7
|
+
openSyntheticLink(target, modifiers);
|
|
8
|
+
},
|
|
9
|
+
useHref: (href) => href
|
|
10
|
+
});
|
|
11
|
+
function shouldClientNavigate(link, modifiers) {
|
|
12
|
+
const target = link.getAttribute("target");
|
|
13
|
+
const sameOrigin = typeof location === "undefined" ? true : link.origin === location.origin;
|
|
14
|
+
return (!target || target === "_self") && sameOrigin && !link.hasAttribute("download") && !modifiers.metaKey && !modifiers.ctrlKey && !modifiers.altKey && !modifiers.shiftKey;
|
|
15
|
+
}
|
|
16
|
+
function openLink(target, modifiers) {
|
|
17
|
+
const event = new MouseEvent("click", {
|
|
18
|
+
metaKey: modifiers.metaKey,
|
|
19
|
+
ctrlKey: modifiers.ctrlKey,
|
|
20
|
+
altKey: modifiers.altKey,
|
|
21
|
+
shiftKey: modifiers.shiftKey,
|
|
22
|
+
detail: 1,
|
|
23
|
+
bubbles: true,
|
|
24
|
+
cancelable: true
|
|
25
|
+
});
|
|
26
|
+
target.dispatchEvent(event);
|
|
27
|
+
}
|
|
28
|
+
function getSyntheticLink(target, open) {
|
|
29
|
+
if (target instanceof HTMLAnchorElement) {
|
|
30
|
+
open(target);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const href = target.getAttribute("data-href");
|
|
34
|
+
if (!href) return;
|
|
35
|
+
const link = document.createElement("a");
|
|
36
|
+
link.href = href;
|
|
37
|
+
const targetValue = target.getAttribute("data-target");
|
|
38
|
+
if (targetValue) link.target = targetValue;
|
|
39
|
+
const rel = target.getAttribute("data-rel");
|
|
40
|
+
if (rel) link.rel = rel;
|
|
41
|
+
const download = target.getAttribute("data-download");
|
|
42
|
+
if (download) link.download = download;
|
|
43
|
+
const ping = target.getAttribute("data-ping");
|
|
44
|
+
if (ping) link.ping = ping;
|
|
45
|
+
const referrerPolicy = target.getAttribute("data-referrer-policy");
|
|
46
|
+
if (referrerPolicy) link.referrerPolicy = referrerPolicy;
|
|
47
|
+
target.appendChild(link);
|
|
48
|
+
open(link);
|
|
49
|
+
target.removeChild(link);
|
|
50
|
+
}
|
|
51
|
+
function openSyntheticLink(target, modifiers) {
|
|
52
|
+
getSyntheticLink(target, (link) => openLink(link, modifiers));
|
|
53
|
+
}
|
|
54
|
+
function useLinkProps(props) {
|
|
55
|
+
const router = useRouter();
|
|
56
|
+
const href = props?.href ?? "";
|
|
57
|
+
return {
|
|
58
|
+
href: props?.href ? router.useHref(href) : void 0,
|
|
59
|
+
target: props?.target,
|
|
60
|
+
rel: props?.rel,
|
|
61
|
+
download: props?.download,
|
|
62
|
+
ping: props?.ping,
|
|
63
|
+
referrerPolicy: props?.referrerPolicy
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function handleLinkClick(event, router, href, routerOptions) {
|
|
67
|
+
if (!router.isNative && event.currentTarget instanceof HTMLAnchorElement && event.currentTarget.href && !event.defaultPrevented && href && shouldClientNavigate(event.currentTarget, event)) {
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
router.open(event.currentTarget, event, href, routerOptions);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* A RouterProvider accepts a `navigate` function from a client-side router,
|
|
74
|
+
* and provides it to all nested solidaria links to enable client-side navigation.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```tsx
|
|
78
|
+
* import { useNavigate } from '@solidjs/router';
|
|
79
|
+
*
|
|
80
|
+
* function App() {
|
|
81
|
+
* const navigate = useNavigate();
|
|
82
|
+
* return (
|
|
83
|
+
* <RouterProvider navigate={navigate}>
|
|
84
|
+
* <Link href="/about">About</Link>
|
|
85
|
+
* </RouterProvider>
|
|
86
|
+
* );
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
function RouterProvider(props) {
|
|
91
|
+
const ctx = {
|
|
92
|
+
isNative: false,
|
|
93
|
+
navigate: props.navigate,
|
|
94
|
+
open: (target, modifiers, href, routerOptions) => {
|
|
95
|
+
getSyntheticLink(target, (link) => {
|
|
96
|
+
if (shouldClientNavigate(link, modifiers)) props.navigate(href, routerOptions);
|
|
97
|
+
else openLink(link, modifiers);
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
useHref: props.useHref ?? ((href) => href)
|
|
101
|
+
};
|
|
102
|
+
return createComponent(RouterContext.Provider, {
|
|
103
|
+
value: ctx,
|
|
104
|
+
get children() {
|
|
105
|
+
return props.children;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Returns the current router context value.
|
|
111
|
+
*/
|
|
112
|
+
function useRouter() {
|
|
113
|
+
return useContext(RouterContext);
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
export { RouterContext, RouterProvider, handleLinkClick, openLink, shouldClientNavigate, useLinkProps, useRouter };
|
|
117
|
+
|
|
118
|
+
//# sourceMappingURL=RouterProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RouterProvider.js","names":["JSX","createContext","useContext","RouterClickModifiers","metaKey","ctrlKey","altKey","shiftKey","RouterContextValue","isNative","navigate","href","routerOptions","RouterOptions","open","target","Element","modifiers","useHref","replace","key","RouterProviderProps","children","defaultRouter","openSyntheticLink","RouterContext","LinkDOMProps","rel","download","ping","referrerPolicy","shouldClientNavigate","link","HTMLAnchorElement","getAttribute","sameOrigin","location","origin","hasAttribute","openLink","event","MouseEvent","detail","bubbles","cancelable","dispatchEvent","getSyntheticLink","document","createElement","targetValue","appendChild","removeChild","useLinkProps","props","router","useRouter","undefined","handleLinkClick","currentTarget","defaultPrevented","preventDefault","RouterProvider","ctx","_$createComponent","Provider","value"],"sources":["../src/RouterProvider.tsx"],"sourcesContent":["/**\n * RouterProvider for solidaria-components\n *\n * A context provider for client-side router integration.\n * SolidJS apps typically use TanStack Router or SolidRouter directly;\n * this provides API compatibility with React Aria's RouterProvider.\n */\n\nimport { type JSX, createContext, useContext } from \"solid-js\";\n\nexport interface RouterClickModifiers {\n metaKey?: boolean;\n ctrlKey?: boolean;\n altKey?: boolean;\n shiftKey?: boolean;\n}\n\nexport interface RouterContextValue {\n /** Whether the router is a native browser router (no client-side navigation). */\n isNative: boolean;\n /** Navigate to a given href. */\n navigate: (href: string, routerOptions?: RouterOptions) => void;\n /** Open a link target with router-aware navigation behavior. */\n open: (\n target: Element,\n modifiers: RouterClickModifiers,\n href: string,\n routerOptions?: RouterOptions,\n ) => void;\n /** Transform an href for the router. */\n useHref: (href: string) => string;\n}\n\nexport interface RouterOptions {\n /** Whether to replace the current history entry. */\n replace?: boolean;\n /** Additional router-specific options. */\n [key: string]: unknown;\n}\n\nexport interface RouterProviderProps {\n /** A function that performs client-side navigation. */\n navigate: (href: string, routerOptions?: RouterOptions) => void;\n /** An optional function that transforms hrefs. */\n useHref?: (href: string) => string;\n /** Children to render. */\n children: JSX.Element;\n}\n\nconst defaultRouter: RouterContextValue = {\n isNative: true,\n navigate: () => {},\n open: (target, modifiers) => {\n openSyntheticLink(target, modifiers);\n },\n useHref: (href: string) => href,\n};\n\nexport const RouterContext = createContext<RouterContextValue>(defaultRouter);\n\nexport interface LinkDOMProps {\n href?: string;\n target?: string;\n rel?: string;\n download?: string | boolean;\n ping?: string;\n referrerPolicy?:\n | \"\"\n | \"no-referrer\"\n | \"no-referrer-when-downgrade\"\n | \"origin\"\n | \"origin-when-cross-origin\"\n | \"same-origin\"\n | \"strict-origin\"\n | \"strict-origin-when-cross-origin\"\n | \"unsafe-url\";\n}\n\nexport function shouldClientNavigate(\n link: HTMLAnchorElement,\n modifiers: RouterClickModifiers,\n): boolean {\n const target = link.getAttribute(\"target\");\n const sameOrigin = typeof location === \"undefined\" ? true : link.origin === location.origin;\n return (\n (!target || target === \"_self\") &&\n sameOrigin &&\n !link.hasAttribute(\"download\") &&\n !modifiers.metaKey &&\n !modifiers.ctrlKey &&\n !modifiers.altKey &&\n !modifiers.shiftKey\n );\n}\n\nexport function openLink(target: HTMLAnchorElement, modifiers: RouterClickModifiers): void {\n const event = new MouseEvent(\"click\", {\n metaKey: modifiers.metaKey,\n ctrlKey: modifiers.ctrlKey,\n altKey: modifiers.altKey,\n shiftKey: modifiers.shiftKey,\n detail: 1,\n bubbles: true,\n cancelable: true,\n });\n target.dispatchEvent(event);\n}\n\nfunction getSyntheticLink(target: Element, open: (link: HTMLAnchorElement) => void): void {\n if (target instanceof HTMLAnchorElement) {\n open(target);\n return;\n }\n\n const href = target.getAttribute(\"data-href\");\n if (!href) {\n return;\n }\n\n const link = document.createElement(\"a\");\n link.href = href;\n\n const targetValue = target.getAttribute(\"data-target\");\n if (targetValue) link.target = targetValue;\n\n const rel = target.getAttribute(\"data-rel\");\n if (rel) link.rel = rel;\n\n const download = target.getAttribute(\"data-download\");\n if (download) link.download = download;\n\n const ping = target.getAttribute(\"data-ping\");\n if (ping) link.ping = ping;\n\n const referrerPolicy = target.getAttribute(\"data-referrer-policy\");\n if (referrerPolicy) {\n link.referrerPolicy = referrerPolicy;\n }\n\n target.appendChild(link);\n open(link);\n target.removeChild(link);\n}\n\nfunction openSyntheticLink(target: Element, modifiers: RouterClickModifiers): void {\n getSyntheticLink(target, (link) => openLink(link, modifiers));\n}\n\nexport function useLinkProps(props?: LinkDOMProps): LinkDOMProps {\n const router = useRouter();\n const href = props?.href ?? \"\";\n return {\n href: props?.href ? router.useHref(href) : undefined,\n target: props?.target,\n rel: props?.rel,\n download: props?.download,\n ping: props?.ping,\n referrerPolicy: props?.referrerPolicy,\n };\n}\n\nexport function handleLinkClick(\n event: MouseEvent,\n router: RouterContextValue,\n href: string | undefined,\n routerOptions?: RouterOptions,\n): void {\n if (\n !router.isNative &&\n event.currentTarget instanceof HTMLAnchorElement &&\n event.currentTarget.href &&\n !event.defaultPrevented &&\n href &&\n shouldClientNavigate(event.currentTarget, event)\n ) {\n event.preventDefault();\n router.open(event.currentTarget, event, href, routerOptions);\n }\n}\n\n/**\n * A RouterProvider accepts a `navigate` function from a client-side router,\n * and provides it to all nested solidaria links to enable client-side navigation.\n *\n * @example\n * ```tsx\n * import { useNavigate } from '@solidjs/router';\n *\n * function App() {\n * const navigate = useNavigate();\n * return (\n * <RouterProvider navigate={navigate}>\n * <Link href=\"/about\">About</Link>\n * </RouterProvider>\n * );\n * }\n * ```\n */\nexport function RouterProvider(props: RouterProviderProps): JSX.Element {\n const ctx: RouterContextValue = {\n isNative: false,\n navigate: props.navigate,\n open: (target, modifiers, href, routerOptions) => {\n getSyntheticLink(target, (link) => {\n if (shouldClientNavigate(link, modifiers)) {\n props.navigate(href, routerOptions);\n } else {\n openLink(link, modifiers);\n }\n });\n },\n useHref: props.useHref ?? ((href: string) => href),\n };\n\n return <RouterContext.Provider value={ctx}>{props.children}</RouterContext.Provider>;\n}\n\n/**\n * Returns the current router context value.\n */\nexport function useRouter(): RouterContextValue {\n return useContext(RouterContext);\n}\n"],"mappings":";;AA0DA,MAAayB,gBAAgBxB,cAAkCsB;CAR7Dd,UAAU;CACVC,gBAAgB,CAAC;CACjBI,OAAOC,QAAQE,cAAc;EAC3BO,kBAAkBT,QAAQE,SAAS;CACrC;CACAC,UAAUP,SAAiBA;AAGkCY,CAAa;AAoB5E,SAAgBQ,qBACdC,MACAf,WACS;CACT,MAAMF,SAASiB,KAAKE,aAAa,QAAQ;CACzC,MAAMC,aAAa,OAAOC,aAAa,cAAc,OAAOJ,KAAKK,WAAWD,SAASC;CACrF,QACG,CAACtB,UAAUA,WAAW,YACvBoB,cACA,CAACH,KAAKM,aAAa,UAAU,KAC7B,CAACrB,UAAUb,WACX,CAACa,UAAUZ,WACX,CAACY,UAAUX,UACX,CAACW,UAAUV;AAEf;AAEA,SAAgBgC,SAASxB,QAA2BE,WAAuC;CACzF,MAAMuB,QAAQ,IAAIC,WAAW,SAAS;EACpCrC,SAASa,UAAUb;EACnBC,SAASY,UAAUZ;EACnBC,QAAQW,UAAUX;EAClBC,UAAUU,UAAUV;EACpBmC,QAAQ;EACRC,SAAS;EACTC,YAAY;CACd,CAAC;CACD7B,OAAO8B,cAAcL,KAAK;AAC5B;AAEA,SAASM,iBAAiB/B,QAAiBD,MAA+C;CACxF,IAAIC,kBAAkBkB,mBAAmB;EACvCnB,KAAKC,MAAM;EACX;CACF;CAEA,MAAMJ,OAAOI,OAAOmB,aAAa,WAAW;CAC5C,IAAI,CAACvB,MACH;CAGF,MAA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AMC,aAAa;CAC7D;AACF;;;;;;;;;;;;;;;;;;;AAoBA,SAAgBiD,eAAeR,OAAyC;CACtE,MAAMS,MAA0B;EAC9BrD,UAAU;EACVC,UAAU2C,MAAM3C;EAChBI,OAAOC,QAAQE,WAAWN,MAAMC,kBAAkB;GAChDkC,iBAAiB/B,SAASiB,SAAS;IACjC,IAAID,qBAAqBC,MAAMf,SAAS,GACtCoC,MAAM3C,SAASC,MAAMC,aAAa;SAElC2B,SAASP,MAAMf,SAAS;GAE5B,CAAC;EACH;EACAC,SAASmC,MAAMnC,aAAaP,SAAiBA;CAC/C;CAEA,OAAAoD,gBAAQtC,cAAcuC,UAAQ;EAACC,OAAOH;EAAG,IAAAxC,WAAA;GAAA,OAAG+B,MAAM/B;EAAQ;CAAA,CAAA;AAC5D;;;;AAKA,SAAgBiC,YAAgC;CAC9C,OAAOrD,WAAWuB,aAAa;AACjC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { createContext, useContext } from "solid-js";
|
|
2
|
+
const RouterContext = createContext({
|
|
3
|
+
isNative: true,
|
|
4
|
+
navigate: () => {},
|
|
5
|
+
open: (target, modifiers) => {
|
|
6
|
+
openSyntheticLink(target, modifiers);
|
|
7
|
+
},
|
|
8
|
+
useHref: (href) => href
|
|
9
|
+
});
|
|
10
|
+
function shouldClientNavigate(link, modifiers) {
|
|
11
|
+
const target = link.getAttribute("target");
|
|
12
|
+
const sameOrigin = typeof location === "undefined" ? true : link.origin === location.origin;
|
|
13
|
+
return (!target || target === "_self") && sameOrigin && !link.hasAttribute("download") && !modifiers.metaKey && !modifiers.ctrlKey && !modifiers.altKey && !modifiers.shiftKey;
|
|
14
|
+
}
|
|
15
|
+
function openLink(target, modifiers) {
|
|
16
|
+
const event = new MouseEvent("click", {
|
|
17
|
+
metaKey: modifiers.metaKey,
|
|
18
|
+
ctrlKey: modifiers.ctrlKey,
|
|
19
|
+
altKey: modifiers.altKey,
|
|
20
|
+
shiftKey: modifiers.shiftKey,
|
|
21
|
+
detail: 1,
|
|
22
|
+
bubbles: true,
|
|
23
|
+
cancelable: true
|
|
24
|
+
});
|
|
25
|
+
target.dispatchEvent(event);
|
|
26
|
+
}
|
|
27
|
+
function getSyntheticLink(target, open) {
|
|
28
|
+
if (target instanceof HTMLAnchorElement) {
|
|
29
|
+
open(target);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const href = target.getAttribute("data-href");
|
|
33
|
+
if (!href) return;
|
|
34
|
+
const link = document.createElement("a");
|
|
35
|
+
link.href = href;
|
|
36
|
+
const targetValue = target.getAttribute("data-target");
|
|
37
|
+
if (targetValue) link.target = targetValue;
|
|
38
|
+
const rel = target.getAttribute("data-rel");
|
|
39
|
+
if (rel) link.rel = rel;
|
|
40
|
+
const download = target.getAttribute("data-download");
|
|
41
|
+
if (download) link.download = download;
|
|
42
|
+
const ping = target.getAttribute("data-ping");
|
|
43
|
+
if (ping) link.ping = ping;
|
|
44
|
+
const referrerPolicy = target.getAttribute("data-referrer-policy");
|
|
45
|
+
if (referrerPolicy) link.referrerPolicy = referrerPolicy;
|
|
46
|
+
target.appendChild(link);
|
|
47
|
+
open(link);
|
|
48
|
+
target.removeChild(link);
|
|
49
|
+
}
|
|
50
|
+
function openSyntheticLink(target, modifiers) {
|
|
51
|
+
getSyntheticLink(target, (link) => openLink(link, modifiers));
|
|
52
|
+
}
|
|
53
|
+
function useLinkProps(props) {
|
|
54
|
+
const router = useRouter();
|
|
55
|
+
const href = props?.href ?? "";
|
|
56
|
+
return {
|
|
57
|
+
href: props?.href ? router.useHref(href) : void 0,
|
|
58
|
+
target: props?.target,
|
|
59
|
+
rel: props?.rel,
|
|
60
|
+
download: props?.download,
|
|
61
|
+
ping: props?.ping,
|
|
62
|
+
referrerPolicy: props?.referrerPolicy
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function handleLinkClick(event, router, href, routerOptions) {
|
|
66
|
+
if (!router.isNative && event.currentTarget instanceof HTMLAnchorElement && event.currentTarget.href && !event.defaultPrevented && href && shouldClientNavigate(event.currentTarget, event)) {
|
|
67
|
+
event.preventDefault();
|
|
68
|
+
router.open(event.currentTarget, event, href, routerOptions);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A RouterProvider accepts a `navigate` function from a client-side router,
|
|
73
|
+
* and provides it to all nested solidaria links to enable client-side navigation.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```tsx
|
|
77
|
+
* import { useNavigate } from '@solidjs/router';
|
|
78
|
+
*
|
|
79
|
+
* function App() {
|
|
80
|
+
* const navigate = useNavigate();
|
|
81
|
+
* return (
|
|
82
|
+
* <RouterProvider navigate={navigate}>
|
|
83
|
+
* <Link href="/about">About</Link>
|
|
84
|
+
* </RouterProvider>
|
|
85
|
+
* );
|
|
86
|
+
* }
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
function RouterProvider(props) {
|
|
90
|
+
const ctx = {
|
|
91
|
+
isNative: false,
|
|
92
|
+
navigate: props.navigate,
|
|
93
|
+
open: (target, modifiers, href, routerOptions) => {
|
|
94
|
+
getSyntheticLink(target, (link) => {
|
|
95
|
+
if (shouldClientNavigate(link, modifiers)) props.navigate(href, routerOptions);
|
|
96
|
+
else openLink(link, modifiers);
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
useHref: props.useHref ?? ((href) => href)
|
|
100
|
+
};
|
|
101
|
+
return <RouterContext.Provider value={ctx}>{props.children}</RouterContext.Provider>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Returns the current router context value.
|
|
105
|
+
*/
|
|
106
|
+
function useRouter() {
|
|
107
|
+
return useContext(RouterContext);
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
export { RouterContext, RouterProvider, handleLinkClick, openLink, shouldClientNavigate, useLinkProps, useRouter };
|
|
111
|
+
|
|
112
|
+
//# sourceMappingURL=RouterProvider.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RouterProvider.jsx","names":[],"sources":["../src/RouterProvider.tsx"],"sourcesContent":["/**\n * RouterProvider for solidaria-components\n *\n * A context provider for client-side router integration.\n * SolidJS apps typically use TanStack Router or SolidRouter directly;\n * this provides API compatibility with React Aria's RouterProvider.\n */\n\nimport { type JSX, createContext, useContext } from \"solid-js\";\n\nexport interface RouterClickModifiers {\n metaKey?: boolean;\n ctrlKey?: boolean;\n altKey?: boolean;\n shiftKey?: boolean;\n}\n\nexport interface RouterContextValue {\n /** Whether the router is a native browser router (no client-side navigation). */\n isNative: boolean;\n /** Navigate to a given href. */\n navigate: (href: string, routerOptions?: RouterOptions) => void;\n /** Open a link target with router-aware navigation behavior. */\n open: (\n target: Element,\n modifiers: RouterClickModifiers,\n href: string,\n routerOptions?: RouterOptions,\n ) => void;\n /** Transform an href for the router. */\n useHref: (href: string) => string;\n}\n\nexport interface RouterOptions {\n /** Whether to replace the current history entry. */\n replace?: boolean;\n /** Additional router-specific options. */\n [key: string]: unknown;\n}\n\nexport interface RouterProviderProps {\n /** A function that performs client-side navigation. */\n navigate: (href: string, routerOptions?: RouterOptions) => void;\n /** An optional function that transforms hrefs. */\n useHref?: (href: string) => string;\n /** Children to render. */\n children: JSX.Element;\n}\n\nconst defaultRouter: RouterContextValue = {\n isNative: true,\n navigate: () => {},\n open: (target, modifiers) => {\n openSyntheticLink(target, modifiers);\n },\n useHref: (href: string) => href,\n};\n\nexport const RouterContext = createContext<RouterContextValue>(defaultRouter);\n\nexport interface LinkDOMProps {\n href?: string;\n target?: string;\n rel?: string;\n download?: string | boolean;\n ping?: string;\n referrerPolicy?:\n | \"\"\n | \"no-referrer\"\n | \"no-referrer-when-downgrade\"\n | \"origin\"\n | \"origin-when-cross-origin\"\n | \"same-origin\"\n | \"strict-origin\"\n | \"strict-origin-when-cross-origin\"\n | \"unsafe-url\";\n}\n\nexport function shouldClientNavigate(\n link: HTMLAnchorElement,\n modifiers: RouterClickModifiers,\n): boolean {\n const target = link.getAttribute(\"target\");\n const sameOrigin = typeof location === \"undefined\" ? true : link.origin === location.origin;\n return (\n (!target || target === \"_self\") &&\n sameOrigin &&\n !link.hasAttribute(\"download\") &&\n !modifiers.metaKey &&\n !modifiers.ctrlKey &&\n !modifiers.altKey &&\n !modifiers.shiftKey\n );\n}\n\nexport function openLink(target: HTMLAnchorElement, modifiers: RouterClickModifiers): void {\n const event = new MouseEvent(\"click\", {\n metaKey: modifiers.metaKey,\n ctrlKey: modifiers.ctrlKey,\n altKey: modifiers.altKey,\n shiftKey: modifiers.shiftKey,\n detail: 1,\n bubbles: true,\n cancelable: true,\n });\n target.dispatchEvent(event);\n}\n\nfunction getSyntheticLink(target: Element, open: (link: HTMLAnchorElement) => void): void {\n if (target instanceof HTMLAnchorElement) {\n open(target);\n return;\n }\n\n const href = target.getAttribute(\"data-href\");\n if (!href) {\n return;\n }\n\n const link = document.createElement(\"a\");\n link.href = href;\n\n const targetValue = target.getAttribute(\"data-target\");\n if (targetValue) link.target = targetValue;\n\n const rel = target.getAttribute(\"data-rel\");\n if (rel) link.rel = rel;\n\n const download = target.getAttribute(\"data-download\");\n if (download) link.download = download;\n\n const ping = target.getAttribute(\"data-ping\");\n if (ping) link.ping = ping;\n\n const referrerPolicy = target.getAttribute(\"data-referrer-policy\");\n if (referrerPolicy) {\n link.referrerPolicy = referrerPolicy;\n }\n\n target.appendChild(link);\n open(link);\n target.removeChild(link);\n}\n\nfunction openSyntheticLink(target: Element, modifiers: RouterClickModifiers): void {\n getSyntheticLink(target, (link) => openLink(link, modifiers));\n}\n\nexport function useLinkProps(props?: LinkDOMProps): LinkDOMProps {\n const router = useRouter();\n const href = props?.href ?? \"\";\n return {\n href: props?.href ? router.useHref(href) : undefined,\n target: props?.target,\n rel: props?.rel,\n download: props?.download,\n ping: props?.ping,\n referrerPolicy: props?.referrerPolicy,\n };\n}\n\nexport function handleLinkClick(\n event: MouseEvent,\n router: RouterContextValue,\n href: string | undefined,\n routerOptions?: RouterOptions,\n): void {\n if (\n !router.isNative &&\n event.currentTarget instanceof HTMLAnchorElement &&\n event.currentTarget.href &&\n !event.defaultPrevented &&\n href &&\n shouldClientNavigate(event.currentTarget, event)\n ) {\n event.preventDefault();\n router.open(event.currentTarget, event, href, routerOptions);\n }\n}\n\n/**\n * A RouterProvider accepts a `navigate` function from a client-side router,\n * and provides it to all nested solidaria links to enable client-side navigation.\n *\n * @example\n * ```tsx\n * import { useNavigate } from '@solidjs/router';\n *\n * function App() {\n * const navigate = useNavigate();\n * return (\n * <RouterProvider navigate={navigate}>\n * <Link href=\"/about\">About</Link>\n * </RouterProvider>\n * );\n * }\n * ```\n */\nexport function RouterProvider(props: RouterProviderProps): JSX.Element {\n const ctx: RouterContextValue = {\n isNative: false,\n navigate: props.navigate,\n open: (target, modifiers, href, routerOptions) => {\n getSyntheticLink(target, (link) => {\n if (shouldClientNavigate(link, modifiers)) {\n props.navigate(href, routerOptions);\n } else {\n openLink(link, modifiers);\n }\n });\n },\n useHref: props.useHref ?? ((href: string) => href),\n };\n\n return <RouterContext.Provider value={ctx}>{props.children}</RouterContext.Provider>;\n}\n\n/**\n * Returns the current router context value.\n */\nexport function useRouter(): RouterContextValue {\n return useContext(RouterContext);\n}\n"],"mappings":";AA0DA,MAAa,gBAAgB,cAAkC;CAR7D,UAAU;CACV,gBAAgB,CAAC;CACjB,OAAO,QAAQ,cAAc;EAC3B,kBAAkB,QAAQ,SAAS;CACrC;CACA,UAAU,SAAiB;AAGkC,CAAa;AAoB5E,SAAgB,qBACd,MACA,WACS;CACT,MAAM,SAAS,KAAK,aAAa,QAAQ;CACzC,MAAM,aAAa,OAAO,aAAa,cAAc,OAAO,KAAK,WAAW,SAAS;CACrF,QACG,CAAC,UAAU,WAAW,YACvB,cACA,CAAC,KAAK,aAAa,UAAU,KAC7B,CAAC,UAAU,WACX,CAAC,UAAU,WACX,CAAC,UAAU,UACX,CAAC,UAAU;AAEf;AAEA,SAAgB,SAAS,QAA2B,WAAuC;C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yB,qBAC/B,MAAM,cAAc,QACpB,CAAC,MAAM,oBACP,QACA,qBAAqB,MAAM,eAAe,KAAK,GAC/C;EACA,MAAM,eAAe;EACrB,OAAO,KAAK,MAAM,eAAe,OAAO,MAAM,aAAa;CAC7D;AACF;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,eAAe,OAAyC;CACtE,MAAM,MAA0B;EAC9B,UAAU;EACV,UAAU,MAAM;EAChB,OAAO,QAAQ,WAAW,MAAM,kBAAkB;GAChD,iBAAiB,SAAS,SAAS;IACjC,IAAI,qBAAqB,MAAM,SAAS,GACtC,MAAM,SAAS,MAAM,aAAa;SAElC,SAAS,MAAM,SAAS;GAE5B,CAAC;EACH;EACA,SAAS,MAAM,aAAa,SAAiB;CAC/C;CAEA,OAAO,CAAC,cAAc,SAAS,OAAO,MAAM,MAAM,SAAS,EAAE,cAAc;AAC7E;;;;AAKA,SAAgB,YAAgC;CAC9C,OAAO,WAAW,aAAa;AACjC"}
|
package/dist/SearchField.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* A pre-wired headless search field that combines state + aria hooks.
|
|
5
5
|
* Port of react-aria-components/src/SearchField.tsx
|
|
6
6
|
*/
|
|
7
|
-
import { type JSX } from "solid-js";
|
|
7
|
+
import { type JSX, type Context } from "solid-js";
|
|
8
8
|
import { type AriaSearchFieldProps } from "@proyecto-viviana/solidaria";
|
|
9
9
|
import { type SearchFieldState } from "@proyecto-viviana/solid-stately";
|
|
10
10
|
import { type RenderChildren, type ClassNameOrFunction, type StyleOrFunction, type SlotProps } from "./utils";
|
|
@@ -98,7 +98,7 @@ interface SearchFieldContextValue extends Partial<SearchFieldProps> {
|
|
|
98
98
|
setInputRef?: (el: HTMLInputElement) => void;
|
|
99
99
|
slots?: Record<string, SearchFieldProps>;
|
|
100
100
|
}
|
|
101
|
-
export declare const SearchFieldContext:
|
|
101
|
+
export declare const SearchFieldContext: Context<SearchFieldContextValue | null>;
|
|
102
102
|
/**
|
|
103
103
|
* A search field allows a user to enter and clear a search query.
|
|
104
104
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchField.d.ts","sourceRoot":"","sources":["../src/SearchField.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"SearchField.d.ts","sourceRoot":"","sources":["../src/SearchField.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,KAAK,GAAG,EACR,KAAK,OAAO,EAQb,MAAM,UAAU,CAAC;AAClB,OAAO,EAML,KAAK,oBAAoB,EAC1B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAGL,KAAK,gBAAgB,EAEtB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,SAAS,EAIf,MAAM,SAAS,CAAC;AAGjB,MAAM,WAAW,sBAAsB;IACrC,yCAAyC;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,4CAA4C;IAC5C,UAAU,EAAE,OAAO,CAAC;IACpB,2CAA2C;IAC3C,SAAS,EAAE,OAAO,CAAC;IACnB,6CAA6C;IAC7C,UAAU,EAAE,OAAO,CAAC;IACpB,4CAA4C;IAC5C,UAAU,EAAE,OAAO,CAAC;IACpB,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,oBAAoB,EAAE,OAAO,CAAC,EAAE,SAAS;IACtF,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,uDAAuD;IACvD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IA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