@lobehub/ui 3.2.0 → 3.3.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,4 @@
1
+ import { type FC } from 'react';
2
+ import type { CenterProps } from './type';
3
+ declare const Center: FC<CenterProps>;
4
+ export default Center;
@@ -0,0 +1,23 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _excluded = ["children", "ref"];
3
+ 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; }
4
+ 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; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
10
+ import FlexBasic from "./FlexBasic";
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ var Center = function Center(_ref) {
13
+ var children = _ref.children,
14
+ ref = _ref.ref,
15
+ props = _objectWithoutProperties(_ref, _excluded);
16
+ return /*#__PURE__*/_jsx(FlexBasic, _objectSpread(_objectSpread({}, props), {}, {
17
+ align: "center",
18
+ justify: "center",
19
+ ref: ref,
20
+ children: children
21
+ }));
22
+ };
23
+ export default Center;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import './style.css';
3
+ import type { FlexBasicProps } from './type';
4
+ declare const _default: import("react").NamedExoticComponent<FlexBasicProps>;
5
+ export default _default;
@@ -0,0 +1,79 @@
1
+ 'use client';
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ var _excluded = ["visible", "flex", "gap", "direction", "horizontal", "align", "justify", "distribution", "height", "width", "padding", "paddingInline", "paddingBlock", "prefixCls", "as", "className", "style", "children", "wrap", "ref"];
5
+ 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; }
6
+ 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; }
7
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
11
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
12
+ import { memo } from 'react';
13
+ import "./style.css";
14
+ import { getCssValue, getFlexDirection, isHorizontal, isSpaceDistribution } from "./utils";
15
+ import { jsx as _jsx } from "react/jsx-runtime";
16
+ var FlexBasic = function FlexBasic(_ref) {
17
+ var visible = _ref.visible,
18
+ flex = _ref.flex,
19
+ gap = _ref.gap,
20
+ direction = _ref.direction,
21
+ horizontal = _ref.horizontal,
22
+ align = _ref.align,
23
+ justify = _ref.justify,
24
+ distribution = _ref.distribution,
25
+ height = _ref.height,
26
+ width = _ref.width,
27
+ padding = _ref.padding,
28
+ paddingInline = _ref.paddingInline,
29
+ paddingBlock = _ref.paddingBlock,
30
+ prefixCls = _ref.prefixCls,
31
+ _ref$as = _ref.as,
32
+ Container = _ref$as === void 0 ? 'div' : _ref$as,
33
+ className = _ref.className,
34
+ style = _ref.style,
35
+ children = _ref.children,
36
+ wrap = _ref.wrap,
37
+ ref = _ref.ref,
38
+ props = _objectWithoutProperties(_ref, _excluded);
39
+ var justifyContent = justify || distribution;
40
+ var calcWidth = function calcWidth() {
41
+ if (isHorizontal(direction, horizontal) && !width && isSpaceDistribution(justifyContent)) return '100%';
42
+ return getCssValue(width);
43
+ };
44
+ var finalWidth = calcWidth();
45
+ var cssVars = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, flex !== undefined ? {
46
+ '--lobe-flex': String(flex)
47
+ } : {}), direction || horizontal ? {
48
+ '--lobe-flex-direction': getFlexDirection(direction, horizontal)
49
+ } : {}), wrap !== undefined ? {
50
+ '--lobe-flex-wrap': wrap
51
+ } : {}), justifyContent !== undefined ? {
52
+ '--lobe-flex-justify': justifyContent
53
+ } : {}), align !== undefined ? {
54
+ '--lobe-flex-align': align
55
+ } : {}), finalWidth !== undefined ? {
56
+ '--lobe-flex-width': finalWidth
57
+ } : {}), height !== undefined ? {
58
+ '--lobe-flex-height': getCssValue(height)
59
+ } : {}), padding !== undefined ? {
60
+ '--lobe-flex-padding': getCssValue(padding)
61
+ } : {}), paddingInline !== undefined ? {
62
+ '--lobe-flex-padding-inline': getCssValue(paddingInline)
63
+ } : {}), paddingBlock !== undefined ? {
64
+ '--lobe-flex-padding-block': getCssValue(paddingBlock)
65
+ } : {}), gap !== undefined ? {
66
+ '--lobe-flex-gap': getCssValue(gap)
67
+ } : {});
68
+ var mergedStyle = _objectSpread(_objectSpread({}, cssVars), style);
69
+ var baseClassName = 'lobe-flex';
70
+ var mergedClassName = [baseClassName, visible === false ? "".concat(baseClassName, "--hidden") : undefined, prefixCls ? "".concat(prefixCls, "-flex") : undefined, className].filter(Boolean).join(' ');
71
+ return /*#__PURE__*/_jsx(Container, _objectSpread(_objectSpread({
72
+ ref: ref
73
+ }, props), {}, {
74
+ className: mergedClassName,
75
+ style: mergedStyle,
76
+ children: children
77
+ }));
78
+ };
79
+ export default /*#__PURE__*/memo(FlexBasic);
@@ -0,0 +1,2 @@
1
+ export { default } from './FlexBasic';
2
+ export { default as Flexbox } from './FlexBasic';
@@ -0,0 +1,2 @@
1
+ export { default } from "./FlexBasic";
2
+ export { default as Flexbox } from "./FlexBasic";
@@ -0,0 +1,4 @@
1
+ export { default as Center } from './Center';
2
+ export { default as FlexBasic } from './FlexBasic';
3
+ export { default as Flexbox } from './Flexbox';
4
+ export type { CenterProps, ContentPosition, FlexBasicProps, FlexboxProps, FlexDirection, } from './type';
@@ -0,0 +1,3 @@
1
+ export { default as Center } from "./Center";
2
+ export { default as FlexBasic } from "./FlexBasic";
3
+ export { default as Flexbox } from "./Flexbox";
@@ -0,0 +1,20 @@
1
+ .lobe-flex {
2
+ display: flex;
3
+ flex: var(--lobe-flex, 0 1 auto);
4
+ flex-direction: var(--lobe-flex-direction, column);
5
+ flex-wrap: var(--lobe-flex-wrap, nowrap);
6
+ justify-content: var(--lobe-flex-justify, flex-start);
7
+ align-items: var(--lobe-flex-align, stretch);
8
+ width: var(--lobe-flex-width, auto);
9
+ height: var(--lobe-flex-height, auto);
10
+ padding: var(--lobe-flex-padding, 0);
11
+ padding-inline: var(--lobe-flex-padding-inline, initial);
12
+ padding-block: var(--lobe-flex-padding-block, initial);
13
+ gap: var(--lobe-flex-gap, 0);
14
+ }
15
+
16
+ .lobe-flex--hidden {
17
+ display: none;
18
+ }
19
+
20
+
@@ -0,0 +1,105 @@
1
+ import type { CSSProperties, ElementType, HTMLAttributes, ReactNode, Ref } from 'react';
2
+ import { DOMAttributes } from 'react';
3
+ export type ContentPosition = 'center' | 'end' | 'flex-end' | 'flex-start' | 'start' | 'stretch' | 'baseline';
4
+ export type FlexDirection = 'vertical' | 'vertical-reverse' | 'horizontal' | 'horizontal-reverse';
5
+ export type DivProps = DOMAttributes<HTMLDivElement> & HTMLAttributes<HTMLDivElement>;
6
+ export type CommonSpaceNumber = 2 | 4 | 8 | 12 | 16 | 24;
7
+ /**
8
+ * Flexbox 布局组件的接口
9
+ */
10
+ export interface IFlexbox {
11
+ /**
12
+ * 交叉轴对齐方式
13
+ * @default "stretch"
14
+ */
15
+ align?: ContentPosition;
16
+ /**
17
+ * 渲染的 HTML 元素类型
18
+ * @default "div"
19
+ */
20
+ as?: ElementType;
21
+ /**
22
+ * 子元素
23
+ */
24
+ children?: ReactNode;
25
+ /**
26
+ * 自定义类名
27
+ */
28
+ className?: string;
29
+ /**
30
+ * 主轴方向
31
+ * @default "horizontal"
32
+ */
33
+ direction?: FlexDirection;
34
+ /**
35
+ * 内容分布
36
+ */
37
+ distribution?: CSSProperties['justifyContent'];
38
+ /**
39
+ * flex 值
40
+ * @default "0 1 auto"
41
+ */
42
+ flex?: number | string;
43
+ /**
44
+ * 主轴方向上的间距
45
+ * @default 0
46
+ */
47
+ gap?: CommonSpaceNumber | number | string;
48
+ /**
49
+ * 高度
50
+ * @default "auto"
51
+ */
52
+ height?: number | string;
53
+ /**
54
+ * 是否横向
55
+ * @default false
56
+ */
57
+ horizontal?: boolean;
58
+ /**
59
+ * 主轴对齐方式
60
+ */
61
+ justify?: CSSProperties['justifyContent'];
62
+ /**
63
+ * 内边距
64
+ * @default 0
65
+ */
66
+ padding?: string | number | CommonSpaceNumber;
67
+ /**
68
+ * 块内边距
69
+ */
70
+ paddingBlock?: string | number;
71
+ /**
72
+ * 内联内边距
73
+ */
74
+ paddingInline?: string | number;
75
+ /**
76
+ * 类名前缀
77
+ */
78
+ prefixCls?: string;
79
+ /**
80
+ * ref 引用
81
+ */
82
+ ref?: Ref<HTMLElement>;
83
+ /**
84
+ * 自定义样式
85
+ */
86
+ style?: CSSProperties;
87
+ /**
88
+ * 是否显示
89
+ * @default true
90
+ */
91
+ visible?: boolean;
92
+ /**
93
+ * 宽度
94
+ * @default "auto"
95
+ */
96
+ width?: number | string;
97
+ /**
98
+ * 换行方式
99
+ */
100
+ wrap?: CSSProperties['flexWrap'];
101
+ }
102
+ export interface FlexBasicProps extends IFlexbox, DivProps {
103
+ }
104
+ export type FlexboxProps = FlexBasicProps;
105
+ export type CenterProps = Omit<FlexBasicProps, 'distribution' | 'direction' | 'align'>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { FlexDirection } from './type';
2
+ export declare const getPrefix: (prefixCls?: string) => string;
3
+ export declare const getFlexDirection: (direction?: FlexDirection, isHorizontal?: boolean) => "column" | "column-reverse" | "row" | "row-reverse";
4
+ export declare const isSpaceDistribution: (distribution?: string) => boolean | undefined;
5
+ export declare const isHorizontal: (direction?: FlexDirection, isHorizontal?: boolean) => boolean;
6
+ export declare const isVertical: (direction?: FlexDirection, isHorizontal?: boolean) => boolean;
7
+ export declare const getCssValue: (value: string | number | undefined) => string | undefined;
@@ -0,0 +1,39 @@
1
+ export var getPrefix = function getPrefix(prefixCls) {
2
+ if (prefixCls) return prefixCls;
3
+ return 'lobe';
4
+ };
5
+ export var getFlexDirection = function getFlexDirection(direction, isHorizontal) {
6
+ if (isHorizontal) return 'row';
7
+ switch (direction) {
8
+ case 'horizontal':
9
+ {
10
+ return 'row';
11
+ }
12
+ case 'horizontal-reverse':
13
+ {
14
+ return 'row-reverse';
15
+ }
16
+ case 'vertical':
17
+ default:
18
+ {
19
+ return 'column';
20
+ }
21
+ case 'vertical-reverse':
22
+ {
23
+ return 'column-reverse';
24
+ }
25
+ }
26
+ };
27
+ export var isSpaceDistribution = function isSpaceDistribution(distribution) {
28
+ if (!distribution) return;
29
+ return ['space-between', 'space-around', 'space-evenly'].includes(distribution);
30
+ };
31
+ export var isHorizontal = function isHorizontal(direction, _isHorizontal) {
32
+ return getFlexDirection(direction, _isHorizontal) === 'row';
33
+ };
34
+ export var isVertical = function isVertical(direction, isHorizontal) {
35
+ return getFlexDirection(direction, isHorizontal) === 'column';
36
+ };
37
+ export var getCssValue = function getCssValue(value) {
38
+ return typeof value === 'number' ? "".concat(value, "px") : value;
39
+ };
package/es/index.d.ts CHANGED
@@ -22,6 +22,7 @@ export { default as EditableText, type EditableTextProps } from './EditableText'
22
22
  export { default as EmojiPicker, type EmojiPickerProps } from './EmojiPicker';
23
23
  export { default as Empty, type EmptyProps } from './Empty';
24
24
  export { default as FileTypeIcon, type FileTypeIconProps } from './FileTypeIcon';
25
+ export { Center, type CenterProps, FlexBasic, type FlexBasicProps, Flexbox, type FlexboxProps, } from './Flex';
25
26
  export { default as FluentEmoji, type FluentEmojiProps } from './FluentEmoji';
26
27
  export { default as FontLoader, type FontLoaderProps } from './FontLoader';
27
28
  export { default as Footer, type FooterProps } from './Footer';
package/es/index.js CHANGED
@@ -22,6 +22,7 @@ export { default as EditableText } from "./EditableText";
22
22
  export { default as EmojiPicker } from "./EmojiPicker";
23
23
  export { default as Empty } from "./Empty";
24
24
  export { default as FileTypeIcon } from "./FileTypeIcon";
25
+ export { Center, FlexBasic, Flexbox } from "./Flex";
25
26
  export { default as FluentEmoji } from "./FluentEmoji";
26
27
  export { default as FontLoader } from "./FontLoader";
27
28
  export { default as Footer } from "./Footer";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",