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