@svgrid/grid 1.2.22 → 1.2.23

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 (190) hide show
  1. package/dist/GridFooter.svelte +34 -20
  2. package/dist/GridFooter.svelte.d.ts +8 -0
  3. package/dist/SvAutoComplete.svelte +100 -0
  4. package/dist/SvAutoComplete.svelte.d.ts +16 -0
  5. package/dist/SvButton.svelte +97 -0
  6. package/dist/SvButton.svelte.d.ts +23 -0
  7. package/dist/SvCalendar.svelte +669 -0
  8. package/dist/SvCalendar.svelte.d.ts +70 -0
  9. package/dist/SvCheckBox.svelte +81 -0
  10. package/dist/SvCheckBox.svelte.d.ts +19 -0
  11. package/dist/SvColorInput.svelte +187 -0
  12. package/dist/SvColorInput.svelte.d.ts +15 -0
  13. package/dist/SvComboBox.svelte +130 -0
  14. package/dist/SvComboBox.svelte.d.ts +15 -0
  15. package/dist/SvCountryInput.svelte +123 -0
  16. package/dist/SvCountryInput.svelte.d.ts +14 -0
  17. package/dist/SvDateTimePicker.svelte +322 -0
  18. package/dist/SvDateTimePicker.svelte.d.ts +37 -0
  19. package/dist/SvDropDownList.svelte +143 -0
  20. package/dist/SvDropDownList.svelte.d.ts +15 -0
  21. package/dist/SvForm.svelte +147 -0
  22. package/dist/SvForm.svelte.d.ts +29 -0
  23. package/dist/SvGauge.svelte +99 -0
  24. package/dist/SvGauge.svelte.d.ts +31 -0
  25. package/dist/SvGrid.controller.svelte.d.ts +16 -2
  26. package/dist/SvGrid.controller.svelte.js +63 -8
  27. package/dist/SvGrid.css +84 -31
  28. package/dist/SvGrid.helpers.d.ts +4 -0
  29. package/dist/SvGrid.helpers.js +40 -12
  30. package/dist/SvGrid.svelte +84 -5
  31. package/dist/SvGrid.types.d.ts +36 -0
  32. package/dist/SvGridDropdown.svelte +16 -30
  33. package/dist/SvGridDropdown.svelte.d.ts +4 -0
  34. package/dist/SvListBox.svelte +122 -0
  35. package/dist/SvListBox.svelte.d.ts +19 -0
  36. package/dist/SvMaskedInput.svelte +0 -0
  37. package/dist/SvMaskedInput.svelte.d.ts +15 -0
  38. package/dist/SvNumberInput.svelte +0 -0
  39. package/dist/SvNumberInput.svelte.d.ts +22 -0
  40. package/dist/SvPasswordInput.svelte +110 -0
  41. package/dist/SvPasswordInput.svelte.d.ts +22 -0
  42. package/dist/SvPhoneInput.svelte +0 -0
  43. package/dist/SvPhoneInput.svelte.d.ts +19 -0
  44. package/dist/SvRadioGroup.svelte +108 -0
  45. package/dist/SvRadioGroup.svelte.d.ts +23 -0
  46. package/dist/SvRating.svelte +111 -0
  47. package/dist/SvRating.svelte.d.ts +20 -0
  48. package/dist/SvRepeatButton.svelte +89 -0
  49. package/dist/SvRepeatButton.svelte.d.ts +21 -0
  50. package/dist/SvSlider.svelte +182 -0
  51. package/dist/SvSlider.svelte.d.ts +25 -0
  52. package/dist/SvSwitchButton.svelte +94 -0
  53. package/dist/SvSwitchButton.svelte.d.ts +19 -0
  54. package/dist/SvTabs.svelte +122 -0
  55. package/dist/SvTabs.svelte.d.ts +26 -0
  56. package/dist/SvTagsInput.svelte +81 -0
  57. package/dist/SvTagsInput.svelte.d.ts +19 -0
  58. package/dist/SvTimePicker.svelte +359 -0
  59. package/dist/SvTimePicker.svelte.d.ts +27 -0
  60. package/dist/SvToggleButton.svelte +57 -0
  61. package/dist/SvToggleButton.svelte.d.ts +16 -0
  62. package/dist/SvTree.svelte +210 -0
  63. package/dist/SvTree.svelte.d.ts +29 -0
  64. package/dist/build-api.js +78 -1
  65. package/dist/cdn/svgrid.js +10022 -5904
  66. package/dist/cdn/svgrid.svelte-external.js +8531 -4429
  67. package/dist/cell-render.d.ts +4 -0
  68. package/dist/cell-render.js +35 -1
  69. package/dist/clipboard.js +19 -1
  70. package/dist/collaboration.d.ts +2 -0
  71. package/dist/collaboration.js +4 -0
  72. package/dist/core.d.ts +22 -1
  73. package/dist/countries.d.ts +15 -0
  74. package/dist/countries.js +61 -0
  75. package/dist/datetime/date-core.d.ts +88 -0
  76. package/dist/datetime/date-core.js +165 -0
  77. package/dist/datetime/date-format.d.ts +39 -0
  78. package/dist/datetime/date-format.js +371 -0
  79. package/dist/datetime/date-restrict.d.ts +23 -0
  80. package/dist/datetime/date-restrict.js +50 -0
  81. package/dist/datetime/date-selection.d.ts +25 -0
  82. package/dist/datetime/date-selection.js +94 -0
  83. package/dist/datetime/mask.d.ts +21 -0
  84. package/dist/datetime/mask.js +90 -0
  85. package/dist/editing.d.ts +1 -1
  86. package/dist/editing.js +7 -0
  87. package/dist/editors/cell-editors.d.ts +2 -2
  88. package/dist/editors/cell-editors.js +3 -1
  89. package/dist/export-format.d.ts +178 -0
  90. package/dist/export-format.js +419 -0
  91. package/dist/hyperformula-adapter.d.ts +4 -0
  92. package/dist/hyperformula-adapter.js +15 -6
  93. package/dist/index.d.ts +36 -0
  94. package/dist/index.js +41 -0
  95. package/dist/list-option.d.ts +10 -0
  96. package/dist/list-option.js +7 -0
  97. package/dist/menus.js +18 -2
  98. package/dist/popover.d.ts +48 -0
  99. package/dist/popover.js +65 -0
  100. package/dist/row-resize.d.ts +4 -4
  101. package/dist/row-resize.js +8 -5
  102. package/dist/selection.d.ts +6 -0
  103. package/dist/selection.js +31 -5
  104. package/dist/server-data-source.d.ts +43 -0
  105. package/dist/server-data-source.js +100 -0
  106. package/dist/sparkline.js +8 -4
  107. package/dist/svgrid-wrapper.types.d.ts +26 -1
  108. package/package.json +6 -1
  109. package/src/GridFooter.svelte +34 -20
  110. package/src/SvAutoComplete.svelte +100 -0
  111. package/src/SvButton.svelte +97 -0
  112. package/src/SvCalendar.svelte +669 -0
  113. package/src/SvCalendar.test.ts +211 -0
  114. package/src/SvCheckBox.svelte +81 -0
  115. package/src/SvColorInput.svelte +187 -0
  116. package/src/SvComboBox.svelte +130 -0
  117. package/src/SvCountryInput.svelte +123 -0
  118. package/src/SvDateTimePicker.svelte +322 -0
  119. package/src/SvDateTimePicker.test.ts +136 -0
  120. package/src/SvDropDownList.svelte +143 -0
  121. package/src/SvForm.svelte +147 -0
  122. package/src/SvGauge.svelte +99 -0
  123. package/src/SvGrid.controller.svelte.ts +74 -8
  124. package/src/SvGrid.css +84 -31
  125. package/src/SvGrid.helpers.ts +41 -12
  126. package/src/SvGrid.svelte +84 -5
  127. package/src/SvGrid.types.ts +33 -0
  128. package/src/SvGridDropdown.svelte +16 -30
  129. package/src/SvListBox.svelte +122 -0
  130. package/src/SvMaskedInput.svelte +0 -0
  131. package/src/SvNumberInput.svelte +0 -0
  132. package/src/SvPasswordInput.svelte +110 -0
  133. package/src/SvPhoneInput.svelte +0 -0
  134. package/src/SvRadioGroup.svelte +108 -0
  135. package/src/SvRating.svelte +111 -0
  136. package/src/SvRepeatButton.svelte +89 -0
  137. package/src/SvSlider.svelte +182 -0
  138. package/src/SvSwitchButton.svelte +94 -0
  139. package/src/SvTabs.svelte +122 -0
  140. package/src/SvTagsInput.svelte +81 -0
  141. package/src/SvTimePicker.svelte +359 -0
  142. package/src/SvTimePicker.test.ts +98 -0
  143. package/src/SvToggleButton.svelte +57 -0
  144. package/src/SvTree.svelte +210 -0
  145. package/src/build-api.ts +115 -0
  146. package/src/cell-render.test.ts +38 -0
  147. package/src/cell-render.ts +43 -0
  148. package/src/clipboard.test.ts +18 -0
  149. package/src/clipboard.ts +24 -1
  150. package/src/collaboration.test.ts +30 -0
  151. package/src/collaboration.ts +6 -0
  152. package/src/core.ts +27 -3
  153. package/src/countries.ts +71 -0
  154. package/src/datetime/date-core.test.ts +217 -0
  155. package/src/datetime/date-core.ts +204 -0
  156. package/src/datetime/date-format.test.ts +121 -0
  157. package/src/datetime/date-format.ts +317 -0
  158. package/src/datetime/date-restrict.ts +60 -0
  159. package/src/datetime/date-selection.test.ts +129 -0
  160. package/src/datetime/date-selection.ts +137 -0
  161. package/src/datetime/mask.test.ts +36 -0
  162. package/src/datetime/mask.ts +84 -0
  163. package/src/editing.test.ts +22 -0
  164. package/src/editing.ts +7 -1
  165. package/src/editors/cell-editors.ts +7 -1
  166. package/src/export-data-api.test.ts +126 -0
  167. package/src/export-format.test.ts +107 -0
  168. package/src/export-format.ts +598 -0
  169. package/src/hyperformula-adapter.test.ts +35 -1
  170. package/src/hyperformula-adapter.ts +18 -6
  171. package/src/index.ts +71 -0
  172. package/src/list-option.ts +15 -0
  173. package/src/menus.ts +21 -2
  174. package/src/popover.ts +79 -0
  175. package/src/row-resize.test.ts +25 -0
  176. package/src/row-resize.ts +8 -5
  177. package/src/selection.test.ts +36 -4
  178. package/src/selection.ts +30 -9
  179. package/src/server-data-source.test.ts +201 -0
  180. package/src/server-data-source.ts +148 -0
  181. package/src/sparkline.test.ts +9 -0
  182. package/src/sparkline.ts +9 -4
  183. package/src/svgrid-wrapper.types.ts +28 -1
  184. package/src/svgrid.behavior.test.ts +27 -0
  185. package/src/svgrid.new-features.wrapper.test.ts +27 -1
  186. package/src/ui-buttons.test.ts +105 -0
  187. package/src/ui-composite.test.ts +89 -0
  188. package/src/ui-inputs.test.ts +92 -0
  189. package/src/ui-range.test.ts +61 -0
  190. package/src/ui-selection.test.ts +106 -0
@@ -0,0 +1,29 @@
1
+ export type TreeNode = {
2
+ id: string;
3
+ label: string;
4
+ children?: TreeNode[];
5
+ disabled?: boolean;
6
+ };
7
+ /**
8
+ * SvTree - a WAI-ARIA tree view. Expand/collapse, single-select highlight, and
9
+ * optional cascading tri-state checkboxes. Parity: Smart `smart-tree`. Keyboard:
10
+ * up/down move, left collapse/parent, right expand/child, Enter/Space select.
11
+ * The visible tree is flattened so roving-focus keyboard nav stays simple.
12
+ */
13
+ type Props = {
14
+ nodes: ReadonlyArray<TreeNode>;
15
+ /** Selected node id (single-select highlight). */
16
+ selected?: string | null;
17
+ onSelect?: (id: string) => void;
18
+ /** Initially/controlled expanded ids. */
19
+ expandedIds?: string[];
20
+ onToggle?: (id: string, expanded: boolean) => void;
21
+ /** Show cascading checkboxes; `checked` is the set of checked ids. */
22
+ checkable?: boolean;
23
+ checked?: string[];
24
+ onCheck?: (ids: string[]) => void;
25
+ ariaLabel?: string;
26
+ };
27
+ declare const SvTree: import("svelte").Component<Props, {}, "">;
28
+ type SvTree = ReturnType<typeof SvTree>;
29
+ export default SvTree;
package/dist/build-api.js CHANGED
@@ -1,8 +1,35 @@
1
1
  import "./sv-grid-scrollbar";
2
- import { isGroupRow, columnDefMatchesId, } from "./cell-values";
2
+ import { projectGridRows, serializeDelimited, serializeJson, serializeMarkdown, downloadTextFile, copyTextToClipboard, } from "./export-format";
3
+ import { isGroupRow, getColumnAlign, columnDefMatchesId, } from "./cell-values";
3
4
  export function createGridApi(ctx) {
4
5
  function buildApi() {
5
6
  const findColumn = (columnId) => ctx.grid.getAllColumns().find((column) => column.id === columnId);
7
+ // --- Free data export (CSV / TSV / JSON + clipboard) helpers ----------
8
+ // Snapshot the VISIBLE columns (field + label + format + align) so the
9
+ // exporter reproduces on-screen values. Mirrors getColumns()'s visible set.
10
+ const exportColumns = () => ctx.allColumns
11
+ .map((c) => ({
12
+ field: c.columnDef.field,
13
+ header: typeof c.columnDef.header === "string" ? c.columnDef.header : c.id,
14
+ format: c.columnDef.format,
15
+ align: getColumnAlign(c),
16
+ }))
17
+ .filter((c) => !!c.field);
18
+ // Rows for the requested scope: current view / checked / full dataset.
19
+ const exportScopeRows = (scope) => {
20
+ if (scope === "all")
21
+ return ctx.internalData;
22
+ const out = [];
23
+ for (const row of ctx.allRows) {
24
+ if (isGroupRow(row))
25
+ continue;
26
+ if (scope === "selected" && !ctx.rowSelectionState[row.id])
27
+ continue;
28
+ out.push(row.original);
29
+ }
30
+ return out;
31
+ };
32
+ const projectForExport = (scope, columns, rawValues) => projectGridRows(exportScopeRows(scope), exportColumns(), { columns, rawValues });
6
33
  return {
7
34
  getCellValue(rowIndex, columnId) {
8
35
  const row = ctx.internalData[rowIndex];
@@ -281,6 +308,12 @@ export function createGridApi(ctx) {
281
308
  ? c.columnDef.header
282
309
  : c.id,
283
310
  visible,
311
+ // Surface the format + alignment so exporters can reproduce the
312
+ // on-screen display value (currency symbol, date pattern, etc.)
313
+ // instead of dumping raw values. `getColumnAlign` applies the same
314
+ // editorType-based default the body uses.
315
+ format: c.columnDef.format,
316
+ align: getColumnAlign(c),
284
317
  });
285
318
  // Visible columns first, in their current visual order...
286
319
  const out = ctx.allColumns.map((c) => describe(c, true));
@@ -294,6 +327,50 @@ export function createGridApi(ctx) {
294
327
  }
295
328
  return out;
296
329
  },
330
+ // ---- Free data export (CSV / TSV / JSON + clipboard) -----------------
331
+ async exportCsv(options = {}) {
332
+ const { records, fields } = projectForExport(options.rows ?? "displayed", options.columns, options.rawValues);
333
+ const text = await serializeDelimited(records, fields, {
334
+ csv: { delimiter: ",", bom: options.bom ?? true },
335
+ signal: options.signal,
336
+ onProgress: options.onProgress,
337
+ });
338
+ if (options.download !== false)
339
+ downloadTextFile(text, `${options.filename ?? "grid"}.csv`, "text/csv;charset=utf-8");
340
+ return text;
341
+ },
342
+ async exportTsv(options = {}) {
343
+ const { records, fields } = projectForExport(options.rows ?? "displayed", options.columns, options.rawValues);
344
+ const text = await serializeDelimited(records, fields, {
345
+ csv: { delimiter: "\t", bom: options.bom ?? true },
346
+ signal: options.signal,
347
+ onProgress: options.onProgress,
348
+ });
349
+ if (options.download !== false)
350
+ downloadTextFile(text, `${options.filename ?? "grid"}.tsv`, "text/tab-separated-values;charset=utf-8");
351
+ return text;
352
+ },
353
+ async exportJson(options = {}) {
354
+ const { records, fields } = projectForExport(options.rows ?? "displayed", options.columns, options.rawValues);
355
+ const text = await serializeJson(records, fields, {
356
+ signal: options.signal,
357
+ onProgress: options.onProgress,
358
+ });
359
+ if (options.download !== false)
360
+ downloadTextFile(text, `${options.filename ?? "grid"}.json`, "application/json");
361
+ return text;
362
+ },
363
+ async copyToClipboard(options = {}) {
364
+ const { records, fields, align } = projectForExport(options.rows ?? "displayed", options.columns, options.rawValues);
365
+ const format = options.format ?? "tsv";
366
+ const text = format === "markdown"
367
+ ? await serializeMarkdown(records, fields, { align })
368
+ : await serializeDelimited(records, fields, {
369
+ csv: { delimiter: format === "csv" ? "," : "\t", bom: false },
370
+ });
371
+ await copyTextToClipboard(text);
372
+ return text;
373
+ },
297
374
  clearRowSelection() {
298
375
  // Wipe the internal selection map AND emit the change so any
299
376
  // consumer holding a derived `selectedRows` resets too.