@plasmicapp/react-web 0.2.133 → 0.2.135
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 +17 -22
- package/dist/index-common.d.ts +2 -1
- package/dist/react-web.cjs.development.js +136 -92
- 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 +135 -93
- package/dist/react-web.esm.js.map +1 -1
- package/dist/render/elements.d.ts +1 -1
- package/dist/states/graph.d.ts +15 -0
- package/dist/states/helpers.d.ts +2 -0
- package/dist/states/index.d.ts +16 -7
- package/dist/states/valtio.d.ts +2 -15
- package/dist/states/vanilla.d.ts +3 -0
- package/dist/stories/UseDollarState.stories.d.ts +5 -2
- package/package.json +7 -5
- package/skinny/dist/index-common.d.ts +2 -1
- package/skinny/dist/index.js +115 -82
- package/skinny/dist/index.js.map +1 -1
- package/skinny/dist/render/elements.d.ts +1 -1
- package/skinny/dist/states/graph.d.ts +15 -0
- package/skinny/dist/states/helpers.d.ts +2 -0
- package/skinny/dist/states/index.d.ts +16 -7
- package/skinny/dist/states/valtio.d.ts +2 -15
- package/skinny/dist/states/vanilla.d.ts +3 -0
- package/skinny/dist/stories/UseDollarState.stories.d.ts +5 -2
package/dist/all.d.ts
CHANGED
|
@@ -23,23 +23,20 @@ declare function omit<T extends {}>(obj: T, ...keys: (keyof T)[]): Partial<T>;
|
|
|
23
23
|
declare type StrictProps<T, TExpected> = Exclude<keyof T, keyof TExpected> extends never ? {} : Partial<"Unexpected extraneous props">;
|
|
24
24
|
declare type HTMLElementRefOf<T extends keyof JSX.IntrinsicElements> = Exclude<React__default.ComponentProps<T>["ref"], string>;
|
|
25
25
|
|
|
26
|
-
declare type InitFunc
|
|
27
|
-
interface $State$1 {
|
|
28
|
-
[key: string]: any;
|
|
29
|
-
registerInitFunc?: (path: string, f: InitFunc$1<any>) => any;
|
|
30
|
-
}
|
|
26
|
+
declare type InitFunc<T> = ($props: Record<string, any>, $state: $State, $ctx: Record<string, any>, indexes?: number[]) => T;
|
|
31
27
|
interface $StateSpec<T> {
|
|
32
28
|
path: string;
|
|
33
|
-
initFunc?: InitFunc
|
|
29
|
+
initFunc?: InitFunc<T>;
|
|
34
30
|
initVal?: T;
|
|
35
31
|
type: "private" | "readonly" | "writable";
|
|
36
32
|
valueProp?: string;
|
|
37
33
|
onChangeProp?: string;
|
|
38
|
-
|
|
34
|
+
isImmutable?: boolean;
|
|
39
35
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
interface $State {
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
registerInitFunc?: (path: string, f: InitFunc<any>) => any;
|
|
39
|
+
}
|
|
43
40
|
|
|
44
41
|
interface Variants {
|
|
45
42
|
[vg: string]: any;
|
|
@@ -89,7 +86,7 @@ declare function wrapWithClassName(element: React.ReactNode, className: string):
|
|
|
89
86
|
display: "grid";
|
|
90
87
|
};
|
|
91
88
|
}, HTMLElement>;
|
|
92
|
-
declare function mergeVariantsWithStates(variants: Variants, $state: $State
|
|
89
|
+
declare function mergeVariantsWithStates(variants: Variants, $state: $State, linkedStates: {
|
|
93
90
|
variantGroup: string;
|
|
94
91
|
statePath: (string | number)[];
|
|
95
92
|
}[]): Variants;
|
|
@@ -565,9 +562,7 @@ interface Node<T> {
|
|
|
565
562
|
// Event bubbling can be problematic in real-world applications, so the default for React Spectrum components
|
|
566
563
|
// is not to propagate. This can be overridden by calling continuePropagation() on the event.
|
|
567
564
|
type BaseEvent<T extends SyntheticEvent> = T & {
|
|
568
|
-
/**
|
|
569
|
-
* Use continuePropagation.
|
|
570
|
-
* @deprecated */
|
|
565
|
+
/** @deprecated Use continuePropagation. */
|
|
571
566
|
stopPropagation(): void,
|
|
572
567
|
continuePropagation(): void
|
|
573
568
|
}
|
|
@@ -661,12 +656,6 @@ declare function useTrigger(trigger: TriggerType, opts: TriggerOpts): [boolean,
|
|
|
661
656
|
|
|
662
657
|
declare function dlv(object: object, key: string | Array<string | number>, defaultValue?: any): any;
|
|
663
658
|
|
|
664
|
-
declare type InitFunc<T> = ($props: Record<string, any>, $state: $State) => T;
|
|
665
|
-
interface $State {
|
|
666
|
-
[key: string]: any;
|
|
667
|
-
registerInitFunc?: (path: string, f: InitFunc<any>) => any;
|
|
668
|
-
}
|
|
669
|
-
|
|
670
659
|
declare function generateStateOnChangeProp($state: $State, stateName: string, dataReps: number[]): (val: any, path: (string | number)[]) => void;
|
|
671
660
|
/**
|
|
672
661
|
* This function generate the state value prop for repeated states
|
|
@@ -680,7 +669,13 @@ declare function generateStateValueProp($state: $State, path: (string | number)[
|
|
|
680
669
|
* Changes: fixed setting a deep value to a proxy object
|
|
681
670
|
*/
|
|
682
671
|
declare function set(obj: any, keys: any, val: any): void;
|
|
683
|
-
declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
|
|
672
|
+
declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
|
|
673
|
+
declare function shallowEqual<T>(a1: T[], a2: T[]): boolean;
|
|
674
|
+
declare function isNum(value: string | number | symbol): value is number;
|
|
675
|
+
|
|
676
|
+
declare function useDollarState(specs: $StateSpec<any>[], props: Record<string, any>, $ctx?: Record<string, any>): any;
|
|
677
|
+
|
|
678
|
+
declare function useCanvasDollarState(specs: $StateSpec<any>[], props: Record<string, any>, $ctx?: Record<string, any>): {};
|
|
684
679
|
|
|
685
680
|
declare const classNames: typeof classNames$1;
|
|
686
681
|
|
|
@@ -1640,4 +1635,4 @@ interface TriggeredOverlayContextValue {
|
|
|
1640
1635
|
}
|
|
1641
1636
|
declare const TriggeredOverlayContext: React.Context<TriggeredOverlayContextValue | undefined>;
|
|
1642
1637
|
|
|
1643
|
-
export { $State
|
|
1638
|
+
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, 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, isNum, makeFragment, mergeVariantsWithStates, omit, pick, plasmicHeadMeta, renderPlasmicSlot, set, setPlumeStrictMode, shallowEqual, useButton, useCanvasDollarState, useCheckbox, useCurrentUser, useDollarState, useIsSSR, useIsomorphicLayoutEffect, useMenu, useMenuButton, useMenuGroup, useMenuItem, useSelect, useSelectOption, useSelectOptionGroup, useSwitch, useTextInput, useTrigger, useTriggeredOverlay, wrapWithClassName };
|
package/dist/index-common.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export { PlasmicDataSourceContextProvider, PlasmicRootProvider, useCurrentUser,
|
|
|
13
13
|
export { Stack } from "./render/Stack";
|
|
14
14
|
export { genTranslatableString, Trans } from "./render/translation";
|
|
15
15
|
export { useTrigger } from "./render/triggers";
|
|
16
|
+
export { $State } from "./states";
|
|
16
17
|
export * from "./states/helpers";
|
|
17
|
-
export {
|
|
18
|
+
export { default as useDollarState, useCanvasDollarState, } from "./states/valtio";
|
|
18
19
|
export declare const classNames: typeof _classNames;
|
|
@@ -13,6 +13,7 @@ var ReactDOM__default = _interopDefault(ReactDOM);
|
|
|
13
13
|
var dataSourcesContext = require('@plasmicapp/data-sources-context');
|
|
14
14
|
var ssr = require('@react-aria/ssr');
|
|
15
15
|
var focus = require('@react-aria/focus');
|
|
16
|
+
var clone = _interopDefault(require('clone'));
|
|
16
17
|
var deepEqual = _interopDefault(require('fast-deep-equal'));
|
|
17
18
|
var valtio = require('valtio');
|
|
18
19
|
var utils = require('valtio/utils');
|
|
@@ -1739,20 +1740,105 @@ function set(obj, keys, val) {
|
|
|
1739
1740
|
}
|
|
1740
1741
|
}
|
|
1741
1742
|
var useIsomorphicLayoutEffect$1 = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
1743
|
+
function shallowEqual(a1, a2) {
|
|
1744
|
+
if (a1.length !== a2.length) {
|
|
1745
|
+
return false;
|
|
1746
|
+
}
|
|
1742
1747
|
|
|
1743
|
-
var
|
|
1744
|
-
|
|
1745
|
-
|
|
1748
|
+
for (var i = 0; i < a1.length; i++) {
|
|
1749
|
+
if (a1[i] !== a2[i]) {
|
|
1750
|
+
return false;
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
return true;
|
|
1755
|
+
}
|
|
1756
|
+
function isNum(value) {
|
|
1757
|
+
return typeof value === "symbol" ? false : !isNaN(+value);
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
var ARRAY_SYMBOL = /*#__PURE__*/Symbol("[]");
|
|
1761
|
+
|
|
1762
|
+
var StateSpecNode = /*#__PURE__*/function () {
|
|
1763
|
+
function StateSpecNode(specs) {
|
|
1764
|
+
this.specs = specs;
|
|
1765
|
+
this.edges = new Map();
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
var _proto = StateSpecNode.prototype;
|
|
1769
|
+
|
|
1770
|
+
_proto.hasEdge = function hasEdge(key) {
|
|
1771
|
+
return this.edges.has(key);
|
|
1772
|
+
};
|
|
1773
|
+
|
|
1774
|
+
_proto.addEdge = function addEdge(key, node) {
|
|
1775
|
+
this.edges.set(key, node);
|
|
1776
|
+
};
|
|
1777
|
+
|
|
1778
|
+
_proto.makeTransition = function makeTransition(key) {
|
|
1779
|
+
key = isNum(key) ? ARRAY_SYMBOL : key;
|
|
1780
|
+
return this.edges.get(key);
|
|
1781
|
+
};
|
|
1782
|
+
|
|
1783
|
+
_proto.isLeaf = function isLeaf() {
|
|
1784
|
+
return this.edges.size === 0;
|
|
1785
|
+
};
|
|
1786
|
+
|
|
1787
|
+
_proto.hasArrayTransition = function hasArrayTransition() {
|
|
1788
|
+
return this.edges.has(ARRAY_SYMBOL);
|
|
1789
|
+
};
|
|
1746
1790
|
|
|
1791
|
+
_proto.getSpec = function getSpec() {
|
|
1792
|
+
return this.specs[0];
|
|
1793
|
+
};
|
|
1794
|
+
|
|
1795
|
+
_proto.getAllSpecs = function getAllSpecs() {
|
|
1796
|
+
return this.specs;
|
|
1797
|
+
};
|
|
1798
|
+
|
|
1799
|
+
return StateSpecNode;
|
|
1800
|
+
}();
|
|
1747
1801
|
var transformPathStringToObj = function transformPathStringToObj(str) {
|
|
1748
1802
|
var splitStatePathPart = function splitStatePathPart(state) {
|
|
1749
|
-
return state.endsWith("[]") ? [].concat(splitStatePathPart(state.slice(0, -2)), [
|
|
1803
|
+
return state.endsWith("[]") ? [].concat(splitStatePathPart(state.slice(0, -2)), [ARRAY_SYMBOL]) : [state];
|
|
1750
1804
|
};
|
|
1751
1805
|
|
|
1752
1806
|
return str.split(".").flatMap(splitStatePathPart);
|
|
1753
1807
|
};
|
|
1808
|
+
function buildGraph(specs) {
|
|
1809
|
+
var internalSpec = specs.map(function (spec) {
|
|
1810
|
+
return _extends({}, spec, {
|
|
1811
|
+
pathObj: transformPathStringToObj(spec.path),
|
|
1812
|
+
isRepeated: spec.path.split(".").some(function (part) {
|
|
1813
|
+
return part.endsWith("[]");
|
|
1814
|
+
})
|
|
1815
|
+
});
|
|
1816
|
+
});
|
|
1754
1817
|
|
|
1755
|
-
function
|
|
1818
|
+
var rec = function rec(currentPath) {
|
|
1819
|
+
var node = new StateSpecNode(internalSpec.filter(function (spec) {
|
|
1820
|
+
return shallowEqual(currentPath, spec.pathObj.slice(0, currentPath.length));
|
|
1821
|
+
}));
|
|
1822
|
+
node.getAllSpecs().forEach(function (spec) {
|
|
1823
|
+
if (spec.pathObj.length > currentPath.length) {
|
|
1824
|
+
var nextKey = spec.pathObj[currentPath.length];
|
|
1825
|
+
|
|
1826
|
+
if (!node.hasEdge(nextKey)) {
|
|
1827
|
+
node.addEdge(nextKey, rec([].concat(currentPath, [nextKey])));
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
});
|
|
1831
|
+
return node;
|
|
1832
|
+
};
|
|
1833
|
+
|
|
1834
|
+
return rec([]);
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
var mkUntrackedValue = function mkUntrackedValue(o) {
|
|
1838
|
+
return o != null && typeof o === "object" ? valtio.ref(o) : o;
|
|
1839
|
+
};
|
|
1840
|
+
|
|
1841
|
+
function shallowEqual$1(a1, a2) {
|
|
1756
1842
|
if (a1.length !== a2.length) {
|
|
1757
1843
|
return false;
|
|
1758
1844
|
}
|
|
@@ -1766,7 +1852,7 @@ function shallowEqual(a1, a2) {
|
|
|
1766
1852
|
return true;
|
|
1767
1853
|
}
|
|
1768
1854
|
|
|
1769
|
-
function isNum(value) {
|
|
1855
|
+
function isNum$1(value) {
|
|
1770
1856
|
return typeof value === "symbol" ? false : !isNaN(+value);
|
|
1771
1857
|
}
|
|
1772
1858
|
|
|
@@ -1788,37 +1874,12 @@ function saveNewState($$state, path, spec) {
|
|
|
1788
1874
|
}
|
|
1789
1875
|
|
|
1790
1876
|
function create$StateProxy($$state, handlers) {
|
|
1791
|
-
var
|
|
1792
|
-
return new Map(Object.entries(Object.values($$state.specsByKey).filter(function (spec) {
|
|
1793
|
-
return shallowEqual(currPath.map(function (p) {
|
|
1794
|
-
return isNum(p) ? "[]" : p;
|
|
1795
|
-
}), spec.pathObj.slice(0, currPath.length));
|
|
1796
|
-
}).reduce(function (agg, spec) {
|
|
1797
|
-
var nextKey = spec.pathObj[currPath.length];
|
|
1798
|
-
|
|
1799
|
-
if (!(nextKey in agg)) {
|
|
1800
|
-
agg[nextKey] = [];
|
|
1801
|
-
}
|
|
1802
|
-
|
|
1803
|
-
agg[nextKey].push(spec);
|
|
1804
|
-
return agg;
|
|
1805
|
-
}, {})));
|
|
1806
|
-
};
|
|
1807
|
-
|
|
1808
|
-
var rec = function rec(currPath) {
|
|
1809
|
-
var nextKeyToSpecs = getNextKeyToSpecMap(currPath);
|
|
1810
|
-
|
|
1811
|
-
var getSpecForProperty = function getSpecForProperty(property) {
|
|
1812
|
-
var _nextKeyToSpecs$get, _nextKeyToSpecs$get2;
|
|
1813
|
-
|
|
1814
|
-
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;
|
|
1815
|
-
};
|
|
1816
|
-
|
|
1877
|
+
var rec = function rec(currPath, currNode) {
|
|
1817
1878
|
var getNextPath = function getNextPath(property) {
|
|
1818
|
-
return [].concat(currPath, [isNum(property) ? +property : property]);
|
|
1879
|
+
return [].concat(currPath, [isNum$1(property) ? +property : property]);
|
|
1819
1880
|
};
|
|
1820
1881
|
|
|
1821
|
-
return new Proxy(
|
|
1882
|
+
return new Proxy(currNode.hasArrayTransition() ? [] : {}, {
|
|
1822
1883
|
deleteProperty: function deleteProperty(target, property) {
|
|
1823
1884
|
var prefixPath = getNextPath(property);
|
|
1824
1885
|
var specKeysToUpdate = new Set();
|
|
@@ -1826,7 +1887,7 @@ function create$StateProxy($$state, handlers) {
|
|
|
1826
1887
|
var path = _ref.path,
|
|
1827
1888
|
specKey = _ref.specKey;
|
|
1828
1889
|
|
|
1829
|
-
if (path.length >= prefixPath.length && shallowEqual(path.slice(0, prefixPath.length), prefixPath)) {
|
|
1890
|
+
if (path.length >= prefixPath.length && shallowEqual$1(path.slice(0, prefixPath.length), prefixPath)) {
|
|
1830
1891
|
deleteState($$state, path);
|
|
1831
1892
|
specKeysToUpdate.add(specKey);
|
|
1832
1893
|
}
|
|
@@ -1843,36 +1904,34 @@ function create$StateProxy($$state, handlers) {
|
|
|
1843
1904
|
return Reflect.deleteProperty(target, property);
|
|
1844
1905
|
},
|
|
1845
1906
|
get: function get(target, property, receiver) {
|
|
1846
|
-
var
|
|
1847
|
-
|
|
1848
|
-
if (spec && typeof property !== "symbol") {
|
|
1849
|
-
var nextPath = getNextPath(property);
|
|
1907
|
+
var nextPath = getNextPath(property);
|
|
1908
|
+
var nextNode = currNode.makeTransition(property);
|
|
1850
1909
|
|
|
1851
|
-
|
|
1910
|
+
if (nextNode) {
|
|
1911
|
+
if (nextNode.isLeaf()) {
|
|
1852
1912
|
var _handlers$get, _handlers;
|
|
1853
1913
|
|
|
1854
|
-
|
|
1855
|
-
target[property] = (_handlers$get = (_handlers = handlers(nextPath, spec)).get) == null ? void 0 : _handlers$get.call(_handlers, target, property, receiver);
|
|
1914
|
+
target[property] = (_handlers$get = (_handlers = handlers(nextPath, nextNode.getSpec())).get) == null ? void 0 : _handlers$get.call(_handlers, target, property, receiver);
|
|
1856
1915
|
} else if (!(property in target)) {
|
|
1857
|
-
target[property] = rec(nextPath);
|
|
1916
|
+
target[property] = rec(nextPath, nextNode);
|
|
1858
1917
|
}
|
|
1859
1918
|
}
|
|
1860
1919
|
|
|
1861
1920
|
return Reflect.get(target, property, receiver);
|
|
1862
1921
|
},
|
|
1863
1922
|
set: function set$1(target, property, value, receiver) {
|
|
1864
|
-
var spec = getSpecForProperty(property);
|
|
1865
1923
|
var nextPath = getNextPath(property);
|
|
1924
|
+
var nextNode = currNode.makeTransition(property);
|
|
1866
1925
|
|
|
1867
|
-
if (
|
|
1868
|
-
if (
|
|
1926
|
+
if (nextNode && typeof property !== "symbol") {
|
|
1927
|
+
if (nextNode.isLeaf()) {
|
|
1869
1928
|
var _handlers$set, _handlers2;
|
|
1870
1929
|
|
|
1871
1930
|
// reached the end of the spec
|
|
1872
|
-
target[property] = (_handlers$set = (_handlers2 = handlers(nextPath,
|
|
1931
|
+
target[property] = (_handlers$set = (_handlers2 = handlers(nextPath, nextNode.getSpec())).set) == null ? void 0 : _handlers$set.call(_handlers2, target, property, value, receiver);
|
|
1873
1932
|
return Reflect.set(target, property, value, receiver);
|
|
1874
1933
|
} else if (typeof value === "object") {
|
|
1875
|
-
target[property] = rec(nextPath);
|
|
1934
|
+
target[property] = rec(nextPath, nextNode);
|
|
1876
1935
|
|
|
1877
1936
|
for (var _i = 0, _Object$keys = Object.keys(value); _i < _Object$keys.length; _i++) {
|
|
1878
1937
|
var key = _Object$keys[_i];
|
|
@@ -1887,13 +1946,13 @@ function create$StateProxy($$state, handlers) {
|
|
|
1887
1946
|
return Reflect.set(target, property, value, receiver);
|
|
1888
1947
|
}
|
|
1889
1948
|
|
|
1890
|
-
if (
|
|
1891
|
-
var
|
|
1949
|
+
if (currNode.hasArrayTransition()) {
|
|
1950
|
+
var _currNode$makeTransit, _currNode$makeTransit2;
|
|
1892
1951
|
|
|
1893
1952
|
set($$state.stateValues, nextPath, value);
|
|
1894
1953
|
|
|
1895
|
-
(
|
|
1896
|
-
if (spec
|
|
1954
|
+
(_currNode$makeTransit = currNode.makeTransition(ARRAY_SYMBOL)) == null ? void 0 : (_currNode$makeTransit2 = _currNode$makeTransit.getAllSpecs()) == null ? void 0 : _currNode$makeTransit2.forEach(function (spec) {
|
|
1955
|
+
if (spec.onChangeProp) {
|
|
1897
1956
|
var _$$state$props$spec$o2, _$$state$props2;
|
|
1898
1957
|
|
|
1899
1958
|
(_$$state$props$spec$o2 = (_$$state$props2 = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o2.call(_$$state$props2, value, nextPath);
|
|
@@ -1908,7 +1967,7 @@ function create$StateProxy($$state, handlers) {
|
|
|
1908
1967
|
});
|
|
1909
1968
|
};
|
|
1910
1969
|
|
|
1911
|
-
return rec([]);
|
|
1970
|
+
return rec([], $$state.rootStateSpec);
|
|
1912
1971
|
}
|
|
1913
1972
|
|
|
1914
1973
|
var deleteState = function deleteState($$state, path) {
|
|
@@ -1979,7 +2038,7 @@ function initializeStateValue($$state, initialStatePath, initialSpec) {
|
|
|
1979
2038
|
var path = _ref2.path,
|
|
1980
2039
|
spec = _ref2.spec;
|
|
1981
2040
|
var unsubscribe = utils.subscribeKey(_get($$state.stateValues, path.slice(-1)), path.slice(-1)[0], function () {
|
|
1982
|
-
return
|
|
2041
|
+
return saveValue($$state, initialStatePath, initialSpec, initialSpec.initFunc($$state.props, $state, $$state.ctx, getIndexes(path, spec)));
|
|
1983
2042
|
});
|
|
1984
2043
|
$$state.unsubscriptionsByState[initialStateKey].push(unsubscribe);
|
|
1985
2044
|
});
|
|
@@ -1988,27 +2047,25 @@ function initializeStateValue($$state, initialStatePath, initialSpec) {
|
|
|
1988
2047
|
return initialValue;
|
|
1989
2048
|
}
|
|
1990
2049
|
|
|
1991
|
-
function
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
// that's why we need to track the array object
|
|
1995
|
-
if (spec.isArray && Array.isArray(initialValue)) {
|
|
1996
|
-
var array = initialValue.map(function (val) {
|
|
1997
|
-
return mkUntrackedValue(val);
|
|
1998
|
-
});
|
|
1999
|
-
|
|
2000
|
-
set($$state.stateValues, path, array); // we need to make the array untracked for initStateValues
|
|
2001
|
-
// so we can distinguish between stateValue and initStateValue.
|
|
2002
|
-
// otherwise they would reference the same array.
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
set($$state.initStateValues, path, mkUntrackedValue(array));
|
|
2050
|
+
function saveValue($$state, path, spec, value) {
|
|
2051
|
+
if (spec.isImmutable) {
|
|
2052
|
+
set($$state.stateValues, path, mkUntrackedValue(value));
|
|
2006
2053
|
} else {
|
|
2054
|
+
set($$state.stateValues, path, value);
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
|
|
2058
|
+
function saveStateInitialValue($$state, path, spec, initialValue) {
|
|
2059
|
+
if (spec.isImmutable) {
|
|
2007
2060
|
var untrackedValue = mkUntrackedValue(initialValue);
|
|
2008
2061
|
|
|
2009
2062
|
set($$state.stateValues, path, untrackedValue);
|
|
2010
2063
|
|
|
2011
|
-
set($$state.initStateValues, path, untrackedValue);
|
|
2064
|
+
set($$state.initStateValues, path, clone(untrackedValue));
|
|
2065
|
+
} else {
|
|
2066
|
+
set($$state.stateValues, path, clone(initialValue));
|
|
2067
|
+
|
|
2068
|
+
set($$state.initStateValues, path, clone(initialValue));
|
|
2012
2069
|
}
|
|
2013
2070
|
}
|
|
2014
2071
|
|
|
@@ -2029,7 +2086,8 @@ function useDollarState(specs, props, $ctx) {
|
|
|
2029
2086
|
unsubscriptionsByState: {},
|
|
2030
2087
|
props: {},
|
|
2031
2088
|
ctx: {},
|
|
2032
|
-
registrationsQueue: []
|
|
2089
|
+
registrationsQueue: [],
|
|
2090
|
+
rootStateSpec: buildGraph(specs)
|
|
2033
2091
|
})).current;
|
|
2034
2092
|
$$state.props = mkUntrackedValue(props);
|
|
2035
2093
|
$$state.ctx = mkUntrackedValue($ctx != null ? $ctx : {});
|
|
@@ -2053,8 +2111,8 @@ function useDollarState(specs, props, $ctx) {
|
|
|
2053
2111
|
return _get($$state.stateValues, path);
|
|
2054
2112
|
}
|
|
2055
2113
|
},
|
|
2056
|
-
set: function set
|
|
2057
|
-
|
|
2114
|
+
set: function set(_t, _p, value) {
|
|
2115
|
+
saveValue($$state, path, spec, value);
|
|
2058
2116
|
|
|
2059
2117
|
if (spec.onChangeProp) {
|
|
2060
2118
|
var _$$state$props$spec$o3, _$$state$props3;
|
|
@@ -2148,28 +2206,12 @@ function useCanvasDollarState(specs, props, $ctx) {
|
|
|
2148
2206
|
unsubscriptionsByState: {},
|
|
2149
2207
|
props: {},
|
|
2150
2208
|
ctx: {},
|
|
2151
|
-
registrationsQueue: []
|
|
2209
|
+
registrationsQueue: [],
|
|
2210
|
+
rootStateSpec: buildGraph(specs)
|
|
2152
2211
|
});
|
|
2153
2212
|
$$state.props = mkUntrackedValue(props);
|
|
2154
2213
|
$$state.ctx = mkUntrackedValue($ctx);
|
|
2155
|
-
var $state =
|
|
2156
|
-
return {
|
|
2157
|
-
get: function get() {
|
|
2158
|
-
return _get($$state.stateValues, path);
|
|
2159
|
-
},
|
|
2160
|
-
set: function set$1(_t, _p, value) {
|
|
2161
|
-
set($$state.stateValues, path, mkUntrackedValue(value));
|
|
2162
|
-
|
|
2163
|
-
if (spec.onChangeProp) {
|
|
2164
|
-
var _$$state$props$spec$o5, _$$state$props5;
|
|
2165
|
-
|
|
2166
|
-
(_$$state$props$spec$o5 = (_$$state$props5 = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o5.call(_$$state$props5, value, path);
|
|
2167
|
-
}
|
|
2168
|
-
|
|
2169
|
-
return true;
|
|
2170
|
-
}
|
|
2171
|
-
};
|
|
2172
|
-
});
|
|
2214
|
+
var $state = {};
|
|
2173
2215
|
|
|
2174
2216
|
for (var _iterator = _createForOfIteratorHelperLoose(specs), _step; !(_step = _iterator()).done;) {
|
|
2175
2217
|
var spec = _step.value;
|
|
@@ -3768,6 +3810,7 @@ exports.generateStateOnChangeProp = generateStateOnChangeProp;
|
|
|
3768
3810
|
exports.generateStateValueProp = generateStateValueProp;
|
|
3769
3811
|
exports.getDataProps = getDataProps;
|
|
3770
3812
|
exports.hasVariant = hasVariant;
|
|
3813
|
+
exports.isNum = isNum;
|
|
3771
3814
|
exports.makeFragment = makeFragment;
|
|
3772
3815
|
exports.mergeVariantsWithStates = mergeVariantsWithStates;
|
|
3773
3816
|
exports.omit = omit;
|
|
@@ -3776,6 +3819,7 @@ exports.plasmicHeadMeta = plasmicHeadMeta;
|
|
|
3776
3819
|
exports.renderPlasmicSlot = renderPlasmicSlot;
|
|
3777
3820
|
exports.set = set;
|
|
3778
3821
|
exports.setPlumeStrictMode = setPlumeStrictMode;
|
|
3822
|
+
exports.shallowEqual = shallowEqual;
|
|
3779
3823
|
exports.useButton = useButton;
|
|
3780
3824
|
exports.useCanvasDollarState = useCanvasDollarState;
|
|
3781
3825
|
exports.useCheckbox = useCheckbox;
|