@lobehub/ui 1.134.3 → 1.135.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.
@@ -0,0 +1,16 @@
1
+ /// <reference types="react" />
2
+ import { type FlexboxProps } from 'react-layout-kit';
3
+ export declare const useStyles: (props?: {
4
+ gap: string | number;
5
+ maxItemWidth: string | number;
6
+ rows: number;
7
+ } | undefined) => import("antd-style").ReturnStyles<{
8
+ container: import("antd-style").SerializedStyles;
9
+ }>;
10
+ export interface GridProps extends Omit<FlexboxProps, 'gap'> {
11
+ gap?: string | number;
12
+ maxItemWidth?: string | number;
13
+ rows?: number;
14
+ }
15
+ declare const Grid: import("react").ForwardRefExoticComponent<GridProps & import("react").RefAttributes<HTMLDivElement>>;
16
+ export default Grid;
@@ -0,0 +1,49 @@
1
+ 'use client';
2
+
3
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
6
+ var _excluded = ["className", "gap", "rows", "children", "maxItemWidth"];
7
+ var _templateObject;
8
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
+ import { createStyles } from 'antd-style';
11
+ import { isString } from 'lodash-es';
12
+ import { forwardRef } from 'react';
13
+ import { Flexbox } from 'react-layout-kit';
14
+ import { jsx as _jsx } from "react/jsx-runtime";
15
+ export var useStyles = createStyles(function (_ref, _ref2) {
16
+ var css = _ref.css;
17
+ var rows = _ref2.rows,
18
+ maxItemWidth = _ref2.maxItemWidth,
19
+ gap = _ref2.gap;
20
+ return {
21
+ container: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n --rows: ", ";\n --max-item-width: ", ";\n --gap: ", ";\n\n display: grid !important;\n grid-template-columns: repeat(\n auto-fill,\n minmax(\n max(var(--max-item-width), calc((100% - var(--gap) * (var(--rows) - 1)) / var(--rows))),\n 1fr\n )\n );\n "])), rows, isString(maxItemWidth) ? maxItemWidth : "".concat(maxItemWidth, "px"), isString(gap) ? gap : "".concat(gap, "px"))
22
+ };
23
+ });
24
+ var Grid = /*#__PURE__*/forwardRef(function (_ref3, ref) {
25
+ var className = _ref3.className,
26
+ _ref3$gap = _ref3.gap,
27
+ gap = _ref3$gap === void 0 ? '1em' : _ref3$gap,
28
+ _ref3$rows = _ref3.rows,
29
+ rows = _ref3$rows === void 0 ? 3 : _ref3$rows,
30
+ children = _ref3.children,
31
+ _ref3$maxItemWidth = _ref3.maxItemWidth,
32
+ maxItemWidth = _ref3$maxItemWidth === void 0 ? 240 : _ref3$maxItemWidth,
33
+ rest = _objectWithoutProperties(_ref3, _excluded);
34
+ var _useStyles = useStyles({
35
+ gap: gap,
36
+ maxItemWidth: maxItemWidth,
37
+ rows: rows
38
+ }),
39
+ cx = _useStyles.cx,
40
+ styles = _useStyles.styles;
41
+ return /*#__PURE__*/_jsx(Flexbox, _objectSpread(_objectSpread({
42
+ className: cx(styles.container, className),
43
+ gap: gap,
44
+ ref: ref
45
+ }, rest), {}, {
46
+ children: children
47
+ }));
48
+ });
49
+ export default Grid;
@@ -2,7 +2,7 @@
2
2
 
3
3
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
- var _excluded = ["children", "className", "style", "fullFeaturedCodeBlock", "onDoubleClick", "enableImageGallery", "componentProps", "allowHtml", "fontSize", "headerMultiple", "marginMultiple", "variant"];
5
+ var _excluded = ["children", "className", "style", "fullFeaturedCodeBlock", "onDoubleClick", "enableImageGallery", "componentProps", "allowHtml", "fontSize", "headerMultiple", "marginMultiple", "variant", "lineHeight"];
6
6
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
7
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
8
  import { memo, useMemo } from 'react';
@@ -33,10 +33,12 @@ var Markdown = /*#__PURE__*/memo(function (_ref) {
33
33
  marginMultiple = _ref.marginMultiple,
34
34
  _ref$variant = _ref.variant,
35
35
  variant = _ref$variant === void 0 ? 'normal' : _ref$variant,
36
+ lineHeight = _ref.lineHeight,
36
37
  rest = _objectWithoutProperties(_ref, _excluded);
37
38
  var _useStyles = useStyles({
38
39
  fontSize: fontSize,
39
40
  headerMultiple: headerMultiple,
41
+ lineHeight: lineHeight,
40
42
  marginMultiple: marginMultiple
41
43
  }),
42
44
  cx = _useStyles.cx,
@@ -2,9 +2,10 @@ import { ReactNode } from 'react';
2
2
  import { DivProps } from "../types";
3
3
  export interface SpotlightCardProps<T = any> extends DivProps {
4
4
  borderRadius?: number;
5
- columns?: string | number;
6
- gap?: number;
5
+ columns?: number;
6
+ gap?: number | string;
7
7
  items: T[];
8
+ maxItemWidth?: string | number;
8
9
  renderItem: (item: T) => ReactNode;
9
10
  size?: number;
10
11
  spotlight?: boolean;
@@ -2,25 +2,26 @@
2
2
 
3
3
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
- var _excluded = ["items", "renderItem", "className", "columns", "gap", "style", "size", "borderRadius", "spotlight"];
5
+ var _excluded = ["items", "renderItem", "maxItemWidth", "className", "columns", "gap", "style", "size", "borderRadius", "spotlight"];
6
6
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
7
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
8
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
9
9
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
10
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
- import { isNumber } from 'lodash-es';
12
- import { memo, useEffect, useMemo, useRef } from 'react';
11
+ import { memo, useEffect, useRef } from 'react';
12
+ import Grid from "../Grid";
13
13
  import SpotlightCardItem from "./SpotlightCardItem";
14
14
  import { CHILDREN_CLASSNAME, useStyles } from "./style";
15
15
  import { jsx as _jsx } from "react/jsx-runtime";
16
16
  var SpotlightCard = /*#__PURE__*/memo(function (_ref) {
17
17
  var items = _ref.items,
18
18
  Content = _ref.renderItem,
19
+ maxItemWidth = _ref.maxItemWidth,
19
20
  className = _ref.className,
20
21
  _ref$columns = _ref.columns,
21
22
  columns = _ref$columns === void 0 ? 3 : _ref$columns,
22
23
  _ref$gap = _ref.gap,
23
- gap = _ref$gap === void 0 ? 12 : _ref$gap,
24
+ gap = _ref$gap === void 0 ? '1em' : _ref$gap,
24
25
  style = _ref.style,
25
26
  _ref$size = _ref.size,
26
27
  size = _ref$size === void 0 ? 800 : _ref$size,
@@ -36,11 +37,6 @@ var SpotlightCard = /*#__PURE__*/memo(function (_ref) {
36
37
  styles = _useStyles.styles,
37
38
  cx = _useStyles.cx;
38
39
  var ref = useRef(null);
39
- var gridColumns = useMemo(function () {
40
- return isNumber(columns) ? Array.from({
41
- length: columns
42
- }).fill('1fr').join(' ') : columns;
43
- }, [columns]);
44
40
  useEffect(function () {
45
41
  if (!ref.current) return;
46
42
  if (!spotlight) return;
@@ -68,13 +64,13 @@ var SpotlightCard = /*#__PURE__*/memo(function (_ref) {
68
64
  (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.removeEventListener('mousemove', fn);
69
65
  };
70
66
  }, []);
71
- return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({
67
+ return /*#__PURE__*/_jsx(Grid, _objectSpread(_objectSpread({
72
68
  className: cx(styles.container, styles.grid, className),
69
+ gap: gap,
70
+ maxItemWidth: maxItemWidth,
73
71
  ref: ref,
74
- style: _objectSpread({
75
- gap: gap,
76
- gridTemplateColumns: gridColumns
77
- }, style)
72
+ rows: columns,
73
+ style: style
78
74
  }, rest), {}, {
79
75
  children: items.map(function (item, index) {
80
76
  return /*#__PURE__*/_jsx(SpotlightCardItem, {
package/es/index.d.ts CHANGED
@@ -39,6 +39,7 @@ export { default as FormTitle, type FormTitleProps } from './Form/components/For
39
39
  export { default as GaussianBackground, type GaussianBackgroundProps } from './GaussianBackground';
40
40
  export { default as Giscus, type GiscusProps } from './Giscus';
41
41
  export { default as GradientButton, type GradientButtonProps } from './GradientButton';
42
+ export { default as Grid, type GridProps } from './Grid';
42
43
  export { default as GridBackground, type GridBackgroundProps } from './GridBackground';
43
44
  export { default as GridShowcase, type GridShowcaseProps } from './GridBackground/GridShowcase';
44
45
  export { default as Header, type HeaderProps } from './Header';
package/es/index.js CHANGED
@@ -38,6 +38,7 @@ export { default as FormTitle } from "./Form/components/FormTitle";
38
38
  export { default as GaussianBackground } from "./GaussianBackground";
39
39
  export { default as Giscus } from "./Giscus";
40
40
  export { default as GradientButton } from "./GradientButton";
41
+ export { default as Grid } from "./Grid";
41
42
  export { default as GridBackground } from "./GridBackground";
42
43
  export { default as GridShowcase } from "./GridBackground/GridShowcase";
43
44
  export { default as Header } from "./Header";
package/es/mdx/Cards.d.ts CHANGED
@@ -11,6 +11,7 @@ export interface CardProps extends Omit<FlexboxProps, 'children'> {
11
11
  }
12
12
  declare const Card: FC<CardProps>;
13
13
  interface _CardsProps extends PropsWithChildren {
14
+ maxItemWidth?: string | number;
14
15
  rows?: number;
15
16
  }
16
17
  declare const _Cards: FC<_CardsProps>;
package/es/mdx/Cards.js CHANGED
@@ -10,18 +10,19 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
10
10
  import { createStyles } from 'antd-style';
11
11
  import { Flexbox } from 'react-layout-kit';
12
12
  import A from "../A";
13
+ import Grid from "../Grid";
13
14
  import Icon from "../Icon";
14
15
  import Img from "../Img";
15
16
  import { jsx as _jsx } from "react/jsx-runtime";
16
17
  import { jsxs as _jsxs } from "react/jsx-runtime";
17
- var useStyles = createStyles(function (_ref, rows) {
18
+ var useStyles = createStyles(function (_ref) {
18
19
  var css = _ref.css,
19
20
  cx = _ref.cx,
20
21
  token = _ref.token;
21
22
  var icon = cx(css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n margin-block: 0.1em;\n opacity: 0.5;\n transition: opacity 0.2s ", ";\n "])), token.motionEaseInOut));
22
23
  return {
23
24
  card: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n --lobe-markdown-header-multiple: 0;\n --lobe-markdown-margin-multiple: 1;\n\n overflow: hidden;\n\n height: 100%;\n\n color: ", ";\n\n border-radius: calc(var(--lobe-markdown-border-radius) * 1px);\n box-shadow: 0 0 0 1px var(--lobe-markdown-border-color);\n\n transition: all 0.2s ", ";\n\n h3,\n p {\n margin-block: 0;\n }\n\n p {\n color: ", ";\n transition: color 0.2s ", ";\n }\n\n &:hover {\n background: ", ";\n box-shadow: 0 0 0 1px ", ";\n\n p {\n color: ", ";\n }\n\n .", " {\n opacity: 1;\n }\n }\n "])), token.colorText, token.motionEaseInOut, token.colorTextDescription, token.motionEaseInOut, token.colorFillQuaternary, token.colorBorder, token.colorTextSecondary, icon),
24
- container: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n --rows: ", ";\n\n display: grid;\n grid-template-columns: repeat(\n auto-fill,\n minmax(max(250px, calc((100% - 1em * 2) / var(--rows))), 1fr)\n );\n gap: 1em;\n margin-block: calc(var(--lobe-markdown-margin-multiple) * 1em);\n\n > div {\n margin: 0 !important;\n }\n "])), rows),
25
+ container: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n margin-block: calc(var(--lobe-markdown-margin-multiple) * 1em);\n\n > div {\n margin: 0 !important;\n }\n "]))),
25
26
  content: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n gap: 0.75em;\n padding: 1em;\n "]))),
26
27
  icon: icon
27
28
  };
@@ -75,12 +76,16 @@ var Card = function Card(_ref2) {
75
76
  };
76
77
  var _Cards = function _Cards(_ref3) {
77
78
  var children = _ref3.children,
79
+ _ref3$maxItemWidth = _ref3.maxItemWidth,
80
+ maxItemWidth = _ref3$maxItemWidth === void 0 ? 250 : _ref3$maxItemWidth,
78
81
  _ref3$rows = _ref3.rows,
79
82
  rows = _ref3$rows === void 0 ? 3 : _ref3$rows;
80
- var _useStyles2 = useStyles(rows),
83
+ var _useStyles2 = useStyles(),
81
84
  styles = _useStyles2.styles;
82
- return /*#__PURE__*/_jsx("div", {
85
+ return /*#__PURE__*/_jsx(Grid, {
83
86
  className: styles.container,
87
+ maxItemWidth: maxItemWidth,
88
+ rows: rows,
84
89
  children: children
85
90
  });
86
91
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.134.3",
3
+ "version": "1.135.0",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",