@extend-ai/react-xlsx 0.14.0 → 0.15.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.
- package/README.md +54 -2
- package/dist/duke_sheets_wasm_bg.wasm +0 -0
- package/dist/index.cjs +1125 -1181
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +107 -37
- package/dist/index.d.ts +107 -37
- package/dist/index.js +1125 -1181
- package/dist/index.js.map +1 -1
- package/dist/xlsx-worker.js +290 -78
- package/dist/xlsx-worker.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -235,7 +235,7 @@ These hooks work inside `XlsxViewer` or `XlsxViewerProvider` context.
|
|
|
235
235
|
|
|
236
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
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
|
|
238
|
+
Buttons do not execute Excel macros. Provide `onFormControlAction` to handle a button activation in your application. Labels and group boxes are display-only.
|
|
239
239
|
|
|
240
240
|
```tsx
|
|
241
241
|
<XlsxViewer
|
|
@@ -249,7 +249,32 @@ Buttons do not execute Excel macros. Provide `onFormControlAction` to handle a b
|
|
|
249
249
|
/>
|
|
250
250
|
```
|
|
251
251
|
|
|
252
|
-
The controller also exposes `addFormControl(input, sheetIndex?)`, `updateFormControl(controlIndex, patch, sheetIndex?)`, `removeFormControl(controlIndex, sheetIndex?)`, and `getFormControlItems(controlIndex, sheetIndex?)`.
|
|
252
|
+
The controller also exposes `addFormControl(input, sheetIndex?)`, `updateFormControl(controlIndex, patch, sheetIndex?)`, `removeFormControl(controlIndex, sheetIndex?)`, and `getFormControlItems(controlIndex, sheetIndex?)`. `XlsxFormControlInput` uses the same `XlsxImageAnchor` union as images and charts, with an optional `editAs` value for two-cell anchors. Captions accept either a string or rich text runs:
|
|
253
|
+
|
|
254
|
+
```ts
|
|
255
|
+
const controlIndex = controller.addFormControl({
|
|
256
|
+
anchor: {
|
|
257
|
+
kind: "two-cell",
|
|
258
|
+
from: { col: 1, row: 1, colOffsetEmu: 0, rowOffsetEmu: 0 },
|
|
259
|
+
to: { col: 3, row: 2, colOffsetEmu: 0, rowOffsetEmu: 0 }
|
|
260
|
+
},
|
|
261
|
+
editAs: "twoCell",
|
|
262
|
+
kind: {
|
|
263
|
+
kind: "checkbox",
|
|
264
|
+
caption: {
|
|
265
|
+
runs: [{ text: "Include forecast", font: { bold: true, name: "Aptos", size: 10 } }]
|
|
266
|
+
},
|
|
267
|
+
state: "checked"
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Migrating To 0.15
|
|
273
|
+
|
|
274
|
+
- `XlsxFormControlAnchor` was removed. Pass an `XlsxImageAnchor` to `XlsxFormControlInput.anchor` instead.
|
|
275
|
+
- Read controls now expose `caption` as `XlsxFormControlCaption`; use `label` when you only need flattened display text.
|
|
276
|
+
- Mutation captions accept either a plain string or `XlsxFormControlCaption` rich text runs.
|
|
277
|
+
- `firstInGroup` is read-only. Duke recomputes option-button grouping when controls are written.
|
|
253
278
|
|
|
254
279
|
## Chart Selection And Formulas
|
|
255
280
|
|
|
@@ -360,6 +385,31 @@ export function CustomWorkbook({ file }: { file: ArrayBuffer }) {
|
|
|
360
385
|
|
|
361
386
|
Apply `triggerProps` to the table-header trigger button so clicks do not leak into grid selection.
|
|
362
387
|
|
|
388
|
+
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.
|
|
389
|
+
|
|
390
|
+
```tsx
|
|
391
|
+
<XlsxViewer
|
|
392
|
+
file={file}
|
|
393
|
+
renderFormControl={({ checked, control, disabled, label, setState, stopPropagation, style }) => {
|
|
394
|
+
if (control.kind === "checkbox" || control.kind === "radio") {
|
|
395
|
+
return (
|
|
396
|
+
<label onPointerDown={stopPropagation} style={style}>
|
|
397
|
+
<input
|
|
398
|
+
checked={checked}
|
|
399
|
+
disabled={disabled}
|
|
400
|
+
onChange={(event) => setState(event.currentTarget.checked ? "checked" : "unchecked")}
|
|
401
|
+
type={control.kind === "radio" ? "radio" : "checkbox"}
|
|
402
|
+
/>
|
|
403
|
+
{label}
|
|
404
|
+
</label>
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
return <div style={style}>{label}</div>;
|
|
409
|
+
}}
|
|
410
|
+
/>
|
|
411
|
+
```
|
|
412
|
+
|
|
363
413
|
## Large Files
|
|
364
414
|
|
|
365
415
|
`XlsxViewer` includes guardrails for large workbooks.
|
|
@@ -437,6 +487,7 @@ Common rendering props:
|
|
|
437
487
|
- `renderImage?: (props: XlsxImageRenderProps) => React.ReactNode`
|
|
438
488
|
- `renderImageSelection?: (props: XlsxImageSelectionRenderProps) => React.ReactNode`
|
|
439
489
|
- `renderChartLoading?: (props: XlsxChartLoadingRenderProps) => React.ReactNode`
|
|
490
|
+
- `renderFormControl?: (props: XlsxFormControlRenderProps) => React.ReactNode`
|
|
440
491
|
- `renderTableHeaderMenu?: (props: XlsxTableHeaderMenuRenderProps) => React.ReactNode`
|
|
441
492
|
- `renderScroller?: (props: XlsxScrollerRenderProps) => React.ReactNode`
|
|
442
493
|
|
|
@@ -607,6 +658,7 @@ The package exports the main types you are likely to use for custom integrations
|
|
|
607
658
|
- `XlsxChart`, `XlsxChartSeries`, `XlsxChartAxis`, `XlsxChartElementSelection`, `XlsxChartsheet`
|
|
608
659
|
- `XlsxFormulaTarget`
|
|
609
660
|
- `XlsxImage`, `XlsxImageRect`, `XlsxImageRenderProps`, `XlsxImageSelectionRenderProps`
|
|
661
|
+
- `XlsxFormControl`, `XlsxFormControlInput`, `XlsxFormControlCaption`, `XlsxFormControlCaptionInput`, `XlsxFormControlCaptionRun`, `XlsxFormControlRenderProps`
|
|
610
662
|
- `XlsxTable`, `XlsxTableColumn`, `XlsxTableHeaderMenuRenderProps`
|
|
611
663
|
- `XlsxWorkbookTab`, `XlsxCellAddress`, `XlsxCellRange`
|
|
612
664
|
|
|
Binary file
|