@atscript/vue-aooth 0.1.75
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/dist/as-consent-array-B8gtVvew.cjs +346 -0
- package/dist/as-consent-array-C1GpSvgX.mjs +341 -0
- package/dist/as-consent-array.cjs +2 -0
- package/dist/as-consent-array.d.cts +25 -0
- package/dist/as-consent-array.d.mts +25 -0
- package/dist/as-consent-array.mjs +2 -0
- package/dist/as-password-rules-DkFih-lL.cjs +271 -0
- package/dist/as-password-rules-f9ouYgev.mjs +266 -0
- package/dist/as-password-rules.cjs +2 -0
- package/dist/as-password-rules.d.cts +27 -0
- package/dist/as-password-rules.d.mts +27 -0
- package/dist/as-password-rules.mjs +2 -0
- package/dist/index.cjs +5 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +3 -0
- package/package.json +81 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Artem Maltsev <artem@maltsev.nl>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
let vue = require("vue");
|
|
2
|
+
let _atscript_vue_form = require("@atscript/vue-form");
|
|
3
|
+
let _atscript_ui = require("@atscript/ui");
|
|
4
|
+
//#region src/components/as-consent-array.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
const _hoisted_1 = ["for"];
|
|
6
|
+
const _hoisted_2 = [
|
|
7
|
+
"id",
|
|
8
|
+
"checked",
|
|
9
|
+
"name",
|
|
10
|
+
"disabled",
|
|
11
|
+
"readonly",
|
|
12
|
+
"aria-required",
|
|
13
|
+
"aria-invalid",
|
|
14
|
+
"aria-describedby",
|
|
15
|
+
"onChange"
|
|
16
|
+
];
|
|
17
|
+
const _hoisted_3 = ["href"];
|
|
18
|
+
const _hoisted_4 = ["id"];
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/components/as-consent-array.vue
|
|
21
|
+
var as_consent_array_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
22
|
+
__name: "as-consent-array",
|
|
23
|
+
props: {
|
|
24
|
+
onBlur: {
|
|
25
|
+
type: Function,
|
|
26
|
+
required: true
|
|
27
|
+
},
|
|
28
|
+
error: {
|
|
29
|
+
type: String,
|
|
30
|
+
required: false
|
|
31
|
+
},
|
|
32
|
+
model: {
|
|
33
|
+
type: Object,
|
|
34
|
+
required: true
|
|
35
|
+
},
|
|
36
|
+
value: {
|
|
37
|
+
type: null,
|
|
38
|
+
required: false
|
|
39
|
+
},
|
|
40
|
+
label: {
|
|
41
|
+
type: String,
|
|
42
|
+
required: false
|
|
43
|
+
},
|
|
44
|
+
description: {
|
|
45
|
+
type: String,
|
|
46
|
+
required: false
|
|
47
|
+
},
|
|
48
|
+
hint: {
|
|
49
|
+
type: String,
|
|
50
|
+
required: false
|
|
51
|
+
},
|
|
52
|
+
placeholder: {
|
|
53
|
+
type: String,
|
|
54
|
+
required: false
|
|
55
|
+
},
|
|
56
|
+
prefixIcon: {
|
|
57
|
+
type: String,
|
|
58
|
+
required: false
|
|
59
|
+
},
|
|
60
|
+
suffixIcon: {
|
|
61
|
+
type: String,
|
|
62
|
+
required: false
|
|
63
|
+
},
|
|
64
|
+
class: {
|
|
65
|
+
type: [Object, String],
|
|
66
|
+
required: false
|
|
67
|
+
},
|
|
68
|
+
style: {
|
|
69
|
+
type: [Object, String],
|
|
70
|
+
required: false
|
|
71
|
+
},
|
|
72
|
+
optional: {
|
|
73
|
+
type: Boolean,
|
|
74
|
+
required: false,
|
|
75
|
+
skipCheck: true
|
|
76
|
+
},
|
|
77
|
+
onToggleOptional: {
|
|
78
|
+
type: Function,
|
|
79
|
+
required: false
|
|
80
|
+
},
|
|
81
|
+
required: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
required: false,
|
|
84
|
+
skipCheck: true
|
|
85
|
+
},
|
|
86
|
+
readonly: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
required: false,
|
|
89
|
+
skipCheck: true
|
|
90
|
+
},
|
|
91
|
+
type: {
|
|
92
|
+
type: String,
|
|
93
|
+
required: true
|
|
94
|
+
},
|
|
95
|
+
formAction: {
|
|
96
|
+
type: Object,
|
|
97
|
+
required: false
|
|
98
|
+
},
|
|
99
|
+
name: {
|
|
100
|
+
type: String,
|
|
101
|
+
required: false
|
|
102
|
+
},
|
|
103
|
+
field: {
|
|
104
|
+
type: Object,
|
|
105
|
+
required: false
|
|
106
|
+
},
|
|
107
|
+
options: {
|
|
108
|
+
type: Array,
|
|
109
|
+
required: false
|
|
110
|
+
},
|
|
111
|
+
maxLength: {
|
|
112
|
+
type: Number,
|
|
113
|
+
required: false
|
|
114
|
+
},
|
|
115
|
+
autocomplete: {
|
|
116
|
+
type: String,
|
|
117
|
+
required: false
|
|
118
|
+
},
|
|
119
|
+
title: {
|
|
120
|
+
type: String,
|
|
121
|
+
required: false
|
|
122
|
+
},
|
|
123
|
+
level: {
|
|
124
|
+
type: Number,
|
|
125
|
+
required: false
|
|
126
|
+
},
|
|
127
|
+
onRemove: {
|
|
128
|
+
type: Function,
|
|
129
|
+
required: false
|
|
130
|
+
},
|
|
131
|
+
canRemove: {
|
|
132
|
+
type: Boolean,
|
|
133
|
+
required: false
|
|
134
|
+
},
|
|
135
|
+
removeLabel: {
|
|
136
|
+
type: String,
|
|
137
|
+
required: false
|
|
138
|
+
},
|
|
139
|
+
arrayIndex: {
|
|
140
|
+
type: Number,
|
|
141
|
+
required: false
|
|
142
|
+
},
|
|
143
|
+
path: {
|
|
144
|
+
type: String,
|
|
145
|
+
required: true
|
|
146
|
+
},
|
|
147
|
+
valueHelp: {
|
|
148
|
+
type: Object,
|
|
149
|
+
required: false
|
|
150
|
+
},
|
|
151
|
+
singularLabel: {
|
|
152
|
+
type: String,
|
|
153
|
+
required: false
|
|
154
|
+
},
|
|
155
|
+
inputId: {
|
|
156
|
+
type: String,
|
|
157
|
+
required: true
|
|
158
|
+
},
|
|
159
|
+
errorId: {
|
|
160
|
+
type: String,
|
|
161
|
+
required: true
|
|
162
|
+
},
|
|
163
|
+
descId: {
|
|
164
|
+
type: String,
|
|
165
|
+
required: true
|
|
166
|
+
},
|
|
167
|
+
ariaDescribedBy: {
|
|
168
|
+
type: String,
|
|
169
|
+
required: false
|
|
170
|
+
},
|
|
171
|
+
currencyCode: {
|
|
172
|
+
type: String,
|
|
173
|
+
required: false
|
|
174
|
+
},
|
|
175
|
+
unitCode: {
|
|
176
|
+
type: String,
|
|
177
|
+
required: false
|
|
178
|
+
},
|
|
179
|
+
precisionScale: {
|
|
180
|
+
type: Number,
|
|
181
|
+
required: false
|
|
182
|
+
},
|
|
183
|
+
prefix: {
|
|
184
|
+
type: String,
|
|
185
|
+
required: false
|
|
186
|
+
},
|
|
187
|
+
suffix: {
|
|
188
|
+
type: String,
|
|
189
|
+
required: false
|
|
190
|
+
},
|
|
191
|
+
scale: {
|
|
192
|
+
type: Number,
|
|
193
|
+
required: false
|
|
194
|
+
},
|
|
195
|
+
hasAdornment: {
|
|
196
|
+
type: Boolean,
|
|
197
|
+
required: false
|
|
198
|
+
},
|
|
199
|
+
disabled: {
|
|
200
|
+
type: Boolean,
|
|
201
|
+
required: false
|
|
202
|
+
},
|
|
203
|
+
hidden: {
|
|
204
|
+
type: Boolean,
|
|
205
|
+
required: false
|
|
206
|
+
},
|
|
207
|
+
pendingConsents: {
|
|
208
|
+
type: Array,
|
|
209
|
+
required: false
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
setup(__props) {
|
|
213
|
+
const props = __props;
|
|
214
|
+
function rowId(itemId) {
|
|
215
|
+
const safe = itemId.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
216
|
+
return `${props.inputId}-${safe}`;
|
|
217
|
+
}
|
|
218
|
+
const consents = (0, vue.computed)(() => props.pendingConsents ?? []);
|
|
219
|
+
const explicitLabel = (0, vue.computed)(() => {
|
|
220
|
+
const prop = props.field?.prop;
|
|
221
|
+
if (!prop) return void 0;
|
|
222
|
+
const meta = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.META_LABEL);
|
|
223
|
+
return typeof meta === "string" ? meta : void 0;
|
|
224
|
+
});
|
|
225
|
+
const { error: localError, onBlur } = (0, _atscript_vue_form.useAsField)({
|
|
226
|
+
getValue: () => props.model.value ?? [],
|
|
227
|
+
setValue: (v) => {
|
|
228
|
+
props.model.value = v;
|
|
229
|
+
},
|
|
230
|
+
rules: [(value) => {
|
|
231
|
+
for (const c of consents.value) if (c.required && !value.includes(c.id)) return c.required;
|
|
232
|
+
return true;
|
|
233
|
+
}],
|
|
234
|
+
path: () => props.path,
|
|
235
|
+
resetValue: []
|
|
236
|
+
});
|
|
237
|
+
const showRequiredErrors = (0, vue.computed)(() => !!localError.value);
|
|
238
|
+
function errorFor(item) {
|
|
239
|
+
if (!showRequiredErrors.value) return void 0;
|
|
240
|
+
if (!item.required) return void 0;
|
|
241
|
+
if ((props.model.value ?? []).includes(item.id)) return void 0;
|
|
242
|
+
return item.required;
|
|
243
|
+
}
|
|
244
|
+
function commit(id, on) {
|
|
245
|
+
const current = props.model.value ?? [];
|
|
246
|
+
if (on) {
|
|
247
|
+
if (current.indexOf(id) === -1) props.model.value = [...current, id];
|
|
248
|
+
} else {
|
|
249
|
+
const next = current.filter((v) => v !== id);
|
|
250
|
+
if (next.length !== current.length) props.model.value = next;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
function onChange(id, ev) {
|
|
254
|
+
commit(id, ev.target.checked);
|
|
255
|
+
}
|
|
256
|
+
const isChecked = (id) => (props.model.value ?? []).includes(id);
|
|
257
|
+
const MD_LINK_RE = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
258
|
+
const SAFE_SCHEME_RE = /^(?:https?:\/\/|mailto:)/i;
|
|
259
|
+
function parseConsentText(text) {
|
|
260
|
+
const segments = [];
|
|
261
|
+
let lastIndex = 0;
|
|
262
|
+
for (const match of text.matchAll(MD_LINK_RE)) {
|
|
263
|
+
const [full, label, href] = match;
|
|
264
|
+
const idx = match.index ?? 0;
|
|
265
|
+
if (idx > lastIndex) segments.push({
|
|
266
|
+
kind: "text",
|
|
267
|
+
value: text.slice(lastIndex, idx)
|
|
268
|
+
});
|
|
269
|
+
if (SAFE_SCHEME_RE.test(href)) segments.push({
|
|
270
|
+
kind: "link",
|
|
271
|
+
label,
|
|
272
|
+
href
|
|
273
|
+
});
|
|
274
|
+
else segments.push({
|
|
275
|
+
kind: "text",
|
|
276
|
+
value: full
|
|
277
|
+
});
|
|
278
|
+
lastIndex = idx + full.length;
|
|
279
|
+
}
|
|
280
|
+
if (lastIndex < text.length) segments.push({
|
|
281
|
+
kind: "text",
|
|
282
|
+
value: text.slice(lastIndex)
|
|
283
|
+
});
|
|
284
|
+
return segments;
|
|
285
|
+
}
|
|
286
|
+
const consentSegments = (0, vue.computed)(() => {
|
|
287
|
+
const map = /* @__PURE__ */ new Map();
|
|
288
|
+
for (const item of consents.value) map.set(item.id, parseConsentText(item.text));
|
|
289
|
+
return map;
|
|
290
|
+
});
|
|
291
|
+
return (_ctx, _cache) => {
|
|
292
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, null, [(0, vue.createCommentVNode)("\n `:error=\"undefined\"` suppresses the shell's footer error row. The\n backend / submit error string would otherwise render here AND under\n each missing-required item (per-item rendering is the canonical\n display, see `errorFor`) — that's the duplication we deliberately\n avoid. Must override `v-bind=\"$props\".error`; the explicit binding\n wins via `mergeProps` semantics.\n\n `:class=\"{ error: showRequiredErrors }\"` still paints the wrapper\n error chrome so the group reads as errored even with no shell\n footer.\n "), consents.value.length > 0 ? ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_atscript_vue_form.AsFieldShell), (0, vue.mergeProps)({ key: 0 }, _ctx.$props, {
|
|
293
|
+
label: explicitLabel.value,
|
|
294
|
+
error: void 0,
|
|
295
|
+
class: { error: showRequiredErrors.value },
|
|
296
|
+
"field-class": "as-consent-array"
|
|
297
|
+
}), {
|
|
298
|
+
default: (0, vue.withCtx)(() => [(0, vue.createElementVNode)("div", {
|
|
299
|
+
class: "as-consent-array-group",
|
|
300
|
+
onBlurCapture: _cache[1] || (_cache[1] = (...args) => (0, vue.unref)(onBlur) && (0, vue.unref)(onBlur)(...args))
|
|
301
|
+
}, [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(consents.value, (item) => {
|
|
302
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
|
|
303
|
+
key: item.id,
|
|
304
|
+
class: "as-consent-array-item"
|
|
305
|
+
}, [(0, vue.createElementVNode)("label", {
|
|
306
|
+
for: rowId(item.id),
|
|
307
|
+
class: "as-consent-array-row"
|
|
308
|
+
}, [(0, vue.createElementVNode)("input", {
|
|
309
|
+
id: rowId(item.id),
|
|
310
|
+
type: "checkbox",
|
|
311
|
+
checked: isChecked(item.id),
|
|
312
|
+
name: __props.name,
|
|
313
|
+
disabled: __props.disabled,
|
|
314
|
+
readonly: __props.readonly,
|
|
315
|
+
"aria-required": item.required ? "true" : void 0,
|
|
316
|
+
"aria-invalid": !!errorFor(item) || void 0,
|
|
317
|
+
"aria-describedby": __props.ariaDescribedBy,
|
|
318
|
+
onChange: (e) => onChange(item.id, e)
|
|
319
|
+
}, null, 40, _hoisted_2), (0, vue.createElementVNode)("span", { class: (0, vue.normalizeClass)(["as-consent-array-text", { required: !!item.required }]) }, [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(consentSegments.value.get(item.id), (seg, segIdx) => {
|
|
320
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: segIdx }, [seg.kind === "link" ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("a", {
|
|
321
|
+
key: 0,
|
|
322
|
+
href: seg.href,
|
|
323
|
+
target: "_blank",
|
|
324
|
+
rel: "noopener noreferrer",
|
|
325
|
+
class: "as-consent-array-link",
|
|
326
|
+
onClick: _cache[0] || (_cache[0] = (0, vue.withModifiers)(() => {}, ["stop"]))
|
|
327
|
+
}, (0, vue.toDisplayString)(seg.label), 9, _hoisted_3)) : ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 1 }, [(0, vue.createTextVNode)((0, vue.toDisplayString)(seg.value), 1)], 64))], 64);
|
|
328
|
+
}), 128))], 2)], 8, _hoisted_1), errorFor(item) ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
|
|
329
|
+
key: 0,
|
|
330
|
+
id: `${rowId(item.id)}-err`,
|
|
331
|
+
class: "as-error-slot",
|
|
332
|
+
role: "alert"
|
|
333
|
+
}, (0, vue.toDisplayString)(errorFor(item)), 9, _hoisted_4)) : (0, vue.createCommentVNode)("v-if", true)]);
|
|
334
|
+
}), 128))], 32)]),
|
|
335
|
+
_: 1
|
|
336
|
+
}, 16, ["label", "class"])) : (0, vue.createCommentVNode)("v-if", true)], 2112);
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
//#endregion
|
|
341
|
+
Object.defineProperty(exports, "as_consent_array_default", {
|
|
342
|
+
enumerable: true,
|
|
343
|
+
get: function() {
|
|
344
|
+
return as_consent_array_default;
|
|
345
|
+
}
|
|
346
|
+
});
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, mergeProps, normalizeClass, openBlock, renderList, toDisplayString, unref, withCtx, withModifiers } from "vue";
|
|
2
|
+
import { AsFieldShell, useAsField } from "@atscript/vue-form";
|
|
3
|
+
import { META_LABEL, getFieldMeta } from "@atscript/ui";
|
|
4
|
+
//#region src/components/as-consent-array.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
const _hoisted_1 = ["for"];
|
|
6
|
+
const _hoisted_2 = [
|
|
7
|
+
"id",
|
|
8
|
+
"checked",
|
|
9
|
+
"name",
|
|
10
|
+
"disabled",
|
|
11
|
+
"readonly",
|
|
12
|
+
"aria-required",
|
|
13
|
+
"aria-invalid",
|
|
14
|
+
"aria-describedby",
|
|
15
|
+
"onChange"
|
|
16
|
+
];
|
|
17
|
+
const _hoisted_3 = ["href"];
|
|
18
|
+
const _hoisted_4 = ["id"];
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/components/as-consent-array.vue
|
|
21
|
+
var as_consent_array_default = /* @__PURE__ */ defineComponent({
|
|
22
|
+
__name: "as-consent-array",
|
|
23
|
+
props: {
|
|
24
|
+
onBlur: {
|
|
25
|
+
type: Function,
|
|
26
|
+
required: true
|
|
27
|
+
},
|
|
28
|
+
error: {
|
|
29
|
+
type: String,
|
|
30
|
+
required: false
|
|
31
|
+
},
|
|
32
|
+
model: {
|
|
33
|
+
type: Object,
|
|
34
|
+
required: true
|
|
35
|
+
},
|
|
36
|
+
value: {
|
|
37
|
+
type: null,
|
|
38
|
+
required: false
|
|
39
|
+
},
|
|
40
|
+
label: {
|
|
41
|
+
type: String,
|
|
42
|
+
required: false
|
|
43
|
+
},
|
|
44
|
+
description: {
|
|
45
|
+
type: String,
|
|
46
|
+
required: false
|
|
47
|
+
},
|
|
48
|
+
hint: {
|
|
49
|
+
type: String,
|
|
50
|
+
required: false
|
|
51
|
+
},
|
|
52
|
+
placeholder: {
|
|
53
|
+
type: String,
|
|
54
|
+
required: false
|
|
55
|
+
},
|
|
56
|
+
prefixIcon: {
|
|
57
|
+
type: String,
|
|
58
|
+
required: false
|
|
59
|
+
},
|
|
60
|
+
suffixIcon: {
|
|
61
|
+
type: String,
|
|
62
|
+
required: false
|
|
63
|
+
},
|
|
64
|
+
class: {
|
|
65
|
+
type: [Object, String],
|
|
66
|
+
required: false
|
|
67
|
+
},
|
|
68
|
+
style: {
|
|
69
|
+
type: [Object, String],
|
|
70
|
+
required: false
|
|
71
|
+
},
|
|
72
|
+
optional: {
|
|
73
|
+
type: Boolean,
|
|
74
|
+
required: false,
|
|
75
|
+
skipCheck: true
|
|
76
|
+
},
|
|
77
|
+
onToggleOptional: {
|
|
78
|
+
type: Function,
|
|
79
|
+
required: false
|
|
80
|
+
},
|
|
81
|
+
required: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
required: false,
|
|
84
|
+
skipCheck: true
|
|
85
|
+
},
|
|
86
|
+
readonly: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
required: false,
|
|
89
|
+
skipCheck: true
|
|
90
|
+
},
|
|
91
|
+
type: {
|
|
92
|
+
type: String,
|
|
93
|
+
required: true
|
|
94
|
+
},
|
|
95
|
+
formAction: {
|
|
96
|
+
type: Object,
|
|
97
|
+
required: false
|
|
98
|
+
},
|
|
99
|
+
name: {
|
|
100
|
+
type: String,
|
|
101
|
+
required: false
|
|
102
|
+
},
|
|
103
|
+
field: {
|
|
104
|
+
type: Object,
|
|
105
|
+
required: false
|
|
106
|
+
},
|
|
107
|
+
options: {
|
|
108
|
+
type: Array,
|
|
109
|
+
required: false
|
|
110
|
+
},
|
|
111
|
+
maxLength: {
|
|
112
|
+
type: Number,
|
|
113
|
+
required: false
|
|
114
|
+
},
|
|
115
|
+
autocomplete: {
|
|
116
|
+
type: String,
|
|
117
|
+
required: false
|
|
118
|
+
},
|
|
119
|
+
title: {
|
|
120
|
+
type: String,
|
|
121
|
+
required: false
|
|
122
|
+
},
|
|
123
|
+
level: {
|
|
124
|
+
type: Number,
|
|
125
|
+
required: false
|
|
126
|
+
},
|
|
127
|
+
onRemove: {
|
|
128
|
+
type: Function,
|
|
129
|
+
required: false
|
|
130
|
+
},
|
|
131
|
+
canRemove: {
|
|
132
|
+
type: Boolean,
|
|
133
|
+
required: false
|
|
134
|
+
},
|
|
135
|
+
removeLabel: {
|
|
136
|
+
type: String,
|
|
137
|
+
required: false
|
|
138
|
+
},
|
|
139
|
+
arrayIndex: {
|
|
140
|
+
type: Number,
|
|
141
|
+
required: false
|
|
142
|
+
},
|
|
143
|
+
path: {
|
|
144
|
+
type: String,
|
|
145
|
+
required: true
|
|
146
|
+
},
|
|
147
|
+
valueHelp: {
|
|
148
|
+
type: Object,
|
|
149
|
+
required: false
|
|
150
|
+
},
|
|
151
|
+
singularLabel: {
|
|
152
|
+
type: String,
|
|
153
|
+
required: false
|
|
154
|
+
},
|
|
155
|
+
inputId: {
|
|
156
|
+
type: String,
|
|
157
|
+
required: true
|
|
158
|
+
},
|
|
159
|
+
errorId: {
|
|
160
|
+
type: String,
|
|
161
|
+
required: true
|
|
162
|
+
},
|
|
163
|
+
descId: {
|
|
164
|
+
type: String,
|
|
165
|
+
required: true
|
|
166
|
+
},
|
|
167
|
+
ariaDescribedBy: {
|
|
168
|
+
type: String,
|
|
169
|
+
required: false
|
|
170
|
+
},
|
|
171
|
+
currencyCode: {
|
|
172
|
+
type: String,
|
|
173
|
+
required: false
|
|
174
|
+
},
|
|
175
|
+
unitCode: {
|
|
176
|
+
type: String,
|
|
177
|
+
required: false
|
|
178
|
+
},
|
|
179
|
+
precisionScale: {
|
|
180
|
+
type: Number,
|
|
181
|
+
required: false
|
|
182
|
+
},
|
|
183
|
+
prefix: {
|
|
184
|
+
type: String,
|
|
185
|
+
required: false
|
|
186
|
+
},
|
|
187
|
+
suffix: {
|
|
188
|
+
type: String,
|
|
189
|
+
required: false
|
|
190
|
+
},
|
|
191
|
+
scale: {
|
|
192
|
+
type: Number,
|
|
193
|
+
required: false
|
|
194
|
+
},
|
|
195
|
+
hasAdornment: {
|
|
196
|
+
type: Boolean,
|
|
197
|
+
required: false
|
|
198
|
+
},
|
|
199
|
+
disabled: {
|
|
200
|
+
type: Boolean,
|
|
201
|
+
required: false
|
|
202
|
+
},
|
|
203
|
+
hidden: {
|
|
204
|
+
type: Boolean,
|
|
205
|
+
required: false
|
|
206
|
+
},
|
|
207
|
+
pendingConsents: {
|
|
208
|
+
type: Array,
|
|
209
|
+
required: false
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
setup(__props) {
|
|
213
|
+
const props = __props;
|
|
214
|
+
function rowId(itemId) {
|
|
215
|
+
const safe = itemId.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
216
|
+
return `${props.inputId}-${safe}`;
|
|
217
|
+
}
|
|
218
|
+
const consents = computed(() => props.pendingConsents ?? []);
|
|
219
|
+
const explicitLabel = computed(() => {
|
|
220
|
+
const prop = props.field?.prop;
|
|
221
|
+
if (!prop) return void 0;
|
|
222
|
+
const meta = getFieldMeta(prop, META_LABEL);
|
|
223
|
+
return typeof meta === "string" ? meta : void 0;
|
|
224
|
+
});
|
|
225
|
+
const { error: localError, onBlur } = useAsField({
|
|
226
|
+
getValue: () => props.model.value ?? [],
|
|
227
|
+
setValue: (v) => {
|
|
228
|
+
props.model.value = v;
|
|
229
|
+
},
|
|
230
|
+
rules: [(value) => {
|
|
231
|
+
for (const c of consents.value) if (c.required && !value.includes(c.id)) return c.required;
|
|
232
|
+
return true;
|
|
233
|
+
}],
|
|
234
|
+
path: () => props.path,
|
|
235
|
+
resetValue: []
|
|
236
|
+
});
|
|
237
|
+
const showRequiredErrors = computed(() => !!localError.value);
|
|
238
|
+
function errorFor(item) {
|
|
239
|
+
if (!showRequiredErrors.value) return void 0;
|
|
240
|
+
if (!item.required) return void 0;
|
|
241
|
+
if ((props.model.value ?? []).includes(item.id)) return void 0;
|
|
242
|
+
return item.required;
|
|
243
|
+
}
|
|
244
|
+
function commit(id, on) {
|
|
245
|
+
const current = props.model.value ?? [];
|
|
246
|
+
if (on) {
|
|
247
|
+
if (current.indexOf(id) === -1) props.model.value = [...current, id];
|
|
248
|
+
} else {
|
|
249
|
+
const next = current.filter((v) => v !== id);
|
|
250
|
+
if (next.length !== current.length) props.model.value = next;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
function onChange(id, ev) {
|
|
254
|
+
commit(id, ev.target.checked);
|
|
255
|
+
}
|
|
256
|
+
const isChecked = (id) => (props.model.value ?? []).includes(id);
|
|
257
|
+
const MD_LINK_RE = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
258
|
+
const SAFE_SCHEME_RE = /^(?:https?:\/\/|mailto:)/i;
|
|
259
|
+
function parseConsentText(text) {
|
|
260
|
+
const segments = [];
|
|
261
|
+
let lastIndex = 0;
|
|
262
|
+
for (const match of text.matchAll(MD_LINK_RE)) {
|
|
263
|
+
const [full, label, href] = match;
|
|
264
|
+
const idx = match.index ?? 0;
|
|
265
|
+
if (idx > lastIndex) segments.push({
|
|
266
|
+
kind: "text",
|
|
267
|
+
value: text.slice(lastIndex, idx)
|
|
268
|
+
});
|
|
269
|
+
if (SAFE_SCHEME_RE.test(href)) segments.push({
|
|
270
|
+
kind: "link",
|
|
271
|
+
label,
|
|
272
|
+
href
|
|
273
|
+
});
|
|
274
|
+
else segments.push({
|
|
275
|
+
kind: "text",
|
|
276
|
+
value: full
|
|
277
|
+
});
|
|
278
|
+
lastIndex = idx + full.length;
|
|
279
|
+
}
|
|
280
|
+
if (lastIndex < text.length) segments.push({
|
|
281
|
+
kind: "text",
|
|
282
|
+
value: text.slice(lastIndex)
|
|
283
|
+
});
|
|
284
|
+
return segments;
|
|
285
|
+
}
|
|
286
|
+
const consentSegments = computed(() => {
|
|
287
|
+
const map = /* @__PURE__ */ new Map();
|
|
288
|
+
for (const item of consents.value) map.set(item.id, parseConsentText(item.text));
|
|
289
|
+
return map;
|
|
290
|
+
});
|
|
291
|
+
return (_ctx, _cache) => {
|
|
292
|
+
return openBlock(), createElementBlock(Fragment, null, [createCommentVNode("\n `:error=\"undefined\"` suppresses the shell's footer error row. The\n backend / submit error string would otherwise render here AND under\n each missing-required item (per-item rendering is the canonical\n display, see `errorFor`) — that's the duplication we deliberately\n avoid. Must override `v-bind=\"$props\".error`; the explicit binding\n wins via `mergeProps` semantics.\n\n `:class=\"{ error: showRequiredErrors }\"` still paints the wrapper\n error chrome so the group reads as errored even with no shell\n footer.\n "), consents.value.length > 0 ? (openBlock(), createBlock(unref(AsFieldShell), mergeProps({ key: 0 }, _ctx.$props, {
|
|
293
|
+
label: explicitLabel.value,
|
|
294
|
+
error: void 0,
|
|
295
|
+
class: { error: showRequiredErrors.value },
|
|
296
|
+
"field-class": "as-consent-array"
|
|
297
|
+
}), {
|
|
298
|
+
default: withCtx(() => [createElementVNode("div", {
|
|
299
|
+
class: "as-consent-array-group",
|
|
300
|
+
onBlurCapture: _cache[1] || (_cache[1] = (...args) => unref(onBlur) && unref(onBlur)(...args))
|
|
301
|
+
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(consents.value, (item) => {
|
|
302
|
+
return openBlock(), createElementBlock("div", {
|
|
303
|
+
key: item.id,
|
|
304
|
+
class: "as-consent-array-item"
|
|
305
|
+
}, [createElementVNode("label", {
|
|
306
|
+
for: rowId(item.id),
|
|
307
|
+
class: "as-consent-array-row"
|
|
308
|
+
}, [createElementVNode("input", {
|
|
309
|
+
id: rowId(item.id),
|
|
310
|
+
type: "checkbox",
|
|
311
|
+
checked: isChecked(item.id),
|
|
312
|
+
name: __props.name,
|
|
313
|
+
disabled: __props.disabled,
|
|
314
|
+
readonly: __props.readonly,
|
|
315
|
+
"aria-required": item.required ? "true" : void 0,
|
|
316
|
+
"aria-invalid": !!errorFor(item) || void 0,
|
|
317
|
+
"aria-describedby": __props.ariaDescribedBy,
|
|
318
|
+
onChange: (e) => onChange(item.id, e)
|
|
319
|
+
}, null, 40, _hoisted_2), createElementVNode("span", { class: normalizeClass(["as-consent-array-text", { required: !!item.required }]) }, [(openBlock(true), createElementBlock(Fragment, null, renderList(consentSegments.value.get(item.id), (seg, segIdx) => {
|
|
320
|
+
return openBlock(), createElementBlock(Fragment, { key: segIdx }, [seg.kind === "link" ? (openBlock(), createElementBlock("a", {
|
|
321
|
+
key: 0,
|
|
322
|
+
href: seg.href,
|
|
323
|
+
target: "_blank",
|
|
324
|
+
rel: "noopener noreferrer",
|
|
325
|
+
class: "as-consent-array-link",
|
|
326
|
+
onClick: _cache[0] || (_cache[0] = withModifiers(() => {}, ["stop"]))
|
|
327
|
+
}, toDisplayString(seg.label), 9, _hoisted_3)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(toDisplayString(seg.value), 1)], 64))], 64);
|
|
328
|
+
}), 128))], 2)], 8, _hoisted_1), errorFor(item) ? (openBlock(), createElementBlock("div", {
|
|
329
|
+
key: 0,
|
|
330
|
+
id: `${rowId(item.id)}-err`,
|
|
331
|
+
class: "as-error-slot",
|
|
332
|
+
role: "alert"
|
|
333
|
+
}, toDisplayString(errorFor(item)), 9, _hoisted_4)) : createCommentVNode("v-if", true)]);
|
|
334
|
+
}), 128))], 32)]),
|
|
335
|
+
_: 1
|
|
336
|
+
}, 16, ["label", "class"])) : createCommentVNode("v-if", true)], 2112);
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
//#endregion
|
|
341
|
+
export { as_consent_array_default as t };
|