@lobehub/ui 1.1.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 (111) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +144 -0
  3. package/es/ActionIcon/index.d.ts +15 -0
  4. package/es/ActionIcon/index.js +84 -0
  5. package/es/DraggablePanel/index.d.ts +26 -0
  6. package/es/DraggablePanel/index.js +197 -0
  7. package/es/DraggablePanel/style.d.ts +18 -0
  8. package/es/DraggablePanel/style.js +30 -0
  9. package/es/DraggablePanel/utils.d.ts +2 -0
  10. package/es/DraggablePanel/utils.js +12 -0
  11. package/es/Logo/Logo3D.d.ts +4 -0
  12. package/es/Logo/Logo3D.js +11 -0
  13. package/es/Logo/LogoFlat.d.ts +4 -0
  14. package/es/Logo/LogoFlat.js +104 -0
  15. package/es/Logo/LogoHighContrast.d.ts +4 -0
  16. package/es/Logo/LogoHighContrast.js +26 -0
  17. package/es/Logo/LogoText.d.ts +4 -0
  18. package/es/Logo/LogoText.js +18 -0
  19. package/es/Logo/index.d.ts +8 -0
  20. package/es/Logo/index.js +54 -0
  21. package/es/SideNav/index.d.ts +9 -0
  22. package/es/SideNav/index.js +44 -0
  23. package/es/Template/index.d.ts +7 -0
  24. package/es/Template/index.js +15 -0
  25. package/es/ThemeProvider/GlobalStyle.d.ts +3 -0
  26. package/es/ThemeProvider/GlobalStyle.js +19 -0
  27. package/es/ThemeProvider/index.d.ts +11 -0
  28. package/es/ThemeProvider/index.js +40 -0
  29. package/es/ThemeProvider/token.d.ts +3 -0
  30. package/es/ThemeProvider/token.js +45 -0
  31. package/es/index.d.ts +6 -0
  32. package/es/index.js +6 -0
  33. package/es/styles/algorithms/colorRelationship.d.ts +6 -0
  34. package/es/styles/algorithms/colorRelationship.js +88 -0
  35. package/es/styles/algorithms/index.d.ts +15 -0
  36. package/es/styles/algorithms/index.js +67 -0
  37. package/es/styles/algorithms/paletteGenerator.d.ts +51 -0
  38. package/es/styles/algorithms/paletteGenerator.js +74 -0
  39. package/es/styles/antdTheme.d.ts +2 -0
  40. package/es/styles/antdTheme.js +4 -0
  41. package/es/styles/customStylish.d.ts +17 -0
  42. package/es/styles/customStylish.js +19 -0
  43. package/es/styles/customToken.d.ts +65 -0
  44. package/es/styles/customToken.js +24 -0
  45. package/es/styles/index.d.ts +3 -0
  46. package/es/styles/index.js +3 -0
  47. package/es/styles/theme/dark.d.ts +4 -0
  48. package/es/styles/theme/dark.js +82 -0
  49. package/es/styles/theme/index.d.ts +2 -0
  50. package/es/styles/theme/index.js +2 -0
  51. package/es/styles/theme/light.d.ts +4 -0
  52. package/es/styles/theme/light.js +36 -0
  53. package/es/types/index.d.ts +9 -0
  54. package/es/types/index.js +1 -0
  55. package/es/utils/colorUtils.d.ts +1 -0
  56. package/es/utils/colorUtils.js +10 -0
  57. package/lib/ActionIcon/index.d.ts +15 -0
  58. package/lib/ActionIcon/index.js +110 -0
  59. package/lib/DraggablePanel/index.d.ts +26 -0
  60. package/lib/DraggablePanel/index.js +217 -0
  61. package/lib/DraggablePanel/style.d.ts +18 -0
  62. package/lib/DraggablePanel/style.js +287 -0
  63. package/lib/DraggablePanel/utils.d.ts +2 -0
  64. package/lib/DraggablePanel/utils.js +40 -0
  65. package/lib/Logo/Logo3D.d.ts +4 -0
  66. package/lib/Logo/Logo3D.js +45 -0
  67. package/lib/Logo/LogoFlat.d.ts +4 -0
  68. package/lib/Logo/LogoFlat.js +130 -0
  69. package/lib/Logo/LogoHighContrast.d.ts +4 -0
  70. package/lib/Logo/LogoHighContrast.js +58 -0
  71. package/lib/Logo/LogoText.d.ts +4 -0
  72. package/lib/Logo/LogoText.js +49 -0
  73. package/lib/Logo/index.d.ts +8 -0
  74. package/lib/Logo/index.js +54 -0
  75. package/lib/SideNav/index.d.ts +9 -0
  76. package/lib/SideNav/index.js +58 -0
  77. package/lib/Template/index.d.ts +7 -0
  78. package/lib/Template/index.js +41 -0
  79. package/lib/ThemeProvider/GlobalStyle.d.ts +3 -0
  80. package/lib/ThemeProvider/GlobalStyle.js +80 -0
  81. package/lib/ThemeProvider/index.d.ts +11 -0
  82. package/lib/ThemeProvider/index.js +68 -0
  83. package/lib/ThemeProvider/token.d.ts +3 -0
  84. package/lib/ThemeProvider/token.js +73 -0
  85. package/lib/index.d.ts +6 -0
  86. package/lib/index.js +54 -0
  87. package/lib/styles/algorithms/colorRelationship.d.ts +6 -0
  88. package/lib/styles/algorithms/colorRelationship.js +87 -0
  89. package/lib/styles/algorithms/index.d.ts +15 -0
  90. package/lib/styles/algorithms/index.js +81 -0
  91. package/lib/styles/algorithms/paletteGenerator.d.ts +51 -0
  92. package/lib/styles/algorithms/paletteGenerator.js +91 -0
  93. package/lib/styles/antdTheme.d.ts +2 -0
  94. package/lib/styles/antdTheme.js +30 -0
  95. package/lib/styles/customStylish.d.ts +17 -0
  96. package/lib/styles/customStylish.js +117 -0
  97. package/lib/styles/customToken.d.ts +65 -0
  98. package/lib/styles/customToken.js +54 -0
  99. package/lib/styles/index.d.ts +3 -0
  100. package/lib/styles/index.js +21 -0
  101. package/lib/styles/theme/dark.d.ts +4 -0
  102. package/lib/styles/theme/dark.js +131 -0
  103. package/lib/styles/theme/index.d.ts +2 -0
  104. package/lib/styles/theme/index.js +32 -0
  105. package/lib/styles/theme/light.d.ts +4 -0
  106. package/lib/styles/theme/light.js +64 -0
  107. package/lib/types/index.d.ts +9 -0
  108. package/lib/types/index.js +17 -0
  109. package/lib/utils/colorUtils.d.ts +1 -0
  110. package/lib/utils/colorUtils.js +52 -0
  111. package/package.json +122 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 LobeHub
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,144 @@
1
+ <a name="readme-top"></a>
2
+
3
+ <div align="center">
4
+
5
+ <img width="160" src="https://raw.githubusercontent.com/lobehub/.github/main/profile/Logo.webp">
6
+
7
+ <h1>Lobe UI</h1>
8
+
9
+ Lobe UI is an open-source UI component library for building chatbot web apps
10
+
11
+ [Changelog](./CHANGELOG.md) · [Report Bug][issues-url] · [Request Feature][issues-url]
12
+
13
+ <!-- SHIELD GROUP -->
14
+
15
+ [![release][release-shield]][release-url]
16
+ [![releaseDate][release-date-shield]][release-date-url]
17
+ [![ciTest][ci-test-shield]][ci-test-url]
18
+ [![ciRelease][ci-release-shield]][ci-release-url]
19
+ <br/>
20
+ [![contributors][contributors-shield]][contributors-url]
21
+ [![forks][forks-shield]][forks-url]
22
+ [![stargazers][stargazers-shield]][stargazers-url]
23
+ [![issues][issues-shield]][issues-url]
24
+
25
+ ![](https://github.com/othneildrew/Best-README-Template/raw/master/images/screenshot.png)
26
+
27
+ </div>
28
+
29
+ ## 📦 Installation
30
+
31
+ To install Lobe Commit, run the following command:
32
+
33
+ ```bash
34
+ pnpm add @lobehub/ui
35
+ ```
36
+
37
+ <div align="right">
38
+
39
+ [![][back-to-top]](#readme-top)
40
+
41
+ </div>
42
+
43
+ ## ⌨️ Local Development
44
+
45
+ You can use Gitpod for online development:
46
+
47
+ [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)][gitpod-url]
48
+
49
+ Or clone it for local development:
50
+
51
+ ```bash
52
+ $ git clone https://github.com/lobehub/lobe-ui.git
53
+ $ cd lobe-ui
54
+ $ pnpm install
55
+ $ pnpm start
56
+ ```
57
+
58
+ <div align="right">
59
+
60
+ [![][back-to-top]](#readme-top)
61
+
62
+ </div>
63
+
64
+
65
+ ## 🤝 Contributing
66
+
67
+ <!-- CONTRIBUTION GROUP -->
68
+
69
+ > 📊 Total: <kbd>**3**</kbd>
70
+
71
+ <a href="https://github.com/canisminor1990" title="canisminor1990">
72
+ <img src="https://avatars.githubusercontent.com/u/17870709?v=4" width="50" />
73
+ </a>
74
+ <a href="https://github.com/actions-user" title="actions-user">
75
+ <img src="https://avatars.githubusercontent.com/u/65916846?v=4" width="50" />
76
+ </a>
77
+ <a href="https://github.com/apps/dependabot" title="dependabot[bot]">
78
+ <img src="https://avatars.githubusercontent.com/in/29110?v=4" width="50" />
79
+ </a>
80
+
81
+ <!-- CONTRIBUTION END -->
82
+
83
+ <div align="right">
84
+
85
+ [![][back-to-top]](#readme-top)
86
+
87
+ </div>
88
+
89
+ ---
90
+ #### 📝 License
91
+
92
+ Copyright © 2023 [LobeHub][profile-url]. <br />
93
+ This project is [MIT](./LICENSE) licensed.
94
+
95
+
96
+ <!-- LINK GROUP -->
97
+
98
+ [profile-url]: https://github.com/lobehub
99
+ [issues-url]: https://github.com/lobehub/lobe-ui/issues/new/choose
100
+ [gitpod-url]: https://gitpod.io/#https://github.com/lobehub/lobe-ui
101
+
102
+ <!-- SHIELD LINK GROUP -->
103
+
104
+ [back-to-top]: https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square
105
+
106
+ <!-- release -->
107
+
108
+ [release-shield]: https://img.shields.io/npm/v/@lobehub/ui?label=%F0%9F%A4%AF%20NPM
109
+ [release-url]: https://www.npmjs.com/package/@lobehub/ui
110
+
111
+ <!-- releaseDate -->
112
+
113
+ [release-date-shield]: https://img.shields.io/github/release-date/lobehub/lobe-ui?style=flat
114
+ [release-date-url]: https://github.com/lobehub/lobe-ui/releases
115
+
116
+ <!-- ciTest -->
117
+
118
+ [ci-test-shield]: https://github.com/lobehub/lobe-ui/workflows/Test%20CI/badge.svg
119
+ [ci-test-url]: https://github.com/lobehub/lobe-ui/actions?query=workflow%3ATest%20CI
120
+
121
+ <!-- ciRelease -->
122
+
123
+ [ci-release-shield]: https://github.com/lobehub/lobe-ui/workflows/Release%20CI/badge.svg
124
+ [ci-release-url]: https://github.com/lobehub/lobe-ui/actions?query=workflow%3ARelease%20CI
125
+
126
+ <!-- contributors -->
127
+
128
+ [contributors-shield]: https://img.shields.io/github/contributors/lobehub/lobe-ui.svg?style=flat
129
+ [contributors-url]: https://github.com/lobehub/lobe-ui/graphs/contributors
130
+
131
+ <!-- forks -->
132
+
133
+ [forks-shield]: https://img.shields.io/github/forks/lobehub/lobe-ui.svg?style=flat
134
+ [forks-url]: https://github.com/lobehub/lobe-ui/network/members
135
+
136
+ <!-- stargazers -->
137
+
138
+ [stargazers-shield]: https://img.shields.io/github/stars/lobehub/lobe-ui.svg?style=flat
139
+ [stargazers-url]: https://github.com/lobehub/lobe-ui/stargazers
140
+
141
+ <!-- issues -->
142
+
143
+ [issues-shield]: https://img.shields.io/github/issues/lobehub/lobe-ui.svg?style=flat
144
+ [issues-url]: https://img.shields.io/github/issues/lobehub/lobe-ui.svg?style=flat
@@ -0,0 +1,15 @@
1
+ import { DivProps } from "../types";
2
+ import { LucideIcon } from 'lucide-react';
3
+ import React from 'react';
4
+ export interface ActionIconProps extends DivProps {
5
+ active?: boolean;
6
+ size?: 'large' | 'normal' | 'small' | {
7
+ blockSize: number;
8
+ fontSize: number;
9
+ strokeWidth: number;
10
+ borderRadius: number;
11
+ };
12
+ icon: LucideIcon;
13
+ }
14
+ declare const _default: React.NamedExoticComponent<ActionIconProps>;
15
+ export default _default;
@@ -0,0 +1,84 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
4
+ var _excluded = ["active", "icon", "size", "style"];
5
+ var _templateObject;
6
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
+ import React from 'react';
9
+ import styled from 'styled-components';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ var Block = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n cursor: pointer;\n\n display: flex;\n flex: none;\n align-items: center;\n justify-content: center;\n\n color: ", ";\n\n background: ", ";\n\n transition: all 0.2s ", ";\n\n &:hover {\n background: ", ";\n }\n\n &:active {\n color: ", ";\n background: ", ";\n }\n"])), function (_ref) {
12
+ var active = _ref.active,
13
+ theme = _ref.theme;
14
+ return active ? theme.colorText : theme.colorTextQuaternary;
15
+ }, function (_ref2) {
16
+ var active = _ref2.active,
17
+ theme = _ref2.theme;
18
+ return active ? theme.colorFill : 'transparent';
19
+ }, function (_ref3) {
20
+ var theme = _ref3.theme;
21
+ return theme.motionEaseOut;
22
+ }, function (_ref4) {
23
+ var theme = _ref4.theme;
24
+ return theme.colorFillTertiary;
25
+ }, function (_ref5) {
26
+ var theme = _ref5.theme;
27
+ return theme.colorText;
28
+ }, function (_ref6) {
29
+ var theme = _ref6.theme;
30
+ return theme.colorFill;
31
+ });
32
+ var ActionIcon = function ActionIcon(_ref7) {
33
+ var active = _ref7.active,
34
+ icon = _ref7.icon,
35
+ _ref7$size = _ref7.size,
36
+ size = _ref7$size === void 0 ? 'normal' : _ref7$size,
37
+ style = _ref7.style,
38
+ props = _objectWithoutProperties(_ref7, _excluded);
39
+ var blockSize;
40
+ var fontSize;
41
+ var strokeWidth;
42
+ var borderRadius;
43
+ var Icon = icon;
44
+ switch (size) {
45
+ case 'large':
46
+ blockSize = 44;
47
+ fontSize = 24;
48
+ strokeWidth = 2;
49
+ borderRadius = 8;
50
+ break;
51
+ case 'normal':
52
+ blockSize = 36;
53
+ fontSize = 24;
54
+ strokeWidth = 2;
55
+ borderRadius = 5;
56
+ break;
57
+ case 'small':
58
+ blockSize = 28;
59
+ fontSize = 20;
60
+ strokeWidth = 1.5;
61
+ borderRadius = 5;
62
+ break;
63
+ default:
64
+ blockSize = (size === null || size === void 0 ? void 0 : size.blockSize) || 36;
65
+ fontSize = (size === null || size === void 0 ? void 0 : size.fontSize) || 24;
66
+ strokeWidth = (size === null || size === void 0 ? void 0 : size.strokeWidth) || 2;
67
+ borderRadius = (size === null || size === void 0 ? void 0 : size.borderRadius) || 5;
68
+ break;
69
+ }
70
+ return /*#__PURE__*/_jsx(Block, _objectSpread(_objectSpread({
71
+ active: active,
72
+ style: _objectSpread({
73
+ width: blockSize,
74
+ height: blockSize,
75
+ borderRadius: borderRadius
76
+ }, style)
77
+ }, props), {}, {
78
+ children: /*#__PURE__*/_jsx(Icon, {
79
+ size: fontSize,
80
+ strokeWidth: strokeWidth
81
+ })
82
+ }));
83
+ };
84
+ export default /*#__PURE__*/React.memo(ActionIcon);
@@ -0,0 +1,26 @@
1
+ import type { DivProps } from "../types";
2
+ import type { NumberSize, Size } from 're-resizable';
3
+ import React from 'react';
4
+ import type { Props as RndProps } from 'react-rnd';
5
+ export declare type placementType = 'right' | 'left' | 'top' | 'bottom';
6
+ export interface DraggablePanelProps extends DivProps {
7
+ pin?: boolean;
8
+ mode?: 'fixed' | 'float';
9
+ placement: placementType;
10
+ minWidth?: number;
11
+ minHeight?: number;
12
+ resize?: RndProps['enableResizing'];
13
+ size?: Partial<Size>;
14
+ onSizeChange?: (delta: NumberSize, size?: Size) => void;
15
+ onSizeDragging?: (delta: NumberSize, size?: Size) => void;
16
+ expandable?: boolean;
17
+ expand?: boolean;
18
+ defaultExpand?: boolean;
19
+ onExpandChange?: (expand: boolean) => void;
20
+ defaultSize?: Partial<Size>;
21
+ destroyOnClose?: boolean;
22
+ showHandlerWhenUnexpand?: boolean;
23
+ hanlderStyle?: React.CSSProperties;
24
+ }
25
+ declare const _default: React.NamedExoticComponent<DraggablePanelProps>;
26
+ export default _default;
@@ -0,0 +1,197 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
+ import { useHover } from 'ahooks';
6
+ import { ChevronDown, ChevronLeft, ChevronRight, ChevronUp } from 'lucide-react';
7
+ import { Resizable } from 're-resizable';
8
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
9
+ import { Center } from 'react-layout-kit';
10
+ import useControlledState from 'use-merge-value';
11
+ import { useStyle } from "./style";
12
+ import { revesePlacement } from "./utils";
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { jsxs as _jsxs } from "react/jsx-runtime";
15
+ var DEFAULT_HEIGHT = 180;
16
+ var DEFAULT_WIDTH = 280;
17
+ var DraggablePanel = function DraggablePanel(_ref) {
18
+ var _ref$pin = _ref.pin,
19
+ pin = _ref$pin === void 0 ? 'true' : _ref$pin,
20
+ _ref$mode = _ref.mode,
21
+ mode = _ref$mode === void 0 ? 'fixed' : _ref$mode,
22
+ children = _ref.children,
23
+ _ref$placement = _ref.placement,
24
+ placement = _ref$placement === void 0 ? 'right' : _ref$placement,
25
+ resize = _ref.resize,
26
+ style = _ref.style,
27
+ size = _ref.size,
28
+ customizeDefaultSize = _ref.defaultSize,
29
+ minWidth = _ref.minWidth,
30
+ minHeight = _ref.minHeight,
31
+ onSizeChange = _ref.onSizeChange,
32
+ onSizeDragging = _ref.onSizeDragging,
33
+ _ref$expandable = _ref.expandable,
34
+ expandable = _ref$expandable === void 0 ? true : _ref$expandable,
35
+ expand = _ref.expand,
36
+ _ref$defaultExpand = _ref.defaultExpand,
37
+ defaultExpand = _ref$defaultExpand === void 0 ? true : _ref$defaultExpand,
38
+ onExpandChange = _ref.onExpandChange,
39
+ className = _ref.className,
40
+ showHandlerWhenUnexpand = _ref.showHandlerWhenUnexpand,
41
+ destroyOnClose = _ref.destroyOnClose,
42
+ hanlderStyle = _ref.hanlderStyle;
43
+ var ref = useRef(null);
44
+ var isHovering = useHover(ref);
45
+ var isVertical = placement === 'top' || placement === 'bottom';
46
+ var _useStyle = useStyle('draggable-panel'),
47
+ styles = _useStyle.styles,
48
+ cx = _useStyle.cx;
49
+ var _useControlledState = useControlledState(defaultExpand, {
50
+ value: expand,
51
+ onChange: onExpandChange
52
+ }),
53
+ _useControlledState2 = _slicedToArray(_useControlledState, 2),
54
+ isExpand = _useControlledState2[0],
55
+ setIsExpand = _useControlledState2[1];
56
+ useEffect(function () {
57
+ if (pin) return;
58
+ if (isHovering && !isExpand) {
59
+ setIsExpand(true);
60
+ } else if (!isHovering && isExpand) {
61
+ setIsExpand(false);
62
+ }
63
+ }, [pin, isHovering, isExpand]);
64
+ var _useState = useState(true),
65
+ _useState2 = _slicedToArray(_useState, 2),
66
+ showExpand = _useState2[0],
67
+ setShowExpand = _useState2[1];
68
+ var canResizing = resize !== false && isExpand;
69
+ var resizeHandleClassNames = useMemo(function () {
70
+ if (!canResizing) return {};
71
+ return _defineProperty({}, revesePlacement(placement), styles["".concat(revesePlacement(placement), "Handle")]);
72
+ }, [canResizing, placement]);
73
+ var resizing = _objectSpread(_defineProperty({
74
+ top: false,
75
+ bottom: false,
76
+ right: false,
77
+ left: false,
78
+ topRight: false,
79
+ bottomRight: false,
80
+ bottomLeft: false,
81
+ topLeft: false
82
+ }, revesePlacement(placement), true), resize);
83
+ var defaultSize = useMemo(function () {
84
+ if (isVertical) return _objectSpread({
85
+ width: '100%',
86
+ height: DEFAULT_HEIGHT
87
+ }, customizeDefaultSize);
88
+ return _objectSpread({
89
+ width: DEFAULT_WIDTH,
90
+ height: '100%'
91
+ }, customizeDefaultSize);
92
+ }, [isVertical]);
93
+ var sizeProps = isExpand ? {
94
+ minWidth: typeof minWidth === 'number' ? Math.max(minWidth, 0) : 280,
95
+ minHeight: typeof minHeight === 'number' ? Math.max(minHeight, 0) : undefined,
96
+ defaultSize: defaultSize,
97
+ size: size
98
+ } : isVertical ? {
99
+ minHeight: 0,
100
+ size: {
101
+ height: 0
102
+ }
103
+ } : {
104
+ minWidth: 0,
105
+ size: {
106
+ width: 0
107
+ }
108
+ };
109
+ var _useMemo = useMemo(function () {
110
+ switch (placement) {
111
+ case 'top':
112
+ return {
113
+ className: 'Bottom',
114
+ Arrow: ChevronDown
115
+ };
116
+ case 'bottom':
117
+ return {
118
+ className: 'Top',
119
+ Arrow: ChevronUp
120
+ };
121
+ case 'right':
122
+ return {
123
+ className: 'Left',
124
+ Arrow: ChevronLeft
125
+ };
126
+ case 'left':
127
+ return {
128
+ className: 'Right',
129
+ Arrow: ChevronRight
130
+ };
131
+ }
132
+ }, [styles, placement]),
133
+ Arrow = _useMemo.Arrow,
134
+ arrowPlacement = _useMemo.className;
135
+ var handler =
136
+ /*#__PURE__*/
137
+ // @ts-ignore
138
+ _jsx(Center
139
+ // @ts-ignore
140
+ , {
141
+ className: cx(styles["toggle".concat(arrowPlacement)]),
142
+ style: {
143
+ opacity: isExpand ? !pin ? 0 : undefined : showHandlerWhenUnexpand ? 1 : 0
144
+ },
145
+ children: /*#__PURE__*/_jsx(Center, {
146
+ style: hanlderStyle,
147
+ onClick: function onClick() {
148
+ setIsExpand(!isExpand);
149
+ },
150
+ children: /*#__PURE__*/_jsx("div", {
151
+ className: styles.handlerIcon,
152
+ style: {
153
+ transform: "rotate(".concat(isExpand ? 180 : 0, "deg)")
154
+ },
155
+ children: /*#__PURE__*/_jsx(Arrow, {
156
+ size: 16,
157
+ strokeWidth: 1.5
158
+ })
159
+ })
160
+ })
161
+ });
162
+ var inner =
163
+ /*#__PURE__*/
164
+ // @ts-ignore
165
+ _jsx(Resizable, _objectSpread(_objectSpread({}, sizeProps), {}, {
166
+ style: style,
167
+ className: styles.panel,
168
+ enable: canResizing ? resizing : undefined,
169
+ handleClasses: resizeHandleClassNames,
170
+ onResizeStop: function onResizeStop(e, direction, ref, delta) {
171
+ setShowExpand(true);
172
+ onSizeChange === null || onSizeChange === void 0 ? void 0 : onSizeChange(delta, {
173
+ width: ref.style.width,
174
+ height: ref.style.height
175
+ });
176
+ },
177
+ onResizeStart: function onResizeStart() {
178
+ setShowExpand(false);
179
+ },
180
+ onResize: function onResize(_, direction, ref, delta) {
181
+ onSizeDragging === null || onSizeDragging === void 0 ? void 0 : onSizeDragging(delta, {
182
+ width: ref.style.width,
183
+ height: ref.style.height
184
+ });
185
+ },
186
+ children: children
187
+ }));
188
+ return /*#__PURE__*/_jsxs("div", {
189
+ ref: ref,
190
+ className: cx(styles.container,
191
+ // @ts-ignore
192
+ styles[mode === 'fixed' ? 'fixed' : "".concat(placement, "Float")], className),
193
+ style: _defineProperty({}, "border".concat(arrowPlacement, "Width"), 1),
194
+ children: [expandable && showExpand && handler, destroyOnClose ? isExpand && inner : inner]
195
+ });
196
+ };
197
+ export default /*#__PURE__*/React.memo(DraggablePanel);
@@ -0,0 +1,18 @@
1
+ export declare const useStyle: (props?: string | undefined) => import("antd-style").ReturnStyles<{
2
+ container: string;
3
+ fixed: import("antd-style").SerializedStyles;
4
+ leftFloat: string;
5
+ rightFloat: string;
6
+ topFloat: string;
7
+ bottomFloat: string;
8
+ toggleLeft: string;
9
+ toggleRight: string;
10
+ toggleTop: string;
11
+ toggleBottom: string;
12
+ panel: string;
13
+ handlerIcon: import("antd-style").SerializedStyles;
14
+ leftHandle: string;
15
+ rightHandle: string;
16
+ topHandle: string;
17
+ bottomHandle: string;
18
+ }>;
@@ -0,0 +1,30 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19;
3
+ import { createStyles, css, cx } from 'antd-style';
4
+ var offset = 16;
5
+ var toggleLength = 40;
6
+ var toggleShort = 16;
7
+ export var useStyle = createStyles(function (_ref, prefix) {
8
+ var token = _ref.token;
9
+ var commonHandle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n &::before {\n content: '';\n position: absolute;\n z-index: 50;\n transition: all 0.2s ", ";\n }\n\n &:hover,\n &:active {\n &::before {\n background: ", ";\n }\n }\n "])), token.motionEaseOut, token.colorPrimary);
10
+ var commonToggle = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n z-index: 1001;\n opacity: 0;\n transition: all 0.2s ", ";\n\n &:hover {\n opacity: 1 !important;\n }\n\n &:active {\n opacity: 1 !important;\n }\n\n > div {\n cursor: pointer;\n\n position: absolute;\n\n color: ", ";\n\n background: ", ";\n border-color: ", ";\n border-style: solid;\n border-width: 1px;\n border-radius: 4px;\n\n transition: all 0.2s ", ";\n\n &:hover {\n color: ", ";\n background: ", ";\n }\n\n &:active {\n color: ", ";\n background: ", ";\n }\n }\n "])), token.motionEaseOut, token.colorTextTertiary, token.colorFillTertiary, token.colorBorderSecondary, token.motionEaseOut, token.colorTextSecondary, token.colorFillSecondary, token.colorText, token.colorFill);
11
+ var float = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: absolute;\n z-index: 2000;\n "])));
12
+ return {
13
+ container: cx(prefix, css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n flex-shrink: 0;\n border: 0 solid ", ";\n\n &:hover {\n .", "-toggle {\n opacity: 1;\n }\n }\n "])), token.colorBorderSecondary, prefix)),
14
+ fixed: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n position: relative;\n "]))),
15
+ leftFloat: cx(float, css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n top: 0;\n bottom: 0;\n left: 0;\n height: 100%;\n "])))),
16
+ rightFloat: cx(float, css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n top: 0;\n right: 0;\n bottom: 0;\n height: 100%;\n "])))),
17
+ topFloat: cx(float, css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n top: 0;\n right: 0;\n left: 0;\n width: 100%;\n "])))),
18
+ bottomFloat: cx(float, css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n right: 0;\n bottom: 0;\n left: 0;\n width: 100%;\n "])))),
19
+ toggleLeft: cx("".concat(prefix, "-toggle"), "".concat(prefix, "-toggle-left"), commonToggle, css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n left: -", "px;\n width: ", "px;\n height: 100%;\n > div {\n top: 50%;\n\n width: ", "px;\n height: ", "px;\n margin-top: -20px;\n\n border-radius: 4px 0 0 4px;\n }\n "])), offset, toggleShort, toggleShort, toggleLength)),
20
+ toggleRight: cx("".concat(prefix, "-toggle"), "".concat(prefix, "-toggle-right"), commonToggle, css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n right: -", "px;\n width: ", "px;\n height: 100%;\n > div {\n top: 50%;\n\n width: ", "px;\n height: ", "px;\n margin-top: -20px;\n\n border-radius: 0 4px 4px 0;\n }\n "])), offset, toggleShort, toggleShort, toggleLength)),
21
+ toggleTop: cx("".concat(prefix, "-toggle"), "".concat(prefix, "-toggle-top"), commonToggle, css(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n top: -", "px;\n width: 100%;\n height: ", "px;\n\n > div {\n left: 50%;\n\n width: ", "px;\n height: ", "px;\n margin-left: -20px;\n\n border-radius: 4px 4px 0 0;\n }\n "])), offset, toggleShort, toggleLength, toggleShort)),
22
+ toggleBottom: cx("".concat(prefix, "-toggle"), "".concat(prefix, "-toggle-bottom"), commonToggle, css(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n bottom: -", "px;\n width: 100%;\n height: ", "px;\n\n > div {\n left: 50%;\n\n width: ", "px;\n height: 16px;\n margin-left: -20px;\n\n border-radius: 0 0 4px 4px;\n }\n "])), offset, toggleShort, toggleLength)),
23
+ panel: cx("".concat(prefix, "-fixed"), css(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n overflow: hidden;\n background: ", ";\n transition: all 0.2s ", ";\n "])), token.colorBgContainer, token.motionEaseOut)),
24
+ handlerIcon: css(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ", ";\n "])), token.motionEaseOut),
25
+ leftHandle: cx(css(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\n ", ";\n\n &::before {\n left: 50%;\n width: 2px;\n height: 100%;\n }\n "])), commonHandle), "".concat(prefix, "-left-handle")),
26
+ rightHandle: cx(css(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["\n ", ";\n &::before {\n right: 50%;\n width: 2px;\n height: 100%;\n }\n "])), commonHandle), "".concat(prefix, "-right-handle")),
27
+ topHandle: cx("".concat(prefix, "-top-handle"), css(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["\n ", ";\n\n &::before {\n top: 50%;\n width: 100%;\n height: 2px;\n }\n "])), commonHandle)),
28
+ bottomHandle: cx("".concat(prefix, "-bottom-handle"), css(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["\n ", ";\n\n &::before {\n bottom: 50%;\n width: 100%;\n height: 2px;\n }\n "])), commonHandle))
29
+ };
30
+ });
@@ -0,0 +1,2 @@
1
+ import { placementType } from './index';
2
+ export declare const revesePlacement: (placement: placementType) => "left" | "right" | "bottom" | "top";
@@ -0,0 +1,12 @@
1
+ export var revesePlacement = function revesePlacement(placement) {
2
+ switch (placement) {
3
+ case 'bottom':
4
+ return 'top';
5
+ case 'top':
6
+ return 'bottom';
7
+ case 'right':
8
+ return 'left';
9
+ case 'left':
10
+ return 'right';
11
+ }
12
+ };
@@ -0,0 +1,4 @@
1
+ import { ImgProps } from "../types";
2
+ import React from 'react';
3
+ declare const _default: React.NamedExoticComponent<ImgProps>;
4
+ export default _default;