@adyen/bento-vue2 2.0.0 → 2.0.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/accordion.js +1 -1
- 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/card.js +1 -1
- package/dist/checkbox.js +2 -2
- package/dist/chunks/{accordion-item.DOj7vqeL.js → accordion-item.B7lteJBu.js} +2 -2
- package/dist/chunks/{accordion-item.DOj7vqeL.js.map → accordion-item.B7lteJBu.js.map} +1 -1
- package/dist/chunks/{card.b9PEJ7hm.js → card.BmpB0VbL.js} +2 -2
- package/dist/chunks/{card.b9PEJ7hm.js.map → card.BmpB0VbL.js.map} +1 -1
- package/dist/chunks/{checkbox-group.UYN1ljai.js → checkbox-group.D1uyc3z3.js} +2 -2
- package/dist/chunks/{checkbox-group.UYN1ljai.js.map → checkbox-group.D1uyc3z3.js.map} +1 -1
- package/dist/chunks/{checkbox.Co4HoHKF.js → checkbox.D5xZ5Nnh.js} +14 -14
- package/dist/chunks/{checkbox.Co4HoHKF.js.map → checkbox.D5xZ5Nnh.js.map} +1 -1
- package/dist/chunks/{data-grid.B1lI07ze.js → data-grid.CMxQpfrY.js} +4 -4
- package/dist/chunks/{data-grid.B1lI07ze.js.map → data-grid.CMxQpfrY.js.map} +1 -1
- package/dist/chunks/{filter-bar.DXpLhnxG.js → filter-bar.D7Lk7wlq.js} +2 -2
- package/dist/chunks/{filter-bar.DXpLhnxG.js.map → filter-bar.D7Lk7wlq.js.map} +1 -1
- package/dist/chunks/{header-with-views.HwbE278X.js → header-with-views.BqobE7IF.js} +2 -2
- package/dist/chunks/{header-with-views.HwbE278X.js.map → header-with-views.BqobE7IF.js.map} +1 -1
- package/dist/chunks/{navigation-menu-group.B-AV49Bn.js → navigation-menu-group.BnHdXODQ.js} +2 -2
- package/dist/chunks/{navigation-menu-group.B-AV49Bn.js.map → navigation-menu-group.BnHdXODQ.js.map} +1 -1
- package/dist/chunks/{rich-text-editor.DNmVJilP.js → rich-text-editor.rXoS7KGY.js} +2 -2
- package/dist/chunks/{rich-text-editor.DNmVJilP.js.map → rich-text-editor.rXoS7KGY.js.map} +1 -1
- package/dist/chunks/{secondary-nav.CXtDQAay.js → secondary-nav.CgdV0QwZ.js} +2 -2
- package/dist/chunks/{secondary-nav.CXtDQAay.js.map → secondary-nav.CgdV0QwZ.js.map} +1 -1
- package/dist/chunks/{selection-card-group.DjFWMqVZ.js → selection-card-group.CmDuj1c7.js} +8 -8
- package/dist/chunks/{selection-card-group.DjFWMqVZ.js.map → selection-card-group.CmDuj1c7.js.map} +1 -1
- package/dist/chunks/use-expandable-content-height.DmFeas9-.js +36 -0
- package/dist/chunks/use-expandable-content-height.DmFeas9-.js.map +1 -0
- package/dist/data-grid.js +1 -1
- package/dist/filter-bar.js +1 -1
- package/dist/header-with-views.js +1 -1
- package/dist/index.js +11 -11
- package/dist/navigation-menu.js +1 -1
- package/dist/rich-text-editor.js +1 -1
- package/dist/secondary-nav.js +1 -1
- package/dist/selection-card.js +1 -1
- package/dist/web-types.json +1 -1
- package/package.json +6 -6
- package/dist/chunks/use-expandable-content-height.Bdd9hQwq.js +0 -34
- package/dist/chunks/use-expandable-content-height.Bdd9hQwq.js.map +0 -1
|
@@ -10,7 +10,7 @@ import { B as U } from "./button.DII5Ifwa.js";
|
|
|
10
10
|
import { C as H } from "./chevron-down.B_QiVCoO.js";
|
|
11
11
|
import { C as j } from "./chevron-up.YQRo8uKs.js";
|
|
12
12
|
import { g as G } from "./generate-uid.DBWe4g6T.js";
|
|
13
|
-
import { u as J } from "./use-expandable-content-height.
|
|
13
|
+
import { u as J } from "./use-expandable-content-height.DmFeas9-.js";
|
|
14
14
|
import { n as B } from "./_plugin-vue2_normalizer.CeySl7Fu.js";
|
|
15
15
|
import "../assets/secondary-nav.css";
|
|
16
16
|
const k = /* @__PURE__ */ Symbol("secondary nav state"), X = {
|
|
@@ -189,4 +189,4 @@ const Te = ce.exports;
|
|
|
189
189
|
export {
|
|
190
190
|
Te as s
|
|
191
191
|
};
|
|
192
|
-
//# sourceMappingURL=secondary-nav.
|
|
192
|
+
//# sourceMappingURL=secondary-nav.CgdV0QwZ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secondary-nav.CXtDQAay.js","sources":["../../src/components/secondary-nav/secondary-nav.keys.ts","../../src/components/secondary-nav/components/secondary-nav-item/secondary-nav-item.vue","../../src/components/secondary-nav/components/secondary-nav-category/secondary-nav-category.vue","../../src/components/secondary-nav/secondary-nav.vue"],"sourcesContent":["import { type InjectionKey } from 'vue';\nimport { type BentoSecondaryNavState } from './secondary-nav.types';\n\nexport const SECONDARY_NAV_STATE = Symbol('secondary nav state') as InjectionKey<BentoSecondaryNavState>;\n","<template>\n <div class=\"b-secondary-nav-item\">\n <div class=\"b-secondary-nav-item__wrapper\">\n <button\n class=\"b-secondary-nav-item__option\"\n :class=\"conditionalClasses\"\n :aria-current=\"isItemSelected ? 'page' : undefined\"\n :aria-expanded=\"expandleItemIsToggleOnly ? `${isOpen}` : undefined\"\n :aria-controls=\"expandleItemIsToggleOnly ? subItemsId : undefined\"\n @click=\"expandleItemIsToggleOnly ? onToggleClick() : onClick($event)\"\n >\n <bento-typography class=\"b-secondary-nav-item__title\" variant=\"body\" stronger>\n {{ label }}\n </bento-typography>\n <bento-tag\n v-if=\"errorCounter\"\n class=\"b-secondary-nav-item__error-counter\"\n variant=\"red\"\n :label=\"errorCounter.toString()\"\n :aria-label=\"tc('errorCount', errorCounter)\"\n >\n <template #icon>\n <cross-circle-fill-icon aria-hidden=\"true\" />\n </template>\n </bento-tag>\n </button>\n <bento-button\n v-if=\"hasSubItems\"\n :aria-hidden=\"expandleItemIsToggleOnly\"\n :tabindex=\"expandleItemIsToggleOnly ? -1 : undefined\"\n class=\"b-secondary-nav-item__toggle\"\n variant=\"tertiary\"\n :aria-label=\"isOpen ? `Collapse ${label}` : `Expand ${label}`\"\n :aria-expanded=\"!expandleItemIsToggleOnly ? `${isOpen}` : undefined\"\n :aria-controls=\"!expandleItemIsToggleOnly ? subItemsId : undefined\"\n @click.stop=\"onToggleClick\"\n >\n <template #iconLeft>\n <chevron-up-icon v-if=\"isOpen\" class=\"b-secondary-nav-item__icon\" aria-hidden=\"true\" />\n <chevron-down-icon v-else class=\"b-secondary-nav-item__icon\" aria-hidden=\"true\" />\n </template>\n </bento-button>\n </div>\n <Transition :name=\"CONTENT_TRANSITION_NAME\">\n <div v-if=\"hasSubItems && isOpen\" :id=\"subItemsId\" :style=\"subItemsMaxHeight\">\n <ul ref=\"subItemsRef\" class=\"b-secondary-nav-item__sub-items\">\n <li v-for=\"item in items\" :key=\"item.value\">\n <secondary-nav-item\n :label=\"item.label\"\n :value=\"item.value\"\n :items=\"item.items\"\n :error-counter=\"item.errorCounter\"\n is-sub-item\n />\n </li>\n </ul>\n </div>\n </Transition>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\n import { SECONDARY_NAV_STATE } from '../../secondary-nav.keys';\n import { BentoButton } from '@/components/button';\n import { BentoTag } from '@/components/tag';\n import { BentoTypography } from '@/components/typography';\n import ChevronDownIcon from '@adyen/ui-assets-icons-16/vue/chevron-down';\n import ChevronUpIcon from '@adyen/ui-assets-icons-16/vue/chevron-up';\n import CrossCircleFillIcon from '@adyen/ui-assets-icons-16/vue/cross-circle-fill';\n import { computed, inject, ref, watch } from 'vue';\n import { useI18n } from '@/utils/ts/i18n';\n import { generateUid } from '@/utils/ts/generate-uid';\n import { type BentoSecondaryNavItemsItem } from '../../secondary-nav.types';\n import { useExpandableContentHeight } from '@/composables/use-expandable-content-height/use-expandable-content-height';\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n const { tc } = useI18n<{ message: MessageSchema }>({ messages });\n const { activeItemValue, updateActiveItemValue, allowExpandableItemNavigation } = inject(SECONDARY_NAV_STATE);\n const CONTENT_TRANSITION_NAME = 'b-secondary-nav-item__animation--content';\n\n const props = defineProps({\n label: null,\n value: null,\n items: null,\n isSubItem: { type: Boolean },\n errorCounter: null\n});\n\n const isOpen = ref(false);\n const subItemsId = generateUid('secondary-nav-sub-items');\n const subItemsRef = ref<HTMLUListElement>(null);\n const hasSubItems = computed(() => !!props.items?.length);\n const isItemSelected = computed(() => activeItemValue.value === props.value);\n const expandleItemIsToggleOnly = computed(() => hasSubItems.value && !allowExpandableItemNavigation.value);\n const { contentHeight } = useExpandableContentHeight(subItemsRef, isOpen);\n const subItemsMaxHeight = computed(() => (contentHeight.value ? { 'max-height': contentHeight.value } : {}));\n\n const conditionalClasses = computed(() => ({\n 'b-secondary-nav-item__option--active': isItemSelected.value,\n 'b-secondary-nav-item__option--expandable': hasSubItems.value,\n 'b-secondary-nav-item__option--sub-item': props.isSubItem,\n }));\n\n const emit = defineEmits([\"click\"]);\n\n const onClick = (e: MouseEvent) => {\n emit('click', e);\n updateActiveItemValue(props.value);\n };\n\n const onToggleClick = () => {\n isOpen.value = !isOpen.value;\n };\n\n const hasActiveDescendant = (items: Array<BentoSecondaryNavItemsItem>, value: string): boolean => {\n return items.some(\n item => item.value === value || (item.items ? hasActiveDescendant(item.items, value) : false)\n );\n };\n\n const hasDescendantErrors = (items: Array<BentoSecondaryNavItemsItem>): boolean =>\n items.some(item => !!item.errorCounter || (item.items ? hasDescendantErrors(item.items) : false));\n\n watch(\n [activeItemValue, () => props.items],\n ([activeValue]) => {\n if (hasSubItems.value && props.items) {\n if (hasActiveDescendant(props.items, activeValue) || hasDescendantErrors(props.items)) {\n isOpen.value = true;\n }\n }\n },\n { immediate: true, deep: true }\n );\n</script>\n\n<script lang=\"ts\">\n /**\n * This component shouldn't be used directly. It is internally used by {@see BentoSecondaryNav}\n */\n export default { i18n: { messages } };\n</script>\n\n<style lang=\"scss\" scoped src=\"./secondary-nav-item.scss\" />\n","<template>\n <section class=\"b-secondary-nav-category\" :aria-label=\"label\">\n <bento-typography el=\"h1\" class=\"b-secondary-nav-category__label\" variant=\"caption\" stronger>{{\n label\n }}</bento-typography>\n <ul class=\"b-secondary-nav__list\">\n <li v-for=\"item in items\" :key=\"item.value\">\n <secondary-nav-item\n :label=\"item.label\"\n :value=\"item.value\"\n :items=\"item.items\"\n :error-counter=\"item.errorCounter\"\n />\n </li>\n </ul>\n </section>\n</template>\n\n<script lang=\"ts\" setup>\n import { BentoTypography } from '@/components/typography';\n import { SecondaryNavItem } from '../secondary-nav-item';\n import { type BentoSecondaryNavItemsItem } from '../../secondary-nav.types';\n\n defineProps({\n label: null,\n items: null\n});\n</script>\n\n<script lang=\"ts\">\n /**\n * This component shouldn't be used directly. It is internally used by {@see BentoSecondaryNav}\n */\n export default {};\n</script>\n\n<style lang=\"scss\" scoped src=\"./secondary-nav-category.scss\" />\n","<template>\n <nav class=\"b-secondary-nav\">\n <bento-dropdown\n v-if=\"isMobile\"\n :aria-label=\"t('mobileDropdownAriaLabel')\"\n :items=\"mobileDropdownItems\"\n :static-categories=\"hasCategories\"\n :model-value=\"activeItemValue\"\n :is-option-disabled=\"isMobileOptionDisabled\"\n @update:model-value=\"updateActiveItemValue\"\n >\n <template #display-value=\"{ label }\">\n <bento-typography el=\"span\">\n {{ label }}\n </bento-typography>\n </template>\n <template #default=\"{ label, data }\">\n <bento-typography\n el=\"div\"\n :class=\"{ 'b-secondary-nav__option': true, 'b-secondary-nav__nested-option': !!data?.level }\"\n >\n {{ label }}\n <bento-tag\n v-if=\"data?.errorCounter\"\n class=\"b-secondary-nav__error-counter\"\n variant=\"red\"\n :label=\"data.errorCounter\"\n :aria-label=\"tc('errorCount', data.errorCounter)\"\n >\n <template #icon>\n <cross-circle-fill-icon aria-hidden=\"true\" />\n </template>\n </bento-tag>\n </bento-typography>\n </template>\n </bento-dropdown>\n <ul v-else class=\"b-secondary-nav__list\">\n <li v-for=\"item in items\" :key=\"item.label\">\n <secondary-nav-category\n v-if=\"'items' in item && !('value' in item)\"\n :label=\"item.label\"\n :items=\"item.items\"\n />\n <secondary-nav-item\n v-else\n :label=\"item.label\"\n :value=\"item.value\"\n :items=\"item.items\"\n :error-counter=\"item.errorCounter\"\n />\n </li>\n </ul>\n </nav>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, provide, readonly, ref, toRef, watch } from 'vue';\n import { SecondaryNavItem } from './components/secondary-nav-item';\n import { SecondaryNavCategory } from './components/secondary-nav-category';\n import { SECONDARY_NAV_STATE } from './secondary-nav.keys';\n import {\n type BentoSecondaryNavItems,\n type BentoSecondaryNavItemsCategory,\n type BentoSecondaryNavItemsItem,\n type BentoSecondaryNavState,\n } from './secondary-nav.types';\n import { BentoDropdown } from '@/components/dropdown';\n import { BentoTypography } from '@/components/typography';\n import { BentoTag } from '@/components/tag';\n import CrossCircleFillIcon from '@adyen/ui-assets-icons-16/vue/cross-circle-fill';\n import { useBreakpoints } from '@vueuse/core';\n import { useI18n } from '@/utils/ts/i18n';\n import { type BentoListboxOptionItem, type BentoListboxOptions } from '@/types/listbox';\n import { BMediaQuerySMax } from '@adyen/bento-design-tokens/dist/js/bento/es6';\n\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n const { t, tc } = useI18n<{ message: MessageSchema }>({ messages });\n\n const breakpoints = useBreakpoints({\n s: BMediaQuerySMax,\n });\n\n const isMobile = breakpoints.smallerOrEqual('s');\n const props = defineProps({\n items: null,\n value: null,\n allowExpandableItemNavigation: { type: Boolean }\n});\n\n const emit = defineEmits([\"change\"]);\n\n const isCategory = (item: BentoSecondaryNavItems[number]): item is BentoSecondaryNavItemsCategory =>\n 'items' in item && !('value' in item);\n\n const mapNestedItems = (items: Array<BentoSecondaryNavItemsItem>, level = 0): BentoListboxOptions =>\n items.flatMap((item): BentoListboxOptions => {\n const currentItem: BentoListboxOptionItem = {\n label: item.label,\n value: item.value,\n data: { level, hasSubItems: !!item.items?.length, errorCounter: item.errorCounter },\n };\n\n if (item.items?.length) {\n return [currentItem, ...mapNestedItems(item.items, level + 1)];\n }\n\n return [currentItem];\n });\n\n const isMobileOptionDisabled = (option: BentoListboxOptionItem): boolean =>\n !props.allowExpandableItemNavigation && (option.data as { hasSubItems?: boolean })?.hasSubItems;\n\n const hasCategories = computed(() => props.items.some(item => isCategory(item)));\n const mobileDropdownItems = computed<BentoListboxOptions>(() => {\n return props.items.flatMap(item => {\n if (isCategory(item)) {\n return [\n {\n label: item.label,\n value: `category-${item.label}`,\n items: mapNestedItems(item.items),\n } satisfies BentoListboxOptionItem,\n ];\n }\n\n if (item.items?.length) {\n return mapNestedItems([item]);\n }\n\n return [\n {\n label: item.label,\n value: item.value,\n data: { level: 0, errorCounter: item.errorCounter },\n } satisfies BentoListboxOptionItem,\n ];\n });\n });\n\n const flattenNestedItems = (items: Array<BentoSecondaryNavItemsItem>): Array<BentoSecondaryNavItemsItem> =>\n items.flatMap(item => [item, ...(item.items?.length ? flattenNestedItems(item.items) : [])]);\n\n const findFirstSelectableNestedItemValue = (items: Array<BentoSecondaryNavItemsItem>): string =>\n flattenNestedItems(items).find(item => props.allowExpandableItemNavigation || !item.items?.length)?.value ?? '';\n\n const activeItemValueFallback = computed(() => {\n if (!props.items.length) {\n return '';\n }\n\n return findFirstSelectableNestedItemValue(\n props.items.flatMap(item =>\n isCategory(item) ? flattenNestedItems(item.items) : flattenNestedItems([item])\n )\n );\n });\n\n const activeItemValue = ref(props.value ?? activeItemValueFallback.value);\n const updateActiveItemValue = (value: string) => {\n activeItemValue.value = value;\n emit('change', value);\n };\n\n // The component's state is inject on `secondary-nav-item` to determine the\n // current active item and to change its value\n const state: BentoSecondaryNavState = {\n activeItemValue: readonly(activeItemValue),\n updateActiveItemValue,\n allowExpandableItemNavigation: toRef(props, 'allowExpandableItemNavigation'),\n };\n\n watch(\n () => props.value,\n value => {\n if (value !== undefined) {\n activeItemValue.value = value;\n }\n }\n );\n\n provide(SECONDARY_NAV_STATE, state);\n</script>\n\n<script lang=\"ts\">\n /**\n * Secondary Nav offers users a structured way to access information.\n * It also provides a clear hierarchy for users to understand and navigate through various information.\n *\n * @example\n * import { BentoSecondaryNav } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoSecondaryNav },\n * template: `\n * <bento-secondary-nav :value=\"value\" :items=\"items\" />\n * `,\n * setup() {\n * const value = ref(2) // Active item value\n * const items: BentoSecondaryNavItemInfo[] = [\n * { label: 'Option 1', value: 1 },\n * { label: 'Option 2', value: 2 },\n * ];\n * return { items, value };\n * }\n * }\n */\n export default {\n i18n: { messages },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./secondary-nav.scss\" />\n"],"names":["SECONDARY_NAV_STATE","__default__$2","messages$1","tc","useI18n","activeItemValue","updateActiveItemValue","allowExpandableItemNavigation","inject","CONTENT_TRANSITION_NAME","isOpen","ref","subItemsId","generateUid","subItemsRef","hasSubItems","computed","props","isItemSelected","expandleItemIsToggleOnly","contentHeight","useExpandableContentHeight","subItemsMaxHeight","conditionalClasses","onClick","e","emit","onToggleClick","hasActiveDescendant","items","value","item","hasDescendantErrors","watch","activeValue","__default__$1","__default__","messages","t","breakpoints","useBreakpoints","BMediaQuerySMax","isMobile","isCategory","mapNestedItems","level","currentItem","isMobileOptionDisabled","option","hasCategories","mobileDropdownItems","flattenNestedItems","findFirstSelectableNestedItemValue","activeItemValueFallback","state","readonly","toRef","provide"],"mappings":";;;;;;;;;;;;;;;AAGO,MAAAA,IAAA,uBAAA,qBAAA;;;;;;;;;;;;GC2IHC,IAAA,EAAA,MAAA,EAAA,UAAAC,EAAA,EAAA;;;;;;;;;;;;iBAhEA,EAAA,IAAAC,EAAA,IAAAC,EAAA,GAC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AGJ;AAAA,MAAO;AAAA,QACH,OAAAA,EAAA;AAAA,QACgB,OAAAA,EAAA;AAAA,QACA,MAAA,EAAA,OAAA,GAAA,cAAAA,EAAA,aAAA;AAAA,MACsC;AAAA,IACtD,CACJ,CACH,GAGLoB,IAAA,CAAAtB,MAAAA,EAAA,QAAA,CAAAE,MAAA,CAAAA,GAAA,GAAAA,EAAA,OAAA,SAAAoB,EAAApB,EAAA,KAAA,IAAA,CAAA,CAAA,CAAA,GAGAqB,IAAA,CAAAvB,MAAAsB,EAAAtB,CAAA,EAAA,KAAA,CAAAE,MAAAd,EAAA,iCAAA,CAAAc,EAAA,OAAA,MAAA,GAAA,SAAA,IAGAsB,IAAArC,EAAA,MACIC,EAAA,MAAA,SAIAmC;AAAA,MAAOnC,EAAA,MAAA;AAAA,QACS,CAAAc,MAAAY,EAAAZ,CAAA,IAAAoB,EAAApB,EAAA,KAAA,IAAAoB,EAAA,CAAApB,CAAA,CAAA;AAAA,MACqE;AAAA,IACjF,IANA,EAOJ,GAGJ1B,IAAAM,EAAAM,EAAA,SAAAoC,EAAA,KAAA,GACA/C,IAAA,CAAAwB,MAAA;AACI,MAAAzB,EAAA,QAAAyB,GACAJ,EAAA,UAAAI,CAAA;AAAA,IAAoB,GAKxBwB,IAAA;AAAA,MAAsC,iBAAAC,EAAAlD,CAAA;AAAA,MACO,uBAAAC;AAAA,MACzC,+BAAAkD,EAAAvC,GAAA,+BAAA;AAAA,IAC2E;AAG/E,WAAAgB;AAAA,MAAA,MAAAhB,EAAA;AAAA,MACgB,CAAAa,MAAA;AAER,QAAAA,MAAA,WACIzB,EAAA,QAAAyB;AAAA,MACJ;AAAA,IACJ,GAGJ2B,EAAAzD,GAAAsD,CAAA;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"secondary-nav.CgdV0QwZ.js","sources":["../../src/components/secondary-nav/secondary-nav.keys.ts","../../src/components/secondary-nav/components/secondary-nav-item/secondary-nav-item.vue","../../src/components/secondary-nav/components/secondary-nav-category/secondary-nav-category.vue","../../src/components/secondary-nav/secondary-nav.vue"],"sourcesContent":["import { type InjectionKey } from 'vue';\nimport { type BentoSecondaryNavState } from './secondary-nav.types';\n\nexport const SECONDARY_NAV_STATE = Symbol('secondary nav state') as InjectionKey<BentoSecondaryNavState>;\n","<template>\n <div class=\"b-secondary-nav-item\">\n <div class=\"b-secondary-nav-item__wrapper\">\n <button\n class=\"b-secondary-nav-item__option\"\n :class=\"conditionalClasses\"\n :aria-current=\"isItemSelected ? 'page' : undefined\"\n :aria-expanded=\"expandleItemIsToggleOnly ? `${isOpen}` : undefined\"\n :aria-controls=\"expandleItemIsToggleOnly ? subItemsId : undefined\"\n @click=\"expandleItemIsToggleOnly ? onToggleClick() : onClick($event)\"\n >\n <bento-typography class=\"b-secondary-nav-item__title\" variant=\"body\" stronger>\n {{ label }}\n </bento-typography>\n <bento-tag\n v-if=\"errorCounter\"\n class=\"b-secondary-nav-item__error-counter\"\n variant=\"red\"\n :label=\"errorCounter.toString()\"\n :aria-label=\"tc('errorCount', errorCounter)\"\n >\n <template #icon>\n <cross-circle-fill-icon aria-hidden=\"true\" />\n </template>\n </bento-tag>\n </button>\n <bento-button\n v-if=\"hasSubItems\"\n :aria-hidden=\"expandleItemIsToggleOnly\"\n :tabindex=\"expandleItemIsToggleOnly ? -1 : undefined\"\n class=\"b-secondary-nav-item__toggle\"\n variant=\"tertiary\"\n :aria-label=\"isOpen ? `Collapse ${label}` : `Expand ${label}`\"\n :aria-expanded=\"!expandleItemIsToggleOnly ? `${isOpen}` : undefined\"\n :aria-controls=\"!expandleItemIsToggleOnly ? subItemsId : undefined\"\n @click.stop=\"onToggleClick\"\n >\n <template #iconLeft>\n <chevron-up-icon v-if=\"isOpen\" class=\"b-secondary-nav-item__icon\" aria-hidden=\"true\" />\n <chevron-down-icon v-else class=\"b-secondary-nav-item__icon\" aria-hidden=\"true\" />\n </template>\n </bento-button>\n </div>\n <Transition :name=\"CONTENT_TRANSITION_NAME\">\n <div v-if=\"hasSubItems && isOpen\" :id=\"subItemsId\" :style=\"subItemsMaxHeight\">\n <ul ref=\"subItemsRef\" class=\"b-secondary-nav-item__sub-items\">\n <li v-for=\"item in items\" :key=\"item.value\">\n <secondary-nav-item\n :label=\"item.label\"\n :value=\"item.value\"\n :items=\"item.items\"\n :error-counter=\"item.errorCounter\"\n is-sub-item\n />\n </li>\n </ul>\n </div>\n </Transition>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\n import { SECONDARY_NAV_STATE } from '../../secondary-nav.keys';\n import { BentoButton } from '@/components/button';\n import { BentoTag } from '@/components/tag';\n import { BentoTypography } from '@/components/typography';\n import ChevronDownIcon from '@adyen/ui-assets-icons-16/vue/chevron-down';\n import ChevronUpIcon from '@adyen/ui-assets-icons-16/vue/chevron-up';\n import CrossCircleFillIcon from '@adyen/ui-assets-icons-16/vue/cross-circle-fill';\n import { computed, inject, ref, watch } from 'vue';\n import { useI18n } from '@/utils/ts/i18n';\n import { generateUid } from '@/utils/ts/generate-uid';\n import { type BentoSecondaryNavItemsItem } from '../../secondary-nav.types';\n import { useExpandableContentHeight } from '@/composables/use-expandable-content-height/use-expandable-content-height';\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n const { tc } = useI18n<{ message: MessageSchema }>({ messages });\n const { activeItemValue, updateActiveItemValue, allowExpandableItemNavigation } = inject(SECONDARY_NAV_STATE);\n const CONTENT_TRANSITION_NAME = 'b-secondary-nav-item__animation--content';\n\n const props = defineProps({\n label: null,\n value: null,\n items: null,\n isSubItem: { type: Boolean },\n errorCounter: null\n});\n\n const isOpen = ref(false);\n const subItemsId = generateUid('secondary-nav-sub-items');\n const subItemsRef = ref<HTMLUListElement>(null);\n const hasSubItems = computed(() => !!props.items?.length);\n const isItemSelected = computed(() => activeItemValue.value === props.value);\n const expandleItemIsToggleOnly = computed(() => hasSubItems.value && !allowExpandableItemNavigation.value);\n const { contentHeight } = useExpandableContentHeight(subItemsRef, isOpen);\n const subItemsMaxHeight = computed(() => (contentHeight.value ? { 'max-height': contentHeight.value } : {}));\n\n const conditionalClasses = computed(() => ({\n 'b-secondary-nav-item__option--active': isItemSelected.value,\n 'b-secondary-nav-item__option--expandable': hasSubItems.value,\n 'b-secondary-nav-item__option--sub-item': props.isSubItem,\n }));\n\n const emit = defineEmits([\"click\"]);\n\n const onClick = (e: MouseEvent) => {\n emit('click', e);\n updateActiveItemValue(props.value);\n };\n\n const onToggleClick = () => {\n isOpen.value = !isOpen.value;\n };\n\n const hasActiveDescendant = (items: Array<BentoSecondaryNavItemsItem>, value: string): boolean => {\n return items.some(\n item => item.value === value || (item.items ? hasActiveDescendant(item.items, value) : false)\n );\n };\n\n const hasDescendantErrors = (items: Array<BentoSecondaryNavItemsItem>): boolean =>\n items.some(item => !!item.errorCounter || (item.items ? hasDescendantErrors(item.items) : false));\n\n watch(\n [activeItemValue, () => props.items],\n ([activeValue]) => {\n if (hasSubItems.value && props.items) {\n if (hasActiveDescendant(props.items, activeValue) || hasDescendantErrors(props.items)) {\n isOpen.value = true;\n }\n }\n },\n { immediate: true, deep: true }\n );\n</script>\n\n<script lang=\"ts\">\n /**\n * This component shouldn't be used directly. It is internally used by {@see BentoSecondaryNav}\n */\n export default { i18n: { messages } };\n</script>\n\n<style lang=\"scss\" scoped src=\"./secondary-nav-item.scss\" />\n","<template>\n <section class=\"b-secondary-nav-category\" :aria-label=\"label\">\n <bento-typography el=\"h1\" class=\"b-secondary-nav-category__label\" variant=\"caption\" stronger>{{\n label\n }}</bento-typography>\n <ul class=\"b-secondary-nav__list\">\n <li v-for=\"item in items\" :key=\"item.value\">\n <secondary-nav-item\n :label=\"item.label\"\n :value=\"item.value\"\n :items=\"item.items\"\n :error-counter=\"item.errorCounter\"\n />\n </li>\n </ul>\n </section>\n</template>\n\n<script lang=\"ts\" setup>\n import { BentoTypography } from '@/components/typography';\n import { SecondaryNavItem } from '../secondary-nav-item';\n import { type BentoSecondaryNavItemsItem } from '../../secondary-nav.types';\n\n defineProps({\n label: null,\n items: null\n});\n</script>\n\n<script lang=\"ts\">\n /**\n * This component shouldn't be used directly. It is internally used by {@see BentoSecondaryNav}\n */\n export default {};\n</script>\n\n<style lang=\"scss\" scoped src=\"./secondary-nav-category.scss\" />\n","<template>\n <nav class=\"b-secondary-nav\">\n <bento-dropdown\n v-if=\"isMobile\"\n :aria-label=\"t('mobileDropdownAriaLabel')\"\n :items=\"mobileDropdownItems\"\n :static-categories=\"hasCategories\"\n :model-value=\"activeItemValue\"\n :is-option-disabled=\"isMobileOptionDisabled\"\n @update:model-value=\"updateActiveItemValue\"\n >\n <template #display-value=\"{ label }\">\n <bento-typography el=\"span\">\n {{ label }}\n </bento-typography>\n </template>\n <template #default=\"{ label, data }\">\n <bento-typography\n el=\"div\"\n :class=\"{ 'b-secondary-nav__option': true, 'b-secondary-nav__nested-option': !!data?.level }\"\n >\n {{ label }}\n <bento-tag\n v-if=\"data?.errorCounter\"\n class=\"b-secondary-nav__error-counter\"\n variant=\"red\"\n :label=\"data.errorCounter\"\n :aria-label=\"tc('errorCount', data.errorCounter)\"\n >\n <template #icon>\n <cross-circle-fill-icon aria-hidden=\"true\" />\n </template>\n </bento-tag>\n </bento-typography>\n </template>\n </bento-dropdown>\n <ul v-else class=\"b-secondary-nav__list\">\n <li v-for=\"item in items\" :key=\"item.label\">\n <secondary-nav-category\n v-if=\"'items' in item && !('value' in item)\"\n :label=\"item.label\"\n :items=\"item.items\"\n />\n <secondary-nav-item\n v-else\n :label=\"item.label\"\n :value=\"item.value\"\n :items=\"item.items\"\n :error-counter=\"item.errorCounter\"\n />\n </li>\n </ul>\n </nav>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, provide, readonly, ref, toRef, watch } from 'vue';\n import { SecondaryNavItem } from './components/secondary-nav-item';\n import { SecondaryNavCategory } from './components/secondary-nav-category';\n import { SECONDARY_NAV_STATE } from './secondary-nav.keys';\n import {\n type BentoSecondaryNavItems,\n type BentoSecondaryNavItemsCategory,\n type BentoSecondaryNavItemsItem,\n type BentoSecondaryNavState,\n } from './secondary-nav.types';\n import { BentoDropdown } from '@/components/dropdown';\n import { BentoTypography } from '@/components/typography';\n import { BentoTag } from '@/components/tag';\n import CrossCircleFillIcon from '@adyen/ui-assets-icons-16/vue/cross-circle-fill';\n import { useBreakpoints } from '@vueuse/core';\n import { useI18n } from '@/utils/ts/i18n';\n import { type BentoListboxOptionItem, type BentoListboxOptions } from '@/types/listbox';\n import { BMediaQuerySMax } from '@adyen/bento-design-tokens/dist/js/bento/es6';\n\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n const { t, tc } = useI18n<{ message: MessageSchema }>({ messages });\n\n const breakpoints = useBreakpoints({\n s: BMediaQuerySMax,\n });\n\n const isMobile = breakpoints.smallerOrEqual('s');\n const props = defineProps({\n items: null,\n value: null,\n allowExpandableItemNavigation: { type: Boolean }\n});\n\n const emit = defineEmits([\"change\"]);\n\n const isCategory = (item: BentoSecondaryNavItems[number]): item is BentoSecondaryNavItemsCategory =>\n 'items' in item && !('value' in item);\n\n const mapNestedItems = (items: Array<BentoSecondaryNavItemsItem>, level = 0): BentoListboxOptions =>\n items.flatMap((item): BentoListboxOptions => {\n const currentItem: BentoListboxOptionItem = {\n label: item.label,\n value: item.value,\n data: { level, hasSubItems: !!item.items?.length, errorCounter: item.errorCounter },\n };\n\n if (item.items?.length) {\n return [currentItem, ...mapNestedItems(item.items, level + 1)];\n }\n\n return [currentItem];\n });\n\n const isMobileOptionDisabled = (option: BentoListboxOptionItem): boolean =>\n !props.allowExpandableItemNavigation && (option.data as { hasSubItems?: boolean })?.hasSubItems;\n\n const hasCategories = computed(() => props.items.some(item => isCategory(item)));\n const mobileDropdownItems = computed<BentoListboxOptions>(() => {\n return props.items.flatMap(item => {\n if (isCategory(item)) {\n return [\n {\n label: item.label,\n value: `category-${item.label}`,\n items: mapNestedItems(item.items),\n } satisfies BentoListboxOptionItem,\n ];\n }\n\n if (item.items?.length) {\n return mapNestedItems([item]);\n }\n\n return [\n {\n label: item.label,\n value: item.value,\n data: { level: 0, errorCounter: item.errorCounter },\n } satisfies BentoListboxOptionItem,\n ];\n });\n });\n\n const flattenNestedItems = (items: Array<BentoSecondaryNavItemsItem>): Array<BentoSecondaryNavItemsItem> =>\n items.flatMap(item => [item, ...(item.items?.length ? flattenNestedItems(item.items) : [])]);\n\n const findFirstSelectableNestedItemValue = (items: Array<BentoSecondaryNavItemsItem>): string =>\n flattenNestedItems(items).find(item => props.allowExpandableItemNavigation || !item.items?.length)?.value ?? '';\n\n const activeItemValueFallback = computed(() => {\n if (!props.items.length) {\n return '';\n }\n\n return findFirstSelectableNestedItemValue(\n props.items.flatMap(item =>\n isCategory(item) ? flattenNestedItems(item.items) : flattenNestedItems([item])\n )\n );\n });\n\n const activeItemValue = ref(props.value ?? activeItemValueFallback.value);\n const updateActiveItemValue = (value: string) => {\n activeItemValue.value = value;\n emit('change', value);\n };\n\n // The component's state is inject on `secondary-nav-item` to determine the\n // current active item and to change its value\n const state: BentoSecondaryNavState = {\n activeItemValue: readonly(activeItemValue),\n updateActiveItemValue,\n allowExpandableItemNavigation: toRef(props, 'allowExpandableItemNavigation'),\n };\n\n watch(\n () => props.value,\n value => {\n if (value !== undefined) {\n activeItemValue.value = value;\n }\n }\n );\n\n provide(SECONDARY_NAV_STATE, state);\n</script>\n\n<script lang=\"ts\">\n /**\n * Secondary Nav offers users a structured way to access information.\n * It also provides a clear hierarchy for users to understand and navigate through various information.\n *\n * @example\n * import { BentoSecondaryNav } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoSecondaryNav },\n * template: `\n * <bento-secondary-nav :value=\"value\" :items=\"items\" />\n * `,\n * setup() {\n * const value = ref(2) // Active item value\n * const items: BentoSecondaryNavItemInfo[] = [\n * { label: 'Option 1', value: 1 },\n * { label: 'Option 2', value: 2 },\n * ];\n * return { items, value };\n * }\n * }\n */\n export default {\n i18n: { messages },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./secondary-nav.scss\" />\n"],"names":["SECONDARY_NAV_STATE","__default__$2","messages$1","tc","useI18n","activeItemValue","updateActiveItemValue","allowExpandableItemNavigation","inject","CONTENT_TRANSITION_NAME","isOpen","ref","subItemsId","generateUid","subItemsRef","hasSubItems","computed","props","isItemSelected","expandleItemIsToggleOnly","contentHeight","useExpandableContentHeight","subItemsMaxHeight","conditionalClasses","onClick","e","emit","onToggleClick","hasActiveDescendant","items","value","item","hasDescendantErrors","watch","activeValue","__default__$1","__default__","messages","t","breakpoints","useBreakpoints","BMediaQuerySMax","isMobile","isCategory","mapNestedItems","level","currentItem","isMobileOptionDisabled","option","hasCategories","mobileDropdownItems","flattenNestedItems","findFirstSelectableNestedItemValue","activeItemValueFallback","state","readonly","toRef","provide"],"mappings":";;;;;;;;;;;;;;;AAGO,MAAAA,IAAA,uBAAA,qBAAA;;;;;;;;;;;;GC2IHC,IAAA,EAAA,MAAA,EAAA,UAAAC,EAAA,EAAA;;;;;;;;;;;;iBAhEA,EAAA,IAAAC,EAAA,IAAAC,EAAA,GACA,EAAA,iBAAAC,GAAA,uBAAAC,GAAA,+BAAAC,EAAA,IAAAC,EAAAR,CAAA,GACAS,IAAA,4CAUAC,IAAAC,EAAA,EAAA,GACAC,IAAAC,EAAA,yBAAA,GACAC,IAAAH,EAAA,IAAA,GACAI,IAAAC,EAAA,MAAA,CAAA,CAAAC,EAAA,OAAA,MAAA,GACAC,IAAAF,EAAA,MAAAX,EAAA,UAAAY,EAAA,KAAA,GACAE,IAAAH,EAAA,MAAAD,EAAA,SAAA,CAAAR,EAAA,KAAA,GACA,EAAA,eAAAa,EAAA,IAAAC,EAAAP,GAAAJ,CAAA,GACAY,IAAAN,EAAA,MAAAI,EAAA,QAAA,EAAA,cAAAA,EAAA,MAAA,IAAA,CAAA,CAAA,GAEAG,IAAAP,EAAA,OAAA;AAAA,MAA2C,wCAAAE,EAAA;AAAA,MACgB,4CAAAH,EAAA;AAAA,MACC,0CAAAE,EAAA;AAAA,IACR,EA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AAA,CAAA;AAAA,MACqE;AAAA,IACjF,IANA,EAOJ,GAGJ1B,IAAAM,EAAAM,EAAA,SAAAoC,EAAA,KAAA,GACA/C,IAAA,CAAAwB,MAAA;AACI,MAAAzB,EAAA,QAAAyB,GACAJ,EAAA,UAAAI,CAAA;AAAA,IAAoB,GAKxBwB,IAAA;AAAA,MAAsC,iBAAAC,EAAAlD,CAAA;AAAA,MACO,uBAAAC;AAAA,MACzC,+BAAAkD,EAAAvC,GAAA,+BAAA;AAAA,IAC2E;AAG/E,WAAAgB;AAAA,MAAA,MAAAhB,EAAA;AAAA,MACgB,CAAAa,MAAA;AAER,QAAAA,MAAA,WACIzB,EAAA,QAAAyB;AAAA,MACJ;AAAA,IACJ,GAGJ2B,EAAAzD,GAAAsD,CAAA;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -2,11 +2,11 @@ import { defineComponent as $, useSlots as L, computed as l, inject as G, ref as
|
|
|
2
2
|
import { h as N } from "./index.CL3TXc0a.js";
|
|
3
3
|
import { a as q, B as z } from "./es6.yPcTMnSH.js";
|
|
4
4
|
import { B as F } from "./typography.D1OZJbEa.js";
|
|
5
|
-
import {
|
|
5
|
+
import { C as j } from "./checkbox-input.CIoy_QxO.js";
|
|
6
|
+
import { u as W } from "./aria-label.CaUURpnB.js";
|
|
6
7
|
import { g as M } from "./generate-uid.DBWe4g6T.js";
|
|
7
|
-
import { u as
|
|
8
|
-
import { a as
|
|
9
|
-
import { C as Q } from "./checkbox-input.CIoy_QxO.js";
|
|
8
|
+
import { u as Y } from "./use-has-slot.C9lQZ6nz.js";
|
|
9
|
+
import { a as Q } from "./radio-input.CLlYadKI.js";
|
|
10
10
|
import { n as T } from "./_plugin-vue2_normalizer.CeySl7Fu.js";
|
|
11
11
|
import { u as U } from "./form-field.B60VsF8d.js";
|
|
12
12
|
import { G as H } from "./grid-layout.BeCrjPgT.js";
|
|
@@ -79,7 +79,7 @@ const P = /* @__PURE__ */ Symbol("selection card radio input injection key"), X
|
|
|
79
79
|
},
|
|
80
80
|
emits: ["input", "update:model-value"],
|
|
81
81
|
setup(i, { emit: e }) {
|
|
82
|
-
const t = i, o = L(), a =
|
|
82
|
+
const t = i, o = L(), a = Y(o), h = M("selection-card-input-id"), r = M("selection-card-description"), d = l(
|
|
83
83
|
() => t.modelValue
|
|
84
84
|
), w = l(
|
|
85
85
|
() => t.modelValue
|
|
@@ -97,7 +97,7 @@ const P = /* @__PURE__ */ Symbol("selection card radio input injection key"), X
|
|
|
97
97
|
"b-selection-card__checkbox-container-text--center-aligned": m.value
|
|
98
98
|
})), k = l(() => ({
|
|
99
99
|
"b-selection-card__slot--with-icon": a("icon")
|
|
100
|
-
})), R =
|
|
100
|
+
})), R = W({
|
|
101
101
|
ariaLabel: t.title,
|
|
102
102
|
label: t.value
|
|
103
103
|
}), c = l(() => Array.isArray(t.modelValue)), x = l(() => u.value ? t.value === t.modelValue : c.value ? t.modelValue.some((s) => s === t.value) : t.modelValue), u = G(P, v(!1)), m = l(() => !t.subtitle && !t.description), p = v(null), _ = v(null), n = v(null), y = (s) => {
|
|
@@ -120,7 +120,7 @@ const P = /* @__PURE__ */ Symbol("selection card radio input injection key"), X
|
|
|
120
120
|
}, V = (s) => {
|
|
121
121
|
!t.disabled && !t.readonly && (e("update:model-value", s), e("input", s));
|
|
122
122
|
};
|
|
123
|
-
return { __sfc: !0, props: t, emit: e, slots: o, hasSlot: a, inputId: h, descriptionId: r, computedRadioInputModelValue: d, computedCheckboxInputModelValue: w, conditionalClasses: B, containerConditionalClasses: g, checkboxContainerConditionalClasses: f, checkboxContainerTextConditionalClasses: C, slotConditionalClasses: k, ariaLabel: R, isCheckboxGroup: c, isChecked: x, isRadioInput: u, isTitleOnly: m, inputRef: p, slotRef: _, dynamicSlotRef: n, handleCardClick: y, toggleInput: E, onChange: V, BentoTypography: F, CheckboxInput:
|
|
123
|
+
return { __sfc: !0, props: t, emit: e, slots: o, hasSlot: a, inputId: h, descriptionId: r, computedRadioInputModelValue: d, computedCheckboxInputModelValue: w, conditionalClasses: B, containerConditionalClasses: g, checkboxContainerConditionalClasses: f, checkboxContainerTextConditionalClasses: C, slotConditionalClasses: k, ariaLabel: R, isCheckboxGroup: c, isChecked: x, isRadioInput: u, isTitleOnly: m, inputRef: p, slotRef: _, dynamicSlotRef: n, handleCardClick: y, toggleInput: E, onChange: V, BentoTypography: F, CheckboxInput: j, RadioInput: Q };
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
126
|
var ee = function() {
|
|
@@ -232,4 +232,4 @@ export {
|
|
|
232
232
|
S as a,
|
|
233
233
|
Re as s
|
|
234
234
|
};
|
|
235
|
-
//# sourceMappingURL=selection-card-group.
|
|
235
|
+
//# sourceMappingURL=selection-card-group.CmDuj1c7.js.map
|
package/dist/chunks/{selection-card-group.DjFWMqVZ.js.map → selection-card-group.CmDuj1c7.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selection-card-group.DjFWMqVZ.js","sources":["../../src/components/selection-card/selection-card.types.ts","../../src/components/selection-card/selection-card.keys.ts","../../src/components/selection-card/selection-card.vue","../../src/components/selection-card/components/selection-card-group/selection-card-group.vue"],"sourcesContent":["import { type RadioInputValue } from '@/components/internal/radio-input';\nimport { type BentoCheckboxType } from '@/types/checkbox';\nimport { type VueNodeElement } from '@/types/elements';\n\nexport enum BentoSelectionCardState {\n DISABLED = 'disabled',\n READONLY = 'readonly',\n ERROR = 'error',\n}\n\nexport type BentoSelectionCardValue = string | number;\n\nexport type BentoSelectionCardModelValue = BentoCheckboxType | RadioInputValue;\n\nexport interface BentoSelectionCardItem {\n content?: string | object;\n description?: string;\n disabled?: boolean;\n dynamicContent?: string | object;\n fullyClickable?: boolean;\n hasError?: boolean;\n icon?: VueNodeElement;\n readonly?: boolean;\n subtitle?: string;\n title: string;\n value: BentoSelectionCardValue;\n}\n","export const SELECTION_CARD_RADIO_INPUT_INJECTION_KEY = Symbol('selection card radio input injection key');\n","<template>\n <div class=\"b-selection-card\" :class=\"conditionalClasses\" @click=\"handleCardClick\">\n <div class=\"b-selection-card__container\" :class=\"containerConditionalClasses\">\n <div class=\"b-selection-card__checkbox-container\" :class=\"checkboxContainerConditionalClasses\">\n <div class=\"b-selection-card__checkbox-container-text\" :class=\"checkboxContainerTextConditionalClasses\">\n <div v-if=\"hasSlot('icon')\" class=\"b-selection-card__icon\" role=\"presentation\" aria-hidden=\"true\">\n <slot name=\"icon\" />\n </div>\n <label :for=\"inputId\" class=\"b-selection-card__text\" @click.stop.prevent=\"handleCardClick\">\n <bento-typography\n v-if=\"subtitle\"\n class=\"b-selection-card__description\"\n el=\"span\"\n variant=\"caption\"\n >\n {{ subtitle }}\n </bento-typography>\n <bento-typography el=\"span\" variant=\"title\">{{ title }}</bento-typography>\n <bento-typography\n v-if=\"description\"\n id=\"descriptionId\"\n class=\"b-selection-card__description\"\n el=\"span\"\n variant=\"body\"\n >\n {{ description }}\n </bento-typography>\n </label>\n </div>\n <radio-input\n v-if=\"isRadioInput\"\n :id=\"inputId\"\n ref=\"inputRef\"\n :aria-label=\"ariaLabel\"\n :aria-describedby=\"description ? descriptionId : undefined\"\n :disabled=\"disabled\"\n :has-error=\"hasError\"\n :aria-readonly=\"readonly ?? undefined\"\n :value=\"value\"\n :readonly=\"readonly\"\n :model-value=\"computedRadioInputModelValue\"\n />\n <checkbox-input\n v-else\n :id=\"inputId\"\n ref=\"inputRef\"\n :aria-label=\"ariaLabel\"\n :aria-describedby=\"description ? descriptionId : undefined\"\n :disabled=\"disabled\"\n :has-error=\"hasError\"\n :aria-readonly=\"readonly ?? undefined\"\n :value=\"value\"\n :readonly=\"readonly\"\n :model-value=\"computedCheckboxInputModelValue\"\n />\n </div>\n <bento-typography\n v-if=\"hasSlot('content')\"\n ref=\"slotRef\"\n el=\"div\"\n class=\"b-selection-card__slot\"\n :class=\"slotConditionalClasses\"\n >\n <slot name=\"content\" />\n </bento-typography>\n <bento-typography\n v-if=\"hasSlot('dynamicContent') && isChecked\"\n ref=\"dynamicSlotRef\"\n el=\"div\"\n class=\"b-selection-card__slot\"\n :class=\"slotConditionalClasses\"\n >\n <slot name=\"dynamicContent\" />\n </bento-typography>\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import { BentoTypography } from '@/components/typography';\n import { CheckboxInput } from '../internal/checkbox-input';\n import { RadioInput, type RadioInputValue } from '../internal/radio-input';\n import { type BentoCheckboxType, type BentoMultiCheckboxType } from '@/types/checkbox';\n import { useAriaLabel } from '@/utils/ts/aria-label';\n import { generateUid } from '@/utils/ts/generate-uid';\n import { computed, type ComputedRef, inject, type PropType, type Ref, ref, useSlots } from 'vue';\n import { useHasSlot } from '@/composables';\n import type { BentoSelectionCardModelValue, BentoSelectionCardValue } from './selection-card.types';\n import { BentoSelectionCardState } from './selection-card.types';\n import { SELECTION_CARD_RADIO_INPUT_INJECTION_KEY } from './selection-card.keys';\n\n const props = defineProps({\n /**\n * The description of the selection card\n */\n description: {\n type: String,\n default: undefined,\n },\n\n /**\n * Disables the selection card\n */\n disabled: { type: Boolean, default: false },\n\n /**\n * Makes the entire selection card clickable. Clicking over interactive elements inside the card with this prop enabled will not be possible.\n */\n fullyClickable: { type: Boolean, default: false },\n\n /**\n * Shows the selection card in error state\n */\n hasError: { type: Boolean, default: false },\n\n /**\n * This property should not be used directly.\n * It will be used by v-model directive on selection card component.\n *\n * When handling a single input, use a string or a number.\n *\n * When handling multiple inputs, use an array of keys.\n * These keys exist as a set \"value\" prop for each input.\n */\n modelValue: {\n type: [Boolean, String, Array] as PropType<BentoSelectionCardModelValue>,\n default: null,\n },\n\n /**\n * Sets the selection card to readonly\n */\n readonly: { type: Boolean, default: false },\n\n /**\n * The subtitle of the selection card\n */\n subtitle: {\n type: String,\n default: undefined,\n },\n\n /**\n * The title of the selection card\n */\n title: {\n type: String,\n required: true,\n },\n\n /**\n * Indicates the value of the input that will be returned when it's checked.\n */\n value: {\n type: [String, Number] as PropType<BentoSelectionCardValue>,\n required: true,\n },\n });\n\n const emit = defineEmits([\"input\", \"update:model-value\"]);\n\n const slots = useSlots();\n const hasSlot = useHasSlot(slots);\n\n const inputId = generateUid('selection-card-input-id');\n const descriptionId = generateUid('selection-card-description');\n\n const computedRadioInputModelValue: ComputedRef<RadioInputValue> = computed(\n () => props.modelValue as RadioInputValue\n );\n const computedCheckboxInputModelValue: ComputedRef<BentoCheckboxType> = computed(\n () => props.modelValue as BentoCheckboxType\n );\n\n const conditionalClasses = computed(() => ({\n 'b-selection-card--checked': isChecked.value,\n 'b-selection-card--fully-clickable': props.fullyClickable,\n }));\n\n const containerConditionalClasses = computed(() => ({\n [`b-selection-card--${BentoSelectionCardState.DISABLED}`]: props.disabled,\n [`b-selection-card--${BentoSelectionCardState.ERROR}`]: props.hasError,\n [`b-selection-card--${BentoSelectionCardState.READONLY}`]: props.readonly,\n 'b-selection-card--center-aligned': isTitleOnly.value,\n }));\n\n const checkboxContainerConditionalClasses = computed(() => ({\n 'b-selection-card__checkbox-container--center-aligned': isTitleOnly.value,\n }));\n\n const checkboxContainerTextConditionalClasses = computed(() => ({\n 'b-selection-card__checkbox-container-text--center-aligned': isTitleOnly.value,\n }));\n\n const slotConditionalClasses = computed(() => ({\n 'b-selection-card__slot--with-icon': hasSlot('icon'),\n }));\n\n const ariaLabel = useAriaLabel({\n ariaLabel: props.title,\n label: props.value as string,\n });\n\n const isCheckboxGroup = computed(() => Array.isArray(props.modelValue));\n\n const isChecked: ComputedRef<boolean> = computed(() => {\n if (isRadioInput.value) {\n return props.value === props.modelValue;\n }\n if (!isCheckboxGroup.value) {\n return props.modelValue as boolean;\n }\n\n return (props.modelValue as BentoMultiCheckboxType).some(item => item === props.value);\n });\n\n const isRadioInput: Ref<boolean> = inject(SELECTION_CARD_RADIO_INPUT_INJECTION_KEY, ref(false));\n\n const isTitleOnly = computed(() => !props.subtitle && !props.description);\n\n const inputRef = ref<InstanceType<typeof RadioInput> | InstanceType<typeof CheckboxInput>>(null);\n const slotRef = ref(null);\n const dynamicSlotRef = ref(null);\n\n // Handle click on the whole card area\n const handleCardClick = (event: Event) => {\n if (inputRef.value.$refs.inputRef === event.target) {\n const newValue = toggleInput();\n onChange(newValue);\n return;\n }\n\n // Do nothing if disabled or readonly\n if (props.disabled && props.readonly) {\n return;\n }\n\n // If it's not fully clickable prevent selecting the card if the click\n // originated in a slot\n if (!props.fullyClickable) {\n // Check if the click originated from the slot - in that case, do nothng\n if (slotRef.value && slotRef.value?.$el?.contains(event.target)) {\n return;\n }\n // Check if the click originated from the dynamic slot - in that case, do nothng\n if (dynamicSlotRef.value && dynamicSlotRef.value?.$el?.contains(event.target)) {\n return;\n }\n // Check if the click originated from the input - in that case do nothing, as the input will emit the event already\n if (inputRef.value && inputRef.value?.$el?.contains(event.target as Node)) {\n return;\n }\n }\n\n // If the click originated outside of these two areas, emit the change event\n const newValue = toggleInput();\n\n onChange(newValue);\n };\n\n const toggleInput = (): BentoSelectionCardModelValue => {\n const currentValue: boolean = (inputRef.value?.$refs.inputRef as HTMLInputElement).checked;\n\n if (isCheckboxGroup.value) {\n const newCheckedList = [...(props.modelValue as BentoMultiCheckboxType)];\n const index = newCheckedList.indexOf(props.value);\n\n if (index === -1) {\n newCheckedList.push(props.value);\n } else {\n newCheckedList.splice(index, 1);\n }\n return newCheckedList;\n }\n\n if (isRadioInput.value) {\n return props.value;\n }\n return currentValue;\n };\n\n const onChange = newValue => {\n if (!props.disabled && !props.readonly) {\n emit('update:model-value', newValue);\n emit('input', newValue);\n }\n };\n</script>\n\n<script lang=\"ts\">\n /**\n * Selection card component. If used standalone, only the checkbox variant can be used. If the checkbox variant is needed, please use the bento-selection-card-group component.\n *\n * @example\n * import { BentoSelectionCard } from '@adyen/bento-vue2';\n * import EmoticonHappyIcon from '@adyen/ui-assets-icons-16/vue/emoticon-happy';\n *\n * export default {\n * components: { BentoSelectionCard, EmoticonHappyIcon },\n * template: `\n * <bento-selection-card title=\"Card title\" :model-value.sync=\"yourModelValue\">\n * <template #icon>\n * <emoticon-happy-icon />\n * </template>\n * </bento-selection-card>\n * `\n * }\n */\n export default {\n name: 'bento-selection-card',\n };\n</script>\n<style lang=\"scss\" scoped src=\"./selection-card.scss\" />\n","<template>\n <controls-group\n ref=\"containerRef\"\n :aria-describedby=\"shouldShowGroupError ? errorMessageId : null\"\n :aria-required=\"required\"\n :label=\"label\"\n :hide-label=\"hideLabel\"\n :description=\"description\"\n :disabled=\"disabled\"\n :tooltip-text=\"tooltipText\"\n :readonly=\"readonly\"\n :required=\"required\"\n :optional=\"optional\"\n class=\"b-selection-card-group\"\n component-name=\"selection-card-group\"\n >\n <div\n v-if=\"!itemsPerRow || layout === 'vertical'\"\n class=\"b-selection-card-group__items\"\n :class=\"conditionalItemsClasses\"\n >\n <bento-selection-card\n v-for=\"item in items\"\n :key=\"`selection-card-${item.value}`\"\n class=\"b-selection-card-group__item\"\n v-bind=\"item\"\n :model-value=\"inputValue\"\n :readonly=\"readonly || item.readonly\"\n :has-error=\"shouldShowGroupError\"\n :disabled=\"disabled || item.disabled\"\n @update:model-value=\"onInput\"\n >\n <template v-if=\"hasSlot('icon') && item.icon\" #icon>\n <slot name=\"icon\" v-bind=\"item\"></slot>\n </template>\n <template v-if=\"hasSlot('content') && item.content\" #content>\n <slot name=\"content\" v-bind=\"item\"></slot>\n </template>\n <template v-if=\"hasSlot('dynamicContent') && item.dynamicContent\" #dynamicContent>\n <slot name=\"dynamicContent\" v-bind=\"item\"></slot>\n </template>\n </bento-selection-card>\n </div>\n <template v-else>\n <div :key=\"`selection-card-group-layout-breakpoint-${currentBreakpoint}`\">\n <grid-layout\n v-for=\"(row, rowIndex) in computedRows\"\n :key=\"`selection-card-group-row-${rowIndex}-cols-${computedItemsPerRow}`\"\n class=\"b-selection-card-group__items--wrap\"\n :column-width=\"computedColumnWidth\"\n >\n <template v-for=\"(item, columnIndex) in row\" #[`col-${Number(columnIndex)+1}`]>\n <bento-selection-card\n :key=\"`selection-card-${item.value}`\"\n class=\"b-selection-card-group__item b-selection-card-group__item--full-height\"\n v-bind=\"item\"\n :model-value=\"inputValue\"\n :readonly=\"readonly || item.readonly\"\n :has-error=\"shouldShowGroupError\"\n :disabled=\"disabled || item.disabled\"\n @update:model-value=\"onInput\"\n >\n <template v-if=\"hasSlot('icon') && item.icon\" #icon>\n <slot name=\"icon\" v-bind=\"item\"></slot>\n </template>\n <template v-if=\"hasSlot('content') && item.content\" #content>\n <slot name=\"content\" v-bind=\"item\"></slot>\n </template>\n <template v-if=\"hasSlot('dynamicContent') && item.dynamicContent\" #dynamicContent>\n <slot name=\"dynamicContent\" v-bind=\"item\"></slot>\n </template>\n </bento-selection-card>\n </template>\n </grid-layout>\n </div>\n </template>\n <error-message\n v-if=\"shouldShowGroupError\"\n :id=\"errorMessageId\"\n :error-message=\"errorMessage\"\n class=\"b-selection-card-group__error-message\"\n />\n </controls-group>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, onMounted, provide, ref, useSlots, watch } from 'vue';\n import { useElementSize } from '@vueuse/core';\n import { BMediaQueryMMax, BMediaQuerySMax } from '@adyen/bento-design-tokens/dist/js/bento/es6';\n import { type BentoSelectionCardGroupEmits, type BentoSelectionCardGroupProps } from './selection-card-group.types';\n import BentoSelectionCard from '../../selection-card.vue';\n import { ControlsGroup, ErrorMessage, GridLayout } from '../../../internal';\n import { SELECTION_CARD_RADIO_INPUT_INJECTION_KEY } from '../../selection-card.keys';\n import { generateUid } from '@/utils/ts/generate-uid';\n import { useFormFieldEmits } from '@/utils/ts/form-field/form-field';\n\n const props = defineProps({\n description: { default: null },\n disabled: { type: Boolean, default: false },\n errorMessage: { default: null },\n label: { default: null },\n optional: { type: Boolean, default: false },\n placeholder: null,\n readonly: { type: Boolean, default: false },\n required: { type: Boolean, default: false },\n tooltipText: { default: null },\n formId: { default: null },\n hideLabel: { type: Boolean, default: null },\n layout: { default: 'vertical' },\n items: null,\n itemsPerRow: { default: undefined },\n modelValue: { default: null },\n variant: { default: 'checkbox' }\n});\n\n const emit = defineEmits([\"update:model-value\"]);\n\n const { emitValue } = useFormFieldEmits(emit);\n\n const slots = useSlots();\n // Slots logic\n // Temporary, use-has-slots composable doesn't currently work for vue3 named scoped slots\n // We do the same in bento-checkbox-group\n const hasSlot = name => !!slots[name];\n\n const conditionalItemsClasses = computed(() => ({\n 'b-selection-card-group__items--horizontal': props.layout === 'horizontal',\n }));\n\n const inputValue = ref(props.modelValue);\n watch(\n () => props.modelValue,\n () => {\n inputValue.value = props.modelValue;\n }\n );\n\n // Error message logic\n const errorMessageId = generateUid('error');\n const shouldShowGroupError = computed(() => !props.disabled && !props.readonly && !!props.errorMessage);\n\n // itemsPerRow logic\n const containerRef = ref<HTMLElement | null>(null);\n const { width } = useElementSize(containerRef);\n\n const smallBreakpoint = computed(() => BMediaQuerySMax.split('px')[0]);\n const mediumBreakpoint = computed(() => BMediaQueryMMax.split('px')[0]);\n\n const currentBreakpoint = computed(() => {\n if (width.value < smallBreakpoint.value) {\n return 'small';\n }\n if (width.value >= smallBreakpoint.value && width.value < mediumBreakpoint.value) {\n return 'medium';\n }\n return 'large';\n });\n\n const computedItemsPerRow = computed(() => {\n return (props.itemsPerRow?.[currentBreakpoint?.value] as number) || props.items.length;\n });\n\n const computedRows = computed(() => {\n if (!props.itemsPerRow) {\n return [];\n }\n const rows = [];\n for (let i = 0; i < props.items.length; i += computedItemsPerRow?.value) {\n rows.push(props.items.slice(i, i + computedItemsPerRow?.value));\n }\n return rows;\n });\n\n // We need to compute the column width on 12 because we're using a 12-column system for out grid-layout logic\n const itemColumnWidth = computed(() => 12 / computedItemsPerRow?.value);\n\n /**\n * Filling the columnWidth array with the same parameters per item to pass\n * to the `grid-layout` layout so the each card can have\n * the same width according to the screen size.\n */\n const computedColumnWidth = computed(() => {\n return computedItemsPerRow?.value\n ? new Array(computedItemsPerRow?.value).fill({\n // Instead of passing the actual screen sizes values, passing the same values per each screen size and recomputing it makes sure visually the change is smoother and not laggy\n small: itemColumnWidth.value,\n medium: itemColumnWidth.value,\n large: itemColumnWidth.value,\n })\n : [];\n });\n\n const onInput = value => {\n inputValue.value = value;\n emitValue(value);\n };\n\n const isRadioVariant = computed(() => props.variant === 'radio');\n\n provide(SELECTION_CARD_RADIO_INPUT_INJECTION_KEY, isRadioVariant);\n\n onMounted(() => {\n if (props.itemsPerRow) {\n Object.values(props.itemsPerRow).forEach(el => {\n if (el && (el < 2 || el > 6)) {\n throw new Error(\n 'itemsPerRow values must have a value between 2 and 6 items per row. Read the documentation for more information.'\n );\n }\n });\n }\n });\n</script>\n\n<script lang=\"ts\">\n /**\n * Group of bento-selection-cards.\n *\n * @example\n * import { BentoSelectionCardGroup } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoSelectionCardGroup },\n * template: `\n * <bento-selection-card-group\n * :items=\"[\n * {\n * title: 'Card 1',\n * value: 'card-1',\n * content: 'Slot content 1',\n * icon: RetailIcon,\n * },\n * {\n * title: 'Card 2',\n * value: 'card-2',\n * content: 'Slot content 2',\n * icon: LeafIcon,\n * },\n * ]\"\n * >\n * <template #icon=\"{ icon }\">\n * <component :is=\"icon\"/>\n * </template>\n * <template #content=\"{ content }\">\n * <div>{{ content }}</div>\n * </template>\n * </bento-selection-card-group>\n * `,\n * }\n */\n export default {\n model: { prop: 'modelValue', event: 'update:model-value' },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./selection-card-group.scss\" />\n"],"names":["BentoSelectionCardState","BentoSelectionCardState2","SELECTION_CARD_RADIO_INPUT_INJECTION_KEY","__default__$1","slots","useSlots","hasSlot","useHasSlot","inputId","generateUid","descriptionId","computedRadioInputModelValue","computed","props","computedCheckboxInputModelValue","conditionalClasses","isChecked","containerConditionalClasses","isTitleOnly","checkboxContainerConditionalClasses","checkboxContainerTextConditionalClasses","slotConditionalClasses","ariaLabel","useAriaLabel","isCheckboxGroup","isRadioInput","item","inject","ref","inputRef","slotRef","dynamicSlotRef","handleCardClick","event","newValue2","toggleInput","onChange","newValue","currentValue","newCheckedList","index","emit","__default__","emitValue","useFormFieldEmits","name","conditionalItemsClasses","inputValue","watch","errorMessageId","shouldShowGroupError","containerRef","width","useElementSize","smallBreakpoint","BMediaQuerySMax","mediumBreakpoint","BMediaQueryMMax","currentBreakpoint","computedItemsPerRow","computedRows","rows","i","itemColumnWidth","computedColumnWidth","onInput","value","isRadioVariant","provide","onMounted","el"],"mappings":";;;;;;;;;;;;;;;AAIO,IAAAA,IAAA,kBAAAC,OACHA,EAAA,WAAA,YACAA,EAAA,WAAA,YACAA,EAAA,QAAA,SAHQA,IAAAD,KAAA,CAAA,CAAA;ACJL,MAAAE,IAAA,uBAAA,0CAAA,GCoTHC,IAAA;AAAA,EAAe,MAAA;AAEf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBArJAC,IAAAC,EAAA,GACAC,IAAAC,EAAAH,CAAA,GAEAI,IAAAC,EAAA,yBAAA,GACAC,IAAAD,EAAA,4BAAA,GAEAE,IAAAC;AAAA,MAAmE,MAAAC,EAAA;AAAA,IACnD,GAEhBC,IAAAF;AAAA,MAAwE,MAAAC,EAAA;AAAA,IACxD,GAGhBE,IAAAH,EAAA,OAAA;AAAA,MAA2C,6BAAAI,EAAA;AAAA,MACA,qCAAAH,EAAA;AAAA,IACI,EAAA,GAG/CI,IAAAL,EAAA,OAAA;AAAA,MAAoD,CAAA,qBAAAZ,EAAA,QAAA,EAAA,GAAAa,EAAA;AAAA,MACiB,CAAA,qBAAAb,EAAA,KAAA,EAAA,GAAAa,EAAA;AAAA,MACH,CAAA,qBAAAb,EAAA,QAAA,EAAA,GAAAa,EAAA;AAAA,MACG,oCAAAK,EAAA;AAAA,IACjB,EAAA,GAGpDC,IAAAP,EAAA,OAAA;AAAA,MAA4D,wDAAAM,EAAA;AAAA,IACY,EAAA,GAGxEE,IAAAR,EAAA,OAAA;AAAA,MAAgE,6DAAAM,EAAA;AAAA,IACa,EAAA,GAG7EG,IAAAT,EAAA,OAAA;AAAA,MAA+C,qCAAAN,EAAA,MAAA;AAAA,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MAAA;AACI,UAAA,CAAAC,EAAA;AACI,eAAA,CAAA;AAEJ,YAAAgD,IAAA,CAAA;AACA,eAAAC,IAAA,GAAAA,IAAAjD,EAAA,MAAA,QAAAiD,KAAAH,GAAA;AACI,QAAAE,EAAA,KAAAhD,EAAA,MAAA,MAAAiD,GAAAA,IAAAH,GAAA,KAAA,CAAA;AAEJ,aAAAE;AAAA,IAAO,CAAA,GAIXE,IAAAnD,EAAA,MAAA,KAAA+C,GAAA,KAAA,GAOAK,IAAApD,EAAA,MACI+C,GAAA,QAAA,IAAA,MAAAA,GAAA,KAAA,EAAA,KAAA;AAAA;AAAA,MACiD,OAAAI,EAAA;AAAA,MAEhB,QAAAA,EAAA;AAAA,MACC,OAAAA,EAAA;AAAA,IACD,CAAA,IAAA,CAAA,CAE1B,GAGXE,IAAA,CAAAC,MAAA;AACI,MAAAnB,EAAA,QAAAmB,GACAvB,EAAAuB,CAAA;AAAA,IAAe,GAGnBC,IAAAvD,EAAA,MAAAC,EAAA,YAAA,OAAA;AAEA,WAAAuD,EAAAlE,GAAAiE,CAAA,GAEAE,EAAA,MAAA;AACI,MAAAxD,EAAA,eACI,OAAA,OAAAA,EAAA,WAAA,EAAA,QAAA,CAAAyD,MAAA;AACI,YAAAA,MAAAA,IAAA,KAAAA,IAAA;AACI,gBAAA,IAAA;AAAA,YAAU;AAAA,UACN;AAAA,MAER,CAAA;AAAA,IAER,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"selection-card-group.CmDuj1c7.js","sources":["../../src/components/selection-card/selection-card.types.ts","../../src/components/selection-card/selection-card.keys.ts","../../src/components/selection-card/selection-card.vue","../../src/components/selection-card/components/selection-card-group/selection-card-group.vue"],"sourcesContent":["import { type RadioInputValue } from '@/components/internal/radio-input';\nimport { type BentoCheckboxType } from '@/types/checkbox';\nimport { type VueNodeElement } from '@/types/elements';\n\nexport enum BentoSelectionCardState {\n DISABLED = 'disabled',\n READONLY = 'readonly',\n ERROR = 'error',\n}\n\nexport type BentoSelectionCardValue = string | number;\n\nexport type BentoSelectionCardModelValue = BentoCheckboxType | RadioInputValue;\n\nexport interface BentoSelectionCardItem {\n content?: string | object;\n description?: string;\n disabled?: boolean;\n dynamicContent?: string | object;\n fullyClickable?: boolean;\n hasError?: boolean;\n icon?: VueNodeElement;\n readonly?: boolean;\n subtitle?: string;\n title: string;\n value: BentoSelectionCardValue;\n}\n","export const SELECTION_CARD_RADIO_INPUT_INJECTION_KEY = Symbol('selection card radio input injection key');\n","<template>\n <div class=\"b-selection-card\" :class=\"conditionalClasses\" @click=\"handleCardClick\">\n <div class=\"b-selection-card__container\" :class=\"containerConditionalClasses\">\n <div class=\"b-selection-card__checkbox-container\" :class=\"checkboxContainerConditionalClasses\">\n <div class=\"b-selection-card__checkbox-container-text\" :class=\"checkboxContainerTextConditionalClasses\">\n <div v-if=\"hasSlot('icon')\" class=\"b-selection-card__icon\" role=\"presentation\" aria-hidden=\"true\">\n <slot name=\"icon\" />\n </div>\n <label :for=\"inputId\" class=\"b-selection-card__text\" @click.stop.prevent=\"handleCardClick\">\n <bento-typography\n v-if=\"subtitle\"\n class=\"b-selection-card__description\"\n el=\"span\"\n variant=\"caption\"\n >\n {{ subtitle }}\n </bento-typography>\n <bento-typography el=\"span\" variant=\"title\">{{ title }}</bento-typography>\n <bento-typography\n v-if=\"description\"\n id=\"descriptionId\"\n class=\"b-selection-card__description\"\n el=\"span\"\n variant=\"body\"\n >\n {{ description }}\n </bento-typography>\n </label>\n </div>\n <radio-input\n v-if=\"isRadioInput\"\n :id=\"inputId\"\n ref=\"inputRef\"\n :aria-label=\"ariaLabel\"\n :aria-describedby=\"description ? descriptionId : undefined\"\n :disabled=\"disabled\"\n :has-error=\"hasError\"\n :aria-readonly=\"readonly ?? undefined\"\n :value=\"value\"\n :readonly=\"readonly\"\n :model-value=\"computedRadioInputModelValue\"\n />\n <checkbox-input\n v-else\n :id=\"inputId\"\n ref=\"inputRef\"\n :aria-label=\"ariaLabel\"\n :aria-describedby=\"description ? descriptionId : undefined\"\n :disabled=\"disabled\"\n :has-error=\"hasError\"\n :aria-readonly=\"readonly ?? undefined\"\n :value=\"value\"\n :readonly=\"readonly\"\n :model-value=\"computedCheckboxInputModelValue\"\n />\n </div>\n <bento-typography\n v-if=\"hasSlot('content')\"\n ref=\"slotRef\"\n el=\"div\"\n class=\"b-selection-card__slot\"\n :class=\"slotConditionalClasses\"\n >\n <slot name=\"content\" />\n </bento-typography>\n <bento-typography\n v-if=\"hasSlot('dynamicContent') && isChecked\"\n ref=\"dynamicSlotRef\"\n el=\"div\"\n class=\"b-selection-card__slot\"\n :class=\"slotConditionalClasses\"\n >\n <slot name=\"dynamicContent\" />\n </bento-typography>\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import { BentoTypography } from '@/components/typography';\n import { CheckboxInput } from '../internal/checkbox-input';\n import { RadioInput, type RadioInputValue } from '../internal/radio-input';\n import { type BentoCheckboxType, type BentoMultiCheckboxType } from '@/types/checkbox';\n import { useAriaLabel } from '@/utils/ts/aria-label';\n import { generateUid } from '@/utils/ts/generate-uid';\n import { computed, type ComputedRef, inject, type PropType, type Ref, ref, useSlots } from 'vue';\n import { useHasSlot } from '@/composables';\n import type { BentoSelectionCardModelValue, BentoSelectionCardValue } from './selection-card.types';\n import { BentoSelectionCardState } from './selection-card.types';\n import { SELECTION_CARD_RADIO_INPUT_INJECTION_KEY } from './selection-card.keys';\n\n const props = defineProps({\n /**\n * The description of the selection card\n */\n description: {\n type: String,\n default: undefined,\n },\n\n /**\n * Disables the selection card\n */\n disabled: { type: Boolean, default: false },\n\n /**\n * Makes the entire selection card clickable. Clicking over interactive elements inside the card with this prop enabled will not be possible.\n */\n fullyClickable: { type: Boolean, default: false },\n\n /**\n * Shows the selection card in error state\n */\n hasError: { type: Boolean, default: false },\n\n /**\n * This property should not be used directly.\n * It will be used by v-model directive on selection card component.\n *\n * When handling a single input, use a string or a number.\n *\n * When handling multiple inputs, use an array of keys.\n * These keys exist as a set \"value\" prop for each input.\n */\n modelValue: {\n type: [Boolean, String, Array] as PropType<BentoSelectionCardModelValue>,\n default: null,\n },\n\n /**\n * Sets the selection card to readonly\n */\n readonly: { type: Boolean, default: false },\n\n /**\n * The subtitle of the selection card\n */\n subtitle: {\n type: String,\n default: undefined,\n },\n\n /**\n * The title of the selection card\n */\n title: {\n type: String,\n required: true,\n },\n\n /**\n * Indicates the value of the input that will be returned when it's checked.\n */\n value: {\n type: [String, Number] as PropType<BentoSelectionCardValue>,\n required: true,\n },\n });\n\n const emit = defineEmits([\"input\", \"update:model-value\"]);\n\n const slots = useSlots();\n const hasSlot = useHasSlot(slots);\n\n const inputId = generateUid('selection-card-input-id');\n const descriptionId = generateUid('selection-card-description');\n\n const computedRadioInputModelValue: ComputedRef<RadioInputValue> = computed(\n () => props.modelValue as RadioInputValue\n );\n const computedCheckboxInputModelValue: ComputedRef<BentoCheckboxType> = computed(\n () => props.modelValue as BentoCheckboxType\n );\n\n const conditionalClasses = computed(() => ({\n 'b-selection-card--checked': isChecked.value,\n 'b-selection-card--fully-clickable': props.fullyClickable,\n }));\n\n const containerConditionalClasses = computed(() => ({\n [`b-selection-card--${BentoSelectionCardState.DISABLED}`]: props.disabled,\n [`b-selection-card--${BentoSelectionCardState.ERROR}`]: props.hasError,\n [`b-selection-card--${BentoSelectionCardState.READONLY}`]: props.readonly,\n 'b-selection-card--center-aligned': isTitleOnly.value,\n }));\n\n const checkboxContainerConditionalClasses = computed(() => ({\n 'b-selection-card__checkbox-container--center-aligned': isTitleOnly.value,\n }));\n\n const checkboxContainerTextConditionalClasses = computed(() => ({\n 'b-selection-card__checkbox-container-text--center-aligned': isTitleOnly.value,\n }));\n\n const slotConditionalClasses = computed(() => ({\n 'b-selection-card__slot--with-icon': hasSlot('icon'),\n }));\n\n const ariaLabel = useAriaLabel({\n ariaLabel: props.title,\n label: props.value as string,\n });\n\n const isCheckboxGroup = computed(() => Array.isArray(props.modelValue));\n\n const isChecked: ComputedRef<boolean> = computed(() => {\n if (isRadioInput.value) {\n return props.value === props.modelValue;\n }\n if (!isCheckboxGroup.value) {\n return props.modelValue as boolean;\n }\n\n return (props.modelValue as BentoMultiCheckboxType).some(item => item === props.value);\n });\n\n const isRadioInput: Ref<boolean> = inject(SELECTION_CARD_RADIO_INPUT_INJECTION_KEY, ref(false));\n\n const isTitleOnly = computed(() => !props.subtitle && !props.description);\n\n const inputRef = ref<InstanceType<typeof RadioInput> | InstanceType<typeof CheckboxInput>>(null);\n const slotRef = ref(null);\n const dynamicSlotRef = ref(null);\n\n // Handle click on the whole card area\n const handleCardClick = (event: Event) => {\n if (inputRef.value.$refs.inputRef === event.target) {\n const newValue = toggleInput();\n onChange(newValue);\n return;\n }\n\n // Do nothing if disabled or readonly\n if (props.disabled && props.readonly) {\n return;\n }\n\n // If it's not fully clickable prevent selecting the card if the click\n // originated in a slot\n if (!props.fullyClickable) {\n // Check if the click originated from the slot - in that case, do nothng\n if (slotRef.value && slotRef.value?.$el?.contains(event.target)) {\n return;\n }\n // Check if the click originated from the dynamic slot - in that case, do nothng\n if (dynamicSlotRef.value && dynamicSlotRef.value?.$el?.contains(event.target)) {\n return;\n }\n // Check if the click originated from the input - in that case do nothing, as the input will emit the event already\n if (inputRef.value && inputRef.value?.$el?.contains(event.target as Node)) {\n return;\n }\n }\n\n // If the click originated outside of these two areas, emit the change event\n const newValue = toggleInput();\n\n onChange(newValue);\n };\n\n const toggleInput = (): BentoSelectionCardModelValue => {\n const currentValue: boolean = (inputRef.value?.$refs.inputRef as HTMLInputElement).checked;\n\n if (isCheckboxGroup.value) {\n const newCheckedList = [...(props.modelValue as BentoMultiCheckboxType)];\n const index = newCheckedList.indexOf(props.value);\n\n if (index === -1) {\n newCheckedList.push(props.value);\n } else {\n newCheckedList.splice(index, 1);\n }\n return newCheckedList;\n }\n\n if (isRadioInput.value) {\n return props.value;\n }\n return currentValue;\n };\n\n const onChange = newValue => {\n if (!props.disabled && !props.readonly) {\n emit('update:model-value', newValue);\n emit('input', newValue);\n }\n };\n</script>\n\n<script lang=\"ts\">\n /**\n * Selection card component. If used standalone, only the checkbox variant can be used. If the checkbox variant is needed, please use the bento-selection-card-group component.\n *\n * @example\n * import { BentoSelectionCard } from '@adyen/bento-vue2';\n * import EmoticonHappyIcon from '@adyen/ui-assets-icons-16/vue/emoticon-happy';\n *\n * export default {\n * components: { BentoSelectionCard, EmoticonHappyIcon },\n * template: `\n * <bento-selection-card title=\"Card title\" :model-value.sync=\"yourModelValue\">\n * <template #icon>\n * <emoticon-happy-icon />\n * </template>\n * </bento-selection-card>\n * `\n * }\n */\n export default {\n name: 'bento-selection-card',\n };\n</script>\n<style lang=\"scss\" scoped src=\"./selection-card.scss\" />\n","<template>\n <controls-group\n ref=\"containerRef\"\n :aria-describedby=\"shouldShowGroupError ? errorMessageId : null\"\n :aria-required=\"required\"\n :label=\"label\"\n :hide-label=\"hideLabel\"\n :description=\"description\"\n :disabled=\"disabled\"\n :tooltip-text=\"tooltipText\"\n :readonly=\"readonly\"\n :required=\"required\"\n :optional=\"optional\"\n class=\"b-selection-card-group\"\n component-name=\"selection-card-group\"\n >\n <div\n v-if=\"!itemsPerRow || layout === 'vertical'\"\n class=\"b-selection-card-group__items\"\n :class=\"conditionalItemsClasses\"\n >\n <bento-selection-card\n v-for=\"item in items\"\n :key=\"`selection-card-${item.value}`\"\n class=\"b-selection-card-group__item\"\n v-bind=\"item\"\n :model-value=\"inputValue\"\n :readonly=\"readonly || item.readonly\"\n :has-error=\"shouldShowGroupError\"\n :disabled=\"disabled || item.disabled\"\n @update:model-value=\"onInput\"\n >\n <template v-if=\"hasSlot('icon') && item.icon\" #icon>\n <slot name=\"icon\" v-bind=\"item\"></slot>\n </template>\n <template v-if=\"hasSlot('content') && item.content\" #content>\n <slot name=\"content\" v-bind=\"item\"></slot>\n </template>\n <template v-if=\"hasSlot('dynamicContent') && item.dynamicContent\" #dynamicContent>\n <slot name=\"dynamicContent\" v-bind=\"item\"></slot>\n </template>\n </bento-selection-card>\n </div>\n <template v-else>\n <div :key=\"`selection-card-group-layout-breakpoint-${currentBreakpoint}`\">\n <grid-layout\n v-for=\"(row, rowIndex) in computedRows\"\n :key=\"`selection-card-group-row-${rowIndex}-cols-${computedItemsPerRow}`\"\n class=\"b-selection-card-group__items--wrap\"\n :column-width=\"computedColumnWidth\"\n >\n <template v-for=\"(item, columnIndex) in row\" #[`col-${Number(columnIndex)+1}`]>\n <bento-selection-card\n :key=\"`selection-card-${item.value}`\"\n class=\"b-selection-card-group__item b-selection-card-group__item--full-height\"\n v-bind=\"item\"\n :model-value=\"inputValue\"\n :readonly=\"readonly || item.readonly\"\n :has-error=\"shouldShowGroupError\"\n :disabled=\"disabled || item.disabled\"\n @update:model-value=\"onInput\"\n >\n <template v-if=\"hasSlot('icon') && item.icon\" #icon>\n <slot name=\"icon\" v-bind=\"item\"></slot>\n </template>\n <template v-if=\"hasSlot('content') && item.content\" #content>\n <slot name=\"content\" v-bind=\"item\"></slot>\n </template>\n <template v-if=\"hasSlot('dynamicContent') && item.dynamicContent\" #dynamicContent>\n <slot name=\"dynamicContent\" v-bind=\"item\"></slot>\n </template>\n </bento-selection-card>\n </template>\n </grid-layout>\n </div>\n </template>\n <error-message\n v-if=\"shouldShowGroupError\"\n :id=\"errorMessageId\"\n :error-message=\"errorMessage\"\n class=\"b-selection-card-group__error-message\"\n />\n </controls-group>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, onMounted, provide, ref, useSlots, watch } from 'vue';\n import { useElementSize } from '@vueuse/core';\n import { BMediaQueryMMax, BMediaQuerySMax } from '@adyen/bento-design-tokens/dist/js/bento/es6';\n import { type BentoSelectionCardGroupEmits, type BentoSelectionCardGroupProps } from './selection-card-group.types';\n import BentoSelectionCard from '../../selection-card.vue';\n import { ControlsGroup, ErrorMessage, GridLayout } from '../../../internal';\n import { SELECTION_CARD_RADIO_INPUT_INJECTION_KEY } from '../../selection-card.keys';\n import { generateUid } from '@/utils/ts/generate-uid';\n import { useFormFieldEmits } from '@/utils/ts/form-field/form-field';\n\n const props = defineProps({\n description: { default: null },\n disabled: { type: Boolean, default: false },\n errorMessage: { default: null },\n label: { default: null },\n optional: { type: Boolean, default: false },\n placeholder: null,\n readonly: { type: Boolean, default: false },\n required: { type: Boolean, default: false },\n tooltipText: { default: null },\n formId: { default: null },\n hideLabel: { type: Boolean, default: null },\n layout: { default: 'vertical' },\n items: null,\n itemsPerRow: { default: undefined },\n modelValue: { default: null },\n variant: { default: 'checkbox' }\n});\n\n const emit = defineEmits([\"update:model-value\"]);\n\n const { emitValue } = useFormFieldEmits(emit);\n\n const slots = useSlots();\n // Slots logic\n // Temporary, use-has-slots composable doesn't currently work for vue3 named scoped slots\n // We do the same in bento-checkbox-group\n const hasSlot = name => !!slots[name];\n\n const conditionalItemsClasses = computed(() => ({\n 'b-selection-card-group__items--horizontal': props.layout === 'horizontal',\n }));\n\n const inputValue = ref(props.modelValue);\n watch(\n () => props.modelValue,\n () => {\n inputValue.value = props.modelValue;\n }\n );\n\n // Error message logic\n const errorMessageId = generateUid('error');\n const shouldShowGroupError = computed(() => !props.disabled && !props.readonly && !!props.errorMessage);\n\n // itemsPerRow logic\n const containerRef = ref<HTMLElement | null>(null);\n const { width } = useElementSize(containerRef);\n\n const smallBreakpoint = computed(() => BMediaQuerySMax.split('px')[0]);\n const mediumBreakpoint = computed(() => BMediaQueryMMax.split('px')[0]);\n\n const currentBreakpoint = computed(() => {\n if (width.value < smallBreakpoint.value) {\n return 'small';\n }\n if (width.value >= smallBreakpoint.value && width.value < mediumBreakpoint.value) {\n return 'medium';\n }\n return 'large';\n });\n\n const computedItemsPerRow = computed(() => {\n return (props.itemsPerRow?.[currentBreakpoint?.value] as number) || props.items.length;\n });\n\n const computedRows = computed(() => {\n if (!props.itemsPerRow) {\n return [];\n }\n const rows = [];\n for (let i = 0; i < props.items.length; i += computedItemsPerRow?.value) {\n rows.push(props.items.slice(i, i + computedItemsPerRow?.value));\n }\n return rows;\n });\n\n // We need to compute the column width on 12 because we're using a 12-column system for out grid-layout logic\n const itemColumnWidth = computed(() => 12 / computedItemsPerRow?.value);\n\n /**\n * Filling the columnWidth array with the same parameters per item to pass\n * to the `grid-layout` layout so the each card can have\n * the same width according to the screen size.\n */\n const computedColumnWidth = computed(() => {\n return computedItemsPerRow?.value\n ? new Array(computedItemsPerRow?.value).fill({\n // Instead of passing the actual screen sizes values, passing the same values per each screen size and recomputing it makes sure visually the change is smoother and not laggy\n small: itemColumnWidth.value,\n medium: itemColumnWidth.value,\n large: itemColumnWidth.value,\n })\n : [];\n });\n\n const onInput = value => {\n inputValue.value = value;\n emitValue(value);\n };\n\n const isRadioVariant = computed(() => props.variant === 'radio');\n\n provide(SELECTION_CARD_RADIO_INPUT_INJECTION_KEY, isRadioVariant);\n\n onMounted(() => {\n if (props.itemsPerRow) {\n Object.values(props.itemsPerRow).forEach(el => {\n if (el && (el < 2 || el > 6)) {\n throw new Error(\n 'itemsPerRow values must have a value between 2 and 6 items per row. Read the documentation for more information.'\n );\n }\n });\n }\n });\n</script>\n\n<script lang=\"ts\">\n /**\n * Group of bento-selection-cards.\n *\n * @example\n * import { BentoSelectionCardGroup } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoSelectionCardGroup },\n * template: `\n * <bento-selection-card-group\n * :items=\"[\n * {\n * title: 'Card 1',\n * value: 'card-1',\n * content: 'Slot content 1',\n * icon: RetailIcon,\n * },\n * {\n * title: 'Card 2',\n * value: 'card-2',\n * content: 'Slot content 2',\n * icon: LeafIcon,\n * },\n * ]\"\n * >\n * <template #icon=\"{ icon }\">\n * <component :is=\"icon\"/>\n * </template>\n * <template #content=\"{ content }\">\n * <div>{{ content }}</div>\n * </template>\n * </bento-selection-card-group>\n * `,\n * }\n */\n export default {\n model: { prop: 'modelValue', event: 'update:model-value' },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./selection-card-group.scss\" />\n"],"names":["BentoSelectionCardState","BentoSelectionCardState2","SELECTION_CARD_RADIO_INPUT_INJECTION_KEY","__default__$1","slots","useSlots","hasSlot","useHasSlot","inputId","generateUid","descriptionId","computedRadioInputModelValue","computed","props","computedCheckboxInputModelValue","conditionalClasses","isChecked","containerConditionalClasses","isTitleOnly","checkboxContainerConditionalClasses","checkboxContainerTextConditionalClasses","slotConditionalClasses","ariaLabel","useAriaLabel","isCheckboxGroup","isRadioInput","item","inject","ref","inputRef","slotRef","dynamicSlotRef","handleCardClick","event","newValue2","toggleInput","onChange","newValue","currentValue","newCheckedList","index","emit","__default__","emitValue","useFormFieldEmits","name","conditionalItemsClasses","inputValue","watch","errorMessageId","shouldShowGroupError","containerRef","width","useElementSize","smallBreakpoint","BMediaQuerySMax","mediumBreakpoint","BMediaQueryMMax","currentBreakpoint","computedItemsPerRow","computedRows","rows","i","itemColumnWidth","computedColumnWidth","onInput","value","isRadioVariant","provide","onMounted","el"],"mappings":";;;;;;;;;;;;;;;AAIO,IAAAA,IAAA,kBAAAC,OACHA,EAAA,WAAA,YACAA,EAAA,WAAA,YACAA,EAAA,QAAA,SAHQA,IAAAD,KAAA,CAAA,CAAA;ACJL,MAAAE,IAAA,uBAAA,0CAAA,GCoTHC,IAAA;AAAA,EAAe,MAAA;AAEf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBArJAC,IAAAC,EAAA,GACAC,IAAAC,EAAAH,CAAA,GAEAI,IAAAC,EAAA,yBAAA,GACAC,IAAAD,EAAA,4BAAA,GAEAE,IAAAC;AAAA,MAAmE,MAAAC,EAAA;AAAA,IACnD,GAEhBC,IAAAF;AAAA,MAAwE,MAAAC,EAAA;AAAA,IACxD,GAGhBE,IAAAH,EAAA,OAAA;AAAA,MAA2C,6BAAAI,EAAA;AAAA,MACA,qCAAAH,EAAA;AAAA,IACI,EAAA,GAG/CI,IAAAL,EAAA,OAAA;AAAA,MAAoD,CAAA,qBAAAZ,EAAA,QAAA,EAAA,GAAAa,EAAA;AAAA,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AER,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ref as a, watch as u, onUnmounted as s, nextTick as c } from "vue";
|
|
2
|
+
import { o as v } from "./resize.Bqks3WUm.js";
|
|
3
|
+
const h = (o, l) => {
|
|
4
|
+
const i = a(null);
|
|
5
|
+
let t = null;
|
|
6
|
+
const n = () => {
|
|
7
|
+
c(() => {
|
|
8
|
+
const e = o.value?.scrollHeight || null;
|
|
9
|
+
i.value = l.value && e ? `${e}px` : "0";
|
|
10
|
+
});
|
|
11
|
+
}, r = () => {
|
|
12
|
+
t && (t.disconnect(), t = null);
|
|
13
|
+
};
|
|
14
|
+
return u(
|
|
15
|
+
() => o.value,
|
|
16
|
+
(e) => {
|
|
17
|
+
r(), e && (t = v(e, () => {
|
|
18
|
+
o.value === e && n();
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
), u(
|
|
22
|
+
l,
|
|
23
|
+
() => {
|
|
24
|
+
n();
|
|
25
|
+
},
|
|
26
|
+
{ immediate: !0 }
|
|
27
|
+
), s(() => {
|
|
28
|
+
r();
|
|
29
|
+
}), {
|
|
30
|
+
contentHeight: i
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
h as u
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=use-expandable-content-height.DmFeas9-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-expandable-content-height.DmFeas9-.js","sources":["../../src/composables/use-expandable-content-height/use-expandable-content-height.ts"],"sourcesContent":["import { nextTick, onUnmounted, ref, watch } from 'vue';\nimport { observeSizeOfElement } from '@/utils/ts/resize';\n\n/**\n * Composable function that gets the height of expandable content. Mostly to use with expanding height animations (accordion, card...).\n * Automatically observes content size changes and updates the height accordingly. Cleans up the observer on unmount.\n *\n * @example\n * <template>\n * <Transition :name=\"b-height__animation\">\n * <div v-if=\"isOpen\" :style=\"contentHeight ? { 'max-height': contentHeight } : {}\" >\n * <div ref=\"contentDiv\">\n * <slot />\n * </div>\n * </div>\n * </Transition>\n * </template>\n *\n * <script script lang=\"ts\">\n * import { useExpandableContentHeight } from '@/composables/use-expandable-content-height/use-expandable-content-height';\n *\n * const { contentHeight } = useExpandableContentHeight(contentDiv, isOpen);\n * </script>\n *\n * @param contentRef Reference to the div with the content\n * @param isOpen Reference to the boolean controlling the expanded state\n * @returns The height of the content\n */\nexport const useExpandableContentHeight = (contentRef, isOpen) => {\n const contentHeight = ref<string | null>(null);\n let observer: ResizeObserver | null = null;\n\n const updateContentHeight = () => {\n nextTick(() => {\n const maxHeight = contentRef.value?.scrollHeight || null;\n contentHeight.value = isOpen.value && maxHeight ? `${maxHeight}px` : '0';\n });\n };\n\n const disconnectObserver = () => {\n if (observer) {\n observer.disconnect();\n observer = null;\n }\n };\n\n watch(\n () => contentRef.value,\n contentElement => {\n disconnectObserver();\n\n if (contentElement) {\n observer = observeSizeOfElement(contentElement, () => {\n if (contentRef.value === contentElement) {\n updateContentHeight();\n }\n });\n }\n }\n );\n\n watch(\n isOpen,\n () => {\n updateContentHeight();\n },\n { immediate: true }\n );\n\n onUnmounted(() => {\n disconnectObserver();\n });\n\n return {\n contentHeight,\n };\n};\n"],"names":["useExpandableContentHeight","contentRef","isOpen","contentHeight","ref","observer","updateContentHeight","nextTick","maxHeight","disconnectObserver","watch","contentElement","observeSizeOfElement","onUnmounted"],"mappings":";;AA4BO,MAAMA,IAA6B,CAACC,GAAYC,MAAW;AAC9D,QAAMC,IAAgBC,EAAmB,IAAI;AAC7C,MAAIC,IAAkC;AAEtC,QAAMC,IAAsB,MAAM;AAC9B,IAAAC,EAAS,MAAM;AACX,YAAMC,IAAYP,EAAW,OAAO,gBAAgB;AACpD,MAAAE,EAAc,QAAQD,EAAO,SAASM,IAAY,GAAGA,CAAS,OAAO;AAAA,IACzE,CAAC;AAAA,EACL,GAEMC,IAAqB,MAAM;AAC7B,IAAIJ,MACAA,EAAS,WAAA,GACTA,IAAW;AAAA,EAEnB;AAEA,SAAAK;AAAA,IACI,MAAMT,EAAW;AAAA,IACjB,CAAAU,MAAkB;AACd,MAAAF,EAAA,GAEIE,MACAN,IAAWO,EAAqBD,GAAgB,MAAM;AAClD,QAAIV,EAAW,UAAUU,KACrBL,EAAA;AAAA,MAER,CAAC;AAAA,IAET;AAAA,EAAA,GAGJI;AAAA,IACIR;AAAA,IACA,MAAM;AACF,MAAAI,EAAA;AAAA,IACJ;AAAA,IACA,EAAE,WAAW,GAAA;AAAA,EAAK,GAGtBO,EAAY,MAAM;AACd,IAAAJ,EAAA;AAAA,EACJ,CAAC,GAEM;AAAA,IACH,eAAAN;AAAA,EAAA;AAER;"}
|
package/dist/data-grid.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as e, d as o, a as r, b as i, c as n, e as d, f as B, g as l, h as s, i as D } from "./chunks/data-grid.
|
|
1
|
+
import { B as e, d as o, a as r, b as i, c as n, e as d, f as B, g as l, h as s, i as D } from "./chunks/data-grid.CMxQpfrY.js";
|
|
2
2
|
export {
|
|
3
3
|
e as BentoColumnOverflow,
|
|
4
4
|
o as BentoDataGrid,
|
package/dist/filter-bar.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { t as b, c as I } from "./chunks/use-bento-toast-controller.A5xraVqa.js"
|
|
|
3
3
|
import { u as Z } from "./chunks/use-bento-toast-controller.A5xraVqa.js";
|
|
4
4
|
import { p as M, d as g } from "./chunks/typography.D1OZJbEa.js";
|
|
5
5
|
import { B as J, a as Q, b as X, c as ee } from "./chunks/typography.D1OZJbEa.js";
|
|
6
|
-
import { a as oe, b as ae } from "./chunks/accordion-item.
|
|
6
|
+
import { a as oe, b as ae } from "./chunks/accordion-item.B7lteJBu.js";
|
|
7
7
|
import { B as re } from "./chunks/action-bar.BsXW7BI2.js";
|
|
8
8
|
import { a as Be } from "./chunks/ai-tag.D2Q0xhFK.js";
|
|
9
9
|
import { B as pe, a as me, b as le, c as ue } from "./chunks/alert.DJDHwVeR.js";
|
|
@@ -11,8 +11,8 @@ import { a as ce } from "./chunks/anchor-scroller.BbvghQxZ.js";
|
|
|
11
11
|
import { B as ge } from "./chunks/avatar.CxPKc8Gy.js";
|
|
12
12
|
import { B as ye, a as xe, b as Se } from "./chunks/button.DII5Ifwa.js";
|
|
13
13
|
import { B as Ee } from "./chunks/dashed-underline.CzKc-fJW.js";
|
|
14
|
-
import { B as Ie, d as Me, a as Ce, b as De, c as ve, e as Le, f as Oe, g as Ne, h as Pe, i as _e } from "./chunks/data-grid.
|
|
15
|
-
import { c as Ge, B as Re, a as ke } from "./chunks/card.
|
|
14
|
+
import { B as Ie, d as Me, a as Ce, b as De, c as ve, e as Le, f as Oe, g as Ne, h as Pe, i as _e } from "./chunks/data-grid.CMxQpfrY.js";
|
|
15
|
+
import { c as Ge, B as Re, a as ke } from "./chunks/card.BmpB0VbL.js";
|
|
16
16
|
import { B as we } from "./chunks/date-picker.gDsw8bn1.js";
|
|
17
17
|
import { B as Ve } from "./chunks/date-picker.types.Ckt7zxGy.js";
|
|
18
18
|
import { B as Ye } from "./chunks/date-range-picker.CqixIJxG.js";
|
|
@@ -21,7 +21,7 @@ import { d as We } from "./chunks/date-time-picker.Bktntun4.js";
|
|
|
21
21
|
import { d as Ze } from "./chunks/draggable.DYKdXdbj.js";
|
|
22
22
|
import { d as Je } from "./chunks/drawer.DPSDM5Mo.js";
|
|
23
23
|
import { B as Xe, a as et, b as tt, c as ot, a as at, b as nt, f as rt } from "./chunks/dropdown.Bnq4kP7k.js";
|
|
24
|
-
import { B as Bt, a as it } from "./chunks/checkbox.
|
|
24
|
+
import { B as Bt, a as it } from "./chunks/checkbox.D5xZ5Nnh.js";
|
|
25
25
|
import { B as mt } from "./chunks/chip.DRsJylWl.js";
|
|
26
26
|
import { B as ut } from "./chunks/click-outside.B0whuTUU.js";
|
|
27
27
|
import { c as ct, B as ft, a as gt, b as Tt } from "./chunks/code-snippet.CnThWqVb.js";
|
|
@@ -32,9 +32,9 @@ import { B as Lt, a as Ot } from "./chunks/date.CPo8t1n9.js";
|
|
|
32
32
|
import { B as Pt } from "./chunks/divider.KxXy6nzJ.js";
|
|
33
33
|
import { B as At, a as Gt, b as Rt, c as kt } from "./chunks/empty-state.C2wjdE3y.js";
|
|
34
34
|
import { f as wt } from "./chunks/file-uploader.DllKBmP8.js";
|
|
35
|
-
import { B as Vt, a as Ut, b as Yt, c as jt, d as zt, u as Kt } from "./chunks/filter-bar.
|
|
35
|
+
import { B as Vt, a as Ut, b as Yt, c as jt, d as zt, u as Kt } from "./chunks/filter-bar.D7Lk7wlq.js";
|
|
36
36
|
import { f as qt, a as Zt, b as $t } from "./chunks/form-layout-title.C0lwzPZz.js";
|
|
37
|
-
import { h as Qt } from "./chunks/header-with-views.
|
|
37
|
+
import { h as Qt } from "./chunks/header-with-views.BqobE7IF.js";
|
|
38
38
|
import { B as eo, a as to, b as oo } from "./chunks/image.C2D2hKat.js";
|
|
39
39
|
import { B as no } from "./chunks/info-icon.B-FAeceD.js";
|
|
40
40
|
import { B as so, a as Bo, b as io, c as po, d as mo, e as lo } from "./chunks/input-field.D912rZS_.js";
|
|
@@ -51,7 +51,7 @@ import { B as Yo, a as jo, b as zo, f as Ko, g as Wo, h as qo, c as Zo, u as $o
|
|
|
51
51
|
import { B as Qo } from "./chunks/modal.B3-pmL5s.js";
|
|
52
52
|
import { B as ea, a as ta, b as oa, c as aa, d as na, e as ra, f as sa, g as Ba } from "./chunks/base-modal.CcmoTJdc.js";
|
|
53
53
|
import { B as pa, a as ma } from "./chunks/modal-fullscreen.Bi1bQs4Z.js";
|
|
54
|
-
import { n as ua, a as da, b as ca } from "./chunks/navigation-menu-group.
|
|
54
|
+
import { n as ua, a as da, b as ca } from "./chunks/navigation-menu-group.BnHdXODQ.js";
|
|
55
55
|
import { B as ga } from "./chunks/header.CmyqVXuG.js";
|
|
56
56
|
import { B as ya } from "./chunks/pagination.cI_pc6oE.js";
|
|
57
57
|
import { B as Sa } from "./chunks/payment-method.DcAITDcK.js";
|
|
@@ -60,10 +60,10 @@ import { B as Ia } from "./chunks/popover.types.DvIwSAAp.js";
|
|
|
60
60
|
import { p as Ca } from "./chunks/progress-bar.RlF3a0Gb.js";
|
|
61
61
|
import { p as va, B as La, a as Oa } from "./chunks/promo-banner.B5szTysj.js";
|
|
62
62
|
import { B as Pa, a as _a, b as Aa } from "./chunks/radio-group.CvsQDlHi.js";
|
|
63
|
-
import { r as Ra } from "./chunks/rich-text-editor.
|
|
63
|
+
import { r as Ra } from "./chunks/rich-text-editor.rXoS7KGY.js";
|
|
64
64
|
import { B as Ha, a as wa, b as Fa } from "./chunks/search-bar.--4KVNkf.js";
|
|
65
|
-
import { s as Ua } from "./chunks/secondary-nav.
|
|
66
|
-
import { B as ja, s as za, a as Ka } from "./chunks/selection-card-group.
|
|
65
|
+
import { s as Ua } from "./chunks/secondary-nav.CgdV0QwZ.js";
|
|
66
|
+
import { B as ja, s as za, a as Ka } from "./chunks/selection-card-group.CmDuj1c7.js";
|
|
67
67
|
import { B as qa } from "./chunks/segmented-control.nYpRQTGc.js";
|
|
68
68
|
import { B as $a } from "./chunks/segmented-control.types.BHRLV8KU.js";
|
|
69
69
|
import { s as Qa, B as Xa, a as en } from "./chunks/sidepanel.CntIcmx-.js";
|
|
@@ -84,7 +84,7 @@ import { d as Zn, a as $n } from "./chunks/dashboard-section.CYEoNH9Q.js";
|
|
|
84
84
|
import { d as Qn } from "./chunks/data-grid-template.DCwzh2G7.js";
|
|
85
85
|
import { a as er } from "./chunks/ai-button.BnFk5CzK.js";
|
|
86
86
|
import { B as or, a as ar, b as nr } from "./chunks/button-actions.types.BptAXjD8.js";
|
|
87
|
-
import { B as sr, a as Br } from "./chunks/checkbox-group.
|
|
87
|
+
import { B as sr, a as Br } from "./chunks/checkbox-group.D1uyc3z3.js";
|
|
88
88
|
import { B as pr } from "./chunks/minus-small.CAycYt5H.js";
|
|
89
89
|
import { B as lr } from "./chunks/directive.D1-d-C2K.js";
|
|
90
90
|
import { C as dr, a as cr, C as fr, a as gr } from "./chunks/calendar.CXdLEeN4.js";
|
package/dist/navigation-menu.js
CHANGED
package/dist/rich-text-editor.js
CHANGED
package/dist/secondary-nav.js
CHANGED
package/dist/selection-card.js
CHANGED
package/dist/web-types.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adyen/bento-vue2",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Adyen Bento Vue2 components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"unified": "11.0.5",
|
|
52
52
|
"uuid": "11.1.1",
|
|
53
53
|
"vue-demi": "0.14.10",
|
|
54
|
-
"@adyen/bento-design-tokens": "2.0.
|
|
54
|
+
"@adyen/bento-design-tokens": "2.0.1"
|
|
55
55
|
},
|
|
56
56
|
"dependenciesMeta": {
|
|
57
57
|
"@adyen/bento-vue-i18n-demi": {
|
|
@@ -132,12 +132,12 @@
|
|
|
132
132
|
"vue-template-compiler": "2.7.16",
|
|
133
133
|
"vue-tsc": "2.2.12",
|
|
134
134
|
"zod": "3.25.35",
|
|
135
|
+
"@adyen/bento-vue-i18n-demi": "0.1.0",
|
|
136
|
+
"@adyen/bento-core": "0.0.1",
|
|
137
|
+
"@adyen/bento-cli": "0.10.8",
|
|
135
138
|
"@adyen/eslint-plugin-bento": "2.23.0",
|
|
136
139
|
"@adyen/ui-assets-icons-16": "7.9.7",
|
|
137
|
-
"@adyen/
|
|
138
|
-
"@adyen/ui-assets-payment-method-icons": "13.0.1",
|
|
139
|
-
"@adyen/bento-vue-i18n-demi": "0.1.0",
|
|
140
|
-
"@adyen/bento-core": "0.0.1"
|
|
140
|
+
"@adyen/ui-assets-payment-method-icons": "13.0.1"
|
|
141
141
|
},
|
|
142
142
|
"optionalDependencies": {
|
|
143
143
|
"vue-router": "~3.6"
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { ref as n, watch as i, onUnmounted as r, nextTick as s } from "vue";
|
|
2
|
-
import { o as m } from "./resize.Bqks3WUm.js";
|
|
3
|
-
const h = (e, t) => {
|
|
4
|
-
const u = n(null);
|
|
5
|
-
let l = null;
|
|
6
|
-
const a = () => {
|
|
7
|
-
s(() => {
|
|
8
|
-
const o = e.value?.scrollHeight || null;
|
|
9
|
-
u.value = t.value && o ? `${o}px` : "0";
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
return i(
|
|
13
|
-
() => e.value,
|
|
14
|
-
() => {
|
|
15
|
-
!l && e.value && (l = m(e.value, () => {
|
|
16
|
-
e.value && a();
|
|
17
|
-
}));
|
|
18
|
-
}
|
|
19
|
-
), i(
|
|
20
|
-
t,
|
|
21
|
-
() => {
|
|
22
|
-
a();
|
|
23
|
-
},
|
|
24
|
-
{ immediate: !0 }
|
|
25
|
-
), r(() => {
|
|
26
|
-
l && (l.disconnect(), l = null);
|
|
27
|
-
}), {
|
|
28
|
-
contentHeight: u
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
export {
|
|
32
|
-
h as u
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=use-expandable-content-height.Bdd9hQwq.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-expandable-content-height.Bdd9hQwq.js","sources":["../../src/composables/use-expandable-content-height/use-expandable-content-height.ts"],"sourcesContent":["import { nextTick, onUnmounted, ref, watch } from 'vue';\nimport { observeSizeOfElement } from '@/utils/ts/resize';\n\n/**\n * Composable function that gets the height of expandable content. Mostly to use with expanding height animations (accordion, card...).\n * Automatically observes content size changes and updates the height accordingly. Cleans up the observer on unmount.\n *\n * @example\n * <template>\n * <Transition :name=\"b-height__animation\">\n * <div v-if=\"isOpen\" :style=\"contentHeight ? { 'max-height': contentHeight } : {}\" >\n * <div ref=\"contentDiv\">\n * <slot />\n * </div>\n * </div>\n * </Transition>\n * </template>\n *\n * <script script lang=\"ts\">\n * import { useExpandableContentHeight } from '@/composables/use-expandable-content-height/use-expandable-content-height';\n *\n * const { contentHeight } = useExpandableContentHeight(contentDiv, isOpen);\n * </script>\n *\n * @param contentRef Reference to the div with the content\n * @param isOpen Reference to the boolean controlling the expanded state\n * @returns The height of the content\n */\nexport const useExpandableContentHeight = (contentRef, isOpen) => {\n const contentHeight = ref<string | null>(null);\n let observer: ResizeObserver | null = null;\n\n const updateContentHeight = () => {\n nextTick(() => {\n const maxHeight = contentRef.value?.scrollHeight || null;\n contentHeight.value = isOpen.value && maxHeight ? `${maxHeight}px` : '0';\n });\n };\n\n watch(\n () => contentRef.value,\n () => {\n if (!observer && contentRef.value) {\n observer = observeSizeOfElement(contentRef.value, () => {\n if (contentRef.value) {\n updateContentHeight();\n }\n });\n }\n }\n );\n\n watch(\n isOpen,\n () => {\n updateContentHeight();\n },\n { immediate: true }\n );\n\n onUnmounted(() => {\n if (observer) {\n observer.disconnect();\n observer = null;\n }\n });\n\n return {\n contentHeight,\n };\n};\n"],"names":["useExpandableContentHeight","contentRef","isOpen","contentHeight","ref","observer","updateContentHeight","nextTick","maxHeight","watch","observeSizeOfElement","onUnmounted"],"mappings":";;AA4BO,MAAMA,IAA6B,CAACC,GAAYC,MAAW;AAC9D,QAAMC,IAAgBC,EAAmB,IAAI;AAC7C,MAAIC,IAAkC;AAEtC,QAAMC,IAAsB,MAAM;AAC9B,IAAAC,EAAS,MAAM;AACX,YAAMC,IAAYP,EAAW,OAAO,gBAAgB;AACpD,MAAAE,EAAc,QAAQD,EAAO,SAASM,IAAY,GAAGA,CAAS,OAAO;AAAA,IACzE,CAAC;AAAA,EACL;AAEA,SAAAC;AAAA,IACI,MAAMR,EAAW;AAAA,IACjB,MAAM;AACF,MAAI,CAACI,KAAYJ,EAAW,UACxBI,IAAWK,EAAqBT,EAAW,OAAO,MAAM;AACpD,QAAIA,EAAW,SACXK,EAAA;AAAA,MAER,CAAC;AAAA,IAET;AAAA,EAAA,GAGJG;AAAA,IACIP;AAAA,IACA,MAAM;AACF,MAAAI,EAAA;AAAA,IACJ;AAAA,IACA,EAAE,WAAW,GAAA;AAAA,EAAK,GAGtBK,EAAY,MAAM;AACd,IAAIN,MACAA,EAAS,WAAA,GACTA,IAAW;AAAA,EAEnB,CAAC,GAEM;AAAA,IACH,eAAAF;AAAA,EAAA;AAER;"}
|