@adyen/bento-vue2 1.40.0 → 1.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/components.d.ts +6 -0
- package/dist/@types/index.d.ts +620 -373
- package/dist/action-bar.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/card.css +1 -1
- package/dist/assets/currency.css +1 -1
- package/dist/assets/data-grid.css +1 -1
- package/dist/assets/dialog-page.css +1 -1
- package/dist/assets/inspector.css +1 -1
- package/dist/assets/layout-row.css +1 -0
- package/dist/assets/menu.css +1 -1
- package/dist/assets/modal-fullscreen.css +1 -1
- package/dist/assets/popover.css +1 -1
- package/dist/assets/promo-banner.css +1 -0
- package/dist/assets/selection-card-group.css +1 -1
- package/dist/assets/sidepanel.css +1 -1
- package/dist/assets/structured-list-item.css +1 -1
- package/dist/chunks/{action-bar.DJmskrzB.js → action-bar.r05wfyni.js} +2 -2
- package/dist/chunks/{action-bar.DJmskrzB.js.map → action-bar.r05wfyni.js.map} +1 -1
- package/dist/chunks/{code-snippet.CmBhucys.js → code-snippet.DRH4X9pH.js} +2 -2
- package/dist/chunks/{code-snippet.CmBhucys.js.map → code-snippet.DRH4X9pH.js.map} +1 -1
- package/dist/chunks/{currency.CEqsVP2T.js → currency.P7Psn_SK.js} +53 -61
- package/dist/chunks/currency.P7Psn_SK.js.map +1 -0
- package/dist/chunks/{dashboard-section.9R8bIh92.js → dashboard-section.DchlD4B2.js} +2 -2
- package/dist/chunks/{dashboard-section.9R8bIh92.js.map → dashboard-section.DchlD4B2.js.map} +1 -1
- package/dist/chunks/{data-grid.Czo9hi7m.js → data-grid.ahAWR42s.js} +934 -895
- package/dist/chunks/data-grid.ahAWR42s.js.map +1 -0
- package/dist/chunks/es6.b4enG1py.js +10 -0
- package/dist/chunks/es6.b4enG1py.js.map +1 -0
- package/dist/chunks/image.C2D2hKat.js +56 -0
- package/dist/chunks/image.C2D2hKat.js.map +1 -0
- package/dist/chunks/index.D5am6ibQ.js +249 -0
- package/dist/chunks/{index.iCshT3Hx.js.map → index.D5am6ibQ.js.map} +1 -1
- package/dist/chunks/layout-row.CtFsZ5-v.js +87 -0
- package/dist/chunks/layout-row.CtFsZ5-v.js.map +1 -0
- package/dist/chunks/promo-banner.NSOVGA7M.js +70 -0
- package/dist/chunks/promo-banner.NSOVGA7M.js.map +1 -0
- package/dist/chunks/{secondary-nav.bchOEARi.js → secondary-nav.DMw1l7rH.js} +3 -3
- package/dist/chunks/{secondary-nav.bchOEARi.js.map → secondary-nav.DMw1l7rH.js.map} +1 -1
- package/dist/chunks/selection-card-group.BjOuUbQD.js +299 -0
- package/dist/chunks/selection-card-group.BjOuUbQD.js.map +1 -0
- package/dist/chunks/{structured-list-item.C4gxvOkq.js → structured-list-item.CAcBJutf.js} +6 -6
- package/dist/chunks/structured-list-item.CAcBJutf.js.map +1 -0
- package/dist/chunks/{timeline-item.Bmn0Pu11.js → timeline-item.CxB3KFiu.js} +2 -2
- package/dist/chunks/{timeline-item.Bmn0Pu11.js.map → timeline-item.CxB3KFiu.js.map} +1 -1
- package/dist/chunks/{tutorial.DG5I6TRS.js → tutorial.CGjM0EJT.js} +2 -2
- package/dist/chunks/{tutorial.DG5I6TRS.js.map → tutorial.CGjM0EJT.js.map} +1 -1
- package/dist/code-snippet.js +1 -1
- package/dist/currency.js +1 -1
- package/dist/dashboard-template.js +1 -1
- package/dist/data-grid.js +1 -1
- package/dist/image.js +1 -1
- package/dist/index.js +184 -177
- package/dist/index.js.map +1 -1
- package/dist/layout.js +6 -0
- package/dist/layout.js.map +1 -0
- package/dist/promo-banner.js +7 -0
- package/dist/promo-banner.js.map +1 -0
- package/dist/secondary-nav.js +1 -1
- package/dist/selection-card.js +1 -1
- package/dist/structured-list.js +1 -1
- package/dist/styles/bento-dark.css +16 -0
- package/dist/styles/bento-light.css +16 -0
- package/dist/styles/bento.css +16 -0
- package/dist/styles/legacy.css +16 -0
- package/dist/styles/styleguide.css +16 -0
- package/dist/timeline.js +1 -1
- package/dist/tutorial.js +1 -1
- package/dist/web-types.json +276 -83
- package/package.json +2 -2
- package/dist/chunks/currency.CEqsVP2T.js.map +0 -1
- package/dist/chunks/data-grid.Czo9hi7m.js.map +0 -1
- package/dist/chunks/es6.BvpG4Oi6.js +0 -9
- package/dist/chunks/es6.BvpG4Oi6.js.map +0 -1
- package/dist/chunks/image.B3uqhFjl.js +0 -82
- package/dist/chunks/image.B3uqhFjl.js.map +0 -1
- package/dist/chunks/index.iCshT3Hx.js +0 -183
- package/dist/chunks/selection-card-group.CW7c72r2.js +0 -255
- package/dist/chunks/selection-card-group.CW7c72r2.js.map +0 -1
- package/dist/chunks/structured-list-item.C4gxvOkq.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-bar.DJmskrzB.js","sources":["../../src/components/action-bar/action-bar.vue"],"sourcesContent":["<template>\n <Transition name=\"b-action-bar__animation\" appear>\n <section class=\"b-action-bar\" :class=\"conditionalClasses\" :aria-label=\"t('actionBar')\">\n <div ref=\"actionBar\" class=\"b-action-bar__container\">\n <div v-if=\"!isConfirmationVariant\" class=\"b-action-bar__close-button\">\n <bento-button variant=\"tertiary\" inverse :aria-label=\"t('close')\" @click=\"emit('close')\">\n <template #iconLeft><cross-icon :aria-hidden=\"true\" /></template>\n </bento-button>\n </div>\n <bento-typography el=\"span\" stronger class=\"b-action-bar__selection\">\n {{ itemCounter }} {{ isConfirmationVariant ? tc('unsavedChanges', itemCounter) : label }}\n </bento-typography>\n <bento-button-actions\n v-if=\"isConfirmationVariant\"\n :actions=\"confirmationActions\"\n class=\"b-action-bar__actions\"\n inverse\n />\n <button-actions-with-menu\n v-else\n :actions=\"actionsInternal\"\n class=\"b-action-bar__actions\"\n :displayed-actions=\"internalDisplayedActions\"\n menu-position=\"top-end\"\n inverse\n />\n </div>\n </section>\n </Transition>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, nextTick, PropType, provide, ref, toRefs, watch } from 'vue';\n import { BentoButton, BentoButtonActions, BentoButtonActionsList } from '@/components/button';\n import { BentoTypography } from '@/components/typography';\n\n import { type BentoActionBarVariant } from '@/components/action-bar/action-bar.types';\n import ButtonActionsWithMenu from '@/components/internal/button-actions-with-menu/button-actions-with-menu.vue';\n import CrossIcon from '@adyen/ui-assets-icons-16/vue/cross';\n\n import { useI18n } from '@/utils/ts/i18n';\n import { useWindowSize } from '@vueuse/core';\n\n import messages from './messages.json';\n import { POPOVER_OFFSET_INJECTION_KEY } from '@/components/popover/popover.keys';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n // Constants\n const AVERAGE_BUTTON_SIZE = 100;\n const MENU_OFFSET = 7;\n const RESPONSIVE_BREAKPOINT = 500;\n const SPACING = 32;\n\n const props = defineProps({\n /**\n * List of actions that will be used to render the buttons.\n * Required and used for the `default` variant.\n *\n * Each object in the list should have a `title`, an `event` and,\n * optionally, an `icon`.\n *\n * The component will display 4 actions and the hide the rest inside a menu.\n *\n * @see BentoButton for a list of all the other props supported by each button action.\n */\n actions: {\n type: Array as PropType<BentoButtonActionsList>,\n default: () => [],\n },\n /**\n * How many actions should be visible outside the menu, cannot be more than 4\n */\n visibleActions: {\n type: Number,\n default: 4,\n validator: (value: number) => value > 0 && value <= 4,\n },\n /**\n * Use when there are sticky elements at the bottom, like sticky pagination\n */\n extraBottomSpacing: {\n type: Boolean,\n default: false,\n },\n /**\n * Show how many items are selected\n */\n itemCounter: {\n type: Number,\n required: true,\n },\n /**\n * Label for the selection, e.g. 'selected'/'changed'\n */\n selectionLabel: {\n type: String,\n default: null,\n },\n /**\n * Variant for the action bar\n * @values default, confirmation\n */\n variant: {\n type: String as PropType<BentoActionBarVariant>,\n default: 'default',\n },\n });\n\n const emit = defineEmits([\"close\", \"cancel\", \"save\"]);\n\n const { t, tc } = useI18n<{ message: MessageSchema }>({ messages });\n const label = computed(() => (props.selectionLabel ? props.selectionLabel : t('selected')));\n\n // Refs\n const actionBar = ref<HTMLDivElement>(null);\n const { extraBottomSpacing, visibleActions } = toRefs(props);\n const { width } = useWindowSize();\n const internalDisplayedActions = ref(null);\n const internalVisibleActions = ref(null);\n\n const isConfirmationVariant = computed(() => props.variant === 'confirmation');\n\n watch(\n () => visibleActions.value,\n value => {\n internalVisibleActions.value = value <= 4 ? value : 4;\n internalDisplayedActions.value = internalVisibleActions.value;\n },\n { immediate: true }\n );\n\n // Styling\n const conditionalClasses = computed(() => ({\n 'b-action-bar--extra-spacing': extraBottomSpacing.value,\n 'b-action-bar--confirmation': isConfirmationVariant.value,\n }));\n\n // Provide POPOVER_OFFSET_INJECTION_KEY to change the value of the popover offset\n provide(POPOVER_OFFSET_INJECTION_KEY, MENU_OFFSET);\n\n // Manipulate actions array to display as intended\n const actionsInternal = computed(() => {\n // All buttons should be of type secondary in the action bar\n const actions = props.actions.map(action => ({\n ...action,\n variant: 'secondary',\n })) as BentoButtonActionsList;\n // Shown actions should display from left to right in action bar, instead of right to left which is the button actions default\n const shownActions = actions.slice(0, internalDisplayedActions.value).reverse();\n const hiddenActions = actions.slice(internalDisplayedActions.value);\n\n return [...shownActions, ...hiddenActions];\n });\n\n const confirmationActions = computed<BentoButtonActionsList>(() => [\n {\n title: t('save'),\n event: () => emit('save'),\n },\n {\n title: t('cancel'),\n variant: 'secondary',\n event: () => emit('cancel'),\n },\n ]);\n\n // Recursive functions to determine how many actions should be visible/hidden based on the screens width\n const showActions = async () => {\n await nextTick();\n if (\n width.value > actionBar.value.clientWidth + SPACING + AVERAGE_BUTTON_SIZE &&\n internalDisplayedActions.value < internalVisibleActions.value\n ) {\n internalDisplayedActions.value += 1;\n showActions();\n }\n };\n\n const hideActions = async () => {\n await nextTick();\n if (width.value < actionBar.value.clientWidth + SPACING && internalDisplayedActions.value > 0) {\n internalDisplayedActions.value -= 1;\n hideActions();\n }\n };\n\n // Screen width watcher to toggle hidden/visible actions\n watch(\n () => width.value,\n async (newValue, oldValue) => {\n await nextTick();\n if (!actionBar.value) {\n return;\n }\n const isIncreasing = newValue > oldValue;\n if (width.value < RESPONSIVE_BREAKPOINT) {\n internalDisplayedActions.value = 0;\n } else if (isIncreasing) {\n showActions();\n } else {\n hideActions();\n }\n },\n { immediate: true }\n );\n</script>\n\n<script lang=\"ts\">\n /**\n * Action bar is a floating bar that provides users with quick access to key actions that can be applied to one or multiple items.\n *\n * @example\n * import { BentoActionBar } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoActionBar },\n * template: `\n * <bento-action-bar\n * :actions='[\n * {\n * title: 'Delete',\n * critical: true,\n * icon: BinIcon,\n * event: () => true,\n * },\n * {\n * title: 'Edit',\n * icon: EditIcon,\n * event: () => true,\n * }\n * ]'\n * @close=\"closeAction\"\n * :item-counter=\"5\"\n * />\n * `\n * }\n */\n export default {\n i18n: { messages },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./action-bar.scss\" />\n"],"names":["__default__","messages","AVERAGE_BUTTON_SIZE","MENU_OFFSET","RESPONSIVE_BREAKPOINT","SPACING","t","tc","useI18n","label","computed","props","actionBar","ref","extraBottomSpacing","visibleActions","toRefs","width","useWindowSize","internalDisplayedActions","internalVisibleActions","isConfirmationVariant","watch","value","conditionalClasses","provide","POPOVER_OFFSET_INJECTION_KEY","actionsInternal","actions","action","shownActions","hiddenActions","confirmationActions","emit","showActions","nextTick","hideActions","newValue","oldValue","isIncreasing"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8OIA,IAAA;AAAA,EAAe,MAAA,EAAA,UAAAC,EAAA;AAEf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA/LAC,IAAA,KACAC,IAAA,GACAC,IAAA,KACAC,IAAA,IA2DA,EAAA,GAAAC,GAAA,IAAAC,EAAA,IAAAC,EAAA,GACAC,IAAAC,EAAA,MAAAC,EAAA,iBAAAA,EAAA,iBAAAL,EAAA,UAA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AAA,UAIID,EAAA,SAAA,GACAe,EAAA;AAAA,IACJ,GAGJE,IAAA,YAAA;AACI,YAAAD,EAAA,GACAlB,EAAA,QAAAL,EAAA,MAAA,cAAAP,KAAAc,EAAA,QAAA,MACIA,EAAA,SAAA,GACAiB,EAAA;AAAA,IACJ;AAIJ,WAAAd;AAAA,MAAA,MAAAL,EAAA;AAAA,MACgB,OAAAoB,GAAAC,MAAA;AAGR,YADA,MAAAH,EAAA,GACA,CAAAvB,EAAA;AACI;AAEJ,cAAA2B,IAAAF,IAAAC;AACA,QAAArB,EAAA,QAAAb,IACIe,EAAA,QAAA,IAAiCoB,IAEjCL,EAAA,IAEAE,EAAA;AAAA,MACJ;AAAA,MACJ,EAAA,WAAA,GAAA;AAAA,IACkB;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"action-bar.r05wfyni.js","sources":["../../src/components/action-bar/action-bar.vue"],"sourcesContent":["<template>\n <Transition name=\"b-action-bar__animation\" appear>\n <section class=\"b-action-bar\" :class=\"conditionalClasses\" :aria-label=\"t('actionBar')\">\n <div ref=\"actionBar\" class=\"b-action-bar__container\">\n <div v-if=\"!isConfirmationVariant\" class=\"b-action-bar__close-button\">\n <bento-button variant=\"tertiary\" inverse :aria-label=\"t('close')\" @click=\"emit('close')\">\n <template #iconLeft><cross-icon :aria-hidden=\"true\" /></template>\n </bento-button>\n </div>\n <bento-typography el=\"span\" stronger class=\"b-action-bar__selection\">\n {{ itemCounter }} {{ isConfirmationVariant ? tc('unsavedChanges', itemCounter) : label }}\n </bento-typography>\n <bento-button-actions\n v-if=\"isConfirmationVariant\"\n :actions=\"confirmationActions\"\n class=\"b-action-bar__actions\"\n inverse\n />\n <button-actions-with-menu\n v-else\n :actions=\"actionsInternal\"\n class=\"b-action-bar__actions\"\n :displayed-actions=\"internalDisplayedActions\"\n menu-position=\"top-end\"\n inverse\n />\n </div>\n </section>\n </Transition>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, nextTick, PropType, provide, ref, toRefs, watch } from 'vue';\n import { BentoButton, BentoButtonActions, BentoButtonActionsList } from '@/components/button';\n import { BentoTypography } from '@/components/typography';\n\n import { type BentoActionBarVariant } from '@/components/action-bar/action-bar.types';\n import ButtonActionsWithMenu from '@/components/internal/button-actions-with-menu/button-actions-with-menu.vue';\n import CrossIcon from '@adyen/ui-assets-icons-16/vue/cross';\n\n import { useI18n } from '@/utils/ts/i18n';\n import { useWindowSize } from '@vueuse/core';\n\n import messages from './messages.json';\n import { POPOVER_OFFSET_INJECTION_KEY } from '@/components/popover/popover.keys';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n // Constants\n const AVERAGE_BUTTON_SIZE = 100;\n const MENU_OFFSET = 7;\n const RESPONSIVE_BREAKPOINT = 500;\n const SPACING = 32;\n\n const props = defineProps({\n /**\n * List of actions that will be used to render the buttons.\n * Required and used for the `default` variant.\n *\n * Each object in the list should have a `title`, an `event` and,\n * optionally, an `icon`.\n *\n * The component will display 4 actions and the hide the rest inside a menu.\n *\n * @see BentoButton for a list of all the other props supported by each button action.\n */\n actions: {\n type: Array as PropType<BentoButtonActionsList>,\n default: () => [],\n },\n /**\n * How many actions should be visible outside the menu, cannot be more than 4\n */\n visibleActions: {\n type: Number,\n default: 4,\n validator: (value: number) => value > 0 && value <= 4,\n },\n /**\n * Use when there are sticky elements at the bottom, like sticky pagination\n */\n extraBottomSpacing: {\n type: Boolean,\n default: false,\n },\n /**\n * Show how many items are selected\n */\n itemCounter: {\n type: Number,\n required: true,\n },\n /**\n * Label for the selection, e.g. 'selected'/'changed'\n */\n selectionLabel: {\n type: String,\n default: null,\n },\n /**\n * Variant for the action bar\n * @values default, confirmation\n */\n variant: {\n type: String as PropType<BentoActionBarVariant>,\n default: 'default',\n },\n });\n\n const emit = defineEmits([\"close\", \"cancel\", \"save\"]);\n\n const { t, tc } = useI18n<{ message: MessageSchema }>({ messages });\n const label = computed(() => (props.selectionLabel ? props.selectionLabel : t('selected')));\n\n // Refs\n const actionBar = ref<HTMLDivElement>(null);\n const { extraBottomSpacing, visibleActions } = toRefs(props);\n const { width } = useWindowSize();\n const internalDisplayedActions = ref(null);\n const internalVisibleActions = ref(null);\n\n const isConfirmationVariant = computed(() => props.variant === 'confirmation');\n\n watch(\n () => visibleActions.value,\n value => {\n internalVisibleActions.value = value <= 4 ? value : 4;\n internalDisplayedActions.value = internalVisibleActions.value;\n },\n { immediate: true }\n );\n\n // Styling\n const conditionalClasses = computed(() => ({\n 'b-action-bar--extra-spacing': extraBottomSpacing.value,\n 'b-action-bar--confirmation': isConfirmationVariant.value,\n }));\n\n // Provide POPOVER_OFFSET_INJECTION_KEY to change the value of the popover offset\n provide(POPOVER_OFFSET_INJECTION_KEY, MENU_OFFSET);\n\n // Manipulate actions array to display as intended\n const actionsInternal = computed(() => {\n // All buttons should be of type secondary in the action bar\n const actions = props.actions.map(action => ({\n ...action,\n variant: 'secondary',\n })) as BentoButtonActionsList;\n // Shown actions should display from left to right in action bar, instead of right to left which is the button actions default\n const shownActions = actions.slice(0, internalDisplayedActions.value).reverse();\n const hiddenActions = actions.slice(internalDisplayedActions.value);\n\n return [...shownActions, ...hiddenActions];\n });\n\n const confirmationActions = computed<BentoButtonActionsList>(() => [\n {\n title: t('save'),\n event: () => emit('save'),\n },\n {\n title: t('cancel'),\n variant: 'secondary',\n event: () => emit('cancel'),\n },\n ]);\n\n // Recursive functions to determine how many actions should be visible/hidden based on the screens width\n const showActions = async () => {\n await nextTick();\n if (\n width.value > actionBar.value.clientWidth + SPACING + AVERAGE_BUTTON_SIZE &&\n internalDisplayedActions.value < internalVisibleActions.value\n ) {\n internalDisplayedActions.value += 1;\n showActions();\n }\n };\n\n const hideActions = async () => {\n await nextTick();\n if (width.value < actionBar.value.clientWidth + SPACING && internalDisplayedActions.value > 0) {\n internalDisplayedActions.value -= 1;\n hideActions();\n }\n };\n\n // Screen width watcher to toggle hidden/visible actions\n watch(\n () => width.value,\n async (newValue, oldValue) => {\n await nextTick();\n if (!actionBar.value) {\n return;\n }\n const isIncreasing = newValue > oldValue;\n if (width.value < RESPONSIVE_BREAKPOINT) {\n internalDisplayedActions.value = 0;\n } else if (isIncreasing) {\n showActions();\n } else {\n hideActions();\n }\n },\n { immediate: true }\n );\n</script>\n\n<script lang=\"ts\">\n /**\n * Action bar is a floating bar that provides users with quick access to key actions that can be applied to one or multiple items.\n *\n * @example\n * import { BentoActionBar } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoActionBar },\n * template: `\n * <bento-action-bar\n * :actions='[\n * {\n * title: 'Delete',\n * critical: true,\n * icon: BinIcon,\n * event: () => true,\n * },\n * {\n * title: 'Edit',\n * icon: EditIcon,\n * event: () => true,\n * }\n * ]'\n * @close=\"closeAction\"\n * :item-counter=\"5\"\n * />\n * `\n * }\n */\n export default {\n i18n: { messages },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./action-bar.scss\" />\n"],"names":["__default__","messages","AVERAGE_BUTTON_SIZE","MENU_OFFSET","RESPONSIVE_BREAKPOINT","SPACING","t","tc","useI18n","label","computed","props","actionBar","ref","extraBottomSpacing","visibleActions","toRefs","width","useWindowSize","internalDisplayedActions","internalVisibleActions","isConfirmationVariant","watch","value","conditionalClasses","provide","POPOVER_OFFSET_INJECTION_KEY","actionsInternal","actions","action","shownActions","hiddenActions","confirmationActions","emit","showActions","nextTick","hideActions","newValue","oldValue","isIncreasing"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8OIA,IAAA;AAAA,EAAe,MAAA,EAAA,UAAAC,EAAA;AAEf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA/LAC,IAAA,KACAC,IAAA,GACAC,IAAA,KACAC,IAAA,IA2DA,EAAA,GAAAC,GAAA,IAAAC,EAAA,IAAAC,EAAA,GACAC,IAAAC,EAAA,MAAAC,EAAA,iBAAAA,EAAA,iBAAAL,EAAA,UAAA,CAAA,GAGAM,IAAAC,EAAA,IAA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A;AAAA,IACJ,GAGJE,IAAA,YAAA;AACI,YAAAD,EAAA,GACAlB,EAAA,QAAAL,EAAA,MAAA,cAAAP,KAAAc,EAAA,QAAA,MACIA,EAAA,SAAA,GACAiB,EAAA;AAAA,IACJ;AAIJ,WAAAd;AAAA,MAAA,MAAAL,EAAA;AAAA,MACgB,OAAAoB,GAAAC,MAAA;AAGR,YADA,MAAAH,EAAA,GACA,CAAAvB,EAAA;AACI;AAEJ,cAAA2B,IAAAF,IAAAC;AACA,QAAArB,EAAA,QAAAb,IACIe,EAAA,QAAA,IAAiCoB,IAEjCL,EAAA,IAEAE,EAAA;AAAA,MACJ;AAAA,MACJ,EAAA,WAAA,GAAA;AAAA,IACkB;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent as j, ref as d, computed as l, shallowRef as x, onMounted as R, watch as D, watchEffect as J } from "vue";
|
|
2
2
|
import { s as P, H as V, t as n, j as G, x as $, a as U, b as W, p as z, E as F, h as X, k as Y, i as K, c as L, d as N, l as q, e as Q, C as h } from "./codemirror.BlV6WO5w.js";
|
|
3
|
-
import { B as Z, a as ee, b as te, c as ne } from "./es6.
|
|
3
|
+
import { B as Z, a as ee, b as te, c as ne } from "./es6.b4enG1py.js";
|
|
4
4
|
import { B as ae } from "./dropdown.D8xKm1YA.js";
|
|
5
5
|
import { B as oe } from "./button.CufUNBkv.js";
|
|
6
6
|
import { B as se } from "./typography.Bu_WAKdf.js";
|
|
@@ -312,4 +312,4 @@ export {
|
|
|
312
312
|
r as b,
|
|
313
313
|
De as c
|
|
314
314
|
};
|
|
315
|
-
//# sourceMappingURL=code-snippet.
|
|
315
|
+
//# sourceMappingURL=code-snippet.DRH4X9pH.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-snippet.CmBhucys.js","sources":["../../src/components/code-snippet/highlight.ts","../../src/components/code-snippet/code-snippet.types.ts","../../src/components/code-snippet/utils/get-lang-loader.ts","../../src/components/code-snippet/utils/indent-same-as-line-before-extension.ts","../../src/components/code-snippet/code-snippet.vue"],"sourcesContent":["import { HighlightStyle, syntaxHighlighting } from '@codemirror/language';\nimport { tags as t } from '@lezer/highlight';\nimport {\n BCodeSnippetCodeAreaHighlightBlue,\n BCodeSnippetCodeAreaHighlightGreen,\n BCodeSnippetCodeAreaHighlightOrange,\n BCodeSnippetCodeAreaHighlightRed,\n} from '@adyen/bento-design-tokens/dist/js/bento/es6';\nimport { BentoCodeSnippetSupportedLanguage } from './code-snippet.types';\n\nconst lightThemeColors = {\n red: BCodeSnippetCodeAreaHighlightRed,\n orange: BCodeSnippetCodeAreaHighlightOrange,\n green: BCodeSnippetCodeAreaHighlightGreen,\n blue: BCodeSnippetCodeAreaHighlightBlue,\n invalid: '#ffffff',\n};\n\nconst highlightStyle = (colors, language: BentoCodeSnippetSupportedLanguage | `${BentoCodeSnippetSupportedLanguage}`) =>\n HighlightStyle.define([\n {\n tag: t.keyword,\n color: colors.red,\n },\n {\n tag: [t.name, t.deleted, t.character, t.propertyName, t.macroName],\n color: colors.green,\n },\n {\n tag: [t.function(t.variableName), t.labelName],\n color: colors.blue,\n },\n {\n tag: [t.color, t.constant(t.name), t.standard(t.name)],\n color: colors.red,\n },\n {\n tag: [t.definition(t.name), ...(language !== 'json' ? [t.separator] : [])],\n color: colors.red,\n },\n {\n tag: [t.typeName, t.className, t.number, t.changed, t.annotation, t.modifier, t.self, t.namespace],\n color: colors.orange,\n },\n {\n tag: [t.operator, t.operatorKeyword, t.url, t.escape, t.regexp, t.link, t.special(t.string)],\n color: colors.blue,\n },\n {\n tag: [t.meta, t.comment],\n color: colors.orange,\n },\n {\n tag: t.strong,\n fontWeight: 'bold',\n },\n {\n tag: t.emphasis,\n fontStyle: 'italic',\n },\n {\n tag: t.strikethrough,\n textDecoration: 'line-through',\n },\n {\n tag: t.link,\n color: colors.orange,\n textDecoration: 'underline',\n },\n {\n tag: t.heading,\n fontWeight: 'bold',\n color: colors.blue,\n },\n {\n tag: [t.atom, t.bool, t.special(t.variableName)],\n color: colors.red,\n },\n {\n tag: [t.processingInstruction, t.string, t.inserted],\n color: colors.blue,\n },\n {\n tag: t.invalid,\n color: colors.invalid,\n },\n ]);\n\nexport const lightThemeHighlight = (\n language: BentoCodeSnippetSupportedLanguage | `${BentoCodeSnippetSupportedLanguage}`\n) => syntaxHighlighting(highlightStyle(lightThemeColors, language));\n","/**\n * @deprecated for usage with properties since version 2.0. Use the string literal instead.\n */\nexport enum BentoCodeSnippetVariant {\n INLINE = 'inline',\n SINGLELINE = 'singleline',\n MULTILINE = 'multiline',\n}\n\n// These supported types need to be kept in line with the ones in packages/vue2/src/components/code-snippet/composables/useLanguage.ts function and vice-versa\n/**\n * @deprecated for usage with properties since version 2.0. Use the string literal instead.\n */\nexport enum BentoCodeSnippetSupportedLanguage {\n JSON = 'json',\n XML = 'xml',\n JAVA = 'java',\n JAVASCRIPT = 'javascript',\n PYTHON = 'python',\n}\n\nexport enum BentoCodeSnippetEvent {\n ACTION = 'action',\n CHANGE = 'change',\n}\n","import { BentoCodeSnippetSupportedLanguage } from '@/components/code-snippet/code-snippet.types';\nimport { json } from '@codemirror/lang-json';\nimport { xml } from '@codemirror/lang-xml';\nimport { javascript } from '@codemirror/lang-javascript';\nimport { java } from '@codemirror/lang-java';\nimport { python } from '@codemirror/lang-python';\n\n/**\n * TODO: This should be handled with dynamic imports,\n * without relying on importing every single language/package available.\n * These supported types need to be kept in line with the ones in packages/vue2/src/components/code-snippet/code-snippet.types.ts enum\n */\nconst importsMap = {\n [BentoCodeSnippetSupportedLanguage.JSON]: json,\n [BentoCodeSnippetSupportedLanguage.XML]: xml,\n [BentoCodeSnippetSupportedLanguage.JAVASCRIPT]: javascript,\n [BentoCodeSnippetSupportedLanguage.JAVA]: java,\n [BentoCodeSnippetSupportedLanguage.PYTHON]: python,\n};\n\n/**\n * Returns a language loder for `CodeMirror`.\n * Supported languages: json, xml, javascript & java\n *\n * @param language Language to be used\n * @returns Language configuration loader to be used in codemirror\n */\nexport const getLangLoader = (language: BentoCodeSnippetSupportedLanguage | `${BentoCodeSnippetSupportedLanguage}`) => {\n const loadLang = async () => importsMap[language];\n\n return loadLang;\n};\n","import { EditorSelection, type EditorState, type SelectionRange } from '@codemirror/state';\n\n/**\n * Calculate indentation for a new line based on line before it.\n * @param state - The editor state\n * @param line - the selection range, in this case one line\n * @returns the indentation string to be pre-pended on a new line.\n */\nconst getIndentation = (state: EditorState, line: SelectionRange) => {\n const currentLine = state.doc.lineAt(line.from);\n const indentMatch = /^\\s*/.exec(currentLine.text);\n return indentMatch ? indentMatch[0] : '';\n};\n\n/**\n * This extension to codemirror will, upon pressing the 'Enter' key, indent the new line\n * the same as the line before it.\n */\nexport const INDENT_SAME_AS_LINE_BEFORE = {\n key: 'Enter',\n run: ({ state, dispatch }) => {\n const changes = state.changeByRange(range => {\n const indentation = getIndentation(state, range);\n const newText = `\\n${indentation}`;\n return {\n changes: { from: range.from, to: range.to, insert: newText },\n range: EditorSelection.cursor(range.from + newText.length),\n };\n });\n dispatch(state.update(changes, { scrollIntoView: true, userEvent: 'input' }));\n return true;\n },\n};\n\nexport default INDENT_SAME_AS_LINE_BEFORE;\n","<template>\n <div class=\"b-code-snippet\" :class=\"conditionalClasses\">\n <section v-if=\"!isInlineVariant\" class=\"b-code-snippet__action-bar\">\n <div class=\"b-code-snippet__action-bar--start\">\n <bento-dropdown\n v-if=\"availableLanguages.length > 0\"\n v-model=\"selectedLanguage\"\n v-bind=\"$props\"\n :disabled=\"availableLanguages.length === 1\"\n :items=\"availableLanguages\"\n class=\"b-code-snippet__language-picker\"\n @input=\"handleChangeLanguage\"\n />\n <bento-typography el=\"span\" stronger>\n {{ displayedLang }}\n </bento-typography>\n </div>\n <div class=\"b-code-snippet__action-bar--end\">\n <bento-loading-indicator v-if=\"loading\" />\n <copy v-if=\"currentContents !== null\" class=\"b-structured-list__icon\" :text=\"currentContents\" />\n <bento-button\n v-if=\"expandable\"\n variant=\"tertiary\"\n condensed\n :aria-label=\"t('expand')\"\n @click=\"showModal = true\"\n >\n <template #iconLeft>\n <expand-icon />\n </template>\n </bento-button>\n <bento-button v-if=\"actionable\" variant=\"primary\" tertiary condensed @click=\"onActionClicked\">\n <template #iconLeft>\n <bento-typography el=\"span\" class=\"b-code-snippet__action-button\">\n {{ runText }}\n </bento-typography>\n </template>\n </bento-button>\n </div>\n </section>\n <code v-if=\"content || editable\" class=\"b-code-snippet__code-area\">\n <div ref=\"container\" class=\"b-code-snippet__code-area-content\" :class=\"codeAreaContentConditionalClasses\" />\n </code>\n <section v-else>\n <slot name=\"empty-state\">\n <!-- TODO: switch with empty-state component when ready -->\n <div class=\"b-code-snippet__empty-state\">{{ t('nothingToDisplay') }}</div>\n </slot>\n </section>\n <base-modal\n v-if=\"expandable\"\n class=\"b-code-snippet__modal\"\n :hide-close-button=\"true\"\n :custom-padding=\"'0px'\"\n :is-dismissible=\"true\"\n :is-open=\"showModal\"\n size=\"large\"\n @close-modal=\"showModal = false\"\n >\n <template #content>\n <bento-code-snippet v-bind=\"{ ...$props, expandable: false }\" />\n </template>\n </base-modal>\n </div>\n</template>\n\n<script lang=\"ts\">\n import { computed, defineComponent, onMounted, PropType, ref, shallowRef, watch, watchEffect } from 'vue';\n import { EditorView, highlightActiveLine, keymap, lineNumbers } from '@codemirror/view';\n import { Compartment, EditorState } from '@codemirror/state';\n import { history, indentWithTab } from '@codemirror/commands';\n import { lightThemeHighlight } from './highlight';\n import { getLangLoader, INDENT_SAME_AS_LINE_BEFORE } from './utils';\n import { BentoDropdown } from '@/components/dropdown';\n import { BentoButton } from '@/components/button';\n import { BentoTypography } from '@/components/typography';\n import { BentoTooltipDirective } from '@/directives';\n import { BentoLoadingIndicator } from '@/components/loading-indicator';\n import { useI18n } from '@/utils/ts/i18n';\n import { Copy } from '@/internal';\n import ExpandIcon from '@adyen/ui-assets-icons-16/vue/expand';\n import {\n BentoCodeSnippetEvent,\n BentoCodeSnippetSupportedLanguage,\n BentoCodeSnippetVariant,\n } from '@/components/code-snippet/code-snippet.types';\n import BaseModal from '@/components/modal/components/base-modal/base-modal.vue';\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n /**\n * A code-snippet is a container to display code in a readable way.\n * Come with added functionalities like syntax highlighting, editing and actioning the code\n *\n * @example\n * import { BentoCodeSnippet } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoCodeSnippet },\n * template: `\n * <bento-code-snippet :variant=\"BentoCodeSnippetVariant.MULTILINE\" content=\"{ example: 1234 }\" />\n * `\n * }\n */\n export default defineComponent({\n i18n: { messages },\n name: 'bento-code-snippet',\n components: {\n BentoTypography,\n BentoButton,\n BentoDropdown,\n Copy,\n BaseModal,\n BentoLoadingIndicator,\n ExpandIcon,\n },\n directives: { BentoTooltipDirective },\n props: {\n /**\n * Defines the variant of code-snippet\n */\n variant: {\n type: String as PropType<BentoCodeSnippetVariant | `${BentoCodeSnippetVariant}`>,\n default: BentoCodeSnippetVariant.MULTILINE,\n validator: (value: BentoCodeSnippetVariant) => Object.values(BentoCodeSnippetVariant).includes(value),\n },\n /**\n * Language name for syntax highlighting rules\n */\n lang: {\n type: String as PropType<BentoCodeSnippetSupportedLanguage | `${BentoCodeSnippetSupportedLanguage}`>,\n default: BentoCodeSnippetSupportedLanguage.JSON,\n validator: (value: BentoCodeSnippetSupportedLanguage) =>\n Object.values(BentoCodeSnippetSupportedLanguage).includes(value),\n },\n /**\n * Label to show in the action-bar, describing the language\n */\n langLabel: {\n type: String,\n default: null,\n },\n /**\n * The code content\n */\n content: {\n type: String,\n default: '',\n },\n /**\n * Allows editing of the code-snippet content by the user\n */\n editable: {\n type: Boolean,\n default: false,\n },\n /**\n * Displays a button that when clicked will emit an action event\n * Leaves to the parent component the logic of what to do with it\n */\n actionable: {\n type: Boolean,\n default: false,\n },\n /**\n * Displays a button that can expand the codeblock into a modal to easily\n * view large blocks of code.\n */\n expandable: {\n type: Boolean,\n default: false,\n },\n /**\n * Displays a button that when clicked will emit a run event\n * Leaves to the parent component the logic of what to do with it\n */\n actionableText: {\n type: String,\n default: 'run',\n },\n /**\n * Toggles the loading indicator within the action bar\n */\n loading: {\n type: Boolean,\n default: false,\n },\n },\n emits: [BentoCodeSnippetEvent.ACTION, BentoCodeSnippetEvent.CHANGE],\n setup(props, { emit }) {\n const { t } = useI18n<{ message: MessageSchema }>({ messages });\n\n // language\n const selectedLanguage = ref<string | null>(null);\n const availableLanguages = []; // TODO: implement\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n const handleChangeLanguage = () => {};\n const displayedLang = computed(() => props.langLabel ?? props.lang.toUpperCase());\n\n const isInlineVariant = computed(() => props.variant === BentoCodeSnippetVariant.INLINE);\n\n const conditionalClasses = computed(() => ({\n 'b-code-snippet--inline': isInlineVariant.value,\n 'b-code-snippet--scrollable': !isInlineVariant.value,\n }));\n\n const codeAreaContentConditionalClasses = computed(() => ({\n 'b-code-snippet__code-area-content--editable': props.editable,\n }));\n\n const loadLang = getLangLoader(props.lang);\n\n const container = shallowRef<HTMLDivElement>();\n const editor = shallowRef<EditorView>();\n const languageConf = new Compartment();\n const editorTheme = new Compartment();\n const editorReadOnly = new Compartment();\n\n const currentContents = ref(null);\n const contentLength = ref(0);\n\n onMounted(async () => {\n const language = await loadLang();\n\n // alongside the updateListener plugin it acts as a watcher of changes to the editor state\n currentContents.value = props.content;\n const updateCurrentContents = ({ state }) => {\n currentContents.value = state.doc.toString();\n };\n\n const extensions = [\n highlightActiveLine(),\n keymap.of([indentWithTab, INDENT_SAME_AS_LINE_BEFORE]),\n languageConf.of(language()),\n editorTheme.of(lightThemeHighlight(props.lang)),\n\n editorReadOnly.of(EditorState.readOnly.of(!props.editable)),\n EditorView.updateListener.of(content => updateCurrentContents(content)),\n ];\n\n if (props.variant === 'multiline') {\n extensions.push([lineNumbers(), history()]);\n }\n\n const state = EditorState.create({\n doc: props.content,\n extensions: [...extensions],\n });\n contentLength.value = state.doc.length;\n\n editor.value = new EditorView({\n state,\n parent: container.value,\n });\n });\n watch(\n () => props.content,\n () => {\n if (props.content !== currentContents.value) {\n const upcomingContentLength = props.content.length;\n editor.value.dispatch({\n changes: {\n from: 0,\n to: contentLength.value,\n insert: props.content,\n },\n });\n contentLength.value = upcomingContentLength;\n }\n }\n );\n\n const runText = computed(() => t(props.actionableText as 'run'));\n const onActionClicked = () => {\n emit(BentoCodeSnippetEvent.ACTION, currentContents.value);\n };\n\n watchEffect(() => {\n if (currentContents.value !== null) {\n emit(BentoCodeSnippetEvent.CHANGE, currentContents.value);\n }\n });\n\n const showModal = ref(false);\n\n return {\n // Values\n availableLanguages,\n codeAreaContentConditionalClasses,\n conditionalClasses,\n container,\n currentContents,\n displayedLang,\n editor,\n selectedLanguage,\n showModal,\n isInlineVariant,\n\n // Methods\n handleChangeLanguage,\n onActionClicked,\n runText,\n\n // Translations\n t,\n };\n },\n });\n</script>\n\n<style lang=\"scss\" scoped src=\"./code-snippet.scss\"></style>\n"],"names":["lightThemeColors","BCodeSnippetCodeAreaHighlightRed","BCodeSnippetCodeAreaHighlightOrange","BCodeSnippetCodeAreaHighlightGreen","BCodeSnippetCodeAreaHighlightBlue","highlightStyle","colors","language","HighlightStyle","tags","lightThemeHighlight","syntaxHighlighting","BentoCodeSnippetVariant","BentoCodeSnippetVariant2","BentoCodeSnippetSupportedLanguage","BentoCodeSnippetSupportedLanguage2","BentoCodeSnippetEvent","BentoCodeSnippetEvent2","importsMap","json","xml","javascript","java","python","getLangLoader","getIndentation","state","line","currentLine","indentMatch","INDENT_SAME_AS_LINE_BEFORE","dispatch","changes","range","newText","EditorSelection","_sfc_main","defineComponent","messages","BentoTypography","BentoButton","BentoDropdown","Copy","BaseModal","BentoLoadingIndicator","ExpandIcon","BentoTooltipDirective","value","props","emit","t","useI18n","selectedLanguage","ref","availableLanguages","handleChangeLanguage","displayedLang","computed","isInlineVariant","conditionalClasses","codeAreaContentConditionalClasses","loadLang","container","shallowRef","editor","languageConf","Compartment","editorTheme","editorReadOnly","currentContents","contentLength","onMounted","updateCurrentContents","state2","extensions","highlightActiveLine","keymap","indentWithTab","EditorState","EditorView","content","lineNumbers","history","watch","upcomingContentLength","runText","onActionClicked","watchEffect","showModal"],"mappings":";;;;;;;;;;;;;;AAUA,MAAAA,KAAA;AAAA,EAAyB,KAAAC;AAAA,EAChB,QAAAC;AAAA,EACG,OAAAC;AAAA,EACD,MAAAC;AAAA,EACD,SAAA;AAEV,GAEAC,KAAA,CAAAC,GAAAC,MAAAC,EAAA,OAAA;AAAA,EAC0B;AAAA,IAClB,KAAAC,EAAA;AAAA,IACW,OAAAH,EAAA;AAAA,EACO;AAAA,EAClB;AAAA,IACA,KAAA,CAAAG,EAAA,MAAAA,EAAA,SAAAA,EAAA,WAAAA,EAAA,cAAAA,EAAA,SAAA;AAAA,IACqE,OAAAH,EAAA;AAAA,EACnD;AAAA,EAClB;AAAA,IACA,KAAA,CAAAG,EAAA,SAAAA,EAAA,YAAA,GAAAA,EAAA,SAAA;AAAA,IACiD,OAAAH,EAAA;AAAA,EAC/B;AAAA,EAClB;AAAA,IACA,KAAA,CAAAG,EAAA,OAAAA,EAAA,SAAAA,EAAA,IAAA,GAAAA,EAAA,SAAAA,EAAA,IAAA,CAAA;AAAA,IACyD,OAAAH,EAAA;AAAA,EACvC;AAAA,EAClB;AAAA,IACA,KAAA,CAAAG,EAAA,WAAAA,EAAA,IAAA,GAAA,GAAAF,MAAA,SAAA,CAAAE,EAAA,SAAA,IAAA,CAAA,CAAA;AAAA,IAC6E,OAAAH,EAAA;AAAA,EAC3D;AAAA,EAClB;AAAA,IACA,KAAA,CAAAG,EAAA,UAAAA,EAAA,WAAAA,EAAA,QAAAA,EAAA,SAAAA,EAAA,YAAAA,EAAA,UAAAA,EAAA,MAAAA,EAAA,SAAA;AAAA,IACqG,OAAAH,EAAA;AAAA,EACnF;AAAA,EAClB;AAAA,IACA,KAAA,CAAAG,EAAA,UAAAA,EAAA,iBAAAA,EAAA,KAAAA,EAAA,QAAAA,EAA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EAAA,QAAA,IAAAe,EAAA;AAAA,QAAA,OAAArD;AAAA,QACA,QAAAoC,EAAA;AAAA,MACA,CAAA;AAAA,IACA,CAAA,GAEAqB;AAAA,MAAA,MAAAnC,EAAA;AAAA,MACA,MAAA;AAEA,YAAAA,EAAA,YAAAqB,EAAA,OAAA;AACA,gBAAAe,IAAApC,EAAA,QAAA;AACA,UAAAgB,EAAA,MAAA,SAAA;AAAA,YAAA,SAAA;AAAA,cACA,MAAA;AAAA,cACA,IAAAM,EAAA;AAAA,cACA,QAAAtB,EAAA;AAAA,YACA;AAAA,UACA,CAAA,GAEAsB,EAAA,QAAAc;AAAA,QAAA;AAAA,MACA;AAAA,IACA;AAGA,UAAAC,IAAA5B,EAAA,MAAAP,EAAAF,EAAA,cAAA,CAAA,GACAsC,IAAA,MAAA;AACA,MAAArC,EAAAjC,EAAA,QAAAqD,EAAA,KAAA;AAAA,IAAA;AAGA,IAAAkB,EAAA,MAAA;AACA,MAAAlB,EAAA,UAAA,QACApB,EAAAjC,EAAA,QAAAqD,EAAA,KAAA;AAAA,IACA,CAAA;AAGA,UAAAmB,IAAAnC,EAAA,EAAA;AAEA,WAAA;AAAA;AAAA,MAAA,oBAAAC;AAAA,MAEA,mCAAAM;AAAA,MACA,oBAAAD;AAAA,MACA,WAAAG;AAAA,MACA,iBAAAO;AAAA,MACA,eAAAb;AAAA,MACA,QAAAQ;AAAA,MACA,kBAAAZ;AAAA,MACA,WAAAoC;AAAA,MACA,iBAAA9B;AAAA;AAAA,MACA,sBAAAH;AAAA,MAGA,iBAAA+B;AAAA,MACA,SAAAD;AAAA;AAAA,MACA,GAAAnC;AAAA,IAGA;AAAA,EACA;AAEA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"code-snippet.DRH4X9pH.js","sources":["../../src/components/code-snippet/highlight.ts","../../src/components/code-snippet/code-snippet.types.ts","../../src/components/code-snippet/utils/get-lang-loader.ts","../../src/components/code-snippet/utils/indent-same-as-line-before-extension.ts","../../src/components/code-snippet/code-snippet.vue"],"sourcesContent":["import { HighlightStyle, syntaxHighlighting } from '@codemirror/language';\nimport { tags as t } from '@lezer/highlight';\nimport {\n BCodeSnippetCodeAreaHighlightBlue,\n BCodeSnippetCodeAreaHighlightGreen,\n BCodeSnippetCodeAreaHighlightOrange,\n BCodeSnippetCodeAreaHighlightRed,\n} from '@adyen/bento-design-tokens/dist/js/bento/es6';\nimport { BentoCodeSnippetSupportedLanguage } from './code-snippet.types';\n\nconst lightThemeColors = {\n red: BCodeSnippetCodeAreaHighlightRed,\n orange: BCodeSnippetCodeAreaHighlightOrange,\n green: BCodeSnippetCodeAreaHighlightGreen,\n blue: BCodeSnippetCodeAreaHighlightBlue,\n invalid: '#ffffff',\n};\n\nconst highlightStyle = (colors, language: BentoCodeSnippetSupportedLanguage | `${BentoCodeSnippetSupportedLanguage}`) =>\n HighlightStyle.define([\n {\n tag: t.keyword,\n color: colors.red,\n },\n {\n tag: [t.name, t.deleted, t.character, t.propertyName, t.macroName],\n color: colors.green,\n },\n {\n tag: [t.function(t.variableName), t.labelName],\n color: colors.blue,\n },\n {\n tag: [t.color, t.constant(t.name), t.standard(t.name)],\n color: colors.red,\n },\n {\n tag: [t.definition(t.name), ...(language !== 'json' ? [t.separator] : [])],\n color: colors.red,\n },\n {\n tag: [t.typeName, t.className, t.number, t.changed, t.annotation, t.modifier, t.self, t.namespace],\n color: colors.orange,\n },\n {\n tag: [t.operator, t.operatorKeyword, t.url, t.escape, t.regexp, t.link, t.special(t.string)],\n color: colors.blue,\n },\n {\n tag: [t.meta, t.comment],\n color: colors.orange,\n },\n {\n tag: t.strong,\n fontWeight: 'bold',\n },\n {\n tag: t.emphasis,\n fontStyle: 'italic',\n },\n {\n tag: t.strikethrough,\n textDecoration: 'line-through',\n },\n {\n tag: t.link,\n color: colors.orange,\n textDecoration: 'underline',\n },\n {\n tag: t.heading,\n fontWeight: 'bold',\n color: colors.blue,\n },\n {\n tag: [t.atom, t.bool, t.special(t.variableName)],\n color: colors.red,\n },\n {\n tag: [t.processingInstruction, t.string, t.inserted],\n color: colors.blue,\n },\n {\n tag: t.invalid,\n color: colors.invalid,\n },\n ]);\n\nexport const lightThemeHighlight = (\n language: BentoCodeSnippetSupportedLanguage | `${BentoCodeSnippetSupportedLanguage}`\n) => syntaxHighlighting(highlightStyle(lightThemeColors, language));\n","/**\n * @deprecated for usage with properties since version 2.0. Use the string literal instead.\n */\nexport enum BentoCodeSnippetVariant {\n INLINE = 'inline',\n SINGLELINE = 'singleline',\n MULTILINE = 'multiline',\n}\n\n// These supported types need to be kept in line with the ones in packages/vue2/src/components/code-snippet/composables/useLanguage.ts function and vice-versa\n/**\n * @deprecated for usage with properties since version 2.0. Use the string literal instead.\n */\nexport enum BentoCodeSnippetSupportedLanguage {\n JSON = 'json',\n XML = 'xml',\n JAVA = 'java',\n JAVASCRIPT = 'javascript',\n PYTHON = 'python',\n}\n\nexport enum BentoCodeSnippetEvent {\n ACTION = 'action',\n CHANGE = 'change',\n}\n","import { BentoCodeSnippetSupportedLanguage } from '@/components/code-snippet/code-snippet.types';\nimport { json } from '@codemirror/lang-json';\nimport { xml } from '@codemirror/lang-xml';\nimport { javascript } from '@codemirror/lang-javascript';\nimport { java } from '@codemirror/lang-java';\nimport { python } from '@codemirror/lang-python';\n\n/**\n * TODO: This should be handled with dynamic imports,\n * without relying on importing every single language/package available.\n * These supported types need to be kept in line with the ones in packages/vue2/src/components/code-snippet/code-snippet.types.ts enum\n */\nconst importsMap = {\n [BentoCodeSnippetSupportedLanguage.JSON]: json,\n [BentoCodeSnippetSupportedLanguage.XML]: xml,\n [BentoCodeSnippetSupportedLanguage.JAVASCRIPT]: javascript,\n [BentoCodeSnippetSupportedLanguage.JAVA]: java,\n [BentoCodeSnippetSupportedLanguage.PYTHON]: python,\n};\n\n/**\n * Returns a language loder for `CodeMirror`.\n * Supported languages: json, xml, javascript & java\n *\n * @param language Language to be used\n * @returns Language configuration loader to be used in codemirror\n */\nexport const getLangLoader = (language: BentoCodeSnippetSupportedLanguage | `${BentoCodeSnippetSupportedLanguage}`) => {\n const loadLang = async () => importsMap[language];\n\n return loadLang;\n};\n","import { EditorSelection, type EditorState, type SelectionRange } from '@codemirror/state';\n\n/**\n * Calculate indentation for a new line based on line before it.\n * @param state - The editor state\n * @param line - the selection range, in this case one line\n * @returns the indentation string to be pre-pended on a new line.\n */\nconst getIndentation = (state: EditorState, line: SelectionRange) => {\n const currentLine = state.doc.lineAt(line.from);\n const indentMatch = /^\\s*/.exec(currentLine.text);\n return indentMatch ? indentMatch[0] : '';\n};\n\n/**\n * This extension to codemirror will, upon pressing the 'Enter' key, indent the new line\n * the same as the line before it.\n */\nexport const INDENT_SAME_AS_LINE_BEFORE = {\n key: 'Enter',\n run: ({ state, dispatch }) => {\n const changes = state.changeByRange(range => {\n const indentation = getIndentation(state, range);\n const newText = `\\n${indentation}`;\n return {\n changes: { from: range.from, to: range.to, insert: newText },\n range: EditorSelection.cursor(range.from + newText.length),\n };\n });\n dispatch(state.update(changes, { scrollIntoView: true, userEvent: 'input' }));\n return true;\n },\n};\n\nexport default INDENT_SAME_AS_LINE_BEFORE;\n","<template>\n <div class=\"b-code-snippet\" :class=\"conditionalClasses\">\n <section v-if=\"!isInlineVariant\" class=\"b-code-snippet__action-bar\">\n <div class=\"b-code-snippet__action-bar--start\">\n <bento-dropdown\n v-if=\"availableLanguages.length > 0\"\n v-model=\"selectedLanguage\"\n v-bind=\"$props\"\n :disabled=\"availableLanguages.length === 1\"\n :items=\"availableLanguages\"\n class=\"b-code-snippet__language-picker\"\n @input=\"handleChangeLanguage\"\n />\n <bento-typography el=\"span\" stronger>\n {{ displayedLang }}\n </bento-typography>\n </div>\n <div class=\"b-code-snippet__action-bar--end\">\n <bento-loading-indicator v-if=\"loading\" />\n <copy v-if=\"currentContents !== null\" class=\"b-structured-list__icon\" :text=\"currentContents\" />\n <bento-button\n v-if=\"expandable\"\n variant=\"tertiary\"\n condensed\n :aria-label=\"t('expand')\"\n @click=\"showModal = true\"\n >\n <template #iconLeft>\n <expand-icon />\n </template>\n </bento-button>\n <bento-button v-if=\"actionable\" variant=\"primary\" tertiary condensed @click=\"onActionClicked\">\n <template #iconLeft>\n <bento-typography el=\"span\" class=\"b-code-snippet__action-button\">\n {{ runText }}\n </bento-typography>\n </template>\n </bento-button>\n </div>\n </section>\n <code v-if=\"content || editable\" class=\"b-code-snippet__code-area\">\n <div ref=\"container\" class=\"b-code-snippet__code-area-content\" :class=\"codeAreaContentConditionalClasses\" />\n </code>\n <section v-else>\n <slot name=\"empty-state\">\n <!-- TODO: switch with empty-state component when ready -->\n <div class=\"b-code-snippet__empty-state\">{{ t('nothingToDisplay') }}</div>\n </slot>\n </section>\n <base-modal\n v-if=\"expandable\"\n class=\"b-code-snippet__modal\"\n :hide-close-button=\"true\"\n :custom-padding=\"'0px'\"\n :is-dismissible=\"true\"\n :is-open=\"showModal\"\n size=\"large\"\n @close-modal=\"showModal = false\"\n >\n <template #content>\n <bento-code-snippet v-bind=\"{ ...$props, expandable: false }\" />\n </template>\n </base-modal>\n </div>\n</template>\n\n<script lang=\"ts\">\n import { computed, defineComponent, onMounted, PropType, ref, shallowRef, watch, watchEffect } from 'vue';\n import { EditorView, highlightActiveLine, keymap, lineNumbers } from '@codemirror/view';\n import { Compartment, EditorState } from '@codemirror/state';\n import { history, indentWithTab } from '@codemirror/commands';\n import { lightThemeHighlight } from './highlight';\n import { getLangLoader, INDENT_SAME_AS_LINE_BEFORE } from './utils';\n import { BentoDropdown } from '@/components/dropdown';\n import { BentoButton } from '@/components/button';\n import { BentoTypography } from '@/components/typography';\n import { BentoTooltipDirective } from '@/directives';\n import { BentoLoadingIndicator } from '@/components/loading-indicator';\n import { useI18n } from '@/utils/ts/i18n';\n import { Copy } from '@/internal';\n import ExpandIcon from '@adyen/ui-assets-icons-16/vue/expand';\n import {\n BentoCodeSnippetEvent,\n BentoCodeSnippetSupportedLanguage,\n BentoCodeSnippetVariant,\n } from '@/components/code-snippet/code-snippet.types';\n import BaseModal from '@/components/modal/components/base-modal/base-modal.vue';\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n /**\n * A code-snippet is a container to display code in a readable way.\n * Come with added functionalities like syntax highlighting, editing and actioning the code\n *\n * @example\n * import { BentoCodeSnippet } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoCodeSnippet },\n * template: `\n * <bento-code-snippet :variant=\"BentoCodeSnippetVariant.MULTILINE\" content=\"{ example: 1234 }\" />\n * `\n * }\n */\n export default defineComponent({\n i18n: { messages },\n name: 'bento-code-snippet',\n components: {\n BentoTypography,\n BentoButton,\n BentoDropdown,\n Copy,\n BaseModal,\n BentoLoadingIndicator,\n ExpandIcon,\n },\n directives: { BentoTooltipDirective },\n props: {\n /**\n * Defines the variant of code-snippet\n */\n variant: {\n type: String as PropType<BentoCodeSnippetVariant | `${BentoCodeSnippetVariant}`>,\n default: BentoCodeSnippetVariant.MULTILINE,\n validator: (value: BentoCodeSnippetVariant) => Object.values(BentoCodeSnippetVariant).includes(value),\n },\n /**\n * Language name for syntax highlighting rules\n */\n lang: {\n type: String as PropType<BentoCodeSnippetSupportedLanguage | `${BentoCodeSnippetSupportedLanguage}`>,\n default: BentoCodeSnippetSupportedLanguage.JSON,\n validator: (value: BentoCodeSnippetSupportedLanguage) =>\n Object.values(BentoCodeSnippetSupportedLanguage).includes(value),\n },\n /**\n * Label to show in the action-bar, describing the language\n */\n langLabel: {\n type: String,\n default: null,\n },\n /**\n * The code content\n */\n content: {\n type: String,\n default: '',\n },\n /**\n * Allows editing of the code-snippet content by the user\n */\n editable: {\n type: Boolean,\n default: false,\n },\n /**\n * Displays a button that when clicked will emit an action event\n * Leaves to the parent component the logic of what to do with it\n */\n actionable: {\n type: Boolean,\n default: false,\n },\n /**\n * Displays a button that can expand the codeblock into a modal to easily\n * view large blocks of code.\n */\n expandable: {\n type: Boolean,\n default: false,\n },\n /**\n * Displays a button that when clicked will emit a run event\n * Leaves to the parent component the logic of what to do with it\n */\n actionableText: {\n type: String,\n default: 'run',\n },\n /**\n * Toggles the loading indicator within the action bar\n */\n loading: {\n type: Boolean,\n default: false,\n },\n },\n emits: [BentoCodeSnippetEvent.ACTION, BentoCodeSnippetEvent.CHANGE],\n setup(props, { emit }) {\n const { t } = useI18n<{ message: MessageSchema }>({ messages });\n\n // language\n const selectedLanguage = ref<string | null>(null);\n const availableLanguages = []; // TODO: implement\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n const handleChangeLanguage = () => {};\n const displayedLang = computed(() => props.langLabel ?? props.lang.toUpperCase());\n\n const isInlineVariant = computed(() => props.variant === BentoCodeSnippetVariant.INLINE);\n\n const conditionalClasses = computed(() => ({\n 'b-code-snippet--inline': isInlineVariant.value,\n 'b-code-snippet--scrollable': !isInlineVariant.value,\n }));\n\n const codeAreaContentConditionalClasses = computed(() => ({\n 'b-code-snippet__code-area-content--editable': props.editable,\n }));\n\n const loadLang = getLangLoader(props.lang);\n\n const container = shallowRef<HTMLDivElement>();\n const editor = shallowRef<EditorView>();\n const languageConf = new Compartment();\n const editorTheme = new Compartment();\n const editorReadOnly = new Compartment();\n\n const currentContents = ref(null);\n const contentLength = ref(0);\n\n onMounted(async () => {\n const language = await loadLang();\n\n // alongside the updateListener plugin it acts as a watcher of changes to the editor state\n currentContents.value = props.content;\n const updateCurrentContents = ({ state }) => {\n currentContents.value = state.doc.toString();\n };\n\n const extensions = [\n highlightActiveLine(),\n keymap.of([indentWithTab, INDENT_SAME_AS_LINE_BEFORE]),\n languageConf.of(language()),\n editorTheme.of(lightThemeHighlight(props.lang)),\n\n editorReadOnly.of(EditorState.readOnly.of(!props.editable)),\n EditorView.updateListener.of(content => updateCurrentContents(content)),\n ];\n\n if (props.variant === 'multiline') {\n extensions.push([lineNumbers(), history()]);\n }\n\n const state = EditorState.create({\n doc: props.content,\n extensions: [...extensions],\n });\n contentLength.value = state.doc.length;\n\n editor.value = new EditorView({\n state,\n parent: container.value,\n });\n });\n watch(\n () => props.content,\n () => {\n if (props.content !== currentContents.value) {\n const upcomingContentLength = props.content.length;\n editor.value.dispatch({\n changes: {\n from: 0,\n to: contentLength.value,\n insert: props.content,\n },\n });\n contentLength.value = upcomingContentLength;\n }\n }\n );\n\n const runText = computed(() => t(props.actionableText as 'run'));\n const onActionClicked = () => {\n emit(BentoCodeSnippetEvent.ACTION, currentContents.value);\n };\n\n watchEffect(() => {\n if (currentContents.value !== null) {\n emit(BentoCodeSnippetEvent.CHANGE, currentContents.value);\n }\n });\n\n const showModal = ref(false);\n\n return {\n // Values\n availableLanguages,\n codeAreaContentConditionalClasses,\n conditionalClasses,\n container,\n currentContents,\n displayedLang,\n editor,\n selectedLanguage,\n showModal,\n isInlineVariant,\n\n // Methods\n handleChangeLanguage,\n onActionClicked,\n runText,\n\n // Translations\n t,\n };\n },\n });\n</script>\n\n<style lang=\"scss\" scoped src=\"./code-snippet.scss\"></style>\n"],"names":["lightThemeColors","BCodeSnippetCodeAreaHighlightRed","BCodeSnippetCodeAreaHighlightOrange","BCodeSnippetCodeAreaHighlightGreen","BCodeSnippetCodeAreaHighlightBlue","highlightStyle","colors","language","HighlightStyle","tags","lightThemeHighlight","syntaxHighlighting","BentoCodeSnippetVariant","BentoCodeSnippetVariant2","BentoCodeSnippetSupportedLanguage","BentoCodeSnippetSupportedLanguage2","BentoCodeSnippetEvent","BentoCodeSnippetEvent2","importsMap","json","xml","javascript","java","python","getLangLoader","getIndentation","state","line","currentLine","indentMatch","INDENT_SAME_AS_LINE_BEFORE","dispatch","changes","range","newText","EditorSelection","_sfc_main","defineComponent","messages","BentoTypography","BentoButton","BentoDropdown","Copy","BaseModal","BentoLoadingIndicator","ExpandIcon","BentoTooltipDirective","value","props","emit","t","useI18n","selectedLanguage","ref","availableLanguages","handleChangeLanguage","displayedLang","computed","isInlineVariant","conditionalClasses","codeAreaContentConditionalClasses","loadLang","container","shallowRef","editor","languageConf","Compartment","editorTheme","editorReadOnly","currentContents","contentLength","onMounted","updateCurrentContents","state2","extensions","highlightActiveLine","keymap","indentWithTab","EditorState","EditorView","content","lineNumbers","history","watch","upcomingContentLength","runText","onActionClicked","watchEffect","showModal"],"mappings":";;;;;;;;;;;;;;AAUA,MAAAA,KAAA;AAAA,EAAyB,KAAAC;AAAA,EAChB,QAAAC;AAAA,EACG,OAAAC;AAAA,EACD,MAAAC;AAAA,EACD,SAAA;AAEV,GAEAC,KAAA,CAAAC,GAAAC,MAAAC,EAAA,OAAA;AAAA,EAC0B;AAAA,IAClB,KAAAC,EAAA;AAAA,IACW,OAAAH,EAAA;AAAA,EACO;AAAA,EAClB;AAAA,IACA,KAAA,CAAAG,EAAA,MAAAA,EAAA,SAAAA,EAAA,WAAAA,EAAA,cAAAA,EAAA,SAAA;AAAA,IACqE,OAAAH,EAAA;AAAA,EACnD;AAAA,EAClB;AAAA,IACA,KAAA,CAAAG,EAAA,SAAAA,EAAA,YAAA,GAAAA,EAAA,SAAA;AAAA,IACiD,OAAAH,EAAA;AAAA,EAC/B;AAAA,EAClB;AAAA,IACA,KAAA,CAAAG,EAAA,OAAAA,EAAA,SAAAA,EAAA,IAAA,GAAAA,EAAA,SAAAA,EAAA,IAAA,CAAA;AAAA,IACyD,OAAAH,EAAA;AAAA,EACvC;AAAA,EAClB;AAAA,IACA,KAAA,CAAAG,EAAA,WAAAA,EAAA,IAAA,GAAA,GAAAF,MAAA,SAAA,CAAAE,EAAA,SAAA,IAAA,CAAA,CAAA;AAAA,IAC6E,OAAAH,EAAA;AAAA,EAC3D;AAAA,EAClB;AAAA,IACA,KAAA,CAAAG,EAAA,UAAAA,EAAA,WAAAA,EAAA,QAAAA,EAAA,SAAAA,EAAA,YAAAA,EAAA,UAAAA,EAAA,MAAAA,EAAA,SAAA;AAAA,IACqG,OAAAH,EAAA;AAAA,EACnF;AAAA,EAClB;AAAA,IACA,KAAA,CAAAG,EAAA,UAAAA,EAAA,iBAAAA,EAAA,KAAAA,EAAA,QAAAA,EAAA,QAAAA,EAAA,MAA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EAAA;AAAA,QAAA,OAAArD;AAAA,QACA,QAAAoC,EAAA;AAAA,MACA,CAAA;AAAA,IACA,CAAA,GAEAqB;AAAA,MAAA,MAAAnC,EAAA;AAAA,MACA,MAAA;AAEA,YAAAA,EAAA,YAAAqB,EAAA,OAAA;AACA,gBAAAe,IAAApC,EAAA,QAAA;AACA,UAAAgB,EAAA,MAAA,SAAA;AAAA,YAAA,SAAA;AAAA,cACA,MAAA;AAAA,cACA,IAAAM,EAAA;AAAA,cACA,QAAAtB,EAAA;AAAA,YACA;AAAA,UACA,CAAA,GAEAsB,EAAA,QAAAc;AAAA,QAAA;AAAA,MACA;AAAA,IACA;AAGA,UAAAC,IAAA5B,EAAA,MAAAP,EAAAF,EAAA,cAAA,CAAA,GACAsC,IAAA,MAAA;AACA,MAAArC,EAAAjC,EAAA,QAAAqD,EAAA,KAAA;AAAA,IAAA;AAGA,IAAAkB,EAAA,MAAA;AACA,MAAAlB,EAAA,UAAA,QACApB,EAAAjC,EAAA,QAAAqD,EAAA,KAAA;AAAA,IACA,CAAA;AAGA,UAAAmB,IAAAnC,EAAA,EAAA;AAEA,WAAA;AAAA;AAAA,MAAA,oBAAAC;AAAA,MAEA,mCAAAM;AAAA,MACA,oBAAAD;AAAA,MACA,WAAAG;AAAA,MACA,iBAAAO;AAAA,MACA,eAAAb;AAAA,MACA,QAAAQ;AAAA,MACA,kBAAAZ;AAAA,MACA,WAAAoC;AAAA,MACA,iBAAA9B;AAAA;AAAA,MACA,sBAAAH;AAAA,MAGA,iBAAA+B;AAAA,MACA,SAAAD;AAAA;AAAA,MACA,GAAAnC;AAAA,IAGA;AAAA,EACA;AAEA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { B as
|
|
3
|
-
import { g as
|
|
4
|
-
import { n as
|
|
1
|
+
import { defineComponent as m, useSlots as G, computed as i, onMounted as f } from "vue";
|
|
2
|
+
import { d as E, B as U } from "./typography.Bu_WAKdf.js";
|
|
3
|
+
import { g as P } from "./get-slot-text.Cgn-E48s.js";
|
|
4
|
+
import { n as _ } from "./_plugin-vue2_normalizer.CeySl7Fu.js";
|
|
5
5
|
import "../assets/currency.css";
|
|
6
|
-
const
|
|
6
|
+
const p = [
|
|
7
7
|
{
|
|
8
8
|
exponent: 0,
|
|
9
9
|
currencies: [
|
|
@@ -32,83 +32,75 @@ const U = [
|
|
|
32
32
|
exponent: 3,
|
|
33
33
|
currencies: ["BHD", "IQD", "JOD", "KWD", "LYD", "OMR", "TND"]
|
|
34
34
|
}
|
|
35
|
-
],
|
|
35
|
+
], L = (D) => {
|
|
36
36
|
var a;
|
|
37
|
-
return ((a =
|
|
38
|
-
},
|
|
39
|
-
const a =
|
|
40
|
-
return Math.round(
|
|
41
|
-
},
|
|
37
|
+
return ((a = p.find((s) => s.currencies.includes(D))) == null ? void 0 : a.exponent) ?? 2;
|
|
38
|
+
}, H = (D) => {
|
|
39
|
+
const a = L(D.currency), s = Number(D.value);
|
|
40
|
+
return Math.round(s * 10 ** a);
|
|
41
|
+
}, Y = (D, a) => (
|
|
42
42
|
// Amount is in minor units and have to be converted to number with fraction digits
|
|
43
43
|
// return (amount.value * 100) / 10 ** exp;
|
|
44
44
|
D.value / 10 ** a
|
|
45
45
|
);
|
|
46
|
-
function
|
|
47
|
-
const
|
|
46
|
+
function Z(D, a = {}, s = !1) {
|
|
47
|
+
const R = (a == null ? void 0 : a.exponent) ?? L(D.currency), K = s ? H(D) : D.value, M = { ...D, value: K }, l = Y(M, R), T = l < 0 ? "decimal" : (a == null ? void 0 : a.style) || "currency", A = a != null && a.optionalFractions ? 0 : R, F = a != null && a.highPrecision ? 10 : R;
|
|
48
48
|
return {
|
|
49
|
-
value:
|
|
49
|
+
value: l,
|
|
50
50
|
format: {
|
|
51
51
|
style: T,
|
|
52
52
|
currency: D.currency,
|
|
53
53
|
currencyDisplay: "symbol",
|
|
54
54
|
minimumFractionDigits: A,
|
|
55
|
-
maximumFractionDigits:
|
|
55
|
+
maximumFractionDigits: F
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
return new Intl.NumberFormat("en-US",
|
|
59
|
+
const v = (D, a, s) => {
|
|
60
|
+
const R = { value: parseFloat(D), currency: a }, K = Z(R, { style: "decimal" }, s);
|
|
61
|
+
return new Intl.NumberFormat("en-US", K.format).format(K.value);
|
|
62
62
|
};
|
|
63
|
-
var
|
|
64
|
-
const
|
|
65
|
-
name: "bento-currency"
|
|
66
|
-
|
|
63
|
+
var N = /* @__PURE__ */ ((D) => (D.AFA = "AFA", D.ALL = "ALL", D.DZD = "DZD", D.AOA = "AOA", D.ARS = "ARS", D.AMD = "AMD", D.AWG = "AWG", D.AUD = "AUD", D.AZN = "AZN", D.BSD = "BSD", D.BHD = "BHD", D.BDT = "BDT", D.BBD = "BBD", D.BYR = "BYR", D.BEF = "BEF", D.BZD = "BZD", D.BMD = "BMD", D.BTN = "BTN", D.BTC = "BTC", D.BOB = "BOB", D.BAM = "BAM", D.BWP = "BWP", D.BRL = "BRL", D.GBP = "GBP", D.BND = "BND", D.BGN = "BGN", D.BIF = "BIF", D.KHR = "KHR", D.CAD = "CAD", D.CVE = "CVE", D.KYD = "KYD", D.XOF = "XOF", D.XAF = "XAF", D.XPF = "XPF", D.CLP = "CLP", D.CLF = "CLF", D.CNY = "CNY", D.COP = "COP", D.KMF = "KMF", D.CDF = "CDF", D.CRC = "CRC", D.HRK = "HRK", D.CUC = "CUC", D.CZK = "CZK", D.DKK = "DKK", D.DJF = "DJF", D.DOP = "DOP", D.XCD = "XCD", D.EGP = "EGP", D.ERN = "ERN", D.EEK = "EEK", D.ETB = "ETB", D.EUR = "EUR", D.FKP = "FKP", D.FJD = "FJD", D.GMD = "GMD", D.GEL = "GEL", D.DEM = "DEM", D.GHS = "GHS", D.GIP = "GIP", D.GRD = "GRD", D.GTQ = "GTQ", D.GNF = "GNF", D.GYD = "GYD", D.HTG = "HTG", D.HNL = "HNL", D.HKD = "HKD", D.HUF = "HUF", D.ISK = "ISK", D.INR = "INR", D.IDR = "IDR", D.IRR = "IRR", D.IQD = "IQD", D.ILS = "ILS", D.ITL = "ITL", D.JMD = "JMD", D.JPY = "JPY", D.JOD = "JOD", D.KZT = "KZT", D.KES = "KES", D.KWD = "KWD", D.KGS = "KGS", D.LAK = "LAK", D.LVL = "LVL", D.LBP = "LBP", D.LSL = "LSL", D.LRD = "LRD", D.LYD = "LYD", D.LTC = "LTC", D.LTL = "LTL", D.MOP = "MOP", D.MKD = "MKD", D.MGA = "MGA", D.MWK = "MWK", D.MYR = "MYR", D.MVR = "MVR", D.MRO = "MRO", D.MUR = "MUR", D.MXN = "MXN", D.MDL = "MDL", D.MNT = "MNT", D.MAD = "MAD", D.MZM = "MZM", D.MMK = "MMK", D.NAD = "NAD", D.NPR = "NPR", D.ANG = "ANG", D.TWD = "TWD", D.NZD = "NZD", D.NIO = "NIO", D.NGN = "NGN", D.KPW = "KPW", D.NOK = "NOK", D.OMR = "OMR", D.PKR = "PKR", D.PAB = "PAB", D.PGK = "PGK", D.PYG = "PYG", D.PEN = "PEN", D.PHP = "PHP", D.PLN = "PLN", D.QAR = "QAR", D.RON = "RON", D.RUB = "RUB", D.RWF = "RWF", D.SVC = "SVC", D.WST = "WST", D.STD = "STD", D.SAR = "SAR", D.RSD = "RSD", D.SCR = "SCR", D.SLL = "SLL", D.SGD = "SGD", D.SKK = "SKK", D.SBD = "SBD", D.SOS = "SOS", D.ZAR = "ZAR", D.KRW = "KRW", D.SSP = "SSP", D.XDR = "XDR", D.LKR = "LKR", D.SHP = "SHP", D.SDG = "SDG", D.SRD = "SRD", D.SZL = "SZL", D.SEK = "SEK", D.CHF = "CHF", D.SYP = "SYP", D.TJS = "TJS", D.TZS = "TZS", D.THB = "THB", D.TOP = "TOP", D.TTD = "TTD", D.TND = "TND", D.TRY = "TRY", D.TMT = "TMT", D.UGX = "UGX", D.UAH = "UAH", D.AED = "AED", D.UYU = "UYU", D.USD = "USD", D.UZS = "UZS", D.VUV = "VUV", D.VEF = "VEF", D.VND = "VND", D.YER = "YER", D.ZMK = "ZMK", D.ZWL = "ZWL", D))(N || {});
|
|
64
|
+
const W = {
|
|
65
|
+
name: "bento-currency"
|
|
66
|
+
}, V = /* @__PURE__ */ m({
|
|
67
|
+
...W,
|
|
67
68
|
props: {
|
|
68
|
-
currency: {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
},
|
|
73
|
-
/**
|
|
74
|
-
* Accepts currency value in major units instead of minor ones
|
|
75
|
-
*/
|
|
76
|
-
majorUnits: {
|
|
77
|
-
type: Boolean,
|
|
78
|
-
default: !1
|
|
79
|
-
},
|
|
80
|
-
/**
|
|
81
|
-
* Disable the default typography for the component. Only use this when the component is inside another typography component.
|
|
82
|
-
*/
|
|
83
|
-
disableTypography: {
|
|
84
|
-
type: Boolean,
|
|
85
|
-
default: !1
|
|
86
|
-
}
|
|
69
|
+
currency: { default: N.EUR },
|
|
70
|
+
disableTypography: { type: Boolean, default: !1 },
|
|
71
|
+
majorUnits: { type: Boolean, default: !1 },
|
|
72
|
+
value: { default: void 0 }
|
|
87
73
|
},
|
|
88
|
-
setup(D
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
74
|
+
setup(D) {
|
|
75
|
+
const a = D, s = G(), R = i(() => {
|
|
76
|
+
const K = a.value || P(s)("default");
|
|
77
|
+
return v(K, a.currency, a.majorUnits);
|
|
78
|
+
});
|
|
79
|
+
return f(() => {
|
|
80
|
+
P(s)("default") && E(
|
|
81
|
+
'BentoCurrency "default" slot',
|
|
82
|
+
`The use of "default" slot in "BentoCurrency" is no longer supported as it causes issues with dynamic content.
|
|
83
|
+
Use the "value" property instead.
|
|
84
|
+
<bento-currency :value="12345.67" currency="USD" major-units="false" />`,
|
|
85
|
+
"2.0.0"
|
|
86
|
+
);
|
|
87
|
+
}), { __sfc: !0, slots: s, props: a, formattedCurrency: R, BentoTypography: U };
|
|
96
88
|
}
|
|
97
89
|
});
|
|
98
|
-
var
|
|
99
|
-
var a = this, R = a._self.
|
|
100
|
-
return
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
90
|
+
var X = function() {
|
|
91
|
+
var a = this, s = a._self._c, R = a._self._setupProxy;
|
|
92
|
+
return s("div", { staticClass: "b-currency" }, [a.disableTypography ? [a._v(a._s(R.formattedCurrency) + " " + a._s(a.currency))] : s(R.BentoTypography, { staticClass: "b-currency__amount", attrs: { el: "span", variant: "body", strong: "" } }, [a._v(" " + a._s(R.formattedCurrency) + " " + a._s(a.currency) + " ")])], 2);
|
|
93
|
+
}, g = [], J = /* @__PURE__ */ _(
|
|
94
|
+
V,
|
|
95
|
+
X,
|
|
96
|
+
g,
|
|
105
97
|
!1,
|
|
106
98
|
null,
|
|
107
|
-
"
|
|
99
|
+
"3cdd791b"
|
|
108
100
|
);
|
|
109
|
-
const
|
|
101
|
+
const j = J.exports;
|
|
110
102
|
export {
|
|
111
|
-
|
|
112
|
-
|
|
103
|
+
N as B,
|
|
104
|
+
j as c
|
|
113
105
|
};
|
|
114
|
-
//# sourceMappingURL=currency.
|
|
106
|
+
//# sourceMappingURL=currency.P7Psn_SK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"currency.P7Psn_SK.js","sources":["../../src/utils/ts/currency/countries-list.ts","../../src/utils/ts/currency/currency.ts","../../src/components/currency/currency.types.ts","../../src/components/currency/currency.vue"],"sourcesContent":["/**\n * Contains mapping configuration between currency code and exponent for amount in the corresponding currency.\n * Since the majority of the currencies have an exponent equal to 2, they are not listed here.\n * https://docs.adyen.com/development-resources/currency-codes\n * @type {Array}\n * @internal\n */\nexport const currencyExponentMap = [\n {\n exponent: 0,\n currencies: [\n 'CVE',\n 'DJF',\n 'GNF',\n 'IDR',\n 'JPY',\n 'KMF',\n 'KRW',\n 'PYG',\n 'RWF',\n 'UGX',\n 'VND',\n 'VUV',\n 'XAF',\n 'XOF',\n 'XPF',\n ],\n },\n {\n exponent: 1,\n currencies: ['MRO'],\n },\n {\n exponent: 3,\n currencies: ['BHD', 'IQD', 'JOD', 'KWD', 'LYD', 'OMR', 'TND'],\n },\n];\n","import { CurrencyAmount, CurrencyOptions, NumberFormatOptionsResult } from './currency.types';\nimport { currencyExponentMap } from './countries-list';\n\n/**\n * Returns exponent for specified currency code.\n */\nexport const getExponent = (currencyCode: string): number =>\n currencyExponentMap.find(obj => obj.currencies.includes(currencyCode))?.exponent ?? 2;\n\n/**\n * Converts passed amount from regular to minor units, based on currency exponent\n */\nexport const getMinorUnitsAmount = (amount: CurrencyAmount): number => {\n const exponent = getExponent(amount.currency);\n const value = Number(amount.value);\n\n return Math.round(value * 10 ** exponent);\n};\n\n/**\n * Returns normalized amount value from minor units as decimal point number (when exponent is more than zero).\n */\nexport const getNormalizedAmount = (amount: CurrencyAmount, exponent: number) =>\n // Amount is in minor units and have to be converted to number with fraction digits\n // return (amount.value * 100) / 10 ** exp;\n amount.value / 10 ** exponent;\n\n/**\n * /**\n * Prepares amount to be rendered by Intl.NumberFormat function.\n * See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat\n *\n * It enables language-sensitive number formatting.\n * Adds currency symbol and ISO code based on provided options\n * The result of execution - is a configuration object that is used in 'getLocalizedCurrencyValue' function\n *\n * @param amount - the value and currency to format.\n * @param options - the formatting options that are passed to the Intl.NumberFormat function.\n * @param majorUnits - if set to true, then currency major units will be used instead of minor ones\n */\nexport function getNumberFormatOptions(\n amount: CurrencyAmount,\n options: CurrencyOptions = {},\n majorUnits = false\n): NumberFormatOptionsResult {\n // Exponent is based on currency, if not specified explicitly.\n const exp = options?.exponent ?? getExponent(amount.currency);\n // Minor Units have to be retrieved from component passed amount\n const minorAmount = majorUnits ? getMinorUnitsAmount(amount) : amount.value;\n const amountInMinorUnits: CurrencyAmount = { ...amount, value: minorAmount };\n // Amount is in minor units and have to be converted to number with fraction digits\n const value = getNormalizedAmount(amountInMinorUnits, exp);\n // This is the requirement for currency component - to remove currency symbol for negative values\n const style = value < 0 ? 'decimal' : options?.style || 'currency';\n // If optionalFractions is true, numbers will not contain fraction digits when they are zero (e.g. 100.00 will be 100)\n const minimumFractionDigits = options?.optionalFractions ? 0 : exp;\n // If highPrecision is true, numbers can contain 10 fraction digits (highest precision in Adyen is about 5)\n const maximumFractionDigits = options?.highPrecision ? 10 : exp;\n\n return {\n value,\n format: {\n style,\n currency: amount.currency,\n currencyDisplay: 'symbol',\n minimumFractionDigits,\n maximumFractionDigits,\n },\n };\n}\n\n/**\n * Get a formatted and localised currency string given an amount and currency type.\n *\n * @param amountValue - the amount of the currency.\n * @param currency - the ISO 4217 currency code.\n * @param majorUnits - if set to true, then currency major units will be used instead of minor ones\n */\nexport const getLocalizedCurrencyValue = (amountValue: string, currency: string, majorUnits?: boolean): string => {\n const amount: CurrencyAmount = { value: parseFloat(amountValue), currency };\n const numberFormatOptions = getNumberFormatOptions(amount, { style: 'decimal' }, majorUnits);\n // TODO replace hardcoded locale with dynamic one, when i18n strategy is defined\n const formatter = new Intl.NumberFormat('en-US', numberFormatOptions.format as Intl.NumberFormatOptions);\n\n return formatter.format(numberFormatOptions.value);\n};\n","export interface BentoCurrencyProps {\n /**\n * Currency code based on the ISO 4217 standard\n */\n currency?: BentoCurrencyISOCode | `${BentoCurrencyISOCode}`;\n\n /**\n * Disable the default typography for the component. Only use this when the component is inside another typography component.\n */\n disableTypography?: boolean;\n\n /**\n * Accepts currency value in major units instead of minor ones\n */\n majorUnits?: boolean;\n\n /**\n * Currency value to be formatted\n */\n value?: number;\n}\n\nexport enum BentoCurrencyISOCode {\n AFA = 'AFA',\n ALL = 'ALL',\n DZD = 'DZD',\n AOA = 'AOA',\n ARS = 'ARS',\n AMD = 'AMD',\n AWG = 'AWG',\n AUD = 'AUD',\n AZN = 'AZN',\n BSD = 'BSD',\n BHD = 'BHD',\n BDT = 'BDT',\n BBD = 'BBD',\n BYR = 'BYR',\n BEF = 'BEF',\n BZD = 'BZD',\n BMD = 'BMD',\n BTN = 'BTN',\n BTC = 'BTC',\n BOB = 'BOB',\n BAM = 'BAM',\n BWP = 'BWP',\n BRL = 'BRL',\n GBP = 'GBP',\n BND = 'BND',\n BGN = 'BGN',\n BIF = 'BIF',\n KHR = 'KHR',\n CAD = 'CAD',\n CVE = 'CVE',\n KYD = 'KYD',\n XOF = 'XOF',\n XAF = 'XAF',\n XPF = 'XPF',\n CLP = 'CLP',\n CLF = 'CLF',\n CNY = 'CNY',\n COP = 'COP',\n KMF = 'KMF',\n CDF = 'CDF',\n CRC = 'CRC',\n HRK = 'HRK',\n CUC = 'CUC',\n CZK = 'CZK',\n DKK = 'DKK',\n DJF = 'DJF',\n DOP = 'DOP',\n XCD = 'XCD',\n EGP = 'EGP',\n ERN = 'ERN',\n EEK = 'EEK',\n ETB = 'ETB',\n EUR = 'EUR',\n FKP = 'FKP',\n FJD = 'FJD',\n GMD = 'GMD',\n GEL = 'GEL',\n DEM = 'DEM',\n GHS = 'GHS',\n GIP = 'GIP',\n GRD = 'GRD',\n GTQ = 'GTQ',\n GNF = 'GNF',\n GYD = 'GYD',\n HTG = 'HTG',\n HNL = 'HNL',\n HKD = 'HKD',\n HUF = 'HUF',\n ISK = 'ISK',\n INR = 'INR',\n IDR = 'IDR',\n IRR = 'IRR',\n IQD = 'IQD',\n ILS = 'ILS',\n ITL = 'ITL',\n JMD = 'JMD',\n JPY = 'JPY',\n JOD = 'JOD',\n KZT = 'KZT',\n KES = 'KES',\n KWD = 'KWD',\n KGS = 'KGS',\n LAK = 'LAK',\n LVL = 'LVL',\n LBP = 'LBP',\n LSL = 'LSL',\n LRD = 'LRD',\n LYD = 'LYD',\n LTC = 'LTC',\n LTL = 'LTL',\n MOP = 'MOP',\n MKD = 'MKD',\n MGA = 'MGA',\n MWK = 'MWK',\n MYR = 'MYR',\n MVR = 'MVR',\n MRO = 'MRO',\n MUR = 'MUR',\n MXN = 'MXN',\n MDL = 'MDL',\n MNT = 'MNT',\n MAD = 'MAD',\n MZM = 'MZM',\n MMK = 'MMK',\n NAD = 'NAD',\n NPR = 'NPR',\n ANG = 'ANG',\n TWD = 'TWD',\n NZD = 'NZD',\n NIO = 'NIO',\n NGN = 'NGN',\n KPW = 'KPW',\n NOK = 'NOK',\n OMR = 'OMR',\n PKR = 'PKR',\n PAB = 'PAB',\n PGK = 'PGK',\n PYG = 'PYG',\n PEN = 'PEN',\n PHP = 'PHP',\n PLN = 'PLN',\n QAR = 'QAR',\n RON = 'RON',\n RUB = 'RUB',\n RWF = 'RWF',\n SVC = 'SVC',\n WST = 'WST',\n STD = 'STD',\n SAR = 'SAR',\n RSD = 'RSD',\n SCR = 'SCR',\n SLL = 'SLL',\n SGD = 'SGD',\n SKK = 'SKK',\n SBD = 'SBD',\n SOS = 'SOS',\n ZAR = 'ZAR',\n KRW = 'KRW',\n SSP = 'SSP',\n XDR = 'XDR',\n LKR = 'LKR',\n SHP = 'SHP',\n SDG = 'SDG',\n SRD = 'SRD',\n SZL = 'SZL',\n SEK = 'SEK',\n CHF = 'CHF',\n SYP = 'SYP',\n TJS = 'TJS',\n TZS = 'TZS',\n THB = 'THB',\n TOP = 'TOP',\n TTD = 'TTD',\n TND = 'TND',\n TRY = 'TRY',\n TMT = 'TMT',\n UGX = 'UGX',\n UAH = 'UAH',\n AED = 'AED',\n UYU = 'UYU',\n USD = 'USD',\n UZS = 'UZS',\n VUV = 'VUV',\n VEF = 'VEF',\n VND = 'VND',\n YER = 'YER',\n ZMK = 'ZMK',\n ZWL = 'ZWL',\n}\n","<template>\n <div class=\"b-currency\">\n <bento-typography v-if=\"!disableTypography\" class=\"b-currency__amount\" el=\"span\" variant=\"body\" strong>\n {{ formattedCurrency }} {{ currency }}\n </bento-typography>\n <template v-else>{{ formattedCurrency }} {{ currency }}</template>\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, onMounted, useSlots } from 'vue';\n import { getLocalizedCurrencyValue } from '@/utils/ts/currency/currency';\n import { BentoTypography } from '@/components/typography';\n import { BentoCurrencyISOCode, BentoCurrencyProps } from './currency.types';\n import { getSlotText } from '@/utils/ts/get-slot-text';\n import { deprecate } from '@/utils/ts/deprecate';\n\n const slots = useSlots();\n\n const props = defineProps({\n currency: { default: BentoCurrencyISOCode.EUR },\n disableTypography: { type: Boolean, default: false },\n majorUnits: { type: Boolean, default: false },\n value: { default: undefined }\n});\n\n const formattedCurrency = computed<string>(() => {\n const value = props.value || getSlotText(slots)('default');\n return getLocalizedCurrencyValue(value as string, props.currency, props.majorUnits);\n });\n\n onMounted(() => {\n if (getSlotText(slots)('default')) {\n deprecate(\n 'BentoCurrency \"default\" slot',\n `The use of \"default\" slot in \"BentoCurrency\" is no longer supported as it causes issues with dynamic content.\n Use the \"value\" property instead.\n <bento-currency :value=\"12345.67\" currency=\"USD\" major-units=\"false\" />`,\n '2.0.0'\n );\n }\n });\n</script>\n\n<script lang=\"ts\">\n /**\n * A Currency component is used to display a formatted currency value.\n *\n * @example\n * import { BentoCurrency, BentoCurrencyISOCode } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoCurrency },\n * template: `\n * <bento-currency\n * :currency=\"BentoCurrencyISOCode.USD\"\n * :value=\"76.33\"\n * />\n * `\n * }\n */\n export default {\n name: 'bento-currency',\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./currency.scss\" />\n"],"names":["currencyExponentMap","getExponent","currencyCode","_a","obj","getMinorUnitsAmount","amount","exponent","value","getNormalizedAmount","getNumberFormatOptions","options","majorUnits","exp","minorAmount","amountInMinorUnits","style","minimumFractionDigits","maximumFractionDigits","getLocalizedCurrencyValue","amountValue","currency","numberFormatOptions","BentoCurrencyISOCode","BentoCurrencyISOCode2","__default__","slots","useSlots","formattedCurrency","computed","props","getSlotText","onMounted","deprecate"],"mappings":";;;;;AAOO,MAAAA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AA,EAAA,UAAA;AAAA,IAAkF,CAAA;AAGtF,WAAAE,EAAA,MAAA;AACI,MAAAD,EAAAL,CAAA,EAAA,SAAA,KACIO;AAAA,QAAA;AAAA,QACI;AAAA;AAAA;AAAA,QACA;AAAA,MAGA;AAAA,IAER,CAAA;;;;;;;;;;;;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent as C, useSlots as T, ref as d, computed as l, watch as m, onUnmounted as R, onMounted as x } from "vue";
|
|
2
2
|
import { B as y } from "./header.DwTrDlSa.js";
|
|
3
3
|
import { B as I, a as H } from "./tabs.Casntai-.js";
|
|
4
|
-
import {
|
|
4
|
+
import { b as P } from "./index.D5am6ibQ.js";
|
|
5
5
|
import { o as W } from "./resize.Bqks3WUm.js";
|
|
6
6
|
import { u as S } from "./use-has-slot.C9lQZ6nz.js";
|
|
7
7
|
import { n as k } from "./_plugin-vue2_normalizer.CeySl7Fu.js";
|
|
@@ -102,4 +102,4 @@ export {
|
|
|
102
102
|
st as a,
|
|
103
103
|
tt as d
|
|
104
104
|
};
|
|
105
|
-
//# sourceMappingURL=dashboard-section.
|
|
105
|
+
//# sourceMappingURL=dashboard-section.DchlD4B2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard-section.9R8bIh92.js","sources":["../../src/templates/dashboard-template/dashboard-template.vue","../../src/templates/dashboard-template/components/dashboard-section/dashboard-section.vue"],"sourcesContent":["<template>\n <main class=\"b-dashboard-template\">\n <bento-header v-bind=\"header\" variant=\"page\" class=\"b-dashboard-template__header\">\n <template v-if=\"hasSlot('infoIconTooltipContent')\" #infoIconTooltipContent>\n <slot name=\"infoIconTooltipContent\" />\n </template>\n </bento-header>\n <div class=\"b-dashboard-template__top-section\" :class=\"dashboardTopSectionConditionalClasses\">\n <div\n v-if=\"hasSlot('filters')\"\n ref=\"filtersRef\"\n class=\"b-dashboard-template__filters\"\n :class=\"dashboardFiltersConditionalClasses\"\n data-testid=\"filters\"\n >\n <slot name=\"filters\" />\n </div>\n\n <bento-tabs\n v-if=\"tabsSlots.length > 1\"\n ref=\"tabsRef\"\n :active-tab-index=\"tabs.activeTabIndex\"\n class=\"b-dashboard-template__tabs\"\n :class=\"dashboardTabsConditionalClasses\"\n data-testid=\"tabs\"\n >\n <bento-tab v-for=\"(_item, index) in tabsSlots\" :key=\"`tab-${index}`\" :title=\"getTabTitle(index)\">\n <div class=\"b-dashboard-template__container b-dashboard-template__container--tabs\">\n <slot :name=\"`tab-${index + 1}`\" />\n </div>\n </bento-tab>\n </bento-tabs>\n <div v-else class=\"b-dashboard-template__container\">\n <slot />\n </div>\n </div>\n </main>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, onUnmounted, ref, useSlots, watch } from 'vue';\n import { BentoHeader } from '@/components/header';\n import { BentoTab, BentoTabs } from '@/components/tabs';\n import { useWindowScroll } from '@vueuse/core';\n import { observeSizeOfElement } from '@/utils/ts/resize';\n import { useHasSlot } from '@/composables';\n import type { BentoDashboardTemplateHeader, BentoDashboardTemplateTabs } from './dashboard-template.types';\n\n const props = defineProps({\n header: null,\n tabs: { default: undefined },\n stickyTabs: { type: Boolean, default: false },\n stickyFilters: { type: Boolean, default: false }\n});\n\n const slots = useSlots();\n const hasSlot = useHasSlot(slots);\n\n const tabsRef = ref<InstanceType<typeof BentoTabs>>();\n const filtersRef = ref<HTMLDivElement>(null);\n const isFiltersPinned = ref(false);\n let filtersElementObserver: ResizeObserver | null = null;\n const isTabsPinned = ref(false);\n const tabsPosition = ref(0);\n\n const hasStickyFilters = computed(() => filtersRef.value && props.stickyFilters);\n const hasStickyTabs = computed(() => tabsRef.value && props.stickyTabs);\n\n const dashboardFiltersConditionalClasses = computed(() => ({\n 'b-dashboard-template__filters--sticky': props.stickyFilters,\n 'b-dashboard-template__filters--show-border':\n hasStickyFilters.value && !hasStickyTabs.value && isFiltersPinned.value,\n }));\n\n const dashboardTabsConditionalClasses = computed(() => ({\n 'b-dashboard-template__tabs--sticky': props.stickyTabs,\n 'b-dashboard-template__tabs--show-border': props.stickyTabs && isTabsPinned.value,\n }));\n\n const dashboardTopSectionConditionalClasses = computed(() => ({\n 'b-dashboard-template__top-section--sticky': props.stickyTabs || props.stickyFilters,\n }));\n\n const tabsSlots = computed(() => Object.keys(slots).filter(el => el?.includes('tab-')));\n\n const getTabTitle = (index: number) => props?.tabs.tabs?.[index]?.title ?? `Tab ${index + 1}`;\n\n const { y } = useWindowScroll();\n\n watch(\n () => filtersRef.value,\n () => {\n if (!filtersElementObserver && filtersRef.value) {\n filtersElementObserver = observeSizeOfElement(filtersRef.value, () => {\n if (filtersRef.value && hasStickyTabs.value) {\n const filtersHeight = filtersRef.value.offsetHeight;\n tabsPosition.value = hasStickyFilters.value ? filtersHeight : 0;\n (tabsRef.value.tablistwrapper.$el as HTMLDivElement).style.top = `${tabsPosition.value}px`;\n }\n });\n }\n }\n );\n\n watch(\n () => y.value,\n () => {\n if (hasStickyFilters.value) {\n isFiltersPinned.value = filtersRef.value?.getBoundingClientRect().top === 0;\n }\n if (hasStickyTabs.value) {\n isTabsPinned.value =\n (tabsRef.value.tablistwrapper.$el as HTMLDivElement)?.getBoundingClientRect().top ===\n tabsPosition.value;\n }\n }\n );\n\n onUnmounted(() => {\n filtersElementObserver?.disconnect();\n });\n</script>\n\n<script lang=\"ts\">\n /**\n * Dashboard template is a full page template used to visualize data on pages such as data dashboards and reports.\n *\n * @example\n * import { BentoDashboardTemplate, BentoDashboardSection } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoDashboardTemplate, BentoDashboardSection },\n * template: `\n * <bento-dashboard-template :header=\"{ title: 'Dashboard'}\" :tabs=\"tabs: [{ title: 'Tab 1' }, { title: 'Tab 2' }]\" sticky-tabs sticky-filters>\n * <template #tab-1>\n * <bento-dashboard-section :header=\"{ title: 'Section'}\">\n * <template #controls>\n * // Add your controls here\n * </template>\n * // Add your content here\n * </bento-dashboard-section>\n * </template>\n * <template #tab-2>\n * <bento-dashboard-section :header=\"{ title: 'Section'}\">\n * // Add your content here\n * </bento-dashboard-section>\n * </template>\n * </bento-dashboard-template>\n * `\n * }\n */\n export default {};\n</script>\n\n<style lang=\"scss\" scoped src=\"./dashboard-template.scss\" />\n","<template>\n <div class=\"b-dashboard-section\" :class=\"conditionalClasses\">\n <bento-header v-bind=\"header\" variant=\"component\" class=\"b-dashboard-template__header\">\n <template v-if=\"hasSlot('infoIconTooltipContent')\" #infoIconTooltipContent>\n <slot name=\"infoIconTooltipContent\" />\n </template>\n </bento-header>\n <div v-if=\"hasSlot('controls')\" class=\"b-dashboard-section__controls\">\n <slot name=\"controls\"></slot>\n </div>\n <div v-if=\"!hasSlot('content-col-1') && !hasSlot('content-col-2')\" class=\"b-dashboard-section__content\">\n <slot name=\"default\"></slot>\n </div>\n <div v-else class=\"b-dashboard-section__columns\">\n <div class=\"b-dashboard-section__content\"><slot name=\"content-col-1\"></slot></div>\n <div class=\"b-dashboard-section__content\"><slot name=\"content-col-2\"></slot></div>\n </div>\n <bento-divider class=\"b-dashboard-section__divider\" />\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, onMounted, useSlots } from 'vue';\n import { BentoHeader } from '@/components/header';\n import { BentoDivider } from '@/components/divider';\n import { useHasSlot } from '@/composables';\n import type { BentoDashboardTemplateHeader } from '../../dashboard-template.types';\n\n const props = defineProps({\n header: null,\n halfWidth: { type: Boolean, default: false }\n});\n\n const slots = useSlots();\n const hasSlot = useHasSlot(slots);\n\n const conditionalClasses = computed(() => ({\n 'b-dashboard-section--half-width': props.halfWidth,\n }));\n\n onMounted(() => {\n if ((hasSlot('content-col-1') || hasSlot('content-col-2')) && props.halfWidth) {\n throw new Error('`content-col-1` and `content-col-2` cannot be used with half-width prop');\n }\n });\n</script>\n\n<script lang=\"ts\">\n /**\n * Dashboard section is subcomponent of Dashboard template meant to be used to create the different sections within the page.\n *\n * @example\n * import { BentoDashboardSection } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoDashboardSection },\n * template: `\n * <bento-dashboard-section :header=\"{ title: 'Section' }\" half-width>\n * <template #controls>\n * // Add your controls here\n * </template>\n * // You can render content with two cols\n * <template #content-col-1>\n * // Add your content here\n * </template>\n * <template #content-col-2>\n * // Add your content here\n * </template>\n * // Or you can render full width content by using default slot\n * // Add your content here\n * </bento-dashboard-section>\n * `\n * }\n */\n export default {};\n</script>\n\n<style lang=\"scss\" scoped src=\"./dashboard-section.scss\" />\n"],"names":["__default__$1","slots","useSlots","hasSlot","useHasSlot","tabsRef","ref","filtersRef","isFiltersPinned","filtersElementObserver","isTabsPinned","tabsPosition","hasStickyFilters","computed","props","hasStickyTabs","dashboardFiltersConditionalClasses","dashboardTabsConditionalClasses","dashboardTopSectionConditionalClasses","tabsSlots","el","getTabTitle","index","_b","_a","y","useWindowScroll","watch","observeSizeOfElement","filtersHeight","onUnmounted","__default__","conditionalClasses","onMounted"],"mappings":";;;;;;;;;AAuJI,MAAAA,IAAA,CAAA;;;;;;;;;;iBAhGAC,IAAAC,EAAA,GACAC,IAAAC,EAAAH,CAAA,GAEAI,IAAAC,EAAA,GACAC,IAAAD,EAAA,IAAA,GACAE,IAAAF,EAAA,EAAA;AACA,QAAAG,IAAA;AACA,UAAAC,IAAAJ,EAAA,EAAA,GACAK,IAAAL,EAAA,CAAA,GAEAM,IAAAC,EAAA,MAAAN,EAAA,SAAAO,EAAA,aAAA,GACAC,IAAAF,EAAA,MAAAR,EAAA,SAAAS,EAAA,UAAA,GAEAE,IAAAH,EAAA,OAAA;AAAA,MAA2D,yCAAAC,EAAA;AAAA,MACR,8CAAAF,EAAA,SAAA,CAAAG,EAAA,SAAAP,EAAA;AAAA,IAEuB,EAAA,GAG1ES,IAAAJ,EAAA,OAAA;AAAA,MAAwD,sCAAAC,EAAA;AAAA,MACR,2CAAAA,EAAA,cAAAJ,EAAA;AAAA,IACgC,EAAA,GAGhFQ,IAAAL,EAAA,OAAA;AAAA,MAA8D,6CAAAC,EAAA,cAAAA,EAAA;AAAA,IACa,EAAA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,EAAA,eAAA,KAAAA,EAAA,eAAA,MAAAW,EAAA;AACI,cAAA,IAAA,MAAA,yEAAA;AAAA,IACJ,CAAA;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"dashboard-section.DchlD4B2.js","sources":["../../src/templates/dashboard-template/dashboard-template.vue","../../src/templates/dashboard-template/components/dashboard-section/dashboard-section.vue"],"sourcesContent":["<template>\n <main class=\"b-dashboard-template\">\n <bento-header v-bind=\"header\" variant=\"page\" class=\"b-dashboard-template__header\">\n <template v-if=\"hasSlot('infoIconTooltipContent')\" #infoIconTooltipContent>\n <slot name=\"infoIconTooltipContent\" />\n </template>\n </bento-header>\n <div class=\"b-dashboard-template__top-section\" :class=\"dashboardTopSectionConditionalClasses\">\n <div\n v-if=\"hasSlot('filters')\"\n ref=\"filtersRef\"\n class=\"b-dashboard-template__filters\"\n :class=\"dashboardFiltersConditionalClasses\"\n data-testid=\"filters\"\n >\n <slot name=\"filters\" />\n </div>\n\n <bento-tabs\n v-if=\"tabsSlots.length > 1\"\n ref=\"tabsRef\"\n :active-tab-index=\"tabs.activeTabIndex\"\n class=\"b-dashboard-template__tabs\"\n :class=\"dashboardTabsConditionalClasses\"\n data-testid=\"tabs\"\n >\n <bento-tab v-for=\"(_item, index) in tabsSlots\" :key=\"`tab-${index}`\" :title=\"getTabTitle(index)\">\n <div class=\"b-dashboard-template__container b-dashboard-template__container--tabs\">\n <slot :name=\"`tab-${index + 1}`\" />\n </div>\n </bento-tab>\n </bento-tabs>\n <div v-else class=\"b-dashboard-template__container\">\n <slot />\n </div>\n </div>\n </main>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, onUnmounted, ref, useSlots, watch } from 'vue';\n import { BentoHeader } from '@/components/header';\n import { BentoTab, BentoTabs } from '@/components/tabs';\n import { useWindowScroll } from '@vueuse/core';\n import { observeSizeOfElement } from '@/utils/ts/resize';\n import { useHasSlot } from '@/composables';\n import type { BentoDashboardTemplateHeader, BentoDashboardTemplateTabs } from './dashboard-template.types';\n\n const props = defineProps({\n header: null,\n tabs: { default: undefined },\n stickyTabs: { type: Boolean, default: false },\n stickyFilters: { type: Boolean, default: false }\n});\n\n const slots = useSlots();\n const hasSlot = useHasSlot(slots);\n\n const tabsRef = ref<InstanceType<typeof BentoTabs>>();\n const filtersRef = ref<HTMLDivElement>(null);\n const isFiltersPinned = ref(false);\n let filtersElementObserver: ResizeObserver | null = null;\n const isTabsPinned = ref(false);\n const tabsPosition = ref(0);\n\n const hasStickyFilters = computed(() => filtersRef.value && props.stickyFilters);\n const hasStickyTabs = computed(() => tabsRef.value && props.stickyTabs);\n\n const dashboardFiltersConditionalClasses = computed(() => ({\n 'b-dashboard-template__filters--sticky': props.stickyFilters,\n 'b-dashboard-template__filters--show-border':\n hasStickyFilters.value && !hasStickyTabs.value && isFiltersPinned.value,\n }));\n\n const dashboardTabsConditionalClasses = computed(() => ({\n 'b-dashboard-template__tabs--sticky': props.stickyTabs,\n 'b-dashboard-template__tabs--show-border': props.stickyTabs && isTabsPinned.value,\n }));\n\n const dashboardTopSectionConditionalClasses = computed(() => ({\n 'b-dashboard-template__top-section--sticky': props.stickyTabs || props.stickyFilters,\n }));\n\n const tabsSlots = computed(() => Object.keys(slots).filter(el => el?.includes('tab-')));\n\n const getTabTitle = (index: number) => props?.tabs.tabs?.[index]?.title ?? `Tab ${index + 1}`;\n\n const { y } = useWindowScroll();\n\n watch(\n () => filtersRef.value,\n () => {\n if (!filtersElementObserver && filtersRef.value) {\n filtersElementObserver = observeSizeOfElement(filtersRef.value, () => {\n if (filtersRef.value && hasStickyTabs.value) {\n const filtersHeight = filtersRef.value.offsetHeight;\n tabsPosition.value = hasStickyFilters.value ? filtersHeight : 0;\n (tabsRef.value.tablistwrapper.$el as HTMLDivElement).style.top = `${tabsPosition.value}px`;\n }\n });\n }\n }\n );\n\n watch(\n () => y.value,\n () => {\n if (hasStickyFilters.value) {\n isFiltersPinned.value = filtersRef.value?.getBoundingClientRect().top === 0;\n }\n if (hasStickyTabs.value) {\n isTabsPinned.value =\n (tabsRef.value.tablistwrapper.$el as HTMLDivElement)?.getBoundingClientRect().top ===\n tabsPosition.value;\n }\n }\n );\n\n onUnmounted(() => {\n filtersElementObserver?.disconnect();\n });\n</script>\n\n<script lang=\"ts\">\n /**\n * Dashboard template is a full page template used to visualize data on pages such as data dashboards and reports.\n *\n * @example\n * import { BentoDashboardTemplate, BentoDashboardSection } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoDashboardTemplate, BentoDashboardSection },\n * template: `\n * <bento-dashboard-template :header=\"{ title: 'Dashboard'}\" :tabs=\"tabs: [{ title: 'Tab 1' }, { title: 'Tab 2' }]\" sticky-tabs sticky-filters>\n * <template #tab-1>\n * <bento-dashboard-section :header=\"{ title: 'Section'}\">\n * <template #controls>\n * // Add your controls here\n * </template>\n * // Add your content here\n * </bento-dashboard-section>\n * </template>\n * <template #tab-2>\n * <bento-dashboard-section :header=\"{ title: 'Section'}\">\n * // Add your content here\n * </bento-dashboard-section>\n * </template>\n * </bento-dashboard-template>\n * `\n * }\n */\n export default {};\n</script>\n\n<style lang=\"scss\" scoped src=\"./dashboard-template.scss\" />\n","<template>\n <div class=\"b-dashboard-section\" :class=\"conditionalClasses\">\n <bento-header v-bind=\"header\" variant=\"component\" class=\"b-dashboard-template__header\">\n <template v-if=\"hasSlot('infoIconTooltipContent')\" #infoIconTooltipContent>\n <slot name=\"infoIconTooltipContent\" />\n </template>\n </bento-header>\n <div v-if=\"hasSlot('controls')\" class=\"b-dashboard-section__controls\">\n <slot name=\"controls\"></slot>\n </div>\n <div v-if=\"!hasSlot('content-col-1') && !hasSlot('content-col-2')\" class=\"b-dashboard-section__content\">\n <slot name=\"default\"></slot>\n </div>\n <div v-else class=\"b-dashboard-section__columns\">\n <div class=\"b-dashboard-section__content\"><slot name=\"content-col-1\"></slot></div>\n <div class=\"b-dashboard-section__content\"><slot name=\"content-col-2\"></slot></div>\n </div>\n <bento-divider class=\"b-dashboard-section__divider\" />\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, onMounted, useSlots } from 'vue';\n import { BentoHeader } from '@/components/header';\n import { BentoDivider } from '@/components/divider';\n import { useHasSlot } from '@/composables';\n import type { BentoDashboardTemplateHeader } from '../../dashboard-template.types';\n\n const props = defineProps({\n header: null,\n halfWidth: { type: Boolean, default: false }\n});\n\n const slots = useSlots();\n const hasSlot = useHasSlot(slots);\n\n const conditionalClasses = computed(() => ({\n 'b-dashboard-section--half-width': props.halfWidth,\n }));\n\n onMounted(() => {\n if ((hasSlot('content-col-1') || hasSlot('content-col-2')) && props.halfWidth) {\n throw new Error('`content-col-1` and `content-col-2` cannot be used with half-width prop');\n }\n });\n</script>\n\n<script lang=\"ts\">\n /**\n * Dashboard section is subcomponent of Dashboard template meant to be used to create the different sections within the page.\n *\n * @example\n * import { BentoDashboardSection } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoDashboardSection },\n * template: `\n * <bento-dashboard-section :header=\"{ title: 'Section' }\" half-width>\n * <template #controls>\n * // Add your controls here\n * </template>\n * // You can render content with two cols\n * <template #content-col-1>\n * // Add your content here\n * </template>\n * <template #content-col-2>\n * // Add your content here\n * </template>\n * // Or you can render full width content by using default slot\n * // Add your content here\n * </bento-dashboard-section>\n * `\n * }\n */\n export default {};\n</script>\n\n<style lang=\"scss\" scoped src=\"./dashboard-section.scss\" />\n"],"names":["__default__$1","slots","useSlots","hasSlot","useHasSlot","tabsRef","ref","filtersRef","isFiltersPinned","filtersElementObserver","isTabsPinned","tabsPosition","hasStickyFilters","computed","props","hasStickyTabs","dashboardFiltersConditionalClasses","dashboardTabsConditionalClasses","dashboardTopSectionConditionalClasses","tabsSlots","el","getTabTitle","index","_b","_a","y","useWindowScroll","watch","observeSizeOfElement","filtersHeight","onUnmounted","__default__","conditionalClasses","onMounted"],"mappings":";;;;;;;;;AAuJI,MAAAA,IAAA,CAAA;;;;;;;;;;iBAhGAC,IAAAC,EAAA,GACAC,IAAAC,EAAAH,CAAA,GA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