@bagelink/vue 0.0.1202 → 0.0.1204
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BagelForm.vue.d.ts","sourceRoot":"","sources":["../../../src/components/form/BagelForm.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BagelForm.vue.d.ts","sourceRoot":"","sources":["../../../src/components/form/BagelForm.vue"],"names":[],"mappings":"AAgHA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,eAAe,CAAA;AAK5D,MAAM,WAAW,cAAc,CAAC,EAAE;IACjC,UAAU,CAAC,EAAE,EAAE,CAAA;IACf,MAAM,CAAC,EAAE,gBAAgB,CAAC,EAAE,CAAC,CAAA;IAC7B,GAAG,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;IACzB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACtC;yBAEgB,CAAC,SAAS;IAAC,CAAC,GAAG,EAAC,MAAM,GAAE,GAAG,CAAA;CAAC,eAC/B,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,cAClD,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,iBAC5F,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC;WA0L1D,mBAAmB,CAAC;;6KAAkE,CAAC,4BAA2B;oBACzG,OAAO,KAAK,EAAE,gBAAgB;;;;MAAsB,GAAG,IAAI;WACpE,GAAG;;yBAxCkB,GAAG;;;;;YACJ,GAAG;yBACF,GAAG;uBACL,GAAG;;cA7IzB,mBAAmB,SAAS,CAAC,KAAG,IAAI;OAuL7B,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AApMzE,wBAoM4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSchemaField.d.ts","sourceRoot":"","sources":["../../src/composables/useSchemaField.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AAChC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAwBxD,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACvC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAA;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC,CAAA;IACpB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAA;IACzD,YAAY,CAAC,EAAE,OAAO,CAAA;CACtB;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EAAE,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC;yBA4BzF,cAAc,CAAC,CAAC,CAAC,UAChB,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE;QAAE,GAAG,EAAE,CAAC,CAAC;QAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,CAAA;KAAE,KAAK,GAAG,CAAC,KAC1E,KAAK,GAAG,IAAI;0BA3Bc,cAAc,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"useSchemaField.d.ts","sourceRoot":"","sources":["../../src/composables/useSchemaField.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AAChC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAwBxD,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACvC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAA;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC,CAAA;IACpB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAA;IACzD,YAAY,CAAC,EAAE,OAAO,CAAA;CACtB;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EAAE,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC;yBA4BzF,cAAc,CAAC,CAAC,CAAC,UAChB,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE;QAAE,GAAG,EAAE,CAAC,CAAC;QAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,CAAA;KAAE,KAAK,GAAG,CAAC,KAC1E,KAAK,GAAG,IAAI;0BA3Bc,cAAc,CAAC,CAAC,CAAC;EAyL9C"}
|
package/dist/index.cjs
CHANGED
|
@@ -7314,6 +7314,20 @@ function useSchemaField(options) {
|
|
|
7314
7314
|
const Component = getComponent(field);
|
|
7315
7315
|
if (!Component) return null;
|
|
7316
7316
|
const rowData = (getRowData == null ? void 0 : getRowData()) || {};
|
|
7317
|
+
const condition = field.vIf ?? field["v-if"];
|
|
7318
|
+
if (condition !== void 0) {
|
|
7319
|
+
if (typeof condition === "function") {
|
|
7320
|
+
if (!condition(field.id ? rowData[field.id] : void 0, rowData)) {
|
|
7321
|
+
return null;
|
|
7322
|
+
}
|
|
7323
|
+
} else if (typeof condition === "string") {
|
|
7324
|
+
if (!rowData[condition]) {
|
|
7325
|
+
return null;
|
|
7326
|
+
}
|
|
7327
|
+
} else if (!condition) {
|
|
7328
|
+
return null;
|
|
7329
|
+
}
|
|
7330
|
+
}
|
|
7317
7331
|
const {
|
|
7318
7332
|
$el,
|
|
7319
7333
|
children: children2,
|
|
@@ -7378,7 +7392,7 @@ function useSchemaField(options) {
|
|
|
7378
7392
|
componentSlots.default = () => children2.map((child) => {
|
|
7379
7393
|
if (typeof child === "string") return child;
|
|
7380
7394
|
return renderField(child, slots);
|
|
7381
|
-
});
|
|
7395
|
+
}).filter(Boolean);
|
|
7382
7396
|
}
|
|
7383
7397
|
if (isSlotValueComponent && transformedValue !== void 0) {
|
|
7384
7398
|
componentSlots.default = () => (transformedValue == null ? void 0 : transformedValue.toString()) || "";
|
|
@@ -11631,18 +11645,6 @@ const _sfc_main$R = /* @__PURE__ */ vue.defineComponent({
|
|
|
11631
11645
|
formState.value = "error";
|
|
11632
11646
|
}
|
|
11633
11647
|
}
|
|
11634
|
-
function shouldRenderField(field) {
|
|
11635
|
-
const condition = field.vIf ?? field["v-if"];
|
|
11636
|
-
if (condition === void 0) return true;
|
|
11637
|
-
if (typeof condition === "function") {
|
|
11638
|
-
console.log("shouldRenderField", field.id, condition(formData.value[field.id], formData.value));
|
|
11639
|
-
return condition(formData.value[field.id], formData.value);
|
|
11640
|
-
}
|
|
11641
|
-
if (typeof condition === "string") {
|
|
11642
|
-
return !!formData.value[condition];
|
|
11643
|
-
}
|
|
11644
|
-
return !!condition;
|
|
11645
|
-
}
|
|
11646
11648
|
function validateForm() {
|
|
11647
11649
|
if (!form.value) return false;
|
|
11648
11650
|
return form.value.reportValidity();
|
|
@@ -11657,23 +11659,8 @@ const _sfc_main$R = /* @__PURE__ */ vue.defineComponent({
|
|
|
11657
11659
|
(_a2 = field.onUpdate) == null ? void 0 : _a2.call(field, value, formData.value);
|
|
11658
11660
|
}
|
|
11659
11661
|
});
|
|
11660
|
-
function parseChildren(children2) {
|
|
11661
|
-
if (!children2) return void 0;
|
|
11662
|
-
return children2.map((child) => {
|
|
11663
|
-
if (typeof child === "string") return child;
|
|
11664
|
-
if (!shouldRenderField(child)) return null;
|
|
11665
|
-
if (!child.children) return child;
|
|
11666
|
-
const parsedChildren = parseChildren(child.children);
|
|
11667
|
-
return (parsedChildren == null ? void 0 : parsedChildren.length) ? { ...child, children: parsedChildren } : null;
|
|
11668
|
-
}).filter((child) => child !== null);
|
|
11669
|
-
}
|
|
11670
11662
|
function renderSchemaField(field) {
|
|
11671
|
-
|
|
11672
|
-
if (!shouldRender) return null;
|
|
11673
|
-
return renderField({
|
|
11674
|
-
...field,
|
|
11675
|
-
children: parseChildren(field.children)
|
|
11676
|
-
});
|
|
11663
|
+
return renderField(field);
|
|
11677
11664
|
}
|
|
11678
11665
|
__expose({ form, isDirty: isDirty.value, validateForm });
|
|
11679
11666
|
return (_ctx, _cache) => {
|
package/dist/index.mjs
CHANGED
|
@@ -7312,6 +7312,20 @@ function useSchemaField(options) {
|
|
|
7312
7312
|
const Component = getComponent(field);
|
|
7313
7313
|
if (!Component) return null;
|
|
7314
7314
|
const rowData = (getRowData == null ? void 0 : getRowData()) || {};
|
|
7315
|
+
const condition = field.vIf ?? field["v-if"];
|
|
7316
|
+
if (condition !== void 0) {
|
|
7317
|
+
if (typeof condition === "function") {
|
|
7318
|
+
if (!condition(field.id ? rowData[field.id] : void 0, rowData)) {
|
|
7319
|
+
return null;
|
|
7320
|
+
}
|
|
7321
|
+
} else if (typeof condition === "string") {
|
|
7322
|
+
if (!rowData[condition]) {
|
|
7323
|
+
return null;
|
|
7324
|
+
}
|
|
7325
|
+
} else if (!condition) {
|
|
7326
|
+
return null;
|
|
7327
|
+
}
|
|
7328
|
+
}
|
|
7315
7329
|
const {
|
|
7316
7330
|
$el,
|
|
7317
7331
|
children: children2,
|
|
@@ -7376,7 +7390,7 @@ function useSchemaField(options) {
|
|
|
7376
7390
|
componentSlots.default = () => children2.map((child) => {
|
|
7377
7391
|
if (typeof child === "string") return child;
|
|
7378
7392
|
return renderField(child, slots);
|
|
7379
|
-
});
|
|
7393
|
+
}).filter(Boolean);
|
|
7380
7394
|
}
|
|
7381
7395
|
if (isSlotValueComponent && transformedValue !== void 0) {
|
|
7382
7396
|
componentSlots.default = () => (transformedValue == null ? void 0 : transformedValue.toString()) || "";
|
|
@@ -11629,18 +11643,6 @@ const _sfc_main$R = /* @__PURE__ */ defineComponent({
|
|
|
11629
11643
|
formState.value = "error";
|
|
11630
11644
|
}
|
|
11631
11645
|
}
|
|
11632
|
-
function shouldRenderField(field) {
|
|
11633
|
-
const condition = field.vIf ?? field["v-if"];
|
|
11634
|
-
if (condition === void 0) return true;
|
|
11635
|
-
if (typeof condition === "function") {
|
|
11636
|
-
console.log("shouldRenderField", field.id, condition(formData.value[field.id], formData.value));
|
|
11637
|
-
return condition(formData.value[field.id], formData.value);
|
|
11638
|
-
}
|
|
11639
|
-
if (typeof condition === "string") {
|
|
11640
|
-
return !!formData.value[condition];
|
|
11641
|
-
}
|
|
11642
|
-
return !!condition;
|
|
11643
|
-
}
|
|
11644
11646
|
function validateForm() {
|
|
11645
11647
|
if (!form.value) return false;
|
|
11646
11648
|
return form.value.reportValidity();
|
|
@@ -11655,23 +11657,8 @@ const _sfc_main$R = /* @__PURE__ */ defineComponent({
|
|
|
11655
11657
|
(_a2 = field.onUpdate) == null ? void 0 : _a2.call(field, value, formData.value);
|
|
11656
11658
|
}
|
|
11657
11659
|
});
|
|
11658
|
-
function parseChildren(children2) {
|
|
11659
|
-
if (!children2) return void 0;
|
|
11660
|
-
return children2.map((child) => {
|
|
11661
|
-
if (typeof child === "string") return child;
|
|
11662
|
-
if (!shouldRenderField(child)) return null;
|
|
11663
|
-
if (!child.children) return child;
|
|
11664
|
-
const parsedChildren = parseChildren(child.children);
|
|
11665
|
-
return (parsedChildren == null ? void 0 : parsedChildren.length) ? { ...child, children: parsedChildren } : null;
|
|
11666
|
-
}).filter((child) => child !== null);
|
|
11667
|
-
}
|
|
11668
11660
|
function renderSchemaField(field) {
|
|
11669
|
-
|
|
11670
|
-
if (!shouldRender) return null;
|
|
11671
|
-
return renderField({
|
|
11672
|
-
...field,
|
|
11673
|
-
children: parseChildren(field.children)
|
|
11674
|
-
});
|
|
11661
|
+
return renderField(field);
|
|
11675
11662
|
}
|
|
11676
11663
|
__expose({ form, isDirty: isDirty.value, validateForm });
|
|
11677
11664
|
return (_ctx, _cache) => {
|
package/package.json
CHANGED
|
@@ -68,22 +68,6 @@ async function handleSubmit() {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
function shouldRenderField(field: Field): boolean {
|
|
72
|
-
const condition = field.vIf ?? field['v-if']
|
|
73
|
-
if (condition === undefined) return true
|
|
74
|
-
|
|
75
|
-
if (typeof condition === 'function') {
|
|
76
|
-
console.log('shouldRenderField', field.id, condition(formData.value[field.id as keyof T], formData.value))
|
|
77
|
-
return condition(formData.value[field.id as keyof T], formData.value)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (typeof condition === 'string') {
|
|
81
|
-
return !!formData.value[condition as keyof T]
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return !!condition
|
|
85
|
-
}
|
|
86
|
-
|
|
87
71
|
function validateForm() {
|
|
88
72
|
if (!form.value) return false
|
|
89
73
|
return form.value.reportValidity()
|
|
@@ -98,26 +82,9 @@ const { renderField } = useSchemaField<T>({
|
|
|
98
82
|
field.onUpdate?.(value, formData.value)
|
|
99
83
|
}
|
|
100
84
|
})
|
|
101
|
-
function parseChildren(children?: (string | Field)[]): (string | Field)[] | undefined {
|
|
102
|
-
if (!children) return undefined
|
|
103
|
-
return children
|
|
104
|
-
.map((child) => {
|
|
105
|
-
if (typeof child === 'string') return child
|
|
106
|
-
if (!shouldRenderField(child)) return null
|
|
107
|
-
if (!child.children) return child
|
|
108
|
-
const parsedChildren = parseChildren(child.children)
|
|
109
|
-
return parsedChildren?.length ? { ...child, children: parsedChildren } : null
|
|
110
|
-
})
|
|
111
|
-
.filter((child): child is string | Field => child !== null)
|
|
112
|
-
}
|
|
113
85
|
|
|
114
86
|
function renderSchemaField(field: Field): VNode | null {
|
|
115
|
-
|
|
116
|
-
if (!shouldRender) return null
|
|
117
|
-
return renderField({
|
|
118
|
-
...field,
|
|
119
|
-
children: parseChildren(field.children)
|
|
120
|
-
})
|
|
87
|
+
return renderField(field)
|
|
121
88
|
}
|
|
122
89
|
|
|
123
90
|
defineExpose({ form, isDirty, validateForm })
|
|
@@ -66,6 +66,22 @@ export function useSchemaField<T extends { [key: string]: any }>(options: UseSch
|
|
|
66
66
|
|
|
67
67
|
const rowData = getRowData?.() || {} as T
|
|
68
68
|
|
|
69
|
+
// Check vIf condition first
|
|
70
|
+
const condition = field.vIf ?? field['v-if']
|
|
71
|
+
if (condition !== undefined) {
|
|
72
|
+
if (typeof condition === 'function') {
|
|
73
|
+
if (!condition(field.id ? rowData[field.id as keyof T] : undefined, rowData)) {
|
|
74
|
+
return null
|
|
75
|
+
}
|
|
76
|
+
} else if (typeof condition === 'string') {
|
|
77
|
+
if (!rowData[condition as keyof T]) {
|
|
78
|
+
return null
|
|
79
|
+
}
|
|
80
|
+
} else if (!condition) {
|
|
81
|
+
return null
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
69
85
|
const {
|
|
70
86
|
$el,
|
|
71
87
|
children,
|
|
@@ -147,15 +163,17 @@ export function useSchemaField<T extends { [key: string]: any }>(options: UseSch
|
|
|
147
163
|
// Handle class binding last to ensure all transformations are applied
|
|
148
164
|
props.class = classify(currentValue, rowData, fieldClass, props.class)
|
|
149
165
|
|
|
150
|
-
// Handle component slots
|
|
166
|
+
// Handle component slots with vIf aware child rendering
|
|
151
167
|
const componentSlots: Record<string, any> = {}
|
|
152
168
|
|
|
153
169
|
// Add default slot if there are children
|
|
154
170
|
if (children?.length) {
|
|
155
|
-
componentSlots.default = () => children
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
171
|
+
componentSlots.default = () => children
|
|
172
|
+
.map((child) => {
|
|
173
|
+
if (typeof child === 'string') return child
|
|
174
|
+
return renderField(child, slots)
|
|
175
|
+
})
|
|
176
|
+
.filter(Boolean) // Filter out null results from vIf
|
|
159
177
|
}
|
|
160
178
|
|
|
161
179
|
// For slot value components, add the transformed value as default slot content
|