@bagelink/vue 0.0.411 → 0.0.417
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/Accordion.vue.d.ts +1 -1
- package/dist/components/AccordionItem.vue.d.ts +2 -2
- package/dist/components/Alert.vue.d.ts +2 -2
- package/dist/components/Avatar.vue.d.ts +2 -2
- package/dist/components/Avatar.vue.d.ts.map +1 -1
- package/dist/components/Badge.vue.d.ts +3 -2
- package/dist/components/BglVideo.vue.d.ts +1 -1
- package/dist/components/Btn.vue.d.ts +4 -3
- package/dist/components/Card.vue.d.ts +2 -2
- package/dist/components/Carousel.vue.d.ts +3 -3
- package/dist/components/DataPreview.vue.d.ts +10 -9
- package/dist/components/ListItem.vue.d.ts +2 -2
- package/dist/components/ListView.vue.d.ts +1 -1
- package/dist/components/MaterialIcon.vue.d.ts +4 -3
- package/dist/components/Modal.vue.d.ts +5 -5
- package/dist/components/ModalConfirm.vue.d.ts +3 -3
- package/dist/components/ModalConfirm.vue.d.ts.map +1 -1
- package/dist/components/ModalForm.vue.d.ts +27 -26
- package/dist/components/NavBar.vue.d.ts +4 -3
- package/dist/components/NavBar.vue.d.ts.map +1 -1
- package/dist/components/PageTitle.vue.d.ts +2 -2
- package/dist/components/RouterWrapper.vue.d.ts +1 -1
- package/dist/components/TableSchema.vue.d.ts +383 -6
- package/dist/components/TableSchema.vue.d.ts.map +1 -1
- package/dist/components/Title.vue.d.ts +2 -2
- package/dist/components/TopBar.vue.d.ts +1 -1
- package/dist/components/dashboard/Lineart.vue.d.ts +4 -3
- package/dist/components/form/BglField.vue.d.ts +5 -4
- package/dist/components/form/BglForm.vue.d.ts +6 -5
- package/dist/components/form/BglForm.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/CheckInput.vue.d.ts +14 -14
- package/dist/components/form/inputs/Checkbox.vue.d.ts +4 -4
- package/dist/components/form/inputs/ColorPicker.vue.d.ts +3 -3
- package/dist/components/form/inputs/DateInput.vue.d.ts +5 -5
- package/dist/components/form/inputs/DatePicker.vue.d.ts +10 -3
- package/dist/components/form/inputs/DatePicker.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/FileUpload.vue.d.ts +16 -15
- package/dist/components/form/inputs/JSONInput.vue.d.ts +3 -3
- package/dist/components/form/inputs/RadioPillsInput.vue.d.ts +3 -3
- package/dist/components/form/inputs/RichText.vue.d.ts +3 -3
- package/dist/components/form/inputs/SelectInput.vue.d.ts +4 -3
- package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/TableField.vue.d.ts +3 -3
- package/dist/components/form/inputs/TextInput.vue.d.ts +5 -4
- package/dist/components/form/inputs/ToggleInput.vue.d.ts +12 -12
- package/dist/components/layout/BottomMenu.vue.d.ts +4 -3
- package/dist/components/layout/Layout.vue.d.ts +2 -2
- package/dist/components/layout/SidebarMenu.vue.d.ts +5 -4
- package/dist/components/layout/TabbedLayout.vue.d.ts +5 -4
- package/dist/components/layout/Tabs.vue.d.ts +4 -3
- package/dist/components/layout/TabsBody.vue.d.ts +2 -2
- package/dist/components/layout/TabsNav.vue.d.ts +4 -3
- package/dist/components/layout/tabsManager.d.ts +1 -1
- package/dist/index.cjs +7041 -4955
- package/dist/index.d.ts +0 -1
- package/dist/index.mjs +7041 -4955
- package/dist/plugins/bagel.d.ts +2 -1
- package/dist/plugins/modal.d.ts +3 -3
- package/dist/style.css +242 -240
- package/dist/types/BagelForm.d.ts +1 -0
- package/dist/types/BtnOptions.d.ts +2 -1
- package/dist/types/NavLink.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/BagelFormUtils.d.ts +2 -1
- package/dist/utils/clickOutside.d.ts +2 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Avatar.vue +2 -1
- package/src/components/NavBar.vue +235 -226
- package/src/components/TableSchema.vue +34 -4
- package/src/components/form/BglForm.vue +13 -3
- package/src/components/form/inputs/CheckInput.vue +1 -0
- package/src/components/form/inputs/DatePicker.vue +13 -2
- package/src/components/form/inputs/SelectInput.vue +14 -15
|
@@ -21,13 +21,16 @@
|
|
|
21
21
|
</thead>
|
|
22
22
|
<tbody ref="infinite" class="rows infinite" :class="{ loading }">
|
|
23
23
|
<tr
|
|
24
|
-
v-for="row in
|
|
24
|
+
v-for="row in computedData"
|
|
25
25
|
:key="row.id"
|
|
26
26
|
@click="selectElement(row)"
|
|
27
27
|
class="row row-item position-relative">
|
|
28
28
|
<td
|
|
29
29
|
class="col"
|
|
30
|
-
v-for="field in computedSchema
|
|
30
|
+
v-for="field in computedSchema.map((c) => ({
|
|
31
|
+
...c,
|
|
32
|
+
transform: undefined,
|
|
33
|
+
}))"
|
|
31
34
|
:key="`${field.id}-${row.id}`">
|
|
32
35
|
<slot
|
|
33
36
|
v-if="field.id && slots[field.id]"
|
|
@@ -74,9 +77,9 @@ const computedSchema = $computed(() => {
|
|
|
74
77
|
|
|
75
78
|
const emit = defineEmits(['select', 'orderBy']);
|
|
76
79
|
|
|
77
|
-
const selectElement = (
|
|
80
|
+
const selectElement = (item: Record<string, any>) => emit('select', item);
|
|
78
81
|
|
|
79
|
-
let sortDirection = $ref('');
|
|
82
|
+
let sortDirection = $ref('ASC');
|
|
80
83
|
let sortField = $ref('');
|
|
81
84
|
|
|
82
85
|
const sort = (fieldname: string) => {
|
|
@@ -89,6 +92,33 @@ const sort = (fieldname: string) => {
|
|
|
89
92
|
}
|
|
90
93
|
emit('orderBy', `${fieldname} ${sortDirection}`.trim());
|
|
91
94
|
};
|
|
95
|
+
|
|
96
|
+
const transform = (rowData: any) => {
|
|
97
|
+
const obj: Record<string, any> = { ...rowData };
|
|
98
|
+
for (const field of computedSchema.filter((f) => f.id)) {
|
|
99
|
+
const fieldData = rowData[field.id as string];
|
|
100
|
+
obj[field.id as string] =
|
|
101
|
+
field.transform?.(fieldData, rowData) || fieldData || '';
|
|
102
|
+
}
|
|
103
|
+
return obj;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const computedData = $computed(() => {
|
|
107
|
+
const dta = [...props.data].map(transform);
|
|
108
|
+
if (sortField) {
|
|
109
|
+
return dta.sort((a, b) => {
|
|
110
|
+
const aValue = a[sortField];
|
|
111
|
+
const bValue = b[sortField];
|
|
112
|
+
if (typeof aValue === 'string') {
|
|
113
|
+
if (sortDirection === 'ASC') return aValue.localeCompare(bValue);
|
|
114
|
+
return bValue.localeCompare(aValue);
|
|
115
|
+
}
|
|
116
|
+
if (sortDirection === 'ASC') return aValue < bValue ? -1 : 1;
|
|
117
|
+
return aValue < bValue ? 1 : -1;
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return dta;
|
|
121
|
+
});
|
|
92
122
|
</script>
|
|
93
123
|
|
|
94
124
|
<style scoped>
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
</template>
|
|
24
24
|
|
|
25
25
|
<script lang="ts" setup>
|
|
26
|
-
import { useSlots } from 'vue';
|
|
26
|
+
import { useSlots, watch } from 'vue';
|
|
27
27
|
import { useModal, BglField, Title } from '@bagelink/vue';
|
|
28
28
|
|
|
29
29
|
import { type BglFormSchemaT } from '@bagelink/vue';
|
|
@@ -61,7 +61,7 @@ let data = $computed({
|
|
|
61
61
|
formData = val;
|
|
62
62
|
emit('update:modelValue', val);
|
|
63
63
|
},
|
|
64
|
-
get: () => formData,
|
|
64
|
+
get: () => props.modelValue || formData,
|
|
65
65
|
});
|
|
66
66
|
const form = $ref<HTMLFormElement>();
|
|
67
67
|
|
|
@@ -71,12 +71,22 @@ const clearForm = () => (data = {});
|
|
|
71
71
|
|
|
72
72
|
type FormStatus = 'idle' | 'loading' | 'success' | 'error';
|
|
73
73
|
|
|
74
|
+
watch(
|
|
75
|
+
() => props.status,
|
|
76
|
+
(status) => {
|
|
77
|
+
if (status === 'success') {
|
|
78
|
+
isDirty = false;
|
|
79
|
+
clearForm();
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
{ immediate: true }
|
|
83
|
+
);
|
|
84
|
+
|
|
74
85
|
const runSubmit = () => {
|
|
75
86
|
const isValid = validateForm();
|
|
76
87
|
if (!isValid) return;
|
|
77
88
|
// props.onSubmit?.(data);
|
|
78
89
|
emit('submit', data);
|
|
79
|
-
clearForm();
|
|
80
90
|
};
|
|
81
91
|
|
|
82
92
|
const i18nT = (val: string) => val;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
inline
|
|
6
6
|
week-start="0"
|
|
7
7
|
v-model="selectedDate"
|
|
8
|
+
:auto-apply="true"
|
|
8
9
|
:highlight-week-days="[6]"
|
|
9
10
|
:enable-time-picker="false"
|
|
10
11
|
:month-change-on-scroll="false"
|
|
@@ -31,13 +32,23 @@
|
|
|
31
32
|
import VDatepicker from '@vuepic/vue-datepicker';
|
|
32
33
|
import '@vuepic/vue-datepicker/dist/main.css';
|
|
33
34
|
|
|
34
|
-
defineProps<{
|
|
35
|
+
const props = defineProps<{
|
|
35
36
|
label?: string;
|
|
36
37
|
id?: string;
|
|
37
38
|
options?: Record<string, any>;
|
|
38
39
|
showTimeWrap?: boolean;
|
|
40
|
+
modelValue?: Date;
|
|
39
41
|
}>();
|
|
40
|
-
|
|
42
|
+
|
|
43
|
+
const emit = defineEmits(['update:modelValue']);
|
|
44
|
+
|
|
45
|
+
const selectedDate = $computed({
|
|
46
|
+
get: () => props.modelValue || new Date(),
|
|
47
|
+
set: (value: Date) => {
|
|
48
|
+
console.log(value);
|
|
49
|
+
emit('update:modelValue', value);
|
|
50
|
+
},
|
|
51
|
+
});
|
|
41
52
|
const selectedHour = $ref();
|
|
42
53
|
|
|
43
54
|
const hours = Array.from({ length: 18 }, (_, index) => {
|
|
@@ -82,7 +82,7 @@ const props = defineProps<{
|
|
|
82
82
|
multiselect?: boolean;
|
|
83
83
|
}>();
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
let selectedItems = $ref<Option[]>([]);
|
|
86
86
|
let search = $ref('');
|
|
87
87
|
|
|
88
88
|
const dropdown = $ref<InstanceType<typeof Dropdown> | null>(null);
|
|
@@ -156,17 +156,19 @@ const select = (option: Option) => {
|
|
|
156
156
|
);
|
|
157
157
|
if (existingIndex > -1) selectedItems.splice(existingIndex, 1);
|
|
158
158
|
else if (props.multiselect) {
|
|
159
|
-
selectedItems
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
159
|
+
const current = [...selectedItems];
|
|
160
|
+
current.push(option);
|
|
161
|
+
|
|
162
|
+
selectedItems = current;
|
|
163
|
+
} else selectedItems.splice(0, selectedItems.length, option);
|
|
164
|
+
|
|
163
165
|
if (!props.multiselect) dropdown?.hide();
|
|
164
166
|
emitUpdate();
|
|
165
167
|
};
|
|
166
168
|
|
|
167
169
|
function emitUpdate() {
|
|
168
170
|
if (props.multiselect) {
|
|
169
|
-
emit('update:modelValue', selectedItems.map(getValue));
|
|
171
|
+
emit('update:modelValue', selectedItems.map(getValue).filter(Boolean));
|
|
170
172
|
} else {
|
|
171
173
|
selectedItems.splice(1, selectedItems.length - 1);
|
|
172
174
|
const [item] = selectedItems;
|
|
@@ -175,26 +177,23 @@ function emitUpdate() {
|
|
|
175
177
|
}
|
|
176
178
|
|
|
177
179
|
function compareArrays(arr1: Option[], arr2: Option[]) {
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
);
|
|
180
|
+
const arr1Values = [...arr1].map((a) => getValue(a)).filter(Boolean);
|
|
181
|
+
const arr2Values = [...arr2].map((a) => getValue(a)).filter(Boolean);
|
|
182
|
+
const isSame = arr1Values.every((item: Option) => arr2Values.includes(item));
|
|
181
183
|
return isSame;
|
|
182
184
|
}
|
|
183
185
|
|
|
184
186
|
watch(
|
|
185
187
|
() => props.modelValue,
|
|
186
188
|
(newVal: Option | Option[]) => {
|
|
187
|
-
console.log('watch');
|
|
188
189
|
if (!props.multiselect) {
|
|
189
190
|
const newOption =
|
|
190
191
|
props.options.find((o) => getValue(o) === newVal) || newVal;
|
|
191
|
-
if (isSelected(newOption))
|
|
192
|
-
selectedItems.splice(0, selectedItems.length, newOption);
|
|
193
|
-
}
|
|
192
|
+
if (newOption && !isSelected(newOption)) selectedItems = [newOption];
|
|
194
193
|
} else {
|
|
195
194
|
const isSame = compareArrays([newVal].flat(), selectedItems);
|
|
196
195
|
if (!isSame) {
|
|
197
|
-
selectedItems.splice(0, selectedItems.length, [newVal].flat());
|
|
196
|
+
selectedItems.splice(0, selectedItems.length, ...[newVal].flat());
|
|
198
197
|
}
|
|
199
198
|
}
|
|
200
199
|
},
|
|
@@ -204,7 +203,7 @@ watch(
|
|
|
204
203
|
watch(
|
|
205
204
|
() => props.options,
|
|
206
205
|
() => {
|
|
207
|
-
|
|
206
|
+
selectedItems.forEach((option, i) => {
|
|
208
207
|
const exists = props.options.find(
|
|
209
208
|
(o) => getValue(o) === getValue(option)
|
|
210
209
|
);
|