@plasmicapp/react-web 0.2.138 → 0.2.140
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/all.d.ts +2 -1
- package/dist/react-web.cjs.development.js +54 -43
- package/dist/react-web.cjs.development.js.map +1 -1
- package/dist/react-web.cjs.production.min.js +1 -1
- package/dist/react-web.cjs.production.min.js.map +1 -1
- package/dist/react-web.esm.js +54 -44
- package/dist/react-web.esm.js.map +1 -1
- package/dist/states/helpers.d.ts +1 -0
- package/dist/states/index.d.ts +1 -1
- package/dist/states/types.d.ts +1 -0
- package/package.json +6 -6
- package/skinny/dist/index.js +50 -39
- package/skinny/dist/index.js.map +1 -1
- package/skinny/dist/states/helpers.d.ts +1 -0
- package/skinny/dist/states/index.d.ts +1 -1
- package/skinny/dist/states/types.d.ts +1 -0
package/dist/all.d.ts
CHANGED
|
@@ -74,6 +74,7 @@ declare function generateStateOnChangeProp($state: $State, stateName: string, da
|
|
|
74
74
|
* We need to pass `parent[index1][index2].counter to the child component
|
|
75
75
|
*/
|
|
76
76
|
declare function generateStateValueProp($state: $State, path: (string | number)[]): any;
|
|
77
|
+
declare function isPlasmicStateProxy(obj: any): any;
|
|
77
78
|
/**
|
|
78
79
|
* Forked from https://github.com/lukeed/dset
|
|
79
80
|
* Changes: fixed setting a deep value to a proxy object
|
|
@@ -1638,4 +1639,4 @@ interface TriggeredOverlayContextValue {
|
|
|
1638
1639
|
}
|
|
1639
1640
|
declare const TriggeredOverlayContext: React.Context<TriggeredOverlayContextValue | undefined>;
|
|
1640
1641
|
|
|
1641
|
-
export { $State, BaseButtonProps, BaseMenuButtonProps, BaseMenuGroupProps, BaseMenuItemProps, BaseMenuProps, BaseSelectOptionGroupProps, BaseSelectOptionProps, BaseSelectProps, BaseTextInputProps, BaseTriggeredOverlayProps, ButtonRef, CheckboxProps, CheckboxRef, CheckboxRefValue, DropdownMenu, Flex, HTMLElementRefOf, HtmlAnchorOnlyProps, HtmlButtonOnlyProps, MenuButtonRef, MenuButtonRefValue, MenuRef, MenuRefValue, MultiChoiceArg, PlasmicDataSourceContextProvider, PlasmicHead, PlasmicIcon, PlasmicImg, PlasmicLink, PlasmicPageGuard, PlasmicRootProvider, PlasmicSlot, SelectContext, SelectOptionRef, SelectRef, SelectRefValue, SingleBooleanChoiceArg, SingleChoiceArg, Stack, StrictProps, SwitchProps, SwitchRef, SwitchRefValue, TextInputRef, TextInputRefValue, Trans, TriggeredOverlayConfig, TriggeredOverlayContext, TriggeredOverlayRef, classNames, createPlasmicElementProxy, createUseScreenVariants, deriveRenderOpts, ensureGlobalVariants, genTranslatableString, generateStateOnChangeProp, generateStateValueProp, dlv as get, getDataProps, hasVariant, makeFragment, mergeVariantsWithStates, omit, pick, plasmicHeadMeta, renderPlasmicSlot, set, setPlumeStrictMode, useButton, useCheckbox, useCurrentUser, useDollarState, useIsSSR, useMenu, useMenuButton, useMenuGroup, useMenuItem, useSelect, useSelectOption, useSelectOptionGroup, useSwitch, useTextInput, useTrigger, useTriggeredOverlay, wrapWithClassName };
|
|
1642
|
+
export { $State, BaseButtonProps, BaseMenuButtonProps, BaseMenuGroupProps, BaseMenuItemProps, BaseMenuProps, BaseSelectOptionGroupProps, BaseSelectOptionProps, BaseSelectProps, BaseTextInputProps, BaseTriggeredOverlayProps, ButtonRef, CheckboxProps, CheckboxRef, CheckboxRefValue, DropdownMenu, Flex, HTMLElementRefOf, HtmlAnchorOnlyProps, HtmlButtonOnlyProps, MenuButtonRef, MenuButtonRefValue, MenuRef, MenuRefValue, MultiChoiceArg, PlasmicDataSourceContextProvider, PlasmicHead, PlasmicIcon, PlasmicImg, PlasmicLink, PlasmicPageGuard, PlasmicRootProvider, PlasmicSlot, SelectContext, SelectOptionRef, SelectRef, SelectRefValue, SingleBooleanChoiceArg, SingleChoiceArg, Stack, StrictProps, SwitchProps, SwitchRef, SwitchRefValue, TextInputRef, TextInputRefValue, Trans, TriggeredOverlayConfig, TriggeredOverlayContext, TriggeredOverlayRef, classNames, createPlasmicElementProxy, createUseScreenVariants, deriveRenderOpts, ensureGlobalVariants, genTranslatableString, generateStateOnChangeProp, generateStateValueProp, dlv as get, getDataProps, hasVariant, isPlasmicStateProxy, makeFragment, mergeVariantsWithStates, omit, pick, plasmicHeadMeta, renderPlasmicSlot, set, setPlumeStrictMode, useButton, useCheckbox, useCurrentUser, useDollarState, useIsSSR, useMenu, useMenuButton, useMenuGroup, useMenuItem, useSelect, useSelectOption, useSelectOptionGroup, useSwitch, useTextInput, useTrigger, useTriggeredOverlay, wrapWithClassName };
|
|
@@ -1285,10 +1285,16 @@ function renderPlasmicSlot(opts) {
|
|
|
1285
1285
|
}
|
|
1286
1286
|
function maybeAsString(node) {
|
|
1287
1287
|
// Unwrap fragments
|
|
1288
|
-
if (React.isValidElement(node)
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1288
|
+
if (React.isValidElement(node)) {
|
|
1289
|
+
// Fragment doesn't render DOM elements
|
|
1290
|
+
if (node.type === React.Fragment) {
|
|
1291
|
+
return maybeAsString(node.props.children);
|
|
1292
|
+
} else if (node.type === Trans) {
|
|
1293
|
+
// Trans also doesn't render DOM elements. But we don't want to just render
|
|
1294
|
+
// its content string, because we want to keep the <Trans/> for the localization.
|
|
1295
|
+
// So we render the same node, to be wrapped into __wab_slot-string-wrapper.
|
|
1296
|
+
return node;
|
|
1297
|
+
}
|
|
1292
1298
|
}
|
|
1293
1299
|
if (typeof node === "string") {
|
|
1294
1300
|
return node;
|
|
@@ -1508,6 +1514,9 @@ function useTrigger(trigger, opts) {
|
|
|
1508
1514
|
return TRIGGER_TO_HOOK[trigger](opts);
|
|
1509
1515
|
}
|
|
1510
1516
|
|
|
1517
|
+
var ARRAY_SYMBOL = /*#__PURE__*/Symbol("[]");
|
|
1518
|
+
var PLASMIC_STATE_PROXY_SYMBOL = /*#__PURE__*/Symbol("plasmic.state.proxy");
|
|
1519
|
+
|
|
1511
1520
|
function generateStateOnChangeProp($state, stateName, dataReps) {
|
|
1512
1521
|
return function (val, path) {
|
|
1513
1522
|
return set($state, [stateName].concat(dataReps, path), val);
|
|
@@ -1524,6 +1533,9 @@ function generateStateValueProp($state, path // ["parent", 0, 1, "counter"]
|
|
|
1524
1533
|
return _get($state, path);
|
|
1525
1534
|
}
|
|
1526
1535
|
var useIsomorphicLayoutEffect$1 = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
1536
|
+
function isPlasmicStateProxy(obj) {
|
|
1537
|
+
return obj != null && typeof obj === "object" && obj[PLASMIC_STATE_PROXY_SYMBOL];
|
|
1538
|
+
}
|
|
1527
1539
|
function shallowEqual(a1, a2) {
|
|
1528
1540
|
if (a1.length !== a2.length) {
|
|
1529
1541
|
return false;
|
|
@@ -1594,8 +1606,6 @@ function assignValue(object, key, value) {
|
|
|
1594
1606
|
}
|
|
1595
1607
|
}
|
|
1596
1608
|
|
|
1597
|
-
var ARRAY_SYMBOL = /*#__PURE__*/Symbol("[]");
|
|
1598
|
-
|
|
1599
1609
|
var UNINITIALIZED = /*#__PURE__*/Symbol("plasmic.unitialized");
|
|
1600
1610
|
var StateSpecNode = /*#__PURE__*/function () {
|
|
1601
1611
|
function StateSpecNode(specs) {
|
|
@@ -1807,6 +1817,9 @@ function create$StateProxy($$state, leafHandlers) {
|
|
|
1807
1817
|
return Reflect.deleteProperty(target, property);
|
|
1808
1818
|
},
|
|
1809
1819
|
get: function get(target, property, receiver) {
|
|
1820
|
+
if (property === PLASMIC_STATE_PROXY_SYMBOL) {
|
|
1821
|
+
return true;
|
|
1822
|
+
}
|
|
1810
1823
|
proxyRoot = proxyRoot == null ? receiver : proxyRoot;
|
|
1811
1824
|
var nextPath = getNextPath(property);
|
|
1812
1825
|
if (isOutside || currNode.isLeaf()) {
|
|
@@ -1865,7 +1878,7 @@ function create$StateProxy($$state, leafHandlers) {
|
|
|
1865
1878
|
return true;
|
|
1866
1879
|
}
|
|
1867
1880
|
};
|
|
1868
|
-
var baseObject = !isOutside && !currNode.isLeaf() ? currNode.hasArrayTransition() ? [] : {} : Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject));
|
|
1881
|
+
var baseObject = !isOutside && !currNode.isLeaf() ? currNode.hasArrayTransition() ? [] : {} : Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject != null ? initialObject : {}));
|
|
1869
1882
|
var proxyObj = new Proxy(baseObject, handlers);
|
|
1870
1883
|
if (initialObject) {
|
|
1871
1884
|
Reflect.ownKeys(initialObject).forEach(function (key) {
|
|
@@ -1898,46 +1911,43 @@ function useDollarState(specs, props, $ctx) {
|
|
|
1898
1911
|
}()).current;
|
|
1899
1912
|
$$state.props = props;
|
|
1900
1913
|
$$state.ctx = $ctx != null ? $ctx : {};
|
|
1901
|
-
var $state = React__default.useRef(function () {
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1914
|
+
var $state = React__default.useRef(Object.assign(create$StateProxy($$state, function (node, path, proxyRoot) {
|
|
1915
|
+
if (!node.hasState(path)) {
|
|
1916
|
+
node.createStateCell(path);
|
|
1917
|
+
var spec = node.getSpec();
|
|
1918
|
+
if (spec.initFunc) {
|
|
1919
|
+
initializeStateValue($$state, node, path, proxyRoot);
|
|
1920
|
+
} else if (!spec.valueProp) {
|
|
1921
|
+
set(proxyRoot, path, spec.initVal);
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
return {
|
|
1925
|
+
get: function get(target, property, receiver) {
|
|
1905
1926
|
var spec = node.getSpec();
|
|
1906
|
-
if (spec.
|
|
1907
|
-
|
|
1908
|
-
} else
|
|
1909
|
-
|
|
1927
|
+
if (spec.valueProp) {
|
|
1928
|
+
return $$state.props[spec.valueProp];
|
|
1929
|
+
} else {
|
|
1930
|
+
return Reflect.get(target, property, receiver);
|
|
1910
1931
|
}
|
|
1911
1932
|
}
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
}
|
|
1921
|
-
};
|
|
1922
|
-
}), {
|
|
1923
|
-
registerInitFunc: function registerInitFunc(pathStr, f, repetitionIndex) {
|
|
1924
|
-
var _findStateCell = findStateCell($$state.rootSpecTree, pathStr, repetitionIndex),
|
|
1925
|
-
node = _findStateCell.node,
|
|
1926
|
-
realPath = _findStateCell.realPath;
|
|
1927
|
-
if (!node.hasState(realPath)) {
|
|
1928
|
-
node.createStateCell(realPath);
|
|
1929
|
-
}
|
|
1930
|
-
if (!deepEqual(node.getState(realPath).initialValue, f($$state.props, useRef$state, $$state.ctx))) {
|
|
1931
|
-
$$state.registrationsQueue.push({
|
|
1932
|
-
node: node,
|
|
1933
|
-
path: realPath,
|
|
1934
|
-
f: f
|
|
1935
|
-
});
|
|
1936
|
-
}
|
|
1933
|
+
};
|
|
1934
|
+
}), {
|
|
1935
|
+
registerInitFunc: function registerInitFunc(pathStr, f, repetitionIndex) {
|
|
1936
|
+
var _findStateCell = findStateCell($$state.rootSpecTree, pathStr, repetitionIndex),
|
|
1937
|
+
node = _findStateCell.node,
|
|
1938
|
+
realPath = _findStateCell.realPath;
|
|
1939
|
+
if (!node.hasState(realPath)) {
|
|
1940
|
+
node.createStateCell(realPath);
|
|
1937
1941
|
}
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1942
|
+
if (!deepEqual(node.getState(realPath).initialValue, f($$state.props, $state, $$state.ctx))) {
|
|
1943
|
+
$$state.registrationsQueue.push({
|
|
1944
|
+
node: node,
|
|
1945
|
+
path: realPath,
|
|
1946
|
+
f: f
|
|
1947
|
+
});
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
})).current;
|
|
1941
1951
|
// For each spec with an initFunc, evaluate it and see if
|
|
1942
1952
|
// the init value has changed. If so, reset its state.
|
|
1943
1953
|
var resetSpecs = [];
|
|
@@ -3435,6 +3445,7 @@ exports.generateStateOnChangeProp = generateStateOnChangeProp;
|
|
|
3435
3445
|
exports.generateStateValueProp = generateStateValueProp;
|
|
3436
3446
|
exports.getDataProps = getDataProps;
|
|
3437
3447
|
exports.hasVariant = hasVariant;
|
|
3448
|
+
exports.isPlasmicStateProxy = isPlasmicStateProxy;
|
|
3438
3449
|
exports.makeFragment = makeFragment;
|
|
3439
3450
|
exports.mergeVariantsWithStates = mergeVariantsWithStates;
|
|
3440
3451
|
exports.omit = omit;
|