@mono-lit/helper 0.0.9 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/dist/accordion-core-DaNyPWRr.js +277 -0
  2. package/dist/alert-core-DWtHbX_-.js +134 -0
  3. package/dist/breadcrumb-list-core-Dh68T8Cf.js +747 -0
  4. package/dist/{mono-button-CLkHg3WW.js → button-core-DerXg84Q.js} +3 -276
  5. package/dist/button-dropdown-core-DKYEOyjy.js +654 -0
  6. package/dist/button-utils-D5-66M02.js +63 -0
  7. package/dist/card-utils-l80qAmrN.js +312 -0
  8. package/dist/chart-core-DV7hD3ZY.js +801 -0
  9. package/dist/checkbox-utils-DKdrhAzF.js +337 -0
  10. package/dist/chip-utils-DpRrd7Zj.js +403 -0
  11. package/dist/{data-source-controller-C6C4ej_M.js → data-source-controller-DS_JLrmS.js} +1 -1
  12. package/dist/{data-source-options-fxT5QIX4.js → data-source-options-DJUNU26C.js} +6 -6
  13. package/dist/{data-source-read-BL266IW0.js → data-source-read-uKJpRAzx.js} +2 -2
  14. package/dist/date-core-CyuSyvvG.js +734 -0
  15. package/dist/drawer-core-DbFWvNln.js +759 -0
  16. package/dist/dropdown-core-BCH1pK14.js +511 -0
  17. package/dist/dropdown-table-core-SfHUJVFq.js +1342 -0
  18. package/dist/export.js +1 -1
  19. package/dist/{field-path-BabiMrrA.js → field-path-DK2VBWHl.js} +1 -1
  20. package/dist/field-tooltip.css_raw-DVblekCl.js +5 -0
  21. package/dist/{field-validation.css_raw-Cx6SGrfP.js → field-validation.css_raw-BU7C6173.js} +1 -170
  22. package/dist/file-upload-core-Cz_dBQMx.js +624 -0
  23. package/dist/filter-builder-core-DyWjbBP7.js +381 -0
  24. package/dist/{filter-builder-B6Y2mmbM.js → filter-builder-vbqIuPhX.js} +1 -1
  25. package/dist/{filter-eval-ChDSaAUH.js → filter-eval-CqeBnMYh.js} +1 -1
  26. package/dist/{filter-odata-Bi27XUpQ.js → filter-odata-GsczYKNC.js} +1 -1
  27. package/dist/{hydration-flush-BaE9gN3C.js → hydration-flush-Volt9X7Q.js} +2 -1071
  28. package/dist/index.js +11 -11
  29. package/dist/{index.node-DTqDBca7.js → index.node-Csy9zrr1.js} +4 -4
  30. package/dist/index.node.js +11 -11
  31. package/dist/input-utils-BglY-k0H.js +1145 -0
  32. package/dist/menu-core-DkAYuCZ2.js +831 -0
  33. package/dist/modal-core-CSBSPN_m.js +844 -0
  34. package/dist/mono-button-DVvZ03P-.js +280 -0
  35. package/dist/{mono-button.shadow-DqZMpcqY.js → mono-button.shadow-BANxMGln.js} +6 -594
  36. package/dist/{mono-data-chart-NKPdAgVq.js → mono-data-chart-ChF4J9RT.js} +6 -6
  37. package/dist/{mono-data-dropdown-B2iRpJuI.js → mono-data-dropdown-Bgj2PDfm.js} +1 -1
  38. package/dist/{mono-data-grid-llJCX9MC.js → mono-data-grid-DJkp96N-.js} +144 -46
  39. package/dist/{mono-event-BPku9HpS.js → mono-event-CAZf0F_k.js} +14 -9
  40. package/dist/{mono-form-controller-BrA10erm.js → mono-form-controller-DxZLvyg6.js} +2 -1
  41. package/dist/mono-table-checkbox-core-BKOMx8R5.js +5288 -0
  42. package/dist/nav-core-B5qU2dzn.js +225 -0
  43. package/dist/{normalize-error-D93O4q8g.js → normalize-error-BEcd1tmS.js} +2 -2
  44. package/dist/nuxt.js +1 -1
  45. package/dist/otp-core-DXg3vFLh.js +758 -0
  46. package/dist/radio-utils-Dk9Tl1jz.js +319 -0
  47. package/dist/rich-text-editor-core-Ddd_QaLn.js +1280 -0
  48. package/dist/select-utils-BgArYHk8.js +2140 -0
  49. package/dist/sidebar-core-CD6txDo3.js +583 -0
  50. package/dist/slider-core-vcWr321-.js +1014 -0
  51. package/dist/src/components/dropdown-table/dropdown-table-core.d.ts +2 -2
  52. package/dist/src/components/dropdown-table/dropdown-table-types.d.ts +1 -1
  53. package/dist/src/components/dropdown-table/index.d.ts +1 -1
  54. package/dist/src/components/dropdown-table/index.shadow.d.ts +1 -1
  55. package/dist/src/components/dropdown-table/mono-data-dropdown.d.ts +1 -1
  56. package/dist/src/components/form/form-types.d.ts +9 -3
  57. package/dist/src/components/input/input-core.d.ts +1 -1
  58. package/dist/src/components/input/input-types.d.ts +1 -1
  59. package/dist/src/components/otp/otp-core.d.ts +1 -1
  60. package/dist/src/components/select/select-core.d.ts +1 -1
  61. package/dist/src/components/select/select-types.d.ts +1 -1
  62. package/dist/src/components/slider/slider-core.d.ts +1 -1
  63. package/dist/src/components/slider/slider-types.d.ts +1 -1
  64. package/dist/src/components/table/filter-suggestion.d.ts +171 -0
  65. package/dist/src/components/table/index.d.ts +5 -4
  66. package/dist/src/components/table/index.shadow.d.ts +5 -4
  67. package/dist/src/components/table/mono-data-grid.d.ts +22 -3
  68. package/dist/src/components/table/mono-table-empty-core.d.ts +37 -0
  69. package/dist/src/components/table/mono-table-search-core.d.ts +22 -3
  70. package/dist/src/components/table/table-types.d.ts +74 -4
  71. package/dist/src/components/tag-input/tag-input-core.d.ts +1 -1
  72. package/dist/src/components/tag-input/tag-input-types.d.ts +1 -1
  73. package/dist/src/components/textarea/textarea-core.d.ts +1 -1
  74. package/dist/src/composables/mono-event.d.ts +7 -1
  75. package/dist/src/entries/index.d.ts +8 -6
  76. package/dist/src/entries/index.node.d.ts +8 -6
  77. package/dist/src/search/index.d.ts +1 -1
  78. package/dist/src/utils/group-count.d.ts +36 -0
  79. package/dist/switch-utils-CTZ4id2V.js +338 -0
  80. package/dist/tabs-core-r5-B8k_N.js +317 -0
  81. package/dist/tag-input-utils-D2JA90DQ.js +3060 -0
  82. package/dist/textarea-utils-VU1KeXm8.js +821 -0
  83. package/dist/ui/accordion.js +2 -274
  84. package/dist/ui/alert.js +2 -131
  85. package/dist/ui/breadcrumb.js +4 -745
  86. package/dist/ui/button-dropdown.js +4 -652
  87. package/dist/ui/button.js +2 -63
  88. package/dist/ui/card.js +2 -310
  89. package/dist/ui/chart.js +4 -800
  90. package/dist/ui/checkbox.js +4 -335
  91. package/dist/ui/chip.js +4 -402
  92. package/dist/ui/date.js +3 -732
  93. package/dist/ui/drawer.js +3 -757
  94. package/dist/ui/dropdown-table.js +5 -1341
  95. package/dist/ui/dropdown.js +4 -509
  96. package/dist/ui/file-upload.js +3 -622
  97. package/dist/ui/filter.js +5 -380
  98. package/dist/ui/form.js +1 -1
  99. package/dist/ui/index.css +118 -1
  100. package/dist/ui/input.js +3 -1141
  101. package/dist/ui/menu.js +4 -828
  102. package/dist/ui/modal.js +4 -843
  103. package/dist/ui/nav.js +4 -223
  104. package/dist/ui/otp.js +4 -756
  105. package/dist/ui/radio.js +4 -317
  106. package/dist/ui/rich-text-editor.js +4 -1278
  107. package/dist/ui/select.js +5 -2138
  108. package/dist/ui/shadow/accordion.js +4 -273
  109. package/dist/ui/shadow/alert.js +4 -130
  110. package/dist/ui/shadow/breadcrumb.js +5 -744
  111. package/dist/ui/shadow/button-dropdown.js +6 -652
  112. package/dist/ui/shadow/button.js +3 -63
  113. package/dist/ui/shadow/card.js +4 -309
  114. package/dist/ui/shadow/chart.js +6 -1576
  115. package/dist/ui/shadow/checkbox.js +4 -334
  116. package/dist/ui/shadow/chip.js +4 -396
  117. package/dist/ui/shadow/date.js +7 -731
  118. package/dist/ui/shadow/drawer.js +4 -756
  119. package/dist/ui/shadow/dropdown-table.js +8 -1762
  120. package/dist/ui/shadow/dropdown.js +4 -508
  121. package/dist/ui/shadow/file-upload.js +4 -620
  122. package/dist/ui/shadow/filter.js +7 -379
  123. package/dist/ui/shadow/input.js +6 -1140
  124. package/dist/ui/shadow/menu.js +5 -828
  125. package/dist/ui/shadow/modal.js +6 -1063
  126. package/dist/ui/shadow/nav.js +5 -223
  127. package/dist/ui/shadow/otp.js +6 -754
  128. package/dist/ui/shadow/radio.js +4 -316
  129. package/dist/ui/shadow/rich-text-editor.js +4 -1276
  130. package/dist/ui/shadow/select.js +6 -2136
  131. package/dist/ui/shadow/sidebar.js +5 -581
  132. package/dist/ui/shadow/slider.js +5 -1010
  133. package/dist/ui/shadow/switch.js +4 -335
  134. package/dist/ui/shadow/table.js +10 -4501
  135. package/dist/ui/shadow/tabs.js +6 -315
  136. package/dist/ui/shadow/tag-input.js +7 -3057
  137. package/dist/ui/shadow/textarea.js +6 -817
  138. package/dist/ui/sidebar.js +3 -581
  139. package/dist/ui/slider.js +4 -1012
  140. package/dist/ui/switch.js +4 -336
  141. package/dist/ui/table.js +9 -4502
  142. package/dist/ui/tabs.js +4 -315
  143. package/dist/ui/tag-input.js +5 -3058
  144. package/dist/ui/textarea.js +4 -819
  145. package/dist/{vite-CivRCJaf.js → vite-CfW7z2wn.js} +21 -14
  146. package/dist/vite.js +1 -1
  147. package/dist/vue.d.ts +3 -2
  148. package/package.json +10 -11
  149. package/dist/chip-strip-bNfLn52Z.js +0 -215
  150. package/dist/data-source-controller-Dx6IQ2CN.js +0 -243
  151. package/dist/data-source-options-BM4r4PRw.js +0 -558
  152. package/dist/data-source-read-HyBCRg1t.js +0 -242
  153. package/dist/excel-BXzr3uI1.js +0 -784
  154. package/dist/export-ixRdCS2y.js +0 -2388
  155. package/dist/field-tooltip-addon-CWCp19mJ.js +0 -702
  156. package/dist/field-tooltip.css_raw-U5UeTa2d.js +0 -269
  157. package/dist/filter-builder-C0T3pMx2.js +0 -208
  158. package/dist/form-control-core-BbiACMtL.js +0 -226
  159. package/dist/icon-ClxnYhBG.js +0 -19
  160. package/dist/import-Dc4eXC02.js +0 -612
  161. package/dist/light-slots-_no0r2Z-.js +0 -246
  162. package/dist/markdown-uGlE_OfJ.js +0 -20191
  163. package/dist/mono-data-grid-e9ZVBlNN.js +0 -4240
  164. package/dist/normalize-error-BmLbgANw.js +0 -1048
@@ -0,0 +1,734 @@
1
+ import { d as buildSizeStyle } from "./mono-ui-kvLVIf1V.js";
2
+ import { a as defineHybridPropAliases, r as booleanStringConverter, t as __decorate } from "./decorate-DbYFpi8R.js";
3
+ import { t as dispatchMonoEvent } from "./mono-event-CAZf0F_k.js";
4
+ import { t as MonoFormControlCore } from "./form-control-core-CRZPZ1ru.js";
5
+ import { t as FieldTooltipController } from "./field-tooltip-Csk4s2ve.js";
6
+ import { t as FieldValidationController } from "./field-validation-CFmUmuDx.js";
7
+ import { html, isServer, nothing } from "lit";
8
+ import { property, query, state } from "lit/decorators.js";
9
+ import { ifDefined } from "lit/directives/if-defined.js";
10
+ import { styleMap } from "lit/directives/style-map.js";
11
+
12
+ //#region src/components/date/date-core.ts
13
+ const numberStringConverter = {
14
+ fromAttribute(value) {
15
+ if (value === null || value === "") return void 0;
16
+ const parsed = Number(value);
17
+ return Number.isFinite(parsed) ? parsed : void 0;
18
+ },
19
+ toAttribute(value) {
20
+ return value === void 0 || value === null ? null : String(value);
21
+ }
22
+ };
23
+ let _uid = 0;
24
+ /**
25
+ * `MonoDateCore` — render-mode-agnostic logic for `mono-date` (props, hybrid
26
+ * aliases, flatpickr instance lifecycle, validation/state, and the full
27
+ * `render()`). SSR-safe: all DOM/`window` access (flatpickr init in
28
+ * `firstUpdated`, the accent read in `_onReady`) is `isServer`-guarded, so the
29
+ * server emits only the field markup and flatpickr is created on the client after
30
+ * hydration. Each build supplies `createRenderRoot()` + `static styles`. Mirrors
31
+ * `textarea-core`/`switch-core`.
32
+ *
33
+ * `mono-date` has no named slots — all content comes from props — so there is no
34
+ * slot capture/scan machinery here. The calendar popup is owned by flatpickr
35
+ * (appended to `<body>`, client-only, styled by the global bundle), so this needs
36
+ * no `PopupPortalController`/`popup-stack`.
37
+ */
38
+ const MonoDateCore = (superClass) => {
39
+ class MonoDateCoreClass extends MonoFormControlCore(superClass) {
40
+ constructor(...args) {
41
+ super(...args);
42
+ this.type = "date";
43
+ this.modelValue = "";
44
+ this.size = "md";
45
+ this.color = "primary";
46
+ this.variant = "outlined";
47
+ this.labelPosition = "top";
48
+ this.validationPosition = "bottom";
49
+ this.tooltip = null;
50
+ this._tooltip = new FieldTooltipController(this, () => this.tooltip);
51
+ this._validation = new FieldValidationController(this, () => ({
52
+ position: this.validationPosition,
53
+ ...this._validationNotice ?? {
54
+ state: void 0,
55
+ text: void 0
56
+ },
57
+ suppressed: !!this._fp?.isOpen
58
+ }), () => this.renderRoot?.querySelector?.("[mono-date] > [mono-field]"));
59
+ this.error = false;
60
+ this.success = false;
61
+ this.disabled = false;
62
+ this.readonly = false;
63
+ this.required = false;
64
+ this.clearable = false;
65
+ this.cssClass = {};
66
+ this.cssClassName = "";
67
+ this._hasValue = false;
68
+ this._fp = null;
69
+ this._buildToken = 0;
70
+ this._id = `mono-date-${++_uid}`;
71
+ this._onTyping = (event) => {
72
+ if (!this._fp || !this._typeable || this.disabled || this.readonly) return;
73
+ if (this.mode === "range" || this.mode === "multiple") return;
74
+ const raw = event.target.value;
75
+ if (!raw.trim()) return;
76
+ const fmt = this._fp.config.dateFormat;
77
+ const parsed = this._fp.parseDate(raw, fmt);
78
+ if (!parsed) return;
79
+ this._fp.jumpToDate(parsed);
80
+ if (this._fp.formatDate(parsed, fmt) === raw) this._fp.setDate(parsed, true);
81
+ };
82
+ defineHybridPropAliases(this, [
83
+ "labelPosition",
84
+ "validationPosition",
85
+ "modelValue",
86
+ "helperText",
87
+ "validationState",
88
+ "validationMessage",
89
+ "errorMessage",
90
+ "successMessage",
91
+ "ariaLabelText",
92
+ "cssClass",
93
+ "dateFormat",
94
+ "altInput",
95
+ "altFormat",
96
+ "clickOpens",
97
+ "defaultDate",
98
+ "minDate",
99
+ "maxDate",
100
+ "enableSeconds",
101
+ "hourIncrement",
102
+ "minuteIncrement",
103
+ "defaultHour",
104
+ "defaultMinute",
105
+ "weekNumbers",
106
+ "monthSelectorType",
107
+ "shorthandCurrentMonth",
108
+ "ariaDateFormat",
109
+ "minWidth",
110
+ "maxWidth",
111
+ "minHeight",
112
+ "maxHeight"
113
+ ]);
114
+ Object.defineProperty(this, "css-class", {
115
+ get: () => this.cssClass,
116
+ set: (value) => this._setCssClass(value),
117
+ configurable: true,
118
+ enumerable: false
119
+ });
120
+ Object.defineProperty(this, "cssclass", {
121
+ get: () => this.cssClass,
122
+ set: (value) => this._setCssClass(value),
123
+ configurable: true,
124
+ enumerable: false
125
+ });
126
+ }
127
+ static get observedAttributes() {
128
+ return [
129
+ ...super.observedAttributes ?? [],
130
+ "modelvalue",
131
+ "css-class",
132
+ "cssclass"
133
+ ];
134
+ }
135
+ attributeChangedCallback(name, oldValue, newValue) {
136
+ super.attributeChangedCallback(name, oldValue, newValue);
137
+ if (oldValue === newValue) return;
138
+ if (name === "modelvalue") {
139
+ this.modelValue = newValue ?? "";
140
+ return;
141
+ }
142
+ if (name === "css-class" || name === "cssclass") this._setCssClass(newValue);
143
+ }
144
+ /**
145
+ * Normalized `typeable` flag. Frameworks (e.g. Vue) set a bare boolean
146
+ * attribute as the *property* `''` — which bypasses `booleanStringConverter`
147
+ * and is falsy. Treat presence (`''`/`true`/`'true'`) as enabled so typing
148
+ * actually works.
149
+ */
150
+ get _typeable() {
151
+ const v = this.typeable;
152
+ return v === true || v === "" || v === "true";
153
+ }
154
+ static {
155
+ this._configKeys = [
156
+ "type",
157
+ "options",
158
+ "mode",
159
+ "inline",
160
+ "locale",
161
+ "dateFormat",
162
+ "altInput",
163
+ "altFormat",
164
+ "typeable",
165
+ "clickOpens",
166
+ "defaultDate",
167
+ "minDate",
168
+ "maxDate",
169
+ "disable",
170
+ "enable",
171
+ "enableSeconds",
172
+ "time24hr",
173
+ "hourIncrement",
174
+ "minuteIncrement",
175
+ "defaultHour",
176
+ "defaultMinute",
177
+ "weekNumbers",
178
+ "monthSelectorType",
179
+ "shorthandCurrentMonth",
180
+ "position",
181
+ "ariaDateFormat",
182
+ "disabled",
183
+ "readonly"
184
+ ];
185
+ }
186
+ willUpdate(changed) {
187
+ super.willUpdate?.(changed);
188
+ for (const key of [
189
+ "error",
190
+ "success",
191
+ "disabled",
192
+ "readonly",
193
+ "required",
194
+ "clearable"
195
+ ]) {
196
+ const v = this[key];
197
+ if (typeof v !== "boolean") this[key] = this._toBoolean(v);
198
+ }
199
+ }
200
+ _toBoolean(value) {
201
+ if (typeof value === "boolean") return value;
202
+ if (typeof value === "string") {
203
+ const normalized = value.toLowerCase().trim();
204
+ return normalized === "" || normalized === "true";
205
+ }
206
+ return Boolean(value);
207
+ }
208
+ async firstUpdated() {
209
+ await this._ensurePicker();
210
+ }
211
+ /**
212
+ * Build the picker if there isn't one — idempotent, and safe to call from every
213
+ * update.
214
+ *
215
+ * Creation used to live only in `firstUpdated`, which Lit runs exactly once. After
216
+ * a disconnect (`v-if`, `<KeepAlive>`, a Vue node move) `disconnectedCallback`
217
+ * destroyed the instance and nothing ever rebuilt it, so the field rendered but had
218
+ * no picker at all — every `open`/`close`/`toggle` was a silent `this._fp?.` no-op.
219
+ * `chart-core` self-heals the same way.
220
+ *
221
+ * The `isConnected` re-check after the await matters just as much: without it, an
222
+ * element disconnected *during* the dynamic import would construct a flatpickr on a
223
+ * detached input that nothing would ever destroy — leaking its calendar DOM and the
224
+ * four document/window listeners flatpickr binds.
225
+ */
226
+ async _ensurePicker() {
227
+ if (isServer || this._fp || !this._nativeEl) return;
228
+ const token = ++this._buildToken;
229
+ const { default: flatpickr } = await import("./esm-D0We7ndD.js");
230
+ if (token !== this._buildToken || !this.isConnected || !this._nativeEl || this._fp) return;
231
+ this._fp = flatpickr(this._nativeEl, this._buildConfig());
232
+ this._hasValue = Boolean(this.modelValue);
233
+ }
234
+ updated(changed) {
235
+ super.updated?.(changed);
236
+ if (!this._fp) {
237
+ this._ensurePicker();
238
+ return;
239
+ }
240
+ if (MonoDateCoreClass._configKeys.some((k) => changed.has(k))) {
241
+ this._rebuild();
242
+ return;
243
+ }
244
+ if (changed.has("modelValue")) this._applyModelValue();
245
+ }
246
+ connectedCallback() {
247
+ super.connectedCallback();
248
+ if (!isServer) this._ensurePicker();
249
+ }
250
+ disconnectedCallback() {
251
+ this._buildToken++;
252
+ this._fp?.destroy();
253
+ this._fp = null;
254
+ super.disconnectedCallback();
255
+ }
256
+ _buildConfig() {
257
+ const typeDefaults = this.type === "time" ? {
258
+ enableTime: true,
259
+ noCalendar: true
260
+ } : this.type === "datetime" ? { enableTime: true } : {};
261
+ const named = {};
262
+ const str = (k, v) => {
263
+ if (v !== void 0 && v !== "") named[k] = v;
264
+ };
265
+ const any = (k, v) => {
266
+ if (v !== void 0) named[k] = v;
267
+ };
268
+ str("dateFormat", this.dateFormat);
269
+ any("altInput", this.altInput);
270
+ str("altFormat", this.altFormat);
271
+ any("allowInput", this._typeable);
272
+ any("clickOpens", this.clickOpens);
273
+ any("defaultDate", this.defaultDate);
274
+ any("minDate", this.minDate);
275
+ any("maxDate", this.maxDate);
276
+ any("disable", this.disable);
277
+ any("enable", this.enable);
278
+ str("mode", this.mode);
279
+ any("enableSeconds", this.enableSeconds);
280
+ any("time_24hr", this.time24hr);
281
+ any("hourIncrement", this.hourIncrement);
282
+ any("minuteIncrement", this.minuteIncrement);
283
+ any("defaultHour", this.defaultHour);
284
+ any("defaultMinute", this.defaultMinute);
285
+ any("inline", this.inline);
286
+ any("weekNumbers", this.weekNumbers);
287
+ str("monthSelectorType", this.monthSelectorType);
288
+ any("shorthandCurrentMonth", this.shorthandCurrentMonth);
289
+ str("position", this.position);
290
+ str("ariaDateFormat", this.ariaDateFormat);
291
+ any("locale", this.locale);
292
+ const config = {
293
+ ...typeDefaults,
294
+ ...this.options ?? {},
295
+ ...named,
296
+ onReady: [(_d, _s, instance) => this._onReady(instance)],
297
+ onChange: [(dates, dateStr, instance) => this._onChange(dates, dateStr, instance)],
298
+ onOpen: [(dates, _s, instance) => {
299
+ this._emitOpenClose("open", dates, instance);
300
+ this._validation.refresh();
301
+ }],
302
+ onClose: [(dates, _s, instance) => {
303
+ this._emitOpenClose("close", dates, instance);
304
+ this._validation.refresh();
305
+ }]
306
+ };
307
+ if (this.modelValue) config.defaultDate = this.modelValue;
308
+ if (this.disabled || this.readonly) config.clickOpens = false;
309
+ return config;
310
+ }
311
+ /**
312
+ * Open / close the calendar. flatpickr owns the popup, so these just forward
313
+ * to the instance — but they give `mono-date` the same `open()`/`close()`/
314
+ * `toggle()` surface as `mono-select` and `mono-dropdown-table`, which lets
315
+ * anything driving an editor generically (e.g. the data grid opening the
316
+ * focused inline editor on `Enter`) treat all of them the same.
317
+ */
318
+ /** Whether the calendar is currently open. */
319
+ get isOpen() {
320
+ return !!this._fp?.isOpen;
321
+ }
322
+ open() {
323
+ if (this.disabled || this.readonly) return;
324
+ this._fp?.open();
325
+ }
326
+ close() {
327
+ this._fp?.close();
328
+ }
329
+ toggle() {
330
+ if (this._fp?.isOpen) this.close();
331
+ else this.open();
332
+ }
333
+ _rebuild() {
334
+ if (!this._nativeEl) return;
335
+ const open = this._fp?.isOpen;
336
+ this._fp?.destroy();
337
+ this._fp = null;
338
+ const token = ++this._buildToken;
339
+ import("./esm-D0We7ndD.js").then(({ default: flatpickr }) => {
340
+ if (token !== this._buildToken || !this.isConnected || !this._nativeEl) return;
341
+ this._fp = flatpickr(this._nativeEl, this._buildConfig());
342
+ if (open) this._fp.open();
343
+ });
344
+ }
345
+ _applyModelValue() {
346
+ this._fp?.setDate(this.modelValue || "", false);
347
+ this._hasValue = Boolean(this.modelValue);
348
+ }
349
+ /**
350
+ * Tag the calendar so our CSS only targets our pickers, and copy the host's
351
+ * resolved accent onto it (the calendar lives in <body> and can't inherit the
352
+ * field's `--date-primary`, so it follows the `color` prop via `--cal-accent`).
353
+ *
354
+ * The accent variable is declared on the `.mono-date` element (the inner
355
+ * wrapper), which in the shadow build lives inside the shadow root — reading
356
+ * from the host (`this`) would return empty. Read from that wrapper instead;
357
+ * in the light build `renderRoot === this` and `.mono-date` is the child, so
358
+ * this resolves correctly for both.
359
+ */
360
+ _onReady(instance) {
361
+ if (isServer) return;
362
+ const cal = instance.calendarContainer;
363
+ if (!cal) return;
364
+ cal.classList.add("mono-flatpickr");
365
+ const scope = this.renderRoot.querySelector?.("[mono-date]") ?? this;
366
+ const cs = getComputedStyle(scope);
367
+ const accent = cs.getPropertyValue("--_mono-date-calendar-accent").trim();
368
+ const accentFg = cs.getPropertyValue("--_mono-date-primary-foreground").trim();
369
+ if (accent) cal.style.setProperty("--cal-accent", accent);
370
+ if (accentFg) cal.style.setProperty("--cal-accent-foreground", accentFg);
371
+ }
372
+ _onChange(dates, dateStr, instance) {
373
+ this.modelValue = dateStr;
374
+ this._hasValue = Boolean(dateStr);
375
+ const detail = {
376
+ value: dateStr,
377
+ modelValue: dateStr,
378
+ dates,
379
+ instance
380
+ };
381
+ const native = this._nativeEl;
382
+ let done = false;
383
+ const onNative = (event) => {
384
+ done = true;
385
+ dispatchMonoEvent(this, "change", detail, { sourceEvent: event });
386
+ };
387
+ native?.addEventListener("change", onNative, {
388
+ once: true,
389
+ capture: true
390
+ });
391
+ queueMicrotask(() => {
392
+ if (done) return;
393
+ done = true;
394
+ native?.removeEventListener("change", onNative, { capture: true });
395
+ dispatchMonoEvent(this, "change", detail);
396
+ });
397
+ }
398
+ _emitOpenClose(kind, dates, instance) {
399
+ dispatchMonoEvent(this, kind, {
400
+ dates,
401
+ instance
402
+ });
403
+ }
404
+ _clear() {
405
+ this._fp?.clear();
406
+ this.modelValue = "";
407
+ this._hasValue = false;
408
+ const detail = {
409
+ value: "",
410
+ modelValue: "",
411
+ dates: [],
412
+ instance: this._fp
413
+ };
414
+ dispatchMonoEvent(this, "change", detail);
415
+ }
416
+ _setCssClass(value) {
417
+ if (value == null) {
418
+ this.cssClass = {};
419
+ this.cssClassName = "";
420
+ return;
421
+ }
422
+ if (typeof value === "object") {
423
+ this.cssClass = value;
424
+ return;
425
+ }
426
+ if (typeof value === "string") {
427
+ const trimmed = value.trim();
428
+ if (!trimmed) {
429
+ this.cssClass = {};
430
+ this.cssClassName = "";
431
+ return;
432
+ }
433
+ if (trimmed.startsWith("{") && trimmed.endsWith("}")) try {
434
+ this.cssClass = JSON.parse(trimmed);
435
+ return;
436
+ } catch {}
437
+ this.cssClassName = trimmed;
438
+ }
439
+ }
440
+ _cls(base, key) {
441
+ const extra = this.cssClass?.[key];
442
+ return extra ? `${base} ${extra}` : base;
443
+ }
444
+ get _resolvedState() {
445
+ if (this.error) return "error";
446
+ if (this.success) return "success";
447
+ const state = this.validationState;
448
+ if (state === "invalid") return "error";
449
+ if (state === "valid") return "success";
450
+ return state ?? "default";
451
+ }
452
+ get _message() {
453
+ if (this._resolvedState === "error") return this.errorMessage || this.validationMessage || void 0;
454
+ if (this._resolvedState === "success") return this.successMessage || this.validationMessage || void 0;
455
+ return this.helperText || void 0;
456
+ }
457
+ get _wrapperClasses() {
458
+ return [
459
+ "mono-date",
460
+ this.size,
461
+ this.color,
462
+ this.variant,
463
+ this.disabled ? "disabled" : "",
464
+ this.readonly ? "readonly" : "",
465
+ this.required ? "required" : "",
466
+ this._hasValue ? "has-value" : "",
467
+ this._resolvedState !== "default" ? `is-${this._resolvedState}` : "",
468
+ this.cssClassName || "",
469
+ this.cssClass?.root || ""
470
+ ].filter(Boolean).join(" ");
471
+ }
472
+ get _fieldClasses() {
473
+ return [
474
+ this._cls("mono-date-field", "field"),
475
+ this.size,
476
+ this.color,
477
+ this.variant,
478
+ this._resolvedState !== "default" ? `is-${this._resolvedState}` : ""
479
+ ].filter(Boolean).join(" ");
480
+ }
481
+ _icon() {
482
+ return this.renderIcon(this.type === "time" ? "clock" : "calendar");
483
+ }
484
+ /**
485
+ * Icon hook. Light build (default): the global `.mono-icon` / `i-mdi-*` UnoCSS
486
+ * icon. Shadow overrides with inline SVG (UnoCSS mask rules can't reach a
487
+ * shadow root — they'd render as a solid "black cube").
488
+ */
489
+ renderIcon(name) {
490
+ return html`<span class=${`mono-icon ${name === "calendar" ? "i-mdi-calendar-outline" : name === "clock" ? "i-mdi-clock-outline" : "i-mdi-close"}`} mono-icon aria-hidden="true"></span>`;
491
+ }
492
+ /**
493
+ * The wrapper renders unconditionally, like input / select / tag-input. The
494
+ * wrapper is a grid child, so returning `nothing` when there is no message left
495
+ * date's block exactly one row-gap shorter than its siblings' — visible as soon
496
+ * as a labelled date sits beside a labelled input in the same row.
497
+ */
498
+ /** The validation message and its state — the same precedence `_message` uses. */
499
+ get _validationNotice() {
500
+ const state = this._resolvedState;
501
+ const text = state === "error" ? this.errorMessage || this.validationMessage : state === "success" ? this.successMessage || this.validationMessage : "";
502
+ return text ? {
503
+ state,
504
+ text
505
+ } : null;
506
+ }
507
+ _renderMessage() {
508
+ if (this._validation.moved) {
509
+ const notice = this._validationNotice;
510
+ return html`
511
+ <div class=${this._cls("mono-date-message-wrap", "messageWrap")} mono-message-wrap>
512
+ ${this.helperText ? html`<div class=${`${this._cls("mono-date-message", "message")} default`} mono-message="helper">${this.helperText}</div>` : nothing}
513
+ <div
514
+ class=${`${this._cls("mono-date-message", "message")} ${notice.state}`}
515
+ mono-message=${notice.state}
516
+ mono-sr-only
517
+ role=${notice.state === "error" ? "alert" : nothing}
518
+ >${notice.text}</div>
519
+ </div>
520
+ `;
521
+ }
522
+ const msg = this._message;
523
+ return html`
524
+ <div class=${this._cls("mono-date-message-wrap", "messageWrap")} mono-message-wrap>
525
+ ${msg ? html`<div
526
+ class=${`${this._cls("mono-date-message", "message")} ${this._resolvedState}`}
527
+ mono-message=${this._resolvedState === "default" ? "helper" : this._resolvedState}
528
+ role=${this._resolvedState === "error" ? "alert" : nothing}
529
+ >${msg}</div>` : nothing}
530
+ </div>
531
+ `;
532
+ }
533
+ render() {
534
+ const state = this._resolvedState;
535
+ return html`
536
+ <div
537
+ class=${this._wrapperClasses}
538
+ style=${styleMap(buildSizeStyle(this))}
539
+ mono-date
540
+ mono-size=${this.size === "md" ? nothing : this.size}
541
+ mono-color=${this.color === "primary" ? nothing : this.color}
542
+ mono-variant=${this.variant === "outlined" ? nothing : this.variant}
543
+ mono-label-position=${this.labelPosition === "top" ? nothing : this.labelPosition}
544
+ mono-validation-position=${this.validationPosition === "bottom" ? nothing : this.validationPosition}
545
+ mono-validation-state=${state === "default" ? nothing : state}
546
+ ?mono-disabled=${this.disabled}
547
+ ?mono-readonly=${this.readonly}
548
+ ?mono-required=${this.required}
549
+ ?mono-clearable=${this.clearable}
550
+ >
551
+ ${this.label ? html`<label class=${this._cls("mono-date-label", "label")} mono-label for=${this._id}>
552
+ ${this.label}${this.required ? html`<span class=${this._cls("mono-date-required", "required")} mono-required-mark>*</span>` : nothing}${this._tooltip.render()}
553
+ </label>` : nothing}
554
+
555
+ <div class=${this._fieldClasses} mono-field>
556
+ <span class=${this._cls("mono-date-icon", "icon")} mono-prefix aria-hidden="true">${this._icon()}</span>
557
+ <input
558
+ class=${this._cls("mono-date-native", "native")}
559
+ mono-native
560
+ id=${this._id}
561
+ type="text"
562
+ placeholder=${ifDefined(this.placeholder)}
563
+ ?disabled=${this.disabled}
564
+ ?readonly=${this.readonly && !this._typeable}
565
+ aria-label=${ifDefined(this.ariaLabelText || this.label || void 0)}
566
+ @input=${this._onTyping}
567
+ />
568
+ ${this._validation.renderIcon()}
569
+ ${this.clearable && this._hasValue && !this.disabled && !this.readonly ? html`<button
570
+ type="button"
571
+ class=${this._cls("mono-date-clear", "clear")}
572
+ mono-clear
573
+ aria-label="Clear"
574
+ @click=${this._clear}
575
+ >
576
+ ${this.renderIcon("close")}
577
+ </button>` : nothing}
578
+ </div>
579
+
580
+ ${this._renderMessage()}
581
+ ${this._validation.renderFloat()}
582
+ </div>
583
+ `;
584
+ }
585
+ }
586
+ __decorate([property({ type: String })], MonoDateCoreClass.prototype, "type", void 0);
587
+ __decorate([property({
588
+ attribute: "model-value",
589
+ reflect: true
590
+ })], MonoDateCoreClass.prototype, "modelValue", void 0);
591
+ __decorate([property({ type: String })], MonoDateCoreClass.prototype, "size", void 0);
592
+ __decorate([property({ type: String })], MonoDateCoreClass.prototype, "color", void 0);
593
+ __decorate([property({ type: String })], MonoDateCoreClass.prototype, "variant", void 0);
594
+ __decorate([property({
595
+ type: String,
596
+ attribute: "label-position"
597
+ })], MonoDateCoreClass.prototype, "labelPosition", void 0);
598
+ __decorate([property({
599
+ type: String,
600
+ attribute: "validation-position"
601
+ })], MonoDateCoreClass.prototype, "validationPosition", void 0);
602
+ __decorate([property({ type: String })], MonoDateCoreClass.prototype, "label", void 0);
603
+ __decorate([property({ type: String })], MonoDateCoreClass.prototype, "placeholder", void 0);
604
+ __decorate([property({
605
+ type: String,
606
+ attribute: "helper-text"
607
+ })], MonoDateCoreClass.prototype, "helperText", void 0);
608
+ __decorate([property()], MonoDateCoreClass.prototype, "tooltip", void 0);
609
+ __decorate([property({
610
+ type: String,
611
+ attribute: "validation-state"
612
+ })], MonoDateCoreClass.prototype, "validationState", void 0);
613
+ __decorate([property({
614
+ type: String,
615
+ attribute: "validation-message"
616
+ })], MonoDateCoreClass.prototype, "validationMessage", void 0);
617
+ __decorate([property({ converter: booleanStringConverter })], MonoDateCoreClass.prototype, "error", void 0);
618
+ __decorate([property({
619
+ type: String,
620
+ attribute: "error-message"
621
+ })], MonoDateCoreClass.prototype, "errorMessage", void 0);
622
+ __decorate([property({ converter: booleanStringConverter })], MonoDateCoreClass.prototype, "success", void 0);
623
+ __decorate([property({
624
+ type: String,
625
+ attribute: "success-message"
626
+ })], MonoDateCoreClass.prototype, "successMessage", void 0);
627
+ __decorate([property({
628
+ reflect: true,
629
+ converter: booleanStringConverter
630
+ })], MonoDateCoreClass.prototype, "disabled", void 0);
631
+ __decorate([property({
632
+ reflect: true,
633
+ converter: booleanStringConverter
634
+ })], MonoDateCoreClass.prototype, "readonly", void 0);
635
+ __decorate([property({
636
+ reflect: true,
637
+ converter: booleanStringConverter
638
+ })], MonoDateCoreClass.prototype, "required", void 0);
639
+ __decorate([property({ converter: booleanStringConverter })], MonoDateCoreClass.prototype, "clearable", void 0);
640
+ __decorate([property({
641
+ type: String,
642
+ attribute: "aria-label-text"
643
+ })], MonoDateCoreClass.prototype, "ariaLabelText", void 0);
644
+ __decorate([property({
645
+ type: String,
646
+ attribute: "date-format"
647
+ })], MonoDateCoreClass.prototype, "dateFormat", void 0);
648
+ __decorate([property({
649
+ attribute: "alt-input",
650
+ converter: booleanStringConverter
651
+ })], MonoDateCoreClass.prototype, "altInput", void 0);
652
+ __decorate([property({
653
+ type: String,
654
+ attribute: "alt-format"
655
+ })], MonoDateCoreClass.prototype, "altFormat", void 0);
656
+ __decorate([property({ converter: booleanStringConverter })], MonoDateCoreClass.prototype, "typeable", void 0);
657
+ __decorate([property({
658
+ attribute: "click-opens",
659
+ converter: booleanStringConverter
660
+ })], MonoDateCoreClass.prototype, "clickOpens", void 0);
661
+ __decorate([property({ attribute: "default-date" })], MonoDateCoreClass.prototype, "defaultDate", void 0);
662
+ __decorate([property({ attribute: "min-date" })], MonoDateCoreClass.prototype, "minDate", void 0);
663
+ __decorate([property({ attribute: "max-date" })], MonoDateCoreClass.prototype, "maxDate", void 0);
664
+ __decorate([property({ attribute: false })], MonoDateCoreClass.prototype, "disable", void 0);
665
+ __decorate([property({ attribute: false })], MonoDateCoreClass.prototype, "enable", void 0);
666
+ __decorate([property({ type: String })], MonoDateCoreClass.prototype, "mode", void 0);
667
+ __decorate([property({
668
+ attribute: "enable-seconds",
669
+ converter: booleanStringConverter
670
+ })], MonoDateCoreClass.prototype, "enableSeconds", void 0);
671
+ __decorate([property({
672
+ attribute: "time-24hr",
673
+ converter: booleanStringConverter
674
+ })], MonoDateCoreClass.prototype, "time24hr", void 0);
675
+ __decorate([property({
676
+ attribute: "hour-increment",
677
+ converter: numberStringConverter
678
+ })], MonoDateCoreClass.prototype, "hourIncrement", void 0);
679
+ __decorate([property({
680
+ attribute: "minute-increment",
681
+ converter: numberStringConverter
682
+ })], MonoDateCoreClass.prototype, "minuteIncrement", void 0);
683
+ __decorate([property({
684
+ attribute: "default-hour",
685
+ converter: numberStringConverter
686
+ })], MonoDateCoreClass.prototype, "defaultHour", void 0);
687
+ __decorate([property({
688
+ attribute: "default-minute",
689
+ converter: numberStringConverter
690
+ })], MonoDateCoreClass.prototype, "defaultMinute", void 0);
691
+ __decorate([property({ converter: booleanStringConverter })], MonoDateCoreClass.prototype, "inline", void 0);
692
+ __decorate([property({
693
+ attribute: "week-numbers",
694
+ converter: booleanStringConverter
695
+ })], MonoDateCoreClass.prototype, "weekNumbers", void 0);
696
+ __decorate([property({ attribute: "month-selector-type" })], MonoDateCoreClass.prototype, "monthSelectorType", void 0);
697
+ __decorate([property({
698
+ attribute: "shorthand-current-month",
699
+ converter: booleanStringConverter
700
+ })], MonoDateCoreClass.prototype, "shorthandCurrentMonth", void 0);
701
+ __decorate([property({ type: String })], MonoDateCoreClass.prototype, "position", void 0);
702
+ __decorate([property({
703
+ type: String,
704
+ attribute: "aria-date-format"
705
+ })], MonoDateCoreClass.prototype, "ariaDateFormat", void 0);
706
+ __decorate([property({ attribute: false })], MonoDateCoreClass.prototype, "locale", void 0);
707
+ __decorate([property({ attribute: false })], MonoDateCoreClass.prototype, "options", void 0);
708
+ __decorate([property({ type: String })], MonoDateCoreClass.prototype, "width", void 0);
709
+ __decorate([property({ type: String })], MonoDateCoreClass.prototype, "height", void 0);
710
+ __decorate([property({
711
+ type: String,
712
+ attribute: "min-width"
713
+ })], MonoDateCoreClass.prototype, "minWidth", void 0);
714
+ __decorate([property({
715
+ type: String,
716
+ attribute: "max-width"
717
+ })], MonoDateCoreClass.prototype, "maxWidth", void 0);
718
+ __decorate([property({
719
+ type: String,
720
+ attribute: "min-height"
721
+ })], MonoDateCoreClass.prototype, "minHeight", void 0);
722
+ __decorate([property({
723
+ type: String,
724
+ attribute: "max-height"
725
+ })], MonoDateCoreClass.prototype, "maxHeight", void 0);
726
+ __decorate([property({ attribute: false })], MonoDateCoreClass.prototype, "cssClass", void 0);
727
+ __decorate([property({ attribute: false })], MonoDateCoreClass.prototype, "cssClassName", void 0);
728
+ __decorate([state()], MonoDateCoreClass.prototype, "_hasValue", void 0);
729
+ __decorate([query(".mono-date-native")], MonoDateCoreClass.prototype, "_nativeEl", void 0);
730
+ return MonoDateCoreClass;
731
+ };
732
+
733
+ //#endregion
734
+ export { MonoDateCore as t };