vueless 0.0.424 → 0.0.426
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/directives/vTooltip.js +15 -1
- package/package.json +1 -1
- package/preset.tailwind.js +40 -0
- package/ui.data-table/UTableRow.vue +47 -52
- package/ui.data-table/config.js +1 -3
- package/ui.data-table/storybook/Docs.mdx +7 -6
- package/ui.data-table/storybook/stories.js +38 -84
- package/ui.data-table/utilTable.js +7 -3
- package/ui.form-calendar/config.js +3 -3
- package/ui.form-date-picker-range/UDatePickerRangePeriodMenu.vue +21 -94
- package/ui.form-date-picker-range/config.js +3 -7
- package/ui.form-date-picker-range/useAttrs.js +9 -26
- package/web-types.json +4 -1
package/directives/vTooltip.js
CHANGED
|
@@ -25,12 +25,26 @@ export default {
|
|
|
25
25
|
mounted(el, bindings) {
|
|
26
26
|
if (isSSR) return;
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
if (typeof bindings.value === "string" && bindings.value.length) {
|
|
29
|
+
tippy(el, merge(settings, { content: bindings.value }));
|
|
30
|
+
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (bindings.value.content && bindings.value.content.length) {
|
|
35
|
+
tippy(el, merge(settings, bindings.value || {}));
|
|
36
|
+
}
|
|
29
37
|
},
|
|
30
38
|
|
|
31
39
|
updated(el, bindings) {
|
|
32
40
|
if (!el._tippy || isSSR) return;
|
|
33
41
|
|
|
42
|
+
if (typeof bindings.value === "string") {
|
|
43
|
+
el._tippy.setProps(merge(settings, { content: bindings.value }));
|
|
44
|
+
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
34
48
|
el._tippy.setProps(merge(settings, bindings.value || {}));
|
|
35
49
|
},
|
|
36
50
|
|
package/package.json
CHANGED
package/preset.tailwind.js
CHANGED
|
@@ -6,6 +6,10 @@ import {
|
|
|
6
6
|
GRAY_COLOR,
|
|
7
7
|
COOL_COLOR,
|
|
8
8
|
DARK_MODE_SELECTOR,
|
|
9
|
+
DEFAULT_ROUNDING,
|
|
10
|
+
DEFAULT_RING,
|
|
11
|
+
DEFAULT_RING_OFFSET,
|
|
12
|
+
DEFAULT_GRAY_COLOR,
|
|
9
13
|
} from "./constants.js";
|
|
10
14
|
|
|
11
15
|
const isStrategyOverride = process.env.VUELESS_STRATEGY === "override";
|
|
@@ -82,6 +86,16 @@ export const vuelessTailwindConfig = {
|
|
|
82
86
|
dynamic: "var(--vl-rounding)",
|
|
83
87
|
},
|
|
84
88
|
},
|
|
89
|
+
configViewer: {
|
|
90
|
+
themeReplacements: {
|
|
91
|
+
// TODO: Set colors from vueless.config.{js|ts} if it present.
|
|
92
|
+
"var(--vl-ring)": DEFAULT_RING,
|
|
93
|
+
"var(--vl-ring-offset)": DEFAULT_RING_OFFSET,
|
|
94
|
+
"var(--vl-rounding)": DEFAULT_ROUNDING,
|
|
95
|
+
...getReplacementColors(GRAY_COLOR, DEFAULT_GRAY_COLOR),
|
|
96
|
+
...getReplacementColors(BRAND_COLOR, DEFAULT_GRAY_COLOR),
|
|
97
|
+
},
|
|
98
|
+
},
|
|
85
99
|
},
|
|
86
100
|
};
|
|
87
101
|
|
|
@@ -133,3 +147,29 @@ function getPalette(color) {
|
|
|
133
147
|
|
|
134
148
|
return palette;
|
|
135
149
|
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Prepare a color object for theme replacement to fix missing css color variables in `tailwind-config-viewer`.
|
|
153
|
+
* @param { String } color (gray | brand)
|
|
154
|
+
* @param { String } tailwindColor any tailwind color with pallet.
|
|
155
|
+
* @returns { Object } - `tailwind-config-viewer` color replacement object.
|
|
156
|
+
*/
|
|
157
|
+
function getReplacementColors(color, tailwindColor) {
|
|
158
|
+
const customColors = {
|
|
159
|
+
...colors,
|
|
160
|
+
[BRAND_COLOR]: brandColors || {},
|
|
161
|
+
[GRAY_COLOR]: grayColors || {},
|
|
162
|
+
[COOL_COLOR]: { ...(colors[GRAY_COLOR] || {}) },
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
let varsPalette = {
|
|
166
|
+
[twColorWithOpacity(`--vl-color-${color}-default`)]: customColors[tailwindColor][600],
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
COLOR_SHADES.forEach((shade) => {
|
|
170
|
+
varsPalette[twColorWithOpacity(`--vl-color-${color}-${shade}`)] =
|
|
171
|
+
customColors[tailwindColor][shade];
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
return varsPalette;
|
|
175
|
+
}
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
<td
|
|
19
19
|
v-for="(value, key, index) in getFilteredRow(row, columns)"
|
|
20
20
|
:key="index"
|
|
21
|
-
v-bind="getCellAttrs(
|
|
21
|
+
v-bind="getCellAttrs(row, index)"
|
|
22
22
|
:class="
|
|
23
|
-
cx([getCellAttrs(
|
|
23
|
+
cx([getCellAttrs(row, index).class, columns[index].tdClass, getCellClasses(row, key)])
|
|
24
24
|
"
|
|
25
25
|
>
|
|
26
26
|
<div
|
|
@@ -36,42 +36,20 @@
|
|
|
36
36
|
:name="getToggleIconName(row)"
|
|
37
37
|
color="brand"
|
|
38
38
|
v-bind="toggleIconConfig"
|
|
39
|
-
@click="
|
|
39
|
+
@click="onClickToggleIcon"
|
|
40
40
|
/>
|
|
41
41
|
</div>
|
|
42
42
|
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
<template v-if="Array.isArray(value.secondary)">
|
|
54
|
-
<div v-for="(secondary, idx) in value.secondary" ref="cellRef" :key="idx">
|
|
55
|
-
<span v-bind="bodyCellSecondaryEmptyAttrs">
|
|
56
|
-
{{ secondary }}
|
|
57
|
-
</span>
|
|
58
|
-
</div>
|
|
59
|
-
</template>
|
|
60
|
-
|
|
61
|
-
<div v-else ref="cellRef">
|
|
62
|
-
{{ value.secondary }}
|
|
63
|
-
</div>
|
|
64
|
-
</div>
|
|
65
|
-
</slot>
|
|
66
|
-
</div>
|
|
67
|
-
|
|
68
|
-
<template v-else>
|
|
69
|
-
<slot :name="`cell-${key}`" :value="value" :row="row">
|
|
70
|
-
<div v-bind="bodyCellPrimaryAttrs" ref="cellRef" :data-test="`${dataTest}-${key}-cell`">
|
|
71
|
-
{{ value || value === 0 ? value : HYPHEN_SYMBOL }}
|
|
72
|
-
</div>
|
|
73
|
-
</slot>
|
|
74
|
-
</template>
|
|
43
|
+
<slot :name="`cell-${key}`" :value="value" :row="row" :index="index">
|
|
44
|
+
<div
|
|
45
|
+
v-bind="bodyCellContentAttrs"
|
|
46
|
+
ref="cellRef"
|
|
47
|
+
:class="cx([bodyCellContentAttrs.class, getCellContentClasses(row, key)])"
|
|
48
|
+
:data-test="`${dataTest}-${key}-cell`"
|
|
49
|
+
>
|
|
50
|
+
{{ value.value || value || HYPHEN_SYMBOL }}
|
|
51
|
+
</div>
|
|
52
|
+
</slot>
|
|
75
53
|
</td>
|
|
76
54
|
</tr>
|
|
77
55
|
|
|
@@ -88,7 +66,7 @@
|
|
|
88
66
|
</template>
|
|
89
67
|
|
|
90
68
|
<UTableRow
|
|
91
|
-
v-if="row.row && !row.row.isHidden && !row.nestedData"
|
|
69
|
+
v-if="isSingleNestedRow && row.row && !row.row.isHidden && !row.nestedData"
|
|
92
70
|
v-bind="$attrs"
|
|
93
71
|
v-model:selected-rows="selectedRows"
|
|
94
72
|
:attrs="attrs"
|
|
@@ -101,6 +79,25 @@
|
|
|
101
79
|
@toggle-row-visibility="onClickToggleRowChild"
|
|
102
80
|
@click="onClick"
|
|
103
81
|
/>
|
|
82
|
+
|
|
83
|
+
<template v-if="!isSingleNestedRow && row.row.length && !row.nestedData">
|
|
84
|
+
<template v-for="nestedRow in row.row" :key="nestedRow.id">
|
|
85
|
+
<UTableRow
|
|
86
|
+
v-if="!nestedRow.isHidden"
|
|
87
|
+
v-bind="$attrs"
|
|
88
|
+
v-model:selected-rows="selectedRows"
|
|
89
|
+
:attrs="attrs"
|
|
90
|
+
:columns="columns"
|
|
91
|
+
:row="nestedRow"
|
|
92
|
+
:data-test="dataTest"
|
|
93
|
+
:nested-level="nestedLevel + 1"
|
|
94
|
+
:config="config"
|
|
95
|
+
:selectable="selectable"
|
|
96
|
+
@toggle-row-visibility="onClickToggleRowChild"
|
|
97
|
+
@click="onClick"
|
|
98
|
+
/>
|
|
99
|
+
</template>
|
|
100
|
+
</template>
|
|
104
101
|
</template>
|
|
105
102
|
|
|
106
103
|
<script setup>
|
|
@@ -169,9 +166,7 @@ const cellRef = ref([]);
|
|
|
169
166
|
useMutationObserver(cellRef, setCellTitle, { childList: true });
|
|
170
167
|
|
|
171
168
|
const {
|
|
172
|
-
|
|
173
|
-
bodyCellSecondaryAttrs,
|
|
174
|
-
bodyCellSecondaryEmptyAttrs,
|
|
169
|
+
bodyCellContentAttrs,
|
|
175
170
|
bodyCellCheckboxAttrs,
|
|
176
171
|
bodyCheckboxAttrs,
|
|
177
172
|
bodyCellNestedAttrs,
|
|
@@ -187,6 +182,8 @@ const toggleIconConfig = computed(() =>
|
|
|
187
182
|
|
|
188
183
|
const shift = computed(() => (props.row.row ? 1.5 : 2));
|
|
189
184
|
|
|
185
|
+
const isSingleNestedRow = computed(() => !Array.isArray(props.row.row));
|
|
186
|
+
|
|
190
187
|
const getToggleIconName = computed(() => (row) => {
|
|
191
188
|
const isHidden = row.row?.isHidden || row.nestedData?.isHidden;
|
|
192
189
|
|
|
@@ -209,19 +206,7 @@ function getCellContentClasses(row, key) {
|
|
|
209
206
|
return typeof cellClasses === "function" ? cellClasses(row[key].value, row) : cellClasses;
|
|
210
207
|
}
|
|
211
208
|
|
|
212
|
-
function
|
|
213
|
-
return typeof value === "object" && value !== null && ("primary" in value || "value" in value);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
function getCellPrimaryContent(value) {
|
|
217
|
-
if (typeof value === "object" && value !== null) {
|
|
218
|
-
return value.primary || value.value || HYPHEN_SYMBOL;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
return value || HYPHEN_SYMBOL;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
function getCellAttrs(key, row, cellIndex) {
|
|
209
|
+
function getCellAttrs(row, cellIndex) {
|
|
225
210
|
const isNestedRow = (row.row || row.nestedData || props.nestedLevel > 0) && cellIndex === 0;
|
|
226
211
|
|
|
227
212
|
return isNestedRow ? bodyCellNestedRowAttrs.value : bodyCellBaseAttrs.value;
|
|
@@ -268,4 +253,14 @@ function setElementTitle(element) {
|
|
|
268
253
|
element.removeAttribute("title");
|
|
269
254
|
}
|
|
270
255
|
}
|
|
256
|
+
|
|
257
|
+
function onClickToggleIcon() {
|
|
258
|
+
if (isSingleNestedRow.value) {
|
|
259
|
+
onClickToggleRowChild(props.row.row.id);
|
|
260
|
+
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
props.row.row.forEach(({ id }) => onClickToggleRowChild(id));
|
|
265
|
+
}
|
|
271
266
|
</script>
|
package/ui.data-table/config.js
CHANGED
|
@@ -57,9 +57,7 @@ export default /*tw*/ {
|
|
|
57
57
|
},
|
|
58
58
|
},
|
|
59
59
|
bodyCellNestedRow: "flex",
|
|
60
|
-
|
|
61
|
-
bodyCellSecondary: "mt-1 text-xs text-gray-500 overflow-hidden text-ellipsis",
|
|
62
|
-
bodyCellSecondaryEmpty: "inline-block",
|
|
60
|
+
bodyCellContent: "text-ellipsis overflow-hidden",
|
|
63
61
|
bodyCellCheckbox: "first:px-4", // try to remove first
|
|
64
62
|
bodyCellDateDivider: "",
|
|
65
63
|
bodyCellNested: "mr-2 mt-0.5",
|
|
@@ -20,12 +20,13 @@ Keys you have/may to provide to component in row object.
|
|
|
20
20
|
|
|
21
21
|
<Markdown>
|
|
22
22
|
{`
|
|
23
|
-
| Key name | Description
|
|
24
|
-
| ------------------|
|
|
25
|
-
| id | A unique identifier for row
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
|
|
|
23
|
+
| Key name | Description | Type | Required |
|
|
24
|
+
| ------------------| ---------------------------------- | ---------------| ------------ |
|
|
25
|
+
| id | A unique identifier for row | String, Number | true |
|
|
26
|
+
| content | Content to be rendered in the cell | Any | false |
|
|
27
|
+
| isChecked | Indicates if row checked | Boolean | false |
|
|
28
|
+
| isHidden | Indicated if nested row hidden | Boolean | false |
|
|
29
|
+
| rowDate | Row date for date divider | String, Date | false |
|
|
29
30
|
`}
|
|
30
31
|
</Markdown>
|
|
31
32
|
|
|
@@ -67,33 +67,53 @@ function getNestedRow() {
|
|
|
67
67
|
key_2: "Some data",
|
|
68
68
|
key_3: "Numbers",
|
|
69
69
|
key_4: "Statistics",
|
|
70
|
-
row:
|
|
71
|
-
|
|
72
|
-
isChecked: false,
|
|
73
|
-
isHidden: true,
|
|
74
|
-
key_1: "Nesting",
|
|
75
|
-
key_2: "Nesting",
|
|
76
|
-
key_3: "Nesting",
|
|
77
|
-
key_4: "Nesting",
|
|
78
|
-
row: {
|
|
70
|
+
row: [
|
|
71
|
+
{
|
|
79
72
|
id: getRandomId(),
|
|
80
73
|
isChecked: false,
|
|
81
74
|
isHidden: true,
|
|
82
|
-
key_1: "
|
|
83
|
-
key_2: "
|
|
84
|
-
key_3: "
|
|
85
|
-
key_4: "
|
|
75
|
+
key_1: "Nesting",
|
|
76
|
+
key_2: "Nesting",
|
|
77
|
+
key_3: "Nesting",
|
|
78
|
+
key_4: "Nesting",
|
|
86
79
|
row: {
|
|
87
80
|
id: getRandomId(),
|
|
88
81
|
isChecked: false,
|
|
89
82
|
isHidden: true,
|
|
90
|
-
key_1: "
|
|
91
|
-
key_2: "
|
|
92
|
-
key_3: "
|
|
93
|
-
key_4: "
|
|
83
|
+
key_1: "Second level nesting",
|
|
84
|
+
key_2: "Second level nesting",
|
|
85
|
+
key_3: "Second level nesting",
|
|
86
|
+
key_4: "Second level nesting",
|
|
94
87
|
},
|
|
95
88
|
},
|
|
96
|
-
|
|
89
|
+
{
|
|
90
|
+
id: getRandomId(),
|
|
91
|
+
isChecked: false,
|
|
92
|
+
isHidden: true,
|
|
93
|
+
key_1: "Nesting",
|
|
94
|
+
key_2: "Nesting",
|
|
95
|
+
key_3: "Nesting",
|
|
96
|
+
key_4: "Nesting",
|
|
97
|
+
row: {
|
|
98
|
+
id: getRandomId(),
|
|
99
|
+
isChecked: false,
|
|
100
|
+
isHidden: true,
|
|
101
|
+
key_1: "Second level nesting",
|
|
102
|
+
key_2: "Second level nesting",
|
|
103
|
+
key_3: "Second level nesting",
|
|
104
|
+
key_4: "Second level nesting",
|
|
105
|
+
row: {
|
|
106
|
+
id: getRandomId(),
|
|
107
|
+
isChecked: false,
|
|
108
|
+
isHidden: true,
|
|
109
|
+
key_1: "Third level nesting",
|
|
110
|
+
key_2: "Third level nesting",
|
|
111
|
+
key_3: "Third level nesting",
|
|
112
|
+
key_4: "Third level nesting",
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
],
|
|
97
117
|
};
|
|
98
118
|
}
|
|
99
119
|
|
|
@@ -257,72 +277,6 @@ RowAndCellClasses.args = {
|
|
|
257
277
|
],
|
|
258
278
|
};
|
|
259
279
|
|
|
260
|
-
export const PrimaryAndSecondaryContent = DefaultTemplate.bind({});
|
|
261
|
-
PrimaryAndSecondaryContent.args = {
|
|
262
|
-
rows: [
|
|
263
|
-
{
|
|
264
|
-
id: getRandomId(),
|
|
265
|
-
isChecked: false,
|
|
266
|
-
key_1: {
|
|
267
|
-
primary: "Primary",
|
|
268
|
-
secondary: "Secondary",
|
|
269
|
-
},
|
|
270
|
-
key_2: {
|
|
271
|
-
primary: "Primary",
|
|
272
|
-
secondary: "Secondary",
|
|
273
|
-
},
|
|
274
|
-
key_3: {
|
|
275
|
-
primary: "Primary",
|
|
276
|
-
secondary: "Secondary",
|
|
277
|
-
},
|
|
278
|
-
key_4: {
|
|
279
|
-
primary: "Primary",
|
|
280
|
-
secondary: "Secondary",
|
|
281
|
-
},
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
id: getRandomId(),
|
|
285
|
-
isChecked: false,
|
|
286
|
-
key_1: {
|
|
287
|
-
primary: "Primary",
|
|
288
|
-
secondary: "Secondary",
|
|
289
|
-
},
|
|
290
|
-
key_2: {
|
|
291
|
-
primary: "Primary",
|
|
292
|
-
secondary: "Secondary",
|
|
293
|
-
},
|
|
294
|
-
key_3: {
|
|
295
|
-
primary: "Primary",
|
|
296
|
-
secondary: "Secondary",
|
|
297
|
-
},
|
|
298
|
-
key_4: {
|
|
299
|
-
primary: "Primary",
|
|
300
|
-
secondary: "Secondary",
|
|
301
|
-
},
|
|
302
|
-
},
|
|
303
|
-
{
|
|
304
|
-
id: getRandomId(),
|
|
305
|
-
isChecked: false,
|
|
306
|
-
key_1: {
|
|
307
|
-
primary: "Primary",
|
|
308
|
-
secondary: "Secondary",
|
|
309
|
-
},
|
|
310
|
-
key_2: {
|
|
311
|
-
primary: "Primary",
|
|
312
|
-
secondary: "Secondary",
|
|
313
|
-
},
|
|
314
|
-
key_3: {
|
|
315
|
-
primary: "Primary",
|
|
316
|
-
secondary: "Secondary",
|
|
317
|
-
},
|
|
318
|
-
key_4: {
|
|
319
|
-
primary: "Primary",
|
|
320
|
-
secondary: "Secondary",
|
|
321
|
-
},
|
|
322
|
-
},
|
|
323
|
-
],
|
|
324
|
-
};
|
|
325
|
-
|
|
326
280
|
export const Empty = EmptyTemplate.bind({});
|
|
327
281
|
Empty.args = {};
|
|
328
282
|
|
|
@@ -24,19 +24,23 @@ export function syncRowCheck(row, selectedRows) {
|
|
|
24
24
|
|
|
25
25
|
export function toggleRowVisibility(row, targetRowId) {
|
|
26
26
|
if (row.id === targetRowId) {
|
|
27
|
-
if ("isHidden"
|
|
27
|
+
if (Object.hasOwn(row, "isHidden")) {
|
|
28
28
|
row.isHidden = !row.isHidden;
|
|
29
|
-
} else if (row.nestedData && "isHidden"
|
|
29
|
+
} else if (row.nestedData && Object.hasOwn(row.nestedData, "isHidden")) {
|
|
30
30
|
row.nestedData.isHidden = !row.nestedData.isHidden;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
if (row.row) {
|
|
36
|
+
if (row.row && !Array.isArray(row.row)) {
|
|
37
37
|
toggleRowVisibility(row.row, targetRowId);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
if (row.row && Array.isArray(row.row)) {
|
|
41
|
+
row.row.forEach((nestedRow) => toggleRowVisibility(nestedRow, targetRowId));
|
|
42
|
+
}
|
|
43
|
+
|
|
40
44
|
if (row.nestedData) {
|
|
41
45
|
toggleRowVisibility(row.nestedData, targetRowId);
|
|
42
46
|
}
|
|
@@ -7,14 +7,14 @@ export default /*tw*/ {
|
|
|
7
7
|
weekDays: "grid grid-cols-7 justify-items-center gap-1",
|
|
8
8
|
weekDay: "flex size-8 items-center justify-center text-xs uppercase text-gray-500",
|
|
9
9
|
days: "grid grid-cols-7 justify-items-center gap-1",
|
|
10
|
-
dateInRange: "bg-brand/15 !text-brand-900 hover:bg-brand/30 rounded-none",
|
|
10
|
+
dateInRange: "bg-brand/15 font-semibold !text-brand-900 hover:bg-brand/30 rounded-none",
|
|
11
11
|
edgeDateInRange: "",
|
|
12
12
|
firstDateInRange: "rounded-r-none",
|
|
13
13
|
lastDateInRange: "rounded-l-none",
|
|
14
14
|
anotherMonthDate: "text-gray-400",
|
|
15
15
|
activeDate: "bg-brand-100",
|
|
16
|
-
selectedDate: "",
|
|
17
|
-
currentDate: "border-2 border-brand-600",
|
|
16
|
+
selectedDate: "font-semibold",
|
|
17
|
+
currentDate: "border-2 border-brand-600 font-semibold",
|
|
18
18
|
day: "{UButton} size-9 w-full font-normal",
|
|
19
19
|
currentDay: "",
|
|
20
20
|
dayInRange: "",
|
|
@@ -127,82 +127,43 @@
|
|
|
127
127
|
</div>
|
|
128
128
|
|
|
129
129
|
<div v-if="isDatePeriodOutOfRange" v-bind="periodDateListAttrs">
|
|
130
|
-
<template v-for="
|
|
130
|
+
<template v-for="date in periodDateList" :key="date.title">
|
|
131
131
|
<UButton
|
|
132
|
-
v-if="getDatePeriodState(date
|
|
133
|
-
no-ring
|
|
132
|
+
v-if="getDatePeriodState(date).isSelected && getDatePeriodState(date).isCurrentDate"
|
|
134
133
|
size="sm"
|
|
135
|
-
color="grayscale"
|
|
136
134
|
variant="thirdary"
|
|
137
|
-
|
|
138
|
-
v-bind="periodDateActiveAttrs"
|
|
139
|
-
:label="String(date.title)"
|
|
140
|
-
:class="{ 'rounded-dynamic': getDatePeriodState(date, index).isSingleItem }"
|
|
141
|
-
@click="selectDate(date), toggleMenu()"
|
|
142
|
-
/>
|
|
143
|
-
|
|
144
|
-
<UButton
|
|
145
|
-
v-else-if="getDatePeriodState(date, index).isFirstInRange && !isListType"
|
|
135
|
+
color="brand"
|
|
146
136
|
no-ring
|
|
147
|
-
|
|
148
|
-
color="grayscale"
|
|
149
|
-
variant="thirdary"
|
|
137
|
+
filled
|
|
150
138
|
:disabled="isDatePeriodOutOfRange(date)"
|
|
151
|
-
v-bind="
|
|
139
|
+
v-bind="periodDateCurrentSelectedAttrs"
|
|
152
140
|
:label="String(date.title)"
|
|
153
|
-
:class="{ 'rounded-dynamic': getDatePeriodState(date, index).isSingleItem }"
|
|
154
141
|
@click="selectDate(date), toggleMenu()"
|
|
155
142
|
/>
|
|
156
143
|
|
|
157
144
|
<UButton
|
|
158
|
-
v-else-if="getDatePeriodState(date
|
|
159
|
-
no-ring
|
|
145
|
+
v-else-if="getDatePeriodState(date).isSelected"
|
|
160
146
|
size="sm"
|
|
161
|
-
color="grayscale"
|
|
162
147
|
variant="thirdary"
|
|
163
|
-
|
|
164
|
-
v-bind="firstPeriodListDateAttrs"
|
|
165
|
-
:label="String(date.title)"
|
|
166
|
-
:class="{ 'rounded-dynamic': getDatePeriodState(date, index).isSingleItem }"
|
|
167
|
-
@click="selectDate(date), toggleMenu()"
|
|
168
|
-
/>
|
|
169
|
-
|
|
170
|
-
<UButton
|
|
171
|
-
v-else-if="getDatePeriodState(date, index).isLastInRange && !isListType"
|
|
148
|
+
color="brand"
|
|
172
149
|
no-ring
|
|
173
|
-
|
|
174
|
-
color="grayscale"
|
|
175
|
-
variant="thirdary"
|
|
150
|
+
filled
|
|
176
151
|
:disabled="isDatePeriodOutOfRange(date)"
|
|
177
|
-
v-bind="
|
|
152
|
+
v-bind="periodDateSelectedAttrs"
|
|
178
153
|
:label="String(date.title)"
|
|
179
|
-
:class="{ 'rounded-dynamic': getDatePeriodState(date, index).isSingleItem }"
|
|
180
154
|
@click="selectDate(date), toggleMenu()"
|
|
181
155
|
/>
|
|
182
156
|
|
|
183
157
|
<UButton
|
|
184
|
-
v-else-if="getDatePeriodState(date
|
|
185
|
-
no-ring
|
|
158
|
+
v-else-if="getDatePeriodState(date).isCurrentDate"
|
|
186
159
|
size="sm"
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
:disabled="isDatePeriodOutOfRange(date)"
|
|
190
|
-
v-bind="lastPeriodListDateAttrs"
|
|
191
|
-
:label="String(date.title)"
|
|
192
|
-
:class="{ 'rounded-dynamic': getDatePeriodState(date, index).isSingleItem }"
|
|
193
|
-
@click="selectDate(date), toggleMenu()"
|
|
194
|
-
/>
|
|
195
|
-
|
|
196
|
-
<UButton
|
|
197
|
-
v-else-if="getDatePeriodState(date, index).isInRange"
|
|
160
|
+
variant="secondary"
|
|
161
|
+
color="brand"
|
|
198
162
|
no-ring
|
|
199
|
-
|
|
200
|
-
color="grayscale"
|
|
201
|
-
variant="thirdary"
|
|
163
|
+
filled
|
|
202
164
|
:disabled="isDatePeriodOutOfRange(date)"
|
|
203
|
-
v-bind="
|
|
165
|
+
v-bind="periodDateCurrentAttrs"
|
|
204
166
|
:label="String(date.title)"
|
|
205
|
-
:class="{ 'rounded-dynamic': getDatePeriodState(date, index).isSingleItem }"
|
|
206
167
|
@click="selectDate(date), toggleMenu()"
|
|
207
168
|
/>
|
|
208
169
|
|
|
@@ -296,12 +257,9 @@ const {
|
|
|
296
257
|
rangeSwitchButtonAttrs,
|
|
297
258
|
rangeSwitchTitleAttrs,
|
|
298
259
|
periodDateListAttrs,
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
lastPeriodGridDateAttrs,
|
|
303
|
-
lastPeriodListDateAttrs,
|
|
304
|
-
periodDateInRangeAttrs,
|
|
260
|
+
periodDateSelectedAttrs,
|
|
261
|
+
periodDateCurrentSelectedAttrs,
|
|
262
|
+
periodDateCurrentAttrs,
|
|
305
263
|
periodDateAttrs,
|
|
306
264
|
} = props.attrs;
|
|
307
265
|
|
|
@@ -312,8 +270,6 @@ const periods = computed(() => [
|
|
|
312
270
|
{ name: PERIOD.year, title: props.locale.year },
|
|
313
271
|
]);
|
|
314
272
|
|
|
315
|
-
const isListType = computed(() => props.isPeriod.quarter || props.isPeriod.week);
|
|
316
|
-
|
|
317
273
|
const rangeSwitchTitle = computed(() => {
|
|
318
274
|
if (props.isPeriod.month || props.isPeriod.quarter) {
|
|
319
275
|
return String(activeDate.value.getFullYear());
|
|
@@ -387,7 +343,7 @@ function selectCustomRange() {
|
|
|
387
343
|
};
|
|
388
344
|
}
|
|
389
345
|
|
|
390
|
-
function getDatePeriodState(date
|
|
346
|
+
function getDatePeriodState(date) {
|
|
391
347
|
const localStart = new Date(localValue.value.from);
|
|
392
348
|
const localEnd = new Date(localValue.value.to);
|
|
393
349
|
|
|
@@ -399,38 +355,9 @@ function getDatePeriodState(date, index) {
|
|
|
399
355
|
localStart.setHours(0, 0, 0, 0);
|
|
400
356
|
localEnd.setHours(23, 59, 59, 999);
|
|
401
357
|
|
|
402
|
-
const
|
|
403
|
-
|
|
404
|
-
});
|
|
405
|
-
|
|
406
|
-
const endDateInRangeIndex = periodDateList.value.findIndex((periodDate) => {
|
|
407
|
-
return localEnd >= periodDate.startRange && localEnd <= periodDate.endRange;
|
|
408
|
-
});
|
|
409
|
-
|
|
410
|
-
let isInRange = index >= startDateInRangeIndex && index <= endDateInRangeIndex;
|
|
411
|
-
|
|
412
|
-
if (!~startDateInRangeIndex || !~endDateInRangeIndex) {
|
|
413
|
-
isInRange =
|
|
414
|
-
(index >= startDateInRangeIndex && startDateInRangeIndex > -1) ||
|
|
415
|
-
(index <= endDateInRangeIndex && endDateInRangeIndex > -1);
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
if (
|
|
419
|
-
!~startDateInRangeIndex &&
|
|
420
|
-
periodDateList.value.at(0).startRange > localStart &&
|
|
421
|
-
!~endDateInRangeIndex &&
|
|
422
|
-
periodDateList.value.at(0).endRange < localEnd
|
|
423
|
-
) {
|
|
424
|
-
isInRange = true;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
const isSingleItem =
|
|
428
|
-
startDateInRangeIndex === endDateInRangeIndex && ~endDateInRangeIndex && ~startDateInRangeIndex;
|
|
429
|
-
|
|
430
|
-
const isFirstInRange = startDateInRangeIndex === index;
|
|
431
|
-
const isLastInRange = endDateInRangeIndex === index;
|
|
432
|
-
const isActive = localValue.value.from === date.startRange;
|
|
358
|
+
const isSelected = localStart - date.startRange === 0 && localEnd - date.endRange === 0;
|
|
359
|
+
const isCurrentDate = date.startRange <= new Date() && new Date() <= date.endRange;
|
|
433
360
|
|
|
434
|
-
return {
|
|
361
|
+
return { isSelected, isCurrentDate };
|
|
435
362
|
}
|
|
436
363
|
</script>
|
|
@@ -60,13 +60,9 @@ export default /*tw*/ {
|
|
|
60
60
|
periodDateYearList: "grid grid-cols-3 grid-rows-1 gap-0.5",
|
|
61
61
|
periodDateQuarterList: "",
|
|
62
62
|
periodDate: "w-full",
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
lastPeriodGridDate: "rounded-l-none",
|
|
67
|
-
firstPeriodListDate: "rounded-b-none",
|
|
68
|
-
lastPeriodListDate: "rounded-t-none",
|
|
69
|
-
periodDateActive: "bg-gray-100",
|
|
63
|
+
periodDateSelected: "",
|
|
64
|
+
periodDateCurrent: "border-2 border-brand-600",
|
|
65
|
+
periodDateCurrentSelected: "",
|
|
70
66
|
customRangeDescription: "",
|
|
71
67
|
rangeInputWrapper: "flex mt-4 -space-x-px group/range-input-wrapper",
|
|
72
68
|
rangeInputFirst: {
|
|
@@ -19,12 +19,7 @@ export default function useAttrs(props, { isShownMenu, isTop, isRight, isPeriod
|
|
|
19
19
|
description: Boolean(props.description),
|
|
20
20
|
}));
|
|
21
21
|
|
|
22
|
-
const extendingKeys = [
|
|
23
|
-
"buttonWrapperActive",
|
|
24
|
-
"buttonActive",
|
|
25
|
-
"edgePeriodDate",
|
|
26
|
-
"periodDateMonthList",
|
|
27
|
-
];
|
|
22
|
+
const extendingKeys = ["buttonWrapperActive", "buttonActive", "periodDateMonthList"];
|
|
28
23
|
const extendingKeysClasses = getExtendingKeysClasses(
|
|
29
24
|
[
|
|
30
25
|
...extendingKeys,
|
|
@@ -34,6 +29,8 @@ export default function useAttrs(props, { isShownMenu, isTop, isRight, isPeriod
|
|
|
34
29
|
"periodDateWeekList",
|
|
35
30
|
"periodDateQuarterList",
|
|
36
31
|
"periodDateYearList",
|
|
32
|
+
"periodDateSelected",
|
|
33
|
+
"periodDateCurrent",
|
|
37
34
|
],
|
|
38
35
|
mutatedProps,
|
|
39
36
|
);
|
|
@@ -65,34 +62,20 @@ export default function useAttrs(props, { isShownMenu, isTop, isRight, isPeriod
|
|
|
65
62
|
periodDateYearList: {
|
|
66
63
|
base: computed(() => [extendingKeysClasses.periodDateList.value]),
|
|
67
64
|
},
|
|
68
|
-
|
|
65
|
+
periodDateSelected: {
|
|
69
66
|
base: computed(() => [extendingKeysClasses.periodDate.value]),
|
|
70
67
|
},
|
|
71
|
-
|
|
72
|
-
base: computed(() => [extendingKeysClasses.periodDate.value]),
|
|
73
|
-
},
|
|
74
|
-
firstPeriodGridDate: {
|
|
75
|
-
base: computed(() => [
|
|
76
|
-
extendingKeysClasses.periodDate.value,
|
|
77
|
-
extendingKeysClasses.edgePeriodDate.value,
|
|
78
|
-
]),
|
|
79
|
-
},
|
|
80
|
-
firstPeriodListDate: {
|
|
81
|
-
base: computed(() => [
|
|
82
|
-
extendingKeysClasses.periodDate.value,
|
|
83
|
-
extendingKeysClasses.edgePeriodDate.value,
|
|
84
|
-
]),
|
|
85
|
-
},
|
|
86
|
-
lastPeriodGridDate: {
|
|
68
|
+
periodDateCurrent: {
|
|
87
69
|
base: computed(() => [
|
|
88
70
|
extendingKeysClasses.periodDate.value,
|
|
89
|
-
extendingKeysClasses.
|
|
71
|
+
extendingKeysClasses.periodDateCurrent.value,
|
|
90
72
|
]),
|
|
91
73
|
},
|
|
92
|
-
|
|
74
|
+
periodDateCurrentSelected: {
|
|
93
75
|
base: computed(() => [
|
|
94
76
|
extendingKeysClasses.periodDate.value,
|
|
95
|
-
extendingKeysClasses.
|
|
77
|
+
extendingKeysClasses.periodDateSelected.value,
|
|
78
|
+
extendingKeysClasses.periodDateCurrent.value,
|
|
96
79
|
]),
|
|
97
80
|
},
|
|
98
81
|
});
|
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.426",
|
|
5
5
|
"contributions": {
|
|
6
6
|
"html": {
|
|
7
7
|
"description-markup": "markdown",
|
|
@@ -8498,6 +8498,9 @@
|
|
|
8498
8498
|
},
|
|
8499
8499
|
{
|
|
8500
8500
|
"name": "row"
|
|
8501
|
+
},
|
|
8502
|
+
{
|
|
8503
|
+
"name": "index"
|
|
8501
8504
|
}
|
|
8502
8505
|
]
|
|
8503
8506
|
},
|