@nysds/components 1.20.0-alpha1 → 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/custom-elements.json +7119 -3701
- package/dist/.vscode/vscode.css-custom-data.json +5 -0
- package/dist/.vscode/vscode.html-custom-data.json +317 -38
- package/dist/custom-elements.json +7119 -3701
- package/dist/nys-icon.library-Cfdq5Zdc.js +696 -0
- package/dist/nys-icon.library-Cfdq5Zdc.js.map +1 -0
- package/dist/nys-icon.library-DHBltclg-BYYeCcpo.js +706 -0
- package/dist/nys-icon.library-DHBltclg-BYYeCcpo.js.map +1 -0
- package/dist/nysds.es.js +9113 -4162
- package/dist/nysds.es.js.map +1 -1
- package/dist/nysds.js +2413 -492
- package/dist/nysds.js.map +1 -1
- package/dist/packages/internals/src/aria-associate.d.ts +41 -0
- package/dist/packages/internals/src/form-control-mixin.d.ts +34 -0
- package/dist/packages/internals/src/id.d.ts +8 -0
- package/dist/packages/internals/src/identified-mixin.d.ts +23 -0
- package/dist/packages/internals/src/index.d.ts +7 -0
- package/dist/packages/internals/src/reflects-aria-mixin.d.ts +33 -0
- package/dist/packages/internals/src/test-helpers.d.ts +29 -0
- package/dist/packages/internals/src/types.d.ts +9 -0
- package/dist/packages/nys-accordion/src/nys-accordion.d.ts +72 -10
- package/dist/packages/nys-accordion/src/nys-accordionitem.d.ts +63 -8
- package/dist/packages/nys-alert/src/nys-alert.d.ts +95 -20
- package/dist/packages/nys-avatar/src/nys-avatar.d.ts +100 -7
- package/dist/packages/nys-backtotop/src/nys-backtotop.d.ts +75 -5
- package/dist/packages/nys-badge/src/nys-badge.d.ts +63 -6
- package/dist/packages/nys-breadcrumbs/src/nys-breadcrumbs.d.ts +79 -10
- package/dist/packages/nys-button/src/nys-button.d.ts +132 -26
- package/dist/packages/nys-card/src/index.d.ts +1 -0
- package/dist/packages/nys-card/src/nys-card.d.ts +325 -0
- package/dist/packages/nys-card/src/nys-card.figma.d.ts +1 -0
- package/dist/packages/nys-checkbox/src/nys-checkbox.d.ts +37 -12
- package/dist/packages/nys-checkbox/src/nys-checkboxgroup.d.ts +84 -6
- package/dist/packages/nys-combobox/src/nys-combobox.d.ts +174 -5
- package/dist/packages/nys-datepicker/src/nys-datepicker.d.ts +83 -13
- package/dist/packages/nys-divider/src/nys-divider.d.ts +33 -9
- package/dist/packages/nys-dropdownmenu/src/nys-dropdownmenu.d.ts +24 -15
- package/dist/packages/nys-dropdownmenu/src/nys-dropdownmenuitem.d.ts +3 -12
- package/dist/packages/nys-errormessage/src/nys-errormessage.d.ts +22 -0
- package/dist/packages/nys-fileinput/src/nys-fileinput.d.ts +129 -12
- package/dist/packages/nys-fileinput/src/nys-fileitem.d.ts +23 -2
- package/dist/packages/nys-globalfooter/src/nys-globalfooter.d.ts +99 -9
- package/dist/packages/nys-globalheader/src/nys-globalheader.d.ts +197 -7
- package/dist/packages/nys-icon/src/icon-cache.d.ts +11 -4
- package/dist/packages/nys-icon/src/icon-library-registry.d.ts +33 -16
- package/dist/packages/nys-icon/src/index.d.ts +2 -2
- package/dist/packages/nys-icon/src/nys-icon.d.ts +98 -8
- package/dist/packages/nys-iconlist/src/index.d.ts +2 -0
- package/dist/packages/nys-iconlist/src/nys-iconlist.d.ts +92 -0
- package/dist/packages/nys-iconlist/src/nys-iconlist.figma.d.ts +1 -0
- package/dist/packages/nys-iconlist/src/nys-iconlistitem.d.ts +32 -0
- package/dist/packages/nys-label/src/nys-label.d.ts +37 -2
- package/dist/packages/nys-modal/src/nys-modal.d.ts +145 -13
- package/dist/packages/nys-pagination/src/nys-pagination.d.ts +67 -3
- package/dist/packages/nys-processlist/src/index.d.ts +2 -0
- package/dist/packages/nys-processlist/src/nys-processlist.d.ts +184 -0
- package/dist/packages/nys-processlist/src/nys-processlist.figma.d.ts +1 -0
- package/dist/packages/nys-processlist/src/nys-processlistitem.d.ts +41 -0
- package/dist/packages/nys-radiobutton/src/nys-radiobutton.d.ts +201 -7
- package/dist/packages/nys-radiobutton/src/nys-radiogroup.d.ts +88 -6
- package/dist/packages/nys-select/src/nys-option.d.ts +0 -8
- package/dist/packages/nys-select/src/nys-select.d.ts +150 -15
- package/dist/packages/nys-skipnav/src/nys-skipnav.d.ts +4 -4
- package/dist/packages/nys-stepper/src/nys-step.d.ts +26 -20
- package/dist/packages/nys-stepper/src/nys-stepper.d.ts +128 -75
- package/dist/packages/nys-tab/src/nys-tab.d.ts +19 -10
- package/dist/packages/nys-tab/src/nys-tabgroup.d.ts +181 -39
- package/dist/packages/nys-tab/src/nys-tabpanel.d.ts +15 -24
- package/dist/packages/nys-table/src/nys-table.d.ts +90 -3
- package/dist/packages/nys-textarea/src/nys-textarea.d.ts +60 -10
- package/dist/packages/nys-textinput/src/nys-textinput.d.ts +77 -14
- package/dist/packages/nys-toggle/src/nys-toggle.d.ts +47 -10
- package/dist/packages/nys-tooltip/src/nys-tooltip.d.ts +48 -8
- package/dist/packages/nys-unavfooter/src/nys-unavfooter.d.ts +45 -4
- package/dist/packages/nys-unavheader/src/nys-unavheader.d.ts +219 -10
- package/dist/packages/nys-verticalnav/src/nys-verticalnav.d.ts +421 -37
- package/dist/packages/nys-verticalnav/src/nys-verticalnavgroup.d.ts +4 -54
- package/dist/packages/nys-video/src/nys-video.d.ts +67 -7
- package/dist/src/index.d.ts +5 -2
- package/package.json +14 -6
- package/packages/react/NysAccordion.d.ts +10 -0
- package/packages/react/NysAccordion.js +2 -1
- package/packages/react/NysAccordionItem.d.ts +10 -0
- package/packages/react/NysAccordionItem.js +3 -1
- package/packages/react/NysAlert.d.ts +8 -10
- package/packages/react/NysAlert.js +0 -2
- package/packages/react/NysAvatar.d.ts +11 -1
- package/packages/react/NysBacktotop.d.ts +3 -0
- package/packages/react/NysBacktotop.js +2 -1
- package/packages/react/NysBreadcrumbs.d.ts +2 -2
- package/packages/react/NysButton.d.ts +38 -8
- package/packages/react/NysButton.js +6 -4
- package/packages/react/NysCard.d.ts +110 -0
- package/packages/react/NysCard.js +61 -0
- package/packages/react/NysCheckbox.d.ts +9 -0
- package/packages/react/NysCheckbox.js +4 -0
- package/packages/react/NysDropdownMenu.d.ts +4 -2
- package/packages/react/NysFileinput.d.ts +25 -3
- package/packages/react/NysFileinput.js +8 -1
- package/packages/react/NysGlobalFooter.d.ts +17 -0
- package/packages/react/NysGlobalFooter.js +10 -2
- package/packages/react/NysGlobalHeader.d.ts +23 -1
- package/packages/react/NysGlobalHeader.js +11 -2
- package/packages/react/NysIconlist.d.ts +54 -0
- package/packages/react/NysIconlist.js +22 -0
- package/packages/react/NysIconlistitem.d.ts +59 -0
- package/packages/react/NysIconlistitem.js +22 -0
- package/packages/react/NysLabel.d.ts +4 -1
- package/packages/react/NysModal.d.ts +8 -1
- package/packages/react/NysModal.js +11 -2
- package/packages/react/NysProcesslist.d.ts +65 -0
- package/packages/react/NysProcesslist.js +25 -0
- package/packages/react/NysProcesslistitem.d.ts +61 -0
- package/packages/react/NysProcesslistitem.js +35 -0
- package/packages/react/NysRadiobutton.d.ts +27 -3
- package/packages/react/NysRadiobutton.js +9 -1
- package/packages/react/NysSelect.d.ts +3 -0
- package/packages/react/NysSelect.js +2 -0
- package/packages/react/NysStepper.d.ts +1 -1
- package/packages/react/NysTabgroup.d.ts +5 -4
- package/packages/react/NysTable.d.ts +1 -1
- package/packages/react/NysTabpanel.d.ts +11 -4
- package/packages/react/NysTextarea.d.ts +4 -1
- package/packages/react/NysTextarea.js +2 -0
- package/packages/react/NysUnavFooter.d.ts +13 -0
- package/packages/react/NysUnavFooter.js +4 -1
- package/packages/react/NysUnavHeader.d.ts +24 -1
- package/packages/react/NysUnavHeader.js +17 -1
- package/packages/react/NysVerticalnav.d.ts +15 -8
- package/packages/react/NysVerticalnav.js +6 -4
- package/packages/react/NysVerticalnavGroup.d.ts +4 -0
- package/packages/react/NysVerticalnavGroup.js +5 -0
- package/packages/react/index.d.ts +5 -0
- package/packages/react/index.js +5 -0
- package/packages/react/nysds-jsx.d.ts +394 -56
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { AriaRelation, AriaTargets } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Feature-detect ARIA element-reference reflection on ElementInternals
|
|
4
|
+
* (e.g. `internals.ariaDescribedByElements`). When false, callers fall back to
|
|
5
|
+
* string reflection or IDREF attributes.
|
|
6
|
+
*/
|
|
7
|
+
export declare function supportsElementRefs(internals: ElementInternals): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Associate a native control (e.g. the `<input>` rendered inside a component's
|
|
10
|
+
* shadow root) with sibling target elements via IDREF attributes.
|
|
11
|
+
*
|
|
12
|
+
* IDREFs resolve within the control's own shadow root, so this is correct and
|
|
13
|
+
* universally supported across browsers — the right tool for form controls that
|
|
14
|
+
* wrap a real focusable element. Missing target ids are auto-assigned. Passing
|
|
15
|
+
* an empty/all-nullish target list removes the attribute.
|
|
16
|
+
*/
|
|
17
|
+
export declare function associateControl(control: HTMLElement, relation: AriaRelation, targets: AriaTargets): void;
|
|
18
|
+
/**
|
|
19
|
+
* Associate the HOST element's accessible name/description with target elements
|
|
20
|
+
* using ElementInternals ARIA element references, which are designed to cross
|
|
21
|
+
* the shadow boundary (host semantics → shadow-internal nodes).
|
|
22
|
+
*
|
|
23
|
+
* Falls back to string ARIA reflection (`internals.ariaLabel` /
|
|
24
|
+
* `internals.ariaDescription`) — and finally to a host attribute — using
|
|
25
|
+
* `fallback` or the targets' text content. Only "labelledby" and "describedby"
|
|
26
|
+
* are meaningful at host level. Use this for presentational components and
|
|
27
|
+
* custom controls that have no inner native focusable element.
|
|
28
|
+
*/
|
|
29
|
+
export declare function associateHost(host: HTMLElement, internals: ElementInternals, relation: AriaRelation, targets: AriaTargets, fallback?: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Associate a native control (e.g. the shadow-DOM `<input>`) with target elements
|
|
32
|
+
* that may live OUTSIDE the control's shadow root (a light-DOM `<th>`), which IDREF
|
|
33
|
+
* attributes cannot reach.
|
|
34
|
+
*
|
|
35
|
+
* Sets the control's own `ariaLabelledByElements`/`ariaDescribedByElements` (honored
|
|
36
|
+
* where supported — Chromium verified) AND a string `aria-label`/`aria-description`
|
|
37
|
+
* fallback derived from the targets' text. Both resolve to the same name; the element
|
|
38
|
+
* reference takes precedence where the engine honors it. Passing an empty/all-nullish
|
|
39
|
+
* target list clears both.
|
|
40
|
+
*/
|
|
41
|
+
export declare function associateControlRefs(control: HTMLElement, relation: AriaRelation, targets: AriaTargets): void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
import { type Constructor, type ReflectsAriaInterface } from "./reflects-aria-mixin";
|
|
3
|
+
import type { FormValue } from "./types";
|
|
4
|
+
/** Surface added by {@link FormControlMixin}, on top of {@link ReflectsAriaInterface}. */
|
|
5
|
+
export declare class FormControlInterface extends ReflectsAriaInterface {
|
|
6
|
+
/** Form-associated custom element opt-in. */
|
|
7
|
+
static formAssociated: boolean;
|
|
8
|
+
/** Push the current value into the owning form. */
|
|
9
|
+
protected setFormValue(value: FormValue): void;
|
|
10
|
+
/** Map a set of validity flags to `setValidity` + host `aria-invalid`. */
|
|
11
|
+
protected setValidityFromState(flags: ValidityStateFlags, message?: string, anchor?: HTMLElement): void;
|
|
12
|
+
/** Clear validity and reset `aria-invalid`. */
|
|
13
|
+
protected clearValidity(): void;
|
|
14
|
+
checkValidity(): boolean;
|
|
15
|
+
reportValidity(): boolean;
|
|
16
|
+
formResetCallback(): void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Mixin that makes an element a form-associated custom element with centralized
|
|
20
|
+
* value, validity, and ARIA-association plumbing. Composes
|
|
21
|
+
* {@link ReflectsAriaMixin}, so it also provides role/state reflection and id
|
|
22
|
+
* generation. Use for form controls.
|
|
23
|
+
*
|
|
24
|
+
* Note: form controls should still declare their own
|
|
25
|
+
* `static shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true }`
|
|
26
|
+
* — the mixin intentionally does not set it, to avoid changing focus behavior on
|
|
27
|
+
* non-form elements.
|
|
28
|
+
*/
|
|
29
|
+
export declare const FormControlMixin: <T extends Constructor<LitElement>>(Base: T) => Constructor<FormControlInterface> & T;
|
|
30
|
+
/**
|
|
31
|
+
* Concrete base class for form controls. Declared as a pure const so bundlers
|
|
32
|
+
* tree-shake it out of packages that don't use it.
|
|
33
|
+
*/
|
|
34
|
+
export declare const NysFormControlElement: Constructor<FormControlInterface> & typeof LitElement;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate a stable, collision-resistant id for a component instance.
|
|
3
|
+
*
|
|
4
|
+
* The format intentionally matches the legacy per-component pattern
|
|
5
|
+
* (`${prefix}-${Date.now()}-${n}`) so existing tests/consumers that assert on
|
|
6
|
+
* id shape continue to pass.
|
|
7
|
+
*/
|
|
8
|
+
export declare function generateId(prefix: string): string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
export type Constructor<T = object> = new (...args: any[]) => T;
|
|
3
|
+
/** Surface added by {@link IdentifiedMixin}. */
|
|
4
|
+
export declare class IdentifiedInterface {
|
|
5
|
+
/** Prefix used for auto-generated ids. Defaults to the element's tag name. */
|
|
6
|
+
protected get idPrefix(): string;
|
|
7
|
+
/** Assign an auto-generated id if the consumer did not supply one. */
|
|
8
|
+
protected ensureId(): void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Minimal mixin that gives an element stable auto-generated ids. This is the
|
|
12
|
+
* lightweight base for presentational components that need consistent id
|
|
13
|
+
* generation but do NOT reflect a host-level role/state via ElementInternals
|
|
14
|
+
* (so they don't pay for that machinery). Components that DO need host
|
|
15
|
+
* role/state should use {@link ReflectsAriaMixin} instead.
|
|
16
|
+
*/
|
|
17
|
+
export declare const IdentifiedMixin: <T extends Constructor<LitElement>>(Base: T) => Constructor<IdentifiedInterface> & T;
|
|
18
|
+
/**
|
|
19
|
+
* Concrete base class: `extends NysElement` for id-only presentational
|
|
20
|
+
* components. Declared as a pure const so bundlers tree-shake it (and the mixin
|
|
21
|
+
* chain it would pull) out of any package that doesn't use it.
|
|
22
|
+
*/
|
|
23
|
+
export declare const NysElement: Constructor<IdentifiedInterface> & typeof LitElement;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { generateId } from "./id";
|
|
2
|
+
export type { AriaRelation, AriaTargets, FormValue } from "./types";
|
|
3
|
+
export { supportsElementRefs, associateControl, associateControlRefs, associateHost, } from "./aria-associate";
|
|
4
|
+
export { IdentifiedMixin, NysElement, type IdentifiedInterface, type Constructor, } from "./identified-mixin";
|
|
5
|
+
export { ReflectsAriaMixin, NysReflectsAriaElement, type ReflectsAriaInterface, } from "./reflects-aria-mixin";
|
|
6
|
+
export { FormControlMixin, NysFormControlElement, type FormControlInterface, } from "./form-control-mixin";
|
|
7
|
+
export { findUnregisteredChildren } from "./test-helpers";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
import { type Constructor, type IdentifiedInterface } from "./identified-mixin";
|
|
3
|
+
export type { Constructor };
|
|
4
|
+
/**
|
|
5
|
+
* Public/protected surface added by {@link ReflectsAriaMixin}, on top of
|
|
6
|
+
* {@link IdentifiedInterface}. Declared separately so consuming components and
|
|
7
|
+
* the composed FormControl layer get correct types.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ReflectsAriaInterface extends IdentifiedInterface {
|
|
10
|
+
/** Lazily-attached ElementInternals, or null in non-DOM (SSR) contexts. */
|
|
11
|
+
protected readonly internals: ElementInternals | null;
|
|
12
|
+
/** Default implicit role applied to the host via internals. Override per component. */
|
|
13
|
+
protected get defaultRole(): string | null;
|
|
14
|
+
/** Apply the default role (and any static semantics) to the host. */
|
|
15
|
+
protected reflectDefaultSemantics(): void;
|
|
16
|
+
/** Set a host-level ARIA state property via internals, with attribute fallback. */
|
|
17
|
+
protected setHostAria(name: string, value: string | null): void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Mixin that adds ElementInternals-based accessibility semantics on top of
|
|
21
|
+
* {@link IdentifiedMixin}: a default host role and host-level ARIA state
|
|
22
|
+
* reflection. Use for presentational components that the host element itself
|
|
23
|
+
* should expose a role/state for (e.g. a separator). Components that only need
|
|
24
|
+
* id generation should use {@link IdentifiedMixin} / NysElement instead. For
|
|
25
|
+
* name/description association, import the `associateHost` / `associateControl`
|
|
26
|
+
* helpers directly (they tree-shake out of components that don't use them).
|
|
27
|
+
*/
|
|
28
|
+
export declare const ReflectsAriaMixin: <T extends Constructor<LitElement>>(Base: T) => Constructor<ReflectsAriaInterface> & T;
|
|
29
|
+
/**
|
|
30
|
+
* Concrete base class for components that reflect a host role/state. Declared as
|
|
31
|
+
* a pure const so bundlers tree-shake it out of packages that don't use it.
|
|
32
|
+
*/
|
|
33
|
+
export declare const NysReflectsAriaElement: Constructor<ReflectsAriaInterface> & typeof LitElement;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Walks `host`'s shadow DOM and light DOM (recursing into every nested shadow
|
|
3
|
+
* root it finds) and returns the lowercase tag name of every `<nys-*>`
|
|
4
|
+
* element encountered that is NOT a registered custom element
|
|
5
|
+
* (`customElements.get(tagName)` returns undefined).
|
|
6
|
+
*
|
|
7
|
+
* `host`'s own tag is never reported — a component always "renders" itself.
|
|
8
|
+
* Duplicate tag names are reported once.
|
|
9
|
+
*
|
|
10
|
+
* @param host - The component under test, already attached via `fixture()`
|
|
11
|
+
* (or otherwise connected — an unconnected host's shadow DOM may not have
|
|
12
|
+
* rendered yet).
|
|
13
|
+
* @returns Sorted array of unregistered `nys-*` tag names. Empty when every
|
|
14
|
+
* rendered child is upgraded — assert `.to.deep.equal([])` (or
|
|
15
|
+
* `.to.be.empty`) on the result.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { findUnregisteredChildren } from "@nysds/internals";
|
|
20
|
+
*
|
|
21
|
+
* it("registers every nys-* element it renders", async () => {
|
|
22
|
+
* const el = await fixture<NysAlert>(
|
|
23
|
+
* html`<nys-alert heading="Test" dismissible></nys-alert>`,
|
|
24
|
+
* );
|
|
25
|
+
* expect(findUnregisteredChildren(el)).to.deep.equal([]);
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function findUnregisteredChildren(host: Element): string[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Value a form-associated control submits. Mirrors `ElementInternals.setFormValue`. */
|
|
2
|
+
export type FormValue = Parameters<ElementInternals["setFormValue"]>[0];
|
|
3
|
+
/**
|
|
4
|
+
* Which ARIA relationship to wire between a control (or host) and the elements
|
|
5
|
+
* that provide its accessible name / description / error message.
|
|
6
|
+
*/
|
|
7
|
+
export type AriaRelation = "labelledby" | "describedby" | "errormessage";
|
|
8
|
+
/** A list of association targets, tolerant of null/undefined entries. */
|
|
9
|
+
export type AriaTargets = Array<Element | null | undefined>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NysElement } from "@nysds/internals";
|
|
2
2
|
import "./nys-accordionitem";
|
|
3
3
|
/**
|
|
4
4
|
* A container for grouping `nys-accordionitem` components with coordinated expand/collapse behavior.
|
|
@@ -6,6 +6,9 @@ import "./nys-accordionitem";
|
|
|
6
6
|
* Place `nys-accordionitem` elements as children. Set `singleSelect` to allow only one item open at a time.
|
|
7
7
|
* The `bordered` style propagates to all children automatically.
|
|
8
8
|
*
|
|
9
|
+
* Each item's toggle button is wrapped in a real heading element. Set
|
|
10
|
+
* `headingLevel` here to place the whole group correctly in the page outline.
|
|
11
|
+
*
|
|
9
12
|
* @summary Container for accordion items with optional single-select and bordered styling.
|
|
10
13
|
* @element nys-accordion
|
|
11
14
|
*
|
|
@@ -15,23 +18,67 @@ import "./nys-accordionitem";
|
|
|
15
18
|
* @cssprop [--nys-accordion-background-color--header--hover] - Background hover color of the accordion header.
|
|
16
19
|
* @cssprop [--nys-accordion-content-max-width] - Maximum readable width of accordion content. Defaults to a character-based width (80ch) for readability.
|
|
17
20
|
*
|
|
18
|
-
* @example Basic
|
|
21
|
+
* @example Basic
|
|
19
22
|
* ```html
|
|
20
23
|
* <nys-accordion>
|
|
21
|
-
* <nys-accordionitem
|
|
22
|
-
*
|
|
24
|
+
* <nys-accordionitem id="accordionId1" heading="How do I renew my passport or apply for a new one?">
|
|
25
|
+
* <p>
|
|
26
|
+
* You can apply for or renew a U.S. passport through the U.S. Department
|
|
27
|
+
* of State. Some renewals can be done by mail.
|
|
28
|
+
* </p>
|
|
29
|
+
* <div style="display: flex; gap: 0.5rem; font-size: 1rem;">
|
|
30
|
+
* <a href="https://www.ny.gov" target="_blank">Check your registration</a>
|
|
31
|
+
* <a href="https://www.ny.gov" target="_blank">Fill out application</a>
|
|
32
|
+
* </div>
|
|
33
|
+
* </nys-accordionitem>
|
|
34
|
+
* <nys-accordionitem id="accordionId2" heading="How can I find out if I’m registered to vote?">
|
|
35
|
+
* <p>You can check your registration status, update your information, or find out how to register through the National Association of Secretaries of State.</p>
|
|
36
|
+
* </nys-accordionitem>
|
|
23
37
|
* </nys-accordion>
|
|
24
38
|
* ```
|
|
25
39
|
*
|
|
26
|
-
* @example Single
|
|
40
|
+
* @example Single Select
|
|
27
41
|
* ```html
|
|
28
|
-
* <nys-accordion singleSelect
|
|
29
|
-
* <nys-accordionitem heading="FAQ 1"
|
|
42
|
+
* <nys-accordion singleSelect>
|
|
43
|
+
* <nys-accordionitem heading="FAQ 1">Answer 1</nys-accordionitem>
|
|
30
44
|
* <nys-accordionitem heading="FAQ 2">Answer 2</nys-accordionitem>
|
|
31
45
|
* </nys-accordion>
|
|
32
46
|
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example Bordered
|
|
49
|
+
* ```html
|
|
50
|
+
*
|
|
51
|
+
* <nys-accordion bordered>
|
|
52
|
+
* <nys-accordionitem heading="We are a group of accordions">
|
|
53
|
+
* <p>Stronger together! Learn more at
|
|
54
|
+
* <a href="https://www.ny.gov" target="_blank">ny.gov</a>
|
|
55
|
+
* </p>
|
|
56
|
+
* </nys-accordionitem>
|
|
57
|
+
* <nys-accordionitem heading="Liberty Ipsum: Bridges & Boroughs">
|
|
58
|
+
* <p>Empire ipsum dolor sit amet, across the Brooklyn Bridge to Central Park, consectetur adipiscing elit.</p>
|
|
59
|
+
* </nys-accordionitem>
|
|
60
|
+
* <nys-accordionitem heading="Hudson Ipsum: Riverfront Stories">
|
|
61
|
+
* <p>From the banks of the Hudson to the peaks of the Adirondacks, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
|
|
62
|
+
* </nys-accordionitem>
|
|
63
|
+
* </nys-accordion>
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @example Heading level
|
|
67
|
+
* Each trigger is a real heading, so it has to sit at the level the page
|
|
68
|
+
* outline expects — one below the heading that introduces the accordion.
|
|
69
|
+
* ```html
|
|
70
|
+
* <h2>Fishing licenses</h2>
|
|
71
|
+
* <nys-accordion headingLevel="h3">
|
|
72
|
+
* <nys-accordionitem heading="Who needs a license?">
|
|
73
|
+
* <p>Anyone 16 or older fishing in New York State freshwater.</p>
|
|
74
|
+
* </nys-accordionitem>
|
|
75
|
+
* <nys-accordionitem heading="How long is a license valid?">
|
|
76
|
+
* <p>Annual licenses are valid for 365 days from the date of purchase.</p>
|
|
77
|
+
* </nys-accordionitem>
|
|
78
|
+
* </nys-accordion>
|
|
79
|
+
* ```
|
|
33
80
|
*/
|
|
34
|
-
export declare class NysAccordion extends
|
|
81
|
+
export declare class NysAccordion extends NysElement {
|
|
35
82
|
static styles: import("lit").CSSResult;
|
|
36
83
|
/** Unique identifier. Auto-generated if not provided. */
|
|
37
84
|
id: string;
|
|
@@ -39,20 +86,35 @@ export declare class NysAccordion extends LitElement {
|
|
|
39
86
|
singleSelect: boolean;
|
|
40
87
|
/** Adds borders around each accordion item. Propagates to all children. */
|
|
41
88
|
bordered: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Heading element wrapping every item's toggle button (`h2` through `h6`).
|
|
91
|
+
*
|
|
92
|
+
* Each item's trigger is a real heading, so this is what places the accordion
|
|
93
|
+
* in the page outline: choose one level below the heading that introduces the
|
|
94
|
+
* accordion (an accordion under an `h2` section heading uses the `h3`
|
|
95
|
+
* default). An individual `nys-accordionitem` can override it with its own
|
|
96
|
+
* `headingLevel`. `h1` is not offered because an accordion trigger is never
|
|
97
|
+
* the page title.
|
|
98
|
+
*/
|
|
99
|
+
headingLevel: "h2" | "h3" | "h4" | "h5" | "h6";
|
|
42
100
|
/**
|
|
43
101
|
* Lifecycle methods
|
|
44
102
|
* --------------------------------------------------------------------------
|
|
45
103
|
*/
|
|
46
|
-
constructor();
|
|
47
104
|
connectedCallback(): void;
|
|
48
105
|
updated(changedProperties: Map<string, any>): void;
|
|
49
106
|
/**
|
|
50
107
|
* Functions
|
|
51
108
|
* --------------------------------------------------------------------------
|
|
52
109
|
*/
|
|
53
|
-
private _generateUniqueId;
|
|
54
110
|
private _getAccordionItems;
|
|
55
111
|
private _onAccordionToggle;
|
|
56
112
|
private _applyBordered;
|
|
113
|
+
/**
|
|
114
|
+
* Items read the group's `headingLevel` themselves (so an item that sets its
|
|
115
|
+
* own always wins), which means a change here is invisible to them until they
|
|
116
|
+
* re-render. Ask them to.
|
|
117
|
+
*/
|
|
118
|
+
private _notifyHeadingLevel;
|
|
57
119
|
render(): import("lit-html").TemplateResult<1>;
|
|
58
120
|
}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type TemplateResult } from "lit";
|
|
2
|
+
import { NysElement } from "@nysds/internals";
|
|
3
|
+
import "@nysds/nys-icon";
|
|
2
4
|
/**
|
|
3
5
|
* A collapsible content panel used within `nys-accordion`. Supports keyboard navigation and smooth animations.
|
|
4
6
|
*
|
|
5
7
|
* Place inside `nys-accordion`. Set `expanded` to open by default. The heading acts as a toggle button
|
|
6
8
|
* accessible via click, Enter, or Space. Parent accordion controls `bordered` and `singleSelect` behavior.
|
|
7
9
|
*
|
|
10
|
+
* Per the WAI-ARIA Accordion pattern the toggle button is wrapped in a real
|
|
11
|
+
* heading element so the panels appear in the document outline and screen
|
|
12
|
+
* reader users can jump between them by heading. Set `headingLevel` (here or on
|
|
13
|
+
* the parent `nys-accordion`) to the level that fits the surrounding page.
|
|
14
|
+
*
|
|
8
15
|
* @summary Collapsible panel for use within nys-accordion with keyboard support.
|
|
9
16
|
* @element nys-accordionitem
|
|
10
17
|
*
|
|
@@ -14,17 +21,45 @@ import { LitElement } from "lit";
|
|
|
14
21
|
*
|
|
15
22
|
* @example Expanded item
|
|
16
23
|
* ```html
|
|
17
|
-
* <nys-
|
|
18
|
-
* <
|
|
19
|
-
*
|
|
24
|
+
* <nys-accordion>
|
|
25
|
+
* <nys-accordionitem heading="How do I apply?" expanded>
|
|
26
|
+
* <p>Visit ny.gov and complete the online application.</p>
|
|
27
|
+
* </nys-accordionitem>
|
|
28
|
+
* <nys-accordionitem heading="What documents do I need?">
|
|
29
|
+
* <p>You will need a valid ID and proof of residency.</p>
|
|
30
|
+
* </nys-accordionitem>
|
|
31
|
+
* </nys-accordion>
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example Per-item heading level
|
|
35
|
+
* ```html
|
|
36
|
+
* <nys-accordion headingLevel="h2">
|
|
37
|
+
* <nys-accordionitem heading="Sits at h2, inherited from the group">
|
|
38
|
+
* <p>Every item follows the group unless it says otherwise.</p>
|
|
39
|
+
* </nys-accordionitem>
|
|
40
|
+
* <nys-accordionitem headingLevel="h3" heading="Sits at h3, set on the item">
|
|
41
|
+
* <p>An item that nests under the preceding one sets its own level.</p>
|
|
42
|
+
* </nys-accordionitem>
|
|
43
|
+
* </nys-accordion>
|
|
20
44
|
* ```
|
|
21
45
|
*/
|
|
22
|
-
export declare class NysAccordionItem extends
|
|
46
|
+
export declare class NysAccordionItem extends NysElement {
|
|
23
47
|
static styles: import("lit").CSSResult;
|
|
24
48
|
/** Unique identifier. Auto-generated if not provided. */
|
|
25
49
|
id: string;
|
|
26
50
|
/** Heading text displayed in the clickable toggle button. */
|
|
27
51
|
heading: string;
|
|
52
|
+
/**
|
|
53
|
+
* Heading element that wraps the toggle button (`h2` through `h6`).
|
|
54
|
+
*
|
|
55
|
+
* Pick the level that puts the trigger in the right place in the page
|
|
56
|
+
* outline — one level below the heading that introduces the accordion. Leave
|
|
57
|
+
* it empty to follow the `headingLevel` of the enclosing `nys-accordion`,
|
|
58
|
+
* which is the usual way to set it for a whole group; `h3` applies when
|
|
59
|
+
* neither is specified. `h1` is not offered because an accordion trigger is
|
|
60
|
+
* never the page title.
|
|
61
|
+
*/
|
|
62
|
+
headingLevel: "h2" | "h3" | "h4" | "h5" | "h6" | "";
|
|
28
63
|
/** Whether the content panel is visible. Toggle via click or keyboard. */
|
|
29
64
|
expanded: boolean;
|
|
30
65
|
/** Adds border styling. Set by parent `nys-accordion`, not directly. */
|
|
@@ -33,7 +68,6 @@ export declare class NysAccordionItem extends LitElement {
|
|
|
33
68
|
* Lifecycle methods
|
|
34
69
|
* --------------------------------------------------------------------------
|
|
35
70
|
*/
|
|
36
|
-
constructor();
|
|
37
71
|
connectedCallback(): void;
|
|
38
72
|
firstUpdated(): void;
|
|
39
73
|
updated(changedProperties: Map<string, any>): void;
|
|
@@ -41,11 +75,32 @@ export declare class NysAccordionItem extends LitElement {
|
|
|
41
75
|
* Functions
|
|
42
76
|
* --------------------------------------------------------------------------
|
|
43
77
|
*/
|
|
44
|
-
|
|
78
|
+
/**
|
|
79
|
+
* The level actually rendered: this item's own `headingLevel`, otherwise the
|
|
80
|
+
* one set on the enclosing `nys-accordion`, otherwise the `h3` default.
|
|
81
|
+
*
|
|
82
|
+
* The group's value is read here rather than pushed down from the container
|
|
83
|
+
* so there is a single source of truth per item and an item-level value
|
|
84
|
+
* always wins. `nys-accordion` re-renders its items when its own level
|
|
85
|
+
* changes (see `_notifyHeadingLevel` there).
|
|
86
|
+
*/
|
|
87
|
+
private _resolveHeadingLevel;
|
|
45
88
|
private _dispatchEvent;
|
|
46
89
|
private _handleExpand;
|
|
47
90
|
private _handleKeydown;
|
|
48
91
|
private _contentContainer;
|
|
49
92
|
private _updateHeight;
|
|
50
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Helper Render Functions
|
|
95
|
+
* --------------------------------------------------------------------------
|
|
96
|
+
*/
|
|
97
|
+
/**
|
|
98
|
+
* WAI-ARIA Accordion pattern: the toggle button must be contained in a
|
|
99
|
+
* heading at the level appropriate for the surrounding page. A real `h2`-`h6`
|
|
100
|
+
* element is used rather than `role="heading"` + `aria-level` so the trigger
|
|
101
|
+
* carries native heading semantics everywhere — including the places that
|
|
102
|
+
* read the DOM instead of the accessibility tree.
|
|
103
|
+
*/
|
|
104
|
+
private _renderHeading;
|
|
105
|
+
render(): TemplateResult<1>;
|
|
51
106
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NysElement } from "@nysds/internals";
|
|
2
|
+
import "@nysds/nys-icon";
|
|
3
|
+
import "@nysds/nys-button";
|
|
2
4
|
/**
|
|
3
5
|
* Displays contextual feedback messages with semantic styling. Uses ARIA live regions for screen reader announcements.
|
|
4
6
|
*
|
|
@@ -12,17 +14,94 @@ import { LitElement } from "lit";
|
|
|
12
14
|
*
|
|
13
15
|
* @fires nys-close - Fired when alert is dismissed. Detail: `{id, type, label}`.
|
|
14
16
|
*
|
|
15
|
-
* @example
|
|
17
|
+
* @example Basic
|
|
16
18
|
* ```html
|
|
17
|
-
* <nys-alert
|
|
19
|
+
* <nys-alert heading="This is a heading"></nys-alert>
|
|
18
20
|
* ```
|
|
19
21
|
*
|
|
20
|
-
* @example
|
|
22
|
+
* @example Text
|
|
21
23
|
* ```html
|
|
22
|
-
* <nys-alert
|
|
24
|
+
* <nys-alert
|
|
25
|
+
* heading="This is a heading"
|
|
26
|
+
* text="This is additional information passed in through the text property"
|
|
27
|
+
* ></nys-alert>
|
|
23
28
|
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example Rich Text
|
|
31
|
+
* ```html
|
|
32
|
+
* <nys-alert heading="Rich Text">
|
|
33
|
+
* <p>This is a custom alert with <strong>HTML content</strong> passed in through the slot.</p>
|
|
34
|
+
* <a href="https://www.ny.gov/" target="_blank">Learn more about our accessibility services</a>
|
|
35
|
+
* </nys-alert>
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @example Info Type
|
|
39
|
+
* ```html
|
|
40
|
+
* <nys-alert type="info" heading="Info alert type"></nys-alert>
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example Success Type
|
|
44
|
+
* ```html
|
|
45
|
+
* <nys-alert type="success" heading="Success alert type"></nys-alert>
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example Warning Type
|
|
49
|
+
* ```html
|
|
50
|
+
* <nys-alert type="warning" heading="Warning alert type"></nys-alert>
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @example Danger Type
|
|
54
|
+
* ```html
|
|
55
|
+
* <nys-alert type="danger" heading="Danger alert type"></nys-alert>
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @example Emergency Type
|
|
59
|
+
* ```html
|
|
60
|
+
* <nys-alert type="emergency" heading="Emergency alert type"></nys-alert>
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @example Dismissible
|
|
64
|
+
* ```html
|
|
65
|
+
* <nys-alert heading="This alert is dismisable" text="Close it by clicking on the X in the corner." dismissible>
|
|
66
|
+
* </nys-alert>
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @example Duration
|
|
70
|
+
* ```html
|
|
71
|
+
* <nys-alert heading="Disappearing alert" text="This alert will disappear after 3 seconds." duration="3000"></nys-alert>
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @render Duration
|
|
75
|
+
* ```html
|
|
76
|
+
* <nys-button
|
|
77
|
+
* class="nys-margin-b-100"
|
|
78
|
+
* label="Show alert"
|
|
79
|
+
* onclick="document.body.appendChild(Object.assign(document.createElement('nys-alert'), {heading: 'Disappearing alert', text: 'This alert will disappear after 3 seconds.', duration: 3000}))"
|
|
80
|
+
* ></nys-button>
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @example Custom Icon
|
|
84
|
+
* ```html
|
|
85
|
+
* <nys-alert
|
|
86
|
+
* type="emergency"
|
|
87
|
+
* heading="Winter storm warning: Dec 10th, 2024."
|
|
88
|
+
* text="A major snowfall is expected across the state of New York for the weekend of Dec 7th. Stay home if possible and use extreme caution when driving."
|
|
89
|
+
* icon="ac_unit">
|
|
90
|
+
* </nys-alert>
|
|
91
|
+
*```
|
|
92
|
+
|
|
93
|
+
* @example Action Links
|
|
94
|
+
* ```html
|
|
95
|
+
* <nys-alert
|
|
96
|
+
* heading="Alert with links"
|
|
97
|
+
* primaryLabel="{primaryAction}"
|
|
98
|
+
* secondaryLabel="{secondaryAction}"
|
|
99
|
+
* primaryAction="https://www.ny.gov/"
|
|
100
|
+
* secondaryAction="https://www.ny.gov/"
|
|
101
|
+
* ></nys-alert>
|
|
102
|
+
*```
|
|
24
103
|
*/
|
|
25
|
-
export declare class NysAlert extends
|
|
104
|
+
export declare class NysAlert extends NysElement {
|
|
26
105
|
static styles: import("lit").CSSResult;
|
|
27
106
|
/** Unique identifier. Auto-generated if not provided. */
|
|
28
107
|
id: string;
|
|
@@ -45,28 +124,25 @@ export declare class NysAlert extends LitElement {
|
|
|
45
124
|
/** Label text for secondary action link. */
|
|
46
125
|
secondaryLabel: string;
|
|
47
126
|
/**
|
|
48
|
-
* Semantic alert type affecting color and ARIA role. `danger`/`emergency` use
|
|
127
|
+
* Semantic alert type affecting color and ARIA role. `warning`/`danger`/`emergency` use
|
|
128
|
+
* `role="alert"` (assertive live region); `base`/`info`/`success` use `role="status"` (polite).
|
|
49
129
|
* @default "base"
|
|
50
130
|
*/
|
|
51
131
|
type: "base" | "info" | "success" | "warning" | "danger" | "emergency";
|
|
52
132
|
private _alertClosed;
|
|
53
133
|
private _slotHasContent;
|
|
54
134
|
/**
|
|
55
|
-
* Returns ARIA role and
|
|
56
|
-
* -
|
|
57
|
-
* -
|
|
58
|
-
*
|
|
135
|
+
* Returns the ARIA role and aria-live setting for the alert's live region based on type.
|
|
136
|
+
* - `warning`/`danger`/`emergency` => role="alert", aria-live="assertive" (urgent, interrupts)
|
|
137
|
+
* - `base`/`info`/`success` => role="status", aria-live="polite" (waits its turn)
|
|
138
|
+
*
|
|
139
|
+
* `aria-live` is set explicitly alongside `role` (rather than relying on the role's implicit
|
|
140
|
+
* live-region semantics) for more consistent behavior across browser/AT combinations.
|
|
59
141
|
*/
|
|
60
142
|
get ariaAttributes(): {
|
|
61
|
-
role: "alert" | "status"
|
|
62
|
-
|
|
143
|
+
role: "alert" | "status";
|
|
144
|
+
ariaLive: "polite" | "assertive";
|
|
63
145
|
};
|
|
64
|
-
/**
|
|
65
|
-
* Returns live-region type for screen readers if applicable.
|
|
66
|
-
* - 'polite' for status role
|
|
67
|
-
* - undefined for alert (since it's implicitly assertive) or region
|
|
68
|
-
*/
|
|
69
|
-
get liveRegion(): "polite" | undefined;
|
|
70
146
|
/**
|
|
71
147
|
* Lifecycle methods
|
|
72
148
|
* --------------------------------------------------------------------------
|
|
@@ -79,7 +155,6 @@ export declare class NysAlert extends LitElement {
|
|
|
79
155
|
* Functions
|
|
80
156
|
* --------------------------------------------------------------------------
|
|
81
157
|
*/
|
|
82
|
-
private _generateUniqueId;
|
|
83
158
|
private _resolveIconName;
|
|
84
159
|
private _checkAltNaming;
|
|
85
160
|
private _closeAlert;
|