@zubra/compiler 0.0.0-stage → 5.0.3

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 (37) hide show
  1. package/LICENSE +15 -0
  2. package/cli.js +175 -0
  3. package/index.d.ts +81 -0
  4. package/index.js +123 -0
  5. package/library.d.ts +20 -0
  6. package/library.js +224 -0
  7. package/package.json +41 -4
  8. package/registry/README.md +41 -0
  9. package/registry/build-index.mjs +58 -0
  10. package/registry/components/accordion-panel.zb +23 -0
  11. package/registry/components/chat-message.zb +65 -0
  12. package/registry/components/choice-cards.zb +47 -0
  13. package/registry/components/color-swatches.zb +30 -0
  14. package/registry/components/combo-box.zb +59 -0
  15. package/registry/components/date-range.zb +37 -0
  16. package/registry/components/donut-chart.zb +56 -0
  17. package/registry/components/dropdown-menu.zb +83 -0
  18. package/registry/components/flip-card.zb +29 -0
  19. package/registry/components/kanban-column.zb +65 -0
  20. package/registry/components/line-chart.zb +58 -0
  21. package/registry/components/message-composer.zb +80 -0
  22. package/registry/components/modal-dialog.zb +44 -0
  23. package/registry/components/money-input.zb +41 -0
  24. package/registry/components/progress-ring.zb +24 -0
  25. package/registry/components/quantity-stepper.zb +22 -0
  26. package/registry/components/segmented-control.zb +23 -0
  27. package/registry/components/spark-line.zb +19 -0
  28. package/registry/components/star-rating.zb +34 -0
  29. package/registry/components/step-indicator.zb +31 -0
  30. package/registry/components/streak-grid.zb +57 -0
  31. package/registry/components/tab-list.zb +59 -0
  32. package/registry/components/tag-input.zb +50 -0
  33. package/registry/components/toggle-switch.zb +27 -0
  34. package/registry/components/tool-tip.zb +68 -0
  35. package/registry/index.json +233 -0
  36. package/zubra.wasm +0 -0
  37. package/README.md +0 -3
@@ -0,0 +1,27 @@
1
+ <!--
2
+ An on/off switch with a label and a description. A form control (submits "on" when checked).
3
+ @fires checkedchange - It was switched; `detail` is the new state.
4
+ -->
5
+ <script>
6
+ function toggle() {
7
+ checked = !checked
8
+ }
9
+ </script>
10
+ <style>
11
+ :host { display: block; }
12
+ button { display: flex; align-items: center; gap: 0.9rem; width: 100%; padding: 0.75rem 0.9rem; border: 1px solid var(--line, #dde); border-radius: 0.8rem; background: var(--surface, #fff); color: inherit; font: inherit; text-align: left; cursor: pointer; }
13
+ .track { flex: none; width: 2.6rem; height: 1.5rem; border-radius: 999px; background: var(--line, #ccd); position: relative; transition: background 0.2s; }
14
+ .track::after { content: ""; position: absolute; top: 0.2rem; left: 0.2rem; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: white; box-shadow: 0 1px 2px #0003; transition: transform 0.2s; }
15
+ [aria-checked=true] .track { background: var(--accent, #36c); }
16
+ [aria-checked=true] .track::after { transform: translateX(1.1rem); }
17
+ .text { display: grid; flex: 1; }
18
+ small { color: var(--muted, #667); }
19
+ .extra { font-weight: 700; white-space: nowrap; }
20
+ </style>
21
+ <toggle-switch form-associated checked:model={false} label="" description="" extra="">
22
+ <button type="button" role="switch" aria-checked={checked ? "true" : "false"} onclick={toggle}>
23
+ <span class="track"></span>
24
+ <span class="text"><span class="label">{label}</span><small>{description}</small></span>
25
+ <span class="extra">{extra}</span>
26
+ </button>
27
+ </toggle-switch>
@@ -0,0 +1,68 @@
1
+ <!--
2
+ A short description shown when its trigger is hovered or focused: the trigger is the slotted
3
+ element, and the tip describes it (aria-describedby), so a screen reader reads it with the
4
+ trigger's name. It shows after `delay` milliseconds, stays while the pointer is over it, and
5
+ Escape hides it without moving focus (WCAG 1.4.13). It sits in the top layer (`popover`), placed
6
+ above the trigger by CSS anchor positioning, or by script where that isn't supported.
7
+ @slot - The trigger: one focusable element.
8
+ @slot content - The tip (defaults to `text`).
9
+ -->
10
+ <script>
11
+ import { id, onMount } from '@zubra/runtime'
12
+
13
+ const tipId = id()
14
+ const anchored = typeof CSS !== "undefined" && CSS.supports("position-area: top")
15
+ let wrap = null
16
+ let tip = null
17
+ let timer = null
18
+
19
+ function show() {
20
+ clearTimeout(timer)
21
+ timer = setTimeout(() => {
22
+ if (!tip || tip.matches(":popover-open")) return
23
+ tip.showPopover()
24
+ if (!anchored) place()
25
+ }, delay)
26
+ }
27
+ function hide() {
28
+ clearTimeout(timer)
29
+ if (tip?.matches(":popover-open")) tip.hidePopover()
30
+ }
31
+ // Without anchor positioning: centred above the trigger, or below it if there's no room.
32
+ function place() {
33
+ const trigger = wrap.firstElementChild.getBoundingClientRect()
34
+ const own = tip.getBoundingClientRect()
35
+ const top = trigger.top - own.height - 6 >= 0 ? trigger.top - own.height - 6 : trigger.bottom + 6
36
+ const left = Math.min(Math.max(4, trigger.left + (trigger.width - own.width) / 2), innerWidth - own.width - 4)
37
+ tip.style.top = `${top}px`
38
+ tip.style.left = `${left}px`
39
+ }
40
+
41
+ onMount(() => {
42
+ const trigger = wrap.firstElementChild
43
+ if (!trigger) return
44
+ const described = (trigger.getAttribute("aria-describedby") ?? "").split(" ").filter(Boolean)
45
+ if (!described.includes(tipId)) trigger.setAttribute("aria-describedby", [...described, tipId].join(" "))
46
+ trigger.style.setProperty("anchor-name", `--${tipId}`)
47
+ const escape = (event) => { if (event.key === "Escape") hide() }
48
+ document.addEventListener("keydown", escape)
49
+ return () => {
50
+ hide()
51
+ document.removeEventListener("keydown", escape)
52
+ }
53
+ })
54
+ </script>
55
+ <style>
56
+ :host { display: inline-block; }
57
+ .trigger { display: contents; }
58
+ [popover] { position: fixed; inset: auto; margin: 0; padding: 0.3rem 0.55rem; border: 0; border-radius: 0.4rem; background: var(--ink, #1d2130); color: var(--surface, #fff); font-size: 0.85rem; line-height: 1.3; max-width: 18rem; pointer-events: auto; }
59
+ @supports (position-area: top) {
60
+ [popover] { position-area: top; position-try-fallbacks: flip-block; margin-bottom: 6px; }
61
+ }
62
+ </style>
63
+ <tool-tip text="" delay={300}>
64
+ <span class="trigger" ref={wrap} onpointerenter={show} onpointerleave={hide} onfocusin={show} onfocusout={hide}>
65
+ <zb-slot></zb-slot>
66
+ <span popover="manual" role="tooltip" id={tipId} ref={tip} style:position-anchor={`--${tipId}`}><zb-slot name="content">{text}</zb-slot></span>
67
+ </span>
68
+ </tool-tip>
@@ -0,0 +1,233 @@
1
+ {
2
+ "components": [
3
+ {
4
+ "name": "accordion-panel",
5
+ "category": "widget",
6
+ "description": "A section that opens and closes, on the native <details>: the browser does the keyboard (Enter and Space on the heading), the find-in-page opening and the announcements. Panels with the same `group` form an accordion where one is open at a time (<details name>). `open` is two-way.",
7
+ "files": [
8
+ "accordion-panel.zb"
9
+ ],
10
+ "dependencies": []
11
+ },
12
+ {
13
+ "name": "chat-message",
14
+ "category": "app",
15
+ "description": "One message: avatar, author, time, text (with @mentions and links picked out), the message it replies to, and reactions. `me` is the signed-in user's name: their messages, mentions of them and their reactions are marked.",
16
+ "files": [
17
+ "chat-message.zb"
18
+ ],
19
+ "dependencies": []
20
+ },
21
+ {
22
+ "name": "choice-cards",
23
+ "category": "input",
24
+ "description": "Pick one of several cards: a radio group. A form control; arrow keys move the choice. Each item is `{ id, title, detail, price, note }` (`note` and `price` optional).",
25
+ "files": [
26
+ "choice-cards.zb"
27
+ ],
28
+ "dependencies": []
29
+ },
30
+ {
31
+ "name": "color-swatches",
32
+ "category": "input",
33
+ "description": "Pick a colour from `colors`. A form control (a radio group): arrow keys move the choice.",
34
+ "files": [
35
+ "color-swatches.zb"
36
+ ],
37
+ "dependencies": []
38
+ },
39
+ {
40
+ "name": "combo-box",
41
+ "category": "widget",
42
+ "description": "A combobox: type to filter, arrow keys to move, Enter to pick, Escape to close. A form control. Its behaviour is Zag.js's combobox machine (through @zubra/runtime/zag); its markup and styles are this file's. It needs `npm install @zag-js/vanilla @zag-js/combobox`. `items` is `[{ value, label }]`; `value` is two-way.",
43
+ "files": [
44
+ "combo-box.zb"
45
+ ],
46
+ "dependencies": [],
47
+ "packages": [
48
+ "@zag-js/vanilla",
49
+ "@zag-js/combobox"
50
+ ]
51
+ },
52
+ {
53
+ "name": "date-range",
54
+ "category": "input",
55
+ "description": "A check-in and check-out date, as one value `{ start, end }` (\"YYYY-MM-DD\" strings). A form control: invalid until both are set and `end` is after `start`.",
56
+ "files": [
57
+ "date-range.zb"
58
+ ],
59
+ "dependencies": []
60
+ },
61
+ {
62
+ "name": "donut-chart",
63
+ "category": "display",
64
+ "description": "A donut chart of `segments` (`[{ label, value, tone }]`, `tone` 0–7), with the total in the middle and a legend. Choosing a segment (or its legend entry) selects it; again clears it.",
65
+ "files": [
66
+ "donut-chart.zb"
67
+ ],
68
+ "dependencies": []
69
+ },
70
+ {
71
+ "name": "dropdown-menu",
72
+ "category": "widget",
73
+ "description": "A menu of actions behind a button, on the platform's `popover`: the browser puts it in the top layer and closes it on Escape or a click outside. Down or Up on the button opens it; arrow keys, Home, End and typing a letter move among the items; Enter or Space picks one, and focus goes back to the button. It's placed below the button by CSS anchor positioning, or by script where that isn't supported. `items` is `[{ value, label, disabled? }]`.",
74
+ "files": [
75
+ "dropdown-menu.zb"
76
+ ],
77
+ "dependencies": []
78
+ },
79
+ {
80
+ "name": "flip-card",
81
+ "category": "display",
82
+ "description": "A card with two faces that flips in 3D. Click, Space or Enter flips it. Shadow DOM: the faces are slotted, and the page's CSS styles them, not the card's.",
83
+ "files": [
84
+ "flip-card.zb"
85
+ ],
86
+ "dependencies": []
87
+ },
88
+ {
89
+ "name": "kanban-column",
90
+ "category": "app",
91
+ "description": "A board column: a heading with a count and an optional work-in-progress limit, its cards (the default slot) and a drop zone for cards dragged from anywhere on the board.",
92
+ "files": [
93
+ "kanban-column.zb"
94
+ ],
95
+ "dependencies": []
96
+ },
97
+ {
98
+ "name": "line-chart",
99
+ "category": "display",
100
+ "description": "A price chart: an area under a line, with the high, low and a crosshair that follows the pointer and shows the value under it.",
101
+ "files": [
102
+ "line-chart.zb"
103
+ ],
104
+ "dependencies": []
105
+ },
106
+ {
107
+ "name": "message-composer",
108
+ "category": "app",
109
+ "description": "Writing a message: Enter sends, Shift+Enter adds a line, the box grows with the text, an emoji menu inserts at the caret, and a message being replied to shows above.",
110
+ "files": [
111
+ "message-composer.zb"
112
+ ],
113
+ "dependencies": []
114
+ },
115
+ {
116
+ "name": "modal-dialog",
117
+ "category": "app",
118
+ "description": "A modal dialog on the native <dialog>: the page behind is inert, focus moves into the dialog and back to where it was, and Escape, the close button or a click on the backdrop closes it. `open` is two-way.",
119
+ "files": [
120
+ "modal-dialog.zb"
121
+ ],
122
+ "dependencies": []
123
+ },
124
+ {
125
+ "name": "money-input",
126
+ "category": "input",
127
+ "description": "An amount of money. Typing is free-form; on blur it's formatted (`1234.5` → `1,234.50`). The value is a number (or null when empty). A form control: `required` and `min` validate it.",
128
+ "files": [
129
+ "money-input.zb"
130
+ ],
131
+ "dependencies": []
132
+ },
133
+ {
134
+ "name": "progress-ring",
135
+ "category": "display",
136
+ "description": "A ring that fills to `value` of `max`, with what's in the middle from the default slot (the percentage if empty).",
137
+ "files": [
138
+ "progress-ring.zb"
139
+ ],
140
+ "dependencies": []
141
+ },
142
+ {
143
+ "name": "quantity-stepper",
144
+ "category": "input",
145
+ "description": "A number with − and + buttons, between `min` and `max`. A form control.",
146
+ "files": [
147
+ "quantity-stepper.zb"
148
+ ],
149
+ "dependencies": []
150
+ },
151
+ {
152
+ "name": "segmented-control",
153
+ "category": "input",
154
+ "description": "A row of mutually exclusive options. `options` is `[{ value, label }]`.",
155
+ "files": [
156
+ "segmented-control.zb"
157
+ ],
158
+ "dependencies": []
159
+ },
160
+ {
161
+ "name": "spark-line",
162
+ "category": "display",
163
+ "description": "A small line of recent values, green when it ends higher than it started, red when lower.",
164
+ "files": [
165
+ "spark-line.zb"
166
+ ],
167
+ "dependencies": []
168
+ },
169
+ {
170
+ "name": "star-rating",
171
+ "category": "input",
172
+ "description": "A star rating that is a form control: it submits its value under its `name`, is invalid while `required` and unset, and goes back to 0 when its form resets. `readonly` shows a rating.",
173
+ "files": [
174
+ "star-rating.zb"
175
+ ],
176
+ "dependencies": []
177
+ },
178
+ {
179
+ "name": "step-indicator",
180
+ "category": "display",
181
+ "description": "Where a multi-step flow is: steps done (which can be revisited), the current one, and those ahead.",
182
+ "files": [
183
+ "step-indicator.zb"
184
+ ],
185
+ "dependencies": []
186
+ },
187
+ {
188
+ "name": "streak-grid",
189
+ "category": "display",
190
+ "description": "A habit's last weeks as a grid of days (a column per week, Monday at the top), shaded by how much of the goal was done. Choosing a day toggles it; arrow keys move between days. `log` maps \"YYYY-MM-DD\" to a count; `today` is \"YYYY-MM-DD\".",
191
+ "files": [
192
+ "streak-grid.zb"
193
+ ],
194
+ "dependencies": []
195
+ },
196
+ {
197
+ "name": "tab-list",
198
+ "category": "widget",
199
+ "description": "Tabs: a tab list and the panels it switches between. The panels are the slotted elements with a `data-tab` attribute matching a tab's value; they get role=tabpanel, are labelled by their tab, and are hidden unless chosen. Arrow keys, Home and End move between the tabs (one tab stop), and the focused tab is chosen as it moves, unless `manual`, where Enter or Space chooses it. `tabs` is `[{ value, label }]`; `value` is two-way and defaults to the first tab.",
200
+ "files": [
201
+ "tab-list.zb"
202
+ ],
203
+ "dependencies": []
204
+ },
205
+ {
206
+ "name": "tag-input",
207
+ "category": "input",
208
+ "description": "A list of tags you type: Enter or comma adds one, Backspace in the empty field removes the last, × removes any. Suggestions come from `suggestions`. A form control.",
209
+ "files": [
210
+ "tag-input.zb"
211
+ ],
212
+ "dependencies": []
213
+ },
214
+ {
215
+ "name": "toggle-switch",
216
+ "category": "input",
217
+ "description": "An on/off switch with a label and a description. A form control (submits \"on\" when checked).",
218
+ "files": [
219
+ "toggle-switch.zb"
220
+ ],
221
+ "dependencies": []
222
+ },
223
+ {
224
+ "name": "tool-tip",
225
+ "category": "widget",
226
+ "description": "A short description shown when its trigger is hovered or focused: the trigger is the slotted element, and the tip describes it (aria-describedby), so a screen reader reads it with the trigger's name. It shows after `delay` milliseconds, stays while the pointer is over it, and Escape hides it without moving focus (WCAG 1.4.13). It sits in the top layer (`popover`), placed above the trigger by CSS anchor positioning, or by script where that isn't supported.",
227
+ "files": [
228
+ "tool-tip.zb"
229
+ ],
230
+ "dependencies": []
231
+ }
232
+ ]
233
+ }
package/zubra.wasm ADDED
Binary file
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.