@extend-ai/react-xlsx 0.1.0 → 0.2.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/dist/index.cjs +88 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +88 -73
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -731,6 +731,7 @@ interface XlsxTableHeaderMenuRenderProps {
|
|
|
731
731
|
interface XlsxViewerProviderProps extends UseXlsxViewerControllerOptions {
|
|
732
732
|
children: React.ReactNode;
|
|
733
733
|
controller?: XlsxViewerController;
|
|
734
|
+
isDark?: boolean;
|
|
734
735
|
}
|
|
735
736
|
interface XlsxViewerProps extends UseXlsxViewerControllerOptions {
|
|
736
737
|
className?: string;
|
|
@@ -739,6 +740,7 @@ interface XlsxViewerProps extends UseXlsxViewerControllerOptions {
|
|
|
739
740
|
errorState?: React.ReactNode | ((error: Error) => React.ReactNode);
|
|
740
741
|
fileTooLargeState?: React.ReactNode | ((props: XlsxFileTooLargeRenderProps) => React.ReactNode);
|
|
741
742
|
height?: React.CSSProperties["height"];
|
|
743
|
+
isDark?: boolean;
|
|
742
744
|
loadingComponent?: React.ReactElement;
|
|
743
745
|
loadingState?: React.ReactNode;
|
|
744
746
|
renderChartLoading?: (props: XlsxChartLoadingRenderProps) => React.ReactNode;
|
|
@@ -762,7 +764,7 @@ declare class XlsxFileSizeLimitExceededError extends Error {
|
|
|
762
764
|
}
|
|
763
765
|
declare function useXlsxViewerController(options: UseXlsxViewerControllerOptions): XlsxViewerController;
|
|
764
766
|
|
|
765
|
-
declare function XlsxViewerProvider({ children, controller, ...options }: XlsxViewerProviderProps): react_jsx_runtime.JSX.Element;
|
|
767
|
+
declare function XlsxViewerProvider({ children, controller, isDark, ...options }: XlsxViewerProviderProps): react_jsx_runtime.JSX.Element;
|
|
766
768
|
declare function useXlsxViewer(): XlsxViewerController;
|
|
767
769
|
declare function useXlsxViewerSelection(): XlsxViewerSelection;
|
|
768
770
|
declare function useXlsxViewerZoom(): XlsxViewerZoom;
|
package/dist/index.d.ts
CHANGED
|
@@ -731,6 +731,7 @@ interface XlsxTableHeaderMenuRenderProps {
|
|
|
731
731
|
interface XlsxViewerProviderProps extends UseXlsxViewerControllerOptions {
|
|
732
732
|
children: React.ReactNode;
|
|
733
733
|
controller?: XlsxViewerController;
|
|
734
|
+
isDark?: boolean;
|
|
734
735
|
}
|
|
735
736
|
interface XlsxViewerProps extends UseXlsxViewerControllerOptions {
|
|
736
737
|
className?: string;
|
|
@@ -739,6 +740,7 @@ interface XlsxViewerProps extends UseXlsxViewerControllerOptions {
|
|
|
739
740
|
errorState?: React.ReactNode | ((error: Error) => React.ReactNode);
|
|
740
741
|
fileTooLargeState?: React.ReactNode | ((props: XlsxFileTooLargeRenderProps) => React.ReactNode);
|
|
741
742
|
height?: React.CSSProperties["height"];
|
|
743
|
+
isDark?: boolean;
|
|
742
744
|
loadingComponent?: React.ReactElement;
|
|
743
745
|
loadingState?: React.ReactNode;
|
|
744
746
|
renderChartLoading?: (props: XlsxChartLoadingRenderProps) => React.ReactNode;
|
|
@@ -762,7 +764,7 @@ declare class XlsxFileSizeLimitExceededError extends Error {
|
|
|
762
764
|
}
|
|
763
765
|
declare function useXlsxViewerController(options: UseXlsxViewerControllerOptions): XlsxViewerController;
|
|
764
766
|
|
|
765
|
-
declare function XlsxViewerProvider({ children, controller, ...options }: XlsxViewerProviderProps): react_jsx_runtime.JSX.Element;
|
|
767
|
+
declare function XlsxViewerProvider({ children, controller, isDark, ...options }: XlsxViewerProviderProps): react_jsx_runtime.JSX.Element;
|
|
766
768
|
declare function useXlsxViewer(): XlsxViewerController;
|
|
767
769
|
declare function useXlsxViewerSelection(): XlsxViewerSelection;
|
|
768
770
|
declare function useXlsxViewerZoom(): XlsxViewerZoom;
|
package/dist/index.js
CHANGED
|
@@ -15981,6 +15981,7 @@ function darkenColor3(color, ratio) {
|
|
|
15981
15981
|
return mixRgbColor3(color, "#000000", ratio);
|
|
15982
15982
|
}
|
|
15983
15983
|
var ViewerContext = React4.createContext(null);
|
|
15984
|
+
var ViewerAppearanceContext = React4.createContext({ isDark: false });
|
|
15984
15985
|
function classNames(...values) {
|
|
15985
15986
|
return values.filter(Boolean).join(" ");
|
|
15986
15987
|
}
|
|
@@ -17242,40 +17243,8 @@ function resolveImageHandleStyle(position, stroke, surface) {
|
|
|
17242
17243
|
}
|
|
17243
17244
|
return style;
|
|
17244
17245
|
}
|
|
17245
|
-
function
|
|
17246
|
-
|
|
17247
|
-
return false;
|
|
17248
|
-
}
|
|
17249
|
-
const classList = document.documentElement.classList;
|
|
17250
|
-
if (classList.contains("dark")) {
|
|
17251
|
-
return true;
|
|
17252
|
-
}
|
|
17253
|
-
if (classList.contains("light")) {
|
|
17254
|
-
return false;
|
|
17255
|
-
}
|
|
17256
|
-
return typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
17257
|
-
}
|
|
17258
|
-
function useViewerPalette() {
|
|
17259
|
-
const [isDarkMode, setIsDarkMode] = React4.useState(resolveIsDarkMode);
|
|
17260
|
-
React4.useEffect(() => {
|
|
17261
|
-
if (typeof window === "undefined") {
|
|
17262
|
-
return;
|
|
17263
|
-
}
|
|
17264
|
-
const update = () => setIsDarkMode(resolveIsDarkMode());
|
|
17265
|
-
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
17266
|
-
const observer = new MutationObserver(update);
|
|
17267
|
-
observer.observe(document.documentElement, {
|
|
17268
|
-
attributeFilter: ["class", "data-theme"],
|
|
17269
|
-
attributes: true
|
|
17270
|
-
});
|
|
17271
|
-
mediaQuery.addEventListener?.("change", update);
|
|
17272
|
-
update();
|
|
17273
|
-
return () => {
|
|
17274
|
-
observer.disconnect();
|
|
17275
|
-
mediaQuery.removeEventListener?.("change", update);
|
|
17276
|
-
};
|
|
17277
|
-
}, []);
|
|
17278
|
-
return isDarkMode ? DARK_PALETTE : LIGHT_PALETTE;
|
|
17246
|
+
function useViewerPalette(isDark = false) {
|
|
17247
|
+
return isDark ? DARK_PALETTE : LIGHT_PALETTE;
|
|
17279
17248
|
}
|
|
17280
17249
|
function columnLabel2(col) {
|
|
17281
17250
|
let label = "";
|
|
@@ -18120,6 +18089,57 @@ function DefaultTableHeaderMenu({
|
|
|
18120
18089
|
}
|
|
18121
18090
|
);
|
|
18122
18091
|
}
|
|
18092
|
+
function SegmentedControl({
|
|
18093
|
+
items,
|
|
18094
|
+
onValueChange,
|
|
18095
|
+
palette,
|
|
18096
|
+
value
|
|
18097
|
+
}) {
|
|
18098
|
+
return /* @__PURE__ */ jsx3(
|
|
18099
|
+
"div",
|
|
18100
|
+
{
|
|
18101
|
+
"aria-label": "Workbook sheets",
|
|
18102
|
+
role: "tablist",
|
|
18103
|
+
style: {
|
|
18104
|
+
alignItems: "center",
|
|
18105
|
+
backgroundColor: palette.sheetInactiveSurface,
|
|
18106
|
+
border: `1px solid ${palette.strongBorder}`,
|
|
18107
|
+
borderRadius: 10,
|
|
18108
|
+
display: "inline-flex",
|
|
18109
|
+
gap: 2,
|
|
18110
|
+
minHeight: 36,
|
|
18111
|
+
padding: 2
|
|
18112
|
+
},
|
|
18113
|
+
children: items.map((item) => {
|
|
18114
|
+
const selected = item.id === value;
|
|
18115
|
+
return /* @__PURE__ */ jsx3(
|
|
18116
|
+
"button",
|
|
18117
|
+
{
|
|
18118
|
+
"aria-selected": selected,
|
|
18119
|
+
onClick: () => onValueChange(item.id),
|
|
18120
|
+
role: "tab",
|
|
18121
|
+
style: {
|
|
18122
|
+
backgroundColor: selected ? palette.sheetActiveSurface : "transparent",
|
|
18123
|
+
border: "none",
|
|
18124
|
+
borderRadius: 8,
|
|
18125
|
+
boxShadow: selected ? palette.shadow : "none",
|
|
18126
|
+
color: selected ? palette.sheetActiveText : palette.sheetInactiveText,
|
|
18127
|
+
cursor: "pointer",
|
|
18128
|
+
fontSize: 12,
|
|
18129
|
+
fontWeight: selected ? 600 : 500,
|
|
18130
|
+
padding: "7px 12px",
|
|
18131
|
+
transition: "background-color 120ms ease, color 120ms ease, box-shadow 120ms ease",
|
|
18132
|
+
whiteSpace: "nowrap"
|
|
18133
|
+
},
|
|
18134
|
+
type: "button",
|
|
18135
|
+
children: item.label
|
|
18136
|
+
},
|
|
18137
|
+
item.id
|
|
18138
|
+
);
|
|
18139
|
+
})
|
|
18140
|
+
}
|
|
18141
|
+
);
|
|
18142
|
+
}
|
|
18123
18143
|
function DefaultToolbar({ controller, palette }) {
|
|
18124
18144
|
const {
|
|
18125
18145
|
activeTabIndex,
|
|
@@ -18241,19 +18261,26 @@ function DefaultToolbar({ controller, palette }) {
|
|
|
18241
18261
|
canDownload ? /* @__PURE__ */ jsx3(
|
|
18242
18262
|
"button",
|
|
18243
18263
|
{
|
|
18264
|
+
"aria-label": "Download workbook",
|
|
18244
18265
|
onClick: download,
|
|
18245
18266
|
style: {
|
|
18267
|
+
alignItems: "center",
|
|
18246
18268
|
background: palette.buttonSurface,
|
|
18247
18269
|
border: `1px solid ${palette.strongBorder}`,
|
|
18248
18270
|
borderRadius: 8,
|
|
18249
18271
|
color: palette.buttonText,
|
|
18250
18272
|
cursor: "pointer",
|
|
18251
|
-
|
|
18273
|
+
display: "inline-flex",
|
|
18274
|
+
fontSize: 16,
|
|
18252
18275
|
fontWeight: 500,
|
|
18253
|
-
|
|
18276
|
+
height: 32,
|
|
18277
|
+
justifyContent: "center",
|
|
18278
|
+
padding: 0,
|
|
18279
|
+
width: 32
|
|
18254
18280
|
},
|
|
18281
|
+
title: "Download workbook",
|
|
18255
18282
|
type: "button",
|
|
18256
|
-
children: "
|
|
18283
|
+
children: "\u2193"
|
|
18257
18284
|
}
|
|
18258
18285
|
) : null
|
|
18259
18286
|
] })
|
|
@@ -18266,32 +18293,18 @@ function DefaultToolbar({ controller, palette }) {
|
|
|
18266
18293
|
style: {
|
|
18267
18294
|
backgroundColor: palette.subtleSurface,
|
|
18268
18295
|
borderBottom: `1px solid ${palette.border}`,
|
|
18269
|
-
display: "flex",
|
|
18270
|
-
gap: 6,
|
|
18271
18296
|
overflowX: "auto",
|
|
18272
18297
|
padding: "8px 12px"
|
|
18273
18298
|
},
|
|
18274
|
-
children:
|
|
18275
|
-
|
|
18299
|
+
children: /* @__PURE__ */ jsx3(
|
|
18300
|
+
SegmentedControl,
|
|
18276
18301
|
{
|
|
18277
|
-
|
|
18278
|
-
|
|
18279
|
-
|
|
18280
|
-
|
|
18281
|
-
|
|
18282
|
-
|
|
18283
|
-
color: index === activeTabIndex ? palette.sheetActiveText : palette.sheetInactiveText,
|
|
18284
|
-
cursor: "pointer",
|
|
18285
|
-
fontSize: 12,
|
|
18286
|
-
fontWeight: 500,
|
|
18287
|
-
padding: "6px 12px",
|
|
18288
|
-
whiteSpace: "nowrap"
|
|
18289
|
-
},
|
|
18290
|
-
type: "button",
|
|
18291
|
-
children: tab.name
|
|
18292
|
-
},
|
|
18293
|
-
tab.id
|
|
18294
|
-
))
|
|
18302
|
+
items: tabs.map((tab, index) => ({ id: String(index), label: tab.name })),
|
|
18303
|
+
onValueChange: (value) => setActiveTabIndex(Number(value)),
|
|
18304
|
+
palette,
|
|
18305
|
+
value: String(activeTabIndex)
|
|
18306
|
+
}
|
|
18307
|
+
)
|
|
18295
18308
|
}
|
|
18296
18309
|
) : null
|
|
18297
18310
|
] });
|
|
@@ -21556,7 +21569,7 @@ function XlsxGrid({
|
|
|
21556
21569
|
selectionFillColor,
|
|
21557
21570
|
selectionHeaderColor
|
|
21558
21571
|
});
|
|
21559
|
-
const selectionBorderWidth = 1
|
|
21572
|
+
const selectionBorderWidth = 1;
|
|
21560
21573
|
const rowColSpan = renderedCols.length + 1 + (leadingColumnSpacerWidth > 0 ? 1 : 0) + (trailingColumnSpacerWidth > 0 ? 1 : 0);
|
|
21561
21574
|
const gutterSeparatorShadow = `inset -1px 0 0 ${palette.border}, inset 0 -1px 0 ${palette.border}`;
|
|
21562
21575
|
const headerCellStyle = {
|
|
@@ -21779,7 +21792,7 @@ function XlsxGrid({
|
|
|
21779
21792
|
"div",
|
|
21780
21793
|
{
|
|
21781
21794
|
style: {
|
|
21782
|
-
border: `
|
|
21795
|
+
border: `1px solid ${selectionStroke}`,
|
|
21783
21796
|
boxShadow: `0 0 0 1px ${palette.surface}`,
|
|
21784
21797
|
boxSizing: "border-box",
|
|
21785
21798
|
inset: 0,
|
|
@@ -21810,7 +21823,7 @@ function XlsxGrid({
|
|
|
21810
21823
|
"div",
|
|
21811
21824
|
{
|
|
21812
21825
|
style: {
|
|
21813
|
-
border: `
|
|
21826
|
+
border: `1px solid ${selectionStroke}`,
|
|
21814
21827
|
boxShadow: `0 0 0 1px ${palette.surface}`,
|
|
21815
21828
|
boxSizing: "border-box",
|
|
21816
21829
|
inset: 0,
|
|
@@ -21883,7 +21896,7 @@ function XlsxGrid({
|
|
|
21883
21896
|
"div",
|
|
21884
21897
|
{
|
|
21885
21898
|
style: {
|
|
21886
|
-
border: `
|
|
21899
|
+
border: `1px solid ${selectionStroke}`,
|
|
21887
21900
|
boxShadow: `0 0 0 1px ${palette.surface}`,
|
|
21888
21901
|
boxSizing: "border-box",
|
|
21889
21902
|
inset: 0,
|
|
@@ -22701,7 +22714,8 @@ function XlsxViewerInner({
|
|
|
22701
22714
|
emptyState,
|
|
22702
22715
|
errorState,
|
|
22703
22716
|
fileTooLargeState,
|
|
22704
|
-
height
|
|
22717
|
+
height,
|
|
22718
|
+
isDark = false,
|
|
22705
22719
|
loadingComponent,
|
|
22706
22720
|
loadingState,
|
|
22707
22721
|
renderChartLoading,
|
|
@@ -22716,15 +22730,14 @@ function XlsxViewerInner({
|
|
|
22716
22730
|
showDefaultToolbar = true,
|
|
22717
22731
|
toolbar
|
|
22718
22732
|
}) {
|
|
22719
|
-
const palette = useViewerPalette();
|
|
22720
|
-
return /* @__PURE__ */ jsx3(ViewerContext.Provider, { value: controller, children: /* @__PURE__ */ jsxs3(
|
|
22733
|
+
const palette = useViewerPalette(isDark);
|
|
22734
|
+
return /* @__PURE__ */ jsx3(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ jsx3(ViewerContext.Provider, { value: controller, children: /* @__PURE__ */ jsxs3(
|
|
22721
22735
|
"div",
|
|
22722
22736
|
{
|
|
22723
22737
|
className: classNames("react-xlsx-viewer", className),
|
|
22724
22738
|
style: {
|
|
22725
22739
|
blockSize: height,
|
|
22726
22740
|
backgroundColor: palette.surface,
|
|
22727
|
-
border: `1px solid ${palette.border}`,
|
|
22728
22741
|
borderRadius: rounded ? 12 : 0,
|
|
22729
22742
|
color: palette.text,
|
|
22730
22743
|
display: "flex",
|
|
@@ -22762,7 +22775,7 @@ function XlsxViewerInner({
|
|
|
22762
22775
|
) })
|
|
22763
22776
|
]
|
|
22764
22777
|
}
|
|
22765
|
-
) });
|
|
22778
|
+
) }) });
|
|
22766
22779
|
}
|
|
22767
22780
|
function XlsxViewerWithInlineController(props) {
|
|
22768
22781
|
const controller = useXlsxViewerController(props);
|
|
@@ -22770,16 +22783,17 @@ function XlsxViewerWithInlineController(props) {
|
|
|
22770
22783
|
}
|
|
22771
22784
|
function XlsxViewerProviderWithInlineController({
|
|
22772
22785
|
children,
|
|
22786
|
+
isDark = false,
|
|
22773
22787
|
...options
|
|
22774
22788
|
}) {
|
|
22775
22789
|
const controller = useXlsxViewerController(options);
|
|
22776
|
-
return /* @__PURE__ */ jsx3(ViewerContext.Provider, { value: controller, children });
|
|
22790
|
+
return /* @__PURE__ */ jsx3(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ jsx3(ViewerContext.Provider, { value: controller, children }) });
|
|
22777
22791
|
}
|
|
22778
|
-
function XlsxViewerProvider({ children, controller, ...options }) {
|
|
22792
|
+
function XlsxViewerProvider({ children, controller, isDark = false, ...options }) {
|
|
22779
22793
|
if (controller) {
|
|
22780
|
-
return /* @__PURE__ */ jsx3(ViewerContext.Provider, { value: controller, children });
|
|
22794
|
+
return /* @__PURE__ */ jsx3(ViewerAppearanceContext.Provider, { value: { isDark }, children: /* @__PURE__ */ jsx3(ViewerContext.Provider, { value: controller, children }) });
|
|
22781
22795
|
}
|
|
22782
|
-
return /* @__PURE__ */ jsx3(XlsxViewerProviderWithInlineController, { ...options, children });
|
|
22796
|
+
return /* @__PURE__ */ jsx3(XlsxViewerProviderWithInlineController, { ...options, isDark, children });
|
|
22783
22797
|
}
|
|
22784
22798
|
function useXlsxViewer() {
|
|
22785
22799
|
const context = React4.useContext(ViewerContext);
|
|
@@ -23105,7 +23119,8 @@ function XlsxViewer(props) {
|
|
|
23105
23119
|
}
|
|
23106
23120
|
function DefaultXlsxToolbar() {
|
|
23107
23121
|
const controller = useXlsxViewer();
|
|
23108
|
-
const
|
|
23122
|
+
const { isDark } = React4.useContext(ViewerAppearanceContext);
|
|
23123
|
+
const palette = useViewerPalette(isDark);
|
|
23109
23124
|
return /* @__PURE__ */ jsx3(DefaultToolbar, { controller, palette });
|
|
23110
23125
|
}
|
|
23111
23126
|
export {
|