@plasmicapp/react-web 0.2.402 → 0.2.404
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 -12
- package/dist/index.cjs.js +12 -15
- package/dist/index.cjs.js.map +1 -1
- package/dist/react-web.esm.js +12 -15
- package/dist/react-web.esm.js.map +1 -1
- package/dist/render/style-tokens.d.ts +14 -10
- package/package.json +4 -4
- package/skinny/dist/index.js +12 -15
- package/skinny/dist/index.js.map +1 -1
- package/skinny/dist/render/style-tokens.d.ts +14 -10
package/dist/all.d.ts
CHANGED
|
@@ -11491,6 +11491,16 @@ interface GraphQLCore<Ctx extends any[]> {
|
|
|
11491
11491
|
method?: string | ContextDependentConfig<Ctx, string>;
|
|
11492
11492
|
headers?: object | ContextDependentConfig<Ctx, object>;
|
|
11493
11493
|
}
|
|
11494
|
+
/**
|
|
11495
|
+
* Dynamic prop/param type that returns different control types based on context
|
|
11496
|
+
*/
|
|
11497
|
+
interface DynamicCore<Ctx extends any[], ControlType> {
|
|
11498
|
+
type: "dynamic";
|
|
11499
|
+
/**
|
|
11500
|
+
* Function that takes the context and returns a control type
|
|
11501
|
+
*/
|
|
11502
|
+
control: ContextDependentConfig<Ctx, ControlType>;
|
|
11503
|
+
}
|
|
11494
11504
|
|
|
11495
11505
|
type Nullish<T> = T | null | undefined;
|
|
11496
11506
|
|
|
@@ -12147,8 +12157,10 @@ interface RichCustomType<P> extends PropTypeBaseDefault<P, any> {
|
|
|
12147
12157
|
control: CustomControl<P>;
|
|
12148
12158
|
}
|
|
12149
12159
|
type CustomType<P> = RichCustomType<P> | CustomControl<P>;
|
|
12160
|
+
interface DynamicType$1<P> extends PropTypeBase<ComponentControlContext<P>>, DynamicCore<ComponentControlContext<P>, PropType$1<P>> {
|
|
12161
|
+
}
|
|
12150
12162
|
type PrimitiveType<P = any> = Extract<StringType$1<P> | BooleanType$1<P> | NumberType$1<P> | JSONLikeType<P>, string>;
|
|
12151
|
-
type PropType$1<P> = StringType$1<P> | BooleanType$1<P> | GraphQLType$1<P> | NumberType$1<P> | JSONLikeType<P> | DataSourceType<P> | DataPickerType<P> | ExprEditorType<P> | FormValidationRulesType<P> | EventHandlerType<P> | ChoiceType$1<P> | CustomType<P> | ImageUrlType<P> | SlotType<P> | DateStringType$1<P> | DateRangeStringsType$1<P>;
|
|
12163
|
+
type PropType$1<P> = StringType$1<P> | BooleanType$1<P> | GraphQLType$1<P> | NumberType$1<P> | JSONLikeType<P> | DataSourceType<P> | DataPickerType<P> | ExprEditorType<P> | FormValidationRulesType<P> | EventHandlerType<P> | ChoiceType$1<P> | CustomType<P> | DynamicType$1<P> | ImageUrlType<P> | SlotType<P> | DateStringType$1<P> | DateRangeStringsType$1<P>;
|
|
12152
12164
|
type ArgType<P> = Exclude<PropType$1<P>, SlotType<P> | EventHandlerType<P>>;
|
|
12153
12165
|
type StringCompatType<P> = DateStringType$1<P> | StringType$1<P> | ChoiceType$1<P> | JSONLikeType<P> | ImageUrlType<P> | CustomType<P> | DataPickerType<P>;
|
|
12154
12166
|
type BoolCompatType<P> = BooleanType$1<P> | CustomType<P> | DataPickerType<P>;
|
|
@@ -12255,10 +12267,12 @@ interface CustomChoiceType<P, Opt extends ChoiceValue = ChoiceValue> extends Fun
|
|
|
12255
12267
|
type ChoiceType<P, T extends ChoiceValue = ChoiceValue> = SingleChoiceType<P, T> | MultiChoiceType<P, T> | CustomChoiceType<P, T>;
|
|
12256
12268
|
type DateStringType = BaseParam & DateStringCore;
|
|
12257
12269
|
type DateRangeStringsType = BaseParam & DateRangeStringsCore;
|
|
12270
|
+
interface DynamicType<P> extends BaseParam, DynamicCore<FunctionControlContext<ToTuple<P>>, ParamType<P, any>> {
|
|
12271
|
+
}
|
|
12258
12272
|
type RestrictedType<P, T> = IsAny<T> extends true ? AnyTyping<P, T> : [
|
|
12259
12273
|
T
|
|
12260
12274
|
] extends [string] ? StringType<P, T> : [T] extends [number] ? NumberType<P, T> : [T] extends [boolean] ? BooleanType<P, T> : T extends string | null | undefined ? Exclude<T, null | undefined> extends string ? StringType<P, T extends string ? T : string> : CommonType<P, T> : T extends number | null | undefined ? Exclude<T, null | undefined> extends number ? NumberType<P, T extends number ? T : number> : CommonType<P, T> : T extends boolean | null | undefined ? Exclude<T, null | undefined> extends boolean ? BooleanType<P, T extends boolean ? T : boolean> : CommonType<P, T> : CommonType<P, T>;
|
|
12261
|
-
type ParamType<P, T> = RestrictedType<P, T>;
|
|
12275
|
+
type ParamType<P, T> = RestrictedType<P, T> | DynamicType<P>;
|
|
12262
12276
|
type RequiredParam<P, T> = ParamType<P, T> & {
|
|
12263
12277
|
isOptional?: false;
|
|
12264
12278
|
isRestParameter?: false;
|
|
@@ -12956,7 +12970,10 @@ declare const useIsSSR: typeof useIsSSR$1;
|
|
|
12956
12970
|
|
|
12957
12971
|
type ClassName = string;
|
|
12958
12972
|
/**
|
|
12959
|
-
* All style token data for this project.
|
|
12973
|
+
* All style token data (except overrides) for this project.
|
|
12974
|
+
* This data is used as the default context value.
|
|
12975
|
+
*
|
|
12976
|
+
* We don't include the overrides because the Provider (that wraps the components) decides which project's overrides to apply.
|
|
12960
12977
|
*
|
|
12961
12978
|
* Usage:
|
|
12962
12979
|
*
|
|
@@ -12965,9 +12982,10 @@ type ClassName = string;
|
|
|
12965
12982
|
* import { usePlatform } from "./PlasmicGlobalVariant__Platform";
|
|
12966
12983
|
* import { useTheme } from "./PlasmicGlobalVariant__Theme";
|
|
12967
12984
|
* import projectcss from "./plasmic.module.css";
|
|
12985
|
+
* import depcss from "../dep/plasmic.module.css";
|
|
12968
12986
|
*
|
|
12969
|
-
* const
|
|
12970
|
-
* base: projectcss.plasmic_tokens
|
|
12987
|
+
* const data: ProjectStyleTokenData = {
|
|
12988
|
+
* base: `${projectcss.plasmic_tokens} ${depcss.plasmic_tokens}`,
|
|
12971
12989
|
* varianted: [
|
|
12972
12990
|
* {
|
|
12973
12991
|
* className: projectcss.global_platform_windows,
|
|
@@ -12994,7 +13012,7 @@ type ClassName = string;
|
|
|
12994
13012
|
* ```
|
|
12995
13013
|
*/
|
|
12996
13014
|
interface ProjectStyleTokenData {
|
|
12997
|
-
base
|
|
13015
|
+
base?: ClassName;
|
|
12998
13016
|
varianted: {
|
|
12999
13017
|
className: ClassName;
|
|
13000
13018
|
groupName: string;
|
|
@@ -13003,14 +13021,13 @@ interface ProjectStyleTokenData {
|
|
|
13003
13021
|
}
|
|
13004
13022
|
type UseStyleTokens = () => ClassName[];
|
|
13005
13023
|
/**
|
|
13006
|
-
*
|
|
13007
|
-
* current project's styles.
|
|
13024
|
+
* Creates a useStyleTokens hook for a given project that returns class names for the given project's tokens plus token overrides from StyleTokensProvider if present.
|
|
13008
13025
|
*
|
|
13009
13026
|
* Usage:
|
|
13010
13027
|
* ```
|
|
13011
13028
|
* // PlasmicStyleTokensProvider.ts
|
|
13012
13029
|
* export const useStyleTokens = createUseStyleTokens(
|
|
13013
|
-
*
|
|
13030
|
+
* data,
|
|
13014
13031
|
* useGlobalVariants,
|
|
13015
13032
|
* );
|
|
13016
13033
|
*
|
|
@@ -13037,14 +13054,15 @@ type UseStyleTokens = () => ClassName[];
|
|
|
13037
13054
|
*/
|
|
13038
13055
|
declare function createUseStyleTokens(tokenData: ProjectStyleTokenData, useGlobalVariants: UseGlobalVariants): UseStyleTokens;
|
|
13039
13056
|
/**
|
|
13040
|
-
* Creates a
|
|
13041
|
-
*
|
|
13057
|
+
* Creates a StyleTokensProvider for a given project to allow propagating its overrides to components of other projects.
|
|
13058
|
+
*
|
|
13059
|
+
* To ensure all tokens in the overrides class name resolve properly, the base and varianted class names must be included.
|
|
13042
13060
|
*
|
|
13043
13061
|
* Usage:
|
|
13044
13062
|
* ```
|
|
13045
13063
|
* // PlasmicStyleTokensProvider.ts
|
|
13046
13064
|
* export const StyleTokensProvider = createStyleTokensProvider(
|
|
13047
|
-
*
|
|
13065
|
+
* { base: `${projectcss.plasmic_tokens_override} ${data.base}`, varianted: data.varianted },
|
|
13048
13066
|
* useGlobalVariants,
|
|
13049
13067
|
* );
|
|
13050
13068
|
*
|
package/dist/index.cjs.js
CHANGED
|
@@ -1844,14 +1844,13 @@ function MaybeWrap(props) {
|
|
|
1844
1844
|
*/
|
|
1845
1845
|
var StyleTokensContext = React.createContext(undefined);
|
|
1846
1846
|
/**
|
|
1847
|
-
*
|
|
1848
|
-
* current project's styles.
|
|
1847
|
+
* Creates a useStyleTokens hook for a given project that returns class names for the given project's tokens plus token overrides from StyleTokensProvider if present.
|
|
1849
1848
|
*
|
|
1850
1849
|
* Usage:
|
|
1851
1850
|
* ```
|
|
1852
1851
|
* // PlasmicStyleTokensProvider.ts
|
|
1853
1852
|
* export const useStyleTokens = createUseStyleTokens(
|
|
1854
|
-
*
|
|
1853
|
+
* data,
|
|
1855
1854
|
* useGlobalVariants,
|
|
1856
1855
|
* );
|
|
1857
1856
|
*
|
|
@@ -1878,27 +1877,24 @@ var StyleTokensContext = React.createContext(undefined);
|
|
|
1878
1877
|
*/
|
|
1879
1878
|
function createUseStyleTokens(tokenData, useGlobalVariants) {
|
|
1880
1879
|
return function () {
|
|
1881
|
-
var
|
|
1880
|
+
var ctxClassNames = React.useContext(StyleTokensContext);
|
|
1882
1881
|
var globalVariants = useGlobalVariants();
|
|
1883
1882
|
return React.useMemo(function () {
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
else {
|
|
1888
|
-
return activeTokensClassNames(tokenData, globalVariants);
|
|
1889
|
-
}
|
|
1890
|
-
}, [overrides, globalVariants, tokenData]);
|
|
1883
|
+
// Use a set to deduplicate
|
|
1884
|
+
return Array.from(new Set(__spreadArray(__spreadArray([], __read((ctxClassNames !== null && ctxClassNames !== void 0 ? ctxClassNames : [])), false), __read(activeTokensClassNames(tokenData, globalVariants)), false)));
|
|
1885
|
+
}, [ctxClassNames, globalVariants]);
|
|
1891
1886
|
};
|
|
1892
1887
|
}
|
|
1893
1888
|
/**
|
|
1894
|
-
* Creates a
|
|
1895
|
-
*
|
|
1889
|
+
* Creates a StyleTokensProvider for a given project to allow propagating its overrides to components of other projects.
|
|
1890
|
+
*
|
|
1891
|
+
* To ensure all tokens in the overrides class name resolve properly, the base and varianted class names must be included.
|
|
1896
1892
|
*
|
|
1897
1893
|
* Usage:
|
|
1898
1894
|
* ```
|
|
1899
1895
|
* // PlasmicStyleTokensProvider.ts
|
|
1900
1896
|
* export const StyleTokensProvider = createStyleTokensProvider(
|
|
1901
|
-
*
|
|
1897
|
+
* { base: `${projectcss.plasmic_tokens_override} ${data.base}`, varianted: data.varianted },
|
|
1902
1898
|
* useGlobalVariants,
|
|
1903
1899
|
* );
|
|
1904
1900
|
*
|
|
@@ -1932,6 +1928,7 @@ function createStyleTokensProvider(tokenData, useGlobalVariants) {
|
|
|
1932
1928
|
* global variants.
|
|
1933
1929
|
*/
|
|
1934
1930
|
function activeTokensClassNames(tokenData, globalVariants) {
|
|
1931
|
+
var _a, _b;
|
|
1935
1932
|
var varianted = tokenData.varianted
|
|
1936
1933
|
.filter(function (_a) {
|
|
1937
1934
|
var groupName = _a.groupName, variant = _a.variant;
|
|
@@ -1941,7 +1938,7 @@ function activeTokensClassNames(tokenData, globalVariants) {
|
|
|
1941
1938
|
var className = _a.className;
|
|
1942
1939
|
return className;
|
|
1943
1940
|
});
|
|
1944
|
-
return __spreadArray([tokenData.base], __read(varianted), false);
|
|
1941
|
+
return __spreadArray(__spreadArray([], __read(((_b = (_a = tokenData.base) === null || _a === void 0 ? void 0 : _a.split(" ")) !== null && _b !== void 0 ? _b : [])), false), __read(varianted), false);
|
|
1945
1942
|
}
|
|
1946
1943
|
|
|
1947
1944
|
function useFocused(opts) {
|