@nysds/nys-checkbox 1.19.4 → 1.20.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/dist/index.d.ts +2 -0
- package/dist/nys-checkbox.d.ts +150 -0
- package/dist/nys-checkbox.figma.d.ts +1 -0
- package/dist/nys-checkbox.js +348 -189
- package/dist/nys-checkbox.js.map +1 -1
- package/dist/nys-checkboxgroup.d.ts +178 -0
- package/package.json +6 -4
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { NysFormControlElement } from "@nysds/internals";
|
|
2
|
+
import "./nys-checkboxgroup";
|
|
3
|
+
import "@nysds/nys-label";
|
|
4
|
+
import "@nysds/nys-errormessage";
|
|
5
|
+
import "@nysds/nys-icon";
|
|
6
|
+
import "@nysds/nys-textinput";
|
|
7
|
+
/**
|
|
8
|
+
* A checkbox input for binary choices or multi-select lists. Can be used standalone or in a `nys-checkboxgroup`.
|
|
9
|
+
* Form-associated with validation via ElementInternals.
|
|
10
|
+
*
|
|
11
|
+
* Use for binary decisions (agree/disagree) or selecting multiple options from a list.
|
|
12
|
+
* For single selection from 2-6 options, use `nys-radiobutton`. For immediate state changes, use `nys-toggle`.
|
|
13
|
+
*
|
|
14
|
+
* @summary Checkbox for binary choices or multi-select options.
|
|
15
|
+
* @element nys-checkbox
|
|
16
|
+
*
|
|
17
|
+
* @slot description - Custom HTML description content.
|
|
18
|
+
*
|
|
19
|
+
* @fires nys-change - Fired when checked state changes. Detail: `{id, checked, name, value}`.
|
|
20
|
+
* @fires nys-focus - Fired when checkbox gains focus.
|
|
21
|
+
* @fires nys-blur - Fired when checkbox loses focus.
|
|
22
|
+
* @fires nys-other-input - Fired when "other" text input value changes. Detail: `{id, name, value}`.
|
|
23
|
+
*
|
|
24
|
+
* @example Single
|
|
25
|
+
* ```html
|
|
26
|
+
* <nys-checkbox label="I agree to the terms" name="terms"></nys-checkbox>
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example Preselected
|
|
30
|
+
* ```html
|
|
31
|
+
* <nys-checkbox label="I agree to the terms" name="terms" checked></nys-checkbox>
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare class NysCheckbox extends NysFormControlElement {
|
|
35
|
+
static styles: import("lit").CSSResult;
|
|
36
|
+
static shadowRootOptions: {
|
|
37
|
+
delegatesFocus: boolean;
|
|
38
|
+
clonable?: boolean;
|
|
39
|
+
customElementRegistry?: CustomElementRegistry;
|
|
40
|
+
mode: ShadowRootMode;
|
|
41
|
+
serializable?: boolean;
|
|
42
|
+
slotAssignment?: SlotAssignmentMode;
|
|
43
|
+
};
|
|
44
|
+
/** Whether checkbox is checked. */
|
|
45
|
+
checked: boolean;
|
|
46
|
+
/** Prevents interaction. */
|
|
47
|
+
disabled: boolean;
|
|
48
|
+
/** Marks as required. Validates that checkbox is checked. */
|
|
49
|
+
required: boolean;
|
|
50
|
+
/** Visible label text. Required for accessibility. */
|
|
51
|
+
label: string;
|
|
52
|
+
/** Helper text below label. Use slot for custom HTML. */
|
|
53
|
+
description: string;
|
|
54
|
+
/** Unique identifier. Auto-generated if not provided. */
|
|
55
|
+
id: string;
|
|
56
|
+
/** Name for form submission. Use same name for grouped checkboxes. */
|
|
57
|
+
name: string;
|
|
58
|
+
/** Value submitted when checked. */
|
|
59
|
+
value: string;
|
|
60
|
+
/** Form `id` to associate with when checkbox is outside form element. */
|
|
61
|
+
form: string | null;
|
|
62
|
+
/** Shows error message when true. */
|
|
63
|
+
showError: boolean;
|
|
64
|
+
/** Error message text. Shown only when `showError` is true. */
|
|
65
|
+
errorMessage: string;
|
|
66
|
+
/** Internal: Set by parent checkboxgroup. Do not set manually. */
|
|
67
|
+
groupExist: boolean;
|
|
68
|
+
/** Renders as tile with larger clickable area. Apply to group for consistency. */
|
|
69
|
+
tile: boolean;
|
|
70
|
+
/** Tooltip text shown on hover/focus of info icon. */
|
|
71
|
+
tooltip: string;
|
|
72
|
+
/**
|
|
73
|
+
* Checkbox size: `sm` (24px) or `md` (32px, default).
|
|
74
|
+
* @default "md"
|
|
75
|
+
*/
|
|
76
|
+
size: "sm" | "md";
|
|
77
|
+
other: boolean;
|
|
78
|
+
showOtherError: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Id of an element in the host's light-DOM tree to borrow the accessible name
|
|
81
|
+
* from (e.g. a table column `<th>`). Enables labelling a checkbox that has no
|
|
82
|
+
* visible label of its own.
|
|
83
|
+
*/
|
|
84
|
+
labelledby: string;
|
|
85
|
+
/**
|
|
86
|
+
* Suppress the internal visible `<nys-label>` (use with `labelledby` for
|
|
87
|
+
* table cells).
|
|
88
|
+
*/
|
|
89
|
+
hideLabel: boolean;
|
|
90
|
+
private _mobileQuery;
|
|
91
|
+
private isMobile;
|
|
92
|
+
private _hasUserInteracted;
|
|
93
|
+
getInputElement(): Promise<HTMLInputElement | null>;
|
|
94
|
+
/**
|
|
95
|
+
* Lifecycle methods
|
|
96
|
+
* --------------------------------------------------------------------------
|
|
97
|
+
* Form association, ElementInternals, and id generation are provided by
|
|
98
|
+
* NysFormControlElement (@nysds/internals).
|
|
99
|
+
*/
|
|
100
|
+
connectedCallback(): void;
|
|
101
|
+
disconnectedCallback(): void;
|
|
102
|
+
firstUpdated(): void;
|
|
103
|
+
willUpdate(changed: Map<string, unknown>): void;
|
|
104
|
+
updated(changed: Map<string, unknown>): void;
|
|
105
|
+
/**
|
|
106
|
+
* Point the native <input> at a light-DOM element that IDREF attributes cannot
|
|
107
|
+
* reach across the shadow boundary. associateControlRefs sets the control's own
|
|
108
|
+
* ariaLabelledByElements (honored in Chromium) plus a string aria-label fallback
|
|
109
|
+
* for engines that do not yet resolve element references.
|
|
110
|
+
*
|
|
111
|
+
* Only ever called with an external labelledby set: with no external target the
|
|
112
|
+
* native input keeps the internal same-root aria-labelledby IDREF that render()
|
|
113
|
+
* emits, and must not be touched.
|
|
114
|
+
*/
|
|
115
|
+
private _syncExternalLabel;
|
|
116
|
+
/**
|
|
117
|
+
* Form Integration
|
|
118
|
+
* --------------------------------------------------------------------------
|
|
119
|
+
*/
|
|
120
|
+
private _setValue;
|
|
121
|
+
private _manageRequire;
|
|
122
|
+
private _setValidityMessage;
|
|
123
|
+
private _validate;
|
|
124
|
+
formResetCallback(): void;
|
|
125
|
+
/**
|
|
126
|
+
* Functions
|
|
127
|
+
* --------------------------------------------------------------------------
|
|
128
|
+
*/
|
|
129
|
+
checkValidity(): boolean;
|
|
130
|
+
private _handleInvalid;
|
|
131
|
+
private _manageLabelClick;
|
|
132
|
+
get _hasDescription(): boolean;
|
|
133
|
+
get _isStandalone(): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Event Handlers
|
|
136
|
+
* --------------------------------------------------------------------------
|
|
137
|
+
*/
|
|
138
|
+
private _handleMobileQuery;
|
|
139
|
+
private _emitChangeEvent;
|
|
140
|
+
private _emitOtherInputEvent;
|
|
141
|
+
private _handleChange;
|
|
142
|
+
private _handleFocus;
|
|
143
|
+
private _handleBlur;
|
|
144
|
+
private _handleTextInputBlur;
|
|
145
|
+
private _handleKeydown;
|
|
146
|
+
private _handleTextInput;
|
|
147
|
+
private _validateOtherAndEmitError;
|
|
148
|
+
private _dispatchClearError;
|
|
149
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
150
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|