@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,991 @@
|
|
|
1
|
+
import { Provider, dataAttr, useIsHydrated, useRenderProps } from "./utils.js";
|
|
2
|
+
import { TextContext } from "./Text.js";
|
|
3
|
+
import { FormContext } from "./Form.js";
|
|
4
|
+
import { CalendarContext } from "./Calendar.js";
|
|
5
|
+
import { RangeCalendarContext } from "./RangeCalendar.js";
|
|
6
|
+
import { d as useDateRangePickerContext, f as HiddenDateInput, n as DateFieldContext, u as DateRangePickerContext } from "./DateField2.js";
|
|
7
|
+
import { Portal, createComponent, getNextElement, insert, mergeProps, runHydrationEvents, spread, template, use } from "solid-js/web";
|
|
8
|
+
import { Show, createContext, createEffect, createMemo, createSignal, onCleanup, splitProps, useContext } from "solid-js";
|
|
9
|
+
import { FocusScope, createDatePicker, createDateRangePicker, createPopover, useUNSAFE_PortalContext } from "@proyecto-viviana/solidaria";
|
|
10
|
+
import { access, createCalendarState, createDateFieldState, createDatePickerState, createRangeCalendarState } from "@proyecto-viviana/solid-stately";
|
|
11
|
+
//#region src/DatePicker.tsx
|
|
12
|
+
/**
|
|
13
|
+
* DatePicker component for solidaria-components
|
|
14
|
+
*
|
|
15
|
+
* Pre-wired headless date picker component that combines a date field with a calendar popup.
|
|
16
|
+
* Port of react-aria-components/src/DatePicker.tsx
|
|
17
|
+
*/
|
|
18
|
+
var _tmpl$ = /*#__PURE__*/ template(`<div class="solidaria-DatePicker solidaria-DatePicker--placeholder"aria-hidden=true>`), _tmpl$2 = /*#__PURE__*/ template(`<div>`), _tmpl$3 = /*#__PURE__*/ template(`<div class="solidaria-DateRangePicker solidaria-DateRangePicker--placeholder"aria-hidden=true>`), _tmpl$4 = /*#__PURE__*/ template(`<button>`), _tmpl$5 = /*#__PURE__*/ template(`<span>`), _tmpl$6 = /*#__PURE__*/ template(`<p>`);
|
|
19
|
+
const DatePickerContext = createContext(null);
|
|
20
|
+
const DatePickerStateContext = createContext(null);
|
|
21
|
+
const DateRangePickerStateContext = createContext(null);
|
|
22
|
+
function withFormValidationBehavior(props, formContext) {
|
|
23
|
+
if (!formContext?.validationBehavior) return props;
|
|
24
|
+
return new Proxy(props, {
|
|
25
|
+
get(target, property, receiver) {
|
|
26
|
+
const localValue = Reflect.get(target, property, receiver);
|
|
27
|
+
if (property === "validationBehavior" && localValue === void 0) return formContext.validationBehavior;
|
|
28
|
+
return localValue;
|
|
29
|
+
},
|
|
30
|
+
has(target, property) {
|
|
31
|
+
return Reflect.has(target, property) || property === "validationBehavior" && formContext.validationBehavior !== void 0;
|
|
32
|
+
},
|
|
33
|
+
ownKeys(target) {
|
|
34
|
+
const keys = new Set(Reflect.ownKeys(target));
|
|
35
|
+
if (formContext.validationBehavior !== void 0) keys.add("validationBehavior");
|
|
36
|
+
return Array.from(keys);
|
|
37
|
+
},
|
|
38
|
+
getOwnPropertyDescriptor(target, property) {
|
|
39
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(target, property);
|
|
40
|
+
if (descriptor) return descriptor;
|
|
41
|
+
if (property === "validationBehavior" && formContext.validationBehavior !== void 0) return {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
configurable: true,
|
|
44
|
+
get: () => formContext.validationBehavior
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function useDatePickerContext() {
|
|
50
|
+
const context = useContext(DatePickerContext);
|
|
51
|
+
if (!context) throw new Error("DatePicker components must be used within a DatePicker");
|
|
52
|
+
return context;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A date picker combines a DateField and a Calendar popover.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* <DatePicker label="Event date">
|
|
60
|
+
* <Label>Event date</Label>
|
|
61
|
+
* <Group>
|
|
62
|
+
* <DateInput>
|
|
63
|
+
* {(segment) => <DateSegment segment={segment} />}
|
|
64
|
+
* </DateInput>
|
|
65
|
+
* <DatePickerButton>📅</DatePickerButton>
|
|
66
|
+
* </Group>
|
|
67
|
+
* <Popover>
|
|
68
|
+
* <Dialog>
|
|
69
|
+
* <Calendar>
|
|
70
|
+
* <CalendarGrid>
|
|
71
|
+
* {(date) => <CalendarCell date={date} />}
|
|
72
|
+
* </CalendarGrid>
|
|
73
|
+
* </Calendar>
|
|
74
|
+
* </Dialog>
|
|
75
|
+
* </Popover>
|
|
76
|
+
* </DatePicker>
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
function DatePicker(props) {
|
|
80
|
+
const isHydrated = useIsHydrated();
|
|
81
|
+
const formContext = useContext(FormContext);
|
|
82
|
+
return createComponent(Show, {
|
|
83
|
+
get when() {
|
|
84
|
+
return isHydrated();
|
|
85
|
+
},
|
|
86
|
+
get fallback() {
|
|
87
|
+
return getNextElement(_tmpl$);
|
|
88
|
+
},
|
|
89
|
+
get children() {
|
|
90
|
+
return createComponent(DatePickerInner, mergeProps(props, { __formContext: formContext }));
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Internal DatePicker component that renders after client mount.
|
|
96
|
+
*/
|
|
97
|
+
function DatePickerInner(props) {
|
|
98
|
+
const formContext = props.__formContext ?? useContext(FormContext);
|
|
99
|
+
const [local, stateProps, rest] = splitProps(withFormValidationBehavior(props, formContext), [
|
|
100
|
+
"children",
|
|
101
|
+
"class",
|
|
102
|
+
"style",
|
|
103
|
+
"slot",
|
|
104
|
+
"shouldCloseOnSelect",
|
|
105
|
+
"__formContext"
|
|
106
|
+
], [
|
|
107
|
+
"value",
|
|
108
|
+
"defaultValue",
|
|
109
|
+
"onChange",
|
|
110
|
+
"isOpen",
|
|
111
|
+
"defaultOpen",
|
|
112
|
+
"onOpenChange",
|
|
113
|
+
"minValue",
|
|
114
|
+
"maxValue",
|
|
115
|
+
"isInvalid",
|
|
116
|
+
"isDisabled",
|
|
117
|
+
"isReadOnly",
|
|
118
|
+
"isRequired",
|
|
119
|
+
"locale",
|
|
120
|
+
"granularity",
|
|
121
|
+
"hourCycle",
|
|
122
|
+
"hideTimeZone",
|
|
123
|
+
"placeholderValue",
|
|
124
|
+
"shouldForceLeadingZeros",
|
|
125
|
+
"createCalendar",
|
|
126
|
+
"validationState",
|
|
127
|
+
"validationBehavior",
|
|
128
|
+
"validate",
|
|
129
|
+
"description",
|
|
130
|
+
"errorMessage",
|
|
131
|
+
"isDateUnavailable",
|
|
132
|
+
"firstDayOfWeek",
|
|
133
|
+
"visibleMonths",
|
|
134
|
+
"pageBehavior",
|
|
135
|
+
"selectionAlignment",
|
|
136
|
+
"isDateDisabled"
|
|
137
|
+
]);
|
|
138
|
+
const [triggerRef, setTriggerRef] = createSignal(null);
|
|
139
|
+
const [fieldRef, setFieldRef] = createSignal(null);
|
|
140
|
+
const datePickerState = createDatePickerState({
|
|
141
|
+
get value() {
|
|
142
|
+
return stateProps.value;
|
|
143
|
+
},
|
|
144
|
+
get defaultValue() {
|
|
145
|
+
return stateProps.defaultValue;
|
|
146
|
+
},
|
|
147
|
+
get onChange() {
|
|
148
|
+
return stateProps.onChange;
|
|
149
|
+
},
|
|
150
|
+
get minValue() {
|
|
151
|
+
return stateProps.minValue;
|
|
152
|
+
},
|
|
153
|
+
get maxValue() {
|
|
154
|
+
return stateProps.maxValue;
|
|
155
|
+
},
|
|
156
|
+
get isDisabled() {
|
|
157
|
+
return stateProps.isDisabled;
|
|
158
|
+
},
|
|
159
|
+
get isReadOnly() {
|
|
160
|
+
return stateProps.isReadOnly;
|
|
161
|
+
},
|
|
162
|
+
get isRequired() {
|
|
163
|
+
return stateProps.isRequired;
|
|
164
|
+
},
|
|
165
|
+
get granularity() {
|
|
166
|
+
return stateProps.granularity;
|
|
167
|
+
},
|
|
168
|
+
get hourCycle() {
|
|
169
|
+
return stateProps.hourCycle;
|
|
170
|
+
},
|
|
171
|
+
get hideTimeZone() {
|
|
172
|
+
return stateProps.hideTimeZone;
|
|
173
|
+
},
|
|
174
|
+
get placeholderValue() {
|
|
175
|
+
return stateProps.placeholderValue;
|
|
176
|
+
},
|
|
177
|
+
get shouldCloseOnSelect() {
|
|
178
|
+
return local.shouldCloseOnSelect;
|
|
179
|
+
},
|
|
180
|
+
get defaultOpen() {
|
|
181
|
+
return stateProps.defaultOpen;
|
|
182
|
+
},
|
|
183
|
+
get isOpen() {
|
|
184
|
+
return stateProps.isOpen;
|
|
185
|
+
},
|
|
186
|
+
get onOpenChange() {
|
|
187
|
+
return stateProps.onOpenChange;
|
|
188
|
+
},
|
|
189
|
+
get isDateUnavailable() {
|
|
190
|
+
return stateProps.isDateUnavailable;
|
|
191
|
+
},
|
|
192
|
+
get validationState() {
|
|
193
|
+
return stateProps.validationState;
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
const overlayState = {
|
|
197
|
+
get isOpen() {
|
|
198
|
+
return datePickerState.isOpen();
|
|
199
|
+
},
|
|
200
|
+
open: datePickerState.open,
|
|
201
|
+
close: datePickerState.close,
|
|
202
|
+
toggle: () => datePickerState.setOpen(!datePickerState.isOpen())
|
|
203
|
+
};
|
|
204
|
+
const fieldState = createDateFieldState({
|
|
205
|
+
...stateProps,
|
|
206
|
+
value: () => datePickerState.value(),
|
|
207
|
+
onChange: (value) => {
|
|
208
|
+
datePickerState.setValue(value);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
const calendarState = createCalendarState({
|
|
212
|
+
value: () => datePickerState.value(),
|
|
213
|
+
onChange: (value) => {
|
|
214
|
+
if (!value) return;
|
|
215
|
+
datePickerState.setDateValue(value);
|
|
216
|
+
},
|
|
217
|
+
minValue: stateProps.minValue,
|
|
218
|
+
maxValue: stateProps.maxValue,
|
|
219
|
+
isDisabled: stateProps.isDisabled,
|
|
220
|
+
isReadOnly: stateProps.isReadOnly,
|
|
221
|
+
locale: stateProps.locale,
|
|
222
|
+
createCalendar: stateProps.createCalendar,
|
|
223
|
+
isDateUnavailable: stateProps.isDateUnavailable,
|
|
224
|
+
firstDayOfWeek: stateProps.firstDayOfWeek,
|
|
225
|
+
visibleMonths: stateProps.visibleMonths,
|
|
226
|
+
pageBehavior: stateProps.pageBehavior,
|
|
227
|
+
selectionAlignment: stateProps.selectionAlignment,
|
|
228
|
+
isDateDisabled: stateProps.isDateDisabled
|
|
229
|
+
});
|
|
230
|
+
const pickerAria = createDatePicker(() => ({
|
|
231
|
+
...rest,
|
|
232
|
+
description: stateProps.description,
|
|
233
|
+
errorMessage: stateProps.errorMessage
|
|
234
|
+
}), fieldState, overlayState, calendarState);
|
|
235
|
+
const contextValue = {
|
|
236
|
+
fieldState,
|
|
237
|
+
datePickerState,
|
|
238
|
+
calendarState,
|
|
239
|
+
overlayState,
|
|
240
|
+
triggerRef,
|
|
241
|
+
setTriggerRef: (element) => {
|
|
242
|
+
if (!element) return;
|
|
243
|
+
const current = triggerRef();
|
|
244
|
+
if (!current || !current.isConnected) setTriggerRef(() => element);
|
|
245
|
+
},
|
|
246
|
+
pickerAria
|
|
247
|
+
};
|
|
248
|
+
const isInvalid = createMemo(() => fieldState.isInvalid() || datePickerState.builtinValidation().isInvalid || Boolean(stateProps.isInvalid));
|
|
249
|
+
const renderValues = createMemo(() => ({
|
|
250
|
+
isDisabled: fieldState.isDisabled(),
|
|
251
|
+
isReadOnly: fieldState.isReadOnly(),
|
|
252
|
+
isRequired: fieldState.isRequired(),
|
|
253
|
+
isInvalid: isInvalid(),
|
|
254
|
+
isOpen: overlayState.isOpen
|
|
255
|
+
}));
|
|
256
|
+
const renderProps = useRenderProps({
|
|
257
|
+
class: local.class,
|
|
258
|
+
style: local.style,
|
|
259
|
+
defaultClassName: "solidaria-DatePicker"
|
|
260
|
+
}, renderValues);
|
|
261
|
+
const validationBehavior = () => stateProps.validationBehavior ?? formContext?.validationBehavior ?? "native";
|
|
262
|
+
return createComponent(DatePickerStateContext.Provider, {
|
|
263
|
+
value: fieldState,
|
|
264
|
+
get children() {
|
|
265
|
+
return createComponent(DatePickerContext.Provider, {
|
|
266
|
+
value: contextValue,
|
|
267
|
+
get children() {
|
|
268
|
+
return createComponent(DateFieldContext.Provider, {
|
|
269
|
+
get value() {
|
|
270
|
+
return {
|
|
271
|
+
state: fieldState,
|
|
272
|
+
aria: {
|
|
273
|
+
labelProps: pickerAria.labelProps,
|
|
274
|
+
inputProps: pickerAria.fieldProps,
|
|
275
|
+
descriptionProps: pickerAria.descriptionProps,
|
|
276
|
+
errorMessageProps: pickerAria.errorMessageProps
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
},
|
|
280
|
+
get children() {
|
|
281
|
+
return createComponent(CalendarContext.Provider, {
|
|
282
|
+
value: calendarState,
|
|
283
|
+
get children() {
|
|
284
|
+
return [(() => {
|
|
285
|
+
var _el$2 = getNextElement(_tmpl$2);
|
|
286
|
+
use(setFieldRef, _el$2);
|
|
287
|
+
spread(_el$2, mergeProps(() => pickerAria.groupProps, {
|
|
288
|
+
get ["class"]() {
|
|
289
|
+
return renderProps.class();
|
|
290
|
+
},
|
|
291
|
+
get style() {
|
|
292
|
+
return renderProps.style();
|
|
293
|
+
},
|
|
294
|
+
get ["data-disabled"]() {
|
|
295
|
+
return dataAttr(fieldState.isDisabled());
|
|
296
|
+
},
|
|
297
|
+
get ["data-readonly"]() {
|
|
298
|
+
return dataAttr(fieldState.isReadOnly());
|
|
299
|
+
},
|
|
300
|
+
get ["data-required"]() {
|
|
301
|
+
return dataAttr(fieldState.isRequired());
|
|
302
|
+
},
|
|
303
|
+
get ["data-invalid"]() {
|
|
304
|
+
return dataAttr(isInvalid());
|
|
305
|
+
},
|
|
306
|
+
get ["data-open"]() {
|
|
307
|
+
return dataAttr(overlayState.isOpen);
|
|
308
|
+
}
|
|
309
|
+
}), false, true);
|
|
310
|
+
insert(_el$2, createComponent(Provider, {
|
|
311
|
+
values: [[TextContext, { slots: {
|
|
312
|
+
get description() {
|
|
313
|
+
return pickerAria.descriptionProps;
|
|
314
|
+
},
|
|
315
|
+
get errorMessage() {
|
|
316
|
+
return pickerAria.errorMessageProps;
|
|
317
|
+
}
|
|
318
|
+
} }]],
|
|
319
|
+
get children() {
|
|
320
|
+
return props.children;
|
|
321
|
+
}
|
|
322
|
+
}));
|
|
323
|
+
runHydrationEvents();
|
|
324
|
+
return _el$2;
|
|
325
|
+
})(), createComponent(Show, {
|
|
326
|
+
get when() {
|
|
327
|
+
return rest.name;
|
|
328
|
+
},
|
|
329
|
+
get children() {
|
|
330
|
+
return createComponent(HiddenDateInput, {
|
|
331
|
+
get name() {
|
|
332
|
+
return rest.name;
|
|
333
|
+
},
|
|
334
|
+
get form() {
|
|
335
|
+
return rest.form;
|
|
336
|
+
},
|
|
337
|
+
value: () => datePickerState.value(),
|
|
338
|
+
get autoComplete() {
|
|
339
|
+
return rest.autoComplete;
|
|
340
|
+
},
|
|
341
|
+
get isDisabled() {
|
|
342
|
+
return fieldState.isDisabled();
|
|
343
|
+
},
|
|
344
|
+
get isRequired() {
|
|
345
|
+
return fieldState.isRequired();
|
|
346
|
+
},
|
|
347
|
+
get validationBehavior() {
|
|
348
|
+
return validationBehavior();
|
|
349
|
+
},
|
|
350
|
+
validationState: fieldState,
|
|
351
|
+
focus: () => {
|
|
352
|
+
fieldRef()?.querySelector("[role=\"spinbutton\"]")?.focus();
|
|
353
|
+
},
|
|
354
|
+
minValue: () => access(stateProps.minValue),
|
|
355
|
+
maxValue: () => access(stateProps.maxValue),
|
|
356
|
+
get granularity() {
|
|
357
|
+
return datePickerState.granularity;
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
})];
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
function DateRangePicker(props) {
|
|
372
|
+
const isHydrated = useIsHydrated();
|
|
373
|
+
return createComponent(Show, {
|
|
374
|
+
get when() {
|
|
375
|
+
return isHydrated();
|
|
376
|
+
},
|
|
377
|
+
get fallback() {
|
|
378
|
+
return getNextElement(_tmpl$3);
|
|
379
|
+
},
|
|
380
|
+
get children() {
|
|
381
|
+
return createComponent(DateRangePickerInner, props);
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
function DateRangePickerInner(props) {
|
|
386
|
+
const [local, overlayProps, stateProps, rest] = splitProps(props, [
|
|
387
|
+
"children",
|
|
388
|
+
"class",
|
|
389
|
+
"style",
|
|
390
|
+
"slot",
|
|
391
|
+
"shouldCloseOnSelect"
|
|
392
|
+
], [
|
|
393
|
+
"defaultOpen",
|
|
394
|
+
"isOpen",
|
|
395
|
+
"onOpenChange"
|
|
396
|
+
], [
|
|
397
|
+
"value",
|
|
398
|
+
"defaultValue",
|
|
399
|
+
"onChange",
|
|
400
|
+
"minValue",
|
|
401
|
+
"maxValue",
|
|
402
|
+
"isDisabled",
|
|
403
|
+
"isReadOnly",
|
|
404
|
+
"focusedValue",
|
|
405
|
+
"defaultFocusedValue",
|
|
406
|
+
"onFocusChange",
|
|
407
|
+
"locale",
|
|
408
|
+
"granularity",
|
|
409
|
+
"hourCycle",
|
|
410
|
+
"hideTimeZone",
|
|
411
|
+
"placeholderValue",
|
|
412
|
+
"createCalendar",
|
|
413
|
+
"isDateUnavailable",
|
|
414
|
+
"visibleMonths",
|
|
415
|
+
"isDateDisabled",
|
|
416
|
+
"validationState",
|
|
417
|
+
"allowsNonContiguousRanges",
|
|
418
|
+
"firstDayOfWeek",
|
|
419
|
+
"pageBehavior",
|
|
420
|
+
"selectionAlignment"
|
|
421
|
+
]);
|
|
422
|
+
const [internalOpen, setInternalOpen] = createSignal(overlayProps.defaultOpen ?? false);
|
|
423
|
+
const isOpen = () => access(overlayProps.isOpen) ?? internalOpen();
|
|
424
|
+
const setOpen = (open) => {
|
|
425
|
+
if (access(overlayProps.isOpen) === void 0) setInternalOpen(open);
|
|
426
|
+
overlayProps.onOpenChange?.(open);
|
|
427
|
+
};
|
|
428
|
+
let triggerRef = null;
|
|
429
|
+
const overlayState = {
|
|
430
|
+
get isOpen() {
|
|
431
|
+
return isOpen();
|
|
432
|
+
},
|
|
433
|
+
open: () => setOpen(true),
|
|
434
|
+
close: () => setOpen(false),
|
|
435
|
+
toggle: () => setOpen(!isOpen())
|
|
436
|
+
};
|
|
437
|
+
const [internalRangeValue, setInternalRangeValue] = createSignal(stateProps.defaultValue ?? null);
|
|
438
|
+
const currentRangeValue = createMemo(() => {
|
|
439
|
+
const controlled = access(stateProps.value);
|
|
440
|
+
return controlled !== void 0 ? controlled : internalRangeValue();
|
|
441
|
+
});
|
|
442
|
+
const setCommittedRangeValue = (value) => {
|
|
443
|
+
if (access(stateProps.value) === void 0) setInternalRangeValue(() => value);
|
|
444
|
+
stateProps.onChange?.(value);
|
|
445
|
+
};
|
|
446
|
+
const calendarState = createRangeCalendarState({
|
|
447
|
+
...stateProps,
|
|
448
|
+
value: currentRangeValue,
|
|
449
|
+
onChange: (value) => {
|
|
450
|
+
setCommittedRangeValue(value);
|
|
451
|
+
if (local.shouldCloseOnSelect !== false && value?.start && value?.end) setOpen(false);
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
const isInvalid = createMemo(() => Boolean(rest.isInvalid) || calendarState.validationState() === "invalid");
|
|
455
|
+
const isRequired = createMemo(() => Boolean(rest.isRequired));
|
|
456
|
+
const [startFieldValue, setStartFieldValue] = createSignal(currentRangeValue()?.start ?? null);
|
|
457
|
+
const [endFieldValue, setEndFieldValue] = createSignal(currentRangeValue()?.end ?? null);
|
|
458
|
+
const rangeGranularity = createMemo(() => {
|
|
459
|
+
if (stateProps.granularity) return stateProps.granularity;
|
|
460
|
+
const value = currentRangeValue()?.start ?? currentRangeValue()?.end;
|
|
461
|
+
if (value && "hour" in value) return "second" in value ? "second" : "minute";
|
|
462
|
+
return "day";
|
|
463
|
+
});
|
|
464
|
+
createEffect(() => {
|
|
465
|
+
const value = currentRangeValue();
|
|
466
|
+
setStartFieldValue(() => value?.start ?? null);
|
|
467
|
+
setEndFieldValue(() => value?.end ?? null);
|
|
468
|
+
});
|
|
469
|
+
const setRangeFieldValue = (part, nextValue) => {
|
|
470
|
+
if (part === "start") setStartFieldValue(() => nextValue);
|
|
471
|
+
else setEndFieldValue(() => nextValue);
|
|
472
|
+
const nextStart = part === "start" ? nextValue : startFieldValue();
|
|
473
|
+
const nextEnd = part === "end" ? nextValue : endFieldValue();
|
|
474
|
+
setCommittedRangeValue(nextStart && nextEnd ? {
|
|
475
|
+
start: nextStart,
|
|
476
|
+
end: nextEnd
|
|
477
|
+
} : null);
|
|
478
|
+
};
|
|
479
|
+
const rangeFieldStateProps = {
|
|
480
|
+
minValue: stateProps.minValue,
|
|
481
|
+
maxValue: stateProps.maxValue,
|
|
482
|
+
isDisabled: stateProps.isDisabled,
|
|
483
|
+
isReadOnly: stateProps.isReadOnly,
|
|
484
|
+
isRequired,
|
|
485
|
+
locale: access(stateProps.locale),
|
|
486
|
+
granularity: rangeGranularity(),
|
|
487
|
+
hourCycle: stateProps.hourCycle,
|
|
488
|
+
hideTimeZone: stateProps.hideTimeZone,
|
|
489
|
+
placeholderValue: stateProps.placeholderValue,
|
|
490
|
+
validationState: () => isInvalid() ? "invalid" : access(stateProps.validationState),
|
|
491
|
+
isDateUnavailable: stateProps.isDateUnavailable ? (date) => stateProps.isDateUnavailable(date, null) : void 0
|
|
492
|
+
};
|
|
493
|
+
const startFieldState = createDateFieldState({
|
|
494
|
+
...rangeFieldStateProps,
|
|
495
|
+
value: startFieldValue,
|
|
496
|
+
onChange: (value) => setRangeFieldValue("start", value)
|
|
497
|
+
});
|
|
498
|
+
const endFieldState = createDateFieldState({
|
|
499
|
+
...rangeFieldStateProps,
|
|
500
|
+
value: endFieldValue,
|
|
501
|
+
onChange: (value) => setRangeFieldValue("end", value)
|
|
502
|
+
});
|
|
503
|
+
const pickerAria = createDateRangePicker(() => ({
|
|
504
|
+
...rest,
|
|
505
|
+
description: props.description,
|
|
506
|
+
errorMessage: props.errorMessage
|
|
507
|
+
}), calendarState, overlayState);
|
|
508
|
+
const contextValue = {
|
|
509
|
+
calendarState,
|
|
510
|
+
startFieldState,
|
|
511
|
+
endFieldState,
|
|
512
|
+
startFieldContext: {
|
|
513
|
+
state: startFieldState,
|
|
514
|
+
aria: {
|
|
515
|
+
labelProps: {},
|
|
516
|
+
get inputProps() {
|
|
517
|
+
return pickerAria.startInputProps;
|
|
518
|
+
},
|
|
519
|
+
get descriptionProps() {
|
|
520
|
+
return pickerAria.descriptionProps;
|
|
521
|
+
},
|
|
522
|
+
get errorMessageProps() {
|
|
523
|
+
return pickerAria.errorMessageProps;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
endFieldContext: {
|
|
528
|
+
state: endFieldState,
|
|
529
|
+
aria: {
|
|
530
|
+
labelProps: {},
|
|
531
|
+
get inputProps() {
|
|
532
|
+
return pickerAria.endInputProps;
|
|
533
|
+
},
|
|
534
|
+
get descriptionProps() {
|
|
535
|
+
return pickerAria.descriptionProps;
|
|
536
|
+
},
|
|
537
|
+
get errorMessageProps() {
|
|
538
|
+
return pickerAria.errorMessageProps;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
},
|
|
542
|
+
overlayState,
|
|
543
|
+
triggerRef: () => triggerRef,
|
|
544
|
+
setTriggerRef: (element) => {
|
|
545
|
+
if (!element) return;
|
|
546
|
+
if (!triggerRef || !triggerRef.isConnected) triggerRef = element;
|
|
547
|
+
},
|
|
548
|
+
pickerAria
|
|
549
|
+
};
|
|
550
|
+
const renderValues = createMemo(() => ({
|
|
551
|
+
isDisabled: calendarState.isDisabled(),
|
|
552
|
+
isReadOnly: calendarState.isReadOnly(),
|
|
553
|
+
isRequired: isRequired(),
|
|
554
|
+
isInvalid: isInvalid(),
|
|
555
|
+
isOpen: overlayState.isOpen
|
|
556
|
+
}));
|
|
557
|
+
const renderProps = useRenderProps({
|
|
558
|
+
class: local.class,
|
|
559
|
+
style: local.style,
|
|
560
|
+
defaultClassName: "solidaria-DateRangePicker"
|
|
561
|
+
}, renderValues);
|
|
562
|
+
return createComponent(DateRangePickerStateContext.Provider, {
|
|
563
|
+
value: calendarState,
|
|
564
|
+
get children() {
|
|
565
|
+
return createComponent(DateRangePickerContext.Provider, {
|
|
566
|
+
value: contextValue,
|
|
567
|
+
get children() {
|
|
568
|
+
return createComponent(RangeCalendarContext.Provider, {
|
|
569
|
+
value: calendarState,
|
|
570
|
+
get children() {
|
|
571
|
+
return [
|
|
572
|
+
(() => {
|
|
573
|
+
var _el$4 = getNextElement(_tmpl$2);
|
|
574
|
+
spread(_el$4, mergeProps(() => pickerAria.groupProps, {
|
|
575
|
+
get ["class"]() {
|
|
576
|
+
return renderProps.class();
|
|
577
|
+
},
|
|
578
|
+
get style() {
|
|
579
|
+
return renderProps.style();
|
|
580
|
+
},
|
|
581
|
+
get ["data-disabled"]() {
|
|
582
|
+
return dataAttr(calendarState.isDisabled());
|
|
583
|
+
},
|
|
584
|
+
get ["data-readonly"]() {
|
|
585
|
+
return dataAttr(calendarState.isReadOnly());
|
|
586
|
+
},
|
|
587
|
+
get ["data-required"]() {
|
|
588
|
+
return dataAttr(isRequired());
|
|
589
|
+
},
|
|
590
|
+
get ["data-invalid"]() {
|
|
591
|
+
return dataAttr(isInvalid());
|
|
592
|
+
},
|
|
593
|
+
get ["data-open"]() {
|
|
594
|
+
return dataAttr(overlayState.isOpen);
|
|
595
|
+
}
|
|
596
|
+
}), false, true);
|
|
597
|
+
insert(_el$4, createComponent(Provider, {
|
|
598
|
+
values: [[TextContext, { slots: {
|
|
599
|
+
get description() {
|
|
600
|
+
return pickerAria.descriptionProps;
|
|
601
|
+
},
|
|
602
|
+
get errorMessage() {
|
|
603
|
+
return pickerAria.errorMessageProps;
|
|
604
|
+
}
|
|
605
|
+
} }]],
|
|
606
|
+
get children() {
|
|
607
|
+
return props.children;
|
|
608
|
+
}
|
|
609
|
+
}));
|
|
610
|
+
runHydrationEvents();
|
|
611
|
+
return _el$4;
|
|
612
|
+
})(),
|
|
613
|
+
createComponent(Show, {
|
|
614
|
+
get when() {
|
|
615
|
+
return rest.startName;
|
|
616
|
+
},
|
|
617
|
+
get children() {
|
|
618
|
+
return createComponent(HiddenDateInput, {
|
|
619
|
+
get name() {
|
|
620
|
+
return rest.startName;
|
|
621
|
+
},
|
|
622
|
+
get form() {
|
|
623
|
+
return rest.form;
|
|
624
|
+
},
|
|
625
|
+
value: () => currentRangeValue()?.start ?? null,
|
|
626
|
+
get isDisabled() {
|
|
627
|
+
return access(stateProps.isDisabled) ?? false;
|
|
628
|
+
},
|
|
629
|
+
minValue: () => access(stateProps.minValue),
|
|
630
|
+
maxValue: () => access(stateProps.maxValue),
|
|
631
|
+
get granularity() {
|
|
632
|
+
return rangeGranularity();
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
}),
|
|
637
|
+
createComponent(Show, {
|
|
638
|
+
get when() {
|
|
639
|
+
return rest.endName;
|
|
640
|
+
},
|
|
641
|
+
get children() {
|
|
642
|
+
return createComponent(HiddenDateInput, {
|
|
643
|
+
get name() {
|
|
644
|
+
return rest.endName;
|
|
645
|
+
},
|
|
646
|
+
get form() {
|
|
647
|
+
return rest.form;
|
|
648
|
+
},
|
|
649
|
+
value: () => currentRangeValue()?.end ?? null,
|
|
650
|
+
get isDisabled() {
|
|
651
|
+
return access(stateProps.isDisabled) ?? false;
|
|
652
|
+
},
|
|
653
|
+
minValue: () => access(stateProps.minValue),
|
|
654
|
+
maxValue: () => access(stateProps.maxValue),
|
|
655
|
+
get granularity() {
|
|
656
|
+
return rangeGranularity();
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
})
|
|
661
|
+
];
|
|
662
|
+
}
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* A button that opens the date picker calendar.
|
|
671
|
+
*/
|
|
672
|
+
function DatePickerButton(props) {
|
|
673
|
+
const context = useDatePickerContext();
|
|
674
|
+
const renderValues = createMemo(() => ({
|
|
675
|
+
isDisabled: context.fieldState.isDisabled() || (props.isDisabled ?? false),
|
|
676
|
+
isOpen: context.overlayState.isOpen
|
|
677
|
+
}));
|
|
678
|
+
const renderProps = useRenderProps({
|
|
679
|
+
get children() {
|
|
680
|
+
return props.children;
|
|
681
|
+
},
|
|
682
|
+
class: props.class,
|
|
683
|
+
style: props.style,
|
|
684
|
+
defaultClassName: "solidaria-DatePickerButton"
|
|
685
|
+
}, renderValues);
|
|
686
|
+
const getChildren = () => {
|
|
687
|
+
if (typeof props.children === "function") return renderProps.renderChildren();
|
|
688
|
+
return props.children ?? "📅";
|
|
689
|
+
};
|
|
690
|
+
return (() => {
|
|
691
|
+
var _el$5 = getNextElement(_tmpl$4);
|
|
692
|
+
use((el) => {
|
|
693
|
+
context.setTriggerRef(el);
|
|
694
|
+
}, _el$5);
|
|
695
|
+
spread(_el$5, mergeProps(() => context.pickerAria.buttonProps, {
|
|
696
|
+
get ["class"]() {
|
|
697
|
+
return renderProps.class();
|
|
698
|
+
},
|
|
699
|
+
get style() {
|
|
700
|
+
return renderProps.style();
|
|
701
|
+
},
|
|
702
|
+
get disabled() {
|
|
703
|
+
return context.fieldState.isDisabled() || props.isDisabled;
|
|
704
|
+
},
|
|
705
|
+
get ["data-disabled"]() {
|
|
706
|
+
return dataAttr(context.fieldState.isDisabled() || props.isDisabled);
|
|
707
|
+
},
|
|
708
|
+
get ["data-open"]() {
|
|
709
|
+
return dataAttr(context.overlayState.isOpen);
|
|
710
|
+
}
|
|
711
|
+
}), false, true);
|
|
712
|
+
insert(_el$5, getChildren);
|
|
713
|
+
runHydrationEvents();
|
|
714
|
+
return _el$5;
|
|
715
|
+
})();
|
|
716
|
+
}
|
|
717
|
+
function DateRangePickerButton(props) {
|
|
718
|
+
const context = useDateRangePickerContext();
|
|
719
|
+
const renderValues = createMemo(() => ({
|
|
720
|
+
isDisabled: context.calendarState.isDisabled() || (props.isDisabled ?? false),
|
|
721
|
+
isOpen: context.overlayState.isOpen
|
|
722
|
+
}));
|
|
723
|
+
const renderProps = useRenderProps({
|
|
724
|
+
get children() {
|
|
725
|
+
return props.children;
|
|
726
|
+
},
|
|
727
|
+
class: props.class,
|
|
728
|
+
style: props.style,
|
|
729
|
+
defaultClassName: "solidaria-DateRangePickerButton"
|
|
730
|
+
}, renderValues);
|
|
731
|
+
const getChildren = () => {
|
|
732
|
+
if (typeof props.children === "function") return renderProps.renderChildren();
|
|
733
|
+
return props.children ?? "📅";
|
|
734
|
+
};
|
|
735
|
+
return (() => {
|
|
736
|
+
var _el$6 = getNextElement(_tmpl$4);
|
|
737
|
+
use((el) => context.setTriggerRef(el), _el$6);
|
|
738
|
+
spread(_el$6, mergeProps(() => context.pickerAria.buttonProps, {
|
|
739
|
+
get ["class"]() {
|
|
740
|
+
return renderProps.class();
|
|
741
|
+
},
|
|
742
|
+
get style() {
|
|
743
|
+
return renderProps.style();
|
|
744
|
+
},
|
|
745
|
+
get disabled() {
|
|
746
|
+
return context.calendarState.isDisabled() || props.isDisabled;
|
|
747
|
+
},
|
|
748
|
+
get ["data-disabled"]() {
|
|
749
|
+
return dataAttr(context.calendarState.isDisabled() || props.isDisabled);
|
|
750
|
+
},
|
|
751
|
+
get ["data-open"]() {
|
|
752
|
+
return dataAttr(context.overlayState.isOpen);
|
|
753
|
+
}
|
|
754
|
+
}), false, true);
|
|
755
|
+
insert(_el$6, getChildren);
|
|
756
|
+
runHydrationEvents();
|
|
757
|
+
return _el$6;
|
|
758
|
+
})();
|
|
759
|
+
}
|
|
760
|
+
function DatePickerLabel(props) {
|
|
761
|
+
const context = useDatePickerContext();
|
|
762
|
+
return (() => {
|
|
763
|
+
var _el$7 = getNextElement(_tmpl$5);
|
|
764
|
+
spread(_el$7, mergeProps(() => context.pickerAria.labelProps, { get ["class"]() {
|
|
765
|
+
return props.class;
|
|
766
|
+
} }), false, true);
|
|
767
|
+
insert(_el$7, () => props.children);
|
|
768
|
+
runHydrationEvents();
|
|
769
|
+
return _el$7;
|
|
770
|
+
})();
|
|
771
|
+
}
|
|
772
|
+
function DatePickerDescription(props) {
|
|
773
|
+
const context = useDatePickerContext();
|
|
774
|
+
return (() => {
|
|
775
|
+
var _el$8 = getNextElement(_tmpl$6);
|
|
776
|
+
spread(_el$8, mergeProps(() => context.pickerAria.descriptionProps, { get ["class"]() {
|
|
777
|
+
return props.class;
|
|
778
|
+
} }), false, true);
|
|
779
|
+
insert(_el$8, () => props.children);
|
|
780
|
+
runHydrationEvents();
|
|
781
|
+
return _el$8;
|
|
782
|
+
})();
|
|
783
|
+
}
|
|
784
|
+
function DatePickerErrorMessage(props) {
|
|
785
|
+
const context = useDatePickerContext();
|
|
786
|
+
return (() => {
|
|
787
|
+
var _el$9 = getNextElement(_tmpl$6);
|
|
788
|
+
spread(_el$9, mergeProps(() => context.pickerAria.errorMessageProps, { get ["class"]() {
|
|
789
|
+
return props.class;
|
|
790
|
+
} }), false, true);
|
|
791
|
+
insert(_el$9, () => props.children);
|
|
792
|
+
runHydrationEvents();
|
|
793
|
+
return _el$9;
|
|
794
|
+
})();
|
|
795
|
+
}
|
|
796
|
+
function DateRangePickerLabel(props) {
|
|
797
|
+
const context = useDateRangePickerContext();
|
|
798
|
+
return (() => {
|
|
799
|
+
var _el$0 = getNextElement(_tmpl$5);
|
|
800
|
+
spread(_el$0, mergeProps(() => context.pickerAria.labelProps, { get ["class"]() {
|
|
801
|
+
return props.class;
|
|
802
|
+
} }), false, true);
|
|
803
|
+
insert(_el$0, () => props.children);
|
|
804
|
+
runHydrationEvents();
|
|
805
|
+
return _el$0;
|
|
806
|
+
})();
|
|
807
|
+
}
|
|
808
|
+
function DateRangePickerDescription(props) {
|
|
809
|
+
const context = useDateRangePickerContext();
|
|
810
|
+
return (() => {
|
|
811
|
+
var _el$1 = getNextElement(_tmpl$6);
|
|
812
|
+
spread(_el$1, mergeProps(() => context.pickerAria.descriptionProps, { get ["class"]() {
|
|
813
|
+
return props.class;
|
|
814
|
+
} }), false, true);
|
|
815
|
+
insert(_el$1, () => props.children);
|
|
816
|
+
runHydrationEvents();
|
|
817
|
+
return _el$1;
|
|
818
|
+
})();
|
|
819
|
+
}
|
|
820
|
+
function DateRangePickerErrorMessage(props) {
|
|
821
|
+
const context = useDateRangePickerContext();
|
|
822
|
+
return (() => {
|
|
823
|
+
var _el$10 = getNextElement(_tmpl$6);
|
|
824
|
+
spread(_el$10, mergeProps(() => context.pickerAria.errorMessageProps, { get ["class"]() {
|
|
825
|
+
return props.class;
|
|
826
|
+
} }), false, true);
|
|
827
|
+
insert(_el$10, () => props.children);
|
|
828
|
+
runHydrationEvents();
|
|
829
|
+
return _el$10;
|
|
830
|
+
})();
|
|
831
|
+
}
|
|
832
|
+
function createEscapeDismissFallback(isOpen, close) {
|
|
833
|
+
createEffect(() => {
|
|
834
|
+
if (!isOpen() || typeof document === "undefined") return;
|
|
835
|
+
const onKeyDown = (event) => {
|
|
836
|
+
if (event.key !== "Escape" || event.defaultPrevented || event.isComposing) return;
|
|
837
|
+
close();
|
|
838
|
+
};
|
|
839
|
+
document.addEventListener("keydown", onKeyDown);
|
|
840
|
+
onCleanup(() => document.removeEventListener("keydown", onKeyDown));
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* The content area of the date picker (typically contains a Calendar).
|
|
845
|
+
*/
|
|
846
|
+
function DatePickerContent(props) {
|
|
847
|
+
const context = useDatePickerContext();
|
|
848
|
+
const portalContext = useUNSAFE_PortalContext();
|
|
849
|
+
let contentRef;
|
|
850
|
+
const portalContainer = () => portalContext.getContainer?.() ?? void 0;
|
|
851
|
+
const popoverAria = createPopover({
|
|
852
|
+
triggerRef: () => context.triggerRef()?.parentElement ?? context.triggerRef(),
|
|
853
|
+
popoverRef: () => contentRef ?? null,
|
|
854
|
+
placement: "bottom start",
|
|
855
|
+
offset: 8,
|
|
856
|
+
isNonModal: false,
|
|
857
|
+
isKeyboardDismissDisabled: false
|
|
858
|
+
}, {
|
|
859
|
+
isOpen: () => context.overlayState.isOpen,
|
|
860
|
+
open: context.overlayState.open,
|
|
861
|
+
close: context.overlayState.close,
|
|
862
|
+
toggle: context.overlayState.toggle
|
|
863
|
+
});
|
|
864
|
+
createEscapeDismissFallback(() => context.overlayState.isOpen, context.overlayState.close);
|
|
865
|
+
const cleanPopoverProps = () => {
|
|
866
|
+
const { style: _style, ref: _ref, ...rest } = popoverAria.popoverProps;
|
|
867
|
+
return rest;
|
|
868
|
+
};
|
|
869
|
+
const mergedStyle = () => {
|
|
870
|
+
return {
|
|
871
|
+
...popoverAria.popoverProps.style,
|
|
872
|
+
...props.style
|
|
873
|
+
};
|
|
874
|
+
};
|
|
875
|
+
createEffect(() => {
|
|
876
|
+
if (!context.overlayState.isOpen) requestAnimationFrame(() => context.triggerRef()?.focus());
|
|
877
|
+
});
|
|
878
|
+
return createComponent(Show, {
|
|
879
|
+
get when() {
|
|
880
|
+
return context.overlayState.isOpen;
|
|
881
|
+
},
|
|
882
|
+
get children() {
|
|
883
|
+
return createComponent(Portal, {
|
|
884
|
+
get mount() {
|
|
885
|
+
return portalContainer();
|
|
886
|
+
},
|
|
887
|
+
get children() {
|
|
888
|
+
return createComponent(FocusScope, {
|
|
889
|
+
contain: true,
|
|
890
|
+
restoreFocus: true,
|
|
891
|
+
get children() {
|
|
892
|
+
var _el$11 = getNextElement(_tmpl$2);
|
|
893
|
+
var _ref$ = contentRef;
|
|
894
|
+
typeof _ref$ === "function" ? use(_ref$, _el$11) : contentRef = _el$11;
|
|
895
|
+
spread(_el$11, mergeProps(cleanPopoverProps, () => context.pickerAria.dialogProps, {
|
|
896
|
+
"tabIndex": -1,
|
|
897
|
+
get ["class"]() {
|
|
898
|
+
return props.class ?? "solidaria-DatePickerContent";
|
|
899
|
+
},
|
|
900
|
+
get style() {
|
|
901
|
+
return mergedStyle();
|
|
902
|
+
},
|
|
903
|
+
get ["data-placement"]() {
|
|
904
|
+
return popoverAria.placement() ?? void 0;
|
|
905
|
+
}
|
|
906
|
+
}), false, true);
|
|
907
|
+
insert(_el$11, () => props.children);
|
|
908
|
+
runHydrationEvents();
|
|
909
|
+
return _el$11;
|
|
910
|
+
}
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
function DateRangePickerContent(props) {
|
|
918
|
+
const context = useDateRangePickerContext();
|
|
919
|
+
const portalContext = useUNSAFE_PortalContext();
|
|
920
|
+
let contentRef;
|
|
921
|
+
const portalContainer = () => portalContext.getContainer?.() ?? void 0;
|
|
922
|
+
const popoverAria = createPopover({
|
|
923
|
+
triggerRef: () => context.triggerRef()?.parentElement ?? context.triggerRef(),
|
|
924
|
+
popoverRef: () => contentRef ?? null,
|
|
925
|
+
placement: "bottom start",
|
|
926
|
+
offset: 8,
|
|
927
|
+
isNonModal: false,
|
|
928
|
+
isKeyboardDismissDisabled: false
|
|
929
|
+
}, {
|
|
930
|
+
isOpen: () => context.overlayState.isOpen,
|
|
931
|
+
open: context.overlayState.open,
|
|
932
|
+
close: context.overlayState.close,
|
|
933
|
+
toggle: context.overlayState.toggle
|
|
934
|
+
});
|
|
935
|
+
createEscapeDismissFallback(() => context.overlayState.isOpen, context.overlayState.close);
|
|
936
|
+
const cleanPopoverProps = () => {
|
|
937
|
+
const { style: _style, ref: _ref, ...rest } = popoverAria.popoverProps;
|
|
938
|
+
return rest;
|
|
939
|
+
};
|
|
940
|
+
const mergedStyle = () => {
|
|
941
|
+
return {
|
|
942
|
+
...popoverAria.popoverProps.style,
|
|
943
|
+
...props.style
|
|
944
|
+
};
|
|
945
|
+
};
|
|
946
|
+
createEffect(() => {
|
|
947
|
+
if (!context.overlayState.isOpen) requestAnimationFrame(() => context.triggerRef()?.focus());
|
|
948
|
+
});
|
|
949
|
+
return createComponent(Show, {
|
|
950
|
+
get when() {
|
|
951
|
+
return context.overlayState.isOpen;
|
|
952
|
+
},
|
|
953
|
+
get children() {
|
|
954
|
+
return createComponent(Portal, {
|
|
955
|
+
get mount() {
|
|
956
|
+
return portalContainer();
|
|
957
|
+
},
|
|
958
|
+
get children() {
|
|
959
|
+
return createComponent(FocusScope, {
|
|
960
|
+
contain: true,
|
|
961
|
+
restoreFocus: true,
|
|
962
|
+
get children() {
|
|
963
|
+
var _el$12 = getNextElement(_tmpl$2);
|
|
964
|
+
var _ref$2 = contentRef;
|
|
965
|
+
typeof _ref$2 === "function" ? use(_ref$2, _el$12) : contentRef = _el$12;
|
|
966
|
+
spread(_el$12, mergeProps(cleanPopoverProps, () => context.pickerAria.dialogProps, {
|
|
967
|
+
"tabIndex": -1,
|
|
968
|
+
get ["class"]() {
|
|
969
|
+
return props.class ?? "solidaria-DateRangePickerContent";
|
|
970
|
+
},
|
|
971
|
+
get style() {
|
|
972
|
+
return mergedStyle();
|
|
973
|
+
},
|
|
974
|
+
get ["data-placement"]() {
|
|
975
|
+
return popoverAria.placement() ?? void 0;
|
|
976
|
+
}
|
|
977
|
+
}), false, true);
|
|
978
|
+
insert(_el$12, () => props.children);
|
|
979
|
+
runHydrationEvents();
|
|
980
|
+
return _el$12;
|
|
981
|
+
}
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
//#endregion
|
|
989
|
+
export { DatePicker, DatePickerButton, DatePickerContent, DatePickerContext, DatePickerDescription, DatePickerErrorMessage, DatePickerLabel, DatePickerStateContext, DateRangePicker, DateRangePickerButton, DateRangePickerContent, DateRangePickerContext, DateRangePickerDescription, DateRangePickerErrorMessage, DateRangePickerLabel, DateRangePickerStateContext, HiddenDateInput, useDatePickerContext, useDateRangePickerContext };
|
|
990
|
+
|
|
991
|
+
//# sourceMappingURL=DatePicker.js.map
|