@atscript/vue-form 0.1.58
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/LICENSE +21 -0
- package/README.md +35 -0
- package/dist/as-action-71f9E_bL.cjs +208 -0
- package/dist/as-action-DU17rykn.mjs +203 -0
- package/dist/as-action.cjs +2 -0
- package/dist/as-action.d.cts +2 -0
- package/dist/as-action.d.mts +2 -0
- package/dist/as-action.mjs +2 -0
- package/dist/as-action.vue-BdbAOZCL.d.cts +13 -0
- package/dist/as-action.vue-CmY3eil1.d.mts +13 -0
- package/dist/as-adornment-shell-9UmdNIPR.cjs +97 -0
- package/dist/as-adornment-shell-knFiB7Ct.mjs +92 -0
- package/dist/as-array-Bn27x9cq.cjs +466 -0
- package/dist/as-array-DwarTaKP.mjs +455 -0
- package/dist/as-array-clear-btn-DAGervXL.cjs +48 -0
- package/dist/as-array-clear-btn-DIhzCKC9.mjs +43 -0
- package/dist/as-array.cjs +11 -0
- package/dist/as-array.d.cts +2 -0
- package/dist/as-array.d.mts +2 -0
- package/dist/as-array.mjs +11 -0
- package/dist/as-array.vue-C5r_ycIa.d.mts +9 -0
- package/dist/as-array.vue-CeBZRVm7.d.cts +9 -0
- package/dist/as-checkbox-B_9mwla6.mjs +285 -0
- package/dist/as-checkbox-DXGTVHPE.cjs +296 -0
- package/dist/as-checkbox.cjs +6 -0
- package/dist/as-checkbox.d.cts +2 -0
- package/dist/as-checkbox.d.mts +2 -0
- package/dist/as-checkbox.mjs +6 -0
- package/dist/as-checkbox.vue-BL53Xjmi.d.mts +9 -0
- package/dist/as-checkbox.vue-Da1KVG5J.d.cts +9 -0
- package/dist/as-collapsible-CqxeJut7.cjs +148 -0
- package/dist/as-collapsible-DtNCofNT.mjs +143 -0
- package/dist/as-date-C7tFQDkh.mjs +253 -0
- package/dist/as-date-k3MW3dmA.cjs +258 -0
- package/dist/as-date.cjs +8 -0
- package/dist/as-date.d.cts +2 -0
- package/dist/as-date.d.mts +2 -0
- package/dist/as-date.mjs +8 -0
- package/dist/as-date.vue-C5JaS3Sd.d.mts +9 -0
- package/dist/as-date.vue-e2ewS_V4.d.cts +9 -0
- package/dist/as-datetime-C030mzI5.cjs +258 -0
- package/dist/as-datetime-elcOoDT5.mjs +253 -0
- package/dist/as-datetime.cjs +8 -0
- package/dist/as-datetime.d.cts +2 -0
- package/dist/as-datetime.d.mts +2 -0
- package/dist/as-datetime.mjs +8 -0
- package/dist/as-datetime.vue-ClsSnJSV.d.mts +9 -0
- package/dist/as-datetime.vue-vfHFsby6.d.cts +9 -0
- package/dist/as-decimal-BJIGgPXU.cjs +711 -0
- package/dist/as-decimal-DtXjFPhe.mjs +694 -0
- package/dist/as-decimal.cjs +7 -0
- package/dist/as-decimal.d.cts +2 -0
- package/dist/as-decimal.d.mts +2 -0
- package/dist/as-decimal.mjs +7 -0
- package/dist/as-decimal.vue-B1pEKdjM.d.cts +25 -0
- package/dist/as-decimal.vue-CSCtYRRa.d.mts +25 -0
- package/dist/as-field-CXVjrEPQ.mjs +481 -0
- package/dist/as-field-shell-B2iTn-iM.cjs +346 -0
- package/dist/as-field-shell-Pdy3sAvr.mjs +341 -0
- package/dist/as-field-shell.cjs +5 -0
- package/dist/as-field-shell.d.cts +2 -0
- package/dist/as-field-shell.d.mts +2 -0
- package/dist/as-field-shell.mjs +5 -0
- package/dist/as-field-shell.vue-Ddnp8KxY.d.mts +37 -0
- package/dist/as-field-shell.vue-Dmt05vGD.d.cts +37 -0
- package/dist/as-field-wLYoaZnT.cjs +498 -0
- package/dist/as-field.cjs +4 -0
- package/dist/as-field.d.cts +25 -0
- package/dist/as-field.d.mts +26 -0
- package/dist/as-field.mjs +4 -0
- package/dist/as-form-CWwgyvfw.mjs +425 -0
- package/dist/as-form-DAIkyt7H.cjs +448 -0
- package/dist/as-form.cjs +7 -0
- package/dist/as-form.d.cts +2 -0
- package/dist/as-form.d.mts +2 -0
- package/dist/as-form.mjs +7 -0
- package/dist/as-form.vue-B4Bn0pbC.d.cts +158 -0
- package/dist/as-form.vue-DRrb_yoj.d.mts +158 -0
- package/dist/as-input-CpbV2k3s.cjs +231 -0
- package/dist/as-input-DIa8BzLv.mjs +226 -0
- package/dist/as-input-control-BzELjheN.mjs +266 -0
- package/dist/as-input-control-C5-DelZT.cjs +271 -0
- package/dist/as-input.cjs +8 -0
- package/dist/as-input.d.cts +2 -0
- package/dist/as-input.d.mts +2 -0
- package/dist/as-input.mjs +8 -0
- package/dist/as-input.vue-11ldp9uT.d.cts +17 -0
- package/dist/as-input.vue-fUhcvfv2.d.mts +17 -0
- package/dist/as-iterator-BYMNe6UJ.cjs +61 -0
- package/dist/as-iterator-CT5y1jyn.mjs +56 -0
- package/dist/as-iterator.cjs +5 -0
- package/dist/as-iterator.d.cts +14 -0
- package/dist/as-iterator.d.mts +15 -0
- package/dist/as-iterator.mjs +5 -0
- package/dist/as-number-BA55JIq1.cjs +387 -0
- package/dist/as-number-JPEwPK8Q.mjs +376 -0
- package/dist/as-number.cjs +8 -0
- package/dist/as-number.d.cts +2 -0
- package/dist/as-number.d.mts +2 -0
- package/dist/as-number.mjs +8 -0
- package/dist/as-number.vue-Bk-W7Vwv.d.mts +26 -0
- package/dist/as-number.vue-C2Aih98s.d.cts +26 -0
- package/dist/as-object-CT6lNEqt.mjs +300 -0
- package/dist/as-object-qUL7l8V1.cjs +305 -0
- package/dist/as-object.cjs +11 -0
- package/dist/as-object.d.cts +2 -0
- package/dist/as-object.d.mts +2 -0
- package/dist/as-object.mjs +11 -0
- package/dist/as-object.vue-CKwMyM_F.d.cts +13 -0
- package/dist/as-object.vue-Cg52b61-.d.mts +13 -0
- package/dist/as-paragraph-BGO-j4US.cjs +203 -0
- package/dist/as-paragraph-jIG_dg7_.mjs +198 -0
- package/dist/as-paragraph.cjs +2 -0
- package/dist/as-paragraph.d.cts +2 -0
- package/dist/as-paragraph.d.mts +2 -0
- package/dist/as-paragraph.mjs +2 -0
- package/dist/as-paragraph.vue-BDt0pBG-.d.cts +9 -0
- package/dist/as-paragraph.vue-C3FgTEt5.d.mts +9 -0
- package/dist/as-radio-B1N-gmoI.mjs +242 -0
- package/dist/as-radio-U3OK7bTg.cjs +247 -0
- package/dist/as-radio.cjs +6 -0
- package/dist/as-radio.d.cts +2 -0
- package/dist/as-radio.d.mts +2 -0
- package/dist/as-radio.mjs +6 -0
- package/dist/as-radio.vue-D_fweoN1.d.mts +9 -0
- package/dist/as-radio.vue-ZC4kLBnT.d.cts +9 -0
- package/dist/as-ref-CIifSSCQ.mjs +337 -0
- package/dist/as-ref-SImaIrwK.cjs +342 -0
- package/dist/as-ref.cjs +7 -0
- package/dist/as-ref.d.cts +2 -0
- package/dist/as-ref.d.mts +2 -0
- package/dist/as-ref.mjs +7 -0
- package/dist/as-ref.vue-BNeQeQpO.d.cts +9 -0
- package/dist/as-ref.vue-Cr5jeNDn.d.mts +9 -0
- package/dist/as-select-BB3uxACS.cjs +246 -0
- package/dist/as-select-UBGCVhku.mjs +241 -0
- package/dist/as-select.cjs +6 -0
- package/dist/as-select.d.cts +2 -0
- package/dist/as-select.d.mts +2 -0
- package/dist/as-select.mjs +6 -0
- package/dist/as-select.vue-Dd7huPq2.d.cts +9 -0
- package/dist/as-select.vue-RYpbZbKt.d.mts +9 -0
- package/dist/as-time-C24rvslH.cjs +258 -0
- package/dist/as-time-CQsxUs8P.mjs +253 -0
- package/dist/as-time.cjs +8 -0
- package/dist/as-time.d.cts +2 -0
- package/dist/as-time.d.mts +2 -0
- package/dist/as-time.mjs +8 -0
- package/dist/as-time.vue-huLx2B4l.d.mts +9 -0
- package/dist/as-time.vue-nMEHLXke.d.cts +9 -0
- package/dist/as-tuple-BU--cuuI.cjs +351 -0
- package/dist/as-tuple-DkI9swlW.mjs +340 -0
- package/dist/as-tuple.cjs +11 -0
- package/dist/as-tuple.d.cts +2 -0
- package/dist/as-tuple.d.mts +2 -0
- package/dist/as-tuple.mjs +11 -0
- package/dist/as-tuple.vue-CQhzOJsn.d.mts +9 -0
- package/dist/as-tuple.vue-DyskCkf-.d.cts +9 -0
- package/dist/as-union-BGvdxr3G.mjs +351 -0
- package/dist/as-union-C0btoJn3.cjs +368 -0
- package/dist/as-union.cjs +6 -0
- package/dist/as-union.d.cts +2 -0
- package/dist/as-union.d.mts +2 -0
- package/dist/as-union.mjs +6 -0
- package/dist/as-union.vue-BjlDPZn0.d.mts +9 -0
- package/dist/as-union.vue-CqjU3O10.d.cts +9 -0
- package/dist/as-variant-picker-BVs0AvjK.mjs +96 -0
- package/dist/as-variant-picker-DObQZHmm.cjs +107 -0
- package/dist/index.cjs +173 -0
- package/dist/index.d.cts +966 -0
- package/dist/index.d.mts +966 -0
- package/dist/index.mjs +105 -0
- package/dist/types-C4HRSxgV.d.cts +233 -0
- package/dist/types-Czm-Gtud.d.mts +233 -0
- package/dist/use-as-date-B7CtcRQd.cjs +329 -0
- package/dist/use-as-date-C39i9mzE.mjs +318 -0
- package/dist/use-as-dropdown-BMnEm6jF.mjs +82 -0
- package/dist/use-as-dropdown-C-Qy7Vt0.cjs +105 -0
- package/dist/use-as-locale-BrFdAgnU.mjs +23 -0
- package/dist/use-as-locale-C4z5stwD.cjs +34 -0
- package/dist/use-as-nested-sections-store-jdMRxjBE.cjs +80 -0
- package/dist/use-as-nested-sections-store-lhi0z5z1.mjs +63 -0
- package/dist/use-as-optional-add-flow-CuXEir_i.mjs +43 -0
- package/dist/use-as-optional-add-flow-STOaQWo9.cjs +48 -0
- package/dist/use-as-value-help-CBykDEjZ.mjs +89 -0
- package/dist/use-as-value-help-uANI3zWa.cjs +100 -0
- package/dist/use-form-context-Dwr8Ai1v.cjs +207 -0
- package/dist/use-form-context-bAj7UoSe.mjs +106 -0
- package/package.json +180 -0
- package/styles.d.ts +2 -0
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
const require_use_form_context = require("./use-form-context-Dwr8Ai1v.cjs");
|
|
2
|
+
const require_as_field = require("./as-field-wLYoaZnT.cjs");
|
|
3
|
+
const require_use_as_dropdown = require("./use-as-dropdown-C-Qy7Vt0.cjs");
|
|
4
|
+
const require_as_variant_picker = require("./as-variant-picker-DObQZHmm.cjs");
|
|
5
|
+
const require_use_as_optional_add_flow = require("./use-as-optional-add-flow-STOaQWo9.cjs");
|
|
6
|
+
const require_as_collapsible = require("./as-collapsible-CqxeJut7.cjs");
|
|
7
|
+
const require_as_array_clear_btn = require("./as-array-clear-btn-DAGervXL.cjs");
|
|
8
|
+
let vue = require("vue");
|
|
9
|
+
let _atscript_ui = require("@atscript/ui");
|
|
10
|
+
//#region src/composables/use-as-array.ts
|
|
11
|
+
/**
|
|
12
|
+
* Composable for managing array field state.
|
|
13
|
+
*
|
|
14
|
+
* Manages stable keys, add/remove with constraints, and item field resolution.
|
|
15
|
+
* Union item types are handled transparently — AsUnion manages variant state locally.
|
|
16
|
+
* Used by the default `AsArray` component and available for custom array components.
|
|
17
|
+
*/
|
|
18
|
+
function useAsArray(field, disabled) {
|
|
19
|
+
const { rootFormData, formContext, pathPrefix, getByPath, setByPath } = require_use_form_context.useFormContext("useAsArray");
|
|
20
|
+
const handleChange = (0, vue.inject)(require_use_form_context.CHANGE_HANDLER_KEY, () => {});
|
|
21
|
+
const arrayValue = (0, vue.computed)(() => {
|
|
22
|
+
const v = getByPath(pathPrefix.value);
|
|
23
|
+
return Array.isArray(v) ? v : [];
|
|
24
|
+
});
|
|
25
|
+
const isOptional = field.prop.optional ?? false;
|
|
26
|
+
const isEmpty = (0, vue.computed)(() => arrayValue.value.length === 0);
|
|
27
|
+
let keyCounter = 0;
|
|
28
|
+
const itemKeys = (0, vue.reactive)([]);
|
|
29
|
+
function generateKey() {
|
|
30
|
+
return `as-item-${keyCounter++}`;
|
|
31
|
+
}
|
|
32
|
+
function syncKeys() {
|
|
33
|
+
const newLen = arrayValue.value.length;
|
|
34
|
+
while (itemKeys.length < newLen) itemKeys.push(generateKey());
|
|
35
|
+
if (itemKeys.length > newLen) {
|
|
36
|
+
for (const key of itemFieldCache.keys()) if (key >= newLen) itemFieldCache.delete(key);
|
|
37
|
+
itemKeys.length = newLen;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
syncKeys();
|
|
41
|
+
(0, vue.watch)(() => arrayValue.value.length, () => syncKeys());
|
|
42
|
+
const isUnion = (0, _atscript_ui.isUnionField)(field.itemField);
|
|
43
|
+
const unionVariants = isUnion ? field.itemField.unionVariants : [];
|
|
44
|
+
const itemFieldCache = /* @__PURE__ */ new Map();
|
|
45
|
+
function getItemField(index, name = "") {
|
|
46
|
+
const cached = itemFieldCache.get(index);
|
|
47
|
+
if (cached && cached.name === name) return cached;
|
|
48
|
+
const fresh = {
|
|
49
|
+
...field.itemField,
|
|
50
|
+
path: String(index),
|
|
51
|
+
name
|
|
52
|
+
};
|
|
53
|
+
itemFieldCache.set(index, fresh);
|
|
54
|
+
return fresh;
|
|
55
|
+
}
|
|
56
|
+
const minLength = (0, _atscript_ui.getFieldMeta)(field.prop, "expect.minLength")?.length ?? 0;
|
|
57
|
+
const maxLength = (0, _atscript_ui.getFieldMeta)(field.prop, "expect.maxLength")?.length ?? Infinity;
|
|
58
|
+
const canAdd = (0, vue.computed)(() => !disabled?.value && arrayValue.value.length < maxLength);
|
|
59
|
+
const canRemove = (0, vue.computed)(() => !disabled?.value && arrayValue.value.length > minLength);
|
|
60
|
+
function ensureArray() {
|
|
61
|
+
let arr = getByPath(pathPrefix.value);
|
|
62
|
+
if (!Array.isArray(arr)) {
|
|
63
|
+
arr = [];
|
|
64
|
+
setByPath(pathPrefix.value, arr);
|
|
65
|
+
}
|
|
66
|
+
return arr;
|
|
67
|
+
}
|
|
68
|
+
function addItem(variantIndex = 0) {
|
|
69
|
+
if (!canAdd.value) return;
|
|
70
|
+
const resolver = (0, _atscript_ui.createFormValueResolver)(rootFormData().value, formContext.value);
|
|
71
|
+
let newItem;
|
|
72
|
+
if (isUnion) {
|
|
73
|
+
const variant = unionVariants[variantIndex];
|
|
74
|
+
if (!variant) return;
|
|
75
|
+
newItem = (0, _atscript_ui.createFormData)(variant.type, resolver).value;
|
|
76
|
+
} else newItem = (0, _atscript_ui.createFormData)(field.itemType, resolver).value;
|
|
77
|
+
ensureArray().push(newItem);
|
|
78
|
+
itemKeys.push(generateKey());
|
|
79
|
+
handleChange("array-add", pathPrefix.value, arrayValue.value);
|
|
80
|
+
}
|
|
81
|
+
function removeItem(index) {
|
|
82
|
+
if (!canRemove.value) return;
|
|
83
|
+
ensureArray().splice(index, 1);
|
|
84
|
+
itemKeys.splice(index, 1);
|
|
85
|
+
for (const key of itemFieldCache.keys()) if (key >= index) itemFieldCache.delete(key);
|
|
86
|
+
handleChange("array-remove", pathPrefix.value, arrayValue.value);
|
|
87
|
+
}
|
|
88
|
+
function clear() {
|
|
89
|
+
if (isOptional) setByPath(pathPrefix.value, void 0);
|
|
90
|
+
else {
|
|
91
|
+
const arr = getByPath(pathPrefix.value);
|
|
92
|
+
if (Array.isArray(arr)) arr.length = 0;
|
|
93
|
+
}
|
|
94
|
+
itemFieldCache.clear();
|
|
95
|
+
handleChange("array-remove", pathPrefix.value, arrayValue.value);
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
arrayValue,
|
|
99
|
+
itemKeys,
|
|
100
|
+
isUnion,
|
|
101
|
+
unionVariants,
|
|
102
|
+
isOptional,
|
|
103
|
+
isEmpty,
|
|
104
|
+
getItemField,
|
|
105
|
+
addItem,
|
|
106
|
+
removeItem,
|
|
107
|
+
clear,
|
|
108
|
+
canAdd,
|
|
109
|
+
canRemove
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/components/internal/as-items-chip.vue?vue&type=script&setup=true&lang.ts
|
|
114
|
+
const _hoisted_1$1 = { class: "as-array-items-chip" };
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/components/internal/as-items-chip.vue
|
|
117
|
+
var as_items_chip_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
118
|
+
__name: "as-items-chip",
|
|
119
|
+
props: { count: {
|
|
120
|
+
type: Number,
|
|
121
|
+
required: true
|
|
122
|
+
} },
|
|
123
|
+
setup(__props) {
|
|
124
|
+
return (_ctx, _cache) => {
|
|
125
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_1$1, (0, vue.toDisplayString)(__props.count) + " items", 1);
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/components/defaults/as-array.vue?vue&type=script&setup=true&lang.ts
|
|
131
|
+
const _hoisted_1 = { class: "as-array-add-row" };
|
|
132
|
+
const _hoisted_2 = ["disabled"];
|
|
133
|
+
const _hoisted_3 = ["disabled"];
|
|
134
|
+
const _hoisted_4 = {
|
|
135
|
+
key: 0,
|
|
136
|
+
class: "as-dropdown-menu"
|
|
137
|
+
};
|
|
138
|
+
const _hoisted_5 = ["onClick"];
|
|
139
|
+
const _hoisted_6 = {
|
|
140
|
+
key: 0,
|
|
141
|
+
class: "as-collapsible-description"
|
|
142
|
+
};
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/components/defaults/as-array.vue
|
|
145
|
+
var as_array_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
146
|
+
__name: "as-array",
|
|
147
|
+
props: {
|
|
148
|
+
onBlur: {
|
|
149
|
+
type: Function,
|
|
150
|
+
required: true
|
|
151
|
+
},
|
|
152
|
+
error: {
|
|
153
|
+
type: String,
|
|
154
|
+
required: false
|
|
155
|
+
},
|
|
156
|
+
model: {
|
|
157
|
+
type: Object,
|
|
158
|
+
required: true
|
|
159
|
+
},
|
|
160
|
+
value: {
|
|
161
|
+
type: null,
|
|
162
|
+
required: false
|
|
163
|
+
},
|
|
164
|
+
label: {
|
|
165
|
+
type: String,
|
|
166
|
+
required: false
|
|
167
|
+
},
|
|
168
|
+
description: {
|
|
169
|
+
type: String,
|
|
170
|
+
required: false
|
|
171
|
+
},
|
|
172
|
+
hint: {
|
|
173
|
+
type: String,
|
|
174
|
+
required: false
|
|
175
|
+
},
|
|
176
|
+
placeholder: {
|
|
177
|
+
type: String,
|
|
178
|
+
required: false
|
|
179
|
+
},
|
|
180
|
+
prefixIcon: {
|
|
181
|
+
type: String,
|
|
182
|
+
required: false
|
|
183
|
+
},
|
|
184
|
+
suffixIcon: {
|
|
185
|
+
type: String,
|
|
186
|
+
required: false
|
|
187
|
+
},
|
|
188
|
+
class: {
|
|
189
|
+
type: [Object, String],
|
|
190
|
+
required: false
|
|
191
|
+
},
|
|
192
|
+
style: {
|
|
193
|
+
type: [Object, String],
|
|
194
|
+
required: false
|
|
195
|
+
},
|
|
196
|
+
optional: {
|
|
197
|
+
type: Boolean,
|
|
198
|
+
required: false,
|
|
199
|
+
skipCheck: true
|
|
200
|
+
},
|
|
201
|
+
onToggleOptional: {
|
|
202
|
+
type: Function,
|
|
203
|
+
required: false
|
|
204
|
+
},
|
|
205
|
+
required: {
|
|
206
|
+
type: Boolean,
|
|
207
|
+
required: false,
|
|
208
|
+
skipCheck: true
|
|
209
|
+
},
|
|
210
|
+
readonly: {
|
|
211
|
+
type: Boolean,
|
|
212
|
+
required: false,
|
|
213
|
+
skipCheck: true
|
|
214
|
+
},
|
|
215
|
+
type: {
|
|
216
|
+
type: String,
|
|
217
|
+
required: true
|
|
218
|
+
},
|
|
219
|
+
formAction: {
|
|
220
|
+
type: Object,
|
|
221
|
+
required: false
|
|
222
|
+
},
|
|
223
|
+
name: {
|
|
224
|
+
type: String,
|
|
225
|
+
required: false
|
|
226
|
+
},
|
|
227
|
+
field: {
|
|
228
|
+
type: Object,
|
|
229
|
+
required: false
|
|
230
|
+
},
|
|
231
|
+
options: {
|
|
232
|
+
type: Array,
|
|
233
|
+
required: false
|
|
234
|
+
},
|
|
235
|
+
maxLength: {
|
|
236
|
+
type: Number,
|
|
237
|
+
required: false
|
|
238
|
+
},
|
|
239
|
+
autocomplete: {
|
|
240
|
+
type: String,
|
|
241
|
+
required: false
|
|
242
|
+
},
|
|
243
|
+
title: {
|
|
244
|
+
type: String,
|
|
245
|
+
required: false
|
|
246
|
+
},
|
|
247
|
+
level: {
|
|
248
|
+
type: Number,
|
|
249
|
+
required: false
|
|
250
|
+
},
|
|
251
|
+
onRemove: {
|
|
252
|
+
type: Function,
|
|
253
|
+
required: false
|
|
254
|
+
},
|
|
255
|
+
canRemove: {
|
|
256
|
+
type: Boolean,
|
|
257
|
+
required: false
|
|
258
|
+
},
|
|
259
|
+
removeLabel: {
|
|
260
|
+
type: String,
|
|
261
|
+
required: false
|
|
262
|
+
},
|
|
263
|
+
arrayIndex: {
|
|
264
|
+
type: Number,
|
|
265
|
+
required: false
|
|
266
|
+
},
|
|
267
|
+
path: {
|
|
268
|
+
type: String,
|
|
269
|
+
required: true
|
|
270
|
+
},
|
|
271
|
+
valueHelp: {
|
|
272
|
+
type: Object,
|
|
273
|
+
required: false
|
|
274
|
+
},
|
|
275
|
+
singularLabel: {
|
|
276
|
+
type: String,
|
|
277
|
+
required: false
|
|
278
|
+
},
|
|
279
|
+
inputId: {
|
|
280
|
+
type: String,
|
|
281
|
+
required: true
|
|
282
|
+
},
|
|
283
|
+
errorId: {
|
|
284
|
+
type: String,
|
|
285
|
+
required: true
|
|
286
|
+
},
|
|
287
|
+
descId: {
|
|
288
|
+
type: String,
|
|
289
|
+
required: true
|
|
290
|
+
},
|
|
291
|
+
ariaDescribedBy: {
|
|
292
|
+
type: String,
|
|
293
|
+
required: false
|
|
294
|
+
},
|
|
295
|
+
currencyCode: {
|
|
296
|
+
type: String,
|
|
297
|
+
required: false
|
|
298
|
+
},
|
|
299
|
+
unitCode: {
|
|
300
|
+
type: String,
|
|
301
|
+
required: false
|
|
302
|
+
},
|
|
303
|
+
precisionScale: {
|
|
304
|
+
type: Number,
|
|
305
|
+
required: false
|
|
306
|
+
},
|
|
307
|
+
prefix: {
|
|
308
|
+
type: String,
|
|
309
|
+
required: false
|
|
310
|
+
},
|
|
311
|
+
suffix: {
|
|
312
|
+
type: String,
|
|
313
|
+
required: false
|
|
314
|
+
},
|
|
315
|
+
scale: {
|
|
316
|
+
type: Number,
|
|
317
|
+
required: false
|
|
318
|
+
},
|
|
319
|
+
hasAdornment: {
|
|
320
|
+
type: Boolean,
|
|
321
|
+
required: false
|
|
322
|
+
},
|
|
323
|
+
disabled: {
|
|
324
|
+
type: Boolean,
|
|
325
|
+
required: false
|
|
326
|
+
},
|
|
327
|
+
hidden: {
|
|
328
|
+
type: Boolean,
|
|
329
|
+
required: false
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
setup(__props) {
|
|
333
|
+
const props = __props;
|
|
334
|
+
const arrayField = props.field;
|
|
335
|
+
const unionCtx = require_use_form_context.useAsUnionVariant();
|
|
336
|
+
const hasVariantPicker = (0, vue.computed)(() => unionCtx !== void 0 && unionCtx.variants.length > 1);
|
|
337
|
+
const optionalEnabled = (0, vue.computed)(() => Array.isArray(props.model?.value));
|
|
338
|
+
const disabled = (0, vue.computed)(() => props.disabled ?? false);
|
|
339
|
+
const { arrayValue, itemKeys, isUnion, unionVariants, isOptional, isEmpty, getItemField, addItem, removeItem, clear, canAdd, canRemove } = useAsArray(arrayField, disabled);
|
|
340
|
+
const level = (0, vue.computed)(() => props.level ?? 0);
|
|
341
|
+
const singular = props.singularLabel ?? "item";
|
|
342
|
+
const defaultOpen = !isOptional;
|
|
343
|
+
const addDropdownRef = (0, vue.ref)(null);
|
|
344
|
+
const { isOpen: addOpen, toggle: toggleAdd, select: selectAdd } = require_use_as_dropdown.useAsDropdown(addDropdownRef);
|
|
345
|
+
const collapsibleRef = (0, vue.useTemplateRef)("collapsibleRef");
|
|
346
|
+
const { composeAction } = require_use_as_optional_add_flow.useAsOptionalAddFlow({ path: () => props.path });
|
|
347
|
+
function fieldFor(idx) {
|
|
348
|
+
return getItemField(idx, singular);
|
|
349
|
+
}
|
|
350
|
+
function handleAdd(variantIndex = 0) {
|
|
351
|
+
collapsibleRef.value?.runAndFocusNew(composeAction(() => addItem(variantIndex)), 1);
|
|
352
|
+
}
|
|
353
|
+
function handleEnableOptional() {
|
|
354
|
+
collapsibleRef.value?.runAndFocusNew(composeAction(() => {
|
|
355
|
+
props.onToggleOptional?.(true);
|
|
356
|
+
addItem(0);
|
|
357
|
+
}), 2);
|
|
358
|
+
}
|
|
359
|
+
return (_ctx, _cache) => {
|
|
360
|
+
return (0, vue.openBlock)(), (0, vue.createBlock)(require_as_collapsible.as_collapsible_default, {
|
|
361
|
+
ref_key: "collapsibleRef",
|
|
362
|
+
ref: collapsibleRef,
|
|
363
|
+
class: (0, vue.normalizeClass)(_ctx.$props.class),
|
|
364
|
+
title: __props.title,
|
|
365
|
+
"array-index": __props.arrayIndex,
|
|
366
|
+
description: __props.description,
|
|
367
|
+
level: level.value,
|
|
368
|
+
optional: !!__props.optional,
|
|
369
|
+
"optional-enabled": optionalEnabled.value,
|
|
370
|
+
path: __props.path,
|
|
371
|
+
error: __props.error,
|
|
372
|
+
hidden: __props.hidden,
|
|
373
|
+
"default-open": defaultOpen
|
|
374
|
+
}, {
|
|
375
|
+
"title-extras": (0, vue.withCtx)(() => [hasVariantPicker.value ? ((0, vue.openBlock)(), (0, vue.createBlock)(require_as_variant_picker.as_variant_picker_default, {
|
|
376
|
+
key: 0,
|
|
377
|
+
"union-context": (0, vue.unref)(unionCtx),
|
|
378
|
+
disabled: disabled.value
|
|
379
|
+
}, null, 8, ["union-context", "disabled"])) : (0, vue.createCommentVNode)("v-if", true)]),
|
|
380
|
+
badges: (0, vue.withCtx)(() => [(0, vue.createVNode)(as_items_chip_default, { count: (0, vue.unref)(arrayValue).length }, null, 8, ["count"])]),
|
|
381
|
+
actions: (0, vue.withCtx)(() => [(0, vue.createCommentVNode)(" Hide Clear only when required+empty: optional arrays keep it\n so the user can collapse back to undefined. "), (0, vue.unref)(isOptional) || !(0, vue.unref)(isEmpty) ? ((0, vue.openBlock)(), (0, vue.createBlock)(require_as_array_clear_btn.as_array_clear_btn_default, {
|
|
382
|
+
key: 0,
|
|
383
|
+
label: __props.title,
|
|
384
|
+
optional: (0, vue.unref)(isOptional),
|
|
385
|
+
disabled: disabled.value,
|
|
386
|
+
onClear: (0, vue.unref)(clear)
|
|
387
|
+
}, null, 8, [
|
|
388
|
+
"label",
|
|
389
|
+
"optional",
|
|
390
|
+
"disabled",
|
|
391
|
+
"onClear"
|
|
392
|
+
])) : (0, vue.createCommentVNode)("v-if", true)]),
|
|
393
|
+
body: (0, vue.withCtx)(() => [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)((0, vue.unref)(arrayValue), (_item, idx) => {
|
|
394
|
+
return (0, vue.openBlock)(), (0, vue.createBlock)(require_as_field.as_field_default, {
|
|
395
|
+
key: (0, vue.unref)(itemKeys)[idx],
|
|
396
|
+
field: fieldFor(idx),
|
|
397
|
+
"array-index": idx,
|
|
398
|
+
"on-remove": () => (0, vue.unref)(removeItem)(idx),
|
|
399
|
+
"can-remove": (0, vue.unref)(canRemove)
|
|
400
|
+
}, null, 8, [
|
|
401
|
+
"field",
|
|
402
|
+
"array-index",
|
|
403
|
+
"on-remove",
|
|
404
|
+
"can-remove"
|
|
405
|
+
]);
|
|
406
|
+
}), 128)), (0, vue.createElementVNode)("div", _hoisted_1, [!(0, vue.unref)(isUnion) ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("button", {
|
|
407
|
+
key: 0,
|
|
408
|
+
type: "button",
|
|
409
|
+
class: "as-array-add-btn",
|
|
410
|
+
disabled: !(0, vue.unref)(canAdd),
|
|
411
|
+
onClick: _cache[0] || (_cache[0] = ($event) => handleAdd(0))
|
|
412
|
+
}, " Add " + (0, vue.toDisplayString)((0, vue.unref)(singular)), 9, _hoisted_2)) : ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
|
|
413
|
+
key: 1,
|
|
414
|
+
ref_key: "addDropdownRef",
|
|
415
|
+
ref: addDropdownRef,
|
|
416
|
+
class: "as-dropdown"
|
|
417
|
+
}, [(0, vue.createElementVNode)("button", {
|
|
418
|
+
type: "button",
|
|
419
|
+
class: "as-array-add-btn",
|
|
420
|
+
disabled: !(0, vue.unref)(canAdd),
|
|
421
|
+
onClick: _cache[1] || (_cache[1] = (...args) => (0, vue.unref)(toggleAdd) && (0, vue.unref)(toggleAdd)(...args))
|
|
422
|
+
}, " Add " + (0, vue.toDisplayString)((0, vue.unref)(singular)), 9, _hoisted_3), (0, vue.unref)(addOpen) ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_4, [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)((0, vue.unref)(unionVariants), (v, vi) => {
|
|
423
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)("button", {
|
|
424
|
+
key: vi,
|
|
425
|
+
type: "button",
|
|
426
|
+
class: "as-dropdown-item",
|
|
427
|
+
onClick: ($event) => (0, vue.unref)(selectAdd)(() => handleAdd(vi))
|
|
428
|
+
}, (0, vue.toDisplayString)(v.label), 9, _hoisted_5);
|
|
429
|
+
}), 128))])) : (0, vue.createCommentVNode)("v-if", true)], 512))])]),
|
|
430
|
+
empty: (0, vue.withCtx)(() => [(0, vue.withDirectives)((0, vue.createElementVNode)("div", { class: (0, vue.normalizeClass)(["as-object-empty as-grid-item", _ctx.$props.class]) }, [(0, vue.createElementVNode)("button", {
|
|
431
|
+
type: "button",
|
|
432
|
+
class: "as-object-empty-add",
|
|
433
|
+
onClick: handleEnableOptional
|
|
434
|
+
}, [_cache[2] || (_cache[2] = (0, vue.createElementVNode)("span", {
|
|
435
|
+
class: "i-as-field-fill as-object-empty-add-icon",
|
|
436
|
+
"aria-hidden": "true"
|
|
437
|
+
}, null, -1)), (0, vue.createTextVNode)(" Add " + (0, vue.toDisplayString)(__props.title), 1)]), __props.description ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("p", _hoisted_6, (0, vue.toDisplayString)(__props.description), 1)) : (0, vue.createCommentVNode)("v-if", true)], 2), [[vue.vShow, !__props.hidden]])]),
|
|
438
|
+
_: 1
|
|
439
|
+
}, 8, [
|
|
440
|
+
"class",
|
|
441
|
+
"title",
|
|
442
|
+
"array-index",
|
|
443
|
+
"description",
|
|
444
|
+
"level",
|
|
445
|
+
"optional",
|
|
446
|
+
"optional-enabled",
|
|
447
|
+
"path",
|
|
448
|
+
"error",
|
|
449
|
+
"hidden"
|
|
450
|
+
]);
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
//#endregion
|
|
455
|
+
Object.defineProperty(exports, "as_array_default", {
|
|
456
|
+
enumerable: true,
|
|
457
|
+
get: function() {
|
|
458
|
+
return as_array_default;
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
Object.defineProperty(exports, "useAsArray", {
|
|
462
|
+
enumerable: true,
|
|
463
|
+
get: function() {
|
|
464
|
+
return useAsArray;
|
|
465
|
+
}
|
|
466
|
+
});
|