@ecopages/radiant-ui 0.1.0-beta.6 → 0.1.0-beta.8
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 +1 -1
- package/dist/components/ui/alert/alert.css +88 -50
- package/dist/components/ui/alert/alert.d.ts +43 -5
- package/dist/components/ui/alert/alert.script.d.ts +51 -4
- package/dist/components/ui/alert/index.d.ts +2 -2
- package/dist/components/ui/alert/index.js +1 -1
- package/dist/components/ui/alert/index.js.map +4 -4
- package/dist/components/ui/autocomplete/autocomplete.css +4 -4
- package/dist/components/ui/autocomplete/autocomplete.d.ts +15 -5
- package/dist/components/ui/autocomplete/autocomplete.script.d.ts +9 -0
- package/dist/components/ui/autocomplete/index.js +1 -1
- package/dist/components/ui/autocomplete/index.js.map +4 -4
- package/dist/components/ui/avatar/avatar.d.ts +15 -1
- package/dist/components/ui/avatar/index.js +1 -1
- package/dist/components/ui/avatar/index.js.map +4 -4
- package/dist/components/ui/breadcrumb/breadcrumb.d.ts +32 -6
- package/dist/components/ui/breadcrumb/index.js +1 -1
- package/dist/components/ui/breadcrumb/index.js.map +4 -4
- package/dist/{styles/components → components/ui/button}/button.css +45 -31
- package/dist/components/ui/button/button.d.ts +21 -4
- package/dist/components/ui/button-group/button-group.d.ts +7 -1
- package/dist/components/ui/button-group/index.js +1 -1
- package/dist/components/ui/button-group/index.js.map +4 -4
- package/dist/components/ui/calendar/calendar.css +7 -7
- package/dist/components/ui/calendar/calendar.d.ts +3 -2
- package/dist/components/ui/calendar/calendar.script.d.ts +39 -1
- package/dist/components/ui/calendar/index.js +1 -1
- package/dist/components/ui/calendar/index.js.map +4 -4
- package/dist/components/ui/carousel/carousel.d.ts +32 -6
- package/dist/components/ui/carousel/carousel.script.d.ts +44 -0
- 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.css +1 -1
- package/dist/components/ui/checkbox/checkbox.d.ts +3 -2
- package/dist/components/ui/checkbox/checkbox.script.d.ts +4 -0
- package/dist/components/ui/checkbox/index.js +1 -1
- package/dist/components/ui/checkbox/index.js.map +4 -4
- package/dist/components/ui/chip/chip.d.ts +8 -0
- package/dist/components/ui/chip/index.js +1 -1
- package/dist/components/ui/chip/index.js.map +4 -4
- package/dist/components/ui/chip-list/chip-list.d.ts +10 -2
- package/dist/components/ui/chip-list/index.js +1 -1
- package/dist/components/ui/chip-list/index.js.map +4 -4
- package/dist/components/ui/combobox/combobox.css +39 -1
- package/dist/components/ui/combobox/combobox.d.ts +15 -5
- package/dist/components/ui/combobox/combobox.script.d.ts +13 -1
- 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.css +15 -0
- package/dist/components/ui/cycle-toggle/cycle-toggle.d.ts +29 -0
- package/dist/components/ui/cycle-toggle/cycle-toggle.script.d.ts +61 -0
- package/dist/components/ui/cycle-toggle/index.d.ts +5 -0
- package/dist/components/ui/cycle-toggle/index.js +2 -0
- package/dist/components/ui/cycle-toggle/index.js.map +7 -0
- package/dist/components/ui/cycle-toggle/theme-preference-icons.d.ts +12 -0
- package/dist/components/ui/date-field/date-field.css +37 -0
- package/dist/components/ui/date-field/date-field.d.ts +22 -3
- package/dist/components/ui/date-field/date-field.script.d.ts +29 -5
- package/dist/components/ui/date-field/index.d.ts +1 -1
- 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-range-picker/date-range-picker.css +37 -0
- package/dist/components/ui/date-range-picker/date-range-picker.d.ts +37 -4
- package/dist/components/ui/date-range-picker/date-range-picker.script.d.ts +31 -5
- package/dist/components/ui/date-range-picker/index.d.ts +1 -1
- 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 +1 -1
- package/dist/components/ui/dialog/dialog.d.ts +30 -5
- package/dist/components/ui/dialog/dialog.script.d.ts +3 -0
- 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.css +1 -1
- package/dist/components/ui/disclosure/disclosure-group.script.d.ts +6 -0
- package/dist/components/ui/disclosure/disclosure.d.ts +26 -7
- package/dist/components/ui/disclosure/disclosure.script.d.ts +5 -0
- package/dist/components/ui/disclosure/index.js +1 -1
- package/dist/components/ui/disclosure/index.js.map +4 -4
- package/dist/components/ui/feed/feed.d.ts +37 -7
- package/dist/components/ui/feed/index.js +1 -1
- package/dist/components/ui/feed/index.js.map +4 -4
- package/dist/components/ui/field/field-description.d.ts +5 -1
- package/dist/components/ui/field/field-error.d.ts +5 -0
- package/dist/components/ui/field/field.d.ts +8 -1
- package/dist/components/ui/field/field.script.d.ts +35 -0
- 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 +6 -0
- package/dist/components/ui/form/form.d.ts +2 -1
- package/dist/components/ui/form/form.script.d.ts +16 -1
- package/dist/components/ui/form/index.d.ts +1 -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 +12 -2
- package/dist/components/ui/grid/grid.script.d.ts +14 -0
- package/dist/components/ui/grid/index.js +1 -1
- package/dist/components/ui/grid/index.js.map +4 -4
- package/dist/components/ui/heading/heading.d.ts +26 -4
- package/dist/components/ui/heading/index.js +1 -1
- package/dist/components/ui/heading/index.js.map +4 -4
- package/dist/components/ui/headline/headline.d.ts +9 -1
- package/dist/components/ui/headline/index.js +1 -1
- package/dist/components/ui/headline/index.js.map +4 -4
- package/dist/components/ui/input/index.d.ts +1 -1
- 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 +2 -7
- package/dist/components/ui/input/input.d.ts +7 -2
- 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 +8 -1
- 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 +2 -5
- package/dist/components/ui/listbox/listbox.d.ts +7 -3
- package/dist/components/ui/listbox/listbox.script.d.ts +14 -1
- package/dist/components/ui/menu-button/index.d.ts +1 -1
- 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.css +2 -2
- package/dist/components/ui/menu-button/menu-button.d.ts +27 -5
- package/dist/components/ui/menu-button/menu-button.script.d.ts +8 -3
- 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.css +4 -4
- package/dist/components/ui/menubar/menubar.d.ts +14 -2
- package/dist/components/ui/menubar/menubar.script.d.ts +10 -1
- package/dist/components/ui/meter/index.js +1 -1
- package/dist/components/ui/meter/index.js.map +4 -4
- package/dist/components/ui/meter/meter.css +1 -1
- package/dist/components/ui/meter/meter.d.ts +7 -2
- package/dist/components/ui/meter/meter.script.d.ts +21 -0
- 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 +2 -2
- package/dist/components/ui/navigation-menu/navigation-menu.d.ts +3 -2
- package/dist/components/ui/navigation-menu/navigation-menu.script.d.ts +4 -0
- package/dist/components/ui/number-field/index.d.ts +1 -1
- 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 +18 -3
- package/dist/components/ui/number-field/number-field.d.ts +36 -8
- package/dist/components/ui/number-field/number-field.script.d.ts +28 -1
- 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 +5 -4
- package/dist/components/ui/popover/popover.script.d.ts +4 -0
- package/dist/components/ui/radio-group/index.d.ts +1 -1
- 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 +29 -4
- package/dist/components/ui/radio-group/radio-group.script.d.ts +14 -9
- 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 +48 -6
- package/dist/components/ui/select/select.d.ts +29 -8
- package/dist/components/ui/select/select.script.d.ts +7 -0
- 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.script.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar.css +41 -24
- package/dist/components/ui/sidebar/sidebar.d.ts +68 -14
- package/dist/components/ui/sidebar/sidebar.docs.css +5 -2
- package/dist/components/ui/sidebar/sidebar.script.d.ts +21 -5
- 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.d.ts +2 -1
- package/dist/components/ui/slider/slider.script.d.ts +29 -1
- 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 +3 -3
- package/dist/components/ui/switch/switch.d.ts +11 -2
- package/dist/components/ui/switch/switch.script.d.ts +5 -0
- package/dist/components/ui/tabs/index.js +1 -1
- package/dist/components/ui/tabs/index.js.map +4 -4
- package/dist/components/ui/tabs/tabs.css +9 -10
- package/dist/components/ui/tabs/tabs.d.ts +30 -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.css +2 -11
- package/dist/components/ui/tag-group/tag-group.d.ts +18 -5
- package/dist/components/ui/tag-group/tag-group.script.d.ts +9 -2
- package/dist/components/ui/textarea/index.d.ts +1 -1
- 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.d.ts +7 -2
- package/dist/components/ui/toast/index.d.ts +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/stack-layout.d.ts +18 -0
- package/dist/components/ui/toast/toast-context.d.ts +10 -0
- package/dist/components/ui/toast/toast.css +30 -9
- package/dist/components/ui/toast/toast.d.ts +12 -2
- package/dist/components/ui/toast/toast.script.d.ts +60 -4
- package/dist/components/ui/toast/toaster.script.d.ts +71 -2
- package/dist/components/ui/toc/index.js +1 -1
- package/dist/components/ui/toc/index.js.map +4 -4
- package/dist/components/ui/toc/toc.css +3 -0
- package/dist/components/ui/toc/toc.d.ts +2 -1
- package/dist/components/ui/toc/toc.script.d.ts +15 -0
- package/dist/components/ui/toolbar/index.js +1 -1
- package/dist/components/ui/toolbar/index.js.map +4 -4
- package/dist/components/ui/toolbar/toolbar.d.ts +3 -2
- package/dist/components/ui/toolbar/toolbar.script.d.ts +8 -0
- 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.d.ts +3 -2
- package/dist/components/ui/tooltip/tooltip.script.d.ts +3 -0
- package/dist/components/ui/tree/index.js +1 -1
- package/dist/components/ui/tree/index.js.map +4 -4
- package/dist/components/ui/tree/tree.d.ts +12 -2
- package/dist/components/ui/tree/tree.script.d.ts +18 -1
- package/dist/components/ui/treegrid/index.js +1 -1
- package/dist/components/ui/treegrid/index.js.map +4 -4
- package/dist/components/ui/treegrid/treegrid.d.ts +15 -2
- package/dist/components/ui/treegrid/treegrid.script.d.ts +22 -1
- package/dist/components/ui/window-splitter/index.js +1 -1
- package/dist/components/ui/window-splitter/index.js.map +4 -4
- package/dist/components/ui/window-splitter/window-splitter.css +1 -1
- package/dist/components/ui/window-splitter/window-splitter.d.ts +3 -2
- package/dist/components/ui/window-splitter/window-splitter.script.d.ts +22 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/lib/cycle-value.d.ts +8 -0
- package/dist/lib/intl-number/range.d.ts +8 -0
- package/dist/styles/radiant-ui-core.css +110 -341
- package/dist/styles/radiant-ui.css +413 -377
- package/dist/styles/styles.css +839 -2731
- package/dist/styles/tailwind.css +626 -530
- package/dist/styles/tokens/colors/aurora.css +2 -2
- package/dist/styles/tokens/colors/basalt.css +2 -1
- package/dist/styles/tokens/colors/glacier.css +2 -1
- package/dist/styles/tokens/presets/colors/aurora.css +42 -14
- package/dist/styles/tokens/presets/colors/basalt.css +28 -0
- package/dist/styles/tokens/presets/colors/ember.css +28 -0
- package/dist/styles/tokens/presets/colors/glacier.css +28 -0
- package/dist/styles/tokens/semantic.css +22 -2
- package/dist/styles/tokens/spacing/compact.css +12 -12
- package/package.json +21 -8
- package/dist/components/ui/dialog/dialog-registry.test.d.ts +0 -1
- package/dist/components/ui/field/field-ssr-hydration.test.d.ts +0 -1
- package/dist/components/ui/form/form-field.test.d.ts +0 -4
- package/dist/components/ui/form/form-store.test.d.ts +0 -1
- package/dist/components/ui/shared/collection-navigation.test.d.ts +0 -1
- package/dist/components/ui/shared/floating-position.test.d.ts +0 -1
- package/dist/components/ui/shared/listbox-popover-behavior.test.d.ts +0 -1
- package/dist/components/ui/shared/popover-controller.test.d.ts +0 -1
- package/dist/components/ui/shared/portal.test.d.ts +0 -1
- package/dist/components/ui/sidebar/sidebar.ssr.test.d.ts +0 -2
- package/dist/components/ui/sidebar/sidebar.test.d.ts +0 -1
- package/dist/components/ui/toast/toast.test.d.ts +0 -2
- package/dist/components/ui/toc/toc-helpers.test.d.ts +0 -1
- package/dist/components/ui/toc/toc.ssr.test.d.ts +0 -1
- package/dist/components/ui/toc/toc.test.d.ts +0 -1
- package/dist/lib/intl-date/parts.test.d.ts +0 -1
- package/dist/lib/intl-date/segments.test.d.ts +0 -1
- package/dist/lib/intl-date/selection.test.d.ts +0 -1
- package/dist/lib/mask/date-mask.test.d.ts +0 -1
- package/dist/lib/mask/input-mask.test.d.ts +0 -1
- package/dist/lib/radiant-view.d.ts +0 -43
- package/dist/lib/text-filter.test.d.ts +0 -1
- package/dist/styles/tokens/presets/radius.css +0 -45
- package/dist/styles/tokens/presets/spacing.css +0 -57
|
@@ -3,17 +3,13 @@
|
|
|
3
3
|
@layer components {
|
|
4
4
|
.rui-button {
|
|
5
5
|
display: inline-flex;
|
|
6
|
-
height: fit-content;
|
|
7
6
|
width: fit-content;
|
|
8
7
|
align-items: center;
|
|
9
8
|
justify-content: center;
|
|
10
|
-
gap: var(--spacing-2, var(--space-2));
|
|
11
9
|
border-radius: var(--radius-button, var(--radius-control));
|
|
12
10
|
border-style: var(--tw-border-style);
|
|
13
11
|
border-width: 1px;
|
|
14
12
|
border-color: transparent;
|
|
15
|
-
font-size: var(--text-sm, var(--text-sm));
|
|
16
|
-
line-height: var(--tw-leading, var(--text-sm--line-height, calc(1.25 / 0.875)));
|
|
17
13
|
--tw-font-weight: var(--font-weight-medium, var(--weight-medium));
|
|
18
14
|
font-weight: var(--font-weight-medium, var(--weight-medium));
|
|
19
15
|
transition-property: background-color,color,box-shadow;
|
|
@@ -25,6 +21,7 @@
|
|
|
25
21
|
transition-timing-function: var(--ease-out, cubic-bezier(0, 0, 0.2, 1));
|
|
26
22
|
cursor: pointer;
|
|
27
23
|
white-space: nowrap;
|
|
24
|
+
gap: var(--space-inline);
|
|
28
25
|
}
|
|
29
26
|
.rui-button > svg {
|
|
30
27
|
pointer-events: none;
|
|
@@ -74,20 +71,12 @@
|
|
|
74
71
|
}
|
|
75
72
|
.rui-button--outline:hover:not(:disabled) {
|
|
76
73
|
background-color: var(--color-surface, var(--surface));
|
|
77
|
-
background-image: var(--sheen-image);
|
|
78
|
-
@media (forced-colors: active) {
|
|
79
|
-
background-image: none;
|
|
80
|
-
}
|
|
81
74
|
}
|
|
82
75
|
.rui-button--outline:active:not(:disabled) {
|
|
83
76
|
background-color: var(--color-surface, var(--surface));
|
|
84
77
|
@supports (color: color-mix(in lab, red, red)) {
|
|
85
78
|
background-color: color-mix(in oklab, var(--color-surface, var(--surface)) 80%, transparent);
|
|
86
79
|
}
|
|
87
|
-
background-image: var(--sheen-image);
|
|
88
|
-
@media (forced-colors: active) {
|
|
89
|
-
background-image: none;
|
|
90
|
-
}
|
|
91
80
|
}
|
|
92
81
|
.rui-button--outline[aria-pressed='true'] {
|
|
93
82
|
background-color: var(--color-background, var(--background));
|
|
@@ -109,10 +98,6 @@
|
|
|
109
98
|
}
|
|
110
99
|
.rui-button--ghost:hover:not(:disabled) {
|
|
111
100
|
background-color: var(--color-surface-container-low, var(--surface-container-low));
|
|
112
|
-
background-image: var(--sheen-image);
|
|
113
|
-
@media (forced-colors: active) {
|
|
114
|
-
background-image: none;
|
|
115
|
-
}
|
|
116
101
|
}
|
|
117
102
|
.rui-button--ghost:active:not(:disabled) {
|
|
118
103
|
background-color: var(--color-surface-container, var(--surface-container));
|
|
@@ -145,28 +130,57 @@
|
|
|
145
130
|
.rui-button--destructive:active:not(:disabled) {
|
|
146
131
|
background-color: var(--color-error-dark, var(--error-dark));
|
|
147
132
|
}
|
|
133
|
+
.rui-button--link {
|
|
134
|
+
background-color: transparent;
|
|
135
|
+
--tw-font-weight: var(--font-weight-normal, 400);
|
|
136
|
+
font-weight: var(--font-weight-normal, 400);
|
|
137
|
+
color: var(--color-link, var(--link));
|
|
138
|
+
text-decoration-line: none;
|
|
139
|
+
text-underline-offset: 2px;
|
|
140
|
+
}
|
|
141
|
+
.rui-button--link:hover:not(:disabled),
|
|
142
|
+
.rui-button--link:focus-visible:not(:disabled) {
|
|
143
|
+
text-decoration-line: underline;
|
|
144
|
+
}
|
|
145
|
+
.rui-button--link:active:not(:disabled) {
|
|
146
|
+
text-decoration-line: underline;
|
|
147
|
+
}
|
|
148
|
+
.rui-button--link[aria-pressed='true'] {
|
|
149
|
+
text-decoration-line: underline;
|
|
150
|
+
}
|
|
151
|
+
.rui-button--none {
|
|
152
|
+
height: auto;
|
|
153
|
+
min-height: 0px;
|
|
154
|
+
padding-inline: 0;
|
|
155
|
+
padding-block: 0;
|
|
156
|
+
}
|
|
148
157
|
.rui-button--sm {
|
|
149
|
-
|
|
150
|
-
padding-
|
|
151
|
-
font-size: var(--text-xs
|
|
152
|
-
line-height: var(--tw-leading, var(--text-xs--line-height, calc(1 / 0.75)));
|
|
158
|
+
height: var(--size-control-sm);
|
|
159
|
+
padding-inline: calc(var(--space-control-x) * 0.75);
|
|
160
|
+
font-size: var(--text-xs);
|
|
153
161
|
}
|
|
154
162
|
.rui-button--md {
|
|
155
|
-
|
|
156
|
-
padding-
|
|
157
|
-
font-size: var(--text-
|
|
158
|
-
line-height: var(--tw-leading, var(--text-sm--line-height, calc(1.25 / 0.875)));
|
|
163
|
+
height: var(--size-control-md);
|
|
164
|
+
padding-inline: var(--space-control-x);
|
|
165
|
+
font-size: var(--text-control, 0.875rem);
|
|
159
166
|
}
|
|
160
167
|
.rui-button--lg {
|
|
161
|
-
|
|
162
|
-
padding-
|
|
163
|
-
font-size: var(--text-
|
|
164
|
-
line-height: var(--tw-leading, var(--text-base--line-height, calc(1.5 / 1)));
|
|
168
|
+
height: var(--size-control-lg);
|
|
169
|
+
padding-inline: calc(var(--space-control-x) * 1.5);
|
|
170
|
+
font-size: var(--text-body);
|
|
165
171
|
}
|
|
166
172
|
.rui-button--icon {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
173
|
+
height: var(--size-control-md);
|
|
174
|
+
width: var(--size-control-md);
|
|
175
|
+
padding-inline: 0;
|
|
176
|
+
font-size: var(--text-control, 0.875rem);
|
|
177
|
+
}
|
|
178
|
+
.rui-button--link.rui-button--sm,
|
|
179
|
+
.rui-button--link.rui-button--md,
|
|
180
|
+
.rui-button--link.rui-button--lg {
|
|
181
|
+
height: auto;
|
|
182
|
+
padding-inline: 0;
|
|
183
|
+
padding-block: 0;
|
|
170
184
|
}
|
|
171
185
|
.rui-button--primary {
|
|
172
186
|
background-color: var(--color-primary, var(--primary));
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { JsxHtmlPropsWithChildren } from '@ecopages/jsx';
|
|
2
|
-
export type RuiButtonVariant = 'filled' | 'outline' | 'destructive' | 'ghost';
|
|
3
|
-
export type RuiButtonSize = 'sm' | 'md' | 'lg';
|
|
2
|
+
export type RuiButtonVariant = 'filled' | 'outline' | 'destructive' | 'ghost' | 'link';
|
|
3
|
+
export type RuiButtonSize = 'none' | 'sm' | 'md' | 'lg';
|
|
4
4
|
type RuiButtonCommonProps = JsxHtmlPropsWithChildren<{
|
|
5
5
|
/** Visual style. Default: `filled`. */
|
|
6
6
|
variant?: RuiButtonVariant;
|
|
7
|
-
/** Control size. Default: `md
|
|
7
|
+
/** Control size. Default: `md` (Default in docs). Use `none` for inline `link` chrome. */
|
|
8
8
|
size?: RuiButtonSize;
|
|
9
9
|
/** Accessible name when the button has no visible text. */
|
|
10
10
|
'aria-label'?: string;
|
|
@@ -41,9 +41,26 @@ export type RuiButtonProps = RuiButtonControlProps | RuiButtonLinkProps;
|
|
|
41
41
|
* No custom element and no controller — only CSS variants/sizes. The `href`
|
|
42
42
|
* union branch preserves native link semantics for navigation.
|
|
43
43
|
*
|
|
44
|
-
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* Default/`md` height uses `--size-control-md`, the same token as `RuiInput`, so
|
|
46
|
+
* form rows align. `none` omits fixed height and padding for inline `link`
|
|
47
|
+
* actions. Styles live in `./button.css`.
|
|
48
|
+
*
|
|
49
|
+
* Variant tones map to semantic action roles — `primary` for filled, `error`
|
|
50
|
+
* (destructive) for destructive — never palette steps.
|
|
45
51
|
*
|
|
46
52
|
* @see https://www.w3.org/WAI/ARIA/apg/patterns/button/
|
|
53
|
+
*
|
|
54
|
+
* @cssclass rui-button - Button / button-styled link root.
|
|
55
|
+
* @cssclass rui-button--filled - Primary filled action (`bg-primary`).
|
|
56
|
+
* @cssclass rui-button--outline - Bordered secondary action.
|
|
57
|
+
* @cssclass rui-button--destructive - Destructive action (`bg-error`).
|
|
58
|
+
* @cssclass rui-button--ghost - Subtle, borderless action.
|
|
59
|
+
* @cssclass rui-button--link - Inline link-styled action.
|
|
60
|
+
* @cssclass rui-button--none - No fixed size (inline `link` chrome).
|
|
61
|
+
* @cssclass rui-button--sm - Small control height.
|
|
62
|
+
* @cssclass rui-button--md - Default control height.
|
|
63
|
+
* @cssclass rui-button--lg - Large control height.
|
|
47
64
|
*/
|
|
48
65
|
export declare function RuiButton(props: RuiButtonProps): import("@ecopages/jsx").JsxRenderable;
|
|
49
66
|
export {};
|
|
@@ -6,5 +6,11 @@ export type RuiButtonGroupProps = JsxHtmlPropsWithChildren<{
|
|
|
6
6
|
/** Accessible name when the group has no visible label. */
|
|
7
7
|
'aria-label'?: string;
|
|
8
8
|
}>;
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Related buttons / links in a horizontal or vertical group.
|
|
11
|
+
*
|
|
12
|
+
* @cssclass rui-button-group - Root group (`role="group"`).
|
|
13
|
+
* @cssclass rui-button-group--horizontal - Side-by-side layout (default).
|
|
14
|
+
* @cssclass rui-button-group--vertical - Stacked layout.
|
|
15
|
+
*/
|
|
10
16
|
export declare function RuiButtonGroup({ children, orientation, class: className, 'aria-label': ariaLabel, ...props }: RuiButtonGroupProps): import("@ecopages/jsx").JsxRenderable;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as a}from"@ecopages/jsx/jsx-runtime";function t(...o){return o.filter(Boolean).join(" ")}function e({children:o,orientation:r="horizontal",class:u,"aria-label":i,...n}){return a("div",{...n,role:"group","aria-label":i,"aria-orientation":r,class:t("rui-button-group",`rui-button-group--${r}`,u),children:o})}export{e as RuiButtonGroup};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/components/ui/button-group/button-group.tsx", "../../../../src/lib/cx.ts"
|
|
4
|
-
"sourcesContent": ["import { jsx } from \"@ecopages/jsx/jsx-runtime\";\nimport { cx } from \"@/lib/cx\";\
|
|
5
|
-
"mappings": "AAAA,OAAS,OAAAA,MAAW,4BCAb,SAASC,KAAMC,EAAO,CAC3B,OAAOA,EAAM,OAAO,OAAO,EAAE,KAAK,GAAG,CACvC,
|
|
6
|
-
"names": ["jsx", "cx", "parts", "
|
|
3
|
+
"sources": ["../../../../src/components/ui/button-group/button-group.tsx", "../../../../src/lib/cx.ts"],
|
|
4
|
+
"sourcesContent": ["import { jsx } from \"@ecopages/jsx/jsx-runtime\";\nimport { cx } from \"@/lib/cx\";\nexport function RuiButtonGroup({\n children,\n orientation = \"horizontal\",\n class: className,\n \"aria-label\": ariaLabel,\n ...props\n}) {\n return /* @__PURE__ */jsx(\"div\", {\n ...props,\n role: \"group\",\n \"aria-label\": ariaLabel,\n \"aria-orientation\": orientation,\n class: cx(\"rui-button-group\", `rui-button-group--${orientation}`, className),\n children\n });\n}", "export function cx(...parts) {\n return parts.filter(Boolean).join(\" \");\n}"],
|
|
5
|
+
"mappings": "AAAA,OAAS,OAAAA,MAAW,4BCAb,SAASC,KAAMC,EAAO,CAC3B,OAAOA,EAAM,OAAO,OAAO,EAAE,KAAK,GAAG,CACvC,CDAO,SAASC,EAAe,CAC7B,SAAAC,EACA,YAAAC,EAAc,aACd,MAAOC,EACP,aAAcC,EACd,GAAGC,CACL,EAAG,CACD,OAAsBC,EAAI,MAAO,CAC/B,GAAGD,EACH,KAAM,QACN,aAAcD,EACd,mBAAoBF,EACpB,MAAOK,EAAG,mBAAoB,qBAAqBL,CAAW,GAAIC,CAAS,EAC3E,SAAAF,CACF,CAAC,CACH",
|
|
6
|
+
"names": ["jsx", "cx", "parts", "RuiButtonGroup", "children", "orientation", "className", "ariaLabel", "props", "jsx", "cx"]
|
|
7
7
|
}
|
|
@@ -10,10 +10,10 @@ rui-calendar {
|
|
|
10
10
|
border-width: 1px;
|
|
11
11
|
border-color: var(--color-border, var(--border));
|
|
12
12
|
background-color: var(--color-background, var(--background));
|
|
13
|
-
padding: var(--spacing-
|
|
13
|
+
padding: var(--spacing-inset, var(--space-inset));
|
|
14
14
|
font-size: var(--text-sm, var(--text-sm));
|
|
15
15
|
line-height: var(--tw-leading, var(--text-sm--line-height, calc(1.25 / 0.875)));
|
|
16
|
-
--tw-shadow: var(--shadow-
|
|
16
|
+
--tw-shadow: var(--shadow-control);
|
|
17
17
|
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
|
18
18
|
}
|
|
19
19
|
.rui-calendar--multi {
|
|
@@ -23,12 +23,12 @@ rui-calendar {
|
|
|
23
23
|
.rui-calendar__months {
|
|
24
24
|
display: flex;
|
|
25
25
|
flex-direction: column;
|
|
26
|
-
gap: var(--spacing-
|
|
26
|
+
gap: var(--spacing-stack, var(--space-stack));
|
|
27
27
|
@media (width >= 40rem) {
|
|
28
28
|
flex-direction: row;
|
|
29
29
|
}
|
|
30
30
|
@media (width >= 40rem) {
|
|
31
|
-
gap: var(--spacing-
|
|
31
|
+
gap: var(--spacing-stack, var(--space-stack));
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
.rui-calendar__month-panel {
|
|
@@ -40,7 +40,7 @@ rui-calendar {
|
|
|
40
40
|
display: flex;
|
|
41
41
|
align-items: center;
|
|
42
42
|
justify-content: space-between;
|
|
43
|
-
gap: var(--spacing-
|
|
43
|
+
gap: var(--spacing-inline, var(--space-inline));
|
|
44
44
|
}
|
|
45
45
|
.rui-calendar__nav-spacer {
|
|
46
46
|
display: inline-flex;
|
|
@@ -199,8 +199,8 @@ rui-calendar {
|
|
|
199
199
|
border-style: var(--tw-border-style);
|
|
200
200
|
border-width: 0px;
|
|
201
201
|
background-color: transparent;
|
|
202
|
-
padding-inline: var(--spacing-
|
|
203
|
-
padding-block: var(--spacing-
|
|
202
|
+
padding-inline: var(--spacing-control-x, var(--space-control-x));
|
|
203
|
+
padding-block: var(--spacing-control-y, var(--space-control-y));
|
|
204
204
|
font-size: var(--text-sm, var(--text-sm));
|
|
205
205
|
line-height: var(--tw-leading, var(--text-sm--line-height, calc(1.25 / 0.875)));
|
|
206
206
|
color: var(--color-primary, var(--primary));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { JsxHtmlPropsWithChildren } from '@ecopages/jsx';
|
|
2
2
|
import type { RuiCalendarProps } from './calendar.script';
|
|
3
|
-
|
|
3
|
+
import './calendar.script';
|
|
4
|
+
export declare function RuiCalendar({ children, ...props }: JsxHtmlPropsWithChildren<RuiCalendarProps & {
|
|
4
5
|
slot?: string;
|
|
5
|
-
}
|
|
6
|
+
}>): import("@ecopages/jsx").JsxRenderable;
|
|
@@ -36,8 +36,40 @@ type MonthPanel = {
|
|
|
36
36
|
* - range: `YYYY-MM-DD/YYYY-MM-DD`
|
|
37
37
|
*
|
|
38
38
|
* @see https://react-aria.adobe.com/Calendar
|
|
39
|
+
*
|
|
39
40
|
* @element rui-calendar
|
|
40
|
-
*
|
|
41
|
+
*
|
|
42
|
+
* @attr {string} value - Selected date(s) in the mode-specific ISO format. Default: `''`.
|
|
43
|
+
* @attr {string} min - Earliest selectable ISO date. Default: `''`.
|
|
44
|
+
* @attr {string} max - Latest selectable ISO date. Default: `''`.
|
|
45
|
+
* @attr {boolean} disabled - Disable all date selection. Default: `false`.
|
|
46
|
+
* @attr {string} locale - BCP 47 locale tag, or comma-separated fallback list. Default: `''`.
|
|
47
|
+
* @attr {('single'|'multiple'|'range')} selection-mode - Selection mode. Default: `single`.
|
|
48
|
+
* @attr {number} visible-months - Month grids shown side by side. Default: `1`.
|
|
49
|
+
* @attr {('visible'|'single')} page-behavior - Whether paging moves by all visible months or one month. Default: `visible`.
|
|
50
|
+
*
|
|
51
|
+
* @fires rui-change - Emitted when the selection changes; detail carries `value`, plus `start` / `end` for ranges.
|
|
52
|
+
*
|
|
53
|
+
* @cssclass rui-calendar - Root surface (`role="application"`).
|
|
54
|
+
* @cssclass rui-calendar--multi - Multi-month root modifier.
|
|
55
|
+
* @cssclass rui-calendar__months - Row of month panels.
|
|
56
|
+
* @cssclass rui-calendar__month-panel - Single month grid column.
|
|
57
|
+
* @cssclass rui-calendar__header - Month title row with paging controls.
|
|
58
|
+
* @cssclass rui-calendar__nav - Prev / next month button.
|
|
59
|
+
* @cssclass rui-calendar__nav-spacer - Placeholder where a nav button is absent.
|
|
60
|
+
* @cssclass rui-calendar__month - Month title.
|
|
61
|
+
* @cssclass rui-calendar__weekdays - Weekday header row.
|
|
62
|
+
* @cssclass rui-calendar__weekday - Weekday label.
|
|
63
|
+
* @cssclass rui-calendar__grid - Month grid (`role="grid"`).
|
|
64
|
+
* @cssclass rui-calendar__week - Grid row.
|
|
65
|
+
* @cssclass rui-calendar__day - Day cell button (`role="gridcell"`).
|
|
66
|
+
* @cssclass rui-calendar__footer - Footer row with the today button.
|
|
67
|
+
* @cssclass rui-calendar__today - "Today" jump button.
|
|
68
|
+
*
|
|
69
|
+
* @remarks
|
|
70
|
+
* Arrow keys move the focused day, PageUp / PageDown page the months (Shift
|
|
71
|
+
* adds ±12), and Enter / Space select the focused day. Disabled or out-of-range
|
|
72
|
+
* days are skipped while navigating.
|
|
41
73
|
*/
|
|
42
74
|
export declare class RuiCalendar extends RadiantElement {
|
|
43
75
|
value: string;
|
|
@@ -65,6 +97,12 @@ export declare class RuiCalendar extends RadiantElement {
|
|
|
65
97
|
private moveMonth;
|
|
66
98
|
private getFlatDays;
|
|
67
99
|
private moveFocusedDay;
|
|
100
|
+
private isMonthVisible;
|
|
101
|
+
/** Moves roving focus without rebuilding a grid that already contains the target day. */
|
|
102
|
+
private focusDayInCurrentGrid;
|
|
103
|
+
/** Restores DOM focus after rebuilding the grid around a newly visible day. */
|
|
104
|
+
private focusFocusedDay;
|
|
105
|
+
private moveFocusedMonth;
|
|
68
106
|
private isIsoAllowed;
|
|
69
107
|
private emitChange;
|
|
70
108
|
private selectSingle;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as p,jsxs as me}from"@ecopages/jsx/jsx-runtime";import{RadiantElement as gt,customElement as Et,event as kt,onEvent as L,onUpdated as Tt,prop as S,state as A}from"@ecopages/radiant";function Ae(t){if(!t)return;let e=t.split(",").map(n=>n.trim()).filter(Boolean);return e.length>1?e:e[0]}function ne(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,o=Number(e[3]),a=new Date(n,r,o);return a.getFullYear()!==n||a.getMonth()!==r||a.getDate()!==o?null:a}function Y(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 re(t,e,n){return!(e&&t<e||n&&t>n)}function T(t,e){return t.localeCompare(e)}function C(t,e){return T(t,e)<=0?{start:t,end:e}:{start:e,end:t}}function F(t){if(!t)return null;let[e,n]=t.split("/");return!e||!n?null:C(e,n)}function ae(t){if(!t)return"";let e=C(t.start,t.end);return`${e.start}/${e.end}`}function z(t){return t?t.split(",").map(e=>e.trim()).filter(Boolean).sort(T):[]}function ie(t){return[...new Set(t)].sort(T).join(",")}function oe(t,e){let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),[...n].sort(T)}function Ee(t,e){let n=C(e.start,e.end);return T(t,n.start)>=0&&T(t,n.end)<=0}function se(t,e,n){if(e==="single"){let f=n.singleIso===t;return{isSelected:f,isRangeStart:f,isRangeEnd:f,isRangeMiddle:!1}}if(e==="multiple"){let f=n.multipleIsos?.includes(t)??!1;return{isSelected:f,isRangeStart:f,isRangeEnd:f,isRangeMiddle:!1}}let r=n.range;if(!r)return{isSelected:!1,isRangeStart:!1,isRangeEnd:!1,isRangeMiddle:!1};let o=C(r.start,r.end),a=Ee(t,o),i=t===o.start,c=t===o.end;return{isSelected:a,isRangeStart:i,isRangeEnd:c,isRangeMiddle:a&&!i&&!c}}function le(t,e,n){return e.anchor?{committed:C(e.anchor,n),draft:{anchor:null,hover:null}}:{committed:t,draft:{anchor:n,hover:n}}}function K(t){let e=_t(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 _t(t){return Array.isArray(t)?t[0]??navigator.language:t??navigator.language}function bt(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function Mt(t,e){return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function wt(t){let e=t.selectionMode??"single",n=t.value??"";if(e==="multiple")return{mode:e,multipleIsos:z(n)};if(e==="range"){let r=F(n);if(t.rangeDraft?.anchor){let o=t.rangeDraft.hover??t.rangeDraft.anchor;return{mode:e,range:Dt(t.rangeDraft.anchor,o)}}return{mode:e,range:r}}return{mode:e,singleIso:n||void 0}}function Dt(t,e){return t.localeCompare(e)<=0?{start:t,end:e}:{start:e,end:t}}function ce(t,e,n){let r=K(n.locale),o=bt(n.today??new Date),a=wt(n),c=(new Date(t,e,1).getDay()-r+7)%7,P=new Date(t,e,1-c),f=[],g=new Date(P);for(let E=0;E<6;E+=1){let D=[];for(let j=0;j<7;j+=1){let V=Y(g),x=se(V,a.mode,{singleIso:a.singleIso,multipleIsos:a.multipleIsos,range:a.range});D.push({date:new Date(g),iso:V,inMonth:g.getMonth()===e,isToday:Mt(g,o),isSelected:x.isSelected,isDisabled:!re(V,n.min,n.max),isRangeStart:x.isRangeStart,isRangeEnd:x.isRangeEnd,isRangeMiddle:x.isRangeMiddle}),g.setDate(g.getDate()+1)}if(f.push(D),E>=4&&g.getMonth()!==e&&g.getDate()>7)break}return f}function J(t,e,n){let r=new Date(t,e+n,1);return{year:r.getFullYear(),month:r.getMonth()}}function de(t,e,n){let r=Math.max(1,Math.min(n,12));return Array.from({length:r},(o,a)=>{let i=J(t,e,a);return{year:i.year,month:i.month,offset:a}})}var ke=new Map;function xt(t,e){return`${JSON.stringify(t??null)}|${JSON.stringify(e)}`}function ue(t,e){let n=xt(t,e),r=ke.get(n);if(r)return r;let o=new Intl.DateTimeFormat(t,e);return ke.set(n,o),o}function he(t,e){return ue(e,{month:"long",year:"numeric"}).format(t)}function fe(t,e){let n=ue(t,{weekday:"narrow"}),r=[];for(let o=0;o<7;o+=1){let a=(e+o)%7,i=new Date(2024,0,a===0?7:a);r.push(n.format(i))}return r}function ge(t){return new Intl.RelativeTimeFormat(t,{numeric:"auto"}).format(0,"day")}var Te,Le,Pe,Ve,Oe,Ye,Ce,Fe,ze,je,Ge,$e,Be,Ue,He,We,Ne,Ke,Je,qe,Xe,Qe,Ze,et,tt,nt,rt,at,it,ot,st,lt,ct,dt,ut,ht;function Rt(t,e,n,r,o,a){var i,c,P,f,g,E,D,j=Symbol.metadata||Symbol.for("Symbol.metadata"),V=Object.defineProperty,x=Object.create,pe=[x(null),x(null)],ve=e.length;function B(s,_,v){return function(l,d){_&&(d=l,l=t);for(var b=0;b<s.length;b++)d=s[b].apply(l,v?[d]:[]);return v?d:l}}function R(s,_,v,l){if(typeof s!="function"&&(l||s!==void 0))throw new TypeError(_+" must "+(v||"be")+" a function"+(l?"":" or undefined"));return s}function ye(s,_,v,l,d,b,k,y,M,w,be){function X(h){if(!be(h))throw new TypeError("Attempted to access private element on non-instance")}var Q=[].concat(_[0]),Me=_[3],Z=!k,G=d===1,we=d===3,De=d===4,U=d===2;function H(h,O,Ie){return function(N,Se){return O&&(Se=N,N=s),Ie&&Ie(N),u[h].call(N,Se)}}if(!Z){var u={},ee=[],I=we?"get":De||G?"set":"value";if(M?(w||G?u={get:ft(function(){return Me(this)},l,"get"),set:function(h){_[4](this,h)}}:u[I]=Me,w||ft(u[I],l,U?"":I)):w||(u=Object.getOwnPropertyDescriptor(s,l)),!w&&!M){if((c=pe[+y][l])&&(c^d)!==7)throw Error("Decorating two elements with the same name ("+u[I].name+") is not supported yet");pe[+y][l]=d<3?1:d}}for(var m=s,W=Q.length-1;W>=0;W-=v?2:1){var xe=R(Q[W],"A decorator","be",!0),Re=v?Q[W-1]:void 0,te={},$={kind:["field","accessor","method","getter","setter","class"][d],name:l,metadata:i,addInitializer:function(h,O){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");R(O,"An initializer","be",!0),b.push(O)}.bind(null,te)};if(Z)c=xe.call(Re,m,$),te.v=1,R(c,"class decorators","return")&&(m=c);else if($.static=y,$.private=M,c=$.access={has:M?be.bind():function(h){return l in h}},De||(c.get=M?U?function(h){return X(h),u.value}:H("get",0,X):function(h){return h[l]}),U||we||(c.set=M?H("set",0,X):function(h,O){h[l]=O}),m=xe.call(Re,G?{get:u.get,set:u.set}:u[I],$),te.v=1,G){if(typeof m=="object"&&m)(c=R(m.get,"accessor.get"))&&(u.get=c),(c=R(m.set,"accessor.set"))&&(u.set=c),(c=R(m.init,"accessor.init"))&&ee.unshift(c);else if(m!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else R(m,(w?"field":"method")+" decorators","return")&&(w?ee.unshift(m):u[I]=m)}return d<2&&k.push(B(ee,y,1),B(b,y,0)),w||Z||(M?G?k.splice(-1,0,H("get",y),H("set",y)):k.push(U?u[I]:R.call.bind(u[I])):V(s,l,u)),m}function _e(s){return V(s,j,{configurable:!0,enumerable:!0,value:i})}return a!==void 0&&(i=a[j]),i=x(i??null),g=[],E=function(s){s&&g.push(B(s))},D=function(s,_){for(var v=0;v<n.length;v++){var l=n[v],d=l[1],b=7&d;if((8&d)==s&&!b==_){var k=l[2],y=!!l[3],M=16&d;ye(s?t:t.prototype,l,M,y?"#"+k:It(k),b,b<2?[]:s?f=f||[]:P=P||[],g,!!s,y,_,s&&y?function(w){return At(w)===t}:o)}}},D(8,0),D(0,0),D(8,1),D(0,1),E(P),E(f),c=g,ve||_e(t),{e:c,get c(){var s=[];return ve&&[_e(t=ye(t,[e],r,t.name,5,s)),B(s,1)]}}}function It(t){var e=St(t,"string");return typeof e=="symbol"?e:e+""}function St(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 ft(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 At(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 q,mt=class extends gt{static{({e:[Pe,Ve,Oe,Ye,Ce,Fe,ze,je,Ge,$e,Be,Ue,He,We,Ne,Ke,Je,qe,Xe,Qe,Ze,et,tt,nt,rt,at,it,ot,st,lt,ct,dt,ut,ht,Te],c:[q,Le]}=Rt(this,[Et("rui-calendar")],[[S({type:String,reflect:!0,defaultValue:""}),0,"value"],[S({type:String,defaultValue:""}),0,"min"],[S({type:String,defaultValue:""}),0,"max"],[S({type:Boolean,reflect:!0,defaultValue:!1}),0,"disabled"],[S({type:String,defaultValue:""}),0,"locale"],[S({type:String,attribute:"selection-mode",defaultValue:"single"}),0,"selectionMode"],[S({type:Number,attribute:"visible-months",defaultValue:1}),0,"visibleMonths"],[S({type:String,attribute:"page-behavior",defaultValue:"visible"}),0,"pageBehavior"],[kt({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[A,0,"viewYear"],[A,0,"viewMonth"],[A,0,"focusedIso"],[A,0,"weekdayLabels"],[A,0,"monthPanels"],[A,0,"todayLabel"],[A,0,"rangeAnchor"],[A,0,"rangeHover"],[Tt(["value","min","max","disabled","locale","selectionMode","visibleMonths","pageBehavior"]),2,"onPropsUpdated"],[L({selector:"[data-calendar-prev-month]",type:"click"}),2,"onPrevMonth"],[L({selector:"[data-calendar-next-month]",type:"click"}),2,"onNextMonth"],[L({selector:"[data-calendar-today]",type:"click"}),2,"onTodayClick"],[L({selector:"[data-calendar-day]",type:"click"}),2,"onDayClick"],[L({selector:"[data-calendar-day]",type:"pointerenter"}),2,"onDayPointerEnter"],[L({selector:"[data-calendar-grid]",type:"pointerleave"}),2,"onGridPointerLeave"],[L({selector:"[data-calendar-day]",type:"keydown"}),2,"onDayKeydown"]],0,void 0,gt))}constructor(...e){super(...e),ht(this)}value=(Te(this),Pe(this));min=(Ve(this),Oe(this));max=(Ye(this),Ce(this));disabled=(Fe(this),ze(this));locale=(je(this),Ge(this));selectionMode=($e(this),Be(this));visibleMonths=(Ue(this),He(this));pageBehavior=(We(this),Ne(this));changeEvent=(Ke(this),Je(this));viewYear=(qe(this),Xe(this,new Date().getFullYear()));viewMonth=(Qe(this),Ze(this,new Date().getMonth()));focusedIso=(et(this),tt(this,""));weekdayLabels=(nt(this),rt(this,[]));monthPanels=(at(this),it(this,[]));todayLabel=(ot(this),st(this,""));rangeAnchor=(lt(this),ct(this,null));rangeHover=(dt(this),ut(this,null));get resolvedLocale(){return Ae(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"?F(this.value)?.start??"":this.selectionMode==="multiple"?z(this.value)[0]??"":this.value,n=ne(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=Y(r)}refreshGrid(){this.weekdayLabels=fe(this.resolvedLocale,K(this.resolvedLocale)),this.monthPanels=de(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:he(n,this.resolvedLocale),weeks:ce(e.year,e.month,this.monthOptions)}}),this.todayLabel=ge(this.resolvedLocale)}moveMonth(e){let n=J(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(i=>!i.isDisabled);if(!n.length)return;let r=n.findIndex(i=>i.iso===this.focusedIso),o=r<0?Math.max(0,n.findIndex(i=>i.inMonth)):(r+e+n.length)%n.length,a=n[o];a&&((a.date.getMonth()!==this.viewMonth||a.date.getFullYear()!==this.viewYear)&&(this.viewYear=a.date.getFullYear(),this.viewMonth=a.date.getMonth()),this.focusedIso=a.iso,this.refreshGrid())}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=ie(oe(z(this.value),e));n!==this.value&&(this.value=n,this.emitChange(n),this.refreshGrid())}selectRange(e){if(!this.isIsoAllowed(e))return;let n=le(F(this.value),{anchor:this.rangeAnchor,hover:this.rangeHover},e);if(this.rangeAnchor=n.draft.anchor,this.rangeHover=n.draft.hover,n.committed){let r=ae(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()}connectedCallback(){super.connectedCallback(),queueMicrotask(()=>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(Y(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){if(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.moveMonth(e.shiftKey?-12:-this.pageDelta);return}if(e.key==="PageDown"){e.preventDefault(),this.moveMonth(e.shiftKey?12:this.pageDelta);return}if(e.key==="Enter"||e.key===" "){e.preventDefault();let n=e.target,r=n.getAttribute("data-iso");r&&!n.disabled&&this.selectIso(r)}}}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 me("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:[p("div",{class:"rui-calendar__months",children:this.monthPanels.map((r,o)=>me("div",{class:"rui-calendar__month-panel","data-calendar-month-panel":!0,children:[me("div",{class:"rui-calendar__header",children:[o===0?p("button",{type:"button",class:"rui-calendar__nav","data-calendar-prev-month":!0,"aria-label":"Previous month",disabled:this.disabled,children:"\u2039"}):p("span",{class:"rui-calendar__nav-spacer","aria-hidden":"true"}),p("div",{class:"rui-calendar__month","aria-live":"polite",children:r.label}),o===e-1?p("button",{type:"button",class:"rui-calendar__nav","data-calendar-next-month":!0,"aria-label":"Next month",disabled:this.disabled,children:"\u203A"}):p("span",{class:"rui-calendar__nav-spacer","aria-hidden":"true"})]}),o===0?p("div",{class:"rui-calendar__weekdays",role:"row",children:this.weekdayLabels.map(a=>p("div",{class:"rui-calendar__weekday",role:"columnheader","aria-hidden":"true",children:a}))}):null,p("div",{class:"rui-calendar__grid",role:"grid","data-calendar-grid":!0,children:r.weeks.map(a=>p("div",{class:"rui-calendar__week",role:"row",children:a.map(i=>p("button",{type:"button",class:"rui-calendar__day","data-calendar-day":!0,"data-iso":i.iso,role:"gridcell",disabled:this.disabled||i.isDisabled,tabIndex:i.iso===this.focusedIso?0:-1,"aria-selected":i.isSelected?"true":"false","aria-current":i.isToday?"date":void 0,"data-outside":i.inMonth?void 0:"true",...this.dayDataAttributes(i),children:i.date.getDate()}))}))})]}))}),p("div",{class:"rui-calendar__footer",children:p("button",{type:"button",class:"rui-calendar__today","data-calendar-today":!0,disabled:this.disabled,children:this.todayLabel})})]})}static{Le()}};import{jsx as Vt}from"@ecopages/jsx/jsx-runtime";var Lt=Symbol.for("@ecopages/storybook-radiant.viewElement"),pt=Symbol.for("@ecopages/storybook-radiant.scriptModule"),vt=Symbol.for("@ecopages/storybook-radiant.scriptExport");function Pt(t,e){t[Lt]=e;let n=e[pt];n&&(t[pt]=n,t[vt]=e[vt]??e.name)}function yt(t,e,n){let r=o=>e(o);return Pt(r,t),r}var Ot=yt(q,({children:t,...e})=>Vt("rui-calendar",{...e,children:t}),{stylesheets:["./calendar.css"]});export{Ot as RuiCalendar,q as RuiCalendarElement};
|
|
1
|
+
import{jsx as p,jsxs as ge}from"@ecopages/jsx/jsx-runtime";import{RadiantElement as ft,customElement as Rt,event as St,onEvent as F,onUpdated as At,prop as S,state as A}from"@ecopages/radiant";function Se(t){if(!t)return;let e=t.split(",").map(n=>n.trim()).filter(Boolean);return e.length>1?e:e[0]}function q(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,a=Number(e[3]),i=new Date(n,r,a);return i.getFullYear()!==n||i.getMonth()!==r||i.getDate()!==a?null:i}function L(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 ne(t,e,n){return!(e&&t<e||n&&t>n)}function T(t,e){return t.localeCompare(e)}function O(t,e){return T(t,e)<=0?{start:t,end:e}:{start:e,end:t}}function C(t){if(!t)return null;let[e,n]=t.split("/");return!e||!n?null:O(e,n)}function re(t){if(!t)return"";let e=O(t.start,t.end);return`${e.start}/${e.end}`}function G(t){return t?t.split(",").map(e=>e.trim()).filter(Boolean).sort(T):[]}function ae(t){return[...new Set(t)].sort(T).join(",")}function ie(t,e){let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),[...n].sort(T)}function Ae(t,e){let n=O(e.start,e.end);return T(t,n.start)>=0&&T(t,n.end)<=0}function oe(t,e,n){if(e==="single"){let f=n.singleIso===t;return{isSelected:f,isRangeStart:f,isRangeEnd:f,isRangeMiddle:!1}}if(e==="multiple"){let f=n.multipleIsos?.includes(t)??!1;return{isSelected:f,isRangeStart:f,isRangeEnd:f,isRangeMiddle:!1}}let r=n.range;if(!r)return{isSelected:!1,isRangeStart:!1,isRangeEnd:!1,isRangeMiddle:!1};let a=O(r.start,r.end),i=Ae(t,a),o=t===a.start,c=t===a.end;return{isSelected:i,isRangeStart:o,isRangeEnd:c,isRangeMiddle:i&&!o&&!c}}function se(t,e,n){return e.anchor?{committed:O(e.anchor,n),draft:{anchor:null,hover:null}}:{committed:t,draft:{anchor:n,hover:n}}}function J(t){let e=pt(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 pt(t){return Array.isArray(t)?t[0]??navigator.language:t??navigator.language}function vt(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function yt(t,e){return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function bt(t){let e=t.selectionMode??"single",n=t.value??"";if(e==="multiple")return{mode:e,multipleIsos:G(n)};if(e==="range"){let r=C(n);if(t.rangeDraft?.anchor){let a=t.rangeDraft.hover??t.rangeDraft.anchor;return{mode:e,range:_t(t.rangeDraft.anchor,a)}}return{mode:e,range:r}}return{mode:e,singleIso:n||void 0}}function _t(t,e){return t.localeCompare(e)<=0?{start:t,end:e}:{start:e,end:t}}function le(t,e,n){let r=J(n.locale),a=vt(n.today??new Date),i=bt(n),c=(new Date(t,e,1).getDay()-r+7)%7,Y=new Date(t,e,1-c),f=[],g=new Date(Y);for(let k=0;k<6;k+=1){let D=[];for(let z=0;z<7;z+=1){let P=L(g),x=oe(P,i.mode,{singleIso:i.singleIso,multipleIsos:i.multipleIsos,range:i.range});D.push({date:new Date(g),iso:P,inMonth:g.getMonth()===e,isToday:yt(g,a),isSelected:x.isSelected,isDisabled:!ne(P,n.min,n.max),isRangeStart:x.isRangeStart,isRangeEnd:x.isRangeEnd,isRangeMiddle:x.isRangeMiddle}),g.setDate(g.getDate()+1)}if(f.push(D),k>=4&&g.getMonth()!==e&&g.getDate()>7)break}return f}function N(t,e,n){let r=new Date(t,e+n,1);return{year:r.getFullYear(),month:r.getMonth()}}function ce(t,e,n){let r=Math.max(1,Math.min(n,12));return Array.from({length:r},(a,i)=>{let o=N(t,e,i);return{year:o.year,month:o.month,offset:i}})}var ke=new Map;function Mt(t,e){return`${JSON.stringify(t??null)}|${JSON.stringify(e)}`}function ue(t,e){let n=Mt(t,e),r=ke.get(n);if(r)return r;let a=new Intl.DateTimeFormat(t,e);return ke.set(n,a),a}function de(t,e){return ue(e,{month:"long",year:"numeric"}).format(t)}function he(t,e){let n=ue(t,{weekday:"narrow"}),r=[];for(let a=0;a<7;a+=1){let i=(e+a)%7,o=new Date(2024,0,i===0?7:i);r.push(n.format(o))}return r}function fe(t){return new Intl.RelativeTimeFormat(t,{numeric:"auto"}).format(0,"day")}var Ee,Le,Te,Fe,Ye,Pe,Ve,Oe,Ce,Ge,ze,je,$e,Be,He,Ue,We,Ke,qe,Je,Ne,Qe,Xe,Ze,et,tt,nt,rt,at,it,ot,st,lt,ct,ut,dt;function wt(t,e,n,r,a,i){var o,c,Y,f,g,k,D,z=Symbol.metadata||Symbol.for("Symbol.metadata"),P=Object.defineProperty,x=Object.create,me=[x(null),x(null)],pe=e.length;function B(s,b,v){return function(l,u){b&&(u=l,l=t);for(var _=0;_<s.length;_++)u=s[_].apply(l,v?[u]:[]);return v?u:l}}function I(s,b,v,l){if(typeof s!="function"&&(l||s!==void 0))throw new TypeError(b+" must "+(v||"be")+" a function"+(l?"":" or undefined"));return s}function ve(s,b,v,l,u,_,E,y,M,w,be){function Q(h){if(!be(h))throw new TypeError("Attempted to access private element on non-instance")}var X=[].concat(b[0]),_e=b[3],Z=!E,j=u===1,Me=u===3,we=u===4,H=u===2;function U(h,V,Ie){return function(K,Re){return V&&(Re=K,K=s),Ie&&Ie(K),d[h].call(K,Re)}}if(!Z){var d={},ee=[],R=Me?"get":we||j?"set":"value";if(M?(w||j?d={get:ht(function(){return _e(this)},l,"get"),set:function(h){b[4](this,h)}}:d[R]=_e,w||ht(d[R],l,H?"":R)):w||(d=Object.getOwnPropertyDescriptor(s,l)),!w&&!M){if((c=me[+y][l])&&(c^u)!==7)throw Error("Decorating two elements with the same name ("+d[R].name+") is not supported yet");me[+y][l]=u<3?1:u}}for(var m=s,W=X.length-1;W>=0;W-=v?2:1){var De=I(X[W],"A decorator","be",!0),xe=v?X[W-1]:void 0,te={},$={kind:["field","accessor","method","getter","setter","class"][u],name:l,metadata:o,addInitializer:function(h,V){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");I(V,"An initializer","be",!0),_.push(V)}.bind(null,te)};if(Z)c=De.call(xe,m,$),te.v=1,I(c,"class decorators","return")&&(m=c);else if($.static=y,$.private=M,c=$.access={has:M?be.bind():function(h){return l in h}},we||(c.get=M?H?function(h){return Q(h),d.value}:U("get",0,Q):function(h){return h[l]}),H||Me||(c.set=M?U("set",0,Q):function(h,V){h[l]=V}),m=De.call(xe,j?{get:d.get,set:d.set}:d[R],$),te.v=1,j){if(typeof m=="object"&&m)(c=I(m.get,"accessor.get"))&&(d.get=c),(c=I(m.set,"accessor.set"))&&(d.set=c),(c=I(m.init,"accessor.init"))&&ee.unshift(c);else if(m!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else I(m,(w?"field":"method")+" decorators","return")&&(w?ee.unshift(m):d[R]=m)}return u<2&&E.push(B(ee,y,1),B(_,y,0)),w||Z||(M?j?E.splice(-1,0,U("get",y),U("set",y)):E.push(H?d[R]:I.call.bind(d[R])):P(s,l,d)),m}function ye(s){return P(s,z,{configurable:!0,enumerable:!0,value:o})}return i!==void 0&&(o=i[z]),o=x(o??null),g=[],k=function(s){s&&g.push(B(s))},D=function(s,b){for(var v=0;v<n.length;v++){var l=n[v],u=l[1],_=7&u;if((8&u)==s&&!_==b){var E=l[2],y=!!l[3],M=16&u;ve(s?t:t.prototype,l,M,y?"#"+E:Dt(E),_,_<2?[]:s?f=f||[]:Y=Y||[],g,!!s,y,b,s&&y?function(w){return It(w)===t}:a)}}},D(8,0),D(0,0),D(8,1),D(0,1),k(Y),k(f),c=g,pe||ye(t),{e:c,get c(){var s=[];return pe&&[ye(t=ve(t,[e],r,t.name,5,s)),B(s,1)]}}}function Dt(t){var e=xt(t,"string");return typeof e=="symbol"?e:e+""}function xt(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 ht(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 It(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 mt,gt=class extends ft{static{({e:[Te,Fe,Ye,Pe,Ve,Oe,Ce,Ge,ze,je,$e,Be,He,Ue,We,Ke,qe,Je,Ne,Qe,Xe,Ze,et,tt,nt,rt,at,it,ot,st,lt,ct,ut,dt,Ee],c:[mt,Le]}=wt(this,[Rt("rui-calendar")],[[S({type:String,reflect:!0,defaultValue:""}),0,"value"],[S({type:String,defaultValue:""}),0,"min"],[S({type:String,defaultValue:""}),0,"max"],[S({type:Boolean,reflect:!0,defaultValue:!1}),0,"disabled"],[S({type:String,defaultValue:""}),0,"locale"],[S({type:String,attribute:"selection-mode",defaultValue:"single"}),0,"selectionMode"],[S({type:Number,attribute:"visible-months",defaultValue:1}),0,"visibleMonths"],[S({type:String,attribute:"page-behavior",defaultValue:"visible"}),0,"pageBehavior"],[St({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[A,0,"viewYear"],[A,0,"viewMonth"],[A,0,"focusedIso"],[A,0,"weekdayLabels"],[A,0,"monthPanels"],[A,0,"todayLabel"],[A,0,"rangeAnchor"],[A,0,"rangeHover"],[At(["value","min","max","disabled","locale","selectionMode","visibleMonths","pageBehavior"]),2,"onPropsUpdated"],[F({selector:"[data-calendar-prev-month]",type:"click"}),2,"onPrevMonth"],[F({selector:"[data-calendar-next-month]",type:"click"}),2,"onNextMonth"],[F({selector:"[data-calendar-today]",type:"click"}),2,"onTodayClick"],[F({selector:"[data-calendar-day]",type:"click"}),2,"onDayClick"],[F({selector:"[data-calendar-day]",type:"pointerenter"}),2,"onDayPointerEnter"],[F({selector:"[data-calendar-grid]",type:"pointerleave"}),2,"onGridPointerLeave"],[F({selector:"[data-calendar-day]",type:"keydown"}),2,"onDayKeydown"]],0,void 0,ft))}constructor(...e){super(...e),dt(this)}value=(Ee(this),Te(this));min=(Fe(this),Ye(this));max=(Pe(this),Ve(this));disabled=(Oe(this),Ce(this));locale=(Ge(this),ze(this));selectionMode=(je(this),$e(this));visibleMonths=(Be(this),He(this));pageBehavior=(Ue(this),We(this));changeEvent=(Ke(this),qe(this));viewYear=(Je(this),Ne(this,new Date().getFullYear()));viewMonth=(Qe(this),Xe(this,new Date().getMonth()));focusedIso=(Ze(this),et(this,""));weekdayLabels=(tt(this),nt(this,[]));monthPanels=(rt(this),at(this,[]));todayLabel=(it(this),ot(this,""));rangeAnchor=(st(this),lt(this,null));rangeHover=(ct(this),ut(this,null));get resolvedLocale(){return Se(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"?C(this.value)?.start??"":this.selectionMode==="multiple"?G(this.value)[0]??"":this.value,n=q(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=L(r)}refreshGrid(){this.weekdayLabels=he(this.resolvedLocale,J(this.resolvedLocale)),this.monthPanels=ce(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:de(n,this.resolvedLocale),weeks:le(e.year,e.month,this.monthOptions)}}),this.todayLabel=fe(this.resolvedLocale)}moveMonth(e){let n=N(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(o=>!o.isDisabled);if(!n.length)return;let r=n.findIndex(o=>o.iso===this.focusedIso),a=r<0?Math.max(0,n.findIndex(o=>o.inMonth)):(r+e+n.length)%n.length,i=n[a];if(i){if(!this.isMonthVisible(i.date)){this.viewYear=i.date.getFullYear(),this.viewMonth=i.date.getMonth(),this.focusedIso=i.iso,this.refreshGrid(),this.focusFocusedDay();return}this.focusedIso=i.iso,this.focusDayInCurrentGrid(i.iso)}}isMonthVisible(e){let n=this.viewYear*12+this.viewMonth,r=n+this.visibleMonths-1,a=e.getFullYear()*12+e.getMonth();return a>=n&&a<=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)`)),a=r.find(i=>!i.hasAttribute("data-outside"))??r[0];a&&(n&&n!==a&&(n.tabIndex=-1),a.tabIndex=0,a.focus())}focusFocusedDay(){requestAnimationFrame(()=>{this.focusDayInCurrentGrid(this.focusedIso)})}moveFocusedMonth(e){let n=q(this.focusedIso)??new Date(this.viewYear,this.viewMonth,1),r=new Date(n.getFullYear(),n.getMonth()+e,1),a=new Date(r.getFullYear(),r.getMonth()+1,0).getDate(),i=new Date(r.getFullYear(),r.getMonth(),Math.min(n.getDate(),a));this.viewYear=i.getFullYear(),this.viewMonth=i.getMonth(),this.focusedIso=L(i),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=ae(ie(G(this.value),e));n!==this.value&&(this.value=n,this.emitChange(n),this.refreshGrid())}selectRange(e){if(!this.isIsoAllowed(e))return;let n=se(C(this.value),{anchor:this.rangeAnchor,hover:this.rangeHover},e);if(this.rangeAnchor=n.draft.anchor,this.rangeHover=n.draft.hover,n.committed){let r=re(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()}connectedCallback(){super.connectedCallback(),queueMicrotask(()=>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(L(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,a=r.getAttribute("data-iso");a&&!r.disabled&&this.selectIso(a)}}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 ge("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:[p("div",{class:"rui-calendar__months",children:this.monthPanels.map((r,a)=>ge("div",{class:"rui-calendar__month-panel","data-calendar-month-panel":!0,children:[ge("div",{class:"rui-calendar__header",children:[a===0?p("button",{type:"button",class:"rui-calendar__nav","data-calendar-prev-month":!0,"aria-label":"Previous month",disabled:this.disabled,children:"\u2039"}):p("span",{class:"rui-calendar__nav-spacer","aria-hidden":"true"}),p("div",{class:"rui-calendar__month","aria-live":"polite",children:r.label}),a===e-1?p("button",{type:"button",class:"rui-calendar__nav","data-calendar-next-month":!0,"aria-label":"Next month",disabled:this.disabled,children:"\u203A"}):p("span",{class:"rui-calendar__nav-spacer","aria-hidden":"true"})]}),a===0?p("div",{class:"rui-calendar__weekdays",role:"row",children:this.weekdayLabels.map(i=>p("div",{class:"rui-calendar__weekday",role:"columnheader","aria-hidden":"true",children:i}))}):null,p("div",{class:"rui-calendar__grid",role:"grid","data-calendar-grid":!0,children:r.weeks.map(i=>p("div",{class:"rui-calendar__week",role:"row",children:i.map(o=>p("button",{type:"button",class:"rui-calendar__day","data-calendar-day":!0,"data-iso":o.iso,role:"gridcell",disabled:this.disabled||o.isDisabled,tabIndex:o.iso===this.focusedIso?0:-1,"aria-selected":o.isSelected?"true":"false","aria-current":o.isToday?"date":void 0,"data-outside":o.inMonth?void 0:"true",...this.dayDataAttributes(o),children:o.date.getDate()}))}))})]}))}),p("div",{class:"rui-calendar__footer",children:p("button",{type:"button",class:"rui-calendar__today","data-calendar-today":!0,disabled:this.disabled,children:this.todayLabel})})]})}static{Le()}};import{jsx as kt}from"@ecopages/jsx/jsx-runtime";function Et({children:t,...e}){return kt("rui-calendar",{...e,children:t})}export{Et as RuiCalendar,mt as RuiCalendarElement};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|