@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/react-web.esm.js
CHANGED
|
@@ -1825,14 +1825,13 @@ function MaybeWrap(props) {
|
|
|
1825
1825
|
*/
|
|
1826
1826
|
var StyleTokensContext = React__default.createContext(undefined);
|
|
1827
1827
|
/**
|
|
1828
|
-
*
|
|
1829
|
-
* current project's styles.
|
|
1828
|
+
* 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.
|
|
1830
1829
|
*
|
|
1831
1830
|
* Usage:
|
|
1832
1831
|
* ```
|
|
1833
1832
|
* // PlasmicStyleTokensProvider.ts
|
|
1834
1833
|
* export const useStyleTokens = createUseStyleTokens(
|
|
1835
|
-
*
|
|
1834
|
+
* data,
|
|
1836
1835
|
* useGlobalVariants,
|
|
1837
1836
|
* );
|
|
1838
1837
|
*
|
|
@@ -1859,27 +1858,24 @@ var StyleTokensContext = React__default.createContext(undefined);
|
|
|
1859
1858
|
*/
|
|
1860
1859
|
function createUseStyleTokens(tokenData, useGlobalVariants) {
|
|
1861
1860
|
return function () {
|
|
1862
|
-
var
|
|
1861
|
+
var ctxClassNames = React__default.useContext(StyleTokensContext);
|
|
1863
1862
|
var globalVariants = useGlobalVariants();
|
|
1864
1863
|
return React__default.useMemo(function () {
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
else {
|
|
1869
|
-
return activeTokensClassNames(tokenData, globalVariants);
|
|
1870
|
-
}
|
|
1871
|
-
}, [overrides, globalVariants, tokenData]);
|
|
1864
|
+
// Use a set to deduplicate
|
|
1865
|
+
return Array.from(new Set(__spreadArray(__spreadArray([], __read((ctxClassNames !== null && ctxClassNames !== void 0 ? ctxClassNames : [])), false), __read(activeTokensClassNames(tokenData, globalVariants)), false)));
|
|
1866
|
+
}, [ctxClassNames, globalVariants]);
|
|
1872
1867
|
};
|
|
1873
1868
|
}
|
|
1874
1869
|
/**
|
|
1875
|
-
* Creates a
|
|
1876
|
-
*
|
|
1870
|
+
* Creates a StyleTokensProvider for a given project to allow propagating its overrides to components of other projects.
|
|
1871
|
+
*
|
|
1872
|
+
* To ensure all tokens in the overrides class name resolve properly, the base and varianted class names must be included.
|
|
1877
1873
|
*
|
|
1878
1874
|
* Usage:
|
|
1879
1875
|
* ```
|
|
1880
1876
|
* // PlasmicStyleTokensProvider.ts
|
|
1881
1877
|
* export const StyleTokensProvider = createStyleTokensProvider(
|
|
1882
|
-
*
|
|
1878
|
+
* { base: `${projectcss.plasmic_tokens_override} ${data.base}`, varianted: data.varianted },
|
|
1883
1879
|
* useGlobalVariants,
|
|
1884
1880
|
* );
|
|
1885
1881
|
*
|
|
@@ -1913,6 +1909,7 @@ function createStyleTokensProvider(tokenData, useGlobalVariants) {
|
|
|
1913
1909
|
* global variants.
|
|
1914
1910
|
*/
|
|
1915
1911
|
function activeTokensClassNames(tokenData, globalVariants) {
|
|
1912
|
+
var _a, _b;
|
|
1916
1913
|
var varianted = tokenData.varianted
|
|
1917
1914
|
.filter(function (_a) {
|
|
1918
1915
|
var groupName = _a.groupName, variant = _a.variant;
|
|
@@ -1922,7 +1919,7 @@ function activeTokensClassNames(tokenData, globalVariants) {
|
|
|
1922
1919
|
var className = _a.className;
|
|
1923
1920
|
return className;
|
|
1924
1921
|
});
|
|
1925
|
-
return __spreadArray([tokenData.base], __read(varianted), false);
|
|
1922
|
+
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);
|
|
1926
1923
|
}
|
|
1927
1924
|
|
|
1928
1925
|
function useFocused(opts) {
|