@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,516 +1,11 @@
1
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, o as numberStringConverter, 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 { i as guardHostTextContent, s as placeSlotNode } from "../light-slots-B5Ck0t_E.js";
6
- import { n as applyPopupPlacement, r as computePopupPlacement, t as PopupPortalController } from "../popup-portal-CINuVjNY.js";
7
- import { n as cssPart, r as defineCssClassAliases, t as applyCssClass } from "../css-class-B6Tc_MAx.js";
8
- import { LitElement, html, isServer, nothing } from "lit";
9
- import { property, state } from "lit/decorators.js";
5
+ import { t as MonoDropdownCore } from "../dropdown-core-BCH1pK14.js";
6
+ import { LitElement, html, nothing } from "lit";
7
+ import { state } from "lit/decorators.js";
10
8
 
11
- //#region src/components/dropdown/dropdown-core.ts
12
- /**
13
- * `MonoDropdownCore` — all render-mode-agnostic logic for `mono-dropdown`:
14
- * reactive props, hybrid aliases, host-class management, open/close state +
15
- * events, trigger listeners, outside-click/escape, and `position: fixed` panel
16
- * positioning (with containing-block compensation).
17
- *
18
- * SSR-safe: every `document`/`window`/layout-measuring path is guarded by
19
- * `isServer` (lit) so `@lit-labs/ssr` can render it on the server.
20
- *
21
- * Leaves to each build: `createRenderRoot()`, the slot strategy + `render()`,
22
- * and `_activeMainNodes()` (light: captured nodes; shadow: main slot's
23
- * assigned elements). Panel/queries use `this.renderRoot`, which is `this` for
24
- * the light build and the shadow root for the shadow build.
25
- */
26
- /**
27
- * The dropdown's PUBLIC custom properties, handed to the popup portal so a
28
- * relocated panel keeps overrides an ancestor of the host set — a portaled panel
29
- * is a child of `<body>`, so it inherits none of them, and `getComputedStyle`
30
- * cannot enumerate custom properties for the portal to copy them blindly.
31
- *
32
- * Kept in step with dropdown.css by tests/dropdown-attributes.test.ts.
33
- */
34
- const DROPDOWN_STYLE_VARS = [
35
- "--mono-dropdown-accent",
36
- "--mono-dropdown-bg",
37
- "--mono-dropdown-border",
38
- "--mono-dropdown-danger",
39
- "--mono-dropdown-font",
40
- "--mono-dropdown-font-lg",
41
- "--mono-dropdown-font-md",
42
- "--mono-dropdown-font-sm",
43
- "--mono-dropdown-font-xl",
44
- "--mono-dropdown-font-xs",
45
- "--mono-dropdown-font-xxl",
46
- "--mono-dropdown-gap",
47
- "--mono-dropdown-gap-lg",
48
- "--mono-dropdown-gap-md",
49
- "--mono-dropdown-gap-sm",
50
- "--mono-dropdown-gap-xl",
51
- "--mono-dropdown-gap-xs",
52
- "--mono-dropdown-gap-xxl",
53
- "--mono-dropdown-info",
54
- "--mono-dropdown-line-height",
55
- "--mono-dropdown-max-width",
56
- "--mono-dropdown-max-width-lg",
57
- "--mono-dropdown-max-width-md",
58
- "--mono-dropdown-max-width-sm",
59
- "--mono-dropdown-max-width-xl",
60
- "--mono-dropdown-max-width-xs",
61
- "--mono-dropdown-max-width-xxl",
62
- "--mono-dropdown-min-width",
63
- "--mono-dropdown-min-width-lg",
64
- "--mono-dropdown-min-width-md",
65
- "--mono-dropdown-min-width-sm",
66
- "--mono-dropdown-min-width-xl",
67
- "--mono-dropdown-min-width-xs",
68
- "--mono-dropdown-min-width-xxl",
69
- "--mono-dropdown-offset",
70
- "--mono-dropdown-offset-lg",
71
- "--mono-dropdown-offset-md",
72
- "--mono-dropdown-offset-sm",
73
- "--mono-dropdown-offset-xl",
74
- "--mono-dropdown-offset-xs",
75
- "--mono-dropdown-offset-xxl",
76
- "--mono-dropdown-pad-x",
77
- "--mono-dropdown-pad-x-lg",
78
- "--mono-dropdown-pad-x-md",
79
- "--mono-dropdown-pad-x-sm",
80
- "--mono-dropdown-pad-x-xl",
81
- "--mono-dropdown-pad-x-xs",
82
- "--mono-dropdown-pad-x-xxl",
83
- "--mono-dropdown-pad-y",
84
- "--mono-dropdown-pad-y-lg",
85
- "--mono-dropdown-pad-y-md",
86
- "--mono-dropdown-pad-y-sm",
87
- "--mono-dropdown-pad-y-xl",
88
- "--mono-dropdown-pad-y-xs",
89
- "--mono-dropdown-pad-y-xxl",
90
- "--mono-dropdown-primary",
91
- "--mono-dropdown-radius",
92
- "--mono-dropdown-radius-lg",
93
- "--mono-dropdown-radius-md",
94
- "--mono-dropdown-radius-sm",
95
- "--mono-dropdown-radius-xl",
96
- "--mono-dropdown-radius-xs",
97
- "--mono-dropdown-radius-xxl",
98
- "--mono-dropdown-ring-base",
99
- "--mono-dropdown-ring-color",
100
- "--mono-dropdown-ring-width",
101
- "--mono-dropdown-secondary",
102
- "--mono-dropdown-shadow",
103
- "--mono-dropdown-success",
104
- "--mono-dropdown-surface",
105
- "--mono-dropdown-text",
106
- "--mono-dropdown-warning",
107
- "--mono-dropdown-teal",
108
- "--mono-dropdown-purple",
109
- "--mono-dropdown-neutral",
110
- "--mono-dropdown-dark"
111
- ];
112
- const MonoDropdownCore = (superClass) => {
113
- class MonoDropdownCoreClass extends superClass {
114
- constructor(...args) {
115
- super(...args);
116
- this._popup = new PopupPortalController(this, {
117
- getPanel: () => this.renderRoot.querySelector(".mono-dropdown-panel"),
118
- getAnchor: () => this._firstMainElement(),
119
- getStyleScope: () => this,
120
- isOpen: () => this.modelValue,
121
- side: () => this._sideFromPlacement(this.placement),
122
- align: () => this._alignFromPlacement(this.placement),
123
- offset: () => this.offset,
124
- styleVars: () => DROPDOWN_STYLE_VARS,
125
- flip: () => this.flip,
126
- shift: () => this.shift,
127
- onSideResolved: (side) => {
128
- if (this._resolvedSide !== side) {
129
- this._resolvedSide = side;
130
- this._updateHostClasses();
131
- }
132
- }
133
- });
134
- this.placement = "bottom-start";
135
- this.trigger = "click";
136
- this.size = "md";
137
- this.color = "primary";
138
- this.modelValue = false;
139
- this.disabled = false;
140
- this.flip = true;
141
- this.shift = true;
142
- this.offset = 4;
143
- this.closeOnOutsideClick = true;
144
- this.closeOnEscape = true;
145
- this.cssClass = {};
146
- this.cssClassName = "";
147
- this._resolvedSide = "bottom";
148
- this._triggerListenersAttached = false;
149
- this._attachedTriggerNodes = [];
150
- this._appliedHostClasses = /* @__PURE__ */ new Set();
151
- this._viewportBound = false;
152
- this._viewportFrame = 0;
153
- this._documentBound = false;
154
- this._handleTriggerClick = (event) => {
155
- if (this.disabled || this.trigger !== "click") return;
156
- event.stopPropagation();
157
- this._setOpen(!this.modelValue, "trigger", event);
158
- };
159
- this._handleTriggerHoverIn = (event) => {
160
- if (this.disabled || this.trigger !== "hover" || this.modelValue) return;
161
- this._setOpen(true, "hover", event);
162
- };
163
- this._handleTriggerHoverOut = (event) => {
164
- if (this.disabled || this.trigger !== "hover" || !this.modelValue) return;
165
- this._setOpen(false, "hover", event);
166
- };
167
- this._handleTriggerKeydown = (event) => {
168
- if (this.disabled || this.trigger !== "click") return;
169
- if (event.key === "Enter" || event.key === " ") {
170
- event.preventDefault();
171
- this._setOpen(!this.modelValue, "trigger", event);
172
- }
173
- };
174
- this._handleDocumentClick = (event) => {
175
- if (!this.modelValue || !this.closeOnOutsideClick) return;
176
- const path = event.composedPath();
177
- if (path.includes(this) || this._popup.containsInPath(path)) return;
178
- this._setOpen(false, "outside", event);
179
- };
180
- this._handleDocumentKeydown = (event) => {
181
- if (!this.modelValue || !this.closeOnEscape || event.key !== "Escape") return;
182
- const path = event.composedPath();
183
- if (this._popup.ownsNestedInPath(path) || this._popup.inLayerAbove(path)) return;
184
- event.preventDefault();
185
- this._setOpen(false, "escape", event);
186
- };
187
- this._handleViewportChange = () => {
188
- if (!this.modelValue || this._viewportFrame) return;
189
- this._viewportFrame = requestAnimationFrame(() => {
190
- this._viewportFrame = 0;
191
- if (this.modelValue) this._positionPanel();
192
- });
193
- };
194
- defineHybridPropAliases(this, [
195
- "modelValue",
196
- "closeOnOutsideClick",
197
- "closeOnEscape"
198
- ]);
199
- defineCssClassAliases(this, (value) => this._setCssClass(value));
200
- }
201
- static get observedAttributes() {
202
- return [
203
- ...super.observedAttributes ?? [],
204
- "modelvalue",
205
- "closeonoutsideclick",
206
- "closeonescape",
207
- "css-class",
208
- "cssclass"
209
- ];
210
- }
211
- attributeChangedCallback(name, oldValue, newValue) {
212
- super.attributeChangedCallback(name, oldValue, newValue);
213
- if (oldValue === newValue) return;
214
- if (name === "modelvalue") this.modelValue = this._toBoolean(newValue);
215
- else if (name === "closeonoutsideclick") this.closeOnOutsideClick = this._toBoolean(newValue);
216
- else if (name === "closeonescape") this.closeOnEscape = this._toBoolean(newValue);
217
- else if (name === "css-class" || name === "cssclass") this._setCssClass(newValue);
218
- }
219
- connectedCallback() {
220
- super.connectedCallback();
221
- this._resolvedSide = this._sideFromPlacement(this.placement);
222
- this._updateHostClasses();
223
- if (isServer) return;
224
- if (this.modelValue) {
225
- this._bindViewport();
226
- this._bindDocument();
227
- }
228
- }
229
- disconnectedCallback() {
230
- this._unbindDocument();
231
- this._unbindViewport();
232
- this._detachTriggerListeners();
233
- super.disconnectedCallback();
234
- }
235
- updated(changed) {
236
- super.updated(changed);
237
- this._updateHostClasses();
238
- this._syncTriggerListeners();
239
- if (this.modelValue) {
240
- this._bindViewport();
241
- this._bindDocument();
242
- if (changed.has("modelValue")) this._popup.reposition();
243
- this._positionPanel();
244
- } else {
245
- this._unbindViewport();
246
- this._unbindDocument();
247
- }
248
- }
249
- /**
250
- * Outside-click / Escape listeners, bound while OPEN only (select's rule). Both handlers
251
- * bail when closed, so at rest they cost only dispatch — two `document` listeners per
252
- * dropdown (one capture-phase) in the path of every click and keystroke on the page.
253
- */
254
- _bindDocument() {
255
- if (isServer || this._documentBound) return;
256
- this._documentBound = true;
257
- document.addEventListener("click", this._handleDocumentClick, true);
258
- document.addEventListener("keydown", this._handleDocumentKeydown);
259
- }
260
- _unbindDocument() {
261
- if (isServer || !this._documentBound) return;
262
- this._documentBound = false;
263
- document.removeEventListener("click", this._handleDocumentClick, true);
264
- document.removeEventListener("keydown", this._handleDocumentKeydown);
265
- }
266
- _toBoolean(value) {
267
- if (typeof value === "boolean") return value;
268
- if (typeof value === "string") {
269
- const normalized = value.toLowerCase().trim();
270
- return normalized === "" || normalized === "true";
271
- }
272
- return Boolean(value);
273
- }
274
- _setCssClass(value) {
275
- applyCssClass(this, value);
276
- }
277
- _cls(base, key) {
278
- return cssPart(this.cssClass, base, key);
279
- }
280
- _sideFromPlacement(p) {
281
- if (p.startsWith("top")) return "top";
282
- if (p.startsWith("left")) return "left";
283
- if (p.startsWith("right")) return "right";
284
- return "bottom";
285
- }
286
- _alignFromPlacement(p) {
287
- if (p.endsWith("-start")) return "start";
288
- if (p.endsWith("-end")) return "end";
289
- return "center";
290
- }
291
- /**
292
- * The Basecoat styling attributes for the ROOT, mirroring the props one for
293
- * one. `side` and `align` are the RESOLVED pair (upstream splits placement
294
- * that way, and flip/shift can move the side at runtime) while
295
- * `mono-placement` keeps the prop itself visible for a consumer's own CSS.
296
- * A value at its default emits nothing, so `:not([mono-size])` is md.
297
- */
298
- _computeRootAttrs() {
299
- const align = this._alignFromPlacement(this.placement);
300
- const side = this.modelValue ? this._resolvedSide : this._sideFromPlacement(this.placement);
301
- return {
302
- "mono-size": this.size === "md" ? null : this.size,
303
- "mono-color": this.color === "primary" ? null : this.color,
304
- "mono-placement": this.placement === "bottom-start" ? null : this.placement,
305
- "mono-side": side === "bottom" ? null : side,
306
- "mono-align": align === "start" ? null : align,
307
- "mono-trigger": this.trigger === "click" ? null : this.trigger,
308
- "mono-open": this.modelValue ? "" : null,
309
- "mono-disabled": this.disabled ? "" : null,
310
- "mono-fixed": ""
311
- };
312
- }
313
- /** Write {@link _computeRootAttrs} onto whichever element carries the root. */
314
- _applyRootAttrs(root) {
315
- if (!root) return;
316
- if (!root.hasAttribute("mono-dropdown")) root.setAttribute("mono-dropdown", "");
317
- for (const [name, value] of Object.entries(this._computeRootAttrs())) if (value === null) root.removeAttribute(name);
318
- else if (root.getAttribute(name) !== value) root.setAttribute(name, value);
319
- }
320
- _computeHostClasses() {
321
- return [
322
- "mono-dropdown",
323
- this.size,
324
- this.color,
325
- this.placement,
326
- `is-${this._resolvedSide}`,
327
- "is-fixed",
328
- this.modelValue ? "open" : null,
329
- this.disabled ? "disabled" : null,
330
- this.cssClassName || null,
331
- this.cssClass?.root || null
332
- ].filter((c) => Boolean(c));
333
- }
334
- /**
335
- * Apply the computed state classes. The LIGHT build renders into `this`, so
336
- * the classes go on the host element (imperatively). The SHADOW build
337
- * overrides this to a no-op and instead renders the classes onto an inner
338
- * `.mono-dropdown` root in `render()` — the host's `class` is controlled by
339
- * the framework (Vue) and would otherwise wipe imperatively-added classes
340
- * (e.g. `open`) on every re-render.
341
- */
342
- _updateHostClasses() {
343
- if (isServer) return;
344
- this._applyRootAttrs(this);
345
- const next = new Set(this._computeHostClasses());
346
- for (const cls of this._appliedHostClasses) if (!next.has(cls)) this.classList.remove(cls);
347
- for (const cls of next) if (!this._appliedHostClasses.has(cls)) this.classList.add(cls);
348
- this._appliedHostClasses = next;
349
- }
350
- _setOpen(next, source, sourceEvent) {
351
- if (this.disabled && next) return;
352
- if (this.modelValue === next) return;
353
- const oldValue = this.modelValue;
354
- this.modelValue = next;
355
- const detail = {
356
- modelValue: next,
357
- currentValue: next,
358
- oldValue,
359
- value: next,
360
- source,
361
- sourceEvent,
362
- resolvedSide: this._resolvedSide
363
- };
364
- dispatchMonoEvent(this, "click", detail, { alias: "toggle" });
365
- dispatchMonoEvent(this, next ? "open" : "close", detail);
366
- }
367
- show(source = "manual") {
368
- this._setOpen(true, source);
369
- }
370
- hide(source = "manual") {
371
- this._setOpen(false, source);
372
- }
373
- toggle(source = "manual") {
374
- this._setOpen(!this.modelValue, source);
375
- }
376
- focus() {
377
- this._firstMainElement()?.focus();
378
- }
379
- blur() {
380
- this._firstMainElement()?.blur();
381
- }
382
- _firstMainElement() {
383
- for (const node of this._activeMainNodes()) return node;
384
- return null;
385
- }
386
- /**
387
- * The activator element(s) projected into the `main` slot. Overridden per
388
- * build (light: captured nodes; shadow: main slot's assignedElements).
389
- */
390
- _activeMainNodes() {
391
- return [];
392
- }
393
- _syncTriggerListeners() {
394
- if (isServer) return;
395
- const next = this._activeMainNodes();
396
- if (next.length === this._attachedTriggerNodes.length && next.every((n, i) => n === this._attachedTriggerNodes[i]) && this._triggerListenersAttached) return;
397
- this._detachTriggerListeners();
398
- for (const node of next) {
399
- node.addEventListener("click", this._handleTriggerClick);
400
- node.addEventListener("keydown", this._handleTriggerKeydown);
401
- node.addEventListener("mouseenter", this._handleTriggerHoverIn);
402
- node.addEventListener("mouseleave", this._handleTriggerHoverOut);
403
- }
404
- this._attachedTriggerNodes = next;
405
- this._triggerListenersAttached = next.length > 0;
406
- }
407
- _detachTriggerListeners() {
408
- for (const node of this._attachedTriggerNodes) {
409
- node.removeEventListener("click", this._handleTriggerClick);
410
- node.removeEventListener("keydown", this._handleTriggerKeydown);
411
- node.removeEventListener("mouseenter", this._handleTriggerHoverIn);
412
- node.removeEventListener("mouseleave", this._handleTriggerHoverOut);
413
- }
414
- this._attachedTriggerNodes = [];
415
- this._triggerListenersAttached = false;
416
- }
417
- /**
418
- * Listen for viewport movement — but ONLY while this dropdown is open.
419
- *
420
- * These used to be bound in `connectedCallback`, so every dropdown on the page
421
- * held a capture-phase `scroll` listener on `window` whether or not it was open,
422
- * and each one ran a forced layout per scroll event. A non-passive capture
423
- * listener on `window` also disqualifies the whole page's scrolling from running
424
- * off the compositor thread; nothing here calls `preventDefault`, so `passive`.
425
- */
426
- _bindViewport() {
427
- if (isServer || this._viewportBound) return;
428
- window.addEventListener("scroll", this._handleViewportChange, {
429
- capture: true,
430
- passive: true
431
- });
432
- window.addEventListener("resize", this._handleViewportChange, { passive: true });
433
- this._viewportBound = true;
434
- }
435
- _unbindViewport() {
436
- if (isServer) return;
437
- if (this._viewportFrame) {
438
- cancelAnimationFrame(this._viewportFrame);
439
- this._viewportFrame = 0;
440
- }
441
- if (!this._viewportBound) return;
442
- window.removeEventListener("scroll", this._handleViewportChange, true);
443
- window.removeEventListener("resize", this._handleViewportChange);
444
- this._viewportBound = false;
445
- }
446
- /**
447
- * Place the panel against its trigger.
448
- *
449
- * SHADOW build in practice: the light build's panel is relocated into a body
450
- * portal and `PopupPortalController` positions it there (from its
451
- * `hostUpdated`, and again from `updated()` once the activator is placed). Both
452
- * paths therefore run the SAME shared math — main-axis flip, cross-axis align
453
- * flip, shift, and painted-extent measurement. This method used to carry its
454
- * own copy of that algorithm, which is precisely how it came to be missing
455
- * all of the above; `dropdown-table-core` already delegates the same way.
456
- */
457
- _positionPanel() {
458
- if (isServer) return;
459
- const panel = this.renderRoot.querySelector(".mono-dropdown-panel");
460
- if (!panel) return;
461
- const main = this._firstMainElement();
462
- if (!main) {
463
- panel.style.top = "";
464
- panel.style.left = "";
465
- panel.style.right = "";
466
- panel.style.bottom = "";
467
- return;
468
- }
469
- const placement = computePopupPlacement(main, panel, {
470
- side: this._sideFromPlacement(this.placement),
471
- align: this._alignFromPlacement(this.placement),
472
- offset: this.offset,
473
- flip: this.flip,
474
- shift: this.shift
475
- });
476
- applyPopupPlacement(panel, placement);
477
- if (this._resolvedSide !== placement.side) {
478
- this._resolvedSide = placement.side;
479
- this._updateHostClasses();
480
- }
481
- }
482
- }
483
- __decorate([property({ type: String })], MonoDropdownCoreClass.prototype, "placement", void 0);
484
- __decorate([property({ type: String })], MonoDropdownCoreClass.prototype, "trigger", void 0);
485
- __decorate([property({ type: String })], MonoDropdownCoreClass.prototype, "size", void 0);
486
- __decorate([property({ type: String })], MonoDropdownCoreClass.prototype, "color", void 0);
487
- __decorate([property({
488
- attribute: "model-value",
489
- reflect: true,
490
- converter: booleanStringConverter
491
- })], MonoDropdownCoreClass.prototype, "modelValue", void 0);
492
- __decorate([property({
493
- reflect: true,
494
- converter: booleanStringConverter
495
- })], MonoDropdownCoreClass.prototype, "disabled", void 0);
496
- __decorate([property({ converter: booleanStringConverter })], MonoDropdownCoreClass.prototype, "flip", void 0);
497
- __decorate([property({ converter: booleanStringConverter })], MonoDropdownCoreClass.prototype, "shift", void 0);
498
- __decorate([property({ converter: numberStringConverter })], MonoDropdownCoreClass.prototype, "offset", void 0);
499
- __decorate([property({
500
- attribute: "close-on-outside-click",
501
- converter: booleanStringConverter
502
- })], MonoDropdownCoreClass.prototype, "closeOnOutsideClick", void 0);
503
- __decorate([property({
504
- attribute: "close-on-escape",
505
- converter: booleanStringConverter
506
- })], MonoDropdownCoreClass.prototype, "closeOnEscape", void 0);
507
- __decorate([property({ attribute: false })], MonoDropdownCoreClass.prototype, "cssClass", void 0);
508
- __decorate([property({ attribute: false })], MonoDropdownCoreClass.prototype, "cssClassName", void 0);
509
- __decorate([state()], MonoDropdownCoreClass.prototype, "_resolvedSide", void 0);
510
- return MonoDropdownCoreClass;
511
- };
512
-
513
- //#endregion
514
9
  //#region src/components/dropdown/mono-dropdown.ts
515
10
  let MonoDropdown = class MonoDropdown extends MonoDropdownCore(LitElement) {
516
11
  constructor(..._args) {