Skip to content

Commit 0878e61

Browse files
authored
add isupdating prop in former (#78)
1 parent be887e2 commit 0878e61

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

packages/former/src/components/Former.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,29 @@ const props = withDefaults(defineProps<{
1919
validator?: Validator;
2020
mode?: Mode;
2121
texts?: Partial<Texts>;
22-
}>(), { mode: 'edit', texts: () => ({}) });
22+
isUpdating?: boolean;
23+
}>(), {
24+
mode: 'edit',
25+
texts: () => ({}),
26+
isUpdating: false,
27+
});
2328
2429
const emit = defineEmits<{
2530
(e: 'valid', valid: boolean): void;
2631
(e: 'schemaValid', valid: boolean): void;
2732
}>();
2833
29-
const schema = defineModel<SchemaNode[]>('schema', { required: true });
34+
const isUpdating = toRef(props, 'isUpdating');
35+
provide('formerIsUpdating', isUpdating);
3036
37+
const schema = defineModel<SchemaNode[]>('schema', { required: true });
3138
const internalSchema = ref<InternalSchemaNode[]>([]);
3239
provide('schema', internalSchema);
3340
3441
const formId = ref(generateFormId());
3542
provide('formId', formId);
3643
3744
const latestSchema = ref<SchemaNode[]>();
38-
3945
watch(schema, (value) => {
4046
if (!isEqual(latestSchema.value, value)) {
4147
internalSchema.value = toInternalSchema(value);
@@ -69,14 +75,15 @@ provide('rootData', wrappedData);
6975
provide('rootSchema', schema);
7076
7177
provide('mode', toRef(props, 'mode'));
72-
7378
provide('components', props.components);
79+
7480
provide('showIf', (node: SchemaNode) => {
7581
if (!props.showIf) {
7682
return true;
7783
}
7884
return props.showIf(node, wrappedData.value, schema.value);
7985
});
86+
8087
const validator = props.validator || (() => true);
8188
provide('validator', validator);
8289

0 commit comments

Comments
 (0)