vueless 0.0.532 → 0.0.533
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 +1 -1
- package/types.ts +12 -0
- package/ui.image-avatar/UAvatar.vue +51 -115
- package/ui.image-avatar/storybook/Docs.mdx +2 -2
- package/ui.image-avatar/storybook/{stories.js → stories.ts} +13 -5
- package/ui.image-avatar/types.ts +71 -0
- package/ui.image-avatar/useAttrs.ts +18 -0
- package/ui.image-icon/UIcon.vue +28 -113
- package/ui.image-icon/storybook/Docs.mdx +1 -1
- package/ui.image-icon/storybook/{stories.js → stories.ts} +13 -5
- package/ui.image-icon/types.ts +83 -0
- package/ui.image-icon/useAttrs.ts +18 -0
- package/ui.navigation-pagination/UPagination.vue +141 -262
- package/ui.navigation-pagination/storybook/Docs.mdx +2 -2
- package/ui.navigation-pagination/storybook/{stories.js → stories.ts} +11 -4
- package/ui.navigation-pagination/types.ts +85 -0
- package/ui.navigation-pagination/{useAttrs.js → useAttrs.ts} +5 -2
- package/ui.navigation-progress/StepperProgress.vue +26 -47
- package/ui.navigation-progress/UProgress.vue +60 -118
- package/ui.navigation-progress/{config.js → config.ts} +1 -0
- package/ui.navigation-progress/storybook/Docs.mdx +2 -2
- package/ui.navigation-progress/storybook/{stories.js → stories.ts} +19 -7
- package/ui.navigation-progress/types.ts +93 -0
- package/ui.navigation-progress/{useAttrs.js → useAttrs.ts} +6 -3
- package/ui.navigation-tab/UTab.vue +18 -54
- package/ui.navigation-tab/storybook/Docs.mdx +2 -2
- package/ui.navigation-tab/storybook/{stories.js → stories.ts} +10 -5
- package/ui.navigation-tab/types.ts +30 -0
- package/ui.navigation-tab/{useAttrs.js → useAttrs.ts} +15 -3
- package/ui.navigation-tabs/UTabs.vue +29 -78
- package/ui.navigation-tabs/storybook/Docs.mdx +2 -2
- package/ui.navigation-tabs/storybook/{stories.js → stories.ts} +13 -5
- package/ui.navigation-tabs/types.ts +37 -0
- package/ui.navigation-tabs/useAttrs.ts +18 -0
- package/web-types.json +146 -77
- package/ui.image-avatar/useAttrs.js +0 -15
- package/ui.image-icon/useAttrs.js +0 -15
- package/ui.navigation-tabs/useAttrs.js +0 -15
- /package/ui.image-avatar/{config.js → config.ts} +0 -0
- /package/ui.image-avatar/{constants.js → constants.ts} +0 -0
- /package/ui.image-icon/{constants.js → constants.ts} +0 -0
- /package/ui.navigation-pagination/{config.js → config.ts} +0 -0
- /package/ui.navigation-pagination/{constants.js → constants.ts} +0 -0
- /package/ui.navigation-progress/{constants.js → constants.ts} +0 -0
- /package/ui.navigation-tab/{config.js → config.ts} +0 -0
- /package/ui.navigation-tab/{constants.js → constants.ts} +0 -0
- /package/ui.navigation-tabs/{config.js → config.ts} +0 -0
- /package/ui.navigation-tabs/{constants.js → constants.ts} +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
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 { UIconProps, Config } from "./types.ts";
|
|
7
|
+
|
|
8
|
+
export default function useAttrs(props: UIconProps): UseAttrs<Config> {
|
|
9
|
+
const { config, getKeysAttrs, hasSlotContent } = useUI<Config>(defaultConfig, () => props.config);
|
|
10
|
+
|
|
11
|
+
const keysAttrs = getKeysAttrs();
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
config,
|
|
15
|
+
...keysAttrs,
|
|
16
|
+
hasSlotContent,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -1,3 +1,144 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { range } from "lodash-es";
|
|
4
|
+
|
|
5
|
+
import UButton from "../ui.button/UButton.vue";
|
|
6
|
+
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
7
|
+
import { getDefault } from "../utils/ui.ts";
|
|
8
|
+
|
|
9
|
+
import defaultConfig from "./config.ts";
|
|
10
|
+
import { UPagination } from "./constants.ts";
|
|
11
|
+
import useAttrs from "./useAttrs.ts";
|
|
12
|
+
|
|
13
|
+
import type { UPaginationProps } from "./types.ts";
|
|
14
|
+
|
|
15
|
+
defineOptions({ inheritAttrs: false });
|
|
16
|
+
|
|
17
|
+
const props = withDefaults(defineProps<UPaginationProps>(), {
|
|
18
|
+
perPage: getDefault<UPaginationProps>(defaultConfig, UPagination).perPage,
|
|
19
|
+
limit: getDefault<UPaginationProps>(defaultConfig, UPagination).limit,
|
|
20
|
+
variant: getDefault<UPaginationProps>(defaultConfig, UPagination).variant,
|
|
21
|
+
size: getDefault<UPaginationProps>(defaultConfig, UPagination).size,
|
|
22
|
+
disabled: getDefault<UPaginationProps>(defaultConfig, UPagination).disabled,
|
|
23
|
+
ellipsis: getDefault<UPaginationProps>(defaultConfig, UPagination).ellipsis,
|
|
24
|
+
showFirst: getDefault<UPaginationProps>(defaultConfig, UPagination).showFirst,
|
|
25
|
+
showLast: getDefault<UPaginationProps>(defaultConfig, UPagination).showLast,
|
|
26
|
+
dataTest: "",
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const emit = defineEmits([
|
|
30
|
+
/**
|
|
31
|
+
* Triggers when current page changes.
|
|
32
|
+
* @property {number} value
|
|
33
|
+
*/
|
|
34
|
+
"change",
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Triggers when current page changes.
|
|
38
|
+
* @property {number} value
|
|
39
|
+
*/
|
|
40
|
+
"update:modelValue",
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
const {
|
|
44
|
+
config,
|
|
45
|
+
paginationAttrs,
|
|
46
|
+
firstButtonAttrs,
|
|
47
|
+
lastButtonAttrs,
|
|
48
|
+
prevButtonAttrs,
|
|
49
|
+
nextButtonAttrs,
|
|
50
|
+
activeButtonAttrs,
|
|
51
|
+
inactiveButtonAttrs,
|
|
52
|
+
lastIconAttrs,
|
|
53
|
+
firstIconAttrs,
|
|
54
|
+
prevIconAttrs,
|
|
55
|
+
nextIconAttrs,
|
|
56
|
+
} = useAttrs(props);
|
|
57
|
+
|
|
58
|
+
const currentPage = computed({
|
|
59
|
+
get: () => props.modelValue,
|
|
60
|
+
set: (value) => {
|
|
61
|
+
emit("update:modelValue", value);
|
|
62
|
+
emit("change", value);
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const buttonSize = computed(() => {
|
|
67
|
+
const sizes = {
|
|
68
|
+
sm: "xs",
|
|
69
|
+
md: "sm",
|
|
70
|
+
lg: "md",
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return sizes[props.size];
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const iconSize = computed(() => {
|
|
77
|
+
const sizes = {
|
|
78
|
+
sm: "xs",
|
|
79
|
+
md: "sm",
|
|
80
|
+
lg: "md",
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return sizes[props.size];
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const totalPages = computed(() => {
|
|
87
|
+
return props.perPage > 0 ? Math.ceil(props.total / props.perPage) : 0;
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const pageButtons = computed(() => {
|
|
91
|
+
const from1 = Number(currentPage.value) - Math.round(props.limit / 2) + 1;
|
|
92
|
+
const from2 = totalPages.value + 1 - props.limit;
|
|
93
|
+
|
|
94
|
+
const from = Math.max(Math.min(from1, from2), 1);
|
|
95
|
+
const to = Math.min(from + props.limit - 1, totalPages.value);
|
|
96
|
+
|
|
97
|
+
return range(from, to + 1).map((page) => {
|
|
98
|
+
if (props.ellipsis && page === from && from > 1) {
|
|
99
|
+
return { number: -Infinity };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (props.ellipsis && page === to && to < totalPages.value) {
|
|
103
|
+
return { number: Infinity };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return { number: page, isActive: page === currentPage.value };
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const prevIsDisabled = computed(() => {
|
|
111
|
+
return props.disabled || currentPage.value === null || currentPage.value <= 1;
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const nextIsDisabled = computed(() => {
|
|
115
|
+
return props.disabled || currentPage.value === null || currentPage.value >= totalPages.value;
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
function selectPage(page: number) {
|
|
119
|
+
currentPage.value = page;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function goToPrevPage() {
|
|
123
|
+
currentPage.value = currentPage.value === null ? 1 : Math.max(currentPage.value - 1, 1);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function goToNextPage() {
|
|
127
|
+
currentPage.value =
|
|
128
|
+
currentPage.value === null
|
|
129
|
+
? totalPages.value
|
|
130
|
+
: Math.min(currentPage.value + 1, totalPages.value);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function goToFirstPage() {
|
|
134
|
+
currentPage.value = 1;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function goToLastPage() {
|
|
138
|
+
currentPage.value = totalPages.value;
|
|
139
|
+
}
|
|
140
|
+
</script>
|
|
141
|
+
|
|
1
142
|
<template>
|
|
2
143
|
<div v-bind="paginationAttrs">
|
|
3
144
|
<UButton
|
|
@@ -134,265 +275,3 @@
|
|
|
134
275
|
</UButton>
|
|
135
276
|
</div>
|
|
136
277
|
</template>
|
|
137
|
-
|
|
138
|
-
<script setup>
|
|
139
|
-
import { computed } from "vue";
|
|
140
|
-
import { range } from "lodash-es";
|
|
141
|
-
|
|
142
|
-
import UButton from "../ui.button/UButton.vue";
|
|
143
|
-
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
144
|
-
import { getDefault } from "../utils/ui.ts";
|
|
145
|
-
|
|
146
|
-
import defaultConfig from "./config.js";
|
|
147
|
-
import { UPagination } from "./constants.js";
|
|
148
|
-
import useAttrs from "./useAttrs.js";
|
|
149
|
-
|
|
150
|
-
defineOptions({ inheritAttrs: false });
|
|
151
|
-
|
|
152
|
-
const props = defineProps({
|
|
153
|
-
/**
|
|
154
|
-
* Current page number.
|
|
155
|
-
*/
|
|
156
|
-
modelValue: {
|
|
157
|
-
type: Number,
|
|
158
|
-
default: null,
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Number of items per page.
|
|
163
|
-
*/
|
|
164
|
-
perPage: {
|
|
165
|
-
type: Number,
|
|
166
|
-
default: getDefault(defaultConfig, UPagination).perPage,
|
|
167
|
-
validator: (value) => value > 0,
|
|
168
|
-
},
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Total number of items.
|
|
172
|
-
*/
|
|
173
|
-
total: {
|
|
174
|
-
type: Number,
|
|
175
|
-
default: 0,
|
|
176
|
-
validator: (value) => value >= 0,
|
|
177
|
-
},
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Limit of visible pages.
|
|
181
|
-
*/
|
|
182
|
-
limit: {
|
|
183
|
-
type: Number,
|
|
184
|
-
default: getDefault(defaultConfig, UPagination).limit,
|
|
185
|
-
validator: (value) => value >= 0,
|
|
186
|
-
},
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Pagination variant.
|
|
190
|
-
* @values primary, secondary, thirdary
|
|
191
|
-
*/
|
|
192
|
-
variant: {
|
|
193
|
-
type: String,
|
|
194
|
-
default: getDefault(defaultConfig, UPagination).variant,
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Pagination size.
|
|
199
|
-
* @values sm, md, lg
|
|
200
|
-
*/
|
|
201
|
-
size: {
|
|
202
|
-
type: String,
|
|
203
|
-
default: getDefault(defaultConfig, UPagination).size,
|
|
204
|
-
},
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* First button label.
|
|
208
|
-
*/
|
|
209
|
-
firstLabel: {
|
|
210
|
-
type: String,
|
|
211
|
-
default: "",
|
|
212
|
-
},
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Prev button label.
|
|
216
|
-
*/
|
|
217
|
-
prevLabel: {
|
|
218
|
-
type: String,
|
|
219
|
-
default: "",
|
|
220
|
-
},
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Next button label.
|
|
224
|
-
*/
|
|
225
|
-
nextLabel: {
|
|
226
|
-
type: String,
|
|
227
|
-
default: "",
|
|
228
|
-
},
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Last button label.
|
|
232
|
-
*/
|
|
233
|
-
lastLabel: {
|
|
234
|
-
type: String,
|
|
235
|
-
default: "",
|
|
236
|
-
},
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Disable navigation buttons.
|
|
240
|
-
*/
|
|
241
|
-
disabled: {
|
|
242
|
-
type: Boolean,
|
|
243
|
-
default: getDefault(defaultConfig, UPagination).disabled,
|
|
244
|
-
},
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Show ellipsis.
|
|
248
|
-
*/
|
|
249
|
-
ellipsis: {
|
|
250
|
-
type: Boolean,
|
|
251
|
-
default: getDefault(defaultConfig, UPagination).ellipsis,
|
|
252
|
-
},
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Show the first control.
|
|
256
|
-
*/
|
|
257
|
-
showFirst: {
|
|
258
|
-
type: Boolean,
|
|
259
|
-
default: getDefault(defaultConfig, UPagination).showLast,
|
|
260
|
-
},
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Show the last control.
|
|
264
|
-
*/
|
|
265
|
-
showLast: {
|
|
266
|
-
type: Boolean,
|
|
267
|
-
default: getDefault(defaultConfig, UPagination).showLast,
|
|
268
|
-
},
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Component config object.
|
|
272
|
-
*/
|
|
273
|
-
config: {
|
|
274
|
-
type: Object,
|
|
275
|
-
default: () => ({}),
|
|
276
|
-
},
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Data-test attribute for automated testing.
|
|
280
|
-
*/
|
|
281
|
-
dataTest: {
|
|
282
|
-
type: String,
|
|
283
|
-
default: "",
|
|
284
|
-
},
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
const emit = defineEmits([
|
|
288
|
-
/**
|
|
289
|
-
* Triggers when current page changes.
|
|
290
|
-
* @property {number} value
|
|
291
|
-
*/
|
|
292
|
-
"change",
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* Triggers when current page changes.
|
|
296
|
-
* @property {number} value
|
|
297
|
-
*/
|
|
298
|
-
"update:modelValue",
|
|
299
|
-
]);
|
|
300
|
-
|
|
301
|
-
const {
|
|
302
|
-
config,
|
|
303
|
-
paginationAttrs,
|
|
304
|
-
firstButtonAttrs,
|
|
305
|
-
lastButtonAttrs,
|
|
306
|
-
prevButtonAttrs,
|
|
307
|
-
nextButtonAttrs,
|
|
308
|
-
activeButtonAttrs,
|
|
309
|
-
inactiveButtonAttrs,
|
|
310
|
-
lastIconAttrs,
|
|
311
|
-
firstIconAttrs,
|
|
312
|
-
prevIconAttrs,
|
|
313
|
-
nextIconAttrs,
|
|
314
|
-
} = useAttrs(props);
|
|
315
|
-
|
|
316
|
-
const currentPage = computed({
|
|
317
|
-
get: () => props.modelValue,
|
|
318
|
-
set: (value) => {
|
|
319
|
-
emit("update:modelValue", value);
|
|
320
|
-
emit("change", value);
|
|
321
|
-
},
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
const buttonSize = computed(() => {
|
|
325
|
-
const sizes = {
|
|
326
|
-
sm: "xs",
|
|
327
|
-
md: "sm",
|
|
328
|
-
lg: "md",
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
return sizes[props.size];
|
|
332
|
-
});
|
|
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
|
-
const totalPages = computed(() => {
|
|
345
|
-
return props.perPage > 0 ? Math.ceil(props.total / props.perPage) : 0;
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
const pageButtons = computed(() => {
|
|
349
|
-
const from1 = Number(currentPage.value) - Math.round(props.limit / 2) + 1;
|
|
350
|
-
const from2 = totalPages.value + 1 - props.limit;
|
|
351
|
-
|
|
352
|
-
const from = Math.max(Math.min(from1, from2), 1);
|
|
353
|
-
const to = Math.min(from + props.limit - 1, totalPages.value);
|
|
354
|
-
|
|
355
|
-
return range(from, to + 1).map((page) => {
|
|
356
|
-
if (props.ellipsis && page === from && from > 1) {
|
|
357
|
-
return { number: -Infinity };
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
if (props.ellipsis && page === to && to < totalPages.value) {
|
|
361
|
-
return { number: Infinity };
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
return { number: page, isActive: page === currentPage.value };
|
|
365
|
-
});
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
const prevIsDisabled = computed(() => {
|
|
369
|
-
return props.disabled || currentPage.value === null || currentPage.value <= 1;
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
const nextIsDisabled = computed(() => {
|
|
373
|
-
return props.disabled || currentPage.value === null || currentPage.value >= totalPages.value;
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
function selectPage(page) {
|
|
377
|
-
currentPage.value = page;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
function goToPrevPage() {
|
|
381
|
-
currentPage.value = currentPage.value === null ? 1 : Math.max(currentPage.value - 1, 1);
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
function goToNextPage() {
|
|
385
|
-
currentPage.value =
|
|
386
|
-
currentPage.value === null
|
|
387
|
-
? totalPages.value
|
|
388
|
-
: Math.min(currentPage.value + 1, totalPages.value);
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
function goToFirstPage() {
|
|
392
|
-
currentPage.value = 1;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
function goToLastPage() {
|
|
396
|
-
currentPage.value = totalPages.value;
|
|
397
|
-
}
|
|
398
|
-
</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} />
|
|
@@ -2,6 +2,13 @@ import { getArgTypes, getSlotNames, getSlotsFragment } from "../../utils/storybo
|
|
|
2
2
|
|
|
3
3
|
import UPagination from "../../ui.navigation-pagination/UPagination.vue";
|
|
4
4
|
|
|
5
|
+
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
6
|
+
import type { UPaginationProps } from "../types.ts";
|
|
7
|
+
|
|
8
|
+
interface UPaginationArgs extends UPaginationProps {
|
|
9
|
+
slotTemplate?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
5
12
|
/**
|
|
6
13
|
* The `UPagination` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.navigation-pagination)
|
|
7
14
|
*/
|
|
@@ -16,9 +23,9 @@ export default {
|
|
|
16
23
|
argTypes: {
|
|
17
24
|
...getArgTypes(UPagination.__name),
|
|
18
25
|
},
|
|
19
|
-
};
|
|
26
|
+
} as Meta;
|
|
20
27
|
|
|
21
|
-
const DefaultTemplate = (args) => ({
|
|
28
|
+
const DefaultTemplate: StoryFn<UPaginationArgs> = (args: UPaginationArgs) => ({
|
|
22
29
|
components: { UPagination },
|
|
23
30
|
setup() {
|
|
24
31
|
const slots = getSlotNames(UPagination.__name);
|
|
@@ -27,7 +34,7 @@ const DefaultTemplate = (args) => ({
|
|
|
27
34
|
},
|
|
28
35
|
template: `
|
|
29
36
|
<UPagination v-bind="args" v-model="args.modelValue">
|
|
30
|
-
${args.slotTemplate || getSlotsFragment()}
|
|
37
|
+
${args.slotTemplate || getSlotsFragment("")}
|
|
31
38
|
</UPagination>
|
|
32
39
|
`,
|
|
33
40
|
});
|
|
@@ -42,7 +49,7 @@ export const Limit = DefaultTemplate.bind({});
|
|
|
42
49
|
Limit.args = { limit: 3 };
|
|
43
50
|
|
|
44
51
|
export const HideEllipsis = DefaultTemplate.bind({});
|
|
45
|
-
HideEllipsis.args = {
|
|
52
|
+
HideEllipsis.args = { ellipsis: false };
|
|
46
53
|
|
|
47
54
|
export const Disabled = DefaultTemplate.bind({});
|
|
48
55
|
Disabled.args = { disabled: true };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import defaultConfig from "./config.ts";
|
|
2
|
+
|
|
3
|
+
export type Config = Partial<typeof defaultConfig>;
|
|
4
|
+
|
|
5
|
+
export interface UPaginationProps {
|
|
6
|
+
/**
|
|
7
|
+
* Current page number.
|
|
8
|
+
*/
|
|
9
|
+
modelValue?: number;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Number of items per page.
|
|
13
|
+
*/
|
|
14
|
+
perPage?: number;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Total number of items.
|
|
18
|
+
*/
|
|
19
|
+
total?: number;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Limit of visible pages.
|
|
23
|
+
*/
|
|
24
|
+
limit?: number;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Pagination variant.
|
|
28
|
+
*/
|
|
29
|
+
variant?: "primary" | "secondary" | "thirdary";
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Pagination size.
|
|
33
|
+
*/
|
|
34
|
+
size?: "sm" | "md" | "lg";
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* First button label.
|
|
38
|
+
*/
|
|
39
|
+
firstLabel?: string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Prev button label.
|
|
43
|
+
*/
|
|
44
|
+
prevLabel?: string;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Next button label.
|
|
48
|
+
*/
|
|
49
|
+
nextLabel?: string;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Last button label.
|
|
53
|
+
*/
|
|
54
|
+
lastLabel?: string;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Disable navigation buttons.
|
|
58
|
+
*/
|
|
59
|
+
disabled?: boolean;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Show ellipsis.
|
|
63
|
+
*/
|
|
64
|
+
ellipsis?: boolean;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Show the first control.
|
|
68
|
+
*/
|
|
69
|
+
showFirst?: boolean;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Show the last control.
|
|
73
|
+
*/
|
|
74
|
+
showLast?: boolean;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Component config object.
|
|
78
|
+
*/
|
|
79
|
+
config?: Partial<typeof defaultConfig>;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Data-test attribute for automated testing.
|
|
83
|
+
*/
|
|
84
|
+
dataTest?: string;
|
|
85
|
+
}
|
|
@@ -3,8 +3,11 @@ import useUI from "../composables/useUI.ts";
|
|
|
3
3
|
|
|
4
4
|
import defaultConfig from "./config.js";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import type { UseAttrs } from "../types.ts";
|
|
7
|
+
import type { UPaginationProps, Config } from "./types.ts";
|
|
8
|
+
|
|
9
|
+
export default function useAttrs(props: UPaginationProps): UseAttrs<Config> {
|
|
10
|
+
const { config, getKeysAttrs, hasSlotContent, getExtendingKeysClasses } = useUI<Config>(
|
|
8
11
|
defaultConfig,
|
|
9
12
|
() => props.config,
|
|
10
13
|
);
|
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import colors from "tailwindcss/colors.js";
|
|
3
|
+
import { computed } from "vue";
|
|
4
|
+
|
|
5
|
+
import { GRAY_COLORS } from "../constants.js";
|
|
6
|
+
|
|
7
|
+
import useAttrs from "./useAttrs.ts";
|
|
8
|
+
|
|
9
|
+
import type { StepperProgressProps } from "./types.ts";
|
|
10
|
+
|
|
11
|
+
const props = withDefaults(defineProps<StepperProgressProps>(), {
|
|
12
|
+
dataTest: "",
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const { stepperCircleAttrs, stepperCountAttrs, stepperGradientAttrs, stepperSvgAttrs } =
|
|
16
|
+
useAttrs(props);
|
|
17
|
+
|
|
18
|
+
const stepperColor = computed(() => {
|
|
19
|
+
return colors[props.color]
|
|
20
|
+
? colors[props.color][500]
|
|
21
|
+
: GRAY_COLORS.includes(props.color)
|
|
22
|
+
? colors[props.color][900]
|
|
23
|
+
: colors.zinc[900];
|
|
24
|
+
});
|
|
25
|
+
</script>
|
|
26
|
+
|
|
1
27
|
<template>
|
|
2
28
|
<svg viewBox="0 0 40 40" v-bind="stepperSvgAttrs">
|
|
3
29
|
<defs>
|
|
@@ -33,50 +59,3 @@
|
|
|
33
59
|
</g>
|
|
34
60
|
</svg>
|
|
35
61
|
</template>
|
|
36
|
-
|
|
37
|
-
<script setup>
|
|
38
|
-
import colors from "tailwindcss/colors.js";
|
|
39
|
-
import { computed } from "vue";
|
|
40
|
-
|
|
41
|
-
import { GRAY_COLORS } from "../constants.js";
|
|
42
|
-
|
|
43
|
-
import useAttrs from "./useAttrs.js";
|
|
44
|
-
|
|
45
|
-
const props = defineProps({
|
|
46
|
-
progressPercent: {
|
|
47
|
-
type: String,
|
|
48
|
-
required: true,
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
value: {
|
|
52
|
-
type: Number,
|
|
53
|
-
required: true,
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
color: {
|
|
57
|
-
type: String,
|
|
58
|
-
required: true,
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
config: {
|
|
62
|
-
type: Object,
|
|
63
|
-
default: () => ({}),
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
dataTest: {
|
|
67
|
-
type: String,
|
|
68
|
-
default: "",
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
const { stepperCircleAttrs, stepperCountAttrs, stepperGradientAttrs, stepperSvgAttrs } =
|
|
73
|
-
useAttrs(props);
|
|
74
|
-
|
|
75
|
-
const stepperColor = computed(() => {
|
|
76
|
-
return colors[props.color]
|
|
77
|
-
? colors[props.color][500]
|
|
78
|
-
: GRAY_COLORS.includes(props.color)
|
|
79
|
-
? colors[props.color][900]
|
|
80
|
-
: colors.zinc[900];
|
|
81
|
-
});
|
|
82
|
-
</script>
|