@lobehub/ui 6.0.0-beta.5 → 6.0.0-beta.7

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 (172) hide show
  1. package/es/ActionIcon/style.mjs +1 -1
  2. package/es/ActionIcon/style.mjs.map +1 -1
  3. package/es/ColorSwatches/ColorSwatches.mjs +17 -22
  4. package/es/ColorSwatches/ColorSwatches.mjs.map +1 -1
  5. package/es/ColorSwatches/CustomPicker.mjs +101 -0
  6. package/es/ColorSwatches/CustomPicker.mjs.map +1 -0
  7. package/es/ColorSwatches/index.d.mts +2 -2
  8. package/es/ColorSwatches/marker.stylex.mjs +9 -0
  9. package/es/ColorSwatches/marker.stylex.mjs.map +1 -0
  10. package/es/ColorSwatches/style.mjs +36 -0
  11. package/es/ColorSwatches/style.mjs.map +1 -1
  12. package/es/ColorSwatches/type.d.mts +11 -2
  13. package/es/EditableText/EditableText.mjs +1 -1
  14. package/es/Grid/style.mjs +1 -1
  15. package/es/Grid/style.mjs.map +1 -1
  16. package/es/Image/type.d.mts +1 -0
  17. package/es/Image/viewer/ImageViewer.mjs +1 -0
  18. package/es/Image/viewer/ImageViewer.mjs.map +1 -1
  19. package/es/Image/viewer/Toolbar.mjs +19 -6
  20. package/es/Image/viewer/Toolbar.mjs.map +1 -1
  21. package/es/Image/viewer/ViewerChrome.mjs.map +1 -1
  22. package/es/Input/style.mjs +3 -3
  23. package/es/Input/style.mjs.map +1 -1
  24. package/es/Text/style.d.mts +3 -3
  25. package/es/awesome/Grainient/Grainient.d.mts +11 -0
  26. package/es/awesome/Grainient/Grainient.mjs +314 -0
  27. package/es/awesome/Grainient/Grainient.mjs.map +1 -0
  28. package/es/awesome/Grainient/index.d.mts +3 -0
  29. package/es/awesome/Grainient/style.mjs +23 -0
  30. package/es/awesome/Grainient/style.mjs.map +1 -0
  31. package/es/awesome/Grainient/type.d.mts +121 -0
  32. package/es/awesome/index.d.mts +4 -1
  33. package/es/awesome/index.mjs +2 -1
  34. package/es/dashboard/AuthLayout/Aside.d.mts +10 -0
  35. package/es/dashboard/AuthLayout/Aside.mjs +31 -0
  36. package/es/dashboard/AuthLayout/Aside.mjs.map +1 -0
  37. package/es/dashboard/AuthLayout/AuthLayout.d.mts +3 -1
  38. package/es/dashboard/AuthLayout/AuthLayout.mjs +93 -37
  39. package/es/dashboard/AuthLayout/AuthLayout.mjs.map +1 -1
  40. package/es/dashboard/AuthLayout/index.d.mts +3 -2
  41. package/es/dashboard/AuthLayout/style.mjs +98 -1
  42. package/es/dashboard/AuthLayout/style.mjs.map +1 -1
  43. package/es/dashboard/AuthLayout/type.d.mts +38 -2
  44. package/es/dashboard/AuthTools/AuthLocaleSwitch.d.mts +10 -0
  45. package/es/dashboard/AuthTools/AuthLocaleSwitch.mjs +33 -0
  46. package/es/dashboard/AuthTools/AuthLocaleSwitch.mjs.map +1 -0
  47. package/es/dashboard/AuthTools/AuthThemeSwitch.d.mts +10 -0
  48. package/es/dashboard/AuthTools/AuthThemeSwitch.mjs +59 -0
  49. package/es/dashboard/AuthTools/AuthThemeSwitch.mjs.map +1 -0
  50. package/es/dashboard/AuthTools/index.d.mts +4 -0
  51. package/es/dashboard/AuthTools/style.mjs +27 -0
  52. package/es/dashboard/AuthTools/style.mjs.map +1 -0
  53. package/es/dashboard/AuthTools/type.d.mts +29 -0
  54. package/es/dashboard/ChartGrid/ChartGrid.d.mts +10 -0
  55. package/es/dashboard/ChartGrid/ChartGrid.mjs +19 -0
  56. package/es/dashboard/ChartGrid/ChartGrid.mjs.map +1 -0
  57. package/es/dashboard/ChartGrid/index.d.mts +3 -0
  58. package/es/dashboard/ChartGrid/style.mjs +18 -0
  59. package/es/dashboard/ChartGrid/style.mjs.map +1 -0
  60. package/es/dashboard/ChartGrid/type.d.mts +8 -0
  61. package/es/dashboard/ConsoleNav/Skeleton.d.mts +15 -0
  62. package/es/dashboard/ConsoleNav/Skeleton.mjs +82 -0
  63. package/es/dashboard/ConsoleNav/Skeleton.mjs.map +1 -0
  64. package/es/dashboard/ConsoleNav/index.d.mts +3 -2
  65. package/es/dashboard/ConsoleNav/style.mjs +18 -0
  66. package/es/dashboard/ConsoleNav/style.mjs.map +1 -1
  67. package/es/dashboard/ConsoleNav/type.d.mts +13 -0
  68. package/es/dashboard/ConsoleShell/ConsoleShell.d.mts +1 -1
  69. package/es/dashboard/ConsoleShell/ConsoleShell.mjs +26 -6
  70. package/es/dashboard/ConsoleShell/ConsoleShell.mjs.map +1 -1
  71. package/es/dashboard/ConsoleShell/style.mjs +10 -0
  72. package/es/dashboard/ConsoleShell/style.mjs.map +1 -1
  73. package/es/dashboard/ConsoleShell/type.d.mts +11 -0
  74. package/es/dashboard/FilterSidebar/FilterSidebar.mjs +18 -17
  75. package/es/dashboard/FilterSidebar/FilterSidebar.mjs.map +1 -1
  76. package/es/dashboard/FilterStrip/FilterStrip.d.mts +11 -0
  77. package/es/dashboard/FilterStrip/FilterStrip.mjs +55 -0
  78. package/es/dashboard/FilterStrip/FilterStrip.mjs.map +1 -0
  79. package/es/dashboard/FilterStrip/index.d.mts +3 -0
  80. package/es/dashboard/FilterStrip/style.mjs +78 -0
  81. package/es/dashboard/FilterStrip/style.mjs.map +1 -0
  82. package/es/dashboard/FilterStrip/type.d.mts +25 -0
  83. package/es/dashboard/LabelWithKey/LabelWithKey.d.mts +10 -0
  84. package/es/dashboard/LabelWithKey/LabelWithKey.mjs +18 -0
  85. package/es/dashboard/LabelWithKey/LabelWithKey.mjs.map +1 -0
  86. package/es/dashboard/LabelWithKey/index.d.mts +3 -0
  87. package/es/dashboard/LabelWithKey/type.d.mts +11 -0
  88. package/es/dashboard/MetricStrip/MetricCell.mjs +81 -0
  89. package/es/dashboard/MetricStrip/MetricCell.mjs.map +1 -0
  90. package/es/dashboard/MetricStrip/MetricStrip.d.mts +13 -0
  91. package/es/dashboard/MetricStrip/MetricStrip.mjs +47 -0
  92. package/es/dashboard/MetricStrip/MetricStrip.mjs.map +1 -0
  93. package/es/dashboard/MetricStrip/index.d.mts +3 -0
  94. package/es/dashboard/MetricStrip/style.mjs +156 -0
  95. package/es/dashboard/MetricStrip/style.mjs.map +1 -0
  96. package/es/dashboard/MetricStrip/type.d.mts +36 -0
  97. package/es/dashboard/PageSkeleton/PageSkeleton.mjs +20 -18
  98. package/es/dashboard/PageSkeleton/PageSkeleton.mjs.map +1 -1
  99. package/es/dashboard/PageSkeleton/style.mjs +1 -1
  100. package/es/dashboard/PageSkeleton/style.mjs.map +1 -1
  101. package/es/dashboard/PageToolbar/PageToolbar.d.mts +10 -0
  102. package/es/dashboard/PageToolbar/PageToolbar.mjs +22 -0
  103. package/es/dashboard/PageToolbar/PageToolbar.mjs.map +1 -0
  104. package/es/dashboard/PageToolbar/index.d.mts +3 -0
  105. package/es/dashboard/PageToolbar/style.mjs +36 -0
  106. package/es/dashboard/PageToolbar/style.mjs.map +1 -0
  107. package/es/dashboard/PageToolbar/type.d.mts +11 -0
  108. package/es/dashboard/PanelSurface/PanelSurface.d.mts +10 -0
  109. package/es/dashboard/PanelSurface/PanelSurface.mjs +40 -0
  110. package/es/dashboard/PanelSurface/PanelSurface.mjs.map +1 -0
  111. package/es/dashboard/PanelSurface/index.d.mts +3 -0
  112. package/es/dashboard/PanelSurface/style.mjs +25 -0
  113. package/es/dashboard/PanelSurface/style.mjs.map +1 -0
  114. package/es/dashboard/PanelSurface/type.d.mts +17 -0
  115. package/es/dashboard/Section/Section.d.mts +10 -0
  116. package/es/dashboard/Section/Section.mjs +81 -0
  117. package/es/dashboard/Section/Section.mjs.map +1 -0
  118. package/es/dashboard/Section/index.d.mts +3 -0
  119. package/es/dashboard/Section/style.mjs +31 -0
  120. package/es/dashboard/Section/style.mjs.map +1 -0
  121. package/es/dashboard/Section/type.d.mts +23 -0
  122. package/es/dashboard/StatCard/StatCard.d.mts +2 -1
  123. package/es/dashboard/StatCard/StatCard.mjs +28 -91
  124. package/es/dashboard/StatCard/StatCard.mjs.map +1 -1
  125. package/es/dashboard/StatCard/type.d.mts +16 -5
  126. package/es/dashboard/Surface/Surface.d.mts +4 -3
  127. package/es/dashboard/Surface/Surface.mjs +91 -8
  128. package/es/dashboard/Surface/Surface.mjs.map +1 -1
  129. package/es/dashboard/Surface/index.d.mts +3 -2
  130. package/es/dashboard/Surface/link.d.mts +16 -0
  131. package/es/dashboard/Surface/link.mjs +40 -0
  132. package/es/dashboard/Surface/link.mjs.map +1 -0
  133. package/es/dashboard/Surface/marker.stylex.mjs +9 -0
  134. package/es/dashboard/Surface/marker.stylex.mjs.map +1 -0
  135. package/es/dashboard/Surface/style.d.mts +2 -0
  136. package/es/dashboard/Surface/style.mjs +155 -14
  137. package/es/dashboard/Surface/style.mjs.map +1 -1
  138. package/es/dashboard/Surface/type.d.mts +29 -1
  139. package/es/dashboard/TableIconActions/TableIconActions.d.mts +17 -0
  140. package/es/dashboard/TableIconActions/TableIconActions.mjs +39 -0
  141. package/es/dashboard/TableIconActions/TableIconActions.mjs.map +1 -0
  142. package/es/dashboard/TableIconActions/index.d.mts +3 -0
  143. package/es/dashboard/TableIconActions/type.d.mts +17 -0
  144. package/es/dashboard/TitleWithTips/TitleWithTips.d.mts +10 -0
  145. package/es/dashboard/TitleWithTips/TitleWithTips.mjs +28 -0
  146. package/es/dashboard/TitleWithTips/TitleWithTips.mjs.map +1 -0
  147. package/es/dashboard/TitleWithTips/index.d.mts +3 -0
  148. package/es/dashboard/TitleWithTips/type.d.mts +10 -0
  149. package/es/dashboard/index.d.mts +38 -4
  150. package/es/dashboard/index.mjs +17 -3
  151. package/es/index.d.mts +3 -2
  152. package/es/index.mjs +5 -4
  153. package/es/style.css +339 -32
  154. package/es/styles/createGlobalStyle.mjs +1 -1
  155. package/es/styles/index.d.mts +3 -2
  156. package/es/styles/index.mjs +5 -4
  157. package/es/styles/theme/createLobeToken.d.mts +3 -2
  158. package/es/styles/theme/createLobeToken.mjs.map +1 -1
  159. package/es/styles/theme/customPrimary.d.mts +7 -0
  160. package/es/styles/theme/customPrimary.mjs +66 -0
  161. package/es/styles/theme/customPrimary.mjs.map +1 -0
  162. package/es/styles/theme/scope.d.mts +4 -3
  163. package/es/styles/theme/scope.mjs +30 -8
  164. package/es/styles/theme/scope.mjs.map +1 -1
  165. package/es/styles/theme/themeCss.d.mts +2 -0
  166. package/es/styles/theme/themeCss.mjs +9 -2
  167. package/es/styles/theme/themeCss.mjs.map +1 -1
  168. package/es/styles/theme/token/primary.mjs +6 -2
  169. package/es/styles/theme/token/primary.mjs.map +1 -1
  170. package/package.json +1 -1
  171. package/es/dashboard/StatCard/style.mjs +0 -105
  172. package/es/dashboard/StatCard/style.mjs.map +0 -1
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { useTheme } from "./theme/scope.mjs";
3
2
  import { css, injectGlobal } from "./css.mjs";
3
+ import { useTheme } from "./theme/scope.mjs";
4
4
  import { useMemo } from "react";
5
5
  //#region src/styles/createGlobalStyle.ts
6
6
  const createGlobalStyle = (template, ...args) => {
@@ -1,9 +1,10 @@
1
1
  import { NeutralColors, NeutralColorsObj, PrimaryColors, PrimaryColorsObj, findCustomThemeName, neutralColors, neutralColorsSwatches, primaryColors, primaryColorsSwatches } from "./customTheme.mjs";
2
+ import { CustomPrimaryColor, LobePrimaryColor, isCustomPrimaryColor } from "./theme/customPrimary.mjs";
2
3
  import { CreateLobeTokenParams, LobeToken, createLobeToken } from "./theme/createLobeToken.mjs";
3
4
  import { LobeAppearance, LobeTheme, LobeThemeScript, LobeThemeScriptProps, LobeThemeState, ResponsiveState, ThemeScope, ThemeScopeProps, setLobeTheme, useResponsive, useTheme, useThemeMode } from "./theme/scope.mjs";
4
5
  import { createGlobalStyle } from "./createGlobalStyle.mjs";
5
6
  import { LobeCssVar, StaticStyleExtract, StaticStyleUtils, createStaticStyles, css, cssVar, cx, extractStaticStyle, injectGlobal, keyframes, responsive } from "./css.mjs";
6
7
  import { staticStylish } from "./theme/customStylishStatic.mjs";
7
8
  import { generateColorNeutralPalette, generateColorPalette } from "./theme/generateColorPalette.mjs";
8
- import { getGlobalCss, getThemeCss } from "./theme/themeCss.mjs";
9
- export { type CreateLobeTokenParams, type LobeAppearance, type LobeCssVar, type LobeTheme, LobeThemeScript, type LobeThemeScriptProps, type LobeThemeState, type LobeToken, NeutralColors, NeutralColorsObj, PrimaryColors, PrimaryColorsObj, type ResponsiveState, type StaticStyleExtract, type StaticStyleUtils, ThemeScope, type ThemeScopeProps, createGlobalStyle, createLobeToken, createStaticStyles, css, cssVar, cx, extractStaticStyle, findCustomThemeName, generateColorNeutralPalette, generateColorPalette, getGlobalCss, getThemeCss, injectGlobal, keyframes, staticStylish as lobeStaticStylish, neutralColors, neutralColorsSwatches, primaryColors, primaryColorsSwatches, responsive, setLobeTheme, useResponsive, useTheme, useThemeMode };
9
+ import { getCustomPrimaryCss, getGlobalCss, getThemeCss } from "./theme/themeCss.mjs";
10
+ export { type CreateLobeTokenParams, type CustomPrimaryColor, type LobeAppearance, type LobeCssVar, type LobePrimaryColor, type LobeTheme, LobeThemeScript, type LobeThemeScriptProps, type LobeThemeState, type LobeToken, NeutralColors, NeutralColorsObj, PrimaryColors, PrimaryColorsObj, type ResponsiveState, type StaticStyleExtract, type StaticStyleUtils, ThemeScope, type ThemeScopeProps, createGlobalStyle, createLobeToken, createStaticStyles, css, cssVar, cx, extractStaticStyle, findCustomThemeName, generateColorNeutralPalette, generateColorPalette, getCustomPrimaryCss, getGlobalCss, getThemeCss, injectGlobal, isCustomPrimaryColor, keyframes, staticStylish as lobeStaticStylish, neutralColors, neutralColorsSwatches, primaryColors, primaryColorsSwatches, responsive, setLobeTheme, useResponsive, useTheme, useThemeMode };
@@ -1,9 +1,10 @@
1
1
  import { generateColorNeutralPalette, generateColorPalette } from "./theme/generateColorPalette.mjs";
2
+ import { findCustomThemeName, neutralColors, neutralColorsSwatches, primaryColors, primaryColorsSwatches } from "./customTheme.mjs";
3
+ import { isCustomPrimaryColor } from "./theme/customPrimary.mjs";
2
4
  import { createLobeToken } from "./theme/createLobeToken.mjs";
3
- import { LobeThemeScript, ThemeScope, setLobeTheme, useResponsive, useTheme, useThemeMode } from "./theme/scope.mjs";
4
5
  import { createStaticStyles, css, cssVar, cx, extractStaticStyle, injectGlobal, keyframes, responsive } from "./css.mjs";
6
+ import { getCustomPrimaryCss, getGlobalCss, getThemeCss } from "./theme/themeCss.mjs";
7
+ import { LobeThemeScript, ThemeScope, setLobeTheme, useResponsive, useTheme, useThemeMode } from "./theme/scope.mjs";
5
8
  import { createGlobalStyle } from "./createGlobalStyle.mjs";
6
- import { findCustomThemeName, neutralColors, neutralColorsSwatches, primaryColors, primaryColorsSwatches } from "./customTheme.mjs";
7
9
  import { staticStylish } from "./theme/customStylishStatic.mjs";
8
- import { getGlobalCss, getThemeCss } from "./theme/themeCss.mjs";
9
- export { LobeThemeScript, ThemeScope, createGlobalStyle, createLobeToken, createStaticStyles, css, cssVar, cx, extractStaticStyle, findCustomThemeName, generateColorNeutralPalette, generateColorPalette, getGlobalCss, getThemeCss, injectGlobal, keyframes, staticStylish as lobeStaticStylish, neutralColors, neutralColorsSwatches, primaryColors, primaryColorsSwatches, responsive, setLobeTheme, useResponsive, useTheme, useThemeMode };
10
+ export { LobeThemeScript, ThemeScope, createGlobalStyle, createLobeToken, createStaticStyles, css, cssVar, cx, extractStaticStyle, findCustomThemeName, generateColorNeutralPalette, generateColorPalette, getCustomPrimaryCss, getGlobalCss, getThemeCss, injectGlobal, isCustomPrimaryColor, keyframes, staticStylish as lobeStaticStylish, neutralColors, neutralColorsSwatches, primaryColors, primaryColorsSwatches, responsive, setLobeTheme, useResponsive, useTheme, useThemeMode };
@@ -1,9 +1,10 @@
1
- import { NeutralColors, PrimaryColors } from "../customTheme.mjs";
1
+ import { NeutralColors } from "../customTheme.mjs";
2
+ import { LobePrimaryColor } from "./customPrimary.mjs";
2
3
  //#region src/styles/theme/createLobeToken.d.ts
3
4
  export interface CreateLobeTokenParams {
4
5
  appearance: 'light' | 'dark';
5
6
  neutralColor?: NeutralColors;
6
- primaryColor?: PrimaryColors;
7
+ primaryColor?: LobePrimaryColor;
7
8
  }
8
9
  export declare const createLobeTokenGroups: ({ appearance, neutralColor, primaryColor }: CreateLobeTokenParams) => {
9
10
  neutral: {
@@ -1 +1 @@
1
- {"version":3,"file":"createLobeToken.mjs","names":[],"sources":["../../../src/styles/theme/createLobeToken.ts"],"sourcesContent":["import type { NeutralColors, PrimaryColors } from '../customTheme';\nimport { createNeutralToken } from './token/neutral';\nimport { createPaletteToken } from './token/palette';\nimport { createPrimaryToken } from './token/primary';\nimport { staticToken } from './token/static';\n\nexport interface CreateLobeTokenParams {\n appearance: 'light' | 'dark';\n neutralColor?: NeutralColors;\n primaryColor?: PrimaryColors;\n}\n\nexport const createLobeTokenGroups = ({\n appearance,\n neutralColor,\n primaryColor,\n}: CreateLobeTokenParams) => {\n const palette = createPaletteToken(appearance);\n\n return {\n neutral: createNeutralToken(appearance, neutralColor, palette),\n palette,\n primary: createPrimaryToken(appearance, primaryColor),\n static: staticToken,\n };\n};\n\nexport type LobeTokenGroups = ReturnType<typeof createLobeTokenGroups>;\n\nexport type LobeToken = LobeTokenGroups['static'] &\n LobeTokenGroups['palette'] &\n LobeTokenGroups['primary'] &\n LobeTokenGroups['neutral'];\n\nexport const createLobeToken = (params: CreateLobeTokenParams): LobeToken => {\n const groups = createLobeTokenGroups(params);\n\n return { ...groups.static, ...groups.palette, ...groups.primary, ...groups.neutral };\n};\n"],"mappings":";;;;;AAYA,MAAa,yBAAyB,EACpC,YACA,cACA,mBAC2B;CAC3B,MAAM,UAAU,mBAAmB,UAAU;CAE7C,OAAO;EACL,SAAS,mBAAmB,YAAY,cAAc,OAAO;EAC7D;EACA,SAAS,mBAAmB,YAAY,YAAY;EACpD,QAAQ;CACV;AACF;AASA,MAAa,mBAAmB,WAA6C;CAC3E,MAAM,SAAS,sBAAsB,MAAM;CAE3C,OAAO;EAAE,GAAG,OAAO;EAAQ,GAAG,OAAO;EAAS,GAAG,OAAO;EAAS,GAAG,OAAO;CAAQ;AACrF"}
1
+ {"version":3,"file":"createLobeToken.mjs","names":[],"sources":["../../../src/styles/theme/createLobeToken.ts"],"sourcesContent":["import type { NeutralColors } from '../customTheme';\nimport type { LobePrimaryColor } from './customPrimary';\nimport { createNeutralToken } from './token/neutral';\nimport { createPaletteToken } from './token/palette';\nimport { createPrimaryToken } from './token/primary';\nimport { staticToken } from './token/static';\n\nexport interface CreateLobeTokenParams {\n appearance: 'light' | 'dark';\n neutralColor?: NeutralColors;\n primaryColor?: LobePrimaryColor;\n}\n\nexport const createLobeTokenGroups = ({\n appearance,\n neutralColor,\n primaryColor,\n}: CreateLobeTokenParams) => {\n const palette = createPaletteToken(appearance);\n\n return {\n neutral: createNeutralToken(appearance, neutralColor, palette),\n palette,\n primary: createPrimaryToken(appearance, primaryColor),\n static: staticToken,\n };\n};\n\nexport type LobeTokenGroups = ReturnType<typeof createLobeTokenGroups>;\n\nexport type LobeToken = LobeTokenGroups['static'] &\n LobeTokenGroups['palette'] &\n LobeTokenGroups['primary'] &\n LobeTokenGroups['neutral'];\n\nexport const createLobeToken = (params: CreateLobeTokenParams): LobeToken => {\n const groups = createLobeTokenGroups(params);\n\n return { ...groups.static, ...groups.palette, ...groups.primary, ...groups.neutral };\n};\n"],"mappings":";;;;;AAaA,MAAa,yBAAyB,EACpC,YACA,cACA,mBAC2B;CAC3B,MAAM,UAAU,mBAAmB,UAAU;CAE7C,OAAO;EACL,SAAS,mBAAmB,YAAY,cAAc,OAAO;EAC7D;EACA,SAAS,mBAAmB,YAAY,YAAY;EACpD,QAAQ;CACV;AACF;AASA,MAAa,mBAAmB,WAA6C;CAC3E,MAAM,SAAS,sBAAsB,MAAM;CAE3C,OAAO;EAAE,GAAG,OAAO;EAAQ,GAAG,OAAO;EAAS,GAAG,OAAO;EAAS,GAAG,OAAO;CAAQ;AACrF"}
@@ -0,0 +1,7 @@
1
+ import { PrimaryColors } from "../customTheme.mjs";
2
+ //#region src/styles/theme/customPrimary.d.ts
3
+ export type CustomPrimaryColor = `#${string}`;
4
+ export type LobePrimaryColor = PrimaryColors | CustomPrimaryColor;
5
+ export declare const isCustomPrimaryColor: (value?: string) => value is CustomPrimaryColor;
6
+ //#endregion
7
+ //# sourceMappingURL=customPrimary.d.mts.map
@@ -0,0 +1,66 @@
1
+ import { colorScales } from "../../color/colors/index.mjs";
2
+ import { primaryColors } from "../customTheme.mjs";
3
+ import chroma from "chroma-js";
4
+ //#region src/styles/theme/customPrimary.ts
5
+ const HEX = /^#[\da-f]{6}$/i;
6
+ const isCustomPrimaryColor = (value) => !!value && HEX.test(value);
7
+ const ANCHOR = 9;
8
+ const ANCHORED_STEPS = /* @__PURE__ */ new Set([
9
+ 7,
10
+ 8,
11
+ 10
12
+ ]);
13
+ const MAX_CHROMA_RATIO = 2;
14
+ const oklch = (color) => {
15
+ const [l, c, h] = chroma(color).oklch();
16
+ return {
17
+ c,
18
+ h: Number.isNaN(h) ? 0 : h,
19
+ l
20
+ };
21
+ };
22
+ const hueDistance = (a, b) => {
23
+ const d = Math.abs(a - b) % 360;
24
+ return d > 180 ? 360 - d : d;
25
+ };
26
+ const nearestPreset = (hue) => Object.keys(primaryColors).reduce((best, name) => hueDistance(oklch(primaryColors[name]).h, hue) < hueDistance(oklch(primaryColors[best]).h, hue) ? name : best);
27
+ const clamp = (value) => Math.min(1, Math.max(0, value));
28
+ const retintSolid = (steps, target, hex) => {
29
+ const anchor = oklch(steps[ANCHOR]);
30
+ const ratio = anchor.c > 0 ? Math.min(target.c / anchor.c, MAX_CHROMA_RATIO) : 0;
31
+ return steps.map((step, i) => {
32
+ if (i === ANCHOR) return hex;
33
+ const { c, l } = oklch(step);
34
+ const lightness = ANCHORED_STEPS.has(i) ? clamp(target.l + l - anchor.l) : l;
35
+ return chroma.oklch(lightness, c * ratio, target.h).hex();
36
+ });
37
+ };
38
+ const retintAlpha = (steps, solid, target) => {
39
+ const anchor = oklch(solid[ANCHOR]);
40
+ const ratio = anchor.c > 0 ? Math.min(target.c / anchor.c, MAX_CHROMA_RATIO) : 0;
41
+ return steps.map((step) => {
42
+ const color = chroma(step);
43
+ const { c, l } = oklch(step);
44
+ return chroma.oklch(l, c * ratio, target.h).alpha(color.alpha()).css();
45
+ });
46
+ };
47
+ const cache = /* @__PURE__ */ new Map();
48
+ const generatePrimaryScale = (color) => {
49
+ const hex = color.toLowerCase();
50
+ const cached = cache.get(hex);
51
+ if (cached) return cached;
52
+ const target = oklch(hex);
53
+ const preset = colorScales[nearestPreset(target.h)];
54
+ const scale = {
55
+ dark: retintSolid(preset.dark, target, hex),
56
+ darkA: retintAlpha(preset.darkA, preset.dark, target),
57
+ light: retintSolid(preset.light, target, hex),
58
+ lightA: retintAlpha(preset.lightA, preset.light, target)
59
+ };
60
+ cache.set(hex, scale);
61
+ return scale;
62
+ };
63
+ //#endregion
64
+ export { generatePrimaryScale, isCustomPrimaryColor };
65
+
66
+ //# sourceMappingURL=customPrimary.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customPrimary.mjs","names":[],"sources":["../../../src/styles/theme/customPrimary.ts"],"sourcesContent":["import chroma from 'chroma-js';\n\nimport { colorScales } from '@/color/colors';\nimport type { ColorScaleItem } from '@/color/types';\n\nimport { type PrimaryColors, primaryColors } from '../customTheme';\n\nexport type CustomPrimaryColor = `#${string}`;\nexport type LobePrimaryColor = PrimaryColors | CustomPrimaryColor;\n\nconst HEX = /^#[\\da-f]{6}$/i;\n\nexport const isCustomPrimaryColor = (value?: string): value is CustomPrimaryColor =>\n !!value && HEX.test(value);\n\nconst ANCHOR = 9;\nconst ANCHORED_STEPS = new Set([7, 8, 10]);\nconst MAX_CHROMA_RATIO = 2;\n\nconst oklch = (color: string) => {\n const [l, c, h] = chroma(color).oklch();\n return { c, h: Number.isNaN(h) ? 0 : h, l };\n};\n\nconst hueDistance = (a: number, b: number) => {\n const d = Math.abs(a - b) % 360;\n return d > 180 ? 360 - d : d;\n};\n\nconst nearestPreset = (hue: number) =>\n (Object.keys(primaryColors) as PrimaryColors[]).reduce((best, name) =>\n hueDistance(oklch(primaryColors[name]).h, hue) < hueDistance(oklch(primaryColors[best]).h, hue)\n ? name\n : best,\n );\n\nconst clamp = (value: number) => Math.min(1, Math.max(0, value));\n\ntype Steps = ColorScaleItem['light'];\n\nconst retintSolid = (steps: Steps, target: ReturnType<typeof oklch>, hex: string): Steps => {\n const anchor = oklch(steps[ANCHOR]);\n const ratio = anchor.c > 0 ? Math.min(target.c / anchor.c, MAX_CHROMA_RATIO) : 0;\n\n return steps.map((step, i) => {\n if (i === ANCHOR) return hex;\n const { c, l } = oklch(step);\n const lightness = ANCHORED_STEPS.has(i) ? clamp(target.l + l - anchor.l) : l;\n return chroma.oklch(lightness, c * ratio, target.h).hex();\n }) as Steps;\n};\n\nconst retintAlpha = (steps: Steps, solid: Steps, target: ReturnType<typeof oklch>): Steps => {\n const anchor = oklch(solid[ANCHOR]);\n const ratio = anchor.c > 0 ? Math.min(target.c / anchor.c, MAX_CHROMA_RATIO) : 0;\n\n return steps.map((step) => {\n const color = chroma(step);\n const { c, l } = oklch(step);\n return chroma\n .oklch(l, c * ratio, target.h)\n .alpha(color.alpha())\n .css();\n }) as Steps;\n};\n\nconst cache = new Map<string, ColorScaleItem>();\n\nexport const generatePrimaryScale = (color: CustomPrimaryColor): ColorScaleItem => {\n const hex = color.toLowerCase();\n const cached = cache.get(hex);\n if (cached) return cached;\n\n const target = oklch(hex);\n const preset = colorScales[nearestPreset(target.h)];\n const scale: ColorScaleItem = {\n dark: retintSolid(preset.dark, target, hex),\n darkA: retintAlpha(preset.darkA, preset.dark, target),\n light: retintSolid(preset.light, target, hex),\n lightA: retintAlpha(preset.lightA, preset.light, target),\n };\n\n cache.set(hex, scale);\n return scale;\n};\n"],"mappings":";;;;AAUA,MAAM,MAAM;AAEZ,MAAa,wBAAwB,UACnC,CAAC,CAAC,SAAS,IAAI,KAAK,KAAK;AAE3B,MAAM,SAAS;AACf,MAAM,iCAAiB,IAAI,IAAI;CAAC;CAAG;CAAG;AAAE,CAAC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AAS;EACzB,MAAM,QAAQ,OAAO,IAAI;EACzB,MAAM,EAAE,GAAG,MAAM,MAAM,IAAI;EAC3B,OAAO,OACJ,MAAM,GAAG,IAAI,OAAO,OAAO,CAAC,CAAC,CAC7B,MAAM,MAAM,MAAM,CAAC,CAAC,CACpB,IAAI;CACT,CAAC;AACH;AAEA,MAAM,wBAAQ,IAAI,IAA4B;AAE9C,MAAa,wBAAwB,UAA8C;CACjF,MAAM,MAAM,MAAM,YAAY;CAC9B,MAAM,SAAS,MAAM,IAAI,GAAG;CAC5B,IAAI,QAAQ,OAAO;CAEnB,MAAM,SAAS,MAAM,GAAG;CACxB,MAAM,SAAS,YAAY,cAAc,OAAO,CAAC;CACjD,MAAM,QAAwB;EAC5B,MAAM,YAAY,OAAO,MAAM,QAAQ,GAAG;EAC1C,OAAO,YAAY,OAAO,OAAO,OAAO,MAAM,MAAM;EACpD,OAAO,YAAY,OAAO,OAAO,QAAQ,GAAG;EAC5C,QAAQ,YAAY,OAAO,QAAQ,OAAO,OAAO,MAAM;CACzD;CAEA,MAAM,IAAI,KAAK,KAAK;CACpB,OAAO;AACT"}
@@ -1,4 +1,5 @@
1
- import { NeutralColors, PrimaryColors } from "../customTheme.mjs";
1
+ import { NeutralColors } from "../customTheme.mjs";
2
+ import { LobePrimaryColor } from "./customPrimary.mjs";
2
3
  import { LobeToken } from "./createLobeToken.mjs";
3
4
  import { CSSProperties, ReactNode } from "react";
4
5
  //#region src/styles/theme/scope.d.ts
@@ -6,7 +7,7 @@ export type LobeAppearance = 'light' | 'dark';
6
7
  export interface LobeThemeState {
7
8
  appearance: LobeAppearance;
8
9
  neutralColor?: NeutralColors;
9
- primaryColor?: PrimaryColors;
10
+ primaryColor?: LobePrimaryColor;
10
11
  }
11
12
  export declare const setLobeTheme: (state: Partial<LobeThemeState>, root?: HTMLElement) => void;
12
13
  export interface ThemeScopeProps extends Partial<LobeThemeState> {
@@ -40,7 +41,7 @@ export interface LobeThemeScriptProps {
40
41
  appearance?: LobeAppearance | 'system';
41
42
  neutralColor?: NeutralColors;
42
43
  nonce?: string;
43
- primaryColor?: PrimaryColors;
44
+ primaryColor?: LobePrimaryColor;
44
45
  }
45
46
  export declare const LobeThemeScript: ({ appearance, neutralColor, nonce, primaryColor }: LobeThemeScriptProps) => import("react").JSX.Element;
46
47
  //#endregion
@@ -1,8 +1,10 @@
1
1
  "use client";
2
+ import { isCustomPrimaryColor } from "./customPrimary.mjs";
2
3
  import { staticToken } from "./token/static.mjs";
3
4
  import { createLobeToken } from "./createLobeToken.mjs";
5
+ import { getCustomPrimaryCss } from "./themeCss.mjs";
4
6
  import { createContext, use, useMemo, useSyncExternalStore } from "react";
5
- import { jsx } from "react/jsx-runtime";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
6
8
  //#region src/styles/theme/scope.tsx
7
9
  const ATTRIBUTES = [
8
10
  "data-theme",
@@ -14,11 +16,23 @@ const toAttributes = ({ appearance, neutralColor, primaryColor }) => ({
14
16
  "data-primary-color": primaryColor,
15
17
  "data-theme": appearance
16
18
  });
19
+ const normalizePrimary = (color) => isCustomPrimaryColor(color) ? color.toLowerCase() : color;
20
+ const customPrimaryStyleId = (color) => `lobe-primary-${color.slice(1)}`;
21
+ const ensureCustomPrimaryStyle = (color, doc) => {
22
+ const id = customPrimaryStyleId(color);
23
+ if (doc.getElementById(id)) return;
24
+ const style = doc.createElement("style");
25
+ style.id = id;
26
+ style.textContent = getCustomPrimaryCss(color);
27
+ doc.head.append(style);
28
+ };
17
29
  const setLobeTheme = (state, root = document.documentElement) => {
18
30
  const next = {
19
31
  ...readThemeState(root),
20
32
  ...state
21
33
  };
34
+ next.primaryColor = normalizePrimary(next.primaryColor);
35
+ if (isCustomPrimaryColor(next.primaryColor)) ensureCustomPrimaryStyle(next.primaryColor, root.ownerDocument);
22
36
  for (const [name, value] of Object.entries(toAttributes(next))) if (value) root.setAttribute(name, value);
23
37
  else root.removeAttribute(name);
24
38
  };
@@ -54,21 +68,26 @@ const ThemeScope = ({ appearance, children, className, neutralColor, primaryColo
54
68
  const state = useMemo(() => ({
55
69
  appearance: appearance ?? parent.appearance,
56
70
  neutralColor: neutralColor ?? parent.neutralColor,
57
- primaryColor: primaryColor ?? parent.primaryColor
71
+ primaryColor: normalizePrimary(primaryColor) ?? parent.primaryColor
58
72
  }), [
59
73
  appearance,
60
74
  neutralColor,
61
75
  primaryColor,
62
76
  parent
63
77
  ]);
64
- return /* @__PURE__ */ jsx(ThemeScopeContext, {
78
+ const customPrimary = isCustomPrimaryColor(state.primaryColor) ? state.primaryColor : void 0;
79
+ return /* @__PURE__ */ jsxs(ThemeScopeContext, {
65
80
  value: state,
66
- children: /* @__PURE__ */ jsx("div", {
81
+ children: [customPrimary && /* @__PURE__ */ jsx("style", {
82
+ href: customPrimaryStyleId(customPrimary),
83
+ precedence: "lobe-theme",
84
+ children: getCustomPrimaryCss(customPrimary)
85
+ }), /* @__PURE__ */ jsx("div", {
67
86
  className,
68
87
  style,
69
88
  ...toAttributes(state),
70
89
  children
71
- })
90
+ })]
72
91
  });
73
92
  };
74
93
  const useThemeMode = () => {
@@ -133,10 +152,13 @@ const subscribeResponsive = (onChange) => {
133
152
  };
134
153
  const useResponsive = () => useSyncExternalStore(subscribeResponsive, getResponsiveSnapshot, () => SERVER_RESPONSIVE);
135
154
  const LobeThemeScript = ({ appearance, neutralColor, nonce, primaryColor }) => {
136
- const script = `(function(a,p,n){var d=document.documentElement;if(a==='system')a=matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light';if(a)d.setAttribute('data-theme',a);else if(!d.hasAttribute('data-theme'))d.setAttribute('data-theme','light');if(p)d.setAttribute('data-primary-color',p);if(n)d.setAttribute('data-neutral-color',n);}).apply(null,${JSON.stringify([
155
+ const primary = normalizePrimary(primaryColor);
156
+ const custom = isCustomPrimaryColor(primary) ? [customPrimaryStyleId(primary), getCustomPrimaryCss(primary)] : [null, null];
157
+ const script = `(function(a,p,n,i,c){var d=document.documentElement;if(a==='system')a=matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light';if(a)d.setAttribute('data-theme',a);else if(!d.hasAttribute('data-theme'))d.setAttribute('data-theme','light');if(p)d.setAttribute('data-primary-color',p);if(n)d.setAttribute('data-neutral-color',n);if(c&&!document.getElementById(i)){var s=document.createElement('style');s.id=i;s.textContent=c;document.head.appendChild(s);}}).apply(null,${JSON.stringify([
137
158
  appearance ?? null,
138
- primaryColor ?? null,
139
- neutralColor ?? null
159
+ primary ?? null,
160
+ neutralColor ?? null,
161
+ ...custom
140
162
  ])})`;
141
163
  return /* @__PURE__ */ jsx("script", {
142
164
  suppressHydrationWarning: true,
@@ -1 +1 @@
1
- {"version":3,"file":"scope.mjs","names":[],"sources":["../../../src/styles/theme/scope.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n type CSSProperties,\n type ReactNode,\n use,\n useMemo,\n useSyncExternalStore,\n} from 'react';\n\nimport type { NeutralColors, PrimaryColors } from '../customTheme';\nimport { createLobeToken, type LobeToken } from './createLobeToken';\nimport { staticToken } from './token/static';\n\nexport type LobeAppearance = 'light' | 'dark';\n\nexport interface LobeThemeState {\n appearance: LobeAppearance;\n neutralColor?: NeutralColors;\n primaryColor?: PrimaryColors;\n}\n\nconst ATTRIBUTES = ['data-theme', 'data-primary-color', 'data-neutral-color'];\n\nconst toAttributes = ({ appearance, neutralColor, primaryColor }: LobeThemeState) => ({\n 'data-neutral-color': neutralColor,\n 'data-primary-color': primaryColor,\n 'data-theme': appearance,\n});\n\nexport const setLobeTheme = (\n state: Partial<LobeThemeState>,\n root: HTMLElement = document.documentElement,\n) => {\n const next = { ...readThemeState(root), ...state };\n for (const [name, value] of Object.entries(toAttributes(next))) {\n if (value) root.setAttribute(name, value);\n else root.removeAttribute(name);\n }\n};\n\nconst readThemeState = (el: HTMLElement): LobeThemeState => ({\n appearance: el.dataset.theme === 'dark' ? 'dark' : 'light',\n neutralColor: (el.dataset.neutralColor as NeutralColors) || undefined,\n primaryColor: (el.dataset.primaryColor as PrimaryColors) || undefined,\n});\n\nconst stateKey = (state: LobeThemeState) =>\n `${state.appearance}|${state.primaryColor ?? ''}|${state.neutralColor ?? ''}`;\n\nconst SERVER_STATE: LobeThemeState = { appearance: 'light' };\nlet rootSnapshot: LobeThemeState = SERVER_STATE;\n\nconst getRootSnapshot = () => {\n const next = readThemeState(document.documentElement);\n if (stateKey(next) !== stateKey(rootSnapshot)) rootSnapshot = next;\n return rootSnapshot;\n};\n\nconst subscribeRoot = (onChange: () => void) => {\n const observer = new MutationObserver(onChange);\n observer.observe(document.documentElement, { attributeFilter: ATTRIBUTES, attributes: true });\n return () => observer.disconnect();\n};\n\nconst ThemeScopeContext = createContext<LobeThemeState | null>(null);\n\nconst useThemeState = () => {\n const scoped = use(ThemeScopeContext);\n const root = useSyncExternalStore(subscribeRoot, getRootSnapshot, () => SERVER_STATE);\n return scoped ?? root;\n};\n\nexport interface ThemeScopeProps extends Partial<LobeThemeState> {\n children?: ReactNode;\n className?: string;\n style?: CSSProperties;\n}\n\nexport const ThemeScope = ({\n appearance,\n children,\n className,\n neutralColor,\n primaryColor,\n style,\n}: ThemeScopeProps) => {\n const parent = useThemeState();\n const state = useMemo<LobeThemeState>(\n () => ({\n appearance: appearance ?? parent.appearance,\n neutralColor: neutralColor ?? parent.neutralColor,\n primaryColor: primaryColor ?? parent.primaryColor,\n }),\n [appearance, neutralColor, primaryColor, parent],\n );\n\n return (\n <ThemeScopeContext value={state}>\n <div className={className} style={style} {...toAttributes(state)}>\n {children}\n </div>\n </ThemeScopeContext>\n );\n};\n\nexport const useThemeMode = () => {\n const { appearance } = useThemeState();\n return useMemo(() => ({ appearance, isDarkMode: appearance === 'dark' }), [appearance]);\n};\n\nexport type LobeTheme = LobeToken & { appearance: LobeAppearance; isDarkMode: boolean };\n\nconst themeCache = new Map<string, LobeTheme>();\n\nexport const useTheme = (): LobeTheme => {\n const state = useThemeState();\n const key = stateKey(state);\n let theme = themeCache.get(key);\n if (!theme) {\n theme = {\n ...createLobeToken(state),\n appearance: state.appearance,\n isDarkMode: state.appearance === 'dark',\n };\n themeCache.set(key, theme);\n }\n return theme;\n};\n\nconst breakpointQueries = {\n lg: `(min-width: ${staticToken.screenLG}px)`,\n md: `(min-width: ${staticToken.screenMD}px)`,\n sm: `(min-width: ${staticToken.screenSM}px)`,\n xl: `(min-width: ${staticToken.screenXL}px)`,\n xs: `(max-width: ${staticToken.screenXSMax}px)`,\n xxl: `(min-width: ${staticToken.screenXXL}px)`,\n xxxl: `(min-width: ${staticToken.screenXXXL}px)`,\n};\n\ntype Breakpoint = keyof typeof breakpointQueries;\nexport type ResponsiveState = Record<\n Breakpoint | 'mobile' | 'tablet' | 'laptop' | 'desktop',\n boolean\n>;\n\nconst toResponsive = (matches: Record<Breakpoint, boolean>): ResponsiveState => ({\n ...matches,\n desktop: matches.xxl,\n laptop: matches.lg,\n mobile: matches.xs,\n tablet: matches.md,\n});\n\nconst SERVER_RESPONSIVE = toResponsive({\n lg: false,\n md: false,\n sm: false,\n xl: false,\n xs: false,\n xxl: false,\n xxxl: false,\n});\nlet responsiveSnapshot = SERVER_RESPONSIVE;\n\nconst getResponsiveSnapshot = () => {\n const matches = Object.fromEntries(\n Object.entries(breakpointQueries).map(([key, query]) => [key, matchMedia(query).matches]),\n ) as Record<Breakpoint, boolean>;\n const changed = (Object.keys(matches) as Breakpoint[]).some(\n (key) => matches[key] !== responsiveSnapshot[key],\n );\n if (changed) responsiveSnapshot = toResponsive(matches);\n return responsiveSnapshot;\n};\n\nconst subscribeResponsive = (onChange: () => void) => {\n const lists = Object.values(breakpointQueries).map((query) => matchMedia(query));\n for (const list of lists) list.addEventListener('change', onChange);\n return () => {\n for (const list of lists) list.removeEventListener('change', onChange);\n };\n};\n\nexport const useResponsive = () =>\n useSyncExternalStore(subscribeResponsive, getResponsiveSnapshot, () => SERVER_RESPONSIVE);\n\nexport interface LobeThemeScriptProps {\n appearance?: LobeAppearance | 'system';\n neutralColor?: NeutralColors;\n nonce?: string;\n primaryColor?: PrimaryColors;\n}\n\nexport const LobeThemeScript = ({\n appearance,\n neutralColor,\n nonce,\n primaryColor,\n}: LobeThemeScriptProps) => {\n const args = JSON.stringify([appearance ?? null, primaryColor ?? null, neutralColor ?? null]);\n const script = `(function(a,p,n){var d=document.documentElement;if(a==='system')a=matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light';if(a)d.setAttribute('data-theme',a);else if(!d.hasAttribute('data-theme'))d.setAttribute('data-theme','light');if(p)d.setAttribute('data-primary-color',p);if(n)d.setAttribute('data-neutral-color',n);}).apply(null,${args})`;\n\n return (\n <script suppressHydrationWarning dangerouslySetInnerHTML={{ __html: script }} nonce={nonce} />\n );\n};\n"],"mappings":";;;;;;AAuBA,MAAM,aAAa;CAAC;CAAc;CAAsB;AAAoB;AAE5E,MAAM,gBAAgB,EAAE,YAAY,cAAc,oBAAoC;CACpF,sBAAsB;CACtB,sBAAsB;CACtB,cAAc;AAChB;AAEA,MAAa,gBACX,OACA,OAAoB,SAAS,oBAC1B;CACH,MAAM,OAAO;EAAE,GAAG,eAAe,IAAI;EAAG,GAAG;CAAM;CACjD,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,aAAa,IAAI,CAAC,GAC3D,IAAI,OAAO,KAAK,aAAa,MAAM,KAAK;MACnC,KAAK,gBAAgB,IAAI;AAElC;AAEA,MAAM,kBAAkB,QAAqC;CAC3D,YAAY,GAAG,QAAQ,UAAU,SAAS,SAAS;CACnD,cAAe,GAAG,QAAQ,gBAAkC,KAAA;CAC5D,cAAe,GAAG,QAAQ,gBAAkC,KAAA;AAC9D;AAEA,MAAM,YAAY,UAChB,GAAG,MAAM,WAAW,GAAG,MAAM,gBAAgB,GAAG,GAAG,MAAM,gBAAgB;AAE3E,MAAM,eAA+B,EAAE,YAAY,QAAQ;AAC3D,IAAI,eAA+B;AAEnC,MAAM,wBAAwB;CAC5B,MAAM,OAAO,eAAe,SAAS,eAAe;CACpD,IAAI,SAAS,IAAI,MAAM,SAAS,YAAY,GAAG,e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B,EAAE,QAAQ,OAAO;EAAU;CAAQ,CAAA;AAEjG"}
1
+ {"version":3,"file":"scope.mjs","names":[],"sources":["../../../src/styles/theme/scope.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n type CSSProperties,\n type ReactNode,\n use,\n useMemo,\n useSyncExternalStore,\n} from 'react';\n\nimport type { NeutralColors } from '../customTheme';\nimport { createLobeToken, type LobeToken } from './createLobeToken';\nimport {\n type CustomPrimaryColor,\n isCustomPrimaryColor,\n type LobePrimaryColor,\n} from './customPrimary';\nimport { getCustomPrimaryCss } from './themeCss';\nimport { staticToken } from './token/static';\n\nexport type LobeAppearance = 'light' | 'dark';\n\nexport interface LobeThemeState {\n appearance: LobeAppearance;\n neutralColor?: NeutralColors;\n primaryColor?: LobePrimaryColor;\n}\n\nconst ATTRIBUTES = ['data-theme', 'data-primary-color', 'data-neutral-color'];\n\nconst toAttributes = ({ appearance, neutralColor, primaryColor }: LobeThemeState) => ({\n 'data-neutral-color': neutralColor,\n 'data-primary-color': primaryColor,\n 'data-theme': appearance,\n});\n\nconst normalizePrimary = (color?: LobePrimaryColor) =>\n isCustomPrimaryColor(color) ? (color.toLowerCase() as CustomPrimaryColor) : color;\n\nconst customPrimaryStyleId = (color: CustomPrimaryColor) => `lobe-primary-${color.slice(1)}`;\n\nconst ensureCustomPrimaryStyle = (color: CustomPrimaryColor, doc: Document) => {\n const id = customPrimaryStyleId(color);\n if (doc.getElementById(id)) return;\n const style = doc.createElement('style');\n style.id = id;\n style.textContent = getCustomPrimaryCss(color);\n doc.head.append(style);\n};\n\nexport const setLobeTheme = (\n state: Partial<LobeThemeState>,\n root: HTMLElement = document.documentElement,\n) => {\n const next = { ...readThemeState(root), ...state };\n next.primaryColor = normalizePrimary(next.primaryColor);\n if (isCustomPrimaryColor(next.primaryColor))\n ensureCustomPrimaryStyle(next.primaryColor, root.ownerDocument);\n for (const [name, value] of Object.entries(toAttributes(next))) {\n if (value) root.setAttribute(name, value);\n else root.removeAttribute(name);\n }\n};\n\nconst readThemeState = (el: HTMLElement): LobeThemeState => ({\n appearance: el.dataset.theme === 'dark' ? 'dark' : 'light',\n neutralColor: (el.dataset.neutralColor as NeutralColors) || undefined,\n primaryColor: (el.dataset.primaryColor as LobePrimaryColor) || undefined,\n});\n\nconst stateKey = (state: LobeThemeState) =>\n `${state.appearance}|${state.primaryColor ?? ''}|${state.neutralColor ?? ''}`;\n\nconst SERVER_STATE: LobeThemeState = { appearance: 'light' };\nlet rootSnapshot: LobeThemeState = SERVER_STATE;\n\nconst getRootSnapshot = () => {\n const next = readThemeState(document.documentElement);\n if (stateKey(next) !== stateKey(rootSnapshot)) rootSnapshot = next;\n return rootSnapshot;\n};\n\nconst subscribeRoot = (onChange: () => void) => {\n const observer = new MutationObserver(onChange);\n observer.observe(document.documentElement, { attributeFilter: ATTRIBUTES, attributes: true });\n return () => observer.disconnect();\n};\n\nconst ThemeScopeContext = createContext<LobeThemeState | null>(null);\n\nconst useThemeState = () => {\n const scoped = use(ThemeScopeContext);\n const root = useSyncExternalStore(subscribeRoot, getRootSnapshot, () => SERVER_STATE);\n return scoped ?? root;\n};\n\nexport interface ThemeScopeProps extends Partial<LobeThemeState> {\n children?: ReactNode;\n className?: string;\n style?: CSSProperties;\n}\n\nexport const ThemeScope = ({\n appearance,\n children,\n className,\n neutralColor,\n primaryColor,\n style,\n}: ThemeScopeProps) => {\n const parent = useThemeState();\n const state = useMemo<LobeThemeState>(\n () => ({\n appearance: appearance ?? parent.appearance,\n neutralColor: neutralColor ?? parent.neutralColor,\n primaryColor: normalizePrimary(primaryColor) ?? parent.primaryColor,\n }),\n [appearance, neutralColor, primaryColor, parent],\n );\n const customPrimary = isCustomPrimaryColor(state.primaryColor) ? state.primaryColor : undefined;\n\n return (\n <ThemeScopeContext value={state}>\n {customPrimary && (\n <style href={customPrimaryStyleId(customPrimary)} precedence=\"lobe-theme\">\n {getCustomPrimaryCss(customPrimary)}\n </style>\n )}\n <div className={className} style={style} {...toAttributes(state)}>\n {children}\n </div>\n </ThemeScopeContext>\n );\n};\n\nexport const useThemeMode = () => {\n const { appearance } = useThemeState();\n return useMemo(() => ({ appearance, isDarkMode: appearance === 'dark' }), [appearance]);\n};\n\nexport type LobeTheme = LobeToken & { appearance: LobeAppearance; isDarkMode: boolean };\n\nconst themeCache = new Map<string, LobeTheme>();\n\nexport const useTheme = (): LobeTheme => {\n const state = useThemeState();\n const key = stateKey(state);\n let theme = themeCache.get(key);\n if (!theme) {\n theme = {\n ...createLobeToken(state),\n appearance: state.appearance,\n isDarkMode: state.appearance === 'dark',\n };\n themeCache.set(key, theme);\n }\n return theme;\n};\n\nconst breakpointQueries = {\n lg: `(min-width: ${staticToken.screenLG}px)`,\n md: `(min-width: ${staticToken.screenMD}px)`,\n sm: `(min-width: ${staticToken.screenSM}px)`,\n xl: `(min-width: ${staticToken.screenXL}px)`,\n xs: `(max-width: ${staticToken.screenXSMax}px)`,\n xxl: `(min-width: ${staticToken.screenXXL}px)`,\n xxxl: `(min-width: ${staticToken.screenXXXL}px)`,\n};\n\ntype Breakpoint = keyof typeof breakpointQueries;\nexport type ResponsiveState = Record<\n Breakpoint | 'mobile' | 'tablet' | 'laptop' | 'desktop',\n boolean\n>;\n\nconst toResponsive = (matches: Record<Breakpoint, boolean>): ResponsiveState => ({\n ...matches,\n desktop: matches.xxl,\n laptop: matches.lg,\n mobile: matches.xs,\n tablet: matches.md,\n});\n\nconst SERVER_RESPONSIVE = toResponsive({\n lg: false,\n md: false,\n sm: false,\n xl: false,\n xs: false,\n xxl: false,\n xxxl: false,\n});\nlet responsiveSnapshot = SERVER_RESPONSIVE;\n\nconst getResponsiveSnapshot = () => {\n const matches = Object.fromEntries(\n Object.entries(breakpointQueries).map(([key, query]) => [key, matchMedia(query).matches]),\n ) as Record<Breakpoint, boolean>;\n const changed = (Object.keys(matches) as Breakpoint[]).some(\n (key) => matches[key] !== responsiveSnapshot[key],\n );\n if (changed) responsiveSnapshot = toResponsive(matches);\n return responsiveSnapshot;\n};\n\nconst subscribeResponsive = (onChange: () => void) => {\n const lists = Object.values(breakpointQueries).map((query) => matchMedia(query));\n for (const list of lists) list.addEventListener('change', onChange);\n return () => {\n for (const list of lists) list.removeEventListener('change', onChange);\n };\n};\n\nexport const useResponsive = () =>\n useSyncExternalStore(subscribeResponsive, getResponsiveSnapshot, () => SERVER_RESPONSIVE);\n\nexport interface LobeThemeScriptProps {\n appearance?: LobeAppearance | 'system';\n neutralColor?: NeutralColors;\n nonce?: string;\n primaryColor?: LobePrimaryColor;\n}\n\nexport const LobeThemeScript = ({\n appearance,\n neutralColor,\n nonce,\n primaryColor,\n}: LobeThemeScriptProps) => {\n const primary = normalizePrimary(primaryColor);\n const custom = isCustomPrimaryColor(primary)\n ? [customPrimaryStyleId(primary), getCustomPrimaryCss(primary)]\n : [null, null];\n const args = JSON.stringify([\n appearance ?? null,\n primary ?? null,\n neutralColor ?? null,\n ...custom,\n ]);\n const script = `(function(a,p,n,i,c){var d=document.documentElement;if(a==='system')a=matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light';if(a)d.setAttribute('data-theme',a);else if(!d.hasAttribute('data-theme'))d.setAttribute('data-theme','light');if(p)d.setAttribute('data-primary-color',p);if(n)d.setAttribute('data-neutral-color',n);if(c&&!document.getElementById(i)){var s=document.createElement('style');s.id=i;s.textContent=c;document.head.appendChild(s);}}).apply(null,${args})`;\n\n return (\n <script suppressHydrationWarning dangerouslySetInnerHTML={{ __html: script }} nonce={nonce} />\n );\n};\n"],"mappings":";;;;;;;;AA6BA,MAAM,aAAa;CAAC;CAAc;CAAsB;AAAoB;AAE5E,MAAM,gBAAgB,EAAE,YAAY,cAAc,oBAAoC;CACpF,sBAAsB;CACtB,sBAAsB;CACtB,cAAc;AAChB;AAEA,MAAM,oBAAoB,UACxB,qBAAqB,KAAK,IAAK,MAAM,YAAY,IAA2B;AAE9E,MAAM,wBAAwB,UAA8B,gBAAgB,MAAM,MAAM,CAAC;AAEzF,MAAM,4BAA4B,OAA2B,QAA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G;CACL,CACgf,EAAE;CAElf,OACE,oBAAC,UAAD;EAAQ,0BAAA;EAAyB,yBAAyB,EAAE,QAAQ,OAAO;EAAU;CAAQ,CAAA;AAEjG"}
@@ -1,4 +1,6 @@
1
+ import { CustomPrimaryColor } from "./customPrimary.mjs";
1
2
  //#region src/styles/theme/themeCss.d.ts
3
+ export declare const getCustomPrimaryCss: (color: CustomPrimaryColor) => string;
2
4
  export declare const getThemeCss: () => string;
3
5
  export declare const getGlobalCss: () => string;
4
6
  //#endregion
@@ -1,6 +1,6 @@
1
+ import { neutralColors, primaryColors } from "../customTheme.mjs";
1
2
  import { createLobeTokenGroups } from "./createLobeToken.mjs";
2
3
  import { toCssVarName, toCssVariables } from "../css.mjs";
3
- import { neutralColors, primaryColors } from "../customTheme.mjs";
4
4
  //#region src/styles/theme/themeCss.ts
5
5
  const v = (key) => `var(${toCssVarName(key)})`;
6
6
  const ring = {
@@ -34,6 +34,13 @@ const colorRules = (appearance) => [...Object.keys(primaryColors).map((primaryCo
34
34
  appearance,
35
35
  neutralColor
36
36
  }).neutral)))];
37
+ const getCustomPrimaryCss = (color) => {
38
+ const hex = color.toLowerCase();
39
+ return ["light", "dark"].map((appearance) => rule(`[data-primary-color='${hex}']${appearanceSelector(appearance)}`, toCssVariables(createLobeTokenGroups({
40
+ appearance,
41
+ primaryColor: hex
42
+ }).primary))).join("\n\n");
43
+ };
37
44
  const essentialCss = `@layer lobe-ui {
38
45
  .lobe-brand-loading path {
39
46
  fill: currentcolor;
@@ -313,6 +320,6 @@ const getThemeCss = () => cached ??= [
313
320
  ].join("\n\n");
314
321
  const getGlobalCss = () => `${layerOrder}\n\n${globalCss}`;
315
322
  //#endregion
316
- export { getGlobalCss, getThemeCss };
323
+ export { getCustomPrimaryCss, getGlobalCss, getThemeCss };
317
324
 
318
325
  //# sourceMappingURL=themeCss.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"themeCss.mjs","names":[],"sources":["../../../src/styles/theme/themeCss.ts"],"sourcesContent":["import { toCssVariables, toCssVarName } from '../css';\nimport { neutralColors, primaryColors } from '../customTheme';\nimport { createLobeTokenGroups } from './createLobeToken';\nimport type { LobeAppearance } from './scope';\n\nconst v = (key: string) => `var(${toCssVarName(key)})`;\n\nconst ring: Record<LobeAppearance, string> = {\n dark: '0 0 0 1px rgb(255 255 255 / 18%)',\n light: '0 0 0 1px rgb(0 0 0 / 5%)',\n};\n\nconst rule = (selector: string, declarations: Record<string, number | string>) =>\n `${selector} {\\n${Object.entries(declarations)\n .map(([name, value]) => ` ${name}: ${value};`)\n .join('\\n')}\\n}`;\n\nconst appearanceRule = (selector: string, appearance: LobeAppearance) => {\n const { neutral, palette, primary, static: base } = createLobeTokenGroups({ appearance });\n const token =\n appearance === 'light'\n ? { ...base, ...palette, ...primary, ...neutral }\n : { ...palette, ...primary, ...neutral };\n\n return rule(selector, {\n ...toCssVariables(token),\n '--lobe-ring': ring[appearance],\n 'color-scheme': appearance,\n });\n};\n\nconst appearanceSelector = (appearance: LobeAppearance) =>\n appearance === 'dark' ? \"[data-theme='dark']\" : \":not([data-theme='dark'])\";\n\nconst colorRules = (appearance: LobeAppearance) => [\n ...(Object.keys(primaryColors) as (keyof typeof primaryColors)[]).map((primaryColor) =>\n rule(\n `[data-primary-color='${primaryColor}']${appearanceSelector(appearance)}`,\n toCssVariables(createLobeTokenGroups({ appearance, primaryColor }).primary),\n ),\n ),\n ...(Object.keys(neutralColors) as (keyof typeof neutralColors)[]).map((neutralColor) =>\n rule(\n `[data-neutral-color='${neutralColor}']${appearanceSelector(appearance)}`,\n toCssVariables(createLobeTokenGroups({ appearance, neutralColor }).neutral),\n ),\n ),\n];\n\nconst essentialCss = `@layer lobe-ui {\n .lobe-brand-loading path {\n fill: currentcolor;\n fill-opacity: 0;\n stroke: currentcolor;\n stroke-dasharray: 1000;\n stroke-dashoffset: 1000;\n stroke-width: 0.25em;\n\n animation:\n draw 2s cubic-bezier(0.4, 0, 0.2, 1) infinite,\n fill 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;\n }\n}\n\n@layer lobe-popup {\n .lobe-context-trigger[data-popup-open],\n .lobe-dropdown-menu-trigger[data-popup-open] {\n background: ${v('colorFillTertiary')};\n }\n}\n\n@layer lobe-base {\n :where(body, body [data-theme]) {\n color: ${v('colorText')};\n font-family: ${v('fontFamily')};\n font-size: ${v('fontSize')};\n line-height: ${v('lineHeight')};\n }\n\n :where(body) :where(a) {\n cursor: pointer;\n\n color: ${v('colorLink')};\n text-decoration: none;\n\n background-color: transparent;\n outline: none;\n\n transition: color ${v('motionDurationSlow')};\n }\n\n :where(body) :where(a):hover {\n color: ${v('colorLinkHover')};\n }\n\n :where(body) :where(a):active {\n color: ${v('colorLinkActive')};\n }\n\n :where(body) :where(a):focus-visible {\n outline: ${v('lineWidthFocus')} solid ${v('colorPrimaryBorder')};\n outline-offset: 1px;\n }\n\n :where(body) :where(a)[disabled] {\n cursor: not-allowed;\n color: ${v('colorTextDisabled')};\n }\n\n :where(.lobe-flex) {\n --lobe-flex: 0 1 auto;\n --lobe-flex-direction: column;\n --lobe-flex-wrap: nowrap;\n --lobe-flex-justify: flex-start;\n --lobe-flex-align: stretch;\n --lobe-flex-width: auto;\n --lobe-flex-height: auto;\n --lobe-flex-padding: 0;\n --lobe-flex-padding-inline: var(--lobe-flex-padding);\n --lobe-flex-padding-block: var(--lobe-flex-padding);\n --lobe-flex-gap: 0;\n\n display: flex;\n flex: var(--lobe-flex);\n flex-flow: var(--lobe-flex-direction) var(--lobe-flex-wrap);\n gap: var(--lobe-flex-gap);\n align-items: var(--lobe-flex-align);\n justify-content: var(--lobe-flex-justify);\n\n width: var(--lobe-flex-width);\n height: var(--lobe-flex-height);\n padding: var(--lobe-flex-padding);\n padding-block: var(--lobe-flex-padding-block);\n padding-inline: var(--lobe-flex-padding-inline);\n }\n\n .lobe-flex-hidden {\n display: none;\n }\n}\n\n@keyframes draw {\n 0% {\n stroke-dashoffset: 1000;\n }\n\n 100% {\n stroke-dashoffset: 0;\n }\n}\n\n@keyframes fill {\n 30% {\n fill-opacity: 0.05;\n }\n\n 100% {\n fill-opacity: 1;\n }\n}`;\n\nconst globalCss = `@layer lobe-base {\n :root {\n --font-settings: 'cv01', 'tnum', 'kern';\n --font-variations: 'opsz' auto, tabular-nums;\n\n font-synthesis: style;\n text-autospace: normal;\n }\n\n html {\n overscroll-behavior: none;\n }\n\n body {\n overflow: hidden auto;\n\n min-height: 100vh;\n margin: 0;\n padding: 0;\n\n font-feature-settings: var(--font-settings);\n font-variation-settings: var(--font-variations);\n font-optical-sizing: auto;\n font-kerning: normal;\n font-variant-ligatures: common-ligatures contextual;\n font-variant-numeric: tabular-nums;\n font-size-adjust: from-font;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-wrap: pretty;\n text-size-adjust: 100%;\n text-rendering: optimizelegibility;\n overflow-wrap: anywhere;\n vertical-align: baseline;\n\n background-color: ${v('colorBgLayout')};\n\n font-synthesis: style;\n\n -webkit-overflow-scrolling: touch;\n -webkit-tap-highlight-color: transparent;\n }\n\n html,\n body {\n width: 100%;\n height: 100%;\n }\n\n [tabindex='-1']:focus {\n outline: none;\n }\n\n [hidden] {\n display: none !important;\n }\n\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n margin-block: 0 0.5em;\n font-weight: 500;\n }\n\n p,\n ol,\n ul,\n dl,\n pre {\n margin-block: 0 1em;\n }\n\n ol ol,\n ul ul,\n ol ul,\n ul ol {\n margin-block-end: 0;\n }\n\n dd {\n margin-block-end: 0.5em;\n margin-inline-start: 0;\n }\n\n blockquote,\n figure {\n margin-block: 0 1em;\n margin-inline: 0;\n }\n\n img {\n border-style: none;\n vertical-align: middle;\n }\n\n table {\n border-collapse: collapse;\n }\n\n input,\n button,\n select,\n optgroup,\n textarea {\n margin: 0;\n\n font-family: inherit;\n font-size: inherit;\n line-height: inherit;\n color: inherit;\n }\n\n textarea {\n resize: vertical;\n overflow: auto;\n }\n\n fieldset {\n min-width: 0;\n margin: 0;\n padding: 0;\n border: 0;\n }\n\n code,\n kbd,\n samp,\n pre {\n font-family: ${v('fontFamilyCode')} !important;\n font-feature-settings:\n 'liga' 0,\n 'calt' 0;\n font-variant-ligatures: none;\n\n span {\n font-family: ${v('fontFamilyCode')} !important;\n }\n }\n\n ::selection {\n color: #000;\n background: ${v('yellow9')};\n\n -webkit-text-fill-color: unset !important;\n }\n\n * {\n scrollbar-color: ${v('colorFill')} transparent;\n scrollbar-width: thin;\n box-sizing: border-box;\n vertical-align: baseline;\n }\n}`;\n\nconst layerOrder = '@layer lobe-base, lobe-popup, lobe-ui;';\n\nlet cached: string | undefined;\n\nexport const getThemeCss = () =>\n (cached ??= [\n layerOrder,\n appearanceRule(\":root, [data-theme='light']\", 'light'),\n appearanceRule(\"[data-theme='dark']\", 'dark'),\n ...colorRules('light'),\n ...colorRules('dark'),\n essentialCss,\n ].join('\\n\\n'));\n\nexport const getGlobalCss = () => `${layerOrder}\\n\\n${globalCss}`;\n"],"mappings":";;;;AAKA,MAAM,KAAK,QAAgB,OAAO,aAAa,GAAG,EAAE;AAEpD,MAAM,OAAuC;CAC3C,MAAM;CACN,OAAO;AACT;AAEA,MAAM,QAAQ,UAAkB,iBAC9B,GAAG,SAAS,MAAM,OAAO,QAAQ,YAAY,CAAC,CAC3C,KAAK,CAAC,MAAM,WAAW,KAAK,KAAK,IAAI,MAAM,EAAE,CAAC,CAC9C,KAAK,IAAI,EAAE;AAEhB,MAAM,kBAAkB,UAAkB,eAA+B;CACvE,MAAM,EAAE,SAAS,SAAS,SAAS,QAAQ,SAAS,sBAAsB,EAAE,WAAW,CAAC;CACxF,MAAM,QACJ,eAAe,UACX;EAAE,GAAG;EAAM,GAAG;EAAS,GAAG;EAAS,GAAG;CAAQ,IAC9C;EAAE,GAAG;EAAS,GAAG;EAAS,GAAG;CAAQ;CAE3C,OAAO,KAAK,UAAU;EACpB,GAAG,eAAe,KAAK;EACvB,eAAe,KAAK;EACpB,gBAAgB;CAClB,CAAC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AAa;AAEnB,IAAI;AAEJ,MAAa,oBACV,WAAW;CACV;CACA,eAAe,+BAA+B,OAAO;CACrD,eAAe,uBAAuB,MAAM;CAC5C,GAAG,WAAW,OAAO;CACrB,GAAG,WAAW,MAAM;CACpB;AACF,CAAC,CAAC,KAAK,MAAM;AAEf,MAAa,qBAAqB,GAAG,WAAW,MAAM"}
1
+ {"version":3,"file":"themeCss.mjs","names":[],"sources":["../../../src/styles/theme/themeCss.ts"],"sourcesContent":["import { toCssVariables, toCssVarName } from '../css';\nimport { neutralColors, primaryColors } from '../customTheme';\nimport { createLobeTokenGroups } from './createLobeToken';\nimport type { CustomPrimaryColor } from './customPrimary';\nimport type { LobeAppearance } from './scope';\n\nconst v = (key: string) => `var(${toCssVarName(key)})`;\n\nconst ring: Record<LobeAppearance, string> = {\n dark: '0 0 0 1px rgb(255 255 255 / 18%)',\n light: '0 0 0 1px rgb(0 0 0 / 5%)',\n};\n\nconst rule = (selector: string, declarations: Record<string, number | string>) =>\n `${selector} {\\n${Object.entries(declarations)\n .map(([name, value]) => ` ${name}: ${value};`)\n .join('\\n')}\\n}`;\n\nconst appearanceRule = (selector: string, appearance: LobeAppearance) => {\n const { neutral, palette, primary, static: base } = createLobeTokenGroups({ appearance });\n const token =\n appearance === 'light'\n ? { ...base, ...palette, ...primary, ...neutral }\n : { ...palette, ...primary, ...neutral };\n\n return rule(selector, {\n ...toCssVariables(token),\n '--lobe-ring': ring[appearance],\n 'color-scheme': appearance,\n });\n};\n\nconst appearanceSelector = (appearance: LobeAppearance) =>\n appearance === 'dark' ? \"[data-theme='dark']\" : \":not([data-theme='dark'])\";\n\nconst colorRules = (appearance: LobeAppearance) => [\n ...(Object.keys(primaryColors) as (keyof typeof primaryColors)[]).map((primaryColor) =>\n rule(\n `[data-primary-color='${primaryColor}']${appearanceSelector(appearance)}`,\n toCssVariables(createLobeTokenGroups({ appearance, primaryColor }).primary),\n ),\n ),\n ...(Object.keys(neutralColors) as (keyof typeof neutralColors)[]).map((neutralColor) =>\n rule(\n `[data-neutral-color='${neutralColor}']${appearanceSelector(appearance)}`,\n toCssVariables(createLobeTokenGroups({ appearance, neutralColor }).neutral),\n ),\n ),\n];\n\nexport const getCustomPrimaryCss = (color: CustomPrimaryColor) => {\n const hex = color.toLowerCase();\n return (['light', 'dark'] as const)\n .map((appearance) =>\n rule(\n `[data-primary-color='${hex}']${appearanceSelector(appearance)}`,\n toCssVariables(\n createLobeTokenGroups({ appearance, primaryColor: hex as CustomPrimaryColor }).primary,\n ),\n ),\n )\n .join('\\n\\n');\n};\n\nconst essentialCss = `@layer lobe-ui {\n .lobe-brand-loading path {\n fill: currentcolor;\n fill-opacity: 0;\n stroke: currentcolor;\n stroke-dasharray: 1000;\n stroke-dashoffset: 1000;\n stroke-width: 0.25em;\n\n animation:\n draw 2s cubic-bezier(0.4, 0, 0.2, 1) infinite,\n fill 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;\n }\n}\n\n@layer lobe-popup {\n .lobe-context-trigger[data-popup-open],\n .lobe-dropdown-menu-trigger[data-popup-open] {\n background: ${v('colorFillTertiary')};\n }\n}\n\n@layer lobe-base {\n :where(body, body [data-theme]) {\n color: ${v('colorText')};\n font-family: ${v('fontFamily')};\n font-size: ${v('fontSize')};\n line-height: ${v('lineHeight')};\n }\n\n :where(body) :where(a) {\n cursor: pointer;\n\n color: ${v('colorLink')};\n text-decoration: none;\n\n background-color: transparent;\n outline: none;\n\n transition: color ${v('motionDurationSlow')};\n }\n\n :where(body) :where(a):hover {\n color: ${v('colorLinkHover')};\n }\n\n :where(body) :where(a):active {\n color: ${v('colorLinkActive')};\n }\n\n :where(body) :where(a):focus-visible {\n outline: ${v('lineWidthFocus')} solid ${v('colorPrimaryBorder')};\n outline-offset: 1px;\n }\n\n :where(body) :where(a)[disabled] {\n cursor: not-allowed;\n color: ${v('colorTextDisabled')};\n }\n\n :where(.lobe-flex) {\n --lobe-flex: 0 1 auto;\n --lobe-flex-direction: column;\n --lobe-flex-wrap: nowrap;\n --lobe-flex-justify: flex-start;\n --lobe-flex-align: stretch;\n --lobe-flex-width: auto;\n --lobe-flex-height: auto;\n --lobe-flex-padding: 0;\n --lobe-flex-padding-inline: var(--lobe-flex-padding);\n --lobe-flex-padding-block: var(--lobe-flex-padding);\n --lobe-flex-gap: 0;\n\n display: flex;\n flex: var(--lobe-flex);\n flex-flow: var(--lobe-flex-direction) var(--lobe-flex-wrap);\n gap: var(--lobe-flex-gap);\n align-items: var(--lobe-flex-align);\n justify-content: var(--lobe-flex-justify);\n\n width: var(--lobe-flex-width);\n height: var(--lobe-flex-height);\n padding: var(--lobe-flex-padding);\n padding-block: var(--lobe-flex-padding-block);\n padding-inline: var(--lobe-flex-padding-inline);\n }\n\n .lobe-flex-hidden {\n display: none;\n }\n}\n\n@keyframes draw {\n 0% {\n stroke-dashoffset: 1000;\n }\n\n 100% {\n stroke-dashoffset: 0;\n }\n}\n\n@keyframes fill {\n 30% {\n fill-opacity: 0.05;\n }\n\n 100% {\n fill-opacity: 1;\n }\n}`;\n\nconst globalCss = `@layer lobe-base {\n :root {\n --font-settings: 'cv01', 'tnum', 'kern';\n --font-variations: 'opsz' auto, tabular-nums;\n\n font-synthesis: style;\n text-autospace: normal;\n }\n\n html {\n overscroll-behavior: none;\n }\n\n body {\n overflow: hidden auto;\n\n min-height: 100vh;\n margin: 0;\n padding: 0;\n\n font-feature-settings: var(--font-settings);\n font-variation-settings: var(--font-variations);\n font-optical-sizing: auto;\n font-kerning: normal;\n font-variant-ligatures: common-ligatures contextual;\n font-variant-numeric: tabular-nums;\n font-size-adjust: from-font;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-wrap: pretty;\n text-size-adjust: 100%;\n text-rendering: optimizelegibility;\n overflow-wrap: anywhere;\n vertical-align: baseline;\n\n background-color: ${v('colorBgLayout')};\n\n font-synthesis: style;\n\n -webkit-overflow-scrolling: touch;\n -webkit-tap-highlight-color: transparent;\n }\n\n html,\n body {\n width: 100%;\n height: 100%;\n }\n\n [tabindex='-1']:focus {\n outline: none;\n }\n\n [hidden] {\n display: none !important;\n }\n\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n margin-block: 0 0.5em;\n font-weight: 500;\n }\n\n p,\n ol,\n ul,\n dl,\n pre {\n margin-block: 0 1em;\n }\n\n ol ol,\n ul ul,\n ol ul,\n ul ol {\n margin-block-end: 0;\n }\n\n dd {\n margin-block-end: 0.5em;\n margin-inline-start: 0;\n }\n\n blockquote,\n figure {\n margin-block: 0 1em;\n margin-inline: 0;\n }\n\n img {\n border-style: none;\n vertical-align: middle;\n }\n\n table {\n border-collapse: collapse;\n }\n\n input,\n button,\n select,\n optgroup,\n textarea {\n margin: 0;\n\n font-family: inherit;\n font-size: inherit;\n line-height: inherit;\n color: inherit;\n }\n\n textarea {\n resize: vertical;\n overflow: auto;\n }\n\n fieldset {\n min-width: 0;\n margin: 0;\n padding: 0;\n border: 0;\n }\n\n code,\n kbd,\n samp,\n pre {\n font-family: ${v('fontFamilyCode')} !important;\n font-feature-settings:\n 'liga' 0,\n 'calt' 0;\n font-variant-ligatures: none;\n\n span {\n font-family: ${v('fontFamilyCode')} !important;\n }\n }\n\n ::selection {\n color: #000;\n background: ${v('yellow9')};\n\n -webkit-text-fill-color: unset !important;\n }\n\n * {\n scrollbar-color: ${v('colorFill')} transparent;\n scrollbar-width: thin;\n box-sizing: border-box;\n vertical-align: baseline;\n }\n}`;\n\nconst layerOrder = '@layer lobe-base, lobe-popup, lobe-ui;';\n\nlet cached: string | undefined;\n\nexport const getThemeCss = () =>\n (cached ??= [\n layerOrder,\n appearanceRule(\":root, [data-theme='light']\", 'light'),\n appearanceRule(\"[data-theme='dark']\", 'dark'),\n ...colorRules('light'),\n ...colorRules('dark'),\n essentialCss,\n ].join('\\n\\n'));\n\nexport const getGlobalCss = () => `${layerOrder}\\n\\n${globalCss}`;\n"],"mappings":";;;;AAMA,MAAM,KAAK,QAAgB,OAAO,aAAa,GAAG,EAAE;AAEpD,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;AAChB;AAEA,MAAM,eAAe;;;;;;;;;;;;;;;;;;kBAkBH,EAAE,mBAAmB,EAAE;;;;;;aAM5B,EAAE,WAAW,EAAE;mBACT,EAAE,YAAY,EAAE;iBAClB,EAAE,UAAU,EAAE;mBACZ,EAAE,YAAY,EAAE;;;;;;aAMtB,EAAE,WAAW,EAAE;;;;;;wBAMJ,EAAE,oBAAoB,EAAE;;;;aAInC,EAAE,gBAAgB,EAAE;;;;aAIpB,EAAE,iBAAiB,EAAE;;;;eAInB,EAAE,gBAAgB,EAAE,SAAS,EAAE,oBAAoB,EAAE;;;;;;aAMvD,EAAE,mBAAmB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDpC,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAmCM,EAAE,eAAe,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAgGxB,EAAE,gBAAgB,EAAE;;;;;;;qBAOlB,EAAE,gBAAgB,EAAE;;;;;;kBAMvB,EAAE,SAAS,EAAE;;;;;;uBAMR,EAAE,WAAW,EAAE;;;;;;AAOtC,MAAM,aAAa;AAEnB,IAAI;AAEJ,MAAa,oBACV,WAAW;CACV;CACA,eAAe,+BAA+B,OAAO;CACrD,eAAe,uBAAuB,MAAM;CAC5C,GAAG,WAAW,OAAO;CACrB,GAAG,WAAW,MAAM;CACpB;AACF,CAAC,CAAC,KAAK,MAAM;AAEf,MAAa,qBAAqB,GAAG,WAAW,MAAM"}
@@ -1,12 +1,16 @@
1
1
  import primary from "../../../color/colors/primary.mjs";
2
2
  import { colorScales } from "../../../color/colors/index.mjs";
3
3
  import { generateColorPalette } from "../generateColorPalette.mjs";
4
+ import { generatePrimaryScale, isCustomPrimaryColor } from "../customPrimary.mjs";
4
5
  //#region src/styles/theme/token/primary.ts
6
+ const resolveScale = (primaryColor) => {
7
+ if (isCustomPrimaryColor(primaryColor)) return generatePrimaryScale(primaryColor);
8
+ return primaryColor && colorScales[primaryColor] || primary;
9
+ };
5
10
  const createPrimaryToken = (appearance, primaryColor) => {
6
- const scale = primaryColor && colorScales[primaryColor] || primary;
7
11
  const token = generateColorPalette({
8
12
  appearance,
9
- scale,
13
+ scale: resolveScale(primaryColor),
10
14
  type: "Primary"
11
15
  });
12
16
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"primary.mjs","names":[],"sources":["../../../../src/styles/theme/token/primary.ts"],"sourcesContent":["import { colorScales, primary } from '@/color/colors';\n\nimport type { PrimaryColors } from '../../customTheme';\nimport { generateColorPalette } from '../generateColorPalette';\n\nexport const createPrimaryToken = (appearance: 'light' | 'dark', primaryColor?: PrimaryColors) => {\n const scale = (primaryColor && colorScales[primaryColor]) || primary;\n const token = generateColorPalette({ appearance, scale, type: 'Primary' });\n\n return {\n ...token,\n controlItemBgActive: token.colorPrimaryBg,\n controlItemBgActiveHover: token.colorPrimaryBgHover,\n };\n};\n"],"mappings":";;;;AAKA,MAAa,sBAAsB,YAA8B,iBAAiC;CAChG,MAAM,QAAS,gBAAgB,YAAY,iBAAkB;CAC7D,MAAM,QAAQ,qBAAqB;EAAE;EAAY;EAAO,MAAM;CAAU,CAAC;CAEzE,OAAO;EACL,GAAG;EACH,qBAAqB,MAAM;EAC3B,0BAA0B,MAAM;CAClC;AACF"}
1
+ {"version":3,"file":"primary.mjs","names":[],"sources":["../../../../src/styles/theme/token/primary.ts"],"sourcesContent":["import { colorScales, primary } from '@/color/colors';\n\nimport {\n generatePrimaryScale,\n isCustomPrimaryColor,\n type LobePrimaryColor,\n} from '../customPrimary';\nimport { generateColorPalette } from '../generateColorPalette';\n\nconst resolveScale = (primaryColor?: LobePrimaryColor) => {\n if (isCustomPrimaryColor(primaryColor)) return generatePrimaryScale(primaryColor);\n return (primaryColor && colorScales[primaryColor]) || primary;\n};\n\nexport const createPrimaryToken = (\n appearance: 'light' | 'dark',\n primaryColor?: LobePrimaryColor,\n) => {\n const token = generateColorPalette({\n appearance,\n scale: resolveScale(primaryColor),\n type: 'Primary',\n });\n\n return {\n ...token,\n controlItemBgActive: token.colorPrimaryBg,\n controlItemBgActiveHover: token.colorPrimaryBgHover,\n };\n};\n"],"mappings":";;;;;AASA,MAAM,gBAAgB,iBAAoC;CACxD,IAAI,qBAAqB,YAAY,GAAG,OAAO,qBAAqB,YAAY;CAChF,OAAQ,gBAAgB,YAAY,iBAAkB;AACxD;AAEA,MAAa,sBACX,YACA,iBACG;CACH,MAAM,QAAQ,qBAAqB;EACjC;EACA,OAAO,aAAa,YAAY;EAChC,MAAM;CACR,CAAC;CAED,OAAO;EACL,GAAG;EACH,qBAAqB,MAAM;EAC3B,0BAA0B,MAAM;CAClC;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "6.0.0-beta.5",
3
+ "version": "6.0.0-beta.7",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",
@@ -1,105 +0,0 @@
1
- //#region src/dashboard/StatCard/style.ts
2
- const styles = {
3
- badge: {
4
- kVAM5u: "lb6d5vuu",
5
- kaIpWk: "lb1vihcfj",
6
- ksu8eU: "lb1y0btm7",
7
- kMzoRj: "lbmkeg23",
8
- kUk6DE: "lb1okw0bk",
9
- kGNEyG: "lb6s0dn4",
10
- kWkggS: "lbaljia1",
11
- kZKoxP: "lbxk0z11",
12
- kMwMTN: "lb53gy9q",
13
- k1xSpc: "lb3nfvp2",
14
- kzqmXN: "lbvy4d1p",
15
- kjj79g: "lbl56j7k",
16
- $$css: true
17
- },
18
- body: {
19
- kVAEAm: "lb1n2onr6",
20
- kY2c9j: "lb1vjfegm",
21
- $$css: true
22
- },
23
- copy: {
24
- kwnvtZ: "lbozqiw3",
25
- k7Eaqz: "lbeuugli",
26
- $$css: true
27
- },
28
- delta: {
29
- kOIVth: "lb195vfkc",
30
- kGNEyG: "lb6s0dn4",
31
- k1xSpc: "lb3nfvp2",
32
- kGuDYH: "lbxobqjj",
33
- kcqcaj: "lbss6m8b",
34
- $$css: true
35
- },
36
- deltaDown: {
37
- kMwMTN: "lb12ap7uz",
38
- $$css: true
39
- },
40
- deltaFlat: {
41
- kMwMTN: "lb53gy9q",
42
- $$css: true
43
- },
44
- deltaUp: {
45
- kMwMTN: "lbs9y9h1",
46
- $$css: true
47
- },
48
- frame: {
49
- kVAM5u: "lb10cypdb",
50
- $$css: true
51
- },
52
- gray: {
53
- k3DiCg: "lbskafm8",
54
- $$css: true
55
- },
56
- lift: {
57
- kaIpWk: "lb1ndkxwp",
58
- kGVxlE: "lb1c4gvbl",
59
- k1xSpc: "lb78zum5",
60
- k7Eaqz: "lbeuugli",
61
- $$css: true
62
- },
63
- metricFoot: {
64
- keoZOQ: "lb1hmvnq2",
65
- $$css: true
66
- },
67
- metricValue: {
68
- kMwMTN: "lb66ogz0",
69
- kGuDYH: "lb1j9mzhl",
70
- kcqcaj: "lbss6m8b",
71
- k63SB2: "lb1xlr1w8",
72
- kLWn49: "lb1f41ap9",
73
- keoZOQ: "lb1k70j0n",
74
- $$css: true
75
- },
76
- root: {
77
- kmVPX3: "lb1tamke2",
78
- kUk6DE: "lb98rzlu",
79
- kVQacm: "lbb3r6kr",
80
- k7Eaqz: "lbeuugli",
81
- kVAEAm: "lb1n2onr6",
82
- $$css: true
83
- },
84
- value: {
85
- kMwMTN: "lb66ogz0",
86
- kGuDYH: "lb1j9mzhl lb1nfhhgm",
87
- kcqcaj: "lbss6m8b",
88
- k63SB2: "lb1s688f",
89
- kLWn49: "lb1u7k74",
90
- $$css: true
91
- },
92
- wash: {
93
- kHBbk8: "lbc8icb0",
94
- kFcpXp: "lbxx281p",
95
- kgeoSG: "lb1cpjm7i",
96
- km8f2m: "lbkk1bqk",
97
- kEoFBp: "lb1hmns74",
98
- kxmVGU: "lb2hztxu",
99
- $$css: true
100
- }
101
- };
102
- //#endregion
103
- export { styles };
104
-
105
- //# sourceMappingURL=style.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"style.mjs","names":[],"sources":["../../../src/dashboard/StatCard/style.ts"],"sourcesContent":["import * as stylex from '@stylexjs/stylex';\n\nimport { cssVar } from '@/styles/stylex/cssVar.stylex';\nimport { media } from '@/styles/stylex/media.stylex';\n\nexport const styles = stylex.create({\n badge: {\n borderColor: cssVar.colorFillSecondary,\n borderRadius: cssVar.borderRadiusSM,\n borderStyle: 'solid',\n borderWidth: 1,\n flex: 'none',\n alignItems: 'center',\n backgroundColor: cssVar.colorFillTertiary,\n blockSize: 24,\n color: cssVar.colorTextTertiary,\n display: 'inline-flex',\n inlineSize: 24,\n justifyContent: 'center',\n },\n body: {\n position: 'relative',\n zIndex: 1,\n },\n copy: {\n flexWrap: 'nowrap',\n minInlineSize: 0,\n },\n delta: {\n gap: 2,\n alignItems: 'center',\n display: 'inline-flex',\n fontSize: cssVar.fontSizeSM,\n fontVariantNumeric: 'tabular-nums',\n },\n deltaDown: {\n color: cssVar.colorError,\n },\n deltaFlat: {\n color: cssVar.colorTextTertiary,\n },\n deltaUp: {\n color: cssVar.colorSuccess,\n },\n frame: {\n borderColor: cssVar.colorBorderSecondary,\n },\n gray: {\n '::before': {\n backgroundImage: `linear-gradient(to bottom, ${cssVar.colorBgElevated} 0%, color-mix(in srgb, ${cssVar.colorText} 4%, ${cssVar.colorBgElevated}) 100%)`,\n },\n },\n lift: {\n borderRadius: cssVar.borderRadiusLG,\n boxShadow: cssVar.boxShadowTertiary,\n display: 'flex',\n minInlineSize: 0,\n },\n metricFoot: {\n marginBlockStart: 14,\n },\n metricValue: {\n color: cssVar.colorText,\n fontSize: cssVar.fontSizeHeading2,\n fontVariantNumeric: 'tabular-nums',\n fontWeight: 700,\n lineHeight: 1.05,\n marginBlockStart: 6,\n },\n root: {\n padding: 16,\n flex: '1',\n overflow: 'hidden',\n minInlineSize: 0,\n position: 'relative',\n },\n value: {\n color: cssVar.colorText,\n fontSize: { default: cssVar.fontSizeHeading2, [media.mobile]: cssVar.fontSizeHeading3 },\n fontVariantNumeric: 'tabular-nums',\n fontWeight: 600,\n lineHeight: 1.2,\n },\n wash: {\n 'isolation': 'isolate',\n '::before': {\n inset: 0,\n content: '\"\"',\n pointerEvents: 'none',\n position: 'absolute',\n zIndex: 0,\n },\n },\n});\n"],"mappings":";AAKA,MAAa,SAAS;CACpB,OAAO;EACL,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,MAAM;EACJ,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,MAAM;EACJ,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,OAAO;EACL,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,WAAW;EACT,QAAQ;EACR,OAAO;CACT;CACA,WAAW;EACT,QAAQ;EACR,OAAO;CACT;CACA,SAAS;EACP,QAAQ;EACR,OAAO;CACT;CACA,OAAO;EACL,QAAQ;EACR,OAAO;CACT;CACA,MAAM;EACJ,QAAQ;EACR,OAAO;CACT;CACA,MAAM;EACJ,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,YAAY;EACV,QAAQ;EACR,OAAO;CACT;CACA,aAAa;EACX,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,MAAM;EACJ,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,OAAO;EACL,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,MAAM;EACJ,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;AACF"}