@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,242 +0,0 @@
1
- import { c as toODataClause, n as isPath, t as getFieldValue } from "./field-path-BabiMrrA.js";
2
- import { T as andFilters } from "./normalize-error-BmLbgANw.js";
3
- import { n as unwrapReactive } from "./reactive-Dtd-esHO.js";
4
-
5
- //#region src/components/table/grouping.ts
6
- /**
7
- * Client-side grouping helpers shared by {@link monoArraySource} and
8
- * {@link monoDataGrid}. Dependency-free so @mono-lit/helper stays standalone; the
9
- * tree shape mirrors what a devextreme DataSource produces for `group`, so a
10
- * consumer can read `row.key` / `row.items[i].key` / … exactly as before.
11
- */
12
- /** Duck-type a grouped node: `{ key, items: [...] }`. */
13
- function isGroupNode(x) {
14
- return !!x && typeof x === "object" && "key" in x && Array.isArray(x.items);
15
- }
16
- /**
17
- * Recursively collect the leaf records from a possibly-grouped array. Already
18
- * flat rows pass straight through, so this safely normalises both a grouped
19
- * payload (devextreme `type:'data'` with `group`) and a plain array.
20
- */
21
- function flattenLeaves(rows) {
22
- const out = [];
23
- const walk = (list) => {
24
- for (const row of list) if (isGroupNode(row)) walk(row.items);
25
- else out.push(row);
26
- };
27
- walk(rows);
28
- return out;
29
- }
30
- /**
31
- * Bucket flat leaf records into the nested {@link MonoGroupNode} tree by
32
- * `fields` (in order). Group order follows first appearance in `rows` — the
33
- * source group-orders the rows, so a paged slice renders contiguous headers.
34
- *
35
- * @param rows Flat leaf records (already group-ordered for nice paging).
36
- * @param fields Group-by field names, outermost first.
37
- * @param collapsed Set of collapsed `path`s; matching nodes get `collapsed:true`.
38
- */
39
- function buildGroups(rows, fields, collapsed = /* @__PURE__ */ new Set()) {
40
- const build = (items, level, parentPath) => {
41
- const field = fields[level];
42
- const buckets = /* @__PURE__ */ new Map();
43
- for (const row of items) {
44
- const key = isPath(field) ? getFieldValue(row, field) : row?.[field];
45
- const keyStr = String(key);
46
- let bucket = buckets.get(keyStr);
47
- if (!bucket) {
48
- bucket = {
49
- key,
50
- rows: []
51
- };
52
- buckets.set(keyStr, bucket);
53
- }
54
- bucket.rows.push(row);
55
- }
56
- const nodes = [];
57
- for (const [keyStr, bucket] of buckets) {
58
- const path = parentPath ? `${parentPath}/${keyStr}` : keyStr;
59
- const isLast = level >= fields.length - 1;
60
- nodes.push({
61
- key: bucket.key,
62
- items: isLast ? bucket.rows : build(bucket.rows, level + 1, path),
63
- count: bucket.rows.length,
64
- level,
65
- path,
66
- collapsed: collapsed.has(path)
67
- });
68
- }
69
- return nodes;
70
- };
71
- return fields.length ? build(rows, 0, "") : [];
72
- }
73
- /** Collect every group node's `path` from a built tree (for collapse-all). */
74
- function collectGroupPaths(nodes) {
75
- const out = [];
76
- const walk = (list) => {
77
- for (const node of list) {
78
- out.push(node.path);
79
- const children = node.items;
80
- if (children.length && isGroupNode(children[0])) walk(children);
81
- }
82
- };
83
- walk(nodes);
84
- return out;
85
- }
86
-
87
- //#endregion
88
- //#region src/utils/data-source-read.ts
89
- /**
90
- * Draining a devextreme DataSource (or store) to a flat array.
91
- *
92
- * The single place that knows how to read *everything* out of a source, shared
93
- * by `monoDataGrid.getData()` and the report engine's `data` resolver. Kept
94
- * duck-typed and dependency-free — @mono-lit/helper never imports devextreme, and a
95
- * real DataSource satisfies these shapes structurally.
96
- *
97
- * The hard part isn't the loop, it's reading a source **without disturbing it**:
98
- * the same DataSource is usually bound to a live grid, so paging state must
99
- * either be left alone (the store path) or restored exactly (the array path).
100
- */
101
- /**
102
- * Store-level load options a DataSource sends on every request that have no accessor and are not
103
- * composed by the drain itself (filter / search / sort / select are). Whitelisted, not copied
104
- * wholesale: `_storeLoadOptions` also carries `group`, paging and total-count state, which would
105
- * turn a flat chunked read into something else.
106
- */
107
- const INHERITED_LOAD_OPTIONS = ["expand", "customQueryParams"];
108
- /** The {@link INHERITED_LOAD_OPTIONS} the source currently carries. */
109
- function inheritedLoadOptionsOf(source) {
110
- const lo = typeof source.loadOptions === "function" ? source.loadOptions() : null;
111
- const out = {};
112
- if (!lo || typeof lo !== "object") return out;
113
- for (const k of INHERITED_LOAD_OPTIONS) if (lo[k] !== void 0 && lo[k] !== null) out[k] = lo[k];
114
- return out;
115
- }
116
- /** Stop runaway loops if a backend keeps returning full chunks forever. */
117
- const MAX_SKIP = 1e7;
118
- /** A devextreme DataSource: it both loads and holds a current page. */
119
- function isDataSourceLike(value) {
120
- const v = value;
121
- return !!v && typeof v === "object" && typeof v.load === "function" && typeof v.items === "function";
122
- }
123
- /** A bare store (ODataStore / CustomStore / ArrayStore) — loads, but has no page. */
124
- function isStoreLike(value) {
125
- const v = value;
126
- return !!v && typeof v === "object" && typeof v.load === "function" && typeof v.items !== "function" && (typeof v.key === "function" || typeof v.byKey === "function");
127
- }
128
- /** Anything this module can drain into an array. */
129
- function isReadableSource(value) {
130
- return isDataSourceLike(value) || isStoreLike(value);
131
- }
132
- /** devextreme `store.load` resolves to either an array or `{ data, … }`. */
133
- function rowsOf(res) {
134
- return Array.isArray(res) ? res : res?.data ?? [];
135
- }
136
- /**
137
- * Build a devextreme filter expression for a DataSource's **active search**.
138
- *
139
- * This is the subtle one. `searchValue` / `searchExpr` are DataSource-level
140
- * options: the DataSource folds them into the request it sends to its store.
141
- * Reading the store directly bypasses them entirely — so an export would
142
- * silently include rows the user filtered away with `<mono-table-search>`.
143
- * Reconstructing the filter here keeps the store path faithful to the grid.
144
- */
145
- function searchFilterOf(source) {
146
- const value = source.searchValue?.();
147
- const search = value == null || value === "" ? null : String(value);
148
- if (!search) return void 0;
149
- const expr = source.searchExpr?.();
150
- const cols = Array.isArray(expr) ? expr : expr ? [expr] : [];
151
- if (!cols.length) return void 0;
152
- const op = source.searchOperation?.() || "contains";
153
- const clauses = cols.map((c) => toODataClause(c, op, search)).filter((c) => c != null);
154
- if (!clauses.length) return void 0;
155
- if (clauses.length === 1) return clauses[0];
156
- const out = [];
157
- clauses.forEach((c, i) => {
158
- if (i) out.push("or");
159
- out.push(c);
160
- });
161
- return out;
162
- }
163
- /**
164
- * Read every row a source can produce, in chunks.
165
- *
166
- * A plain array passes straight through, so callers can accept
167
- * "array or DataSource" without branching.
168
- */
169
- async function readAllRows(source, options = {}) {
170
- const src = unwrapReactive(source);
171
- if (Array.isArray(src)) return flattenLeaves(src);
172
- if (!src) return [];
173
- const chunkSize = Math.max(1, Math.floor(options.chunkSize ?? 100));
174
- if (isDataSourceLike(src)) {
175
- const store = src.store?.();
176
- if (store && typeof store.load === "function") {
177
- const filter = andFilters(andFilters(src.filter?.() ?? null, searchFilterOf(src) ?? null), options.filter ?? null);
178
- const sort = options.sort ?? src.sort?.() ?? null;
179
- const select = options.select ?? src.select?.() ?? null;
180
- const loadOptions = {
181
- ...inheritedLoadOptionsOf(src),
182
- ...options.loadOptions ?? {}
183
- };
184
- return drainStore(store, {
185
- chunkSize,
186
- ...select ? { select } : {},
187
- ...filter ? { filter } : {},
188
- ...sort ? { sort } : {},
189
- ...Object.keys(loadOptions).length ? { loadOptions } : {}
190
- });
191
- }
192
- return readArrayDataSource(src);
193
- }
194
- if (isStoreLike(src)) return drainStore(src, {
195
- chunkSize,
196
- select: options.select,
197
- sort: options.sort,
198
- ...options.filter ? { filter: options.filter } : {},
199
- ...options.loadOptions ? { loadOptions: options.loadOptions } : {}
200
- });
201
- return [];
202
- }
203
- /** Loop `store.load` until a short chunk comes back. */
204
- async function drainStore(store, opts) {
205
- const acc = [];
206
- for (let skip = 0;; skip += opts.chunkSize) {
207
- const rows = rowsOf(await store.load({
208
- ...opts.loadOptions ?? {},
209
- ...opts.filter ? { filter: opts.filter } : {},
210
- ...opts.sort ? { sort: opts.sort } : {},
211
- ...opts.select ? { select: opts.select } : {},
212
- skip,
213
- take: opts.chunkSize,
214
- requireTotalCount: false
215
- }));
216
- acc.push(...flattenLeaves(rows));
217
- if (rows.length < opts.chunkSize) break;
218
- if (skip > MAX_SKIP) break;
219
- }
220
- return acc;
221
- }
222
- /**
223
- * An array-backed DataSource has no separate read channel, so its paging has to
224
- * be switched off, read, and put back exactly as it was — subscribers must not
225
- * observe the detour.
226
- */
227
- async function readArrayDataSource(src) {
228
- const paginate = src.paginate?.();
229
- const pageIndex = src.pageIndex?.();
230
- try {
231
- src.paginate?.(false);
232
- await src.load();
233
- return flattenLeaves([...src.items?.() ?? []]);
234
- } finally {
235
- if (typeof paginate === "boolean") src.paginate?.(paginate);
236
- if (typeof pageIndex === "number") src.pageIndex?.(pageIndex);
237
- await src.load();
238
- }
239
- }
240
-
241
- //#endregion
242
- export { buildGroups as a, isGroupNode as c, searchFilterOf as i, isReadableSource as n, collectGroupPaths as o, readAllRows as r, flattenLeaves as s, isDataSourceLike as t };