@lark-apaas/miaoda-core 0.1.0-alpha.13 → 0.1.0-alpha.15

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.
Files changed (67) hide show
  1. package/lib/apis/dataloom.d.ts +1 -1
  2. package/lib/apis/dataloom.js +2 -2
  3. package/lib/apis/hooks/useAppInfo.d.ts +1 -0
  4. package/lib/apis/hooks/useAppInfo.js +1 -0
  5. package/lib/apis/utils/registerChinaMap.js +34 -34
  6. package/lib/components/AppContainer/IframeBridge.js +62 -96
  7. package/lib/components/AppContainer/PageHoc.js +1 -1
  8. package/lib/components/AppContainer/childApi.d.ts +5 -0
  9. package/lib/components/AppContainer/childApi.js +20 -0
  10. package/lib/components/AppContainer/index.js +1 -1
  11. package/lib/components/ErrorRender/index.js +4 -4
  12. package/lib/components/NotFoundRender/index.js +3 -3
  13. package/lib/components/TopNav/BottomNav.js +1 -1
  14. package/lib/components/TopNav/TitleBar.js +9 -6
  15. package/lib/components/TopNav/TopNav.js +3 -3
  16. package/lib/components/User/UserDisplay.d.ts +1 -1
  17. package/lib/components/User/UserProfile/UserProfileUI.js +4 -4
  18. package/lib/components/User/UserProfile/utils.js +1 -1
  19. package/lib/components/User/UserSelect.js +3 -2
  20. package/lib/components/User/UserWithAvatar.js +1 -1
  21. package/lib/components/Welcome/index.js +3 -3
  22. package/lib/components/common/LogoInfo.js +3 -3
  23. package/lib/components/common/NavItem.js +1 -1
  24. package/lib/components/common/UserAvatarMenu.js +1 -1
  25. package/lib/components/theme/ThemeProvider.d.ts +2 -2
  26. package/lib/components/theme/ThemeProvider.js +3 -3
  27. package/lib/components/theme/constants.d.ts +1 -1
  28. package/lib/components/theme/constants.js +5 -4
  29. package/lib/components/theme/ui-config.d.ts +1 -49
  30. package/lib/components/theme/ui-config.js +1 -757
  31. package/lib/components/theme/util.d.ts +3 -3
  32. package/lib/components/theme/util.js +4 -4
  33. package/lib/hooks/index.d.ts +1 -1
  34. package/lib/hooks/index.js +1 -1
  35. package/lib/hooks/{useCurrentAppInfo.d.ts → useAppInfo.d.ts} +1 -1
  36. package/lib/hooks/{useCurrentAppInfo.js → useAppInfo.js} +6 -5
  37. package/lib/hooks/useCurrentUserProfile.js +34 -2
  38. package/lib/hooks/useLogout.js +16 -2
  39. package/lib/hooks/useTheme.js +1 -1
  40. package/lib/index.css +1 -0
  41. package/lib/inspector.dev.css +10 -0
  42. package/lib/integrations/dataloom.d.ts +2 -1
  43. package/lib/integrations/dataloom.js +22 -8
  44. package/lib/integrations/generateImage.js +15 -0
  45. package/lib/integrations/generateTextStream.d.ts +0 -5
  46. package/lib/integrations/generateTextStream.js +28 -13
  47. package/lib/integrations/getAppInfo.d.ts +1 -1
  48. package/lib/integrations/getAppInfo.js +12 -2
  49. package/lib/tailwind-theme.css +1 -101
  50. package/lib/theme-layer.css +3 -0
  51. package/lib/types/common.d.ts +0 -7
  52. package/lib/types/iframe-events.d.ts +9 -1
  53. package/lib/types/index.d.ts +2 -0
  54. package/lib/utils/copyToClipboard.js +2 -2
  55. package/lib/utils/getAppId.d.ts +1 -6
  56. package/lib/utils/getAppId.js +4 -2
  57. package/lib/utils/getCsrfToken.d.ts +5 -0
  58. package/lib/utils/getCsrfToken.js +10 -0
  59. package/lib/utils/getInitialInfo.d.ts +20 -0
  60. package/lib/utils/getInitialInfo.js +32 -0
  61. package/lib/utils/getParentOrigin.js +2 -2
  62. package/lib/utils/getUserProfile.js +7 -1
  63. package/lib/utils/utils.d.ts +2 -0
  64. package/lib/utils/utils.js +4 -1
  65. package/package.json +22 -20
  66. package/lib/apis/hooks/useCurrentAppInfo.d.ts +0 -1
  67. package/lib/apis/hooks/useCurrentAppInfo.js +0 -1
@@ -3,13 +3,13 @@ import { useRef, useState } from "react";
3
3
  import { Menu, X } from "lucide-react";
4
4
  import { Link } from "react-router-dom";
5
5
  import { clsxWithTw } from "../../utils/utils.js";
6
- import { useCurrentAppInfo } from "../../hooks/useCurrentAppInfo.js";
6
+ import { useAppInfo } from "../../hooks/useAppInfo.js";
7
7
  import { useCurrentUserProfile } from "../../hooks/useCurrentUserProfile.js";
8
8
  import { DropdownThemeClass, NavMenu, TopHeaderThemeClass, UserAvatarMenu } from "../common/index.js";
9
9
  function TopNav({ navList = [], align = 'left', className, activeClassName }) {
10
10
  const [isMenuOpen, setIsMenuOpen] = useState(false);
11
11
  const navRef = useRef(null);
12
- const { appName, appLogo } = useCurrentAppInfo();
12
+ const { appName, appLogo } = useAppInfo();
13
13
  const { avatar: userAvatar } = useCurrentUserProfile();
14
14
  return /*#__PURE__*/ jsxs("header", {
15
15
  ref: navRef,
@@ -34,7 +34,7 @@ function TopNav({ navList = [], align = 'left', className, activeClassName }) {
34
34
  /*#__PURE__*/ jsx("span", {
35
35
  className: "max-w-[240px] font-medium w-full truncate",
36
36
  title: appName,
37
- children: appName || '新应用'
37
+ children: appName || "\u65B0\u5E94\u7528"
38
38
  })
39
39
  ]
40
40
  })
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import type { IUserProfile } from '../../apis/udt-types';
3
3
  export interface UserDisplayProps {
4
4
  users: IUserProfile[];
5
- size: 'small' | 'medium' | 'large';
5
+ size?: 'small' | 'medium' | 'large';
6
6
  className?: string;
7
7
  style?: React.CSSProperties;
8
8
  }
@@ -41,7 +41,7 @@ function UserProfileUI({ user }) {
41
41
  style: {
42
42
  marginRight: 0
43
43
  },
44
- children: "暂停使用"
44
+ children: "\u6682\u505C\u4F7F\u7528"
45
45
  })
46
46
  ]
47
47
  }),
@@ -65,7 +65,7 @@ function UserProfileUI({ user }) {
65
65
  href: getChatAppLink(user.feishu_open_id),
66
66
  target: "_blank",
67
67
  rel: "noopener noreferrer",
68
- children: "消息"
68
+ children: "\u6D88\u606F"
69
69
  })
70
70
  }) : null
71
71
  ]
@@ -78,7 +78,7 @@ function UserProfileUI({ user }) {
78
78
  children: [
79
79
  /*#__PURE__*/ jsx("span", {
80
80
  className: "text-sm text-[#646A73] min-w-[74px]",
81
- children: "部门"
81
+ children: "\u90E8\u95E8"
82
82
  }),
83
83
  /*#__PURE__*/ jsx("span", {
84
84
  className: clsxWithTw('text-sm text-[#1F2329] flex-1 break-all', {
@@ -93,7 +93,7 @@ function UserProfileUI({ user }) {
93
93
  children: [
94
94
  /*#__PURE__*/ jsx("span", {
95
95
  className: "text-sm text-[#646A73] min-w-[74px]",
96
- children: "邮箱"
96
+ children: "\u90AE\u7BB1"
97
97
  }),
98
98
  user.email ? /*#__PURE__*/ jsx("a", {
99
99
  href: `mailto:${user.email}`,
@@ -16,7 +16,7 @@ const formatI18nProfile = (profile)=>({
16
16
  });
17
17
  const getChatAppLink = (openId)=>`https://applink.feishu.cn/client/chat/open?openId=${openId}`;
18
18
  const INVALID_USER = {
19
- name: '无效人员',
19
+ name: "\u65E0\u6548\u4EBA\u5458",
20
20
  avatar: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp/miao/no-person.svg',
21
21
  email: '',
22
22
  department: '',
@@ -3,7 +3,7 @@ import { useMemo, useRef, useState } from "react";
3
3
  import { Avatar, Select, Spin } from "antd";
4
4
  import { LoaderCircle } from "lucide-react";
5
5
  import { debounce } from "lodash";
6
- import { dataloom } from "../../integrations/dataloom.js";
6
+ import { getDataloom } from "../../integrations/dataloom.js";
7
7
  import "./UserSelect.css";
8
8
  import { UserWithAvatar } from "./UserWithAvatar.js";
9
9
  const mapValueToOptions = (value)=>{
@@ -57,6 +57,7 @@ const UserSelect = ({ mode = 'single', defaultValue, value, onChange, placeholde
57
57
  const fetchRef = useRef(0);
58
58
  const fetchUsers = async (search)=>{
59
59
  try {
60
+ const dataloom = await getDataloom();
60
61
  const { data } = await dataloom.service.user.search({
61
62
  name: search,
62
63
  pageSize: 20
@@ -140,7 +141,7 @@ const UserSelect = ({ mode = 'single', defaultValue, value, onChange, placeholde
140
141
  })
141
142
  }) : /*#__PURE__*/ jsx("span", {
142
143
  className: "py-[1px] px-1 text-[#8F959E]",
143
- children: "无结果,建议更换搜索词"
144
+ children: "\u65E0\u7ED3\u679C\uFF0C\u5EFA\u8BAE\u66F4\u6362\u641C\u7D22\u8BCD"
144
145
  }),
145
146
  optionRender: optionRender,
146
147
  options: options,
@@ -14,7 +14,7 @@ const textVariantMap = {
14
14
  };
15
15
  function UserWithAvatar({ data, size = 'medium', mode = 'tag', className }) {
16
16
  const { avatar, name } = data;
17
- const displayName = name || '无效人员';
17
+ const displayName = name || "\u65E0\u6548\u4EBA\u5458";
18
18
  return /*#__PURE__*/ jsxs("div", {
19
19
  className: clsxWithTw('flex items-center gap-1 rounded-full', {
20
20
  'bg-[rgba(31,35,41,0.1)]': 'tag' === mode,
@@ -8,15 +8,15 @@ const Welcome = ()=>/*#__PURE__*/ jsxs("div", {
8
8
  children: [
9
9
  /*#__PURE__*/ jsx("div", {
10
10
  className: "text-2xl font-bold mb-3",
11
- children: "欢迎使用妙搭 \uD83D\uDC4B"
11
+ children: "\u6B22\u8FCE\u4F7F\u7528\u5999\u642D \uD83D\uDC4B"
12
12
  }),
13
13
  /*#__PURE__*/ jsx("div", {
14
14
  className: "text-[#646A73] text-sm",
15
- children: "1. 随时发送消息,开始构建你的专属应用"
15
+ children: "1. \u968F\u65F6\u53D1\u9001\u6D88\u606F\uFF0C\u5F00\u59CB\u6784\u5EFA\u4F60\u7684\u4E13\u5C5E\u5E94\u7528"
16
16
  }),
17
17
  /*#__PURE__*/ jsx("div", {
18
18
  className: "text-[#646A73] text-sm",
19
- children: "2. 无需担心代码实现,妙搭帮你一一解决"
19
+ children: "2. \u65E0\u9700\u62C5\u5FC3\u4EE3\u7801\u5B9E\u73B0\uFF0C\u5999\u642D\u5E2E\u4F60\u4E00\u4E00\u89E3\u51B3"
20
20
  })
21
21
  ]
22
22
  }),
@@ -1,10 +1,10 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import "react";
3
3
  import { Link } from "react-router-dom";
4
- import { useCurrentAppInfo } from "../../hooks/useCurrentAppInfo.js";
4
+ import { useAppInfo } from "../../hooks/useAppInfo.js";
5
5
  import { clsxWithTw } from "../../utils/utils.js";
6
6
  function LogoInfo({ className, logoClassName }) {
7
- const { name, avatar } = useCurrentAppInfo();
7
+ const { name, avatar } = useAppInfo();
8
8
  return /*#__PURE__*/ jsx("div", {
9
9
  className: clsxWithTw('overflow-hidden text-ellipsis whitespace-nowrap', className),
10
10
  children: /*#__PURE__*/ jsxs(Link, {
@@ -19,7 +19,7 @@ function LogoInfo({ className, logoClassName }) {
19
19
  /*#__PURE__*/ jsxs("span", {
20
20
  className: "w-full truncate",
21
21
  children: [
22
- name || '新应用',
22
+ name || "\u65B0\u5E94\u7528",
23
23
  " "
24
24
  ]
25
25
  })
@@ -80,7 +80,7 @@ const NavItem = /*#__PURE__*/ react.forwardRef((props, ref)=>{
80
80
  });
81
81
  });
82
82
  NavItem.displayName = 'NavItem';
83
- const MoreNavItem = ({ expandedNavItemsPath, onClick, isExpanded, name = '更多', ...restProps })=>{
83
+ const MoreNavItem = ({ expandedNavItemsPath, onClick, isExpanded, name = "\u66F4\u591A", ...restProps })=>{
84
84
  const { pathname } = useLocation();
85
85
  const isActive = useMemo(()=>{
86
86
  const matched = expandedNavItemsPath.some((path)=>{
@@ -36,7 +36,7 @@ function UserAvatarMenu({ className }) {
36
36
  children: [
37
37
  /*#__PURE__*/ jsx(LogOut, {}),
38
38
  /*#__PURE__*/ jsx("span", {
39
- children: "退出登录"
39
+ children: "\u9000\u51FA\u767B\u5F55"
40
40
  })
41
41
  ]
42
42
  })
@@ -1,10 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import { type ReactNode } from 'react';
3
3
  import type { ITheme } from '../../types';
4
- import { IThemeMeta } from './util';
4
+ import { IThemeTokenMeta } from './util';
5
5
  export interface IBaseThemeProviderProps {
6
6
  defaultTheme?: ITheme;
7
- themeMeta?: Partial<IThemeMeta>;
7
+ themeMeta?: Partial<IThemeTokenMeta>;
8
8
  }
9
9
  interface ThemeProviderProps extends IBaseThemeProviderProps {
10
10
  children: ReactNode;
@@ -22,13 +22,13 @@ function ThemeProvider({ children, defaultTheme = 'light', themeMeta = {}, enabl
22
22
  useEffect(()=>{
23
23
  const root = window.document.documentElement;
24
24
  if (void 0 !== themeMeta.spacing) {
25
- const { rem } = findValueByPixel(`${themeMeta.spacing}`, themeMetaOptions.themeSpaces) || {
25
+ const { rem } = findValueByPixel(themeMetaOptions.themeSpaces, themeMeta.spacing) || {
26
26
  rem: '0.25'
27
27
  };
28
28
  root.style.setProperty('--spacing', `${rem}rem`);
29
29
  }
30
30
  if (void 0 !== themeMeta.borderRadius) {
31
- const { rem } = findValueByPixel(`${themeMeta.borderRadius}`, themeMetaOptions.themeRadius) || {
31
+ const { rem } = findValueByPixel(themeMetaOptions.themeRadius, themeMeta.borderRadius) || {
32
32
  rem: '0.625'
33
33
  };
34
34
  root.style.setProperty('--radius', `${rem}rem`);
@@ -44,7 +44,7 @@ function ThemeProvider({ children, defaultTheme = 'light', themeMeta = {}, enabl
44
44
  }
45
45
  };
46
46
  const antdTheme = useMemo(()=>{
47
- const res = findValueByPixel(`${themeMeta.spacing}`, themeMetaOptions.themeSpaces) || {
47
+ const res = findValueByPixel(themeMetaOptions.themeSpaces, themeMeta.spacing) || {
48
48
  pixel: '36',
49
49
  rem: '0.25',
50
50
  size: {
@@ -41,7 +41,7 @@ type ThemeColorTokenMap = {
41
41
  };
42
42
  export declare const themeColorTokenMap: ThemeColorTokenMap;
43
43
  export declare function getKeyByColor(colorValue: string, theme: keyof ThemeColorTokenMap): string;
44
- export declare function findValueByPixel(pixelValue: string, themeSpaces: typeof themeMetaOptions.themeSpaces | typeof themeMetaOptions.themeRadius): {
44
+ export declare function findValueByPixel(themeSpaces: typeof themeMetaOptions.themeSpaces | typeof themeMetaOptions.themeRadius, pixelValue?: string | number): {
45
45
  pixel: string;
46
46
  rem: string;
47
47
  };
@@ -1,6 +1,6 @@
1
1
  const themeMetaOptions = {
2
2
  themeColors: {
3
- title: '主题色',
3
+ title: "\u4E3B\u9898\u8272",
4
4
  options: [
5
5
  {
6
6
  value: '--blue-700',
@@ -33,7 +33,7 @@ const themeMetaOptions = {
33
33
  ]
34
34
  },
35
35
  themeRadius: {
36
- title: '圆角',
36
+ title: "\u5706\u89D2",
37
37
  options: [
38
38
  {
39
39
  value: {
@@ -70,7 +70,7 @@ const themeMetaOptions = {
70
70
  ]
71
71
  },
72
72
  themeSpaces: {
73
- title: '间距',
73
+ title: "\u95F4\u8DDD",
74
74
  options: [
75
75
  {
76
76
  value: {
@@ -550,7 +550,8 @@ function getKeyByColor(colorValue, theme) {
550
550
  const colorMap = themeColorTokenMap[theme];
551
551
  return Object.keys(colorMap).find((key)=>colorMap[key] === colorValue) || '';
552
552
  }
553
- function findValueByPixel(pixelValue, themeSpaces) {
553
+ function findValueByPixel(themeSpaces, pixelValue) {
554
+ if (!pixelValue) return;
554
555
  return themeSpaces.options.find((option)=>option.value.pixel === pixelValue)?.value;
555
556
  }
556
557
  export { findValueByPixel, getKeyByColor, themeColorTokenMap, themeMetaOptions, themeTailwindRadius };
@@ -1,49 +1 @@
1
- export interface SelectOption {
2
- label: string;
3
- value: string;
4
- rawValue: string;
5
- }
6
- export interface SelectUIConfig {
7
- type: 'select';
8
- options: SelectOption[];
9
- }
10
- export interface SpacingUIConfig {
11
- type: 'spacing';
12
- options: SelectOption[];
13
- }
14
- interface Color {
15
- label: string;
16
- value: string;
17
- type?: 'tailwind' | 'style';
18
- rawValue?: string;
19
- }
20
- export interface ColorPickerUIConfig {
21
- type: 'color-picker';
22
- recommendColors: {
23
- title: string;
24
- options: Color[];
25
- }[];
26
- }
27
- export interface IconPickerUIConfig {
28
- type: 'icon-picker';
29
- }
30
- export type UIComponentConfig = SelectUIConfig | ColorPickerUIConfig | IconPickerUIConfig | SpacingUIConfig;
31
- export interface InspectorUIConfig {
32
- version: string;
33
- common: {
34
- fontSize: UIComponentConfig;
35
- fontWeight: UIComponentConfig;
36
- borderRadius: UIComponentConfig;
37
- borderWidth: UIComponentConfig;
38
- textAlign: UIComponentConfig;
39
- padding: UIComponentConfig;
40
- margin: UIComponentConfig;
41
- color: UIComponentConfig;
42
- borderColor: UIComponentConfig;
43
- backgroundColor: UIComponentConfig;
44
- };
45
- components?: Record<string, Record<string, UIComponentConfig>>;
46
- tokens: Record<string, string>;
47
- }
48
- export declare const defaultUIConfig: InspectorUIConfig;
49
- export {};
1
+ export { defaultUIConfig, type UIComponentConfig, } from '@lark-apaas/miaoda-inspector';