@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
@@ -1,1347 +1,11 @@
1
- import { d as buildSizeStyle, f as toCssSize, g as monoHostChildNodes, y as monoPendingGrace } from "../mono-ui-kvLVIf1V.js";
2
- import { n as detachEventHandlers, t as applyProps } from "../element-props-xvw0EB7H.js";
3
- import { t as monoDataDropdown } from "../mono-data-dropdown-B2iRpJuI.js";
1
+ import { g as monoHostChildNodes } from "../mono-ui-kvLVIf1V.js";
2
+ import { t as monoDataDropdown } from "../mono-data-dropdown-Bgj2PDfm.js";
4
3
  import { t as customElement } from "../mono-element-CKcT0rwv.js";
5
- import { a as defineHybridPropAliases, i as defineHybridPropAlias, o as numberStringConverter, r as booleanStringConverter, s as optionalNumberConverter, t as __decorate } from "../decorate-DbYFpi8R.js";
6
- import { t as dispatchMonoEvent } from "../mono-event-BPku9HpS.js";
4
+ import { t as __decorate } from "../decorate-DbYFpi8R.js";
7
5
  import { i as guardHostTextContent, s as placeSlotNode } from "../light-slots-B5Ck0t_E.js";
8
- import { n as applyPopupPlacement, r as computePopupPlacement, t as PopupPortalController } from "../popup-portal-CINuVjNY.js";
9
- import { a as closeIcon, i as chevronIcon, n as caretIcon } from "../field-icons-t8rXRCKs.js";
10
- import { t as MonoFormControlCore } from "../form-control-core-CRZPZ1ru.js";
11
- import { t as FieldTooltipController } from "../field-tooltip-Csk4s2ve.js";
12
- import { t as FieldValidationController } from "../field-validation-CFmUmuDx.js";
13
- import { n as visibleChipCap, r as ChipStripController, t as resolveChipLimit } from "../chip-limits-CFABydIL.js";
14
- import { LitElement, html, isServer, nothing } from "lit";
15
- import { property } from "lit/decorators.js";
16
- import { ifDefined } from "lit/directives/if-defined.js";
17
- import { styleMap } from "lit/directives/style-map.js";
6
+ import { t as MonoDropdownTableCore } from "../dropdown-table-core-SfHUJVFq.js";
7
+ import { LitElement } from "lit";
18
8
 
19
- //#region src/components/dropdown-table/dropdown-table-core.ts
20
- /** Sentinel so an initial `model-value === our last emit` guard never matches by accident. */
21
- const SYMBOL_INIT = Symbol("init");
22
- /**
23
- * `MonoDropdownTableCore` — the field + popup shell for `<mono-dropdown-table>`. The
24
- * FIELD mirrors `<mono-select>` (same size/color/variant/validation/label props and
25
- * an identical look); the selection/value/display magic lives in the bound
26
- * {@link MonoDropdownController} (`monoDataDropdown`). The consumer's native `<table>`
27
- * + `mono-table-*` are slotted into the body-portaled panel; row clicks delegate to
28
- * `dd.toggleRow`. The panel is sized independently of the field via the `dropdown`
29
- * object (`matchWidth` is intentionally off). Reuses `PopupPortalController`,
30
- * `buildSizeStyle`, and the global `.mono-chip` classes.
31
- */
32
- const MonoDropdownTableCore = (superClass) => {
33
- class MonoDropdownTableCoreClass extends MonoFormControlCore(superClass) {
34
- static {
35
- this.monoPendingAuto = "data";
36
- }
37
- _monoPendingReady() {
38
- const grid = this._dd?.grid;
39
- if (!grid) return monoPendingGrace(this);
40
- if (grid.hasLoaded || grid.error) return true;
41
- return monoPendingGrace(this) && !grid.loading;
42
- }
43
- constructor(...args) {
44
- super(...args);
45
- this.size = "md";
46
- this.color = "primary";
47
- this.variant = "outlined";
48
- this.labelPosition = "top";
49
- this.validationPosition = "bottom";
50
- this.label = "";
51
- this.placeholder = "Select…";
52
- this.helperText = "";
53
- this.tooltip = null;
54
- this._tooltip = new FieldTooltipController(this, () => this.tooltip);
55
- this._validation = new FieldValidationController(this, () => ({
56
- position: this.validationPosition,
57
- ...this._validationNotice ?? {
58
- state: void 0,
59
- text: void 0
60
- },
61
- suppressed: this._isOpen || this._moreOpen
62
- }), () => this.renderRoot?.querySelector?.("[mono-dropdown-table] > [mono-dd-control] > [mono-dd-trigger]"));
63
- this.validationState = "default";
64
- this.validationMessage = "";
65
- this.errorMessage = "";
66
- this.successMessage = "";
67
- this.required = false;
68
- this.disabled = false;
69
- this.readonly = false;
70
- this.clearable = false;
71
- this.multiple = false;
72
- this.maxVisible = 5;
73
- this.chip = {};
74
- this.modelValue = void 0;
75
- this.placement = "bottom-start";
76
- this.flip = true;
77
- this.shift = true;
78
- this.offset = 6;
79
- this.autoFocusSearch = true;
80
- this.stayOpen = false;
81
- this.cssClass = {};
82
- this.cssClassName = "";
83
- this._moreOpen = false;
84
- this._resolvedSide = "bottom";
85
- this._lastEmitted = SYMBOL_INIT;
86
- this._chipStrip = new ChipStripController(this, {
87
- strip: () => this.renderRoot?.querySelector(".mono-dropdown-table-chip-strip"),
88
- enabled: () => this._inlineChips
89
- });
90
- this._popup = new PopupPortalController(this, {
91
- getPanel: () => this.renderRoot.querySelector(".mono-dropdown-table-panel"),
92
- getAnchor: () => this.renderRoot.querySelector(".mono-dropdown-table-trigger"),
93
- getStyleScope: () => this.renderRoot.querySelector(".mono-dropdown-table"),
94
- isOpen: () => this._isOpen,
95
- matchWidth: false,
96
- ...this._placementOpts(),
97
- onSideResolved: (side) => {
98
- this._resolvedSide = side;
99
- this._applySideClass();
100
- }
101
- });
102
- this._morePopup = new PopupPortalController(this, {
103
- getPanel: () => this.renderRoot.querySelector(".mono-dropdown-table-more"),
104
- getAnchor: () => this.renderRoot.querySelector(".mono-dropdown-table-more-chip"),
105
- getStyleScope: () => this.renderRoot.querySelector(".mono-dropdown-table"),
106
- isOpen: () => this._moreOpen,
107
- matchWidth: false,
108
- ...this._morePlacementOpts()
109
- });
110
- this._ddPropsQueued = false;
111
- this._onTriggerKeydown = (e) => {
112
- if (e.key === "Enter" || e.key === " " || e.key === "ArrowDown") {
113
- e.preventDefault();
114
- this.open();
115
- } else if (e.key === "Escape" && this._isOpen) {
116
- e.preventDefault();
117
- this.close();
118
- }
119
- };
120
- this._onDocPointer = (e) => {
121
- if (this.stayOpen) return;
122
- if (!this._isOpen && !this._moreOpen) return;
123
- const path = e.composedPath();
124
- if (path.includes(this)) return;
125
- if (this._popup.containsInPath(path)) return;
126
- if (this._morePopup.containsInPath(path)) return;
127
- this.close();
128
- };
129
- this._onDocKey = (e) => {
130
- if (e.key !== "Escape") return;
131
- if (!this._isOpen && !this._moreOpen) return;
132
- const path = e.composedPath();
133
- if (this._popup.ownsNestedInPath(path) || this._popup.inLayerAbove(path)) return;
134
- this.close();
135
- };
136
- this._onPanelClick = (e) => {
137
- if (this.disabled || this.readonly) return;
138
- const path = e.composedPath();
139
- if (path.some((n) => n?.matches?.("mono-table-checkbox, mono-shadow-table-checkbox, mono-checkbox, mono-shadow-checkbox, .mono-checkbox, input, button, a, select, textarea"))) return;
140
- const row = path.find((n) => n?.matches?.("[data-row-key]"));
141
- if (!row) return;
142
- const key = row.getAttribute("data-row-key");
143
- if (key == null) return;
144
- this._activeRowKey = key;
145
- this._focusZone = "list";
146
- this._dd?.toggleRow(key);
147
- this._reflectSelection();
148
- };
149
- this._onViewportChange = () => {
150
- if (!this._isOpen && !this._moreOpen || this._viewportFrame) return;
151
- this._viewportFrame = requestAnimationFrame(() => {
152
- this._viewportFrame = 0;
153
- if (this._isOpen) this._positionPanel();
154
- if (this._moreOpen) this._positionMorePanel();
155
- });
156
- };
157
- this._viewportBound = false;
158
- this._viewportFrame = 0;
159
- this._docBound = false;
160
- this._wasOpen = false;
161
- this._lastSelectedCount = 0;
162
- this._searchFocused = false;
163
- this._focusZone = "search";
164
- this._activeRowKey = null;
165
- this._panelTabHeld = false;
166
- this._panelTabConsumed = false;
167
- this._onPanelKeydown = (e) => {
168
- if (this.disabled || this.readonly || !this._isOpen) return;
169
- if (e.key === "Tab") {
170
- if (!this._searchEl()) return;
171
- e.preventDefault();
172
- if (!e.repeat) {
173
- this._panelTabHeld = true;
174
- this._panelTabConsumed = false;
175
- }
176
- return;
177
- }
178
- if (this._panelTabHeld && (e.key === "ArrowDown" || e.key === "ArrowUp")) {
179
- e.preventDefault();
180
- this._panelTabConsumed = true;
181
- if (e.key === "ArrowDown") this._enterList();
182
- else this._enterSearch();
183
- return;
184
- }
185
- if (e.key === "ArrowDown" || e.key === "ArrowUp") {
186
- if (this._focusZone !== "list") return;
187
- e.preventDefault();
188
- this._moveActiveRow(e.key === "ArrowDown" ? 1 : -1);
189
- return;
190
- }
191
- if (e.key === "Enter" && this._focusZone === "list") {
192
- e.preventDefault();
193
- this._selectActiveRow();
194
- }
195
- };
196
- this._onPanelKeyup = (e) => {
197
- if (e.key !== "Tab" || !this._panelTabHeld) return;
198
- this._panelTabHeld = false;
199
- if (this._panelTabConsumed) return;
200
- if (this._focusZone === "search") this._enterList();
201
- else this._enterSearch();
202
- };
203
- defineHybridPropAliases(this, [
204
- "labelPosition",
205
- "validationPosition",
206
- "dataDropdown",
207
- "modelValue",
208
- "cssClass",
209
- "autoFocusSearch",
210
- "stayOpen",
211
- "maxVisible",
212
- "minVisible"
213
- ]);
214
- defineHybridPropAlias(this, "controlDataDropdown", "dataDropdown");
215
- for (const alias of ["css-class", "cssclass"]) Object.defineProperty(this, alias, {
216
- get: () => this.cssClass,
217
- set: (value) => this._setCssClass(value),
218
- configurable: true,
219
- enumerable: false
220
- });
221
- }
222
- /** Normalize an object | JSON string | plain-string `css-class` value. */
223
- _setCssClass(value) {
224
- if (value == null) {
225
- this.cssClass = {};
226
- this.cssClassName = "";
227
- return;
228
- }
229
- if (typeof value === "object") {
230
- this.cssClass = value;
231
- return;
232
- }
233
- if (typeof value === "string") {
234
- const trimmed = value.trim();
235
- if (!trimmed) {
236
- this.cssClass = {};
237
- this.cssClassName = "";
238
- return;
239
- }
240
- if (trimmed.startsWith("{") && trimmed.endsWith("}")) try {
241
- this.cssClass = JSON.parse(trimmed);
242
- return;
243
- } catch {}
244
- this.cssClassName = trimmed;
245
- }
246
- }
247
- /** Append the consumer's per-part override to a built-in class. */
248
- _cls(base, key) {
249
- const extra = this.cssClass?.[key];
250
- return extra ? `${base} ${extra}` : base;
251
- }
252
- /**
253
- * `chip` is an object prop, so the real binding is `:chip.prop="{…}"`. This
254
- * covers the two ways a *string* can arrive: a hand-written JSON attribute
255
- * (`chip='{"size":"md"}'`, incl. DSD/SSR), and Vue's `String(value)` mirror
256
- * of a plain `:chip="{…}"` binding — which yields `"[object Object]"` and
257
- * must be ignored, or it would wipe the property set moments later.
258
- */
259
- _setChip(value) {
260
- if (value == null) {
261
- this.chip = {};
262
- return;
263
- }
264
- if (typeof value === "object") {
265
- this.chip = value;
266
- return;
267
- }
268
- if (typeof value !== "string") return;
269
- const trimmed = value.trim();
270
- if (!trimmed) {
271
- this.chip = {};
272
- return;
273
- }
274
- if (!trimmed.startsWith("{") || !trimmed.endsWith("}")) return;
275
- try {
276
- this.chip = JSON.parse(trimmed);
277
- } catch {}
278
- }
279
- static get observedAttributes() {
280
- return [
281
- ...super.observedAttributes ?? [],
282
- "css-class",
283
- "cssclass",
284
- "chip"
285
- ];
286
- }
287
- attributeChangedCallback(name, old, value) {
288
- super.attributeChangedCallback(name, old, value);
289
- if (name === "css-class" || name === "cssclass") this._setCssClass(value);
290
- if (name === "chip") this._setChip(value);
291
- }
292
- /** The validation message and its state — the same precedence the message row uses. */
293
- get _validationNotice() {
294
- if (this.validationMessage) return {
295
- state: this._validationState,
296
- text: this.validationMessage
297
- };
298
- if (this.errorMessage) return {
299
- state: "invalid",
300
- text: this.errorMessage
301
- };
302
- if (this.successMessage) return {
303
- state: "valid",
304
- text: this.successMessage
305
- };
306
- return null;
307
- }
308
- /** Imperatively sync the `is-<side>` class — see `_resolvedSide`. */
309
- _applySideClass() {
310
- const root = this.renderRoot.querySelector(".mono-dropdown-table");
311
- if (!root) return;
312
- root.classList.toggle("is-top", this._resolvedSide === "top");
313
- root.classList.toggle("is-bottom", this._resolvedSide === "bottom");
314
- root.classList.toggle("is-left", this._resolvedSide === "left");
315
- root.classList.toggle("is-right", this._resolvedSide === "right");
316
- if (root.getAttribute("mono-side") !== this._resolvedSide) root.setAttribute("mono-side", this._resolvedSide);
317
- }
318
- /** Shared by the light path (the controller) and the shadow path (`_positionMorePanel`). */
319
- _morePlacementOpts() {
320
- return {
321
- side: () => "bottom",
322
- align: () => "start",
323
- offset: () => 4,
324
- flip: () => true,
325
- shift: () => true,
326
- constrainSize: () => true
327
- };
328
- }
329
- /**
330
- * Placement options shared by the light path (the controller) and the shadow
331
- * path (`_positionPanel`), so both run the identical algorithm.
332
- *
333
- * `constrainSize` is on: a field low in a dense grid can have less room than
334
- * the panel wants on BOTH sides, so flipping alone isn't enough — the panel
335
- * also has to shrink and scroll internally (see dropdown-table.css).
336
- */
337
- _placementOpts() {
338
- return {
339
- side: () => this._sideFromPlacement(this.placement),
340
- align: () => this._alignFromPlacement(this.placement),
341
- offset: () => this.offset,
342
- flip: () => this.flip,
343
- shift: () => this.shift,
344
- constrainSize: () => true
345
- };
346
- }
347
- _sideFromPlacement(p) {
348
- if (p.startsWith("top")) return "top";
349
- if (p.startsWith("left")) return "left";
350
- if (p.startsWith("right")) return "right";
351
- return "bottom";
352
- }
353
- _alignFromPlacement(p) {
354
- if (p.endsWith("-start")) return "start";
355
- if (p.endsWith("-end")) return "end";
356
- return "center";
357
- }
358
- get _dd() {
359
- return this.dataDropdown;
360
- }
361
- get _isOpen() {
362
- return !!this._dd?.open;
363
- }
364
- get _multi() {
365
- return this.multiple || !!this._dd?.multiple;
366
- }
367
- get _hasValue() {
368
- const v = this._dd?.value;
369
- return this._multi ? Array.isArray(v) && v.length > 0 : v != null;
370
- }
371
- /** Resolve the effective validation state (message props force it). */
372
- get _validationState() {
373
- if (this.validationState && this.validationState !== "default") return this.validationState;
374
- if (this.errorMessage) return "invalid";
375
- if (this.successMessage) return "valid";
376
- return "default";
377
- }
378
- get _wrapperClasses() {
379
- const v = this._validationState;
380
- return [
381
- "mono-dropdown-table",
382
- this.size,
383
- this.color,
384
- this.variant,
385
- `is-${this._resolvedSide}`,
386
- this._isOpen ? "open" : "",
387
- this._moreOpen ? "more-open" : "",
388
- this.disabled ? "disabled" : "",
389
- this.readonly ? "readonly" : "",
390
- v !== "default" ? `is-${v}` : "",
391
- this._hasValue ? "has-value" : "",
392
- this._multi ? "multiple" : "",
393
- this.cssClassName,
394
- this.cssClass?.root
395
- ].filter(Boolean).join(" ");
396
- }
397
- get _triggerClasses() {
398
- return [
399
- "mono-dropdown-table-trigger",
400
- this.size,
401
- this.color,
402
- this.variant,
403
- this.disabled ? "disabled" : "",
404
- this.readonly ? "readonly" : "",
405
- this.cssClass?.trigger
406
- ].filter(Boolean).join(" ");
407
- }
408
- connectedCallback() {
409
- super.connectedCallback();
410
- this._subscribe();
411
- this._wireDropdown();
412
- if (!isServer) this._syncViewportListeners();
413
- }
414
- disconnectedCallback() {
415
- this._off?.();
416
- this._off = void 0;
417
- this._panelObserver?.disconnect();
418
- this._panelObserver = void 0;
419
- if (this._dropdownWired) this._dropdownWired.onValueChange = null;
420
- if (!isServer) {
421
- document.removeEventListener("pointerdown", this._onDocPointer, true);
422
- document.removeEventListener("keydown", this._onDocKey, true);
423
- this._docBound = false;
424
- window.removeEventListener("scroll", this._onViewportChange, true);
425
- window.removeEventListener("resize", this._onViewportChange);
426
- if (this._viewportFrame) cancelAnimationFrame(this._viewportFrame);
427
- this._viewportFrame = 0;
428
- this._viewportBound = false;
429
- }
430
- super.disconnectedCallback();
431
- }
432
- willUpdate(changed) {
433
- if (changed.has("dataDropdown")) {
434
- this._subscribe();
435
- this._wireDropdown();
436
- }
437
- if (changed.has("modelValue")) this._pushModelToDd();
438
- if (changed.has("dataDropdown") || changed.has("max") || changed.has("min") || changed.has("chip")) this._pushLimits();
439
- super.willUpdate?.(changed);
440
- }
441
- /**
442
- * Second entry point for the props apply. `MonoFormControlCore` (composed
443
- * below this core) also overrides `update`, so chain `super`.
444
- */
445
- update(changed) {
446
- this._scheduleApplyDropdownProps();
447
- super.update(changed);
448
- }
449
- _subscribe() {
450
- this._off?.();
451
- detachEventHandlers(this);
452
- this._off = this._dd?.subscribe(() => {
453
- this._scheduleApplyDropdownProps();
454
- this.requestUpdate();
455
- });
456
- this._scheduleApplyDropdownProps();
457
- }
458
- /**
459
- * Deferred + de-duplicated, and driven from `update()` as well as
460
- * `_subscribe()` — the same belt-and-braces the table base needed once two
461
- * cores were found replacing `_subscribe` without chaining `super`. The
462
- * deferral keeps the reactive writes out of the update cycle, so they can't
463
- * trip Lit's change-in-update warning.
464
- */
465
- _scheduleApplyDropdownProps() {
466
- if (this._ddPropsQueued) return;
467
- if (typeof queueMicrotask !== "function") {
468
- this._applyDropdownProps();
469
- return;
470
- }
471
- this._ddPropsQueued = true;
472
- queueMicrotask(() => {
473
- this._ddPropsQueued = false;
474
- this._applyDropdownProps();
475
- });
476
- }
477
- /**
478
- * Pull `monoDataDropdown({ props: { dropdownTable } })` onto this element, so
479
- * the field needs nothing but `:data-dropdown.prop`. The CONTROLLER WINS for
480
- * keys it declares; the rest stay with the template.
481
- */
482
- _applyDropdownProps() {
483
- const dd = this._dd;
484
- if (!dd?.props) return;
485
- applyProps(this, dd.props().dropdownTable);
486
- }
487
- _wireDropdown() {
488
- const dd = this._dd;
489
- if (this._dropdownWired && this._dropdownWired !== dd) this._dropdownWired.onValueChange = null;
490
- this._dropdownWired = dd;
491
- if (!dd) return;
492
- dd.onValueChange = (v) => {
493
- this._lastEmitted = v;
494
- this.modelValue = v;
495
- this._emitChange(v);
496
- };
497
- this._pushModelToDd();
498
- }
499
- /**
500
- * The selection limits the element asks for: `chip.max` / `chip.min` pin,
501
- * `max` / `min` are the fallback, and `undefined` leaves the controller's own
502
- * option in force. They are ENFORCED by the controller's check store (the one
503
- * place a row click, the keyboard, a `<mono-table-checkbox>` and the
504
- * select-all drain all go through), so the element only forwards them.
505
- */
506
- _pushLimits() {
507
- const chip = this._chipProps;
508
- this._dd?.setLimits({
509
- max: resolveChipLimit(chip, "max", this.max),
510
- min: resolveChipLimit(chip, "min", this.min)
511
- });
512
- }
513
- /** Push an external `model-value` into the controller (guarding our own echo). */
514
- _pushModelToDd() {
515
- const dd = this._dd;
516
- if (!dd || this.modelValue === void 0) return;
517
- if (this._sameValue(this.modelValue, this._lastEmitted)) return;
518
- if (this._sameValue(this.modelValue, dd.value)) return;
519
- dd.setValue(this.modelValue);
520
- }
521
- _sameValue(a, b) {
522
- if (a === b) return true;
523
- if (Array.isArray(a) && Array.isArray(b)) return a.length === b.length && a.every((x, i) => String(x) === String(b[i]));
524
- return String(a) === String(b);
525
- }
526
- _emitChange(value) {
527
- const detail = {
528
- modelValue: value,
529
- value,
530
- selectedItems: this._dd?.selectedItems() ?? []
531
- };
532
- dispatchMonoEvent(this, "change", detail);
533
- }
534
- /** Whether the panel is currently open. */
535
- get isOpen() {
536
- return this._isOpen;
537
- }
538
- open() {
539
- if (this.disabled || this.readonly) return;
540
- this._dd?.setOpen(true);
541
- }
542
- close() {
543
- this._moreOpen = false;
544
- this._dd?.setOpen(false);
545
- this.requestUpdate();
546
- }
547
- toggle() {
548
- if (this.disabled || this.readonly) return;
549
- this._moreOpen = false;
550
- this._dd?.setOpen(!this._isOpen);
551
- }
552
- /**
553
- * Where the `[data-row-key]` rows live: light = the captured table inside the
554
- * (portaled) panel; shadow = the SLOTTED table (host's light-DOM children).
555
- */
556
- get _rowScope() {
557
- return this.renderRoot === this ? this._popup.panelRoot : this;
558
- }
559
- _reflectSelection(rows = this._rowEls()) {
560
- const dd = this._dd;
561
- if (!dd) return;
562
- if ((this._focusZone === "list" || this._activeRowKey != null) && rows.length && !rows.some((el) => el.getAttribute("data-row-key") === this._activeRowKey)) this._activeRowKey = rows[0].getAttribute("data-row-key");
563
- rows.forEach((el) => {
564
- const key = el.getAttribute("data-row-key");
565
- const on = key != null && dd.isSelected(key);
566
- const active = key != null && key === this._activeRowKey;
567
- el.classList.toggle("mono-dd-row-selected", on);
568
- el.classList.toggle("mono-dd-row-active", active);
569
- el.toggleAttribute("mono-selected", on);
570
- el.toggleAttribute("mono-dd-selected", on);
571
- el.toggleAttribute("mono-dd-active", active);
572
- if (on !== el.hasAttribute("aria-selected")) {
573
- if (on) el.setAttribute("aria-selected", "true");
574
- else el.removeAttribute("aria-selected");
575
- }
576
- });
577
- }
578
- /** Re-reflect after the consumer's Vue re-renders rows (paging/search). */
579
- _observePanel() {
580
- const root = this._rowScope;
581
- if (!root || this._panelObserver) return;
582
- const touchesRows = (nodes) => {
583
- for (const n of Array.from(nodes)) {
584
- if (n.nodeType !== 1) continue;
585
- const el = n;
586
- if (el.matches("[data-row-key]") || el.querySelector("[data-row-key]")) return true;
587
- }
588
- return false;
589
- };
590
- this._panelObserver = new MutationObserver((records) => {
591
- if (records.some((r) => touchesRows(r.addedNodes) || touchesRows(r.removedNodes))) this._reflectSelection();
592
- });
593
- this._panelObserver.observe(root, {
594
- childList: true,
595
- subtree: true
596
- });
597
- }
598
- /** True for the shadow build — a shadow host keeps its panel in the shadow root. */
599
- get _isShadowHost() {
600
- return this.renderRoot !== this;
601
- }
602
- /**
603
- * Position the panel for the SHADOW build (renderRoot ≠ this): the popup
604
- * controller only portals/positions LIGHT hosts (`_canPortal`), so a shadow
605
- * host places its own `position:fixed` panel. It runs the SAME shared math as
606
- * the light path — flip, shift and size-constrain included. Light is untouched.
607
- */
608
- _positionPanel() {
609
- if (isServer || !this._isShadowHost) return;
610
- if (!this._isOpen) return;
611
- const root = this.renderRoot;
612
- const panel = root.querySelector(".mono-dropdown-table-panel");
613
- const anchor = root.querySelector(".mono-dropdown-table-trigger");
614
- if (!panel || !anchor) return;
615
- const o = this._placementOpts();
616
- const placement = computePopupPlacement(anchor, panel, {
617
- side: o.side(),
618
- align: o.align(),
619
- offset: o.offset(),
620
- flip: o.flip(),
621
- shift: o.shift(),
622
- constrain: true
623
- });
624
- applyPopupPlacement(panel, placement, true);
625
- this._resolvedSide = placement.side;
626
- this._applySideClass();
627
- }
628
- /** The shadow build's in-place placement of the "+N more" panel — see `_positionPanel`. */
629
- _positionMorePanel() {
630
- if (isServer || !this._isShadowHost) return;
631
- if (!this._moreOpen) return;
632
- const root = this.renderRoot;
633
- const panel = root.querySelector(".mono-dropdown-table-more");
634
- const anchor = root.querySelector(".mono-dropdown-table-more-chip");
635
- if (!panel || !anchor) return;
636
- const o = this._morePlacementOpts();
637
- const placement = computePopupPlacement(anchor, panel, {
638
- side: o.side(),
639
- align: o.align(),
640
- offset: o.offset(),
641
- flip: o.flip(),
642
- shift: o.shift(),
643
- constrain: true
644
- });
645
- applyPopupPlacement(panel, placement, true);
646
- }
647
- /**
648
- * Outside-dismiss listeners, both builds, bound while a panel is OPEN only (select's rule).
649
- * Both handlers bail when the list and "+N more" panels are closed, so at rest they cost
650
- * only dispatch — two capture-phase `document` listeners per field.
651
- */
652
- _syncDocListeners() {
653
- const want = this.isConnected && (this._isOpen || this._moreOpen);
654
- if (want === this._docBound) return;
655
- this._docBound = want;
656
- if (want) {
657
- document.addEventListener("pointerdown", this._onDocPointer, true);
658
- document.addEventListener("keydown", this._onDocKey, true);
659
- } else {
660
- document.removeEventListener("pointerdown", this._onDocPointer, true);
661
- document.removeEventListener("keydown", this._onDocKey, true);
662
- }
663
- }
664
- /**
665
- * Shadow build only, and only while a panel is OPEN — the popup controller's rule. They used
666
- * to be bound at connect for every shadow instance: a capture-phase, non-passive `scroll`
667
- * listener on `window` per field, open or not, which also keeps the page's scrolling off the
668
- * compositor thread.
669
- */
670
- _syncViewportListeners() {
671
- if (isServer) return;
672
- this._syncDocListeners();
673
- const want = this._isShadowHost && this.isConnected && (this._isOpen || this._moreOpen);
674
- if (want === this._viewportBound) return;
675
- if (want) {
676
- window.addEventListener("scroll", this._onViewportChange, {
677
- capture: true,
678
- passive: true
679
- });
680
- window.addEventListener("resize", this._onViewportChange, { passive: true });
681
- } else {
682
- window.removeEventListener("scroll", this._onViewportChange, true);
683
- window.removeEventListener("resize", this._onViewportChange);
684
- if (this._viewportFrame) cancelAnimationFrame(this._viewportFrame);
685
- this._viewportFrame = 0;
686
- }
687
- this._viewportBound = want;
688
- }
689
- updated(changed) {
690
- super.updated(changed);
691
- if (isServer) return;
692
- this._syncViewportListeners();
693
- if (this._isOpen) {
694
- this._observePanel();
695
- this._reflectSelection();
696
- this._positionPanel();
697
- } else {
698
- this._panelObserver?.disconnect();
699
- this._panelObserver = void 0;
700
- }
701
- if (this._moreOpen) {
702
- if (!this._overflowItems(this._dd?.selectedItems() ?? []).length) {
703
- this._moreOpen = false;
704
- this.requestUpdate();
705
- } else this._positionMorePanel();
706
- }
707
- const selectedCount = this._dd?.selectedItems?.()?.length ?? 0;
708
- const capChanged = changed.has("maxVisible") || changed.has("minVisible") || changed.has("chip");
709
- if (selectedCount !== this._lastSelectedCount) {
710
- if (this._isOpen && selectedCount > this._lastSelectedCount && this._inlineChips) this._chipStrip.scrollToEnd();
711
- else this._chipStrip.invalidate();
712
- } else if (capChanged) this._chipStrip.invalidate();
713
- this._lastSelectedCount = selectedCount;
714
- if (this._isOpen !== this._wasOpen) {
715
- this._wasOpen = this._isOpen;
716
- if (this._isOpen) this._initPanelFocus();
717
- else {
718
- this._activeRowKey = null;
719
- this._focusZone = "search";
720
- this._panelTabHeld = false;
721
- this._restoreTriggerFocus();
722
- }
723
- }
724
- }
725
- /** The focusable trigger (`tabindex=0`), in both builds. */
726
- _triggerElement() {
727
- return this.renderRoot.querySelector(".mono-dropdown-table-trigger");
728
- }
729
- /**
730
- * Delegate focus to the trigger — the host itself isn't focusable. Needed by
731
- * anything that focuses the component from outside, e.g. the data grid
732
- * focusing the editor in a clicked cell (`focusRowCell`), which looks for an
733
- * inner `input/textarea/select/button` and otherwise falls back to calling
734
- * `focus()` on the element itself.
735
- */
736
- focus(options) {
737
- this._triggerElement()?.focus(options);
738
- }
739
- blur() {
740
- this._triggerElement()?.blur();
741
- }
742
- /** The search region's slotted content — light: captured nodes; shadow: `<slot>`. */
743
- _searchRegionElements() {
744
- if (this._isShadowHost) {
745
- const slot = this.renderRoot.querySelector("slot[name=\"search\"]");
746
- return slot ? slot.assignedElements({ flatten: true }) : [];
747
- }
748
- const sel = "[data-mono-slot=\"search\"]";
749
- const region = this.querySelector(sel) ?? this._popup.panelRoot?.querySelector?.(sel);
750
- return region ? Array.from(region.children) : [];
751
- }
752
- /**
753
- * Focus the panel's search box once the panel is rendered, placed and (light
754
- * build) portaled. Deferred a microtask so a slotted element that hasn't
755
- * rendered its input yet gets a chance to — `updateComplete` on the search
756
- * element itself, since it updates independently of this host.
757
- */
758
- /**
759
- * The element to focus for "the search box", or null when the panel has no
760
- * search region. `mono-table-search` / `mono-shadow-table-search` expose
761
- * `focus()` and delegate to their own input, so neither build needs a DOM
762
- * reach-in; anything else slotted in its place falls back to its first field.
763
- */
764
- _searchEl() {
765
- for (const el of this._searchRegionElements()) {
766
- if (el.matches("mono-table-search, mono-shadow-table-search")) return el;
767
- const sel = "input:not([type=\"hidden\"]), textarea, select";
768
- const field = el.matches(sel) ? el : el.querySelector(sel) ?? el.shadowRoot?.querySelector(sel);
769
- if (field) return field;
770
- }
771
- return null;
772
- }
773
- async _focusSearch() {
774
- await this.updateComplete;
775
- if (!this._isOpen) return;
776
- const el = this._searchEl();
777
- if (!el) return;
778
- const pending = el.updateComplete;
779
- if (pending) await pending;
780
- if (!this._isOpen) return;
781
- el.focus({ preventScroll: true });
782
- this._focusZone = "search";
783
- this._searchFocused = true;
784
- }
785
- _rowEls() {
786
- const root = this._rowScope;
787
- if (!root?.querySelectorAll) return [];
788
- return Array.from(root.querySelectorAll("[data-row-key]"));
789
- }
790
- _panelEl() {
791
- return (this._popup.panelRoot ?? this.renderRoot)?.querySelector?.(".mono-dropdown-table-panel") ?? null;
792
- }
793
- /** `rows`: the caller's own `_rowEls()` — one query per arrow key, not three. */
794
- _setActiveRow(key, reveal = false, rows = this._rowEls()) {
795
- this._activeRowKey = key;
796
- this._reflectSelection(rows);
797
- if (!reveal || key == null) return;
798
- rows.find((r) => r.getAttribute("data-row-key") === key)?.scrollIntoView?.({ block: "nearest" });
799
- }
800
- _moveActiveRow(delta) {
801
- const rows = this._rowEls();
802
- const keys = rows.map((r) => r.getAttribute("data-row-key") ?? "");
803
- if (!keys.length) return;
804
- const i = this._activeRowKey == null ? -1 : keys.indexOf(this._activeRowKey);
805
- const next = i < 0 ? delta > 0 ? 0 : keys.length - 1 : Math.min(Math.max(i + delta, 0), keys.length - 1);
806
- this._setActiveRow(keys[next], true, rows);
807
- }
808
- /** Move the keyboard into the row list, highlighting the first row. */
809
- _enterList() {
810
- this._focusZone = "list";
811
- if (this._activeRowKey == null) this._setActiveRow(this._rowEls()[0]?.getAttribute("data-row-key") ?? null, true);
812
- this._panelEl()?.focus({ preventScroll: true });
813
- }
814
- /** Move the keyboard back to the search box (no-op when there isn't one). */
815
- _enterSearch() {
816
- const el = this._searchEl();
817
- if (!el) return;
818
- this._focusZone = "search";
819
- el.focus({ preventScroll: true });
820
- }
821
- _selectActiveRow() {
822
- if (this._activeRowKey == null) return;
823
- this._dd?.toggleRow(this._activeRowKey);
824
- this._reflectSelection();
825
- }
826
- /**
827
- * Where the keyboard starts when the panel opens: the search box if there is
828
- * one, otherwise straight into the list with the first row highlighted.
829
- */
830
- async _initPanelFocus() {
831
- await this.updateComplete;
832
- if (!this._isOpen) return;
833
- const selected = this._dd?.selectedItems?.() ?? [];
834
- if (selected.length) this._setActiveRow(String(selected[selected.length - 1].key), true);
835
- if (this._searchEl()) {
836
- this._focusZone = "search";
837
- if (this.autoFocusSearch) this._focusSearch();
838
- return;
839
- }
840
- this._enterList();
841
- }
842
- /**
843
- * Hand focus back to the trigger when a panel that HAD focus closes — hiding
844
- * the panel blurs its input to `<body>`, which would otherwise strand the
845
- * keyboard. Covers every close path (Escape, outside pointerdown, a
846
- * controller-driven auto-close after a single-select pick) because it hangs
847
- * off the state edge rather than off `close()`.
848
- */
849
- _restoreTriggerFocus() {
850
- if (!this._searchFocused) return;
851
- this._searchFocused = false;
852
- const active = document.activeElement;
853
- const panel = this._popup.panelRoot?.querySelector?.(".mono-dropdown-table-panel");
854
- if (!(!active || active === document.body || this.contains(active) || !!panel?.contains(active))) return;
855
- this.focus({ preventScroll: true });
856
- }
857
- /** A panel region — light: a `data-mono-slot` capture target; shadow overrides with `<slot>`. */
858
- _renderRegion(cls, name) {
859
- return html`<div class="mono-dropdown-table-region ${cls}" mono-dd-region=${cls} data-mono-slot="${name}"></div>`;
860
- }
861
- _caretIcon() {
862
- return caretIcon();
863
- }
864
- _chevronIcon(dir) {
865
- return chevronIcon(dir);
866
- }
867
- /**
868
- * One scroll button. `active` false keeps the box — and therefore the row's
869
- * width — but hides it (`is-idle` → `visibility: hidden`), so reaching an end
870
- * of the strip costs no layout. `aria-hidden` keeps the hidden one out of
871
- * reach of assistive tech; `pointer-events: none` handles the pointer.
872
- */
873
- _renderScrollButton(dir, active) {
874
- const back = dir === -1;
875
- const base = `mono-dropdown-table-scroll mono-dropdown-table-scroll-${back ? "prev" : "next"}${active ? "" : " is-idle"}`;
876
- return html`<span
877
- role="button"
878
- tabindex="-1"
879
- class=${this._cls(base, back ? "scrollPrev" : "scrollNext")}
880
- mono-dd-scroll=${back ? "prev" : "next"}
881
- ?mono-idle=${!active}
882
- aria-label=${back ? "Scroll selection backward" : "Scroll selection forward"}
883
- aria-hidden=${active ? "false" : "true"}
884
- @mousedown=${(e) => e.preventDefault()}
885
- @click=${(e) => {
886
- e.stopPropagation();
887
- this._chipStrip.page(dir);
888
- }}
889
- >${this._chevronIcon(dir)}</span
890
- >`;
891
- }
892
- /** The `chip` prop, always an object (it can be assigned null from a binding). */
893
- get _chipProps() {
894
- return this.chip ?? {};
895
- }
896
- /** Chip layout: `inline` = one scrolling line, anything else = today's wrap. */
897
- get _chipBehaviour() {
898
- return this._chipProps.behaviour === "inline" ? "inline" : "flex";
899
- }
900
- /** True where a scrolling strip actually renders: multi, inline, with chips. */
901
- get _inlineChips() {
902
- return this._multi && this._hasValue && this._chipBehaviour === "inline";
903
- }
904
- /**
905
- * How many chips to draw for `total` selected rows before the rest collapse
906
- * into "+N more" — Infinity when uncapped or under the collapse floor.
907
- * `chip.maxVisible` / `chip.minVisible` pin, the element props are the
908
- * fallback (`resolveChipLimit`). Applies to `inline` as well: the "+N more"
909
- * chip then sits in the strip after the visible ones and its panel lists the
910
- * rest, exactly as in `flex`.
911
- */
912
- _visibleCap(total) {
913
- const chip = this._chipProps;
914
- return visibleChipCap(total, resolveChipLimit(chip, "maxVisible", this.maxVisible), resolveChipLimit(chip, "minVisible", this.minVisible));
915
- }
916
- /** The selection floor in force (element / chip / controller), 0 when none. */
917
- get _minSelected() {
918
- return this._dd?.limits().min ?? 0;
919
- }
920
- /** A chip can be removed while the selection sits above its floor. */
921
- get _canRemove() {
922
- return (this._dd?.selectedItems?.()?.length ?? 0) > this._minSelected;
923
- }
924
- /**
925
- * Chip skin matching the field skin: a `filled` field already tints its own
926
- * surface, so a soft chip would vanish into it — go solid; `underlined` is
927
- * minimal, so the chip stays outline. `chip.variant` pins one instead.
928
- */
929
- get _chipVariantClass() {
930
- const pinned = this._chipProps.variant;
931
- if (pinned) return pinned;
932
- if (this.variant === "filled") return "solid";
933
- if (this.variant === "underlined") return "outline";
934
- return "soft";
935
- }
936
- /** Chips wear the control's color unless `chip.color` pins another. */
937
- get _chipColorClass() {
938
- return this._chipProps.color ?? this.color;
939
- }
940
- /**
941
- * Classes shared by the selection chips and the "+N more" chip, in
942
- * `mono-chip`'s own order (`mono-chip <size> <variant>-<color> <shape>`), so
943
- * chip.css paints them exactly as it paints a real `<mono-chip>`.
944
- *
945
- * `mono-dropdown-table-chip` is a marker only — it scopes the `--mono-chip-*`
946
- * bridge in dropdown-table.css so the bridge never reaches a `<mono-chip>` a
947
- * consumer slots into the panel. `chip.color` deliberately picks a hue OTHER
948
- * than the control accent, so it adds the `-pinned` marker that switches the
949
- * bridge back off.
950
- */
951
- get _chipBaseClasses() {
952
- const chip = this._chipProps;
953
- return [
954
- "mono-dropdown-table-chip",
955
- chip.color ? "mono-dropdown-table-chip-pinned" : "",
956
- chip.size ?? (this.size === "xs" || this.size === "sm" ? "xs" : "sm"),
957
- `${this._chipVariantClass}-${this._chipColorClass}`,
958
- "",
959
- chip.dot ? "has-dot" : ""
960
- ].filter(Boolean).join(" ");
961
- }
962
- /**
963
- * Class for one chip part. Both class APIs append: the field-level key
964
- * (`cssClass.chip` / `.chipLabel` / `.chipRemove`) and the chip-level one
965
- * (`chip.cssClass.*`, which additionally reaches the parts the field has no
966
- * key for — `main`, `content`, `dot`).
967
- */
968
- _chipCls(base, chipKey, key) {
969
- return [
970
- base,
971
- key ? this.cssClass?.[key] : void 0,
972
- this._chipProps.cssClass?.[chipKey]
973
- ].filter(Boolean).join(" ");
974
- }
975
- _renderChip(it) {
976
- const chip = this._chipProps;
977
- const removable = !this.disabled && !this.readonly && this._canRemove;
978
- return html`
979
- <div
980
- class=${this._chipCls(`${this._chipBaseClasses}${removable ? " removable" : ""}`, "root", "chip")}
981
- mono-dd-chip
982
- ?mono-dd-removable=${removable}
983
- mono-dd-chip-color=${chip.color ?? nothing}
984
- mono-dd-chip-rounded=${chip.rounded ?? nothing}
985
- >
986
- <span class=${ifDefined(chip.cssClass?.main)} mono-dd-chip-main>
987
- <span class=${this._chipCls("chip-content", "content")} mono-dd-chip-content>
988
- ${chip.dot ? html`<span class=${this._chipCls("chip-dot", "dot")} mono-dd-chip-dot aria-hidden="true"></span>` : nothing}
989
- <span class=${this._chipCls("chip-label", "label", "chipLabel")} mono-dd-chip-label>${it.text}</span>
990
- ${removable ? html`<button
991
- type="button"
992
- class=${this._chipCls("chip-close", "close", "chipRemove")}
993
- mono-dd-chip-close
994
- aria-label=${chip.closeLabel ?? `Remove ${it.text}`}
995
- @click=${(e) => {
996
- e.stopPropagation();
997
- this._dd?.removeKey(it.key);
998
- }}
999
- >
1000
- ${closeIcon()}
1001
- </button>` : nothing}
1002
- </span>
1003
- </span>
1004
- </div>
1005
- `;
1006
- }
1007
- /**
1008
- * The chip region. `flex` returns the chips as bare children of the value
1009
- * span, so they wrap — the historical markup, unchanged. `inline` nests them
1010
- * in one `overflow-x: hidden` strip instead, which is what makes the row
1011
- * scroll as a unit.
1012
- */
1013
- _renderChipRegion(items) {
1014
- const chips = this._renderChips(items);
1015
- if (this._chipBehaviour !== "inline") return chips;
1016
- return html`
1017
- <span class=${this._cls("mono-dropdown-table-chip-strip", "chipStrip")} mono-dd-chip-strip>${chips}</span>
1018
- `;
1019
- }
1020
- _renderChips(items) {
1021
- const max = this._visibleCap(items.length);
1022
- const visible = max === Infinity ? items : items.slice(0, max);
1023
- const overflow = this._overflowItems(items);
1024
- const chips = visible.map((it) => this._renderChip(it));
1025
- if (overflow.length) chips.push(html`
1026
- <div
1027
- class=${this._cls(`${this._chipBaseClasses.replace(" has-dot", "")} clickable mono-dropdown-table-more-chip`, "moreChip")}
1028
- mono-dd-chip
1029
- mono-dd-more
1030
- mono-dd-chip-color=${this._chipProps.color ?? nothing}
1031
- mono-dd-chip-rounded=${this._chipProps.rounded ?? nothing}
1032
- >
1033
- <span
1034
- class=${ifDefined(this._chipProps.cssClass?.main)}
1035
- mono-dd-chip-main
1036
- role="button"
1037
- tabindex="0"
1038
- @mousedown=${(e) => e.preventDefault()}
1039
- @click=${(e) => {
1040
- e.stopPropagation();
1041
- const next = !this._moreOpen;
1042
- this._dd?.setOpen(false);
1043
- this._moreOpen = next;
1044
- this.requestUpdate();
1045
- }}
1046
- >
1047
- <span class=${this._chipCls("chip-content", "content")} mono-dd-chip-content
1048
- ><span class=${this._chipCls("chip-label", "label")} mono-dd-chip-label
1049
- >+${overflow.length} more</span
1050
- ></span
1051
- >
1052
- </span>
1053
- </div>
1054
- `);
1055
- return chips;
1056
- }
1057
- /** Selected rows past the visible cap — empty when uncapped or under the collapse floor. */
1058
- _overflowItems(items) {
1059
- const max = this._visibleCap(items.length);
1060
- return max === Infinity ? [] : items.slice(max);
1061
- }
1062
- /**
1063
- * Always rendered, shown by the root's `more-open` class: the panel lives in
1064
- * a body portal while open and a portaled node cannot be removed by a
1065
- * conditional render (Lit's ChildPart no longer contains it).
1066
- */
1067
- _renderMore(items) {
1068
- const overflow = this._moreOpen ? this._overflowItems(items) : [];
1069
- return html`<div class="mono-dropdown-table-more" mono-dd-more>${overflow.map((it) => this._renderChip(it))}</div>`;
1070
- }
1071
- _renderLabel() {
1072
- if (!this.label) return nothing;
1073
- return html`<label class=${this._cls("mono-dropdown-table-label", "label")} mono-dd-label
1074
- >${this.label}${this.required ? html`<span class=${this._cls("mono-dropdown-table-required", "required")} mono-dd-required-mark>*</span>` : nothing}${this._tooltip.render()}</label
1075
- >`;
1076
- }
1077
- _renderMessage() {
1078
- const base = this._cls("mono-dropdown-table-message", "message");
1079
- if (this._validation.moved) {
1080
- const notice = this._validationNotice;
1081
- return html`${this.helperText ? html`<div class="${base} helper" mono-dd-message="helper">${this.helperText}</div>` : nothing}<div
1082
- class="${base} ${notice.state}"
1083
- mono-dd-message=${notice.state}
1084
- mono-sr-only
1085
- role=${notice.state === "invalid" ? "alert" : nothing}
1086
- >${notice.text}</div>`;
1087
- }
1088
- if (this.validationMessage) {
1089
- const state = this._validationState;
1090
- return html`<div class="${base} ${state}" mono-dd-message=${state} role=${state === "invalid" ? "alert" : nothing}>
1091
- ${this.validationMessage}
1092
- </div>`;
1093
- }
1094
- if (this.errorMessage) return html`<div class="${base} invalid" mono-dd-message="invalid" role="alert">${this.errorMessage}</div>`;
1095
- if (this.successMessage) return html`<div class="${base} valid" mono-dd-message="valid">${this.successMessage}</div>`;
1096
- if (this.helperText) return html`<div class="${base} helper" mono-dd-message="helper">${this.helperText}</div>`;
1097
- return nothing;
1098
- }
1099
- _renderTrigger(items) {
1100
- const dd = this._dd;
1101
- const hasValue = this._hasValue;
1102
- const inert = this.disabled || this.readonly;
1103
- const canClear = this.clearable && hasValue && !inert && !(this._multi && this._minSelected > 0);
1104
- const inlineChips = this._inlineChips;
1105
- return html`
1106
- <div
1107
- class=${this._triggerClasses}
1108
- mono-dd-trigger
1109
- role="combobox"
1110
- tabindex=${this.disabled ? -1 : 0}
1111
- aria-expanded=${this._isOpen ? "true" : "false"}
1112
- @click=${() => this.toggle()}
1113
- @keydown=${this._onTriggerKeydown}
1114
- >
1115
- <span
1116
- class="${this._cls("mono-dropdown-table-value", "value")}${hasValue ? "" : ` mono-dropdown-table-placeholder${this.cssClass?.placeholder ? ` ${this.cssClass.placeholder}` : ""}`}${inlineChips ? " is-inline" : ""}"
1117
- mono-dd-value
1118
- ?mono-dd-placeholder=${!hasValue}
1119
- ?mono-inline=${inlineChips}
1120
- >
1121
- ${this._multi ? hasValue ? this._renderChipRegion(items) : this.placeholder : hasValue ? html`<span>${dd?.displayText()}</span>` : this.placeholder}
1122
- </span>
1123
- ${this._validation.renderIcon()}
1124
- <span class=${this._cls("mono-dropdown-table-actions", "actions")} mono-dd-actions>
1125
- ${inlineChips && this._chipStrip.overflowing ? html`${this._renderScrollButton(-1, this._chipStrip.canScrollStart)}
1126
- ${this._renderScrollButton(1, this._chipStrip.canScrollEnd)}` : nothing}
1127
- ${canClear ? html`<span
1128
- role="button"
1129
- tabindex="-1"
1130
- class=${this._cls("mono-dropdown-table-clear", "clear")}
1131
- mono-dd-clear
1132
- aria-label="Clear"
1133
- @mousedown=${(e) => e.preventDefault()}
1134
- @click=${(e) => {
1135
- e.stopPropagation();
1136
- this._dd?.clear();
1137
- this.close();
1138
- }}
1139
- >${closeIcon()}</span
1140
- >` : nothing}
1141
- ${!inert && !canClear ? html`<span
1142
- role="button"
1143
- tabindex="-1"
1144
- class=${this._cls("mono-dropdown-table-arrow", "arrow")}
1145
- mono-dd-arrow
1146
- aria-label="Toggle"
1147
- aria-expanded=${this._isOpen ? "true" : "false"}
1148
- @mousedown=${(e) => e.preventDefault()}
1149
- @click=${(e) => {
1150
- e.stopPropagation();
1151
- this.toggle();
1152
- }}
1153
- >${this._caretIcon()}</span
1154
- >` : nothing}
1155
- </span>
1156
- </div>
1157
- `;
1158
- }
1159
- /**
1160
- * Panel-only sizing from the `dropdown` object.
1161
- *
1162
- * `maxHeight` is published as the custom property `--_mono-dropdown-table-panel-max-h` rather than a direct
1163
- * `max-height`: the popup controller also constrains the panel (via `--mono-popup-avail-h`),
1164
- * and two writers on the same declaration would clobber each other across renders. The CSS
1165
- * combines both with `min()`. Everything else is a plain declaration.
1166
- *
1167
- * `height` is an EXACT height here now. It used to be the cap, because this object had no
1168
- * `maxHeight`; it does now, and the three popup components share one meaning.
1169
- */
1170
- _panelStyle() {
1171
- const d = this.dropdown;
1172
- if (!d) return {};
1173
- const s = {};
1174
- const w = toCssSize(d.width);
1175
- const mw = toCssSize(d.minWidth);
1176
- const xw = toCssSize(d.maxWidth);
1177
- const h = toCssSize(d.height);
1178
- const mh = toCssSize(d.minHeight);
1179
- const xh = toCssSize(d.maxHeight);
1180
- if (w) s.width = w;
1181
- if (mw) s["min-width"] = mw;
1182
- if (xw) s["max-width"] = xw;
1183
- if (h) s.height = h;
1184
- if (mh) s["min-height"] = mh;
1185
- if (xh) s["--_mono-dropdown-table-panel-max-h"] = xh;
1186
- return s;
1187
- }
1188
- render() {
1189
- const items = this._dd?.selectedItems() ?? [];
1190
- const state = this._validationState;
1191
- return html`
1192
- <div
1193
- class=${this._wrapperClasses}
1194
- style=${styleMap(buildSizeStyle(this))}
1195
- mono-dropdown-table
1196
- mono-size=${this.size === "md" ? nothing : this.size}
1197
- mono-color=${this.color === "primary" ? nothing : this.color}
1198
- mono-variant=${this.variant === "outlined" ? nothing : this.variant}
1199
- mono-label-position=${this.labelPosition === "top" ? nothing : this.labelPosition}
1200
- mono-validation-position=${this.validationPosition === "bottom" ? nothing : this.validationPosition}
1201
- mono-validation-state=${state === "default" ? nothing : state}
1202
- mono-side=${this._resolvedSide}
1203
- ?mono-open=${this._isOpen}
1204
- ?mono-more-open=${this._moreOpen}
1205
- ?mono-disabled=${this.disabled}
1206
- ?mono-readonly=${this.readonly}
1207
- ?mono-required=${this.required}
1208
- ?mono-clearable=${this.clearable}
1209
- ?mono-multiple=${this._multi}
1210
- ?mono-has-value=${this._hasValue}
1211
- >
1212
- ${this._renderLabel()}
1213
- <div
1214
- class="mono-dropdown-table-control${this._inlineChips ? " is-inline" : ""}"
1215
- mono-dd-control
1216
- ?mono-inline=${this._inlineChips}
1217
- >
1218
- ${this._renderTrigger(items)} ${this._renderMore(items)}
1219
- </div>
1220
- ${this._renderMessage()}
1221
- ${this._validation.renderFloat()}
1222
- <div
1223
- class="mono-dropdown-table-panel ${this._isOpen ? "open" : ""}"
1224
- mono-dd-panel
1225
- role="dialog"
1226
- tabindex="-1"
1227
- style=${styleMap(this._panelStyle())}
1228
- @click=${this._onPanelClick}
1229
- @keydown=${this._onPanelKeydown}
1230
- @keyup=${this._onPanelKeyup}
1231
- >
1232
- ${this._renderRegion("search", "search")}
1233
- ${this._renderRegion("body", "body")}
1234
- ${this._renderRegion("foot", "footer")}
1235
- </div>
1236
- </div>
1237
- `;
1238
- }
1239
- }
1240
- __decorate([property({ attribute: false })], MonoDropdownTableCoreClass.prototype, "dataDropdown", void 0);
1241
- __decorate([property({ type: String })], MonoDropdownTableCoreClass.prototype, "size", void 0);
1242
- __decorate([property({ type: String })], MonoDropdownTableCoreClass.prototype, "color", void 0);
1243
- __decorate([property({ type: String })], MonoDropdownTableCoreClass.prototype, "variant", void 0);
1244
- __decorate([property({
1245
- type: String,
1246
- attribute: "label-position"
1247
- })], MonoDropdownTableCoreClass.prototype, "labelPosition", void 0);
1248
- __decorate([property({
1249
- type: String,
1250
- attribute: "validation-position"
1251
- })], MonoDropdownTableCoreClass.prototype, "validationPosition", void 0);
1252
- __decorate([property({ type: String })], MonoDropdownTableCoreClass.prototype, "label", void 0);
1253
- __decorate([property({ type: String })], MonoDropdownTableCoreClass.prototype, "placeholder", void 0);
1254
- __decorate([property({
1255
- type: String,
1256
- attribute: "helper-text"
1257
- })], MonoDropdownTableCoreClass.prototype, "helperText", void 0);
1258
- __decorate([property()], MonoDropdownTableCoreClass.prototype, "tooltip", void 0);
1259
- __decorate([property({
1260
- type: String,
1261
- attribute: "validation-state"
1262
- })], MonoDropdownTableCoreClass.prototype, "validationState", void 0);
1263
- __decorate([property({
1264
- type: String,
1265
- attribute: "validation-message"
1266
- })], MonoDropdownTableCoreClass.prototype, "validationMessage", void 0);
1267
- __decorate([property({
1268
- type: String,
1269
- attribute: "error-message"
1270
- })], MonoDropdownTableCoreClass.prototype, "errorMessage", void 0);
1271
- __decorate([property({
1272
- type: String,
1273
- attribute: "success-message"
1274
- })], MonoDropdownTableCoreClass.prototype, "successMessage", void 0);
1275
- __decorate([property({
1276
- reflect: true,
1277
- converter: booleanStringConverter
1278
- })], MonoDropdownTableCoreClass.prototype, "required", void 0);
1279
- __decorate([property({
1280
- reflect: true,
1281
- converter: booleanStringConverter
1282
- })], MonoDropdownTableCoreClass.prototype, "disabled", void 0);
1283
- __decorate([property({
1284
- reflect: true,
1285
- converter: booleanStringConverter
1286
- })], MonoDropdownTableCoreClass.prototype, "readonly", void 0);
1287
- __decorate([property({
1288
- reflect: true,
1289
- converter: booleanStringConverter
1290
- })], MonoDropdownTableCoreClass.prototype, "clearable", void 0);
1291
- __decorate([property({
1292
- reflect: true,
1293
- converter: booleanStringConverter
1294
- })], MonoDropdownTableCoreClass.prototype, "multiple", void 0);
1295
- __decorate([property({ converter: optionalNumberConverter })], MonoDropdownTableCoreClass.prototype, "max", void 0);
1296
- __decorate([property({ converter: optionalNumberConverter })], MonoDropdownTableCoreClass.prototype, "min", void 0);
1297
- __decorate([property({
1298
- attribute: "max-visible",
1299
- converter: optionalNumberConverter
1300
- })], MonoDropdownTableCoreClass.prototype, "maxVisible", void 0);
1301
- __decorate([property({
1302
- attribute: "min-visible",
1303
- converter: optionalNumberConverter
1304
- })], MonoDropdownTableCoreClass.prototype, "minVisible", void 0);
1305
- __decorate([property({ attribute: false })], MonoDropdownTableCoreClass.prototype, "chip", void 0);
1306
- __decorate([property({ attribute: "model-value" })], MonoDropdownTableCoreClass.prototype, "modelValue", void 0);
1307
- __decorate([property({ type: String })], MonoDropdownTableCoreClass.prototype, "width", void 0);
1308
- __decorate([property({ type: String })], MonoDropdownTableCoreClass.prototype, "height", void 0);
1309
- __decorate([property({
1310
- type: String,
1311
- attribute: "min-width"
1312
- })], MonoDropdownTableCoreClass.prototype, "minWidth", void 0);
1313
- __decorate([property({
1314
- type: String,
1315
- attribute: "max-width"
1316
- })], MonoDropdownTableCoreClass.prototype, "maxWidth", void 0);
1317
- __decorate([property({
1318
- type: String,
1319
- attribute: "min-height"
1320
- })], MonoDropdownTableCoreClass.prototype, "minHeight", void 0);
1321
- __decorate([property({
1322
- type: String,
1323
- attribute: "max-height"
1324
- })], MonoDropdownTableCoreClass.prototype, "maxHeight", void 0);
1325
- __decorate([property({ attribute: false })], MonoDropdownTableCoreClass.prototype, "dropdown", void 0);
1326
- __decorate([property({ type: String })], MonoDropdownTableCoreClass.prototype, "placement", void 0);
1327
- __decorate([property({ converter: booleanStringConverter })], MonoDropdownTableCoreClass.prototype, "flip", void 0);
1328
- __decorate([property({ converter: booleanStringConverter })], MonoDropdownTableCoreClass.prototype, "shift", void 0);
1329
- __decorate([property({ converter: numberStringConverter })], MonoDropdownTableCoreClass.prototype, "offset", void 0);
1330
- __decorate([property({
1331
- attribute: "auto-focus-search",
1332
- converter: booleanStringConverter
1333
- })], MonoDropdownTableCoreClass.prototype, "autoFocusSearch", void 0);
1334
- __decorate([property({
1335
- attribute: "stay-open",
1336
- reflect: true,
1337
- converter: booleanStringConverter
1338
- })], MonoDropdownTableCoreClass.prototype, "stayOpen", void 0);
1339
- __decorate([property({ attribute: false })], MonoDropdownTableCoreClass.prototype, "cssClass", void 0);
1340
- __decorate([property({ attribute: false })], MonoDropdownTableCoreClass.prototype, "cssClassName", void 0);
1341
- return MonoDropdownTableCoreClass;
1342
- };
1343
-
1344
- //#endregion
1345
9
  //#region src/components/dropdown-table/mono-dropdown-table.ts
1346
10
  let MonoDropdownTable = class MonoDropdownTable extends MonoDropdownTableCore(LitElement) {
1347
11
  constructor(..._args) {