@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/states/helpers.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare function generateStateOnChangeProp($state: $State, stateName: str
|
|
|
9
9
|
*/
|
|
10
10
|
export declare function generateStateValueProp($state: $State, path: (string | number)[]): any;
|
|
11
11
|
export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
|
|
12
|
+
export declare function isPlasmicStateProxy(obj: any): any;
|
|
12
13
|
export declare function shallowEqual<T>(a1: T[], a2: T[]): boolean;
|
|
13
14
|
export declare function isNum(value: string | number | symbol): value is number;
|
|
14
15
|
declare type StringGen = string | (() => string);
|
package/dist/states/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { default as get } from "dlv";
|
|
2
|
-
export { generateStateOnChangeProp, generateStateValueProp, set, } from "./helpers";
|
|
2
|
+
export { generateStateOnChangeProp, generateStateValueProp, isPlasmicStateProxy, set, } from "./helpers";
|
|
3
3
|
export { $State } from "./types";
|
|
4
4
|
export { useDollarState } from "./valtio";
|
package/dist/states/types.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export interface $State {
|
|
|
14
14
|
registerInitFunc?: (path: string, f: InitFunc<any>, repetitonIndex?: number[]) => any;
|
|
15
15
|
}
|
|
16
16
|
export declare const ARRAY_SYMBOL: unique symbol;
|
|
17
|
+
export declare const PLASMIC_STATE_PROXY_SYMBOL: unique symbol;
|
|
17
18
|
export interface Internal$StateSpec<T> extends $StateSpec<T> {
|
|
18
19
|
isRepeated: boolean;
|
|
19
20
|
pathObj: (string | symbol)[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plasmicapp/react-web",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.140",
|
|
4
4
|
"description": "plasmic library for rendering in the presentational style",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
},
|
|
41
41
|
"prettier": {},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@plasmicapp/data-sources": "0.1.
|
|
44
|
-
"@plasmicapp/data-sources-context": "0.1.
|
|
45
|
-
"@plasmicapp/host": "1.0.
|
|
46
|
-
"@plasmicapp/query": "0.1.
|
|
43
|
+
"@plasmicapp/data-sources": "0.1.24",
|
|
44
|
+
"@plasmicapp/data-sources-context": "0.1.4",
|
|
45
|
+
"@plasmicapp/host": "1.0.94",
|
|
46
|
+
"@plasmicapp/query": "0.1.59",
|
|
47
47
|
"@react-aria/checkbox": "^3.5.0",
|
|
48
48
|
"@react-aria/focus": "^3.7.0",
|
|
49
49
|
"@react-aria/interactions": "^3.10.0",
|
|
@@ -109,5 +109,5 @@
|
|
|
109
109
|
"react": ">=16.8.0",
|
|
110
110
|
"react-dom": ">=16.8.0"
|
|
111
111
|
},
|
|
112
|
-
"gitHead": "
|
|
112
|
+
"gitHead": "2ddf7320f54e314e4f44d3df3c50468d2740ddbf"
|
|
113
113
|
}
|
package/skinny/dist/index.js
CHANGED
|
@@ -494,10 +494,17 @@ function renderPlasmicSlot(opts) {
|
|
|
494
494
|
}
|
|
495
495
|
function maybeAsString(node) {
|
|
496
496
|
// Unwrap fragments
|
|
497
|
-
if (React.isValidElement(node)
|
|
498
|
-
// Fragment
|
|
499
|
-
(node.type === React.Fragment
|
|
500
|
-
|
|
497
|
+
if (React.isValidElement(node)) {
|
|
498
|
+
// Fragment doesn't render DOM elements
|
|
499
|
+
if (node.type === React.Fragment) {
|
|
500
|
+
return maybeAsString(node.props.children);
|
|
501
|
+
}
|
|
502
|
+
else if (node.type === Trans) {
|
|
503
|
+
// Trans also doesn't render DOM elements. But we don't want to just render
|
|
504
|
+
// its content string, because we want to keep the <Trans/> for the localization.
|
|
505
|
+
// So we render the same node, to be wrapped into __wab_slot-string-wrapper.
|
|
506
|
+
return node;
|
|
507
|
+
}
|
|
501
508
|
}
|
|
502
509
|
if (typeof node === "string") {
|
|
503
510
|
return node;
|
|
@@ -660,6 +667,9 @@ function useTrigger(trigger, opts) {
|
|
|
660
667
|
return TRIGGER_TO_HOOK[trigger](opts);
|
|
661
668
|
}
|
|
662
669
|
|
|
670
|
+
var ARRAY_SYMBOL = Symbol("[]");
|
|
671
|
+
var PLASMIC_STATE_PROXY_SYMBOL = Symbol("plasmic.state.proxy");
|
|
672
|
+
|
|
663
673
|
function generateStateOnChangeProp($state, stateName, dataReps) {
|
|
664
674
|
return function (val, path) { return set($state, __spreadArray(__spreadArray([stateName], __read(dataReps), false), __read(path), false), val); };
|
|
665
675
|
}
|
|
@@ -674,6 +684,9 @@ function generateStateValueProp($state, path // ["parent", 0, 1, "counter"]
|
|
|
674
684
|
return get($state, path);
|
|
675
685
|
}
|
|
676
686
|
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
|
|
687
|
+
function isPlasmicStateProxy(obj) {
|
|
688
|
+
return (obj != null && typeof obj === "object" && obj[PLASMIC_STATE_PROXY_SYMBOL]);
|
|
689
|
+
}
|
|
677
690
|
function shallowEqual(a1, a2) {
|
|
678
691
|
if (a1.length !== a2.length) {
|
|
679
692
|
return false;
|
|
@@ -747,8 +760,6 @@ function assignValue(object, key, value) {
|
|
|
747
760
|
}
|
|
748
761
|
}
|
|
749
762
|
|
|
750
|
-
var ARRAY_SYMBOL = Symbol("[]");
|
|
751
|
-
|
|
752
763
|
var UNINITIALIZED = Symbol("plasmic.unitialized");
|
|
753
764
|
var StateSpecNode = /** @class */ (function () {
|
|
754
765
|
function StateSpecNode(specs) {
|
|
@@ -980,6 +991,9 @@ function create$StateProxy($$state, leafHandlers) {
|
|
|
980
991
|
},
|
|
981
992
|
get: function (target, property, receiver) {
|
|
982
993
|
var _a, _b;
|
|
994
|
+
if (property === PLASMIC_STATE_PROXY_SYMBOL) {
|
|
995
|
+
return true;
|
|
996
|
+
}
|
|
983
997
|
proxyRoot = proxyRoot == null ? receiver : proxyRoot;
|
|
984
998
|
var nextPath = getNextPath(property);
|
|
985
999
|
if (isOutside || currNode.isLeaf()) {
|
|
@@ -1047,7 +1061,7 @@ function create$StateProxy($$state, leafHandlers) {
|
|
|
1047
1061
|
: {}
|
|
1048
1062
|
: Array.isArray(initialObject)
|
|
1049
1063
|
? []
|
|
1050
|
-
: Object.create(Object.getPrototypeOf(initialObject));
|
|
1064
|
+
: Object.create(Object.getPrototypeOf(initialObject !== null && initialObject !== void 0 ? initialObject : {}));
|
|
1051
1065
|
var proxyObj = new Proxy(baseObject, handlers);
|
|
1052
1066
|
if (initialObject) {
|
|
1053
1067
|
Reflect.ownKeys(initialObject).forEach(function (key) {
|
|
@@ -1081,42 +1095,39 @@ function useDollarState(specs, props, $ctx) {
|
|
|
1081
1095
|
})()).current;
|
|
1082
1096
|
$$state.props = props;
|
|
1083
1097
|
$$state.ctx = $ctx !== null && $ctx !== void 0 ? $ctx : {};
|
|
1084
|
-
var $state = React__default.useRef((function () {
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1098
|
+
var $state = React__default.useRef(Object.assign(create$StateProxy($$state, function (node, path, proxyRoot) {
|
|
1099
|
+
if (!node.hasState(path)) {
|
|
1100
|
+
node.createStateCell(path);
|
|
1101
|
+
var spec = node.getSpec();
|
|
1102
|
+
if (spec.initFunc) {
|
|
1103
|
+
initializeStateValue($$state, node, path, proxyRoot);
|
|
1104
|
+
}
|
|
1105
|
+
else if (!spec.valueProp) {
|
|
1106
|
+
set(proxyRoot, path, spec.initVal);
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
return {
|
|
1110
|
+
get: function (target, property, receiver) {
|
|
1088
1111
|
var spec = node.getSpec();
|
|
1089
|
-
if (spec.
|
|
1090
|
-
|
|
1112
|
+
if (spec.valueProp) {
|
|
1113
|
+
return $$state.props[spec.valueProp];
|
|
1091
1114
|
}
|
|
1092
|
-
else
|
|
1093
|
-
|
|
1115
|
+
else {
|
|
1116
|
+
return Reflect.get(target, property, receiver);
|
|
1094
1117
|
}
|
|
1095
1118
|
}
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
else {
|
|
1103
|
-
return Reflect.get(target, property, receiver);
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
};
|
|
1107
|
-
}), {
|
|
1108
|
-
registerInitFunc: function (pathStr, f, repetitionIndex) {
|
|
1109
|
-
var _a = findStateCell($$state.rootSpecTree, pathStr, repetitionIndex), node = _a.node, realPath = _a.realPath;
|
|
1110
|
-
if (!node.hasState(realPath)) {
|
|
1111
|
-
node.createStateCell(realPath);
|
|
1112
|
-
}
|
|
1113
|
-
if (!deepEqual(node.getState(realPath).initialValue, f($$state.props, useRef$state, $$state.ctx))) {
|
|
1114
|
-
$$state.registrationsQueue.push({ node: node, path: realPath, f: f });
|
|
1115
|
-
}
|
|
1119
|
+
};
|
|
1120
|
+
}), {
|
|
1121
|
+
registerInitFunc: function (pathStr, f, repetitionIndex) {
|
|
1122
|
+
var _a = findStateCell($$state.rootSpecTree, pathStr, repetitionIndex), node = _a.node, realPath = _a.realPath;
|
|
1123
|
+
if (!node.hasState(realPath)) {
|
|
1124
|
+
node.createStateCell(realPath);
|
|
1116
1125
|
}
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1126
|
+
if (!deepEqual(node.getState(realPath).initialValue, f($$state.props, $state, $$state.ctx))) {
|
|
1127
|
+
$$state.registrationsQueue.push({ node: node, path: realPath, f: f });
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
})).current;
|
|
1120
1131
|
// For each spec with an initFunc, evaluate it and see if
|
|
1121
1132
|
// the init value has changed. If so, reset its state.
|
|
1122
1133
|
var resetSpecs = [];
|
|
@@ -1172,5 +1183,5 @@ function useDollarState(specs, props, $ctx) {
|
|
|
1172
1183
|
// Utilities used by generated code
|
|
1173
1184
|
var classNames = classNames$1;
|
|
1174
1185
|
|
|
1175
|
-
export { PlasmicIcon, PlasmicLink, PlasmicPageGuard, PlasmicSlot, Stack, classNames, createPlasmicElementProxy, createUseScreenVariants, deriveRenderOpts, ensureGlobalVariants, generateStateOnChangeProp, generateStateValueProp, hasVariant, makeFragment, mergeVariantsWithStates, renderPlasmicSlot, set, useDollarState, useTrigger, wrapWithClassName };
|
|
1186
|
+
export { PlasmicIcon, PlasmicLink, PlasmicPageGuard, PlasmicSlot, Stack, classNames, createPlasmicElementProxy, createUseScreenVariants, deriveRenderOpts, ensureGlobalVariants, generateStateOnChangeProp, generateStateValueProp, hasVariant, isPlasmicStateProxy, makeFragment, mergeVariantsWithStates, renderPlasmicSlot, set, useDollarState, useTrigger, wrapWithClassName };
|
|
1176
1187
|
//# sourceMappingURL=index.js.map
|