@svgrid/grid 1.2.22 → 1.2.24

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 (263) hide show
  1. package/dist/GridFooter.svelte +34 -20
  2. package/dist/GridFooter.svelte.d.ts +8 -0
  3. package/dist/SvAutoComplete.svelte +89 -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 +409 -0
  8. package/dist/SvCalendar.svelte.d.ts +52 -0
  9. package/dist/SvCheckBox.svelte +82 -0
  10. package/dist/SvCheckBox.svelte.d.ts +19 -0
  11. package/dist/SvColorInput.svelte +160 -0
  12. package/dist/SvColorInput.svelte.d.ts +15 -0
  13. package/dist/SvComboBox.svelte +108 -0
  14. package/dist/SvComboBox.svelte.d.ts +15 -0
  15. package/dist/SvCountryInput.svelte +125 -0
  16. package/dist/SvCountryInput.svelte.d.ts +14 -0
  17. package/dist/SvDateTimePicker.svelte +265 -0
  18. package/dist/SvDateTimePicker.svelte.d.ts +38 -0
  19. package/dist/SvDropDownList.svelte +120 -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 +97 -0
  24. package/dist/SvGauge.svelte.d.ts +26 -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 +89 -0
  35. package/dist/SvListBox.svelte.d.ts +22 -0
  36. package/dist/SvMaskedInput.svelte +66 -0
  37. package/dist/SvMaskedInput.svelte.d.ts +15 -0
  38. package/dist/SvNumberInput.svelte +116 -0
  39. package/dist/SvNumberInput.svelte.d.ts +18 -0
  40. package/dist/SvPasswordInput.svelte +100 -0
  41. package/dist/SvPasswordInput.svelte.d.ts +18 -0
  42. package/dist/SvPhoneInput.svelte +87 -0
  43. package/dist/SvPhoneInput.svelte.d.ts +19 -0
  44. package/dist/SvRadioGroup.svelte +85 -0
  45. package/dist/SvRadioGroup.svelte.d.ts +20 -0
  46. package/dist/SvRating.svelte +91 -0
  47. package/dist/SvRating.svelte.d.ts +18 -0
  48. package/dist/SvRepeatButton.svelte +89 -0
  49. package/dist/SvRepeatButton.svelte.d.ts +21 -0
  50. package/dist/SvSlider.svelte +155 -0
  51. package/dist/SvSlider.svelte.d.ts +20 -0
  52. package/dist/SvSwitchButton.svelte +87 -0
  53. package/dist/SvSwitchButton.svelte.d.ts +14 -0
  54. package/dist/SvTabs.svelte +109 -0
  55. package/dist/SvTabs.svelte.d.ts +26 -0
  56. package/dist/SvTagsInput.svelte +70 -0
  57. package/dist/SvTagsInput.svelte.d.ts +14 -0
  58. package/dist/SvTimePicker.svelte +201 -0
  59. package/dist/SvTimePicker.svelte.d.ts +30 -0
  60. package/dist/SvToggleButton.svelte +57 -0
  61. package/dist/SvToggleButton.svelte.d.ts +16 -0
  62. package/dist/SvTree.svelte +131 -0
  63. package/dist/SvTree.svelte.d.ts +27 -0
  64. package/dist/build-api.js +78 -1
  65. package/dist/cdn/svgrid.js +11674 -5907
  66. package/dist/cdn/svgrid.svelte-external.js +10436 -4671
  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/createAutocomplete.svelte.d.ts +77 -0
  76. package/dist/createAutocomplete.svelte.js +100 -0
  77. package/dist/createCalendar.svelte.d.ts +192 -0
  78. package/dist/createCalendar.svelte.js +402 -0
  79. package/dist/createCheckbox.svelte.d.ts +45 -0
  80. package/dist/createCheckbox.svelte.js +26 -0
  81. package/dist/createColorInput.svelte.d.ts +67 -0
  82. package/dist/createColorInput.svelte.js +100 -0
  83. package/dist/createCombobox.svelte.d.ts +102 -0
  84. package/dist/createCombobox.svelte.js +171 -0
  85. package/dist/createCountryInput.svelte.d.ts +86 -0
  86. package/dist/createCountryInput.svelte.js +126 -0
  87. package/dist/createDateTimePicker.svelte.d.ts +83 -0
  88. package/dist/createDateTimePicker.svelte.js +202 -0
  89. package/dist/createDropdownList.svelte.d.ts +78 -0
  90. package/dist/createDropdownList.svelte.js +117 -0
  91. package/dist/createGauge.svelte.d.ts +56 -0
  92. package/dist/createGauge.svelte.js +49 -0
  93. package/dist/createListbox.svelte.d.ts +79 -0
  94. package/dist/createListbox.svelte.js +117 -0
  95. package/dist/createMaskedInput.svelte.d.ts +30 -0
  96. package/dist/createMaskedInput.svelte.js +62 -0
  97. package/dist/createNumberInput.svelte.d.ts +72 -0
  98. package/dist/createNumberInput.svelte.js +167 -0
  99. package/dist/createPasswordInput.svelte.d.ts +60 -0
  100. package/dist/createPasswordInput.svelte.js +72 -0
  101. package/dist/createPhoneInput.svelte.d.ts +46 -0
  102. package/dist/createPhoneInput.svelte.js +105 -0
  103. package/dist/createRadioGroup.svelte.d.ts +64 -0
  104. package/dist/createRadioGroup.svelte.js +73 -0
  105. package/dist/createRating.svelte.d.ts +70 -0
  106. package/dist/createRating.svelte.js +85 -0
  107. package/dist/createSlider.svelte.d.ts +71 -0
  108. package/dist/createSlider.svelte.js +123 -0
  109. package/dist/createSwitch.svelte.d.ts +43 -0
  110. package/dist/createSwitch.svelte.js +41 -0
  111. package/dist/createTabs.svelte.d.ts +78 -0
  112. package/dist/createTabs.svelte.js +92 -0
  113. package/dist/createTagsInput.svelte.d.ts +65 -0
  114. package/dist/createTagsInput.svelte.js +93 -0
  115. package/dist/createTimePicker.svelte.d.ts +106 -0
  116. package/dist/createTimePicker.svelte.js +248 -0
  117. package/dist/createToggle.svelte.d.ts +43 -0
  118. package/dist/createToggle.svelte.js +39 -0
  119. package/dist/createTree.svelte.d.ts +96 -0
  120. package/dist/createTree.svelte.js +194 -0
  121. package/dist/datetime/date-core.d.ts +88 -0
  122. package/dist/datetime/date-core.js +165 -0
  123. package/dist/datetime/date-format.d.ts +39 -0
  124. package/dist/datetime/date-format.js +371 -0
  125. package/dist/datetime/date-restrict.d.ts +23 -0
  126. package/dist/datetime/date-restrict.js +50 -0
  127. package/dist/datetime/date-selection.d.ts +25 -0
  128. package/dist/datetime/date-selection.js +94 -0
  129. package/dist/datetime/mask.d.ts +21 -0
  130. package/dist/datetime/mask.js +90 -0
  131. package/dist/editing.d.ts +1 -1
  132. package/dist/editing.js +7 -0
  133. package/dist/editor-contract.d.ts +48 -0
  134. package/dist/editor-contract.js +26 -0
  135. package/dist/editors/cell-editors.d.ts +2 -2
  136. package/dist/editors/cell-editors.js +3 -1
  137. package/dist/export-format.d.ts +178 -0
  138. package/dist/export-format.js +419 -0
  139. package/dist/hyperformula-adapter.d.ts +4 -0
  140. package/dist/hyperformula-adapter.js +15 -6
  141. package/dist/index.d.ts +60 -0
  142. package/dist/index.js +72 -0
  143. package/dist/list-option.d.ts +10 -0
  144. package/dist/list-option.js +7 -0
  145. package/dist/menus.js +18 -2
  146. package/dist/popover.d.ts +48 -0
  147. package/dist/popover.js +65 -0
  148. package/dist/row-resize.d.ts +4 -4
  149. package/dist/row-resize.js +8 -5
  150. package/dist/selection.d.ts +6 -0
  151. package/dist/selection.js +31 -5
  152. package/dist/server-data-source.d.ts +43 -0
  153. package/dist/server-data-source.js +100 -0
  154. package/dist/sparkline.js +8 -4
  155. package/dist/svgrid-wrapper.types.d.ts +26 -1
  156. package/package.json +6 -1
  157. package/src/GridFooter.svelte +34 -20
  158. package/src/SvAutoComplete.svelte +89 -0
  159. package/src/SvButton.svelte +97 -0
  160. package/src/SvCalendar.svelte +409 -0
  161. package/src/SvCalendar.test.ts +211 -0
  162. package/src/SvCheckBox.svelte +82 -0
  163. package/src/SvColorInput.svelte +160 -0
  164. package/src/SvComboBox.svelte +108 -0
  165. package/src/SvCountryInput.svelte +125 -0
  166. package/src/SvDateTimePicker.svelte +265 -0
  167. package/src/SvDateTimePicker.test.ts +136 -0
  168. package/src/SvDropDownList.svelte +120 -0
  169. package/src/SvForm.svelte +147 -0
  170. package/src/SvGauge.svelte +97 -0
  171. package/src/SvGrid.controller.svelte.ts +74 -8
  172. package/src/SvGrid.css +84 -31
  173. package/src/SvGrid.helpers.ts +41 -12
  174. package/src/SvGrid.svelte +84 -5
  175. package/src/SvGrid.types.ts +33 -0
  176. package/src/SvGridDropdown.svelte +16 -30
  177. package/src/SvListBox.svelte +89 -0
  178. package/src/SvMaskedInput.svelte +66 -0
  179. package/src/SvNumberInput.svelte +116 -0
  180. package/src/SvPasswordInput.svelte +100 -0
  181. package/src/SvPhoneInput.svelte +87 -0
  182. package/src/SvRadioGroup.svelte +85 -0
  183. package/src/SvRating.svelte +91 -0
  184. package/src/SvRepeatButton.svelte +89 -0
  185. package/src/SvSlider.svelte +155 -0
  186. package/src/SvSwitchButton.svelte +87 -0
  187. package/src/SvTabs.svelte +109 -0
  188. package/src/SvTagsInput.svelte +70 -0
  189. package/src/SvTimePicker.svelte +201 -0
  190. package/src/SvTimePicker.test.ts +98 -0
  191. package/src/SvToggleButton.svelte +57 -0
  192. package/src/SvTree.svelte +131 -0
  193. package/src/build-api.ts +115 -0
  194. package/src/cell-render.test.ts +38 -0
  195. package/src/cell-render.ts +43 -0
  196. package/src/clipboard.test.ts +18 -0
  197. package/src/clipboard.ts +24 -1
  198. package/src/collaboration.test.ts +30 -0
  199. package/src/collaboration.ts +6 -0
  200. package/src/core.ts +27 -3
  201. package/src/countries.ts +71 -0
  202. package/src/createAutocomplete.svelte.ts +104 -0
  203. package/src/createCalendar.svelte.ts +488 -0
  204. package/src/createCheckbox.svelte.ts +74 -0
  205. package/src/createColorInput.svelte.ts +115 -0
  206. package/src/createCombobox.svelte.ts +158 -0
  207. package/src/createCountryInput.svelte.ts +126 -0
  208. package/src/createDateTimePicker.svelte.ts +216 -0
  209. package/src/createDropdownList.svelte.ts +125 -0
  210. package/src/createGauge.svelte.ts +86 -0
  211. package/src/createListbox.svelte.ts +186 -0
  212. package/src/createMaskedInput.svelte.ts +81 -0
  213. package/src/createNumberInput.svelte.ts +193 -0
  214. package/src/createPasswordInput.svelte.ts +87 -0
  215. package/src/createPhoneInput.svelte.ts +119 -0
  216. package/src/createRadioGroup.svelte.ts +132 -0
  217. package/src/createRating.svelte.ts +145 -0
  218. package/src/createSlider.svelte.ts +160 -0
  219. package/src/createSwitch.svelte.ts +78 -0
  220. package/src/createTabs.svelte.ts +129 -0
  221. package/src/createTagsInput.svelte.ts +98 -0
  222. package/src/createTimePicker.svelte.ts +289 -0
  223. package/src/createToggle.svelte.ts +69 -0
  224. package/src/createTree.svelte.ts +216 -0
  225. package/src/datetime/date-core.test.ts +217 -0
  226. package/src/datetime/date-core.ts +204 -0
  227. package/src/datetime/date-format.test.ts +121 -0
  228. package/src/datetime/date-format.ts +317 -0
  229. package/src/datetime/date-restrict.ts +60 -0
  230. package/src/datetime/date-selection.test.ts +129 -0
  231. package/src/datetime/date-selection.ts +137 -0
  232. package/src/datetime/mask.test.ts +36 -0
  233. package/src/datetime/mask.ts +84 -0
  234. package/src/editing.test.ts +22 -0
  235. package/src/editing.ts +7 -1
  236. package/src/editor-contract.test.ts +32 -0
  237. package/src/editor-contract.ts +60 -0
  238. package/src/editors/cell-editors.ts +7 -1
  239. package/src/export-data-api.test.ts +126 -0
  240. package/src/export-format.test.ts +107 -0
  241. package/src/export-format.ts +598 -0
  242. package/src/hyperformula-adapter.test.ts +35 -1
  243. package/src/hyperformula-adapter.ts +18 -6
  244. package/src/index.ts +110 -0
  245. package/src/list-option.ts +15 -0
  246. package/src/menus.ts +21 -2
  247. package/src/popover.ts +79 -0
  248. package/src/row-resize.test.ts +25 -0
  249. package/src/row-resize.ts +8 -5
  250. package/src/selection.test.ts +36 -4
  251. package/src/selection.ts +30 -9
  252. package/src/server-data-source.test.ts +201 -0
  253. package/src/server-data-source.ts +148 -0
  254. package/src/sparkline.test.ts +9 -0
  255. package/src/sparkline.ts +9 -4
  256. package/src/svgrid-wrapper.types.ts +28 -1
  257. package/src/svgrid.behavior.test.ts +27 -0
  258. package/src/svgrid.new-features.wrapper.test.ts +27 -1
  259. package/src/ui-buttons.test.ts +105 -0
  260. package/src/ui-composite.test.ts +89 -0
  261. package/src/ui-inputs.test.ts +118 -0
  262. package/src/ui-range.test.ts +61 -0
  263. package/src/ui-selection.test.ts +119 -0
@@ -0,0 +1,419 @@
1
+ import { formatNumericWithConfig, getDateFormatter, resolveDatePattern, } from './cell-formatting';
2
+ // Re-export the pure conditional-formatting engine here too, so the
3
+ // Svelte-free `@svgrid/grid/format` subpath carries it for @svgrid/enterprise's
4
+ // export code (which must not pull in SvGrid.svelte).
5
+ export { computeColumnStat, contrastText, formatsNeedingStats, resolveCellFormat, } from './conditional-formatting';
6
+ /** Best-effort coercion of a cell value to a Date. Accepts Date, epoch ms
7
+ * numbers, and parseable date strings. Returns null when it isn't a date. */
8
+ export function coerceExportDate(value) {
9
+ if (value instanceof Date)
10
+ return Number.isNaN(value.getTime()) ? null : value;
11
+ if (typeof value === 'number' && Number.isFinite(value)) {
12
+ const d = new Date(value);
13
+ return Number.isNaN(d.getTime()) ? null : d;
14
+ }
15
+ if (typeof value === 'string' && value.trim() !== '') {
16
+ const d = new Date(value);
17
+ return Number.isNaN(d.getTime()) ? null : d;
18
+ }
19
+ return null;
20
+ }
21
+ /**
22
+ * Format a raw cell value to its on-screen display string using the column's
23
+ * `format` config. Mirrors the grid's own numeric / currency / percent / date
24
+ * branches. Values with no (or an unrecognised) format fall back to
25
+ * `String(value)`, and `null` / `undefined` become an empty string.
26
+ */
27
+ export function formatValueForExport(value, format) {
28
+ if (value == null)
29
+ return '';
30
+ if (!format)
31
+ return String(value);
32
+ if (format.type === 'number' || format.type === 'currency' || format.type === 'percent') {
33
+ return formatNumericWithConfig(value, {
34
+ type: format.type,
35
+ locales: format.locales,
36
+ currency: format.type === 'currency' ? (format.currency ?? 'USD') : undefined,
37
+ valueIsPercentPoints: format.type === 'percent' ? format.valueIsPercentPoints : undefined,
38
+ options: format.options,
39
+ });
40
+ }
41
+ if (format.type === 'date' || format.type === 'datetime') {
42
+ const parsed = coerceExportDate(value);
43
+ if (parsed) {
44
+ const preset = resolveDatePattern(format.pattern, format.type);
45
+ const merged = preset || format.options
46
+ ? { ...preset, ...format.options }
47
+ : format.type === 'date'
48
+ ? { year: 'numeric', month: '2-digit', day: '2-digit' }
49
+ : {
50
+ year: 'numeric',
51
+ month: '2-digit',
52
+ day: '2-digit',
53
+ hour: '2-digit',
54
+ minute: '2-digit',
55
+ };
56
+ return getDateFormatter(format.locales, merged).format(parsed);
57
+ }
58
+ }
59
+ return String(value);
60
+ }
61
+ /**
62
+ * Map a `CellFormatConfig` to an Excel/OOXML number-format code, so an xlsx
63
+ * writer can keep the cell numeric/date while displaying it formatted.
64
+ * Returns `undefined` when the format has no natural Excel representation
65
+ * (or the caller should just write a string).
66
+ *
67
+ * These are deliberately conservative, widely-recognised codes:
68
+ * number → `#,##0[.00…]` (grouping + N decimals)
69
+ * currency → `"$"#,##0.00` (symbol + grouping + 2 decimals)
70
+ * percent → `0[.00…]%` (Excel multiplies by 100, so this pairs with a
71
+ * 0..1 fraction; see `valueForExcel`)
72
+ * date → `yyyy-mm-dd`, datetime → `yyyy-mm-dd hh:mm`
73
+ */
74
+ export function toExcelNumFmt(format) {
75
+ if (!format)
76
+ return undefined;
77
+ const decimals = () => {
78
+ // `options` is a union across number/date formats; only the numeric ones
79
+ // carry fraction-digit hints, so read them through a narrow shape.
80
+ const o = format.options;
81
+ if (o && typeof o.maximumFractionDigits === 'number')
82
+ return o.maximumFractionDigits;
83
+ if (o && typeof o.minimumFractionDigits === 'number')
84
+ return o.minimumFractionDigits;
85
+ return format.type === 'currency' ? 2 : format.type === 'number' ? 0 : 2;
86
+ };
87
+ const dp = (n) => (n > 0 ? '.' + '0'.repeat(n) : '');
88
+ switch (format.type) {
89
+ case 'number':
90
+ return `#,##0${dp(decimals())}`;
91
+ case 'currency': {
92
+ const sym = currencySymbol(format.currency ?? 'USD');
93
+ return `"${sym}"#,##0${dp(decimals())}`;
94
+ }
95
+ case 'percent':
96
+ return `0${dp(decimals())}%`;
97
+ case 'date':
98
+ return 'yyyy-mm-dd';
99
+ case 'datetime':
100
+ return 'yyyy-mm-dd hh:mm';
101
+ default:
102
+ return undefined;
103
+ }
104
+ }
105
+ /**
106
+ * Turn a grid's data rows + columns into the header-first `{ field: value }`
107
+ * record shape the serializers consume, applying each column's `format` so
108
+ * the export matches what's on screen (unless `rawValues`). Optionally
109
+ * restricts + reorders columns to a `columns` field subset.
110
+ */
111
+ export function projectGridRows(dataRows, columns, opts = {}) {
112
+ const chosen = opts.columns && opts.columns.length
113
+ ? opts.columns
114
+ .map((f) => columns.find((c) => c.field === f))
115
+ .filter((c) => !!c)
116
+ : columns.filter((c) => c.field);
117
+ const fields = chosen.map((c) => c.field);
118
+ const align = {};
119
+ for (const c of chosen)
120
+ if (c.align)
121
+ align[c.field] = c.align;
122
+ const header = {};
123
+ for (const c of chosen)
124
+ header[c.field] = c.header;
125
+ const records = [header];
126
+ for (const row of dataRows) {
127
+ const rec = {};
128
+ for (const c of chosen) {
129
+ const raw = row[c.field];
130
+ rec[c.field] = opts.rawValues ? raw : formatValueForExport(raw, c.format);
131
+ }
132
+ records.push(rec);
133
+ }
134
+ return { records, fields, align };
135
+ }
136
+ /** A tiny currency-code → symbol map for the Excel numFmt code. Falls back
137
+ * to the ISO code itself (e.g. "CHF") when we don't have a glyph. */
138
+ function currencySymbol(code) {
139
+ const map = {
140
+ USD: '$',
141
+ EUR: '€',
142
+ GBP: '£',
143
+ JPY: '¥',
144
+ CNY: '¥',
145
+ INR: '₹',
146
+ KRW: '₩',
147
+ RUB: '₽',
148
+ BRL: 'R$',
149
+ };
150
+ return map[code.toUpperCase()] ?? code.toUpperCase();
151
+ }
152
+ /**
153
+ * The value to write into a native xlsx cell that carries an Excel numFmt.
154
+ * Numbers stay numbers; percent values are divided to the 0..1 fraction Excel
155
+ * expects (unless the config already stores 0..1); dates become real `Date`s.
156
+ * Returns `{ ok: false }` when the value can't be represented natively and the
157
+ * caller should fall back to the formatted string.
158
+ */
159
+ export function valueForExcel(value, format) {
160
+ if (value == null || !format)
161
+ return { ok: false };
162
+ if (format.type === 'number' || format.type === 'currency') {
163
+ const n = typeof value === 'number' ? value : Number(value);
164
+ return Number.isFinite(n) ? { ok: true, value: n } : { ok: false };
165
+ }
166
+ if (format.type === 'percent') {
167
+ const n = typeof value === 'number' ? value : Number(value);
168
+ if (!Number.isFinite(n))
169
+ return { ok: false };
170
+ // Excel's percent numFmt multiplies by 100, so it wants the fraction.
171
+ return { ok: true, value: format.valueIsPercentPoints === true ? n / 100 : n };
172
+ }
173
+ if (format.type === 'date' || format.type === 'datetime') {
174
+ const d = coerceExportDate(value);
175
+ return d ? { ok: true, value: d } : { ok: false };
176
+ }
177
+ return { ok: false };
178
+ }
179
+ const EXPORT_BOM = '';
180
+ function throwIfAborted(signal) {
181
+ if (signal?.aborted) {
182
+ throw new DOMException('Export aborted', 'AbortError');
183
+ }
184
+ }
185
+ /** Let the event loop breathe (paint a progress bar, honour an abort). */
186
+ const yieldToLoop = () => new Promise((resolve) => setTimeout(resolve, 0));
187
+ /** RFC-4180 quoting: wrap in double quotes and double any embedded quote
188
+ * when the value contains the delimiter, a quote, or a newline. */
189
+ function csvCell(value, delimiter) {
190
+ const s = value == null
191
+ ? ''
192
+ : value instanceof Date
193
+ ? value.toISOString()
194
+ : String(value);
195
+ if (s === '')
196
+ return s;
197
+ if (s.includes(delimiter) || s.includes('"') || s.includes('\n') || s.includes('\r')) {
198
+ return `"${s.replace(/"/g, '""')}"`;
199
+ }
200
+ return s;
201
+ }
202
+ /**
203
+ * Serialize projected rows to a delimited string (CSV / TSV).
204
+ * `rows[0]` is treated as the header row.
205
+ */
206
+ export async function serializeDelimited(rows, fields, opts = {}) {
207
+ const delimiter = opts.csv?.delimiter ?? ',';
208
+ const eol = opts.csv?.eol ?? '\r\n';
209
+ const useBom = opts.csv?.bom ?? true;
210
+ const chunk = Math.max(1, opts.chunkRows ?? 5000);
211
+ const total = rows.length;
212
+ const parts = [];
213
+ for (let i = 0; i < rows.length; i++) {
214
+ throwIfAborted(opts.signal);
215
+ const row = rows[i];
216
+ parts.push(fields.map((f) => csvCell(row[f], delimiter)).join(delimiter));
217
+ if (i > 0 && i % chunk === 0) {
218
+ opts.onProgress?.({ phase: 'serialize', ratio: i / total, row: i, total });
219
+ await yieldToLoop();
220
+ }
221
+ }
222
+ opts.onProgress?.({ phase: 'serialize', ratio: 1, row: total, total });
223
+ const body = parts.join(eol);
224
+ return (useBom ? EXPORT_BOM : '') + body;
225
+ }
226
+ const HTML_ESCAPE = {
227
+ '&': '&amp;',
228
+ '<': '&lt;',
229
+ '>': '&gt;',
230
+ '"': '&quot;',
231
+ "'": '&#39;',
232
+ };
233
+ function htmlCell(value) {
234
+ const s = value == null ? '' : value instanceof Date ? value.toISOString() : String(value);
235
+ return s.replace(/[&<>"']/g, (c) => HTML_ESCAPE[c]);
236
+ }
237
+ /**
238
+ * Serialize projected rows to a standalone HTML `<table>` document.
239
+ * `rows[0]` is the header row (rendered as `<th>`); the rest are `<td>`.
240
+ */
241
+ export async function serializeHtml(rows, fields, opts = {}) {
242
+ const chunk = Math.max(1, opts.chunkRows ?? 5000);
243
+ const total = rows.length;
244
+ const align = opts.align ?? {};
245
+ const cellStyle = opts.cellStyle;
246
+ const cellLink = opts.cellLink;
247
+ const title = opts.title ?? 'Grid export';
248
+ const head = rows[0];
249
+ const th = head
250
+ ? fields.map((f) => `<th>${htmlCell(head[f])}</th>`).join('')
251
+ : '';
252
+ const bodyParts = [];
253
+ for (let i = 1; i < rows.length; i++) {
254
+ throwIfAborted(opts.signal);
255
+ const row = rows[i];
256
+ const tds = fields
257
+ .map((f, ci) => {
258
+ const a = align[f];
259
+ const styles = [];
260
+ if (a && a !== 'left')
261
+ styles.push(`text-align:${a}`);
262
+ const cf = cellStyle?.(i - 1, ci);
263
+ if (cf?.fill)
264
+ styles.push(`background:${cf.fill}`);
265
+ if (cf?.color)
266
+ styles.push(`color:${cf.color}`);
267
+ if (cf?.bold)
268
+ styles.push('font-weight:700');
269
+ const style = styles.length ? ` style="${styles.join(';')}"` : '';
270
+ let text = cf?.icon ? `${cf.icon} ${htmlCell(row[f])}` : htmlCell(row[f]);
271
+ const href = cellLink?.(i - 1, ci);
272
+ if (href)
273
+ text = `<a href="${htmlCell(href)}">${text}</a>`;
274
+ return `<td${style}>${text}</td>`;
275
+ })
276
+ .join('');
277
+ bodyParts.push(`<tr>${tds}</tr>`);
278
+ if (i > 0 && i % chunk === 0) {
279
+ opts.onProgress?.({ phase: 'serialize', ratio: i / total, row: i, total });
280
+ await yieldToLoop();
281
+ }
282
+ }
283
+ opts.onProgress?.({ phase: 'serialize', ratio: 1, row: total, total });
284
+ return (`<!doctype html><html><head><meta charset="utf-8"><title>${htmlCell(title)}</title>` +
285
+ `<style>table{border-collapse:collapse;font-family:system-ui,sans-serif;font-size:13px}` +
286
+ `th,td{border:1px solid #d0d7de;padding:6px 10px}th{background:#f6f8fa;text-align:left}</style>` +
287
+ `</head><body><table><thead><tr>${th}</tr></thead><tbody>${bodyParts.join('')}</tbody></table></body></html>`);
288
+ }
289
+ /**
290
+ * Serialize projected rows to a JSON array of `{ field: value }` objects.
291
+ * `rows[0]` (the header row) is dropped - JSON keys are the field names.
292
+ */
293
+ export async function serializeJson(rows, fields, opts = {}) {
294
+ const chunk = Math.max(1, opts.chunkRows ?? 5000);
295
+ const total = rows.length - 1;
296
+ const out = [];
297
+ for (let i = 1; i < rows.length; i++) {
298
+ throwIfAborted(opts.signal);
299
+ const src = rows[i];
300
+ const obj = {};
301
+ for (const f of fields)
302
+ obj[f] = src[f];
303
+ out.push(obj);
304
+ if (i > 0 && i % chunk === 0) {
305
+ opts.onProgress?.({ phase: 'serialize', ratio: i / total, row: i, total });
306
+ await yieldToLoop();
307
+ }
308
+ }
309
+ opts.onProgress?.({ phase: 'serialize', ratio: 1, row: total, total });
310
+ return JSON.stringify(out, null, 2);
311
+ }
312
+ /** Escape a Markdown table cell: pipes and newlines would break the row. */
313
+ function mdCell(value) {
314
+ const s = value == null ? '' : value instanceof Date ? value.toISOString() : String(value);
315
+ return s.replace(/\\/g, '\\\\').replace(/\|/g, '\\|').replace(/\r?\n/g, '<br>');
316
+ }
317
+ /**
318
+ * Serialize projected rows to a GitHub-flavored Markdown table. `rows[0]` is
319
+ * the header row; `align` sets the `:---`, `:--:`, `---:` markers per column.
320
+ */
321
+ export async function serializeMarkdown(rows, fields, opts = {}) {
322
+ const chunk = Math.max(1, opts.chunkRows ?? 5000);
323
+ const total = rows.length;
324
+ const align = opts.align ?? {};
325
+ const head = rows[0];
326
+ const headerLine = `| ${fields.map((f) => mdCell(head?.[f])).join(' | ')} |`;
327
+ const sepLine = `| ${fields
328
+ .map((f) => {
329
+ const a = align[f];
330
+ return a === 'right' ? '---:' : a === 'center' ? ':--:' : '---';
331
+ })
332
+ .join(' | ')} |`;
333
+ const bodyLines = [];
334
+ for (let i = 1; i < rows.length; i++) {
335
+ throwIfAborted(opts.signal);
336
+ const src = rows[i];
337
+ bodyLines.push(`| ${fields.map((f) => mdCell(src[f])).join(' | ')} |`);
338
+ if (i > 0 && i % chunk === 0) {
339
+ opts.onProgress?.({ phase: 'serialize', ratio: i / total, row: i, total });
340
+ await yieldToLoop();
341
+ }
342
+ }
343
+ opts.onProgress?.({ phase: 'serialize', ratio: 1, row: total, total });
344
+ return [headerLine, sepLine, ...bodyLines].join('\n') + '\n';
345
+ }
346
+ const XML_ESCAPE = {
347
+ '&': '&amp;',
348
+ '<': '&lt;',
349
+ '>': '&gt;',
350
+ '"': '&quot;',
351
+ "'": '&apos;',
352
+ };
353
+ function xmlText(value) {
354
+ const s = value == null ? '' : value instanceof Date ? value.toISOString() : String(value);
355
+ return s.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, '').replace(/[&<>"']/g, (c) => XML_ESCAPE[c]);
356
+ }
357
+ /** Coerce a field name into a valid XML element name. */
358
+ function xmlTag(field) {
359
+ const t = field.replace(/[^A-Za-z0-9_.-]/g, '_');
360
+ return /^[A-Za-z_]/.test(t) ? t : `_${t}`;
361
+ }
362
+ /**
363
+ * Serialize projected rows to a simple XML document:
364
+ * `<rows><row><field>value</field>…</row>…</rows>`. `rows[0]` (header) is
365
+ * dropped - element names come from the field names.
366
+ */
367
+ export async function serializeXml(rows, fields, opts = {}) {
368
+ const chunk = Math.max(1, opts.chunkRows ?? 5000);
369
+ const total = rows.length - 1;
370
+ const root = opts.rootTag ?? 'rows';
371
+ const rowTag = opts.rowTag ?? 'row';
372
+ const tags = fields.map(xmlTag);
373
+ const parts = [`<?xml version="1.0" encoding="UTF-8"?>`, `<${root}>`];
374
+ for (let i = 1; i < rows.length; i++) {
375
+ throwIfAborted(opts.signal);
376
+ const src = rows[i];
377
+ const cells = fields
378
+ .map((f, ci) => `<${tags[ci]}>${xmlText(src[f])}</${tags[ci]}>`)
379
+ .join('');
380
+ parts.push(` <${rowTag}>${cells}</${rowTag}>`);
381
+ if (i > 0 && i % chunk === 0) {
382
+ opts.onProgress?.({ phase: 'serialize', ratio: i / total, row: i, total });
383
+ await yieldToLoop();
384
+ }
385
+ }
386
+ parts.push(`</${root}>`);
387
+ opts.onProgress?.({ phase: 'serialize', ratio: 1, row: total, total });
388
+ return parts.join('\n');
389
+ }
390
+ // ----- Delivery: download + clipboard (browser-guarded) --------------------
391
+ /** Trigger a browser download of an already-built Blob. No-op guard for SSR. */
392
+ export function downloadBlobFile(blob, filename) {
393
+ if (typeof document === 'undefined' || typeof URL === 'undefined') {
394
+ throw new Error('@svgrid/grid: export requires a browser environment');
395
+ }
396
+ const url = URL.createObjectURL(blob);
397
+ const a = document.createElement('a');
398
+ a.href = url;
399
+ a.download = filename;
400
+ document.body.appendChild(a);
401
+ a.click();
402
+ a.remove();
403
+ setTimeout(() => URL.revokeObjectURL(url), 0);
404
+ }
405
+ /** Trigger a browser download of a text blob. No-op guard for SSR. */
406
+ export function downloadTextFile(text, filename, mime) {
407
+ if (typeof document === 'undefined' || typeof URL === 'undefined') {
408
+ throw new Error('@svgrid/grid: text export requires a browser environment');
409
+ }
410
+ downloadBlobFile(new Blob([text], { type: mime }), filename);
411
+ }
412
+ /** Write text to the system clipboard. Throws when the API is unavailable
413
+ * (insecure context / SSR). */
414
+ export async function copyTextToClipboard(text) {
415
+ if (typeof navigator === 'undefined' || !navigator.clipboard) {
416
+ throw new Error('@svgrid/grid: clipboard API is unavailable in this context');
417
+ }
418
+ await navigator.clipboard.writeText(text);
419
+ }
@@ -43,6 +43,10 @@ export type HyperFormulaInstance = {
43
43
  row: number;
44
44
  col: number;
45
45
  }): unknown;
46
+ /** Bulk-load an entire sheet in one call (one recalc instead of one per
47
+ * cell). Optional so minimal / mock instances still satisfy the type;
48
+ * the adapter falls back to per-cell `setCellContents` when it's absent. */
49
+ setSheetContent?(sheetId: number, values: unknown[][]): unknown;
46
50
  destroy(): void;
47
51
  rebuildAndRecalculate(): void;
48
52
  };
@@ -31,12 +31,21 @@ export function createHyperFormulaSheet(config) {
31
31
  const colByField = new Map();
32
32
  fields.forEach((f, i) => colByField.set(f, i));
33
33
  // 1. Seed HF with every cell. HF expects raw strings for formulas
34
- // (`'=A1+B1'`) and primitives for everything else.
35
- for (let r = 0; r < rows.length; r += 1) {
36
- const row = rows[r];
37
- for (let c = 0; c < fields.length; c += 1) {
38
- const field = fields[c];
39
- hf.setCellContents({ sheet: sheetId, row: r, col: c }, row[field]);
34
+ // (`'=A1+B1'`) and primitives for everything else. Prefer a single bulk
35
+ // `setSheetContent` write - it recalculates ONCE instead of once per
36
+ // setCellContents, ~3x faster to mount a large sheet (e.g. 200x26). Fall
37
+ // back to per-cell for instances that don't expose it.
38
+ if (typeof hf.setSheetContent === 'function') {
39
+ const grid = rows.map((row) => fields.map((f) => row[f]));
40
+ hf.setSheetContent(sheetId, grid);
41
+ }
42
+ else {
43
+ for (let r = 0; r < rows.length; r += 1) {
44
+ const row = rows[r];
45
+ for (let c = 0; c < fields.length; c += 1) {
46
+ const field = fields[c];
47
+ hf.setCellContents({ sheet: sheetId, row: r, col: c }, row[field]);
48
+ }
40
49
  }
41
50
  }
42
51
  /** Pull computed values out of HF into a fresh row array. Preserves
package/dist/index.d.ts CHANGED
@@ -1,9 +1,69 @@
1
1
  export { formatNumericWithConfig, resolveDatePattern } from './cell-formatting';
2
+ export { coerceExportDate, formatValueForExport, projectGridRows, toExcelNumFmt, valueForExcel, serializeDelimited, serializeJson, serializeMarkdown, serializeHtml, serializeXml, downloadTextFile, downloadBlobFile, copyTextToClipboard, type GridExportOptions, type GridExportScope, type GridExportColumn, type GridClipboardOptions, type GridClipboardFormat, type SerializeProgress, type SerializeOptions, type CsvOptions, } from './export-format';
2
3
  export { columnFilteringFeature, columnGroupingFeature, createCoreRowModel, createExpandedRowModel, createFilteredRowModel, createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, applyGroupAggregate, filterFns, rowExpandingFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, sortFns, tableFeatures, type Cell, type CellContext, type CellSpanParams, type ValueParserParams, type EditorContext, type CellData, type ActiveCellState, type CellFormatConfig, type CellFormatter, type Column, type ColumnDef, type ColumnDefTemplate, type GroupAggregator, type Header, type HeaderContext, type HeaderGroup, type Row, type RowData, type SortingState, type SvGrid as SvGridInstance, type SvGridOptions, type TableFeatures, type Updater, } from './core';
3
4
  export { createGrid, createSvGrid, type SvelteGrid } from './createGrid.svelte';
4
5
  export { createGridState, createSvGridState } from './createGridState.svelte';
5
6
  export { subscribeGrid, subscribeSvGrid } from './subscribe';
6
7
  export { default as SvGrid } from './SvGrid.svelte';
8
+ export { default as SvGridDropdown } from './SvGridDropdown.svelte';
9
+ export { default as SvCalendar, type CalendarValue, type CalendarPreset, type CalendarAnimation } from './SvCalendar.svelte';
10
+ export { default as SvTimePicker, type TimeValue } from './SvTimePicker.svelte';
11
+ export { default as SvDateTimePicker, type DateTimeValue } from './SvDateTimePicker.svelte';
12
+ export { editorAria, editorErrorId, type SvEditorProps, type EditorSize, type EditorAriaState } from './editor-contract';
13
+ export { createListbox, toSelectedArray, type Listbox, type ListboxConfig, type ListboxValue, type ListboxRootProps, type OptionProps, } from './createListbox.svelte';
14
+ export { createCombobox, type Combobox, type ComboboxConfig, type ComboboxValue } from './createCombobox.svelte';
15
+ export { createDropdownList, type DropdownList, type DropdownListConfig, type DropdownValue } from './createDropdownList.svelte';
16
+ export { createAutocomplete, type Autocomplete, type AutocompleteConfig } from './createAutocomplete.svelte';
17
+ export { createTagsInput, type TagsInput, type TagsInputConfig } from './createTagsInput.svelte';
18
+ export { createCountryInput, type CountryInput, type CountryInputConfig } from './createCountryInput.svelte';
19
+ export { createNumberInput, type NumberInputConfig, type NumberInputCore } from './createNumberInput.svelte';
20
+ export { createMaskedInput, type MaskedInputConfig, type MaskedInputCore } from './createMaskedInput.svelte';
21
+ export { createPhoneInput, type PhoneInputConfig, type PhoneInputCore } from './createPhoneInput.svelte';
22
+ export { createColorInput, normalizeHex, type ColorInputConfig, type ColorInputCore } from './createColorInput.svelte';
23
+ export { createPasswordInput, passwordStrength, STRENGTH_LABELS, type PasswordInputConfig, type PasswordInputCore } from './createPasswordInput.svelte';
24
+ export { createToggle, type Toggle, type ToggleConfig, type ToggleButtonProps } from './createToggle.svelte';
25
+ export { createSwitch, type Switch, type SwitchConfig, type SwitchProps } from './createSwitch.svelte';
26
+ export { createCheckbox, type Checkbox, type CheckboxConfig, type CheckboxBoxProps } from './createCheckbox.svelte';
27
+ export { createRadioGroup, type RadioGroup, type RadioGroupConfig, type RadioProps, type RadioGroupProps } from './createRadioGroup.svelte';
28
+ export { createRating, type Rating, type RatingConfig, type RatingFill, type RatingRootProps, type RatingStarProps } from './createRating.svelte';
29
+ export { createCalendar, normalizeCalendarValue, type Calendar, type CalendarConfig, type CalendarDayState, type CalendarNavDir, type CalendarNameFormat, type DisplayMode } from './createCalendar.svelte';
30
+ export { createTimePicker, parseTimeValue, type TimePicker, type TimePickerConfig, type TimeSelection, type TimeFormat, type DialTick } from './createTimePicker.svelte';
31
+ export { createDateTimePicker, type DateTimePicker, type DateTimePickerConfig, type DropDownDisplayMode, type DateTimeTab } from './createDateTimePicker.svelte';
32
+ export { createTabs, type Tabs, type TabsConfig, type TabsOrientation, type TabsActivation } from './createTabs.svelte';
33
+ export { createTree, treeDescendantIds, treeCheckState, type Tree, type TreeConfig, type TreeRow, type CheckState } from './createTree.svelte';
34
+ export { createSlider, type Slider, type SliderConfig, type SliderValue, type SliderOrientation, type SliderThumb, type SliderPoint } from './createSlider.svelte';
35
+ export { createGauge, type Gauge, type GaugeConfig, type GaugePoint } from './createGauge.svelte';
36
+ export { default as SvButton } from './SvButton.svelte';
37
+ export { default as SvRepeatButton } from './SvRepeatButton.svelte';
38
+ export { default as SvToggleButton } from './SvToggleButton.svelte';
39
+ export { default as SvSwitchButton } from './SvSwitchButton.svelte';
40
+ export { default as SvCheckBox } from './SvCheckBox.svelte';
41
+ export { default as SvRadioGroup, type RadioOption } from './SvRadioGroup.svelte';
42
+ export { default as SvRating } from './SvRating.svelte';
43
+ export { default as SvNumberInput } from './SvNumberInput.svelte';
44
+ export { default as SvPasswordInput } from './SvPasswordInput.svelte';
45
+ export { default as SvMaskedInput } from './SvMaskedInput.svelte';
46
+ export { default as SvPhoneInput } from './SvPhoneInput.svelte';
47
+ export { default as SvColorInput } from './SvColorInput.svelte';
48
+ export { applyMask, unmask, isMaskComplete } from './datetime/mask';
49
+ export { COUNTRIES, COUNTRY_BY_CODE, flagEmoji, type Country } from './countries';
50
+ export { default as SvListBox } from './SvListBox.svelte';
51
+ export { default as SvDropDownList } from './SvDropDownList.svelte';
52
+ export { default as SvComboBox } from './SvComboBox.svelte';
53
+ export { default as SvAutoComplete } from './SvAutoComplete.svelte';
54
+ export { default as SvTagsInput } from './SvTagsInput.svelte';
55
+ export { default as SvCountryInput } from './SvCountryInput.svelte';
56
+ export { filterOptions, type ListOption } from './list-option';
57
+ export { default as SvSlider } from './SvSlider.svelte';
58
+ export { default as SvGauge } from './SvGauge.svelte';
59
+ export { default as SvTabs, type TabItem } from './SvTabs.svelte';
60
+ export { default as SvTree, type TreeNode as SvTreeNode } from './SvTree.svelte';
61
+ export { default as SvForm, type FormField, type FormFieldType } from './SvForm.svelte';
62
+ export { anchoredRect, portalToBody, PANEL_THEME_VARS, type AnchoredRect } from './popover';
63
+ export { toDate, startOfDay, addDays, addMonths, addYears, clampDate, isSameDay, monthMatrix, isoWeek, decadeRange, withTime, snapMinute, type DateLike, } from './datetime/date-core';
64
+ export { formatDate, parseDate, tokenizeMask } from './datetime/date-format';
65
+ export { selectDate, rangeDays, isSelected, isMultiSelectMode, emptySelection, type SelectionMode, type SelectionState, } from './datetime/date-selection';
66
+ export { isDisabledDay, isOutOfRange, isRestricted, isImportant, type RestrictOptions, } from './datetime/date-restrict';
7
67
  export { default as FlexRender } from './FlexRender.svelte';
8
68
  export { renderComponent, renderSnippet } from './render-component';
9
69
  export { default as SvGridChart } from './SvGridChart.svelte';
package/dist/index.js CHANGED
@@ -1,9 +1,81 @@
1
1
  export { formatNumericWithConfig, resolveDatePattern } from './cell-formatting';
2
+ export { coerceExportDate, formatValueForExport, projectGridRows, toExcelNumFmt, valueForExcel, serializeDelimited, serializeJson, serializeMarkdown, serializeHtml, serializeXml, downloadTextFile, downloadBlobFile, copyTextToClipboard, } from './export-format';
2
3
  export { columnFilteringFeature, columnGroupingFeature, createCoreRowModel, createExpandedRowModel, createFilteredRowModel, createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, applyGroupAggregate, filterFns, rowExpandingFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, sortFns, tableFeatures, } from './core';
3
4
  export { createGrid, createSvGrid } from './createGrid.svelte';
4
5
  export { createGridState, createSvGridState } from './createGridState.svelte';
5
6
  export { subscribeGrid, subscribeSvGrid } from './subscribe';
6
7
  export { default as SvGrid } from './SvGrid.svelte';
8
+ export { default as SvGridDropdown } from './SvGridDropdown.svelte';
9
+ export { default as SvCalendar } from './SvCalendar.svelte';
10
+ export { default as SvTimePicker } from './SvTimePicker.svelte';
11
+ export { default as SvDateTimePicker } from './SvDateTimePicker.svelte';
12
+ // UI kit - shared editor contract (common props + a11y wiring for every editor)
13
+ export { editorAria, editorErrorId } from './editor-contract';
14
+ // UI kit - headless cores (state + prop-getters you render yourself, like createSvGrid)
15
+ export { createListbox, toSelectedArray, } from './createListbox.svelte';
16
+ // Selection family cores
17
+ export { createCombobox } from './createCombobox.svelte';
18
+ export { createDropdownList } from './createDropdownList.svelte';
19
+ export { createAutocomplete } from './createAutocomplete.svelte';
20
+ export { createTagsInput } from './createTagsInput.svelte';
21
+ export { createCountryInput } from './createCountryInput.svelte';
22
+ // Text-input family cores
23
+ export { createNumberInput } from './createNumberInput.svelte';
24
+ export { createMaskedInput } from './createMaskedInput.svelte';
25
+ export { createPhoneInput } from './createPhoneInput.svelte';
26
+ export { createColorInput, normalizeHex } from './createColorInput.svelte';
27
+ export { createPasswordInput, passwordStrength, STRENGTH_LABELS } from './createPasswordInput.svelte';
28
+ // Buttons & toggles family cores
29
+ export { createToggle } from './createToggle.svelte';
30
+ export { createSwitch } from './createSwitch.svelte';
31
+ export { createCheckbox } from './createCheckbox.svelte';
32
+ export { createRadioGroup } from './createRadioGroup.svelte';
33
+ export { createRating } from './createRating.svelte';
34
+ // Date & time family cores
35
+ export { createCalendar, normalizeCalendarValue } from './createCalendar.svelte';
36
+ export { createTimePicker, parseTimeValue } from './createTimePicker.svelte';
37
+ export { createDateTimePicker } from './createDateTimePicker.svelte';
38
+ // Layout & range family cores
39
+ export { createTabs } from './createTabs.svelte';
40
+ export { createTree, treeDescendantIds, treeCheckState } from './createTree.svelte';
41
+ export { createSlider } from './createSlider.svelte';
42
+ export { createGauge } from './createGauge.svelte';
43
+ // UI kit - Group B (buttons & toggles)
44
+ export { default as SvButton } from './SvButton.svelte';
45
+ export { default as SvRepeatButton } from './SvRepeatButton.svelte';
46
+ export { default as SvToggleButton } from './SvToggleButton.svelte';
47
+ export { default as SvSwitchButton } from './SvSwitchButton.svelte';
48
+ export { default as SvCheckBox } from './SvCheckBox.svelte';
49
+ export { default as SvRadioGroup } from './SvRadioGroup.svelte';
50
+ export { default as SvRating } from './SvRating.svelte';
51
+ // UI kit - Group C (text inputs)
52
+ export { default as SvNumberInput } from './SvNumberInput.svelte';
53
+ export { default as SvPasswordInput } from './SvPasswordInput.svelte';
54
+ export { default as SvMaskedInput } from './SvMaskedInput.svelte';
55
+ export { default as SvPhoneInput } from './SvPhoneInput.svelte';
56
+ export { default as SvColorInput } from './SvColorInput.svelte';
57
+ export { applyMask, unmask, isMaskComplete } from './datetime/mask';
58
+ export { COUNTRIES, COUNTRY_BY_CODE, flagEmoji } from './countries';
59
+ // UI kit - Group D (selection overlays)
60
+ export { default as SvListBox } from './SvListBox.svelte';
61
+ export { default as SvDropDownList } from './SvDropDownList.svelte';
62
+ export { default as SvComboBox } from './SvComboBox.svelte';
63
+ export { default as SvAutoComplete } from './SvAutoComplete.svelte';
64
+ export { default as SvTagsInput } from './SvTagsInput.svelte';
65
+ export { default as SvCountryInput } from './SvCountryInput.svelte';
66
+ export { filterOptions } from './list-option';
67
+ // UI kit - Group E (range & feedback)
68
+ export { default as SvSlider } from './SvSlider.svelte';
69
+ export { default as SvGauge } from './SvGauge.svelte';
70
+ // UI kit - Group F (composite / layout)
71
+ export { default as SvTabs } from './SvTabs.svelte';
72
+ export { default as SvTree } from './SvTree.svelte';
73
+ export { default as SvForm } from './SvForm.svelte';
74
+ export { anchoredRect, portalToBody, PANEL_THEME_VARS } from './popover';
75
+ export { toDate, startOfDay, addDays, addMonths, addYears, clampDate, isSameDay, monthMatrix, isoWeek, decadeRange, withTime, snapMinute, } from './datetime/date-core';
76
+ export { formatDate, parseDate, tokenizeMask } from './datetime/date-format';
77
+ export { selectDate, rangeDays, isSelected, isMultiSelectMode, emptySelection, } from './datetime/date-selection';
78
+ export { isDisabledDay, isOutOfRange, isRestricted, isImportant, } from './datetime/date-restrict';
7
79
  export { default as FlexRender } from './FlexRender.svelte';
8
80
  export { renderComponent, renderSnippet } from './render-component';
9
81
  export { default as SvGridChart } from './SvGridChart.svelte';
@@ -0,0 +1,10 @@
1
+ /** Shared option shape for the SvGrid UI-kit selection controls. */
2
+ export type ListOption = {
3
+ value: string | number;
4
+ label: string;
5
+ disabled?: boolean;
6
+ /** Optional group heading this option belongs under. */
7
+ group?: string;
8
+ };
9
+ /** Case-insensitive substring filter over option labels. */
10
+ export declare function filterOptions(options: ReadonlyArray<ListOption>, query: string): ListOption[];
@@ -0,0 +1,7 @@
1
+ /** Case-insensitive substring filter over option labels. */
2
+ export function filterOptions(options, query) {
3
+ const q = query.trim().toLowerCase();
4
+ if (!q)
5
+ return [...options];
6
+ return options.filter((o) => o.label.toLowerCase().includes(q));
7
+ }