@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,205 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
@click="onClick"
|
|
4
|
+
class="person-card"
|
|
5
|
+
v-if="person"
|
|
6
|
+
>
|
|
7
|
+
<div
|
|
8
|
+
class="person-card-edit flex gap-2"
|
|
9
|
+
v-if="!onClick"
|
|
10
|
+
>
|
|
11
|
+
<Btn
|
|
12
|
+
@click="hideModal"
|
|
13
|
+
round
|
|
14
|
+
thin
|
|
15
|
+
icon.end="arrow_outward"
|
|
16
|
+
value="Profile"
|
|
17
|
+
v-if="!$route.path.match('/search')"
|
|
18
|
+
is="router-link"
|
|
19
|
+
:to="`/search/${person.id}`"
|
|
20
|
+
/>
|
|
21
|
+
<Btn
|
|
22
|
+
thin
|
|
23
|
+
flat
|
|
24
|
+
@click="showEditForm"
|
|
25
|
+
icon="edit"
|
|
26
|
+
/>
|
|
27
|
+
</div>
|
|
28
|
+
<div class="person-card-icon-wrap">
|
|
29
|
+
<p class="person-card-icon">
|
|
30
|
+
{{ initials(person.first_name, person.last_name) }}
|
|
31
|
+
</p>
|
|
32
|
+
<p class="person-card-name txt20">
|
|
33
|
+
{{ person.first_name }} {{ person.last_name }}
|
|
34
|
+
</p>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<div class="person-card-details-wrap">
|
|
38
|
+
<div
|
|
39
|
+
class="person-card-details"
|
|
40
|
+
v-if="person.phone?.length"
|
|
41
|
+
>
|
|
42
|
+
<MaterialIcon icon="phone" />
|
|
43
|
+
<p
|
|
44
|
+
v-for="phone in person.phone"
|
|
45
|
+
:key="phone.id"
|
|
46
|
+
>
|
|
47
|
+
{{ phone.phone }}
|
|
48
|
+
</p>
|
|
49
|
+
</div>
|
|
50
|
+
<div
|
|
51
|
+
class="person-card-details"
|
|
52
|
+
v-if="person.email?.length"
|
|
53
|
+
>
|
|
54
|
+
<MaterialIcon icon="email" />
|
|
55
|
+
<p
|
|
56
|
+
v-for="email in person.email"
|
|
57
|
+
:key="email.id"
|
|
58
|
+
>
|
|
59
|
+
{{ email.email }}
|
|
60
|
+
</p>
|
|
61
|
+
</div>
|
|
62
|
+
<div
|
|
63
|
+
class="person-card-details badge"
|
|
64
|
+
v-if="person.date_of_birth || person.gender"
|
|
65
|
+
>
|
|
66
|
+
<MaterialIcon icon="badge" />
|
|
67
|
+
<p v-if="person.date_of_birth">
|
|
68
|
+
{{ person.date_of_birth }}
|
|
69
|
+
</p>
|
|
70
|
+
<p v-if="person.gender">
|
|
71
|
+
{{ person.gender }}
|
|
72
|
+
</p>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
</template>
|
|
77
|
+
|
|
78
|
+
<script lang="ts" setup>
|
|
79
|
+
|
|
80
|
+
import type { Person } from '@/types';
|
|
81
|
+
import {
|
|
82
|
+
useModal, initials,
|
|
83
|
+
} from '@/utils';
|
|
84
|
+
import { Btn, MaterialIcon } from '@/components';
|
|
85
|
+
import { useBagel } from 'src/plugins/bagel';
|
|
86
|
+
import type { FormKitSchemaDefinition } from '@formkit/core';
|
|
87
|
+
|
|
88
|
+
// const toast = useToast(); // TODO: use toast
|
|
89
|
+
const bagel = useBagel();
|
|
90
|
+
const { modalForm, hideModal } = useModal();
|
|
91
|
+
|
|
92
|
+
const props = defineProps<{
|
|
93
|
+
context: Record<string, any>;
|
|
94
|
+
onClick: ((event: MouseEvent) => void) | undefined;
|
|
95
|
+
personSchema: () => FormKitSchemaDefinition;
|
|
96
|
+
}>();
|
|
97
|
+
|
|
98
|
+
const person = $computed<Person>(() => props.context.value);
|
|
99
|
+
|
|
100
|
+
const showEditForm = async () => {
|
|
101
|
+
const { first_name, last_name } = person;
|
|
102
|
+
modalForm({
|
|
103
|
+
side: true,
|
|
104
|
+
title: `${first_name} ${last_name}`,
|
|
105
|
+
schema: props.personSchema,
|
|
106
|
+
modelValue: person,
|
|
107
|
+
onSubmit: (newPerson) => bagel.put('/person', newPerson)
|
|
108
|
+
// .then(() => toast.success($t('updatedSuccessfully'))), // TODO: use toast
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
</script>
|
|
112
|
+
<style>
|
|
113
|
+
.person-card {
|
|
114
|
+
border: 1.1px solid var(--border-color);
|
|
115
|
+
/* background: var(--input-bg); */
|
|
116
|
+
border-radius: var(--card-border-radius);
|
|
117
|
+
padding: 1rem;
|
|
118
|
+
margin-bottom: 0.5rem;
|
|
119
|
+
font-size: 1rem;
|
|
120
|
+
position: relative;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.person-card p {
|
|
124
|
+
margin: 0;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.person-card-details {
|
|
128
|
+
font-size: 14px;
|
|
129
|
+
margin-bottom: 2px;
|
|
130
|
+
line-height: 1.3;
|
|
131
|
+
display: flex;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.person-card-details p {
|
|
135
|
+
color: var(--input-color);
|
|
136
|
+
opacity: 0.6;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.person-card-details.badge p {
|
|
140
|
+
opacity: 1;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.person-card-details p:nth-child(2) {
|
|
144
|
+
opacity: 1;
|
|
145
|
+
padding-inline-end: 0.5rem;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.person-card-details .icon-font {
|
|
149
|
+
color: var(--bgl-blue);
|
|
150
|
+
padding-inline-end: 0.25rem;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.person-card-edit {
|
|
154
|
+
position: absolute;
|
|
155
|
+
inset-inline-end: 1rem;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.person-card-details-wrap {
|
|
159
|
+
display: flex;
|
|
160
|
+
gap: 0.5rem;
|
|
161
|
+
flex-wrap: wrap;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.person-card-icon {
|
|
165
|
+
background: var(--bgl-gray);
|
|
166
|
+
height: 30px;
|
|
167
|
+
width: 30px;
|
|
168
|
+
border-radius: 100%;
|
|
169
|
+
text-transform: uppercase;
|
|
170
|
+
display: flex;
|
|
171
|
+
justify-content: center;
|
|
172
|
+
align-items: center;
|
|
173
|
+
color: white;
|
|
174
|
+
font-size: 12px;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.person-card-icon-wrap {
|
|
178
|
+
display: flex;
|
|
179
|
+
gap: 0.5rem;
|
|
180
|
+
align-items: center;
|
|
181
|
+
padding-bottom: 0.75rem;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
@media screen and (max-width: 910px) {
|
|
185
|
+
.person-card-icon-wrap {
|
|
186
|
+
padding-bottom: 0.5rem;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.person-card {
|
|
190
|
+
padding: 0.75rem;
|
|
191
|
+
position: relative;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.person-card-edit {
|
|
195
|
+
/* position: relative; */
|
|
196
|
+
inset-inline-end: 0.5rem;
|
|
197
|
+
margin-bottom: 1rem;
|
|
198
|
+
justify-content: flex-end;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.person-card-name {
|
|
202
|
+
max-width: calc(100% - 170px);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
</style>
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- :class="{ editable: editable }" -->
|
|
3
|
+
<div
|
|
4
|
+
@click="focusEditor"
|
|
5
|
+
:id="`canvas-${elementId}`"
|
|
6
|
+
@keydown.meta.enter="$emit('keydown.meta.enter')"
|
|
7
|
+
/>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script setup lang="ts">
|
|
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
|
+
|
|
20
|
+
const props = withDefaults(
|
|
21
|
+
defineProps<{
|
|
22
|
+
elementId?: string;
|
|
23
|
+
modelValue: string;
|
|
24
|
+
}>(),
|
|
25
|
+
{
|
|
26
|
+
elementId: Math.random().toString(36).substr(2, 9),
|
|
27
|
+
modelValue: '',
|
|
28
|
+
},
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const emit = defineEmits(['update:modelValue', 'keydown.meta.enter']);
|
|
32
|
+
|
|
33
|
+
const html = ref<string>(props.modelValue);
|
|
34
|
+
let view: EditorView;
|
|
35
|
+
|
|
36
|
+
const createEditorStateFromHTML = (htmlContent: string) => {
|
|
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
|
+
};
|
|
59
|
+
|
|
60
|
+
function handleChange(newState: any) {
|
|
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
|
+
}
|
|
67
|
+
|
|
68
|
+
const createEditorView = (state: EditorState) => {
|
|
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
|
+
};
|
|
83
|
+
|
|
84
|
+
function loadContent() {
|
|
85
|
+
const state = createEditorStateFromHTML(props.modelValue);
|
|
86
|
+
createEditorView(state);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
watch(
|
|
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
|
+
);
|
|
98
|
+
|
|
99
|
+
onMounted(loadContent);
|
|
100
|
+
|
|
101
|
+
function focusEditor() {
|
|
102
|
+
view.focus();
|
|
103
|
+
}
|
|
104
|
+
</script>
|
|
105
|
+
|
|
106
|
+
<style>
|
|
107
|
+
.new-comment .ProseMirror {
|
|
108
|
+
width: 100%;
|
|
109
|
+
height: 100%;
|
|
110
|
+
border-radius: 3px;
|
|
111
|
+
padding: 0.55rem;
|
|
112
|
+
min-height: 40px;
|
|
113
|
+
}
|
|
114
|
+
.new-comment .ProseMirror p {
|
|
115
|
+
margin: 0;
|
|
116
|
+
}
|
|
117
|
+
.comment-input .ProseMirror {
|
|
118
|
+
background-color: var(--bgl-bg);
|
|
119
|
+
margin-inline-start: 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.new-comment .editable {
|
|
123
|
+
background-color: var(--bgl-bg);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.ProseMirror-focused {
|
|
127
|
+
outline: none;
|
|
128
|
+
border: none;
|
|
129
|
+
box-shadow: inset 0 0 10px #00000012;
|
|
130
|
+
}
|
|
131
|
+
.ProseMirror,
|
|
132
|
+
.editor-wrapper {
|
|
133
|
+
height: 100%;
|
|
134
|
+
border-radius: 3px;
|
|
135
|
+
padding: 0.55rem;
|
|
136
|
+
border-radius: var(--btn-border-radius);
|
|
137
|
+
margin-inline-start: 1rem;
|
|
138
|
+
}
|
|
139
|
+
.ProseMirror p,
|
|
140
|
+
.editor-wrapper p {
|
|
141
|
+
margin: 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.editable .ProseMirror {
|
|
145
|
+
background-color: var(--bgl-bg);
|
|
146
|
+
}
|
|
147
|
+
</style>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<router-view v-slot="{ Component, route }">
|
|
3
|
+
<transition :duration="300" name="slide-fade" mode="out-in" appear>
|
|
4
|
+
<component :is="Component" :key="route?.params.itemID" />
|
|
5
|
+
</transition>
|
|
6
|
+
</router-view>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script lang="ts" setup></script>
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="h-100 grid list-view gap-3">
|
|
3
|
+
<div class="card tabs-top">
|
|
4
|
+
<slot name="top-section" />
|
|
5
|
+
<div class="tabs grid auto-flow-columns fit-content">
|
|
6
|
+
<div
|
|
7
|
+
v-for="tab in tabs"
|
|
8
|
+
:class="{
|
|
9
|
+
active:
|
|
10
|
+
tab === activeTab ||
|
|
11
|
+
tab === router.currentRoute.value.path.split('/').slice(-1)[0],
|
|
12
|
+
}"
|
|
13
|
+
class="tab"
|
|
14
|
+
:key="tab"
|
|
15
|
+
@click="changeTab(tab)"
|
|
16
|
+
>
|
|
17
|
+
{{ tab }}
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
<!-- <TransitionRouterView v-if="baseRoute" /> -->
|
|
22
|
+
<div
|
|
23
|
+
class="list-content"
|
|
24
|
+
v-for="tab in tabs.filter((item) => item === activeTab)"
|
|
25
|
+
:key="tab"
|
|
26
|
+
>
|
|
27
|
+
<slot :name="tab" :key="tab" />
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<script setup lang="ts">
|
|
33
|
+
import { onMounted } from 'vue';
|
|
34
|
+
import type { Router } from 'vue-router';
|
|
35
|
+
|
|
36
|
+
const emit = defineEmits(['update:modelValue']);
|
|
37
|
+
|
|
38
|
+
let activeTab = $ref<string>();
|
|
39
|
+
const props = defineProps<{
|
|
40
|
+
title?: string;
|
|
41
|
+
tabs: string[];
|
|
42
|
+
modelValue?: string;
|
|
43
|
+
router: Router
|
|
44
|
+
}>();
|
|
45
|
+
|
|
46
|
+
function changeTab(tab: string) {
|
|
47
|
+
const router = props.router;
|
|
48
|
+
activeTab = tab;
|
|
49
|
+
router.push({
|
|
50
|
+
path: router.currentRoute.value.path,
|
|
51
|
+
query: { ...router.currentRoute.value.query, t: tab },
|
|
52
|
+
hash: router.currentRoute.value.hash,
|
|
53
|
+
});
|
|
54
|
+
emit('update:modelValue', activeTab);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
onMounted(() => {
|
|
58
|
+
const firstTab = props.modelValue || props.router.currentRoute.value.query.t || props.tabs[0];
|
|
59
|
+
activeTab = firstTab as string;
|
|
60
|
+
});
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<style scoped>
|
|
64
|
+
.tab {
|
|
65
|
+
text-transform: capitalize;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* .top-section {
|
|
69
|
+
grid-area: top-section;
|
|
70
|
+
font-size: 10px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.detail-section {
|
|
74
|
+
grid-area: detail-section;
|
|
75
|
+
} */
|
|
76
|
+
.card.tabs-top{
|
|
77
|
+
width: 99%;
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
</style>
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="table-list-wrap h-100">
|
|
3
|
+
<!-- <div v-for="field in schema" :key="field.id">{{ parseLocale(field.label) }}</div> -->
|
|
4
|
+
<table class="infinite-wrapper">
|
|
5
|
+
<thead class="row first-row">
|
|
6
|
+
<th class="col" v-for="field in columns" :key="field.id" @click="sort(field.id)">
|
|
7
|
+
<div class="flex">
|
|
8
|
+
{{ parseLocale(field.label || field.id) }}
|
|
9
|
+
<div class="list-arrows" :class="{ sorted: sortField === field.id }">
|
|
10
|
+
<MaterialIcon :class="{ desc: sortDirection === 'DESC' }" icon="keyboard_arrow_up" />
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
</th>
|
|
14
|
+
</thead>
|
|
15
|
+
<tbody ref="infinite" class="rows infinite" :class="{ loading }">
|
|
16
|
+
<tr @click="selectElement(row)" class="row row-item position-relative" v-for="row in data" :key="row.id">
|
|
17
|
+
<td class="col" v-for="field in columns" :key="`${field.id}-${row.id}`">
|
|
18
|
+
<slot v-if="slots[field.id]" :name="field.id" :row="row" :field="field" />
|
|
19
|
+
<div v-else>
|
|
20
|
+
<component
|
|
21
|
+
:is="field.$el || field.$cmp || 'div'"
|
|
22
|
+
v-if="field['v-if'] ? field['v-if'](row[field.id], row) : true"
|
|
23
|
+
v-bind="bindAttrs(field.attrs, row[field.id], row)"
|
|
24
|
+
:src="field.$el === 'img' ? row[field.id]?.url : ''"
|
|
25
|
+
>
|
|
26
|
+
{{ field?.transform?.(row[field.id], row) || row[field.id] || '' }}
|
|
27
|
+
</component>
|
|
28
|
+
</div>
|
|
29
|
+
</td>
|
|
30
|
+
</tr>
|
|
31
|
+
</tbody>
|
|
32
|
+
</table>
|
|
33
|
+
<!-- </Transition> -->
|
|
34
|
+
</div>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<script setup lang="ts">
|
|
38
|
+
import { useSlots } from 'vue';
|
|
39
|
+
import { MaterialIcon } from '@/components';
|
|
40
|
+
import { parseLocale } from '@/utils';
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
const slots = useSlots();
|
|
44
|
+
const loading = $ref(true);
|
|
45
|
+
|
|
46
|
+
const props = defineProps<{
|
|
47
|
+
data: any[];
|
|
48
|
+
schema?: any[];
|
|
49
|
+
}>();
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
const emit = defineEmits(['select']);
|
|
53
|
+
|
|
54
|
+
const selectElement = (data: Record<string, any>) => {
|
|
55
|
+
emit('select', data);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const bindAttrs = (attrs: Record<string, string | any>, field: any, row: any) => {
|
|
59
|
+
const arr = Object.entries(attrs || {}).map(([key, value]) => [key, typeof value === 'function' ? value(field, row) : value]);
|
|
60
|
+
const resolvedAttrs = Object.fromEntries(arr);
|
|
61
|
+
return resolvedAttrs;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// const sortList = () => {};
|
|
65
|
+
let sortDirection = $ref('');
|
|
66
|
+
let sortField = $ref('');
|
|
67
|
+
|
|
68
|
+
const sort = (fieldname: string) => {
|
|
69
|
+
if (sortField === fieldname) {
|
|
70
|
+
if (sortDirection === 'ASC') sortDirection = 'DESC';
|
|
71
|
+
else sortField = '';
|
|
72
|
+
} else {
|
|
73
|
+
sortField = fieldname;
|
|
74
|
+
sortDirection = 'ASC';
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const columns = $computed(
|
|
79
|
+
() => props.schema
|
|
80
|
+
|| Object.keys(props.data[0]).map((k: string) => ({
|
|
81
|
+
id: k,
|
|
82
|
+
inputType: 'PlainText',
|
|
83
|
+
})),
|
|
84
|
+
);
|
|
85
|
+
</script>
|
|
86
|
+
|
|
87
|
+
<style scoped>
|
|
88
|
+
.list-arrows {
|
|
89
|
+
opacity: 0;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.list-arrows .icon-font {
|
|
93
|
+
transition: all ease-in-out 0.2s;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.list-arrows.sorted {
|
|
97
|
+
opacity: 1;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.col img {
|
|
101
|
+
height: 35px;
|
|
102
|
+
margin-top: -14px;
|
|
103
|
+
margin-bottom: -14px;
|
|
104
|
+
border-radius: 5px;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.list-arrows.sorted .desc {
|
|
108
|
+
transform: rotate(180deg);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
table {
|
|
112
|
+
border-collapse: separate;
|
|
113
|
+
border-spacing: 0 15px;
|
|
114
|
+
border-collapse: collapse;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
th {
|
|
118
|
+
font-weight: 400;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.row {
|
|
122
|
+
border-bottom: 1px solid var(--border-color);
|
|
123
|
+
cursor: pointer;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.row.first-row {
|
|
127
|
+
font-size: 0.8rem;
|
|
128
|
+
color: var(--bgl-black-tint);
|
|
129
|
+
position: sticky;
|
|
130
|
+
top: 0;
|
|
131
|
+
z-index: 2;
|
|
132
|
+
background: var(--bgl-white);
|
|
133
|
+
height: 50px;
|
|
134
|
+
vertical-align: bottom;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.row.first-row::after {
|
|
138
|
+
content: '';
|
|
139
|
+
border-bottom: 1px solid var(--border-color);
|
|
140
|
+
position: absolute;
|
|
141
|
+
left: 0;
|
|
142
|
+
right: 0;
|
|
143
|
+
bottom: -1px;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.first-row .col {
|
|
147
|
+
cursor: pointer;
|
|
148
|
+
background: var(--bgl-white);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.col {
|
|
152
|
+
white-space: nowrap;
|
|
153
|
+
padding: 14px;
|
|
154
|
+
transition: var(--bgl-transition);
|
|
155
|
+
line-height: 1;
|
|
156
|
+
padding-left: 1rem;
|
|
157
|
+
padding-right: 1rem;
|
|
158
|
+
align-items: center;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.col>div {
|
|
162
|
+
display: flex;
|
|
163
|
+
gap: 0.5rem;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.max-col-width {
|
|
167
|
+
max-width: 30vw;
|
|
168
|
+
overflow: hidden;
|
|
169
|
+
text-overflow: ellipsis;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.col.check .icon-font {
|
|
173
|
+
border-radius: 100%;
|
|
174
|
+
background: var(--bgl-blue-20);
|
|
175
|
+
color: var(--bgl-blue);
|
|
176
|
+
width: 20px;
|
|
177
|
+
height: 20px;
|
|
178
|
+
display: flex;
|
|
179
|
+
align-items: center;
|
|
180
|
+
justify-content: center;
|
|
181
|
+
margin-top: -2px;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.rows {
|
|
185
|
+
font-size: 0.8125em;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.table-list {
|
|
189
|
+
height: 100%;
|
|
190
|
+
position: relative;
|
|
191
|
+
padding-left: 0 !important;
|
|
192
|
+
padding-right: 0 !important;
|
|
193
|
+
overflow: auto;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.BagelTable .table-list {
|
|
197
|
+
overflow: unset;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.row-item {
|
|
201
|
+
height: 50px;
|
|
202
|
+
transition: all 200ms ease;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.row-item:hover {
|
|
206
|
+
background: var(--bgl-gray-light);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.infinite-wrapper {
|
|
210
|
+
overflow-y: auto;
|
|
211
|
+
width: 100%;
|
|
212
|
+
}
|
|
213
|
+
</style>
|