@sheetpane/grid 0.0.0-stage → 0.1.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 (92) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +429 -2
  3. package/custom-elements.json +1246 -0
  4. package/dist/errors/element.d.ts +108 -0
  5. package/dist/errors/element.d.ts.map +1 -0
  6. package/dist/errors/element.js +456 -0
  7. package/dist/errors/element.js.map +1 -0
  8. package/dist/errors/index.d.ts +2 -0
  9. package/dist/errors/index.d.ts.map +1 -0
  10. package/dist/errors/index.js +3 -0
  11. package/dist/errors/index.js.map +1 -0
  12. package/dist/excel/element.d.ts +434 -0
  13. package/dist/excel/element.d.ts.map +1 -0
  14. package/dist/excel/element.js +3382 -0
  15. package/dist/excel/element.js.map +1 -0
  16. package/dist/excel/geometry.d.ts +81 -0
  17. package/dist/excel/geometry.d.ts.map +1 -0
  18. package/dist/excel/geometry.js +137 -0
  19. package/dist/excel/geometry.js.map +1 -0
  20. package/dist/excel/index.d.ts +2 -0
  21. package/dist/excel/index.d.ts.map +1 -0
  22. package/dist/excel/index.js +3 -0
  23. package/dist/excel/index.js.map +1 -0
  24. package/dist/excel/selection.d.ts +103 -0
  25. package/dist/excel/selection.d.ts.map +1 -0
  26. package/dist/excel/selection.js +189 -0
  27. package/dist/excel/selection.js.map +1 -0
  28. package/dist/excel/styles.d.ts +3 -0
  29. package/dist/excel/styles.d.ts.map +1 -0
  30. package/dist/excel/styles.js +206 -0
  31. package/dist/excel/styles.js.map +1 -0
  32. package/dist/frameworks/elements.d.ts +136 -0
  33. package/dist/frameworks/jsx.d.ts +64 -0
  34. package/dist/frameworks/jsx.js +2 -0
  35. package/dist/frameworks/solid.d.ts +133 -0
  36. package/dist/frameworks/solid.js +2 -0
  37. package/dist/frameworks/svelte.d.ts +102 -0
  38. package/dist/frameworks/svelte.js +2 -0
  39. package/dist/frameworks/vue.d.ts +69 -0
  40. package/dist/frameworks/vue.js +2 -0
  41. package/dist/index.d.ts +23 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +25 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/llms-full.txt +8028 -0
  46. package/dist/llms.txt +111 -0
  47. package/dist/pane/index.d.ts +2 -0
  48. package/dist/pane/index.d.ts.map +1 -0
  49. package/dist/pane/index.js +3 -0
  50. package/dist/pane/index.js.map +1 -0
  51. package/dist/pane/registry.d.ts +33 -0
  52. package/dist/pane/registry.d.ts.map +1 -0
  53. package/dist/pane/registry.js +73 -0
  54. package/dist/pane/registry.js.map +1 -0
  55. package/dist/pane/rules.d.ts +231 -0
  56. package/dist/pane/rules.d.ts.map +1 -0
  57. package/dist/pane/rules.js +792 -0
  58. package/dist/pane/rules.js.map +1 -0
  59. package/dist/pane/store.d.ts +385 -0
  60. package/dist/pane/store.d.ts.map +1 -0
  61. package/dist/pane/store.js +1028 -0
  62. package/dist/pane/store.js.map +1 -0
  63. package/dist/pane/types.d.ts +130 -0
  64. package/dist/pane/types.d.ts.map +1 -0
  65. package/dist/pane/types.js +22 -0
  66. package/dist/pane/types.js.map +1 -0
  67. package/dist/plugins/host.d.ts +56 -0
  68. package/dist/plugins/host.d.ts.map +1 -0
  69. package/dist/plugins/host.js +124 -0
  70. package/dist/plugins/host.js.map +1 -0
  71. package/dist/plugins/types.d.ts +159 -0
  72. package/dist/plugins/types.d.ts.map +1 -0
  73. package/dist/plugins/types.js +12 -0
  74. package/dist/plugins/types.js.map +1 -0
  75. package/dist/rules.schema.json +52 -0
  76. package/dist/shared/dom.d.ts +23 -0
  77. package/dist/shared/dom.d.ts.map +1 -0
  78. package/dist/shared/dom.js +32 -0
  79. package/dist/shared/dom.js.map +1 -0
  80. package/dist/skills-bin.d.ts +3 -0
  81. package/dist/skills-bin.d.ts.map +1 -0
  82. package/dist/skills-bin.js +9 -0
  83. package/dist/skills-bin.js.map +1 -0
  84. package/dist/style.css +3 -0
  85. package/dist/tokens.d.ts +49 -0
  86. package/dist/tokens.d.ts.map +1 -0
  87. package/dist/tokens.js +43 -0
  88. package/dist/tokens.js.map +1 -0
  89. package/dist/vscode.css-custom-data.json +365 -0
  90. package/dist/vscode.html-custom-data.json +218 -0
  91. package/dist/web-types.json +914 -0
  92. package/package.json +72 -3
package/dist/llms.txt ADDED
@@ -0,0 +1,111 @@
1
+ # sheetpane
2
+
3
+ > View, edit and review .xlsx and .csv files inside any web page: two web components — <sheetpane-excel> (the sheet, View or Edit) and <sheetpane-errors> (the review list) — kept in sync through one in-memory workbook per `pane`, an export that writes every change into a copy of the upload, eight optional plugins, column rules and a JSON rules file. Nothing is uploaded. Version 0.1.0.
4
+
5
+ Every rule lives in one standing record; READMEs and skills point to them. The full text of everything below is in llms-full.txt.
6
+
7
+ ## Start
8
+ - [sheetpane](https://github.com/arpitarya/sheetpane/blob/v0.1.0/README.md): what it is, the packages, try it
9
+ - [@sheetpane/grid](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/grid/README.md): the elements: attributes, properties, events, column rules, rules file, React hooks, styling
10
+ - [Architecture](https://github.com/arpitarya/sheetpane/blob/v0.1.0/docs/ARCHITECTURE.md): packages, elements, the one workbook, the flows
11
+ - [Changelog](https://github.com/arpitarya/sheetpane/blob/v0.1.0/CHANGELOG.md): what changed, breaking changes first
12
+
13
+ ## Try it
14
+ - [Live playground](https://arpitarya.github.io/sheetpane/): the plugin gallery in plain HTML; `/react/` in React (deployed from each release)
15
+ - [Starters](https://github.com/arpitarya/sheetpane/blob/v0.1.0/examples/starters/README.md): each create-sheetpane template, with an Open in StackBlitz link
16
+ - [create-sheetpane](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/create-sheetpane/README.md): `npm create sheetpane@latest`: a working app in one command
17
+
18
+ ## Elements
19
+ - [SR-GRID](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0105_GRID.md): the sheet, the store, the plugin host, events, rules, test hooks
20
+ - [SR-ERRORS](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0106_ERRORS.md): the error list and the New error form
21
+ - [custom-elements.json](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/grid/custom-elements.json): both elements as a Custom Elements Manifest: attributes, properties, methods, events with payload types, slots, parts, --sp-* properties
22
+ - [Vue, Svelte, Solid, Angular](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/grid/README.md#vue-svelte-solid-angular): the elements in each framework; typings @sheetpane/grid/jsx, /vue, /svelte, /solid
23
+ - [@sheetpane/import](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/import/README.md): read .xlsx / .csv into a JavaScript workbook
24
+ - [@sheetpane/export](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/export/README.md): write .xlsx / .csv, patch the original, download()
25
+
26
+ ## Plugins
27
+ - [@sheetpane/numfmt](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/numfmt/README.md): Excel number formats for sheetpane — currency, dates, fractions, elapsed time, conditional sections, locales — as a plugin on the `format` hook.
28
+ - [@sheetpane/formulas](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/formulas/README.md): Formula recalculation for sheetpane — edit a cell and every dependent formula updates — as a plugin on the `derive` hook, backed by IronCalc (WASM, lazy-loaded).
29
+ - [@sheetpane/styles](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/styles/README.md): Cell styles for sheetpane — fill, bold, italic, underline, strikethrough, colour, size, borders, alignment, wrap — as a plugin on the `decorate` hook. Never a font family (SR-LAW-5): the host's font is the font.
30
+ - [@sheetpane/validation](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/validation/README.md): The workbook's own data-validation rules, checked when the file loads and after every edit. Each cell that breaks a rule shows up as a warning in `<sheetpane-errors>`.
31
+ - [@sheetpane/condfmt](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/condfmt/README.md): Conditional formatting for sheetpane — the file's own `<conditionalFormatting>` rules drawn as Excel draws them: value and text rules, duplicates, top / bottom, averages, colour scales, data bars and formula rules — as a plugin on the `decorate` hook, after `@sheetpane/styles`. Render only: nothing here writes a rule.
32
+ - [@sheetpane/images](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/images/README.md): Images for sheetpane — pictures anchored in the sheet drawn in sheet space through the `overlay` hook; view only, kept on export.
33
+ - [@sheetpane/charts](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/charts/README.md): Charts for sheetpane — each chart in a workbook shown at its anchor: a frame with its title, type, series count and Show source cells (stage 1), drawn as our own SVG for bar, column, line, pie and scatter (stage 2) — through the `overlay` hook.
34
+ - [@sheetpane/comments](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/comments/README.md): Excel's comments and sheetpane's errors, in both directions. When a file loads, its notes and threaded comments show up in `<sheetpane-errors>`. When you export, every error in the review goes into the file as an Excel threaded comment on its cell.
35
+ - [@sheetpane/visibility](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/visibility/README.md): Hide and unhide rows, columns and sheets in `<sheetpane-excel>` — as changes, written into the download.
36
+
37
+ ## Rules and errors
38
+ - [Column rules](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/grid/README.md#column-rules): checks by column title in code
39
+ - [Rules file](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/grid/README.md#rules-file): valid and invalid values as JSON, rules-src, flagging="off"
40
+ - [rules.schema.json](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/grid/rules.schema.json): the rules file's JSON Schema
41
+ - [Error codes](https://github.com/arpitarya/sheetpane/blob/v0.1.0/docs/ERRORS.md): every SP-xxxx code: meaning, cause, fix
42
+
43
+ ## Testing and tooling
44
+ - [@sheetpane/testing](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/testing/README.md): Playwright and Vitest helpers for host apps
45
+ - [@sheetpane/fixtures](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/fixtures/README.md): known workbooks with a manifest
46
+ - [create-sheetpane](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/create-sheetpane/README.md): npm create sheetpane — a working app in vanilla, React, Next.js, Vue, Angular or Svelte
47
+
48
+ ## Skills
49
+ - [@sheetpane/skills](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/README.md): npx sheetpane-skills install — skills for Claude Code, Kiro and Codex
50
+ - [@sheetpane/mcp](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/mcp/README.md): npx -y @sheetpane/mcp — an MCP server: describe the API, inspect a workbook, draft and check a rules file, explain an SP code, find a skill
51
+ - [sheetpane](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane/SKILL.md): Use first for any sheetpane task in a host app - a decision table pointing to the right sheetpane skill (embedding, loading, errors, events, rules, plugins, theming, testing, frameworks, troubleshooting). Not needed once you know which skill applies.
52
+ - [sheetpane-a11y](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-a11y/SKILL.md): Use when making a host's sheetpane page accessible - the grid's keyboard contract, labelling the host tab or dialog, focus when the pop-up closes, colour never alone. Not for the grid's own internals.
53
+ - [sheetpane-backend](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-backend/SKILL.md): Use when a host saves the reviewed file and the review on a server and restores them later - the exported blob, getErrors()/setErrors() JSON, restoring after sheetpane-load, a file that changed since. Not for client-only use.
54
+ - [sheetpane-column-rules](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-column-rules/SKILL.md): Use when the host checks what users type by column title in code - columns, validate(ctx, signal), on-invalid flag or block, header-row. Not for rules shipped as a JSON file (sheetpane-rules-file) or the workbook's own validation (sheetpane-plugins).
55
+ - [sheetpane-embed](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-embed/SKILL.md): Use when placing <sheetpane-excel> and <sheetpane-errors> on a page - tab or pop-up, linking them by pane, giving the sheet a height, the host's font. Not for React specifics (sheetpane-react) or loading and saving files (sheetpane-load-export).
56
+ - [sheetpane-errors](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-errors/SKILL.md): Use for the review list - <sheetpane-errors>, the SheetpaneError schema, getErrors()/setErrors(), sheetpane-errors and sheetpane-reveal, error types. Not for rule-made errors (sheetpane-column-rules) or server storage (sheetpane-backend).
57
+ - [sheetpane-events](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-events/SKILL.md): Use when a host reacts to what the user does in the sheet - selection, typing, saving, cancelling, refusing a value with sheetpane-beforechange, or switching sheets. Not for column checks (sheetpane-column-rules) or the error list (sheetpane-errors).
58
+ - [sheetpane-file-work-item](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-file-work-item/SKILL.md): Use when contributing to the sheetpane repo and filing a new work item W-nn - the next free id, the item file, its OPEN-WORK row and ball, the worklog and NOW. Not for host apps that use sheetpane.
59
+ - [sheetpane-frameworks](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-frameworks/SKILL.md): Use when embedding sheetpane in Vue, Svelte, Solid, Angular, Next.js or plain HTML with typed props and events - the custom-element setup, @sheetpane/grid/vue|svelte|solid typings, editor data. Not for React (sheetpane-react).
60
+ - [sheetpane-load-export](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-load-export/SKILL.md): Use when opening a file in the sheet (src, file, load()) or getting it back (the Download button, export(), sheetpane-export, download()). Not for saving the review (sheetpane-errors, sheetpane-backend) or no-UI read/write (sheetpane-setup).
61
+ - [sheetpane-migrate](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-migrate/SKILL.md): Use when replacing SheetJS, Handsontable or AG Grid with sheetpane - their concepts mapped to sheetpane's elements, events and plugins, and what has no equivalent. Not for a fresh project (sheetpane-setup).
62
+ - [sheetpane-performance](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-performance/SKILL.md): Use when a host deals with large workbooks - what loads fast, how rule checks are sliced, lazy-mounting several sheets, what to measure on your own machine and data. Not for small files, which need nothing special.
63
+ - [sheetpane-plugin-author](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-plugin-author/SKILL.md): Use when writing a sheetpane plugin - the six hooks, the slots and control descriptors, exportOptions, registerPlugin, what a plugin may never do. Not for choosing among the shipped plugins (sheetpane-plugins).
64
+ - [sheetpane-plugins](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-plugins/SKILL.md): Use when a host needs more than review - number formats, live formulas, cell styles, data validation, conditional formats, pictures, charts or comments - and must pick and enable plugins. Not for writing a plugin (sheetpane-plugin-author).
65
+ - [sheetpane-react](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-react/SKILL.md): Use when sheetpane is used from React 18 or 19 - props and onsheetpane-* events on the custom elements, refs, the copy-in hook recipes, JSX typing. Not for plain HTML (sheetpane-embed) or Vue, Angular, Svelte, Next.js (sheetpane-frameworks).
66
+ - [sheetpane-records](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-records/SKILL.md): Use when contributing to the sheetpane repo and a change touches a rule - finding the record that owns a module, the laws, the commit guard, where a rule lives, archive-is-not-evidence. Not for host apps.
67
+ - [sheetpane-rules](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-rules/SKILL.md): The /sheetpane-rules [workbook or rules file] command - drafts a rules file for a workbook, or fixes one, then runs sheetpane-skills check-rules until it is clean. Not for learning the format (sheetpane-rules-file) or rules in code.
68
+ - [sheetpane-rules-file](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-rules-file/SKILL.md): Use when valid and invalid values ship as a JSON file per sheet, column or cell, checked on load and listed only in the errors panel - rules / rules-src, its JSON Schema, flagging="off". Not for rules written in code (sheetpane-column-rules).
69
+ - [sheetpane-security](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-security/SKILL.md): Use when sheetpane handles untrusted uploads or runs under a strict CSP - what the grid reads and never sends, regexes in rules, CSV formula injection, sandboxed iframes, styles in shadow DOM. Not for general web security.
70
+ - [sheetpane-setup](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-setup/SKILL.md): Use when adding sheetpane to a project - which @sheetpane packages to install, a bundler import or a plain-HTML import map, one version for all. Not for placing the elements (sheetpane-embed) or choosing plugins (sheetpane-plugins).
71
+ - [sheetpane-test](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-test/SKILL.md): The /sheetpane-test [workbook] command - writes one end-to-end test for a host page with sheetpane - load the .xlsx or .csv (or a fixture), edit a cell, read the download. Not for the testing techniques themselves (sheetpane-testing).
72
+ - [sheetpane-testing](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-testing/SKILL.md): Use when writing end-to-end or browser tests for a host app that embeds sheetpane - reaching cells in shadow DOM, waiting for sheetpane-load, editing, reading a downloaded .xlsx back, known fixture files. Not for testing sheetpane itself.
73
+ - [sheetpane-theming](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-theming/SKILL.md): Use when matching sheetpane to a host's look - dark mode via theme, the --sp-* colour tokens, style.css, why no font is set. Not for a workbook's own colours (sheetpane-plugins - styles, condfmt).
74
+ - [sheetpane-troubleshoot](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-troubleshoot/SKILL.md): Use when sheetpane misbehaves in a host - a blank grid, a file refused, an SP-xxxx code in the console, SSR crashes, CORS on src, copy not working, rules errors that look wrong. Not for designing a feature.
75
+ - [sheetpane-upgrade](https://github.com/arpitarya/sheetpane/blob/v0.1.0/packages/skills/skills/sheetpane-upgrade/SKILL.md): Use when moving a host to a newer sheetpane version - reading CHANGELOG.md, the lockstep version rule, removed or renamed controls and events, re-checking a host's tests. Not for first-time setup (sheetpane-setup).
76
+
77
+ ## Records
78
+ - [The register](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/README.md): every record, its state and what it owns
79
+ - [SR-LAWS](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0001_LAWS.md): Assigns the handles L0, L1, … and routes each to the record that states it. This record states no law itself.
80
+ - [SR-LAW-0](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0002_LAW-0-authority.md): Every rule is stated in exactly one record; every other artifact links to it; Law records outrank every other record; a Law changes only on the decider's ruling.
81
+ - [SR-LAW-1](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0003_LAW-1-retired-records-archived.md): A retired record moves to archive/records/ in the same change, with a map row, status archived and a dated banner; from then on it is named, never cited.
82
+ - [SR-LAW-2](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0004_LAW-2-foss-dependencies.md): Every dependency sheetpane declares or pulls in — runtime, peer, optional, dev and transitive — is released under a free and open source licence.
83
+ - [SR-LAW-3](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0005_LAW-3-xlsx-and-csv-only.md): sheetpane opens, views, edits and saves exactly two file formats — XLSX and CSV; every other spreadsheet format is out of scope until the decider rules otherwise.
84
+ - [SR-LAW-4](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0006_LAW-4-web-component.md): sheetpane ships as a standards-based web component — a custom element any framework, or none, can use — and is never tied to one framework.
85
+ - [SR-LAW-5](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0007_LAW-5-host-font.md): sheetpane ships no font of its own: by default it renders in the browser's default font, and when the host application sets a font, every part of sheetpane uses it.
86
+ - [SR-LAW-6](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0008_LAW-6-edits-in-memory-export-with-changes.md): Once a workbook is loaded, every change made to it is held in memory, and an export produces the workbook with every change applied.
87
+ - [SR-LAW-7](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0009_LAW-7-surfaces-always-in-sync.md): The view, edit and error components always show the same workbook: a change in any one appears in the others at once, with no refresh or save.
88
+ - [SR-LAW-8](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0010_LAW-8-npm-package.md): sheetpane is distributed as an npm package: published to the npm registry, installed with npm or any npm-compatible client, and imported as a module.
89
+ - [SR-LAW-9](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0011_LAW-9-memory-is-a-javascript-object.md): Wherever a record says memory, it means JavaScript objects held in the page; no browser storage or database is memory, until the decider rules otherwise.
90
+ - [SR-DOWNLOAD](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0101_DOWNLOAD.md): One function, download(data, filename, options?), turns what @sheetpane/export produces into a file the browser saves — .xlsx or .csv only, bytes unchanged, errors never silent.
91
+ - [SR-BUILD](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0102_BUILD.md): How the monorepo installs, type-checks, builds, tests, runs in CI and publishes every package under packages/ at one version.
92
+ - [SR-EXPORT](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0103_EXPORT.md): A plain Workbook object in, .xlsx bytes or .csv text out; patchXlsx rewrites only the changed cells of the uploaded file; no runtime dependencies.
93
+ - [SR-IMPORT](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0104_IMPORT.md): The reader: extension and magic bytes checked, .xlsx through the ZIP walk and DOMParser, .csv through a state machine; raw values beside display text; the parsed tables plugins read.
94
+ - [SR-GRID](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0105_GRID.md): One in-memory workbook per pane that every element reads and writes; the sheet element that views and edits it; six hooks and six slots for plugins; one undo stack per pane; freeze panes in the core grid.
95
+ - [SR-ERRORS](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0106_ERRORS.md): The error component reads and writes the pane's one workbook: a filterable list, the form Flag issue opens, Show in sheet, read-only sign-off — no private copy, no linked chip, no export footer.
96
+ - [SR-IMAGES](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0107_IMAGES.md): A view-only plugin that draws each picture a sheet's drawing anchors at its place in the grid, decoding media lazily from the package, with the anchor arithmetic @sheetpane/charts reuses.
97
+ - [SR-VALIDATION](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0108_VALIDATION.md): A plugin on the validate hook that checks the workbook's <dataValidations> on load and after every edit, writing one workbook-authored warning per failing cell, with a list arrow for list rules.
98
+ - [SR-NUMFMT](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0109_NUMFMT.md): A plugin on the format hook that shows every numeric cell as Excel would — every built-in and custom code, locales, 1904 — with a format dropdown in Edit and the new formats written back on export.
99
+ - [SR-STYLES](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0110_STYLES.md): A plugin on the decorate hook that draws each cell's fill, font weight, style, size, colour, decoration, borders and alignment from the workbook — never a font family — with a format row in Edit and the changes written into styles.xml on export.
100
+ - [SR-FORMULAS](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0111_FORMULAS.md): A plugin on the derive and exportPatch hooks that recalculates formulas with IronCalc (WASM, loaded on the first formula), marks the cells it changed, and writes typed formulas and new cached values on export.
101
+ - [SR-COMMENTS](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0112_COMMENTS.md): A plugin on the validate and exportPatch hooks: a workbook's notes and threaded comments arrive as read-only file errors, and an export writes every review error as an Excel threaded comment (with its legacy note and VML) at its cell — on by default, switchable off.
102
+ - [SR-CHARTS](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0113_CHARTS.md): An overlay plugin that shows every chart at its anchor — a frame with title, type, series and Show source cells, then an SVG drawing for bar, column, line, pie, doughnut and scatter — from the chart's cached values, or the live cells when a formula plugin is installed; export copies charts untouched.
103
+ - [SR-CONDFMT](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0114_CONDFMT.md): A decorate plugin, ordered after styles, that draws the conditional formats a workbook carries — cell rules, text rules, duplicates, top/bottom, averages, colour scales, data bars and expressions — live as cells change; render only, with a hover legend and a rule count.
104
+ - [SR-FIXTURES](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0115_FIXTURES.md): A dependency-free package of hand-built test workbooks — the showcase, its rules sample, edge cases, CSV dialects — with a manifest of what each holds and url / path / bytes to reach them from any runner.
105
+ - [SR-SKILLS](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0116_SKILLS.md): A leaf package of 23 Markdown skills, entry files and a no-dependency installer that copies them where each coding agent looks; every sheetpane package depends on it; a drift check keeps the skills true to the code.
106
+ - [SR-CODES](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0117_CODES.md): Every throw, console warning, rules-engine note, refused load and blocked edit carries a permanent SP-xxxx code from one registry in @sheetpane/export, with an entry in docs/ERRORS.md; a test fails on any message without one.
107
+ - [SR-TESTING](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0118_TESTING.md): One driver API for Playwright and Vitest browser mode — locators, actions, Download read back as values, matchers — built only on the grid's committed test hooks.
108
+ - [SR-MCP](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0119_MCP.md): A stdio MCP server, hand-written, tools only: describe the API, inspect a workbook, draft and check a rules file, explain an SP code, find a skill — deterministic and read-only.
109
+ - [SR-CREATE](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0120_CREATE.md): npm create sheetpane — six framework templates with the grid, the errors panel, the showcase and its rules file, one test, the skills and the MCP server; checked end to end in CI.
110
+ - [SR-VISIBILITY](https://github.com/arpitarya/sheetpane/blob/v0.1.0/records/0121_VISIBILITY.md): The plugin that lets an editor hide and unhide rows, columns and sheets and group outlines — menus, Google Sheets' keys, a marker click — written into the download. Seeing the file's hiding is core (SR-GRID 21c).
111
+
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pane/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ // pane — the shared in-memory workbook; not built yet. Spec: work/open/W-01-sheetpane-excel.md
2
+ export {};
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pane/index.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,OAAO,EAAE,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { type WorkbookStore } from './store.js';
2
+ /**
3
+ * The store for a pane id, created on first use; the elements call it when they connect
4
+ * (SR-GRID decision 1). A later caller naming other plugins gets a console warning (SP-3011).
5
+ * @param id - The `pane` attribute's value.
6
+ * @param el - The element taking a hold on the store; {@link releasePane} drops it.
7
+ * @param plugins - Registered plugin ids; they apply only when this call creates the store — the set is fixed per pane.
8
+ * @returns The pane's store.
9
+ */
10
+ export declare function acquirePane(id: string, el: Element, plugins: readonly string[]): WorkbookStore;
11
+ /**
12
+ * Drops an element's hold on a pane; the store goes when the last element releases it.
13
+ * @param id - The pane id.
14
+ * @param el - The element that acquired it.
15
+ */
16
+ export declare function releasePane(id: string, el: Element): void;
17
+ /**
18
+ * The live store of a pane, if any element holds it — for a host or a test to read or drive.
19
+ * @param id - The `pane` attribute's value.
20
+ * @returns The pane's store, or undefined when no connected element names that pane.
21
+ * @example
22
+ * ```ts
23
+ * import { paneStore } from '@sheetpane/grid';
24
+ * const book = paneStore('q3');
25
+ * if (book) console.log(book.changeCount, book.getErrors().length);
26
+ * ```
27
+ */
28
+ export declare function paneStore(id: string): WorkbookStore | undefined;
29
+ /** Elements attached to a store, in connection order: events nobody owns go out on the first sheet, else the first element. */
30
+ export declare function attach(store: WorkbookStore, el: Element): void;
31
+ export declare function detach(store: WorkbookStore, el: Element): void;
32
+ export declare function isPrimary(store: WorkbookStore, el: Element): boolean;
33
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/pane/registry.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAMhE;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,aAAa,CAU9F;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,GAAG,IAAI,CAKzD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAE/D;AAED,+HAA+H;AAC/H,wBAAgB,MAAM,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,EAAE,OAAO,GAAG,IAAI,CAI9D;AACD,wBAAgB,MAAM,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,EAAE,OAAO,GAAG,IAAI,CAG9D;AACD,wBAAgB,SAAS,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,EAAE,OAAO,GAAG,OAAO,CAIpE"}
@@ -0,0 +1,73 @@
1
+ // One store per `pane` id, shared by every element that names it (contract
2
+ // verdict decision 1): created by the first element that asks, released when
3
+ // the last one disconnects. Elements without a pane get a private store.
4
+ import { spMessage } from '@sheetpane/export';
5
+ import { pluginsFromIds } from '../plugins/host.js';
6
+ import { createWorkbook } from './store.js';
7
+ const panes = new Map();
8
+ const attached = new WeakMap();
9
+ /**
10
+ * The store for a pane id, created on first use; the elements call it when they connect
11
+ * (SR-GRID decision 1). A later caller naming other plugins gets a console warning (SP-3011).
12
+ * @param id - The `pane` attribute's value.
13
+ * @param el - The element taking a hold on the store; {@link releasePane} drops it.
14
+ * @param plugins - Registered plugin ids; they apply only when this call creates the store — the set is fixed per pane.
15
+ * @returns The pane's store.
16
+ */
17
+ export function acquirePane(id, el, plugins) {
18
+ let e = panes.get(id);
19
+ if (!e) {
20
+ e = { store: createWorkbook({ plugins: pluginsFromIds(plugins) }), users: new Set(), plugins: plugins.join(' ') };
21
+ panes.set(id, e);
22
+ }
23
+ else if (plugins.length && plugins.join(' ') !== e.plugins) {
24
+ console.warn(spMessage('SP-3011', `sheetpane: pane "${id}" already runs plugins "${e.plugins}"; "${plugins.join(' ')}" on a later element is ignored (the set is fixed per pane)`));
25
+ }
26
+ e.users.add(el);
27
+ return e.store;
28
+ }
29
+ /**
30
+ * Drops an element's hold on a pane; the store goes when the last element releases it.
31
+ * @param id - The pane id.
32
+ * @param el - The element that acquired it.
33
+ */
34
+ export function releasePane(id, el) {
35
+ const e = panes.get(id);
36
+ if (!e)
37
+ return;
38
+ e.users.delete(el);
39
+ if (!e.users.size)
40
+ panes.delete(id);
41
+ }
42
+ /**
43
+ * The live store of a pane, if any element holds it — for a host or a test to read or drive.
44
+ * @param id - The `pane` attribute's value.
45
+ * @returns The pane's store, or undefined when no connected element names that pane.
46
+ * @example
47
+ * ```ts
48
+ * import { paneStore } from '@sheetpane/grid';
49
+ * const book = paneStore('q3');
50
+ * if (book) console.log(book.changeCount, book.getErrors().length);
51
+ * ```
52
+ */
53
+ export function paneStore(id) {
54
+ return panes.get(id)?.store;
55
+ }
56
+ /** Elements attached to a store, in connection order: events nobody owns go out on the first sheet, else the first element. */
57
+ export function attach(store, el) {
58
+ const l = attached.get(store) ?? [];
59
+ if (!l.includes(el))
60
+ l.push(el);
61
+ attached.set(store, l);
62
+ }
63
+ export function detach(store, el) {
64
+ const l = attached.get(store);
65
+ if (l)
66
+ attached.set(store, l.filter((x) => x !== el));
67
+ }
68
+ export function isPrimary(store, el) {
69
+ const l = attached.get(store) ?? [];
70
+ const first = l.find((x) => x.localName === 'sheetpane-excel') ?? l[0];
71
+ return first === el;
72
+ }
73
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/pane/registry.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,6EAA6E;AAC7E,yEAAyE;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAsB,MAAM,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js';
4
+ import type { Severity } from './types.js';
5
+ /** One rule, as plain JSON: for a column (by title) or for a cell or range (rules file). */
6
+ export interface ColumnRule {
7
+ required?: boolean;
8
+ type?: 'text' | 'number' | 'integer' | 'date' | 'boolean';
9
+ /** A number, or for `type: 'date'` an ISO date (`2026-01-31`) or a serial. */
10
+ min?: number | string;
11
+ max?: number | string;
12
+ minLength?: number;
13
+ maxLength?: number;
14
+ /** A regular expression source, tested against the cell's text (values over 10,000 characters are not tested). */
15
+ pattern?: string;
16
+ /** The valid values. */
17
+ oneOf?: readonly (string | number | boolean)[];
18
+ /** Values that are never valid (W-33). */
19
+ noneOf?: readonly (string | number | boolean)[];
20
+ /** The one valid value (W-33); a blank cell fails it. */
21
+ equals?: string | number | boolean;
22
+ unique?: boolean;
23
+ /** Replaces the generated message. */
24
+ message?: string;
25
+ /** Free text for whoever maintains the rules; never shown as the message (W-33). */
26
+ note?: string;
27
+ severity?: Severity;
28
+ onInvalid?: OnInvalid;
29
+ }
30
+ /** Column rules keyed by column title (or, in a rules file's `cells`, by A1 cell or range). */
31
+ export type ColumnRules = Readonly<Record<string, ColumnRule>>;
32
+ /** What a failing rule does on commit: `flag` stores the value and adds an error; `block` refuses it. */
33
+ export type OnInvalid = 'flag' | 'block';
34
+ /** When a rule runs: while typing (`input`), on commit, or over every row when a file loads. */
35
+ export type RulePhase = 'input' | 'commit' | 'load';
36
+ /** The rules file (W-33), version 1: rules per sheet (`"*"` for every sheet), by column title and by cell or range. */
37
+ export interface RulesDocument {
38
+ $schema?: string;
39
+ version: 1;
40
+ sheets: Readonly<Record<string, {
41
+ headerRow?: number;
42
+ columns?: ColumnRules;
43
+ cells?: ColumnRules;
44
+ }>>;
45
+ }
46
+ /** What `validate(ctx, signal)` is told (verdict decision 6). */
47
+ export interface RuleContext {
48
+ phase: RulePhase;
49
+ sheet: string;
50
+ ref: string;
51
+ /** Zero-based. */
52
+ row: number;
53
+ column: {
54
+ index: number;
55
+ letter: string;
56
+ header: string;
57
+ };
58
+ value: Cell;
59
+ was: Cell;
60
+ original: Cell;
61
+ /** The row's values keyed by column title. */
62
+ rowValues: Readonly<Record<string, Cell>>;
63
+ }
64
+ /** A failure a host `validate` function reports; `null` or `undefined` means the cell passes. */
65
+ export interface RuleResult {
66
+ severity?: Severity;
67
+ message: string;
68
+ expected?: string;
69
+ }
70
+ /** The host's own check for each cell of a titled column; `signal` aborts when a newer check of the cell starts. */
71
+ export type ValidateFn = (ctx: RuleContext, signal: AbortSignal) => RuleResult | null | undefined | Promise<RuleResult | null | undefined>;
72
+ /** The pane's column rules (SR-GRID decision 22): set by the element or `store.setColumnRules()`. */
73
+ export interface ColumnRulesConfig {
74
+ columns?: ColumnRules;
75
+ validate?: ValidateFn | undefined;
76
+ /** The default for every rule and for `validate` (decision 9: `flag`). */
77
+ onInvalid?: OnInvalid;
78
+ /** The row holding the titles, 1-based (decision 11: 1). A rules file's sheet may set its own. */
79
+ headerRow?: number;
80
+ /** A rules file (W-33), checked as given: its problems become `note` errors, never a throw. */
81
+ document?: unknown;
82
+ }
83
+ /** A failure, before it becomes an error. */
84
+ export interface RuleOutcome {
85
+ severity: Severity;
86
+ message: string;
87
+ expected: string;
88
+ onInvalid: OnInvalid;
89
+ }
90
+ /** What the rules need from the store (kept narrow, so this module stays testable). */
91
+ export interface RulesHost {
92
+ bookSheets(): readonly {
93
+ name: string;
94
+ rows: readonly (readonly Cell[])[];
95
+ }[] | undefined;
96
+ date1904(): boolean;
97
+ value(sheet: string, ref: string): Cell;
98
+ /** The same by position, without building a ref (the load phase reads every cell). */
99
+ valueAt(sheet: string, row: number, col: number): Cell;
100
+ text(sheet: string, ref: string): string;
101
+ original(sheet: string, ref: string): {
102
+ value: Cell;
103
+ text: string;
104
+ };
105
+ /** Re-run `validate` for these sheets (findings changed). */
106
+ revalidate(sheets: string[]): void;
107
+ /** Drop host errors no longer produced (rules changed, decision 12). */
108
+ prune(providerId: string, produced: ReadonlySet<string>): void;
109
+ /** The load phase's progress changed. */
110
+ progress(): void;
111
+ }
112
+ export declare const RULES_PROVIDER_ID = "host-rules";
113
+ /** The error `type` of a column rule's finding. */
114
+ export declare const RULE_TYPE = "column-rule";
115
+ /** The error `type` of a rules file's cell rule finding. */
116
+ export declare const CELL_RULE_TYPE = "cell-rule";
117
+ /** One problem found in a rules file: a `note`, never a throw; `code` is its SP code (W-40). */
118
+ export interface DocProblem {
119
+ code: SpCode;
120
+ sheet?: string;
121
+ found: string;
122
+ message: string;
123
+ }
124
+ interface DocSheet {
125
+ headerRow?: number;
126
+ columns: Record<string, ColumnRule>;
127
+ cells: Record<string, ColumnRule>;
128
+ }
129
+ export declare class HostRules {
130
+ private readonly host;
131
+ private cfg;
132
+ /** The element's patterns, compiled (an invalid one throws at `configure`). */
133
+ private patterns;
134
+ /** The rules file, checked: per sheet (`*` and named), and the problems found in it. */
135
+ private doc;
136
+ private sheetRules;
137
+ /** Per sheet, per column: the rule its title resolves to (resolved once per load, not per cell). */
138
+ private colRules;
139
+ /** Per sheet: title (normalised) → column; the titles by column. */
140
+ private headers;
141
+ private notes;
142
+ /** Per sheet, per cell: the column rule's failure. */
143
+ private json;
144
+ /** Per sheet, per cell: a cell rule's failure (rules file). */
145
+ private cellJson;
146
+ /** Per sheet, per cell: the function's latest result. */
147
+ private fn;
148
+ /** Per sheet and column: normalised value → its row, or its rows once it repeats (for `unique`; a Set per distinct value would be 250,000 Sets). */
149
+ private uniq;
150
+ private inflight;
151
+ private gen;
152
+ /** The load phase: rows checked of rows to check; undefined when idle. */
153
+ progress: {
154
+ done: number;
155
+ total: number;
156
+ } | undefined;
157
+ readonly provider: Plugin;
158
+ constructor(host: RulesHost);
159
+ get active(): boolean;
160
+ get config(): Readonly<ColumnRulesConfig>;
161
+ /** Whether a rules file is in force (its errors are labelled "Rules file"). */
162
+ get hasDocument(): boolean;
163
+ /** Rules may change after a workbook is loaded (decision 12): every row is checked again and stale host errors go. */
164
+ configure(c: ColumnRulesConfig): void;
165
+ /** A new workbook: forget everything and check it (`load`). */
166
+ reset(): void;
167
+ private drafts;
168
+ private compileSheet;
169
+ private readHeaders;
170
+ /** A `note` error about the rules themselves; it carries its SP code (W-40). */
171
+ private note;
172
+ /** The rule for a title on a sheet (matched trimmed and case-insensitive; an exact title wins). */
173
+ private ruleFor;
174
+ private headerRow;
175
+ /** The column's title on a sheet, when the column is the first of its title. */
176
+ private headerAt;
177
+ private context;
178
+ /** A rule's first failing constraint for a value, or null. `label` names what is checked (a column's title or a cell). */
179
+ /** A rule's first failing constraint for a value, or null. `label` names what is checked (a column's title or a cell).
180
+ * `at` is where the value sits (its shown text is read only when a constraint needs it — reading fills the store's
181
+ * text cache) or, for a draft, the text itself. No closure is made per call: the load phase checks a million cells. */
182
+ private checkRule;
183
+ private fail;
184
+ private shownText;
185
+ private trimmed;
186
+ /** The column rule's verdict for a cell, or null. `at` is the cell's place, or a draft's text. */
187
+ private checkJson;
188
+ /** The first failing cell rule (rules file) for a cell, or null. */
189
+ private checkCells;
190
+ private dateMs;
191
+ private boundMs;
192
+ private toDraft;
193
+ /** Is this cell a data cell in a titled column of a sheet with rules? */
194
+ private inScope;
195
+ private inCellRule;
196
+ private setJson;
197
+ private setCell;
198
+ /** Calls the host's function for one cell; a sync result lands now, an async one later (unless superseded). */
199
+ private callFn;
200
+ /** `load` (decision 7): every row of every sheet with titles, then every cell a cell rule names, in time slices; progress is shown. */
201
+ private loadPhase;
202
+ /** `commit` (decision 7): cells changed by an edit, a paste or undo. */
203
+ touch(cells: readonly {
204
+ sheet: string;
205
+ ref: string;
206
+ }[]): void;
207
+ private reindexUnique;
208
+ /** `input` (decision 7): the draft checked as typed — nothing is stored. */
209
+ checkInput(sheet: string, ref: string, value: Cell, text: string, signal: AbortSignal): Promise<RuleOutcome | null>;
210
+ /** The `block` check at commit (decision 9): a failing rule set to block refuses the value. Async results can only flag. */
211
+ blocked(sheet: string, ref: string, value: Cell, text: string): RuleOutcome | null;
212
+ }
213
+ /**
214
+ * Checks a rules file (W-33) by hand — no schema library at run time. Every problem
215
+ * is named (an unknown key, version or word, a bad ref or pattern) and the rest
216
+ * still applies; nothing throws (SR-GRID decision 22d).
217
+ * @param doc - The parsed JSON, as given.
218
+ * @returns The usable rules per sheet, and one problem per thing wrong.
219
+ */
220
+ export declare function checkDocument(doc: unknown): {
221
+ sheets: Map<string, DocSheet>;
222
+ problems: DocProblem[];
223
+ };
224
+ /**
225
+ * A rule in words, for an error's `expected`: "a whole number from 18 to 99", "one of Active, Inactive".
226
+ * @param r - The rule.
227
+ * @returns The rule as a phrase.
228
+ */
229
+ export declare function describeRule(r: ColumnRule): string;
230
+ export {};
231
+ //# sourceMappingURL=rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/pane/rules.ts"],"names":[],"mappings":"AAUA,OAAO,EAA6E,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3H,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,KAAK,EAAc,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,4FAA4F;AAC5F,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;IAC1D,8EAA8E;IAC9E,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kHAAkH;IAClH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wBAAwB;IACxB,KAAK,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;IAC/C,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