@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.
@@ -2,7 +2,10 @@ import React from "react";
2
2
  import { UseGlobalVariants } from "./global-variants";
3
3
  type ClassName = string;
4
4
  /**
5
- * All style token data for this project.
5
+ * All style token data (except overrides) for this project.
6
+ * This data is used as the default context value.
7
+ *
8
+ * We don't include the overrides because the Provider (that wraps the components) decides which project's overrides to apply.
6
9
  *
7
10
  * Usage:
8
11
  *
@@ -11,9 +14,10 @@ type ClassName = string;
11
14
  * import { usePlatform } from "./PlasmicGlobalVariant__Platform";
12
15
  * import { useTheme } from "./PlasmicGlobalVariant__Theme";
13
16
  * import projectcss from "./plasmic.module.css";
17
+ * import depcss from "../dep/plasmic.module.css";
14
18
  *
15
- * const projectStyleTokenData: ProjectStyleTokenData = {
16
- * base: projectcss.plasmic_tokens,
19
+ * const data: ProjectStyleTokenData = {
20
+ * base: `${projectcss.plasmic_tokens} ${depcss.plasmic_tokens}`,
17
21
  * varianted: [
18
22
  * {
19
23
  * className: projectcss.global_platform_windows,
@@ -40,7 +44,7 @@ type ClassName = string;
40
44
  * ```
41
45
  */
42
46
  interface ProjectStyleTokenData {
43
- base: ClassName;
47
+ base?: ClassName;
44
48
  varianted: {
45
49
  className: ClassName;
46
50
  groupName: string;
@@ -49,14 +53,13 @@ interface ProjectStyleTokenData {
49
53
  }
50
54
  type UseStyleTokens = () => ClassName[];
51
55
  /**
52
- * Returns style tokens. If the context is not available, falls back to the
53
- * current project's styles.
56
+ * 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.
54
57
  *
55
58
  * Usage:
56
59
  * ```
57
60
  * // PlasmicStyleTokensProvider.ts
58
61
  * export const useStyleTokens = createUseStyleTokens(
59
- * projectStyleTokenData,
62
+ * data,
60
63
  * useGlobalVariants,
61
64
  * );
62
65
  *
@@ -83,14 +86,15 @@ type UseStyleTokens = () => ClassName[];
83
86
  */
84
87
  export declare function createUseStyleTokens(tokenData: ProjectStyleTokenData, useGlobalVariants: UseGlobalVariants): UseStyleTokens;
85
88
  /**
86
- * Creates a StyleTokens context provider for a given project, which includes
87
- * its tokens, overrides, and all tokens from its dependencies.
89
+ * Creates a StyleTokensProvider for a given project to allow propagating its overrides to components of other projects.
90
+ *
91
+ * To ensure all tokens in the overrides class name resolve properly, the base and varianted class names must be included.
88
92
  *
89
93
  * Usage:
90
94
  * ```
91
95
  * // PlasmicStyleTokensProvider.ts
92
96
  * export const StyleTokensProvider = createStyleTokensProvider(
93
- * projectStyleTokenData,
97
+ * { base: `${projectcss.plasmic_tokens_override} ${data.base}`, varianted: data.varianted },
94
98
  * useGlobalVariants,
95
99
  * );
96
100
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/react-web",
3
- "version": "0.2.403",
3
+ "version": "0.2.405",
4
4
  "description": "plasmic library for rendering in the presentational style",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
@@ -95,14 +95,14 @@
95
95
  "test-storybook": "test-storybook"
96
96
  },
97
97
  "dependencies": {
98
- "@plasmicapp/auth-react": "0.0.23",
99
- "@plasmicapp/data-sources": "0.1.190",
98
+ "@plasmicapp/auth-react": "0.0.24",
99
+ "@plasmicapp/data-sources": "0.1.191",
100
100
  "@plasmicapp/data-sources-context": "0.1.22",
101
- "@plasmicapp/host": "1.0.226",
101
+ "@plasmicapp/host": "1.0.227",
102
102
  "@plasmicapp/loader-splits": "1.0.65",
103
- "@plasmicapp/nextjs-app-router": "1.0.18",
104
- "@plasmicapp/prepass": "1.0.20",
105
- "@plasmicapp/query": "0.1.80",
103
+ "@plasmicapp/nextjs-app-router": "1.0.19",
104
+ "@plasmicapp/prepass": "1.0.21",
105
+ "@plasmicapp/query": "0.1.81",
106
106
  "@react-aria/checkbox": "^3.15.5",
107
107
  "@react-aria/focus": "^3.20.3",
108
108
  "@react-aria/interactions": "^3.25.1",
@@ -153,5 +153,5 @@
153
153
  "react": ">=16.8.0",
154
154
  "react-dom": ">=16.8.0"
155
155
  },
156
- "gitHead": "8c7b2566770ba6dbc181bd98a22cca50cc84c57e"
156
+ "gitHead": "6b7adfd7b48f564d94e18eed3f1904c62dcd1e2d"
157
157
  }
@@ -749,14 +749,13 @@ function createUseScreenVariants(isMulti, screenQueries) {
749
749
  */
750
750
  var StyleTokensContext = React__default.createContext(undefined);
751
751
  /**
752
- * Returns style tokens. If the context is not available, falls back to the
753
- * current project's styles.
752
+ * 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.
754
753
  *
755
754
  * Usage:
756
755
  * ```
757
756
  * // PlasmicStyleTokensProvider.ts
758
757
  * export const useStyleTokens = createUseStyleTokens(
759
- * projectStyleTokenData,
758
+ * data,
760
759
  * useGlobalVariants,
761
760
  * );
762
761
  *
@@ -783,27 +782,24 @@ var StyleTokensContext = React__default.createContext(undefined);
783
782
  */
784
783
  function createUseStyleTokens(tokenData, useGlobalVariants) {
785
784
  return function () {
786
- var overrides = React__default.useContext(StyleTokensContext);
785
+ var ctxClassNames = React__default.useContext(StyleTokensContext);
787
786
  var globalVariants = useGlobalVariants();
788
787
  return React__default.useMemo(function () {
789
- if (overrides && overrides.length > 0) {
790
- return overrides;
791
- }
792
- else {
793
- return activeTokensClassNames(tokenData, globalVariants);
794
- }
795
- }, [overrides, globalVariants, tokenData]);
788
+ // Use a set to deduplicate
789
+ return Array.from(new Set(__spreadArray(__spreadArray([], __read((ctxClassNames !== null && ctxClassNames !== void 0 ? ctxClassNames : [])), false), __read(activeTokensClassNames(tokenData, globalVariants)), false)));
790
+ }, [ctxClassNames, globalVariants]);
796
791
  };
797
792
  }
798
793
  /**
799
- * Creates a StyleTokens context provider for a given project, which includes
800
- * its tokens, overrides, and all tokens from its dependencies.
794
+ * Creates a StyleTokensProvider for a given project to allow propagating its overrides to components of other projects.
795
+ *
796
+ * To ensure all tokens in the overrides class name resolve properly, the base and varianted class names must be included.
801
797
  *
802
798
  * Usage:
803
799
  * ```
804
800
  * // PlasmicStyleTokensProvider.ts
805
801
  * export const StyleTokensProvider = createStyleTokensProvider(
806
- * projectStyleTokenData,
802
+ * { base: `${projectcss.plasmic_tokens_override} ${data.base}`, varianted: data.varianted },
807
803
  * useGlobalVariants,
808
804
  * );
809
805
  *
@@ -837,6 +833,7 @@ function createStyleTokensProvider(tokenData, useGlobalVariants) {
837
833
  * global variants.
838
834
  */
839
835
  function activeTokensClassNames(tokenData, globalVariants) {
836
+ var _a, _b;
840
837
  var varianted = tokenData.varianted
841
838
  .filter(function (_a) {
842
839
  var groupName = _a.groupName, variant = _a.variant;
@@ -846,7 +843,7 @@ function activeTokensClassNames(tokenData, globalVariants) {
846
843
  var className = _a.className;
847
844
  return className;
848
845
  });
849
- return __spreadArray([tokenData.base], __read(varianted), false);
846
+ 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);
850
847
  }
851
848
 
852
849
  function useFocused(opts) {