html-form-field 0.2.0 → 0.3.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 +1 -1
- package/README.md +40 -21
- package/browser/import.js +2 -0
- package/browser/package.json +1 -0
- package/package.json +48 -29
- package/src/form-field.ts +1 -1
- package/src/form-item.ts +1 -1
- package/src/index.ts +8 -4
- package/types/html-form-field.d.ts +71 -77
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# html-form-field
|
|
2
2
|
|
|
3
|
-
Unified interface for HTML form fields with
|
|
3
|
+
Unified interface for HTML form fields with two-way binding to object properties.
|
|
4
4
|
|
|
5
|
-
[](https://github.com/kawanet/html-form-field/actions/)
|
|
6
6
|
[](https://www.npmjs.com/package/html-form-field)
|
|
7
7
|
[](https://cdn.jsdelivr.net/npm/html-form-field/dist/html-form-field.min.js)
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
- Two-way binding between form
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
9
|
+
- A single getter/setter API for text inputs, checkboxes, radio buttons, and `<select>` elements.
|
|
10
|
+
- Two-way binding between a form field and an object property: assignments flow in either direction.
|
|
11
|
+
- Change-detection hooks via `onWrite` (any value write) and `onChange` (user-driven change events).
|
|
12
|
+
- Tiny browser build — [html-form-field.min.js](https://cdn.jsdelivr.net/npm/html-form-field/dist/html-form-field.min.js) is under 4 KB minified and under 2 KB gzipped.
|
|
13
|
+
- First-class TypeScript types — see [html-form-field.d.ts](https://github.com/kawanet/html-form-field/blob/main/types/html-form-field.d.ts) for the full surface.
|
|
14
14
|
|
|
15
15
|
## SYNOPSIS
|
|
16
16
|
|
|
@@ -29,15 +29,14 @@ const ctx = {} as Context
|
|
|
29
29
|
|
|
30
30
|
formField({form, bindTo: ctx, name: "nickname"})
|
|
31
31
|
|
|
32
|
-
console.log(ctx.nickname) // reads from form field
|
|
32
|
+
console.log(ctx.nickname) // reads from the form field
|
|
33
33
|
|
|
34
|
-
ctx.nickname = "John"
|
|
34
|
+
ctx.nickname = "John" // writes back to the form field
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
#### HTML Example
|
|
38
38
|
|
|
39
39
|
```html
|
|
40
|
-
|
|
41
40
|
<form>
|
|
42
41
|
<ul>
|
|
43
42
|
<li>Nickname: <input type="text" name="nickname" value="Alice"></li>
|
|
@@ -56,9 +55,9 @@ ctx.nickname = "John" // updates form field
|
|
|
56
55
|
```js
|
|
57
56
|
const email = formField({form, name: "email"})
|
|
58
57
|
|
|
59
|
-
console.log(email.value)
|
|
58
|
+
console.log(email.value) // read the current value
|
|
60
59
|
|
|
61
|
-
email.value = "john@example.com" //
|
|
60
|
+
email.value = "john@example.com" // assign a new value
|
|
62
61
|
```
|
|
63
62
|
|
|
64
63
|
#### Multiple Selections
|
|
@@ -66,19 +65,17 @@ email.value = "john@example.com" // update value
|
|
|
66
65
|
```js
|
|
67
66
|
const favo = formField({form, name: "favo", delim: ","})
|
|
68
67
|
|
|
69
|
-
favo.toggle("tech")
|
|
70
|
-
|
|
71
|
-
favo.toggle("
|
|
68
|
+
favo.toggle("tech") // toggle one checkbox
|
|
69
|
+
favo.toggle("travel", true) // force-check
|
|
70
|
+
favo.toggle("trading", false) // force-uncheck
|
|
72
71
|
|
|
73
|
-
favo.
|
|
72
|
+
console.log(favo.has("travel")) // is this option currently selected?
|
|
74
73
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
// Shortcut to item by index. Equivalent to items().at(index))
|
|
74
|
+
// Shortcut for items().at(index)
|
|
78
75
|
const firstItem = favo.itemAt(0)
|
|
79
76
|
console.log(firstItem.checked)
|
|
80
77
|
|
|
81
|
-
// Shortcut
|
|
78
|
+
// Shortcut for items().find(v => v.value === value)
|
|
82
79
|
const travelItem = favo.itemOf("travel")
|
|
83
80
|
console.log(travelItem.checked)
|
|
84
81
|
```
|
|
@@ -96,7 +93,29 @@ formField({
|
|
|
96
93
|
})
|
|
97
94
|
```
|
|
98
95
|
|
|
99
|
-
##
|
|
96
|
+
## SEE ALSO
|
|
100
97
|
|
|
101
98
|
- https://www.npmjs.com/package/html-form-field
|
|
102
99
|
- https://github.com/kawanet/html-form-field
|
|
100
|
+
|
|
101
|
+
## MIT LICENSE
|
|
102
|
+
|
|
103
|
+
Copyright (c) 2025-2026 Yusuke Kawasaki
|
|
104
|
+
|
|
105
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
106
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
107
|
+
in the Software without restriction, including without limitation the rights
|
|
108
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
109
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
110
|
+
furnished to do so, subject to the following conditions:
|
|
111
|
+
|
|
112
|
+
The above copyright notice and this permission notice shall be included in all
|
|
113
|
+
copies or substantial portions of the Software.
|
|
114
|
+
|
|
115
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
116
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
117
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
118
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
119
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
120
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
121
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
package/package.json
CHANGED
|
@@ -1,47 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-form-field",
|
|
3
3
|
"description": "Unified interface for HTML form fields with synchronized binding to object properties",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"author": "
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"text",
|
|
9
|
-
"lcov"
|
|
10
|
-
],
|
|
11
|
-
"include": [
|
|
12
|
-
"src/**/*.ts"
|
|
13
|
-
],
|
|
14
|
-
"reportsDir": "coverage"
|
|
4
|
+
"version": "0.3.1",
|
|
5
|
+
"author": "@kawanet",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/kawanet/html-form-field/issues"
|
|
15
8
|
},
|
|
9
|
+
"contributors": [
|
|
10
|
+
"kawanet <u-suke@kawa.net>"
|
|
11
|
+
],
|
|
16
12
|
"devDependencies": {
|
|
17
13
|
"@rollup/plugin-alias": "^5.1.1",
|
|
14
|
+
"@rollup/plugin-commonjs": "^28.0.6",
|
|
18
15
|
"@rollup/plugin-multi-entry": "^7.1.0",
|
|
19
16
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
20
|
-
"@rollup/plugin-sucrase": "^5.0
|
|
17
|
+
"@rollup/plugin-sucrase": "^5.1.0",
|
|
21
18
|
"@rollup/plugin-terser": "^0.4.4",
|
|
22
|
-
"@types/jsdom": "^
|
|
19
|
+
"@types/jsdom": "^28.0.3",
|
|
23
20
|
"@types/node": "^24.9.1",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"rollup": "^4.52.5",
|
|
30
|
-
"terser": "^5.44.0",
|
|
21
|
+
"html-ele": "^0.1.1",
|
|
22
|
+
"jsdom": "^29.1.1",
|
|
23
|
+
"mocha": "^11.7.6",
|
|
24
|
+
"rollup": "^4.60.4",
|
|
25
|
+
"terser": "^5.48.0",
|
|
31
26
|
"typescript": "^5.9.3"
|
|
32
27
|
},
|
|
28
|
+
"devEngines": {
|
|
29
|
+
"runtime": {
|
|
30
|
+
"name": "node",
|
|
31
|
+
"version": ">=22",
|
|
32
|
+
"onFail": "warn"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=20"
|
|
37
|
+
},
|
|
33
38
|
"exports": {
|
|
34
39
|
".": {
|
|
40
|
+
"types": "./types/html-form-field.d.ts",
|
|
35
41
|
"require": "./dist/html-form-field.cjs",
|
|
36
|
-
"import":
|
|
37
|
-
"types": "./types/html-form-field.d.ts",
|
|
38
|
-
"default": "./dist/html-form-field.mjs"
|
|
39
|
-
}
|
|
42
|
+
"import": "./dist/html-form-field.mjs"
|
|
40
43
|
}
|
|
41
44
|
},
|
|
42
45
|
"files": [
|
|
43
46
|
"LICENSE",
|
|
44
47
|
"README.md",
|
|
48
|
+
"browser/import.js",
|
|
49
|
+
"browser/package.json",
|
|
45
50
|
"dist/html-form-field.cjs",
|
|
46
51
|
"dist/html-form-field.min.js",
|
|
47
52
|
"dist/html-form-field.mjs",
|
|
@@ -49,16 +54,30 @@
|
|
|
49
54
|
"src/*.ts",
|
|
50
55
|
"types/*.d.ts"
|
|
51
56
|
],
|
|
57
|
+
"homepage": "https://github.com/kawanet/html-form-field",
|
|
58
|
+
"keywords": [
|
|
59
|
+
"checkbox",
|
|
60
|
+
"form",
|
|
61
|
+
"html",
|
|
62
|
+
"input",
|
|
63
|
+
"radio",
|
|
64
|
+
"select",
|
|
65
|
+
"textarea"
|
|
66
|
+
],
|
|
52
67
|
"license": "MIT",
|
|
53
|
-
"main": "./
|
|
68
|
+
"main": "./dist/html-form-field.cjs",
|
|
69
|
+
"repository": {
|
|
70
|
+
"type": "git",
|
|
71
|
+
"url": "git+https://github.com/kawanet/html-form-field.git"
|
|
72
|
+
},
|
|
54
73
|
"scripts": {
|
|
55
74
|
"build": "make -C builder",
|
|
56
75
|
"fixpack": "fixpack",
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"test
|
|
76
|
+
"prepack": "make -C builder is-buildable",
|
|
77
|
+
"prepare": "make -C builder is-not-buildable 2> /dev/null || make -C builder clean all test",
|
|
78
|
+
"test": "make -C builder test"
|
|
60
79
|
},
|
|
61
80
|
"sideEffects": false,
|
|
62
81
|
"type": "module",
|
|
63
|
-
"types": "types/html-form-field.d.ts"
|
|
82
|
+
"types": "./types/html-form-field.d.ts"
|
|
64
83
|
}
|
package/src/form-field.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {formField as NS, FormField, FormFieldOptions} from "
|
|
1
|
+
import type {formField as NS, FormField, FormFieldOptions} from "html-form-field"
|
|
2
2
|
import {formItemList} from "./form-item.ts"
|
|
3
3
|
|
|
4
4
|
type FieldEventHandler = (this: NS.FieldElement, ev: Event) => void
|
package/src/form-item.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
// Self-reference via the package name so `tsc --noEmit` resolves these
|
|
2
|
+
// types through `package.json` `exports` — the same path an external
|
|
3
|
+
// consumer would take. If the `exports.types` mapping ever breaks, the
|
|
4
|
+
// build fails here.
|
|
5
|
+
import type * as declared from "html-form-field"
|
|
4
6
|
|
|
5
|
-
export
|
|
7
|
+
export {formField} from "./form-field.ts"
|
|
8
|
+
export type {FormField, FormFieldOptions} from "html-form-field"
|
|
9
|
+
export type formField = typeof declared.formField
|
|
@@ -1,71 +1,83 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* html-form-field
|
|
2
|
+
* html-form-field — Unified interface for HTML form fields with two-way
|
|
3
|
+
* binding to object properties.
|
|
4
|
+
*
|
|
5
|
+
* @author kawanet
|
|
6
|
+
* @see https://github.com/kawanet/html-form-field
|
|
3
7
|
*/
|
|
8
|
+
|
|
4
9
|
declare namespace formField {
|
|
10
|
+
/** Form field elements addressable by `name=`. */
|
|
5
11
|
type FieldElement = HTMLInputElement | HTMLTextAreaElement | HTMLButtonElement | HTMLSelectElement
|
|
6
12
|
|
|
13
|
+
/** Individual item elements managed inside a field (a checkbox/radio in a group, or an `<option>` in a `<select>`). */
|
|
7
14
|
type ItemElement = HTMLInputElement | HTMLTextAreaElement | HTMLButtonElement | HTMLOptionElement
|
|
8
15
|
|
|
9
16
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* -
|
|
17
|
+
* Extracts the string-valued keys of `T`.
|
|
18
|
+
*
|
|
19
|
+
* - `T = undefined`: any `string` is accepted (no bound object means no key constraint).
|
|
20
|
+
* - `T` is an object: the union of keys `K` where `T[K]` extends `string`.
|
|
13
21
|
*/
|
|
14
22
|
type StringKeys<T> = [T] extends [undefined]
|
|
15
23
|
? string
|
|
16
24
|
: { [K in keyof T]: K extends string ? (T[K] extends string ? K : never) : never }[keyof T];
|
|
17
25
|
|
|
26
|
+
/** Handler invoked when a field value is written. See `FormFieldOptions.onWrite`. */
|
|
18
27
|
type OnWrite<T> = FormFieldOptions<T>["onWrite"]
|
|
19
28
|
|
|
29
|
+
/** Handler invoked on a user-driven `change` event. See `FormFieldOptions.onChange`. */
|
|
20
30
|
type OnChange<T> = FormFieldOptions<T>["onChange"]
|
|
21
31
|
|
|
22
32
|
interface FormFieldOptions<T = any> {
|
|
23
33
|
/**
|
|
24
|
-
* form element or container element
|
|
34
|
+
* The form element, or any container element that holds the field elements.
|
|
25
35
|
*/
|
|
26
36
|
form: HTMLFormElement | FieldElement | ParentNode
|
|
27
37
|
|
|
28
38
|
/**
|
|
29
|
-
* name of the field
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
39
|
+
* `name=` attribute of the field to bind.
|
|
40
|
+
*
|
|
41
|
+
* When `bindTo` is supplied, TypeScript infers `T` from that object and `name` is
|
|
42
|
+
* restricted to keys of the bound object whose value type is `string`. Without
|
|
43
|
+
* `bindTo`, any string is accepted.
|
|
33
44
|
*/
|
|
34
45
|
name: StringKeys<T>
|
|
35
46
|
|
|
36
47
|
/**
|
|
37
|
-
* Object to synchronize form
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
48
|
+
* Object to synchronize with the form field.
|
|
49
|
+
*
|
|
50
|
+
* A getter/setter is installed on the property matching `name`: the getter reads
|
|
51
|
+
* the live DOM value, the setter writes back to the DOM and fires `onWrite`. Other
|
|
52
|
+
* properties on the object are left untouched.
|
|
42
53
|
*/
|
|
43
54
|
bindTo?: T
|
|
44
55
|
|
|
45
56
|
/**
|
|
46
|
-
* Called
|
|
47
|
-
* or
|
|
48
|
-
* Fires before onChange
|
|
57
|
+
* Called whenever the field value is written — either by a setter
|
|
58
|
+
* (`field.value = ...` or assignment to a bound property) or by a user-driven
|
|
59
|
+
* `change` event. Fires before `onChange`.
|
|
49
60
|
*/
|
|
50
61
|
onWrite?: (field: FormField<T>) => void
|
|
51
62
|
|
|
52
63
|
/**
|
|
53
|
-
* Called
|
|
54
|
-
*
|
|
64
|
+
* Called only on a user-driven `change` event. Setter assignments do not trigger
|
|
65
|
+
* this handler. Fires after `onWrite`.
|
|
55
66
|
*/
|
|
56
67
|
onChange?: (item: FormField<T>) => void
|
|
57
68
|
|
|
58
69
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
70
|
+
* Delimiter joining multiple values for checkbox groups and multi-select fields.
|
|
71
|
+
* Defaults to `,` (comma). Use Unit Separator (`\x1F`) if your values may contain
|
|
72
|
+
* commas.
|
|
62
73
|
*/
|
|
63
74
|
delim?: string
|
|
64
75
|
|
|
65
76
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
77
|
+
* Candidate initial values, tried in order.
|
|
78
|
+
*
|
|
79
|
+
* For checkbox / radio / select fields, the first value with a matching option is
|
|
80
|
+
* applied; if none matches, the next candidate is tried, and so on.
|
|
69
81
|
*/
|
|
70
82
|
defaults?: string[]
|
|
71
83
|
}
|
|
@@ -73,108 +85,90 @@ declare namespace formField {
|
|
|
73
85
|
interface FormField<T = any> {
|
|
74
86
|
readonly options: FormFieldOptions<T>
|
|
75
87
|
|
|
76
|
-
/**
|
|
77
|
-
* name of the field element (input, select, textarea)
|
|
78
|
-
*/
|
|
88
|
+
/** `name=` attribute of the bound field. */
|
|
79
89
|
readonly name: StringKeys<T>
|
|
80
90
|
|
|
81
91
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
92
|
+
* Getter/setter for the field value. Assignment fires the `onWrite` handler.
|
|
93
|
+
*
|
|
94
|
+
* For checkbox groups and multi-select fields the value is exposed as a single
|
|
95
|
+
* string formed by joining the selected values with `options.delim` (default `,`).
|
|
86
96
|
*/
|
|
87
97
|
value: string
|
|
88
98
|
|
|
89
99
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
100
|
+
* Re-scan the form for items matching `name` and rebind them. Call this after
|
|
101
|
+
* the underlying DOM changes — for example when checkboxes, radio buttons, or
|
|
102
|
+
* `<option>` elements are added or removed — so the `FormField` reflects the
|
|
103
|
+
* current state of the form.
|
|
94
104
|
*/
|
|
95
105
|
reload(): void
|
|
96
106
|
|
|
97
107
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* -
|
|
108
|
+
* All items belonging to the field, including disabled ones.
|
|
109
|
+
*
|
|
110
|
+
* - checkbox / radio / select: every option in the group.
|
|
111
|
+
* - other field types: the single underlying item.
|
|
101
112
|
*/
|
|
102
113
|
items(): FormItem[]
|
|
103
114
|
|
|
104
115
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* -
|
|
108
|
-
* -
|
|
116
|
+
* Active items only — disabled items are excluded.
|
|
117
|
+
*
|
|
118
|
+
* - checkbox / radio: items that are currently checked and enabled.
|
|
119
|
+
* - select: options that are currently selected and enabled.
|
|
120
|
+
* - other field types: the single underlying item, if enabled.
|
|
109
121
|
*/
|
|
110
122
|
current(): FormItem[]
|
|
111
123
|
|
|
112
124
|
/**
|
|
113
|
-
*
|
|
125
|
+
* Toggle the selection of an item (checkbox or multi-select). With `checked`
|
|
126
|
+
* supplied, sets the state explicitly; without it, flips the current state.
|
|
127
|
+
* Returns the new selection state.
|
|
114
128
|
*/
|
|
115
129
|
toggle(value: string, checked?: boolean): boolean
|
|
116
130
|
|
|
117
|
-
/**
|
|
118
|
-
* check if an option is selected (for checkbox, multi-select)
|
|
119
|
-
*/
|
|
131
|
+
/** Returns `true` if the given value is currently selected. */
|
|
120
132
|
has(value: string): boolean
|
|
121
133
|
|
|
122
134
|
/**
|
|
123
|
-
* Shortcut
|
|
124
|
-
* Equivalent to items().at(index). Returns undefined if out of range.
|
|
135
|
+
* Shortcut for `items().at(index)`. Returns `undefined` when out of range.
|
|
125
136
|
*/
|
|
126
137
|
itemAt(index: number): FormItem | undefined
|
|
127
138
|
|
|
128
139
|
/**
|
|
129
|
-
* Shortcut
|
|
130
|
-
*
|
|
140
|
+
* Shortcut for `items().find(v => v.value === value)`. Returns the first match,
|
|
141
|
+
* or `undefined` if no item has the given value.
|
|
131
142
|
*/
|
|
132
143
|
itemOf(value: string): FormItem | undefined
|
|
133
144
|
}
|
|
134
145
|
|
|
135
146
|
interface FormItem<E extends ItemElement = ItemElement> {
|
|
136
|
-
/**
|
|
137
|
-
* underlying HTML element (input, option, textarea)
|
|
138
|
-
*/
|
|
147
|
+
/** Underlying HTML element (`<input>`, `<option>`, `<textarea>`, ...). */
|
|
139
148
|
readonly node: E
|
|
140
149
|
|
|
141
|
-
/**
|
|
142
|
-
* getter/setter of the `value` property
|
|
143
|
-
* setter triggers onWrite handler
|
|
144
|
-
*/
|
|
150
|
+
/** Getter/setter for the item's `value` property. Assignment fires `onWrite`. */
|
|
145
151
|
value: string
|
|
146
152
|
|
|
147
|
-
/**
|
|
148
|
-
* method to set the `value` property silently
|
|
149
|
-
* does not trigger onWrite handler
|
|
150
|
-
*/
|
|
153
|
+
/** Set `value` without firing `onWrite`. */
|
|
151
154
|
setValue(value: string): void
|
|
152
155
|
|
|
153
|
-
/**
|
|
154
|
-
* whether the option is checkable (radio, checkbox, select)
|
|
155
|
-
*/
|
|
156
|
+
/** Whether the item is a checkable type (radio, checkbox, or `<option>`). */
|
|
156
157
|
readonly checkable: boolean
|
|
157
158
|
|
|
158
159
|
/**
|
|
159
|
-
*
|
|
160
|
-
*
|
|
160
|
+
* Selection state for radio buttons, checkboxes, and `<option>` elements.
|
|
161
|
+
* Assignment fires `onWrite`.
|
|
161
162
|
*/
|
|
162
163
|
checked: boolean | undefined
|
|
163
164
|
|
|
164
|
-
/**
|
|
165
|
-
* method to set the `checked` property silently
|
|
166
|
-
* does not trigger onWrite handler
|
|
167
|
-
*/
|
|
165
|
+
/** Set `checked` without firing `onWrite`. */
|
|
168
166
|
setChecked(checked: boolean): void
|
|
169
167
|
|
|
170
|
-
/**
|
|
171
|
-
* getter/setter of the `disabled` property
|
|
172
|
-
*/
|
|
168
|
+
/** Getter/setter for the `disabled` property. */
|
|
173
169
|
disabled: boolean
|
|
174
170
|
|
|
175
|
-
/**
|
|
176
|
-
* text content of the option (if applicable)
|
|
177
|
-
*/
|
|
171
|
+
/** Visible label text of the item, when the underlying element exposes one. */
|
|
178
172
|
readonly label: string | undefined
|
|
179
173
|
}
|
|
180
174
|
}
|