@4399ywkf/core 5.0.20 → 5.0.22
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/index.js +35 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3659,11 +3659,13 @@ function buildImports(opts) {
|
|
|
3659
3659
|
"useCallback",
|
|
3660
3660
|
"useEffect",
|
|
3661
3661
|
"useMemo",
|
|
3662
|
+
"useState",
|
|
3662
3663
|
...opts.cssVar ? ["useLayoutEffect", "useRef"] : [],
|
|
3663
3664
|
"type ReactNode"
|
|
3664
3665
|
];
|
|
3665
3666
|
const antdStyleImports = [
|
|
3666
3667
|
"ThemeProvider as AntdThemeProvider",
|
|
3668
|
+
"StyleProvider",
|
|
3667
3669
|
"type GetAntdTheme",
|
|
3668
3670
|
...opts.globalReset ? ["createGlobalStyle", "css"] : []
|
|
3669
3671
|
];
|
|
@@ -3789,7 +3791,6 @@ const GlobalReset = createGlobalStyle(({ theme }) => css\`
|
|
|
3789
3791
|
}
|
|
3790
3792
|
|
|
3791
3793
|
::selection {
|
|
3792
|
-
color: #000;
|
|
3793
3794
|
-webkit-text-fill-color: unset !important;
|
|
3794
3795
|
}
|
|
3795
3796
|
\`);`;
|
|
@@ -3904,9 +3905,21 @@ function buildWrapperCode(opts) {
|
|
|
3904
3905
|
const childrenSlot = cssVar ? `<div ref={containerRef} style={{ display: "contents" }}>
|
|
3905
3906
|
{children}
|
|
3906
3907
|
</div>` : "{children}";
|
|
3908
|
+
const antdProvider = `<AntdThemeProvider
|
|
3909
|
+
prefixCls={RUNTIME_PREFIX_CLS}
|
|
3910
|
+
appearance={resolvedAppearance}
|
|
3911
|
+
themeMode={appearance}
|
|
3912
|
+
theme={theme}${cssVar ? "\n customToken={{ cssVar: true }}" : ""}
|
|
3913
|
+
>
|
|
3914
|
+
${globalReset ? "<GlobalReset />" : ""}
|
|
3915
|
+
${childrenSlot}
|
|
3916
|
+
</AntdThemeProvider>`;
|
|
3907
3917
|
return `
|
|
3908
3918
|
// \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 ThemeWrapper \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
|
|
3909
3919
|
|
|
3920
|
+
// \u8FD0\u884C\u65F6\u5224\u65AD\u662F\u5426\u5904\u4E8E Garfish \u5B50\u5E94\u7528\u73AF\u5883\uFF0C\u540C\u4E00 bundle \u652F\u6301\u72EC\u7ACB\u90E8\u7F72\u4E0E\u5FAE\u524D\u7AEF\u4E24\u79CD\u6A21\u5F0F\u3002
|
|
3921
|
+
const IS_MICRO_APP = typeof window !== "undefined" && !!(window as any).__GARFISH__;
|
|
3922
|
+
|
|
3910
3923
|
const RUNTIME_PREFIX_CLS = typeof process !== "undefined"
|
|
3911
3924
|
&& process.env?.YWKF_PREFIX_CLS
|
|
3912
3925
|
|| "${prefixCls}";
|
|
@@ -3921,6 +3934,21 @@ export function ThemeWrapper({ children }: ThemeWrapperProps) {${refLine}
|
|
|
3921
3934
|
shallow,
|
|
3922
3935
|
);${cssVarSyncLine}${appearanceSyncLine}${externalThemeLine}
|
|
3923
3936
|
|
|
3937
|
+
// \u5FAE\u524D\u7AEF\u6A21\u5F0F\u4E0B\uFF0C\u5C06 CSS-in-JS \u6837\u5F0F\u6CE8\u5165\u5230 Garfish \u5B50\u5E94\u7528\u5BB9\u5668\u800C\u975E document.head\uFF0C
|
|
3938
|
+
// \u907F\u514D\u4E0E\u4E3B\u5E94\u7528\u5171\u4EAB\u7684 @ant-design/cssinjs StyleContext \u4EA7\u751F\u51B2\u7A81\u3002
|
|
3939
|
+
// useState lazy initializer \u540C\u6B65\u8BFB\u53D6\uFF08Garfish \u6302\u8F7D\u65F6\u5BB9\u5668\u5DF2\u63D0\u524D\u521B\u5EFA\uFF09\uFF0C
|
|
3940
|
+
// useEffect \u515C\u5E95\u5904\u7406\u6781\u7AEF\u7ADE\u6001\uFF08\u5982 SSR hydration\uFF09\u3002
|
|
3941
|
+
const [styleContainer, setStyleContainer] = useState<HTMLElement | undefined>(() => {
|
|
3942
|
+
if (!IS_MICRO_APP || typeof document === "undefined") return undefined;
|
|
3943
|
+
return document.getElementById(RUNTIME_PREFIX_CLS)?.parentElement ?? undefined;
|
|
3944
|
+
});
|
|
3945
|
+
|
|
3946
|
+
useEffect(() => {
|
|
3947
|
+
if (!IS_MICRO_APP) return;
|
|
3948
|
+
const el = document.getElementById(RUNTIME_PREFIX_CLS)?.parentElement;
|
|
3949
|
+
if (el) setStyleContainer(el);
|
|
3950
|
+
}, []);
|
|
3951
|
+
|
|
3924
3952
|
const resolvedAppearance = useMemo(() => {
|
|
3925
3953
|
if (appearance !== "auto") return appearance;
|
|
3926
3954
|
if (typeof window === "undefined") return "light";
|
|
@@ -3936,17 +3964,13 @@ export function ThemeWrapper({ children }: ThemeWrapperProps) {${refLine}
|
|
|
3936
3964
|
[primaryColor, neutralColor],
|
|
3937
3965
|
);
|
|
3938
3966
|
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
prefixCls={RUNTIME_PREFIX_CLS}
|
|
3942
|
-
appearance={resolvedAppearance}
|
|
3943
|
-
themeMode={appearance}
|
|
3944
|
-
theme={theme}${cssVar ? "\n customToken={{ cssVar: true }}" : ""}
|
|
3945
|
-
>
|
|
3946
|
-
${globalReset ? "<GlobalReset />" : ""}
|
|
3947
|
-
${childrenSlot}
|
|
3948
|
-
</AntdThemeProvider>
|
|
3967
|
+
const provider = (
|
|
3968
|
+
${antdProvider}
|
|
3949
3969
|
);
|
|
3970
|
+
|
|
3971
|
+
return IS_MICRO_APP && styleContainer ? (
|
|
3972
|
+
<StyleProvider container={styleContainer}>{provider}</StyleProvider>
|
|
3973
|
+
) : provider;
|
|
3950
3974
|
}
|
|
3951
3975
|
|
|
3952
3976
|
export default ThemeWrapper;
|