vueless 0.0.175 → 0.0.177

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.
Files changed (32) hide show
  1. package/package.json +2 -2
  2. package/ui.data-table/components/TableRow.vue +170 -0
  3. package/ui.data-table/composables/attrs.composable.js +30 -11
  4. package/ui.data-table/configs/default.config.js +27 -8
  5. package/ui.data-table/index.stories.js +106 -16
  6. package/ui.data-table/index.vue +49 -166
  7. package/ui.data-table/services/table.service.js +49 -9
  8. package/ui.dropdown-list/configs/default.config.js +2 -2
  9. package/ui.form-checkbox/configs/default.config.js +3 -2
  10. package/ui.form-checkbox/index.vue +3 -1
  11. package/ui.form-input/configs/default.config.js +3 -3
  12. package/ui.form-label/configs/default.config.js +31 -25
  13. package/ui.form-label/index.vue +3 -13
  14. package/ui.form-radio/configs/default.config.js +3 -0
  15. package/ui.form-radio/index.vue +1 -1
  16. package/ui.form-select/configs/default.config.js +8 -8
  17. package/ui.form-select/index.vue +13 -3
  18. package/ui.form-textarea/configs/default.config.js +10 -13
  19. package/ui.loader-rendering/Docs.mdx +2 -1
  20. package/ui.loader-rendering/index.stories.js +20 -15
  21. package/ui.loader-top/Docs.mdx +40 -8
  22. package/ui.loader-top/composables/useLoaderTop.js +10 -23
  23. package/ui.loader-top/index.stories.js +28 -23
  24. package/ui.loader-top/index.vue +21 -21
  25. package/web-types.json +100 -134
  26. package/ui.form-radio-card/Docs.mdx +0 -16
  27. package/ui.form-radio-card/composables/attrs.composable.js +0 -37
  28. package/ui.form-radio-card/configs/default.config.js +0 -31
  29. package/ui.form-radio-card/constants/index.js +0 -5
  30. package/ui.form-radio-card/index.stories.js +0 -152
  31. package/ui.form-radio-card/index.vue +0 -142
  32. package/ui.form-radio-card/services/variant.service.js +0 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.175",
3
+ "version": "0.0.177",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -37,7 +37,7 @@
37
37
  "@release-it/bumper": "^6.0.1",
38
38
  "@vitejs/plugin-vue": "^5.0.5",
39
39
  "@vue/eslint-config-prettier": "^9.0.0",
40
- "@vueless/plugin-vite": "^0.0.32",
40
+ "@vueless/plugin-vite": "^0.0.34",
41
41
  "@vueless/storybook": "^0.0.32",
42
42
  "@vueless/web-types": "^0.0.12",
43
43
  "autoprefixer": "^10.4.19",
@@ -0,0 +1,170 @@
1
+ <template>
2
+ <tr v-bind="$attrs" @click="onClick(props.row)">
3
+ <td
4
+ v-if="selectable"
5
+ :style="getNestedCheckboxShift()"
6
+ v-bind="attrs.bodyCellAttrs(config.bodyCellCheckbox)"
7
+ >
8
+ <UCheckbox
9
+ v-model="selectedRows"
10
+ :data-id="row.id"
11
+ :value="row.id"
12
+ size="sm"
13
+ :data-cy="`${dataCy}-body-checkbox`"
14
+ v-bind="attrs.bodyCheckboxAttrs"
15
+ @click.stop
16
+ />
17
+ </td>
18
+
19
+ <td
20
+ v-for="(value, key, index) in getFilteredRow(row, columns)"
21
+ :key="index"
22
+ v-bind="attrs.bodyCellAttrs(getCellClasses(key, row, index))"
23
+ >
24
+ <div
25
+ v-if="(row.row || nestedLevel) && index === 0"
26
+ :style="getNestedShift()"
27
+ v-bind="attrs.bodyCellNestedAttrs"
28
+ >
29
+ <UIcon
30
+ v-if="row.row"
31
+ size="xs"
32
+ internal
33
+ interactive
34
+ :name="
35
+ row?.row?.isHidden
36
+ ? config.bodyCellNestedExpandIconName
37
+ : config.bodyCellNestedCollapseIconName
38
+ "
39
+ color="brand"
40
+ v-bind="toggleIconConfig"
41
+ @click="onClickToggleRowChild(row.row.id)"
42
+ />
43
+ </div>
44
+
45
+ <div v-if="value?.hasOwnProperty('secondary')">
46
+ <slot :name="`cell-${key}`" :value="value" :row="row">
47
+ <div :data-cy="`${dataCy}-${key}-cell`">
48
+ {{ value.primary || HYPHEN_SYMBOL }}
49
+ </div>
50
+
51
+ <div v-bind="attrs.bodyCellSecondaryAttrs">
52
+ <template v-if="Array.isArray(value.secondary)">
53
+ <div v-for="(secondary, idx) in value.secondary" :key="idx">
54
+ <span v-bind="attrs.bodyCellSecondaryEmptyAttrs">
55
+ {{ secondary }}
56
+ </span>
57
+ </div>
58
+ </template>
59
+
60
+ <template v-else>
61
+ {{ value.secondary }}
62
+ </template>
63
+ </div>
64
+ </slot>
65
+ </div>
66
+
67
+ <template v-else>
68
+ <slot :name="`cell-${key}`" :value="value" :row="row">
69
+ <div :data-cy="`${dataCy}-${key}-cell`">
70
+ {{ value || HYPHEN_SYMBOL }}
71
+ </div>
72
+ </slot>
73
+ </template>
74
+ </td>
75
+ </tr>
76
+
77
+ <TableRow
78
+ v-if="row.row && !row.row.isHidden"
79
+ v-bind="$attrs"
80
+ v-model:selected-rows="selectedRows"
81
+ :attrs="attrs"
82
+ :columns="columns"
83
+ :row="row.row"
84
+ :data-cy="dataCy"
85
+ :nested-level="nestedLevel + 1"
86
+ :config="config"
87
+ :selectable="selectable"
88
+ @toggle-row-visibility="onClickToggleRowChild"
89
+ @click="onClick"
90
+ />
91
+ </template>
92
+
93
+ <script setup>
94
+ import { computed } from "vue";
95
+
96
+ import { HYPHEN_SYMBOL } from "../../service.ui";
97
+ import { getFilteredRow } from "../services/table.service.js";
98
+
99
+ import UIcon from "../../ui.image-icon";
100
+ import UCheckbox from "../../ui.form-checkbox";
101
+
102
+ const props = defineProps({
103
+ row: {
104
+ type: Object,
105
+ required: true,
106
+ },
107
+ columns: {
108
+ type: Array,
109
+ required: true,
110
+ },
111
+ tag: {
112
+ type: String,
113
+ default: "tr",
114
+ },
115
+ selectable: {
116
+ type: Boolean,
117
+ default: false,
118
+ },
119
+ nestedLevel: {
120
+ type: Number,
121
+ default: 0,
122
+ },
123
+ dataCy: {
124
+ type: String,
125
+ required: true,
126
+ },
127
+ attrs: {
128
+ type: Object,
129
+ required: true,
130
+ },
131
+ config: {
132
+ type: Object,
133
+ required: true,
134
+ },
135
+ });
136
+
137
+ const emit = defineEmits(["toggleRowVisibility", "click"]);
138
+
139
+ const selectedRows = defineModel("selectedRows", { type: Array, default: () => [] });
140
+
141
+ const toggleIconConfig = computed(() =>
142
+ props.row?.row?.isHidden
143
+ ? props.attrs.bodyCellNestedExpandIconAttrs
144
+ : props.attrs.bodyCellNestedCollapseIconAttrs,
145
+ );
146
+
147
+ const shift = computed(() => (props.row.row ? 1.5 : 2));
148
+
149
+ function getCellClasses(key, row, cellIndex) {
150
+ const isNestedRow = (row.row || props.nestedLevel) && cellIndex === 0;
151
+
152
+ return [props.columns.find((column) => column.key === key)?.tdClass, isNestedRow && "flex"];
153
+ }
154
+
155
+ function getNestedShift() {
156
+ return { marginLeft: `${props.nestedLevel * shift.value}rem` };
157
+ }
158
+
159
+ function getNestedCheckboxShift() {
160
+ return { transform: `translateX(${props.nestedLevel * shift.value}rem)` };
161
+ }
162
+
163
+ function onClickToggleRowChild(rowId) {
164
+ emit("toggleRowVisibility", rowId);
165
+ }
166
+
167
+ function onClick(row) {
168
+ emit("click", row);
169
+ }
170
+ </script>
@@ -5,10 +5,18 @@ import { computed } from "vue";
5
5
 
6
6
  export function useAttrs(
7
7
  props,
8
- { tableRows, isNesting, isShownActionsHeader, isHeaderSticky, isFooterSticky },
8
+ { tableRows, isShownActionsHeader, isHeaderSticky, isFooterSticky },
9
9
  ) {
10
10
  const { config, getAttrs, hasSlotContent } = useUI(defaultConfig, () => props.config);
11
- const { stickyHeaderCell, headerCell, footerRow, bodyCell, headerCellGeneral } = config.value;
11
+ const {
12
+ stickyHeaderCell,
13
+ headerCell,
14
+ footerRow,
15
+ bodyCell,
16
+ headerCellGeneral,
17
+ stickyHeaderCounter,
18
+ headerCounter,
19
+ } = config.value;
12
20
 
13
21
  const cvaHeaderCellGeneral = cva({
14
22
  base: headerCellGeneral.base,
@@ -40,19 +48,37 @@ export function useAttrs(
40
48
  compoundVariants: bodyCell.compoundVariants,
41
49
  });
42
50
 
51
+ const cvaStickyHeaderCounter = cva({
52
+ base: stickyHeaderCounter.base,
53
+ variants: stickyHeaderCounter.variants,
54
+ compoundVariants: stickyHeaderCounter.compoundVariants,
55
+ });
56
+
57
+ const cvaHeaderCounter = cva({
58
+ base: headerCounter.base,
59
+ variants: headerCounter.variants,
60
+ compoundVariants: headerCounter.compoundVariants,
61
+ });
62
+
43
63
  const stickyHeaderCellClasses = computed(() => cvaCustomHeaderItem({ compact: props.compact }));
44
64
  const headerCellClasses = computed(() => cvaHeaderCell({ compact: props.compact }));
45
65
  const footerRowClasses = computed(() => cvaFooterRow({ compact: props.compact }));
46
66
  const bodyCellClasses = computed(() => cvaBodyCell({ compact: props.compact }));
47
67
  const headerCellGeneralClasses = computed(() => cvaHeaderCellGeneral({ compact: props.compact }));
68
+ const headerCounterClasses = computed(() => cvaHeaderCounter({ compact: props.compact }));
69
+ const stickyHeaderCounterClasses = computed(() =>
70
+ cvaStickyHeaderCounter({ compact: props.compact }),
71
+ );
48
72
 
49
73
  const wrapperAttrs = getAttrs("wrapper");
50
74
  const stickyHeaderAttrsRaw = getAttrs("stickyHeader");
51
75
  const stickyHeaderCellAttrsRaw = getAttrs("stickyHeaderCell", {
52
76
  classes: stickyHeaderCellClasses,
53
77
  });
54
- const headerCounterAttrsRaw = getAttrs("headerCounter");
55
- const stickyHeaderCounterAttrsRaw = getAttrs("stickyHeaderCounter");
78
+ const headerCounterAttrsRaw = getAttrs("headerCounter", { classes: headerCounterClasses });
79
+ const stickyHeaderCounterAttrsRaw = getAttrs("stickyHeaderCounter", {
80
+ classes: stickyHeaderCounterClasses,
81
+ });
56
82
  const stickyHeaderActionsCounterAttrsRaw = getAttrs("stickyHeaderActionsCounter");
57
83
  const stickyHeaderCheckboxAttrs = getAttrs("stickyHeaderCheckbox", {
58
84
  isComponent: true,
@@ -88,7 +114,6 @@ export function useAttrs(
88
114
  const bodyRowBeforeCellAttrsRaw = getAttrs("bodyRowBeforeCell");
89
115
  const bodyRowAfterAttrs = getAttrs("bodyRowAfter");
90
116
  const bodyRowAfterCellAttrsRaw = getAttrs("bodyRowAfterCell");
91
- const bodyCellNestedWrapperAttrsRaw = getAttrs("bodyCellNestedWrapper");
92
117
 
93
118
  const bodyRowAttrsRaw = getAttrs("bodyRow");
94
119
 
@@ -195,11 +220,6 @@ export function useAttrs(
195
220
  return getAttrs("bodyRowDateSeparator", { classes: activeClass }).value;
196
221
  };
197
222
 
198
- const bodyCellNestedWrapperAttrs = computed(() => (index) => ({
199
- ...bodyCellNestedWrapperAttrsRaw.value,
200
- class: index === 0 && isNesting.value ? config.value.bodyCellNestedWrapper : "",
201
- }));
202
-
203
223
  return {
204
224
  config,
205
225
  wrapperAttrs,
@@ -215,7 +235,6 @@ export function useAttrs(
215
235
  bodyRowBeforeAttrs,
216
236
  bodyRowBeforeCellAttrs,
217
237
  bodyRowDateSeparatorAttrs,
218
- bodyCellNestedWrapperAttrs,
219
238
  bodyCellAttrs,
220
239
  stickyHeaderCounterAttrs,
221
240
  stickyHeaderActionsCounterAttrs,
@@ -13,7 +13,14 @@ export default /*tw*/ {
13
13
  stickyHeaderRow: "border-gray-200 bg-white",
14
14
  stickyHeaderCell: "flex-none whitespace-nowrap",
15
15
  stickyHeaderCheckbox: "",
16
- stickyHeaderCounter: "absolute top-4 left-11 bg-gradient-to-r from-white from-80%",
16
+ stickyHeaderCounter: {
17
+ base: "absolute top-5 left-11 bg-gradient-to-r from-white from-80%",
18
+ variants: {
19
+ compact: {
20
+ true: "top-3",
21
+ },
22
+ },
23
+ },
17
24
  stickyHeaderLoader: "",
18
25
  stickyHeaderActions: "absolute rounded-t-lg border-blue-200 bg-blue-50",
19
26
  stickyHeaderActionsCheckbox: "",
@@ -25,7 +32,14 @@ export default /*tw*/ {
25
32
  headerCell: "",
26
33
  headerCellCheckbox: "w-10",
27
34
  headerCheckbox: "",
28
- headerCounter: "absolute top-4 left-11 bg-gradient-to-r from-white from-80% mt-px ml-px",
35
+ headerCounter: {
36
+ base: "absolute top-5 mt-px left-11 bg-gradient-to-r from-white from-80% ml-px",
37
+ variants: {
38
+ compact: {
39
+ true: "top-3",
40
+ },
41
+ },
42
+ },
29
43
  headerLoader: "absolute !top-auto",
30
44
  body: "group/body divide-none",
31
45
  bodyRow: "hover:bg-gray-50",
@@ -36,10 +50,10 @@ export default /*tw*/ {
36
50
  bodyRowAfterCell: "py-1",
37
51
  bodyRowDateSeparator: "",
38
52
  bodyCell: {
39
- base: "p-[1.125rem] py-5 first:p-5 truncate align-top last:p-5",
53
+ base: "p-[1.125rem] py-5 first:!p-5 truncate align-top last:p-5",
40
54
  variants: {
41
55
  compact: {
42
- true: "px-4 py-3 last:px-4 last:py-3 first:px-4 first:py-3",
56
+ true: "px-4 py-3 last:px-4 last:py-3 first:!px-3.5 first:py-3",
43
57
  },
44
58
  },
45
59
  },
@@ -47,11 +61,16 @@ export default /*tw*/ {
47
61
  bodyCellSecondaryEmpty: "inline-block",
48
62
  bodyCellCheckbox: "first:px-4", // try to remove first
49
63
  bodyCellDateSeparator: "",
50
- bodyCellNestedWrapper: "flex items-center",
51
- bodyCellNested: "flex relative -top-px",
52
- bodyCellNestedExpandIcon: "mr-2 rounded-sm bg-gray-200",
64
+ bodyCellNested: "mr-2 mt-0.5",
65
+ bodyCellNestedExpandIcon: {
66
+ wrapper: "rounded-sm",
67
+ container: "bg-gray-200",
68
+ },
53
69
  bodyCellNestedExpandIconName: "add",
54
- bodyCellNestedCollapseIcon: "mr-2 rounded-sm bg-gray-200",
70
+ bodyCellNestedCollapseIcon: {
71
+ wrapper: "rounded-sm",
72
+ container: "bg-gray-200",
73
+ },
55
74
  bodyCellNestedCollapseIconName: "remove",
56
75
  bodyCheckbox: "",
57
76
  bodyDateSeparator: "",
@@ -42,29 +42,119 @@ export default {
42
42
  { key: "key_3", label: "title 3" },
43
43
  { key: "key_4", label: "title 4" },
44
44
  ],
45
+ row: getRow,
46
+ numberOfRows: 5,
47
+ },
48
+ };
49
+
50
+ function getNestedRow() {
51
+ return {
52
+ id: getRandomId(),
53
+ isChecked: false,
54
+ key_1: {
55
+ primary: "primary",
56
+ secondary: "secondary",
57
+ },
58
+ key_2: {
59
+ primary: "primary",
60
+ secondary: "secondary",
61
+ },
62
+ key_3: {
63
+ primary: "primary",
64
+ secondary: "secondary",
65
+ },
66
+ key_4: {
67
+ primary: "primary",
68
+ secondary: "secondary",
69
+ },
45
70
  row: {
46
- id: 1,
71
+ id: getRandomId(),
47
72
  isChecked: false,
73
+ isHidden: true,
48
74
  key_1: {
49
- primary: "primary",
75
+ primary: "Nesting",
50
76
  secondary: "secondary",
51
77
  },
52
78
  key_2: {
53
- primary: "primary",
79
+ primary: "Nesting",
54
80
  secondary: "secondary",
55
81
  },
56
82
  key_3: {
57
- primary: "primary",
83
+ primary: "Nesting",
58
84
  secondary: "secondary",
59
85
  },
60
86
  key_4: {
61
- primary: "primary",
87
+ primary: "Nesting",
62
88
  secondary: "secondary",
63
89
  },
90
+ row: {
91
+ id: getRandomId(),
92
+ isChecked: false,
93
+ isHidden: true,
94
+ key_1: {
95
+ primary: "Two level nesting",
96
+ secondary: "secondary",
97
+ },
98
+ key_2: {
99
+ primary: "Two level nesting",
100
+ secondary: "secondary",
101
+ },
102
+ key_3: {
103
+ primary: "Two level nesting",
104
+ secondary: "secondary",
105
+ },
106
+ key_4: {
107
+ primary: "Two level nesting",
108
+ secondary: "secondary",
109
+ },
110
+ row: {
111
+ id: getRandomId(),
112
+ isChecked: false,
113
+ isHidden: true,
114
+ key_1: {
115
+ primary: "Three level nesting",
116
+ secondary: "secondary",
117
+ },
118
+ key_2: {
119
+ primary: "Three level nesting",
120
+ secondary: "secondary",
121
+ },
122
+ key_3: {
123
+ primary: "Three level nesting",
124
+ secondary: "secondary",
125
+ },
126
+ key_4: {
127
+ primary: "Three level nesting",
128
+ secondary: "secondary",
129
+ },
130
+ },
131
+ },
64
132
  },
65
- numberOfRows: 5,
66
- },
67
- };
133
+ };
134
+ }
135
+
136
+ function getRow() {
137
+ return {
138
+ id: getRandomId(),
139
+ isChecked: false,
140
+ key_1: {
141
+ primary: "primary",
142
+ secondary: "secondary",
143
+ },
144
+ key_2: {
145
+ primary: "primary",
146
+ secondary: "secondary",
147
+ },
148
+ key_3: {
149
+ primary: "primary",
150
+ secondary: "secondary",
151
+ },
152
+ key_4: {
153
+ primary: "primary",
154
+ secondary: "secondary",
155
+ },
156
+ };
157
+ }
68
158
 
69
159
  const DefaultTemplate = (args) => ({
70
160
  components: { UTable },
@@ -85,10 +175,7 @@ const DefaultTemplate = (args) => ({
85
175
  let rows = [];
86
176
 
87
177
  for (let i = 0; i < args.numberOfRows; i++) {
88
- const newRow = { ...args.row };
89
-
90
- newRow.id = getRandomId();
91
- rows.push(newRow);
178
+ rows.push(args.row());
92
179
  }
93
180
 
94
181
  return rows;
@@ -126,10 +213,7 @@ const SlotTemplate = (args) => ({
126
213
  let rows = [];
127
214
 
128
215
  for (let i = 0; i < args.numberOfRows; i++) {
129
- const newRow = { ...args.row };
130
-
131
- newRow.id = getRandomId();
132
- rows.push(newRow);
216
+ rows.push(args.row());
133
217
  }
134
218
 
135
219
  return rows;
@@ -140,6 +224,12 @@ const SlotTemplate = (args) => ({
140
224
  export const Default = DefaultTemplate.bind({});
141
225
  Default.args = {};
142
226
 
227
+ export const Nesting = DefaultTemplate.bind({});
228
+ Nesting.args = {
229
+ row: getNestedRow,
230
+ selectable: true,
231
+ };
232
+
143
233
  export const Empty = EmptyTemplate.bind({});
144
234
  Empty.args = {};
145
235