@pfern/elements 0.1.11 → 0.2.1
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 +11 -11
- package/README.md +292 -62
- package/elements.js +4 -1942
- package/env.d.ts +24 -0
- package/mathml.js +1 -0
- package/package.json +20 -23
- package/src/core/elements.js +513 -0
- package/src/core/events.js +143 -0
- package/src/core/props.js +183 -0
- package/src/core/tags.js +225 -0
- package/src/core/tick.js +116 -0
- package/src/core/types.js +696 -0
- package/src/helpers.js +73 -0
- package/src/html.js +996 -0
- package/src/mathml.js +340 -0
- package/src/router.js +51 -0
- package/src/ssr.js +173 -0
- package/src/svg.js +407 -0
- package/types/elements.d.ts +4 -1394
- package/types/mathml.d.ts +1 -0
- package/types/src/core/elements.d.ts +29 -0
- package/types/src/core/events.d.ts +15 -0
- package/types/src/core/props.d.ts +9 -0
- package/types/src/core/tags.d.ts +4 -0
- package/types/src/core/tick.d.ts +5 -0
- package/types/src/core/types.d.ts +507 -0
- package/types/src/helpers.d.ts +5 -0
- package/types/src/html.d.ts +802 -0
- package/types/src/mathml.d.ts +264 -0
- package/types/src/router.d.ts +4 -0
- package/types/src/ssr.d.ts +3 -0
- package/types/src/svg.d.ts +348 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/mathml.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export const DEBUG: boolean;
|
|
3
|
+
export function render(vtree: import("./types.js").ElementsVNode, container?: HTMLElement | null, { replace }?: {
|
|
4
|
+
replace?: boolean;
|
|
5
|
+
}): void;
|
|
6
|
+
export function component<Args extends any[]>(fn: (...args: Args) => import("./types.js").ElementsVNode): (...args: Args) => import("./types.js").ElementsVNode;
|
|
7
|
+
/**
|
|
8
|
+
* A map of supported HTML and SVG element helpers.
|
|
9
|
+
*
|
|
10
|
+
* Each helper is a function that accepts optional props as first argument
|
|
11
|
+
* and children as subsequent arguments.
|
|
12
|
+
*
|
|
13
|
+
* Example:
|
|
14
|
+
*
|
|
15
|
+
* ```js
|
|
16
|
+
* div({ id: 'foo' }, 'Hello World')
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* Produces:
|
|
20
|
+
*
|
|
21
|
+
* ```js
|
|
22
|
+
* ['div', { id: 'foo' }, 'Hello World']
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* The following helpers are included:
|
|
26
|
+
* `div`, `span`, `button`, `svg`, `circle`, etc.
|
|
27
|
+
*/
|
|
28
|
+
/** @type {import('./types.js').ElementsElementMap} */
|
|
29
|
+
export const elements: import("./types.js").ElementsElementMap;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function isEventProp(key: any, value: any): boolean;
|
|
2
|
+
export function isFormEventProp(key: any): boolean;
|
|
3
|
+
export function isSubmitEventProp(key: any): boolean;
|
|
4
|
+
export function isValueEventProp(key: any): boolean;
|
|
5
|
+
export function getNearestRoot(el: any, isRoot: any): any;
|
|
6
|
+
export function createDeclarativeEventHandler(env: {
|
|
7
|
+
el: any;
|
|
8
|
+
key: string;
|
|
9
|
+
handler: Function;
|
|
10
|
+
isRoot: (el: any) => boolean;
|
|
11
|
+
renderTree: (node: any, isRoot?: boolean, namespaceURI?: string | null) => any;
|
|
12
|
+
getCurrentEventRoot: () => any;
|
|
13
|
+
setCurrentEventRoot: (el: any) => void;
|
|
14
|
+
debug: boolean;
|
|
15
|
+
}): (...args: any[]) => any;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function removeMissingProps(el: any, prevProps: Record<string, any>, nextProps: Record<string, any>): void;
|
|
2
|
+
export function assignProperties(el: any, props: Record<string, any>, env: {
|
|
3
|
+
svgNS: string;
|
|
4
|
+
debug: boolean;
|
|
5
|
+
isRoot: (el: any) => boolean;
|
|
6
|
+
renderTree: (node: any, isRoot?: boolean, namespaceURI?: string | null) => any;
|
|
7
|
+
getCurrentEventRoot: () => any;
|
|
8
|
+
setCurrentEventRoot: (el: any) => void;
|
|
9
|
+
}): void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** @internal */
|
|
2
|
+
export const htmlTagNames: readonly ["html", "head", "base", "link", "meta", "title", "body", "header", "hgroup", "nav", "main", "section", "article", "aside", "footer", "address", "h1", "h2", "h3", "h4", "h5", "h6", "p", "hr", "menu", "pre", "blockquote", "ol", "ul", "li", "dl", "dt", "dd", "figure", "figcaption", "div", "a", "abbr", "b", "bdi", "bdo", "br", "cite", "code", "data", "dfn", "em", "i", "kbd", "mark", "q", "rb", "rp", "rt", "rtc", "ruby", "s", "samp", "small", "span", "strong", "sub", "sup", "time", "u", "var", "wbr", "ins", "del", "img", "iframe", "embed", "object", "param", "video", "audio", "source", "track", "picture", "table", "caption", "thead", "tbody", "tfoot", "tr", "th", "td", "colgroup", "col", "form", "fieldset", "legend", "label", "input", "button", "select", "datalist", "optgroup", "option", "textarea", "output", "progress", "meter", "details", "search", "summary", "dialog", "slot", "template", "script", "noscript", "style", "canvas", "picture", "map", "area", "slot"];
|
|
3
|
+
/** @internal */
|
|
4
|
+
export const svgTagNames: readonly ["animate", "animateMotion", "animateTransform", "mpath", "set", "circle", "ellipse", "line", "path", "polygon", "polyline", "rect", "defs", "g", "marker", "mask", "pattern", "svg", "switch", "symbol", "use", "desc", "metadata", "title", "filter", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "linearGradient", "radialGradient", "stop", "image", "foreignObject", "text", "textPath", "tspan", "script", "style", "view"];
|
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Primitive values that can be serialized as HTML/SVG attribute values.
|
|
3
|
+
*
|
|
4
|
+
* Note: the runtime assigns most props via `setAttribute`, so strings are the
|
|
5
|
+
* canonical representation. Numbers/booleans are accepted for convenience and
|
|
6
|
+
* are coerced by the DOM.
|
|
7
|
+
*/
|
|
8
|
+
export type ElementsAttributeValue = string | number | boolean | null | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Inline style object applied via `Object.assign(el.style, style)`.
|
|
11
|
+
*/
|
|
12
|
+
export type ElementsStyleObject = Partial<CSSStyleDeclaration> & Record<string, string | number>;
|
|
13
|
+
/**
|
|
14
|
+
* A vnode is a declarative array of the form:
|
|
15
|
+
*
|
|
16
|
+
* ```js
|
|
17
|
+
* [tag, props, ...children]
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export type ElementsVNode = [tag: string, props: ElementsProps, ...children: ElementsChild[]];
|
|
21
|
+
/**
|
|
22
|
+
* Child nodes are plain values, nested arrays, or vnodes.
|
|
23
|
+
*
|
|
24
|
+
* Note: nested arrays are treated as children values (they are not
|
|
25
|
+
* automatically flattened).
|
|
26
|
+
*/
|
|
27
|
+
export type ElementsChild = ElementsVNode | string | number | boolean | null | undefined | any[];
|
|
28
|
+
/**
|
|
29
|
+
* Props for the `ontick` animation hook.
|
|
30
|
+
*
|
|
31
|
+
* `ontick` is not a DOM event. It runs once per animation frame and can thread
|
|
32
|
+
* context across ticks:
|
|
33
|
+
*
|
|
34
|
+
* ```js
|
|
35
|
+
* ontick: (el, ctx = { t: 0 }, dt) => ({ ...ctx, t: ctx.t + dt })
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* The handler must be synchronous; thrown errors stop ticking.
|
|
39
|
+
*/
|
|
40
|
+
export type ElementsOnTick = (el: Element, ctx: any, dtMs: number) => any | void;
|
|
41
|
+
/**
|
|
42
|
+
* If an event handler returns a vnode array, the UI updates by replacing the
|
|
43
|
+
* nearest component boundary. Otherwise the event is treated as passive.
|
|
44
|
+
*/
|
|
45
|
+
export type ElementsEventResult = ElementsVNode | void | null | false | "" | 0;
|
|
46
|
+
/**
|
|
47
|
+
* If an event handler returns a vnode array, the UI updates by replacing the
|
|
48
|
+
* nearest component boundary. Otherwise the event is treated as passive.
|
|
49
|
+
*/
|
|
50
|
+
export type ElementsMaybeAsyncEventResult = ElementsEventResult | Promise<ElementsEventResult>;
|
|
51
|
+
export type ElementsEventHandler<Evt extends Event> = (event: Evt) => ElementsMaybeAsyncEventResult;
|
|
52
|
+
/**
|
|
53
|
+
* Form event handlers receive `(elements, event)`.
|
|
54
|
+
*/
|
|
55
|
+
export type ElementsFormEventHandler<FormEvt extends Event> = (elements: any, event: FormEvt) => ElementsMaybeAsyncEventResult;
|
|
56
|
+
/**
|
|
57
|
+
* Common global HTML attributes.
|
|
58
|
+
*
|
|
59
|
+
* This is a permissive shared set: some attributes only apply to certain
|
|
60
|
+
* elements in the HTML spec, but Elements.js accepts them everywhere because
|
|
61
|
+
* the underlying DOM will ignore irrelevant attributes.
|
|
62
|
+
*
|
|
63
|
+
* This is not exhaustive; `data-*` and `aria-*` are supported via template
|
|
64
|
+
* keys below.
|
|
65
|
+
*/
|
|
66
|
+
export type ElementsGlobalAttributes = {
|
|
67
|
+
id?: string;
|
|
68
|
+
class?: string;
|
|
69
|
+
title?: string;
|
|
70
|
+
role?: string;
|
|
71
|
+
name?: string;
|
|
72
|
+
part?: string;
|
|
73
|
+
slot?: string;
|
|
74
|
+
exportparts?: string;
|
|
75
|
+
nonce?: string;
|
|
76
|
+
elementtiming?: string;
|
|
77
|
+
contentsecuritypolicy?: string;
|
|
78
|
+
popovertarget?: string;
|
|
79
|
+
popovertargetaction?: "toggle" | "show" | "hide";
|
|
80
|
+
autocapitalize?: "none" | "sentences" | "words" | "characters" | "on" | "off";
|
|
81
|
+
enterkeyhint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send";
|
|
82
|
+
inputmode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search";
|
|
83
|
+
virtualkeyboardpolicy?: "auto" | "manual";
|
|
84
|
+
draggable?: boolean;
|
|
85
|
+
hidden?: boolean;
|
|
86
|
+
inert?: boolean;
|
|
87
|
+
spellcheck?: boolean;
|
|
88
|
+
tabindex?: number | string;
|
|
89
|
+
accesskey?: string;
|
|
90
|
+
translate?: "yes" | "no";
|
|
91
|
+
autocorrect?: "on" | "off";
|
|
92
|
+
autocomplete?: string;
|
|
93
|
+
lang?: string;
|
|
94
|
+
dir?: "ltr" | "rtl" | "auto";
|
|
95
|
+
is?: string;
|
|
96
|
+
writingsuggestions?: "true" | "false" | boolean;
|
|
97
|
+
contenteditable?: "true" | "false" | "plaintext-only" | boolean;
|
|
98
|
+
autofocus?: boolean;
|
|
99
|
+
popover?: "auto" | "manual";
|
|
100
|
+
label?: string;
|
|
101
|
+
itemscope?: boolean;
|
|
102
|
+
itemtype?: string;
|
|
103
|
+
itemid?: string;
|
|
104
|
+
itemprop?: string;
|
|
105
|
+
itemref?: string;
|
|
106
|
+
vocab?: string;
|
|
107
|
+
typeof?: string;
|
|
108
|
+
property?: string;
|
|
109
|
+
resource?: string;
|
|
110
|
+
prefix?: string;
|
|
111
|
+
href?: string;
|
|
112
|
+
hreflang?: string;
|
|
113
|
+
referrerpolicy?: string;
|
|
114
|
+
target?: string;
|
|
115
|
+
rel?: string;
|
|
116
|
+
download?: string;
|
|
117
|
+
ping?: string;
|
|
118
|
+
src?: string;
|
|
119
|
+
srcset?: string;
|
|
120
|
+
sizes?: string;
|
|
121
|
+
imagesrcset?: string;
|
|
122
|
+
imagesizes?: string;
|
|
123
|
+
alt?: string;
|
|
124
|
+
width?: number | string;
|
|
125
|
+
height?: number | string;
|
|
126
|
+
type?: string;
|
|
127
|
+
content?: string;
|
|
128
|
+
placeholder?: string;
|
|
129
|
+
required?: boolean;
|
|
130
|
+
readonly?: boolean;
|
|
131
|
+
minlength?: number | string;
|
|
132
|
+
maxlength?: number | string;
|
|
133
|
+
min?: number | string;
|
|
134
|
+
max?: number | string;
|
|
135
|
+
step?: number | string;
|
|
136
|
+
pattern?: string;
|
|
137
|
+
accept?: string;
|
|
138
|
+
for?: string;
|
|
139
|
+
action?: string;
|
|
140
|
+
method?: string;
|
|
141
|
+
enctype?: string;
|
|
142
|
+
novalidate?: boolean;
|
|
143
|
+
formaction?: string;
|
|
144
|
+
formenctype?: string;
|
|
145
|
+
formmethod?: string;
|
|
146
|
+
formnovalidate?: boolean;
|
|
147
|
+
formtarget?: string;
|
|
148
|
+
rows?: number | string;
|
|
149
|
+
cols?: number | string;
|
|
150
|
+
wrap?: string;
|
|
151
|
+
list?: string;
|
|
152
|
+
async?: boolean;
|
|
153
|
+
defer?: boolean;
|
|
154
|
+
nomodule?: boolean;
|
|
155
|
+
crossorigin?: "" | "anonymous" | "use-credentials";
|
|
156
|
+
integrity?: string;
|
|
157
|
+
fetchpriority?: "auto" | "high" | "low";
|
|
158
|
+
loading?: "lazy" | "eager";
|
|
159
|
+
decoding?: "sync" | "async" | "auto";
|
|
160
|
+
media?: string;
|
|
161
|
+
as?: string;
|
|
162
|
+
controls?: boolean;
|
|
163
|
+
controlslist?: string;
|
|
164
|
+
autoplay?: boolean;
|
|
165
|
+
loop?: boolean;
|
|
166
|
+
playsinline?: boolean;
|
|
167
|
+
preload?: "none" | "metadata" | "auto";
|
|
168
|
+
poster?: string;
|
|
169
|
+
};
|
|
170
|
+
export type ElementsDataAttributes = {
|
|
171
|
+
[key: `data-${string}`]: ElementsAttributeValue;
|
|
172
|
+
};
|
|
173
|
+
export type ElementsAriaAttributes = {
|
|
174
|
+
[key: `aria-${string}`]: ElementsAttributeValue;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Dash-cased attributes commonly used by custom elements and utilities.
|
|
178
|
+
*/
|
|
179
|
+
export type ElementsDashedAttributes = {
|
|
180
|
+
[key: `${string}-${string}`]: ElementsAttributeValue;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* DOM event handler props.
|
|
184
|
+
*/
|
|
185
|
+
export type ElementsEventProps = Omit<{ [K in keyof GlobalEventHandlersEventMap as `on${K}`]?: ElementsEventHandler<GlobalEventHandlersEventMap[K]>; }, "oninput" | "onsubmit" | "onchange"> & {
|
|
186
|
+
oninput?: ElementsFormEventHandler<InputEvent | Event>;
|
|
187
|
+
onsubmit?: ElementsFormEventHandler<SubmitEvent | Event>;
|
|
188
|
+
onchange?: ElementsFormEventHandler<Event>;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Special (non-attribute) props supported by Elements.js.
|
|
192
|
+
*
|
|
193
|
+
* Note: some props are assigned as DOM properties (when present on the target
|
|
194
|
+
* element) rather than attributes: `value`, `checked`, `selected`, `disabled`,
|
|
195
|
+
* `multiple`, `muted`, `volume`, `currentTime`, `playbackRate`, `open`,
|
|
196
|
+
* `indeterminate`.
|
|
197
|
+
*/
|
|
198
|
+
export type ElementsSpecialProps = {
|
|
199
|
+
style?: ElementsStyleObject;
|
|
200
|
+
innerHTML?: string;
|
|
201
|
+
ontick?: ElementsOnTick;
|
|
202
|
+
value?: string | number;
|
|
203
|
+
checked?: boolean;
|
|
204
|
+
selected?: boolean;
|
|
205
|
+
disabled?: boolean;
|
|
206
|
+
multiple?: boolean;
|
|
207
|
+
muted?: boolean;
|
|
208
|
+
volume?: number;
|
|
209
|
+
currentTime?: number;
|
|
210
|
+
playbackRate?: number;
|
|
211
|
+
open?: boolean;
|
|
212
|
+
indeterminate?: boolean;
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* Props accepted by all Elements.js tag helpers.
|
|
216
|
+
*/
|
|
217
|
+
export type ElementsProps = ElementsGlobalAttributes & ElementsDataAttributes & ElementsAriaAttributes & ElementsDashedAttributes & ElementsEventProps & ElementsSpecialProps;
|
|
218
|
+
export type ElementsElementHelper<P extends ElementsProps> = (propsOrChild?: P | ElementsChild, ...children: ElementsChild[]) => ElementsVNode;
|
|
219
|
+
export type ElementsHtmlTagName = (typeof htmlTagNames)[number];
|
|
220
|
+
export type ElementsSvgTagName = (typeof svgTagNames)[number];
|
|
221
|
+
export type ElementsTagName = ElementsHtmlTagName | ElementsSvgTagName;
|
|
222
|
+
/**
|
|
223
|
+
* Props for `<a>`.
|
|
224
|
+
*/
|
|
225
|
+
export type ElementsAnchorProps = ElementsProps & {
|
|
226
|
+
href?: string;
|
|
227
|
+
target?: string;
|
|
228
|
+
rel?: string;
|
|
229
|
+
download?: string;
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* Props for `<img>`.
|
|
233
|
+
*/
|
|
234
|
+
export type ElementsImgProps = ElementsProps & {
|
|
235
|
+
src?: string;
|
|
236
|
+
alt?: string;
|
|
237
|
+
loading?: "lazy" | "eager";
|
|
238
|
+
decoding?: "sync" | "async" | "auto";
|
|
239
|
+
referrerpolicy?: string;
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* Props for `<input>`.
|
|
243
|
+
*/
|
|
244
|
+
export type ElementsInputProps = ElementsProps & {
|
|
245
|
+
type?: string;
|
|
246
|
+
name?: string;
|
|
247
|
+
placeholder?: string;
|
|
248
|
+
required?: boolean;
|
|
249
|
+
readonly?: boolean;
|
|
250
|
+
minlength?: number | string;
|
|
251
|
+
maxlength?: number | string;
|
|
252
|
+
min?: number | string;
|
|
253
|
+
max?: number | string;
|
|
254
|
+
step?: number | string;
|
|
255
|
+
pattern?: string;
|
|
256
|
+
accept?: string;
|
|
257
|
+
autocomplete?: string;
|
|
258
|
+
};
|
|
259
|
+
/**
|
|
260
|
+
* Props for `<form>`.
|
|
261
|
+
*/
|
|
262
|
+
export type ElementsFormProps = ElementsProps & {
|
|
263
|
+
action?: string;
|
|
264
|
+
method?: string;
|
|
265
|
+
enctype?: string;
|
|
266
|
+
novalidate?: boolean;
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* Props for `<button>`.
|
|
270
|
+
*/
|
|
271
|
+
export type ElementsButtonProps = ElementsProps & {
|
|
272
|
+
type?: "button" | "submit" | "reset" | string;
|
|
273
|
+
name?: string;
|
|
274
|
+
value?: string | number;
|
|
275
|
+
disabled?: boolean;
|
|
276
|
+
};
|
|
277
|
+
/**
|
|
278
|
+
* Props for `<textarea>`.
|
|
279
|
+
*/
|
|
280
|
+
export type ElementsTextareaProps = ElementsProps & {
|
|
281
|
+
name?: string;
|
|
282
|
+
rows?: number | string;
|
|
283
|
+
cols?: number | string;
|
|
284
|
+
wrap?: string;
|
|
285
|
+
placeholder?: string;
|
|
286
|
+
required?: boolean;
|
|
287
|
+
readonly?: boolean;
|
|
288
|
+
minlength?: number | string;
|
|
289
|
+
maxlength?: number | string;
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* Props for `<select>`.
|
|
293
|
+
*/
|
|
294
|
+
export type ElementsSelectProps = ElementsProps & {
|
|
295
|
+
name?: string;
|
|
296
|
+
required?: boolean;
|
|
297
|
+
multiple?: boolean;
|
|
298
|
+
};
|
|
299
|
+
/**
|
|
300
|
+
* Props for `<option>`.
|
|
301
|
+
*/
|
|
302
|
+
export type ElementsOptionProps = ElementsProps & {
|
|
303
|
+
value?: string | number;
|
|
304
|
+
selected?: boolean;
|
|
305
|
+
disabled?: boolean;
|
|
306
|
+
};
|
|
307
|
+
/**
|
|
308
|
+
* Props for `<script>`.
|
|
309
|
+
*/
|
|
310
|
+
export type ElementsScriptProps = ElementsProps & {
|
|
311
|
+
src?: string;
|
|
312
|
+
type?: string;
|
|
313
|
+
async?: boolean;
|
|
314
|
+
defer?: boolean;
|
|
315
|
+
nomodule?: boolean;
|
|
316
|
+
crossorigin?: "" | "anonymous" | "use-credentials";
|
|
317
|
+
integrity?: string;
|
|
318
|
+
};
|
|
319
|
+
/**
|
|
320
|
+
* Props for `<link>`.
|
|
321
|
+
*/
|
|
322
|
+
export type ElementsLinkProps = ElementsProps & {
|
|
323
|
+
href?: string;
|
|
324
|
+
rel?: string;
|
|
325
|
+
as?: string;
|
|
326
|
+
type?: string;
|
|
327
|
+
media?: string;
|
|
328
|
+
crossorigin?: "" | "anonymous" | "use-credentials";
|
|
329
|
+
integrity?: string;
|
|
330
|
+
referrerpolicy?: string;
|
|
331
|
+
fetchpriority?: "auto" | "high" | "low";
|
|
332
|
+
};
|
|
333
|
+
/**
|
|
334
|
+
* Props for `<meta>`.
|
|
335
|
+
*/
|
|
336
|
+
export type ElementsMetaProps = ElementsProps & {
|
|
337
|
+
name?: string;
|
|
338
|
+
content?: string;
|
|
339
|
+
charset?: string;
|
|
340
|
+
"http-equiv"?: string;
|
|
341
|
+
};
|
|
342
|
+
/**
|
|
343
|
+
* Props for `<video>` and `<audio>`.
|
|
344
|
+
*/
|
|
345
|
+
export type ElementsMediaProps = ElementsProps & {
|
|
346
|
+
src?: string;
|
|
347
|
+
controls?: boolean;
|
|
348
|
+
controlslist?: string;
|
|
349
|
+
autoplay?: boolean;
|
|
350
|
+
loop?: boolean;
|
|
351
|
+
muted?: boolean;
|
|
352
|
+
playsinline?: boolean;
|
|
353
|
+
preload?: "none" | "metadata" | "auto";
|
|
354
|
+
};
|
|
355
|
+
/**
|
|
356
|
+
* Props for `<source>`.
|
|
357
|
+
*/
|
|
358
|
+
export type ElementsSourceProps = ElementsProps & {
|
|
359
|
+
src?: string;
|
|
360
|
+
type?: string;
|
|
361
|
+
srcset?: string;
|
|
362
|
+
sizes?: string;
|
|
363
|
+
media?: string;
|
|
364
|
+
};
|
|
365
|
+
/**
|
|
366
|
+
* Props for `<svg>`.
|
|
367
|
+
*/
|
|
368
|
+
export type ElementsSvgProps = ElementsProps & {
|
|
369
|
+
viewBox?: string;
|
|
370
|
+
xmlns?: string;
|
|
371
|
+
fill?: string;
|
|
372
|
+
stroke?: string;
|
|
373
|
+
"stroke-width"?: number | string;
|
|
374
|
+
};
|
|
375
|
+
/**
|
|
376
|
+
* Props for `<path>`.
|
|
377
|
+
*/
|
|
378
|
+
export type ElementsPathProps = ElementsProps & {
|
|
379
|
+
d?: string;
|
|
380
|
+
fill?: string;
|
|
381
|
+
stroke?: string;
|
|
382
|
+
"stroke-width"?: number | string;
|
|
383
|
+
};
|
|
384
|
+
/**
|
|
385
|
+
* Props for `<circle>`.
|
|
386
|
+
*/
|
|
387
|
+
export type ElementsCircleProps = ElementsProps & {
|
|
388
|
+
cx?: number | string;
|
|
389
|
+
cy?: number | string;
|
|
390
|
+
r?: number | string;
|
|
391
|
+
fill?: string;
|
|
392
|
+
stroke?: string;
|
|
393
|
+
"stroke-width"?: number | string;
|
|
394
|
+
};
|
|
395
|
+
/**
|
|
396
|
+
* Props for `<rect>`.
|
|
397
|
+
*/
|
|
398
|
+
export type ElementsRectProps = ElementsProps & {
|
|
399
|
+
x?: number | string;
|
|
400
|
+
y?: number | string;
|
|
401
|
+
rx?: number | string;
|
|
402
|
+
ry?: number | string;
|
|
403
|
+
width?: number | string;
|
|
404
|
+
height?: number | string;
|
|
405
|
+
fill?: string;
|
|
406
|
+
stroke?: string;
|
|
407
|
+
"stroke-width"?: number | string;
|
|
408
|
+
};
|
|
409
|
+
/**
|
|
410
|
+
* Props for `<line>`.
|
|
411
|
+
*/
|
|
412
|
+
export type ElementsLineProps = ElementsProps & {
|
|
413
|
+
x1?: number | string;
|
|
414
|
+
y1?: number | string;
|
|
415
|
+
x2?: number | string;
|
|
416
|
+
y2?: number | string;
|
|
417
|
+
stroke?: string;
|
|
418
|
+
"stroke-width"?: number | string;
|
|
419
|
+
};
|
|
420
|
+
/**
|
|
421
|
+
* Props for `<text>` (SVG).
|
|
422
|
+
*
|
|
423
|
+
* Note: X3D also has a `text` node; it is exported as `x3dtext` in `/3d`.
|
|
424
|
+
*/
|
|
425
|
+
export type ElementsSvgTextProps = ElementsProps & {
|
|
426
|
+
x?: number | string;
|
|
427
|
+
y?: number | string;
|
|
428
|
+
dx?: number | string;
|
|
429
|
+
dy?: number | string;
|
|
430
|
+
rotate?: number | string;
|
|
431
|
+
"text-anchor"?: string;
|
|
432
|
+
};
|
|
433
|
+
/**
|
|
434
|
+
* Props for `<label>`.
|
|
435
|
+
*/
|
|
436
|
+
export type ElementsLabelProps = ElementsProps & {
|
|
437
|
+
for?: string;
|
|
438
|
+
form?: string;
|
|
439
|
+
};
|
|
440
|
+
/**
|
|
441
|
+
* Props for `<dialog>`.
|
|
442
|
+
*/
|
|
443
|
+
export type ElementsDialogProps = ElementsProps & {
|
|
444
|
+
open?: boolean;
|
|
445
|
+
};
|
|
446
|
+
/**
|
|
447
|
+
* Props for `<details>`.
|
|
448
|
+
*/
|
|
449
|
+
export type ElementsDetailsProps = ElementsProps & {
|
|
450
|
+
open?: boolean;
|
|
451
|
+
};
|
|
452
|
+
/**
|
|
453
|
+
* Props for `<progress>`.
|
|
454
|
+
*/
|
|
455
|
+
export type ElementsProgressProps = ElementsProps & {
|
|
456
|
+
value?: number | string;
|
|
457
|
+
max?: number | string;
|
|
458
|
+
};
|
|
459
|
+
/**
|
|
460
|
+
* Props for `<meter>`.
|
|
461
|
+
*/
|
|
462
|
+
export type ElementsMeterProps = ElementsProps & {
|
|
463
|
+
value?: number | string;
|
|
464
|
+
min?: number | string;
|
|
465
|
+
max?: number | string;
|
|
466
|
+
low?: number | string;
|
|
467
|
+
high?: number | string;
|
|
468
|
+
optimum?: number | string;
|
|
469
|
+
};
|
|
470
|
+
/**
|
|
471
|
+
* Props for `<iframe>`.
|
|
472
|
+
*/
|
|
473
|
+
export type ElementsIframeProps = ElementsProps & {
|
|
474
|
+
src?: string;
|
|
475
|
+
srcdoc?: string;
|
|
476
|
+
name?: string;
|
|
477
|
+
allow?: string;
|
|
478
|
+
sandbox?: string;
|
|
479
|
+
referrerpolicy?: string;
|
|
480
|
+
loading?: "lazy" | "eager";
|
|
481
|
+
allowfullscreen?: boolean;
|
|
482
|
+
};
|
|
483
|
+
/**
|
|
484
|
+
* Props for `<canvas>`.
|
|
485
|
+
*/
|
|
486
|
+
export type ElementsCanvasProps = ElementsProps & {
|
|
487
|
+
width?: number | string;
|
|
488
|
+
height?: number | string;
|
|
489
|
+
};
|
|
490
|
+
export type ElementsPropsForTag<Tag extends ElementsTagName> = Tag extends "a" ? ElementsAnchorProps : Tag extends "img" ? ElementsImgProps : Tag extends "input" ? ElementsInputProps : Tag extends "form" ? ElementsFormProps : Tag extends "button" ? ElementsButtonProps : Tag extends "textarea" ? ElementsTextareaProps : Tag extends "select" ? ElementsSelectProps : Tag extends "option" ? ElementsOptionProps : Tag extends "script" ? ElementsScriptProps : Tag extends "link" ? ElementsLinkProps : Tag extends "meta" ? ElementsMetaProps : Tag extends "video" ? ElementsMediaProps : Tag extends "audio" ? ElementsMediaProps : Tag extends "source" ? ElementsSourceProps : Tag extends "svg" ? ElementsSvgProps : Tag extends "path" ? ElementsPathProps : Tag extends "circle" ? ElementsCircleProps : Tag extends "rect" ? ElementsRectProps : Tag extends "line" ? ElementsLineProps : Tag extends "text" ? ElementsSvgTextProps : Tag extends "label" ? ElementsLabelProps : Tag extends "dialog" ? ElementsDialogProps : Tag extends "details" ? ElementsDetailsProps : Tag extends "progress" ? ElementsProgressProps : Tag extends "meter" ? ElementsMeterProps : Tag extends "iframe" ? ElementsIframeProps : Tag extends "canvas" ? ElementsCanvasProps : ElementsProps;
|
|
491
|
+
/**
|
|
492
|
+
* All tag helpers, with per-tag prop typing when known.
|
|
493
|
+
*/
|
|
494
|
+
export type ElementsElementMap = {
|
|
495
|
+
fragment: ElementsElementHelper<ElementsProps>;
|
|
496
|
+
} & { [K in ElementsTagName]: ElementsElementHelper<ElementsPropsForTag<K>>; };
|
|
497
|
+
/**
|
|
498
|
+
* Aliases (short names) for Types-as-Docs.
|
|
499
|
+
*
|
|
500
|
+
* These are convenience names for editor DX. The `Elements*` names remain the
|
|
501
|
+
* canonical internal names.
|
|
502
|
+
*/
|
|
503
|
+
export type ElementProps = ElementsProps;
|
|
504
|
+
export type ElementHelper<P extends ElementProps> = ElementsElementHelper<P>;
|
|
505
|
+
export type ElementMap = ElementsElementMap;
|
|
506
|
+
import { htmlTagNames } from './tags.js';
|
|
507
|
+
import { svgTagNames } from './tags.js';
|