@gcsa/console-vue 0.1.2 → 0.1.4
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/components/GcsaCascader.vue.js +8 -7
- package/dist/components/GcsaCascader.vue.js.map +1 -1
- package/dist/components/GcsaPopover.vue.d.ts +3 -0
- package/dist/components/GcsaPopover.vue.js +61 -59
- package/dist/components/GcsaPopover.vue.js.map +1 -1
- package/dist/components/GcsaPortal.vue.js +30 -16
- package/dist/components/GcsaPortal.vue.js.map +1 -1
- package/dist/components/GcsaTransfer.vue.js +117 -79
- package/dist/components/GcsaTransfer.vue.js.map +1 -1
- package/dist/components/GcsaUpload.vue.js +1 -1
- package/dist/components/GcsaUpload.vue.js.map +1 -1
- package/dist/icons/iconNames.d.ts +2 -2
- package/dist/icons/iconNames.js +1 -0
- package/dist/icons/iconNames.js.map +1 -1
- package/dist/icons/registry.d.ts +1 -1
- package/dist/icons/registry.js +38 -35
- package/dist/icons/registry.js.map +1 -1
- package/dist/icons/svg/result-empty.svg.js +12 -2
- package/dist/icons/svg/result-empty.svg.js.map +1 -1
- package/dist/icons/svg/upload.svg.js +10 -0
- package/dist/icons/svg/upload.svg.js.map +1 -0
- package/dist/icons/svg/users.svg.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +56 -55
- package/dist/style.css +223 -140
- package/dist/types/componentProps.d.ts +2 -0
- package/package.json +3 -3
- package/src/components/GcsaCascader.vue +1 -1
- package/src/components/GcsaPopover.vue +11 -13
- package/src/components/GcsaPortal.vue +26 -2
- package/src/components/GcsaTransfer.vue +125 -13
- package/src/components/GcsaUpload.vue +1 -1
- package/src/icons/iconNames.ts +1 -0
- package/src/icons/registry.ts +3 -1
- package/src/icons/svg/result-empty.svg +11 -1
- package/src/icons/svg/upload.svg +5 -0
- package/src/index.ts +1 -1
- package/src/types/componentProps.ts +2 -0
|
@@ -19,11 +19,11 @@ const $ = ["disabled", "data-invalid"], E = ["data-placeholder"], j = { class: "
|
|
|
19
19
|
},
|
|
20
20
|
emits: ["update:modelValue", "change"],
|
|
21
21
|
setup(d, { emit: C }) {
|
|
22
|
-
const p = S(), s = d,
|
|
22
|
+
const p = S(), s = d, w = m(() => s.placeholder ?? p.value.selectPlaceholder), v = C, o = z([...s.modelValue]);
|
|
23
23
|
D(() => s.modelValue, (a) => {
|
|
24
24
|
o.value = [...a ?? []];
|
|
25
25
|
}, { deep: !0 });
|
|
26
|
-
const
|
|
26
|
+
const B = m(() => {
|
|
27
27
|
var t;
|
|
28
28
|
const a = [s.options];
|
|
29
29
|
let c = s.options;
|
|
@@ -33,7 +33,7 @@ const $ = ["disabled", "data-invalid"], E = ["data-placeholder"], j = { class: "
|
|
|
33
33
|
a.push(e.children), c = e.children;
|
|
34
34
|
}
|
|
35
35
|
return a;
|
|
36
|
-
}),
|
|
36
|
+
}), h = m(() => {
|
|
37
37
|
const a = [];
|
|
38
38
|
let c = s.options;
|
|
39
39
|
for (const t of s.modelValue ?? []) {
|
|
@@ -47,12 +47,13 @@ const $ = ["disabled", "data-invalid"], E = ["data-placeholder"], j = { class: "
|
|
|
47
47
|
var l;
|
|
48
48
|
if (a.disabled) return;
|
|
49
49
|
const t = [...o.value.slice(0, c), a.value];
|
|
50
|
-
o.value = t, (!((l = a.children) != null && l.length) || s.changeOnSelect) && (
|
|
50
|
+
o.value = t, (!((l = a.children) != null && l.length) || s.changeOnSelect) && (v("update:modelValue", t), v("change", t));
|
|
51
51
|
}
|
|
52
52
|
return (a, c) => (n(), _(P, {
|
|
53
53
|
arrow: !1,
|
|
54
54
|
portalled: d.portalled,
|
|
55
55
|
gutter: 6,
|
|
56
|
+
"fit-viewport": !0,
|
|
56
57
|
class: "gcsa-cascader-popover"
|
|
57
58
|
}, {
|
|
58
59
|
trigger: g(() => [
|
|
@@ -64,8 +65,8 @@ const $ = ["disabled", "data-invalid"], E = ["data-placeholder"], j = { class: "
|
|
|
64
65
|
}, [
|
|
65
66
|
u("span", {
|
|
66
67
|
class: "gcsa-cascader__value",
|
|
67
|
-
"data-placeholder": !
|
|
68
|
-
}, f(
|
|
68
|
+
"data-placeholder": !h.value || void 0
|
|
69
|
+
}, f(h.value || w.value), 9, E),
|
|
69
70
|
N(V, {
|
|
70
71
|
name: "chevronDown",
|
|
71
72
|
size: "sm",
|
|
@@ -75,7 +76,7 @@ const $ = ["disabled", "data-invalid"], E = ["data-placeholder"], j = { class: "
|
|
|
75
76
|
]),
|
|
76
77
|
default: g(() => [
|
|
77
78
|
u("div", j, [
|
|
78
|
-
(n(!0), r(b, null, y(
|
|
79
|
+
(n(!0), r(b, null, y(B.value, (t, l) => (n(), r("div", {
|
|
79
80
|
key: l,
|
|
80
81
|
class: "gcsa-cascader__column",
|
|
81
82
|
role: "menu"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GcsaCascader.vue.js","sources":["../../src/components/GcsaCascader.vue"],"sourcesContent":["<template>\n <GcsaPopover :arrow=\"false\" :portalled=\"portalled\" :gutter=\"6\" class=\"gcsa-cascader-popover\">\n <template #trigger>\n <button type=\"button\" class=\"gcsa-cascader__trigger gcsa-focus-ring\" :disabled=\"disabled\" :data-invalid=\"invalid || undefined\">\n <span class=\"gcsa-cascader__value\" :data-placeholder=\"!displayLabel || undefined\">{{ displayLabel || resolvedPlaceholder }}</span>\n <GcsaIcon name=\"chevronDown\" size=\"sm\" aria-hidden=\"true\" />\n </button>\n </template>\n <div class=\"gcsa-cascader__panel\">\n <div v-for=\"(column, depth) in columns\" :key=\"depth\" class=\"gcsa-cascader__column\" role=\"menu\">\n <button\n v-for=\"option in column\"\n :key=\"option.value\"\n type=\"button\"\n class=\"gcsa-cascader__option gcsa-focus-ring\"\n :class=\"{ 'gcsa-cascader__option--active': activePath[depth] === option.value }\"\n :disabled=\"option.disabled\"\n role=\"menuitem\"\n @click=\"selectOption(option, depth)\"\n >\n <span>{{ option.label }}</span>\n <GcsaIcon v-if=\"option.children?.length\" name=\"chevronDown\" size=\"sm\" class=\"gcsa-cascader__arrow\" aria-hidden=\"true\" />\n </button>\n <span v-if=\"!column.length\" class=\"gcsa-cascader__empty\">{{ messages.noOptions }}</span>\n </div>\n </div>\n </GcsaPopover>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, ref, watch } from 'vue';\nimport type { GcsaCascaderOption } from '@gcsa/console-core';\nimport type { GcsaCascaderProps } from '../types/componentProps';\nimport GcsaIcon from './GcsaIcon.vue';\nimport GcsaPopover from './GcsaPopover.vue';\nimport { useGcsaLocaleMessages } from '../composables/useGcsaLocale';\n\ndefineOptions({ name: 'GcsaCascader' });\n\nconst messages = useGcsaLocaleMessages();\n\nconst props = withDefaults(defineProps<GcsaCascaderProps>(), { modelValue: () => [], disabled: false, invalid: false, changeOnSelect: false, portalled: true });\n\nconst resolvedPlaceholder = computed(() => props.placeholder ?? messages.value.selectPlaceholder);\n\nconst emit = defineEmits<{ 'update:modelValue': [value: string[]]; change: [value: string[]] }>();\nconst activePath = ref([...props.modelValue]);\n\nwatch(() => props.modelValue, value => { activePath.value = [...(value ?? [])]; }, { deep: true });\n\nconst columns = computed(() => {\n const result: GcsaCascaderOption[][] = [props.options];\n let current = props.options;\n for (const value of activePath.value) {\n const selected = current.find(option => option.value === value);\n if (!selected?.children?.length) break;\n result.push(selected.children);\n current = selected.children;\n }\n return result;\n});\n\nconst displayLabel = computed(() => {\n const labels: string[] = [];\n let current = props.options;\n for (const value of props.modelValue ?? []) {\n const selected = current.find(option => option.value === value);\n if (!selected) break;\n labels.push(selected.label);\n current = selected.children ?? [];\n }\n return labels.join(' / ');\n});\n\nfunction selectOption(option: GcsaCascaderOption, depth: number) {\n if (option.disabled) return;\n const next = [...activePath.value.slice(0, depth), option.value];\n activePath.value = next;\n if (!option.children?.length || props.changeOnSelect) {\n emit('update:modelValue', next);\n emit('change', next);\n }\n}\n</script>\n"],"names":["messages","useGcsaLocaleMessages","props","__props","resolvedPlaceholder","computed","emit","__emit","activePath","ref","watch","value","columns","result","current","selected","option","_a","displayLabel","labels","selectOption","depth","next","_createBlock","GcsaPopover","_createElementVNode","_toDisplayString","_hoisted_2","_createVNode","GcsaIcon","_hoisted_3","_openBlock","_createElementBlock","_Fragment","_renderList","column","_normalizeClass","$event","_hoisted_5","_unref"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuCA,UAAMA,IAAWC,EAAA,GAEXC,IAAQC,GAERC,IAAsBC,EAAS,MAAMH,EAAM,eAAeF,EAAS,MAAM,iBAAiB,GAE1FM,IAAOC,GACPC,IAAaC,EAAI,CAAC,GAAGP,EAAM,UAAU,CAAC;AAE5C,IAAAQ,EAAM,MAAMR,EAAM,YAAY,CAAAS,MAAS;AAAE,MAAAH,EAAW,QAAQ,CAAC,GAAIG,KAAS,CAAA,CAAG;AAAA,IAAG,GAAG,EAAE,MAAM,IAAM;AAEjG,UAAMC,IAAUP,EAAS,MAAM;;AAC7B,YAAMQ,IAAiC,CAACX,EAAM,OAAO;AACrD,UAAIY,IAAUZ,EAAM;AACpB,iBAAWS,KAASH,EAAW,OAAO;AACpC,cAAMO,IAAWD,EAAQ,KAAK,CAAAE,MAAUA,EAAO,UAAUL,CAAK;AAC9D,YAAI,GAACM,IAAAF,KAAA,gBAAAA,EAAU,aAAV,QAAAE,EAAoB,QAAQ;AACjC,QAAAJ,EAAO,KAAKE,EAAS,QAAQ,GAC7BD,IAAUC,EAAS;AAAA,MACrB;AACA,aAAOF;AAAA,IACT,CAAC,GAEKK,IAAeb,EAAS,MAAM;AAClC,YAAMc,IAAmB,CAAA;AACzB,UAAIL,IAAUZ,EAAM;AACpB,iBAAWS,KAAST,EAAM,cAAc,CAAA,GAAI;AAC1C,cAAMa,IAAWD,EAAQ,KAAK,CAAAE,MAAUA,EAAO,UAAUL,CAAK;AAC9D,YAAI,CAACI,EAAU;AACf,QAAAI,EAAO,KAAKJ,EAAS,KAAK,GAC1BD,IAAUC,EAAS,YAAY,CAAA;AAAA,MACjC;AACA,aAAOI,EAAO,KAAK,KAAK;AAAA,IAC1B,CAAC;AAED,aAASC,EAAaJ,GAA4BK,GAAe;;AAC/D,UAAIL,EAAO,SAAU;AACrB,YAAMM,IAAO,CAAC,GAAGd,EAAW,MAAM,MAAM,GAAGa,CAAK,GAAGL,EAAO,KAAK;AAC/D,MAAAR,EAAW,QAAQc,IACf,GAACL,IAAAD,EAAO,aAAP,QAAAC,EAAiB,WAAUf,EAAM,oBACpCI,EAAK,qBAAqBgB,CAAI,GAC9BhB,EAAK,UAAUgB,CAAI;AAAA,IAEvB;2BAjFEC,EAyBcC,GAAA;AAAA,MAzBA,OAAO;AAAA,MAAQ,WAAWrB,EAAA;AAAA,MAAY,QAAQ;AAAA,
|
|
1
|
+
{"version":3,"file":"GcsaCascader.vue.js","sources":["../../src/components/GcsaCascader.vue"],"sourcesContent":["<template>\n <GcsaPopover :arrow=\"false\" :portalled=\"portalled\" :gutter=\"6\" :fit-viewport=\"true\" class=\"gcsa-cascader-popover\">\n <template #trigger>\n <button type=\"button\" class=\"gcsa-cascader__trigger gcsa-focus-ring\" :disabled=\"disabled\" :data-invalid=\"invalid || undefined\">\n <span class=\"gcsa-cascader__value\" :data-placeholder=\"!displayLabel || undefined\">{{ displayLabel || resolvedPlaceholder }}</span>\n <GcsaIcon name=\"chevronDown\" size=\"sm\" aria-hidden=\"true\" />\n </button>\n </template>\n <div class=\"gcsa-cascader__panel\">\n <div v-for=\"(column, depth) in columns\" :key=\"depth\" class=\"gcsa-cascader__column\" role=\"menu\">\n <button\n v-for=\"option in column\"\n :key=\"option.value\"\n type=\"button\"\n class=\"gcsa-cascader__option gcsa-focus-ring\"\n :class=\"{ 'gcsa-cascader__option--active': activePath[depth] === option.value }\"\n :disabled=\"option.disabled\"\n role=\"menuitem\"\n @click=\"selectOption(option, depth)\"\n >\n <span>{{ option.label }}</span>\n <GcsaIcon v-if=\"option.children?.length\" name=\"chevronDown\" size=\"sm\" class=\"gcsa-cascader__arrow\" aria-hidden=\"true\" />\n </button>\n <span v-if=\"!column.length\" class=\"gcsa-cascader__empty\">{{ messages.noOptions }}</span>\n </div>\n </div>\n </GcsaPopover>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, ref, watch } from 'vue';\nimport type { GcsaCascaderOption } from '@gcsa/console-core';\nimport type { GcsaCascaderProps } from '../types/componentProps';\nimport GcsaIcon from './GcsaIcon.vue';\nimport GcsaPopover from './GcsaPopover.vue';\nimport { useGcsaLocaleMessages } from '../composables/useGcsaLocale';\n\ndefineOptions({ name: 'GcsaCascader' });\n\nconst messages = useGcsaLocaleMessages();\n\nconst props = withDefaults(defineProps<GcsaCascaderProps>(), { modelValue: () => [], disabled: false, invalid: false, changeOnSelect: false, portalled: true });\n\nconst resolvedPlaceholder = computed(() => props.placeholder ?? messages.value.selectPlaceholder);\n\nconst emit = defineEmits<{ 'update:modelValue': [value: string[]]; change: [value: string[]] }>();\nconst activePath = ref([...props.modelValue]);\n\nwatch(() => props.modelValue, value => { activePath.value = [...(value ?? [])]; }, { deep: true });\n\nconst columns = computed(() => {\n const result: GcsaCascaderOption[][] = [props.options];\n let current = props.options;\n for (const value of activePath.value) {\n const selected = current.find(option => option.value === value);\n if (!selected?.children?.length) break;\n result.push(selected.children);\n current = selected.children;\n }\n return result;\n});\n\nconst displayLabel = computed(() => {\n const labels: string[] = [];\n let current = props.options;\n for (const value of props.modelValue ?? []) {\n const selected = current.find(option => option.value === value);\n if (!selected) break;\n labels.push(selected.label);\n current = selected.children ?? [];\n }\n return labels.join(' / ');\n});\n\nfunction selectOption(option: GcsaCascaderOption, depth: number) {\n if (option.disabled) return;\n const next = [...activePath.value.slice(0, depth), option.value];\n activePath.value = next;\n if (!option.children?.length || props.changeOnSelect) {\n emit('update:modelValue', next);\n emit('change', next);\n }\n}\n</script>\n"],"names":["messages","useGcsaLocaleMessages","props","__props","resolvedPlaceholder","computed","emit","__emit","activePath","ref","watch","value","columns","result","current","selected","option","_a","displayLabel","labels","selectOption","depth","next","_createBlock","GcsaPopover","_createElementVNode","_toDisplayString","_hoisted_2","_createVNode","GcsaIcon","_hoisted_3","_openBlock","_createElementBlock","_Fragment","_renderList","column","_normalizeClass","$event","_hoisted_5","_unref"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuCA,UAAMA,IAAWC,EAAA,GAEXC,IAAQC,GAERC,IAAsBC,EAAS,MAAMH,EAAM,eAAeF,EAAS,MAAM,iBAAiB,GAE1FM,IAAOC,GACPC,IAAaC,EAAI,CAAC,GAAGP,EAAM,UAAU,CAAC;AAE5C,IAAAQ,EAAM,MAAMR,EAAM,YAAY,CAAAS,MAAS;AAAE,MAAAH,EAAW,QAAQ,CAAC,GAAIG,KAAS,CAAA,CAAG;AAAA,IAAG,GAAG,EAAE,MAAM,IAAM;AAEjG,UAAMC,IAAUP,EAAS,MAAM;;AAC7B,YAAMQ,IAAiC,CAACX,EAAM,OAAO;AACrD,UAAIY,IAAUZ,EAAM;AACpB,iBAAWS,KAASH,EAAW,OAAO;AACpC,cAAMO,IAAWD,EAAQ,KAAK,CAAAE,MAAUA,EAAO,UAAUL,CAAK;AAC9D,YAAI,GAACM,IAAAF,KAAA,gBAAAA,EAAU,aAAV,QAAAE,EAAoB,QAAQ;AACjC,QAAAJ,EAAO,KAAKE,EAAS,QAAQ,GAC7BD,IAAUC,EAAS;AAAA,MACrB;AACA,aAAOF;AAAA,IACT,CAAC,GAEKK,IAAeb,EAAS,MAAM;AAClC,YAAMc,IAAmB,CAAA;AACzB,UAAIL,IAAUZ,EAAM;AACpB,iBAAWS,KAAST,EAAM,cAAc,CAAA,GAAI;AAC1C,cAAMa,IAAWD,EAAQ,KAAK,CAAAE,MAAUA,EAAO,UAAUL,CAAK;AAC9D,YAAI,CAACI,EAAU;AACf,QAAAI,EAAO,KAAKJ,EAAS,KAAK,GAC1BD,IAAUC,EAAS,YAAY,CAAA;AAAA,MACjC;AACA,aAAOI,EAAO,KAAK,KAAK;AAAA,IAC1B,CAAC;AAED,aAASC,EAAaJ,GAA4BK,GAAe;;AAC/D,UAAIL,EAAO,SAAU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ML,EAAO,MAAA,CAAK,CAAA;AAAA,gBAC5E,UAAUA,EAAO;AAAA,gBAClB,MAAK;AAAA,gBACJ,SAAK,CAAAqB,MAAEjB,EAAaJ,GAAQK,CAAK;AAAA,cAAA;gBAElCI,EAA+B,QAAA,MAAAC,EAAtBV,EAAO,KAAK,GAAA,CAAA;AAAA,iBACLC,IAAAD,EAAO,aAAP,QAAAC,EAAiB,eAAjCM,EAAwHM,GAAA;AAAA;kBAA/E,MAAK;AAAA,kBAAc,MAAK;AAAA,kBAAK,OAAM;AAAA,kBAAuB,eAAY;AAAA,gBAAA;;;YAEpGM,EAAO,sBAApBJ,KAAAC,EAAwF,QAAxFM,GAAwFZ,EAA5Ba,EAAAvC,CAAA,EAAS,SAAS,GAAA,CAAA;AAAA;;;;;;;"}
|
|
@@ -2,8 +2,10 @@ import { GcsaPopoverProps } from '../types/componentProps';
|
|
|
2
2
|
declare function __VLS_template(): any;
|
|
3
3
|
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
4
4
|
declare const __VLS_component: import('vue').DefineComponent<GcsaPopoverProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
5
|
+
"update:open": (open: boolean) => any;
|
|
5
6
|
"open-change": (open: boolean) => any;
|
|
6
7
|
}, string, import('vue').PublicProps, Readonly<GcsaPopoverProps> & Readonly<{
|
|
8
|
+
"onUpdate:open"?: ((open: boolean) => any) | undefined;
|
|
7
9
|
"onOpen-change"?: ((open: boolean) => any) | undefined;
|
|
8
10
|
}>, {
|
|
9
11
|
size: import('..').GcsaPopoverSize;
|
|
@@ -11,6 +13,7 @@ declare const __VLS_component: import('vue').DefineComponent<GcsaPopoverProps, {
|
|
|
11
13
|
placement: import('..').GcsaPopoverPlacement;
|
|
12
14
|
arrow: boolean;
|
|
13
15
|
gutter: number;
|
|
16
|
+
fitViewport: boolean;
|
|
14
17
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
15
18
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
16
19
|
export default _default;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Popover as
|
|
3
|
-
import { toCssLength as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { useGcsaLocaleMessages as
|
|
7
|
-
import { useGcsaPopupZIndex as
|
|
8
|
-
const
|
|
1
|
+
import { defineComponent as I, computed as s, useSlots as L, ref as $, watch as M, openBlock as n, createBlock as i, unref as a, withCtx as t, renderSlot as f, createVNode as p, createTextVNode as C, toDisplayString as B, normalizeStyle as k, normalizeClass as j, createCommentVNode as g, createElementVNode as A, createElementBlock as E } from "vue";
|
|
2
|
+
import { Popover as l } from "@ark-ui/vue/popover";
|
|
3
|
+
import { toCssLength as m, createGcsaPopupPositioning as O } from "@gcsa/console-core";
|
|
4
|
+
import Z from "./GcsaButton.vue.js";
|
|
5
|
+
import D from "./GcsaPortal.vue.js";
|
|
6
|
+
import { useGcsaLocaleMessages as F } from "../composables/useGcsaLocale.js";
|
|
7
|
+
import { useGcsaPopupZIndex as R } from "../composables/useGcsaPopupZIndex.js";
|
|
8
|
+
const U = { class: "gcsa-popover__body" }, q = {
|
|
9
9
|
key: 1,
|
|
10
10
|
class: "gcsa-popover__footer"
|
|
11
|
-
},
|
|
11
|
+
}, oe = /* @__PURE__ */ I({
|
|
12
12
|
name: "GcsaPopover",
|
|
13
13
|
__name: "GcsaPopover",
|
|
14
14
|
props: {
|
|
@@ -19,105 +19,107 @@ const J = { class: "gcsa-popover__body" }, K = {
|
|
|
19
19
|
portalled: { type: Boolean, default: !0 },
|
|
20
20
|
gutter: { default: 8 },
|
|
21
21
|
open: { type: Boolean },
|
|
22
|
+
fitViewport: { type: Boolean, default: !1 },
|
|
22
23
|
size: { default: "default" },
|
|
23
24
|
width: {},
|
|
24
25
|
minWidth: {},
|
|
25
26
|
maxWidth: {},
|
|
26
27
|
contentClassName: {}
|
|
27
28
|
},
|
|
28
|
-
emits: ["open-change"],
|
|
29
|
+
emits: ["open-change", "update:open"],
|
|
29
30
|
setup(r, { emit: W }) {
|
|
30
|
-
const o = r,
|
|
31
|
-
|
|
31
|
+
const o = r, v = W, P = F(), { zIndex: c, onOpenChange: S } = R(), z = s(() => o.triggerLabel ?? P.value.open), h = L(), N = s(() => !!h.trigger), _ = s(() => !!h.footer), d = $(o.open ?? !1);
|
|
32
|
+
M(
|
|
32
33
|
() => o.open,
|
|
33
34
|
(e) => {
|
|
34
|
-
e !== void 0 && (
|
|
35
|
+
e !== void 0 && (d.value = e);
|
|
35
36
|
}
|
|
36
37
|
);
|
|
37
|
-
const
|
|
38
|
-
() =>
|
|
39
|
-
),
|
|
38
|
+
const T = s(
|
|
39
|
+
() => c.value == null ? void 0 : { zIndex: c.value }
|
|
40
|
+
), V = s(() => {
|
|
40
41
|
const e = {};
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
return
|
|
44
|
-
}),
|
|
42
|
+
c.value != null && (e.zIndex = c.value);
|
|
43
|
+
const u = m(o.width), y = m(o.minWidth), w = m(o.maxWidth);
|
|
44
|
+
return u && (e.width = u), y && (e.minWidth = y), w && (e.maxWidth = w), Object.keys(e).length ? e : void 0;
|
|
45
|
+
}), b = s(
|
|
45
46
|
() => [
|
|
46
47
|
"gcsa-popover",
|
|
47
48
|
"gcsa-ui-surface",
|
|
48
49
|
o.size === "lg" ? "gcsa-popover--lg" : void 0,
|
|
49
|
-
|
|
50
|
+
_.value ? "gcsa-popover--with-footer" : void 0,
|
|
50
51
|
o.contentClassName
|
|
51
52
|
].filter(Boolean).join(" ")
|
|
52
|
-
),
|
|
53
|
-
() =>
|
|
53
|
+
), x = s(
|
|
54
|
+
() => O({
|
|
54
55
|
placement: o.placement,
|
|
55
|
-
gutter: o.gutter
|
|
56
|
+
gutter: o.gutter,
|
|
57
|
+
fitViewport: o.fitViewport
|
|
56
58
|
})
|
|
57
59
|
);
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
+
function G(e) {
|
|
61
|
+
d.value = e, v("update:open", e), v("open-change", e), S(e);
|
|
60
62
|
}
|
|
61
|
-
return (e,
|
|
62
|
-
open:
|
|
63
|
-
positioning:
|
|
64
|
-
|
|
63
|
+
return (e, u) => (n(), i(a(l).Root, {
|
|
64
|
+
open: d.value,
|
|
65
|
+
positioning: x.value,
|
|
66
|
+
"onUpdate:open": G
|
|
65
67
|
}, {
|
|
66
|
-
default:
|
|
67
|
-
N.value ? (
|
|
68
|
+
default: t(() => [
|
|
69
|
+
N.value ? (n(), i(a(l).Trigger, {
|
|
68
70
|
key: 0,
|
|
69
71
|
"as-child": ""
|
|
70
72
|
}, {
|
|
71
|
-
default:
|
|
73
|
+
default: t(() => [
|
|
72
74
|
f(e.$slots, "trigger")
|
|
73
75
|
]),
|
|
74
76
|
_: 3
|
|
75
|
-
})) : (
|
|
76
|
-
default:
|
|
77
|
-
p(
|
|
78
|
-
default:
|
|
79
|
-
|
|
77
|
+
})) : (n(), i(a(l).Trigger, { key: 1 }, {
|
|
78
|
+
default: t(() => [
|
|
79
|
+
p(Z, { variant: "secondary" }, {
|
|
80
|
+
default: t(() => [
|
|
81
|
+
C(B(z.value), 1)
|
|
80
82
|
]),
|
|
81
83
|
_: 1
|
|
82
84
|
})
|
|
83
85
|
]),
|
|
84
86
|
_: 1
|
|
85
87
|
})),
|
|
86
|
-
p(
|
|
87
|
-
default:
|
|
88
|
-
p(l
|
|
89
|
-
style:
|
|
88
|
+
p(D, { portalled: r.portalled }, {
|
|
89
|
+
default: t(() => [
|
|
90
|
+
p(a(l).Positioner, {
|
|
91
|
+
style: k(T.value)
|
|
90
92
|
}, {
|
|
91
|
-
default:
|
|
92
|
-
p(l
|
|
93
|
-
class:
|
|
94
|
-
style:
|
|
93
|
+
default: t(() => [
|
|
94
|
+
p(a(l).Content, {
|
|
95
|
+
class: j(b.value),
|
|
96
|
+
style: k(V.value)
|
|
95
97
|
}, {
|
|
96
|
-
default:
|
|
97
|
-
r.title ? (
|
|
98
|
+
default: t(() => [
|
|
99
|
+
r.title ? (n(), i(a(l).Title, {
|
|
98
100
|
key: 0,
|
|
99
101
|
class: "gcsa-popover__title"
|
|
100
102
|
}, {
|
|
101
|
-
default:
|
|
102
|
-
|
|
103
|
+
default: t(() => [
|
|
104
|
+
C(B(r.title), 1)
|
|
103
105
|
]),
|
|
104
106
|
_: 1
|
|
105
|
-
})) :
|
|
106
|
-
|
|
107
|
+
})) : g("", !0),
|
|
108
|
+
A("div", U, [
|
|
107
109
|
f(e.$slots, "default")
|
|
108
110
|
]),
|
|
109
|
-
|
|
111
|
+
_.value ? (n(), E("div", q, [
|
|
110
112
|
f(e.$slots, "footer")
|
|
111
|
-
])) :
|
|
112
|
-
r.arrow ? (
|
|
113
|
+
])) : g("", !0),
|
|
114
|
+
r.arrow ? (n(), i(a(l).Arrow, {
|
|
113
115
|
key: 2,
|
|
114
116
|
class: "gcsa-popover__arrow"
|
|
115
117
|
}, {
|
|
116
|
-
default:
|
|
117
|
-
p(l
|
|
118
|
+
default: t(() => [
|
|
119
|
+
p(a(l).ArrowTip, { class: "gcsa-popover__arrow-tip" })
|
|
118
120
|
]),
|
|
119
121
|
_: 1
|
|
120
|
-
})) :
|
|
122
|
+
})) : g("", !0)
|
|
121
123
|
]),
|
|
122
124
|
_: 3
|
|
123
125
|
}, 8, ["class", "style"])
|
|
@@ -133,6 +135,6 @@ const J = { class: "gcsa-popover__body" }, K = {
|
|
|
133
135
|
}
|
|
134
136
|
});
|
|
135
137
|
export {
|
|
136
|
-
|
|
138
|
+
oe as default
|
|
137
139
|
};
|
|
138
140
|
//# sourceMappingURL=GcsaPopover.vue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GcsaPopover.vue.js","sources":["../../src/components/GcsaPopover.vue"],"sourcesContent":["<template>\n <Popover.Root\n :open=\"
|
|
1
|
+
{"version":3,"file":"GcsaPopover.vue.js","sources":["../../src/components/GcsaPopover.vue"],"sourcesContent":["<template>\n <Popover.Root\n :open=\"open\"\n :positioning=\"positioningOptions\"\n @update:open=\"handleOpenChange\"\n >\n <Popover.Trigger v-if=\"hasTriggerSlot\" as-child>\n <slot name=\"trigger\" />\n </Popover.Trigger>\n <Popover.Trigger v-else>\n <GcsaButton variant=\"secondary\">{{ resolvedTriggerLabel }}</GcsaButton>\n </Popover.Trigger>\n <GcsaPortal :portalled=\"portalled\">\n <Popover.Positioner :style=\"positionerStyle\">\n <Popover.Content :class=\"contentClassNames\" :style=\"contentStyle\">\n <Popover.Title v-if=\"title\" class=\"gcsa-popover__title\">{{ title }}</Popover.Title>\n <div class=\"gcsa-popover__body\">\n <slot />\n </div>\n <div v-if=\"hasFooterSlot\" class=\"gcsa-popover__footer\">\n <slot name=\"footer\" />\n </div>\n <Popover.Arrow v-if=\"arrow\" class=\"gcsa-popover__arrow\">\n <Popover.ArrowTip class=\"gcsa-popover__arrow-tip\" />\n </Popover.Arrow>\n </Popover.Content>\n </Popover.Positioner>\n </GcsaPortal>\n </Popover.Root>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, ref, useSlots, watch } from 'vue';\nimport { Popover } from '@ark-ui/vue/popover';\nimport { createGcsaPopupPositioning, toCssLength } from '@gcsa/console-core';\nimport type { GcsaPopoverProps } from '../types/componentProps';\nimport GcsaButton from './GcsaButton.vue';\nimport GcsaPortal from './GcsaPortal.vue';\nimport { useGcsaLocaleMessages } from '../composables/useGcsaLocale';\nimport { useGcsaPopupZIndex } from '../composables/useGcsaPopupZIndex';\n\ndefineOptions({ name: 'GcsaPopover' });\n\nconst props = withDefaults(\n defineProps<GcsaPopoverProps>(),\n {\n placement: 'bottom',\n arrow: true,\n portalled: true,\n gutter: 8,\n size: 'default',\n fitViewport: false\n }\n);\n\nconst emit = defineEmits<{\n 'open-change': [open: boolean];\n 'update:open': [open: boolean];\n}>();\n\nconst messages = useGcsaLocaleMessages();\nconst { zIndex: popupZIndex, onOpenChange: onPopupOpenChange } = useGcsaPopupZIndex();\nconst resolvedTriggerLabel = computed(() => props.triggerLabel ?? messages.value.open);\nconst slots = useSlots();\nconst hasTriggerSlot = computed(() => Boolean(slots.trigger));\nconst hasFooterSlot = computed(() => Boolean(slots.footer));\n\nconst open = ref(props.open ?? false);\n\nwatch(\n () => props.open,\n (next) => {\n if (next !== undefined) open.value = next;\n }\n);\n\nconst positionerStyle = computed(() =>\n popupZIndex.value == null ? undefined : { zIndex: popupZIndex.value }\n);\n\nconst contentStyle = computed(() => {\n const style: Record<string, string | number> = {};\n if (popupZIndex.value != null) style.zIndex = popupZIndex.value;\n const resolvedWidth = toCssLength(props.width);\n const resolvedMinWidth = toCssLength(props.minWidth);\n const resolvedMaxWidth = toCssLength(props.maxWidth);\n if (resolvedWidth) style.width = resolvedWidth;\n if (resolvedMinWidth) style.minWidth = resolvedMinWidth;\n if (resolvedMaxWidth) style.maxWidth = resolvedMaxWidth;\n return Object.keys(style).length ? style : undefined;\n});\n\nconst contentClassNames = computed(() =>\n [\n 'gcsa-popover',\n 'gcsa-ui-surface',\n props.size === 'lg' ? 'gcsa-popover--lg' : undefined,\n hasFooterSlot.value ? 'gcsa-popover--with-footer' : undefined,\n props.contentClassName\n ]\n .filter(Boolean)\n .join(' ')\n);\n\nconst positioningOptions = computed(() =>\n createGcsaPopupPositioning({\n placement: props.placement,\n gutter: props.gutter,\n fitViewport: props.fitViewport\n })\n);\n\nfunction handleOpenChange(nextOpen: boolean) {\n open.value = nextOpen;\n emit('update:open', nextOpen);\n emit('open-change', nextOpen);\n onPopupOpenChange(nextOpen);\n}\n</script>\n"],"names":["props","__props","emit","__emit","messages","useGcsaLocaleMessages","popupZIndex","onPopupOpenChange","useGcsaPopupZIndex","resolvedTriggerLabel","computed","slots","useSlots","hasTriggerSlot","hasFooterSlot","open","ref","watch","next","positionerStyle","contentStyle","style","resolvedWidth","toCssLength","resolvedMinWidth","resolvedMaxWidth","contentClassNames","positioningOptions","createGcsaPopupPositioning","handleOpenChange","nextOpen","_createBlock","_unref","Popover","_renderSlot","_ctx","_createVNode","GcsaButton","GcsaPortal","_createElementVNode","_hoisted_1","_openBlock","_createElementBlock","_hoisted_2"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,UAAMA,IAAQC,GAYRC,IAAOC,GAKPC,IAAWC,EAAA,GACX,EAAE,QAAQC,GAAa,cAAcC,EAAA,IAAsBC,EAAA,GAC3DC,IAAuBC,EAAS,MAAMV,EAAM,gBAAgBI,EAAS,MAAM,IAAI,GAC/EO,IAAQC,EAAA,GACRC,IAAiBH,EAAS,MAAM,EAAQC,EAAM,OAAQ,GACtDG,IAAgBJ,EAAS,MAAM,EAAQC,EAAM,MAAO,GAEpDI,IAAOC,EAAIhB,EAAM,QAAQ,EAAK;AAEpC,IAAAiB;AAAA,MACE,MAAMjB,EAAM;AAAA,MACZ,CAACkB,MAAS;AACR,QAAIA,MAAS,WAAWH,EAAK,QAAQG;AAAA,MACvC;AAAA,IAAA;AAGF,UAAMC,IAAkBT;AAAA,MAAS,MAC/BJ,EAAY,SAAS,OAAO,SAAY,EAAE,QAAQA,EAAY,MAAA;AAAA,IAAM,GAGhEc,IAAeV,EAAS,MAAM;AAClC,YAAMW,IAAyC,CAAA;AAC/C,MAAIf,EAAY,SAAS,SAAMe,EAAM,SAASf,EAAY;AAC1D,YAAMgB,IAAgBC,EAAYvB,EAAM,KAAK,GACvCwB,IAAmBD,EAAYvB,EAAM,QAAQ,GAC7CyB,IAAmBF,EAAYvB,EAAM,QAAQ;AACnD,aAAIsB,QAAqB,QAAQA,IAC7BE,QAAwB,WAAWA,IACnCC,QAAwB,WAAWA,IAChC,OAAO,KAAKJ,CAAK,EAAE,SAASA,IAAQ;AAAA,IAC7C,CAAC,GAEKK,IAAoBhB;AAAA,MAAS,MACjC;AAAA,QACE;AAAA,QACA;AAAA,QACAV,EAAM,SAAS,OAAO,qBAAqB;AAAA,QAC3Cc,EAAc,QAAQ,8BAA8B;AAAA,QAC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9DnB,EAAA,cAArB8B,EAAmFC,EAAAC,CAAA,EAAA,OAAA;AAAA;sBAAvD,OAAM;AAAA,oBAAA;iCAAsB,MAAW;AAAA,4BAARhC,EAAA,KAAK,GAAA,CAAA;AAAA,sBAAA;;;oBAChEsC,EAEM,OAFNC,GAEM;AAAA,sBADJN,EAAQC,EAAA,QAAA,SAAA;AAAA,oBAAA;oBAECrB,EAAA,SAAX2B,EAAA,GAAAC,EAEM,OAFNC,GAEM;AAAA,sBADJT,EAAsBC,EAAA,QAAA,QAAA;AAAA,oBAAA;oBAEHlC,EAAA,cAArB8B,EAEgBC,EAAAC,CAAA,EAAA,OAAA;AAAA;sBAFY,OAAM;AAAA,oBAAA;iCAChC,MAAoD;AAAA,wBAApDG,EAAoDJ,EAAAC,CAAA,EAAA,UAAA,EAAlC,OAAM,2BAAyB;AAAA,sBAAA;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,32 +1,46 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { GCSA_THEME_KEY as
|
|
3
|
-
const
|
|
1
|
+
import { defineComponent as f, inject as v, ref as d, computed as l, onMounted as h, onUnmounted as g, openBlock as _, createBlock as b, Teleport as k, createElementVNode as E, renderSlot as s } from "vue";
|
|
2
|
+
import { GCSA_THEME_KEY as y } from "../composables/useGcsaTheme.js";
|
|
3
|
+
const M = ["data-gcsa-theme"], P = /* @__PURE__ */ f({
|
|
4
4
|
name: "GcsaPortal",
|
|
5
5
|
__name: "GcsaPortal",
|
|
6
6
|
props: {
|
|
7
7
|
portalled: { type: Boolean, default: !0 },
|
|
8
8
|
to: {}
|
|
9
9
|
},
|
|
10
|
-
setup(
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
setup(c) {
|
|
11
|
+
const u = c;
|
|
12
|
+
function o() {
|
|
13
|
+
if (typeof document > "u") return "dark";
|
|
14
|
+
const t = document.documentElement.getAttribute("data-gcsa-theme");
|
|
15
|
+
return t === "light" || t === "dark" ? t : "dark";
|
|
16
|
+
}
|
|
17
|
+
const a = v(y, null), n = d(o()), m = l(() => (a == null ? void 0 : a.value) ?? n.value), r = d(!1);
|
|
18
|
+
let e = null;
|
|
19
|
+
h(() => {
|
|
20
|
+
r.value = !0, n.value = o(), typeof MutationObserver < "u" && (e = new MutationObserver(() => {
|
|
21
|
+
n.value = o();
|
|
22
|
+
}), e.observe(document.documentElement, {
|
|
23
|
+
attributes: !0,
|
|
24
|
+
attributeFilter: ["data-gcsa-theme"]
|
|
25
|
+
}));
|
|
26
|
+
}), g(() => {
|
|
27
|
+
e == null || e.disconnect(), e = null;
|
|
14
28
|
});
|
|
15
|
-
const
|
|
16
|
-
return (
|
|
29
|
+
const i = l(() => u.to ?? "body"), p = l(() => u.portalled && r.value);
|
|
30
|
+
return (t, T) => p.value ? (_(), b(k, {
|
|
17
31
|
key: 0,
|
|
18
|
-
to:
|
|
32
|
+
to: i.value
|
|
19
33
|
}, [
|
|
20
|
-
|
|
34
|
+
E("div", {
|
|
21
35
|
class: "gcsa-portal-scope",
|
|
22
|
-
"data-gcsa-theme":
|
|
36
|
+
"data-gcsa-theme": m.value
|
|
23
37
|
}, [
|
|
24
|
-
s(
|
|
25
|
-
], 8,
|
|
26
|
-
], 8, ["to"])) : s(
|
|
38
|
+
s(t.$slots, "default")
|
|
39
|
+
], 8, M)
|
|
40
|
+
], 8, ["to"])) : s(t.$slots, "default", {}, void 0, void 0, 1);
|
|
27
41
|
}
|
|
28
42
|
});
|
|
29
43
|
export {
|
|
30
|
-
|
|
44
|
+
P as default
|
|
31
45
|
};
|
|
32
46
|
//# sourceMappingURL=GcsaPortal.vue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GcsaPortal.vue.js","sources":["../../src/components/GcsaPortal.vue"],"sourcesContent":["<template>\n <Teleport v-if=\"shouldPortal\" :to=\"resolvedTarget\">\n <div class=\"gcsa-portal-scope\" :data-gcsa-theme=\"theme\">\n <slot />\n </div>\n </Teleport>\n <slot v-else />\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, inject, onMounted, ref, type ComputedRef } from 'vue';\nimport type { GcsaConsoleTheme } from '@gcsa/console-core';\nimport type { GcsaPortalProps } from '../types/componentProps';\nimport { GCSA_THEME_KEY } from '../composables/useGcsaTheme';\n\ndefineOptions({ name: 'GcsaPortal' });\n\nconst props = withDefaults(\n defineProps<GcsaPortalProps>(),\n {\n portalled: true\n }\n);\n\nconst injectedTheme = inject<ComputedRef<GcsaConsoleTheme> | null>(GCSA_THEME_KEY, null);\nconst theme = computed(() => injectedTheme?.value ??
|
|
1
|
+
{"version":3,"file":"GcsaPortal.vue.js","sources":["../../src/components/GcsaPortal.vue"],"sourcesContent":["<template>\n <Teleport v-if=\"shouldPortal\" :to=\"resolvedTarget\">\n <div class=\"gcsa-portal-scope\" :data-gcsa-theme=\"theme\">\n <slot />\n </div>\n </Teleport>\n <slot v-else />\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, inject, onMounted, onUnmounted, ref, type ComputedRef } from 'vue';\nimport type { GcsaConsoleTheme } from '@gcsa/console-core';\nimport type { GcsaPortalProps } from '../types/componentProps';\nimport { GCSA_THEME_KEY } from '../composables/useGcsaTheme';\n\ndefineOptions({ name: 'GcsaPortal' });\n\nconst props = withDefaults(\n defineProps<GcsaPortalProps>(),\n {\n portalled: true\n }\n);\n\nfunction readDocumentTheme(): GcsaConsoleTheme {\n if (typeof document === 'undefined') return 'dark';\n const value = document.documentElement.getAttribute('data-gcsa-theme');\n return value === 'light' || value === 'dark' ? value : 'dark';\n}\n\nconst injectedTheme = inject<ComputedRef<GcsaConsoleTheme> | null>(GCSA_THEME_KEY, null);\nconst documentTheme = ref<GcsaConsoleTheme>(readDocumentTheme());\nconst theme = computed(() => injectedTheme?.value ?? documentTheme.value);\n\n/**\n * 延迟到客户端挂载后再创建 Teleport,避免 Suspense / 异步父组件初次渲染时\n * Vue 对 Teleport 做 deferred mount 却找不到 parentNode 的竞态。\n * 浮层统一挂 body,层级由 useGcsaZIndex 栈管理(勿挂到 modal 内 fixed 容器,会破坏定位)。\n */\nconst mounted = ref(false);\nlet themeObserver: MutationObserver | null = null;\n\nonMounted(() => {\n mounted.value = true;\n documentTheme.value = readDocumentTheme();\n if (typeof MutationObserver !== 'undefined') {\n themeObserver = new MutationObserver(() => {\n documentTheme.value = readDocumentTheme();\n });\n themeObserver.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['data-gcsa-theme']\n });\n }\n});\n\nonUnmounted(() => {\n themeObserver?.disconnect();\n themeObserver = null;\n});\n\nconst resolvedTarget = computed(() => props.to ?? 'body');\n\nconst shouldPortal = computed(() => props.portalled && mounted.value);\n</script>\n"],"names":["props","__props","readDocumentTheme","value","injectedTheme","inject","GCSA_THEME_KEY","documentTheme","ref","theme","computed","mounted","themeObserver","onMounted","onUnmounted","resolvedTarget","shouldPortal","_createBlock","_Teleport","_createElementVNode","_renderSlot","_ctx"],"mappings":";;;;;;;;;;AAiBA,UAAMA,IAAQC;AAOd,aAASC,IAAsC;AAC7C,UAAI,OAAO,WAAa,IAAa,QAAO;AAC5C,YAAMC,IAAQ,SAAS,gBAAgB,aAAa,iBAAiB;AACrE,aAAOA,MAAU,WAAWA,MAAU,SAASA,IAAQ;AAAA,IACzD;AAEA,UAAMC,IAAgBC,EAA6CC,GAAgB,IAAI,GACjFC,IAAgBC,EAAsBN,GAAmB,GACzDO,IAAQC,EAAS,OAAMN,KAAA,gBAAAA,EAAe,UAASG,EAAc,KAAK,GAOlEI,IAAUH,EAAI,EAAK;AACzB,QAAII,IAAyC;AAE7C,IAAAC,EAAU,MAAM;AACd,MAAAF,EAAQ,QAAQ,IAChBJ,EAAc,QAAQL,EAAA,GAClB,OAAO,mBAAqB,QAC9BU,IAAgB,IAAI,iBAAiB,MAAM;AACzC,QAAAL,EAAc,QAAQL,EAAA;AAAA,MACxB,CAAC,GACDU,EAAc,QAAQ,SAAS,iBAAiB;AAAA,QAC9C,YAAY;AAAA,QACZ,iBAAiB,CAA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