@plasmicapp/react-web 0.2.403 → 0.2.405
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 +14 -10
- 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 +8 -8
- 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
|
@@ -12970,7 +12970,10 @@ declare const useIsSSR: typeof useIsSSR$1;
|
|
|
12970
12970
|
|
|
12971
12971
|
type ClassName = string;
|
|
12972
12972
|
/**
|
|
12973
|
-
* 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.
|
|
12974
12977
|
*
|
|
12975
12978
|
* Usage:
|
|
12976
12979
|
*
|
|
@@ -12979,9 +12982,10 @@ type ClassName = string;
|
|
|
12979
12982
|
* import { usePlatform } from "./PlasmicGlobalVariant__Platform";
|
|
12980
12983
|
* import { useTheme } from "./PlasmicGlobalVariant__Theme";
|
|
12981
12984
|
* import projectcss from "./plasmic.module.css";
|
|
12985
|
+
* import depcss from "../dep/plasmic.module.css";
|
|
12982
12986
|
*
|
|
12983
|
-
* const
|
|
12984
|
-
* base: projectcss.plasmic_tokens
|
|
12987
|
+
* const data: ProjectStyleTokenData = {
|
|
12988
|
+
* base: `${projectcss.plasmic_tokens} ${depcss.plasmic_tokens}`,
|
|
12985
12989
|
* varianted: [
|
|
12986
12990
|
* {
|
|
12987
12991
|
* className: projectcss.global_platform_windows,
|
|
@@ -13008,7 +13012,7 @@ type ClassName = string;
|
|
|
13008
13012
|
* ```
|
|
13009
13013
|
*/
|
|
13010
13014
|
interface ProjectStyleTokenData {
|
|
13011
|
-
base
|
|
13015
|
+
base?: ClassName;
|
|
13012
13016
|
varianted: {
|
|
13013
13017
|
className: ClassName;
|
|
13014
13018
|
groupName: string;
|
|
@@ -13017,14 +13021,13 @@ interface ProjectStyleTokenData {
|
|
|
13017
13021
|
}
|
|
13018
13022
|
type UseStyleTokens = () => ClassName[];
|
|
13019
13023
|
/**
|
|
13020
|
-
*
|
|
13021
|
-
* 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.
|
|
13022
13025
|
*
|
|
13023
13026
|
* Usage:
|
|
13024
13027
|
* ```
|
|
13025
13028
|
* // PlasmicStyleTokensProvider.ts
|
|
13026
13029
|
* export const useStyleTokens = createUseStyleTokens(
|
|
13027
|
-
*
|
|
13030
|
+
* data,
|
|
13028
13031
|
* useGlobalVariants,
|
|
13029
13032
|
* );
|
|
13030
13033
|
*
|
|
@@ -13051,14 +13054,15 @@ type UseStyleTokens = () => ClassName[];
|
|
|
13051
13054
|
*/
|
|
13052
13055
|
declare function createUseStyleTokens(tokenData: ProjectStyleTokenData, useGlobalVariants: UseGlobalVariants): UseStyleTokens;
|
|
13053
13056
|
/**
|
|
13054
|
-
* Creates a
|
|
13055
|
-
*
|
|
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.
|
|
13056
13060
|
*
|
|
13057
13061
|
* Usage:
|
|
13058
13062
|
* ```
|
|
13059
13063
|
* // PlasmicStyleTokensProvider.ts
|
|
13060
13064
|
* export const StyleTokensProvider = createStyleTokensProvider(
|
|
13061
|
-
*
|
|
13065
|
+
* { base: `${projectcss.plasmic_tokens_override} ${data.base}`, varianted: data.varianted },
|
|
13062
13066
|
* useGlobalVariants,
|
|
13063
13067
|
* );
|
|
13064
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) {
|