sprintify-ui 0.10.50 → 0.10.52
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/{BaseCkeditor-C9d4NSCx.js → BaseCkeditor-Dz9KdCFr.js} +35 -25
- package/dist/sprintify-ui.es.js +2999 -2972
- package/dist/types/components/BaseCkeditor.vue.d.ts +5 -1
- package/dist/types/components/BaseDraggable.vue.d.ts +3 -3
- package/dist/types/composables/field.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/BaseCkeditor.vue +17 -1
- package/src/components/BaseDraggable.vue +3 -3
- package/src/components/BaseForm.vue +21 -1
- package/src/components/BaseRichText.vue +17 -1
- package/src/composables/field.ts +18 -0
|
@@ -10,16 +10,20 @@ type __VLS_Props = {
|
|
|
10
10
|
required?: boolean;
|
|
11
11
|
name?: string;
|
|
12
12
|
};
|
|
13
|
-
declare const _default: import("vue").DefineComponent<__VLS_Props, {
|
|
13
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {
|
|
14
|
+
getEditorData(): string;
|
|
15
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
14
16
|
blur: (...args: any[]) => void;
|
|
15
17
|
focus: (...args: any[]) => void;
|
|
16
18
|
input: (...args: any[]) => void;
|
|
17
19
|
"update:modelValue": (...args: any[]) => void;
|
|
20
|
+
ready: (...args: any[]) => void;
|
|
18
21
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
19
22
|
onBlur?: ((...args: any[]) => any) | undefined;
|
|
20
23
|
onFocus?: ((...args: any[]) => any) | undefined;
|
|
21
24
|
onInput?: ((...args: any[]) => any) | undefined;
|
|
22
25
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
26
|
+
onReady?: ((...args: any[]) => any) | undefined;
|
|
23
27
|
}>, {
|
|
24
28
|
size: Size;
|
|
25
29
|
required: boolean;
|
|
@@ -3,7 +3,7 @@ type __VLS_Props = {
|
|
|
3
3
|
itemKey: string;
|
|
4
4
|
handle?: string;
|
|
5
5
|
disabled?: boolean;
|
|
6
|
-
|
|
6
|
+
as?: string;
|
|
7
7
|
};
|
|
8
8
|
declare const elementsRef: import("vue").Ref<HTMLElement | null, HTMLElement | null>;
|
|
9
9
|
declare function getKey(element: any): any;
|
|
@@ -25,7 +25,7 @@ declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
|
|
|
25
25
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
26
26
|
}>, {
|
|
27
27
|
disabled: boolean;
|
|
28
|
-
|
|
28
|
+
as: string;
|
|
29
29
|
itemKey: string;
|
|
30
30
|
handle: string;
|
|
31
31
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -35,7 +35,7 @@ declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}
|
|
|
35
35
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
36
36
|
}>, {
|
|
37
37
|
disabled: boolean;
|
|
38
|
-
|
|
38
|
+
as: string;
|
|
39
39
|
itemKey: string;
|
|
40
40
|
handle: string;
|
|
41
41
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -18,5 +18,7 @@ export declare function useField(config: Config): {
|
|
|
18
18
|
emitUpdate: (value: any) => void;
|
|
19
19
|
enableForm: () => void;
|
|
20
20
|
disableForm: () => void;
|
|
21
|
+
addBeforeSubmitListener: (listener: () => void) => void;
|
|
22
|
+
removeBeforeSubmitListener: () => void;
|
|
21
23
|
};
|
|
22
24
|
export {};
|
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
@focus="emit('focus', $event)"
|
|
10
10
|
@blur="emit('blur', $event)"
|
|
11
11
|
@input="emit('input', $event)"
|
|
12
|
+
@ready="onReady"
|
|
12
13
|
/>
|
|
13
14
|
</template>
|
|
14
15
|
|
|
@@ -41,7 +42,16 @@ const props = withDefaults(defineProps<{
|
|
|
41
42
|
hasError: false,
|
|
42
43
|
});
|
|
43
44
|
|
|
44
|
-
const emit = defineEmits(['update:modelValue', 'focus', 'blur', 'input']);
|
|
45
|
+
const emit = defineEmits(['update:modelValue', 'focus', 'blur', 'input', 'ready']);
|
|
46
|
+
|
|
47
|
+
type Editor = InlineEditor | BalloonEditor | ClassicEditor;
|
|
48
|
+
|
|
49
|
+
let ckeditorInstance = null as Editor | null;
|
|
50
|
+
|
|
51
|
+
function onReady(editor: Editor | null) {
|
|
52
|
+
ckeditorInstance = editor;
|
|
53
|
+
emit('ready', editor);
|
|
54
|
+
}
|
|
45
55
|
|
|
46
56
|
const editorInternal = computed(() => {
|
|
47
57
|
switch (props.editor) {
|
|
@@ -134,4 +144,10 @@ const config = computed(() => {
|
|
|
134
144
|
};
|
|
135
145
|
});
|
|
136
146
|
|
|
147
|
+
defineExpose({
|
|
148
|
+
getEditorData() {
|
|
149
|
+
return ckeditorInstance?.getData() || '';
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
|
|
137
153
|
</script>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<component
|
|
3
|
-
:is="
|
|
3
|
+
:is="as"
|
|
4
4
|
ref="elementsRef"
|
|
5
5
|
>
|
|
6
6
|
<slot
|
|
@@ -22,12 +22,12 @@ const props = withDefaults(defineProps<{
|
|
|
22
22
|
itemKey: string;
|
|
23
23
|
handle?: string;
|
|
24
24
|
disabled?: boolean;
|
|
25
|
-
|
|
25
|
+
as?: string
|
|
26
26
|
}>(), {
|
|
27
27
|
itemKey: 'id',
|
|
28
28
|
handle: '.handle',
|
|
29
29
|
disabled: false,
|
|
30
|
-
|
|
30
|
+
as: 'div', // Default to a div if not specified
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
const emit = defineEmits(['update:modelValue']);
|
|
@@ -192,13 +192,20 @@ function submit() {
|
|
|
192
192
|
props.beforeSubmit(query);
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
function query() {
|
|
195
|
+
async function query() {
|
|
196
196
|
if (loading.value) {
|
|
197
197
|
return;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
loading.value = true;
|
|
201
201
|
|
|
202
|
+
Object.values(beforeSubmitListeners).forEach((listener) => {
|
|
203
|
+
listener();
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
// The listener might have changed the data, so we need to wait for the next tick
|
|
207
|
+
await nextTick();
|
|
208
|
+
|
|
202
209
|
let method = props.method as Method;
|
|
203
210
|
let data = props.data;
|
|
204
211
|
let headers = { 'Content-Type': 'application/json' };
|
|
@@ -329,6 +336,16 @@ const disabled = computed((): boolean => {
|
|
|
329
336
|
return disablingFields.size > 0;
|
|
330
337
|
});
|
|
331
338
|
|
|
339
|
+
const beforeSubmitListeners = {} as Record<string, () => void>;
|
|
340
|
+
|
|
341
|
+
function addBeforeSubmitListener(uuid: string, listener: () => void) {
|
|
342
|
+
beforeSubmitListeners[uuid] = listener;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function removeBeforeSubmitListener(uuid: string) {
|
|
346
|
+
delete beforeSubmitListeners[uuid];
|
|
347
|
+
}
|
|
348
|
+
|
|
332
349
|
provide('form:autosave', computed(() => props.autosave));
|
|
333
350
|
provide('form:submit', submit);
|
|
334
351
|
provide('form:submitDebounced', submitDebounced);
|
|
@@ -341,6 +358,9 @@ provide('form:disabled', readonly(disabled));
|
|
|
341
358
|
provide('form:enable', enableForm);
|
|
342
359
|
provide('form:disable', disabledForm);
|
|
343
360
|
|
|
361
|
+
provide('form:addBeforeSubmitListener', addBeforeSubmitListener);
|
|
362
|
+
provide('form:removeBeforeSubmitListener', removeBeforeSubmitListener);
|
|
363
|
+
|
|
344
364
|
defineExpose({
|
|
345
365
|
submit,
|
|
346
366
|
errors,
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
]"
|
|
12
12
|
>
|
|
13
13
|
<BaseCkeditor
|
|
14
|
+
ref="baseCkeditorRef"
|
|
14
15
|
:model-value="modelValue"
|
|
15
16
|
:editor="editor"
|
|
16
17
|
:size="sizeInternal"
|
|
@@ -59,7 +60,7 @@ const props = withDefaults(defineProps<{
|
|
|
59
60
|
|
|
60
61
|
const emit = defineEmits(['update:modelValue', 'focus', 'blur', 'input']);
|
|
61
62
|
|
|
62
|
-
const { nameInternal, requiredInternal, hasErrorInternal, emitUpdate, sizeInternal } =
|
|
63
|
+
const { nameInternal, requiredInternal, hasErrorInternal, emitUpdate, sizeInternal, addBeforeSubmitListener } =
|
|
63
64
|
useField({
|
|
64
65
|
name: computed(() => props.name),
|
|
65
66
|
required: computed(() => props.required),
|
|
@@ -68,4 +69,19 @@ const { nameInternal, requiredInternal, hasErrorInternal, emitUpdate, sizeIntern
|
|
|
68
69
|
emit: emit,
|
|
69
70
|
});
|
|
70
71
|
|
|
72
|
+
const baseCkeditorRef = ref<InstanceType<typeof BaseCkeditor> | null>(null);
|
|
73
|
+
|
|
74
|
+
// This make sure that the latest editor data is emitted when the form is submitted
|
|
75
|
+
// If the user types really fast, then press submit really fast, the editor data might not be up to date
|
|
76
|
+
// This is a workaround to make sure that the latest data is emitted
|
|
77
|
+
addBeforeSubmitListener(() => {
|
|
78
|
+
if (!baseCkeditorRef.value) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const latestData = baseCkeditorRef.value.getEditorData();
|
|
83
|
+
|
|
84
|
+
emitUpdate(latestData);
|
|
85
|
+
});
|
|
86
|
+
|
|
71
87
|
</script>
|
package/src/composables/field.ts
CHANGED
|
@@ -79,6 +79,18 @@ export function useField(config: Config) {
|
|
|
79
79
|
enableForm(uuid);
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
+
const addBeforeSubmitListener = inject('form:addBeforeSubmitListener', () => {
|
|
83
|
+
return;
|
|
84
|
+
}) as (uuid: string, listener: () => void) => void;
|
|
85
|
+
|
|
86
|
+
const removeBeforeSubmitListener = inject('form:removeBeforeSubmitListener', () => {
|
|
87
|
+
return;
|
|
88
|
+
}) as (uuid: string) => void;
|
|
89
|
+
|
|
90
|
+
onBeforeUnmount(() => {
|
|
91
|
+
removeBeforeSubmitListener(uuid);
|
|
92
|
+
});
|
|
93
|
+
|
|
82
94
|
const requiredInternal = computed((): boolean => {
|
|
83
95
|
if (required.value !== undefined) {
|
|
84
96
|
return required.value;
|
|
@@ -134,5 +146,11 @@ export function useField(config: Config) {
|
|
|
134
146
|
emitUpdate,
|
|
135
147
|
enableForm: () => enableForm(uuid),
|
|
136
148
|
disableForm: () => disableForm(uuid),
|
|
149
|
+
addBeforeSubmitListener: (listener: () => void) => {
|
|
150
|
+
addBeforeSubmitListener(uuid, listener);
|
|
151
|
+
},
|
|
152
|
+
removeBeforeSubmitListener: () => {
|
|
153
|
+
removeBeforeSubmitListener(uuid);
|
|
154
|
+
}
|
|
137
155
|
};
|
|
138
156
|
}
|