@spring-systems/core 0.8.7 → 0.8.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-F3VXVDPQ.js";import{a as _}from"./chunk-RKLYBW3O.js";import{b as n,c as g}from"./chunk-3OMNT22N.js";import"./chunk-MNLYYTGZ.js";import"./chunk-PNDXLNCU.js";import{a as e,b as r,c as i,d as t}from"./chunk-UT6X6RQM.js";import"./chunk-GSQE2NEY.js";import{d as o,e as a}from"./chunk-RVQHSQYF.js";import"./chunk-R3XYEEGR.js";import"./chunk-YMSSF2ZU.js";import"./chunk-EVDFSWPU.js";import"./chunk-JRHMAY5G.js";import"./chunk-OOVZTF74.js";var p="0.8.7";export{p as SPRING_CORE_VERSION,e as configureCapabilities,o as configureFramework,_ as eventBus,t as getCapabilities,i as getCapability,a as getFrameworkConfig,g as getMiddlewareRunner,r as hasCapability,n as registerMiddleware};
1
+ import"./chunk-F3VXVDPQ.js";import{a as _}from"./chunk-RKLYBW3O.js";import{b as n,c as g}from"./chunk-3OMNT22N.js";import"./chunk-MNLYYTGZ.js";import"./chunk-PNDXLNCU.js";import{a as e,b as r,c as i,d as t}from"./chunk-UT6X6RQM.js";import"./chunk-GSQE2NEY.js";import{d as o,e as a}from"./chunk-RVQHSQYF.js";import"./chunk-R3XYEEGR.js";import"./chunk-YMSSF2ZU.js";import"./chunk-EVDFSWPU.js";import"./chunk-JRHMAY5G.js";import"./chunk-OOVZTF74.js";var p="0.8.9";export{p as SPRING_CORE_VERSION,e as configureCapabilities,o as configureFramework,_ as eventBus,t as getCapabilities,i as getCapability,a as getFrameworkConfig,g as getMiddlewareRunner,r as hasCapability,n as registerMiddleware};
@@ -13,6 +13,47 @@ declare function getBrightness(r: number, g: number, b: number): number;
13
13
  declare function hexToRgb(hex: string): [number, number, number];
14
14
  declare function rgbToHex(rgb: string): string;
15
15
  declare function getContrastYIQ(hex: string): string;
16
+ /**
17
+ * Background → text contrast pairs for automatic text color derivation.
18
+ *
19
+ * Only includes the sidebar menu — the one component where projects routinely
20
+ * override the background independently of `--spring-color-primary`.
21
+ *
22
+ * List headers and buttons are intentionally excluded: their text colors are
23
+ * derived from the CSS variable chain (`text-secondary` / `text-on-accent`)
24
+ * which already produces correct results for both light and dark modes.
25
+ * Auto-deriving them would override intentional design choices (e.g. white
26
+ * text on a medium-toned gold that the YIQ formula classifies as "light").
27
+ */
28
+ declare const CONTRAST_PAIRS: ReadonlyArray<{
29
+ bg: string;
30
+ text: string;
31
+ }>;
32
+ /**
33
+ * Resolve a CSS custom property to a hex color value.
34
+ * Uses a probe element to force the browser to resolve `var()` chains
35
+ * and named colors (e.g. "white") to computed `rgb()` values.
36
+ *
37
+ * @returns Hex color string (e.g. "#2563eb") or null if unresolvable.
38
+ */
39
+ declare function resolveColorVar(cssVar: string, root?: HTMLElement): string | null;
40
+ /**
41
+ * Auto-derive text colors from background colors using YIQ contrast.
42
+ *
43
+ * For each pair: resolves the computed background color, determines if it is
44
+ * light or dark, and sets the text variable to `--spring-color-text` (for
45
+ * light backgrounds) or `#ffffff` (for dark backgrounds).
46
+ *
47
+ * Called automatically by the theme store after dark mode init and on
48
+ * theme changes. Projects can also call it after runtime CSS variable changes.
49
+ *
50
+ * @param pairs — Override default pairs. Defaults to {@link CONTRAST_PAIRS}.
51
+ * @param root — Override root element. Defaults to `document.documentElement`.
52
+ */
53
+ declare function applyContrastColors(pairs?: ReadonlyArray<{
54
+ bg: string;
55
+ text: string;
56
+ }>, root?: HTMLElement): void;
16
57
 
17
58
  declare function isValueNotEmpty(value: string | number | boolean | null | undefined | FormDataValue[]): boolean;
18
59
  /** Returns a deep copy of an object, removing unwanted references. */
@@ -140,4 +181,4 @@ declare function removeNode<T extends BaseTreeNode>(nodes: T[], id: string, chil
140
181
  declare function addNode<T extends BaseTreeNode>(nodes: T[], parentId: string | null, newNode: T, childrenField?: string): T[];
141
182
  declare function findParentId<T extends BaseTreeNode>(nodes: T[], id: string, childrenField?: string, parentId?: string | null): string | null;
142
183
 
143
- export { type BaseTreeNode, type ValueType, __DEV__, addNode, clearDeprecationWarnings, dateManager, deepCopy, deepEqual, deepMerge, devAssert, devThrow, devWarn, findNode, findParentId, generateGUID, getAllIds, getBrightness, getChildren, getContrastYIQ, getFilterFieldType, getValueByPath, getValueType, hexToRgb, isValueNotEmpty, normalizeString, normalizeSystemFilter, onKeyActivate, parseFilter, parseJSONSafely, prefersReducedMotion, removeNode, rgbToHex, sanitizeContent, sanitizeEditorContent, setColumnBodyType, setDateLocale, setDefaultStructure, springDeprecate, toNumber, truncateString, updateNode };
184
+ export { type BaseTreeNode, CONTRAST_PAIRS, type ValueType, __DEV__, addNode, applyContrastColors, clearDeprecationWarnings, dateManager, deepCopy, deepEqual, deepMerge, devAssert, devThrow, devWarn, findNode, findParentId, generateGUID, getAllIds, getBrightness, getChildren, getContrastYIQ, getFilterFieldType, getValueByPath, getValueType, hexToRgb, isValueNotEmpty, normalizeString, normalizeSystemFilter, onKeyActivate, parseFilter, parseJSONSafely, prefersReducedMotion, removeNode, resolveColorVar, rgbToHex, sanitizeContent, sanitizeEditorContent, setColumnBodyType, setDateLocale, setDefaultStructure, springDeprecate, toNumber, truncateString, updateNode };
@@ -1 +1 @@
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};
1
+ import{a as x}from"../chunk-GSQE2NEY.js";import{e as c}from"../chunk-RVQHSQYF.js";import{b as p}from"../chunk-7P4BJDQR.js";import"../chunk-HUASNNWD.js";import"../chunk-YMSSF2ZU.js";import{a as ee,b as te}from"../chunk-EVDFSWPU.js";import{a as m,b as Y,c as w,d as A}from"../chunk-JRHMAY5G.js";import{c as T}from"../chunk-OOVZTF74.js";function re(e){if(e)return t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),e(t))}}function ne(){return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function k(e,t,n){return(e*299+t*587+n*114)/1e3}function F(e){let t=parseInt(e.slice(1),16),n=t>>16&255,r=t>>8&255,o=t&255;return[n,r,o]}function M(e){let t=e.match(/\d+/g);return t?`#${t.map(r=>parseInt(r).toString(16).padStart(2,"0")).join("")}`:"#000000"}function N(e){let[t,n,r]=F(e);return k(t,n,r)>150?"black":"white"}var _=[{bg:"--spring-page-menu-bg",text:"--spring-page-menu-color"}];function h(e,t){if(typeof document>"u")return null;let n=t??document.documentElement,r=getComputedStyle(n).getPropertyValue(e).trim();if(!r||r==="transparent"||r==="initial"||r==="inherit")return null;if(/^#[0-9a-fA-F]{6}$/.test(r))return r;let o=document.createElement("div");o.style.display="none",o.style.color=`var(${e})`,n.appendChild(o);let i=getComputedStyle(o).color;return o.remove(),i?M(i):null}function ie(e=_,t){if(typeof document>"u")return;let n=t??document.documentElement,r=h("--spring-color-text",n)??"#374151";for(let{bg:o,text:i}of e){let u=h(o,n);if(!u)continue;let f=N(u);n.style.setProperty(i,f==="white"?"#ffffff":r)}}import g from"dayjs";import E from"dayjs/plugin/customParseFormat";g.extend(E);var C=new Set(["__proto__","prototype","constructor"]);function ce(e){return e!==0&&e!==null&&e!==void 0&&e!==!1&&e!==""&&!(Array.isArray(e)&&e.length===0)}function I(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]=I(e[o],n));return r}function R(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 f of o)if(!u.has(f)||!R(n[f],r[f]))return!1;return!0}function V(e,t){let n={...e};return Object.keys(t).forEach(r=>{if(C.has(r))return;let o=r;t[o]&&typeof t[o]=="object"&&!Array.isArray(t[o])?n[o]=V(e[o]&&typeof e[o]=="object"?e[o]:{},t[o]):n[o]=t[o]}),n}function de(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 me(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function pe(){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 ge(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 H(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=H(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 $ from"dayjs/plugin/customParseFormat";import O from"dayjs/plugin/isBetween";s.extend($);s.extend(O);var D=null;function B(){let e=c().i18n.dayjsLocale;e&&e!==D&&(s.locale(e),D=e)}function he(e){D=e,s.locale(e)}function a(){return B(),c().i18n.dateFormats}var d={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 we(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 Ae(){b.clear()}function j(e){return e instanceof Date?e.toISOString():Array.isArray(e)?JSON.stringify(e):typeof e=="boolean"?e:e!=null?e.toString():""}function Me(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=j(o);return{field:r,operator:"eq",value:i}});return n.length===0?null:{logic:"and",filters:n}}return null}function Ne(e,t,n){let r=t&&t[e];return r&&typeof r.type=="string"?r.type:y(n)}import S from"sanitize-html";function Ve(e){return e?S(e,{allowedTags:[],allowedAttributes:{}}):""}var P=["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"],U={a:["href","title","target","rel"],td:["colspan","rowspan"],th:["colspan","rowspan"],span:["style"]},z=/^(?!.*(?:url|expression)\s*\()[a-z0-9#(),.%\s-]{1,80}$/i,L=new Set(["_blank","_self","_parent","_top"]);function G(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 K={a:(e,t)=>{let n={...t};if(typeof n.target=="string"){let r=n.target.trim().toLowerCase();L.has(r)?n.target=r:delete n.target}if(n.target==="_blank"){let r=G(n.rel);r.includes("noopener")||r.push("noopener"),r.includes("noreferrer")||r.push("noreferrer"),n.rel=r.join(" ")}return{tagName:e,attribs:n}}},W={span:{"text-decoration":[z]}};function He(e){return e?S(e,{allowedTags:P,allowedAttributes:U,allowedStyles:W,transformTags:K,allowedSchemes:["http","https","mailto"]}):""}function $e(e,t){return e.length<=t?e:t<3?e.slice(0,t):e.slice(0,t-3)+"..."}function v(e,t){let n=c().i18n.numberLocale;return Number(e).toLocaleString(n,{minimumFractionDigits:t||0,maximumFractionDigits:t||0})}function Oe(e,t){let n=t.field,r=e,o=r[n];switch(t.type){case"date":o=d.formatDate(r[n]);break;case"datetime":o=d.formatDateTime(r[n]);break;case"time":o=d.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?v(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 J(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=J(o,t,n);if(i)return i}}return null}function je(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 q(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]:q(i,t,n,r)}:o})}function Z(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]:Z(o,t,n)}:r})}function Q(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]:Q(i,t,n,r)}:o})}function X(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=X(i,t,n,o.id_public);if(u!==null)return u}}return null}export{_ as CONTRAST_PAIRS,m as __DEV__,Q as addNode,ie as applyContrastColors,Ae as clearDeprecationWarnings,d as dateManager,I as deepCopy,R as deepEqual,V as deepMerge,A as devAssert,w as devThrow,Y as devWarn,J as findNode,X as findParentId,pe as generateGUID,je as getAllIds,k as getBrightness,l as getChildren,N as getContrastYIQ,Ne as getFilterFieldType,de as getValueByPath,y as getValueType,F as hexToRgb,ee as isSensitiveSecurityKey,ce as isValueNotEmpty,me as normalizeString,Me as normalizeSystemFilter,re as onKeyActivate,j as parseFilter,H as parseJSONSafely,ne as prefersReducedMotion,Z as removeNode,h as resolveColorVar,M as rgbToHex,Ve as sanitizeContent,He as sanitizeEditorContent,te as sanitizeSecurityData,Oe as setColumnBodyType,he as setDateLocale,ge as setDefaultStructure,we as springDeprecate,v as toNumber,$e as truncateString,q as updateNode};
package/package.json CHANGED
@@ -1,146 +1,145 @@
1
1
  {
2
- "name": "@spring-systems/core",
3
- "version": "0.8.7",
4
- "description": "Core types, utilities, and configuration for the Spring Systems framework",
5
- "type": "module",
6
- "main": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
8
- "files": [
9
- "dist",
10
- "README.md",
11
- "LICENSE",
12
- "CHANGELOG.md"
13
- ],
14
- "license": "UNLICENSED",
15
- "author": "Spring Systems",
16
- "publishConfig": {
17
- "access": "restricted"
2
+ "name": "@spring-systems/core",
3
+ "version": "0.8.9",
4
+ "description": "Core types, utilities, and configuration for the Spring Systems framework",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "README.md",
11
+ "LICENSE",
12
+ "CHANGELOG.md"
13
+ ],
14
+ "license": "UNLICENSED",
15
+ "author": "Spring Systems",
16
+ "publishConfig": {
17
+ "access": "restricted"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://bitbucket.org/springsystems-projects/spring-framework-frontend.git",
22
+ "directory": "packages/core"
23
+ },
24
+ "homepage": "https://bitbucket.org/springsystems-projects/spring-framework-frontend/src/main/packages/core#readme",
25
+ "bugs": {
26
+ "url": "https://bitbucket.org/springsystems-projects/spring-framework-frontend/issues"
27
+ },
28
+ "keywords": [
29
+ "spring-systems",
30
+ "typescript",
31
+ "framework",
32
+ "core",
33
+ "event-bus",
34
+ "middleware",
35
+ "configuration"
36
+ ],
37
+ "engines": {
38
+ "node": ">=22.0.0"
39
+ },
40
+ "sideEffects": false,
41
+ "exports": {
42
+ ".": {
43
+ "types": "./dist/index.d.ts",
44
+ "import": "./dist/index.js",
45
+ "default": "./dist/index.js"
18
46
  },
19
- "repository": {
20
- "type": "git",
21
- "url": "git+https://bitbucket.org/springsystems-projects/spring-framework-frontend.git",
22
- "directory": "packages/core"
47
+ "./types": {
48
+ "types": "./dist/types/index.d.ts",
49
+ "import": "./dist/types/index.js",
50
+ "default": "./dist/types/index.js"
23
51
  },
24
- "homepage": "https://bitbucket.org/springsystems-projects/spring-framework-frontend/src/main/packages/core#readme",
25
- "bugs": {
26
- "url": "https://bitbucket.org/springsystems-projects/spring-framework-frontend/issues"
52
+ "./utils": {
53
+ "types": "./dist/utils/index.d.ts",
54
+ "import": "./dist/utils/index.js",
55
+ "default": "./dist/utils/index.js"
27
56
  },
28
- "keywords": [
29
- "spring-systems",
30
- "typescript",
31
- "framework",
32
- "core",
33
- "event-bus",
34
- "middleware",
35
- "configuration"
36
- ],
37
- "engines": {
38
- "node": ">=22.0.0"
57
+ "./config": {
58
+ "types": "./dist/config/index.d.ts",
59
+ "import": "./dist/config/index.js",
60
+ "default": "./dist/config/index.js"
39
61
  },
40
- "sideEffects": false,
41
- "exports": {
42
- ".": {
43
- "types": "./dist/index.d.ts",
44
- "import": "./dist/index.js",
45
- "default": "./dist/index.js"
46
- },
47
- "./types": {
48
- "types": "./dist/types/index.d.ts",
49
- "import": "./dist/types/index.js",
50
- "default": "./dist/types/index.js"
51
- },
52
- "./utils": {
53
- "types": "./dist/utils/index.d.ts",
54
- "import": "./dist/utils/index.js",
55
- "default": "./dist/utils/index.js"
56
- },
57
- "./config": {
58
- "types": "./dist/config/index.d.ts",
59
- "import": "./dist/config/index.js",
60
- "default": "./dist/config/index.js"
61
- },
62
- "./validation": {
63
- "types": "./dist/validation/index.d.ts",
64
- "import": "./dist/validation/index.js",
65
- "default": "./dist/validation/index.js"
66
- },
67
- "./logger": {
68
- "types": "./dist/logger/index.d.ts",
69
- "import": "./dist/logger/index.js",
70
- "default": "./dist/logger/index.js"
71
- },
72
- "./auth": {
73
- "types": "./dist/auth/index.d.ts",
74
- "import": "./dist/auth/index.js",
75
- "default": "./dist/auth/index.js"
76
- },
77
- "./adapters": {
78
- "types": "./dist/adapters/index.d.ts",
79
- "import": "./dist/adapters/index.js",
80
- "default": "./dist/adapters/index.js"
81
- },
82
- "./plugins": {
83
- "types": "./dist/plugins/index.d.ts",
84
- "import": "./dist/plugins/index.js",
85
- "default": "./dist/plugins/index.js"
86
- },
87
- "./events": {
88
- "types": "./dist/events/index.d.ts",
89
- "import": "./dist/events/index.js",
90
- "default": "./dist/events/index.js"
91
- },
92
- "./middleware": {
93
- "types": "./dist/middleware/index.d.ts",
94
- "import": "./dist/middleware/index.js",
95
- "default": "./dist/middleware/index.js"
96
- },
97
- "./errors": {
98
- "types": "./dist/errors/index.d.ts",
99
- "import": "./dist/errors/index.js",
100
- "default": "./dist/errors/index.js"
101
- },
102
- "./i18n": {
103
- "types": "./dist/i18n/index.d.ts",
104
- "import": "./dist/i18n/index.js",
105
- "default": "./dist/i18n/index.js"
106
- },
107
- "./instance": {
108
- "types": "./dist/instance/index.d.ts",
109
- "import": "./dist/instance/index.js",
110
- "default": "./dist/instance/index.js"
111
- },
112
- "./testing": {
113
- "types": "./dist/testing/index.d.ts",
114
- "import": "./dist/testing/index.js",
115
- "default": "./dist/testing/index.js"
116
- },
117
- "./devtools": {
118
- "types": "./dist/devtools/index.d.ts",
119
- "import": "./dist/devtools/index.js",
120
- "default": "./dist/devtools/index.js"
121
- }
62
+ "./validation": {
63
+ "types": "./dist/validation/index.d.ts",
64
+ "import": "./dist/validation/index.js",
65
+ "default": "./dist/validation/index.js"
122
66
  },
123
- "scripts": {
124
- "build": "tsup",
125
- "dev": "tsup --watch",
126
- "typecheck": "tsc --noEmit",
127
- "test": "vitest run",
128
- "check:circular": "madge --circular --extensions ts,tsx --ts-config ../../tsconfig.base.json ./src",
129
- "lint": "eslint src/",
130
- "check:exports": "node scripts/check-exports.mjs",
131
- "prepack": "pnpm run build && pnpm check:exports"
67
+ "./logger": {
68
+ "types": "./dist/logger/index.d.ts",
69
+ "import": "./dist/logger/index.js",
70
+ "default": "./dist/logger/index.js"
132
71
  },
133
- "dependencies": {
134
- "dayjs": "^1.11.19",
135
- "sanitize-html": "^2.17.1"
72
+ "./auth": {
73
+ "types": "./dist/auth/index.d.ts",
74
+ "import": "./dist/auth/index.js",
75
+ "default": "./dist/auth/index.js"
136
76
  },
137
- "devDependencies": {
138
- "@types/jsdom": "^28.0.0",
139
- "@types/sanitize-html": "^2.16.1",
140
- "@vitest/coverage-v8": "^4.0.18",
141
- "jsdom": "^25.0.1",
142
- "tsup": "^8.5.1",
143
- "typescript": "^5.9.3",
144
- "vitest": "^4.0.18"
77
+ "./adapters": {
78
+ "types": "./dist/adapters/index.d.ts",
79
+ "import": "./dist/adapters/index.js",
80
+ "default": "./dist/adapters/index.js"
81
+ },
82
+ "./plugins": {
83
+ "types": "./dist/plugins/index.d.ts",
84
+ "import": "./dist/plugins/index.js",
85
+ "default": "./dist/plugins/index.js"
86
+ },
87
+ "./events": {
88
+ "types": "./dist/events/index.d.ts",
89
+ "import": "./dist/events/index.js",
90
+ "default": "./dist/events/index.js"
91
+ },
92
+ "./middleware": {
93
+ "types": "./dist/middleware/index.d.ts",
94
+ "import": "./dist/middleware/index.js",
95
+ "default": "./dist/middleware/index.js"
96
+ },
97
+ "./errors": {
98
+ "types": "./dist/errors/index.d.ts",
99
+ "import": "./dist/errors/index.js",
100
+ "default": "./dist/errors/index.js"
101
+ },
102
+ "./i18n": {
103
+ "types": "./dist/i18n/index.d.ts",
104
+ "import": "./dist/i18n/index.js",
105
+ "default": "./dist/i18n/index.js"
106
+ },
107
+ "./instance": {
108
+ "types": "./dist/instance/index.d.ts",
109
+ "import": "./dist/instance/index.js",
110
+ "default": "./dist/instance/index.js"
111
+ },
112
+ "./testing": {
113
+ "types": "./dist/testing/index.d.ts",
114
+ "import": "./dist/testing/index.js",
115
+ "default": "./dist/testing/index.js"
116
+ },
117
+ "./devtools": {
118
+ "types": "./dist/devtools/index.d.ts",
119
+ "import": "./dist/devtools/index.js",
120
+ "default": "./dist/devtools/index.js"
145
121
  }
146
- }
122
+ },
123
+ "dependencies": {
124
+ "dayjs": "^1.11.19",
125
+ "sanitize-html": "^2.17.1"
126
+ },
127
+ "devDependencies": {
128
+ "@types/jsdom": "^28.0.0",
129
+ "@types/sanitize-html": "^2.16.1",
130
+ "@vitest/coverage-v8": "^4.0.18",
131
+ "jsdom": "^25.0.1",
132
+ "tsup": "^8.5.1",
133
+ "typescript": "^5.9.3",
134
+ "vitest": "^4.0.18"
135
+ },
136
+ "scripts": {
137
+ "build": "tsup",
138
+ "dev": "tsup --watch",
139
+ "typecheck": "tsc --noEmit",
140
+ "test": "vitest run",
141
+ "check:circular": "madge --circular --extensions ts,tsx --ts-config ../../tsconfig.base.json ./src",
142
+ "lint": "eslint src/",
143
+ "check:exports": "node scripts/check-exports.mjs"
144
+ }
145
+ }