sheet-widget 0.1.4 → 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.js +27 -21
- package/dist/index.mjs +28 -22
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -37208,19 +37208,21 @@ function WidgetNode({ id, data }) {
|
|
|
37208
37208
|
var _a, _b;
|
|
37209
37209
|
const info = data == null ? void 0 : data.info;
|
|
37210
37210
|
const table = data == null ? void 0 : data.table;
|
|
37211
|
+
const [localTable, setLocalTable] = (0, import_react3.useState)(null);
|
|
37211
37212
|
const widgetId = (_a = data == null ? void 0 : data.widgetId) != null ? _a : info == null ? void 0 : info.widgetId;
|
|
37212
|
-
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");
|
|
37213
37215
|
const [newTitle, setNewTitle] = (0, import_react3.useState)("\u041D\u043E\u0432\u0430\u044F \u0442\u0430\u0431\u043B\u0438\u0446\u0430");
|
|
37214
37216
|
const [rowsCount, setRowsCount] = (0, import_react3.useState)(10);
|
|
37215
37217
|
const [colsCount, setColsCount] = (0, import_react3.useState)(8);
|
|
37216
37218
|
const [isCreating, setIsCreating] = (0, import_react3.useState)(false);
|
|
37217
|
-
const
|
|
37219
|
+
const externalSetNodes = typeof (data == null ? void 0 : data.setNodes) === "function" ? data.setNodes : null;
|
|
37218
37220
|
const lastSyncedConfig = (0, import_react3.useRef)(null);
|
|
37219
37221
|
(0, import_react3.useEffect)(() => {
|
|
37220
|
-
if (!widgetId || !(
|
|
37222
|
+
if (!widgetId || !(effectiveTable == null ? void 0 : effectiveTable.id)) {
|
|
37221
37223
|
return;
|
|
37222
37224
|
}
|
|
37223
|
-
const nextConfig = { tableId:
|
|
37225
|
+
const nextConfig = { tableId: effectiveTable.id };
|
|
37224
37226
|
const serialized = JSON.stringify(nextConfig);
|
|
37225
37227
|
if (lastSyncedConfig.current === serialized) {
|
|
37226
37228
|
return;
|
|
@@ -37229,10 +37231,10 @@ function WidgetNode({ id, data }) {
|
|
|
37229
37231
|
import_axios2.default.put(`${WIDGET_CONFIG_API}${widgetId}`, nextConfig).catch((error) => {
|
|
37230
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);
|
|
37231
37233
|
});
|
|
37232
|
-
}, [
|
|
37234
|
+
}, [effectiveTable == null ? void 0 : effectiveTable.id, widgetId]);
|
|
37233
37235
|
(0, import_react3.useEffect)(() => {
|
|
37234
|
-
setTableTitle((
|
|
37235
|
-
}, [
|
|
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]);
|
|
37236
37238
|
const handleCreateTable = async (titleOverride, rowsOverride, colsOverride) => {
|
|
37237
37239
|
var _a2;
|
|
37238
37240
|
const titleValue = typeof titleOverride === "string" ? titleOverride : newTitle;
|
|
@@ -37252,17 +37254,21 @@ function WidgetNode({ id, data }) {
|
|
|
37252
37254
|
title: titleValue,
|
|
37253
37255
|
data: { rows: emptyRows }
|
|
37254
37256
|
});
|
|
37255
|
-
|
|
37256
|
-
(
|
|
37257
|
-
(
|
|
37258
|
-
|
|
37259
|
-
|
|
37260
|
-
|
|
37261
|
-
|
|
37262
|
-
|
|
37263
|
-
|
|
37264
|
-
|
|
37265
|
-
|
|
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
|
+
}
|
|
37266
37272
|
setTableTitle(((_a2 = response.data) == null ? void 0 : _a2.title) || titleValue);
|
|
37267
37273
|
} catch (error) {
|
|
37268
37274
|
console.error(error);
|
|
@@ -37272,11 +37278,11 @@ function WidgetNode({ id, data }) {
|
|
|
37272
37278
|
}
|
|
37273
37279
|
};
|
|
37274
37280
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: containerStyle, children: [
|
|
37275
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: titleStyle, className: "node-drag-handle", children:
|
|
37276
|
-
|
|
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)(
|
|
37277
37283
|
TableEditor_default,
|
|
37278
37284
|
{
|
|
37279
|
-
id:
|
|
37285
|
+
id: effectiveTable.id,
|
|
37280
37286
|
compactMode: true,
|
|
37281
37287
|
showCompactControls: true,
|
|
37282
37288
|
onTitleChange: setTableTitle
|
package/dist/index.mjs
CHANGED
|
@@ -8126,7 +8126,7 @@ import React3 from "react";
|
|
|
8126
8126
|
// src/WidgetNode.js
|
|
8127
8127
|
import React2, { useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
8128
8128
|
import axios2 from "axios";
|
|
8129
|
-
import { Handle, Position
|
|
8129
|
+
import { Handle, Position } from "@xyflow/react";
|
|
8130
8130
|
|
|
8131
8131
|
// src/TableEditor.js
|
|
8132
8132
|
import React, { useEffect, useState, useRef } from "react";
|
|
@@ -37199,19 +37199,21 @@ function WidgetNode({ id, data }) {
|
|
|
37199
37199
|
var _a, _b;
|
|
37200
37200
|
const info = data == null ? void 0 : data.info;
|
|
37201
37201
|
const table = data == null ? void 0 : data.table;
|
|
37202
|
+
const [localTable, setLocalTable] = useState2(null);
|
|
37202
37203
|
const widgetId = (_a = data == null ? void 0 : data.widgetId) != null ? _a : info == null ? void 0 : info.widgetId;
|
|
37203
|
-
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");
|
|
37204
37206
|
const [newTitle, setNewTitle] = useState2("\u041D\u043E\u0432\u0430\u044F \u0442\u0430\u0431\u043B\u0438\u0446\u0430");
|
|
37205
37207
|
const [rowsCount, setRowsCount] = useState2(10);
|
|
37206
37208
|
const [colsCount, setColsCount] = useState2(8);
|
|
37207
37209
|
const [isCreating, setIsCreating] = useState2(false);
|
|
37208
|
-
const
|
|
37210
|
+
const externalSetNodes = typeof (data == null ? void 0 : data.setNodes) === "function" ? data.setNodes : null;
|
|
37209
37211
|
const lastSyncedConfig = useRef2(null);
|
|
37210
37212
|
useEffect2(() => {
|
|
37211
|
-
if (!widgetId || !(
|
|
37213
|
+
if (!widgetId || !(effectiveTable == null ? void 0 : effectiveTable.id)) {
|
|
37212
37214
|
return;
|
|
37213
37215
|
}
|
|
37214
|
-
const nextConfig = { tableId:
|
|
37216
|
+
const nextConfig = { tableId: effectiveTable.id };
|
|
37215
37217
|
const serialized = JSON.stringify(nextConfig);
|
|
37216
37218
|
if (lastSyncedConfig.current === serialized) {
|
|
37217
37219
|
return;
|
|
@@ -37220,10 +37222,10 @@ function WidgetNode({ id, data }) {
|
|
|
37220
37222
|
axios2.put(`${WIDGET_CONFIG_API}${widgetId}`, nextConfig).catch((error) => {
|
|
37221
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);
|
|
37222
37224
|
});
|
|
37223
|
-
}, [
|
|
37225
|
+
}, [effectiveTable == null ? void 0 : effectiveTable.id, widgetId]);
|
|
37224
37226
|
useEffect2(() => {
|
|
37225
|
-
setTableTitle((
|
|
37226
|
-
}, [
|
|
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]);
|
|
37227
37229
|
const handleCreateTable = async (titleOverride, rowsOverride, colsOverride) => {
|
|
37228
37230
|
var _a2;
|
|
37229
37231
|
const titleValue = typeof titleOverride === "string" ? titleOverride : newTitle;
|
|
@@ -37243,17 +37245,21 @@ function WidgetNode({ id, data }) {
|
|
|
37243
37245
|
title: titleValue,
|
|
37244
37246
|
data: { rows: emptyRows }
|
|
37245
37247
|
});
|
|
37246
|
-
|
|
37247
|
-
(
|
|
37248
|
-
(
|
|
37249
|
-
|
|
37250
|
-
|
|
37251
|
-
|
|
37252
|
-
|
|
37253
|
-
|
|
37254
|
-
|
|
37255
|
-
|
|
37256
|
-
|
|
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
|
+
}
|
|
37257
37263
|
setTableTitle(((_a2 = response.data) == null ? void 0 : _a2.title) || titleValue);
|
|
37258
37264
|
} catch (error) {
|
|
37259
37265
|
console.error(error);
|
|
@@ -37263,11 +37269,11 @@ function WidgetNode({ id, data }) {
|
|
|
37263
37269
|
}
|
|
37264
37270
|
};
|
|
37265
37271
|
return /* @__PURE__ */ jsxs2("div", { style: containerStyle, children: [
|
|
37266
|
-
/* @__PURE__ */ jsx2("div", { style: titleStyle, className: "node-drag-handle", children:
|
|
37267
|
-
|
|
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(
|
|
37268
37274
|
TableEditor_default,
|
|
37269
37275
|
{
|
|
37270
|
-
id:
|
|
37276
|
+
id: effectiveTable.id,
|
|
37271
37277
|
compactMode: true,
|
|
37272
37278
|
showCompactControls: true,
|
|
37273
37279
|
onTitleChange: setTableTitle
|