@lark-apaas/client-toolkit 1.2.10-alpha.36 → 1.2.10-alpha.38

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.
@@ -4,7 +4,11 @@ import '../../runtime';
4
4
  interface IBaseAuthProviderProps {
5
5
  enableAuth?: boolean;
6
6
  }
7
+ interface IToasterProps {
8
+ /** 禁用内建 Toaster 组件,默认 false */
9
+ disableToaster?: boolean;
10
+ }
7
11
  declare const AppContainer: React.FC<{
8
12
  children: React.ReactNode;
9
- } & IBaseThemeProviderProps & IBaseAuthProviderProps>;
13
+ } & IBaseThemeProviderProps & IBaseAuthProviderProps & IToasterProps>;
10
14
  export default AppContainer;
@@ -4,8 +4,10 @@ import { ConfigProvider } from "antd";
4
4
  import { MiaodaInspector } from "@lark-apaas/miaoda-inspector";
5
5
  import zh_CN from "antd/locale/zh_CN";
6
6
  import IframeBridge from "./IframeBridge.js";
7
+ import { defaultUIConfig } from "../theme/ui-config.js";
7
8
  import { Toaster } from "./sonner.js";
8
9
  import { PageHoc } from "./PageHoc.js";
10
+ import { findValueByPixel, generateTailwindRadiusToken, themeColorTokenMap, themeMetaOptions } from "../theme/index.js";
9
11
  import { reportTeaEvent } from "./utils/tea.js";
10
12
  import { useAppInfo } from "../../hooks/index.js";
11
13
  import { TrackKey } from "../../types/tea.js";
@@ -24,9 +26,21 @@ const readCssVarColor = (varName, fallback)=>{
24
26
  return fallback;
25
27
  }
26
28
  };
29
+ const appFlags = process.env.APP_FLAGS || {};
27
30
  const App = (props)=>{
28
- const { enableAuth } = props;
31
+ const { themeMeta = {}, enableAuth, disableToaster = false } = props;
29
32
  useAppInfo();
33
+ const { rem } = findValueByPixel(themeMetaOptions.themeRadius, themeMeta.borderRadius) || {
34
+ rem: '0.625'
35
+ };
36
+ const radiusToken = generateTailwindRadiusToken(Number(rem));
37
+ const themeToken = {
38
+ ...defaultUIConfig,
39
+ common: {
40
+ ...defaultUIConfig.common,
41
+ borderRadius: radiusToken
42
+ }
43
+ };
30
44
  useEffect(()=>{
31
45
  if (isMiaodaPreview) fetch(`${location.origin}/ai/api/feida_preview/csrf`).then(()=>{
32
46
  setTimeout(()=>{
@@ -50,8 +64,15 @@ const App = (props)=>{
50
64
  enable: enableAuth
51
65
  },
52
66
  children: [
53
- /*#__PURE__*/ jsx(Toaster, {}),
54
- 'production' !== process.env.NODE_ENV && /*#__PURE__*/ jsx(MiaodaInspector, {}),
67
+ !disableToaster && true !== appFlags.customToaster && /*#__PURE__*/ jsx(Toaster, {}),
68
+ 'production' !== process.env.NODE_ENV && /*#__PURE__*/ jsx(MiaodaInspector, {
69
+ theme: {
70
+ themeMetaOptions: themeMetaOptions,
71
+ themeColorTokenMap: themeColorTokenMap,
72
+ themeToken
73
+ },
74
+ cwd: process.env.CWD || ''
75
+ }),
55
76
  'production' !== process.env.NODE_ENV && /*#__PURE__*/ jsx(IframeBridge, {}),
56
77
  /*#__PURE__*/ jsx(PageHoc, {
57
78
  children: props.children
@@ -60,7 +81,7 @@ const App = (props)=>{
60
81
  });
61
82
  };
62
83
  const AppContainer_AppContainer = (props)=>{
63
- const { children } = props;
84
+ const { children, ...rest } = props;
64
85
  const [cssColors, setCssColors] = useState(()=>({
65
86
  background: readCssVarColor('--background'),
66
87
  destructive: readCssVarColor('--destructive'),
@@ -188,7 +209,9 @@ const AppContainer_AppContainer = (props)=>{
188
209
  }
189
210
  },
190
211
  children: /*#__PURE__*/ jsx(App, {
212
+ themeMeta: props.themeMeta,
191
213
  enableAuth: props.enableAuth,
214
+ disableToaster: props.disableToaster,
192
215
  children: children
193
216
  })
194
217
  })
@@ -1,2 +1,3 @@
1
1
  export * from './constants';
2
2
  export * from './util';
3
+ export * from './ui-config';
@@ -1,2 +1,3 @@
1
1
  export * from "./constants.js";
2
2
  export * from "./util.js";
3
+ export * from "./ui-config.js";
@@ -0,0 +1 @@
1
+ export { defaultUIConfig, type UIComponentConfig, } from '@lark-apaas/miaoda-inspector';
@@ -0,0 +1,2 @@
1
+ import { defaultUIConfig } from "@lark-apaas/miaoda-inspector";
2
+ export { defaultUIConfig };
@@ -1,4 +1,5 @@
1
1
  import { ITheme } from "../../types";
2
+ import { UIComponentConfig } from "./ui-config";
2
3
  export interface IBaseThemeProviderProps {
3
4
  defaultTheme?: ITheme;
4
5
  themeMeta?: Partial<IThemeTokenMeta>;
@@ -17,3 +18,4 @@ export interface IThemeTokenMeta {
17
18
  */
18
19
  spacing: number;
19
20
  }
21
+ export declare const generateTailwindRadiusToken: (radiusRemValue: number) => UIComponentConfig;
@@ -0,0 +1,108 @@
1
+ const generateTailwindRadiusToken = (radiusRemValue)=>{
2
+ try {
3
+ const rootFontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);
4
+ const radiusPx = radiusRemValue * rootFontSize;
5
+ const tempElement = document.createElement('div');
6
+ tempElement.style.position = 'absolute';
7
+ tempElement.style.visibility = 'hidden';
8
+ document.body.appendChild(tempElement);
9
+ tempElement.style.borderRadius = `${radiusPx}px`;
10
+ const computed = getComputedStyle(tempElement).borderRadius;
11
+ document.body.removeChild(tempElement);
12
+ if (computed && 'auto' !== computed && 'initial' !== computed) return {
13
+ type: 'select',
14
+ options: [
15
+ {
16
+ value: 'rounded-none',
17
+ label: 'none(0px)',
18
+ rawValue: '0'
19
+ },
20
+ {
21
+ value: 'rounded-sm',
22
+ label: `sm (${Math.max(0, radiusPx - 4)}px)`,
23
+ rawValue: `${Math.max(0, radiusPx - 4)}`
24
+ },
25
+ {
26
+ value: 'rounded',
27
+ label: 's (4px)',
28
+ rawValue: '4'
29
+ },
30
+ {
31
+ value: 'rounded-md',
32
+ label: `m (${Math.max(0, radiusPx - 2)}px)`,
33
+ rawValue: `${Math.max(0, radiusPx - 2)}`
34
+ },
35
+ {
36
+ value: 'rounded-lg',
37
+ label: `l (${radiusPx}px)`,
38
+ rawValue: `${radiusPx}`
39
+ },
40
+ {
41
+ value: 'rounded-xl',
42
+ label: `xl (${radiusPx + 4}px)`,
43
+ rawValue: `${radiusPx + 4}`
44
+ },
45
+ {
46
+ value: 'rounded-2xl',
47
+ label: '2xl (16px)',
48
+ rawValue: '16'
49
+ },
50
+ {
51
+ value: 'rounded-full',
52
+ label: 'Full',
53
+ rawValue: '9999'
54
+ }
55
+ ]
56
+ };
57
+ throw new Error('Browser calculation validation failed');
58
+ } catch (error) {
59
+ console.warn('Failed to get computed values from browser, falling back to default calculation:', error);
60
+ const radiusPx = 16 * radiusRemValue;
61
+ return {
62
+ type: 'select',
63
+ options: [
64
+ {
65
+ value: 'rounded-none',
66
+ label: 'none(0px)',
67
+ rawValue: '0'
68
+ },
69
+ {
70
+ value: 'rounded-sm',
71
+ label: `sm (${Math.max(0, radiusPx - 4)}px)`,
72
+ rawValue: `${Math.max(0, radiusPx - 4)}`
73
+ },
74
+ {
75
+ value: 'rounded',
76
+ label: 's (4px)',
77
+ rawValue: '4'
78
+ },
79
+ {
80
+ value: 'rounded-md',
81
+ label: `m (${Math.max(0, radiusPx - 2)}px)`,
82
+ rawValue: `${Math.max(0, radiusPx - 2)}`
83
+ },
84
+ {
85
+ value: 'rounded-lg',
86
+ label: `l (${radiusPx}px)`,
87
+ rawValue: `${radiusPx}`
88
+ },
89
+ {
90
+ value: 'rounded-xl',
91
+ label: `xl (${radiusPx + 4}px)`,
92
+ rawValue: `${radiusPx + 4}`
93
+ },
94
+ {
95
+ value: 'rounded-2xl',
96
+ label: '2xl (16px)',
97
+ rawValue: '16'
98
+ },
99
+ {
100
+ value: 'rounded-full',
101
+ label: 'Full',
102
+ rawValue: '9999'
103
+ }
104
+ ]
105
+ };
106
+ }
107
+ };
108
+ export { generateTailwindRadiusToken };
@@ -14,6 +14,7 @@ export type UserInfo = {
14
14
  avatar: string;
15
15
  userType: '_employee' | '_externalUser' | '_anonymousUser';
16
16
  department: DepartmentBasic;
17
+ email?: string;
17
18
  };
18
19
  export type DepartmentInfo = {
19
20
  departmentID: string;
@@ -15,7 +15,6 @@
15
15
  * - 使用 __FULLSTACK_RUNTIME_INITIALIZED__ 标志位防止重复初始化
16
16
  * - 旧版 AppContainer 和新版 runtime 可以共存
17
17
  */
18
- import './react-devtools-hook';
19
18
  import './styles';
20
19
  declare global {
21
20
  interface Window {
@@ -1,4 +1,3 @@
1
- import "./react-devtools-hook.js";
2
1
  import "./styles.js";
3
2
  import { registerDayjsPlugins } from "./dayjs.js";
4
3
  import { initAxiosConfig } from "./axios.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/client-toolkit",
3
- "version": "1.2.10-alpha.36",
3
+ "version": "1.2.10-alpha.38",
4
4
  "types": "./lib/index.d.ts",
5
5
  "main": "./lib/index.js",
6
6
  "files": [
@@ -93,10 +93,10 @@
93
93
  "dependencies": {
94
94
  "@ant-design/colors": "^7.2.1",
95
95
  "@ant-design/cssinjs": "^1.24.0",
96
- "@data-loom/js": "0.4.6",
96
+ "@data-loom/js": "0.4.7",
97
97
  "@lark-apaas/auth-sdk": "^0.1.0",
98
98
  "@lark-apaas/client-capability": "^0.1.4",
99
- "@lark-apaas/miaoda-inspector": "1.0.14-alpha.18",
99
+ "@lark-apaas/miaoda-inspector": "^1.0.16",
100
100
  "@lark-apaas/observable-web": "^1.0.1",
101
101
  "@radix-ui/react-avatar": "^1.1.10",
102
102
  "@radix-ui/react-popover": "^1.1.15",
@@ -1,19 +0,0 @@
1
- /**
2
- * Inject minimal __REACT_DEVTOOLS_GLOBAL_HOOK__ before React loads.
3
- * React checks for this hook during module initialization and registers its
4
- * renderer via hook.inject(). This gives us access to renderer.overrideProps()
5
- * for live component prop modification in the inspector.
6
- *
7
- * Must execute before React's module-level code runs.
8
- *
9
- * When react-refresh-runtime runs first (as an rspack runtime module),
10
- * it may create __REACT_DEVTOOLS_GLOBAL_HOOK__ with an inject() that
11
- * doesn't populate the renderers Map. We patch the existing hook to
12
- * ensure renderers are always tracked.
13
- */
14
- export {};
15
- declare global {
16
- interface Window {
17
- __REACT_DEVTOOLS_GLOBAL_HOOK__?: any;
18
- }
19
- }
@@ -1,20 +0,0 @@
1
- if ('undefined' != typeof window) if (window.__REACT_DEVTOOLS_GLOBAL_HOOK__) {
2
- const hook = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
3
- if (!(hook.renderers instanceof Map)) hook.renderers = new Map();
4
- const originalInject = 'function' == typeof hook.inject ? hook.inject.bind(hook) : null;
5
- hook.inject = function(renderer) {
6
- const id = originalInject ? originalInject(renderer) : hook.renderers.size + 1;
7
- if (null != id && !hook.renderers.has(id)) hook.renderers.set(id, renderer);
8
- return id;
9
- };
10
- } else window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = {
11
- renderers: new Map(),
12
- supportsFiber: true,
13
- inject (renderer) {
14
- const id = this.renderers.size + 1;
15
- this.renderers.set(id, renderer);
16
- return id;
17
- },
18
- onCommitFiberRoot () {},
19
- onCommitFiberUnmount () {}
20
- };