@nuxt/ui 0.4.1 → 2.8.1
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/LICENSE.md +9 -0
- package/README.md +63 -50
- package/dist/module.cjs +5 -0
- package/dist/module.d.mts +1234 -0
- package/dist/module.d.ts +1234 -0
- package/dist/module.json +8 -0
- package/dist/module.mjs +407 -0
- package/dist/runtime/app.config.d.ts +1203 -0
- package/dist/runtime/app.config.mjs +1057 -0
- package/dist/runtime/components/data/Table.vue +251 -0
- package/dist/runtime/components/data/Table.vue.d.ts +215 -0
- package/dist/runtime/components/elements/Accordion.vue +138 -0
- package/dist/runtime/components/elements/Accordion.vue.d.ts +80 -0
- package/dist/runtime/components/elements/Alert.vue +120 -0
- package/dist/runtime/components/elements/Alert.vue.d.ts +107 -0
- package/dist/runtime/components/elements/Avatar.vue +149 -0
- package/dist/runtime/components/elements/Avatar.vue.d.ts +115 -0
- package/dist/runtime/components/elements/AvatarGroup.d.ts +37 -0
- package/dist/runtime/components/elements/AvatarGroup.mjs +53 -0
- package/dist/runtime/components/elements/Badge.vue +69 -0
- package/dist/runtime/components/elements/Badge.vue.d.ts +63 -0
- package/dist/runtime/components/elements/Button.vue +182 -0
- package/dist/runtime/components/elements/Button.vue.d.ts +187 -0
- package/dist/runtime/components/elements/ButtonGroup.d.ts +39 -0
- package/dist/runtime/components/elements/ButtonGroup.mjs +70 -0
- package/dist/runtime/components/elements/Dropdown.vue +172 -0
- package/dist/runtime/components/elements/Dropdown.vue.d.ts +96 -0
- package/dist/runtime/components/elements/Icon.vue +15 -0
- package/dist/runtime/components/elements/Icon.vue.d.ts +12 -0
- package/dist/runtime/components/elements/Kbd.vue +55 -0
- package/dist/runtime/components/elements/Kbd.vue.d.ts +42 -0
- package/dist/runtime/components/elements/Link.vue +80 -0
- package/dist/runtime/components/elements/Link.vue.d.ts +9 -0
- package/dist/runtime/components/forms/Checkbox.vue +136 -0
- package/dist/runtime/components/forms/Checkbox.vue.d.ts +129 -0
- package/dist/runtime/components/forms/Form.vue +185 -0
- package/dist/runtime/components/forms/Form.vue.d.ts +50 -0
- package/dist/runtime/components/forms/FormGroup.vue +97 -0
- package/dist/runtime/components/forms/FormGroup.vue.d.ts +98 -0
- package/dist/runtime/components/forms/Input.vue +250 -0
- package/dist/runtime/components/forms/Input.vue.d.ts +214 -0
- package/dist/runtime/components/forms/Radio.vue +122 -0
- package/dist/runtime/components/forms/Radio.vue.d.ts +109 -0
- package/dist/runtime/components/forms/Range.vue +163 -0
- package/dist/runtime/components/forms/Range.vue.d.ts +119 -0
- package/dist/runtime/components/forms/Select.vue +307 -0
- package/dist/runtime/components/forms/Select.vue.d.ts +229 -0
- package/dist/runtime/components/forms/SelectMenu.vue +429 -0
- package/dist/runtime/components/forms/SelectMenu.vue.d.ts +330 -0
- package/dist/runtime/components/forms/Textarea.vue +184 -0
- package/dist/runtime/components/forms/Textarea.vue.d.ts +161 -0
- package/dist/runtime/components/forms/Toggle.vue +113 -0
- package/dist/runtime/components/forms/Toggle.vue.d.ts +83 -0
- package/dist/runtime/components/layout/Card.vue +58 -0
- package/dist/runtime/components/layout/Card.vue.d.ts +31 -0
- package/dist/runtime/components/layout/Container.vue +43 -0
- package/dist/runtime/components/layout/Container.vue.d.ts +31 -0
- package/dist/runtime/components/layout/Skeleton.vue +37 -0
- package/dist/runtime/components/layout/Skeleton.vue.d.ts +22 -0
- package/dist/runtime/components/navigation/CommandPalette.vue +304 -0
- package/dist/runtime/components/navigation/CommandPalette.vue.d.ts +224 -0
- package/dist/runtime/components/navigation/CommandPaletteGroup.vue +152 -0
- package/dist/runtime/components/navigation/CommandPaletteGroup.vue.d.ts +63 -0
- package/dist/runtime/components/navigation/Pagination.vue +197 -0
- package/dist/runtime/components/navigation/Pagination.vue.d.ts +125 -0
- package/dist/runtime/components/navigation/Tabs.vue +138 -0
- package/dist/runtime/components/navigation/Tabs.vue.d.ts +69 -0
- package/dist/runtime/components/navigation/VerticalNavigation.vue +79 -0
- package/dist/runtime/components/navigation/VerticalNavigation.vue.d.ts +37 -0
- package/dist/runtime/components/overlays/ContextMenu.vue +74 -0
- package/dist/runtime/components/overlays/ContextMenu.vue.d.ts +54 -0
- package/dist/runtime/components/overlays/Modal.vue +113 -0
- package/dist/runtime/components/overlays/Modal.vue.d.ts +82 -0
- package/dist/runtime/components/overlays/Notification.vue +197 -0
- package/dist/runtime/components/overlays/Notification.vue.d.ts +126 -0
- package/dist/runtime/components/overlays/Notifications.vue +61 -0
- package/dist/runtime/components/overlays/Notifications.vue.d.ts +41 -0
- package/dist/runtime/components/overlays/Popover.vue +139 -0
- package/dist/runtime/components/overlays/Popover.vue.d.ts +82 -0
- package/dist/runtime/components/overlays/Slideover.vue +103 -0
- package/dist/runtime/components/overlays/Slideover.vue.d.ts +84 -0
- package/dist/runtime/components/overlays/Tooltip.vue +118 -0
- package/dist/runtime/components/overlays/Tooltip.vue.d.ts +82 -0
- package/dist/runtime/composables/defineShortcuts.d.ts +13 -0
- package/dist/runtime/composables/defineShortcuts.mjs +108 -0
- package/dist/runtime/composables/useCopyToClipboard.d.ts +10 -0
- package/dist/runtime/composables/useCopyToClipboard.mjs +26 -0
- package/dist/runtime/composables/useFormGroup.d.ts +6 -0
- package/dist/runtime/composables/useFormGroup.mjs +30 -0
- package/dist/runtime/composables/usePopper.d.ts +232 -0
- package/dist/runtime/composables/usePopper.mjs +78 -0
- package/dist/runtime/composables/useShortcuts.d.ts +12 -0
- package/dist/runtime/composables/useShortcuts.mjs +24 -0
- package/dist/runtime/composables/useTimer.d.ts +8 -0
- package/dist/runtime/composables/useTimer.mjs +51 -0
- package/dist/runtime/composables/useToast.d.ts +18 -0
- package/dist/runtime/composables/useToast.mjs +22 -0
- package/dist/runtime/plugins/colors.d.ts +2 -0
- package/dist/runtime/plugins/colors.mjs +46 -0
- package/dist/runtime/types/accordion.d.ts +9 -0
- package/dist/runtime/types/avatar.d.ts +9 -0
- package/dist/runtime/types/button.d.ts +23 -0
- package/dist/runtime/types/clipboard.d.ts +3 -0
- package/dist/runtime/types/command-palette.d.ts +26 -0
- package/dist/runtime/types/dropdown.d.ts +13 -0
- package/dist/runtime/types/form.d.ts +21 -0
- package/dist/runtime/types/index.d.ts +12 -0
- package/dist/runtime/types/link.d.ts +8 -0
- package/dist/runtime/types/notification.d.ts +22 -0
- package/dist/runtime/types/popper.d.ts +14 -0
- package/dist/runtime/types/tabs.d.ts +6 -0
- package/dist/runtime/types/vertical-navigation.d.ts +11 -0
- package/dist/runtime/ui.css +13 -0
- package/dist/runtime/utils/StateEmitter.d.ts +17 -0
- package/dist/runtime/utils/StateEmitter.mjs +21 -0
- package/dist/runtime/utils/index.d.ts +11 -0
- package/dist/runtime/utils/index.mjs +33 -0
- package/dist/types.d.mts +15 -0
- package/dist/types.d.ts +15 -0
- package/package.json +56 -39
- package/LICENSE +0 -21
- package/dist/assets/styles.css +0 -14
- package/dist/components/NButton.vue +0 -22
- package/dist/components/NCard.vue +0 -5
- package/dist/components/NCheckbox.vue +0 -35
- package/dist/components/NDarkToggle.vue +0 -28
- package/dist/components/NDialog.vue +0 -59
- package/dist/components/NDropdown.vue +0 -31
- package/dist/components/NIcon.vue +0 -9
- package/dist/components/NLink.vue +0 -20
- package/dist/components/NRadio.vue +0 -40
- package/dist/components/NSwitch.vue +0 -37
- package/dist/components/NTextInput.vue +0 -34
- package/dist/components/NTip.vue +0 -16
- package/dist/components/NuxtContentLogo.vue +0 -7
- package/dist/components/NuxtExampleLayout.vue +0 -82
- package/dist/components/NuxtLogo.vue +0 -20
- package/dist/components/nuxt/NDarkToggle.vue +0 -28
- package/dist/nuxt.d.ts +0 -16
- package/dist/nuxt.mjs +0 -36
- package/dist/unocss.d.ts +0 -7
- package/dist/unocss.mjs +0 -127
- package/nuxt.cjs +0 -7
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="wrapperClass" v-bind="attrs">
|
|
3
|
+
<table :class="[ui.base, ui.divide]">
|
|
4
|
+
<thead :class="ui.thead">
|
|
5
|
+
<tr :class="ui.tr.base">
|
|
6
|
+
<th v-if="modelValue" scope="col" class="ps-4">
|
|
7
|
+
<UCheckbox :checked="indeterminate || selected.length === rows.length" :indeterminate="indeterminate" @change="onChange" />
|
|
8
|
+
</th>
|
|
9
|
+
|
|
10
|
+
<th v-for="(column, index) in columns" :key="index" scope="col" :class="[ui.th.base, ui.th.padding, ui.th.color, ui.th.font, ui.th.size, column.class]">
|
|
11
|
+
<slot :name="`${column.key}-header`" :column="column" :sort="sort" :on-sort="onSort">
|
|
12
|
+
<UButton
|
|
13
|
+
v-if="column.sortable"
|
|
14
|
+
v-bind="{ ...ui.default.sortButton, ...sortButton }"
|
|
15
|
+
:icon="(!sort.column || sort.column !== column.key) ? (sortButton.icon || ui.default.sortButton.icon) : sort.direction === 'asc' ? sortAscIcon : sortDescIcon"
|
|
16
|
+
:label="column[columnAttribute]"
|
|
17
|
+
@click="onSort(column)"
|
|
18
|
+
/>
|
|
19
|
+
<span v-else>{{ column[columnAttribute] }}</span>
|
|
20
|
+
</slot>
|
|
21
|
+
</th>
|
|
22
|
+
</tr>
|
|
23
|
+
</thead>
|
|
24
|
+
<tbody :class="ui.tbody">
|
|
25
|
+
<tr v-if="loadingState && loading">
|
|
26
|
+
<td :colspan="columns.length + (modelValue ? 1 : 0)">
|
|
27
|
+
<slot name="loading-state">
|
|
28
|
+
<div :class="ui.loadingState.wrapper">
|
|
29
|
+
<UIcon v-if="loadingState.icon" :name="loadingState.icon" :class="ui.loadingState.icon" aria-hidden="true" />
|
|
30
|
+
<p :class="ui.loadingState.label">
|
|
31
|
+
{{ loadingState.label }}
|
|
32
|
+
</p>
|
|
33
|
+
</div>
|
|
34
|
+
</slot>
|
|
35
|
+
</td>
|
|
36
|
+
</tr>
|
|
37
|
+
|
|
38
|
+
<tr v-else-if="emptyState && !rows.length">
|
|
39
|
+
<td :colspan="columns.length + (modelValue ? 1 : 0)">
|
|
40
|
+
<slot name="empty-state">
|
|
41
|
+
<div :class="ui.emptyState.wrapper">
|
|
42
|
+
<UIcon v-if="emptyState.icon" :name="emptyState.icon" :class="ui.emptyState.icon" aria-hidden="true" />
|
|
43
|
+
<p :class="ui.emptyState.label">
|
|
44
|
+
{{ emptyState.label }}
|
|
45
|
+
</p>
|
|
46
|
+
</div>
|
|
47
|
+
</slot>
|
|
48
|
+
</td>
|
|
49
|
+
</tr>
|
|
50
|
+
|
|
51
|
+
<template v-else>
|
|
52
|
+
<tr v-for="(row, index) in rows" :key="index" :class="[ui.tr.base, isSelected(row) && ui.tr.selected, $attrs.onSelect && ui.tr.active]" @click="() => onSelect(row)">
|
|
53
|
+
<td v-if="modelValue" class="ps-4">
|
|
54
|
+
<UCheckbox v-model="selected" :value="row" @click.stop />
|
|
55
|
+
</td>
|
|
56
|
+
|
|
57
|
+
<td v-for="(column, subIndex) in columns" :key="subIndex" :class="[ui.td.base, ui.td.padding, ui.td.color, ui.td.font, ui.td.size]">
|
|
58
|
+
<slot :name="`${column.key}-data`" :column="column" :row="row" :index="index" :get-row-data="(defaultValue) => getRowData(row, column.key, defaultValue)">
|
|
59
|
+
{{ getRowData(row, column.key) }}
|
|
60
|
+
</slot>
|
|
61
|
+
</td>
|
|
62
|
+
</tr>
|
|
63
|
+
</template>
|
|
64
|
+
</tbody>
|
|
65
|
+
</table>
|
|
66
|
+
</div>
|
|
67
|
+
</template>
|
|
68
|
+
|
|
69
|
+
<script>
|
|
70
|
+
import { ref, computed, defineComponent, toRaw } from "vue";
|
|
71
|
+
import { omit, capitalize, orderBy, get } from "lodash-es";
|
|
72
|
+
import { defu } from "defu";
|
|
73
|
+
import { twMerge } from "tailwind-merge";
|
|
74
|
+
import { defuTwMerge } from "../../utils";
|
|
75
|
+
import UButton from "../elements/Button.vue";
|
|
76
|
+
import UIcon from "../elements/Icon.vue";
|
|
77
|
+
import UCheckbox from "../forms/Checkbox.vue";
|
|
78
|
+
import { useAppConfig } from "#imports";
|
|
79
|
+
import appConfig from "#build/app.config";
|
|
80
|
+
function defaultComparator(a, z) {
|
|
81
|
+
return a === z;
|
|
82
|
+
}
|
|
83
|
+
export default defineComponent({
|
|
84
|
+
components: {
|
|
85
|
+
UButton,
|
|
86
|
+
UIcon,
|
|
87
|
+
UCheckbox
|
|
88
|
+
},
|
|
89
|
+
inheritAttrs: false,
|
|
90
|
+
props: {
|
|
91
|
+
modelValue: {
|
|
92
|
+
type: Array,
|
|
93
|
+
default: null
|
|
94
|
+
},
|
|
95
|
+
by: {
|
|
96
|
+
type: [String, Function],
|
|
97
|
+
default: () => defaultComparator
|
|
98
|
+
},
|
|
99
|
+
rows: {
|
|
100
|
+
type: Array,
|
|
101
|
+
default: () => []
|
|
102
|
+
},
|
|
103
|
+
columns: {
|
|
104
|
+
type: Array,
|
|
105
|
+
default: null
|
|
106
|
+
},
|
|
107
|
+
columnAttribute: {
|
|
108
|
+
type: String,
|
|
109
|
+
default: "label"
|
|
110
|
+
},
|
|
111
|
+
sort: {
|
|
112
|
+
type: Object,
|
|
113
|
+
default: () => ({})
|
|
114
|
+
},
|
|
115
|
+
sortButton: {
|
|
116
|
+
type: Object,
|
|
117
|
+
default: () => appConfig.ui.table.default.sortButton
|
|
118
|
+
},
|
|
119
|
+
sortAscIcon: {
|
|
120
|
+
type: String,
|
|
121
|
+
default: () => appConfig.ui.table.default.sortAscIcon
|
|
122
|
+
},
|
|
123
|
+
sortDescIcon: {
|
|
124
|
+
type: String,
|
|
125
|
+
default: () => appConfig.ui.table.default.sortDescIcon
|
|
126
|
+
},
|
|
127
|
+
loading: {
|
|
128
|
+
type: Boolean,
|
|
129
|
+
default: false
|
|
130
|
+
},
|
|
131
|
+
loadingState: {
|
|
132
|
+
type: Object,
|
|
133
|
+
default: () => appConfig.ui.table.default.loadingState
|
|
134
|
+
},
|
|
135
|
+
emptyState: {
|
|
136
|
+
type: Object,
|
|
137
|
+
default: () => appConfig.ui.table.default.emptyState
|
|
138
|
+
},
|
|
139
|
+
ui: {
|
|
140
|
+
type: Object,
|
|
141
|
+
default: () => ({})
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
emits: ["update:modelValue"],
|
|
145
|
+
setup(props, { emit, attrs }) {
|
|
146
|
+
const appConfig2 = useAppConfig();
|
|
147
|
+
const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.table));
|
|
148
|
+
const wrapperClass = computed(() => twMerge(ui.value.wrapper, attrs.class));
|
|
149
|
+
const columns = computed(() => props.columns ?? Object.keys(omit(props.rows[0] ?? {}, ["click"])).map((key) => ({ key, label: capitalize(key), sortable: false })));
|
|
150
|
+
const sort = ref(defu({}, props.sort, { column: null, direction: "asc" }));
|
|
151
|
+
const rows = computed(() => {
|
|
152
|
+
if (!sort.value?.column) {
|
|
153
|
+
return props.rows;
|
|
154
|
+
}
|
|
155
|
+
const { column, direction } = sort.value;
|
|
156
|
+
return orderBy(props.rows, column, direction);
|
|
157
|
+
});
|
|
158
|
+
const selected = computed({
|
|
159
|
+
get() {
|
|
160
|
+
return props.modelValue;
|
|
161
|
+
},
|
|
162
|
+
set(value) {
|
|
163
|
+
emit("update:modelValue", value);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
const indeterminate = computed(() => selected.value && selected.value.length > 0 && selected.value.length < props.rows.length);
|
|
167
|
+
const emptyState = computed(() => {
|
|
168
|
+
if (props.emptyState === null)
|
|
169
|
+
return null;
|
|
170
|
+
return { ...ui.value.default.emptyState, ...props.emptyState };
|
|
171
|
+
});
|
|
172
|
+
const loadingState = computed(() => {
|
|
173
|
+
if (props.loadingState === null)
|
|
174
|
+
return null;
|
|
175
|
+
return { ...ui.value.default.loadingState, ...props.loadingState };
|
|
176
|
+
});
|
|
177
|
+
function compare(a, z) {
|
|
178
|
+
if (typeof props.by === "string") {
|
|
179
|
+
const property = props.by;
|
|
180
|
+
return a?.[property] === z?.[property];
|
|
181
|
+
}
|
|
182
|
+
return props.by(a, z);
|
|
183
|
+
}
|
|
184
|
+
function isSelected(row) {
|
|
185
|
+
if (!props.modelValue) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
return selected.value.some((item) => compare(toRaw(item), toRaw(row)));
|
|
189
|
+
}
|
|
190
|
+
function onSort(column) {
|
|
191
|
+
if (sort.value.column === column.key) {
|
|
192
|
+
const direction = !column.direction || column.direction === "asc" ? "desc" : "asc";
|
|
193
|
+
if (sort.value.direction === direction) {
|
|
194
|
+
sort.value = defu({}, props.sort, { column: null, direction: "asc" });
|
|
195
|
+
} else {
|
|
196
|
+
sort.value.direction = sort.value.direction === "asc" ? "desc" : "asc";
|
|
197
|
+
}
|
|
198
|
+
} else {
|
|
199
|
+
sort.value = { column: column.key, direction: column.direction || "asc" };
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function onSelect(row) {
|
|
203
|
+
if (!attrs.onSelect) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
attrs.onSelect(row);
|
|
207
|
+
}
|
|
208
|
+
function selectAllRows() {
|
|
209
|
+
props.rows.forEach((row) => {
|
|
210
|
+
if (selected.value.some((item) => compare(toRaw(item), toRaw(row)))) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
onSelect(row);
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
function onChange(event) {
|
|
217
|
+
if (event.target.checked) {
|
|
218
|
+
selectAllRows();
|
|
219
|
+
} else {
|
|
220
|
+
selected.value = [];
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
function getRowData(row, rowKey, defaultValue = "Failed to get cell value") {
|
|
224
|
+
return get(row, rowKey, defaultValue);
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
attrs: omit(attrs, ["class"]),
|
|
228
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
229
|
+
ui,
|
|
230
|
+
wrapperClass,
|
|
231
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
232
|
+
sort,
|
|
233
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
234
|
+
columns,
|
|
235
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
236
|
+
rows,
|
|
237
|
+
selected,
|
|
238
|
+
indeterminate,
|
|
239
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
240
|
+
emptyState,
|
|
241
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
242
|
+
loadingState,
|
|
243
|
+
isSelected,
|
|
244
|
+
onSort,
|
|
245
|
+
onSelect,
|
|
246
|
+
onChange,
|
|
247
|
+
getRowData
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
</script>
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
|
+
import type { PropType } from 'vue';
|
|
3
|
+
import type { Button } from '../../types/button';
|
|
4
|
+
declare function defaultComparator<T>(a: T, z: T): boolean;
|
|
5
|
+
declare const _default: import("vue").DefineComponent<{
|
|
6
|
+
modelValue: {
|
|
7
|
+
type: ArrayConstructor;
|
|
8
|
+
default: null;
|
|
9
|
+
};
|
|
10
|
+
by: {
|
|
11
|
+
type: (StringConstructor | FunctionConstructor)[];
|
|
12
|
+
default: () => typeof defaultComparator;
|
|
13
|
+
};
|
|
14
|
+
rows: {
|
|
15
|
+
type: PropType<{
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
click?: Function | undefined;
|
|
18
|
+
}[]>;
|
|
19
|
+
default: () => never[];
|
|
20
|
+
};
|
|
21
|
+
columns: {
|
|
22
|
+
type: PropType<{
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
key: string;
|
|
25
|
+
sortable?: boolean | undefined;
|
|
26
|
+
direction?: "asc" | "desc" | undefined;
|
|
27
|
+
class?: string | undefined;
|
|
28
|
+
}[]>;
|
|
29
|
+
default: null;
|
|
30
|
+
};
|
|
31
|
+
columnAttribute: {
|
|
32
|
+
type: StringConstructor;
|
|
33
|
+
default: string;
|
|
34
|
+
};
|
|
35
|
+
sort: {
|
|
36
|
+
type: PropType<{
|
|
37
|
+
column: string;
|
|
38
|
+
direction: 'asc' | 'desc';
|
|
39
|
+
}>;
|
|
40
|
+
default: () => {};
|
|
41
|
+
};
|
|
42
|
+
sortButton: {
|
|
43
|
+
type: PropType<Button>;
|
|
44
|
+
default: () => any;
|
|
45
|
+
};
|
|
46
|
+
sortAscIcon: {
|
|
47
|
+
type: StringConstructor;
|
|
48
|
+
default: () => any;
|
|
49
|
+
};
|
|
50
|
+
sortDescIcon: {
|
|
51
|
+
type: StringConstructor;
|
|
52
|
+
default: () => any;
|
|
53
|
+
};
|
|
54
|
+
loading: {
|
|
55
|
+
type: BooleanConstructor;
|
|
56
|
+
default: boolean;
|
|
57
|
+
};
|
|
58
|
+
loadingState: {
|
|
59
|
+
type: PropType<{
|
|
60
|
+
icon: string;
|
|
61
|
+
label: string;
|
|
62
|
+
}>;
|
|
63
|
+
default: () => any;
|
|
64
|
+
};
|
|
65
|
+
emptyState: {
|
|
66
|
+
type: PropType<{
|
|
67
|
+
icon: string;
|
|
68
|
+
label: string;
|
|
69
|
+
}>;
|
|
70
|
+
default: () => any;
|
|
71
|
+
};
|
|
72
|
+
ui: {
|
|
73
|
+
type: PropType<any>;
|
|
74
|
+
default: () => {};
|
|
75
|
+
};
|
|
76
|
+
}, {
|
|
77
|
+
attrs: import("lodash").Omit<{
|
|
78
|
+
[x: string]: unknown;
|
|
79
|
+
}, "class">;
|
|
80
|
+
ui: import("vue").ComputedRef<any>;
|
|
81
|
+
wrapperClass: import("vue").ComputedRef<string>;
|
|
82
|
+
sort: import("vue").Ref<{
|
|
83
|
+
direction: string;
|
|
84
|
+
column: string;
|
|
85
|
+
}>;
|
|
86
|
+
columns: import("vue").ComputedRef<{
|
|
87
|
+
[key: string]: any;
|
|
88
|
+
key: string;
|
|
89
|
+
sortable?: boolean | undefined;
|
|
90
|
+
direction?: "asc" | "desc" | undefined;
|
|
91
|
+
class?: string | undefined;
|
|
92
|
+
}[]>;
|
|
93
|
+
rows: import("vue").ComputedRef<{
|
|
94
|
+
[key: string]: any;
|
|
95
|
+
click?: Function | undefined;
|
|
96
|
+
}[]>;
|
|
97
|
+
selected: import("vue").WritableComputedRef<unknown[]>;
|
|
98
|
+
indeterminate: import("vue").ComputedRef<boolean>;
|
|
99
|
+
emptyState: import("vue").ComputedRef<any>;
|
|
100
|
+
loadingState: import("vue").ComputedRef<any>;
|
|
101
|
+
isSelected: (row: any) => boolean;
|
|
102
|
+
onSort: (column: {
|
|
103
|
+
key: string;
|
|
104
|
+
direction?: 'asc' | 'desc';
|
|
105
|
+
}) => void;
|
|
106
|
+
onSelect: (row: any) => void;
|
|
107
|
+
onChange: (event: any) => void;
|
|
108
|
+
getRowData: (row: Object, rowKey: string | string[], defaultValue?: any) => any;
|
|
109
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
110
|
+
modelValue: {
|
|
111
|
+
type: ArrayConstructor;
|
|
112
|
+
default: null;
|
|
113
|
+
};
|
|
114
|
+
by: {
|
|
115
|
+
type: (StringConstructor | FunctionConstructor)[];
|
|
116
|
+
default: () => typeof defaultComparator;
|
|
117
|
+
};
|
|
118
|
+
rows: {
|
|
119
|
+
type: PropType<{
|
|
120
|
+
[key: string]: any;
|
|
121
|
+
click?: Function | undefined;
|
|
122
|
+
}[]>;
|
|
123
|
+
default: () => never[];
|
|
124
|
+
};
|
|
125
|
+
columns: {
|
|
126
|
+
type: PropType<{
|
|
127
|
+
[key: string]: any;
|
|
128
|
+
key: string;
|
|
129
|
+
sortable?: boolean | undefined;
|
|
130
|
+
direction?: "asc" | "desc" | undefined;
|
|
131
|
+
class?: string | undefined;
|
|
132
|
+
}[]>;
|
|
133
|
+
default: null;
|
|
134
|
+
};
|
|
135
|
+
columnAttribute: {
|
|
136
|
+
type: StringConstructor;
|
|
137
|
+
default: string;
|
|
138
|
+
};
|
|
139
|
+
sort: {
|
|
140
|
+
type: PropType<{
|
|
141
|
+
column: string;
|
|
142
|
+
direction: 'asc' | 'desc';
|
|
143
|
+
}>;
|
|
144
|
+
default: () => {};
|
|
145
|
+
};
|
|
146
|
+
sortButton: {
|
|
147
|
+
type: PropType<Button>;
|
|
148
|
+
default: () => any;
|
|
149
|
+
};
|
|
150
|
+
sortAscIcon: {
|
|
151
|
+
type: StringConstructor;
|
|
152
|
+
default: () => any;
|
|
153
|
+
};
|
|
154
|
+
sortDescIcon: {
|
|
155
|
+
type: StringConstructor;
|
|
156
|
+
default: () => any;
|
|
157
|
+
};
|
|
158
|
+
loading: {
|
|
159
|
+
type: BooleanConstructor;
|
|
160
|
+
default: boolean;
|
|
161
|
+
};
|
|
162
|
+
loadingState: {
|
|
163
|
+
type: PropType<{
|
|
164
|
+
icon: string;
|
|
165
|
+
label: string;
|
|
166
|
+
}>;
|
|
167
|
+
default: () => any;
|
|
168
|
+
};
|
|
169
|
+
emptyState: {
|
|
170
|
+
type: PropType<{
|
|
171
|
+
icon: string;
|
|
172
|
+
label: string;
|
|
173
|
+
}>;
|
|
174
|
+
default: () => any;
|
|
175
|
+
};
|
|
176
|
+
ui: {
|
|
177
|
+
type: PropType<any>;
|
|
178
|
+
default: () => {};
|
|
179
|
+
};
|
|
180
|
+
}>> & {
|
|
181
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
182
|
+
}, {
|
|
183
|
+
sort: {
|
|
184
|
+
column: string;
|
|
185
|
+
direction: 'asc' | 'desc';
|
|
186
|
+
};
|
|
187
|
+
ui: any;
|
|
188
|
+
modelValue: unknown[];
|
|
189
|
+
by: string | Function;
|
|
190
|
+
rows: {
|
|
191
|
+
[key: string]: any;
|
|
192
|
+
click?: Function | undefined;
|
|
193
|
+
}[];
|
|
194
|
+
columns: {
|
|
195
|
+
[key: string]: any;
|
|
196
|
+
key: string;
|
|
197
|
+
sortable?: boolean | undefined;
|
|
198
|
+
direction?: "asc" | "desc" | undefined;
|
|
199
|
+
class?: string | undefined;
|
|
200
|
+
}[];
|
|
201
|
+
columnAttribute: string;
|
|
202
|
+
sortButton: Button;
|
|
203
|
+
sortAscIcon: string;
|
|
204
|
+
sortDescIcon: string;
|
|
205
|
+
loading: boolean;
|
|
206
|
+
loadingState: {
|
|
207
|
+
icon: string;
|
|
208
|
+
label: string;
|
|
209
|
+
};
|
|
210
|
+
emptyState: {
|
|
211
|
+
icon: string;
|
|
212
|
+
label: string;
|
|
213
|
+
};
|
|
214
|
+
}, {}>;
|
|
215
|
+
export default _default;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="wrapperClass">
|
|
3
|
+
<HDisclosure v-for="(item, index) in items" v-slot="{ open, close }" :key="index" :default-open="defaultOpen || item.defaultOpen">
|
|
4
|
+
<HDisclosureButton :ref="() => buttonRefs[index] = close" as="template" :disabled="item.disabled">
|
|
5
|
+
<slot :item="item" :index="index" :open="open" :close="close">
|
|
6
|
+
<UButton v-bind="{ ...omit(ui.default, ['openIcon', 'closeIcon']), ...attrs, ...omit(item, ['slot', 'disabled', 'content', 'defaultOpen']) }">
|
|
7
|
+
<template #trailing>
|
|
8
|
+
<UIcon
|
|
9
|
+
:name="!open ? openIcon : closeIcon ? closeIcon : openIcon"
|
|
10
|
+
:class="[
|
|
11
|
+
open && !closeIcon ? '-rotate-180' : '',
|
|
12
|
+
uiButton.icon.size[item.size || uiButton.default.size],
|
|
13
|
+
ui.item.icon
|
|
14
|
+
]"
|
|
15
|
+
/>
|
|
16
|
+
</template>
|
|
17
|
+
</UButton>
|
|
18
|
+
</slot>
|
|
19
|
+
</HDisclosureButton>
|
|
20
|
+
|
|
21
|
+
<StateEmitter :open="open" @open="closeOthers(index)" />
|
|
22
|
+
|
|
23
|
+
<Transition
|
|
24
|
+
v-bind="ui.transition"
|
|
25
|
+
@enter="onEnter"
|
|
26
|
+
@after-enter="onAfterEnter"
|
|
27
|
+
@before-leave="onBeforeLeave"
|
|
28
|
+
@leave="onLeave"
|
|
29
|
+
>
|
|
30
|
+
<div v-show="open">
|
|
31
|
+
<HDisclosurePanel :class="[ui.item.base, ui.item.size, ui.item.color, ui.item.padding]" static>
|
|
32
|
+
<slot :name="item.slot || 'item'" :item="item" :index="index" :open="open" :close="close">
|
|
33
|
+
{{ item.content }}
|
|
34
|
+
</slot>
|
|
35
|
+
</HDisclosurePanel>
|
|
36
|
+
</div>
|
|
37
|
+
</Transition>
|
|
38
|
+
</HDisclosure>
|
|
39
|
+
</div>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<script>
|
|
43
|
+
import { ref, computed, defineComponent } from "vue";
|
|
44
|
+
import { Disclosure as HDisclosure, DisclosureButton as HDisclosureButton, DisclosurePanel as HDisclosurePanel } from "@headlessui/vue";
|
|
45
|
+
import { omit } from "lodash-es";
|
|
46
|
+
import { twMerge } from "tailwind-merge";
|
|
47
|
+
import UIcon from "../elements/Icon.vue";
|
|
48
|
+
import UButton from "../elements/Button.vue";
|
|
49
|
+
import { defuTwMerge } from "../../utils";
|
|
50
|
+
import StateEmitter from "../../utils/StateEmitter";
|
|
51
|
+
import { useAppConfig } from "#imports";
|
|
52
|
+
import appConfig from "#build/app.config";
|
|
53
|
+
export default defineComponent({
|
|
54
|
+
components: {
|
|
55
|
+
HDisclosure,
|
|
56
|
+
HDisclosureButton,
|
|
57
|
+
HDisclosurePanel,
|
|
58
|
+
UIcon,
|
|
59
|
+
UButton,
|
|
60
|
+
StateEmitter
|
|
61
|
+
},
|
|
62
|
+
inheritAttrs: false,
|
|
63
|
+
props: {
|
|
64
|
+
items: {
|
|
65
|
+
type: Array,
|
|
66
|
+
default: () => []
|
|
67
|
+
},
|
|
68
|
+
defaultOpen: {
|
|
69
|
+
type: Boolean,
|
|
70
|
+
default: false
|
|
71
|
+
},
|
|
72
|
+
openIcon: {
|
|
73
|
+
type: String,
|
|
74
|
+
default: () => appConfig.ui.accordion.default.openIcon
|
|
75
|
+
},
|
|
76
|
+
closeIcon: {
|
|
77
|
+
type: String,
|
|
78
|
+
default: () => appConfig.ui.accordion.default.closeIcon
|
|
79
|
+
},
|
|
80
|
+
multiple: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: false
|
|
83
|
+
},
|
|
84
|
+
ui: {
|
|
85
|
+
type: Object,
|
|
86
|
+
default: () => ({})
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
setup(props, { attrs }) {
|
|
90
|
+
const appConfig2 = useAppConfig();
|
|
91
|
+
const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.accordion));
|
|
92
|
+
const uiButton = computed(() => appConfig2.ui.button);
|
|
93
|
+
const wrapperClass = computed(() => twMerge(ui.value.wrapper, attrs.class));
|
|
94
|
+
const buttonRefs = ref([]);
|
|
95
|
+
function closeOthers(itemIndex) {
|
|
96
|
+
if (!props.items[itemIndex].closeOthers && props.multiple) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
buttonRefs.value.forEach((close, index) => {
|
|
100
|
+
if (index === itemIndex)
|
|
101
|
+
return;
|
|
102
|
+
close();
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function onEnter(el, done) {
|
|
106
|
+
el.style.height = "0";
|
|
107
|
+
el.offsetHeight;
|
|
108
|
+
el.style.height = el.scrollHeight + "px";
|
|
109
|
+
el.addEventListener("transitionend", done, { once: true });
|
|
110
|
+
}
|
|
111
|
+
function onBeforeLeave(el) {
|
|
112
|
+
el.style.height = el.scrollHeight + "px";
|
|
113
|
+
el.offsetHeight;
|
|
114
|
+
}
|
|
115
|
+
function onAfterEnter(el) {
|
|
116
|
+
el.style.height = "auto";
|
|
117
|
+
}
|
|
118
|
+
function onLeave(el, done) {
|
|
119
|
+
el.style.height = "0";
|
|
120
|
+
el.addEventListener("transitionend", done, { once: true });
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
attrs: omit(attrs, ["class"]),
|
|
124
|
+
// eslint-disable-next-line vue/no-dupe-keys
|
|
125
|
+
ui,
|
|
126
|
+
uiButton,
|
|
127
|
+
wrapperClass,
|
|
128
|
+
buttonRefs,
|
|
129
|
+
closeOthers,
|
|
130
|
+
omit,
|
|
131
|
+
onEnter,
|
|
132
|
+
onBeforeLeave,
|
|
133
|
+
onAfterEnter,
|
|
134
|
+
onLeave
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
</script>
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
|
+
import type { PropType } from 'vue';
|
|
3
|
+
import type { AccordionItem } from '../../types/accordion';
|
|
4
|
+
declare const _default: import("vue").DefineComponent<{
|
|
5
|
+
items: {
|
|
6
|
+
type: PropType<AccordionItem[]>;
|
|
7
|
+
default: () => never[];
|
|
8
|
+
};
|
|
9
|
+
defaultOpen: {
|
|
10
|
+
type: BooleanConstructor;
|
|
11
|
+
default: boolean;
|
|
12
|
+
};
|
|
13
|
+
openIcon: {
|
|
14
|
+
type: StringConstructor;
|
|
15
|
+
default: () => any;
|
|
16
|
+
};
|
|
17
|
+
closeIcon: {
|
|
18
|
+
type: StringConstructor;
|
|
19
|
+
default: () => any;
|
|
20
|
+
};
|
|
21
|
+
multiple: {
|
|
22
|
+
type: BooleanConstructor;
|
|
23
|
+
default: boolean;
|
|
24
|
+
};
|
|
25
|
+
ui: {
|
|
26
|
+
type: PropType<any>;
|
|
27
|
+
default: () => {};
|
|
28
|
+
};
|
|
29
|
+
}, {
|
|
30
|
+
attrs: import("lodash").Omit<{
|
|
31
|
+
[x: string]: unknown;
|
|
32
|
+
}, "class">;
|
|
33
|
+
ui: import("vue").ComputedRef<any>;
|
|
34
|
+
uiButton: import("vue").ComputedRef<any>;
|
|
35
|
+
wrapperClass: import("vue").ComputedRef<string>;
|
|
36
|
+
buttonRefs: import("vue").Ref<Function[]>;
|
|
37
|
+
closeOthers: (itemIndex: number) => void;
|
|
38
|
+
omit: {
|
|
39
|
+
<T extends object, K extends import("lodash").PropertyName[]>(object: T | null | undefined, ...paths: K): Pick<T, Exclude<keyof T, K[number]>>;
|
|
40
|
+
<T_1 extends object, K_1 extends keyof T_1>(object: T_1 | null | undefined, ...paths: import("lodash").Many<K_1>[]): import("lodash").Omit<T_1, K_1>;
|
|
41
|
+
<T_2 extends object>(object: T_2 | null | undefined, ...paths: import("lodash").Many<import("lodash").PropertyName>[]): Partial<T_2>;
|
|
42
|
+
};
|
|
43
|
+
onEnter: (el: HTMLElement, done: any) => void;
|
|
44
|
+
onBeforeLeave: (el: HTMLElement) => void;
|
|
45
|
+
onAfterEnter: (el: HTMLElement) => void;
|
|
46
|
+
onLeave: (el: HTMLElement, done: any) => void;
|
|
47
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
48
|
+
items: {
|
|
49
|
+
type: PropType<AccordionItem[]>;
|
|
50
|
+
default: () => never[];
|
|
51
|
+
};
|
|
52
|
+
defaultOpen: {
|
|
53
|
+
type: BooleanConstructor;
|
|
54
|
+
default: boolean;
|
|
55
|
+
};
|
|
56
|
+
openIcon: {
|
|
57
|
+
type: StringConstructor;
|
|
58
|
+
default: () => any;
|
|
59
|
+
};
|
|
60
|
+
closeIcon: {
|
|
61
|
+
type: StringConstructor;
|
|
62
|
+
default: () => any;
|
|
63
|
+
};
|
|
64
|
+
multiple: {
|
|
65
|
+
type: BooleanConstructor;
|
|
66
|
+
default: boolean;
|
|
67
|
+
};
|
|
68
|
+
ui: {
|
|
69
|
+
type: PropType<any>;
|
|
70
|
+
default: () => {};
|
|
71
|
+
};
|
|
72
|
+
}>>, {
|
|
73
|
+
ui: any;
|
|
74
|
+
defaultOpen: boolean;
|
|
75
|
+
items: AccordionItem[];
|
|
76
|
+
openIcon: string;
|
|
77
|
+
closeIcon: string;
|
|
78
|
+
multiple: boolean;
|
|
79
|
+
}, {}>;
|
|
80
|
+
export default _default;
|