foldkit-data-grid 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/clipboard.d.ts +44 -0
  2. package/dist/clipboard.d.ts.map +1 -0
  3. package/dist/clipboard.js +109 -0
  4. package/dist/clipboard.js.map +1 -0
  5. package/dist/columnState.d.ts +53 -0
  6. package/dist/columnState.d.ts.map +1 -0
  7. package/dist/columnState.js +201 -0
  8. package/dist/columnState.js.map +1 -0
  9. package/dist/{rows-D8siEVqF.d.mts → columns.d.ts} +15 -81
  10. package/dist/columns.d.ts.map +1 -0
  11. package/dist/columns.js +73 -0
  12. package/dist/columns.js.map +1 -0
  13. package/dist/{crud.d.mts → crud.d.ts} +3 -2
  14. package/dist/{crud.d.mts.map → crud.d.ts.map} +1 -1
  15. package/dist/{crud.mjs → crud.js} +3 -2
  16. package/dist/crud.js.map +1 -0
  17. package/dist/fill.d.ts +49 -0
  18. package/dist/fill.d.ts.map +1 -0
  19. package/dist/fill.js +113 -0
  20. package/dist/fill.js.map +1 -0
  21. package/dist/focus.d.ts +119 -0
  22. package/dist/focus.d.ts.map +1 -0
  23. package/dist/focus.js +150 -0
  24. package/dist/focus.js.map +1 -0
  25. package/dist/{index.d.mts → grid.d.ts} +13 -564
  26. package/dist/grid.d.ts.map +1 -0
  27. package/dist/{index.mjs → grid.js} +11 -1024
  28. package/dist/grid.js.map +1 -0
  29. package/dist/index.d.ts +13 -0
  30. package/dist/index.js +13 -0
  31. package/dist/layout.d.ts +20 -0
  32. package/dist/layout.d.ts.map +1 -0
  33. package/dist/layout.js +27 -0
  34. package/dist/layout.js.map +1 -0
  35. package/dist/projection.d.ts +87 -0
  36. package/dist/projection.d.ts.map +1 -0
  37. package/dist/projection.js +102 -0
  38. package/dist/projection.js.map +1 -0
  39. package/dist/rows.d.ts +70 -0
  40. package/dist/rows.d.ts.map +1 -0
  41. package/dist/{rows-Dy1HPpGX.mjs → rows.js} +3 -71
  42. package/dist/rows.js.map +1 -0
  43. package/dist/selection.d.ts +65 -0
  44. package/dist/selection.d.ts.map +1 -0
  45. package/dist/selection.js +137 -0
  46. package/dist/selection.js.map +1 -0
  47. package/dist/viewport.d.ts +74 -0
  48. package/dist/viewport.d.ts.map +1 -0
  49. package/dist/viewport.js +116 -0
  50. package/dist/viewport.js.map +1 -0
  51. package/dist/virtual.d.ts +73 -0
  52. package/dist/virtual.d.ts.map +1 -0
  53. package/dist/virtual.js +112 -0
  54. package/dist/virtual.js.map +1 -0
  55. package/package.json +15 -15
  56. package/dist/crud.mjs.map +0 -1
  57. package/dist/index.d.mts.map +0 -1
  58. package/dist/index.mjs.map +0 -1
  59. package/dist/rows-D8siEVqF.d.mts.map +0 -1
  60. package/dist/rows-Dy1HPpGX.mjs.map +0 -1
@@ -0,0 +1,73 @@
1
+ import { Schema, SchemaAST } from "effect";
2
+ import { defineTaggedUnion } from "foldkit/schema";
3
+ // src/columns.ts
4
+ /**
5
+ * How a cell's edit is drawn, read from its column's schema: a choice of the
6
+ * literals its text may be, a number typed, or text.
7
+ */
8
+ const CellEditor = defineTaggedUnion({
9
+ Text: {},
10
+ /** The schema decodes to a number: typed with a decimal keypad on touch. */
11
+ Number: {},
12
+ /** The schema's text is one of these, offered in order. */
13
+ Choice: { options: Schema.Array(Schema.String) },
14
+ /** The schema decodes to a date: a native date field over the draft text. */
15
+ Date: {}
16
+ });
17
+ /**
18
+ * Whether a schema decodes to a date, found as Effect's own tools find it:
19
+ * by the declaration's representation id. Only Date-ness is read here, never
20
+ * the text format: committing decodes the draft through the schema, and a
21
+ * refusal is the cell's error.
22
+ */
23
+ const DATE_ID = "effect/schema/Date";
24
+ const isDate = (ast) => {
25
+ if (!SchemaAST.isDeclaration(ast)) return false;
26
+ const representation = ast.annotations?.["representation"];
27
+ return typeof representation === "object" && representation !== null && "id" in representation && representation.id === DATE_ID;
28
+ };
29
+ /** A column's editor, from its schema; a column with none edits text. */
30
+ const editorOf = (schema) => {
31
+ if (schema === void 0) return CellEditor.Text();
32
+ const encoded = SchemaAST.toEncoded(schema.ast);
33
+ if (SchemaAST.isUnion(encoded)) {
34
+ const options = encoded.types.flatMap((member) => SchemaAST.isLiteral(member) && typeof member.literal === "string" ? [member.literal] : []);
35
+ if (options.length === encoded.types.length) return CellEditor.Choice({ options });
36
+ }
37
+ const type = SchemaAST.toType(schema.ast);
38
+ if (isDate(type)) return CellEditor.Date();
39
+ return SchemaAST.isNumber(type) ? CellEditor.Number() : CellEditor.Text();
40
+ };
41
+ const arrayIndex = /^(0|[1-9][0-9]*)$/;
42
+ const Columns = {
43
+ /** The width of a column that names none. */
44
+ defaultWidth: 120,
45
+ /** The narrowest a column with no `minWidth` resizes to. */
46
+ minWidth: 40,
47
+ /** A value as a cell shows it: nothing for `null` or `undefined`. */
48
+ textOf: (value) => value === null || value === void 0 ? "" : String(value),
49
+ /**
50
+ * Declares a grid's columns over `Row`. Call it twice, once with the row
51
+ * type and once with the specs, so the ids and values are inferred:
52
+ * `Columns.define<Product>()({ sku: { header: 'SKU', value: p => p.sku } })`.
53
+ */
54
+ define: () => (specs) => {
55
+ if (Object.getPrototypeOf(specs) !== Object.prototype || Object.hasOwn(specs, "__proto__")) throw new Error("Columns.define: \"__proto__\" cannot name a column.");
56
+ const ids = Object.keys(specs);
57
+ const byId = {};
58
+ for (const id of ids) {
59
+ if (arrayIndex.test(id)) throw new Error(`Columns.define: the column id "${id}" is an array index, which JavaScript orders before every other key. Give it a name that is not a number.`);
60
+ byId[id] = Object.freeze({
61
+ ...specs[id],
62
+ id
63
+ });
64
+ }
65
+ return Object.freeze({
66
+ ids: Object.freeze(ids),
67
+ byId: Object.freeze(byId)
68
+ });
69
+ }
70
+ };
71
+ export { CellEditor, Columns, editorOf };
72
+
73
+ //# sourceMappingURL=columns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"columns.js","names":[],"sources":["../src/columns.ts"],"sourcesContent":["import { Schema, SchemaAST } from 'effect'\nimport { defineTaggedUnion } from 'foldkit/schema'\n/** What a column shows and where it starts out. Its id is its key in `Columns.define`. */\nexport interface ColumnSpec<Row, Value> {\n readonly header: string\n readonly value: (row: Row) => Value\n /** The region the column starts in; `ColumnLayout.initial` reads it. */\n readonly pinned?: 'start' | 'end'\n /** Whether the column starts hidden; `ColumnLayout.initial` reads it. */\n readonly hidden?: boolean\n /** Its width in pixels until resized. Default `Columns.defaultWidth`. */\n readonly width?: number\n /** The narrowest a resize makes it. Default `Columns.minWidth`. */\n readonly minWidth?: number\n /** The widest a resize makes it. Default no limit. */\n readonly maxWidth?: number\n /** Whether it can be resized. Default `true`. */\n readonly resizable?: boolean\n /** Whether it can be hidden. Default `true`. */\n readonly hideable?: boolean\n /**\n * Makes the column's cells editable as text. The grid holds the draft,\n * commits it only when the column's schema decodes it, and reports the\n * committed text as an `Edited` OutMessage; `matchEdit` reads its value\n * back, and writing it is the application's.\n */\n readonly edit?: ColumnEdit<Row, unknown>\n}\n\nexport interface ColumnEdit<Row, Value = string> {\n /** The text an edit of a row's cell begins with. Default the value as a string. */\n readonly draft?: (row: Row) => string\n /**\n * What the text means: from the text typed to the column's value. A draft\n * is committed only when it decodes, and the failure's message is the\n * cell's error, so a check's own `message` is what a person reads. Default\n * any text, as itself.\n */\n readonly schema?: Schema.Codec<Value, string>\n}\n\n/**\n * How a cell's edit is drawn, read from its column's schema: a choice of the\n * literals its text may be, a number typed, or text.\n */\nexport const CellEditor = defineTaggedUnion({\n Text: {},\n /** The schema decodes to a number: typed with a decimal keypad on touch. */\n Number: {},\n /** The schema's text is one of these, offered in order. */\n Choice: { options: Schema.Array(Schema.String) },\n /** The schema decodes to a date: a native date field over the draft text. */\n Date: {},\n})\nexport type CellEditor = typeof CellEditor.Type\n\n/**\n * Whether a schema decodes to a date, found as Effect's own tools find it:\n * by the declaration's representation id. Only Date-ness is read here, never\n * the text format: committing decodes the draft through the schema, and a\n * refusal is the cell's error.\n */\nconst DATE_ID = 'effect/schema/Date'\n\nconst isDate = (ast: SchemaAST.AST): boolean => {\n if (!SchemaAST.isDeclaration(ast)) return false\n const representation: unknown = ast.annotations?.['representation']\n return (\n typeof representation === 'object' &&\n representation !== null &&\n 'id' in representation &&\n representation.id === DATE_ID\n )\n}\n\n/** A column's editor, from its schema; a column with none edits text. */\nexport const editorOf = (schema: Schema.Top | undefined): CellEditor => {\n if (schema === undefined) return CellEditor.Text()\n const encoded = SchemaAST.toEncoded(schema.ast)\n if (SchemaAST.isUnion(encoded)) {\n const options = encoded.types.flatMap(member =>\n SchemaAST.isLiteral(member) && typeof member.literal === 'string' ? [member.literal] : [],\n )\n // Every member a text literal: anything else typed would be refused.\n if (options.length === encoded.types.length) return CellEditor.Choice({ options })\n }\n const type = SchemaAST.toType(schema.ast)\n if (isDate(type)) return CellEditor.Date()\n return SchemaAST.isNumber(type) ? CellEditor.Number() : CellEditor.Text()\n}\n\n/** The ids of the columns that edit. */\nexport type EditableId<Specs> = {\n [K in keyof Specs]: Specs[K] extends { readonly edit: object } ? K : never\n}[keyof Specs] &\n string\n\n/** What an editable column's text decodes to: its schema's value, or the text. */\nexport type EditValue<Spec> = Spec extends {\n readonly edit: { readonly schema: Schema.Codec<infer Value, string> }\n}\n ? Value\n : string\n\nexport interface Column<Row, Id extends string, Value> extends ColumnSpec<Row, Value> {\n readonly id: Id\n}\n\ntype ValueOf<Spec> = Spec extends ColumnSpec<never, infer Value> ? Value : never\n\nexport type ColumnId<C> = C extends Columns<never, infer Specs> ? keyof Specs & string : never\n\n/**\n * A grid's columns, keyed by stable id. Order, visibility and pinning live in\n * a `ColumnLayout`, so every reference to a column (focus, a selected range,\n * a saved width) names its id and survives a reorder.\n */\nexport interface Columns<Row, Specs extends Record<string, ColumnSpec<Row, unknown>>> {\n /** In definition order: the order `ColumnLayout.initial` starts from. */\n readonly ids: ReadonlyArray<keyof Specs & string>\n readonly byId: {\n readonly [Id in keyof Specs & string]: Column<Row, Id, ValueOf<Specs[Id]>>\n }\n /**\n * Type-only: the specs as written, so a grid made from these columns infers\n * each one exactly, its edit's schema included. Never set.\n */\n readonly Specs?: Specs\n}\n\n// Integer-like keys are enumerated before every other key, whatever the order\n// they were written in, so `{ name, 2024 }` would put 2024 first.\nconst arrayIndex = /^(0|[1-9][0-9]*)$/\n\nexport const Columns = {\n /** The width of a column that names none. */\n defaultWidth: 120,\n /** The narrowest a column with no `minWidth` resizes to. */\n minWidth: 40,\n /** A value as a cell shows it: nothing for `null` or `undefined`. */\n textOf: (value: unknown): string => (value === null || value === undefined ? '' : String(value)),\n /**\n * Declares a grid's columns over `Row`. Call it twice, once with the row\n * type and once with the specs, so the ids and values are inferred:\n * `Columns.define<Product>()({ sku: { header: 'SKU', value: p => p.sku } })`.\n */\n define:\n <Row>() =>\n <Specs extends Record<string, ColumnSpec<Row, unknown>>>(\n specs: Specs,\n ): NoInfer<Columns<Row, Specs>> => {\n // A literal `__proto__:` key sets the prototype instead of naming a\n // column, so the column would vanish from `Object.keys`.\n if (Object.getPrototypeOf(specs) !== Object.prototype || Object.hasOwn(specs, '__proto__')) {\n throw new Error('Columns.define: \"__proto__\" cannot name a column.')\n }\n const ids = Object.keys(specs)\n const byId: Record<string, Column<Row, string, unknown>> = {}\n for (const id of ids) {\n if (arrayIndex.test(id)) {\n throw new Error(\n `Columns.define: the column id \"${id}\" is an array index, which JavaScript orders before every other key. Give it a name that is not a number.`,\n )\n }\n byId[id] = Object.freeze({ ...specs[id]!, id })\n }\n return Object.freeze({\n ids: Object.freeze(ids),\n byId: Object.freeze(byId),\n }) as Columns<Row, Specs>\n },\n}\n"],"mappings":";;;;;;;AA6CA,MAAa,aAAa,kBAAkB;CAC1C,MAAM,CAAC;;CAEP,QAAQ,CAAC;;CAET,QAAQ,EAAE,SAAS,OAAO,MAAM,OAAO,MAAM,EAAE;;CAE/C,MAAM,CAAC;AACT,CAAC;;;;;;;AASD,MAAM,UAAU;AAEhB,MAAM,UAAU,QAAgC;CAC9C,IAAI,CAAC,UAAU,cAAc,GAAG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AM,OAAO,OAAO,IAAI;EAC1B,CAAC;CACH;AACJ"}
@@ -1,6 +1,7 @@
1
- import { l as ColumnSpec, n as RowModel, r as RowStatus, u as Columns } from "./rows-D8siEVqF.mjs";
1
+ import { ColumnSpec, Columns } from "./columns.js";
2
2
  import { DisplayColumn, DisplayWords } from "foldkit-crud";
3
3
  import { Page, RemoteData } from "foldkit-remote";
4
+ import { RowModel, RowStatus } from "./rows.js";
4
5
  /** What a grid adds to a listed member's column: where it stands, its size, and editing. */
5
6
  type ColumnOptions<Row> = Partial<Omit<ColumnSpec<Row, string>, 'value'>>;
6
7
  /**
@@ -27,4 +28,4 @@ export declare const GridCrud: {
27
28
  status: typeof status;
28
29
  };
29
30
  export {};
30
- //# sourceMappingURL=crud.d.mts.map
31
+ //# sourceMappingURL=crud.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"crud.d.mts","names":[],"sources":["../src/crud.ts"],"mappings":";;;;KAcK,cAAc,OAAO,QAAQ,KAAK,WAAW;;;;;;;;;cAU5C,UACJ,oBACA,wBAAwB,KAAK,kBAE7B,4BAA4B,KAAK,OAAO,cAAc,SAAM;WAE3C,SAAS,cAAc,cAAc;WAAgB,KAAK;GAAK;WAC5D,QAAQ;WAAuB,UAAU;MAC5D,QAAQ,iBAAiB,KAAK,MAAM,WAAW,eAAe,QAAQ;cA4BnE,OAAQ,KAAG,MAAQ,WAAW,KAAK,OAAK,MAAQ,KAAK,mBAAiB,SAAS;;cAuB/E,SAAU,KAAG,MAAQ,WAAW,KAAK,UAAQ;qBAUtC"}
1
+ {"version":3,"file":"crud.d.ts","names":[],"sources":["../src/crud.ts"],"mappings":";;;;;KAcK,cAAc,OAAO,QAAQ,KAAK,WAAW;;;;;;;;;cAU5C,UACJ,oBACA,wBAAwB,KAAK,kBAE7B,4BAA4B,KAAK,OAAO,cAAc,SAAM;WAE3C,SAAS,cAAc,cAAc;WAAgB,KAAK;GAAK;WAC5D,QAAQ;WAAuB,UAAU;MAC5D,QAAQ,iBAAiB,KAAK,MAAM,WAAW,eAAe,QAAQ;cA4BnE,OAAQ,KAAG,MAAQ,WAAW,KAAK,OAAK,MAAQ,KAAK,mBAAiB,SAAS;;cAuB/E,SAAU,KAAG,MAAQ,WAAW,KAAK,UAAQ;qBAUtC"}
@@ -1,7 +1,8 @@
1
- import { n as RowModel, o as Columns, r as RowStatus, t as RowCount } from "./rows-Dy1HPpGX.mjs";
2
1
  import { Option } from "effect";
2
+ import { Columns } from "./columns.js";
3
3
  import { Display } from "foldkit-crud";
4
4
  import { RemoteData } from "foldkit-remote";
5
+ import { RowCount, RowModel, RowStatus } from "./rows.js";
5
6
  // src/crud.ts
6
7
  /**
7
8
  * `foldkit-data-grid/crud` — a grid over a `foldkit-crud` list and the Remote
@@ -76,4 +77,4 @@ const GridCrud = {
76
77
  };
77
78
  export { GridCrud };
78
79
 
79
- //# sourceMappingURL=crud.mjs.map
80
+ //# sourceMappingURL=crud.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crud.js","names":[],"sources":["../src/crud.ts"],"sourcesContent":["/**\n * `foldkit-data-grid/crud` — a grid over a `foldkit-crud` list and the Remote\n * page it reads. The list says the columns, their labels and how each value\n * shows; Remote owns the page, its loading and its retries. This module only\n * reads both into the grid's terms: columns, a row model, and a status. It\n * fetches nothing and holds nothing.\n */\nimport { Option } from 'effect'\nimport { Display, type DisplayColumn, type DisplayWords } from 'foldkit-crud'\nimport { type Page, RemoteData } from 'foldkit-remote'\nimport { Columns, type ColumnSpec } from './columns.js'\nimport { RowCount, RowModel, RowStatus } from './rows.js'\n\n/** What a grid adds to a listed member's column: where it stands, its size, and editing. */\ntype ColumnOptions<Row> = Partial<Omit<ColumnSpec<Row, string>, 'value'>>\n\n/**\n * The grid's columns for a list: one per listed member, keyed by its member\n * key, headed by its label, its value the member's text as its Display says\n * it. A member whose Display is hidden (usually the id) starts hidden: it is\n * read, and can be shown, but is not drawn. `columns` adds what only the\n * grid knows to a member's column: pinning, widths, `edit`, or another\n * header; what it gives wins over what the list says.\n */\nconst columns = <\n Key extends string,\n Row extends { readonly [K in Key]: unknown },\n // Each member's options as written, so an edit's schema types its value.\n Options extends { readonly [K in Key]?: ColumnOptions<Row> },\n>(\n list: { readonly columns: ReadonlyArray<DisplayColumn<Key>>; readonly Row: Row },\n options: { readonly words?: DisplayWords; readonly columns?: Options } = {},\n): Columns<Row, { readonly [K in Key]: ColumnSpec<Row, string> & Options[K] }> => {\n // Filled for every listed key below, so the record holds each Key.\n const specs = {} as Record<Key, ColumnSpec<Row, string>>\n for (const column of list.columns) {\n specs[column.key] = {\n header: column.label,\n value: row => Display.show(column.display, row[column.key], options.words ?? {}),\n ...(column.display.shown ? {} : { hidden: true }),\n ...options.columns?.[column.key],\n }\n }\n // Each spec is the member's column with its options spread over it, so it\n // holds what `Options` says of it.\n return Columns.define<Row>()(\n specs as { readonly [K in Key]: ColumnSpec<Row, string> & Options[K] },\n )\n}\n\n/**\n * The rows of a page as the grid's row model, in the page's order. A page with\n * more after it counts as unknown, at least its rows; a failed read keeps the\n * rows it had. No answer yet, or none found, is no rows.\n */\n// One row model per page value, so the projection built from it, and what is\n// worked out from that, is kept across renders while the page is unchanged.\nconst pages = new WeakMap<object, RowModel<unknown>>()\nconst empty: ReadonlyArray<never> = []\n\nconst rows = <Row>(page: RemoteData<Page<Row>>, key: (row: Row) => string): RowModel<Row> => {\n const items = (value: Page<Row>): RowModel<Row> => {\n const known = pages.get(value)\n if (known !== undefined) return known as RowModel<Row>\n const model = RowModel.fromArray(value.items, key)\n const counted = value.hasNext\n ? { ...model, count: RowCount.Unknown({ atLeast: value.items.length }) }\n : model\n pages.set(value, counted)\n return counted\n }\n const none = RowModel.fromArray<Row>(empty, key)\n return RemoteData.match<Page<Row>, RowModel<Row>>(page, {\n Initial: () => none,\n Loading: () => none,\n NotFound: () => none,\n Ready: items,\n Refreshing: items,\n Failed: (_, previous) => Option.match(previous, { onNone: () => none, onSome: items }),\n })\n}\n\n/** Where a page stands, for the grid to say. */\nconst status = <Row>(page: RemoteData<Page<Row>>): RowStatus =>\n RemoteData.match<Page<Row>, RowStatus>(page, {\n Initial: () => RowStatus.Loading(),\n Loading: () => RowStatus.Loading(),\n NotFound: () => RowStatus.Ready(),\n Ready: () => RowStatus.Ready(),\n Refreshing: () => RowStatus.Refreshing(),\n Failed: error => RowStatus.Failed({ message: error.message }),\n })\n\nexport const GridCrud = { columns, rows, status }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwBA,MAAM,WAMJ,MACA,UAAyE,CAAC,MACM;CAEhF,MAAM,QAAQ,CAAC;CACf,KAAK,MAAM,UAAU,KAAK,SACxB,MAAM,OAAO,OAAO;EAClB,QAAQ,OAAO;EACf,QAAO,QAAO,QAAQ,KAAK,OAAO,SAAS,IAAI,OAAO,MAAM,QAAQ,SAAS,CAAC,CAAC;EAC/E,GAAI,OAAO,QAAQ,QAAQ,CAAC,IAAI,EAAE,QAAQ,KAAK;EAC/C,GAAG,QAAQ,UAAU,OAAO;CAC9B;CAIF,OAAO,QAAQ,OAAY,CAAC,CAC1B,KACF;AACF;;;;;;AASA,MAAM,wBAAQ,IAAI,QAAmC;AACrD,MAAM,QAA8B,CAAC;AAErC,MAAM,QAAa,MAA6B,QAA6C;CAC3F,MAAM,SAAS,UAAoC;EACjD,MAAM,QAAQ,MAAM,IAAI,KAAK;EAC7B,IAAI,UAAU,KAAA,GAAW,OAAO;EAChC,MAAM,QAAQ,SAAS,UAAU,MAAM,OAAO,GAAG;EACjD,MAAM,UAAU,MAAM,UAClB;GAAE,GAAG;GAAO,OAAO,SAAS,QAAQ,EAAE,SAAS,MAAM,MAAM,OAAO,CAAC;EAAE,IACrE;EACJ,MAAM,IAAI,OAAO,OAAO;EACxB,OAAO;CACT;CACA,MAAM,OAAO,SAAS,UAAe,OAAO,GAAG;CAC/C,OAAO,WAAW,MAAgC,MAAM;EACtD,eAAe;EACf,eAAe;EACf,gBAAgB;EAChB,OAAO;EACP,YAAY;EACZ,SAAS,GAAG,aAAa,OAAO,MAAM,UAAU;GAAE,cAAc;GAAM,QAAQ;EAAM,CAAC;CACvF,CAAC;AACH;;AAGA,MAAM,UAAe,SACnB,WAAW,MAA4B,MAAM;CAC3C,eAAe,UAAU,QAAQ;CACjC,eAAe,UAAU,QAAQ;CACjC,gBAAgB,UAAU,MAAM;CAChC,aAAa,UAAU,MAAM;CAC7B,kBAAkB,UAAU,WAAW;CACvC,SAAQ,UAAS,UAAU,OAAO,EAAE,SAAS,MAAM,QAAQ,CAAC;AAC9D,CAAC;AAEH,MAAa,WAAW;CAAE;CAAS;CAAM;AAAO"}
package/dist/fill.d.ts ADDED
@@ -0,0 +1,49 @@
1
+ import { Option } from "effect";
2
+ import { CellAddress, CellBox, GridProjection } from "./projection.js";
3
+ import { PastedCell } from "./clipboard.js";
4
+ /** A fill: the range whose cells are carried on, and the cell it was carried to. */
5
+ export interface FillRequest<Id extends string> {
6
+ readonly source: {
7
+ readonly anchor: CellAddress<Id>;
8
+ readonly focus: CellAddress<Id>;
9
+ };
10
+ readonly to: CellAddress<Id>;
11
+ }
12
+ /**
13
+ * Where a fill lands: the source's box, and the box it fills beyond it, down,
14
+ * up, right or left, whichever way `to` lies further outside the source. A
15
+ * fill carries on along one axis only, as spreadsheets do.
16
+ */
17
+ export interface FillPlan<Id extends string> {
18
+ readonly source: CellBox<Id>;
19
+ readonly target: CellBox<Id>;
20
+ /** Rows (`down`/`up`) or columns (`right`/`left`), away from the source. */
21
+ readonly toward: 'down' | 'up' | 'right' | 'left';
22
+ }
23
+ /**
24
+ * The texts that carry `source` on for `count` cells, the first of them next
25
+ * to it. Two or more numbers a constant step apart continue their step, with
26
+ * as many decimals as the most precise of them; anything else repeats, in
27
+ * order. `backward` carries the source on before its first text, as filling
28
+ * up or left does.
29
+ */
30
+ declare const series: (source: ReadonlyArray<string>, count: number, backward: boolean) => ReadonlyArray<string>;
31
+ /** The source's box and the box beyond it toward `to`; none when `to` is inside it. */
32
+ declare const plan: <Row, Id extends string>(projection: GridProjection<Row, Id>, request: FillRequest<Id>) => Option.Option<FillPlan<Id>>;
33
+ /**
34
+ * The cells a fill writes: each lane of the source (a column for a fill down
35
+ * or up, a row for one right or left) carried on through the target by
36
+ * `series`. Cells on a column that does not edit, or on a row not loaded, are
37
+ * dropped; each kept cell has `from`, the text it showed.
38
+ */
39
+ declare const cells: <Row, Id extends string>(projection: GridProjection<Row, Id>, fill: FillPlan<Id>, options: {
40
+ readonly editable: (column: Id) => boolean;
41
+ readonly from: (address: CellAddress<Id>) => string;
42
+ }) => ReadonlyArray<PastedCell<Id>>;
43
+ export declare const Fill: {
44
+ series: typeof series;
45
+ plan: typeof plan;
46
+ cells: typeof cells;
47
+ };
48
+ export {};
49
+ //# sourceMappingURL=fill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fill.d.ts","names":[],"sources":["../src/fill.ts"],"mappings":";;;;iBAKiB,YAAY;WAClB;aAAmB,QAAQ,YAAY;aAAc,OAAO,YAAY;;WACxE,IAAI,YAAY;;;;;;;iBAQV,SAAS;WACf,QAAQ,QAAQ;WAChB,QAAQ,QAAQ;;WAEhB;;;;;;;;;cAYL,SAAM,QACF,uBAAqB,eAChB,sBAEZ;;cAqBG,OAAQ,KAAK,mBAAiB,YACtB,eAAe,KAAK,KAAG,SAC1B,YAAY,QACpB,OAAO,OAAO,SAAS;;;;;;;cAyCpB,QAAS,KAAK,mBAAiB,YACvB,eAAe,KAAK,KAAG,MAC7B,SAAS,KAAG;WAEP,WAAW,QAAQ;WACnB,OAAO,SAAS,YAAY;MAEtC,cAAc,WAAW;qBAsCf"}
package/dist/fill.js ADDED
@@ -0,0 +1,113 @@
1
+ import { Option } from "effect";
2
+ // src/fill.ts
3
+ const number = /^-?\d+(?:\.(\d+))?$/;
4
+ /**
5
+ * The texts that carry `source` on for `count` cells, the first of them next
6
+ * to it. Two or more numbers a constant step apart continue their step, with
7
+ * as many decimals as the most precise of them; anything else repeats, in
8
+ * order. `backward` carries the source on before its first text, as filling
9
+ * up or left does.
10
+ */
11
+ const series = (source, count, backward) => {
12
+ const at = (index) => source[(index % source.length + source.length) % source.length];
13
+ const repeated = Array.from({ length: count }, (_, index) => backward ? at(-1 - index) : at(source.length + index));
14
+ if (source.length < 2) return repeated;
15
+ const parsed = source.map((text) => number.exec(text.trim()));
16
+ if (parsed.some((match) => match === null)) return repeated;
17
+ const decimals = Math.max(...parsed.map((match) => match[1]?.length ?? 0));
18
+ const scale = 10 ** decimals;
19
+ const units = source.map((text) => Math.round(Number(text.trim()) * scale));
20
+ const step = units[1] - units[0];
21
+ if (units.some((unit, index) => index > 0 && unit - units[index - 1] !== step)) return repeated;
22
+ const from = backward ? units[0] : units[units.length - 1];
23
+ return Array.from({ length: count }, (_, index) => ((from + (backward ? -step : step) * (index + 1)) / scale).toFixed(decimals));
24
+ };
25
+ /** The source's box and the box beyond it toward `to`; none when `to` is inside it. */
26
+ const plan = (projection, request) => Option.flatMap(projection.box(request.source.anchor, request.source.focus), (source) => Option.flatMap(projection.positionOf(request.to), (to) => {
27
+ const first = projection.columns.indexOf(source.columns[0]);
28
+ const last = first + source.columns.length - 1;
29
+ const below = to.row - (source.rows.end - 1);
30
+ const above = source.rows.start - to.row;
31
+ const right = to.column - last;
32
+ const left = first - to.column;
33
+ const rows = Math.max(below, above);
34
+ const columns = Math.max(right, left);
35
+ if (rows <= 0 && columns <= 0) return Option.none();
36
+ if (rows >= columns) {
37
+ const target = below > 0 ? {
38
+ start: source.rows.end,
39
+ end: to.row + 1
40
+ } : {
41
+ start: to.row,
42
+ end: source.rows.start
43
+ };
44
+ return Option.some({
45
+ source,
46
+ target: {
47
+ rows: target,
48
+ columns: source.columns
49
+ },
50
+ toward: below > 0 ? "down" : "up"
51
+ });
52
+ }
53
+ const columnsOf = (start, end) => projection.columns.slice(start, end);
54
+ return Option.some({
55
+ source,
56
+ target: {
57
+ rows: source.rows,
58
+ columns: right > 0 ? columnsOf(last + 1, to.column + 1) : columnsOf(to.column, first)
59
+ },
60
+ toward: right > 0 ? "right" : "left"
61
+ });
62
+ }));
63
+ /**
64
+ * The cells a fill writes: each lane of the source (a column for a fill down
65
+ * or up, a row for one right or left) carried on through the target by
66
+ * `series`. Cells on a column that does not edit, or on a row not loaded, are
67
+ * dropped; each kept cell has `from`, the text it showed.
68
+ */
69
+ const cells = (projection, fill, options) => {
70
+ const rowsOf = (box) => Array.from({ length: box.end - box.start }, (_, offset) => box.start + offset);
71
+ const keyAt = (index) => projection.rows.keyAt(index);
72
+ const textAt = (index, column) => Option.match(keyAt(index), {
73
+ onNone: () => "",
74
+ onSome: (row) => options.from({
75
+ row,
76
+ column
77
+ })
78
+ });
79
+ const cell = (index, column, text) => options.editable(column) ? Option.match(keyAt(index), {
80
+ onNone: () => [],
81
+ onSome: (row) => [{
82
+ row,
83
+ column,
84
+ text,
85
+ from: options.from({
86
+ row,
87
+ column
88
+ })
89
+ }]
90
+ }) : [];
91
+ const backward = fill.toward === "up" || fill.toward === "left";
92
+ const away = (items) => backward ? [...items].reverse() : items;
93
+ if (fill.toward === "down" || fill.toward === "up") {
94
+ const targetRows = away(rowsOf(fill.target.rows));
95
+ return fill.source.columns.flatMap((column) => {
96
+ const texts = series(rowsOf(fill.source.rows).map((index) => textAt(index, column)), targetRows.length, backward);
97
+ return targetRows.flatMap((index, at) => cell(index, column, texts[at]));
98
+ });
99
+ }
100
+ const targetColumns = away(fill.target.columns);
101
+ return rowsOf(fill.source.rows).flatMap((index) => {
102
+ const texts = series(fill.source.columns.map((column) => textAt(index, column)), targetColumns.length, backward);
103
+ return targetColumns.flatMap((column, at) => cell(index, column, texts[at]));
104
+ });
105
+ };
106
+ const Fill = {
107
+ series,
108
+ plan,
109
+ cells
110
+ };
111
+ export { Fill };
112
+
113
+ //# sourceMappingURL=fill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fill.js","names":[],"sources":["../src/fill.ts"],"sourcesContent":["import { Option } from 'effect'\nimport type { PastedCell } from './clipboard.js'\nimport type { CellAddress, CellBox, GridProjection } from './projection.js'\n\n/** A fill: the range whose cells are carried on, and the cell it was carried to. */\nexport interface FillRequest<Id extends string> {\n readonly source: { readonly anchor: CellAddress<Id>; readonly focus: CellAddress<Id> }\n readonly to: CellAddress<Id>\n}\n\n/**\n * Where a fill lands: the source's box, and the box it fills beyond it, down,\n * up, right or left, whichever way `to` lies further outside the source. A\n * fill carries on along one axis only, as spreadsheets do.\n */\nexport interface FillPlan<Id extends string> {\n readonly source: CellBox<Id>\n readonly target: CellBox<Id>\n /** Rows (`down`/`up`) or columns (`right`/`left`), away from the source. */\n readonly toward: 'down' | 'up' | 'right' | 'left'\n}\n\nconst number = /^-?\\d+(?:\\.(\\d+))?$/\n\n/**\n * The texts that carry `source` on for `count` cells, the first of them next\n * to it. Two or more numbers a constant step apart continue their step, with\n * as many decimals as the most precise of them; anything else repeats, in\n * order. `backward` carries the source on before its first text, as filling\n * up or left does.\n */\nconst series = (\n source: ReadonlyArray<string>,\n count: number,\n backward: boolean,\n): ReadonlyArray<string> => {\n const at = (index: number) => source[((index % source.length) + source.length) % source.length]!\n const repeated = Array.from({ length: count }, (_, index) =>\n backward ? at(-1 - index) : at(source.length + index),\n )\n if (source.length < 2) return repeated\n const parsed = source.map(text => number.exec(text.trim()))\n if (parsed.some(match => match === null)) return repeated\n const decimals = Math.max(...parsed.map(match => match![1]?.length ?? 0))\n // Whole units of the finest decimal, so a step of 0.1 adds up exactly.\n const scale = 10 ** decimals\n const units = source.map(text => Math.round(Number(text.trim()) * scale))\n const step = units[1]! - units[0]!\n if (units.some((unit, index) => index > 0 && unit - units[index - 1]! !== step)) return repeated\n const from = backward ? units[0]! : units[units.length - 1]!\n return Array.from({ length: count }, (_, index) =>\n ((from + (backward ? -step : step) * (index + 1)) / scale).toFixed(decimals),\n )\n}\n\n/** The source's box and the box beyond it toward `to`; none when `to` is inside it. */\nconst plan = <Row, Id extends string>(\n projection: GridProjection<Row, Id>,\n request: FillRequest<Id>,\n): Option.Option<FillPlan<Id>> =>\n Option.flatMap(projection.box(request.source.anchor, request.source.focus), source =>\n Option.flatMap(projection.positionOf(request.to), to => {\n const first = projection.columns.indexOf(source.columns[0]!)\n const last = first + source.columns.length - 1\n const below = to.row - (source.rows.end - 1)\n const above = source.rows.start - to.row\n const right = to.column - last\n const left = first - to.column\n const rows = Math.max(below, above)\n const columns = Math.max(right, left)\n if (rows <= 0 && columns <= 0) return Option.none()\n if (rows >= columns) {\n const target =\n below > 0\n ? { start: source.rows.end, end: to.row + 1 }\n : { start: to.row, end: source.rows.start }\n return Option.some({\n source,\n target: { rows: target, columns: source.columns },\n toward: below > 0 ? 'down' : 'up',\n })\n }\n const columnsOf = (start: number, end: number) => projection.columns.slice(start, end)\n return Option.some({\n source,\n target: {\n rows: source.rows,\n columns: right > 0 ? columnsOf(last + 1, to.column + 1) : columnsOf(to.column, first),\n },\n toward: right > 0 ? 'right' : 'left',\n })\n }),\n )\n\n/**\n * The cells a fill writes: each lane of the source (a column for a fill down\n * or up, a row for one right or left) carried on through the target by\n * `series`. Cells on a column that does not edit, or on a row not loaded, are\n * dropped; each kept cell has `from`, the text it showed.\n */\nconst cells = <Row, Id extends string>(\n projection: GridProjection<Row, Id>,\n fill: FillPlan<Id>,\n options: {\n readonly editable: (column: Id) => boolean\n readonly from: (address: CellAddress<Id>) => string\n },\n): ReadonlyArray<PastedCell<Id>> => {\n const rowsOf = (box: { readonly start: number; readonly end: number }) =>\n Array.from({ length: box.end - box.start }, (_, offset) => box.start + offset)\n const keyAt = (index: number) => projection.rows.keyAt(index)\n const textAt = (index: number, column: Id) =>\n Option.match(keyAt(index), { onNone: () => '', onSome: row => options.from({ row, column }) })\n const cell = (index: number, column: Id, text: string): ReadonlyArray<PastedCell<Id>> =>\n options.editable(column)\n ? Option.match(keyAt(index), {\n onNone: () => [],\n onSome: row => [{ row, column, text, from: options.from({ row, column }) }],\n })\n : []\n const backward = fill.toward === 'up' || fill.toward === 'left'\n // Away from the source, so the series' first text lands next to it.\n const away = <A>(items: ReadonlyArray<A>) => (backward ? [...items].reverse() : items)\n if (fill.toward === 'down' || fill.toward === 'up') {\n const targetRows = away(rowsOf(fill.target.rows))\n return fill.source.columns.flatMap(column => {\n const texts = series(\n rowsOf(fill.source.rows).map(index => textAt(index, column)),\n targetRows.length,\n backward,\n )\n return targetRows.flatMap((index, at) => cell(index, column, texts[at]!))\n })\n }\n const targetColumns = away(fill.target.columns)\n return rowsOf(fill.source.rows).flatMap(index => {\n const texts = series(\n fill.source.columns.map(column => textAt(index, column)),\n targetColumns.length,\n backward,\n )\n return targetColumns.flatMap((column, at) => cell(index, column, texts[at]!))\n })\n}\n\nexport const Fill = { series, plan, cells }\n"],"mappings":";;AAsBA,MAAM,SAAS;;;;;;;;AASf,MAAM,UACJ,QACA,OACA,aAC0B;CAC1B,MAAM,MAAM,UAAkB,QAAS,QAAQ,OAAO,SAAU,OAAO,UAAU,OAAO;CACxF,MAAM,WAAW,MAAM,KAAK,EAAE,QAAQ,MAAM,IAAI,GAAG,UACjD,WAAW,GAAG,KAAK,KAAK,IAAI,GAAG,OAAO,SAAS,KAAK,CACtD;CACA,IAAI,OAAO,SAAS,GAAG,OAAO;CAC9B,MAAM,SAAS,OAAO,KAAI,SAAQ,OAAO,KAAK,KAAK,KAAK,CAAC,CAAC;CAC1D,IAAI,OAAO,MAAK,UAAS,UAAU,IAAI,GAAG,OAAO;CACjD,MAAM,WAAW,KAAK,IAAI,GAAG,OAAO,KAAI,UAAS,MAAO,EAAE,EAAE,UAAU,CAAC,CAAC;CAExE,MAAM,QAAQ,MAAM;CACpB,MAAM,QAAQ,OAAO,KAAI,SAAQ,KAAK,MAAM,OAAO,KAAK,KAAK,CAAC,IAAI,KAAK,CAAC;CACxE,MAAM,OAAO,MAAM,KAAM,MAAM;CAC/B,IAAI,MAAM,MAAM,MAAM,UAAU,QAAQ,KAAK,OAAO,MAAM,QAAQ,OAAQ,IAAI,GAAG,OAAO;CACxF,MAAM,OAAO,WAAW,MAAM,KAAM,MAAM,MAAM,SAAS;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MAAM,QAAQ,OACZ,KAAK,OAAO,QAAQ,KAAI,WAAU,OAAO,OAAO,MAAM,CAAC,GACvD,cAAc,QACd,QACF;EACA,OAAO,cAAc,SAAS,QAAQ,OAAO,KAAK,OAAO,QAAQ,MAAM,GAAI,CAAC;CAC9E,CAAC;AACH;AAEA,MAAa,OAAO;CAAE;CAAQ;CAAM;AAAM"}
@@ -0,0 +1,119 @@
1
+ import { Option, Schema } from "effect";
2
+ import { ColumnSpec, Columns } from "./columns.js";
3
+ import { Bundle } from "foldkit-bundle";
4
+ import { CellAddress, GridProjection } from "./projection.js";
5
+ import { KeyboardModifiers } from "foldkit/html";
6
+ export type Direction = 'ltr' | 'rtl';
7
+ export interface KeyOptions<Id extends string> {
8
+ readonly current: Option.Option<CellAddress<Id>>;
9
+ readonly key: string;
10
+ readonly modifiers: KeyboardModifiers;
11
+ /** Default `'ltr'`; under `'rtl'` the left and right arrows swap. */
12
+ readonly direction?: Direction;
13
+ /** How many rows PageUp and PageDown move: the rows a viewport shows. */
14
+ readonly pageRows: number;
15
+ }
16
+ /**
17
+ * The cell that holds the grid's one tab stop: the focused cell while it is
18
+ * shown, and otherwise the first cell. A focused cell whose column was hidden
19
+ * or whose row went away stays in the Model, so focus returns to it if it
20
+ * comes back, but the tab stop moves on until then.
21
+ */
22
+ declare const tabStop: <Row, Id extends string>(projection: GridProjection<Row, Id>, current: Option.Option<CellAddress<Id>>) => Option.Option<CellAddress<Id>>;
23
+ /**
24
+ * The cell a key moves focus to, or none when the key is not the grid's to
25
+ * handle, so the caller leaves it to the page. Arrows step one cell, Home and
26
+ * End go to the row's edges and, with Ctrl, to the grid's corners; PageUp and
27
+ * PageDown move `pageRows`. A key the grid handles always lands somewhere: at
28
+ * an edge, or onto a row that is counted but not loaded, focus stays where it
29
+ * is. Shift, Alt and Meta combinations are left alone: Shift extends a
30
+ * selection, which is not focus's to decide.
31
+ */
32
+ declare const target: <Row, Id extends string>(projection: GridProjection<Row, Id>, options: KeyOptions<Id>) => Option.Option<CellAddress<Id>>;
33
+ /**
34
+ * A cell's DOM id: the grid's id, the row key and the column id, each
35
+ * URI-encoded and joined by `:`, which encoding never leaves in a part, so no
36
+ * two cells share an id. The container points at it with
37
+ * `aria-activedescendant`.
38
+ */
39
+ declare const cellId: <Id extends string>(grid: string, address: CellAddress<Id>) => string;
40
+ /**
41
+ * The address a `cellId` names, if it is one of this grid's: its row key and
42
+ * its column id as written, for the grid's columns to check. An id from
43
+ * another grid, or with a malformed escape, is none.
44
+ */
45
+ declare const cellOf: (grid: string, id: string) => Option.Option<{
46
+ readonly row: string;
47
+ readonly column: string;
48
+ }>;
49
+ /**
50
+ * A column header's DOM id: the grid's id and the column id, URI-encoded and
51
+ * joined by `:`. It has two parts where a cell's has three, so the two never
52
+ * meet.
53
+ */
54
+ declare const headerId: (grid: string, column: string) => string;
55
+ /** The column a `headerId` names, if it is one of this grid's, as written. */
56
+ declare const headerOf: (grid: string, id: string) => Option.Option<string>;
57
+ /**
58
+ * Focus for one grid: which cell is current, by identity. Make it once per
59
+ * grid from its columns, so a focus saved in the Model decodes only against
60
+ * columns that exist.
61
+ */
62
+ declare const make: <Row, Specs extends Record<string, ColumnSpec<Row, unknown>>>(columns: Columns<Row, Specs>) => {
63
+ Address: Schema.Struct<{
64
+ readonly row: Schema.String;
65
+ readonly column: Schema.Literals<readonly (keyof Specs & string)[]>;
66
+ }>;
67
+ Model: Schema.Struct<{
68
+ /** The focused cell; stored as `null` when none is. */
69
+ readonly current: Schema.OptionFromNullOr<Schema.Struct<{
70
+ readonly row: Schema.String;
71
+ readonly column: Schema.Literals<readonly (keyof Specs & string)[]>;
72
+ }>>;
73
+ /**
74
+ * The column header focus is on, when it is on the header row. The cell
75
+ * focused before stays in `current`, so going back down returns to it.
76
+ */
77
+ readonly header: Schema.OptionFromNullOr<Schema.Literals<readonly (keyof Specs & string)[]>>;
78
+ }>;
79
+ Message: import("foldkit/message").MessageUnion<{
80
+ /** A cell became current: the user focused it, or a key moved there. */
81
+ readonly Focused: {
82
+ address: Schema.Struct<{
83
+ readonly row: Schema.String;
84
+ readonly column: Schema.Literals<readonly (keyof Specs & string)[]>;
85
+ }>;
86
+ };
87
+ /** Focus went up to a column's header. */
88
+ readonly HeaderFocused: {
89
+ column: Schema.Literals<readonly (keyof Specs & string)[]>;
90
+ };
91
+ }>;
92
+ bundle: Bundle.Bundle<"GridFocus", void, {
93
+ readonly current: Option.Option<{
94
+ readonly row: string;
95
+ readonly column: keyof Specs & string;
96
+ }>;
97
+ readonly header: Option.Option<keyof Specs & string>;
98
+ }, {
99
+ readonly _tag: "Focused";
100
+ readonly address: {
101
+ readonly row: string;
102
+ readonly column: keyof Specs & string;
103
+ };
104
+ } | {
105
+ readonly _tag: "HeaderFocused";
106
+ readonly column: keyof Specs & string;
107
+ }, never, never, never, void, {}, {}>;
108
+ };
109
+ export declare const GridFocus: {
110
+ make: typeof make;
111
+ target: typeof target;
112
+ tabStop: typeof tabStop;
113
+ cellId: typeof cellId;
114
+ cellOf: typeof cellOf;
115
+ headerId: typeof headerId;
116
+ headerOf: typeof headerOf;
117
+ };
118
+ export {};
119
+ //# sourceMappingURL=focus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focus.d.ts","names":[],"sources":["../src/focus.ts"],"mappings":";;;;;YAQY;iBAEK,WAAW;WACjB,SAAS,OAAO,OAAO,YAAY;WACnC;WACA,WAAW;;WAEX,YAAY;;WAEZ;;;;;;;;cAYL,UAAW,KAAK,mBAAiB,YACzB,eAAe,KAAK,KAAG,SAC1B,OAAO,OAAO,YAAY,SAClC,OAAO,OAAO,YAAY;;;;;;;;;;cAsBvB,SAAU,KAAK,mBAAiB,YACxB,eAAe,KAAK,KAAG,SAC1B,WAAW,QACnB,OAAO,OAAO,YAAY;;;;;;;cAyBvB,SAAU,mBAAiB,cAAc,SAAW,YAAY;;;;;;cAUhE,SAAM,cACE,eAEX,OAAO;WAAkB;WAAsB;;;;;;;cAiB5C,WAAQ,cAAgB;;cAIxB,WAAQ,cAAgB,eAAe,OAAO;;;;;;cAQ9C,OAAQ,KAAK,cAAc,eAAe,WAAW,gBAAc,SAC9D,QAAQ,KAAK;;;;;;;;;;;;;;;;;;;;MAeT,SAAO,OAAA;;;;;;;MAED,QAAM,OAAA,yBAAA;;;;;;;;;;;;;;;;;;;;qBA2Bd"}
package/dist/focus.js ADDED
@@ -0,0 +1,150 @@
1
+ import { Option, Schema } from "effect";
2
+ import { defineMessageUnion } from "foldkit/message";
3
+ import { modifyFields } from "foldkit/struct";
4
+ import { Bundle } from "foldkit-bundle";
5
+ import { CellAddress } from "./projection.js";
6
+ // src/focus.ts
7
+ const sameAddress = (a, b) => a.row === b.row && a.column === b.column;
8
+ /**
9
+ * The cell that holds the grid's one tab stop: the focused cell while it is
10
+ * shown, and otherwise the first cell. A focused cell whose column was hidden
11
+ * or whose row went away stays in the Model, so focus returns to it if it
12
+ * comes back, but the tab stop moves on until then.
13
+ */
14
+ const tabStop = (projection, current) => Option.orElse(Option.filter(current, (address) => Option.isSome(projection.positionOf(address))), () => projection.first());
15
+ const arrows = /* @__PURE__ */ new Map([
16
+ ["ArrowUp", {
17
+ rows: -1,
18
+ columns: 0
19
+ }],
20
+ ["ArrowDown", {
21
+ rows: 1,
22
+ columns: 0
23
+ }],
24
+ ["ArrowLeft", {
25
+ rows: 0,
26
+ columns: -1
27
+ }],
28
+ ["ArrowRight", {
29
+ rows: 0,
30
+ columns: 1
31
+ }]
32
+ ]);
33
+ /**
34
+ * The cell a key moves focus to, or none when the key is not the grid's to
35
+ * handle, so the caller leaves it to the page. Arrows step one cell, Home and
36
+ * End go to the row's edges and, with Ctrl, to the grid's corners; PageUp and
37
+ * PageDown move `pageRows`. A key the grid handles always lands somewhere: at
38
+ * an edge, or onto a row that is counted but not loaded, focus stays where it
39
+ * is. Shift, Alt and Meta combinations are left alone: Shift extends a
40
+ * selection, which is not focus's to decide.
41
+ */
42
+ const target = (projection, options) => {
43
+ const { key, modifiers } = options;
44
+ if (modifiers.shiftKey || modifiers.altKey || modifiers.metaKey) return Option.none();
45
+ return Option.flatMap(tabStop(projection, options.current), (from) => {
46
+ const stay = (to) => Option.some(Option.getOrElse(to, () => from));
47
+ if (key === "Home") return stay(modifiers.ctrlKey ? projection.first() : projection.rowStart(from));
48
+ if (key === "End") return stay(modifiers.ctrlKey ? projection.last() : projection.rowEnd(from));
49
+ if (modifiers.ctrlKey) return Option.none();
50
+ if (key === "PageUp") return stay(projection.moveBy(from, { rows: -options.pageRows }));
51
+ if (key === "PageDown") return stay(projection.moveBy(from, { rows: options.pageRows }));
52
+ const step = arrows.get(key);
53
+ if (step === void 0) return Option.none();
54
+ const flip = options.direction === "rtl" ? -1 : 1;
55
+ return stay(projection.moveBy(from, {
56
+ rows: step.rows,
57
+ columns: step.columns * flip
58
+ }));
59
+ });
60
+ };
61
+ /**
62
+ * A cell's DOM id: the grid's id, the row key and the column id, each
63
+ * URI-encoded and joined by `:`, which encoding never leaves in a part, so no
64
+ * two cells share an id. The container points at it with
65
+ * `aria-activedescendant`.
66
+ */
67
+ const cellId = (grid, address) => [
68
+ grid,
69
+ address.row,
70
+ address.column
71
+ ].map(encodeURIComponent).join(":");
72
+ const decode = Option.liftThrowable(decodeURIComponent);
73
+ /**
74
+ * The address a `cellId` names, if it is one of this grid's: its row key and
75
+ * its column id as written, for the grid's columns to check. An id from
76
+ * another grid, or with a malformed escape, is none.
77
+ */
78
+ const cellOf = (grid, id) => Option.map(partsOf(grid, id, 3), ([row, column]) => ({
79
+ row,
80
+ column
81
+ }));
82
+ /** The parts of one of this grid's ids after the grid's own, when it has `count` parts in all. */
83
+ const partsOf = (grid, id, count) => {
84
+ const parts = id.split(":");
85
+ if (parts.length !== count) return Option.none();
86
+ return Option.flatMap(Option.all(parts.map((part) => decode(part))), ([owner, ...rest]) => owner === grid ? Option.some(rest) : Option.none());
87
+ };
88
+ /**
89
+ * A column header's DOM id: the grid's id and the column id, URI-encoded and
90
+ * joined by `:`. It has two parts where a cell's has three, so the two never
91
+ * meet.
92
+ */
93
+ const headerId = (grid, column) => [grid, column].map(encodeURIComponent).join(":");
94
+ /** The column a `headerId` names, if it is one of this grid's, as written. */
95
+ const headerOf = (grid, id) => Option.map(partsOf(grid, id, 2), ([column]) => column);
96
+ /**
97
+ * Focus for one grid: which cell is current, by identity. Make it once per
98
+ * grid from its columns, so a focus saved in the Model decodes only against
99
+ * columns that exist.
100
+ */
101
+ const make = (columns) => {
102
+ const Address = CellAddress.schema(columns);
103
+ const Model = Schema.Struct({
104
+ /** The focused cell; stored as `null` when none is. */
105
+ current: Schema.OptionFromNullOr(Address),
106
+ /**
107
+ * The column header focus is on, when it is on the header row. The cell
108
+ * focused before stays in `current`, so going back down returns to it.
109
+ */
110
+ header: Schema.OptionFromNullOr(Address.fields.column)
111
+ });
112
+ const Message = defineMessageUnion({
113
+ /** A cell became current: the user focused it, or a key moved there. */
114
+ Focused: { address: Address },
115
+ /** Focus went up to a column's header. */
116
+ HeaderFocused: { column: Address.fields.column }
117
+ });
118
+ return {
119
+ Address,
120
+ Model,
121
+ Message,
122
+ bundle: Bundle.make("GridFocus", {
123
+ Model,
124
+ Message,
125
+ init: () => ({ model: {
126
+ current: Option.none(),
127
+ header: Option.none()
128
+ } }),
129
+ update: (model, message) => ({ model: Message.match(message, {
130
+ Focused: ({ address }) => Option.isNone(model.header) && Option.isSome(model.current) && sameAddress(model.current.value, address) ? model : modifyFields(model, {
131
+ current: () => Option.some(address),
132
+ header: () => Option.none()
133
+ }),
134
+ HeaderFocused: ({ column }) => Option.contains(model.header, column) ? model : modifyFields(model, { header: () => Option.some(column) })
135
+ }) })
136
+ })
137
+ };
138
+ };
139
+ const GridFocus = {
140
+ make,
141
+ target,
142
+ tabStop,
143
+ cellId,
144
+ cellOf,
145
+ headerId,
146
+ headerOf
147
+ };
148
+ export { GridFocus };
149
+
150
+ //# sourceMappingURL=focus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focus.js","names":[],"sources":["../src/focus.ts"],"sourcesContent":["import { Option, Schema } from 'effect'\nimport type { KeyboardModifiers } from 'foldkit/html'\nimport { defineMessageUnion } from 'foldkit/message'\nimport { modifyFields } from 'foldkit/struct'\nimport { Bundle } from 'foldkit-bundle'\nimport type { Columns, ColumnSpec } from './columns.js'\nimport { CellAddress, type GridProjection } from './projection.js'\n\nexport type Direction = 'ltr' | 'rtl'\n\nexport interface KeyOptions<Id extends string> {\n readonly current: Option.Option<CellAddress<Id>>\n readonly key: string\n readonly modifiers: KeyboardModifiers\n /** Default `'ltr'`; under `'rtl'` the left and right arrows swap. */\n readonly direction?: Direction\n /** How many rows PageUp and PageDown move: the rows a viewport shows. */\n readonly pageRows: number\n}\n\nconst sameAddress = <Id extends string>(a: CellAddress<Id>, b: CellAddress<Id>): boolean =>\n a.row === b.row && a.column === b.column\n\n/**\n * The cell that holds the grid's one tab stop: the focused cell while it is\n * shown, and otherwise the first cell. A focused cell whose column was hidden\n * or whose row went away stays in the Model, so focus returns to it if it\n * comes back, but the tab stop moves on until then.\n */\nconst tabStop = <Row, Id extends string>(\n projection: GridProjection<Row, Id>,\n current: Option.Option<CellAddress<Id>>,\n): Option.Option<CellAddress<Id>> =>\n Option.orElse(\n Option.filter(current, address => Option.isSome(projection.positionOf(address))),\n () => projection.first(),\n )\n\nconst arrows: ReadonlyMap<string, { readonly rows: number; readonly columns: number }> = new Map([\n ['ArrowUp', { rows: -1, columns: 0 }],\n ['ArrowDown', { rows: 1, columns: 0 }],\n ['ArrowLeft', { rows: 0, columns: -1 }],\n ['ArrowRight', { rows: 0, columns: 1 }],\n])\n\n/**\n * The cell a key moves focus to, or none when the key is not the grid's to\n * handle, so the caller leaves it to the page. Arrows step one cell, Home and\n * End go to the row's edges and, with Ctrl, to the grid's corners; PageUp and\n * PageDown move `pageRows`. A key the grid handles always lands somewhere: at\n * an edge, or onto a row that is counted but not loaded, focus stays where it\n * is. Shift, Alt and Meta combinations are left alone: Shift extends a\n * selection, which is not focus's to decide.\n */\nconst target = <Row, Id extends string>(\n projection: GridProjection<Row, Id>,\n options: KeyOptions<Id>,\n): Option.Option<CellAddress<Id>> => {\n const { key, modifiers } = options\n if (modifiers.shiftKey || modifiers.altKey || modifiers.metaKey) return Option.none()\n return Option.flatMap(tabStop(projection, options.current), from => {\n const stay = (to: Option.Option<CellAddress<Id>>) =>\n Option.some(Option.getOrElse(to, () => from))\n if (key === 'Home')\n return stay(modifiers.ctrlKey ? projection.first() : projection.rowStart(from))\n if (key === 'End') return stay(modifiers.ctrlKey ? projection.last() : projection.rowEnd(from))\n if (modifiers.ctrlKey) return Option.none()\n if (key === 'PageUp') return stay(projection.moveBy(from, { rows: -options.pageRows }))\n if (key === 'PageDown') return stay(projection.moveBy(from, { rows: options.pageRows }))\n const step = arrows.get(key)\n if (step === undefined) return Option.none()\n const flip = options.direction === 'rtl' ? -1 : 1\n return stay(projection.moveBy(from, { rows: step.rows, columns: step.columns * flip }))\n })\n}\n\n/**\n * A cell's DOM id: the grid's id, the row key and the column id, each\n * URI-encoded and joined by `:`, which encoding never leaves in a part, so no\n * two cells share an id. The container points at it with\n * `aria-activedescendant`.\n */\nconst cellId = <Id extends string>(grid: string, address: CellAddress<Id>): string =>\n [grid, address.row, address.column].map(encodeURIComponent).join(':')\n\nconst decode = Option.liftThrowable(decodeURIComponent)\n\n/**\n * The address a `cellId` names, if it is one of this grid's: its row key and\n * its column id as written, for the grid's columns to check. An id from\n * another grid, or with a malformed escape, is none.\n */\nconst cellOf = (\n grid: string,\n id: string,\n): Option.Option<{ readonly row: string; readonly column: string }> =>\n Option.map(partsOf(grid, id, 3), ([row, column]) => ({ row: row!, column: column! }))\n\n/** The parts of one of this grid's ids after the grid's own, when it has `count` parts in all. */\nconst partsOf = (grid: string, id: string, count: number): Option.Option<ReadonlyArray<string>> => {\n const parts = id.split(':')\n if (parts.length !== count) return Option.none()\n return Option.flatMap(Option.all(parts.map(part => decode(part))), ([owner, ...rest]) =>\n owner === grid ? Option.some(rest) : Option.none(),\n )\n}\n\n/**\n * A column header's DOM id: the grid's id and the column id, URI-encoded and\n * joined by `:`. It has two parts where a cell's has three, so the two never\n * meet.\n */\nconst headerId = (grid: string, column: string): string =>\n [grid, column].map(encodeURIComponent).join(':')\n\n/** The column a `headerId` names, if it is one of this grid's, as written. */\nconst headerOf = (grid: string, id: string): Option.Option<string> =>\n Option.map(partsOf(grid, id, 2), ([column]) => column!)\n\n/**\n * Focus for one grid: which cell is current, by identity. Make it once per\n * grid from its columns, so a focus saved in the Model decodes only against\n * columns that exist.\n */\nconst make = <Row, Specs extends Record<string, ColumnSpec<Row, unknown>>>(\n columns: Columns<Row, Specs>,\n) => {\n const Address = CellAddress.schema(columns)\n const Model = Schema.Struct({\n /** The focused cell; stored as `null` when none is. */\n current: Schema.OptionFromNullOr(Address),\n /**\n * The column header focus is on, when it is on the header row. The cell\n * focused before stays in `current`, so going back down returns to it.\n */\n header: Schema.OptionFromNullOr(Address.fields.column),\n })\n type Model = typeof Model.Type\n const Message = defineMessageUnion({\n /** A cell became current: the user focused it, or a key moved there. */\n Focused: { address: Address },\n /** Focus went up to a column's header. */\n HeaderFocused: { column: Address.fields.column },\n })\n const bundle = Bundle.make('GridFocus', {\n Model,\n Message,\n init: () => ({ model: { current: Option.none(), header: Option.none() } }),\n update: (model: Model, message: typeof Message.Type) => ({\n model: Message.match(message, {\n Focused: ({ address }) =>\n Option.isNone(model.header) &&\n Option.isSome(model.current) &&\n sameAddress(model.current.value, address)\n ? model\n : modifyFields(model, {\n current: () => Option.some(address),\n header: () => Option.none(),\n }),\n HeaderFocused: ({ column }) =>\n Option.contains(model.header, column)\n ? model\n : modifyFields(model, { header: () => Option.some(column) }),\n }),\n }),\n })\n return { Address, Model, Message, bundle }\n}\n\nexport const GridFocus = { make, target, tabStop, cellId, cellOf, headerId, headerOf }\n"],"mappings":";;;;;;AAoBA,MAAM,eAAkC,GAAoB,MAC1D,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE;;;;;;;AAQpC,MAAM,WACJ,YAC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