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