zyzz 0.0.33 → 0.0.35
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/binding/compiler.wasm +0 -0
- package/binding/wasi/zyzz.wasm32-wasi.wasm +0 -0
- package/binding/zyzz.darwin-arm64.node +0 -0
- package/binding/zyzz.darwin-x64.node +0 -0
- package/binding/zyzz.linux-arm64-gnu.node +0 -0
- package/binding/zyzz.linux-arm64-musl.node +0 -0
- package/binding/zyzz.linux-x64-gnu.node +0 -0
- package/binding/zyzz.linux-x64-musl.node +0 -0
- package/binding/zyzz.win32-arm64-msvc.node +0 -0
- package/binding/zyzz.win32-x64-msvc.node +0 -0
- package/dist/Style.d.ts +1 -1
- package/dist/Style.d.ts.map +1 -1
- package/dist/Style.js.map +1 -1
- package/dist/Vars.d.ts +17 -11
- package/dist/Vars.d.ts.map +1 -1
- package/dist/Vars.js.map +1 -1
- package/dist/babel/index.d.ts.map +1 -1
- package/dist/babel/index.js +10 -1
- package/dist/babel/index.js.map +1 -1
- package/dist/base-ui/react/Config.d.ts +48 -0
- package/dist/base-ui/react/Config.d.ts.map +1 -0
- package/dist/base-ui/react/Config.js +30 -0
- package/dist/base-ui/react/Config.js.map +1 -0
- package/dist/base-ui/react/Style.d.ts +47 -0
- package/dist/base-ui/react/Style.d.ts.map +1 -0
- package/dist/base-ui/react/Style.js +12 -0
- package/dist/base-ui/react/Style.js.map +1 -0
- package/dist/base-ui/react/index.d.ts +13 -0
- package/dist/base-ui/react/index.d.ts.map +1 -0
- package/dist/base-ui/react/index.js +13 -0
- package/dist/base-ui/react/index.js.map +1 -0
- package/dist/base-ui/react/internal/Attributes.generated.d.ts +372 -0
- package/dist/base-ui/react/internal/Attributes.generated.d.ts.map +1 -0
- package/dist/base-ui/react/internal/Attributes.generated.js +403 -0
- package/dist/base-ui/react/internal/Attributes.generated.js.map +1 -0
- package/dist/base-ui/react/internal/Authoring.d.ts +9 -0
- package/dist/base-ui/react/internal/Authoring.d.ts.map +1 -0
- package/dist/base-ui/react/internal/Authoring.js +139 -0
- package/dist/base-ui/react/internal/Authoring.js.map +1 -0
- package/dist/base-ui/react/internal/Types.generated.d.ts +18933 -0
- package/dist/base-ui/react/internal/Types.generated.d.ts.map +1 -0
- package/dist/base-ui/react/internal/Types.generated.js +2 -0
- package/dist/base-ui/react/internal/Types.generated.js.map +1 -0
- package/dist/binding/compiler.wasm +0 -0
- package/dist/compiler/Graph.d.ts +1 -1
- package/dist/compiler/Graph.d.ts.map +1 -1
- package/dist/compiler/internal/Modules.d.ts +33 -0
- package/dist/compiler/internal/Modules.d.ts.map +1 -0
- package/dist/compiler/internal/Modules.js +56 -0
- package/dist/compiler/internal/Modules.js.map +1 -0
- package/dist/compiler/internal/Results.d.ts +2 -26
- package/dist/compiler/internal/Results.d.ts.map +1 -1
- package/dist/compiler/internal/Results.js +4 -57
- package/dist/compiler/internal/Results.js.map +1 -1
- package/dist/compiler/wasm/Graph.d.ts +70 -0
- package/dist/compiler/wasm/Graph.d.ts.map +1 -0
- package/dist/compiler/wasm/Graph.js +70 -0
- package/dist/compiler/wasm/Graph.js.map +1 -0
- package/dist/compiler/wasm/index.d.ts +8 -0
- package/dist/compiler/wasm/index.d.ts.map +1 -0
- package/dist/compiler/wasm/index.js +8 -0
- package/dist/compiler/wasm/index.js.map +1 -0
- package/dist/default.js.zyzz.json +1 -1
- package/dist/internal/Configuration.d.ts +2 -1
- package/dist/internal/Configuration.d.ts.map +1 -1
- package/dist/internal/Configuration.js.map +1 -1
- package/dist/internal/Value.d.ts +4 -0
- package/dist/internal/Value.d.ts.map +1 -1
- package/dist/internal/Value.js.map +1 -1
- package/dist/internal/VariableSets.d.ts.map +1 -1
- package/dist/internal/VariableSets.js +16 -0
- package/dist/internal/VariableSets.js.map +1 -1
- package/dist/internal/Wasm.d.ts +7 -5
- package/dist/internal/Wasm.d.ts.map +1 -1
- package/dist/internal/Wasm.js +19 -7
- package/dist/internal/Wasm.js.map +1 -1
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +9 -1
- package/dist/vite/index.js.map +1 -1
- package/dist/web/internal/Wasm.generated.d.ts.map +1 -1
- package/dist/web/internal/Wasm.generated.js +1 -1
- package/dist/web/internal/Wasm.generated.js.map +1 -1
- package/package.json +20 -1
- package/src/Style.ts +4 -1
- package/src/Vars.ts +41 -21
- package/src/babel/index.ts +13 -1
- package/src/base-ui/react/Config.ts +74 -0
- package/src/base-ui/react/Style.ts +109 -0
- package/src/base-ui/react/index.ts +12 -0
- package/src/base-ui/react/internal/Attributes.generated.ts +403 -0
- package/src/base-ui/react/internal/Authoring.ts +173 -0
- package/src/base-ui/react/internal/Catalog.generated.ts +8088 -0
- package/src/base-ui/react/internal/Types.generated.ts +19016 -0
- package/src/compiler/Graph.ts +1 -1
- package/src/compiler/internal/Modules.ts +94 -0
- package/src/compiler/internal/Results.ts +6 -91
- package/src/compiler/wasm/Graph.ts +178 -0
- package/src/compiler/wasm/index.ts +7 -0
- package/src/internal/Configuration.ts +4 -1
- package/src/internal/Value.ts +5 -0
- package/src/internal/VariableSets.ts +22 -0
- package/src/internal/Wasm.ts +22 -7
- package/src/vite/index.ts +12 -1
- package/src/web/internal/Wasm.generated.ts +1 -1
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by scripts/base-ui.ts. Do not edit.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** Attribute spellings and domains for untransformed authoring. Component validation belongs to types and source extraction. */
|
|
7
|
+
export const attributes = {
|
|
8
|
+
activationDirection: {
|
|
9
|
+
attribute: 'data-activation-direction',
|
|
10
|
+
presence: false,
|
|
11
|
+
values: [
|
|
12
|
+
' ',
|
|
13
|
+
' up',
|
|
14
|
+
' down',
|
|
15
|
+
'left ',
|
|
16
|
+
'left up',
|
|
17
|
+
'left down',
|
|
18
|
+
'right ',
|
|
19
|
+
'right up',
|
|
20
|
+
'right down',
|
|
21
|
+
'left',
|
|
22
|
+
'right',
|
|
23
|
+
'up',
|
|
24
|
+
'down',
|
|
25
|
+
'none',
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
active: {
|
|
29
|
+
attribute: 'data-active',
|
|
30
|
+
presence: true,
|
|
31
|
+
values: [],
|
|
32
|
+
},
|
|
33
|
+
align: {
|
|
34
|
+
attribute: 'data-align',
|
|
35
|
+
presence: false,
|
|
36
|
+
values: ['center', 'start', 'end'],
|
|
37
|
+
},
|
|
38
|
+
anchorHidden: {
|
|
39
|
+
attribute: 'data-anchor-hidden',
|
|
40
|
+
presence: true,
|
|
41
|
+
values: [],
|
|
42
|
+
},
|
|
43
|
+
behind: {
|
|
44
|
+
attribute: 'data-behind',
|
|
45
|
+
presence: true,
|
|
46
|
+
values: [],
|
|
47
|
+
},
|
|
48
|
+
checked: {
|
|
49
|
+
attribute: 'data-checked',
|
|
50
|
+
presence: true,
|
|
51
|
+
values: [],
|
|
52
|
+
},
|
|
53
|
+
closed: {
|
|
54
|
+
attribute: 'data-closed',
|
|
55
|
+
presence: true,
|
|
56
|
+
values: [],
|
|
57
|
+
},
|
|
58
|
+
complete: {
|
|
59
|
+
attribute: 'data-complete',
|
|
60
|
+
presence: true,
|
|
61
|
+
values: [],
|
|
62
|
+
},
|
|
63
|
+
current: {
|
|
64
|
+
attribute: 'data-current',
|
|
65
|
+
presence: true,
|
|
66
|
+
selector: '& > [data-current]',
|
|
67
|
+
values: [],
|
|
68
|
+
},
|
|
69
|
+
direction: {
|
|
70
|
+
attribute: 'data-direction',
|
|
71
|
+
presence: false,
|
|
72
|
+
values: ['down', 'up'],
|
|
73
|
+
},
|
|
74
|
+
dirty: {
|
|
75
|
+
attribute: 'data-dirty',
|
|
76
|
+
presence: true,
|
|
77
|
+
values: [],
|
|
78
|
+
},
|
|
79
|
+
disabled: {
|
|
80
|
+
attribute: 'data-disabled',
|
|
81
|
+
presence: true,
|
|
82
|
+
values: [],
|
|
83
|
+
},
|
|
84
|
+
dragging: {
|
|
85
|
+
attribute: 'data-dragging',
|
|
86
|
+
presence: true,
|
|
87
|
+
values: [],
|
|
88
|
+
},
|
|
89
|
+
empty: {
|
|
90
|
+
attribute: 'data-empty',
|
|
91
|
+
presence: true,
|
|
92
|
+
values: [],
|
|
93
|
+
},
|
|
94
|
+
endingStyle: {
|
|
95
|
+
attribute: 'data-ending-style',
|
|
96
|
+
presence: true,
|
|
97
|
+
values: [],
|
|
98
|
+
},
|
|
99
|
+
error: {
|
|
100
|
+
attribute: 'data-error',
|
|
101
|
+
presence: true,
|
|
102
|
+
values: [],
|
|
103
|
+
},
|
|
104
|
+
expanded: {
|
|
105
|
+
attribute: 'data-expanded',
|
|
106
|
+
presence: true,
|
|
107
|
+
values: [],
|
|
108
|
+
},
|
|
109
|
+
filled: {
|
|
110
|
+
attribute: 'data-filled',
|
|
111
|
+
presence: true,
|
|
112
|
+
values: [],
|
|
113
|
+
},
|
|
114
|
+
focusable: {
|
|
115
|
+
attribute: 'data-focusable',
|
|
116
|
+
presence: true,
|
|
117
|
+
values: [],
|
|
118
|
+
},
|
|
119
|
+
focused: {
|
|
120
|
+
attribute: 'data-focused',
|
|
121
|
+
presence: true,
|
|
122
|
+
values: [],
|
|
123
|
+
},
|
|
124
|
+
hasOverflowX: {
|
|
125
|
+
attribute: 'data-has-overflow-x',
|
|
126
|
+
presence: true,
|
|
127
|
+
values: [],
|
|
128
|
+
},
|
|
129
|
+
hasOverflowY: {
|
|
130
|
+
attribute: 'data-has-overflow-y',
|
|
131
|
+
presence: true,
|
|
132
|
+
values: [],
|
|
133
|
+
},
|
|
134
|
+
hasSubmenuOpen: {
|
|
135
|
+
attribute: 'data-has-submenu-open',
|
|
136
|
+
presence: true,
|
|
137
|
+
values: [],
|
|
138
|
+
},
|
|
139
|
+
hidden: {
|
|
140
|
+
attribute: 'data-hidden',
|
|
141
|
+
presence: true,
|
|
142
|
+
values: [],
|
|
143
|
+
},
|
|
144
|
+
highlighted: {
|
|
145
|
+
attribute: 'data-highlighted',
|
|
146
|
+
presence: true,
|
|
147
|
+
values: [],
|
|
148
|
+
},
|
|
149
|
+
hovering: {
|
|
150
|
+
attribute: 'data-hovering',
|
|
151
|
+
presence: true,
|
|
152
|
+
values: [],
|
|
153
|
+
},
|
|
154
|
+
inactive: {
|
|
155
|
+
attribute: 'data-inactive',
|
|
156
|
+
presence: true,
|
|
157
|
+
values: [],
|
|
158
|
+
},
|
|
159
|
+
indeterminate: {
|
|
160
|
+
attribute: 'data-indeterminate',
|
|
161
|
+
presence: true,
|
|
162
|
+
values: [],
|
|
163
|
+
},
|
|
164
|
+
index: {
|
|
165
|
+
attribute: 'data-index',
|
|
166
|
+
presence: false,
|
|
167
|
+
values: [],
|
|
168
|
+
domain: 'number',
|
|
169
|
+
},
|
|
170
|
+
instant: {
|
|
171
|
+
attribute: 'data-instant',
|
|
172
|
+
presence: true,
|
|
173
|
+
values: [
|
|
174
|
+
'click',
|
|
175
|
+
'dismiss',
|
|
176
|
+
'group',
|
|
177
|
+
'trigger-change',
|
|
178
|
+
'focus',
|
|
179
|
+
'delay',
|
|
180
|
+
'tracking-cursor',
|
|
181
|
+
],
|
|
182
|
+
},
|
|
183
|
+
invalid: {
|
|
184
|
+
attribute: 'data-invalid',
|
|
185
|
+
presence: true,
|
|
186
|
+
values: [],
|
|
187
|
+
},
|
|
188
|
+
limited: {
|
|
189
|
+
attribute: 'data-limited',
|
|
190
|
+
presence: true,
|
|
191
|
+
values: [],
|
|
192
|
+
},
|
|
193
|
+
listEmpty: {
|
|
194
|
+
attribute: 'data-list-empty',
|
|
195
|
+
presence: true,
|
|
196
|
+
values: [],
|
|
197
|
+
},
|
|
198
|
+
loading: {
|
|
199
|
+
attribute: 'data-loading',
|
|
200
|
+
presence: true,
|
|
201
|
+
values: [],
|
|
202
|
+
},
|
|
203
|
+
modal: {
|
|
204
|
+
attribute: 'data-modal',
|
|
205
|
+
presence: true,
|
|
206
|
+
values: [],
|
|
207
|
+
},
|
|
208
|
+
multiple: {
|
|
209
|
+
attribute: 'data-multiple',
|
|
210
|
+
presence: true,
|
|
211
|
+
values: [],
|
|
212
|
+
},
|
|
213
|
+
nested: {
|
|
214
|
+
attribute: 'data-nested',
|
|
215
|
+
presence: true,
|
|
216
|
+
values: [],
|
|
217
|
+
},
|
|
218
|
+
nestedDialogOpen: {
|
|
219
|
+
attribute: 'data-nested-dialog-open',
|
|
220
|
+
presence: true,
|
|
221
|
+
values: [],
|
|
222
|
+
},
|
|
223
|
+
nestedDrawerOpen: {
|
|
224
|
+
attribute: 'data-nested-drawer-open',
|
|
225
|
+
presence: true,
|
|
226
|
+
values: [],
|
|
227
|
+
},
|
|
228
|
+
nestedDrawerSwiping: {
|
|
229
|
+
attribute: 'data-nested-drawer-swiping',
|
|
230
|
+
presence: true,
|
|
231
|
+
values: [],
|
|
232
|
+
},
|
|
233
|
+
open: {
|
|
234
|
+
attribute: 'data-open',
|
|
235
|
+
presence: true,
|
|
236
|
+
values: [],
|
|
237
|
+
},
|
|
238
|
+
orientation: {
|
|
239
|
+
attribute: 'data-orientation',
|
|
240
|
+
presence: false,
|
|
241
|
+
values: ['horizontal', 'vertical'],
|
|
242
|
+
},
|
|
243
|
+
overflowXEnd: {
|
|
244
|
+
attribute: 'data-overflow-x-end',
|
|
245
|
+
presence: true,
|
|
246
|
+
values: [],
|
|
247
|
+
},
|
|
248
|
+
overflowXStart: {
|
|
249
|
+
attribute: 'data-overflow-x-start',
|
|
250
|
+
presence: true,
|
|
251
|
+
values: [],
|
|
252
|
+
},
|
|
253
|
+
overflowYEnd: {
|
|
254
|
+
attribute: 'data-overflow-y-end',
|
|
255
|
+
presence: true,
|
|
256
|
+
values: [],
|
|
257
|
+
},
|
|
258
|
+
overflowYStart: {
|
|
259
|
+
attribute: 'data-overflow-y-start',
|
|
260
|
+
presence: true,
|
|
261
|
+
values: [],
|
|
262
|
+
},
|
|
263
|
+
panelOpen: {
|
|
264
|
+
attribute: 'data-panel-open',
|
|
265
|
+
presence: true,
|
|
266
|
+
values: [],
|
|
267
|
+
},
|
|
268
|
+
placeholder: {
|
|
269
|
+
attribute: 'data-placeholder',
|
|
270
|
+
presence: true,
|
|
271
|
+
values: [],
|
|
272
|
+
},
|
|
273
|
+
popupOpen: {
|
|
274
|
+
attribute: 'data-popup-open',
|
|
275
|
+
presence: true,
|
|
276
|
+
values: [],
|
|
277
|
+
},
|
|
278
|
+
popupSide: {
|
|
279
|
+
attribute: 'data-popup-side',
|
|
280
|
+
presence: false,
|
|
281
|
+
values: ['top', 'bottom', 'left', 'right', 'inline-end', 'inline-start'],
|
|
282
|
+
},
|
|
283
|
+
pressed: {
|
|
284
|
+
attribute: 'data-pressed',
|
|
285
|
+
presence: true,
|
|
286
|
+
values: [],
|
|
287
|
+
},
|
|
288
|
+
previous: {
|
|
289
|
+
attribute: 'data-previous',
|
|
290
|
+
presence: true,
|
|
291
|
+
selector: '& > [data-previous]',
|
|
292
|
+
values: [],
|
|
293
|
+
},
|
|
294
|
+
progressing: {
|
|
295
|
+
attribute: 'data-progressing',
|
|
296
|
+
presence: true,
|
|
297
|
+
values: [],
|
|
298
|
+
},
|
|
299
|
+
readonly: {
|
|
300
|
+
attribute: 'data-readonly',
|
|
301
|
+
presence: true,
|
|
302
|
+
values: [],
|
|
303
|
+
},
|
|
304
|
+
readOnly: {
|
|
305
|
+
attribute: 'data-readonly',
|
|
306
|
+
presence: true,
|
|
307
|
+
values: [],
|
|
308
|
+
},
|
|
309
|
+
required: {
|
|
310
|
+
attribute: 'data-required',
|
|
311
|
+
presence: true,
|
|
312
|
+
values: [],
|
|
313
|
+
},
|
|
314
|
+
scrolling: {
|
|
315
|
+
attribute: 'data-scrolling',
|
|
316
|
+
presence: true,
|
|
317
|
+
values: [],
|
|
318
|
+
},
|
|
319
|
+
scrubbing: {
|
|
320
|
+
attribute: 'data-scrubbing',
|
|
321
|
+
presence: true,
|
|
322
|
+
values: [],
|
|
323
|
+
},
|
|
324
|
+
selected: {
|
|
325
|
+
attribute: 'data-selected',
|
|
326
|
+
presence: true,
|
|
327
|
+
values: [],
|
|
328
|
+
},
|
|
329
|
+
side: {
|
|
330
|
+
attribute: 'data-side',
|
|
331
|
+
presence: false,
|
|
332
|
+
values: [
|
|
333
|
+
'top',
|
|
334
|
+
'bottom',
|
|
335
|
+
'left',
|
|
336
|
+
'right',
|
|
337
|
+
'inline-end',
|
|
338
|
+
'inline-start',
|
|
339
|
+
'none',
|
|
340
|
+
],
|
|
341
|
+
},
|
|
342
|
+
startingStyle: {
|
|
343
|
+
attribute: 'data-starting-style',
|
|
344
|
+
presence: true,
|
|
345
|
+
values: [],
|
|
346
|
+
},
|
|
347
|
+
swipeDirection: {
|
|
348
|
+
attribute: 'data-swipe-direction',
|
|
349
|
+
presence: false,
|
|
350
|
+
values: ['left', 'right', 'up', 'down'],
|
|
351
|
+
},
|
|
352
|
+
swipeDismiss: {
|
|
353
|
+
attribute: 'data-swipe-dismiss',
|
|
354
|
+
presence: true,
|
|
355
|
+
values: [],
|
|
356
|
+
},
|
|
357
|
+
swiping: {
|
|
358
|
+
attribute: 'data-swiping',
|
|
359
|
+
presence: true,
|
|
360
|
+
values: [],
|
|
361
|
+
},
|
|
362
|
+
touched: {
|
|
363
|
+
attribute: 'data-touched',
|
|
364
|
+
presence: true,
|
|
365
|
+
values: [],
|
|
366
|
+
},
|
|
367
|
+
transitioning: {
|
|
368
|
+
attribute: 'data-transitioning',
|
|
369
|
+
presence: true,
|
|
370
|
+
values: [],
|
|
371
|
+
},
|
|
372
|
+
triggerDisabled: {
|
|
373
|
+
attribute: 'data-trigger-disabled',
|
|
374
|
+
presence: true,
|
|
375
|
+
values: [],
|
|
376
|
+
},
|
|
377
|
+
type: {
|
|
378
|
+
attribute: 'data-type',
|
|
379
|
+
presence: false,
|
|
380
|
+
values: [],
|
|
381
|
+
domain: 'string',
|
|
382
|
+
},
|
|
383
|
+
uncentered: {
|
|
384
|
+
attribute: 'data-uncentered',
|
|
385
|
+
presence: true,
|
|
386
|
+
values: [],
|
|
387
|
+
},
|
|
388
|
+
unchecked: {
|
|
389
|
+
attribute: 'data-unchecked',
|
|
390
|
+
presence: true,
|
|
391
|
+
values: [],
|
|
392
|
+
},
|
|
393
|
+
valid: {
|
|
394
|
+
attribute: 'data-valid',
|
|
395
|
+
presence: true,
|
|
396
|
+
values: [],
|
|
397
|
+
},
|
|
398
|
+
visible: {
|
|
399
|
+
attribute: 'data-visible',
|
|
400
|
+
presence: true,
|
|
401
|
+
values: [],
|
|
402
|
+
},
|
|
403
|
+
} as const
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/** Expands documented Base UI states for untransformed web authoring. @module */
|
|
2
|
+
import * as Attributes from './Attributes.generated.js'
|
|
3
|
+
import * as Style from '../../../Style.js'
|
|
4
|
+
import type { style } from '../../../styleFunction.js'
|
|
5
|
+
import * as Token from '../../../internal/Token.js'
|
|
6
|
+
|
|
7
|
+
type Attribute = {
|
|
8
|
+
readonly attribute: string
|
|
9
|
+
readonly domain?: 'number' | 'string'
|
|
10
|
+
readonly presence: boolean
|
|
11
|
+
readonly selector?: string
|
|
12
|
+
readonly values: readonly string[]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Matches css::string::encode so CSS-only identities agree with the compiler.
|
|
16
|
+
function quote(value: string): string {
|
|
17
|
+
let result = '"'
|
|
18
|
+
let spaceBeforeHex = false
|
|
19
|
+
|
|
20
|
+
for (const code of value) {
|
|
21
|
+
const point = code.codePointAt(0)!
|
|
22
|
+
if (point === 0)
|
|
23
|
+
throw new Style.InvalidError([
|
|
24
|
+
{
|
|
25
|
+
code: 'invalid_structure',
|
|
26
|
+
message: 'Base UI state values cannot contain NUL.',
|
|
27
|
+
path: [],
|
|
28
|
+
},
|
|
29
|
+
])
|
|
30
|
+
|
|
31
|
+
if (point <= 0x1f || point === 0x7f) {
|
|
32
|
+
result += `\\${point.toString(16)}`
|
|
33
|
+
spaceBeforeHex = true
|
|
34
|
+
} else if (code === '"' || code === '\\') {
|
|
35
|
+
result += `\\${code}`
|
|
36
|
+
spaceBeforeHex = false
|
|
37
|
+
} else {
|
|
38
|
+
if (spaceBeforeHex && /[\da-fA-F\t\n\f\r ]/u.test(code)) result += ' '
|
|
39
|
+
result += code
|
|
40
|
+
spaceBeforeHex = false
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return `${result}"`
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function record(value: unknown): Record<string, unknown> {
|
|
48
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
49
|
+
throw new Style.InvalidError([
|
|
50
|
+
{
|
|
51
|
+
code: 'invalid_structure',
|
|
52
|
+
message: 'Base UI styles require static object bodies.',
|
|
53
|
+
path: [],
|
|
54
|
+
},
|
|
55
|
+
])
|
|
56
|
+
|
|
57
|
+
return value as Record<string, unknown>
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function lower(input: unknown, depth = 0): Record<string, unknown> {
|
|
61
|
+
if (depth > 64)
|
|
62
|
+
throw new Style.InvalidError([
|
|
63
|
+
{
|
|
64
|
+
code: 'invalid_structure',
|
|
65
|
+
message: 'Base UI style nesting exceeds 64 levels.',
|
|
66
|
+
path: [],
|
|
67
|
+
},
|
|
68
|
+
])
|
|
69
|
+
|
|
70
|
+
const result: Record<string, unknown> = {}
|
|
71
|
+
const insert = (selector: string, value: unknown) => {
|
|
72
|
+
let key = selector
|
|
73
|
+
let occurrence = 1
|
|
74
|
+
// Distinct condition entries retain their position without changing specificity.
|
|
75
|
+
while (Object.hasOwn(result, key))
|
|
76
|
+
key = `${selector}/*base-ui-${occurrence++}*/`
|
|
77
|
+
|
|
78
|
+
result[key] = lower(value, depth + 1)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
for (const [key, value] of Object.entries(record(input))) {
|
|
82
|
+
if (key === 'states') {
|
|
83
|
+
for (const [name, body] of Object.entries(record(value))) {
|
|
84
|
+
const attribute = (
|
|
85
|
+
Attributes.attributes as Readonly<Record<string, Attribute>>
|
|
86
|
+
)[name]
|
|
87
|
+
if (!attribute)
|
|
88
|
+
throw new Style.InvalidError([
|
|
89
|
+
{
|
|
90
|
+
code: 'invalid_structure',
|
|
91
|
+
message: `Unknown Base UI state: ${name}.`,
|
|
92
|
+
path: ['states', name],
|
|
93
|
+
},
|
|
94
|
+
])
|
|
95
|
+
|
|
96
|
+
const choices = Object.entries(record(body))
|
|
97
|
+
// A few parts expose presence-only `instant`, others expose a finite value.
|
|
98
|
+
// A shorthand can share a value key, but its scalar/token is not a declaration body.
|
|
99
|
+
// The compiler checks the component-specific domain.
|
|
100
|
+
if (
|
|
101
|
+
attribute.presence &&
|
|
102
|
+
!choices.some(
|
|
103
|
+
(entry) =>
|
|
104
|
+
attribute.values.includes(entry[0]) &&
|
|
105
|
+
entry[1] !== null &&
|
|
106
|
+
typeof entry[1] === 'object' &&
|
|
107
|
+
!Array.isArray(entry[1]) &&
|
|
108
|
+
!Token.is(entry[1]) &&
|
|
109
|
+
!Token.isExpression(entry[1]),
|
|
110
|
+
)
|
|
111
|
+
) {
|
|
112
|
+
insert(attribute.selector ?? `&[${attribute.attribute}]`, body)
|
|
113
|
+
continue
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
for (const [choice, declarations] of choices) {
|
|
117
|
+
if (
|
|
118
|
+
attribute.domain === 'number'
|
|
119
|
+
? !Number.isFinite(Number(choice)) ||
|
|
120
|
+
String(Number(choice)) !== choice
|
|
121
|
+
: attribute.domain !== 'string' &&
|
|
122
|
+
!attribute.values.includes(choice)
|
|
123
|
+
)
|
|
124
|
+
throw new Style.InvalidError([
|
|
125
|
+
{
|
|
126
|
+
code: 'invalid_structure',
|
|
127
|
+
message: `Unknown Base UI state value: ${name}.${choice}.`,
|
|
128
|
+
path: ['states', name, choice],
|
|
129
|
+
},
|
|
130
|
+
])
|
|
131
|
+
|
|
132
|
+
insert(`&[${attribute.attribute}=${quote(choice)}]`, declarations)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
} else if (key === 'selectors') {
|
|
136
|
+
for (const [selector, declarations] of Object.entries(record(value)))
|
|
137
|
+
insert(selector, declarations)
|
|
138
|
+
} else if (key.startsWith('@') || key.startsWith(':') || key.includes('&'))
|
|
139
|
+
insert(key, value)
|
|
140
|
+
else if (key === 'targets') {
|
|
141
|
+
const targets = record(value)
|
|
142
|
+
result[key] = Object.fromEntries(
|
|
143
|
+
Object.entries(targets).map((entry) => [
|
|
144
|
+
entry[0],
|
|
145
|
+
entry[0] === 'web' ? lower(entry[1], depth + 1) : entry[1],
|
|
146
|
+
]),
|
|
147
|
+
)
|
|
148
|
+
} else result[key] = value
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return result
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** Adds component-first static authoring without loading or registering components. */
|
|
155
|
+
export function bind(factory: bind.Factory): bind.Factory {
|
|
156
|
+
return (...args) => {
|
|
157
|
+
const first = args[0]
|
|
158
|
+
const component =
|
|
159
|
+
args.length >= 2 &&
|
|
160
|
+
first !== null &&
|
|
161
|
+
typeof first === 'object' &&
|
|
162
|
+
'$$typeof' in first
|
|
163
|
+
if (!component) return factory(...args)
|
|
164
|
+
|
|
165
|
+
return factory(lower(args[1]), args[2])
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Runtime callable boundary. Public authoring retains its overloads separately. */
|
|
170
|
+
export declare namespace bind {
|
|
171
|
+
/** Style implementation accepting the existing authoring arguments. */
|
|
172
|
+
type Factory = (...args: readonly unknown[]) => style.ReturnType<style.Output>
|
|
173
|
+
}
|