@adyen/bento-vue3 2.1.0 → 2.1.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/button-actions.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/file-uploader.css +1 -1
- package/dist/assets/inspector.css +1 -1
- package/dist/assets/modal-fullscreen.css +1 -1
- package/dist/assets/navigation-menu-group.css +1 -1
- package/dist/assets/secondary-nav.css +1 -1
- package/dist/assets/sidepanel.css +1 -1
- package/dist/checkbox.js +2 -2
- package/dist/chunks/{calendar.EuBZ9HoM.js → calendar.CycKx_P3.js} +2 -2
- package/dist/chunks/{calendar.EuBZ9HoM.js.map → calendar.CycKx_P3.js.map} +1 -1
- package/dist/chunks/{checkbox-group.Deb5pHjj.js → checkbox-group.Bcy98dh8.js} +2 -2
- package/dist/chunks/{checkbox-group.Deb5pHjj.js.map → checkbox-group.Bcy98dh8.js.map} +1 -1
- package/dist/chunks/{checkbox.YBhv3GCJ.js → checkbox.BN7ttBqd.js} +14 -14
- package/dist/chunks/{checkbox.YBhv3GCJ.js.map → checkbox.BN7ttBqd.js.map} +1 -1
- package/dist/chunks/{code-snippet.DNDXr7t6.js → code-snippet.3u22Ij2R.js} +2 -2
- package/dist/chunks/{code-snippet.DNDXr7t6.js.map → code-snippet.3u22Ij2R.js.map} +1 -1
- package/dist/chunks/{data-grid.o5MQdWnJ.js → data-grid.DYNep9mz.js} +6 -6
- package/dist/chunks/{data-grid.o5MQdWnJ.js.map → data-grid.DYNep9mz.js.map} +1 -1
- package/dist/chunks/{date-picker.DyB8XkiY.js → date-picker.DjLNf7fF.js} +5 -5
- package/dist/chunks/{date-picker.DyB8XkiY.js.map → date-picker.DjLNf7fF.js.map} +1 -1
- package/dist/chunks/{date-range-picker.BcQUUVcW.js → date-range-picker.CI5hBzgs.js} +6 -6
- package/dist/chunks/{date-range-picker.BcQUUVcW.js.map → date-range-picker.CI5hBzgs.js.map} +1 -1
- package/dist/chunks/{dropdown-tag.BvXqllkv.js → dropdown-tag.GOcJPx20.js} +2 -2
- package/dist/chunks/{dropdown-tag.BvXqllkv.js.map → dropdown-tag.GOcJPx20.js.map} +1 -1
- package/dist/chunks/{dropdown.BoSI-Rre.js → dropdown.BvrZG8Za.js} +13 -13
- package/dist/chunks/{dropdown.BoSI-Rre.js.map → dropdown.BvrZG8Za.js.map} +1 -1
- package/dist/chunks/{filter-bar.6ElVHgFA.js → filter-bar.DrOXGxUc.js} +9 -9
- package/dist/chunks/{filter-bar.6ElVHgFA.js.map → filter-bar.DrOXGxUc.js.map} +1 -1
- package/dist/chunks/{header-with-views.Dl6bfk_7.js → header-with-views.LJ3oCsMN.js} +4 -4
- package/dist/chunks/{header-with-views.Dl6bfk_7.js.map → header-with-views.LJ3oCsMN.js.map} +1 -1
- package/dist/chunks/{input-field-password.BXptrVTT.js → input-field-password.CFBPscot.js} +2 -2
- package/dist/chunks/{input-field-password.BXptrVTT.js.map → input-field-password.CFBPscot.js.map} +1 -1
- package/dist/chunks/{input-field-phone-number.Crxi8Wm7.js → input-field-phone-number.BNAKRBLr.js} +2 -2
- package/dist/chunks/{input-field-phone-number.Crxi8Wm7.js.map → input-field-phone-number.BNAKRBLr.js.map} +1 -1
- package/dist/chunks/{input-field._keU91LW.js → input-field.BBSr4o-k.js} +2 -2
- package/dist/chunks/{input-field._keU91LW.js.map → input-field.BBSr4o-k.js.map} +1 -1
- package/dist/chunks/{input-time.D7UW_ww_.js → input-time.Cdz9Jb-1.js} +3 -3
- package/dist/chunks/{input-time.D7UW_ww_.js.map → input-time.Cdz9Jb-1.js.map} +1 -1
- package/dist/chunks/{pagination.C-kvJ-XK.js → pagination.DbGaudSO.js} +2 -2
- package/dist/chunks/{pagination.C-kvJ-XK.js.map → pagination.DbGaudSO.js.map} +1 -1
- package/dist/chunks/{rich-text-editor.ClUU1zPM.js → rich-text-editor.CjbYg6ee.js} +2 -2
- package/dist/chunks/{rich-text-editor.ClUU1zPM.js.map → rich-text-editor.CjbYg6ee.js.map} +1 -1
- package/dist/chunks/{search-bar.D1Jz7hdd.js → search-bar.D8LwiALL.js} +3 -3
- package/dist/chunks/{search-bar.D1Jz7hdd.js.map → search-bar.D8LwiALL.js.map} +1 -1
- package/dist/chunks/{secondary-nav.D32VFDTi.js → secondary-nav.CWZFULKD.js} +2 -2
- package/dist/chunks/{secondary-nav.D32VFDTi.js.map → secondary-nav.CWZFULKD.js.map} +1 -1
- package/dist/chunks/{selection-card-group.CQsS8-H9.js → selection-card-group.Covrf9mH.js} +9 -9
- package/dist/chunks/{selection-card-group.CQsS8-H9.js.map → selection-card-group.Covrf9mH.js.map} +1 -1
- package/dist/chunks/{use-date-input-formatter.BIVkaB1k.js → use-date-input-formatter.deZ3kB0L.js} +2 -2
- package/dist/chunks/{use-date-input-formatter.BIVkaB1k.js.map → use-date-input-formatter.deZ3kB0L.js.map} +1 -1
- package/dist/code-snippet.js +1 -1
- package/dist/data-grid.js +1 -1
- package/dist/date-picker.js +2 -2
- package/dist/date-range-picker.js +2 -2
- package/dist/date-time-picker.js +4 -4
- package/dist/dropdown.js +2 -2
- package/dist/filter-bar.js +1 -1
- package/dist/header-with-views.js +1 -1
- package/dist/index.js +20 -20
- package/dist/input-field-password.js +1 -1
- package/dist/input-field-phone-number.js +1 -1
- package/dist/input-field.js +1 -1
- package/dist/input-time.js +1 -1
- package/dist/internal.js +2 -2
- package/dist/pagination.js +1 -1
- package/dist/rich-text-editor.js +1 -1
- package/dist/search-bar.js +2 -2
- package/dist/secondary-nav.js +1 -1
- package/dist/selection-card.js +1 -1
- package/dist/web-types.json +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent as we, useSlots as ke, ref as g, provide as Le, inject as j, toRef as Ee, computed as l, openBlock as n, createBlock as u, unref as o, mergeProps as F, withCtx as m, renderSlot as p, createCommentVNode as d, createElementVNode as R, createElementBlock as c, withModifiers as K, withKeys as he, createTextVNode as J, toDisplayString as X, createVNode as _e } from "vue";
|
|
2
|
-
import { h as Te, B as Z } from "./dropdown.
|
|
2
|
+
import { h as Te, B as Z } from "./dropdown.BvrZG8Za.js";
|
|
3
3
|
import { p as $, d as Ne, B as L } from "./typography.B6elnWpr.js";
|
|
4
4
|
import { u as Ae } from "./form-field.B60VsF8d.js";
|
|
5
5
|
import { g as E } from "./generate-uid.DBWe4g6T.js";
|
|
@@ -323,4 +323,4 @@ export {
|
|
|
323
323
|
v as e,
|
|
324
324
|
Ie as f
|
|
325
325
|
};
|
|
326
|
-
//# sourceMappingURL=input-field.
|
|
326
|
+
//# sourceMappingURL=input-field.BBSr4o-k.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-field._keU91LW.js","sources":["../../../vue2/src/components/input-field/input-field.keys.ts","../../../vue2/src/components/input-field/input-field.types.ts","../../../vue2/src/components/input-field/input-field.vue"],"sourcesContent":["export const INPUT_FIELD_HINT_INJECTION_KEY = Symbol('input field hint injection key');\nexport const INPUT_FIELD_PARENT_COMPONENT_INJECTION_KEY = Symbol('input field parent component injection key');\n","import { type BentoDropdownProps } from '../dropdown/dropdown.types';\nimport { type FormField } from '../../types/form-field';\n\n/**\n * @deprecated Since v3.0.0. Use string literal instead.\n */\nexport enum BentoInputFieldVariant {\n DEFAULT = 'default',\n PAYMENT_METHOD = 'payment-method',\n STATIC_VALUE = 'static-value',\n DROPDOWN = 'dropdown',\n}\n\n/**\n * @deprecated Since v3.0.0. Use string literal instead.\n */\nexport enum BentoInputFieldElementPosition {\n START = 'start',\n END = 'end',\n}\n\nexport enum BentoInputFieldStateClass {\n CONDENSED = 'condensed',\n DISABLED = 'disabled',\n READONLY = 'readonly',\n ERROR = 'error',\n}\n\n/**\n * @deprecated Since v3.0.0. Use string literal instead.\n */\nexport enum BentoInputFieldType {\n SEARCH = 'search',\n TEXT = 'text',\n NUMBER = 'number',\n}\n\nexport type BentoInputFieldValue = string | number;\n\nexport interface BentoInputDropdownProps {\n /**\n * Text that labels the dropdown element\n */\n 'aria-label'?: string;\n /**\n * Indicates that dropdown items are loading (shows a loading skeleton)\n */\n componentLoading?: BentoDropdownProps['componentLoading'];\n /**\n * Enables dynamic filtering\n */\n dynamicFiltering?: BentoDropdownProps['dynamicFiltering'];\n /**\n * Empty state displayed when no search results are found\n */\n emptyState?: BentoDropdownProps['emptyState'];\n /**\n * Enables value/label pair handling for selected values\n */\n enableValueLabelPair?: BentoDropdownProps['enableValueLabelPair'];\n /**\n * Indicates whether there are more items to load\n */\n hasMoreItems?: BentoDropdownProps['hasMoreItems'];\n /**\n * Function that determines which options are disabled from interaction\n */\n isOptionDisabled?: BentoDropdownProps['isOptionDisabled'];\n /**\n * List of available items\n */\n items: BentoDropdownProps['items'];\n /**\n * The type of lazy load: \"automatic\" for infinite scrolling, \"button\" for a show-more button\n */\n lazyLoadType?: BentoDropdownProps['lazyLoadType'];\n /**\n * Indicates if new options are lazy loading\n */\n loading?: BentoDropdownProps['loading'];\n /**\n * Selected value of the dropdown\n */\n modelValue?: BentoDropdownProps['modelValue'];\n /**\n * Sets the dropdown in read-only mode\n */\n readonly?: BentoDropdownProps['readonly'];\n /**\n * Dropdown search options including debounce time and placeholder\n */\n search?: BentoDropdownProps['search'];\n /**\n * Displays non-selectable, static categories in the dropdown\n */\n staticCategories?: BentoDropdownProps['staticCategories'];\n /**\n * Enables virtual scrolling for large lists of items\n */\n virtualScroll?: BentoDropdownProps['virtualScroll'];\n}\n\n/**\n * @deprecated Since v3.0.0. Use `@<emit name>` instead.\n */\nexport enum BentoInputFieldEvent {\n INPUT = 'input',\n ESCAPE_PRESSED = 'escape-pressed',\n UPDATE_DROPDOWN = 'update:dropdown',\n DROPDOWN_INPUT = 'dropdown-input',\n FOCUS = 'focus',\n CHANGE = 'change',\n BLUR = 'blur',\n KEYDOWN = 'keydown',\n}\n\nexport interface BentoInputFieldProps extends FormField {\n /**\n * Indicates whether the element is exposed to an accessibility API.\n */\n ariaHidden?: boolean;\n\n /**\n * Reduces height of the input\n */\n condensed?: boolean;\n\n /**\n * Dropdown props for the single-select dropdown menu embedded in the input field.\n * Only a subset of `BentoDropdownProps` is supported (multi-select is not available).\n *\n * @see {@link BentoInputDropdownProps}\n */\n dropdown?: BentoInputDropdownProps;\n\n /**\n * Position of the dropdown before or after input value\n */\n dropdownPosition?: BentoInputFieldElementPosition | `${BentoInputFieldElementPosition}`;\n\n /**\n * Text displayed as the value of the input-field\n */\n modelValue?: BentoInputFieldValue;\n\n /**\n * Renders a font numeric style with slashed zeros instead of normal ones.\n */\n slashedZero?: boolean;\n\n /**\n * Static text that displayed before or after input value\n * Applicable to the Static Value variant\n */\n staticValue?: string;\n\n /**\n * Position of Static Value before or after input value\n */\n staticValuePosition?: BentoInputFieldElementPosition | `${BentoInputFieldElementPosition}`;\n\n /**\n * A string specifying the type of control to render.\n * All `input` types are available but only `search`, `text` and `number` are fully supported.\n *\n * If `type` is `search`, use `bento-search-bar` instead.\n */\n type?: BentoInputFieldType | `${BentoInputFieldType}` | HTMLInputElement['type'];\n\n /**\n * Describes the different variants for the input element\n */\n variant?: BentoInputFieldVariant | `${BentoInputFieldVariant}`;\n}\n","<template>\n <bento-typography\n class=\"b-input-field\"\n v-bind=\"getRootAttributes($attrs)\"\n :data-testid=\"getDataTestId($attrs)\"\n :class=\"inputFieldConditionalClasses\"\n el=\"div\"\n variant=\"body\"\n >\n <field-label\n v-if=\"hasSlot('default') || label\"\n :for=\"inputFieldId\"\n data-testid=\"input-field-label\"\n :tooltip-text=\"tooltipText\"\n :optional=\"optional\"\n :required=\"required\"\n :label=\"label\"\n @click=\"focusInput\"\n >\n <slot></slot>\n </field-label>\n\n <div class=\"b-input-field__input-box\" data-testid=\"input-box\" :aria-disabled=\"disabled\" @click=\"focusInput\">\n <!-- Optional Icon for Default text variant -->\n <span\n v-if=\"isDefaultVariant && (hasSlot('defaultIconBefore') || hasSlot('iconBefore'))\"\n :aria-hidden=\"ariaHidden ? 'true' : undefined\"\n class=\"b-input-field__icon-before\"\n >\n <slot v-if=\"hasSlot('iconBefore')\" name=\"iconBefore\" />\n <slot v-if=\"hasSlot('defaultIconBefore') && !hasSlot('iconBefore')\" name=\"defaultIconBefore\" />\n </span>\n\n <!-- Mandatory Icon for Payment Method variant -->\n <span\n v-if=\"isPaymentMethodVariant && hasSlot('paymentMethod')\"\n :aria-hidden=\"ariaHidden ? 'true' : undefined\"\n class=\"b-input-field__payment-method\"\n >\n <slot name=\"paymentMethod\" />\n </span>\n\n <!-- Dropdown at start -->\n <div\n v-if=\"shouldDisplayDropdownAtStart\"\n :id=\"dropdownId\"\n class=\"b-input-field__dropdown b-input-field__dropdown--start\"\n @click.stop\n >\n <bento-dropdown\n v-if=\"dropdown\"\n ref=\"inputDropdownElement\"\n v-bind=\"getInputFieldDropdownProps($attrs)\"\n :disabled=\"disabled\"\n :readonly=\"isDropdownReadOnly\"\n @update:model-value=\"onDropdownInput\"\n />\n </div>\n\n <!-- Static Value at start -->\n <bento-typography\n v-if=\"shouldDisplayStaticValueAtStart\"\n :id=\"staticValueId\"\n class=\"b-input-field__static-value b-input-field__static-value--start\"\n el=\"span\"\n variant=\"body\"\n >\n <slot name=\"staticValue\" />\n </bento-typography>\n <div class=\"b-input-field__input-container\">\n <input\n :id=\"inputFieldId\"\n v-bind=\"$attrs\"\n ref=\"inputFieldElement\"\n class=\"b-input-field__input\"\n :aria-label=\"getAriaLabel($attrs)\"\n :aria-describedby=\"computedAriaDescribedBy\"\n :aria-owns=\"computedAriaOwns\"\n :aria-invalid=\"shouldShowError\"\n :placeholder=\"placeholder\"\n :required=\"required\"\n :aria-required=\"required\"\n :type=\"type\"\n :value=\"modelValue\"\n :disabled=\"disabled\"\n :readonly=\"isReadOnly\"\n @input=\"onInput\"\n @change=\"emit('change')\"\n @focus=\"onFocus\"\n @blur=\"onBlur\"\n @keydown=\"emit('keydown', $event)\"\n @keyup=\"emit('keyup', $event)\"\n @keydown.esc=\"emit('escape-pressed')\"\n @click=\"emit('click', $event)\"\n />\n\n <!-- Hint at the end -->\n <bento-typography v-if=\"hint && isFocused && modelValue\" el=\"span\" class=\"b-input-field__hint\">\n {{ hint }}\n </bento-typography>\n </div>\n\n <span\n v-if=\"hasSlot('iconAfter')\"\n :aria-hidden=\"ariaHidden ? 'true' : undefined\"\n class=\"b-input-field__icon-after\"\n data-testid=\"input-text__icon-after\"\n >\n <slot name=\"iconAfter\" />\n </span>\n\n <!-- Static Value at the end -->\n <bento-typography\n v-if=\"shouldDisplayStaticValueAtEnd\"\n :id=\"staticValueId\"\n class=\"b-input-field__static-value b-input-field__static-value--end\"\n el=\"span\"\n variant=\"body\"\n >\n <slot name=\"staticValue\" />\n </bento-typography>\n\n <!-- Dropdown at end -->\n <div\n v-if=\"shouldDisplayDropdownAtEnd\"\n :id=\"dropdownId\"\n data-testid=\"input-field-dropdown-container-end\"\n class=\"b-input-field__dropdown b-input-field__dropdown--end\"\n @click.stop\n >\n <bento-dropdown\n v-if=\"dropdown\"\n :id=\"dropdownId\"\n ref=\"inputDropdownElement\"\n v-bind=\"getInputFieldDropdownProps($attrs)\"\n :disabled=\"disabled\"\n :readonly=\"isDropdownReadOnly\"\n @update:model-value=\"onDropdownInput\"\n />\n </div>\n </div>\n\n <div\n v-if=\"(shouldShowError && !!errorMessage) || hasSlot('description') || description\"\n class=\"b-input-field__footer\"\n >\n <error-message v-if=\"shouldShowError && !!errorMessage\" :id=\"errorId\" :error-message=\"errorMessage\" />\n\n <span\n v-if=\"hasSlot('description') || description\"\n :id=\"descriptionId\"\n class=\"b-input-field__description\"\n @click=\"focusInput\"\n >\n <bento-typography el=\"span\" variant=\"body\">\n <slot id=\"description\" name=\"description\">\n {{ description }}\n </slot>\n </bento-typography>\n </span>\n </div>\n </bento-typography>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, inject, provide, type Ref, ref, toRef, useSlots } from 'vue';\n\n // Components\n import { BentoDropdown } from '@/components/dropdown';\n import { DROPDOWN_SMALL_SIZE_INJECTION_KEY } from '@/components/dropdown/dropdown.keys';\n import { BentoTypography } from '@/components/typography';\n import { ErrorMessage, FieldLabel } from '@/internal';\n\n // Utils\n import { deprecate } from '@/utils/ts/deprecate';\n import { useFormFieldEmits } from '@/utils/ts/form-field/form-field';\n import { generateUid } from '@/utils/ts/generate-uid';\n import { getSlotText } from '@/utils/ts/get-slot-text';\n import { useI18n } from '@/utils/ts/i18n';\n import { printDevelopmentWarning } from '@/utils/ts/print-development-warning';\n import {\n INPUT_FIELD_HINT_INJECTION_KEY,\n INPUT_FIELD_PARENT_COMPONENT_INJECTION_KEY,\n } from '@/components/input-field/input-field.keys';\n import { type BentoListboxSelectedValue } from '@/types/listbox';\n\n // Composables\n import { useFormLayoutFieldLoading, useHasSlot } from '@/composables';\n\n // Types\n import {\n type BentoInputDropdownProps,\n BentoInputFieldElementPosition,\n type BentoInputFieldProps,\n BentoInputFieldStateClass,\n BentoInputFieldType,\n type BentoInputFieldValue,\n BentoInputFieldVariant,\n } from './input-field.types';\n\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n const slots = useSlots();\n\n const props = withDefaults(defineProps<BentoInputFieldProps>(), {\n ariaHidden: true,\n condensed: false,\n description: '',\n disabled: false,\n dropdown: undefined,\n dropdownPosition: BentoInputFieldElementPosition.START,\n errorMessage: null,\n label: '',\n modelValue: undefined,\n optional: false,\n placeholder: '',\n required: false,\n readonly: false,\n slashedZero: false,\n staticValue: '',\n staticValuePosition: BentoInputFieldElementPosition.START,\n tooltipText: null,\n type: BentoInputFieldType.TEXT,\n variant: BentoInputFieldVariant.DEFAULT,\n });\n\n const emit = defineEmits<{\n /**\n * Emitted when the element has lost focus\n */\n (e: 'blur'): void;\n\n /**\n * Emitted when the input is clicked\n */\n (e: 'click', event: MouseEvent);\n\n /**\n * Emitted when the user modifies the element's value. Unlike the 'input' event, the change event is not necessarily fired for each alteration to an element's value\n */\n (e: 'change'): void;\n\n /**\n * Emitted when the Input Field's internal dropdown changes it's value\n */\n (e: 'dropdown-input', selectedValue: BentoListboxSelectedValue): void;\n\n /**\n * Emitted when the \"ESC\" key is pressed\n */\n (e: 'escape-pressed'): void;\n\n /**\n * Emitted when the element has received focus\n */\n (e: 'focus'): void;\n\n /**\n * Emitted when a key is pressed down\n */\n (e: 'keydown', event: KeyboardEvent): void;\n\n /**\n * Emitted when a key is pressed and lifted up\n */\n (e: 'keyup', event: KeyboardEvent): void;\n\n /**\n * Emitted when the Input Field's internal dropdown changes it's value. Contains every dropdown prop passed with the updated selected value as 'value'\n */\n (e: 'update:dropdown', updatedDropdownProps: BentoInputDropdownProps): void;\n\n /**\n * Emitted when the component's model changes\n */\n (e: 'update:model-value', inputValue: BentoInputFieldValue): void;\n }>();\n\n const { emitValue } = useFormFieldEmits<BentoInputFieldValue>(emit);\n const { t } = useI18n<{ message: MessageSchema }>({ messages });\n const hasSlot = useHasSlot(slots);\n const inputFieldElement = ref<HTMLInputElement>(null);\n const inputDropdownElement = ref(null);\n const inputFieldId = generateUid('input');\n const dropdownId = generateUid('input-dropdown');\n const staticValueId = generateUid('input-static-value');\n const descriptionId = generateUid('input-description');\n const errorId = generateUid('input-error');\n const isFocused = ref(false);\n\n /**\n * Gets the overriden or the default data-testid attribute\n * @param attributes - the live attributes object\n */\n function getDataTestId(attributes: Record<string, unknown>) {\n return (attributes['data-testid'] as string) ?? 'input-text-container';\n }\n /**\n * Filters out all aria attributes for the root element.\n * @param attributes - the live attributes object\n */\n function getRootAttributes(attributes: Record<string, unknown>) {\n return Object.fromEntries(\n Object.entries(attributes).filter(([key]) => !key.startsWith('aria-') && key !== 'data-testid')\n );\n }\n\n // Provide DROPDOWN_SMALL_SIZE_INJECTION_KEY as true, to set the input only dropdown size variant in the BentoDropdown comp\n provide(DROPDOWN_SMALL_SIZE_INJECTION_KEY, true);\n // Renders the input with a hint if a string is provided\n const hint = inject<Ref<string | undefined>>(INPUT_FIELD_HINT_INJECTION_KEY, ref(undefined));\n\n const onFocus = () => {\n isFocused.value = true;\n emit('focus');\n };\n\n const onBlur = () => {\n isFocused.value = false;\n emit('blur');\n };\n\n const { isReadOnly } = useFormLayoutFieldLoading(toRef(props, 'readonly'));\n const isDropdownReadOnly = computed<BentoInputDropdownProps['readonly']>(\n () => isReadOnly.value || props.dropdown?.readonly\n );\n\n const shouldShowStaticValue = computed(\n () => props.variant === BentoInputFieldVariant.STATIC_VALUE && !!slots.staticValue\n );\n\n const isDefaultVariant = computed(() => props.variant === BentoInputFieldVariant.DEFAULT);\n\n const isPaymentMethodVariant = computed(() => props.variant === BentoInputFieldVariant.PAYMENT_METHOD);\n\n const shouldDisplayStaticValueAtStart = computed(\n () => shouldShowStaticValue.value && props.staticValuePosition === BentoInputFieldElementPosition.START\n );\n const shouldDisplayStaticValueAtEnd = computed(\n () => shouldShowStaticValue.value && props.staticValuePosition === BentoInputFieldElementPosition.END\n );\n\n const shouldShowDropdown = computed(() => props.variant === BentoInputFieldVariant.DROPDOWN && !!props.dropdown);\n const shouldDisplayDropdownAtStart = computed(\n () => shouldShowDropdown.value && props.dropdownPosition === BentoInputFieldElementPosition.START\n );\n const shouldDisplayDropdownAtEnd = computed(\n () => shouldShowDropdown.value && props.dropdownPosition === BentoInputFieldElementPosition.END\n );\n\n const shouldShowError = computed(() => !props.disabled && !isReadOnly.value && !!props.errorMessage);\n\n const computedLabel = computed(() => (getSlotText(slots)('default') as string) || props.label);\n const computedDescription = computed(() => (getSlotText(slots)('description') as string) || props.description);\n\n const computedAriaOwns = computed(() => {\n if (shouldShowDropdown.value === true && shouldShowStaticValue.value === true) {\n return `${staticValueId} ${dropdownId}`;\n }\n if (shouldShowDropdown.value === true) {\n return `${dropdownId}`;\n }\n if (shouldShowStaticValue.value === true) {\n return `${staticValueId}`;\n }\n return null;\n });\n\n // vue-i18n issue with t() used in script - direct usage in template works\n // requires either createI18n({ legacy: false }) or to be wrapped in computed()\n const computedAriaLabelFallbackMessage = computed(() => t('ariaLabelFallback'));\n const getAriaLabel = (attributes: Record<string, unknown>) =>\n (attributes['aria-label'] as string | undefined) ??\n (attributes['aria-labelledby'] ? undefined : computedLabel.value || computedAriaLabelFallbackMessage.value);\n\n const computedAriaDescribedBy = computed(\n () =>\n `${computedDescription.value ? descriptionId : ''} ${\n shouldShowError.value && !!props.errorMessage ? errorId : ''\n }`\n );\n\n const inputFieldConditionalClasses = computed(() => ({\n [`b-input-field--${BentoInputFieldStateClass.CONDENSED}`]: props.condensed,\n [`b-input-field--${BentoInputFieldStateClass.DISABLED}`]: props.disabled,\n [`b-input-field--${BentoInputFieldStateClass.READONLY}`]: isReadOnly.value,\n [`b-input-field--${BentoInputFieldStateClass.ERROR}`]: shouldShowError.value,\n [`b-input-field--slashed-zero`]: props.slashedZero,\n }));\n\n const getInputFieldDropdownProps = (attributes: Record<string, unknown>) => ({\n 'aria-label': t('ariaLabelDropdownFallback', { inputLabel: getAriaLabel(attributes) }),\n ...props.dropdown,\n });\n\n const onInput = (event: Event) => {\n const inputValue = (event.target as HTMLInputElement).value;\n if (!props.disabled && !isReadOnly.value) {\n emitValue(inputValue);\n }\n };\n\n const onDropdownInput = (selectedValue: BentoListboxSelectedValue) => {\n emit('dropdown-input', selectedValue);\n emit('update:dropdown', { ...props?.dropdown, modelValue: selectedValue });\n };\n\n const focusInput = () => {\n inputFieldElement.value.focus();\n };\n\n const focus = () => {\n if (props.variant === 'dropdown') {\n inputDropdownElement.value.focus();\n } else {\n focusInput();\n }\n };\n\n // Expose focus methods for parent components in Vue 3.\n defineExpose({\n /**\n * Focuses the input field.\n */\n focusInput,\n\n /**\n * Focuses the dropdown when using the dropdown variant; otherwise focuses the input field.\n */\n focus,\n\n /**\n * Reference to the native input element.\n */\n inputFieldElement,\n });\n const inputFieldParentComponent = inject(INPUT_FIELD_PARENT_COMPONENT_INJECTION_KEY, '');\n\n if (!Object.values(BentoInputFieldType).includes(props.type as BentoInputFieldType) && !inputFieldParentComponent) {\n if (props.type === 'tel') {\n printDevelopmentWarning(\n `\"bento-input-field\" dropdown does not support the type '${props.type}', use \"bento-input-field-phone-number\" instead.`\n );\n } else if (props.type === 'password') {\n printDevelopmentWarning(\n `\"bento-input-field\" dropdown does not support the type '${props.type}', use \"bento-input-field-password\" instead.`\n );\n } else {\n printDevelopmentWarning(`\"bento-input-field\" dropdown does not support the type '${props.type}'`);\n }\n }\n\n /**\n * Deprecations\n */\n if (hasSlot('defaultIconBefore')) {\n deprecate(\n 'BentoInputField \"defaultIconBefore\" slot',\n `Use the BentoInputField \"iconBefore\" slot instead to add an icon at the left side of the input field\n <bento-input-field>\n \\t<template #iconBefore>\n \\t\\t<my-icon-goes-here />\n \\t</template>\n </bento-input-field>`,\n '3.0.0'\n );\n }\n</script>\n\n<script lang=\"ts\">\n /**\n * Input field component is used to create interactive controls for web-based\n * forms in order to accept data from the user.\n *\n * @example\n * import { BentoInputField } from '@adyen/bento-vue2'\n *\n * const inputValue = ref('');\n *\n * export default {\n * components: { BentoInputField },\n * tempate: `\n * <bento-input-field\n * :model-value=\"inputValue\"\n * :@update:model-value=\"newValue => inputValue.value = newValue\"\n * >\n * }\n */\n export default {\n name: 'bento-input-field',\n inheritAttrs: false,\n model: { prop: 'modelValue', event: 'update:model-value' },\n i18n: { messages },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./input-field.scss\" />\n"],"names":["INPUT_FIELD_HINT_INJECTION_KEY","INPUT_FIELD_PARENT_COMPONENT_INJECTION_KEY","BentoInputFieldVariant","BentoInputFieldVariant2","BentoInputFieldElementPosition","BentoInputFieldElementPosition2","BentoInputFieldStateClass","BentoInputFieldStateClass2","BentoInputFieldType","BentoInputFieldType2","BentoInputFieldEvent","BentoInputFieldEvent2","__default__","messages","slots","useSlots","props","__props","emit","__emit","emitValue","useFormFieldEmits","t","useI18n","hasSlot","useHasSlot","inputFieldElement","ref","inputDropdownElement","inputFieldId","generateUid","dropdownId","staticValueId","descriptionId","errorId","isFocused","getDataTestId","attributes","getRootAttributes","key","provide","DROPDOWN_SMALL_SIZE_INJECTION_KEY","hint","inject","onFocus","onBlur","isReadOnly","useFormLayoutFieldLoading","toRef","isDropdownReadOnly","computed","shouldShowStaticValue","isDefaultVariant","isPaymentMethodVariant","shouldDisplayStaticValueAtStart","shouldDisplayStaticValueAtEnd","shouldShowDropdown","shouldDisplayDropdownAtStart","shouldDisplayDropdownAtEnd","shouldShowError","computedLabel","getSlotText","computedDescription","computedAriaOwns","computedAriaLabelFallbackMessage","getAriaLabel","computedAriaDescribedBy","inputFieldConditionalClasses","getInputFieldDropdownProps","onInput","event","inputValue","onDropdownInput","selectedValue","focusInput","__expose","inputFieldParentComponent","printDevelopmentWarning","deprecate"],"mappings":";;;;;;;;;;;;;AAAO,MAAAA,KAAA,uBAAA,gCAAA,GACAC,KAAA,uBAAA,4CAAA;ACKA,IAAAC,IAAA,kBAAAC,OACHA,EAAA,UAAA,WACAA,EAAA,iBAAA,kBACAA,EAAA,eAAA,gBACAA,EAAA,WAAA,YAJQA,IAAAD,KAAA,CAAA,CAAA,GAULE,IAAA,kBAAAC,OACHA,EAAA,QAAA,SACAA,EAAA,MAAA,OAFQA,IAAAD,KAAA,CAAA,CAAA,GAKLE,IAAA,kBAAAC,OACHA,EAAA,YAAA,aACAA,EAAA,WAAA,YACAA,EAAA,WAAA,YACAA,EAAA,QAAA,SAJQA,IAAAD,KAAA,CAAA,CAAA,GAULE,IAAA,kBAAAC,OACHA,EAAA,SAAA,UACAA,EAAA,OAAA,QACAA,EAAA,SAAA,UAHQA,IAAAD,KAAA,CAAA,CAAA,GA0ELE,KAAA,kBAAAC,OACHA,EAAA,QAAA,SACAA,EAAA,iBAAA,kBACAA,EAAA,kBAAA,mBACAA,EAAA,iBAAA,kBACAA,EAAA,QAAA,SACAA,EAAA,SAAA,UACAA,EAAA,OAAA,QACAA,EAAA,UAAA,WARQA,IAAAD,MAAA,CAAA,CA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,EAAA,IAAA,KAAA,CAAA4D,OACI5D,EAAA,SAAA,QACI6D;AAAA,MAAA,2DAAA7D,EAAA,IAAA;AAAA,IACyE,IACzEA,EAAA,SAAA,aAEA6D;AAAA,MAAA,2DAAA7D,EAAA,IAAA;AAAA,IACyE,IAGzE6D,EAAA,2DAAA7D,EAAA,IAAA,GAAA,IAORQ,EAAA,mBAAA,KACIsD;AAAA,MAAA;AAAA,MACI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MACA;AAAA,IAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"input-field.BBSr4o-k.js","sources":["../../../vue2/src/components/input-field/input-field.keys.ts","../../../vue2/src/components/input-field/input-field.types.ts","../../../vue2/src/components/input-field/input-field.vue"],"sourcesContent":["export const INPUT_FIELD_HINT_INJECTION_KEY = Symbol('input field hint injection key');\nexport const INPUT_FIELD_PARENT_COMPONENT_INJECTION_KEY = Symbol('input field parent component injection key');\n","import { type BentoDropdownProps } from '../dropdown/dropdown.types';\nimport { type FormField } from '../../types/form-field';\n\n/**\n * @deprecated Since v3.0.0. Use string literal instead.\n */\nexport enum BentoInputFieldVariant {\n DEFAULT = 'default',\n PAYMENT_METHOD = 'payment-method',\n STATIC_VALUE = 'static-value',\n DROPDOWN = 'dropdown',\n}\n\n/**\n * @deprecated Since v3.0.0. Use string literal instead.\n */\nexport enum BentoInputFieldElementPosition {\n START = 'start',\n END = 'end',\n}\n\nexport enum BentoInputFieldStateClass {\n CONDENSED = 'condensed',\n DISABLED = 'disabled',\n READONLY = 'readonly',\n ERROR = 'error',\n}\n\n/**\n * @deprecated Since v3.0.0. Use string literal instead.\n */\nexport enum BentoInputFieldType {\n SEARCH = 'search',\n TEXT = 'text',\n NUMBER = 'number',\n}\n\nexport type BentoInputFieldValue = string | number;\n\nexport interface BentoInputDropdownProps {\n /**\n * Text that labels the dropdown element\n */\n 'aria-label'?: string;\n /**\n * Indicates that dropdown items are loading (shows a loading skeleton)\n */\n componentLoading?: BentoDropdownProps['componentLoading'];\n /**\n * Enables dynamic filtering\n */\n dynamicFiltering?: BentoDropdownProps['dynamicFiltering'];\n /**\n * Empty state displayed when no search results are found\n */\n emptyState?: BentoDropdownProps['emptyState'];\n /**\n * Enables value/label pair handling for selected values\n */\n enableValueLabelPair?: BentoDropdownProps['enableValueLabelPair'];\n /**\n * Indicates whether there are more items to load\n */\n hasMoreItems?: BentoDropdownProps['hasMoreItems'];\n /**\n * Function that determines which options are disabled from interaction\n */\n isOptionDisabled?: BentoDropdownProps['isOptionDisabled'];\n /**\n * List of available items\n */\n items: BentoDropdownProps['items'];\n /**\n * The type of lazy load: \"automatic\" for infinite scrolling, \"button\" for a show-more button\n */\n lazyLoadType?: BentoDropdownProps['lazyLoadType'];\n /**\n * Indicates if new options are lazy loading\n */\n loading?: BentoDropdownProps['loading'];\n /**\n * Selected value of the dropdown\n */\n modelValue?: BentoDropdownProps['modelValue'];\n /**\n * Sets the dropdown in read-only mode\n */\n readonly?: BentoDropdownProps['readonly'];\n /**\n * Dropdown search options including debounce time and placeholder\n */\n search?: BentoDropdownProps['search'];\n /**\n * Displays non-selectable, static categories in the dropdown\n */\n staticCategories?: BentoDropdownProps['staticCategories'];\n /**\n * Enables virtual scrolling for large lists of items\n */\n virtualScroll?: BentoDropdownProps['virtualScroll'];\n}\n\n/**\n * @deprecated Since v3.0.0. Use `@<emit name>` instead.\n */\nexport enum BentoInputFieldEvent {\n INPUT = 'input',\n ESCAPE_PRESSED = 'escape-pressed',\n UPDATE_DROPDOWN = 'update:dropdown',\n DROPDOWN_INPUT = 'dropdown-input',\n FOCUS = 'focus',\n CHANGE = 'change',\n BLUR = 'blur',\n KEYDOWN = 'keydown',\n}\n\nexport interface BentoInputFieldProps extends FormField {\n /**\n * Indicates whether the element is exposed to an accessibility API.\n */\n ariaHidden?: boolean;\n\n /**\n * Reduces height of the input\n */\n condensed?: boolean;\n\n /**\n * Dropdown props for the single-select dropdown menu embedded in the input field.\n * Only a subset of `BentoDropdownProps` is supported (multi-select is not available).\n *\n * @see {@link BentoInputDropdownProps}\n */\n dropdown?: BentoInputDropdownProps;\n\n /**\n * Position of the dropdown before or after input value\n */\n dropdownPosition?: BentoInputFieldElementPosition | `${BentoInputFieldElementPosition}`;\n\n /**\n * Text displayed as the value of the input-field\n */\n modelValue?: BentoInputFieldValue;\n\n /**\n * Renders a font numeric style with slashed zeros instead of normal ones.\n */\n slashedZero?: boolean;\n\n /**\n * Static text that displayed before or after input value\n * Applicable to the Static Value variant\n */\n staticValue?: string;\n\n /**\n * Position of Static Value before or after input value\n */\n staticValuePosition?: BentoInputFieldElementPosition | `${BentoInputFieldElementPosition}`;\n\n /**\n * A string specifying the type of control to render.\n * All `input` types are available but only `search`, `text` and `number` are fully supported.\n *\n * If `type` is `search`, use `bento-search-bar` instead.\n */\n type?: BentoInputFieldType | `${BentoInputFieldType}` | HTMLInputElement['type'];\n\n /**\n * Describes the different variants for the input element\n */\n variant?: BentoInputFieldVariant | `${BentoInputFieldVariant}`;\n}\n","<template>\n <bento-typography\n class=\"b-input-field\"\n v-bind=\"getRootAttributes($attrs)\"\n :data-testid=\"getDataTestId($attrs)\"\n :class=\"inputFieldConditionalClasses\"\n el=\"div\"\n variant=\"body\"\n >\n <field-label\n v-if=\"hasSlot('default') || label\"\n :for=\"inputFieldId\"\n data-testid=\"input-field-label\"\n :tooltip-text=\"tooltipText\"\n :optional=\"optional\"\n :required=\"required\"\n :label=\"label\"\n @click=\"focusInput\"\n >\n <slot></slot>\n </field-label>\n\n <div class=\"b-input-field__input-box\" data-testid=\"input-box\" :aria-disabled=\"disabled\" @click=\"focusInput\">\n <!-- Optional Icon for Default text variant -->\n <span\n v-if=\"isDefaultVariant && (hasSlot('defaultIconBefore') || hasSlot('iconBefore'))\"\n :aria-hidden=\"ariaHidden ? 'true' : undefined\"\n class=\"b-input-field__icon-before\"\n >\n <slot v-if=\"hasSlot('iconBefore')\" name=\"iconBefore\" />\n <slot v-if=\"hasSlot('defaultIconBefore') && !hasSlot('iconBefore')\" name=\"defaultIconBefore\" />\n </span>\n\n <!-- Mandatory Icon for Payment Method variant -->\n <span\n v-if=\"isPaymentMethodVariant && hasSlot('paymentMethod')\"\n :aria-hidden=\"ariaHidden ? 'true' : undefined\"\n class=\"b-input-field__payment-method\"\n >\n <slot name=\"paymentMethod\" />\n </span>\n\n <!-- Dropdown at start -->\n <div\n v-if=\"shouldDisplayDropdownAtStart\"\n :id=\"dropdownId\"\n class=\"b-input-field__dropdown b-input-field__dropdown--start\"\n @click.stop\n >\n <bento-dropdown\n v-if=\"dropdown\"\n ref=\"inputDropdownElement\"\n v-bind=\"getInputFieldDropdownProps($attrs)\"\n :disabled=\"disabled\"\n :readonly=\"isDropdownReadOnly\"\n @update:model-value=\"onDropdownInput\"\n />\n </div>\n\n <!-- Static Value at start -->\n <bento-typography\n v-if=\"shouldDisplayStaticValueAtStart\"\n :id=\"staticValueId\"\n class=\"b-input-field__static-value b-input-field__static-value--start\"\n el=\"span\"\n variant=\"body\"\n >\n <slot name=\"staticValue\" />\n </bento-typography>\n <div class=\"b-input-field__input-container\">\n <input\n :id=\"inputFieldId\"\n v-bind=\"$attrs\"\n ref=\"inputFieldElement\"\n class=\"b-input-field__input\"\n :aria-label=\"getAriaLabel($attrs)\"\n :aria-describedby=\"computedAriaDescribedBy\"\n :aria-owns=\"computedAriaOwns\"\n :aria-invalid=\"shouldShowError\"\n :placeholder=\"placeholder\"\n :required=\"required\"\n :aria-required=\"required\"\n :type=\"type\"\n :value=\"modelValue\"\n :disabled=\"disabled\"\n :readonly=\"isReadOnly\"\n @input=\"onInput\"\n @change=\"emit('change')\"\n @focus=\"onFocus\"\n @blur=\"onBlur\"\n @keydown=\"emit('keydown', $event)\"\n @keyup=\"emit('keyup', $event)\"\n @keydown.esc=\"emit('escape-pressed')\"\n @click=\"emit('click', $event)\"\n />\n\n <!-- Hint at the end -->\n <bento-typography v-if=\"hint && isFocused && modelValue\" el=\"span\" class=\"b-input-field__hint\">\n {{ hint }}\n </bento-typography>\n </div>\n\n <span\n v-if=\"hasSlot('iconAfter')\"\n :aria-hidden=\"ariaHidden ? 'true' : undefined\"\n class=\"b-input-field__icon-after\"\n data-testid=\"input-text__icon-after\"\n >\n <slot name=\"iconAfter\" />\n </span>\n\n <!-- Static Value at the end -->\n <bento-typography\n v-if=\"shouldDisplayStaticValueAtEnd\"\n :id=\"staticValueId\"\n class=\"b-input-field__static-value b-input-field__static-value--end\"\n el=\"span\"\n variant=\"body\"\n >\n <slot name=\"staticValue\" />\n </bento-typography>\n\n <!-- Dropdown at end -->\n <div\n v-if=\"shouldDisplayDropdownAtEnd\"\n :id=\"dropdownId\"\n data-testid=\"input-field-dropdown-container-end\"\n class=\"b-input-field__dropdown b-input-field__dropdown--end\"\n @click.stop\n >\n <bento-dropdown\n v-if=\"dropdown\"\n :id=\"dropdownId\"\n ref=\"inputDropdownElement\"\n v-bind=\"getInputFieldDropdownProps($attrs)\"\n :disabled=\"disabled\"\n :readonly=\"isDropdownReadOnly\"\n @update:model-value=\"onDropdownInput\"\n />\n </div>\n </div>\n\n <div\n v-if=\"(shouldShowError && !!errorMessage) || hasSlot('description') || description\"\n class=\"b-input-field__footer\"\n >\n <error-message v-if=\"shouldShowError && !!errorMessage\" :id=\"errorId\" :error-message=\"errorMessage\" />\n\n <span\n v-if=\"hasSlot('description') || description\"\n :id=\"descriptionId\"\n class=\"b-input-field__description\"\n @click=\"focusInput\"\n >\n <bento-typography el=\"span\" variant=\"body\">\n <slot id=\"description\" name=\"description\">\n {{ description }}\n </slot>\n </bento-typography>\n </span>\n </div>\n </bento-typography>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, inject, provide, type Ref, ref, toRef, useSlots } from 'vue';\n\n // Components\n import { BentoDropdown } from '@/components/dropdown';\n import { DROPDOWN_SMALL_SIZE_INJECTION_KEY } from '@/components/dropdown/dropdown.keys';\n import { BentoTypography } from '@/components/typography';\n import { ErrorMessage, FieldLabel } from '@/internal';\n\n // Utils\n import { deprecate } from '@/utils/ts/deprecate';\n import { useFormFieldEmits } from '@/utils/ts/form-field/form-field';\n import { generateUid } from '@/utils/ts/generate-uid';\n import { getSlotText } from '@/utils/ts/get-slot-text';\n import { useI18n } from '@/utils/ts/i18n';\n import { printDevelopmentWarning } from '@/utils/ts/print-development-warning';\n import {\n INPUT_FIELD_HINT_INJECTION_KEY,\n INPUT_FIELD_PARENT_COMPONENT_INJECTION_KEY,\n } from '@/components/input-field/input-field.keys';\n import { type BentoListboxSelectedValue } from '@/types/listbox';\n\n // Composables\n import { useFormLayoutFieldLoading, useHasSlot } from '@/composables';\n\n // Types\n import {\n type BentoInputDropdownProps,\n BentoInputFieldElementPosition,\n type BentoInputFieldProps,\n BentoInputFieldStateClass,\n BentoInputFieldType,\n type BentoInputFieldValue,\n BentoInputFieldVariant,\n } from './input-field.types';\n\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n const slots = useSlots();\n\n const props = withDefaults(defineProps<BentoInputFieldProps>(), {\n ariaHidden: true,\n condensed: false,\n description: '',\n disabled: false,\n dropdown: undefined,\n dropdownPosition: BentoInputFieldElementPosition.START,\n errorMessage: null,\n label: '',\n modelValue: undefined,\n optional: false,\n placeholder: '',\n required: false,\n readonly: false,\n slashedZero: false,\n staticValue: '',\n staticValuePosition: BentoInputFieldElementPosition.START,\n tooltipText: null,\n type: BentoInputFieldType.TEXT,\n variant: BentoInputFieldVariant.DEFAULT,\n });\n\n const emit = defineEmits<{\n /**\n * Emitted when the element has lost focus\n */\n (e: 'blur'): void;\n\n /**\n * Emitted when the input is clicked\n */\n (e: 'click', event: MouseEvent);\n\n /**\n * Emitted when the user modifies the element's value. Unlike the 'input' event, the change event is not necessarily fired for each alteration to an element's value\n */\n (e: 'change'): void;\n\n /**\n * Emitted when the Input Field's internal dropdown changes it's value\n */\n (e: 'dropdown-input', selectedValue: BentoListboxSelectedValue): void;\n\n /**\n * Emitted when the \"ESC\" key is pressed\n */\n (e: 'escape-pressed'): void;\n\n /**\n * Emitted when the element has received focus\n */\n (e: 'focus'): void;\n\n /**\n * Emitted when a key is pressed down\n */\n (e: 'keydown', event: KeyboardEvent): void;\n\n /**\n * Emitted when a key is pressed and lifted up\n */\n (e: 'keyup', event: KeyboardEvent): void;\n\n /**\n * Emitted when the Input Field's internal dropdown changes it's value. Contains every dropdown prop passed with the updated selected value as 'value'\n */\n (e: 'update:dropdown', updatedDropdownProps: BentoInputDropdownProps): void;\n\n /**\n * Emitted when the component's model changes\n */\n (e: 'update:model-value', inputValue: BentoInputFieldValue): void;\n }>();\n\n const { emitValue } = useFormFieldEmits<BentoInputFieldValue>(emit);\n const { t } = useI18n<{ message: MessageSchema }>({ messages });\n const hasSlot = useHasSlot(slots);\n const inputFieldElement = ref<HTMLInputElement>(null);\n const inputDropdownElement = ref(null);\n const inputFieldId = generateUid('input');\n const dropdownId = generateUid('input-dropdown');\n const staticValueId = generateUid('input-static-value');\n const descriptionId = generateUid('input-description');\n const errorId = generateUid('input-error');\n const isFocused = ref(false);\n\n /**\n * Gets the overriden or the default data-testid attribute\n * @param attributes - the live attributes object\n */\n function getDataTestId(attributes: Record<string, unknown>) {\n return (attributes['data-testid'] as string) ?? 'input-text-container';\n }\n /**\n * Filters out all aria attributes for the root element.\n * @param attributes - the live attributes object\n */\n function getRootAttributes(attributes: Record<string, unknown>) {\n return Object.fromEntries(\n Object.entries(attributes).filter(([key]) => !key.startsWith('aria-') && key !== 'data-testid')\n );\n }\n\n // Provide DROPDOWN_SMALL_SIZE_INJECTION_KEY as true, to set the input only dropdown size variant in the BentoDropdown comp\n provide(DROPDOWN_SMALL_SIZE_INJECTION_KEY, true);\n // Renders the input with a hint if a string is provided\n const hint = inject<Ref<string | undefined>>(INPUT_FIELD_HINT_INJECTION_KEY, ref(undefined));\n\n const onFocus = () => {\n isFocused.value = true;\n emit('focus');\n };\n\n const onBlur = () => {\n isFocused.value = false;\n emit('blur');\n };\n\n const { isReadOnly } = useFormLayoutFieldLoading(toRef(props, 'readonly'));\n const isDropdownReadOnly = computed<BentoInputDropdownProps['readonly']>(\n () => isReadOnly.value || props.dropdown?.readonly\n );\n\n const shouldShowStaticValue = computed(\n () => props.variant === BentoInputFieldVariant.STATIC_VALUE && !!slots.staticValue\n );\n\n const isDefaultVariant = computed(() => props.variant === BentoInputFieldVariant.DEFAULT);\n\n const isPaymentMethodVariant = computed(() => props.variant === BentoInputFieldVariant.PAYMENT_METHOD);\n\n const shouldDisplayStaticValueAtStart = computed(\n () => shouldShowStaticValue.value && props.staticValuePosition === BentoInputFieldElementPosition.START\n );\n const shouldDisplayStaticValueAtEnd = computed(\n () => shouldShowStaticValue.value && props.staticValuePosition === BentoInputFieldElementPosition.END\n );\n\n const shouldShowDropdown = computed(() => props.variant === BentoInputFieldVariant.DROPDOWN && !!props.dropdown);\n const shouldDisplayDropdownAtStart = computed(\n () => shouldShowDropdown.value && props.dropdownPosition === BentoInputFieldElementPosition.START\n );\n const shouldDisplayDropdownAtEnd = computed(\n () => shouldShowDropdown.value && props.dropdownPosition === BentoInputFieldElementPosition.END\n );\n\n const shouldShowError = computed(() => !props.disabled && !isReadOnly.value && !!props.errorMessage);\n\n const computedLabel = computed(() => (getSlotText(slots)('default') as string) || props.label);\n const computedDescription = computed(() => (getSlotText(slots)('description') as string) || props.description);\n\n const computedAriaOwns = computed(() => {\n if (shouldShowDropdown.value === true && shouldShowStaticValue.value === true) {\n return `${staticValueId} ${dropdownId}`;\n }\n if (shouldShowDropdown.value === true) {\n return `${dropdownId}`;\n }\n if (shouldShowStaticValue.value === true) {\n return `${staticValueId}`;\n }\n return null;\n });\n\n // vue-i18n issue with t() used in script - direct usage in template works\n // requires either createI18n({ legacy: false }) or to be wrapped in computed()\n const computedAriaLabelFallbackMessage = computed(() => t('ariaLabelFallback'));\n const getAriaLabel = (attributes: Record<string, unknown>) =>\n (attributes['aria-label'] as string | undefined) ??\n (attributes['aria-labelledby'] ? undefined : computedLabel.value || computedAriaLabelFallbackMessage.value);\n\n const computedAriaDescribedBy = computed(\n () =>\n `${computedDescription.value ? descriptionId : ''} ${\n shouldShowError.value && !!props.errorMessage ? errorId : ''\n }`\n );\n\n const inputFieldConditionalClasses = computed(() => ({\n [`b-input-field--${BentoInputFieldStateClass.CONDENSED}`]: props.condensed,\n [`b-input-field--${BentoInputFieldStateClass.DISABLED}`]: props.disabled,\n [`b-input-field--${BentoInputFieldStateClass.READONLY}`]: isReadOnly.value,\n [`b-input-field--${BentoInputFieldStateClass.ERROR}`]: shouldShowError.value,\n [`b-input-field--slashed-zero`]: props.slashedZero,\n }));\n\n const getInputFieldDropdownProps = (attributes: Record<string, unknown>) => ({\n 'aria-label': t('ariaLabelDropdownFallback', { inputLabel: getAriaLabel(attributes) }),\n ...props.dropdown,\n });\n\n const onInput = (event: Event) => {\n const inputValue = (event.target as HTMLInputElement).value;\n if (!props.disabled && !isReadOnly.value) {\n emitValue(inputValue);\n }\n };\n\n const onDropdownInput = (selectedValue: BentoListboxSelectedValue) => {\n emit('dropdown-input', selectedValue);\n emit('update:dropdown', { ...props?.dropdown, modelValue: selectedValue });\n };\n\n const focusInput = () => {\n inputFieldElement.value.focus();\n };\n\n const focus = () => {\n if (props.variant === 'dropdown') {\n inputDropdownElement.value.focus();\n } else {\n focusInput();\n }\n };\n\n // Expose focus methods for parent components in Vue 3.\n defineExpose({\n /**\n * Focuses the input field.\n */\n focusInput,\n\n /**\n * Focuses the dropdown when using the dropdown variant; otherwise focuses the input field.\n */\n focus,\n\n /**\n * Reference to the native input element.\n */\n inputFieldElement,\n });\n const inputFieldParentComponent = inject(INPUT_FIELD_PARENT_COMPONENT_INJECTION_KEY, '');\n\n if (!Object.values(BentoInputFieldType).includes(props.type as BentoInputFieldType) && !inputFieldParentComponent) {\n if (props.type === 'tel') {\n printDevelopmentWarning(\n `\"bento-input-field\" dropdown does not support the type '${props.type}', use \"bento-input-field-phone-number\" instead.`\n );\n } else if (props.type === 'password') {\n printDevelopmentWarning(\n `\"bento-input-field\" dropdown does not support the type '${props.type}', use \"bento-input-field-password\" instead.`\n );\n } else {\n printDevelopmentWarning(`\"bento-input-field\" dropdown does not support the type '${props.type}'`);\n }\n }\n\n /**\n * Deprecations\n */\n if (hasSlot('defaultIconBefore')) {\n deprecate(\n 'BentoInputField \"defaultIconBefore\" slot',\n `Use the BentoInputField \"iconBefore\" slot instead to add an icon at the left side of the input field\n <bento-input-field>\n \\t<template #iconBefore>\n \\t\\t<my-icon-goes-here />\n \\t</template>\n </bento-input-field>`,\n '3.0.0'\n );\n }\n</script>\n\n<script lang=\"ts\">\n /**\n * Input field component is used to create interactive controls for web-based\n * forms in order to accept data from the user.\n *\n * @example\n * import { BentoInputField } from '@adyen/bento-vue2'\n *\n * const inputValue = ref('');\n *\n * export default {\n * components: { BentoInputField },\n * tempate: `\n * <bento-input-field\n * :model-value=\"inputValue\"\n * :@update:model-value=\"newValue => inputValue.value = newValue\"\n * >\n * }\n */\n export default {\n name: 'bento-input-field',\n inheritAttrs: false,\n model: { prop: 'modelValue', event: 'update:model-value' },\n i18n: { messages },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./input-field.scss\" />\n"],"names":["INPUT_FIELD_HINT_INJECTION_KEY","INPUT_FIELD_PARENT_COMPONENT_INJECTION_KEY","BentoInputFieldVariant","BentoInputFieldVariant2","BentoInputFieldElementPosition","BentoInputFieldElementPosition2","BentoInputFieldStateClass","BentoInputFieldStateClass2","BentoInputFieldType","BentoInputFieldType2","BentoInputFieldEvent","BentoInputFieldEvent2","__default__","messages","slots","useSlots","props","__props","emit","__emit","emitValue","useFormFieldEmits","t","useI18n","hasSlot","useHasSlot","inputFieldElement","ref","inputDropdownElement","inputFieldId","generateUid","dropdownId","staticValueId","descriptionId","errorId","isFocused","getDataTestId","attributes","getRootAttributes","key","provide","DROPDOWN_SMALL_SIZE_INJECTION_KEY","hint","inject","onFocus","onBlur","isReadOnly","useFormLayoutFieldLoading","toRef","isDropdownReadOnly","computed","shouldShowStaticValue","isDefaultVariant","isPaymentMethodVariant","shouldDisplayStaticValueAtStart","shouldDisplayStaticValueAtEnd","shouldShowDropdown","shouldDisplayDropdownAtStart","shouldDisplayDropdownAtEnd","shouldShowError","computedLabel","getSlotText","computedDescription","computedAriaOwns","computedAriaLabelFallbackMessage","getAriaLabel","computedAriaDescribedBy","inputFieldConditionalClasses","getInputFieldDropdownProps","onInput","event","inputValue","onDropdownInput","selectedValue","focusInput","__expose","inputFieldParentComponent","printDevelopmentWarning","deprecate"],"mappings":";;;;;;;;;;;;;AAAO,MAAAA,KAAA,uBAAA,gCAAA,GACAC,KAAA,uBAAA,4CAAA;ACKA,IAAAC,IAAA,kBAAAC,OACHA,EAAA,UAAA,WACAA,EAAA,iBAAA,kBACAA,EAAA,eAAA,gBACAA,EAAA,WAAA,YAJQA,IAAAD,KAAA,CAAA,CAAA,GAULE,IAAA,kBAAAC,OACHA,EAAA,QAAA,SACAA,EAAA,MAAA,OAFQA,IAAAD,KAAA,CAAA,CAAA,GAKLE,IAAA,kBAAAC,OACHA,EAAA,YAAA,aACAA,EAAA,WAAA,YACAA,EAAA,WAAA,YACAA,EAAA,QAAA,SAJQA,IAAAD,KAAA,CAAA,CAAA,GAULE,IAAA,kBAAAC,OACHA,EAAA,SAAA,UACAA,EAAA,OAAA,QACAA,EAAA,SAAA,UAHQA,IAAAD,KAAA,CAAA,CAAA,GA0ELE,KAAA,kBAAAC,OACHA,EAAA,QAAA,SACAA,EAAA,iBAAA,kBACAA,EAAA,kBAAA,mBACAA,EAAA,iBAAA,kBACAA,EAAA,QAAA,SACAA,EAAA,SAAA,UACAA,EAAA,OAAA,QACAA,EAAA,UAAA,WARQA,IAAAD,MAAA,CAAA,CAAA;;;;;;;;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,KAAA,CAAA4D,OACI5D,EAAA,SAAA,QACI6D;AAAA,MAAA,2DAAA7D,EAAA,IAAA;AAAA,IACyE,IACzEA,EAAA,SAAA,aAEA6D;AAAA,MAAA,2DAAA7D,EAAA,IAAA;AAAA,IACyE,IAGzE6D,EAAA,2DAAA7D,EAAA,IAAA,GAAA,IAORQ,EAAA,mBAAA,KACIsD;AAAA,MAAA;AAAA,MACI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MACA;AAAA,IAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent as q, provide as K, useSlots as P, ref as G, computed as d, watch as F, openBlock as D, createBlock as b, unref as f, mergeProps as H, withCtx as g, renderSlot as M, createTextVNode as _, toDisplayString as E, createSlots as J } from "vue";
|
|
2
|
-
import { B as W, g as X } from "./dropdown.
|
|
3
|
-
import { f as Y, B as j } from "./input-field.
|
|
2
|
+
import { B as W, g as X } from "./dropdown.BvrZG8Za.js";
|
|
3
|
+
import { f as Y, B as j } from "./input-field.BBSr4o-k.js";
|
|
4
4
|
import { u as z } from "./index.CGBfMQdv.js";
|
|
5
5
|
import { p as Z } from "./typography.B6elnWpr.js";
|
|
6
6
|
import { u as Q } from "./use-has-slot.CyMiImRQ.js";
|
|
@@ -190,4 +190,4 @@ export {
|
|
|
190
190
|
I as i,
|
|
191
191
|
ye as s
|
|
192
192
|
};
|
|
193
|
-
//# sourceMappingURL=input-time.
|
|
193
|
+
//# sourceMappingURL=input-time.Cdz9Jb-1.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-time.D7UW_ww_.js","sources":["../../../vue2/src/utils/ts/time-input.ts","../../../vue2/src/components/input-time/input-time.vue"],"sourcesContent":["const validDigitRegex = /[\\d]/;\n\nconst hourRegex = /^\\d{2}$/;\nconst minuteRegex = /^\\d{2}:\\d{2}$/;\n\nconst MAX_TIME_INPUT_LENGTH = 8;\n\nconst MINUTES_IN_A_DAY = 24 * 60;\nconst MIN_TIME_INTERVAL = 5;\n\nconst minutesToTimeString = (minutes: number): string => {\n const hours = Math.floor(minutes / 60);\n const remainingMinutes = minutes % 60;\n return `${String(hours).padStart(2, '0')}:${String(remainingMinutes).padStart(2, '0')}:00`;\n};\n\nconst timeStringToSeconds = (timeText: string): number => {\n const [hours, minutes, seconds] = timeText.split(':');\n return parseInt(hours, 10) * 3600 + parseInt(minutes, 10) * 60 + parseInt(seconds, 10);\n};\n\n/**\n * Validates a complete time string in HH:MM:SS format.\n * Hours: 00-24, Minutes: 00-59, Seconds: 00-59\n * @param timeText The time string to validate\n * @returns True if the time string is valid, false otherwise\n */\nexport const isValidTimeString = (timeText: string): boolean =>\n /^(?:[01]\\d|2[0-4]):(?:[0-5]\\d):(?:[0-5]\\d)$/.test(timeText);\n\n/**\n * Validates a time interval expressed in minutes.\n * An interval must be a whole number of at least 5 minutes that divides a full day,\n * so the generated options are evenly spread from midnight onwards.\n * @param interval The interval in minutes\n * @returns True if the interval can be used to generate time options, false otherwise\n */\nexport const isValidTimeInterval = (interval: number): boolean =>\n Number.isInteger(interval) &&\n interval >= MIN_TIME_INTERVAL &&\n interval <= MINUTES_IN_A_DAY &&\n MINUTES_IN_A_DAY % interval === 0;\n\n/**\n * Generates the list of selectable times for a given interval, starting at midnight.\n * Seconds are always `00`, e.g. an interval of 60 generates `00:00:00` up to `23:00:00`.\n * @param interval The interval in minutes\n * @returns A list of time strings in HH:MM:SS format, or an empty list for an invalid interval\n */\nexport const generateTimeOptions = (interval: number): Array<string> => {\n if (!isValidTimeInterval(interval)) {\n return [];\n }\n\n const options: Array<string> = [];\n for (let minutes = 0; minutes < MINUTES_IN_A_DAY; minutes += interval) {\n options.push(minutesToTimeString(minutes));\n }\n\n return options;\n};\n\n/**\n * Snaps a time to the closest selectable time of the given interval.\n * Rounding `up` is clamped to the last selectable time, so `23:59:59` with an\n * interval of 60 resolves to `23:00:00` instead of overflowing into the next day.\n * @param timeText The time string in HH:MM:SS format\n * @param interval The interval in minutes\n * @param direction Whether to round the time down or up\n * @returns The snapped time string, or the given time when it cannot be snapped\n */\nexport const snapTimeToInterval = (timeText: string, interval: number, direction: 'down' | 'up'): string => {\n if (!timeText || !isValidTimeString(timeText) || !isValidTimeInterval(interval)) {\n return timeText;\n }\n\n const intervalInSeconds = interval * 60;\n const lastOptionInSeconds = MINUTES_IN_A_DAY * 60 - intervalInSeconds;\n const totalSeconds = timeStringToSeconds(timeText);\n\n if (totalSeconds <= lastOptionInSeconds && totalSeconds % intervalInSeconds === 0) {\n return timeText;\n }\n\n const roundedSeconds =\n direction === 'down'\n ? Math.floor(totalSeconds / intervalInSeconds) * intervalInSeconds\n : Math.ceil(totalSeconds / intervalInSeconds) * intervalInSeconds;\n\n return minutesToTimeString(Math.min(roundedSeconds, lastOptionInSeconds) / 60);\n};\n\nexport const validateTimeInput = (event: KeyboardEvent) => {\n const { selectionStart, value = '' } = event.target as HTMLInputElement;\n\n const allowedKeys = ['Backspace', 'Tab', 'ArrowLeft', 'ArrowRight'];\n const isAllowedKey = allowedKeys.includes(event.key);\n const isValidKey = validDigitRegex.test(event.key) || isAllowedKey;\n const isValidColon = [1, 2, 4, 5].includes(selectionStart) && event.key === ':';\n const isAtMaxLength = value.length >= MAX_TIME_INPUT_LENGTH;\n\n if ((!isValidKey && !isValidColon) || (isAtMaxLength && !isAllowedKey)) {\n event.preventDefault();\n }\n};\n\nexport const formatTimeInputValue = (value: string) => {\n if (!value) {\n return value;\n }\n\n let formattedValue = value;\n\n // Format if the first value is bigger than 2, because it can't be bigger than 24 hours\n if (formattedValue.length === 1 && parseInt(value, 10) > 2) {\n return `0${formattedValue}:`;\n }\n\n const [secondToLastDigit, lastDigit] = formattedValue.slice(-2);\n if ([2, 5].includes(formattedValue.length) && lastDigit === ':') {\n formattedValue = `${formattedValue.slice(0, formattedValue.length - 2)}0${secondToLastDigit}`;\n }\n\n // Add `:` after hour/minute\n if (hourRegex.test(formattedValue) || minuteRegex.test(formattedValue)) {\n formattedValue += ':';\n }\n return formattedValue;\n};\n","<template>\n <bento-dropdown\n v-if=\"isTimeDropdown\"\n class=\"b-input-time\"\n dynamic-filtering\n :condensed=\"props.condensed\"\n :disabled=\"props.disabled\"\n :error-message=\"computedErrorMessage\"\n :items=\"timeItems\"\n :label=\"props.label\"\n :model-value=\"props.modelValue ?? ''\"\n :optional=\"props.optional\"\n :placeholder=\"props.placeholder\"\n :readonly=\"props.readonly\"\n :required=\"props.required\"\n :tooltip-text=\"props.tooltipText\"\n v-bind=\"$attrs\"\n @click.native=\"emit('click', $event)\"\n @update:model-value=\"onTimeSelected\"\n >\n <template #description>\n <slot name=\"description\">{{ timeDescription }}</slot>\n </template>\n </bento-dropdown>\n <bento-input-field\n v-else\n class=\"b-input-time\"\n :type=\"inputType\"\n :step=\"nativeStep\"\n :condensed=\"props.condensed\"\n :disabled=\"props.disabled\"\n :error-message=\"inputErrorMessage\"\n :label=\"props.label\"\n :model-value=\"inputModelValue\"\n :optional=\"props.optional\"\n :placeholder=\"computedPlaceholder\"\n :readonly=\"props.readonly\"\n :required=\"props.required\"\n :tooltip-text=\"props.tooltipText\"\n v-bind=\"$attrs\"\n @click=\"emit('click', $event)\"\n @update:model-value=\"onInput\"\n @keydown=\"onKeyDown\"\n >\n <template v-if=\"hasSlot('default')\" #default>\n <slot name=\"default\"></slot>\n </template>\n <template v-if=\"!isTouchDevice\" #description>\n <slot name=\"description\">{{ timeDescription }}</slot>\n </template>\n </bento-input-field>\n</template>\n\n<script setup lang=\"ts\">\n // Components\n import { BentoDropdown } from '@/components/dropdown';\n import { BentoInputField } from '@/components/input-field';\n import { INPUT_FIELD_PARENT_COMPONENT_INJECTION_KEY } from '@/components/input-field/input-field.keys';\n\n // Utils\n import { debounce } from '@/utils/ts/debounce';\n import { useI18n } from '@/utils/ts/i18n';\n import { printDevelopmentWarning } from '@/utils/ts/print-development-warning';\n import {\n formatTimeInputValue,\n generateTimeOptions,\n isValidTimeInterval,\n isValidTimeString,\n validateTimeInput,\n } from '@/utils/ts/time-input';\n\n // Types\n import type { BentoInputFieldValue } from '@/components/input-field/input-field.types';\n import { type BentoInputTimeProps } from './input-time.types';\n\n // Localization\n import messages from './messages.json';\n\n import { computed, provide, ref, useSlots, watch } from 'vue';\n import { useHasSlot, useTouchDevice } from '@/composables';\n\n const VALIDATION_DEBOUNCE_TIME = 300;\n\n provide(INPUT_FIELD_PARENT_COMPONENT_INJECTION_KEY, 'bento-input-time');\n\n const slots = useSlots();\n const hasSlot = useHasSlot(slots);\n const { isTouchDevice } = useTouchDevice();\n\n type MessageSchema = (typeof messages)['en-US'];\n const { t } = useI18n<{ message: MessageSchema }>({ messages });\n\n const props = withDefaults(defineProps<BentoInputTimeProps>(), {\n condensed: false,\n description: undefined,\n disabled: false,\n errorMessage: null,\n interval: undefined,\n label: '',\n modelValue: undefined,\n optional: false,\n placeholder: '',\n readonly: false,\n required: false,\n tooltipText: null,\n });\n\n const emit = defineEmits<{\n /**\n * Emitted when the input is clicked\n */\n (e: 'click', event: MouseEvent): void;\n\n /**\n * Emitted when the component's model changes\n */\n (e: 'update:model-value', value: BentoInputFieldValue): void;\n\n /**\n * Emitted when a key is pressed down\n */\n (e: 'keydown', event: KeyboardEvent): void;\n\n /**\n * Emitted when the time value passes validation (complete HH:MM:SS format)\n */\n (e: 'input:valid'): void;\n\n /**\n * Emitted when the time value fails validation\n */\n (e: 'input:error'): void;\n }>();\n\n const internalError = ref(false);\n const computedErrorMessage = computed(() => {\n if (props.errorMessage) {\n return props.errorMessage;\n }\n return internalError.value ? t('invalidTimeFormat') : null;\n });\n const inputErrorMessage = computed(() => (isTouchDevice.value ? props.errorMessage : computedErrorMessage.value));\n const inputType = computed(() => (isTouchDevice.value ? 'time' : undefined));\n const inputModelValue = computed(() => props.modelValue);\n const computedPlaceholder = computed(() => (isTouchDevice ? undefined : props.placeholder));\n const timeDescription = computed(() =>\n props.description ? `${props.description} ${t('timeFormatDescription')}` : t('timeFormatDescription')\n );\n\n const hasTimeInterval = computed(() => isValidTimeInterval(props.interval));\n // On touch devices the native time input already restricts the selectable times through `step`\n const isTimeDropdown = computed(() => hasTimeInterval.value && !isTouchDevice.value);\n const timeItems = computed(() =>\n generateTimeOptions(props.interval).map(timeOption => ({ label: timeOption, value: timeOption }))\n );\n const nativeStep = computed(() => {\n if (!isTouchDevice.value) {\n return undefined;\n }\n\n return hasTimeInterval.value ? props.interval * 60 : 1;\n });\n\n watch(\n () => props.interval,\n interval => {\n if (interval != null && !isValidTimeInterval(interval)) {\n printDevelopmentWarning(\n `[bento-input-time] The \"interval\" prop must be a whole number of minutes of at least 5 that divides a full day, e.g. 5, 15, 30 or 60. Received \"${interval}\", falling back to a free text time input.`\n );\n }\n },\n { immediate: true }\n );\n\n const validateTime = (timeText: string) => {\n if (!timeText) {\n internalError.value = false;\n return;\n }\n\n const isValid = isValidTimeString(timeText);\n internalError.value = !isValid;\n\n if (isValid) {\n emit('input:valid');\n } else {\n emit('input:error');\n }\n };\n const validateTimeWithDebounce = debounce(validateTime, VALIDATION_DEBOUNCE_TIME);\n\n // Watch for external modelValue changes (e.g., when parent resets the value)\n watch(\n () => props.modelValue,\n newValue => {\n const timeText = String(newValue ?? '');\n // Clear the error only when the new value is a complete, valid time string\n if (timeText.length === 8 && isValidTimeString(timeText)) {\n internalError.value = false;\n }\n }\n );\n\n const onInput = (value: BentoInputFieldValue) => {\n if (props.disabled || props.readonly) {\n return;\n }\n\n if (isTouchDevice.value) {\n // A `step` of whole minutes hides the seconds in the native input, so they are added back\n const nativeValue = String(value ?? '');\n const shouldAppendSeconds = hasTimeInterval.value && nativeValue.length === 5;\n\n emit('update:model-value', shouldAppendSeconds ? `${nativeValue}:00` : nativeValue);\n emit('input:valid');\n } else {\n const formatted = formatTimeInputValue(String(value ?? ''));\n emit('update:model-value', formatted);\n validateTimeWithDebounce(formatted);\n }\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (!isTouchDevice.value) {\n validateTimeInput(event);\n }\n emit('keydown', event);\n };\n\n const onTimeSelected = (value: BentoInputFieldValue) => {\n if (props.disabled || props.readonly) {\n return;\n }\n\n internalError.value = false;\n emit('update:model-value', String(value ?? ''));\n emit('input:valid');\n };\n</script>\n\n<script lang=\"ts\">\n /**\n * Input time component for entering time values in HH:MM:SS format.\n * This is an extension of the `bento-input-field` component with built-in\n * time formatting and validation logic.\n *\n * @usage\n * import { BentoInputTime } from '@adyen/bento-vue2';\n *\n * const timeValue = ref('');\n *\n * export default {\n * components: { BentoInputTime },\n * template: `\n * <bento-input-time\n * label=\"Start time\"\n * :model-value=\"timeValue\"\n * @update:model-value=\"newValue => timeValue.value = newValue\"\n * />\n * `\n * }\n */\n export default {\n i18n: { messages },\n name: 'bento-input-time',\n inheritAttrs: false,\n model: { prop: 'modelValue' },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./input-time.scss\" />\n"],"names":["validDigitRegex","hourRegex","minuteRegex","MAX_TIME_INPUT_LENGTH","MINUTES_IN_A_DAY","MIN_TIME_INTERVAL","minutesToTimeString","minutes","hours","remainingMinutes","timeStringToSeconds","timeText","seconds","isValidTimeString","isValidTimeInterval","interval","generateTimeOptions","options","snapTimeToInterval","direction","intervalInSeconds","lastOptionInSeconds","totalSeconds","roundedSeconds","validateTimeInput","event","selectionStart","value","isAllowedKey","isValidKey","isValidColon","isAtMaxLength","formatTimeInputValue","formattedValue","secondToLastDigit","lastDigit","__default__","messages","provide","INPUT_FIELD_PARENT_COMPONENT_INJECTION_KEY","slots","useSlots","hasSlot","useHasSlot","isTouchDevice","useTouchDevice","t","useI18n","props","__props","emit","__emit","internalError","ref","computedErrorMessage","computed","inputErrorMessage","inputType","inputModelValue","computedPlaceholder","timeDescription","hasTimeInterval","isTimeDropdown","timeItems","timeOption","nativeStep","watch","printDevelopmentWarning","validateTimeWithDebounce","debounce","isValid","newValue","onInput","nativeValue","shouldAppendSeconds","formatted","onKeyDown","onTimeSelected"],"mappings":";;;;;;;;;AAAA,MAAAA,KAAA,QAEAC,KAAA,WACAC,KAAA,iBAEAC,KAAA,GAEAC,IAAA,MACAC,KAAA,GAEAC,IAAA,CAAAC,MAAA;AACI,QAAAC,IAAA,KAAA,MAAAD,IAAA,EAAA,GACAE,IAAAF,IAAA;AACA,SAAA,GAAA,OAAAC,CAAA,EAAA,SAAA,GAAA,GAAA,CAAA,IAAA,OAAAC,CAAA,EAAA,SAAA,GAAA,GAAA,CAAA;AACJ,GAEAC,KAAA,CAAAC,MAAA;AACI,QAAA,CAAAH,GAAAD,GAAAK,CAAA,IAAAD,EAAA,MAAA,GAAA;AACA,SAAA,SAAAH,GAAA,EAAA,IAAA,OAAA,SAAAD,GAAA,EAAA,IAAA,KAAA,SAAAK,GAAA,EAAA;AACJ,GAQOC,IAAA,CAAAF,MAAA,8CAAA,KAAAA,CAAA,GAUAG,IAAA,CAAAC,MAAA,OAAA,UAAAA,CAAA,KAAAA,KAAAV,MAAAU,KAAAX,KAAAA,IAAAW,MAAA,GAYAC,KAAA,CAAAD,MAAA;AACH,MAAA,CAAAD,EAAAC,CAAA;AACI,WAAA,CAAA;AAGJ,QAAAE,IAAA,CAAA;AACA,WAAAV,IAAA,GAAAA,IAAAH,GAAAG,KAAAQ;AACI,IAAAE,EAAA,KAAAX,EAAAC,CAAA,CAAA;AAGJ,SAAAU;AACJ,GAWOC,KAAA,CAAAP,GAAAI,GAAAI,MAAA;AACH,MAAA,CAAAR,KAAA,CAAAE,EAAAF,CAAA,KAAA,CAAAG,EAAAC,CAAA;AACI,WAAAJ;AAGJ,QAAAS,IAAAL,IAAA,IACAM,IAAAjB,IAAA,KAAAgB,GACAE,IAAAZ,GAAAC,CAAA;AAEA,MAAAW,KAAAD,KAAA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sources":["../../../vue2/src/utils/ts/time-input.ts","../../../vue2/src/components/input-time/input-time.vue"],"sourcesContent":["const validDigitRegex = /[\\d]/;\n\nconst hourRegex = /^\\d{2}$/;\nconst minuteRegex = /^\\d{2}:\\d{2}$/;\n\nconst MAX_TIME_INPUT_LENGTH = 8;\n\nconst MINUTES_IN_A_DAY = 24 * 60;\nconst MIN_TIME_INTERVAL = 5;\n\nconst minutesToTimeString = (minutes: number): string => {\n const hours = Math.floor(minutes / 60);\n const remainingMinutes = minutes % 60;\n return `${String(hours).padStart(2, '0')}:${String(remainingMinutes).padStart(2, '0')}:00`;\n};\n\nconst timeStringToSeconds = (timeText: string): number => {\n const [hours, minutes, seconds] = timeText.split(':');\n return parseInt(hours, 10) * 3600 + parseInt(minutes, 10) * 60 + parseInt(seconds, 10);\n};\n\n/**\n * Validates a complete time string in HH:MM:SS format.\n * Hours: 00-24, Minutes: 00-59, Seconds: 00-59\n * @param timeText The time string to validate\n * @returns True if the time string is valid, false otherwise\n */\nexport const isValidTimeString = (timeText: string): boolean =>\n /^(?:[01]\\d|2[0-4]):(?:[0-5]\\d):(?:[0-5]\\d)$/.test(timeText);\n\n/**\n * Validates a time interval expressed in minutes.\n * An interval must be a whole number of at least 5 minutes that divides a full day,\n * so the generated options are evenly spread from midnight onwards.\n * @param interval The interval in minutes\n * @returns True if the interval can be used to generate time options, false otherwise\n */\nexport const isValidTimeInterval = (interval: number): boolean =>\n Number.isInteger(interval) &&\n interval >= MIN_TIME_INTERVAL &&\n interval <= MINUTES_IN_A_DAY &&\n MINUTES_IN_A_DAY % interval === 0;\n\n/**\n * Generates the list of selectable times for a given interval, starting at midnight.\n * Seconds are always `00`, e.g. an interval of 60 generates `00:00:00` up to `23:00:00`.\n * @param interval The interval in minutes\n * @returns A list of time strings in HH:MM:SS format, or an empty list for an invalid interval\n */\nexport const generateTimeOptions = (interval: number): Array<string> => {\n if (!isValidTimeInterval(interval)) {\n return [];\n }\n\n const options: Array<string> = [];\n for (let minutes = 0; minutes < MINUTES_IN_A_DAY; minutes += interval) {\n options.push(minutesToTimeString(minutes));\n }\n\n return options;\n};\n\n/**\n * Snaps a time to the closest selectable time of the given interval.\n * Rounding `up` is clamped to the last selectable time, so `23:59:59` with an\n * interval of 60 resolves to `23:00:00` instead of overflowing into the next day.\n * @param timeText The time string in HH:MM:SS format\n * @param interval The interval in minutes\n * @param direction Whether to round the time down or up\n * @returns The snapped time string, or the given time when it cannot be snapped\n */\nexport const snapTimeToInterval = (timeText: string, interval: number, direction: 'down' | 'up'): string => {\n if (!timeText || !isValidTimeString(timeText) || !isValidTimeInterval(interval)) {\n return timeText;\n }\n\n const intervalInSeconds = interval * 60;\n const lastOptionInSeconds = MINUTES_IN_A_DAY * 60 - intervalInSeconds;\n const totalSeconds = timeStringToSeconds(timeText);\n\n if (totalSeconds <= lastOptionInSeconds && totalSeconds % intervalInSeconds === 0) {\n return timeText;\n }\n\n const roundedSeconds =\n direction === 'down'\n ? Math.floor(totalSeconds / intervalInSeconds) * intervalInSeconds\n : Math.ceil(totalSeconds / intervalInSeconds) * intervalInSeconds;\n\n return minutesToTimeString(Math.min(roundedSeconds, lastOptionInSeconds) / 60);\n};\n\nexport const validateTimeInput = (event: KeyboardEvent) => {\n const { selectionStart, value = '' } = event.target as HTMLInputElement;\n\n const allowedKeys = ['Backspace', 'Tab', 'ArrowLeft', 'ArrowRight'];\n const isAllowedKey = allowedKeys.includes(event.key);\n const isValidKey = validDigitRegex.test(event.key) || isAllowedKey;\n const isValidColon = [1, 2, 4, 5].includes(selectionStart) && event.key === ':';\n const isAtMaxLength = value.length >= MAX_TIME_INPUT_LENGTH;\n\n if ((!isValidKey && !isValidColon) || (isAtMaxLength && !isAllowedKey)) {\n event.preventDefault();\n }\n};\n\nexport const formatTimeInputValue = (value: string) => {\n if (!value) {\n return value;\n }\n\n let formattedValue = value;\n\n // Format if the first value is bigger than 2, because it can't be bigger than 24 hours\n if (formattedValue.length === 1 && parseInt(value, 10) > 2) {\n return `0${formattedValue}:`;\n }\n\n const [secondToLastDigit, lastDigit] = formattedValue.slice(-2);\n if ([2, 5].includes(formattedValue.length) && lastDigit === ':') {\n formattedValue = `${formattedValue.slice(0, formattedValue.length - 2)}0${secondToLastDigit}`;\n }\n\n // Add `:` after hour/minute\n if (hourRegex.test(formattedValue) || minuteRegex.test(formattedValue)) {\n formattedValue += ':';\n }\n return formattedValue;\n};\n","<template>\n <bento-dropdown\n v-if=\"isTimeDropdown\"\n class=\"b-input-time\"\n dynamic-filtering\n :condensed=\"props.condensed\"\n :disabled=\"props.disabled\"\n :error-message=\"computedErrorMessage\"\n :items=\"timeItems\"\n :label=\"props.label\"\n :model-value=\"props.modelValue ?? ''\"\n :optional=\"props.optional\"\n :placeholder=\"props.placeholder\"\n :readonly=\"props.readonly\"\n :required=\"props.required\"\n :tooltip-text=\"props.tooltipText\"\n v-bind=\"$attrs\"\n @click.native=\"emit('click', $event)\"\n @update:model-value=\"onTimeSelected\"\n >\n <template #description>\n <slot name=\"description\">{{ timeDescription }}</slot>\n </template>\n </bento-dropdown>\n <bento-input-field\n v-else\n class=\"b-input-time\"\n :type=\"inputType\"\n :step=\"nativeStep\"\n :condensed=\"props.condensed\"\n :disabled=\"props.disabled\"\n :error-message=\"inputErrorMessage\"\n :label=\"props.label\"\n :model-value=\"inputModelValue\"\n :optional=\"props.optional\"\n :placeholder=\"computedPlaceholder\"\n :readonly=\"props.readonly\"\n :required=\"props.required\"\n :tooltip-text=\"props.tooltipText\"\n v-bind=\"$attrs\"\n @click=\"emit('click', $event)\"\n @update:model-value=\"onInput\"\n @keydown=\"onKeyDown\"\n >\n <template v-if=\"hasSlot('default')\" #default>\n <slot name=\"default\"></slot>\n </template>\n <template v-if=\"!isTouchDevice\" #description>\n <slot name=\"description\">{{ timeDescription }}</slot>\n </template>\n </bento-input-field>\n</template>\n\n<script setup lang=\"ts\">\n // Components\n import { BentoDropdown } from '@/components/dropdown';\n import { BentoInputField } from '@/components/input-field';\n import { INPUT_FIELD_PARENT_COMPONENT_INJECTION_KEY } from '@/components/input-field/input-field.keys';\n\n // Utils\n import { debounce } from '@/utils/ts/debounce';\n import { useI18n } from '@/utils/ts/i18n';\n import { printDevelopmentWarning } from '@/utils/ts/print-development-warning';\n import {\n formatTimeInputValue,\n generateTimeOptions,\n isValidTimeInterval,\n isValidTimeString,\n validateTimeInput,\n } from '@/utils/ts/time-input';\n\n // Types\n import type { BentoInputFieldValue } from '@/components/input-field/input-field.types';\n import { type BentoInputTimeProps } from './input-time.types';\n\n // Localization\n import messages from './messages.json';\n\n import { computed, provide, ref, useSlots, watch } from 'vue';\n import { useHasSlot, useTouchDevice } from '@/composables';\n\n const VALIDATION_DEBOUNCE_TIME = 300;\n\n provide(INPUT_FIELD_PARENT_COMPONENT_INJECTION_KEY, 'bento-input-time');\n\n const slots = useSlots();\n const hasSlot = useHasSlot(slots);\n const { isTouchDevice } = useTouchDevice();\n\n type MessageSchema = (typeof messages)['en-US'];\n const { t } = useI18n<{ message: MessageSchema }>({ messages });\n\n const props = withDefaults(defineProps<BentoInputTimeProps>(), {\n condensed: false,\n description: undefined,\n disabled: false,\n errorMessage: null,\n interval: undefined,\n label: '',\n modelValue: undefined,\n optional: false,\n placeholder: '',\n readonly: false,\n required: false,\n tooltipText: null,\n });\n\n const emit = defineEmits<{\n /**\n * Emitted when the input is clicked\n */\n (e: 'click', event: MouseEvent): void;\n\n /**\n * Emitted when the component's model changes\n */\n (e: 'update:model-value', value: BentoInputFieldValue): void;\n\n /**\n * Emitted when a key is pressed down\n */\n (e: 'keydown', event: KeyboardEvent): void;\n\n /**\n * Emitted when the time value passes validation (complete HH:MM:SS format)\n */\n (e: 'input:valid'): void;\n\n /**\n * Emitted when the time value fails validation\n */\n (e: 'input:error'): void;\n }>();\n\n const internalError = ref(false);\n const computedErrorMessage = computed(() => {\n if (props.errorMessage) {\n return props.errorMessage;\n }\n return internalError.value ? t('invalidTimeFormat') : null;\n });\n const inputErrorMessage = computed(() => (isTouchDevice.value ? props.errorMessage : computedErrorMessage.value));\n const inputType = computed(() => (isTouchDevice.value ? 'time' : undefined));\n const inputModelValue = computed(() => props.modelValue);\n const computedPlaceholder = computed(() => (isTouchDevice ? undefined : props.placeholder));\n const timeDescription = computed(() =>\n props.description ? `${props.description} ${t('timeFormatDescription')}` : t('timeFormatDescription')\n );\n\n const hasTimeInterval = computed(() => isValidTimeInterval(props.interval));\n // On touch devices the native time input already restricts the selectable times through `step`\n const isTimeDropdown = computed(() => hasTimeInterval.value && !isTouchDevice.value);\n const timeItems = computed(() =>\n generateTimeOptions(props.interval).map(timeOption => ({ label: timeOption, value: timeOption }))\n );\n const nativeStep = computed(() => {\n if (!isTouchDevice.value) {\n return undefined;\n }\n\n return hasTimeInterval.value ? props.interval * 60 : 1;\n });\n\n watch(\n () => props.interval,\n interval => {\n if (interval != null && !isValidTimeInterval(interval)) {\n printDevelopmentWarning(\n `[bento-input-time] The \"interval\" prop must be a whole number of minutes of at least 5 that divides a full day, e.g. 5, 15, 30 or 60. Received \"${interval}\", falling back to a free text time input.`\n );\n }\n },\n { immediate: true }\n );\n\n const validateTime = (timeText: string) => {\n if (!timeText) {\n internalError.value = false;\n return;\n }\n\n const isValid = isValidTimeString(timeText);\n internalError.value = !isValid;\n\n if (isValid) {\n emit('input:valid');\n } else {\n emit('input:error');\n }\n };\n const validateTimeWithDebounce = debounce(validateTime, VALIDATION_DEBOUNCE_TIME);\n\n // Watch for external modelValue changes (e.g., when parent resets the value)\n watch(\n () => props.modelValue,\n newValue => {\n const timeText = String(newValue ?? '');\n // Clear the error only when the new value is a complete, valid time string\n if (timeText.length === 8 && isValidTimeString(timeText)) {\n internalError.value = false;\n }\n }\n );\n\n const onInput = (value: BentoInputFieldValue) => {\n if (props.disabled || props.readonly) {\n return;\n }\n\n if (isTouchDevice.value) {\n // A `step` of whole minutes hides the seconds in the native input, so they are added back\n const nativeValue = String(value ?? '');\n const shouldAppendSeconds = hasTimeInterval.value && nativeValue.length === 5;\n\n emit('update:model-value', shouldAppendSeconds ? `${nativeValue}:00` : nativeValue);\n emit('input:valid');\n } else {\n const formatted = formatTimeInputValue(String(value ?? ''));\n emit('update:model-value', formatted);\n validateTimeWithDebounce(formatted);\n }\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (!isTouchDevice.value) {\n validateTimeInput(event);\n }\n emit('keydown', event);\n };\n\n const onTimeSelected = (value: BentoInputFieldValue) => {\n if (props.disabled || props.readonly) {\n return;\n }\n\n internalError.value = false;\n emit('update:model-value', String(value ?? ''));\n emit('input:valid');\n };\n</script>\n\n<script lang=\"ts\">\n /**\n * Input time component for entering time values in HH:MM:SS format.\n * This is an extension of the `bento-input-field` component with built-in\n * time formatting and validation logic.\n *\n * @usage\n * import { BentoInputTime } from '@adyen/bento-vue2';\n *\n * const timeValue = ref('');\n *\n * export default {\n * components: { BentoInputTime },\n * template: `\n * <bento-input-time\n * label=\"Start time\"\n * :model-value=\"timeValue\"\n * @update:model-value=\"newValue => timeValue.value = newValue\"\n * />\n * `\n * }\n */\n export default {\n i18n: { messages },\n name: 'bento-input-time',\n inheritAttrs: false,\n model: { prop: 'modelValue' },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./input-time.scss\" />\n"],"names":["validDigitRegex","hourRegex","minuteRegex","MAX_TIME_INPUT_LENGTH","MINUTES_IN_A_DAY","MIN_TIME_INTERVAL","minutesToTimeString","minutes","hours","remainingMinutes","timeStringToSeconds","timeText","seconds","isValidTimeString","isValidTimeInterval","interval","generateTimeOptions","options","snapTimeToInterval","direction","intervalInSeconds","lastOptionInSeconds","totalSeconds","roundedSeconds","validateTimeInput","event","selectionStart","value","isAllowedKey","isValidKey","isValidColon","isAtMaxLength","formatTimeInputValue","formattedValue","secondToLastDigit","lastDigit","__default__","messages","provide","INPUT_FIELD_PARENT_COMPONENT_INJECTION_KEY","slots","useSlots","hasSlot","useHasSlot","isTouchDevice","useTouchDevice","t","useI18n","props","__props","emit","__emit","internalError","ref","computedErrorMessage","computed","inputErrorMessage","inputType","inputModelValue","computedPlaceholder","timeDescription","hasTimeInterval","isTimeDropdown","timeItems","timeOption","nativeStep","watch","printDevelopmentWarning","validateTimeWithDebounce","debounce","isValid","newValue","onInput","nativeValue","shouldAppendSeconds","formatted","onKeyDown","onTimeSelected"],"mappings":";;;;;;;;;AAAA,MAAAA,KAAA,QAEAC,KAAA,WACAC,KAAA,iBAEAC,KAAA,GAEAC,IAAA,MACAC,KAAA,GAEAC,IAAA,CAAAC,MAAA;AACI,QAAAC,IAAA,KAAA,MAAAD,IAAA,EAAA,GACAE,IAAAF,IAAA;AACA,SAAA,GAAA,OAAAC,CAAA,EAAA,SAAA,GAAA,GAAA,CAAA,IAAA,OAAAC,CAAA,EAAA,SAAA,GAAA,GAAA,CAAA;AACJ,GAEAC,KAAA,CAAAC,MAAA;AACI,QAAA,CAAAH,GAAAD,GAAAK,CAAA,IAAAD,EAAA,MAAA,GAAA;AACA,SAAA,SAAAH,GAAA,EAAA,IAAA,OAAA,SAAAD,GAAA,EAAA,IAAA,KAAA,SAAAK,GAAA,EAAA;AACJ,GAQOC,IAAA,CAAAF,MAAA,8CAAA,KAAAA,CAAA,GAUAG,IAAA,CAAAC,MAAA,OAAA,UAAAA,CAAA,KAAAA,KAAAV,MAAAU,KAAAX,KAAAA,IAAAW,MAAA,GAYAC,KAAA,CAAAD,MAAA;AACH,MAAA,CAAAD,EAAAC,CAAA;AACI,WAAA,CAAA;AAGJ,QAAAE,IAAA,CAAA;AACA,WAAAV,IAAA,GAAAA,IAAAH,GAAAG,KAAAQ;AACI,IAAAE,EAAA,KAAAX,EAAAC,CAAA,CAAA;AAGJ,SAAAU;AACJ,GAWOC,KAAA,CAAAP,GAAAI,GAAAI,MAAA;AACH,MAAA,CAAAR,KAAA,CAAAE,EAAAF,CAAA,KAAA,CAAAG,EAAAC,CAAA;AACI,WAAAJ;AAGJ,QAAAS,IAAAL,IAAA,IACAM,IAAAjB,IAAA,KAAAgB,GACAE,IAAAZ,GAAAC,CAAA;AAEA,MA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
|
1
1
|
import { defineComponent as L, computed as P, watch as x, openBlock as n, createElementBlock as d, createVNode as u, unref as t, withCtx as m, createBlock as b, resolveDynamicComponent as F, mergeProps as S, createSlots as E, createTextVNode as y, toDisplayString as N, getCurrentInstance as $, createCommentVNode as C, createElementVNode as c, useSlots as R, normalizeClass as U, renderSlot as j } from "vue";
|
|
2
2
|
import { p as G, B as I } from "./typography.B6elnWpr.js";
|
|
3
|
-
import { B as O } from "./dropdown.
|
|
3
|
+
import { B as O } from "./dropdown.BvrZG8Za.js";
|
|
4
4
|
import { g as V } from "./generate-uid.DBWe4g6T.js";
|
|
5
5
|
import { u as z, g as W, a as D } from "./index.CGBfMQdv.js";
|
|
6
6
|
import { _ as B } from "./_plugin-vue_export-helper.CHgC5LLL.js";
|
|
@@ -411,4 +411,4 @@ const A = {
|
|
|
411
411
|
export {
|
|
412
412
|
ke as B
|
|
413
413
|
};
|
|
414
|
-
//# sourceMappingURL=pagination.
|
|
414
|
+
//# sourceMappingURL=pagination.DbGaudSO.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.C-kvJ-XK.js","sources":["../../../vue2/src/components/pagination/components/pagination-results-per-page/pagination-results-per-page.vue","../../../vue2/src/components/pagination/components/pagination-context/pagination-context.vue","../../../ui-assets/icons-16/dist/vue/skip-left.vue","../../../ui-assets/icons-16/dist/vue/skip-right.vue","../../../ui-assets/icons-16/dist/vue/chevron-left-small.vue","../../../vue2/src/components/pagination/components/pagination-controls/pagination-controls.vue","../../../vue2/src/components/pagination/pagination.vue"],"sourcesContent":["<template>\n <div class=\"b-pagination-results-per-page\">\n <bento-typography el=\"div\">\n <component\n :is=\"i18nComponent\"\n v-bind=\"getI18nProps(translationPathKey)\"\n class=\"b-pagination-results-per-page__dropdown-container\"\n tag=\"div\"\n :plural=\"totalCount\"\n >\n <template v-if=\"hidePageSizeSelection\" #itemCount>{{ itemsPerPage }}</template>\n\n <template v-else #itemCount>\n <bento-dropdown\n :id=\"dropdownId\"\n :aria-label=\"t(translationPathKey, { itemCount: itemsPerPage, totalCount })\"\n class=\"b-pagination-results-per-page__dropdown\"\n condensed\n :items=\"predefinedDropdownOptions\"\n :model-value=\"itemsPerPage\"\n @update:model-value=\"onSelectChange\"\n />\n </template>\n <template v-if=\"!!totalCount\" #totalCount>{{ totalCount }}</template>\n </component>\n </bento-typography>\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, watch } from 'vue';\n import { BentoTypography } from '@/components/typography';\n import { BentoDropdown } from '@/components/dropdown';\n import { generateUid } from '@/utils/ts/generate-uid';\n import { getI18nComponent, getI18nProps, useI18n } from '@/utils/ts/i18n';\n import { printDevelopmentWarning } from '@/utils/ts/print-development-warning';\n\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n const { t, n } = useI18n<{ message: MessageSchema }>({ messages });\n\n const props = withDefaults(\n defineProps<{\n /**\n * Determines whether to hide the dropdown that allows users to change the number of results per page.\n * When set to `true`, the current `itemsPerPage` value is displayed as plain static text.\n */\n hidePageSizeSelection?: boolean;\n /**\n * The amount of items the pager is paging through.\n */\n itemsPerPage?: number;\n /**\n * The total number of items the pager is paging through.\n */\n totalCount?: number;\n /**\n * The predefined options for the results per page dropdown.\n */\n pageSizeItems?: Array<number>;\n }>(),\n {\n hidePageSizeSelection: false,\n itemsPerPage: 50,\n totalCount: null,\n pageSizeItems: () => [10, 20, 50, 75, 100],\n }\n );\n\n const emit = defineEmits<{\n (e: 'select', value: number);\n }>();\n\n const isValid = computed(\n () => Array.isArray(props.pageSizeItems) && props.pageSizeItems.every(option => Number.isInteger(option))\n );\n\n watch(\n isValid,\n valid => {\n if (!valid) {\n printDevelopmentWarning('BentoPagination: pageSizeItems must be an array of integers.');\n }\n },\n { immediate: true }\n );\n\n const dropdownId = generateUid('b-pagination-context-number-elements');\n const predefinedDropdownOptions = computed(() =>\n props.pageSizeItems.map(option => ({\n label: n(option),\n value: option,\n }))\n );\n const i18nComponent = getI18nComponent();\n\n const onSelectChange = (selectedNumberOfResults: number) => {\n emit('select', selectedNumberOfResults);\n };\n\n const translationPathKey = computed(() => (props.totalCount ? 'showingItemsWithTotal' : 'showingItems'));\n</script>\n\n<script lang=\"ts\">\n export default {\n i18n: { messages },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./pagination-results-per-page.scss\" />\n","<template>\n <div class=\"b-pagination-context\">\n <bento-typography v-if=\"totalPages > 1 && !hidePageSelection\" el=\"div\">\n <component :is=\"i18nComponent\" v-bind=\"getI18nProps('pageNumber')\" tag=\"div\">\n <template #page>\n <bento-dropdown\n :id=\"dropdownId\"\n :aria-label=\"t('pageNumber', { page: n(page) })\"\n class=\"b-pagination-context__dropdown\"\n condensed\n :items=\"listOfAvailablePages\"\n :model-value=\"page\"\n :virtual-scroll=\"virtualScroll\"\n @update:model-value=\"onPageSelectChange\"\n />\n </template>\n </component>\n </bento-typography>\n <bento-typography v-else-if=\"showPageNumberOfTotal\" el=\"span\">\n {{ t('pageNumberOfTotal', { page: n(page), totalPages: n(totalPages) }) }}\n </bento-typography>\n <bento-typography v-else el=\"span\">\n {{ t('pageNumber', { page: n(page) }) }}\n </bento-typography>\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import { computed } from 'vue';\n import { BentoTypography } from '@/components/typography';\n import { BentoDropdown } from '@/components/dropdown';\n import { type BentoListboxOptionItem } from '@/types/listbox';\n import { generateUid } from '@/utils/ts/generate-uid';\n import messages from './messages.json';\n import { getI18nComponent, getI18nProps, useI18n } from '@/utils/ts/i18n';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n const props = withDefaults(\n defineProps<{\n /**\n * Hides the page selection dropdown and displays a static \"Page X of Y\" text instead.\n * Useful for very large datasets where rendering all page options would cause performance issues.\n */\n hidePageSelection?: boolean;\n /**\n * The current page number of the pager.\n */\n page?: number;\n\n /**\n * The total number of items the pager is paging through.\n */\n totalPages?: number;\n\n /**\n * Enables virtual scrolling on all dropdowns if set to true.\n */\n virtualScroll?: boolean;\n }>(),\n {\n hidePageSelection: false,\n page: 1,\n totalPages: null,\n virtualScroll: false,\n }\n );\n const emit = defineEmits<{\n (e: 'page-selected', value: string | number);\n }>();\n\n const { t, n } = useI18n<{ message: MessageSchema }>({ messages });\n const dropdownId = generateUid('bento-pagination-context-current-page');\n const onPageSelectChange = (selectedPage: string | number) => emit('page-selected', selectedPage);\n const i18nComponent = getI18nComponent();\n\n // Generate a list of pages from 1 to \"totalPages\"\n const transformIntoOption = (value: number): BentoListboxOptionItem => ({\n label: n(value),\n value,\n });\n const transformToPageNumber = (_, index) => index + 1;\n const listOfAvailablePages = computed(() =>\n Array.from(new Array(props.totalPages), transformToPageNumber).map(transformIntoOption)\n );\n const showPageNumberOfTotal = computed(\n () => props.totalPages === 1 || (props.hidePageSelection && props.page <= props.totalPages)\n );\n</script>\n\n<script lang=\"ts\">\n export default {\n i18n: { messages },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./pagination-context.scss\" />\n","\n<template>\n <svg role=\"img\" v-bind=\"$attrs\" class=\"ui-assets-icons-16\" xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"none\"><title v-if=\"$attrs['svg-title']\">{{ $attrs['svg-title'] }}</title><path fill=\"#001222\" d=\"M9.06055 8.00011L12.0605 5.00011L10.9999 3.93945L6.93923 8.00011L10.9999 12.0608L12.0605 11.0001L9.06055 8.00011Z\"/><path fill=\"#001222\" d=\"M4.25 4.25L4.25 11.75H5.75L5.75 4.25L4.25 4.25Z\"/></svg>\n</template>\n<script setup>\n import { getCurrentInstance } from 'vue';\n import '../css/main.css';\n\n const instance = getCurrentInstance();\n const uuid = String(instance?.uid ?? instance?.proxy?._uid);\n</script>\n","\n<template>\n <svg role=\"img\" v-bind=\"$attrs\" class=\"ui-assets-icons-16\" xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"none\"><title v-if=\"$attrs['svg-title']\">{{ $attrs['svg-title'] }}</title><path fill=\"#001222\" d=\"M6.93945 7.99962L3.93945 10.9996L5.00011 12.0603L9.06077 7.99963L5.00011 3.93896L3.93945 4.99963L6.93945 7.99962Z\"/><path fill=\"#001222\" d=\"M11.75 11.7497V4.24974L10.25 4.24974V11.7497H11.75Z\"/></svg>\n</template>\n<script setup>\n import { getCurrentInstance } from 'vue';\n import '../css/main.css';\n\n const instance = getCurrentInstance();\n const uuid = String(instance?.uid ?? instance?.proxy?._uid);\n</script>\n","\n<template>\n <svg role=\"img\" v-bind=\"$attrs\" class=\"ui-assets-icons-16\" xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"none\"><title v-if=\"$attrs['svg-title']\">{{ $attrs['svg-title'] }}</title><path fill=\"#001222\" d=\"M10.5608 5.00011L7.56077 8.00011L10.5608 11.0001L9.50011 12.0608L5.43945 8.00011L9.50011 3.93945L10.5608 5.00011Z\"/></svg>\n</template>\n<script setup>\n import { getCurrentInstance } from 'vue';\n import '../css/main.css';\n\n const instance = getCurrentInstance();\n const uuid = String(instance?.uid ?? instance?.proxy?._uid);\n</script>\n","<template>\n <ul class=\"b-pagination-controls\">\n <li v-if=\"!hideFirstLastPageButtons\" key=\"first\" class=\"b-pagination-controls__item\">\n <!-- Navigate to the first page -->\n <bento-button :disabled=\"isCurrentPageFirst\" variant=\"tertiary\" condensed @click=\"navigate(1)\">\n <template #iconLeft>\n <skip-left :svg-title=\"t('navigateToTheFirstPage')\" />\n </template>\n </bento-button>\n </li>\n <li key=\"previous\" class=\"b-pagination-controls__item\">\n <!-- Navigate to the previous page -->\n <bento-button :disabled=\"isCurrentPageFirst\" variant=\"tertiary\" condensed @click=\"navigate(page - 1)\">\n <template #iconLeft>\n <chevron-left :svg-title=\"t('navigateToThePreviousPage')\" />\n </template>\n </bento-button>\n </li>\n <li key=\"next\" class=\"b-pagination-controls__item\">\n <!-- Navigate to the next page -->\n <bento-button :disabled=\"isNextButtonDisabled\" variant=\"tertiary\" condensed @click=\"navigate(page + 1)\">\n <template #iconLeft>\n <chevron-right :svg-title=\"t('navigateToTheNextPage')\" />\n </template>\n </bento-button>\n </li>\n <li v-if=\"!hideFirstLastPageButtons\" key=\"last\" class=\"b-pagination-controls__item\">\n <!-- Navigate to the last page -->\n <bento-button\n :disabled=\"isLastPageButtonDisabled\"\n variant=\"tertiary\"\n condensed\n @click=\"navigate(totalPages)\"\n >\n <template #iconLeft>\n <skip-right :svg-title=\"t('navigateToTheLastPage')\" />\n </template>\n </bento-button>\n </li>\n </ul>\n</template>\n\n<script setup lang=\"ts\">\n import { computed } from 'vue';\n import { BentoButton } from '@/components/button';\n import { useI18n } from '@/utils/ts/i18n';\n import SkipLeft from '@adyen/ui-assets-icons-16/vue/skip-left';\n import SkipRight from '@adyen/ui-assets-icons-16/vue/skip-right';\n import ChevronLeft from '@adyen/ui-assets-icons-16/vue/chevron-left-small';\n import ChevronRight from '@adyen/ui-assets-icons-16/vue/chevron-right-small';\n\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n const props = withDefaults(\n defineProps<{\n /**\n * Use to determine if the pager has a \"next page\".\n */\n hasNext?: boolean;\n\n /**\n * Hides the \"navigate to the first page\" and \"navigate to the last page\" buttons.\n * Useful for cursor-based pagination, where jumping directly to the first or last page is not supported.\n */\n hideFirstLastPageButtons?: boolean;\n\n /**\n * The current page number of the pager.\n */\n page: number;\n\n /**\n * The current page number of the pager.\n */\n totalPages?: number;\n }>(),\n {\n hasNext: null,\n hideFirstLastPageButtons: false,\n totalPages: null,\n }\n );\n\n const emit = defineEmits<{\n (e: 'navigate', value: number);\n }>();\n\n const { t } = useI18n<{ message: MessageSchema }>({ messages });\n\n const isCurrentPageFirst = computed(() => props.page === 1);\n const isCurrentPageLast = computed(() => props.page === props.totalPages);\n const isNextButtonDisabled = computed(() => {\n const hasNoNextPage = !props.hasNext;\n return hasNoNextPage || isCurrentPageLast.value;\n });\n const isLastPageButtonDisabled = computed(() => {\n const hasNoNextPage = !props.hasNext;\n const hasNoTotalPagesNumber = !props.totalPages;\n\n return hasNoNextPage || isCurrentPageLast.value || hasNoTotalPagesNumber;\n });\n\n const navigate = (pageArg: number) => {\n emit('navigate', pageArg);\n };\n</script>\n\n<script lang=\"ts\">\n export default {\n i18n: { messages },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./pagination-controls.scss\" />\n","<template>\n <div class=\"b-pagination\">\n <nav\n :aria-label=\"$attrs['aria-label']\"\n class=\"b-pagination__navigation\"\n :class=\"navigationConditionalClasses()\"\n >\n <bento-pagination-results-per-page\n v-if=\"!hidePageSize\"\n class=\"b-pagination__results-per-page\"\n :hide-page-size-selection=\"hidePageSizeSelection\"\n :items-per-page=\"size\"\n :total-count=\"totalCount\"\n :page-size-items=\"pageSizeItems\"\n @select=\"onItemsPerPageChange\"\n />\n <bento-typography v-else-if=\"hasSlot('default')\"><slot /></bento-typography>\n\n <div class=\"b-pagination__page-navigator\">\n <bento-pagination-context\n class=\"b-pagination__context\"\n :total-pages=\"totalPages\"\n :page=\"page\"\n :virtual-scroll=\"virtualScroll\"\n :hide-page-selection=\"hidePageSelection\"\n @page-selected=\"onPageSelected\"\n />\n\n <div class=\"b-pagination__divider\"></div>\n\n <bento-pagination-controls\n class=\"b-pagination__controls\"\n :has-next=\"hasNext\"\n :hide-first-last-page-buttons=\"hideFirstLastPageButtons\"\n :page=\"page\"\n :total-pages=\"totalPages\"\n @navigate=\"navigate\"\n />\n </div>\n </nav>\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, useSlots } from 'vue';\n import { BentoTypography } from '@/components/typography';\n import BentoPaginationResultsPerPage from './components/pagination-results-per-page/pagination-results-per-page.vue';\n import BentoPaginationContext from './components/pagination-context/pagination-context.vue';\n import BentoPaginationControls from './components/pagination-controls/pagination-controls.vue';\n import { useHasSlot } from '@/composables';\n import type { BentoPaginationProps } from './pagination.types';\n\n const props = withDefaults(defineProps<BentoPaginationProps>(), {\n hasNext: null,\n hideFirstLastPageButtons: false,\n hidePageSize: false,\n hidePageSelection: false,\n hidePageSizeSelection: false,\n page: 1,\n pageSizeItems: undefined,\n size: 20,\n totalCount: null,\n virtualScroll: false,\n });\n\n const emit = defineEmits<{\n /**\n * Triggered when the navigation controls are clicked or the items per page is changed (i.e. when the arrow buttons to the\n * rightmost of the screen or either dropdown is updated). It indicates to which page it should go next and also the page size.\n */\n (e: 'navigate', page: number, items?: number): void;\n\n /**\n * Triggered when the number of items per page is changed from the left hand dropdown.\n * It indicates the new number of items that will be displayed.\n */\n (e: 'items-page', size: number): void;\n\n /**\n * Triggered when the navigation controls are clicked, whether the arrow buttons to the\n * right most of the screen or the dropdown on the right hand is updated.\n * It indicates to which page it should go next\n * (easily achieved using the [sync modifier](https://v2.vuejs.org/v2/guide/components-custom-events.html#sync-Modifier))\n * e.g. `:page.sync=\"currentPage\"`\n */\n (e: 'update:page', page: number): void;\n\n /**\n * Triggered when the number of items per page is changed from the left hand dropdown.\n * It indicates the new number of items that will be displayed.\n * (easily achieved using the [sync modifier](https://v2.vuejs.org/v2/guide/components-custom-events.html#sync-Modifier))\n * e.g. `:size.sync=\"itemsPerPage\"`\n */\n (e: 'update:size', size: number): void;\n }>();\n\n const slots = useSlots();\n const hasSlot = useHasSlot(slots);\n\n const totalPages = computed(() =>\n !props.totalCount || !props.size ? null : Math.ceil(props.totalCount / props.size)\n );\n\n const navigate = (pageArg: number, itemsPerPage?: number) => {\n if (props.hidePageSize) {\n emit('navigate', pageArg);\n } else {\n emit('navigate', pageArg, itemsPerPage ?? props?.size);\n }\n emit('update:page', pageArg);\n };\n\n const onPageSelected = (pageNumber: number) => {\n navigate(pageNumber);\n };\n\n const onItemsPerPageChange = (elements: number) => {\n emit('items-page', elements);\n emit('update:size', elements);\n\n // Always go to first page when the\n // number of items page changes\n navigate(1, elements);\n };\n\n const navigationConditionalClasses = () => ({\n 'b-pagination__navigation--only-page-navigator': !hasSlot('default') && props.hidePageSize,\n });\n</script>\n\n<script lang=\"ts\">\n /**\n * Paginiation component to help users page through data sets.\n *\n * There are two ways of doing navigation in this component:\n * 1. (Basic) You tell the component if there is a next page (hasNext)\n * 2. (Enhanced) You tell the component:\n * - How many total items exist (totalCount)\n * - The max number of items that you show/fetch per page (size)\n * - In this case you should not set the hasNext props\n *\n * If you have the data available and opt to use the Enhanced way you get extra controls:\n * - Page dropdown selector\n * - Last page button\n * - \"Showing 10 of 200 items\" text\n *\n * @usage\n * import { BentoPagination } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoPagination },\n * template: `\n * <bento-pagination :has-next=\"isNextPage\" />\n * `,\n * }\n */\n\n export default {\n name: 'bento-pagination',\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./pagination.scss\" />\n"],"names":["__default__$3","messages$2","t","n","useI18n","props","__props","emit","__emit","isValid","computed","option","watch","valid","printDevelopmentWarning","dropdownId","generateUid","predefinedDropdownOptions","i18nComponent","getI18nComponent","onSelectChange","selectedNumberOfResults","translationPathKey","__default__$2","messages$1","onPageSelectChange","selectedPage","transformIntoOption","value","transformToPageNumber","_","index","listOfAvailablePages","showPageNumberOfTotal","instance","getCurrentInstance","__default__$1","messages","isCurrentPageFirst","isCurrentPageLast","isNextButtonDisabled","isLastPageButtonDisabled","hasNoNextPage","hasNoTotalPagesNumber","navigate","pageArg","__default__","slots","useSlots","hasSlot","useHasSlot","totalPages","itemsPerPage","onPageSelected","pageNumber","onItemsPerPageChange","elements","navigationConditionalClasses"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;mDA0GIA,IAAA;AAAA,EAAe,MAAA,EAAA,UAAAC,EAAA;AAEf;;;;;;;;;;;AAnEA,UAAA,EAAA,GAAAC,GAAA,GAAAC,EAAA,IAAAC,EAAA,EAAA,UAAAH,EAAA,CAAA,GAEAI,IAAAC,GA4BAC,IAAAC,GAIAC,IAAAC;AAAA,MAAgB,MAAA,MAAA,QAAAL,EAAA,aAAA,KAAAA,EAAA,cAAA,MAAA,CAAAM,MAAA,OAAA,UAAAA,CAAA,CAAA;AAAA,IAC4F;AAG5G,IAAAC;AAA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/C,EAAA,eACIE,EAAA,YAAAsC,CAAA,IAEAtC,EAAA,YAAAsC,GAAAO,KAAA/C,GAAA,IAAA,GAEJE,EAAA,eAAAsC,CAAA;AAAA,IAA2B,GAG/BQ,IAAA,CAAAC,MAAA;AACI,MAAAV,EAAAU,CAAA;AAAA,IAAmB,GAGvBC,IAAA,CAAAC,MAAA;AACI,MAAAjD,EAAA,cAAAiD,CAAA,GACAjD,EAAA,eAAAiD,CAAA,GAIAZ,EAAA,GAAAY,CAAA;AAAA,IAAoB,GAGxBC,IAAA,OAAA;AAAA,MAA4C,iDAAA,CAAAR,EAAA,SAAA,KAAA5C,EAAA;AAAA,IACsC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"pagination.DbGaudSO.js","sources":["../../../vue2/src/components/pagination/components/pagination-results-per-page/pagination-results-per-page.vue","../../../vue2/src/components/pagination/components/pagination-context/pagination-context.vue","../../../ui-assets/icons-16/dist/vue/skip-left.vue","../../../ui-assets/icons-16/dist/vue/skip-right.vue","../../../ui-assets/icons-16/dist/vue/chevron-left-small.vue","../../../vue2/src/components/pagination/components/pagination-controls/pagination-controls.vue","../../../vue2/src/components/pagination/pagination.vue"],"sourcesContent":["<template>\n <div class=\"b-pagination-results-per-page\">\n <bento-typography el=\"div\">\n <component\n :is=\"i18nComponent\"\n v-bind=\"getI18nProps(translationPathKey)\"\n class=\"b-pagination-results-per-page__dropdown-container\"\n tag=\"div\"\n :plural=\"totalCount\"\n >\n <template v-if=\"hidePageSizeSelection\" #itemCount>{{ itemsPerPage }}</template>\n\n <template v-else #itemCount>\n <bento-dropdown\n :id=\"dropdownId\"\n :aria-label=\"t(translationPathKey, { itemCount: itemsPerPage, totalCount })\"\n class=\"b-pagination-results-per-page__dropdown\"\n condensed\n :items=\"predefinedDropdownOptions\"\n :model-value=\"itemsPerPage\"\n @update:model-value=\"onSelectChange\"\n />\n </template>\n <template v-if=\"!!totalCount\" #totalCount>{{ totalCount }}</template>\n </component>\n </bento-typography>\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, watch } from 'vue';\n import { BentoTypography } from '@/components/typography';\n import { BentoDropdown } from '@/components/dropdown';\n import { generateUid } from '@/utils/ts/generate-uid';\n import { getI18nComponent, getI18nProps, useI18n } from '@/utils/ts/i18n';\n import { printDevelopmentWarning } from '@/utils/ts/print-development-warning';\n\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n const { t, n } = useI18n<{ message: MessageSchema }>({ messages });\n\n const props = withDefaults(\n defineProps<{\n /**\n * Determines whether to hide the dropdown that allows users to change the number of results per page.\n * When set to `true`, the current `itemsPerPage` value is displayed as plain static text.\n */\n hidePageSizeSelection?: boolean;\n /**\n * The amount of items the pager is paging through.\n */\n itemsPerPage?: number;\n /**\n * The total number of items the pager is paging through.\n */\n totalCount?: number;\n /**\n * The predefined options for the results per page dropdown.\n */\n pageSizeItems?: Array<number>;\n }>(),\n {\n hidePageSizeSelection: false,\n itemsPerPage: 50,\n totalCount: null,\n pageSizeItems: () => [10, 20, 50, 75, 100],\n }\n );\n\n const emit = defineEmits<{\n (e: 'select', value: number);\n }>();\n\n const isValid = computed(\n () => Array.isArray(props.pageSizeItems) && props.pageSizeItems.every(option => Number.isInteger(option))\n );\n\n watch(\n isValid,\n valid => {\n if (!valid) {\n printDevelopmentWarning('BentoPagination: pageSizeItems must be an array of integers.');\n }\n },\n { immediate: true }\n );\n\n const dropdownId = generateUid('b-pagination-context-number-elements');\n const predefinedDropdownOptions = computed(() =>\n props.pageSizeItems.map(option => ({\n label: n(option),\n value: option,\n }))\n );\n const i18nComponent = getI18nComponent();\n\n const onSelectChange = (selectedNumberOfResults: number) => {\n emit('select', selectedNumberOfResults);\n };\n\n const translationPathKey = computed(() => (props.totalCount ? 'showingItemsWithTotal' : 'showingItems'));\n</script>\n\n<script lang=\"ts\">\n export default {\n i18n: { messages },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./pagination-results-per-page.scss\" />\n","<template>\n <div class=\"b-pagination-context\">\n <bento-typography v-if=\"totalPages > 1 && !hidePageSelection\" el=\"div\">\n <component :is=\"i18nComponent\" v-bind=\"getI18nProps('pageNumber')\" tag=\"div\">\n <template #page>\n <bento-dropdown\n :id=\"dropdownId\"\n :aria-label=\"t('pageNumber', { page: n(page) })\"\n class=\"b-pagination-context__dropdown\"\n condensed\n :items=\"listOfAvailablePages\"\n :model-value=\"page\"\n :virtual-scroll=\"virtualScroll\"\n @update:model-value=\"onPageSelectChange\"\n />\n </template>\n </component>\n </bento-typography>\n <bento-typography v-else-if=\"showPageNumberOfTotal\" el=\"span\">\n {{ t('pageNumberOfTotal', { page: n(page), totalPages: n(totalPages) }) }}\n </bento-typography>\n <bento-typography v-else el=\"span\">\n {{ t('pageNumber', { page: n(page) }) }}\n </bento-typography>\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import { computed } from 'vue';\n import { BentoTypography } from '@/components/typography';\n import { BentoDropdown } from '@/components/dropdown';\n import { type BentoListboxOptionItem } from '@/types/listbox';\n import { generateUid } from '@/utils/ts/generate-uid';\n import messages from './messages.json';\n import { getI18nComponent, getI18nProps, useI18n } from '@/utils/ts/i18n';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n const props = withDefaults(\n defineProps<{\n /**\n * Hides the page selection dropdown and displays a static \"Page X of Y\" text instead.\n * Useful for very large datasets where rendering all page options would cause performance issues.\n */\n hidePageSelection?: boolean;\n /**\n * The current page number of the pager.\n */\n page?: number;\n\n /**\n * The total number of items the pager is paging through.\n */\n totalPages?: number;\n\n /**\n * Enables virtual scrolling on all dropdowns if set to true.\n */\n virtualScroll?: boolean;\n }>(),\n {\n hidePageSelection: false,\n page: 1,\n totalPages: null,\n virtualScroll: false,\n }\n );\n const emit = defineEmits<{\n (e: 'page-selected', value: string | number);\n }>();\n\n const { t, n } = useI18n<{ message: MessageSchema }>({ messages });\n const dropdownId = generateUid('bento-pagination-context-current-page');\n const onPageSelectChange = (selectedPage: string | number) => emit('page-selected', selectedPage);\n const i18nComponent = getI18nComponent();\n\n // Generate a list of pages from 1 to \"totalPages\"\n const transformIntoOption = (value: number): BentoListboxOptionItem => ({\n label: n(value),\n value,\n });\n const transformToPageNumber = (_, index) => index + 1;\n const listOfAvailablePages = computed(() =>\n Array.from(new Array(props.totalPages), transformToPageNumber).map(transformIntoOption)\n );\n const showPageNumberOfTotal = computed(\n () => props.totalPages === 1 || (props.hidePageSelection && props.page <= props.totalPages)\n );\n</script>\n\n<script lang=\"ts\">\n export default {\n i18n: { messages },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./pagination-context.scss\" />\n","\n<template>\n <svg role=\"img\" v-bind=\"$attrs\" class=\"ui-assets-icons-16\" xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"none\"><title v-if=\"$attrs['svg-title']\">{{ $attrs['svg-title'] }}</title><path fill=\"#001222\" d=\"M9.06055 8.00011L12.0605 5.00011L10.9999 3.93945L6.93923 8.00011L10.9999 12.0608L12.0605 11.0001L9.06055 8.00011Z\"/><path fill=\"#001222\" d=\"M4.25 4.25L4.25 11.75H5.75L5.75 4.25L4.25 4.25Z\"/></svg>\n</template>\n<script setup>\n import { getCurrentInstance } from 'vue';\n import '../css/main.css';\n\n const instance = getCurrentInstance();\n const uuid = String(instance?.uid ?? instance?.proxy?._uid);\n</script>\n","\n<template>\n <svg role=\"img\" v-bind=\"$attrs\" class=\"ui-assets-icons-16\" xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"none\"><title v-if=\"$attrs['svg-title']\">{{ $attrs['svg-title'] }}</title><path fill=\"#001222\" d=\"M6.93945 7.99962L3.93945 10.9996L5.00011 12.0603L9.06077 7.99963L5.00011 3.93896L3.93945 4.99963L6.93945 7.99962Z\"/><path fill=\"#001222\" d=\"M11.75 11.7497V4.24974L10.25 4.24974V11.7497H11.75Z\"/></svg>\n</template>\n<script setup>\n import { getCurrentInstance } from 'vue';\n import '../css/main.css';\n\n const instance = getCurrentInstance();\n const uuid = String(instance?.uid ?? instance?.proxy?._uid);\n</script>\n","\n<template>\n <svg role=\"img\" v-bind=\"$attrs\" class=\"ui-assets-icons-16\" xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"none\"><title v-if=\"$attrs['svg-title']\">{{ $attrs['svg-title'] }}</title><path fill=\"#001222\" d=\"M10.5608 5.00011L7.56077 8.00011L10.5608 11.0001L9.50011 12.0608L5.43945 8.00011L9.50011 3.93945L10.5608 5.00011Z\"/></svg>\n</template>\n<script setup>\n import { getCurrentInstance } from 'vue';\n import '../css/main.css';\n\n const instance = getCurrentInstance();\n const uuid = String(instance?.uid ?? instance?.proxy?._uid);\n</script>\n","<template>\n <ul class=\"b-pagination-controls\">\n <li v-if=\"!hideFirstLastPageButtons\" key=\"first\" class=\"b-pagination-controls__item\">\n <!-- Navigate to the first page -->\n <bento-button :disabled=\"isCurrentPageFirst\" variant=\"tertiary\" condensed @click=\"navigate(1)\">\n <template #iconLeft>\n <skip-left :svg-title=\"t('navigateToTheFirstPage')\" />\n </template>\n </bento-button>\n </li>\n <li key=\"previous\" class=\"b-pagination-controls__item\">\n <!-- Navigate to the previous page -->\n <bento-button :disabled=\"isCurrentPageFirst\" variant=\"tertiary\" condensed @click=\"navigate(page - 1)\">\n <template #iconLeft>\n <chevron-left :svg-title=\"t('navigateToThePreviousPage')\" />\n </template>\n </bento-button>\n </li>\n <li key=\"next\" class=\"b-pagination-controls__item\">\n <!-- Navigate to the next page -->\n <bento-button :disabled=\"isNextButtonDisabled\" variant=\"tertiary\" condensed @click=\"navigate(page + 1)\">\n <template #iconLeft>\n <chevron-right :svg-title=\"t('navigateToTheNextPage')\" />\n </template>\n </bento-button>\n </li>\n <li v-if=\"!hideFirstLastPageButtons\" key=\"last\" class=\"b-pagination-controls__item\">\n <!-- Navigate to the last page -->\n <bento-button\n :disabled=\"isLastPageButtonDisabled\"\n variant=\"tertiary\"\n condensed\n @click=\"navigate(totalPages)\"\n >\n <template #iconLeft>\n <skip-right :svg-title=\"t('navigateToTheLastPage')\" />\n </template>\n </bento-button>\n </li>\n </ul>\n</template>\n\n<script setup lang=\"ts\">\n import { computed } from 'vue';\n import { BentoButton } from '@/components/button';\n import { useI18n } from '@/utils/ts/i18n';\n import SkipLeft from '@adyen/ui-assets-icons-16/vue/skip-left';\n import SkipRight from '@adyen/ui-assets-icons-16/vue/skip-right';\n import ChevronLeft from '@adyen/ui-assets-icons-16/vue/chevron-left-small';\n import ChevronRight from '@adyen/ui-assets-icons-16/vue/chevron-right-small';\n\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n const props = withDefaults(\n defineProps<{\n /**\n * Use to determine if the pager has a \"next page\".\n */\n hasNext?: boolean;\n\n /**\n * Hides the \"navigate to the first page\" and \"navigate to the last page\" buttons.\n * Useful for cursor-based pagination, where jumping directly to the first or last page is not supported.\n */\n hideFirstLastPageButtons?: boolean;\n\n /**\n * The current page number of the pager.\n */\n page: number;\n\n /**\n * The current page number of the pager.\n */\n totalPages?: number;\n }>(),\n {\n hasNext: null,\n hideFirstLastPageButtons: false,\n totalPages: null,\n }\n );\n\n const emit = defineEmits<{\n (e: 'navigate', value: number);\n }>();\n\n const { t } = useI18n<{ message: MessageSchema }>({ messages });\n\n const isCurrentPageFirst = computed(() => props.page === 1);\n const isCurrentPageLast = computed(() => props.page === props.totalPages);\n const isNextButtonDisabled = computed(() => {\n const hasNoNextPage = !props.hasNext;\n return hasNoNextPage || isCurrentPageLast.value;\n });\n const isLastPageButtonDisabled = computed(() => {\n const hasNoNextPage = !props.hasNext;\n const hasNoTotalPagesNumber = !props.totalPages;\n\n return hasNoNextPage || isCurrentPageLast.value || hasNoTotalPagesNumber;\n });\n\n const navigate = (pageArg: number) => {\n emit('navigate', pageArg);\n };\n</script>\n\n<script lang=\"ts\">\n export default {\n i18n: { messages },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./pagination-controls.scss\" />\n","<template>\n <div class=\"b-pagination\">\n <nav\n :aria-label=\"$attrs['aria-label']\"\n class=\"b-pagination__navigation\"\n :class=\"navigationConditionalClasses()\"\n >\n <bento-pagination-results-per-page\n v-if=\"!hidePageSize\"\n class=\"b-pagination__results-per-page\"\n :hide-page-size-selection=\"hidePageSizeSelection\"\n :items-per-page=\"size\"\n :total-count=\"totalCount\"\n :page-size-items=\"pageSizeItems\"\n @select=\"onItemsPerPageChange\"\n />\n <bento-typography v-else-if=\"hasSlot('default')\"><slot /></bento-typography>\n\n <div class=\"b-pagination__page-navigator\">\n <bento-pagination-context\n class=\"b-pagination__context\"\n :total-pages=\"totalPages\"\n :page=\"page\"\n :virtual-scroll=\"virtualScroll\"\n :hide-page-selection=\"hidePageSelection\"\n @page-selected=\"onPageSelected\"\n />\n\n <div class=\"b-pagination__divider\"></div>\n\n <bento-pagination-controls\n class=\"b-pagination__controls\"\n :has-next=\"hasNext\"\n :hide-first-last-page-buttons=\"hideFirstLastPageButtons\"\n :page=\"page\"\n :total-pages=\"totalPages\"\n @navigate=\"navigate\"\n />\n </div>\n </nav>\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, useSlots } from 'vue';\n import { BentoTypography } from '@/components/typography';\n import BentoPaginationResultsPerPage from './components/pagination-results-per-page/pagination-results-per-page.vue';\n import BentoPaginationContext from './components/pagination-context/pagination-context.vue';\n import BentoPaginationControls from './components/pagination-controls/pagination-controls.vue';\n import { useHasSlot } from '@/composables';\n import type { BentoPaginationProps } from './pagination.types';\n\n const props = withDefaults(defineProps<BentoPaginationProps>(), {\n hasNext: null,\n hideFirstLastPageButtons: false,\n hidePageSize: false,\n hidePageSelection: false,\n hidePageSizeSelection: false,\n page: 1,\n pageSizeItems: undefined,\n size: 20,\n totalCount: null,\n virtualScroll: false,\n });\n\n const emit = defineEmits<{\n /**\n * Triggered when the navigation controls are clicked or the items per page is changed (i.e. when the arrow buttons to the\n * rightmost of the screen or either dropdown is updated). It indicates to which page it should go next and also the page size.\n */\n (e: 'navigate', page: number, items?: number): void;\n\n /**\n * Triggered when the number of items per page is changed from the left hand dropdown.\n * It indicates the new number of items that will be displayed.\n */\n (e: 'items-page', size: number): void;\n\n /**\n * Triggered when the navigation controls are clicked, whether the arrow buttons to the\n * right most of the screen or the dropdown on the right hand is updated.\n * It indicates to which page it should go next\n * (easily achieved using the [sync modifier](https://v2.vuejs.org/v2/guide/components-custom-events.html#sync-Modifier))\n * e.g. `:page.sync=\"currentPage\"`\n */\n (e: 'update:page', page: number): void;\n\n /**\n * Triggered when the number of items per page is changed from the left hand dropdown.\n * It indicates the new number of items that will be displayed.\n * (easily achieved using the [sync modifier](https://v2.vuejs.org/v2/guide/components-custom-events.html#sync-Modifier))\n * e.g. `:size.sync=\"itemsPerPage\"`\n */\n (e: 'update:size', size: number): void;\n }>();\n\n const slots = useSlots();\n const hasSlot = useHasSlot(slots);\n\n const totalPages = computed(() =>\n !props.totalCount || !props.size ? null : Math.ceil(props.totalCount / props.size)\n );\n\n const navigate = (pageArg: number, itemsPerPage?: number) => {\n if (props.hidePageSize) {\n emit('navigate', pageArg);\n } else {\n emit('navigate', pageArg, itemsPerPage ?? props?.size);\n }\n emit('update:page', pageArg);\n };\n\n const onPageSelected = (pageNumber: number) => {\n navigate(pageNumber);\n };\n\n const onItemsPerPageChange = (elements: number) => {\n emit('items-page', elements);\n emit('update:size', elements);\n\n // Always go to first page when the\n // number of items page changes\n navigate(1, elements);\n };\n\n const navigationConditionalClasses = () => ({\n 'b-pagination__navigation--only-page-navigator': !hasSlot('default') && props.hidePageSize,\n });\n</script>\n\n<script lang=\"ts\">\n /**\n * Paginiation component to help users page through data sets.\n *\n * There are two ways of doing navigation in this component:\n * 1. (Basic) You tell the component if there is a next page (hasNext)\n * 2. (Enhanced) You tell the component:\n * - How many total items exist (totalCount)\n * - The max number of items that you show/fetch per page (size)\n * - In this case you should not set the hasNext props\n *\n * If you have the data available and opt to use the Enhanced way you get extra controls:\n * - Page dropdown selector\n * - Last page button\n * - \"Showing 10 of 200 items\" text\n *\n * @usage\n * import { BentoPagination } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoPagination },\n * template: `\n * <bento-pagination :has-next=\"isNextPage\" />\n * `,\n * }\n */\n\n export default {\n name: 'bento-pagination',\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./pagination.scss\" />\n"],"names":["__default__$3","messages$2","t","n","useI18n","props","__props","emit","__emit","isValid","computed","option","watch","valid","printDevelopmentWarning","dropdownId","generateUid","predefinedDropdownOptions","i18nComponent","getI18nComponent","onSelectChange","selectedNumberOfResults","translationPathKey","__default__$2","messages$1","onPageSelectChange","selectedPage","transformIntoOption","value","transformToPageNumber","_","index","listOfAvailablePages","showPageNumberOfTotal","instance","getCurrentInstance","__default__$1","messages","isCurrentPageFirst","isCurrentPageLast","isNextButtonDisabled","isLastPageButtonDisabled","hasNoNextPage","hasNoTotalPagesNumber","navigate","pageArg","__default__","slots","useSlots","hasSlot","useHasSlot","totalPages","itemsPerPage","onPageSelected","pageNumber","onItemsPerPageChange","elements","navigationConditionalClasses"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;mDA0GIA,IAAA;AAAA,EAAe,MAAA,EAAA,UAAAC,EAAA;AAEf;;;;;;;;;;;AAnEA,UAAA,EAAA,GAAAC,GAAA,GAAAC,EAAA,IAAAC,EAAA,EAAA,UAAAH,EAAA,CAAA,GAEAI,IAAAC,GA4BAC,IAAAC,GAIAC,IAAAC;AAAA,MAAgB,MAAA,MAAA,QAAAL,EAAA,aAAA,KAAAA,EAAA,cAAA,MAAA,CAAAM,MAAA,OAAA,UAAAA,CAAA,CAAA;AAAA,IAC4F;AAG5G,IAAAC;AAAA,MAAAH;AAAA,MACI,CAAAI,MAAA;AAEI,QAAAA,KACIC,EAAA,8DAAA;AAAA,MACJ;AAAA,MACJ,EAAA,WAAA,GAAA;AAAA,IACkB;AAGtB,UAAAC,IAAAC,EAAA,sCAAA,GACAC,IAAAP;AAAA,MAAkC,MAAAL,EAAA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,GAGvBC,IAAA,CAAAC,MAAA;AACI,MAAAjD,EAAA,cAAAiD,CAAA,GACAjD,EAAA,eAAAiD,CAAA,GAIAZ,EAAA,GAAAY,CAAA;AAAA,IAAoB,GAGxBC,IAAA,OAAA;AAAA,MAA4C,iDAAA,CAAAR,EAAA,SAAA,KAAA5C,EAAA;AAAA,IACsC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -4,7 +4,7 @@ import { B as sr } from "./segmented-control.CarI0i3p.js";
|
|
|
4
4
|
import { B as cr } from "./alert.BYmn1ewo.js";
|
|
5
5
|
import { _ as Fe } from "./_plugin-vue_export-helper.CHgC5LLL.js";
|
|
6
6
|
import { B as fr } from "./link.types.BZ1u_6CS.js";
|
|
7
|
-
import { B as hr } from "./checkbox.
|
|
7
|
+
import { B as hr } from "./checkbox.BN7ttBqd.js";
|
|
8
8
|
import { u as pr } from "./index.CGBfMQdv.js";
|
|
9
9
|
import { u as mr } from "./aria-label.CaUURpnB.js";
|
|
10
10
|
import { g as Re } from "./generate-uid.DBWe4g6T.js";
|
|
@@ -6221,4 +6221,4 @@ const no = {
|
|
|
6221
6221
|
export {
|
|
6222
6222
|
wo as r
|
|
6223
6223
|
};
|
|
6224
|
-
//# sourceMappingURL=rich-text-editor.
|
|
6224
|
+
//# sourceMappingURL=rich-text-editor.CjbYg6ee.js.map
|