@plasmicapp/react-web 0.2.124 → 0.2.125
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 +7 -6
- package/dist/react-web.cjs.development.js +17 -11
- 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 +18 -13
- package/dist/react-web.esm.js.map +1 -1
- package/dist/states/helpers.d.ts +2 -0
- package/dist/states/valtio.d.ts +3 -3
- package/dist/stories/UseDollarState.stories.d.ts +7 -1
- package/package.json +2 -2
- package/skinny/dist/index.js +23 -16
- package/skinny/dist/index.js.map +1 -1
- package/skinny/dist/states/helpers.d.ts +2 -0
- package/skinny/dist/states/valtio.d.ts +3 -3
- package/skinny/dist/stories/UseDollarState.stories.d.ts +7 -1
package/dist/react-web.esm.js
CHANGED
|
@@ -2,7 +2,7 @@ import classNames$1 from 'classnames';
|
|
|
2
2
|
import _get from 'dlv';
|
|
3
3
|
export { default as get } from 'dlv';
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import React__default, { forwardRef, createElement, Fragment, isValidElement, useContext, createContext, useState, useRef, useMemo, useImperativeHandle, useCallback, cloneElement } from 'react';
|
|
5
|
+
import React__default, { forwardRef, createElement, Fragment, isValidElement, useContext, createContext, useState, useRef, useMemo, useLayoutEffect, useEffect, useImperativeHandle, useCallback, cloneElement } from 'react';
|
|
6
6
|
import ReactDOM__default, { createPortal } from 'react-dom';
|
|
7
7
|
import { PlasmicDataSourceContextProvider } from '@plasmicapp/data-sources-context';
|
|
8
8
|
export { PlasmicDataSourceContextProvider, useCurrentUser } from '@plasmicapp/data-sources-context';
|
|
@@ -1733,9 +1733,10 @@ function set(obj, keys, val) {
|
|
|
1733
1733
|
}
|
|
1734
1734
|
}
|
|
1735
1735
|
}
|
|
1736
|
+
var useIsomorphicLayoutEffect$1 = typeof window !== "undefined" ? useLayoutEffect : useEffect;
|
|
1736
1737
|
|
|
1737
1738
|
var mkUntrackedValue = function mkUntrackedValue(o) {
|
|
1738
|
-
return typeof o === "object" ? ref(o) : o;
|
|
1739
|
+
return o != null && typeof o === "object" ? ref(o) : o;
|
|
1739
1740
|
};
|
|
1740
1741
|
|
|
1741
1742
|
var transformPathStringToObj = function transformPathStringToObj(str) {
|
|
@@ -1973,11 +1974,11 @@ function initializeStateValue($$state, initialStatePath, initialSpec) {
|
|
|
1973
1974
|
var path = _ref2.path,
|
|
1974
1975
|
spec = _ref2.spec;
|
|
1975
1976
|
var unsubscribe = subscribeKey(_get($$state.stateValues, path.slice(-1)), path.slice(-1)[0], function () {
|
|
1976
|
-
return set($$state.stateValues, initialStatePath, mkUntrackedValue(initialSpec.initFunc($$state.props, $state, getIndexes(path, spec))));
|
|
1977
|
+
return set($$state.stateValues, initialStatePath, mkUntrackedValue(initialSpec.initFunc($$state.props, $state, $$state.ctx, getIndexes(path, spec))));
|
|
1977
1978
|
});
|
|
1978
1979
|
$$state.unsubscriptionsByState[initialStateKey].push(unsubscribe);
|
|
1979
1980
|
});
|
|
1980
|
-
var initialValue = initialSpec.initFunc($$state.props, $state, getIndexes(initialStatePath, initialSpec));
|
|
1981
|
+
var initialValue = initialSpec.initFunc($$state.props, $state, $$state.ctx, getIndexes(initialStatePath, initialSpec));
|
|
1981
1982
|
saveStateInitialValue($$state, initialStatePath, initialSpec, initialValue);
|
|
1982
1983
|
return initialValue;
|
|
1983
1984
|
}
|
|
@@ -2006,7 +2007,7 @@ function saveStateInitialValue($$state, path, spec, initialValue) {
|
|
|
2006
2007
|
}
|
|
2007
2008
|
}
|
|
2008
2009
|
|
|
2009
|
-
function useDollarState(specs, props) {
|
|
2010
|
+
function useDollarState(specs, props, $ctx) {
|
|
2010
2011
|
var $$state = React__default.useRef(proxy({
|
|
2011
2012
|
stateValues: {},
|
|
2012
2013
|
initStateValues: {},
|
|
@@ -2021,10 +2022,12 @@ function useDollarState(specs, props) {
|
|
|
2021
2022
|
statesInstanceBySpec: new Map(),
|
|
2022
2023
|
existingStates: new Map(),
|
|
2023
2024
|
unsubscriptionsByState: {},
|
|
2024
|
-
props:
|
|
2025
|
+
props: {},
|
|
2026
|
+
ctx: {},
|
|
2025
2027
|
registrationsQueue: []
|
|
2026
2028
|
})).current;
|
|
2027
2029
|
$$state.props = mkUntrackedValue(props);
|
|
2030
|
+
$$state.ctx = mkUntrackedValue($ctx != null ? $ctx : {});
|
|
2028
2031
|
var $state = React__default.useRef(Object.assign(create$StateProxy($$state, function (path, spec) {
|
|
2029
2032
|
var key = JSON.stringify(path);
|
|
2030
2033
|
|
|
@@ -2064,7 +2067,7 @@ function useDollarState(specs, props) {
|
|
|
2064
2067
|
if ((_$$state$statesInstan = $$state.statesInstanceBySpec.get(pathStr)) != null && _$$state$statesInstan.some(function (_ref3) {
|
|
2065
2068
|
var path = _ref3.path,
|
|
2066
2069
|
specKey = _ref3.specKey;
|
|
2067
|
-
return !deepEqual(_get($$state.initStateValues, path), f(props, $state, getIndexes(path, $$state.specsByKey[specKey])));
|
|
2070
|
+
return !deepEqual(_get($$state.initStateValues, path), f(props, $state, $ctx != null ? $ctx : {}, getIndexes(path, $$state.specsByKey[specKey])));
|
|
2068
2071
|
})) {
|
|
2069
2072
|
$$state.registrationsQueue.push({
|
|
2070
2073
|
pathStr: pathStr,
|
|
@@ -2082,7 +2085,7 @@ function useDollarState(specs, props) {
|
|
|
2082
2085
|
var spec = $$state.specsByKey[specKey];
|
|
2083
2086
|
|
|
2084
2087
|
if (spec.initFunc) {
|
|
2085
|
-
var newInit = spec.initFunc(props, $state, getIndexes(path, spec));
|
|
2088
|
+
var newInit = spec.initFunc(props, $state, $ctx != null ? $ctx : {}, getIndexes(path, spec));
|
|
2086
2089
|
|
|
2087
2090
|
if (!deepEqual(newInit, _get($$state.initStateValues, path))) {
|
|
2088
2091
|
resetSpecs.push({
|
|
@@ -2092,7 +2095,7 @@ function useDollarState(specs, props) {
|
|
|
2092
2095
|
}
|
|
2093
2096
|
}
|
|
2094
2097
|
});
|
|
2095
|
-
|
|
2098
|
+
useIsomorphicLayoutEffect$1(function () {
|
|
2096
2099
|
resetSpecs.forEach(function (_ref5) {
|
|
2097
2100
|
var path = _ref5.path,
|
|
2098
2101
|
spec = _ref5.spec;
|
|
@@ -2105,7 +2108,7 @@ function useDollarState(specs, props) {
|
|
|
2105
2108
|
}
|
|
2106
2109
|
});
|
|
2107
2110
|
}, [props, resetSpecs]);
|
|
2108
|
-
|
|
2111
|
+
useIsomorphicLayoutEffect$1(function () {
|
|
2109
2112
|
$$state.registrationsQueue.forEach(function (_ref6) {
|
|
2110
2113
|
var f = _ref6.f,
|
|
2111
2114
|
pathStr = _ref6.pathStr;
|
|
@@ -2123,7 +2126,7 @@ function useDollarState(specs, props) {
|
|
|
2123
2126
|
return $state;
|
|
2124
2127
|
}
|
|
2125
2128
|
|
|
2126
|
-
function useCanvasDollarState(specs, props) {
|
|
2129
|
+
function useCanvasDollarState(specs, props, $ctx) {
|
|
2127
2130
|
var $$state = proxy({
|
|
2128
2131
|
stateValues: {},
|
|
2129
2132
|
initStateValues: {},
|
|
@@ -2138,10 +2141,12 @@ function useCanvasDollarState(specs, props) {
|
|
|
2138
2141
|
statesInstanceBySpec: new Map(),
|
|
2139
2142
|
existingStates: new Map(),
|
|
2140
2143
|
unsubscriptionsByState: {},
|
|
2141
|
-
props:
|
|
2144
|
+
props: {},
|
|
2145
|
+
ctx: {},
|
|
2142
2146
|
registrationsQueue: []
|
|
2143
2147
|
});
|
|
2144
2148
|
$$state.props = mkUntrackedValue(props);
|
|
2149
|
+
$$state.ctx = mkUntrackedValue($ctx);
|
|
2145
2150
|
var $state = create$StateProxy($$state, function (path, spec) {
|
|
2146
2151
|
return {
|
|
2147
2152
|
get: function get() {
|
|
@@ -3724,5 +3729,5 @@ function useTriggeredOverlay(plasmicClass, props, config, outerRef, isDismissabl
|
|
|
3724
3729
|
};
|
|
3725
3730
|
}
|
|
3726
3731
|
|
|
3727
|
-
export { DropdownMenu, PlasmicHead, PlasmicIcon, PlasmicImg, PlasmicLink, PlasmicRootProvider, PlasmicSlot, SelectContext, Stack, Trans, TriggeredOverlayContext, classNames, createPlasmicElementProxy, createUseScreenVariants, deriveRenderOpts, ensureGlobalVariants, genTranslatableString, generateStateOnChangeProp, generateStateValueProp, getDataProps, hasVariant, makeFragment, mergeVariantsWithStates, omit, pick, plasmicHeadMeta, renderPlasmicSlot, set, setPlumeStrictMode, useButton, useCanvasDollarState, useCheckbox, useDollarState, useIsSSR, useMenu, useMenuButton, useMenuGroup, useMenuItem, useSelect, useSelectOption, useSelectOptionGroup, useSwitch, useTextInput, useTrigger, useTriggeredOverlay, wrapWithClassName };
|
|
3732
|
+
export { DropdownMenu, PlasmicHead, PlasmicIcon, PlasmicImg, PlasmicLink, PlasmicRootProvider, PlasmicSlot, SelectContext, Stack, Trans, TriggeredOverlayContext, classNames, createPlasmicElementProxy, createUseScreenVariants, deriveRenderOpts, ensureGlobalVariants, genTranslatableString, generateStateOnChangeProp, generateStateValueProp, getDataProps, hasVariant, makeFragment, mergeVariantsWithStates, omit, pick, plasmicHeadMeta, renderPlasmicSlot, set, setPlumeStrictMode, useButton, useCanvasDollarState, useCheckbox, useDollarState, useIsSSR, useIsomorphicLayoutEffect$1 as useIsomorphicLayoutEffect, useMenu, useMenuButton, useMenuGroup, useMenuItem, useSelect, useSelectOption, useSelectOptionGroup, useSwitch, useTextInput, useTrigger, useTriggeredOverlay, wrapWithClassName };
|
|
3728
3733
|
//# sourceMappingURL=react-web.esm.js.map
|