@shwfed/nuxt 0.11.4 → 0.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.json +1 -1
- package/dist/runtime/components/fields.d.vue.ts +1 -1
- package/dist/runtime/components/fields.vue +29 -0
- package/dist/runtime/components/fields.vue.d.ts +1 -1
- package/dist/runtime/components/ui/fields/Fields.d.vue.ts +6 -1
- package/dist/runtime/components/ui/fields/Fields.vue +58 -5
- package/dist/runtime/components/ui/fields/Fields.vue.d.ts +6 -1
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
2
|
import { type FieldsConfigInput } from './ui/fields/Fields.vue.js';
|
|
3
3
|
export { CalendarFieldC, EmptyFieldC, FieldC, FieldsBodyC, FieldsBodyInputC, FieldsConfigC, FieldsConfigInputC, NumberFieldC, SelectFieldC, SlotFieldC, StringFieldC, CURRENT_COMPATIBILITY_DATE, KIND, SUPPORTED_COMPATIBILITY_DATES, createFieldsConfig, } from './ui/fields/Fields.vue.js';
|
|
4
|
-
export type { EmptyField, Field, FieldsBody, FieldsBodyInput, FieldsConfig, FieldsConfigInput, SlotField, } from './ui/fields/Fields.vue.js';
|
|
4
|
+
export type { EmptyField, Field, FieldsInstance, FieldsBody, FieldsBodyInput, FieldsConfig, FieldsConfigInput, SlotField, } from './ui/fields/Fields.vue.js';
|
|
5
5
|
declare const _default: typeof __VLS_export;
|
|
6
6
|
export default _default;
|
|
7
7
|
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { Effect } from "effect";
|
|
3
|
+
import { ref } from "vue";
|
|
3
4
|
import UiFields, {
|
|
4
5
|
createFieldsConfig
|
|
5
6
|
} from "./ui/fields/Fields.vue";
|
|
@@ -23,6 +24,33 @@ function handleConfigUpdate(config2) {
|
|
|
23
24
|
function handleInitialValueReady() {
|
|
24
25
|
emit("initial-value-ready");
|
|
25
26
|
}
|
|
27
|
+
const fieldsRef = ref(null);
|
|
28
|
+
defineExpose(new Proxy({}, {
|
|
29
|
+
get(_target, property) {
|
|
30
|
+
return fieldsRef.value ? Reflect.get(fieldsRef.value, property) : void 0;
|
|
31
|
+
},
|
|
32
|
+
has(_target, property) {
|
|
33
|
+
return fieldsRef.value ? Reflect.has(fieldsRef.value, property) : false;
|
|
34
|
+
},
|
|
35
|
+
ownKeys() {
|
|
36
|
+
return fieldsRef.value ? Reflect.ownKeys(fieldsRef.value) : [];
|
|
37
|
+
},
|
|
38
|
+
getOwnPropertyDescriptor(_target, property) {
|
|
39
|
+
if (!fieldsRef.value || !Reflect.has(fieldsRef.value, property)) {
|
|
40
|
+
return void 0;
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
configurable: true,
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get() {
|
|
46
|
+
if (!fieldsRef.value) {
|
|
47
|
+
return void 0;
|
|
48
|
+
}
|
|
49
|
+
return Reflect.get(fieldsRef.value, property);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}));
|
|
26
54
|
</script>
|
|
27
55
|
|
|
28
56
|
<script>
|
|
@@ -47,6 +75,7 @@ export {
|
|
|
47
75
|
|
|
48
76
|
<template>
|
|
49
77
|
<UiFields
|
|
78
|
+
ref="fieldsRef"
|
|
50
79
|
v-bind="$attrs"
|
|
51
80
|
v-model="modelValue"
|
|
52
81
|
:config="config"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
2
|
import { type FieldsConfigInput } from './ui/fields/Fields.vue.js';
|
|
3
3
|
export { CalendarFieldC, EmptyFieldC, FieldC, FieldsBodyC, FieldsBodyInputC, FieldsConfigC, FieldsConfigInputC, NumberFieldC, SelectFieldC, SlotFieldC, StringFieldC, CURRENT_COMPATIBILITY_DATE, KIND, SUPPORTED_COMPATIBILITY_DATES, createFieldsConfig, } from './ui/fields/Fields.vue.js';
|
|
4
|
-
export type { EmptyField, Field, FieldsBody, FieldsBodyInput, FieldsConfig, FieldsConfigInput, SlotField, } from './ui/fields/Fields.vue.js';
|
|
4
|
+
export type { EmptyField, Field, FieldsInstance, FieldsBody, FieldsBodyInput, FieldsConfig, FieldsConfigInput, SlotField, } from './ui/fields/Fields.vue.js';
|
|
5
5
|
declare const _default: typeof __VLS_export;
|
|
6
6
|
export default _default;
|
|
7
7
|
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
@@ -2,6 +2,9 @@ import { Effect } from 'effect';
|
|
|
2
2
|
import type { CSSProperties } from 'vue';
|
|
3
3
|
export { CalendarFieldC, CURRENT_COMPATIBILITY_DATE, EmptyFieldC, FieldC, FieldsBodyC, FieldsBodyInputC, FieldsConfigC, FieldsConfigInputC, KIND, NumberFieldC, SelectFieldC, SlotFieldC, SUPPORTED_COMPATIBILITY_DATES, StringFieldC, ValidationRuleC, createFieldsConfig, validationC, } from './schema.js';
|
|
4
4
|
export type { EmptyField, Field, FieldsBody, FieldsBodyInput, FieldsConfig, FieldsConfigInput, SlotField, ValidationRule, } from './schema.js';
|
|
5
|
+
export type FieldsInstance = {
|
|
6
|
+
valid: import('effect').Effect.Effect<boolean, never>;
|
|
7
|
+
};
|
|
5
8
|
declare const _default: typeof __VLS_export;
|
|
6
9
|
export default _default;
|
|
7
10
|
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
@@ -127,7 +130,9 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
127
130
|
}> | undefined>;
|
|
128
131
|
} & {
|
|
129
132
|
modelValue?: Record<string, unknown>;
|
|
130
|
-
}, {
|
|
133
|
+
}, {
|
|
134
|
+
valid: Effect.Effect<boolean, never, never>;
|
|
135
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
131
136
|
"update:modelValue": (value: Record<string, unknown>) => any;
|
|
132
137
|
"update:config": (args_0: Readonly<{
|
|
133
138
|
fields: readonly ({
|
|
@@ -41,8 +41,10 @@ const displayConfig = ref(defaultConfig);
|
|
|
41
41
|
const validationErrors = ref({});
|
|
42
42
|
const calendarOpen = ref({});
|
|
43
43
|
const selectOpen = ref({});
|
|
44
|
+
const isReady = ref(false);
|
|
44
45
|
const hasInitializedFieldValues = ref(false);
|
|
45
46
|
const hasEmittedInitialValueReady = ref(false);
|
|
47
|
+
const readyResolvers = [];
|
|
46
48
|
function cloneConfig(config2) {
|
|
47
49
|
const nextConfig = {
|
|
48
50
|
kind: config2.kind,
|
|
@@ -214,6 +216,24 @@ function handleSelectCommandValueChange(field, state, value) {
|
|
|
214
216
|
function clearFieldValidation(path) {
|
|
215
217
|
Reflect.deleteProperty(validationErrors.value, path);
|
|
216
218
|
}
|
|
219
|
+
function markReady() {
|
|
220
|
+
if (isReady.value) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
isReady.value = true;
|
|
224
|
+
while (readyResolvers.length > 0) {
|
|
225
|
+
const resolve = readyResolvers.shift();
|
|
226
|
+
resolve?.();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function waitForReady() {
|
|
230
|
+
if (isReady.value) {
|
|
231
|
+
return Promise.resolve();
|
|
232
|
+
}
|
|
233
|
+
return new Promise((resolve) => {
|
|
234
|
+
readyResolvers.push(resolve);
|
|
235
|
+
});
|
|
236
|
+
}
|
|
217
237
|
function snapshotValidationContext(field) {
|
|
218
238
|
const form = structuredClone(toRaw(modelValue.value));
|
|
219
239
|
return {
|
|
@@ -221,10 +241,9 @@ function snapshotValidationContext(field) {
|
|
|
221
241
|
form
|
|
222
242
|
};
|
|
223
243
|
}
|
|
224
|
-
function
|
|
244
|
+
function getValidationFailure(field) {
|
|
225
245
|
if (!field.validation?.length || isFieldHidden(field) || isFieldDisabled(field)) {
|
|
226
|
-
|
|
227
|
-
return;
|
|
246
|
+
return void 0;
|
|
228
247
|
}
|
|
229
248
|
const context = {
|
|
230
249
|
value: getFieldValue(field),
|
|
@@ -232,14 +251,39 @@ function validateField(field) {
|
|
|
232
251
|
};
|
|
233
252
|
for (const rule of field.validation) {
|
|
234
253
|
if (!$dsl.evaluate`${rule.expression}`(context)) {
|
|
235
|
-
|
|
254
|
+
return {
|
|
236
255
|
message: rule.message,
|
|
237
256
|
context: snapshotValidationContext(field)
|
|
238
257
|
};
|
|
239
|
-
return;
|
|
240
258
|
}
|
|
241
259
|
}
|
|
260
|
+
return void 0;
|
|
261
|
+
}
|
|
262
|
+
function syncFieldValidation(field) {
|
|
263
|
+
const failure = getValidationFailure(field);
|
|
264
|
+
if (failure) {
|
|
265
|
+
validationErrors.value[field.path] = failure;
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
242
268
|
clearFieldValidation(field.path);
|
|
269
|
+
return true;
|
|
270
|
+
}
|
|
271
|
+
function validateField(field) {
|
|
272
|
+
syncFieldValidation(field);
|
|
273
|
+
}
|
|
274
|
+
function validateFields() {
|
|
275
|
+
const nextValidationErrors = {};
|
|
276
|
+
for (const field of displayConfig.value.fields) {
|
|
277
|
+
if (isPassiveField(field)) {
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
const failure = getValidationFailure(field);
|
|
281
|
+
if (failure) {
|
|
282
|
+
nextValidationErrors[field.path] = failure;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
validationErrors.value = nextValidationErrors;
|
|
286
|
+
return Object.keys(nextValidationErrors).length === 0;
|
|
243
287
|
}
|
|
244
288
|
function isFieldInvalid(field) {
|
|
245
289
|
return validationErrors.value[field.path] !== void 0;
|
|
@@ -274,6 +318,14 @@ function handleConfiguratorConfirm(nextConfig) {
|
|
|
274
318
|
displayConfig.value = cloneConfig(nextConfig);
|
|
275
319
|
emit("update:config", nextConfig);
|
|
276
320
|
}
|
|
321
|
+
const fieldsApi = {
|
|
322
|
+
valid: Effect.async((resume) => {
|
|
323
|
+
void waitForReady().then(() => {
|
|
324
|
+
resume(Effect.sync(() => validateFields()));
|
|
325
|
+
});
|
|
326
|
+
})
|
|
327
|
+
};
|
|
328
|
+
defineExpose(fieldsApi);
|
|
277
329
|
watch(config, (value) => {
|
|
278
330
|
if (!value) {
|
|
279
331
|
return;
|
|
@@ -287,6 +339,7 @@ watch(config, (value) => {
|
|
|
287
339
|
hasEmittedInitialValueReady.value = true;
|
|
288
340
|
emit("initial-value-ready");
|
|
289
341
|
}
|
|
342
|
+
markReady();
|
|
290
343
|
}, { immediate: true });
|
|
291
344
|
watchEffect(() => {
|
|
292
345
|
const activePaths = /* @__PURE__ */ new Set();
|
|
@@ -2,6 +2,9 @@ import { Effect } from 'effect';
|
|
|
2
2
|
import type { CSSProperties } from 'vue';
|
|
3
3
|
export { CalendarFieldC, CURRENT_COMPATIBILITY_DATE, EmptyFieldC, FieldC, FieldsBodyC, FieldsBodyInputC, FieldsConfigC, FieldsConfigInputC, KIND, NumberFieldC, SelectFieldC, SlotFieldC, SUPPORTED_COMPATIBILITY_DATES, StringFieldC, ValidationRuleC, createFieldsConfig, validationC, } from './schema.js';
|
|
4
4
|
export type { EmptyField, Field, FieldsBody, FieldsBodyInput, FieldsConfig, FieldsConfigInput, SlotField, ValidationRule, } from './schema.js';
|
|
5
|
+
export type FieldsInstance = {
|
|
6
|
+
valid: import('effect').Effect.Effect<boolean, never>;
|
|
7
|
+
};
|
|
5
8
|
declare const _default: typeof __VLS_export;
|
|
6
9
|
export default _default;
|
|
7
10
|
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
@@ -127,7 +130,9 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
127
130
|
}> | undefined>;
|
|
128
131
|
} & {
|
|
129
132
|
modelValue?: Record<string, unknown>;
|
|
130
|
-
}, {
|
|
133
|
+
}, {
|
|
134
|
+
valid: Effect.Effect<boolean, never, never>;
|
|
135
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
131
136
|
"update:modelValue": (value: Record<string, unknown>) => any;
|
|
132
137
|
"update:config": (args_0: Readonly<{
|
|
133
138
|
fields: readonly ({
|