@nysds/nys-textarea 1.19.3 → 1.20.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 @@
1
+ export * from "./nys-textarea";
@@ -0,0 +1,173 @@
1
+ import { NysFormControlElement } from "@nysds/internals";
2
+ import "@nysds/nys-label";
3
+ import "@nysds/nys-errormessage";
4
+ /**
5
+ * A multi-line text input for collecting longer responses like comments, descriptions, or feedback.
6
+ * Form-associated with validation support via ElementInternals.
7
+ *
8
+ * Use for detailed responses needing multiple lines. For single-line input, use `nys-textinput`.
9
+ * For predefined options, use `nys-select`, `nys-radiobutton`, or `nys-checkbox`.
10
+ *
11
+ * @summary Multi-line text input for comments, descriptions, and feedback.
12
+ * @element nys-textarea
13
+ *
14
+ * @slot description - Custom HTML description content below the label.
15
+ *
16
+ * @fires nys-input - Fired on input change. Detail: `{id, value}`.
17
+ * @fires nys-focus - Fired when textarea gains focus.
18
+ * @fires nys-blur - Fired when textarea loses focus. Triggers validation.
19
+ * @fires nys-select - Fired when user selects text. Detail: `{id, value}`.
20
+ *
21
+ * @example Basic
22
+ * ```html
23
+ * <nys-textarea label="Comments"></nys-textarea>
24
+ * ```
25
+ *
26
+ * @example Disabled
27
+ * ```html
28
+ * <nys-textarea label="Comments" disabled></nys-textarea>
29
+ * ```
30
+ *
31
+ * @example Readonly
32
+ * ```html
33
+ * <nys-textarea label="Comments" readonly value="You can see me but not edit me"></nys-textarea>
34
+ * ```
35
+ *
36
+ * @example Required
37
+ * ```html
38
+ * <nys-textarea label="Describe the incident" required></nys-textarea>
39
+ * ```
40
+ *
41
+ * @example Optional
42
+ * ```html
43
+ * <nys-textarea label="Comments" optional></nys-textarea>
44
+ * ```
45
+ *
46
+ * @example Max length
47
+ * ```html
48
+ * <nys-textarea label="Comments" maxlength="100"></nys-textarea>
49
+ * ```
50
+ *
51
+ * @example Width Small
52
+ * ```html
53
+ * <nys-textarea label="Comments" width="sm"></nys-textarea>
54
+ * ```
55
+ *
56
+ * @example Width Medium
57
+ * ```html
58
+ * <nys-textarea label="Comments" width="md"></nys-textarea>
59
+ * ```
60
+ *
61
+ * @example Width Large
62
+ * ```html
63
+ * <nys-textarea label="Comments" width="lg"></nys-textarea>
64
+ * ```
65
+ *
66
+ * @example Description
67
+ * ```html
68
+ * <nys-textarea label="Describe the incident" description="Please provide details"></nys-textarea>
69
+ * ```
70
+ *
71
+ * @example Description Slot
72
+ * ```html
73
+ * <nys-textarea label="Describe the incident">
74
+ * <div slot="description">Please provide details</div>
75
+ * </nys-textarea>
76
+ * ```
77
+ */
78
+ export declare class NysTextarea extends NysFormControlElement {
79
+ static styles: import("lit").CSSResult;
80
+ static shadowRootOptions: {
81
+ delegatesFocus: boolean;
82
+ clonable?: boolean;
83
+ customElementRegistry?: CustomElementRegistry;
84
+ mode: ShadowRootMode;
85
+ serializable?: boolean;
86
+ slotAssignment?: SlotAssignmentMode;
87
+ };
88
+ /** Unique identifier. Auto-generated if not provided. */
89
+ id: string;
90
+ /** Name for form submission. */
91
+ name: string;
92
+ /** Visible label text. Required for accessibility. */
93
+ label: string;
94
+ /** Helper text below label. Use slot for custom HTML. */
95
+ description: string;
96
+ /** Placeholder text. Don't use as label replacement. */
97
+ placeholder: string;
98
+ /** Current textarea value. */
99
+ value: string;
100
+ /** Prevents interaction. */
101
+ disabled: boolean;
102
+ /** Makes textarea readonly but focusable. */
103
+ readonly: boolean;
104
+ /** Marks as required. Shows "Required" flag and validates on blur. */
105
+ required: boolean;
106
+ /** Shows "Optional" flag. Use when most fields are required. */
107
+ optional: boolean;
108
+ /** Tooltip text shown on hover/focus of info icon. */
109
+ tooltip: string;
110
+ /** Adjusts colors for dark backgrounds. */
111
+ inverted: boolean;
112
+ /** Form `id` to associate with when textarea is outside form element. */
113
+ form: string | null;
114
+ /** Maximum character length. */
115
+ maxlength: number | null;
116
+ /**
117
+ * Textarea width: `sm` (88px), `md` (200px), `lg` (384px), `full` (100%, default).
118
+ * @default "full"
119
+ */
120
+ width: "sm" | "md" | "lg" | "full";
121
+ /**
122
+ * Visible height in lines.
123
+ * @default 4
124
+ */
125
+ rows: number;
126
+ /**
127
+ * Resize behavior: `vertical` (default, user can resize height), `none` (fixed size).
128
+ * @default "vertical"
129
+ */
130
+ resize: "vertical" | "none";
131
+ /** Shows error message when true. Set by validation or manually. */
132
+ showError: boolean;
133
+ /** Error message text. Shown only when `showError` is true. */
134
+ errorMessage: string;
135
+ /** Accessible label used only when no visible `label` is provided. */
136
+ ariaLabel: string;
137
+ private _hasUserInteracted;
138
+ /**
139
+ * Lifecycle methods
140
+ * --------------------------------------------------------------------------
141
+ * Form association, ElementInternals, and id generation are provided by
142
+ * NysFormControlElement (@nysds/internals).
143
+ */
144
+ connectedCallback(): void;
145
+ disconnectedCallback(): void;
146
+ firstUpdated(): void;
147
+ updated(changedProperties: Map<string | number | symbol, unknown>): Promise<void>;
148
+ /**
149
+ * Form Integration
150
+ * --------------------------------------------------------------------------
151
+ */
152
+ private _setValue;
153
+ private _manageRequire;
154
+ private _setValidityMessage;
155
+ private _validate;
156
+ formResetCallback(): void;
157
+ /**
158
+ * Functions
159
+ * --------------------------------------------------------------------------
160
+ */
161
+ checkValidity(): boolean;
162
+ private _handleInvalid;
163
+ /**
164
+ * Event Handlers
165
+ * --------------------------------------------------------------------------
166
+ */
167
+ private _handleInput;
168
+ private _handleFocus;
169
+ private _handleBlur;
170
+ private _handleSelect;
171
+ private _handleSelectionChange;
172
+ render(): import("lit-html").TemplateResult<1>;
173
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,31 +1,127 @@
1
- import { LitElement as u, unsafeCSS as y, html as p } from "lit";
1
+ import { LitElement as p, unsafeCSS as v, html as f } from "lit";
2
2
  import { property as a } from "lit/decorators.js";
3
- import { ifDefined as o } from "lit/directives/if-defined.js";
3
+ import { ifDefined as h } from "lit/directives/if-defined.js";
4
+ import "@nysds/nys-label";
5
+ import "@nysds/nys-errormessage";
4
6
  /*!
5
7
  * █▄ █ █ █ █▀▀▀█ █▀▀▄ █▀▀▀█
6
8
  * █ █ █ █▄▄▄█ ▀▀▀▄▄ █ █ ▀▀▀▄▄
7
9
  * █ ▀█ █ █▄▄▄█ █▄▄▀ █▄▄▄█
8
10
  *
9
- * Textarea Component v1.19.3
11
+ * Textarea Component v1.20.0
10
12
  * Part of the New York State Design System
11
13
  * Repository: https://github.com/its-hcd/nysds
12
14
  * License: MIT
13
15
  */
14
- const v = ':host{--_nys-textarea-width: 100%;--_nys-textarea-border-radius: var(--nys-radius-md, 4px);--_nys-textarea-border-width: var(--nys-border-width-sm, 1px);--_nys-textarea-border-color: var(--nys-color-neutral-400, #909395);--_nys-textarea-padding: var(--nys-space-200, 16px);--_nys-textarea-gap: var(--nys-space-50, 4px);--_nys-textarea-color: var(--nys-color-ink, #1b1b1b);--_nys-textarea-color--placeholder: var( --nys-color-text-weaker, var(--nys-color-neutral-500, #797c7f) );--_nys-textarea-outline-color--hover: var(--nys-color-neutral-900, #1b1b1b);--_nys-textarea-outline-width: var(--nys-border-width-sm, 1px);--_nys-textarea-outline-color--focus: var(--nys-color-focus, #004dd1);--_nys-textarea-background-color--disabled: var( --nys-color-neutral-10, #f6f6f6 );--_nys-textarea-border-color--disabled: var(--nys-color-neutral-200, #bec0c1);--_nys-textarea-color--disabled: var( --nys-color-text-disabled, var(--nys-color-neutral-200, #bec0c1) );--_nys-textarea-font-family: var( --nys-font-family-ui, var( --nys-font-family-sans, "Proxima Nova", "Helvetica Neue", "Helvetica", "Arial", sans-serif ) );--_nys-textarea-font-size: var(--nys-font-size-ui-md, 16px);--_nys-textarea-font-weight: var(--nys-font-weight-regular, 400);--_nys-textarea-line-height: var(--nys-font-lineheight-ui-md, 24px);--nys-textarea-letterspacing-ui: var( --nys-font-letterspacing-ui-md, var(--nys-font-letterspacing-400, .044px) )}:host([width=sm]){--_nys-textarea-width: var(--nys-form-width-sm, 88px)}:host([width=md]){--_nys-textarea-width: var(--nys-form-width-md, 200px)}:host([width=lg]){--_nys-textarea-width: var(--nys-form-width-lg, 384px)}:host([width=full]){--_nys-textarea-width: 100%;flex:1}:host([showError]){--_nys-textarea-border-color: var(--nys-color-danger, #b52c2c)}:host([inverted]){--_nys-textarea-outline-color--focus: var(--nys-color-focus-reverse, #7aa5e7)}.nys-textarea{font-weight:var(--_nys-textarea-font-weight);font-family:var(--_nys-textarea-font-family);line-height:var(--_nys-textarea-line-height);letter-spacing:var(--nys-textarea-letterspacing-ui);color:var(--_nys-textarea-color);gap:var(--_nys-textarea-gap);display:flex;flex-direction:column}.nys-textarea__textarea{color:var(--_nys-textarea-color);font-size:var(--_nys-textarea-font-size);font-family:var(--_nys-textarea-font-family);border-radius:var(--_nys-textarea-border-radius);border:solid var(--_nys-textarea-border-color) var(--_nys-textarea-border-width);padding:var(--_nys-textarea-padding);width:var(--_nys-textarea-width);line-height:var(--_nys-textarea-line-height);max-width:var(--_nys-textarea-width);box-sizing:border-box}.nys-textarea__textarea::placeholder{color:var(--_nys-textarea-color--placeholder)}.nys-textarea__textarea.none{resize:none}.nys-textarea__textarea:hover:not(:disabled):not(:focus):not([readonly]){outline:solid var(--_nys-textarea-outline-width) var(--_nys-textarea-outline-color--hover);border-color:var(--_nys-textarea-outline-color--hover)}.nys-textarea__textarea:focus:not([readonly]){outline:solid var(--_nys-textarea-outline-width) var(--_nys-textarea-outline-color--focus);border-color:var(--_nys-textarea-outline-color--focus);caret-color:var(--_nys-textarea-outline-color--focus)}.nys-textarea__textarea:disabled,.nys-textarea__textarea:disabled::placeholder{background-color:var(--_nys-textarea-background-color--disabled);border-color:var(--_nys-textarea-border-color--disabled);color:var(--_nys-textarea-color--disabled);cursor:not-allowed}';
15
- var f = Object.defineProperty, s = (c, e, t, d) => {
16
- for (var i = void 0, h = c.length - 1, n; h >= 0; h--)
17
- (n = c[h]) && (i = n(e, t, i) || i);
18
- return i && f(e, t, i), i;
19
- };
16
+ /*!
17
+ * New York State Design System v1.20.0
18
+ * Description: A design system for New York State's digital products.
19
+ * Repository: https://github.com/its-hcd/nysds
20
+ * License: MIT
21
+ */
20
22
  let x = 0;
21
- const l = class l extends u {
22
- // allows use of elementInternals' API
23
+ function _(o) {
24
+ return `${o}-${Date.now()}-${x++}`;
25
+ }
26
+ const b = (o) => {
27
+ class e extends o {
28
+ get idPrefix() {
29
+ return this.localName || "nys-element";
30
+ }
31
+ ensureId() {
32
+ this.id || (this.id = _(this.idPrefix));
33
+ }
34
+ connectedCallback() {
35
+ super.connectedCallback(), this.ensureId();
36
+ }
37
+ }
38
+ return e;
39
+ }, m = (o) => {
40
+ class e extends b(o) {
41
+ constructor() {
42
+ super(...arguments), this.__internals = null;
43
+ }
44
+ get internals() {
45
+ if (this.__internals) return this.__internals;
46
+ if (typeof this.attachInternals == "function")
47
+ try {
48
+ this.__internals = this.attachInternals();
49
+ } catch {
50
+ this.__internals = null;
51
+ }
52
+ return this.__internals;
53
+ }
54
+ get defaultRole() {
55
+ return null;
56
+ }
57
+ setHostAria(n, i) {
58
+ const l = this.internals;
59
+ if (l && n in l) {
60
+ l[n] = i;
61
+ return;
62
+ }
63
+ const d = g(n);
64
+ i === null ? this.removeAttribute(d) : this.setAttribute(d, i);
65
+ }
66
+ reflectDefaultSemantics() {
67
+ const n = this.defaultRole;
68
+ n && this.setHostAria("role", n);
69
+ }
70
+ connectedCallback() {
71
+ super.connectedCallback(), this.reflectDefaultSemantics();
72
+ }
73
+ }
74
+ return e;
75
+ };
76
+ function g(o) {
77
+ if (o === "role") return "role";
78
+ const e = o.replace(/^aria/, "");
79
+ return "aria-" + e.charAt(0).toLowerCase() + e.slice(1);
80
+ }
81
+ const w = (o) => {
82
+ const e = class extends m(o) {
83
+ setFormValue(i) {
84
+ this.internals?.setFormValue(i ?? null);
85
+ }
86
+ setValidityFromState(i, l, d) {
87
+ const u = this.internals;
88
+ if (!u) return;
89
+ const y = Object.values(i).some(Boolean);
90
+ y ? u.setValidity(i, l ?? "Invalid value", d) : u.setValidity({}), this.setHostAria("ariaInvalid", y ? "true" : "false");
91
+ }
92
+ clearValidity() {
93
+ this.internals?.setValidity({}), this.setHostAria("ariaInvalid", "false");
94
+ }
95
+ checkValidity() {
96
+ return this.internals?.checkValidity() ?? !0;
97
+ }
98
+ reportValidity() {
99
+ return this.internals?.reportValidity() ?? !0;
100
+ }
101
+ formResetCallback() {
102
+ this.clearValidity();
103
+ }
104
+ };
105
+ return e.formAssociated = !0, e;
106
+ }, $ = /* @__PURE__ */ w(p), S = ':host{--_nys-textarea-width: 100%;--_nys-textarea-border-radius: var(--nys-radius-md, 4px);--_nys-textarea-border-width: var(--nys-border-width-sm, 1px);--_nys-textarea-border-color: var(--nys-color-neutral-400, #909395);--_nys-textarea-padding: var(--nys-space-200, 16px);--_nys-textarea-gap: var(--nys-space-50, 4px);--_nys-textarea-color: var(--nys-color-ink, #1b1b1b);--_nys-textarea-color--placeholder: var( --nys-color-text-weaker, var(--nys-color-neutral-500, #797c7f) );--_nys-textarea-outline-color--hover: var(--nys-color-neutral-900, #1b1b1b);--_nys-textarea-outline-width: var(--nys-border-width-sm, 1px);--_nys-textarea-outline-color--focus: var(--nys-color-focus, #004dd1);--_nys-textarea-background-color--disabled: var( --nys-color-neutral-10, #f6f6f6 );--_nys-textarea-border-color--disabled: var(--nys-color-neutral-200, #bec0c1);--_nys-textarea-color--disabled: var( --nys-color-text-disabled, var(--nys-color-neutral-200, #bec0c1) );--_nys-textarea-font-family: var( --nys-font-family-ui, var( --nys-font-family-sans, "Proxima Nova", "Helvetica Neue", "Helvetica", "Arial", sans-serif ) );--_nys-textarea-font-size: var(--nys-font-size-ui-md, 16px);--_nys-textarea-font-weight: var(--nys-font-weight-regular, 400);--_nys-textarea-line-height: var(--nys-font-lineheight-ui-md, 24px);--nys-textarea-letterspacing-ui: var( --nys-font-letterspacing-ui-md, var(--nys-font-letterspacing-400, .044px) )}:host([width=sm]){--_nys-textarea-width: var(--nys-form-width-sm, 88px)}:host([width=md]){--_nys-textarea-width: var(--nys-form-width-md, 200px)}:host([width=lg]){--_nys-textarea-width: var(--nys-form-width-lg, 384px)}:host([width=full]){--_nys-textarea-width: 100%;flex:1}:host([showError]){--_nys-textarea-border-color: var(--nys-color-danger, #b52c2c)}:host([inverted]){--_nys-textarea-outline-color--focus: var(--nys-color-focus-reverse, #7aa5e7)}.nys-textarea{font-weight:var(--_nys-textarea-font-weight);font-family:var(--_nys-textarea-font-family);line-height:var(--_nys-textarea-line-height);letter-spacing:var(--nys-textarea-letterspacing-ui);color:var(--_nys-textarea-color);gap:var(--_nys-textarea-gap);display:flex;flex-direction:column}.nys-textarea__textarea{color:var(--_nys-textarea-color);font-size:var(--_nys-textarea-font-size);font-family:var(--_nys-textarea-font-family);border-radius:var(--_nys-textarea-border-radius);border:solid var(--_nys-textarea-border-color) var(--_nys-textarea-border-width);padding:var(--_nys-textarea-padding);width:var(--_nys-textarea-width);line-height:var(--_nys-textarea-line-height);max-width:var(--_nys-textarea-width);box-sizing:border-box}.nys-textarea__textarea::placeholder{color:var(--_nys-textarea-color--placeholder)}.nys-textarea__textarea.none{resize:none}.nys-textarea__textarea:hover:not(:disabled):not(:focus):not([readonly]){outline:solid var(--_nys-textarea-outline-width) var(--_nys-textarea-outline-color--hover);border-color:var(--_nys-textarea-outline-color--hover)}.nys-textarea__textarea:focus:not([readonly]){outline:solid var(--_nys-textarea-outline-width) var(--_nys-textarea-outline-color--focus);border-color:var(--_nys-textarea-outline-color--focus);caret-color:var(--_nys-textarea-outline-color--focus)}.nys-textarea__textarea:disabled,.nys-textarea__textarea:disabled::placeholder{background-color:var(--_nys-textarea-background-color--disabled);border-color:var(--_nys-textarea-border-color--disabled);color:var(--_nys-textarea-color--disabled);cursor:not-allowed}';
107
+ var V = Object.defineProperty, s = (o, e, t, n) => {
108
+ for (var i = void 0, l = o.length - 1, d; l >= 0; l--)
109
+ (d = o[l]) && (i = d(e, t, i) || i);
110
+ return i && V(e, t, i), i;
111
+ };
112
+ const c = class c extends $ {
23
113
  constructor() {
24
- super(), this.id = "", this.name = "", this.label = "", this.description = "", this.placeholder = "", this.value = "", this.disabled = !1, this.readonly = !1, this.required = !1, this.optional = !1, this.tooltip = "", this.inverted = !1, this.form = null, this.maxlength = null, this.width = "full", this.rows = 4, this.resize = "vertical", this.showError = !1, this.errorMessage = "", this._hasUserInteracted = !1, this._internals = this.attachInternals();
114
+ super(...arguments), this.id = "", this.name = "", this.label = "", this.description = "", this.placeholder = "", this.value = "", this.disabled = !1, this.readonly = !1, this.required = !1, this.optional = !1, this.tooltip = "", this.inverted = !1, this.form = null, this.maxlength = null, this.width = "full", this.rows = 4, this.resize = "vertical", this.showError = !1, this.errorMessage = "", this.ariaLabel = "", this._hasUserInteracted = !1;
25
115
  }
26
- // Generate a unique ID if one is not provided
116
+ // need this flag for "eager mode"
117
+ /**
118
+ * Lifecycle methods
119
+ * --------------------------------------------------------------------------
120
+ * Form association, ElementInternals, and id generation are provided by
121
+ * NysFormControlElement (@nysds/internals).
122
+ */
27
123
  connectedCallback() {
28
- super.connectedCallback(), this.id || (this.id = `nys-textarea-${Date.now()}-${x++}`), this.addEventListener("invalid", this._handleInvalid);
124
+ super.connectedCallback(), this.addEventListener("invalid", this._handleInvalid);
29
125
  }
30
126
  disconnectedCallback() {
31
127
  super.disconnectedCallback(), this.removeEventListener("invalid", this._handleInvalid);
@@ -44,21 +140,17 @@ const l = class l extends u {
44
140
  * --------------------------------------------------------------------------
45
141
  */
46
142
  _setValue() {
47
- this._internals.setFormValue(this.value), this._manageRequire();
143
+ this.setFormValue(this.value), this._manageRequire();
48
144
  }
49
145
  _manageRequire() {
50
146
  const e = this.shadowRoot?.querySelector("textarea");
51
147
  if (!e) return;
52
148
  const t = this.errorMessage || "This field is required";
53
- this.required && !this.value ? (this._internals.ariaInvalid = "true", this._internals.setValidity({ valueMissing: !0 }, t, e)) : (this._internals.ariaInvalid = "false", this._internals.setValidity({}), this._hasUserInteracted = !1);
149
+ this.required && !this.value ? this.setValidityFromState({ valueMissing: !0 }, t, e) : (this.clearValidity(), this._hasUserInteracted = !1);
54
150
  }
55
151
  _setValidityMessage(e = "") {
56
152
  const t = this.shadowRoot?.querySelector("textarea");
57
- t && (this.showError = !!e, this.errorMessage?.trim() && e !== "" && (e = this.errorMessage), this._internals.setValidity(
58
- e ? { customError: !0 } : {},
59
- e,
60
- t
61
- ));
153
+ t && (this.showError = !!e, this.errorMessage?.trim() && e !== "" && (e = this.errorMessage), e ? this.setValidityFromState({ customError: !0 }, e, t) : this.clearValidity());
62
154
  }
63
155
  _validate() {
64
156
  const e = this.shadowRoot?.querySelector("textarea");
@@ -70,7 +162,7 @@ const l = class l extends u {
70
162
  formResetCallback() {
71
163
  this.value = "";
72
164
  const e = this.shadowRoot?.querySelector("textarea");
73
- e && (e.value = "", e.setAttribute("aria-invalid", "false")), this.showError = !1, this._internals.setValidity({}), this.requestUpdate();
165
+ e && (e.value = "", e.setAttribute("aria-invalid", "false")), this.showError = !1, this.clearValidity(), this.requestUpdate();
74
166
  }
75
167
  /**
76
168
  * Functions
@@ -85,9 +177,9 @@ const l = class l extends u {
85
177
  e.preventDefault(), this._hasUserInteracted = !0, this._validate();
86
178
  const t = this.shadowRoot?.querySelector("textarea");
87
179
  if (t) {
88
- const d = this._internals.form;
89
- d ? Array.from(d.elements).find(
90
- (n) => typeof n.checkValidity == "function" && !n.checkValidity()
180
+ const n = this.internals?.form;
181
+ n ? Array.from(n.elements).find(
182
+ (d) => typeof d.checkValidity == "function" && !d.checkValidity()
91
183
  ) === this && t.focus() : t.focus();
92
184
  }
93
185
  }
@@ -98,7 +190,7 @@ const l = class l extends u {
98
190
  // Handle input event to check pattern validity
99
191
  _handleInput(e) {
100
192
  const t = e.target;
101
- this.value = t.value, this._internals.setFormValue(this.value), this._hasUserInteracted && this._validate(), this.dispatchEvent(
193
+ this.value = t.value, this.setFormValue(this.value), this._hasUserInteracted && this._validate(), this.dispatchEvent(
102
194
  new CustomEvent("nys-input", {
103
195
  detail: { id: this.id, value: this.value },
104
196
  bubbles: !0,
@@ -139,9 +231,10 @@ const l = class l extends u {
139
231
  );
140
232
  }
141
233
  render() {
142
- return p`
234
+ return f`
143
235
  <div class="nys-textarea">
144
236
  <nys-label
237
+ id="${this.id}--label"
145
238
  label=${this.label}
146
239
  description=${this.description}
147
240
  flag=${this.required && !this.readonly ? "required" : this.optional ? "optional" : ""}
@@ -158,16 +251,26 @@ const l = class l extends u {
158
251
  ?disabled=${this.disabled}
159
252
  ?required=${this.required && !this.readonly}
160
253
  ?readonly=${this.readonly}
161
- aria-disabled=${o(this.disabled ? "true" : void 0)}
162
- aria-required=${o(this.required ? "true" : void 0)}
163
- aria-label=${o(this.label || void 0)}
164
- aria-description=${o(this.description || void 0)}
165
- placeholder=${o(
254
+ aria-disabled=${h(this.disabled ? "true" : void 0)}
255
+ aria-required=${h(this.required ? "true" : void 0)}
256
+ aria-labelledby=${h(
257
+ this.label ? this.id + "--label" : void 0
258
+ )}
259
+ aria-label=${h(
260
+ !this.label && this.ariaLabel ? this.ariaLabel : void 0
261
+ )}
262
+ aria-description=${h(this.description || void 0)}
263
+ aria-invalid=${this.showError ? "true" : "false"}
264
+ aria-errormessage=${this.id + "--error"}
265
+ aria-describedby=${h(
266
+ this.showError ? this.id + "--error" : void 0
267
+ )}
268
+ placeholder=${h(
166
269
  this.placeholder ? this.placeholder : void 0
167
270
  )}
168
- maxlength=${o(this.maxlength ?? void 0)}
271
+ maxlength=${h(this.maxlength ?? void 0)}
169
272
  .rows=${this.rows}
170
- form=${o(this.form || void 0)}
273
+ form=${h(this.form || void 0)}
171
274
  @input=${this._handleInput}
172
275
  @focus="${this._handleFocus}"
173
276
  @blur="${this._handleBlur}"
@@ -175,18 +278,19 @@ const l = class l extends u {
175
278
  @selectionchange="${this._handleSelectionChange}"
176
279
  ></textarea>
177
280
  <nys-errormessage
281
+ id=${this.id + "--error"}
178
282
  ?showError=${this.showError}
179
- errorMessage=${this._internals.validationMessage || this.errorMessage}
283
+ errorMessage=${this.internals.validationMessage || this.errorMessage}
180
284
  ></nys-errormessage>
181
285
  </div>
182
286
  `;
183
287
  }
184
288
  };
185
- l.styles = y(v), l.shadowRootOptions = {
186
- ...u.shadowRootOptions,
289
+ c.styles = v(S), c.shadowRootOptions = {
290
+ ...p.shadowRootOptions,
187
291
  delegatesFocus: !0
188
- }, l.formAssociated = !0;
189
- let r = l;
292
+ };
293
+ let r = c;
190
294
  s([
191
295
  a({ type: String, reflect: !0 })
192
296
  ], r.prototype, "id");
@@ -244,6 +348,9 @@ s([
244
348
  s([
245
349
  a({ type: String })
246
350
  ], r.prototype, "errorMessage");
351
+ s([
352
+ a({ type: String })
353
+ ], r.prototype, "ariaLabel");
247
354
  customElements.get("nys-textarea") || customElements.define("nys-textarea", r);
248
355
  export {
249
356
  r as NysTextarea
@@ -1 +1 @@
1
- {"version":3,"file":"nys-textarea.js","sources":["../src/nys-textarea.ts"],"sourcesContent":["import { LitElement, html, unsafeCSS } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\n// @ts-ignore: SCSS module imported via bundler as inline\nimport styles from \"./nys-textarea.scss?inline\";\n\nlet textareaIdCounter = 0;\n\n/**\n * A multi-line text input for collecting longer responses like comments, descriptions, or feedback.\n * Form-associated with validation support via ElementInternals.\n *\n * Use for detailed responses needing multiple lines. For single-line input, use `nys-textinput`.\n * For predefined options, use `nys-select`, `nys-radiobutton`, or `nys-checkbox`.\n *\n * @summary Multi-line text input for comments, descriptions, and feedback.\n * @element nys-textarea\n *\n * @slot description - Custom HTML description content below the label.\n *\n * @fires nys-input - Fired on input change. Detail: `{id, value}`.\n * @fires nys-focus - Fired when textarea gains focus.\n * @fires nys-blur - Fired when textarea loses focus. Triggers validation.\n * @fires nys-select - Fired when user selects text. Detail: `{id, value}`.\n *\n * @example Basic\n * ```html\n * <nys-textarea label=\"Comments\"></nys-textarea>\n * ```\n *\n * @example Disabled\n * ```html\n * <nys-textarea label=\"Comments\" disabled></nys-textarea>\n * ```\n *\n * @example Readonly\n * ```html\n * <nys-textarea label=\"Comments\" readonly value=\"You can see me but not edit me\"></nys-textarea>\n * ```\n *\n * @example Required\n * ```html\n * <nys-textarea label=\"Describe the incident\" required></nys-textarea>\n * ```\n *\n * @example Optional\n * ```html\n * <nys-textarea label=\"Comments\" optional></nys-textarea>\n * ```\n *\n * @example Max length\n * ```html\n * <nys-textarea label=\"Comments\" maxlength=\"100\"></nys-textarea>\n * ```\n *\n * @example Width Small\n * ```html\n * <nys-textarea label=\"Comments\" width=\"sm\"></nys-textarea>\n * ```\n *\n * @example Width Medium\n * ```html\n * <nys-textarea label=\"Comments\" width=\"md\"></nys-textarea>\n * ```\n *\n * @example Width Large\n * ```html\n * <nys-textarea label=\"Comments\" width=\"lg\"></nys-textarea>\n * ```\n *\n * @example Description\n * ```html\n * <nys-textarea label=\"Describe the incident\" description=\"Please provide details\"></nys-textarea>\n * ```\n *\n * @example Description Slot\n * ```html\n * <nys-textarea label=\"Describe the incident\">\n * <div slot=\"description\">Please provide details</div>\n * </nys-textarea>\n * ```\n */\n\nexport class NysTextarea extends LitElement {\n static styles = unsafeCSS(styles);\n static shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n /** Unique identifier. Auto-generated if not provided. */\n @property({ type: String, reflect: true }) id = \"\";\n\n /** Name for form submission. */\n @property({ type: String, reflect: true }) name = \"\";\n\n /** Visible label text. Required for accessibility. */\n @property({ type: String }) label = \"\";\n\n /** Helper text below label. Use slot for custom HTML. */\n @property({ type: String }) description = \"\";\n\n /** Placeholder text. Don't use as label replacement. */\n @property({ type: String }) placeholder = \"\";\n\n /** Current textarea value. */\n @property({ type: String }) value = \"\";\n\n /** Prevents interaction. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /** Makes textarea readonly but focusable. */\n @property({ type: Boolean, reflect: true }) readonly = false;\n\n /** Marks as required. Shows \"Required\" flag and validates on blur. */\n @property({ type: Boolean, reflect: true }) required = false;\n\n /** Shows \"Optional\" flag. Use when most fields are required. */\n @property({ type: Boolean, reflect: true }) optional = false;\n\n /** Tooltip text shown on hover/focus of info icon. */\n @property({ type: String }) tooltip = \"\";\n\n /** Adjusts colors for dark backgrounds. */\n @property({ type: Boolean, reflect: true }) inverted = false;\n\n /** Form `id` to associate with when textarea is outside form element. */\n @property({ type: String, reflect: true }) form: string | null = null;\n\n /** Maximum character length. */\n @property({ type: Number }) maxlength: number | null = null;\n\n /**\n * Textarea width: `sm` (88px), `md` (200px), `lg` (384px), `full` (100%, default).\n * @default \"full\"\n */\n @property({ type: String, reflect: true }) width:\n | \"sm\"\n | \"md\"\n | \"lg\"\n | \"full\" = \"full\";\n\n /**\n * Visible height in lines.\n * @default 4\n */\n @property({ type: Number }) rows = 4;\n\n /**\n * Resize behavior: `vertical` (default, user can resize height), `none` (fixed size).\n * @default \"vertical\"\n */\n @property({ type: String, reflect: true }) resize: \"vertical\" | \"none\" =\n \"vertical\";\n\n /** Shows error message when true. Set by validation or manually. */\n @property({ type: Boolean, reflect: true }) showError = false;\n\n /** Error message text. Shown only when `showError` is true. */\n @property({ type: String }) errorMessage = \"\";\n\n private _hasUserInteracted = false; // need this flag for \"eager mode\"\n private _internals: ElementInternals;\n\n /**\n * Lifecycle methods\n * --------------------------------------------------------------------------\n */\n\n static formAssociated = true; // allows use of elementInternals' API\n\n constructor() {\n super();\n this._internals = this.attachInternals();\n }\n\n // Generate a unique ID if one is not provided\n connectedCallback() {\n super.connectedCallback();\n if (!this.id) {\n this.id = `nys-textarea-${Date.now()}-${textareaIdCounter++}`;\n }\n this.addEventListener(\"invalid\", this._handleInvalid);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener(\"invalid\", this._handleInvalid);\n }\n\n firstUpdated() {\n // This ensures our element always participates in the form\n this._setValue();\n }\n\n async updated(changedProperties: Map<string | number | symbol, unknown>) {\n await Promise.resolve();\n\n if (changedProperties.has(\"value\")) {\n this._setValue();\n }\n if (changedProperties.has(\"rows\")) {\n this.rows = this.rows ?? 4;\n }\n if (\n changedProperties.has(\"readonly\") ||\n changedProperties.has(\"required\")\n ) {\n const input = this.shadowRoot?.querySelector(\"textarea\");\n\n if (input) input.required = this.required && !this.readonly;\n }\n }\n\n /**\n * Form Integration\n * --------------------------------------------------------------------------\n */\n\n private _setValue() {\n this._internals.setFormValue(this.value);\n this._manageRequire();\n }\n\n private _manageRequire() {\n const textarea = this.shadowRoot?.querySelector(\"textarea\");\n\n if (!textarea) return;\n\n const message = this.errorMessage || \"This field is required\";\n const isInvalid = this.required && !this.value;\n\n if (isInvalid) {\n this._internals.ariaInvalid = \"true\";\n this._internals.setValidity({ valueMissing: true }, message, textarea);\n } else {\n this._internals.ariaInvalid = \"false\"; // Reset when valid\n this._internals.setValidity({});\n this._hasUserInteracted = false; // Reset lazy validation when valid\n }\n }\n\n private _setValidityMessage(message: string = \"\") {\n const textarea = this.shadowRoot?.querySelector(\"textarea\");\n if (!textarea) return;\n\n // Toggle the HTML <div> tag error message\n this.showError = !!message;\n // If user sets errorMessage, this will always override the native validation message\n if (this.errorMessage?.trim() && message !== \"\") {\n message = this.errorMessage;\n }\n\n this._internals.setValidity(\n message ? { customError: true } : {},\n message,\n textarea,\n );\n }\n\n private _validate() {\n const textarea = this.shadowRoot?.querySelector(\"textarea\");\n if (!textarea) return;\n\n // Get the native validation state\n let message = textarea.validationMessage;\n\n this._setValidityMessage(message);\n }\n\n // This callback is automatically called when the parent form is reset.\n public formResetCallback() {\n this.value = \"\";\n\n const textarea = this.shadowRoot?.querySelector(\"textarea\");\n if (textarea) {\n textarea.value = \"\";\n textarea.setAttribute(\"aria-invalid\", \"false\");\n }\n\n // Reset validation UI\n this.showError = false;\n this._internals.setValidity({});\n\n // Re-render UI\n this.requestUpdate();\n }\n\n /**\n * Functions\n * --------------------------------------------------------------------------\n */\n\n // This helper function is called to perform the element's native validation.\n checkValidity(): boolean {\n const textarea = this.shadowRoot?.querySelector(\"textarea\");\n return textarea ? textarea.checkValidity() : true;\n }\n\n private _handleInvalid(event: Event) {\n event.preventDefault();\n this._hasUserInteracted = true; // Start aggressive mode due to form submission\n this._validate();\n\n const textarea = this.shadowRoot?.querySelector(\"textarea\");\n if (textarea) {\n // Focus only if this is the first invalid element (top-down approach)\n const form = this._internals.form;\n if (form) {\n const elements = Array.from(form.elements) as Array<\n HTMLElement & { checkValidity?: () => boolean }\n >;\n // Find the first element in the form that is invalid\n const firstInvalidElement = elements.find(\n (element) =>\n typeof element.checkValidity === \"function\" &&\n !element.checkValidity(),\n );\n if (firstInvalidElement === this) {\n textarea.focus();\n }\n } else {\n // If not part of a form, simply focus.\n textarea.focus();\n }\n }\n }\n\n /**\n * Event Handlers\n * --------------------------------------------------------------------------\n */\n\n // Handle input event to check pattern validity\n private _handleInput(event: Event) {\n const textarea = event.target as HTMLInputElement;\n this.value = textarea.value;\n this._internals.setFormValue(this.value);\n\n // Field is invalid after unfocused, validate aggressively on each input (e.g. Eager mode: a combination of aggressive and lazy.)\n if (this._hasUserInteracted) {\n this._validate();\n }\n\n this.dispatchEvent(\n new CustomEvent(\"nys-input\", {\n detail: { id: this.id, value: this.value },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n // Handle focus event\n private _handleFocus() {\n this.dispatchEvent(\n new Event(\"nys-focus\", { bubbles: true, composed: true }),\n );\n }\n\n // Handle blur event\n private _handleBlur() {\n if (!this._hasUserInteracted) {\n this._hasUserInteracted = true; // At initial unfocus: if textarea is invalid, start aggressive mode\n }\n\n this._validate();\n this.dispatchEvent(\n new Event(\"nys-blur\", { bubbles: true, composed: true }),\n );\n }\n\n private _handleSelect(e: Event) {\n const select = e.target as HTMLSelectElement;\n this.value = select.value;\n this.dispatchEvent(\n new CustomEvent(\"nys-select\", {\n detail: { id: this.id, value: this.value },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private _handleSelectionChange(e: Event) {\n const select = e.target as HTMLSelectElement;\n this.value = select.value;\n this.dispatchEvent(\n new CustomEvent(\"nys-selectionchange\", {\n detail: { id: this.id, value: this.value },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n render() {\n return html`\n <div class=\"nys-textarea\">\n <nys-label\n label=${this.label}\n description=${this.description}\n flag=${this.required && !this.readonly\n ? \"required\"\n : this.optional\n ? \"optional\"\n : \"\"}\n tooltip=${this.tooltip}\n ?inverted=${this.inverted}\n >\n <slot name=\"description\" slot=\"description\">${this.description}</slot>\n </nys-label>\n <textarea\n class=\"nys-textarea__textarea ${this.resize}\"\n name=${this.name}\n id=${this.id}\n .value=${this.value}\n ?disabled=${this.disabled}\n ?required=${this.required && !this.readonly}\n ?readonly=${this.readonly}\n aria-disabled=${ifDefined(this.disabled ? \"true\" : undefined)}\n aria-required=${ifDefined(this.required ? \"true\" : undefined)}\n aria-label=${ifDefined(this.label || undefined)}\n aria-description=${ifDefined(this.description || undefined)}\n placeholder=${ifDefined(\n this.placeholder ? this.placeholder : undefined,\n )}\n maxlength=${ifDefined(this.maxlength ?? undefined)}\n .rows=${this.rows}\n form=${ifDefined(this.form || undefined)}\n @input=${this._handleInput}\n @focus=\"${this._handleFocus}\"\n @blur=\"${this._handleBlur}\"\n @select=\"${this._handleSelect}\"\n @selectionchange=\"${this._handleSelectionChange}\"\n ></textarea>\n <nys-errormessage\n ?showError=${this.showError}\n errorMessage=${this._internals.validationMessage || this.errorMessage}\n ></nys-errormessage>\n </div>\n `;\n }\n}\n\nif (!customElements.get(\"nys-textarea\")) {\n customElements.define(\"nys-textarea\", NysTextarea);\n}\n"],"names":["textareaIdCounter","_NysTextarea","LitElement","changedProperties","input","textarea","message","event","form","element","select","html","ifDefined","unsafeCSS","styles","NysTextarea","__decorateClass","property"],"mappings":";;;;;;;;;;;;;;;;;;;AAMA,IAAIA,IAAoB;AA6EjB,MAAMC,IAAN,MAAMA,UAAoBC,EAAW;AAAA;AAAA,EAwF1C,cAAc;AACZ,UAAA,GAjFyC,KAAA,KAAK,IAGL,KAAA,OAAO,IAGtB,KAAA,QAAQ,IAGR,KAAA,cAAc,IAGd,KAAA,cAA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,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GAzC/BF,EAyCiC,WAAA,UAAA;AAGDC,EAAA;AAAA,EAA1CC,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM;AAAA,GA5C9BF,EA4CgC,WAAA,MAAA;AAGfC,EAAA;AAAA,EAA3BC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA/CfF,EA+CiB,WAAA,WAAA;AAMeC,EAAA;AAAA,EAA1CC,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM;AAAA,GArD9BF,EAqDgC,WAAA,OAAA;AAUfC,EAAA;AAAA,EAA3BC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA/DfF,EA+DiB,WAAA,MAAA;AAMeC,EAAA;AAAA,EAA1CC,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM;AAAA,GArE9BF,EAqEgC,WAAA,QAAA;AAICC,EAAA;AAAA,EAA3CC,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GAzE/BF,EAyEiC,WAAA,WAAA;AAGhBC,EAAA;AAAA,EAA3BC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA5EfF,EA4EiB,WAAA,cAAA;AA8RzB,eAAe,IAAI,cAAc,KACpC,eAAe,OAAO,gBAAgBA,CAAW;"}
1
+ {"version":3,"file":"nys-textarea.js","sources":["../../internals/dist/index.js","../src/nys-textarea.ts"],"sourcesContent":["import { LitElement as u } from \"lit\";\n/*!\n * New York State Design System v1.20.0\n * Description: A design system for New York State's digital products.\n * Repository: https://github.com/its-hcd/nysds\n * License: MIT\n */\nlet y = 0;\nfunction f(e) {\n return `${e}-${Date.now()}-${y++}`;\n}\nconst p = {\n labelledby: \"ariaLabelledByElements\",\n describedby: \"ariaDescribedByElements\"\n}, A = {\n labelledby: \"ariaLabel\",\n describedby: \"ariaDescription\"\n};\nfunction R(e) {\n return \"ariaDescribedByElements\" in e;\n}\nfunction _(e) {\n return e === \"errormessage\" ? \"aria-errormessage\" : `aria-${e}`;\n}\nfunction d(e) {\n return e.filter((t) => !!t);\n}\nfunction E(e) {\n return e.map((t) => (t.id || (t.id = f(\"nys-ref\")), t.id));\n}\nfunction V(e, t, n) {\n const i = d(n), r = _(t);\n i.length ? e.setAttribute(r, E(i).join(\" \")) : e.removeAttribute(r);\n}\nfunction x(e, t, n, i, r) {\n const s = d(i), a = p[n], l = t;\n if (a && R(t)) {\n l[a] = s.length ? s : null;\n return;\n }\n const o = A[n];\n if (!o) return;\n const c = r ?? (s.length ? s.map((m) => m.textContent?.trim() ?? \"\").filter(Boolean).join(\" \") : \"\");\n o in l ? l[o] = c || null : c ? e.setAttribute(\n n === \"labelledby\" ? \"aria-label\" : \"aria-description\",\n c\n ) : e.removeAttribute(\n n === \"labelledby\" ? \"aria-label\" : \"aria-description\"\n );\n}\nconst g = {\n labelledby: \"ariaLabelledByElements\",\n describedby: \"ariaDescribedByElements\"\n}, C = {\n labelledby: \"aria-label\",\n describedby: \"aria-description\"\n};\nfunction L(e, t, n) {\n const i = d(n), r = g[t], s = C[t], a = e;\n if (r && r in e && (a[r] = i.length ? i : null), !s) return;\n const l = i.map((o) => o.textContent?.trim() ?? \"\").filter(Boolean).join(\" \");\n l ? e.setAttribute(s, l) : e.removeAttribute(s);\n}\nconst b = (e) => {\n class t extends e {\n get idPrefix() {\n return this.localName || \"nys-element\";\n }\n ensureId() {\n this.id || (this.id = f(this.idPrefix));\n }\n connectedCallback() {\n super.connectedCallback(), this.ensureId();\n }\n }\n return t;\n}, P = /* @__PURE__ */ b(u), h = (e) => {\n class t extends b(e) {\n constructor() {\n super(...arguments), this.__internals = null;\n }\n get internals() {\n if (this.__internals) return this.__internals;\n if (typeof this.attachInternals == \"function\")\n try {\n this.__internals = this.attachInternals();\n } catch {\n this.__internals = null;\n }\n return this.__internals;\n }\n get defaultRole() {\n return null;\n }\n setHostAria(i, r) {\n const s = this.internals;\n if (s && i in s) {\n s[i] = r;\n return;\n }\n const a = v(i);\n r === null ? this.removeAttribute(a) : this.setAttribute(a, r);\n }\n reflectDefaultSemantics() {\n const i = this.defaultRole;\n i && this.setHostAria(\"role\", i);\n }\n connectedCallback() {\n super.connectedCallback(), this.reflectDefaultSemantics();\n }\n }\n return t;\n};\nfunction v(e) {\n if (e === \"role\") return \"role\";\n const t = e.replace(/^aria/, \"\");\n return \"aria-\" + t.charAt(0).toLowerCase() + t.slice(1);\n}\nconst T = /* @__PURE__ */ h(u), I = (e) => {\n const n = class n extends h(e) {\n setFormValue(r) {\n this.internals?.setFormValue(r ?? null);\n }\n setValidityFromState(r, s, a) {\n const l = this.internals;\n if (!l) return;\n const o = Object.values(r).some(Boolean);\n o ? l.setValidity(r, s ?? \"Invalid value\", a) : l.setValidity({}), this.setHostAria(\"ariaInvalid\", o ? \"true\" : \"false\");\n }\n clearValidity() {\n this.internals?.setValidity({}), this.setHostAria(\"ariaInvalid\", \"false\");\n }\n checkValidity() {\n return this.internals?.checkValidity() ?? !0;\n }\n reportValidity() {\n return this.internals?.reportValidity() ?? !0;\n }\n formResetCallback() {\n this.clearValidity();\n }\n };\n n.formAssociated = !0;\n let t = n;\n return t;\n}, w = /* @__PURE__ */ I(u);\nfunction O(e) {\n const t = e.tagName.toLowerCase(), n = /* @__PURE__ */ new Set(), i = (r) => {\n r.querySelectorAll(\"*\").forEach((s) => {\n const a = s.tagName.toLowerCase();\n a.startsWith(\"nys-\") && a !== t && !customElements.get(a) && n.add(a), s.shadowRoot && i(s.shadowRoot);\n });\n };\n return e.shadowRoot && i(e.shadowRoot), i(e), [...n].sort();\n}\nexport {\n I as FormControlMixin,\n b as IdentifiedMixin,\n P as NysElement,\n w as NysFormControlElement,\n T as NysReflectsAriaElement,\n h as ReflectsAriaMixin,\n V as associateControl,\n L as associateControlRefs,\n x as associateHost,\n O as findUnregisteredChildren,\n f as generateId,\n R as supportsElementRefs\n};\n//# sourceMappingURL=index.js.map\n","import { LitElement, html, unsafeCSS } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\nimport { NysFormControlElement } from \"@nysds/internals\";\n// These internal elements are rendered inside this component's shadow DOM, so\n// they must be registered whenever nys-textarea is used. Importing them here\n// (intentional side effect) guarantees the visible label and error message —\n// which the accessible name/error association depends on — always render.\nimport \"@nysds/nys-label\";\nimport \"@nysds/nys-errormessage\";\n// @ts-ignore: SCSS module imported via bundler as inline\nimport styles from \"./nys-textarea.scss?inline\";\n\n/**\n * A multi-line text input for collecting longer responses like comments, descriptions, or feedback.\n * Form-associated with validation support via ElementInternals.\n *\n * Use for detailed responses needing multiple lines. For single-line input, use `nys-textinput`.\n * For predefined options, use `nys-select`, `nys-radiobutton`, or `nys-checkbox`.\n *\n * @summary Multi-line text input for comments, descriptions, and feedback.\n * @element nys-textarea\n *\n * @slot description - Custom HTML description content below the label.\n *\n * @fires nys-input - Fired on input change. Detail: `{id, value}`.\n * @fires nys-focus - Fired when textarea gains focus.\n * @fires nys-blur - Fired when textarea loses focus. Triggers validation.\n * @fires nys-select - Fired when user selects text. Detail: `{id, value}`.\n *\n * @example Basic\n * ```html\n * <nys-textarea label=\"Comments\"></nys-textarea>\n * ```\n *\n * @example Disabled\n * ```html\n * <nys-textarea label=\"Comments\" disabled></nys-textarea>\n * ```\n *\n * @example Readonly\n * ```html\n * <nys-textarea label=\"Comments\" readonly value=\"You can see me but not edit me\"></nys-textarea>\n * ```\n *\n * @example Required\n * ```html\n * <nys-textarea label=\"Describe the incident\" required></nys-textarea>\n * ```\n *\n * @example Optional\n * ```html\n * <nys-textarea label=\"Comments\" optional></nys-textarea>\n * ```\n *\n * @example Max length\n * ```html\n * <nys-textarea label=\"Comments\" maxlength=\"100\"></nys-textarea>\n * ```\n *\n * @example Width Small\n * ```html\n * <nys-textarea label=\"Comments\" width=\"sm\"></nys-textarea>\n * ```\n *\n * @example Width Medium\n * ```html\n * <nys-textarea label=\"Comments\" width=\"md\"></nys-textarea>\n * ```\n *\n * @example Width Large\n * ```html\n * <nys-textarea label=\"Comments\" width=\"lg\"></nys-textarea>\n * ```\n *\n * @example Description\n * ```html\n * <nys-textarea label=\"Describe the incident\" description=\"Please provide details\"></nys-textarea>\n * ```\n *\n * @example Description Slot\n * ```html\n * <nys-textarea label=\"Describe the incident\">\n * <div slot=\"description\">Please provide details</div>\n * </nys-textarea>\n * ```\n */\n\nexport class NysTextarea extends NysFormControlElement {\n static styles = unsafeCSS(styles);\n static shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n /** Unique identifier. Auto-generated if not provided. */\n @property({ type: String, reflect: true }) id = \"\";\n\n /** Name for form submission. */\n @property({ type: String, reflect: true }) name = \"\";\n\n /** Visible label text. Required for accessibility. */\n @property({ type: String }) label = \"\";\n\n /** Helper text below label. Use slot for custom HTML. */\n @property({ type: String }) description = \"\";\n\n /** Placeholder text. Don't use as label replacement. */\n @property({ type: String }) placeholder = \"\";\n\n /** Current textarea value. */\n @property({ type: String }) value = \"\";\n\n /** Prevents interaction. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /** Makes textarea readonly but focusable. */\n @property({ type: Boolean, reflect: true }) readonly = false;\n\n /** Marks as required. Shows \"Required\" flag and validates on blur. */\n @property({ type: Boolean, reflect: true }) required = false;\n\n /** Shows \"Optional\" flag. Use when most fields are required. */\n @property({ type: Boolean, reflect: true }) optional = false;\n\n /** Tooltip text shown on hover/focus of info icon. */\n @property({ type: String }) tooltip = \"\";\n\n /** Adjusts colors for dark backgrounds. */\n @property({ type: Boolean, reflect: true }) inverted = false;\n\n /** Form `id` to associate with when textarea is outside form element. */\n @property({ type: String, reflect: true }) form: string | null = null;\n\n /** Maximum character length. */\n @property({ type: Number }) maxlength: number | null = null;\n\n /**\n * Textarea width: `sm` (88px), `md` (200px), `lg` (384px), `full` (100%, default).\n * @default \"full\"\n */\n @property({ type: String, reflect: true }) width:\n | \"sm\"\n | \"md\"\n | \"lg\"\n | \"full\" = \"full\";\n\n /**\n * Visible height in lines.\n * @default 4\n */\n @property({ type: Number }) rows = 4;\n\n /**\n * Resize behavior: `vertical` (default, user can resize height), `none` (fixed size).\n * @default \"vertical\"\n */\n @property({ type: String, reflect: true }) resize: \"vertical\" | \"none\" =\n \"vertical\";\n\n /** Shows error message when true. Set by validation or manually. */\n @property({ type: Boolean, reflect: true }) showError = false;\n\n /** Error message text. Shown only when `showError` is true. */\n @property({ type: String }) errorMessage = \"\";\n\n /** Accessible label used only when no visible `label` is provided. */\n @property({ type: String }) ariaLabel = \"\";\n\n private _hasUserInteracted = false; // need this flag for \"eager mode\"\n\n /**\n * Lifecycle methods\n * --------------------------------------------------------------------------\n * Form association, ElementInternals, and id generation are provided by\n * NysFormControlElement (@nysds/internals).\n */\n\n connectedCallback() {\n // super.connectedCallback() (NysFormControlElement) assigns an id when one\n // is not provided and reflects default semantics.\n super.connectedCallback();\n this.addEventListener(\"invalid\", this._handleInvalid);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener(\"invalid\", this._handleInvalid);\n }\n\n firstUpdated() {\n // This ensures our element always participates in the form\n this._setValue();\n }\n\n async updated(changedProperties: Map<string | number | symbol, unknown>) {\n await Promise.resolve();\n\n if (changedProperties.has(\"value\")) {\n this._setValue();\n }\n if (changedProperties.has(\"rows\")) {\n this.rows = this.rows ?? 4;\n }\n if (\n changedProperties.has(\"readonly\") ||\n changedProperties.has(\"required\")\n ) {\n const input = this.shadowRoot?.querySelector(\"textarea\");\n\n if (input) input.required = this.required && !this.readonly;\n }\n }\n\n /**\n * Form Integration\n * --------------------------------------------------------------------------\n */\n\n private _setValue() {\n this.setFormValue(this.value);\n this._manageRequire();\n }\n\n private _manageRequire() {\n const textarea = this.shadowRoot?.querySelector(\"textarea\");\n\n if (!textarea) return;\n\n const message = this.errorMessage || \"This field is required\";\n const isInvalid = this.required && !this.value;\n\n if (isInvalid) {\n this.setValidityFromState({ valueMissing: true }, message, textarea);\n } else {\n this.clearValidity();\n this._hasUserInteracted = false; // Reset lazy validation when valid\n }\n }\n\n private _setValidityMessage(message: string = \"\") {\n const textarea = this.shadowRoot?.querySelector(\"textarea\");\n if (!textarea) return;\n\n // Toggle the HTML <div> tag error message\n this.showError = !!message;\n // If user sets errorMessage, this will always override the native validation message\n if (this.errorMessage?.trim() && message !== \"\") {\n message = this.errorMessage;\n }\n\n if (message) {\n this.setValidityFromState({ customError: true }, message, textarea);\n } else {\n this.clearValidity();\n }\n }\n\n private _validate() {\n const textarea = this.shadowRoot?.querySelector(\"textarea\");\n if (!textarea) return;\n\n // Get the native validation state\n let message = textarea.validationMessage;\n\n this._setValidityMessage(message);\n }\n\n // This callback is automatically called when the parent form is reset.\n public formResetCallback() {\n this.value = \"\";\n\n const textarea = this.shadowRoot?.querySelector(\"textarea\");\n if (textarea) {\n textarea.value = \"\";\n textarea.setAttribute(\"aria-invalid\", \"false\");\n }\n\n // Reset validation UI\n this.showError = false;\n this.clearValidity();\n\n // Re-render UI\n this.requestUpdate();\n }\n\n /**\n * Functions\n * --------------------------------------------------------------------------\n */\n\n // This helper function is called to perform the element's native validation.\n checkValidity(): boolean {\n const textarea = this.shadowRoot?.querySelector(\"textarea\");\n return textarea ? textarea.checkValidity() : true;\n }\n\n private _handleInvalid(event: Event) {\n event.preventDefault();\n this._hasUserInteracted = true; // Start aggressive mode due to form submission\n this._validate();\n\n const textarea = this.shadowRoot?.querySelector(\"textarea\");\n if (textarea) {\n // Focus only if this is the first invalid element (top-down approach)\n const form = this.internals?.form;\n if (form) {\n const elements = Array.from(form.elements) as Array<\n HTMLElement & { checkValidity?: () => boolean }\n >;\n // Find the first element in the form that is invalid\n const firstInvalidElement = elements.find(\n (element) =>\n typeof element.checkValidity === \"function\" &&\n !element.checkValidity(),\n );\n if (firstInvalidElement === this) {\n textarea.focus();\n }\n } else {\n // If not part of a form, simply focus.\n textarea.focus();\n }\n }\n }\n\n /**\n * Event Handlers\n * --------------------------------------------------------------------------\n */\n\n // Handle input event to check pattern validity\n private _handleInput(event: Event) {\n const textarea = event.target as HTMLInputElement;\n this.value = textarea.value;\n this.setFormValue(this.value);\n\n // Field is invalid after unfocused, validate aggressively on each input (e.g. Eager mode: a combination of aggressive and lazy.)\n if (this._hasUserInteracted) {\n this._validate();\n }\n\n this.dispatchEvent(\n new CustomEvent(\"nys-input\", {\n detail: { id: this.id, value: this.value },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n // Handle focus event\n private _handleFocus() {\n this.dispatchEvent(\n new Event(\"nys-focus\", { bubbles: true, composed: true }),\n );\n }\n\n // Handle blur event\n private _handleBlur() {\n if (!this._hasUserInteracted) {\n this._hasUserInteracted = true; // At initial unfocus: if textarea is invalid, start aggressive mode\n }\n\n this._validate();\n this.dispatchEvent(\n new Event(\"nys-blur\", { bubbles: true, composed: true }),\n );\n }\n\n private _handleSelect(e: Event) {\n const select = e.target as HTMLSelectElement;\n this.value = select.value;\n this.dispatchEvent(\n new CustomEvent(\"nys-select\", {\n detail: { id: this.id, value: this.value },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private _handleSelectionChange(e: Event) {\n const select = e.target as HTMLSelectElement;\n this.value = select.value;\n this.dispatchEvent(\n new CustomEvent(\"nys-selectionchange\", {\n detail: { id: this.id, value: this.value },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n render() {\n return html`\n <div class=\"nys-textarea\">\n <nys-label\n id=\"${this.id}--label\"\n label=${this.label}\n description=${this.description}\n flag=${this.required && !this.readonly\n ? \"required\"\n : this.optional\n ? \"optional\"\n : \"\"}\n tooltip=${this.tooltip}\n ?inverted=${this.inverted}\n >\n <slot name=\"description\" slot=\"description\">${this.description}</slot>\n </nys-label>\n <textarea\n class=\"nys-textarea__textarea ${this.resize}\"\n name=${this.name}\n id=${this.id}\n .value=${this.value}\n ?disabled=${this.disabled}\n ?required=${this.required && !this.readonly}\n ?readonly=${this.readonly}\n aria-disabled=${ifDefined(this.disabled ? \"true\" : undefined)}\n aria-required=${ifDefined(this.required ? \"true\" : undefined)}\n aria-labelledby=${ifDefined(\n this.label ? this.id + \"--label\" : undefined,\n )}\n aria-label=${ifDefined(\n !this.label && this.ariaLabel ? this.ariaLabel : undefined,\n )}\n aria-description=${ifDefined(this.description || undefined)}\n aria-invalid=${this.showError ? \"true\" : \"false\"}\n aria-errormessage=${this.id + \"--error\"}\n aria-describedby=${ifDefined(\n this.showError ? this.id + \"--error\" : undefined,\n )}\n placeholder=${ifDefined(\n this.placeholder ? this.placeholder : undefined,\n )}\n maxlength=${ifDefined(this.maxlength ?? undefined)}\n .rows=${this.rows}\n form=${ifDefined(this.form || undefined)}\n @input=${this._handleInput}\n @focus=\"${this._handleFocus}\"\n @blur=\"${this._handleBlur}\"\n @select=\"${this._handleSelect}\"\n @selectionchange=\"${this._handleSelectionChange}\"\n ></textarea>\n <nys-errormessage\n id=${this.id + \"--error\"}\n ?showError=${this.showError}\n errorMessage=${this.internals!.validationMessage || this.errorMessage}\n ></nys-errormessage>\n </div>\n `;\n }\n}\n\nif (!customElements.get(\"nys-textarea\")) {\n customElements.define(\"nys-textarea\", NysTextarea);\n}\n"],"names":["LitElement","unsafeCSS","html","property","ifDefined","y","f","e","t","h","i","r","s","a","v","I","n","l","o","w","u","_NysTextarea","NysFormControlElement","changedProperties","input","textarea","message","event","form","element","select","styles","NysTextarea","__decorateClass"],"mappings":"AACA,SAAA,cAAAA,GAAA,aAAAC,GAAA,QAAAC,SAAA;AAAA,SAAA,YAAAC,SAAA;AAAA,SAAA,aAAAC,SAAA;AAAA,OAAA;AAAA,OAAA;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,IAAIC,IAAI;AACR,SAASC,EAAEC,GAAG;AACZ,SAAO,GAAGA,CAAC,IAAI,KAAK,KAAK,IAAIF,GAAG;AAClC;AAqDK,MAAC,IAAI,CAACE,MAAM;AAAA,EACf,MAAMC,UAAUD,EAAE;AAAA,IAChB,IAAI,WAAW;AACb,aAAO,KAAK,aAAa;AAAA,IAC3B;AAAA,IACA,WAAW;AACT,WAAK,OAAO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AAQ,SAAS,IAAM;AAAA,GA5C9B6B,EA4CgC,WAAA,MAAA;AAGfC,EAAA;AAAA,EAA3B9B,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA/Cf6B,EA+CiB,WAAA,WAAA;AAMeC,EAAA;AAAA,EAA1C9B,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM;AAAA,GArD9B6B,EAqDgC,WAAA,OAAA;AAUfC,EAAA;AAAA,EAA3B9B,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA/Df6B,EA+DiB,WAAA,MAAA;AAMeC,EAAA;AAAA,EAA1C9B,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM;AAAA,GArE9B6B,EAqEgC,WAAA,QAAA;AAICC,EAAA;AAAA,EAA3C9B,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GAzE/B6B,EAyEiC,WAAA,WAAA;AAGhBC,EAAA;AAAA,EAA3B9B,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA5Ef6B,EA4EiB,WAAA,cAAA;AAGAC,EAAA;AAAA,EAA3B9B,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA/Ef6B,EA+EiB,WAAA,WAAA;AAgSzB,eAAe,IAAI,cAAc,KACpC,eAAe,OAAO,gBAAgBA,CAAW;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nysds/nys-textarea",
3
- "version": "1.19.3",
3
+ "version": "1.20.0",
4
4
  "description": "The Textarea component from the NYS Design System.",
5
5
  "module": "dist/nys-textarea.js",
6
6
  "types": "dist/index.d.ts",
@@ -23,11 +23,12 @@
23
23
  "lit-analyze": "lit-analyzer '**/*.ts'"
24
24
  },
25
25
  "dependencies": {
26
- "@nysds/nys-icon": "^1.19.3",
27
- "@nysds/nys-label": "^1.19.3",
28
- "@nysds/nys-errormessage": "^1.19.3"
26
+ "@nysds/nys-icon": "^1.20.0",
27
+ "@nysds/nys-label": "^1.20.0",
28
+ "@nysds/nys-errormessage": "^1.20.0"
29
29
  },
30
30
  "devDependencies": {
31
+ "@nysds/internals": "^1.20.0",
31
32
  "lit": "^3.3.1",
32
33
  "typescript": "^5.9.3",
33
34
  "vite": "^7.3.1"