@mono-lit/helper 0.0.9 → 0.1.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 (164) hide show
  1. package/dist/accordion-core-DaNyPWRr.js +277 -0
  2. package/dist/alert-core-DWtHbX_-.js +134 -0
  3. package/dist/breadcrumb-list-core-Dh68T8Cf.js +747 -0
  4. package/dist/{mono-button-CLkHg3WW.js → button-core-DerXg84Q.js} +3 -276
  5. package/dist/button-dropdown-core-DKYEOyjy.js +654 -0
  6. package/dist/button-utils-D5-66M02.js +63 -0
  7. package/dist/card-utils-l80qAmrN.js +312 -0
  8. package/dist/chart-core-DV7hD3ZY.js +801 -0
  9. package/dist/checkbox-utils-DKdrhAzF.js +337 -0
  10. package/dist/chip-utils-DpRrd7Zj.js +403 -0
  11. package/dist/{data-source-controller-C6C4ej_M.js → data-source-controller-DS_JLrmS.js} +1 -1
  12. package/dist/{data-source-options-fxT5QIX4.js → data-source-options-DJUNU26C.js} +6 -6
  13. package/dist/{data-source-read-BL266IW0.js → data-source-read-uKJpRAzx.js} +2 -2
  14. package/dist/date-core-CyuSyvvG.js +734 -0
  15. package/dist/drawer-core-DbFWvNln.js +759 -0
  16. package/dist/dropdown-core-BCH1pK14.js +511 -0
  17. package/dist/dropdown-table-core-SfHUJVFq.js +1342 -0
  18. package/dist/export.js +1 -1
  19. package/dist/{field-path-BabiMrrA.js → field-path-DK2VBWHl.js} +1 -1
  20. package/dist/field-tooltip.css_raw-DVblekCl.js +5 -0
  21. package/dist/{field-validation.css_raw-Cx6SGrfP.js → field-validation.css_raw-BU7C6173.js} +1 -170
  22. package/dist/file-upload-core-Cz_dBQMx.js +624 -0
  23. package/dist/filter-builder-core-DyWjbBP7.js +381 -0
  24. package/dist/{filter-builder-B6Y2mmbM.js → filter-builder-vbqIuPhX.js} +1 -1
  25. package/dist/{filter-eval-ChDSaAUH.js → filter-eval-CqeBnMYh.js} +1 -1
  26. package/dist/{filter-odata-Bi27XUpQ.js → filter-odata-GsczYKNC.js} +1 -1
  27. package/dist/{hydration-flush-BaE9gN3C.js → hydration-flush-Volt9X7Q.js} +2 -1071
  28. package/dist/index.js +11 -11
  29. package/dist/{index.node-DTqDBca7.js → index.node-Csy9zrr1.js} +4 -4
  30. package/dist/index.node.js +11 -11
  31. package/dist/input-utils-BglY-k0H.js +1145 -0
  32. package/dist/menu-core-DkAYuCZ2.js +831 -0
  33. package/dist/modal-core-CSBSPN_m.js +844 -0
  34. package/dist/mono-button-DVvZ03P-.js +280 -0
  35. package/dist/{mono-button.shadow-DqZMpcqY.js → mono-button.shadow-BANxMGln.js} +6 -594
  36. package/dist/{mono-data-chart-NKPdAgVq.js → mono-data-chart-ChF4J9RT.js} +6 -6
  37. package/dist/{mono-data-dropdown-B2iRpJuI.js → mono-data-dropdown-Bgj2PDfm.js} +1 -1
  38. package/dist/{mono-data-grid-llJCX9MC.js → mono-data-grid-DJkp96N-.js} +144 -46
  39. package/dist/{mono-event-BPku9HpS.js → mono-event-CAZf0F_k.js} +14 -9
  40. package/dist/{mono-form-controller-BrA10erm.js → mono-form-controller-DxZLvyg6.js} +2 -1
  41. package/dist/mono-table-checkbox-core-BKOMx8R5.js +5288 -0
  42. package/dist/nav-core-B5qU2dzn.js +225 -0
  43. package/dist/{normalize-error-D93O4q8g.js → normalize-error-BEcd1tmS.js} +2 -2
  44. package/dist/nuxt.js +1 -1
  45. package/dist/otp-core-DXg3vFLh.js +758 -0
  46. package/dist/radio-utils-Dk9Tl1jz.js +319 -0
  47. package/dist/rich-text-editor-core-Ddd_QaLn.js +1280 -0
  48. package/dist/select-utils-BgArYHk8.js +2140 -0
  49. package/dist/sidebar-core-CD6txDo3.js +583 -0
  50. package/dist/slider-core-vcWr321-.js +1014 -0
  51. package/dist/src/components/dropdown-table/dropdown-table-core.d.ts +2 -2
  52. package/dist/src/components/dropdown-table/dropdown-table-types.d.ts +1 -1
  53. package/dist/src/components/dropdown-table/index.d.ts +1 -1
  54. package/dist/src/components/dropdown-table/index.shadow.d.ts +1 -1
  55. package/dist/src/components/dropdown-table/mono-data-dropdown.d.ts +1 -1
  56. package/dist/src/components/form/form-types.d.ts +9 -3
  57. package/dist/src/components/input/input-core.d.ts +1 -1
  58. package/dist/src/components/input/input-types.d.ts +1 -1
  59. package/dist/src/components/otp/otp-core.d.ts +1 -1
  60. package/dist/src/components/select/select-core.d.ts +1 -1
  61. package/dist/src/components/select/select-types.d.ts +1 -1
  62. package/dist/src/components/slider/slider-core.d.ts +1 -1
  63. package/dist/src/components/slider/slider-types.d.ts +1 -1
  64. package/dist/src/components/table/filter-suggestion.d.ts +171 -0
  65. package/dist/src/components/table/index.d.ts +5 -4
  66. package/dist/src/components/table/index.shadow.d.ts +5 -4
  67. package/dist/src/components/table/mono-data-grid.d.ts +22 -3
  68. package/dist/src/components/table/mono-table-empty-core.d.ts +37 -0
  69. package/dist/src/components/table/mono-table-search-core.d.ts +22 -3
  70. package/dist/src/components/table/table-types.d.ts +74 -4
  71. package/dist/src/components/tag-input/tag-input-core.d.ts +1 -1
  72. package/dist/src/components/tag-input/tag-input-types.d.ts +1 -1
  73. package/dist/src/components/textarea/textarea-core.d.ts +1 -1
  74. package/dist/src/composables/mono-event.d.ts +7 -1
  75. package/dist/src/entries/index.d.ts +8 -6
  76. package/dist/src/entries/index.node.d.ts +8 -6
  77. package/dist/src/search/index.d.ts +1 -1
  78. package/dist/src/utils/group-count.d.ts +36 -0
  79. package/dist/switch-utils-CTZ4id2V.js +338 -0
  80. package/dist/tabs-core-r5-B8k_N.js +317 -0
  81. package/dist/tag-input-utils-D2JA90DQ.js +3060 -0
  82. package/dist/textarea-utils-VU1KeXm8.js +821 -0
  83. package/dist/ui/accordion.js +2 -274
  84. package/dist/ui/alert.js +2 -131
  85. package/dist/ui/breadcrumb.js +4 -745
  86. package/dist/ui/button-dropdown.js +4 -652
  87. package/dist/ui/button.js +2 -63
  88. package/dist/ui/card.js +2 -310
  89. package/dist/ui/chart.js +4 -800
  90. package/dist/ui/checkbox.js +4 -335
  91. package/dist/ui/chip.js +4 -402
  92. package/dist/ui/date.js +3 -732
  93. package/dist/ui/drawer.js +3 -757
  94. package/dist/ui/dropdown-table.js +5 -1341
  95. package/dist/ui/dropdown.js +4 -509
  96. package/dist/ui/file-upload.js +3 -622
  97. package/dist/ui/filter.js +5 -380
  98. package/dist/ui/form.js +1 -1
  99. package/dist/ui/index.css +118 -1
  100. package/dist/ui/input.js +3 -1141
  101. package/dist/ui/menu.js +4 -828
  102. package/dist/ui/modal.js +4 -843
  103. package/dist/ui/nav.js +4 -223
  104. package/dist/ui/otp.js +4 -756
  105. package/dist/ui/radio.js +4 -317
  106. package/dist/ui/rich-text-editor.js +4 -1278
  107. package/dist/ui/select.js +5 -2138
  108. package/dist/ui/shadow/accordion.js +4 -273
  109. package/dist/ui/shadow/alert.js +4 -130
  110. package/dist/ui/shadow/breadcrumb.js +5 -744
  111. package/dist/ui/shadow/button-dropdown.js +6 -652
  112. package/dist/ui/shadow/button.js +3 -63
  113. package/dist/ui/shadow/card.js +4 -309
  114. package/dist/ui/shadow/chart.js +6 -1576
  115. package/dist/ui/shadow/checkbox.js +4 -334
  116. package/dist/ui/shadow/chip.js +4 -396
  117. package/dist/ui/shadow/date.js +7 -731
  118. package/dist/ui/shadow/drawer.js +4 -756
  119. package/dist/ui/shadow/dropdown-table.js +8 -1762
  120. package/dist/ui/shadow/dropdown.js +4 -508
  121. package/dist/ui/shadow/file-upload.js +4 -620
  122. package/dist/ui/shadow/filter.js +7 -379
  123. package/dist/ui/shadow/input.js +6 -1140
  124. package/dist/ui/shadow/menu.js +5 -828
  125. package/dist/ui/shadow/modal.js +6 -1063
  126. package/dist/ui/shadow/nav.js +5 -223
  127. package/dist/ui/shadow/otp.js +6 -754
  128. package/dist/ui/shadow/radio.js +4 -316
  129. package/dist/ui/shadow/rich-text-editor.js +4 -1276
  130. package/dist/ui/shadow/select.js +6 -2136
  131. package/dist/ui/shadow/sidebar.js +5 -581
  132. package/dist/ui/shadow/slider.js +5 -1010
  133. package/dist/ui/shadow/switch.js +4 -335
  134. package/dist/ui/shadow/table.js +10 -4501
  135. package/dist/ui/shadow/tabs.js +6 -315
  136. package/dist/ui/shadow/tag-input.js +7 -3057
  137. package/dist/ui/shadow/textarea.js +6 -817
  138. package/dist/ui/sidebar.js +3 -581
  139. package/dist/ui/slider.js +4 -1012
  140. package/dist/ui/switch.js +4 -336
  141. package/dist/ui/table.js +9 -4502
  142. package/dist/ui/tabs.js +4 -315
  143. package/dist/ui/tag-input.js +5 -3058
  144. package/dist/ui/textarea.js +4 -819
  145. package/dist/{vite-CivRCJaf.js → vite-CfW7z2wn.js} +21 -14
  146. package/dist/vite.js +1 -1
  147. package/dist/vue.d.ts +3 -2
  148. package/package.json +10 -11
  149. package/dist/chip-strip-bNfLn52Z.js +0 -215
  150. package/dist/data-source-controller-Dx6IQ2CN.js +0 -243
  151. package/dist/data-source-options-BM4r4PRw.js +0 -558
  152. package/dist/data-source-read-HyBCRg1t.js +0 -242
  153. package/dist/excel-BXzr3uI1.js +0 -784
  154. package/dist/export-ixRdCS2y.js +0 -2388
  155. package/dist/field-tooltip-addon-CWCp19mJ.js +0 -702
  156. package/dist/field-tooltip.css_raw-U5UeTa2d.js +0 -269
  157. package/dist/filter-builder-C0T3pMx2.js +0 -208
  158. package/dist/form-control-core-BbiACMtL.js +0 -226
  159. package/dist/icon-ClxnYhBG.js +0 -19
  160. package/dist/import-Dc4eXC02.js +0 -612
  161. package/dist/light-slots-_no0r2Z-.js +0 -246
  162. package/dist/markdown-uGlE_OfJ.js +0 -20191
  163. package/dist/mono-data-grid-e9ZVBlNN.js +0 -4240
  164. package/dist/normalize-error-BmLbgANw.js +0 -1048
@@ -0,0 +1,1014 @@
1
+ import { f as toCssSize } from "./mono-ui-kvLVIf1V.js";
2
+ import { a as defineHybridPropAliases, i as defineHybridPropAlias, r as booleanStringConverter, t as __decorate } from "./decorate-DbYFpi8R.js";
3
+ import { t as dispatchMonoEvent } from "./mono-event-CAZf0F_k.js";
4
+ import { t as MonoFormControlCore } from "./form-control-core-CRZPZ1ru.js";
5
+ import { a as parseFormat, t as applyFormat } from "./input-format-GrRCJBqV.js";
6
+ import { n as cssPart } from "./css-class-B6Tc_MAx.js";
7
+ import { t as FieldTooltipController } from "./field-tooltip-Csk4s2ve.js";
8
+ import { html, nothing } from "lit";
9
+ import { property, state } from "lit/decorators.js";
10
+ import { ifDefined } from "lit/directives/if-defined.js";
11
+ import { styleMap } from "lit/directives/style-map.js";
12
+
13
+ //#region src/components/slider/slider-math.ts
14
+ /** Past this many grid ticks, `marks` = true draws only the ends: denser than this reads as a texture. */
15
+ const MAX_AUTO_MARKS = 26;
16
+ /** Strip float noise (0.1 + 0.2) without losing a fractional step. */
17
+ function stripNoise(n) {
18
+ return Number(n.toFixed(10));
19
+ }
20
+ function toNumber(value) {
21
+ if (value === null || value === void 0 || value === "") return void 0;
22
+ const n = typeof value === "number" ? value : Number(value);
23
+ return Number.isFinite(n) ? n : void 0;
24
+ }
25
+ /**
26
+ * Anything a consumer (or a framework) might hand over as a value — a number, an array, a JSON
27
+ * string (`"[20,80]"`, what an SSR attribute carries), a comma list (`"20,80"`), a numeric string —
28
+ * as a list of finite numbers. Non-numbers are dropped. `null` when nothing usable is left.
29
+ */
30
+ function coerceNumbers(value) {
31
+ if (value === null || value === void 0 || value === "") return null;
32
+ if (typeof value === "number") return Number.isFinite(value) ? [value] : null;
33
+ if (Array.isArray(value)) {
34
+ const out = value.map(toNumber).filter((n) => n !== void 0);
35
+ return out.length ? out : null;
36
+ }
37
+ if (typeof value === "string") {
38
+ const text = value.trim();
39
+ if (text.startsWith("[")) try {
40
+ return coerceNumbers(JSON.parse(text));
41
+ } catch {
42
+ return null;
43
+ }
44
+ if (text.includes(",")) return coerceNumbers(text.split(","));
45
+ const n = toNumber(text);
46
+ return n === void 0 ? null : [n];
47
+ }
48
+ return null;
49
+ }
50
+ /** The scale from raw props: defaults 0 / 100 / 1, `max` never below `min`, stops cleaned. */
51
+ function resolveScale(input) {
52
+ const min = toNumber(input.min) ?? 0;
53
+ const rawMax = toNumber(input.max) ?? 100;
54
+ const max = rawMax < min ? min : rawMax;
55
+ const rawStep = toNumber(input.step);
56
+ const step = rawStep === void 0 ? 1 : rawStep > 0 ? rawStep : 0;
57
+ const minGap = Math.max(0, toNumber(input.minGap) ?? 0);
58
+ const list = coerceNumbers(input.stops);
59
+ const stops = list ? [...new Set(list.filter((n) => n >= min && n <= max).map(stripNoise))].sort((a, b) => a - b) : null;
60
+ return {
61
+ min,
62
+ max,
63
+ step,
64
+ stops: stops && stops.length ? stops : null,
65
+ minGap
66
+ };
67
+ }
68
+ function clamp(v, lo, hi) {
69
+ return Math.min(hi, Math.max(lo, v));
70
+ }
71
+ /** The allowed value nearest to `v` (a stop, a grid point, or `v` itself when continuous). */
72
+ function snap(v, scale) {
73
+ const x = clamp(v, scale.min, scale.max);
74
+ if (scale.stops) {
75
+ let best = scale.stops[0];
76
+ for (const s of scale.stops) if (Math.abs(s - x) < Math.abs(best - x)) best = s;
77
+ return best;
78
+ }
79
+ if (!scale.step) return stripNoise(x);
80
+ const snapped = scale.min + Math.round((x - scale.min) / scale.step) * scale.step;
81
+ return stripNoise(snapped > scale.max ? snapped - scale.step : snapped);
82
+ }
83
+ /** The smallest allowed value ≥ x (or `max` when none is). */
84
+ function ceilTo(x, scale) {
85
+ if (x <= scale.min) return scale.min;
86
+ if (scale.stops) return scale.stops.find((s) => s >= x - 1e-9) ?? scale.max;
87
+ if (!scale.step) return Math.min(x, scale.max);
88
+ const v = scale.min + Math.ceil(stripNoise((x - scale.min) / scale.step)) * scale.step;
89
+ return stripNoise(v > scale.max ? scale.max : v);
90
+ }
91
+ /** The largest allowed value ≤ x (or `min` when none is). */
92
+ function floorTo(x, scale) {
93
+ if (x >= scale.max) return scale.stops ? scale.stops[scale.stops.length - 1] : snapFloorMax(scale);
94
+ if (scale.stops) {
95
+ for (let i = scale.stops.length - 1; i >= 0; i--) if (scale.stops[i] <= x + 1e-9) return scale.stops[i];
96
+ return scale.min;
97
+ }
98
+ if (!scale.step) return Math.max(x, scale.min);
99
+ const v = scale.min + Math.floor(stripNoise((x - scale.min) / scale.step)) * scale.step;
100
+ return stripNoise(v < scale.min ? scale.min : v);
101
+ }
102
+ /** The highest grid point (equals `max` only when the step divides the span). */
103
+ function snapFloorMax(scale) {
104
+ if (!scale.step) return scale.max;
105
+ return stripNoise(scale.min + Math.floor(stripNoise((scale.max - scale.min) / scale.step)) * scale.step);
106
+ }
107
+ /**
108
+ * The values, made valid: each clamped and snapped, sorted, then spread so neighbours are at least
109
+ * `minGap` apart. Thumbs are never dropped — when the gap cannot fit every thumb, they pack
110
+ * against the ends (the forward pass pushes right, the backward pass pulls back under `max`).
111
+ */
112
+ function normalise(values, scale) {
113
+ const out = values.map((v) => snap(v, scale)).sort((a, b) => a - b);
114
+ if (!scale.minGap || out.length < 2) return out;
115
+ for (let i = 1; i < out.length; i++) if (out[i] - out[i - 1] < scale.minGap - 1e-9) out[i] = ceilTo(out[i - 1] + scale.minGap, scale);
116
+ for (let i = out.length - 2; i >= 0; i--) if (out[i + 1] - out[i] < scale.minGap - 1e-9) out[i] = floorTo(out[i + 1] - scale.minGap, scale);
117
+ return out.map((v) => clamp(v, scale.min, scale.max));
118
+ }
119
+ /** The range thumb `i` may move in: its neighbours ± `minGap` (the BLOCK rule). */
120
+ function thumbBounds(values, i, scale) {
121
+ const lo = i > 0 ? ceilTo(values[i - 1] + scale.minGap, scale) : scale.min;
122
+ const hi = i < values.length - 1 ? floorTo(values[i + 1] - scale.minGap, scale) : snapFloorMaxOrStop(scale);
123
+ return {
124
+ lo,
125
+ hi: Math.max(lo, hi)
126
+ };
127
+ }
128
+ function snapFloorMaxOrStop(scale) {
129
+ return scale.stops ? scale.stops[scale.stops.length - 1] : snapFloorMax(scale);
130
+ }
131
+ function snapFloorMinOrStop(scale) {
132
+ return scale.stops ? scale.stops[0] : scale.min;
133
+ }
134
+ /**
135
+ * Move thumb `i` toward `v`: snap, then stop at the neighbours (± gap). Returns a NEW array when
136
+ * the thumb actually moved, the SAME array otherwise — callers use identity to skip no-op events.
137
+ */
138
+ function moveThumb(values, i, v, scale) {
139
+ const { lo, hi } = thumbBounds(values, i, scale);
140
+ const next = clamp(snap(v, scale), lo, hi);
141
+ if (next === values[i]) return values;
142
+ const out = values.slice();
143
+ out[i] = next;
144
+ return out;
145
+ }
146
+ /**
147
+ * Shift a whole run of thumbs `[from..to]` by `delta`, keeping their spacing — the drag of a filled
148
+ * segment between two thumbs. The run stops at the track ends and at the thumbs outside it.
149
+ */
150
+ function moveRun(values, from, to, delta, scale) {
151
+ const lo = from > 0 ? values[from - 1] + scale.minGap : snapFloorMinOrStop(scale);
152
+ const hi = to < values.length - 1 ? values[to + 1] - scale.minGap : snapFloorMaxOrStop(scale);
153
+ const d = clamp(delta, lo - values[from], hi - values[to]);
154
+ if (!d) return values;
155
+ const applied = clamp(snap(values[from] + d, scale) - values[from], lo - values[from], hi - values[to]);
156
+ if (!applied) return values;
157
+ const out = values.slice();
158
+ for (let k = from; k <= to; k++) out[k] = stripNoise(values[k] + applied);
159
+ return out;
160
+ }
161
+ /**
162
+ * The thumb a press at `v` should grab: the nearest one. Thumbs sitting on the same spot (`[2, 2,
163
+ * 3]`) tie — then the press picks by SIDE: a press above the stack takes its LAST thumb, below it
164
+ * the FIRST, so stacked thumbs can always be pulled apart. `dir` (+1 / -1) breaks an exact hit,
165
+ * once the drag has shown which way it is heading.
166
+ */
167
+ function nearestThumb(values, v, dir = 0) {
168
+ let best = 0;
169
+ let bestDist = Infinity;
170
+ for (let i = 0; i < values.length; i++) {
171
+ const d = Math.abs(values[i] - v);
172
+ if (d < bestDist - 1e-9) {
173
+ best = i;
174
+ bestDist = d;
175
+ }
176
+ }
177
+ let first = best;
178
+ let last = best;
179
+ while (first > 0 && Math.abs(values[first - 1] - values[best]) < 1e-9) first--;
180
+ while (last < values.length - 1 && Math.abs(values[last + 1] - values[best]) < 1e-9) last++;
181
+ if (first === last) return best;
182
+ return (v > values[best] + 1e-9 ? 1 : v < values[best] - 1e-9 ? -1 : dir) > 0 ? last : first;
183
+ }
184
+ /** True when several thumbs share position `values[i]` (a stack the next drag must split). */
185
+ function isStacked(values, i) {
186
+ return i > 0 && Math.abs(values[i - 1] - values[i]) < 1e-9 || i < values.length - 1 && Math.abs(values[i + 1] - values[i]) < 1e-9;
187
+ }
188
+ /** `v` as a 0–100 position along the track. */
189
+ function toPercent(v, scale) {
190
+ const span = scale.max - scale.min;
191
+ if (span <= 0) return 0;
192
+ return clamp((v - scale.min) / span * 100, 0, 100);
193
+ }
194
+ /** A 0–1 position along the track as a raw (unsnapped) value. */
195
+ function fromRatio(ratio, scale) {
196
+ return scale.min + clamp(ratio, 0, 1) * (scale.max - scale.min);
197
+ }
198
+ /**
199
+ * The track as pieces between its boundaries (the two ends and every thumb), each flagged filled
200
+ * or not by the `fill` mode. Rendering every stretch as its own piece is what lets `track-gap` cut
201
+ * the track back around each thumb, and lets a consumer colour segments one by one.
202
+ */
203
+ function trackPieces(values, scale, fill) {
204
+ const bounds = [
205
+ 0,
206
+ ...values.map((v) => toPercent(v, scale)),
207
+ 100
208
+ ];
209
+ const n = values.length;
210
+ const pieces = [];
211
+ for (let k = 0; k < bounds.length - 1; k++) {
212
+ let filled = false;
213
+ if (fill === "start") filled = k === 0;
214
+ else if (fill === "end") filled = k === n;
215
+ else if (fill === "auto") filled = n === 1 ? k === 0 : k >= 1 && k <= n - 1;
216
+ pieces.push({
217
+ from: bounds[k],
218
+ to: bounds[k + 1],
219
+ cutStart: k > 0,
220
+ cutEnd: k < n,
221
+ filled
222
+ });
223
+ }
224
+ return pieces;
225
+ }
226
+ /** The marks to draw. `true` = one per stop, or per step (only the two ends past ~26 — denser is a texture, not ticks). */
227
+ function markPoints(marks, scale) {
228
+ if (marks === false || marks === null || marks === void 0 || marks === "" || marks === "false") return [];
229
+ let list = marks;
230
+ if (typeof marks === "string") {
231
+ const text = marks.trim();
232
+ if (text === "true") list = true;
233
+ else try {
234
+ list = JSON.parse(text);
235
+ } catch {
236
+ list = coerceNumbers(text) ?? [];
237
+ }
238
+ }
239
+ if (list === true) return (scale.stops ?? autoGrid(scale)).map((value) => ({
240
+ value,
241
+ pct: toPercent(value, scale),
242
+ labelled: false
243
+ }));
244
+ if (!Array.isArray(list)) return [];
245
+ const out = [];
246
+ for (const item of list) if (typeof item === "number" || typeof item === "string") {
247
+ const value = toNumber(item);
248
+ if (value !== void 0 && value >= scale.min && value <= scale.max) out.push({
249
+ value,
250
+ pct: toPercent(value, scale),
251
+ labelled: false
252
+ });
253
+ } else if (item && typeof item === "object") {
254
+ const value = toNumber(item.value);
255
+ if (value !== void 0 && value >= scale.min && value <= scale.max) {
256
+ const label = item.label;
257
+ out.push({
258
+ value,
259
+ pct: toPercent(value, scale),
260
+ label: label == null ? void 0 : String(label),
261
+ labelled: true
262
+ });
263
+ }
264
+ }
265
+ return out.sort((a, b) => a.value - b.value);
266
+ }
267
+ function autoGrid(scale) {
268
+ if (!scale.step) return [scale.min, scale.max];
269
+ const count = Math.floor(stripNoise((scale.max - scale.min) / scale.step)) + 1;
270
+ if (count > MAX_AUTO_MARKS) return [scale.min, scale.max];
271
+ return Array.from({ length: count }, (_, i) => stripNoise(scale.min + i * scale.step));
272
+ }
273
+ /**
274
+ * One keyboard step from `v`: `dir` ±1, `big` for PageUp/PageDown. With stops it walks the list
275
+ * (big = a tenth of it, at least one); with a grid it moves a step (big = ten); continuous moves
276
+ * 1% (big = 10%).
277
+ */
278
+ function stepFrom(v, dir, big, scale) {
279
+ if (scale.stops) {
280
+ const stops = scale.stops;
281
+ let idx = stops.findIndex((s) => Math.abs(s - v) < 1e-9);
282
+ if (idx < 0) idx = stops.findIndex((s) => s > v) - (dir > 0 ? 1 : 0);
283
+ const jump = big ? Math.max(1, Math.round(stops.length / 10)) : 1;
284
+ return stops[clamp(idx + dir * jump, 0, stops.length - 1)];
285
+ }
286
+ return stripNoise(v + dir * (scale.step || (scale.max - scale.min) / 100) * (big ? 10 : 1));
287
+ }
288
+
289
+ //#endregion
290
+ //#region src/components/slider/slider-core.ts
291
+ /** Pixels a press must travel before a press between two thumbs becomes a segment drag. */
292
+ const SEGMENT_DRAG_THRESHOLD = 3;
293
+ /**
294
+ * `true` unless the attribute says `"false"` — for props that are ON by default (`show-value`),
295
+ * where an ABSENT attribute must not read as off.
296
+ */
297
+ const defaultOnConverter = { fromAttribute: (v) => v === null ? true : booleanStringConverter.fromAttribute(v) };
298
+ /** A model that holds the same numbers in the same shape is not a change (Vue re-sends arrays). */
299
+ function sliderValueHasChanged(value, old) {
300
+ if (value === old) return false;
301
+ const a = coerceNumbers(value);
302
+ const b = coerceNumbers(old);
303
+ if (!a || !b) return a !== b;
304
+ if (Array.isArray(value) !== Array.isArray(old)) return true;
305
+ return a.length !== b.length || a.some((n, i) => n !== b[i]);
306
+ }
307
+ /**
308
+ * `MonoSliderCore` — everything `mono-slider` does that does not depend on light vs shadow DOM:
309
+ * props + hybrid aliases, the value maths (slider-math.ts), pointer + keyboard interaction,
310
+ * events, form binding, and the shared `render()`. The label / message regions are hooks the
311
+ * shadow build overrides with native `<slot>`s (the light build captures `slot="label|helper"`
312
+ * children and drops them into `[data-mono-slot]` placeholders, like mono-input).
313
+ *
314
+ * Thumbs are `role="slider"` elements, not native range inputs: N thumbs on one track, blocking,
315
+ * stops, gaps and segment drags are all beyond `<input type="range">`.
316
+ */
317
+ const MonoSliderCore = (superClass) => {
318
+ class MonoSliderCoreClass extends MonoFormControlCore(superClass) {
319
+ constructor(...args) {
320
+ super(...args);
321
+ this.modelValue = 0;
322
+ this.min = 0;
323
+ this.max = 100;
324
+ this.step = 1;
325
+ this.minGap = 0;
326
+ this.type = "horizontal";
327
+ this.marks = false;
328
+ this.fill = "auto";
329
+ this.trackGap = 0;
330
+ this.valueTooltip = "auto";
331
+ this.showValue = true;
332
+ this.valueSeparator = " – ";
333
+ this.size = "md";
334
+ this.color = "primary";
335
+ this.label = "";
336
+ this.helperText = "";
337
+ this.tooltip = null;
338
+ this._tooltip = new FieldTooltipController(this, () => this.tooltip);
339
+ this.validationState = "default";
340
+ this.validationMessage = "";
341
+ this.error = false;
342
+ this.errorMessage = "";
343
+ this.success = false;
344
+ this.successMessage = "";
345
+ this.disabled = false;
346
+ this.readonly = false;
347
+ this.required = false;
348
+ this.name = "";
349
+ this.cssClass = {};
350
+ this.cssClassName = "";
351
+ this._values = [0];
352
+ this._active = 0;
353
+ this._dragging = -1;
354
+ this._hasLabelSlotState = false;
355
+ this._hasHelperSlotState = false;
356
+ this._scale = resolveScale({});
357
+ this._sliderId = `mono-slider-${Math.random().toString(36).slice(2)}`;
358
+ this._messageId = `${this._sliderId}-message`;
359
+ this._gesture = null;
360
+ defineHybridPropAliases(this, [
361
+ "modelValue",
362
+ "minGap",
363
+ "trackGap",
364
+ "valueTooltip",
365
+ "showValue",
366
+ "valueSeparator",
367
+ "formatDisplay",
368
+ "formatLocale",
369
+ "helperText",
370
+ "validationState",
371
+ "validationMessage",
372
+ "errorMessage",
373
+ "successMessage",
374
+ "ariaLabelText",
375
+ "cssClass"
376
+ ]);
377
+ defineHybridPropAlias(this, "value", "modelValue");
378
+ for (const alias of [
379
+ "ariaLabel",
380
+ "aria-label",
381
+ "arialabel"
382
+ ]) Object.defineProperty(this, alias, {
383
+ get: () => this.ariaLabelText,
384
+ set: (v) => {
385
+ this.ariaLabelText = v == null ? void 0 : String(v);
386
+ },
387
+ configurable: true,
388
+ enumerable: false
389
+ });
390
+ }
391
+ static get observedAttributes() {
392
+ return [
393
+ ...super.observedAttributes ?? [],
394
+ "value",
395
+ "modelvalue",
396
+ "mingap",
397
+ "trackgap",
398
+ "valuetooltip",
399
+ "showvalue",
400
+ "valueseparator",
401
+ "formatdisplay",
402
+ "format-display",
403
+ "formatlocale",
404
+ "helpertext",
405
+ "validationstate",
406
+ "validationmessage",
407
+ "errormessage",
408
+ "successmessage",
409
+ "arialabel",
410
+ "arialabeltext",
411
+ "css-class",
412
+ "cssclass"
413
+ ];
414
+ }
415
+ attributeChangedCallback(name, oldValue, newValue) {
416
+ super.attributeChangedCallback(name, oldValue, newValue);
417
+ if (oldValue === newValue) return;
418
+ switch (name) {
419
+ case "value":
420
+ case "modelvalue":
421
+ this.modelValue = newValue ?? "";
422
+ return;
423
+ case "mingap":
424
+ this.minGap = newValue ?? 0;
425
+ return;
426
+ case "trackgap":
427
+ this.trackGap = newValue ?? 0;
428
+ return;
429
+ case "valuetooltip":
430
+ this.valueTooltip = newValue ?? "auto";
431
+ return;
432
+ case "showvalue":
433
+ this.showValue = defaultOnConverter.fromAttribute(newValue);
434
+ return;
435
+ case "valueseparator":
436
+ this.valueSeparator = newValue ?? " – ";
437
+ return;
438
+ case "formatdisplay":
439
+ case "format-display":
440
+ if (typeof this.formatDisplay === "function") return;
441
+ if (newValue && /^(?:async\s+)?(?:function|\([^)]*\)\s*=>|[A-Za-z_$][\w$]*\s*=>)/.test(newValue.trim())) return;
442
+ this.formatDisplay = newValue ?? void 0;
443
+ return;
444
+ case "formatlocale":
445
+ this.formatLocale = newValue ?? void 0;
446
+ return;
447
+ case "helpertext":
448
+ this.helperText = newValue ?? "";
449
+ return;
450
+ case "validationstate":
451
+ this.validationState = newValue ?? "default";
452
+ return;
453
+ case "validationmessage":
454
+ this.validationMessage = newValue ?? "";
455
+ return;
456
+ case "errormessage":
457
+ this.errorMessage = newValue ?? "";
458
+ return;
459
+ case "successmessage":
460
+ this.successMessage = newValue ?? "";
461
+ return;
462
+ case "arialabel":
463
+ case "arialabeltext":
464
+ this.ariaLabelText = newValue ?? void 0;
465
+ return;
466
+ case "css-class":
467
+ case "cssclass":
468
+ this.cssClassName = newValue ?? "";
469
+ return;
470
+ }
471
+ }
472
+ /** The thumb positions, always as a sorted array. */
473
+ get values() {
474
+ return this._values.slice();
475
+ }
476
+ willUpdate(changed) {
477
+ const scaleKeys = [
478
+ "min",
479
+ "max",
480
+ "step",
481
+ "stops",
482
+ "minGap"
483
+ ];
484
+ if (scaleKeys.some((k) => changed.has(k))) this._scale = resolveScale({
485
+ min: this.min,
486
+ max: this.max,
487
+ step: this.step,
488
+ stops: this.stops,
489
+ minGap: this.minGap
490
+ });
491
+ if (changed.has("modelValue") || scaleKeys.some((k) => changed.has(k))) {
492
+ const raw = coerceNumbers(this.modelValue) ?? [this._scale.min];
493
+ const next = normalise(raw, this._scale);
494
+ if (next.length !== this._values.length || next.some((n, i) => n !== this._values[i])) {
495
+ this._values = next;
496
+ if (this._active >= next.length) this._active = next.length - 1;
497
+ }
498
+ }
499
+ super.willUpdate?.(changed);
500
+ }
501
+ /** True when the model is (or was handed over as) a list — the shape we hand back. */
502
+ get _isArrayModel() {
503
+ const v = this.modelValue;
504
+ return Array.isArray(v) || typeof v === "string" && (v.trim().startsWith("[") || v.includes(","));
505
+ }
506
+ _out(values) {
507
+ return this._isArrayModel || values.length > 1 ? values.slice() : values[0];
508
+ }
509
+ /** A value as text, through `format-display` (pattern or function), padded like a commit. */
510
+ _format(v) {
511
+ const raw = String(stripNoise(v));
512
+ const fmt = this.formatDisplay;
513
+ if (!fmt) return raw;
514
+ if (typeof fmt === "function") return String(fmt({
515
+ value: raw,
516
+ type: "slider",
517
+ locale: this.formatLocale
518
+ }) ?? "");
519
+ const descriptor = parseFormat(fmt);
520
+ return descriptor ? applyFormat(raw, descriptor, this.formatLocale, { pad: true }) : raw;
521
+ }
522
+ get _readoutText() {
523
+ return this._values.map((v) => this._format(v)).join(this.valueSeparator);
524
+ }
525
+ get _vertical() {
526
+ return this.type === "vertical";
527
+ }
528
+ get _trackEl() {
529
+ return this.renderRoot.querySelector("[mono-slider-track]");
530
+ }
531
+ _thumbEl(i) {
532
+ return this.renderRoot.querySelector(`[mono-slider-thumb][data-index="${i}"]`);
533
+ }
534
+ /** True when the slider is laid out right-to-left (horizontal only flips). */
535
+ _isRtl() {
536
+ if (this._vertical || typeof getComputedStyle === "undefined") return false;
537
+ return getComputedStyle(this).direction === "rtl";
538
+ }
539
+ /**
540
+ * The unsnapped value under a pointer. A thumb's CENTRE travels from half a thumb in to half a
541
+ * thumb short of the end (where a native range thumb sits), so the usable length is the track
542
+ * minus one thumb.
543
+ */
544
+ _rawAt(event) {
545
+ const rect = this._trackEl?.getBoundingClientRect();
546
+ if (!rect) return this._scale.min;
547
+ const thumb = this._thumbEl(0);
548
+ let ratio;
549
+ if (this._vertical) {
550
+ const along = thumb?.offsetHeight ?? 0;
551
+ const usable = rect.height - along;
552
+ ratio = usable > 0 ? (rect.bottom - along / 2 - event.clientY) / usable : 0;
553
+ } else {
554
+ const along = thumb?.offsetWidth ?? 0;
555
+ const usable = rect.width - along;
556
+ ratio = usable > 0 ? (event.clientX - rect.left - along / 2) / usable : 0;
557
+ if (this._isRtl()) ratio = 1 - ratio;
558
+ }
559
+ return fromRatio(ratio, this._scale);
560
+ }
561
+ /**
562
+ * Take `next` as the new value and announce it. `next === this._values` (identity — the maths
563
+ * returns the same array when nothing moved) is a no-op for `input`.
564
+ */
565
+ _commit(next, index, kind, sourceEvent, oldValues) {
566
+ if (kind === "input" && next === this._values) return;
567
+ const old = oldValues ?? this._values;
568
+ this._values = next;
569
+ const out = this._out(next);
570
+ const oldOut = this._out(old);
571
+ this.modelValue = out;
572
+ const detail = {
573
+ modelValue: out,
574
+ currentValue: out,
575
+ oldValue: oldOut,
576
+ value: out,
577
+ values: next.slice(),
578
+ index,
579
+ name: this.name || void 0,
580
+ sourceEvent
581
+ };
582
+ dispatchMonoEvent(this, kind, detail);
583
+ }
584
+ get _interactive() {
585
+ return !this.disabled && !this.readonly;
586
+ }
587
+ _onPointerDown(event) {
588
+ if (event.button !== 0 || this.disabled) return;
589
+ const control = event.currentTarget;
590
+ const thumb = event.composedPath().find((n) => n instanceof Element && n.hasAttribute?.("mono-slider-thumb"));
591
+ if (this.readonly) {
592
+ if (thumb) thumb.focus({ preventScroll: true });
593
+ return;
594
+ }
595
+ event.preventDefault();
596
+ const raw = this._rawAt(event);
597
+ const values = this._values;
598
+ let index = thumb ? Number(thumb.dataset.index) : nearestThumb(values, raw);
599
+ let mode = "thumb";
600
+ let stack;
601
+ let run;
602
+ if (thumb && isStacked(values, index)) {
603
+ let first = index;
604
+ let last = index;
605
+ while (first > 0 && values[first - 1] === values[index]) first--;
606
+ while (last < values.length - 1 && values[last + 1] === values[index]) last++;
607
+ stack = [first, last];
608
+ mode = "stack";
609
+ } else if (!thumb && values.length > 1) {
610
+ const k = values.findIndex((v) => v > raw);
611
+ if (k > 0) {
612
+ if (trackPieces(values, this._scale, this.fill)[k]?.filled) {
613
+ run = [k - 1, k];
614
+ mode = "segment-pending";
615
+ }
616
+ }
617
+ }
618
+ this._gesture = {
619
+ pointerId: event.pointerId,
620
+ mode,
621
+ index,
622
+ run,
623
+ stack,
624
+ startX: event.clientX,
625
+ startY: event.clientY,
626
+ startRaw: raw,
627
+ startValues: values
628
+ };
629
+ control.setPointerCapture?.(event.pointerId);
630
+ if (mode === "thumb") {
631
+ this._active = index;
632
+ this._dragging = index;
633
+ this._focusThumb(index);
634
+ if (!thumb) this._commit(moveThumb(values, index, raw, this._scale), index, "input", event);
635
+ }
636
+ }
637
+ _onPointerMove(event) {
638
+ const g = this._gesture;
639
+ if (!g || g.pointerId !== event.pointerId) return;
640
+ const raw = this._rawAt(event);
641
+ if (g.mode === "stack" && g.stack) {
642
+ if (raw === g.startRaw) return;
643
+ g.index = raw > g.startRaw ? g.stack[1] : g.stack[0];
644
+ g.mode = "thumb";
645
+ this._active = g.index;
646
+ this._dragging = g.index;
647
+ this._focusThumb(g.index);
648
+ }
649
+ if (g.mode === "segment-pending") {
650
+ if (Math.hypot(event.clientX - g.startX, event.clientY - g.startY) < SEGMENT_DRAG_THRESHOLD) return;
651
+ g.mode = "segment";
652
+ this._dragging = g.run[0];
653
+ }
654
+ if (g.mode === "segment" && g.run) {
655
+ const next = moveRun(g.startValues, g.run[0], g.run[1], raw - g.startRaw, this._scale);
656
+ if (!(next.length === this._values.length && next.every((n, i) => n === this._values[i]))) this._commit(next, -1, "input", event);
657
+ return;
658
+ }
659
+ if (g.mode === "thumb") this._commit(moveThumb(this._values, g.index, raw, this._scale), g.index, "input", event);
660
+ }
661
+ _onPointerUp(event) {
662
+ const g = this._gesture;
663
+ if (!g || g.pointerId !== event.pointerId) return;
664
+ this._gesture = null;
665
+ event.currentTarget.releasePointerCapture?.(event.pointerId);
666
+ if (g.mode === "segment-pending") {
667
+ const raw = this._rawAt(event);
668
+ const index = nearestThumb(this._values, raw);
669
+ this._active = index;
670
+ this._focusThumb(index);
671
+ this._commit(moveThumb(this._values, index, raw, this._scale), index, "input", event);
672
+ }
673
+ this._dragging = -1;
674
+ if (g.startValues.length !== this._values.length || g.startValues.some((n, i) => n !== this._values[i])) this._commit(this._values, g.mode === "segment" ? -1 : g.index, "change", event, g.startValues);
675
+ }
676
+ _onPointerCancel(event) {
677
+ const g = this._gesture;
678
+ if (!g || g.pointerId !== event.pointerId) return;
679
+ this._onPointerUp(event);
680
+ }
681
+ _focusThumb(i) {
682
+ this.updateComplete.then(() => this._thumbEl(i)?.focus({ preventScroll: true }));
683
+ }
684
+ _onThumbKeydown(event) {
685
+ if (!this._interactive) return;
686
+ let i = Number(event.currentTarget.dataset.index);
687
+ const values = this._values;
688
+ const rtl = this._isRtl();
689
+ let dir = 0;
690
+ let big = false;
691
+ let edge = null;
692
+ switch (event.key) {
693
+ case "ArrowUp":
694
+ dir = 1;
695
+ break;
696
+ case "ArrowDown":
697
+ dir = -1;
698
+ break;
699
+ case "ArrowRight":
700
+ dir = rtl ? -1 : 1;
701
+ break;
702
+ case "ArrowLeft":
703
+ dir = rtl ? 1 : -1;
704
+ break;
705
+ case "PageUp":
706
+ dir = 1;
707
+ big = true;
708
+ break;
709
+ case "PageDown":
710
+ dir = -1;
711
+ big = true;
712
+ break;
713
+ case "Home":
714
+ edge = "lo";
715
+ break;
716
+ case "End":
717
+ edge = "hi";
718
+ break;
719
+ default: return;
720
+ }
721
+ event.preventDefault();
722
+ if (dir && isStacked(values, i)) {
723
+ let j = i;
724
+ if (dir > 0) while (j < values.length - 1 && values[j + 1] === values[i]) j++;
725
+ else while (j > 0 && values[j - 1] === values[i]) j--;
726
+ if (j !== i) {
727
+ i = j;
728
+ this._focusThumb(i);
729
+ }
730
+ }
731
+ const { lo, hi } = thumbBounds(values, i, this._scale);
732
+ const target = edge === "lo" ? lo : edge === "hi" ? hi : stepFrom(values[i], dir, big, this._scale);
733
+ const next = moveThumb(values, i, target, this._scale);
734
+ this._active = i;
735
+ if (next === values) return;
736
+ this._commit(next, i, "input", event);
737
+ this._commit(next, i, "change", event, values);
738
+ }
739
+ get _resolvedValidationState() {
740
+ if (this.validationState && this.validationState !== "default") return this.validationState;
741
+ if (this.error || this.errorMessage) return "invalid";
742
+ if (this.success || this.successMessage) return "valid";
743
+ return "default";
744
+ }
745
+ _cls(base, key) {
746
+ return cssPart(this.cssClass, base, key);
747
+ }
748
+ get _hasLabel() {
749
+ return !!(this.label || this._hasLabelSlotState);
750
+ }
751
+ get _describedBy() {
752
+ return this.validationMessage || this.errorMessage || this.successMessage || this.helperText || this._hasHelperSlotState ? this._messageId : void 0;
753
+ }
754
+ _thumbLabel(i) {
755
+ const base = this.ariaLabelText || this.label || void 0;
756
+ const n = this._values.length;
757
+ if (n === 1) return base;
758
+ const which = n === 2 ? i === 0 ? "minimum" : "maximum" : `${i + 1} of ${n}`;
759
+ return base ? `${base} (${which})` : which;
760
+ }
761
+ focus(options) {
762
+ this._thumbEl(this._active)?.focus(options);
763
+ }
764
+ blur() {
765
+ this._thumbEl(this._active)?.blur();
766
+ }
767
+ /** Label text region — light: placeholder for the captured slot; shadow overrides with `<slot>`. */
768
+ _renderLabelText() {
769
+ return this._hasLabelSlotState ? html`<span data-mono-slot="label"></span>` : this.label;
770
+ }
771
+ _renderReadout() {
772
+ return html`<span class=${this._cls("mono-slider-value", "value")} mono-slider-value aria-hidden="true">${this._readoutText}</span>`;
773
+ }
774
+ /** The label row: text, required mark, ⓘ, and the value at its end. */
775
+ _renderLabel() {
776
+ if (!this._hasLabel) return nothing;
777
+ return html`
778
+ <div mono-label-row>
779
+ <label class=${this._cls("mono-slider-label", "label")} mono-label id=${`${this._sliderId}-label`}>
780
+ ${this._renderLabelText()}
781
+ ${this.required ? html`<span class=${this._cls("mono-slider-required", "required")} mono-required-mark>*</span>` : nothing}
782
+ ${this._tooltip.render()}
783
+ </label>
784
+ ${this.showValue ? this._renderReadout() : nothing}
785
+ </div>
786
+ `;
787
+ }
788
+ _renderMessage() {
789
+ const base = this._cls("mono-slider-message", "message");
790
+ if (this.validationMessage) {
791
+ const s = this._resolvedValidationState;
792
+ return html`<div class=${`${base} ${s}`} mono-message=${s} role=${s === "invalid" ? "alert" : nothing}>${this.validationMessage}</div>`;
793
+ }
794
+ if (this.errorMessage) return html`<div class=${`${base} invalid`} mono-message="invalid" role="alert">${this.errorMessage}</div>`;
795
+ if (this.successMessage) return html`<div class=${`${base} valid`} mono-message="valid">${this.successMessage}</div>`;
796
+ if (this.helperText || this._hasHelperSlotState) return html`<div class=${`${base} helper`} mono-message="helper">${this._hasHelperSlotState ? html`<span data-mono-slot="helper"></span>` : this.helperText}</div>`;
797
+ return nothing;
798
+ }
799
+ _renderPieces(pieces) {
800
+ return html`${pieces.map((p, k) => html`<span
801
+ class=${this._cls("mono-slider-fill", "fill")}
802
+ mono-slider-piece
803
+ ?mono-filled=${p.filled}
804
+ ?mono-cut-start=${p.cutStart}
805
+ ?mono-cut-end=${p.cutEnd}
806
+ data-k=${k}
807
+ style=${`--a: ${p.from / 100}; --b: ${p.to / 100}`}
808
+ ></span>`)}`;
809
+ }
810
+ _renderMarks(marks, pieces) {
811
+ if (!marks.length) return nothing;
812
+ const filled = pieces.filter((p) => p.filled);
813
+ const active = (pct) => filled.some((p) => pct >= p.from - 1e-9 && pct <= p.to + 1e-9);
814
+ const labelled = Array.isArray(this.marks) || typeof this.marks === "string" && this.marks.trim().startsWith("[");
815
+ return html`
816
+ <div class=${this._cls("mono-slider-marks", "marks")} mono-slider-marks aria-hidden="true">
817
+ ${marks.map((m) => html`<span
818
+ class=${this._cls("mono-slider-mark", "mark")}
819
+ mono-slider-mark
820
+ ?mono-active=${active(m.pct)}
821
+ style=${`--p: ${m.pct / 100}`}
822
+ >${labelled ? html`<span class=${this._cls("mono-slider-mark-label", "markLabel")} mono-slider-mark-label>${m.label ?? this._format(m.value)}</span>` : nothing}</span>`)}
823
+ </div>
824
+ `;
825
+ }
826
+ _renderThumb(v, i) {
827
+ const { lo, hi } = thumbBounds(this._values, i, this._scale);
828
+ const text = this._format(v);
829
+ const raw = String(stripNoise(v));
830
+ return html`<div
831
+ class=${this._cls("mono-slider-thumb", "thumb")}
832
+ mono-slider-thumb
833
+ role="slider"
834
+ data-index=${i}
835
+ tabindex=${this.disabled ? -1 : 0}
836
+ style=${`--p: ${toPercent(v, this._scale) / 100}`}
837
+ ?mono-active=${i === this._active}
838
+ ?mono-dragging=${i === this._dragging}
839
+ aria-valuemin=${lo}
840
+ aria-valuemax=${hi}
841
+ aria-valuenow=${raw}
842
+ aria-valuetext=${ifDefined(text !== raw ? text : void 0)}
843
+ aria-orientation=${this._vertical ? "vertical" : "horizontal"}
844
+ aria-label=${ifDefined(this._thumbLabel(i))}
845
+ aria-labelledby=${ifDefined(!this.ariaLabelText && this._hasLabel && this._values.length === 1 ? `${this._sliderId}-label` : void 0)}
846
+ aria-disabled=${ifDefined(this.disabled ? "true" : void 0)}
847
+ aria-readonly=${ifDefined(this.readonly ? "true" : void 0)}
848
+ aria-required=${ifDefined(this.required ? "true" : void 0)}
849
+ aria-invalid=${ifDefined(this._resolvedValidationState === "invalid" ? "true" : void 0)}
850
+ aria-describedby=${ifDefined(this._describedBy)}
851
+ @keydown=${this._onThumbKeydown}
852
+ @focus=${() => {
853
+ this._active = i;
854
+ }}
855
+ >${this.valueTooltip === "never" ? nothing : html`<span class=${this._cls("mono-slider-tooltip", "tooltip")} mono-slider-tooltip aria-hidden="true">${text}</span>`}</div>`;
856
+ }
857
+ _renderHidden() {
858
+ if (!this.name) return nothing;
859
+ const name = (this._values.length > 1 || this._isArrayModel) && !this.name.endsWith("[]") ? `${this.name}[]` : this.name;
860
+ return html`${this._values.map((v) => html`<input type="hidden" mono-slider-hidden name=${name} .value=${String(v)} ?disabled=${this.disabled} />`)}`;
861
+ }
862
+ render() {
863
+ const pieces = trackPieces(this._values, this._scale, this.fill);
864
+ const marks = markPoints(this.marks === "" ? true : this.marks, this._scale);
865
+ const state = this._resolvedValidationState;
866
+ const gap = Number(this.trackGap) || 0;
867
+ const labelledMarks = marks.length > 0 && (Array.isArray(this.marks) || typeof this.marks === "string" && this.marks.trim().startsWith("["));
868
+ const style = {};
869
+ const width = toCssSize(this.width);
870
+ if (width) style.width = width;
871
+ const length = toCssSize(this.height);
872
+ if (length) style["--_mono-slider-length"] = length;
873
+ if (gap > 0) style["--_mono-slider-track-gap"] = `${gap}px`;
874
+ return html`<div
875
+ class=${[
876
+ "mono-slider",
877
+ this.size,
878
+ this.color,
879
+ this._vertical ? "vertical" : "",
880
+ this.disabled ? "disabled" : "",
881
+ this.cssClassName,
882
+ this.cssClass?.root
883
+ ].filter(Boolean).join(" ")}
884
+ style=${styleMap(style)}
885
+ mono-slider
886
+ mono-size=${this.size === "md" ? nothing : this.size}
887
+ mono-color=${this.color === "primary" ? nothing : this.color}
888
+ mono-type=${this._vertical ? "vertical" : nothing}
889
+ mono-validation-state=${state === "default" ? nothing : state}
890
+ mono-value-tooltip=${this.valueTooltip === "auto" ? nothing : this.valueTooltip}
891
+ ?mono-track-gap=${gap > 0}
892
+ ?mono-marks-labelled=${labelledMarks}
893
+ ?mono-disabled=${this.disabled}
894
+ ?mono-readonly=${this.readonly}
895
+ ?mono-required=${this.required}
896
+ ?mono-dragging=${this._dragging >= 0}
897
+ >
898
+ ${this._renderLabel()}
899
+ <div mono-slider-field>
900
+ <div
901
+ class=${this._cls("mono-slider-control", "control")}
902
+ mono-slider-control
903
+ @pointerdown=${this._onPointerDown}
904
+ @pointermove=${this._onPointerMove}
905
+ @pointerup=${this._onPointerUp}
906
+ @pointercancel=${this._onPointerCancel}
907
+ >
908
+ <div class=${this._cls("mono-slider-track", "track")} mono-slider-track>${this._renderPieces(pieces)}</div>
909
+ ${this._renderMarks(marks, pieces)}
910
+ ${this._values.map((v, i) => this._renderThumb(v, i))}
911
+ </div>
912
+ ${!this._hasLabel && this.showValue ? this._renderReadout() : nothing}
913
+ </div>
914
+ ${this._renderHidden()}
915
+ <div id=${this._messageId} class=${this.cssClass?.messageWrap ?? ""} mono-message-wrap>${this._renderMessage()}</div>
916
+ </div>`;
917
+ }
918
+ }
919
+ __decorate([property({
920
+ attribute: "model-value",
921
+ hasChanged: sliderValueHasChanged
922
+ })], MonoSliderCoreClass.prototype, "modelValue", void 0);
923
+ __decorate([property()], MonoSliderCoreClass.prototype, "min", void 0);
924
+ __decorate([property()], MonoSliderCoreClass.prototype, "max", void 0);
925
+ __decorate([property()], MonoSliderCoreClass.prototype, "step", void 0);
926
+ __decorate([property({ hasChanged: sliderValueHasChanged })], MonoSliderCoreClass.prototype, "stops", void 0);
927
+ __decorate([property({ attribute: "min-gap" })], MonoSliderCoreClass.prototype, "minGap", void 0);
928
+ __decorate([property({ type: String })], MonoSliderCoreClass.prototype, "type", void 0);
929
+ __decorate([property()], MonoSliderCoreClass.prototype, "marks", void 0);
930
+ __decorate([property({ type: String })], MonoSliderCoreClass.prototype, "fill", void 0);
931
+ __decorate([property({ attribute: "track-gap" })], MonoSliderCoreClass.prototype, "trackGap", void 0);
932
+ __decorate([property({
933
+ type: String,
934
+ attribute: "value-tooltip"
935
+ })], MonoSliderCoreClass.prototype, "valueTooltip", void 0);
936
+ __decorate([property({
937
+ attribute: "show-value",
938
+ converter: defaultOnConverter
939
+ })], MonoSliderCoreClass.prototype, "showValue", void 0);
940
+ __decorate([property({
941
+ type: String,
942
+ attribute: "value-separator"
943
+ })], MonoSliderCoreClass.prototype, "valueSeparator", void 0);
944
+ __decorate([property({ attribute: false })], MonoSliderCoreClass.prototype, "formatDisplay", void 0);
945
+ __decorate([property({
946
+ type: String,
947
+ attribute: "format-locale"
948
+ })], MonoSliderCoreClass.prototype, "formatLocale", void 0);
949
+ __decorate([property({ type: String })], MonoSliderCoreClass.prototype, "size", void 0);
950
+ __decorate([property({ type: String })], MonoSliderCoreClass.prototype, "color", void 0);
951
+ __decorate([property({ type: String })], MonoSliderCoreClass.prototype, "label", void 0);
952
+ __decorate([property({
953
+ type: String,
954
+ attribute: "helper-text"
955
+ })], MonoSliderCoreClass.prototype, "helperText", void 0);
956
+ __decorate([property()], MonoSliderCoreClass.prototype, "tooltip", void 0);
957
+ __decorate([property({
958
+ type: String,
959
+ attribute: "validation-state"
960
+ })], MonoSliderCoreClass.prototype, "validationState", void 0);
961
+ __decorate([property({
962
+ type: String,
963
+ attribute: "validation-message"
964
+ })], MonoSliderCoreClass.prototype, "validationMessage", void 0);
965
+ __decorate([property({
966
+ reflect: true,
967
+ converter: booleanStringConverter
968
+ })], MonoSliderCoreClass.prototype, "error", void 0);
969
+ __decorate([property({
970
+ type: String,
971
+ attribute: "error-message"
972
+ })], MonoSliderCoreClass.prototype, "errorMessage", void 0);
973
+ __decorate([property({
974
+ reflect: true,
975
+ converter: booleanStringConverter
976
+ })], MonoSliderCoreClass.prototype, "success", void 0);
977
+ __decorate([property({
978
+ type: String,
979
+ attribute: "success-message"
980
+ })], MonoSliderCoreClass.prototype, "successMessage", void 0);
981
+ __decorate([property({
982
+ reflect: true,
983
+ converter: booleanStringConverter
984
+ })], MonoSliderCoreClass.prototype, "disabled", void 0);
985
+ __decorate([property({
986
+ reflect: true,
987
+ converter: booleanStringConverter
988
+ })], MonoSliderCoreClass.prototype, "readonly", void 0);
989
+ __decorate([property({
990
+ reflect: true,
991
+ converter: booleanStringConverter
992
+ })], MonoSliderCoreClass.prototype, "required", void 0);
993
+ __decorate([property({ type: String })], MonoSliderCoreClass.prototype, "name", void 0);
994
+ __decorate([property({
995
+ type: String,
996
+ attribute: "aria-label"
997
+ })], MonoSliderCoreClass.prototype, "ariaLabelText", void 0);
998
+ __decorate([property({ type: String })], MonoSliderCoreClass.prototype, "width", void 0);
999
+ __decorate([property({ type: String })], MonoSliderCoreClass.prototype, "height", void 0);
1000
+ __decorate([property({ attribute: false })], MonoSliderCoreClass.prototype, "cssClass", void 0);
1001
+ __decorate([property({
1002
+ type: String,
1003
+ attribute: "css-class"
1004
+ })], MonoSliderCoreClass.prototype, "cssClassName", void 0);
1005
+ __decorate([state()], MonoSliderCoreClass.prototype, "_values", void 0);
1006
+ __decorate([state()], MonoSliderCoreClass.prototype, "_active", void 0);
1007
+ __decorate([state()], MonoSliderCoreClass.prototype, "_dragging", void 0);
1008
+ __decorate([state()], MonoSliderCoreClass.prototype, "_hasLabelSlotState", void 0);
1009
+ __decorate([state()], MonoSliderCoreClass.prototype, "_hasHelperSlotState", void 0);
1010
+ return MonoSliderCoreClass;
1011
+ };
1012
+
1013
+ //#endregion
1014
+ export { moveRun as a, normalise as c, stepFrom as d, thumbBounds as f, markPoints as i, resolveScale as l, trackPieces as m, coerceNumbers as n, moveThumb as o, toPercent as p, fromRatio as r, nearestThumb as s, MonoSliderCore as t, snap as u };