@abpjs/ui 0.2.0-next.2 → 0.2.0-next.21

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/rules.d.ts CHANGED
@@ -70,6 +70,28 @@ declare function inGroups<T>(rows: readonly T[], of: (row: T) => string): {
70
70
  rows: T[];
71
71
  }[];
72
72
 
73
+ /** Names by language, as settings keep them: `{ en: 'Triage', ar: 'الفرز' }`. */
74
+ type Names = Record<string, string | null | undefined> | null | undefined;
75
+ /**
76
+ * The languages to try, in order, when showing a name: the reader's, its base language (ar for ar-SA), the site's
77
+ * default, then English.
78
+ */
79
+ declare function languageChain(locale: string, defaultLanguage?: string | null): string[];
80
+ /** A name in the first language of the chain that has one, else any name given, else the fallback (usually a key). */
81
+ declare function pickName(chain: readonly string[], names: Names, fallback: string): string;
82
+ /** A comma- or line-separated list, trimmed, without blanks. */
83
+ declare function splitList(value: string): string[];
84
+ /**
85
+ * A name kept as a written name and its other languages (`{ name, names }`, as servers keep a group's or a directory's),
86
+ * as the one map `TranslatedInput` edits: the written name under `written` (English unless said).
87
+ */
88
+ declare function toNamesValue(name: string | null | undefined, names: Names, written?: string): Record<string, string>;
89
+ /** And back: the written name, and the other languages with blanks dropped and each trimmed. */
90
+ declare function fromNamesValue(value: Record<string, string>, written?: string): {
91
+ name: string;
92
+ names: Record<string, string>;
93
+ };
94
+
73
95
  /**
74
96
  * Settings in sections (ADR 0095, moved into the design system by ADR 0109): an area's sections and pages each have a
75
97
  * key and a weight. The higher the weight, the nearer the top; equal ones by title. A host's own come in steps of 100,
@@ -116,4 +138,4 @@ declare function findSettingsPage<P extends {
116
138
  href: string;
117
139
  }>(pages: P[], pathname: string): P | undefined;
118
140
 
119
- export { LIST_OPS, type MaybeVisible, NO_VALUE_OPS, type QueryConditionJson, type QueryField, type SettingsPageLike, type SettingsSectionLike, findSettingsPage, foldBreadcrumbs, groupKey, heavierFirst, inGroups, inSections, mergeSameField, parseValue, periodName, settingsArea, valueText };
141
+ export { LIST_OPS, type MaybeVisible, NO_VALUE_OPS, type Names, type QueryConditionJson, type QueryField, type SettingsPageLike, type SettingsSectionLike, findSettingsPage, foldBreadcrumbs, fromNamesValue, groupKey, heavierFirst, inGroups, inSections, languageChain, mergeSameField, parseValue, periodName, pickName, settingsArea, splitList, toNamesValue, valueText };
package/dist/rules.js CHANGED
@@ -85,6 +85,36 @@ function inGroups(rows, of) {
85
85
  return groups;
86
86
  }
87
87
 
88
+ // src/rules/names.ts
89
+ function languageChain(locale, defaultLanguage) {
90
+ return [...new Set([locale, locale.split("-")[0], defaultLanguage ?? "", "en"].filter(Boolean))];
91
+ }
92
+ function pickName(chain, names, fallback) {
93
+ if (names) {
94
+ for (const code of chain) {
95
+ const value = names[code];
96
+ if (value && value.trim()) return value;
97
+ }
98
+ for (const value of Object.values(names)) if (value && value.trim()) return value;
99
+ }
100
+ return fallback;
101
+ }
102
+ function splitList(value) {
103
+ return value.split(/[,\n]/).map((x) => x.trim()).filter(Boolean);
104
+ }
105
+ function toNamesValue(name, names, written = "en") {
106
+ const value = {};
107
+ for (const [code, text] of Object.entries(names ?? {})) if (text && text.trim()) value[code] = text;
108
+ if (name && name.trim()) value[written] = name;
109
+ return value;
110
+ }
111
+ function fromNamesValue(value, written = "en") {
112
+ const names = Object.fromEntries(
113
+ Object.entries(value).filter(([code, text]) => code !== written && text && text.trim()).map(([code, text]) => [code, text.trim()])
114
+ );
115
+ return { name: (value[written] ?? "").trim(), names };
116
+ }
117
+
88
118
  // src/rules/settings.ts
89
119
  var heavierFirst = (a, b) => b.weight - a.weight || a.title.localeCompare(b.title);
90
120
  function inSections(sections, pages) {
@@ -103,14 +133,19 @@ export {
103
133
  NO_VALUE_OPS,
104
134
  findSettingsPage,
105
135
  foldBreadcrumbs,
136
+ fromNamesValue,
106
137
  groupKey,
107
138
  heavierFirst,
108
139
  inGroups,
109
140
  inSections,
141
+ languageChain,
110
142
  mergeSameField,
111
143
  parseValue,
112
144
  periodName,
145
+ pickName,
113
146
  settingsArea,
147
+ splitList,
148
+ toNamesValue,
114
149
  valueText
115
150
  };
116
151
  //# sourceMappingURL=rules.js.map
package/dist/rules.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/rules/breadcrumbs.ts","../src/rules/conditions.ts","../src/rules/grouping.ts","../src/rules/settings.ts"],"sourcesContent":["/**\n * A breadcrumb trail past four levels, folded (UI round 9, step 66): the first and the last two stay, the middle ones\n * go behind \"…\" (`null` in `shown`) and come back as `hidden`. Four or fewer stay as they are.\n */\nexport function foldBreadcrumbs<T>(items: readonly T[]): { shown: ({ item: T; index: number } | null)[]; hidden: T[] } {\n if (items.length <= 4) return { shown: items.map((item, index) => ({ item, index })), hidden: [] };\n return {\n shown: [{ item: items[0], index: 0 }, null, ...items.slice(-2).map((item, k) => ({ item, index: items.length - 2 + k }))],\n hidden: items.slice(1, -2),\n };\n}\n","/**\n * A query's conditions as the filter builders write them (ADR 0013; UI round 9, step 57): which operators take a value\n * or a list, a typed value as the query takes it and back, and conditions on one field merged into \"is any of\".\n */\n\n/** A field a query can use, as GET /api/query/{entity}/fields returns it. */\nexport interface QueryField {\n id: string;\n kind: string;\n label: string;\n sortable: boolean;\n groupable: boolean;\n /** JSON-form operator names: eq, ne, in, notIn, contains, isEmpty… */\n operators: string[];\n}\n\n/** One condition in a query's JSON form. */\nexport interface QueryConditionJson {\n field: string;\n op: string;\n value?: unknown;\n}\n\n/** Operators that take no value (\"is empty\"). */\nexport const NO_VALUE_OPS: ReadonlySet<string> = new Set(['isEmpty', 'isNotEmpty']);\n/** Operators whose value is a list (\"is any of\", and \"between\" with its two ends). */\nexport const LIST_OPS: ReadonlySet<string> = new Set(['in', 'notIn', 'hasAny', 'hasAll', 'between']);\n\n/** A typed value as the query takes it: a function call (\"startOfDay()\") or the text. */\nexport function parseValue(text: string): unknown {\n const call = /^([A-Za-z]\\w*)\\((.*)\\)$/.exec(text.trim());\n if (call) {\n const args = call[2].trim() === '' ? [] : call[2].split(',').map((a) => (Number.isFinite(Number(a.trim())) ? Number(a.trim()) : a.trim()));\n return { fn: call[1], args };\n }\n return text.trim();\n}\n\n/** A condition's value as text (a chip's, or a box's to edit). */\nexport function valueText(value: unknown): string {\n if (value == null) return '';\n if (Array.isArray(value)) return value.map(valueText).join(', ');\n if (typeof value === 'object') {\n const v = value as Record<string, unknown>;\n if (typeof v.fn === 'string') return `${v.fn}(${Array.isArray(v.args) ? v.args.map(valueText).join(', ') : ''})`;\n if (typeof v.field === 'string') return `field(${v.field})`;\n if ('query' in v) return '(…)';\n }\n return String(value);\n}\n\n/**\n * Conditions on one field that each say \"is\" one value become one \"is any of\" (\"Conditions on the same field match any\n * of their values\"), where the field takes that operator; everything else stays an AND. The conditions given are left\n * as they were.\n */\nexport function mergeSameField(conditions: readonly QueryConditionJson[], fields: readonly Pick<QueryField, 'id' | 'operators'>[]): QueryConditionJson[] {\n const out: QueryConditionJson[] = [];\n for (const c of conditions) {\n const field = fields.find((f) => f.id === c.field);\n const into = c.op === 'eq' && field?.operators.includes('in') ? out.find((o) => o.field === c.field && (o.op === 'eq' || o.op === 'in')) : undefined;\n if (into) {\n const values = [...(into.op === 'in' ? (into.value as unknown[]) : [into.value]), c.value];\n into.op = 'in';\n into.value = values;\n } else {\n out.push({ ...c });\n }\n }\n return out;\n}\n","/**\n * A grouped query's rows (ADR 0013): a row's group as a key, a date period's name, and rows cut into their groups.\n */\n\n/**\n * A row's group, as a key: a reference's key or id (a status, a person), a value's text, or \"\" for none. The groups a\n * grouped query returns key the same way, so a row finds its group's count and name.\n */\nexport function groupKey(value: unknown): string {\n if (value == null) return '';\n if (typeof value === 'object') {\n const v = value as Record<string, unknown>;\n const id = v.key ?? v.id ?? v.username ?? v.name;\n return id == null ? JSON.stringify(value) : String(id);\n }\n return String(value);\n}\n\n/**\n * A date period's name from its first day (yyyy-mm-dd), in the reader's language: a day, \"Week of 2 Nov 2026\",\n * \"November 2026\", \"Q4 2026\", \"2026\". The day is read as written, never shifted by a time zone.\n */\nexport function periodName(day: string, period: string, locale: string, labels: { week: string; quarter: string }): string {\n const m = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(day);\n if (!m) return day;\n const date = new Date(Date.UTC(Number(m[1]), Number(m[2]) - 1, Number(m[3])));\n const format = (options: Intl.DateTimeFormatOptions) => new Intl.DateTimeFormat(locale, { numberingSystem: 'latn', ...options, timeZone: 'UTC' }).format(date);\n const fill = (template: string, values: Record<string, string>) => template.replace(/\\{(\\w+)\\}/g, (_, k: string) => values[k] ?? `{${k}}`);\n switch (period) {\n case 'year': return format({ year: 'numeric' });\n case 'quarter': return fill(labels.quarter, { quarter: new Intl.NumberFormat(locale, { numberingSystem: 'latn' }).format(Math.floor((Number(m[2]) - 1) / 3) + 1), year: format({ year: 'numeric' }) });\n case 'month': return format({ month: 'long', year: 'numeric' });\n case 'week': return fill(labels.week, { day: format({ day: 'numeric', month: 'short', year: 'numeric' }) });\n default: return format({ day: 'numeric', month: 'short', year: 'numeric' });\n }\n}\n\n/**\n * Rows in their groups, in the order they came (a grouped query's rows come in group order): a new group wherever the\n * key changes, so a group split by paging stays one when its rows are together.\n */\nexport function inGroups<T>(rows: readonly T[], of: (row: T) => string): { key: string; rows: T[] }[] {\n const groups: { key: string; rows: T[] }[] = [];\n for (const row of rows) {\n const key = of(row);\n const last = groups[groups.length - 1];\n if (last && last.key === key) last.rows.push(row);\n else groups.push({ key, rows: [row] });\n }\n return groups;\n}\n","/**\n * Settings in sections (ADR 0095, moved into the design system by ADR 0109): an area's sections and pages each have a\n * key and a weight. The higher the weight, the nearer the top; equal ones by title. A host's own come in steps of 100,\n * so a package's or a plugin's section or page fits between any two of them.\n */\n\nexport interface SettingsSectionLike {\n key: string;\n weight: number;\n title: string;\n}\n\nexport interface SettingsPageLike {\n section: string;\n weight: number;\n title: string;\n}\n\n/** Heavier first, then by title. */\nexport const heavierFirst = (a: { weight: number; title: string }, b: { weight: number; title: string }) =>\n b.weight - a.weight || a.title.localeCompare(b.title);\n\n/** The sections that have pages, heaviest first, each with its pages heaviest first; a page whose section isn't there is left out. */\nexport function inSections<S extends SettingsSectionLike, P extends SettingsPageLike>(sections: S[], pages: P[]): { section: S; pages: P[] }[] {\n return [...sections]\n .sort(heavierFirst)\n .map((section) => ({ section, pages: pages.filter((p) => p.section === section.key).sort(heavierFirst) }))\n .filter((s) => s.pages.length > 0);\n}\n\n/** A page that may say who sees it (a flag, or a check the host's rights answer). */\nexport interface MaybeVisible {\n visible?: boolean | (() => boolean);\n}\n\nconst isVisible = (p: MaybeVisible) => (typeof p.visible === 'function' ? p.visible() : p.visible !== false);\n\n/**\n * An area's sections with the pages this person may see, heaviest first then by title: the host's static sections and\n * pages together with the ones it loads (ADR 0095's order, unchanged). A section a package or plugin adds under a key\n * the host already has is taken once, the host's first.\n */\nexport function settingsArea<S extends SettingsSectionLike, P extends SettingsPageLike & MaybeVisible>(sections: S[], pages: P[]): { section: S; pages: P[] }[] {\n const once = sections.filter((s, i) => sections.findIndex((x) => x.key === s.key) === i);\n return inSections(once, pages.filter(isVisible));\n}\n\n/** The page an address opens, for a host's catch-all route: the one whose `href` is the address or above it, the longest. */\nexport function findSettingsPage<P extends { href: string }>(pages: P[], pathname: string): P | undefined {\n return pages.filter((p) => pathname === p.href || pathname.startsWith(`${p.href}/`)).sort((a, b) => b.href.length - a.href.length)[0];\n}\n"],"mappings":";AAIO,SAAS,gBAAmB,OAAoF;AACrH,MAAI,MAAM,UAAU,EAAG,QAAO,EAAE,OAAO,MAAM,IAAI,CAAC,MAAM,WAAW,EAAE,MAAM,MAAM,EAAE,GAAG,QAAQ,CAAC,EAAE;AACjG,SAAO;AAAA,IACL,OAAO,CAAC,EAAE,MAAM,MAAM,CAAC,GAAG,OAAO,EAAE,GAAG,MAAM,GAAG,MAAM,MAAM,EAAE,EAAE,IAAI,CAAC,MAAM,OAAO,EAAE,MAAM,OAAO,MAAM,SAAS,IAAI,EAAE,EAAE,CAAC;AAAA,IACxH,QAAQ,MAAM,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,OAAO,EAAE,YAAY,aAAa,EAAE,QAAQ,IAAI,EAAE,YAAY;AAO/F,SAAS,aAAuF,UAAe,OAA0C;AAC9J,QAAM,OAAO,SAAS,OAAO,CAAC,GAAG,MAAM,SAAS,UAAU,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;AACvF,SAAO,WAAW,MAAM,MAAM,OAAO,SAAS,CAAC;AACjD;AAGO,SAAS,iBAA6C,OAAY,UAAiC;AACxG,SAAO,MAAM,OAAO,CAAC,MAAM,aAAa,EAAE,QAAQ,SAAS,WAAW,GAAG,EAAE,IAAI,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,SAAS,EAAE,KAAK,MAAM,EAAE,CAAC;AACtI;","names":[]}
1
+ {"version":3,"sources":["../src/rules/breadcrumbs.ts","../src/rules/conditions.ts","../src/rules/grouping.ts","../src/rules/names.ts","../src/rules/settings.ts"],"sourcesContent":["/**\n * A breadcrumb trail past four levels, folded (UI round 9, step 66): the first and the last two stay, the middle ones\n * go behind \"…\" (`null` in `shown`) and come back as `hidden`. Four or fewer stay as they are.\n */\nexport function foldBreadcrumbs<T>(items: readonly T[]): { shown: ({ item: T; index: number } | null)[]; hidden: T[] } {\n if (items.length <= 4) return { shown: items.map((item, index) => ({ item, index })), hidden: [] };\n return {\n shown: [{ item: items[0], index: 0 }, null, ...items.slice(-2).map((item, k) => ({ item, index: items.length - 2 + k }))],\n hidden: items.slice(1, -2),\n };\n}\n","/**\n * A query's conditions as the filter builders write them (ADR 0013; UI round 9, step 57): which operators take a value\n * or a list, a typed value as the query takes it and back, and conditions on one field merged into \"is any of\".\n */\n\n/** A field a query can use, as GET /api/query/{entity}/fields returns it. */\nexport interface QueryField {\n id: string;\n kind: string;\n label: string;\n sortable: boolean;\n groupable: boolean;\n /** JSON-form operator names: eq, ne, in, notIn, contains, isEmpty… */\n operators: string[];\n}\n\n/** One condition in a query's JSON form. */\nexport interface QueryConditionJson {\n field: string;\n op: string;\n value?: unknown;\n}\n\n/** Operators that take no value (\"is empty\"). */\nexport const NO_VALUE_OPS: ReadonlySet<string> = new Set(['isEmpty', 'isNotEmpty']);\n/** Operators whose value is a list (\"is any of\", and \"between\" with its two ends). */\nexport const LIST_OPS: ReadonlySet<string> = new Set(['in', 'notIn', 'hasAny', 'hasAll', 'between']);\n\n/** A typed value as the query takes it: a function call (\"startOfDay()\") or the text. */\nexport function parseValue(text: string): unknown {\n const call = /^([A-Za-z]\\w*)\\((.*)\\)$/.exec(text.trim());\n if (call) {\n const args = call[2].trim() === '' ? [] : call[2].split(',').map((a) => (Number.isFinite(Number(a.trim())) ? Number(a.trim()) : a.trim()));\n return { fn: call[1], args };\n }\n return text.trim();\n}\n\n/** A condition's value as text (a chip's, or a box's to edit). */\nexport function valueText(value: unknown): string {\n if (value == null) return '';\n if (Array.isArray(value)) return value.map(valueText).join(', ');\n if (typeof value === 'object') {\n const v = value as Record<string, unknown>;\n if (typeof v.fn === 'string') return `${v.fn}(${Array.isArray(v.args) ? v.args.map(valueText).join(', ') : ''})`;\n if (typeof v.field === 'string') return `field(${v.field})`;\n if ('query' in v) return '(…)';\n }\n return String(value);\n}\n\n/**\n * Conditions on one field that each say \"is\" one value become one \"is any of\" (\"Conditions on the same field match any\n * of their values\"), where the field takes that operator; everything else stays an AND. The conditions given are left\n * as they were.\n */\nexport function mergeSameField(conditions: readonly QueryConditionJson[], fields: readonly Pick<QueryField, 'id' | 'operators'>[]): QueryConditionJson[] {\n const out: QueryConditionJson[] = [];\n for (const c of conditions) {\n const field = fields.find((f) => f.id === c.field);\n const into = c.op === 'eq' && field?.operators.includes('in') ? out.find((o) => o.field === c.field && (o.op === 'eq' || o.op === 'in')) : undefined;\n if (into) {\n const values = [...(into.op === 'in' ? (into.value as unknown[]) : [into.value]), c.value];\n into.op = 'in';\n into.value = values;\n } else {\n out.push({ ...c });\n }\n }\n return out;\n}\n","/**\n * A grouped query's rows (ADR 0013): a row's group as a key, a date period's name, and rows cut into their groups.\n */\n\n/**\n * A row's group, as a key: a reference's key or id (a status, a person), a value's text, or \"\" for none. The groups a\n * grouped query returns key the same way, so a row finds its group's count and name.\n */\nexport function groupKey(value: unknown): string {\n if (value == null) return '';\n if (typeof value === 'object') {\n const v = value as Record<string, unknown>;\n const id = v.key ?? v.id ?? v.username ?? v.name;\n return id == null ? JSON.stringify(value) : String(id);\n }\n return String(value);\n}\n\n/**\n * A date period's name from its first day (yyyy-mm-dd), in the reader's language: a day, \"Week of 2 Nov 2026\",\n * \"November 2026\", \"Q4 2026\", \"2026\". The day is read as written, never shifted by a time zone.\n */\nexport function periodName(day: string, period: string, locale: string, labels: { week: string; quarter: string }): string {\n const m = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(day);\n if (!m) return day;\n const date = new Date(Date.UTC(Number(m[1]), Number(m[2]) - 1, Number(m[3])));\n const format = (options: Intl.DateTimeFormatOptions) => new Intl.DateTimeFormat(locale, { numberingSystem: 'latn', ...options, timeZone: 'UTC' }).format(date);\n const fill = (template: string, values: Record<string, string>) => template.replace(/\\{(\\w+)\\}/g, (_, k: string) => values[k] ?? `{${k}}`);\n switch (period) {\n case 'year': return format({ year: 'numeric' });\n case 'quarter': return fill(labels.quarter, { quarter: new Intl.NumberFormat(locale, { numberingSystem: 'latn' }).format(Math.floor((Number(m[2]) - 1) / 3) + 1), year: format({ year: 'numeric' }) });\n case 'month': return format({ month: 'long', year: 'numeric' });\n case 'week': return fill(labels.week, { day: format({ day: 'numeric', month: 'short', year: 'numeric' }) });\n default: return format({ day: 'numeric', month: 'short', year: 'numeric' });\n }\n}\n\n/**\n * Rows in their groups, in the order they came (a grouped query's rows come in group order): a new group wherever the\n * key changes, so a group split by paging stays one when its rows are together.\n */\nexport function inGroups<T>(rows: readonly T[], of: (row: T) => string): { key: string; rows: T[] }[] {\n const groups: { key: string; rows: T[] }[] = [];\n for (const row of rows) {\n const key = of(row);\n const last = groups[groups.length - 1];\n if (last && last.key === key) last.rows.push(row);\n else groups.push({ key, rows: [row] });\n }\n return groups;\n}\n","/** Names by language, as settings keep them: `{ en: 'Triage', ar: 'الفرز' }`. */\nexport type Names = Record<string, string | null | undefined> | null | undefined;\n\n/**\n * The languages to try, in order, when showing a name: the reader's, its base language (ar for ar-SA), the site's\n * default, then English.\n */\nexport function languageChain(locale: string, defaultLanguage?: string | null): string[] {\n return [...new Set([locale, locale.split('-')[0], defaultLanguage ?? '', 'en'].filter(Boolean))];\n}\n\n/** A name in the first language of the chain that has one, else any name given, else the fallback (usually a key). */\nexport function pickName(chain: readonly string[], names: Names, fallback: string): string {\n if (names) {\n for (const code of chain) {\n const value = names[code];\n if (value && value.trim()) return value;\n }\n for (const value of Object.values(names)) if (value && value.trim()) return value;\n }\n return fallback;\n}\n\n/** A comma- or line-separated list, trimmed, without blanks. */\nexport function splitList(value: string): string[] {\n return value.split(/[,\\n]/).map((x) => x.trim()).filter(Boolean);\n}\n\n/**\n * A name kept as a written name and its other languages (`{ name, names }`, as servers keep a group's or a directory's),\n * as the one map `TranslatedInput` edits: the written name under `written` (English unless said).\n */\nexport function toNamesValue(name: string | null | undefined, names: Names, written = 'en'): Record<string, string> {\n const value: Record<string, string> = {};\n for (const [code, text] of Object.entries(names ?? {})) if (text && text.trim()) value[code] = text;\n if (name && name.trim()) value[written] = name;\n return value;\n}\n\n/** And back: the written name, and the other languages with blanks dropped and each trimmed. */\nexport function fromNamesValue(value: Record<string, string>, written = 'en'): { name: string; names: Record<string, string> } {\n const names = Object.fromEntries(\n Object.entries(value)\n .filter(([code, text]) => code !== written && text && text.trim())\n .map(([code, text]) => [code, text.trim()]),\n );\n return { name: (value[written] ?? '').trim(), names };\n}\n","/**\n * Settings in sections (ADR 0095, moved into the design system by ADR 0109): an area's sections and pages each have a\n * key and a weight. The higher the weight, the nearer the top; equal ones by title. A host's own come in steps of 100,\n * so a package's or a plugin's section or page fits between any two of them.\n */\n\nexport interface SettingsSectionLike {\n key: string;\n weight: number;\n title: string;\n}\n\nexport interface SettingsPageLike {\n section: string;\n weight: number;\n title: string;\n}\n\n/** Heavier first, then by title. */\nexport const heavierFirst = (a: { weight: number; title: string }, b: { weight: number; title: string }) =>\n b.weight - a.weight || a.title.localeCompare(b.title);\n\n/** The sections that have pages, heaviest first, each with its pages heaviest first; a page whose section isn't there is left out. */\nexport function inSections<S extends SettingsSectionLike, P extends SettingsPageLike>(sections: S[], pages: P[]): { section: S; pages: P[] }[] {\n return [...sections]\n .sort(heavierFirst)\n .map((section) => ({ section, pages: pages.filter((p) => p.section === section.key).sort(heavierFirst) }))\n .filter((s) => s.pages.length > 0);\n}\n\n/** A page that may say who sees it (a flag, or a check the host's rights answer). */\nexport interface MaybeVisible {\n visible?: boolean | (() => boolean);\n}\n\nconst isVisible = (p: MaybeVisible) => (typeof p.visible === 'function' ? p.visible() : p.visible !== false);\n\n/**\n * An area's sections with the pages this person may see, heaviest first then by title: the host's static sections and\n * pages together with the ones it loads (ADR 0095's order, unchanged). A section a package or plugin adds under a key\n * the host already has is taken once, the host's first.\n */\nexport function settingsArea<S extends SettingsSectionLike, P extends SettingsPageLike & MaybeVisible>(sections: S[], pages: P[]): { section: S; pages: P[] }[] {\n const once = sections.filter((s, i) => sections.findIndex((x) => x.key === s.key) === i);\n return inSections(once, pages.filter(isVisible));\n}\n\n/** The page an address opens, for a host's catch-all route: the one whose `href` is the address or above it, the longest. */\nexport function findSettingsPage<P extends { href: string }>(pages: P[], pathname: string): P | undefined {\n return pages.filter((p) => pathname === p.href || pathname.startsWith(`${p.href}/`)).sort((a, b) => b.href.length - a.href.length)[0];\n}\n"],"mappings":";AAIO,SAAS,gBAAmB,OAAoF;AACrH,MAAI,MAAM,UAAU,EAAG,QAAO,EAAE,OAAO,MAAM,IAAI,CAAC,MAAM,WAAW,EAAE,MAAM,MAAM,EAAE,GAAG,QAAQ,CAAC,EAAE;AACjG,SAAO;AAAA,IACL,OAAO,CAAC,EAAE,MAAM,MAAM,CAAC,GAAG,OAAO,EAAE,GAAG,MAAM,GAAG,MA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AAC,MAAM,EAAE,MAAM,SAAS,CAAC;AACrC;AAOA,IAAM,YAAY,CAAC,MAAqB,OAAO,EAAE,YAAY,aAAa,EAAE,QAAQ,IAAI,EAAE,YAAY;AAO/F,SAAS,aAAuF,UAAe,OAA0C;AAC9J,QAAM,OAAO,SAAS,OAAO,CAAC,GAAG,MAAM,SAAS,UAAU,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;AACvF,SAAO,WAAW,MAAM,MAAM,OAAO,SAAS,CAAC;AACjD;AAGO,SAAS,iBAA6C,OAAY,UAAiC;AACxG,SAAO,MAAM,OAAO,CAAC,MAAM,aAAa,EAAE,QAAQ,SAAS,WAAW,GAAG,EAAE,IAAI,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,SAAS,EAAE,KAAK,MAAM,EAAE,CAAC;AACtI;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abpjs/ui",
3
- "version": "0.2.0-next.2",
3
+ "version": "0.2.0-next.21",
4
4
  "description": "The design system for ABP applications on Chakra UI v3 and React 19: tokens, recipes, the app shell, tables, lists, boards, forms and a settings frame. Names no product: the host gives its prefix, colours and words.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -39,6 +39,16 @@
39
39
  "import": "./dist/ai.js",
40
40
  "default": "./dist/ai.js"
41
41
  },
42
+ "./agent": {
43
+ "types": "./dist/agent.d.ts",
44
+ "import": "./dist/agent.js",
45
+ "default": "./dist/agent.js"
46
+ },
47
+ "./guard": {
48
+ "types": "./dist/guard.d.ts",
49
+ "import": "./dist/guard.js",
50
+ "default": "./dist/guard.js"
51
+ },
42
52
  "./package.json": "./package.json"
43
53
  },
44
54
  "files": [
@@ -71,9 +81,12 @@
71
81
  },
72
82
  "dependencies": {
73
83
  "@chakra-ui/charts": "3.38.0",
84
+ "@dagrejs/dagre": "3.1.1",
74
85
  "@dnd-kit/core": "6.3.1",
75
86
  "@dnd-kit/sortable": "10.0.0",
76
87
  "@dnd-kit/utilities": "3.2.2",
88
+ "@emotion/cache": "^11.14.0",
89
+ "@xyflow/react": "12.12.0",
77
90
  "lucide-react": "1.52.0",
78
91
  "motion": "13.5.1",
79
92
  "recharts": "3.10.1"