@adyen/bento-vue2 1.95.0 → 1.96.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/index.d.ts +77 -0
- package/dist/assets/accordion-item.css +1 -1
- package/dist/assets/action-bar.css +1 -1
- package/dist/assets/base-modal.css +1 -1
- package/dist/assets/button-actions.css +1 -1
- package/dist/assets/card.css +1 -1
- package/dist/assets/data-grid.css +1 -1
- package/dist/assets/date-picker.css +1 -1
- package/dist/assets/dialog-page.css +1 -1
- package/dist/assets/draggable-handle.css +1 -1
- package/dist/assets/dropdown.css +1 -1
- package/dist/assets/field-label.css +1 -1
- package/dist/assets/file-uploader.css +1 -1
- package/dist/assets/filter-bar.css +1 -1
- package/dist/assets/input-field-password.css +1 -1
- package/dist/assets/inspector.css +1 -1
- package/dist/assets/modal-fullscreen.css +1 -1
- package/dist/assets/navigation-menu-group.css +1 -1
- package/dist/assets/secondary-nav.css +1 -1
- package/dist/assets/sidepanel.css +1 -1
- package/dist/checkbox.js +2 -2
- package/dist/chunks/{calendar.ofn3G6eW.js → calendar.D0JIbmoS.js} +310 -304
- package/dist/chunks/calendar.D0JIbmoS.js.map +1 -0
- package/dist/chunks/{checkbox-group.BAjvgXlc.js → checkbox-group.CNTMMwQr.js} +2 -2
- package/dist/chunks/{checkbox-group.BAjvgXlc.js.map → checkbox-group.CNTMMwQr.js.map} +1 -1
- package/dist/chunks/{checkbox.BAQDBNL6.js → checkbox.BIzqX_eH.js} +18 -18
- package/dist/chunks/{checkbox.BAQDBNL6.js.map → checkbox.BIzqX_eH.js.map} +1 -1
- package/dist/chunks/{code-snippet.B3iCsNmb.js → code-snippet.lcQRsLdZ.js} +2 -2
- package/dist/chunks/{code-snippet.B3iCsNmb.js.map → code-snippet.lcQRsLdZ.js.map} +1 -1
- package/dist/chunks/{dashboard-section.HFJcf8-_.js → dashboard-section.DiGQXS9L.js} +2 -2
- package/dist/chunks/{dashboard-section.HFJcf8-_.js.map → dashboard-section.DiGQXS9L.js.map} +1 -1
- package/dist/chunks/{data-grid-template.BjfPUEoH.js → data-grid-template.BVppx9kZ.js} +2 -2
- package/dist/chunks/{data-grid-template.BjfPUEoH.js.map → data-grid-template.BVppx9kZ.js.map} +1 -1
- package/dist/chunks/{data-grid.Cua2Jxvq.js → data-grid.DQwAkw4U.js} +11 -11
- package/dist/chunks/{data-grid.Cua2Jxvq.js.map → data-grid.DQwAkw4U.js.map} +1 -1
- package/dist/chunks/{date-picker.CYDTf6De.js → date-picker.BWxvyK5J.js} +40 -40
- package/dist/chunks/date-picker.BWxvyK5J.js.map +1 -0
- package/dist/chunks/{date-range-picker.DGGvwRfn.js → date-range-picker.gfRJmzXn.js} +10 -10
- package/dist/chunks/{date-range-picker.DGGvwRfn.js.map → date-range-picker.gfRJmzXn.js.map} +1 -1
- package/dist/chunks/{date-time-picker.CyNb-xDm.js → date-time-picker.BIl9kFLh.js} +5 -5
- package/dist/chunks/{date-time-picker.CyNb-xDm.js.map → date-time-picker.BIl9kFLh.js.map} +1 -1
- package/dist/chunks/{draggable-handle.CU1L7J87.js → draggable-handle.DIhHtHG9.js} +530 -499
- package/dist/chunks/{draggable-handle.CU1L7J87.js.map → draggable-handle.DIhHtHG9.js.map} +1 -1
- package/dist/chunks/{dropdown-tag.C1qg52L9.js → dropdown-tag.CuDxdSfb.js} +2 -2
- package/dist/chunks/{dropdown-tag.C1qg52L9.js.map → dropdown-tag.CuDxdSfb.js.map} +1 -1
- package/dist/chunks/{dropdown.BEurqT8m.js → dropdown.C70AlvOT.js} +264 -257
- package/dist/chunks/dropdown.C70AlvOT.js.map +1 -0
- package/dist/chunks/{filter-bar.gjMPoK6d.js → filter-bar.DQ9fJXq1.js} +57 -50
- package/dist/chunks/{filter-bar.gjMPoK6d.js.map → filter-bar.DQ9fJXq1.js.map} +1 -1
- package/dist/chunks/{header-with-views.B2Ok5KI1.js → header-with-views.4VNHbNk0.js} +4 -4
- package/dist/chunks/{header-with-views.B2Ok5KI1.js.map → header-with-views.4VNHbNk0.js.map} +1 -1
- package/dist/chunks/{input-field-password.viF49CQh.js → input-field-password.CRqYWZGS.js} +34 -34
- package/dist/chunks/input-field-password.CRqYWZGS.js.map +1 -0
- package/dist/chunks/{input-field-phone-number.DnpTj7q5.js → input-field-phone-number.DHiuL0cF.js} +2 -2
- package/dist/chunks/{input-field-phone-number.DnpTj7q5.js.map → input-field-phone-number.DHiuL0cF.js.map} +1 -1
- package/dist/chunks/{input-field.D86PSAiu.js → input-field.BkQZ6Qzl.js} +2 -2
- package/dist/chunks/{input-field.D86PSAiu.js.map → input-field.BkQZ6Qzl.js.map} +1 -1
- package/dist/chunks/{input-time.LyKZXnVO.js → input-time.BiOHvUEA.js} +3 -3
- package/dist/chunks/{input-time.LyKZXnVO.js.map → input-time.BiOHvUEA.js.map} +1 -1
- package/dist/chunks/{pagination.CJ3d1O_s.js → pagination.DItyAwy1.js} +2 -2
- package/dist/chunks/{pagination.CJ3d1O_s.js.map → pagination.DItyAwy1.js.map} +1 -1
- package/dist/chunks/{rich-text-editor.Dwq3Z_lK.js → rich-text-editor.D5URbwnM.js} +2 -2
- package/dist/chunks/{rich-text-editor.Dwq3Z_lK.js.map → rich-text-editor.D5URbwnM.js.map} +1 -1
- package/dist/chunks/{search-bar.BvHhXdNu.js → search-bar.D-WK8eMQ.js} +3 -3
- package/dist/chunks/{search-bar.BvHhXdNu.js.map → search-bar.D-WK8eMQ.js.map} +1 -1
- package/dist/chunks/secondary-nav.C7lEDaoj.js +259 -0
- package/dist/chunks/{secondary-nav.BvbT8LXa.js.map → secondary-nav.C7lEDaoj.js.map} +1 -1
- package/dist/chunks/{selection-card-group.ZZ_qF1L1.js → selection-card-group.CiFW4AZR.js} +8 -8
- package/dist/chunks/{selection-card-group.ZZ_qF1L1.js.map → selection-card-group.CiFW4AZR.js.map} +1 -1
- package/dist/chunks/tab.QEKU5Udp.js +256 -0
- package/dist/chunks/{tab.YQXssvyU.js.map → tab.QEKU5Udp.js.map} +1 -1
- package/dist/chunks/{use-cached-selected-values.txnml8sE.js → use-cached-selected-values.D0s14AxT.js} +2 -2
- package/dist/chunks/{use-cached-selected-values.txnml8sE.js.map → use-cached-selected-values.D0s14AxT.js.map} +1 -1
- package/dist/chunks/{use-date-input-formatter.D7Ud6Ana.js → use-date-input-formatter.B5GQd3s2.js} +2 -2
- package/dist/chunks/{use-date-input-formatter.D7Ud6Ana.js.map → use-date-input-formatter.B5GQd3s2.js.map} +1 -1
- package/dist/code-snippet.js +1 -1
- package/dist/dashboard-template.js +1 -1
- package/dist/data-grid-template.js +1 -1
- package/dist/data-grid.js +1 -1
- package/dist/date-picker.js +2 -2
- package/dist/date-range-picker.js +2 -2
- package/dist/date-time-picker.js +1 -1
- package/dist/draggable.js +1 -1
- package/dist/dropdown.js +3 -3
- package/dist/filter-bar.js +1 -1
- package/dist/header-with-views.js +1 -1
- package/dist/index.js +26 -26
- package/dist/input-field-password.js +1 -1
- package/dist/input-field-phone-number.js +1 -1
- package/dist/input-field.js +1 -1
- package/dist/input-time.js +1 -1
- package/dist/internal.js +2 -2
- package/dist/pagination.js +1 -1
- package/dist/rich-text-editor.js +1 -1
- package/dist/search-bar.js +2 -2
- package/dist/secondary-nav.js +1 -1
- package/dist/selection-card.js +1 -1
- package/dist/tabs.js +1 -1
- package/dist/web-types.json +11 -1
- package/package.json +4 -4
- package/dist/chunks/calendar.ofn3G6eW.js.map +0 -1
- package/dist/chunks/date-picker.CYDTf6De.js.map +0 -1
- package/dist/chunks/dropdown.BEurqT8m.js.map +0 -1
- package/dist/chunks/input-field-password.viF49CQh.js.map +0 -1
- package/dist/chunks/secondary-nav.BvbT8LXa.js +0 -223
- package/dist/chunks/tab.YQXssvyU.js +0 -229
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent as m, provide as _, toRef as b, useAttrs as C, ref as o, watch as S } from "vue";
|
|
2
|
-
import { d as v } from "./use-cached-selected-values.
|
|
2
|
+
import { d as v } from "./use-cached-selected-values.D0s14AxT.js";
|
|
3
3
|
import { u as y } from "./index.B6WW_F-J.js";
|
|
4
|
-
import { I, B as E } from "./input-field.
|
|
4
|
+
import { I, B as E } from "./input-field.BkQZ6Qzl.js";
|
|
5
5
|
import { S as k } from "./search.D53Ia3rC.js";
|
|
6
6
|
import { C as T } from "./cross-circle-fill.DTDtgLMf.js";
|
|
7
7
|
import { n as F } from "./_plugin-vue2_normalizer.CeySl7Fu.js";
|
|
@@ -122,4 +122,4 @@ export {
|
|
|
122
122
|
A as a,
|
|
123
123
|
i as b
|
|
124
124
|
};
|
|
125
|
-
//# sourceMappingURL=search-bar.
|
|
125
|
+
//# sourceMappingURL=search-bar.D-WK8eMQ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-bar.
|
|
1
|
+
{"version":3,"file":"search-bar.D-WK8eMQ.js","sources":["../../src/components/search-bar/search-bar.types.ts","../../src/components/search-bar/search-bar.vue"],"sourcesContent":["export enum BentoSearchBarInternalEvent {\n CLEAR = 'clear',\n ESCAPE = 'escape-pressed',\n INPUT = 'input',\n UPDATE = 'update:search-term',\n}\n\nexport enum BentoSearchBarEvent {\n CLEAR = 'search-clear',\n INPUT = 'search-input',\n UPDATE = 'update:search-term',\n}\n\nexport interface BentoSearchBarItem {\n label: string;\n items?: Array<BentoSearchBarItem>;\n}\n\nexport type BentoSearchBarData = Array<BentoSearchBarItem>;\n\nexport interface BentoSearchBarProps {\n /**\n * Text that labels an the search bar input element\n */\n inputFieldAriaLabel: string;\n\n /**\n * Reduces height of the search bar. Default: false\n */\n condensed?: boolean;\n\n /**\n * Custom debounce time. Default: 300\n */\n debounceTime?: number;\n\n /**\n * Disables the text input.\n */\n disabled?: boolean;\n\n /**\n * Text displayed as a hint when the field is not empty\n */\n hint?: string;\n\n /**\n * Text displayed as the placeholder of the input-field\n */\n placeholder?: string;\n\n /**\n * Text displayed as the value being searched\n */\n value?: string;\n}\n","<template>\n <div class=\"b-search-bar\">\n <bento-input-field\n ref=\"bentoInputField\"\n v-bind=\"attrs\"\n :model-value=\"searchTerm\"\n type=\"search\"\n :condensed=\"condensed\"\n :aria-label=\"inputFieldAriaLabel\"\n :aria-hidden=\"false\"\n :disabled=\"disabled\"\n :placeholder=\"placeholder\"\n @update:model-value=\"onInputEvent\"\n @focus=\"emit('focus')\"\n @blur=\"emit('blur')\"\n @escape-pressed=\"emit(BentoSearchBarInternalEvent.ESCAPE)\"\n >\n <template #iconBefore>\n <search-icon :svg-title=\"t('search')\" aria-hidden=\"true\" />\n </template>\n\n <template v-if=\"searchTerm\" #iconAfter>\n <div\n class=\"b-search-bar__clear-search\"\n tabindex=\"0\"\n data-testid=\"b-search-bar-clear-search-button\"\n @click=\"onClearSearch\"\n @keypress.enter=\"onClearSearch\"\n @keyup.space=\"onClearSearch\"\n >\n <cross-circle-fill-icon :svg-title=\"t('clearSearch')\" />\n </div>\n </template>\n </bento-input-field>\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import { provide, ref, toRef, useAttrs, watch } from 'vue';\n import { debounce } from '@/utils/ts/debounce';\n import { BentoSearchBarInternalEvent, type BentoSearchBarProps } from './search-bar.types';\n import { useI18n } from '@/utils/ts/i18n';\n import { INPUT_FIELD_HINT_INJECTION_KEY } from '@/components/input-field/input-field.keys';\n // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n import BentoInputField from '@/components/input-field/input-field.vue';\n import SearchIcon from '@adyen/ui-assets-icons-16/vue/search';\n import CrossCircleFillIcon from '@adyen/ui-assets-icons-16/vue/cross-circle-fill';\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n const { t } = useI18n<{ message: MessageSchema }>({ messages });\n\n const props = defineProps({\n inputFieldAriaLabel: null,\n condensed: { type: Boolean, default: false },\n debounceTime: { default: 300 },\n disabled: { type: Boolean, default: false },\n hint: { default: '' },\n placeholder: { default: '' },\n value: { default: undefined }\n});\n\n const emit = defineEmits([\"input\", \"clear\", \"escape-pressed\", \"blur\", \"focus\"]);\n\n provide(INPUT_FIELD_HINT_INJECTION_KEY, toRef(props, 'hint'));\n\n const attrs = useAttrs();\n const searchTerm = ref(props.value);\n const bentoInputField = ref<InstanceType<typeof BentoInputField> | null>();\n\n watch(\n () => props.value,\n () => {\n searchTerm.value = props.value;\n },\n { immediate: true }\n );\n\n const onClearSearch = () => {\n searchTerm.value = '';\n emit('clear');\n emit('input', '');\n };\n\n const debouncedEmit = debounce(() => {\n emit('input', searchTerm.value);\n }, props.debounceTime);\n\n const onInputEvent = (value: string) => {\n searchTerm.value = value;\n debouncedEmit();\n };\n\n const focus = () => {\n // bentoInputField.value?.focusInput();\n bentoInputField.value.focusInput();\n };\n\n // Expose method so that it can be used to focus on the input from outside the component\n defineExpose({\n /**\n * Focus on the input field when called.\n */\n focus,\n });\n</script>\n\n<script lang=\"ts\">\n /**\n * Search functionality to help users find the desired data quicker.\n * When a user starts typing, the data is dynamically filtered to\n * only show the relevant results.\n *\n * Clearing the search field displays the entire list again.\n *\n * @example\n * import {\n * BentoSearchBar,\n * BentoSearchBarData,\n * useSearchBarFilter\n * } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoSearchBar },\n * template: `\n * <bento-search-bar\n * input-field-aria-label=\"Search bar\"\n * v-model=\"searchTerm\"\n * @input=\"onInput\"\n * @clear=\"onClearSearch\"\n * />\n * // Render the filtered data\n * {{ filteredData }}\n * `,\n * setup() {\n * const searchTerm = ref('');\n * const data = ref<BentoSearchBarData>([]);\n * const filteredData = useSearchBarFilter(searchTerm, data);\n *\n * consdt onInput = () => {}\n * consdt onClearSearch = () => {}\n *\n * return {\n * searchTerm,\n * filteredData,\n * onInput,\n * onClearSearch,\n * };\n * }\n * }\n */\n export default {\n i18n: { messages },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./search-bar.scss\" />\n"],"names":["BentoSearchBarInternalEvent","BentoSearchBarInternalEvent2","BentoSearchBarEvent","BentoSearchBarEvent2","__default__","messages","t","useI18n","provide","INPUT_FIELD_HINT_INJECTION_KEY","toRef","props","attrs","useAttrs","searchTerm","ref","bentoInputField","watch","onClearSearch","emit","debouncedEmit","debounce","onInputEvent","value","focus","expose"],"mappings":";;;;;;;;AAAO,IAAAA,IAAA,kBAAAC,OACHA,EAAA,QAAA,SACAA,EAAA,SAAA,kBACAA,EAAA,QAAA,SACAA,EAAA,SAAA,sBAJQA,IAAAD,KAAA,CAAA,CAAA,GAOLE,IAAA,kBAAAC,OACHA,EAAA,QAAA,gBACAA,EAAA,QAAA,gBACAA,EAAA,SAAA,sBAHQA,IAAAD,KAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GCiJRE,IAAA;AAAA,EAAe,MAAA,EAAA,UAAAC,EAAA;AAEf;;;;;;;;;;;;;;iBAvGA,EAAA,GAAAC,EAAA,IAAAC,EAAA;AAcA,IAAAC,EAAAC,GAAAC,EAAAC,GAAA,MAAA,CAAA;AAEA,UAAAC,IAAAC,EAAA,GACAC,IAAAC,EAAAJ,EAAA,KAAA,GACAK,IAAAD,EAAA;AAEA,IAAAE;AAAA,MAAA,MAAAN,EAAA;AAAA,MACgB,MAAA;AAER,QAAAG,EAAA,QAAAH,EAAA;AAAA,MAAyB;AAAA,MAC7B,EAAA,WAAA,GAAA;AAAA,IACkB;AAGtB,UAAAO,IAAA,MAAA;AACI,MAAAJ,EAAA,QAAA,IACAK,EAAA,OAAA,GACAA,EAAA,SAAA,EAAA;AAAA,IAAgB,GAGpBC,IAAAC,EAAA,MAAA;AACI,MAAAF,EAAA,SAAAL,EAAA,KAAA;AAAA,IAA8B,GAAAH,EAAA,YAAA,GAGlCW,IAAA,CAAAC,MAAA;AACI,MAAAT,EAAA,QAAAS,GACAH,EAAA;AAAA,IAAc,GAGlBI,IAAA,MAAA;AAEI,MAAAR,EAAA,MAAA,WAAA;AAAA,IAAiC;AAIrC,WAAAS,EAAA;AAAA;AAAA;AAAA;AAAA,MAAa,OAAAD;AAAA,IAIT,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { defineComponent as S, inject as $, ref as T, computed as p, watch as D, toRef as F, readonly as R, provide as L } from "vue";
|
|
2
|
+
import { B as V } from "./dropdown.C70AlvOT.js";
|
|
3
|
+
import { B as w } from "./typography.C8lPlsbD.js";
|
|
4
|
+
import { B as A } from "./tag.CbNFG45Y.js";
|
|
5
|
+
import { C as M } from "./cross-circle-fill.DTDtgLMf.js";
|
|
6
|
+
import { b as P } from "./index.CJYgd0QI.js";
|
|
7
|
+
import { u as O } from "./index.B6WW_F-J.js";
|
|
8
|
+
import { a as z } from "./es6.Cu3DYUPA.js";
|
|
9
|
+
import { B as U } from "./button.DITA6YtS.js";
|
|
10
|
+
import { C as H } from "./chevron-down.eYtgv5ly.js";
|
|
11
|
+
import { C as j } from "./chevron-up.d8cwIlA_.js";
|
|
12
|
+
import { g as G } from "./generate-uid.NJ8tVoha.js";
|
|
13
|
+
import { u as J } from "./use-expandable-content-height.2WJLCL-R.js";
|
|
14
|
+
import { n as B } from "./_plugin-vue2_normalizer.CeySl7Fu.js";
|
|
15
|
+
import "../assets/secondary-nav.css";
|
|
16
|
+
const k = /* @__PURE__ */ Symbol("secondary nav state"), X = {
|
|
17
|
+
"de-DE": {
|
|
18
|
+
errorCount: "Fehler | Fehler"
|
|
19
|
+
},
|
|
20
|
+
"en-GB": {
|
|
21
|
+
errorCount: "error | errors"
|
|
22
|
+
},
|
|
23
|
+
"en-US": {
|
|
24
|
+
errorCount: "error | errors"
|
|
25
|
+
},
|
|
26
|
+
"es-ES": {
|
|
27
|
+
errorCount: "error | errores"
|
|
28
|
+
},
|
|
29
|
+
"es-MX": {
|
|
30
|
+
errorCount: "error | errores"
|
|
31
|
+
},
|
|
32
|
+
"fr-FR": {
|
|
33
|
+
errorCount: "erreur | erreurs"
|
|
34
|
+
},
|
|
35
|
+
"it-IT": {
|
|
36
|
+
errorCount: "errore | errori"
|
|
37
|
+
},
|
|
38
|
+
"ja-JP": {
|
|
39
|
+
errorCount: "エラー | エラー"
|
|
40
|
+
},
|
|
41
|
+
"pt-BR": {
|
|
42
|
+
errorCount: "erro | erros"
|
|
43
|
+
},
|
|
44
|
+
"zh-CN": {
|
|
45
|
+
errorCount: "错误 | 错误"
|
|
46
|
+
}
|
|
47
|
+
}, q = { i18n: { messages: X } }, Q = /* @__PURE__ */ S({
|
|
48
|
+
...q,
|
|
49
|
+
__name: "secondary-nav-item",
|
|
50
|
+
props: {
|
|
51
|
+
label: null,
|
|
52
|
+
value: null,
|
|
53
|
+
items: null,
|
|
54
|
+
isSubItem: { type: Boolean },
|
|
55
|
+
errorCounter: null
|
|
56
|
+
},
|
|
57
|
+
emits: ["click"],
|
|
58
|
+
setup(_, { emit: o }) {
|
|
59
|
+
const e = _, { tc: r } = O(), { activeItemValue: t, updateActiveItemValue: i, allowExpandableItemNavigation: y } = $(k), m = "b-secondary-nav-item__animation--content", u = T(!1), N = G("secondary-nav-sub-items"), g = T(null), v = p(() => {
|
|
60
|
+
var s;
|
|
61
|
+
return !!((s = e.items) != null && s.length);
|
|
62
|
+
}), d = p(() => t.value === e.value), I = p(() => v.value && !y.value), { contentHeight: b } = J(g, u), C = p(() => b.value ? { "max-height": b.value } : {}), h = p(() => ({
|
|
63
|
+
"b-secondary-nav-item__option--active": d.value,
|
|
64
|
+
"b-secondary-nav-item__option--expandable": v.value,
|
|
65
|
+
"b-secondary-nav-item__option--sub-item": e.isSubItem
|
|
66
|
+
})), x = (s) => {
|
|
67
|
+
o("click", s), i(e.value);
|
|
68
|
+
}, n = () => {
|
|
69
|
+
u.value = !u.value;
|
|
70
|
+
}, a = (s, c) => s.some(
|
|
71
|
+
(f) => f.value === c || (f.items ? a(f.items, c) : !1)
|
|
72
|
+
), l = (s) => s.some((c) => !!c.errorCounter || (c.items ? l(c.items) : !1));
|
|
73
|
+
return D(
|
|
74
|
+
[t, () => e.items],
|
|
75
|
+
([s]) => {
|
|
76
|
+
v.value && e.items && (a(e.items, s) || l(e.items)) && (u.value = !0);
|
|
77
|
+
},
|
|
78
|
+
{ immediate: !0, deep: !0 }
|
|
79
|
+
), { __sfc: !0, tc: r, activeItemValue: t, updateActiveItemValue: i, allowExpandableItemNavigation: y, CONTENT_TRANSITION_NAME: m, props: e, isOpen: u, subItemsId: N, subItemsRef: g, hasSubItems: v, isItemSelected: d, expandleItemIsToggleOnly: I, contentHeight: b, subItemsMaxHeight: C, conditionalClasses: h, emit: o, onClick: x, onToggleClick: n, hasActiveDescendant: a, hasDescendantErrors: l, BentoButton: U, BentoTag: A, BentoTypography: w, ChevronDownIcon: H, ChevronUpIcon: j, CrossCircleFillIcon: M };
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
var Y = function() {
|
|
83
|
+
var o = this, e = o._self._c, r = o._self._setupProxy;
|
|
84
|
+
return e("div", { staticClass: "b-secondary-nav-item" }, [e("div", { staticClass: "b-secondary-nav-item__wrapper" }, [e("button", { staticClass: "b-secondary-nav-item__option", class: r.conditionalClasses, attrs: { "aria-current": r.isItemSelected ? "page" : void 0, "aria-expanded": r.expandleItemIsToggleOnly ? `${r.isOpen}` : void 0, "aria-controls": r.expandleItemIsToggleOnly ? r.subItemsId : void 0 }, on: { click: function(t) {
|
|
85
|
+
r.expandleItemIsToggleOnly ? r.onToggleClick() : r.onClick(t);
|
|
86
|
+
} } }, [e(r.BentoTypography, { staticClass: "b-secondary-nav-item__title", attrs: { variant: "body", stronger: "" } }, [o._v(" " + o._s(o.label) + " ")]), o.errorCounter ? e(r.BentoTag, { staticClass: "b-secondary-nav-item__error-counter", attrs: { variant: "red" }, scopedSlots: o._u([{ key: "icon", fn: function() {
|
|
87
|
+
return [e(r.CrossCircleFillIcon, { attrs: { "aria-hidden": "true" } })];
|
|
88
|
+
}, proxy: !0 }], null, !1, 196511213) }, [e("span", [o._v(o._s(o.errorCounter))]), e("span", { staticClass: "b-secondary-nav-item__visually-hidden" }, [o._v(o._s(r.tc("errorCount", o.errorCounter)))])]) : o._e()], 1), r.hasSubItems ? e(r.BentoButton, { staticClass: "b-secondary-nav-item__toggle", attrs: { "aria-hidden": r.expandleItemIsToggleOnly, tabindex: r.expandleItemIsToggleOnly ? -1 : void 0, variant: "tertiary", "aria-label": r.isOpen ? `Collapse ${o.label}` : `Expand ${o.label}`, "aria-expanded": r.expandleItemIsToggleOnly ? void 0 : `${r.isOpen}`, "aria-controls": r.expandleItemIsToggleOnly ? void 0 : r.subItemsId }, on: { click: function(t) {
|
|
89
|
+
return t.stopPropagation(), r.onToggleClick.apply(null, arguments);
|
|
90
|
+
} }, scopedSlots: o._u([{ key: "iconLeft", fn: function() {
|
|
91
|
+
return [r.isOpen ? e(r.ChevronUpIcon, { staticClass: "b-secondary-nav-item__icon", attrs: { "aria-hidden": "true" } }) : e(r.ChevronDownIcon, { staticClass: "b-secondary-nav-item__icon", attrs: { "aria-hidden": "true" } })];
|
|
92
|
+
}, proxy: !0 }], null, !1, 3107710104) }) : o._e()], 1), e("Transition", { attrs: { name: r.CONTENT_TRANSITION_NAME } }, [r.hasSubItems && r.isOpen ? e("div", { style: r.subItemsMaxHeight, attrs: { id: r.subItemsId } }, [e("ul", { ref: "subItemsRef", staticClass: "b-secondary-nav-item__sub-items" }, o._l(o.items, function(t) {
|
|
93
|
+
return e("li", { key: t.value }, [e("secondary-nav-item", { attrs: { label: t.label, value: t.value, items: t.items, "error-counter": t.errorCounter, "is-sub-item": "" } })], 1);
|
|
94
|
+
}), 0)]) : o._e()])], 1);
|
|
95
|
+
}, K = [], W = /* @__PURE__ */ B(
|
|
96
|
+
Q,
|
|
97
|
+
Y,
|
|
98
|
+
K,
|
|
99
|
+
!1,
|
|
100
|
+
null,
|
|
101
|
+
"14334916"
|
|
102
|
+
);
|
|
103
|
+
const E = W.exports, Z = {}, ee = /* @__PURE__ */ S({
|
|
104
|
+
...Z,
|
|
105
|
+
__name: "secondary-nav-category",
|
|
106
|
+
props: {
|
|
107
|
+
label: null,
|
|
108
|
+
items: null
|
|
109
|
+
},
|
|
110
|
+
setup(_) {
|
|
111
|
+
return { __sfc: !0, BentoTypography: w, SecondaryNavItem: E };
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
var re = function() {
|
|
115
|
+
var o = this, e = o._self._c, r = o._self._setupProxy;
|
|
116
|
+
return e("section", { staticClass: "b-secondary-nav-category", attrs: { "aria-label": o.label } }, [e(r.BentoTypography, { staticClass: "b-secondary-nav-category__label", attrs: { el: "h1", variant: "caption", stronger: "" } }, [o._v(o._s(o.label))]), e("ul", { staticClass: "b-secondary-nav__list" }, o._l(o.items, function(t) {
|
|
117
|
+
return e("li", { key: t.value }, [e(r.SecondaryNavItem, { attrs: { label: t.label, value: t.value, items: t.items, "error-counter": t.errorCounter } })], 1);
|
|
118
|
+
}), 0)], 1);
|
|
119
|
+
}, oe = [], te = /* @__PURE__ */ B(
|
|
120
|
+
ee,
|
|
121
|
+
re,
|
|
122
|
+
oe,
|
|
123
|
+
!1,
|
|
124
|
+
null,
|
|
125
|
+
"777b2ce6"
|
|
126
|
+
);
|
|
127
|
+
const ne = te.exports, ae = {
|
|
128
|
+
"de-DE": {
|
|
129
|
+
errorCount: "Fehler | Fehler",
|
|
130
|
+
mobileDropdownAriaLabel: "Navigationsoptionen Dropdown-Menü"
|
|
131
|
+
},
|
|
132
|
+
"en-GB": {
|
|
133
|
+
errorCount: "error | errors",
|
|
134
|
+
mobileDropdownAriaLabel: "Navigation options drop-down"
|
|
135
|
+
},
|
|
136
|
+
"en-US": {
|
|
137
|
+
errorCount: "error | errors",
|
|
138
|
+
mobileDropdownAriaLabel: "Navigation options dropdown"
|
|
139
|
+
},
|
|
140
|
+
"es-ES": {
|
|
141
|
+
errorCount: "error | errores",
|
|
142
|
+
mobileDropdownAriaLabel: "Menú desplegable de opciones de navegación"
|
|
143
|
+
},
|
|
144
|
+
"es-MX": {
|
|
145
|
+
errorCount: "error | errores",
|
|
146
|
+
mobileDropdownAriaLabel: "Menú desplegable de opciones de navegación"
|
|
147
|
+
},
|
|
148
|
+
"fr-FR": {
|
|
149
|
+
errorCount: "erreur | erreurs",
|
|
150
|
+
mobileDropdownAriaLabel: "Menu déroulant des options de navigation"
|
|
151
|
+
},
|
|
152
|
+
"it-IT": {
|
|
153
|
+
errorCount: "errore | errori",
|
|
154
|
+
mobileDropdownAriaLabel: "Menu a tendina delle opzioni di navigazione"
|
|
155
|
+
},
|
|
156
|
+
"ja-JP": {
|
|
157
|
+
errorCount: "エラー | エラー",
|
|
158
|
+
mobileDropdownAriaLabel: "ナビゲーションオプションのドロップダウン"
|
|
159
|
+
},
|
|
160
|
+
"pt-BR": {
|
|
161
|
+
errorCount: "erro | erros",
|
|
162
|
+
mobileDropdownAriaLabel: "Menu suspenso de opções de navegação"
|
|
163
|
+
},
|
|
164
|
+
"zh-CN": {
|
|
165
|
+
errorCount: "错误 | 错误",
|
|
166
|
+
mobileDropdownAriaLabel: "导航选项下拉菜单"
|
|
167
|
+
}
|
|
168
|
+
}, se = {
|
|
169
|
+
i18n: { messages: ae }
|
|
170
|
+
}, le = /* @__PURE__ */ S({
|
|
171
|
+
...se,
|
|
172
|
+
__name: "secondary-nav",
|
|
173
|
+
props: {
|
|
174
|
+
items: null,
|
|
175
|
+
value: null,
|
|
176
|
+
allowExpandableItemNavigation: { type: Boolean }
|
|
177
|
+
},
|
|
178
|
+
emits: ["change"],
|
|
179
|
+
setup(_, { emit: o }) {
|
|
180
|
+
const e = _, { t: r, tc: t } = O(), i = P({
|
|
181
|
+
s: z
|
|
182
|
+
}), y = i.smallerOrEqual("s"), m = (n) => "items" in n && !("value" in n), u = (n, a = 0) => n.flatMap((l) => {
|
|
183
|
+
var c, f;
|
|
184
|
+
const s = {
|
|
185
|
+
label: l.label,
|
|
186
|
+
value: l.value,
|
|
187
|
+
data: { level: a, hasSubItems: !!((c = l.items) != null && c.length), errorCounter: l.errorCounter }
|
|
188
|
+
};
|
|
189
|
+
return (f = l.items) != null && f.length ? [s, ...u(l.items, a + 1)] : [s];
|
|
190
|
+
}), N = (n) => {
|
|
191
|
+
var a;
|
|
192
|
+
return !e.allowExpandableItemNavigation && ((a = n.data) == null ? void 0 : a.hasSubItems);
|
|
193
|
+
}, g = p(() => e.items.some((n) => m(n))), v = p(() => e.items.flatMap((n) => {
|
|
194
|
+
var a;
|
|
195
|
+
return m(n) ? [
|
|
196
|
+
{
|
|
197
|
+
label: n.label,
|
|
198
|
+
value: `category-${n.label}`,
|
|
199
|
+
items: u(n.items)
|
|
200
|
+
}
|
|
201
|
+
] : (a = n.items) != null && a.length ? u([n]) : [
|
|
202
|
+
{
|
|
203
|
+
label: n.label,
|
|
204
|
+
value: n.value,
|
|
205
|
+
data: { level: 0, errorCounter: n.errorCounter }
|
|
206
|
+
}
|
|
207
|
+
];
|
|
208
|
+
})), d = (n) => n.flatMap((a) => {
|
|
209
|
+
var l;
|
|
210
|
+
return [a, ...(l = a.items) != null && l.length ? d(a.items) : []];
|
|
211
|
+
}), I = (n) => {
|
|
212
|
+
var a;
|
|
213
|
+
return ((a = d(n).find((l) => {
|
|
214
|
+
var s;
|
|
215
|
+
return e.allowExpandableItemNavigation || !((s = l.items) != null && s.length);
|
|
216
|
+
})) == null ? void 0 : a.value) ?? "";
|
|
217
|
+
}, b = p(() => e.items.length ? I(
|
|
218
|
+
e.items.flatMap(
|
|
219
|
+
(n) => m(n) ? d(n.items) : d([n])
|
|
220
|
+
)
|
|
221
|
+
) : ""), C = T(e.value ?? b.value), h = (n) => {
|
|
222
|
+
C.value = n, o("change", n);
|
|
223
|
+
}, x = {
|
|
224
|
+
activeItemValue: R(C),
|
|
225
|
+
updateActiveItemValue: h,
|
|
226
|
+
allowExpandableItemNavigation: F(e, "allowExpandableItemNavigation")
|
|
227
|
+
};
|
|
228
|
+
return D(
|
|
229
|
+
() => e.value,
|
|
230
|
+
(n) => {
|
|
231
|
+
n !== void 0 && (C.value = n);
|
|
232
|
+
}
|
|
233
|
+
), L(k, x), { __sfc: !0, t: r, tc: t, breakpoints: i, isMobile: y, props: e, emit: o, isCategory: m, mapNestedItems: u, isMobileOptionDisabled: N, hasCategories: g, mobileDropdownItems: v, flattenNestedItems: d, findFirstSelectableNestedItemValue: I, activeItemValueFallback: b, activeItemValue: C, updateActiveItemValue: h, state: x, SecondaryNavItem: E, SecondaryNavCategory: ne, BentoDropdown: V, BentoTypography: w, BentoTag: A, CrossCircleFillIcon: M };
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
var ie = function() {
|
|
237
|
+
var o = this, e = o._self._c, r = o._self._setupProxy;
|
|
238
|
+
return e("nav", { staticClass: "b-secondary-nav" }, [r.isMobile ? e(r.BentoDropdown, { attrs: { "aria-label": r.t("mobileDropdownAriaLabel"), items: r.mobileDropdownItems, "static-categories": r.hasCategories, "model-value": r.activeItemValue, "is-option-disabled": r.isMobileOptionDisabled }, on: { "update:model-value": r.updateActiveItemValue }, scopedSlots: o._u([{ key: "display-value", fn: function({ label: t }) {
|
|
239
|
+
return [e(r.BentoTypography, { attrs: { el: "span" } }, [o._v(" " + o._s(t) + " ")])];
|
|
240
|
+
} }, { key: "default", fn: function({ label: t, data: i }) {
|
|
241
|
+
return [e(r.BentoTypography, { class: { "b-secondary-nav__option": !0, "b-secondary-nav__nested-option": !!(i != null && i.level) }, attrs: { el: "div" } }, [o._v(" " + o._s(t) + " "), i != null && i.errorCounter ? e(r.BentoTag, { staticClass: "b-secondary-nav__error-counter", attrs: { variant: "red" }, scopedSlots: o._u([{ key: "icon", fn: function() {
|
|
242
|
+
return [e(r.CrossCircleFillIcon, { attrs: { "aria-hidden": "true" } })];
|
|
243
|
+
}, proxy: !0 }], null, !0) }, [e("span", [o._v(o._s(i.errorCounter))]), e("span", { staticClass: "b-secondary-nav__visually-hidden" }, [o._v(o._s(r.tc("errorCount", i.errorCounter)))])]) : o._e()], 1)];
|
|
244
|
+
} }], null, !1, 2211008849) }) : e("ul", { staticClass: "b-secondary-nav__list" }, o._l(o.items, function(t) {
|
|
245
|
+
return e("li", { key: t.label }, ["items" in t && !("value" in t) ? e(r.SecondaryNavCategory, { attrs: { label: t.label, items: t.items } }) : e(r.SecondaryNavItem, { attrs: { label: t.label, value: t.value, items: t.items, "error-counter": t.errorCounter } })], 1);
|
|
246
|
+
}), 0)], 1);
|
|
247
|
+
}, ue = [], ce = /* @__PURE__ */ B(
|
|
248
|
+
le,
|
|
249
|
+
ie,
|
|
250
|
+
ue,
|
|
251
|
+
!1,
|
|
252
|
+
null,
|
|
253
|
+
"900dc964"
|
|
254
|
+
);
|
|
255
|
+
const Te = ce.exports;
|
|
256
|
+
export {
|
|
257
|
+
Te as s
|
|
258
|
+
};
|
|
259
|
+
//# sourceMappingURL=secondary-nav.C7lEDaoj.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secondary-nav.BvbT8LXa.js","sources":["../../src/components/secondary-nav/secondary-nav.keys.ts","../../src/components/secondary-nav/components/secondary-nav-item/secondary-nav-item.vue","../../src/components/secondary-nav/components/secondary-nav-category/secondary-nav-category.vue","../../src/components/secondary-nav/secondary-nav.vue"],"sourcesContent":["import { type InjectionKey } from 'vue';\nimport { type BentoSecondaryNavState } from './secondary-nav.types';\n\nexport const SECONDARY_NAV_STATE = Symbol('secondary nav state') as InjectionKey<BentoSecondaryNavState>;\n","<template>\n <div class=\"b-secondary-nav-item\">\n <div class=\"b-secondary-nav-item__wrapper\">\n <button\n class=\"b-secondary-nav-item__option\"\n :class=\"conditionalClasses\"\n :aria-current=\"isItemSelected ? 'page' : undefined\"\n :aria-expanded=\"expandleItemIsToggleOnly ? `${isOpen}` : undefined\"\n :aria-controls=\"expandleItemIsToggleOnly ? subItemsId : undefined\"\n @click=\"expandleItemIsToggleOnly ? onToggleClick() : onClick($event)\"\n >\n <bento-typography class=\"b-secondary-nav-item__title\" variant=\"body\" stronger>\n {{ label }}\n </bento-typography>\n <bento-tag v-if=\"errorCounter\" class=\"b-secondary-nav-item__error-counter\" variant=\"red\">\n <template #icon>\n <cross-circle-fill-icon aria-hidden=\"true\" />\n </template>\n <span>{{ errorCounter }}</span>\n <span class=\"b-secondary-nav-item__visually-hidden\">{{ tc('errorCount', errorCounter) }}</span>\n </bento-tag>\n </button>\n <bento-button\n v-if=\"hasSubItems\"\n :aria-hidden=\"expandleItemIsToggleOnly\"\n :tabindex=\"expandleItemIsToggleOnly ? -1 : undefined\"\n class=\"b-secondary-nav-item__toggle\"\n variant=\"tertiary\"\n :aria-label=\"isOpen ? `Collapse ${label}` : `Expand ${label}`\"\n :aria-expanded=\"!expandleItemIsToggleOnly ? `${isOpen}` : undefined\"\n :aria-controls=\"!expandleItemIsToggleOnly ? subItemsId : undefined\"\n @click.stop=\"onToggleClick\"\n >\n <template #iconLeft>\n <chevron-up-icon v-if=\"isOpen\" class=\"b-secondary-nav-item__icon\" aria-hidden=\"true\" />\n <chevron-down-icon v-else class=\"b-secondary-nav-item__icon\" aria-hidden=\"true\" />\n </template>\n </bento-button>\n </div>\n <Transition :name=\"CONTENT_TRANSITION_NAME\">\n <div v-if=\"hasSubItems && isOpen\" :id=\"subItemsId\" :style=\"subItemsMaxHeight\">\n <ul ref=\"subItemsRef\" class=\"b-secondary-nav-item__sub-items\">\n <li v-for=\"item in items\" :key=\"item.value\">\n <secondary-nav-item\n :label=\"item.label\"\n :value=\"item.value\"\n :items=\"item.items\"\n :error-counter=\"item.errorCounter\"\n is-sub-item\n />\n </li>\n </ul>\n </div>\n </Transition>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\n import { SECONDARY_NAV_STATE } from '../../secondary-nav.keys';\n import { BentoButton } from '@/components/button';\n import { BentoTag } from '@/components/tag';\n import { BentoTypography } from '@/components/typography';\n import ChevronDownIcon from '@adyen/ui-assets-icons-16/vue/chevron-down';\n import ChevronUpIcon from '@adyen/ui-assets-icons-16/vue/chevron-up';\n import CrossCircleFillIcon from '@adyen/ui-assets-icons-16/vue/cross-circle-fill';\n import { computed, inject, ref, watch } from 'vue';\n import { useI18n } from '@/utils/ts/i18n';\n import { generateUid } from '@/core/utils/ts';\n import { type BentoSecondaryNavItemsItem } from '../../secondary-nav.types';\n import { useExpandableContentHeight } from '@/composables/use-expandable-content-height/use-expandable-content-height';\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n const { tc } = useI18n<{ message: MessageSchema }>({ messages });\n const { activeItemValue, updateActiveItemValue, allowExpandableItemNavigation } = inject(SECONDARY_NAV_STATE);\n const CONTENT_TRANSITION_NAME = 'b-secondary-nav-item__animation--content';\n\n const props = defineProps({\n label: null,\n value: null,\n items: null,\n isSubItem: { type: Boolean },\n errorCounter: null\n});\n\n const isOpen = ref(false);\n const subItemsId = generateUid('secondary-nav-sub-items');\n const subItemsRef = ref<HTMLUListElement>(null);\n const hasSubItems = computed(() => !!props.items?.length);\n const isItemSelected = computed(() => activeItemValue.value === props.value);\n const expandleItemIsToggleOnly = computed(() => hasSubItems.value && !allowExpandableItemNavigation.value);\n const { contentHeight } = useExpandableContentHeight(subItemsRef, isOpen);\n const subItemsMaxHeight = computed(() => (contentHeight.value ? { 'max-height': contentHeight.value } : {}));\n\n const conditionalClasses = computed(() => ({\n 'b-secondary-nav-item__option--active': isItemSelected.value,\n 'b-secondary-nav-item__option--expandable': hasSubItems.value,\n 'b-secondary-nav-item__option--sub-item': props.isSubItem,\n }));\n\n const emit = defineEmits([\"click\"]);\n\n const onClick = (e: MouseEvent) => {\n emit('click', e);\n updateActiveItemValue(props.value);\n };\n\n const onToggleClick = () => {\n isOpen.value = !isOpen.value;\n };\n\n const hasActiveDescendant = (items: Array<BentoSecondaryNavItemsItem>, value: string): boolean => {\n return items.some(\n item => item.value === value || (item.items ? hasActiveDescendant(item.items, value) : false)\n );\n };\n\n const hasDescendantErrors = (items: Array<BentoSecondaryNavItemsItem>): boolean =>\n items.some(item => !!item.errorCounter || (item.items ? hasDescendantErrors(item.items) : false));\n\n watch(\n [activeItemValue, () => props.items],\n ([activeValue]) => {\n if (hasSubItems.value && props.items) {\n if (hasActiveDescendant(props.items, activeValue) || hasDescendantErrors(props.items)) {\n isOpen.value = true;\n }\n }\n },\n { immediate: true, deep: true }\n );\n</script>\n\n<script lang=\"ts\">\n /**\n * This component shouldn't be used directly. It is internally used by {@see BentoSecondaryNav}\n */\n export default { i18n: { messages } };\n</script>\n\n<style lang=\"scss\" scoped src=\"./secondary-nav-item.scss\" />\n","<template>\n <section class=\"b-secondary-nav-category\" :aria-label=\"label\">\n <bento-typography el=\"h1\" class=\"b-secondary-nav-category__label\" variant=\"caption\" stronger>{{\n label\n }}</bento-typography>\n <ul class=\"b-secondary-nav__list\">\n <li v-for=\"item in items\" :key=\"item.value\">\n <secondary-nav-item\n :label=\"item.label\"\n :value=\"item.value\"\n :items=\"item.items\"\n :error-counter=\"item.errorCounter\"\n />\n </li>\n </ul>\n </section>\n</template>\n\n<script lang=\"ts\" setup>\n import { BentoTypography } from '@/components/typography';\n import { SecondaryNavItem } from '../secondary-nav-item';\n import { type BentoSecondaryNavItemsItem } from '../../secondary-nav.types';\n\n defineProps({\n label: null,\n items: null\n});\n</script>\n\n<script lang=\"ts\">\n /**\n * This component shouldn't be used directly. It is internally used by {@see BentoSecondaryNav}\n */\n export default {};\n</script>\n\n<style lang=\"scss\" scoped src=\"./secondary-nav-category.scss\" />\n","<template>\n <nav class=\"b-secondary-nav\">\n <bento-dropdown\n v-if=\"isMobile\"\n :aria-label=\"t('mobileDropdownAriaLabel')\"\n :items=\"mobileDropdownItems\"\n :static-categories=\"hasCategories\"\n :model-value=\"activeItemValue\"\n :is-option-disabled=\"isMobileOptionDisabled\"\n @update:model-value=\"updateActiveItemValue\"\n >\n <template #display-value=\"{ label }\">\n <bento-typography el=\"span\">\n {{ label }}\n </bento-typography>\n </template>\n <template #default=\"{ label, data }\">\n <bento-typography\n el=\"div\"\n :class=\"{ 'b-secondary-nav__option': true, 'b-secondary-nav__nested-option': !!data?.level }\"\n >\n {{ label }}\n <bento-tag v-if=\"data?.errorCounter\" class=\"b-secondary-nav__error-counter\" variant=\"red\">\n <template #icon>\n <cross-circle-fill-icon aria-hidden=\"true\" />\n </template>\n <span>{{ data.errorCounter }}</span>\n <span class=\"b-secondary-nav__visually-hidden\">{{ tc('errorCount', data.errorCounter) }}</span>\n </bento-tag>\n </bento-typography>\n </template>\n </bento-dropdown>\n <ul v-else class=\"b-secondary-nav__list\">\n <li v-for=\"item in items\" :key=\"item.label\">\n <secondary-nav-category\n v-if=\"'items' in item && !('value' in item)\"\n :label=\"item.label\"\n :items=\"item.items\"\n />\n <secondary-nav-item\n v-else\n :label=\"item.label\"\n :value=\"item.value\"\n :items=\"item.items\"\n :error-counter=\"item.errorCounter\"\n />\n </li>\n </ul>\n </nav>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, provide, readonly, ref, toRef, watch } from 'vue';\n import { SecondaryNavItem } from './components/secondary-nav-item';\n import { SecondaryNavCategory } from './components/secondary-nav-category';\n import { SECONDARY_NAV_STATE } from './secondary-nav.keys';\n import {\n type BentoSecondaryNavItems,\n type BentoSecondaryNavItemsCategory,\n type BentoSecondaryNavItemsItem,\n type BentoSecondaryNavState,\n } from './secondary-nav.types';\n import { BentoDropdown } from '@/components/dropdown';\n import { BentoTypography } from '@/components/typography';\n import { BentoTag } from '@/components/tag';\n import CrossCircleFillIcon from '@adyen/ui-assets-icons-16/vue/cross-circle-fill';\n import { useBreakpoints } from '@vueuse/core';\n import { useI18n } from '@/utils/ts/i18n';\n import { type BentoListboxOptionItem, type BentoListboxOptions } from '@/types/listbox';\n import { BMediaQuerySMax } from '@adyen/bento-design-tokens/dist/js/bento/es6';\n\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n const { t, tc } = useI18n<{ message: MessageSchema }>({ messages });\n\n const breakpoints = useBreakpoints({\n s: BMediaQuerySMax,\n });\n\n const isMobile = breakpoints.smallerOrEqual('s');\n const props = defineProps({\n items: null,\n value: null,\n allowExpandableItemNavigation: { type: Boolean }\n});\n\n const emit = defineEmits([\"change\"]);\n\n const isCategory = (item: BentoSecondaryNavItems[number]): item is BentoSecondaryNavItemsCategory =>\n 'items' in item && !('value' in item);\n\n const mapNestedItems = (items: Array<BentoSecondaryNavItemsItem>, level = 0): BentoListboxOptions =>\n items.flatMap((item): BentoListboxOptions => {\n const currentItem: BentoListboxOptionItem = {\n label: item.label,\n value: item.value,\n data: { level, hasSubItems: !!item.items?.length, errorCounter: item.errorCounter },\n };\n\n if (item.items?.length) {\n return [currentItem, ...mapNestedItems(item.items, level + 1)];\n }\n\n return [currentItem];\n });\n\n const isMobileOptionDisabled = (option: BentoListboxOptionItem): boolean =>\n !props.allowExpandableItemNavigation && (option.data as { hasSubItems?: boolean })?.hasSubItems;\n\n const hasCategories = computed(() => props.items.some(item => isCategory(item)));\n const mobileDropdownItems = computed<BentoListboxOptions>(() => {\n return props.items.flatMap(item => {\n if (isCategory(item)) {\n return [\n {\n label: item.label,\n value: `category-${item.label}`,\n items: mapNestedItems(item.items),\n } satisfies BentoListboxOptionItem,\n ];\n }\n\n if (item.items?.length) {\n return mapNestedItems([item]);\n }\n\n return [\n {\n label: item.label,\n value: item.value,\n data: { level: 0, errorCounter: item.errorCounter },\n } satisfies BentoListboxOptionItem,\n ];\n });\n });\n\n const flattenNestedItems = (items: Array<BentoSecondaryNavItemsItem>): Array<BentoSecondaryNavItemsItem> =>\n items.flatMap(item => [item, ...(item.items?.length ? flattenNestedItems(item.items) : [])]);\n\n const findFirstSelectableNestedItemValue = (items: Array<BentoSecondaryNavItemsItem>): string =>\n flattenNestedItems(items).find(item => props.allowExpandableItemNavigation || !item.items?.length)?.value ?? '';\n\n const activeItemValueFallback = computed(() => {\n if (!props.items.length) {\n return '';\n }\n\n return findFirstSelectableNestedItemValue(\n props.items.flatMap(item =>\n isCategory(item) ? flattenNestedItems(item.items) : flattenNestedItems([item])\n )\n );\n });\n\n const activeItemValue = ref(props.value ?? activeItemValueFallback.value);\n const updateActiveItemValue = (value: string) => {\n activeItemValue.value = value;\n emit('change', value);\n };\n\n // The component's state is inject on `secondary-nav-item` to determine the\n // current active item and to change its value\n const state: BentoSecondaryNavState = {\n activeItemValue: readonly(activeItemValue),\n updateActiveItemValue,\n allowExpandableItemNavigation: toRef(props, 'allowExpandableItemNavigation'),\n };\n\n watch(\n () => props.value,\n value => {\n if (value !== undefined) {\n activeItemValue.value = value;\n }\n }\n );\n\n provide(SECONDARY_NAV_STATE, state);\n</script>\n\n<script lang=\"ts\">\n /**\n * Secondary Nav offers users a structured way to access information.\n * It also provides a clear hierarchy for users to understand and navigate through various information.\n *\n * @example\n * import { BentoSecondaryNav } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoSecondaryNav },\n * template: `\n * <bento-secondary-nav :value=\"value\" :items=\"items\" />\n * `,\n * setup() {\n * const value = ref(2) // Active item value\n * const items: BentoSecondaryNavItemInfo[] = [\n * { label: 'Option 1', value: 1 },\n * { label: 'Option 2', value: 2 },\n * ];\n * return { items, value };\n * }\n * }\n */\n export default {\n i18n: { messages },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./secondary-nav.scss\" />\n"],"names":["SECONDARY_NAV_STATE","__default__$2","messages$1","tc","useI18n","activeItemValue","updateActiveItemValue","allowExpandableItemNavigation","inject","CONTENT_TRANSITION_NAME","isOpen","ref","subItemsId","generateUid","subItemsRef","hasSubItems","computed","_a","props","isItemSelected","expandleItemIsToggleOnly","contentHeight","useExpandableContentHeight","subItemsMaxHeight","conditionalClasses","onClick","e","emit","onToggleClick","hasActiveDescendant","items","value","item","hasDescendantErrors","watch","activeValue","__default__$1","__default__","messages","t","breakpoints","useBreakpoints","BMediaQuerySMax","isMobile","isCategory","mapNestedItems","level","currentItem","_b","isMobileOptionDisabled","option","hasCategories","mobileDropdownItems","flattenNestedItems","findFirstSelectableNestedItemValue","activeItemValueFallback","state","readonly","toRef","provide"],"mappings":";;;;;;;;;;;;;;;AAGO,MAAAA,IAAA,uBAAA,qBAAA;;;;GCuIHC,IAAA,EAAA,MAAA,EAAA,UAAAC,EAAA,EAAA;;;;;;;;;;;;iBAhE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,IAC2E;AAG/E,WAAAgB;AAAA,MAAA,MAAAhB,EAAA;AAAA,MACgB,CAAAa,MAAA;AAER,QAAAA,MAAA,WACI1B,EAAA,QAAA0B;AAAA,MACJ;AAAA,IACJ,GAGJ4B,EAAA3D,GAAAwD,CAAA;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"secondary-nav.C7lEDaoj.js","sources":["../../src/components/secondary-nav/secondary-nav.keys.ts","../../src/components/secondary-nav/components/secondary-nav-item/secondary-nav-item.vue","../../src/components/secondary-nav/components/secondary-nav-category/secondary-nav-category.vue","../../src/components/secondary-nav/secondary-nav.vue"],"sourcesContent":["import { type InjectionKey } from 'vue';\nimport { type BentoSecondaryNavState } from './secondary-nav.types';\n\nexport const SECONDARY_NAV_STATE = Symbol('secondary nav state') as InjectionKey<BentoSecondaryNavState>;\n","<template>\n <div class=\"b-secondary-nav-item\">\n <div class=\"b-secondary-nav-item__wrapper\">\n <button\n class=\"b-secondary-nav-item__option\"\n :class=\"conditionalClasses\"\n :aria-current=\"isItemSelected ? 'page' : undefined\"\n :aria-expanded=\"expandleItemIsToggleOnly ? `${isOpen}` : undefined\"\n :aria-controls=\"expandleItemIsToggleOnly ? subItemsId : undefined\"\n @click=\"expandleItemIsToggleOnly ? onToggleClick() : onClick($event)\"\n >\n <bento-typography class=\"b-secondary-nav-item__title\" variant=\"body\" stronger>\n {{ label }}\n </bento-typography>\n <bento-tag v-if=\"errorCounter\" class=\"b-secondary-nav-item__error-counter\" variant=\"red\">\n <template #icon>\n <cross-circle-fill-icon aria-hidden=\"true\" />\n </template>\n <span>{{ errorCounter }}</span>\n <span class=\"b-secondary-nav-item__visually-hidden\">{{ tc('errorCount', errorCounter) }}</span>\n </bento-tag>\n </button>\n <bento-button\n v-if=\"hasSubItems\"\n :aria-hidden=\"expandleItemIsToggleOnly\"\n :tabindex=\"expandleItemIsToggleOnly ? -1 : undefined\"\n class=\"b-secondary-nav-item__toggle\"\n variant=\"tertiary\"\n :aria-label=\"isOpen ? `Collapse ${label}` : `Expand ${label}`\"\n :aria-expanded=\"!expandleItemIsToggleOnly ? `${isOpen}` : undefined\"\n :aria-controls=\"!expandleItemIsToggleOnly ? subItemsId : undefined\"\n @click.stop=\"onToggleClick\"\n >\n <template #iconLeft>\n <chevron-up-icon v-if=\"isOpen\" class=\"b-secondary-nav-item__icon\" aria-hidden=\"true\" />\n <chevron-down-icon v-else class=\"b-secondary-nav-item__icon\" aria-hidden=\"true\" />\n </template>\n </bento-button>\n </div>\n <Transition :name=\"CONTENT_TRANSITION_NAME\">\n <div v-if=\"hasSubItems && isOpen\" :id=\"subItemsId\" :style=\"subItemsMaxHeight\">\n <ul ref=\"subItemsRef\" class=\"b-secondary-nav-item__sub-items\">\n <li v-for=\"item in items\" :key=\"item.value\">\n <secondary-nav-item\n :label=\"item.label\"\n :value=\"item.value\"\n :items=\"item.items\"\n :error-counter=\"item.errorCounter\"\n is-sub-item\n />\n </li>\n </ul>\n </div>\n </Transition>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\n import { SECONDARY_NAV_STATE } from '../../secondary-nav.keys';\n import { BentoButton } from '@/components/button';\n import { BentoTag } from '@/components/tag';\n import { BentoTypography } from '@/components/typography';\n import ChevronDownIcon from '@adyen/ui-assets-icons-16/vue/chevron-down';\n import ChevronUpIcon from '@adyen/ui-assets-icons-16/vue/chevron-up';\n import CrossCircleFillIcon from '@adyen/ui-assets-icons-16/vue/cross-circle-fill';\n import { computed, inject, ref, watch } from 'vue';\n import { useI18n } from '@/utils/ts/i18n';\n import { generateUid } from '@/core/utils/ts';\n import { type BentoSecondaryNavItemsItem } from '../../secondary-nav.types';\n import { useExpandableContentHeight } from '@/composables/use-expandable-content-height/use-expandable-content-height';\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n const { tc } = useI18n<{ message: MessageSchema }>({ messages });\n const { activeItemValue, updateActiveItemValue, allowExpandableItemNavigation } = inject(SECONDARY_NAV_STATE);\n const CONTENT_TRANSITION_NAME = 'b-secondary-nav-item__animation--content';\n\n const props = defineProps({\n label: null,\n value: null,\n items: null,\n isSubItem: { type: Boolean },\n errorCounter: null\n});\n\n const isOpen = ref(false);\n const subItemsId = generateUid('secondary-nav-sub-items');\n const subItemsRef = ref<HTMLUListElement>(null);\n const hasSubItems = computed(() => !!props.items?.length);\n const isItemSelected = computed(() => activeItemValue.value === props.value);\n const expandleItemIsToggleOnly = computed(() => hasSubItems.value && !allowExpandableItemNavigation.value);\n const { contentHeight } = useExpandableContentHeight(subItemsRef, isOpen);\n const subItemsMaxHeight = computed(() => (contentHeight.value ? { 'max-height': contentHeight.value } : {}));\n\n const conditionalClasses = computed(() => ({\n 'b-secondary-nav-item__option--active': isItemSelected.value,\n 'b-secondary-nav-item__option--expandable': hasSubItems.value,\n 'b-secondary-nav-item__option--sub-item': props.isSubItem,\n }));\n\n const emit = defineEmits([\"click\"]);\n\n const onClick = (e: MouseEvent) => {\n emit('click', e);\n updateActiveItemValue(props.value);\n };\n\n const onToggleClick = () => {\n isOpen.value = !isOpen.value;\n };\n\n const hasActiveDescendant = (items: Array<BentoSecondaryNavItemsItem>, value: string): boolean => {\n return items.some(\n item => item.value === value || (item.items ? hasActiveDescendant(item.items, value) : false)\n );\n };\n\n const hasDescendantErrors = (items: Array<BentoSecondaryNavItemsItem>): boolean =>\n items.some(item => !!item.errorCounter || (item.items ? hasDescendantErrors(item.items) : false));\n\n watch(\n [activeItemValue, () => props.items],\n ([activeValue]) => {\n if (hasSubItems.value && props.items) {\n if (hasActiveDescendant(props.items, activeValue) || hasDescendantErrors(props.items)) {\n isOpen.value = true;\n }\n }\n },\n { immediate: true, deep: true }\n );\n</script>\n\n<script lang=\"ts\">\n /**\n * This component shouldn't be used directly. It is internally used by {@see BentoSecondaryNav}\n */\n export default { i18n: { messages } };\n</script>\n\n<style lang=\"scss\" scoped src=\"./secondary-nav-item.scss\" />\n","<template>\n <section class=\"b-secondary-nav-category\" :aria-label=\"label\">\n <bento-typography el=\"h1\" class=\"b-secondary-nav-category__label\" variant=\"caption\" stronger>{{\n label\n }}</bento-typography>\n <ul class=\"b-secondary-nav__list\">\n <li v-for=\"item in items\" :key=\"item.value\">\n <secondary-nav-item\n :label=\"item.label\"\n :value=\"item.value\"\n :items=\"item.items\"\n :error-counter=\"item.errorCounter\"\n />\n </li>\n </ul>\n </section>\n</template>\n\n<script lang=\"ts\" setup>\n import { BentoTypography } from '@/components/typography';\n import { SecondaryNavItem } from '../secondary-nav-item';\n import { type BentoSecondaryNavItemsItem } from '../../secondary-nav.types';\n\n defineProps({\n label: null,\n items: null\n});\n</script>\n\n<script lang=\"ts\">\n /**\n * This component shouldn't be used directly. It is internally used by {@see BentoSecondaryNav}\n */\n export default {};\n</script>\n\n<style lang=\"scss\" scoped src=\"./secondary-nav-category.scss\" />\n","<template>\n <nav class=\"b-secondary-nav\">\n <bento-dropdown\n v-if=\"isMobile\"\n :aria-label=\"t('mobileDropdownAriaLabel')\"\n :items=\"mobileDropdownItems\"\n :static-categories=\"hasCategories\"\n :model-value=\"activeItemValue\"\n :is-option-disabled=\"isMobileOptionDisabled\"\n @update:model-value=\"updateActiveItemValue\"\n >\n <template #display-value=\"{ label }\">\n <bento-typography el=\"span\">\n {{ label }}\n </bento-typography>\n </template>\n <template #default=\"{ label, data }\">\n <bento-typography\n el=\"div\"\n :class=\"{ 'b-secondary-nav__option': true, 'b-secondary-nav__nested-option': !!data?.level }\"\n >\n {{ label }}\n <bento-tag v-if=\"data?.errorCounter\" class=\"b-secondary-nav__error-counter\" variant=\"red\">\n <template #icon>\n <cross-circle-fill-icon aria-hidden=\"true\" />\n </template>\n <span>{{ data.errorCounter }}</span>\n <span class=\"b-secondary-nav__visually-hidden\">{{ tc('errorCount', data.errorCounter) }}</span>\n </bento-tag>\n </bento-typography>\n </template>\n </bento-dropdown>\n <ul v-else class=\"b-secondary-nav__list\">\n <li v-for=\"item in items\" :key=\"item.label\">\n <secondary-nav-category\n v-if=\"'items' in item && !('value' in item)\"\n :label=\"item.label\"\n :items=\"item.items\"\n />\n <secondary-nav-item\n v-else\n :label=\"item.label\"\n :value=\"item.value\"\n :items=\"item.items\"\n :error-counter=\"item.errorCounter\"\n />\n </li>\n </ul>\n </nav>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, provide, readonly, ref, toRef, watch } from 'vue';\n import { SecondaryNavItem } from './components/secondary-nav-item';\n import { SecondaryNavCategory } from './components/secondary-nav-category';\n import { SECONDARY_NAV_STATE } from './secondary-nav.keys';\n import {\n type BentoSecondaryNavItems,\n type BentoSecondaryNavItemsCategory,\n type BentoSecondaryNavItemsItem,\n type BentoSecondaryNavState,\n } from './secondary-nav.types';\n import { BentoDropdown } from '@/components/dropdown';\n import { BentoTypography } from '@/components/typography';\n import { BentoTag } from '@/components/tag';\n import CrossCircleFillIcon from '@adyen/ui-assets-icons-16/vue/cross-circle-fill';\n import { useBreakpoints } from '@vueuse/core';\n import { useI18n } from '@/utils/ts/i18n';\n import { type BentoListboxOptionItem, type BentoListboxOptions } from '@/types/listbox';\n import { BMediaQuerySMax } from '@adyen/bento-design-tokens/dist/js/bento/es6';\n\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n const { t, tc } = useI18n<{ message: MessageSchema }>({ messages });\n\n const breakpoints = useBreakpoints({\n s: BMediaQuerySMax,\n });\n\n const isMobile = breakpoints.smallerOrEqual('s');\n const props = defineProps({\n items: null,\n value: null,\n allowExpandableItemNavigation: { type: Boolean }\n});\n\n const emit = defineEmits([\"change\"]);\n\n const isCategory = (item: BentoSecondaryNavItems[number]): item is BentoSecondaryNavItemsCategory =>\n 'items' in item && !('value' in item);\n\n const mapNestedItems = (items: Array<BentoSecondaryNavItemsItem>, level = 0): BentoListboxOptions =>\n items.flatMap((item): BentoListboxOptions => {\n const currentItem: BentoListboxOptionItem = {\n label: item.label,\n value: item.value,\n data: { level, hasSubItems: !!item.items?.length, errorCounter: item.errorCounter },\n };\n\n if (item.items?.length) {\n return [currentItem, ...mapNestedItems(item.items, level + 1)];\n }\n\n return [currentItem];\n });\n\n const isMobileOptionDisabled = (option: BentoListboxOptionItem): boolean =>\n !props.allowExpandableItemNavigation && (option.data as { hasSubItems?: boolean })?.hasSubItems;\n\n const hasCategories = computed(() => props.items.some(item => isCategory(item)));\n const mobileDropdownItems = computed<BentoListboxOptions>(() => {\n return props.items.flatMap(item => {\n if (isCategory(item)) {\n return [\n {\n label: item.label,\n value: `category-${item.label}`,\n items: mapNestedItems(item.items),\n } satisfies BentoListboxOptionItem,\n ];\n }\n\n if (item.items?.length) {\n return mapNestedItems([item]);\n }\n\n return [\n {\n label: item.label,\n value: item.value,\n data: { level: 0, errorCounter: item.errorCounter },\n } satisfies BentoListboxOptionItem,\n ];\n });\n });\n\n const flattenNestedItems = (items: Array<BentoSecondaryNavItemsItem>): Array<BentoSecondaryNavItemsItem> =>\n items.flatMap(item => [item, ...(item.items?.length ? flattenNestedItems(item.items) : [])]);\n\n const findFirstSelectableNestedItemValue = (items: Array<BentoSecondaryNavItemsItem>): string =>\n flattenNestedItems(items).find(item => props.allowExpandableItemNavigation || !item.items?.length)?.value ?? '';\n\n const activeItemValueFallback = computed(() => {\n if (!props.items.length) {\n return '';\n }\n\n return findFirstSelectableNestedItemValue(\n props.items.flatMap(item =>\n isCategory(item) ? flattenNestedItems(item.items) : flattenNestedItems([item])\n )\n );\n });\n\n const activeItemValue = ref(props.value ?? activeItemValueFallback.value);\n const updateActiveItemValue = (value: string) => {\n activeItemValue.value = value;\n emit('change', value);\n };\n\n // The component's state is inject on `secondary-nav-item` to determine the\n // current active item and to change its value\n const state: BentoSecondaryNavState = {\n activeItemValue: readonly(activeItemValue),\n updateActiveItemValue,\n allowExpandableItemNavigation: toRef(props, 'allowExpandableItemNavigation'),\n };\n\n watch(\n () => props.value,\n value => {\n if (value !== undefined) {\n activeItemValue.value = value;\n }\n }\n );\n\n provide(SECONDARY_NAV_STATE, state);\n</script>\n\n<script lang=\"ts\">\n /**\n * Secondary Nav offers users a structured way to access information.\n * It also provides a clear hierarchy for users to understand and navigate through various information.\n *\n * @example\n * import { BentoSecondaryNav } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoSecondaryNav },\n * template: `\n * <bento-secondary-nav :value=\"value\" :items=\"items\" />\n * `,\n * setup() {\n * const value = ref(2) // Active item value\n * const items: BentoSecondaryNavItemInfo[] = [\n * { label: 'Option 1', value: 1 },\n * { label: 'Option 2', value: 2 },\n * ];\n * return { items, value };\n * }\n * }\n */\n export default {\n i18n: { messages },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./secondary-nav.scss\" />\n"],"names":["SECONDARY_NAV_STATE","__default__$2","messages$1","tc","useI18n","activeItemValue","updateActiveItemValue","allowExpandableItemNavigation","inject","CONTENT_TRANSITION_NAME","isOpen","ref","subItemsId","generateUid","subItemsRef","hasSubItems","computed","_a","props","isItemSelected","expandleItemIsToggleOnly","contentHeight","useExpandableContentHeight","subItemsMaxHeight","conditionalClasses","onClick","e","emit","onToggleClick","hasActiveDescendant","items","value","item","hasDescendantErrors","watch","activeValue","__default__$1","__default__","messages","t","breakpoints","useBreakpoints","BMediaQuerySMax","isMobile","isCategory","mapNestedItems","level","currentItem","_b","isMobileOptionDisabled","option","hasCategories","mobileDropdownItems","flattenNestedItems","findFirstSelectableNestedItemValue","activeItemValueFallback","state","readonly","toRef","provide"],"mappings":";;;;;;;;;;;;;;;AAGO,MAAAA,IAAA,uBAAA,qBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GCuIHC,IAAA,EAAA,MAAA,EAAA,UAAAC,EAAA,EAAA;;;;;;;;;;;;iBAhEA,EAAA,IAAAC,EAAA,IAAAC,EAAA,GACA,EAAA,iBAAAC,GAAA,uBAAAC,GAAA,+BAAAC,EAAA,IAAAC,EAAAR,CAAA,GACAS,IAAA,4CAUAC,IAAAC,EAAA,EAAA,GACAC,IAAAC,EAAA,yBAAA,GACAC,IAAAH,EAAA,IAAA,GACAI,IAAAC,EAAA,MAA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,11 +2,11 @@ import { defineComponent as O, useSlots as D, computed as n, inject as F, ref as
|
|
|
2
2
|
import { d as Y } from "./index.CJYgd0QI.js";
|
|
3
3
|
import { a as Q, B as U } from "./es6.Cu3DYUPA.js";
|
|
4
4
|
import { B as H } from "./typography.C8lPlsbD.js";
|
|
5
|
-
import {
|
|
6
|
-
import { u as K } from "./aria-label.CaUURpnB.js";
|
|
5
|
+
import { u as J } from "./aria-label.CaUURpnB.js";
|
|
7
6
|
import { g as $ } from "./generate-uid.NJ8tVoha.js";
|
|
8
|
-
import { u as
|
|
9
|
-
import { a as
|
|
7
|
+
import { u as K } from "./use-has-slot.C9lQZ6nz.js";
|
|
8
|
+
import { a as X } from "./radio-input.CLlYadKI.js";
|
|
9
|
+
import { C as Z } from "./checkbox-input.08E9BNeF.js";
|
|
10
10
|
import { n as N } from "./_plugin-vue2_normalizer.CeySl7Fu.js";
|
|
11
11
|
import { u as ee } from "./form-field.D_2g7vaP.js";
|
|
12
12
|
import { G as te } from "./grid-layout.1aIiz2N_.js";
|
|
@@ -79,7 +79,7 @@ const q = /* @__PURE__ */ Symbol("selection card radio input injection key"), le
|
|
|
79
79
|
},
|
|
80
80
|
emits: ["input", "update:model-value"],
|
|
81
81
|
setup(u, { emit: e }) {
|
|
82
|
-
const t = u, o = D(), a =
|
|
82
|
+
const t = u, o = D(), a = K(o), C = $("selection-card-input-id"), s = $("selection-card-description"), d = n(
|
|
83
83
|
() => t.modelValue
|
|
84
84
|
), E = n(
|
|
85
85
|
() => t.modelValue
|
|
@@ -97,7 +97,7 @@ const q = /* @__PURE__ */ Symbol("selection card radio input injection key"), le
|
|
|
97
97
|
"b-selection-card__checkbox-container-text--center-aligned": m.value
|
|
98
98
|
})), S = n(() => ({
|
|
99
99
|
"b-selection-card__slot--with-icon": a("icon")
|
|
100
|
-
})), y =
|
|
100
|
+
})), y = J({
|
|
101
101
|
ariaLabel: t.title,
|
|
102
102
|
label: t.value
|
|
103
103
|
}), l = n(() => Array.isArray(t.modelValue)), R = n(() => c.value ? t.value === t.modelValue : l.value ? t.modelValue.some((i) => i === t.value) : t.modelValue), c = F(q, h(!1)), m = n(() => !t.subtitle && !t.description), p = h(null), b = h(null), r = h(null), v = (i) => {
|
|
@@ -122,7 +122,7 @@ const q = /* @__PURE__ */ Symbol("selection card radio input injection key"), le
|
|
|
122
122
|
}, M = (i) => {
|
|
123
123
|
!t.disabled && !t.readonly && (e("update:model-value", i), e("input", i));
|
|
124
124
|
};
|
|
125
|
-
return { __sfc: !0, props: t, emit: e, slots: o, hasSlot: a, inputId: C, descriptionId: s, computedRadioInputModelValue: d, computedCheckboxInputModelValue: E, conditionalClasses: V, containerConditionalClasses: x, checkboxContainerConditionalClasses: _, checkboxContainerTextConditionalClasses: g, slotConditionalClasses: S, ariaLabel: y, isCheckboxGroup: l, isChecked: R, isRadioInput: c, isTitleOnly: m, inputRef: p, slotRef: b, dynamicSlotRef: r, handleCardClick: v, toggleInput: w, onChange: M, BentoTypography: H, CheckboxInput:
|
|
125
|
+
return { __sfc: !0, props: t, emit: e, slots: o, hasSlot: a, inputId: C, descriptionId: s, computedRadioInputModelValue: d, computedCheckboxInputModelValue: E, conditionalClasses: V, containerConditionalClasses: x, checkboxContainerConditionalClasses: _, checkboxContainerTextConditionalClasses: g, slotConditionalClasses: S, ariaLabel: y, isCheckboxGroup: l, isChecked: R, isRadioInput: c, isTitleOnly: m, inputRef: p, slotRef: b, dynamicSlotRef: r, handleCardClick: v, toggleInput: w, onChange: M, BentoTypography: H, CheckboxInput: Z, RadioInput: X };
|
|
126
126
|
}
|
|
127
127
|
});
|
|
128
128
|
var re = function() {
|
|
@@ -237,4 +237,4 @@ export {
|
|
|
237
237
|
B as a,
|
|
238
238
|
Ve as s
|
|
239
239
|
};
|
|
240
|
-
//# sourceMappingURL=selection-card-group.
|
|
240
|
+
//# sourceMappingURL=selection-card-group.CiFW4AZR.js.map
|