@nova-design-system/nova-react 3.1.0 → 3.2.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.
Files changed (43) hide show
  1. package/dist/cjs/{index-Cn-oNJnW.js → index-B2jv2KXv.js} +1610 -793
  2. package/dist/cjs/index.js +2 -1
  3. package/dist/cjs/{nv-alert.entry-BFwufSUQ.js → nv-alert.entry-pxBJfmIm.js} +1 -1
  4. package/dist/cjs/{nv-avatar.entry-Do1K4s3s.js → nv-avatar.entry-CHtVctSK.js} +1 -1
  5. package/dist/cjs/{nv-badge_2.entry-NTGHyFdg.js → nv-badge_2.entry-BO88KO1O.js} +1 -1
  6. package/dist/cjs/{nv-breadcrumb.entry-oPVGJYlk.js → nv-breadcrumb.entry-7azRtyl5.js} +1 -1
  7. package/dist/cjs/{nv-breadcrumbs.entry-BsOw153b.js → nv-breadcrumbs.entry-DfZVMKpY.js} +1 -1
  8. package/dist/cjs/{nv-button.entry-13tdBiRr.js → nv-button.entry-DW9SblsY.js} +1 -1
  9. package/dist/cjs/{nv-calendar.entry-u9MgGb83.js → nv-calendar.entry-BeayRRor.js} +16 -37
  10. package/dist/cjs/{nv-col.entry-DFhv-GI7.js → nv-col.entry-C6oEkSbI.js} +1 -1
  11. package/dist/cjs/{nv-datagrid.entry-BoB17gvI.js → nv-datagrid.entry-xhQP6JJP.js} +95 -103
  12. package/dist/cjs/{nv-datagridcolumn.entry-C3MYBmfS.js → nv-datagridcolumn.entry-CjYmo4fM.js} +2 -2
  13. package/dist/cjs/{nv-dialog.entry-OA3qL3Tx.js → nv-dialog.entry-mxETaZbc.js} +1 -1
  14. package/dist/cjs/{nv-dialogfooter_2.entry-LAQYSiGV.js → nv-dialogfooter_2.entry-DnLg2DHy.js} +1 -1
  15. package/dist/cjs/{nv-fieldcheckbox.entry-CP7SDzVO.js → nv-fieldcheckbox.entry-Be9__i15.js} +1 -1
  16. package/dist/cjs/{nv-fielddate.entry-CD7PX6yA.js → nv-fielddate.entry-BlNily-X.js} +2 -2
  17. package/dist/cjs/{nv-fielddaterange.entry-BVBVGmly.js → nv-fielddaterange.entry-CycpKoJd.js} +73 -18
  18. package/dist/cjs/{nv-fielddropdown.entry-Nwric1vT.js → nv-fielddropdown.entry-BPwviyCp.js} +84 -60
  19. package/dist/cjs/{nv-fielddropdownitem.entry-CiqSw5VL.js → nv-fielddropdownitem.entry-BGuUR9KP.js} +1 -1
  20. package/dist/cjs/{nv-fieldmultiselect.entry-QKNIBcW1.js → nv-fieldmultiselect.entry-Lrxr1gsi.js} +116 -104
  21. package/dist/cjs/{nv-fieldnumber.entry-DfHcI-sO.js → nv-fieldnumber.entry-B1VySoWj.js} +2 -2
  22. package/dist/cjs/{nv-fieldpassword.entry-b2pUmS8F.js → nv-fieldpassword.entry-D7Qlx7Bh.js} +2 -2
  23. package/dist/cjs/{nv-fieldradio.entry-Dxc6ZCyb.js → nv-fieldradio.entry-CDu8xs0p.js} +1 -1
  24. package/dist/cjs/{nv-fieldselect.entry-Cys0KRyG.js → nv-fieldselect.entry-NEdv8bQK.js} +2 -2
  25. package/dist/cjs/nv-fieldslider.entry-51gF9XPz.js +660 -0
  26. package/dist/cjs/{nv-fieldtext.entry-DCZWLFFp.js → nv-fieldtext.entry-Bug9zMgo.js} +5 -5
  27. package/dist/cjs/{nv-fieldtextarea.entry-DEeRdtZ7.js → nv-fieldtextarea.entry-D44HbsVQ.js} +5 -5
  28. package/dist/cjs/{nv-fieldtime.entry-BqxiFlLI.js → nv-fieldtime.entry-MbaWbVtc.js} +11 -11
  29. package/dist/cjs/nv-icon.entry-BSSHr-ud.js +79 -0
  30. package/dist/cjs/{nv-iconbutton_2.entry-BLNrQz9Q.js → nv-iconbutton_2.entry-DMaO-JWz.js} +3 -3
  31. package/dist/cjs/{nv-menu.entry-7IDfPmZ8.js → nv-menu.entry-D5_lj9XB.js} +2 -2
  32. package/dist/cjs/{nv-menuitem.entry-B9cjy7O8.js → nv-menuitem.entry-fhnYI91K.js} +2 -2
  33. package/dist/cjs/{nv-popover.entry-ChLYZ3zY.js → nv-popover.entry-CYqBaVbr.js} +2 -2
  34. package/dist/cjs/{nv-row.entry-DiLY8Vbc.js → nv-row.entry-BUheLufV.js} +2 -2
  35. package/dist/cjs/{nv-stack.entry-MpPzmg5_.js → nv-stack.entry-DNPce51E.js} +2 -2
  36. package/dist/cjs/{nv-table.entry-cME3Zuq2.js → nv-table.entry-DXQM8l3t.js} +3 -3
  37. package/dist/cjs/{nv-tablecolumn.entry-DSctDxCS.js → nv-tablecolumn.entry-DROQK_0c.js} +1 -1
  38. package/dist/cjs/{nv-toggle.entry-EBWm3Xy5.js → nv-toggle.entry-fMzTrdte.js} +3 -3
  39. package/dist/cjs/{nv-tooltip.entry-q6rJLq1C.js → nv-tooltip.entry-yB2Ek1Cz.js} +3 -3
  40. package/dist/generated/components.js +8 -0
  41. package/dist/types/generated/components.d.ts +5 -0
  42. package/package.json +1 -1
  43. package/dist/cjs/nv-icon.entry-CzEdUDdA.js +0 -79
@@ -0,0 +1,660 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index-B2jv2KXv.js');
4
+ var v4A79185f4 = require('./v4-a79185f4-2n0dOd_Y.js');
5
+ require('react');
6
+
7
+ /**
8
+ * Utility functions for nv-fieldslider.
9
+ */
10
+ /**
11
+ * Clamp a value between min and max.
12
+ * @param {number} value - The value to clamp
13
+ * @param {number} min - The minimum boundary
14
+ * @param {number} max - The maximum boundary
15
+ * @returns {number} The clamped value
16
+ */
17
+ function clamp(value, min, max) {
18
+ return Math.max(min, Math.min(max, value));
19
+ }
20
+ /**
21
+ * Calculate the percentage position of a value within a range.
22
+ * @param {number} value - The value to convert to percentage
23
+ * @param {number} min - The minimum value of the range
24
+ * @param {number} max - The maximum value of the range
25
+ * @returns {number} The percentage (0-100)
26
+ */
27
+ function valueToPercent(value, min, max) {
28
+ if (max === min)
29
+ return 0;
30
+ return ((value - min) / (max - min)) * 100;
31
+ }
32
+ /**
33
+ * Snap a value to the nearest step.
34
+ * @param {number} value - The value to snap
35
+ * @param {number} min - The minimum boundary
36
+ * @param {number} max - The maximum boundary
37
+ * @param {number} step - The step size
38
+ * @returns {number} The snapped value
39
+ */
40
+ function snapToStep(value, min, max, step) {
41
+ const clamped = clamp(value, min, max);
42
+ const snapped = Math.round((clamped - min) / step) * step + min;
43
+ return clamp(snapped, min, max);
44
+ }
45
+ /**
46
+ * Generate tick values for the slider.
47
+ * @param {number} min - The minimum value
48
+ * @param {number} max - The maximum value
49
+ * @param {number} step - The step size
50
+ * @returns {number[]} Array of tick values
51
+ */
52
+ function generateTicks(min, max, step) {
53
+ const ticks = [];
54
+ for (let v = min; v <= max; v += step) {
55
+ ticks.push(Number(v.toFixed(10))); // avoid floating point issues
56
+ }
57
+ if (ticks[ticks.length - 1] !== max) {
58
+ ticks.push(max);
59
+ }
60
+ return ticks;
61
+ }
62
+ /**
63
+ * Snap a value to the nearest tick mark.
64
+ * @param {number} value - The value to snap
65
+ * @param {object[]} ticks - Array of tick objects
66
+ * @returns {number} The value of the closest tick
67
+ */
68
+ function snapToTicks(value, ticks) {
69
+ if (!ticks || ticks.length === 0)
70
+ return value;
71
+ // Find the closest tick
72
+ let closestTick = ticks[0].value;
73
+ let minDistance = Math.abs(value - closestTick);
74
+ for (const tick of ticks) {
75
+ const distance = Math.abs(value - tick.value);
76
+ if (distance < minDistance) {
77
+ minDistance = distance;
78
+ closestTick = tick.value;
79
+ }
80
+ }
81
+ return closestTick;
82
+ }
83
+
84
+ /**
85
+ * Renders single thumb in standard mode.
86
+ * @param {SingleThumbProps} props - Component properties
87
+ * @returns {JSX.Element} JSX element representing the thumb
88
+ */
89
+ const SingleThumb = props => {
90
+ const { value, min, max, rawPosition, isDragging, snap, disabled, readonly, onKeyDown, labelBeforeValue, labelAfterValue, } = props;
91
+ // Use raw position for visual display during dragging, but the snapped value otherwise
92
+ let displayPosition = value;
93
+ if (isDragging && !snap) {
94
+ displayPosition = clamp(rawPosition, min, max);
95
+ }
96
+ const percent = valueToPercent(displayPosition, min, max);
97
+ return (index.h("div", { class: "thumb", style: { left: `${percent}%` }, role: "slider", "aria-valuemin": min, "aria-valuemax": max, "aria-valuenow": value, "aria-disabled": disabled ? 'true' : undefined, "aria-readonly": readonly ? 'true' : undefined, tabindex: disabled ? -1 : 0, onKeyDown: onKeyDown },
98
+ index.h("div", { class: "thumb-tooltip" },
99
+ labelBeforeValue && (index.h("span", { class: "label-before" }, labelBeforeValue)),
100
+ String(value),
101
+ labelAfterValue && index.h("span", { class: "label-after" }, labelAfterValue))));
102
+ };
103
+
104
+ /**
105
+ * Renders dual thumbs in range mode.
106
+ * @param {RangeThumbProps} props - Component properties
107
+ * @returns {JSX.Element[]} Array of JSX elements representing the range slider thumbs
108
+ */
109
+ const RangeThumb = props => {
110
+ const { rangeValue, rawRangePosition, activeDragThumb, isDragging, snap, min, max, disabled, readonly, onKeyDown, labelBeforeValue, labelAfterValue, } = props;
111
+ const [leftValue, rightValue] = rangeValue;
112
+ // Use raw positions for visual display during dragging, but the snapped values otherwise
113
+ let displayLeftPosition = leftValue;
114
+ let displayRightPosition = rightValue;
115
+ if (isDragging && !snap) {
116
+ const [rawLeft, rawRight] = rawRangePosition;
117
+ if (activeDragThumb === 'left') {
118
+ displayLeftPosition = clamp(rawLeft, min, Math.min(rightValue, max));
119
+ }
120
+ else if (activeDragThumb === 'right') {
121
+ displayRightPosition = clamp(rawRight, Math.max(leftValue, min), max);
122
+ }
123
+ }
124
+ const leftPercent = valueToPercent(displayLeftPosition, min, max);
125
+ const rightPercent = valueToPercent(displayRightPosition, min, max);
126
+ return [
127
+ index.h("div", { class: "track-range", style: {
128
+ left: `${leftPercent}%`,
129
+ width: `${rightPercent - leftPercent}%`,
130
+ } }),
131
+ index.h("div", { class: "thumb thumb-left", style: { left: `${leftPercent}%` }, role: "slider", "aria-valuemin": min, "aria-valuemax": max, "aria-valuenow": leftValue, "aria-disabled": disabled ? 'true' : undefined, "aria-readonly": readonly ? 'true' : undefined, "data-thumb": "left", tabindex: disabled ? -1 : 0, onKeyDown: onKeyDown },
132
+ index.h("div", { class: "thumb-tooltip" },
133
+ labelBeforeValue && (index.h("span", { class: "label-before" }, labelBeforeValue)),
134
+ String(leftValue),
135
+ labelAfterValue && index.h("span", { class: "label-after" }, labelAfterValue))),
136
+ index.h("div", { class: "thumb thumb-right", style: { left: `${rightPercent}%` }, role: "slider", "aria-valuemin": min, "aria-valuemax": max, "aria-valuenow": rightValue, "aria-disabled": disabled ? 'true' : undefined, "aria-readonly": readonly ? 'true' : undefined, "data-thumb": "right", tabindex: disabled ? -1 : 0, onKeyDown: onKeyDown },
137
+ index.h("div", { class: "thumb-tooltip" },
138
+ labelBeforeValue && (index.h("span", { class: "label-before" }, labelBeforeValue)),
139
+ String(rightValue),
140
+ labelAfterValue && index.h("span", { class: "label-after" }, labelAfterValue))),
141
+ ];
142
+ };
143
+
144
+ /**
145
+ * Renders tick marks along the slider track.
146
+ * @param {TickMarksProps} props - Component properties
147
+ * @returns {JSX.Element | null} JSX element representing the tick marks or null if no ticks
148
+ */
149
+ const TickMarks = props => {
150
+ const { ticks, min, max } = props;
151
+ if (ticks.length === 0) {
152
+ return null;
153
+ }
154
+ return (index.h("div", { class: "track-ticks" }, ticks.map(tick => {
155
+ const percent = valueToPercent(tick.value, min, max);
156
+ return (index.h("div", { class: "track-tick", style: { left: `${percent}%` } }, tick.label && index.h("div", { class: "tick-label" }, tick.label)));
157
+ })));
158
+ };
159
+
160
+ /**
161
+ * Renders field input for direct value entry
162
+ * @param {FieldInputProps} props - Component properties
163
+ * @returns {JSX.Element} JSX element representing the field input
164
+ */
165
+ const FieldInput = props => {
166
+ const { range, hasField, value, rangeValue, index: index$1, inputId, min, max, step, disabled, readonly, onInput, labelBeforeValue, labelAfterValue, name, endName, } = props;
167
+ // Determine the appropriate value based on mode and index
168
+ const fieldValue = range ? rangeValue[index$1] : value;
169
+ // In range mode, we need data-index for event handling
170
+ const dataAttrs = range ? { 'data-index': index$1.toString() } : {};
171
+ // Determine the appropriate name based on mode and index
172
+ let inputName;
173
+ if (range) {
174
+ if (index$1 === 0) {
175
+ inputName = name || '';
176
+ }
177
+ else {
178
+ // Use endName if provided, otherwise append "-end" to the name
179
+ inputName = endName || (name ? `${name}-end` : '');
180
+ }
181
+ }
182
+ else {
183
+ inputName = name || '';
184
+ }
185
+ // If hasField is false, only the containers are visible, not the input fields
186
+ const containerClass = hasField
187
+ ? 'input-container'
188
+ : 'input-container hidden-input';
189
+ return hasField ? (index.h("div", { class: containerClass },
190
+ labelBeforeValue && index.h("span", { class: "label-before" }, labelBeforeValue),
191
+ index.h("input", Object.assign({ id: inputId, type: "number", value: fieldValue, min: min, max: max, step: step, disabled: disabled, readonly: readonly, name: inputName }, dataAttrs, { onInput: onInput })),
192
+ labelAfterValue && index.h("span", { class: "label-after" }, labelAfterValue))) : (index.h("input", { id: inputId, type: "hidden", value: fieldValue, disabled: disabled, readonly: readonly, name: inputName }));
193
+ };
194
+
195
+ const nvFieldsliderCss = "nv-fieldslider{--nv-field-border-default:var(--components-form-field-border-default);--nv-field-border-hover:var(--components-form-field-border-hover);--nv-field-border-focus:var(--components-form-field-border-focus);--nv-field-border-disabled:var(--components-form-field-border-default);--nv-field-border-readonly:var(--components-form-field-border-default);--nv-field-focus-box-shadow:var(--color-focus-brand);--nv-field-background:var(--components-form-field-background-default);display:flex;flex-direction:column;align-items:flex-start;gap:var(--form-gap-y);box-sizing:border-box;max-width:480px}nv-fieldslider .slider-container{width:100%;display:flex;flex-direction:row;align-items:center;gap:var(--form-gap-x)}nv-fieldslider .slider-container .track-container{position:relative;flex:1;height:calc(16px + 0.25rem);padding:calc(16px / 2) 0}nv-fieldslider .slider-container .track-container .track{position:relative;height:4px;background:#e5e7eb;border-radius:4px;cursor:pointer}nv-fieldslider .slider-container .track-container .track .track-range{position:absolute;top:0;height:4px;background:var(--nv-field-border-focus);border-radius:4px;pointer-events:none}nv-fieldslider .slider-container .track-container .track .thumb{position:absolute;top:50%;width:16px;height:16px;background:#ffffff;border:2px solid var(--nv-field-border-focus);border-radius:50%;box-shadow:0 2px 4px rgba(0, 0, 0, 0.1);transform:translate(-50%, -50%);z-index:1;cursor:grab;transition:box-shadow 0.2s, background-color 0.2s}nv-fieldslider .slider-container .track-container .track .thumb:focus{box-shadow:0 4px 6px rgba(0, 0, 0, 0.15);outline:6px solid color-mix(in srgb, var(--nv-field-border-focus) 50%, transparent);transition:outline}nv-fieldslider .slider-container .track-container .track .thumb:active{cursor:grabbing;background-color:#e6f7ff}nv-fieldslider .slider-container .track-container .track .thumb .thumb-tooltip{position:absolute;top:25px;left:50%;background-color:var(--components-tooltip-background);color:var(--components-tooltip-text);padding:5px;border-radius:var(--tooltip-radius);font-size:var(--tooltip-font-size);z-index:10;pointer-events:none;user-select:none;opacity:0;transition:opacity 0.3s ease-in-out;transform:translateX(-50%)}nv-fieldslider .slider-container .track-container .track .thumb .thumb-tooltip:after{content:\"\";background:var(--components-tooltip-background);box-shadow:none;border:none;position:absolute;border-bottom-color:transparent;border-right-color:transparent;width:6px;height:6px;transform:rotate(45deg);border-radius:1px;top:-3px;left:50%;margin-left:-3px}nv-fieldslider .slider-container .track-container .track .thumb:hover .thumb-tooltip,nv-fieldslider .slider-container .track-container .track .thumb:active .thumb-tooltip,nv-fieldslider .slider-container .track-container .track .thumb:focus .thumb-tooltip{opacity:1}nv-fieldslider .slider-container .track-container .track-ticks{position:relative;height:1rem;margin-top:0.25rem}nv-fieldslider .slider-container .track-container .track-ticks .track-tick{position:absolute;top:0;width:6px;height:6px;background:var(--components-form-field-border-default);border-radius:50%;transform:translate(-50%, 0);pointer-events:none}nv-fieldslider .slider-container .track-container .track-ticks .track-tick .tick-label{position:absolute;top:calc(6px + 0.25rem);left:50%;color:var(--components-form-field-border-default);transform:translateX(-50%);white-space:nowrap}nv-fieldslider .slider-container .input-container{display:flex;flex-grow:1;justify-content:center;align-items:center;align-self:stretch;border-radius:var(--form-field-radius);border-width:1px;border-style:solid;border-color:var(--nv-field-border-default);opacity:var(--components-form-opacity-default, 1);background:var(--nv-field-background);transition:all 150ms ease-out;width:64px;flex-grow:unset}nv-fieldslider .slider-container .input-container:hover{border-color:var(--nv-field-border-hover)}nv-fieldslider .slider-container .input-container:focus-within,nv-fieldslider .slider-container .input-container:focus-within:hover,nv-fieldslider .slider-container .input-container:focus,nv-fieldslider .slider-container .input-container:focus:hover{border-color:var(--nv-field-border-focus);box-shadow:0px 0px 0px var(--focus-field-stroke) var(--nv-field-focus-box-shadow)}nv-fieldslider .slider-container .input-container:has(input:read-only){opacity:0.5;background-color:var(--components-form-field-background-readonly);border-color:var(--nv-field-border-readonly)}nv-fieldslider .slider-container .input-container:has(input:disabled){opacity:0.5;background-color:var(--components-form-field-background-disabled);border-color:var(--nv-field-border-disabled)}nv-fieldslider .slider-container .input-container input{display:flex;align-items:center;flex:1 0 0;overflow:hidden;background-color:transparent;color:var(--components-form-field-content-text);padding:var(--form-field-padding-y) var(--form-field-padding-x);font-size:var(--form-field-font-size);font-style:normal;font-weight:500;line-height:var(--form-field-line-height);width:100%}nv-fieldslider .slider-container .input-container input:focus{outline:none}nv-fieldslider .slider-container .input-container input::placeholder{overflow:hidden;color:var(--components-form-field-content-placeholder);text-overflow:ellipsis;font-family:\"TT Norms Pro\", sans-serif;font-size:var(--form-field-font-size);font-style:normal;font-weight:400;line-height:var(--form-field-line-height)}nv-fieldslider[fluid]:not([fluid=false]){max-width:unset}nv-fieldslider[error]:not([error=false]){--nv-field-border-default:var(--components-form-field-border-error);--nv-field-border-hover:var(--nv-field-border-default);--nv-field-border-focus:var(--nv-field-border-default);--nv-field-border-disabled:var(--nv-field-border-default);--nv-field-border-readonly:var(--nv-field-border-default);--nv-field-focus-box-shadow:var(--color-focus-destructive-in-field)}nv-fieldslider[success]:not([success=false]){--nv-field-border-default:var(--components-form-field-border-success);--nv-field-border-hover:var(--nv-field-border-default);--nv-field-border-focus:var(--nv-field-border-default);--nv-field-border-disabled:var(--nv-field-border-default);--nv-field-border-readonly:var(--nv-field-border-default);--nv-field-focus-box-shadow:var(--color-focus-success)}nv-fieldslider[readonly]:not([readonly=false]){--nv-field-border-default:var(--components-form-field-border-readonly);--nv-field-border-hover:var(--nv-field-border-default);--nv-field-border-focus:var(--components-form-field-border-focus);--nv-field-border-disabled:var(--nv-field-border-default);--nv-field-border-readonly:var(--nv-field-border-default);--nv-field-background:var(--components-form-field-background-readonly)}nv-fieldslider[readonly]:not([readonly=false]) .track,nv-fieldslider[readonly]:not([readonly=false]) .thumb{cursor:default}nv-fieldslider label{display:flex;align-items:center;gap:var(--form-label-gap);align-self:stretch;color:var(--components-form-text-label-default);font-family:\"TT Norms Pro\", sans-serif;font-size:var(--form-label-font-size);font-style:normal;font-weight:500;line-height:var(--form-label-line-height)}nv-fieldslider[hide-label]:not([hide-label=false]) label{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}nv-fieldslider[has-field]:not([has-field=false]) .thumb-tooltip{display:none}nv-fieldslider>.description{display:flex;align-items:center;align-self:stretch;gap:var(--spacing-1);color:var(--components-form-text-description-default);font-family:\"TT Norms Pro\", sans-serif;font-size:var(--form-description-font-size);font-style:normal;line-height:var(--form-description-line-height)}nv-fieldslider>.error-description{display:flex;align-items:center;align-self:stretch;gap:var(--spacing-1);color:var(--components-form-text-description-default);font-family:\"TT Norms Pro\", sans-serif;font-size:var(--form-description-font-size);font-style:normal;line-height:var(--form-description-line-height);color:var(--components-form-text-description-error)}nv-fieldslider>.error-description[hidden]{display:none}";
196
+ const NvFieldsliderStyle0 = nvFieldsliderCss;
197
+
198
+ const NvFieldslider = class {
199
+ constructor(hostRef) {
200
+ index.registerInstance(this, hostRef);
201
+ this.valueChanged = index.createEvent(this, "valueChanged");
202
+ /****************************************************************************/
203
+ //#region PROPERTIES
204
+ /**
205
+ * Sets the ID for the start input element and the for attribute of the associated
206
+ * label. If no ID is provided, a random one will be automatically generated.
207
+ */
208
+ this.startInputId = v4A79185f4.v4();
209
+ /**
210
+ * Sets the ID for the end input element and the for attribute of the associated
211
+ * label. If no ID is provided, a random one will be automatically generated.
212
+ */
213
+ this.endInputId = v4A79185f4.v4();
214
+ /**
215
+ * Keeps the interface clean by removing visible labels, but still announces
216
+ * the label to screen readers so users relying on assistive tech aren't left
217
+ * guessing.
218
+ */
219
+ this.hideLabel = false;
220
+ /**
221
+ * Enables an optional numeric input field alongside the slider, allowing
222
+ * users to type a value directly instead of—or in addition to—using the
223
+ * slider handle.
224
+ */
225
+ this.hasField = false;
226
+ /**
227
+ * Allows the slider to display two thumbs, enabling users to select a
228
+ * continuous range between a minimum and maximum value. Ideal for use cases
229
+ * like filtering by price or time.
230
+ */
231
+ this.range = false;
232
+ /**
233
+ * Disables user interaction with the slider and its associated input fields.
234
+ */
235
+ this.disabled = false;
236
+ /**
237
+ * Makes the slider and input non-editable while keeping them focusable and
238
+ * included in form submissions.
239
+ */
240
+ this.readonly = false;
241
+ /**
242
+ * Alters the slider's appearance to indicate an error, helping users
243
+ * identify fields that need correction.
244
+ * @validator error
245
+ */
246
+ this.error = false;
247
+ /**
248
+ * Changes the slider's appearance to indicate successful input or validation.
249
+ */
250
+ this.success = false;
251
+ /**
252
+ * Numeric value of the slider as a string, if range mode is on, the values
253
+ * will be a comma-separated string.
254
+ */
255
+ this.value = '0';
256
+ /**
257
+ * Defines the interval between selectable values on the slider. Controls how
258
+ * much the value increases or decreases with each keyboard interaction, drag
259
+ * movement, or direct input.
260
+ */
261
+ this.step = 1;
262
+ /**
263
+ * Controls whether the slider handle should visually snap to step values
264
+ * during dragging. When false, the handle can be positioned at any point
265
+ * along the track while dragging, but the actual value will still snap to the
266
+ * nearest step value. When true, the handle will visually snap to the nearest
267
+ * step value during dragging.
268
+ */
269
+ this.snap = false;
270
+ /**
271
+ * When true and custom ticks are provided, the slider will snap to the nearest
272
+ * tick value during dragging, instead of using the step value. This is useful
273
+ * when you have custom ticks at specific values that don't align with regular step intervals.
274
+ */
275
+ this.snapTicks = false;
276
+ /**
277
+ * Defines the minimum allowed value for the slider. The thumb cannot move
278
+ * below this value, and manual input is also constrained accordingly.
279
+ */
280
+ this.min = 0;
281
+ /**
282
+ * Defines the maximum allowed value for the slider. The thumb cannot move
283
+ * above this value, and manual input is also constrained accordingly.
284
+ */
285
+ this.max = 100;
286
+ /**
287
+ * Controls the visibility of tick marks on the slider. When enabled, all
288
+ * visual ticks that indicate step points along the track are shown. If custom
289
+ * ticks are provided, they are always shown regardless of this setting.
290
+ */
291
+ this.showTicks = false;
292
+ /**
293
+ * Allows the field to stretch and fill the entire width of its container.
294
+ */
295
+ this.fluid = false;
296
+ //#endregion PROPERTIES
297
+ /****************************************************************************/
298
+ //#region STATE
299
+ this.isDragging = false;
300
+ this.activeDragThumb = 'single';
301
+ this.internalTicks = [];
302
+ // These track the raw slider positions for visual display
303
+ this.rawPosition = 0;
304
+ this.rawRangePosition = [0, 0];
305
+ this.valueInternal = 0;
306
+ this.rangeValueInternal = [0, 0];
307
+ /**
308
+ * Parses the value string into a number or array of numbers for internal use.
309
+ */
310
+ this.parseValue = () => {
311
+ const values = this.value.replace(/\s/g, '').split(',');
312
+ if (values.length === 1) {
313
+ this.valueInternal = parseFloat(values[0]);
314
+ }
315
+ else if (values.length === 2) {
316
+ values.forEach((value, index) => {
317
+ this.valueInternal = parseFloat(value);
318
+ this.rangeValueInternal[index] = this.valueInternal;
319
+ });
320
+ }
321
+ };
322
+ /**
323
+ * Handles pointer events on the track.
324
+ * @param {PointerEvent} event - The pointer event
325
+ */
326
+ this.onTrackInteraction = (event) => {
327
+ if (this.disabled || this.readonly) {
328
+ return;
329
+ }
330
+ const trackRect = event.currentTarget.getBoundingClientRect();
331
+ const percentage = clamp(((event.clientX - trackRect.left) / trackRect.width) * 100, 0, 100);
332
+ const newValue = this.min + (percentage / 100) * (this.max - this.min);
333
+ // Store raw position for visual display
334
+ this.rawPosition = newValue;
335
+ if (this.range) {
336
+ // In range mode, determine which thumb to move based on proximity
337
+ const leftPct = valueToPercent(this.rangeValueInternal[0], this.min, this.max);
338
+ const rightPct = valueToPercent(this.rangeValueInternal[1], this.min, this.max);
339
+ const distanceToLeft = Math.abs(percentage - leftPct);
340
+ const distanceToRight = Math.abs(percentage - rightPct);
341
+ if (distanceToLeft <= distanceToRight) {
342
+ this.activeDragThumb = 'left';
343
+ this.rawRangePosition = [newValue, this.rawRangePosition[1]];
344
+ this.handleValueChange([newValue, this.rangeValueInternal[1]]);
345
+ }
346
+ else {
347
+ this.activeDragThumb = 'right';
348
+ this.rawRangePosition = [this.rawRangePosition[0], newValue];
349
+ this.handleValueChange([this.rangeValueInternal[0], newValue]);
350
+ }
351
+ }
352
+ else {
353
+ this.activeDragThumb = 'single';
354
+ this.rawPosition = newValue;
355
+ this.handleValueChange(newValue);
356
+ }
357
+ this.isDragging = true;
358
+ this.registerGlobalEvents();
359
+ };
360
+ /**
361
+ * Handles pointer move events during drag.
362
+ * @param {PointerEvent} event - The pointer event
363
+ */
364
+ this.onPointerMove = (event) => {
365
+ if (!this.isDragging || this.disabled || this.readonly) {
366
+ return;
367
+ }
368
+ const trackElement = this.el.querySelector('.track');
369
+ if (!trackElement)
370
+ return;
371
+ const trackRect = trackElement.getBoundingClientRect();
372
+ const percentage = clamp(((event.clientX - trackRect.left) / trackRect.width) * 100, 0, 100);
373
+ const newValue = this.min + (percentage / 100) * (this.max - this.min);
374
+ // Update visual position
375
+ if (this.range) {
376
+ if (this.activeDragThumb === 'left') {
377
+ this.rawRangePosition = [newValue, this.rawRangePosition[1]];
378
+ this.handleValueChange([newValue, this.rangeValueInternal[1]]);
379
+ }
380
+ else {
381
+ this.rawRangePosition = [this.rawRangePosition[0], newValue];
382
+ this.handleValueChange([this.rangeValueInternal[0], newValue]);
383
+ }
384
+ }
385
+ else {
386
+ this.rawPosition = newValue;
387
+ this.handleValueChange(newValue);
388
+ }
389
+ };
390
+ /**
391
+ * Handles the end of a drag operation.
392
+ */
393
+ this.onPointerUp = () => {
394
+ this.isDragging = false;
395
+ this.removeGlobalEvents();
396
+ };
397
+ /**
398
+ * Handles keydown events for keyboard accessibility.
399
+ * @param {KeyboardEvent} event - The keyboard event
400
+ */
401
+ this.onKeyDown = (event) => {
402
+ if (this.disabled || this.readonly) {
403
+ return;
404
+ }
405
+ let newValue;
406
+ const stepMultiplier = event.shiftKey ? 10 : 1;
407
+ const singleStep = this.step * stepMultiplier;
408
+ if (this.range) {
409
+ const focusedThumb = event.target.getAttribute('data-thumb');
410
+ const idx = focusedThumb === 'left' ? 0 : 1;
411
+ const currentValue = [...this.rangeValueInternal];
412
+ switch (event.key) {
413
+ case 'ArrowRight':
414
+ case 'ArrowUp':
415
+ currentValue[idx] += singleStep;
416
+ break;
417
+ case 'ArrowLeft':
418
+ case 'ArrowDown':
419
+ currentValue[idx] -= singleStep;
420
+ break;
421
+ case 'Home':
422
+ currentValue[idx] = this.min;
423
+ break;
424
+ case 'End':
425
+ currentValue[idx] = this.max;
426
+ break;
427
+ case 'PageUp':
428
+ currentValue[idx] += singleStep * 10;
429
+ break;
430
+ case 'PageDown':
431
+ currentValue[idx] -= singleStep * 10;
432
+ break;
433
+ default:
434
+ return;
435
+ }
436
+ newValue = currentValue;
437
+ }
438
+ else {
439
+ switch (event.key) {
440
+ case 'ArrowRight':
441
+ case 'ArrowUp':
442
+ newValue = this.valueInternal + singleStep;
443
+ break;
444
+ case 'ArrowLeft':
445
+ case 'ArrowDown':
446
+ newValue = this.valueInternal - singleStep;
447
+ break;
448
+ case 'Home':
449
+ newValue = this.min;
450
+ break;
451
+ case 'End':
452
+ newValue = this.max;
453
+ break;
454
+ case 'PageUp':
455
+ newValue = this.valueInternal + singleStep * 10;
456
+ break;
457
+ case 'PageDown':
458
+ newValue = this.valueInternal - singleStep * 10;
459
+ break;
460
+ default:
461
+ return;
462
+ }
463
+ }
464
+ event.preventDefault();
465
+ this.handleValueChange(newValue);
466
+ };
467
+ /**
468
+ * Handles field input value changes.
469
+ * @param {Event} event - The input event
470
+ */
471
+ this.handleFieldChange = (event) => {
472
+ const input = event.target;
473
+ const newValue = parseFloat(input.value);
474
+ if (isNaN(newValue)) {
475
+ return;
476
+ }
477
+ if (this.range) {
478
+ const fieldIndex = input.getAttribute('data-index') === '0' ? 0 : 1;
479
+ const updatedRange = [...this.rangeValueInternal];
480
+ updatedRange[fieldIndex] = newValue;
481
+ this.handleValueChange(updatedRange);
482
+ }
483
+ else {
484
+ this.handleValueChange(newValue);
485
+ }
486
+ };
487
+ }
488
+ //#endregion STATE
489
+ /****************************************************************************/
490
+ //#region METHODS
491
+ /**
492
+ * Ensures value is valid and within bounds.
493
+ * @param {number} val - The value to validate
494
+ * @returns {number} The validated and snapped value
495
+ */
496
+ validateValue(val) {
497
+ // First ensure the value is within bounds
498
+ const clampedValue = clamp(val, this.min, this.max);
499
+ // If snapTicks is true and we have custom ticks, snap to the nearest tick
500
+ if (this.snapTicks && this.internalTicks && this.internalTicks.length > 0) {
501
+ return snapToTicks(clampedValue, this.internalTicks);
502
+ }
503
+ // Otherwise snap to step values
504
+ return snapToStep(clampedValue, this.min, this.max, this.step);
505
+ }
506
+ /**
507
+ * Handles value changes from slider interaction.
508
+ * @param {number | number[]} newValue - The new value or range values
509
+ */
510
+ handleValueChange(newValue) {
511
+ if (this.disabled || this.readonly) {
512
+ return;
513
+ }
514
+ if (this.range) {
515
+ // Handle range values
516
+ if (Array.isArray(newValue) && newValue.length === 2) {
517
+ // Ensure values are in order (left ≤ right)
518
+ const orderedValues = [
519
+ Math.min(newValue[0], newValue[1]),
520
+ Math.max(newValue[0], newValue[1]),
521
+ ];
522
+ // Snap to steps and clamp
523
+ const validatedValues = [
524
+ this.validateValue(orderedValues[0]),
525
+ this.validateValue(orderedValues[1]),
526
+ ];
527
+ if (validatedValues[0] !== this.rangeValueInternal[0] ||
528
+ validatedValues[1] !== this.rangeValueInternal[1]) {
529
+ this.rangeValueInternal = validatedValues;
530
+ this.value = this.rangeValueInternal.join(',');
531
+ this.valueChanged.emit(this.rangeValueInternal.join(','));
532
+ }
533
+ }
534
+ }
535
+ else {
536
+ // Handle single value
537
+ if (typeof newValue === 'number') {
538
+ const validatedValue = this.validateValue(newValue);
539
+ if (validatedValue !== this.valueInternal) {
540
+ this.valueInternal = validatedValue;
541
+ this.value = String(this.valueInternal);
542
+ this.valueChanged.emit(String(this.valueInternal));
543
+ }
544
+ }
545
+ }
546
+ }
547
+ /**
548
+ * Generates the ticks to display based on props and state.
549
+ */
550
+ generateDisplayTicks() {
551
+ // If custom ticks are provided, always use them regardless of showTicks setting
552
+ if (this.ticks && this.ticks.length > 0) {
553
+ this.internalTicks = [...this.ticks].sort((a, b) => a.value - b.value);
554
+ return;
555
+ }
556
+ // If showTicks is false and there are no custom ticks, hide all ticks
557
+ if (!this.showTicks) {
558
+ this.internalTicks = [];
559
+ return;
560
+ }
561
+ // Generate all ticks at each step point
562
+ const autoTicks = generateTicks(this.min, this.max, this.step);
563
+ this.internalTicks = autoTicks.map(value => ({ value }));
564
+ }
565
+ /**
566
+ * Registers global events for tracking pointer movement.
567
+ */
568
+ registerGlobalEvents() {
569
+ document.addEventListener('pointermove', this.onPointerMove);
570
+ document.addEventListener('pointerup', this.onPointerUp);
571
+ document.addEventListener('pointercancel', this.onPointerUp);
572
+ }
573
+ /**
574
+ * Removes global events when tracking ends.
575
+ */
576
+ removeGlobalEvents() {
577
+ document.removeEventListener('pointermove', this.onPointerMove);
578
+ document.removeEventListener('pointerup', this.onPointerUp);
579
+ document.removeEventListener('pointercancel', this.onPointerUp);
580
+ }
581
+ //#endregion METHODS
582
+ /****************************************************************************/
583
+ //#region WATCHERS
584
+ onValueChange() {
585
+ this.parseValue();
586
+ }
587
+ onConfigChange() {
588
+ this.generateDisplayTicks();
589
+ if (this.range) {
590
+ this.handleValueChange(this.rangeValueInternal);
591
+ }
592
+ else {
593
+ this.handleValueChange(this.valueInternal);
594
+ }
595
+ }
596
+ onRangeChange(newValue) {
597
+ if (newValue) {
598
+ // Switching to range mode
599
+ this.rangeValueInternal = [this.min, this.valueInternal];
600
+ }
601
+ else {
602
+ // Switching to single mode, take the higher value
603
+ this.valueInternal = this.rangeValueInternal[1];
604
+ }
605
+ }
606
+ //#endregion WATCHERS
607
+ /****************************************************************************/
608
+ //#region LIFECYCLE
609
+ connectedCallback() {
610
+ this.parseValue();
611
+ this.generateDisplayTicks();
612
+ // Initialize values and make sure they're valid
613
+ if (this.range) {
614
+ if (!Array.isArray(this.rangeValueInternal) ||
615
+ this.rangeValueInternal.length !== 2) {
616
+ this.rangeValueInternal = [this.min, this.max];
617
+ }
618
+ this.handleValueChange(this.rangeValueInternal);
619
+ // Initialize raw range position to match actual values
620
+ this.rawRangePosition = [
621
+ this.rangeValueInternal[0],
622
+ this.rangeValueInternal[1],
623
+ ];
624
+ }
625
+ else {
626
+ this.handleValueChange(this.valueInternal);
627
+ // Initialize raw position to match actual value
628
+ this.rawPosition = this.valueInternal;
629
+ }
630
+ }
631
+ disconnectedCallback() {
632
+ this.removeGlobalEvents();
633
+ }
634
+ //#endregion EVENTS
635
+ /****************************************************************************/
636
+ //#region RENDER
637
+ render() {
638
+ return (index.h(index.Host, { key: '69cded86eeaff3470f970d8c5e359d467cea1762' }, (this.label || this.el.querySelector('[slot="label"]')) && (index.h("label", { key: 'd6725108d8cfc35d4722e5761592b08f20c390b2', htmlFor: this.startInputId }, index.h("slot", { key: 'a13207c702baa4ea95073da3db56419c50114de2', name: "label" }, this.label))), index.h("div", { key: 'a771db3df06edf4ca150db4f66f42a6816e32bc8', class: "slider-container" }, this.range ? (index.h(FieldInput, { range: this.range, hasField: this.hasField, value: this.valueInternal, rangeValue: this.rangeValueInternal, index: 0, inputId: this.startInputId, min: this.min, max: this.max, step: this.step, disabled: this.disabled, readonly: this.readonly, onInput: this.handleFieldChange, labelBeforeValue: this.labelBeforeValue, labelAfterValue: this.labelAfterValue, name: this.name, endName: this.endName })) : null, index.h("div", { key: '705fe70c9d5ebba5dc9b877532936d301df0baf6', class: "track-container" }, index.h("div", { key: '1f9a691c278e88160319699ff91d925dfd8184c2', class: "track", onPointerDown: this.onTrackInteraction }, this.range ? (index.h(RangeThumb, { rangeValue: this.rangeValueInternal, rawRangePosition: this.rawRangePosition, activeDragThumb: this.activeDragThumb, isDragging: this.isDragging, snap: this.snap, min: this.min, max: this.max, disabled: this.disabled, readonly: this.readonly, onKeyDown: this.onKeyDown, labelBeforeValue: this.labelBeforeValue, labelAfterValue: this.labelAfterValue })) : (index.h(SingleThumb, { value: this.valueInternal, min: this.min, max: this.max, rawPosition: this.rawPosition, isDragging: this.isDragging, snap: this.snap, disabled: this.disabled, readonly: this.readonly, onKeyDown: this.onKeyDown, labelBeforeValue: this.labelBeforeValue, labelAfterValue: this.labelAfterValue }))), index.h(TickMarks, { key: 'b80cf4eeb492587ca44ebc6512ded331ec5619ef', ticks: this.internalTicks, min: this.min, max: this.max })), this.range ? (index.h(FieldInput, { range: this.range, hasField: this.hasField, value: this.valueInternal, rangeValue: this.rangeValueInternal, index: 1, inputId: this.endInputId, min: this.min, max: this.max, step: this.step, disabled: this.disabled, readonly: this.readonly, onInput: this.handleFieldChange, labelBeforeValue: this.labelBeforeValue, labelAfterValue: this.labelAfterValue, name: this.name, endName: this.endName })) : (index.h(FieldInput, { range: this.range, hasField: this.hasField, value: this.valueInternal, rangeValue: this.rangeValueInternal, inputId: this.startInputId, min: this.min, max: this.max, step: this.step, disabled: this.disabled, readonly: this.readonly, onInput: this.handleFieldChange, labelBeforeValue: this.labelBeforeValue, labelAfterValue: this.labelAfterValue, name: this.name }))), (this.success ||
639
+ this.description ||
640
+ this.el.querySelector('[slot="description"]')) && (index.h("div", { key: '97a111d5b194aeb4f1fcf1049489ddcf30527157', class: "description" }, this.success && (index.h("nv-icon", { key: 'cc549945c9a330892c69826867f4279e039944e8', name: "circle-check", class: "validation", size: "md" })), index.h("slot", { key: '54b3e872439763a15595d6bf4f9c5e129aeae386', name: "description" }, this.description))), (this.error ||
641
+ this.errorDescription ||
642
+ this.el.querySelector('[slot="error-description"]')) && (index.h("div", { key: 'cd5702e6819a11782a634d522a2dccd992af00f3', class: "error-description", hidden: !this.error }, this.error && (index.h("nv-icon", { key: '1641a68da28b0963d61b74e69c2c32f566ffeff3', name: "alert-circle", class: "validation", size: "md" })), index.h("slot", { key: 'a969cc7e37c4a21024790a5603a44365e135693d', name: "error-description" }, this.errorDescription)))));
643
+ }
644
+ static get formAssociated() { return true; }
645
+ get el() { return index.getElement(this); }
646
+ static get watchers() { return {
647
+ "value": ["onValueChange"],
648
+ "min": ["onConfigChange"],
649
+ "max": ["onConfigChange"],
650
+ "step": ["onConfigChange"],
651
+ "ticks": ["onConfigChange"],
652
+ "showTicks": ["onConfigChange"],
653
+ "snap": ["onConfigChange"],
654
+ "snapTicks": ["onConfigChange"],
655
+ "range": ["onRangeChange"]
656
+ }; }
657
+ };
658
+ NvFieldslider.style = NvFieldsliderStyle0;
659
+
660
+ exports.nv_fieldslider = NvFieldslider;