@adyen/bento-vue2 1.74.0 → 1.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/index.d.ts +1693 -616
- 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/calendar.css +1 -1
- package/dist/assets/card.css +1 -1
- package/dist/assets/data-grid-template.css +1 -1
- package/dist/assets/data-grid.css +1 -1
- package/dist/assets/date-picker.css +1 -1
- package/dist/assets/date-range-picker.css +1 -1
- package/dist/assets/dialog-page.css +1 -1
- package/dist/assets/dropdown-tag.css +1 -1
- package/dist/assets/file-uploader.css +1 -1
- package/dist/assets/filter-bar.css +1 -1
- package/dist/assets/header-meta.css +1 -1
- package/dist/assets/input-field-password.css +1 -1
- package/dist/assets/input-field.css +1 -1
- package/dist/assets/inspector.css +1 -1
- package/dist/assets/modal-fullscreen.css +1 -1
- package/dist/assets/selection-card-group.css +1 -1
- package/dist/assets/sidepanel.css +1 -1
- package/dist/assets/timeline-item.css +1 -1
- package/dist/assets/use-cached-selected-values.css +1 -1
- package/dist/checkbox.js +2 -2
- package/dist/chunks/calendar.Fm_dfQC5.js +1871 -0
- package/dist/chunks/calendar.Fm_dfQC5.js.map +1 -0
- package/dist/chunks/{checkbox-group.DETXTJqI.js → checkbox-group.CtNVRcmP.js} +2 -2
- package/dist/chunks/{checkbox-group.DETXTJqI.js.map → checkbox-group.CtNVRcmP.js.map} +1 -1
- package/dist/chunks/{checkbox.BPtHAAEa.js → checkbox.nyUc0gLb.js} +18 -18
- package/dist/chunks/{checkbox.BPtHAAEa.js.map → checkbox.nyUc0gLb.js.map} +1 -1
- package/dist/chunks/{code-snippet.VtrsOTEC.js → code-snippet.DFf3KMSi.js} +2 -2
- package/dist/chunks/{code-snippet.VtrsOTEC.js.map → code-snippet.DFf3KMSi.js.map} +1 -1
- package/dist/chunks/constructNow.CHWWeLPc.js +8 -0
- package/dist/chunks/constructNow.CHWWeLPc.js.map +1 -0
- package/dist/chunks/{currency.DDB4G_A8.js → currency.AvvbekWO.js} +15 -14
- package/dist/chunks/{currency.DDB4G_A8.js.map → currency.AvvbekWO.js.map} +1 -1
- package/dist/chunks/{dashboard-section.jIpBvP6X.js → dashboard-section.D1l7wDX3.js} +2 -2
- package/dist/chunks/{dashboard-section.jIpBvP6X.js.map → dashboard-section.D1l7wDX3.js.map} +1 -1
- package/dist/chunks/{data-grid-template.CozTcWQ0.js → data-grid-template.DGUDqzjj.js} +2 -2
- package/dist/chunks/{data-grid-template.CozTcWQ0.js.map → data-grid-template.DGUDqzjj.js.map} +1 -1
- package/dist/chunks/{data-grid.DN9xml8y.js → data-grid.B5aCkT0o.js} +1257 -1223
- package/dist/chunks/data-grid.B5aCkT0o.js.map +1 -0
- package/dist/chunks/{date-picker.DoYYzWcA.js → date-picker.DImAYvoM.js} +14 -14
- package/dist/chunks/date-picker.DImAYvoM.js.map +1 -0
- package/dist/chunks/date-range-picker.DgZMERzx.js +914 -0
- package/dist/chunks/date-range-picker.DgZMERzx.js.map +1 -0
- package/dist/chunks/{get-date-locale.CAyOIbcp.js → differenceInMonths.C8FyCrav.js} +580 -364
- package/dist/chunks/differenceInMonths.C8FyCrav.js.map +1 -0
- package/dist/chunks/dropdown-tag.CpvU8eSZ.js +260 -0
- package/dist/chunks/dropdown-tag.CpvU8eSZ.js.map +1 -0
- package/dist/chunks/{dropdown.BOvtYKXS.js → dropdown.RxD2TqnP.js} +14 -14
- package/dist/chunks/{dropdown.BOvtYKXS.js.map → dropdown.RxD2TqnP.js.map} +1 -1
- package/dist/chunks/es6.MoTTyETW.js.map +1 -1
- package/dist/chunks/{filter-bar.DzHJi42d.js → filter-bar.C0S87JZD.js} +511 -486
- package/dist/chunks/filter-bar.C0S87JZD.js.map +1 -0
- package/dist/chunks/getRoundingMethod.C3eaeGLR.js +10 -0
- package/dist/chunks/getRoundingMethod.C3eaeGLR.js.map +1 -0
- package/dist/chunks/{index.BrH1t1iu.js → getTimezoneOffsetInMilliseconds.BW7U6PxE.js} +254 -177
- package/dist/chunks/getTimezoneOffsetInMilliseconds.BW7U6PxE.js.map +1 -0
- package/dist/chunks/header-meta.D-6dL1Vg.js +170 -0
- package/dist/chunks/header-meta.D-6dL1Vg.js.map +1 -0
- package/dist/chunks/{header-with-views.t5Fr63SD.js → header-with-views.j16q5wEc.js} +4 -4
- package/dist/chunks/{header-with-views.t5Fr63SD.js.map → header-with-views.j16q5wEc.js.map} +1 -1
- package/dist/chunks/{header.DwSyDQ68.js → header.DoWKsA15.js} +2 -2
- package/dist/chunks/{header.DwSyDQ68.js.map → header.DoWKsA15.js.map} +1 -1
- package/dist/chunks/{input-field-password.Dm3HYonF.js → input-field-password.CSfXqEbT.js} +47 -38
- package/dist/chunks/input-field-password.CSfXqEbT.js.map +1 -0
- package/dist/chunks/{input-field-phone-number.bZauIuHJ.js → input-field-phone-number.oa4hXQdK.js} +3 -3
- package/dist/chunks/{input-field-phone-number.bZauIuHJ.js.map → input-field-phone-number.oa4hXQdK.js.map} +1 -1
- package/dist/chunks/input-field.DdQu3b1-.js +161 -0
- package/dist/chunks/input-field.DdQu3b1-.js.map +1 -0
- package/dist/chunks/{pagination.CKD9FDrA.js → pagination.C0YW_A_o.js} +2 -2
- package/dist/chunks/{pagination.CKD9FDrA.js.map → pagination.C0YW_A_o.js.map} +1 -1
- package/dist/chunks/radio-group.AcYMFudv.js.map +1 -1
- package/dist/chunks/{rich-text-editor.BZgQ578S.js → rich-text-editor.eYW8X_YP.js} +354 -352
- package/dist/chunks/{rich-text-editor.BZgQ578S.js.map → rich-text-editor.eYW8X_YP.js.map} +1 -1
- package/dist/chunks/{search-bar.c-w7Uky2.js → search-bar.DJVfPz-f.js} +3 -3
- package/dist/chunks/{search-bar.c-w7Uky2.js.map → search-bar.DJVfPz-f.js.map} +1 -1
- package/dist/chunks/{secondary-nav.D69COlqF.js → secondary-nav.BFiTQaag.js} +2 -2
- package/dist/chunks/{secondary-nav.D69COlqF.js.map → secondary-nav.BFiTQaag.js.map} +1 -1
- package/dist/chunks/{selection-card-group.8UIir78G.js → selection-card-group.D4rcUyvV.js} +58 -120
- package/dist/chunks/{selection-card-group.8UIir78G.js.map → selection-card-group.D4rcUyvV.js.map} +1 -1
- package/dist/chunks/textarea.CIQuLWQ8.js.map +1 -1
- package/dist/chunks/{timeline-item.VSw9vKdO.js → timeline-item.CZBuknZ_.js} +156 -168
- package/dist/chunks/timeline-item.CZBuknZ_.js.map +1 -0
- package/dist/chunks/{use-cached-selected-values.IsfhJHxQ.js → use-cached-selected-values.BZd3CTeP.js} +334 -314
- package/dist/chunks/use-cached-selected-values.BZd3CTeP.js.map +1 -0
- package/dist/code-snippet.js +1 -1
- package/dist/currency.js +1 -1
- package/dist/dashboard-template.js +1 -1
- package/dist/data-grid-template.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/dropdown.js +3 -3
- package/dist/filter-bar.js +1 -1
- package/dist/header-with-views.js +1 -1
- package/dist/header.js +1 -1
- package/dist/index.js +221 -220
- 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/internal.js +3 -3
- 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/styles/bento-dark.css +7 -5
- package/dist/styles/bento-light.css +7 -5
- package/dist/styles/bento.css +7 -5
- package/dist/styles/legacy.css +7 -5
- package/dist/styles/styleguide.css +7 -5
- package/dist/timeline.js +1 -1
- package/dist/web-types.json +692 -1390
- package/package.json +12 -27
- package/dist/chunks/_commonjsHelpers.C6fGbg64.js +0 -7
- package/dist/chunks/_commonjsHelpers.C6fGbg64.js.map +0 -1
- package/dist/chunks/calendar.EfqJlztU.js +0 -2093
- package/dist/chunks/calendar.EfqJlztU.js.map +0 -1
- package/dist/chunks/data-grid.DN9xml8y.js.map +0 -1
- package/dist/chunks/date-picker.DoYYzWcA.js.map +0 -1
- package/dist/chunks/date-range-picker.C_pJ8yH5.js +0 -917
- package/dist/chunks/date-range-picker.C_pJ8yH5.js.map +0 -1
- package/dist/chunks/dropdown-tag.DBnurtCQ.js +0 -245
- package/dist/chunks/dropdown-tag.DBnurtCQ.js.map +0 -1
- package/dist/chunks/filter-bar.DzHJi42d.js.map +0 -1
- package/dist/chunks/get-date-locale.CAyOIbcp.js.map +0 -1
- package/dist/chunks/header-meta.uiIO1wHP.js +0 -185
- package/dist/chunks/header-meta.uiIO1wHP.js.map +0 -1
- package/dist/chunks/index.BrH1t1iu.js.map +0 -1
- package/dist/chunks/index.BxBB1rsx.js +0 -15
- package/dist/chunks/index.BxBB1rsx.js.map +0 -1
- package/dist/chunks/input-field-password.Dm3HYonF.js.map +0 -1
- package/dist/chunks/input-field.D52XYEzU.js +0 -157
- package/dist/chunks/input-field.D52XYEzU.js.map +0 -1
- package/dist/chunks/timeline-item.VSw9vKdO.js.map +0 -1
- package/dist/chunks/use-cached-selected-values.IsfhJHxQ.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textarea.CIQuLWQ8.js","sources":["../../src/components/textarea/textarea.types.ts","../../src/components/textarea/textarea.vue"],"sourcesContent":["import type { FormField } from '../../types';\n\n/**\n * @deprecated for usage with properties since version 2.0. Use the string literal instead.\n */\nexport enum BentoTextareaResizeOption {\n HORIZONTAL = 'horizontal',\n VERTICAL = 'vertical',\n BOTH = 'both',\n NONE = 'none',\n}\n\nexport enum BentoTextareaStateClass {\n CLEARABLE = 'clearable',\n DISABLED = 'disabled',\n ERROR = 'error',\n READONLY = 'readonly',\n}\n\nexport enum BentoTextareaEvent {\n BLUR = 'blur',\n CHANGE = 'change',\n CLEAR = 'clear',\n ESCAPE_PRESSED = 'escape-pressed',\n FOCUS = 'focus',\n INPUT = 'input',\n KEYDOWN = 'keydown',\n KEYUP = 'keyup',\n}\n\nexport interface BentoTextareaProps extends FormField {\n /**\n * Text that labels the input element\n * @default undefined\n */\n ariaLabel?: string;\n\n /**\n * Text that shows number of characters in textarea\n * @default undefined\n */\n characterLimit?: number;\n\n /**\n * If set to true, shows a button to clear all the text\n * @default false\n */\n clearable?: boolean;\n\n /**\n * Sets the height of the textarea, e.g 200px OR 20vh\n * @default null\n */\n height?: string | null;\n\n /**\n * Indicates the possibility of resize the textarea.\n * Accepts the Enum or the string literal version.\n * @default BentoTextareaResizeOption.BOTH\n */\n resizable?: BentoTextareaResizeOption | `${BentoTextareaResizeOption}`;\n\n /**\n * Text displayed as the value of the textarea\n */\n value?: string;\n}\n","<template>\n <div ref=\"textareaComponent\" class=\"b-textarea\" :class=\"conditionalClasses\">\n <div :style=\"{ width: textareaWrapperWidth }\">\n <div class=\"b-textarea__label-box\" :class=\"conditionalClassesLabelBox\">\n <field-label\n v-if=\"label\"\n :for=\"textareaId\"\n :label=\"label\"\n :tooltip-text=\"tooltipText\"\n :optional=\"optional\"\n :required=\"required\"\n />\n <bento-typography\n v-if=\"characterLimit\"\n el=\"span\"\n class=\"b-textarea__label-item\"\n :class=\"conditionalClassesLabelItem\"\n >\n {{ counter }}\n </bento-typography>\n </div>\n <bento-typography el=\"div\" class=\"b-textarea__input-box\" :aria-disabled=\"disabled\">\n <textarea\n :id=\"textareaId\"\n ref=\"textareaElement\"\n :value=\"textareaValue\"\n class=\"b-textarea__input\"\n :class=\"conditionalClassesInput\"\n :aria-label=\"computedAriaLabel\"\n :aria-invalid=\"invalidInput\"\n :readonly=\"isReadOnly\"\n :required=\"required\"\n :disabled=\"disabled\"\n :placeholder=\"placeholder\"\n :style=\"{ resize: resizable, height: textareaHeight }\"\n @blur=\"onBlur\"\n @change=\"onChange\"\n @focus=\"onFocus\"\n @input=\"onInput\"\n @keydown.esc=\"onPressEscape\"\n @keydown=\"onKeyDown\"\n @keyup=\"onKeyUp\"\n @mousedown=\"onMouseDown\"\n @mouseup=\"onMouseUp\"\n >\n </textarea>\n\n <div v-if=\"showClearButton\" class=\"b-textarea__clear-button\">\n <bento-button\n variant=\"tertiary\"\n :disabled=\"disabled\"\n @click=\"onClear\"\n @keypress.enter=\"onClear\"\n @keyup.space=\"onClear\"\n >\n <template #iconLeft>\n <cross-circle-fill-small-icon :svg-title=\"t('clearText')\" />\n </template>\n </bento-button>\n </div>\n </bento-typography>\n\n <error-message v-if=\"isOverCharacterLimit\" :error-message=\"counterErrorText\" />\n\n <error-message v-if=\"errorMessage\" :error-message=\"errorMessage\" />\n\n <bento-typography v-if=\"description\" class=\"b-textarea__description\" el=\"span\">\n {{ description }}\n </bento-typography>\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, nextTick, onMounted, onUnmounted, ref, toRef, toRefs, useAttrs, watch } from 'vue';\n\n // Components\n import { BentoButton } from '@/components/button';\n import { BentoTypography } from '@/components/typography';\n import { ErrorMessage, FieldLabel } from '@/internal';\n import CrossCircleFillSmallIcon from '@adyen/ui-assets-icons-16/vue/cross-circle-fill-small';\n\n // Utils\n import { generateUid } from '@/core/utils/ts';\n import { observeSizeOfElement } from '@/utils/ts/resize';\n import { useAriaLabel } from '@/utils/ts/aria-label';\n import { useI18n } from '@/utils/ts/i18n';\n\n // Composables\n import { useFormLayoutFieldLoading } from '@/composables/use-form-layout-loading/use-form-layout-loading';\n\n // Constants\n import { BTextareaInputFocusBorderWidth } from '@adyen/bento-design-tokens/dist/js/bento/es6';\n\n // Types\n import { BentoTextareaEvent, type BentoTextareaProps, BentoTextareaStateClass } from './textarea.types';\n\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n const attrs = useAttrs();\n\n const props = defineProps({\n description: { default: '' },\n disabled: { type: Boolean, default: false },\n errorMessage: { default: '' },\n label: { default: '' },\n optional: { type: Boolean, default: false },\n placeholder: { default: '' },\n readonly: { type: Boolean, default: false },\n required: { type: Boolean, default: false },\n tooltipText: { default: null },\n ariaLabel: { default: undefined },\n characterLimit: { default: undefined },\n clearable: { type: Boolean, default: false },\n height: { default: null },\n resizable: { default: 'both' },\n value: { default: '' }\n});\n\n const emit = defineEmits([]);\n\n const { height } = toRefs(props);\n\n const textareaId = generateUid('textarea');\n const textareaElement = ref<HTMLTextAreaElement>(null);\n const textareaComponent = ref<HTMLDivElement>(null);\n const textareaValue = ref(props.value);\n const defaultTextareaHeight = 44;\n const textareaHeight = ref(props.height || `${defaultTextareaHeight}px`);\n const userSetHeight = ref<number>(0);\n const textareaWrapperWidth = ref('100%'); // The width set to the wrapper of the label, textarea and description\n const isUserResizing = ref(false);\n let textareaElementObserver: ResizeObserver | null = null;\n let textareaComponentObserver: ResizeObserver | null = null;\n\n const { t, n } = useI18n<{ message: MessageSchema }>({ messages });\n\n const { isReadOnly } = useFormLayoutFieldLoading(toRef(props, 'readonly'));\n\n const counter = computed(() => `${n(textareaValue?.value?.length ?? 0)} / ${n(props.characterLimit)}`);\n const isDynamicHeight = computed(() => !height.value);\n const isOverCharacterLimit = computed(\n () => props.characterLimit && textareaValue.value.length > props.characterLimit\n );\n\n /**\n * Calculates and sets the height of the textarea.\n * The height is determined by the maximum of the following values:\n *\n * 1. The content's scroll height (with a minimum of `defaultTextareaHeight`) + the border width.\n * 2. The height set by the user manually resizing the textarea (`userSetHeight`).\n * 3. The default minimum height (`defaultTextareaHeight`).\n *\n * This ensures the textarea grows with content, shrinks when content is removed,\n * but never goes below the manually set height or the default height.\n */\n const calculateHeight = () => {\n if (textareaElement.value) {\n const newHeight = Math.max(\n textareaElement.value.scrollHeight <= defaultTextareaHeight\n ? defaultTextareaHeight\n : textareaElement.value.scrollHeight + TEXTAREA_BORDER_WIDTH * 2,\n userSetHeight.value,\n defaultTextareaHeight\n );\n textareaHeight.value = `${newHeight}px`;\n }\n };\n\n watch(height, () => {\n if (isDynamicHeight.value) {\n calculateHeight();\n } else {\n textareaHeight.value = height.value;\n }\n });\n\n watch(\n () => props.value,\n () => {\n textareaValue.value = props.value;\n },\n { immediate: true }\n );\n\n watch(\n () => textareaValue.value,\n async () => {\n if (isDynamicHeight.value) {\n // Hack to make the textarea calculate its height properly\n // Set the textarea back to the original value before calculating the height\n textareaHeight.value = `${defaultTextareaHeight}px`;\n if (!textareaValue.value) {\n return;\n }\n\n await nextTick();\n calculateHeight();\n }\n },\n { immediate: true }\n );\n\n const invalidInput = computed(() => !!props.errorMessage || isOverCharacterLimit.value);\n\n const conditionalClasses = computed(() => ({\n [`b-textarea--${BentoTextareaStateClass.DISABLED}`]: props.disabled,\n }));\n\n const conditionalClassesInput = computed(() => ({\n [`b-textarea__input--${BentoTextareaStateClass.CLEARABLE}`]: props.clearable,\n [`b-textarea__input--${BentoTextareaStateClass.READONLY}`]: isReadOnly.value,\n [`b-textarea__input--${BentoTextareaStateClass.ERROR}`]: invalidInput.value,\n [`b-textarea__input--dynamic-height`]: isDynamicHeight.value,\n }));\n\n const conditionalClassesLabelBox = computed(() => ({\n [`b-textarea__label-box--no-label`]: !props.label,\n }));\n\n const conditionalClassesLabelItem = computed(() => ({\n [`b-textarea__label-item--${BentoTextareaStateClass.ERROR}`]: isOverCharacterLimit.value,\n }));\n\n const counterErrorText = computed(() => t('yourTextCanBenAtMost', { characterLimit: props.characterLimit }));\n\n const ariaLabelAttribute = ref(attrs['aria-label']);\n const { ariaLabel, label } = toRefs(props);\n const computedAriaLabel = useAriaLabel({\n ariaLabel: ariaLabelAttribute.value as string,\n // TODO: take this line away when the aria-label props is removed\n label: ariaLabel,\n defaultFallback: label,\n });\n\n const showClearButton = computed(\n () => props.clearable && textareaValue.value && !props.disabled && !isReadOnly.value\n );\n\n const onClear = () => {\n textareaValue.value = '';\n emit(BentoTextareaEvent.CLEAR);\n emit(BentoTextareaEvent.INPUT, '');\n };\n\n const onInput = (event: InputEvent) => {\n event.stopImmediatePropagation();\n\n if (!props.disabled && !isReadOnly.value) {\n textareaValue.value = (event.target as HTMLInputElement).value;\n /**\n * Triggered when input value is changed\n *\n * @event input\n * @property {String} inputValue - the updated textarea value\n */\n emit(BentoTextareaEvent.INPUT, textareaValue.value);\n }\n };\n\n const onBlur = () => {\n textareaElement.value.scrollTop = 0;\n emit(BentoTextareaEvent.BLUR);\n };\n\n const onFocus = () => {\n textareaElement.value.focus();\n emit(BentoTextareaEvent.FOCUS);\n };\n\n const onChange = () => {\n emit(BentoTextareaEvent.CHANGE);\n };\n\n const onPressEscape = () => {\n emit(BentoTextareaEvent.ESCAPE_PRESSED);\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n event.stopPropagation();\n emit(BentoTextareaEvent.KEYDOWN, event);\n };\n\n const onKeyUp = (event: KeyboardEvent) => {\n event.stopPropagation();\n emit(BentoTextareaEvent.KEYUP, event);\n };\n\n const onMouseDown = () => {\n isUserResizing.value = true;\n };\n\n const onMouseUp = () => {\n isUserResizing.value = false;\n };\n\n /**\n * Updates the textarea width depending if the container or the user update its size.\n * @param isTextareaElement - sets to true if the element being observed is the textarea HTML element.\n */\n const resizeTextareaWrapper = (isTextareaElement = false) => {\n // Width assigned by the browser whenever the textarea is manually resized. String of the format `<value>px`.\n const textareaStyleWidth = textareaElement.value.style.width;\n\n // Make sure the tracked textareaHeight is always in sync with the height size in case we manually resize the textarea\n if (textareaElement.value.style.height) {\n if (isUserResizing.value) {\n userSetHeight.value = parseInt(textareaElement.value.style.height, 10);\n }\n textareaHeight.value = textareaElement.value.style.height;\n }\n\n // If the textarea element observer is being triggered, but there's no textareaStyleWidth, we want to ignore it, as no manual resize as happened yet\n // The component wrapper will handle the resizing logic instead\n if (isTextareaElement && !textareaStyleWidth) {\n return;\n }\n\n // Width of the whole bento-textarea component\n const textareaComponentWidth = textareaComponent?.value?.offsetWidth;\n\n // If there is no textareaStyleWidth or the textareaStyleWidth is larger than the component container, the wrapper should be 100% of the container\n if (!textareaStyleWidth || parseInt(textareaStyleWidth, 10) > textareaComponentWidth) {\n textareaWrapperWidth.value = '100%';\n } else {\n // Else the wrapper should always be as wide as the textarea element itself\n textareaWrapperWidth.value = textareaStyleWidth;\n }\n };\n\n const focus = () => {\n textareaElement.value.focus();\n };\n\n defineExpose({\n focus,\n });\n\n onMounted(() => {\n textareaElementObserver = observeSizeOfElement(textareaElement.value, () => {\n resizeTextareaWrapper(true);\n });\n\n textareaComponentObserver = observeSizeOfElement(textareaComponent.value, () => {\n resizeTextareaWrapper();\n });\n\n if (isDynamicHeight.value) {\n calculateHeight();\n }\n });\n\n onUnmounted(() => {\n textareaElementObserver?.disconnect();\n textareaComponentObserver?.disconnect();\n });\n</script>\n\n<script lang=\"ts\">\n const TEXTAREA_BORDER_WIDTH = parseFloat(BTextareaInputFocusBorderWidth);\n\n export default {\n i18n: { messages },\n name: 'bento-textarea',\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./textarea.scss\" />\n"],"names":["BentoTextareaStateClass","BentoTextareaStateClass2","BentoTextareaEvent","BentoTextareaEvent2","TEXTAREA_BORDER_WIDTH","BTextareaInputFocusBorderWidth","__default__","messages","attrs","useAttrs","height","toRefs","props","textareaId","generateUid","textareaElement","ref","textareaComponent","textareaValue","defaultTextareaHeight","textareaHeight","userSetHeight","textareaWrapperWidth","isUserResizing","textareaElementObserver","textareaComponentObserver","t","n","useI18n","isReadOnly","useFormLayoutFieldLoading","toRef","counter","computed","_a","isDynamicHeight","isOverCharacterLimit","calculateHeight","newHeight","watch","nextTick","invalidInput","conditionalClasses","conditionalClassesInput","conditionalClassesLabelBox","conditionalClassesLabelItem","counterErrorText","ariaLabelAttribute","ariaLabel","label","computedAriaLabel","useAriaLabel","showClearButton","onClear","emit","onInput","event","onBlur","onFocus","onChange","onPressEscape","onKeyDown","onKeyUp","onMouseDown","onMouseUp","resizeTextareaWrapper","isTextareaElement","textareaStyleWidth","textareaComponentWidth","focus","expose","onMounted","observeSizeOfElement","onUnmounted"],"mappings":";;;;;;;;;;;;;AAYY,IAAAA,IAAA,kBAAAC,OACRA,EAAA,YAAA,aACAA,EAAA,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AAA;AACI,MAAAA,EAAA,gBAAA,GACAF,EAAApD,EAAA,OAAAsD,CAAA;AAAA,IAAoC,GAGxCO,KAAA,MAAA;AACI,MAAAxC,EAAA,QAAA;AAAA,IAAuB,GAG3ByC,KAAA,MAAA;AACI,MAAAzC,EAAA,QAAA;AAAA,IAAuB,GAO3B0C,IAAA,CAAAC,IAAA,OAAA;;AAEI,YAAAC,IAAApD,EAAA,MAAA,MAAA;AAYA,UATAA,EAAA,MAAA,MAAA,WACIQ,EAAA,UACIF,EAAA,QAAA,SAAAN,EAAA,MAAA,MAAA,QAAA,EAAA,IAEJK,EAAA,QAAAL,EAAA,MAAA,MAAA,SAKJmD,KAAA,CAAAC;AACI;AAIJ,YAAAC,MAAAlC,IAAAjB,KAAA,gBAAAA,EAAA,UAAA,gBAAAiB,EAAA;AAGA,MAAA,CAAAiC,KAAA,SAAAA,GAAA,EAAA,IAAAC,KACI9C,EAAA,QAAA,SAGAA,EAAA,QAAA6C;AAAA,IACJ,GAGJE,IAAA,MAAA;AACI,MAAAtD,EAAA,MAAA,MAAA;AAAA,IAA4B;AAGhC,WAAAuD,EAAA;AAAA,MAAa,OAAAD;AAAA,IACT,CAAA,GAGJE,GAAA,MAAA;AACI,MAAA/C,IAAAgD,EAAAzD,EAAA,OAAA,MAAA;AACI,QAAAkD,EAAA,EAAA;AAAA,MAA0B,CAAA,GAG9BxC,IAAA+C,EAAAvD,EAAA,OAAA,MAAA;AACI,QAAAgD,EAAA;AAAA,MAAsB,CAAA,GAG1B9B,EAAA,SACIE,EAAA;AAAA,IACJ,CAAA,GAGJoC,GAAA,MAAA;AACI,MAAAjD,KAAA,QAAAA,EAAA,cACAC,KAAA,QAAAA,EAAA;AAAA,IAAsC,CAAA;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"textarea.CIQuLWQ8.js","sources":["../../src/components/textarea/textarea.types.ts","../../src/components/textarea/textarea.vue"],"sourcesContent":["import type { FormField } from '../../types/form-field';\n\n/**\n * @deprecated for usage with properties since version 2.0. Use the string literal instead.\n */\nexport enum BentoTextareaResizeOption {\n HORIZONTAL = 'horizontal',\n VERTICAL = 'vertical',\n BOTH = 'both',\n NONE = 'none',\n}\n\nexport enum BentoTextareaStateClass {\n CLEARABLE = 'clearable',\n DISABLED = 'disabled',\n ERROR = 'error',\n READONLY = 'readonly',\n}\n\nexport enum BentoTextareaEvent {\n BLUR = 'blur',\n CHANGE = 'change',\n CLEAR = 'clear',\n ESCAPE_PRESSED = 'escape-pressed',\n FOCUS = 'focus',\n INPUT = 'input',\n KEYDOWN = 'keydown',\n KEYUP = 'keyup',\n}\n\nexport interface BentoTextareaProps extends FormField {\n /**\n * Text that labels the input element\n * @default undefined\n */\n ariaLabel?: string;\n\n /**\n * Text that shows number of characters in textarea\n * @default undefined\n */\n characterLimit?: number;\n\n /**\n * If set to true, shows a button to clear all the text\n * @default false\n */\n clearable?: boolean;\n\n /**\n * Sets the height of the textarea, e.g 200px OR 20vh\n * @default null\n */\n height?: string | null;\n\n /**\n * Indicates the possibility of resize the textarea.\n * Accepts the Enum or the string literal version.\n * @default BentoTextareaResizeOption.BOTH\n */\n resizable?: BentoTextareaResizeOption | `${BentoTextareaResizeOption}`;\n\n /**\n * Text displayed as the value of the textarea\n */\n value?: string;\n}\n","<template>\n <div ref=\"textareaComponent\" class=\"b-textarea\" :class=\"conditionalClasses\">\n <div :style=\"{ width: textareaWrapperWidth }\">\n <div class=\"b-textarea__label-box\" :class=\"conditionalClassesLabelBox\">\n <field-label\n v-if=\"label\"\n :for=\"textareaId\"\n :label=\"label\"\n :tooltip-text=\"tooltipText\"\n :optional=\"optional\"\n :required=\"required\"\n />\n <bento-typography\n v-if=\"characterLimit\"\n el=\"span\"\n class=\"b-textarea__label-item\"\n :class=\"conditionalClassesLabelItem\"\n >\n {{ counter }}\n </bento-typography>\n </div>\n <bento-typography el=\"div\" class=\"b-textarea__input-box\" :aria-disabled=\"disabled\">\n <textarea\n :id=\"textareaId\"\n ref=\"textareaElement\"\n :value=\"textareaValue\"\n class=\"b-textarea__input\"\n :class=\"conditionalClassesInput\"\n :aria-label=\"computedAriaLabel\"\n :aria-invalid=\"invalidInput\"\n :readonly=\"isReadOnly\"\n :required=\"required\"\n :disabled=\"disabled\"\n :placeholder=\"placeholder\"\n :style=\"{ resize: resizable, height: textareaHeight }\"\n @blur=\"onBlur\"\n @change=\"onChange\"\n @focus=\"onFocus\"\n @input=\"onInput\"\n @keydown.esc=\"onPressEscape\"\n @keydown=\"onKeyDown\"\n @keyup=\"onKeyUp\"\n @mousedown=\"onMouseDown\"\n @mouseup=\"onMouseUp\"\n >\n </textarea>\n\n <div v-if=\"showClearButton\" class=\"b-textarea__clear-button\">\n <bento-button\n variant=\"tertiary\"\n :disabled=\"disabled\"\n @click=\"onClear\"\n @keypress.enter=\"onClear\"\n @keyup.space=\"onClear\"\n >\n <template #iconLeft>\n <cross-circle-fill-small-icon :svg-title=\"t('clearText')\" />\n </template>\n </bento-button>\n </div>\n </bento-typography>\n\n <error-message v-if=\"isOverCharacterLimit\" :error-message=\"counterErrorText\" />\n\n <error-message v-if=\"errorMessage\" :error-message=\"errorMessage\" />\n\n <bento-typography v-if=\"description\" class=\"b-textarea__description\" el=\"span\">\n {{ description }}\n </bento-typography>\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, nextTick, onMounted, onUnmounted, ref, toRef, toRefs, useAttrs, watch } from 'vue';\n\n // Components\n import { BentoButton } from '@/components/button';\n import { BentoTypography } from '@/components/typography';\n import { ErrorMessage, FieldLabel } from '@/internal';\n import CrossCircleFillSmallIcon from '@adyen/ui-assets-icons-16/vue/cross-circle-fill-small';\n\n // Utils\n import { generateUid } from '@/core/utils/ts';\n import { observeSizeOfElement } from '@/utils/ts/resize';\n import { useAriaLabel } from '@/utils/ts/aria-label';\n import { useI18n } from '@/utils/ts/i18n';\n\n // Composables\n import { useFormLayoutFieldLoading } from '@/composables/use-form-layout-loading/use-form-layout-loading';\n\n // Constants\n import { BTextareaInputFocusBorderWidth } from '@adyen/bento-design-tokens/dist/js/bento/es6';\n\n // Types\n import { BentoTextareaEvent, type BentoTextareaProps, BentoTextareaStateClass } from './textarea.types';\n\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n const attrs = useAttrs();\n\n const props = defineProps({\n description: { default: '' },\n disabled: { type: Boolean, default: false },\n errorMessage: { default: '' },\n label: { default: '' },\n optional: { type: Boolean, default: false },\n placeholder: { default: '' },\n readonly: { type: Boolean, default: false },\n required: { type: Boolean, default: false },\n tooltipText: { default: null },\n ariaLabel: { default: undefined },\n characterLimit: { default: undefined },\n clearable: { type: Boolean, default: false },\n height: { default: null },\n resizable: { default: 'both' },\n value: { default: '' }\n});\n\n const emit = defineEmits([]);\n\n const { height } = toRefs(props);\n\n const textareaId = generateUid('textarea');\n const textareaElement = ref<HTMLTextAreaElement>(null);\n const textareaComponent = ref<HTMLDivElement>(null);\n const textareaValue = ref(props.value);\n const defaultTextareaHeight = 44;\n const textareaHeight = ref(props.height || `${defaultTextareaHeight}px`);\n const userSetHeight = ref<number>(0);\n const textareaWrapperWidth = ref('100%'); // The width set to the wrapper of the label, textarea and description\n const isUserResizing = ref(false);\n let textareaElementObserver: ResizeObserver | null = null;\n let textareaComponentObserver: ResizeObserver | null = null;\n\n const { t, n } = useI18n<{ message: MessageSchema }>({ messages });\n\n const { isReadOnly } = useFormLayoutFieldLoading(toRef(props, 'readonly'));\n\n const counter = computed(() => `${n(textareaValue?.value?.length ?? 0)} / ${n(props.characterLimit)}`);\n const isDynamicHeight = computed(() => !height.value);\n const isOverCharacterLimit = computed(\n () => props.characterLimit && textareaValue.value.length > props.characterLimit\n );\n\n /**\n * Calculates and sets the height of the textarea.\n * The height is determined by the maximum of the following values:\n *\n * 1. The content's scroll height (with a minimum of `defaultTextareaHeight`) + the border width.\n * 2. The height set by the user manually resizing the textarea (`userSetHeight`).\n * 3. The default minimum height (`defaultTextareaHeight`).\n *\n * This ensures the textarea grows with content, shrinks when content is removed,\n * but never goes below the manually set height or the default height.\n */\n const calculateHeight = () => {\n if (textareaElement.value) {\n const newHeight = Math.max(\n textareaElement.value.scrollHeight <= defaultTextareaHeight\n ? defaultTextareaHeight\n : textareaElement.value.scrollHeight + TEXTAREA_BORDER_WIDTH * 2,\n userSetHeight.value,\n defaultTextareaHeight\n );\n textareaHeight.value = `${newHeight}px`;\n }\n };\n\n watch(height, () => {\n if (isDynamicHeight.value) {\n calculateHeight();\n } else {\n textareaHeight.value = height.value;\n }\n });\n\n watch(\n () => props.value,\n () => {\n textareaValue.value = props.value;\n },\n { immediate: true }\n );\n\n watch(\n () => textareaValue.value,\n async () => {\n if (isDynamicHeight.value) {\n // Hack to make the textarea calculate its height properly\n // Set the textarea back to the original value before calculating the height\n textareaHeight.value = `${defaultTextareaHeight}px`;\n if (!textareaValue.value) {\n return;\n }\n\n await nextTick();\n calculateHeight();\n }\n },\n { immediate: true }\n );\n\n const invalidInput = computed(() => !!props.errorMessage || isOverCharacterLimit.value);\n\n const conditionalClasses = computed(() => ({\n [`b-textarea--${BentoTextareaStateClass.DISABLED}`]: props.disabled,\n }));\n\n const conditionalClassesInput = computed(() => ({\n [`b-textarea__input--${BentoTextareaStateClass.CLEARABLE}`]: props.clearable,\n [`b-textarea__input--${BentoTextareaStateClass.READONLY}`]: isReadOnly.value,\n [`b-textarea__input--${BentoTextareaStateClass.ERROR}`]: invalidInput.value,\n [`b-textarea__input--dynamic-height`]: isDynamicHeight.value,\n }));\n\n const conditionalClassesLabelBox = computed(() => ({\n [`b-textarea__label-box--no-label`]: !props.label,\n }));\n\n const conditionalClassesLabelItem = computed(() => ({\n [`b-textarea__label-item--${BentoTextareaStateClass.ERROR}`]: isOverCharacterLimit.value,\n }));\n\n const counterErrorText = computed(() => t('yourTextCanBenAtMost', { characterLimit: props.characterLimit }));\n\n const ariaLabelAttribute = ref(attrs['aria-label']);\n const { ariaLabel, label } = toRefs(props);\n const computedAriaLabel = useAriaLabel({\n ariaLabel: ariaLabelAttribute.value as string,\n // TODO: take this line away when the aria-label props is removed\n label: ariaLabel,\n defaultFallback: label,\n });\n\n const showClearButton = computed(\n () => props.clearable && textareaValue.value && !props.disabled && !isReadOnly.value\n );\n\n const onClear = () => {\n textareaValue.value = '';\n emit(BentoTextareaEvent.CLEAR);\n emit(BentoTextareaEvent.INPUT, '');\n };\n\n const onInput = (event: InputEvent) => {\n event.stopImmediatePropagation();\n\n if (!props.disabled && !isReadOnly.value) {\n textareaValue.value = (event.target as HTMLInputElement).value;\n /**\n * Triggered when input value is changed\n *\n * @event input\n * @property {String} inputValue - the updated textarea value\n */\n emit(BentoTextareaEvent.INPUT, textareaValue.value);\n }\n };\n\n const onBlur = () => {\n textareaElement.value.scrollTop = 0;\n emit(BentoTextareaEvent.BLUR);\n };\n\n const onFocus = () => {\n textareaElement.value.focus();\n emit(BentoTextareaEvent.FOCUS);\n };\n\n const onChange = () => {\n emit(BentoTextareaEvent.CHANGE);\n };\n\n const onPressEscape = () => {\n emit(BentoTextareaEvent.ESCAPE_PRESSED);\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n event.stopPropagation();\n emit(BentoTextareaEvent.KEYDOWN, event);\n };\n\n const onKeyUp = (event: KeyboardEvent) => {\n event.stopPropagation();\n emit(BentoTextareaEvent.KEYUP, event);\n };\n\n const onMouseDown = () => {\n isUserResizing.value = true;\n };\n\n const onMouseUp = () => {\n isUserResizing.value = false;\n };\n\n /**\n * Updates the textarea width depending if the container or the user update its size.\n * @param isTextareaElement - sets to true if the element being observed is the textarea HTML element.\n */\n const resizeTextareaWrapper = (isTextareaElement = false) => {\n // Width assigned by the browser whenever the textarea is manually resized. String of the format `<value>px`.\n const textareaStyleWidth = textareaElement.value.style.width;\n\n // Make sure the tracked textareaHeight is always in sync with the height size in case we manually resize the textarea\n if (textareaElement.value.style.height) {\n if (isUserResizing.value) {\n userSetHeight.value = parseInt(textareaElement.value.style.height, 10);\n }\n textareaHeight.value = textareaElement.value.style.height;\n }\n\n // If the textarea element observer is being triggered, but there's no textareaStyleWidth, we want to ignore it, as no manual resize as happened yet\n // The component wrapper will handle the resizing logic instead\n if (isTextareaElement && !textareaStyleWidth) {\n return;\n }\n\n // Width of the whole bento-textarea component\n const textareaComponentWidth = textareaComponent?.value?.offsetWidth;\n\n // If there is no textareaStyleWidth or the textareaStyleWidth is larger than the component container, the wrapper should be 100% of the container\n if (!textareaStyleWidth || parseInt(textareaStyleWidth, 10) > textareaComponentWidth) {\n textareaWrapperWidth.value = '100%';\n } else {\n // Else the wrapper should always be as wide as the textarea element itself\n textareaWrapperWidth.value = textareaStyleWidth;\n }\n };\n\n const focus = () => {\n textareaElement.value.focus();\n };\n\n defineExpose({\n focus,\n });\n\n onMounted(() => {\n textareaElementObserver = observeSizeOfElement(textareaElement.value, () => {\n resizeTextareaWrapper(true);\n });\n\n textareaComponentObserver = observeSizeOfElement(textareaComponent.value, () => {\n resizeTextareaWrapper();\n });\n\n if (isDynamicHeight.value) {\n calculateHeight();\n }\n });\n\n onUnmounted(() => {\n textareaElementObserver?.disconnect();\n textareaComponentObserver?.disconnect();\n });\n</script>\n\n<script lang=\"ts\">\n const TEXTAREA_BORDER_WIDTH = parseFloat(BTextareaInputFocusBorderWidth);\n\n export default {\n i18n: { messages },\n name: 'bento-textarea',\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./textarea.scss\" />\n"],"names":["BentoTextareaStateClass","BentoTextareaStateClass2","BentoTextareaEvent","BentoTextareaEvent2","TEXTAREA_BORDER_WIDTH","BTextareaInputFocusBorderWidth","__default__","messages","attrs","useAttrs","height","toRefs","props","textareaId","generateUid","textareaElement","ref","textareaComponent","textareaValue","defaultTextareaHeight","textareaHeight","userSetHeight","textareaWrapperWidth","isUserResizing","textareaElementObserver","textareaComponentObserver","t","n","useI18n","isReadOnly","useFormLayoutFieldLoading","toRef","counter","computed","_a","isDynamicHeight","isOverCharacterLimit","calculateHeight","newHeight","watch","nextTick","invalidInput","conditionalClasses","conditionalClassesInput","conditionalClassesLabelBox","conditionalClassesLabelItem","counterErrorText","ariaLabelAttribute","ariaLabel","label","computedAriaLabel","useAriaLabel","showClearButton","onClear","emit","onInput","event","onBlur","onFocus","onChange","onPressEscape","onKeyDown","onKeyUp","onMouseDown","onMouseUp","resizeTextareaWrapper","isTextareaElement","textareaStyleWidth","textareaComponentWidth","focus","expose","onMounted","observeSizeOfElement","onUnmounted"],"mappings":";;;;;;;;;;;;;AAYY,IAAAA,IAAA,kBAAAC,OACRA,EAAA,YAAA,aACAA,EAAA,WAAA,YACAA,EAAA,QAAA,SACAA,EAAA,WAAA,YAJQA,IAAAD,KAAA,CAAA,CAAA,GAOAE,IAAA,kBAAAC,OACRA,EAAA,OAAA,QACAA,EAAA,SAAA,UACAA,EAAA,QAAA,SACAA,EAAA,iBAAA,kBACAA,EAAA,QAAA,SACAA,EAAA,QAAA,SACAA,EAAA,UAAA,WACAA,EAAA,QAAA,SARQA,IAAAD,KAAA,CAAA,CAAA;;;;;;;GCsVRE,IAAA,WAAAC,EAAA,GAEAC,KAAA;AAAA,EAAe,MAAA,EAAA,UAAAC,GAAA;AAAA,EACM,MAAA;AAErB;;;;;;;;;;;;;;;;;;;;;iBAzQAC,IAAAC,GAAA,GAsBA,EAAA,QAAAC,EAAA,IAAAC,EAAAC,CAAA,GAEAC,IAAAC,GAAA,UAAA,GACAC,IAAAC,EAAA,IAAA,GACAC,IAAAD,EAAA,IAAA,GACAE,IAAAF,EAAAJ,EAAA,KAAA,GACAO,IAAA,IACAC,IAAAJ,EAAAJ,EAAA,UAAA,GAAAO,CAAA,IAAA,GACAE,IAAAL,EAAA,CAAA,GACAM,IAAAN,EAAA,MAAA,GACAO,IAAAP,EAAA,EAAA;AACA,QAAAQ,IAAA,MACAC,IAAA;AAEA,UAAA,EAAA,GAAAC,GAAA,GAAAC,EAAA,IAAAC,GAAA,GAEA,EAAA,YAAAC,EAAA,IAAAC,GAAAC,GAAAnB,GAAA,UAAA,CAAA,GAEAoB,IAAAC,EA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D,EAAA;AAAA,MAAsB,CAAA,GAG1B9B,EAAA,SACIE,EAAA;AAAA,IACJ,CAAA,GAGJoC,GAAA,MAAA;AACI,MAAAjD,KAAA,QAAAA,EAAA,cACAC,KAAA,QAAAA,EAAA;AAAA,IAAsC,CAAA;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,67 +1,22 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { B as
|
|
3
|
-
import { B as
|
|
4
|
-
import { u as
|
|
5
|
-
import { B as
|
|
6
|
-
import { n as
|
|
7
|
-
import { B as
|
|
8
|
-
import { B as
|
|
9
|
-
import { B as
|
|
10
|
-
import { B as
|
|
11
|
-
import { a as
|
|
1
|
+
import { defineComponent as P, computed as s, ref as y, toRefs as Z, watch as G, provide as x, nextTick as Q, inject as D, onUnmounted as X } from "vue";
|
|
2
|
+
import { B as z } from "./button.CS_kdxYh.js";
|
|
3
|
+
import { B as ee } from "./textarea.CIQuLWQ8.js";
|
|
4
|
+
import { u as H } from "./index.B6WW_F-J.js";
|
|
5
|
+
import { B as te } from "./button-actions.B81vY51z.js";
|
|
6
|
+
import { n as A } from "./_plugin-vue2_normalizer.CeySl7Fu.js";
|
|
7
|
+
import { B as ae } from "./date.C1z2TXzM.js";
|
|
8
|
+
import { B as ie } from "./link.D8qpqg3W.js";
|
|
9
|
+
import { B as se } from "./tag.BwKc2d2E.js";
|
|
10
|
+
import { B as ne, d as le } from "./typography.hlOAxsEn.js";
|
|
11
|
+
import { a as oe, B as re, S as ce } from "./structured-list-item.CMsVwwA6.js";
|
|
12
12
|
/* empty css */
|
|
13
|
-
import { g as
|
|
14
|
-
import { u as
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
13
|
+
import { g as me } from "./generate-uid.NJ8tVoha.js";
|
|
14
|
+
import { u as de } from "./use-has-slot.C9lQZ6nz.js";
|
|
15
|
+
import { b as ue, e as _e, a as ve, n as fe, g as k, m as B, d as j, f as $, h as F } from "./getTimezoneOffsetInMilliseconds.BW7U6PxE.js";
|
|
16
|
+
import { g as be } from "./getRoundingMethod.C3eaeGLR.js";
|
|
17
17
|
import "../assets/timeline-item.css";
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
var a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
21
|
-
_e(2, arguments);
|
|
22
|
-
var i = a.locale || ve;
|
|
23
|
-
if (!i.formatDistance)
|
|
24
|
-
throw new RangeError("locale must contain localize.formatDistance property");
|
|
25
|
-
var f = fe(t, e);
|
|
26
|
-
if (isNaN(f))
|
|
27
|
-
throw new RangeError("Invalid time value");
|
|
28
|
-
var l = pe(a);
|
|
29
|
-
l.addSuffix = !!a.addSuffix, l.comparison = f;
|
|
30
|
-
var p, d;
|
|
31
|
-
f > 0 ? (p = S(e), d = S(t)) : (p = S(t), d = S(e));
|
|
32
|
-
var b = a.roundingMethod == null ? "round" : String(a.roundingMethod), s;
|
|
33
|
-
if (b === "floor")
|
|
34
|
-
s = Math.floor;
|
|
35
|
-
else if (b === "ceil")
|
|
36
|
-
s = Math.ceil;
|
|
37
|
-
else if (b === "round")
|
|
38
|
-
s = Math.round;
|
|
39
|
-
else
|
|
40
|
-
throw new RangeError("roundingMethod must be 'floor', 'ceil' or 'round'");
|
|
41
|
-
var g = d.getTime() - p.getTime(), u = g / j, c = $(d) - $(p), _ = (g - c) / j, n;
|
|
42
|
-
if (a.unit == null ? u < 1 ? n = "second" : u < 60 ? n = "minute" : u < L ? n = "hour" : _ < F ? n = "day" : _ < U ? n = "month" : n = "year" : n = String(a.unit), n === "second") {
|
|
43
|
-
var h = s(g / 1e3);
|
|
44
|
-
return i.formatDistance("xSeconds", h, l);
|
|
45
|
-
} else if (n === "minute") {
|
|
46
|
-
var r = s(u);
|
|
47
|
-
return i.formatDistance("xMinutes", r, l);
|
|
48
|
-
} else if (n === "hour") {
|
|
49
|
-
var y = s(u / 60);
|
|
50
|
-
return i.formatDistance("xHours", y, l);
|
|
51
|
-
} else if (n === "day") {
|
|
52
|
-
var w = s(_ / L);
|
|
53
|
-
return i.formatDistance("xDays", w, l);
|
|
54
|
-
} else if (n === "month") {
|
|
55
|
-
var C = s(_ / F);
|
|
56
|
-
return C === 12 && a.unit !== "month" ? i.formatDistance("xYears", 1, l) : i.formatDistance("xMonths", C, l);
|
|
57
|
-
} else if (n === "year") {
|
|
58
|
-
var E = s(_ / U);
|
|
59
|
-
return i.formatDistance("xYears", E, l);
|
|
60
|
-
}
|
|
61
|
-
throw new RangeError("unit must be 'second', 'minute', 'hour', 'day', 'month' or 'year'");
|
|
62
|
-
}
|
|
63
|
-
var T = /* @__PURE__ */ ((t) => (t.BOTTOM = "bottom", t.AFTER_FIRST = "after-first", t.BEFORE_LAST = "before-last", t))(T || {}), be = /* @__PURE__ */ ((t) => (t.SECOND = "second", t.MINUTE = "minute", t.HOUR = "hour", t.DAY = "day", t.MONTH = "month", t.YEAR = "year", t))(be || {}), M = /* @__PURE__ */ ((t) => (t.DEFAULT = "SquareSmallIcon", t.SUCCESS = "CheckedCircleIcon", t.CRITICAL = "CrossCircleIcon", t))(M || {}), J = /* @__PURE__ */ ((t) => (t.BLACK = "black", t.BLUE = "blue", t.GREEN = "green", t.GREY = "grey", t.ORANGE = "orange", t.RED = "red", t.YELLOW = "yellow", t))(J || {});
|
|
64
|
-
const K = Symbol("timeline register entry injection key"), V = Symbol("timeline config obj injection key"), ge = {
|
|
18
|
+
var C = /* @__PURE__ */ ((t) => (t.BOTTOM = "bottom", t.AFTER_FIRST = "after-first", t.BEFORE_LAST = "before-last", t))(C || {}), he = /* @__PURE__ */ ((t) => (t.SECOND = "second", t.MINUTE = "minute", t.HOUR = "hour", t.DAY = "day", t.MONTH = "month", t.YEAR = "year", t))(he || {}), N = /* @__PURE__ */ ((t) => (t.DEFAULT = "SquareSmallIcon", t.SUCCESS = "CheckedCircleIcon", t.CRITICAL = "CrossCircleIcon", t))(N || {}), J = /* @__PURE__ */ ((t) => (t.BLACK = "black", t.BLUE = "blue", t.GREEN = "green", t.GREY = "grey", t.ORANGE = "orange", t.RED = "red", t.YELLOW = "yellow", t))(J || {});
|
|
19
|
+
const q = Symbol("timeline register entry injection key"), K = Symbol("timeline config obj injection key"), ge = {
|
|
65
20
|
"en-US": {
|
|
66
21
|
addNote: "Add note",
|
|
67
22
|
cancel: "Cancel"
|
|
@@ -74,10 +29,10 @@ const K = Symbol("timeline register entry injection key"), V = Symbol("timeline
|
|
|
74
29
|
addNote: "Adicionar anotação",
|
|
75
30
|
cancel: "Cancelar"
|
|
76
31
|
}
|
|
77
|
-
},
|
|
32
|
+
}, pe = P({
|
|
78
33
|
i18n: { messages: ge },
|
|
79
34
|
name: "bento-timeline",
|
|
80
|
-
components: { BentoButton:
|
|
35
|
+
components: { BentoButton: z, BentoButtonActions: te, BentoTextarea: ee },
|
|
81
36
|
props: {
|
|
82
37
|
/**
|
|
83
38
|
* If set to true, gives the possibility to manually add notes to the timeline via a textarea
|
|
@@ -106,62 +61,62 @@ const K = Symbol("timeline register entry injection key"), V = Symbol("timeline
|
|
|
106
61
|
},
|
|
107
62
|
emits: ["add-timeline-note"],
|
|
108
63
|
setup(t, { emit: e }) {
|
|
109
|
-
const { t: a } =
|
|
110
|
-
|
|
111
|
-
},
|
|
112
|
-
var
|
|
113
|
-
|
|
64
|
+
const { t: a } = H(), c = s(() => a("addNote")), m = s(() => a("cancel")), b = y(), d = (r) => {
|
|
65
|
+
b.value = r;
|
|
66
|
+
}, h = y(null), p = y(null), l = y(!1), g = async () => {
|
|
67
|
+
var r, f;
|
|
68
|
+
l.value = !l.value, await Q(), l.value ? (r = h.value.$refs.textareaElement) == null || r.focus() : (f = p.value.$el) == null || f.focus();
|
|
114
69
|
}, u = () => {
|
|
115
70
|
e("add-timeline-note", {
|
|
116
|
-
description:
|
|
71
|
+
description: b.value,
|
|
117
72
|
timestamp: { date: /* @__PURE__ */ new Date() },
|
|
118
73
|
type: "note"
|
|
119
74
|
}), g();
|
|
120
|
-
},
|
|
121
|
-
() => t.showMore &&
|
|
122
|
-
),
|
|
123
|
-
...
|
|
124
|
-
|
|
125
|
-
] : t.showMore.placement ===
|
|
75
|
+
}, o = y([]), _ = s(
|
|
76
|
+
() => t.showMore && o.value.length > t.showMore.limit ? o.value.length - t.showMore.limit : null
|
|
77
|
+
), v = y(!1), { timegapLimit: n } = Z(t), i = s(() => Array.from(o.value.keys())), w = s(() => t.showMore ? t.showMore.placement === C.BEFORE_LAST ? [
|
|
78
|
+
...i.value.slice(0, t.showMore.limit - 1),
|
|
79
|
+
i.value[i.value.length - 1]
|
|
80
|
+
] : t.showMore.placement === C.AFTER_FIRST ? [i.value[0], ...i.value.slice(-(t.showMore.limit - 1))] : i.value.slice(0, t.showMore.limit) : null), E = s(() => {
|
|
126
81
|
if (!t.showMore)
|
|
127
82
|
return null;
|
|
128
83
|
switch (t.showMore.placement) {
|
|
129
|
-
case
|
|
84
|
+
case C.BEFORE_LAST:
|
|
130
85
|
return t.showMore.limit - 2;
|
|
131
|
-
case
|
|
86
|
+
case C.AFTER_FIRST:
|
|
132
87
|
return 0;
|
|
133
|
-
case
|
|
88
|
+
case C.BOTTOM:
|
|
134
89
|
default:
|
|
135
90
|
return t.showMore.limit - 1;
|
|
136
91
|
}
|
|
137
|
-
}),
|
|
138
|
-
|
|
139
|
-
},
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
},
|
|
143
|
-
|
|
144
|
-
() =>
|
|
145
|
-
() =>
|
|
92
|
+
}), I = () => {
|
|
93
|
+
o.value.sort((r, f) => new Date(f.date).getTime() - new Date(r.date).getTime());
|
|
94
|
+
}, S = (r) => () => {
|
|
95
|
+
const f = o.value.indexOf(r);
|
|
96
|
+
f > -1 && o.value.splice(f, 1);
|
|
97
|
+
}, T = (r) => (o.value.push(r), { timelineEntries: o, unregisterTimelineEntry: S(r) });
|
|
98
|
+
G(
|
|
99
|
+
() => o.value.length,
|
|
100
|
+
() => I()
|
|
146
101
|
);
|
|
147
|
-
const
|
|
148
|
-
showAll:
|
|
149
|
-
showMoreIndex:
|
|
102
|
+
const L = {
|
|
103
|
+
showAll: v,
|
|
104
|
+
showMoreIndex: E,
|
|
150
105
|
hiddenItems: _,
|
|
151
|
-
visibleIndexes:
|
|
152
|
-
timegapLimit:
|
|
153
|
-
timelineEntries:
|
|
106
|
+
visibleIndexes: w,
|
|
107
|
+
timegapLimit: n,
|
|
108
|
+
timelineEntries: o
|
|
154
109
|
};
|
|
155
|
-
return x(
|
|
156
|
-
addNoteLabel:
|
|
157
|
-
cancelLabel:
|
|
110
|
+
return x(q, T), x(K, L), {
|
|
111
|
+
addNoteLabel: c,
|
|
112
|
+
cancelLabel: m,
|
|
158
113
|
toggleAddNote: g,
|
|
159
|
-
updateNoteContent:
|
|
114
|
+
updateNoteContent: d,
|
|
160
115
|
addNoteToTimeline: u,
|
|
161
|
-
showAddNoteTextArea:
|
|
116
|
+
showAddNoteTextArea: l,
|
|
162
117
|
// refs
|
|
163
|
-
addNoteTextareaRef:
|
|
164
|
-
addNoteButtonRef:
|
|
118
|
+
addNoteTextareaRef: h,
|
|
119
|
+
addNoteButtonRef: p
|
|
165
120
|
};
|
|
166
121
|
}
|
|
167
122
|
});
|
|
@@ -171,33 +126,66 @@ var ye = function() {
|
|
|
171
126
|
{ title: e.addNoteLabel, event: e.addNoteToTimeline },
|
|
172
127
|
{ title: e.cancelLabel, event: e.toggleAddNote }
|
|
173
128
|
] } })], 1) : e._e()], 1) : e._e(), a("ol", { staticClass: "b-timeline__items" }, [e._t("default")], 2)]);
|
|
174
|
-
}, Ce = [],
|
|
175
|
-
|
|
129
|
+
}, Ce = [], Te = /* @__PURE__ */ A(
|
|
130
|
+
pe,
|
|
176
131
|
ye,
|
|
177
132
|
Ce,
|
|
178
133
|
!1,
|
|
179
134
|
null,
|
|
180
135
|
"80180322"
|
|
181
136
|
);
|
|
182
|
-
const We =
|
|
183
|
-
let
|
|
184
|
-
const
|
|
137
|
+
const We = Te.exports;
|
|
138
|
+
let U = 0;
|
|
139
|
+
const we = {
|
|
185
140
|
beforeCreate() {
|
|
186
|
-
this.uuid =
|
|
141
|
+
this.uuid = U.toString(), U += 1;
|
|
187
142
|
}
|
|
188
143
|
};
|
|
189
|
-
var
|
|
144
|
+
var Ne = function() {
|
|
190
145
|
var e = this, a = e._self._c;
|
|
191
146
|
return a("svg", e._b({ staticClass: "ui-assets-icons-16", attrs: { role: "img", xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "none" } }, "svg", e.$attrs, !1), [e.$attrs["svg-title"] ? a("title", [e._v(e._s(e.$attrs["svg-title"]))]) : e._e(), a("path", { attrs: { fill: "#001222", d: "M10 3.25C11.5188 3.25 12.75 4.48122 12.75 6V10C12.75 11.5188 11.5188 12.75 10 12.75H6C4.48122 12.75 3.25 11.5188 3.25 10V6C3.25 4.48122 4.48122 3.25 6 3.25H10Z" } })]);
|
|
192
|
-
}, Ee = [], Ie = /* @__PURE__ */
|
|
193
|
-
Te,
|
|
147
|
+
}, Ee = [], Ie = /* @__PURE__ */ A(
|
|
194
148
|
we,
|
|
149
|
+
Ne,
|
|
195
150
|
Ee,
|
|
196
151
|
!1,
|
|
197
152
|
null,
|
|
198
153
|
null
|
|
199
154
|
);
|
|
200
|
-
const Se = Ie.exports
|
|
155
|
+
const Se = Ie.exports;
|
|
156
|
+
function Y(t, e, a) {
|
|
157
|
+
const c = ue(), m = (a == null ? void 0 : a.locale) ?? c.locale ?? _e, b = ve(t, e);
|
|
158
|
+
if (isNaN(b))
|
|
159
|
+
throw new RangeError("Invalid time value");
|
|
160
|
+
const d = Object.assign({}, a, {
|
|
161
|
+
addSuffix: a == null ? void 0 : a.addSuffix,
|
|
162
|
+
comparison: b
|
|
163
|
+
}), [h, p] = fe(
|
|
164
|
+
a == null ? void 0 : a.in,
|
|
165
|
+
...b > 0 ? [e, t] : [t, e]
|
|
166
|
+
), l = be((a == null ? void 0 : a.roundingMethod) ?? "round"), g = p.getTime() - h.getTime(), u = g / F, o = k(p) - k(h), _ = (g - o) / F, v = a == null ? void 0 : a.unit;
|
|
167
|
+
let n;
|
|
168
|
+
if (v ? n = v : u < 1 ? n = "second" : u < 60 ? n = "minute" : u < B ? n = "hour" : _ < j ? n = "day" : _ < $ ? n = "month" : n = "year", n === "second") {
|
|
169
|
+
const i = l(g / 1e3);
|
|
170
|
+
return m.formatDistance("xSeconds", i, d);
|
|
171
|
+
} else if (n === "minute") {
|
|
172
|
+
const i = l(u);
|
|
173
|
+
return m.formatDistance("xMinutes", i, d);
|
|
174
|
+
} else if (n === "hour") {
|
|
175
|
+
const i = l(u / 60);
|
|
176
|
+
return m.formatDistance("xHours", i, d);
|
|
177
|
+
} else if (n === "day") {
|
|
178
|
+
const i = l(_ / B);
|
|
179
|
+
return m.formatDistance("xDays", i, d);
|
|
180
|
+
} else if (n === "month") {
|
|
181
|
+
const i = l(_ / j);
|
|
182
|
+
return i === 12 && v !== "month" ? m.formatDistance("xYears", 1, d) : m.formatDistance("xMonths", i, d);
|
|
183
|
+
} else {
|
|
184
|
+
const i = l(_ / $);
|
|
185
|
+
return m.formatDistance("xYears", i, d);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const Le = {
|
|
201
189
|
"en-US": {
|
|
202
190
|
showLess: "Show less",
|
|
203
191
|
showMore: "Show {items} more",
|
|
@@ -209,19 +197,19 @@ const Se = Ie.exports, Me = {
|
|
|
209
197
|
"pt-BR": {
|
|
210
198
|
showLess: "Mostrar menos"
|
|
211
199
|
}
|
|
212
|
-
},
|
|
200
|
+
}, Me = P({
|
|
213
201
|
name: "bento-timeline-item",
|
|
214
202
|
components: {
|
|
215
|
-
BentoButton:
|
|
216
|
-
BentoDate:
|
|
217
|
-
BentoLink:
|
|
218
|
-
BentoTag:
|
|
219
|
-
BentoTypography:
|
|
220
|
-
BentoStructuredList:
|
|
221
|
-
BentoStructuredListItem:
|
|
203
|
+
BentoButton: z,
|
|
204
|
+
BentoDate: ae,
|
|
205
|
+
BentoLink: ie,
|
|
206
|
+
BentoTag: se,
|
|
207
|
+
BentoTypography: ne,
|
|
208
|
+
BentoStructuredList: re,
|
|
209
|
+
BentoStructuredListItem: oe,
|
|
222
210
|
SquareSmallIcon: Se
|
|
223
211
|
},
|
|
224
|
-
i18n: { messages:
|
|
212
|
+
i18n: { messages: Le },
|
|
225
213
|
props: {
|
|
226
214
|
/**
|
|
227
215
|
* Additional timestamp of the event
|
|
@@ -292,96 +280,96 @@ const Se = Ie.exports, Me = {
|
|
|
292
280
|
variant: {
|
|
293
281
|
type: String,
|
|
294
282
|
default: null,
|
|
295
|
-
validator: (t) => Object.values(
|
|
283
|
+
validator: (t) => Object.values(N).includes(t)
|
|
296
284
|
}
|
|
297
285
|
},
|
|
298
286
|
setup(t, { slots: e }) {
|
|
299
|
-
const { t: a } =
|
|
300
|
-
t.variant &&
|
|
287
|
+
const { t: a } = H(), c = s(() => t.type === "note"), m = s(() => t.variant === N.CRITICAL ? "red" : t.variant === N.SUCCESS ? "green" : t.status);
|
|
288
|
+
t.variant && le(
|
|
301
289
|
'BentoTimelineItem "variant" property',
|
|
302
290
|
`Use the BentoTimelineItem "status" modifier instead to modify the color of the timeline icon.
|
|
303
291
|
<bento-timeline-item status="red" />`,
|
|
304
292
|
"2.0.0"
|
|
305
293
|
);
|
|
306
|
-
const
|
|
307
|
-
[`b-timeline-item__icon--${
|
|
308
|
-
})),
|
|
309
|
-
"b-timeline-item--note":
|
|
294
|
+
const b = s(() => ({
|
|
295
|
+
[`b-timeline-item__icon--${m.value}`]: m.value && !c.value
|
|
296
|
+
})), d = s(() => ({
|
|
297
|
+
"b-timeline-item--note": c.value
|
|
310
298
|
}));
|
|
311
|
-
x(
|
|
312
|
-
const
|
|
299
|
+
x(ce, !0);
|
|
300
|
+
const h = {
|
|
313
301
|
title: t.title,
|
|
314
302
|
date: t.timestamp.date
|
|
315
|
-
},
|
|
316
|
-
|
|
317
|
-
const { showAll: u, showMoreIndex:
|
|
318
|
-
() =>
|
|
319
|
-
),
|
|
320
|
-
var
|
|
321
|
-
if (!
|
|
303
|
+
}, p = D(q), { timelineEntries: l, unregisterTimelineEntry: g } = p(h);
|
|
304
|
+
X(() => g());
|
|
305
|
+
const { showAll: u, showMoreIndex: o, hiddenItems: _, visibleIndexes: v, timegapLimit: n } = D(K), i = s(() => l.value.indexOf(h)), w = s(() => u.value || !v.value), E = s(
|
|
306
|
+
() => w.value ? !0 : v.value.includes(i.value)
|
|
307
|
+
), I = s(() => typeof t.title == "object"), S = s(() => t.title), T = s(() => {
|
|
308
|
+
var O;
|
|
309
|
+
if (!n.value)
|
|
322
310
|
return null;
|
|
323
|
-
const
|
|
324
|
-
if (!
|
|
311
|
+
const M = (O = l.value[i.value - 1]) == null ? void 0 : O.date, V = w.value || v.value.includes(i.value - 1);
|
|
312
|
+
if (!M || !V)
|
|
325
313
|
return null;
|
|
326
|
-
const { date:
|
|
327
|
-
Y(
|
|
314
|
+
const { date: R } = l.value[i.value], W = parseInt(
|
|
315
|
+
Y(M, R, { unit: n.value.unit }),
|
|
328
316
|
10
|
|
329
317
|
);
|
|
330
|
-
return
|
|
331
|
-
}),
|
|
318
|
+
return n.value.amount < W ? Y(M, R, { roundingMethod: "floor" }) : null;
|
|
319
|
+
}), L = s(() => T.value ? a("timegap", { timegap: T.value }) : ""), r = s(() => _.value && o.value === i.value), f = s(() => i.value !== -1 && i.value === l.value.length - 1);
|
|
332
320
|
return {
|
|
333
321
|
// Values
|
|
334
|
-
isNoteType:
|
|
335
|
-
iconConditionalClasses:
|
|
336
|
-
conditionalClasses:
|
|
337
|
-
displayShowMoreButton:
|
|
322
|
+
isNoteType: c,
|
|
323
|
+
iconConditionalClasses: b,
|
|
324
|
+
conditionalClasses: d,
|
|
325
|
+
displayShowMoreButton: r,
|
|
338
326
|
showAll: u,
|
|
339
327
|
hiddenItems: _,
|
|
340
|
-
isVisible:
|
|
341
|
-
isLinkTitle:
|
|
342
|
-
linkTitleProps:
|
|
343
|
-
timegap:
|
|
344
|
-
timegapAriaLabel:
|
|
345
|
-
isLastItem:
|
|
328
|
+
isVisible: E,
|
|
329
|
+
isLinkTitle: I,
|
|
330
|
+
linkTitleProps: S,
|
|
331
|
+
timegap: T,
|
|
332
|
+
timegapAriaLabel: L,
|
|
333
|
+
isLastItem: f,
|
|
346
334
|
// Methods
|
|
347
|
-
generateUid:
|
|
348
|
-
hasSlot:
|
|
335
|
+
generateUid: me,
|
|
336
|
+
hasSlot: de(e),
|
|
349
337
|
t: a
|
|
350
338
|
};
|
|
351
339
|
}
|
|
352
340
|
});
|
|
353
|
-
var
|
|
341
|
+
var xe = function() {
|
|
354
342
|
var e = this, a = e._self._c;
|
|
355
343
|
return e._self._setupProxy, e.isVisible ? a("li", { staticClass: "b-timeline-item", class: e.conditionalClasses }, [e.timegap ? a("div", { staticClass: "b-timeline-item__row" }, [e._m(0), a("div", { staticClass: "b-timeline-item__content" }, [a("bento-typography", { staticClass: "b-timeline-item__timegap", attrs: { "aria-label": e.timegapAriaLabel } }, [e._v(" " + e._s(e.timegap) + " ")])], 1)]) : e._e(), a("div", { staticClass: "b-timeline-item__row" }, [a("div", { staticClass: "b-timeline-item__marker", attrs: { "aria-hidden": "true" } }, [a("square-small-icon", { staticClass: "b-timeline-item__icon", class: e.iconConditionalClasses }), e.isLastItem ? e._e() : a("div", { staticClass: "b-timeline-item__separator", attrs: { "data-testid": "last-timeline-item-separator" } })], 1), a("div", { staticClass: "b-timeline-item__content" }, [e.isNoteType ? e._e() : a("bento-typography", { staticClass: "b-timeline-item__title", attrs: { el: "div", variant: "body", strongest: "", role: "heading", "aria-level": "2" } }, [e.isLinkTitle ? a("bento-link", e._b({ attrs: { "disable-typography": "" } }, "bento-link", e.linkTitleProps, !1), [e._v(e._s(e.linkTitleProps.title))]) : a("span", [e._v(e._s(e.title))])], 1), e.isNoteType && (e.description || e.hasSlot("default")) ? a("bento-typography", { staticClass: "b-timeline-item__description", attrs: { el: "div", variant: "body" } }, [e._t("default", function() {
|
|
356
344
|
return [e._v(e._s(e.description))];
|
|
357
345
|
})], 2) : e._e(), e.timestamp ? a("bento-typography", { staticClass: "b-timeline-item__timestamp", attrs: { el: "div", variant: "caption" } }, [a("bento-date", { attrs: { date: e.timestamp.date, format: e.timestamp.format, "disable-typography": "" } }), e._v(" " + e._s(e.timestamp.value) + " ")], 1) : e._e(), !e.isNoteType && e.additionalTimestamp ? a("bento-typography", { staticClass: "b-timeline-item__timestamp", attrs: { el: "div", variant: "caption" } }, [a("bento-date", { attrs: { date: e.additionalTimestamp.date, format: e.additionalTimestamp.format, "disable-typography": "" } }), e._v(" " + e._s(e.additionalTimestamp.value) + " ")], 1) : e._e(), !e.isNoteType && (e.description || e.hasSlot("default")) ? a("bento-typography", { staticClass: "b-timeline-item__description", attrs: { el: "div", variant: "body" } }, [e._t("default", function() {
|
|
358
346
|
return [e._v(e._s(e.description))];
|
|
359
|
-
})], 2) : e._e(), !e.isNoteType && e.dataList ? a("div", { staticClass: "b-timeline-item__data-list" }, [a("bento-structured-list", e._l(e.dataList, function(
|
|
360
|
-
return a("bento-structured-list-item", { key: e.generateUid(
|
|
361
|
-
}), 1)], 1) : e._e(), !e.isNoteType && e.tag ? a("bento-tag", e._b({ staticClass: "b-timeline-item__tag" }, "bento-tag", e.tag, !1)) : e._e()], 1)]), e.displayShowMoreButton ? a("div", { staticClass: "b-timeline-item__row" }, [e._m(1), a("div", { staticClass: "b-timeline-item__content" }, [a("bento-button", { staticClass: "b-timeline__show-more", attrs: { variant: "tertiary" }, on: { click: function(
|
|
347
|
+
})], 2) : e._e(), !e.isNoteType && e.dataList ? a("div", { staticClass: "b-timeline-item__data-list" }, [a("bento-structured-list", e._l(e.dataList, function(c) {
|
|
348
|
+
return a("bento-structured-list-item", { key: e.generateUid(c.label), attrs: { label: c.label } }, [a("bento-typography", { attrs: { variant: "caption" } }, [e._v(e._s(c.value))])], 1);
|
|
349
|
+
}), 1)], 1) : e._e(), !e.isNoteType && e.tag ? a("bento-tag", e._b({ staticClass: "b-timeline-item__tag" }, "bento-tag", e.tag, !1)) : e._e()], 1)]), e.displayShowMoreButton ? a("div", { staticClass: "b-timeline-item__row" }, [e._m(1), a("div", { staticClass: "b-timeline-item__content" }, [a("bento-button", { staticClass: "b-timeline__show-more", attrs: { variant: "tertiary" }, on: { click: function(c) {
|
|
362
350
|
e.showAll = !e.showAll;
|
|
363
351
|
} } }, [e.showAll ? [e._v(e._s(e.t("showLess")))] : [e._v(e._s(e.t("showMore", { items: e.hiddenItems })))]], 2)], 1)]) : e._e()]) : e._e();
|
|
364
|
-
},
|
|
352
|
+
}, Ae = [function() {
|
|
365
353
|
var t = this, e = t._self._c;
|
|
366
354
|
return t._self._setupProxy, e("div", { staticClass: "b-timeline-item__marker", attrs: { "aria-hidden": "true" } }, [e("div", { staticClass: "b-timeline-item__icon b-timeline-item__icon--timegap" }), e("div", { staticClass: "b-timeline-item__separator" })]);
|
|
367
355
|
}, function() {
|
|
368
356
|
var t = this, e = t._self._c;
|
|
369
357
|
return t._self._setupProxy, e("div", { staticClass: "b-timeline-item__marker", attrs: { "aria-hidden": "true" } }, [e("div", { staticClass: "b-timeline-item__separator" })]);
|
|
370
|
-
}],
|
|
371
|
-
|
|
358
|
+
}], Re = /* @__PURE__ */ A(
|
|
359
|
+
Me,
|
|
360
|
+
xe,
|
|
372
361
|
Ae,
|
|
373
|
-
Re,
|
|
374
362
|
!1,
|
|
375
363
|
null,
|
|
376
|
-
"
|
|
364
|
+
"862b2546"
|
|
377
365
|
);
|
|
378
|
-
const Ze =
|
|
366
|
+
const Ze = Re.exports;
|
|
379
367
|
export {
|
|
380
|
-
|
|
368
|
+
C as B,
|
|
381
369
|
Ze as a,
|
|
382
|
-
|
|
383
|
-
|
|
370
|
+
he as b,
|
|
371
|
+
N as c,
|
|
384
372
|
J as d,
|
|
385
373
|
We as t
|
|
386
374
|
};
|
|
387
|
-
//# sourceMappingURL=timeline-item.
|
|
375
|
+
//# sourceMappingURL=timeline-item.CZBuknZ_.js.map
|