@plasmicapp/react-web 0.2.145 → 0.2.146
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 +15 -2
- package/dist/react-web.cjs.development.js +142 -107
- 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 +141 -108
- package/dist/react-web.esm.js.map +1 -1
- package/dist/states/graph.d.ts +1 -4
- package/dist/states/helpers.d.ts +9 -1
- package/dist/states/index.d.ts +2 -2
- package/dist/states/types.d.ts +1 -0
- package/package.json +2 -2
- package/skinny/dist/index.js +127 -104
- package/skinny/dist/index.js.map +1 -1
- package/skinny/dist/states/graph.d.ts +1 -4
- package/skinny/dist/states/helpers.d.ts +9 -1
- package/skinny/dist/states/index.d.ts +2 -2
- package/skinny/dist/states/types.d.ts +1 -0
package/dist/all.d.ts
CHANGED
|
@@ -45,15 +45,28 @@ interface $StateSpec<T> {
|
|
|
45
45
|
valueProp?: string;
|
|
46
46
|
onChangeProp?: string;
|
|
47
47
|
isImmutable?: boolean;
|
|
48
|
+
variableType: "text" | "number" | "boolean" | "array" | "object" | "variant";
|
|
48
49
|
}
|
|
49
50
|
interface $State {
|
|
50
51
|
[key: string]: any;
|
|
51
52
|
registerInitFunc?: (path: string, f: InitFunc<any>, repetitonIndex?: number[]) => any;
|
|
53
|
+
}
|
|
54
|
+
interface Internal$StateSpec<T> extends $StateSpec<T> {
|
|
55
|
+
isRepeated: boolean;
|
|
56
|
+
pathObj: (string | symbol)[];
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
declare function generateStateOnChangeProp($state: $State, path: ObjectPath): (val: any) => void;
|
|
55
60
|
declare function generateStateValueProp($state: $State, path: ObjectPath): any;
|
|
56
|
-
declare function isPlasmicStateProxy(obj: any):
|
|
61
|
+
declare function isPlasmicStateProxy(obj: any): boolean;
|
|
62
|
+
declare function getStateCellsInPlasmicProxy(obj: any): {
|
|
63
|
+
realPath: ObjectPath;
|
|
64
|
+
path: string;
|
|
65
|
+
}[];
|
|
66
|
+
declare function getStateSpecInPlasmicProxy(obj: any, path: ObjectPath): {
|
|
67
|
+
spec: Internal$StateSpec<any>;
|
|
68
|
+
isImplicitStateArray: boolean;
|
|
69
|
+
} | undefined;
|
|
57
70
|
/**
|
|
58
71
|
* Forked from https://github.com/lukeed/dset
|
|
59
72
|
* Changes: fixed setting a deep value to a proxy object
|
|
@@ -1638,4 +1651,4 @@ interface TriggeredOverlayContextValue {
|
|
|
1638
1651
|
}
|
|
1639
1652
|
declare const TriggeredOverlayContext: React.Context<TriggeredOverlayContextValue | undefined>;
|
|
1640
1653
|
|
|
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, 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 };
|
|
1654
|
+
export { $State, $StateSpec, 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, getStateCellsInPlasmicProxy, getStateSpecInPlasmicProxy, 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 };
|
|
@@ -2279,96 +2279,6 @@ function useTrigger(trigger, opts) {
|
|
|
2279
2279
|
var ARRAY_SYMBOL = /*#__PURE__*/Symbol("[]");
|
|
2280
2280
|
var PLASMIC_STATE_PROXY_SYMBOL = /*#__PURE__*/Symbol("plasmic.state.proxy");
|
|
2281
2281
|
|
|
2282
|
-
function generateStateOnChangeProp($state, path) {
|
|
2283
|
-
return function (val) {
|
|
2284
|
-
return set($state, path, val);
|
|
2285
|
-
};
|
|
2286
|
-
}
|
|
2287
|
-
function generateStateValueProp($state, path) {
|
|
2288
|
-
return _get($state, path);
|
|
2289
|
-
}
|
|
2290
|
-
var useIsomorphicLayoutEffect$1 = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
2291
|
-
function isPlasmicStateProxy(obj) {
|
|
2292
|
-
return obj != null && typeof obj === "object" && obj[PLASMIC_STATE_PROXY_SYMBOL];
|
|
2293
|
-
}
|
|
2294
|
-
function shallowEqual(a1, a2) {
|
|
2295
|
-
if (a1.length !== a2.length) {
|
|
2296
|
-
return false;
|
|
2297
|
-
}
|
|
2298
|
-
for (var i = 0; i < a1.length; i++) {
|
|
2299
|
-
if (a1[i] !== a2[i]) {
|
|
2300
|
-
return false;
|
|
2301
|
-
}
|
|
2302
|
-
}
|
|
2303
|
-
return true;
|
|
2304
|
-
}
|
|
2305
|
-
/**
|
|
2306
|
-
* Shallow comparison of arrays.
|
|
2307
|
-
*/
|
|
2308
|
-
function arrayEq(xs, ys) {
|
|
2309
|
-
return xs.length === ys.length && xs.every(function (_, index) {
|
|
2310
|
-
return xs[index] === ys[index];
|
|
2311
|
-
});
|
|
2312
|
-
}
|
|
2313
|
-
function isNum(value) {
|
|
2314
|
-
return typeof value === "symbol" ? false : !isNaN(+value);
|
|
2315
|
-
}
|
|
2316
|
-
function assert(cond, msg) {
|
|
2317
|
-
if (msg === void 0) {
|
|
2318
|
-
msg = "Assertion failed";
|
|
2319
|
-
}
|
|
2320
|
-
if (!cond) {
|
|
2321
|
-
// We always generate an non empty message so that it doesn't get swallowed
|
|
2322
|
-
// by the async library.
|
|
2323
|
-
msg = (typeof msg === "string" ? msg : msg()) || "Assertion failed";
|
|
2324
|
-
debugger;
|
|
2325
|
-
throw new Error(msg);
|
|
2326
|
-
}
|
|
2327
|
-
}
|
|
2328
|
-
/**
|
|
2329
|
-
* Forked from https://github.com/lukeed/dset
|
|
2330
|
-
* Changes: fixed setting a deep value to a proxy object
|
|
2331
|
-
*/
|
|
2332
|
-
function set(obj, keys, val) {
|
|
2333
|
-
keys = keys.split ? keys.split(".") : keys;
|
|
2334
|
-
var i = 0,
|
|
2335
|
-
l = keys.length,
|
|
2336
|
-
t = obj,
|
|
2337
|
-
x,
|
|
2338
|
-
k;
|
|
2339
|
-
while (i < l) {
|
|
2340
|
-
k = keys[i++];
|
|
2341
|
-
if (k === "__proto__" || k === "constructor" || k === "prototype") break;
|
|
2342
|
-
var newValue = i === l ? val : typeof (x = t[k]) === typeof keys ? x : keys[i] * 0 !== 0 || !!~("" + keys[i]).indexOf(".") ? {} : [];
|
|
2343
|
-
assignValue(t, k, newValue);
|
|
2344
|
-
t = t[k];
|
|
2345
|
-
}
|
|
2346
|
-
}
|
|
2347
|
-
/**
|
|
2348
|
-
* Forked from lodash
|
|
2349
|
-
*/
|
|
2350
|
-
function baseAssignValue(object, key, value) {
|
|
2351
|
-
if (key == "__proto__") {
|
|
2352
|
-
Object.defineProperty(object, key, {
|
|
2353
|
-
configurable: true,
|
|
2354
|
-
enumerable: true,
|
|
2355
|
-
value: value,
|
|
2356
|
-
writable: true
|
|
2357
|
-
});
|
|
2358
|
-
} else {
|
|
2359
|
-
object[key] = value;
|
|
2360
|
-
}
|
|
2361
|
-
}
|
|
2362
|
-
function eq(value, other) {
|
|
2363
|
-
return value === other || value !== value && other !== other;
|
|
2364
|
-
}
|
|
2365
|
-
function assignValue(object, key, value) {
|
|
2366
|
-
var objValue = object[key];
|
|
2367
|
-
if (!(Object.prototype.hasOwnProperty.call(object, key) && eq(objValue, value)) || value === undefined && !(key in object)) {
|
|
2368
|
-
baseAssignValue(object, key, value);
|
|
2369
|
-
}
|
|
2370
|
-
}
|
|
2371
|
-
|
|
2372
2282
|
var UNINITIALIZED = /*#__PURE__*/Symbol("plasmic.unitialized");
|
|
2373
2283
|
var StateSpecNode = /*#__PURE__*/function () {
|
|
2374
2284
|
function StateSpecNode(specs) {
|
|
@@ -2425,14 +2335,7 @@ var StateSpecNode = /*#__PURE__*/function () {
|
|
|
2425
2335
|
this._state = {};
|
|
2426
2336
|
};
|
|
2427
2337
|
_proto.states = function states() {
|
|
2428
|
-
return Object.
|
|
2429
|
-
var key = _ref[0],
|
|
2430
|
-
stateCell = _ref[1];
|
|
2431
|
-
return {
|
|
2432
|
-
path: JSON.parse(key),
|
|
2433
|
-
stateCell: stateCell
|
|
2434
|
-
};
|
|
2435
|
-
});
|
|
2338
|
+
return Object.values(this._state);
|
|
2436
2339
|
};
|
|
2437
2340
|
_proto.hasState = function hasState(path) {
|
|
2438
2341
|
var key = JSON.stringify(path);
|
|
@@ -2560,6 +2463,133 @@ function findStateCell(root, pathStr, repetitionIndex) {
|
|
|
2560
2463
|
};
|
|
2561
2464
|
}
|
|
2562
2465
|
|
|
2466
|
+
function generateStateOnChangeProp($state, path) {
|
|
2467
|
+
return function (val) {
|
|
2468
|
+
return set($state, path, val);
|
|
2469
|
+
};
|
|
2470
|
+
}
|
|
2471
|
+
function generateStateValueProp($state, path) {
|
|
2472
|
+
return _get($state, path);
|
|
2473
|
+
}
|
|
2474
|
+
var useIsomorphicLayoutEffect$1 = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
2475
|
+
function isPlasmicStateProxy(obj) {
|
|
2476
|
+
return obj != null && typeof obj === "object" && !!obj[PLASMIC_STATE_PROXY_SYMBOL];
|
|
2477
|
+
}
|
|
2478
|
+
function getStateCellsInPlasmicProxy(obj) {
|
|
2479
|
+
if (!isPlasmicStateProxy(obj)) {
|
|
2480
|
+
return [];
|
|
2481
|
+
}
|
|
2482
|
+
var _obj$PLASMIC_STATE_PR = obj[PLASMIC_STATE_PROXY_SYMBOL],
|
|
2483
|
+
rootNode = _obj$PLASMIC_STATE_PR.node,
|
|
2484
|
+
rootPath = _obj$PLASMIC_STATE_PR.path,
|
|
2485
|
+
isOutside = _obj$PLASMIC_STATE_PR.isOutside;
|
|
2486
|
+
if (isOutside) {
|
|
2487
|
+
return [];
|
|
2488
|
+
}
|
|
2489
|
+
return getStateCells(rootNode).flatMap(function (node) {
|
|
2490
|
+
return node.states().map(function (stateCell) {
|
|
2491
|
+
return {
|
|
2492
|
+
path: node.getSpec().path,
|
|
2493
|
+
realPath: stateCell.path.slice(rootPath.length)
|
|
2494
|
+
};
|
|
2495
|
+
});
|
|
2496
|
+
});
|
|
2497
|
+
}
|
|
2498
|
+
function getStateSpecInPlasmicProxy(obj, path) {
|
|
2499
|
+
obj = _get(obj, path.slice(0, path.length - 1));
|
|
2500
|
+
if (!isPlasmicStateProxy(obj)) {
|
|
2501
|
+
return undefined;
|
|
2502
|
+
}
|
|
2503
|
+
var _obj$PLASMIC_STATE_PR2 = obj[PLASMIC_STATE_PROXY_SYMBOL],
|
|
2504
|
+
node = _obj$PLASMIC_STATE_PR2.node,
|
|
2505
|
+
isOutside = _obj$PLASMIC_STATE_PR2.isOutside;
|
|
2506
|
+
var nextNode = node.makeTransition(path[path.length - 1]);
|
|
2507
|
+
if (isOutside || node.isLeaf() || !nextNode) {
|
|
2508
|
+
return undefined;
|
|
2509
|
+
}
|
|
2510
|
+
return {
|
|
2511
|
+
spec: nextNode.getSpec(),
|
|
2512
|
+
isImplicitStateArray: nextNode.hasArrayTransition()
|
|
2513
|
+
};
|
|
2514
|
+
}
|
|
2515
|
+
function shallowEqual(a1, a2) {
|
|
2516
|
+
if (a1.length !== a2.length) {
|
|
2517
|
+
return false;
|
|
2518
|
+
}
|
|
2519
|
+
for (var i = 0; i < a1.length; i++) {
|
|
2520
|
+
if (a1[i] !== a2[i]) {
|
|
2521
|
+
return false;
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
return true;
|
|
2525
|
+
}
|
|
2526
|
+
/**
|
|
2527
|
+
* Shallow comparison of arrays.
|
|
2528
|
+
*/
|
|
2529
|
+
function arrayEq(xs, ys) {
|
|
2530
|
+
return xs.length === ys.length && xs.every(function (_, index) {
|
|
2531
|
+
return xs[index] === ys[index];
|
|
2532
|
+
});
|
|
2533
|
+
}
|
|
2534
|
+
function isNum(value) {
|
|
2535
|
+
return typeof value === "symbol" ? false : !isNaN(+value);
|
|
2536
|
+
}
|
|
2537
|
+
function assert(cond, msg) {
|
|
2538
|
+
if (msg === void 0) {
|
|
2539
|
+
msg = "Assertion failed";
|
|
2540
|
+
}
|
|
2541
|
+
if (!cond) {
|
|
2542
|
+
// We always generate an non empty message so that it doesn't get swallowed
|
|
2543
|
+
// by the async library.
|
|
2544
|
+
msg = (typeof msg === "string" ? msg : msg()) || "Assertion failed";
|
|
2545
|
+
debugger;
|
|
2546
|
+
throw new Error(msg);
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2549
|
+
/**
|
|
2550
|
+
* Forked from https://github.com/lukeed/dset
|
|
2551
|
+
* Changes: fixed setting a deep value to a proxy object
|
|
2552
|
+
*/
|
|
2553
|
+
function set(obj, keys, val) {
|
|
2554
|
+
keys = keys.split ? keys.split(".") : keys;
|
|
2555
|
+
var i = 0,
|
|
2556
|
+
l = keys.length,
|
|
2557
|
+
t = obj,
|
|
2558
|
+
x,
|
|
2559
|
+
k;
|
|
2560
|
+
while (i < l) {
|
|
2561
|
+
k = keys[i++];
|
|
2562
|
+
if (k === "__proto__" || k === "constructor" || k === "prototype") break;
|
|
2563
|
+
var newValue = i === l ? val : typeof (x = t[k]) === typeof keys ? x : keys[i] * 0 !== 0 || !!~("" + keys[i]).indexOf(".") ? {} : [];
|
|
2564
|
+
assignValue(t, k, newValue);
|
|
2565
|
+
t = t[k];
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
/**
|
|
2569
|
+
* Forked from lodash
|
|
2570
|
+
*/
|
|
2571
|
+
function baseAssignValue(object, key, value) {
|
|
2572
|
+
if (key == "__proto__") {
|
|
2573
|
+
Object.defineProperty(object, key, {
|
|
2574
|
+
configurable: true,
|
|
2575
|
+
enumerable: true,
|
|
2576
|
+
value: value,
|
|
2577
|
+
writable: true
|
|
2578
|
+
});
|
|
2579
|
+
} else {
|
|
2580
|
+
object[key] = value;
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2583
|
+
function eq(value, other) {
|
|
2584
|
+
return value === other || value !== value && other !== other;
|
|
2585
|
+
}
|
|
2586
|
+
function assignValue(object, key, value) {
|
|
2587
|
+
var objValue = object[key];
|
|
2588
|
+
if (!(Object.prototype.hasOwnProperty.call(object, key) && eq(objValue, value)) || value === undefined && !(key in object)) {
|
|
2589
|
+
baseAssignValue(object, key, value);
|
|
2590
|
+
}
|
|
2591
|
+
}
|
|
2592
|
+
|
|
2563
2593
|
function isNum$1(value) {
|
|
2564
2594
|
return typeof value === "symbol" ? false : !isNaN(+value);
|
|
2565
2595
|
}
|
|
@@ -2632,7 +2662,11 @@ function create$StateProxy($$state, leafHandlers) {
|
|
|
2632
2662
|
},
|
|
2633
2663
|
get: function get(target, property, receiver) {
|
|
2634
2664
|
if (property === PLASMIC_STATE_PROXY_SYMBOL) {
|
|
2635
|
-
return
|
|
2665
|
+
return {
|
|
2666
|
+
node: currNode,
|
|
2667
|
+
path: currPath,
|
|
2668
|
+
isOutside: isOutside
|
|
2669
|
+
};
|
|
2636
2670
|
}
|
|
2637
2671
|
var nextPath = getNextPath(property);
|
|
2638
2672
|
if (isOutside || currNode.isLeaf()) {
|
|
@@ -2802,16 +2836,15 @@ function useDollarState(specs, props, $ctx, opts) {
|
|
|
2802
2836
|
// the init value has changed. If so, reset its state.
|
|
2803
2837
|
var resetSpecs = [];
|
|
2804
2838
|
$$state.specTreeLeaves.flatMap(function (node) {
|
|
2805
|
-
return node.states().map(function (
|
|
2806
|
-
var stateCell = _ref3.stateCell;
|
|
2839
|
+
return node.states().map(function (stateCell) {
|
|
2807
2840
|
return {
|
|
2808
2841
|
stateCell: stateCell,
|
|
2809
2842
|
node: node
|
|
2810
2843
|
};
|
|
2811
2844
|
});
|
|
2812
|
-
}).forEach(function (
|
|
2813
|
-
var node =
|
|
2814
|
-
stateCell =
|
|
2845
|
+
}).forEach(function (_ref3) {
|
|
2846
|
+
var node = _ref3.node,
|
|
2847
|
+
stateCell = _ref3.stateCell;
|
|
2815
2848
|
var initFunc = node.getInitFunc(stateCell);
|
|
2816
2849
|
if (initFunc) {
|
|
2817
2850
|
var newInit = initFunc(props, $state, $ctx != null ? $ctx : {});
|
|
@@ -2832,9 +2865,9 @@ function useDollarState(specs, props, $ctx, opts) {
|
|
|
2832
2865
|
}
|
|
2833
2866
|
};
|
|
2834
2867
|
useIsomorphicLayoutEffect$1(function () {
|
|
2835
|
-
resetSpecs.forEach(function (
|
|
2836
|
-
var stateCell =
|
|
2837
|
-
node =
|
|
2868
|
+
resetSpecs.forEach(function (_ref4) {
|
|
2869
|
+
var stateCell = _ref4.stateCell,
|
|
2870
|
+
node = _ref4.node;
|
|
2838
2871
|
reInitializeState(node, stateCell);
|
|
2839
2872
|
});
|
|
2840
2873
|
}, [props, resetSpecs]);
|
|
@@ -4297,6 +4330,8 @@ exports.genTranslatableString = genTranslatableString;
|
|
|
4297
4330
|
exports.generateStateOnChangeProp = generateStateOnChangeProp;
|
|
4298
4331
|
exports.generateStateValueProp = generateStateValueProp;
|
|
4299
4332
|
exports.getDataProps = getDataProps;
|
|
4333
|
+
exports.getStateCellsInPlasmicProxy = getStateCellsInPlasmicProxy;
|
|
4334
|
+
exports.getStateSpecInPlasmicProxy = getStateSpecInPlasmicProxy;
|
|
4300
4335
|
exports.hasVariant = hasVariant;
|
|
4301
4336
|
exports.isPlasmicStateProxy = isPlasmicStateProxy;
|
|
4302
4337
|
exports.makeFragment = makeFragment;
|