@lobehub/ui 1.127.0 → 1.128.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.
@@ -9,7 +9,7 @@ export interface ItemGroup {
9
9
  icon?: FormGroupProps['icon'];
10
10
  title: FormGroupProps['title'];
11
11
  }
12
- export interface FormProps extends AntFormProps {
12
+ export interface FormProps extends Omit<AntFormProps, 'variant'> {
13
13
  children?: ReactNode;
14
14
  footer?: ReactNode;
15
15
  itemMinWidth?: FormItemProps['minWidth'];
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { type ActionIconProps } from "../ActionIcon";
3
+ declare const DragHandle: React.NamedExoticComponent<ActionIconProps>;
4
+ export default DragHandle;
@@ -0,0 +1,21 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ 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; }
3
+ 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; }
4
+ import { GripVertical } from 'lucide-react';
5
+ import React, { memo, useContext } from 'react';
6
+ import ActionIcon from "../ActionIcon";
7
+ import { SortableItemContext } from "./SortableItem";
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ var DragHandle = /*#__PURE__*/memo(function (props) {
10
+ var _useContext = useContext(SortableItemContext),
11
+ attributes = _useContext.attributes,
12
+ listeners = _useContext.listeners,
13
+ ref = _useContext.ref;
14
+ return /*#__PURE__*/_jsx(ActionIcon, _objectSpread(_objectSpread(_objectSpread(_objectSpread({
15
+ icon: GripVertical,
16
+ size: 'small'
17
+ }, props), attributes), listeners), {}, {
18
+ ref: ref
19
+ }));
20
+ });
21
+ export default DragHandle;
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ import type { DraggableSyntheticListeners } from '@dnd-kit/core';
3
+ import { type FlexboxProps } from 'react-layout-kit';
4
+ interface Context {
5
+ attributes: Record<string, any>;
6
+ listeners: DraggableSyntheticListeners;
7
+ ref(node: HTMLElement | null): void;
8
+ }
9
+ export declare const SortableItemContext: import("react").Context<Context>;
10
+ export interface SortableItemProps extends Omit<FlexboxProps, 'id'> {
11
+ id: string | number;
12
+ }
13
+ declare const SortableItem: import("react").NamedExoticComponent<SortableItemProps>;
14
+ export default SortableItem;
@@ -0,0 +1,60 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["children", "id", "style"];
4
+ 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; }
5
+ 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; }
6
+ import { useSortable } from '@dnd-kit/sortable';
7
+ import { CSS } from '@dnd-kit/utilities';
8
+ import { createContext, memo, useMemo } from 'react';
9
+ import { Flexbox } from 'react-layout-kit';
10
+ import { useStyles } from "./style";
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ export var SortableItemContext = /*#__PURE__*/createContext({
13
+ attributes: {},
14
+ listeners: undefined,
15
+ ref: function ref() {}
16
+ });
17
+ var SortableItem = /*#__PURE__*/memo(function (_ref) {
18
+ var children = _ref.children,
19
+ id = _ref.id,
20
+ style = _ref.style,
21
+ rest = _objectWithoutProperties(_ref, _excluded);
22
+ var _useStyles = useStyles(),
23
+ styles = _useStyles.styles;
24
+ var _useSortable = useSortable({
25
+ id: id
26
+ }),
27
+ attributes = _useSortable.attributes,
28
+ isDragging = _useSortable.isDragging,
29
+ listeners = _useSortable.listeners,
30
+ setNodeRef = _useSortable.setNodeRef,
31
+ setActivatorNodeRef = _useSortable.setActivatorNodeRef,
32
+ transform = _useSortable.transform,
33
+ transition = _useSortable.transition;
34
+ var context = useMemo(function () {
35
+ return {
36
+ attributes: attributes,
37
+ listeners: listeners,
38
+ ref: setActivatorNodeRef
39
+ };
40
+ }, [attributes, listeners, setActivatorNodeRef]);
41
+ return /*#__PURE__*/_jsx(SortableItemContext.Provider, {
42
+ value: context,
43
+ children: /*#__PURE__*/_jsx(Flexbox, _objectSpread(_objectSpread({
44
+ align: 'center',
45
+ as: 'li',
46
+ className: styles.item,
47
+ gap: 4,
48
+ horizontal: true,
49
+ ref: setNodeRef,
50
+ style: _objectSpread({
51
+ opacity: isDragging ? 0.4 : undefined,
52
+ transform: CSS.Translate.toString(transform),
53
+ transition: transition
54
+ }, style)
55
+ }, rest), {}, {
56
+ children: children
57
+ }))
58
+ });
59
+ });
60
+ export default SortableItem;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ declare const SortableOverlay: import("react").NamedExoticComponent<{
3
+ children?: import("react").ReactNode;
4
+ }>;
5
+ export default SortableOverlay;
@@ -0,0 +1,20 @@
1
+ import { DragOverlay, defaultDropAnimationSideEffects } from '@dnd-kit/core';
2
+ import { memo } from 'react';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ var dropAnimationConfig = {
5
+ sideEffects: defaultDropAnimationSideEffects({
6
+ styles: {
7
+ active: {
8
+ opacity: '0.4'
9
+ }
10
+ }
11
+ })
12
+ };
13
+ var SortableOverlay = /*#__PURE__*/memo(function (_ref) {
14
+ var children = _ref.children;
15
+ return /*#__PURE__*/_jsx(DragOverlay, {
16
+ dropAnimation: dropAnimationConfig,
17
+ children: children
18
+ });
19
+ });
20
+ export default SortableOverlay;
@@ -0,0 +1,20 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type FlexboxProps } from 'react-layout-kit';
3
+ import DragHandle from './DragHandle';
4
+ import SortableItem from './SortableItem';
5
+ interface BaseItem {
6
+ [key: string]: any;
7
+ id: string | number;
8
+ }
9
+ export interface SortableListProps extends Omit<FlexboxProps, 'onChange'> {
10
+ items: BaseItem[];
11
+ onChange(items: BaseItem[]): void;
12
+ renderItem(item: BaseItem): ReactNode;
13
+ }
14
+ export interface ISortableList {
15
+ (props: SortableListProps): ReactNode;
16
+ DragHandle: typeof DragHandle;
17
+ Item: typeof SortableItem;
18
+ }
19
+ declare const SortableList: ISortableList;
20
+ export default SortableList;
@@ -0,0 +1,84 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
+ var _excluded = ["items", "onChange", "renderItem", "gap"];
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
+ import { DndContext, KeyboardSensor, PointerSensor, useSensor, useSensors } from '@dnd-kit/core';
8
+ import { SortableContext, arrayMove, sortableKeyboardCoordinates } from '@dnd-kit/sortable';
9
+ import { Fragment, memo, useMemo, useState } from 'react';
10
+ import { Flexbox } from 'react-layout-kit';
11
+ import DragHandle from "./DragHandle";
12
+ import SortableItem from "./SortableItem";
13
+ import SortableOverlay from "./SortableOverlay";
14
+ import { useStyles } from "./style";
15
+ import { jsx as _jsx } from "react/jsx-runtime";
16
+ import { jsxs as _jsxs } from "react/jsx-runtime";
17
+ var SortableListParent = /*#__PURE__*/memo(function (_ref) {
18
+ var items = _ref.items,
19
+ onChange = _ref.onChange,
20
+ renderItem = _ref.renderItem,
21
+ _ref$gap = _ref.gap,
22
+ gap = _ref$gap === void 0 ? 8 : _ref$gap,
23
+ rest = _objectWithoutProperties(_ref, _excluded);
24
+ var _useState = useState(null),
25
+ _useState2 = _slicedToArray(_useState, 2),
26
+ active = _useState2[0],
27
+ setActive = _useState2[1];
28
+ var _useStyles = useStyles(),
29
+ styles = _useStyles.styles;
30
+ var activeItem = useMemo(function () {
31
+ return items.find(function (item) {
32
+ return item.id === (active === null || active === void 0 ? void 0 : active.id);
33
+ });
34
+ }, [active, items]);
35
+ var sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, {
36
+ coordinateGetter: sortableKeyboardCoordinates
37
+ }));
38
+ return /*#__PURE__*/_jsxs(DndContext, {
39
+ onDragCancel: function onDragCancel() {
40
+ setActive(null);
41
+ },
42
+ onDragEnd: function onDragEnd(_ref2) {
43
+ var active = _ref2.active,
44
+ over = _ref2.over;
45
+ if (over && active.id !== (over === null || over === void 0 ? void 0 : over.id)) {
46
+ var activeIndex = items.findIndex(function (_ref3) {
47
+ var id = _ref3.id;
48
+ return id === active.id;
49
+ });
50
+ var overIndex = items.findIndex(function (_ref4) {
51
+ var id = _ref4.id;
52
+ return id === over.id;
53
+ });
54
+ onChange(arrayMove(items, activeIndex, overIndex));
55
+ }
56
+ setActive(null);
57
+ },
58
+ onDragStart: function onDragStart(_ref5) {
59
+ var active = _ref5.active;
60
+ setActive(active);
61
+ },
62
+ sensors: sensors,
63
+ children: [/*#__PURE__*/_jsx(SortableContext, {
64
+ items: items,
65
+ children: /*#__PURE__*/_jsx(Flexbox, _objectSpread(_objectSpread({
66
+ as: 'ul',
67
+ className: styles.container,
68
+ gap: gap
69
+ }, rest), {}, {
70
+ children: items.map(function (item) {
71
+ return /*#__PURE__*/_jsx(Fragment, {
72
+ children: renderItem(item)
73
+ }, item.id);
74
+ })
75
+ }))
76
+ }), /*#__PURE__*/_jsx(SortableOverlay, {
77
+ children: activeItem ? renderItem(activeItem) : null
78
+ })]
79
+ });
80
+ });
81
+ var SortableList = SortableListParent;
82
+ SortableList.Item = SortableItem;
83
+ SortableList.DragHandle = DragHandle;
84
+ export default SortableList;
@@ -0,0 +1,4 @@
1
+ export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
2
+ container: import("antd-style").SerializedStyles;
3
+ item: import("antd-style").SerializedStyles;
4
+ }>;
@@ -0,0 +1,10 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2;
3
+ import { createStyles } from 'antd-style';
4
+ export var useStyles = createStyles(function (_ref) {
5
+ var css = _ref.css;
6
+ return {
7
+ container: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 0;\n list-style: none;\n "]))),
8
+ item: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n box-sizing: border-box;\n list-style: none;\n "])))
9
+ };
10
+ });
@@ -3,5 +3,5 @@ var _templateObject;
3
3
  import { css } from 'antd-style';
4
4
  import { readableColor, rgba } from 'polished';
5
5
  export default (function (token) {
6
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .", "-checkbox-inner:after {\n border-color: ", " !important;\n }\n\n .", "-btn {\n box-shadow: none;\n }\n\n .", "-btn-primary:not(:disabled) {\n color: ", " !important;\n\n &:hover {\n color: ", " !important;\n }\n\n &:active {\n color: ", " !important;\n }\n }\n\n .", "-tooltip-inner {\n display: flex;\n align-items: center;\n justify-content: center;\n\n min-height: unset;\n padding: 4px 8px;\n\n color: ", " !important;\n\n background-color: ", " !important;\n border-radius: ", "px !important;\n }\n\n .", "-tooltip-arrow {\n &::before,\n &::after {\n background: ", " !important;\n }\n }\n\n .", "-switch-handle::before {\n background: ", " !important;\n }\n\n .", "-image-preview-close,\n .", "-image-preview-switch-right,.", "-image-preview-switch-left {\n ", ";\n border-radius: ", "px;\n background: ", ";\n\n width: 32px;\n height: 32px;\n\n display: flex;\n align-items: center;\n justify-content: center;\n\n padding: 0;\n }\n\n .", "-dropdown {\n .", "-dropdown-menu {\n border: 1px solid ", ";\n border-radius: ", "px !important;\n box-shadow: ", ";\n }\n }\n\n @media (max-width: 575px) {\n .", "-tooltip {\n display: none !important;\n }\n }\n"])), token.prefixCls, readableColor(token.colorPrimary), token.prefixCls, token.prefixCls, readableColor(token.colorPrimary), readableColor(token.colorPrimary), readableColor(token.colorPrimaryActive), token.prefixCls, token.colorBgLayout, token.colorText, token.borderRadiusSM, token.prefixCls, token.colorText, token.prefixCls, token.colorBgContainer, token.prefixCls, token.prefixCls, token.prefixCls, token.stylish.blur, token.borderRadiusLG, rgba(token.colorBgMask, 0.1), token.prefixCls, token.prefixCls, token.colorBorderSecondary, token.borderRadius, token.boxShadowSecondary, token.prefixCls);
6
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .", "-checkbox-inner:after {\n border-color: ", " !important;\n }\n\n .", "-btn {\n box-shadow: none;\n }\n\n .", "-btn-primary:not(:disabled) {\n color: ", " !important;\n\n &:hover {\n color: ", " !important;\n }\n\n &:active {\n color: ", " !important;\n }\n }\n\n .", "-tooltip-inner {\n display: flex;\n align-items: center;\n justify-content: center;\n\n min-height: unset;\n padding: 4px 8px;\n\n color: ", " !important;\n\n background-color: ", " !important;\n border-radius: ", "px !important;\n }\n\n .", "-tooltip-arrow {\n &::before,\n &::after {\n background: ", " !important;\n }\n }\n\n .", "-switch-handle::before {\n background: ", " !important;\n }\n\n .", "-image-preview-close,\n .", "-image-preview-switch-right,.", "-image-preview-switch-left {\n ", ";\n border-radius: ", "px;\n background: ", ";\n\n width: 32px;\n height: 32px;\n\n display: flex;\n align-items: center;\n justify-content: center;\n\n padding: 0;\n }\n\n .", "-popover-inner {\n border: 1px solid ", ";\n box-shadow: ", ";\n }\n\n ul.", "-dropdown-menu {\n border: 1px solid ", ";\n border-radius: ", "px !important;\n box-shadow: ", ";\n }\n\n @media (max-width: 575px) {\n .", "-tooltip {\n display: none !important;\n }\n }\n"])), token.prefixCls, readableColor(token.colorPrimary), token.prefixCls, token.prefixCls, readableColor(token.colorPrimary), readableColor(token.colorPrimary), readableColor(token.colorPrimaryActive), token.prefixCls, token.colorBgLayout, token.colorText, token.borderRadiusSM, token.prefixCls, token.colorText, token.prefixCls, token.colorBgContainer, token.prefixCls, token.prefixCls, token.prefixCls, token.stylish.blur, token.borderRadiusLG, rgba(token.colorBgMask, 0.1), token.prefixCls, token.colorBorderSecondary, token.boxShadowSecondary, token.prefixCls, token.colorBorderSecondary, token.borderRadius, token.boxShadowSecondary, token.prefixCls);
7
7
  });
package/es/index.d.ts CHANGED
@@ -68,17 +68,10 @@ export { default as SelectWithImg, type SelectWithImgOptionItem, type SelectWith
68
68
  export { default as SideNav, type SideNavProps } from './SideNav';
69
69
  export { default as SliderWithInput, type SliderWithInputProps } from './SliderWithInput';
70
70
  export { default as Snippet, type SnippetProps } from './Snippet';
71
+ export { default as SortableList, type SortableListProps } from './SortableList';
71
72
  export { default as Spotlight, type SpotlightProps } from './Spotlight';
72
73
  export { default as SpotlightCard, type SpotlightCardProps } from './SpotlightCard';
73
- export { default as StoryBook, type StoryBookProps,
74
- /**
75
- * @deprecated Use `StoryBookProps` instead. It was a typo.
76
- */
77
- default as StroyBook,
78
- /**
79
- * @deprecated Use `StoryBookProps` instead. It was a typo.
80
- */
81
- type StoryBookProps as StroyBookProps, useControls, useCreateStore, } from './StoryBook';
74
+ export { default as StoryBook, type StoryBookProps, useControls, useCreateStore, } from './StoryBook';
82
75
  export * from './styles';
83
76
  export { default as Swatches, type SwatchesProps } from './Swatches';
84
77
  export { default as TabsNav, type TabsNavProps } from './TabsNav';
package/es/index.js CHANGED
@@ -67,16 +67,10 @@ export { default as SelectWithImg } from "./SelectWithImg";
67
67
  export { default as SideNav } from "./SideNav";
68
68
  export { default as SliderWithInput } from "./SliderWithInput";
69
69
  export { default as Snippet } from "./Snippet";
70
+ export { default as SortableList } from "./SortableList";
70
71
  export { default as Spotlight } from "./Spotlight";
71
72
  export { default as SpotlightCard } from "./SpotlightCard";
72
- export { default as StoryBook,
73
- /**
74
- * @deprecated Use `StoryBookProps` instead. It was a typo.
75
- */
76
- default as StroyBook
77
- /**
78
- * @deprecated Use `StoryBookProps` instead. It was a typo.
79
- */, useControls, useCreateStore } from "./StoryBook";
73
+ export { default as StoryBook, useControls, useCreateStore } from "./StoryBook";
80
74
  export * from "./styles";
81
75
  export { default as Swatches } from "./Swatches";
82
76
  export { default as TabsNav } from "./TabsNav";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.127.0",
3
+ "version": "1.128.0",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",
@@ -31,6 +31,7 @@
31
31
  "build:watch": "father dev",
32
32
  "ci": "npm run lint && npm run type-check",
33
33
  "clean": "rm -r es lib dist coverage .dumi/tmp .eslintcache node_modules/.cache",
34
+ "dev": "father dev",
34
35
  "docs:build": "dumi build",
35
36
  "docs:build-analyze": "ANALYZE=1 dumi build",
36
37
  "docs:dev": "dumi dev",
@@ -73,6 +74,9 @@
73
74
  "@ant-design/colors": "^7",
74
75
  "@ant-design/icons": "^5",
75
76
  "@babel/runtime": "^7",
77
+ "@dnd-kit/core": "^6",
78
+ "@dnd-kit/sortable": "^8",
79
+ "@dnd-kit/utilities": "^3",
76
80
  "@emoji-mart/data": "^1",
77
81
  "@emoji-mart/react": "^1",
78
82
  "@floating-ui/react": "^0",