@nysds/nys-checkbox 1.21.1 → 1.22.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.
@@ -4,6 +4,51 @@ import "@nysds/nys-label";
4
4
  import "@nysds/nys-errormessage";
5
5
  import "@nysds/nys-icon";
6
6
  import "@nysds/nys-textinput";
7
+ /** Detail payload for the `nys-change` event fired by `nys-checkbox`. */
8
+ export interface NysCheckboxChangeDetail {
9
+ id: string;
10
+ checked: boolean;
11
+ name: string;
12
+ value: string;
13
+ }
14
+ /** The `nys-change` event fired by `nys-checkbox`. */
15
+ export type NysCheckboxChangeEvent = CustomEvent<NysCheckboxChangeDetail>;
16
+ /** Detail payload for the `nys-other-input` event fired by `nys-checkbox`. */
17
+ export interface NysCheckboxOtherInputDetail {
18
+ id: string;
19
+ name: string;
20
+ value: string;
21
+ }
22
+ /** The `nys-other-input` event fired by `nys-checkbox`. */
23
+ export type NysCheckboxOtherInputEvent = CustomEvent<NysCheckboxOtherInputDetail>;
24
+ /**
25
+ * Detail payload for the `nys-error` group-coordination event.
26
+ * @internal
27
+ */
28
+ export interface NysCheckboxErrorDetail {
29
+ id: string;
30
+ name: string;
31
+ type: "other";
32
+ message: string;
33
+ sourceCheckbox: NysCheckbox;
34
+ }
35
+ /**
36
+ * The `nys-error` group-coordination event.
37
+ * @internal
38
+ */
39
+ export type NysCheckboxErrorEvent = CustomEvent<NysCheckboxErrorDetail>;
40
+ /**
41
+ * Detail payload for the `nys-error-clear` group-coordination event.
42
+ * @internal
43
+ */
44
+ export interface NysCheckboxErrorClearDetail {
45
+ sourceCheckbox: NysCheckbox;
46
+ }
47
+ /**
48
+ * The `nys-error-clear` group-coordination event.
49
+ * @internal
50
+ */
51
+ export type NysCheckboxErrorClearEvent = CustomEvent<NysCheckboxErrorClearDetail>;
7
52
  /**
8
53
  * A checkbox input for binary choices or multi-select lists. Can be used standalone or in a `nys-checkboxgroup`.
9
54
  * Form-associated with validation via ElementInternals.
@@ -13,13 +58,27 @@ import "@nysds/nys-textinput";
13
58
  *
14
59
  * @summary Checkbox for binary choices or multi-select options.
15
60
  * @element nys-checkbox
61
+ * @formControl checked nys-change
16
62
  *
17
63
  * @slot description - Custom HTML description content.
18
64
  *
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}`.
65
+ * @fires {NysCheckboxChangeEvent} nys-change - Fired when checked state changes. Detail: `{id, checked, name, value}`. Bubbles and composed.
66
+ * @fires {Event} nys-focus - Fired when checkbox gains focus. Bubbles and composed.
67
+ * @fires {Event} nys-blur - Fired when checkbox loses focus. Bubbles and composed.
68
+ * @fires {NysCheckboxOtherInputEvent} nys-other-input - Fired when "other" text input value changes. Detail: `{id, name, value}`.
69
+ * @fires {NysCheckboxErrorEvent} nys-error - Internal group coordination: reports an empty "other" field to the parent `nys-checkboxgroup`. Not part of the public API.
70
+ * @fires {NysCheckboxErrorClearEvent} nys-error-clear - Internal group coordination: clears a previously reported "other" field error. Not part of the public API.
71
+ *
72
+ * @usagedos
73
+ * - Use for binary decisions (agree/disagree), confirmation, or multi-select lists.
74
+ * - Use for selecting multiple options from a list of up to 10 choices.
75
+ * - Use `nys-checkboxgroup` to group checkboxes with a shared label and description.
76
+ *
77
+ * @usagedonts
78
+ * - Use when users need to select only one option. Use a `<nys-radiobutton>` for 1–6 choices or a <nys-select> for 7 or more.
79
+ * - Use a checkbox when changing its state immediately affects the system. Use a `<nys-toggle>` instead (e.g., enabling Dark Mode).
80
+ * - Use when you have more than 10 options to choose from.
81
+ * - Change the state of one checkbox based on another being clicked.
23
82
  *
24
83
  * @example Single
25
84
  * ```html
@@ -63,7 +122,12 @@ export declare class NysCheckbox extends NysFormControlElement {
63
122
  showError: boolean;
64
123
  /** Error message text. Shown only when `showError` is true. */
65
124
  errorMessage: string;
66
- /** Internal: Set by parent checkboxgroup. Do not set manually. */
125
+ /**
126
+ * Set by the parent `nys-checkboxgroup` (via property) when all checkboxes
127
+ * in the group share a name, so the group owns the combined form value.
128
+ * Internal coordination state. Do not set manually.
129
+ * @internal
130
+ */
67
131
  groupExist: boolean;
68
132
  /** Renders as tile with larger clickable area. Apply to group for consistency. */
69
133
  tile: boolean;
@@ -74,7 +138,13 @@ export declare class NysCheckbox extends NysFormControlElement {
74
138
  * @default "md"
75
139
  */
76
140
  size: "sm" | "md";
141
+ /** Renders an additional free-text input when checked ("Other" option). */
77
142
  other: boolean;
143
+ /**
144
+ * Whether the "other" free-text field is in an error state. Managed by the
145
+ * component during validation; treat as read-only.
146
+ * @internal
147
+ */
78
148
  showOtherError: boolean;
79
149
  /**
80
150
  * Id of an element in the host's light-DOM tree to borrow the accessible name
@@ -129,8 +199,8 @@ export declare class NysCheckbox extends NysFormControlElement {
129
199
  checkValidity(): boolean;
130
200
  private _handleInvalid;
131
201
  private _manageLabelClick;
132
- get _hasDescription(): boolean;
133
- get _isStandalone(): boolean;
202
+ private get _hasDescription();
203
+ private get _isStandalone();
134
204
  /**
135
205
  * Event Handlers
136
206
  * --------------------------------------------------------------------------