@aglyn/shared-data-enums 1.15.2 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/shared-data-enums",
3
- "version": "1.15.2",
3
+ "version": "1.16.0",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://aglyn.com",
6
6
  "repository": {
@@ -25,8 +25,8 @@
25
25
  "./package.json": "./package.json"
26
26
  },
27
27
  "dependencies": {
28
- "@aglyn/shared-data-mdi": "1.15.2",
29
- "@aglyn/shared-util-tools": "1.15.2",
28
+ "@aglyn/shared-data-mdi": "1.16.0",
29
+ "@aglyn/shared-util-tools": "1.16.0",
30
30
  "@swc/helpers": "0.5.23"
31
31
  },
32
32
  "peerDependencies": {
@@ -32,6 +32,12 @@
32
32
  * paste straight in. A leading and trailing pipe are optional, which is what
33
33
  * a copied markdown table has.
34
34
  */
35
+ /**
36
+ * The Table element's 1-based "emphasize column" prop. Named here because a
37
+ * shape edit made outside the element (the canvas) has to move it with its
38
+ * column — see {@link emphasisAfterShapeEdit}.
39
+ */
40
+ export declare const DATA_TABLE_EMPHASIS_PROP = "emphasizeColumn";
35
41
  /** Column alignments the editor offers and the renderer honours. */
36
42
  export declare const DATA_TABLE_ALIGNMENTS: readonly ["left", "center", "right"];
37
43
  export type DataTableAlignment = (typeof DATA_TABLE_ALIGNMENTS)[number];
@@ -105,3 +111,66 @@ export declare function withColumnRemoved(rows: string[][], at: number): string[
105
111
  export declare function withRowAdded(rows: string[][], at?: number): string[][];
106
112
  export declare function withRowRemoved(rows: string[][], at: number): string[][];
107
113
  export declare function withCellSet(rows: string[][], rowIndex: number, columnIndex: number, value: string): string[][];
114
+ /**
115
+ * A cell that holds FORMATTED text: inline markup (bold, italic, underline,
116
+ * a link, a line break), written by the canvas's in-place cell editor.
117
+ *
118
+ * A cell is otherwise plain text, and both kinds live in the same pipe grid:
119
+ * nothing about the storage changes, and a table nobody formats is
120
+ * byte-for-byte what it always was. The test is "starts a tag or spells a
121
+ * character reference", which is what the editor writes for ANY cell whose
122
+ * text could be misread as markup (it stores `a &lt; b` rather than `a < b`
123
+ * when the text happens to spell a tag), so the reading is never a guess
124
+ * about what an author meant.
125
+ */
126
+ export declare function isDataTableCellMarkup(cell: unknown): boolean;
127
+ /**
128
+ * The words a cell shows, without its formatting — what a field that can
129
+ * only hold plain text (the Attributes grid) displays for a formatted cell.
130
+ */
131
+ export declare function dataTableCellText(cell: unknown): string;
132
+ /** One change to a table's shape, as the canvas and the Attributes grid make it. */
133
+ export type DataTableShapeEdit = {
134
+ kind: 'insertRow';
135
+ at: number;
136
+ } | {
137
+ kind: 'removeRow';
138
+ at: number;
139
+ } | {
140
+ kind: 'insertColumn';
141
+ at: number;
142
+ } | {
143
+ kind: 'removeColumn';
144
+ at: number;
145
+ };
146
+ /**
147
+ * The stored value after one shape edit, with each column's ALIGNMENT moving
148
+ * with its column.
149
+ *
150
+ * Inserting or removing a column by rows alone leaves the alignments where
151
+ * they were by index, so every column after the edit takes its neighbour's
152
+ * alignment: a centred "Us" column turns left-aligned the moment a column is
153
+ * inserted before it. The alignment is spliced at the same index as the
154
+ * cells, and a new column starts at the default.
155
+ */
156
+ export declare function editDataTableShape(value: unknown, edit: DataTableShapeEdit): string;
157
+ /**
158
+ * The emphasised column after a shape edit, so the highlight stays on the
159
+ * column it was put on (1-based, `0` for none — see
160
+ * {@link normalizeEmphasisColumn}).
161
+ *
162
+ * Inserting a column before "Us" moves "Us" one to the right, and the
163
+ * highlight goes with it. Removing the emphasised column removes the
164
+ * highlight rather than handing it to whichever column slid into the gap.
165
+ */
166
+ export declare function emphasisAfterShapeEdit(emphasis: unknown, columnCount: number, edit: DataTableShapeEdit): number;
167
+ /**
168
+ * What "Start a table" writes into an empty Table, wherever it is offered:
169
+ * a header row and one blank row, with the two comparison columns centred.
170
+ */
171
+ export declare const DATA_TABLE_STARTER: {
172
+ rows: string[][];
173
+ alignments: DataTableAlignment[];
174
+ };
175
+ /** {@link DATA_TABLE_STARTER} in its stored form. */
176
+ export declare function dataTableStarterValue(): string;
@@ -30,7 +30,12 @@
30
30
  * own syntax, so the comparison tables already authored in Markdown elements
31
31
  * paste straight in. A leading and trailing pipe are optional, which is what
32
32
  * a copied markdown table has.
33
- */ /** Column alignments the editor offers and the renderer honours. */ export const DATA_TABLE_ALIGNMENTS = [
33
+ */ /**
34
+ * The Table element's 1-based "emphasize column" prop. Named here because a
35
+ * shape edit made outside the element (the canvas) has to move it with its
36
+ * column — see {@link emphasisAfterShapeEdit}.
37
+ */ export const DATA_TABLE_EMPHASIS_PROP = 'emphasizeColumn';
38
+ /** Column alignments the editor offers and the renderer honours. */ export const DATA_TABLE_ALIGNMENTS = [
34
39
  'left',
35
40
  'center',
36
41
  'right'
@@ -221,5 +226,125 @@ export function withRowRemoved(rows, at) {
221
226
  export function withCellSet(rows, rowIndex, columnIndex, value) {
222
227
  return rows.map((row, r)=>r === rowIndex ? row.map((cell, c)=>c === columnIndex ? value : cell) : row);
223
228
  }
229
+ /**
230
+ * A cell that holds FORMATTED text: inline markup (bold, italic, underline,
231
+ * a link, a line break), written by the canvas's in-place cell editor.
232
+ *
233
+ * A cell is otherwise plain text, and both kinds live in the same pipe grid:
234
+ * nothing about the storage changes, and a table nobody formats is
235
+ * byte-for-byte what it always was. The test is "starts a tag or spells a
236
+ * character reference", which is what the editor writes for ANY cell whose
237
+ * text could be misread as markup (it stores `a &lt; b` rather than `a < b`
238
+ * when the text happens to spell a tag), so the reading is never a guess
239
+ * about what an author meant.
240
+ */ export function isDataTableCellMarkup(cell) {
241
+ return typeof cell === 'string' && /<[a-z/!]|&(#\d+|#x[0-9a-f]+|[a-z][a-z0-9]*);/i.test(cell);
242
+ }
243
+ const CELL_ENTITIES = {
244
+ amp: '&',
245
+ lt: '<',
246
+ gt: '>',
247
+ quot: '"',
248
+ apos: "'",
249
+ nbsp: ' '
250
+ };
251
+ /**
252
+ * The words a cell shows, without its formatting — what a field that can
253
+ * only hold plain text (the Attributes grid) displays for a formatted cell.
254
+ */ export function dataTableCellText(cell) {
255
+ const text = typeof cell === 'string' ? cell : '';
256
+ if (!isDataTableCellMarkup(text)) return text;
257
+ return text.replace(/<br\s*\/?>/gi, ' ').replace(/<[^>]*>/g, '').replace(/&(#\d+|#x[0-9a-f]+|[a-z][a-z0-9]*);/gi, (whole, name)=>{
258
+ var _CELL_ENTITIES_name_toLowerCase;
259
+ if (name[0] === '#') {
260
+ const code = name[1] === 'x' || name[1] === 'X' ? parseInt(name.slice(2), 16) : parseInt(name.slice(1), 10);
261
+ return Number.isFinite(code) ? String.fromCodePoint(code) : whole;
262
+ }
263
+ return (_CELL_ENTITIES_name_toLowerCase = CELL_ENTITIES[name.toLowerCase()]) != null ? _CELL_ENTITIES_name_toLowerCase : whole;
264
+ }).replace(/\s+/g, ' ').trim();
265
+ }
266
+ /**
267
+ * The stored value after one shape edit, with each column's ALIGNMENT moving
268
+ * with its column.
269
+ *
270
+ * Inserting or removing a column by rows alone leaves the alignments where
271
+ * they were by index, so every column after the edit takes its neighbour's
272
+ * alignment: a centred "Us" column turns left-aligned the moment a column is
273
+ * inserted before it. The alignment is spliced at the same index as the
274
+ * cells, and a new column starts at the default.
275
+ */ export function editDataTableShape(value, edit) {
276
+ var _ref;
277
+ var _rows_;
278
+ const rows = parseDataTableRows(value);
279
+ const width = (_ref = (_rows_ = rows[0]) == null ? void 0 : _rows_.length) != null ? _ref : 0;
280
+ const alignments = readDataTableAlignments(value, width);
281
+ switch(edit.kind){
282
+ case 'insertRow':
283
+ return serializeDataTable(withRowAdded(rows, edit.at), alignments);
284
+ case 'removeRow':
285
+ return serializeDataTable(withRowRemoved(rows, edit.at), alignments);
286
+ case 'insertColumn':
287
+ {
288
+ const at = Math.max(0, Math.min(edit.at, width));
289
+ const next = [
290
+ ...alignments
291
+ ];
292
+ next.splice(at, 0, DATA_TABLE_ALIGNMENT_DEFAULT);
293
+ return serializeDataTable(withColumnAdded(rows, at), next);
294
+ }
295
+ case 'removeColumn':
296
+ {
297
+ if (width <= 1) return serializeDataTable(rows, alignments);
298
+ return serializeDataTable(withColumnRemoved(rows, edit.at), alignments.filter((_, index)=>index !== edit.at));
299
+ }
300
+ }
301
+ }
302
+ /**
303
+ * The emphasised column after a shape edit, so the highlight stays on the
304
+ * column it was put on (1-based, `0` for none — see
305
+ * {@link normalizeEmphasisColumn}).
306
+ *
307
+ * Inserting a column before "Us" moves "Us" one to the right, and the
308
+ * highlight goes with it. Removing the emphasised column removes the
309
+ * highlight rather than handing it to whichever column slid into the gap.
310
+ */ export function emphasisAfterShapeEdit(emphasis, columnCount, edit) {
311
+ const current = normalizeEmphasisColumn(emphasis, columnCount);
312
+ if (current === 0) return 0;
313
+ const index = current - 1;
314
+ if (edit.kind === 'insertColumn') {
315
+ return edit.at <= index ? current + 1 : current;
316
+ }
317
+ if (edit.kind === 'removeColumn') {
318
+ if (columnCount <= 1) return current;
319
+ if (edit.at === index) return 0;
320
+ return edit.at < index ? current - 1 : current;
321
+ }
322
+ return current;
323
+ }
324
+ /**
325
+ * What "Start a table" writes into an empty Table, wherever it is offered:
326
+ * a header row and one blank row, with the two comparison columns centred.
327
+ */ export const DATA_TABLE_STARTER = {
328
+ rows: [
329
+ [
330
+ 'Feature',
331
+ 'Us',
332
+ 'Them'
333
+ ],
334
+ [
335
+ '',
336
+ '',
337
+ ''
338
+ ]
339
+ ],
340
+ alignments: [
341
+ 'left',
342
+ 'center',
343
+ 'center'
344
+ ]
345
+ };
346
+ /** {@link DATA_TABLE_STARTER} in its stored form. */ export function dataTableStarterValue() {
347
+ return serializeDataTable(DATA_TABLE_STARTER.rows, DATA_TABLE_STARTER.alignments);
348
+ }
224
349
 
225
350
  //# sourceMappingURL=data-table.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/shared/data/enums/src/lib/data-table.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * The grid behind the Table element (AGL-2543).\n *\n * ONE parser, shared by the renderer and the attributes-panel editor. Two\n * implementations of \"what does this string mean\" is how a table comes to\n * look right in the canvas and wrong on the page, and the two are written by\n * different people months apart.\n *\n * The persisted prop is a single string, following the house pattern used by\n * `CSS_DIMENSION` and `CSS_GRADIENT`: the rich editor is an input affordance,\n * not a shape change, so nothing downstream has to learn a new type and a\n * value the editor cannot model is never clobbered.\n *\n * Pipe-delimited, one row per line — deliberately the markdown table body's\n * own syntax, so the comparison tables already authored in Markdown elements\n * paste straight in. A leading and trailing pipe are optional, which is what\n * a copied markdown table has.\n */\n\n/** Column alignments the editor offers and the renderer honours. */\nexport const DATA_TABLE_ALIGNMENTS = ['left', 'center', 'right'] as const\n\nexport type DataTableAlignment = (typeof DATA_TABLE_ALIGNMENTS)[number]\n\nexport const DATA_TABLE_ALIGNMENT_DEFAULT: DataTableAlignment = 'left'\n\n/**\n * A markdown alignment divider — `|---|:--:|---:|`.\n *\n * Dropped rather than rendered as a row of dashes. It carries no content, and\n * an author pasting a markdown table has no reason to expect it to survive as\n * data; its alignment intent is read out separately by\n * {@link alignmentsFromDivider}.\n */\nconst DIVIDER_CELL = /^:?-{2,}:?$/\n\nfunction splitRow(line: string): string[] {\n // `\\|` is a literal pipe, so a cell may contain one. Split on unescaped\n // pipes only, then unescape — doing it in the other order would turn an\n // escaped pipe into a column break.\n const cells = line\n .replace(/^\\s*\\|/, '')\n .replace(/\\|\\s*$/, '')\n .split(/(?<!\\\\)\\|/)\n .map((cell) => cell.replace(/\\\\\\|/g, '|').trim())\n return cells\n}\n\nfunction isDividerRow(cells: string[]): boolean {\n return cells.length > 0 && cells.every((cell) => DIVIDER_CELL.test(cell))\n}\n\n/**\n * The alignments a pasted markdown divider row encodes, or `null` when the\n * line is not one. `:--` is left, `:-:` centre, `--:` right.\n */\nexport function alignmentsFromDivider(\n line: string,\n): DataTableAlignment[] | null {\n const cells = splitRow(String(line ?? ''))\n if (!isDividerRow(cells)) return null\n return cells.map((cell) => {\n const left = cell.startsWith(':')\n const right = cell.endsWith(':')\n if (left && right) return 'center'\n if (right) return 'right'\n return 'left'\n })\n}\n\n/**\n * The grid a stored value describes.\n *\n * Rows are padded to the widest one so the renderer and the editor always see\n * a rectangle: a short row is an authoring accident, and a table that renders\n * with a missing cell is harder to fix than one with an empty one.\n */\nexport function parseDataTableRows(value: unknown): string[][] {\n const text = typeof value === 'string' ? value : ''\n const rows = text\n .split(/\\r?\\n/)\n .map((line) => line.trim())\n .filter((line) => line.length > 0)\n .map(splitRow)\n .filter((cells) => !isDividerRow(cells))\n const width = rows.reduce((widest, row) => Math.max(widest, row.length), 0)\n return rows.map((row) => [\n ...row,\n ...Array.from({ length: width - row.length }, () => ''),\n ])\n}\n\n/**\n * The alignments a stored value carries, padded to the table's width.\n *\n * Alignment lives in the SAME string as the grid, as a markdown divider row,\n * rather than in a prop of its own. A field editor is handed one prop, so a\n * second prop could not be reached from the grid's own per-column controls —\n * and encoding it the way markdown already does means a pasted table keeps\n * the alignment it was authored with instead of silently flattening to left.\n */\nexport function readDataTableAlignments(\n value: unknown,\n columnCount: number,\n): DataTableAlignment[] {\n const found = String(value ?? '')\n .split(/\\r?\\n/)\n .map((line) => alignmentsFromDivider(line))\n .find((alignments) => alignments !== null)\n return Array.from({ length: Math.max(0, columnCount) }, (_, index) => {\n const candidate = found?.[index]\n return candidate ?? DATA_TABLE_ALIGNMENT_DEFAULT\n })\n}\n\n/** A row of a table the author pasted, and the alignments it carried. */\nexport interface PastedDataTable {\n rows: string[][]\n alignments: DataTableAlignment[]\n}\n\n/** A pipe that breaks a column, as opposed to a `\\|` inside a cell. */\nfunction hasUnescapedPipe(line: string): boolean {\n return /(?<!\\\\)\\|/.test(line)\n}\n\n/**\n * The table a pasted string describes, or `null` when it is not one\n * (AGL-2568).\n *\n * Reading it is the migration path off the Markdown workaround: the tables\n * this element replaces are already authored as pipe syntax, and the\n * alternative to importing them is retyping thirty cells of dated competitor\n * pricing by hand, which is the content least safe to retype.\n *\n * `null` rather than a best effort is the important half. This runs on every\n * paste into every cell, and an author pasting `Pro | Business` as a cell\n * VALUE must get those characters, not a two-column table. So a paste is only\n * read as a table when it could not sensibly be anything else: more than one\n * line, every one of them carrying an unescaped pipe, and at least two\n * columns once parsed. A single line never qualifies, however many pipes it\n * has.\n */\nexport function readPastedDataTable(value: unknown): PastedDataTable | null {\n const text = typeof value === 'string' ? value : ''\n const lines = text\n .split(/\\r?\\n/)\n .map((line) => line.trim())\n .filter((line) => line.length > 0)\n if (lines.length < 2 || !lines.every(hasUnescapedPipe)) return null\n const rows = parseDataTableRows(text)\n const width = rows[0]?.length ?? 0\n if (rows.length === 0 || width < 2) return null\n return { rows, alignments: readDataTableAlignments(text, width) }\n}\n\n/** The markdown divider encoding one column's alignment. */\nfunction dividerCell(alignment: DataTableAlignment): string {\n if (alignment === 'center') return ':---:'\n if (alignment === 'right') return '---:'\n return '---'\n}\n\n/**\n * The stored form of a grid plus its alignments.\n *\n * The divider is written after the first row, where markdown puts it, and\n * only when some column is not the default — an all-left table stays a plain\n * pipe grid rather than growing a row of dashes nobody asked for.\n */\nexport function serializeDataTable(\n rows: string[][],\n alignments?: readonly DataTableAlignment[],\n): string {\n const body = (rows ?? []).map((row) =>\n (row ?? [])\n .map((cell) => String(cell ?? '').replace(/\\|/g, '\\\\|'))\n .join(' | '),\n )\n const meaningful =\n alignments?.some(\n (alignment) => alignment && alignment !== DATA_TABLE_ALIGNMENT_DEFAULT,\n ) ?? false\n if (!meaningful || body.length === 0) return body.join('\\n')\n const width = rows[0]?.length ?? 0\n const divider = Array.from({ length: width }, (_, index) =>\n dividerCell(alignments?.[index] ?? DATA_TABLE_ALIGNMENT_DEFAULT),\n ).join(' | ')\n return [body[0], divider, ...body.slice(1)].join('\\n')\n}\n\n/**\n * The 1-based column to emphasise, or `0` for none.\n *\n * 1-based because the control says \"column 3\" to an author who is looking at\n * the third column; `0` rather than `null` so \"none\" survives a form field\n * that only speaks numbers. Out-of-range values mean none, so deleting a\n * column cannot leave a table pointing at one that is gone.\n */\nexport function normalizeEmphasisColumn(\n value: unknown,\n columnCount: number,\n): number {\n const parsed = Math.trunc(Number(value))\n if (!Number.isFinite(parsed) || parsed < 1 || parsed > columnCount) return 0\n return parsed\n}\n\n/** A grid with `count` empty columns appended to every row. */\nexport function withColumnAdded(rows: string[][], at?: number): string[][] {\n const width = rows[0]?.length ?? 0\n const index = at == null ? width : Math.max(0, Math.min(at, width))\n return (rows.length ? rows : [[]]).map((row) => {\n const next = [...row]\n next.splice(index, 0, '')\n return next\n })\n}\n\nexport function withColumnRemoved(rows: string[][], at: number): string[][] {\n const width = rows[0]?.length ?? 0\n // Never leave a table with no columns: a zero-column grid cannot be typed\n // back into through the editor, so the last column is not removable.\n if (width <= 1) return rows\n return rows.map((row) => row.filter((_, index) => index !== at))\n}\n\nexport function withRowAdded(rows: string[][], at?: number): string[][] {\n const width = rows[0]?.length ?? 1\n const blank = Array.from({ length: width }, () => '')\n const next = [...rows]\n next.splice(at == null ? rows.length : Math.max(0, Math.min(at, rows.length)), 0, blank)\n return next\n}\n\nexport function withRowRemoved(rows: string[][], at: number): string[][] {\n if (rows.length <= 1) return rows\n return rows.filter((_, index) => index !== at)\n}\n\nexport function withCellSet(\n rows: string[][],\n rowIndex: number,\n columnIndex: number,\n value: string,\n): string[][] {\n return rows.map((row, r) =>\n r === rowIndex\n ? row.map((cell, c) => (c === columnIndex ? value : cell))\n : row,\n )\n}\n"],"names":["DATA_TABLE_ALIGNMENTS","DATA_TABLE_ALIGNMENT_DEFAULT","DIVIDER_CELL","splitRow","line","cells","replace","split","map","cell","trim","isDividerRow","length","every","test","alignmentsFromDivider","String","left","startsWith","right","endsWith","parseDataTableRows","value","text","rows","filter","width","reduce","widest","row","Math","max","Array","from","readDataTableAlignments","columnCount","found","find","alignments","_","index","candidate","hasUnescapedPipe","readPastedDataTable","lines","dividerCell","alignment","serializeDataTable","body","join","meaningful","some","divider","slice","normalizeEmphasisColumn","parsed","trunc","Number","isFinite","withColumnAdded","at","min","next","splice","withColumnRemoved","withRowAdded","blank","withRowRemoved","withCellSet","rowIndex","columnIndex","r","c"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;CAiBC,GAED,kEAAkE,GAClE,OAAO,MAAMA,wBAAwB;IAAC;IAAQ;IAAU;CAAQ,CAAS;AAIzE,OAAO,MAAMC,+BAAmD,OAAM;AAEtE;;;;;;;CAOC,GACD,MAAMC,eAAe;AAErB,SAASC,SAASC,IAAY;IAC5B,wEAAwE;IACxE,wEAAwE;IACxE,oCAAoC;IACpC,MAAMC,QAAQD,KACXE,OAAO,CAAC,UAAU,IAClBA,OAAO,CAAC,UAAU,IAClBC,KAAK,CAAC,aACNC,GAAG,CAAC,CAACC,OAASA,KAAKH,OAAO,CAAC,SAAS,KAAKI,IAAI;IAChD,OAAOL;AACT;AAEA,SAASM,aAAaN,KAAe;IACnC,OAAOA,MAAMO,MAAM,GAAG,KAAKP,MAAMQ,KAAK,CAAC,CAACJ,OAASP,aAAaY,IAAI,CAACL;AACrE;AAEA;;;CAGC,GACD,OAAO,SAASM,sBACdX,IAAY;IAEZ,MAAMC,QAAQF,SAASa,OAAOZ,eAAAA,OAAQ;IACtC,IAAI,CAACO,aAAaN,QAAQ,OAAO;IACjC,OAAOA,MAAMG,GAAG,CAAC,CAACC;QAChB,MAAMQ,OAAOR,KAAKS,UAAU,CAAC;QAC7B,MAAMC,QAAQV,KAAKW,QAAQ,CAAC;QAC5B,IAAIH,QAAQE,OAAO,OAAO;QA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C,MAAMC,IAAI,CAAC;QAAErB,QAAQc;IAAM,GAAG,IAAM;IAClD,MAAMoC,OAAO;WAAItC;KAAK;IACtBsC,KAAKC,MAAM,CAACH,MAAM,OAAOpC,KAAKZ,MAAM,GAAGkB,KAAKC,GAAG,CAAC,GAAGD,KAAK+B,GAAG,CAACD,IAAIpC,KAAKZ,MAAM,IAAI,GAAGsD;IAClF,OAAOJ;AACT;AAEA,OAAO,SAASK,eAAe3C,IAAgB,EAAEoC,EAAU;IACzD,IAAIpC,KAAKZ,MAAM,IAAI,GAAG,OAAOY;IAC7B,OAAOA,KAAKC,MAAM,CAAC,CAACc,GAAGC,QAAUA,UAAUoB;AAC7C;AAEA,OAAO,SAASQ,YACd5C,IAAgB,EAChB6C,QAAgB,EAChBC,WAAmB,EACnBhD,KAAa;IAEb,OAAOE,KAAKhB,GAAG,CAAC,CAACqB,KAAK0C,IACpBA,MAAMF,WACFxC,IAAIrB,GAAG,CAAC,CAACC,MAAM+D,IAAOA,MAAMF,cAAchD,QAAQb,QAClDoB;AAER"}
1
+ {"version":3,"sources":["../../../../../../../libs/shared/data/enums/src/lib/data-table.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * The grid behind the Table element (AGL-2543).\n *\n * ONE parser, shared by the renderer and the attributes-panel editor. Two\n * implementations of \"what does this string mean\" is how a table comes to\n * look right in the canvas and wrong on the page, and the two are written by\n * different people months apart.\n *\n * The persisted prop is a single string, following the house pattern used by\n * `CSS_DIMENSION` and `CSS_GRADIENT`: the rich editor is an input affordance,\n * not a shape change, so nothing downstream has to learn a new type and a\n * value the editor cannot model is never clobbered.\n *\n * Pipe-delimited, one row per line — deliberately the markdown table body's\n * own syntax, so the comparison tables already authored in Markdown elements\n * paste straight in. A leading and trailing pipe are optional, which is what\n * a copied markdown table has.\n */\n\n/**\n * The Table element's 1-based \"emphasize column\" prop. Named here because a\n * shape edit made outside the element (the canvas) has to move it with its\n * column — see {@link emphasisAfterShapeEdit}.\n */\nexport const DATA_TABLE_EMPHASIS_PROP = 'emphasizeColumn'\n\n/** Column alignments the editor offers and the renderer honours. */\nexport const DATA_TABLE_ALIGNMENTS = ['left', 'center', 'right'] as const\n\nexport type DataTableAlignment = (typeof DATA_TABLE_ALIGNMENTS)[number]\n\nexport const DATA_TABLE_ALIGNMENT_DEFAULT: DataTableAlignment = 'left'\n\n/**\n * A markdown alignment divider — `|---|:--:|---:|`.\n *\n * Dropped rather than rendered as a row of dashes. It carries no content, and\n * an author pasting a markdown table has no reason to expect it to survive as\n * data; its alignment intent is read out separately by\n * {@link alignmentsFromDivider}.\n */\nconst DIVIDER_CELL = /^:?-{2,}:?$/\n\nfunction splitRow(line: string): string[] {\n // `\\|` is a literal pipe, so a cell may contain one. Split on unescaped\n // pipes only, then unescape — doing it in the other order would turn an\n // escaped pipe into a column break.\n const cells = line\n .replace(/^\\s*\\|/, '')\n .replace(/\\|\\s*$/, '')\n .split(/(?<!\\\\)\\|/)\n .map((cell) => cell.replace(/\\\\\\|/g, '|').trim())\n return cells\n}\n\nfunction isDividerRow(cells: string[]): boolean {\n return cells.length > 0 && cells.every((cell) => DIVIDER_CELL.test(cell))\n}\n\n/**\n * The alignments a pasted markdown divider row encodes, or `null` when the\n * line is not one. `:--` is left, `:-:` centre, `--:` right.\n */\nexport function alignmentsFromDivider(\n line: string,\n): DataTableAlignment[] | null {\n const cells = splitRow(String(line ?? ''))\n if (!isDividerRow(cells)) return null\n return cells.map((cell) => {\n const left = cell.startsWith(':')\n const right = cell.endsWith(':')\n if (left && right) return 'center'\n if (right) return 'right'\n return 'left'\n })\n}\n\n/**\n * The grid a stored value describes.\n *\n * Rows are padded to the widest one so the renderer and the editor always see\n * a rectangle: a short row is an authoring accident, and a table that renders\n * with a missing cell is harder to fix than one with an empty one.\n */\nexport function parseDataTableRows(value: unknown): string[][] {\n const text = typeof value === 'string' ? value : ''\n const rows = text\n .split(/\\r?\\n/)\n .map((line) => line.trim())\n .filter((line) => line.length > 0)\n .map(splitRow)\n .filter((cells) => !isDividerRow(cells))\n const width = rows.reduce((widest, row) => Math.max(widest, row.length), 0)\n return rows.map((row) => [\n ...row,\n ...Array.from({ length: width - row.length }, () => ''),\n ])\n}\n\n/**\n * The alignments a stored value carries, padded to the table's width.\n *\n * Alignment lives in the SAME string as the grid, as a markdown divider row,\n * rather than in a prop of its own. A field editor is handed one prop, so a\n * second prop could not be reached from the grid's own per-column controls —\n * and encoding it the way markdown already does means a pasted table keeps\n * the alignment it was authored with instead of silently flattening to left.\n */\nexport function readDataTableAlignments(\n value: unknown,\n columnCount: number,\n): DataTableAlignment[] {\n const found = String(value ?? '')\n .split(/\\r?\\n/)\n .map((line) => alignmentsFromDivider(line))\n .find((alignments) => alignments !== null)\n return Array.from({ length: Math.max(0, columnCount) }, (_, index) => {\n const candidate = found?.[index]\n return candidate ?? DATA_TABLE_ALIGNMENT_DEFAULT\n })\n}\n\n/** A row of a table the author pasted, and the alignments it carried. */\nexport interface PastedDataTable {\n rows: string[][]\n alignments: DataTableAlignment[]\n}\n\n/** A pipe that breaks a column, as opposed to a `\\|` inside a cell. */\nfunction hasUnescapedPipe(line: string): boolean {\n return /(?<!\\\\)\\|/.test(line)\n}\n\n/**\n * The table a pasted string describes, or `null` when it is not one\n * (AGL-2568).\n *\n * Reading it is the migration path off the Markdown workaround: the tables\n * this element replaces are already authored as pipe syntax, and the\n * alternative to importing them is retyping thirty cells of dated competitor\n * pricing by hand, which is the content least safe to retype.\n *\n * `null` rather than a best effort is the important half. This runs on every\n * paste into every cell, and an author pasting `Pro | Business` as a cell\n * VALUE must get those characters, not a two-column table. So a paste is only\n * read as a table when it could not sensibly be anything else: more than one\n * line, every one of them carrying an unescaped pipe, and at least two\n * columns once parsed. A single line never qualifies, however many pipes it\n * has.\n */\nexport function readPastedDataTable(value: unknown): PastedDataTable | null {\n const text = typeof value === 'string' ? value : ''\n const lines = text\n .split(/\\r?\\n/)\n .map((line) => line.trim())\n .filter((line) => line.length > 0)\n if (lines.length < 2 || !lines.every(hasUnescapedPipe)) return null\n const rows = parseDataTableRows(text)\n const width = rows[0]?.length ?? 0\n if (rows.length === 0 || width < 2) return null\n return { rows, alignments: readDataTableAlignments(text, width) }\n}\n\n/** The markdown divider encoding one column's alignment. */\nfunction dividerCell(alignment: DataTableAlignment): string {\n if (alignment === 'center') return ':---:'\n if (alignment === 'right') return '---:'\n return '---'\n}\n\n/**\n * The stored form of a grid plus its alignments.\n *\n * The divider is written after the first row, where markdown puts it, and\n * only when some column is not the default — an all-left table stays a plain\n * pipe grid rather than growing a row of dashes nobody asked for.\n */\nexport function serializeDataTable(\n rows: string[][],\n alignments?: readonly DataTableAlignment[],\n): string {\n const body = (rows ?? []).map((row) =>\n (row ?? [])\n .map((cell) => String(cell ?? '').replace(/\\|/g, '\\\\|'))\n .join(' | '),\n )\n const meaningful =\n alignments?.some(\n (alignment) => alignment && alignment !== DATA_TABLE_ALIGNMENT_DEFAULT,\n ) ?? false\n if (!meaningful || body.length === 0) return body.join('\\n')\n const width = rows[0]?.length ?? 0\n const divider = Array.from({ length: width }, (_, index) =>\n dividerCell(alignments?.[index] ?? DATA_TABLE_ALIGNMENT_DEFAULT),\n ).join(' | ')\n return [body[0], divider, ...body.slice(1)].join('\\n')\n}\n\n/**\n * The 1-based column to emphasise, or `0` for none.\n *\n * 1-based because the control says \"column 3\" to an author who is looking at\n * the third column; `0` rather than `null` so \"none\" survives a form field\n * that only speaks numbers. Out-of-range values mean none, so deleting a\n * column cannot leave a table pointing at one that is gone.\n */\nexport function normalizeEmphasisColumn(\n value: unknown,\n columnCount: number,\n): number {\n const parsed = Math.trunc(Number(value))\n if (!Number.isFinite(parsed) || parsed < 1 || parsed > columnCount) return 0\n return parsed\n}\n\n/** A grid with `count` empty columns appended to every row. */\nexport function withColumnAdded(rows: string[][], at?: number): string[][] {\n const width = rows[0]?.length ?? 0\n const index = at == null ? width : Math.max(0, Math.min(at, width))\n return (rows.length ? rows : [[]]).map((row) => {\n const next = [...row]\n next.splice(index, 0, '')\n return next\n })\n}\n\nexport function withColumnRemoved(rows: string[][], at: number): string[][] {\n const width = rows[0]?.length ?? 0\n // Never leave a table with no columns: a zero-column grid cannot be typed\n // back into through the editor, so the last column is not removable.\n if (width <= 1) return rows\n return rows.map((row) => row.filter((_, index) => index !== at))\n}\n\nexport function withRowAdded(rows: string[][], at?: number): string[][] {\n const width = rows[0]?.length ?? 1\n const blank = Array.from({ length: width }, () => '')\n const next = [...rows]\n next.splice(at == null ? rows.length : Math.max(0, Math.min(at, rows.length)), 0, blank)\n return next\n}\n\nexport function withRowRemoved(rows: string[][], at: number): string[][] {\n if (rows.length <= 1) return rows\n return rows.filter((_, index) => index !== at)\n}\n\nexport function withCellSet(\n rows: string[][],\n rowIndex: number,\n columnIndex: number,\n value: string,\n): string[][] {\n return rows.map((row, r) =>\n r === rowIndex\n ? row.map((cell, c) => (c === columnIndex ? value : cell))\n : row,\n )\n}\n\n/**\n * A cell that holds FORMATTED text: inline markup (bold, italic, underline,\n * a link, a line break), written by the canvas's in-place cell editor.\n *\n * A cell is otherwise plain text, and both kinds live in the same pipe grid:\n * nothing about the storage changes, and a table nobody formats is\n * byte-for-byte what it always was. The test is \"starts a tag or spells a\n * character reference\", which is what the editor writes for ANY cell whose\n * text could be misread as markup (it stores `a &lt; b` rather than `a < b`\n * when the text happens to spell a tag), so the reading is never a guess\n * about what an author meant.\n */\nexport function isDataTableCellMarkup(cell: unknown): boolean {\n return (\n typeof cell === 'string' &&\n /<[a-z/!]|&(#\\d+|#x[0-9a-f]+|[a-z][a-z0-9]*);/i.test(cell)\n )\n}\n\nconst CELL_ENTITIES: Record<string, string> = {\n amp: '&',\n lt: '<',\n gt: '>',\n quot: '\"',\n apos: \"'\",\n nbsp: ' ',\n}\n\n/**\n * The words a cell shows, without its formatting — what a field that can\n * only hold plain text (the Attributes grid) displays for a formatted cell.\n */\nexport function dataTableCellText(cell: unknown): string {\n const text = typeof cell === 'string' ? cell : ''\n if (!isDataTableCellMarkup(text)) return text\n return text\n .replace(/<br\\s*\\/?>/gi, ' ')\n .replace(/<[^>]*>/g, '')\n .replace(/&(#\\d+|#x[0-9a-f]+|[a-z][a-z0-9]*);/gi, (whole, name: string) => {\n if (name[0] === '#') {\n const code =\n name[1] === 'x' || name[1] === 'X'\n ? parseInt(name.slice(2), 16)\n : parseInt(name.slice(1), 10)\n return Number.isFinite(code) ? String.fromCodePoint(code) : whole\n }\n return CELL_ENTITIES[name.toLowerCase()] ?? whole\n })\n .replace(/\\s+/g, ' ')\n .trim()\n}\n\n/** One change to a table's shape, as the canvas and the Attributes grid make it. */\nexport type DataTableShapeEdit =\n | { kind: 'insertRow'; at: number }\n | { kind: 'removeRow'; at: number }\n | { kind: 'insertColumn'; at: number }\n | { kind: 'removeColumn'; at: number }\n\n/**\n * The stored value after one shape edit, with each column's ALIGNMENT moving\n * with its column.\n *\n * Inserting or removing a column by rows alone leaves the alignments where\n * they were by index, so every column after the edit takes its neighbour's\n * alignment: a centred \"Us\" column turns left-aligned the moment a column is\n * inserted before it. The alignment is spliced at the same index as the\n * cells, and a new column starts at the default.\n */\nexport function editDataTableShape(\n value: unknown,\n edit: DataTableShapeEdit,\n): string {\n const rows = parseDataTableRows(value)\n const width = rows[0]?.length ?? 0\n const alignments = readDataTableAlignments(value, width)\n switch (edit.kind) {\n case 'insertRow':\n return serializeDataTable(withRowAdded(rows, edit.at), alignments)\n case 'removeRow':\n return serializeDataTable(withRowRemoved(rows, edit.at), alignments)\n case 'insertColumn': {\n const at = Math.max(0, Math.min(edit.at, width))\n const next = [...alignments]\n next.splice(at, 0, DATA_TABLE_ALIGNMENT_DEFAULT)\n return serializeDataTable(withColumnAdded(rows, at), next)\n }\n case 'removeColumn': {\n if (width <= 1) return serializeDataTable(rows, alignments)\n return serializeDataTable(\n withColumnRemoved(rows, edit.at),\n alignments.filter((_, index) => index !== edit.at),\n )\n }\n }\n}\n\n/**\n * The emphasised column after a shape edit, so the highlight stays on the\n * column it was put on (1-based, `0` for none — see\n * {@link normalizeEmphasisColumn}).\n *\n * Inserting a column before \"Us\" moves \"Us\" one to the right, and the\n * highlight goes with it. Removing the emphasised column removes the\n * highlight rather than handing it to whichever column slid into the gap.\n */\nexport function emphasisAfterShapeEdit(\n emphasis: unknown,\n columnCount: number,\n edit: DataTableShapeEdit,\n): number {\n const current = normalizeEmphasisColumn(emphasis, columnCount)\n if (current === 0) return 0\n const index = current - 1\n if (edit.kind === 'insertColumn') {\n return edit.at <= index ? current + 1 : current\n }\n if (edit.kind === 'removeColumn') {\n if (columnCount <= 1) return current\n if (edit.at === index) return 0\n return edit.at < index ? current - 1 : current\n }\n return current\n}\n\n/**\n * What \"Start a table\" writes into an empty Table, wherever it is offered:\n * a header row and one blank row, with the two comparison columns centred.\n */\nexport const DATA_TABLE_STARTER = {\n rows: [\n ['Feature', 'Us', 'Them'],\n ['', '', ''],\n ],\n alignments: ['left', 'center', 'center'] as DataTableAlignment[],\n}\n\n/** {@link DATA_TABLE_STARTER} in its stored form. */\nexport function dataTableStarterValue(): string {\n return serializeDataTable(\n DATA_TABLE_STARTER.rows,\n DATA_TABLE_STARTER.alignments,\n )\n}\n"],"names":["DATA_TABLE_EMPHASIS_PROP","DATA_TABLE_ALIGNMENTS","DATA_TABLE_ALIGNMENT_DEFAULT","DIVIDER_CELL","splitRow","line","cells","replace","split","map","cell","trim","isDividerRow","length","every","test","alignmentsFromDivider","String","left","startsWith","right","endsWith","parseDataTableRows","value","text","rows","filter","width","reduce","widest","row","Math","max","Array","from","readDataTableAlignments","columnCount","found","find","alignments","_","index","candidate","hasUnescapedPipe","readPastedDataTable","lines","dividerCell","alignment","serializeDataTable","body","join","meaningful","some","divider","slice","normalizeEmphasisColumn","parsed","trunc","Number","isFinite","withColumnAdded","at","min","next","splice","withColumnRemoved","withRowAdded","blank","withRowRemoved","withCellSet","rowIndex","columnIndex","r","c","isDataTableCellMarkup","CELL_ENTITIES","amp","lt","gt","quot","apos","nbsp","dataTableCellText","whole","name","code","parseInt","fromCodePoint","toLowerCase","editDataTableShape","edit","kind","emphasisAfterShapeEdit","emphasis","current","DATA_TABLE_STARTER","dataTableStarterValue"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;CAiBC,GAED;;;;CAIC,GACD,OAAO,MAAMA,2BAA2B,kBAAiB;AAEzD,kEAAkE,GAClE,OAAO,MAAMC,wBAAwB;IAAC;IAAQ;IAAU;CAAQ,CAAS;AAIzE,OAAO,MAAMC,+BAAmD,OAAM;AAEtE;;;;;;;CAOC,GACD,MAAMC,eAAe;AAErB,SAASC,SAASC,IAAY;IAC5B,wEAAwE;IACxE,wEAAwE;IACxE,oCAAoC;IACpC,MAAMC,QAAQD,KACXE,OAAO,CAAC,UAAU,IAClBA,OAAO,CAAC,UAAU,IAClBC,KAAK,CAAC,aACNC,GAAG,CAAC,CAACC,OAASA,KAAKH,OAAO,CAAC,SAAS,KAAKI,IAAI;IAChD,OAAOL;AACT;AAEA,SAASM,aAAaN,KAAe;IACnC,OAAOA,MAAMO,MAAM,GAAG,KAAKP,MAAMQ,KAAK,CAAC,CAACJ,OAASP,aAAaY,IAAI,CAACL;AACrE;AAEA;;;CAGC,GACD,OAAO,SAASM,sBACdX,IAAY;IAEZ,MAAMC,QAAQF,SAASa,OAAOZ,eAAAA,OAAQ;IACtC,IAAI,CAACO,aAAaN,QAAQ,OAAO;IACjC,OAAOA,MAAMG,GAAG,CAAC,CAACC;QAChB,MAAMQ,OAAOR,KAAKS,UAAU,CAAC;QAC7B,MAAMC,QAAQV,KAAKW,QAAQ,CAA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