@tiny-codes/react-easy 1.1.2 → 1.2.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 (140) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/es/components/BreakLines/index.d.ts +13 -19
  3. package/es/components/BreakLines/index.js +2 -3
  4. package/es/components/BreakLines/index.js.map +1 -1
  5. package/es/components/ConfigProvider/context.d.ts +20 -26
  6. package/es/components/ConfigProvider/context.js.map +1 -1
  7. package/es/components/ConfigProvider/index.d.ts +5 -7
  8. package/es/components/ConfigProvider/index.js +2 -3
  9. package/es/components/ConfigProvider/index.js.map +1 -1
  10. package/es/components/ConfirmAction/index.d.ts +66 -89
  11. package/es/components/ConfirmAction/index.js +27 -18
  12. package/es/components/ConfirmAction/index.js.map +1 -1
  13. package/es/components/ContextMenu/index.d.ts +42 -0
  14. package/es/components/ContextMenu/index.js +188 -0
  15. package/es/components/ContextMenu/index.js.map +1 -0
  16. package/es/components/ContextMenu/style/index.d.ts +3 -0
  17. package/es/components/ContextMenu/style/index.js +25 -0
  18. package/es/components/ContextMenu/style/index.js.map +1 -0
  19. package/es/components/DeleteConfirmAction/index.d.ts +2 -3
  20. package/es/components/DeleteConfirmAction/index.js +8 -12
  21. package/es/components/DeleteConfirmAction/index.js.map +1 -1
  22. package/es/components/EditableText/form.d.ts +150 -0
  23. package/es/components/EditableText/form.js +359 -0
  24. package/es/components/EditableText/form.js.map +1 -0
  25. package/es/components/EditableText/index.d.ts +160 -0
  26. package/es/components/EditableText/index.js +222 -0
  27. package/es/components/EditableText/index.js.map +1 -0
  28. package/es/components/EditableText/style/index.d.ts +3 -0
  29. package/es/components/EditableText/style/index.js +76 -0
  30. package/es/components/EditableText/style/index.js.map +1 -0
  31. package/es/components/FloatDrawer/index.d.ts +89 -86
  32. package/es/components/FloatDrawer/index.js +43 -20
  33. package/es/components/FloatDrawer/index.js.map +1 -1
  34. package/es/components/FloatDrawer/style/index.js +42 -21
  35. package/es/components/FloatDrawer/style/index.js.map +1 -1
  36. package/es/components/Loading/index.d.ts +9 -14
  37. package/es/components/Loading/index.js +7 -6
  38. package/es/components/Loading/index.js.map +1 -1
  39. package/es/components/Loading/style/index.js +1 -1
  40. package/es/components/Loading/style/index.js.map +1 -1
  41. package/es/components/ModalAction/index.d.ts +98 -139
  42. package/es/components/ModalAction/index.js +25 -37
  43. package/es/components/ModalAction/index.js.map +1 -1
  44. package/es/components/OverflowTags/index.d.ts +30 -8
  45. package/es/components/OverflowTags/index.js +26 -7
  46. package/es/components/OverflowTags/index.js.map +1 -1
  47. package/es/components/OverflowTags/style/index.js +1 -1
  48. package/es/components/OverflowTags/style/index.js.map +1 -1
  49. package/es/components/index.d.ts +4 -0
  50. package/es/components/index.js +2 -0
  51. package/es/components/index.js.map +1 -1
  52. package/es/hooks/useRefFunction.d.ts +4 -5
  53. package/es/hooks/useRefFunction.js +6 -7
  54. package/es/hooks/useRefFunction.js.map +1 -1
  55. package/es/hooks/useRefValue.d.ts +2 -3
  56. package/es/hooks/useRefValue.js +2 -3
  57. package/es/hooks/useRefValue.js.map +1 -1
  58. package/es/hooks/useT.js +1 -2
  59. package/es/hooks/useT.js.map +1 -1
  60. package/es/hooks/useValidator.d.ts +2 -3
  61. package/es/hooks/useValidator.js +2 -3
  62. package/es/hooks/useValidator.js.map +1 -1
  63. package/es/hooks/useValidatorBuilder.d.ts +41 -61
  64. package/es/hooks/useValidatorBuilder.js +4 -6
  65. package/es/hooks/useValidatorBuilder.js.map +1 -1
  66. package/es/hooks/useValidators.d.ts +62 -83
  67. package/es/hooks/useValidators.js +3 -4
  68. package/es/hooks/useValidators.js.map +1 -1
  69. package/es/locales/index.d.ts +15 -0
  70. package/es/locales/langs/en-US.d.ts +5 -0
  71. package/es/locales/langs/en-US.js +5 -0
  72. package/es/locales/langs/en-US.js.map +1 -1
  73. package/es/locales/langs/zh-CN.d.ts +5 -0
  74. package/es/locales/langs/zh-CN.js +5 -0
  75. package/es/locales/langs/zh-CN.js.map +1 -1
  76. package/lib/components/BreakLines/index.d.ts +13 -19
  77. package/lib/components/BreakLines/index.js.map +2 -2
  78. package/lib/components/ConfigProvider/context.d.ts +20 -26
  79. package/lib/components/ConfigProvider/context.js.map +2 -2
  80. package/lib/components/ConfigProvider/index.d.ts +5 -7
  81. package/lib/components/ConfigProvider/index.js.map +2 -2
  82. package/lib/components/ConfirmAction/index.d.ts +66 -89
  83. package/lib/components/ConfirmAction/index.js +9 -0
  84. package/lib/components/ConfirmAction/index.js.map +2 -2
  85. package/lib/components/ContextMenu/index.d.ts +42 -0
  86. package/lib/components/ContextMenu/index.js +190 -0
  87. package/lib/components/ContextMenu/index.js.map +7 -0
  88. package/lib/components/ContextMenu/style/index.d.ts +3 -0
  89. package/lib/components/ContextMenu/style/index.js +48 -0
  90. package/lib/components/ContextMenu/style/index.js.map +7 -0
  91. package/lib/components/DeleteConfirmAction/index.d.ts +2 -3
  92. package/lib/components/DeleteConfirmAction/index.js.map +2 -2
  93. package/lib/components/EditableText/form.d.ts +150 -0
  94. package/lib/components/EditableText/form.js +253 -0
  95. package/lib/components/EditableText/form.js.map +7 -0
  96. package/lib/components/EditableText/index.d.ts +160 -0
  97. package/lib/components/EditableText/index.js +181 -0
  98. package/lib/components/EditableText/index.js.map +7 -0
  99. package/lib/components/EditableText/style/index.d.ts +3 -0
  100. package/lib/components/EditableText/style/index.js +118 -0
  101. package/lib/components/EditableText/style/index.js.map +7 -0
  102. package/lib/components/FloatDrawer/index.d.ts +89 -86
  103. package/lib/components/FloatDrawer/index.js +64 -39
  104. package/lib/components/FloatDrawer/index.js.map +2 -2
  105. package/lib/components/FloatDrawer/style/index.js +60 -23
  106. package/lib/components/FloatDrawer/style/index.js.map +2 -2
  107. package/lib/components/Loading/index.d.ts +9 -14
  108. package/lib/components/Loading/index.js +13 -4
  109. package/lib/components/Loading/index.js.map +2 -2
  110. package/lib/components/Loading/style/index.js +1 -1
  111. package/lib/components/Loading/style/index.js.map +2 -2
  112. package/lib/components/ModalAction/index.d.ts +98 -139
  113. package/lib/components/ModalAction/index.js.map +2 -2
  114. package/lib/components/OverflowTags/index.d.ts +30 -8
  115. package/lib/components/OverflowTags/index.js +7 -5
  116. package/lib/components/OverflowTags/index.js.map +2 -2
  117. package/lib/components/OverflowTags/style/index.js +1 -1
  118. package/lib/components/OverflowTags/style/index.js.map +2 -2
  119. package/lib/components/index.d.ts +4 -0
  120. package/lib/components/index.js +6 -0
  121. package/lib/components/index.js.map +2 -2
  122. package/lib/hooks/useRefFunction.d.ts +4 -5
  123. package/lib/hooks/useRefFunction.js.map +2 -2
  124. package/lib/hooks/useRefValue.d.ts +2 -3
  125. package/lib/hooks/useRefValue.js.map +2 -2
  126. package/lib/hooks/useT.js.map +2 -2
  127. package/lib/hooks/useValidator.d.ts +2 -3
  128. package/lib/hooks/useValidator.js.map +2 -2
  129. package/lib/hooks/useValidatorBuilder.d.ts +41 -61
  130. package/lib/hooks/useValidatorBuilder.js.map +2 -2
  131. package/lib/hooks/useValidators.d.ts +62 -83
  132. package/lib/hooks/useValidators.js.map +2 -2
  133. package/lib/locales/index.d.ts +15 -0
  134. package/lib/locales/langs/en-US.d.ts +5 -0
  135. package/lib/locales/langs/en-US.js +5 -0
  136. package/lib/locales/langs/en-US.js.map +2 -2
  137. package/lib/locales/langs/zh-CN.d.ts +5 -0
  138. package/lib/locales/langs/zh-CN.js +5 -0
  139. package/lib/locales/langs/zh-CN.js.map +2 -2
  140. package/package.json +3 -2
@@ -1,179 +1,182 @@
1
1
  import type { CSSProperties, FC, ReactNode } from 'react';
2
2
  import type { CardProps } from 'antd';
3
3
  export interface FloatDrawerProps {
4
+ prefixCls?: string;
4
5
  /**
5
- * **EN:** Whether the drawer is open
6
- *
7
- * **CN:** 抽屉是否打开
6
+ * - **EN:** Whether the drawer is open
7
+ * - **CN:** 抽屉是否打开
8
8
  */
9
9
  open?: boolean;
10
10
  /**
11
- * **EN:** Position of the drawer
12
- *
13
- * **CN:** 抽屉的位置
11
+ * - **EN:** Position of the drawer
12
+ * - **CN:** 抽屉的位置
14
13
  *
15
14
  * @default 'right'
16
15
  */
17
16
  position?: 'left' | 'right' | 'top' | 'bottom';
18
17
  /**
19
- * **EN:** Default size of the drawer. If the drawer is placed on the left or right, this is the
20
- * width, otherwise it is the height.
21
- *
22
- * **CN:** 抽屉的默认宽度。如果抽屉放在左侧或右侧,则为宽度,否则为高度。
23
- *
24
- * @default 300
18
+ * - **EN:** Default size of the drawer. If the drawer is placed on the left or right, this is the
19
+ * width, otherwise it is the height. If not set, the drawer will adapt to the content size.
20
+ * - **CN:** 抽屉的默认宽度。如果抽屉放在左侧或右侧,则为宽度,否则为高度。不设置时,抽屉会根据内容自适应大小。
25
21
  */
26
22
  defaultSize?: number;
27
23
  /**
28
- * **EN:** Minimum size of the drawer
29
- *
30
- * **CN:** 抽屉的最小宽度
24
+ * - **EN:** Minimum size of the drawer
25
+ * - **CN:** 抽屉的最小宽度
31
26
  *
32
27
  * @default 0
33
28
  */
34
29
  minSize?: number;
35
30
  /**
36
- * **EN:** Maximum size of the drawer
37
- *
38
- * **CN:** 抽屉的最大宽度
31
+ * - **EN:** Maximum size of the drawer
32
+ * - **CN:** 抽屉的最大宽度
39
33
  *
40
34
  * @default Infinity
41
35
  */
42
36
  maxSize?: number;
43
37
  /**
44
- * **EN:** Cache key for storing the drawer size in localStorage. If not set, the size will not be
45
- * cached.
38
+ * - **EN:** Offset of the drawer from the edge of the screen, supports all CSS length units,
39
+ * default is `0`.
40
+ *
41
+ * > The drawer will be hidden outside the parent container's edge, but since the parent container
42
+ * > may have padding or border, the drawer may not be completely hidden. You can adjust the
43
+ * > `edgeOffset` to ensure the drawer is completely hidden outside the parent container.
46
44
  *
47
- * **CN:** 指定一个localStorage缓存键,用于记忆抽屉宽度。如果不设置,则不使用缓存。
45
+ * - **CN:** 抽屉距离屏幕边缘的偏移量,支持所有的CSS长度单位, 默认`0`。
46
+ *
47
+ * > 抽屉会隐藏在父容器的外边缘, 但由于父容器可能有padding或border, 导致抽屉不能完全隐藏, 因此可以通过设置 `edgeOffset` 来调整抽屉的偏移量,
48
+ * > 以确保抽屉完全隐藏在父容器之外。
49
+ *
50
+ * @default 0
51
+ */
52
+ edgeOffset?: CSSProperties['width'];
53
+ /**
54
+ * - **EN:** Whether to show the toggle button, default is `true`.
55
+ * - **CN:** 是否显示展开/收起按钮,默认`true`。
56
+ */
57
+ showToggle?: boolean;
58
+ /**
59
+ * - **EN:** Whether the drawer is resizable, default is `true`.
60
+ * - **CN:** 抽屉是否可调整大小, 默认`true`。
61
+ */
62
+ resizable?: boolean;
63
+ /**
64
+ * - **EN:** Cache key for storing the drawer size in localStorage. If not set, the size will not be
65
+ * cached.
66
+ * - **CN:** 指定一个localStorage缓存键,用于记忆抽屉宽度。如果不设置,则不使用缓存。
48
67
  */
49
68
  cacheKey?: string;
50
69
  /**
51
- * **EN:** Custom class name for the root element
52
- *
53
- * **CN:** 根元素的自定义类名
70
+ * - **EN:** Custom class name for the root element
71
+ * - **CN:** 根元素的自定义类名
54
72
  */
55
73
  className?: string;
56
74
  /**
57
- * **EN:** Custom class names for specific elements
58
- *
59
- * **CN:** 特定元素的自定义类名
75
+ * - **EN:** Custom class names for specific elements
76
+ * - **CN:** 特定元素的自定义类名
60
77
  */
61
78
  classNames?: {
62
79
  /**
63
- * **EN:** Class name for the drawer element
64
- *
65
- * **CN:** 抽屉元素的类名
80
+ * - **EN:** Class name for the drawer element
81
+ * - **CN:** 抽屉元素的类名
66
82
  */
67
83
  drawer?: string;
68
84
  /**
69
- * **EN:** Class name for the expand handle
70
- *
71
- * **CN:** 展开手柄的类名
85
+ * - **EN:** Class name for the expand handle
86
+ * - **CN:** 展开手柄的类名
72
87
  */
73
- expandHandle?: string;
88
+ toggle?: string;
74
89
  /**
75
- * **EN:** Class name for the resize handle
76
- *
77
- * **CN:** 调整大小手柄的类名
90
+ * - **EN:** Class name for the resize handle
91
+ * - **CN:** 调整大小手柄的类名
78
92
  */
79
93
  resizeHandle?: string;
80
94
  /**
81
- * **EN:** Class name for the handle icon
82
- *
83
- * **CN:** 手柄图标的类名
95
+ * - **EN:** Class name for the handle icon
96
+ * - **CN:** 手柄图标的类名
84
97
  */
85
98
  handleIcon?: string;
86
99
  /**
87
- * **EN:** Class name for the content area
88
- *
89
- * **CN:** 内容区域的类名
100
+ * - **EN:** Class name for the content area
101
+ * - **CN:** 内容区域的类名
90
102
  */
91
103
  content?: string;
92
104
  /**
93
- * **EN:** Class name for the card element
94
- *
95
- * **CN:** 卡片元素的类名
105
+ * - **EN:** Class name for the card element
106
+ * - **CN:** 卡片元素的类名
96
107
  */
97
108
  card?: string;
98
109
  };
99
110
  /**
100
- * **EN:** Custom styles for the root element
101
- *
102
- * **CN:** 根元素的自定义样式
111
+ * - **EN:** Custom styles for the root element
112
+ * - **CN:** 根元素的自定义样式
103
113
  */
104
114
  style?: CSSProperties;
105
115
  /**
106
- * **EN:** Custom styles for specific elements
107
- *
108
- * **CN:** 特定元素的自定义样式
116
+ * - **EN:** Custom styles for specific elements
117
+ * - **CN:** 特定元素的自定义样式
109
118
  */
110
119
  styles?: {
111
120
  /**
112
- * **EN:** Styles for the drawer element
113
- *
114
- * **CN:** 抽屉元素的样式
121
+ * - **EN:** Styles for the drawer element
122
+ * - **CN:** 抽屉元素的样式
115
123
  */
116
124
  drawer?: CSSProperties;
117
125
  /**
118
- * **EN:** Styles for the expand handle
119
- *
120
- * **CN:** 展开手柄的样式
126
+ * - **EN:** Styles for the expand handle
127
+ * - **CN:** 展开手柄的样式
121
128
  */
122
- expandHandle?: CSSProperties;
129
+ toggle?: CSSProperties;
123
130
  /**
124
- * **EN:** Styles for the resize handle
125
- *
126
- * **CN:** 调整大小手柄的样式
131
+ * - **EN:** Styles for the resize handle
132
+ * - **CN:** 调整大小手柄的样式
127
133
  */
128
134
  resizeHandle?: CSSProperties;
129
135
  /**
130
- * **EN:** Styles for the handle icon
131
- *
132
- * **CN:** 手柄图标的样式
136
+ * - **EN:** Styles for the handle icon
137
+ * - **CN:** 手柄图标的样式
133
138
  */
134
139
  handleIcon?: CSSProperties;
135
140
  /**
136
- * **EN:** Styles for the content area
137
- *
138
- * **CN:** 内容区域的样式
141
+ * - **EN:** Styles for the content area
142
+ * - **CN:** 内容区域的样式
139
143
  */
140
144
  content?: CSSProperties;
141
145
  /**
142
- * **EN:** Styles for the card element
143
- *
144
- * **CN:** 卡片元素的样式
146
+ * - **EN:** Styles for the card element
147
+ * - **CN:** 卡片元素的样式
145
148
  */
146
149
  card?: CSSProperties;
147
150
  };
148
151
  /**
149
- * **EN:** Custom properties for the card element
150
- *
151
- * **CN:** 卡片元素的自定义属性
152
+ * - **EN:** Custom properties for the card element
153
+ * - **CN:** 卡片元素的自定义属性
152
154
  */
153
155
  cardProps?: Omit<CardProps, 'children'>;
154
156
  /**
155
- * **EN:** Content to be rendered inside the drawer
156
- *
157
- * **CN:** 抽屉内容
157
+ * - **EN:** Content to be rendered inside the drawer
158
+ * - **CN:** 抽屉内容
158
159
  */
159
160
  children?: ReactNode;
160
161
  /**
161
- * **EN:** Callback function when the open state changes
162
- *
163
- * **CN:** 打开状态变化时的回调函数
162
+ * - **EN:** Callback function when the open state changes
163
+ * - **CN:** 打开状态变化时的回调函数
164
164
  */
165
165
  onOpenChange?: (open: boolean) => void;
166
166
  /**
167
- * **EN:** Callback function when the drawer is resized
168
- *
169
- * **CN:** 抽屉调整大小时的回调函数
167
+ * - **EN:** Callback function when the drawer is resized
168
+ * - **CN:** 抽屉调整大小时的回调函数
170
169
  */
171
170
  onResize?: (size: number) => void;
171
+ /**
172
+ * - **EN:** Event handler for click events on the drawer container and its internal elements
173
+ * - **CN:** 点击抽屉容器及内部元素时的事件
174
+ */
175
+ onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
172
176
  }
173
177
  /**
174
- * **EN:** FloatDrawer component for creating a draggable, resizable drawer
175
- *
176
- * **CN:** FloatDrawer组件,用于创建可拖动、可调整大小的抽屉
178
+ * - **EN:** FloatDrawer component for creating a draggable, resizable drawer
179
+ * - **CN:** FloatDrawer组件,用于创建可拖动、可调整大小的抽屉
177
180
  */
178
181
  declare const FloatDrawer: FC<FloatDrawerProps>;
179
182
  export default FloatDrawer;
@@ -19,12 +19,12 @@ import useStyle from "./style";
19
19
  import { jsx as _jsx } from "react/jsx-runtime";
20
20
  import { jsxs as _jsxs } from "react/jsx-runtime";
21
21
  /**
22
- * **EN:** FloatDrawer component for creating a draggable, resizable drawer
23
- *
24
- * **CN:** FloatDrawer组件,用于创建可拖动、可调整大小的抽屉
22
+ * - **EN:** FloatDrawer component for creating a draggable, resizable drawer
23
+ * - **CN:** FloatDrawer组件,用于创建可拖动、可调整大小的抽屉
25
24
  */
26
25
  var FloatDrawer = function FloatDrawer(props) {
27
- var open = props.open,
26
+ var prefixClsInProps = props.prefixCls,
27
+ open = props.open,
28
28
  _props$position = props.position,
29
29
  position = _props$position === void 0 ? 'right' : _props$position,
30
30
  cardProps = props.cardProps,
@@ -34,26 +34,31 @@ var FloatDrawer = function FloatDrawer(props) {
34
34
  style = props.style,
35
35
  styles = props.styles,
36
36
  cacheKey = props.cacheKey,
37
- _props$defaultSize = props.defaultSize,
38
- defaultSize = _props$defaultSize === void 0 ? 300 : _props$defaultSize,
37
+ defaultSize = props.defaultSize,
39
38
  _props$minSize = props.minSize,
40
39
  minSize = _props$minSize === void 0 ? 0 : _props$minSize,
41
40
  _props$maxSize = props.maxSize,
42
41
  maxSize = _props$maxSize === void 0 ? +Infinity : _props$maxSize,
42
+ edgeOffset = props.edgeOffset,
43
+ _props$showToggle = props.showToggle,
44
+ showToggle = _props$showToggle === void 0 ? true : _props$showToggle,
45
+ _props$resizable = props.resizable,
46
+ resizable = _props$resizable === void 0 ? true : _props$resizable,
43
47
  onOpenChange = props.onOpenChange,
44
- onResize = props.onResize;
48
+ onResize = props.onResize,
49
+ onClick = props.onClick;
45
50
  var _useContext = useContext(ConfigProvider.ConfigContext),
46
51
  getPrefixCls = _useContext.getPrefixCls;
47
- var prefixCls = getPrefixCls('easy-float-drawer');
52
+ var prefixCls = getPrefixCls('easy-float-drawer', prefixClsInProps);
48
53
  var _useStyle = useStyle(prefixCls),
49
54
  _useStyle2 = _slicedToArray(_useStyle, 3),
50
55
  wrapCSSVar = _useStyle2[0],
51
56
  hashId = _useStyle2[1],
52
57
  cssVarCls = _useStyle2[2];
53
- var _useState = useState(),
58
+ var _useState = useState(null),
54
59
  _useState2 = _slicedToArray(_useState, 2),
55
- isOpen = _useState2[0],
56
- setIsOpen = _useState2[1];
60
+ drawerRef = _useState2[0],
61
+ setDrawerRef = _useState2[1];
57
62
  var _useState3 = useState(cacheKey && localStorage.getItem(cacheKey) ? Number(localStorage.getItem(cacheKey)) || defaultSize : defaultSize),
58
63
  _useState4 = _slicedToArray(_useState3, 2),
59
64
  size = _useState4[0],
@@ -62,10 +67,14 @@ var FloatDrawer = function FloatDrawer(props) {
62
67
  var type = position === 'left' || position === 'right' ? 'width' : 'height';
63
68
  return _defineProperty({}, type, size);
64
69
  }, [position, size]);
65
- var _useState5 = useState(false),
70
+ var _useState5 = useState(),
66
71
  _useState6 = _slicedToArray(_useState5, 2),
67
- isDragging = _useState6[0],
68
- setIsDragging = _useState6[1];
72
+ isOpen = _useState6[0],
73
+ setIsOpen = _useState6[1];
74
+ var _useState7 = useState(false),
75
+ _useState8 = _slicedToArray(_useState7, 2),
76
+ isDragging = _useState8[0],
77
+ setIsDragging = _useState8[1];
69
78
  var dragStartPos = useRef(0);
70
79
  var dragStartSize = useRef(size);
71
80
  var classString = classNames(prefixCls, className, _defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-open"), isOpen), "".concat(prefixCls, "-closed"), !isOpen), "".concat(prefixCls, "-").concat(position), position), hashId, cssVarCls);
@@ -94,7 +103,7 @@ var FloatDrawer = function FloatDrawer(props) {
94
103
  e.preventDefault();
95
104
  });
96
105
  var handleResize = useRefFunction(function (e) {
97
- if (isDragging) {
106
+ if (isDragging && dragStartSize.current) {
98
107
  var newSize;
99
108
  if (position === 'left') {
100
109
  newSize = dragStartSize.current - (dragStartPos.current - e.clientX);
@@ -118,6 +127,15 @@ var FloatDrawer = function FloatDrawer(props) {
118
127
  setIsDragging(false);
119
128
  });
120
129
 
130
+ // Monitor drawer ref, calculate size if not set
131
+ // This is useful for initial rendering when size is not provided
132
+ useEffect(function () {
133
+ if (drawerRef && size === undefined) {
134
+ var rect = drawerRef.getBoundingClientRect();
135
+ setSize(position === 'left' || position === 'right' ? rect.width : rect.height);
136
+ }
137
+ }, [drawerRef, position, size]);
138
+
121
139
  // Controlled open state
122
140
  useEffect(function () {
123
141
  setIsOpen(open);
@@ -139,11 +157,16 @@ var FloatDrawer = function FloatDrawer(props) {
139
157
  }, [isDragging]);
140
158
  return wrapCSSVar( /*#__PURE__*/_jsx("div", {
141
159
  className: classString,
142
- style: style,
160
+ style: _objectSpread({
161
+ // @ts-expect-error: because of dynamic CSS variables
162
+ '--edge-offset': typeof edgeOffset === 'number' ? "".concat(edgeOffset, "px") : edgeOffset
163
+ }, style),
164
+ onClick: onClick,
143
165
  children: /*#__PURE__*/_jsxs("div", {
166
+ ref: setDrawerRef,
144
167
  className: classNames("".concat(prefixCls, "-drawer"), classNamesInProps === null || classNamesInProps === void 0 ? void 0 : classNamesInProps.drawer),
145
168
  style: _objectSpread(_objectSpread({}, sizeMap), styles === null || styles === void 0 ? void 0 : styles.drawer),
146
- children: [/*#__PURE__*/_jsx("div", {
169
+ children: [resizable && /*#__PURE__*/_jsx("div", {
147
170
  className: classNames("".concat(prefixCls, "-resize-handle"), isDragging && "".concat(prefixCls, "-resize-handle-dragging"), classNamesInProps === null || classNamesInProps === void 0 ? void 0 : classNamesInProps.resizeHandle),
148
171
  style: styles === null || styles === void 0 ? void 0 : styles.resizeHandle,
149
172
  onMouseDown: handleResizeStart
@@ -158,9 +181,9 @@ var FloatDrawer = function FloatDrawer(props) {
158
181
  }, cardProps), {}, {
159
182
  children: children
160
183
  }))
161
- }), /*#__PURE__*/_jsx("div", {
162
- className: classNames("".concat(prefixCls, "-expand-handle"), classNamesInProps === null || classNamesInProps === void 0 ? void 0 : classNamesInProps.expandHandle),
163
- style: styles === null || styles === void 0 ? void 0 : styles.expandHandle,
184
+ }), showToggle && /*#__PURE__*/_jsx("div", {
185
+ className: classNames("".concat(prefixCls, "-toggle"), classNamesInProps === null || classNamesInProps === void 0 ? void 0 : classNamesInProps.toggle),
186
+ style: styles === null || styles === void 0 ? void 0 : styles.toggle,
164
187
  onClick: toggleDrawer,
165
188
  children: /*#__PURE__*/_jsx("div", {
166
189
  className: classNames("".concat(prefixCls, "-handle-icon"), classNamesInProps === null || classNamesInProps === void 0 ? void 0 : classNamesInProps.handleIcon),
@@ -1 +1 @@
1
- {"version":3,"names":["useContext","useEffect","useMemo","useRef","useState","Card","ConfigProvider","classNames","DownOutlined","LeftOutlined","RightOutlined","UpOutlined","useRefFunction","useStyle","jsx","_jsx","jsxs","_jsxs","FloatDrawer","props","open","_props$position","position","cardProps","children","className","classNamesInProps","style","styles","cacheKey","_props$defaultSize","defaultSize","_props$minSize","minSize","_props$maxSize","maxSize","Infinity","onOpenChange","onResize","_useContext","ConfigContext","getPrefixCls","prefixCls","_useStyle","_useStyle2","_slicedToArray","wrapCSSVar","hashId","cssVarCls","_useState","_useState2","isOpen","setIsOpen","_useState3","localStorage","getItem","Number","_useState4","size","setSize","sizeMap","type","_defineProperty","_useState5","_useState6","isDragging","setIsDragging","dragStartPos","dragStartSize","classString","concat","closeIcon","openIcon","toggleDrawer","handleResizeStart","e","current","clientY","clientX","preventDefault","handleResize","newSize","setItem","String","handleResizeEnd","window","addEventListener","removeEventListener","drawer","_objectSpread","resizeHandle","onMouseDown","content","bordered","variant","card","expandHandle","onClick","handleIcon"],"sources":["../../../src/components/FloatDrawer/index.tsx"],"sourcesContent":["import type { CSSProperties, FC, ReactNode } from 'react';\nimport { useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport type { CardProps } from 'antd';\nimport { Card, ConfigProvider } from 'antd';\nimport classNames from 'classnames';\nimport { DownOutlined, LeftOutlined, RightOutlined, UpOutlined } from '@ant-design/icons';\nimport useRefFunction from '../../hooks/useRefFunction';\nimport useStyle from './style';\n\nexport interface FloatDrawerProps {\n /**\n * **EN:** Whether the drawer is open\n *\n * **CN:** 抽屉是否打开\n */\n open?: boolean;\n /**\n * **EN:** Position of the drawer\n *\n * **CN:** 抽屉的位置\n *\n * @default 'right'\n */\n position?: 'left' | 'right' | 'top' | 'bottom';\n /**\n * **EN:** Default size of the drawer. If the drawer is placed on the left or right, this is the\n * width, otherwise it is the height.\n *\n * **CN:** 抽屉的默认宽度。如果抽屉放在左侧或右侧,则为宽度,否则为高度。\n *\n * @default 300\n */\n defaultSize?: number;\n /**\n * **EN:** Minimum size of the drawer\n *\n * **CN:** 抽屉的最小宽度\n *\n * @default 0\n */\n minSize?: number;\n /**\n * **EN:** Maximum size of the drawer\n *\n * **CN:** 抽屉的最大宽度\n *\n * @default Infinity\n */\n maxSize?: number;\n /**\n * **EN:** Cache key for storing the drawer size in localStorage. If not set, the size will not be\n * cached.\n *\n * **CN:** 指定一个localStorage缓存键,用于记忆抽屉宽度。如果不设置,则不使用缓存。\n */\n cacheKey?: string;\n /**\n * **EN:** Custom class name for the root element\n *\n * **CN:** 根元素的自定义类名\n */\n className?: string;\n /**\n * **EN:** Custom class names for specific elements\n *\n * **CN:** 特定元素的自定义类名\n */\n classNames?: {\n /**\n * **EN:** Class name for the drawer element\n *\n * **CN:** 抽屉元素的类名\n */\n drawer?: string;\n /**\n * **EN:** Class name for the expand handle\n *\n * **CN:** 展开手柄的类名\n */\n expandHandle?: string;\n /**\n * **EN:** Class name for the resize handle\n *\n * **CN:** 调整大小手柄的类名\n */\n resizeHandle?: string;\n /**\n * **EN:** Class name for the handle icon\n *\n * **CN:** 手柄图标的类名\n */\n handleIcon?: string;\n /**\n * **EN:** Class name for the content area\n *\n * **CN:** 内容区域的类名\n */\n content?: string;\n /**\n * **EN:** Class name for the card element\n *\n * **CN:** 卡片元素的类名\n */\n card?: string;\n };\n /**\n * **EN:** Custom styles for the root element\n *\n * **CN:** 根元素的自定义样式\n */\n style?: CSSProperties;\n /**\n * **EN:** Custom styles for specific elements\n *\n * **CN:** 特定元素的自定义样式\n */\n styles?: {\n /**\n * **EN:** Styles for the drawer element\n *\n * **CN:** 抽屉元素的样式\n */\n drawer?: CSSProperties;\n /**\n * **EN:** Styles for the expand handle\n *\n * **CN:** 展开手柄的样式\n */\n expandHandle?: CSSProperties;\n /**\n * **EN:** Styles for the resize handle\n *\n * **CN:** 调整大小手柄的样式\n */\n resizeHandle?: CSSProperties;\n /**\n * **EN:** Styles for the handle icon\n *\n * **CN:** 手柄图标的样式\n */\n handleIcon?: CSSProperties;\n /**\n * **EN:** Styles for the content area\n *\n * **CN:** 内容区域的样式\n */\n content?: CSSProperties;\n /**\n * **EN:** Styles for the card element\n *\n * **CN:** 卡片元素的样式\n */\n card?: CSSProperties;\n };\n /**\n * **EN:** Custom properties for the card element\n *\n * **CN:** 卡片元素的自定义属性\n */\n cardProps?: Omit<CardProps, 'children'>;\n /**\n * **EN:** Content to be rendered inside the drawer\n *\n * **CN:** 抽屉内容\n */\n children?: ReactNode;\n /**\n * **EN:** Callback function when the open state changes\n *\n * **CN:** 打开状态变化时的回调函数\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * **EN:** Callback function when the drawer is resized\n *\n * **CN:** 抽屉调整大小时的回调函数\n */\n onResize?: (size: number) => void;\n}\n\n/**\n * **EN:** FloatDrawer component for creating a draggable, resizable drawer\n *\n * **CN:** FloatDrawer组件,用于创建可拖动、可调整大小的抽屉\n */\nconst FloatDrawer: FC<FloatDrawerProps> = (props) => {\n const {\n open,\n position = 'right',\n cardProps,\n children,\n className,\n classNames: classNamesInProps,\n style,\n styles,\n cacheKey,\n defaultSize = 300,\n minSize = 0,\n maxSize = +Infinity,\n onOpenChange,\n onResize,\n } = props;\n const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);\n const prefixCls = getPrefixCls('easy-float-drawer');\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);\n const [isOpen, setIsOpen] = useState<boolean>();\n const [size, setSize] = useState(\n cacheKey && localStorage.getItem(cacheKey) ? Number(localStorage.getItem(cacheKey)) || defaultSize : defaultSize\n );\n const sizeMap = useMemo(() => {\n const type = position === 'left' || position === 'right' ? 'width' : 'height';\n return {\n [type]: size,\n };\n }, [position, size]);\n const [isDragging, setIsDragging] = useState(false);\n const dragStartPos = useRef<number>(0);\n const dragStartSize = useRef<number>(size);\n const classString = classNames(\n prefixCls,\n className,\n {\n [`${prefixCls}-open`]: isOpen,\n [`${prefixCls}-closed`]: !isOpen,\n [`${prefixCls}-${position}`]: position,\n },\n hashId,\n cssVarCls\n );\n const closeIcon = useMemo(() => {\n return position === 'left' ? (\n <RightOutlined />\n ) : position === 'top' ? (\n <DownOutlined />\n ) : position === 'bottom' ? (\n <UpOutlined />\n ) : (\n <LeftOutlined />\n );\n }, [position]);\n const openIcon = useMemo(() => {\n return position === 'left' ? (\n <LeftOutlined />\n ) : position === 'top' ? (\n <UpOutlined />\n ) : position === 'bottom' ? (\n <DownOutlined />\n ) : (\n <RightOutlined />\n );\n }, [position]);\n\n // Handle drawer visibility\n const toggleDrawer = () => {\n setIsOpen(!isOpen);\n onOpenChange?.(!isOpen);\n };\n\n // Handle resize events\n const handleResizeStart = useRefFunction((e: React.MouseEvent) => {\n setIsDragging(true);\n if (position === 'top' || position === 'bottom') {\n dragStartPos.current = e.clientY;\n } else {\n dragStartPos.current = e.clientX;\n }\n dragStartSize.current = size;\n e.preventDefault();\n });\n const handleResize = useRefFunction((e: MouseEvent) => {\n if (isDragging) {\n let newSize: number;\n if (position === 'left') {\n newSize = dragStartSize.current - (dragStartPos.current - e.clientX);\n } else if (position === 'top') {\n newSize = dragStartSize.current - (dragStartPos.current - e.clientY);\n } else if (position === 'bottom') {\n newSize = dragStartSize.current - (e.clientY - dragStartPos.current);\n } else {\n newSize = dragStartSize.current - (e.clientX - dragStartPos.current);\n }\n if (newSize >= minSize && newSize <= maxSize) {\n setSize(newSize);\n if (cacheKey) {\n localStorage.setItem(cacheKey, String(newSize));\n }\n onResize?.(newSize);\n }\n }\n });\n const handleResizeEnd = useRefFunction(() => {\n setIsDragging(false);\n });\n\n // Controlled open state\n useEffect(() => {\n setIsOpen(open);\n }, [open]);\n\n // Handle global events\n useEffect(() => {\n if (isDragging) {\n window.addEventListener('mousemove', handleResize);\n window.addEventListener('mouseup', handleResizeEnd);\n } else {\n window.removeEventListener('mousemove', handleResize);\n window.removeEventListener('mouseup', handleResizeEnd);\n }\n return () => {\n window.removeEventListener('mousemove', handleResize);\n window.removeEventListener('mouseup', handleResizeEnd);\n };\n }, [isDragging]);\n\n return wrapCSSVar(\n <div className={classString} style={style}>\n <div\n className={classNames(`${prefixCls}-drawer`, classNamesInProps?.drawer)}\n style={{ ...sizeMap, ...styles?.drawer }}\n >\n <div\n className={classNames(\n `${prefixCls}-resize-handle`,\n isDragging && `${prefixCls}-resize-handle-dragging`,\n classNamesInProps?.resizeHandle\n )}\n style={styles?.resizeHandle}\n onMouseDown={handleResizeStart}\n />\n <div className={classNames(`${prefixCls}-content`, classNamesInProps?.content)} style={styles?.content}>\n <Card\n bordered={false}\n variant=\"borderless\"\n className={classNames(`${prefixCls}-card`, classNamesInProps?.card)}\n style={styles?.card}\n {...cardProps}\n >\n {children}\n </Card>\n </div>\n <div\n className={classNames(`${prefixCls}-expand-handle`, classNamesInProps?.expandHandle)}\n style={styles?.expandHandle}\n onClick={toggleDrawer}\n >\n <div\n className={classNames(`${prefixCls}-handle-icon`, classNamesInProps?.handleIcon)}\n style={styles?.handleIcon}\n >\n {isOpen ? openIcon : closeIcon}\n </div>\n </div>\n </div>\n </div>\n );\n};\n\nexport default FloatDrawer;\n"],"mappings":";;;;;;;;;;;;AACA,SAASA,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAExE,SAASC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AC,CACH,CAAC;IAAA,CACH;EAAC,CACH,CACP,CAAC;AACH,CAAC;AAED,eAAerD,WAAW"}
1
+ {"version":3,"names":["useContext","useEffect","useMemo","useRef","useState","Card","ConfigProvider","classNames","DownOutlined","LeftOutlined","RightOutlined","UpOutlined","useRefFunction","useStyle","jsx","_jsx","jsxs","_jsxs","FloatDrawer","props","prefixClsInProps","prefixCls","open","_props$position","position","cardProps","children","className","classNamesInProps","style","styles","cacheKey","defaultSize","_props$minSize","minSize","_props$maxSize","maxSize","Infinity","edgeOffset","_props$showToggle","showToggle","_props$resizable","resizable","onOpenChange","onResize","onClick","_useContext","ConfigContext","getPrefixCls","_useStyle","_useStyle2","_slicedToArray","wrapCSSVar","hashId","cssVarCls","_useState","_useState2","drawerRef","setDrawerRef","_useState3","localStorage","getItem","Number","_useState4","size","setSize","sizeMap","type","_defineProperty","_useState5","_useState6","isOpen","setIsOpen","_useState7","_useState8","isDragging","setIsDragging","dragStartPos","dragStartSize","classString","concat","closeIcon","openIcon","toggleDrawer","handleResizeStart","e","current","clientY","clientX","preventDefault","handleResize","newSize","setItem","String","handleResizeEnd","undefined","rect","getBoundingClientRect","width","height","window","addEventListener","removeEventListener","_objectSpread","ref","drawer","resizeHandle","onMouseDown","content","bordered","variant","card","toggle","handleIcon"],"sources":["../../../src/components/FloatDrawer/index.tsx"],"sourcesContent":["import type { CSSProperties, FC, ReactNode } from 'react';\nimport { useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport type { CardProps } from 'antd';\nimport { Card, ConfigProvider } from 'antd';\nimport classNames from 'classnames';\nimport { DownOutlined, LeftOutlined, RightOutlined, UpOutlined } from '@ant-design/icons';\nimport useRefFunction from '../../hooks/useRefFunction';\nimport useStyle from './style';\n\nexport interface FloatDrawerProps {\n prefixCls?: string;\n /**\n * - **EN:** Whether the drawer is open\n * - **CN:** 抽屉是否打开\n */\n open?: boolean;\n /**\n * - **EN:** Position of the drawer\n * - **CN:** 抽屉的位置\n *\n * @default 'right'\n */\n position?: 'left' | 'right' | 'top' | 'bottom';\n /**\n * - **EN:** Default size of the drawer. If the drawer is placed on the left or right, this is the\n * width, otherwise it is the height. If not set, the drawer will adapt to the content size.\n * - **CN:** 抽屉的默认宽度。如果抽屉放在左侧或右侧,则为宽度,否则为高度。不设置时,抽屉会根据内容自适应大小。\n */\n defaultSize?: number;\n /**\n * - **EN:** Minimum size of the drawer\n * - **CN:** 抽屉的最小宽度\n *\n * @default 0\n */\n minSize?: number;\n /**\n * - **EN:** Maximum size of the drawer\n * - **CN:** 抽屉的最大宽度\n *\n * @default Infinity\n */\n maxSize?: number;\n /**\n * - **EN:** Offset of the drawer from the edge of the screen, supports all CSS length units,\n * default is `0`.\n *\n * > The drawer will be hidden outside the parent container's edge, but since the parent container\n * > may have padding or border, the drawer may not be completely hidden. You can adjust the\n * > `edgeOffset` to ensure the drawer is completely hidden outside the parent container.\n *\n * - **CN:** 抽屉距离屏幕边缘的偏移量,支持所有的CSS长度单位, 默认`0`。\n *\n * > 抽屉会隐藏在父容器的外边缘, 但由于父容器可能有padding或border, 导致抽屉不能完全隐藏, 因此可以通过设置 `edgeOffset` 来调整抽屉的偏移量,\n * > 以确保抽屉完全隐藏在父容器之外。\n *\n * @default 0\n */\n edgeOffset?: CSSProperties['width'];\n /**\n * - **EN:** Whether to show the toggle button, default is `true`.\n * - **CN:** 是否显示展开/收起按钮,默认`true`。\n */\n showToggle?: boolean;\n /**\n * - **EN:** Whether the drawer is resizable, default is `true`.\n * - **CN:** 抽屉是否可调整大小, 默认`true`。\n */\n resizable?: boolean;\n /**\n * - **EN:** Cache key for storing the drawer size in localStorage. If not set, the size will not be\n * cached.\n * - **CN:** 指定一个localStorage缓存键,用于记忆抽屉宽度。如果不设置,则不使用缓存。\n */\n cacheKey?: string;\n /**\n * - **EN:** Custom class name for the root element\n * - **CN:** 根元素的自定义类名\n */\n className?: string;\n /**\n * - **EN:** Custom class names for specific elements\n * - **CN:** 特定元素的自定义类名\n */\n classNames?: {\n /**\n * - **EN:** Class name for the drawer element\n * - **CN:** 抽屉元素的类名\n */\n drawer?: string;\n /**\n * - **EN:** Class name for the expand handle\n * - **CN:** 展开手柄的类名\n */\n toggle?: string;\n /**\n * - **EN:** Class name for the resize handle\n * - **CN:** 调整大小手柄的类名\n */\n resizeHandle?: string;\n /**\n * - **EN:** Class name for the handle icon\n * - **CN:** 手柄图标的类名\n */\n handleIcon?: string;\n /**\n * - **EN:** Class name for the content area\n * - **CN:** 内容区域的类名\n */\n content?: string;\n /**\n * - **EN:** Class name for the card element\n * - **CN:** 卡片元素的类名\n */\n card?: string;\n };\n /**\n * - **EN:** Custom styles for the root element\n * - **CN:** 根元素的自定义样式\n */\n style?: CSSProperties;\n /**\n * - **EN:** Custom styles for specific elements\n * - **CN:** 特定元素的自定义样式\n */\n styles?: {\n /**\n * - **EN:** Styles for the drawer element\n * - **CN:** 抽屉元素的样式\n */\n drawer?: CSSProperties;\n /**\n * - **EN:** Styles for the expand handle\n * - **CN:** 展开手柄的样式\n */\n toggle?: CSSProperties;\n /**\n * - **EN:** Styles for the resize handle\n * - **CN:** 调整大小手柄的样式\n */\n resizeHandle?: CSSProperties;\n /**\n * - **EN:** Styles for the handle icon\n * - **CN:** 手柄图标的样式\n */\n handleIcon?: CSSProperties;\n /**\n * - **EN:** Styles for the content area\n * - **CN:** 内容区域的样式\n */\n content?: CSSProperties;\n /**\n * - **EN:** Styles for the card element\n * - **CN:** 卡片元素的样式\n */\n card?: CSSProperties;\n };\n /**\n * - **EN:** Custom properties for the card element\n * - **CN:** 卡片元素的自定义属性\n */\n cardProps?: Omit<CardProps, 'children'>;\n /**\n * - **EN:** Content to be rendered inside the drawer\n * - **CN:** 抽屉内容\n */\n children?: ReactNode;\n /**\n * - **EN:** Callback function when the open state changes\n * - **CN:** 打开状态变化时的回调函数\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * - **EN:** Callback function when the drawer is resized\n * - **CN:** 抽屉调整大小时的回调函数\n */\n onResize?: (size: number) => void;\n /**\n * - **EN:** Event handler for click events on the drawer container and its internal elements\n * - **CN:** 点击抽屉容器及内部元素时的事件\n */\n onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;\n}\n\n/**\n * - **EN:** FloatDrawer component for creating a draggable, resizable drawer\n * - **CN:** FloatDrawer组件,用于创建可拖动、可调整大小的抽屉\n */\nconst FloatDrawer: FC<FloatDrawerProps> = (props) => {\n const {\n prefixCls: prefixClsInProps,\n open,\n position = 'right',\n cardProps,\n children,\n className,\n classNames: classNamesInProps,\n style,\n styles,\n cacheKey,\n defaultSize,\n minSize = 0,\n maxSize = +Infinity,\n edgeOffset,\n showToggle = true,\n resizable = true,\n onOpenChange,\n onResize,\n onClick,\n } = props;\n const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);\n const prefixCls = getPrefixCls('easy-float-drawer', prefixClsInProps);\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);\n const [drawerRef, setDrawerRef] = useState<HTMLDivElement | null>(null);\n const [size, setSize] = useState(\n cacheKey && localStorage.getItem(cacheKey) ? Number(localStorage.getItem(cacheKey)) || defaultSize : defaultSize\n );\n const sizeMap = useMemo(() => {\n const type = position === 'left' || position === 'right' ? 'width' : 'height';\n return {\n [type]: size,\n };\n }, [position, size]);\n const [isOpen, setIsOpen] = useState<boolean>();\n const [isDragging, setIsDragging] = useState(false);\n const dragStartPos = useRef<number>(0);\n const dragStartSize = useRef<number>(size);\n const classString = classNames(\n prefixCls,\n className,\n {\n [`${prefixCls}-open`]: isOpen,\n [`${prefixCls}-closed`]: !isOpen,\n [`${prefixCls}-${position}`]: position,\n },\n hashId,\n cssVarCls\n );\n const closeIcon = useMemo(() => {\n return position === 'left' ? (\n <RightOutlined />\n ) : position === 'top' ? (\n <DownOutlined />\n ) : position === 'bottom' ? (\n <UpOutlined />\n ) : (\n <LeftOutlined />\n );\n }, [position]);\n const openIcon = useMemo(() => {\n return position === 'left' ? (\n <LeftOutlined />\n ) : position === 'top' ? (\n <UpOutlined />\n ) : position === 'bottom' ? (\n <DownOutlined />\n ) : (\n <RightOutlined />\n );\n }, [position]);\n\n // Handle drawer visibility\n const toggleDrawer = () => {\n setIsOpen(!isOpen);\n onOpenChange?.(!isOpen);\n };\n\n // Handle resize events\n const handleResizeStart = useRefFunction((e: React.MouseEvent) => {\n setIsDragging(true);\n if (position === 'top' || position === 'bottom') {\n dragStartPos.current = e.clientY;\n } else {\n dragStartPos.current = e.clientX;\n }\n dragStartSize.current = size;\n e.preventDefault();\n });\n const handleResize = useRefFunction((e: MouseEvent) => {\n if (isDragging && dragStartSize.current) {\n let newSize: number;\n if (position === 'left') {\n newSize = dragStartSize.current - (dragStartPos.current - e.clientX);\n } else if (position === 'top') {\n newSize = dragStartSize.current - (dragStartPos.current - e.clientY);\n } else if (position === 'bottom') {\n newSize = dragStartSize.current - (e.clientY - dragStartPos.current);\n } else {\n newSize = dragStartSize.current - (e.clientX - dragStartPos.current);\n }\n if (newSize >= minSize && newSize <= maxSize) {\n setSize(newSize);\n if (cacheKey) {\n localStorage.setItem(cacheKey, String(newSize));\n }\n onResize?.(newSize);\n }\n }\n });\n const handleResizeEnd = useRefFunction(() => {\n setIsDragging(false);\n });\n\n // Monitor drawer ref, calculate size if not set\n // This is useful for initial rendering when size is not provided\n useEffect(() => {\n if (drawerRef && size === undefined) {\n const rect = drawerRef.getBoundingClientRect();\n setSize(position === 'left' || position === 'right' ? rect.width : rect.height);\n }\n }, [drawerRef, position, size]);\n\n // Controlled open state\n useEffect(() => {\n setIsOpen(open);\n }, [open]);\n\n // Handle global events\n useEffect(() => {\n if (isDragging) {\n window.addEventListener('mousemove', handleResize);\n window.addEventListener('mouseup', handleResizeEnd);\n } else {\n window.removeEventListener('mousemove', handleResize);\n window.removeEventListener('mouseup', handleResizeEnd);\n }\n return () => {\n window.removeEventListener('mousemove', handleResize);\n window.removeEventListener('mouseup', handleResizeEnd);\n };\n }, [isDragging]);\n\n return wrapCSSVar(\n <div\n className={classString}\n style={{\n // @ts-expect-error: because of dynamic CSS variables\n '--edge-offset': typeof edgeOffset === 'number' ? `${edgeOffset}px` : edgeOffset,\n ...style,\n }}\n onClick={onClick}\n >\n <div\n ref={setDrawerRef}\n className={classNames(`${prefixCls}-drawer`, classNamesInProps?.drawer)}\n style={{ ...sizeMap, ...styles?.drawer }}\n >\n {resizable && (\n <div\n className={classNames(\n `${prefixCls}-resize-handle`,\n isDragging && `${prefixCls}-resize-handle-dragging`,\n classNamesInProps?.resizeHandle\n )}\n style={styles?.resizeHandle}\n onMouseDown={handleResizeStart}\n />\n )}\n <div className={classNames(`${prefixCls}-content`, classNamesInProps?.content)} style={styles?.content}>\n <Card\n bordered={false}\n variant=\"borderless\"\n className={classNames(`${prefixCls}-card`, classNamesInProps?.card)}\n style={styles?.card}\n {...cardProps}\n >\n {children}\n </Card>\n </div>\n {showToggle && (\n <div\n className={classNames(`${prefixCls}-toggle`, classNamesInProps?.toggle)}\n style={styles?.toggle}\n onClick={toggleDrawer}\n >\n <div\n className={classNames(`${prefixCls}-handle-icon`, classNamesInProps?.handleIcon)}\n style={styles?.handleIcon}\n >\n {isOpen ? openIcon : closeIcon}\n </div>\n </div>\n )}\n </div>\n </div>\n );\n};\n\nexport default FloatDrawer;\n"],"mappings":";;;;;;;;;;;;AACA,SAASA,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAExE,SAASC,IAAI,EAAEC,cAAc,QAAQ,MAAM;AAC3C,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,YAAY,EAAEC,YAAY,EAAEC,aAAa,EAAEC,UAAU,QAAQ,mBAAmB;AACzF,OAAOC,cAAc;AACrB,OAAOC,QAAQ;AAAgB,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAiL/B;AACA;AACA;AACA;AACA,IAAMC,WAAiC,GAAG,SAApCA,WAAiCA,CAAIC,KAAK,EAAK;EACnD,IACaC,gBAAgB,GAmBzBD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AAEC,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEiF;QAAK,GAChBtF,SAAS;UAAAC,QAAA,EAEZA;QAAQ,EACL;MAAC,CACJ,CAAC,EACLc,UAAU,iBACTzB,IAAA;QACEY,SAAS,EAAEpB,UAAU,IAAAyE,MAAA,CAAI3D,SAAS,cAAWO,iBAAiB,aAAjBA,iBAAiB,uBAAjBA,iBAAiB,CAAEoF,MAAM,CAAE;QACxEnF,KAAK,EAAEC,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEkF,MAAO;QACtBnE,OAAO,EAAEsC,YAAa;QAAAzD,QAAA,eAEtBX,IAAA;UACEY,SAAS,EAAEpB,UAAU,IAAAyE,MAAA,CAAI3D,SAAS,mBAAgBO,iBAAiB,aAAjBA,iBAAiB,uBAAjBA,iBAAiB,CAAEqF,UAAU,CAAE;UACjFpF,KAAK,EAAEC,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEmF,UAAW;UAAAvF,QAAA,EAEzB6C,MAAM,GAAGW,QAAQ,GAAGD;QAAS,CAC3B;MAAC,CACH,CACN;IAAA,CACE;EAAC,CACH,CACP,CAAC;AACH,CAAC;AAED,eAAe/D,WAAW"}
@@ -2,7 +2,8 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
2
2
  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; }
3
3
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
4
4
  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); }
5
- import { genStyleHooks } from 'antd/es/theme/internal';
5
+ import { genStyleHooks } from 'antd/es/theme/util/genStyleUtils';
6
+ import { FastColor } from '@ant-design/fast-color';
6
7
  import { getColorLuminance } from "../../../utils";
7
8
  var genStyle = function genStyle(token) {
8
9
  var _componentCls;
@@ -41,22 +42,26 @@ var genStyle = function genStyle(token) {
41
42
  }), "&".concat(componentCls, "-open").concat(componentCls, "-left ").concat(componentCls, "-drawer,\n &").concat(componentCls, "-open").concat(componentCls, "-right ").concat(componentCls, "-drawer,\n &").concat(componentCls, "-open").concat(componentCls, "-top ").concat(componentCls, "-drawer,\n &").concat(componentCls, "-open").concat(componentCls, "-bottom ").concat(componentCls, "-drawer"), {
42
43
  transform: 'translate(0, 0)'
43
44
  }), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_componentCls, "&".concat(componentCls, "-open").concat(componentCls, "-left ").concat(componentCls, "-drawer"), {
44
- boxShadow: "2px 0 10px ".concat(token.colorFill)
45
+ // On the left side: the shadow casts to the right
46
+ boxShadow: "2px 0 12px ".concat(new FastColor(token.colorTextBase).setA(0.1).toRgbString(), ", 1.5px 0 6px ").concat(new FastColor(token.colorTextBase).setA(0.02).toRgbString())
45
47
  }), "&".concat(componentCls, "-open").concat(componentCls, "-right ").concat(componentCls, "-drawer"), {
46
- boxShadow: "-2px 0 10px ".concat(token.colorFill)
48
+ // On the right side: the shadow casts to the left
49
+ boxShadow: "-2px 0 12px ".concat(new FastColor(token.colorTextBase).setA(0.1).toRgbString(), ", -1.5px 0 6px ").concat(new FastColor(token.colorTextBase).setA(0.02).toRgbString())
47
50
  }), "&".concat(componentCls, "-open").concat(componentCls, "-top ").concat(componentCls, "-drawer"), {
48
- boxShadow: "0 2px 10px ".concat(token.colorFill)
51
+ // On the top side: the shadow casts downward
52
+ boxShadow: "0 2px 12px ".concat(new FastColor(token.colorTextBase).setA(0.1).toRgbString(), ", 0 1.5px 6px ").concat(new FastColor(token.colorTextBase).setA(0.02).toRgbString())
49
53
  }), "&".concat(componentCls, "-open").concat(componentCls, "-bottom ").concat(componentCls, "-drawer"), {
50
- boxShadow: "0 -2px 10px ".concat(token.colorFill)
54
+ // On the bottom side: the shadow casts upward
55
+ boxShadow: "0 -2px 12px ".concat(new FastColor(token.colorTextBase).setA(0.1).toRgbString(), ", 0 -1.5px 6px ").concat(new FastColor(token.colorTextBase).setA(0.02).toRgbString())
51
56
  }), "&".concat(componentCls, "-closed").concat(componentCls, "-left ").concat(componentCls, "-drawer"), {
52
- transform: 'translateX(-100%)'
57
+ transform: 'translateX(calc(-100% - var(--edge-offset, 0px)))'
53
58
  }), "&".concat(componentCls, "-closed").concat(componentCls, "-right ").concat(componentCls, "-drawer"), {
54
- transform: 'translateX(100%)'
59
+ transform: 'translateX(calc(100% + var(--edge-offset, 0px)))'
55
60
  }), "&".concat(componentCls, "-closed").concat(componentCls, "-top ").concat(componentCls, "-drawer"), {
56
- transform: 'translateY(-100%)'
61
+ transform: 'translateY(calc(-100% - var(--edge-offset, 0px)))'
57
62
  }), "&".concat(componentCls, "-closed").concat(componentCls, "-bottom ").concat(componentCls, "-drawer"), {
58
- transform: 'translateY(100%)'
59
- }), "".concat(componentCls, "-expand-handle"), {
63
+ transform: 'translateY(calc(100% + var(--edge-offset, 0px)))'
64
+ }), "".concat(componentCls, "-toggle"), {
60
65
  position: 'absolute',
61
66
  zIndex: 2,
62
67
  cursor: 'pointer',
@@ -70,34 +75,50 @@ var genStyle = function genStyle(token) {
70
75
  color: token.colorText,
71
76
  backgroundColor: getColorLuminance(token.colorBgBase) > 0.5 ? '#f0f0f0' : '#1a1a1a'
72
77
  }
73
- }), "&".concat(componentCls, "-left ").concat(componentCls, "-expand-handle,\n &").concat(componentCls, "-right ").concat(componentCls, "-expand-handle"), {
78
+ }), "&".concat(componentCls, "-left ").concat(componentCls, "-toggle,\n &").concat(componentCls, "-right ").concat(componentCls, "-toggle"), {
74
79
  top: '50%',
75
80
  width: 24,
76
81
  height: 60
77
- }), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_componentCls, "&".concat(componentCls, "-top ").concat(componentCls, "-expand-handle,\n &").concat(componentCls, "-bottom ").concat(componentCls, "-expand-handle"), {
82
+ }), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_componentCls, "&".concat(componentCls, "-top ").concat(componentCls, "-toggle,\n &").concat(componentCls, "-bottom ").concat(componentCls, "-toggle"), {
78
83
  left: '50%',
79
84
  width: 60,
80
85
  height: 24
81
- }), "&".concat(componentCls, "-left ").concat(componentCls, "-expand-handle"), {
86
+ }), "&".concat(componentCls, "-left ").concat(componentCls, "-toggle"), {
82
87
  right: 0,
83
88
  transform: 'translate(100%, -50%)',
84
89
  borderRadius: '0 8px 8px 0',
85
- boxShadow: "2px 0 5px ".concat(token.colorFill)
86
- }), "&".concat(componentCls, "-right ").concat(componentCls, "-expand-handle"), {
90
+ // On the left side: the shadow casts to the right and upward/downward in half size
91
+ boxShadow: "0px 2px 4px ".concat(new FastColor(token.colorTextBase).setA(0.08).toRgbString(), ", \n 0px -2px 4px ").concat(new FastColor(token.colorTextBase).setA(0.08).toRgbString(), ", \n 4px 0px 8px ").concat(new FastColor(token.colorTextBase).setA(0.1).toRgbString()),
92
+ '&:hover': {
93
+ boxShadow: "0px 2px 4px ".concat(new FastColor(token.colorTextBase).setA(0.1).toRgbString(), ", \n 0px -2px 4px ").concat(new FastColor(token.colorTextBase).setA(0.1).toRgbString(), ", \n 4px 0px 8px ").concat(new FastColor(token.colorTextBase).setA(0.12).toRgbString())
94
+ }
95
+ }), "&".concat(componentCls, "-right ").concat(componentCls, "-toggle"), {
87
96
  left: 0,
88
97
  transform: 'translate(-100%, -50%)',
89
98
  borderRadius: '8px 0 0 8px',
90
- boxShadow: "-2px 0 5px ".concat(token.colorFill)
91
- }), "&".concat(componentCls, "-top ").concat(componentCls, "-expand-handle"), {
99
+ // On the right side: the shadow casts to the left and upward/downward in half size
100
+ boxShadow: "0px 2px 4px ".concat(new FastColor(token.colorTextBase).setA(0.08).toRgbString(), ", \n 0px -2px 4px ").concat(new FastColor(token.colorTextBase).setA(0.08).toRgbString(), ", \n -4px 0px 8px ").concat(new FastColor(token.colorTextBase).setA(0.1).toRgbString()),
101
+ '&:hover': {
102
+ boxShadow: "0px 2px 4px ".concat(new FastColor(token.colorTextBase).setA(0.1).toRgbString(), ", \n 0px -2px 4px ").concat(new FastColor(token.colorTextBase).setA(0.1).toRgbString(), ", \n -4px 0px 8px ").concat(new FastColor(token.colorTextBase).setA(0.12).toRgbString())
103
+ }
104
+ }), "&".concat(componentCls, "-top ").concat(componentCls, "-toggle"), {
92
105
  bottom: 0,
93
106
  transform: 'translate(-50%, 100%)',
94
107
  borderRadius: '0 0 8px 8px',
95
- boxShadow: "0 2px 5px ".concat(token.colorFill)
96
- }), "&".concat(componentCls, "-bottom ").concat(componentCls, "-expand-handle"), {
108
+ // On the top side: the shadow casts downward and left/right in half size
109
+ boxShadow: "2px 0px 4px ".concat(new FastColor(token.colorTextBase).setA(0.08).toRgbString(), ", \n -2px 0px 4px ").concat(new FastColor(token.colorTextBase).setA(0.08).toRgbString(), ", \n 0px 4px 8px ").concat(new FastColor(token.colorTextBase).setA(0.1).toRgbString()),
110
+ '&:hover': {
111
+ boxShadow: "2px 0px 4px ".concat(new FastColor(token.colorTextBase).setA(0.1).toRgbString(), ", \n -2px 0px 4px ").concat(new FastColor(token.colorTextBase).setA(0.1).toRgbString(), ", \n 0px 4px 8px ").concat(new FastColor(token.colorTextBase).setA(0.12).toRgbString())
112
+ }
113
+ }), "&".concat(componentCls, "-bottom ").concat(componentCls, "-toggle"), {
97
114
  top: 0,
98
115
  transform: 'translate(-50%, -100%)',
99
116
  borderRadius: '8px 8px 0 0',
100
- boxShadow: "0 -2px 5px ".concat(token.colorFill)
117
+ // On the bottom side: the shadow casts upward and left/right in half size
118
+ boxShadow: "2px 0px 4px ".concat(new FastColor(token.colorTextBase).setA(0.08).toRgbString(), ", \n -2px 0px 4px ").concat(new FastColor(token.colorTextBase).setA(0.08).toRgbString(), ", \n 0px -4px 8px ").concat(new FastColor(token.colorTextBase).setA(0.1).toRgbString()),
119
+ '&:hover': {
120
+ boxShadow: "2px 0px 4px ".concat(new FastColor(token.colorTextBase).setA(0.1).toRgbString(), ", \n -2px 0px 4px ").concat(new FastColor(token.colorTextBase).setA(0.1).toRgbString(), ", \n 0px -4px 8px ").concat(new FastColor(token.colorTextBase).setA(0.12).toRgbString())
121
+ }
101
122
  }), "".concat(componentCls, "-handle-icon"), {
102
123
  userSelect: 'none',
103
124
  lineHeight: 0
@@ -144,5 +165,5 @@ var genStyle = function genStyle(token) {
144
165
  overflow: 'auto'
145
166
  })))));
146
167
  };
147
- export default genStyleHooks('easy-float-drawer', genStyle);
168
+ export default genStyleHooks('EasyFloatDrawer', genStyle);
148
169
  //# sourceMappingURL=index.js.map