vueless 1.2.15-beta.3 → 1.2.15-beta.5

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 (58) hide show
  1. package/locales/en.json +1 -1
  2. package/package.json +1 -1
  3. package/ui.container-accordion-item/UAccordionItem.vue +1 -5
  4. package/ui.container-accordion-item/tests/UAccordionItem.test.ts +5 -5
  5. package/ui.data-list/config.ts +1 -1
  6. package/ui.data-list/storybook/stories.ts +24 -24
  7. package/ui.data-list/tests/UDataList.test.ts +7 -7
  8. package/ui.data-table/config.ts +2 -0
  9. package/ui.data-table/storybook/stories.ts +3 -1
  10. package/ui.dropdown-badge/config.ts +1 -1
  11. package/ui.dropdown-badge/storybook/stories.ts +3 -3
  12. package/ui.dropdown-badge/tests/UDropdownBadge.test.ts +5 -5
  13. package/ui.dropdown-button/config.ts +1 -1
  14. package/ui.dropdown-button/storybook/stories.ts +7 -7
  15. package/ui.dropdown-button/tests/UDropdownButton.test.ts +5 -5
  16. package/ui.dropdown-link/config.ts +1 -1
  17. package/ui.dropdown-link/storybook/stories.ts +3 -3
  18. package/ui.dropdown-link/tests/UDropdownLink.test.ts +5 -5
  19. package/ui.form-calendar/UCalendar.vue +4 -0
  20. package/ui.form-calendar/config.ts +5 -0
  21. package/ui.form-checkbox/UCheckbox.vue +23 -4
  22. package/ui.form-checkbox/config.ts +4 -0
  23. package/ui.form-checkbox/tests/UCheckbox.test.ts +1 -1
  24. package/ui.form-checkbox-group/UCheckboxGroup.vue +2 -2
  25. package/ui.form-checkbox-group/config.ts +2 -0
  26. package/ui.form-checkbox-group/storybook/stories.ts +46 -9
  27. package/ui.form-checkbox-group/tests/UCheckboxGroup.test.ts +65 -0
  28. package/ui.form-checkbox-group/types.ts +10 -0
  29. package/ui.form-date-picker/config.ts +5 -0
  30. package/ui.form-input/UInput.vue +9 -3
  31. package/ui.form-input-counter/UInputCounter.vue +9 -0
  32. package/ui.form-input-counter/config.ts +5 -0
  33. package/ui.form-input-password/UInputPassword.vue +11 -12
  34. package/ui.form-input-password/tests/UInputPassword.test.ts +2 -2
  35. package/ui.form-label/ULabel.vue +5 -1
  36. package/ui.form-label/types.ts +5 -0
  37. package/ui.form-listbox/UListbox.vue +37 -11
  38. package/ui.form-listbox/config.ts +1 -1
  39. package/ui.form-listbox/storybook/stories.ts +25 -25
  40. package/ui.form-listbox/tests/UListbox.test.ts +6 -6
  41. package/ui.form-radio-group/URadioGroup.vue +2 -2
  42. package/ui.form-radio-group/config.ts +2 -0
  43. package/ui.form-radio-group/storybook/stories.ts +48 -8
  44. package/ui.form-radio-group/tests/URadioGroup.test.ts +68 -0
  45. package/ui.form-radio-group/types.ts +18 -4
  46. package/ui.form-select/USelect.vue +37 -2
  47. package/ui.form-select/config.ts +1 -1
  48. package/ui.form-select/tests/USelect.test.ts +6 -4
  49. package/ui.form-switch/USwitch.vue +20 -7
  50. package/ui.form-switch/config.ts +2 -0
  51. package/ui.form-switch/tests/USwitch.test.ts +6 -4
  52. package/ui.form-textarea/UTextarea.vue +15 -5
  53. package/ui.form-textarea/tests/UTextarea.test.ts +1 -1
  54. package/ui.navigation-pagination/UPagination.vue +14 -0
  55. package/ui.navigation-pagination/config.ts +9 -0
  56. package/ui.text-alert/UAlert.vue +8 -0
  57. package/ui.text-alert/config.ts +4 -0
  58. package/icons/storybook/notifications.svg +0 -1
package/locales/en.json CHANGED
@@ -1 +1 @@
1
- {"USelect":{"listIsEmpty":"List is empty.","noDataToShow":"No data to show.","clear":"clear","addMore":"Add more..."},"USwitch":{"inactive":"Off","active":"On"},"UInputFile":{"sizeError":"File size is too big.","formatError":"Format is not supported.","noFile":"No file selected","uploadFile":"Choose file"},"UListbox":{"noDataToShow":"No data to show.","add":"Add","search":"Search..."},"UModalConfirm":{"confirm":"Confirm","cancel":"Cancel"},"UTable":{"noData":"There is no data in the table."},"UCalendar":{"today":"Today","yesterday":"Yesterday","tomorrow":"Tomorrow","weekdays":{"shorthand":{"sunday":"Sun","monday":"Mon","tuesday":"Tue","wednesday":"Wed","thursday":"Thu","friday":"Fri","saturday":"Sat"},"longhand":{"sunday":"Sunday","monday":"Monday","tuesday":"Tuesday","wednesday":"Wednesday","thursday":"Thursday","friday":"Friday","saturday":"Saturday"},"userFormat":{"sunday":"Sunday","monday":"Monday","tuesday":"Tuesday","wednesday":"Wednesday","thursday":"Thursday","friday":"Friday","saturday":"Saturday"}},"months":{"shorthand":{"january":"Jan","february":"Feb","march":"Mar","april":"Apr","may":"May","june":"Jun","july":"Jul","august":"Aug","september":"Sep","october":"Oct","november":"Nov","december":"Dec"},"longhand":{"january":"January","february":"February","march":"March","april":"April","may":"May","june":"June","july":"July","august":"August","september":"September","october":"October","november":"November","december":"December"},"userFormat":{"january":"January","february":"February","march":"March","april":"April","may":"May","june":"June","july":"July","august":"August","september":"September","october":"October","november":"November","december":"December"}},"timeLabel":"Time","okLabel":"Ok"},"UDatePicker":{"today":"Today","yesterday":"Yesterday","tomorrow":"Tomorrow","weekdays":{"shorthand":{"sunday":"Sun","monday":"Mon","tuesday":"Tue","wednesday":"Wed","thursday":"Thu","friday":"Fri","saturday":"Sat"},"longhand":{"sunday":"Sunday","monday":"Monday","tuesday":"Tuesday","wednesday":"Wednesday","thursday":"Thursday","friday":"Friday","saturday":"Saturday"},"userFormat":{"sunday":"Sunday","monday":"Monday","tuesday":"Tuesday","wednesday":"Wednesday","thursday":"Thursday","friday":"Friday","saturday":"Saturday"}},"months":{"shorthand":{"january":"Jan","february":"Feb","march":"Mar","april":"Apr","may":"May","june":"Jun","july":"Jul","august":"Aug","september":"Sep","october":"Oct","november":"Nov","december":"Dec"},"longhand":{"january":"January","february":"February","march":"March","april":"April","may":"May","june":"June","july":"July","august":"August","september":"September","october":"October","november":"November","december":"December"},"userFormat":{"january":"January","february":"February","march":"March","april":"April","may":"May","june":"June","july":"July","august":"August","september":"September","october":"October","november":"November","december":"December"}},"timeLabel":"Time","okLabel":"Ok"},"UDatePickerRange":{"ownRange":"Own range","week":"Week","month":"Month","quarter":"Quarter","year":"Year","dateFormatWithDot":"The date should be in format 'dd.mm.yyyy'.","notCorrectMonthNumber":"Wrong month number.","notCorrectDayNumber":"Wrong day in month.","fromDateGraterThanSecond":"The 'from' date should be less than the 'to' date.","toDateSmallerThanFirst":"The 'to' date should be greater than the 'from' date.","today":"Today","yesterday":"Yesterday","tomorrow":"Tomorrow","weekdays":{"shorthand":{"sunday":"Sun","monday":"Mon","tuesday":"Tue","wednesday":"Wed","thursday":"Thu","friday":"Fri","saturday":"Sat"},"longhand":{"sunday":"Sunday","monday":"Monday","tuesday":"Tuesday","wednesday":"Wednesday","thursday":"Thursday","friday":"Friday","saturday":"Saturday"},"userFormat":{"sunday":"Sunday","monday":"Monday","tuesday":"Tuesday","wednesday":"Wednesday","thursday":"Thursday","friday":"Friday","saturday":"Saturday"}},"months":{"shorthand":{"january":"Jan","february":"Feb","march":"Mar","april":"Apr","may":"May","june":"Jun","july":"Jul","august":"Aug","september":"Sep","october":"Oct","november":"Nov","december":"Dec"},"longhand":{"january":"January","february":"February","march":"March","april":"April","may":"May","june":"June","july":"July","august":"August","september":"September","october":"October","november":"November","december":"December"},"userFormat":{"january":"January","february":"February","march":"March","april":"April","may":"May","june":"June","july":"July","august":"August","september":"September","october":"October","november":"November","december":"December"}}},"UDataList":{"emptyTitle":"","emptyDescription":"There is no data in the list."},"UNotify":{"success":{"default":"Operation successful."},"warning":{"default":"Operation warning."},"error":{"default":"Operation error."}}}
1
+ {"USelect":{"listIsEmpty":"List is empty.","noDataToShow":"No data to show.","clear":"clear","addMore":"Add more..."},"USwitch":{"switch":"Switch","inactive":"Off","active":"On"},"UInputFile":{"sizeError":"File size is too big.","formatError":"Format is not supported.","noFile":"No file selected","uploadFile":"Choose file"},"UListbox":{"noDataToShow":"No data to show.","add":"Add","search":"Search..."},"UModalConfirm":{"confirm":"Confirm","cancel":"Cancel"},"UTable":{"noData":"There is no data in the table.","checkbox":"Checkbox"},"UCalendar":{"today":"Today","yesterday":"Yesterday","tomorrow":"Tomorrow","weekdays":{"shorthand":{"sunday":"Sun","monday":"Mon","tuesday":"Tue","wednesday":"Wed","thursday":"Thu","friday":"Fri","saturday":"Sat"},"longhand":{"sunday":"Sunday","monday":"Monday","tuesday":"Tuesday","wednesday":"Wednesday","thursday":"Thursday","friday":"Friday","saturday":"Saturday"},"userFormat":{"sunday":"Sunday","monday":"Monday","tuesday":"Tuesday","wednesday":"Wednesday","thursday":"Thursday","friday":"Friday","saturday":"Saturday"}},"months":{"shorthand":{"january":"Jan","february":"Feb","march":"Mar","april":"Apr","may":"May","june":"Jun","july":"Jul","august":"Aug","september":"Sep","october":"Oct","november":"Nov","december":"Dec"},"longhand":{"january":"January","february":"February","march":"March","april":"April","may":"May","june":"June","july":"July","august":"August","september":"September","october":"October","november":"November","december":"December"},"userFormat":{"january":"January","february":"February","march":"March","april":"April","may":"May","june":"June","july":"July","august":"August","september":"September","october":"October","november":"November","december":"December"}},"timeLabel":"Time","okLabel":"Ok","previousYear":"Previous Year","nextYear":"Next Year","previousMonth":"Previous Month","nextMonth":"Next Month"},"UDatePicker":{"today":"Today","yesterday":"Yesterday","tomorrow":"Tomorrow","weekdays":{"shorthand":{"sunday":"Sun","monday":"Mon","tuesday":"Tue","wednesday":"Wed","thursday":"Thu","friday":"Fri","saturday":"Sat"},"longhand":{"sunday":"Sunday","monday":"Monday","tuesday":"Tuesday","wednesday":"Wednesday","thursday":"Thursday","friday":"Friday","saturday":"Saturday"},"userFormat":{"sunday":"Sunday","monday":"Monday","tuesday":"Tuesday","wednesday":"Wednesday","thursday":"Thursday","friday":"Friday","saturday":"Saturday"}},"months":{"shorthand":{"january":"Jan","february":"Feb","march":"Mar","april":"Apr","may":"May","june":"Jun","july":"Jul","august":"Aug","september":"Sep","october":"Oct","november":"Nov","december":"Dec"},"longhand":{"january":"January","february":"February","march":"March","april":"April","may":"May","june":"June","july":"July","august":"August","september":"September","october":"October","november":"November","december":"December"},"userFormat":{"january":"January","february":"February","march":"March","april":"April","may":"May","june":"June","july":"July","august":"August","september":"September","october":"October","november":"November","december":"December"}},"timeLabel":"Time","okLabel":"Ok","previousYear":"Previous Year","nextYear":"Next Year","previousMonth":"Previous Month","nextMonth":"Next Month"},"UDatePickerRange":{"ownRange":"Own range","week":"Week","month":"Month","quarter":"Quarter","year":"Year","dateFormatWithDot":"The date should be in format 'dd.mm.yyyy'.","notCorrectMonthNumber":"Wrong month number.","notCorrectDayNumber":"Wrong day in month.","fromDateGraterThanSecond":"The 'from' date should be less than the 'to' date.","toDateSmallerThanFirst":"The 'to' date should be greater than the 'from' date.","today":"Today","yesterday":"Yesterday","tomorrow":"Tomorrow","weekdays":{"shorthand":{"sunday":"Sun","monday":"Mon","tuesday":"Tue","wednesday":"Wed","thursday":"Thu","friday":"Fri","saturday":"Sat"},"longhand":{"sunday":"Sunday","monday":"Monday","tuesday":"Tuesday","wednesday":"Wednesday","thursday":"Thursday","friday":"Friday","saturday":"Saturday"},"userFormat":{"sunday":"Sunday","monday":"Monday","tuesday":"Tuesday","wednesday":"Wednesday","thursday":"Thursday","friday":"Friday","saturday":"Saturday"}},"months":{"shorthand":{"january":"Jan","february":"Feb","march":"Mar","april":"Apr","may":"May","june":"Jun","july":"Jul","august":"Aug","september":"Sep","october":"Oct","november":"Nov","december":"Dec"},"longhand":{"january":"January","february":"February","march":"March","april":"April","may":"May","june":"June","july":"July","august":"August","september":"September","october":"October","november":"November","december":"December"},"userFormat":{"january":"January","february":"February","march":"March","april":"April","may":"May","june":"June","july":"July","august":"August","september":"September","october":"October","november":"November","december":"December"}}},"UDataList":{"emptyTitle":"","emptyDescription":"There is no data in the list."},"UNotify":{"success":{"default":"Operation successful."},"warning":{"default":"Operation warning."},"error":{"default":"Operation error."}}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "1.2.15-beta.3",
3
+ "version": "1.2.15-beta.5",
4
4
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
5
5
  "author": "Johnny Grid <hello@vueless.com> (https://vueless.com)",
6
6
  "homepage": "https://vueless.com",
@@ -145,11 +145,7 @@ const {
145
145
  </slot>
146
146
  </div>
147
147
 
148
- <div
149
- v-if="description || hasSlotContent(slots['description'])"
150
- :id="`description-${elementId}`"
151
- v-bind="descriptionAttrs"
152
- >
148
+ <div v-if="description || hasSlotContent(slots['description'])" v-bind="descriptionAttrs">
153
149
  <!--
154
150
  @slot Use it to add custom description content.
155
151
  @binding {string} description
@@ -91,7 +91,7 @@ describe("UAccordionItem", () => {
91
91
  },
92
92
  });
93
93
 
94
- expect(component.find(`[id="description-${id}"]`).exists()).toBe(true);
94
+ expect(component.find(`[vl-key='description']`).exists()).toBe(true);
95
95
  });
96
96
 
97
97
  // DataTest prop
@@ -381,13 +381,13 @@ describe("UAccordionItem", () => {
381
381
  },
382
382
  });
383
383
 
384
- expect(component.find("[id^='description-']").classes()).not.toContain("opacity-100");
384
+ expect(component.find("[vl-key='description']").classes()).not.toContain("opacity-100");
385
385
 
386
386
  await component.find(`.${slotClass}`).trigger("click");
387
- expect(component.find("[id^='description-']").classes()).toContain("opacity-100");
387
+ expect(component.find("[vl-key='description']").classes()).toContain("opacity-100");
388
388
 
389
389
  await component.find(`.${slotClass}`).trigger("click");
390
- expect(component.find("[id^='description-']").classes()).not.toContain("opacity-100");
390
+ expect(component.find("[vl-key='description']").classes()).not.toContain("opacity-100");
391
391
  });
392
392
 
393
393
  it("description slot content is always visible when slot is provided", () => {
@@ -461,7 +461,7 @@ describe("UAccordionItem", () => {
461
461
  },
462
462
  });
463
463
 
464
- const descriptionElement = component.find("[id^='description-']");
464
+ const descriptionElement = component.find("[vl-key='description']");
465
465
 
466
466
  // Initially not opened
467
467
  expect(descriptionElement.classes()).not.toContain(openedClass);
@@ -53,7 +53,7 @@ export default /*tw*/ {
53
53
  defaults: {
54
54
  size: "md",
55
55
  labelKey: "label",
56
- valueKey: "id",
56
+ valueKey: "value",
57
57
  animationDuration: 200,
58
58
  /* icons */
59
59
  dragIcon: "drag_indicator",
@@ -30,9 +30,9 @@ export default {
30
30
  component: UDataList,
31
31
  args: {
32
32
  list: [
33
- { label: "Expenses", id: 1 },
34
- { label: "Revenue Streams", id: 2 },
35
- { label: "Departments", id: 3 },
33
+ { label: "Expenses", value: 1 },
34
+ { label: "Revenue Streams", value: 2 },
35
+ { label: "Departments", value: 3 },
36
36
  ],
37
37
  },
38
38
  argTypes: {
@@ -87,29 +87,29 @@ Nesting.args = {
87
87
  list: [
88
88
  {
89
89
  label: "Expenses",
90
- id: 1,
90
+ value: 1,
91
91
  children: [
92
- { label: "Office Supplies", id: 1.1 },
93
- { label: "Travel & Lodging", id: 1.2 },
94
- { label: "Utilities", id: 1.3 },
92
+ { label: "Office Supplies", value: 1.1 },
93
+ { label: "Travel & Lodging", value: 1.2 },
94
+ { label: "Utilities", value: 1.3 },
95
95
  ],
96
96
  },
97
97
  {
98
98
  label: "Revenue Streams",
99
- id: 2,
99
+ value: 2,
100
100
  children: [
101
- { label: "Product Sales", id: 2.1 },
102
- { label: "Subscription Services", id: 2.2 },
103
- { label: "Consulting", id: 2.3 },
101
+ { label: "Product Sales", value: 2.1 },
102
+ { label: "Subscription Services", value: 2.2 },
103
+ { label: "Consulting", value: 2.3 },
104
104
  ],
105
105
  },
106
106
  {
107
107
  label: "Departments",
108
- id: 3,
108
+ value: 3,
109
109
  children: [
110
- { label: "Engineering", id: 3.1 },
111
- { label: "Marketing", id: 3.2 },
112
- { label: "Finance", id: 3.3 },
110
+ { label: "Engineering", value: 3.1 },
111
+ { label: "Marketing", value: 3.2 },
112
+ { label: "Finance", value: 3.3 },
113
113
  ],
114
114
  },
115
115
  ],
@@ -159,17 +159,17 @@ DragSlot.args = {
159
159
  list: [
160
160
  {
161
161
  label: "John Doe (Engineering)",
162
- id: 1,
162
+ value: 1,
163
163
  avatar: "https://cdn-icons-png.flaticon.com/128/1999/1999625.png",
164
164
  },
165
165
  {
166
166
  label: "Michael Johnson (Finance)",
167
- id: 2,
167
+ value: 2,
168
168
  avatar: "https://cdn-icons-png.flaticon.com/128/4140/4140057.png",
169
169
  },
170
170
  {
171
171
  label: "Emma Smith (Marketing)",
172
- id: 3,
172
+ value: 3,
173
173
  avatar: "https://cdn-icons-png.flaticon.com/128/4140/4140047.png",
174
174
  },
175
175
  ],
@@ -183,18 +183,18 @@ DragSlot.args = {
183
183
  export const ActionsSlot = DefaultTemplate.bind({});
184
184
  ActionsSlot.args = {
185
185
  list: [
186
- { label: "Expenses", id: 1 },
186
+ { label: "Expenses", value: 1 },
187
187
  {
188
188
  label: "Revenue Streams",
189
- id: 2,
189
+ value: 2,
190
190
  actions: false,
191
191
  children: [
192
- { label: "Product Sales", id: 2.1 },
193
- { label: "Subscription Services", id: 2.2 },
194
- { label: "Consulting", id: 2.3, actions: false },
192
+ { label: "Product Sales", value: 2.1 },
193
+ { label: "Subscription Services", value: 2.2 },
194
+ { label: "Consulting", value: 2.3, actions: false },
195
195
  ],
196
196
  },
197
- { label: "Departments", id: 3, crossed: true },
197
+ { label: "Departments", value: 3, crossed: true },
198
198
  ],
199
199
  slotTemplate: `
200
200
  <template #actions="{ item }">
@@ -10,21 +10,21 @@ import type { Props, DataListItem } from "../types";
10
10
 
11
11
  describe("UDataList.vue", () => {
12
12
  const defaultList: DataListItem[] = [
13
- { id: 1, label: "Item 1" },
14
- { id: 2, label: "Item 2", crossed: true },
15
- { id: 3, label: "Item 3", actions: false },
13
+ { value: 1, label: "Item 1" },
14
+ { value: 2, label: "Item 2", crossed: true },
15
+ { value: 3, label: "Item 3", actions: false },
16
16
  ];
17
17
 
18
18
  const nestedList: DataListItem[] = [
19
19
  {
20
- id: 1,
20
+ value: 1,
21
21
  label: "Parent 1",
22
22
  children: [
23
- { id: 11, label: "Child 1.1" },
24
- { id: 12, label: "Child 1.2" },
23
+ { value: 11, label: "Child 1.1" },
24
+ { value: 12, label: "Child 1.2" },
25
25
  ],
26
26
  },
27
- { id: 2, label: "Parent 2" },
27
+ { value: 2, label: "Parent 2" },
28
28
  ];
29
29
 
30
30
  describe("Props", () => {
@@ -105,6 +105,8 @@ export default /*tw*/ {
105
105
  `,
106
106
  i18n: {
107
107
  noData: "There is no data in the table.",
108
+ /* These are used for a11y. */
109
+ checkbox: "Checkbox",
108
110
  },
109
111
  defaults: {
110
112
  emptyCellLabel: "—",
@@ -7,6 +7,8 @@ import {
7
7
  } from "../../utils/storybook";
8
8
  import { getRandomId } from "../../utils/helper";
9
9
 
10
+ import defaultConfig from "../config";
11
+
10
12
  import UTable from "../UTable.vue";
11
13
  import UButton from "../../ui.button/UButton.vue";
12
14
  import ULink from "../../ui.button-link/ULink.vue";
@@ -731,7 +733,7 @@ export const EmptyStateSlot = DefaultTemplate.bind({});
731
733
  EmptyStateSlot.args = {
732
734
  rows: [],
733
735
  config: {
734
- i18n: { noData: "Fetching data..." },
736
+ i18n: { ...defaultConfig.i18n, noData: "Fetching data..." },
735
737
  bodyEmptyStateCell: "py-10",
736
738
  },
737
739
  slotTemplate: `
@@ -37,7 +37,7 @@ export default /*tw*/ {
37
37
  size: "md",
38
38
  variant: "solid",
39
39
  labelKey: "label",
40
- valueKey: "id",
40
+ valueKey: "value",
41
41
  groupLabelKey: "label",
42
42
  yPosition: "bottom",
43
43
  xPosition: "left",
@@ -41,9 +41,9 @@ export default {
41
41
  args: {
42
42
  label: "Order Status",
43
43
  options: [
44
- { label: "Pending", id: "pending" },
45
- { label: "Delivered", id: "delivered" },
46
- { label: "Cancelled", id: "cancelled" },
44
+ { label: "Pending", value: "pending" },
45
+ { label: "Delivered", value: "delivered" },
46
+ { label: "Cancelled", value: "cancelled" },
47
47
  ],
48
48
  },
49
49
  argTypes: {
@@ -10,9 +10,9 @@ import type { Props } from "../types";
10
10
 
11
11
  describe("UDropdownBadge.vue", () => {
12
12
  const defaultOptions = [
13
- { id: 1, label: "Option 1" },
14
- { id: 2, label: "Option 2" },
15
- { id: 3, label: "Option 3" },
13
+ { value: 1, label: "Option 1" },
14
+ { value: 2, label: "Option 2" },
15
+ { value: 3, label: "Option 3" },
16
16
  ];
17
17
 
18
18
  // Props tests
@@ -43,7 +43,7 @@ describe("UDropdownBadge.vue", () => {
43
43
  });
44
44
 
45
45
  // Find the selected option's label
46
- const selectedOption = defaultOptions.find((option) => option.id === modelValue);
46
+ const selectedOption = defaultOptions.find((option) => option.value === modelValue);
47
47
 
48
48
  expect(component.findComponent(UBadge).props("label")).toBe(selectedOption?.label);
49
49
  });
@@ -61,7 +61,7 @@ describe("UDropdownBadge.vue", () => {
61
61
  });
62
62
 
63
63
  // Find the selected options' labels
64
- const selectedOptions = defaultOptions.filter((option) => modelValue.includes(option.id));
64
+ const selectedOptions = defaultOptions.filter((option) => modelValue.includes(option.value));
65
65
  const expectedLabel = selectedOptions.map((option) => option.label).join(", ");
66
66
 
67
67
  expect(component.findComponent(UBadge).props("label")).toBe(expectedLabel);
@@ -50,7 +50,7 @@ export default /*tw*/ {
50
50
  size: "md",
51
51
  variant: "solid",
52
52
  labelKey: "label",
53
- valueKey: "id",
53
+ valueKey: "value",
54
54
  groupLabelKey: "label",
55
55
  yPosition: "bottom",
56
56
  xPosition: "left",
@@ -41,9 +41,9 @@ export default {
41
41
  args: {
42
42
  label: "Actions",
43
43
  options: [
44
- { label: "Edit", id: "edit" },
45
- { label: "Copy", id: "copy" },
46
- { label: "Remove", id: "delete" },
44
+ { label: "Edit", value: "edit" },
45
+ { label: "Copy", value: "copy" },
46
+ { label: "Remove", value: "delete" },
47
47
  ],
48
48
  },
49
49
  argTypes: {
@@ -365,7 +365,7 @@ export const OptionSlots: StoryFn<DefaultUDropdownButtonArgs> = (args) => ({
365
365
  :options="[
366
366
  {
367
367
  label: 'John Doe',
368
- id: '1',
368
+ value: '1',
369
369
  role: 'Developer',
370
370
  avatar: johnDoe,
371
371
  status: 'online',
@@ -373,7 +373,7 @@ export const OptionSlots: StoryFn<DefaultUDropdownButtonArgs> = (args) => ({
373
373
  },
374
374
  {
375
375
  label: 'Jane Smith',
376
- id: '2',
376
+ value: '2',
377
377
  role: 'Designer',
378
378
  avatar: emilyDavis,
379
379
  status: 'away',
@@ -381,7 +381,7 @@ export const OptionSlots: StoryFn<DefaultUDropdownButtonArgs> = (args) => ({
381
381
  },
382
382
  {
383
383
  label: 'Mike Johnson',
384
- id: '3',
384
+ value: '3',
385
385
  role: 'Product Manager',
386
386
  avatar: alexJohnson,
387
387
  status: 'offline',
@@ -389,7 +389,7 @@ export const OptionSlots: StoryFn<DefaultUDropdownButtonArgs> = (args) => ({
389
389
  },
390
390
  {
391
391
  label: 'Sarah Wilson',
392
- id: '4',
392
+ value: '4',
393
393
  role: 'QA Engineer',
394
394
  avatar: patMorgan,
395
395
  status: 'online',
@@ -10,9 +10,9 @@ import type { Props } from "../types";
10
10
 
11
11
  describe("UDropdownButton.vue", () => {
12
12
  const defaultOptions = [
13
- { id: 1, label: "Option 1" },
14
- { id: 2, label: "Option 2" },
15
- { id: 3, label: "Option 3" },
13
+ { value: 1, label: "Option 1" },
14
+ { value: 2, label: "Option 2" },
15
+ { value: 3, label: "Option 3" },
16
16
  ];
17
17
 
18
18
  // Props tests
@@ -43,7 +43,7 @@ describe("UDropdownButton.vue", () => {
43
43
  });
44
44
 
45
45
  // Find the selected option's label
46
- const selectedOption = defaultOptions.find((option) => option.id === modelValue);
46
+ const selectedOption = defaultOptions.find((option) => option.value === modelValue);
47
47
 
48
48
  expect(component.findComponent(UButton).props("label")).toBe(selectedOption?.label);
49
49
  });
@@ -61,7 +61,7 @@ describe("UDropdownButton.vue", () => {
61
61
  });
62
62
 
63
63
  // Find the selected options' labels
64
- const selectedOptions = defaultOptions.filter((option) => modelValue.includes(option.id));
64
+ const selectedOptions = defaultOptions.filter((option) => modelValue.includes(option.value));
65
65
  const expectedLabel = selectedOptions.map((option) => option.label).join(", ");
66
66
 
67
67
  expect(component.findComponent(UButton).props("label")).toBe(expectedLabel);
@@ -32,7 +32,7 @@ export default /*tw*/ {
32
32
  color: "primary",
33
33
  size: "md",
34
34
  labelKey: "label",
35
- valueKey: "id",
35
+ valueKey: "value",
36
36
  groupLabelKey: "label",
37
37
  yPosition: "bottom",
38
38
  xPosition: "left",
@@ -40,9 +40,9 @@ export default {
40
40
  args: {
41
41
  label: "Account",
42
42
  options: [
43
- { label: "Profile", id: "profile" },
44
- { label: "Settings", id: "settings" },
45
- { label: "Logout", id: "logout" },
43
+ { label: "Profile", value: "profile" },
44
+ { label: "Settings", value: "settings" },
45
+ { label: "Logout", value: "logout" },
46
46
  ],
47
47
  },
48
48
  argTypes: {
@@ -10,9 +10,9 @@ import type { Props } from "../types";
10
10
 
11
11
  describe("UDropdownLink.vue", () => {
12
12
  const defaultOptions = [
13
- { id: 1, label: "Option 1" },
14
- { id: 2, label: "Option 2" },
15
- { id: 3, label: "Option 3" },
13
+ { value: 1, label: "Option 1" },
14
+ { value: 2, label: "Option 2" },
15
+ { value: 3, label: "Option 3" },
16
16
  ];
17
17
 
18
18
  // Props tests
@@ -43,7 +43,7 @@ describe("UDropdownLink.vue", () => {
43
43
  });
44
44
 
45
45
  // Find the selected option's label
46
- const selectedOption = defaultOptions.find((option) => option.id === modelValue);
46
+ const selectedOption = defaultOptions.find((option) => option.value === modelValue);
47
47
 
48
48
  expect(component.findComponent(ULink).props("label")).toBe(selectedOption?.label);
49
49
  });
@@ -61,7 +61,7 @@ describe("UDropdownLink.vue", () => {
61
61
  });
62
62
 
63
63
  // Find the selected options' labels
64
- const selectedOptions = defaultOptions.filter((option) => modelValue.includes(option.id));
64
+ const selectedOptions = defaultOptions.filter((option) => modelValue.includes(option.value));
65
65
  const expectedLabel = selectedOptions.map((option) => option.label).join(", ");
66
66
 
67
67
  expect(component.findComponent(ULink).props("label")).toBe(expectedLabel);
@@ -829,6 +829,7 @@ const {
829
829
  color="grayscale"
830
830
  variant="ghost"
831
831
  :icon="config.defaults.prevYearIcon"
832
+ :aria-label="localeMessages.previousYear"
832
833
  v-bind="nextPrevButtonAttrs"
833
834
  :data-test="getDataTest('prev-year')"
834
835
  @mousedown.prevent.capture
@@ -841,6 +842,7 @@ const {
841
842
  color="grayscale"
842
843
  variant="ghost"
843
844
  :icon="config.defaults.prevIcon"
845
+ :aria-label="localeMessages.previousMonth"
844
846
  v-bind="nextPrevButtonAttrs"
845
847
  :data-test="getDataTest('prev')"
846
848
  @mousedown.prevent.capture
@@ -866,6 +868,7 @@ const {
866
868
  color="grayscale"
867
869
  variant="ghost"
868
870
  :icon="config.defaults.nextIcon"
871
+ :aria-label="localeMessages.nextMonth"
869
872
  v-bind="nextPrevButtonAttrs"
870
873
  :data-test="getDataTest('next')"
871
874
  @mousedown.prevent.capture
@@ -879,6 +882,7 @@ const {
879
882
  color="grayscale"
880
883
  variant="ghost"
881
884
  :icon="config.defaults.nextYearIcon"
885
+ :aria-label="localeMessages.nextYear"
882
886
  v-bind="nextPrevButtonAttrs"
883
887
  :data-test="getDataTest('next-year')"
884
888
  @mousedown.prevent.capture
@@ -144,6 +144,11 @@ export default /*tw*/ {
144
144
  },
145
145
  timeLabel: "Time",
146
146
  okLabel: "Ok",
147
+ /* These are used for a11y. */
148
+ previousYear: "Previous Year",
149
+ nextYear: "Next Year",
150
+ previousMonth: "Previous Month",
151
+ nextMonth: "Next Month",
147
152
  },
148
153
  defaults: {
149
154
  userDateFormat: "j F, Y",
@@ -1,9 +1,10 @@
1
1
  <script setup lang="ts">
2
- import { inject, ref, onMounted, computed, watchEffect, toValue, useId } from "vue";
2
+ import { inject, ref, onMounted, computed, watchEffect, toValue, useId, useSlots } from "vue";
3
3
  import { isEqual } from "lodash-es";
4
4
 
5
5
  import { useUI } from "../composables/useUI";
6
6
  import { getDefaults } from "../utils/ui";
7
+ import { useComponentLocaleMessages } from "../composables/useComponentLocaleMassages";
7
8
 
8
9
  import UIcon from "../ui.image-icon/UIcon.vue";
9
10
  import ULabel from "../ui.form-label/ULabel.vue";
@@ -48,12 +49,24 @@ const emit = defineEmits([
48
49
  "input",
49
50
  ]);
50
51
 
52
+ const { localeMessages } = useComponentLocaleMessages<typeof defaultConfig.i18n>(
53
+ COMPONENT_NAME,
54
+ defaultConfig.i18n,
55
+ props?.config?.i18n,
56
+ );
57
+
58
+ const slots = useSlots();
59
+
51
60
  const checkboxName = ref("");
52
61
  const checkboxSize = ref(props.size);
53
62
  const checkboxColor = ref(props.color);
54
63
 
55
64
  const elementId = props.id || useId();
56
65
 
66
+ const hasLabel = computed(() => Boolean(props.label || slots.label));
67
+
68
+ const inputAriaLabelledBy = computed(() => (hasLabel.value ? elementId : undefined));
69
+
57
70
  const isBinary = computed(() => !Array.isArray(props.modelValue));
58
71
  const isCheckboxInGroup = computed(() => Boolean(toValue(getCheckboxGroupName)));
59
72
 
@@ -108,6 +121,10 @@ function onChange() {
108
121
  emit("input", newModelValue);
109
122
  }
110
123
 
124
+ function onIconClick() {
125
+ document.getElementById(elementId)?.click();
126
+ }
127
+
111
128
  /**
112
129
  * Get element / nested component attributes for each config token ✨
113
130
  * Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
@@ -161,15 +178,17 @@ const {
161
178
  :name="checkboxName"
162
179
  :checked="isChecked"
163
180
  :disabled="disabled"
181
+ :aria-labelledby="inputAriaLabelledBy"
182
+ :aria-label="!hasLabel ? localeMessages.checkbox : undefined"
164
183
  v-bind="checkboxAttrs"
165
184
  :data-test="getDataTest()"
166
185
  @change="onChange"
167
186
  />
168
187
 
169
- <label
188
+ <div
170
189
  v-if="isChecked"
171
190
  v-bind="partial ? partiallyCheckedAttrs : checkedAttrs"
172
- :for="elementId"
191
+ @click="onIconClick"
173
192
  >
174
193
  <UIcon
175
194
  v-if="partial"
@@ -179,7 +198,7 @@ const {
179
198
  />
180
199
 
181
200
  <UIcon v-else :name="config.defaults.checkedIcon" color="inherit" v-bind="checkedIconAttrs" />
182
- </label>
201
+ </div>
183
202
 
184
203
  <template #bottom>
185
204
  <!-- @slot Use it to add something below the checkbox. -->
@@ -51,6 +51,10 @@ export default /*tw*/ {
51
51
  },
52
52
  },
53
53
  partiallyCheckedIcon: "{>checkedIcon}",
54
+ /* These are used for a11y. */
55
+ i18n: {
56
+ checkbox: "Checkbox",
57
+ },
54
58
  defaults: {
55
59
  color: "primary",
56
60
  size: "md",
@@ -198,7 +198,7 @@ describe("UCheckbox.vue", () => {
198
198
  },
199
199
  });
200
200
 
201
- expect(component.find("label").attributes("class")).toContain(color);
201
+ expect(component.get("[vl-key='checked']").attributes("class")).toContain(`bg-${color}`);
202
202
  });
203
203
  });
204
204
 
@@ -103,10 +103,10 @@ const { getDataTest, groupLabelAttrs, groupCheckboxAttrs, listAttrs } =
103
103
  v-for="(option, index) in options"
104
104
  :key="index"
105
105
  :model-value="modelValue"
106
- :value="option.value"
106
+ :value="option[valueKey]"
107
107
  :true-value="option.trueValue"
108
108
  :false-value="option.falseValue"
109
- :label="option.label"
109
+ :label="String(option[labelKey] || undefined)"
110
110
  :description="option.description"
111
111
  :disabled="disabled"
112
112
  v-bind="groupCheckboxAttrs"
@@ -14,6 +14,8 @@ export default /*tw*/ {
14
14
  defaults: {
15
15
  color: "primary",
16
16
  size: "md",
17
+ labelKey: "label",
18
+ valueKey: "value",
17
19
  disabled: false,
18
20
  },
19
21
  };