@lark-apaas/miaoda-core 0.1.0-alpha.12 → 0.1.0-alpha.14

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 (36) hide show
  1. package/lib/apis/hooks/useAppInfo.d.ts +1 -0
  2. package/lib/apis/hooks/useAppInfo.js +1 -0
  3. package/lib/components/AppContainer/index.js +1 -1
  4. package/lib/components/TopNav/TitleBar.js +5 -2
  5. package/lib/components/TopNav/TopNav.js +2 -2
  6. package/lib/components/User/UserDisplay.d.ts +1 -1
  7. package/lib/components/common/LogoInfo.js +2 -2
  8. package/lib/components/theme/ThemeProvider.d.ts +2 -2
  9. package/lib/components/theme/ThemeProvider.js +3 -3
  10. package/lib/components/theme/constants.d.ts +1 -1
  11. package/lib/components/theme/constants.js +2 -1
  12. package/lib/components/theme/ui-config.d.ts +1 -49
  13. package/lib/components/theme/ui-config.js +1 -757
  14. package/lib/components/theme/util.d.ts +3 -3
  15. package/lib/components/theme/util.js +2 -2
  16. package/lib/hooks/index.d.ts +1 -1
  17. package/lib/hooks/index.js +1 -1
  18. package/lib/hooks/{useCurrentAppInfo.d.ts → useAppInfo.d.ts} +1 -1
  19. package/lib/hooks/{useCurrentAppInfo.js → useAppInfo.js} +2 -2
  20. package/lib/hooks/useCurrentUserProfile.js +31 -2
  21. package/lib/hooks/useLogout.js +12 -0
  22. package/lib/index.css +1 -0
  23. package/lib/inspector.dev.css +10 -0
  24. package/lib/integrations/dataloom.js +11 -2
  25. package/lib/integrations/generateImage.js +14 -0
  26. package/lib/integrations/generateTextStream.js +23 -9
  27. package/lib/tailwind-theme.css +1 -101
  28. package/lib/theme-layer.css +3 -0
  29. package/lib/utils/getAppId.d.ts +1 -1
  30. package/lib/utils/getAppId.js +4 -2
  31. package/lib/utils/getCsrfToken.d.ts +5 -0
  32. package/lib/utils/getCsrfToken.js +10 -0
  33. package/lib/utils/getUserProfile.js +6 -1
  34. package/package.json +4 -3
  35. package/lib/apis/hooks/useCurrentAppInfo.d.ts +0 -1
  36. package/lib/apis/hooks/useCurrentAppInfo.js +0 -1
@@ -0,0 +1 @@
1
+ export * from '../../hooks/useAppInfo';
@@ -0,0 +1 @@
1
+ export * from "../../hooks/useAppInfo.js";
@@ -13,7 +13,7 @@ registerDayjsPlugins();
13
13
  const isMiaodaPreview = window.IS_MIAODA_PREVIEW;
14
14
  const App = (props)=>{
15
15
  const { themeMeta = {} } = props;
16
- const { rem } = findValueByPixel(`${themeMeta.borderRadius}`, themeMetaOptions.themeRadius) || {
16
+ const { rem } = findValueByPixel(themeMetaOptions.themeRadius, themeMeta.borderRadius) || {
17
17
  rem: '0.625'
18
18
  };
19
19
  const radiusToken = generateTailwindRadiusToken(Number(rem));
@@ -3,7 +3,7 @@ import { useMemo, useState } from "react";
3
3
  import { Link, matchPath, useLocation } from "react-router-dom";
4
4
  import { LogOut, MoreHorizontal, X } from "lucide-react";
5
5
  import { clsxWithTw } from "../../utils/utils.js";
6
- import { useCurrentAppInfo, useCurrentUserProfile, useLogout } from "../../hooks/index.js";
6
+ import { useAppInfo, useCurrentUserProfile, useLogout } from "../../hooks/index.js";
7
7
  import { DropdownThemeClass, MaskThemeClass, TopHeaderThemeClass } from "../common/index.js";
8
8
  const TitleBar = ({ navList, className })=>{
9
9
  const { pathname } = useLocation();
@@ -17,7 +17,7 @@ const TitleBar = ({ navList, className })=>{
17
17
  navList,
18
18
  pathname
19
19
  ]);
20
- const { appName, appLogo } = useCurrentAppInfo();
20
+ const { appName, appLogo } = useAppInfo();
21
21
  const { name: userName, avatar: userAvatar } = useCurrentUserProfile();
22
22
  const { handlerLogout } = useLogout();
23
23
  const [isMenuOpen, setIsMenuOpen] = useState(false);
@@ -90,6 +90,9 @@ const TitleBar = ({ navList, className })=>{
90
90
  children: userName
91
91
  }),
92
92
  /*#__PURE__*/ jsx("img", {
93
+ onClick: ()=>{
94
+ if (window._IS_Spark_RUNTIME) location.href = '/suda/user?brand=1';
95
+ },
93
96
  src: userAvatar,
94
97
  alt: "avatar",
95
98
  className: "w-8 h-8 rounded-full ml-2"
@@ -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,
@@ -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
  }
@@ -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, {
@@ -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
  };
@@ -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';