@bagelink/vue 0.0.25 → 0.0.32
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/package.json +32 -9
- package/src/components/Btn.vue +221 -0
- package/src/components/Comments.vue +265 -0
- package/src/components/ContactArray.vue +127 -0
- package/src/components/ContactSubmissions.vue +42 -0
- package/src/components/DataPreview.vue +72 -0
- package/src/components/DropDown.vue +122 -0
- package/src/components/FileUploader.vue +344 -0
- package/src/components/FormKitTable.vue +250 -0
- package/src/components/FormSchema.vue +65 -0
- package/src/components/LangText.vue +30 -0
- package/src/components/ListItem.vue +16 -0
- package/src/components/ListView.vue +39 -0
- package/src/components/MaterialIcon.vue +16 -0
- package/src/components/Modal.vue +50 -0
- package/src/components/ModalForm.vue +94 -0
- package/src/components/NavBar.vue +343 -0
- package/src/components/PageTitle.vue +17 -0
- package/src/components/PersonPreview.vue +205 -0
- package/src/components/PersonPreviewFormkit.vue +205 -0
- package/src/components/RTXEditor.vue +147 -0
- package/src/components/RouterWrapper.vue +9 -0
- package/src/components/TabbedLayout.vue +80 -0
- package/src/components/TableSchema.vue +213 -0
- package/src/components/TopBar.vue +5 -0
- package/src/components/charts/BarChart.vue +290 -0
- package/src/components/dashboard/Lineart.vue +165 -0
- package/src/components/form/ItemRef.vue +38 -0
- package/src/components/form/MaterialIcon.vue +19 -0
- package/src/components/form/PlainInputField.vue +80 -0
- package/src/components/form/inputs/CheckInput.vue +143 -0
- package/src/components/form/inputs/Checkbox.vue +69 -0
- package/src/components/form/inputs/ColorPicker.vue +37 -0
- package/src/components/form/inputs/CurrencyInput.vue +133 -0
- package/src/components/form/inputs/DateInput.vue +49 -0
- package/src/components/form/inputs/DatetimeInput.vue +46 -0
- package/src/components/form/inputs/DurationInput.vue +51 -0
- package/src/components/form/inputs/DynamicLinkField.vue +140 -0
- package/src/components/form/inputs/EmailInput.vue +53 -0
- package/src/components/form/inputs/FloatInput.vue +48 -0
- package/src/components/form/inputs/IntInput.vue +49 -0
- package/src/components/form/inputs/JSONInput.vue +51 -0
- package/src/components/form/inputs/LinkField.vue +293 -0
- package/src/components/form/inputs/Password.vue +89 -0
- package/src/components/form/inputs/PasswordInput.vue +89 -0
- package/src/components/form/inputs/PlainText.vue +52 -0
- package/src/components/form/inputs/ReadOnlyInput.vue +24 -0
- package/src/components/form/inputs/RichTextEditor.vue +54 -0
- package/src/components/form/inputs/SelectField.vue +253 -0
- package/src/components/form/inputs/TableField.vue +321 -0
- package/src/components/form/inputs/TextArea.vue +70 -0
- package/src/components/form/inputs/TextInput.vue +53 -0
- package/src/components/form/inputs/index.ts +17 -0
- package/src/components/formkit/AddressArray.vue +240 -0
- package/src/components/formkit/BankDetailsArray.vue +265 -0
- package/src/components/formkit/ContactArrayFormKit.vue +151 -0
- package/src/components/formkit/FileUploader.vue +391 -0
- package/src/components/formkit/MiscFields.vue +69 -0
- package/src/components/formkit/Toggle.vue +160 -0
- package/src/components/formkit/index.ts +29 -0
- package/src/components/index.ts +20 -0
- package/src/components/whatsapp/form/MsgTemplate.vue +220 -0
- package/src/components/whatsapp/form/TextVariableExamples.vue +74 -0
- package/src/components/whatsapp/interfaces.ts +58 -0
- package/src/index.ts +1 -26
- package/src/plugins/bagel.ts +26 -0
- package/src/styles/modal.css +90 -0
- package/src/types/BagelField.ts +57 -0
- package/src/types/BtnOptions.ts +14 -0
- package/src/types/Person.ts +51 -0
- package/src/types/file.ts +12 -0
- package/src/types/index.ts +4 -0
- package/src/types/materialIcons.d.ts +3005 -0
- package/src/utils/index.ts +57 -0
- package/src/utils/modal.ts +95 -0
- package/src/utils/objects.ts +81 -0
- package/src/utils/strings.ts +29 -0
- package/dist/index.cjs +0 -23
- package/dist/index.d.cts +0 -12
- package/dist/index.d.mts +0 -12
- package/dist/index.d.ts +0 -12
- package/dist/index.mjs +0 -19
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="bagel-input" :class="{ small }" :title="field.description" v-if="field.id">
|
|
3
|
+
<label :for="field.id">
|
|
4
|
+
{{ field.label }}
|
|
5
|
+
<input
|
|
6
|
+
:id="field.id" v-model="inputVal" type="text" :placeholder="field.placeholder || field.label"
|
|
7
|
+
:class="{ 'no-edit': !editMode }" :required="required" :pattern="pattern" v-bind="nativeInputAttrs"
|
|
8
|
+
>
|
|
9
|
+
</label>
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup lang="ts">
|
|
14
|
+
import { watch } from 'vue';
|
|
15
|
+
import { BagelField } from '@/types/BagelField';
|
|
16
|
+
|
|
17
|
+
const emit = defineEmits(['update:modelValue']);
|
|
18
|
+
const props = withDefaults(
|
|
19
|
+
defineProps<{
|
|
20
|
+
field: BagelField;
|
|
21
|
+
modelValue: any;
|
|
22
|
+
editMode?: boolean;
|
|
23
|
+
small?: boolean;
|
|
24
|
+
required?: boolean;
|
|
25
|
+
pattern?: string;
|
|
26
|
+
nativeInputAttrs?: Record<string, any>;
|
|
27
|
+
}>(),
|
|
28
|
+
{
|
|
29
|
+
editMode: true,
|
|
30
|
+
},
|
|
31
|
+
);
|
|
32
|
+
let inputVal = $ref<string>();
|
|
33
|
+
|
|
34
|
+
watch(
|
|
35
|
+
() => inputVal,
|
|
36
|
+
(newVal) => emit('update:modelValue', newVal),
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
watch(
|
|
40
|
+
() => props.modelValue,
|
|
41
|
+
(newVal) => {
|
|
42
|
+
if (newVal !== inputVal) inputVal = newVal;
|
|
43
|
+
},
|
|
44
|
+
{ immediate: true },
|
|
45
|
+
);
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<style scoped>
|
|
49
|
+
.no-edit {
|
|
50
|
+
cursor: not-allowed;
|
|
51
|
+
}
|
|
52
|
+
</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="bagel-input" :title="field.description" :class="{ small: small }">
|
|
3
|
+
<label v-if="field.label">
|
|
4
|
+
{{ field.label }}
|
|
5
|
+
</label>
|
|
6
|
+
{{ modelValue }}
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script setup lang="ts">
|
|
11
|
+
import { BagelField } from '@/types/BagelField';
|
|
12
|
+
|
|
13
|
+
defineProps<{
|
|
14
|
+
field: BagelField;
|
|
15
|
+
modelValue: any;
|
|
16
|
+
small?: boolean;
|
|
17
|
+
}>();
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<style scoped>
|
|
21
|
+
.no-edit {
|
|
22
|
+
margin-bottom: 2px;
|
|
23
|
+
}
|
|
24
|
+
</style>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="bagel-input" :title="description" :class="{ small: small }">
|
|
3
|
+
<label v-if="label">
|
|
4
|
+
<LangText :input="label" />
|
|
5
|
+
</label>
|
|
6
|
+
<textarea
|
|
7
|
+
:value="modelValue"
|
|
8
|
+
@input="handleInput"
|
|
9
|
+
:placeholder="bagelApp.translate(placeholder, true)"
|
|
10
|
+
:class="{ 'no-edit': !editMode }"
|
|
11
|
+
/>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
// @ts-ignore TODO: remove this
|
|
17
|
+
import { bagelApp } from '../../../index';
|
|
18
|
+
|
|
19
|
+
const emits = defineEmits(['update:modelValue']);
|
|
20
|
+
// @ts-ignore TODO: remove this
|
|
21
|
+
const props = withDefaults(
|
|
22
|
+
defineProps<{
|
|
23
|
+
description?: string;
|
|
24
|
+
label?: string;
|
|
25
|
+
modelValue: any;
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
editMode?: boolean;
|
|
28
|
+
small?: boolean;
|
|
29
|
+
}>(),
|
|
30
|
+
{
|
|
31
|
+
description: '',
|
|
32
|
+
editMode: true,
|
|
33
|
+
placeholder: '',
|
|
34
|
+
label: '',
|
|
35
|
+
},
|
|
36
|
+
);
|
|
37
|
+
const handleInput = (e: Event) => {
|
|
38
|
+
const el = e.target as HTMLInputElement;
|
|
39
|
+
emits('update:modelValue', el.value);
|
|
40
|
+
};
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<style scoped>
|
|
44
|
+
.bagel-input {
|
|
45
|
+
height: 100%;
|
|
46
|
+
margin: 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.bagel-input textarea {
|
|
50
|
+
height: 100%;
|
|
51
|
+
resize: none;
|
|
52
|
+
background: transparent;
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="bagel-input"
|
|
4
|
+
:class="{ 'no-edit': !editMode, small: small }"
|
|
5
|
+
:title="description"
|
|
6
|
+
>
|
|
7
|
+
<label v-if="label" for="label" :class="{ active: showList }">
|
|
8
|
+
<LangText :input="label" />
|
|
9
|
+
</label>
|
|
10
|
+
|
|
11
|
+
<div
|
|
12
|
+
class="custom-select"
|
|
13
|
+
ref="selectEl"
|
|
14
|
+
:class="{ 'open-select': showList && editMode }"
|
|
15
|
+
>
|
|
16
|
+
<div
|
|
17
|
+
@click.stop="toggleShowList"
|
|
18
|
+
class="input"
|
|
19
|
+
name="select-input"
|
|
20
|
+
:class="{ active: showList }"
|
|
21
|
+
>
|
|
22
|
+
<LangText :input="displayValue" />
|
|
23
|
+
</div>
|
|
24
|
+
<Teleport to="#app">
|
|
25
|
+
<div
|
|
26
|
+
ref="dropdown"
|
|
27
|
+
class="custom-select-drop"
|
|
28
|
+
:class="{ 'open-select': showList && editMode }"
|
|
29
|
+
>
|
|
30
|
+
<div
|
|
31
|
+
v-for="option in optionsRef"
|
|
32
|
+
:key="option.value"
|
|
33
|
+
@click="handleSelect(option)"
|
|
34
|
+
>
|
|
35
|
+
<LangText :input="option.label" />
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
</Teleport>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
</template>
|
|
42
|
+
|
|
43
|
+
<script lang="ts" setup>
|
|
44
|
+
import {
|
|
45
|
+
onMounted, onUnmounted, ref, computed,
|
|
46
|
+
watch,
|
|
47
|
+
} from 'vue';
|
|
48
|
+
import { type SelectBagelField } from '@/types/BagelField';
|
|
49
|
+
import LangText from '@/components/LangText.vue';
|
|
50
|
+
|
|
51
|
+
const selectEl = ref<HTMLElement>();
|
|
52
|
+
const dropdown = ref<HTMLElement>();
|
|
53
|
+
const showList = ref(false);
|
|
54
|
+
const props = withDefaults(
|
|
55
|
+
defineProps<
|
|
56
|
+
Omit<SelectBagelField, 'key'> & {
|
|
57
|
+
editMode?: boolean;
|
|
58
|
+
field: SelectBagelField;
|
|
59
|
+
modelValue: any;
|
|
60
|
+
small?: boolean;
|
|
61
|
+
}
|
|
62
|
+
>(),
|
|
63
|
+
{
|
|
64
|
+
description: '',
|
|
65
|
+
editMode: true,
|
|
66
|
+
label: '',
|
|
67
|
+
placeholder: '',
|
|
68
|
+
},
|
|
69
|
+
);
|
|
70
|
+
const left = ref('0');
|
|
71
|
+
const top = ref(0);
|
|
72
|
+
const width = ref('0');
|
|
73
|
+
const selectedValue = ref('');
|
|
74
|
+
const optionsRef = ref<{ label: string; value: string | number }[]>([]);
|
|
75
|
+
const displayValue = computed(() => {
|
|
76
|
+
const option = optionsRef.value.find((o) => o.value === selectedValue.value);
|
|
77
|
+
return option?.label || '';
|
|
78
|
+
});
|
|
79
|
+
const emits = defineEmits(['update:modelValue', 'selected']);
|
|
80
|
+
|
|
81
|
+
function handleSelect(option: any) {
|
|
82
|
+
emits('update:modelValue', option.value);
|
|
83
|
+
selectedValue.value = option.value;
|
|
84
|
+
showList.value = false;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function handleClick(e: any) {
|
|
88
|
+
const { target } = e;
|
|
89
|
+
if (target.name !== 'select-input' && showList.value === true) {
|
|
90
|
+
showList.value = false;
|
|
91
|
+
emits('update:modelValue', selectedValue);
|
|
92
|
+
}
|
|
93
|
+
// showList.value = false
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function setPosition(e?: WheelEvent) {
|
|
97
|
+
const elInfo = selectEl.value?.getBoundingClientRect() || {
|
|
98
|
+
top: 0,
|
|
99
|
+
left: 0,
|
|
100
|
+
width: 0,
|
|
101
|
+
bottom: 0,
|
|
102
|
+
};
|
|
103
|
+
if (e?.deltaY) {
|
|
104
|
+
// top.value = top.value + e.deltaY * -1
|
|
105
|
+
} else {
|
|
106
|
+
//
|
|
107
|
+
}
|
|
108
|
+
top.value = elInfo.bottom;
|
|
109
|
+
|
|
110
|
+
left.value = `${elInfo.left}px`;
|
|
111
|
+
width.value = `${elInfo.width}px`;
|
|
112
|
+
const dropRect = dropdown.value?.getBoundingClientRect?.() || {
|
|
113
|
+
height: 0,
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
if (window.innerHeight - elInfo.bottom < dropRect.height) {
|
|
117
|
+
top.value = elInfo.top - dropRect.height;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function hideDrop(e: WheelEvent) {
|
|
122
|
+
const dropRect = dropdown.value?.getBoundingClientRect() || {
|
|
123
|
+
left: 0,
|
|
124
|
+
right: 0,
|
|
125
|
+
};
|
|
126
|
+
if (e.clientX < dropRect.left || e.clientX > dropRect.right) {
|
|
127
|
+
showList.value = false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
watch(
|
|
132
|
+
() => props.modelValue,
|
|
133
|
+
() => {
|
|
134
|
+
if (selectedValue.value !== props.modelValue) selectedValue.value = props.modelValue;
|
|
135
|
+
},
|
|
136
|
+
{ immediate: true },
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
onMounted(() => {
|
|
140
|
+
// scroll event listener
|
|
141
|
+
window.addEventListener('wheel', hideDrop);
|
|
142
|
+
|
|
143
|
+
selectedValue.value = props.modelValue;
|
|
144
|
+
if (typeof props.field.options === 'string') {
|
|
145
|
+
props.field.options.split('\n').forEach((option) => {
|
|
146
|
+
optionsRef.value?.push({ label: option, value: option });
|
|
147
|
+
});
|
|
148
|
+
} else {
|
|
149
|
+
props.field.options.forEach((option) => {
|
|
150
|
+
optionsRef.value?.push(option);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
document.addEventListener('click', handleClick);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
function toggleShowList() {
|
|
157
|
+
setPosition();
|
|
158
|
+
showList.value = !showList.value;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
onUnmounted(() => {
|
|
162
|
+
document.removeEventListener('click', handleClick);
|
|
163
|
+
// window.removeEventListener('wheel', hideDrop);
|
|
164
|
+
});
|
|
165
|
+
</script>
|
|
166
|
+
|
|
167
|
+
<style scoped>
|
|
168
|
+
.custom-select {
|
|
169
|
+
position: relative;
|
|
170
|
+
font-size: var(--input-font-size);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.custom-select .input {
|
|
174
|
+
width: 100%;
|
|
175
|
+
cursor: pointer;
|
|
176
|
+
background: var(--input-bg);
|
|
177
|
+
min-height: var(--input-height);
|
|
178
|
+
border: none;
|
|
179
|
+
border-radius: var(--input-border-radius);
|
|
180
|
+
color: var(--input-color);
|
|
181
|
+
position: relative;
|
|
182
|
+
display: flex;
|
|
183
|
+
flex-direction: column;
|
|
184
|
+
text-align: start;
|
|
185
|
+
margin-inline-end: 20px;
|
|
186
|
+
justify-content: center;
|
|
187
|
+
margin-bottom: 2px;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.custom-select .input:after {
|
|
191
|
+
content: 'keyboard_arrow_down';
|
|
192
|
+
font-family: 'Material Symbols Outlined', serif;
|
|
193
|
+
position: absolute;
|
|
194
|
+
top: calc(var(--input-height) / 2 - 10px);
|
|
195
|
+
font-size: calc(var(--input-font-size) * 1.5);
|
|
196
|
+
right: calc(var(--input-height) / 4);
|
|
197
|
+
height: 100%;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
[dir='rtl'] .custom-select .input:after {
|
|
201
|
+
right: unset;
|
|
202
|
+
left: calc(var(--input-font-size) / 2);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
[dir='rtl'] .custom-select-drop {
|
|
206
|
+
inset-inline-end: v-bind(left);
|
|
207
|
+
inset-inline-start: unset;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.custom-select-drop {
|
|
211
|
+
position: fixed;
|
|
212
|
+
|
|
213
|
+
cursor: pointer;
|
|
214
|
+
font-size: 12px;
|
|
215
|
+
top: v-bind('`${top}px`');
|
|
216
|
+
inset-inline-start: v-bind(left);
|
|
217
|
+
box-sizing: border-box;
|
|
218
|
+
min-width: 220px;
|
|
219
|
+
width: v-bind(width);
|
|
220
|
+
background: var(--bgl-white);
|
|
221
|
+
box-shadow: 0 0 10px 0 var(--bgl-shadow);
|
|
222
|
+
border-radius: 10px;
|
|
223
|
+
z-index: 10000;
|
|
224
|
+
overflow-y: auto;
|
|
225
|
+
opacity: 0;
|
|
226
|
+
pointer-events: none;
|
|
227
|
+
max-height: 0;
|
|
228
|
+
/*transition: var(--bgl-transition);*/
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.open-select.custom-select-drop {
|
|
232
|
+
opacity: 1;
|
|
233
|
+
max-height: 150px;
|
|
234
|
+
pointer-events: all;
|
|
235
|
+
/*transition: var(--bgl-transition);*/
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.custom-select-drop > * {
|
|
239
|
+
/*transition: var(--bgl-transition); */
|
|
240
|
+
padding: 0.5rem 0.75rem;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.custom-select-drop > *:hover {
|
|
244
|
+
background: var(--bgl-blue-light);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.custom-select-drop > *:active {
|
|
248
|
+
filter: var(--bgl-hover-filter);
|
|
249
|
+
}
|
|
250
|
+
.bagel-input label {
|
|
251
|
+
margin-bottom: 0;
|
|
252
|
+
}
|
|
253
|
+
</style>
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="table-field-wrap"
|
|
4
|
+
:title="description"
|
|
5
|
+
>
|
|
6
|
+
<div class="bagel-input">
|
|
7
|
+
<label>
|
|
8
|
+
{{ fieldMeta?.label }}
|
|
9
|
+
</label>
|
|
10
|
+
</div>
|
|
11
|
+
<div class="table-side-scroll">
|
|
12
|
+
<div class="table-header">
|
|
13
|
+
<div
|
|
14
|
+
class="header-col"
|
|
15
|
+
:class="formatString(field.fieldtype, 'pascal')"
|
|
16
|
+
v-for="field in entityMeta?.fields"
|
|
17
|
+
:key="`${field.fieldname}header`"
|
|
18
|
+
>
|
|
19
|
+
{{ field.label }}
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
<VueDraggableNext
|
|
23
|
+
v-model="listRef"
|
|
24
|
+
animation="150"
|
|
25
|
+
handle=".table-reorder"
|
|
26
|
+
group="mainGroup"
|
|
27
|
+
easing="cubic-bezier(1, 0, 0, 1)"
|
|
28
|
+
ghost-class="ghost"
|
|
29
|
+
@end="ended"
|
|
30
|
+
>
|
|
31
|
+
<TransitionGroup>
|
|
32
|
+
<div
|
|
33
|
+
v-for="(row, index) in modelValue"
|
|
34
|
+
class="flex table-row"
|
|
35
|
+
:key="row.id"
|
|
36
|
+
>
|
|
37
|
+
<div class="table-reorder">
|
|
38
|
+
<MaterialIcon icon="more_vert" />
|
|
39
|
+
</div>
|
|
40
|
+
<div
|
|
41
|
+
class="table-cell"
|
|
42
|
+
:class="formatString(field.fieldtype, 'pascal')"
|
|
43
|
+
v-for="field in entityMeta?.fields"
|
|
44
|
+
:key="`${field.fieldname}${row.id}`"
|
|
45
|
+
>
|
|
46
|
+
<BagelInput
|
|
47
|
+
no-label
|
|
48
|
+
:field-meta="field"
|
|
49
|
+
:bagel-app="bagel"
|
|
50
|
+
@update:modelValue="(value: any) =>
|
|
51
|
+
handleUpdateModelValue(value, index, field.fieldname)
|
|
52
|
+
"
|
|
53
|
+
:model-value="row[field.fieldname]"
|
|
54
|
+
/>
|
|
55
|
+
</div>
|
|
56
|
+
|
|
57
|
+
<div class="table-action">
|
|
58
|
+
<MaterialIcon
|
|
59
|
+
icon="delete"
|
|
60
|
+
@click="removeRow(index)"
|
|
61
|
+
/>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
</TransitionGroup>
|
|
65
|
+
</VueDraggableNext>
|
|
66
|
+
</div>
|
|
67
|
+
<Btn
|
|
68
|
+
thin
|
|
69
|
+
flat
|
|
70
|
+
icon="add"
|
|
71
|
+
color="light"
|
|
72
|
+
@click="addRow"
|
|
73
|
+
>
|
|
74
|
+
New
|
|
75
|
+
</Btn>
|
|
76
|
+
</div>
|
|
77
|
+
</template>
|
|
78
|
+
|
|
79
|
+
<script setup lang="ts">
|
|
80
|
+
import { VueDraggableNext } from 'vue-draggable-next';
|
|
81
|
+
// import { EntityMeta } from 'bagel-sdk/types';
|
|
82
|
+
import { onMounted, ref } from 'vue';
|
|
83
|
+
import { Btn } from '@/components';
|
|
84
|
+
// import { bagelApp as api } from '../../../index';
|
|
85
|
+
import MaterialIcon from '../MaterialIcon.vue';
|
|
86
|
+
import { formatString } from '@/utils/strings';
|
|
87
|
+
// import TransitionGroupPop from '../../transitions/TransitionGroupPop.vue';
|
|
88
|
+
// import { formatString } from '../../../composables';
|
|
89
|
+
// import { ButtonIcon } from 'src/components/buttons'
|
|
90
|
+
let bagel: any;
|
|
91
|
+
let api: any;
|
|
92
|
+
const props = withDefaults(
|
|
93
|
+
defineProps<{
|
|
94
|
+
description?: string;
|
|
95
|
+
meta: Record<string, any> /* EntityMeta */;
|
|
96
|
+
fieldname: string;
|
|
97
|
+
bagelApp?: any;
|
|
98
|
+
modelValue: any;
|
|
99
|
+
}>(),
|
|
100
|
+
{
|
|
101
|
+
description: '',
|
|
102
|
+
bagelApp: null,
|
|
103
|
+
},
|
|
104
|
+
);
|
|
105
|
+
const listRef = ref(props.modelValue);
|
|
106
|
+
const emits = defineEmits(['update:modelValue']);
|
|
107
|
+
const fieldMeta = props.meta.doc_meta.fields.find(
|
|
108
|
+
(field: Record<string, any>) => field.fieldname === props.fieldname,
|
|
109
|
+
);
|
|
110
|
+
const entityMeta = props.meta.links.find(
|
|
111
|
+
(link: Record<string, any>) => link.id === fieldMeta?.options,
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
function handleUpdateModelValue(value: any, index: number, fieldname: string) {
|
|
115
|
+
const rows = [...props.modelValue];
|
|
116
|
+
rows[index][fieldname] = value;
|
|
117
|
+
emits('update:modelValue', rows);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function addRow() {
|
|
121
|
+
const rows = [...props.modelValue];
|
|
122
|
+
const entry = {
|
|
123
|
+
idx: rows.length,
|
|
124
|
+
} as { [key: string]: any };
|
|
125
|
+
entityMeta?.fields.forEach((field: any) => {
|
|
126
|
+
if (field.default) {
|
|
127
|
+
if (field.fieldtype === 'Check') {
|
|
128
|
+
entry[field.fieldname] = parseInt(field.default);
|
|
129
|
+
} else {
|
|
130
|
+
entry[field.fieldname] = field.default;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
rows.push(entry);
|
|
135
|
+
emits('update:modelValue', rows);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function removeRow(idx: number) {
|
|
139
|
+
const rows = [...props.modelValue];
|
|
140
|
+
rows.splice(idx, 1);
|
|
141
|
+
emits('update:modelValue', rows);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function ended() {
|
|
145
|
+
listRef.value.forEach((item: Record<string, any>, index: number) => {
|
|
146
|
+
item.idx = index + 1;
|
|
147
|
+
});
|
|
148
|
+
emits('update:modelValue', listRef.value);
|
|
149
|
+
}
|
|
150
|
+
onMounted(() => {
|
|
151
|
+
bagel = props.bagelApp || api;
|
|
152
|
+
});
|
|
153
|
+
</script>
|
|
154
|
+
|
|
155
|
+
<style scoped>
|
|
156
|
+
.table-side-scroll {
|
|
157
|
+
overflow: auto;
|
|
158
|
+
margin-inline-start: -1rem;
|
|
159
|
+
padding-inline-start: 1rem;
|
|
160
|
+
padding-bottom: 1rem;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.table-field-wrap {
|
|
164
|
+
margin-bottom: -1rem;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.table-cell {
|
|
168
|
+
border-inline-end: 1px solid var(--border-color);
|
|
169
|
+
border-bottom: 1px solid var(--border-color);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.table-row {
|
|
173
|
+
transition: var(--bgl-transition);
|
|
174
|
+
position: relative;
|
|
175
|
+
width: max-content;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.table-row:hover {
|
|
179
|
+
background: var(--bgl-gray-light);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.table-reorder {
|
|
183
|
+
opacity: 0;
|
|
184
|
+
width: 2rem;
|
|
185
|
+
text-align: center;
|
|
186
|
+
position: absolute;
|
|
187
|
+
margin-inline-start: -2rem;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.table-row:hover .table-reorder {
|
|
191
|
+
opacity: 1;
|
|
192
|
+
cursor: grab;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.table-reorder:active {
|
|
196
|
+
opacity: 1;
|
|
197
|
+
cursor: grab;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.btn.thin.btn-txt {
|
|
201
|
+
margin-inline-start: -1rem;
|
|
202
|
+
margin-top: 1rem;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.table-header {
|
|
206
|
+
display: flex;
|
|
207
|
+
width: max-content;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.header-col {
|
|
211
|
+
min-width: calc(var(--input-height) * 3);
|
|
212
|
+
font-size: 13px;
|
|
213
|
+
color: var(--input-color);
|
|
214
|
+
padding: 10px 0;
|
|
215
|
+
border-bottom: 1px solid var(--border-color);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.table-cell,
|
|
219
|
+
.header-col {
|
|
220
|
+
width: 160px;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.table-cell.check,
|
|
224
|
+
.header-col.check {
|
|
225
|
+
width: 100px;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.table-cell.date,
|
|
229
|
+
.header-col.date {
|
|
230
|
+
width: 140px;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.header-col.small-text,
|
|
234
|
+
.header-col.text,
|
|
235
|
+
.header-col.long-text,
|
|
236
|
+
.header-col.json,
|
|
237
|
+
.table-cell.small-text,
|
|
238
|
+
.table-cell.text,
|
|
239
|
+
.table-cell.long-text,
|
|
240
|
+
.table-cell.json {
|
|
241
|
+
width: 240px;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.table-cell.small-text .bagel-input,
|
|
245
|
+
.table-cell.text .bagel-input,
|
|
246
|
+
.table-cell.long-text .bagel-input,
|
|
247
|
+
.table-cell.json .bagel-input {
|
|
248
|
+
height: 40px;
|
|
249
|
+
overflow: auto;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.table-action {
|
|
253
|
+
text-align: center;
|
|
254
|
+
position: sticky;
|
|
255
|
+
opacity: 0;
|
|
256
|
+
transition: var(--bgl-transition);
|
|
257
|
+
inset-inline-end: 0;
|
|
258
|
+
height: 100%;
|
|
259
|
+
margin-top: -1px;
|
|
260
|
+
background: var(--border-color);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.table-action>.icon-font {
|
|
264
|
+
padding: 11.4px;
|
|
265
|
+
cursor: pointer;
|
|
266
|
+
transition: var(--bgl-transition);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.table-action:hover>.icon-font {
|
|
270
|
+
background: var(--bgl-red);
|
|
271
|
+
color: var(--bgl-white);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.table-action:active>.icon-font {
|
|
275
|
+
filter: brightness(90%);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.table-row:hover .table-action {
|
|
279
|
+
opacity: 1;
|
|
280
|
+
}
|
|
281
|
+
</style>
|
|
282
|
+
<style>
|
|
283
|
+
.table-row .bagel-input input,
|
|
284
|
+
.table-row .bagel-input textarea,
|
|
285
|
+
.table-row .bagel-input .input {
|
|
286
|
+
border-radius: 0;
|
|
287
|
+
background: transparent;
|
|
288
|
+
color: var(--bgl-black);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.table-row .bagel-input textarea {
|
|
292
|
+
resize: none;
|
|
293
|
+
min-height: 40px;
|
|
294
|
+
overflow: auto;
|
|
295
|
+
margin: 0px;
|
|
296
|
+
padding: 0.64rem 0.7rem 0;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.table-row .bagel-input {
|
|
300
|
+
margin: 0;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
.table-row .bagel-input input:focus-visible,
|
|
304
|
+
.table-row .bagel-input textarea:focus-visible,
|
|
305
|
+
.table-row .bagel-input .input:focus-visible {
|
|
306
|
+
background: var(--border-color);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.ghost {
|
|
310
|
+
opacity: 0;
|
|
311
|
+
background: #c8ebfb;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.sortable-chosen {
|
|
315
|
+
cursor: grabbing !important;
|
|
316
|
+
border-color: transparent;
|
|
317
|
+
background: var(--bgl-white);
|
|
318
|
+
border-radius: 10px;
|
|
319
|
+
box-shadow: 0 0 10px 0 rgb(0 0 0 /20%);
|
|
320
|
+
}
|
|
321
|
+
</style>
|