vueless 0.0.415 → 0.0.416
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
CHANGED
package/ui.data-table/UTable.vue
CHANGED
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
<UCheckbox
|
|
12
12
|
v-if="selectable"
|
|
13
13
|
v-model="selectAll"
|
|
14
|
-
size="sm"
|
|
15
14
|
:partial="!isSelectedAllRows"
|
|
16
15
|
:data-test="`${dataTest}-select-all`"
|
|
17
16
|
v-bind="stickyHeaderActionsCheckboxAttrs"
|
|
@@ -36,7 +35,6 @@
|
|
|
36
35
|
<UCheckbox
|
|
37
36
|
v-if="selectable"
|
|
38
37
|
v-model="selectAll"
|
|
39
|
-
size="sm"
|
|
40
38
|
:partial="!isSelectedAllRows"
|
|
41
39
|
:data-test="`${dataTest}-select-all`"
|
|
42
40
|
v-bind="stickyHeaderCheckboxAttrs"
|
|
@@ -107,7 +105,6 @@
|
|
|
107
105
|
<th v-if="selectable" v-bind="headerCellCheckboxAttrs">
|
|
108
106
|
<UCheckbox
|
|
109
107
|
v-model="selectAll"
|
|
110
|
-
size="sm"
|
|
111
108
|
:partial="!isSelectedAllRows"
|
|
112
109
|
:data-test="`${dataTest}-select-all`"
|
|
113
110
|
v-bind="headerCheckboxAttrs"
|
|
@@ -165,19 +162,12 @@
|
|
|
165
162
|
</td>
|
|
166
163
|
</tr>
|
|
167
164
|
|
|
168
|
-
<tr
|
|
169
|
-
v-
|
|
170
|
-
v-bind="
|
|
171
|
-
shouldDisplayDateSeparator(rowIndex)
|
|
172
|
-
? bodyRowDateSeparatorCheckedAttrs
|
|
173
|
-
: bodyRowDateSeparatorAttrs
|
|
174
|
-
"
|
|
175
|
-
>
|
|
176
|
-
<td v-bind="bodyCellDateSeparatorAttrs(rowIndex)" :colspan="colsCount">
|
|
165
|
+
<tr v-if="isShownDateDivider(rowIndex) && row.rowDate" v-bind="bodyRowDateDividerAttrs">
|
|
166
|
+
<td v-bind="bodyCellDateDividerAttrs" :colspan="colsCount">
|
|
177
167
|
<UDivider
|
|
178
168
|
size="xs"
|
|
179
|
-
:label="
|
|
180
|
-
v-bind="
|
|
169
|
+
:label="getDateDividerLabel(row.rowDate)"
|
|
170
|
+
v-bind="bodyDateDividerAttrs"
|
|
181
171
|
/>
|
|
182
172
|
</td>
|
|
183
173
|
</tr>
|
|
@@ -235,7 +225,7 @@
|
|
|
235
225
|
<!-- @slot Use it to add custom empty state. -->
|
|
236
226
|
<slot name="empty-state">
|
|
237
227
|
<UEmpty
|
|
238
|
-
size="
|
|
228
|
+
size="md"
|
|
239
229
|
:description="currentLocale.noData"
|
|
240
230
|
:data-test="`${dataTest}-empty`"
|
|
241
231
|
v-bind="bodyEmptyStateAttrs"
|
|
@@ -525,8 +515,7 @@ const {
|
|
|
525
515
|
bodyRowAttrs,
|
|
526
516
|
bodyRowCheckedAttrs,
|
|
527
517
|
footerAttrs,
|
|
528
|
-
|
|
529
|
-
bodyRowDateSeparatorCheckedAttrs,
|
|
518
|
+
bodyRowDateDividerAttrs,
|
|
530
519
|
headerCellBaseAttrs,
|
|
531
520
|
headerCellCheckboxAttrs,
|
|
532
521
|
stickyHeaderActionsCheckboxAttrs,
|
|
@@ -534,8 +523,8 @@ const {
|
|
|
534
523
|
headerCheckboxAttrs,
|
|
535
524
|
headerCounterAttrs,
|
|
536
525
|
bodyEmptyStateAttrs,
|
|
537
|
-
|
|
538
|
-
|
|
526
|
+
bodyDateDividerAttrs,
|
|
527
|
+
bodyCellDateDividerAttrs,
|
|
539
528
|
stickyHeaderActionsCounterAttrs,
|
|
540
529
|
stickyHeaderCounterAttrs,
|
|
541
530
|
stickyHeaderLoaderAttrs,
|
|
@@ -595,18 +584,10 @@ function onWindowResize() {
|
|
|
595
584
|
setFooterCellWidth();
|
|
596
585
|
}
|
|
597
586
|
|
|
598
|
-
function
|
|
587
|
+
function getDateDividerLabel(rowDate) {
|
|
599
588
|
return Array.isArray(props.dateDivider)
|
|
600
|
-
? props.dateDivider.find((dateItem) => dateItem.date ===
|
|
601
|
-
:
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
function shouldDisplayDateSeparator(rowIndex) {
|
|
605
|
-
const isPreviousRowChecked = tableRows.value[rowIndex - 1]?.isChecked;
|
|
606
|
-
const isCheckedRowAfter = tableRows.value[rowIndex]?.isChecked;
|
|
607
|
-
const isFirstRowAndNextChecked = rowIndex === 0 && isCheckedRowAfter;
|
|
608
|
-
|
|
609
|
-
return (isPreviousRowChecked && isCheckedRowAfter) || isFirstRowAndNextChecked;
|
|
589
|
+
? props.dateDivider.find((dateItem) => dateItem.date === rowDate)?.label || rowDate
|
|
590
|
+
: rowDate;
|
|
610
591
|
}
|
|
611
592
|
|
|
612
593
|
function getRowAttrs(rowId) {
|
|
@@ -668,7 +649,7 @@ function onKeyupEsc(event) {
|
|
|
668
649
|
}
|
|
669
650
|
}
|
|
670
651
|
|
|
671
|
-
function
|
|
652
|
+
function isShownDateDivider(rowIndex) {
|
|
672
653
|
const prevIndex = rowIndex ? rowIndex - 1 : rowIndex;
|
|
673
654
|
const nextIndex = rowIndex ? rowIndex + 1 : rowIndex;
|
|
674
655
|
const prevItem = tableRows.value[prevIndex];
|
|
@@ -679,8 +660,8 @@ function isShownDateSeparator(rowIndex) {
|
|
|
679
660
|
return hasSlotContentBeforeFirstRow.value;
|
|
680
661
|
}
|
|
681
662
|
|
|
682
|
-
const isPrevSameDate = prevItem?.
|
|
683
|
-
const isNextSameDate = nextItem?.
|
|
663
|
+
const isPrevSameDate = prevItem?.rowDate === currentItem?.rowDate;
|
|
664
|
+
const isNextSameDate = nextItem?.rowDate === currentItem?.rowDate;
|
|
684
665
|
|
|
685
666
|
return isPrevSameDate && !isNextSameDate && props.dateDivider;
|
|
686
667
|
}
|
|
@@ -720,6 +701,7 @@ function clearSelectedItems() {
|
|
|
720
701
|
}
|
|
721
702
|
|
|
722
703
|
function onToggleRowVisibility(rowId) {
|
|
704
|
+
// TODO: Use map instead of forEach to get rid of implicit array mutation.
|
|
723
705
|
tableRows.value.forEach((row) => toggleRowVisibility(row, rowId));
|
|
724
706
|
}
|
|
725
707
|
</script>
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<tr v-bind="$attrs" @click="onClick(props.row)">
|
|
3
|
-
<td
|
|
3
|
+
<td
|
|
4
|
+
v-if="selectable"
|
|
5
|
+
:style="getNestedCheckboxShift()"
|
|
6
|
+
v-bind="bodyCellCheckboxAttrs"
|
|
7
|
+
@click.stop
|
|
8
|
+
>
|
|
4
9
|
<UCheckbox
|
|
5
10
|
v-model="selectedRows"
|
|
6
11
|
:data-id="row.id"
|
|
7
12
|
:value="row.id"
|
|
8
|
-
size="sm"
|
|
9
13
|
:data-test="`${dataTest}-body-checkbox`"
|
|
10
14
|
v-bind="bodyCheckboxAttrs"
|
|
11
15
|
/>
|
package/ui.data-table/config.js
CHANGED
|
@@ -22,7 +22,7 @@ export default /*tw*/ {
|
|
|
22
22
|
header: "border-b border-gray-200",
|
|
23
23
|
headerRow: "",
|
|
24
24
|
headerCellBase: {
|
|
25
|
-
base: "p-4
|
|
25
|
+
base: "p-4 text-sm font-normal text-gray-500 text-left text-nowrap",
|
|
26
26
|
variants: {
|
|
27
27
|
compact: {
|
|
28
28
|
true: "px-4 py-3 last:px-4 last:py-3 first:px-4 first:py-3",
|
|
@@ -32,7 +32,7 @@ export default /*tw*/ {
|
|
|
32
32
|
headerCellCheckbox: "w-10",
|
|
33
33
|
headerCheckbox: "{UCheckbox}",
|
|
34
34
|
headerCounter: {
|
|
35
|
-
base: "absolute top-
|
|
35
|
+
base: "absolute top-4 mt-px left-11 bg-gradient-to-r from-white from-80% ml-px",
|
|
36
36
|
variants: {
|
|
37
37
|
compact: {
|
|
38
38
|
true: "top-3",
|
|
@@ -47,9 +47,9 @@ export default /*tw*/ {
|
|
|
47
47
|
bodyRowBeforeCell: "py-1",
|
|
48
48
|
bodyRowAfter: "!p-0",
|
|
49
49
|
bodyRowAfterCell: "py-1",
|
|
50
|
-
|
|
50
|
+
bodyRowDateDivider: "",
|
|
51
51
|
bodyCellBase: {
|
|
52
|
-
base: "p-[1.125rem] py-5
|
|
52
|
+
base: "p-[1.125rem] py-5 truncate align-top",
|
|
53
53
|
variants: {
|
|
54
54
|
compact: {
|
|
55
55
|
true: "px-4 py-3 last:px-4 last:py-3 first:!px-3.5 first:py-3",
|
|
@@ -61,7 +61,7 @@ export default /*tw*/ {
|
|
|
61
61
|
bodyCellSecondary: "mt-1 text-xs text-gray-500 overflow-hidden text-ellipsis",
|
|
62
62
|
bodyCellSecondaryEmpty: "inline-block",
|
|
63
63
|
bodyCellCheckbox: "first:px-4", // try to remove first
|
|
64
|
-
|
|
64
|
+
bodyCellDateDivider: "",
|
|
65
65
|
bodyCellNested: "mr-2 mt-0.5",
|
|
66
66
|
bodyCellNestedExpandIcon: {
|
|
67
67
|
component: "{UIcon}",
|
|
@@ -74,7 +74,7 @@ export default /*tw*/ {
|
|
|
74
74
|
container: "bg-gray-200",
|
|
75
75
|
},
|
|
76
76
|
bodyCheckbox: "{UCheckbox}",
|
|
77
|
-
|
|
77
|
+
bodyDateDivider: "{UDivider}",
|
|
78
78
|
bodyEmptyState: "{UEmpty} my-8",
|
|
79
79
|
footer: "group/footer border-t border-solid border-gray-200",
|
|
80
80
|
footerRow: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Meta, Title, Subtitle, Description, Primary, Controls, Stories, Source } from "@storybook/blocks";
|
|
1
|
+
import { Markdown, Meta, Title, Subtitle, Description, Primary, Controls, Stories, Source } from "@storybook/blocks";
|
|
2
2
|
import { getSource } from "../../utils/utilStorybook.js";
|
|
3
3
|
|
|
4
4
|
import * as stories from "./stories.js";
|
|
@@ -12,5 +12,22 @@ import defaultConfig from "../config.js?raw"
|
|
|
12
12
|
<Controls of={stories.Default} />
|
|
13
13
|
<Stories of={stories} />
|
|
14
14
|
|
|
15
|
+
## Formatting tokens
|
|
16
|
+
Each character in the table below can be used in `dateFormat` and `userDateFormat` / `userDateTimeFormat` options to achieve the format you need.
|
|
17
|
+
|
|
18
|
+
## Row meta keys
|
|
19
|
+
Keys you have/may to provide to component in row object.
|
|
20
|
+
|
|
21
|
+
<Markdown>
|
|
22
|
+
{`
|
|
23
|
+
| Key name | Description | Type | Required |
|
|
24
|
+
| ------------------| ------------------------------ | ---------------| ------------ |
|
|
25
|
+
| id | A unique identifier for row | String, Number | true |
|
|
26
|
+
| isChecked | Indicates if row checked | Boolean | false |
|
|
27
|
+
| isHidden | Indicated if nested row hidden | Boolean | false |
|
|
28
|
+
| rowDate | Row date for date divider | String, Date | false |
|
|
29
|
+
`}
|
|
30
|
+
</Markdown>
|
|
31
|
+
|
|
15
32
|
## Default config
|
|
16
33
|
<Source code={getSource(defaultConfig)} language="jsx" dark />
|
|
@@ -8,7 +8,7 @@ import UMoney from "../../ui.text-money/UMoney.vue";
|
|
|
8
8
|
import UBadge from "../../ui.text-badge/UBadge.vue";
|
|
9
9
|
import URow from "../../ui.container-row/URow.vue";
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const SHORT_STORY_PARAMETERS = {
|
|
12
12
|
docs: {
|
|
13
13
|
story: {
|
|
14
14
|
inline: false,
|
|
@@ -47,6 +47,18 @@ export default {
|
|
|
47
47
|
},
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
+
function getDateDividerRow() {
|
|
51
|
+
return {
|
|
52
|
+
id: getRandomId(),
|
|
53
|
+
isChecked: false,
|
|
54
|
+
rowDate: new Date().toString(),
|
|
55
|
+
key_1: "Info",
|
|
56
|
+
key_2: "Statistics",
|
|
57
|
+
key_3: "Reports",
|
|
58
|
+
key_4: "Discounts",
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
50
62
|
function getNestedRow() {
|
|
51
63
|
return {
|
|
52
64
|
id: getRandomId(),
|
|
@@ -321,11 +333,11 @@ export const Selectable = DefaultTemplate.bind({});
|
|
|
321
333
|
Selectable.args = { selectable: true };
|
|
322
334
|
|
|
323
335
|
export const StickyHeader = DefaultTemplate.bind({});
|
|
324
|
-
StickyHeader.parameters =
|
|
336
|
+
StickyHeader.parameters = SHORT_STORY_PARAMETERS;
|
|
325
337
|
StickyHeader.args = { numberOfRows: 50, selectable: true, stickyHeader: true };
|
|
326
338
|
|
|
327
339
|
export const StickyFooter = DefaultTemplate.bind({});
|
|
328
|
-
StickyFooter.parameters =
|
|
340
|
+
StickyFooter.parameters = SHORT_STORY_PARAMETERS;
|
|
329
341
|
StickyFooter.args = {
|
|
330
342
|
numberOfRows: 50,
|
|
331
343
|
selectable: true,
|
|
@@ -346,16 +358,12 @@ export const Compact = DefaultTemplate.bind({});
|
|
|
346
358
|
Compact.args = { compact: true };
|
|
347
359
|
|
|
348
360
|
export const DateDivider = DefaultTemplate.bind({});
|
|
349
|
-
DateDivider.args = { dateDivider: true };
|
|
361
|
+
DateDivider.args = { dateDivider: true, row: getDateDividerRow };
|
|
350
362
|
|
|
351
363
|
export const DateDividerCustomLabel = DefaultTemplate.bind({});
|
|
352
364
|
DateDividerCustomLabel.args = {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
date: new Date(1709046013 * 1000).toString(),
|
|
356
|
-
label: "Label for this date",
|
|
357
|
-
},
|
|
358
|
-
],
|
|
365
|
+
row: getDateDividerRow,
|
|
366
|
+
dateDivider: [{ date: new Date().toString(), label: "Custom label for specific date" }],
|
|
359
367
|
};
|
|
360
368
|
|
|
361
369
|
export const SlotDefault = DefaultTemplate.bind({});
|
|
@@ -368,6 +376,7 @@ SlotDefault.args = {
|
|
|
368
376
|
};
|
|
369
377
|
|
|
370
378
|
export const SlotHeaderActions = DefaultTemplate.bind({});
|
|
379
|
+
SlotHeaderActions.parameters = SHORT_STORY_PARAMETERS;
|
|
371
380
|
SlotHeaderActions.args = {
|
|
372
381
|
numberOfRows: 50,
|
|
373
382
|
stickyHeader: true,
|