@plasmicapp/react-web 0.2.123 → 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/lib/data-sources/index.cjs.js +17 -0
- package/lib/data-sources/index.cjs.js.map +1 -0
- package/lib/data-sources/package.json +4 -1
- package/lib/host/index.cjs.js +17 -0
- package/lib/host/index.cjs.js.map +1 -0
- package/lib/host/package.json +4 -1
- package/lib/query/index.cjs.js +17 -0
- package/lib/query/index.cjs.js.map +1 -0
- package/lib/query/package.json +4 -1
- package/package.json +4 -4
- 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/all.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import React__default, { AriaAttributes, DOMAttributes as DOMAttributes$1, AriaRole, CSSProperties, Key, ReactNode, ReactElement, FocusEvent, KeyboardEvent as KeyboardEvent$1, SyntheticEvent } from 'react';
|
|
2
|
+
import React__default, { AriaAttributes, DOMAttributes as DOMAttributes$1, AriaRole, CSSProperties, Key, ReactNode, ReactElement, FocusEvent, KeyboardEvent as KeyboardEvent$1, SyntheticEvent, useLayoutEffect } from 'react';
|
|
3
3
|
|
|
4
4
|
// LICENSE is MIT
|
|
5
5
|
//
|
|
@@ -23,7 +23,7 @@ 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$1<T> = ($props: Record<string, any>, $state: $State$1, indexes: number[]) => T;
|
|
26
|
+
declare type InitFunc$1<T> = ($props: Record<string, any>, $state: $State$1, $ctx: Record<string, any>, indexes: number[]) => T;
|
|
27
27
|
interface $State$1 {
|
|
28
28
|
[key: string]: any;
|
|
29
29
|
registerInitFunc?: (path: string, f: InitFunc$1<any>) => any;
|
|
@@ -37,9 +37,9 @@ interface $StateSpec<T> {
|
|
|
37
37
|
onChangeProp?: string;
|
|
38
38
|
isArray?: boolean;
|
|
39
39
|
}
|
|
40
|
-
declare function useDollarState(specs: $StateSpec<any>[], props: Record<string, any>): any;
|
|
40
|
+
declare function useDollarState(specs: $StateSpec<any>[], props: Record<string, any>, $ctx?: Record<string, any>): any;
|
|
41
41
|
|
|
42
|
-
declare function useCanvasDollarState(specs: $StateSpec<any>[], props: Record<string, any>): any;
|
|
42
|
+
declare function useCanvasDollarState(specs: $StateSpec<any>[], props: Record<string, any>, $ctx?: Record<string, any>): any;
|
|
43
43
|
|
|
44
44
|
interface Variants {
|
|
45
45
|
[vg: string]: any;
|
|
@@ -677,7 +677,8 @@ declare function generateStateValueProp($state: $State, path: (string | number)[
|
|
|
677
677
|
* Forked from https://github.com/lukeed/dset
|
|
678
678
|
* Changes: fixed setting a deep value to a proxy object
|
|
679
679
|
*/
|
|
680
|
-
declare function set(obj: any, keys: any, val: any): void;
|
|
680
|
+
declare function set(obj: any, keys: any, val: any): void;
|
|
681
|
+
declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
|
|
681
682
|
|
|
682
683
|
declare const classNames: typeof classNames$1;
|
|
683
684
|
|
|
@@ -1637,4 +1638,4 @@ interface TriggeredOverlayContextValue {
|
|
|
1637
1638
|
}
|
|
1638
1639
|
declare const TriggeredOverlayContext: React.Context<TriggeredOverlayContextValue | undefined>;
|
|
1639
1640
|
|
|
1640
|
-
export { $State$1 as $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, makeFragment, mergeVariantsWithStates, omit, pick, plasmicHeadMeta, renderPlasmicSlot, set, setPlumeStrictMode, useButton, useCanvasDollarState, useCheckbox, useCurrentUser, useDollarState, useIsSSR, useMenu, useMenuButton, useMenuGroup, useMenuItem, useSelect, useSelectOption, useSelectOptionGroup, useSwitch, useTextInput, useTrigger, useTriggeredOverlay, wrapWithClassName };
|
|
1641
|
+
export { $State$1 as $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, makeFragment, mergeVariantsWithStates, omit, pick, plasmicHeadMeta, renderPlasmicSlot, set, setPlumeStrictMode, useButton, useCanvasDollarState, useCheckbox, useCurrentUser, useDollarState, useIsSSR, useIsomorphicLayoutEffect, useMenu, useMenuButton, useMenuGroup, useMenuItem, useSelect, useSelectOption, useSelectOptionGroup, useSwitch, useTextInput, useTrigger, useTriggeredOverlay, wrapWithClassName };
|
|
@@ -1738,9 +1738,10 @@ function set(obj, keys, val) {
|
|
|
1738
1738
|
}
|
|
1739
1739
|
}
|
|
1740
1740
|
}
|
|
1741
|
+
var useIsomorphicLayoutEffect$1 = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
1741
1742
|
|
|
1742
1743
|
var mkUntrackedValue = function mkUntrackedValue(o) {
|
|
1743
|
-
return typeof o === "object" ? valtio.ref(o) : o;
|
|
1744
|
+
return o != null && typeof o === "object" ? valtio.ref(o) : o;
|
|
1744
1745
|
};
|
|
1745
1746
|
|
|
1746
1747
|
var transformPathStringToObj = function transformPathStringToObj(str) {
|
|
@@ -1978,11 +1979,11 @@ function initializeStateValue($$state, initialStatePath, initialSpec) {
|
|
|
1978
1979
|
var path = _ref2.path,
|
|
1979
1980
|
spec = _ref2.spec;
|
|
1980
1981
|
var unsubscribe = utils.subscribeKey(_get($$state.stateValues, path.slice(-1)), path.slice(-1)[0], function () {
|
|
1981
|
-
return set($$state.stateValues, initialStatePath, mkUntrackedValue(initialSpec.initFunc($$state.props, $state, getIndexes(path, spec))));
|
|
1982
|
+
return set($$state.stateValues, initialStatePath, mkUntrackedValue(initialSpec.initFunc($$state.props, $state, $$state.ctx, getIndexes(path, spec))));
|
|
1982
1983
|
});
|
|
1983
1984
|
$$state.unsubscriptionsByState[initialStateKey].push(unsubscribe);
|
|
1984
1985
|
});
|
|
1985
|
-
var initialValue = initialSpec.initFunc($$state.props, $state, getIndexes(initialStatePath, initialSpec));
|
|
1986
|
+
var initialValue = initialSpec.initFunc($$state.props, $state, $$state.ctx, getIndexes(initialStatePath, initialSpec));
|
|
1986
1987
|
saveStateInitialValue($$state, initialStatePath, initialSpec, initialValue);
|
|
1987
1988
|
return initialValue;
|
|
1988
1989
|
}
|
|
@@ -2011,7 +2012,7 @@ function saveStateInitialValue($$state, path, spec, initialValue) {
|
|
|
2011
2012
|
}
|
|
2012
2013
|
}
|
|
2013
2014
|
|
|
2014
|
-
function useDollarState(specs, props) {
|
|
2015
|
+
function useDollarState(specs, props, $ctx) {
|
|
2015
2016
|
var $$state = React__default.useRef(valtio.proxy({
|
|
2016
2017
|
stateValues: {},
|
|
2017
2018
|
initStateValues: {},
|
|
@@ -2026,10 +2027,12 @@ function useDollarState(specs, props) {
|
|
|
2026
2027
|
statesInstanceBySpec: new Map(),
|
|
2027
2028
|
existingStates: new Map(),
|
|
2028
2029
|
unsubscriptionsByState: {},
|
|
2029
|
-
props:
|
|
2030
|
+
props: {},
|
|
2031
|
+
ctx: {},
|
|
2030
2032
|
registrationsQueue: []
|
|
2031
2033
|
})).current;
|
|
2032
2034
|
$$state.props = mkUntrackedValue(props);
|
|
2035
|
+
$$state.ctx = mkUntrackedValue($ctx != null ? $ctx : {});
|
|
2033
2036
|
var $state = React__default.useRef(Object.assign(create$StateProxy($$state, function (path, spec) {
|
|
2034
2037
|
var key = JSON.stringify(path);
|
|
2035
2038
|
|
|
@@ -2069,7 +2072,7 @@ function useDollarState(specs, props) {
|
|
|
2069
2072
|
if ((_$$state$statesInstan = $$state.statesInstanceBySpec.get(pathStr)) != null && _$$state$statesInstan.some(function (_ref3) {
|
|
2070
2073
|
var path = _ref3.path,
|
|
2071
2074
|
specKey = _ref3.specKey;
|
|
2072
|
-
return !deepEqual(_get($$state.initStateValues, path), f(props, $state, getIndexes(path, $$state.specsByKey[specKey])));
|
|
2075
|
+
return !deepEqual(_get($$state.initStateValues, path), f(props, $state, $ctx != null ? $ctx : {}, getIndexes(path, $$state.specsByKey[specKey])));
|
|
2073
2076
|
})) {
|
|
2074
2077
|
$$state.registrationsQueue.push({
|
|
2075
2078
|
pathStr: pathStr,
|
|
@@ -2087,7 +2090,7 @@ function useDollarState(specs, props) {
|
|
|
2087
2090
|
var spec = $$state.specsByKey[specKey];
|
|
2088
2091
|
|
|
2089
2092
|
if (spec.initFunc) {
|
|
2090
|
-
var newInit = spec.initFunc(props, $state, getIndexes(path, spec));
|
|
2093
|
+
var newInit = spec.initFunc(props, $state, $ctx != null ? $ctx : {}, getIndexes(path, spec));
|
|
2091
2094
|
|
|
2092
2095
|
if (!deepEqual(newInit, _get($$state.initStateValues, path))) {
|
|
2093
2096
|
resetSpecs.push({
|
|
@@ -2097,7 +2100,7 @@ function useDollarState(specs, props) {
|
|
|
2097
2100
|
}
|
|
2098
2101
|
}
|
|
2099
2102
|
});
|
|
2100
|
-
|
|
2103
|
+
useIsomorphicLayoutEffect$1(function () {
|
|
2101
2104
|
resetSpecs.forEach(function (_ref5) {
|
|
2102
2105
|
var path = _ref5.path,
|
|
2103
2106
|
spec = _ref5.spec;
|
|
@@ -2110,7 +2113,7 @@ function useDollarState(specs, props) {
|
|
|
2110
2113
|
}
|
|
2111
2114
|
});
|
|
2112
2115
|
}, [props, resetSpecs]);
|
|
2113
|
-
|
|
2116
|
+
useIsomorphicLayoutEffect$1(function () {
|
|
2114
2117
|
$$state.registrationsQueue.forEach(function (_ref6) {
|
|
2115
2118
|
var f = _ref6.f,
|
|
2116
2119
|
pathStr = _ref6.pathStr;
|
|
@@ -2128,7 +2131,7 @@ function useDollarState(specs, props) {
|
|
|
2128
2131
|
return $state;
|
|
2129
2132
|
}
|
|
2130
2133
|
|
|
2131
|
-
function useCanvasDollarState(specs, props) {
|
|
2134
|
+
function useCanvasDollarState(specs, props, $ctx) {
|
|
2132
2135
|
var $$state = valtio.proxy({
|
|
2133
2136
|
stateValues: {},
|
|
2134
2137
|
initStateValues: {},
|
|
@@ -2143,10 +2146,12 @@ function useCanvasDollarState(specs, props) {
|
|
|
2143
2146
|
statesInstanceBySpec: new Map(),
|
|
2144
2147
|
existingStates: new Map(),
|
|
2145
2148
|
unsubscriptionsByState: {},
|
|
2146
|
-
props:
|
|
2149
|
+
props: {},
|
|
2150
|
+
ctx: {},
|
|
2147
2151
|
registrationsQueue: []
|
|
2148
2152
|
});
|
|
2149
2153
|
$$state.props = mkUntrackedValue(props);
|
|
2154
|
+
$$state.ctx = mkUntrackedValue($ctx);
|
|
2150
2155
|
var $state = create$StateProxy($$state, function (path, spec) {
|
|
2151
2156
|
return {
|
|
2152
2157
|
get: function get() {
|
|
@@ -3776,6 +3781,7 @@ exports.useCanvasDollarState = useCanvasDollarState;
|
|
|
3776
3781
|
exports.useCheckbox = useCheckbox;
|
|
3777
3782
|
exports.useDollarState = useDollarState;
|
|
3778
3783
|
exports.useIsSSR = useIsSSR;
|
|
3784
|
+
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect$1;
|
|
3779
3785
|
exports.useMenu = useMenu;
|
|
3780
3786
|
exports.useMenuButton = useMenuButton;
|
|
3781
3787
|
exports.useMenuGroup = useMenuGroup;
|