vueless 0.0.404 → 0.0.406

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.404",
3
+ "version": "0.0.406",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
@@ -2,12 +2,23 @@
2
2
  <div v-bind="wrapperAttrs">
3
3
  <UDivider v-if="upperlined" size="xl" padding="after" v-bind="dividerAttrs" />
4
4
 
5
- <UEmpty
5
+ <!--
6
+ @slot Use it to add something instead of the drag icon.
7
+ @binding {string} empty-title
8
+ @binding {string} empty-description
9
+ -->
10
+ <slot
6
11
  v-if="!hideEmptyStateForNesting && !list?.length"
7
- :title="emptyTitle || currentLocale.emptyTitle"
8
- :description="emptyDescription || currentLocale.emptyDescription"
9
- v-bind="emptyAttrs"
10
- />
12
+ name="empty"
13
+ :empty-title="emptyTitle"
14
+ :empty-description="emptyDescription"
15
+ >
16
+ <UEmpty
17
+ :title="emptyTitle || currentLocale.emptyTitle"
18
+ :description="emptyDescription || currentLocale.emptyDescription"
19
+ v-bind="emptyAttrs"
20
+ />
21
+ </slot>
11
22
 
12
23
  <draggable
13
24
  v-else
@@ -27,6 +38,7 @@
27
38
  <div :data-test="`${dataTest}-item-${element[valueKey]}`" v-bind="itemAttrs">
28
39
  <!--
29
40
  @slot Use it to add something instead of the drag icon.
41
+ @binding {string} icon-name
30
42
  @binding {string} icon-size
31
43
  -->
32
44
  <slot name="drag" :icon-name="config.defaults.dragIcon" :icon-size="iconSize">
@@ -43,6 +55,7 @@
43
55
  <!--
44
56
  @slot Use it to modify label.
45
57
  @binding {object} item
58
+ @binding {boolean} active
46
59
  -->
47
60
  <slot name="label" :item="element" :active="isActive(element)">
48
61
  {{ element[labelKey] }}
@@ -63,6 +76,7 @@
63
76
 
64
77
  <!--
65
78
  @slot Use it to add something instead of the delete icon.
79
+ @binding {string} icon-name
66
80
  @binding {string} icon-size
67
81
  -->
68
82
  <slot name="delete" :icon-name="config.defaults.deleteIcon" :icon-size="iconSize">
@@ -82,6 +96,7 @@
82
96
 
83
97
  <!--
84
98
  @slot Use it to add something instead of the edit icon.
99
+ @binding {string} icon-name
85
100
  @binding {string} icon-size
86
101
  -->
87
102
  <slot name="edit" :icon-name="config.defaults.editIcon" :icon-size="iconSize">
@@ -114,6 +129,11 @@
114
129
  @drag-sort="onDragEnd"
115
130
  >
116
131
  <template #label="{ item, active }">
132
+ <!--
133
+ @slot Use it to modify label.
134
+ @binding {object} item
135
+ @binding {boolean} active
136
+ -->
117
137
  <slot name="label" :item="item" :active="active">
118
138
  <div v-bind="active ? labelCrossedAttrs : labelAttrs" v-text="item[labelKey]" />
119
139
  </slot>
@@ -152,7 +172,7 @@ defineOptions({ inheritAttrs: false });
152
172
 
153
173
  const props = defineProps({
154
174
  /**
155
- * Data list array.
175
+ * Data item options.
156
176
  */
157
177
  list: {
158
178
  type: Array,
@@ -217,7 +237,7 @@ const props = defineProps({
217
237
  },
218
238
 
219
239
  /**
220
- * Enables nesting.
240
+ * Enable nesting.
221
241
  */
222
242
  nesting: {
223
243
  type: Boolean,
@@ -190,7 +190,8 @@
190
190
  :columns="columns"
191
191
  :config="config"
192
192
  :attrs="keysAttrs"
193
- v-bind="isRowSelected(row) ? bodyRowCheckedAttrs : bodyRowAttrs"
193
+ v-bind="getRowAttrs(row.id)"
194
+ :class="cx([getRowAttrs(row.id).class, row.class])"
194
195
  @click="onClickRow"
195
196
  @toggle-row-visibility="onToggleRowVisibility"
196
197
  >
@@ -598,8 +599,8 @@ function shouldDisplayDateSeparator(rowIndex) {
598
599
  return (isPreviousRowChecked && isCheckedRowAfter) || isFirstRowAndNextChecked;
599
600
  }
600
601
 
601
- function isRowSelected(row) {
602
- return Boolean(selectedRows.value.includes(row.id));
602
+ function getRowAttrs(rowId) {
603
+ return selectedRows.value.includes(rowId) ? bodyRowCheckedAttrs : bodyRowAttrs;
603
604
  }
604
605
 
605
606
  function setFooterCellWidth(width) {
@@ -15,7 +15,7 @@
15
15
  v-for="(value, key, index) in getFilteredRow(row, columns)"
16
16
  :key="index"
17
17
  v-bind="getCellAttrs(key, row, index)"
18
- :class="cx([getCellAttrs(key, row, index).class, columns[index].tdClass])"
18
+ :class="cx([getCellAttrs(key, row, index).class, columns[index].tdClass, row[key]?.class])"
19
19
  >
20
20
  <div
21
21
  v-if="(row.row || nestedLevel || row.nestedData) && index === 0"
@@ -34,10 +34,10 @@
34
34
  />
35
35
  </div>
36
36
 
37
- <div v-if="value?.hasOwnProperty('secondary')">
37
+ <div v-if="isCellObject(value)">
38
38
  <slot :name="`cell-${key}`" :value="value" :row="row">
39
39
  <div v-bind="bodyCellPrimaryAttrs" ref="cellRef" :data-test="`${dataTest}-${key}-cell`">
40
- {{ value.primary || HYPHEN_SYMBOL }}
40
+ {{ getCellPrimaryContent(value) }}
41
41
  </div>
42
42
 
43
43
  <div v-bind="bodyCellSecondaryAttrs">
@@ -188,6 +188,18 @@ onMounted(() => {
188
188
  cellRef.value.forEach(setElementTitle);
189
189
  });
190
190
 
191
+ function isCellObject(value) {
192
+ return typeof value === "object" && value !== null && ("primary" in value || "value" in value);
193
+ }
194
+
195
+ function getCellPrimaryContent(value) {
196
+ if (typeof value === "object" && value !== null) {
197
+ return value.primary || value.value || HYPHEN_SYMBOL;
198
+ }
199
+
200
+ return value || HYPHEN_SYMBOL;
201
+ }
202
+
191
203
  function getCellAttrs(key, row, cellIndex) {
192
204
  const isNestedRow = (row.row || row.nestedData || props.nestedLevel > 0) && cellIndex === 0;
193
205
 
@@ -51,82 +51,34 @@ function getNestedRow() {
51
51
  return {
52
52
  id: getRandomId(),
53
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
- },
54
+ key_1: "Click to expand",
55
+ key_2: "Some data",
56
+ key_3: "Numbers",
57
+ key_4: "Statistics",
70
58
  row: {
71
59
  id: getRandomId(),
72
60
  isChecked: false,
73
61
  isHidden: true,
74
- key_1: {
75
- primary: "Nesting",
76
- secondary: "secondary",
77
- },
78
- key_2: {
79
- primary: "Nesting",
80
- secondary: "secondary",
81
- },
82
- key_3: {
83
- primary: "Nesting",
84
- secondary: "secondary",
85
- },
86
- key_4: {
87
- primary: "Nesting",
88
- secondary: "secondary",
89
- },
62
+ key_1: "Nesting",
63
+ key_2: "Nesting",
64
+ key_3: "Nesting",
65
+ key_4: "Nesting",
90
66
  row: {
91
67
  id: getRandomId(),
92
68
  isChecked: false,
93
69
  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
- },
70
+ key_1: "Second level nesting",
71
+ key_2: "Second level nesting",
72
+ key_3: "Second level nesting",
73
+ key_4: "Second level nesting",
110
74
  row: {
111
75
  id: getRandomId(),
112
76
  isChecked: false,
113
77
  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
- },
78
+ key_1: "Third level nesting",
79
+ key_2: "Third level nesting",
80
+ key_3: "Third level nesting",
81
+ key_4: "Third level nesting",
130
82
  },
131
83
  },
132
84
  },
@@ -137,22 +89,10 @@ function getRow() {
137
89
  return {
138
90
  id: getRandomId(),
139
91
  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
- },
92
+ key_1: "Info",
93
+ key_2: "Statistics",
94
+ key_3: "Reports",
95
+ key_4: "Discounts",
156
96
  };
157
97
  }
158
98
 
@@ -166,7 +106,7 @@ const DefaultTemplate = (args) => ({
166
106
  template: `
167
107
  <UTable
168
108
  v-bind="args"
169
- :rows="itemsData"
109
+ :rows="args.rows || itemsData"
170
110
  >
171
111
  ${args.slotTemplate || getSlotsFragment()}
172
112
  </UTable>
@@ -218,18 +158,9 @@ NestedContent.args = {
218
158
  return {
219
159
  id: getRandomId(),
220
160
  isChecked: false,
221
- key_1: {
222
- primary: "Row with nested content",
223
- secondary: "Click to expand",
224
- },
225
- key_2: {
226
- primary: "Primary content",
227
- secondary: "Secondary content",
228
- },
229
- key_3: {
230
- primary: "More info",
231
- secondary: "Details below",
232
- },
161
+ key_1: "Row with nested content",
162
+ key_2: "Basic data",
163
+ key_3: "More info",
233
164
  nestedData: {
234
165
  isChecked: false,
235
166
  isHidden: true,
@@ -259,18 +190,9 @@ NestedContent.args = {
259
190
  return {
260
191
  id: getRandomId(),
261
192
  isChecked: false,
262
- key_1: {
263
- primary: `Regular row ${index}`,
264
- secondary: "No nested content",
265
- },
266
- key_2: {
267
- primary: "Standard info",
268
- secondary: "Nothing special",
269
- },
270
- key_3: {
271
- primary: "Basic data",
272
- secondary: "No details",
273
- },
193
+ key_1: `Regular row ${index}`,
194
+ key_2: "Standard info",
195
+ key_3: "Basic data",
274
196
  };
275
197
  }
276
198
  },
@@ -292,6 +214,103 @@ NestedContent.args = {
292
214
  `,
293
215
  };
294
216
 
217
+ export const RowAndCellClasses = DefaultTemplate.bind({});
218
+ RowAndCellClasses.args = {
219
+ rows: [
220
+ {
221
+ id: getRandomId(),
222
+ isChecked: false,
223
+ key_1: "Info",
224
+ key_2: "Statistics",
225
+ key_3: { value: "Reports", class: "bg-red-200" },
226
+ key_4: "Discounts",
227
+ },
228
+ {
229
+ id: getRandomId(),
230
+ isChecked: false,
231
+ class: "bg-green-100",
232
+ key_1: "Data",
233
+ key_2: "Meetings",
234
+ key_3: "Calendar",
235
+ key_4: "Departments",
236
+ },
237
+ {
238
+ id: getRandomId(),
239
+ isChecked: false,
240
+ key_1: "Events",
241
+ key_2: "Sales",
242
+ key_3: "Renovation",
243
+ key_4: "Calendar",
244
+ },
245
+ ],
246
+ };
247
+
248
+ export const PrimaryAndSecondaryContent = DefaultTemplate.bind({});
249
+ PrimaryAndSecondaryContent.args = {
250
+ rows: [
251
+ {
252
+ id: getRandomId(),
253
+ isChecked: false,
254
+ key_1: {
255
+ primary: "Primary",
256
+ secondary: "Secondary",
257
+ },
258
+ key_2: {
259
+ primary: "Primary",
260
+ secondary: "Secondary",
261
+ },
262
+ key_3: {
263
+ primary: "Primary",
264
+ secondary: "Secondary",
265
+ },
266
+ key_4: {
267
+ primary: "Primary",
268
+ secondary: "Secondary",
269
+ },
270
+ },
271
+ {
272
+ id: getRandomId(),
273
+ isChecked: false,
274
+ key_1: {
275
+ primary: "Primary",
276
+ secondary: "Secondary",
277
+ },
278
+ key_2: {
279
+ primary: "Primary",
280
+ secondary: "Secondary",
281
+ },
282
+ key_3: {
283
+ primary: "Primary",
284
+ secondary: "Secondary",
285
+ },
286
+ key_4: {
287
+ primary: "Primary",
288
+ secondary: "Secondary",
289
+ },
290
+ },
291
+ {
292
+ id: getRandomId(),
293
+ isChecked: false,
294
+ key_1: {
295
+ primary: "Primary",
296
+ secondary: "Secondary",
297
+ },
298
+ key_2: {
299
+ primary: "Primary",
300
+ secondary: "Secondary",
301
+ },
302
+ key_3: {
303
+ primary: "Primary",
304
+ secondary: "Secondary",
305
+ },
306
+ key_4: {
307
+ primary: "Primary",
308
+ secondary: "Secondary",
309
+ },
310
+ },
311
+ ],
312
+ };
313
+
295
314
  export const Empty = EmptyTemplate.bind({});
296
315
  Empty.args = {};
297
316
 
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.404",
4
+ "version": "0.0.406",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
@@ -2054,7 +2054,7 @@
2054
2054
  "attributes": [
2055
2055
  {
2056
2056
  "name": "list",
2057
- "description": "Data list array.",
2057
+ "description": "Data item options.",
2058
2058
  "value": {
2059
2059
  "kind": "expression",
2060
2060
  "type": "array"
@@ -2126,7 +2126,7 @@
2126
2126
  },
2127
2127
  {
2128
2128
  "name": "nesting",
2129
- "description": "Enables nesting.",
2129
+ "description": "Enable nesting.",
2130
2130
  "value": {
2131
2131
  "kind": "expression",
2132
2132
  "type": "boolean"
@@ -2221,12 +2221,28 @@
2221
2221
  }
2222
2222
  ],
2223
2223
  "slots": [
2224
+ {
2225
+ "name": "empty",
2226
+ "scoped": true,
2227
+ "description": "Use it to add something instead of the drag icon.",
2228
+ "bindings": [
2229
+ {
2230
+ "type": "string",
2231
+ "name": "empty-title"
2232
+ },
2233
+ {
2234
+ "type": "string",
2235
+ "name": "empty-description"
2236
+ }
2237
+ ]
2238
+ },
2224
2239
  {
2225
2240
  "name": "drag",
2226
2241
  "scoped": true,
2227
2242
  "description": "Use it to add something instead of the drag icon.",
2228
2243
  "bindings": [
2229
2244
  {
2245
+ "type": "string",
2230
2246
  "name": "icon-name"
2231
2247
  },
2232
2248
  {
@@ -2241,9 +2257,11 @@
2241
2257
  "description": "Use it to modify label.",
2242
2258
  "bindings": [
2243
2259
  {
2260
+ "type": "object",
2244
2261
  "name": "item"
2245
2262
  },
2246
2263
  {
2264
+ "type": "boolean",
2247
2265
  "name": "active"
2248
2266
  }
2249
2267
  ]
@@ -2265,6 +2283,7 @@
2265
2283
  "description": "Use it to add something instead of the delete icon.",
2266
2284
  "bindings": [
2267
2285
  {
2286
+ "type": "string",
2268
2287
  "name": "icon-name"
2269
2288
  },
2270
2289
  {
@@ -2279,6 +2298,7 @@
2279
2298
  "description": "Use it to add something instead of the edit icon.",
2280
2299
  "bindings": [
2281
2300
  {
2301
+ "type": "string",
2282
2302
  "name": "icon-name"
2283
2303
  },
2284
2304
  {