vueless 0.0.566 → 0.0.568
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/composables/useUI.ts +1 -1
- package/package.json +1 -1
- package/types.ts +3 -0
- package/ui.button/UButton.vue +2 -14
- package/ui.button/types.ts +2 -1
- package/ui.data-list/UDataList.vue +153 -226
- package/ui.data-list/storybook/Docs.mdx +2 -2
- package/ui.data-list/storybook/{stories.js → stories.ts} +10 -3
- package/ui.data-list/types.ts +88 -0
- package/ui.data-list/useAttrs.ts +12 -0
- package/utils/ui.ts +28 -2
- package/web-types.json +25 -15
- package/ui.data-list/useAttrs.js +0 -9
- /package/ui.data-list/{config.js → config.ts} +0 -0
- /package/ui.data-list/{constants.js → constants.ts} +0 -0
package/composables/useUI.ts
CHANGED
|
@@ -34,7 +34,7 @@ import type {
|
|
|
34
34
|
*/
|
|
35
35
|
export default function useUI<T>(
|
|
36
36
|
defaultConfig: T & Component,
|
|
37
|
-
propsConfigGetter?: () =>
|
|
37
|
+
propsConfigGetter?: () => T & Component,
|
|
38
38
|
topLevelClassKey?: string,
|
|
39
39
|
mutatedProps?: ComputedRef,
|
|
40
40
|
): UseUI<T> {
|
package/package.json
CHANGED
package/types.ts
CHANGED
|
@@ -46,6 +46,7 @@ import URadioGroupConfig from "./ui.form-radio-group/config.ts";
|
|
|
46
46
|
import USwitchConfig from "./ui.form-switch/config.ts";
|
|
47
47
|
import UTextareaConfig from "./ui.form-textarea/config.ts";
|
|
48
48
|
import ULabelConfig from "./ui.form-label/config.ts";
|
|
49
|
+
import UDataListConfig from "./ui.data-list/config.ts";
|
|
49
50
|
|
|
50
51
|
import type { ComputedRef, MaybeRef, Ref, UnwrapRef } from "vue";
|
|
51
52
|
import type { Props } from "tippy.js";
|
|
@@ -134,6 +135,7 @@ export interface Config extends ThemeConfig {
|
|
|
134
135
|
|
|
135
136
|
export type UnknownObject = Record<string, unknown>;
|
|
136
137
|
export type UnknownArray = Array<unknown>;
|
|
138
|
+
export type UnknownType = string | number | boolean | UnknownObject | undefined | null;
|
|
137
139
|
export type ComponentNames = keyof Components; // keys union
|
|
138
140
|
export type Strategies = "merge" | "replace" | "override";
|
|
139
141
|
export type Gray = "gray";
|
|
@@ -207,6 +209,7 @@ export interface Components {
|
|
|
207
209
|
USwitch?: Partial<typeof USwitchConfig>;
|
|
208
210
|
UTextarea?: Partial<typeof UTextareaConfig>;
|
|
209
211
|
ULabel?: Partial<typeof ULabelConfig>;
|
|
212
|
+
UDataList?: Partial<typeof UDataListConfig>;
|
|
210
213
|
}
|
|
211
214
|
|
|
212
215
|
export interface Directives {
|
package/ui.button/UButton.vue
CHANGED
|
@@ -4,7 +4,7 @@ import { computed, ref, watchEffect, useId, watch, useSlots } from "vue";
|
|
|
4
4
|
import useUI from "../composables/useUI.ts";
|
|
5
5
|
import { useDarkMode } from "../composables/useDarkMode.ts";
|
|
6
6
|
import { hasSlotContent } from "../utils/helper.ts";
|
|
7
|
-
import {
|
|
7
|
+
import { getDefaults } from "../utils/ui.ts";
|
|
8
8
|
|
|
9
9
|
import ULoader from "../ui.loader/ULoader.vue";
|
|
10
10
|
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
@@ -17,19 +17,7 @@ import type { UButtonProps, LoaderSize, IconSize, Config } from "./types.ts";
|
|
|
17
17
|
defineOptions({ inheritAttrs: false });
|
|
18
18
|
|
|
19
19
|
const props = withDefaults(defineProps<UButtonProps>(), {
|
|
20
|
-
|
|
21
|
-
color: getDefault<UButtonProps>(defaultConfig, UButton).color,
|
|
22
|
-
size: getDefault<UButtonProps>(defaultConfig, UButton).size,
|
|
23
|
-
tag: getDefault<UButtonProps>(defaultConfig, UButton).tag,
|
|
24
|
-
tabindex: getDefault<UButtonProps>(defaultConfig, UButton).tabindex,
|
|
25
|
-
filled: getDefault<UButtonProps>(defaultConfig, UButton).filled,
|
|
26
|
-
disabled: getDefault<UButtonProps>(defaultConfig, UButton).disabled,
|
|
27
|
-
block: getDefault<UButtonProps>(defaultConfig, UButton).block,
|
|
28
|
-
round: getDefault<UButtonProps>(defaultConfig, UButton).round,
|
|
29
|
-
square: getDefault<UButtonProps>(defaultConfig, UButton).square,
|
|
30
|
-
loading: getDefault<UButtonProps>(defaultConfig, UButton).loading,
|
|
31
|
-
noRing: getDefault<UButtonProps>(defaultConfig, UButton).noRing,
|
|
32
|
-
dataTest: "",
|
|
20
|
+
...getDefaults<UButtonProps>(defaultConfig, UButton),
|
|
33
21
|
});
|
|
34
22
|
|
|
35
23
|
const slots = useSlots();
|
package/ui.button/types.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import defaultConfig from "./config.ts";
|
|
2
|
+
import type { Component } from "../types.ts";
|
|
2
3
|
|
|
3
|
-
export type Config = Partial<typeof defaultConfig
|
|
4
|
+
export type Config = Partial<typeof defaultConfig> & Component;
|
|
4
5
|
|
|
5
6
|
export type LoaderSize = "sm" | "md" | "lg";
|
|
6
7
|
export type IconSize = "2xs" | "xs" | "sm" | "md";
|
|
@@ -1,3 +1,150 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import draggable from "vuedraggable";
|
|
4
|
+
import { merge } from "lodash-es";
|
|
5
|
+
|
|
6
|
+
import { getDefault } from "../utils/ui.ts";
|
|
7
|
+
import { hasSlotContent } from "../utils/helper.ts";
|
|
8
|
+
|
|
9
|
+
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
10
|
+
import UEmpty from "../ui.text-empty/UEmpty.vue";
|
|
11
|
+
|
|
12
|
+
import { UDataList as UDataListName } from "./constants.ts";
|
|
13
|
+
import defaultConfig from "./config.ts";
|
|
14
|
+
import useAttrs from "./useAttrs.ts";
|
|
15
|
+
import { useLocale } from "../composables/useLocale.ts";
|
|
16
|
+
|
|
17
|
+
import type { UnknownObject } from "../types.ts";
|
|
18
|
+
import type { UDataListProps, IconSize, DragMoveEvent, DataListItem } from "./types.ts";
|
|
19
|
+
|
|
20
|
+
defineOptions({ inheritAttrs: false });
|
|
21
|
+
|
|
22
|
+
const props = withDefaults(defineProps<UDataListProps>(), {
|
|
23
|
+
size: getDefault<UDataListProps>(defaultConfig, UDataListName).size,
|
|
24
|
+
labelKey: getDefault<UDataListProps>(defaultConfig, UDataListName).labelKey,
|
|
25
|
+
valueKey: getDefault<UDataListProps>(defaultConfig, UDataListName).valueKey,
|
|
26
|
+
animationDuration: getDefault<UDataListProps>(defaultConfig, UDataListName).animationDuration,
|
|
27
|
+
nesting: getDefault<UDataListProps>(defaultConfig, UDataListName).nesting,
|
|
28
|
+
hideEmptyStateForNesting: false,
|
|
29
|
+
dataTest: "",
|
|
30
|
+
config: () => ({}),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const emit = defineEmits([
|
|
34
|
+
/**
|
|
35
|
+
* Triggers when item is sorted (after drag).
|
|
36
|
+
* @property {array} sortData
|
|
37
|
+
*/
|
|
38
|
+
"dragSort",
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Triggers when edit button is clicked.
|
|
42
|
+
* @property {number} value
|
|
43
|
+
* @property {string} label
|
|
44
|
+
*/
|
|
45
|
+
"clickEdit",
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Triggers when delete button is clicked.
|
|
49
|
+
* @property {number} value
|
|
50
|
+
* @property {string} label
|
|
51
|
+
*/
|
|
52
|
+
"clickDelete",
|
|
53
|
+
]);
|
|
54
|
+
|
|
55
|
+
defineSlots<{
|
|
56
|
+
edit: { element: UnknownObject };
|
|
57
|
+
delete: { element: UnknownObject };
|
|
58
|
+
drag: { element: UnknownObject };
|
|
59
|
+
empty: {
|
|
60
|
+
emptyTitle: string;
|
|
61
|
+
emptyDescription: string;
|
|
62
|
+
};
|
|
63
|
+
label: { item: DataListItem; active: boolean };
|
|
64
|
+
actions: { item: DataListItem };
|
|
65
|
+
}>();
|
|
66
|
+
|
|
67
|
+
const {
|
|
68
|
+
config,
|
|
69
|
+
wrapperAttrs,
|
|
70
|
+
emptyAttrs,
|
|
71
|
+
draggableAttrs,
|
|
72
|
+
nestedAttrs,
|
|
73
|
+
itemWrapperAttrs,
|
|
74
|
+
itemAttrs,
|
|
75
|
+
labelAttrs,
|
|
76
|
+
labelCrossedAttrs,
|
|
77
|
+
customActionsAttrs,
|
|
78
|
+
deleteIconAttrs,
|
|
79
|
+
editIconAttrs,
|
|
80
|
+
dragIconAttrs,
|
|
81
|
+
} = useAttrs(props);
|
|
82
|
+
const { tm } = useLocale();
|
|
83
|
+
|
|
84
|
+
const i18nGlobal = tm(UDataListName);
|
|
85
|
+
const currentLocale = computed(() => merge(defaultConfig.i18n, i18nGlobal, props.config.i18n));
|
|
86
|
+
|
|
87
|
+
const iconSize = computed(() => {
|
|
88
|
+
const sizes = {
|
|
89
|
+
sm: "xs",
|
|
90
|
+
md: "sm",
|
|
91
|
+
lg: "md",
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
return sizes[props.size] as IconSize;
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
function isActive(element: DataListItem) {
|
|
98
|
+
return element.isActive === undefined || element.isActive;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function onDragMove(event: DragMoveEvent): boolean | void {
|
|
102
|
+
const isDisabledNestingItem = event.draggedContext.element.isDisabledNesting;
|
|
103
|
+
const isNestingAction = !event.relatedContext?.element?.isDisabledNesting;
|
|
104
|
+
|
|
105
|
+
if (isDisabledNestingItem && isNestingAction) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function onDragEnd() {
|
|
111
|
+
const sortData = prepareSortData(props.list);
|
|
112
|
+
|
|
113
|
+
emit("dragSort", sortData);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function onClickEdit(value: number, label: string) {
|
|
117
|
+
emit("clickEdit", value, label);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function onClickDelete(value: number, label: string) {
|
|
121
|
+
emit("clickDelete", value, label);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function prepareSortData(list: DataListItem[] = [], parentValue: string | number | null = null) {
|
|
125
|
+
const sortData: DataListItem[] = [];
|
|
126
|
+
|
|
127
|
+
list.forEach((item: DataListItem) => {
|
|
128
|
+
const hasItemChildren = item?.children?.length;
|
|
129
|
+
|
|
130
|
+
if (hasItemChildren) {
|
|
131
|
+
const childrenItem = prepareSortData(
|
|
132
|
+
item.children,
|
|
133
|
+
item[props.valueKey] as string | number | null,
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
childrenItem.forEach((item) => sortData.push(item));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const parentItem = { ...item, parentValue };
|
|
140
|
+
|
|
141
|
+
sortData.push(parentItem);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
return sortData;
|
|
145
|
+
}
|
|
146
|
+
</script>
|
|
147
|
+
|
|
1
148
|
<template>
|
|
2
149
|
<div v-bind="wrapperAttrs">
|
|
3
150
|
<!--
|
|
@@ -44,7 +191,7 @@
|
|
|
44
191
|
<slot
|
|
45
192
|
name="drag"
|
|
46
193
|
:item="element"
|
|
47
|
-
:icon-name="config.defaults
|
|
194
|
+
:icon-name="config.defaults?.dragIcon"
|
|
48
195
|
:icon-size="iconSize"
|
|
49
196
|
>
|
|
50
197
|
<UIcon
|
|
@@ -52,7 +199,7 @@
|
|
|
52
199
|
color="gray"
|
|
53
200
|
variant="light"
|
|
54
201
|
:size="iconSize"
|
|
55
|
-
:name="config.defaults
|
|
202
|
+
:name="config.defaults?.dragIcon"
|
|
56
203
|
v-bind="dragIconAttrs"
|
|
57
204
|
/>
|
|
58
205
|
</slot>
|
|
@@ -89,7 +236,7 @@
|
|
|
89
236
|
<slot
|
|
90
237
|
name="delete"
|
|
91
238
|
:item="element"
|
|
92
|
-
:icon-name="config.defaults
|
|
239
|
+
:icon-name="config.defaults?.deleteIcon"
|
|
93
240
|
:icon-size="iconSize"
|
|
94
241
|
>
|
|
95
242
|
<UIcon
|
|
@@ -98,7 +245,7 @@
|
|
|
98
245
|
interactive
|
|
99
246
|
color="red"
|
|
100
247
|
:size="iconSize"
|
|
101
|
-
:name="config.defaults
|
|
248
|
+
:name="config.defaults?.deleteIcon"
|
|
102
249
|
:tooltip="currentLocale.delete"
|
|
103
250
|
v-bind="deleteIconAttrs"
|
|
104
251
|
:data-test="`${dataTest}-delete`"
|
|
@@ -115,7 +262,7 @@
|
|
|
115
262
|
<slot
|
|
116
263
|
name="edit"
|
|
117
264
|
:item="element"
|
|
118
|
-
:icon-name="config.defaults
|
|
265
|
+
:icon-name="config.defaults?.editIcon"
|
|
119
266
|
:icon-size="iconSize"
|
|
120
267
|
>
|
|
121
268
|
<UIcon
|
|
@@ -124,7 +271,7 @@
|
|
|
124
271
|
interactive
|
|
125
272
|
color="gray"
|
|
126
273
|
:size="iconSize"
|
|
127
|
-
:name="config.defaults
|
|
274
|
+
:name="config.defaults?.editIcon"
|
|
128
275
|
:tooltip="currentLocale.edit"
|
|
129
276
|
v-bind="editIconAttrs"
|
|
130
277
|
:data-test="`${dataTest}-edit`"
|
|
@@ -170,223 +317,3 @@
|
|
|
170
317
|
</draggable>
|
|
171
318
|
</div>
|
|
172
319
|
</template>
|
|
173
|
-
|
|
174
|
-
<script setup>
|
|
175
|
-
import { computed } from "vue";
|
|
176
|
-
import draggable from "vuedraggable";
|
|
177
|
-
import { merge } from "lodash-es";
|
|
178
|
-
|
|
179
|
-
import { getDefault } from "../utils/ui.ts";
|
|
180
|
-
import { hasSlotContent } from "../utils/helper.ts";
|
|
181
|
-
|
|
182
|
-
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
183
|
-
import UEmpty from "../ui.text-empty/UEmpty.vue";
|
|
184
|
-
|
|
185
|
-
import { UDataList as UDataListName } from "./constants.js";
|
|
186
|
-
import defaultConfig from "./config.js";
|
|
187
|
-
import useAttrs from "./useAttrs.js";
|
|
188
|
-
import { useLocale } from "../composables/useLocale.ts";
|
|
189
|
-
|
|
190
|
-
defineOptions({ inheritAttrs: false });
|
|
191
|
-
|
|
192
|
-
const props = defineProps({
|
|
193
|
-
/**
|
|
194
|
-
* Data item options.
|
|
195
|
-
*/
|
|
196
|
-
list: {
|
|
197
|
-
type: Array,
|
|
198
|
-
default: () => [],
|
|
199
|
-
},
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Group name.
|
|
203
|
-
*/
|
|
204
|
-
group: {
|
|
205
|
-
type: String,
|
|
206
|
-
default: "",
|
|
207
|
-
},
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Data list size.
|
|
211
|
-
* @values sm, md, lg
|
|
212
|
-
*/
|
|
213
|
-
size: {
|
|
214
|
-
type: String,
|
|
215
|
-
default: getDefault(defaultConfig, UDataListName).size,
|
|
216
|
-
},
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Label key in the item object of options.
|
|
220
|
-
*/
|
|
221
|
-
labelKey: {
|
|
222
|
-
type: String,
|
|
223
|
-
default: getDefault(defaultConfig, UDataListName).labelKey,
|
|
224
|
-
},
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Value key in the item object of options.
|
|
228
|
-
*/
|
|
229
|
-
valueKey: {
|
|
230
|
-
type: String,
|
|
231
|
-
default: getDefault(defaultConfig, UDataListName).valueKey,
|
|
232
|
-
},
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Empty state title.
|
|
236
|
-
*/
|
|
237
|
-
emptyTitle: {
|
|
238
|
-
type: String,
|
|
239
|
-
default: "",
|
|
240
|
-
},
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Empty state description.
|
|
244
|
-
*/
|
|
245
|
-
emptyDescription: {
|
|
246
|
-
type: String,
|
|
247
|
-
default: "",
|
|
248
|
-
},
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Drag animation duration.
|
|
252
|
-
*/
|
|
253
|
-
animationDuration: {
|
|
254
|
-
type: Number,
|
|
255
|
-
default: getDefault(defaultConfig, UDataListName).animationDuration,
|
|
256
|
-
},
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Enable nesting.
|
|
260
|
-
*/
|
|
261
|
-
nesting: {
|
|
262
|
-
type: Boolean,
|
|
263
|
-
default: getDefault(defaultConfig, UDataListName).nesting,
|
|
264
|
-
},
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Disable empty state for nested elements if empty (internal props).
|
|
268
|
-
* @ignore
|
|
269
|
-
*/
|
|
270
|
-
hideEmptyStateForNesting: {
|
|
271
|
-
type: Boolean,
|
|
272
|
-
default: false,
|
|
273
|
-
},
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Component config object.
|
|
277
|
-
*/
|
|
278
|
-
config: {
|
|
279
|
-
type: Object,
|
|
280
|
-
default: () => ({}),
|
|
281
|
-
},
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Data-test attribute for automated testing.
|
|
285
|
-
*/
|
|
286
|
-
dataTest: {
|
|
287
|
-
type: String,
|
|
288
|
-
default: "",
|
|
289
|
-
},
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
const emit = defineEmits([
|
|
293
|
-
/**
|
|
294
|
-
* Triggers when item is sorted (after drag).
|
|
295
|
-
* @property {array} sortData
|
|
296
|
-
*/
|
|
297
|
-
"dragSort",
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* Triggers when edit button is clicked.
|
|
301
|
-
* @property {number} value
|
|
302
|
-
* @property {string} label
|
|
303
|
-
*/
|
|
304
|
-
"clickEdit",
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* Triggers when delete button is clicked.
|
|
308
|
-
* @property {number} value
|
|
309
|
-
* @property {string} label
|
|
310
|
-
*/
|
|
311
|
-
"clickDelete",
|
|
312
|
-
]);
|
|
313
|
-
|
|
314
|
-
const {
|
|
315
|
-
config,
|
|
316
|
-
wrapperAttrs,
|
|
317
|
-
emptyAttrs,
|
|
318
|
-
draggableAttrs,
|
|
319
|
-
nestedAttrs,
|
|
320
|
-
itemWrapperAttrs,
|
|
321
|
-
itemAttrs,
|
|
322
|
-
labelAttrs,
|
|
323
|
-
labelCrossedAttrs,
|
|
324
|
-
customActionsAttrs,
|
|
325
|
-
deleteIconAttrs,
|
|
326
|
-
editIconAttrs,
|
|
327
|
-
dragIconAttrs,
|
|
328
|
-
} = useAttrs(props);
|
|
329
|
-
const { tm } = useLocale();
|
|
330
|
-
|
|
331
|
-
const i18nGlobal = tm(UDataListName);
|
|
332
|
-
const currentLocale = computed(() => merge(defaultConfig.i18n, i18nGlobal, props.config.i18n));
|
|
333
|
-
|
|
334
|
-
const iconSize = computed(() => {
|
|
335
|
-
const sizes = {
|
|
336
|
-
sm: "xs",
|
|
337
|
-
md: "sm",
|
|
338
|
-
lg: "md",
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
return sizes[props.size];
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
function isActive(element) {
|
|
345
|
-
return element.isActive === undefined || element.isActive;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
function onDragMove(event) {
|
|
349
|
-
const isDisabledNestingItem = event.draggedContext.element.isDisabledNesting;
|
|
350
|
-
const isNestingAction = !event.relatedContext.element?.isDisabledNesting;
|
|
351
|
-
|
|
352
|
-
if (isDisabledNestingItem && isNestingAction) {
|
|
353
|
-
return false;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
function onDragEnd() {
|
|
358
|
-
const sortData = prepareSortData(props.list);
|
|
359
|
-
|
|
360
|
-
emit("dragSort", sortData);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
function onClickEdit(value, label) {
|
|
364
|
-
emit("clickEdit", value, label);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
function onClickDelete(value, label) {
|
|
368
|
-
emit("clickDelete", value, label);
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
function prepareSortData(list, parentId) {
|
|
372
|
-
const sortData = [];
|
|
373
|
-
|
|
374
|
-
list.forEach((item) => {
|
|
375
|
-
const hasItemChildren = item?.children?.length;
|
|
376
|
-
|
|
377
|
-
if (hasItemChildren) {
|
|
378
|
-
const childrenItem = prepareSortData(item.children, item[props.valueKey]);
|
|
379
|
-
|
|
380
|
-
childrenItem.forEach((item) => {
|
|
381
|
-
sortData.push(item);
|
|
382
|
-
});
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
const parentItem = { ...item, parentId: 0 || parentId };
|
|
386
|
-
|
|
387
|
-
sortData.push(parentItem);
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
return sortData;
|
|
391
|
-
}
|
|
392
|
-
</script>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Meta, Title, Subtitle, Description, Primary, Controls, Stories, Source } from "@storybook/blocks";
|
|
2
2
|
import { getSource } from "../../utils/storybook.ts";
|
|
3
3
|
|
|
4
|
-
import * as stories from "./stories.
|
|
5
|
-
import defaultConfig from "../config.
|
|
4
|
+
import * as stories from "./stories.ts";
|
|
5
|
+
import defaultConfig from "../config.ts?raw"
|
|
6
6
|
|
|
7
7
|
<Meta of={stories} />
|
|
8
8
|
<Title of={stories} />
|
|
@@ -10,6 +10,13 @@ import UIcon from "../../ui.image-icon/UIcon.vue";
|
|
|
10
10
|
import UButton from "../../ui.button/UButton.vue";
|
|
11
11
|
import URow from "../../ui.container-row/URow.vue";
|
|
12
12
|
|
|
13
|
+
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
14
|
+
import type { UDataListProps } from "../types.ts";
|
|
15
|
+
|
|
16
|
+
interface UDataListArgs extends UDataListProps {
|
|
17
|
+
slotTemplate?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
13
20
|
export default {
|
|
14
21
|
id: "7020",
|
|
15
22
|
title: "Data / Data List",
|
|
@@ -45,9 +52,9 @@ export default {
|
|
|
45
52
|
parameters: {
|
|
46
53
|
...getDocsDescription(UDataList.__name),
|
|
47
54
|
},
|
|
48
|
-
};
|
|
55
|
+
} as Meta;
|
|
49
56
|
|
|
50
|
-
const DefaultTemplate = (args) => ({
|
|
57
|
+
const DefaultTemplate: StoryFn<UDataListArgs> = (args: UDataListArgs) => ({
|
|
51
58
|
components: { UDataList, UIcon, URow, UButton },
|
|
52
59
|
setup() {
|
|
53
60
|
const slots = getSlotNames(UDataList.__name);
|
|
@@ -56,7 +63,7 @@ const DefaultTemplate = (args) => ({
|
|
|
56
63
|
},
|
|
57
64
|
template: `
|
|
58
65
|
<UDataList v-bind="args">
|
|
59
|
-
${args.slotTemplate || getSlotsFragment()}
|
|
66
|
+
${args.slotTemplate || getSlotsFragment("")}
|
|
60
67
|
</UDataList>
|
|
61
68
|
`,
|
|
62
69
|
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import defaultConfig from "./config.ts";
|
|
2
|
+
|
|
3
|
+
import DraggableContext from "vuedraggable";
|
|
4
|
+
|
|
5
|
+
import type { UnknownType } from "../types.ts";
|
|
6
|
+
|
|
7
|
+
export type Config = Partial<typeof defaultConfig>;
|
|
8
|
+
|
|
9
|
+
export type IconSize = "xs" | "sm" | "md";
|
|
10
|
+
|
|
11
|
+
export interface DragMoveEvent extends DragEvent {
|
|
12
|
+
draggedContext: typeof DraggableContext;
|
|
13
|
+
relatedContext: typeof DraggableContext | null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface DataListItem {
|
|
17
|
+
isActive?: boolean;
|
|
18
|
+
isHiddenActions?: boolean;
|
|
19
|
+
isHiddenCustomActions?: boolean;
|
|
20
|
+
isHiddenDelete?: boolean;
|
|
21
|
+
isHiddenEdit?: boolean;
|
|
22
|
+
isDisabledNesting?: boolean;
|
|
23
|
+
children?: DataListItem[];
|
|
24
|
+
[key: string]: UnknownType | DataListItem[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface UDataListProps {
|
|
28
|
+
/**
|
|
29
|
+
* Data item options.
|
|
30
|
+
*/
|
|
31
|
+
list?: DataListItem[];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Group name.
|
|
35
|
+
*/
|
|
36
|
+
group?: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Data list size.
|
|
40
|
+
*/
|
|
41
|
+
size?: "sm" | "md" | "lg";
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Label key in the item object of options.
|
|
45
|
+
*/
|
|
46
|
+
labelKey?: string;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Value key in the item object of options.
|
|
50
|
+
*/
|
|
51
|
+
valueKey?: string;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Empty state title.
|
|
55
|
+
*/
|
|
56
|
+
emptyTitle?: string;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Empty state description.
|
|
60
|
+
*/
|
|
61
|
+
emptyDescription?: string;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Drag animation duration.
|
|
65
|
+
*/
|
|
66
|
+
animationDuration?: number;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Enable nesting.
|
|
70
|
+
*/
|
|
71
|
+
nesting?: boolean;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Disable empty state for nested elements if empty (internal props).
|
|
75
|
+
* @ignore
|
|
76
|
+
*/
|
|
77
|
+
hideEmptyStateForNesting?: boolean;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Component config object.
|
|
81
|
+
*/
|
|
82
|
+
config?: Config;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Data-test attribute for automated testing.
|
|
86
|
+
*/
|
|
87
|
+
dataTest?: string;
|
|
88
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import useUI from "../composables/useUI.ts";
|
|
2
|
+
|
|
3
|
+
import defaultConfig from "./config.ts";
|
|
4
|
+
|
|
5
|
+
import type { UseAttrs } from "../types.ts";
|
|
6
|
+
import type { UDataListProps, Config } from "./types.ts";
|
|
7
|
+
|
|
8
|
+
export default function useAttrs(props: UDataListProps): UseAttrs<Config> {
|
|
9
|
+
const { config, getKeysAttrs } = useUI<Config>(defaultConfig, () => props.config);
|
|
10
|
+
|
|
11
|
+
return { config, ...getKeysAttrs() };
|
|
12
|
+
}
|
package/utils/ui.ts
CHANGED
|
@@ -94,9 +94,11 @@ export const cva = ({ base = "", variants = {}, compoundVariants = [], defaultVa
|
|
|
94
94
|
});
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
|
+
* @deprecated
|
|
98
|
+
* TODO: remove if after all components migration into getDefaults()
|
|
97
99
|
* Return default values for component props, icons, etc..
|
|
98
100
|
*/
|
|
99
|
-
export function getDefault<T>(defaultConfig: Component, name: ComponentNames)
|
|
101
|
+
export function getDefault<T>(defaultConfig: Component, name: ComponentNames) {
|
|
100
102
|
const componentDefaults = cloneDeep(defaultConfig.defaults) || {};
|
|
101
103
|
const globalDefaults = cloneDeep(vuelessConfig.component?.[name]?.defaults) || {};
|
|
102
104
|
|
|
@@ -106,7 +108,31 @@ export function getDefault<T>(defaultConfig: Component, name: ComponentNames): T
|
|
|
106
108
|
defaults.color = getColor(defaults.color as BrandColors);
|
|
107
109
|
}
|
|
108
110
|
|
|
109
|
-
return
|
|
111
|
+
return {
|
|
112
|
+
...defaults,
|
|
113
|
+
dataTest: "",
|
|
114
|
+
config: () => {},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Return default values for component props, icons, etc..
|
|
120
|
+
*/
|
|
121
|
+
export function getDefaults<T>(defaultConfig: Component, name: ComponentNames) {
|
|
122
|
+
const componentDefaults = cloneDeep(defaultConfig.defaults) || {};
|
|
123
|
+
const globalDefaults = cloneDeep(vuelessConfig.component?.[name]?.defaults) || {};
|
|
124
|
+
|
|
125
|
+
const defaults = merge(componentDefaults, globalDefaults) as T & Defaults;
|
|
126
|
+
|
|
127
|
+
if (defaults.color) {
|
|
128
|
+
defaults.color = getColor(defaults.color as BrandColors);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
...defaults,
|
|
133
|
+
dataTest: "",
|
|
134
|
+
config: () => ({}),
|
|
135
|
+
};
|
|
110
136
|
}
|
|
111
137
|
|
|
112
138
|
/**
|
package/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"framework": "vue",
|
|
3
3
|
"name": "vueless",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.568",
|
|
5
5
|
"contributions": {
|
|
6
6
|
"html": {
|
|
7
7
|
"description-markup": "markdown",
|
|
@@ -1027,8 +1027,7 @@
|
|
|
1027
1027
|
"value": {
|
|
1028
1028
|
"kind": "expression",
|
|
1029
1029
|
"type": "string"
|
|
1030
|
-
}
|
|
1031
|
-
"default": "\"\""
|
|
1030
|
+
}
|
|
1032
1031
|
}
|
|
1033
1032
|
],
|
|
1034
1033
|
"slots": [
|
|
@@ -2630,24 +2629,28 @@
|
|
|
2630
2629
|
"attributes": [
|
|
2631
2630
|
{
|
|
2632
2631
|
"name": "list",
|
|
2632
|
+
"required": false,
|
|
2633
2633
|
"description": "Data item options.",
|
|
2634
|
+
"enum": [
|
|
2635
|
+
"DataListItem"
|
|
2636
|
+
],
|
|
2634
2637
|
"value": {
|
|
2635
2638
|
"kind": "expression",
|
|
2636
|
-
"type": "
|
|
2637
|
-
}
|
|
2638
|
-
"default": "[]"
|
|
2639
|
+
"type": "Array"
|
|
2640
|
+
}
|
|
2639
2641
|
},
|
|
2640
2642
|
{
|
|
2641
2643
|
"name": "group",
|
|
2644
|
+
"required": false,
|
|
2642
2645
|
"description": "Group name.",
|
|
2643
2646
|
"value": {
|
|
2644
2647
|
"kind": "expression",
|
|
2645
2648
|
"type": "string"
|
|
2646
|
-
}
|
|
2647
|
-
"default": "\"\""
|
|
2649
|
+
}
|
|
2648
2650
|
},
|
|
2649
2651
|
{
|
|
2650
2652
|
"name": "size",
|
|
2653
|
+
"required": false,
|
|
2651
2654
|
"description": "Data list size.",
|
|
2652
2655
|
"enum": [
|
|
2653
2656
|
"sm",
|
|
@@ -2656,12 +2659,13 @@
|
|
|
2656
2659
|
],
|
|
2657
2660
|
"value": {
|
|
2658
2661
|
"kind": "expression",
|
|
2659
|
-
"type": "
|
|
2662
|
+
"type": "union"
|
|
2660
2663
|
},
|
|
2661
2664
|
"default": "md"
|
|
2662
2665
|
},
|
|
2663
2666
|
{
|
|
2664
2667
|
"name": "labelKey",
|
|
2668
|
+
"required": false,
|
|
2665
2669
|
"description": "Label key in the item object of options.",
|
|
2666
2670
|
"value": {
|
|
2667
2671
|
"kind": "expression",
|
|
@@ -2671,6 +2675,7 @@
|
|
|
2671
2675
|
},
|
|
2672
2676
|
{
|
|
2673
2677
|
"name": "valueKey",
|
|
2678
|
+
"required": false,
|
|
2674
2679
|
"description": "Value key in the item object of options.",
|
|
2675
2680
|
"value": {
|
|
2676
2681
|
"kind": "expression",
|
|
@@ -2680,24 +2685,25 @@
|
|
|
2680
2685
|
},
|
|
2681
2686
|
{
|
|
2682
2687
|
"name": "emptyTitle",
|
|
2688
|
+
"required": false,
|
|
2683
2689
|
"description": "Empty state title.",
|
|
2684
2690
|
"value": {
|
|
2685
2691
|
"kind": "expression",
|
|
2686
2692
|
"type": "string"
|
|
2687
|
-
}
|
|
2688
|
-
"default": "\"\""
|
|
2693
|
+
}
|
|
2689
2694
|
},
|
|
2690
2695
|
{
|
|
2691
2696
|
"name": "emptyDescription",
|
|
2697
|
+
"required": false,
|
|
2692
2698
|
"description": "Empty state description.",
|
|
2693
2699
|
"value": {
|
|
2694
2700
|
"kind": "expression",
|
|
2695
2701
|
"type": "string"
|
|
2696
|
-
}
|
|
2697
|
-
"default": "\"\""
|
|
2702
|
+
}
|
|
2698
2703
|
},
|
|
2699
2704
|
{
|
|
2700
2705
|
"name": "animationDuration",
|
|
2706
|
+
"required": false,
|
|
2701
2707
|
"description": "Drag animation duration.",
|
|
2702
2708
|
"value": {
|
|
2703
2709
|
"kind": "expression",
|
|
@@ -2707,6 +2713,7 @@
|
|
|
2707
2713
|
},
|
|
2708
2714
|
{
|
|
2709
2715
|
"name": "nesting",
|
|
2716
|
+
"required": false,
|
|
2710
2717
|
"description": "Enable nesting.",
|
|
2711
2718
|
"value": {
|
|
2712
2719
|
"kind": "expression",
|
|
@@ -2716,6 +2723,7 @@
|
|
|
2716
2723
|
},
|
|
2717
2724
|
{
|
|
2718
2725
|
"name": "hideEmptyStateForNesting",
|
|
2726
|
+
"required": false,
|
|
2719
2727
|
"description": "@ignore: Disable empty state for nested elements if empty (internal props).",
|
|
2720
2728
|
"value": {
|
|
2721
2729
|
"kind": "expression",
|
|
@@ -2725,15 +2733,17 @@
|
|
|
2725
2733
|
},
|
|
2726
2734
|
{
|
|
2727
2735
|
"name": "config",
|
|
2736
|
+
"required": false,
|
|
2728
2737
|
"description": "Component config object.",
|
|
2729
2738
|
"value": {
|
|
2730
2739
|
"kind": "expression",
|
|
2731
|
-
"type": "
|
|
2740
|
+
"type": "Config"
|
|
2732
2741
|
},
|
|
2733
|
-
"default": "{}"
|
|
2742
|
+
"default": "() => ({})"
|
|
2734
2743
|
},
|
|
2735
2744
|
{
|
|
2736
2745
|
"name": "dataTest",
|
|
2746
|
+
"required": false,
|
|
2737
2747
|
"description": "Data-test attribute for automated testing.",
|
|
2738
2748
|
"value": {
|
|
2739
2749
|
"kind": "expression",
|
package/ui.data-list/useAttrs.js
DELETED
|
File without changes
|
|
File without changes
|