hzzt-plus 2.0.5 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/dist/index.full.js +77 -74
  2. package/dist/index.full.min.js +10 -10
  3. package/dist/index.full.min.js.map +1 -1
  4. package/dist/index.full.min.mjs +10 -10
  5. package/dist/index.full.min.mjs.map +1 -1
  6. package/dist/index.full.mjs +77 -74
  7. package/dist/locale/en.js +1 -1
  8. package/dist/locale/en.min.js +1 -1
  9. package/dist/locale/en.min.mjs +1 -1
  10. package/dist/locale/en.mjs +1 -1
  11. package/dist/locale/zh-cn.js +1 -1
  12. package/dist/locale/zh-cn.min.js +1 -1
  13. package/dist/locale/zh-cn.min.mjs +1 -1
  14. package/dist/locale/zh-cn.mjs +1 -1
  15. package/es/components/cascader/index.mjs +2 -2
  16. package/es/components/cascader/src/cascader.mjs +36 -122
  17. package/es/components/cascader/src/cascader.mjs.map +1 -1
  18. package/es/components/cascader/src/cascader2.mjs +122 -36
  19. package/es/components/cascader/src/cascader2.mjs.map +1 -1
  20. package/es/components/click-input/index.mjs +2 -2
  21. package/es/components/click-input/src/click-input.mjs +84 -21
  22. package/es/components/click-input/src/click-input.mjs.map +1 -1
  23. package/es/components/click-input/src/click-input2.mjs +21 -84
  24. package/es/components/click-input/src/click-input2.mjs.map +1 -1
  25. package/es/components/collapse/index.mjs +2 -2
  26. package/es/components/collapse/src/collapse.mjs +0 -88
  27. package/es/components/collapse/src/collapse.mjs.map +1 -1
  28. package/es/components/collapse/src/collapse2.mjs +88 -0
  29. package/es/components/collapse/src/collapse2.mjs.map +1 -1
  30. package/es/components/icon/index.d.ts +432 -3
  31. package/es/components/icon/index.mjs +12 -11
  32. package/es/components/icon/index.mjs.map +1 -1
  33. package/es/components/icon/src/index.mjs +4 -1
  34. package/es/components/icon/src/index.mjs.map +1 -1
  35. package/es/components/index.mjs +5 -5
  36. package/es/components/input-range/index.mjs +2 -2
  37. package/es/components/input-range/src/input-range.mjs +26 -76
  38. package/es/components/input-range/src/input-range.mjs.map +1 -1
  39. package/es/components/input-range/src/input-range2.mjs +76 -26
  40. package/es/components/input-range/src/input-range2.mjs.map +1 -1
  41. package/es/components/lazy-list/index.mjs +2 -2
  42. package/es/components/lazy-list/src/lazy-list.mjs +22 -80
  43. package/es/components/lazy-list/src/lazy-list.mjs.map +1 -1
  44. package/es/components/lazy-list/src/lazy-list2.mjs +80 -22
  45. package/es/components/lazy-list/src/lazy-list2.mjs.map +1 -1
  46. package/es/components/select-input/index.mjs +2 -2
  47. package/es/components/select-input/src/select-input.mjs +45 -124
  48. package/es/components/select-input/src/select-input.mjs.map +1 -1
  49. package/es/components/select-input/src/select-input2.mjs +124 -45
  50. package/es/components/select-input/src/select-input2.mjs.map +1 -1
  51. package/es/components/tab/index.d.ts +2 -0
  52. package/es/components/tab/src/index.mjs +10 -9
  53. package/es/components/tab/src/index.mjs.map +1 -1
  54. package/es/components/tab/src/index.vue.d.ts +2 -0
  55. package/es/index.mjs +5 -5
  56. package/es/version.d.ts +1 -1
  57. package/es/version.mjs +1 -1
  58. package/es/version.mjs.map +1 -1
  59. package/lib/components/cascader/index.js +2 -2
  60. package/lib/components/cascader/src/cascader.js +36 -121
  61. package/lib/components/cascader/src/cascader.js.map +1 -1
  62. package/lib/components/cascader/src/cascader2.js +121 -36
  63. package/lib/components/cascader/src/cascader2.js.map +1 -1
  64. package/lib/components/click-input/index.js +2 -2
  65. package/lib/components/click-input/src/click-input.js +84 -22
  66. package/lib/components/click-input/src/click-input.js.map +1 -1
  67. package/lib/components/click-input/src/click-input2.js +22 -84
  68. package/lib/components/click-input/src/click-input2.js.map +1 -1
  69. package/lib/components/collapse/index.js +2 -2
  70. package/lib/components/collapse/src/collapse.js +0 -91
  71. package/lib/components/collapse/src/collapse.js.map +1 -1
  72. package/lib/components/collapse/src/collapse2.js +91 -0
  73. package/lib/components/collapse/src/collapse2.js.map +1 -1
  74. package/lib/components/icon/index.d.ts +432 -3
  75. package/lib/components/icon/index.js +14 -13
  76. package/lib/components/icon/index.js.map +1 -1
  77. package/lib/components/icon/src/index.js +4 -1
  78. package/lib/components/icon/src/index.js.map +1 -1
  79. package/lib/components/index.js +5 -5
  80. package/lib/components/input-range/index.js +2 -2
  81. package/lib/components/input-range/src/input-range.js +27 -76
  82. package/lib/components/input-range/src/input-range.js.map +1 -1
  83. package/lib/components/input-range/src/input-range2.js +76 -27
  84. package/lib/components/input-range/src/input-range2.js.map +1 -1
  85. package/lib/components/lazy-list/index.js +2 -2
  86. package/lib/components/lazy-list/src/lazy-list.js +23 -80
  87. package/lib/components/lazy-list/src/lazy-list.js.map +1 -1
  88. package/lib/components/lazy-list/src/lazy-list2.js +80 -23
  89. package/lib/components/lazy-list/src/lazy-list2.js.map +1 -1
  90. package/lib/components/select-input/index.js +2 -2
  91. package/lib/components/select-input/src/select-input.js +46 -124
  92. package/lib/components/select-input/src/select-input.js.map +1 -1
  93. package/lib/components/select-input/src/select-input2.js +124 -46
  94. package/lib/components/select-input/src/select-input2.js.map +1 -1
  95. package/lib/components/tab/index.d.ts +2 -0
  96. package/lib/components/tab/src/index.js +9 -8
  97. package/lib/components/tab/src/index.js.map +1 -1
  98. package/lib/components/tab/src/index.vue.d.ts +2 -0
  99. package/lib/index.js +5 -5
  100. package/lib/version.d.ts +1 -1
  101. package/lib/version.js +1 -1
  102. package/lib/version.js.map +1 -1
  103. package/package.json +1 -1
  104. package/web-types.json +1 -1
@@ -1,128 +1,42 @@
1
- import { defineComponent, useAttrs, ref, computed, watch, openBlock, createElementBlock, normalizeClass, unref, createVNode, mergeProps } from 'vue';
2
- import { cascaderProps, cascaderEmits } from './cascader2.mjs';
3
- import { useFormSize, useFormDisabled, ElInput, ElCascader } from 'element-plus';
4
- import '../../../hooks/index.mjs';
5
1
  import '../../../utils/index.mjs';
6
- import { getCascaderId } from './hooks/utils.mjs';
7
- import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
8
- import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
9
- import { useGlobalSize } from '../../../hooks/use-size/index.mjs';
10
- import { isArray } from '@vue/shared';
2
+ import '../../../hooks/index.mjs';
3
+ import '../../../constants/index.mjs';
4
+ import { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs';
5
+ import { useSizeProp } from '../../../hooks/use-size/index.mjs';
6
+ import { UPDATE_MODEL_EVENT } from '../../../constants/event.mjs';
7
+ import { isString } from '@vue/shared';
11
8
 
12
- const __default__ = defineComponent({
13
- name: "HzztCascader"
14
- });
15
- const _sfc_main = /* @__PURE__ */ defineComponent({
16
- ...__default__,
17
- props: cascaderProps,
18
- emits: cascaderEmits,
19
- setup(__props, { emit }) {
20
- const props = __props;
21
- const attrs = useAttrs();
22
- const inputVal = ref(props.modelValue);
23
- const cascaderVal = ref();
24
- const inputRef = ref();
25
- const cascaderRef = ref();
26
- const nsCascader = useNamespace("cascader");
27
- const formSize = useFormSize();
28
- const formDisabled = useFormDisabled();
29
- const trueSize = computed(() => props.size || formSize.value || useGlobalSize().value);
30
- const trueDisabled = computed(() => props.disabled || formDisabled.value);
31
- const containerCls = computed(() => [
32
- "relative",
33
- nsCascader.b(),
34
- nsCascader.m(trueSize.value)
35
- ]);
36
- const inputCls = computed(() => [
37
- nsCascader.e("input")
38
- ]);
39
- const cascaderCls = computed(() => [
40
- nsCascader.e("cascader")
41
- ]);
42
- const _inputProps = computed(() => ({
43
- disabled: trueDisabled.value,
44
- size: trueSize.value,
45
- clearable: props.clearable,
46
- placeholder: props.placeholder,
47
- readonly: props.readonly,
48
- ...attrs
49
- }));
50
- const _cascaderProps = computed(() => ({
51
- options: props.options,
52
- disabled: trueDisabled.value,
53
- size: trueSize.value,
54
- clearable: props.clearable,
55
- placeholder: props.placeholder,
56
- props: { checkStrictly: true, expandTrigger: "hover" },
57
- filterable: true,
58
- separator: "/",
59
- showAllLevels: true,
60
- ...props.cascaderProps
61
- }));
62
- watch(() => props.modelValue, (v) => {
63
- inputVal.value = v;
64
- getCascaderVal();
65
- });
66
- watch(() => props.options, (v) => {
67
- if (!v)
68
- return;
69
- getCascaderVal();
70
- });
71
- getCascaderVal();
72
- function input(str) {
73
- emit("update:modelValue", str);
74
- emit("input", str);
75
- }
76
- function change(str) {
77
- emit("change", str);
78
- }
79
- function click(e) {
80
- cascaderRef.value.togglePopperVisible();
81
- const target = e.target;
82
- target.focus();
83
- }
84
- function cascaderChange(val) {
85
- const separator = _cascaderProps.value.separator || "/";
86
- inputVal.value = val ? isArray(val) ? val.join(separator) : [val].join(separator) : "";
87
- input(inputVal.value);
88
- change(inputVal.value);
89
- }
90
- function getCascaderVal() {
91
- const separator = _cascaderProps.value.separator || "/";
92
- if (_cascaderProps.value.showAllLevels === false) {
93
- const list = getCascaderId(props.modelValue, props.options);
94
- cascaderVal.value = list.join(separator);
95
- } else {
96
- cascaderVal.value = (props.modelValue || "").split(separator);
97
- }
98
- }
99
- return (_ctx, _cache) => {
100
- return openBlock(), createElementBlock("div", {
101
- class: normalizeClass(unref(containerCls))
102
- }, [
103
- createVNode(unref(ElInput), mergeProps({
104
- class: unref(inputCls),
105
- modelValue: inputVal.value,
106
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inputVal.value = $event),
107
- ref_key: "inputRef",
108
- ref: inputRef
109
- }, unref(_inputProps), {
110
- onInput: input,
111
- onClick: click,
112
- onChange: change
113
- }), null, 16, ["class", "modelValue"]),
114
- createVNode(unref(ElCascader), mergeProps({
115
- class: unref(cascaderCls),
116
- modelValue: cascaderVal.value,
117
- "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => cascaderVal.value = $event),
118
- ref_key: "cascaderRef",
119
- ref: cascaderRef
120
- }, unref(_cascaderProps), { onChange: cascaderChange }), null, 16, ["class", "modelValue"])
121
- ], 2);
122
- };
9
+ const cascaderProps = buildProps({
10
+ cascaderProps: {
11
+ type: Object,
12
+ default: () => ({
13
+ showAllLevels: true
14
+ })
15
+ },
16
+ disabled: Boolean,
17
+ readonly: Boolean,
18
+ clearable: Boolean,
19
+ size: useSizeProp,
20
+ options: {
21
+ type: definePropType(Array),
22
+ default: () => []
23
+ },
24
+ placeholder: {
25
+ type: String,
26
+ default: ""
27
+ },
28
+ modelValue: {
29
+ type: definePropType([
30
+ String
31
+ ]),
32
+ default: ""
123
33
  }
124
34
  });
125
- var Cascader = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "cascader.vue"]]);
35
+ const cascaderEmits = {
36
+ [UPDATE_MODEL_EVENT]: (value) => isString(value),
37
+ input: (value) => isString(value),
38
+ change: (value) => isString(value)
39
+ };
126
40
 
127
- export { Cascader as default };
41
+ export { cascaderEmits, cascaderProps };
128
42
  //# sourceMappingURL=cascader.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cascader.mjs","sources":["../../../../../../packages/components/cascader/src/cascader.vue"],"sourcesContent":["<template>\n <div :class=\"containerCls\">\n <el-input\n :class=\"inputCls\"\n v-model=\"inputVal\"\n ref=\"inputRef\"\n v-bind=\"_inputProps\"\n @input=\"input\"\n @click=\"click\"\n @change=\"change\"\n >\n </el-input>\n <el-cascader :class=\"cascaderCls\" v-model=\"cascaderVal\" ref=\"cascaderRef\" v-bind=\"_cascaderProps\"\n @change=\"cascaderChange\">\n </el-cascader>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\n import {cascaderEmits, cascaderProps} from './cascader'\n import {computed, ref, useAttrs, watch} from \"vue\";\n import {CascaderProps, useFormDisabled, useFormSize, CascaderValue} from \"element-plus\";\n import {useGlobalSize, useNamespace} from \"@hzzt-plus/hooks\";\n import {isArray} from '@hzzt-plus/utils'\n import {ElInput, ElCascader} from 'element-plus'\n import {getCascaderId} from \"./hooks/utils\";\n\n defineOptions({\n name: 'HzztCascader',\n })\n\n const props = defineProps(cascaderProps)\n const emit = defineEmits(cascaderEmits)\n\n const attrs = useAttrs();\n\n const inputVal = ref(props.modelValue);\n const cascaderVal = ref();\n const inputRef = ref();\n const cascaderRef = ref();\n\n const nsCascader = useNamespace('cascader');\n\n const formSize = useFormSize()\n const formDisabled = useFormDisabled()\n\n const trueSize = computed(\n () => props.size || formSize.value || useGlobalSize().value\n )\n\n const trueDisabled = computed(() => props.disabled || formDisabled.value)\n\n const containerCls = computed(() => [\n 'relative',\n nsCascader.b(),\n nsCascader.m(trueSize.value),\n ])\n\n const inputCls = computed(() => [\n nsCascader.e('input'),\n ])\n\n const cascaderCls = computed(() => [\n nsCascader.e('cascader'),\n ])\n\n const _inputProps = computed(() => ({\n disabled: trueDisabled.value,\n size: trueSize.value,\n clearable: props.clearable,\n placeholder: props.placeholder,\n readonly: props.readonly,\n ...attrs,\n }))\n\n const _cascaderProps = computed(() => ({\n options: props.options,\n disabled: trueDisabled.value,\n size: trueSize.value,\n clearable: props.clearable,\n placeholder: props.placeholder,\n props: {checkStrictly: true, expandTrigger: 'hover'} as CascaderProps,\n filterable: true,\n separator: '/',\n showAllLevels: true,\n ...props.cascaderProps,\n }))\n\n watch(() => props.modelValue, (v) => {\n inputVal.value = v;\n getCascaderVal();\n })\n\n watch(() => props.options, (v) => {\n if (!v) return;\n getCascaderVal();\n })\n\n getCascaderVal();\n\n function input(str: string) {\n emit('update:modelValue', str)\n emit('input', str)\n }\n\n function change(str: string) {\n emit('change', str)\n }\n\n function click(e: MouseEvent) {\n cascaderRef.value.togglePopperVisible();\n const target = e.target as HTMLInputElement;\n target.focus();\n }\n\n function cascaderChange(val: CascaderValue) {\n const separator = _cascaderProps.value.separator || '/';\n inputVal.value = val ? isArray(val) ? val.join(separator) : [val].join(separator) : '';\n input(inputVal.value);\n change(inputVal.value);\n }\n\n function getCascaderVal() {\n const separator = _cascaderProps.value.separator || '/';\n if (_cascaderProps.value.showAllLevels === false) {\n const list = getCascaderId(props.modelValue, props.options);\n cascaderVal.value = list.join(separator);\n } else {\n cascaderVal.value = (props.modelValue || '').split(separator);\n }\n }\n\n\n</script>\n"],"names":["_openBlock","_createElementBlock"],"mappings":";;;;;;;;;;;mCA2BgB,CAAA;AAA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{buildProps, definePropType, isString} from '@hzzt-plus/utils'\nimport {useSizeProp} from \"@hzzt-plus/hooks\";\nimport type {ExtractPropTypes} from 'vue'\nimport type Cascader from './cascader.vue'\nimport {UPDATE_MODEL_EVENT} from \"@hzzt-plus/constants\";\n\nexport type CascaderNodeValue = string | number\n\nexport interface CascaderOption extends Record<string, unknown> {\n label?: string\n value?: CascaderNodeValue\n children?: CascaderOption[]\n disabled?: boolean\n leaf?: boolean\n}\n\nexport const cascaderProps = buildProps({\n cascaderProps: {\n type: Object,\n default: () => ({\n showAllLevels: true,\n }),\n },\n disabled: Boolean,\n readonly: Boolean,\n clearable: Boolean,\n size: useSizeProp,\n options: {\n type: definePropType<CascaderOption[]>(Array),\n default: () => [] as CascaderOption[],\n },\n placeholder: {\n type: String,\n default: '',\n },\n modelValue: {\n type: definePropType<string | undefined>([\n String,\n ]),\n default: '',\n },\n})\n\nexport type CascaderProps = ExtractPropTypes<typeof cascaderProps>\n\nexport const cascaderEmits = {\n [UPDATE_MODEL_EVENT]: (value: string | undefined) => isString(value),\n input: (value: string | undefined) => isString(value),\n change: (value: string | undefined) => isString(value),\n}\nexport type CascaderEmits = typeof cascaderEmits\n\n\nexport type CascaderInstance = InstanceType<typeof Cascader>\n"],"names":[],"mappings":";;;;;;;;AAGY,MAAC,aAAa,GAAG,UAAU,CAAC;AACxC,EAAE,aAAa,EAAE;AACjB,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,OAAO;AACpB,MAAM,aAAa,EAAE,IAAI;AACzB,KAAK,CAAC;AACN,GAAG;AACH,EAAE,QAAQ,EAAE,OAAO;AACnB,EAAE,QAAQ,EAAE,OAAO;AACnB,EAAE,SAAS,EAAE,OAAO;AACpB,EAAE,IAAI,EAAE,WAAW;AACnB,EAAE,OAAO,EAAE;AACX,IAAI,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC;AAC/B,IAAI,OAAO,EAAE,MAAM,EAAE;AACrB,GAAG;AACH,EAAE,WAAW,EAAE;AACf,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,cAAc,CAAC;AACzB,MAAM,MAAM;AACZ,KAAK,CAAC;AACN,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,CAAC,EAAE;AACS,MAAC,aAAa,GAAG;AAC7B,EAAE,CAAC,kBAAkB,GAAG,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,CAAC;AAClD,EAAE,KAAK,EAAE,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,CAAC;AACnC,EAAE,MAAM,EAAE,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,CAAC;AACpC;;;;"}
@@ -1,42 +1,128 @@
1
- import '../../../utils/index.mjs';
1
+ import { defineComponent, useAttrs, ref, computed, watch, openBlock, createElementBlock, normalizeClass, unref, createVNode, mergeProps } from 'vue';
2
+ import { cascaderProps, cascaderEmits } from './cascader.mjs';
3
+ import { useFormSize, useFormDisabled, ElInput, ElCascader } from 'element-plus';
2
4
  import '../../../hooks/index.mjs';
3
- import '../../../constants/index.mjs';
4
- import { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs';
5
- import { useSizeProp } from '../../../hooks/use-size/index.mjs';
6
- import { UPDATE_MODEL_EVENT } from '../../../constants/event.mjs';
7
- import { isString } from '@vue/shared';
5
+ import '../../../utils/index.mjs';
6
+ import { getCascaderId } from './hooks/utils.mjs';
7
+ import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
8
+ import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
9
+ import { useGlobalSize } from '../../../hooks/use-size/index.mjs';
10
+ import { isArray } from '@vue/shared';
8
11
 
9
- const cascaderProps = buildProps({
10
- cascaderProps: {
11
- type: Object,
12
- default: () => ({
13
- showAllLevels: true
14
- })
15
- },
16
- disabled: Boolean,
17
- readonly: Boolean,
18
- clearable: Boolean,
19
- size: useSizeProp,
20
- options: {
21
- type: definePropType(Array),
22
- default: () => []
23
- },
24
- placeholder: {
25
- type: String,
26
- default: ""
27
- },
28
- modelValue: {
29
- type: definePropType([
30
- String
31
- ]),
32
- default: ""
12
+ const __default__ = defineComponent({
13
+ name: "HzztCascader"
14
+ });
15
+ const _sfc_main = /* @__PURE__ */ defineComponent({
16
+ ...__default__,
17
+ props: cascaderProps,
18
+ emits: cascaderEmits,
19
+ setup(__props, { emit }) {
20
+ const props = __props;
21
+ const attrs = useAttrs();
22
+ const inputVal = ref(props.modelValue);
23
+ const cascaderVal = ref();
24
+ const inputRef = ref();
25
+ const cascaderRef = ref();
26
+ const nsCascader = useNamespace("cascader");
27
+ const formSize = useFormSize();
28
+ const formDisabled = useFormDisabled();
29
+ const trueSize = computed(() => props.size || formSize.value || useGlobalSize().value);
30
+ const trueDisabled = computed(() => props.disabled || formDisabled.value);
31
+ const containerCls = computed(() => [
32
+ "relative",
33
+ nsCascader.b(),
34
+ nsCascader.m(trueSize.value)
35
+ ]);
36
+ const inputCls = computed(() => [
37
+ nsCascader.e("input")
38
+ ]);
39
+ const cascaderCls = computed(() => [
40
+ nsCascader.e("cascader")
41
+ ]);
42
+ const _inputProps = computed(() => ({
43
+ disabled: trueDisabled.value,
44
+ size: trueSize.value,
45
+ clearable: props.clearable,
46
+ placeholder: props.placeholder,
47
+ readonly: props.readonly,
48
+ ...attrs
49
+ }));
50
+ const _cascaderProps = computed(() => ({
51
+ options: props.options,
52
+ disabled: trueDisabled.value,
53
+ size: trueSize.value,
54
+ clearable: props.clearable,
55
+ placeholder: props.placeholder,
56
+ props: { checkStrictly: true, expandTrigger: "hover" },
57
+ filterable: true,
58
+ separator: "/",
59
+ showAllLevels: true,
60
+ ...props.cascaderProps
61
+ }));
62
+ watch(() => props.modelValue, (v) => {
63
+ inputVal.value = v;
64
+ getCascaderVal();
65
+ });
66
+ watch(() => props.options, (v) => {
67
+ if (!v)
68
+ return;
69
+ getCascaderVal();
70
+ });
71
+ getCascaderVal();
72
+ function input(str) {
73
+ emit("update:modelValue", str);
74
+ emit("input", str);
75
+ }
76
+ function change(str) {
77
+ emit("change", str);
78
+ }
79
+ function click(e) {
80
+ cascaderRef.value.togglePopperVisible();
81
+ const target = e.target;
82
+ target.focus();
83
+ }
84
+ function cascaderChange(val) {
85
+ const separator = _cascaderProps.value.separator || "/";
86
+ inputVal.value = val ? isArray(val) ? val.join(separator) : [val].join(separator) : "";
87
+ input(inputVal.value);
88
+ change(inputVal.value);
89
+ }
90
+ function getCascaderVal() {
91
+ const separator = _cascaderProps.value.separator || "/";
92
+ if (_cascaderProps.value.showAllLevels === false) {
93
+ const list = getCascaderId(props.modelValue, props.options);
94
+ cascaderVal.value = list.join(separator);
95
+ } else {
96
+ cascaderVal.value = (props.modelValue || "").split(separator);
97
+ }
98
+ }
99
+ return (_ctx, _cache) => {
100
+ return openBlock(), createElementBlock("div", {
101
+ class: normalizeClass(unref(containerCls))
102
+ }, [
103
+ createVNode(unref(ElInput), mergeProps({
104
+ class: unref(inputCls),
105
+ modelValue: inputVal.value,
106
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inputVal.value = $event),
107
+ ref_key: "inputRef",
108
+ ref: inputRef
109
+ }, unref(_inputProps), {
110
+ onInput: input,
111
+ onClick: click,
112
+ onChange: change
113
+ }), null, 16, ["class", "modelValue"]),
114
+ createVNode(unref(ElCascader), mergeProps({
115
+ class: unref(cascaderCls),
116
+ modelValue: cascaderVal.value,
117
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => cascaderVal.value = $event),
118
+ ref_key: "cascaderRef",
119
+ ref: cascaderRef
120
+ }, unref(_cascaderProps), { onChange: cascaderChange }), null, 16, ["class", "modelValue"])
121
+ ], 2);
122
+ };
33
123
  }
34
124
  });
35
- const cascaderEmits = {
36
- [UPDATE_MODEL_EVENT]: (value) => isString(value),
37
- input: (value) => isString(value),
38
- change: (value) => isString(value)
39
- };
125
+ var Cascader = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "cascader.vue"]]);
40
126
 
41
- export { cascaderEmits, cascaderProps };
127
+ export { Cascader as default };
42
128
  //# sourceMappingURL=cascader2.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cascader2.mjs","sources":["../../../../../../packages/components/cascader/src/cascader.ts"],"sourcesContent":["import {buildProps, definePropType, isString} from '@hzzt-plus/utils'\nimport {useSizeProp} from \"@hzzt-plus/hooks\";\nimport type {ExtractPropTypes} from 'vue'\nimport type Cascader from './cascader.vue'\nimport {UPDATE_MODEL_EVENT} from \"@hzzt-plus/constants\";\n\nexport type CascaderNodeValue = string | number\n\nexport interface CascaderOption extends Record<string, unknown> {\n label?: string\n value?: CascaderNodeValue\n children?: CascaderOption[]\n disabled?: boolean\n leaf?: boolean\n}\n\nexport const cascaderProps = buildProps({\n cascaderProps: {\n type: Object,\n default: () => ({\n showAllLevels: true,\n }),\n },\n disabled: Boolean,\n readonly: Boolean,\n clearable: Boolean,\n size: useSizeProp,\n options: {\n type: definePropType<CascaderOption[]>(Array),\n default: () => [] as CascaderOption[],\n },\n placeholder: {\n type: String,\n default: '',\n },\n modelValue: {\n type: definePropType<string | undefined>([\n String,\n ]),\n default: '',\n },\n})\n\nexport type CascaderProps = ExtractPropTypes<typeof cascaderProps>\n\nexport const cascaderEmits = {\n [UPDATE_MODEL_EVENT]: (value: string | undefined) => isString(value),\n input: (value: string | undefined) => isString(value),\n change: (value: string | undefined) => isString(value),\n}\nexport type CascaderEmits = typeof cascaderEmits\n\n\nexport type CascaderInstance = InstanceType<typeof Cascader>\n"],"names":[],"mappings":";;;;;;;;AAGY,MAAC,aAAa,GAAG,UAAU,CAAC;AACxC,EAAE,aAAa,EAAE;AACjB,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,OAAO;AACpB,MAAM,aAAa,EAAE,IAAI;AACzB,KAAK,CAAC;AACN,GAAG;AACH,EAAE,QAAQ,EAAE,OAAO;AACnB,EAAE,QAAQ,EAAE,OAAO;AACnB,EAAE,SAAS,EAAE,OAAO;AACpB,EAAE,IAAI,EAAE,WAAW;AACnB,EAAE,OAAO,EAAE;AACX,IAAI,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC;AAC/B,IAAI,OAAO,EAAE,MAAM,EAAE;AACrB,GAAG;AACH,EAAE,WAAW,EAAE;AACf,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,cAAc,CAAC;AACzB,MAAM,MAAM;AACZ,KAAK,CAAC;AACN,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,CAAC,EAAE;AACS,MAAC,aAAa,GAAG;AAC7B,EAAE,CAAC,kBAAkB,GAAG,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,CAAC;AAClD,EAAE,KAAK,EAAE,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,CAAC;AACnC,EAAE,MAAM,EAAE,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,CAAC;AACpC;;;;"}
1
+ {"version":3,"file":"cascader2.mjs","sources":["../../../../../../packages/components/cascader/src/cascader.vue"],"sourcesContent":["<template>\n <div :class=\"containerCls\">\n <el-input\n :class=\"inputCls\"\n v-model=\"inputVal\"\n ref=\"inputRef\"\n v-bind=\"_inputProps\"\n @input=\"input\"\n @click=\"click\"\n @change=\"change\"\n >\n </el-input>\n <el-cascader :class=\"cascaderCls\" v-model=\"cascaderVal\" ref=\"cascaderRef\" v-bind=\"_cascaderProps\"\n @change=\"cascaderChange\">\n </el-cascader>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\n import {cascaderEmits, cascaderProps} from './cascader'\n import {computed, ref, useAttrs, watch} from \"vue\";\n import {CascaderProps, useFormDisabled, useFormSize, CascaderValue} from \"element-plus\";\n import {useGlobalSize, useNamespace} from \"@hzzt-plus/hooks\";\n import {isArray} from '@hzzt-plus/utils'\n import {ElInput, ElCascader} from 'element-plus'\n import {getCascaderId} from \"./hooks/utils\";\n\n defineOptions({\n name: 'HzztCascader',\n })\n\n const props = defineProps(cascaderProps)\n const emit = defineEmits(cascaderEmits)\n\n const attrs = useAttrs();\n\n const inputVal = ref(props.modelValue);\n const cascaderVal = ref();\n const inputRef = ref();\n const cascaderRef = ref();\n\n const nsCascader = useNamespace('cascader');\n\n const formSize = useFormSize()\n const formDisabled = useFormDisabled()\n\n const trueSize = computed(\n () => props.size || formSize.value || useGlobalSize().value\n )\n\n const trueDisabled = computed(() => props.disabled || formDisabled.value)\n\n const containerCls = computed(() => [\n 'relative',\n nsCascader.b(),\n nsCascader.m(trueSize.value),\n ])\n\n const inputCls = computed(() => [\n nsCascader.e('input'),\n ])\n\n const cascaderCls = computed(() => [\n nsCascader.e('cascader'),\n ])\n\n const _inputProps = computed(() => ({\n disabled: trueDisabled.value,\n size: trueSize.value,\n clearable: props.clearable,\n placeholder: props.placeholder,\n readonly: props.readonly,\n ...attrs,\n }))\n\n const _cascaderProps = computed(() => ({\n options: props.options,\n disabled: trueDisabled.value,\n size: trueSize.value,\n clearable: props.clearable,\n placeholder: props.placeholder,\n props: {checkStrictly: true, expandTrigger: 'hover'} as CascaderProps,\n filterable: true,\n separator: '/',\n showAllLevels: true,\n ...props.cascaderProps,\n }))\n\n watch(() => props.modelValue, (v) => {\n inputVal.value = v;\n getCascaderVal();\n })\n\n watch(() => props.options, (v) => {\n if (!v) return;\n getCascaderVal();\n })\n\n getCascaderVal();\n\n function input(str: string) {\n emit('update:modelValue', str)\n emit('input', str)\n }\n\n function change(str: string) {\n emit('change', str)\n }\n\n function click(e: MouseEvent) {\n cascaderRef.value.togglePopperVisible();\n const target = e.target as HTMLInputElement;\n target.focus();\n }\n\n function cascaderChange(val: CascaderValue) {\n const separator = _cascaderProps.value.separator || '/';\n inputVal.value = val ? isArray(val) ? val.join(separator) : [val].join(separator) : '';\n input(inputVal.value);\n change(inputVal.value);\n }\n\n function getCascaderVal() {\n const separator = _cascaderProps.value.separator || '/';\n if (_cascaderProps.value.showAllLevels === false) {\n const list = getCascaderId(props.modelValue, props.options);\n cascaderVal.value = list.join(separator);\n } else {\n cascaderVal.value = (props.modelValue || '').split(separator);\n }\n }\n\n\n</script>\n"],"names":["_openBlock","_createElementBlock"],"mappings":";;;;;;;;;;;mCA2BgB,CAAA;AAAA,EACZ,IAAM,EAAA,cAAA;AACR,CAAA,CAAA,CAAA;;;;;;;AAKA,IAAA,MAAM,QAAQ,QAAS,EAAA,CAAA;AAEvB,IAAM,MAAA,QAAA,GAAW,GAAI,CAAA,KAAA,CAAM,UAAU,CAAA,CAAA;AACrC,IAAA,MAAM,cAAc,GAAI,EAAA,CAAA;AACxB,IAAA,MAAM,WAAW,GAAI,EAAA,CAAA;AACrB,IAAA,MAAM,cAAc,GAAI,EAAA,CAAA;AAExB,IAAM,MAAA,UAAA,GAAa,aAAa,UAAU,CAAA,CAAA;AAE1C,IAAA,MAAM,WAAW,WAAY,EAAA,CAAA;AAC7B,IAAA,MAAM,eAAe,eAAgB,EAAA,CAAA;AAErC,IAAA,MAAM,QAAW,GAAA,QAAA,CAAA,MAAA,KAAA,CAAA,IAAA,IAAA,QAAA,CAAA,KAAA,IAAA,aAAA,EAAA,CAAA,KAAA,CAAA,CAAA;AAAA,IAAA,kBACH,GAAA,QAAiB,CAAA,MAAA,kBAAuB,YAAE,CAAA,KAAA,CAAA,CAAA;AAAA,IACxD,MAAA,YAAA,GAAA,QAAA,CAAA,MAAA;AAEA,MAAA;AAEA,MAAM,UAAA,CAAA,CAAA,EAAA;AAA8B,MAClC,UAAA,CAAA,CAAA,CAAA,QAAA,CAAA,KAAA,CAAA;AAAA,KAAA,CACA;AAAa,IACb,MAAA,QAAa,GAAA,QAAc,CAAA,MAAA;AAAA,MAC5B,UAAA,CAAA,CAAA,CAAA,OAAA,CAAA;AAED,KAAM,CAAA,CAAA;AAA0B,IAC9B,MAAA,WAAoB,GAAA,QAAA,CAAA,MAAA;AAAA,MACrB,UAAA,CAA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OAAA,CAAA,IAAA,EAAA,MAAA,KAAA;AAAA,MACF,OAAAA,SAAA,EAAA,EAAAC,kBAAA,CAAA,KAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,6 +1,6 @@
1
1
  import '../../utils/index.mjs';
2
- import ClickInput from './src/click-input2.mjs';
3
- export { clickInputEmits, clickInputProps } from './src/click-input.mjs';
2
+ import ClickInput from './src/click-input.mjs';
3
+ export { clickInputEmits, clickInputProps } from './src/click-input2.mjs';
4
4
  import { withInstall } from '../../utils/vue/install.mjs';
5
5
 
6
6
  const HzztClickInput = withInstall(ClickInput);
@@ -1,26 +1,89 @@
1
- import '../../../utils/index.mjs';
1
+ import { defineComponent, ref, computed, watch, nextTick, openBlock, createElementBlock, normalizeClass, unref, createBlock, mergeProps, withKeys, toDisplayString } from 'vue';
2
+ import { clickInputProps, clickInputEmits } from './click-input2.mjs';
2
3
  import '../../../hooks/index.mjs';
3
- import '../../../constants/index.mjs';
4
- import { buildProps } from '../../../utils/vue/props/runtime.mjs';
5
- import { useSizeProp } from '../../../hooks/use-size/index.mjs';
6
- import { UPDATE_MODEL_EVENT } from '../../../constants/event.mjs';
7
- import { isString } from '@vue/shared';
4
+ import { useFormSize, useFormDisabled, ElInput } from 'element-plus';
5
+ import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
6
+ import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
7
+ import { useGlobalSize } from '../../../hooks/use-size/index.mjs';
8
8
 
9
- const clickInputProps = buildProps({
10
- modelValue: {
11
- type: String,
12
- default: ""
13
- },
14
- disabled: Boolean,
15
- readonly: Boolean,
16
- inputProps: Object,
17
- size: useSizeProp
9
+ const __default__ = defineComponent({
10
+ name: "HzztClickInput"
18
11
  });
19
- const clickInputEmits = {
20
- [UPDATE_MODEL_EVENT]: (value) => isString(value),
21
- input: (value) => isString(value),
22
- change: (value) => isString(value)
23
- };
12
+ const _sfc_main = /* @__PURE__ */ defineComponent({
13
+ ...__default__,
14
+ props: clickInputProps,
15
+ emits: clickInputEmits,
16
+ setup(__props, { emit }) {
17
+ const props = __props;
18
+ const _inputVal = ref(props.modelValue || "");
19
+ const inputVal = ref(props.modelValue || "");
20
+ const inputRef = ref();
21
+ const editable = ref(false);
22
+ const nsInput = useNamespace("click-input");
23
+ const formSize = useFormSize();
24
+ const formDisabled = useFormDisabled();
25
+ const trueSize = computed(() => props.size || formSize.value || useGlobalSize().value);
26
+ const trueDisabled = computed(() => props.disabled || formDisabled.value);
27
+ const trueReadonly = computed(() => trueDisabled.value || props.readonly || !editable.value);
28
+ const containerCls = computed(() => [
29
+ nsInput.b(),
30
+ nsInput.m(trueSize.value),
31
+ "flex width-100% align-items-center"
32
+ ]);
33
+ const spanClass = computed(() => [
34
+ nsInput.e("span"),
35
+ "flex width-100% align-items-center"
36
+ ]);
37
+ watch(() => props.modelValue, (v) => {
38
+ inputVal.value = v || "";
39
+ _inputVal.value = v || "";
40
+ });
41
+ function input(val) {
42
+ emit("update:modelValue", val);
43
+ emit("input", val);
44
+ }
45
+ function change() {
46
+ editable.value = false;
47
+ if (_inputVal.value === inputVal.value) {
48
+ return;
49
+ }
50
+ input(inputVal.value);
51
+ emit("change", inputVal.value);
52
+ }
53
+ function edit() {
54
+ if (trueDisabled.value || props.readonly) {
55
+ return;
56
+ }
57
+ editable.value = true;
58
+ nextTick(() => {
59
+ inputRef.value.focus();
60
+ });
61
+ }
62
+ return (_ctx, _cache) => {
63
+ return openBlock(), createElementBlock("div", {
64
+ class: normalizeClass(unref(containerCls))
65
+ }, [
66
+ !unref(trueReadonly) ? (openBlock(), createBlock(unref(ElInput), mergeProps({
67
+ key: 0,
68
+ ref_key: "inputRef",
69
+ ref: inputRef,
70
+ modelValue: inputVal.value,
71
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inputVal.value = $event)
72
+ }, _ctx.inputProps, {
73
+ clearable: "",
74
+ size: unref(trueSize),
75
+ onKeyup: withKeys(change, ["enter"]),
76
+ onBlur: change
77
+ }), null, 16, ["modelValue", "size", "onKeyup"])) : (openBlock(), createElementBlock("div", {
78
+ key: 1,
79
+ class: normalizeClass(["width-100%", unref(spanClass)]),
80
+ onClick: edit
81
+ }, toDisplayString(inputVal.value || " "), 3))
82
+ ], 2);
83
+ };
84
+ }
85
+ });
86
+ var ClickInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "click-input.vue"]]);
24
87
 
25
- export { clickInputEmits, clickInputProps };
88
+ export { ClickInput as default };
26
89
  //# sourceMappingURL=click-input.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"click-input.mjs","sources":["../../../../../../packages/components/click-input/src/click-input.ts"],"sourcesContent":["import {buildProps, isString} from '@hzzt-plus/utils'\nimport {useSizeProp} from \"@hzzt-plus/hooks\";\n\nimport type { ExtractPropTypes } from 'vue'\nimport type ClickInput from './click-input.vue'\nimport {UPDATE_MODEL_EVENT} from \"@hzzt-plus/constants\";\n\nexport const clickInputProps = buildProps({\n modelValue: {\n type: String,\n default: '',\n },\n disabled: Boolean,\n readonly: Boolean,\n inputProps: Object,\n size: useSizeProp,\n})\n\nexport type ClickInputProps = ExtractPropTypes<typeof clickInputProps>\n\nexport const clickInputEmits = {\n [UPDATE_MODEL_EVENT]: (value: string) => isString(value),\n input: (value: string) => isString(value),\n change: (value: string) => isString(value),\n}\nexport type ClickInputEmits = typeof clickInputEmits\n\nexport type ClickInputInstance = InstanceType<typeof ClickInput>\n"],"names":[],"mappings":";;;;;;;;AAGY,MAAC,eAAe,GAAG,UAAU,CAAC;AAC1C,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,QAAQ,EAAE,OAAO;AACnB,EAAE,QAAQ,EAAE,OAAO;AACnB,EAAE,UAAU,EAAE,MAAM;AACpB,EAAE,IAAI,EAAE,WAAW;AACnB,CAAC,EAAE;AACS,MAAC,eAAe,GAAG;AAC/B,EAAE,CAAC,kBAAkB,GAAG,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,CAAC;AAClD,EAAE,KAAK,EAAE,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,CAAC;AACnC,EAAE,MAAM,EAAE,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,CAAC;AACpC;;;;"}
1
+ {"version":3,"file":"click-input.mjs","sources":["../../../../../../packages/components/click-input/src/click-input.vue"],"sourcesContent":["<template>\n <div :class=\"containerCls\">\n <el-input\n v-if=\"!trueReadonly\"\n ref=\"inputRef\"\n v-model=\"inputVal\"\n v-bind=\"inputProps\"\n clearable\n :size=\"trueSize\"\n @keyup.enter=\"change\"\n @blur=\"change\"\n />\n <div v-else class=\"width-100%\" :class=\"spanClass\" @click=\"edit\">\n {{ inputVal || ' ' }}\n </div>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\n import {computed, ref, watch, nextTick} from 'vue'\n import {clickInputEmits, clickInputProps} from './click-input'\n import {useGlobalSize, useNamespace} from \"@hzzt-plus/hooks\";\n import {useFormDisabled, useFormSize} from \"element-plus\";\n import {ElInput} from 'element-plus'\n\n defineOptions({\n name: 'HzztClickInput',\n })\n\n const props = defineProps(clickInputProps)\n const emit = defineEmits(clickInputEmits)\n\n const _inputVal = ref(props.modelValue || '');\n const inputVal = ref(props.modelValue || '');\n const inputRef = ref();\n const editable = ref(false);\n\n const nsInput = useNamespace('click-input')\n const formSize = useFormSize()\n const formDisabled = useFormDisabled()\n\n const trueSize = computed(\n () => props.size || formSize.value || useGlobalSize().value\n )\n\n const trueDisabled = computed(() => props.disabled || formDisabled.value)\n\n const trueReadonly = computed(() => trueDisabled.value || props.readonly || !editable.value)\n\n const containerCls = computed(() => [\n nsInput.b(),\n nsInput.m(trueSize.value),\n 'flex width-100% align-items-center',\n ])\n\n const spanClass = computed(() => [\n nsInput.e('span'),\n 'flex width-100% align-items-center',\n ])\n\n watch(() => props.modelValue, (v) => {\n inputVal.value = v || '';\n _inputVal.value = v || '';\n })\n\n function input(val: string) {\n emit('update:modelValue', val);\n emit('input', val);\n }\n\n function change() {\n editable.value = false;\n if (_inputVal.value === inputVal.value) {\n return;\n }\n input(inputVal.value);\n emit('change', inputVal.value);\n }\n\n function edit() {\n if (trueDisabled.value || props.readonly) {\n return;\n }\n editable.value = true;\n nextTick(() => {\n inputRef.value.focus();\n });\n }\n\n</script>\n"],"names":["_openBlock","_createElementBlock"],"mappings":";;;;;;;;mCAyBgB,CAAA;AAAA,EACZ,IAAM,EAAA,gBAAA;AACR,CAAA,CAAA,CAAA;;;;;;;AAKA,IAAA,MAAM,SAAY,GAAA,GAAA,CAAI,KAAM,CAAA,UAAA,IAAc,EAAE,CAAA,CAAA;AAC5C,IAAA,MAAM,QAAW,GAAA,GAAA,CAAI,KAAM,CAAA,UAAA,IAAc,EAAE,CAAA,CAAA;AAC3C,IAAA,MAAM,WAAW,GAAI,EAAA,CAAA;AACrB,IAAM,MAAA,QAAA,GAAW,IAAI,KAAK,CAAA,CAAA;AAE1B,IAAM,MAAA,OAAA,GAAU,aAAa,aAAa,CAAA,CAAA;AAC1C,IAAA,MAAM,WAAW,WAAY,EAAA,CAAA;AAC7B,IAAA,MAAM,eAAe,eAAgB,EAAA,CAAA;AAErC,IAAA,MAAM,QAAW,GAAA,QAAA,CAAA,MAAA,KAAA,CAAA,IAAA,IAAA,QAAA,CAAA,KAAA,IAAA,aAAA,EAAA,CAAA,KAAA,CAAA,CAAA;AAAA,IAAA,kBACH,GAAA,QAAiB,CAAA,MAAA,kBAAuB,YAAE,CAAA,KAAA,CAAA,CAAA;AAAA,IACxD,MAAA,YAAA,GAAA,QAAA,CAAA,MAAA,YAAA,CAAA,KAAA,IAAA,KAAA,CAAA,QAAA,IAAA,CAAA,QAAA,CAAA,KAAA,CAAA,CAAA;AAEA,IAAA,MAAM,eAAe,QAAS,CAAA,MAAM;AAEpC,MAAM,OAAA,CAAA,CAAA,EAAA;AAEN,MAAM,OAAA,CAAA,CAAA,CAAA,QAAA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