@adia-ai/web-components 0.6.20 → 0.6.22

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 (252) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/components/accordion/accordion-item.a2ui.json +20 -3
  3. package/components/accordion/accordion-item.yaml +24 -0
  4. package/components/accordion/accordion.a2ui.json +1 -1
  5. package/components/accordion/accordion.d.ts +8 -1
  6. package/components/accordion/accordion.yaml +15 -2
  7. package/components/action-list/action-item.a2ui.json +19 -3
  8. package/components/action-list/action-item.yaml +24 -0
  9. package/components/action-list/action-list.a2ui.json +12 -2
  10. package/components/action-list/action-list.yaml +13 -3
  11. package/components/agent-artifact/agent-artifact.a2ui.json +9 -2
  12. package/components/agent-artifact/agent-artifact.d.ts +1 -1
  13. package/components/agent-artifact/agent-artifact.yaml +17 -3
  14. package/components/agent-feedback-bar/agent-feedback-bar.a2ui.json +9 -2
  15. package/components/agent-feedback-bar/agent-feedback-bar.d.ts +8 -1
  16. package/components/agent-feedback-bar/agent-feedback-bar.yaml +19 -3
  17. package/components/agent-questions/agent-questions.a2ui.json +8 -2
  18. package/components/agent-questions/agent-questions.d.ts +8 -1
  19. package/components/agent-questions/agent-questions.yaml +19 -3
  20. package/components/agent-reasoning/agent-reasoning.yaml +9 -1
  21. package/components/agent-suggestions/agent-suggestions.a2ui.json +9 -2
  22. package/components/agent-suggestions/agent-suggestions.d.ts +7 -1
  23. package/components/agent-suggestions/agent-suggestions.yaml +18 -3
  24. package/components/agent-trace/agent-trace.a2ui.json +9 -2
  25. package/components/agent-trace/agent-trace.d.ts +1 -1
  26. package/components/agent-trace/agent-trace.yaml +16 -3
  27. package/components/alert/alert.a2ui.json +1 -1
  28. package/components/alert/alert.css +8 -0
  29. package/components/alert/alert.d.ts +9 -1
  30. package/components/alert/alert.yaml +16 -2
  31. package/components/aside/aside.a2ui.json +7 -1
  32. package/components/aside/aside.yaml +33 -2
  33. package/components/avatar/avatar-group.a2ui.json +20 -3
  34. package/components/avatar/avatar-group.yaml +24 -0
  35. package/components/avatar/avatar.a2ui.json +1 -1
  36. package/components/avatar/avatar.d.ts +7 -1
  37. package/components/avatar/avatar.yaml +14 -2
  38. package/components/badge/badge.a2ui.json +1 -1
  39. package/components/badge/badge.d.ts +7 -1
  40. package/components/badge/badge.yaml +14 -2
  41. package/components/block/block.a2ui.json +9 -4
  42. package/components/block/block.d.ts +9 -3
  43. package/components/block/block.yaml +25 -5
  44. package/components/block/class.js +23 -0
  45. package/components/breadcrumb/breadcrumb.a2ui.json +5 -1
  46. package/components/breadcrumb/breadcrumb.yaml +33 -2
  47. package/components/button/button.a2ui.json +22 -2
  48. package/components/button/button.yaml +21 -3
  49. package/components/calendar-picker/calendar-picker.a2ui.json +1 -1
  50. package/components/calendar-picker/calendar-picker.yaml +13 -2
  51. package/components/canvas/canvas.a2ui.json +6 -2
  52. package/components/canvas/canvas.yaml +20 -3
  53. package/components/card/card.css +23 -2
  54. package/components/card/card.yaml +12 -0
  55. package/components/chart/chart.css +4 -2
  56. package/components/chart/chart.yaml +9 -1
  57. package/components/chart-legend/chart-legend.yaml +7 -1
  58. package/components/chat-thread/chat-thread.a2ui.json +6 -2
  59. package/components/chat-thread/chat-thread.d.ts +8 -1
  60. package/components/chat-thread/chat-thread.yaml +21 -3
  61. package/components/check/check.a2ui.json +13 -3
  62. package/components/check/check.yaml +18 -3
  63. package/components/code/code.a2ui.json +1 -1
  64. package/components/code/code.yaml +13 -2
  65. package/components/col/class.js +39 -0
  66. package/components/col/col.a2ui.json +12 -5
  67. package/components/col/col.d.ts +12 -4
  68. package/components/col/col.yaml +27 -7
  69. package/components/color-input/color-input.yaml +27 -1
  70. package/components/color-picker/color-picker.a2ui.json +8 -2
  71. package/components/color-picker/color-picker.yaml +15 -3
  72. package/components/command/command.a2ui.json +7 -2
  73. package/components/command/command.d.ts +9 -1
  74. package/components/command/command.yaml +39 -3
  75. package/components/demo-toggle/demo-toggle.yaml +7 -1
  76. package/components/description-list/description-list.a2ui.json +5 -1
  77. package/components/description-list/description-list.yaml +11 -2
  78. package/components/divider/divider.a2ui.json +1 -1
  79. package/components/divider/divider.d.ts +8 -1
  80. package/components/divider/divider.yaml +15 -2
  81. package/components/drawer/drawer.yaml +32 -1
  82. package/components/embed/embed.a2ui.json +1 -1
  83. package/components/embed/embed.d.ts +8 -1
  84. package/components/embed/embed.yaml +17 -2
  85. package/components/empty-state/empty-state.a2ui.json +19 -2
  86. package/components/empty-state/empty-state.css +14 -0
  87. package/components/empty-state/empty-state.d.ts +3 -1
  88. package/components/empty-state/empty-state.yaml +50 -3
  89. package/components/feed/feed-item.a2ui.json +21 -3
  90. package/components/feed/feed-item.yaml +25 -0
  91. package/components/feed/feed.a2ui.json +23 -3
  92. package/components/feed/feed.css +9 -4
  93. package/components/feed/feed.yaml +26 -0
  94. package/components/fields/fields.yaml +7 -1
  95. package/components/footer/footer.a2ui.json +7 -1
  96. package/components/footer/footer.yaml +27 -2
  97. package/components/grid/class.js +57 -0
  98. package/components/grid/grid.a2ui.json +3 -3
  99. package/components/grid/grid.d.ts +3 -3
  100. package/components/grid/grid.yaml +22 -8
  101. package/components/header/header.a2ui.json +8 -1
  102. package/components/header/header.yaml +30 -2
  103. package/components/heatmap/heatmap.yaml +7 -1
  104. package/components/icon/icon.a2ui.json +9 -2
  105. package/components/icon/icon.d.ts +1 -1
  106. package/components/icon/icon.yaml +32 -3
  107. package/components/image/image.yaml +7 -1
  108. package/components/input/input.css +8 -1
  109. package/components/input/input.yaml +29 -1
  110. package/components/inspector/inspector.a2ui.json +7 -2
  111. package/components/inspector/inspector.d.ts +9 -1
  112. package/components/inspector/inspector.yaml +23 -3
  113. package/components/kbd/kbd.a2ui.json +1 -1
  114. package/components/kbd/kbd.d.ts +1 -1
  115. package/components/kbd/kbd.yaml +11 -2
  116. package/components/list/list-item.a2ui.json +21 -3
  117. package/components/list/list-item.yaml +25 -0
  118. package/components/list/list.a2ui.json +7 -2
  119. package/components/list/list.d.ts +9 -1
  120. package/components/list/list.yaml +21 -3
  121. package/components/menu/menu-divider.a2ui.json +17 -3
  122. package/components/menu/menu-divider.yaml +35 -0
  123. package/components/menu/menu-item.a2ui.json +19 -3
  124. package/components/menu/menu-item.yaml +42 -0
  125. package/components/menu/menu.a2ui.json +7 -1
  126. package/components/menu/menu.yaml +33 -2
  127. package/components/modal/modal.a2ui.json +7 -2
  128. package/components/modal/modal.d.ts +10 -1
  129. package/components/modal/modal.yaml +48 -3
  130. package/components/nav/nav.a2ui.json +16 -2
  131. package/components/nav/nav.yaml +40 -3
  132. package/components/nav-group/nav-group.a2ui.json +12 -2
  133. package/components/nav-group/nav-group.yaml +37 -3
  134. package/components/nav-item/nav-item.a2ui.json +13 -2
  135. package/components/nav-item/nav-item.yaml +40 -3
  136. package/components/noodles/noodles.a2ui.json +12 -2
  137. package/components/noodles/noodles.yaml +14 -3
  138. package/components/option-card/option-card.yaml +27 -1
  139. package/components/otp-input/otp-input.yaml +24 -1
  140. package/components/page/page.a2ui.json +7 -1
  141. package/components/page/page.yaml +9 -2
  142. package/components/pagination/pagination.a2ui.json +1 -1
  143. package/components/pagination/pagination.d.ts +1 -1
  144. package/components/pagination/pagination.yaml +13 -2
  145. package/components/pane/pane.a2ui.json +1 -1
  146. package/components/pane/pane.d.ts +7 -1
  147. package/components/pane/pane.yaml +33 -2
  148. package/components/pipeline-status/pipeline-status.a2ui.json +6 -2
  149. package/components/pipeline-status/pipeline-status.d.ts +1 -1
  150. package/components/pipeline-status/pipeline-status.yaml +18 -3
  151. package/components/popover/popover.yaml +30 -1
  152. package/components/progress/progress.a2ui.json +1 -1
  153. package/components/progress/progress.d.ts +1 -1
  154. package/components/progress/progress.yaml +13 -2
  155. package/components/progress-row/progress-row.a2ui.json +12 -2
  156. package/components/progress-row/progress-row.yaml +13 -3
  157. package/components/radio/radio.a2ui.json +1 -1
  158. package/components/radio/radio.yaml +9 -1
  159. package/components/range/range.yaml +7 -1
  160. package/components/rating/rating.a2ui.json +4 -1
  161. package/components/rating/rating.yaml +10 -2
  162. package/components/richtext/richtext.a2ui.json +6 -2
  163. package/components/richtext/richtext.d.ts +9 -1
  164. package/components/richtext/richtext.yaml +20 -3
  165. package/components/row/class.js +34 -0
  166. package/components/row/row.a2ui.json +11 -5
  167. package/components/row/row.d.ts +11 -4
  168. package/components/row/row.yaml +25 -7
  169. package/components/search/search.a2ui.json +5 -1
  170. package/components/search/search.yaml +11 -2
  171. package/components/section/section.a2ui.json +7 -1
  172. package/components/section/section.yaml +36 -2
  173. package/components/segment/segment.a2ui.json +8 -2
  174. package/components/segment/segment.d.ts +7 -1
  175. package/components/segment/segment.yaml +16 -3
  176. package/components/segmented/segmented.a2ui.json +6 -1
  177. package/components/segmented/segmented.css +5 -0
  178. package/components/segmented/segmented.yaml +12 -2
  179. package/components/select/select.a2ui.json +1 -1
  180. package/components/select/select.yaml +34 -2
  181. package/components/skeleton/skeleton.a2ui.json +7 -2
  182. package/components/skeleton/skeleton.d.ts +1 -1
  183. package/components/skeleton/skeleton.yaml +17 -3
  184. package/components/slider/slider.yaml +7 -1
  185. package/components/stack/stack.a2ui.json +14 -3
  186. package/components/stack/stack.d.ts +9 -1
  187. package/components/stack/stack.yaml +22 -4
  188. package/components/stat/stat.a2ui.json +6 -2
  189. package/components/stat/stat.css +5 -2
  190. package/components/stat/stat.d.ts +1 -1
  191. package/components/stat/stat.yaml +16 -3
  192. package/components/step-progress/step-progress.yaml +7 -1
  193. package/components/stepper/stepper-item.a2ui.json +20 -3
  194. package/components/stepper/stepper-item.yaml +24 -0
  195. package/components/stepper/stepper.a2ui.json +1 -1
  196. package/components/stepper/stepper.d.ts +1 -1
  197. package/components/stepper/stepper.yaml +13 -2
  198. package/components/stream/stream.a2ui.json +12 -2
  199. package/components/stream/stream.yaml +15 -3
  200. package/components/swatch/swatch.yaml +7 -1
  201. package/components/swiper/swiper.yaml +7 -1
  202. package/components/switch/switch.a2ui.json +6 -2
  203. package/components/switch/switch.yaml +16 -2
  204. package/components/table/cell-types.js +23 -10
  205. package/components/table/class.js +12 -2
  206. package/components/table/table.a2ui.json +6 -1
  207. package/components/table/table.css +68 -1
  208. package/components/table/table.d.ts +3 -1
  209. package/components/table/table.test.js +64 -0
  210. package/components/table/table.yaml +39 -2
  211. package/components/table-toolbar/table-toolbar.yaml +27 -1
  212. package/components/tabs/tab.a2ui.json +17 -3
  213. package/components/tabs/tab.yaml +39 -0
  214. package/components/tabs/tabs.a2ui.json +1 -1
  215. package/components/tabs/tabs.d.ts +1 -1
  216. package/components/tabs/tabs.yaml +36 -2
  217. package/components/tag/tag.a2ui.json +6 -2
  218. package/components/tag/tag.d.ts +9 -1
  219. package/components/tag/tag.yaml +38 -3
  220. package/components/text/class.js +13 -0
  221. package/components/text/text.a2ui.json +9 -2
  222. package/components/text/text.d.ts +1 -1
  223. package/components/text/text.yaml +12 -5
  224. package/components/textarea/textarea.a2ui.json +15 -3
  225. package/components/textarea/textarea.yaml +41 -4
  226. package/components/timeline/timeline-item.a2ui.json +20 -3
  227. package/components/timeline/timeline-item.yaml +24 -0
  228. package/components/timeline/timeline.a2ui.json +8 -1
  229. package/components/timeline/timeline.yaml +9 -2
  230. package/components/toast/toast.a2ui.json +6 -2
  231. package/components/toast/toast.yaml +19 -3
  232. package/components/toggle-group/toggle-group.a2ui.json +13 -3
  233. package/components/toggle-group/toggle-group.d.ts +1 -1
  234. package/components/toggle-group/toggle-group.yaml +19 -4
  235. package/components/toggle-group/toggle-option.a2ui.json +18 -3
  236. package/components/toggle-group/toggle-option.yaml +23 -0
  237. package/components/toggle-scheme/toggle-scheme.yaml +4 -0
  238. package/components/toolbar/toolbar-group.a2ui.json +18 -3
  239. package/components/toolbar/toolbar-group.yaml +23 -0
  240. package/components/toolbar/toolbar.yaml +7 -1
  241. package/components/tooltip/tooltip.yaml +24 -1
  242. package/components/tree/tree-item.a2ui.json +19 -3
  243. package/components/tree/tree-item.yaml +42 -0
  244. package/components/tree/tree.a2ui.json +6 -1
  245. package/components/tree/tree.yaml +31 -2
  246. package/components/upload/upload.yaml +7 -1
  247. package/core/index.js +1 -0
  248. package/core/responsive.d.ts +29 -0
  249. package/core/responsive.js +120 -0
  250. package/core/responsive.test.js +121 -0
  251. package/package.json +1 -1
  252. package/styles/tokens.css +6 -6
@@ -39,3 +39,45 @@ props:
39
39
 
40
40
  Added in §184 (v0.5.5, FEEDBACK-08 §1).
41
41
  type: string
42
+
43
+ a2ui:
44
+ rules:
45
+ - >-
46
+ <tree-item-ui> MUST be a direct or nested descendant of
47
+ <tree-ui>. It is not a standalone primitive — outside a <tree-ui>
48
+ parent, selection / expansion / keyboard nav don't wire.
49
+ - >-
50
+ Provide a stable [value] attribute on every <tree-item-ui> that
51
+ consumers will select. The `tree-select` event's detail.value is
52
+ the identifier downstream code reads to know which node was
53
+ picked.
54
+ - >-
55
+ Use [open] to pre-expand branch nodes on initial render. Do NOT
56
+ set [selected] declaratively on more than one item — the parent
57
+ <tree-ui> manages selection. The host listens for click /
58
+ Enter / Space / ArrowRight (expand) / ArrowLeft (collapse) per
59
+ WAI-ARIA tree-view APG.
60
+ - >-
61
+ Use [icon] (Phosphor name) for affordance (folder / file /
62
+ component icons); use [badge] for counts or short status labels
63
+ (§184 v0.5.5).
64
+ - >-
65
+ Nest further <tree-item-ui> in the default slot only — no
66
+ <list-item-ui>, <nav-item-ui>, or arbitrary content inside a
67
+ tree row. The chevron is auto-stamped when the row has nested
68
+ tree-item-ui children.
69
+
70
+ keywords:
71
+ - tree-item
72
+ - tree-row
73
+ - tree-node
74
+ - hierarchy-item
75
+
76
+ related:
77
+ - Tree
78
+ - List
79
+ - Nav
80
+ - Accordion
81
+
82
+ synonyms:
83
+ tree-item: [tree-node, tree-row, hierarchy-row]
@@ -70,7 +70,12 @@
70
70
  "folder"
71
71
  ],
72
72
  "name": "UITree",
73
- "related": [],
73
+ "related": [
74
+ "TreeItem",
75
+ "Nav",
76
+ "List",
77
+ "Accordion"
78
+ ],
74
79
  "slots": {
75
80
  "default (tree-item-ui children)": {
76
81
  "description": "Child content region for the `default (tree-item-ui children)` slot."
@@ -92,7 +92,32 @@ tokens:
92
92
  requiredIcons:
93
93
  - caret-right
94
94
  a2ui:
95
- rules: []
95
+ rules:
96
+ - >-
97
+ Use <tree-ui> only when data is hierarchical with arbitrary
98
+ nesting AND a single selected node is meaningful. For flat
99
+ lists use <list-ui>; for flat sidebar navigation use <nav-ui>;
100
+ for one-level collapsible groups use <accordion-ui>.
101
+ - >-
102
+ Canonical mount: inside <editor-sidebar slot="leading"> →
103
+ <pane-ui side="leading" resizable> → <section> → <tree-ui id="…">
104
+ as the structure / navigator pane of the three-pane editor shell.
105
+ Pair with a <header> in the same pane (e.g. "Structure",
106
+ "Layers", "Files").
107
+ - >-
108
+ Direct children of <tree-ui> MUST be <tree-item-ui>. No other
109
+ element types in the default slot. <tree-ui> manages
110
+ single-selection across the whole subtree and implements
111
+ WAI-ARIA tree-view keyboard navigation (Arrow keys, Enter /
112
+ Space, Home / End).
113
+ - >-
114
+ Listen for `tree-select` on the <tree-ui>, NOT on individual
115
+ rows — selection is managed by the parent and bubbles once.
116
+ Detail = {item, text, value, ctrlKey, metaKey, shiftKey}.
117
+ - >-
118
+ Per ADR-0027, <tree-ui> composes <icon-ui> (for chevrons) but
119
+ does NOT auto-import its children. Consumer pages must
120
+ explicitly import both <tree-ui> and <tree-item-ui>.
96
121
  anti_patterns: []
97
122
  examples:
98
123
  - name: basic-tree
@@ -128,4 +153,8 @@ synonyms:
128
153
  - sidebar
129
154
  - nav
130
155
  - tree
131
- related: []
156
+ related:
157
+ - TreeItem
158
+ - Nav
159
+ - List
160
+ - Accordion
@@ -66,7 +66,13 @@ states:
66
66
  traits: []
67
67
  tokens: {}
68
68
  a2ui:
69
- rules: []
69
+ rules:
70
+ - rule: 'File-upload input with drop zone + browse button. Form-associated; emits file-list change events.'
71
+ reason: 'File-input canonical primitive.'
72
+ - rule: 'Multiple attribute enables multi-file selection; accept= constrains file types.'
73
+ reason: 'Standard file-input knobs.'
74
+ - rule: 'For agent chat attachments use <chat-composer-ui>''s built-in upload affordance instead.'
75
+ reason: 'Chat composer has its own attachment lane.'
70
76
  anti_patterns: []
71
77
  examples:
72
78
  - name: data-import
package/core/index.js CHANGED
@@ -31,3 +31,4 @@ export * from './transport.js';
31
31
  export * from './polyfills.js';
32
32
  export { streams, whenStream } from './data-stream.js';
33
33
  export * from './streams-bridge.js';
34
+ export * from './responsive.js';
@@ -0,0 +1,29 @@
1
+ import type { Signal } from './signals.js';
2
+
3
+ /** Min-width px thresholds keyed by breakpoint name. */
4
+ export declare const BREAKPOINTS: { xs: 0; sm: 480; md: 768; lg: 1024; xl: 1280 };
5
+
6
+ /** Ordered breakpoint names, narrowest → widest. */
7
+ export declare const BP_NAMES: string[];
8
+
9
+ /**
10
+ * Shared signal holding the current viewport breakpoint name.
11
+ * Read inside a UIElement `render()` to subscribe; the component
12
+ * re-renders automatically on breakpoint change.
13
+ */
14
+ export declare const breakpoint: Signal<'xs' | 'sm' | 'md' | 'lg' | 'xl'>;
15
+
16
+ /**
17
+ * Resolve a responsive attribute value for the given breakpoint.
18
+ *
19
+ * Syntax: `"base @bp:override ..."` — e.g. `"1 2@sm 4@lg"`.
20
+ * Mobile-first: `@bp` applies at that breakpoint and all wider ones.
21
+ * Returns the unannotated default when no annotation matches.
22
+ *
23
+ * @param value Raw attribute string (e.g. `"1 2@sm 4@lg"`).
24
+ * @param activeBp Breakpoint to resolve for. Defaults to `breakpoint.value`.
25
+ */
26
+ export declare function parseResponsive(
27
+ value: string | null | undefined,
28
+ activeBp?: string,
29
+ ): string | null;
@@ -0,0 +1,120 @@
1
+ /**
2
+ * AdiaUI Responsive — viewport-breakpoint signal + `@bp` attribute parser.
3
+ *
4
+ * Components that support responsive attribute values read `breakpoint.value`
5
+ * inside their `render()` method. UIElement wraps render() in an effect, so
6
+ * the component automatically re-renders whenever the viewport crosses a
7
+ * breakpoint boundary — no manual subscription needed.
8
+ *
9
+ * ## Syntax
10
+ *
11
+ * "4" → scalar, fast-path (no parsing)
12
+ * "1 2@sm 4@lg" → 1 on xs, 2 from sm, 4 from lg/xl
13
+ * "4 1@sm" → 4 on md/lg/xl, 1 on xs/sm
14
+ * "2@md" → 2 from md+, inherits component default below md
15
+ *
16
+ * Semantics: mobile-first / min-width — `@bp` means "apply at this
17
+ * breakpoint and all wider viewports, unless overridden by a larger
18
+ * annotation". The unannotated value is the base (smallest screens).
19
+ *
20
+ * Resolution: largest `@bp` whose index ≤ active-bp-index wins.
21
+ * If no annotation matches, the unannotated default is returned.
22
+ *
23
+ * @example
24
+ * import { parseResponsive, breakpoint } from '../../core/responsive.js';
25
+ *
26
+ * render() {
27
+ * const bp = breakpoint.value; // subscribe
28
+ * const cols = parseResponsive(this.columns, bp);
29
+ * this.style.gridTemplateColumns = `repeat(${cols}, 1fr)`;
30
+ * }
31
+ */
32
+
33
+ import { signal } from './signals.js';
34
+
35
+ // ─── Breakpoint scale ─────────────────────────────────────────────────────────
36
+
37
+ /** Min-width px thresholds, narrowest first. */
38
+ export const BREAKPOINTS = /** @type {Record<string, number>} */ ({
39
+ xs: 0,
40
+ sm: 480,
41
+ md: 768,
42
+ lg: 1024,
43
+ xl: 1280,
44
+ });
45
+
46
+ /** Ordered list of breakpoint names, narrowest → widest. */
47
+ export const BP_NAMES = /** @type {string[]} */ (Object.keys(BREAKPOINTS));
48
+ const BP_VALS = /** @type {number[]} */ (Object.values(BREAKPOINTS));
49
+
50
+ // ─── Active-breakpoint signal ─────────────────────────────────────────────────
51
+
52
+ function _detect() {
53
+ if (typeof window === 'undefined') return 'lg'; // SSR / non-browser fallback
54
+ const w = window.innerWidth;
55
+ for (let i = BP_NAMES.length - 1; i >= 0; i--) {
56
+ if (w >= BP_VALS[i]) return BP_NAMES[i];
57
+ }
58
+ return 'xs';
59
+ }
60
+
61
+ /**
62
+ * Shared signal — current viewport breakpoint name.
63
+ * Reading `.value` inside a UIElement `render()` creates a subscription;
64
+ * the component re-renders automatically on breakpoint change.
65
+ *
66
+ * @type {import('./signals.js').Signal<string>}
67
+ */
68
+ export const breakpoint = signal(_detect());
69
+
70
+ // Wire matchMedia listeners once (browser only, skipped in SSR / tests)
71
+ if (typeof window !== 'undefined') {
72
+ // One listener per non-zero threshold; fires whenever the viewport crosses
73
+ // that boundary in either direction.
74
+ for (let i = 1; i < BP_VALS.length; i++) {
75
+ window
76
+ .matchMedia(`(min-width: ${BP_VALS[i]}px)`)
77
+ .addEventListener('change', () => { breakpoint.value = _detect(); });
78
+ }
79
+ }
80
+
81
+ // ─── Parser ───────────────────────────────────────────────────────────────────
82
+
83
+ /**
84
+ * Resolve a responsive attribute value for the given breakpoint.
85
+ *
86
+ * @param {string | null | undefined} value Raw attribute string.
87
+ * @param {string} activeBp Current breakpoint name.
88
+ * @returns {string | null} Resolved scalar, or null.
89
+ */
90
+ export function parseResponsive(value, activeBp = breakpoint.value) {
91
+ if (!value) return null;
92
+ if (!value.includes('@')) return value; // fast path — plain scalar
93
+
94
+ let defaultVal = /** @type {string | null} */ (null);
95
+ const bpMap = /** @type {Map<string, string>} */ (new Map());
96
+
97
+ for (const token of value.trim().split(/\s+/)) {
98
+ const at = token.lastIndexOf('@');
99
+ if (at === -1) {
100
+ defaultVal = token;
101
+ } else {
102
+ bpMap.set(token.slice(at + 1), token.slice(0, at));
103
+ }
104
+ }
105
+
106
+ // Find the largest @bp annotation whose index ≤ active-bp index.
107
+ const activeIdx = BP_NAMES.indexOf(activeBp);
108
+ let best = /** @type {string | null} */ (null);
109
+ let bestIdx = -1;
110
+
111
+ for (const [bp, val] of bpMap) {
112
+ const idx = BP_NAMES.indexOf(bp);
113
+ if (idx !== -1 && idx <= activeIdx && idx > bestIdx) {
114
+ best = val;
115
+ bestIdx = idx;
116
+ }
117
+ }
118
+
119
+ return best ?? defaultVal;
120
+ }
@@ -0,0 +1,121 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { parseResponsive, BP_NAMES, BREAKPOINTS } from './responsive.js';
3
+
4
+ // ── parseResponsive ────────────────────────────────────────────────────────
5
+
6
+ describe('parseResponsive — scalar fast path', () => {
7
+ it('returns value unchanged when no @ present', () => {
8
+ expect(parseResponsive('3', 'md')).toBe('3');
9
+ expect(parseResponsive('auto-fill','lg')).toBe('auto-fill');
10
+ expect(parseResponsive('md', 'sm')).toBe('md');
11
+ });
12
+
13
+ it('returns null for null / undefined input', () => {
14
+ expect(parseResponsive(null, 'md')).toBeNull();
15
+ expect(parseResponsive(undefined, 'md')).toBeNull();
16
+ });
17
+
18
+ it('returns null for empty string', () => {
19
+ expect(parseResponsive('', 'md')).toBeNull();
20
+ });
21
+ });
22
+
23
+ describe('parseResponsive — mobile-first resolution', () => {
24
+ // "1 2@sm 4@lg" = 1 at xs, 2 from sm, 4 from lg
25
+ const val = '1 2@sm 4@lg';
26
+
27
+ it('base (xs) — no annotation matches, returns unannotated default', () => {
28
+ expect(parseResponsive(val, 'xs')).toBe('1');
29
+ });
30
+
31
+ it('sm — @sm matches exactly', () => {
32
+ expect(parseResponsive(val, 'sm')).toBe('2');
33
+ });
34
+
35
+ it('md — largest annotation ≤ md is @sm', () => {
36
+ expect(parseResponsive(val, 'md')).toBe('2');
37
+ });
38
+
39
+ it('lg — @lg matches exactly', () => {
40
+ expect(parseResponsive(val, 'lg')).toBe('4');
41
+ });
42
+
43
+ it('xl — largest annotation ≤ xl is @lg', () => {
44
+ expect(parseResponsive(val, 'xl')).toBe('4');
45
+ });
46
+ });
47
+
48
+ describe('parseResponsive — sparse annotations (two-point)', () => {
49
+ it('"4 1@sm": 4 at xs, 1 from sm upward', () => {
50
+ expect(parseResponsive('4 1@sm', 'xs')).toBe('4');
51
+ expect(parseResponsive('4 1@sm', 'sm')).toBe('1');
52
+ expect(parseResponsive('4 1@sm', 'md')).toBe('1');
53
+ expect(parseResponsive('4 1@sm', 'lg')).toBe('1');
54
+ });
55
+
56
+ it('"2@md": no default — returns null below md, 2 from md up', () => {
57
+ expect(parseResponsive('2@md', 'xs')).toBeNull();
58
+ expect(parseResponsive('2@md', 'sm')).toBeNull();
59
+ expect(parseResponsive('2@md', 'md')).toBe('2');
60
+ expect(parseResponsive('2@md', 'xl')).toBe('2');
61
+ });
62
+
63
+ it('"1 4@lg": only one override — md falls back to base', () => {
64
+ expect(parseResponsive('1 4@lg', 'xs')).toBe('1');
65
+ expect(parseResponsive('1 4@lg', 'md')).toBe('1');
66
+ expect(parseResponsive('1 4@lg', 'lg')).toBe('4');
67
+ expect(parseResponsive('1 4@lg', 'xl')).toBe('4');
68
+ });
69
+ });
70
+
71
+ describe('parseResponsive — order-independence', () => {
72
+ it('annotations in any order resolve identically', () => {
73
+ const a = '1 2@sm 4@lg';
74
+ const b = '4@lg 1 2@sm';
75
+ const c = '2@sm 4@lg 1';
76
+ for (const bp of BP_NAMES) {
77
+ const ref = parseResponsive(a, bp);
78
+ expect(parseResponsive(b, bp)).toBe(ref);
79
+ expect(parseResponsive(c, bp)).toBe(ref);
80
+ }
81
+ });
82
+ });
83
+
84
+ describe('parseResponsive — edge cases', () => {
85
+ it('unknown bp annotation is silently skipped; default still returned', () => {
86
+ expect(parseResponsive('3 1@xxl', 'xl')).toBe('3');
87
+ });
88
+
89
+ it('single annotation with no default', () => {
90
+ expect(parseResponsive('2@sm', 'xs')).toBeNull();
91
+ expect(parseResponsive('2@sm', 'sm')).toBe('2');
92
+ });
93
+
94
+ it('all five breakpoints annotated — each resolves to its own value', () => {
95
+ const val = '0 1@xs 2@sm 3@md 4@lg 5@xl';
96
+ expect(parseResponsive(val, 'xs')).toBe('1');
97
+ expect(parseResponsive(val, 'sm')).toBe('2');
98
+ expect(parseResponsive(val, 'md')).toBe('3');
99
+ expect(parseResponsive(val, 'lg')).toBe('4');
100
+ expect(parseResponsive(val, 'xl')).toBe('5');
101
+ });
102
+ });
103
+
104
+ // ── BREAKPOINTS contract ───────────────────────────────────────────────────
105
+
106
+ describe('BREAKPOINTS / BP_NAMES exports', () => {
107
+ it('BP_NAMES is ordered narrowest → widest', () => {
108
+ expect(BP_NAMES).toEqual(['xs', 'sm', 'md', 'lg', 'xl']);
109
+ });
110
+
111
+ it('BREAKPOINTS values are strictly increasing', () => {
112
+ const vals = BP_NAMES.map((bp) => BREAKPOINTS[bp]);
113
+ for (let i = 1; i < vals.length; i++) {
114
+ expect(vals[i]).toBeGreaterThan(vals[i - 1]);
115
+ }
116
+ });
117
+
118
+ it('xs starts at 0', () => {
119
+ expect(BREAKPOINTS.xs).toBe(0);
120
+ });
121
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adia-ai/web-components",
3
- "version": "0.6.20",
3
+ "version": "0.6.22",
4
4
  "description": "AdiaUI web components \u2014 vanilla custom elements. A2UI runtime (renderer, registry, streams, wiring) lives in @adia-ai/a2ui-runtime.",
5
5
  "type": "module",
6
6
  "types": "./index.d.ts",
package/styles/tokens.css CHANGED
@@ -96,15 +96,15 @@
96
96
  --a-radius: var(--a-radius-md);
97
97
 
98
98
  /* ── Inset ── */
99
- --a-inset-sm: var(--a-space-4);
100
- --a-inset-md: var(--a-space-6);
101
- --a-inset-lg: var(--a-space-8);
99
+ --a-inset-sm: var(--a-space-2);
100
+ --a-inset-md: var(--a-space-4);
101
+ --a-inset-lg: var(--a-space-6);
102
102
  --a-inset: var(--a-inset-md);
103
103
 
104
104
  /* ── Gaps ── */
105
- --a-gap-sm: var(--a-space-3);
106
- --a-gap-md: var(--a-space-4);
107
- --a-gap-lg: var(--a-space-6);
105
+ --a-gap-sm: var(--a-space-2);
106
+ --a-gap-md: var(--a-space-3);
107
+ --a-gap-lg: var(--a-space-4);
108
108
  --a-gap: var(--a-gap-md);
109
109
 
110
110
  /* ── Sizing (component heights) ──