@extend-ai/react-xlsx 0.13.4 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -231,6 +231,26 @@ These hooks work inside `XlsxViewer` or `XlsxViewerProvider` context.
231
231
  - `useXlsxViewerCharts()` for chart, chart element, formula, and chartsheet state
232
232
  - `useXlsxViewerThumbnails(options)` for painting worksheet thumbnails into your own canvases
233
233
 
234
+ ## Form Control Editing
235
+
236
+ When `readOnly={false}`, Duke-backed checkboxes, option buttons, dropdowns, list boxes, scrollbars, and spinners are interactive. Changes update linked cells immediately, participate in undo/redo, and are written by `exportXlsx()` / `download()`.
237
+
238
+ Buttons do not execute Excel macros. Provide `onFormControlAction` to handle a button activation in your application. Labels and group boxes are display-only, and legacy edit boxes remain render-only because Duke Sheets does not expose them as editable form controls.
239
+
240
+ ```tsx
241
+ <XlsxViewer
242
+ file={file}
243
+ onFormControlAction={({ control }) => {
244
+ console.log("Activated", control.name);
245
+ }}
246
+ onFormControlChange={({ control, previousControl }) => {
247
+ console.log(previousControl.state, "->", control.state);
248
+ }}
249
+ />
250
+ ```
251
+
252
+ The controller also exposes `addFormControl(input, sheetIndex?)`, `updateFormControl(controlIndex, patch, sheetIndex?)`, `removeFormControl(controlIndex, sheetIndex?)`, and `getFormControlItems(controlIndex, sheetIndex?)`. Inputs use Duke's flat two-cell anchor and kind-specific form-control shape, exported as `XlsxFormControlInput` and related types.
253
+
234
254
  ## Chart Selection And Formulas
235
255
 
236
256
  Chart interactions follow Excel's selection progression: clicking a chart selects the chart frame, clicking a plotted item or legend entry again selects the series, and clicking an item in an already-selected series selects that point. `selectedChartElement` exposes the current chart, series, legend entry, or point selection through the controller and `useXlsxViewerCharts()`.
@@ -340,6 +360,31 @@ export function CustomWorkbook({ file }: { file: ArrayBuffer }) {
340
360
 
341
361
  Apply `triggerProps` to the table-header trigger button so clicks do not leak into grid selection.
342
362
 
363
+ Use `renderFormControl` to replace the built-in worksheet widgets. The callback receives the parsed `control`, resolved `items` and `label`, calculated `style`, read-only state, and `activate`, `setState`, `setSelected`, and `setValue` helpers. Apply `style` to the custom root and call `stopPropagation` from pointer/click handlers. The helpers keep Duke mutations, linked cells, undo/redo, export, and `onFormControlChange` in sync.
364
+
365
+ ```tsx
366
+ <XlsxViewer
367
+ file={file}
368
+ renderFormControl={({ checked, control, disabled, label, setState, stopPropagation, style }) => {
369
+ if (control.kind === "checkbox" || control.kind === "radio") {
370
+ return (
371
+ <label onPointerDown={stopPropagation} style={style}>
372
+ <input
373
+ checked={checked}
374
+ disabled={disabled}
375
+ onChange={(event) => setState(event.currentTarget.checked ? "checked" : "unchecked")}
376
+ type={control.kind === "radio" ? "radio" : "checkbox"}
377
+ />
378
+ {label}
379
+ </label>
380
+ );
381
+ }
382
+
383
+ return <div style={style}>{label}</div>;
384
+ }}
385
+ />
386
+ ```
387
+
343
388
  ## Large Files
344
389
 
345
390
  `XlsxViewer` includes guardrails for large workbooks.
@@ -417,6 +462,7 @@ Common rendering props:
417
462
  - `renderImage?: (props: XlsxImageRenderProps) => React.ReactNode`
418
463
  - `renderImageSelection?: (props: XlsxImageSelectionRenderProps) => React.ReactNode`
419
464
  - `renderChartLoading?: (props: XlsxChartLoadingRenderProps) => React.ReactNode`
465
+ - `renderFormControl?: (props: XlsxFormControlRenderProps) => React.ReactNode`
420
466
  - `renderTableHeaderMenu?: (props: XlsxTableHeaderMenuRenderProps) => React.ReactNode`
421
467
  - `renderScroller?: (props: XlsxScrollerRenderProps) => React.ReactNode`
422
468
 
@@ -587,6 +633,7 @@ The package exports the main types you are likely to use for custom integrations
587
633
  - `XlsxChart`, `XlsxChartSeries`, `XlsxChartAxis`, `XlsxChartElementSelection`, `XlsxChartsheet`
588
634
  - `XlsxFormulaTarget`
589
635
  - `XlsxImage`, `XlsxImageRect`, `XlsxImageRenderProps`, `XlsxImageSelectionRenderProps`
636
+ - `XlsxFormControl`, `XlsxFormControlRenderProps`
590
637
  - `XlsxTable`, `XlsxTableColumn`, `XlsxTableHeaderMenuRenderProps`
591
638
  - `XlsxWorkbookTab`, `XlsxCellAddress`, `XlsxCellRange`
592
639
 
Binary file