@nectary/components 5.38.1 → 5.39.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.
Files changed (40) hide show
  1. package/bundle.d.ts +2 -0
  2. package/bundle.js +1710 -219
  3. package/bundle.ts +2 -0
  4. package/package.json +3 -3
  5. package/progress/index.js +4 -3
  6. package/progress-stepper-item-v2/global/index.d.ts +1 -0
  7. package/progress-stepper-item-v2/global/index.js +2 -0
  8. package/progress-stepper-item-v2/index.d.ts +23 -0
  9. package/progress-stepper-item-v2/index.js +187 -0
  10. package/progress-stepper-item-v2/types.d.ts +69 -0
  11. package/progress-stepper-item-v2/types.js +1 -0
  12. package/progress-stepper-item-v2/utils.d.ts +22 -0
  13. package/progress-stepper-item-v2/utils.js +88 -0
  14. package/progress-stepper-v2/compact-format.d.ts +22 -0
  15. package/progress-stepper-v2/compact-format.js +56 -0
  16. package/progress-stepper-v2/compact.d.ts +26 -0
  17. package/progress-stepper-v2/compact.js +330 -0
  18. package/progress-stepper-v2/global/index.d.ts +1 -0
  19. package/progress-stepper-v2/global/index.js +2 -0
  20. package/progress-stepper-v2/index.d.ts +31 -0
  21. package/progress-stepper-v2/index.js +618 -0
  22. package/progress-stepper-v2/model.d.ts +32 -0
  23. package/progress-stepper-v2/model.js +59 -0
  24. package/progress-stepper-v2/orientation.d.ts +8 -0
  25. package/progress-stepper-v2/orientation.js +24 -0
  26. package/progress-stepper-v2/separators.d.ts +1 -0
  27. package/progress-stepper-v2/separators.js +48 -0
  28. package/progress-stepper-v2/step-chip.d.ts +9 -0
  29. package/progress-stepper-v2/step-chip.js +126 -0
  30. package/progress-stepper-v2/types.d.ts +66 -0
  31. package/progress-stepper-v2/types.js +1 -0
  32. package/standalone.d.ts +2 -0
  33. package/standalone.js +2 -0
  34. package/standalone.ts +2 -0
  35. package/utils/component-names.d.ts +2 -2
  36. package/utils/component-names.js +2 -0
  37. package/utils/dom.d.ts +10 -2
  38. package/utils/dom.js +29 -0
  39. package/utils/element.d.ts +2 -0
  40. package/utils/index.js +4 -1
@@ -0,0 +1,59 @@
1
+ function deriveStepStatuses(items, params) {
2
+ const { noCompletionOrder, progressValue } = params;
3
+ if (noCompletionOrder) {
4
+ return items.map((item) => {
5
+ if (item.disabled) {
6
+ return "inactive";
7
+ }
8
+ if (item.complete) {
9
+ return "complete";
10
+ }
11
+ return "incomplete";
12
+ });
13
+ }
14
+ let progressIndex = items.findIndex((it) => it.value === progressValue);
15
+ if (progressIndex < 0 && items.length > 0) {
16
+ progressIndex = 0;
17
+ }
18
+ return items.map((_, i) => {
19
+ if (progressIndex < 0 || progressIndex < i) {
20
+ return "inactive";
21
+ }
22
+ if (progressIndex > i) {
23
+ return "complete";
24
+ }
25
+ return "incomplete";
26
+ });
27
+ }
28
+ function computeOrientationLayout(params) {
29
+ const {
30
+ noAutoOrientation,
31
+ containerWidth,
32
+ wrapperScrollWidth
33
+ } = params;
34
+ if (noAutoOrientation) {
35
+ return {
36
+ isHorizontal: true,
37
+ dataOrientation: "horizontal",
38
+ mode: "horizontal"
39
+ };
40
+ }
41
+ const safeWidth = Math.max(containerWidth, 1);
42
+ const isHorizontal = wrapperScrollWidth <= safeWidth;
43
+ if (isHorizontal) {
44
+ return {
45
+ isHorizontal: true,
46
+ dataOrientation: "horizontal",
47
+ mode: "horizontal"
48
+ };
49
+ }
50
+ return {
51
+ isHorizontal: false,
52
+ dataOrientation: "vertical",
53
+ mode: "compact"
54
+ };
55
+ }
56
+ export {
57
+ computeOrientationLayout,
58
+ deriveStepStatuses
59
+ };
@@ -0,0 +1,8 @@
1
+ /** Coalesces resize observations into a single animation frame. */
2
+ export declare class OrientationScheduler {
3
+ #private;
4
+ private readonly run;
5
+ constructor(run: () => void);
6
+ schedule(): void;
7
+ cancel(): void;
8
+ }
@@ -0,0 +1,24 @@
1
+ class OrientationScheduler {
2
+ constructor(run) {
3
+ this.run = run;
4
+ }
5
+ #rafId = null;
6
+ schedule() {
7
+ if (this.#rafId !== null) {
8
+ cancelAnimationFrame(this.#rafId);
9
+ }
10
+ this.#rafId = requestAnimationFrame(() => {
11
+ this.#rafId = null;
12
+ this.run();
13
+ });
14
+ }
15
+ cancel() {
16
+ if (this.#rafId !== null) {
17
+ cancelAnimationFrame(this.#rafId);
18
+ this.#rafId = null;
19
+ }
20
+ }
21
+ }
22
+ export {
23
+ OrientationScheduler
24
+ };
@@ -0,0 +1 @@
1
+ export declare function syncStepSeparators(host: HTMLElement, itemTagName: string): void;
@@ -0,0 +1,48 @@
1
+ import { createScopedElement } from "../utils/dom.js";
2
+ const TAG_STEP_SEPARATOR_ICON = "sinch-icon";
3
+ const ATTR_STEP_SEPARATOR = "data-nectary-progress-stepper-v2-separator";
4
+ function isStepSeparatorNode(el) {
5
+ return el instanceof HTMLElement && el.tagName.toLowerCase() === TAG_STEP_SEPARATOR_ICON && el.hasAttribute(ATTR_STEP_SEPARATOR);
6
+ }
7
+ function separatorsPlacementValid(items) {
8
+ for (let i = 0; i < items.length - 1; i++) {
9
+ const between = items[i].nextElementSibling;
10
+ if (!isStepSeparatorNode(between)) {
11
+ return false;
12
+ }
13
+ if (between.nextElementSibling !== items[i + 1]) {
14
+ return false;
15
+ }
16
+ }
17
+ return true;
18
+ }
19
+ function createStepSeparator(anchor) {
20
+ const icon = createScopedElement(anchor, TAG_STEP_SEPARATOR_ICON);
21
+ icon.setAttribute(ATTR_STEP_SEPARATOR, "");
22
+ icon.setAttribute("icons-version", "2");
23
+ icon.setAttribute("name", "fa-chevron-right");
24
+ icon.setAttribute("aria-hidden", "true");
25
+ icon.setAttribute("tabindex", "-1");
26
+ return icon;
27
+ }
28
+ function syncStepSeparators(host, itemTagName) {
29
+ const normalizedItemTagName = itemTagName.toLowerCase();
30
+ const items = [...host.children].filter(
31
+ (el) => el.tagName.toLowerCase() === normalizedItemTagName
32
+ );
33
+ const separators = [...host.children].filter(isStepSeparatorNode);
34
+ if (items.length <= 1) {
35
+ separators.forEach((n) => n.remove());
36
+ return;
37
+ }
38
+ if (separators.length === items.length - 1 && separatorsPlacementValid(items)) {
39
+ return;
40
+ }
41
+ separators.forEach((n) => n.remove());
42
+ for (let i = 0; i < items.length - 1; i++) {
43
+ items[i].insertAdjacentElement("afterend", createStepSeparator(host));
44
+ }
45
+ }
46
+ export {
47
+ syncStepSeparators
48
+ };
@@ -0,0 +1,9 @@
1
+ import '../icon';
2
+ export type TSinchProgressStepperStepChipModel = {
3
+ /** Resolved step label (e.g. `"3"`). */
4
+ stepIndexDisplay: string;
5
+ status: string;
6
+ invalid: boolean;
7
+ checked: boolean;
8
+ };
9
+ export declare const fillProgressStepperStepChipHost: (host: HTMLElement, model: TSinchProgressStepperStepChipModel) => void;
@@ -0,0 +1,126 @@
1
+ import "../icon/index.js";
2
+ import { createScopedElement } from "../utils/dom.js";
3
+ const STEP_CHIP_TOKEN = "--sinch-comp-progress-stepper-v2-step";
4
+ const chipStyles = new CSSStyleSheet();
5
+ chipStyles.replaceSync(`
6
+ .step-chip {
7
+ display: inline-grid;
8
+ place-items: center;
9
+ width: 24px;
10
+ height: 24px;
11
+ border-radius: var(${STEP_CHIP_TOKEN}-shape-radius-indicator);
12
+ flex-shrink: 0;
13
+ box-sizing: border-box;
14
+ vertical-align: middle;
15
+ line-height: var(--sinch-comp-text-line-height);
16
+ font: var(--sinch-sys-font-body-s);
17
+ }
18
+
19
+ .step-chip[data-checked] {
20
+ font: var(--sinch-sys-font-body-emphasize-s);
21
+ }
22
+
23
+ .step-chip[data-status="incomplete"] {
24
+ background: var(${STEP_CHIP_TOKEN}-color-incomplete-icon-container-initial);
25
+ color: var(${STEP_CHIP_TOKEN}-color-incomplete-icon-initial);
26
+ }
27
+
28
+ .step-chip[data-status="incomplete"][data-checked] {
29
+ background: var(${STEP_CHIP_TOKEN}-color-incomplete-icon-container-current);
30
+ color: var(${STEP_CHIP_TOKEN}-color-incomplete-icon-current);
31
+ }
32
+
33
+ .step-chip[data-status="complete"] {
34
+ background: var(${STEP_CHIP_TOKEN}-color-complete-icon-container-initial);
35
+ color: var(${STEP_CHIP_TOKEN}-color-complete-icon-initial);
36
+ }
37
+
38
+ .step-chip[data-status="complete"][data-checked] {
39
+ background: var(${STEP_CHIP_TOKEN}-color-complete-icon-container-current);
40
+ color: var(${STEP_CHIP_TOKEN}-color-complete-icon-current);
41
+ }
42
+
43
+ .step-chip[data-invalid] {
44
+ background: var(${STEP_CHIP_TOKEN}-color-invalid-icon-container-initial);
45
+ color: var(${STEP_CHIP_TOKEN}-color-invalid-icon-initial);
46
+ }
47
+
48
+ .step-chip[data-invalid][data-checked] {
49
+ background: var(${STEP_CHIP_TOKEN}-color-invalid-icon-container-current);
50
+ color: var(${STEP_CHIP_TOKEN}-color-invalid-icon-current);
51
+ }
52
+
53
+ .step-chip__num,
54
+ .step-chip__check,
55
+ .step-chip__warn {
56
+ grid-area: 1 / 1;
57
+ }
58
+
59
+ .step-chip__check,
60
+ .step-chip__warn {
61
+ display: none;
62
+ --sinch-global-size-icon: 20px;
63
+ --sinch-global-color-icon: currentcolor;
64
+ }
65
+
66
+ .step-chip[data-invalid] .step-chip__num,
67
+ .step-chip[data-status="complete"] .step-chip__num {
68
+ display: none;
69
+ }
70
+
71
+ .step-chip[data-invalid] .step-chip__warn {
72
+ display: block;
73
+ }
74
+
75
+ .step-chip[data-status="complete"]:not([data-invalid]) .step-chip__check {
76
+ display: block;
77
+ }
78
+ `);
79
+ const adoptChipStylesOnce = (root) => {
80
+ if (!root.adoptedStyleSheets.includes(chipStyles)) {
81
+ root.adoptedStyleSheets = [...root.adoptedStyleSheets, chipStyles];
82
+ }
83
+ };
84
+ const ensureChipStyles = (host) => {
85
+ const root = host.getRootNode();
86
+ if (root instanceof ShadowRoot || root instanceof Document) {
87
+ adoptChipStylesOnce(root);
88
+ }
89
+ };
90
+ const buildProgressStepperStepChip = (anchor) => {
91
+ const chip = document.createElement("span");
92
+ chip.className = "step-chip";
93
+ chip.setAttribute("aria-hidden", "true");
94
+ const num = document.createElement("span");
95
+ num.className = "step-chip__num";
96
+ const check = createScopedElement(anchor, "sinch-icon");
97
+ check.className = "step-chip__check";
98
+ check.setAttribute("icons-version", "2");
99
+ check.setAttribute("name", "fa-check");
100
+ check.setAttribute("aria-hidden", "true");
101
+ const warn = createScopedElement(anchor, "sinch-icon");
102
+ warn.className = "step-chip__warn";
103
+ warn.setAttribute("icons-version", "2");
104
+ warn.setAttribute("name", "triangle-exclamation");
105
+ warn.setAttribute("aria-hidden", "true");
106
+ chip.append(num, check, warn);
107
+ return chip;
108
+ };
109
+ const fillProgressStepperStepChipHost = (host, model) => {
110
+ ensureChipStyles(host);
111
+ let chip = host.querySelector(":scope > .step-chip");
112
+ if (!(chip instanceof HTMLElement)) {
113
+ chip = buildProgressStepperStepChip(host);
114
+ host.appendChild(chip);
115
+ }
116
+ chip.toggleAttribute("data-invalid", model.invalid);
117
+ chip.toggleAttribute("data-checked", model.checked);
118
+ chip.setAttribute(
119
+ "data-status",
120
+ model.status === "inactive" ? "incomplete" : model.status
121
+ );
122
+ chip.querySelector(".step-chip__num").textContent = model.stepIndexDisplay;
123
+ };
124
+ export {
125
+ fillProgressStepperStepChipHost
126
+ };
@@ -0,0 +1,66 @@
1
+ import type { NectaryComponentReactByType, NectaryComponentVanillaByType, NectaryComponentReact, NectaryComponentVanilla } from '../types';
2
+ export type TSinchProgressStepperV2Props = {
3
+ /** Current selected item value */
4
+ value: string;
5
+ /**
6
+ * Accessible name for the stepper. Recommended when the layout collapses to compact
7
+ * (short widget name for the listbox/popover). When omitted in compact mode, the
8
+ * menu and popover use the same derived name as the trigger (`{current} of {total}, {step}`).
9
+ */
10
+ 'aria-label'?: string;
11
+ /**
12
+ * Template for the compact trigger counter badge.
13
+ * Placeholders: `{current}`, `{total}`.
14
+ * Default when unset: `{current} of {total}`.
15
+ */
16
+ 'compact-counter-format'?: string;
17
+ /**
18
+ * Template for the compact trigger `aria-label`.
19
+ * Placeholders: `{label}`, `{current}`, `{total}`, `{step}`.
20
+ * Default when unset: `{label}, {current} of {total}, {step}` if `aria-label` is set,
21
+ * otherwise `{current} of {total}, {step}`.
22
+ */
23
+ 'compact-trigger-aria-label-format'?: string;
24
+ /**
25
+ * Current progress value used to derive each item's status in ordered mode (default).
26
+ * Ignored when `noCompletionOrder` is set.
27
+ */
28
+ progressValue?: string;
29
+ /**
30
+ * When set, step statuses are controlled by per-item `complete` / `disabled` attributes
31
+ * instead of deriving order from `progressValue`.
32
+ */
33
+ noCompletionOrder?: boolean;
34
+ /** When set, orientation stays horizontal and does not auto-switch to vertical on overflow. */
35
+ noAutoOrientation?: boolean;
36
+ };
37
+ export type TSinchProgressStepperV2Events = {
38
+ /** Change selected value event */
39
+ '-change'?: (e: CustomEvent<string>) => void;
40
+ };
41
+ export type TSinchProgressStepperV2 = {
42
+ props: TSinchProgressStepperV2Props;
43
+ events: TSinchProgressStepperV2Events;
44
+ };
45
+ export type TSinchProgressStepperV2Element = NectaryComponentVanillaByType<TSinchProgressStepperV2>;
46
+ export type TSinchProgressStepperV2React = NectaryComponentReactByType<TSinchProgressStepperV2>;
47
+ declare global {
48
+ interface NectaryComponentMap {
49
+ 'sinch-progress-stepper-v2': TSinchProgressStepperV2;
50
+ }
51
+ interface HTMLElementTagNameMap {
52
+ 'sinch-progress-stepper-v2': NectaryComponentVanilla<'sinch-progress-stepper-v2'>;
53
+ }
54
+ namespace JSX {
55
+ interface IntrinsicElements {
56
+ 'sinch-progress-stepper-v2': NectaryComponentReact<'sinch-progress-stepper-v2'>;
57
+ }
58
+ }
59
+ }
60
+ declare module 'react' {
61
+ namespace JSX {
62
+ interface IntrinsicElements extends globalThis.JSX.IntrinsicElements {
63
+ 'sinch-progress-stepper-v2': NectaryComponentReact<'sinch-progress-stepper-v2'>;
64
+ }
65
+ }
66
+ }
@@ -0,0 +1 @@
1
+
package/standalone.d.ts CHANGED
@@ -43,7 +43,9 @@ import './pagination/index.js';
43
43
  import './persistent-overlay/index.js';
44
44
  import './pop/index.js';
45
45
  import './popover/index.js';
46
+ import './progress-stepper-item-v2/index.js';
46
47
  import './progress-stepper-item/index.js';
48
+ import './progress-stepper-v2/index.js';
47
49
  import './progress-stepper/index.js';
48
50
  import './progress/index.js';
49
51
  import './radio-option/index.js';
package/standalone.js CHANGED
@@ -44,7 +44,9 @@ import "./pagination/index.js";
44
44
  import "./persistent-overlay/index.js";
45
45
  import "./pop/index.js";
46
46
  import "./popover/index.js";
47
+ import "./progress-stepper-item-v2/index.js";
47
48
  import "./progress-stepper-item/index.js";
49
+ import "./progress-stepper-v2/index.js";
48
50
  import "./progress-stepper/index.js";
49
51
  import "./progress/index.js";
50
52
  import "./radio-option/index.js";
package/standalone.ts CHANGED
@@ -51,7 +51,9 @@ import './pagination/index.js'
51
51
  import './persistent-overlay/index.js'
52
52
  import './pop/index.js'
53
53
  import './popover/index.js'
54
+ import './progress-stepper-item-v2/index.js'
54
55
  import './progress-stepper-item/index.js'
56
+ import './progress-stepper-v2/index.js'
55
57
  import './progress-stepper/index.js'
56
58
  import './progress/index.js'
57
59
  import './radio-option/index.js'
@@ -1,3 +1,3 @@
1
- export declare const BASE_COMPONENT_NAMES_LIST: readonly ["accordion-item", "accordion", "action-menu-option", "action-menu", "alert", "avatar", "badge", "button-group-item", "button-group", "button", "card-container", "card-v2-title", "card-v2", "checkbox", "chip", "code-tag", "color-menu-option", "color-menu", "color-swatch", "date-picker", "dialog", "emoji-picker", "emoji", "field", "field-v2", "file-drop", "file-picker", "file-status", "flag", "floating-panel", "floating-panel-button", "floating-panel-icon-button", "grid-item", "grid", "help-tooltip", "icon", "inline-alert", "input", "link", "list-item", "list", "pagination", "persistent-overlay", "pop", "popover", "progress-stepper-item", "progress-stepper", "progress", "radio-option", "radio", "rich-text", "rich-textarea", "rich-textarea-chip", "segment-collapse", "segmented-control-option", "segmented-control", "segmented-icon-control-option", "segmented-icon-control", "select-button", "select-menu-option", "select-menu", "sheet", "sheet-title", "skeleton-item", "skeleton", "spinner", "stop-events", "table-body", "table-cell", "table-head-cell", "table-head", "table-row", "table", "tabs-icon-option", "tabs-option", "tabs", "tag", "text", "textarea", "time-picker", "title", "toast-manager", "toast", "toggle", "tooltip"];
2
- export declare const BASE_COMPONENT_NAMES: Set<"pop" | "button" | "dialog" | "input" | "link" | "progress" | "table" | "textarea" | "title" | "accordion-item" | "accordion" | "action-menu-option" | "action-menu" | "alert" | "avatar" | "badge" | "button-group-item" | "button-group" | "card-container" | "card-v2-title" | "card-v2" | "checkbox" | "chip" | "code-tag" | "color-menu-option" | "color-menu" | "color-swatch" | "date-picker" | "emoji-picker" | "emoji" | "field" | "field-v2" | "file-drop" | "file-picker" | "file-status" | "flag" | "floating-panel" | "floating-panel-button" | "floating-panel-icon-button" | "grid-item" | "grid" | "help-tooltip" | "icon" | "inline-alert" | "list-item" | "list" | "pagination" | "persistent-overlay" | "popover" | "progress-stepper-item" | "progress-stepper" | "radio-option" | "radio" | "rich-text" | "rich-textarea" | "rich-textarea-chip" | "segment-collapse" | "segmented-control-option" | "segmented-control" | "segmented-icon-control-option" | "segmented-icon-control" | "select-button" | "select-menu-option" | "select-menu" | "sheet" | "sheet-title" | "skeleton-item" | "skeleton" | "spinner" | "stop-events" | "table-body" | "table-cell" | "table-head-cell" | "table-head" | "table-row" | "tabs-icon-option" | "tabs-option" | "tabs" | "tag" | "text" | "time-picker" | "toast-manager" | "toast" | "toggle" | "tooltip">;
1
+ export declare const BASE_COMPONENT_NAMES_LIST: readonly ["accordion-item", "accordion", "action-menu-option", "action-menu", "alert", "avatar", "badge", "button-group-item", "button-group", "button", "card-container", "card-v2-title", "card-v2", "checkbox", "chip", "code-tag", "color-menu-option", "color-menu", "color-swatch", "date-picker", "dialog", "emoji-picker", "emoji", "field", "field-v2", "file-drop", "file-picker", "file-status", "flag", "floating-panel", "floating-panel-button", "floating-panel-icon-button", "grid-item", "grid", "help-tooltip", "icon", "inline-alert", "input", "link", "list-item", "list", "pagination", "persistent-overlay", "pop", "popover", "progress-stepper-item-v2", "progress-stepper-item", "progress-stepper-v2", "progress-stepper", "progress", "radio-option", "radio", "rich-text", "rich-textarea", "rich-textarea-chip", "segment-collapse", "segmented-control-option", "segmented-control", "segmented-icon-control-option", "segmented-icon-control", "select-button", "select-menu-option", "select-menu", "sheet", "sheet-title", "skeleton-item", "skeleton", "spinner", "stop-events", "table-body", "table-cell", "table-head-cell", "table-head", "table-row", "table", "tabs-icon-option", "tabs-option", "tabs", "tag", "text", "textarea", "time-picker", "title", "toast-manager", "toast", "toggle", "tooltip"];
2
+ export declare const BASE_COMPONENT_NAMES: Set<"pop" | "button" | "dialog" | "input" | "link" | "progress" | "table" | "textarea" | "title" | "popover" | "text" | "icon" | "chip" | "accordion-item" | "accordion" | "action-menu-option" | "action-menu" | "alert" | "avatar" | "badge" | "button-group-item" | "button-group" | "card-container" | "card-v2-title" | "card-v2" | "checkbox" | "code-tag" | "color-menu-option" | "color-menu" | "color-swatch" | "date-picker" | "emoji-picker" | "emoji" | "field" | "field-v2" | "file-drop" | "file-picker" | "file-status" | "flag" | "floating-panel" | "floating-panel-button" | "floating-panel-icon-button" | "grid-item" | "grid" | "help-tooltip" | "inline-alert" | "list-item" | "list" | "pagination" | "persistent-overlay" | "progress-stepper-item-v2" | "progress-stepper-item" | "progress-stepper-v2" | "progress-stepper" | "radio-option" | "radio" | "rich-text" | "rich-textarea" | "rich-textarea-chip" | "segment-collapse" | "segmented-control-option" | "segmented-control" | "segmented-icon-control-option" | "segmented-icon-control" | "select-button" | "select-menu-option" | "select-menu" | "sheet" | "sheet-title" | "skeleton-item" | "skeleton" | "spinner" | "stop-events" | "table-body" | "table-cell" | "table-head-cell" | "table-head" | "table-row" | "tabs-icon-option" | "tabs-option" | "tabs" | "tag" | "time-picker" | "toast-manager" | "toast" | "toggle" | "tooltip">;
3
3
  export type ComponentName = `sinch-${typeof BASE_COMPONENT_NAMES_LIST[number]}`;
@@ -44,7 +44,9 @@ const BASE_COMPONENT_NAMES_LIST = [
44
44
  "persistent-overlay",
45
45
  "pop",
46
46
  "popover",
47
+ "progress-stepper-item-v2",
47
48
  "progress-stepper-item",
49
+ "progress-stepper-v2",
48
50
  "progress-stepper",
49
51
  "progress",
50
52
  "radio-option",
package/utils/dom.d.ts CHANGED
@@ -12,13 +12,20 @@ export declare function getLiteralAttribute<T extends readonly string[]>($elemen
12
12
  export declare function getLiteralAttribute<T extends readonly string[]>($element: Element, literals: T, attrName: string, defaultValue: T[number]): T[number];
13
13
  export declare const clampNumber: (value: number, min: number, max: number) => number;
14
14
  type IntegerOptions = {
15
- min?: number;
16
- max?: number;
15
+ min?: number | undefined;
16
+ max?: number | undefined;
17
17
  defaultValue?: number | null;
18
18
  itemSizeMultiplier?: number;
19
19
  itemSpaceBetween?: number;
20
20
  addExtraSpace?: boolean;
21
21
  };
22
+ type FloatOptions = {
23
+ min?: number | undefined;
24
+ max?: number | undefined;
25
+ fractionDigits?: number;
26
+ };
27
+ export declare const applyRange: (value: number, { min, max }: IntegerOptions) => number;
28
+ export declare const attrValueToFloat: (value: string | null, options: FloatOptions) => string | null;
22
29
  export declare const attrValueToInteger: (value: string | null, options?: IntegerOptions) => number | null;
23
30
  export declare const attrValueToPixels: (value: string | null, options?: IntegerOptions) => string;
24
31
  export declare const updateIntegerAttribute: ($element: Element, attrName: string, attrValue: string | number | null | undefined, options?: IntegerOptions) => void;
@@ -35,6 +42,7 @@ export declare const getDeepActiveElement: (ownerDocument?: Document) => Element
35
42
  export declare const composedContains: (container: Node, node: Node | null) => boolean;
36
43
  export declare const isAttrEqual: (oldVal: string | null, newVal: string | null) => boolean;
37
44
  export declare const getScrollableParents: (node: HTMLElement | null) => (HTMLElement | Document)[];
45
+ export declare const createScopedElement: <K extends keyof HTMLElementTagNameMap>(anchor: Element, tag: K) => HTMLElementTagNameMap[K];
38
46
  export declare const isTransformedElement: (element: HTMLElement | null) => element is HTMLElement;
39
47
  export declare const getTransformedAncestor: (node: HTMLElement | null) => HTMLElement | null;
40
48
  export {};
package/utils/dom.js CHANGED
@@ -52,6 +52,9 @@ const DEFAULT_INTEGER_OPTIONS = {
52
52
  itemSpaceBetween: 0,
53
53
  defaultValue: null
54
54
  };
55
+ const DEFAULT_FLOAT_OPTIONS = {
56
+ fractionDigits: 2
57
+ };
55
58
  const applyRange = (value, { min, max }) => {
56
59
  let result = value;
57
60
  if (min != null) {
@@ -62,6 +65,21 @@ const applyRange = (value, { min, max }) => {
62
65
  }
63
66
  return result;
64
67
  };
68
+ const attrValueToFloat = (value, options) => {
69
+ const opts = {
70
+ ...DEFAULT_FLOAT_OPTIONS,
71
+ ...options
72
+ };
73
+ const float = Number.parseFloat(String(value));
74
+ if (Number.isNaN(float)) {
75
+ return null;
76
+ }
77
+ if (opts.min !== void 0 || opts.max !== void 0) {
78
+ const rangedFloat = applyRange(float, { min: opts.min, max: opts.max });
79
+ return rangedFloat.toFixed(opts.fractionDigits);
80
+ }
81
+ return float.toFixed(opts.fractionDigits);
82
+ };
65
83
  const attrValueToInteger = (value, options = DEFAULT_INTEGER_OPTIONS) => {
66
84
  const { defaultValue = null, itemSizeMultiplier = 1, itemSpaceBetween = 0, addExtraSpace = false } = options;
67
85
  let intValue = defaultValue;
@@ -179,6 +197,14 @@ const getScrollableParents = (node) => {
179
197
  scrollableParents.push(document);
180
198
  return scrollableParents;
181
199
  };
200
+ const createScopedElement = (anchor, tag) => {
201
+ const root = anchor.getRootNode();
202
+ const shadowCreateElement = root.createElement;
203
+ if (typeof shadowCreateElement === "function") {
204
+ return shadowCreateElement.call(root, tag);
205
+ }
206
+ return document.createElement(tag);
207
+ };
182
208
  const isTransformedElement = (element) => {
183
209
  if (element == null) {
184
210
  return false;
@@ -212,11 +238,14 @@ const getTransformedAncestor = (node) => {
212
238
  return null;
213
239
  };
214
240
  export {
241
+ applyRange,
242
+ attrValueToFloat,
215
243
  attrValueToInteger,
216
244
  attrValueToPixels,
217
245
  clampNumber,
218
246
  cloneNode,
219
247
  composedContains,
248
+ createScopedElement,
220
249
  getAttribute,
221
250
  getBooleanAttribute,
222
251
  getCssVar,
@@ -53,7 +53,9 @@ declare const BASE_COMPONENT_NAMES_LIST: readonly [
53
53
  "persistent-overlay",
54
54
  "pop",
55
55
  "popover",
56
+ "progress-stepper-item-v2",
56
57
  "progress-stepper-item",
58
+ "progress-stepper-v2",
57
59
  "progress-stepper",
58
60
  "progress",
59
61
  "radio-option",
package/utils/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Context, subscribeContext } from "./context.js";
2
2
  import { CSV_DELIMITER, getFirstCsvValue, packCsv, unpackCsv, updateCsv } from "./csv.js";
3
- import { attrValueToInteger, attrValueToPixels, clampNumber, cloneNode, composedContains, getAttribute, getBooleanAttribute, getCssVar, getCssVars, getDeepActiveElement, getIntegerAttribute, getLiteralAttribute, getScrollableParents, getTransformedAncestor, hasClass, isAttrEqual, isAttrTrue, isLiteralValue, isTransformedElement, setClass, shouldReduceMotion, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateIntegerAttribute, updateLiteralAttribute } from "./dom.js";
3
+ import { applyRange, attrValueToFloat, attrValueToInteger, attrValueToPixels, clampNumber, cloneNode, composedContains, createScopedElement, getAttribute, getBooleanAttribute, getCssVar, getCssVars, getDeepActiveElement, getIntegerAttribute, getLiteralAttribute, getScrollableParents, getTransformedAncestor, hasClass, isAttrEqual, isAttrTrue, isLiteralValue, isTransformedElement, setClass, shouldReduceMotion, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateIntegerAttribute, updateLiteralAttribute } from "./dom.js";
4
4
  import { NectaryElement, defineCustomElement, pascalToKebabCase, registerComponent, resetNectaryRegistry, setNectaryRegistry } from "./element.js";
5
5
  import { getRect, getTargetRect, rectOverlap } from "./rect.js";
6
6
  import { getFirstFocusableElement, getFirstSlotElement, isElementFocused } from "./slot.js";
@@ -15,11 +15,14 @@ export {
15
15
  CSV_DELIMITER,
16
16
  Context,
17
17
  NectaryElement,
18
+ applyRange,
19
+ attrValueToFloat,
18
20
  attrValueToInteger,
19
21
  attrValueToPixels,
20
22
  clampNumber,
21
23
  cloneNode,
22
24
  composedContains,
25
+ createScopedElement,
23
26
  debounceAnimationFrame,
24
27
  debounceTimeout,
25
28
  defineCustomElement,