@bagelink/vue 0.0.218 → 0.0.226-beta.0
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/components/AccordionItem.vue.d.ts +23 -0
- package/dist/components/AccordionItem.vue.d.ts.map +1 -0
- package/dist/components/Avatar.vue.d.ts +20 -0
- package/dist/components/Avatar.vue.d.ts.map +1 -0
- package/dist/components/Card.vue.d.ts +27 -0
- package/dist/components/Card.vue.d.ts.map +1 -0
- package/dist/components/DataPreview.vue.d.ts +18 -18
- package/dist/components/DataPreview.vue.d.ts.map +1 -1
- package/dist/components/Drop.vue.d.ts +34 -0
- package/dist/components/Drop.vue.d.ts.map +1 -0
- package/dist/components/FileUploader.vue.d.ts +60 -0
- package/dist/components/FileUploader.vue.d.ts.map +1 -0
- package/dist/components/Modal.vue.d.ts.map +1 -1
- package/dist/components/ModalBglForm.vue.d.ts +50 -31
- package/dist/components/ModalBglForm.vue.d.ts.map +1 -1
- package/dist/components/NavBar.vue.d.ts +17 -12
- package/dist/components/NavBar.vue.d.ts.map +1 -1
- package/dist/components/TableSchema.vue.d.ts +5 -4
- package/dist/components/TableSchema.vue.d.ts.map +1 -1
- package/dist/components/Title.vue.d.ts +31 -0
- package/dist/components/Title.vue.d.ts.map +1 -0
- package/dist/components/form/BglField.vue.d.ts +19 -5
- package/dist/components/form/BglField.vue.d.ts.map +1 -1
- package/dist/components/form/BglForm.vue.d.ts +38 -27
- package/dist/components/form/BglForm.vue.d.ts.map +1 -1
- package/dist/components/form/ItemRef.vue.d.ts +1 -0
- package/dist/components/form/ItemRef.vue.d.ts.map +1 -1
- package/dist/components/form/index.d.ts +0 -3
- package/dist/components/form/index.d.ts.map +1 -1
- package/dist/components/form/inputs/CheckInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/DateInput.vue.d.ts +36 -38
- package/dist/components/form/inputs/DateInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/FileUpload.vue.d.ts +25 -15
- package/dist/components/form/inputs/FileUpload.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/SelectField.vue.d.ts +1 -4
- package/dist/components/form/inputs/SelectField.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/SelectInput.vue.d.ts +37 -0
- package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -0
- package/dist/components/form/inputs/TableField.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/ToggleInput.vue.d.ts +46 -0
- package/dist/components/form/inputs/ToggleInput.vue.d.ts.map +1 -0
- package/dist/components/form/inputs/index.d.ts +2 -3
- package/dist/components/form/inputs/index.d.ts.map +1 -1
- package/dist/components/formkit/index.d.ts +1 -2
- package/dist/components/formkit/index.d.ts.map +1 -1
- package/dist/components/index.d.ts +5 -4
- package/dist/components/index.d.ts.map +1 -1
- package/dist/index.cjs +14523 -13691
- package/dist/index.mjs +14524 -13692
- package/dist/plugins/bagel.d.ts +1 -1
- package/dist/plugins/bagel.d.ts.map +1 -1
- package/dist/plugins/modal.d.ts +1 -3
- package/dist/plugins/modal.d.ts.map +1 -1
- package/dist/style.css +744 -404
- package/dist/types/BagelForm.d.ts +8 -0
- package/dist/types/BagelForm.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/index.d.ts +5 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +12 -10
- package/src/components/AccordionItem.vue +100 -0
- package/src/components/Avatar.vue +47 -0
- package/src/components/Card.vue +13 -0
- package/src/components/Comments.vue +75 -75
- package/src/components/ContactArray.vue +10 -39
- package/src/components/DataPreview.vue +22 -49
- package/src/components/{DropDown.vue → Drop.vue} +55 -29
- package/src/components/FormKitTable.vue +121 -125
- package/src/components/Modal.vue +6 -23
- package/src/components/ModalBglForm.vue +10 -24
- package/src/components/NavBar.vue +33 -17
- package/src/components/RTXEditor.vue +69 -69
- package/src/components/TableSchema.vue +26 -72
- package/src/components/Title.vue +19 -0
- package/src/components/form/BglField.vue +29 -26
- package/src/components/form/BglForm.vue +19 -14
- package/src/components/form/index.ts +0 -3
- package/src/components/form/inputs/CheckInput.vue +20 -18
- package/src/components/form/inputs/DateInput.vue +16 -34
- package/src/components/form/inputs/FileUpload.vue +139 -19
- package/src/components/form/inputs/SelectField.vue +80 -138
- package/src/components/form/inputs/SelectInput.vue +517 -0
- package/src/components/form/inputs/TableField.vue +1 -5
- package/src/components/form/inputs/index.ts +2 -3
- package/src/components/formkit/index.ts +0 -3
- package/src/components/index.ts +5 -4
- package/src/plugins/bagel.ts +2 -2
- package/src/plugins/modal.ts +7 -13
- package/src/styles/inputs.css +2 -2
- package/src/styles/layout.css +1 -1
- package/src/styles/modal.css +3 -2
- package/src/styles/theme.css +7 -6
- package/src/types/BagelForm.ts +5 -0
- package/src/types/index.ts +1 -1
- package/src/utils/index.ts +26 -6
- package/src/components/ContactSubmissions.vue +0 -45
- package/src/components/PersonPreview.vue +0 -199
- package/src/components/PersonPreviewFormkit.vue +0 -178
- package/src/components/form/ItemRef.vue +0 -44
- package/src/components/form/MaterialIcon.vue +0 -19
- package/src/components/form/PlainInputField.vue +0 -79
- package/src/components/form/inputs/DynamicLinkField.vue +0 -137
- package/src/components/form/inputs/EmailInput.vue +0 -58
- package/src/types/Person.ts +0 -51
|
@@ -1,105 +1,105 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
<!-- :class="{ editable: editable }" -->
|
|
3
|
+
<div
|
|
4
|
+
@click="focusEditor"
|
|
5
|
+
:id="`canvas-${elementId}`"
|
|
6
|
+
@keydown.meta.enter="$emit('keydown.meta.enter')"
|
|
7
|
+
/>
|
|
8
8
|
</template>
|
|
9
9
|
|
|
10
10
|
<script setup lang="ts">
|
|
11
|
-
import { ref, onMounted, watch } from
|
|
12
|
-
import { DOMParser, DOMSerializer } from
|
|
13
|
-
import { EditorState } from
|
|
14
|
-
import { EditorView } from
|
|
15
|
-
import { keymap } from
|
|
16
|
-
import { baseKeymap } from
|
|
17
|
-
import { undo, redo, history } from
|
|
18
|
-
import { schema } from
|
|
11
|
+
import { ref, onMounted, watch } from 'vue';
|
|
12
|
+
import { DOMParser, DOMSerializer } from 'prosemirror-model';
|
|
13
|
+
import { EditorState } from 'prosemirror-state';
|
|
14
|
+
import { EditorView } from 'prosemirror-view';
|
|
15
|
+
import { keymap } from 'prosemirror-keymap';
|
|
16
|
+
import { baseKeymap } from 'prosemirror-commands';
|
|
17
|
+
import { undo, redo, history } from 'prosemirror-history';
|
|
18
|
+
import { schema } from 'prosemirror-schema-basic';
|
|
19
19
|
|
|
20
20
|
const props = withDefaults(
|
|
21
|
-
|
|
21
|
+
defineProps<{
|
|
22
22
|
elementId?: string;
|
|
23
23
|
modelValue: string;
|
|
24
24
|
}>(),
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
{
|
|
26
|
+
elementId: Math.random().toString(36).substr(2, 9),
|
|
27
|
+
modelValue: '',
|
|
28
|
+
},
|
|
29
29
|
);
|
|
30
30
|
|
|
31
|
-
const emit = defineEmits([
|
|
31
|
+
const emit = defineEmits(['update:modelValue', 'keydown.meta.enter']);
|
|
32
32
|
|
|
33
33
|
const html = ref<string>(props.modelValue);
|
|
34
34
|
let view: EditorView;
|
|
35
35
|
|
|
36
36
|
const createEditorStateFromHTML = (htmlContent: string) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
37
|
+
let content = { type: 'doc', content: [] };
|
|
38
|
+
try {
|
|
39
|
+
const dom = document.createElement('div');
|
|
40
|
+
dom.innerHTML = htmlContent || '';
|
|
41
|
+
content = DOMParser.fromSchema(schema)
|
|
42
|
+
.parse(dom, { preserveWhitespace: true })
|
|
43
|
+
.toJSON();
|
|
44
|
+
} catch (err) {
|
|
45
|
+
content = { type: 'doc', content: [] };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const state = EditorState.create({
|
|
49
|
+
doc: DOMParser.fromSchema(schema).schema.nodeFromJSON(content),
|
|
50
|
+
plugins: [
|
|
51
|
+
history(),
|
|
52
|
+
keymap({ 'Mod-z': undo, 'Mod-y': redo }),
|
|
53
|
+
keymap(baseKeymap),
|
|
54
|
+
],
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return state;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
function handleChange(newState: any) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
const dom = document.createElement('div');
|
|
62
|
+
const node = DOMSerializer.fromSchema(schema).serializeFragment(newState);
|
|
63
|
+
dom.appendChild(node);
|
|
64
|
+
html.value = dom?.innerHTML || '';
|
|
65
|
+
emit('update:modelValue', html.value);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
const createEditorView = (state: EditorState) => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
69
|
+
const editorDiv = document.getElementById(`canvas-${props.elementId}`);
|
|
70
|
+
view = new EditorView(editorDiv, {
|
|
71
|
+
state,
|
|
72
|
+
// editable: () => props.editable,
|
|
73
|
+
dispatchTransaction(transaction) {
|
|
74
|
+
const newState = view.state.apply(transaction);
|
|
75
|
+
handleChange(newState.doc);
|
|
76
|
+
view.updateState(newState);
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
view.setProps({
|
|
80
|
+
// editable: () => props.editable,
|
|
81
|
+
});
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
function loadContent() {
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
const state = createEditorStateFromHTML(props.modelValue);
|
|
86
|
+
createEditorView(state);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
watch(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
() => props.modelValue,
|
|
91
|
+
(val: string) => {
|
|
92
|
+
if (val === html.value) return;
|
|
93
|
+
const el = document.getElementById(`canvas-${props.elementId}`);
|
|
94
|
+
if (el) el.innerHTML = '';
|
|
95
|
+
loadContent();
|
|
96
|
+
},
|
|
97
97
|
);
|
|
98
98
|
|
|
99
99
|
onMounted(loadContent);
|
|
100
100
|
|
|
101
101
|
function focusEditor() {
|
|
102
|
-
|
|
102
|
+
view.focus();
|
|
103
103
|
}
|
|
104
104
|
</script>
|
|
105
105
|
|
|
@@ -2,59 +2,28 @@
|
|
|
2
2
|
<div class="table-list-wrap h-100">
|
|
3
3
|
<table class="infinite-wrapper">
|
|
4
4
|
<thead class="row first-row">
|
|
5
|
-
<th
|
|
6
|
-
class="col"
|
|
7
|
-
v-for="field in columns"
|
|
8
|
-
:key="field.id"
|
|
9
|
-
@click="sort(field.id)"
|
|
10
|
-
>
|
|
5
|
+
<th class="col" v-for="field in schema" :key="field.id" @click="sort(field?.id || '')">
|
|
11
6
|
<div class="flex">
|
|
12
|
-
{{ field
|
|
13
|
-
<div
|
|
14
|
-
class="
|
|
15
|
-
:class="{ sorted: sortField === field.id }"
|
|
16
|
-
>
|
|
17
|
-
<MaterialIcon
|
|
18
|
-
:class="{ desc: sortDirection === 'DESC' }"
|
|
19
|
-
icon="keyboard_arrow_up"
|
|
20
|
-
/>
|
|
7
|
+
{{ field.id }}
|
|
8
|
+
<div class="list-arrows" :class="{ sorted: sortField === field.id }">
|
|
9
|
+
<MaterialIcon :class="{ desc: sortDirection === 'DESC' }" icon="keyboard_arrow_up" />
|
|
21
10
|
</div>
|
|
22
11
|
</div>
|
|
23
12
|
</th>
|
|
24
13
|
</thead>
|
|
25
|
-
<tbody
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
>
|
|
30
|
-
<tr
|
|
31
|
-
@click="selectElement(row)"
|
|
32
|
-
class="row row-item position-relative"
|
|
33
|
-
v-for="row in data"
|
|
34
|
-
:key="row.id"
|
|
35
|
-
>
|
|
36
|
-
<td
|
|
37
|
-
class="col"
|
|
38
|
-
v-for="field in columns"
|
|
39
|
-
:key="`${field.id}-${row.id}`"
|
|
40
|
-
>
|
|
41
|
-
<slot
|
|
42
|
-
v-if="slots[field.id]"
|
|
43
|
-
:name="field.id"
|
|
44
|
-
:row="row"
|
|
45
|
-
:field="field"
|
|
46
|
-
/>
|
|
14
|
+
<tbody ref="infinite" class="rows infinite" :class="{ loading }">
|
|
15
|
+
<tr @click="selectElement(row)" class="row row-item position-relative" v-for="row in data" :key="row.id">
|
|
16
|
+
<td class="col" v-for="field in schema" :key="`${field.id}-${row.id}`">
|
|
17
|
+
<slot v-if="field.id && slots[field.id]" :name="field.id" :row="row" :field="field" />
|
|
47
18
|
<div v-else>
|
|
48
|
-
<component
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
:
|
|
53
|
-
@update:modelValue="($event: any) => field?.onUpdate?.($event, row
|
|
54
|
-
:modelValue="row[field.id]"
|
|
55
|
-
>
|
|
19
|
+
<component :is="field.$el || 'div'" v-if="iffer(field, row)"
|
|
20
|
+
v-bind="bindAttrs(field.attrs, denullify(row, field.id), row)"
|
|
21
|
+
:class="classify(denullify(row, field.id), row, field.class, field.attrs?.class)"
|
|
22
|
+
:src="field.$el === 'img' && field.id ? row[field.id]?.url : ''"
|
|
23
|
+
:modelValue="field.id ? row[field.id] : ''"
|
|
24
|
+
@update:modelValue="($event: any) => field?.onUpdate?.($event, denullify(row, field.id), row)">
|
|
56
25
|
{{
|
|
57
|
-
field?.transform?.(row
|
|
26
|
+
field?.transform?.(denullify(row, field.id), row) || denullify(row, field.id) || ""
|
|
58
27
|
}}
|
|
59
28
|
</component>
|
|
60
29
|
</div>
|
|
@@ -68,34 +37,27 @@
|
|
|
68
37
|
|
|
69
38
|
<script setup lang="ts">
|
|
70
39
|
import { useSlots } from 'vue';
|
|
71
|
-
import {
|
|
40
|
+
import {
|
|
41
|
+
type BglFormSchemaT,
|
|
42
|
+
bindAttrs,
|
|
43
|
+
classify,
|
|
44
|
+
denullify,
|
|
45
|
+
MaterialIcon,
|
|
46
|
+
iffer,
|
|
47
|
+
} from '@bagelink/vue';
|
|
72
48
|
|
|
73
49
|
const slots = useSlots();
|
|
74
50
|
const loading = $ref(true);
|
|
75
51
|
|
|
76
|
-
|
|
52
|
+
defineProps<{
|
|
77
53
|
data: any[];
|
|
78
|
-
schema
|
|
54
|
+
schema: BglFormSchemaT;
|
|
79
55
|
}>();
|
|
80
56
|
|
|
81
|
-
|
|
82
|
-
|
|
83
57
|
const emit = defineEmits(['select']);
|
|
84
58
|
|
|
85
|
-
const selectElement = (data: Record<string, any>) =>
|
|
86
|
-
emit('select', data);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const bindAttrs = (attrs: Record<string, any>, field: any, row: any) => {
|
|
90
|
-
const arr = Object.entries(attrs || {}).map(([key, value]) => [
|
|
91
|
-
key,
|
|
92
|
-
typeof value === 'function' ? value(field, row) : value,
|
|
93
|
-
]);
|
|
94
|
-
const resolvedAttrs = Object.fromEntries(arr);
|
|
95
|
-
return resolvedAttrs;
|
|
96
|
-
};
|
|
59
|
+
const selectElement = (data: Record<string, any>) => emit('select', data);
|
|
97
60
|
|
|
98
|
-
// const sortList = () => {};
|
|
99
61
|
let sortDirection = $ref('');
|
|
100
62
|
let sortField = $ref('');
|
|
101
63
|
|
|
@@ -108,14 +70,6 @@ const sort = (fieldname: string) => {
|
|
|
108
70
|
sortDirection = 'ASC';
|
|
109
71
|
}
|
|
110
72
|
};
|
|
111
|
-
|
|
112
|
-
const columns = $computed(
|
|
113
|
-
() => props.schema?.()?.map((field) => ({
|
|
114
|
-
...field,
|
|
115
|
-
id: field?.relationshipObjKey || field.id,
|
|
116
|
-
})) ||
|
|
117
|
-
Object.keys(props.data[0]).map((k: string) => ({ id: k, inputType: 'PlainText' })),
|
|
118
|
-
);
|
|
119
73
|
</script>
|
|
120
74
|
|
|
121
75
|
<style scoped>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component :is="tag">
|
|
3
|
+
<slot />
|
|
4
|
+
{{ label }}
|
|
5
|
+
</component>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script lang="ts" setup>
|
|
9
|
+
defineProps({
|
|
10
|
+
label: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: '',
|
|
13
|
+
},
|
|
14
|
+
tag: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: 'h1',
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
</script>
|
|
@@ -1,39 +1,42 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<component
|
|
3
|
-
:
|
|
4
|
-
|
|
5
|
-
v-
|
|
6
|
-
:is="field.$el || 'div'"
|
|
7
|
-
:label="field.label"
|
|
8
|
-
:id="field.id"
|
|
9
|
-
:placeholder="field.placeholder || field.label"
|
|
10
|
-
:modelValue="props.modelValue[field.id || '']"
|
|
11
|
-
@update:modelValue="($event:any)=>emits('update:modelValue', $event)"
|
|
12
|
-
>
|
|
13
|
-
<BglField
|
|
14
|
-
:modelValue="modelValue"
|
|
15
|
-
@update:modelValue="($event:any)=>emits('update:modelValue', $event)"
|
|
16
|
-
v-for="(child,ii) in field.children" :key="child.id||ii"
|
|
17
|
-
:field="child"
|
|
18
|
-
/>
|
|
2
|
+
<component :required="field.required" v-bind="bindAttrs(field?.attrs || {}, fieldData, modelValue)"
|
|
3
|
+
:class="classify(fieldData, modelValue, field.class, field.attrs?.class)" v-if="vIf" :is="field.$el || 'div'"
|
|
4
|
+
:label="field.label" :id="field.id" :placeholder="field.placeholder || field.label" v-model="fieldData">
|
|
5
|
+
<BglField v-model="formData" v-for="(child, ii) in field.children" :key="child.id || ii" :field="child" />
|
|
19
6
|
</component>
|
|
20
7
|
</template>
|
|
21
8
|
|
|
22
9
|
<script lang="ts" setup>
|
|
23
|
-
import { type Field, bindAttrs } from '@bagelink/vue';
|
|
10
|
+
import { type Field, bindAttrs, classify } from '@bagelink/vue';
|
|
24
11
|
|
|
25
|
-
const props = defineProps<{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
const props = withDefaults(defineProps<{
|
|
13
|
+
field: Field
|
|
14
|
+
modelValue: Record<string, any>
|
|
15
|
+
}>(), {
|
|
16
|
+
modelValue: () => ({}),
|
|
17
|
+
});
|
|
18
|
+
const emit = defineEmits(['update:modelValue']);
|
|
19
|
+
|
|
20
|
+
const formData = $computed({
|
|
21
|
+
get: () => props.modelValue,
|
|
22
|
+
set: (val: any) => emit('update:modelValue', val),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const fieldData = $computed({
|
|
26
|
+
set: (val: any) => {
|
|
27
|
+
if (!props.field.id) return;
|
|
28
|
+
const data = { ...props.modelValue } || {};
|
|
29
|
+
data[props.field.id] = val;
|
|
30
|
+
emit('update:modelValue', data);
|
|
31
|
+
},
|
|
32
|
+
get: () => (props.field.id ? props.modelValue[props.field.id] : ''),
|
|
33
|
+
});
|
|
29
34
|
|
|
30
35
|
const vIf = $computed(() => {
|
|
31
36
|
if (props.field['v-if'] === undefined) return true;
|
|
32
37
|
if (typeof props.field['v-if'] === 'boolean') return props.field['v-if'];
|
|
33
|
-
if (typeof props.field['v-if'] === 'string') return !!props.modelValue[props.field['v-if']];
|
|
34
|
-
if (typeof props.field['v-if'] === 'function') return props.field['v-if']!(
|
|
38
|
+
if (typeof props.field['v-if'] === 'string') return !!props.modelValue.value[props.field['v-if']];
|
|
39
|
+
if (typeof props.field['v-if'] === 'function') return props.field['v-if']!(fieldData.value, props.modelValue);
|
|
35
40
|
return true;
|
|
36
41
|
});
|
|
37
|
-
|
|
38
|
-
const emits = defineEmits(['update:modelValue']);
|
|
39
42
|
</script>
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<form ref="form" @submit.prevent="runSubmit">
|
|
3
3
|
<BglField
|
|
4
|
-
v-for="(field, i) in schema" :key="field.id || `${i
|
|
5
|
-
@update:modelValue="($event)=>updateModelValue($event, field?.id || '')"
|
|
4
|
+
v-for="(field, i) in schema" :key="field.id || `${i}p`" :field="field" v-model="data"
|
|
6
5
|
/>
|
|
7
6
|
<Btn
|
|
8
7
|
class="del-top" v-if="data?.id && onDelete" @click="runDelete" value="Delete" flat icon="delete"
|
|
@@ -21,31 +20,37 @@ import { type BglFormSchemaT } from '@bagelink/vue';
|
|
|
21
20
|
|
|
22
21
|
const { showModal } = useModal();
|
|
23
22
|
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
const props = defineProps<{
|
|
23
|
+
const props = withDefaults(
|
|
24
|
+
defineProps<{
|
|
27
25
|
schema: BglFormSchemaT;
|
|
26
|
+
modelValue?: Record<string, any>;
|
|
28
27
|
onDelete?: ((id: string) => void);
|
|
29
28
|
onSubmit?: ((data: any) => void);
|
|
30
|
-
}>()
|
|
29
|
+
}>(),
|
|
30
|
+
{
|
|
31
|
+
modelValue: () => ({}),
|
|
32
|
+
},
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const emit = defineEmits(['update:modelValue', 'submit']);
|
|
31
36
|
|
|
37
|
+
const data = $computed({
|
|
38
|
+
set: (val: any) => {
|
|
39
|
+
emit('update:modelValue', val);
|
|
40
|
+
},
|
|
41
|
+
get: () => props.modelValue || {},
|
|
42
|
+
});
|
|
32
43
|
const form = $ref<HTMLFormElement>();
|
|
33
44
|
|
|
34
45
|
const validateForm = () => form?.reportValidity?.();
|
|
35
46
|
|
|
36
|
-
const updateModelValue = (val: any, fieldID: string) => {
|
|
37
|
-
if (!fieldID || !data.value) return;
|
|
38
|
-
data.value[fieldID] = val;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
47
|
defineExpose({ validateForm });
|
|
42
48
|
|
|
43
|
-
const clearForm = () => Object.assign(data, {});
|
|
44
|
-
const emits = defineEmits(['submit']);
|
|
49
|
+
const clearForm = () => Object.assign(data.value, {});
|
|
45
50
|
|
|
46
51
|
const runSubmit = () => {
|
|
47
52
|
validateForm();
|
|
48
|
-
|
|
53
|
+
emit('submit', data.value);
|
|
49
54
|
clearForm();
|
|
50
55
|
};
|
|
51
56
|
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
export { default as ItemRef } from './ItemRef.vue';
|
|
2
|
-
export { default as MaterialIcon } from './MaterialIcon.vue';
|
|
3
|
-
export { default as PlainInputField } from './PlainInputField.vue';
|
|
4
1
|
export { default as BglForm } from './BglForm.vue';
|
|
5
2
|
export { default as BagelForm } from './BglForm.vue';
|
|
6
3
|
export { default as BglField } from './BglField.vue';
|
|
@@ -10,12 +10,14 @@
|
|
|
10
10
|
v-model="inputVal"
|
|
11
11
|
:class="{ 'no-edit': !editMode }"
|
|
12
12
|
>
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
<div class="check-square">
|
|
14
|
+
<svg
|
|
15
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
16
|
+
height="24" viewBox="0 -960 960 960"
|
|
17
|
+
width="24"
|
|
18
|
+
>
|
|
19
|
+
<path d="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"/></svg>
|
|
20
|
+
</div>
|
|
19
21
|
<label :for="id">
|
|
20
22
|
{{ label }}
|
|
21
23
|
</label>
|
|
@@ -51,13 +53,16 @@ const inputVal = defineModel<boolean>('modelValue', { default: false });
|
|
|
51
53
|
</style>
|
|
52
54
|
<style scoped>
|
|
53
55
|
.bgl-checkbox{
|
|
54
|
-
position: relative;
|
|
56
|
+
position: relative;
|
|
57
|
+
display: flex;
|
|
58
|
+
flex-direction: row;
|
|
59
|
+
align-items: center;
|
|
55
60
|
}
|
|
56
61
|
.bgl-checkbox input[type=checkbox]{
|
|
57
62
|
display: none;
|
|
58
63
|
}
|
|
59
64
|
.bgl-checkbox label{
|
|
60
|
-
padding-inline-start:
|
|
65
|
+
padding-inline-start: 0.5rem;
|
|
61
66
|
transition: var(--bgl-transition);
|
|
62
67
|
cursor: pointer;
|
|
63
68
|
user-select: none;
|
|
@@ -68,34 +73,31 @@ position: relative;
|
|
|
68
73
|
.bgl-checkbox:active{
|
|
69
74
|
filter: var(--bgl-active-filter);
|
|
70
75
|
}
|
|
71
|
-
.bgl-checkbox
|
|
72
|
-
content: "";
|
|
76
|
+
.bgl-checkbox .check-square{
|
|
73
77
|
width: calc(var(--input-height) / 2.5);
|
|
74
78
|
height: calc(var(--input-height) / 2.5);
|
|
75
79
|
background: var(--bgl-white);
|
|
76
|
-
display: inline-block;
|
|
77
|
-
position: absolute;
|
|
78
|
-
margin-top: 0.25rem;
|
|
79
|
-
inset-inline-start: 0;
|
|
80
80
|
border-radius: calc(var(--input-border-radius) / 2) ;
|
|
81
81
|
border: var(--bgl-primary) 1px solid;
|
|
82
|
+
position: relative;
|
|
83
|
+
display: flex;
|
|
84
|
+
align-items: center;
|
|
85
|
+
justify-content: center;
|
|
82
86
|
}
|
|
83
87
|
|
|
84
|
-
input:checked ~
|
|
88
|
+
input:checked ~ .check-square{
|
|
85
89
|
background: var(--bgl-primary);
|
|
86
90
|
}
|
|
87
91
|
.bgl-checkbox svg{
|
|
88
92
|
width: calc(var(--input-height) / 2.5);
|
|
89
93
|
height: calc(var(--input-height) / 2.5);
|
|
90
94
|
position: absolute;
|
|
91
|
-
inset-inline-start: 0.05rem;
|
|
92
|
-
margin-top: 0.3rem;
|
|
93
95
|
z-index: 2;
|
|
94
96
|
fill: var(--bgl-white);
|
|
95
97
|
opacity: 0;
|
|
96
98
|
pointer-events: none;
|
|
97
99
|
}
|
|
98
|
-
input:checked ~ svg{
|
|
100
|
+
input:checked ~ .check-square svg{
|
|
99
101
|
opacity: 1;
|
|
100
102
|
}
|
|
101
103
|
</style>
|
|
@@ -1,55 +1,37 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
:class="{ small: small }"
|
|
6
|
-
>
|
|
7
|
-
<label v-if="field.label">
|
|
8
|
-
{{ field.label }}
|
|
2
|
+
<div class="bagel-input" :title="label" :class="{ small: small }">
|
|
3
|
+
<label v-if="label">
|
|
4
|
+
{{ label }}
|
|
9
5
|
</label>
|
|
10
|
-
<
|
|
11
|
-
type="date"
|
|
12
|
-
v-model="date"
|
|
13
|
-
@update:modelValue="handleInput"
|
|
14
|
-
:placeholder="field.placeholder || field.label"
|
|
15
|
-
class="date-picker"
|
|
16
|
-
:disabled="!editMode"
|
|
17
|
-
:enableTimePicker="false"
|
|
18
|
-
:textInputOptions="{ format: 'yyyy-MM-dd' }"
|
|
19
|
-
>
|
|
6
|
+
<VDatepicker ref="datePicker" :auto-apply="true" v-model="date" :enable-time-picker="enableTime"/>
|
|
20
7
|
</div>
|
|
21
8
|
</template>
|
|
22
9
|
|
|
23
10
|
<script setup lang="ts">
|
|
24
|
-
import {
|
|
25
|
-
import
|
|
11
|
+
import VDatepicker, { DatePickerInstance } from '@vuepic/vue-datepicker';
|
|
12
|
+
import '@vuepic/vue-datepicker/dist/main.css';
|
|
26
13
|
|
|
27
|
-
const
|
|
14
|
+
const datePicker = $ref<DatePickerInstance>();
|
|
15
|
+
|
|
16
|
+
withDefaults(
|
|
28
17
|
defineProps<{
|
|
29
|
-
|
|
30
|
-
modelValue: any;
|
|
18
|
+
label?: string;
|
|
31
19
|
editMode?: boolean;
|
|
32
20
|
small?: boolean;
|
|
21
|
+
enableTime?: boolean;
|
|
33
22
|
}>(),
|
|
34
23
|
{
|
|
24
|
+
enableTime: false,
|
|
35
25
|
editMode: true,
|
|
36
26
|
small: false,
|
|
37
27
|
},
|
|
38
28
|
);
|
|
39
29
|
|
|
40
|
-
const date =
|
|
41
|
-
|
|
42
|
-
const emit = defineEmits(['update:modelValue']);
|
|
43
|
-
|
|
44
|
-
const handleInput = () => {
|
|
45
|
-
emit('update:modelValue', date.value.toISOString().split('T').shift());
|
|
46
|
-
};
|
|
30
|
+
const date = defineModel<string | Date>('modelValue', { default: '' });
|
|
47
31
|
</script>
|
|
48
32
|
|
|
49
|
-
<style
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
padding-inline-start: 10px;
|
|
33
|
+
<style>
|
|
34
|
+
.dp__input_wrap input {
|
|
35
|
+
padding-inline-start: 2rem !important;
|
|
53
36
|
}
|
|
54
|
-
*/
|
|
55
37
|
</style>
|