@adyen/bento-vue2 1.74.0 → 1.76.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/dist/@types/index.d.ts +1693 -616
  2. package/dist/assets/accordion-item.css +1 -1
  3. package/dist/assets/action-bar.css +1 -1
  4. package/dist/assets/base-modal.css +1 -1
  5. package/dist/assets/button-actions.css +1 -1
  6. package/dist/assets/calendar.css +1 -1
  7. package/dist/assets/card.css +1 -1
  8. package/dist/assets/data-grid-template.css +1 -1
  9. package/dist/assets/data-grid.css +1 -1
  10. package/dist/assets/date-picker.css +1 -1
  11. package/dist/assets/date-range-picker.css +1 -1
  12. package/dist/assets/dialog-page.css +1 -1
  13. package/dist/assets/dropdown-tag.css +1 -1
  14. package/dist/assets/file-uploader.css +1 -1
  15. package/dist/assets/filter-bar.css +1 -1
  16. package/dist/assets/header-meta.css +1 -1
  17. package/dist/assets/input-field-password.css +1 -1
  18. package/dist/assets/input-field.css +1 -1
  19. package/dist/assets/inspector.css +1 -1
  20. package/dist/assets/modal-fullscreen.css +1 -1
  21. package/dist/assets/selection-card-group.css +1 -1
  22. package/dist/assets/sidepanel.css +1 -1
  23. package/dist/assets/timeline-item.css +1 -1
  24. package/dist/assets/use-cached-selected-values.css +1 -1
  25. package/dist/checkbox.js +2 -2
  26. package/dist/chunks/calendar.Fm_dfQC5.js +1871 -0
  27. package/dist/chunks/calendar.Fm_dfQC5.js.map +1 -0
  28. package/dist/chunks/{checkbox-group.DETXTJqI.js → checkbox-group.CtNVRcmP.js} +2 -2
  29. package/dist/chunks/{checkbox-group.DETXTJqI.js.map → checkbox-group.CtNVRcmP.js.map} +1 -1
  30. package/dist/chunks/{checkbox.BPtHAAEa.js → checkbox.nyUc0gLb.js} +18 -18
  31. package/dist/chunks/{checkbox.BPtHAAEa.js.map → checkbox.nyUc0gLb.js.map} +1 -1
  32. package/dist/chunks/{code-snippet.VtrsOTEC.js → code-snippet.DFf3KMSi.js} +2 -2
  33. package/dist/chunks/{code-snippet.VtrsOTEC.js.map → code-snippet.DFf3KMSi.js.map} +1 -1
  34. package/dist/chunks/constructNow.CHWWeLPc.js +8 -0
  35. package/dist/chunks/constructNow.CHWWeLPc.js.map +1 -0
  36. package/dist/chunks/{currency.DDB4G_A8.js → currency.AvvbekWO.js} +15 -14
  37. package/dist/chunks/{currency.DDB4G_A8.js.map → currency.AvvbekWO.js.map} +1 -1
  38. package/dist/chunks/{dashboard-section.jIpBvP6X.js → dashboard-section.D1l7wDX3.js} +2 -2
  39. package/dist/chunks/{dashboard-section.jIpBvP6X.js.map → dashboard-section.D1l7wDX3.js.map} +1 -1
  40. package/dist/chunks/{data-grid-template.CozTcWQ0.js → data-grid-template.DGUDqzjj.js} +2 -2
  41. package/dist/chunks/{data-grid-template.CozTcWQ0.js.map → data-grid-template.DGUDqzjj.js.map} +1 -1
  42. package/dist/chunks/{data-grid.DN9xml8y.js → data-grid.B5aCkT0o.js} +1257 -1223
  43. package/dist/chunks/data-grid.B5aCkT0o.js.map +1 -0
  44. package/dist/chunks/{date-picker.DoYYzWcA.js → date-picker.DImAYvoM.js} +14 -14
  45. package/dist/chunks/date-picker.DImAYvoM.js.map +1 -0
  46. package/dist/chunks/date-range-picker.DgZMERzx.js +914 -0
  47. package/dist/chunks/date-range-picker.DgZMERzx.js.map +1 -0
  48. package/dist/chunks/{get-date-locale.CAyOIbcp.js → differenceInMonths.C8FyCrav.js} +580 -364
  49. package/dist/chunks/differenceInMonths.C8FyCrav.js.map +1 -0
  50. package/dist/chunks/dropdown-tag.CpvU8eSZ.js +260 -0
  51. package/dist/chunks/dropdown-tag.CpvU8eSZ.js.map +1 -0
  52. package/dist/chunks/{dropdown.BOvtYKXS.js → dropdown.RxD2TqnP.js} +14 -14
  53. package/dist/chunks/{dropdown.BOvtYKXS.js.map → dropdown.RxD2TqnP.js.map} +1 -1
  54. package/dist/chunks/es6.MoTTyETW.js.map +1 -1
  55. package/dist/chunks/{filter-bar.DzHJi42d.js → filter-bar.C0S87JZD.js} +511 -486
  56. package/dist/chunks/filter-bar.C0S87JZD.js.map +1 -0
  57. package/dist/chunks/getRoundingMethod.C3eaeGLR.js +10 -0
  58. package/dist/chunks/getRoundingMethod.C3eaeGLR.js.map +1 -0
  59. package/dist/chunks/{index.BrH1t1iu.js → getTimezoneOffsetInMilliseconds.BW7U6PxE.js} +254 -177
  60. package/dist/chunks/getTimezoneOffsetInMilliseconds.BW7U6PxE.js.map +1 -0
  61. package/dist/chunks/header-meta.D-6dL1Vg.js +170 -0
  62. package/dist/chunks/header-meta.D-6dL1Vg.js.map +1 -0
  63. package/dist/chunks/{header-with-views.t5Fr63SD.js → header-with-views.j16q5wEc.js} +4 -4
  64. package/dist/chunks/{header-with-views.t5Fr63SD.js.map → header-with-views.j16q5wEc.js.map} +1 -1
  65. package/dist/chunks/{header.DwSyDQ68.js → header.DoWKsA15.js} +2 -2
  66. package/dist/chunks/{header.DwSyDQ68.js.map → header.DoWKsA15.js.map} +1 -1
  67. package/dist/chunks/{input-field-password.Dm3HYonF.js → input-field-password.CSfXqEbT.js} +47 -38
  68. package/dist/chunks/input-field-password.CSfXqEbT.js.map +1 -0
  69. package/dist/chunks/{input-field-phone-number.bZauIuHJ.js → input-field-phone-number.oa4hXQdK.js} +3 -3
  70. package/dist/chunks/{input-field-phone-number.bZauIuHJ.js.map → input-field-phone-number.oa4hXQdK.js.map} +1 -1
  71. package/dist/chunks/input-field.DdQu3b1-.js +161 -0
  72. package/dist/chunks/input-field.DdQu3b1-.js.map +1 -0
  73. package/dist/chunks/{pagination.CKD9FDrA.js → pagination.C0YW_A_o.js} +2 -2
  74. package/dist/chunks/{pagination.CKD9FDrA.js.map → pagination.C0YW_A_o.js.map} +1 -1
  75. package/dist/chunks/radio-group.AcYMFudv.js.map +1 -1
  76. package/dist/chunks/{rich-text-editor.BZgQ578S.js → rich-text-editor.eYW8X_YP.js} +354 -352
  77. package/dist/chunks/{rich-text-editor.BZgQ578S.js.map → rich-text-editor.eYW8X_YP.js.map} +1 -1
  78. package/dist/chunks/{search-bar.c-w7Uky2.js → search-bar.DJVfPz-f.js} +3 -3
  79. package/dist/chunks/{search-bar.c-w7Uky2.js.map → search-bar.DJVfPz-f.js.map} +1 -1
  80. package/dist/chunks/{secondary-nav.D69COlqF.js → secondary-nav.BFiTQaag.js} +2 -2
  81. package/dist/chunks/{secondary-nav.D69COlqF.js.map → secondary-nav.BFiTQaag.js.map} +1 -1
  82. package/dist/chunks/{selection-card-group.8UIir78G.js → selection-card-group.D4rcUyvV.js} +58 -120
  83. package/dist/chunks/{selection-card-group.8UIir78G.js.map → selection-card-group.D4rcUyvV.js.map} +1 -1
  84. package/dist/chunks/textarea.CIQuLWQ8.js.map +1 -1
  85. package/dist/chunks/{timeline-item.VSw9vKdO.js → timeline-item.CZBuknZ_.js} +156 -168
  86. package/dist/chunks/timeline-item.CZBuknZ_.js.map +1 -0
  87. package/dist/chunks/{use-cached-selected-values.IsfhJHxQ.js → use-cached-selected-values.BZd3CTeP.js} +334 -314
  88. package/dist/chunks/use-cached-selected-values.BZd3CTeP.js.map +1 -0
  89. package/dist/code-snippet.js +1 -1
  90. package/dist/currency.js +1 -1
  91. package/dist/dashboard-template.js +1 -1
  92. package/dist/data-grid-template.js +1 -1
  93. package/dist/data-grid.js +1 -1
  94. package/dist/date-picker.js +2 -2
  95. package/dist/date-range-picker.js +2 -2
  96. package/dist/dropdown.js +3 -3
  97. package/dist/filter-bar.js +1 -1
  98. package/dist/header-with-views.js +1 -1
  99. package/dist/header.js +1 -1
  100. package/dist/index.js +221 -220
  101. package/dist/input-field-password.js +1 -1
  102. package/dist/input-field-phone-number.js +1 -1
  103. package/dist/input-field.js +1 -1
  104. package/dist/internal.js +3 -3
  105. package/dist/pagination.js +1 -1
  106. package/dist/rich-text-editor.js +1 -1
  107. package/dist/search-bar.js +2 -2
  108. package/dist/secondary-nav.js +1 -1
  109. package/dist/selection-card.js +1 -1
  110. package/dist/styles/bento-dark.css +7 -5
  111. package/dist/styles/bento-light.css +7 -5
  112. package/dist/styles/bento.css +7 -5
  113. package/dist/styles/legacy.css +7 -5
  114. package/dist/styles/styleguide.css +7 -5
  115. package/dist/timeline.js +1 -1
  116. package/dist/web-types.json +692 -1390
  117. package/package.json +12 -27
  118. package/dist/chunks/_commonjsHelpers.C6fGbg64.js +0 -7
  119. package/dist/chunks/_commonjsHelpers.C6fGbg64.js.map +0 -1
  120. package/dist/chunks/calendar.EfqJlztU.js +0 -2093
  121. package/dist/chunks/calendar.EfqJlztU.js.map +0 -1
  122. package/dist/chunks/data-grid.DN9xml8y.js.map +0 -1
  123. package/dist/chunks/date-picker.DoYYzWcA.js.map +0 -1
  124. package/dist/chunks/date-range-picker.C_pJ8yH5.js +0 -917
  125. package/dist/chunks/date-range-picker.C_pJ8yH5.js.map +0 -1
  126. package/dist/chunks/dropdown-tag.DBnurtCQ.js +0 -245
  127. package/dist/chunks/dropdown-tag.DBnurtCQ.js.map +0 -1
  128. package/dist/chunks/filter-bar.DzHJi42d.js.map +0 -1
  129. package/dist/chunks/get-date-locale.CAyOIbcp.js.map +0 -1
  130. package/dist/chunks/header-meta.uiIO1wHP.js +0 -185
  131. package/dist/chunks/header-meta.uiIO1wHP.js.map +0 -1
  132. package/dist/chunks/index.BrH1t1iu.js.map +0 -1
  133. package/dist/chunks/index.BxBB1rsx.js +0 -15
  134. package/dist/chunks/index.BxBB1rsx.js.map +0 -1
  135. package/dist/chunks/input-field-password.Dm3HYonF.js.map +0 -1
  136. package/dist/chunks/input-field.D52XYEzU.js +0 -157
  137. package/dist/chunks/input-field.D52XYEzU.js.map +0 -1
  138. package/dist/chunks/timeline-item.VSw9vKdO.js.map +0 -1
  139. package/dist/chunks/use-cached-selected-values.IsfhJHxQ.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { defineComponent as y, toRef as _, computed as l, watch as c, ref as v } from "vue";
2
- import { a as n, B as E } from "./checkbox.BPtHAAEa.js";
2
+ import { a as n, B as E } from "./checkbox.nyUc0gLb.js";
3
3
  import { g as x } from "./generate-uid.NJ8tVoha.js";
4
4
  import { d as k } from "./typography.hlOAxsEn.js";
5
5
  import { u as C } from "./use-form-layout-loading.D3lALhtC.js";
@@ -149,4 +149,4 @@ export {
149
149
  s as B,
150
150
  q as c
151
151
  };
152
- //# sourceMappingURL=checkbox-group.DETXTJqI.js.map
152
+ //# sourceMappingURL=checkbox-group.CtNVRcmP.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox-group.DETXTJqI.js","sources":["../../src/components/checkbox/components/checkbox-group/checkbox-group.types.ts","../../src/components/checkbox/components/checkbox-group/checkbox-group.vue"],"sourcesContent":["import type { BentoCheckboxTag } from '../../checkbox.types';\n\n/**\n * @deprecated for usage with properties since version 2.0. Use the string literal instead.\n */\nexport enum BentoCheckboxGroupVariant {\n HORIZONTAL = 'horizontal',\n VERTICAL = 'vertical',\n}\n\ninterface BentoCheckboxGroupItem {\n value: string | number;\n label: string;\n description?: string;\n disabled?: boolean;\n hasError?: boolean;\n errorMessage?: string;\n readonly?: boolean;\n tag?: BentoCheckboxTag;\n}\n\nexport type BentoCheckboxGroupItems = Array<BentoCheckboxGroupItem>;\n","<template>\n <div class=\"b-checkbox-group\">\n <controls-group\n class=\"b-checkbox-group__checkboxes\"\n :aria-describedby=\"shouldShowGroupErrorMessage ? errorId : ''\"\n :component-name=\"COMPONENT_NAME\"\n :class=\"conditionalClasses\"\n :description=\"description\"\n :disabled=\"disabled\"\n :form=\"formId\"\n :hide-label=\"hideLabel\"\n :label=\"label\"\n :optional=\"optional\"\n :required=\"required\"\n :tooltip-text=\"tooltipText\"\n >\n <bento-checkbox\n v-for=\"item in items\"\n :key=\"item.value\"\n :model-value=\"inputValue\"\n :value=\"item.value\"\n :disabled=\"disabled || item.disabled\"\n :has-error=\"shouldShowGroupError || item.hasError\"\n :error-message=\"shouldShowGroupError ? null : item.errorMessage\"\n :readonly=\"isReadOnly || item.readonly\"\n :tag=\"item.tag\"\n @update:model-value=\"onInput\"\n >\n <template #default>{{ item.label }}</template>\n <template v-if=\"item.description\" #description>{{ item.description }}</template>\n <template v-if=\"hasContentSlot('content')\" #content>\n <slot name=\"content\" v-bind=\"item\"></slot>\n </template>\n </bento-checkbox>\n </controls-group>\n <error-message\n v-if=\"shouldShowGroupErrorMessage\"\n :id=\"errorId\"\n :error-message=\"errorMessage\"\n class=\"b-checkbox-group__error-message\"\n />\n </div>\n</template>\n\n<script lang=\"ts\">\n import { computed, defineComponent, type PropType, ref, toRef, watch } from 'vue';\n import { ControlsGroup } from '@/components/internal/controls-group';\n import { ErrorMessage } from '@/components/internal/error-message';\n import { type BentoCheckboxGroupItems, BentoCheckboxGroupVariant } from './checkbox-group.types';\n import BentoCheckbox from '@/components/checkbox/checkbox.vue';\n import { BentoCheckboxEvent } from '../../checkbox.types';\n import { generateUid } from '@/core/utils/ts';\n import { deprecate } from '@/utils/ts/deprecate';\n import { useFormLayoutFieldLoading } from '@/composables/use-form-layout-loading/use-form-layout-loading';\n\n /**\n * The name of the component to be used in the Vue devtools and console warnings.\n */\n const COMPONENT_NAME = 'bento-checkbox-group';\n\n /**\n * A checkbox group component should be used whenever it is necessary to group a set of checkboxes that are related together\n * This component conforms to the official WAI-ARIA guidelines for grouping controls: https://www.w3.org/WAI/tutorials/forms/grouping/\n *\n * import { BentoCheckboxGroup } from '@adyen/bento-vue2/';\n *\n * export default {\n * components: { BentoCheckboxGroup },\n * template: `\n * <bento-checkbox-group\n * label=\"Your group label\"\n * :items=\"[\n * { value: 1, label: 'Your label' },\n * { value: 2, label: 'Another label', description: 'Your sub label' },\n * ]\"\n * />\n * `\n * };\n */\n export default defineComponent({\n name: COMPONENT_NAME,\n components: { BentoCheckbox, ControlsGroup, ErrorMessage },\n model: { prop: 'modelValue' },\n props: {\n /**\n * Descriptive supporting text visbile underneath the label.\n */\n description: { type: String, default: null },\n\n /**\n * If set to true, renders all checkboxes in the group in a disabled state.\n */\n disabled: { type: Boolean, default: false },\n\n /**\n * Renders all checkboxes in an error state with an error message.\n */\n errorMessage: { type: String, default: null },\n\n /**\n * The form id the checkbox group is associated with. Defaults to null, as a checkbox group can also be used standalone.\n */\n formId: { type: String, default: null },\n\n /**\n * If set to true, renders all checkboxes in the group in an error state.\n *\n * @deprecated Use \"errorMessage\" prop instead\n */\n hasError: { type: Boolean, default: false },\n\n /**\n * Shows/hides the group label.\n */\n hideLabel: { type: Boolean, default: null },\n\n /**\n * The checkbox group's items.\n */\n items: { type: Array as PropType<BentoCheckboxGroupItems>, required: true },\n\n /**\n * The name associated with the group. Required for accessibility purposes.\n */\n label: { type: String, required: true },\n\n /**\n * Determines the initially selected value of the group. Corresponds to the BentoCheckboxButtonItem's value.\n * Defaults to no value selected.\n */\n modelValue: { type: Array<number | string | null>, default: () => [] },\n\n /**\n * Indicates the field is optional.\n */\n optional: { type: Boolean, default: false },\n\n /**\n * If set to true, renders all checkboxes in the group in a readonly state.\n */\n readonly: { type: Boolean, default: false },\n\n /**\n * Indicates the field is required.\n */\n required: { type: Boolean, default: false },\n\n /**\n * Tooltip message.\n */\n tooltipText: { type: String, default: null },\n\n /**\n * The checkbox group's layout. It can be vertical or horizontal. Defaults to vertical.\n */\n variant: {\n type: String as PropType<BentoCheckboxGroupVariant | `${BentoCheckboxGroupVariant}`>,\n default: BentoCheckboxGroupVariant.VERTICAL,\n validator: (value: BentoCheckboxGroupVariant) =>\n Object.values(BentoCheckboxGroupVariant).includes(value),\n },\n },\n emits: [BentoCheckboxEvent.UPDATE, BentoCheckboxEvent.INPUT],\n setup(props, { emit, slots }) {\n const errorId = generateUid('error');\n const { isReadOnly } = useFormLayoutFieldLoading(toRef(props, 'readonly'));\n\n const shouldShowGroupError = computed(\n () => !props.disabled && !isReadOnly.value && (!!props.errorMessage || props.hasError)\n );\n const shouldShowGroupErrorMessage = computed(\n () => !props.disabled && !isReadOnly.value && !!props.errorMessage\n );\n\n const conditionalClasses = computed(() => ({\n 'b-checkbox-group__checkboxes--horizontal': props.variant === BentoCheckboxGroupVariant.HORIZONTAL,\n }));\n\n // Slots logic\n // Temporary, use-has-slots composable doesn't currently work for\n // vue3 named scoped slots\n const hasContentSlot = name => !!slots[name];\n const shouldShowSlotsError = computed(() => hasContentSlot('content') && props.variant !== 'vertical');\n\n watch(\n shouldShowSlotsError,\n newValue => {\n if (newValue) {\n throw new Error('The content slot is only available for the vertical checkbox group layout');\n }\n },\n { immediate: true }\n );\n\n const inputValue = ref(props.modelValue);\n watch(\n () => props.modelValue,\n () => {\n inputValue.value = props.modelValue;\n }\n );\n\n const onInput = value => {\n inputValue.value = value;\n emit(BentoCheckboxEvent.UPDATE, value);\n emit(BentoCheckboxEvent.INPUT, value);\n };\n\n if (props.hasError) {\n deprecate(\n 'BentoCheckboxGroup \"hasError\" property',\n `Use the BentoCheckboxGroup \"errorMessage\" property instead to indicate that there is a modifier error.\n Having the field as \"undefined\" will hide/remove the error.\n <bento-checkbox-group errorMessage=\"Error message text\" />`,\n '2.0.0'\n );\n }\n\n return {\n // Values\n COMPONENT_NAME,\n errorId,\n isReadOnly,\n shouldShowGroupError,\n shouldShowGroupErrorMessage,\n conditionalClasses,\n inputValue,\n hasContentSlot,\n\n // Methods\n onInput,\n };\n },\n });\n</script>\n\n<style lang=\"scss\" scoped src=\"./checkbox-group.scss\" />\n"],"names":["BentoCheckboxGroupVariant","BentoCheckboxGroupVariant2","COMPONENT_NAME","_sfc_main","defineComponent","BentoCheckbox","ControlsGroup","ErrorMessage","value","BentoCheckboxEvent","props","emit","slots","errorId","generateUid","isReadOnly","useFormLayoutFieldLoading","toRef","shouldShowGroupError","computed","shouldShowGroupErrorMessage","conditionalClasses","hasContentSlot","name","shouldShowSlotsError","watch","newValue","inputValue","ref","onInput","deprecate"],"mappings":";;;;;;;;;AAKY,IAAAA,IAAA,kBAAAC,OACRA,EAAA,aAAA,cACAA,EAAA,WAAA,YAFQA,IAAAD,KAAA,CAAA,CAAA;ACqDZ,MAAAE,IAAA,wBAqBAC,IAAAC,EAAA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,oBAAAC;AAAA,MACA,YAAAM;AAAA,MACA,gBAAAL;AAAA;AAAA,MACA,SAAAO;AAAA,IAGA;AAAA,EACA;AAEA,CAAA;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"checkbox-group.CtNVRcmP.js","sources":["../../src/components/checkbox/components/checkbox-group/checkbox-group.types.ts","../../src/components/checkbox/components/checkbox-group/checkbox-group.vue"],"sourcesContent":["import type { BentoCheckboxTag } from '../../checkbox.types';\n\n/**\n * @deprecated for usage with properties since version 2.0. Use the string literal instead.\n */\nexport enum BentoCheckboxGroupVariant {\n HORIZONTAL = 'horizontal',\n VERTICAL = 'vertical',\n}\n\ninterface BentoCheckboxGroupItem {\n value: string | number;\n label: string;\n description?: string;\n disabled?: boolean;\n hasError?: boolean;\n errorMessage?: string;\n readonly?: boolean;\n tag?: BentoCheckboxTag;\n}\n\nexport type BentoCheckboxGroupItems = Array<BentoCheckboxGroupItem>;\n","<template>\n <div class=\"b-checkbox-group\">\n <controls-group\n class=\"b-checkbox-group__checkboxes\"\n :aria-describedby=\"shouldShowGroupErrorMessage ? errorId : ''\"\n :component-name=\"COMPONENT_NAME\"\n :class=\"conditionalClasses\"\n :description=\"description\"\n :disabled=\"disabled\"\n :form=\"formId\"\n :hide-label=\"hideLabel\"\n :label=\"label\"\n :optional=\"optional\"\n :required=\"required\"\n :tooltip-text=\"tooltipText\"\n >\n <bento-checkbox\n v-for=\"item in items\"\n :key=\"item.value\"\n :model-value=\"inputValue\"\n :value=\"item.value\"\n :disabled=\"disabled || item.disabled\"\n :has-error=\"shouldShowGroupError || item.hasError\"\n :error-message=\"shouldShowGroupError ? null : item.errorMessage\"\n :readonly=\"isReadOnly || item.readonly\"\n :tag=\"item.tag\"\n @update:model-value=\"onInput\"\n >\n <template #default>{{ item.label }}</template>\n <template v-if=\"item.description\" #description>{{ item.description }}</template>\n <template v-if=\"hasContentSlot('content')\" #content>\n <slot name=\"content\" v-bind=\"item\"></slot>\n </template>\n </bento-checkbox>\n </controls-group>\n <error-message\n v-if=\"shouldShowGroupErrorMessage\"\n :id=\"errorId\"\n :error-message=\"errorMessage\"\n class=\"b-checkbox-group__error-message\"\n />\n </div>\n</template>\n\n<script lang=\"ts\">\n import { computed, defineComponent, type PropType, ref, toRef, watch } from 'vue';\n import { ControlsGroup } from '@/components/internal/controls-group';\n import { ErrorMessage } from '@/components/internal/error-message';\n import { type BentoCheckboxGroupItems, BentoCheckboxGroupVariant } from './checkbox-group.types';\n import BentoCheckbox from '@/components/checkbox/checkbox.vue';\n import { BentoCheckboxEvent } from '../../checkbox.types';\n import { generateUid } from '@/core/utils/ts';\n import { deprecate } from '@/utils/ts/deprecate';\n import { useFormLayoutFieldLoading } from '@/composables/use-form-layout-loading/use-form-layout-loading';\n\n /**\n * The name of the component to be used in the Vue devtools and console warnings.\n */\n const COMPONENT_NAME = 'bento-checkbox-group';\n\n /**\n * A checkbox group component should be used whenever it is necessary to group a set of checkboxes that are related together\n * This component conforms to the official WAI-ARIA guidelines for grouping controls: https://www.w3.org/WAI/tutorials/forms/grouping/\n *\n * import { BentoCheckboxGroup } from '@adyen/bento-vue2/';\n *\n * export default {\n * components: { BentoCheckboxGroup },\n * template: `\n * <bento-checkbox-group\n * label=\"Your group label\"\n * :items=\"[\n * { value: 1, label: 'Your label' },\n * { value: 2, label: 'Another label', description: 'Your sub label' },\n * ]\"\n * />\n * `\n * };\n */\n export default defineComponent({\n name: COMPONENT_NAME,\n components: { BentoCheckbox, ControlsGroup, ErrorMessage },\n model: { prop: 'modelValue' },\n props: {\n /**\n * Descriptive supporting text visbile underneath the label.\n */\n description: { type: String, default: null },\n\n /**\n * If set to true, renders all checkboxes in the group in a disabled state.\n */\n disabled: { type: Boolean, default: false },\n\n /**\n * Renders all checkboxes in an error state with an error message.\n */\n errorMessage: { type: String, default: null },\n\n /**\n * The form id the checkbox group is associated with. Defaults to null, as a checkbox group can also be used standalone.\n */\n formId: { type: String, default: null },\n\n /**\n * If set to true, renders all checkboxes in the group in an error state.\n *\n * @deprecated Use \"errorMessage\" prop instead\n */\n hasError: { type: Boolean, default: false },\n\n /**\n * Shows/hides the group label.\n */\n hideLabel: { type: Boolean, default: null },\n\n /**\n * The checkbox group's items.\n */\n items: { type: Array as PropType<BentoCheckboxGroupItems>, required: true },\n\n /**\n * The name associated with the group. Required for accessibility purposes.\n */\n label: { type: String, required: true },\n\n /**\n * Determines the initially selected value of the group. Corresponds to the BentoCheckboxButtonItem's value.\n * Defaults to no value selected.\n */\n modelValue: { type: Array<number | string | null>, default: () => [] },\n\n /**\n * Indicates the field is optional.\n */\n optional: { type: Boolean, default: false },\n\n /**\n * If set to true, renders all checkboxes in the group in a readonly state.\n */\n readonly: { type: Boolean, default: false },\n\n /**\n * Indicates the field is required.\n */\n required: { type: Boolean, default: false },\n\n /**\n * Tooltip message.\n */\n tooltipText: { type: String, default: null },\n\n /**\n * The checkbox group's layout. It can be vertical or horizontal. Defaults to vertical.\n */\n variant: {\n type: String as PropType<BentoCheckboxGroupVariant | `${BentoCheckboxGroupVariant}`>,\n default: BentoCheckboxGroupVariant.VERTICAL,\n validator: (value: BentoCheckboxGroupVariant) =>\n Object.values(BentoCheckboxGroupVariant).includes(value),\n },\n },\n emits: [BentoCheckboxEvent.UPDATE, BentoCheckboxEvent.INPUT],\n setup(props, { emit, slots }) {\n const errorId = generateUid('error');\n const { isReadOnly } = useFormLayoutFieldLoading(toRef(props, 'readonly'));\n\n const shouldShowGroupError = computed(\n () => !props.disabled && !isReadOnly.value && (!!props.errorMessage || props.hasError)\n );\n const shouldShowGroupErrorMessage = computed(\n () => !props.disabled && !isReadOnly.value && !!props.errorMessage\n );\n\n const conditionalClasses = computed(() => ({\n 'b-checkbox-group__checkboxes--horizontal': props.variant === BentoCheckboxGroupVariant.HORIZONTAL,\n }));\n\n // Slots logic\n // Temporary, use-has-slots composable doesn't currently work for\n // vue3 named scoped slots\n const hasContentSlot = name => !!slots[name];\n const shouldShowSlotsError = computed(() => hasContentSlot('content') && props.variant !== 'vertical');\n\n watch(\n shouldShowSlotsError,\n newValue => {\n if (newValue) {\n throw new Error('The content slot is only available for the vertical checkbox group layout');\n }\n },\n { immediate: true }\n );\n\n const inputValue = ref(props.modelValue);\n watch(\n () => props.modelValue,\n () => {\n inputValue.value = props.modelValue;\n }\n );\n\n const onInput = value => {\n inputValue.value = value;\n emit(BentoCheckboxEvent.UPDATE, value);\n emit(BentoCheckboxEvent.INPUT, value);\n };\n\n if (props.hasError) {\n deprecate(\n 'BentoCheckboxGroup \"hasError\" property',\n `Use the BentoCheckboxGroup \"errorMessage\" property instead to indicate that there is a modifier error.\n Having the field as \"undefined\" will hide/remove the error.\n <bento-checkbox-group errorMessage=\"Error message text\" />`,\n '2.0.0'\n );\n }\n\n return {\n // Values\n COMPONENT_NAME,\n errorId,\n isReadOnly,\n shouldShowGroupError,\n shouldShowGroupErrorMessage,\n conditionalClasses,\n inputValue,\n hasContentSlot,\n\n // Methods\n onInput,\n };\n },\n });\n</script>\n\n<style lang=\"scss\" scoped src=\"./checkbox-group.scss\" />\n"],"names":["BentoCheckboxGroupVariant","BentoCheckboxGroupVariant2","COMPONENT_NAME","_sfc_main","defineComponent","BentoCheckbox","ControlsGroup","ErrorMessage","value","BentoCheckboxEvent","props","emit","slots","errorId","generateUid","isReadOnly","useFormLayoutFieldLoading","toRef","shouldShowGroupError","computed","shouldShowGroupErrorMessage","conditionalClasses","hasContentSlot","name","shouldShowSlotsError","watch","newValue","inputValue","ref","onInput","deprecate"],"mappings":";;;;;;;;;AAKY,IAAAA,IAAA,kBAAAC,OACRA,EAAA,aAAA,cACAA,EAAA,WAAA,YAFQA,IAAAD,KAAA,CAAA,CAAA;ACqDZ,MAAAE,IAAA,wBAqBAC,IAAAC,EAAA;AAAA,EAAA,MAAAF;AAAA,EACA,YAAA,EAAA,eAAAG,GAAA,eAAAC,GAAA,cAAAC,EAAA;AAAA,EACA,OAAA,EAAA,MAAA,aAAA;AAAA,EACA,OAAA;AAAA;AAAA;AAAA;AA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1
  import { defineComponent as R, toRefs as k, computed as o, ref as A, onMounted as H, useAttrs as j } from "vue";
2
2
  import { B as F } from "./typography.hlOAxsEn.js";
3
- import { u as z } from "./use-default-slot-validator.BDn0wkYP.js";
4
- import { u as J } from "./use-has-slot.C9lQZ6nz.js";
5
- import { g as C } from "./generate-uid.NJ8tVoha.js";
3
+ import { C as z } from "./checkbox-input.B0NsfSNR.js";
4
+ import { C } from "./minus-small.DJacLGTw.js";
5
+ import { u as J } from "./use-default-slot-validator.BDn0wkYP.js";
6
+ import { u as O } from "./use-has-slot.C9lQZ6nz.js";
7
+ import { g as B } from "./generate-uid.NJ8tVoha.js";
6
8
  import { g as f } from "./get-slot-text.BQS5Olxm.js";
7
- import { u as O } from "./index.B6WW_F-J.js";
8
- import { u as Y } from "./aria-label.CaUURpnB.js";
9
- import { B as K } from "./tag.BwKc2d2E.js";
10
- import { E as Q } from "./field-label.Auq-Pzho.js";
11
- import { C as W } from "./checkbox-input.B0NsfSNR.js";
12
- import { C as B } from "./minus-small.DJacLGTw.js";
9
+ import { u as Y } from "./index.B6WW_F-J.js";
10
+ import { u as K } from "./aria-label.CaUURpnB.js";
11
+ import { B as Q } from "./tag.BwKc2d2E.js";
12
+ import { E as W } from "./field-label.Auq-Pzho.js";
13
13
  import { n as X } from "./_plugin-vue2_normalizer.CeySl7Fu.js";
14
14
  import "../assets/checkbox.css";
15
15
  var s = /* @__PURE__ */ ((a) => (a.UPDATE = "update:model-value", a.INPUT = "input", a))(s || {});
@@ -33,10 +33,10 @@ const Z = {
33
33
  name: "bento-checkbox",
34
34
  i18n: { messages: Z },
35
35
  components: {
36
- BentoTag: K,
36
+ BentoTag: Q,
37
37
  BentoTypography: F,
38
- CheckboxInput: W,
39
- ErrorMessage: Q
38
+ CheckboxInput: z,
39
+ ErrorMessage: W
40
40
  },
41
41
  inheritAttrs: !1,
42
42
  model: { prop: "modelValue" },
@@ -105,8 +105,8 @@ const Z = {
105
105
  },
106
106
  emits: [s.UPDATE, s.INPUT],
107
107
  setup(a, { attrs: e, emit: t, slots: l }) {
108
- const { t: m } = O(), h = C("description"), _ = C("error"), d = J(l), { disabled: y, indeterminate: E, modelValue: u, readonly: I, value: T } = k(a), v = f(l)("default"), g = f(l)("description");
109
- z("bento-checkbox", l.default, l.description);
108
+ const { t: m } = Y(), h = B("description"), _ = B("error"), d = O(l), { disabled: y, indeterminate: E, modelValue: u, readonly: I, value: T } = k(a), v = f(l)("default"), g = f(l)("description");
109
+ J("bento-checkbox", l.default, l.description);
110
110
  const n = o(() => Array.isArray(u.value)), b = o(() => n.value ? u.value.some((r) => r === T.value) : u.value), i = o(() => E.value), q = o(
111
111
  () => !a.disabled && !a.readonly && (a.hasError || !!a.errorMessage)
112
112
  ), x = o(() => !a.disabled && !a.readonly && !!a.errorMessage), c = o(() => d("content")), p = o(() => (i == null ? void 0 : i.value) || (b == null ? void 0 : b.value)), D = o(
@@ -118,7 +118,7 @@ const Z = {
118
118
  S.value = m("checkbox");
119
119
  });
120
120
  const U = o(
121
- () => Y({
121
+ () => K({
122
122
  ariaLabel: M.value,
123
123
  // TODO: take this line away when the aria-label props is removed
124
124
  label: P,
@@ -131,8 +131,8 @@ const Z = {
131
131
  style: r
132
132
  };
133
133
  }), N = o(() => ({
134
- [`b-checkbox--${B.DISABLED}`]: y.value,
135
- [`b-checkbox--${B.READONLY}`]: I.value
134
+ [`b-checkbox--${C.DISABLED}`]: y.value,
135
+ [`b-checkbox--${C.READONLY}`]: I.value
136
136
  }));
137
137
  return {
138
138
  // Values
@@ -175,4 +175,4 @@ export {
175
175
  _e as B,
176
176
  s as a
177
177
  };
178
- //# sourceMappingURL=checkbox.BPtHAAEa.js.map
178
+ //# sourceMappingURL=checkbox.nyUc0gLb.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.BPtHAAEa.js","sources":["../../src/components/checkbox/checkbox.types.ts","../../src/components/checkbox/checkbox.vue"],"sourcesContent":["import type { BentoTagProps } from '../tag/tag.types';\nimport {\n CheckboxInputState as BentoCheckboxState,\n type CheckboxInputType as BentoCheckboxType,\n type MultiCheckboxInputType as BentoMultiCheckboxType,\n} from '@/internal/checkbox-input/checkbox-input.types';\n\nexport { BentoCheckboxState, BentoCheckboxType, BentoMultiCheckboxType };\n\nexport enum BentoCheckboxEvent {\n UPDATE = 'update:model-value',\n INPUT = 'input',\n}\n\nexport type BentoCheckboxTag = BentoTagProps;\n","<template>\n <label class=\"b-checkbox\" :class=\"conditionalClass\" v-bind=\"styleAttrs\" :aria-hidden=\"getAriaHidden($attrs)\">\n <checkbox-input\n v-bind=\"$attrs\"\n ref=\"input\"\n :aria-label=\"computedAriaLabel\"\n :aria-describedby=\"ariaDescribedBy\"\n :disabled=\"disabled\"\n :has-error=\"shouldShowError\"\n :indeterminate=\"isIndeterminate\"\n :value=\"value\"\n :model-value=\"modelValue\"\n :readonly=\"readonly\"\n @update:model-value=\"onChange\"\n />\n <span v-if=\"hasSlot('default') || shouldShowErrorMessage\" class=\"b-checkbox__text\">\n <bento-typography v-if=\"hasSlot('default')\" class=\"b-checkbox__label\" el=\"span\" variant=\"body\">\n <span><slot /></span>\n <bento-typography v-if=\"optional\" class=\"b-checkbox__label-requirement\" el=\"span\"\n >({{ t('optional') }})</bento-typography\n >\n <bento-typography v-else-if=\"required\" class=\"b-checkbox__label-requirement\" el=\"span\"\n >({{ t('required') }})</bento-typography\n >\n <bento-tag v-if=\"tag\" class=\"b-checkbox__label-tag\" v-bind=\"tag\" />\n </bento-typography>\n <bento-typography\n v-if=\"hasSlot('default') && hasSlot('description')\"\n :id=\"descriptionId\"\n class=\"b-checkbox__description\"\n el=\"span\"\n variant=\"body\"\n >\n <slot name=\"description\"></slot>\n </bento-typography>\n <error-message v-if=\"shouldShowErrorMessage\" :id=\"errorId\" :error-message=\"errorMessage\" />\n\n <bento-typography v-if=\"contentSlotAvailable\" class=\"b-checkbox__content\" el=\"span\" variant=\"body\">\n <slot name=\"content\"></slot>\n </bento-typography>\n </span>\n </label>\n</template>\n\n<script lang=\"ts\">\n import {\n computed,\n defineComponent,\n type HTMLAttributes,\n onMounted,\n type PropType,\n ref,\n toRefs,\n useAttrs,\n } from 'vue';\n import {\n BentoCheckboxEvent,\n BentoCheckboxState,\n type BentoCheckboxTag,\n type BentoCheckboxType,\n type BentoMultiCheckboxType,\n } from './checkbox.types';\n import { BentoTypography } from '@/components/typography';\n import { CheckboxInput } from '@/components/internal/checkbox-input';\n import { ErrorMessage } from '@/components/internal/error-message';\n import { useDefaultSlotValidator, useHasSlot } from '@/composables';\n import { generateUid } from '@/core/utils/ts';\n import { getSlotText } from '@/utils/ts/get-slot-text';\n import { useI18n } from '@/utils/ts/i18n';\n import { useAriaLabel } from '@/utils/ts/aria-label';\n import { BentoTag } from '@/components/tag';\n import { type BentoCheckboxGroupItems } from './components/checkbox-group/checkbox-group.types';\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n /**\n * Checkboxes are used to make a binary choice about an option.\n * The label tag area is also clickable.\n *\n * @usage\n * import { BentoCheckbox } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoCheckbox },\n * template: `\n * <bento-checkbox>\n * Label text\n * <template #description>Sub label text</template>\n * </bento-checkbox>\n * `,\n * }\n */\n export default defineComponent({\n name: 'bento-checkbox',\n i18n: { messages },\n components: {\n BentoTag,\n BentoTypography,\n CheckboxInput,\n ErrorMessage,\n },\n inheritAttrs: false,\n model: { prop: 'modelValue' },\n props: {\n /**\n * @deprecated from version 2.0.0. Use the aria-label attribute instead.\n */\n /**\n * Accessible name for the radio button component. It is strongly recommended to pas this value in case this component is used without a label.\n */\n ariaLabel: { type: String, default: null },\n\n /**\n * Setting this property to true will disable the checkbox in your form.\n */\n disabled: { type: Boolean, default: false },\n\n /**\n * Renders the checkbox in an error state with an error message.\n */\n errorMessage: { type: String, default: null },\n\n /**\n * Setting this property to true will show the checkbox in error state.\n */\n hasError: { type: Boolean, default: false },\n\n /**\n * The :indeterminate CSS pseudo-class represents any form element\n * whose state is indeterminate, such as checkboxes which have their HTML indeterminate attribute\n * set to true, radio buttons which are members of a group in which all radio buttons are unchecked,\n * and indeterminate <progress> elements. https://developer.mozilla.org/en-US/docs/Web/CSS/:indeterminate\n * This property lets you control the input.indeterminate native property.\n */\n indeterminate: { type: Boolean, default: false },\n\n /**\n * When handling a single checkbox with a singular state, use a boolean.\n *\n * When handling multiple checkboxes, use an array of keys.\n * These keys exist as a set \"value\" prop for each checkbox.\n */\n modelValue: {\n type: [Boolean, Array] as PropType<BentoCheckboxType | BentoCheckboxGroupItems>,\n default: false,\n },\n\n /**\n * Highlights the checkbox is optional.\n */\n optional: { type: Boolean, default: false },\n\n /**\n * Setting this property to true will set the checkbox to read only state.\n */\n readonly: { type: Boolean, default: false },\n\n /**\n * Highlights the checkbox is required.\n */\n required: { type: Boolean, default: false },\n\n /**\n * Sets the properties of the BentoTag component that is placed next to the label.\n * {@see BentoTag}\n */\n tag: { type: Object as PropType<BentoCheckboxTag>, default: undefined },\n\n /**\n * The value of the component. The DOM API casts this to a string.\n * The browser uses \"on\" as the default value.\n *\n * In the case of multiple checkboxes this value is used as a unique key.\n */\n value: { type: [String, Number], default: null },\n },\n emits: [BentoCheckboxEvent.UPDATE, BentoCheckboxEvent.INPUT],\n setup(props, { attrs, emit, slots }) {\n const { t } = useI18n<{ message: MessageSchema }>({ messages });\n const descriptionId = generateUid('description');\n const errorId = generateUid('error');\n const hasSlot = useHasSlot(slots);\n\n const { disabled, indeterminate, modelValue, readonly, value } = toRefs(props);\n\n const defaultSlotValue = getSlotText(slots)('default');\n const descriptionSlotValue = getSlotText(slots)('description');\n\n useDefaultSlotValidator('bento-checkbox', slots.default, slots.description);\n\n const isCheckboxGroup = computed(() => Array.isArray(modelValue.value));\n const isChecked = computed(() => {\n if (!isCheckboxGroup.value) {\n return modelValue.value as boolean;\n }\n\n return (modelValue.value as BentoMultiCheckboxType).some(item => item === value.value);\n });\n const isIndeterminate = computed(() => indeterminate.value);\n\n const shouldShowError = computed(\n () => !props.disabled && !props.readonly && (props.hasError || !!props.errorMessage)\n );\n const shouldShowErrorMessage = computed(() => !props.disabled && !props.readonly && !!props.errorMessage);\n\n // Content slot logic\n const hasContentSlot = computed(() => hasSlot('content'));\n const isCheckedOrIntermediate = computed(() => isIndeterminate?.value || isChecked?.value);\n const contentSlotAvailable = computed(\n () => hasContentSlot?.value && isCheckboxGroup?.value && isCheckedOrIntermediate?.value\n );\n\n // ARIA fields\n const ariaDescribedBy = computed<HTMLAttributes['aria-describedby']>(\n () =>\n `${shouldShowErrorMessage.value ? errorId : ''} ${\n defaultSlotValue && descriptionSlotValue ? descriptionId : ''\n }`.trim() || null\n );\n\n const ariaLabelAttribute = ref(attrs['aria-label']);\n const { ariaLabel } = toRefs(props);\n const checkboxTranslation = ref();\n // Translations used in the script tag need to be inside onMounted otherwise they fail in Vue 3\n onMounted(() => {\n checkboxTranslation.value = t('checkbox');\n });\n // Only add aria-label if no label slot is present\n const computedAriaLabel = computed(\n () =>\n useAriaLabel({\n ariaLabel: ariaLabelAttribute.value as string,\n // TODO: take this line away when the aria-label props is removed\n label: ariaLabel,\n defaultFallback: hasSlot('default')\n ? (getSlotText(slots)('default') as string)\n : checkboxTranslation.value,\n }).value\n );\n const getAriaHidden = (attributes: HTMLAttributes) => attributes?.['aria-hidden'];\n\n const styleAttrs = computed(() => {\n const { style, class: cls } = useAttrs();\n return {\n class: cls as HTMLAttributes['class'],\n style: style as HTMLAttributes['style'],\n };\n });\n\n const conditionalClass = computed(() => ({\n [`b-checkbox--${BentoCheckboxState.DISABLED}`]: disabled.value,\n [`b-checkbox--${BentoCheckboxState.READONLY}`]: readonly.value,\n }));\n\n const onChange = (newValue: BentoCheckboxType | BentoCheckboxGroupItems) => {\n if (disabled.value) {\n return;\n }\n emit(BentoCheckboxEvent.UPDATE, newValue);\n emit(BentoCheckboxEvent.INPUT, newValue);\n };\n\n return {\n // Values\n descriptionId,\n errorId,\n ariaDescribedBy,\n computedAriaLabel,\n conditionalClass,\n defaultSlotValue,\n descriptionSlotValue,\n isIndeterminate,\n shouldShowError,\n shouldShowErrorMessage,\n contentSlotAvailable,\n hasContentSlot,\n styleAttrs,\n\n // Methods\n hasSlot,\n onChange,\n getAriaHidden,\n\n t,\n };\n },\n });\n</script>\n\n<style lang=\"scss\" scoped src=\"./checkbox.scss\" />\n"],"names":["BentoCheckboxEvent","BentoCheckboxEvent2","_sfc_main","defineComponent","messages","BentoTag","BentoTypography","CheckboxInput","ErrorMessage","props","attrs","emit","slots","t","useI18n","descriptionId","generateUid","errorId","hasSlot","useHasSlot","disabled","indeterminate","modelValue","readonly","value","toRefs","defaultSlotValue","getSlotText","descriptionSlotValue","useDefaultSlotValidator","isCheckboxGroup","computed","isChecked","item","isIndeterminate","shouldShowError","shouldShowErrorMessage","hasContentSlot","isCheckedOrIntermediate","contentSlotAvailable","ariaDescribedBy","ariaLabelAttribute","ref","ariaLabel","checkboxTranslation","onMounted","computedAriaLabel","useAriaLabel","getAriaHidden","attributes","styleAttrs","style","cls","useAttrs","conditionalClass","CheckboxInputState","newValue"],"mappings":";;;;;;;;;;;;;;AASY,IAAAA,IAAA,kBAAAC,OACRA,EAAA,SAAA,sBACAA,EAAA,QAAA,SAFQA,IAAAD,KAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;GCoFZE,IAAAC,EAAA;AAAA,EAAA,MAAA;AAAA,EACA,MAAA,EAAA,UAAAC,EAAA;AAAA,EACA,YAAA;AAAA,IACA,UAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,eAAAC;AAAA,IACA,cAAAC;AAAA,EACA;AAAA,EACA,cAAA;AAAA,EACA,OAAA,EAAA,MAAA,aAAA;AAAA,EACA,OAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IACA,WAAA,EAAA,MAAA,QAAA,SAAA,KAAA;AAAA;AAAA;AAAA;AAAA,IAOA,UAAA,EAAA,MAAA,SAAA,SAAA,GAAA;AAAA;AAAA;AAAA;AAAA,IAKA,cAAA,EAAA,M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,OAAAoB,GAAA,OAAAC,EAAA,IAAAC,EAAA;AACA,aAAA;AAAA,QAAA,OAAAD;AAAA,QACA,OAAAD;AAAA,MACA;AAAA,IACA,CAAA,GAGAG,IAAAvB,EAAA,OAAA;AAAA,MAAA,CAAA,eAAAwB,EAAA,QAAA,EAAA,GAAAnC,EAAA;AAAA,MACA,CAAA,eAAAmC,EAAA,QAAA,EAAA,GAAAhC,EAAA;AAAA,IACA,EAAA;AAWA,WAAA;AAAA;AAAA,MAAA,eAAAR;AAAA,MAEA,SAAAE;AAAA,MACA,iBAAAuB;AAAA,MACA,mBAAAM;AAAA,MACA,kBAAAQ;AAAA,MACA,kBAAA5B;AAAA,MACA,sBAAAE;AAAA,MACA,iBAAAM;AAAA,MACA,iBAAAC;AAAA,MACA,wBAAAC;AAAA,MACA,sBAAAG;AAAA,MACA,gBAAAF;AAAA,MACA,YAAAa;AAAA;AAAA,MACA,SAAAhC;AAAA,MAGA,UAzBA,CAAAsC,MAAA;AACA,QAAApC,EAAA,UAGAT,EAAAX,EAAA,QAAAwD,CAAA,GACA7C,EAAAX,EAAA,OAAAwD,CAAA;AAAA,MAAA;AAAA,MAqBA,eAAAR;AAAA,MACA,GAAAnC;AAAA,IAEA;AAAA,EACA;AAEA,CAAA;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"checkbox.nyUc0gLb.js","sources":["../../src/components/checkbox/checkbox.types.ts","../../src/components/checkbox/checkbox.vue"],"sourcesContent":["import type { BentoTagProps } from '../tag/tag.types';\nimport {\n CheckboxInputState as BentoCheckboxState,\n type CheckboxInputType as BentoCheckboxType,\n type MultiCheckboxInputType as BentoMultiCheckboxType,\n} from '@/internal/checkbox-input/checkbox-input.types';\n\nexport { BentoCheckboxState, BentoCheckboxType, BentoMultiCheckboxType };\n\nexport enum BentoCheckboxEvent {\n UPDATE = 'update:model-value',\n INPUT = 'input',\n}\n\nexport type BentoCheckboxTag = BentoTagProps;\n","<template>\n <label class=\"b-checkbox\" :class=\"conditionalClass\" v-bind=\"styleAttrs\" :aria-hidden=\"getAriaHidden($attrs)\">\n <checkbox-input\n v-bind=\"$attrs\"\n ref=\"input\"\n :aria-label=\"computedAriaLabel\"\n :aria-describedby=\"ariaDescribedBy\"\n :disabled=\"disabled\"\n :has-error=\"shouldShowError\"\n :indeterminate=\"isIndeterminate\"\n :value=\"value\"\n :model-value=\"modelValue\"\n :readonly=\"readonly\"\n @update:model-value=\"onChange\"\n />\n <span v-if=\"hasSlot('default') || shouldShowErrorMessage\" class=\"b-checkbox__text\">\n <bento-typography v-if=\"hasSlot('default')\" class=\"b-checkbox__label\" el=\"span\" variant=\"body\">\n <span><slot /></span>\n <bento-typography v-if=\"optional\" class=\"b-checkbox__label-requirement\" el=\"span\"\n >({{ t('optional') }})</bento-typography\n >\n <bento-typography v-else-if=\"required\" class=\"b-checkbox__label-requirement\" el=\"span\"\n >({{ t('required') }})</bento-typography\n >\n <bento-tag v-if=\"tag\" class=\"b-checkbox__label-tag\" v-bind=\"tag\" />\n </bento-typography>\n <bento-typography\n v-if=\"hasSlot('default') && hasSlot('description')\"\n :id=\"descriptionId\"\n class=\"b-checkbox__description\"\n el=\"span\"\n variant=\"body\"\n >\n <slot name=\"description\"></slot>\n </bento-typography>\n <error-message v-if=\"shouldShowErrorMessage\" :id=\"errorId\" :error-message=\"errorMessage\" />\n\n <bento-typography v-if=\"contentSlotAvailable\" class=\"b-checkbox__content\" el=\"span\" variant=\"body\">\n <slot name=\"content\"></slot>\n </bento-typography>\n </span>\n </label>\n</template>\n\n<script lang=\"ts\">\n import {\n computed,\n defineComponent,\n type HTMLAttributes,\n onMounted,\n type PropType,\n ref,\n toRefs,\n useAttrs,\n } from 'vue';\n import {\n BentoCheckboxEvent,\n BentoCheckboxState,\n type BentoCheckboxTag,\n type BentoCheckboxType,\n type BentoMultiCheckboxType,\n } from './checkbox.types';\n import { BentoTypography } from '@/components/typography';\n import { CheckboxInput } from '@/components/internal/checkbox-input';\n import { ErrorMessage } from '@/components/internal/error-message';\n import { useDefaultSlotValidator, useHasSlot } from '@/composables';\n import { generateUid } from '@/core/utils/ts';\n import { getSlotText } from '@/utils/ts/get-slot-text';\n import { useI18n } from '@/utils/ts/i18n';\n import { useAriaLabel } from '@/utils/ts/aria-label';\n import { BentoTag } from '@/components/tag';\n import { type BentoCheckboxGroupItems } from './components/checkbox-group/checkbox-group.types';\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n /**\n * Checkboxes are used to make a binary choice about an option.\n * The label tag area is also clickable.\n *\n * @usage\n * import { BentoCheckbox } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoCheckbox },\n * template: `\n * <bento-checkbox>\n * Label text\n * <template #description>Sub label text</template>\n * </bento-checkbox>\n * `,\n * }\n */\n export default defineComponent({\n name: 'bento-checkbox',\n i18n: { messages },\n components: {\n BentoTag,\n BentoTypography,\n CheckboxInput,\n ErrorMessage,\n },\n inheritAttrs: false,\n model: { prop: 'modelValue' },\n props: {\n /**\n * @deprecated from version 2.0.0. Use the aria-label attribute instead.\n */\n /**\n * Accessible name for the radio button component. It is strongly recommended to pas this value in case this component is used without a label.\n */\n ariaLabel: { type: String, default: null },\n\n /**\n * Setting this property to true will disable the checkbox in your form.\n */\n disabled: { type: Boolean, default: false },\n\n /**\n * Renders the checkbox in an error state with an error message.\n */\n errorMessage: { type: String, default: null },\n\n /**\n * Setting this property to true will show the checkbox in error state.\n */\n hasError: { type: Boolean, default: false },\n\n /**\n * The :indeterminate CSS pseudo-class represents any form element\n * whose state is indeterminate, such as checkboxes which have their HTML indeterminate attribute\n * set to true, radio buttons which are members of a group in which all radio buttons are unchecked,\n * and indeterminate <progress> elements. https://developer.mozilla.org/en-US/docs/Web/CSS/:indeterminate\n * This property lets you control the input.indeterminate native property.\n */\n indeterminate: { type: Boolean, default: false },\n\n /**\n * When handling a single checkbox with a singular state, use a boolean.\n *\n * When handling multiple checkboxes, use an array of keys.\n * These keys exist as a set \"value\" prop for each checkbox.\n */\n modelValue: {\n type: [Boolean, Array] as PropType<BentoCheckboxType | BentoCheckboxGroupItems>,\n default: false,\n },\n\n /**\n * Highlights the checkbox is optional.\n */\n optional: { type: Boolean, default: false },\n\n /**\n * Setting this property to true will set the checkbox to read only state.\n */\n readonly: { type: Boolean, default: false },\n\n /**\n * Highlights the checkbox is required.\n */\n required: { type: Boolean, default: false },\n\n /**\n * Sets the properties of the BentoTag component that is placed next to the label.\n * {@see BentoTag}\n */\n tag: { type: Object as PropType<BentoCheckboxTag>, default: undefined },\n\n /**\n * The value of the component. The DOM API casts this to a string.\n * The browser uses \"on\" as the default value.\n *\n * In the case of multiple checkboxes this value is used as a unique key.\n */\n value: { type: [String, Number], default: null },\n },\n emits: [BentoCheckboxEvent.UPDATE, BentoCheckboxEvent.INPUT],\n setup(props, { attrs, emit, slots }) {\n const { t } = useI18n<{ message: MessageSchema }>({ messages });\n const descriptionId = generateUid('description');\n const errorId = generateUid('error');\n const hasSlot = useHasSlot(slots);\n\n const { disabled, indeterminate, modelValue, readonly, value } = toRefs(props);\n\n const defaultSlotValue = getSlotText(slots)('default');\n const descriptionSlotValue = getSlotText(slots)('description');\n\n useDefaultSlotValidator('bento-checkbox', slots.default, slots.description);\n\n const isCheckboxGroup = computed(() => Array.isArray(modelValue.value));\n const isChecked = computed(() => {\n if (!isCheckboxGroup.value) {\n return modelValue.value as boolean;\n }\n\n return (modelValue.value as BentoMultiCheckboxType).some(item => item === value.value);\n });\n const isIndeterminate = computed(() => indeterminate.value);\n\n const shouldShowError = computed(\n () => !props.disabled && !props.readonly && (props.hasError || !!props.errorMessage)\n );\n const shouldShowErrorMessage = computed(() => !props.disabled && !props.readonly && !!props.errorMessage);\n\n // Content slot logic\n const hasContentSlot = computed(() => hasSlot('content'));\n const isCheckedOrIntermediate = computed(() => isIndeterminate?.value || isChecked?.value);\n const contentSlotAvailable = computed(\n () => hasContentSlot?.value && isCheckboxGroup?.value && isCheckedOrIntermediate?.value\n );\n\n // ARIA fields\n const ariaDescribedBy = computed<HTMLAttributes['aria-describedby']>(\n () =>\n `${shouldShowErrorMessage.value ? errorId : ''} ${\n defaultSlotValue && descriptionSlotValue ? descriptionId : ''\n }`.trim() || null\n );\n\n const ariaLabelAttribute = ref(attrs['aria-label']);\n const { ariaLabel } = toRefs(props);\n const checkboxTranslation = ref();\n // Translations used in the script tag need to be inside onMounted otherwise they fail in Vue 3\n onMounted(() => {\n checkboxTranslation.value = t('checkbox');\n });\n // Only add aria-label if no label slot is present\n const computedAriaLabel = computed(\n () =>\n useAriaLabel({\n ariaLabel: ariaLabelAttribute.value as string,\n // TODO: take this line away when the aria-label props is removed\n label: ariaLabel,\n defaultFallback: hasSlot('default')\n ? (getSlotText(slots)('default') as string)\n : checkboxTranslation.value,\n }).value\n );\n const getAriaHidden = (attributes: HTMLAttributes) => attributes?.['aria-hidden'];\n\n const styleAttrs = computed(() => {\n const { style, class: cls } = useAttrs();\n return {\n class: cls as HTMLAttributes['class'],\n style: style as HTMLAttributes['style'],\n };\n });\n\n const conditionalClass = computed(() => ({\n [`b-checkbox--${BentoCheckboxState.DISABLED}`]: disabled.value,\n [`b-checkbox--${BentoCheckboxState.READONLY}`]: readonly.value,\n }));\n\n const onChange = (newValue: BentoCheckboxType | BentoCheckboxGroupItems) => {\n if (disabled.value) {\n return;\n }\n emit(BentoCheckboxEvent.UPDATE, newValue);\n emit(BentoCheckboxEvent.INPUT, newValue);\n };\n\n return {\n // Values\n descriptionId,\n errorId,\n ariaDescribedBy,\n computedAriaLabel,\n conditionalClass,\n defaultSlotValue,\n descriptionSlotValue,\n isIndeterminate,\n shouldShowError,\n shouldShowErrorMessage,\n contentSlotAvailable,\n hasContentSlot,\n styleAttrs,\n\n // Methods\n hasSlot,\n onChange,\n getAriaHidden,\n\n t,\n };\n },\n });\n</script>\n\n<style lang=\"scss\" scoped src=\"./checkbox.scss\" />\n"],"names":["BentoCheckboxEvent","BentoCheckboxEvent2","_sfc_main","defineComponent","messages","BentoTag","BentoTypography","CheckboxInput","ErrorMessage","props","attrs","emit","slots","t","useI18n","descriptionId","generateUid","errorId","hasSlot","useHasSlot","disabled","indeterminate","modelValue","readonly","value","toRefs","defaultSlotValue","getSlotText","descriptionSlotValue","useDefaultSlotValidator","isCheckboxGroup","computed","isChecked","item","isIndeterminate","shouldShowError","shouldShowErrorMessage","hasContentSlot","isCheckedOrIntermediate","contentSlotAvailable","ariaDescribedBy","ariaLabelAttribute","ref","ariaLabel","checkboxTranslation","onMounted","computedAriaLabel","useAriaLabel","getAriaHidden","attributes","styleAttrs","style","cls","useAttrs","conditionalClass","CheckboxInputState","newValue"],"mappings":";;;;;;;;;;;;;;AASY,IAAAA,IAAA,kBAAAC,OACRA,EAAA,SAAA,sBACAA,EAAA,QAAA,SAFQA,IAAAD,KAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;GCoFZE,IAAAC,EAAA;AAAA,EAAA,MAAA;AAAA,EACA,MAAA,EAAA,UAAAC,EAAA;AAAA,EACA,YAAA;AAAA,IACA,UAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,eAAAC;AAAA,IACA,cAAAC;AAAA,EACA;AAAA,EACA,cAAA;AAAA,EACA,OAAA,EAAA,MAAA,aAAA;AAAA,EACA,OAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IACA,WAAA,EAAA,MAAA,QAAA,SAAA,KAAA;AAAA;AAAA;AAAA;AAAA,IAOA,UAAA,EAAA,MAAA,SAAA,SAAA,GAAA;AAAA;AAAA;AAAA;AAAA,IAKA,cAAA,EAAA,MAAA,QAAA,SAAA,KAAA;AAAA;AAAA;AAAA;AAAA,IAKA,UAAA,EAAA,MAAA,SAAA,SAAA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA,eAAA,EAAA,MAAA,SAAA,SAAA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASA,YAAA;AAAA,MAQA,MAAA,CAAA,SAAA,KAAA;AAAA,MACA,SAAA;AAA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A;AAAA;AAAA,MAAA,eAAAR;AAAA,MAEA,SAAAE;AAAA,MACA,iBAAAuB;AAAA,MACA,mBAAAM;AAAA,MACA,kBAAAQ;AAAA,MACA,kBAAA5B;AAAA,MACA,sBAAAE;AAAA,MACA,iBAAAM;AAAA,MACA,iBAAAC;AAAA,MACA,wBAAAC;AAAA,MACA,sBAAAG;AAAA,MACA,gBAAAF;AAAA,MACA,YAAAa;AAAA;AAAA,MACA,SAAAhC;AAAA,MAGA,UAzBA,CAAAsC,MAAA;AACA,QAAApC,EAAA,UAGAT,EAAAX,EAAA,QAAAwD,CAAA,GACA7C,EAAAX,EAAA,OAAAwD,CAAA;AAAA,MAAA;AAAA,MAqBA,eAAAR;AAAA,MACA,GAAAnC;AAAA,IAEA;AAAA,EACA;AAEA,CAAA;;;;;;;;;;;;;"}
@@ -1,7 +1,7 @@
1
1
  import { defineComponent as Y, useAttrs as H, ref as g, computed as l, shallowRef as P, onMounted as V, watch as D, watchEffect as Z } from "vue";
2
2
  import { s as j, H as J, t as e, L as W, a as U, b as G, c as z, p as F, j as X, d as K, x as q, e as ee, E as te, h as ne, k as ae, C as f, f as _, i as oe, g as A, l as se, m as ie } from "./codemirror.Zv80n3Z2.js";
3
3
  import { c as re, d as le, e as ce, f as de } from "./es6.MoTTyETW.js";
4
- import { B as pe } from "./dropdown.BOvtYKXS.js";
4
+ import { B as pe } from "./dropdown.RxD2TqnP.js";
5
5
  import { B as ue } from "./button.CS_kdxYh.js";
6
6
  import { B as ge } from "./typography.hlOAxsEn.js";
7
7
  import { B as fe } from "./loading-indicator.PxbRzshH.js";
@@ -265,4 +265,4 @@ export {
265
265
  c as b,
266
266
  Ge as c
267
267
  };
268
- //# sourceMappingURL=code-snippet.VtrsOTEC.js.map
268
+ //# sourceMappingURL=code-snippet.DFf3KMSi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"code-snippet.VtrsOTEC.js","sources":["../../src/components/code-snippet/highlight.ts","../../src/components/code-snippet/code-snippet.types.ts","../../../../node_modules/.pnpm/codemirror-lang-csv@0.1.1/node_modules/codemirror-lang-csv/dist/index.js","../../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 { type 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/**\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 CSV = 'csv',\n}\n\nexport enum BentoCodeSnippetEvent {\n ACTION = 'action',\n CHANGE = 'change',\n}\n\nexport interface BentoCodeSnippetProps {\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?: boolean;\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?: string;\n\n /**\n * The code content\n */\n content?: string;\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?: boolean;\n\n /**\n * Allows editing of the code-snippet content by the user\n */\n editable?: boolean;\n\n /**\n * Language name for syntax highlighting rules\n */\n lang?: BentoCodeSnippetSupportedLanguage | `${BentoCodeSnippetSupportedLanguage}`;\n\n /**\n * Label to show in the action-bar, describing the language\n */\n langLabel?: string;\n\n /**\n * Toggles the loading indicator within the action bar\n */\n loading?: boolean;\n\n /**\n * Defines the variant of code-snippet\n */\n variant?: BentoCodeSnippetVariant | `${BentoCodeSnippetVariant}`;\n}\n","import { LRParser } from '@lezer/lr';\nimport { LRLanguage, LanguageSupport } from '@codemirror/language';\nimport { styleTags, tags } from '@lezer/highlight';\n\n// This file was generated by lezer-generator. You probably shouldn't edit it.\nconst parser = LRParser.deserialize({\n version: 14,\n states: \"nQVQPOOOOQO'#Ce'#CeOOQO'#Ca'#CaQVQPOOOOQO-E6_-E6_\",\n stateData: \"g~OWOS~OQPORPOSPO~OQRSR~\",\n goto: \"eYPPPPPZPPPaQRORSRTQOR\",\n nodeNames: \"⚠ Program String Separator Value\",\n maxTerm: 9,\n skippedNodes: [0],\n repeatNodeCount: 1,\n tokenData: \"'Y~RZOYtYZ!cZrtrs!hs|t|}'T}!]t!]!^'T!^;'St;'S;=`!]<%lOt~yUS~OYtZ|t}!]t!^;'St;'S;=`!]<%lOt~!`P;=`<%lt~!hOW~~!m]S~OY!hYZ#fZr!hrs%Ss|!h|}#f}!]!h!]!^#f!^#O!h#O#P%m#P;'S!h;'S;=`&}<%lO!h~#iVOr#frs$Os#O#f#O#P$T#P;'S#f;'S;=`$|<%lO#f~$TOQ~~$WRO;'S#f;'S;=`$a;=`O#f~$dWOr#frs$Os#O#f#O#P$T#P;'S#f;'S;=`$|;=`<%l#f<%lO#f~%PP;=`<%l#f~%ZUQ~S~OYtZ|t}!]t!^;'St;'S;=`!]<%lOt~%rYS~OY!hYZ#fZ|!h|}#f}!]!h!]!^#f!^;'S!h;'S;=`&b;=`<%l#f<%lO!h~&eWOr#frs$Os#O#f#O#P$T#P;'S#f;'S;=`$|;=`<%l!h<%lO#f~'QP;=`<%l!h~'YOR~\",\n tokenizers: [0],\n topRules: {\"Program\":[0,1]},\n tokenPrec: 18\n});\n\nconst csvLanguage = LRLanguage.define({\n parser: parser.configure({\n props: [\n styleTags({\n Separator: tags.separator,\n Value: tags.string,\n String: tags.string,\n LineComment: tags.lineComment,\n \"( )\": tags.paren,\n }),\n ],\n }),\n});\nfunction csv() {\n return new LanguageSupport(csvLanguage);\n}\n\nexport { csv, csvLanguage };\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';\nimport { csv } from 'codemirror-lang-csv';\nimport type { LanguageSupport } from '@codemirror/language';\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: Record<BentoCodeSnippetSupportedLanguage, () => LanguageSupport> = {\n [BentoCodeSnippetSupportedLanguage.JSON]: json,\n [BentoCodeSnippetSupportedLanguage.XML]: xml,\n [BentoCodeSnippetSupportedLanguage.JAVASCRIPT]: javascript,\n [BentoCodeSnippetSupportedLanguage.JAVA]: java,\n [BentoCodeSnippetSupportedLanguage.PYTHON]: python,\n [BentoCodeSnippetSupportedLanguage.CSV]: csv,\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 setup lang=\"ts\">\n import { computed, type HTMLAttributes, onMounted, ref, shallowRef, useAttrs, 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 { BentoLoadingIndicator } from '@/components/loading-indicator';\n import { useI18n } from '@/utils/ts/i18n';\n import { Copy } from '@/internal';\n import {\n BentoCodeSnippetEvent,\n type BentoCodeSnippetProps,\n BentoCodeSnippetSupportedLanguage,\n BentoCodeSnippetVariant,\n } from './code-snippet.types';\n import ExpandIcon from '@adyen/ui-assets-icons-16/vue/expand';\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 const props = defineProps({\n actionable: { type: Boolean, default: false },\n actionableText: { default: null },\n content: { default: '' },\n expandable: { type: Boolean, default: false },\n editable: { type: Boolean, default: false },\n lang: { default: BentoCodeSnippetSupportedLanguage.JSON },\n langLabel: { default: null },\n loading: { type: Boolean, default: false },\n variant: { default: BentoCodeSnippetVariant.MULTILINE }\n});\n\n const emit = defineEmits([BentoCodeSnippetEvent.ACTION, BentoCodeSnippetEvent.CHANGE]);\n\n const attrs = useAttrs();\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 const editorAttributes = new Compartment();\n\n const currentContents = ref(null);\n const contentLength = ref(0);\n\n const runText = computed(() => props.actionableText || t('run'));\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 editorReadOnly.of(EditorState.readOnly.of(!props.editable)),\n editorAttributes.of(\n EditorView.contentAttributes.of({\n 'aria-label': (attrs['aria-label'] as HTMLAttributes['aria-label']) ?? t('codeSnippet'),\n ...(!isInlineVariant.value && { tabindex: '0' }),\n })\n ),\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 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</script>\n\n<script lang=\"ts\">\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 {\n i18n: { messages },\n name: 'bento-code-snippet',\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","parser","LRParser","csvLanguage","LRLanguage","styleTags","csv","LanguageSupport","importsMap","json","xml","javascript","java","python","getLangLoader","getIndentation","state","line","currentLine","indentMatch","INDENT_SAME_AS_LINE_BEFORE","dispatch","changes","range","newText","EditorSelection","__default__","messages","attrs","useAttrs","t","useI18n","selectedLanguage","ref","availableLanguages","handleChangeLanguage","displayedLang","computed","props","isInlineVariant","conditionalClasses","codeAreaContentConditionalClasses","loadLang","container","shallowRef","editor","languageConf","Compartment","editorTheme","editorReadOnly","editorAttributes","currentContents","contentLength","runText","onMounted","updateCurrentContents","state2","extensions","highlightActiveLine","keymap","indentWithTab","EditorState","EditorView","content","lineNumbers","history","watch","upcomingContentLength","onActionClicked","emit","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,MAAAA,EAAA,QAAAA,EAAA,MAAA,C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A;AAAA,YAAsB,SAAA;AAAA,cACT,MAAA;AAAA,cACC,IAAAO,EAAA;AAAA,cACY,QAAAd,EAAA;AAAA,YACJ;AAAA,UAClB,CAAA,GAEJc,EAAA,QAAAe;AAAA,QAAsB;AAAA,MAC1B;AAAA,IACJ;AAGJ,UAAAC,IAAA,MAAA;AACI,MAAAC,EAAAtE,EAAA,QAAAoD,EAAA,KAAA;AAAA,IAAwD;AAG5D,IAAAmB,EAAA,MAAA;AACI,MAAAnB,EAAA,UAAA,QACIkB,EAAAtE,EAAA,QAAAoD,EAAA,KAAA;AAAA,IACJ,CAAA;AAGJ,UAAAoB,IAAAtC,EAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","x_google_ignoreList":[2]}
1
+ {"version":3,"file":"code-snippet.DFf3KMSi.js","sources":["../../src/components/code-snippet/highlight.ts","../../src/components/code-snippet/code-snippet.types.ts","../../../../node_modules/.pnpm/codemirror-lang-csv@0.1.1/node_modules/codemirror-lang-csv/dist/index.js","../../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 { type 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/**\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 CSV = 'csv',\n}\n\nexport enum BentoCodeSnippetEvent {\n ACTION = 'action',\n CHANGE = 'change',\n}\n\nexport interface BentoCodeSnippetProps {\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?: boolean;\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?: string;\n\n /**\n * The code content\n */\n content?: string;\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?: boolean;\n\n /**\n * Allows editing of the code-snippet content by the user\n */\n editable?: boolean;\n\n /**\n * Language name for syntax highlighting rules\n */\n lang?: BentoCodeSnippetSupportedLanguage | `${BentoCodeSnippetSupportedLanguage}`;\n\n /**\n * Label to show in the action-bar, describing the language\n */\n langLabel?: string;\n\n /**\n * Toggles the loading indicator within the action bar\n */\n loading?: boolean;\n\n /**\n * Defines the variant of code-snippet\n */\n variant?: BentoCodeSnippetVariant | `${BentoCodeSnippetVariant}`;\n}\n","import { LRParser } from '@lezer/lr';\nimport { LRLanguage, LanguageSupport } from '@codemirror/language';\nimport { styleTags, tags } from '@lezer/highlight';\n\n// This file was generated by lezer-generator. You probably shouldn't edit it.\nconst parser = LRParser.deserialize({\n version: 14,\n states: \"nQVQPOOOOQO'#Ce'#CeOOQO'#Ca'#CaQVQPOOOOQO-E6_-E6_\",\n stateData: \"g~OWOS~OQPORPOSPO~OQRSR~\",\n goto: \"eYPPPPPZPPPaQRORSRTQOR\",\n nodeNames: \"⚠ Program String Separator Value\",\n maxTerm: 9,\n skippedNodes: [0],\n repeatNodeCount: 1,\n tokenData: \"'Y~RZOYtYZ!cZrtrs!hs|t|}'T}!]t!]!^'T!^;'St;'S;=`!]<%lOt~yUS~OYtZ|t}!]t!^;'St;'S;=`!]<%lOt~!`P;=`<%lt~!hOW~~!m]S~OY!hYZ#fZr!hrs%Ss|!h|}#f}!]!h!]!^#f!^#O!h#O#P%m#P;'S!h;'S;=`&}<%lO!h~#iVOr#frs$Os#O#f#O#P$T#P;'S#f;'S;=`$|<%lO#f~$TOQ~~$WRO;'S#f;'S;=`$a;=`O#f~$dWOr#frs$Os#O#f#O#P$T#P;'S#f;'S;=`$|;=`<%l#f<%lO#f~%PP;=`<%l#f~%ZUQ~S~OYtZ|t}!]t!^;'St;'S;=`!]<%lOt~%rYS~OY!hYZ#fZ|!h|}#f}!]!h!]!^#f!^;'S!h;'S;=`&b;=`<%l#f<%lO!h~&eWOr#frs$Os#O#f#O#P$T#P;'S#f;'S;=`$|;=`<%l!h<%lO#f~'QP;=`<%l!h~'YOR~\",\n tokenizers: [0],\n topRules: {\"Program\":[0,1]},\n tokenPrec: 18\n});\n\nconst csvLanguage = LRLanguage.define({\n parser: parser.configure({\n props: [\n styleTags({\n Separator: tags.separator,\n Value: tags.string,\n String: tags.string,\n LineComment: tags.lineComment,\n \"( )\": tags.paren,\n }),\n ],\n }),\n});\nfunction csv() {\n return new LanguageSupport(csvLanguage);\n}\n\nexport { csv, csvLanguage };\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';\nimport { csv } from 'codemirror-lang-csv';\nimport type { LanguageSupport } from '@codemirror/language';\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: Record<BentoCodeSnippetSupportedLanguage, () => LanguageSupport> = {\n [BentoCodeSnippetSupportedLanguage.JSON]: json,\n [BentoCodeSnippetSupportedLanguage.XML]: xml,\n [BentoCodeSnippetSupportedLanguage.JAVASCRIPT]: javascript,\n [BentoCodeSnippetSupportedLanguage.JAVA]: java,\n [BentoCodeSnippetSupportedLanguage.PYTHON]: python,\n [BentoCodeSnippetSupportedLanguage.CSV]: csv,\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 setup lang=\"ts\">\n import { computed, type HTMLAttributes, onMounted, ref, shallowRef, useAttrs, 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 { BentoLoadingIndicator } from '@/components/loading-indicator';\n import { useI18n } from '@/utils/ts/i18n';\n import { Copy } from '@/internal';\n import {\n BentoCodeSnippetEvent,\n type BentoCodeSnippetProps,\n BentoCodeSnippetSupportedLanguage,\n BentoCodeSnippetVariant,\n } from './code-snippet.types';\n import ExpandIcon from '@adyen/ui-assets-icons-16/vue/expand';\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 const props = defineProps({\n actionable: { type: Boolean, default: false },\n actionableText: { default: null },\n content: { default: '' },\n expandable: { type: Boolean, default: false },\n editable: { type: Boolean, default: false },\n lang: { default: BentoCodeSnippetSupportedLanguage.JSON },\n langLabel: { default: null },\n loading: { type: Boolean, default: false },\n variant: { default: BentoCodeSnippetVariant.MULTILINE }\n});\n\n const emit = defineEmits([BentoCodeSnippetEvent.ACTION, BentoCodeSnippetEvent.CHANGE]);\n\n const attrs = useAttrs();\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 const editorAttributes = new Compartment();\n\n const currentContents = ref(null);\n const contentLength = ref(0);\n\n const runText = computed(() => props.actionableText || t('run'));\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 editorReadOnly.of(EditorState.readOnly.of(!props.editable)),\n editorAttributes.of(\n EditorView.contentAttributes.of({\n 'aria-label': (attrs['aria-label'] as HTMLAttributes['aria-label']) ?? t('codeSnippet'),\n ...(!isInlineVariant.value && { tabindex: '0' }),\n })\n ),\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 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</script>\n\n<script lang=\"ts\">\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 {\n i18n: { messages },\n name: 'bento-code-snippet',\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","parser","LRParser","csvLanguage","LRLanguage","styleTags","csv","LanguageSupport","importsMap","json","xml","javascript","java","python","getLangLoader","getIndentation","state","line","currentLine","indentMatch","INDENT_SAME_AS_LINE_BEFORE","dispatch","changes","range","newText","EditorSelection","__default__","messages","attrs","useAttrs","t","useI18n","selectedLanguage","ref","availableLanguages","handleChangeLanguage","displayedLang","computed","props","isInlineVariant","conditionalClasses","codeAreaContentConditionalClasses","loadLang","container","shallowRef","editor","languageConf","Compartment","editorTheme","editorReadOnly","editorAttributes","currentContents","contentLength","runText","onMounted","updateCurrentContents","state2","extensions","highlightActiveLine","keymap","indentWithTab","EditorState","EditorView","content","lineNumbers","history","watch","upcomingContentLength","onActionClicked","emit","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,GA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AC,MAAAR,EAAAQ,CAAA,CAAA;AAAA,MACsE;AAG1E,MAAAzB,EAAA,YAAA,eACImB,EAAA,KAAA,CAAAO,GAAA,GAAAC,GAAA,CAAA,CAAA;AAGJ,YAAAjD,IAAA6C,EAAA,OAAA;AAAA,QAAiC,KAAAvB,EAAA;AAAA,QAClB,YAAA,CAAA,GAAAmB,CAAA;AAAA,MACe,CAAA;AAE9B,MAAAL,EAAA,QAAApC,EAAA,IAAA,QAEA6B,EAAA,QAAA,IAAAiB,EAAA;AAAA,QAA8B,OAAA9C;AAAA,QAC1B,QAAA2B,EAAA;AAAA,MACkB,CAAA;AAAA,IACrB,CAAA,GAELuB;AAAA,MAAA,MAAA5B,EAAA;AAAA,MACgB,MAAA;AAER,YAAAA,EAAA,YAAAa,EAAA,OAAA;AACI,gBAAAgB,IAAA7B,EAAA,QAAA;AACA,UAAAO,EAAA,MAAA,SAAA;AAAA,YAAsB,SAAA;AAAA,cACT,MAAA;AAAA,cACC,IAAAO,EAAA;AAAA,cACY,QAAAd,EAAA;AAAA,YACJ;AAAA,UAClB,CAAA,GAEJc,EAAA,QAAAe;AAAA,QAAsB;AAAA,MAC1B;AAAA,IACJ;AAGJ,UAAAC,IAAA,MAAA;AACI,MAAAC,EAAAtE,EAAA,QAAAoD,EAAA,KAAA;AAAA,IAAwD;AAG5D,IAAAmB,EAAA,MAAA;AACI,MAAAnB,EAAA,UAAA,QACIkB,EAAAtE,EAAA,QAAAoD,EAAA,KAAA;AAAA,IACJ,CAAA;AAGJ,UAAAoB,IAAAtC,EAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","x_google_ignoreList":[2]}
@@ -0,0 +1,8 @@
1
+ import { c as t } from "./getTimezoneOffsetInMilliseconds.BW7U6PxE.js";
2
+ function c(o) {
3
+ return t(o, Date.now());
4
+ }
5
+ export {
6
+ c
7
+ };
8
+ //# sourceMappingURL=constructNow.CHWWeLPc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constructNow.CHWWeLPc.js","sources":["../../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/constructNow.js"],"sourcesContent":["import { constructFrom } from \"./constructFrom.js\";\n\n/**\n * @name constructNow\n * @category Generic Helpers\n * @summary Constructs a new current date using the passed value constructor.\n * @pure false\n *\n * @description\n * The function constructs a new current date using the constructor from\n * the reference date. It helps to build generic functions that accept date\n * extensions and use the current date.\n *\n * It defaults to `Date` if the passed reference date is a number or a string.\n *\n * @param date - The reference date to take constructor from\n *\n * @returns Current date initialized using the given date constructor\n *\n * @example\n * import { constructNow, isSameDay } from 'date-fns'\n *\n * function isToday<DateType extends Date>(\n * date: DateArg<DateType>,\n * ): boolean {\n * // If we were to use `new Date()` directly, the function would behave\n * // differently in different timezones and return false for the same date.\n * return isSameDay(date, constructNow(date));\n * }\n */\nexport function constructNow(date) {\n return constructFrom(date, Date.now());\n}\n\n// Fallback for modularized imports:\nexport default constructNow;\n"],"names":["constructNow","date","constructFrom"],"mappings":";AA8BO,SAASA,EAAaC,GAAM;AACjC,SAAOC,EAAcD,GAAM,KAAK,IAAG,CAAE;AACvC;","x_google_ignoreList":[0]}
@@ -40,18 +40,18 @@ function l(D) {
40
40
  }
41
41
  const v = (D, s) => D / 10 ** l(s);
42
42
  function X() {
43
- const { n: D } = Z(), s = "USD", a = "standard";
43
+ const { n: D } = Z(), s = "USD", R = "standard";
44
44
  return {
45
- formatCurrency: (M, R) => {
45
+ formatCurrency: (M, a) => {
46
46
  var T;
47
- const K = (R == null ? void 0 : R.currency) ?? s, N = Number(M) || 0;
47
+ const K = (a == null ? void 0 : a.currency) ?? s, N = Number(M) || 0;
48
48
  isNaN(Number(M)) && f(
49
49
  "The value provided is not a valid string with numbers or valid number. Falling back to 0."
50
50
  );
51
- const F = R != null && R.majorUnits ? N : v(N, K), P = ((T = A(K)) == null ? void 0 : T.exponent) ?? l(K), U = D(F, {
51
+ const F = a != null && a.majorUnits ? N : v(N, K), P = ((T = A(K)) == null ? void 0 : T.exponent) ?? l(K), U = D(F, {
52
52
  style: "currency",
53
53
  currency: K,
54
- currencySign: (R == null ? void 0 : R.currencySign) ?? a,
54
+ currencySign: (a == null ? void 0 : a.currencySign) ?? R,
55
55
  currencyDisplay: "code",
56
56
  minimumFractionDigits: P,
57
57
  maximumFractionDigits: P
@@ -75,28 +75,28 @@ const b = {
75
75
  currencySign: { default: "standard" }
76
76
  },
77
77
  setup(D) {
78
- const s = D, a = p(), { formatCurrency: i } = X(), M = _(() => {
79
- const R = s.value ?? L(a)("default");
80
- return i(R, {
78
+ const s = D, R = p(), { formatCurrency: i } = X(), M = _(() => {
79
+ const a = s.value ?? L(R)("default");
80
+ return i(a, {
81
81
  currency: s.currency,
82
82
  currencySign: s.currencySign,
83
83
  majorUnits: s.majorUnits
84
84
  });
85
85
  });
86
86
  return Y(() => {
87
- L(a)("default") && g(
87
+ L(R)("default") && g(
88
88
  'BentoCurrency "default" slot',
89
89
  `The use of "default" slot in "BentoCurrency" is no longer supported as it causes issues with dynamic content.
90
90
  Use the "value" property instead.
91
91
  <bento-currency :value="12345.67" currency="USD" major-units="false" />`,
92
92
  "2.0.0"
93
93
  );
94
- }), { __sfc: !0, slots: a, props: s, formatCurrency: i, formattedCurrency: M, BentoTypography: H };
94
+ }), { __sfc: !0, slots: R, props: s, formatCurrency: i, formattedCurrency: M, BentoTypography: H };
95
95
  }
96
96
  });
97
97
  var x = function() {
98
- var s = this, a = s._self._c, i = s._self._setupProxy;
99
- return a("div", { staticClass: "b-currency" }, [s.disableTypography ? [s._v(s._s(i.formattedCurrency))] : a(i.BentoTypography, { staticClass: "b-currency__amount", attrs: { el: "span", variant: "body", strong: "" } }, [s._v(" " + s._s(i.formattedCurrency) + " ")])], 2);
98
+ var s = this, R = s._self._c, i = s._self._setupProxy;
99
+ return R("div", { staticClass: "b-currency" }, [s.disableTypography ? [s._v(s._s(i.formattedCurrency))] : R(i.BentoTypography, { staticClass: "b-currency__amount", attrs: { el: "span", variant: "body", strong: "" } }, [s._v(" " + s._s(i.formattedCurrency) + " ")])], 2);
100
100
  }, h = [], Q = /* @__PURE__ */ W(
101
101
  J,
102
102
  x,
@@ -108,6 +108,7 @@ var x = function() {
108
108
  const t = Q.exports;
109
109
  export {
110
110
  G as B,
111
- t as c
111
+ t as c,
112
+ X as u
112
113
  };
113
- //# sourceMappingURL=currency.DDB4G_A8.js.map
114
+ //# sourceMappingURL=currency.AvvbekWO.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"currency.DDB4G_A8.js","sources":["../../src/utils/ts/currency/currency-map.ts","../../src/utils/ts/currency/currency.ts","../../src/composables/use-bento-currency/use-bento-currency.ts","../../src/components/currency/currency.types.ts","../../src/components/currency/currency.vue"],"sourcesContent":["export interface CurrencyMap {\n exponent: number;\n currencies: Array<string>;\n}\n\n/**\n * Contains mapping configuration between currency code and exponent for amount in the corresponding currency.\n * https://docs.adyen.com/development-resources/currency-codes\n *\n * @internal\n */\nexport const currencyMap: Array<CurrencyMap> = [\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 { currencyMap, type CurrencyMap } from './currency-map';\nimport { type CurrencyAmount } from './currency.types';\n\n/**\n * Returns exponent for specified currency code that do not adhere to the ISO 4217 standard.\n */\nexport const getNonStandardCurrency = (currency: string): CurrencyMap =>\n currencyMap.find(item => item.currencies.includes(currency));\n\n/**\n * Returns the number of minor units (decimal places) for a given currency.\n * The function uses an internal map for currencies with non-standard decimal places and defaults to 2 for all others.\n *\n * @param currency - The three-letter ISO 4217 currency code (e.g., 'USD', 'JPY').\n * @returns The number of decimal places for the currency.\n *\n * @example\n * getMinorUnitDigits('USD'); // Returns 2\n * getMinorUnitDigits('JPY'); // Returns 0\n */\nexport function getMinorUnitDigits(currency: string): number {\n const exception = getNonStandardCurrency(currency);\n\n return exception?.exponent ?? 2;\n}\n\n/**\n * Converts a currency amount from minor units to major units.\n *\n * @param amount The amount in minor units (e.g., cents).\n * @param currency The three-letter ISO 4217 currency code.\n * @returns The amount in major units (e.g., dollars).\n */\nexport const getNormalizedAmount = (amount: CurrencyAmount['value'], currency: string) =>\n amount / 10 ** getMinorUnitDigits(currency);\n","import { getMinorUnitDigits, getNonStandardCurrency, getNormalizedAmount } from '@/utils/ts/currency';\nimport { useI18n } from '@/utils/ts/i18n';\nimport { printDevelopmentWarning } from '@/utils/ts/print-development-warning';\nimport { type BentoCurrencyISOCode } from '../../components/currency/currency.types';\n\nexport interface UseBentoCurrencyFormatCurrencyOptions {\n currency: `${BentoCurrencyISOCode}`;\n currencySign?: Intl.NumberFormatOptions['currencySign'];\n majorUnits?: boolean;\n}\n\n/**\n * A composable that returns a fully formatted and localized currency string.\n * It enforces the format `[localized number][non-breaking space][ISO code]`.\n *\n * @remarks\n * The formatting process involves several steps:\n * 1. It safely resolves the input `value`, whether it's from a prop or a slot, into a valid number.\n *\n * 2. If `majorUnits` is false, it converts the amount from minor units to major units\n * (e.g., cents to dollars) by dividing by 10 to the power of the currency's\n * decimal places (the \"exponent\"). For example, `12345 / (10 ** 2)` becomes `123.45`.\n *\n * 3. It determines the correct number of decimal places, respecting any non-standard\n * currency exceptions.\n *\n * 4. It uses `vue-i18n` to format the number with the correct sign placement and decimal/thousand\n * separators for the current locale, then manually reconstructs the string to ensure\n * the ISO code is always at the end.\n *\n * @returns An object with a function to format the currency string.\n */\nexport function useBentoCurrency() {\n const { n } = useI18n();\n\n const DEFAULT_CURRENCY = 'USD';\n const DEFAULT_CURRENCY_SIGN = 'standard';\n\n /**\n * Formats a given amount into a localized currency string with a specific structure.\n *\n * This function ensures that the output format is always `[localized number][non-breaking space][ISO code]`,\n * providing a consistent and predictable currency representation across different locales.\n *\n * @param amount The numeric value to be formatted. If `formatOptions.majorUnits` is `false` or undefined,\n * this value is treated as being in the currency's minor units (e.g., cents).\n * @param formatOptions An optional object containing options for currency formatting.\n * - `currency`: The 3-letter ISO currency code (e.g., `'USD'`, `'EUR'`). Defaults to `'USD'`.\n * - `currencySign`: The currency sign to use. Can be `'standard'` or `'accounting'`. Defaults to `'standard'`. In `accounting` mode, negative values are typically wrapped in parentheses.\n * - `majorUnits`: Set to `true` if the `amount` is already in major units (e.g., dollars instead of cents). Defaults to `false`.\n *\n * @returns A fully formatted and localized currency string (e.g., \"1,234.56 EUR\").\n */\n const formatCurrency = (amount: string | number, formatOptions?: UseBentoCurrencyFormatCurrencyOptions): string => {\n const targetCurrency = formatOptions?.currency ?? DEFAULT_CURRENCY;\n\n // Parse and Fallback\n const parsedValue = Number(amount) || 0;\n\n if (isNaN(Number(amount))) {\n printDevelopmentWarning(\n 'The value provided is not a valid string with numbers or valid number. Falling back to 0.'\n );\n }\n\n // Normalize Amount\n const normalizedAmount = formatOptions?.majorUnits\n ? parsedValue\n : getNormalizedAmount(parsedValue, targetCurrency);\n\n // Determine Precision\n const fractionDigits = getNonStandardCurrency(targetCurrency)?.exponent ?? getMinorUnitDigits(targetCurrency);\n\n // Format with Locale\n const localizedCurrencyString = n(normalizedAmount, {\n style: 'currency',\n currency: targetCurrency,\n currencySign: formatOptions?.currencySign ?? DEFAULT_CURRENCY_SIGN,\n currencyDisplay: 'code',\n minimumFractionDigits: fractionDigits,\n maximumFractionDigits: fractionDigits,\n });\n\n // Enforce Standard Format: `[number][nbsp][code]`\n const isoCodeRegex = new RegExp(`\\\\s*${targetCurrency}\\\\s*`);\n const numberPart = localizedCurrencyString.replace(isoCodeRegex, '');\n\n return `${numberPart}\\u00A0${targetCurrency}`;\n };\n\n return {\n formatCurrency,\n };\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 /**\n * Determines how the currency symbol and negative values are displayed.\n * This is only applicable to certain countries such as `en-US`.\n *\n * - `'standard'`: Default format (e.g., `-1,234.56 USD`).\n * - `'accounting'`: Uses accounting conventions, such as wrapping negative numbers in parentheses (e.g., `(1,234.56) USD`).\n *\n * @default 'standard'\n */\n currencySign?: Intl.NumberFormatOptions['currencySign'];\n}\n\nexport enum BentoCurrencyISOCode {\n AED = 'AED',\n AFA = 'AFA',\n ALL = 'ALL',\n AMD = 'AMD',\n ANG = 'ANG',\n AOA = 'AOA',\n ARS = 'ARS',\n AUD = 'AUD',\n AWG = 'AWG',\n AZN = 'AZN',\n BAM = 'BAM',\n BBD = 'BBD',\n BDT = 'BDT',\n BEF = 'BEF',\n BGN = 'BGN',\n BHD = 'BHD',\n BIF = 'BIF',\n BMD = 'BMD',\n BND = 'BND',\n BOB = 'BOB',\n BRL = 'BRL',\n BSD = 'BSD',\n BTC = 'BTC',\n BTN = 'BTN',\n BWP = 'BWP',\n BYR = 'BYR',\n BZD = 'BZD',\n CAD = 'CAD',\n CDF = 'CDF',\n CHF = 'CHF',\n CLF = 'CLF',\n CLP = 'CLP',\n CNY = 'CNY',\n COP = 'COP',\n CRC = 'CRC',\n CUC = 'CUC',\n CVE = 'CVE',\n CZK = 'CZK',\n DEM = 'DEM',\n DJF = 'DJF',\n DKK = 'DKK',\n DOP = 'DOP',\n DZD = 'DZD',\n EEK = 'EEK',\n EGP = 'EGP',\n ERN = 'ERN',\n ETB = 'ETB',\n EUR = 'EUR',\n FJD = 'FJD',\n FKP = 'FKP',\n GBP = 'GBP',\n GEL = 'GEL',\n GHS = 'GHS',\n GIP = 'GIP',\n GMD = 'GMD',\n GNF = 'GNF',\n GRD = 'GRD',\n GTQ = 'GTQ',\n GYD = 'GYD',\n HKD = 'HKD',\n HNL = 'HNL',\n HRK = 'HRK',\n HTG = 'HTG',\n HUF = 'HUF',\n IDR = 'IDR',\n ILS = 'ILS',\n INR = 'INR',\n IQD = 'IQD',\n IRR = 'IRR',\n ISK = 'ISK',\n ITL = 'ITL',\n JMD = 'JMD',\n JOD = 'JOD',\n JPY = 'JPY',\n KES = 'KES',\n KGS = 'KGS',\n KHR = 'KHR',\n KMF = 'KMF',\n KPW = 'KPW',\n KRW = 'KRW',\n KWD = 'KWD',\n KYD = 'KYD',\n KZT = 'KZT',\n LAK = 'LAK',\n LBP = 'LBP',\n LKR = 'LKR',\n LRD = 'LRD',\n LSL = 'LSL',\n LTC = 'LTC',\n LTL = 'LTL',\n LVL = 'LVL',\n LYD = 'LYD',\n MAD = 'MAD',\n MDL = 'MDL',\n MGA = 'MGA',\n MKD = 'MKD',\n MMK = 'MMK',\n MNT = 'MNT',\n MOP = 'MOP',\n MRO = 'MRO',\n MRU = 'MRU',\n MUR = 'MUR',\n MVR = 'MVR',\n MWK = 'MWK',\n MXN = 'MXN',\n MYR = 'MYR',\n MZM = 'MZM',\n NAD = 'NAD',\n NGN = 'NGN',\n NIO = 'NIO',\n NOK = 'NOK',\n NPR = 'NPR',\n NZD = 'NZD',\n OMR = 'OMR',\n PAB = 'PAB',\n PEN = 'PEN',\n PGK = 'PGK',\n PHP = 'PHP',\n PKR = 'PKR',\n PLN = 'PLN',\n PYG = 'PYG',\n QAR = 'QAR',\n RON = 'RON',\n RSD = 'RSD',\n RUB = 'RUB',\n RWF = 'RWF',\n SAR = 'SAR',\n SBD = 'SBD',\n SCR = 'SCR',\n SDG = 'SDG',\n SEK = 'SEK',\n SGD = 'SGD',\n SHP = 'SHP',\n SKK = 'SKK',\n SLL = 'SLL',\n SOS = 'SOS',\n SRD = 'SRD',\n SSP = 'SSP',\n STD = 'STD',\n SVC = 'SVC',\n SYP = 'SYP',\n SZL = 'SZL',\n THB = 'THB',\n TJS = 'TJS',\n TMT = 'TMT',\n TND = 'TND',\n TOP = 'TOP',\n TRY = 'TRY',\n TTD = 'TTD',\n TWD = 'TWD',\n TZS = 'TZS',\n UAH = 'UAH',\n UGX = 'UGX',\n USD = 'USD',\n UYU = 'UYU',\n UZS = 'UZS',\n VEF = 'VEF',\n VND = 'VND',\n VUV = 'VUV',\n WST = 'WST',\n XAF = 'XAF',\n XCD = 'XCD',\n XDR = 'XDR',\n XOF = 'XOF',\n XPF = 'XPF',\n YER = 'YER',\n ZAR = 'ZAR',\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 }}\n </bento-typography>\n\n <template v-else>{{ formattedCurrency }}</template>\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, onMounted, useSlots } from 'vue';\n import { BentoTypography } from '@/components/typography';\n import { useBentoCurrency } from '@/composables/use-bento-currency/use-bento-currency';\n import { deprecate } from '@/utils/ts/deprecate';\n import { getSlotText } from '@/utils/ts/get-slot-text';\n import { BentoCurrencyISOCode, type BentoCurrencyProps } from './currency.types';\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 currencySign: { default: 'standard' }\n});\n\n const { formatCurrency } = useBentoCurrency();\n\n const formattedCurrency = computed(() => {\n const rawCurrencyValue = props.value ?? getSlotText(slots)('default');\n\n return formatCurrency(rawCurrencyValue, {\n currency: props.currency,\n currencySign: props.currencySign,\n majorUnits: props.majorUnits,\n });\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 i18n: {}, // required to enable E2E to run as they do not have vue-i18n set up\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./currency.scss\" />\n"],"names":["currencyMap","getNonStandardCurrency","currency","item","getMinorUnitDigits","exception","getNormalizedAmount","amount","useBentoCurrency","n","useI18n","DEFAULT_CURRENCY","DEFAULT_CURRENCY_SIGN","formatOptions","targetCurrency","parsedValue","printDevelopmentWarning","normalizedAmount","fractionDigits","_a","localizedCurrencyString","isoCodeRegex","BentoCurrencyISOCode","BentoCurrencyISOCode2","__default__","slots","useSlots","formatCurrency","formattedCurrency","computed","rawCurrencyValue","props","getSlotText","onMounted","deprecate"],"mappings":";;;;;;AAWO,MAAAA,IAAA;AAAA,EAAwC;AAAA,IAC3C,UAAA;AAAA,IACc,YAAA;AAAA,MACE;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACA;AAAA,EACJ;AAAA,EACJ;AAAA,IACA,UAAA;AAAA,IACc,YAAA,CAAA,KAAA;AAAA,EACQ;AAAA,EACtB;AAAA,IACA,UAAA;AAAA,IACc,YAAA,CAAA,OAAA,OAAA,OAAA,OAAA,OAAA,OAAA,KAAA;AAAA,EACkD;AAEpE,GClCaC,IAAA,CAAAC,MAAAF,EAAA,KAAA,CAAAG,MAAAA,EAAA,WAAA,SAAAD,CAAA,CAAA;AAcN,SAAAE,EAAAF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A,OACAA,EAAA,MAAA,OACAA,EAAA,MAAA,OACAA,EAAA,MAAA,OACAA,EAAA,MAAA,OACAA,EAAA,MAAA,OACAA,EAAA,MAAA,OACAA,EAAA,MAAA,OACAA,EAAA,MAAA,OACAA,EAAA,MAAA,OACAA,EAAA,MAAA,OACAA,EAAA,MAAA,OACAA,EAAA,MAAA,OACAA,EAAA,MAAA,OACAA,EAAA,MAAA,OACAA,EAAA,MAAA,OACAA,EAAA,MAAA,OACAA,EAAA,MAAA,OAzKQA,IAAAD,KAAA,CAAA,CAAA;ACqCR,MAAAE,IAAA;AAAA,EAAe,MAAA;AAAA,EACL,MAAA,CAAA;AAAA;AAEV;;;;;;;;;;iBAvDAC,IAAAC,EAAA,GAUA,EAAA,gBAAAC,EAAA,IAAAnB,EAAA,GAEAoB,IAAAC,EAAA,MAAA;AACI,YAAAC,IAAAC,EAAA,SAAAC,EAAAP,CAAA,EAAA,SAAA;AAEA,aAAAE,EAAAG,GAAA;AAAA,QAAwC,UAAAC,EAAA;AAAA,QACpB,cAAAA,EAAA;AAAA,QACI,YAAAA,EAAA;AAAA,MACF,CAAA;AAAA,IACrB,CAAA;AAGL,WAAAE,EAAA,MAAA;AACI,MAAAD,EAAAP,CAAA,EAAA,SAAA,KACIS;AAAA,QAAA;AAAA,QACI;AAAA;AAAA;AAAA,QACA;AAAA,MAGA;AAAA,IAER,CAAA;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"currency.AvvbekWO.js","sources":["../../src/utils/ts/currency/currency-map.ts","../../src/utils/ts/currency/currency.ts","../../src/composables/use-bento-currency/use-bento-currency.ts","../../src/components/currency/currency.types.ts","../../src/components/currency/currency.vue"],"sourcesContent":["export interface CurrencyMap {\n exponent: number;\n currencies: Array<string>;\n}\n\n/**\n * Contains mapping configuration between currency code and exponent for amount in the corresponding currency.\n * https://docs.adyen.com/development-resources/currency-codes\n *\n * @internal\n */\nexport const currencyMap: Array<CurrencyMap> = [\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 { currencyMap, type CurrencyMap } from './currency-map';\nimport { type CurrencyAmount } from './currency.types';\n\n/**\n * Returns exponent for specified currency code that do not adhere to the ISO 4217 standard.\n */\nexport const getNonStandardCurrency = (currency: string): CurrencyMap =>\n currencyMap.find(item => item.currencies.includes(currency));\n\n/**\n * Returns the number of minor units (decimal places) for a given currency.\n * The function uses an internal map for currencies with non-standard decimal places and defaults to 2 for all others.\n *\n * @param currency - The three-letter ISO 4217 currency code (e.g., 'USD', 'JPY').\n * @returns The number of decimal places for the currency.\n *\n * @example\n * getMinorUnitDigits('USD'); // Returns 2\n * getMinorUnitDigits('JPY'); // Returns 0\n */\nexport function getMinorUnitDigits(currency: string): number {\n const exception = getNonStandardCurrency(currency);\n\n return exception?.exponent ?? 2;\n}\n\n/**\n * Converts a currency amount from minor units to major units.\n *\n * @param amount The amount in minor units (e.g., cents).\n * @param currency The three-letter ISO 4217 currency code.\n * @returns The amount in major units (e.g., dollars).\n */\nexport const getNormalizedAmount = (amount: CurrencyAmount['value'], currency: string) =>\n amount / 10 ** getMinorUnitDigits(currency);\n","import { getMinorUnitDigits, getNonStandardCurrency, getNormalizedAmount } from '@/utils/ts/currency';\nimport { useI18n } from '@/utils/ts/i18n';\nimport { printDevelopmentWarning } from '@/utils/ts/print-development-warning';\nimport { type BentoCurrencyISOCode } from '../../components/currency/currency.types';\n\nexport interface UseBentoCurrencyFormatCurrencyOptions {\n currency: `${BentoCurrencyISOCode}`;\n currencySign?: Intl.NumberFormatOptions['currencySign'];\n majorUnits?: boolean;\n}\n\n/**\n * A composable that returns a fully formatted and localized currency string.\n * It enforces the format `[localized number][non-breaking space][ISO code]`.\n *\n * @remarks\n * The formatting process involves several steps:\n * 1. It safely resolves the input `value`, whether it's from a prop or a slot, into a valid number.\n *\n * 2. If `majorUnits` is false, it converts the amount from minor units to major units\n * (e.g., cents to dollars) by dividing by 10 to the power of the currency's\n * decimal places (the \"exponent\"). For example, `12345 / (10 ** 2)` becomes `123.45`.\n *\n * 3. It determines the correct number of decimal places, respecting any non-standard\n * currency exceptions.\n *\n * 4. It uses `vue-i18n` to format the number with the correct sign placement and decimal/thousand\n * separators for the current locale, then manually reconstructs the string to ensure\n * the ISO code is always at the end.\n *\n * @returns An object with a function to format the currency string.\n */\nexport function useBentoCurrency() {\n const { n } = useI18n();\n\n const DEFAULT_CURRENCY = 'USD';\n const DEFAULT_CURRENCY_SIGN = 'standard';\n\n /**\n * Formats a given amount into a localized currency string with a specific structure.\n *\n * This function ensures that the output format is always `[localized number][non-breaking space][ISO code]`,\n * providing a consistent and predictable currency representation across different locales.\n *\n * @param amount The numeric value to be formatted. If `formatOptions.majorUnits` is `false` or undefined,\n * this value is treated as being in the currency's minor units (e.g., cents).\n * @param formatOptions An optional object containing options for currency formatting.\n * - `currency`: The 3-letter ISO currency code (e.g., `'USD'`, `'EUR'`). Defaults to `'USD'`.\n * - `currencySign`: The currency sign to use. Can be `'standard'` or `'accounting'`. Defaults to `'standard'`. In `accounting` mode, negative values are typically wrapped in parentheses.\n * - `majorUnits`: Set to `true` if the `amount` is already in major units (e.g., dollars instead of cents). Defaults to `false`.\n *\n * @returns A fully formatted and localized currency string (e.g., \"1,234.56 EUR\").\n */\n const formatCurrency = (amount: string | number, formatOptions?: UseBentoCurrencyFormatCurrencyOptions): string => {\n const targetCurrency = formatOptions?.currency ?? DEFAULT_CURRENCY;\n\n // Parse and Fallback\n const parsedValue = Number(amount) || 0;\n\n if (isNaN(Number(amount))) {\n printDevelopmentWarning(\n 'The value provided is not a valid string with numbers or valid number. Falling back to 0.'\n );\n }\n\n // Normalize Amount\n const normalizedAmount = formatOptions?.majorUnits\n ? parsedValue\n : getNormalizedAmount(parsedValue, targetCurrency);\n\n // Determine Precision\n const fractionDigits = getNonStandardCurrency(targetCurrency)?.exponent ?? getMinorUnitDigits(targetCurrency);\n\n // Format with Locale\n const localizedCurrencyString = n(normalizedAmount, {\n style: 'currency',\n currency: targetCurrency,\n currencySign: formatOptions?.currencySign ?? DEFAULT_CURRENCY_SIGN,\n currencyDisplay: 'code',\n minimumFractionDigits: fractionDigits,\n maximumFractionDigits: fractionDigits,\n });\n\n // Enforce Standard Format: `[number][nbsp][code]`\n const isoCodeRegex = new RegExp(`\\\\s*${targetCurrency}\\\\s*`);\n const numberPart = localizedCurrencyString.replace(isoCodeRegex, '');\n\n return `${numberPart}\\u00A0${targetCurrency}`;\n };\n\n return {\n formatCurrency,\n };\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 /**\n * Determines how the currency symbol and negative values are displayed.\n * This is only applicable to certain countries such as `en-US`.\n *\n * - `'standard'`: Default format (e.g., `-1,234.56 USD`).\n * - `'accounting'`: Uses accounting conventions, such as wrapping negative numbers in parentheses (e.g., `(1,234.56) USD`).\n *\n * @default 'standard'\n */\n currencySign?: Intl.NumberFormatOptions['currencySign'];\n}\n\nexport enum BentoCurrencyISOCode {\n AED = 'AED',\n AFA = 'AFA',\n ALL = 'ALL',\n AMD = 'AMD',\n ANG = 'ANG',\n AOA = 'AOA',\n ARS = 'ARS',\n AUD = 'AUD',\n AWG = 'AWG',\n AZN = 'AZN',\n BAM = 'BAM',\n BBD = 'BBD',\n BDT = 'BDT',\n BEF = 'BEF',\n BGN = 'BGN',\n BHD = 'BHD',\n BIF = 'BIF',\n BMD = 'BMD',\n BND = 'BND',\n BOB = 'BOB',\n BRL = 'BRL',\n BSD = 'BSD',\n BTC = 'BTC',\n BTN = 'BTN',\n BWP = 'BWP',\n BYR = 'BYR',\n BZD = 'BZD',\n CAD = 'CAD',\n CDF = 'CDF',\n CHF = 'CHF',\n CLF = 'CLF',\n CLP = 'CLP',\n CNY = 'CNY',\n COP = 'COP',\n CRC = 'CRC',\n CUC = 'CUC',\n CVE = 'CVE',\n CZK = 'CZK',\n DEM = 'DEM',\n DJF = 'DJF',\n DKK = 'DKK',\n DOP = 'DOP',\n DZD = 'DZD',\n EEK = 'EEK',\n EGP = 'EGP',\n ERN = 'ERN',\n ETB = 'ETB',\n EUR = 'EUR',\n FJD = 'FJD',\n FKP = 'FKP',\n GBP = 'GBP',\n GEL = 'GEL',\n GHS = 'GHS',\n GIP = 'GIP',\n GMD = 'GMD',\n GNF = 'GNF',\n GRD = 'GRD',\n GTQ = 'GTQ',\n GYD = 'GYD',\n HKD = 'HKD',\n HNL = 'HNL',\n HRK = 'HRK',\n HTG = 'HTG',\n HUF = 'HUF',\n IDR = 'IDR',\n ILS = 'ILS',\n INR = 'INR',\n IQD = 'IQD',\n IRR = 'IRR',\n ISK = 'ISK',\n ITL = 'ITL',\n JMD = 'JMD',\n JOD = 'JOD',\n JPY = 'JPY',\n KES = 'KES',\n KGS = 'KGS',\n KHR = 'KHR',\n KMF = 'KMF',\n KPW = 'KPW',\n KRW = 'KRW',\n KWD = 'KWD',\n KYD = 'KYD',\n KZT = 'KZT',\n LAK = 'LAK',\n LBP = 'LBP',\n LKR = 'LKR',\n LRD = 'LRD',\n LSL = 'LSL',\n LTC = 'LTC',\n LTL = 'LTL',\n LVL = 'LVL',\n LYD = 'LYD',\n MAD = 'MAD',\n MDL = 'MDL',\n MGA = 'MGA',\n MKD = 'MKD',\n MMK = 'MMK',\n MNT = 'MNT',\n MOP = 'MOP',\n MRO = 'MRO',\n MRU = 'MRU',\n MUR = 'MUR',\n MVR = 'MVR',\n MWK = 'MWK',\n MXN = 'MXN',\n MYR = 'MYR',\n MZM = 'MZM',\n NAD = 'NAD',\n NGN = 'NGN',\n NIO = 'NIO',\n NOK = 'NOK',\n NPR = 'NPR',\n NZD = 'NZD',\n OMR = 'OMR',\n PAB = 'PAB',\n PEN = 'PEN',\n PGK = 'PGK',\n PHP = 'PHP',\n PKR = 'PKR',\n PLN = 'PLN',\n PYG = 'PYG',\n QAR = 'QAR',\n RON = 'RON',\n RSD = 'RSD',\n RUB = 'RUB',\n RWF = 'RWF',\n SAR = 'SAR',\n SBD = 'SBD',\n SCR = 'SCR',\n SDG = 'SDG',\n SEK = 'SEK',\n SGD = 'SGD',\n SHP = 'SHP',\n SKK = 'SKK',\n SLL = 'SLL',\n SOS = 'SOS',\n SRD = 'SRD',\n SSP = 'SSP',\n STD = 'STD',\n SVC = 'SVC',\n SYP = 'SYP',\n SZL = 'SZL',\n THB = 'THB',\n TJS = 'TJS',\n TMT = 'TMT',\n TND = 'TND',\n TOP = 'TOP',\n TRY = 'TRY',\n TTD = 'TTD',\n TWD = 'TWD',\n TZS = 'TZS',\n UAH = 'UAH',\n UGX = 'UGX',\n USD = 'USD',\n UYU = 'UYU',\n UZS = 'UZS',\n VEF = 'VEF',\n VND = 'VND',\n VUV = 'VUV',\n WST = 'WST',\n XAF = 'XAF',\n XCD = 'XCD',\n XDR = 'XDR',\n XOF = 'XOF',\n XPF = 'XPF',\n YER = 'YER',\n ZAR = 'ZAR',\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 }}\n </bento-typography>\n\n <template v-else>{{ formattedCurrency }}</template>\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, onMounted, useSlots } from 'vue';\n import { BentoTypography } from '@/components/typography';\n import { useBentoCurrency } from '@/composables/use-bento-currency/use-bento-currency';\n import { deprecate } from '@/utils/ts/deprecate';\n import { getSlotText } from '@/utils/ts/get-slot-text';\n import { BentoCurrencyISOCode, type BentoCurrencyProps } from './currency.types';\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 currencySign: { default: 'standard' }\n});\n\n const { formatCurrency } = useBentoCurrency();\n\n const formattedCurrency = computed(() => {\n const rawCurrencyValue = props.value ?? getSlotText(slots)('default');\n\n return formatCurrency(rawCurrencyValue, {\n currency: props.currency,\n currencySign: props.currencySign,\n majorUnits: props.majorUnits,\n });\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 i18n: {}, // required to enable E2E to run as they do not have vue-i18n set up\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./currency.scss\" />\n"],"names":["currencyMap","getNonStandardCurrency","currency","item","getMinorUnitDigits","exception","getNormalizedAmount","amount","useBentoCurrency","n","useI18n","DEFAULT_CURRENCY","DEFAULT_CURRENCY_SIGN","formatOptions","targetCurrency","parsedValue","printDevelopmentWarning","normalizedAmount","fractionDigits","_a","localizedCurrencyString","isoCodeRegex","BentoCurrencyISOCode","BentoCurrencyISOCode2","__default__","slots","useSlots","formatCurrency","formatted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