sheet-widget 0.1.3 → 0.1.5
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.d.mts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +37 -26
- package/dist/index.mjs +36 -26
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -16,6 +16,11 @@ declare class WidgetNodeErrorBoundary {
|
|
|
16
16
|
componentDidCatch(error: any, errorInfo: any): void;
|
|
17
17
|
render(): any;
|
|
18
18
|
}
|
|
19
|
-
declare function WidgetNodeSafe(props
|
|
19
|
+
declare function WidgetNodeSafe({ fallback, onError, ...props }: {
|
|
20
|
+
[x: string]: any;
|
|
21
|
+
fallback: any;
|
|
22
|
+
onError: any;
|
|
23
|
+
}): any;
|
|
24
|
+
declare const WidgetNodeUnsafe: typeof WidgetNode;
|
|
20
25
|
|
|
21
|
-
export { WidgetNode, WidgetNodeErrorBoundary, WidgetNodeSafe };
|
|
26
|
+
export { WidgetNodeSafe as WidgetNode, WidgetNodeErrorBoundary, WidgetNodeSafe, WidgetNodeUnsafe };
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,11 @@ declare class WidgetNodeErrorBoundary {
|
|
|
16
16
|
componentDidCatch(error: any, errorInfo: any): void;
|
|
17
17
|
render(): any;
|
|
18
18
|
}
|
|
19
|
-
declare function WidgetNodeSafe(props
|
|
19
|
+
declare function WidgetNodeSafe({ fallback, onError, ...props }: {
|
|
20
|
+
[x: string]: any;
|
|
21
|
+
fallback: any;
|
|
22
|
+
onError: any;
|
|
23
|
+
}): any;
|
|
24
|
+
declare const WidgetNodeUnsafe: typeof WidgetNode;
|
|
20
25
|
|
|
21
|
-
export { WidgetNode, WidgetNodeErrorBoundary, WidgetNodeSafe };
|
|
26
|
+
export { WidgetNodeSafe as WidgetNode, WidgetNodeErrorBoundary, WidgetNodeSafe, WidgetNodeUnsafe };
|
package/dist/index.js
CHANGED
|
@@ -8121,13 +8121,17 @@ var require_tiny_emitter = __commonJS({
|
|
|
8121
8121
|
// src/index.js
|
|
8122
8122
|
var index_exports = {};
|
|
8123
8123
|
__export(index_exports, {
|
|
8124
|
-
WidgetNode: () =>
|
|
8124
|
+
WidgetNode: () => WidgetNodeSafe,
|
|
8125
8125
|
WidgetNodeErrorBoundary: () => WidgetNodeErrorBoundary,
|
|
8126
|
-
WidgetNodeSafe: () => WidgetNodeSafe
|
|
8126
|
+
WidgetNodeSafe: () => WidgetNodeSafe,
|
|
8127
|
+
WidgetNodeUnsafe: () => WidgetNodeUnsafe
|
|
8127
8128
|
});
|
|
8128
8129
|
module.exports = __toCommonJS(index_exports);
|
|
8129
8130
|
var import_handsontable_full_min = require("handsontable/dist/handsontable.full.min.css");
|
|
8130
8131
|
|
|
8132
|
+
// src/WidgetNodeSafe.js
|
|
8133
|
+
var import_react5 = __toESM(require("react"));
|
|
8134
|
+
|
|
8131
8135
|
// src/WidgetNode.js
|
|
8132
8136
|
var import_react3 = __toESM(require("react"));
|
|
8133
8137
|
var import_axios2 = __toESM(require("axios"));
|
|
@@ -37204,19 +37208,21 @@ function WidgetNode({ id, data }) {
|
|
|
37204
37208
|
var _a, _b;
|
|
37205
37209
|
const info = data == null ? void 0 : data.info;
|
|
37206
37210
|
const table = data == null ? void 0 : data.table;
|
|
37211
|
+
const [localTable, setLocalTable] = (0, import_react3.useState)(null);
|
|
37207
37212
|
const widgetId = (_a = data == null ? void 0 : data.widgetId) != null ? _a : info == null ? void 0 : info.widgetId;
|
|
37208
|
-
const
|
|
37213
|
+
const effectiveTable = localTable != null ? localTable : table;
|
|
37214
|
+
const [tableTitle, setTableTitle] = (0, import_react3.useState)((effectiveTable == null ? void 0 : effectiveTable.title) || "\u0411\u0435\u0437 \u043D\u0430\u0437\u0432\u0430\u043D\u0438\u044F");
|
|
37209
37215
|
const [newTitle, setNewTitle] = (0, import_react3.useState)("\u041D\u043E\u0432\u0430\u044F \u0442\u0430\u0431\u043B\u0438\u0446\u0430");
|
|
37210
37216
|
const [rowsCount, setRowsCount] = (0, import_react3.useState)(10);
|
|
37211
37217
|
const [colsCount, setColsCount] = (0, import_react3.useState)(8);
|
|
37212
37218
|
const [isCreating, setIsCreating] = (0, import_react3.useState)(false);
|
|
37213
|
-
const
|
|
37219
|
+
const externalSetNodes = typeof (data == null ? void 0 : data.setNodes) === "function" ? data.setNodes : null;
|
|
37214
37220
|
const lastSyncedConfig = (0, import_react3.useRef)(null);
|
|
37215
37221
|
(0, import_react3.useEffect)(() => {
|
|
37216
|
-
if (!widgetId || !(
|
|
37222
|
+
if (!widgetId || !(effectiveTable == null ? void 0 : effectiveTable.id)) {
|
|
37217
37223
|
return;
|
|
37218
37224
|
}
|
|
37219
|
-
const nextConfig = { tableId:
|
|
37225
|
+
const nextConfig = { tableId: effectiveTable.id };
|
|
37220
37226
|
const serialized = JSON.stringify(nextConfig);
|
|
37221
37227
|
if (lastSyncedConfig.current === serialized) {
|
|
37222
37228
|
return;
|
|
@@ -37225,10 +37231,10 @@ function WidgetNode({ id, data }) {
|
|
|
37225
37231
|
import_axios2.default.put(`${WIDGET_CONFIG_API}${widgetId}`, nextConfig).catch((error) => {
|
|
37226
37232
|
console.error("\u041E\u0448\u0438\u0431\u043A\u0430 \u0441\u0438\u043D\u0445\u0440\u043E\u043D\u0438\u0437\u0430\u0446\u0438\u0438 \u043A\u043E\u043D\u0444\u0438\u0433\u0430 \u0432\u0438\u0434\u0436\u0435\u0442\u0430:", error);
|
|
37227
37233
|
});
|
|
37228
|
-
}, [
|
|
37234
|
+
}, [effectiveTable == null ? void 0 : effectiveTable.id, widgetId]);
|
|
37229
37235
|
(0, import_react3.useEffect)(() => {
|
|
37230
|
-
setTableTitle((
|
|
37231
|
-
}, [
|
|
37236
|
+
setTableTitle((effectiveTable == null ? void 0 : effectiveTable.title) || "\u0411\u0435\u0437 \u043D\u0430\u0437\u0432\u0430\u043D\u0438\u044F");
|
|
37237
|
+
}, [effectiveTable == null ? void 0 : effectiveTable.title]);
|
|
37232
37238
|
const handleCreateTable = async (titleOverride, rowsOverride, colsOverride) => {
|
|
37233
37239
|
var _a2;
|
|
37234
37240
|
const titleValue = typeof titleOverride === "string" ? titleOverride : newTitle;
|
|
@@ -37248,17 +37254,21 @@ function WidgetNode({ id, data }) {
|
|
|
37248
37254
|
title: titleValue,
|
|
37249
37255
|
data: { rows: emptyRows }
|
|
37250
37256
|
});
|
|
37251
|
-
|
|
37252
|
-
(
|
|
37253
|
-
(
|
|
37254
|
-
|
|
37255
|
-
|
|
37256
|
-
|
|
37257
|
-
|
|
37258
|
-
|
|
37259
|
-
|
|
37260
|
-
|
|
37261
|
-
|
|
37257
|
+
if (externalSetNodes) {
|
|
37258
|
+
externalSetNodes(
|
|
37259
|
+
(current) => current.map(
|
|
37260
|
+
(node) => node.id === id ? {
|
|
37261
|
+
...node,
|
|
37262
|
+
data: {
|
|
37263
|
+
...node.data,
|
|
37264
|
+
table: response.data
|
|
37265
|
+
}
|
|
37266
|
+
} : node
|
|
37267
|
+
)
|
|
37268
|
+
);
|
|
37269
|
+
} else {
|
|
37270
|
+
setLocalTable(response.data);
|
|
37271
|
+
}
|
|
37262
37272
|
setTableTitle(((_a2 = response.data) == null ? void 0 : _a2.title) || titleValue);
|
|
37263
37273
|
} catch (error) {
|
|
37264
37274
|
console.error(error);
|
|
@@ -37268,11 +37278,11 @@ function WidgetNode({ id, data }) {
|
|
|
37268
37278
|
}
|
|
37269
37279
|
};
|
|
37270
37280
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: containerStyle, children: [
|
|
37271
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: titleStyle, className: "node-drag-handle", children:
|
|
37272
|
-
|
|
37281
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: titleStyle, className: "node-drag-handle", children: effectiveTable ? tableTitle : (data == null ? void 0 : data.title) || "\u041D\u043E\u0432\u044B\u0439 \u0432\u0438\u0434\u0436\u0435\u0442" }),
|
|
37282
|
+
effectiveTable ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: editorContainerStyle, className: "nodrag", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
37273
37283
|
TableEditor_default,
|
|
37274
37284
|
{
|
|
37275
|
-
id:
|
|
37285
|
+
id: effectiveTable.id,
|
|
37276
37286
|
compactMode: true,
|
|
37277
37287
|
showCompactControls: true,
|
|
37278
37288
|
onTitleChange: setTableTitle
|
|
@@ -37363,7 +37373,6 @@ function WidgetNode({ id, data }) {
|
|
|
37363
37373
|
var WidgetNode_default = WidgetNode;
|
|
37364
37374
|
|
|
37365
37375
|
// src/WidgetNodeSafe.js
|
|
37366
|
-
var import_react5 = __toESM(require("react"));
|
|
37367
37376
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
37368
37377
|
var WidgetNodeErrorBoundary = class extends import_react5.default.Component {
|
|
37369
37378
|
constructor(props) {
|
|
@@ -37393,12 +37402,14 @@ var WidgetNodeErrorBoundary = class extends import_react5.default.Component {
|
|
|
37393
37402
|
return this.props.children;
|
|
37394
37403
|
}
|
|
37395
37404
|
};
|
|
37396
|
-
var WidgetNodeSafe = (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(WidgetNodeErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(WidgetNode_default, { ...props }) });
|
|
37405
|
+
var WidgetNodeSafe = ({ fallback, onError, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(WidgetNodeErrorBoundary, { fallback, onError, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(WidgetNode_default, { ...props }) });
|
|
37406
|
+
var WidgetNodeUnsafe = WidgetNode_default;
|
|
37397
37407
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37398
37408
|
0 && (module.exports = {
|
|
37399
37409
|
WidgetNode,
|
|
37400
37410
|
WidgetNodeErrorBoundary,
|
|
37401
|
-
WidgetNodeSafe
|
|
37411
|
+
WidgetNodeSafe,
|
|
37412
|
+
WidgetNodeUnsafe
|
|
37402
37413
|
});
|
|
37403
37414
|
/*! Bundled license information:
|
|
37404
37415
|
|
package/dist/index.mjs
CHANGED
|
@@ -8120,10 +8120,13 @@ var require_tiny_emitter = __commonJS({
|
|
|
8120
8120
|
// src/index.js
|
|
8121
8121
|
import "handsontable/dist/handsontable.full.min.css";
|
|
8122
8122
|
|
|
8123
|
+
// src/WidgetNodeSafe.js
|
|
8124
|
+
import React3 from "react";
|
|
8125
|
+
|
|
8123
8126
|
// src/WidgetNode.js
|
|
8124
8127
|
import React2, { useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
8125
8128
|
import axios2 from "axios";
|
|
8126
|
-
import { Handle, Position
|
|
8129
|
+
import { Handle, Position } from "@xyflow/react";
|
|
8127
8130
|
|
|
8128
8131
|
// src/TableEditor.js
|
|
8129
8132
|
import React, { useEffect, useState, useRef } from "react";
|
|
@@ -37196,19 +37199,21 @@ function WidgetNode({ id, data }) {
|
|
|
37196
37199
|
var _a, _b;
|
|
37197
37200
|
const info = data == null ? void 0 : data.info;
|
|
37198
37201
|
const table = data == null ? void 0 : data.table;
|
|
37202
|
+
const [localTable, setLocalTable] = useState2(null);
|
|
37199
37203
|
const widgetId = (_a = data == null ? void 0 : data.widgetId) != null ? _a : info == null ? void 0 : info.widgetId;
|
|
37200
|
-
const
|
|
37204
|
+
const effectiveTable = localTable != null ? localTable : table;
|
|
37205
|
+
const [tableTitle, setTableTitle] = useState2((effectiveTable == null ? void 0 : effectiveTable.title) || "\u0411\u0435\u0437 \u043D\u0430\u0437\u0432\u0430\u043D\u0438\u044F");
|
|
37201
37206
|
const [newTitle, setNewTitle] = useState2("\u041D\u043E\u0432\u0430\u044F \u0442\u0430\u0431\u043B\u0438\u0446\u0430");
|
|
37202
37207
|
const [rowsCount, setRowsCount] = useState2(10);
|
|
37203
37208
|
const [colsCount, setColsCount] = useState2(8);
|
|
37204
37209
|
const [isCreating, setIsCreating] = useState2(false);
|
|
37205
|
-
const
|
|
37210
|
+
const externalSetNodes = typeof (data == null ? void 0 : data.setNodes) === "function" ? data.setNodes : null;
|
|
37206
37211
|
const lastSyncedConfig = useRef2(null);
|
|
37207
37212
|
useEffect2(() => {
|
|
37208
|
-
if (!widgetId || !(
|
|
37213
|
+
if (!widgetId || !(effectiveTable == null ? void 0 : effectiveTable.id)) {
|
|
37209
37214
|
return;
|
|
37210
37215
|
}
|
|
37211
|
-
const nextConfig = { tableId:
|
|
37216
|
+
const nextConfig = { tableId: effectiveTable.id };
|
|
37212
37217
|
const serialized = JSON.stringify(nextConfig);
|
|
37213
37218
|
if (lastSyncedConfig.current === serialized) {
|
|
37214
37219
|
return;
|
|
@@ -37217,10 +37222,10 @@ function WidgetNode({ id, data }) {
|
|
|
37217
37222
|
axios2.put(`${WIDGET_CONFIG_API}${widgetId}`, nextConfig).catch((error) => {
|
|
37218
37223
|
console.error("\u041E\u0448\u0438\u0431\u043A\u0430 \u0441\u0438\u043D\u0445\u0440\u043E\u043D\u0438\u0437\u0430\u0446\u0438\u0438 \u043A\u043E\u043D\u0444\u0438\u0433\u0430 \u0432\u0438\u0434\u0436\u0435\u0442\u0430:", error);
|
|
37219
37224
|
});
|
|
37220
|
-
}, [
|
|
37225
|
+
}, [effectiveTable == null ? void 0 : effectiveTable.id, widgetId]);
|
|
37221
37226
|
useEffect2(() => {
|
|
37222
|
-
setTableTitle((
|
|
37223
|
-
}, [
|
|
37227
|
+
setTableTitle((effectiveTable == null ? void 0 : effectiveTable.title) || "\u0411\u0435\u0437 \u043D\u0430\u0437\u0432\u0430\u043D\u0438\u044F");
|
|
37228
|
+
}, [effectiveTable == null ? void 0 : effectiveTable.title]);
|
|
37224
37229
|
const handleCreateTable = async (titleOverride, rowsOverride, colsOverride) => {
|
|
37225
37230
|
var _a2;
|
|
37226
37231
|
const titleValue = typeof titleOverride === "string" ? titleOverride : newTitle;
|
|
@@ -37240,17 +37245,21 @@ function WidgetNode({ id, data }) {
|
|
|
37240
37245
|
title: titleValue,
|
|
37241
37246
|
data: { rows: emptyRows }
|
|
37242
37247
|
});
|
|
37243
|
-
|
|
37244
|
-
(
|
|
37245
|
-
(
|
|
37246
|
-
|
|
37247
|
-
|
|
37248
|
-
|
|
37249
|
-
|
|
37250
|
-
|
|
37251
|
-
|
|
37252
|
-
|
|
37253
|
-
|
|
37248
|
+
if (externalSetNodes) {
|
|
37249
|
+
externalSetNodes(
|
|
37250
|
+
(current) => current.map(
|
|
37251
|
+
(node) => node.id === id ? {
|
|
37252
|
+
...node,
|
|
37253
|
+
data: {
|
|
37254
|
+
...node.data,
|
|
37255
|
+
table: response.data
|
|
37256
|
+
}
|
|
37257
|
+
} : node
|
|
37258
|
+
)
|
|
37259
|
+
);
|
|
37260
|
+
} else {
|
|
37261
|
+
setLocalTable(response.data);
|
|
37262
|
+
}
|
|
37254
37263
|
setTableTitle(((_a2 = response.data) == null ? void 0 : _a2.title) || titleValue);
|
|
37255
37264
|
} catch (error) {
|
|
37256
37265
|
console.error(error);
|
|
@@ -37260,11 +37269,11 @@ function WidgetNode({ id, data }) {
|
|
|
37260
37269
|
}
|
|
37261
37270
|
};
|
|
37262
37271
|
return /* @__PURE__ */ jsxs2("div", { style: containerStyle, children: [
|
|
37263
|
-
/* @__PURE__ */ jsx2("div", { style: titleStyle, className: "node-drag-handle", children:
|
|
37264
|
-
|
|
37272
|
+
/* @__PURE__ */ jsx2("div", { style: titleStyle, className: "node-drag-handle", children: effectiveTable ? tableTitle : (data == null ? void 0 : data.title) || "\u041D\u043E\u0432\u044B\u0439 \u0432\u0438\u0434\u0436\u0435\u0442" }),
|
|
37273
|
+
effectiveTable ? /* @__PURE__ */ jsx2(Fragment2, { children: /* @__PURE__ */ jsx2("div", { style: editorContainerStyle, className: "nodrag", children: /* @__PURE__ */ jsx2(
|
|
37265
37274
|
TableEditor_default,
|
|
37266
37275
|
{
|
|
37267
|
-
id:
|
|
37276
|
+
id: effectiveTable.id,
|
|
37268
37277
|
compactMode: true,
|
|
37269
37278
|
showCompactControls: true,
|
|
37270
37279
|
onTitleChange: setTableTitle
|
|
@@ -37355,7 +37364,6 @@ function WidgetNode({ id, data }) {
|
|
|
37355
37364
|
var WidgetNode_default = WidgetNode;
|
|
37356
37365
|
|
|
37357
37366
|
// src/WidgetNodeSafe.js
|
|
37358
|
-
import React3 from "react";
|
|
37359
37367
|
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
37360
37368
|
var WidgetNodeErrorBoundary = class extends React3.Component {
|
|
37361
37369
|
constructor(props) {
|
|
@@ -37385,11 +37393,13 @@ var WidgetNodeErrorBoundary = class extends React3.Component {
|
|
|
37385
37393
|
return this.props.children;
|
|
37386
37394
|
}
|
|
37387
37395
|
};
|
|
37388
|
-
var WidgetNodeSafe = (props) => /* @__PURE__ */ jsx3(WidgetNodeErrorBoundary, { children: /* @__PURE__ */ jsx3(WidgetNode_default, { ...props }) });
|
|
37396
|
+
var WidgetNodeSafe = ({ fallback, onError, ...props }) => /* @__PURE__ */ jsx3(WidgetNodeErrorBoundary, { fallback, onError, children: /* @__PURE__ */ jsx3(WidgetNode_default, { ...props }) });
|
|
37397
|
+
var WidgetNodeUnsafe = WidgetNode_default;
|
|
37389
37398
|
export {
|
|
37390
|
-
|
|
37399
|
+
WidgetNodeSafe as WidgetNode,
|
|
37391
37400
|
WidgetNodeErrorBoundary,
|
|
37392
|
-
WidgetNodeSafe
|
|
37401
|
+
WidgetNodeSafe,
|
|
37402
|
+
WidgetNodeUnsafe
|
|
37393
37403
|
};
|
|
37394
37404
|
/*! Bundled license information:
|
|
37395
37405
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sheet-widget",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"files": ["dist"],
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"@xyflow/react": "^12.10.0",
|
|
20
|
-
"react": "^19.
|
|
21
|
-
"react-dom": "^19.
|
|
20
|
+
"react": "^19.0.0",
|
|
21
|
+
"react-dom": "^19.0.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@testing-library/dom": "^10.4.1",
|