@primitiv-ui/web 0.1.43 → 0.1.44
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/README.md +49 -6
- package/dist/accordion/AccordionController.d.ts +33 -0
- package/dist/accordion/AccordionController.js +41 -0
- package/dist/accordion/elements.d.ts +79 -0
- package/dist/accordion/elements.js +194 -0
- package/dist/accordion/index.d.ts +2 -0
- package/dist/accordion/index.js +2 -0
- package/dist/cdn/accordion.js +1 -0
- package/dist/cdn/chunks/chunk-FKLOMAT4.js +1 -0
- package/dist/cdn/tabs.js +1 -1
- package/dist/custom-elements.json +308 -48
- package/dist/define/accordion.d.ts +1 -0
- package/dist/define/accordion.js +11 -0
- package/dist/define/index.d.ts +1 -0
- package/dist/define/index.js +1 -0
- package/dist/frameworks/events.d.ts +4 -0
- package/dist/frameworks/react.d.ts +20 -2
- package/dist/frameworks/svelte.d.ts +19 -1
- package/dist/frameworks/vue.d.ts +20 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/RootElement.d.ts +46 -0
- package/dist/internal/RootElement.js +59 -0
- package/dist/internal/TriggerController.d.ts +52 -0
- package/dist/internal/TriggerController.js +76 -0
- package/dist/internal/element.d.ts +38 -0
- package/dist/internal/element.js +60 -0
- package/dist/primitiv-web.js +1 -1
- package/dist/tabs/TabsController.d.ts +6 -31
- package/dist/tabs/TabsController.js +11 -79
- package/dist/tabs/elements.d.ts +13 -26
- package/dist/tabs/elements.js +22 -100
- package/dist/tags.d.ts +6 -0
- package/package.json +10 -2
|
@@ -4,21 +4,297 @@
|
|
|
4
4
|
"modules": [
|
|
5
5
|
{
|
|
6
6
|
"kind": "javascript-module",
|
|
7
|
-
"path": "src/
|
|
7
|
+
"path": "src/accordion/elements.ts",
|
|
8
8
|
"declarations": [
|
|
9
9
|
{
|
|
10
10
|
"kind": "class",
|
|
11
|
-
"description": "`<primitiv-
|
|
12
|
-
"name": "
|
|
11
|
+
"description": "`<primitiv-accordion>` — the state owner of a WAI-ARIA accordion.\n\nThe root finds its own items, so an accordion nested in a panel keeps its\nown, and reconciles every part's ARIA from its reflected state whenever a part\narrives, leaves, or changes an attribute the root reads (the lifecycle is\n`PrimitivRootElement`'s). `multiple` is read live at each toggle, so a change\nto it needs no reconcile.\n\nEach trigger sits in a heading you write (`<h3>`, at the level the page's\noutline needs): a real heading element is the header, so there is no element\nfor it.",
|
|
12
|
+
"name": "PrimitivAccordionElement",
|
|
13
13
|
"members": [
|
|
14
14
|
{
|
|
15
15
|
"kind": "field",
|
|
16
|
-
"name": "#
|
|
16
|
+
"name": "#shown",
|
|
17
|
+
"privacy": "private",
|
|
18
|
+
"default": "new Set<string>()",
|
|
19
|
+
"description": "The items open at the last reconcile, so an item opening fires primitiv-accordion-show."
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"kind": "field",
|
|
23
|
+
"name": "#rendered",
|
|
17
24
|
"privacy": "private",
|
|
18
25
|
"type": {
|
|
19
|
-
"text": "
|
|
26
|
+
"text": "boolean"
|
|
27
|
+
},
|
|
28
|
+
"default": "false"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"kind": "field",
|
|
32
|
+
"name": "controller",
|
|
33
|
+
"type": {
|
|
34
|
+
"text": "AccordionController"
|
|
35
|
+
},
|
|
36
|
+
"privacy": "protected",
|
|
37
|
+
"readonly": true,
|
|
38
|
+
"default": "new AccordionController(this, this.#host())"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"kind": "field",
|
|
42
|
+
"name": "reconcileOn",
|
|
43
|
+
"type": {
|
|
44
|
+
"text": "readonly string[]"
|
|
45
|
+
},
|
|
46
|
+
"privacy": "protected",
|
|
47
|
+
"readonly": true,
|
|
48
|
+
"default": "[\"value\", \"disabled\", \"orientation\", \"force-mount\"]"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"kind": "field",
|
|
52
|
+
"name": "value",
|
|
53
|
+
"type": {
|
|
54
|
+
"text": "string[]"
|
|
55
|
+
},
|
|
56
|
+
"description": "Set the open items, as an array or a space-separated string."
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"kind": "method",
|
|
60
|
+
"name": "#host",
|
|
61
|
+
"privacy": "private",
|
|
62
|
+
"return": {
|
|
63
|
+
"type": {
|
|
64
|
+
"text": "AccordionControllerHost"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"description": "The controller's view of this element: state lives in reflected attributes."
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"kind": "method",
|
|
71
|
+
"name": "#orientation",
|
|
72
|
+
"privacy": "private",
|
|
73
|
+
"return": {
|
|
74
|
+
"type": {
|
|
75
|
+
"text": "AccordionOrientation"
|
|
76
|
+
}
|
|
20
77
|
}
|
|
21
78
|
},
|
|
79
|
+
{
|
|
80
|
+
"kind": "method",
|
|
81
|
+
"name": "reconcile",
|
|
82
|
+
"privacy": "protected",
|
|
83
|
+
"return": {
|
|
84
|
+
"type": {
|
|
85
|
+
"text": "void"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
"events": [
|
|
91
|
+
{
|
|
92
|
+
"type": {
|
|
93
|
+
"text": "CustomEvent<{ value: string[] }>"
|
|
94
|
+
},
|
|
95
|
+
"description": "Bubbles, cancelable, fired before a user-driven toggle is applied, with every item open afterwards. Call `preventDefault()` to veto it.",
|
|
96
|
+
"name": "primitiv-accordion-change"
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
"attributes": [
|
|
100
|
+
{
|
|
101
|
+
"type": {
|
|
102
|
+
"text": "string"
|
|
103
|
+
},
|
|
104
|
+
"description": "The open items' values, separated by spaces. Reflected: it changes as the user toggles items, so a server re-render or a history snapshot sees what is open. Item values therefore cannot contain whitespace.",
|
|
105
|
+
"name": "value"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"type": {
|
|
109
|
+
"text": "boolean"
|
|
110
|
+
},
|
|
111
|
+
"description": "Lets more than one item be open at once. Without it, opening an item closes the open one.",
|
|
112
|
+
"name": "multiple"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"type": {
|
|
116
|
+
"text": "\"vertical\" | \"horizontal\""
|
|
117
|
+
},
|
|
118
|
+
"description": "Layout axis, which picks the arrow-key pair. Defaults to `vertical`.",
|
|
119
|
+
"name": "orientation"
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
"superclass": {
|
|
123
|
+
"name": "PrimitivRootElement",
|
|
124
|
+
"module": "/src/internal/RootElement.ts"
|
|
125
|
+
},
|
|
126
|
+
"tagName": "primitiv-accordion",
|
|
127
|
+
"customElement": true,
|
|
128
|
+
"summary": "The state owner of a WAI-ARIA accordion."
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"kind": "class",
|
|
132
|
+
"description": "`<primitiv-accordion-item>` — one collapsible section. Structural: it pairs a\ntrigger and a panel and carries the value the root's `value` lists.",
|
|
133
|
+
"name": "PrimitivAccordionItemElement",
|
|
134
|
+
"attributes": [
|
|
135
|
+
{
|
|
136
|
+
"type": {
|
|
137
|
+
"text": "string"
|
|
138
|
+
},
|
|
139
|
+
"description": "The item's value, listed in the root's `value` while it is open. No whitespace.",
|
|
140
|
+
"name": "value"
|
|
141
|
+
}
|
|
142
|
+
],
|
|
143
|
+
"superclass": {
|
|
144
|
+
"name": "ElementBase",
|
|
145
|
+
"module": "/src/internal/element.ts"
|
|
146
|
+
},
|
|
147
|
+
"tagName": "primitiv-accordion-item",
|
|
148
|
+
"customElement": true
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"kind": "class",
|
|
152
|
+
"description": "`<primitiv-accordion-trigger>` — an interactive part. It decorates exactly one\nchild the consumer writes, a `<button>`, which receives `aria-expanded`,\n`aria-controls` and the state attributes, so the rendered DOM matches React's\n`<button aria-expanded>` (RFC 0033 D24). Put it inside a heading.",
|
|
153
|
+
"name": "PrimitivAccordionTriggerElement",
|
|
154
|
+
"attributes": [
|
|
155
|
+
{
|
|
156
|
+
"type": {
|
|
157
|
+
"text": "boolean"
|
|
158
|
+
},
|
|
159
|
+
"description": "Marks the item disabled: the button stays focusable but never toggles, and the arrow keys skip it.",
|
|
160
|
+
"name": "disabled"
|
|
161
|
+
}
|
|
162
|
+
],
|
|
163
|
+
"superclass": {
|
|
164
|
+
"name": "ElementBase",
|
|
165
|
+
"module": "/src/internal/element.ts"
|
|
166
|
+
},
|
|
167
|
+
"tagName": "primitiv-accordion-trigger",
|
|
168
|
+
"customElement": true
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"kind": "class",
|
|
172
|
+
"description": "`<primitiv-accordion-content>` — an item's panel. Structural: the root writes\nits ARIA and hides it while the item is closed.",
|
|
173
|
+
"name": "PrimitivAccordionContentElement",
|
|
174
|
+
"events": [
|
|
175
|
+
{
|
|
176
|
+
"type": {
|
|
177
|
+
"text": "CustomEvent"
|
|
178
|
+
},
|
|
179
|
+
"description": "Bubbles from the panel as its item opens (not on first render), so a lazy panel can fetch its content.",
|
|
180
|
+
"name": "primitiv-accordion-show"
|
|
181
|
+
}
|
|
182
|
+
],
|
|
183
|
+
"attributes": [
|
|
184
|
+
{
|
|
185
|
+
"type": {
|
|
186
|
+
"text": "boolean"
|
|
187
|
+
},
|
|
188
|
+
"description": "Never sets `hidden`, so styles can animate the panel open and closed. A closed panel always carries `aria-hidden`, so it stays out of the accessibility tree either way.",
|
|
189
|
+
"name": "force-mount"
|
|
190
|
+
}
|
|
191
|
+
],
|
|
192
|
+
"superclass": {
|
|
193
|
+
"name": "ElementBase",
|
|
194
|
+
"module": "/src/internal/element.ts"
|
|
195
|
+
},
|
|
196
|
+
"tagName": "primitiv-accordion-content",
|
|
197
|
+
"customElement": true
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"kind": "class",
|
|
201
|
+
"description": "`<primitiv-accordion-trigger-icon>` — a decorative indicator inside the\ntrigger's button. The root hides it from assistive technology and mirrors its\nitem's `data-state`, for a chevron that flips.",
|
|
202
|
+
"name": "PrimitivAccordionTriggerIconElement",
|
|
203
|
+
"superclass": {
|
|
204
|
+
"name": "ElementBase",
|
|
205
|
+
"module": "/src/internal/element.ts"
|
|
206
|
+
},
|
|
207
|
+
"tagName": "primitiv-accordion-trigger-icon",
|
|
208
|
+
"customElement": true
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"kind": "function",
|
|
212
|
+
"name": "defineAccordion",
|
|
213
|
+
"return": {
|
|
214
|
+
"type": {
|
|
215
|
+
"text": "void"
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
"parameters": [
|
|
219
|
+
{
|
|
220
|
+
"name": "registry",
|
|
221
|
+
"default": "globalThis.customElements",
|
|
222
|
+
"type": {
|
|
223
|
+
"text": "ElementRegistry | undefined"
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
],
|
|
227
|
+
"description": "Define the five Accordion elements on `registry` (the global `customElements`\nby default). Safe to call more than once, and a no-op where there is no\nregistry (a server render)."
|
|
228
|
+
}
|
|
229
|
+
],
|
|
230
|
+
"exports": [
|
|
231
|
+
{
|
|
232
|
+
"kind": "js",
|
|
233
|
+
"name": "ElementRegistry",
|
|
234
|
+
"declaration": {
|
|
235
|
+
"name": "ElementRegistry",
|
|
236
|
+
"module": "src/accordion/elements.ts"
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
"kind": "js",
|
|
241
|
+
"name": "PrimitivAccordionElement",
|
|
242
|
+
"declaration": {
|
|
243
|
+
"name": "PrimitivAccordionElement",
|
|
244
|
+
"module": "src/accordion/elements.ts"
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"kind": "js",
|
|
249
|
+
"name": "PrimitivAccordionItemElement",
|
|
250
|
+
"declaration": {
|
|
251
|
+
"name": "PrimitivAccordionItemElement",
|
|
252
|
+
"module": "src/accordion/elements.ts"
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"kind": "js",
|
|
257
|
+
"name": "PrimitivAccordionTriggerElement",
|
|
258
|
+
"declaration": {
|
|
259
|
+
"name": "PrimitivAccordionTriggerElement",
|
|
260
|
+
"module": "src/accordion/elements.ts"
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"kind": "js",
|
|
265
|
+
"name": "PrimitivAccordionContentElement",
|
|
266
|
+
"declaration": {
|
|
267
|
+
"name": "PrimitivAccordionContentElement",
|
|
268
|
+
"module": "src/accordion/elements.ts"
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"kind": "js",
|
|
273
|
+
"name": "PrimitivAccordionTriggerIconElement",
|
|
274
|
+
"declaration": {
|
|
275
|
+
"name": "PrimitivAccordionTriggerIconElement",
|
|
276
|
+
"module": "src/accordion/elements.ts"
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
"kind": "js",
|
|
281
|
+
"name": "defineAccordion",
|
|
282
|
+
"declaration": {
|
|
283
|
+
"name": "defineAccordion",
|
|
284
|
+
"module": "src/accordion/elements.ts"
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
]
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"kind": "javascript-module",
|
|
291
|
+
"path": "src/tabs/elements.ts",
|
|
292
|
+
"declarations": [
|
|
293
|
+
{
|
|
294
|
+
"kind": "class",
|
|
295
|
+
"description": "`<primitiv-tabs>` — the state owner of a WAI-ARIA tab set.\n\nThe root finds its own parts, so a tab set nested in a panel keeps its own,\nand reconciles their ARIA from its reflected state whenever a part arrives,\nleaves, or changes an attribute the root reads (the lifecycle is\n`PrimitivRootElement`'s). `activation-mode` is read live at each key press,\nso a change to it needs no reconcile.",
|
|
296
|
+
"name": "PrimitivTabsElement",
|
|
297
|
+
"members": [
|
|
22
298
|
{
|
|
23
299
|
"kind": "field",
|
|
24
300
|
"name": "#shown",
|
|
@@ -39,18 +315,23 @@
|
|
|
39
315
|
},
|
|
40
316
|
{
|
|
41
317
|
"kind": "field",
|
|
42
|
-
"name": "
|
|
43
|
-
"
|
|
318
|
+
"name": "controller",
|
|
319
|
+
"type": {
|
|
320
|
+
"text": "TabsController"
|
|
321
|
+
},
|
|
322
|
+
"privacy": "protected",
|
|
44
323
|
"readonly": true,
|
|
45
324
|
"default": "new TabsController(this, this.#host())"
|
|
46
325
|
},
|
|
47
326
|
{
|
|
48
327
|
"kind": "field",
|
|
49
|
-
"name": "
|
|
50
|
-
"
|
|
328
|
+
"name": "reconcileOn",
|
|
329
|
+
"type": {
|
|
330
|
+
"text": "readonly string[]"
|
|
331
|
+
},
|
|
332
|
+
"privacy": "protected",
|
|
51
333
|
"readonly": true,
|
|
52
|
-
"default": "
|
|
53
|
-
"description": "Watches the subtree for parts arriving, leaving, or changing the attributes\nthe root reads. The root's own writes (role, aria-*, ids, data-*) are not in\nthe filter, so reconciling never re-triggers itself."
|
|
334
|
+
"default": "[\"value\", \"disabled\", \"label\", \"orientation\"]"
|
|
54
335
|
},
|
|
55
336
|
{
|
|
56
337
|
"kind": "field",
|
|
@@ -69,7 +350,7 @@
|
|
|
69
350
|
"text": "TabsControllerHost"
|
|
70
351
|
}
|
|
71
352
|
},
|
|
72
|
-
"description": "The controller's view of this element
|
|
353
|
+
"description": "The controller's view of this element: state lives in reflected attributes."
|
|
73
354
|
},
|
|
74
355
|
{
|
|
75
356
|
"kind": "method",
|
|
@@ -93,37 +374,8 @@
|
|
|
93
374
|
},
|
|
94
375
|
{
|
|
95
376
|
"kind": "method",
|
|
96
|
-
"name": "
|
|
97
|
-
"privacy": "
|
|
98
|
-
"return": {
|
|
99
|
-
"type": {
|
|
100
|
-
"text": "HTMLElement[]"
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
"parameters": [
|
|
104
|
-
{
|
|
105
|
-
"name": "selector",
|
|
106
|
-
"type": {
|
|
107
|
-
"text": "string"
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
],
|
|
111
|
-
"description": "Parts of this tab set only, never those of a nested one."
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
"kind": "method",
|
|
115
|
-
"name": "#rootId",
|
|
116
|
-
"privacy": "private",
|
|
117
|
-
"return": {
|
|
118
|
-
"type": {
|
|
119
|
-
"text": "string"
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
"kind": "method",
|
|
125
|
-
"name": "#reconcile",
|
|
126
|
-
"privacy": "private",
|
|
377
|
+
"name": "reconcile",
|
|
378
|
+
"privacy": "protected",
|
|
127
379
|
"return": {
|
|
128
380
|
"type": {
|
|
129
381
|
"text": "void"
|
|
@@ -164,8 +416,8 @@
|
|
|
164
416
|
}
|
|
165
417
|
],
|
|
166
418
|
"superclass": {
|
|
167
|
-
"name": "
|
|
168
|
-
"module": "src/
|
|
419
|
+
"name": "PrimitivRootElement",
|
|
420
|
+
"module": "/src/internal/RootElement.ts"
|
|
169
421
|
},
|
|
170
422
|
"tagName": "primitiv-tabs",
|
|
171
423
|
"customElement": true,
|
|
@@ -186,7 +438,7 @@
|
|
|
186
438
|
],
|
|
187
439
|
"superclass": {
|
|
188
440
|
"name": "ElementBase",
|
|
189
|
-
"module": "src/
|
|
441
|
+
"module": "/src/internal/element.ts"
|
|
190
442
|
},
|
|
191
443
|
"tagName": "primitiv-tabs-list",
|
|
192
444
|
"customElement": true
|
|
@@ -213,7 +465,7 @@
|
|
|
213
465
|
],
|
|
214
466
|
"superclass": {
|
|
215
467
|
"name": "ElementBase",
|
|
216
|
-
"module": "src/
|
|
468
|
+
"module": "/src/internal/element.ts"
|
|
217
469
|
},
|
|
218
470
|
"tagName": "primitiv-tabs-trigger",
|
|
219
471
|
"customElement": true
|
|
@@ -242,7 +494,7 @@
|
|
|
242
494
|
],
|
|
243
495
|
"superclass": {
|
|
244
496
|
"name": "ElementBase",
|
|
245
|
-
"module": "src/
|
|
497
|
+
"module": "/src/internal/element.ts"
|
|
246
498
|
},
|
|
247
499
|
"tagName": "primitiv-tabs-content",
|
|
248
500
|
"customElement": true
|
|
@@ -268,6 +520,14 @@
|
|
|
268
520
|
}
|
|
269
521
|
],
|
|
270
522
|
"exports": [
|
|
523
|
+
{
|
|
524
|
+
"kind": "js",
|
|
525
|
+
"name": "ElementRegistry",
|
|
526
|
+
"declaration": {
|
|
527
|
+
"name": "ElementRegistry",
|
|
528
|
+
"module": "src/tabs/elements.ts"
|
|
529
|
+
}
|
|
530
|
+
},
|
|
271
531
|
{
|
|
272
532
|
"kind": "js",
|
|
273
533
|
"name": "PrimitivTabsElement",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Side-effect entry: importing this module defines the five Accordion elements
|
|
3
|
+
* (`<primitiv-accordion>`, `-item`, `-trigger`, `-content`, `-trigger-icon`) on
|
|
4
|
+
* the global `customElements` registry.
|
|
5
|
+
*
|
|
6
|
+
* ```html
|
|
7
|
+
* <script type="module">import "@primitiv-ui/web/define/accordion";</script>
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
import { defineAccordion } from "../accordion/elements.js";
|
|
11
|
+
defineAccordion();
|
package/dist/define/index.d.ts
CHANGED
package/dist/define/index.js
CHANGED
|
@@ -7,3 +7,7 @@ export type PrimitivTabsChangeEvent = CustomEvent<{
|
|
|
7
7
|
value: string;
|
|
8
8
|
index: number;
|
|
9
9
|
}>;
|
|
10
|
+
/** The `primitiv-accordion-change` event: bubbles, cancelable, fired before the change applies, with every item open afterwards. */
|
|
11
|
+
export type PrimitivAccordionChangeEvent = CustomEvent<{
|
|
12
|
+
value: string[];
|
|
13
|
+
}>;
|
|
@@ -18,16 +18,34 @@
|
|
|
18
18
|
* which JSR does not allow a published module to do.
|
|
19
19
|
*/
|
|
20
20
|
import type { DetailedHTMLProps, HTMLAttributes } from "react";
|
|
21
|
+
import type { PrimitivAccordionContentElement, PrimitivAccordionElement, PrimitivAccordionItemElement, PrimitivAccordionTriggerElement, PrimitivAccordionTriggerIconElement } from "../accordion/elements.js";
|
|
21
22
|
import type { PrimitivTabsContentElement, PrimitivTabsElement, PrimitivTabsListElement, PrimitivTabsTriggerElement } from "../tabs/elements.js";
|
|
22
|
-
import type { PrimitivTabsChangeEvent } from "./events.js";
|
|
23
|
+
import type { PrimitivAccordionChangeEvent, PrimitivTabsChangeEvent } from "./events.js";
|
|
23
24
|
/** React's own props for an element, plus `class`, which React 19 passes to custom elements. */
|
|
24
25
|
type ElementProps<E extends HTMLElement> = DetailedHTMLProps<HTMLAttributes<E>, E> & {
|
|
25
26
|
class?: string;
|
|
26
27
|
};
|
|
27
|
-
export type { PrimitivTabsChangeEvent };
|
|
28
|
+
export type { PrimitivAccordionChangeEvent, PrimitivTabsChangeEvent };
|
|
28
29
|
declare module "react" {
|
|
29
30
|
namespace JSX {
|
|
30
31
|
interface IntrinsicElements {
|
|
32
|
+
"primitiv-accordion": ElementProps<PrimitivAccordionElement> & {
|
|
33
|
+
value?: string | readonly string[];
|
|
34
|
+
multiple?: boolean;
|
|
35
|
+
orientation?: "vertical" | "horizontal";
|
|
36
|
+
"onprimitiv-accordion-change"?: (event: PrimitivAccordionChangeEvent) => void;
|
|
37
|
+
};
|
|
38
|
+
"primitiv-accordion-item": ElementProps<PrimitivAccordionItemElement> & {
|
|
39
|
+
value: string;
|
|
40
|
+
};
|
|
41
|
+
"primitiv-accordion-trigger": ElementProps<PrimitivAccordionTriggerElement> & {
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
};
|
|
44
|
+
"primitiv-accordion-content": ElementProps<PrimitivAccordionContentElement> & {
|
|
45
|
+
"force-mount"?: boolean;
|
|
46
|
+
"onprimitiv-accordion-show"?: (event: CustomEvent) => void;
|
|
47
|
+
};
|
|
48
|
+
"primitiv-accordion-trigger-icon": ElementProps<PrimitivAccordionTriggerIconElement>;
|
|
31
49
|
"primitiv-tabs": ElementProps<PrimitivTabsElement> & {
|
|
32
50
|
value?: string;
|
|
33
51
|
orientation?: "horizontal" | "vertical";
|
|
@@ -17,12 +17,30 @@
|
|
|
17
17
|
* JSR does not allow a published module to do.
|
|
18
18
|
*/
|
|
19
19
|
import type { HTMLAttributes } from "svelte/elements";
|
|
20
|
+
import type { PrimitivAccordionContentElement, PrimitivAccordionElement, PrimitivAccordionItemElement, PrimitivAccordionTriggerElement, PrimitivAccordionTriggerIconElement } from "../accordion/elements.js";
|
|
20
21
|
import type { PrimitivTabsContentElement, PrimitivTabsElement, PrimitivTabsListElement, PrimitivTabsTriggerElement } from "../tabs/elements.js";
|
|
21
|
-
import type { PrimitivTabsChangeEvent } from "./events.js";
|
|
22
|
+
import type { PrimitivAccordionChangeEvent, PrimitivTabsChangeEvent } from "./events.js";
|
|
22
23
|
/** Svelte's own attributes and events for an element. */
|
|
23
24
|
type Attributes<E extends HTMLElement> = HTMLAttributes<E>;
|
|
24
25
|
declare module "svelte/elements" {
|
|
25
26
|
interface SvelteHTMLElements {
|
|
27
|
+
"primitiv-accordion": Attributes<PrimitivAccordionElement> & {
|
|
28
|
+
value?: string | readonly string[];
|
|
29
|
+
multiple?: boolean;
|
|
30
|
+
orientation?: "vertical" | "horizontal";
|
|
31
|
+
"onprimitiv-accordion-change"?: (event: PrimitivAccordionChangeEvent) => void;
|
|
32
|
+
};
|
|
33
|
+
"primitiv-accordion-item": Attributes<PrimitivAccordionItemElement> & {
|
|
34
|
+
value: string;
|
|
35
|
+
};
|
|
36
|
+
"primitiv-accordion-trigger": Attributes<PrimitivAccordionTriggerElement> & {
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
};
|
|
39
|
+
"primitiv-accordion-content": Attributes<PrimitivAccordionContentElement> & {
|
|
40
|
+
"force-mount"?: boolean;
|
|
41
|
+
"onprimitiv-accordion-show"?: (event: CustomEvent) => void;
|
|
42
|
+
};
|
|
43
|
+
"primitiv-accordion-trigger-icon": Attributes<PrimitivAccordionTriggerIconElement>;
|
|
26
44
|
"primitiv-tabs": Attributes<PrimitivTabsElement> & {
|
|
27
45
|
value?: string;
|
|
28
46
|
orientation?: "horizontal" | "vertical";
|
package/dist/frameworks/vue.d.ts
CHANGED
|
@@ -19,11 +19,30 @@
|
|
|
19
19
|
* JSR does not allow a published module to do.
|
|
20
20
|
*/
|
|
21
21
|
import type { DefineComponent, EmitsOptions } from "vue";
|
|
22
|
-
import type { PrimitivTabsChangeEvent } from "./events.js";
|
|
22
|
+
import type { PrimitivAccordionChangeEvent, PrimitivTabsChangeEvent } from "./events.js";
|
|
23
23
|
/** A tag as Vue's template checker sees it: its props, and the events it emits. */
|
|
24
24
|
type Tag<Props, Events extends EmitsOptions = Record<never, never>> = DefineComponent<Props, Record<never, never>, Record<never, never>, Record<never, never>, Record<never, never>, Record<never, never>, Record<never, never>, Events>;
|
|
25
25
|
declare module "vue" {
|
|
26
26
|
interface GlobalComponents {
|
|
27
|
+
"primitiv-accordion": Tag<{
|
|
28
|
+
value?: string | readonly string[];
|
|
29
|
+
multiple?: boolean | "";
|
|
30
|
+
orientation?: "vertical" | "horizontal";
|
|
31
|
+
}, {
|
|
32
|
+
"primitiv-accordion-change": (event: PrimitivAccordionChangeEvent) => void;
|
|
33
|
+
}>;
|
|
34
|
+
"primitiv-accordion-item": Tag<{
|
|
35
|
+
value: string;
|
|
36
|
+
}>;
|
|
37
|
+
"primitiv-accordion-trigger": Tag<{
|
|
38
|
+
disabled?: boolean | "";
|
|
39
|
+
}>;
|
|
40
|
+
"primitiv-accordion-content": Tag<{
|
|
41
|
+
forceMount?: boolean | "";
|
|
42
|
+
}, {
|
|
43
|
+
"primitiv-accordion-show": (event: CustomEvent) => void;
|
|
44
|
+
}>;
|
|
45
|
+
"primitiv-accordion-trigger-icon": Tag<Record<never, never>>;
|
|
27
46
|
"primitiv-tabs": Tag<{
|
|
28
47
|
value?: string;
|
|
29
48
|
orientation?: "horizontal" | "vertical";
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ElementBase } from "./element.js";
|
|
2
|
+
/** What a root element hosts: a controller it connects and disconnects with itself. */
|
|
3
|
+
type Connectable = {
|
|
4
|
+
connect(): void;
|
|
5
|
+
disconnect(): void;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The lifecycle every component's root element shares (RFC 0033 §5.4, D11).
|
|
9
|
+
*
|
|
10
|
+
* The root never caches its parts, so markup that arrives later is picked up on
|
|
11
|
+
* the next reconcile. One `MutationObserver` is the only trigger after connect:
|
|
12
|
+
* it sees parts arriving and leaving and every attribute in
|
|
13
|
+
* {@link PrimitivRootElement.reconcileOn | `reconcileOn`}, and it already
|
|
14
|
+
* delivers a task's changes as one callback, so no further batching is needed.
|
|
15
|
+
* The root's own writes (role, aria-*, ids, data-*) stay out of that list, so
|
|
16
|
+
* reconciling never re-triggers itself. Leaving the document stops all
|
|
17
|
+
* listening; a move (an `hx-preserve`, a framework reparenting) is a disconnect
|
|
18
|
+
* followed by a connect, so handlers never stack.
|
|
19
|
+
*
|
|
20
|
+
* A subclass supplies its controller, the attributes it reads, and the
|
|
21
|
+
* reconcile that writes its parts' ARIA. Internal — not an entry point.
|
|
22
|
+
*/
|
|
23
|
+
export declare abstract class PrimitivRootElement extends ElementBase {
|
|
24
|
+
#private;
|
|
25
|
+
/** The behaviour this root hosts, listening while the root is connected. */
|
|
26
|
+
protected abstract readonly controller: Connectable;
|
|
27
|
+
/** The attributes, on the root or any part, whose change needs a reconcile. */
|
|
28
|
+
protected abstract readonly reconcileOn: readonly string[];
|
|
29
|
+
/** Write every part's ARIA and state from the root's reflected attributes. */
|
|
30
|
+
protected abstract reconcile(): void;
|
|
31
|
+
connectedCallback(): void;
|
|
32
|
+
disconnectedCallback(): void;
|
|
33
|
+
/** The root's id, or one generated once, which the parts' ids derive from. */
|
|
34
|
+
protected rootId(): string;
|
|
35
|
+
/** The reading direction, from `:dir()`, so an inherited `dir` attribute applies (D8). */
|
|
36
|
+
protected direction(): "ltr" | "rtl";
|
|
37
|
+
/** This root's `selector` parts, never those of a nested root of the same kind. */
|
|
38
|
+
protected parts(selector: string): HTMLElement[];
|
|
39
|
+
/**
|
|
40
|
+
* Announce a user-driven change as a bubbling, cancelable `type` event fired
|
|
41
|
+
* before it applies, so a listener can veto it — the elements' equivalent of
|
|
42
|
+
* React's controlled mode (D7). Returns `false` when it was vetoed.
|
|
43
|
+
*/
|
|
44
|
+
protected announce(type: string, detail: unknown): boolean;
|
|
45
|
+
}
|
|
46
|
+
export {};
|