@iyulab/components 1.40.3 → 1.41.1

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 (61) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +31 -0
  3. package/dist/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/decorate.js +1 -1
  4. package/dist/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/decorateMetadata.js +1 -1
  5. package/dist/components/UFloatingElement.js +2 -2
  6. package/dist/components/UFormControlElement.d.ts +36 -0
  7. package/dist/components/UFormControlElement.js +58 -3
  8. package/dist/components/UOverlayElement.js +2 -2
  9. package/dist/components/alert/UAlert.js +2 -2
  10. package/dist/components/avatar/UAvatar.js +2 -2
  11. package/dist/components/badge/UBadge.js +2 -2
  12. package/dist/components/breadcrumb/UBreadcrumb.js +1 -1
  13. package/dist/components/breadcrumb-item/UBreadcrumbItem.js +2 -2
  14. package/dist/components/button/UButton.js +2 -2
  15. package/dist/components/button-group/UButtonGroup.js +2 -2
  16. package/dist/components/card/UCard.js +2 -2
  17. package/dist/components/carousel/UCarousel.js +2 -2
  18. package/dist/components/checkbox/UCheckbox.js +5 -3
  19. package/dist/components/chip/UChip.js +2 -2
  20. package/dist/components/copy-button/UCopyButton.js +2 -2
  21. package/dist/components/date-picker/UDatePicker.js +4 -4
  22. package/dist/components/dialog/UDialog.js +2 -2
  23. package/dist/components/divider/UDivider.js +2 -2
  24. package/dist/components/drawer/UDrawer.js +2 -2
  25. package/dist/components/expander/UExpander.js +2 -2
  26. package/dist/components/field/UField.d.ts +74 -0
  27. package/dist/components/field/UField.js +138 -5
  28. package/dist/components/file-input/UFileInput.d.ts +11 -0
  29. package/dist/components/file-input/UFileInput.js +17 -2
  30. package/dist/components/form/UForm.js +2 -2
  31. package/dist/components/icon/UIcon.js +2 -2
  32. package/dist/components/icon-button/UIconButton.js +2 -2
  33. package/dist/components/input/UInput.js +4 -4
  34. package/dist/components/menu/UMenu.js +2 -2
  35. package/dist/components/menu-item/UMenuItem.js +2 -2
  36. package/dist/components/option/UOption.js +2 -2
  37. package/dist/components/panel/UPanel.js +2 -2
  38. package/dist/components/popover/UPopover.js +2 -2
  39. package/dist/components/progress-bar/UProgressBar.js +2 -2
  40. package/dist/components/progress-ring/UProgressRing.js +2 -2
  41. package/dist/components/radio/URadio.js +4 -4
  42. package/dist/components/rating/URating.js +4 -4
  43. package/dist/components/select/USelect.js +5 -5
  44. package/dist/components/skeleton/USkeleton.js +2 -2
  45. package/dist/components/slider/USlider.js +3 -3
  46. package/dist/components/spinner/USpinner.js +2 -2
  47. package/dist/components/split-panel/USplitPanel.js +2 -2
  48. package/dist/components/switch/USwitch.js +11 -3
  49. package/dist/components/tab/UTab.js +2 -2
  50. package/dist/components/tab-panel/UTabPanel.js +2 -2
  51. package/dist/components/tag/UTag.js +2 -2
  52. package/dist/components/text/UText.js +2 -2
  53. package/dist/components/textarea/UTextarea.js +4 -4
  54. package/dist/components/tooltip/UTooltip.js +2 -2
  55. package/dist/components/tree/UTree.js +2 -2
  56. package/dist/components/tree-item/UTreeItem.js +2 -2
  57. package/dist/utilities/accent.d.ts +1 -1
  58. package/dist/utilities/accent.js +1 -1
  59. package/package.json +3 -3
  60. package/skills/iyulab-components/references/components/field.md +42 -0
  61. package/skills/iyulab-components/references/components/switch.md +2 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@iyulab/components",
3
3
  "description": "web-components library based on lit-element made by iyulab",
4
- "version": "1.40.3",
4
+ "version": "1.41.1",
5
5
  "keywords": [
6
6
  "iyulab",
7
7
  "components",
@@ -86,7 +86,7 @@
86
86
  "@eslint/js": "^10.0.1",
87
87
  "@types/node": "^26.1.1",
88
88
  "@types/react": "^19.2.14",
89
- "@vitest/browser-playwright": "^4.1.10",
89
+ "@vitest/browser-playwright": "^5.0.0",
90
90
  "eslint": "^10.1.0",
91
91
  "eslint-plugin-lit": "^2.3.1",
92
92
  "globals": "^17.7.0",
@@ -97,6 +97,6 @@
97
97
  "vite": "^8.1.4",
98
98
  "vite-plugin-dts": "^5.0.3",
99
99
  "vite-plugin-static-copy": "^4.1.1",
100
- "vitest": "^4.1.10"
100
+ "vitest": "^5.0.0"
101
101
  }
102
102
  }
@@ -23,6 +23,48 @@ Layout wrapper for form controls. Renders label, required marker, description te
23
23
 
24
24
  ---
25
25
 
26
+ ## Accessible name
27
+
28
+ `u-field` does more than draw the label — it **names the control you slot into it**. The label text
29
+ is copied onto the slotted element as `aria-label` (and `description` as `aria-description`), and
30
+ `u-*` form controls pass that through to the native control inside their shadow root.
31
+ `aria-labelledby` is not used: it does not cross shadow boundaries.
32
+
33
+ **Set the label in one place only.** If the slotted control already carries its own `label`,
34
+ `aria-label`, or `aria-labelledby`, the field leaves it alone — overriding it would make the visible
35
+ label and the accessible name disagree (WCAG SC 2.5.3 Label in Name). Setting `label` on *both*
36
+ renders the label twice; a development-mode console warning points at that spot.
37
+
38
+ ```html
39
+ <!-- label on the field -->
40
+ <u-field label="Email"><u-input type="email" name="email"></u-input></u-field>
41
+
42
+ <!-- or on the control — not both -->
43
+ <u-input label="Email" type="email" name="email"></u-input>
44
+
45
+ <!-- native elements work the same way -->
46
+ <u-field label="Notes"><textarea name="notes"></textarea></u-field>
47
+ ```
48
+
49
+ A `u-field` that has a `label` but no form control in its default slot also warns: that label names
50
+ nothing. "Form control" here is a question about **structure**, not about what is on screen — a
51
+ form-associated custom element, a native form or focusable tag, `tabindex`, or `contenteditable`.
52
+ A field that is `disabled`, or rendered inside a container that is currently hidden (a closed
53
+ drawer, an inactive tab panel, a wizard step that is not current), is still correctly built and does
54
+ not warn. The control may sit inside a wrapper element; it does not have to be the slot's direct
55
+ child.
56
+
57
+ All ten form controls take the field's label this way. Three of them get it slightly differently,
58
+ because their name normally comes from their own content:
59
+
60
+ | Control | How the field label reaches it |
61
+ |---------|-------------------------------|
62
+ | `u-checkbox`, `u-switch` | Only when they have no label text of their own (own `label`, or content in the default slot). Their own text always wins. |
63
+ | `u-file-input` | Composed into the trigger button's name as `"<button text>, <field label>"`, so the visible text stays part of the accessible name. |
64
+ | everything else | Directly, on the native control inside the shadow root. |
65
+
66
+ ---
67
+
26
68
  ## Slots
27
69
 
28
70
  | Name | Description |
@@ -25,7 +25,7 @@ Toggle switch (on/off). Supports custom track and thumb content via slots. Form-
25
25
 
26
26
  | Name | Description |
27
27
  |------|-------------|
28
- | *(default)* | Label text |
28
+ | *(default)* | Label text (falls back to the `label` property) |
29
29
  | `track-checked` | Content inside the track when checked |
30
30
  | `track-unchecked` | Content inside the track when unchecked |
31
31
  | `thumb-checked` | Thumb content when checked |
@@ -35,6 +35,7 @@ Toggle switch (on/off). Supports custom track and thumb content via slots. Form-
35
35
 
36
36
  | Property | Type | Default | Reflect | Description |
37
37
  |----------|------|---------|---------|-------------|
38
+ | `label` | `string` | — | — | Label text — fallback for the default slot |
38
39
  | `checked` | `boolean` | `false` | ✓ | On/off state |
39
40
  | `disabled` | `boolean` | `false` | ✓ | Disable |
40
41
  | `readonly` | `boolean` | `false` | ✓ | Read-only |