@lobehub/ui 6.2.0 → 6.4.0

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 (44) hide show
  1. package/es/Mermaid/SyntaxMermaid/MermaidSvg.mjs +2 -3
  2. package/es/Mermaid/SyntaxMermaid/MermaidSvg.mjs.map +1 -1
  3. package/es/Mermaid/SyntaxMermaid/StaticMermaid.mjs +3 -1
  4. package/es/Mermaid/SyntaxMermaid/StaticMermaid.mjs.map +1 -1
  5. package/es/Mermaid/SyntaxMermaid/StreamMermaid.mjs +3 -4
  6. package/es/Mermaid/SyntaxMermaid/StreamMermaid.mjs.map +1 -1
  7. package/es/Mermaid/SyntaxMermaid/index.mjs +1 -1
  8. package/es/Mermaid/SyntaxMermaid/index.mjs.map +1 -1
  9. package/es/Mermaid/SyntaxMermaid/standaloneSvg.mjs +32 -0
  10. package/es/Mermaid/SyntaxMermaid/standaloneSvg.mjs.map +1 -0
  11. package/es/Mermaid/const.mjs +2 -2
  12. package/es/Mermaid/const.mjs.map +1 -1
  13. package/es/Mermaid/index.d.mts +13 -2
  14. package/es/Mermaid/index.mjs +12 -1
  15. package/es/Mermaid/index.mjs.map +1 -0
  16. package/es/Mermaid/themes.d.mts +107 -0
  17. package/es/Mermaid/themes.mjs +149 -0
  18. package/es/Mermaid/themes.mjs.map +1 -0
  19. package/es/Mermaid/type.d.mts +2 -2
  20. package/es/Text/style.d.mts +2 -2
  21. package/es/ToggleGroup/ToggleGroup.d.mts +1 -1
  22. package/es/ToggleGroup/ToggleGroup.mjs +18 -9
  23. package/es/ToggleGroup/ToggleGroup.mjs.map +1 -1
  24. package/es/ToggleGroup/atoms.mjs +16 -4
  25. package/es/ToggleGroup/atoms.mjs.map +1 -1
  26. package/es/ToggleGroup/style.d.mts +36 -2
  27. package/es/ToggleGroup/style.mjs +42 -2
  28. package/es/ToggleGroup/style.mjs.map +1 -1
  29. package/es/ToggleGroup/type.d.mts +21 -5
  30. package/es/eslint/index.d.mts +1 -1
  31. package/es/hooks/useMermaid.mjs +21 -82
  32. package/es/hooks/useMermaid.mjs.map +1 -1
  33. package/es/hooks/useStreamMermaid.mjs +22 -16
  34. package/es/hooks/useStreamMermaid.mjs.map +1 -1
  35. package/es/node_modules/.pnpm/{eslint@10.12.0_jiti@2.6.1_supports-color@10.2.2 → eslint@10.13.0_jiti@2.6.1_supports-color@10.2.2}/node_modules/eslint/lib/types/index.d.mts +1 -1
  36. package/es/style.css +6 -5
  37. package/package.json +2 -2
  38. package/es/Mermaid/SyntaxMermaid/prepareInlineSvg.mjs +0 -54
  39. package/es/Mermaid/SyntaxMermaid/prepareInlineSvg.mjs.map +0 -1
  40. package/es/Mermaid/SyntaxMermaid/prepareMermaidSvg.mjs +0 -20
  41. package/es/Mermaid/SyntaxMermaid/prepareMermaidSvg.mjs.map +0 -1
  42. package/es/hooks/useMermaidCdn.d.mts +0 -9
  43. package/es/hooks/useMermaidCdn.mjs +0 -97
  44. package/es/hooks/useMermaidCdn.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ToggleGroup.mjs","names":["clsx"],"sources":["../../src/ToggleGroup/ToggleGroup.tsx"],"sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { useMemo } from 'react';\n\nimport { useControlledState } from '@/hooks/useControlledState';\n\nimport {\n ToggleGroupItem,\n ToggleGroupItemIcon,\n ToggleGroupItemLabel,\n ToggleGroupRoot,\n} from './atoms';\nimport type { ToggleGroupOption, ToggleGroupProps } from './type';\n\nconst normalizeOption = <Value extends string>(\n option: ToggleGroupOption<Value> | Value,\n): ToggleGroupOption<Value> => (typeof option === 'string' ? { value: option } : option);\n\nconst ToggleGroup = <Value extends string = string>({\n className,\n classNames,\n defaultValue,\n disabled = false,\n onChange,\n options,\n ref,\n size = 'middle',\n style,\n styles: customStyles,\n value,\n variant = 'outlined',\n}: ToggleGroupProps<Value>) => {\n const [innerValue, setInnerValue] = useControlledState<Value | undefined>(defaultValue, {\n defaultValue,\n onChange: (next) => {\n if (next != null) onChange?.(next);\n },\n value,\n });\n\n const normalizedOptions = useMemo(\n () => (options ?? []).map((o) => normalizeOption<Value>(o)),\n [options],\n );\n\n const groupValue = useMemo<Value[]>(() => (innerValue != null ? [innerValue] : []), [innerValue]);\n\n return (\n <ToggleGroupRoot<Value>\n className={clsx(classNames?.root, className)}\n disabled={disabled}\n ref={ref}\n style={{ ...style, ...customStyles?.root }}\n value={groupValue}\n variant={variant}\n onValueChange={(next) => {\n const picked = next[0];\n if (picked != null) setInnerValue(picked);\n }}\n >\n {normalizedOptions.map((opt) => (\n <ToggleGroupItem<Value>\n aria-label={typeof opt.label === 'string' ? opt.label : opt.title}\n className={clsx(classNames?.item, opt.className)}\n disabled={disabled || opt.disabled}\n key={opt.value}\n size={size}\n style={customStyles?.item}\n title={opt.title}\n value={opt.value}\n variant={variant}\n >\n {opt.icon != null && (\n <ToggleGroupItemIcon className={classNames?.itemIcon} style={customStyles?.itemIcon}>\n {opt.icon}\n </ToggleGroupItemIcon>\n )}\n {opt.label != null && (\n <ToggleGroupItemLabel className={classNames?.itemLabel} style={customStyles?.itemLabel}>\n {opt.label}\n </ToggleGroupItemLabel>\n )}\n </ToggleGroupItem>\n ))}\n </ToggleGroupRoot>\n );\n};\n\nToggleGroup.displayName = 'ToggleGroup';\n\nexport default ToggleGroup;\n"],"mappings":";;;;;;;AAeA,MAAM,mBACJ,WAC8B,OAAO,WAAW,WAAW,EAAE,OAAO,OAAO,IAAI;AAEjF,MAAM,eAA8C,EAClD,WACA,YACA,cACA,WAAW,OACX,UACA,SACA,KACA,OAAO,UACP,OACA,QAAQ,cACR,OACA,UAAU,iBACmB;CAC7B,MAAM,CAAC,YAAY,iBAAiB,mBAAsC,cAAc;EACtF;EACA,WAAW,SAAS;GAClB,IAAI,QAAQ,MAAM,WAAW,IAAI;EACnC;EACA;CACF,CAAC;CAED,MAAM,oBAAoB,eACjB,WAAW,CAAC,EAAA,CAAG,KAAK,MAAM,gBAAuB,CAAC,CAAC,GAC1D,CAAC,OAAO,CACV;CAEA,MAAM,aAAa,cAAwB,cAAc,OAAO,CAAC,UAAU,IAAI,CAAC,GAAI,CAAC,UAAU,CAAC;CAEhG,OACE,oBAAC,iBAAD;EACE,WAAWA,OAAK,YAAY,MAAM,SAAS;EACjC;EACL;EACL,OAAO;GAAE,GAAG;GAAO,GAAG,cAAc;EAAK;EACzC,OAAO;EACE;EACT,gBAAgB,SAAS;GACvB,MAAM,SAAS,KAAK;GACpB,IAAI,UAAU,MAAM,cAAc,MAAM;EAC1C;EAEC,UAAA,kBAAkB,KAAK,QACtB,qBAAC,iBAAD;GACE,cAAY,OAAO,IAAI,UAAU,WAAW,IAAI,QAAQ,IAAI;GAC5D,WAAWA,OAAK,YAAY,MAAM,IAAI,SAAS;GAC/C,UAAU,YAAY,IAAI;GAEpB;GACN,OAAO,cAAc;GACrB,OAAO,IAAI;GACX,OAAO,IAAI;GACF;GATX,UAAA,CAWG,IAAI,QAAQ,QACX,oBAAC,qBAAD;IAAqB,WAAW,YAAY;IAAU,OAAO,cAAc;IACxE,UAAA,IAAI;GACc,CAAA,GAEtB,IAAI,SAAS,QACZ,oBAAC,sBAAD;IAAsB,WAAW,YAAY;IAAW,OAAO,cAAc;IAC1E,UAAA,IAAI;GACe,CAAA,CAET;EAjBV,GAAA,IAAI,KAiBM,CAClB;CACc,CAAA;AAErB;AAEA,YAAY,cAAc"}
1
+ {"version":3,"file":"ToggleGroup.mjs","names":["clsx"],"sources":["../../src/ToggleGroup/ToggleGroup.tsx"],"sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { type CSSProperties, type Ref, useMemo } from 'react';\n\nimport { useControlledState } from '@/hooks/useControlledState';\n\nimport {\n ToggleGroupItem,\n ToggleGroupItemIcon,\n ToggleGroupItemLabel,\n ToggleGroupRoot,\n} from './atoms';\nimport type {\n ToggleGroupClassNames,\n ToggleGroupOption,\n ToggleGroupProps,\n ToggleGroupSize,\n ToggleGroupStyles,\n ToggleGroupVariant,\n} from './type';\n\nconst normalizeOption = <Value extends string>(\n option: ToggleGroupOption<Value> | Value,\n): ToggleGroupOption<Value> => (typeof option === 'string' ? { value: option } : option);\n\nconst toValueArray = <Value extends string>(value?: Value | Value[]): Value[] => {\n if (value === undefined) return [];\n return Array.isArray(value) ? value : [value];\n};\n\ninterface InternalProps<Value extends string = string> {\n className?: string;\n classNames?: ToggleGroupClassNames;\n defaultValue?: Value | Value[];\n disabled?: boolean;\n multiple?: boolean;\n onChange?: (value: Value | Value[]) => void;\n options?: (ToggleGroupOption<Value> | Value)[];\n ref?: Ref<HTMLDivElement>;\n size?: ToggleGroupSize;\n style?: CSSProperties;\n styles?: ToggleGroupStyles;\n value?: Value | Value[];\n variant?: ToggleGroupVariant;\n}\n\nconst ToggleGroup = <Value extends string = string>(props: ToggleGroupProps<Value>) => {\n const {\n className,\n classNames,\n defaultValue,\n disabled = false,\n multiple = false,\n onChange,\n options,\n ref,\n size = 'middle',\n style,\n styles: customStyles,\n value,\n variant = multiple ? 'segmented' : 'outlined',\n } = props as InternalProps<Value>;\n\n const [innerValues, setInnerValues] = useControlledState<Value[]>(toValueArray(defaultValue), {\n defaultValue: toValueArray(defaultValue),\n onChange: (next) => {\n if (multiple) {\n onChange?.(next);\n return;\n }\n if (next[0] !== undefined) onChange?.(next[0]);\n },\n value: value === undefined ? undefined : toValueArray(value),\n });\n\n const normalizedOptions = useMemo(\n () => (options ?? []).map((o) => normalizeOption<Value>(o)),\n [options],\n );\n\n return (\n <ToggleGroupRoot<Value>\n className={clsx(classNames?.root, className)}\n disabled={disabled}\n multiple={multiple}\n ref={ref}\n style={{ ...style, ...customStyles?.root }}\n value={innerValues}\n variant={variant}\n onValueChange={(next) => {\n // In single mode the pressed item is locked: Base UI reports an empty\n // array when it is clicked again, which must not clear the selection.\n if (!multiple && next.length === 0) return;\n setInnerValues(next);\n }}\n >\n {normalizedOptions.map((opt) => (\n <ToggleGroupItem<Value>\n aria-label={typeof opt.label === 'string' ? opt.label : opt.title}\n className={clsx(classNames?.item, opt.className)}\n disabled={disabled || opt.disabled}\n key={opt.value}\n size={size}\n style={customStyles?.item}\n title={opt.title}\n value={opt.value}\n variant={variant}\n >\n {opt.icon != null && (\n <ToggleGroupItemIcon className={classNames?.itemIcon} style={customStyles?.itemIcon}>\n {opt.icon}\n </ToggleGroupItemIcon>\n )}\n {opt.label != null && (\n <ToggleGroupItemLabel className={classNames?.itemLabel} style={customStyles?.itemLabel}>\n {opt.label}\n </ToggleGroupItemLabel>\n )}\n </ToggleGroupItem>\n ))}\n </ToggleGroupRoot>\n );\n};\n\nToggleGroup.displayName = 'ToggleGroup';\n\nexport default ToggleGroup;\n"],"mappings":";;;;;;;AAsBA,MAAM,mBACJ,WAC8B,OAAO,WAAW,WAAW,EAAE,OAAO,OAAO,IAAI;AAEjF,MAAM,gBAAsC,UAAqC;CAC/E,IAAI,UAAU,KAAA,GAAW,OAAO,CAAC;CACjC,OAAO,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK;AAC9C;AAkBA,MAAM,eAA8C,UAAmC;CACrF,MAAM,EACJ,WACA,YACA,cACA,WAAW,OACX,WAAW,OACX,UACA,SACA,KACA,OAAO,UACP,OACA,QAAQ,cACR,OACA,UAAU,WAAW,cAAc,eACjC;CAEJ,MAAM,CAAC,aAAa,kBAAkB,mBAA4B,aAAa,YAAY,GAAG;EAC5F,cAAc,aAAa,YAAY;EACvC,WAAW,SAAS;GAClB,IAAI,UAAU;IACZ,WAAW,IAAI;IACf;GACF;GACA,IAAI,KAAK,OAAO,KAAA,GAAW,WAAW,KAAK,EAAE;EAC/C;EACA,OAAO,UAAU,KAAA,IAAY,KAAA,IAAY,aAAa,KAAK;CAC7D,CAAC;CAED,MAAM,oBAAoB,eACjB,WAAW,CAAC,EAAA,CAAG,KAAK,MAAM,gBAAuB,CAAC,CAAC,GAC1D,CAAC,OAAO,CACV;CAEA,OACE,oBAAC,iBAAD;EACE,WAAWA,OAAK,YAAY,MAAM,SAAS;EACjC;EACA;EACL;EACL,OAAO;GAAE,GAAG;GAAO,GAAG,cAAc;EAAK;EACzC,OAAO;EACE;EACT,gBAAgB,SAAS;GAGvB,IAAI,CAAC,YAAY,KAAK,WAAW,GAAG;GACpC,eAAe,IAAI;EACrB;EAEC,UAAA,kBAAkB,KAAK,QACtB,qBAAC,iBAAD;GACE,cAAY,OAAO,IAAI,UAAU,WAAW,IAAI,QAAQ,IAAI;GAC5D,WAAWA,OAAK,YAAY,MAAM,IAAI,SAAS;GAC/C,UAAU,YAAY,IAAI;GAEpB;GACN,OAAO,cAAc;GACrB,OAAO,IAAI;GACX,OAAO,IAAI;GACF;GATX,UAAA,CAWG,IAAI,QAAQ,QACX,oBAAC,qBAAD;IAAqB,WAAW,YAAY;IAAU,OAAO,cAAc;IACxE,UAAA,IAAI;GACc,CAAA,GAEtB,IAAI,SAAS,QACZ,oBAAC,sBAAD;IAAsB,WAAW,YAAY;IAAW,OAAO,cAAc;IAC1E,UAAA,IAAI;GACe,CAAA,CAET;EAjBV,GAAA,IAAI,KAiBM,CAClB;CACc,CAAA;AAErB;AAEA,YAAY,cAAc"}
@@ -11,30 +11,42 @@ import { ToggleGroup } from "@base-ui/react/toggle-group";
11
11
  //#region src/ToggleGroup/atoms.tsx
12
12
  const rootVariantStyles = {
13
13
  borderless: styles.rootBorderless,
14
- outlined: styles.rootOutlined
14
+ outlined: styles.rootOutlined,
15
+ segmented: styles.rootSegmented
15
16
  };
16
17
  const itemSizeStyles = {
17
18
  middle: styles.itemMiddle,
18
19
  small: styles.itemSmall
19
20
  };
21
+ const itemSegmentedSizeStyles = {
22
+ middle: styles.itemSegmentedMiddle,
23
+ small: styles.itemSegmentedSmall
24
+ };
20
25
  const itemVariantStyles = {
21
- borderless: null,
22
- outlined: [toggleGroupItemMarker, styles.itemOutlined]
26
+ borderless: [styles.itemTone],
27
+ outlined: [
28
+ toggleGroupItemMarker,
29
+ styles.itemOutlined,
30
+ styles.itemTone
31
+ ],
32
+ segmented: [styles.itemSegmented, styles.itemSegmentedTone]
23
33
  };
24
34
  const ToggleGroupRoot = ({ className, variant = "outlined", ...rest }) => {
25
35
  return /* @__PURE__ */ jsx(ToggleGroup, {
26
36
  className: styleProps([styles.root, rootVariantStyles[variant]], className).className,
37
+ "data-variant": variant,
27
38
  ...rest
28
39
  });
29
40
  };
30
41
  ToggleGroupRoot.displayName = "ToggleGroupRoot";
31
42
  const ToggleGroupItem = ({ className, size = "middle", variant = "outlined", ...rest }) => {
43
+ const sizeStyle = variant === "segmented" ? itemSegmentedSizeStyles[size] : itemSizeStyles[size];
32
44
  return /* @__PURE__ */ jsx(Toggle, {
33
45
  ...rest,
34
46
  className: styleProps([
35
47
  styles.item,
36
48
  focusRing.info,
37
- itemSizeStyles[size],
49
+ sizeStyle,
38
50
  itemVariantStyles[variant]
39
51
  ], className).className
40
52
  });
@@ -1 +1 @@
1
- {"version":3,"file":"atoms.mjs","names":["BaseUIToggleGroup","BaseUIToggle","clsx"],"sources":["../../src/ToggleGroup/atoms.tsx"],"sourcesContent":["'use client';\n\nimport { Toggle as BaseUIToggle } from '@base-ui/react/toggle';\nimport { ToggleGroup as BaseUIToggleGroup } from '@base-ui/react/toggle-group';\nimport * as stylex from '@stylexjs/stylex';\nimport clsx from 'clsx';\nimport { type ComponentProps, type CSSProperties, type FC, type ReactNode } from 'react';\n\nimport { focusRing } from '@/styles/stylex/focusRing';\nimport { styleProps } from '@/styles/stylex/props';\n\nimport { toggleGroupItemMarker } from './marker.stylex';\nimport { styles } from './style';\nimport type { ToggleGroupSize, ToggleGroupVariant } from './type';\n\nconst rootVariantStyles = { borderless: styles.rootBorderless, outlined: styles.rootOutlined };\n\nconst itemSizeStyles = { middle: styles.itemMiddle, small: styles.itemSmall };\n\nconst itemVariantStyles = {\n borderless: null,\n outlined: [toggleGroupItemMarker, styles.itemOutlined],\n};\n\nexport type ToggleGroupRootProps<Value extends string = string> = Omit<\n ComponentProps<typeof BaseUIToggleGroup<Value>>,\n 'className' | 'render'\n> & {\n className?: string;\n variant?: ToggleGroupVariant;\n};\n\nexport const ToggleGroupRoot = <Value extends string = string>({\n className,\n variant = 'outlined',\n ...rest\n}: ToggleGroupRootProps<Value>) => {\n return (\n <BaseUIToggleGroup<Value>\n className={styleProps([styles.root, rootVariantStyles[variant]], className).className}\n {...rest}\n />\n );\n};\n\nToggleGroupRoot.displayName = 'ToggleGroupRoot';\n\nexport type ToggleGroupItemProps<Value extends string = string> = Omit<\n ComponentProps<typeof BaseUIToggle<Value>>,\n 'className' | 'render'\n> & {\n className?: string;\n size?: ToggleGroupSize;\n variant?: ToggleGroupVariant;\n};\n\nexport const ToggleGroupItem = <Value extends string = string>({\n className,\n size = 'middle',\n variant = 'outlined',\n ...rest\n}: ToggleGroupItemProps<Value>) => {\n return (\n <BaseUIToggle<Value>\n {...rest}\n className={\n styleProps(\n [styles.item, focusRing.info, itemSizeStyles[size], itemVariantStyles[variant]],\n className,\n ).className\n }\n />\n );\n};\n\nToggleGroupItem.displayName = 'ToggleGroupItem';\n\ninterface SimpleSpanProps {\n children?: ReactNode;\n className?: string;\n style?: CSSProperties;\n}\n\nexport const ToggleGroupItemIcon: FC<SimpleSpanProps> = ({ children, className, style }) => (\n <span {...styleProps(styles.itemIcon, className, style)}>{children}</span>\n);\nToggleGroupItemIcon.displayName = 'ToggleGroupItemIcon';\n\nexport const ToggleGroupItemLabel: FC<SimpleSpanProps> = ({ children, className, style }) => (\n <span {...styleProps(styles.itemLabel, clsx('toggle-group-item-label', className), style)}>\n {children}\n </span>\n);\nToggleGroupItemLabel.displayName = 'ToggleGroupItemLabel';\n\nexport const toggleGroupStyles = Object.fromEntries(\n Object.entries(styles).map(([key, value]) => [key, stylex.props(value).className ?? '']),\n) as Record<keyof typeof styles, string>;\n"],"mappings":";;;;;;;;;;;AAYA,MAAM,oBAAoB;CACxB,YAAY,OAAO;CACnB,UAAU,OAAO;AACnB;AACA,MAAM,iBAAiB;CACrB,QAAQ,OAAO;CACf,OAAO,OAAO;AAChB;AACA,MAAM,oBAAoB;CACxB,YAAY;CACZ,UAAU,CAAC,uBAAuB,OAAO,YAAY;AACvD;AAKA,MAAa,mBAAmD,EAC9D,WACA,UAAU,YACV,GAAG,WAC8B;CACjC,OAAO,oBAACA,aAAD;EAA0B,WAAW,WAAW,CAAC,OAAO,MAAM,kBAAkB,QAAQ,GAAG,SAAS,CAAC,CAAC;EAAW,GAAI;CAAO,CAAA;AACrI;AACA,gBAAgB,cAAc;AAM9B,MAAa,mBAAmD,EAC9D,WACA,OAAO,UACP,UAAU,YACV,GAAG,WAC8B;CACjC,OAAO,oBAACC,QAAD;EAAqB,GAAI;EAAM,WAAW,WAAW;GAAC,OAAO;GAAM,UAAU;GAAM,eAAe;GAAO,kBAAkB;EAAQ,GAAG,SAAS,CAAC,CAAC;CAAY,CAAA;AACtK;AACA,gBAAgB,cAAc;AAM9B,MAAa,uBAA4C,EACvD,UACA,WACA,YACI,oBAAC,QAAD;CAAM,GAAI,WAAW,OAAO,UAAU,WAAW,KAAK;CAAI;AAAe,CAAA;AAC/E,oBAAoB,cAAc;AAClC,MAAa,wBAA6C,EACxD,UACA,WACA,YACI,oBAAC,QAAD;CAAM,GAAI,WAAW,OAAO,WAAWC,OAAK,2BAA2B,SAAS,GAAG,KAAK;CACzF;AACG,CAAA;AACR,qBAAqB,cAAc;AACnC,MAAa,oBAAoB,OAAO,YAAY,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,CAAC,KAAK,OAAO,MAAM,KAAK,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC"}
1
+ {"version":3,"file":"atoms.mjs","names":["BaseUIToggleGroup","BaseUIToggle","clsx"],"sources":["../../src/ToggleGroup/atoms.tsx"],"sourcesContent":["'use client';\n\nimport { Toggle as BaseUIToggle } from '@base-ui/react/toggle';\nimport { ToggleGroup as BaseUIToggleGroup } from '@base-ui/react/toggle-group';\nimport * as stylex from '@stylexjs/stylex';\nimport clsx from 'clsx';\nimport { type ComponentProps, type CSSProperties, type FC, type ReactNode } from 'react';\n\nimport { focusRing } from '@/styles/stylex/focusRing';\nimport { styleProps } from '@/styles/stylex/props';\n\nimport { toggleGroupItemMarker } from './marker.stylex';\nimport { styles } from './style';\nimport type { ToggleGroupSize, ToggleGroupVariant } from './type';\n\nconst rootVariantStyles = {\n borderless: styles.rootBorderless,\n outlined: styles.rootOutlined,\n segmented: styles.rootSegmented,\n};\n\nconst itemSizeStyles = { middle: styles.itemMiddle, small: styles.itemSmall };\n\nconst itemSegmentedSizeStyles = {\n middle: styles.itemSegmentedMiddle,\n small: styles.itemSegmentedSmall,\n};\n\nconst itemVariantStyles = {\n borderless: [styles.itemTone],\n outlined: [toggleGroupItemMarker, styles.itemOutlined, styles.itemTone],\n segmented: [styles.itemSegmented, styles.itemSegmentedTone],\n};\n\nexport type ToggleGroupRootProps<Value extends string = string> = Omit<\n ComponentProps<typeof BaseUIToggleGroup<Value>>,\n 'className' | 'render'\n> & {\n className?: string;\n variant?: ToggleGroupVariant;\n};\n\nexport const ToggleGroupRoot = <Value extends string = string>({\n className,\n variant = 'outlined',\n ...rest\n}: ToggleGroupRootProps<Value>) => {\n return (\n <BaseUIToggleGroup<Value>\n className={styleProps([styles.root, rootVariantStyles[variant]], className).className}\n data-variant={variant}\n {...rest}\n />\n );\n};\n\nToggleGroupRoot.displayName = 'ToggleGroupRoot';\n\nexport type ToggleGroupItemProps<Value extends string = string> = Omit<\n ComponentProps<typeof BaseUIToggle<Value>>,\n 'className' | 'render'\n> & {\n className?: string;\n size?: ToggleGroupSize;\n variant?: ToggleGroupVariant;\n};\n\nexport const ToggleGroupItem = <Value extends string = string>({\n className,\n size = 'middle',\n variant = 'outlined',\n ...rest\n}: ToggleGroupItemProps<Value>) => {\n const sizeStyle = variant === 'segmented' ? itemSegmentedSizeStyles[size] : itemSizeStyles[size];\n\n return (\n <BaseUIToggle<Value>\n {...rest}\n className={\n styleProps([styles.item, focusRing.info, sizeStyle, itemVariantStyles[variant]], className)\n .className\n }\n />\n );\n};\n\nToggleGroupItem.displayName = 'ToggleGroupItem';\n\ninterface SimpleSpanProps {\n children?: ReactNode;\n className?: string;\n style?: CSSProperties;\n}\n\nexport const ToggleGroupItemIcon: FC<SimpleSpanProps> = ({ children, className, style }) => (\n <span {...styleProps(styles.itemIcon, className, style)}>{children}</span>\n);\nToggleGroupItemIcon.displayName = 'ToggleGroupItemIcon';\n\nexport const ToggleGroupItemLabel: FC<SimpleSpanProps> = ({ children, className, style }) => (\n <span {...styleProps(styles.itemLabel, clsx('toggle-group-item-label', className), style)}>\n {children}\n </span>\n);\nToggleGroupItemLabel.displayName = 'ToggleGroupItemLabel';\n\nexport const toggleGroupStyles = Object.fromEntries(\n Object.entries(styles).map(([key, value]) => [key, stylex.props(value).className ?? '']),\n) as Record<keyof typeof styles, string>;\n"],"mappings":";;;;;;;;;;;AAYA,MAAM,oBAAoB;CACxB,YAAY,OAAO;CACnB,UAAU,OAAO;CACjB,WAAW,OAAO;AACpB;AACA,MAAM,iBAAiB;CACrB,QAAQ,OAAO;CACf,OAAO,OAAO;AAChB;AACA,MAAM,0BAA0B;CAC9B,QAAQ,OAAO;CACf,OAAO,OAAO;AAChB;AACA,MAAM,oBAAoB;CACxB,YAAY,CAAC,OAAO,QAAQ;CAC5B,UAAU;EAAC;EAAuB,OAAO;EAAc,OAAO;CAAQ;CACtE,WAAW,CAAC,OAAO,eAAe,OAAO,iBAAiB;AAC5D;AAKA,MAAa,mBAAmD,EAC9D,WACA,UAAU,YACV,GAAG,WAC8B;CACjC,OAAO,oBAACA,aAAD;EAA0B,WAAW,WAAW,CAAC,OAAO,MAAM,kBAAkB,QAAQ,GAAG,SAAS,CAAC,CAAC;EAAW,gBAAc;EAAS,GAAI;CAAO,CAAA;AAC5J;AACA,gBAAgB,cAAc;AAM9B,MAAa,mBAAmD,EAC9D,WACA,OAAO,UACP,UAAU,YACV,GAAG,WAC8B;CACjC,MAAM,YAAY,YAAY,cAAc,wBAAwB,QAAQ,eAAe;CAC3F,OAAO,oBAACC,QAAD;EAAqB,GAAI;EAAM,WAAW,WAAW;GAAC,OAAO;GAAM,UAAU;GAAM;GAAW,kBAAkB;EAAQ,GAAG,SAAS,CAAC,CAAC;CAAY,CAAA;AAC3J;AACA,gBAAgB,cAAc;AAM9B,MAAa,uBAA4C,EACvD,UACA,WACA,YACI,oBAAC,QAAD;CAAM,GAAI,WAAW,OAAO,UAAU,WAAW,KAAK;CAAI;AAAe,CAAA;AAC/E,oBAAoB,cAAc;AAClC,MAAa,wBAA6C,EACxD,UACA,WACA,YACI,oBAAC,QAAD;CAAM,GAAI,WAAW,OAAO,WAAWC,OAAK,2BAA2B,SAAS,GAAG,KAAK;CACzF;AACG,CAAA;AACR,qBAAqB,cAAc;AACnC,MAAa,oBAAoB,OAAO,YAAY,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,CAAC,KAAK,OAAO,MAAM,KAAK,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC"}
@@ -11,8 +11,6 @@ export declare const styles: Readonly<{
11
11
  readonly outline: stylex.StyleXClassNameFor<"outline", "none">;
12
12
  readonly transition: stylex.StyleXClassNameFor<"transition", `background 120ms ${string}, color 120ms ${string}`>;
13
13
  readonly alignItems: stylex.StyleXClassNameFor<"alignItems", "center">;
14
- readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", string>;
15
- readonly color: stylex.StyleXClassNameFor<"color", string>;
16
14
  readonly cursor: stylex.StyleXClassNameFor<"cursor", "pointer" | "not-allowed">;
17
15
  readonly display: stylex.StyleXClassNameFor<"display", "inline-flex">;
18
16
  readonly flexShrink: stylex.StyleXClassNameFor<"flexShrink", 0>;
@@ -40,10 +38,34 @@ export declare const styles: Readonly<{
40
38
  readonly borderInlineStartStyle: stylex.StyleXClassNameFor<"borderInlineStartStyle", "solid" | null>;
41
39
  readonly borderInlineStartWidth: stylex.StyleXClassNameFor<"borderInlineStartWidth", 1 | null>;
42
40
  }>;
41
+ readonly itemSegmented: Readonly<{
42
+ readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
43
+ readonly boxSizing: stylex.StyleXClassNameFor<"boxSizing", "border-box">;
44
+ readonly fontWeight: stylex.StyleXClassNameFor<"fontWeight", 500>;
45
+ readonly position: stylex.StyleXClassNameFor<"position", "relative">;
46
+ }>;
47
+ readonly itemSegmentedMiddle: Readonly<{
48
+ readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", 12>;
49
+ readonly fontSize: stylex.StyleXClassNameFor<"fontSize", 13>;
50
+ readonly height: stylex.StyleXClassNameFor<"height", 32>;
51
+ }>;
52
+ readonly itemSegmentedSmall: Readonly<{
53
+ readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", 10>;
54
+ readonly fontSize: stylex.StyleXClassNameFor<"fontSize", 12>;
55
+ readonly height: stylex.StyleXClassNameFor<"height", 26>;
56
+ }>;
57
+ readonly itemSegmentedTone: Readonly<{
58
+ readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", string>;
59
+ readonly color: stylex.StyleXClassNameFor<"color", string>;
60
+ }>;
43
61
  readonly itemSmall: Readonly<{
44
62
  readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", 6>;
45
63
  readonly height: stylex.StyleXClassNameFor<"height", 24>;
46
64
  }>;
65
+ readonly itemTone: Readonly<{
66
+ readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", string>;
67
+ readonly color: stylex.StyleXClassNameFor<"color", string>;
68
+ }>;
47
69
  readonly root: Readonly<{
48
70
  readonly alignItems: stylex.StyleXClassNameFor<"alignItems", "center">;
49
71
  readonly display: stylex.StyleXClassNameFor<"display", "inline-flex">;
@@ -58,6 +80,18 @@ export declare const styles: Readonly<{
58
80
  readonly borderWidth: stylex.StyleXClassNameFor<"borderWidth", 1>;
59
81
  readonly overflow: stylex.StyleXClassNameFor<"overflow", "hidden">;
60
82
  }>;
83
+ readonly rootSegmented: Readonly<{
84
+ readonly padding: stylex.StyleXClassNameFor<"padding", 3>;
85
+ readonly borderColor: stylex.StyleXClassNameFor<"borderColor", string>;
86
+ readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
87
+ readonly borderStyle: stylex.StyleXClassNameFor<"borderStyle", "solid">;
88
+ readonly borderWidth: stylex.StyleXClassNameFor<"borderWidth", 1>;
89
+ readonly gap: stylex.StyleXClassNameFor<"gap", 4>;
90
+ readonly alignItems: stylex.StyleXClassNameFor<"alignItems", "center">;
91
+ readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", string>;
92
+ readonly boxSizing: stylex.StyleXClassNameFor<"boxSizing", "border-box">;
93
+ readonly display: stylex.StyleXClassNameFor<"display", "inline-flex">;
94
+ }>;
61
95
  }>;
62
96
  //#endregion
63
97
  //# sourceMappingURL=style.d.mts.map
@@ -10,8 +10,6 @@ const styles = {
10
10
  kI3sdo: "lb1a2a7pz",
11
11
  kmkexE: "lb1whbijk",
12
12
  kGNEyG: "lb6s0dn4",
13
- kWkggS: "lbjbqb8w lb1rjvrxj lb1d0xo12 lb1rbaw9i lb1hhsbb9",
14
- kMwMTN: "lb53gy9q lb530zvf lb2poks1 lb1uh4nfb",
15
13
  kkrTdU: "lb1ypdohk lb5ezrf1",
16
14
  k1xSpc: "lb3nfvp2",
17
15
  kmuXW: "lb2lah0s",
@@ -44,11 +42,40 @@ const styles = {
44
42
  k2ei4v: "lb1wutzi2",
45
43
  $$css: true
46
44
  },
45
+ itemSegmented: {
46
+ kaIpWk: "lb1sbi92r",
47
+ kB7OPa: "lb9f619",
48
+ k63SB2: "lbk50ysn",
49
+ kVAEAm: "lb1n2onr6",
50
+ $$css: true
51
+ },
52
+ itemSegmentedMiddle: {
53
+ kg3NbH: "lbaope02",
54
+ kGuDYH: "lb4z9k3i",
55
+ kZKoxP: "lb10w6t97",
56
+ $$css: true
57
+ },
58
+ itemSegmentedSmall: {
59
+ kg3NbH: "lb1awh872",
60
+ kGuDYH: "lbfifm61",
61
+ kZKoxP: "lbd7y6wv",
62
+ $$css: true
63
+ },
64
+ itemSegmentedTone: {
65
+ kWkggS: "lbjbqb8w lb14mr86t",
66
+ kMwMTN: "lbc77et8 lb3fdyxb lb2poks1 lb1y4fyfr",
67
+ $$css: true
68
+ },
47
69
  itemSmall: {
48
70
  kg3NbH: "lb1xijbu4",
49
71
  kZKoxP: "lbxk0z11",
50
72
  $$css: true
51
73
  },
74
+ itemTone: {
75
+ kWkggS: "lbjbqb8w lb1rjvrxj lb1d0xo12 lb1rbaw9i lb1hhsbb9",
76
+ kMwMTN: "lb53gy9q lb530zvf lb2poks1 lb1uh4nfb",
77
+ $$css: true
78
+ },
52
79
  root: {
53
80
  kGNEyG: "lb6s0dn4",
54
81
  k1xSpc: "lb3nfvp2",
@@ -65,6 +92,19 @@ const styles = {
65
92
  kMzoRj: "lbmkeg23",
66
93
  kVQacm: "lbb3r6kr",
67
94
  $$css: true
95
+ },
96
+ rootSegmented: {
97
+ kmVPX3: "lb9ms5i6",
98
+ kVAM5u: "lb1g3whta",
99
+ kaIpWk: "lb1ndkxwp",
100
+ ksu8eU: "lb1y0btm7",
101
+ kMzoRj: "lbmkeg23",
102
+ kOIVth: "lb1jnr06f",
103
+ kGNEyG: "lb6s0dn4",
104
+ kWkggS: "lb41ilrr",
105
+ kB7OPa: "lb9f619",
106
+ k1xSpc: "lb3nfvp2",
107
+ $$css: true
68
108
  }
69
109
  };
70
110
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"style.mjs","names":[],"sources":["../../src/ToggleGroup/style.ts"],"sourcesContent":["import * as stylex from '@stylexjs/stylex';\n\nimport { cssVar } from '@/styles/stylex/cssVar.stylex';\n\nimport { toggleGroupItemMarker } from './marker.stylex';\n\nexport const styles = stylex.create({\n item: {\n font: 'inherit',\n borderColor: 'currentcolor',\n borderRadius: cssVar.borderRadius,\n borderStyle: 'none',\n borderWidth: 0,\n gap: 4,\n outline: 'none',\n transition: `background 120ms ${cssVar.motionEaseOut}, color 120ms ${cssVar.motionEaseOut}`,\n alignItems: 'center',\n backgroundColor: {\n 'default': 'transparent',\n ':hover:not([data-disabled]):not([data-pressed])': cssVar.colorFillSecondary,\n ':is([data-pressed]):hover:not([data-disabled])': cssVar.colorFill,\n ':is([data-pressed]):is([data-disabled])': cssVar.colorFillSecondary,\n ':is([data-pressed]):not(:hover)': cssVar.colorFillSecondary,\n },\n color: {\n 'default': cssVar.colorTextTertiary,\n ':hover:not([data-disabled])': cssVar.colorTextSecondary,\n ':is([data-disabled])': cssVar.colorTextDisabled,\n ':is([data-pressed]):not(:hover):not([data-disabled])': cssVar.colorText,\n },\n cursor: { 'default': 'pointer', ':is([data-disabled])': 'not-allowed' },\n display: 'inline-flex',\n flexShrink: 0,\n fontSize: 12,\n justifyContent: 'center',\n userSelect: 'none',\n whiteSpace: 'nowrap',\n },\n itemIcon: {\n alignItems: 'center',\n display: 'inline-flex',\n flexShrink: 0,\n },\n itemLabel: {\n alignItems: 'center',\n display: 'inline-flex',\n },\n itemMiddle: {\n paddingInline: 8,\n height: 28,\n },\n itemOutlined: {\n borderRadius: 0,\n borderInlineStartColor: {\n default: null,\n [stylex.when.siblingBefore(':is(*)', toggleGroupItemMarker)]: cssVar.colorBorderSecondary,\n },\n borderInlineStartStyle: {\n default: null,\n [stylex.when.siblingBefore(':is(*)', toggleGroupItemMarker)]: 'solid',\n },\n borderInlineStartWidth: {\n default: null,\n [stylex.when.siblingBefore(':is(*)', toggleGroupItemMarker)]: 1,\n },\n },\n itemSmall: {\n paddingInline: 6,\n height: 24,\n },\n root: {\n alignItems: 'center',\n display: 'inline-flex',\n },\n rootBorderless: {\n gap: 2,\n },\n rootOutlined: {\n borderColor: cssVar.colorBorderSecondary,\n borderRadius: cssVar.borderRadius,\n borderStyle: 'solid',\n borderWidth: 1,\n overflow: 'hidden',\n },\n});\n"],"mappings":";AAKA,MAAa,SAAS;CACpB,MAAM;EACJ,QAAQ;EACR,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;EACP,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,UAAU;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,OAAO;CACT;CACA,WAAW;EACT,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,YAAY;EACV,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,cAAc;EACZ,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,WAAW;EACT,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,MAAM;EACJ,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,gBAAgB;EACd,QAAQ;EACR,OAAO;CACT;CACA,cAAc;EACZ,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"style.mjs","names":[],"sources":["../../src/ToggleGroup/style.ts"],"sourcesContent":["import * as stylex from '@stylexjs/stylex';\n\nimport { cssVar } from '@/styles/stylex/cssVar.stylex';\n\nimport { toggleGroupItemMarker } from './marker.stylex';\n\nexport const styles = stylex.create({\n item: {\n font: 'inherit',\n borderColor: 'currentcolor',\n borderRadius: cssVar.borderRadius,\n borderStyle: 'none',\n borderWidth: 0,\n gap: 4,\n outline: 'none',\n transition: `background 120ms ${cssVar.motionEaseOut}, color 120ms ${cssVar.motionEaseOut}`,\n alignItems: 'center',\n cursor: { 'default': 'pointer', ':is([data-disabled])': 'not-allowed' },\n display: 'inline-flex',\n flexShrink: 0,\n fontSize: 12,\n justifyContent: 'center',\n userSelect: 'none',\n whiteSpace: 'nowrap',\n },\n itemIcon: {\n alignItems: 'center',\n display: 'inline-flex',\n flexShrink: 0,\n },\n itemLabel: {\n alignItems: 'center',\n display: 'inline-flex',\n },\n itemMiddle: {\n paddingInline: 8,\n height: 28,\n },\n itemOutlined: {\n borderRadius: 0,\n borderInlineStartColor: {\n default: null,\n [stylex.when.siblingBefore(':is(*)', toggleGroupItemMarker)]: cssVar.colorBorderSecondary,\n },\n borderInlineStartStyle: {\n default: null,\n [stylex.when.siblingBefore(':is(*)', toggleGroupItemMarker)]: 'solid',\n },\n borderInlineStartWidth: {\n default: null,\n [stylex.when.siblingBefore(':is(*)', toggleGroupItemMarker)]: 1,\n },\n },\n itemSegmented: {\n borderRadius: cssVar.borderRadius,\n boxSizing: 'border-box',\n fontWeight: 500,\n position: 'relative',\n },\n itemSegmentedMiddle: {\n paddingInline: 12,\n fontSize: 13,\n height: 32,\n },\n itemSegmentedSmall: {\n paddingInline: 10,\n fontSize: 12,\n height: 26,\n },\n itemSegmentedTone: {\n backgroundColor: {\n 'default': 'transparent',\n ':is([data-pressed])': cssVar.colorBgElevated,\n },\n color: {\n 'default': cssVar.colorTextSecondary,\n ':hover:not([data-disabled]):not([data-pressed])': cssVar.colorText,\n ':is([data-disabled])': cssVar.colorTextDisabled,\n ':is([data-pressed]):not([data-disabled])': cssVar.colorText,\n },\n },\n itemSmall: {\n paddingInline: 6,\n height: 24,\n },\n itemTone: {\n backgroundColor: {\n 'default': 'transparent',\n ':hover:not([data-disabled]):not([data-pressed])': cssVar.colorFillSecondary,\n ':is([data-pressed]):hover:not([data-disabled])': cssVar.colorFill,\n ':is([data-pressed]):is([data-disabled])': cssVar.colorFillSecondary,\n ':is([data-pressed]):not(:hover)': cssVar.colorFillSecondary,\n },\n color: {\n 'default': cssVar.colorTextTertiary,\n ':hover:not([data-disabled])': cssVar.colorTextSecondary,\n ':is([data-disabled])': cssVar.colorTextDisabled,\n ':is([data-pressed]):not(:hover):not([data-disabled])': cssVar.colorText,\n },\n },\n root: {\n alignItems: 'center',\n display: 'inline-flex',\n },\n rootBorderless: {\n gap: 2,\n },\n rootOutlined: {\n borderColor: cssVar.colorBorderSecondary,\n borderRadius: cssVar.borderRadius,\n borderStyle: 'solid',\n borderWidth: 1,\n overflow: 'hidden',\n },\n rootSegmented: {\n padding: 3,\n borderColor: cssVar.colorFillQuaternary,\n borderRadius: cssVar.borderRadiusLG,\n borderStyle: 'solid',\n borderWidth: 1,\n gap: 4,\n alignItems: 'center',\n backgroundColor: cssVar.colorBgLayout,\n boxSizing: 'border-box',\n display: 'inline-flex',\n },\n});\n"],"mappings":";AAKA,MAAa,SAAS;CACpB,MAAM;EACJ,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,UAAU;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,OAAO;CACT;CACA,WAAW;EACT,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,YAAY;EACV,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,cAAc;EACZ,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,eAAe;EACb,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,qBAAqB;EACnB,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,oBAAoB;EAClB,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,mBAAmB;EACjB,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,WAAW;EACT,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,UAAU;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,MAAM;EACJ,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,gBAAgB;EACd,QAAQ;EACR,OAAO;CACT;CACA,cAAc;EACZ,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,eAAe;EACb,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;AACF"}
@@ -1,7 +1,7 @@
1
1
  import { CSSProperties, ReactNode, Ref } from "react";
2
2
  //#region src/ToggleGroup/type.d.ts
3
3
  export type ToggleGroupSize = 'middle' | 'small';
4
- export type ToggleGroupVariant = 'borderless' | 'outlined';
4
+ export type ToggleGroupVariant = 'borderless' | 'outlined' | 'segmented';
5
5
  export interface ToggleGroupClassNames {
6
6
  item?: string;
7
7
  itemIcon?: string;
@@ -22,19 +22,35 @@ export interface ToggleGroupOption<Value extends string = string> {
22
22
  title?: string;
23
23
  value: Value;
24
24
  }
25
- export interface ToggleGroupProps<Value extends string = string> {
25
+ export interface ToggleGroupBaseProps<Value extends string = string> {
26
26
  className?: string;
27
27
  classNames?: ToggleGroupClassNames;
28
- defaultValue?: Value;
29
28
  disabled?: boolean;
30
- onChange?: (value: Value) => void;
31
29
  options?: (ToggleGroupOption<Value> | Value)[];
32
30
  ref?: Ref<HTMLDivElement>;
33
31
  size?: ToggleGroupSize;
34
32
  style?: CSSProperties;
35
33
  styles?: ToggleGroupStyles;
36
- value?: Value;
34
+ /**
35
+ * Visual style of the group.
36
+ * - outlined (default) - joined group with 1px dividers
37
+ * - borderless - detached action buttons
38
+ * - segmented - Segmented-like container with detached pill items, pairs with multiple
39
+ */
37
40
  variant?: ToggleGroupVariant;
38
41
  }
42
+ export interface ToggleGroupSingleProps<Value extends string = string> extends ToggleGroupBaseProps<Value> {
43
+ defaultValue?: Value;
44
+ multiple?: false;
45
+ onChange?: (value: Value) => void;
46
+ value?: Value;
47
+ }
48
+ export interface ToggleGroupMultipleProps<Value extends string = string> extends ToggleGroupBaseProps<Value> {
49
+ defaultValue?: Value[];
50
+ multiple: true;
51
+ onChange?: (value: Value[]) => void;
52
+ value?: Value[];
53
+ }
54
+ export type ToggleGroupProps<Value extends string = string> = ToggleGroupSingleProps<Value> | ToggleGroupMultipleProps<Value>;
39
55
  //#endregion
40
56
  //# sourceMappingURL=type.d.mts.map
@@ -1,4 +1,4 @@
1
- import { Rule } from "../node_modules/.pnpm/eslint@10.12.0_jiti@2.6.1_supports-color@10.2.2/node_modules/eslint/lib/types/index.mjs";
1
+ import { Rule } from "../node_modules/.pnpm/eslint@10.13.0_jiti@2.6.1_supports-color@10.2.2/node_modules/eslint/lib/types/index.mjs";
2
2
  //#region src/eslint/index.d.ts
3
3
  export declare const restrictedImports: {
4
4
  rules: {
@@ -1,98 +1,37 @@
1
1
  "use client";
2
- import { useThemeMode } from "../styles/theme/scope.mjs";
3
- import { prepareInlineMermaidSvg } from "../Mermaid/SyntaxMermaid/prepareInlineSvg.mjs";
4
- import { createCdnMermaidConfig, renderWithCdnMermaid } from "./useMermaidCdn.mjs";
5
- import { useEffect, useId, useMemo, useState } from "react";
6
- import { THEMES, renderMermaidSVG } from "beautiful-mermaid";
2
+ import { useId, useMemo } from "react";
3
+ import { render } from "pele";
7
4
  //#region src/hooks/useMermaid.ts
8
- /**
9
- * beautiful-mermaid emits these as CSS custom properties on the SVG root and
10
- * derives the rest with color-mix(), so pointing them at antd's variables lets
11
- * the diagram follow the theme through CSS alone — no token subscription, and
12
- * no re-render (or re-layout) when the appearance changes.
13
- */
14
- const LOBE_THEME_OPTIONS = {
15
- accent: "var(--lobe-color-primary)",
16
- bg: "var(--lobe-color-bg-container)",
17
- border: "var(--lobe-color-border)",
18
- fg: "var(--lobe-color-text)",
19
- line: "var(--lobe-color-text-secondary)",
20
- muted: "var(--lobe-color-text-description)",
21
- surface: "var(--lobe-color-fill-tertiary)",
22
- transparent: true
5
+ const FALLBACK_FONT = "sans-serif";
6
+ const resolveFontFamily = () => {
7
+ if (typeof document === "undefined") return FALLBACK_FONT;
8
+ return globalThis.getComputedStyle(document.documentElement).getPropertyValue("--lobe-font-family").trim() || FALLBACK_FONT;
23
9
  };
24
- const isNamedTheme = (theme) => !!theme && theme !== "lobe-theme" && theme in THEMES;
25
- const createMermaidOptions = (customTheme) => isNamedTheme(customTheme) ? THEMES[customTheme] : LOBE_THEME_OPTIONS;
26
- /**
27
- * beautiful-mermaid covers six diagram types; anything else throws here and is
28
- * handed to the CDN-loaded upstream mermaid instead.
29
- */
30
- const renderMermaid = (content, scopeId, customTheme) => {
10
+ const renderMermaid = (content, scopeId) => {
31
11
  if (!content) return { svg: "" };
32
12
  try {
33
- const svg = renderMermaidSVG(content, createMermaidOptions(customTheme));
34
- return { svg: prepareInlineMermaidSvg(svg, scopeId) };
35
- } catch {
13
+ const { svg } = render(content, {
14
+ fontFamily: resolveFontFamily(),
15
+ fontSize: 14,
16
+ idPrefix: scopeId
17
+ });
18
+ return { svg };
19
+ } catch (error) {
36
20
  return {
37
- error: "unsupported",
21
+ error: error.message || "Failed to render diagram",
38
22
  svg: ""
39
23
  };
40
24
  }
41
25
  };
42
- const useCdnMermaidFallback = (content, { enabled, theme: customTheme }) => {
43
- const { isDarkMode } = useThemeMode();
26
+ const useMermaidScopeId = () => {
44
27
  const reactId = useId();
45
- const [result, setResult] = useState({ svg: "" });
46
- useEffect(() => {
47
- if (!enabled || !content) {
48
- setResult({ svg: "" });
49
- return;
50
- }
51
- let active = true;
52
- setResult({
53
- loading: true,
54
- svg: ""
55
- });
56
- const config = createCdnMermaidConfig(isDarkMode, isNamedTheme(customTheme) ? customTheme : void 0);
57
- renderWithCdnMermaid(content, `mermaid-cdn-${reactId.replaceAll(":", "")}`, config).then((svg) => {
58
- if (!active) return;
59
- setResult(svg ? { svg } : {
60
- error: "Failed to render diagram",
61
- svg: ""
62
- });
63
- }).catch(() => {
64
- if (active) setResult({
65
- error: "Failed to render diagram",
66
- svg: ""
67
- });
68
- });
69
- return () => {
70
- active = false;
71
- };
72
- }, [
73
- enabled,
74
- content,
75
- isDarkMode,
76
- customTheme,
77
- reactId
78
- ]);
79
- return result;
28
+ return useMemo(() => `mermaid-${reactId.replaceAll(":", "")}-`, [reactId]);
80
29
  };
81
- const useMermaid = (content, { theme: customTheme } = {}) => {
82
- const reactId = useId();
83
- const scopeId = useMemo(() => `mermaid-${reactId.replaceAll(":", "")}`, [reactId]);
84
- const primary = useMemo(() => renderMermaid(content, scopeId, customTheme), [
85
- content,
86
- scopeId,
87
- customTheme
88
- ]);
89
- const fallback = useCdnMermaidFallback(content, {
90
- enabled: Boolean(primary.error),
91
- theme: customTheme
92
- });
93
- return primary.error ? fallback : primary;
30
+ const useMermaid = (content) => {
31
+ const scopeId = useMermaidScopeId();
32
+ return useMemo(() => renderMermaid(content, scopeId), [content, scopeId]);
94
33
  };
95
34
  //#endregion
96
- export { createMermaidOptions, renderMermaid, useCdnMermaidFallback, useMermaid };
35
+ export { renderMermaid, useMermaid, useMermaidScopeId };
97
36
 
98
37
  //# sourceMappingURL=useMermaid.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useMermaid.mjs","names":[],"sources":["../../src/hooks/useMermaid.ts"],"sourcesContent":["'use client';\n\nimport { renderMermaidSVG, type RenderOptions, type ThemeName, THEMES } from 'beautiful-mermaid';\nimport { useEffect, useId, useMemo, useState } from 'react';\n\nimport { prepareInlineMermaidSvg } from '@/Mermaid/SyntaxMermaid/prepareInlineSvg';\nimport { useThemeMode } from '@/styles';\n\nimport { createCdnMermaidConfig, renderWithCdnMermaid } from './useMermaidCdn';\n\nexport type MermaidThemeName = 'lobe-theme' | ThemeName;\n\nexport interface MermaidRenderResult {\n error?: string;\n loading?: boolean;\n svg: string;\n}\n\n/**\n * beautiful-mermaid emits these as CSS custom properties on the SVG root and\n * derives the rest with color-mix(), so pointing them at antd's variables lets\n * the diagram follow the theme through CSS alone — no token subscription, and\n * no re-render (or re-layout) when the appearance changes.\n */\nconst LOBE_THEME_OPTIONS: RenderOptions = {\n accent: 'var(--lobe-color-primary)',\n bg: 'var(--lobe-color-bg-container)',\n border: 'var(--lobe-color-border)',\n fg: 'var(--lobe-color-text)',\n line: 'var(--lobe-color-text-secondary)',\n muted: 'var(--lobe-color-text-description)',\n surface: 'var(--lobe-color-fill-tertiary)',\n transparent: true,\n};\n\nconst isNamedTheme = (theme?: MermaidThemeName): theme is ThemeName =>\n !!theme && theme !== 'lobe-theme' && theme in THEMES;\n\nexport const createMermaidOptions = (customTheme?: MermaidThemeName): RenderOptions =>\n isNamedTheme(customTheme) ? THEMES[customTheme]! : LOBE_THEME_OPTIONS;\n\n/**\n * beautiful-mermaid covers six diagram types; anything else throws here and is\n * handed to the CDN-loaded upstream mermaid instead.\n */\nexport const renderMermaid = (\n content: string,\n scopeId: string,\n customTheme?: MermaidThemeName,\n): MermaidRenderResult => {\n if (!content) return { svg: '' };\n try {\n const svg = renderMermaidSVG(content, createMermaidOptions(customTheme));\n return { svg: prepareInlineMermaidSvg(svg, scopeId) };\n } catch {\n return { error: 'unsupported', svg: '' };\n }\n};\n\nexport const useCdnMermaidFallback = (\n content: string,\n { enabled, theme: customTheme }: { enabled: boolean; theme?: MermaidThemeName },\n): MermaidRenderResult => {\n const { isDarkMode } = useThemeMode();\n const reactId = useId();\n const [result, setResult] = useState<MermaidRenderResult>({ svg: '' });\n\n useEffect(() => {\n if (!enabled || !content) {\n setResult({ svg: '' });\n return;\n }\n\n let active = true;\n setResult({ loading: true, svg: '' });\n\n const config = createCdnMermaidConfig(\n isDarkMode,\n isNamedTheme(customTheme) ? customTheme : undefined,\n );\n\n renderWithCdnMermaid(content, `mermaid-cdn-${reactId.replaceAll(':', '')}`, config)\n .then((svg) => {\n if (!active) return;\n setResult(svg ? { svg } : { error: 'Failed to render diagram', svg: '' });\n })\n .catch(() => {\n if (active) setResult({ error: 'Failed to render diagram', svg: '' });\n });\n\n return () => {\n active = false;\n };\n }, [enabled, content, isDarkMode, customTheme, reactId]);\n\n return result;\n};\n\nexport const useMermaid = (\n content: string,\n { theme: customTheme }: { theme?: MermaidThemeName } = {},\n): MermaidRenderResult => {\n const reactId = useId();\n const scopeId = useMemo(() => `mermaid-${reactId.replaceAll(':', '')}`, [reactId]);\n\n const primary = useMemo(\n () => renderMermaid(content, scopeId, customTheme),\n [content, scopeId, customTheme],\n );\n\n const fallback = useCdnMermaidFallback(content, {\n enabled: Boolean(primary.error),\n theme: customTheme,\n });\n\n return primary.error ? fallback : primary;\n};\n"],"mappings":";;;;;;;;;;;;;AAwBA,MAAM,qBAAoC;CACxC,QAAQ;CACR,IAAI;CACJ,QAAQ;CACR,IAAI;CACJ,MAAM;CACN,OAAO;CACP,SAAS;CACT,aAAa;AACf;AAEA,MAAM,gBAAgB,UACpB,CAAC,CAAC,SAAS,UAAU,gBAAgB,SAAS;AAEhD,MAAa,wBAAwB,gBACnC,aAAa,WAAW,IAAI,OAAO,eAAgB;;;;;AAMrD,MAAa,iBACX,SACA,SACA,gBACwB;CACxB,IAAI,CAAC,SAAS,OAAO,EAAE,KAAK,GAAG;CAC/B,IAAI;EACF,MAAM,MAAM,iBAAiB,SAAS,qBAAqB,WAAW,CAAC;EACvE,OAAO,EAAE,KAAK,wBAAwB,KAAK,OAAO,EAAE;CACtD,QAAQ;EACN,OAAO;GAAE,OAAO;GAAe,KAAK;EAAG;CACzC;AACF;AAEA,MAAa,yBACX,SACA,EAAE,SAAS,OAAO,kBACM;CACxB,MAAM,EAAE,eAAe,aAAa;CACpC,MAAM,UAAU,MAAM;CACtB,MAAM,CAAC,QAAQ,aAAa,SAA8B,EAAE,KAAK,GAAG,CAAC;CAErE,gBAAgB;EACd,IAAI,CAAC,WAAW,CAAC,SAAS;GACxB,UAAU,EAAE,KAAK,GAAG,CAAC;GACrB;EACF;EAEA,IAAI,SAAS;EACb,UAAU;GAAE,SAAS;GAAM,KAAK;EAAG,CAAC;EAEpC,MAAM,SAAS,uBACb,YACA,aAAa,WAAW,IAAI,cAAc,KAAA,CAC5C;EAEA,qBAAqB,SAAS,eAAe,QAAQ,WAAW,KAAK,EAAE,KAAK,MAAM,CAAC,CAChF,MAAM,QAAQ;GACb,IAAI,CAAC,QAAQ;GACb,UAAU,MAAM,EAAE,IAAI,IAAI;IAAE,OAAO;IAA4B,KAAK;GAAG,CAAC;EAC1E,CAAC,CAAC,CACD,YAAY;GACX,IAAI,QAAQ,UAAU;IAAE,OAAO;IAA4B,KAAK;GAAG,CAAC;EACtE,CAAC;EAEH,aAAa;GACX,SAAS;EACX;CACF,GAAG;EAAC;EAAS;EAAS;EAAY;EAAa;CAAO,CAAC;CAEvD,OAAO;AACT;AAEA,MAAa,cACX,SACA,EAAE,OAAO,gBAA8C,CAAC,MAChC;CACxB,MAAM,UAAU,MAAM;CACtB,MAAM,UAAU,cAAc,WAAW,QAAQ,WAAW,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC;CAEjF,MAAM,UAAU,cACR,cAAc,SAAS,SAAS,WAAW,GACjD;EAAC;EAAS;EAAS;CAAW,CAChC;CAEA,MAAM,WAAW,sBAAsB,SAAS;EAC9C,SAAS,QAAQ,QAAQ,KAAK;EAC9B,OAAO;CACT,CAAC;CAED,OAAO,QAAQ,QAAQ,WAAW;AACpC"}
1
+ {"version":3,"file":"useMermaid.mjs","names":[],"sources":["../../src/hooks/useMermaid.ts"],"sourcesContent":["'use client';\n\nimport { render } from 'pele';\nimport { useId, useMemo } from 'react';\n\nexport type { MermaidThemeName } from '@/Mermaid/themes';\n\nexport interface MermaidRenderResult {\n error?: string;\n loading?: boolean;\n svg: string;\n}\n\nconst FALLBACK_FONT = 'sans-serif';\n\n// pele sizes nodes by measuring labels on a canvas, which cannot resolve var(),\n// so the theme font has to be read as a literal before rendering.\nconst resolveFontFamily = (): string => {\n if (typeof document === 'undefined') return FALLBACK_FONT;\n const value = globalThis\n .getComputedStyle(document.documentElement)\n .getPropertyValue('--lobe-font-family')\n .trim();\n return value || FALLBACK_FONT;\n};\n\nexport const renderMermaid = (content: string, scopeId: string): MermaidRenderResult => {\n if (!content) return { svg: '' };\n try {\n const { svg } = render(content, {\n fontFamily: resolveFontFamily(),\n fontSize: 14,\n idPrefix: scopeId,\n });\n return { svg };\n } catch (error) {\n return { error: (error as Error).message || 'Failed to render diagram', svg: '' };\n }\n};\n\nexport const useMermaidScopeId = () => {\n const reactId = useId();\n return useMemo(() => `mermaid-${reactId.replaceAll(':', '')}-`, [reactId]);\n};\n\nexport const useMermaid = (content: string): MermaidRenderResult => {\n const scopeId = useMermaidScopeId();\n return useMemo(() => renderMermaid(content, scopeId), [content, scopeId]);\n};\n"],"mappings":";;;;AAaA,MAAM,gBAAgB;AAItB,MAAM,0BAAkC;CACtC,IAAI,OAAO,aAAa,aAAa,OAAO;CAK5C,OAJc,WACX,iBAAiB,SAAS,eAAe,CAAC,CAC1C,iBAAiB,oBAAoB,CAAC,CACtC,KACQ,KAAK;AAClB;AAEA,MAAa,iBAAiB,SAAiB,YAAyC;CACtF,IAAI,CAAC,SAAS,OAAO,EAAE,KAAK,GAAG;CAC/B,IAAI;EACF,MAAM,EAAE,QAAQ,OAAO,SAAS;GAC9B,YAAY,kBAAkB;GAC9B,UAAU;GACV,UAAU;EACZ,CAAC;EACD,OAAO,EAAE,IAAI;CACf,SAAS,OAAO;EACd,OAAO;GAAE,OAAQ,MAAgB,WAAW;GAA4B,KAAK;EAAG;CAClF;AACF;AAEA,MAAa,0BAA0B;CACrC,MAAM,UAAU,MAAM;CACtB,OAAO,cAAc,WAAW,QAAQ,WAAW,KAAK,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC;AAC3E;AAEA,MAAa,cAAc,YAAyC;CAClE,MAAM,UAAU,kBAAkB;CAClC,OAAO,cAAc,cAAc,SAAS,OAAO,GAAG,CAAC,SAAS,OAAO,CAAC;AAC1E"}
@@ -1,32 +1,38 @@
1
1
  "use client";
2
- import { renderMermaid, useCdnMermaidFallback } from "./useMermaid.mjs";
3
- import { useEffect, useId, useMemo, useState } from "react";
2
+ import { renderMermaid, useMermaidScopeId } from "./useMermaid.mjs";
3
+ import { useEffect, useRef, useState } from "react";
4
4
  //#region src/hooks/useStreamMermaid.ts
5
5
  const EMPTY = { svg: "" };
6
- const useStreamMermaid = (content, { enabled = true, theme: customTheme }) => {
7
- const reactId = useId();
8
- const scopeId = useMemo(() => `mermaid-${reactId.replaceAll(":", "")}`, [reactId]);
9
- const [primary, setPrimary] = useState(EMPTY);
6
+ const PENDING = {
7
+ loading: true,
8
+ svg: ""
9
+ };
10
+ const THROTTLE = 150;
11
+ const useStreamMermaid = (content, { enabled = true } = {}) => {
12
+ const scopeId = useMermaidScopeId();
13
+ const [result, setResult] = useState(EMPTY);
14
+ const lastRenderRef = useRef(0);
10
15
  useEffect(() => {
11
16
  if (!enabled || !content) {
12
- setPrimary(EMPTY);
17
+ setResult(EMPTY);
13
18
  return;
14
19
  }
20
+ const wait = Math.max(0, THROTTLE - (Date.now() - lastRenderRef.current));
15
21
  const timer = setTimeout(() => {
16
- setPrimary(renderMermaid(content, scopeId, customTheme));
17
- }, 300);
22
+ lastRenderRef.current = Date.now();
23
+ const next = renderMermaid(content, scopeId);
24
+ setResult((previous) => {
25
+ if (!next.error) return next;
26
+ return previous.svg ? previous : PENDING;
27
+ });
28
+ }, wait);
18
29
  return () => clearTimeout(timer);
19
30
  }, [
20
31
  enabled,
21
32
  content,
22
- scopeId,
23
- customTheme
33
+ scopeId
24
34
  ]);
25
- const fallback = useCdnMermaidFallback(content, {
26
- enabled: enabled && Boolean(primary.error),
27
- theme: customTheme
28
- });
29
- return primary.error ? fallback : primary;
35
+ return result;
30
36
  };
31
37
  //#endregion
32
38
  export { useStreamMermaid };
@@ -1 +1 @@
1
- {"version":3,"file":"useStreamMermaid.mjs","names":[],"sources":["../../src/hooks/useStreamMermaid.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useId, useMemo, useState } from 'react';\n\nimport {\n type MermaidRenderResult,\n type MermaidThemeName,\n renderMermaid,\n useCdnMermaidFallback,\n} from './useMermaid';\n\nconst EMPTY: MermaidRenderResult = { svg: '' };\n\nexport const useStreamMermaid = (\n content: string,\n {\n enabled = true,\n theme: customTheme,\n }: {\n enabled?: boolean;\n theme?: MermaidThemeName;\n },\n): MermaidRenderResult => {\n const reactId = useId();\n const scopeId = useMemo(() => `mermaid-${reactId.replaceAll(':', '')}`, [reactId]);\n const [primary, setPrimary] = useState<MermaidRenderResult>(EMPTY);\n\n useEffect(() => {\n if (!enabled || !content) {\n setPrimary(EMPTY);\n return;\n }\n\n // Debounce rendering so streaming content only re-renders after it settles\n const timer = setTimeout(() => {\n setPrimary(renderMermaid(content, scopeId, customTheme));\n }, 300);\n\n return () => clearTimeout(timer);\n }, [enabled, content, scopeId, customTheme]);\n\n const fallback = useCdnMermaidFallback(content, {\n enabled: enabled && Boolean(primary.error),\n theme: customTheme,\n });\n\n return primary.error ? fallback : primary;\n};\n"],"mappings":";;;;AAWA,MAAM,QAA6B,EAAE,KAAK,GAAG;AAE7C,MAAa,oBACX,SACA,EACE,UAAU,MACV,OAAO,kBAKe;CACxB,MAAM,UAAU,MAAM;CACtB,MAAM,UAAU,cAAc,WAAW,QAAQ,WAAW,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC;CACjF,MAAM,CAAC,SAAS,cAAc,SAA8B,KAAK;CAEjE,gBAAgB;EACd,IAAI,CAAC,WAAW,CAAC,SAAS;GACxB,WAAW,KAAK;GAChB;EACF;EAGA,MAAM,QAAQ,iBAAiB;GAC7B,WAAW,cAAc,SAAS,SAAS,WAAW,CAAC;EACzD,GAAG,GAAG;EAEN,aAAa,aAAa,KAAK;CACjC,GAAG;EAAC;EAAS;EAAS;EAAS;CAAW,CAAC;CAE3C,MAAM,WAAW,sBAAsB,SAAS;EAC9C,SAAS,WAAW,QAAQ,QAAQ,KAAK;EACzC,OAAO;CACT,CAAC;CAED,OAAO,QAAQ,QAAQ,WAAW;AACpC"}
1
+ {"version":3,"file":"useStreamMermaid.mjs","names":[],"sources":["../../src/hooks/useStreamMermaid.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useRef, useState } from 'react';\n\nimport { type MermaidRenderResult, renderMermaid, useMermaidScopeId } from './useMermaid';\n\nconst EMPTY: MermaidRenderResult = { svg: '' };\nconst PENDING: MermaidRenderResult = { loading: true, svg: '' };\nconst THROTTLE = 150;\n\n// Most prefixes of a diagram are not valid syntax yet, so a failed render keeps\n// the last good SVG instead of flashing an error; the static renderer that takes\n// over once streaming ends is the one that reports real errors.\nexport const useStreamMermaid = (\n content: string,\n { enabled = true }: { enabled?: boolean } = {},\n): MermaidRenderResult => {\n const scopeId = useMermaidScopeId();\n const [result, setResult] = useState<MermaidRenderResult>(EMPTY);\n const lastRenderRef = useRef(0);\n\n useEffect(() => {\n if (!enabled || !content) {\n setResult(EMPTY);\n return;\n }\n\n // Throttle rather than debounce: chunks arrive faster than any debounce\n // window, which would hold the diagram back until the stream pauses.\n const wait = Math.max(0, THROTTLE - (Date.now() - lastRenderRef.current));\n const timer = setTimeout(() => {\n lastRenderRef.current = Date.now();\n const next = renderMermaid(content, scopeId);\n setResult((previous) => {\n if (!next.error) return next;\n return previous.svg ? previous : PENDING;\n });\n }, wait);\n\n return () => clearTimeout(timer);\n }, [enabled, content, scopeId]);\n\n return result;\n};\n"],"mappings":";;;;AAMA,MAAM,QAA6B,EAAE,KAAK,GAAG;AAC7C,MAAM,UAA+B;CAAE,SAAS;CAAM,KAAK;AAAG;AAC9D,MAAM,WAAW;AAKjB,MAAa,oBACX,SACA,EAAE,UAAU,SAAgC,CAAC,MACrB;CACxB,MAAM,UAAU,kBAAkB;CAClC,MAAM,CAAC,QAAQ,aAAa,SAA8B,KAAK;CAC/D,MAAM,gBAAgB,OAAO,CAAC;CAE9B,gBAAgB;EACd,IAAI,CAAC,WAAW,CAAC,SAAS;GACxB,UAAU,KAAK;GACf;EACF;EAIA,MAAM,OAAO,KAAK,IAAI,GAAG,YAAY,KAAK,IAAI,IAAI,cAAc,QAAQ;EACxE,MAAM,QAAQ,iBAAiB;GAC7B,cAAc,UAAU,KAAK,IAAI;GACjC,MAAM,OAAO,cAAc,SAAS,OAAO;GAC3C,WAAW,aAAa;IACtB,IAAI,CAAC,KAAK,OAAO,OAAO;IACxB,OAAO,SAAS,MAAM,WAAW;GACnC,CAAC;EACH,GAAG,IAAI;EAEP,aAAa,aAAa,KAAK;CACjC,GAAG;EAAC;EAAS;EAAS;CAAO,CAAC;CAE9B,OAAO;AACT"}
@@ -1,7 +1,7 @@
1
1
  import { ArrowFunctionExpression, AssignmentExpression, BaseNode, CatchClause, ClassDeclaration, ClassExpression, Comment, Expression, ForInStatement, ForOfStatement, FunctionDeclaration, FunctionExpression, Identifier, ImportDeclaration, ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportSpecifier, Node as Node$1, Position, Program, SourceLocation as SourceLocation$1, VariableDeclaration, VariableDeclarator } from "../../../../../@types_estree@1.0.9/node_modules/@types/estree/index.mjs";
2
2
  import { BaseConfig, ConfigObject, ConfigOverride, DeprecatedInfo, EcmaVersion as EcmaVersion$1, EnvironmentConfig, GlobalAccess, GlobalsConfig, HasRules, JavaScriptSourceType, LanguageOptions, LegacyConfigObject, LintMessage as LintMessage$1, LintSuggestion, LinterOptionsConfig, ObjectMetaProperties, Plugin as Plugin$1, Processor, ProcessorFile as ProcessorFile$1, RuleConfig, RuleContext as RuleContext$1, RuleDefinition, RuleFixer, RuleTextEdit, RuleTextEditor, RulesConfig, RulesMeta, Severity, SeverityLevel, SeverityName, SourceRange, SuggestedEdit, SuggestedEditBase, SuggestionMessage, TextSourceCode, TraversalStep, ViolationLocation, ViolationMessage, ViolationReport, ViolationReportBase } from "../../../../../@eslint_core@1.2.1/node_modules/@eslint/core/dist/esm/types.mjs";
3
3
  import { CustomRuleVisitorWithExit } from "../../../../../@eslint_plugin-kit@0.7.3/node_modules/@eslint/plugin-kit/dist/cjs/index.mjs";
4
- //#region node_modules/.pnpm/eslint@10.12.0_jiti@2.6.1_supports-color@10.2.2/node_modules/eslint/lib/types/index.d.ts
4
+ //#region node_modules/.pnpm/eslint@10.13.0_jiti@2.6.1_supports-color@10.2.2/node_modules/eslint/lib/types/index.d.ts
5
5
  //------------------------------------------------------------------------------
6
6
  // Exports
7
7
  //------------------------------------------------------------------------------
package/es/style.css CHANGED
@@ -1999,16 +1999,13 @@
1999
1999
  }
2000
2000
 
2001
2001
  .lobe-mermaid svg {
2002
- width: 100%;
2002
+ max-width: 100%;
2003
2003
  height: auto;
2004
2004
  max-height: 480px;
2005
+ margin-inline: auto;
2005
2006
  display: block;
2006
2007
  }
2007
2008
 
2008
- .lobe-mermaid svg text {
2009
- font-family: var(--lobe-font-family);
2010
- }
2011
-
2012
2009
  .lobe-mermaid-transparent img {
2013
2010
  background: none !important;
2014
2011
  }
@@ -8573,6 +8570,10 @@
8573
8570
  background-color: var(--lobe-checkbox-bg, var(--lobe-color-primary));
8574
8571
  }
8575
8572
 
8573
+ .lb14mr86t[data-pressed] {
8574
+ background-color: var(--lobe-color-bg-elevated);
8575
+ }
8576
+
8576
8577
  .lb1ca5mm0:hover:not(:active) {
8577
8578
  background-color: var(--lobe-color-error-hover);
8578
8579
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "6.2.0",
3
+ "version": "6.4.0",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",
@@ -167,7 +167,6 @@
167
167
  "@tanstack/form-core": "^1.33.5",
168
168
  "@tanstack/react-table": "^9.2.8",
169
169
  "@tanstack/react-virtual": "^3.14.18",
170
- "beautiful-mermaid": "^1.1.3",
171
170
  "chroma-js": "^3.2.0",
172
171
  "clsx": "^2.1.1",
173
172
  "dayjs": "^1.11.21",
@@ -179,6 +178,7 @@
179
178
  "leva": "^0.10.1",
180
179
  "lucide-react": "^1.55.0",
181
180
  "motion": "^13.0.0 || ^14.0.0",
181
+ "pele": "^1.6.0",
182
182
  "re-resizable": "^6.11.2",
183
183
  "react-avatar-editor": "^16.0.0",
184
184
  "react-error-boundary": "^6.1.6",