@lark-apaas/client-toolkit 1.1.19-antd-test.0 → 1.1.19-antd-test.2

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.
@@ -1,7 +1,5 @@
1
1
  import React from 'react';
2
- import { IBaseThemeProviderProps } from '../theme';
3
- import '../../index.css';
4
2
  declare const AppContainer: React.FC<{
5
3
  children: React.ReactNode;
6
- } & IBaseThemeProviderProps>;
4
+ }>;
7
5
  export default AppContainer;
@@ -1,19 +1,7 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import react, { useEffect } from "react";
3
- import { MiaodaInspector } from "@lark-apaas/miaoda-inspector";
4
- import IframeBridge from "./IframeBridge.js";
5
- import { defaultUIConfig } from "../theme/ui-config.js";
6
- import { Toaster } from "./sonner.js";
7
- import { PageHoc } from "./PageHoc.js";
8
- import { findValueByPixel, generateTailwindRadiusToken, themeColorTokenMap, themeMetaOptions } from "../theme/index.js";
9
- import { registerDayjsPlugins } from "./dayjsPlugins.js";
10
- import "../../index.css";
11
- import { initAxiosConfig } from "../../utils/axiosConfig.js";
12
- import { useAppInfo } from "../../hooks/index.js";
2
+ import { useEffect, useRef, useState } from "react";
3
+ import { ConfigProvider } from "antd";
13
4
  import safety from "./safety.js";
14
- registerDayjsPlugins();
15
- initAxiosConfig();
16
- const isMiaodaPreview = window.IS_MIAODA_PREVIEW;
17
5
  const readCssVarColor = (varName, fallback)=>{
18
6
  try {
19
7
  if ('undefined' == typeof document) return fallback;
@@ -23,149 +11,85 @@ const readCssVarColor = (varName, fallback)=>{
23
11
  return fallback;
24
12
  }
25
13
  };
26
- const App = (props)=>{
27
- const { themeMeta = {} } = props;
28
- useAppInfo();
29
- const { rem } = findValueByPixel(themeMetaOptions.themeRadius, themeMeta.borderRadius) || {
30
- rem: '0.625'
31
- };
32
- const radiusToken = generateTailwindRadiusToken(Number(rem));
33
- const themeToken = {
34
- ...defaultUIConfig,
35
- common: {
36
- ...defaultUIConfig.common,
37
- borderRadius: radiusToken
38
- }
39
- };
14
+ const AppContainer = (props)=>{
15
+ const { children } = props;
16
+ const [cssColors, setCssColors] = useState(()=>({
17
+ background: readCssVarColor('--background'),
18
+ destructive: readCssVarColor('--destructive'),
19
+ primary: readCssVarColor('--primary'),
20
+ foreground: readCssVarColor('--foreground'),
21
+ warning: readCssVarColor('--warning'),
22
+ success: readCssVarColor('--success'),
23
+ muted: readCssVarColor('--muted'),
24
+ mutedForeground: readCssVarColor('--muted-foreground'),
25
+ border: readCssVarColor('--border'),
26
+ popover: readCssVarColor('--popover'),
27
+ accent: readCssVarColor('--accent'),
28
+ radius: readCssVarColor('--radius')
29
+ }));
30
+ const lastHref = useRef(null);
40
31
  useEffect(()=>{
41
- if (isMiaodaPreview) fetch(`${location.origin}/ai/api/feida_preview/csrf`).then(()=>{
42
- setTimeout(()=>{
43
- const match = document.cookie.match(/lgw_csrf_token=([^;]+)/);
44
- if (match) window.lgw_csrf_token = match[1];
45
- }, 300);
32
+ if ('production' === process.env.NODE_ENV) return;
33
+ const selector = 'link[data-webpack="fullstack-nestjs-template:chunk-main"]';
34
+ const updateTheme = ()=>{
35
+ const linkTag = document.querySelector(selector);
36
+ const currentHref = linkTag?.href;
37
+ if (currentHref && currentHref !== lastHref.current) {
38
+ lastHref.current = currentHref;
39
+ setTimeout(()=>{
40
+ const newColors = {
41
+ background: readCssVarColor('--background'),
42
+ destructive: readCssVarColor('--destructive'),
43
+ primary: readCssVarColor('--primary'),
44
+ foreground: readCssVarColor('--foreground'),
45
+ warning: readCssVarColor('--warning'),
46
+ success: readCssVarColor('--success'),
47
+ muted: readCssVarColor('--muted'),
48
+ mutedForeground: readCssVarColor('--muted-foreground'),
49
+ border: readCssVarColor('--border'),
50
+ popover: readCssVarColor('--popover'),
51
+ accent: readCssVarColor('--accent'),
52
+ radius: readCssVarColor('--radius')
53
+ };
54
+ setCssColors((currentColors)=>{
55
+ if (JSON.stringify(currentColors) !== JSON.stringify(newColors)) return newColors;
56
+ return currentColors;
57
+ });
58
+ }, 100);
59
+ }
60
+ };
61
+ const headObserver = new MutationObserver(updateTheme);
62
+ updateTheme();
63
+ headObserver.observe(document.head, {
64
+ childList: true,
65
+ subtree: true
46
66
  });
67
+ return ()=>{
68
+ headObserver.disconnect();
69
+ };
47
70
  }, []);
48
- return /*#__PURE__*/ jsxs(Fragment, {
49
- children: [
50
- /*#__PURE__*/ jsx(Toaster, {}),
51
- 'production' !== process.env.NODE_ENV && /*#__PURE__*/ jsx(MiaodaInspector, {
52
- theme: {
53
- themeMetaOptions: themeMetaOptions,
54
- themeColorTokenMap: themeColorTokenMap,
55
- themeToken
56
- },
57
- cwd: process.env.CWD || ''
58
- }),
59
- 'production' !== process.env.NODE_ENV && /*#__PURE__*/ jsx(IframeBridge, {}),
60
- /*#__PURE__*/ jsx(PageHoc, {
61
- children: props.children
62
- })
63
- ]
64
- });
65
- };
66
- const AppContainer_AppContainer = (props)=>{
67
- const { children, ...rest } = props;
68
- const cssColors = {
69
- background: readCssVarColor('--background'),
70
- destructive: readCssVarColor('--destructive'),
71
- primary: readCssVarColor('--primary'),
72
- foreground: readCssVarColor('--foreground'),
73
- warning: readCssVarColor('--warning'),
74
- success: readCssVarColor('--success'),
75
- muted: readCssVarColor('--muted'),
76
- mutedForeground: readCssVarColor('--muted-foreground'),
77
- border: readCssVarColor('--border'),
78
- popover: readCssVarColor('--popover'),
79
- accent: readCssVarColor('--accent'),
80
- radius: readCssVarColor('--radius')
81
- };
82
- const antdThemeToken = {
83
- borderRadius: cssColors.radius,
84
- colorBgBase: cssColors.background,
85
- colorError: cssColors.destructive,
86
- colorInfo: cssColors.primary,
87
- colorLink: cssColors.primary,
88
- colorPrimary: cssColors.primary,
89
- colorSuccess: cssColors.primary,
90
- colorTextBase: cssColors.foreground,
91
- colorWarning: cssColors.destructive
92
- };
93
- const antdTableToken = {
94
- bodySortBg: cssColors.muted,
95
- borderColor: cssColors.border,
96
- expandIconBg: cssColors.background,
97
- filterDropdownBg: cssColors.popover,
98
- filterDropdownMenuBg: cssColors.popover,
99
- fixedHeaderSortActiveBg: cssColors.muted,
100
- footerBg: cssColors.muted,
101
- footerColor: cssColors.mutedForeground,
102
- headerBg: cssColors.muted,
103
- headerColor: cssColors.mutedForeground,
104
- headerFilterHoverBg: cssColors.muted,
105
- headerSortActiveBg: cssColors.muted,
106
- headerSortHoverBg: cssColors.muted,
107
- headerSplitColor: cssColors.border,
108
- rowExpandedBg: cssColors.background,
109
- rowHoverBg: cssColors.muted,
110
- rowSelectedBg: cssColors.accent,
111
- rowSelectedHoverBg: cssColors.accent,
112
- stickyScrollBarBg: cssColors.muted,
113
- headerBorderRadius: 'var(--radius)'
114
- };
115
- const antdPaginationToken = {
116
- itemActiveBg: cssColors.background,
117
- itemActiveBgDisabled: cssColors.muted,
118
- itemActiveColor: cssColors.primary,
119
- itemActiveColorDisabled: cssColors.muted,
120
- itemActiveColorHover: cssColors.muted,
121
- itemBg: cssColors.background,
122
- itemInputBg: cssColors.background,
123
- itemLinkBg: cssColors.background
124
- };
125
- const OptionalAntdProvider = ({ children })=>{
126
- const [Provider, setProvider] = react.useState(null);
127
- const [ready, setReady] = react.useState(false);
128
- react.useEffect(()=>{
129
- let mounted = true;
130
- import("antd").then((mod)=>{
131
- if (mounted && mod?.ConfigProvider) setProvider(()=>mod.ConfigProvider);
132
- if (mounted) setReady(true);
133
- }).catch(()=>{
134
- if (mounted) {
135
- setProvider(null);
136
- setReady(true);
137
- }
138
- });
139
- return ()=>{
140
- mounted = false;
141
- };
142
- }, []);
143
- if (!ready) return null;
144
- if (!Provider) return /*#__PURE__*/ jsx(Fragment, {
145
- children: children
146
- });
147
- return /*#__PURE__*/ jsx(Provider, {
148
- theme: {
149
- token: antdThemeToken,
150
- components: {
151
- Table: antdTableToken,
152
- Pagination: antdPaginationToken
153
- }
154
- },
155
- children: children
156
- });
71
+ const antdTheme = {
72
+ token: {
73
+ colorPrimary: cssColors.primary,
74
+ colorSuccess: cssColors.success,
75
+ colorWarning: cssColors.warning,
76
+ colorError: cssColors.destructive,
77
+ colorInfo: cssColors.primary,
78
+ colorTextBase: cssColors.foreground,
79
+ colorBgContainer: cssColors.background,
80
+ colorBorder: cssColors.border,
81
+ borderRadius: parseInt(cssColors.radius || '0')
82
+ }
157
83
  };
158
84
  return /*#__PURE__*/ jsxs(Fragment, {
159
85
  children: [
160
86
  /*#__PURE__*/ jsx(safety, {}),
161
- /*#__PURE__*/ jsx(OptionalAntdProvider, {
162
- children: /*#__PURE__*/ jsx(App, {
163
- themeMeta: props.themeMeta,
164
- children: children
165
- })
87
+ /*#__PURE__*/ jsx(ConfigProvider, {
88
+ theme: antdTheme,
89
+ children: children
166
90
  })
167
91
  ]
168
92
  });
169
93
  };
170
- const AppContainer = AppContainer_AppContainer;
171
- export { AppContainer as default };
94
+ const components_AppContainer = AppContainer;
95
+ export { components_AppContainer as default };
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { type VariantProps } from "class-variance-authority";
3
3
  declare const badgeVariants: (props?: {
4
- variant?: "default" | "secondary" | "destructive" | "outline";
4
+ variant?: "default" | "destructive" | "secondary" | "outline";
5
5
  } & import("class-variance-authority/dist/types").ClassProp) => string;
6
6
  declare function Badge({ className, variant, asChild, ...props }: React.ComponentProps<"span"> & VariantProps<typeof badgeVariants> & {
7
7
  asChild?: boolean;
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { type VariantProps } from "class-variance-authority";
3
3
  declare const buttonVariants: (props?: {
4
- variant?: "default" | "link" | "secondary" | "destructive" | "outline" | "ghost";
4
+ variant?: "default" | "link" | "destructive" | "secondary" | "outline" | "ghost";
5
5
  size?: "default" | "icon" | "sm" | "lg" | "icon-sm" | "icon-lg";
6
6
  } & import("class-variance-authority/dist/types").ClassProp) => string;
7
7
  declare function Button({ className, variant, size, asChild, ...props }: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/client-toolkit",
3
- "version": "1.1.19-antd-test.0",
3
+ "version": "1.1.19-antd-test.2",
4
4
  "types": "./lib/index.d.ts",
5
5
  "main": "./lib/index.js",
6
6
  "files": [
@@ -15,10 +15,10 @@
15
15
  "require": "./lib/index.js",
16
16
  "types": "./lib/index.d.ts"
17
17
  },
18
- "./ant-table": {
19
- "import": "./lib/ant-table.js",
20
- "require": "./lib/ant-table.js",
21
- "types": "./lib/ant-table.d.ts"
18
+ "./antd-table": {
19
+ "import": "./lib/antd-table.js",
20
+ "require": "./lib/antd-table.js",
21
+ "types": "./lib/antd-table.d.ts"
22
22
  },
23
23
  "./lib/index.css": "./lib/index.css",
24
24
  "./dataloom": {
File without changes
File without changes