@pointcloud/pcloud-components 0.1.30 → 0.1.32

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 (36) hide show
  1. package/README.md +107 -302
  2. package/dist/esm/AnimatedScrollList/index.d.ts +7 -0
  3. package/dist/esm/AnimatedScrollList/index.js +322 -0
  4. package/dist/esm/AnimatedScrollList/interface.d.ts +71 -0
  5. package/dist/esm/AnimatedScrollList/interface.js +1 -0
  6. package/dist/esm/AnimatedScrollList/styles/index.less +22 -0
  7. package/dist/esm/ColorPicker/index.d.ts +11 -10
  8. package/dist/esm/ColorPicker/index.js +1 -1
  9. package/dist/esm/ConfigProvider/index.d.ts +1 -1
  10. package/dist/esm/ConfigProvider/index.js +21 -4
  11. package/dist/esm/ConfigProvider/interface.d.ts +2 -4
  12. package/dist/esm/ErrorBoundary/index.d.ts +2 -1
  13. package/dist/esm/InfiniteScrollList/index.d.ts +1 -1
  14. package/dist/esm/LabelValue/index.d.ts +1 -1
  15. package/dist/esm/Loading/loading.d.ts +2 -1
  16. package/dist/esm/LoginForm/index.js +1 -1
  17. package/dist/esm/NoData/index.d.ts +2 -1
  18. package/dist/esm/OrgTree/index.d.ts +5 -0
  19. package/dist/esm/OrgTree/index.js +58 -0
  20. package/dist/esm/OrgTree/index.less +15 -0
  21. package/dist/esm/OrgTree/interface.d.ts +41 -0
  22. package/dist/esm/OrgTree/interface.js +1 -0
  23. package/dist/esm/RndDrag/index.d.ts +2 -1
  24. package/dist/esm/ScrollNumber/index.d.ts +2 -1
  25. package/dist/esm/TypewriterText/index.d.ts +5 -0
  26. package/dist/esm/TypewriterText/index.js +282 -0
  27. package/dist/esm/TypewriterText/index.less +29 -0
  28. package/dist/esm/TypewriterText/interface.d.ts +42 -0
  29. package/dist/esm/TypewriterText/interface.js +1 -0
  30. package/dist/esm/WordCloud/index.d.ts +2 -1
  31. package/dist/esm/index.d.ts +6 -0
  32. package/dist/esm/index.js +4 -1
  33. package/dist/umd/pcloud-components.min.css +1 -1
  34. package/dist/umd/pcloud-components.min.js +1 -1
  35. package/package.json +3 -2
  36. package/README_USER.md +0 -133
@@ -0,0 +1,322 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
+ import React, { useRef, useEffect, useCallback, useContext } from 'react';
4
+ import classNames from 'classnames';
5
+ import { ConfigContext } from "../ConfigProvider";
6
+ import "./styles/index.less";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ import { Fragment as _Fragment } from "react/jsx-runtime";
9
+ import { jsxs as _jsxs } from "react/jsx-runtime";
10
+ function AnimatedScrollList(props) {
11
+ var _props$direction = props.direction,
12
+ direction = _props$direction === void 0 ? 'up' : _props$direction,
13
+ _props$speed = props.speed,
14
+ speed = _props$speed === void 0 ? 50 : _props$speed,
15
+ _props$hoverStop = props.hoverStop,
16
+ hoverStop = _props$hoverStop === void 0 ? true : _props$hoverStop,
17
+ _props$autoStart = props.autoStart,
18
+ autoStart = _props$autoStart === void 0 ? true : _props$autoStart,
19
+ containerHeight = props.containerHeight,
20
+ containerWidth = props.containerWidth,
21
+ _props$data = props.data,
22
+ data = _props$data === void 0 ? [] : _props$data,
23
+ renderItem = props.renderItem,
24
+ _props$itemKey = props.itemKey,
25
+ itemKey = _props$itemKey === void 0 ? 'id' : _props$itemKey,
26
+ _props$className = props.className,
27
+ className = _props$className === void 0 ? '' : _props$className,
28
+ _props$style = props.style,
29
+ style = _props$style === void 0 ? {} : _props$style,
30
+ _props$showScrollbar = props.showScrollbar,
31
+ showScrollbar = _props$showScrollbar === void 0 ? false : _props$showScrollbar,
32
+ _props$scrollWhenInsu = props.scrollWhenInsufficient,
33
+ scrollWhenInsufficient = _props$scrollWhenInsu === void 0 ? false : _props$scrollWhenInsu,
34
+ header = props.header;
35
+ var _useContext = useContext(ConfigContext),
36
+ prefixCls = _useContext.prefixCls,
37
+ getPrefixCls = _useContext.getPrefixCls;
38
+ var classname = getPrefixCls('animated-scroll-list');
39
+ var wrapperClass = classNames(_defineProperty({}, "".concat(prefixCls, "-animated-scroll-list"), !!prefixCls), classname, className);
40
+ var containerRef = useRef(null);
41
+ var contentRef = useRef(null);
42
+ var animationFrameRef = useRef(null);
43
+ var lastTimestampRef = useRef(0);
44
+ var currentOffsetRef = useRef(0);
45
+ var isHoveringRef = useRef(false);
46
+ var isPausedRef = useRef(!autoStart);
47
+ var totalSizeRef = useRef(0);
48
+
49
+ // 判断是否为垂直方向
50
+ var isVertical = direction === 'up' || direction === 'down';
51
+ // 是否反向滚动
52
+ var isReverse = direction === 'down' || direction === 'right';
53
+
54
+ // 获取列表项的 key
55
+ var getItemKey = useCallback(function (item, index) {
56
+ var _item$itemKey;
57
+ if (typeof itemKey === 'function') {
58
+ return itemKey(item, index);
59
+ }
60
+ return (_item$itemKey = item === null || item === void 0 ? void 0 : item[itemKey]) !== null && _item$itemKey !== void 0 ? _item$itemKey : index;
61
+ }, [itemKey]);
62
+ var parsePixelValue = useCallback(function (value) {
63
+ var parsed = parseFloat(value || '');
64
+ return Number.isNaN(parsed) ? 0 : parsed;
65
+ }, []);
66
+
67
+ // 计算列表项尺寸(包含元素自身尺寸和滚动方向上的 margin)
68
+ var calculateItemDimensions = useCallback(function () {
69
+ if (!contentRef.current || data.length === 0) {
70
+ totalSizeRef.current = 0;
71
+ return 0;
72
+ }
73
+ var items = contentRef.current.children;
74
+ var firstGroupItems = Array.from(items).slice(0, data.length);
75
+ if (firstGroupItems.length === 0) {
76
+ totalSizeRef.current = 0;
77
+ return 0;
78
+ }
79
+ var totalSize = firstGroupItems.reduce(function (sum, item) {
80
+ var rect = item.getBoundingClientRect();
81
+ var styles = window.getComputedStyle(item);
82
+ var axisMargin = isVertical ? parsePixelValue(styles.marginTop) + parsePixelValue(styles.marginBottom) : parsePixelValue(styles.marginLeft) + parsePixelValue(styles.marginRight);
83
+ var size = isVertical ? rect.height : rect.width;
84
+ return sum + size + axisMargin;
85
+ }, 0);
86
+ totalSizeRef.current = totalSize;
87
+ return totalSize;
88
+ }, [data, isVertical, parsePixelValue]);
89
+ var applyTransform = useCallback(function (offset) {
90
+ if (!contentRef.current) return;
91
+ var value = isVertical ? "translateY(".concat(-offset, "px)") : "translateX(".concat(-offset, "px)");
92
+ contentRef.current.style.transform = value;
93
+ }, [isVertical]);
94
+
95
+ // 动画循环
96
+ var animate = useCallback(function (timestamp) {
97
+ if (!contentRef.current || isPausedRef.current || data.length === 0) {
98
+ animationFrameRef.current = null;
99
+ return;
100
+ }
101
+ if (lastTimestampRef.current === 0) {
102
+ lastTimestampRef.current = timestamp;
103
+ animationFrameRef.current = requestAnimationFrame(animate);
104
+ return;
105
+ }
106
+ var deltaSeconds = (timestamp - lastTimestampRef.current) / 1000;
107
+ lastTimestampRef.current = timestamp;
108
+ var distance = speed * deltaSeconds;
109
+
110
+ // 计算新的偏移量
111
+ // 反向滚动时,从 totalSize 开始递减;正向滚动时,从 0 开始递增
112
+ var newOffset = isReverse ? currentOffsetRef.current - distance : currentOffsetRef.current + distance;
113
+
114
+ // 如果总尺寸为 0,说明还没有计算完成,等待
115
+ if (totalSizeRef.current === 0) {
116
+ animationFrameRef.current = requestAnimationFrame(animate);
117
+ return;
118
+ }
119
+
120
+ // 无缝循环:当滚动超过一个完整列表的高度/宽度时,重置位置
121
+ if (isReverse) {
122
+ // 反向滚动:从 totalSize 开始向 0 滚动
123
+ if (newOffset <= 0) {
124
+ newOffset = totalSizeRef.current + newOffset;
125
+ }
126
+ } else {
127
+ // 正向滚动:从 0 开始向 totalSize 滚动
128
+ if (newOffset >= totalSizeRef.current) {
129
+ newOffset = newOffset - totalSizeRef.current;
130
+ }
131
+ }
132
+ currentOffsetRef.current = newOffset;
133
+
134
+ // 应用 transform
135
+ applyTransform(newOffset);
136
+ animationFrameRef.current = requestAnimationFrame(animate);
137
+ }, [speed, isReverse, data.length, applyTransform]);
138
+
139
+ // 启动动画
140
+ var startAnimation = useCallback(function () {
141
+ if (animationFrameRef.current || isPausedRef.current) return;
142
+ lastTimestampRef.current = 0;
143
+ animationFrameRef.current = requestAnimationFrame(animate);
144
+ }, [animate]);
145
+
146
+ // 停止动画
147
+ var stopAnimation = useCallback(function () {
148
+ if (animationFrameRef.current) {
149
+ cancelAnimationFrame(animationFrameRef.current);
150
+ animationFrameRef.current = null;
151
+ }
152
+ lastTimestampRef.current = 0;
153
+ }, []);
154
+
155
+ // 数据动态更新时保持动画平滑
156
+ useEffect(function () {
157
+ if (data.length === 0) {
158
+ stopAnimation();
159
+ totalSizeRef.current = 0;
160
+ currentOffsetRef.current = 0;
161
+ applyTransform(0);
162
+ return;
163
+ }
164
+ var rafId = null;
165
+ var timerId = null;
166
+ var measure = function measure() {
167
+ var _containerRef$current, _containerRef$current2, _containerRef$current3, _containerRef$current4;
168
+ var previousTotal = totalSizeRef.current;
169
+ var newTotal = calculateItemDimensions();
170
+ if (newTotal === 0) {
171
+ rafId = window.requestAnimationFrame(measure);
172
+ return;
173
+ }
174
+ var containerSize = isVertical ? (_containerRef$current = (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.clientHeight) !== null && _containerRef$current !== void 0 ? _containerRef$current : 0 : (_containerRef$current3 = (_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.clientWidth) !== null && _containerRef$current3 !== void 0 ? _containerRef$current3 : 0;
175
+ var shouldScroll = scrollWhenInsufficient || newTotal > containerSize;
176
+ var normalizedOffset = previousTotal > 0 ? currentOffsetRef.current % previousTotal : 0;
177
+ if (normalizedOffset < 0) {
178
+ normalizedOffset += previousTotal;
179
+ }
180
+ var progress = previousTotal > 0 ? normalizedOffset / previousTotal : isReverse ? 1 : 0;
181
+ var nextOffset = shouldScroll ? progress * newTotal : 0;
182
+ if (isReverse && shouldScroll && nextOffset === 0) {
183
+ nextOffset = newTotal;
184
+ }
185
+ currentOffsetRef.current = nextOffset;
186
+ applyTransform(nextOffset);
187
+ if (shouldScroll && autoStart && !isHoveringRef.current && !isPausedRef.current) {
188
+ startAnimation();
189
+ } else {
190
+ stopAnimation();
191
+ }
192
+ };
193
+ stopAnimation();
194
+ timerId = window.setTimeout(function () {
195
+ rafId = window.requestAnimationFrame(measure);
196
+ }, 80);
197
+ return function () {
198
+ if (timerId) {
199
+ window.clearTimeout(timerId);
200
+ }
201
+ if (rafId) {
202
+ window.cancelAnimationFrame(rafId);
203
+ }
204
+ };
205
+ }, [data, calculateItemDimensions, applyTransform, isVertical, isReverse, scrollWhenInsufficient, autoStart, startAnimation, stopAnimation]);
206
+
207
+ // 处理鼠标进入
208
+ var handleMouseEnter = useCallback(function () {
209
+ if (!hoverStop) return;
210
+ isHoveringRef.current = true;
211
+ stopAnimation();
212
+ }, [hoverStop, stopAnimation]);
213
+
214
+ // 处理鼠标离开
215
+ var handleMouseLeave = useCallback(function () {
216
+ if (!hoverStop) return;
217
+ isHoveringRef.current = false;
218
+ if (!isPausedRef.current) {
219
+ startAnimation();
220
+ }
221
+ }, [hoverStop, startAnimation]);
222
+
223
+ // 监听 visibilitychange
224
+ useEffect(function () {
225
+ var handleVisibilityChange = function handleVisibilityChange() {
226
+ if (document.hidden) {
227
+ stopAnimation();
228
+ } else {
229
+ if (!isPausedRef.current && !isHoveringRef.current) {
230
+ startAnimation();
231
+ }
232
+ }
233
+ };
234
+ document.addEventListener('visibilitychange', handleVisibilityChange);
235
+ return function () {
236
+ document.removeEventListener('visibilitychange', handleVisibilityChange);
237
+ };
238
+ }, [startAnimation, stopAnimation]);
239
+
240
+ // 初始化动画
241
+ useEffect(function () {
242
+ if (autoStart && !isPausedRef.current && data.length > 0) {
243
+ // 等待尺寸计算完成后再启动动画
244
+ var checkAndStart = function checkAndStart() {
245
+ if (containerRef.current && contentRef.current && totalSizeRef.current > 0) {
246
+ var containerSize = isVertical ? containerRef.current.clientHeight : containerRef.current.clientWidth;
247
+ var shouldScroll = scrollWhenInsufficient || totalSizeRef.current > containerSize;
248
+ if (shouldScroll) {
249
+ startAnimation();
250
+ }
251
+ } else if (totalSizeRef.current === 0) {
252
+ // 如果尺寸还没计算完成,延迟重试
253
+ setTimeout(checkAndStart, 50);
254
+ }
255
+ };
256
+ checkAndStart();
257
+ return function () {
258
+ stopAnimation();
259
+ };
260
+ }
261
+ return function () {
262
+ stopAnimation();
263
+ };
264
+ }, [autoStart, data, startAnimation, stopAnimation, scrollWhenInsufficient, isVertical]);
265
+
266
+ // 渲染列表项(复制一份用于无缝循环)
267
+ var renderItems = useCallback(function () {
268
+ if (data.length === 0) return null;
269
+ var items = data.map(function (item, index) {
270
+ return /*#__PURE__*/_jsx("div", {
271
+ className: "data-scroll-item",
272
+ children: renderItem(item, index)
273
+ }, "first-".concat(getItemKey(item, index)));
274
+ });
275
+
276
+ // 复制一份用于无缝循环
277
+ var duplicatedItems = data.map(function (item, index) {
278
+ return /*#__PURE__*/_jsx("div", {
279
+ className: "data-scroll-item",
280
+ children: renderItem(item, index)
281
+ }, "second-".concat(getItemKey(item, index)));
282
+ });
283
+ return /*#__PURE__*/_jsxs(_Fragment, {
284
+ children: [items, duplicatedItems]
285
+ });
286
+ }, [data, renderItem, getItemKey]);
287
+
288
+ // 容器样式
289
+ var containerStyle = _objectSpread({
290
+ height: containerHeight,
291
+ width: containerWidth,
292
+ overflow: showScrollbar ? 'auto' : 'hidden',
293
+ position: 'relative'
294
+ }, style);
295
+
296
+ // 内容容器样式
297
+ var contentStyle = {
298
+ display: 'flex',
299
+ flexDirection: isVertical ? 'column' : 'row',
300
+ willChange: 'transform'
301
+ };
302
+ return /*#__PURE__*/_jsxs("div", {
303
+ className: wrapperClass,
304
+ children: [header && /*#__PURE__*/_jsx("div", {
305
+ className: "".concat(classname, "-header"),
306
+ children: header
307
+ }), /*#__PURE__*/_jsx("div", {
308
+ ref: containerRef,
309
+ className: "".concat(classname, "-body"),
310
+ style: containerStyle,
311
+ onMouseEnter: handleMouseEnter,
312
+ onMouseLeave: handleMouseLeave,
313
+ children: /*#__PURE__*/_jsx("div", {
314
+ ref: contentRef,
315
+ className: "".concat(classname, "-content"),
316
+ style: contentStyle,
317
+ children: renderItems()
318
+ })
319
+ })]
320
+ });
321
+ }
322
+ export default /*#__PURE__*/React.memo(AnimatedScrollList);
@@ -0,0 +1,71 @@
1
+ import React from 'react';
2
+ export declare type ScrollDirection = 'up' | 'down' | 'left' | 'right';
3
+ export interface IAnimatedScrollListProps {
4
+ /**
5
+ * @description 滚动方向
6
+ * @default 'up'
7
+ */
8
+ direction?: ScrollDirection;
9
+ /**
10
+ * @description 滚动速度,单位 px/s
11
+ * @default 50
12
+ */
13
+ speed?: number;
14
+ /**
15
+ * @description 是否在鼠标悬停时暂停滚动
16
+ * @default true
17
+ */
18
+ hoverStop?: boolean;
19
+ /**
20
+ * @description 是否自动开始滚动
21
+ * @default true
22
+ */
23
+ autoStart?: boolean;
24
+ /**
25
+ * @description 容器高度(垂直滚动时)或宽度(水平滚动时)
26
+ */
27
+ containerHeight?: number | string;
28
+ /**
29
+ * @description 容器宽度(水平滚动时)或高度(垂直滚动时)
30
+ */
31
+ containerWidth?: number | string;
32
+ /**
33
+ * @description 列表数据
34
+ */
35
+ data: any[];
36
+ /**
37
+ * @description 渲染列表项的方法
38
+ * @param item 列表项数据
39
+ * @param index 索引
40
+ * @returns React.ReactNode
41
+ */
42
+ renderItem: (_item: any, _index: number) => React.ReactNode;
43
+ /**
44
+ * @description 列表项的唯一标识字段,用于 key
45
+ * @default 'id'
46
+ */
47
+ itemKey?: string | ((_item: any, _index: number) => string | number);
48
+ /**
49
+ * @description 自定义类名
50
+ */
51
+ className?: string;
52
+ /**
53
+ * @description 自定义样式
54
+ */
55
+ style?: React.CSSProperties;
56
+ /**
57
+ * @description 是否显示滚动条
58
+ * @default false
59
+ */
60
+ showScrollbar?: boolean;
61
+ /**
62
+ * @description 当列表项数量不足一屏时是否仍然滚动
63
+ * @default false
64
+ */
65
+ scrollWhenInsufficient?: boolean;
66
+ /**
67
+ * @description 表头内容,传入后表头固定,内容区域自动滚动
68
+ */
69
+ header?: React.ReactNode;
70
+ }
71
+ export declare type AnimatedScrollListProps = IAnimatedScrollListProps;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ @import '../../commonStyle/index.less';
2
+
3
+ .@{prefix}-animated-scroll-list {
4
+ position: relative;
5
+ display: flex;
6
+ flex-direction: column;
7
+ height: 100%;
8
+ overflow: hidden;
9
+
10
+ &-header {
11
+ flex-shrink: 0;
12
+ }
13
+
14
+ &-body {
15
+ position: relative;
16
+ overflow: hidden;
17
+ }
18
+
19
+ &-content {
20
+ position: relative;
21
+ }
22
+ }
@@ -1,17 +1,18 @@
1
+ /// <reference types="react" />
1
2
  import { ColorPickerProps, TwitterPickerProps, HuePickerProps, AlphaPickerProps, BlockPickerProps, ChromePickerProps, CompactPickerProps, CirclePickerProps, SliderPickerProps } from './interface';
2
3
  import './index.less';
3
4
  declare const ColorPicker: {
4
- (props: ColorPickerProps): import("react/jsx-runtime").JSX.Element;
5
+ (props: ColorPickerProps): JSX.Element;
5
6
  PSPicker(props: ColorPickerProps & {
6
7
  title?: string;
7
- }): import("react/jsx-runtime").JSX.Element;
8
- SliderPicker(props: SliderPickerProps): import("react/jsx-runtime").JSX.Element;
9
- AlphaPicker(props: AlphaPickerProps): import("react/jsx-runtime").JSX.Element;
10
- BlockPicker(props: BlockPickerProps): import("react/jsx-runtime").JSX.Element;
11
- ChromePicker(props: ChromePickerProps): import("react/jsx-runtime").JSX.Element;
12
- CirclePicker(props: CirclePickerProps): import("react/jsx-runtime").JSX.Element;
13
- CompactPicker(props: CompactPickerProps): import("react/jsx-runtime").JSX.Element;
14
- HuePicker(props: HuePickerProps): import("react/jsx-runtime").JSX.Element;
15
- TwitterPicker(props: TwitterPickerProps): import("react/jsx-runtime").JSX.Element;
8
+ }): JSX.Element;
9
+ SliderPicker(props: SliderPickerProps): JSX.Element;
10
+ AlphaPicker(props: AlphaPickerProps): JSX.Element;
11
+ BlockPicker(props: BlockPickerProps): JSX.Element;
12
+ ChromePicker(props: ChromePickerProps): JSX.Element;
13
+ CirclePicker(props: CirclePickerProps): JSX.Element;
14
+ CompactPicker(props: CompactPickerProps): JSX.Element;
15
+ HuePicker(props: HuePickerProps): JSX.Element;
16
+ TwitterPicker(props: TwitterPickerProps): JSX.Element;
16
17
  };
17
18
  export default ColorPicker;
@@ -9,8 +9,8 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
9
9
  import { useState, useContext } from 'react';
10
10
  import classNames from 'classnames';
11
11
  import { Popconfirm } from 'antd';
12
- import { SketchPicker, PhotoshopPicker, SliderPicker, AlphaPicker, BlockPicker, ChromePicker, CirclePicker, CompactPicker, HuePicker, TwitterPicker } from 'react-color';
13
12
  import { ConfigContext } from "../ConfigProvider";
13
+ import { SketchPicker, PhotoshopPicker, SliderPicker, AlphaPicker, BlockPicker, ChromePicker, CirclePicker, CompactPicker, HuePicker, TwitterPicker } from 'react-color';
14
14
  import "./index.less";
15
15
  import { jsx as _jsx } from "react/jsx-runtime";
16
16
  import { Fragment as _Fragment } from "react/jsx-runtime";
@@ -2,5 +2,5 @@ import React from 'react';
2
2
  import { ConfigProviderProps } from './interface';
3
3
  export declare const defaultPrefixCls = "pui";
4
4
  export declare const ConfigContext: React.Context<ConfigProviderProps>;
5
- declare const ConfigProvider: (props: ConfigProviderProps) => import("react/jsx-runtime").JSX.Element;
5
+ declare const ConfigProvider: (props: ConfigProviderProps) => JSX.Element;
6
6
  export default ConfigProvider;
@@ -1,18 +1,35 @@
1
- import React, { createContext } from 'react';
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["children", "prefixCls", "getPrefixCls"];
4
+ import React, { createContext, useMemo } from 'react';
5
+ import { ConfigProvider as AntdConfigProvider } from 'antd';
2
6
  import { jsx as _jsx } from "react/jsx-runtime";
3
7
  export var defaultPrefixCls = 'pui';
4
8
 
5
9
  // export const ConfigContext = createContext<ConfigProviderProps>({} as ConfigProviderProps);
6
10
  export var ConfigContext = /*#__PURE__*/createContext({
11
+ // prefixCls: defaultPrefixCls,
7
12
  getPrefixCls: function getPrefixCls(componentName, customPrefix) {
8
13
  return "".concat(customPrefix || defaultPrefixCls, "-").concat(componentName);
9
14
  }
10
15
  });
11
16
  var ConfigProvider = function ConfigProvider(props) {
12
- var children = props.children;
17
+ var children = props.children,
18
+ _props$prefixCls = props.prefixCls,
19
+ prefixCls = _props$prefixCls === void 0 ? defaultPrefixCls : _props$prefixCls,
20
+ getPrefixCls = props.getPrefixCls,
21
+ antdProps = _objectWithoutProperties(props, _excluded);
22
+ var contextValue = useMemo(function () {
23
+ return {
24
+ prefixCls: prefixCls,
25
+ getPrefixCls: getPrefixCls
26
+ };
27
+ }, [prefixCls, getPrefixCls]);
13
28
  return /*#__PURE__*/_jsx(ConfigContext.Provider, {
14
- value: props,
15
- children: children
29
+ value: contextValue,
30
+ children: /*#__PURE__*/_jsx(AntdConfigProvider, _objectSpread(_objectSpread({}, antdProps), {}, {
31
+ children: children
32
+ }))
16
33
  });
17
34
  };
18
35
  export default ConfigProvider;
@@ -1,11 +1,9 @@
1
- import * as React from 'react';
2
- export interface ConfigProviderProps {
1
+ import { ConfigProviderProps as AntdConfigProviderProps } from 'antd/lib/config-provider';
2
+ export interface ConfigProviderProps extends AntdConfigProviderProps {
3
3
  /**
4
4
  * @description 全局组件类名前缀
5
5
  * @default pui
6
6
  */
7
7
  prefixCls?: string;
8
8
  getPrefixCls?: (_componentName: string, _customPrefix?: string) => string;
9
- children?: React.ReactNode;
10
9
  }
11
- export declare type OtherProps = Omit<ConfigProviderProps, 'children'>;
@@ -1,5 +1,6 @@
1
+ /// <reference types="react" />
1
2
  import './index.less';
2
3
  declare function ErrorBoundary({ err }: {
3
4
  err?: any;
4
- }): import("react/jsx-runtime").JSX.Element;
5
+ }): JSX.Element;
5
6
  export default ErrorBoundary;
@@ -59,5 +59,5 @@ interface ISLProps<T, P> {
59
59
  endMessage?: React.ReactNode;
60
60
  }
61
61
  export declare type InfiniteScrollListProps<T, P> = ISLProps<T, P>;
62
- declare const _default: React.MemoExoticComponent<(<T, P>(props: ISLProps<T, P>) => import("react/jsx-runtime").JSX.Element)>;
62
+ declare const _default: React.MemoExoticComponent<(<T, P>(props: ISLProps<T, P>) => JSX.Element)>;
63
63
  export default _default;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { ILabelValueProps } from './interface';
3
3
  import './styles/index.less';
4
- declare function LabelValue({ label, value, emptyValue, className, noWrap, noColon, formatter, style }: ILabelValueProps): import("react/jsx-runtime").JSX.Element;
4
+ declare function LabelValue({ label, value, emptyValue, className, noWrap, noColon, formatter, style }: ILabelValueProps): JSX.Element;
5
5
  declare namespace LabelValue {
6
6
  var defaultProps: {
7
7
  className: string;
@@ -1,6 +1,7 @@
1
+ /// <reference types="react" />
1
2
  import { ILoadingInstance, LoadingInstanceProps } from './interface';
2
3
  import './styles/index.less';
3
- declare function Loading(props: LoadingInstanceProps): import("react/jsx-runtime").JSX.Element;
4
+ declare function Loading(props: LoadingInstanceProps): JSX.Element;
4
5
  declare namespace Loading {
5
6
  var newInstance: (args?: LoadingInstanceProps | undefined) => ILoadingInstance;
6
7
  }
@@ -9,8 +9,8 @@ var _excluded = ["extraItems", "onFinish", "loginText", "loginButtonDisabled", "
9
9
  import React, { useState, useEffect, forwardRef, useContext, useMemo } from 'react';
10
10
  import classNames from 'classnames';
11
11
  import { DForm } from "./..";
12
- import { defaultUsernameItem, defaultPasswordItem, defaultLoginButtonItem } from "./defaultConfig";
13
12
  import { ConfigContext } from "../ConfigProvider";
13
+ import { defaultUsernameItem, defaultPasswordItem, defaultLoginButtonItem } from "./defaultConfig";
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
15
  var mergeItemProps = function mergeItemProps(defaultItem, item, options) {
16
16
  var baseMerged = _objectSpread(_objectSpread({}, defaultItem), item);
@@ -1,4 +1,5 @@
1
+ /// <reference types="react" />
1
2
  import { INoDataProps } from './interface';
2
3
  import './styles/index.less';
3
- declare const NoData: (props: INoDataProps) => import("react/jsx-runtime").JSX.Element;
4
+ declare const NoData: (props: INoDataProps) => JSX.Element;
4
5
  export default NoData;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import type { OrgTreeProps } from './interface';
3
+ import './index.less';
4
+ declare const OrgTree: import("react").ForwardRefExoticComponent<OrgTreeProps & import("react").RefAttributes<any>>;
5
+ export default OrgTree;
@@ -0,0 +1,58 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["data", "className", "style", "collapsable", "expandAll", "labelWidth", "labelClassName"];
4
+ import { forwardRef, useContext, useImperativeHandle, useRef } from 'react';
5
+ import { ConfigContext } from "../ConfigProvider";
6
+ import OrgTreeComponent from 'react-org-tree';
7
+ import "./index.less";
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ var OrgTree = /*#__PURE__*/forwardRef(function (props, ref) {
10
+ var data = props.data,
11
+ className = props.className,
12
+ style = props.style,
13
+ _props$collapsable = props.collapsable,
14
+ collapsable = _props$collapsable === void 0 ? true : _props$collapsable,
15
+ _props$expandAll = props.expandAll,
16
+ expandAll = _props$expandAll === void 0 ? false : _props$expandAll,
17
+ labelWidth = props.labelWidth,
18
+ labelClassName = props.labelClassName,
19
+ otherProps = _objectWithoutProperties(props, _excluded);
20
+ var _useContext = useContext(ConfigContext),
21
+ getPrefixCls = _useContext.getPrefixCls;
22
+ var prefixCls = getPrefixCls('org-tree');
23
+ var orgTreeRef = useRef(null);
24
+
25
+ // 暴露组件方法
26
+ useImperativeHandle(ref, function () {
27
+ return {
28
+ // 获取组织树实例
29
+ getOrgTreeInstance: function getOrgTreeInstance() {
30
+ return orgTreeRef.current;
31
+ }
32
+ };
33
+ });
34
+
35
+ // 处理样式相关属性
36
+ var treeStyle = {};
37
+ if (labelWidth) {
38
+ treeStyle['--org-tree-label-width'] = typeof labelWidth === 'number' ? "".concat(labelWidth, "px") : labelWidth;
39
+ }
40
+ return /*#__PURE__*/_jsx("div", {
41
+ className: "".concat(prefixCls, " ").concat(className || ''),
42
+ style: style,
43
+ children: /*#__PURE__*/_jsx("div", {
44
+ className: "".concat(prefixCls, "-container"),
45
+ children: /*#__PURE__*/_jsx(OrgTreeComponent, _objectSpread({
46
+ ref: orgTreeRef,
47
+ data: data,
48
+ collapsable: collapsable,
49
+ expandAll: expandAll,
50
+ labelWidth: labelWidth,
51
+ labelClassName: labelClassName,
52
+ style: treeStyle
53
+ }, otherProps))
54
+ })
55
+ });
56
+ });
57
+ OrgTree.displayName = 'OrgTree';
58
+ export default OrgTree;
@@ -0,0 +1,15 @@
1
+ @import '../commonStyle/index.less';
2
+
3
+ .@{prefix}-org-tree {
4
+ width: 100%;
5
+ height: 100%;
6
+ overflow: auto;
7
+ position: relative;
8
+ display: flex;
9
+ align-items: center;
10
+ justify-content: center;
11
+
12
+ .org-tree-node-label {
13
+ cursor: pointer;
14
+ }
15
+ }