@uniformdev/mesh-sdk-react 20.71.2-alpha.10 → 20.71.2-alpha.14
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.esm.js +45 -13
- package/dist/index.js +43 -12
- package/dist/index.mjs +45 -13
- package/package.json +6 -6
package/dist/index.esm.js
CHANGED
|
@@ -685,7 +685,8 @@ import {
|
|
|
685
685
|
$isNodeSelection,
|
|
686
686
|
$setSelection,
|
|
687
687
|
COMMAND_PRIORITY_NORMAL,
|
|
688
|
-
createCommand
|
|
688
|
+
createCommand,
|
|
689
|
+
SKIP_DOM_SELECTION_TAG
|
|
689
690
|
} from "lexical";
|
|
690
691
|
import { useCallback as useCallback2, useEffect as useEffect4, useMemo as useMemo6, useRef as useRef3, useState as useState4 } from "react";
|
|
691
692
|
import { createPortal } from "react-dom";
|
|
@@ -1147,6 +1148,11 @@ var DISCONNECT_VARIABLE_COMMAND = createCommand(
|
|
|
1147
1148
|
"uniform:disconnect-variable"
|
|
1148
1149
|
);
|
|
1149
1150
|
var INSERT_VARIABLE_COMMAND = createCommand("uniform:insert-variable");
|
|
1151
|
+
function isEditorFocused(editor) {
|
|
1152
|
+
var _a;
|
|
1153
|
+
const rootElement = editor.getRootElement();
|
|
1154
|
+
return (_a = rootElement == null ? void 0 : rootElement.contains(rootElement.ownerDocument.activeElement)) != null ? _a : false;
|
|
1155
|
+
}
|
|
1150
1156
|
var DollarSignVariablesRegex = /(^.*)(\$\$(.{0,20}))$/;
|
|
1151
1157
|
function getPossibleQueryMatch(text) {
|
|
1152
1158
|
const match = DollarSignVariablesRegex.exec(text);
|
|
@@ -1441,7 +1447,7 @@ function VariablesPlugin({
|
|
|
1441
1447
|
replaceValueOnVariableInsert,
|
|
1442
1448
|
disableVariableDisplayNames
|
|
1443
1449
|
]);
|
|
1444
|
-
const
|
|
1450
|
+
const computeUpdatedVariableNodeState = useCallback2(
|
|
1445
1451
|
(variableNode) => {
|
|
1446
1452
|
var _a, _b, _c, _d;
|
|
1447
1453
|
const targetVar = variablesRef.current.variables[variableNode.reference];
|
|
@@ -1449,7 +1455,7 @@ function VariablesPlugin({
|
|
|
1449
1455
|
const isLoadingVariables = variablesRef.current.isLoading;
|
|
1450
1456
|
const currentState = variableNode.getState();
|
|
1451
1457
|
if (currentState.isFresh && !targetVar && !targetUndefinedVar) {
|
|
1452
|
-
return;
|
|
1458
|
+
return void 0;
|
|
1453
1459
|
}
|
|
1454
1460
|
const tooltip = (_d = (_c = (_b = (_a = targetVar == null ? void 0 : targetVar.tooltip) != null ? _a : targetVar == null ? void 0 : targetVar.helpText) != null ? _b : targetUndefinedVar == null ? void 0 : targetUndefinedVar.error) != null ? _c : targetUndefinedVar == null ? void 0 : targetUndefinedVar.warning) != null ? _d : targetUndefinedVar == null ? void 0 : targetUndefinedVar.info;
|
|
1455
1461
|
const displayName = disableVariableDisplayNames ? prettifyBindExpression(variableNode.reference) : (targetVar == null ? void 0 : targetVar.displayName) || (targetUndefinedVar == null ? void 0 : targetUndefinedVar.displayName) || prettifyBindExpression(variableNode.reference);
|
|
@@ -1462,26 +1468,50 @@ function VariablesPlugin({
|
|
|
1462
1468
|
tooltip,
|
|
1463
1469
|
isFresh: false
|
|
1464
1470
|
};
|
|
1465
|
-
|
|
1471
|
+
return dequal(currentState, newState) ? void 0 : newState;
|
|
1472
|
+
},
|
|
1473
|
+
[canEditVariable, disableVariableDisplayNames]
|
|
1474
|
+
);
|
|
1475
|
+
const updateExistingNodeIfChanged = useCallback2(
|
|
1476
|
+
(variableNode) => {
|
|
1477
|
+
const newState = computeUpdatedVariableNodeState(variableNode);
|
|
1478
|
+
if (newState) {
|
|
1466
1479
|
variableNode.setState(newState);
|
|
1467
1480
|
}
|
|
1468
1481
|
},
|
|
1469
|
-
[
|
|
1482
|
+
[computeUpdatedVariableNodeState]
|
|
1470
1483
|
);
|
|
1471
1484
|
useEffect4(() => {
|
|
1472
|
-
|
|
1485
|
+
const pendingUpdates = [];
|
|
1473
1486
|
editor.read(() => {
|
|
1474
|
-
|
|
1487
|
+
$dfs().forEach(({ node }) => {
|
|
1488
|
+
if ($isVariableNode(node)) {
|
|
1489
|
+
const newState = computeUpdatedVariableNodeState(node);
|
|
1490
|
+
if (newState) {
|
|
1491
|
+
pendingUpdates.push({ key: node.getKey(), newState });
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
});
|
|
1475
1495
|
});
|
|
1496
|
+
if (pendingUpdates.length === 0) {
|
|
1497
|
+
return;
|
|
1498
|
+
}
|
|
1499
|
+
const shouldSyncDomSelection = isEditorFocused(editor);
|
|
1476
1500
|
editor.update(() => {
|
|
1477
1501
|
var _a;
|
|
1478
|
-
$
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1502
|
+
const selection = $getSelection();
|
|
1503
|
+
pendingUpdates.forEach(({ key, newState }) => {
|
|
1504
|
+
const node = $getNodeByKey(key);
|
|
1505
|
+
if ($isVariableNode(node)) {
|
|
1506
|
+
node.setState(newState);
|
|
1507
|
+
}
|
|
1482
1508
|
});
|
|
1509
|
+
$setSelection((_a = selection == null ? void 0 : selection.clone()) != null ? _a : null);
|
|
1510
|
+
if (!shouldSyncDomSelection) {
|
|
1511
|
+
$addUpdateTag(SKIP_DOM_SELECTION_TAG);
|
|
1512
|
+
}
|
|
1483
1513
|
});
|
|
1484
|
-
}, [editor, variables, knownUndefinedValues,
|
|
1514
|
+
}, [editor, variables, knownUndefinedValues, computeUpdatedVariableNodeState]);
|
|
1485
1515
|
useEffect4(() => {
|
|
1486
1516
|
return editor.registerNodeTransform(VariableNode, (variableNode) => {
|
|
1487
1517
|
updateExistingNodeIfChanged(variableNode);
|
|
@@ -6560,7 +6590,9 @@ var FilterControls = ({
|
|
|
6560
6590
|
const [localSearchTerm, setLocalSearchTerm] = useState21(searchTerm);
|
|
6561
6591
|
useDebounce7(
|
|
6562
6592
|
() => {
|
|
6563
|
-
|
|
6593
|
+
if (localSearchTerm !== searchTerm) {
|
|
6594
|
+
setSearchTerm(localSearchTerm);
|
|
6595
|
+
}
|
|
6564
6596
|
},
|
|
6565
6597
|
300,
|
|
6566
6598
|
[localSearchTerm]
|
package/dist/index.js
CHANGED
|
@@ -1293,6 +1293,11 @@ var DISCONNECT_VARIABLE_COMMAND = (0, import_lexical4.createCommand)(
|
|
|
1293
1293
|
"uniform:disconnect-variable"
|
|
1294
1294
|
);
|
|
1295
1295
|
var INSERT_VARIABLE_COMMAND = (0, import_lexical4.createCommand)("uniform:insert-variable");
|
|
1296
|
+
function isEditorFocused(editor) {
|
|
1297
|
+
var _a;
|
|
1298
|
+
const rootElement = editor.getRootElement();
|
|
1299
|
+
return (_a = rootElement == null ? void 0 : rootElement.contains(rootElement.ownerDocument.activeElement)) != null ? _a : false;
|
|
1300
|
+
}
|
|
1296
1301
|
var DollarSignVariablesRegex = /(^.*)(\$\$(.{0,20}))$/;
|
|
1297
1302
|
function getPossibleQueryMatch(text) {
|
|
1298
1303
|
const match = DollarSignVariablesRegex.exec(text);
|
|
@@ -1587,7 +1592,7 @@ function VariablesPlugin({
|
|
|
1587
1592
|
replaceValueOnVariableInsert,
|
|
1588
1593
|
disableVariableDisplayNames
|
|
1589
1594
|
]);
|
|
1590
|
-
const
|
|
1595
|
+
const computeUpdatedVariableNodeState = (0, import_react15.useCallback)(
|
|
1591
1596
|
(variableNode) => {
|
|
1592
1597
|
var _a, _b, _c, _d;
|
|
1593
1598
|
const targetVar = variablesRef.current.variables[variableNode.reference];
|
|
@@ -1595,7 +1600,7 @@ function VariablesPlugin({
|
|
|
1595
1600
|
const isLoadingVariables = variablesRef.current.isLoading;
|
|
1596
1601
|
const currentState = variableNode.getState();
|
|
1597
1602
|
if (currentState.isFresh && !targetVar && !targetUndefinedVar) {
|
|
1598
|
-
return;
|
|
1603
|
+
return void 0;
|
|
1599
1604
|
}
|
|
1600
1605
|
const tooltip = (_d = (_c = (_b = (_a = targetVar == null ? void 0 : targetVar.tooltip) != null ? _a : targetVar == null ? void 0 : targetVar.helpText) != null ? _b : targetUndefinedVar == null ? void 0 : targetUndefinedVar.error) != null ? _c : targetUndefinedVar == null ? void 0 : targetUndefinedVar.warning) != null ? _d : targetUndefinedVar == null ? void 0 : targetUndefinedVar.info;
|
|
1601
1606
|
const displayName = disableVariableDisplayNames ? prettifyBindExpression(variableNode.reference) : (targetVar == null ? void 0 : targetVar.displayName) || (targetUndefinedVar == null ? void 0 : targetUndefinedVar.displayName) || prettifyBindExpression(variableNode.reference);
|
|
@@ -1608,26 +1613,50 @@ function VariablesPlugin({
|
|
|
1608
1613
|
tooltip,
|
|
1609
1614
|
isFresh: false
|
|
1610
1615
|
};
|
|
1611
|
-
|
|
1616
|
+
return (0, import_lite.dequal)(currentState, newState) ? void 0 : newState;
|
|
1617
|
+
},
|
|
1618
|
+
[canEditVariable, disableVariableDisplayNames]
|
|
1619
|
+
);
|
|
1620
|
+
const updateExistingNodeIfChanged = (0, import_react15.useCallback)(
|
|
1621
|
+
(variableNode) => {
|
|
1622
|
+
const newState = computeUpdatedVariableNodeState(variableNode);
|
|
1623
|
+
if (newState) {
|
|
1612
1624
|
variableNode.setState(newState);
|
|
1613
1625
|
}
|
|
1614
1626
|
},
|
|
1615
|
-
[
|
|
1627
|
+
[computeUpdatedVariableNodeState]
|
|
1616
1628
|
);
|
|
1617
1629
|
(0, import_react15.useEffect)(() => {
|
|
1618
|
-
|
|
1630
|
+
const pendingUpdates = [];
|
|
1619
1631
|
editor.read(() => {
|
|
1620
|
-
|
|
1632
|
+
(0, import_utils.$dfs)().forEach(({ node }) => {
|
|
1633
|
+
if ($isVariableNode(node)) {
|
|
1634
|
+
const newState = computeUpdatedVariableNodeState(node);
|
|
1635
|
+
if (newState) {
|
|
1636
|
+
pendingUpdates.push({ key: node.getKey(), newState });
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
});
|
|
1621
1640
|
});
|
|
1641
|
+
if (pendingUpdates.length === 0) {
|
|
1642
|
+
return;
|
|
1643
|
+
}
|
|
1644
|
+
const shouldSyncDomSelection = isEditorFocused(editor);
|
|
1622
1645
|
editor.update(() => {
|
|
1623
1646
|
var _a;
|
|
1624
|
-
(0, import_lexical4.$
|
|
1625
|
-
(
|
|
1626
|
-
|
|
1627
|
-
|
|
1647
|
+
const selection = (0, import_lexical4.$getSelection)();
|
|
1648
|
+
pendingUpdates.forEach(({ key, newState }) => {
|
|
1649
|
+
const node = (0, import_lexical4.$getNodeByKey)(key);
|
|
1650
|
+
if ($isVariableNode(node)) {
|
|
1651
|
+
node.setState(newState);
|
|
1652
|
+
}
|
|
1628
1653
|
});
|
|
1654
|
+
(0, import_lexical4.$setSelection)((_a = selection == null ? void 0 : selection.clone()) != null ? _a : null);
|
|
1655
|
+
if (!shouldSyncDomSelection) {
|
|
1656
|
+
(0, import_lexical4.$addUpdateTag)(import_lexical4.SKIP_DOM_SELECTION_TAG);
|
|
1657
|
+
}
|
|
1629
1658
|
});
|
|
1630
|
-
}, [editor, variables, knownUndefinedValues,
|
|
1659
|
+
}, [editor, variables, knownUndefinedValues, computeUpdatedVariableNodeState]);
|
|
1631
1660
|
(0, import_react15.useEffect)(() => {
|
|
1632
1661
|
return editor.registerNodeTransform(VariableNode, (variableNode) => {
|
|
1633
1662
|
updateExistingNodeIfChanged(variableNode);
|
|
@@ -6622,7 +6651,9 @@ var FilterControls = ({
|
|
|
6622
6651
|
const [localSearchTerm, setLocalSearchTerm] = (0, import_react65.useState)(searchTerm);
|
|
6623
6652
|
(0, import_react_use7.useDebounce)(
|
|
6624
6653
|
() => {
|
|
6625
|
-
|
|
6654
|
+
if (localSearchTerm !== searchTerm) {
|
|
6655
|
+
setSearchTerm(localSearchTerm);
|
|
6656
|
+
}
|
|
6626
6657
|
},
|
|
6627
6658
|
300,
|
|
6628
6659
|
[localSearchTerm]
|
package/dist/index.mjs
CHANGED
|
@@ -685,7 +685,8 @@ import {
|
|
|
685
685
|
$isNodeSelection,
|
|
686
686
|
$setSelection,
|
|
687
687
|
COMMAND_PRIORITY_NORMAL,
|
|
688
|
-
createCommand
|
|
688
|
+
createCommand,
|
|
689
|
+
SKIP_DOM_SELECTION_TAG
|
|
689
690
|
} from "lexical";
|
|
690
691
|
import { useCallback as useCallback2, useEffect as useEffect4, useMemo as useMemo6, useRef as useRef3, useState as useState4 } from "react";
|
|
691
692
|
import { createPortal } from "react-dom";
|
|
@@ -1147,6 +1148,11 @@ var DISCONNECT_VARIABLE_COMMAND = createCommand(
|
|
|
1147
1148
|
"uniform:disconnect-variable"
|
|
1148
1149
|
);
|
|
1149
1150
|
var INSERT_VARIABLE_COMMAND = createCommand("uniform:insert-variable");
|
|
1151
|
+
function isEditorFocused(editor) {
|
|
1152
|
+
var _a;
|
|
1153
|
+
const rootElement = editor.getRootElement();
|
|
1154
|
+
return (_a = rootElement == null ? void 0 : rootElement.contains(rootElement.ownerDocument.activeElement)) != null ? _a : false;
|
|
1155
|
+
}
|
|
1150
1156
|
var DollarSignVariablesRegex = /(^.*)(\$\$(.{0,20}))$/;
|
|
1151
1157
|
function getPossibleQueryMatch(text) {
|
|
1152
1158
|
const match = DollarSignVariablesRegex.exec(text);
|
|
@@ -1441,7 +1447,7 @@ function VariablesPlugin({
|
|
|
1441
1447
|
replaceValueOnVariableInsert,
|
|
1442
1448
|
disableVariableDisplayNames
|
|
1443
1449
|
]);
|
|
1444
|
-
const
|
|
1450
|
+
const computeUpdatedVariableNodeState = useCallback2(
|
|
1445
1451
|
(variableNode) => {
|
|
1446
1452
|
var _a, _b, _c, _d;
|
|
1447
1453
|
const targetVar = variablesRef.current.variables[variableNode.reference];
|
|
@@ -1449,7 +1455,7 @@ function VariablesPlugin({
|
|
|
1449
1455
|
const isLoadingVariables = variablesRef.current.isLoading;
|
|
1450
1456
|
const currentState = variableNode.getState();
|
|
1451
1457
|
if (currentState.isFresh && !targetVar && !targetUndefinedVar) {
|
|
1452
|
-
return;
|
|
1458
|
+
return void 0;
|
|
1453
1459
|
}
|
|
1454
1460
|
const tooltip = (_d = (_c = (_b = (_a = targetVar == null ? void 0 : targetVar.tooltip) != null ? _a : targetVar == null ? void 0 : targetVar.helpText) != null ? _b : targetUndefinedVar == null ? void 0 : targetUndefinedVar.error) != null ? _c : targetUndefinedVar == null ? void 0 : targetUndefinedVar.warning) != null ? _d : targetUndefinedVar == null ? void 0 : targetUndefinedVar.info;
|
|
1455
1461
|
const displayName = disableVariableDisplayNames ? prettifyBindExpression(variableNode.reference) : (targetVar == null ? void 0 : targetVar.displayName) || (targetUndefinedVar == null ? void 0 : targetUndefinedVar.displayName) || prettifyBindExpression(variableNode.reference);
|
|
@@ -1462,26 +1468,50 @@ function VariablesPlugin({
|
|
|
1462
1468
|
tooltip,
|
|
1463
1469
|
isFresh: false
|
|
1464
1470
|
};
|
|
1465
|
-
|
|
1471
|
+
return dequal(currentState, newState) ? void 0 : newState;
|
|
1472
|
+
},
|
|
1473
|
+
[canEditVariable, disableVariableDisplayNames]
|
|
1474
|
+
);
|
|
1475
|
+
const updateExistingNodeIfChanged = useCallback2(
|
|
1476
|
+
(variableNode) => {
|
|
1477
|
+
const newState = computeUpdatedVariableNodeState(variableNode);
|
|
1478
|
+
if (newState) {
|
|
1466
1479
|
variableNode.setState(newState);
|
|
1467
1480
|
}
|
|
1468
1481
|
},
|
|
1469
|
-
[
|
|
1482
|
+
[computeUpdatedVariableNodeState]
|
|
1470
1483
|
);
|
|
1471
1484
|
useEffect4(() => {
|
|
1472
|
-
|
|
1485
|
+
const pendingUpdates = [];
|
|
1473
1486
|
editor.read(() => {
|
|
1474
|
-
|
|
1487
|
+
$dfs().forEach(({ node }) => {
|
|
1488
|
+
if ($isVariableNode(node)) {
|
|
1489
|
+
const newState = computeUpdatedVariableNodeState(node);
|
|
1490
|
+
if (newState) {
|
|
1491
|
+
pendingUpdates.push({ key: node.getKey(), newState });
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
});
|
|
1475
1495
|
});
|
|
1496
|
+
if (pendingUpdates.length === 0) {
|
|
1497
|
+
return;
|
|
1498
|
+
}
|
|
1499
|
+
const shouldSyncDomSelection = isEditorFocused(editor);
|
|
1476
1500
|
editor.update(() => {
|
|
1477
1501
|
var _a;
|
|
1478
|
-
$
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1502
|
+
const selection = $getSelection();
|
|
1503
|
+
pendingUpdates.forEach(({ key, newState }) => {
|
|
1504
|
+
const node = $getNodeByKey(key);
|
|
1505
|
+
if ($isVariableNode(node)) {
|
|
1506
|
+
node.setState(newState);
|
|
1507
|
+
}
|
|
1482
1508
|
});
|
|
1509
|
+
$setSelection((_a = selection == null ? void 0 : selection.clone()) != null ? _a : null);
|
|
1510
|
+
if (!shouldSyncDomSelection) {
|
|
1511
|
+
$addUpdateTag(SKIP_DOM_SELECTION_TAG);
|
|
1512
|
+
}
|
|
1483
1513
|
});
|
|
1484
|
-
}, [editor, variables, knownUndefinedValues,
|
|
1514
|
+
}, [editor, variables, knownUndefinedValues, computeUpdatedVariableNodeState]);
|
|
1485
1515
|
useEffect4(() => {
|
|
1486
1516
|
return editor.registerNodeTransform(VariableNode, (variableNode) => {
|
|
1487
1517
|
updateExistingNodeIfChanged(variableNode);
|
|
@@ -6560,7 +6590,9 @@ var FilterControls = ({
|
|
|
6560
6590
|
const [localSearchTerm, setLocalSearchTerm] = useState21(searchTerm);
|
|
6561
6591
|
useDebounce7(
|
|
6562
6592
|
() => {
|
|
6563
|
-
|
|
6593
|
+
if (localSearchTerm !== searchTerm) {
|
|
6594
|
+
setSearchTerm(localSearchTerm);
|
|
6595
|
+
}
|
|
6564
6596
|
},
|
|
6565
6597
|
300,
|
|
6566
6598
|
[localSearchTerm]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/mesh-sdk-react",
|
|
3
|
-
"version": "20.71.2-alpha.
|
|
3
|
+
"version": "20.71.2-alpha.14+e527b409ae",
|
|
4
4
|
"description": "Uniform Mesh Framework SDK for React",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"@lexical/selection": "0.45.0",
|
|
51
51
|
"@lexical/utils": "0.45.0",
|
|
52
52
|
"@react-icons/all-files": "https://github.com/react-icons/react-icons/releases/download/v5.5.0/react-icons-all-files-5.5.0.tgz",
|
|
53
|
-
"@uniformdev/canvas": "20.71.2-alpha.
|
|
54
|
-
"@uniformdev/design-system": "20.71.2-alpha.
|
|
55
|
-
"@uniformdev/mesh-sdk": "20.71.2-alpha.
|
|
56
|
-
"@uniformdev/richtext": "20.71.2-alpha.
|
|
53
|
+
"@uniformdev/canvas": "20.71.2-alpha.14+e527b409ae",
|
|
54
|
+
"@uniformdev/design-system": "20.71.2-alpha.14+e527b409ae",
|
|
55
|
+
"@uniformdev/mesh-sdk": "20.71.2-alpha.14+e527b409ae",
|
|
56
|
+
"@uniformdev/richtext": "20.71.2-alpha.14+e527b409ae",
|
|
57
57
|
"dequal": "^2.0.3",
|
|
58
58
|
"lexical": "0.45.0",
|
|
59
59
|
"mitt": "3.0.1",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"publishConfig": {
|
|
86
86
|
"access": "public"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "e527b409ae4d2b190d4f9195e6787f5c8b89fc85"
|
|
89
89
|
}
|