@astryx-vue/core 0.1.0 → 0.1.3
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/AppShell/index.d.ts +2 -0
- package/dist/AppShell/index.js +2 -0
- package/dist/AppShell-b0PWt9Fz.js +249 -0
- package/dist/AspectRatio/index.d.ts +2 -0
- package/dist/AspectRatio/index.js +2 -0
- package/dist/AspectRatio-Bij7e-tq.js +40 -0
- package/dist/AvatarGroup/index.d.ts +1 -1
- package/dist/Banner/index.d.ts +1 -1
- package/dist/BottomSheet/index.d.ts +1 -1
- package/dist/Button/index.d.ts +1 -1
- package/dist/ButtonGroup/index.d.ts +1 -1
- package/dist/Calendar/index.js +1 -1
- package/dist/{Calendar-DpYFXwgb.js → Calendar-CYhGDT6f.js} +2 -1
- package/dist/Chat/index.js +1 -1
- package/dist/{Chat-Bfd-YPAK.js → Chat-C1aWl5V3.js} +2 -2
- package/dist/CheckboxInput/index.d.ts +1 -1
- package/dist/CheckboxInput/index.js +1 -1
- package/dist/{CheckboxInput-C86o3XoG.js → CheckboxInput-CMsEE1_4.js} +4 -2
- package/dist/CheckboxList/index.d.ts +2 -0
- package/dist/CheckboxList/index.js +2 -0
- package/dist/CheckboxList-EsIEXjK_.js +174 -0
- package/dist/Citation/index.js +1 -1
- package/dist/{Citation-DaDd1teb.js → Citation-C1X0Rde8.js} +2 -2
- package/dist/ClickableCard/index.d.ts +2 -0
- package/dist/ClickableCard/index.js +2 -0
- package/dist/ClickableCard-Bhds4RRe.js +112 -0
- package/dist/Code/index.js +1 -1
- package/dist/{CodeBlock-CK-NWM_1.js → CodeBlock-BQdooQy2.js} +1 -1
- package/dist/Collapsible/index.d.ts +2 -2
- package/dist/Collapsible/index.js +2 -2
- package/dist/Collapsible-BS9ctCQV.js +192 -0
- package/dist/CommandPalette/index.d.ts +2 -0
- package/dist/CommandPalette/index.js +2 -0
- package/dist/CommandPalette-u5h_E05P.js +489 -0
- package/dist/ComplexSelector/index.d.ts +2 -0
- package/dist/ComplexSelector/index.js +2 -0
- package/dist/ComplexSelector-BHmGWml0.js +293 -0
- package/dist/ContextMenu/index.d.ts +1 -1
- package/dist/ContextMenu/index.js +1 -1
- package/dist/{ContextMenu-BJh99Exj.js → ContextMenu-dA-ppaRQ.js} +284 -12
- package/dist/DateInput/index.d.ts +1 -1
- package/dist/DateInput/index.js +1 -1
- package/dist/{DateInput-zJAdXByM.js → DateInput-D2ErjXYO.js} +18 -10
- package/dist/DateRangeInput/index.d.ts +2 -0
- package/dist/DateRangeInput/index.js +2 -0
- package/dist/DateRangeInput-fmQlr_A7.js +385 -0
- package/dist/DateTimeInput/index.d.ts +2 -0
- package/dist/DateTimeInput/index.js +2 -0
- package/dist/DateTimeInput-Bs1JmcIp.js +196 -0
- package/dist/Divider/index.d.ts +1 -1
- package/dist/DropdownMenu/index.d.ts +1 -1
- package/dist/DropdownMenu/index.js +1 -1
- package/dist/{DropdownMenu-C3j2zaEn.js → DropdownMenu-B0gogrvG.js} +2 -2
- package/dist/Field/index.d.ts +2 -2
- package/dist/Field/index.js +3 -4
- package/dist/{Field-VlTBsIEo.js → Field-8zRxzDHE.js} +11 -3
- package/dist/{FieldLabel-B1NRyQlS.js → FieldLabel-DmmJyX7w.js} +6 -1
- package/dist/FieldStatus/index.d.ts +2 -0
- package/dist/FieldStatus/index.js +2 -0
- package/dist/FileInput/index.d.ts +2 -0
- package/dist/FileInput/index.js +2 -0
- package/dist/FileInput-CmAfOpkA.js +238 -0
- package/dist/FormLayout/index.d.ts +2 -0
- package/dist/FormLayout/index.js +2 -0
- package/dist/FormLayout-D47FjiOq.js +40 -0
- package/dist/HoverCard/index.d.ts +1 -1
- package/dist/{Icon-B6qNgBP9.js → Icon-5MdZQ18k.js} +10 -2
- package/dist/Layout/index.d.ts +2 -0
- package/dist/Layout/index.js +3 -0
- package/dist/Layout-Bed3kP0M.js +56 -0
- package/dist/LayoutPanel-C34uOq3e.js +358 -0
- package/dist/List/index.d.ts +1 -1
- package/dist/Markdown/index.d.ts +1 -1
- package/dist/Markdown/index.js +1 -1
- package/dist/{Markdown-DyKIwAL_.js → Markdown-CwtLr3f_.js} +2 -2
- package/dist/MetadataList/index.d.ts +2 -0
- package/dist/MetadataList/index.js +2 -0
- package/dist/MetadataList-DlXQTLog.js +124 -0
- package/dist/MobileNav/index.d.ts +1 -1
- package/dist/MobileNav/index.js +1 -1
- package/dist/{MobileNavToggle-BK2iRJF-.js → MobileNavToggle-CgQamG6E.js} +19 -12
- package/dist/MoreMenu/index.d.ts +1 -1
- package/dist/MoreMenu/index.js +1 -1
- package/dist/{MoreMenu-BjUsVWWk.js → MoreMenu-BXL6Dqsu.js} +2 -2
- package/dist/MultiSelector/index.d.ts +1 -1
- package/dist/MultiSelector/index.js +1 -1
- package/dist/{MultiSelector-CKTbTj1A.js → MultiSelector-DT8ZccMI.js} +3 -3
- package/dist/NavItem/index.d.ts +1 -1
- package/dist/NavMenu/index.d.ts +1 -1
- package/dist/NumberInput/index.d.ts +1 -1
- package/dist/NumberInput/index.js +1 -1
- package/dist/{NumberInput-DU3_rw7z.js → NumberInput-DspJO6z6.js} +1 -1
- package/dist/OverflowList/index.d.ts +1 -1
- package/dist/OverflowList/index.js +1 -1
- package/dist/{OverflowList-B2T5UtiQ.js → OverflowList-zXg3g6fy.js} +1 -1
- package/dist/Overlay/index.d.ts +1 -1
- package/dist/Pagination/index.js +1 -1
- package/dist/{Pagination-qCgNwwhr.js → Pagination-DXfgMUKJ.js} +2 -2
- package/dist/Popover/index.d.ts +2 -1
- package/dist/Radio/index.d.ts +2 -2
- package/dist/Radio/index.js +2 -2
- package/dist/{Radio-BioQfwHQ.js → RadioGroup-BqjdSCfJ.js} +21 -88
- package/dist/RadioList/index.d.ts +2 -0
- package/dist/RadioList/index.js +2 -0
- package/dist/RadioList-DI8ujXcT.js +122 -0
- package/dist/Resizable/index.d.ts +2 -0
- package/dist/Resizable/index.js +2 -0
- package/dist/Resizable-BuGKvU9I.js +261 -0
- package/dist/ScrollableArea/index.d.ts +2 -0
- package/dist/ScrollableArea/index.js +2 -0
- package/dist/ScrollableArea-DQDYjnxO.js +78 -0
- package/dist/Section/index.d.ts +2 -0
- package/dist/Section/index.js +2 -0
- package/dist/Section-C48Wqfc7.js +68 -0
- package/dist/SegmentedControl/index.d.ts +1 -1
- package/dist/SelectableCard/index.d.ts +2 -0
- package/dist/SelectableCard/index.js +2 -0
- package/dist/SelectableCard-Bj5s_tIN.js +108 -0
- package/dist/Selector/index.d.ts +1 -1
- package/dist/Selector/index.js +1 -1
- package/dist/{Selector-C6sPJMtH.js → Selector-DlZpQh42.js} +1 -1
- package/dist/SideNav/index.d.ts +1 -1
- package/dist/SideNav/index.js +2 -1
- package/dist/{SideNav-D9lnn-sM.js → SideNav-Cdrigq2A.js} +49 -27
- package/dist/Slider/index.js +1 -1
- package/dist/{Slider-DTnWxtnb.js → Slider-D8h_RKcF.js} +1 -1
- package/dist/Stack/index.d.ts +1 -1
- package/dist/Stepper/index.d.ts +2 -0
- package/dist/Stepper/index.js +2 -0
- package/dist/Stepper-DxmLfh8O.js +423 -0
- package/dist/Switch/index.d.ts +1 -1
- package/dist/Switch/index.js +1 -1
- package/dist/{Switch-CNdnr5TP.js → Switch-SesQzPGZ.js} +4 -2
- package/dist/TabList/index.d.ts +2 -2
- package/dist/TabList/index.js +2 -2
- package/dist/TabList-C411uNQU.js +380 -0
- package/dist/Table/index.d.ts +3 -0
- package/dist/Table/index.js +2 -0
- package/dist/Table-7qRmlIQd.js +967 -0
- package/dist/Text/index.d.ts +1 -1
- package/dist/TextArea/index.d.ts +1 -1
- package/dist/TextArea/index.js +1 -1
- package/dist/{TextArea-BL0NuB99.js → TextArea-Cv9UVbzS.js} +5 -3
- package/dist/TextInput/index.d.ts +1 -1
- package/dist/TextInput/index.js +1 -1
- package/dist/{TextInput-B0IKC7g5.js → TextInput-BasnjVvy.js} +5 -3
- package/dist/Thumbnail/index.d.ts +2 -0
- package/dist/Thumbnail/index.js +2 -0
- package/dist/Thumbnail-BWVzLLyI.js +163 -0
- package/dist/TimeField-l3QzU6vC.js +214 -0
- package/dist/TimeInput/index.d.ts +2 -0
- package/dist/TimeInput/index.js +2 -0
- package/dist/TimeInput-OkgX-xbQ.js +121 -0
- package/dist/Timestamp/index.d.ts +2 -0
- package/dist/Timestamp/index.js +2 -0
- package/dist/Timestamp-DUoP9ari.js +465 -0
- package/dist/ToggleButton/index.d.ts +1 -1
- package/dist/Token/index.js +1 -1
- package/dist/{Token-Ctf9jekS.js → Token-C4KD0fZD.js} +1 -1
- package/dist/Tokenizer/index.d.ts +1 -1
- package/dist/Tokenizer/index.js +1 -1
- package/dist/{Tokenizer-D5MPgau0.js → Tokenizer-BA8sTMPZ.js} +3 -3
- package/dist/Toolbar/index.d.ts +1 -1
- package/dist/Tooltip/index.d.ts +1 -1
- package/dist/TopNav/index.d.ts +1 -1
- package/dist/TopNav/index.js +1 -1
- package/dist/{TopNav-CjbMCbkC.js → TopNav-CZokS7E_.js} +57 -31
- package/dist/TreeList/index.d.ts +2 -0
- package/dist/TreeList/index.js +2 -0
- package/dist/TreeList-CIbAGOMf.js +506 -0
- package/dist/Typeahead/index.d.ts +1 -1
- package/dist/Typeahead/index.js +1 -1
- package/dist/{Typeahead-BMoU3hfx.js → Typeahead-DIw-K4aa.js} +3 -3
- package/dist/composables/index.d.ts +3 -2
- package/dist/composables/index.js +8 -2
- package/dist/composables-CVfjp9h4.js +502 -0
- package/dist/context-BjNya0v8.js +19 -0
- package/dist/context-Cfjh8te1.js +29 -0
- package/dist/{locale-56lkR7OK.js → context-D6ECRdc5.js} +267 -18
- package/dist/index-1uRMrk63.d.ts +54 -0
- package/dist/{index-Dw21t7Uf.d.ts → index-2u4l3wq8.d.ts} +2 -2
- package/dist/{index-CvLlWLIZ.d.ts → index-B4OOtNP8.d.ts} +4 -4
- package/dist/{index-_1-uvr27.d.ts → index-B8MbfMwV.d.ts} +1 -1
- package/dist/{index-MPcg1Pm4.d.ts → index-BKr7yvVv.d.ts} +1 -1
- package/dist/index-Be1czg3M.d.ts +167 -0
- package/dist/{index-Dbmgcm8a.d.ts → index-BeR-1LgF.d.ts} +2 -0
- package/dist/{index-CnVbMebA.d.ts → index-Bqb_Fyju.d.ts} +3 -3
- package/dist/index-BrJzFA5X.d.ts +38 -0
- package/dist/{index-BDZCJ9ri.d.ts → index-BuubzuE8.d.ts} +2 -2
- package/dist/index-By2mSzUA.d.ts +67 -0
- package/dist/{index-HV6W3xCx.d.ts → index-Byar3h1e.d.ts} +1 -1
- package/dist/{index-BQuN_dWR.d.ts → index-BzqRns96.d.ts} +1 -1
- package/dist/{index-BkIgRYGz.d.ts → index-C5p2NeCr.d.ts} +2 -2
- package/dist/{index-Cc2HGODZ.d.ts → index-C6RecznD.d.ts} +3 -3
- package/dist/{index-BSRk8MFK.d.ts → index-C8wDPDcP.d.ts} +1 -1
- package/dist/index-CDdRQQF3.d.ts +170 -0
- package/dist/index-COqjznX0.d.ts +47 -0
- package/dist/{index-Cz9ZHVf6.d.ts → index-CT8KEpec.d.ts} +2 -2
- package/dist/{index-CxspvLBl.d.ts → index-CTolyeii.d.ts} +1 -1
- package/dist/index-CVn0GBdB.d.ts +115 -0
- package/dist/index-CX97hlld.d.ts +158 -0
- package/dist/index-C_2Z65Rp.d.ts +67 -0
- package/dist/index-CjtAH60j.d.ts +38 -0
- package/dist/index-CtlkhQ55.d.ts +36 -0
- package/dist/{index-JeZ0YTyd.d.ts → index-D-ZuubCK.d.ts} +4 -4
- package/dist/index-DA52oIdw.d.ts +171 -0
- package/dist/{index-C8NW9xre.d.ts → index-DGNqi2za.d.ts} +7 -7
- package/dist/{index-CCA4R0Mf.d.ts → index-DT9S92sh.d.ts} +31 -6
- package/dist/index-DXSs3rwa.d.ts +252 -0
- package/dist/{index-C0S2Xzoi.d.ts → index-DYChvBOM.d.ts} +135 -0
- package/dist/index-Da7Jm8Ht.d.ts +10 -0
- package/dist/{index-CaHXYQ_E.d.ts → index-Df2YvC8o.d.ts} +717 -147
- package/dist/{index-DjOdQv5B.d.ts → index-DfgHJE7H.d.ts} +1 -1
- package/dist/{index-CPhDtlv-.d.ts → index-FEy8qFSD.d.ts} +3 -3
- package/dist/{index-DBcbfStA.d.ts → index-SMh42NI8.d.ts} +182 -2
- package/dist/{index-Cdi82rTW.d.ts → index-ZJyk8RtQ.d.ts} +6 -2
- package/dist/{index-BeJqhW4l.d.ts → index-fa72tWIU.d.ts} +3 -3
- package/dist/{index-COxy6LEW.d.ts → index-gW0HW02U.d.ts} +1 -1
- package/dist/{index-BQa836Vz.d.ts → index-iBLzInje.d.ts} +6 -14
- package/dist/{index-BhYFxnjV.d.ts → index-kaKBOZSU.d.ts} +2 -2
- package/dist/index-nKlTsNfV.d.ts +42 -0
- package/dist/index-utZGF4GR.d.ts +79 -0
- package/dist/index.d.ts +76 -59
- package/dist/index.js +119 -78
- package/dist/locale/index.d.ts +1 -1
- package/dist/locale/index.js +2 -1
- package/dist/locale-Cpk_nrLA.js +18 -0
- package/dist/size-BuTzpgnR.d.ts +14 -0
- package/dist/size-xcIqExkS.js +79 -0
- package/dist/{index-Cp0NlzQv.d.ts → types-Db3Owy8Q.d.ts} +1 -36
- package/dist/types-JktRxujg.d.ts +107 -0
- package/dist/useAppShellMobile-DTsyuAJ4.js +19 -0
- package/dist/useClickableContainer-DyNpnSEa.js +112 -0
- package/dist/useFileSelection-BPtaegqK.js +58 -0
- package/dist/useMonthGrid-CmJsZTcB.js +139 -0
- package/dist/useResizable-CeESZS1v.d.ts +72 -0
- package/dist/useScrollableArea-DDk_CluT.js +172 -0
- package/dist/useTimeValue-DWk6oTAZ.js +113 -0
- package/package.json +97 -1
- package/styles/app-shell.css +151 -0
- package/styles/aspect-ratio.css +49 -0
- package/styles/bordered-control.css +87 -0
- package/styles/calendar.css +8 -2
- package/styles/card.css +5 -1
- package/styles/checkbox-list.css +15 -0
- package/styles/clickable-card.css +101 -0
- package/styles/collapsible.css +37 -0
- package/styles/command-palette.css +183 -0
- package/styles/complex-selector.css +114 -0
- package/styles/date-range-input.css +163 -0
- package/styles/date-time-input.css +40 -0
- package/styles/field.css +14 -3
- package/styles/file-input.css +87 -0
- package/styles/form-layout.css +31 -0
- package/styles/heading.css +19 -17
- package/styles/icon.css +32 -0
- package/styles/layout.css +280 -0
- package/styles/metadata-list.css +107 -0
- package/styles/number-input.css +6 -0
- package/styles/radio.css +32 -0
- package/styles/resize-handle.css +128 -0
- package/styles/scrollable-area.css +50 -0
- package/styles/section.css +60 -0
- package/styles/selector.css +10 -0
- package/styles/side-nav.css +26 -0
- package/styles/stepper.css +357 -0
- package/styles/tab-menu.css +91 -0
- package/styles/table.css +256 -0
- package/styles/text-area.css +6 -1
- package/styles/text-input.css +6 -0
- package/styles/thumbnail.css +151 -0
- package/styles/time-input.css +51 -0
- package/styles/timestamp.css +93 -0
- package/styles/tree-list.css +229 -0
- package/styles.css +23 -0
- package/dist/Collapsible-ByXCGhT8.js +0 -102
- package/dist/TabList-LV1U4ZD6.js +0 -184
- package/dist/composables-Dq9RS33w.js +0 -111
- package/dist/index-TnaIHsCS.d.ts +0 -87
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as useAstryxMessages } from "./context-D6ECRdc5.js";
|
|
2
|
+
import { t as _sfc_main$1 } from "./Calendar-CYhGDT6f.js";
|
|
3
3
|
import { t as _sfc_main$2 } from "./Popover-Crhk9PNP.js";
|
|
4
4
|
import { computed, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, normalizeClass, openBlock, ref, renderSlot, useId, useTemplateRef, watch, withCtx } from "vue";
|
|
5
5
|
import "../styles/date-input.css";
|
|
@@ -11,10 +11,13 @@ const _hoisted_2 = {
|
|
|
11
11
|
};
|
|
12
12
|
const _hoisted_3 = ["disabled", "aria-label"];
|
|
13
13
|
const _hoisted_4 = [
|
|
14
|
+
"id",
|
|
14
15
|
"value",
|
|
15
16
|
"placeholder",
|
|
16
17
|
"disabled",
|
|
17
18
|
"aria-label",
|
|
19
|
+
"aria-describedby",
|
|
20
|
+
"aria-controls",
|
|
18
21
|
"aria-expanded",
|
|
19
22
|
"title"
|
|
20
23
|
];
|
|
@@ -23,11 +26,14 @@ const _hoisted_6 = {
|
|
|
23
26
|
key: 2,
|
|
24
27
|
class: "astryx-date-input-suffix"
|
|
25
28
|
};
|
|
26
|
-
const _hoisted_7 = ["
|
|
29
|
+
const _hoisted_7 = ["id"];
|
|
30
|
+
const _hoisted_8 = ["name", "value"];
|
|
27
31
|
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
28
32
|
name: "AstryxDateInput",
|
|
29
33
|
__name: "DateInput",
|
|
30
34
|
props: {
|
|
35
|
+
id: {},
|
|
36
|
+
describedBy: {},
|
|
31
37
|
modelValue: { default: null },
|
|
32
38
|
placeholder: {},
|
|
33
39
|
min: {},
|
|
@@ -52,8 +58,9 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
52
58
|
setup(__props, { emit: __emit }) {
|
|
53
59
|
const props = __props;
|
|
54
60
|
const emit = __emit;
|
|
55
|
-
const
|
|
56
|
-
const
|
|
61
|
+
const generatedId = `astryx-date-input-${useId()}`;
|
|
62
|
+
const inputId = computed(() => props.id ?? generatedId);
|
|
63
|
+
const popupId = computed(() => `${inputId.value}-popup`);
|
|
57
64
|
const messages = useAstryxMessages();
|
|
58
65
|
const resolvedPlaceholder = computed(() => props.placeholder ?? messages.value.dateInput.placeholder);
|
|
59
66
|
const resolvedClearLabel = computed(() => props.clearLabel ?? messages.value.dateInput.clear(props.label));
|
|
@@ -133,7 +140,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
133
140
|
label: dialogLabel.value,
|
|
134
141
|
onOpenChange
|
|
135
142
|
}, {
|
|
136
|
-
content: withCtx(() => [createElementVNode("div", { id: popupId }, [createVNode(_sfc_main$1, {
|
|
143
|
+
content: withCtx(() => [createElementVNode("div", { id: popupId.value }, [createVNode(_sfc_main$1, {
|
|
137
144
|
"model-value": props.modelValue,
|
|
138
145
|
min: props.min,
|
|
139
146
|
max: props.max,
|
|
@@ -144,7 +151,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
144
151
|
"min",
|
|
145
152
|
"max",
|
|
146
153
|
"is-date-disabled"
|
|
147
|
-
])])]),
|
|
154
|
+
])], 8, _hoisted_7)]),
|
|
148
155
|
default: withCtx(() => [createElementVNode("div", {
|
|
149
156
|
class: "astryx-date-input-wrapper",
|
|
150
157
|
"data-disabled": props.disabled ? "true" : void 0,
|
|
@@ -185,7 +192,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
185
192
|
})
|
|
186
193
|
], -1)])], 8, _hoisted_3),
|
|
187
194
|
createElementVNode("input", {
|
|
188
|
-
id: inputId,
|
|
195
|
+
id: inputId.value,
|
|
189
196
|
ref_key: "inputRef",
|
|
190
197
|
ref: inputRef,
|
|
191
198
|
type: "text",
|
|
@@ -195,7 +202,8 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
195
202
|
placeholder: resolvedPlaceholder.value,
|
|
196
203
|
disabled: props.disabled,
|
|
197
204
|
"aria-label": props.label,
|
|
198
|
-
"aria-
|
|
205
|
+
"aria-describedby": props.describedBy,
|
|
206
|
+
"aria-controls": popupId.value,
|
|
199
207
|
"aria-expanded": isOpen.value,
|
|
200
208
|
"aria-haspopup": "dialog",
|
|
201
209
|
title: props.disabledReason,
|
|
@@ -234,7 +242,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
234
242
|
type: "hidden",
|
|
235
243
|
name: props.name,
|
|
236
244
|
value: formatDate(props.modelValue)
|
|
237
|
-
}, null, 8,
|
|
245
|
+
}, null, 8, _hoisted_8)) : createCommentVNode("v-if", true)], 2);
|
|
238
246
|
};
|
|
239
247
|
}
|
|
240
248
|
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { $n as DateRangeInputEmits, Qn as DateRange, Zn as _default, er as DateRangeInputProps, tr as DateRangePreset } from "../index-Df2YvC8o.js";
|
|
2
|
+
export { type DateRange, _default as DateRangeInput, type DateRangeInputEmits, type DateRangeInputProps, type DateRangePreset };
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
import { a as todayISODate, c as formatDateRange, f as orderRange, l as isDayOutsideSpan, n as buildMonthGrid, o as applyRangeClick, p as resolveWeekStart, t as addMonths, u as isRangeWithinSpan } from "./useMonthGrid-CmJsZTcB.js";
|
|
2
|
+
import { a as useAstryxMessages, i as useAstryxLocale } from "./context-D6ECRdc5.js";
|
|
3
|
+
import { n as weekdayNames, t as formatCalendarMonth } from "./locale-Cpk_nrLA.js";
|
|
4
|
+
import { t as _sfc_main$2 } from "./FieldIcon--NTgW5IU.js";
|
|
5
|
+
import { t as _sfc_main$3 } from "./IconButton-BNQuz9W_.js";
|
|
6
|
+
import { t as _sfc_main$4 } from "./Icon-5MdZQ18k.js";
|
|
7
|
+
import { t as _sfc_main$5 } from "./Field-8zRxzDHE.js";
|
|
8
|
+
import { t as _sfc_main$6 } from "./Popover-Crhk9PNP.js";
|
|
9
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, mergeModels, normalizeClass, openBlock, renderList, shallowRef, toDisplayString, unref, useId, useModel, withCtx } from "vue";
|
|
10
|
+
import "../styles/calendar.css";
|
|
11
|
+
import "../styles/date-range-input.css";
|
|
12
|
+
import "../styles/bordered-control.css";
|
|
13
|
+
//#region src/DateRangeInput/RangeCalendar.vue
|
|
14
|
+
const _hoisted_1$1 = { class: "astryx-calendar astryx-date-range-calendar" };
|
|
15
|
+
const _hoisted_2$1 = { class: "astryx-calendar-header" };
|
|
16
|
+
const _hoisted_3$1 = ["aria-label"];
|
|
17
|
+
const _hoisted_4$1 = { class: "astryx-calendar-month-year" };
|
|
18
|
+
const _hoisted_5$1 = ["aria-label"];
|
|
19
|
+
const _hoisted_6$1 = { class: "astryx-date-range-months" };
|
|
20
|
+
const _hoisted_7$1 = { class: "astryx-calendar-weekdays" };
|
|
21
|
+
const _hoisted_8 = ["aria-label"];
|
|
22
|
+
const _hoisted_9 = [
|
|
23
|
+
"disabled",
|
|
24
|
+
"aria-pressed",
|
|
25
|
+
"aria-current",
|
|
26
|
+
"onClick",
|
|
27
|
+
"onMouseenter",
|
|
28
|
+
"onFocus"
|
|
29
|
+
];
|
|
30
|
+
const _hoisted_10 = { class: "astryx-calendar-day" };
|
|
31
|
+
const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
32
|
+
__name: "RangeCalendar",
|
|
33
|
+
props: /*@__PURE__*/ mergeModels({
|
|
34
|
+
cursorYear: {},
|
|
35
|
+
cursorMonth: {},
|
|
36
|
+
monthCount: { default: 2 },
|
|
37
|
+
range: { default: null },
|
|
38
|
+
pending: { default: null },
|
|
39
|
+
min: {},
|
|
40
|
+
max: {},
|
|
41
|
+
minRangeSpan: { default: 1 },
|
|
42
|
+
maxRangeSpan: {},
|
|
43
|
+
weekStartsOn: {}
|
|
44
|
+
}, {
|
|
45
|
+
"hover": { default: null },
|
|
46
|
+
"hoverModifiers": {}
|
|
47
|
+
}),
|
|
48
|
+
emits: /*@__PURE__*/ mergeModels(["select", "shift"], ["update:hover"]),
|
|
49
|
+
setup(__props, { emit: __emit }) {
|
|
50
|
+
const props = __props;
|
|
51
|
+
const emit = __emit;
|
|
52
|
+
const locale = useAstryxLocale();
|
|
53
|
+
const messages = useAstryxMessages();
|
|
54
|
+
const hover = useModel(__props, "hover");
|
|
55
|
+
const today = todayISODate();
|
|
56
|
+
const weekStart = computed(() => resolveWeekStart(props.weekStartsOn ?? (locale.value === "zh-CN" ? 1 : 0)));
|
|
57
|
+
const weekDays = computed(() => {
|
|
58
|
+
const names = weekdayNames(locale.value, "narrow");
|
|
59
|
+
const labels = weekdayNames(locale.value, "long");
|
|
60
|
+
const start = weekStart.value;
|
|
61
|
+
return Array.from({ length: 7 }, (_, index) => ({
|
|
62
|
+
name: names[(index + start) % 7],
|
|
63
|
+
label: labels[(index + start) % 7]
|
|
64
|
+
}));
|
|
65
|
+
});
|
|
66
|
+
const months = computed(() => Array.from({ length: props.monthCount }, (_, index) => {
|
|
67
|
+
const cursor = addMonths(props.cursorYear, props.cursorMonth, index);
|
|
68
|
+
return {
|
|
69
|
+
...cursor,
|
|
70
|
+
label: formatCalendarMonth(cursor.year, cursor.month, locale.value),
|
|
71
|
+
weeks: buildMonthGrid(cursor.year, cursor.month, weekStart.value)
|
|
72
|
+
};
|
|
73
|
+
}));
|
|
74
|
+
const headerLabel = computed(() => months.value.map((month) => month.label).join(" – "));
|
|
75
|
+
const preview = computed(() => {
|
|
76
|
+
if (props.pending && hover.value && hover.value !== props.pending) return orderRange(props.pending, hover.value);
|
|
77
|
+
return props.range;
|
|
78
|
+
});
|
|
79
|
+
function monthKey(iso) {
|
|
80
|
+
return iso.slice(0, 7);
|
|
81
|
+
}
|
|
82
|
+
function inSpan(day, range) {
|
|
83
|
+
return range != null && day >= range.start && day <= range.end;
|
|
84
|
+
}
|
|
85
|
+
function isDisabled(day) {
|
|
86
|
+
if (props.min && day < props.min) return true;
|
|
87
|
+
if (props.max && day > props.max) return true;
|
|
88
|
+
return isDayOutsideSpan(props.pending, day, props.minRangeSpan, props.maxRangeSpan);
|
|
89
|
+
}
|
|
90
|
+
return (_ctx, _cache) => {
|
|
91
|
+
return openBlock(), createElementBlock("div", _hoisted_1$1, [createElementVNode("div", _hoisted_2$1, [
|
|
92
|
+
createElementVNode("button", {
|
|
93
|
+
type: "button",
|
|
94
|
+
class: "astryx-calendar-nav-button",
|
|
95
|
+
"aria-label": unref(messages).calendar.previousMonth,
|
|
96
|
+
onClick: _cache[0] || (_cache[0] = ($event) => emit("shift", -1))
|
|
97
|
+
}, [createVNode(_sfc_main$4, {
|
|
98
|
+
icon: "chevronLeft",
|
|
99
|
+
size: "sm"
|
|
100
|
+
})], 8, _hoisted_3$1),
|
|
101
|
+
createElementVNode("span", _hoisted_4$1, toDisplayString(headerLabel.value), 1),
|
|
102
|
+
createElementVNode("button", {
|
|
103
|
+
type: "button",
|
|
104
|
+
class: "astryx-calendar-nav-button",
|
|
105
|
+
"aria-label": unref(messages).calendar.nextMonth,
|
|
106
|
+
onClick: _cache[1] || (_cache[1] = ($event) => emit("shift", 1))
|
|
107
|
+
}, [createVNode(_sfc_main$4, {
|
|
108
|
+
icon: "chevronRight",
|
|
109
|
+
size: "sm"
|
|
110
|
+
})], 8, _hoisted_5$1)
|
|
111
|
+
]), createElementVNode("div", _hoisted_6$1, [(openBlock(true), createElementBlock(Fragment, null, renderList(months.value, (month) => {
|
|
112
|
+
return openBlock(), createElementBlock("div", {
|
|
113
|
+
key: `${month.year}-${month.month}`,
|
|
114
|
+
class: "astryx-date-range-month"
|
|
115
|
+
}, [createElementVNode("div", _hoisted_7$1, [(openBlock(true), createElementBlock(Fragment, null, renderList(weekDays.value, (day) => {
|
|
116
|
+
return openBlock(), createElementBlock("div", {
|
|
117
|
+
key: day.label,
|
|
118
|
+
class: "astryx-calendar-weekday",
|
|
119
|
+
"aria-label": day.label
|
|
120
|
+
}, toDisplayString(day.name), 9, _hoisted_8);
|
|
121
|
+
}), 128))]), (openBlock(true), createElementBlock(Fragment, null, renderList(month.weeks, (week, weekIndex) => {
|
|
122
|
+
return openBlock(), createElementBlock("div", {
|
|
123
|
+
key: weekIndex,
|
|
124
|
+
class: "astryx-calendar-row"
|
|
125
|
+
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(week, (day) => {
|
|
126
|
+
return openBlock(), createElementBlock("button", {
|
|
127
|
+
key: day,
|
|
128
|
+
type: "button",
|
|
129
|
+
class: normalizeClass(["astryx-calendar-cell", {
|
|
130
|
+
"is-other-month": monthKey(day) !== `${month.year}-${String(month.month).padStart(2, "0")}`,
|
|
131
|
+
"is-today": day === unref(today),
|
|
132
|
+
"is-selected": day === preview.value?.start || day === preview.value?.end || day === __props.pending,
|
|
133
|
+
"is-in-range": inSpan(day, preview.value),
|
|
134
|
+
"is-range-start": day === preview.value?.start,
|
|
135
|
+
"is-range-end": day === preview.value?.end,
|
|
136
|
+
"is-disabled": isDisabled(day)
|
|
137
|
+
}]),
|
|
138
|
+
disabled: isDisabled(day),
|
|
139
|
+
"aria-pressed": day === preview.value?.start || day === preview.value?.end || void 0,
|
|
140
|
+
"aria-current": day === unref(today) ? "date" : void 0,
|
|
141
|
+
onClick: ($event) => emit("select", day),
|
|
142
|
+
onMouseenter: ($event) => hover.value = day,
|
|
143
|
+
onMouseleave: _cache[2] || (_cache[2] = ($event) => hover.value = null),
|
|
144
|
+
onFocus: ($event) => hover.value = day,
|
|
145
|
+
onBlur: _cache[3] || (_cache[3] = ($event) => hover.value = null)
|
|
146
|
+
}, [createElementVNode("span", _hoisted_10, toDisplayString(Number(day.slice(8))), 1)], 42, _hoisted_9);
|
|
147
|
+
}), 128))]);
|
|
148
|
+
}), 128))]);
|
|
149
|
+
}), 128))])]);
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region src/DateRangeInput/DateRangeInput.vue
|
|
155
|
+
const _hoisted_1 = [
|
|
156
|
+
"data-size",
|
|
157
|
+
"data-status",
|
|
158
|
+
"data-disabled"
|
|
159
|
+
];
|
|
160
|
+
const _hoisted_2 = [
|
|
161
|
+
"id",
|
|
162
|
+
"disabled",
|
|
163
|
+
"aria-describedby",
|
|
164
|
+
"aria-invalid"
|
|
165
|
+
];
|
|
166
|
+
const _hoisted_3 = ["data-placeholder"];
|
|
167
|
+
const _hoisted_4 = { class: "astryx-date-range-popover" };
|
|
168
|
+
const _hoisted_5 = { class: "astryx-date-range-panel" };
|
|
169
|
+
const _hoisted_6 = {
|
|
170
|
+
key: 0,
|
|
171
|
+
class: "astryx-date-range-presets"
|
|
172
|
+
};
|
|
173
|
+
const _hoisted_7 = ["disabled", "onClick"];
|
|
174
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
175
|
+
name: "AstryxDateRangeInput",
|
|
176
|
+
__name: "DateRangeInput",
|
|
177
|
+
props: /*@__PURE__*/ mergeModels({
|
|
178
|
+
label: {},
|
|
179
|
+
id: {},
|
|
180
|
+
description: {},
|
|
181
|
+
placeholder: {},
|
|
182
|
+
presets: {},
|
|
183
|
+
monthCount: { default: 2 },
|
|
184
|
+
min: {},
|
|
185
|
+
max: {},
|
|
186
|
+
minRangeSpan: { default: 1 },
|
|
187
|
+
maxRangeSpan: {},
|
|
188
|
+
weekStartsOn: {},
|
|
189
|
+
hasClear: {
|
|
190
|
+
type: Boolean,
|
|
191
|
+
default: true
|
|
192
|
+
},
|
|
193
|
+
clearLabel: {},
|
|
194
|
+
size: { default: "md" },
|
|
195
|
+
isDisabled: { type: Boolean },
|
|
196
|
+
isRequired: { type: Boolean },
|
|
197
|
+
isOptional: { type: Boolean },
|
|
198
|
+
isLabelHidden: { type: Boolean },
|
|
199
|
+
status: {},
|
|
200
|
+
statusVariant: { default: "attached" },
|
|
201
|
+
width: {}
|
|
202
|
+
}, {
|
|
203
|
+
"modelValue": { default: null },
|
|
204
|
+
"modelModifiers": {}
|
|
205
|
+
}),
|
|
206
|
+
emits: /*@__PURE__*/ mergeModels(["update:modelValue", "change"], ["update:modelValue"]),
|
|
207
|
+
setup(__props, { emit: __emit }) {
|
|
208
|
+
const props = __props;
|
|
209
|
+
const emit = __emit;
|
|
210
|
+
const model = useModel(__props, "modelValue");
|
|
211
|
+
const messages = useAstryxMessages();
|
|
212
|
+
const locale = useAstryxLocale();
|
|
213
|
+
const generatedId = `astryx-date-range-${useId()}`;
|
|
214
|
+
const inputId = computed(() => props.id ?? generatedId);
|
|
215
|
+
const open = shallowRef(false);
|
|
216
|
+
const pending = shallowRef(null);
|
|
217
|
+
const today = todayISODate();
|
|
218
|
+
const cursor = shallowRef({
|
|
219
|
+
year: Number(today.slice(0, 4)),
|
|
220
|
+
month: Number(today.slice(5, 7))
|
|
221
|
+
});
|
|
222
|
+
const display = computed(() => formatDateRange(model.value, locale.value));
|
|
223
|
+
const placeholder = computed(() => props.placeholder ?? messages.value.dateRangeInput.placeholder);
|
|
224
|
+
const clearLabel = computed(() => props.clearLabel ?? messages.value.dateRangeInput.clear(props.label));
|
|
225
|
+
function commit(value) {
|
|
226
|
+
model.value = value;
|
|
227
|
+
emit("change", value);
|
|
228
|
+
}
|
|
229
|
+
function onSelect(day) {
|
|
230
|
+
const result = applyRangeClick(pending.value, day, props.minRangeSpan, props.maxRangeSpan);
|
|
231
|
+
pending.value = result.pending;
|
|
232
|
+
if (result.commit) {
|
|
233
|
+
commit(result.commit);
|
|
234
|
+
open.value = false;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
function onShift(amount) {
|
|
238
|
+
cursor.value = addMonths(cursor.value.year, cursor.value.month, amount);
|
|
239
|
+
}
|
|
240
|
+
function onOpenChange(next) {
|
|
241
|
+
open.value = next;
|
|
242
|
+
if (next && model.value) {
|
|
243
|
+
cursor.value = {
|
|
244
|
+
year: Number(model.value.start.slice(0, 4)),
|
|
245
|
+
month: Number(model.value.start.slice(5, 7))
|
|
246
|
+
};
|
|
247
|
+
pending.value = null;
|
|
248
|
+
}
|
|
249
|
+
if (!next) pending.value = null;
|
|
250
|
+
}
|
|
251
|
+
function applyPreset(preset) {
|
|
252
|
+
const range = preset.getRange();
|
|
253
|
+
if (!isRangeWithinSpan(range, props.minRangeSpan, props.maxRangeSpan)) return;
|
|
254
|
+
commit(range);
|
|
255
|
+
pending.value = null;
|
|
256
|
+
open.value = false;
|
|
257
|
+
}
|
|
258
|
+
function presetDisabled(preset) {
|
|
259
|
+
return !isRangeWithinSpan(preset.getRange(), props.minRangeSpan, props.maxRangeSpan);
|
|
260
|
+
}
|
|
261
|
+
function clear() {
|
|
262
|
+
pending.value = null;
|
|
263
|
+
commit(null);
|
|
264
|
+
open.value = false;
|
|
265
|
+
}
|
|
266
|
+
return (_ctx, _cache) => {
|
|
267
|
+
return openBlock(), createBlock(_sfc_main$5, {
|
|
268
|
+
label: __props.label,
|
|
269
|
+
"input-id": inputId.value,
|
|
270
|
+
description: __props.description,
|
|
271
|
+
width: __props.width,
|
|
272
|
+
"is-label-hidden": __props.isLabelHidden,
|
|
273
|
+
"is-disabled": __props.isDisabled,
|
|
274
|
+
"is-optional": __props.isOptional,
|
|
275
|
+
"is-required": __props.isRequired,
|
|
276
|
+
status: __props.status,
|
|
277
|
+
"status-variant": __props.statusVariant
|
|
278
|
+
}, {
|
|
279
|
+
default: withCtx((field) => [createVNode(_sfc_main$6, {
|
|
280
|
+
"is-open": open.value,
|
|
281
|
+
"is-enabled": !__props.isDisabled,
|
|
282
|
+
placement: "below",
|
|
283
|
+
alignment: "start",
|
|
284
|
+
padding: 0,
|
|
285
|
+
width: "min(40rem, calc(100vw - 16px))",
|
|
286
|
+
"has-close-button": false,
|
|
287
|
+
"is-modal": false,
|
|
288
|
+
role: "dialog",
|
|
289
|
+
label: unref(messages).dateRangeInput.dialogLabel,
|
|
290
|
+
onOpenChange
|
|
291
|
+
}, {
|
|
292
|
+
content: withCtx(() => [createElementVNode("div", _hoisted_4, [createElementVNode("div", _hoisted_5, [__props.presets?.length ? (openBlock(), createElementBlock("div", _hoisted_6, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.presets, (preset) => {
|
|
293
|
+
return openBlock(), createElementBlock("button", {
|
|
294
|
+
key: preset.label,
|
|
295
|
+
type: "button",
|
|
296
|
+
class: "astryx-date-range-preset",
|
|
297
|
+
disabled: presetDisabled(preset),
|
|
298
|
+
onClick: ($event) => applyPreset(preset)
|
|
299
|
+
}, toDisplayString(preset.label), 9, _hoisted_7);
|
|
300
|
+
}), 128))])) : createCommentVNode("v-if", true), createVNode(_sfc_main$1, {
|
|
301
|
+
"cursor-year": cursor.value.year,
|
|
302
|
+
"cursor-month": cursor.value.month,
|
|
303
|
+
"month-count": __props.monthCount,
|
|
304
|
+
range: model.value,
|
|
305
|
+
pending: pending.value,
|
|
306
|
+
min: __props.min,
|
|
307
|
+
max: __props.max,
|
|
308
|
+
"min-range-span": __props.minRangeSpan,
|
|
309
|
+
"max-range-span": __props.maxRangeSpan,
|
|
310
|
+
"week-starts-on": __props.weekStartsOn,
|
|
311
|
+
onSelect,
|
|
312
|
+
onShift
|
|
313
|
+
}, null, 8, [
|
|
314
|
+
"cursor-year",
|
|
315
|
+
"cursor-month",
|
|
316
|
+
"month-count",
|
|
317
|
+
"range",
|
|
318
|
+
"pending",
|
|
319
|
+
"min",
|
|
320
|
+
"max",
|
|
321
|
+
"min-range-span",
|
|
322
|
+
"max-range-span",
|
|
323
|
+
"week-starts-on"
|
|
324
|
+
])])])]),
|
|
325
|
+
default: withCtx(() => [createElementVNode("div", {
|
|
326
|
+
class: "astryx-date-range-input astryx-bordered-control",
|
|
327
|
+
"data-size": __props.size,
|
|
328
|
+
"data-status": __props.status?.type,
|
|
329
|
+
"data-disabled": __props.isDisabled || void 0
|
|
330
|
+
}, [
|
|
331
|
+
createElementVNode("button", {
|
|
332
|
+
id: inputId.value,
|
|
333
|
+
type: "button",
|
|
334
|
+
class: "astryx-date-range-trigger",
|
|
335
|
+
disabled: __props.isDisabled,
|
|
336
|
+
"aria-describedby": field.describedBy,
|
|
337
|
+
"aria-invalid": __props.status?.type === "error" || void 0
|
|
338
|
+
}, [createVNode(_sfc_main$4, {
|
|
339
|
+
class: "astryx-date-range-icon",
|
|
340
|
+
icon: "calendar",
|
|
341
|
+
size: "sm"
|
|
342
|
+
}), createElementVNode("span", {
|
|
343
|
+
class: "astryx-date-range-value",
|
|
344
|
+
"data-placeholder": !display.value || void 0
|
|
345
|
+
}, toDisplayString(display.value || placeholder.value), 9, _hoisted_3)], 8, _hoisted_2),
|
|
346
|
+
__props.hasClear && model.value && !__props.isDisabled ? (openBlock(), createBlock(_sfc_main$3, {
|
|
347
|
+
key: 0,
|
|
348
|
+
class: "astryx-input-clear-button",
|
|
349
|
+
variant: "ghost",
|
|
350
|
+
size: "sm",
|
|
351
|
+
label: clearLabel.value,
|
|
352
|
+
onClick: clear
|
|
353
|
+
}, {
|
|
354
|
+
default: withCtx(() => [createVNode(_sfc_main$2, { type: "clear" })]),
|
|
355
|
+
_: 1
|
|
356
|
+
}, 8, ["label"])) : createCommentVNode("v-if", true),
|
|
357
|
+
__props.status ? (openBlock(), createBlock(_sfc_main$2, {
|
|
358
|
+
key: 1,
|
|
359
|
+
type: __props.status.type
|
|
360
|
+
}, null, 8, ["type"])) : createCommentVNode("v-if", true)
|
|
361
|
+
], 8, _hoisted_1)]),
|
|
362
|
+
_: 2
|
|
363
|
+
}, 1032, [
|
|
364
|
+
"is-open",
|
|
365
|
+
"is-enabled",
|
|
366
|
+
"label"
|
|
367
|
+
])]),
|
|
368
|
+
_: 1
|
|
369
|
+
}, 8, [
|
|
370
|
+
"label",
|
|
371
|
+
"input-id",
|
|
372
|
+
"description",
|
|
373
|
+
"width",
|
|
374
|
+
"is-label-hidden",
|
|
375
|
+
"is-disabled",
|
|
376
|
+
"is-optional",
|
|
377
|
+
"is-required",
|
|
378
|
+
"status",
|
|
379
|
+
"status-variant"
|
|
380
|
+
]);
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
//#endregion
|
|
385
|
+
export { _sfc_main as t };
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { a as useAstryxMessages } from "./context-D6ECRdc5.js";
|
|
2
|
+
import { t as _sfc_main$1 } from "./FieldIcon--NTgW5IU.js";
|
|
3
|
+
import { t as _sfc_main$2 } from "./IconButton-BNQuz9W_.js";
|
|
4
|
+
import { t as _sfc_main$3 } from "./Field-8zRxzDHE.js";
|
|
5
|
+
import { t as _sfc_main$4 } from "./DateInput-D2ErjXYO.js";
|
|
6
|
+
import { t as _sfc_main$5 } from "./TimeField-l3QzU6vC.js";
|
|
7
|
+
import { computed, createBlock, createCommentVNode, createElementVNode, createVNode, defineComponent, mergeModels, openBlock, ref, unref, useId, useModel, watch, withCtx } from "vue";
|
|
8
|
+
import "../styles/date-time-input.css";
|
|
9
|
+
//#region src/DateTimeInput/DateTimeInput.vue
|
|
10
|
+
const _hoisted_1 = [
|
|
11
|
+
"data-size",
|
|
12
|
+
"data-status",
|
|
13
|
+
"data-disabled"
|
|
14
|
+
];
|
|
15
|
+
const _hoisted_2 = { class: "astryx-date-time-fields" };
|
|
16
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
17
|
+
name: "AstryxDateTimeInput",
|
|
18
|
+
__name: "DateTimeInput",
|
|
19
|
+
props: /*@__PURE__*/ mergeModels({
|
|
20
|
+
label: {},
|
|
21
|
+
id: {},
|
|
22
|
+
description: {},
|
|
23
|
+
placeholder: {},
|
|
24
|
+
hourFormat: { default: "12h" },
|
|
25
|
+
presentation: {},
|
|
26
|
+
nativePicker: {},
|
|
27
|
+
hasClear: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: false
|
|
30
|
+
},
|
|
31
|
+
clearLabel: {},
|
|
32
|
+
size: { default: "md" },
|
|
33
|
+
min: {},
|
|
34
|
+
max: {},
|
|
35
|
+
isDisabled: { type: Boolean },
|
|
36
|
+
isReadOnly: { type: Boolean },
|
|
37
|
+
isRequired: { type: Boolean },
|
|
38
|
+
isOptional: { type: Boolean },
|
|
39
|
+
isLabelHidden: { type: Boolean },
|
|
40
|
+
status: {},
|
|
41
|
+
statusVariant: { default: "attached" },
|
|
42
|
+
width: {}
|
|
43
|
+
}, {
|
|
44
|
+
"modelValue": { default: null },
|
|
45
|
+
"modelModifiers": {}
|
|
46
|
+
}),
|
|
47
|
+
emits: /*@__PURE__*/ mergeModels(["update:modelValue", "change"], ["update:modelValue"]),
|
|
48
|
+
setup(__props, { emit: __emit }) {
|
|
49
|
+
const emit = __emit;
|
|
50
|
+
const model = useModel(__props, "modelValue");
|
|
51
|
+
const messages = useAstryxMessages();
|
|
52
|
+
const generatedId = `astryx-date-time-${useId()}`;
|
|
53
|
+
const draftDate = ref(void 0);
|
|
54
|
+
const draftTime = ref(void 0);
|
|
55
|
+
function parseDate(value) {
|
|
56
|
+
const date = value?.slice(0, 10) ?? "";
|
|
57
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) return null;
|
|
58
|
+
const [year, month, day] = date.split("-").map(Number);
|
|
59
|
+
return new Date(year, month - 1, day);
|
|
60
|
+
}
|
|
61
|
+
function parseTime(value) {
|
|
62
|
+
const time = value?.slice(11, 16) ?? "";
|
|
63
|
+
return /^\d{2}:\d{2}$/.test(time) ? time : null;
|
|
64
|
+
}
|
|
65
|
+
function formatDate(date) {
|
|
66
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
67
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
68
|
+
return `${date.getFullYear()}-${month}-${day}`;
|
|
69
|
+
}
|
|
70
|
+
const dateValue = computed(() => draftDate.value !== void 0 ? draftDate.value : parseDate(model.value));
|
|
71
|
+
const timeValue = computed(() => draftTime.value !== void 0 ? draftTime.value : parseTime(model.value));
|
|
72
|
+
const clearLabel = computed(() => messages.value.dateTimeInput.clear());
|
|
73
|
+
function publish() {
|
|
74
|
+
const date = dateValue.value;
|
|
75
|
+
const time = timeValue.value;
|
|
76
|
+
const next = date && time ? `${formatDate(date)}T${time}` : null;
|
|
77
|
+
if (next != null) {
|
|
78
|
+
draftDate.value = void 0;
|
|
79
|
+
draftTime.value = void 0;
|
|
80
|
+
}
|
|
81
|
+
if (next !== model.value) {
|
|
82
|
+
model.value = next;
|
|
83
|
+
emit("change", next);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function onDate(value) {
|
|
87
|
+
draftDate.value = value;
|
|
88
|
+
publish();
|
|
89
|
+
}
|
|
90
|
+
function onTime(value) {
|
|
91
|
+
draftTime.value = value;
|
|
92
|
+
publish();
|
|
93
|
+
}
|
|
94
|
+
function clear() {
|
|
95
|
+
draftDate.value = null;
|
|
96
|
+
draftTime.value = null;
|
|
97
|
+
if (model.value !== null) {
|
|
98
|
+
model.value = null;
|
|
99
|
+
emit("change", null);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
watch(model, (value) => {
|
|
103
|
+
if (value) {
|
|
104
|
+
draftDate.value = void 0;
|
|
105
|
+
draftTime.value = void 0;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
return (_ctx, _cache) => {
|
|
109
|
+
return openBlock(), createBlock(_sfc_main$3, {
|
|
110
|
+
label: __props.label,
|
|
111
|
+
"input-id": generatedId,
|
|
112
|
+
description: __props.description,
|
|
113
|
+
width: __props.width,
|
|
114
|
+
"is-label-hidden": __props.isLabelHidden,
|
|
115
|
+
"is-disabled": __props.isDisabled,
|
|
116
|
+
"is-optional": __props.isOptional,
|
|
117
|
+
"is-required": __props.isRequired,
|
|
118
|
+
status: __props.status,
|
|
119
|
+
"status-variant": __props.statusVariant
|
|
120
|
+
}, {
|
|
121
|
+
default: withCtx((field) => [createElementVNode("div", {
|
|
122
|
+
class: "astryx-date-time-input",
|
|
123
|
+
"data-size": __props.size,
|
|
124
|
+
"data-status": __props.status?.type,
|
|
125
|
+
"data-disabled": __props.isDisabled || void 0
|
|
126
|
+
}, [createElementVNode("div", _hoisted_2, [createVNode(_sfc_main$4, {
|
|
127
|
+
id: generatedId,
|
|
128
|
+
"model-value": dateValue.value,
|
|
129
|
+
label: unref(messages).dateTimeInput.dateLabel,
|
|
130
|
+
placeholder: __props.placeholder,
|
|
131
|
+
disabled: __props.isDisabled,
|
|
132
|
+
size: __props.size,
|
|
133
|
+
"described-by": field.describedBy,
|
|
134
|
+
"onUpdate:modelValue": onDate
|
|
135
|
+
}, null, 8, [
|
|
136
|
+
"model-value",
|
|
137
|
+
"label",
|
|
138
|
+
"placeholder",
|
|
139
|
+
"disabled",
|
|
140
|
+
"size",
|
|
141
|
+
"described-by"
|
|
142
|
+
]), createVNode(_sfc_main$5, {
|
|
143
|
+
"model-value": timeValue.value,
|
|
144
|
+
label: unref(messages).dateTimeInput.timeLabel,
|
|
145
|
+
"described-by": field.describedBy,
|
|
146
|
+
"hour-format": __props.hourFormat,
|
|
147
|
+
presentation: __props.presentation,
|
|
148
|
+
"native-picker": __props.nativePicker,
|
|
149
|
+
min: __props.min,
|
|
150
|
+
max: __props.max,
|
|
151
|
+
size: __props.size,
|
|
152
|
+
"is-disabled": __props.isDisabled,
|
|
153
|
+
"is-read-only": __props.isReadOnly,
|
|
154
|
+
status: __props.status,
|
|
155
|
+
"onUpdate:modelValue": onTime
|
|
156
|
+
}, null, 8, [
|
|
157
|
+
"model-value",
|
|
158
|
+
"label",
|
|
159
|
+
"described-by",
|
|
160
|
+
"hour-format",
|
|
161
|
+
"presentation",
|
|
162
|
+
"native-picker",
|
|
163
|
+
"min",
|
|
164
|
+
"max",
|
|
165
|
+
"size",
|
|
166
|
+
"is-disabled",
|
|
167
|
+
"is-read-only",
|
|
168
|
+
"status"
|
|
169
|
+
])]), __props.hasClear && (dateValue.value || timeValue.value) && !__props.isDisabled ? (openBlock(), createBlock(_sfc_main$2, {
|
|
170
|
+
key: 0,
|
|
171
|
+
class: "astryx-input-clear-button",
|
|
172
|
+
variant: "ghost",
|
|
173
|
+
size: "sm",
|
|
174
|
+
label: clearLabel.value,
|
|
175
|
+
onClick: clear
|
|
176
|
+
}, {
|
|
177
|
+
default: withCtx(() => [createVNode(_sfc_main$1, { type: "clear" })]),
|
|
178
|
+
_: 1
|
|
179
|
+
}, 8, ["label"])) : createCommentVNode("v-if", true)], 8, _hoisted_1)]),
|
|
180
|
+
_: 1
|
|
181
|
+
}, 8, [
|
|
182
|
+
"label",
|
|
183
|
+
"description",
|
|
184
|
+
"width",
|
|
185
|
+
"is-label-hidden",
|
|
186
|
+
"is-disabled",
|
|
187
|
+
"is-optional",
|
|
188
|
+
"is-required",
|
|
189
|
+
"status",
|
|
190
|
+
"status-variant"
|
|
191
|
+
]);
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
//#endregion
|
|
196
|
+
export { _sfc_main as t };
|