@adyen/bento-vue2 1.32.0 → 1.32.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/accordion-item.css +1 -1
- package/dist/assets/action-bar.css +1 -1
- package/dist/assets/base-modal.css +1 -1
- package/dist/assets/card.css +1 -1
- package/dist/assets/data-grid.css +1 -1
- package/dist/assets/dialog-page.css +1 -1
- package/dist/assets/inspector.css +1 -1
- package/dist/assets/menu.css +1 -1
- package/dist/assets/modal-fullscreen.css +1 -1
- package/dist/assets/popover.css +1 -1
- package/dist/assets/sidepanel.css +1 -1
- package/dist/chunks/{code-snippet.Dr7HvCcg.js → code-snippet.Bg39szoO.js} +2 -2
- package/dist/chunks/{code-snippet.Dr7HvCcg.js.map → code-snippet.Bg39szoO.js.map} +1 -1
- package/dist/chunks/{data-grid.Dsv60eRz.js → data-grid.Bq6Dy5tI.js} +5 -5
- package/dist/chunks/{data-grid.Dsv60eRz.js.map → data-grid.Bq6Dy5tI.js.map} +1 -1
- package/dist/chunks/{date-picker.CZ34YMMu.js → date-picker.DInJznhU.js} +12 -12
- package/dist/chunks/{date-picker.CZ34YMMu.js.map → date-picker.DInJznhU.js.map} +1 -1
- package/dist/chunks/{date-range-picker.C__cQBs3.js → date-range-picker.D8-Ns1O7.js} +21 -21
- package/dist/chunks/{date-range-picker.C__cQBs3.js.map → date-range-picker.D8-Ns1O7.js.map} +1 -1
- package/dist/chunks/{dropdown-tag.DEqYdqVG.js → dropdown-tag.Ce5HgBMv.js} +2 -2
- package/dist/chunks/{dropdown-tag.DEqYdqVG.js.map → dropdown-tag.Ce5HgBMv.js.map} +1 -1
- package/dist/chunks/{dropdown.Bn6SRkU5.js → dropdown.CR6vDGwi.js} +14 -14
- package/dist/chunks/{dropdown.Bn6SRkU5.js.map → dropdown.CR6vDGwi.js.map} +1 -1
- package/dist/chunks/{filter-bar.Dcsv7a4q.js → filter-bar.jtfYLtU9.js} +6 -6
- package/dist/chunks/{filter-bar.Dcsv7a4q.js.map → filter-bar.jtfYLtU9.js.map} +1 -1
- package/dist/chunks/{input-field.mEo-bCtk.js → input-field.Czp_0nIh.js} +2 -2
- package/dist/chunks/{input-field.mEo-bCtk.js.map → input-field.Czp_0nIh.js.map} +1 -1
- package/dist/chunks/{pagination.CT08YpqC.js → pagination.Bz02p3If.js} +2 -2
- package/dist/chunks/{pagination.CT08YpqC.js.map → pagination.Bz02p3If.js.map} +1 -1
- package/dist/chunks/{search-bar.hxEJk-w0.js → search-bar.CQw7r7Km.js} +2 -2
- package/dist/chunks/{search-bar.hxEJk-w0.js.map → search-bar.CQw7r7Km.js.map} +1 -1
- package/dist/chunks/{secondary-nav.Bsi7Dj0s.js → secondary-nav.BCccdpL6.js} +2 -2
- package/dist/chunks/{secondary-nav.Bsi7Dj0s.js.map → secondary-nav.BCccdpL6.js.map} +1 -1
- package/dist/code-snippet.js +1 -1
- package/dist/data-grid.js +1 -1
- package/dist/date-picker.js +1 -1
- package/dist/date-range-picker.js +1 -1
- package/dist/dropdown.js +2 -2
- package/dist/filter-bar.js +1 -1
- package/dist/index.js +11 -11
- package/dist/input-field.js +1 -1
- package/dist/pagination.js +1 -1
- package/dist/search-bar.js +2 -2
- package/dist/secondary-nav.js +1 -1
- package/dist/web-types.json +1 -1
- package/package.json +2 -2
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { ref as f, computed as D, defineComponent as Y, toRef as E, watch as $, nextTick as T } from "vue";
|
|
2
2
|
import { B as q } from "./popover.Du6UI6Yh.js";
|
|
3
3
|
import { B as W } from "./typography.CdCYtxYj.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { D as K } from "./dropdown-default-textbox.BM9qsdzQ.js";
|
|
5
|
+
import { d as j } from "./debounce.DUTu11PS.js";
|
|
6
|
+
import { D as B, v as z, f as G } from "./date-input.BqBdAO1E.js";
|
|
6
7
|
import { g as u } from "./unique-id.XFfoKuc2.js";
|
|
7
8
|
import { u as S } from "./i18n.BQkEbtPM.js";
|
|
8
9
|
import { f as O } from "./date.DQaxR7TF.js";
|
|
9
|
-
import { l as I, a as
|
|
10
|
-
import { u as
|
|
10
|
+
import { l as I, a as H, b as J } from "./index.B_UZQ6qF.js";
|
|
11
|
+
import { u as Q } from "./use-form-layout-loading.D3lALhtC.js";
|
|
11
12
|
import "./index.Cl4_42j5.js";
|
|
12
13
|
import { a as p } from "./calendar.etLGotqH.js";
|
|
13
|
-
import { D as Q } from "./dropdown-default-textbox.BM9qsdzQ.js";
|
|
14
14
|
import { E as X, F as Z } from "./error-message.epR1WJH2.js";
|
|
15
15
|
import { B as ee } from "./directive.O3yEdalv.js";
|
|
16
16
|
import { n as ae } from "./_plugin-vue2_normalizer.CeySl7Fu.js";
|
|
17
17
|
import "../assets/date-picker.css";
|
|
18
18
|
const te = ({ datePickerValue: a, isDateIncorrect: e }) => {
|
|
19
19
|
var v;
|
|
20
|
-
const { locale: r, t: n } = S(), m = { de:
|
|
20
|
+
const { locale: r, t: n } = S(), m = { de: H, enUS: I, fr: J }, s = f((v = a.value) == null ? void 0 : v.toDateString());
|
|
21
21
|
return {
|
|
22
22
|
// Values
|
|
23
23
|
dateDisplayValue: D(() => e.value ? s.value : a.value ? O(a.value, B.FULL_DATE, {
|
|
@@ -49,7 +49,7 @@ const re = {
|
|
|
49
49
|
BentoPopover: q,
|
|
50
50
|
Calendar: p,
|
|
51
51
|
ErrorMessage: X,
|
|
52
|
-
DropdownInputDefault:
|
|
52
|
+
DropdownInputDefault: K,
|
|
53
53
|
FieldLabel: Z
|
|
54
54
|
},
|
|
55
55
|
directives: { BentoClickOutsideDirective: ee },
|
|
@@ -109,7 +109,7 @@ const re = {
|
|
|
109
109
|
},
|
|
110
110
|
emits: [i.INPUT],
|
|
111
111
|
setup(a, { emit: e }) {
|
|
112
|
-
const { t: r } = S(), n = u("bento-date-picker-container"), m = u("bento-date-picker-label"), s = u("bento-date-picker-description"), b = u("bento-date-picker-error"), y = u("bento-date-picker-date-error"), v = D(() => a.label || r("datePicker", { name: n })), c = f(null), w = f(null), l = f(!1), o = f(!1), { isReadOnly: R } =
|
|
112
|
+
const { t: r } = S(), n = u("bento-date-picker-container"), m = u("bento-date-picker-label"), s = u("bento-date-picker-description"), b = u("bento-date-picker-error"), y = u("bento-date-picker-date-error"), v = D(() => a.label || r("datePicker", { name: n })), c = f(null), w = f(null), l = f(!1), o = f(!1), { isReadOnly: R } = Q(E(a, "readonly"));
|
|
113
113
|
$(
|
|
114
114
|
() => a.disabled,
|
|
115
115
|
(t) => {
|
|
@@ -132,12 +132,12 @@ const re = {
|
|
|
132
132
|
}, A = async () => {
|
|
133
133
|
l.value && (l.value = !1, d.value = null), e(i.INPUT, null);
|
|
134
134
|
}, F = (t) => {
|
|
135
|
-
|
|
135
|
+
z(t);
|
|
136
136
|
}, P = (t) => {
|
|
137
137
|
if (t.length < 10)
|
|
138
138
|
return;
|
|
139
139
|
/^\d{4}-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])$/.test(t) && M(new Date(t)) ? (l.value = !1, e(i.INPUT, new Date(t))) : t && (l.value = !0, e(i.INPUT, null));
|
|
140
|
-
}, L =
|
|
140
|
+
}, L = j(P, ne);
|
|
141
141
|
return {
|
|
142
142
|
// Refs
|
|
143
143
|
inputContainerRef: w,
|
|
@@ -164,7 +164,7 @@ const re = {
|
|
|
164
164
|
openDatePicker: C,
|
|
165
165
|
onDateKeyDown: F,
|
|
166
166
|
onDateInputChange: (t) => {
|
|
167
|
-
d.value =
|
|
167
|
+
d.value = G(t), o.value ? L(d.value) : P(d.value);
|
|
168
168
|
},
|
|
169
169
|
// Keyboard navigation
|
|
170
170
|
onSpaceBarOrEnter: async (t) => {
|
|
@@ -194,4 +194,4 @@ export {
|
|
|
194
194
|
Be as B,
|
|
195
195
|
i as a
|
|
196
196
|
};
|
|
197
|
-
//# sourceMappingURL=date-picker.
|
|
197
|
+
//# sourceMappingURL=date-picker.DInJznhU.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-picker.CZ34YMMu.js","sources":["../../src/components/date-picker/composables/use-date-picker-single-calendar-text.ts","../../src/components/date-picker/date-picker.types.ts","../../src/components/date-picker/date-picker.vue"],"sourcesContent":["import { computed, ref } from 'vue';\nimport { de, enUS, fr } from 'date-fns/locale';\nimport { useI18n } from '@/utils/ts/i18n';\nimport { UseDateDisplayText } from './use-date-picker-single-calendar-text.types';\nimport { DateFormat } from '@/types';\nimport format from 'date-fns/format';\n\n/**\n * Composable that sets and formats the date to be displayed in the input box of a Single Date Picker\n * @param {Ref<Date>} option.datePickerValue Ref to the datePickerValue set in the DatePicker component\n * @param {Ref<boolean>} option.isDateIncorrect Indicates if the date is correct or not\n */\nexport const useDatePickerSingleCalendarText: UseDateDisplayText<Date> = ({ datePickerValue, isDateIncorrect }) => {\n const { locale, t } = useI18n();\n const locales = { de, enUS, fr };\n\n const textInputValue = ref(datePickerValue.value?.toDateString());\n\n const dateDisplayValue = computed(() => {\n // Display incorrect date when there's an error with the input\n if (isDateIncorrect.value) {\n return textInputValue.value;\n }\n\n // Display \"Select a date\" when there's no date selected or input\n if (!datePickerValue.value) {\n return t('selectDate') as string;\n }\n\n // Display the date in format \"dd MMM, yyyy (25 Jun, 2023)\" if there's a valid date selected\n return format(datePickerValue.value as Date, DateFormat.FULL_DATE, {\n locale: locales[locale.value.substring(0, 2)] || enUS,\n });\n });\n\n /**\n * Formats the \"dateToFormat\" date value with the yyyy-MM-dd format and sets it as \"formatTextInputDisplayValue\" value\n * @param {DATE} dateToFormat - Date to be assigned and formatted\n */\n const formatTextInputDisplayValue = (dateToFormat: Date = datePickerValue.value) => {\n // If date is incorrect, leave the textInputValue intact\n if (isDateIncorrect.value) {\n return;\n }\n\n textInputValue.value = dateToFormat\n ? format(dateToFormat, DateFormat.NUMERIC_DATE_YEAR_FIRST, {\n locale: locales[locale.value.substring(0, 2)] || enUS,\n })\n : null;\n };\n\n return {\n // Values\n dateDisplayValue,\n textInputValue,\n\n // Methods\n formatTextInputDisplayValue,\n };\n};\n","export { CalendarFirstDayOfWeek as BentoDatePickerFirstDayOfWeek } from '@/internal';\nexport type {\n CalendarIsDateDisabled as BentoDatePickerIsDateDisabled,\n CalendarSingleDateValue as BentoDatePickerValue,\n} from '@/internal';\n\nexport enum BentoDatePickerEvent {\n INPUT = 'input',\n}\n","<!-- TODO: Remove aria props as these are part of JSX elements /vue/types/jsx.d.ts -->\n<!-- eslint-disable vue/attribute-hyphenation -->\n<template>\n <div\n v-bento-click-outside-directive=\"closeDatePicker\"\n class=\"b-date-picker\"\n @keydown.space.capture=\"onSpaceBarOrEnter\"\n @keydown.enter.capture=\"onSpaceBarOrEnter\"\n >\n <!-- Label -->\n <field-label\n v-if=\"label\"\n :id=\"labelId\"\n :label=\"label\"\n :tooltip-text=\"tooltipText\"\n :optional=\"optional\"\n :required=\"required\"\n />\n\n <!-- Input -->\n <div>\n <dropdown-input-default\n ref=\"inputContainerRef\"\n always-combobox-is-input\n :ariaControls=\"datePickerContainerId\"\n :ariaExpanded=\"isDatePickerOpen\"\n :aria-labelledby=\"label ? labelId : null\"\n :aria-describedby=\"ariaDescribedBy\"\n :disabled=\"disabled\"\n dynamic-filtering\n :is-invalid=\"!!errorMessage || !!dateErrorText\"\n :open=\"isDatePickerOpen\"\n :value=\"textInputValue\"\n :display-value=\"dateDisplayValue\"\n :debounce-time=\"0\"\n :readonly=\"isReadOnly\"\n @input=\"onDateInputChange\"\n @open=\"openDatePicker\"\n @keydown=\"onDateKeyDown\"\n @clear=\"clearDatePickerValue\"\n @close=\"closeDatePicker\"\n />\n </div>\n\n <!-- Error Messages -->\n <error-message\n v-if=\"dateErrorText\"\n :id=\"dateErrorId\"\n :error-message=\"dateErrorText\"\n class=\"b-date-picker__error-message\"\n />\n <error-message\n v-if=\"errorMessage\"\n :id=\"errorId\"\n :error-message=\"errorMessage\"\n class=\"b-date-picker__error-message\"\n />\n\n <!-- Description -->\n <bento-typography\n v-if=\"description\"\n class=\"b-date-picker__description\"\n :class=\"descriptionConditionalClasses\"\n el=\"span\"\n >\n {{ description }}\n </bento-typography>\n\n <!-- Calendar container -->\n <bento-popover\n v-if=\"inputContainerRef\"\n :id=\"datePickerContainerId\"\n class=\"b-date-picker__container\"\n role=\"dialog\"\n :open=\"isDatePickerOpen\"\n :target-element=\"inputContainerRef\"\n :disable-focus-trap=\"true\"\n :aria-label=\"popoverAriaLabel\"\n :aria-modal=\"true\"\n position=\"bottom-start\"\n fit-content\n >\n <calendar\n ref=\"calendarContainerRef\"\n :first-day-of-week=\"firstDayOfWeek\"\n :is-date-disabled=\"isDateDisabled\"\n :number-of-months=\"1\"\n :value=\"value\"\n :min=\"min\"\n :max=\"max\"\n @input=\"onDateSelected\"\n />\n </bento-popover>\n </div>\n</template>\n\n<script lang=\"ts\">\n import { computed, defineComponent, nextTick, PropType, Ref, ref, toRef, watch } from 'vue';\n\n // Components\n import { BentoPopover } from '@/components/popover';\n import { BentoTypography } from '../typography';\n import { Calendar, ErrorMessage, FieldLabel } from '@/internal';\n import { DropdownInputDefault } from '@/components/dropdown/components';\n\n // Utils\n import { debounce } from '@/utils/ts/debounce';\n import { formatDateInputValue, validateDateInput } from '@/utils/ts/date-input';\n import { generateUid } from '@/utils/ts/unique-id';\n import { useI18n } from '@/utils/ts/i18n';\n\n // Composables\n import { useDatePickerSingleCalendarText } from './composables/use-date-picker-single-calendar-text';\n import { useFormLayoutFieldLoading } from '@/composables';\n\n // Directive\n import { BentoClickOutsideDirective } from '@/directives';\n\n // Types\n import { BentoDatePickerEvent, BentoDatePickerValue } from './date-picker.types';\n\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n const DEBOUNCE_TIME = 1000;\n\n /**\n * Date picker selector.\n *\n * @example\n * import { BentoDatePicker } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoDatePicker },\n * template: `\n * <bento-date-picker\n * label=\"Label\"\n * description=\"Supporting text\"\n * required\n * optional\n * disabled\n * @input=\"onDateChanged\"\n * v-model=\"selectedDate\"\n * />\n * `,\n * setup() {\n * const selectedDate = ref(new Date()); // reactive({ startDate: new Date(), endDate: new Date() })\n * return {\n * selectedDate,\n * }\n * }\n * }\n */\n export default defineComponent({\n i18n: { messages },\n name: 'bento-date-picker',\n components: {\n BentoTypography,\n BentoPopover,\n Calendar,\n ErrorMessage,\n DropdownInputDefault,\n FieldLabel,\n },\n directives: { BentoClickOutsideDirective },\n props: {\n /**\n * Descriptive supporting text visbile underneath the dropdown.\n */\n description: { type: String, default: undefined },\n\n /**\n * Disables dropdown functionality.\n */\n disabled: { type: Boolean, default: false },\n\n /**\n * Displays component in an error state with an error message\n */\n errorMessage: { type: String, default: null },\n\n /**\n * Allows you to set the first day of the week. 0 is sunday, 1 is monday, 6 is saturday\n */\n firstDayOfWeek: Calendar.props.firstDayOfWeek,\n\n /**\n * Indicate if a date should be disabled or not\n */\n isDateDisabled: Calendar.props.isDateDisabled,\n\n /**\n * Sets a minimum limit for selectable dates - dates before `min` will not be selectable\n */\n min: Calendar.props.min,\n\n /**\n * Sets a maximum limit for selectable dates - dates after `max` will not be selectable\n */\n max: Calendar.props.max,\n\n /**\n * Text that is displayed as a label above the element.\n */\n label: { type: String, default: undefined },\n\n /**\n * Highlights the dropdown is optional.\n */\n optional: { type: Boolean, default: false },\n\n /**\n * The Boolean readonly property, when present, makes the element not mutable, meaning the user can not edit the date picker.\n */\n readonly: { type: Boolean, default: false },\n\n /**\n * Highlights the dropdown is required.\n */\n required: { type: Boolean, default: false },\n\n /**\n * Adds a info icon next to the label to display the passed tooltip message.\n */\n tooltipText: { type: String, default: null },\n\n /**\n * Selected date\n */\n value: { type: [Date, Object] as PropType<BentoDatePickerValue>, default: null },\n },\n emits: [BentoDatePickerEvent.INPUT],\n setup(props, { emit }) {\n const { t } = useI18n<{ message: MessageSchema }>({ messages });\n const datePickerContainerId = generateUid('bento-date-picker-container');\n const labelId = generateUid('bento-date-picker-label');\n const descriptionId = generateUid('bento-date-picker-description');\n const errorId = generateUid('bento-date-picker-error');\n const dateErrorId = generateUid('bento-date-picker-date-error');\n const popoverAriaLabel = computed(() => props.label || t('datePicker', { name: datePickerContainerId }));\n\n // Refs\n const calendarContainerRef = ref(null);\n const inputContainerRef = ref(null);\n\n // Values\n const isDateIncorrect = ref(false);\n const isDatePickerOpen = ref(false);\n const { isReadOnly } = useFormLayoutFieldLoading(toRef(props, 'readonly'));\n\n watch(\n () => props.disabled,\n disabled => {\n // Close date picker popover if it's opened when it's disabled\n if (disabled && isDatePickerOpen.value) {\n isDatePickerOpen.value = false;\n }\n }\n );\n\n const { dateDisplayValue, textInputValue, formatTextInputDisplayValue } = useDatePickerSingleCalendarText({\n datePickerValue: toRef(props, 'value') as Ref<Date>,\n isDateIncorrect,\n });\n\n const dateErrorText = computed(() => {\n if (\n props.isDateDisabled &&\n props.isDateDisabled(new Date(textInputValue.value)) &&\n !isDatePickerOpen.value\n ) {\n return t('selectedDateIsNotAvailable');\n }\n\n return isDateIncorrect.value ? t('provideDateInAFormat') : null;\n });\n\n const descriptionConditionalClasses = computed(() => ({\n 'b-date-picker__description--error': props.errorMessage || dateErrorText.value,\n }));\n\n const ariaDescribedBy = computed(\n () =>\n `${props.description ? descriptionId : ''} ${props.errorMessage ? errorId : ''} ${\n dateErrorText.value ? dateErrorId : ''\n }`.trim() || null\n );\n\n const isDateEnabled = (date: Date) => {\n // Check if date is between min/max bounds, if there are any\n if ((props.min && date <= props.min) || (props.max && date >= props.max)) {\n return false;\n }\n\n // Check if function is set, otherwise all dates are enabled\n if (props.isDateDisabled) {\n return !props.isDateDisabled(date);\n }\n\n return true;\n };\n\n const closeDatePicker = () => {\n isDatePickerOpen.value = false;\n };\n\n const openDatePicker = () => {\n isDatePickerOpen.value = true;\n\n formatTextInputDisplayValue();\n };\n\n const onDateSelected = (selectedDate: Date) => {\n // Reset the error state when a valid date is selected\n isDateIncorrect.value = false;\n\n closeDatePicker();\n emit(BentoDatePickerEvent.INPUT, selectedDate);\n };\n\n const clearDatePickerValue = async () => {\n if (isDateIncorrect.value) {\n isDateIncorrect.value = false;\n textInputValue.value = null;\n }\n emit(BentoDatePickerEvent.INPUT, null);\n };\n\n const onDateKeyDown = (event: KeyboardEvent) => {\n validateDateInput(event);\n };\n\n const validateDate = (stringDate: string) => {\n // Validate only if the date is complete\n if (stringDate.length < 10) {\n return;\n }\n\n // Checks for YYYY-MM-DD format\n const dateRegex = /^\\d{4}-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])$/;\n const isValidDate = dateRegex.test(stringDate) && isDateEnabled(new Date(stringDate));\n if (isValidDate) {\n isDateIncorrect.value = false;\n emit(BentoDatePickerEvent.INPUT, new Date(stringDate));\n } else if (stringDate) {\n // Only set to true if the value exists (not null/undefined)\n isDateIncorrect.value = true;\n emit(BentoDatePickerEvent.INPUT, null);\n }\n };\n\n const validateDateDebounced = debounce(validateDate, DEBOUNCE_TIME);\n\n const onDateInputChange = (stringDate: string) => {\n textInputValue.value = formatDateInputValue(stringDate);\n // If we are closing the date picker, we should validate (and emit date inputs) immediately so the user doesn't have to wait for the debounce time.\n if (isDatePickerOpen.value) {\n validateDateDebounced(textInputValue.value);\n } else {\n validateDate(textInputValue.value);\n }\n };\n\n /**\n * Space bar and Enter keyDown event handler.\n *\n * * Opens the date picker dialog on the first keydown.\n * * Move focus to selected date, i.e., the date displayed in the date input text field. If no date has been selected, places focus on the current date.\n * @param {KeyboardEvent} event Event being triggered\n */\n const onSpaceBarOrEnter = async (event: KeyboardEvent) => {\n if (isDatePickerOpen.value) {\n return;\n }\n event.preventDefault();\n\n openDatePicker();\n\n // Wait for the date picker dialog to open\n await nextTick();\n\n // Set current date (today) if no date is selected\n if (!props.value) {\n // Format the opened date picker date to YYYY-MM-DD\n formatTextInputDisplayValue(new Date());\n emit(BentoDatePickerEvent.INPUT, new Date());\n\n // Wait for new value to be set with the emit\n await nextTick();\n }\n\n // Focus on date\n calendarContainerRef.value?.$refs.calendarRef[0].focusOnDate(props.value);\n };\n\n return {\n // Refs\n inputContainerRef,\n calendarContainerRef,\n\n // Values,\n dateDisplayValue,\n datePickerContainerId,\n descriptionConditionalClasses,\n isDateIncorrect,\n isDatePickerOpen,\n isReadOnly,\n dateErrorText,\n labelId,\n descriptionId,\n errorId,\n dateErrorId,\n popoverAriaLabel,\n ariaDescribedBy,\n textInputValue,\n\n // Events\n closeDatePicker,\n clearDatePickerValue,\n onDateSelected,\n openDatePicker,\n onDateKeyDown,\n onDateInputChange,\n\n // Keyboard navigation\n onSpaceBarOrEnter,\n };\n },\n });\n</script>\n\n<style lang=\"scss\" scoped src=\"./date-picker.scss\" />\n"],"names":["useDatePickerSingleCalendarText","datePickerValue","isDateIncorrect","locale$3","t","useI18n","locales","locale$1","locale","locale$2","textInputValue","ref","_a","computed","format","DateFormat","dateToFormat","BentoDatePickerEvent","BentoDatePickerEvent2","DEBOUNCE_TIME","_sfc_main","defineComponent","messages","BentoTypography","BentoPopover","Calendar","ErrorMessage","DropdownInputDefault","FieldLabel","BentoClickOutsideDirective","props","emit","datePickerContainerId","generateUid","labelId","descriptionId","errorId","dateErrorId","popoverAriaLabel","calendarContainerRef","inputContainerRef","isDatePickerOpen","isReadOnly","useFormLayoutFieldLoading","toRef","watch","disabled","dateDisplayValue","formatTextInputDisplayValue","dateErrorText","descriptionConditionalClasses","ariaDescribedBy","isDateEnabled","date","closeDatePicker","openDatePicker","onDateSelected","selectedDate","clearDatePickerValue","onDateKeyDown","event","validateDateInput","validateDate","stringDate","validateDateDebounced","debounce","formatDateInputValue","nextTick"],"mappings":";;;;;;;;;;;;;;;;;AAYO,MAAAA,KAAA,CAAA,EAAA,iBAAAC,GAAA,iBAAAC,EAAA,MAAA;;AACH,QAAA,EAAA,QAAAC,GAAA,GAAAC,EAAA,IAAAC,EAAA,GACAC,IAAA,EAAA,IAAAC,GAAA,MAAAC,GAAA,IAAAC,EAAA,GAEAC,IAAAC,GAAAC,IAAAX,EAAA,UAAA,gBAAAW,EAAA,cAAA;AAoC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AA,KAAA8C,CAAA,CAAA,KAAAA,MAGA7D,EAAA,QAAA,IACA6B,EAAAd,EAAA,OAAA,IAAA;AAAA,IACA,GAGA+C,IAAAC,EAAAH,GAAA3C,EAAA;AA4CA,WAAA;AAAA;AAAA,MAAA,mBAAAqB;AAAA,MAEA,sBAAAD;AAAA;AAAA,MACA,kBAAAQ;AAAA,MAGA,uBAAAf;AAAA,MACA,+BAAAkB;AAAA,MACA,iBAAAhD;AAAA,MACA,kBAAAuC;AAAA,MACA,YAAAC;AAAA,MACA,eAAAO;AAAA,MACA,SAAAf;AAAA,MACA,eAAAC;AAAA,MACA,SAAAC;AAAA,MACA,aAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,iBAAAa;AAAA,MACA,gBAAAzC;AAAA;AAAA,MACA,iBAAA4C;AAAA,MAGA,sBAAAI;AAAA,MACA,gBAAAF;AAAA,MACA,gBAAAD;AAAA,MACA,eAAAI;AAAA,MACA,mBApEA,CAAAI,MAAA;AACA,QAAArD,EAAA,QAAAwD,EAAAH,CAAA,GAEAtB,EAAA,QACAuB,EAAAtD,EAAA,KAAA,IAEAoD,EAAApD,EAAA,KAAA;AAAA,MACA;AAAA;AAAA,MA8DA,mBApDA,OAAAkD,MAAA;;AACA,QAAAnB,EAAA,UAGAmB,EAAA,eAAA,GAEAL,EAAA,GAGA,MAAAY,EAAA,GAGArC,EAAA,UAEAkB,EAAA,oBAAA,KAAA,CAAA,GACAjB,EAAAd,EAAA,OAAA,oBAAA,KAAA,CAAA,GAGA,MAAAkD,EAAA,KAIAvD,IAAA2B,EAAA,UAAA,QAAA3B,EAAA,MAAA,YAAA,GAAA,YAAAkB,EAAA;AAAA,MAAA;AAAA,IAiCA;AAAA,EACA;AAEA,CAAA;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"date-picker.DInJznhU.js","sources":["../../src/components/date-picker/composables/use-date-picker-single-calendar-text.ts","../../src/components/date-picker/date-picker.types.ts","../../src/components/date-picker/date-picker.vue"],"sourcesContent":["import { computed, ref } from 'vue';\nimport { de, enUS, fr } from 'date-fns/locale';\nimport { useI18n } from '@/utils/ts/i18n';\nimport { UseDateDisplayText } from './use-date-picker-single-calendar-text.types';\nimport { DateFormat } from '@/types';\nimport format from 'date-fns/format';\n\n/**\n * Composable that sets and formats the date to be displayed in the input box of a Single Date Picker\n * @param {Ref<Date>} option.datePickerValue Ref to the datePickerValue set in the DatePicker component\n * @param {Ref<boolean>} option.isDateIncorrect Indicates if the date is correct or not\n */\nexport const useDatePickerSingleCalendarText: UseDateDisplayText<Date> = ({ datePickerValue, isDateIncorrect }) => {\n const { locale, t } = useI18n();\n const locales = { de, enUS, fr };\n\n const textInputValue = ref(datePickerValue.value?.toDateString());\n\n const dateDisplayValue = computed(() => {\n // Display incorrect date when there's an error with the input\n if (isDateIncorrect.value) {\n return textInputValue.value;\n }\n\n // Display \"Select a date\" when there's no date selected or input\n if (!datePickerValue.value) {\n return t('selectDate') as string;\n }\n\n // Display the date in format \"dd MMM, yyyy (25 Jun, 2023)\" if there's a valid date selected\n return format(datePickerValue.value as Date, DateFormat.FULL_DATE, {\n locale: locales[locale.value.substring(0, 2)] || enUS,\n });\n });\n\n /**\n * Formats the \"dateToFormat\" date value with the yyyy-MM-dd format and sets it as \"formatTextInputDisplayValue\" value\n * @param {DATE} dateToFormat - Date to be assigned and formatted\n */\n const formatTextInputDisplayValue = (dateToFormat: Date = datePickerValue.value) => {\n // If date is incorrect, leave the textInputValue intact\n if (isDateIncorrect.value) {\n return;\n }\n\n textInputValue.value = dateToFormat\n ? format(dateToFormat, DateFormat.NUMERIC_DATE_YEAR_FIRST, {\n locale: locales[locale.value.substring(0, 2)] || enUS,\n })\n : null;\n };\n\n return {\n // Values\n dateDisplayValue,\n textInputValue,\n\n // Methods\n formatTextInputDisplayValue,\n };\n};\n","export { CalendarFirstDayOfWeek as BentoDatePickerFirstDayOfWeek } from '@/internal';\nexport type {\n CalendarIsDateDisabled as BentoDatePickerIsDateDisabled,\n CalendarSingleDateValue as BentoDatePickerValue,\n} from '@/internal';\n\nexport enum BentoDatePickerEvent {\n INPUT = 'input',\n}\n","<!-- TODO: Remove aria props as these are part of JSX elements /vue/types/jsx.d.ts -->\n<!-- eslint-disable vue/attribute-hyphenation -->\n<template>\n <div\n v-bento-click-outside-directive=\"closeDatePicker\"\n class=\"b-date-picker\"\n @keydown.space.capture=\"onSpaceBarOrEnter\"\n @keydown.enter.capture=\"onSpaceBarOrEnter\"\n >\n <!-- Label -->\n <field-label\n v-if=\"label\"\n :id=\"labelId\"\n :label=\"label\"\n :tooltip-text=\"tooltipText\"\n :optional=\"optional\"\n :required=\"required\"\n />\n\n <!-- Input -->\n <div>\n <dropdown-input-default\n ref=\"inputContainerRef\"\n always-combobox-is-input\n :ariaControls=\"datePickerContainerId\"\n :ariaExpanded=\"isDatePickerOpen\"\n :aria-labelledby=\"label ? labelId : null\"\n :aria-describedby=\"ariaDescribedBy\"\n :disabled=\"disabled\"\n dynamic-filtering\n :is-invalid=\"!!errorMessage || !!dateErrorText\"\n :open=\"isDatePickerOpen\"\n :value=\"textInputValue\"\n :display-value=\"dateDisplayValue\"\n :debounce-time=\"0\"\n :readonly=\"isReadOnly\"\n @input=\"onDateInputChange\"\n @open=\"openDatePicker\"\n @keydown=\"onDateKeyDown\"\n @clear=\"clearDatePickerValue\"\n @close=\"closeDatePicker\"\n />\n </div>\n\n <!-- Error Messages -->\n <error-message\n v-if=\"dateErrorText\"\n :id=\"dateErrorId\"\n :error-message=\"dateErrorText\"\n class=\"b-date-picker__error-message\"\n />\n <error-message\n v-if=\"errorMessage\"\n :id=\"errorId\"\n :error-message=\"errorMessage\"\n class=\"b-date-picker__error-message\"\n />\n\n <!-- Description -->\n <bento-typography\n v-if=\"description\"\n class=\"b-date-picker__description\"\n :class=\"descriptionConditionalClasses\"\n el=\"span\"\n >\n {{ description }}\n </bento-typography>\n\n <!-- Calendar container -->\n <bento-popover\n v-if=\"inputContainerRef\"\n :id=\"datePickerContainerId\"\n class=\"b-date-picker__container\"\n role=\"dialog\"\n :open=\"isDatePickerOpen\"\n :target-element=\"inputContainerRef\"\n :disable-focus-trap=\"true\"\n :aria-label=\"popoverAriaLabel\"\n :aria-modal=\"true\"\n position=\"bottom-start\"\n fit-content\n >\n <calendar\n ref=\"calendarContainerRef\"\n :first-day-of-week=\"firstDayOfWeek\"\n :is-date-disabled=\"isDateDisabled\"\n :number-of-months=\"1\"\n :value=\"value\"\n :min=\"min\"\n :max=\"max\"\n @input=\"onDateSelected\"\n />\n </bento-popover>\n </div>\n</template>\n\n<script lang=\"ts\">\n import { computed, defineComponent, nextTick, PropType, Ref, ref, toRef, watch } from 'vue';\n\n // Components\n import { BentoPopover } from '@/components/popover';\n import { BentoTypography } from '../typography';\n import { Calendar, ErrorMessage, FieldLabel } from '@/internal';\n import { DropdownInputDefault } from '@/components/dropdown/components';\n\n // Utils\n import { debounce } from '@/utils/ts/debounce';\n import { formatDateInputValue, validateDateInput } from '@/utils/ts/date-input';\n import { generateUid } from '@/utils/ts/unique-id';\n import { useI18n } from '@/utils/ts/i18n';\n\n // Composables\n import { useDatePickerSingleCalendarText } from './composables/use-date-picker-single-calendar-text';\n import { useFormLayoutFieldLoading } from '@/composables';\n\n // Directive\n import { BentoClickOutsideDirective } from '@/directives';\n\n // Types\n import { BentoDatePickerEvent, BentoDatePickerValue } from './date-picker.types';\n\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n const DEBOUNCE_TIME = 1000;\n\n /**\n * Date picker selector.\n *\n * @example\n * import { BentoDatePicker } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoDatePicker },\n * template: `\n * <bento-date-picker\n * label=\"Label\"\n * description=\"Supporting text\"\n * required\n * optional\n * disabled\n * @input=\"onDateChanged\"\n * v-model=\"selectedDate\"\n * />\n * `,\n * setup() {\n * const selectedDate = ref(new Date()); // reactive({ startDate: new Date(), endDate: new Date() })\n * return {\n * selectedDate,\n * }\n * }\n * }\n */\n export default defineComponent({\n i18n: { messages },\n name: 'bento-date-picker',\n components: {\n BentoTypography,\n BentoPopover,\n Calendar,\n ErrorMessage,\n DropdownInputDefault,\n FieldLabel,\n },\n directives: { BentoClickOutsideDirective },\n props: {\n /**\n * Descriptive supporting text visbile underneath the dropdown.\n */\n description: { type: String, default: undefined },\n\n /**\n * Disables dropdown functionality.\n */\n disabled: { type: Boolean, default: false },\n\n /**\n * Displays component in an error state with an error message\n */\n errorMessage: { type: String, default: null },\n\n /**\n * Allows you to set the first day of the week. 0 is sunday, 1 is monday, 6 is saturday\n */\n firstDayOfWeek: Calendar.props.firstDayOfWeek,\n\n /**\n * Indicate if a date should be disabled or not\n */\n isDateDisabled: Calendar.props.isDateDisabled,\n\n /**\n * Sets a minimum limit for selectable dates - dates before `min` will not be selectable\n */\n min: Calendar.props.min,\n\n /**\n * Sets a maximum limit for selectable dates - dates after `max` will not be selectable\n */\n max: Calendar.props.max,\n\n /**\n * Text that is displayed as a label above the element.\n */\n label: { type: String, default: undefined },\n\n /**\n * Highlights the dropdown is optional.\n */\n optional: { type: Boolean, default: false },\n\n /**\n * The Boolean readonly property, when present, makes the element not mutable, meaning the user can not edit the date picker.\n */\n readonly: { type: Boolean, default: false },\n\n /**\n * Highlights the dropdown is required.\n */\n required: { type: Boolean, default: false },\n\n /**\n * Adds a info icon next to the label to display the passed tooltip message.\n */\n tooltipText: { type: String, default: null },\n\n /**\n * Selected date\n */\n value: { type: [Date, Object] as PropType<BentoDatePickerValue>, default: null },\n },\n emits: [BentoDatePickerEvent.INPUT],\n setup(props, { emit }) {\n const { t } = useI18n<{ message: MessageSchema }>({ messages });\n const datePickerContainerId = generateUid('bento-date-picker-container');\n const labelId = generateUid('bento-date-picker-label');\n const descriptionId = generateUid('bento-date-picker-description');\n const errorId = generateUid('bento-date-picker-error');\n const dateErrorId = generateUid('bento-date-picker-date-error');\n const popoverAriaLabel = computed(() => props.label || t('datePicker', { name: datePickerContainerId }));\n\n // Refs\n const calendarContainerRef = ref(null);\n const inputContainerRef = ref(null);\n\n // Values\n const isDateIncorrect = ref(false);\n const isDatePickerOpen = ref(false);\n const { isReadOnly } = useFormLayoutFieldLoading(toRef(props, 'readonly'));\n\n watch(\n () => props.disabled,\n disabled => {\n // Close date picker popover if it's opened when it's disabled\n if (disabled && isDatePickerOpen.value) {\n isDatePickerOpen.value = false;\n }\n }\n );\n\n const { dateDisplayValue, textInputValue, formatTextInputDisplayValue } = useDatePickerSingleCalendarText({\n datePickerValue: toRef(props, 'value') as Ref<Date>,\n isDateIncorrect,\n });\n\n const dateErrorText = computed(() => {\n if (\n props.isDateDisabled &&\n props.isDateDisabled(new Date(textInputValue.value)) &&\n !isDatePickerOpen.value\n ) {\n return t('selectedDateIsNotAvailable');\n }\n\n return isDateIncorrect.value ? t('provideDateInAFormat') : null;\n });\n\n const descriptionConditionalClasses = computed(() => ({\n 'b-date-picker__description--error': props.errorMessage || dateErrorText.value,\n }));\n\n const ariaDescribedBy = computed(\n () =>\n `${props.description ? descriptionId : ''} ${props.errorMessage ? errorId : ''} ${\n dateErrorText.value ? dateErrorId : ''\n }`.trim() || null\n );\n\n const isDateEnabled = (date: Date) => {\n // Check if date is between min/max bounds, if there are any\n if ((props.min && date <= props.min) || (props.max && date >= props.max)) {\n return false;\n }\n\n // Check if function is set, otherwise all dates are enabled\n if (props.isDateDisabled) {\n return !props.isDateDisabled(date);\n }\n\n return true;\n };\n\n const closeDatePicker = () => {\n isDatePickerOpen.value = false;\n };\n\n const openDatePicker = () => {\n isDatePickerOpen.value = true;\n\n formatTextInputDisplayValue();\n };\n\n const onDateSelected = (selectedDate: Date) => {\n // Reset the error state when a valid date is selected\n isDateIncorrect.value = false;\n\n closeDatePicker();\n emit(BentoDatePickerEvent.INPUT, selectedDate);\n };\n\n const clearDatePickerValue = async () => {\n if (isDateIncorrect.value) {\n isDateIncorrect.value = false;\n textInputValue.value = null;\n }\n emit(BentoDatePickerEvent.INPUT, null);\n };\n\n const onDateKeyDown = (event: KeyboardEvent) => {\n validateDateInput(event);\n };\n\n const validateDate = (stringDate: string) => {\n // Validate only if the date is complete\n if (stringDate.length < 10) {\n return;\n }\n\n // Checks for YYYY-MM-DD format\n const dateRegex = /^\\d{4}-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])$/;\n const isValidDate = dateRegex.test(stringDate) && isDateEnabled(new Date(stringDate));\n if (isValidDate) {\n isDateIncorrect.value = false;\n emit(BentoDatePickerEvent.INPUT, new Date(stringDate));\n } else if (stringDate) {\n // Only set to true if the value exists (not null/undefined)\n isDateIncorrect.value = true;\n emit(BentoDatePickerEvent.INPUT, null);\n }\n };\n\n const validateDateDebounced = debounce(validateDate, DEBOUNCE_TIME);\n\n const onDateInputChange = (stringDate: string) => {\n textInputValue.value = formatDateInputValue(stringDate);\n // If we are closing the date picker, we should validate (and emit date inputs) immediately so the user doesn't have to wait for the debounce time.\n if (isDatePickerOpen.value) {\n validateDateDebounced(textInputValue.value);\n } else {\n validateDate(textInputValue.value);\n }\n };\n\n /**\n * Space bar and Enter keyDown event handler.\n *\n * * Opens the date picker dialog on the first keydown.\n * * Move focus to selected date, i.e., the date displayed in the date input text field. If no date has been selected, places focus on the current date.\n * @param {KeyboardEvent} event Event being triggered\n */\n const onSpaceBarOrEnter = async (event: KeyboardEvent) => {\n if (isDatePickerOpen.value) {\n return;\n }\n event.preventDefault();\n\n openDatePicker();\n\n // Wait for the date picker dialog to open\n await nextTick();\n\n // Set current date (today) if no date is selected\n if (!props.value) {\n // Format the opened date picker date to YYYY-MM-DD\n formatTextInputDisplayValue(new Date());\n emit(BentoDatePickerEvent.INPUT, new Date());\n\n // Wait for new value to be set with the emit\n await nextTick();\n }\n\n // Focus on date\n calendarContainerRef.value?.$refs.calendarRef[0].focusOnDate(props.value);\n };\n\n return {\n // Refs\n inputContainerRef,\n calendarContainerRef,\n\n // Values,\n dateDisplayValue,\n datePickerContainerId,\n descriptionConditionalClasses,\n isDateIncorrect,\n isDatePickerOpen,\n isReadOnly,\n dateErrorText,\n labelId,\n descriptionId,\n errorId,\n dateErrorId,\n popoverAriaLabel,\n ariaDescribedBy,\n textInputValue,\n\n // Events\n closeDatePicker,\n clearDatePickerValue,\n onDateSelected,\n openDatePicker,\n onDateKeyDown,\n onDateInputChange,\n\n // Keyboard navigation\n onSpaceBarOrEnter,\n };\n },\n });\n</script>\n\n<style lang=\"scss\" scoped src=\"./date-picker.scss\" />\n"],"names":["useDatePickerSingleCalendarText","datePickerValue","isDateIncorrect","locale$3","t","useI18n","locales","locale$1","locale","locale$2","textInputValue","ref","_a","computed","format","DateFormat","dateToFormat","BentoDatePickerEvent","BentoDatePickerEvent2","DEBOUNCE_TIME","_sfc_main","defineComponent","messages","BentoTypography","BentoPopover","Calendar","ErrorMessage","DropdownInputDefault","FieldLabel","BentoClickOutsideDirective","props","emit","datePickerContainerId","generateUid","labelId","descriptionId","errorId","dateErrorId","popoverAriaLabel","calendarContainerRef","inputContainerRef","isDatePickerOpen","isReadOnly","useFormLayoutFieldLoading","toRef","watch","disabled","dateDisplayValue","formatTextInputDisplayValue","dateErrorText","descriptionConditionalClasses","ariaDescribedBy","isDateEnabled","date","closeDatePicker","openDatePicker","onDateSelected","selectedDate","clearDatePickerValue","onDateKeyDown","event","validateDateInput","validateDate","stringDate","validateDateDebounced","debounce","formatDateInputValue","nextTick"],"mappings":";;;;;;;;;;;;;;;;;AAYO,MAAAA,KAAA,CAAA,EAAA,iBAAAC,GAAA,iBAAAC,EAAA,MAAA;;AACH,QAAA,EAAA,QAAAC,GAAA,GAAAC,EAAA,IAAAC,EAAA,GACAC,IAAA,EAAA,IAAAC,GAAA,MAAAC,GAAA,IAAAC,EAAA,GAEAC,IAAAC,GAAAC,IAAAX,EAAA,UAAA,gBAAAW,EAAA,cAAA;AAoCA,SAAA;AAAA;AAAA,IAAO,kBAlCPC,EAAA,MAEIX,EAAA,QACIQ,EAAA,QAIJT,EAAA,QAKAa,EAAAb,EAAA,OAAAc,EAAA,WAAA;AAAA,MAAmE,QAAAT,EA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;AAAA;AAAA,MAAA,mBAAAqB;AAAA,MAEA,sBAAAD;AAAA;AAAA,MACA,kBAAAQ;AAAA,MAGA,uBAAAf;AAAA,MACA,+BAAAkB;AAAA,MACA,iBAAAhD;AAAA,MACA,kBAAAuC;AAAA,MACA,YAAAC;AAAA,MACA,eAAAO;AAAA,MACA,SAAAf;AAAA,MACA,eAAAC;AAAA,MACA,SAAAC;AAAA,MACA,aAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,iBAAAa;AAAA,MACA,gBAAAzC;AAAA;AAAA,MACA,iBAAA4C;AAAA,MAGA,sBAAAI;AAAA,MACA,gBAAAF;AAAA,MACA,gBAAAD;AAAA,MACA,eAAAI;AAAA,MACA,mBApEA,CAAAI,MAAA;AACA,QAAArD,EAAA,QAAAwD,EAAAH,CAAA,GAEAtB,EAAA,QACAuB,EAAAtD,EAAA,KAAA,IAEAoD,EAAApD,EAAA,KAAA;AAAA,MACA;AAAA;AAAA,MA8DA,mBApDA,OAAAkD,MAAA;;AACA,QAAAnB,EAAA,UAGAmB,EAAA,eAAA,GAEAL,EAAA,GAGA,MAAAY,EAAA,GAGArC,EAAA,UAEAkB,EAAA,oBAAA,KAAA,CAAA,GACAjB,EAAAd,EAAA,OAAA,oBAAA,KAAA,CAAA,GAGA,MAAAkD,EAAA,KAIAvD,IAAA2B,EAAA,UAAA,QAAA3B,EAAA,MAAA,YAAA,GAAA,YAAAkB,EAAA;AAAA,MAAA;AAAA,IAiCA;AAAA,EACA;AAEA,CAAA;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { reactive as z, defineComponent as ye, computed as I, ref as U, onMounted as Ye, toRaw as Ve, toRef as de, watch as Ge } from "vue";
|
|
2
2
|
import { B as He } from "./popover.Du6UI6Yh.js";
|
|
3
3
|
import { B as Ie } from "./typography.CdCYtxYj.js";
|
|
4
|
+
import { D as We } from "./dropdown-default-textbox.BM9qsdzQ.js";
|
|
4
5
|
import { g as G } from "./unique-id.XFfoKuc2.js";
|
|
5
6
|
import { u as te } from "./i18n.BQkEbtPM.js";
|
|
6
7
|
import { t as ae, f as W } from "./date.DQaxR7TF.js";
|
|
7
8
|
import { r as q, t as J, l as M, a as ne, b as re } from "./index.B_UZQ6qF.js";
|
|
8
|
-
import { f as ue, v as
|
|
9
|
-
import { u as
|
|
9
|
+
import { f as ue, v as qe, D as _ } from "./date-input.BqBdAO1E.js";
|
|
10
|
+
import { u as je } from "./use-form-layout-loading.D3lALhtC.js";
|
|
10
11
|
import "./index.Cl4_42j5.js";
|
|
11
|
-
import { B as
|
|
12
|
-
import { B as
|
|
13
|
-
import { B as
|
|
12
|
+
import { B as Ke } from "./input-field.Czp_0nIh.js";
|
|
13
|
+
import { B as ze } from "./dropdown.CR6vDGwi.js";
|
|
14
|
+
import { B as Je } from "./segmented-control.BeXMVbce.js";
|
|
14
15
|
import { d as K } from "./debounce.DUTu11PS.js";
|
|
15
|
-
import { u as
|
|
16
|
-
import { s as H, c as ce, i as B, d as
|
|
16
|
+
import { u as Qe } from "./use-has-slot.C9lQZ6nz.js";
|
|
17
|
+
import { s as H, c as ce, i as B, d as Xe, e as De, f as Ze, g as me, h as et, j as tt, a as F, u as at } from "./calendar.etLGotqH.js";
|
|
17
18
|
import { e as O } from "./index.B_EJflcs.js";
|
|
18
19
|
import { e as fe } from "./index.Z84QE0E2.js";
|
|
19
20
|
import { n as be } from "./_plugin-vue2_normalizer.CeySl7Fu.js";
|
|
20
|
-
import { D as at } from "./dropdown-default-textbox.BM9qsdzQ.js";
|
|
21
21
|
import { E as nt, F as rt } from "./error-message.epR1WJH2.js";
|
|
22
22
|
import { B as st } from "./directive.O3yEdalv.js";
|
|
23
23
|
import "../assets/date-range-picker.css";
|
|
@@ -57,13 +57,13 @@ const dt = ({
|
|
|
57
57
|
p = H(d.earliest);
|
|
58
58
|
else {
|
|
59
59
|
const D = ce(p, { weekStartsOn: t });
|
|
60
|
-
B(p, D) || (p = H(
|
|
60
|
+
B(p, D) || (p = H(Xe(De(p, { weekStartsOn: t }), 1)));
|
|
61
61
|
}
|
|
62
62
|
if (d.latest)
|
|
63
63
|
n = O(d.latest);
|
|
64
64
|
else {
|
|
65
65
|
const D = De(n, { weekStartsOn: t });
|
|
66
|
-
B(n, D) || (n = O(
|
|
66
|
+
B(n, D) || (n = O(Ze(ce(n, { weekStartsOn: t }), 1)));
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
if ((d == null ? void 0 : d.type) === "monthly") {
|
|
@@ -71,13 +71,13 @@ const dt = ({
|
|
|
71
71
|
p = H(d.earliest);
|
|
72
72
|
else {
|
|
73
73
|
const D = me(p);
|
|
74
|
-
B(p, D) || (p = me(
|
|
74
|
+
B(p, D) || (p = me(et(p, 1)));
|
|
75
75
|
}
|
|
76
76
|
if (d.latest)
|
|
77
77
|
n = O(d.latest);
|
|
78
78
|
else {
|
|
79
79
|
const D = fe(n);
|
|
80
|
-
B(n, D) || (n = fe(
|
|
80
|
+
B(n, D) || (n = fe(tt(n, 1)));
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
return { min: p, max: n };
|
|
@@ -127,9 +127,9 @@ const ct = /[\d]/, Dt = /^\d{2}$/, mt = /^\d{2}:\d{2}$/, ft = (t) => {
|
|
|
127
127
|
i18n: { messages: pt },
|
|
128
128
|
name: "date-range-picker-calendar",
|
|
129
129
|
components: {
|
|
130
|
-
BentoDropdown:
|
|
131
|
-
BentoInputField:
|
|
132
|
-
BentoSegmentedControl:
|
|
130
|
+
BentoDropdown: ze,
|
|
131
|
+
BentoInputField: Ke,
|
|
132
|
+
BentoSegmentedControl: Je,
|
|
133
133
|
BentoTypography: Ie,
|
|
134
134
|
Calendar: F
|
|
135
135
|
},
|
|
@@ -242,7 +242,7 @@ const ct = /[\d]/, Dt = /^\d{2}$/, mt = /^\d{2}:\d{2}$/, ft = (t) => {
|
|
|
242
242
|
adjustEndDateInputForWeekly: v,
|
|
243
243
|
adjustStartDateInputForMonthly: X,
|
|
244
244
|
adjustEndDateInputForMonthly: Z
|
|
245
|
-
} =
|
|
245
|
+
} = at(t.firstDayOfWeek), { savedRanges: y, saveRange: se, resetSavedRanges: ee } = ut(), R = (a) => a ? W(a, _.NUMERIC_DATE_YEAR_FIRST, {
|
|
246
246
|
locale: p[l.value.substring(0, 2)] || M
|
|
247
247
|
}) : "", Y = (a) => a ? W(a, _.HOUR_MINUTE_SECONDS, {
|
|
248
248
|
locale: p[l.value.substring(0, 2)] || M
|
|
@@ -354,7 +354,7 @@ const ct = /[\d]/, Dt = /^\d{2}$/, mt = /^\d{2}:\d{2}$/, ft = (t) => {
|
|
|
354
354
|
}, _e), Ce = (a) => {
|
|
355
355
|
s.endDate = ue(a), we(s.endDate);
|
|
356
356
|
}, he = (a) => {
|
|
357
|
-
|
|
357
|
+
qe(a);
|
|
358
358
|
}, xe = K((a) => {
|
|
359
359
|
if (S(a)) {
|
|
360
360
|
x.value = !1, n.startDate = E(n.startDate, a);
|
|
@@ -460,7 +460,7 @@ const ct = /[\d]/, Dt = /^\d{2}$/, mt = /^\d{2}:\d{2}$/, ft = (t) => {
|
|
|
460
460
|
quickSelectRangeDefaultItems: $,
|
|
461
461
|
formInputWrapperConditionalClasses: L,
|
|
462
462
|
// Methods
|
|
463
|
-
hasSlot:
|
|
463
|
+
hasSlot: Qe(r),
|
|
464
464
|
t: d,
|
|
465
465
|
// Events
|
|
466
466
|
onDateInput: ke,
|
|
@@ -543,7 +543,7 @@ const yt = {
|
|
|
543
543
|
BentoTypography: Ie,
|
|
544
544
|
BentoPopover: He,
|
|
545
545
|
DateRangePickerCalendar: k,
|
|
546
|
-
DropdownInputDefault:
|
|
546
|
+
DropdownInputDefault: We,
|
|
547
547
|
ErrorMessage: nt,
|
|
548
548
|
FieldLabel: rt
|
|
549
549
|
},
|
|
@@ -638,7 +638,7 @@ const yt = {
|
|
|
638
638
|
setup(t, { emit: e }) {
|
|
639
639
|
const { locale: r, t: l } = te(), d = { de: ne, enUS: M, fr: re }, p = G("bento-date-range-picker-container"), n = G("bento-date-range-picker-label"), D = G("bento-date-range-picker-description"), L = G("bento-date-range-picker-error"), $ = G("bento-date-range-picker-date-error"), b = I(
|
|
640
640
|
() => t.label || l("dateRangePicker", { name: p })
|
|
641
|
-
), g = U(!1), P = U(null), m = U(!1), { isReadOnly: T } =
|
|
641
|
+
), g = U(!1), P = U(null), m = U(!1), { isReadOnly: T } = je(de(t, "readonly"));
|
|
642
642
|
Ge(
|
|
643
643
|
() => t.disabled,
|
|
644
644
|
() => {
|
|
@@ -731,4 +731,4 @@ export {
|
|
|
731
731
|
k as D,
|
|
732
732
|
N as a
|
|
733
733
|
};
|
|
734
|
-
//# sourceMappingURL=date-range-picker.
|
|
734
|
+
//# sourceMappingURL=date-range-picker.D8-Ns1O7.js.map
|