@jxsuite/ui 0.0.0
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/LICENSE +21 -0
- package/README.md +11 -0
- package/components/jx-action-button.json +414 -0
- package/components/jx-button.json +310 -0
- package/components/jx-icon.json +81 -0
- package/components/jx-menu-item.json +265 -0
- package/components/jx-menu.json +122 -0
- package/icons/list.json +102 -0
- package/icons/manifest.json +348 -0
- package/package.json +46 -0
- package/project.json +167 -0
- package/src/behaviors/menu.ts +396 -0
- package/src/documents.ts +23 -0
- package/src/icons-build.ts +74 -0
- package/src/icons.ts +55 -0
- package/src/index.ts +70 -0
- package/src/testing/popover-shim.ts +139 -0
- package/src/theme.ts +63 -0
- package/stylebook/jx-action-button.json +108 -0
- package/stylebook/jx-button.json +104 -0
- package/stylebook/jx-icon.json +208 -0
- package/stylebook/jx-menu-item.json +221 -0
- package/stylebook/jx-menu.json +302 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kevin Shenk
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# `@jxsuite/ui`
|
|
2
|
+
|
|
3
|
+
The Jx UI kit: interface elements authored as Jx documents, with the theme and the icons they draw on. Jx Studio's own chrome is built from it, and a site can register the same elements with `registerUi()`.
|
|
4
|
+
|
|
5
|
+
- `components/`: one document per element (`jx-icon.json`, and so on). Each is a custom-element definition the runtime interprets; nothing here is compiled.
|
|
6
|
+
- `project.json`: the kit as a Jx project. Its `style` block is the theme: every design token, on `:root`, in `light-dark()` pairs. Open this file in Studio to edit the kit on the canvas.
|
|
7
|
+
- `icons/`: `list.json` names the Phosphor glyphs the kit ships; `manifest.json` is generated from it by `bun run build:icons` and committed.
|
|
8
|
+
- `stylebook/`: one page per element showing every variant and state.
|
|
9
|
+
- `src/`: `registerUi()` (registers every element from bundled JSON, with no network), the theme builder, and the icon lookup.
|
|
10
|
+
|
|
11
|
+
Contract: [`specs/ui.md`](../../specs/ui.md). Embedding contract the kit relies on: [`specs/embedding.md`](../../specs/embedding.md).
|
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://jxsuite.com/schema/v1",
|
|
3
|
+
"$id": "JxActionButton",
|
|
4
|
+
"tagName": "jx-action-button",
|
|
5
|
+
"observedAttributes": [
|
|
6
|
+
"label",
|
|
7
|
+
"hint",
|
|
8
|
+
"icon",
|
|
9
|
+
"mirror",
|
|
10
|
+
"weight",
|
|
11
|
+
"toggles",
|
|
12
|
+
"selected",
|
|
13
|
+
"quiet",
|
|
14
|
+
"emphasized",
|
|
15
|
+
"size",
|
|
16
|
+
"disabled",
|
|
17
|
+
"popovertarget",
|
|
18
|
+
"popovertargetaction",
|
|
19
|
+
"command",
|
|
20
|
+
"commandfor",
|
|
21
|
+
"stacked",
|
|
22
|
+
"haspopup",
|
|
23
|
+
"expanded",
|
|
24
|
+
"badge"
|
|
25
|
+
],
|
|
26
|
+
"$elements": [
|
|
27
|
+
{
|
|
28
|
+
"$ref": "./jx-icon.json"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"state": {
|
|
32
|
+
"label": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"default": "",
|
|
35
|
+
"attribute": "label",
|
|
36
|
+
"description": "The accessible name, required: an action button is icon-first, so its name is not on screen. Also its tooltip."
|
|
37
|
+
},
|
|
38
|
+
"hint": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"default": "",
|
|
41
|
+
"attribute": "hint",
|
|
42
|
+
"description": "The tooltip when it is more than the name: the name with its chord, or with why the button is off. Empty means the label is the tooltip."
|
|
43
|
+
},
|
|
44
|
+
"icon": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"default": "",
|
|
47
|
+
"attribute": "icon",
|
|
48
|
+
"description": "The glyph, by its name in the kit's manifest. Empty for a text-only action button."
|
|
49
|
+
},
|
|
50
|
+
"mirror": {
|
|
51
|
+
"type": "boolean",
|
|
52
|
+
"default": false,
|
|
53
|
+
"attribute": "mirror",
|
|
54
|
+
"description": "Draw the glyph flipped horizontally: one shipped glyph serves both sides of a pair."
|
|
55
|
+
},
|
|
56
|
+
"weight": {
|
|
57
|
+
"type": "string",
|
|
58
|
+
"default": "regular",
|
|
59
|
+
"attribute": "weight",
|
|
60
|
+
"description": "The glyph's weight: regular, bold or fill. A selected toggle draws fill by convention."
|
|
61
|
+
},
|
|
62
|
+
"toggles": {
|
|
63
|
+
"type": "boolean",
|
|
64
|
+
"default": false,
|
|
65
|
+
"attribute": "toggles",
|
|
66
|
+
"description": "A two-state button: selected flips on activation and aria-pressed says which state it is in."
|
|
67
|
+
},
|
|
68
|
+
"selected": {
|
|
69
|
+
"type": "boolean",
|
|
70
|
+
"default": false,
|
|
71
|
+
"attribute": "selected",
|
|
72
|
+
"description": "The pressed state of a toggling button. A host may hold it: the property wins over the flip."
|
|
73
|
+
},
|
|
74
|
+
"quiet": {
|
|
75
|
+
"type": "boolean",
|
|
76
|
+
"default": true,
|
|
77
|
+
"attribute": "quiet",
|
|
78
|
+
"description": "No fill and no border until hovered, which is what a toolbar wants. Off for a standalone tool button."
|
|
79
|
+
},
|
|
80
|
+
"emphasized": {
|
|
81
|
+
"type": "boolean",
|
|
82
|
+
"default": false,
|
|
83
|
+
"attribute": "emphasized",
|
|
84
|
+
"description": "Draws the selected state in the accent rather than a neutral fill."
|
|
85
|
+
},
|
|
86
|
+
"size": {
|
|
87
|
+
"type": "string",
|
|
88
|
+
"default": "md",
|
|
89
|
+
"attribute": "size",
|
|
90
|
+
"description": "sm, md or lg."
|
|
91
|
+
},
|
|
92
|
+
"disabled": {
|
|
93
|
+
"type": "boolean",
|
|
94
|
+
"default": false,
|
|
95
|
+
"attribute": "disabled",
|
|
96
|
+
"description": "Cannot act. Disabled, never absent."
|
|
97
|
+
},
|
|
98
|
+
"stacked": {
|
|
99
|
+
"type": "boolean",
|
|
100
|
+
"default": false,
|
|
101
|
+
"attribute": "stacked",
|
|
102
|
+
"description": "Icon above the label, the label visible and small: the shape of a rail button. The label is then on screen, so it is the accessible name by itself."
|
|
103
|
+
},
|
|
104
|
+
"haspopup": {
|
|
105
|
+
"type": "string",
|
|
106
|
+
"default": "",
|
|
107
|
+
"attribute": "haspopup",
|
|
108
|
+
"description": "What the button opens instead of running a command: menu, dialog or listbox. Forwarded to the control as aria-haspopup."
|
|
109
|
+
},
|
|
110
|
+
"expanded": {
|
|
111
|
+
"type": "boolean",
|
|
112
|
+
"default": false,
|
|
113
|
+
"attribute": "expanded",
|
|
114
|
+
"description": "Whether what haspopup names is showing. Forwarded to the control as aria-expanded, only when haspopup is set."
|
|
115
|
+
},
|
|
116
|
+
"badge": {
|
|
117
|
+
"type": "string",
|
|
118
|
+
"default": "",
|
|
119
|
+
"attribute": "badge",
|
|
120
|
+
"description": "A count or a mark drawn over the button's corner; empty for none."
|
|
121
|
+
},
|
|
122
|
+
"popovertarget": {
|
|
123
|
+
"type": "string",
|
|
124
|
+
"default": "",
|
|
125
|
+
"attribute": "popovertarget",
|
|
126
|
+
"description": "The popover this button invokes; forwarded to the inner control."
|
|
127
|
+
},
|
|
128
|
+
"popovertargetaction": {
|
|
129
|
+
"type": "string",
|
|
130
|
+
"default": "",
|
|
131
|
+
"attribute": "popovertargetaction",
|
|
132
|
+
"description": "toggle, show or hide; forwarded with popovertarget."
|
|
133
|
+
},
|
|
134
|
+
"command": {
|
|
135
|
+
"type": "string",
|
|
136
|
+
"default": "",
|
|
137
|
+
"attribute": "command",
|
|
138
|
+
"description": "The invoker command this button sends; forwarded to the inner control."
|
|
139
|
+
},
|
|
140
|
+
"commandfor": {
|
|
141
|
+
"type": "string",
|
|
142
|
+
"default": "",
|
|
143
|
+
"attribute": "commandfor",
|
|
144
|
+
"description": "The element the command is sent to; forwarded to the inner control."
|
|
145
|
+
},
|
|
146
|
+
"noIcon": {
|
|
147
|
+
"$expression": {
|
|
148
|
+
"operator": "!",
|
|
149
|
+
"target": {
|
|
150
|
+
"$ref": "#/state/icon"
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
"hasBadge": {
|
|
155
|
+
"$expression": {
|
|
156
|
+
"operator": "!==",
|
|
157
|
+
"target": {
|
|
158
|
+
"$ref": "#/state/badge"
|
|
159
|
+
},
|
|
160
|
+
"value": ""
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
"onClick": {
|
|
164
|
+
"$prototype": "Function",
|
|
165
|
+
"body": [
|
|
166
|
+
{
|
|
167
|
+
"if": {
|
|
168
|
+
"operator": "&&",
|
|
169
|
+
"target": {
|
|
170
|
+
"$ref": "#/state/toggles"
|
|
171
|
+
},
|
|
172
|
+
"value": {
|
|
173
|
+
"operator": "!",
|
|
174
|
+
"target": {
|
|
175
|
+
"$ref": "#/state/disabled"
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
"then": [
|
|
180
|
+
{
|
|
181
|
+
"operator": "=",
|
|
182
|
+
"target": {
|
|
183
|
+
"$ref": "#/state/selected"
|
|
184
|
+
},
|
|
185
|
+
"value": {
|
|
186
|
+
"operator": "!",
|
|
187
|
+
"target": {
|
|
188
|
+
"$ref": "#/state/selected"
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"dispatchEvent": "change",
|
|
194
|
+
"detail": {
|
|
195
|
+
"$ref": "#/state/selected"
|
|
196
|
+
},
|
|
197
|
+
"bubbles": true
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
}
|
|
201
|
+
],
|
|
202
|
+
"emits": [
|
|
203
|
+
{
|
|
204
|
+
"name": "change",
|
|
205
|
+
"description": "A toggling button flipped; detail is the new selected state."
|
|
206
|
+
}
|
|
207
|
+
],
|
|
208
|
+
"description": "A toggling button flips selected and says so with change. A plain one leaves the click to the host, which listens for it on the element."
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
"onclick": {
|
|
212
|
+
"$ref": "#/state/onClick"
|
|
213
|
+
},
|
|
214
|
+
"attributes": {
|
|
215
|
+
"data-size": "${state.size}",
|
|
216
|
+
"data-quiet": "${state.quiet ? '' : null}",
|
|
217
|
+
"data-emphasized": "${state.emphasized ? '' : null}",
|
|
218
|
+
"data-selected": "${state.toggles && state.selected ? '' : null}",
|
|
219
|
+
"data-stacked": "${state.stacked ? '' : null}"
|
|
220
|
+
},
|
|
221
|
+
"style": {
|
|
222
|
+
"display": "inline-flex",
|
|
223
|
+
"verticalAlign": "middle",
|
|
224
|
+
"&[hidden]": {
|
|
225
|
+
"display": "none"
|
|
226
|
+
},
|
|
227
|
+
"& > [part=\"control\"]": {
|
|
228
|
+
"appearance": "none",
|
|
229
|
+
"font": "inherit",
|
|
230
|
+
"fontFamily": "var(--jx-font-sans)",
|
|
231
|
+
"fontSize": "var(--jx-text-md)",
|
|
232
|
+
"display": "inline-flex",
|
|
233
|
+
"alignItems": "center",
|
|
234
|
+
"justifyContent": "center",
|
|
235
|
+
"gap": "var(--jx-space-2)",
|
|
236
|
+
"minWidth": "var(--jx-control-h)",
|
|
237
|
+
"minHeight": "var(--jx-control-h)",
|
|
238
|
+
"margin": "0",
|
|
239
|
+
"padding": "0 var(--jx-space-2)",
|
|
240
|
+
"border": "1px solid var(--jx-border-strong)",
|
|
241
|
+
"borderRadius": "var(--jx-radius-sm)",
|
|
242
|
+
"background": "var(--jx-bg-input)",
|
|
243
|
+
"color": "var(--jx-fg-dim)",
|
|
244
|
+
"cursor": "pointer",
|
|
245
|
+
"whiteSpace": "nowrap",
|
|
246
|
+
"outline": "none",
|
|
247
|
+
"transition": "background var(--jx-dur-1) var(--jx-ease-out), color var(--jx-dur-1) var(--jx-ease-out)",
|
|
248
|
+
":hover": {
|
|
249
|
+
"background": "var(--jx-hover-bg)",
|
|
250
|
+
"color": "var(--jx-fg)"
|
|
251
|
+
},
|
|
252
|
+
":focus-visible": {
|
|
253
|
+
"outline": "var(--jx-focus-ring)",
|
|
254
|
+
"outlineOffset": "2px"
|
|
255
|
+
},
|
|
256
|
+
":disabled": {
|
|
257
|
+
"opacity": "0.5",
|
|
258
|
+
"cursor": "default"
|
|
259
|
+
},
|
|
260
|
+
"position": "relative"
|
|
261
|
+
},
|
|
262
|
+
"&[data-quiet] > [part=\"control\"]": {
|
|
263
|
+
"background": "transparent",
|
|
264
|
+
"borderColor": "transparent",
|
|
265
|
+
":hover": {
|
|
266
|
+
"background": "var(--jx-hover-bg)"
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
"&[data-stacked] > [part=\"control\"]": {
|
|
270
|
+
"flexDirection": "column",
|
|
271
|
+
"gap": "2px",
|
|
272
|
+
"width": "100%",
|
|
273
|
+
"minWidth": "0",
|
|
274
|
+
"padding": "var(--jx-space-2) var(--jx-space-1)",
|
|
275
|
+
"borderRadius": "0",
|
|
276
|
+
"fontSize": "var(--jx-text-xs)",
|
|
277
|
+
"lineHeight": "var(--jx-leading-xs)"
|
|
278
|
+
},
|
|
279
|
+
"&[data-stacked] > [part=\"control\"] > [part=\"label\"]": {
|
|
280
|
+
"maxWidth": "100%",
|
|
281
|
+
"overflow": "hidden",
|
|
282
|
+
"textOverflow": "ellipsis",
|
|
283
|
+
"whiteSpace": "nowrap"
|
|
284
|
+
},
|
|
285
|
+
"&[data-selected] > [part=\"control\"]": {
|
|
286
|
+
"background": "var(--jx-accent-15)",
|
|
287
|
+
"color": "var(--jx-fg)"
|
|
288
|
+
},
|
|
289
|
+
"&[data-selected][data-emphasized] > [part=\"control\"]": {
|
|
290
|
+
"background": "var(--jx-accent-solid)",
|
|
291
|
+
"color": "var(--jx-accent-fg)"
|
|
292
|
+
},
|
|
293
|
+
"&[data-size=\"sm\"] > [part=\"control\"]": {
|
|
294
|
+
"minWidth": "calc(var(--jx-control-h) - 4px)",
|
|
295
|
+
"minHeight": "calc(var(--jx-control-h) - 4px)",
|
|
296
|
+
"padding": "0 var(--jx-space-1)"
|
|
297
|
+
},
|
|
298
|
+
"&[data-size=\"lg\"] > [part=\"control\"]": {
|
|
299
|
+
"minWidth": "calc(var(--jx-control-h) + 8px)",
|
|
300
|
+
"minHeight": "calc(var(--jx-control-h) + 8px)",
|
|
301
|
+
"padding": "0 var(--jx-space-3)"
|
|
302
|
+
},
|
|
303
|
+
"& [part=\"icon\"]": {
|
|
304
|
+
"display": "inline-flex",
|
|
305
|
+
"color": "inherit"
|
|
306
|
+
},
|
|
307
|
+
"& [part=\"icon\"][hidden]": {
|
|
308
|
+
"display": "none"
|
|
309
|
+
},
|
|
310
|
+
"& [part=\"label\"]:empty": {
|
|
311
|
+
"display": "none"
|
|
312
|
+
},
|
|
313
|
+
"& [part=\"badge\"]": {
|
|
314
|
+
"position": "absolute",
|
|
315
|
+
"top": "2px",
|
|
316
|
+
"right": "2px",
|
|
317
|
+
"minWidth": "16px",
|
|
318
|
+
"height": "16px",
|
|
319
|
+
"padding": "0 4px",
|
|
320
|
+
"boxSizing": "border-box",
|
|
321
|
+
"borderRadius": "8px",
|
|
322
|
+
"background": "var(--jx-accent-solid)",
|
|
323
|
+
"color": "var(--jx-accent-fg)",
|
|
324
|
+
"fontSize": "var(--jx-text-xs)",
|
|
325
|
+
"lineHeight": "16px",
|
|
326
|
+
"textAlign": "center",
|
|
327
|
+
"pointerEvents": "none"
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
"children": [
|
|
331
|
+
{
|
|
332
|
+
"tagName": "button",
|
|
333
|
+
"attributes": {
|
|
334
|
+
"part": "control",
|
|
335
|
+
"type": "button",
|
|
336
|
+
"disabled": {
|
|
337
|
+
"$ref": "#/state/disabled"
|
|
338
|
+
},
|
|
339
|
+
"aria-label": "${state.label || null}",
|
|
340
|
+
"title": "${state.hint || state.label || null}",
|
|
341
|
+
"aria-pressed": "${state.toggles ? (state.selected ? 'true' : 'false') : null}",
|
|
342
|
+
"popovertarget": "${state.popovertarget || null}",
|
|
343
|
+
"popovertargetaction": "${state.popovertargetaction || null}",
|
|
344
|
+
"command": "${state.command || null}",
|
|
345
|
+
"commandfor": "${state.commandfor || null}",
|
|
346
|
+
"aria-haspopup": "${state.haspopup || null}",
|
|
347
|
+
"aria-expanded": "${state.haspopup ? (state.expanded ? 'true' : 'false') : null}"
|
|
348
|
+
},
|
|
349
|
+
"children": [
|
|
350
|
+
{
|
|
351
|
+
"tagName": "span",
|
|
352
|
+
"attributes": {
|
|
353
|
+
"part": "icon"
|
|
354
|
+
},
|
|
355
|
+
"hidden": {
|
|
356
|
+
"$ref": "#/state/noIcon"
|
|
357
|
+
},
|
|
358
|
+
"children": [
|
|
359
|
+
{
|
|
360
|
+
"tagName": "jx-icon",
|
|
361
|
+
"$props": {
|
|
362
|
+
"name": {
|
|
363
|
+
"$ref": "#/state/icon"
|
|
364
|
+
},
|
|
365
|
+
"weight": {
|
|
366
|
+
"$ref": "#/state/weight"
|
|
367
|
+
},
|
|
368
|
+
"mirror": {
|
|
369
|
+
"$ref": "#/state/mirror"
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
"attributes": {
|
|
373
|
+
"part": "icon-glyph"
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
]
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
"tagName": "span",
|
|
380
|
+
"attributes": {
|
|
381
|
+
"part": "label"
|
|
382
|
+
},
|
|
383
|
+
"children": [
|
|
384
|
+
{
|
|
385
|
+
"tagName": "slot",
|
|
386
|
+
"attributes": {
|
|
387
|
+
"part": "label-slot"
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
]
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
"tagName": "span",
|
|
394
|
+
"attributes": {
|
|
395
|
+
"part": "badge-slot"
|
|
396
|
+
},
|
|
397
|
+
"$switch": {
|
|
398
|
+
"$ref": "#/state/hasBadge"
|
|
399
|
+
},
|
|
400
|
+
"cases": {
|
|
401
|
+
"true": {
|
|
402
|
+
"tagName": "span",
|
|
403
|
+
"attributes": {
|
|
404
|
+
"part": "badge",
|
|
405
|
+
"aria-hidden": "true"
|
|
406
|
+
},
|
|
407
|
+
"textContent": "${state.badge}"
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
]
|
|
412
|
+
}
|
|
413
|
+
]
|
|
414
|
+
}
|