@ecopages/radiant-ui 0.1.0-rc.7 → 0.1.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/README.md +11 -3
- package/dist/components/ui/alert/alert.d.ts +2 -4
- package/dist/components/ui/alert/alert.script.d.ts +25 -15
- package/dist/components/ui/autocomplete/autocomplete.css +1 -2
- package/dist/components/ui/autocomplete/autocomplete.d.ts +8 -3
- package/dist/components/ui/autocomplete/autocomplete.script.d.ts +29 -4
- package/dist/components/ui/avatar/avatar.css +10 -8
- package/dist/components/ui/avatar/avatar.d.ts +3 -1
- package/dist/components/ui/breadcrumb/breadcrumb.d.ts +11 -11
- package/dist/components/ui/breadcrumb/breadcrumb.script.d.ts +10 -10
- package/dist/components/ui/calendar/calendar.css +10 -5
- package/dist/components/ui/calendar/calendar.script.d.ts +24 -21
- package/dist/components/ui/calendar/index.js +1 -1
- package/dist/components/ui/calendar/index.js.map +3 -3
- package/dist/components/ui/carousel/carousel-autoplay.d.ts +22 -0
- package/dist/components/ui/carousel/carousel-swipe.d.ts +17 -0
- package/dist/components/ui/carousel/carousel-window.d.ts +63 -0
- package/dist/components/ui/carousel/carousel.css +71 -18
- package/dist/components/ui/carousel/carousel.d.ts +8 -4
- package/dist/components/ui/carousel/carousel.script.d.ts +73 -40
- package/dist/components/ui/carousel/index.js +1 -1
- package/dist/components/ui/carousel/index.js.map +4 -4
- package/dist/components/ui/checkbox/checkbox.d.ts +11 -0
- package/dist/components/ui/checkbox/checkbox.script.d.ts +31 -8
- package/dist/components/ui/checkbox/index.js +1 -1
- package/dist/components/ui/checkbox/index.js.map +4 -4
- package/dist/components/ui/checkbox-group/checkbox-group.d.ts +4 -2
- package/dist/components/ui/checkbox-group/checkbox-group.script.d.ts +39 -20
- package/dist/components/ui/checkbox-group/index.js +1 -1
- package/dist/components/ui/checkbox-group/index.js.map +4 -4
- package/dist/components/ui/combobox/combobox.css +9 -1
- package/dist/components/ui/combobox/combobox.d.ts +12 -4
- package/dist/components/ui/combobox/combobox.script.d.ts +74 -25
- package/dist/components/ui/combobox/index.d.ts +2 -2
- package/dist/components/ui/combobox/index.js +1 -1
- package/dist/components/ui/combobox/index.js.map +4 -4
- package/dist/components/ui/cycle-toggle/cycle-toggle.d.ts +6 -2
- package/dist/components/ui/cycle-toggle/cycle-toggle.script.d.ts +35 -4
- package/dist/components/ui/cycle-toggle/index.js +1 -1
- package/dist/components/ui/cycle-toggle/index.js.map +3 -3
- package/dist/components/ui/date-field/date-field.css +13 -17
- package/dist/components/ui/date-field/date-field.d.ts +10 -8
- package/dist/components/ui/date-field/date-field.script.d.ts +35 -52
- package/dist/components/ui/date-field/index.js +1 -1
- package/dist/components/ui/date-field/index.js.map +4 -4
- package/dist/components/ui/date-input/date-input-segment-dom.d.ts +24 -0
- package/dist/components/ui/date-input/date-input.css +50 -0
- package/dist/components/ui/date-input/date-input.d.ts +8 -0
- package/dist/components/ui/date-input/date-input.script.d.ts +137 -0
- package/dist/components/ui/date-input/index.d.ts +2 -0
- package/dist/components/ui/date-input/index.js +2 -0
- package/dist/components/ui/date-input/index.js.map +7 -0
- package/dist/components/ui/date-range-picker/date-range-picker.css +18 -19
- package/dist/components/ui/date-range-picker/date-range-picker.d.ts +11 -9
- package/dist/components/ui/date-range-picker/date-range-picker.script.d.ts +42 -51
- package/dist/components/ui/date-range-picker/index.js +1 -1
- package/dist/components/ui/date-range-picker/index.js.map +4 -4
- package/dist/components/ui/dialog/dialog.css +18 -14
- package/dist/components/ui/dialog/dialog.d.ts +6 -0
- package/dist/components/ui/dialog/dialog.script.d.ts +43 -10
- package/dist/components/ui/dialog/index.js +1 -1
- package/dist/components/ui/dialog/index.js.map +4 -4
- package/dist/components/ui/disclosure/disclosure-group.script.d.ts +19 -3
- package/dist/components/ui/disclosure/disclosure.css +3 -6
- package/dist/components/ui/disclosure/disclosure.d.ts +23 -7
- package/dist/components/ui/disclosure/disclosure.script.d.ts +31 -7
- package/dist/components/ui/disclosure/index.d.ts +1 -1
- package/dist/components/ui/disclosure/index.js +1 -1
- package/dist/components/ui/disclosure/index.js.map +4 -4
- package/dist/components/ui/field/field-description.d.ts +1 -0
- package/dist/components/ui/field/field-error.d.ts +2 -2
- package/dist/components/ui/field/field.d.ts +4 -4
- package/dist/components/ui/field/field.script.d.ts +54 -24
- package/dist/components/ui/field/index.js +1 -1
- package/dist/components/ui/field/index.js.map +4 -4
- package/dist/components/ui/form/control-protocol.d.ts +38 -1
- package/dist/components/ui/form/form-context.d.ts +3 -0
- package/dist/components/ui/form/form.d.ts +6 -0
- package/dist/components/ui/form/form.script.d.ts +29 -12
- package/dist/components/ui/form/index.d.ts +2 -1
- package/dist/components/ui/form/index.js +1 -1
- package/dist/components/ui/form/index.js.map +4 -4
- package/dist/components/ui/grid/grid.d.ts +4 -3
- package/dist/components/ui/grid/grid.script.d.ts +19 -11
- package/dist/components/ui/hover-card/hover-card.css +12 -101
- package/dist/components/ui/hover-card/hover-card.d.ts +7 -2
- package/dist/components/ui/hover-card/hover-card.script.d.ts +36 -5
- package/dist/components/ui/hover-card/index.js +1 -1
- package/dist/components/ui/hover-card/index.js.map +4 -4
- package/dist/components/ui/input/index.js +1 -1
- package/dist/components/ui/input/index.js.map +4 -4
- package/dist/components/ui/input/input.css +1 -1
- package/dist/components/ui/knob/index.js +1 -1
- package/dist/components/ui/knob/index.js.map +3 -3
- package/dist/components/ui/knob/knob.css +6 -1
- package/dist/components/ui/knob/knob.d.ts +4 -4
- package/dist/components/ui/knob/knob.script.d.ts +55 -20
- package/dist/components/ui/label/index.js +1 -1
- package/dist/components/ui/label/index.js.map +4 -4
- package/dist/components/ui/label/label.d.ts +2 -1
- package/dist/components/ui/listbox/index.d.ts +2 -2
- package/dist/components/ui/listbox/index.js +1 -1
- package/dist/components/ui/listbox/index.js.map +4 -4
- package/dist/components/ui/listbox/listbox.css +14 -0
- package/dist/components/ui/listbox/listbox.d.ts +16 -2
- package/dist/components/ui/listbox/listbox.script.d.ts +55 -12
- package/dist/components/ui/menu-button/index.js +1 -1
- package/dist/components/ui/menu-button/index.js.map +4 -4
- package/dist/components/ui/menu-button/menu-button.d.ts +2 -2
- package/dist/components/ui/menu-button/menu-button.script.d.ts +30 -27
- package/dist/components/ui/menubar/index.js +1 -1
- package/dist/components/ui/menubar/index.js.map +4 -4
- package/dist/components/ui/menubar/menubar.script.d.ts +41 -15
- package/dist/components/ui/meter/index.js +1 -1
- package/dist/components/ui/meter/index.js.map +3 -3
- package/dist/components/ui/meter/meter.css +27 -2
- package/dist/components/ui/meter/meter.script.d.ts +19 -14
- package/dist/components/ui/navigation-menu/index.d.ts +1 -1
- package/dist/components/ui/navigation-menu/index.js +1 -1
- package/dist/components/ui/navigation-menu/index.js.map +4 -4
- package/dist/components/ui/navigation-menu/navigation-menu.css +32 -34
- package/dist/components/ui/navigation-menu/navigation-menu.d.ts +34 -5
- package/dist/components/ui/navigation-menu/navigation-menu.script.d.ts +93 -12
- package/dist/components/ui/number-field/index.js +1 -1
- package/dist/components/ui/number-field/index.js.map +4 -4
- package/dist/components/ui/number-field/number-field.css +1 -1
- package/dist/components/ui/number-field/number-field.d.ts +8 -19
- package/dist/components/ui/number-field/number-field.script.d.ts +30 -9
- package/dist/components/ui/pagination/index.d.ts +1 -1
- package/dist/components/ui/pagination/index.js +1 -1
- package/dist/components/ui/pagination/index.js.map +3 -3
- package/dist/components/ui/pagination/pagination.css +50 -13
- package/dist/components/ui/pagination/pagination.d.ts +33 -9
- package/dist/components/ui/pagination/pagination.script.d.ts +29 -9
- package/dist/components/ui/popover/index.js +1 -1
- package/dist/components/ui/popover/index.js.map +4 -4
- package/dist/components/ui/popover/popover.d.ts +17 -1
- package/dist/components/ui/popover/popover.script.d.ts +57 -9
- package/dist/components/ui/radio-group/index.js +1 -1
- package/dist/components/ui/radio-group/index.js.map +4 -4
- package/dist/components/ui/radio-group/radio-group.d.ts +2 -2
- package/dist/components/ui/radio-group/radio-group.script.d.ts +35 -16
- package/dist/components/ui/select/index.d.ts +2 -2
- package/dist/components/ui/select/index.js +1 -1
- package/dist/components/ui/select/index.js.map +4 -4
- package/dist/components/ui/select/select.css +8 -6
- package/dist/components/ui/select/select.d.ts +18 -9
- package/dist/components/ui/select/select.script.d.ts +74 -26
- package/dist/components/ui/shared/calendar-popover-behavior.d.ts +27 -0
- package/dist/components/ui/shared/control-toggle.css +8 -4
- package/dist/components/ui/shared/field-label.d.ts +5 -0
- package/dist/components/ui/shared/listbox-host-controller.d.ts +41 -0
- package/dist/components/ui/shared/listbox-option.d.ts +4 -0
- package/dist/components/ui/shared/multi-value.d.ts +23 -1
- package/dist/components/ui/shared/numeric-range.d.ts +8 -0
- package/dist/components/ui/shared/popover.css +10 -99
- package/dist/components/ui/sidebar/index.d.ts +2 -1
- package/dist/components/ui/sidebar/index.js +1 -1
- package/dist/components/ui/sidebar/index.js.map +4 -4
- package/dist/components/ui/sidebar/sidebar-trigger.d.ts +12 -0
- package/dist/components/ui/sidebar/sidebar-trigger.script.d.ts +52 -31
- package/dist/components/ui/sidebar/sidebar.css +67 -61
- package/dist/components/ui/sidebar/sidebar.d.ts +9 -4
- package/dist/components/ui/sidebar/sidebar.script.d.ts +42 -20
- package/dist/components/ui/slider/index.js +1 -1
- package/dist/components/ui/slider/index.js.map +4 -4
- package/dist/components/ui/slider/slider.css +5 -5
- package/dist/components/ui/slider/slider.d.ts +20 -10
- package/dist/components/ui/slider/slider.script.d.ts +103 -27
- package/dist/components/ui/switch/index.js +1 -1
- package/dist/components/ui/switch/index.js.map +4 -4
- package/dist/components/ui/switch/switch.css +28 -22
- package/dist/components/ui/switch/switch.d.ts +13 -0
- package/dist/components/ui/switch/switch.script.d.ts +34 -8
- package/dist/components/ui/table/index.js +1 -1
- package/dist/components/ui/table/index.js.map +4 -4
- package/dist/components/ui/table/table.d.ts +9 -7
- package/dist/components/ui/table/table.script.d.ts +55 -12
- package/dist/components/ui/tabs/tabs.css +18 -12
- package/dist/components/ui/tabs/tabs.d.ts +7 -4
- package/dist/components/ui/tabs/tabs.script.d.ts +39 -9
- package/dist/components/ui/tag-group/index.js +1 -1
- package/dist/components/ui/tag-group/index.js.map +4 -4
- package/dist/components/ui/tag-group/tag-group.d.ts +19 -7
- package/dist/components/ui/tag-group/tag-group.script.d.ts +58 -10
- package/dist/components/ui/textarea/index.js +1 -1
- package/dist/components/ui/textarea/index.js.map +4 -4
- package/dist/components/ui/textarea/textarea.css +1 -1
- package/dist/components/ui/toast/index.js +1 -1
- package/dist/components/ui/toast/index.js.map +4 -4
- package/dist/components/ui/toast/toast.css +35 -32
- package/dist/components/ui/toast/toast.script.d.ts +17 -31
- package/dist/components/ui/toast/toaster.script.d.ts +24 -12
- package/dist/components/ui/toc/toc.script.d.ts +19 -8
- package/dist/components/ui/toolbar/toolbar.d.ts +5 -0
- package/dist/components/ui/toolbar/toolbar.script.d.ts +24 -4
- package/dist/components/ui/tooltip/index.js +1 -1
- package/dist/components/ui/tooltip/index.js.map +4 -4
- package/dist/components/ui/tooltip/tooltip.css +14 -94
- package/dist/components/ui/tooltip/tooltip.d.ts +7 -0
- package/dist/components/ui/tooltip/tooltip.script.d.ts +36 -6
- package/dist/components/ui/tree/tree.d.ts +4 -3
- package/dist/components/ui/tree/tree.script.d.ts +28 -15
- package/dist/components/ui/treegrid/treegrid.d.ts +5 -3
- package/dist/components/ui/treegrid/treegrid.script.d.ts +33 -14
- package/dist/components/ui/window-splitter/index.d.ts +1 -1
- package/dist/components/ui/window-splitter/index.js +1 -1
- package/dist/components/ui/window-splitter/index.js.map +3 -3
- package/dist/components/ui/window-splitter/window-splitter.d.ts +10 -1
- package/dist/components/ui/window-splitter/window-splitter.script.d.ts +26 -8
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/lib/icons/check.d.ts +3 -0
- package/dist/lib/icons/chevron-down.d.ts +0 -1
- package/dist/lib/icons/index.d.ts +2 -0
- package/dist/lib/icons/x.d.ts +5 -0
- package/dist/lib/intl-date/index.d.ts +4 -2
- package/dist/lib/intl-date/segment-editing.d.ts +34 -0
- package/dist/lib/intl-date/segments.d.ts +26 -4
- package/dist/lib/non-empty.d.ts +6 -0
- package/dist/lib/unique-id.d.ts +11 -0
- package/dist/lib/viewport/breakpoints.d.ts +6 -0
- package/dist/lib/viewport/mobile-layout.d.ts +15 -0
- package/dist/styles/primitives.css +14 -11
- package/dist/styles/radiant-ui-core.css +10 -0
- package/dist/styles/radiant-ui.css +40 -11
- package/dist/styles/style-dependencies.json +38 -13
- package/dist/styles/styles.css +485 -252
- package/dist/styles/tailwind.css +40 -101
- package/dist/styles/tokens/presets/colors/aurora.css +2 -0
- package/dist/styles/tokens/presets/colors/basalt.css +2 -0
- package/dist/styles/tokens/presets/colors/ember.css +2 -0
- package/dist/styles/tokens/presets/colors/glacier.css +2 -0
- package/dist/styles/tokens/semantic.css +1 -0
- package/dist/styles/tokens/system.css +11 -3
- package/dist/styles/tokens/typography/default.css +8 -0
- package/package.json +27 -13
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { RadiantElement } from '@ecopages/radiant';
|
|
2
2
|
import type { EventEmitter } from '@ecopages/radiant/tools/event-emitter';
|
|
3
|
-
import type { DateDisplayStyle } from '@/lib/intl-date';
|
|
4
3
|
export type RuiDateRangePickerProps = {
|
|
5
4
|
value?: string;
|
|
6
5
|
min?: string;
|
|
@@ -8,12 +7,9 @@ export type RuiDateRangePickerProps = {
|
|
|
8
7
|
disabled?: boolean;
|
|
9
8
|
readOnly?: boolean;
|
|
10
9
|
locale?: string;
|
|
11
|
-
placeholderStart?: string;
|
|
12
|
-
placeholderEnd?: string;
|
|
13
10
|
startName?: string;
|
|
14
11
|
endName?: string;
|
|
15
12
|
name?: string;
|
|
16
|
-
dateStyle?: DateDisplayStyle;
|
|
17
13
|
visibleMonths?: number;
|
|
18
14
|
};
|
|
19
15
|
export type RuiDateRangePickerChangeDetail = {
|
|
@@ -21,43 +17,50 @@ export type RuiDateRangePickerChangeDetail = {
|
|
|
21
17
|
start: string;
|
|
22
18
|
end: string;
|
|
23
19
|
};
|
|
24
|
-
type EditingField = 'start' | 'end' | null;
|
|
25
20
|
/**
|
|
26
|
-
* `<rui-date-range-picker>` — start/end date
|
|
21
|
+
* `<rui-date-range-picker>` — start/end date segments with a range calendar popover.
|
|
22
|
+
*
|
|
23
|
+
* The custom element is a behavior host: it does not render the composed tree.
|
|
24
|
+
* Import the script and place light-DOM children that match the contract below,
|
|
25
|
+
* or use the `RuiDateRangePicker*` view helpers which stamp the same targets.
|
|
26
|
+
* `RuiDateRangePicker` supplies the default composition when it has no children.
|
|
27
27
|
*
|
|
28
28
|
* Canonical `value` is `YYYY-MM-DD/YYYY-MM-DD`. Pair with `RuiField` for validation.
|
|
29
|
-
* Compose inputs, a toggle, popover, and calendar with the `RuiDateRangePicker*`
|
|
30
|
-
* view helpers. `RuiDateRangePicker` supplies that composition when it has no children.
|
|
31
29
|
*
|
|
32
|
-
*
|
|
33
|
-
* segment editing is currently limited to `RuiDateField` so two range inputs do
|
|
34
|
-
* not maintain separate partial-mask state.
|
|
30
|
+
* ## Light-DOM contract
|
|
35
31
|
*
|
|
36
|
-
*
|
|
32
|
+
* Required:
|
|
33
|
+
* - `[data-range-start]` — nested `rui-date-input` for the start date. Host sets
|
|
34
|
+
* `name`, `locale`, `min`, `max`, `disabled`, and `read-only`. Writes `value`
|
|
35
|
+
* only when committing a complete range.
|
|
36
|
+
* - `[data-range-end]` — nested `rui-date-input` for the end date. Same host writes
|
|
37
|
+
* as start.
|
|
38
|
+
* - `[data-range-trigger]` — calendar toggle (`data-ref="trigger"`). Host sets
|
|
39
|
+
* `aria-expanded` and `disabled`.
|
|
40
|
+
* - `[data-range-popover]` — popup shell (`data-ref="popover"`). Host sets `hidden`.
|
|
41
|
+
* - `[data-range-calendar]` — nested `rui-calendar` in range mode. Host syncs
|
|
42
|
+
* `selection-mode="range"`, `visible-months`, `value`, `min`, `max`, `locale`,
|
|
43
|
+
* and `disabled`.
|
|
37
44
|
*
|
|
38
|
-
*
|
|
45
|
+
* Nested hosts:
|
|
46
|
+
* - `rui-date-input` at start/end — listen for `rui-change` and `rui-form-reset`.
|
|
47
|
+
* Nested inputs own in-progress segment state until both sides are a valid ISO date.
|
|
48
|
+
* - `rui-calendar` at `[data-range-calendar]` — parent queries day targets when the popup opens.
|
|
49
|
+
*
|
|
50
|
+
* Do not set `aria-expanded` on the trigger — the host owns it.
|
|
39
51
|
*
|
|
52
|
+
* @see https://react-aria.adobe.com/DateRangePicker
|
|
53
|
+
* @element rui-date-range-picker
|
|
40
54
|
* @attr {string} value - Canonical `YYYY-MM-DD/YYYY-MM-DD` range. Default: `''`.
|
|
41
55
|
* @attr {string} min - Earliest selectable ISO date. Default: `''`.
|
|
42
56
|
* @attr {string} max - Latest selectable ISO date. Default: `''`.
|
|
43
57
|
* @attr {boolean} disabled - Disable both inputs and the calendar. Default: `false`.
|
|
44
58
|
* @attr {boolean} read-only - Disable editing while keeping values visible. Default: `false`.
|
|
45
59
|
* @attr {string} locale - BCP 47 locale tag, or comma-separated fallback list. Default: `''`.
|
|
46
|
-
* @attr {string}
|
|
47
|
-
* @attr {string}
|
|
48
|
-
* @attr {
|
|
49
|
-
* @
|
|
50
|
-
* @attr {string} date-style - How committed values are displayed in the inputs. Default: `medium`.
|
|
51
|
-
* @attr {number} visible-months - Month grids shown in the range calendar popover. Default: `2`.
|
|
52
|
-
*
|
|
53
|
-
* @fires rui-change - Emitted when a valid range is committed; detail carries `value`, `start`, and `end`.
|
|
54
|
-
*
|
|
55
|
-
* @cssclass rui-date-range-picker - Root surface.
|
|
56
|
-
* @cssclass rui-date-range-picker__group - Bordered control-height row wrapping inputs and toggle.
|
|
57
|
-
* @cssclass rui-date-range-picker__values - Start / end input row.
|
|
58
|
-
* @cssclass rui-date-range-picker__input - A range text input.
|
|
59
|
-
* @cssclass rui-date-range-picker__separator - Em dash between the inputs.
|
|
60
|
-
* @cssclass rui-date-range-picker__popover - Range calendar popup shell (`rui-popover` / `rui-floating`).
|
|
60
|
+
* @attr {string} start-name - Form field name on the nested start `rui-date-input`. Default: `''`.
|
|
61
|
+
* @attr {string} end-name - Form field name on the nested end `rui-date-input`. Default: `''`.
|
|
62
|
+
* @attr {number} visible-months - Month grids shown in the range calendar popover (adapts to 1 on screens under 640px). Default: `2`.
|
|
63
|
+
* @fires rui-change - Emitted when a valid range is committed, or when a committed range is cleared; detail carries `value`, `start`, and `end`.
|
|
61
64
|
*/
|
|
62
65
|
export declare class RuiDateRangePicker extends RadiantElement {
|
|
63
66
|
value: string;
|
|
@@ -66,55 +69,43 @@ export declare class RuiDateRangePicker extends RadiantElement {
|
|
|
66
69
|
disabled: boolean;
|
|
67
70
|
readOnly: boolean;
|
|
68
71
|
locale: string;
|
|
69
|
-
placeholderStart: string;
|
|
70
|
-
placeholderEnd: string;
|
|
71
72
|
startName: string;
|
|
72
73
|
endName: string;
|
|
73
74
|
name: string;
|
|
74
|
-
dateStyle: DateDisplayStyle;
|
|
75
75
|
visibleMonths: number;
|
|
76
76
|
changeEvent: EventEmitter<RuiDateRangePickerChangeDetail>;
|
|
77
77
|
open: boolean;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
editing: EditingField;
|
|
81
|
-
private popoverController;
|
|
82
|
-
private suppressPopoverDismiss;
|
|
78
|
+
private readonly calendarPopover;
|
|
79
|
+
private disposeMobileLayoutListener;
|
|
83
80
|
popoverTarget: HTMLElement;
|
|
84
|
-
private
|
|
81
|
+
private readonly onMediaChange;
|
|
85
82
|
private get isoValue();
|
|
86
83
|
private getStartInput;
|
|
87
84
|
private getEndInput;
|
|
88
85
|
private getToggle;
|
|
89
86
|
private getCalendar;
|
|
90
|
-
private
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
private readInputIso;
|
|
88
|
+
/**
|
|
89
|
+
* @remarks Nested inputs own draft segments. Projecting an empty host `value`
|
|
90
|
+
* onto them would wipe a start date typed before the end date exists.
|
|
91
|
+
*/
|
|
92
|
+
private projectCompleteRangeOntoInputs;
|
|
93
93
|
private commitRange;
|
|
94
|
-
private parseField;
|
|
95
94
|
private commitFromInputs;
|
|
96
95
|
private setOpen;
|
|
97
|
-
/** Focus the calendar's roving day, falling back to its first available day. */
|
|
98
|
-
private focusCalendarDay;
|
|
99
|
-
private ensurePopoverController;
|
|
100
|
-
private syncPopoverPosition;
|
|
101
96
|
private syncToggle;
|
|
102
97
|
private syncCalendar;
|
|
103
|
-
private wireInputNames;
|
|
104
98
|
private initialize;
|
|
105
99
|
protected onConnected(): void;
|
|
106
100
|
disconnectedCallback(): void;
|
|
107
101
|
onPropsUpdated(): void;
|
|
108
102
|
onOpenUpdated(): void;
|
|
103
|
+
onDateInputChange(event: Event): void;
|
|
104
|
+
onDateInputReset(): void;
|
|
109
105
|
onTriggerPointerDown(): void;
|
|
110
106
|
onTriggerClick(): void;
|
|
111
|
-
onStartFocus(): void;
|
|
112
|
-
onEndFocus(): void;
|
|
113
|
-
onInputBlur(): void;
|
|
114
|
-
onInput(event: Event): void;
|
|
115
107
|
onPopoverMouseDown(event: Event): void;
|
|
116
108
|
onCalendarChange(event: Event): void;
|
|
117
109
|
onRootKeydown(event: KeyboardEvent): void;
|
|
118
110
|
onRootFocusOut(event: FocusEvent): void;
|
|
119
111
|
}
|
|
120
|
-
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{RadiantElement as Ee,customElement as dn,event as pn,onEvent as S,onUpdated as Te,prop as v,query as fn,state as H}from"@ecopages/radiant";function L(e){if(e==null)return null;let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e.trim());if(!t)return null;let n=Number(t[1]),r=Number(t[2])-1,i=Number(t[3]),a=new Date(n,r,i);return a.getFullYear()!==n||a.getMonth()!==r||a.getDate()!==i?null:a}function tt(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${r}`}function bt(e,t){return e.localeCompare(t)}function et(e,t){return bt(e,t)<=0?{start:e,end:t}:{start:t,end:e}}function O(e){if(!e)return null;let[t,n]=e.split("/");return!t||!n?null:et(t,n)}function nt(e){if(!e)return"";let t=et(e.start,e.end);return`${t.start}/${t.end}`}var Dt=new Map;function We(e,t){return`${JSON.stringify(e??null)}|${JSON.stringify(t)}`}function M(e,t){let n=We(e,t),r=Dt.get(n);if(r)return r;let i=new Intl.DateTimeFormat(e,t);return Dt.set(n,i),i}function rt(e,t,n="medium"){return M(t,{dateStyle:n}).format(e)}var qe={0:"digit",a:"letter","*":"any"};function ze(e,t){let n=t?.[e];if(n instanceof RegExp)return{kind:"any",pattern:n};if(n)return{kind:n};let r=qe[e];return r?{kind:r}:null}function _t(e,t,n=!1){let r=[],i=0;for(;i<e.length;){let a=e[i];if(a==="\\"){let o=e[i+1];o&&r.push({type:"literal",value:o}),i+=2;continue}if(a==="{"){let o=e.indexOf("}",i+1);if(o<0){r.push({type:"literal",value:"{"}),i+=1;continue}r.push({type:"fixed",value:e.slice(i+1,o)}),i=o+1;continue}if(a==="["){let o=He(e,i+1);if(o<0){r.push({type:"literal",value:"["}),i+=1;continue}let l=_t(e.slice(i+1,o),t,!0);r.push(...l),i=o+1;continue}if(a==="]")break;let s=ze(a,t);if(s){r.push({type:"input",definition:a,kind:s.kind,pattern:s.pattern,optional:n}),i+=1;continue}r.push({type:"literal",value:a}),i+=1}return r}function He(e,t){let n=1;for(let r=t;r<e.length;r+=1)if(e[r]==="["&&e[r-1]!=="\\"&&(n+=1),e[r]==="]"&&e[r-1]!=="\\"&&(n-=1,n===0))return r;return-1}function Rt(e,t){return _t(e,t)}function wt(e,t={}){return e.filter(n=>n.type==="input"&&(!t.requiredOnly||!n.optional)).length}var St=new Date(2001,8,3);function Ue(e){return M(e,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(St).filter(t=>t.type==="year"||t.type==="month"||t.type==="day").map(t=>t.type)}function It(e){let t=M(e,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(St),n="";for(let r of t){if(r.type==="literal"){n+=r.value;continue}(r.type==="month"||r.type==="day"||r.type==="year")&&(n+=r.value.replace(/\d/g,"0"))}return n}function kt(e){return e.replace(/\D/g,"")}function Pt(e){return wt(Rt(e),{requiredOnly:!0})}function Ye(e){return e>=100?e:e>=69?1900+e:2e3+e}function Et(e,t){let n=Ue(t),r=0,i={};for(let a of n){let s=a==="year"?4:2,o=e.slice(r,r+s);if(o.length<s)return null;let l=Number(o);a==="year"&&(l=Ye(l)),i[a]=l,r+=s}return i}function Tt(e){if(e.year==null||e.month==null||e.day==null)return null;let t=new Date(e.year,e.month-1,e.day);return t.getFullYear()!==e.year||t.getMonth()!==e.month-1||t.getDate()!==e.day?null:t}var Ge=new Date(2001,8,3);function Mt(e){return M(e,{year:"numeric",month:"numeric",day:"numeric"}).formatToParts(Ge).filter(n=>n.type==="year"||n.type==="month"||n.type==="day").map(n=>n.type)}function Ct(e){return e>=100?e:e>=69?1900+e:2e3+e}function Ot(e){let t=e.year,n=e.month,r=e.day;if(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r))return null;let i=new Date(t,n-1,r);return i.getFullYear()!==t||i.getMonth()!==n-1||i.getDate()!==r?null:i}function it(e,t){let n=(e??"").trim();if(!n)return null;let r=L(n);if(r)return r;let i=Ke(n,t);if(i)return i;let a=Xe(n,t);if(a)return a;let s=Mt(t),o=n.match(/\d+/g);if(!o||o.length<3)return null;let l={day:0,month:0,year:0};for(let h=0;h<3;h+=1){let m=s[h];if(!m)return null;let y=Number(o[h]);m==="year"&&(y=Ct(y)),l[m]=y}return Ot(l)}function Ke(e,t){let n=It(t),r=kt(e);return r.length<Pt(n)?null:Tt(Et(r,t)??{})}function Je(e){let t=new Map;for(let n of["short","long"])for(let r=0;r<12;r+=1){let i=M(e,{month:n}).formatToParts(new Date(2020,r,1)).find(a=>a.type==="month")?.value;i&&t.set(i.toLowerCase(),r+1)}return t}function Xe(e,t){let n=Je(t),r=e.toLowerCase();for(let[i,a]of n){if(r.indexOf(i)<0)continue;let o=e.match(/\d+/g);if(!o||o.length<2)continue;let l=o.find(b=>b.length===4)??o[o.length-1],h=o.find(b=>b!==l&&Number(b)<=31);if(!h||!l)continue;let m=Ct(Number(l)),y=Number(h);return Ot({year:m,month:a,day:y})}return null}var Qe={top:"bottom",bottom:"top",left:"right",right:"left"},Ze=8;function tn(e){let t=e.indexOf("-");if(t===-1)return{side:e,align:"center"};let n=e.slice(0,t),r=e.slice(t+1);return{side:n,align:r==="start"||r==="end"?r:"center"}}function Nt(e){return e==="top"||e==="bottom"?"y":"x"}function Ft(e,t,n,r,i){let{width:a,height:s}=t,o=0,l=0;switch(n){case"top":l=e.top-s-i;break;case"bottom":l=e.bottom+i;break;case"left":o=e.left-a-i;break;case"right":o=e.right+i;break}return Nt(n)==="y"?r==="start"?o=e.left:r==="end"?o=e.right-a:o=e.left+(e.width-a)/2:r==="start"?l=e.top:r==="end"?l=e.bottom-s:l=e.top+(e.height-s)/2,{x:o,y:l}}function en(e,t,n,r){let{padding:i,width:a,height:s}=r;return n==="top"?Math.max(0,i-e.y):n==="bottom"?Math.max(0,e.y+t.height-(s-i)):n==="left"?Math.max(0,i-e.x):Math.max(0,e.x+t.width-(a-i))}function At(e,t,n,r){let{padding:i,width:a,height:s}=r;return n==="top"?e.top-i-t.height:n==="bottom"?s-i-t.height-e.bottom:n==="left"?e.left-i-t.width:a-i-t.width-e.right}function nn(e,t){return t==="center"?e:`${e}-${t}`}function rn(e,t,n,r){let{padding:i,width:a,height:s}=r;if(Nt(n)==="y"){let l=Math.max(i,a-i-t.width);return{x:Math.min(Math.max(e.x,i),l),y:e.y}}let o=Math.max(i,s-i-t.height);return{x:e.x,y:Math.min(Math.max(e.y,i),o)}}function on(e,t,n,r,i={width:typeof window>"u"?0:window.innerWidth,height:typeof window>"u"?0:window.innerHeight,padding:Ze}){let{side:a,align:s}=tn(n),o=Ft(e,t,a,s,r),l=en(o,t,a,i),h=a,m=o;if(l>0){let y=Qe[a],b=Ft(e,t,y,s,r),V=At(e,t,a,i);At(e,t,y,i)>V&&(h=y,m=b)}return{coords:rn(m,t,h,i),placement:nn(h,s)}}function an(e,t,n,r,i={}){let{coords:a,placement:s}=on(e.getBoundingClientRect(),{width:t.offsetWidth,height:t.offsetHeight},n,r);return Object.assign(t.style,{position:"fixed",left:`${a.x}px`,top:`${a.y}px`,right:"auto",bottom:"auto",visibility:"visible"}),i.matchAnchorWidth&&(t.style.width=`${e.offsetWidth}px`),t.setAttribute("data-placement",s),s}function Lt({anchor:e,floating:t,getPlacement:n,gap:r,matchAnchorWidth:i}){let a=()=>{t.hidden||an(e,t,n(),r,{matchAnchorWidth:i})};a(),window.addEventListener("resize",a),window.addEventListener("scroll",a,!0);let s=new ResizeObserver(a);return s.observe(e),s.observe(t),()=>{window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0),s.disconnect()}}function Vt(e,t=document.body){let n=e.parentNode;if(!n)return{unmount:()=>{}};let r=document.createComment("rui-portal");return n.insertBefore(r,e),t.appendChild(e),{unmount:()=>{let i=r.parentNode;i&&(i.insertBefore(e,r),r.remove())}}}function jt(e,t,n){return n?!!(e?.contains(n)||t?.contains(n)):!1}function $t(e,t,n){return n instanceof Node?!jt(e,t,n):!0}var z=class{config;cleanupFloating=null;portalHandle=null;floatingElement=null;constructor(t){this.config=t}updateConfig(t){this.config={...this.config,...t}}sync(){let t=this.resolveFloating();if(!t)return;if(!this.config.getOpen()){this.teardown(),t.toggleAttribute("hidden",!0);return}let r=this.config.getAnchor();if(!r)return;t.toggleAttribute("hidden",!1),this.config.portal!==!1?this.portalHandle||(this.portalHandle=Vt(t,this.config.portalContainer??document.body)):this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null),this.teardownFloating(),this.cleanupFloating=Lt({anchor:r,floating:t,getPlacement:this.config.getPlacement,gap:this.config.gap??8,matchAnchorWidth:this.config.matchAnchorWidth})}contains(t){return jt(this.config.getAnchor(),this.resolveFloating(),t)}getFloatingElement(){return this.resolveFloating()}teardown(){this.teardownFloating(),this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null)}destroy(){this.teardown(),this.floatingElement=null}resolveFloating(){let t=this.config.getFloating();return t&&(this.floatingElement=t),t??this.floatingElement}teardownFloating(){this.cleanupFloating?.(),this.cleanupFloating=null}};function Bt(e){if(!e)return;let t=e.split(",").map(n=>n.trim()).filter(Boolean);return t.length>1?t:t[0]}var Wt,qt,zt,Ht,Ut,Yt,Gt,Kt,Jt,Xt,Qt,Zt,te,ee,ne,re,ie,oe,ae,se,le,ue,ce,de,pe,fe,he,ge,me,ye,xe,ve,be,De,_e,Re,we,Se,Ie,ke;function sn(e,t,n,r,i,a){var s,o,l,h,m,y,b,V=Symbol.metadata||Symbol.for("Symbol.metadata"),Y=Object.defineProperty,G=Object.create,lt=[G(null),G(null)],ut=t.length;function j(u,R,D){return function(c,d){R&&(d=c,c=e);for(var w=0;w<u.length;w++)d=u[w].apply(c,D?[d]:[]);return D?d:c}}function E(u,R,D,c){if(typeof u!="function"&&(c||u!==void 0))throw new TypeError(R+" must "+(D||"be")+" a function"+(c?"":" or undefined"));return u}function ct(u,R,D,c,d,w,C,_,k,P,pt){function K(g){if(!pt(g))throw new TypeError("Attempted to access private element on non-instance")}var J=[].concat(R[0]),ft=R[3],X=!C,A=d===1,ht=d===3,gt=d===4,$=d===2;function B(g,F,xt){return function(q,vt){return F&&(vt=q,q=u),xt&&xt(q),f[g].call(q,vt)}}if(!X){var f={},Q=[],T=ht?"get":gt||A?"set":"value";if(k?(P||A?f={get:Pe(function(){return ft(this)},c,"get"),set:function(g){R[4](this,g)}}:f[T]=ft,P||Pe(f[T],c,$?"":T)):P||(f=Object.getOwnPropertyDescriptor(u,c)),!P&&!k){if((o=lt[+_][c])&&(o^d)!==7)throw Error("Decorating two elements with the same name ("+f[T].name+") is not supported yet");lt[+_][c]=d<3?1:d}}for(var x=u,W=J.length-1;W>=0;W-=D?2:1){var mt=E(J[W],"A decorator","be",!0),yt=D?J[W-1]:void 0,Z={},N={kind:["field","accessor","method","getter","setter","class"][d],name:c,metadata:s,addInitializer:function(g,F){if(g.v)throw new TypeError("attempted to call addInitializer after decoration was finished");E(F,"An initializer","be",!0),w.push(F)}.bind(null,Z)};if(X)o=mt.call(yt,x,N),Z.v=1,E(o,"class decorators","return")&&(x=o);else if(N.static=_,N.private=k,o=N.access={has:k?pt.bind():function(g){return c in g}},gt||(o.get=k?$?function(g){return K(g),f.value}:B("get",0,K):function(g){return g[c]}),$||ht||(o.set=k?B("set",0,K):function(g,F){g[c]=F}),x=mt.call(yt,A?{get:f.get,set:f.set}:f[T],N),Z.v=1,A){if(typeof x=="object"&&x)(o=E(x.get,"accessor.get"))&&(f.get=o),(o=E(x.set,"accessor.set"))&&(f.set=o),(o=E(x.init,"accessor.init"))&&Q.unshift(o);else if(x!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else E(x,(P?"field":"method")+" decorators","return")&&(P?Q.unshift(x):f[T]=x)}return d<2&&C.push(j(Q,_,1),j(w,_,0)),P||X||(k?A?C.splice(-1,0,B("get",_),B("set",_)):C.push($?f[T]:E.call.bind(f[T])):Y(u,c,f)),x}function dt(u){return Y(u,V,{configurable:!0,enumerable:!0,value:s})}return a!==void 0&&(s=a[V]),s=G(s??null),m=[],y=function(u){u&&m.push(j(u))},b=function(u,R){for(var D=0;D<n.length;D++){var c=n[D],d=c[1],w=7&d;if((8&d)==u&&!w==R){var C=c[2],_=!!c[3],k=16&d;ct(u?e:e.prototype,c,k,_?"#"+C:ln(C),w,w<2?[]:u?h=h||[]:l=l||[],m,!!u,_,R,u&&_?function(P){return cn(P)===e}:i)}}},b(8,0),b(0,0),b(8,1),b(0,1),y(l),y(h),o=m,ut||dt(e),{e:o,get c(){var u=[];return ut&&[dt(e=ct(e,[t],r,e.name,5,u)),j(u,1)]}}}function ln(e){var t=un(e,"string");return typeof t=="symbol"?t:t+""}function un(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Pe(e,t,n){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(e,"name",{configurable:!0,value:n?n+" "+t:t})}catch{}return e}function cn(e){if(Object(e)!==e)throw TypeError("right-hand side of 'in' should be an object, got "+(e!==null?typeof e:"null"));return e}var Ce,Me=class extends Ee{static{({e:[zt,Ht,Ut,Yt,Gt,Kt,Jt,Xt,Qt,Zt,te,ee,ne,re,ie,oe,ae,se,le,ue,ce,de,pe,fe,he,ge,me,ye,xe,ve,be,De,_e,Re,we,Se,Ie,ke,Wt],c:[Ce,qt]}=sn(this,[dn("rui-date-range-picker")],[[v({type:String,reflect:!0,defaultValue:""}),0,"value"],[v({type:String,defaultValue:""}),0,"min"],[v({type:String,defaultValue:""}),0,"max"],[v({type:Boolean,reflect:!0,defaultValue:!1}),0,"disabled"],[v({type:Boolean,attribute:"read-only",reflect:!0,defaultValue:!1}),0,"readOnly"],[v({type:String,defaultValue:""}),0,"locale"],[v({type:String,attribute:"placeholder-start",defaultValue:""}),0,"placeholderStart"],[v({type:String,attribute:"placeholder-end",defaultValue:""}),0,"placeholderEnd"],[v({type:String,attribute:"start-name",defaultValue:""}),0,"startName"],[v({type:String,attribute:"end-name",defaultValue:""}),0,"endName"],[v({type:String,defaultValue:""}),0,"name"],[v({type:String,attribute:"date-style",defaultValue:"medium"}),0,"dateStyle"],[v({type:Number,attribute:"visible-months",defaultValue:2}),0,"visibleMonths"],[pn({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[H,0,"open"],[H,0,"startDisplay"],[H,0,"endDisplay"],[H,0,"editing"],[fn({ref:"popover"}),0,"popoverTarget"],[Te(["value","min","max","disabled","readOnly","locale","dateStyle","startName","endName","visibleMonths"]),2,"onPropsUpdated"],[Te(["open"]),2,"onOpenUpdated"],[S({ref:"trigger",type:"pointerdown"}),2,"onTriggerPointerDown"],[S({ref:"trigger",type:"click"}),2,"onTriggerClick"],[S({selector:"[data-range-start]",type:"focus"}),2,"onStartFocus"],[S({selector:"[data-range-end]",type:"focus"}),2,"onEndFocus"],[S({selector:"[data-range-start], [data-range-end]",type:"blur"}),2,"onInputBlur"],[S({selector:"[data-range-start], [data-range-end]",type:"input"}),2,"onInput"],[S({selector:"[data-range-popover]",type:"mousedown"}),2,"onPopoverMouseDown"],[S({selector:"[data-range-calendar]",type:"rui-change"}),2,"onCalendarChange"],[S({selector:"[data-range-start], [data-range-end], [data-range-trigger], [data-range-calendar]",type:"keydown"}),2,"onRootKeydown"],[S({selector:"[data-range-start], [data-range-end], [data-range-trigger], [data-range-popover]",type:"focusout"}),2,"onRootFocusOut"]],0,void 0,Ee))}constructor(...t){super(...t),ke(this)}value=(Wt(this),zt(this));min=(Ht(this),Ut(this));max=(Yt(this),Gt(this));disabled=(Kt(this),Jt(this));readOnly=(Xt(this),Qt(this));locale=(Zt(this),te(this));placeholderStart=(ee(this),ne(this));placeholderEnd=(re(this),ie(this));startName=(oe(this),ae(this));endName=(se(this),le(this));name=(ue(this),ce(this));dateStyle=(de(this),pe(this));visibleMonths=(fe(this),he(this));changeEvent=(ge(this),me(this));open=(ye(this),xe(this,!1));startDisplay=(ve(this),be(this,""));endDisplay=(De(this),_e(this,""));editing=(Re(this),we(this,null));popoverController=(Se(this),null);suppressPopoverDismiss=!1;popoverTarget=Ie(this);get resolvedLocale(){return Bt(this.locale)}get isoValue(){return this.value??""}getStartInput(){return this.querySelector("[data-range-start]")}getEndInput(){return this.querySelector("[data-range-end]")}getToggle(){return this.querySelector("[data-range-trigger]")}getCalendar(){return this.querySelector("[data-range-calendar]")}formatIso(t){if(!t)return"";let n=L(t);return n?rt(n,this.resolvedLocale,this.dateStyle):""}syncDisplayValues(){if(this.editing==="start"||this.editing==="end")return;let t=O(this.isoValue);this.startDisplay=this.formatIso(t?.start??""),this.endDisplay=this.formatIso(t?.end??"");let n=this.getStartInput(),r=this.getEndInput();n&&(n.value=this.startDisplay),r&&(r.value=this.endDisplay)}isIsoAllowed(t){return!(this.min&&t<this.min||this.max&&t>this.max)}commitRange(t,n){if(t&&!this.isIsoAllowed(t)){this.syncDisplayValues();return}if(n&&!this.isIsoAllowed(n)){this.syncDisplayValues();return}let r=t&&n?nt({start:t,end:n}):"";if(r===this.isoValue){this.syncDisplayValues();return}this.value=r,this.changeEvent.emit({value:r,start:t,end:n}),this.syncDisplayValues()}parseField(t){let n=(t??"").trim();if(!n)return"";let r=it(n,this.resolvedLocale);return r?tt(r):""}commitFromInputs(){let t=this.parseField(this.getStartInput()?.value??""),n=this.parseField(this.getEndInput()?.value??"");if(!t&&!n){this.commitRange("","");return}if(t&&n){this.commitRange(t,n);return}let r=O(this.isoValue);this.commitRange(t||r?.start||"",n||r?.end||"")}setOpen(t){this.open=t,queueMicrotask(()=>{this.syncCalendar(),this.syncPopoverPosition(),t&&this.focusCalendarDay()})}focusCalendarDay(){requestAnimationFrame(()=>{if(!this.open)return;let t=this.getCalendar(),n=O(this.isoValue)?.start;((n?t?.querySelector(`[data-calendar-day][data-iso="${n}"]:not(:disabled)`):null)??t?.querySelector('[data-calendar-day][tabindex="0"]:not(:disabled), [data-calendar-day]:not(:disabled)'))?.focus()})}ensurePopoverController(){return this.popoverController||(this.popoverController=new z({getAnchor:()=>this.getToggle()?.parentElement??this,getFloating:()=>this.popoverTarget,getOpen:()=>this.open,getPlacement:()=>"bottom-start",gap:4,portal:!1})),this.popoverController}syncPopoverPosition(){let t=this.popoverTarget;if(!t)return;t.hidden=!this.open;let n=this.ensurePopoverController();n.updateConfig({getOpen:()=>this.open}),n.sync()}syncToggle(){let t=this.getToggle();t&&(t.disabled=this.disabled||this.readOnly,t.setAttribute("aria-expanded",String(this.open)))}syncCalendar(){let t=this.getCalendar();t&&(t.setAttribute("selection-mode","range"),t.setAttribute("visible-months",String(this.visibleMonths)),t.setAttribute("value",this.isoValue),t.setAttribute("min",this.min),t.setAttribute("max",this.max),t.setAttribute("locale",this.locale),t.toggleAttribute("disabled",this.disabled))}wireInputNames(){let t=this.getStartInput(),n=this.getEndInput();t&&(t.name=this.startName,t.disabled=this.disabled,t.readOnly=this.readOnly,t.placeholder=this.placeholderStart||"Start date"),n&&(n.name=this.endName,n.disabled=this.disabled,n.readOnly=this.readOnly,n.placeholder=this.placeholderEnd||"End date")}initialize(){this.wireInputNames(),this.syncDisplayValues(),this.syncToggle(),this.syncCalendar(),this.setOpen(!1)}onConnected(){this.initialize()}disconnectedCallback(){this.popoverController?.destroy(),this.popoverController=null,super.disconnectedCallback()}onPropsUpdated(){this.wireInputNames(),this.syncDisplayValues(),this.syncToggle(),this.syncCalendar()}onOpenUpdated(){this.syncToggle(),this.syncPopoverPosition()}onTriggerPointerDown(){this.suppressPopoverDismiss=!0}onTriggerClick(){this.disabled||this.readOnly||this.setOpen(!this.open)}onStartFocus(){this.editing="start";let t=O(this.isoValue),n=this.getStartInput();n&&(n.value=t?.start?this.formatIso(t.start):"")}onEndFocus(){this.editing="end";let t=O(this.isoValue),n=this.getEndInput();n&&(n.value=t?.end?this.formatIso(t.end):"")}onInputBlur(){this.editing=null,this.commitFromInputs()}onInput(t){let n=t.target;if(n.matches("[data-range-start]")){this.startDisplay=n.value;return}this.endDisplay=n.value}onPopoverMouseDown(t){t.preventDefault()}onCalendarChange(t){let n=t.target;if(!(n instanceof HTMLElement)||!n.matches("[data-range-calendar]"))return;let r=t.detail;!r?.start||!r.end||(this.commitRange(r.start,r.end),this.setOpen(!1))}onRootKeydown(t){t.key==="Escape"&&this.open&&(t.preventDefault(),this.setOpen(!1))}onRootFocusOut(t){let n=t.relatedTarget;queueMicrotask(()=>{if(this.suppressPopoverDismiss){this.suppressPopoverDismiss=!1;return}if(!this.open)return;let r=n instanceof Node?n:document.activeElement;$t(this,this.popoverTarget,r)&&this.setOpen(!1)})}static{qt()}};import{Fragment as mn,jsx as p,jsxs as st}from"@ecopages/jsx/jsx-runtime";function Oe(e,t){return t===void 0||e?.label!==void 0?e:{...e,label:t}}function I(...e){return e.filter(Boolean).join(" ")}import{jsx as U,jsxs as hn}from"@ecopages/jsx/jsx-runtime";function ot({class:e,size:t="sm",...n}){return hn("svg",{...n,class:I("rui-icon",t==="md"&&"rui-icon--md",e),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[U("path",{d:"M8 2v4"}),U("path",{d:"M16 2v4"}),U("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),U("path",{d:"M3 10h18"})]})}import{jsx as gn}from"@ecopages/jsx/jsx-runtime";function at({children:e,...t}){return gn("rui-calendar",{...t,children:e})}function Fe({children:e,class:t,...n}){return p("div",{...n,class:I("rui-date-range-picker",t),children:p("div",{class:"rui-date-range-picker__group",children:e})})}function Ae({children:e,class:t,...n}){return p("div",{...n,class:I("rui-date-range-picker__values",t),children:e})}function Ne({class:e,...t}){return p("input",{...t,type:"text","data-range-start":!0,"data-rui-control":!0,"data-rui-control-type":"text",class:I("rui-date-range-picker__input",e),autocomplete:"off"})}function Le({class:e,...t}){return p("input",{...t,type:"text","data-range-end":!0,"data-rui-control":!0,"data-rui-control-type":"text",class:I("rui-date-range-picker__input",e),autocomplete:"off"})}function Ve({children:e="\u2013",class:t,...n}){return p("span",{...n,class:I("rui-date-range-picker__separator",t),"aria-hidden":"true",children:e})}function je({children:e,class:t,aria:n,...r}){return p("button",{...r,aria:Oe(n,"Open calendar"),type:"button","data-ref":"trigger","data-range-trigger":!0,class:I("rui-control-toggle",t),"aria-haspopup":"dialog",children:e??p(ot,{})})}function $e({children:e,class:t,...n}){return p("div",{...n,"data-ref":"popover","data-range-popover":!0,class:I("rui-date-range-picker__popover rui-popover rui-floating",t),hidden:!0,role:"dialog",children:e})}function Be(e){return p(at,{...e,"data-range-calendar":!0})}function yn({children:e,startLabel:t="Start date",endLabel:n="End date",...r}){return p("rui-date-range-picker",{...r,children:e??st(mn,{children:[st(Fe,{children:[st(Ae,{children:[p(Ne,{"aria-label":t}),p(Ve,{}),p(Le,{"aria-label":n})]}),p(je,{})]}),p($e,{children:p(Be,{})})]})})}export{yn as RuiDateRangePicker,Be as RuiDateRangePickerCalendar,Fe as RuiDateRangePickerControl,Ce as RuiDateRangePickerElement,Le as RuiDateRangePickerEndInput,Ae as RuiDateRangePickerInputs,$e as RuiDateRangePickerPopover,Ve as RuiDateRangePickerSeparator,Ne as RuiDateRangePickerStartInput,je as RuiDateRangePickerToggle};
|
|
1
|
+
import{RadiantElement as Zt,bindTo as X,customElement as ri,event as ii,onEvent as ce,onUpdated as Qt,prop as q,query as ai,state as oi}from"@ecopages/radiant";function fe(t){if(t==null)return null;let e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t.trim());if(!e)return null;let n=Number(e[1]),r=Number(e[2])-1,i=Number(e[3]),a=new Date(n,r,i);return a.getFullYear()!==n||a.getMonth()!==r||a.getDate()!==i?null:a}function K(t){let e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`}function ue(t,e,n){return!(e&&t<e||n&&t>n)}function pe(t,e){return t.localeCompare(e)}function ye(t,e){return pe(t,e)<=0?{start:t,end:e}:{start:e,end:t}}function U(t){if(!t)return null;let[e,n]=t.split("/");return!e||!n?null:ye(e,n)}function ve(t){if(!t)return"";let e=ye(t.start,t.end);return`${e.start}/${e.end}`}function be(t){return t?t.split(",").map(e=>e.trim()).filter(Boolean).sort(pe):[]}function Oe(t){return[...new Set(t)].sort(pe).join(",")}function Ve(t,e){let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),[...n].sort(pe)}function it(t,e){let n=ye(e.start,e.end);return pe(t,n.start)>=0&&pe(t,n.end)<=0}function Le(t,e,n){if(e==="single"){let g=n.singleIso===t;return{isSelected:g,isRangeStart:g,isRangeEnd:g,isRangeMiddle:!1}}if(e==="multiple"){let g=n.multipleIsos?.includes(t)??!1;return{isSelected:g,isRangeStart:g,isRangeEnd:g,isRangeMiddle:!1}}let r=n.range;if(!r)return{isSelected:!1,isRangeStart:!1,isRangeEnd:!1,isRangeMiddle:!1};let i=ye(r.start,r.end),a=it(t,i),s=t===i.start,o=t===i.end;return{isSelected:a,isRangeStart:s,isRangeEnd:o,isRangeMiddle:a&&!s&&!o}}function je(t,e,n){return e.anchor?{committed:ye(e.anchor,n),draft:{anchor:null,hover:null}}:{committed:t,draft:{anchor:n,hover:n}}}function Se(t){let e=Mr(t);try{let r=new Intl.Locale(e).weekInfo;if(r?.firstDay!=null)return r.firstDay===7?0:r.firstDay}catch{}return e.startsWith("en-US")?0:1}function Mr(t){return Array.isArray(t)?t[0]??navigator.language:t??navigator.language}function Pr(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function kr(t,e){return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function Er(t){let e=t.selectionMode??"single",n=t.value??"";if(e==="multiple")return{mode:e,multipleIsos:be(n)};if(e==="range"){let r=U(n);if(t.rangeDraft?.anchor){let i=t.rangeDraft.hover??t.rangeDraft.anchor;return{mode:e,range:Ar(t.rangeDraft.anchor,i)}}return{mode:e,range:r}}return{mode:e,singleIso:n||void 0}}function Ar(t,e){return t.localeCompare(e)<=0?{start:t,end:e}:{start:e,end:t}}function Ye(t,e,n){let r=Se(n.locale),i=Pr(n.today??new Date),a=Er(n),o=(new Date(t,e,1).getDay()-r+7)%7,f=new Date(t,e,1-o),g=[],v=new Date(f);for(let R=0;R<6;R+=1){let D=[];for(let j=0;j<7;j+=1){let Y=K(v),F=Le(Y,a.mode,{singleIso:a.singleIso,multipleIsos:a.multipleIsos,range:a.range});D.push({date:new Date(v),iso:Y,inMonth:v.getMonth()===e,isToday:kr(v,i),isSelected:F.isSelected,isDisabled:!ue(Y,n.min,n.max),isRangeStart:F.isRangeStart,isRangeEnd:F.isRangeEnd,isRangeMiddle:F.isRangeMiddle}),v.setDate(v.getDate()+1)}if(g.push(D),R>=4&&v.getMonth()!==e&&v.getDate()>7)break}return g}function Ie(t,e,n){let r=new Date(t,e+n,1);return{year:r.getFullYear(),month:r.getMonth()}}function Be(t,e,n){let r=Math.max(1,Math.min(n,12));return Array.from({length:r},(i,a)=>{let s=Ie(t,e,a);return{year:s.year,month:s.month,offset:a}})}var at=new Map;function Fr(t,e){return`${JSON.stringify(t??null)}|${JSON.stringify(e)}`}function ge(t,e){let n=Fr(t,e),r=at.get(n);if(r)return r;let i=new Intl.DateTimeFormat(t,e);return at.set(n,i),i}function $e(t,e){return ge(e,{month:"long",year:"numeric"}).format(t)}function ze(t,e){let n=ge(t,{weekday:"narrow"}),r=[];for(let i=0;i<7;i+=1){let a=(e+i)%7,s=new Date(2024,0,a===0?7:a);r.push(n.format(s))}return r}function Ge(t){return new Intl.RelativeTimeFormat(t,{numeric:"auto"}).format(0,"day")}var Tr=new Date(2e3,0,1);function Cr(t,e){return t==="year"?e==="year":t==="month"?e==="year"||e==="month":!0}function Or(t,e){let r=ge(e,{[t]:t==="year"?"numeric":"2-digit"}).formatToParts(Tr).find(i=>i.type===t);return r?r.value.replace(/\d/g,t==="year"?"y":t==="month"?"m":"d"):t==="year"?"yyyy":"mm"}function Vr(t,e,n){let r=t==="year"?{year:"numeric"}:{[t]:"2-digit"};return ge(n,r).formatToParts(e).find(i=>i.type===t)?.value??""}function Re(t,e,n={}){let r=n.granularity??"day",i=t??n.placeholderDate??new Date;return ge(e,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(i).filter(s=>s.type!=="era").map(s=>{if(s.type==="literal")return{type:"literal",value:s.value,placeholder:s.value,isPlaceholder:!1,editable:!1};let o=s.type;if(!Cr(r,o))return null;let f=t!=null;return{type:o,value:f?Vr(o,t,e):"",placeholder:Or(o,e),isPlaceholder:!f,editable:!0}}).filter(s=>s!=null)}function Lr(t){if(t.isPlaceholder||t.value==="")return null;let e=Number(t.value);return Number.isFinite(e)?e:null}function jr(t){return t>=100?t:t>=69?1900+t:2e3+t}function ot(t){let e={};for(let r of t){if(!r.editable)continue;let i=Lr(r);if(i==null)return null;e[r.type]=r.type==="year"?jr(i):i}if(e.year==null||e.month==null||e.day==null)return null;let n=new Date(e.year,e.month-1,e.day);return n.getFullYear()!==e.year||n.getMonth()!==e.month-1||n.getDate()!==e.day?null:n}function st(t){return t.every(e=>!e.editable||e.isPlaceholder||e.value==="")}function We(t,e={}){let n=t.find(a=>a.editable&&a.type==="year");if(n&&!n.isPlaceholder&&n.value!==""&&n.value.replace(/\D/g,"").length<4)return{kind:"partial-year"};if(st(t))return{kind:"empty"};let r=ot(t);if(!r)return{kind:"incomplete"};let i=K(r);return ue(i,e.min,e.max)?{kind:"date",iso:i}:{kind:"out-of-range"}}function He(t){return t==="year"?4:2}function Yr(t,e){return t.findIndex(n=>n.editable&&n.type===e)}function Br(t){return t.map(e=>({...e}))}function Ue(t,e,n){let r=Br(t),i=Yr(r,e);return i<0||(r[i]={...r[i],...n}),r}function Ne(t){if(t==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}function Me(t,e){return{min:1,max:ut(t,e)}}function ut(t,e){if(t==="month")return 12;if(t==="day"){let n=lt(e,"year"),r=lt(e,"month");return n!=null&&r!=null?new Date(n,r,0).getDate():31}return 9999}function lt(t,e){let n=t.find(r=>r.editable&&r.type===e);return!n||n.isPlaceholder||n.value===""?null:Number(n.value)}function ct(t,e){return t==="year"?String(e).padStart(4,"0"):String(e).padStart(2,"0")}function qe(t,e){try{let r=new Intl.DisplayNames(e,{type:"dateTimeField"}).of(t);if(r)return r}catch{}return t==="month"?"Month":t==="day"?"Day":"Year"}function De(t){return t.isPlaceholder||t.value===""?t.placeholder:t.value}function Pe(t){return t.isPlaceholder||t.value===""?null:Ne(t.value.replace(/\D/g,""))}function dt(t,e){return Ue(t,e,{value:"",isPlaceholder:!0})}function ht(t,e,n){return Ue(t,e,{value:ct(e,n),isPlaceholder:!1})}function Ke(t,e,n){let r=t.find(f=>f.editable&&f.type===e);if(!r)return t;let{min:i,max:a}=Me(e,t),o=(Pe(r)??(n>0?i-1:a+1))+n;return e==="month"||e==="day"?o<i?o=a:o>a&&(o=i):o=Math.max(i,o),ht(t,e,o)}function Xe(t,e,n,r){let i=n.replace(/\D/g,"");if(!i)return{segments:t,enteredKeys:r,focusNext:!1};let a=r+i,s=Ne(a);if(s==null)return{segments:t,enteredKeys:r,focusNext:!1};let o=ut(e,t),f=s;f>o&&(f=Ne(i)??f);let g=He(e),v=+`${f}0`>o||a.length>=g||String(f).length>=g,R=v?ct(e,f):String(f);return{segments:Ue(t,e,{value:R,isPlaceholder:!1}),enteredKeys:v?"":a,focusNext:v}}function ft(t){return t.filter(e=>e.editable).map(e=>e.type)}function xe(t,e,n){let r=ft(t),i=r.indexOf(e);if(i<0)return r[0]??null;let a=i+n;return a<0||a>=r.length?null:r[a]??null}function Je(t){let e=null;for(let n of t){if(!n.editable)continue;let r=n.type;if(e||(e=r),n.isPlaceholder||n.value==="")return r}return e}function Ze(t,e){let n=t.find(a=>a.editable&&a.type===e);if(!n)return{kind:"focus-previous"};if(n.isPlaceholder||n.value==="")return{kind:"focus-previous"};let r=n.value.replace(/\D/g,"");if(r.length<=1)return{kind:"updated",segments:dt(t,e),enteredKeys:""};let i=r.slice(0,-1);return{kind:"updated",segments:t.map(a=>a.editable&&a.type===e?{...a,value:i,isPlaceholder:!1}:a),enteredKeys:i}}var $r={top:"bottom",bottom:"top",left:"right",right:"left"},zr=8,Qe=new WeakMap;function Gr(t){Qe.has(t)&&(t.style.width="",t.style.minWidth="",t.style.maxWidth="",t.style.boxSizing="",Qe.delete(t))}function Wr(t){let e=t.indexOf("-");if(e===-1)return{side:t,align:"center"};let n=t.slice(0,e),r=t.slice(e+1);return{side:n,align:r==="start"||r==="end"?r:"center"}}function mt(t){return t==="top"||t==="bottom"?"y":"x"}function pt(t,e,n,r,i){let{width:a,height:s}=e,o=0,f=0;switch(n){case"top":f=t.top-s-i;break;case"bottom":f=t.bottom+i;break;case"left":o=t.left-a-i;break;case"right":o=t.right+i;break}return mt(n)==="y"?r==="start"?o=t.left:r==="end"?o=t.right-a:o=t.left+(t.width-a)/2:r==="start"?f=t.top:r==="end"?f=t.bottom-s:f=t.top+(t.height-s)/2,{x:o,y:f}}function Hr(t,e,n,r){let{padding:i,width:a,height:s}=r;return n==="top"?Math.max(0,i-t.y):n==="bottom"?Math.max(0,t.y+e.height-(s-i)):n==="left"?Math.max(0,i-t.x):Math.max(0,t.x+e.width-(a-i))}function gt(t,e,n,r){let{padding:i,width:a,height:s}=r;return n==="top"?t.top-i-e.height:n==="bottom"?s-i-e.height-t.bottom:n==="left"?t.left-i-e.width:a-i-e.width-t.right}function Nr(t,e){return e==="center"?t:`${t}-${e}`}function Ur(t,e,n,r){let{padding:i,width:a,height:s}=r;if(mt(n)==="y"){let f=Math.max(i,a-i-e.width);return{x:Math.min(Math.max(t.x,i),f),y:Math.max(i,t.y)}}let o=Math.max(i,s-i-e.height);return{x:Math.max(i,t.x),y:Math.min(Math.max(t.y,i),o)}}function qr(t,e,n,r,i={width:typeof window>"u"?0:window.innerWidth,height:typeof window>"u"?0:window.innerHeight,padding:zr}){let{side:a,align:s}=Wr(n),o=pt(t,e,a,s,r),f=Hr(o,e,a,i),g=a,v=o;if(f>0){let R=$r[a],D=pt(t,e,R,s,r),j=gt(t,e,a,i);gt(t,e,R,i)>j&&(g=R,v=D)}return{coords:Ur(v,e,g,i),placement:Nr(g,s)}}function Kr(t,e,n,r,i={}){let a=i.matchAnchorWidth===!0,s=t.offsetWidth,o=a?{width:s,height:e.offsetHeight}:{width:e.offsetWidth,height:e.offsetHeight};a?(e.style.width=`${s}px`,e.style.minWidth=`${s}px`,e.style.maxWidth=`${s}px`,e.style.boxSizing="border-box",Qe.set(e,!0)):Gr(e);let{coords:f,placement:g}=qr(t.getBoundingClientRect(),o,n,r);return Object.assign(e.style,{position:"fixed",left:`${f.x}px`,top:`${f.y}px`,right:"auto",bottom:"auto",visibility:"visible"}),e.setAttribute("data-placement",g),g}function yt({anchor:t,floating:e,getPlacement:n,gap:r,matchAnchorWidth:i}){let a=()=>{e.hidden||Kr(t,e,n(),r,{matchAnchorWidth:i})};a(),window.addEventListener("resize",a),window.addEventListener("scroll",a,!0);let s=new ResizeObserver(a);return s.observe(t),s.observe(e),()=>{window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0),s.disconnect()}}function vt(t,e=document.body){let n=t.parentNode;if(!n)return{unmount:()=>{}};let r=document.createComment("rui-portal");return n.insertBefore(r,t),e.appendChild(t),{unmount:()=>{let i=r.parentNode;i&&(i.insertBefore(t,r),r.remove())}}}function bt(t,e,n){return n?!!(t?.contains(n)||e?.contains(n)):!1}function xt(t,e,n){return n instanceof Node?!bt(t,e,n):!0}var ke=class{config;cleanupFloating=null;portalHandle=null;floatingElement=null;constructor(e){this.config=e}updateConfig(e){this.config={...this.config,...e}}sync(){let e=this.resolveFloating();if(!e)return;if(!this.config.getOpen()){this.teardown(),e.toggleAttribute("hidden",!0);return}let r=this.config.getAnchor();if(!r)return;e.toggleAttribute("hidden",!1),this.config.portal!==!1?this.portalHandle||(this.portalHandle=vt(e,this.config.portalContainer??document.body)):this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null),this.teardownFloating(),this.cleanupFloating=yt({anchor:r,floating:e,getPlacement:this.config.getPlacement,gap:this.config.gap??8,matchAnchorWidth:this.config.matchAnchorWidth})}contains(e){return bt(this.config.getAnchor(),this.resolveFloating(),e)}getFloatingElement(){return this.resolveFloating()}teardown(){this.teardownFloating(),this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null)}destroy(){this.teardown(),this.floatingElement=null}resolveFloating(){let e=this.config.getFloating();return e&&(this.floatingElement=e),e??this.floatingElement}teardownFloating(){this.cleanupFloating?.(),this.cleanupFloating=null}};var Ee=class{config;popoverController=null;suppressPopoverDismiss=!1;constructor(e){this.config=e}destroy(){this.popoverController?.destroy(),this.popoverController=null}suppressDismiss(){this.suppressPopoverDismiss=!0}syncPopover(){let e=this.config.getFloating();if(!e)return;e.hidden=!this.config.getOpen();let n=this.ensureController();n.updateConfig({getOpen:()=>this.config.getOpen()}),n.sync()}focusCalendarDay(){Xr(this.config.getCalendar(),this.config.getFocusIso())}handleFocusOut(e,n){let r=e.relatedTarget;queueMicrotask(()=>{if(this.suppressPopoverDismiss){this.suppressPopoverDismiss=!1;return}if(!this.config.getOpen())return;let i=this.config.getFloating();if(!i)return;let a=r instanceof Node?r:document.activeElement;xt(this.config.getHost(),i,a)&&n()})}ensureController(){return this.popoverController||(this.popoverController=new ke({getAnchor:this.config.getAnchor,getFloating:this.config.getFloating,getOpen:this.config.getOpen,getPlacement:()=>"bottom-start",gap:4,portal:!1})),this.popoverController}};function Xr(t,e){requestAnimationFrame(()=>{if(!t)return;((e?t.querySelector(`[data-calendar-day][data-iso="${e}"]:not(:disabled)`):null)??t.querySelector('[data-calendar-day][tabindex="0"]:not(:disabled), [data-calendar-day]:not(:disabled)'))?.focus()})}function Zr(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(`(max-width: ${639}px)`).matches}function _t(t){return t<=1||!Zr()?t:1}function wt(t){if(typeof window>"u"||typeof window.matchMedia!="function")return null;let e=window.matchMedia(`(max-width: ${639}px)`);return e.addEventListener("change",t),()=>e.removeEventListener("change",t)}var Dt,St,It,Rt,Mt,Pt,kt,Et,At,Ft,Tt,Ct,Ot,Vt,Lt,jt,Yt,Bt,$t,zt,Gt,Wt,Ht,Nt,Ut,qt,Kt,Xt;function Qr(t,e,n,r,i,a){var s,o,f,g,v,R,D,j=Symbol.metadata||Symbol.for("Symbol.metadata"),Y=Object.defineProperty,F=Object.create,J=[F(null),F(null)],Z=e.length;function T(l,b,m){return function(u,c){b&&(c=u,u=t);for(var x=0;x<l.length;x++)c=l[x].apply(u,m?[c]:[]);return m?c:u}}function S(l,b,m,u){if(typeof l!="function"&&(u||l!==void 0))throw new TypeError(b+" must "+(m||"be")+" a function"+(u?"":" or undefined"));return l}function Q(l,b,m,u,c,x,M,y,_,w,te){function z(h){if(!te(h))throw new TypeError("Attempted to access private element on non-instance")}var G=[].concat(b[0]),ne=b[3],W=!M,k=c===1,re=c===3,ie=c===4,C=c===2;function O(h,P,se){return function(L,le){return P&&(le=L,L=l),se&&se(L),d[h].call(L,le)}}if(!W){var d={},H=[],I=re?"get":ie||k?"set":"value";if(_?(w||k?d={get:Jt(function(){return ne(this)},u,"get"),set:function(h){b[4](this,h)}}:d[I]=ne,w||Jt(d[I],u,C?"":I)):w||(d=Object.getOwnPropertyDescriptor(l,u)),!w&&!_){if((o=J[+y][u])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[I].name+") is not supported yet");J[+y][u]=c<3?1:c}}for(var p=l,V=G.length-1;V>=0;V-=m?2:1){var ae=S(G[V],"A decorator","be",!0),oe=m?G[V-1]:void 0,N={},E={kind:["field","accessor","method","getter","setter","class"][c],name:u,metadata:s,addInitializer:function(h,P){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");S(P,"An initializer","be",!0),x.push(P)}.bind(null,N)};if(W)o=ae.call(oe,p,E),N.v=1,S(o,"class decorators","return")&&(p=o);else if(E.static=y,E.private=_,o=E.access={has:_?te.bind():function(h){return u in h}},ie||(o.get=_?C?function(h){return z(h),d.value}:O("get",0,z):function(h){return h[u]}),C||re||(o.set=_?O("set",0,z):function(h,P){h[u]=P}),p=ae.call(oe,k?{get:d.get,set:d.set}:d[I],E),N.v=1,k){if(typeof p=="object"&&p)(o=S(p.get,"accessor.get"))&&(d.get=o),(o=S(p.set,"accessor.set"))&&(d.set=o),(o=S(p.init,"accessor.init"))&&H.unshift(o);else if(p!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else S(p,(w?"field":"method")+" decorators","return")&&(w?H.unshift(p):d[I]=p)}return c<2&&M.push(T(H,y,1),T(x,y,0)),w||W||(_?k?M.splice(-1,0,O("get",y),O("set",y)):M.push(C?d[I]:S.call.bind(d[I])):Y(l,u,d)),p}function ee(l){return Y(l,j,{configurable:!0,enumerable:!0,value:s})}return a!==void 0&&(s=a[j]),s=F(s??null),v=[],R=function(l){l&&v.push(T(l))},D=function(l,b){for(var m=0;m<n.length;m++){var u=n[m],c=u[1],x=7&c;if((8&c)==l&&!x==b){var M=u[2],y=!!u[3],_=16&c;Q(l?t:t.prototype,u,_,y?"#"+M:ei(M),x,x<2?[]:l?g=g||[]:f=f||[],v,!!l,y,b,l&&y?function(w){return ni(w)===t}:i)}}},D(8,0),D(0,0),D(8,1),D(0,1),R(f),R(g),o=v,Z||ee(t),{e:o,get c(){var l=[];return Z&&[ee(t=Q(t,[e],r,t.name,5,l)),T(l,1)]}}}function ei(t){var e=ti(t,"string");return typeof e=="symbol"?e:e+""}function ti(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Jt(t,e,n){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:n?n+" "+e:e})}catch{}return t}function ni(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}var tn,en=class extends Zt{static{({e:[It,Rt,Mt,Pt,kt,Et,At,Ft,Tt,Ct,Ot,Vt,Lt,jt,Yt,Bt,$t,zt,Gt,Wt,Ht,Nt,Ut,qt,Kt,Xt,Dt],c:[tn,St]}=Qr(this,[ri("rui-date-range-picker")],[[[q({type:String,reflect:!0,defaultValue:""}),X({selector:"[data-range-calendar]",attr:"value"})],0,"value"],[[q({type:String,defaultValue:""}),X([{selector:"[data-range-start]",attr:"min"},{selector:"[data-range-end]",attr:"min"},{selector:"[data-range-calendar]",attr:"min"}])],0,"min"],[[q({type:String,defaultValue:""}),X([{selector:"[data-range-start]",attr:"max"},{selector:"[data-range-end]",attr:"max"},{selector:"[data-range-calendar]",attr:"max"}])],0,"max"],[[q({type:Boolean,reflect:!0,defaultValue:!1}),X([{selector:"[data-range-start]",bool:"disabled"},{selector:"[data-range-end]",bool:"disabled"},{selector:"[data-range-calendar]",bool:"disabled"}])],0,"disabled"],[[q({type:Boolean,attribute:"read-only",reflect:!0,defaultValue:!1}),X([{selector:"[data-range-start]",bool:"read-only"},{selector:"[data-range-end]",bool:"read-only"}])],0,"readOnly"],[[q({type:String,defaultValue:""}),X([{selector:"[data-range-start]",attr:"locale"},{selector:"[data-range-end]",attr:"locale"},{selector:"[data-range-calendar]",attr:"locale"}])],0,"locale"],[[q({type:String,attribute:"start-name",defaultValue:""}),X({selector:"[data-range-start]",attr:"name"})],0,"startName"],[[q({type:String,attribute:"end-name",defaultValue:""}),X({selector:"[data-range-end]",attr:"name"})],0,"endName"],[q({type:String,defaultValue:""}),0,"name"],[q({type:Number,attribute:"visible-months",defaultValue:2}),0,"visibleMonths"],[ii({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[[oi,X({selector:"[data-range-trigger]",attr:"aria-expanded"})],0,"open"],[ai({ref:"popover"}),0,"popoverTarget"],[Qt(["value","min","max","disabled","readOnly","locale","visibleMonths"]),2,"onPropsUpdated"],[Qt(["open"]),2,"onOpenUpdated"],[ce({selector:"[data-range-start], [data-range-end]",type:"rui-change"}),2,"onDateInputChange"],[ce({selector:"[data-range-start], [data-range-end]",type:"rui-form-reset"}),2,"onDateInputReset"],[ce({ref:"trigger",type:"pointerdown"}),2,"onTriggerPointerDown"],[ce({ref:"trigger",type:"click"}),2,"onTriggerClick"],[ce({selector:"[data-range-popover]",type:"mousedown"}),2,"onPopoverMouseDown"],[ce({selector:"[data-range-calendar]",type:"rui-change"}),2,"onCalendarChange"],[ce({selector:"[data-range-start], [data-range-end], [data-range-trigger], [data-range-calendar]",type:"keydown"}),2,"onRootKeydown"],[ce({selector:"[data-range-start], [data-range-end], [data-range-trigger], [data-range-popover]",type:"focusout"}),2,"onRootFocusOut"]],0,void 0,Zt))}value=(Dt(this),It(this));min=(Rt(this),Mt(this));max=(Pt(this),kt(this));disabled=(Et(this),At(this));readOnly=(Ft(this),Tt(this));locale=(Ct(this),Ot(this));startName=(Vt(this),Lt(this));endName=(jt(this),Yt(this));name=(Bt(this),$t(this));visibleMonths=(zt(this),Gt(this));changeEvent=(Wt(this),Ht(this));open=(Nt(this),Ut(this,!1));calendarPopover=(qt(this),new Ee({getHost:()=>this,getAnchor:()=>this.getToggle()?.parentElement??this,getFloating:()=>this.popoverTarget,getOpen:()=>this.open,getCalendar:()=>this.getCalendar(),getFocusIso:()=>U(this.isoValue)?.start}));disposeMobileLayoutListener=null;popoverTarget=Kt(this);onMediaChange=(Xt(this),()=>{this.syncCalendar(),this.open&&this.calendarPopover.syncPopover()});get isoValue(){return this.value??""}getStartInput(){return this.querySelector("[data-range-start]")}getEndInput(){return this.querySelector("[data-range-end]")}getToggle(){return this.querySelector("[data-range-trigger]")}getCalendar(){return this.querySelector("[data-range-calendar]")}readInputIso(e){let n=e==="start"?this.getStartInput():this.getEndInput();if(!n)return"";let r=Reflect.get(n,"value");return typeof r=="string"?r:n.getAttribute("value")??""}projectCompleteRangeOntoInputs(){let e=U(this.isoValue);e&&(this.getStartInput()?.setAttribute("value",e.start),this.getEndInput()?.setAttribute("value",e.end))}commitRange(e,n){let r=this.min||void 0,i=this.max||void 0;if(e&&!ue(e,r,i)||n&&!ue(n,r,i))return;let a=e&&n?ve({start:e,end:n}):"";a!==this.isoValue&&(this.value=a,this.changeEvent.emit({value:a,start:e,end:n}))}commitFromInputs(){let e=this.readInputIso("start"),n=this.readInputIso("end");if(e&&n){this.commitRange(e,n);return}this.commitRange("","")}setOpen(e){this.open=e,queueMicrotask(()=>{this.calendarPopover.syncPopover(),e&&this.calendarPopover.focusCalendarDay()})}syncToggle(){let e=this.getToggle();e&&(e.disabled=this.disabled||this.readOnly)}syncCalendar(){let e=this.getCalendar();e&&(e.setAttribute("selection-mode","range"),e.setAttribute("visible-months",String(_t(this.visibleMonths))))}initialize(){this.projectCompleteRangeOntoInputs(),this.syncToggle(),this.syncCalendar(),this.setOpen(!1)}onConnected(){this.disposeMobileLayoutListener=wt(this.onMediaChange),this.initialize()}disconnectedCallback(){this.disposeMobileLayoutListener?.(),this.disposeMobileLayoutListener=null,this.calendarPopover.destroy(),super.disconnectedCallback()}onPropsUpdated(){this.projectCompleteRangeOntoInputs(),this.syncToggle(),this.syncCalendar()}onOpenUpdated(){this.syncToggle(),this.calendarPopover.syncPopover()}onDateInputChange(e){let n=e.target;n instanceof HTMLElement&&n.matches("[data-range-start], [data-range-end]")&&this.commitFromInputs()}onDateInputReset(){queueMicrotask(()=>{let e=this.readInputIso("start"),n=this.readInputIso("end");this.value=e&&n?ve({start:e,end:n}):""})}onTriggerPointerDown(){this.calendarPopover.suppressDismiss()}onTriggerClick(){this.disabled||this.readOnly||this.setOpen(!this.open)}onPopoverMouseDown(e){e.preventDefault()}onCalendarChange(e){let n=e.target;if(!(n instanceof HTMLElement)||!n.matches("[data-range-calendar]"))return;let r=e.detail;!r?.start||!r.end||(this.commitRange(r.start,r.end),this.setOpen(!1))}onRootKeydown(e){e.key==="Escape"&&this.open&&(e.preventDefault(),this.setOpen(!1))}onRootFocusOut(e){this.calendarPopover.handleFocusOut(e,()=>this.setOpen(!1))}static{St()}};import{Fragment as Pi,jsx as A,jsxs as rt}from"@ecopages/jsx/jsx-runtime";function nn(t,e){return e===void 0||t?.label!==void 0?t:{...t,label:e}}function $(...t){return t.filter(Boolean).join(" ")}import{jsx as Ae,jsxs as si}from"@ecopages/jsx/jsx-runtime";function et({class:t,size:e="sm",...n}){return si("svg",{...n,class:$("rui-icon",e==="md"&&"rui-icon--md",t),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[Ae("path",{d:"M8 2v4"}),Ae("path",{d:"M16 2v4"}),Ae("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),Ae("path",{d:"M3 10h18"})]})}import{jsx as B,jsxs as tt}from"@ecopages/jsx/jsx-runtime";import{RadiantElement as $n,customElement as hi,event as fi,onEvent as me,onUpdated as pi,prop as de,registerSsrPreparationCallback as gi,state as he}from"@ecopages/radiant";function Fe(t){if(!t)return;let e=t.split(",").map(n=>n.trim()).filter(Boolean);return e.length>1?e:e[0]}var rn,an,on,sn,ln,un,cn,dn,hn,fn,pn,gn,mn,yn,vn,bn,xn,_n,wn,Dn,Sn,In,Rn,Mn,Pn,kn,En,An,Fn,Tn,Cn,On,Vn,Ln,jn,Yn;function li(t,e,n,r,i,a){var s,o,f,g,v,R,D,j=Symbol.metadata||Symbol.for("Symbol.metadata"),Y=Object.defineProperty,F=Object.create,J=[F(null),F(null)],Z=e.length;function T(l,b,m){return function(u,c){b&&(c=u,u=t);for(var x=0;x<l.length;x++)c=l[x].apply(u,m?[c]:[]);return m?c:u}}function S(l,b,m,u){if(typeof l!="function"&&(u||l!==void 0))throw new TypeError(b+" must "+(m||"be")+" a function"+(u?"":" or undefined"));return l}function Q(l,b,m,u,c,x,M,y,_,w,te){function z(h){if(!te(h))throw new TypeError("Attempted to access private element on non-instance")}var G=[].concat(b[0]),ne=b[3],W=!M,k=c===1,re=c===3,ie=c===4,C=c===2;function O(h,P,se){return function(L,le){return P&&(le=L,L=l),se&&se(L),d[h].call(L,le)}}if(!W){var d={},H=[],I=re?"get":ie||k?"set":"value";if(_?(w||k?d={get:Bn(function(){return ne(this)},u,"get"),set:function(h){b[4](this,h)}}:d[I]=ne,w||Bn(d[I],u,C?"":I)):w||(d=Object.getOwnPropertyDescriptor(l,u)),!w&&!_){if((o=J[+y][u])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[I].name+") is not supported yet");J[+y][u]=c<3?1:c}}for(var p=l,V=G.length-1;V>=0;V-=m?2:1){var ae=S(G[V],"A decorator","be",!0),oe=m?G[V-1]:void 0,N={},E={kind:["field","accessor","method","getter","setter","class"][c],name:u,metadata:s,addInitializer:function(h,P){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");S(P,"An initializer","be",!0),x.push(P)}.bind(null,N)};if(W)o=ae.call(oe,p,E),N.v=1,S(o,"class decorators","return")&&(p=o);else if(E.static=y,E.private=_,o=E.access={has:_?te.bind():function(h){return u in h}},ie||(o.get=_?C?function(h){return z(h),d.value}:O("get",0,z):function(h){return h[u]}),C||re||(o.set=_?O("set",0,z):function(h,P){h[u]=P}),p=ae.call(oe,k?{get:d.get,set:d.set}:d[I],E),N.v=1,k){if(typeof p=="object"&&p)(o=S(p.get,"accessor.get"))&&(d.get=o),(o=S(p.set,"accessor.set"))&&(d.set=o),(o=S(p.init,"accessor.init"))&&H.unshift(o);else if(p!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else S(p,(w?"field":"method")+" decorators","return")&&(w?H.unshift(p):d[I]=p)}return c<2&&M.push(T(H,y,1),T(x,y,0)),w||W||(_?k?M.splice(-1,0,O("get",y),O("set",y)):M.push(C?d[I]:S.call.bind(d[I])):Y(l,u,d)),p}function ee(l){return Y(l,j,{configurable:!0,enumerable:!0,value:s})}return a!==void 0&&(s=a[j]),s=F(s??null),v=[],R=function(l){l&&v.push(T(l))},D=function(l,b){for(var m=0;m<n.length;m++){var u=n[m],c=u[1],x=7&c;if((8&c)==l&&!x==b){var M=u[2],y=!!u[3],_=16&c;Q(l?t:t.prototype,u,_,y?"#"+M:ui(M),x,x<2?[]:l?g=g||[]:f=f||[],v,!!l,y,b,l&&y?function(w){return di(w)===t}:i)}}},D(8,0),D(0,0),D(8,1),D(0,1),R(f),R(g),o=v,Z||ee(t),{e:o,get c(){var l=[];return Z&&[ee(t=Q(t,[e],r,t.name,5,l)),T(l,1)]}}}function ui(t){var e=ci(t,"string");return typeof e=="symbol"?e:e+""}function ci(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Bn(t,e,n){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:n?n+" "+e:e})}catch{}return t}function di(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}var Gn,zn=class extends $n{static{({e:[on,sn,ln,un,cn,dn,hn,fn,pn,gn,mn,yn,vn,bn,xn,_n,wn,Dn,Sn,In,Rn,Mn,Pn,kn,En,An,Fn,Tn,Cn,On,Vn,Ln,jn,Yn,rn],c:[Gn,an]}=li(this,[hi("rui-calendar")],[[de({type:String,reflect:!0,defaultValue:""}),0,"value"],[de({type:String,defaultValue:""}),0,"min"],[de({type:String,defaultValue:""}),0,"max"],[de({type:Boolean,reflect:!0,defaultValue:!1}),0,"disabled"],[de({type:String,defaultValue:""}),0,"locale"],[de({type:String,attribute:"selection-mode",defaultValue:"single"}),0,"selectionMode"],[de({type:Number,attribute:"visible-months",defaultValue:1}),0,"visibleMonths"],[de({type:String,attribute:"page-behavior",defaultValue:"visible"}),0,"pageBehavior"],[fi({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[he,0,"viewYear"],[he,0,"viewMonth"],[he,0,"focusedIso"],[he,0,"weekdayLabels"],[he,0,"monthPanels"],[he,0,"todayLabel"],[he,0,"rangeAnchor"],[he,0,"rangeHover"],[pi(["value","min","max","disabled","locale","selectionMode","visibleMonths","pageBehavior"]),2,"onPropsUpdated"],[me({selector:"[data-calendar-prev-month]",type:"click"}),2,"onPrevMonth"],[me({selector:"[data-calendar-next-month]",type:"click"}),2,"onNextMonth"],[me({selector:"[data-calendar-today]",type:"click"}),2,"onTodayClick"],[me({selector:"[data-calendar-day]",type:"click"}),2,"onDayClick"],[me({selector:"[data-calendar-day]",type:"pointerenter"}),2,"onDayPointerEnter"],[me({selector:"[data-calendar-grid]",type:"pointerleave"}),2,"onGridPointerLeave"],[me({selector:"[data-calendar-day]",type:"keydown"}),2,"onDayKeydown"]],0,void 0,$n))}value=(rn(this),on(this));min=(sn(this),ln(this));max=(un(this),cn(this));disabled=(dn(this),hn(this));locale=(fn(this),pn(this));selectionMode=(gn(this),mn(this));visibleMonths=(yn(this),vn(this));pageBehavior=(bn(this),xn(this));changeEvent=(_n(this),wn(this));viewYear=(Dn(this),Sn(this,new Date().getFullYear()));viewMonth=(In(this),Rn(this,new Date().getMonth()));focusedIso=(Mn(this),Pn(this,""));weekdayLabels=(kn(this),En(this,[]));monthPanels=(An(this),Fn(this,[]));todayLabel=(Tn(this),Cn(this,""));rangeAnchor=(On(this),Vn(this,null));rangeHover=(Ln(this),jn(this,null));get resolvedLocale(){return Fe(this.locale)}get pageDelta(){return this.pageBehavior==="single"?1:Math.max(1,Math.min(this.visibleMonths,12))}get monthOptions(){return{locale:this.resolvedLocale,selectionMode:this.selectionMode,value:this.value??"",rangeDraft:{anchor:this.rangeAnchor,hover:this.rangeHover},min:this.min||void 0,max:this.max||void 0}}syncViewFromValue(){let e=this.selectionMode==="range"?U(this.value)?.start??"":this.selectionMode==="multiple"?be(this.value)[0]??"":this.value,n=fe(e);if(n){this.viewYear=n.getFullYear(),this.viewMonth=n.getMonth(),this.focusedIso=e;return}let r=new Date;this.viewYear=r.getFullYear(),this.viewMonth=r.getMonth(),this.focusedIso=K(r)}refreshGrid(){this.weekdayLabels=ze(this.resolvedLocale,Se(this.resolvedLocale)),this.monthPanels=Be(this.viewYear,this.viewMonth,this.visibleMonths).map(e=>{let n=new Date(e.year,e.month,1);return{year:e.year,month:e.month,label:$e(n,this.resolvedLocale),weeks:Ye(e.year,e.month,this.monthOptions)}}),this.todayLabel=Ge(this.resolvedLocale)}moveMonth(e){let n=Ie(this.viewYear,this.viewMonth,e);this.viewYear=n.year,this.viewMonth=n.month,this.refreshGrid()}getFlatDays(){return this.monthPanels.flatMap(e=>e.weeks.flat())}moveFocusedDay(e){let n=this.getFlatDays().filter(s=>!s.isDisabled);if(!n.length)return;let r=n.findIndex(s=>s.iso===this.focusedIso),i=r<0?Math.max(0,n.findIndex(s=>s.inMonth)):(r+e+n.length)%n.length,a=n[i];if(a){if(!this.isMonthVisible(a.date)){this.viewYear=a.date.getFullYear(),this.viewMonth=a.date.getMonth(),this.focusedIso=a.iso,this.refreshGrid(),this.focusFocusedDay();return}this.focusedIso=a.iso,this.focusDayInCurrentGrid(a.iso)}}isMonthVisible(e){let n=this.viewYear*12+this.viewMonth,r=n+this.visibleMonths-1,i=e.getFullYear()*12+e.getMonth();return i>=n&&i<=r}focusDayInCurrentGrid(e){let n=this.querySelector('[data-calendar-day][tabindex="0"]'),r=Array.from(this.querySelectorAll(`[data-calendar-day][data-iso="${e}"]:not(:disabled)`)),i=r.find(a=>!a.hasAttribute("data-outside"))??r[0];i&&(n&&n!==i&&(n.tabIndex=-1),i.tabIndex=0,i.focus())}focusFocusedDay(){requestAnimationFrame(()=>{this.focusDayInCurrentGrid(this.focusedIso)})}moveFocusedMonth(e){let n=fe(this.focusedIso)??new Date(this.viewYear,this.viewMonth,1),r=new Date(n.getFullYear(),n.getMonth()+e,1),i=new Date(r.getFullYear(),r.getMonth()+1,0).getDate(),a=new Date(r.getFullYear(),r.getMonth(),Math.min(n.getDate(),i));this.viewYear=a.getFullYear(),this.viewMonth=a.getMonth(),this.focusedIso=K(a),this.refreshGrid(),this.focusFocusedDay()}isIsoAllowed(e){return!(this.min&&e<this.min||this.max&&e>this.max)}emitChange(e,n={}){this.changeEvent.emit({value:e,...n})}selectSingle(e){!this.isIsoAllowed(e)||e===this.value||(this.value=e,this.emitChange(e),this.refreshGrid())}selectMultiple(e){if(!this.isIsoAllowed(e))return;let n=Oe(Ve(be(this.value),e));n!==this.value&&(this.value=n,this.emitChange(n),this.refreshGrid())}selectRange(e){if(!this.isIsoAllowed(e))return;let n=je(U(this.value),{anchor:this.rangeAnchor,hover:this.rangeHover},e);if(this.rangeAnchor=n.draft.anchor,this.rangeHover=n.draft.hover,n.committed){let r=ve(n.committed);r!==this.value&&(this.value=r,this.emitChange(r,{start:n.committed.start,end:n.committed.end}))}this.refreshGrid()}selectIso(e){if(this.selectionMode==="multiple"){this.selectMultiple(e);return}if(this.selectionMode==="range"){this.selectRange(e);return}this.selectSingle(e)}previewRange(e){this.selectionMode!=="range"||!this.rangeAnchor||this.disabled||this.rangeHover!==e&&(this.rangeHover=e,this.refreshGrid())}clearRangePreview(){this.rangeHover&&(this.rangeHover=this.rangeAnchor,this.refreshGrid())}initialize(){this.syncViewFromValue(),this.refreshGrid()}constructor(){super(),Yn(this),gi(this,()=>this.initialize())}onConnected(){this.initialize()}onPropsUpdated(){this.selectionMode!=="range"&&(this.rangeAnchor=null,this.rangeHover=null),this.syncViewFromValue(),this.refreshGrid()}onPrevMonth(e){e.preventDefault(),this.moveMonth(-this.pageDelta)}onNextMonth(e){e.preventDefault(),this.moveMonth(this.pageDelta)}onTodayClick(e){e.preventDefault(),this.selectIso(K(new Date))}onDayClick(e){let n=e.target.closest("[data-calendar-day]"),r=n?.getAttribute("data-iso");!r||n?.disabled||this.disabled||this.selectIso(r)}onDayPointerEnter(e){let n=e.target.closest("[data-calendar-day]"),r=n?.getAttribute("data-iso");!r||n?.disabled||this.previewRange(r)}onGridPointerLeave(){this.clearRangePreview()}onDayKeydown(e){if(this.disabled)return;let n=e.target.getAttribute("data-iso");if(n&&(this.focusedIso=n),e.key==="ArrowLeft"){e.preventDefault(),this.moveFocusedDay(-1);return}if(e.key==="ArrowRight"){e.preventDefault(),this.moveFocusedDay(1);return}if(e.key==="ArrowUp"){e.preventDefault(),this.moveFocusedDay(-7);return}if(e.key==="ArrowDown"){e.preventDefault(),this.moveFocusedDay(7);return}if(e.key==="PageUp"){e.preventDefault(),this.moveFocusedMonth(e.shiftKey?-12:-this.pageDelta);return}if(e.key==="PageDown"){e.preventDefault(),this.moveFocusedMonth(e.shiftKey?12:this.pageDelta);return}if(e.key==="Enter"||e.key===" "){e.preventDefault();let r=e.target,i=r.getAttribute("data-iso");i&&!r.disabled&&this.selectIso(i)}}dayDataAttributes(e){return{"data-range-start":e.isRangeStart?"true":void 0,"data-range-end":e.isRangeEnd?"true":void 0,"data-range-middle":e.isRangeMiddle?"true":void 0}}render(){let e=this.monthPanels.length,n=e>1;return tt("div",{class:`rui-calendar${n?" rui-calendar--multi":""}`,"data-ref":"root",role:"application","aria-label":"Calendar","aria-multiselectable":this.selectionMode==="multiple"?"true":void 0,children:[B("div",{class:"rui-calendar__months",children:this.monthPanels.map((r,i)=>tt("div",{class:"rui-calendar__month-panel","data-calendar-month-panel":!0,children:[tt("div",{class:"rui-calendar__header",children:[i===0?B("button",{type:"button",class:"rui-calendar__nav","data-calendar-prev-month":!0,"aria-label":"Previous month",disabled:this.disabled,children:"\u2039"}):B("span",{class:"rui-calendar__nav-spacer","aria-hidden":"true"}),B("div",{class:"rui-calendar__month","aria-live":"polite",children:r.label}),i===e-1?B("button",{type:"button",class:"rui-calendar__nav","data-calendar-next-month":!0,"aria-label":"Next month",disabled:this.disabled,children:"\u203A"}):B("span",{class:"rui-calendar__nav-spacer","aria-hidden":"true"})]}),i===0?B("div",{class:"rui-calendar__weekdays",role:"row",children:this.weekdayLabels.map(a=>B("div",{class:"rui-calendar__weekday",role:"columnheader","aria-hidden":"true",children:a}))}):null,B("div",{class:"rui-calendar__grid",role:"grid","data-calendar-grid":!0,children:r.weeks.map(a=>B("div",{class:"rui-calendar__week",role:"row",children:a.map(s=>B("button",{type:"button",class:"rui-calendar__day","data-calendar-day":!0,"data-iso":s.iso,role:"gridcell",disabled:this.disabled||s.isDisabled,tabIndex:s.iso===this.focusedIso?0:-1,"aria-selected":s.isSelected?"true":"false","aria-current":s.isToday?"date":void 0,"data-outside":s.inMonth?void 0:"true",...this.dayDataAttributes(s),children:s.date.getDate()}))}))})]}))}),B("div",{class:"rui-calendar__footer",children:B("button",{type:"button",class:"rui-calendar__today","data-calendar-today":!0,disabled:this.disabled,children:this.todayLabel})})]})}static{an()}};import{jsx as mi}from"@ecopages/jsx/jsx-runtime";function nt({children:t,...e}){return mi("rui-calendar",{...e,children:t})}import{jsx as Te}from"@ecopages/jsx/jsx-runtime";import{customElement as Di,event as Si,onEvent as _e,onUpdated as pr,prop as we,registerSsrPreparationCallback as Ii,state as gr}from"@ecopages/radiant";import{FormAssociatedElement as mr}from"@ecopages/radiant/form-associated-element";var yi=/^[A-Za-z][A-Za-z0-9_-]*$/;function Wn(t){return yi.test(t)}function vi(t){let e=t.trim();if(Wn(e))return e;let n=`rui-${e}`;return e&&Wn(n)?n:"rui"}function Hn(t){let e=typeof crypto.randomUUID=="function"?crypto.randomUUID().replace(/-/g,""):Array.from(crypto.getRandomValues(new Uint8Array(16)),n=>n.toString(16).padStart(2,"0")).join("");return`${vi(t)}-${e}`}function Nn(t,e){let n=t.type,r=Pe(t),i=!e.useTextboxRole,a=i?"spinbutton":"textbox",s=!e.disabled&&!e.readOnly,o=Me(n,e.segments);return{ariaLabel:qe(n,e.locale),ariaReadonly:e.readOnly||void 0,ariaRole:a,ariaValuemax:i?o.max:void 0,ariaValuemin:i?o.min:void 0,ariaValuenow:i&&r!=null?r:void 0,ariaValuetext:i?De(t):void 0,className:$("rui-date-input__segment",t.isPlaceholder&&"rui-date-input__segment--placeholder"),contenteditable:s?"true":void 0,inputmode:s?"numeric":void 0,suppresscontenteditablewarning:s?"true":void 0,tabindex:e.disabled?void 0:0}}var Un,qn,Kn,Xn,Jn,Zn,Qn,er,tr,nr,rr,ir,ar,or,sr,lr,ur,cr,dr,hr;function bi(t,e,n,r,i,a){var s,o,f,g,v,R,D,j=Symbol.metadata||Symbol.for("Symbol.metadata"),Y=Object.defineProperty,F=Object.create,J=[F(null),F(null)],Z=e.length;function T(l,b,m){return function(u,c){b&&(c=u,u=t);for(var x=0;x<l.length;x++)c=l[x].apply(u,m?[c]:[]);return m?c:u}}function S(l,b,m,u){if(typeof l!="function"&&(u||l!==void 0))throw new TypeError(b+" must "+(m||"be")+" a function"+(u?"":" or undefined"));return l}function Q(l,b,m,u,c,x,M,y,_,w,te){function z(h){if(!te(h))throw new TypeError("Attempted to access private element on non-instance")}var G=[].concat(b[0]),ne=b[3],W=!M,k=c===1,re=c===3,ie=c===4,C=c===2;function O(h,P,se){return function(L,le){return P&&(le=L,L=l),se&&se(L),d[h].call(L,le)}}if(!W){var d={},H=[],I=re?"get":ie||k?"set":"value";if(_?(w||k?d={get:fr(function(){return ne(this)},u,"get"),set:function(h){b[4](this,h)}}:d[I]=ne,w||fr(d[I],u,C?"":I)):w||(d=Object.getOwnPropertyDescriptor(l,u)),!w&&!_){if((o=J[+y][u])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[I].name+") is not supported yet");J[+y][u]=c<3?1:c}}for(var p=l,V=G.length-1;V>=0;V-=m?2:1){var ae=S(G[V],"A decorator","be",!0),oe=m?G[V-1]:void 0,N={},E={kind:["field","accessor","method","getter","setter","class"][c],name:u,metadata:s,addInitializer:function(h,P){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");S(P,"An initializer","be",!0),x.push(P)}.bind(null,N)};if(W)o=ae.call(oe,p,E),N.v=1,S(o,"class decorators","return")&&(p=o);else if(E.static=y,E.private=_,o=E.access={has:_?te.bind():function(h){return u in h}},ie||(o.get=_?C?function(h){return z(h),d.value}:O("get",0,z):function(h){return h[u]}),C||re||(o.set=_?O("set",0,z):function(h,P){h[u]=P}),p=ae.call(oe,k?{get:d.get,set:d.set}:d[I],E),N.v=1,k){if(typeof p=="object"&&p)(o=S(p.get,"accessor.get"))&&(d.get=o),(o=S(p.set,"accessor.set"))&&(d.set=o),(o=S(p.init,"accessor.init"))&&H.unshift(o);else if(p!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else S(p,(w?"field":"method")+" decorators","return")&&(w?H.unshift(p):d[I]=p)}return c<2&&M.push(T(H,y,1),T(x,y,0)),w||W||(_?k?M.splice(-1,0,O("get",y),O("set",y)):M.push(C?d[I]:S.call.bind(d[I])):Y(l,u,d)),p}function ee(l){return Y(l,j,{configurable:!0,enumerable:!0,value:s})}return a!==void 0&&(s=a[j]),s=F(s??null),v=[],R=function(l){l&&v.push(T(l))},D=function(l,b){for(var m=0;m<n.length;m++){var u=n[m],c=u[1],x=7&c;if((8&c)==l&&!x==b){var M=u[2],y=!!u[3],_=16&c;Q(l?t:t.prototype,u,_,y?"#"+M:xi(M),x,x<2?[]:l?g=g||[]:f=f||[],v,!!l,y,b,l&&y?function(w){return wi(w)===t}:i)}}},D(8,0),D(0,0),D(8,1),D(0,1),R(f),R(g),o=v,Z||ee(t),{e:o,get c(){var l=[];return Z&&[ee(t=Q(t,[e],r,t.name,5,l)),T(l,1)]}}}function xi(t){var e=_i(t,"string");return typeof e=="symbol"?e:e+""}function _i(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function fr(t,e,n){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:n?n+" "+e:e})}catch{}return t}function wi(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}function Ri(){return typeof navigator>"u"?!1:/iPad|iPhone|iPod/.test(navigator.userAgent)}var vr,yr=class extends mr{static{({e:[Kn,Xn,Jn,Zn,Qn,er,tr,nr,rr,ir,ar,or,sr,lr,ur,cr,dr,hr,Un],c:[vr,qn]}=bi(this,[Di("rui-date-input")],[[we({type:String,reflect:!0,defaultValue:""}),0,"value"],[we({type:String,defaultValue:""}),0,"min"],[we({type:String,defaultValue:""}),0,"max"],[we({type:Boolean,attribute:"read-only",reflect:!0,defaultValue:!1}),0,"readOnly"],[we({type:String,defaultValue:""}),0,"label"],[we({type:String,defaultValue:""}),0,"locale"],[Si({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[gr,0,"segments"],[gr,0,"focusedPart"],[pr(["value","locale"]),2,"syncSegmentsFromValue"],[pr("label"),2,"syncGroupLabel"],[_e({selector:'[data-ref="root"]',type:"focusin"}),2,"onGroupFocusIn"],[_e({selector:"[data-date-segment]",type:"focusin"}),2,"onSegmentFocusIn"],[_e({selector:"[data-date-segment]",type:"focusout"}),2,"onSegmentFocusOut"],[_e({selector:"[data-date-segment]",type:"keydown"}),2,"onSegmentKeyDown"],[_e({selector:"[data-date-segment]",type:"beforeinput"}),2,"onSegmentBeforeInput"],[_e({selector:"[data-date-segment]",type:"pointerdown"}),2,"onSegmentPointerDown"]],0,void 0,mr))}value=(Un(this),Kn(this));min=(Xn(this),Jn(this));max=(Zn(this),Qn(this));readOnly=(er(this),tr(this));label=(nr(this),rr(this));locale=(ir(this),ar(this));changeEvent=(or(this),sr(this));segments=(lr(this),ur(this,[]));focusedPart=(cr(this),dr(this,null));uid=(hr(this),Hn("rui-date-input"));buffer="";useTextboxRole=Ri();pendingFocus=null;get resolvedLocale(){return Fe(this.locale)}get isoValue(){return this.value??""}syncSegmentsFromValue(){this.segments=Re(fe(this.isoValue),this.resolvedLocale),this.buffer=""}get displaySegments(){return this.segments.length>0?this.segments:Re(fe(this.isoValue),this.resolvedLocale)}constructor(){super(),Ii(this,()=>this.syncSegmentsFromValue())}getSegmentElement(e){return this.querySelector(`[data-date-segment][data-type="${e}"]`)}setFocusedPart(e,n="leave"){let r=this.focusedPart;e===r&&n==="leave"||(this.buffer="",(r!=null||n==="blur")&&this.commit(n),this.focusedPart=e)}focusPart(e){this.setFocusedPart(e),this.pendingFocus=e}updated(e){super.updated(e),this.pendingFocus=null;let n=this.focusedPart;if(!n||!(e.has("focusedPart")||e.has("segments"))||!this.matches(":focus-within"))return;let r=this.getSegmentElement(n);r&&(document.activeElement!==r&&r.focus(),document.activeElement===r&&window.getSelection()?.collapse(r,0))}commit(e){if(e==="edit"&&this.buffer)return;let n=We(this.segments,{min:this.min,max:this.max});switch(n.kind){case"partial-year":e!=="edit"&&this.syncSegmentsFromValue();return;case"incomplete":e==="blur"&&this.syncSegmentsFromValue();return;case"out-of-range":this.syncSegmentsFromValue();return;case"empty":this.publish("");return;case"date":this.publish(n.iso)}}publish(e){if(e===this.isoValue){this.syncSegmentsFromValue();return}this.value=e,this.changeEvent.emit({value:e})}partFromTarget(e){if(!(e instanceof HTMLElement))return null;let r=e.closest("[data-date-segment]")?.getAttribute("data-type");return r==="month"||r==="day"||r==="year"?r:null}handleDigit(e,n){this.setFocusedPart(e);let r=Xe(this.segments,e,n,this.buffer);if(this.segments=r.segments,this.buffer=r.enteredKeys,r.focusNext){this.focusPart(xe(this.segments,e,1));return}this.commit("edit")}handleBackspace(e){this.setFocusedPart(e);let n=Ze(this.segments,e);if(n.kind==="focus-previous"){this.focusPart(xe(this.segments,e,-1));return}this.segments=n.segments,this.buffer=n.enteredKeys,this.commit("edit")}handleIncrement(e,n){this.setFocusedPart(e),this.buffer="",this.segments=Ke(this.segments,e,n),this.commit("edit")}onConnected(){this.syncSegmentsFromValue(),this.syncGroupLabel()}formValue(){return this.name?this.isoValue:null}formState(){return this.value}restoreFormState(e){this.value=typeof e=="string"?e:"",this.syncSegmentsFromValue()}formResetCallback(){super.formResetCallback(),this.dispatchEvent(new Event("rui-form-reset",{bubbles:!0}))}syncGroupLabel(){let e=this.querySelector('[data-ref="root"]');if(!e)return;e.id||(e.id=`${this.uid}-group`);let n=this.label||this.getAttribute("aria-label")||"";n?e.setAttribute("aria-label",n):e.removeAttribute("aria-label")}onGroupFocusIn(e){this.partFromTarget(e.target)||this.focusPart(Je(this.segments))}onSegmentFocusIn(e){let n=this.partFromTarget(e.target);n&&(this.pendingFocus&&this.pendingFocus!==n||this.setFocusedPart(n))}onSegmentFocusOut(){queueMicrotask(()=>{this.matches(":focus-within")||this.setFocusedPart(null,"blur")})}onSegmentKeyDown(e){let n=this.partFromTarget(e.target);if(!(!n||this.effectiveDisabled||this.readOnly)){if(e.key==="ArrowLeft"){e.preventDefault(),this.focusPart(xe(this.segments,n,-1));return}if(e.key==="ArrowRight"){e.preventDefault(),this.focusPart(xe(this.segments,n,1));return}if(e.key==="ArrowUp"){e.preventDefault(),this.handleIncrement(n,1);return}if(e.key==="ArrowDown"){e.preventDefault(),this.handleIncrement(n,-1);return}(e.key==="Backspace"||e.key==="Delete")&&(e.preventDefault(),e.stopPropagation(),this.handleBackspace(n))}}onSegmentBeforeInput(e){let n=this.partFromTarget(e.target);if(!(!n||this.effectiveDisabled||this.readOnly))switch(e.preventDefault(),e.inputType){case"deleteContentBackward":case"deleteContentForward":this.handleBackspace(n);break;default:e.data!=null&&this.handleDigit(n,e.data);break}}onSegmentPointerDown(e){e.stopPropagation()}renderSegment(e,n){if(!e.editable)return Te("span",{class:"rui-date-input__literal","data-type":"literal","aria-hidden":"true",children:e.value},`literal-${n}`);let r=e.type,i=this.focusedPart===r,a=Nn(e,{disabled:this.effectiveDisabled,locale:this.resolvedLocale,readOnly:this.readOnly,segments:this.displaySegments,useTextboxRole:this.useTextboxRole});return Te("span",{class:a.className,"data-date-segment":!0,"data-type":r,"data-placeholder":e.isPlaceholder?"true":void 0,"data-focused":i?"true":void 0,role:a.ariaRole,"aria-label":a.ariaLabel,"aria-valuemin":a.ariaValuemin,"aria-valuemax":a.ariaValuemax,"aria-valuenow":a.ariaValuenow,"aria-valuetext":a.ariaValuetext,"aria-readonly":a.ariaReadonly,contenteditable:a.contenteditable,suppresscontenteditablewarning:a.suppresscontenteditablewarning,spellcheck:"false",inputmode:a.inputmode,tabindex:a.tabindex,children:De(e)},r)}render(){return Te("div",{class:"rui-date-input","data-ref":"root",role:"group",children:Te("div",{class:"rui-date-input__segments",children:this.displaySegments.map((e,n)=>this.renderSegment(e,n))})})}static{qn()}};import{jsx as Mi}from"@ecopages/jsx/jsx-runtime";function Ce({children:t,...e}){return Mi("rui-date-input",{"data-rui-control":!0,"data-rui-control-type":"date","data-rui-aria-target":'[data-ref="root"]',...e,children:t})}function br({children:t,class:e,...n}){return A("div",{...n,class:$("rui-date-range-picker",e),children:A("div",{class:"rui-date-range-picker__group","data-ref":"control",children:t})})}function xr({children:t,class:e,...n}){return A("div",{...n,class:$("rui-date-range-picker__values",e),"data-ref":"values",children:t})}function _r({class:t,...e}){return A(Ce,{...e,"data-range-start":!0,class:$("rui-date-range-picker__input",t)})}function wr({class:t,...e}){return A(Ce,{...e,"data-range-end":!0,class:$("rui-date-range-picker__input",t)})}function Dr({children:t="\u2013",class:e,...n}){return A("span",{...n,class:$("rui-date-range-picker__separator",e),"aria-hidden":"true",children:t})}function Sr({children:t,class:e,aria:n,...r}){return A("button",{...r,aria:nn(n,"Open calendar"),type:"button","data-ref":"trigger","data-range-trigger":!0,class:$("rui-control-toggle",e),"aria-haspopup":"dialog",children:t??A(et,{})})}function Ir({children:t,class:e,...n}){return A("div",{...n,"data-ref":"popover","data-range-popover":!0,class:$("rui-date-range-picker__popover rui-popover rui-floating",e),hidden:!0,role:"dialog",children:t})}function Rr(t){return A(nt,{...t,"data-range-calendar":!0})}function ki(t){let{children:e,startLabel:n="Start date",endLabel:r="End date",value:i,min:a,max:s,disabled:o,readOnly:f,locale:g,startName:v,endName:R}=t,D=U(i??"");return A("rui-date-range-picker",{"data-rui-aria-targets":'[data-range-start] [data-ref="root"],[data-range-end] [data-ref="root"]',...t,children:e??rt(Pi,{children:[rt(br,{children:[rt(xr,{children:[A(_r,{"aria-label":n,value:D?.start,min:a,max:s,disabled:o,readOnly:f,locale:g,name:v}),A(Dr,{}),A(wr,{"aria-label":r,value:D?.end,min:a,max:s,disabled:o,readOnly:f,locale:g,name:R})]}),A(Sr,{})]}),A(Ir,{children:A(Rr,{})})]})})}export{ki as RuiDateRangePicker,Rr as RuiDateRangePickerCalendar,br as RuiDateRangePickerControl,tn as RuiDateRangePickerElement,wr as RuiDateRangePickerEndInput,xr as RuiDateRangePickerInputs,Ir as RuiDateRangePickerPopover,Dr as RuiDateRangePickerSeparator,_r as RuiDateRangePickerStartInput,Sr as RuiDateRangePickerToggle};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|