@mpen/jsxhtml 0.2.1 → 0.3.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.
@@ -0,0 +1,25 @@
1
+ /*! Adapted from https://github.com/mathiasbynens/CSS.escape/blob/4b25c283eaf4dd443f44a7096463e973d56dd1b2/css.escape.js */
2
+ /**
3
+ * Escapes a string for use as a CSS identifier.
4
+ *
5
+ * This function is an implementation of the CSS Object Model's `CSS.escape()`
6
+ * method. It can be used to safely escape strings for use in CSS selectors.
7
+ *
8
+ * @see https://drafts.csswg.org/cssom/#the-css.escape()-method
9
+ *
10
+ * @param value The string to be escaped. In the original spec, this is a `DOMString`.
11
+ * @returns The escaped string.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import cssEscape from './css-escape';
16
+ *
17
+ * const id = 'foo.bar:baz';
18
+ * const escapedId = cssEscape(id); // 'foo\\.bar\\:baz'
19
+ * const selector = `#${escapedId}`; // '#foo\\.bar\\:baz'
20
+ *
21
+ * // This selector can now be used with document.querySelector
22
+ * // const element = document.querySelector(selector);
23
+ * ```
24
+ */
25
+ export default function cssEscape(value: string): string;
@@ -16,7 +16,7 @@ export declare function DocType(props: DocTypeProps): JsxDocType;
16
16
  /**
17
17
  * `<!DOCTYPE html><html ...>{children}</html>`
18
18
  */
19
- export declare function HtmlDocument({ children, ...htmlAttrs }: AnyAttributes): import("./jsx-node").JsxNode;
19
+ export declare function HtmlDocument({ children, ...htmlAttrs }: AnyAttributes): import("./jsx").JSX.Element;
20
20
  /**
21
21
  * No output.
22
22
  */
package/dist/dev.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,55 @@
1
+ /**
2
+ * All standard attributes for the `<button>` HTML element.
3
+ */
4
+ export type ButtonAttributes = {
5
+ /** Automatically focus the button when the page loads. */
6
+ autofocus?: boolean;
7
+ /**
8
+ * Action to perform on the controlled element:
9
+ * - "show-modal" | "close" | "request-close"
10
+ * - "show-popover" | "hide-popover" | "toggle-popover"
11
+ * - "--custom": custom command (must start with `--`)
12
+ */
13
+ command?: string;
14
+ /** ID of the element this button controls as a command button. */
15
+ commandfor?: string;
16
+ /** Whether the button is disabled and non-interactive. */
17
+ disabled?: boolean;
18
+ /** Associates the button with a `<form>` by ID. */
19
+ form?: string;
20
+ /** URL to submit to when clicked. Overrides form’s `action`. */
21
+ formaction?: string;
22
+ /**
23
+ * Encoding type for submitted data:
24
+ * - "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain"
25
+ */
26
+ formenctype?: 'application/x-www-form-urlencoded' | 'multipart/form-data' | 'text/plain';
27
+ /**
28
+ * Method for submitting the form:
29
+ * - "get" | "post" | "dialog"
30
+ */
31
+ formmethod?: 'get' | 'post' | 'dialog';
32
+ /** Skip form validation on submit. */
33
+ formnovalidate?: boolean;
34
+ /**
35
+ * Browsing context for the response:
36
+ * - "_self" | "_blank" | "_parent" | "_top" | custom target
37
+ */
38
+ formtarget?: string;
39
+ /** Name of the button, submitted as name=value with the form. */
40
+ name?: string;
41
+ /** ID of the popover element controlled by this button. */
42
+ popovertarget?: string;
43
+ /**
44
+ * Action to perform on the popover:
45
+ * - "show" | "hide" | "toggle"
46
+ */
47
+ popovertargetaction?: 'show' | 'hide' | 'toggle';
48
+ /**
49
+ * Button type:
50
+ * - "submit" (default), "reset", or "button"
51
+ */
52
+ type?: 'submit' | 'reset' | 'button';
53
+ /** Value submitted with the form when using this button. */
54
+ value?: string;
55
+ };
@@ -277,9 +277,79 @@ export type XmlAttributes = {
277
277
  */
278
278
  'xml:base': string;
279
279
  };
280
- export type GlobalEventHandlers = {
281
- [evt in EventHandlerNames]?: string | ((this: HTMLElement) => void);
280
+ export type EventHandlerMap = {
281
+ onauxclick: MouseEvent;
282
+ onbeforeinput: InputEvent;
283
+ onbeforematch: Event;
284
+ onbeforetoggle: Event;
285
+ onblur: FocusEvent;
286
+ oncancel: Event;
287
+ oncanplay: Event;
288
+ oncanplaythrough: Event;
289
+ onchange: Event;
290
+ onclick: MouseEvent;
291
+ onclose: Event;
292
+ oncontextlost: Event;
293
+ oncontextmenu: MouseEvent;
294
+ oncontextrestored: Event;
295
+ oncopy: ClipboardEvent;
296
+ oncuechange: Event;
297
+ oncut: ClipboardEvent;
298
+ ondblclick: MouseEvent;
299
+ ondrag: DragEvent;
300
+ ondragend: DragEvent;
301
+ ondragenter: DragEvent;
302
+ ondragleave: DragEvent;
303
+ ondragover: DragEvent;
304
+ ondragstart: DragEvent;
305
+ ondrop: DragEvent;
306
+ ondurationchange: Event;
307
+ onemptied: Event;
308
+ onended: Event;
309
+ onerror: ErrorEvent;
310
+ onfocus: FocusEvent;
311
+ onformdata: FormDataEvent;
312
+ oninput: InputEvent;
313
+ oninvalid: Event;
314
+ onkeydown: KeyboardEvent;
315
+ onkeypress: KeyboardEvent;
316
+ onkeyup: KeyboardEvent;
317
+ onload: Event;
318
+ onloadeddata: Event;
319
+ onloadedmetadata: Event;
320
+ onloadstart: ProgressEvent;
321
+ onmousedown: MouseEvent;
322
+ onmouseenter: MouseEvent;
323
+ onmouseleave: MouseEvent;
324
+ onmousemove: MouseEvent;
325
+ onmouseout: MouseEvent;
326
+ onmouseover: MouseEvent;
327
+ onmouseup: MouseEvent;
328
+ onpaste: ClipboardEvent;
329
+ onpause: Event;
330
+ onplay: Event;
331
+ onplaying: Event;
332
+ onprogress: ProgressEvent;
333
+ onratechange: Event;
334
+ onreset: Event;
335
+ onresize: UIEvent;
336
+ onscroll: Event;
337
+ onscrollend: Event;
338
+ onsecuritypolicyviolation: SecurityPolicyViolationEvent;
339
+ onseeked: Event;
340
+ onseeking: Event;
341
+ onselect: Event;
342
+ onslotchange: Event;
343
+ onstalled: Event;
344
+ onsubmit: SubmitEvent;
345
+ onsuspend: Event;
346
+ ontimeupdate: Event;
347
+ ontoggle: Event;
348
+ onvolumechange: Event;
349
+ onwaiting: Event;
350
+ onwheel: WheelEvent;
282
351
  };
283
- export type AllGlobalAttributes = StandardGlobalAttributes | AriaAttributes | GlobalEventHandlers;
284
- type EventHandlerNames = 'onauxclick' | 'onbeforeinput' | 'onbeforematch' | 'onbeforetoggle' | 'onblur' | 'oncancel' | 'oncanplay' | 'oncanplaythrough' | 'onchange' | 'onclick' | 'onclose' | 'oncontextlost' | 'oncontextmenu' | 'oncontextrestored' | 'oncopy' | 'oncuechange' | 'oncut' | 'ondblclick' | 'ondrag' | 'ondragend' | 'ondragenter' | 'ondragleave' | 'ondragover' | 'ondragstart' | 'ondrop' | 'ondurationchange' | 'onemptied' | 'onended' | 'onerror' | 'onfocus' | 'onformdata' | 'oninput' | 'oninvalid' | 'onkeydown' | 'onkeypress' | 'onkeyup' | 'onload' | 'onloadeddata' | 'onloadedmetadata' | 'onloadstart' | 'onmousedown' | 'onmouseenter' | 'onmouseleave' | 'onmousemove' | 'onmouseout' | 'onmouseover' | 'onmouseup' | 'onpaste' | 'onpause' | 'onplay' | 'onplaying' | 'onprogress' | 'onratechange' | 'onreset' | 'onresize' | 'onscroll' | 'onscrollend' | 'onsecuritypolicyviolation' | 'onseeked' | 'onseeking' | 'onselect' | 'onslotchange' | 'onstalled' | 'onsubmit' | 'onsuspend' | 'ontimeupdate' | 'ontoggle' | 'onvolumechange' | 'onwaiting' | 'onwheel';
285
- export {};
352
+ export type GlobalEventHandlers<E = HTMLElement> = {
353
+ [K in keyof EventHandlerMap]?: string | ((this: E, ev: EventHandlerMap[K]) => any);
354
+ };
355
+ export type AllGlobalAttributes<E = HTMLElement> = StandardGlobalAttributes & AriaAttributes & GlobalEventHandlers<E>;
@@ -0,0 +1,221 @@
1
+ /**
2
+ * A union of all possible 'type' attribute values for the <input> element.
3
+ */
4
+ export type InputType = 'button' | 'checkbox' | 'color' | 'date' | 'datetime-local' | 'email' | 'file' | 'hidden' | 'image' | 'month' | 'number' | 'password' | 'radio' | 'range' | 'reset' | 'search' | 'submit' | 'tel' | 'text' | 'time' | 'url' | 'week' | 'datetime';
5
+ /**
6
+ * Type definition for the attributes of the HTML <input> element, excluding global attributes.
7
+ * The <input> element is used to create interactive controls for web-based forms to accept data from the user.
8
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
9
+ */
10
+ export type InputAttributes = {
11
+ /**
12
+ * Specifies the types of files that the server accepts (that can be submitted through a file upload).
13
+ * Valid for the `file` input type only.
14
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#accept
15
+ */
16
+ accept?: string;
17
+ /**
18
+ * Provides alternative text for the image, displaying if the image `src` is missing or fails to load.
19
+ * Valid for the `image` input type only.
20
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#alt
21
+ */
22
+ alt?: string;
23
+ /**
24
+ * A string that describes what, if any, type of autocomplete functionality the input should provide.
25
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#autocomplete
26
+ */
27
+ autocomplete?: string;
28
+ /**
29
+ * Defines which media (microphone, video, or camera) should be used to capture a new file for upload.
30
+ * Valid for the `file` input type only.
31
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#capture
32
+ */
33
+ capture?: boolean | 'user' | 'environment';
34
+ /**
35
+ * Indicates whether a control is checked by default (when the page loads).
36
+ * Valid for `radio` and `checkbox` types.
37
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#checked
38
+ */
39
+ checked?: boolean;
40
+ /**
41
+ * Enables the submission of the directionality of the element, and specifies the name of the field that will contain this value.
42
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#dirname
43
+ */
44
+ dirname?: string;
45
+ /**
46
+ * Indicates that the user should not be able to interact with the input.
47
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#disabled
48
+ */
49
+ disabled?: boolean;
50
+ /**
51
+ * The ID of the `<form>` element with which the input is associated.
52
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#form
53
+ */
54
+ form?: string;
55
+ /**
56
+ * The URL that processes the information submitted by the input. Overrides the `action` attribute of the parent form.
57
+ * Valid for `image` and `submit` types.
58
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#formaction
59
+ */
60
+ formaction?: string;
61
+ /**
62
+ * Specifies the encoding of the form data when the form is submitted. Overrides the `enctype` of the parent form.
63
+ * Valid for `image` and `submit` types.
64
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#formenctype
65
+ */
66
+ formenctype?: 'application/x-www-form-urlencoded' | 'multipart/form-data' | 'text/plain';
67
+ /**
68
+ * The HTTP method to use for form submission. Overrides the `method` of the parent form.
69
+ * Valid for `image` and `submit` types.
70
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#formmethod
71
+ */
72
+ formmethod?: 'get' | 'post';
73
+ /**
74
+ * If present, bypasses form control validation for form submission. Overrides the `novalidate` of the parent form.
75
+ * Valid for `image` and `submit` types.
76
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#formnovalidate
77
+ */
78
+ formnovalidate?: boolean;
79
+ /**
80
+ * Specifies the browsing context for form submission. Overrides the `target` of the parent form.
81
+ * Valid for `image` and `submit` types.
82
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#formtarget
83
+ */
84
+ formtarget?: string;
85
+ /**
86
+ * The height of the image file to display for a graphical submit button.
87
+ * Valid for the `image` input type only.
88
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#height
89
+ */
90
+ height?: string | number;
91
+ /**
92
+ * The ID of a `<datalist>` element located in the same document to provide a list of predefined values to suggest for this input.
93
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#list
94
+ */
95
+ list?: string;
96
+ /**
97
+ * The greatest value in the range of permitted values.
98
+ * Valid for `date`, `month`, `week`, `time`, `datetime-local`, `number`, and `range`.
99
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#max
100
+ */
101
+ max?: string | number;
102
+ /**
103
+ * The maximum string length (in UTF-16 code units) that the user can enter.
104
+ * Valid for `text`, `search`, `url`, `tel`, `email`, and `password`.
105
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#maxlength
106
+ */
107
+ maxlength?: number;
108
+ /**
109
+ * The most negative value in the range of permitted values.
110
+ * Valid for `date`, `month`, `week`, `time`, `datetime-local`, `number`, and `range`.
111
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#min
112
+ */
113
+ min?: string | number;
114
+ /**
115
+ * The minimum string length (in UTF-16 code units) that the user can enter.
116
+ * Valid for `text`, `search`, `url`, `tel`, `email`, and `password`.
117
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#minlength
118
+ */
119
+ minlength?: number;
120
+ /**
121
+ * If present, the user can enter multiple values.
122
+ * Valid for `email` and `file` types.
123
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#multiple
124
+ */
125
+ multiple?: boolean;
126
+ /**
127
+ * The name of the input control. This name is submitted along with the control's value when the form is submitted.
128
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#name
129
+ */
130
+ name?: string;
131
+ /**
132
+ * A regular expression that the input's value must match for the value to pass constraint validation.
133
+ * Valid for `text`, `search`, `url`, `tel`, `email`, and `password`.
134
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#pattern
135
+ */
136
+ pattern?: string;
137
+ /**
138
+ * A brief hint to the user as to what kind of information is expected in the field.
139
+ * Valid for `text`, `search`, `url`, `tel`, `email`, `password`, and `number`.
140
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#placeholder
141
+ */
142
+ placeholder?: string;
143
+ /**
144
+ * Designates an `<input type="button">` as a control for a popover element, taking the ID of the popover.
145
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#popovertarget
146
+ */
147
+ popovertarget?: string;
148
+ /**
149
+ * Specifies the action ('show', 'hide', or 'toggle') that a popover control button should perform.
150
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#popovertargetaction
151
+ */
152
+ popovertargetaction?: 'show' | 'hide' | 'toggle';
153
+ /**
154
+ * If present, indicates that the user should not be able to edit the value of the input.
155
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#readonly
156
+ */
157
+ readonly?: boolean;
158
+ /**
159
+ * If present, indicates that the user must specify a value for the input before the owning form can be submitted.
160
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#required
161
+ */
162
+ required?: boolean;
163
+ /**
164
+ * The visible size of the control, in characters for text/password, or pixels for others.
165
+ * Valid for `email`, `password`, `tel`, `url`, and `text`.
166
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#size
167
+ */
168
+ size?: number;
169
+ /**
170
+ * The URL of the image file to display for the graphical submit button.
171
+ * Valid for the `image` input type only.
172
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#src
173
+ */
174
+ src?: string;
175
+ /**
176
+ * A number that specifies the granularity that the value must adhere to, or the special value "any".
177
+ * Valid for `date`, `month`, `week`, `time`, `datetime-local`, `number`, and `range`.
178
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#step
179
+ */
180
+ step?: number | 'any';
181
+ /**
182
+ * The type of control to render. If omitted, the default is `text`.
183
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#type
184
+ */
185
+ type?: InputType;
186
+ /**
187
+ * The input control's value. When specified in the HTML, this is the initial value.
188
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#value
189
+ */
190
+ value?: string | number | readonly string[];
191
+ /**
192
+ * The width of the image file to display for the graphical submit button.
193
+ * Valid for the `image` input type only.
194
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#width
195
+ */
196
+ width?: string | number;
197
+ /**
198
+ * If present, tells the user agent to process the input as a live search.
199
+ * @nonstandard
200
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#incremental
201
+ */
202
+ incremental?: boolean;
203
+ /**
204
+ * Defines the orientation of the range slider.
205
+ * @nonstandard This is a Firefox-only attribute.
206
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#orient
207
+ */
208
+ orient?: 'horizontal' | 'vertical';
209
+ /**
210
+ * Overrides the maximum number of entries to be displayed in the dropdown menu of previous search queries.
211
+ * @nonstandard This is a Safari-only attribute.
212
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#results
213
+ */
214
+ results?: number;
215
+ /**
216
+ * If present, indicates that only directories should be available to be selected by the user in the file picker interface.
217
+ * @nonstandard
218
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#webkitdirectory
219
+ */
220
+ webkitdirectory?: boolean;
221
+ };