@canvas-components/react-pivot-table 0.2.16 → 0.2.17
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 +57 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +58 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -692,6 +692,58 @@ function DataFormatMenu(props) {
|
|
|
692
692
|
}
|
|
693
693
|
);
|
|
694
694
|
}
|
|
695
|
+
function PivotExportNameDialog({
|
|
696
|
+
request
|
|
697
|
+
}) {
|
|
698
|
+
const extension = request.fileName.match(/\.(xlsx|csv)$/i)?.[0] ?? "";
|
|
699
|
+
const [fileName, setFileName] = react.useState(
|
|
700
|
+
extension ? request.fileName.slice(0, -extension.length) : request.fileName
|
|
701
|
+
);
|
|
702
|
+
const [invalid, setInvalid] = react.useState(false);
|
|
703
|
+
const confirm = () => {
|
|
704
|
+
if (!fileName.trim()) {
|
|
705
|
+
setInvalid(true);
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
request.onConfirm(`${fileName.trim()}${extension}`);
|
|
709
|
+
};
|
|
710
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
711
|
+
reactComponents.ReactModal,
|
|
712
|
+
{
|
|
713
|
+
open: true,
|
|
714
|
+
title: "\u5BFC\u51FA\u6587\u4EF6",
|
|
715
|
+
width: 420,
|
|
716
|
+
fullscreenable: false,
|
|
717
|
+
onCancel: request.onCancel,
|
|
718
|
+
onOk: confirm,
|
|
719
|
+
okText: "\u5BFC\u51FA",
|
|
720
|
+
cancelText: "\u53D6\u6D88",
|
|
721
|
+
children: [
|
|
722
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
|
|
723
|
+
"\u6587\u4EF6\u540D\u79F0",
|
|
724
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
|
|
725
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
726
|
+
reactComponents.ReactInput,
|
|
727
|
+
{
|
|
728
|
+
autoFocus: true,
|
|
729
|
+
value: fileName,
|
|
730
|
+
placeholder: "\u8BF7\u8F93\u5165\u6587\u4EF6\u540D\u79F0",
|
|
731
|
+
onFocus: (event) => event.target.select(),
|
|
732
|
+
onChange: (event) => {
|
|
733
|
+
setFileName(event.target.value);
|
|
734
|
+
setInvalid(false);
|
|
735
|
+
},
|
|
736
|
+
onPressEnter: confirm
|
|
737
|
+
}
|
|
738
|
+
),
|
|
739
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "aria-label": "\u6587\u4EF6\u540E\u7F00", style: { flexShrink: 0 }, children: extension })
|
|
740
|
+
] })
|
|
741
|
+
] }),
|
|
742
|
+
invalid ? /* @__PURE__ */ jsxRuntime.jsx("div", { role: "alert", style: { color: "#ff4d4f", marginTop: 8 }, children: "\u8BF7\u8F93\u5165\u6587\u4EF6\u540D\u79F0" }) : null
|
|
743
|
+
]
|
|
744
|
+
}
|
|
745
|
+
);
|
|
746
|
+
}
|
|
695
747
|
function PivotTooltip(props) {
|
|
696
748
|
const { request } = props;
|
|
697
749
|
if (!request) return null;
|
|
@@ -1712,6 +1764,7 @@ function ReactPivotTableInner(props, ref) {
|
|
|
1712
1764
|
const [densityOverride, setDensityOverride] = react.useState(null);
|
|
1713
1765
|
const [filterRequest, setFilterRequest] = react.useState(null);
|
|
1714
1766
|
const [contextMenuRequest, setContextMenuRequest] = react.useState(null);
|
|
1767
|
+
const [exportNameRequest, setExportNameRequest] = react.useState(null);
|
|
1715
1768
|
const [tooltipRequest, setTooltipRequest] = react.useState(null);
|
|
1716
1769
|
const panelOpen = customizationOptions?.open ?? internalPanelOpen;
|
|
1717
1770
|
const fieldLayout = customizationOptions?.layout ?? internalLayout;
|
|
@@ -1790,6 +1843,9 @@ function ReactPivotTableInner(props, ref) {
|
|
|
1790
1843
|
rowHeight: densityOverride == null ? tableOptions.rowHeight : resolveDensityRowHeight(densityOverride),
|
|
1791
1844
|
indicators: customizedOptions?.indicators ?? overriddenIndicators,
|
|
1792
1845
|
ui: {
|
|
1846
|
+
onExportNameRequest: (request) => {
|
|
1847
|
+
setExportNameRequest(request);
|
|
1848
|
+
},
|
|
1793
1849
|
onFilterPanelRequest: setFilterRequest,
|
|
1794
1850
|
onContextMenuRequest: (request) => {
|
|
1795
1851
|
if (request) {
|
|
@@ -2065,6 +2121,7 @@ function ReactPivotTableInner(props, ref) {
|
|
|
2065
2121
|
),
|
|
2066
2122
|
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.ReactFilterPanel, { request: sharedFilterRequest }),
|
|
2067
2123
|
/* @__PURE__ */ jsxRuntime.jsx(PivotContextMenu, { request: contextMenuRequest }),
|
|
2124
|
+
exportNameRequest ? /* @__PURE__ */ jsxRuntime.jsx(PivotExportNameDialog, { request: exportNameRequest }) : null,
|
|
2068
2125
|
/* @__PURE__ */ jsxRuntime.jsx(PivotTooltip, { request: tooltipRequest })
|
|
2069
2126
|
] });
|
|
2070
2127
|
}
|