@spring-systems/core 0.8.6 → 0.8.7

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 (97) hide show
  1. package/dist/adapters/index.js +1 -56
  2. package/dist/auth/index.js +1 -19
  3. package/dist/chunk-3OMNT22N.js +1 -0
  4. package/dist/chunk-4KRUU6MS.js +1 -0
  5. package/dist/chunk-6J2VFOKL.js +1 -0
  6. package/dist/chunk-7P4BJDQR.js +1 -0
  7. package/dist/chunk-AMXSATFF.js +1 -0
  8. package/dist/chunk-BMIRKMVX.js +1 -0
  9. package/dist/chunk-EVDFSWPU.js +1 -0
  10. package/dist/chunk-F3VXVDPQ.js +1 -0
  11. package/dist/chunk-GSQE2NEY.js +1 -0
  12. package/dist/chunk-HUASNNWD.js +1 -0
  13. package/dist/chunk-ICKHSEIX.js +1 -0
  14. package/dist/chunk-JRHMAY5G.js +1 -0
  15. package/dist/chunk-MNLYYTGZ.js +7 -0
  16. package/dist/chunk-OOVZTF74.js +1 -0
  17. package/dist/chunk-PNDXLNCU.js +1 -0
  18. package/dist/chunk-R3XYEEGR.js +1 -0
  19. package/dist/chunk-RKLYBW3O.js +1 -0
  20. package/dist/chunk-RVQHSQYF.js +3 -0
  21. package/dist/chunk-UT6X6RQM.js +1 -0
  22. package/dist/chunk-Y6DB43IE.js +3 -0
  23. package/dist/chunk-YMSSF2ZU.js +1 -0
  24. package/dist/config/index.js +1 -109
  25. package/dist/devtools/index.js +1 -67
  26. package/dist/errors/index.js +1 -21
  27. package/dist/events/index.js +1 -12
  28. package/dist/i18n/index.js +1 -7
  29. package/dist/index.js +1 -42
  30. package/dist/instance/index.js +1 -37
  31. package/dist/logger/index.js +1 -27
  32. package/dist/middleware/index.js +1 -23
  33. package/dist/plugins/index.js +1 -16
  34. package/dist/testing/index.js +1 -171
  35. package/dist/types/index.js +1 -72
  36. package/dist/utils/index.d.ts +1 -0
  37. package/dist/utils/index.js +1 -772
  38. package/dist/validation/index.js +1 -147
  39. package/package.json +137 -136
  40. package/dist/adapters/index.js.map +0 -1
  41. package/dist/auth/index.js.map +0 -1
  42. package/dist/chunk-2PJWFA5S.js +0 -393
  43. package/dist/chunk-2PJWFA5S.js.map +0 -1
  44. package/dist/chunk-EFUBAQCV.js +0 -94
  45. package/dist/chunk-EFUBAQCV.js.map +0 -1
  46. package/dist/chunk-F2SIMWZ5.js +0 -173
  47. package/dist/chunk-F2SIMWZ5.js.map +0 -1
  48. package/dist/chunk-F7WUQJH7.js +0 -399
  49. package/dist/chunk-F7WUQJH7.js.map +0 -1
  50. package/dist/chunk-GON7Q32Q.js +0 -176
  51. package/dist/chunk-GON7Q32Q.js.map +0 -1
  52. package/dist/chunk-GXU75LQX.js +0 -182
  53. package/dist/chunk-GXU75LQX.js.map +0 -1
  54. package/dist/chunk-HFELOXDQ.js +0 -110
  55. package/dist/chunk-HFELOXDQ.js.map +0 -1
  56. package/dist/chunk-KX32MU3I.js +0 -190
  57. package/dist/chunk-KX32MU3I.js.map +0 -1
  58. package/dist/chunk-MEWPYTWC.js +0 -284
  59. package/dist/chunk-MEWPYTWC.js.map +0 -1
  60. package/dist/chunk-N2L4TUC4.js +0 -34
  61. package/dist/chunk-N2L4TUC4.js.map +0 -1
  62. package/dist/chunk-NQQIVCLX.js +0 -47
  63. package/dist/chunk-NQQIVCLX.js.map +0 -1
  64. package/dist/chunk-OSSX443T.js +0 -146
  65. package/dist/chunk-OSSX443T.js.map +0 -1
  66. package/dist/chunk-PT4DIYUK.js +0 -78
  67. package/dist/chunk-PT4DIYUK.js.map +0 -1
  68. package/dist/chunk-QAVWXARR.js +0 -51
  69. package/dist/chunk-QAVWXARR.js.map +0 -1
  70. package/dist/chunk-RRWKDFAB.js +0 -143
  71. package/dist/chunk-RRWKDFAB.js.map +0 -1
  72. package/dist/chunk-RUCXSQEY.js +0 -42
  73. package/dist/chunk-RUCXSQEY.js.map +0 -1
  74. package/dist/chunk-S6RPCN5H.js +0 -64
  75. package/dist/chunk-S6RPCN5H.js.map +0 -1
  76. package/dist/chunk-S7MKRNMI.js +0 -153
  77. package/dist/chunk-S7MKRNMI.js.map +0 -1
  78. package/dist/chunk-SQB4F3EF.js +0 -55
  79. package/dist/chunk-SQB4F3EF.js.map +0 -1
  80. package/dist/chunk-UDT2RPX2.js +0 -43
  81. package/dist/chunk-UDT2RPX2.js.map +0 -1
  82. package/dist/chunk-VRMVN2UM.js +0 -17
  83. package/dist/chunk-VRMVN2UM.js.map +0 -1
  84. package/dist/config/index.js.map +0 -1
  85. package/dist/devtools/index.js.map +0 -1
  86. package/dist/errors/index.js.map +0 -1
  87. package/dist/events/index.js.map +0 -1
  88. package/dist/i18n/index.js.map +0 -1
  89. package/dist/index.js.map +0 -1
  90. package/dist/instance/index.js.map +0 -1
  91. package/dist/logger/index.js.map +0 -1
  92. package/dist/middleware/index.js.map +0 -1
  93. package/dist/plugins/index.js.map +0 -1
  94. package/dist/testing/index.js.map +0 -1
  95. package/dist/types/index.js.map +0 -1
  96. package/dist/utils/index.js.map +0 -1
  97. package/dist/validation/index.js.map +0 -1
@@ -1,772 +1 @@
1
- import {
2
- emptyGuid
3
- } from "../chunk-VRMVN2UM.js";
4
- import {
5
- getFrameworkConfig
6
- } from "../chunk-F7WUQJH7.js";
7
- import {
8
- getContentRes
9
- } from "../chunk-NQQIVCLX.js";
10
- import "../chunk-N2L4TUC4.js";
11
- import "../chunk-RUCXSQEY.js";
12
- import {
13
- isSensitiveSecurityKey,
14
- sanitizeSecurityData
15
- } from "../chunk-KX32MU3I.js";
16
- import {
17
- __DEV__,
18
- devAssert,
19
- devThrow,
20
- devWarn
21
- } from "../chunk-EFUBAQCV.js";
22
- import {
23
- SpringValidationError
24
- } from "../chunk-PT4DIYUK.js";
25
-
26
- // src/utils/a11y.ts
27
- function onKeyActivate(handler) {
28
- if (!handler) return void 0;
29
- return (e) => {
30
- if (e.key === "Enter" || e.key === " ") {
31
- e.preventDefault();
32
- handler(e);
33
- }
34
- };
35
- }
36
- function prefersReducedMotion() {
37
- if (typeof window === "undefined") return false;
38
- return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
39
- }
40
-
41
- // src/utils/color.ts
42
- function getBrightness(r, g, b) {
43
- return (r * 299 + g * 587 + b * 114) / 1e3;
44
- }
45
- function hexToRgb(hex) {
46
- const bigint = parseInt(hex.slice(1), 16);
47
- const r = bigint >> 16 & 255;
48
- const g = bigint >> 8 & 255;
49
- const b = bigint & 255;
50
- return [r, g, b];
51
- }
52
- function rgbToHex(rgb) {
53
- const match = rgb.match(/\d+/g);
54
- if (!match) return "#000000";
55
- const result = match.map((x) => parseInt(x).toString(16).padStart(2, "0")).join("");
56
- return `#${result}`;
57
- }
58
- function getContrastYIQ(hex) {
59
- const [r, g, b] = hexToRgb(hex);
60
- const brightness = getBrightness(r, g, b);
61
- return brightness > 150 ? "black" : "white";
62
- }
63
-
64
- // src/utils/data-utils.ts
65
- import dayjs from "dayjs";
66
- import customParseFormat from "dayjs/plugin/customParseFormat";
67
- dayjs.extend(customParseFormat);
68
- var UNSAFE_MERGE_KEYS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
69
- function isValueNotEmpty(value) {
70
- return value !== 0 && value !== null && value !== void 0 && value !== false && value !== "" && !(Array.isArray(value) && value.length === 0);
71
- }
72
- function deepCopy(obj, hash) {
73
- if (!hash && typeof structuredClone === "function") {
74
- try {
75
- return structuredClone(obj);
76
- } catch {
77
- }
78
- }
79
- const map = hash ?? /* @__PURE__ */ new WeakMap();
80
- if (typeof obj === "object" && obj !== null && map.has(obj)) return map.get(obj);
81
- if (obj instanceof Date) return new Date(obj.getTime());
82
- if (obj instanceof RegExp) return new RegExp(obj.source, obj.flags);
83
- if (obj === null || typeof obj !== "object") return obj;
84
- const result = Array.isArray(obj) ? [] : {};
85
- map.set(obj, result);
86
- for (const key in obj) {
87
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
88
- result[key] = deepCopy(obj[key], map);
89
- }
90
- }
91
- return result;
92
- }
93
- function deepEqual(a, b) {
94
- if (a === b) return true;
95
- if (a === null && b === "" || a === "" && b === null) return true;
96
- if (a == null || b == null || typeof a !== "object" && typeof a !== "function" || typeof b !== "object" && typeof b !== "function") {
97
- return false;
98
- }
99
- if (Array.isArray(a) !== Array.isArray(b)) return false;
100
- const objA = a;
101
- const objB = b;
102
- const keysA = Object.keys(objA);
103
- const keysB = Object.keys(objB);
104
- if (keysA.length !== keysB.length) {
105
- return false;
106
- }
107
- const keysBSet = new Set(keysB);
108
- for (const key of keysA) {
109
- if (!keysBSet.has(key) || !deepEqual(objA[key], objB[key])) {
110
- return false;
111
- }
112
- }
113
- return true;
114
- }
115
- function deepMerge(target, source) {
116
- const result = { ...target };
117
- Object.keys(source).forEach((key) => {
118
- if (UNSAFE_MERGE_KEYS.has(key)) {
119
- return;
120
- }
121
- const k = key;
122
- if (source[k] && typeof source[k] === "object" && !Array.isArray(source[k])) {
123
- result[k] = deepMerge(
124
- target[k] && typeof target[k] === "object" ? target[k] : {},
125
- source[k]
126
- );
127
- } else {
128
- result[k] = source[k];
129
- }
130
- });
131
- return result;
132
- }
133
- function getValueByPath(obj, path) {
134
- const keys = path.split(".");
135
- let current = obj;
136
- for (const key of keys) {
137
- if (current == null || typeof current !== "object" || current instanceof Date) {
138
- return void 0;
139
- }
140
- if (Array.isArray(current)) return void 0;
141
- current = current[key];
142
- }
143
- return current;
144
- }
145
- function normalizeString(str) {
146
- return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
147
- }
148
- function generateGUID() {
149
- const cryptoApi = globalThis.crypto;
150
- if (cryptoApi && typeof cryptoApi.randomUUID === "function") {
151
- return cryptoApi.randomUUID();
152
- }
153
- if (cryptoApi && typeof cryptoApi.getRandomValues === "function") {
154
- const bytes = new Uint8Array(16);
155
- cryptoApi.getRandomValues(bytes);
156
- const b6 = bytes[6] ?? 0;
157
- const b8 = bytes[8] ?? 0;
158
- bytes[6] = b6 & 15 | 64;
159
- bytes[8] = b8 & 63 | 128;
160
- const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
161
- return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
162
- }
163
- throw new SpringValidationError(
164
- "generateGUID(): secure random source unavailable. Provide Web Crypto (crypto.randomUUID or crypto.getRandomValues).",
165
- "generateGUID"
166
- );
167
- }
168
- function setDefaultStructure(data) {
169
- const result = {
170
- id_public: emptyGuid
171
- };
172
- const defaultValue = (type) => {
173
- switch (type) {
174
- case "boolean":
175
- return false;
176
- case "string":
177
- return "";
178
- case "number":
179
- return "";
180
- case "object":
181
- case "date":
182
- case "datetime":
183
- case "time":
184
- return null;
185
- default:
186
- return void 0;
187
- }
188
- };
189
- data.forEach((item) => {
190
- if (item.field) {
191
- result[item.field] = defaultValue(item.type);
192
- }
193
- });
194
- return result;
195
- }
196
- function parseJSONSafely(value) {
197
- if (typeof value === "string") {
198
- if (value.toLowerCase() === "true") {
199
- return true;
200
- } else if (value.toLowerCase() === "false") {
201
- return false;
202
- }
203
- try {
204
- return JSON.parse(value);
205
- } catch (_e) {
206
- return value;
207
- }
208
- }
209
- return value;
210
- }
211
- function getValueType(value) {
212
- const v = parseJSONSafely(value);
213
- if (v === null || v === void 0) {
214
- return "string";
215
- }
216
- if (v instanceof Date) {
217
- return "date";
218
- }
219
- if (typeof v === "string") {
220
- const trimmed = v.trim();
221
- const looksLikeDate = /[0-9]/.test(trimmed) && /[-./]/.test(trimmed) && trimmed.length >= 6;
222
- if (looksLikeDate) {
223
- const formats = [
224
- "D.M.YYYY",
225
- "DD.MM.YYYY",
226
- "D. M. YYYY",
227
- "DD. MM. YYYY",
228
- "DD.MM.YYYY HH:mm",
229
- "D.M.YYYY HH:mm",
230
- "DD.MM.YYYY H:mm",
231
- "D.M.YYYY H:mm",
232
- "YYYY-MM-DD",
233
- "YYYY-MM-DDTHH:mm:ss",
234
- "YYYY-MM-DDTHH:mm:ss.SSS",
235
- "YYYY-MM-DDTHH:mm:ssZ",
236
- "YYYY-MM-DDTHH:mm:ss.SSSZ"
237
- ];
238
- if (dayjs(trimmed, formats, true).isValid()) {
239
- return "date";
240
- }
241
- if (dayjs(trimmed).isValid() && /^\d{4}-\d{2}-\d{2}/.test(trimmed)) {
242
- return "date";
243
- }
244
- }
245
- }
246
- if (Array.isArray(v)) {
247
- if (v.length === 0) {
248
- return "object";
249
- }
250
- return getValueType(v[0]);
251
- }
252
- const t = typeof v;
253
- if (t === "number") {
254
- return "number";
255
- }
256
- if (t === "boolean") {
257
- return "boolean";
258
- }
259
- if (t === "object") {
260
- return "object";
261
- }
262
- return "string";
263
- }
264
-
265
- // src/utils/date.ts
266
- import dayjs2 from "dayjs";
267
- import customParseFormat2 from "dayjs/plugin/customParseFormat";
268
- import isBetweenPlugin from "dayjs/plugin/isBetween";
269
- dayjs2.extend(customParseFormat2);
270
- dayjs2.extend(isBetweenPlugin);
271
- var activeLocale = null;
272
- function ensureLocale() {
273
- const locale = getFrameworkConfig().i18n.dayjsLocale;
274
- if (locale && locale !== activeLocale) {
275
- dayjs2.locale(locale);
276
- activeLocale = locale;
277
- }
278
- }
279
- function setDateLocale(locale) {
280
- activeLocale = locale;
281
- dayjs2.locale(locale);
282
- }
283
- function fmt() {
284
- ensureLocale();
285
- return getFrameworkConfig().i18n.dateFormats;
286
- }
287
- var dateManager = {
288
- formatDateCustom(value, format) {
289
- if (!value) {
290
- return "";
291
- } else {
292
- return dayjs2(value).format(format);
293
- }
294
- },
295
- formatDate(value) {
296
- if (!value) {
297
- return "";
298
- } else {
299
- return dayjs2(value).format(fmt().date);
300
- }
301
- },
302
- formatDateTime(value) {
303
- if (!value) {
304
- return "";
305
- } else {
306
- return dayjs2(value).format(fmt().dateTime);
307
- }
308
- },
309
- formatTime(value) {
310
- if (!value) {
311
- return "";
312
- } else {
313
- return dayjs2(value).format(fmt().time);
314
- }
315
- },
316
- formatDateRange(dateFrom, dateTo, format = fmt().date) {
317
- const from = dayjs2(dateFrom);
318
- const to = dayjs2(dateTo);
319
- const dtFmt = fmt().dateTime;
320
- if (from.isSame(to, "day")) {
321
- if (format.includes("H") || format.includes("h")) {
322
- return `${from.format(dtFmt)}-${to.format(fmt().time)}`;
323
- } else if (format === fmt().time) {
324
- return `${from.format(fmt().time)}-${to.format(fmt().time)}`;
325
- }
326
- return from.format(format);
327
- }
328
- if (format.includes("H") || format.includes("h")) {
329
- return `${from.format(dtFmt)} - ${to.format(dtFmt)}`;
330
- } else if (format === fmt().time) {
331
- return `${from.format(fmt().time)} - ${to.format(fmt().time)}`;
332
- }
333
- return `${from.format(fmt().date)} - ${to.format(fmt().date)}`;
334
- },
335
- formatDateTimeWithSeconds(value) {
336
- if (!value) {
337
- return "";
338
- } else {
339
- return dayjs2(value).format(fmt().dateTimeSeconds);
340
- }
341
- },
342
- /** Formats a value as date with time, or time only if it is today */
343
- formatDateTimeShort(value) {
344
- if (!value) {
345
- return "";
346
- } else if (dayjs2(value).isSame(Date.now(), "day")) {
347
- return dayjs2(value).format(fmt().time);
348
- } else {
349
- return this.formatDateTime(value);
350
- }
351
- },
352
- getAgeFromDate(value) {
353
- return dayjs2().diff(value, "years");
354
- },
355
- formatMonthName(value, format) {
356
- return dayjs2(value).format(format);
357
- },
358
- formatMonthNumber(value) {
359
- return dayjs2(value).month() + 1;
360
- },
361
- getPreviousMonth(date, numberOfMonth) {
362
- return dayjs2(date).subtract(numberOfMonth, "months").toDate();
363
- },
364
- setTimeFromString(date, time, onlyMinutes) {
365
- const setDate = dayjs2(date).toDate();
366
- const split = time.split(":");
367
- if (!onlyMinutes) {
368
- setDate.setHours(Number(split[0] ?? 0));
369
- } else {
370
- setDate.setSeconds(0);
371
- }
372
- setDate.setMinutes(Number(split[1] ?? 0));
373
- return setDate;
374
- },
375
- formatDateString(value) {
376
- if (!value) {
377
- return null;
378
- } else {
379
- if (value.split("-")[0]?.length === 4) {
380
- return dayjs2(value).toDate();
381
- }
382
- if (value.split(".")[0]?.length === 4 || value.split("/")[0]?.length === 4) {
383
- return dayjs2(value, "YYYY. M. D.").toDate();
384
- }
385
- return dayjs2(value, "D. M. YYYY").toDate();
386
- }
387
- },
388
- getDuration(date, date2, type) {
389
- if (!date || !date2) {
390
- return null;
391
- } else {
392
- const value = dayjs2(date);
393
- const value2 = dayjs2(date2);
394
- const result = value2.diff(value, type);
395
- return result;
396
- }
397
- },
398
- getStartOfDate(date, unitOfTime) {
399
- return dayjs2(date).startOf(unitOfTime).toDate();
400
- },
401
- getEndOfDay(date) {
402
- return dayjs2(date).endOf("day").toDate();
403
- },
404
- getDateRange(date, unitOfTime) {
405
- const startDate = dayjs2(date).startOf(unitOfTime).toDate();
406
- const endDate = dayjs2(date).endOf(unitOfTime).toDate();
407
- return { dateFrom: startDate, dateTo: endDate };
408
- },
409
- isDateInRange(startDate, endDate, dateToCheck) {
410
- if (!endDate) {
411
- return dayjs2(dateToCheck).isSame(startDate, "day");
412
- }
413
- return dayjs2(dateToCheck).isBetween(startDate, endDate, null, "[]");
414
- },
415
- /** Adds a number of days (or other unit) to a date */
416
- add(value, count, type) {
417
- return dayjs2(value).add(count, type ? type : "days").toDate();
418
- },
419
- substractDaysFromDate(numberOfDays, date) {
420
- const result = dayjs2(date).subtract(numberOfDays, "days").toDate();
421
- return result;
422
- }
423
- };
424
-
425
- // src/utils/deprecation.ts
426
- var warned = /* @__PURE__ */ new Set();
427
- function springDeprecate(name, alternative, removeVersion) {
428
- const key = `${name}:${alternative}`;
429
- if (warned.has(key)) return;
430
- warned.add(key);
431
- const versionNote = removeVersion ? ` It will be removed in v${removeVersion}.` : "";
432
- console.warn(`[SPRING Deprecation] "${name}" is deprecated. Use ${alternative} instead.${versionNote}`);
433
- }
434
- function clearDeprecationWarnings() {
435
- warned.clear();
436
- }
437
-
438
- // src/utils/filter-utils.ts
439
- function parseFilter(value) {
440
- if (value instanceof Date) {
441
- return value.toISOString();
442
- }
443
- if (Array.isArray(value)) {
444
- return JSON.stringify(value);
445
- }
446
- if (typeof value === "boolean") {
447
- return value;
448
- }
449
- return value != null ? value.toString() : "";
450
- }
451
- function normalizeSystemFilter(input) {
452
- if (!input) return null;
453
- if (typeof input === "object" && input !== null && ("logic" in input || "field" in input)) {
454
- return input;
455
- }
456
- if (typeof input === "object" && input !== null) {
457
- const entries = Object.entries(input).filter(([k, v]) => k && v !== void 0 && v !== null && v !== "");
458
- const filters = entries.map(([k, v]) => {
459
- const val = parseFilter(v);
460
- return {
461
- field: k,
462
- operator: "eq",
463
- value: val
464
- };
465
- });
466
- if (filters.length === 0) {
467
- return null;
468
- }
469
- return {
470
- logic: "and",
471
- filters
472
- };
473
- }
474
- return null;
475
- }
476
- function getFilterFieldType(fieldKey, defaultListFilter, value) {
477
- const fieldDef = defaultListFilter && defaultListFilter[fieldKey];
478
- if (fieldDef && typeof fieldDef.type === "string") {
479
- return fieldDef.type;
480
- }
481
- return getValueType(value);
482
- }
483
-
484
- // src/utils/format-utils.ts
485
- import sanitizeHtml from "sanitize-html";
486
- function sanitizeContent(content) {
487
- if (!content) {
488
- return "";
489
- }
490
- const clean = sanitizeHtml(content, {
491
- allowedTags: [],
492
- allowedAttributes: {}
493
- });
494
- return clean;
495
- }
496
- var editorAllowedTags = [
497
- "p",
498
- "br",
499
- "div",
500
- "ul",
501
- "ol",
502
- "li",
503
- "b",
504
- "i",
505
- "em",
506
- "strong",
507
- "u",
508
- "s",
509
- "sub",
510
- "sup",
511
- "h1",
512
- "h2",
513
- "h3",
514
- "h4",
515
- "h5",
516
- "h6",
517
- "span",
518
- "a",
519
- "table",
520
- "thead",
521
- "tbody",
522
- "tr",
523
- "th",
524
- "td"
525
- ];
526
- var editorAllowedAttributes = {
527
- a: ["href", "title", "target", "rel"],
528
- td: ["colspan", "rowspan"],
529
- th: ["colspan", "rowspan"],
530
- span: ["style"]
531
- };
532
- var SAFE_TEXT_DECORATION_PATTERN = /^(?!.*(?:url|expression)\s*\()[a-z0-9#(),.%\s-]{1,80}$/i;
533
- var SAFE_LINK_TARGETS = /* @__PURE__ */ new Set(["_blank", "_self", "_parent", "_top"]);
534
- function normalizeRelTokens(rel) {
535
- if (!rel) return [];
536
- const seen = /* @__PURE__ */ new Set();
537
- const tokens = [];
538
- for (const raw of rel.split(/\s+/)) {
539
- const token = raw.trim().toLowerCase();
540
- if (!token || token === "opener" || seen.has(token)) continue;
541
- seen.add(token);
542
- tokens.push(token);
543
- }
544
- return tokens;
545
- }
546
- var editorTransformTags = {
547
- a: (tagName, attribs) => {
548
- const nextAttribs = { ...attribs };
549
- if (typeof nextAttribs.target === "string") {
550
- const normalizedTarget = nextAttribs.target.trim().toLowerCase();
551
- if (SAFE_LINK_TARGETS.has(normalizedTarget)) {
552
- nextAttribs.target = normalizedTarget;
553
- } else {
554
- delete nextAttribs.target;
555
- }
556
- }
557
- if (nextAttribs.target === "_blank") {
558
- const relTokens = normalizeRelTokens(nextAttribs.rel);
559
- if (!relTokens.includes("noopener")) relTokens.push("noopener");
560
- if (!relTokens.includes("noreferrer")) relTokens.push("noreferrer");
561
- nextAttribs.rel = relTokens.join(" ");
562
- }
563
- return { tagName, attribs: nextAttribs };
564
- }
565
- };
566
- var editorAllowedStyles = {
567
- span: {
568
- "text-decoration": [SAFE_TEXT_DECORATION_PATTERN]
569
- }
570
- };
571
- function sanitizeEditorContent(content) {
572
- if (!content) {
573
- return "";
574
- }
575
- return sanitizeHtml(content, {
576
- allowedTags: editorAllowedTags,
577
- allowedAttributes: editorAllowedAttributes,
578
- allowedStyles: editorAllowedStyles,
579
- transformTags: editorTransformTags,
580
- allowedSchemes: ["http", "https", "mailto"]
581
- });
582
- }
583
- function truncateString(value, maxLength) {
584
- if (value.length <= maxLength) {
585
- return value;
586
- } else if (maxLength < 3) {
587
- return value.slice(0, maxLength);
588
- } else {
589
- return value.slice(0, maxLength - 3) + "...";
590
- }
591
- }
592
- function toNumber(value, decimals) {
593
- const locale = getFrameworkConfig().i18n.numberLocale;
594
- return Number(value).toLocaleString(locale, {
595
- minimumFractionDigits: decimals ? decimals : 0,
596
- maximumFractionDigits: decimals ? decimals : 0
597
- });
598
- }
599
- function setColumnBodyType(item, obj) {
600
- const key = obj.field;
601
- const rec = item;
602
- let result = rec[key];
603
- switch (obj.type) {
604
- case "date":
605
- result = dateManager.formatDate(rec[key]);
606
- break;
607
- case "datetime":
608
- result = dateManager.formatDateTime(rec[key]);
609
- break;
610
- case "time":
611
- result = dateManager.formatTime(rec[key]);
612
- break;
613
- case "boolean":
614
- result = rec[key] ? getContentRes("admin-yes") : getContentRes("admin-no");
615
- break;
616
- case "number": {
617
- const numVal = rec[key];
618
- result = numVal !== void 0 ? obj.decimals ? toNumber(numVal, obj.decimals) : numVal : "";
619
- break;
620
- }
621
- case "object": {
622
- const objVal = rec[key];
623
- result = objVal ? obj.textField ? objVal[obj.textField] : objVal.full_name || objVal.name || "" : "";
624
- break;
625
- }
626
- case "string":
627
- case "color":
628
- break;
629
- default: {
630
- const _exhaustive = obj.type;
631
- void _exhaustive;
632
- }
633
- }
634
- return result;
635
- }
636
-
637
- // src/utils/tree-utils.ts
638
- function getChildren(node, field) {
639
- const val = node[field];
640
- return Array.isArray(val) ? val : void 0;
641
- }
642
- function findNode(nodes, id, childrenField = "childrenNodes") {
643
- for (const node of nodes) {
644
- if (node.id_public === id) return node;
645
- const children = getChildren(node, childrenField);
646
- if (children && children.length > 0) {
647
- const found = findNode(children, id, childrenField);
648
- if (found) return found;
649
- }
650
- }
651
- return null;
652
- }
653
- function getAllIds(nodes, childrenField = "childrenNodes") {
654
- const ids = [];
655
- const collect = (items) => {
656
- for (const node of items) {
657
- ids.push(node.id_public);
658
- const children = getChildren(node, childrenField);
659
- if (children && children.length > 0) {
660
- collect(children);
661
- }
662
- }
663
- };
664
- collect(nodes);
665
- return ids;
666
- }
667
- function updateNode(nodes, id, updater, childrenField = "childrenNodes") {
668
- return nodes.map((node) => {
669
- if (node.id_public === id) {
670
- return updater(node);
671
- }
672
- const children = getChildren(node, childrenField);
673
- if (children && children.length > 0) {
674
- return {
675
- ...node,
676
- [childrenField]: updateNode(children, id, updater, childrenField)
677
- };
678
- }
679
- return node;
680
- });
681
- }
682
- function removeNode(nodes, id, childrenField = "childrenNodes") {
683
- return nodes.filter((node) => node.id_public !== id).map((node) => {
684
- const children = getChildren(node, childrenField);
685
- if (children && children.length > 0) {
686
- return {
687
- ...node,
688
- [childrenField]: removeNode(children, id, childrenField)
689
- };
690
- }
691
- return node;
692
- });
693
- }
694
- function addNode(nodes, parentId, newNode, childrenField = "childrenNodes") {
695
- if (parentId === null) {
696
- return [...nodes, newNode];
697
- }
698
- return nodes.map((node) => {
699
- if (node.id_public === parentId) {
700
- const children2 = getChildren(node, childrenField) || [];
701
- return {
702
- ...node,
703
- [childrenField]: [...children2, newNode]
704
- };
705
- }
706
- const children = getChildren(node, childrenField);
707
- if (children && children.length > 0) {
708
- return {
709
- ...node,
710
- [childrenField]: addNode(children, parentId, newNode, childrenField)
711
- };
712
- }
713
- return node;
714
- });
715
- }
716
- function findParentId(nodes, id, childrenField = "childrenNodes", parentId = null) {
717
- for (const node of nodes) {
718
- if (node.id_public === id) {
719
- return parentId;
720
- }
721
- const children = getChildren(node, childrenField);
722
- if (children && children.length > 0) {
723
- const found = findParentId(children, id, childrenField, node.id_public);
724
- if (found !== null) return found;
725
- }
726
- }
727
- return null;
728
- }
729
- export {
730
- __DEV__,
731
- addNode,
732
- clearDeprecationWarnings,
733
- dateManager,
734
- deepCopy,
735
- deepEqual,
736
- deepMerge,
737
- devAssert,
738
- devThrow,
739
- devWarn,
740
- findNode,
741
- findParentId,
742
- generateGUID,
743
- getAllIds,
744
- getBrightness,
745
- getChildren,
746
- getContrastYIQ,
747
- getFilterFieldType,
748
- getValueByPath,
749
- getValueType,
750
- hexToRgb,
751
- isSensitiveSecurityKey,
752
- isValueNotEmpty,
753
- normalizeString,
754
- normalizeSystemFilter,
755
- onKeyActivate,
756
- parseFilter,
757
- parseJSONSafely,
758
- prefersReducedMotion,
759
- removeNode,
760
- rgbToHex,
761
- sanitizeContent,
762
- sanitizeEditorContent,
763
- sanitizeSecurityData,
764
- setColumnBodyType,
765
- setDateLocale,
766
- setDefaultStructure,
767
- springDeprecate,
768
- toNumber,
769
- truncateString,
770
- updateNode
771
- };
772
- //# sourceMappingURL=index.js.map
1
+ import{a as x}from"../chunk-GSQE2NEY.js";import{e as f}from"../chunk-RVQHSQYF.js";import{b as p}from"../chunk-7P4BJDQR.js";import"../chunk-HUASNNWD.js";import"../chunk-YMSSF2ZU.js";import{a as Z,b as Q}from"../chunk-EVDFSWPU.js";import{a as m,b as S,c as Y,d as k}from"../chunk-JRHMAY5G.js";import{c as T}from"../chunk-OOVZTF74.js";function X(e){if(e)return t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),e(t))}}function v(){return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function w(e,t,n){return(e*299+t*587+n*114)/1e3}function A(e){let t=parseInt(e.slice(1),16),n=t>>16&255,r=t>>8&255,o=t&255;return[n,r,o]}function te(e){let t=e.match(/\d+/g);return t?`#${t.map(r=>parseInt(r).toString(16).padStart(2,"0")).join("")}`:"#000000"}function re(e){let[t,n,r]=A(e);return w(t,n,r)>150?"black":"white"}import g from"dayjs";import F from"dayjs/plugin/customParseFormat";g.extend(F);var N=new Set(["__proto__","prototype","constructor"]);function ue(e){return e!==0&&e!==null&&e!==void 0&&e!==!1&&e!==""&&!(Array.isArray(e)&&e.length===0)}function M(e,t){if(!t&&typeof structuredClone=="function")try{return structuredClone(e)}catch{}let n=t??new WeakMap;if(typeof e=="object"&&e!==null&&n.has(e))return n.get(e);if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(e===null||typeof e!="object")return e;let r=Array.isArray(e)?[]:{};n.set(e,r);for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&(r[o]=M(e[o],n));return r}function _(e,t){if(e===t||e===null&&t===""||e===""&&t===null)return!0;if(e==null||t==null||typeof e!="object"&&typeof e!="function"||typeof t!="object"&&typeof t!="function"||Array.isArray(e)!==Array.isArray(t))return!1;let n=e,r=t,o=Object.keys(n),i=Object.keys(r);if(o.length!==i.length)return!1;let u=new Set(i);for(let d of o)if(!u.has(d)||!_(n[d],r[d]))return!1;return!0}function I(e,t){let n={...e};return Object.keys(t).forEach(r=>{if(N.has(r))return;let o=r;t[o]&&typeof t[o]=="object"&&!Array.isArray(t[o])?n[o]=I(e[o]&&typeof e[o]=="object"?e[o]:{},t[o]):n[o]=t[o]}),n}function le(e,t){let n=t.split("."),r=e;for(let o of n){if(r==null||typeof r!="object"||r instanceof Date||Array.isArray(r))return;r=r[o]}return r}function fe(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function ce(){let e=globalThis.crypto;if(e&&typeof e.randomUUID=="function")return e.randomUUID();if(e&&typeof e.getRandomValues=="function"){let t=new Uint8Array(16);e.getRandomValues(t);let n=t[6]??0,r=t[8]??0;t[6]=n&15|64,t[8]=r&63|128;let o=Array.from(t,i=>i.toString(16).padStart(2,"0")).join("");return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20)}`}throw new T("generateGUID(): secure random source unavailable. Provide Web Crypto (crypto.randomUUID or crypto.getRandomValues).","generateGUID")}function de(e){let t={id_public:x},n=r=>{switch(r){case"boolean":return!1;case"string":return"";case"number":return"";case"object":case"date":case"datetime":case"time":return null;default:return}};return e.forEach(r=>{r.field&&(t[r.field]=n(r.type))}),t}function E(e){if(typeof e=="string"){if(e.toLowerCase()==="true")return!0;if(e.toLowerCase()==="false")return!1;try{return JSON.parse(e)}catch{return e}}return e}function y(e){let t=E(e);if(t==null)return"string";if(t instanceof Date)return"date";if(typeof t=="string"){let r=t.trim();if(/[0-9]/.test(r)&&/[-./]/.test(r)&&r.length>=6&&(g(r,["D.M.YYYY","DD.MM.YYYY","D. M. YYYY","DD. MM. YYYY","DD.MM.YYYY HH:mm","D.M.YYYY HH:mm","DD.MM.YYYY H:mm","D.M.YYYY H:mm","YYYY-MM-DD","YYYY-MM-DDTHH:mm:ss","YYYY-MM-DDTHH:mm:ss.SSS","YYYY-MM-DDTHH:mm:ssZ","YYYY-MM-DDTHH:mm:ss.SSSZ"],!0).isValid()||g(r).isValid()&&/^\d{4}-\d{2}-\d{2}/.test(r)))return"date"}if(Array.isArray(t))return t.length===0?"object":y(t[0]);let n=typeof t;return n==="number"?"number":n==="boolean"?"boolean":n==="object"?"object":"string"}import s from"dayjs";import V from"dayjs/plugin/customParseFormat";import C from"dayjs/plugin/isBetween";s.extend(V);s.extend(C);var D=null;function $(){let e=f().i18n.dayjsLocale;e&&e!==D&&(s.locale(e),D=e)}function be(e){D=e,s.locale(e)}function a(){return $(),f().i18n.dateFormats}var c={formatDateCustom(e,t){return e?s(e).format(t):""},formatDate(e){return e?s(e).format(a().date):""},formatDateTime(e){return e?s(e).format(a().dateTime):""},formatTime(e){return e?s(e).format(a().time):""},formatDateRange(e,t,n=a().date){let r=s(e),o=s(t),i=a().dateTime;return r.isSame(o,"day")?n.includes("H")||n.includes("h")?`${r.format(i)}-${o.format(a().time)}`:n===a().time?`${r.format(a().time)}-${o.format(a().time)}`:r.format(n):n.includes("H")||n.includes("h")?`${r.format(i)} - ${o.format(i)}`:n===a().time?`${r.format(a().time)} - ${o.format(a().time)}`:`${r.format(a().date)} - ${o.format(a().date)}`},formatDateTimeWithSeconds(e){return e?s(e).format(a().dateTimeSeconds):""},formatDateTimeShort(e){return e?s(e).isSame(Date.now(),"day")?s(e).format(a().time):this.formatDateTime(e):""},getAgeFromDate(e){return s().diff(e,"years")},formatMonthName(e,t){return s(e).format(t)},formatMonthNumber(e){return s(e).month()+1},getPreviousMonth(e,t){return s(e).subtract(t,"months").toDate()},setTimeFromString(e,t,n){let r=s(e).toDate(),o=t.split(":");return n?r.setSeconds(0):r.setHours(Number(o[0]??0)),r.setMinutes(Number(o[1]??0)),r},formatDateString(e){return e?e.split("-")[0]?.length===4?s(e).toDate():e.split(".")[0]?.length===4||e.split("/")[0]?.length===4?s(e,"YYYY. M. D.").toDate():s(e,"D. M. YYYY").toDate():null},getDuration(e,t,n){if(!e||!t)return null;{let r=s(e);return s(t).diff(r,n)}},getStartOfDate(e,t){return s(e).startOf(t).toDate()},getEndOfDay(e){return s(e).endOf("day").toDate()},getDateRange(e,t){let n=s(e).startOf(t).toDate(),r=s(e).endOf(t).toDate();return{dateFrom:n,dateTo:r}},isDateInRange(e,t,n){return t?s(n).isBetween(e,t,null,"[]"):s(n).isSame(e,"day")},add(e,t,n){return s(e).add(t,n||"days").toDate()},substractDaysFromDate(e,t){return s(t).subtract(e,"days").toDate()}};var b=new Set;function he(e,t,n){if(!m)return;let r=`${e}:${t}`;if(b.has(r))return;b.add(r);let o=n?` It will be removed in v${n}.`:"";console.warn(`[SPRING Deprecation] "${e}" is deprecated. Use ${t} instead.${o}`)}function Se(){b.clear()}function H(e){return e instanceof Date?e.toISOString():Array.isArray(e)?JSON.stringify(e):typeof e=="boolean"?e:e!=null?e.toString():""}function we(e){if(!e)return null;if(typeof e=="object"&&e!==null&&("logic"in e||"field"in e))return e;if(typeof e=="object"&&e!==null){let n=Object.entries(e).filter(([r,o])=>r&&o!==void 0&&o!==null&&o!=="").map(([r,o])=>{let i=H(o);return{field:r,operator:"eq",value:i}});return n.length===0?null:{logic:"and",filters:n}}return null}function Ae(e,t,n){let r=t&&t[e];return r&&typeof r.type=="string"?r.type:y(n)}import h from"sanitize-html";function Ee(e){return e?h(e,{allowedTags:[],allowedAttributes:{}}):""}var O=["p","br","div","ul","ol","li","b","i","em","strong","u","s","sub","sup","h1","h2","h3","h4","h5","h6","span","a","table","thead","tbody","tr","th","td"],R={a:["href","title","target","rel"],td:["colspan","rowspan"],th:["colspan","rowspan"],span:["style"]},B=/^(?!.*(?:url|expression)\s*\()[a-z0-9#(),.%\s-]{1,80}$/i,j=new Set(["_blank","_self","_parent","_top"]);function U(e){if(!e)return[];let t=new Set,n=[];for(let r of e.split(/\s+/)){let o=r.trim().toLowerCase();!o||o==="opener"||t.has(o)||(t.add(o),n.push(o))}return n}var z={a:(e,t)=>{let n={...t};if(typeof n.target=="string"){let r=n.target.trim().toLowerCase();j.has(r)?n.target=r:delete n.target}if(n.target==="_blank"){let r=U(n.rel);r.includes("noopener")||r.push("noopener"),r.includes("noreferrer")||r.push("noreferrer"),n.rel=r.join(" ")}return{tagName:e,attribs:n}}},P={span:{"text-decoration":[B]}};function Ve(e){return e?h(e,{allowedTags:O,allowedAttributes:R,allowedStyles:P,transformTags:z,allowedSchemes:["http","https","mailto"]}):""}function Ce(e,t){return e.length<=t?e:t<3?e.slice(0,t):e.slice(0,t-3)+"..."}function L(e,t){let n=f().i18n.numberLocale;return Number(e).toLocaleString(n,{minimumFractionDigits:t||0,maximumFractionDigits:t||0})}function $e(e,t){let n=t.field,r=e,o=r[n];switch(t.type){case"date":o=c.formatDate(r[n]);break;case"datetime":o=c.formatDateTime(r[n]);break;case"time":o=c.formatTime(r[n]);break;case"boolean":o=r[n]?p("admin-yes"):p("admin-no");break;case"number":{let i=r[n];o=i!==void 0?t.decimals?L(i,t.decimals):i:"";break}case"object":{let i=r[n];o=i?t.textField?i[t.textField]:i.full_name||i.name||"":"";break}case"string":case"color":break;default:{let i=t.type}}return o}function l(e,t){let n=e[t];return Array.isArray(n)?n:void 0}function G(e,t,n="childrenNodes"){for(let r of e){if(r.id_public===t)return r;let o=l(r,n);if(o&&o.length>0){let i=G(o,t,n);if(i)return i}}return null}function Oe(e,t="childrenNodes"){let n=[],r=o=>{for(let i of o){n.push(i.id_public);let u=l(i,t);u&&u.length>0&&r(u)}};return r(e),n}function K(e,t,n,r="childrenNodes"){return e.map(o=>{if(o.id_public===t)return n(o);let i=l(o,r);return i&&i.length>0?{...o,[r]:K(i,t,n,r)}:o})}function W(e,t,n="childrenNodes"){return e.filter(r=>r.id_public!==t).map(r=>{let o=l(r,n);return o&&o.length>0?{...r,[n]:W(o,t,n)}:r})}function J(e,t,n,r="childrenNodes"){return t===null?[...e,n]:e.map(o=>{if(o.id_public===t){let u=l(o,r)||[];return{...o,[r]:[...u,n]}}let i=l(o,r);return i&&i.length>0?{...o,[r]:J(i,t,n,r)}:o})}function q(e,t,n="childrenNodes",r=null){for(let o of e){if(o.id_public===t)return r;let i=l(o,n);if(i&&i.length>0){let u=q(i,t,n,o.id_public);if(u!==null)return u}}return null}export{m as __DEV__,J as addNode,Se as clearDeprecationWarnings,c as dateManager,M as deepCopy,_ as deepEqual,I as deepMerge,k as devAssert,Y as devThrow,S as devWarn,G as findNode,q as findParentId,ce as generateGUID,Oe as getAllIds,w as getBrightness,l as getChildren,re as getContrastYIQ,Ae as getFilterFieldType,le as getValueByPath,y as getValueType,A as hexToRgb,Z as isSensitiveSecurityKey,ue as isValueNotEmpty,fe as normalizeString,we as normalizeSystemFilter,X as onKeyActivate,H as parseFilter,E as parseJSONSafely,v as prefersReducedMotion,W as removeNode,te as rgbToHex,Ee as sanitizeContent,Ve as sanitizeEditorContent,Q as sanitizeSecurityData,$e as setColumnBodyType,be as setDateLocale,de as setDefaultStructure,he as springDeprecate,L as toNumber,Ce as truncateString,K as updateNode};