@plasmicapp/react-web 0.2.110 → 0.2.112
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 +30 -13
- package/dist/index-common.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/react-web.cjs.development.js +366 -342
- 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 +363 -342
- package/dist/react-web.esm.js.map +1 -1
- package/dist/render/elements.d.ts +5 -0
- package/dist/states/helpers.d.ts +5 -0
- package/dist/states/index.d.ts +1 -1
- package/dist/states/valtio.d.ts +16 -0
- package/dist/stories/UseDollarState.stories.d.ts +11 -0
- package/package.json +6 -2
- package/skinny/dist/collection-utils-42de4441.js +244 -0
- package/skinny/dist/collection-utils-42de4441.js.map +1 -0
- package/skinny/dist/{collection-utils-3487dd27.js → collection-utils-bf37b8fb.js} +5 -5
- package/skinny/dist/collection-utils-bf37b8fb.js.map +1 -0
- package/skinny/dist/common-98719219.js +68 -0
- package/skinny/dist/common-98719219.js.map +1 -0
- package/skinny/dist/common-9efbae57.js +201 -0
- package/skinny/dist/common-9efbae57.js.map +1 -0
- package/skinny/dist/context-4ca6f5cd.js +6 -0
- package/skinny/dist/context-4ca6f5cd.js.map +1 -0
- package/skinny/dist/index-common.d.ts +1 -1
- package/skinny/dist/index.d.ts +1 -1
- package/skinny/dist/index.js +17 -4
- package/skinny/dist/index.js.map +1 -1
- package/skinny/dist/plume/checkbox/index.js +2 -1
- package/skinny/dist/plume/checkbox/index.js.map +1 -1
- package/skinny/dist/plume/menu/index.js +2 -1
- package/skinny/dist/plume/menu/index.js.map +1 -1
- package/skinny/dist/plume/menu-button/index.js +2 -1
- package/skinny/dist/plume/menu-button/index.js.map +1 -1
- package/skinny/dist/plume/select/index.js +2 -1
- package/skinny/dist/plume/select/index.js.map +1 -1
- package/skinny/dist/plume/switch/index.js +2 -1
- package/skinny/dist/plume/switch/index.js.map +1 -1
- package/skinny/dist/plume-utils-1e225de5.js +25 -0
- package/skinny/dist/plume-utils-1e225de5.js.map +1 -0
- package/skinny/dist/plume-utils-d2476af1.js +35 -0
- package/skinny/dist/plume-utils-d2476af1.js.map +1 -0
- package/skinny/dist/props-utils-c60d3105.js +8 -0
- package/skinny/dist/props-utils-c60d3105.js.map +1 -0
- package/skinny/dist/props-utils-cac0cccf.js +8 -0
- package/skinny/dist/props-utils-cac0cccf.js.map +1 -0
- package/skinny/dist/react-utils-6050fadc.js +201 -0
- package/skinny/dist/react-utils-6050fadc.js.map +1 -0
- package/skinny/dist/react-utils-b5dc6320.js +155 -0
- package/skinny/dist/react-utils-b5dc6320.js.map +1 -0
- package/skinny/dist/render/elements.d.ts +5 -0
- package/skinny/dist/{ssr-84e27ffb.js → ssr-68913b60.js} +34 -37
- package/skinny/dist/ssr-68913b60.js.map +1 -0
- package/skinny/dist/{ssr-b1615b80.js → ssr-d3321868.js} +9 -4
- package/skinny/dist/ssr-d3321868.js.map +1 -0
- package/skinny/dist/states/helpers.d.ts +5 -0
- package/skinny/dist/states/index.d.ts +1 -1
- package/skinny/dist/states/valtio copy.d.ts +15 -0
- package/skinny/dist/states/valtio.d.ts +16 -0
- package/skinny/dist/stories/UseDollarState.stories.d.ts +11 -0
- package/skinny/dist/stories/UseDollarState.test.d.ts +11 -0
- package/skinny/dist/stories/UseDollarState2.stories.d.ts +7 -0
- package/skinny/dist/collection-utils-3487dd27.js.map +0 -1
- package/skinny/dist/ssr-14264281.js +0 -158
- package/skinny/dist/ssr-14264281.js.map +0 -1
- package/skinny/dist/ssr-5141fc77.js +0 -158
- package/skinny/dist/ssr-5141fc77.js.map +0 -1
- package/skinny/dist/ssr-579df58f.js +0 -158
- package/skinny/dist/ssr-579df58f.js.map +0 -1
- package/skinny/dist/ssr-84e27ffb.js.map +0 -1
- package/skinny/dist/ssr-b1615b80.js.map +0 -1
- package/skinny/dist/ssr-d2fd94f2.js +0 -31
- package/skinny/dist/ssr-d2fd94f2.js.map +0 -1
|
@@ -5,10 +5,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
6
|
|
|
7
7
|
var classNames$1 = _interopDefault(require('classnames'));
|
|
8
|
+
var _get = _interopDefault(require('dlv'));
|
|
8
9
|
var React = require('react');
|
|
9
10
|
var React__default = _interopDefault(React);
|
|
10
11
|
var ReactDOM = require('react-dom');
|
|
11
12
|
var ReactDOM__default = _interopDefault(ReactDOM);
|
|
13
|
+
var dataSourcesContext = require('@plasmicapp/data-sources-context');
|
|
12
14
|
var ssr = require('@react-aria/ssr');
|
|
13
15
|
var focus = require('@react-aria/focus');
|
|
14
16
|
var checkbox = require('@react-aria/checkbox');
|
|
@@ -25,8 +27,9 @@ var listbox = require('@react-aria/listbox');
|
|
|
25
27
|
var select$1 = require('@react-stately/select');
|
|
26
28
|
var _switch = require('@react-aria/switch');
|
|
27
29
|
var overlays = require('@react-aria/overlays');
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
+
var deepEqual = _interopDefault(require('fast-deep-equal'));
|
|
31
|
+
var valtio = require('valtio');
|
|
32
|
+
var utils = require('valtio/utils');
|
|
30
33
|
|
|
31
34
|
function _extends() {
|
|
32
35
|
_extends = Object.assign || function (target) {
|
|
@@ -692,6 +695,14 @@ function mergeVariants(v1, v2) {
|
|
|
692
695
|
return _extends({}, v1, v2);
|
|
693
696
|
}
|
|
694
697
|
|
|
698
|
+
function mergeVariantsWithStates(variants, $state, linkedStates) {
|
|
699
|
+
return _extends({}, variants, Object.fromEntries(linkedStates.map(function (_ref) {
|
|
700
|
+
var variantGroup = _ref.variantGroup,
|
|
701
|
+
statePath = _ref.statePath;
|
|
702
|
+
return [variantGroup, _get($state, statePath)];
|
|
703
|
+
})));
|
|
704
|
+
}
|
|
705
|
+
|
|
695
706
|
function mergeArgs(a1, a2) {
|
|
696
707
|
if (!a1 || !a2) {
|
|
697
708
|
return a1 || a2 || {};
|
|
@@ -717,7 +728,7 @@ function mergeFlexOverrides(o1, o2) {
|
|
|
717
728
|
}
|
|
718
729
|
|
|
719
730
|
function mergeFlexOverride(fo1, fo2) {
|
|
720
|
-
var _o1$props,
|
|
731
|
+
var _o1$props, _ref2;
|
|
721
732
|
|
|
722
733
|
if (!fo1) {
|
|
723
734
|
return fo2;
|
|
@@ -753,7 +764,7 @@ function mergeFlexOverride(fo1, fo2) {
|
|
|
753
764
|
} // "as" will take precedence
|
|
754
765
|
|
|
755
766
|
|
|
756
|
-
var as = (
|
|
767
|
+
var as = (_ref2 = o2.type === "as" ? o2.as : undefined) != null ? _ref2 : o1.type === "as" ? o1.as : undefined;
|
|
757
768
|
return _extends({
|
|
758
769
|
props: props,
|
|
759
770
|
wrap: wrap,
|
|
@@ -1538,19 +1549,27 @@ function createUseScreenVariants(isMulti, screenQueries) {
|
|
|
1538
1549
|
var PlasmicRootContext = /*#__PURE__*/React.createContext(undefined);
|
|
1539
1550
|
function PlasmicRootProvider(props) {
|
|
1540
1551
|
var platform = props.platform,
|
|
1541
|
-
children = props.children
|
|
1552
|
+
children = props.children,
|
|
1553
|
+
userAuthToken = props.userAuthToken;
|
|
1542
1554
|
var context = React.useMemo(function () {
|
|
1543
1555
|
return {
|
|
1544
1556
|
platform: platform
|
|
1545
1557
|
};
|
|
1546
1558
|
}, [platform]);
|
|
1559
|
+
var dataSourceContextValue = React.useMemo(function () {
|
|
1560
|
+
return {
|
|
1561
|
+
userAuthToken: userAuthToken
|
|
1562
|
+
};
|
|
1563
|
+
}, [userAuthToken]);
|
|
1547
1564
|
return React.createElement(PlasmicRootContext.Provider, {
|
|
1548
1565
|
value: context
|
|
1549
|
-
}, React.createElement(ssr.SSRProvider, null, React.createElement(
|
|
1566
|
+
}, React.createElement(ssr.SSRProvider, null, React.createElement(dataSourcesContext.PlasmicDataSourceContextProvider, {
|
|
1567
|
+
value: dataSourceContextValue
|
|
1568
|
+
}, React.createElement(PlasmicTranslatorContext.Provider, {
|
|
1550
1569
|
value: props.translator
|
|
1551
1570
|
}, React.createElement(PlasmicHeadContext.Provider, {
|
|
1552
1571
|
value: props.Head
|
|
1553
|
-
}, children))));
|
|
1572
|
+
}, children)))));
|
|
1554
1573
|
}
|
|
1555
1574
|
var useIsSSR = ssr.useIsSSR;
|
|
1556
1575
|
function useHasPlasmicRoot() {
|
|
@@ -3217,7 +3236,7 @@ function useTriggeredOverlay(plasmicClass, props, config, outerRef, isDismissabl
|
|
|
3217
3236
|
|
|
3218
3237
|
function generateStateOnChangeProp($state, stateName, dataReps) {
|
|
3219
3238
|
return function (val, path) {
|
|
3220
|
-
return
|
|
3239
|
+
return set($state, [stateName].concat(dataReps, path), val);
|
|
3221
3240
|
};
|
|
3222
3241
|
}
|
|
3223
3242
|
/**
|
|
@@ -3231,8 +3250,51 @@ function generateStateValueProp($state, path // ["parent", 0, 1, "counter"]
|
|
|
3231
3250
|
) {
|
|
3232
3251
|
return _get($state, path);
|
|
3233
3252
|
}
|
|
3253
|
+
/**
|
|
3254
|
+
* Forked from https://github.com/lukeed/dset
|
|
3255
|
+
* Changes: fixed setting a deep value to a proxy object
|
|
3256
|
+
*/
|
|
3234
3257
|
|
|
3235
|
-
|
|
3258
|
+
function set(obj, keys, val) {
|
|
3259
|
+
keys = keys.split ? keys.split(".") : keys;
|
|
3260
|
+
var i = 0,
|
|
3261
|
+
l = keys.length,
|
|
3262
|
+
t = obj,
|
|
3263
|
+
x,
|
|
3264
|
+
k;
|
|
3265
|
+
|
|
3266
|
+
while (i < l) {
|
|
3267
|
+
k = keys[i++];
|
|
3268
|
+
if (k === "__proto__" || k === "constructor" || k === "prototype") break;
|
|
3269
|
+
|
|
3270
|
+
if (i === l) {
|
|
3271
|
+
t[k] = val;
|
|
3272
|
+
t = t[k];
|
|
3273
|
+
} else {
|
|
3274
|
+
if (typeof (x = t[k]) === typeof keys) {
|
|
3275
|
+
t = t[k] = x;
|
|
3276
|
+
} else if (keys[i] * 0 !== 0 || !!~("" + keys[i]).indexOf(".")) {
|
|
3277
|
+
t[k] = {};
|
|
3278
|
+
t = t[k];
|
|
3279
|
+
} else {
|
|
3280
|
+
t[k] = [];
|
|
3281
|
+
t = t[k];
|
|
3282
|
+
}
|
|
3283
|
+
}
|
|
3284
|
+
}
|
|
3285
|
+
}
|
|
3286
|
+
|
|
3287
|
+
var mkUntrackedValue = function mkUntrackedValue(o) {
|
|
3288
|
+
return typeof o === "object" ? valtio.ref(o) : o;
|
|
3289
|
+
};
|
|
3290
|
+
|
|
3291
|
+
var transformPathStringToObj = function transformPathStringToObj(str) {
|
|
3292
|
+
var splitStatePathPart = function splitStatePathPart(state) {
|
|
3293
|
+
return state.endsWith("[]") ? [].concat(splitStatePathPart(state.slice(0, -2)), ["[]"]) : [state];
|
|
3294
|
+
};
|
|
3295
|
+
|
|
3296
|
+
return str.split(".").flatMap(splitStatePathPart);
|
|
3297
|
+
};
|
|
3236
3298
|
|
|
3237
3299
|
function shallowEqual(a1, a2) {
|
|
3238
3300
|
if (a1.length !== a2.length) {
|
|
@@ -3248,145 +3310,144 @@ function shallowEqual(a1, a2) {
|
|
|
3248
3310
|
return true;
|
|
3249
3311
|
}
|
|
3250
3312
|
|
|
3251
|
-
|
|
3313
|
+
function isNum(value) {
|
|
3252
3314
|
return typeof value === "symbol" ? false : !isNaN(+value);
|
|
3253
|
-
}
|
|
3315
|
+
}
|
|
3254
3316
|
|
|
3255
|
-
function
|
|
3256
|
-
var
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3317
|
+
function saveNewState($$state, path, spec) {
|
|
3318
|
+
var key = JSON.stringify(path);
|
|
3319
|
+
$$state.existingStates.set(key, {
|
|
3320
|
+
path: path,
|
|
3321
|
+
specKey: spec.path
|
|
3322
|
+
});
|
|
3323
|
+
|
|
3324
|
+
if (!$$state.statesInstanceBySpec.has(spec.path)) {
|
|
3325
|
+
$$state.statesInstanceBySpec.set(spec.path, []);
|
|
3326
|
+
}
|
|
3327
|
+
|
|
3328
|
+
$$state.statesInstanceBySpec.get(spec.path).push({
|
|
3329
|
+
path: path,
|
|
3330
|
+
specKey: spec.path
|
|
3331
|
+
});
|
|
3332
|
+
}
|
|
3266
3333
|
|
|
3267
|
-
|
|
3268
|
-
|
|
3334
|
+
function create$StateProxy($$state, handlers) {
|
|
3335
|
+
var getNextKeyToSpecMap = function getNextKeyToSpecMap(currPath) {
|
|
3336
|
+
return new Map(Object.entries(Object.values($$state.specsByKey).filter(function (spec) {
|
|
3269
3337
|
return shallowEqual(currPath.map(function (p) {
|
|
3270
3338
|
return isNum(p) ? "[]" : p;
|
|
3271
|
-
}), spec.
|
|
3272
|
-
}).
|
|
3273
|
-
var
|
|
3274
|
-
|
|
3275
|
-
if (
|
|
3276
|
-
|
|
3277
|
-
isLast: true,
|
|
3278
|
-
specKey: spec.pathStr
|
|
3279
|
-
}];
|
|
3280
|
-
} else {
|
|
3281
|
-
return [nextPart, {
|
|
3282
|
-
isLast: false,
|
|
3283
|
-
specKey: spec.pathStr
|
|
3284
|
-
}];
|
|
3339
|
+
}), spec.pathObj.slice(0, currPath.length));
|
|
3340
|
+
}).reduce(function (agg, spec) {
|
|
3341
|
+
var nextKey = spec.pathObj[currPath.length];
|
|
3342
|
+
|
|
3343
|
+
if (!(nextKey in agg)) {
|
|
3344
|
+
agg[nextKey] = [];
|
|
3285
3345
|
}
|
|
3286
|
-
}));
|
|
3287
|
-
};
|
|
3288
|
-
/**
|
|
3289
|
-
* We use this function when we're setting a value in the middle of the state path.
|
|
3290
|
-
* We can't just set the value, because we need to keep the proxy properties, so
|
|
3291
|
-
* we use the specs to walk through the object and just set the value in the end of the path
|
|
3292
|
-
**/
|
|
3293
3346
|
|
|
3347
|
+
agg[nextKey].push(spec);
|
|
3348
|
+
return agg;
|
|
3349
|
+
}, {})));
|
|
3350
|
+
};
|
|
3294
3351
|
|
|
3295
|
-
var
|
|
3296
|
-
|
|
3297
|
-
return;
|
|
3298
|
-
}
|
|
3352
|
+
var rec = function rec(currPath) {
|
|
3353
|
+
var nextKeyToSpecs = getNextKeyToSpecMap(currPath);
|
|
3299
3354
|
|
|
3300
|
-
var
|
|
3355
|
+
var getSpecForProperty = function getSpecForProperty(property) {
|
|
3356
|
+
var _nextKeyToSpecs$get, _nextKeyToSpecs$get2;
|
|
3301
3357
|
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
nextPart = _Object$entries$_i[0],
|
|
3305
|
-
_Object$entries$_i$ = _Object$entries$_i[1],
|
|
3306
|
-
isLast = _Object$entries$_i$.isLast,
|
|
3307
|
-
specKey = _Object$entries$_i$.specKey;
|
|
3358
|
+
return nextKeyToSpecs.has("[]") && isNum(property) ? (_nextKeyToSpecs$get = nextKeyToSpecs.get("[]")) == null ? void 0 : _nextKeyToSpecs$get[0] : typeof property === "string" && nextKeyToSpecs.has(property) ? (_nextKeyToSpecs$get2 = nextKeyToSpecs.get(property)) == null ? void 0 : _nextKeyToSpecs$get2[0] : undefined;
|
|
3359
|
+
};
|
|
3308
3360
|
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
}
|
|
3313
|
-
} else if (nextPart in value) {
|
|
3314
|
-
if (isLast) {
|
|
3315
|
-
var _handlers$set, _handlers;
|
|
3316
|
-
|
|
3317
|
-
handlers == null ? void 0 : (_handlers$set = (_handlers = handlers({
|
|
3318
|
-
specKey: specKey,
|
|
3319
|
-
path: [].concat(currPath, [nextPart])
|
|
3320
|
-
})).set) == null ? void 0 : _handlers$set.call(_handlers, target, nextPart, value[nextPart], undefined);
|
|
3321
|
-
} else {
|
|
3322
|
-
cloneValue(target[nextPart], [].concat(currPath, [nextPart]), value[nextPart]);
|
|
3323
|
-
}
|
|
3324
|
-
}
|
|
3325
|
-
}
|
|
3326
|
-
};
|
|
3361
|
+
var getNextPath = function getNextPath(property) {
|
|
3362
|
+
return [].concat(currPath, [isNum(property) ? +property : property]);
|
|
3363
|
+
};
|
|
3327
3364
|
|
|
3328
|
-
|
|
3329
|
-
var nextParts = getNextParts(currPath);
|
|
3330
|
-
return new Proxy("[]" in nextParts ? [] : {}, {
|
|
3365
|
+
return new Proxy(nextKeyToSpecs.has("[]") ? [] : {}, {
|
|
3331
3366
|
deleteProperty: function deleteProperty(target, property) {
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
}
|
|
3367
|
+
var prefixPath = getNextPath(property);
|
|
3368
|
+
var specKeysToUpdate = new Set();
|
|
3369
|
+
$$state.existingStates.forEach(function (_ref) {
|
|
3370
|
+
var path = _ref.path,
|
|
3371
|
+
specKey = _ref.specKey;
|
|
3372
|
+
|
|
3373
|
+
if (path.length >= prefixPath.length && shallowEqual(path.slice(0, prefixPath.length), prefixPath)) {
|
|
3374
|
+
deleteState($$state, path);
|
|
3375
|
+
specKeysToUpdate.add(specKey);
|
|
3376
|
+
}
|
|
3377
|
+
});
|
|
3378
|
+
specKeysToUpdate.forEach(function (specKey) {
|
|
3379
|
+
var spec = $$state.specsByKey[specKey];
|
|
3343
3380
|
|
|
3344
|
-
|
|
3381
|
+
if (spec.onChangeProp) {
|
|
3382
|
+
var _$$state$props$spec$o, _$$state$props;
|
|
3383
|
+
|
|
3384
|
+
(_$$state$props$spec$o = (_$$state$props = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o.call(_$$state$props, _get($$state.stateValues, currPath), currPath);
|
|
3385
|
+
}
|
|
3386
|
+
});
|
|
3387
|
+
return Reflect.deleteProperty(target, property);
|
|
3345
3388
|
},
|
|
3346
3389
|
get: function get(target, property, receiver) {
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
if (
|
|
3353
|
-
var _handlers$get,
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
specKey: nextParts[property].specKey
|
|
3358
|
-
})).get) == null ? void 0 : _handlers$get.call(_handlers3, target, property, receiver);
|
|
3390
|
+
var spec = getSpecForProperty(property);
|
|
3391
|
+
|
|
3392
|
+
if (spec && typeof property !== "symbol") {
|
|
3393
|
+
var nextPath = getNextPath(property);
|
|
3394
|
+
|
|
3395
|
+
if (spec.pathObj.length === currPath.length + 1) {
|
|
3396
|
+
var _handlers$get, _handlers;
|
|
3397
|
+
|
|
3398
|
+
// reached the end of the spec
|
|
3399
|
+
target[property] = (_handlers$get = (_handlers = handlers(nextPath, spec)).get) == null ? void 0 : _handlers$get.call(_handlers, target, property, receiver);
|
|
3359
3400
|
} else if (!(property in target)) {
|
|
3360
|
-
target[property] = rec(
|
|
3401
|
+
target[property] = rec(nextPath);
|
|
3361
3402
|
}
|
|
3362
3403
|
}
|
|
3363
3404
|
|
|
3364
|
-
return target
|
|
3405
|
+
return Reflect.get(target, property, receiver);
|
|
3365
3406
|
},
|
|
3366
|
-
set: function set(target, property, value, receiver) {
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
target[property] = value;
|
|
3376
|
-
return (
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3407
|
+
set: function set$1(target, property, value, receiver) {
|
|
3408
|
+
var spec = getSpecForProperty(property);
|
|
3409
|
+
var nextPath = getNextPath(property);
|
|
3410
|
+
|
|
3411
|
+
if (spec && typeof property !== "symbol") {
|
|
3412
|
+
if (spec.pathObj.length === currPath.length + 1) {
|
|
3413
|
+
var _handlers$set, _handlers2;
|
|
3414
|
+
|
|
3415
|
+
// reached the end of the spec
|
|
3416
|
+
target[property] = (_handlers$set = (_handlers2 = handlers(nextPath, spec)).set) == null ? void 0 : _handlers$set.call(_handlers2, target, property, value, receiver);
|
|
3417
|
+
return Reflect.set(target, property, value, receiver);
|
|
3418
|
+
} else if (typeof value === "object") {
|
|
3419
|
+
target[property] = rec(nextPath);
|
|
3420
|
+
|
|
3421
|
+
for (var _i = 0, _Object$keys = Object.keys(value); _i < _Object$keys.length; _i++) {
|
|
3422
|
+
var key = _Object$keys[_i];
|
|
3423
|
+
target[property][key] = value[key];
|
|
3424
|
+
}
|
|
3425
|
+
|
|
3426
|
+
return true;
|
|
3380
3427
|
}
|
|
3381
3428
|
}
|
|
3382
3429
|
|
|
3383
|
-
if (property === "registerInitFunc") {
|
|
3384
|
-
target
|
|
3385
|
-
} else if (typeof value === "object") {
|
|
3386
|
-
cloneValue(target[property], [].concat(currPath, [isNum(property) ? +property : property]), value);
|
|
3430
|
+
if (property === "registerInitFunc" && currPath.length === 0) {
|
|
3431
|
+
return Reflect.set(target, property, value, receiver);
|
|
3387
3432
|
}
|
|
3388
3433
|
|
|
3389
|
-
|
|
3434
|
+
if (nextKeyToSpecs.has("[]")) {
|
|
3435
|
+
var _nextKeyToSpecs$get3;
|
|
3436
|
+
|
|
3437
|
+
set($$state.stateValues, nextPath, value);
|
|
3438
|
+
|
|
3439
|
+
(_nextKeyToSpecs$get3 = nextKeyToSpecs.get("[]")) == null ? void 0 : _nextKeyToSpecs$get3.forEach(function (spec) {
|
|
3440
|
+
if (spec != null && spec.onChangeProp) {
|
|
3441
|
+
var _$$state$props$spec$o2, _$$state$props2;
|
|
3442
|
+
|
|
3443
|
+
(_$$state$props$spec$o2 = (_$$state$props2 = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o2.call(_$$state$props2, value, nextPath);
|
|
3444
|
+
}
|
|
3445
|
+
});
|
|
3446
|
+
return Reflect.set(target, property, value, receiver);
|
|
3447
|
+
} // invalid setting a value that doesn't make part of the spec
|
|
3448
|
+
|
|
3449
|
+
|
|
3450
|
+
return false;
|
|
3390
3451
|
}
|
|
3391
3452
|
});
|
|
3392
3453
|
};
|
|
@@ -3394,136 +3455,136 @@ function mkProxy(specs, maybeHandlers) {
|
|
|
3394
3455
|
return rec([]);
|
|
3395
3456
|
}
|
|
3396
3457
|
|
|
3397
|
-
function
|
|
3398
|
-
var
|
|
3399
|
-
Object.values(states).forEach(function (_ref) {
|
|
3400
|
-
var path = _ref.path;
|
|
3458
|
+
var deleteState = function deleteState($$state, path) {
|
|
3459
|
+
var _$$state$unsubscripti;
|
|
3401
3460
|
|
|
3402
|
-
|
|
3461
|
+
var key = JSON.stringify(path);
|
|
3462
|
+
(_$$state$unsubscripti = $$state.unsubscriptionsByState[key]) == null ? void 0 : _$$state$unsubscripti.forEach(function (f) {
|
|
3463
|
+
return f();
|
|
3403
3464
|
});
|
|
3404
|
-
|
|
3405
|
-
|
|
3465
|
+
delete $$state.unsubscriptionsByState[key];
|
|
3466
|
+
$$state.existingStates["delete"](key); // delete get($$state.stateValues, path.slice(-1))[path.slice(-1)[0]];
|
|
3467
|
+
// delete get($$state.initStateValues, path.slice(-1))[path.slice(-1)[0]];
|
|
3468
|
+
};
|
|
3406
3469
|
|
|
3407
|
-
function
|
|
3408
|
-
|
|
3409
|
-
}
|
|
3470
|
+
var getIndexes = function getIndexes(path, spec) {
|
|
3471
|
+
var indexes = [];
|
|
3410
3472
|
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
}
|
|
3473
|
+
if (path.length !== spec.pathObj.length) {
|
|
3474
|
+
throw new Error("Unexpected error: state path and spec path have different lengths");
|
|
3475
|
+
}
|
|
3414
3476
|
|
|
3415
|
-
var
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
}
|
|
3477
|
+
for (var i = 0; i < spec.pathObj.length; i++) {
|
|
3478
|
+
if (spec.pathObj[i] === "[]") {
|
|
3479
|
+
indexes.push(path[i]);
|
|
3480
|
+
}
|
|
3481
|
+
}
|
|
3420
3482
|
|
|
3421
|
-
return
|
|
3483
|
+
return indexes;
|
|
3422
3484
|
};
|
|
3423
3485
|
|
|
3424
|
-
function
|
|
3425
|
-
var
|
|
3426
|
-
var $$state = React__default.useMemo(function () {
|
|
3427
|
-
var specs = Object.fromEntries(_specs.map(function (_ref2) {
|
|
3428
|
-
var pathStr = _ref2.path,
|
|
3429
|
-
spec = _objectWithoutPropertiesLoose(_ref2, ["path"]);
|
|
3430
|
-
|
|
3431
|
-
return [pathStr, _extends({}, spec, {
|
|
3432
|
-
pathStr: pathStr,
|
|
3433
|
-
path: transformPathStringToObj(pathStr),
|
|
3434
|
-
isRepeated: pathStr.split(".").some(function (part) {
|
|
3435
|
-
return part.endsWith("[]");
|
|
3436
|
-
})
|
|
3437
|
-
})];
|
|
3438
|
-
}));
|
|
3439
|
-
return {
|
|
3440
|
-
stateValues: mkProxy(specs),
|
|
3441
|
-
initStateDeps: {},
|
|
3442
|
-
initStateValues: mkProxy(specs),
|
|
3443
|
-
states: {},
|
|
3444
|
-
specs: specs
|
|
3445
|
-
};
|
|
3446
|
-
}, []);
|
|
3447
|
-
var $state = Object.assign(mkProxy($$state.specs, function (state) {
|
|
3448
|
-
return {
|
|
3449
|
-
deleteProperty: function deleteProperty(_target, _property) {
|
|
3450
|
-
var prefixPath = state.path;
|
|
3451
|
-
|
|
3452
|
-
for (var _i2 = 0, _Object$entries2 = Object.entries($$state.states); _i2 < _Object$entries2.length; _i2++) {
|
|
3453
|
-
var _Object$entries2$_i = _Object$entries2[_i2],
|
|
3454
|
-
key = _Object$entries2$_i[0],
|
|
3455
|
-
existingState = _Object$entries2$_i[1];
|
|
3486
|
+
function initializeStateValue($$state, initialStatePath, initialSpec) {
|
|
3487
|
+
var _$$state$unsubscripti2;
|
|
3456
3488
|
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3489
|
+
var initialStateKey = JSON.stringify(initialStatePath);
|
|
3490
|
+
var stateAccess = new Set();
|
|
3491
|
+
var $state = create$StateProxy($$state, function (path, spec) {
|
|
3492
|
+
return {
|
|
3493
|
+
get: function get() {
|
|
3494
|
+
var key = JSON.stringify(path);
|
|
3495
|
+
stateAccess.add({
|
|
3496
|
+
path: path,
|
|
3497
|
+
spec: spec
|
|
3464
3498
|
});
|
|
3465
|
-
return true;
|
|
3466
|
-
},
|
|
3467
|
-
get: function get(_target, _property) {
|
|
3468
|
-
var spec = $$state.specs[state.specKey];
|
|
3469
3499
|
|
|
3470
3500
|
if (spec.valueProp) {
|
|
3471
|
-
|
|
3472
|
-
return props[spec.valueProp];
|
|
3473
|
-
} else {
|
|
3474
|
-
return _get(props[spec.valueProp], state.path.slice(1));
|
|
3475
|
-
}
|
|
3501
|
+
return !spec.isRepeated ? $$state.props[spec.valueProp] : _get($$state.props[spec.valueProp], path.slice(1));
|
|
3476
3502
|
}
|
|
3477
3503
|
|
|
3478
|
-
if (
|
|
3479
|
-
|
|
3504
|
+
if ($$state.existingStates.has(key)) {
|
|
3505
|
+
// is already initialized
|
|
3506
|
+
return _get($$state.stateValues, path);
|
|
3507
|
+
} else if (spec.initFunc) {
|
|
3508
|
+
initializeStateValue($$state, path, spec);
|
|
3509
|
+
}
|
|
3480
3510
|
|
|
3481
|
-
|
|
3511
|
+
return _get($$state.stateValues, path);
|
|
3512
|
+
},
|
|
3513
|
+
set: function set() {
|
|
3514
|
+
throw new Error("Cannot update state values during initialization");
|
|
3515
|
+
}
|
|
3516
|
+
};
|
|
3517
|
+
});
|
|
3518
|
+
(_$$state$unsubscripti2 = $$state.unsubscriptionsByState[initialStateKey]) == null ? void 0 : _$$state$unsubscripti2.forEach(function (f) {
|
|
3519
|
+
return f();
|
|
3520
|
+
});
|
|
3521
|
+
$$state.unsubscriptionsByState[initialStateKey] = [];
|
|
3522
|
+
stateAccess.forEach(function (_ref2) {
|
|
3523
|
+
var path = _ref2.path,
|
|
3524
|
+
spec = _ref2.spec;
|
|
3525
|
+
var unsubscribe = utils.subscribeKey(_get($$state.stateValues, path.slice(-1)), path.slice(-1)[0], function () {
|
|
3526
|
+
return set($$state.stateValues, initialStatePath, mkUntrackedValue(initialSpec.initFunc($$state.props, $state, getIndexes(path, spec))));
|
|
3527
|
+
});
|
|
3528
|
+
$$state.unsubscriptionsByState[initialStateKey].push(unsubscribe);
|
|
3529
|
+
});
|
|
3530
|
+
var untrackedInitialValue = mkUntrackedValue(initialSpec.initFunc($$state.props, $state, getIndexes(initialStatePath, initialSpec)));
|
|
3482
3531
|
|
|
3483
|
-
|
|
3532
|
+
set($$state.initStateValues, initialStatePath, untrackedInitialValue);
|
|
3484
3533
|
|
|
3485
|
-
|
|
3534
|
+
set($$state.stateValues, initialStatePath, untrackedInitialValue);
|
|
3486
3535
|
|
|
3487
|
-
|
|
3536
|
+
return untrackedInitialValue;
|
|
3537
|
+
}
|
|
3488
3538
|
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3539
|
+
function useDollarState(specs, props) {
|
|
3540
|
+
var $$state = React__default.useRef(valtio.proxy({
|
|
3541
|
+
stateValues: {},
|
|
3542
|
+
initStateValues: {},
|
|
3543
|
+
specsByKey: Object.fromEntries(specs.map(function (spec) {
|
|
3544
|
+
return [spec.path, _extends({}, spec, {
|
|
3545
|
+
pathObj: transformPathStringToObj(spec.path),
|
|
3546
|
+
isRepeated: spec.path.split(".").some(function (part) {
|
|
3547
|
+
return part.endsWith("[]");
|
|
3548
|
+
})
|
|
3549
|
+
})];
|
|
3550
|
+
})),
|
|
3551
|
+
statesInstanceBySpec: new Map(),
|
|
3552
|
+
existingStates: new Map(),
|
|
3553
|
+
unsubscriptionsByState: {},
|
|
3554
|
+
props: undefined,
|
|
3555
|
+
registrationsQueue: []
|
|
3556
|
+
})).current;
|
|
3557
|
+
$$state.props = mkUntrackedValue(props);
|
|
3558
|
+
var $state = React__default.useRef(Object.assign(create$StateProxy($$state, function (path, spec) {
|
|
3559
|
+
var key = JSON.stringify(path);
|
|
3495
3560
|
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
set: function set(_target, _property, newValue) {
|
|
3499
|
-
if (newValue !== _get($$state.stateValues, state.path)) {
|
|
3500
|
-
saveState(state, $$state.states);
|
|
3561
|
+
if (!$$state.existingStates.has(key)) {
|
|
3562
|
+
var _spec$initVal;
|
|
3501
3563
|
|
|
3502
|
-
|
|
3564
|
+
saveNewState($$state, path, spec);
|
|
3565
|
+
var untrackedValue = !spec.initFunc ? mkUntrackedValue((_spec$initVal = spec.initVal) != null ? _spec$initVal : undefined) : initializeStateValue($$state, path, spec);
|
|
3503
3566
|
|
|
3504
|
-
|
|
3505
|
-
var _Object$entries3$_i = _Object$entries3[_i3],
|
|
3506
|
-
key = _Object$entries3$_i[0],
|
|
3507
|
-
deps = _Object$entries3$_i[1];
|
|
3567
|
+
set($$state.stateValues, path, untrackedValue);
|
|
3508
3568
|
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
}
|
|
3512
|
-
}
|
|
3569
|
+
set($$state.initStateValues, path, untrackedValue);
|
|
3570
|
+
}
|
|
3513
3571
|
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3572
|
+
return {
|
|
3573
|
+
get: function get() {
|
|
3574
|
+
if (spec.valueProp) {
|
|
3575
|
+
var value = !spec.isRepeated ? $$state.props[spec.valueProp] : _get($$state.props[spec.valueProp], path.slice(1));
|
|
3576
|
+
return value;
|
|
3577
|
+
} else {
|
|
3578
|
+
return _get($$state.stateValues, path);
|
|
3519
3579
|
}
|
|
3520
|
-
|
|
3521
|
-
|
|
3580
|
+
},
|
|
3581
|
+
set: function set$1(_t, _p, value) {
|
|
3582
|
+
set($$state.stateValues, path, mkUntrackedValue(value));
|
|
3522
3583
|
|
|
3523
3584
|
if (spec.onChangeProp) {
|
|
3524
|
-
var
|
|
3585
|
+
var _$$state$props$spec$o3, _$$state$props3;
|
|
3525
3586
|
|
|
3526
|
-
(
|
|
3587
|
+
(_$$state$props$spec$o3 = (_$$state$props3 = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o3.call(_$$state$props3, value, path);
|
|
3527
3588
|
}
|
|
3528
3589
|
|
|
3529
3590
|
return true;
|
|
@@ -3531,157 +3592,117 @@ function useVanillaDollarState(_specs, props) {
|
|
|
3531
3592
|
};
|
|
3532
3593
|
}), {
|
|
3533
3594
|
registerInitFunc: function registerInitFunc(pathStr, f) {
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
return _get($$state.
|
|
3595
|
+
var _$$state$statesInstan;
|
|
3596
|
+
|
|
3597
|
+
if ((_$$state$statesInstan = $$state.statesInstanceBySpec.get(pathStr)) != null && _$$state$statesInstan.some(function (_ref3) {
|
|
3598
|
+
var path = _ref3.path,
|
|
3599
|
+
specKey = _ref3.specKey;
|
|
3600
|
+
return !deepEqual(_get($$state.initStateValues, path), f(props, $state, getIndexes(path, $$state.specsByKey[specKey])));
|
|
3540
3601
|
})) {
|
|
3541
|
-
$$state.
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
forceRender(function (r) {
|
|
3545
|
-
return r + 1;
|
|
3602
|
+
$$state.registrationsQueue.push({
|
|
3603
|
+
pathStr: pathStr,
|
|
3604
|
+
f: f
|
|
3546
3605
|
});
|
|
3547
3606
|
}
|
|
3548
3607
|
}
|
|
3549
|
-
}); // For each spec with an initFunc, evaluate it and see if
|
|
3608
|
+
})).current; // For each spec with an initFunc, evaluate it and see if
|
|
3550
3609
|
// the init value has changed. If so, reset its state.
|
|
3551
3610
|
|
|
3552
|
-
var newStateValues = undefined;
|
|
3553
3611
|
var resetSpecs = [];
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
specKey = _Object$values$_i.specKey;
|
|
3559
|
-
var spec = $$state.specs[specKey];
|
|
3612
|
+
$$state.existingStates.forEach(function (_ref4) {
|
|
3613
|
+
var path = _ref4.path,
|
|
3614
|
+
specKey = _ref4.specKey;
|
|
3615
|
+
var spec = $$state.specsByKey[specKey];
|
|
3560
3616
|
|
|
3561
3617
|
if (spec.initFunc) {
|
|
3562
|
-
var newInit = spec.initFunc(props, $state);
|
|
3618
|
+
var newInit = spec.initFunc(props, $state, getIndexes(path, spec));
|
|
3563
3619
|
|
|
3564
|
-
if (newInit
|
|
3565
|
-
console.log("init changed for " + JSON.stringify(path) + " from " + _get($$state.initStateValues, path) + " to " + newInit + "; resetting state");
|
|
3620
|
+
if (!deepEqual(newInit, _get($$state.initStateValues, path))) {
|
|
3566
3621
|
resetSpecs.push({
|
|
3567
3622
|
path: path,
|
|
3568
|
-
|
|
3623
|
+
spec: spec
|
|
3569
3624
|
});
|
|
3570
|
-
|
|
3571
|
-
if (!newStateValues) {
|
|
3572
|
-
newStateValues = cloneProxy($$state.specs, $$state.states, $$state.stateValues);
|
|
3573
|
-
}
|
|
3574
|
-
|
|
3575
|
-
dset.dset(newStateValues, path, UNINITIALIZED);
|
|
3576
3625
|
}
|
|
3577
3626
|
}
|
|
3578
|
-
}
|
|
3579
|
-
|
|
3627
|
+
});
|
|
3580
3628
|
React__default.useLayoutEffect(function () {
|
|
3581
|
-
|
|
3582
|
-
var
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
var path = _ref5.path;
|
|
3586
|
-
|
|
3587
|
-
dset.dset(initStateValues, path, _get(newStateValues, path));
|
|
3588
|
-
});
|
|
3589
|
-
$$state.stateValues = cloneProxy($$state.specs, $$state.states, newStateValues);
|
|
3590
|
-
$$state.initStateValues = initStateValues;
|
|
3591
|
-
$$state.initStateDeps = _extends({}, $$state.initStateDeps, newDeps);
|
|
3592
|
-
forceRender(function (r) {
|
|
3593
|
-
return r + 1;
|
|
3594
|
-
});
|
|
3595
|
-
|
|
3596
|
-
for (var _iterator = _createForOfIteratorHelperLoose(resetSpecs), _step; !(_step = _iterator()).done;) {
|
|
3597
|
-
var _step$value = _step.value,
|
|
3598
|
-
_path = _step$value.path,
|
|
3599
|
-
_specKey = _step$value.specKey;
|
|
3600
|
-
var _spec = $$state.specs[_specKey];
|
|
3629
|
+
resetSpecs.forEach(function (_ref5) {
|
|
3630
|
+
var path = _ref5.path,
|
|
3631
|
+
spec = _ref5.spec;
|
|
3632
|
+
var newInit = initializeStateValue($$state, path, spec);
|
|
3601
3633
|
|
|
3602
|
-
|
|
3603
|
-
|
|
3634
|
+
if (spec.onChangeProp) {
|
|
3635
|
+
var _$$state$props$spec$o4, _$$state$props4;
|
|
3604
3636
|
|
|
3605
|
-
|
|
3606
|
-
(_props$_spec$onChange = props[_spec.onChangeProp]) == null ? void 0 : _props$_spec$onChange.call(props, _get(newStateValues, _path));
|
|
3607
|
-
}
|
|
3637
|
+
(_$$state$props$spec$o4 = (_$$state$props4 = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o4.call(_$$state$props4, newInit, path);
|
|
3608
3638
|
}
|
|
3609
|
-
}
|
|
3610
|
-
}, [
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
for (var _i5 = 0, _Object$values2 = Object.values($$state.states); _i5 < _Object$values2.length; _i5++) {
|
|
3621
|
-
var _path2 = _Object$values2[_i5].path;
|
|
3622
|
-
|
|
3623
|
-
_get($state, _path2);
|
|
3624
|
-
}
|
|
3639
|
+
});
|
|
3640
|
+
}, [props, resetSpecs]);
|
|
3641
|
+
React__default.useLayoutEffect(function () {
|
|
3642
|
+
$$state.registrationsQueue.forEach(function (_ref6) {
|
|
3643
|
+
var f = _ref6.f,
|
|
3644
|
+
pathStr = _ref6.pathStr;
|
|
3645
|
+
$$state.specsByKey[pathStr].initFunc = f;
|
|
3646
|
+
});
|
|
3647
|
+
$$state.registrationsQueue = [];
|
|
3648
|
+
}, [$$state.registrationsQueue]); // Re-render if any value changed in one of these objects
|
|
3625
3649
|
|
|
3650
|
+
valtio.useSnapshot($$state.stateValues, {
|
|
3651
|
+
sync: true
|
|
3652
|
+
});
|
|
3653
|
+
valtio.useSnapshot($$state.specsByKey, {
|
|
3654
|
+
sync: true
|
|
3655
|
+
});
|
|
3626
3656
|
return $state;
|
|
3627
3657
|
}
|
|
3628
3658
|
|
|
3629
|
-
function
|
|
3630
|
-
var
|
|
3631
|
-
|
|
3632
|
-
|
|
3659
|
+
function useCanvasDollarState(specs, props) {
|
|
3660
|
+
var $$state = valtio.proxy({
|
|
3661
|
+
stateValues: {},
|
|
3662
|
+
initStateValues: {},
|
|
3663
|
+
specsByKey: Object.fromEntries(specs.map(function (spec) {
|
|
3664
|
+
return [spec.path, _extends({}, spec, {
|
|
3665
|
+
pathObj: transformPathStringToObj(spec.path),
|
|
3666
|
+
isRepeated: spec.path.split(".").some(function (part) {
|
|
3667
|
+
return part.endsWith("[]");
|
|
3668
|
+
})
|
|
3669
|
+
})];
|
|
3670
|
+
})),
|
|
3671
|
+
statesInstanceBySpec: new Map(),
|
|
3672
|
+
existingStates: new Map(),
|
|
3673
|
+
unsubscriptionsByState: {},
|
|
3674
|
+
props: undefined,
|
|
3675
|
+
registrationsQueue: []
|
|
3676
|
+
});
|
|
3677
|
+
$$state.props = mkUntrackedValue(props);
|
|
3678
|
+
var $state = create$StateProxy($$state, function (path, spec) {
|
|
3633
3679
|
return {
|
|
3634
|
-
get: function get(
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
return props[spec.valueProp];
|
|
3640
|
-
} else {
|
|
3641
|
-
return _get(props[spec.valueProp], state.path.slice(1));
|
|
3642
|
-
}
|
|
3643
|
-
}
|
|
3644
|
-
|
|
3645
|
-
var value = _get(stateValues, state.path);
|
|
3646
|
-
|
|
3647
|
-
if (value === UNINITIALIZED) {
|
|
3648
|
-
// This value has a init expression; need to be evaluated.
|
|
3649
|
-
value = tracked(state);
|
|
3680
|
+
get: function get() {
|
|
3681
|
+
return _get($$state.stateValues, path);
|
|
3682
|
+
},
|
|
3683
|
+
set: function set$1(_t, _p, value) {
|
|
3684
|
+
set($$state.stateValues, path, mkUntrackedValue(value));
|
|
3650
3685
|
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
// trackInit() to know what fields were used to compute
|
|
3654
|
-
// the init value
|
|
3686
|
+
if (spec.onChangeProp) {
|
|
3687
|
+
var _$$state$props$spec$o5, _$$state$props5;
|
|
3655
3688
|
|
|
3689
|
+
(_$$state$props$spec$o5 = (_$$state$props5 = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o5.call(_$$state$props5, value, path);
|
|
3690
|
+
}
|
|
3656
3691
|
|
|
3657
|
-
|
|
3658
|
-
return value;
|
|
3659
|
-
},
|
|
3660
|
-
set: function set() {
|
|
3661
|
-
throw new Error("Cannot update state values during initialization");
|
|
3692
|
+
return true;
|
|
3662
3693
|
}
|
|
3663
3694
|
};
|
|
3664
|
-
}), {
|
|
3665
|
-
registerInitFunc: function registerInitFunc() {}
|
|
3666
3695
|
});
|
|
3667
3696
|
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
var
|
|
3671
|
-
var
|
|
3672
|
-
initFuncDeps[JSON.stringify(state.path)] = [].concat(deps.values());
|
|
3673
|
-
return res;
|
|
3674
|
-
}
|
|
3675
|
-
|
|
3676
|
-
for (var _i6 = 0, _Object$values3 = Object.values(states); _i6 < _Object$values3.length; _i6++) {
|
|
3677
|
-
var path = _Object$values3[_i6].path;
|
|
3697
|
+
for (var _iterator = _createForOfIteratorHelperLoose(specs), _step; !(_step = _iterator()).done;) {
|
|
3698
|
+
var spec = _step.value;
|
|
3699
|
+
var path = transformPathStringToObj(spec.path);
|
|
3700
|
+
var init = spec.valueProp ? $$state.props[spec.valueProp] : spec.initVal ? spec.initVal : spec.initFunc ? initializeStateValue($$state, path, $$state.specsByKey[spec.path]) : undefined;
|
|
3678
3701
|
|
|
3679
|
-
|
|
3680
|
-
_get($state, path);
|
|
3681
|
-
}
|
|
3702
|
+
set($state, path, init);
|
|
3682
3703
|
}
|
|
3683
3704
|
|
|
3684
|
-
return
|
|
3705
|
+
return $state;
|
|
3685
3706
|
}
|
|
3686
3707
|
|
|
3687
3708
|
exports.DropdownMenu = DropdownMenu;
|
|
@@ -3706,14 +3727,17 @@ exports.generateStateValueProp = generateStateValueProp;
|
|
|
3706
3727
|
exports.getDataProps = getDataProps;
|
|
3707
3728
|
exports.hasVariant = hasVariant;
|
|
3708
3729
|
exports.makeFragment = makeFragment;
|
|
3730
|
+
exports.mergeVariantsWithStates = mergeVariantsWithStates;
|
|
3709
3731
|
exports.omit = omit;
|
|
3710
3732
|
exports.pick = pick;
|
|
3711
3733
|
exports.plasmicHeadMeta = plasmicHeadMeta;
|
|
3712
3734
|
exports.renderPlasmicSlot = renderPlasmicSlot;
|
|
3735
|
+
exports.set = set;
|
|
3713
3736
|
exports.setPlumeStrictMode = setPlumeStrictMode;
|
|
3714
3737
|
exports.useButton = useButton;
|
|
3738
|
+
exports.useCanvasDollarState = useCanvasDollarState;
|
|
3715
3739
|
exports.useCheckbox = useCheckbox;
|
|
3716
|
-
exports.useDollarState =
|
|
3740
|
+
exports.useDollarState = useDollarState;
|
|
3717
3741
|
exports.useIsSSR = useIsSSR;
|
|
3718
3742
|
exports.useMenu = useMenu;
|
|
3719
3743
|
exports.useMenuButton = useMenuButton;
|