@shwfed/config 2.2.4 → 2.2.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/form/fields/2026-05-13/com.shwfed.form.field.list/row.d.vue.ts +3 -4
- package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.list/row.vue +1 -1
- package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.list/row.vue.d.ts +3 -4
- package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.list/runtime.vue +9 -2
- package/dist/runtime/components/form/utils/state.d.ts +10 -2
- package/dist/runtime/components/form/utils/state.js +10 -3
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.list/row.d.vue.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import type { FormUnitValue } from '../../../schema.js';
|
|
2
|
-
import { type FormState } from '../../../utils/state.js';
|
|
3
2
|
type __VLS_Props = {
|
|
4
3
|
unit: FormUnitValue;
|
|
5
4
|
index: number;
|
|
6
5
|
};
|
|
7
6
|
type __VLS_ModelProps = {
|
|
8
|
-
modelValue:
|
|
7
|
+
modelValue: unknown;
|
|
9
8
|
};
|
|
10
9
|
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
11
10
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
12
|
-
"update:modelValue": (value:
|
|
11
|
+
"update:modelValue": (value: unknown) => any;
|
|
13
12
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
14
|
-
"onUpdate:modelValue"?: ((value:
|
|
13
|
+
"onUpdate:modelValue"?: ((value: unknown) => any) | undefined;
|
|
15
14
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
16
15
|
declare const _default: typeof __VLS_export;
|
|
17
16
|
export default _default;
|
|
@@ -6,7 +6,7 @@ import FormUnitRenderer from "../../../FormUnitRenderer.vue";
|
|
|
6
6
|
import { useDerived, useDerivedQuiescence } from "../../../utils/derived";
|
|
7
7
|
import { provideFormState } from "../../../utils/state";
|
|
8
8
|
defineOptions({ name: "ShwfedListFieldRow" });
|
|
9
|
-
const state = defineModel({ type:
|
|
9
|
+
const state = defineModel({ type: null, ...{ required: true } });
|
|
10
10
|
const props = defineProps({
|
|
11
11
|
unit: { type: Object, required: true },
|
|
12
12
|
index: { type: Number, required: true }
|
package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.list/row.vue.d.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import type { FormUnitValue } from '../../../schema.js';
|
|
2
|
-
import { type FormState } from '../../../utils/state.js';
|
|
3
2
|
type __VLS_Props = {
|
|
4
3
|
unit: FormUnitValue;
|
|
5
4
|
index: number;
|
|
6
5
|
};
|
|
7
6
|
type __VLS_ModelProps = {
|
|
8
|
-
modelValue:
|
|
7
|
+
modelValue: unknown;
|
|
9
8
|
};
|
|
10
9
|
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
11
10
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
12
|
-
"update:modelValue": (value:
|
|
11
|
+
"update:modelValue": (value: unknown) => any;
|
|
13
12
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
14
|
-
"onUpdate:modelValue"?: ((value:
|
|
13
|
+
"onUpdate:modelValue"?: ((value: unknown) => any) | undefined;
|
|
15
14
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
16
15
|
declare const _default: typeof __VLS_export;
|
|
17
16
|
export default _default;
|
package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.list/runtime.vue
CHANGED
|
@@ -14,7 +14,7 @@ import { Button } from "../../../../ui/button";
|
|
|
14
14
|
import { Field, FieldLabel } from "../../../../ui/field";
|
|
15
15
|
import { InputGroupButton } from "../../../../ui/input-group";
|
|
16
16
|
import { Markdown } from "../../../../ui/markdown";
|
|
17
|
-
import { useFormState } from "../../../utils/state";
|
|
17
|
+
import { SELF_BINDING, useFormState } from "../../../utils/state";
|
|
18
18
|
import Row from "./row.vue";
|
|
19
19
|
defineOptions({ name: "ShwfedListFieldRuntime" });
|
|
20
20
|
const props = defineProps({
|
|
@@ -45,6 +45,12 @@ function evalBool(expression, label) {
|
|
|
45
45
|
}
|
|
46
46
|
const isDisabled = computed(() => evalBool(props.config.disabled, "disabled"));
|
|
47
47
|
const reorderable = computed(() => props.config.reorderable ?? true);
|
|
48
|
+
const isScalarRow = computed(() => {
|
|
49
|
+
const fields = props.config.unit.fields;
|
|
50
|
+
if (fields.length !== 1) return false;
|
|
51
|
+
const only = fields[0];
|
|
52
|
+
return only.binding === SELF_BINDING;
|
|
53
|
+
});
|
|
48
54
|
const localItems = ref([]);
|
|
49
55
|
const items = computed(() => {
|
|
50
56
|
const path = props.config.binding;
|
|
@@ -120,7 +126,8 @@ const canRemove = computed(() => !isDisabled.value && !atMin.value);
|
|
|
120
126
|
const canReorder = computed(() => !isDisabled.value && reorderable.value);
|
|
121
127
|
function append() {
|
|
122
128
|
if (!canAdd.value) return;
|
|
123
|
-
|
|
129
|
+
const seed = isScalarRow.value ? null : {};
|
|
130
|
+
writeItems([...items.value, seed]);
|
|
124
131
|
const id = makeId();
|
|
125
132
|
rowKeys.value = [...rowKeys.value, id];
|
|
126
133
|
const next = new Set(expandedKeys.value);
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import type { InjectionKey, Ref } from 'vue';
|
|
2
2
|
export type FormState = Record<string, unknown>;
|
|
3
|
+
/**
|
|
4
|
+
* Sentinel binding meaning "the bag's state itself", not a key inside it.
|
|
5
|
+
* Used by `list` rows that hold scalar items: the inner field's `binding: '.'`
|
|
6
|
+
* tells the bag to read/replace `state.value` wholesale instead of walking
|
|
7
|
+
* into it as a dot-prop path. dot-prop has no notion of a self-path, so the
|
|
8
|
+
* bag intercepts this before delegating.
|
|
9
|
+
*/
|
|
10
|
+
export declare const SELF_BINDING: ".";
|
|
3
11
|
export type FormStateBag = {
|
|
4
|
-
state: Ref<
|
|
12
|
+
state: Ref<unknown>;
|
|
5
13
|
getAt: (path: string) => unknown;
|
|
6
14
|
/**
|
|
7
15
|
* Write a value at `path` on behalf of a **user interaction**. Besides
|
|
@@ -33,5 +41,5 @@ export type FormStateBag = {
|
|
|
33
41
|
markDirty: (path: string) => void;
|
|
34
42
|
};
|
|
35
43
|
export declare const FORM_STATE_KEY: InjectionKey<FormStateBag>;
|
|
36
|
-
export declare function provideFormState(state: Ref<
|
|
44
|
+
export declare function provideFormState(state: Ref<unknown>): FormStateBag;
|
|
37
45
|
export declare function useFormState(): FormStateBag;
|
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import { getProperty, setProperty } from "dot-prop";
|
|
2
2
|
import { inject, provide, ref } from "vue";
|
|
3
|
+
export const SELF_BINDING = ".";
|
|
3
4
|
export const FORM_STATE_KEY = Symbol("shwfed-form-state");
|
|
4
5
|
export function provideFormState(state) {
|
|
5
6
|
const dirty = ref(/* @__PURE__ */ new Set());
|
|
6
7
|
function write(path, value) {
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
const normalized = value === void 0 ? null : value;
|
|
9
|
+
if (path === SELF_BINDING) {
|
|
10
|
+
state.value = normalized;
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const current = state.value;
|
|
14
|
+
setProperty(current, path, normalized);
|
|
15
|
+
state.value = { ...current };
|
|
9
16
|
}
|
|
10
17
|
function markDirty(path) {
|
|
11
18
|
if (!dirty.value.has(path)) dirty.value = new Set(dirty.value).add(path);
|
|
12
19
|
}
|
|
13
20
|
const bag = {
|
|
14
21
|
state,
|
|
15
|
-
getAt: (path) => getProperty(state.value, path),
|
|
22
|
+
getAt: (path) => path === SELF_BINDING ? state.value : getProperty(state.value, path),
|
|
16
23
|
setAt: (path, value) => {
|
|
17
24
|
write(path, value);
|
|
18
25
|
markDirty(path);
|