@tiny-design/react 1.1.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/drawer/drawer.js +3 -2
- package/es/drawer/drawer.js.map +1 -1
- package/es/index.d.ts +2 -1
- package/es/index.js +2 -1
- package/es/message/message.js +3 -2
- package/es/message/message.js.map +1 -1
- package/es/modal/modal.js +3 -2
- package/es/modal/modal.js.map +1 -1
- package/es/overlay/overlay.js +2 -2
- package/es/overlay/overlay.js.map +1 -1
- package/es/transition/index.js +1 -0
- package/es/transition/index.js.map +1 -1
- package/es/transition/transition.d.ts +20 -5
- package/es/transition/transition.js +33 -8
- package/es/transition/transition.js.map +1 -1
- package/es/transition/use-transition.js +137 -0
- package/es/transition/use-transition.js.map +1 -0
- package/es/waterfall/hooks/use-breakpoint.js +47 -0
- package/es/waterfall/hooks/use-breakpoint.js.map +1 -0
- package/es/waterfall/hooks/use-positions.js +28 -0
- package/es/waterfall/hooks/use-positions.js.map +1 -0
- package/es/waterfall/index.d.ts +2 -0
- package/es/waterfall/index.js +9 -0
- package/es/waterfall/index.js.map +1 -0
- package/es/waterfall/style/_index.scss +22 -0
- package/es/waterfall/style/index.css +16 -0
- package/es/waterfall/style/index.d.ts +1 -0
- package/es/waterfall/style/index.js +1 -0
- package/es/waterfall/types.d.ts +35 -0
- package/es/waterfall/waterfall.d.ts +8 -0
- package/es/waterfall/waterfall.js +151 -0
- package/es/waterfall/waterfall.js.map +1 -0
- package/lib/drawer/drawer.js +5 -4
- package/lib/drawer/drawer.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -0
- package/lib/message/message.js +3 -2
- package/lib/message/message.js.map +1 -1
- package/lib/modal/modal.js +5 -4
- package/lib/modal/modal.js.map +1 -1
- package/lib/overlay/overlay.js +3 -3
- package/lib/overlay/overlay.js.map +1 -1
- package/lib/transition/index.js +1 -0
- package/lib/transition/index.js.map +1 -1
- package/lib/transition/transition.d.ts +20 -5
- package/lib/transition/transition.js +32 -7
- package/lib/transition/transition.js.map +1 -1
- package/lib/transition/use-transition.js +138 -0
- package/lib/transition/use-transition.js.map +1 -0
- package/lib/waterfall/hooks/use-breakpoint.js +49 -0
- package/lib/waterfall/hooks/use-breakpoint.js.map +1 -0
- package/lib/waterfall/hooks/use-positions.js +29 -0
- package/lib/waterfall/hooks/use-positions.js.map +1 -0
- package/lib/waterfall/index.js +8 -0
- package/lib/waterfall/index.js.map +1 -0
- package/lib/waterfall/style/_index.scss +22 -0
- package/lib/waterfall/style/index.css +16 -0
- package/lib/waterfall/style/index.d.ts +1 -0
- package/lib/waterfall/style/index.js +1 -0
- package/lib/waterfall/types.d.ts +35 -0
- package/lib/waterfall/waterfall.d.ts +8 -0
- package/lib/waterfall/waterfall.js +154 -0
- package/lib/waterfall/waterfall.js.map +1 -0
- package/package.json +3 -5
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
//#region src/waterfall/hooks/use-positions.ts
|
|
3
|
+
function usePositions(itemHeights, columnCount, verticalGutter) {
|
|
4
|
+
return useMemo(() => {
|
|
5
|
+
const columnHeights = new Array(columnCount).fill(0);
|
|
6
|
+
const positions = /* @__PURE__ */ new Map();
|
|
7
|
+
for (let i = 0; i < itemHeights.length; i += 1) {
|
|
8
|
+
const [itemKey, itemHeight, itemColumn] = itemHeights[i];
|
|
9
|
+
let targetColumn = itemColumn ?? columnHeights.indexOf(Math.min(...columnHeights));
|
|
10
|
+
targetColumn = Math.min(targetColumn, columnCount - 1);
|
|
11
|
+
const top = columnHeights[targetColumn];
|
|
12
|
+
positions.set(itemKey, {
|
|
13
|
+
column: targetColumn,
|
|
14
|
+
top
|
|
15
|
+
});
|
|
16
|
+
columnHeights[targetColumn] += itemHeight + verticalGutter;
|
|
17
|
+
}
|
|
18
|
+
return [positions, Math.max(0, Math.max(...columnHeights) - verticalGutter)];
|
|
19
|
+
}, [
|
|
20
|
+
columnCount,
|
|
21
|
+
itemHeights,
|
|
22
|
+
verticalGutter
|
|
23
|
+
]);
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { usePositions as default };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=use-positions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-positions.js","names":[],"sources":["../../../src/waterfall/hooks/use-positions.ts"],"sourcesContent":["import { useMemo } from 'react';\n\nexport type ItemHeightData = [key: React.Key, height: number, column?: number];\n\nexport type ItemPositions = Map<\n React.Key,\n {\n column: number;\n top: number;\n }\n>;\n\nexport default function usePositions(\n itemHeights: ItemHeightData[],\n columnCount: number,\n verticalGutter: number,\n): [ItemPositions, number] {\n return useMemo(() => {\n const columnHeights = new Array(columnCount).fill(0) as number[];\n const positions: ItemPositions = new Map();\n\n for (let i = 0; i < itemHeights.length; i += 1) {\n const [itemKey, itemHeight, itemColumn] = itemHeights[i];\n\n let targetColumn = itemColumn ?? columnHeights.indexOf(Math.min(...columnHeights));\n targetColumn = Math.min(targetColumn, columnCount - 1);\n\n const top = columnHeights[targetColumn];\n positions.set(itemKey, { column: targetColumn, top });\n\n columnHeights[targetColumn] += itemHeight + verticalGutter;\n }\n\n const totalHeight = Math.max(0, Math.max(...columnHeights) - verticalGutter);\n return [positions, totalHeight];\n }, [columnCount, itemHeights, verticalGutter]);\n}\n"],"mappings":";;AAYA,SAAwB,aACtB,aACA,aACA,gBACyB;AACzB,QAAO,cAAc;EACnB,MAAM,gBAAgB,IAAI,MAAM,YAAY,CAAC,KAAK,EAAE;EACpD,MAAM,4BAA2B,IAAI,KAAK;AAE1C,OAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK,GAAG;GAC9C,MAAM,CAAC,SAAS,YAAY,cAAc,YAAY;GAEtD,IAAI,eAAe,cAAc,cAAc,QAAQ,KAAK,IAAI,GAAG,cAAc,CAAC;AAClF,kBAAe,KAAK,IAAI,cAAc,cAAc,EAAE;GAEtD,MAAM,MAAM,cAAc;AAC1B,aAAU,IAAI,SAAS;IAAE,QAAQ;IAAc;IAAK,CAAC;AAErD,iBAAc,iBAAiB,aAAa;;AAI9C,SAAO,CAAC,WADY,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,cAAc,GAAG,eAAe,CAC7C;IAC9B;EAAC;EAAa;EAAa;EAAe,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import '../style/base.css';
|
|
2
|
+
import './style/index.css';
|
|
3
|
+
import Waterfall from "./waterfall.js";
|
|
4
|
+
//#region src/waterfall/index.tsx
|
|
5
|
+
var waterfall_default = Waterfall;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { waterfall_default as default };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/waterfall/index.tsx"],"sourcesContent":["import Waterfall from './waterfall';\n\nexport type { WaterfallProps, WaterfallItem, Breakpoint } from './types';\n\nexport default Waterfall;\n"],"mappings":";;AAIA,IAAA,oBAAe"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
@use '../../style/variables' as *;
|
|
2
|
+
|
|
3
|
+
.#{$prefix}-waterfall {
|
|
4
|
+
position: relative;
|
|
5
|
+
width: 100%;
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
|
|
8
|
+
&__item {
|
|
9
|
+
position: absolute;
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Exit animation
|
|
14
|
+
&__item-fade-exit {
|
|
15
|
+
opacity: 1;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&__item-fade-exit-active {
|
|
19
|
+
opacity: 0;
|
|
20
|
+
transition: opacity 0.3s ease;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.ty-waterfall {
|
|
2
|
+
position: relative;
|
|
3
|
+
width: 100%;
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
}
|
|
6
|
+
.ty-waterfall__item {
|
|
7
|
+
position: absolute;
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
}
|
|
10
|
+
.ty-waterfall__item-fade-exit {
|
|
11
|
+
opacity: 1;
|
|
12
|
+
}
|
|
13
|
+
.ty-waterfall__item-fade-exit-active {
|
|
14
|
+
opacity: 0;
|
|
15
|
+
transition: opacity 0.3s ease;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./_index.css";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BaseProps } from "../_utils/props.js";
|
|
2
|
+
import React, { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/waterfall/types.d.ts
|
|
5
|
+
type Breakpoint = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
|
|
6
|
+
interface WaterfallItem<T = any> {
|
|
7
|
+
key: React.Key;
|
|
8
|
+
/** Pin this item to a specific column index */
|
|
9
|
+
column?: number;
|
|
10
|
+
/** Direct content — takes priority over itemRender */
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
/** Custom data passed to itemRender */
|
|
13
|
+
data?: T;
|
|
14
|
+
}
|
|
15
|
+
interface WaterfallProps<T = any> extends BaseProps, Omit<React.PropsWithRef<JSX.IntrinsicElements['div']>, 'children'> {
|
|
16
|
+
/** Number of columns, or responsive breakpoint config. Default: 3 */
|
|
17
|
+
columns?: number | Partial<Record<Breakpoint, number>>;
|
|
18
|
+
/** Spacing between items: number or [horizontal, vertical] */
|
|
19
|
+
gutter?: number | [number, number];
|
|
20
|
+
/** Array of items to render */
|
|
21
|
+
items?: WaterfallItem<T>[];
|
|
22
|
+
/** Custom render function for each item */
|
|
23
|
+
itemRender?: (item: WaterfallItem<T> & {
|
|
24
|
+
index: number;
|
|
25
|
+
column: number;
|
|
26
|
+
}) => ReactNode;
|
|
27
|
+
/** Callback when layout order changes */
|
|
28
|
+
onLayoutChange?: (sortInfo: {
|
|
29
|
+
key: React.Key;
|
|
30
|
+
column: number;
|
|
31
|
+
}[]) => void;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { Breakpoint, WaterfallItem, WaterfallProps };
|
|
35
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { WaterfallProps } from "./types.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/waterfall/waterfall.d.ts
|
|
5
|
+
declare const Waterfall: React.ForwardRefExoticComponent<Omit<WaterfallProps<any>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { Waterfall };
|
|
8
|
+
//# sourceMappingURL=waterfall.d.ts.map
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { ConfigContext } from "../config-provider/config-context.js";
|
|
2
|
+
import { getPrefixCls } from "../_utils/general.js";
|
|
3
|
+
import transition_default from "../transition/index.js";
|
|
4
|
+
import useBreakpoint, { responsiveArray } from "./hooks/use-breakpoint.js";
|
|
5
|
+
import usePositions from "./hooks/use-positions.js";
|
|
6
|
+
import React, { useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
7
|
+
import classNames from "classnames";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
//#region src/waterfall/waterfall.tsx
|
|
10
|
+
const Waterfall = React.forwardRef((props, ref) => {
|
|
11
|
+
const { prefixCls: customisedCls, className, style, columns = 3, gutter = 0, items, itemRender, onLayoutChange, ...otherProps } = props;
|
|
12
|
+
const prefixCls = getPrefixCls("waterfall", useContext(ConfigContext).prefixCls, customisedCls);
|
|
13
|
+
const screens = useBreakpoint();
|
|
14
|
+
const columnCount = React.useMemo(() => {
|
|
15
|
+
if (typeof columns === "number") return columns;
|
|
16
|
+
const matchingBreakpoint = responsiveArray.find((bp) => screens[bp] && columns[bp] !== void 0);
|
|
17
|
+
if (matchingBreakpoint) return columns[matchingBreakpoint];
|
|
18
|
+
return columns.xs ?? 1;
|
|
19
|
+
}, [columns, screens]);
|
|
20
|
+
const [horizontalGutter, verticalGutter] = Array.isArray(gutter) ? gutter : [gutter, gutter];
|
|
21
|
+
const itemRefsMap = useRef(/* @__PURE__ */ new Map());
|
|
22
|
+
const setItemRef = useCallback((key, el) => {
|
|
23
|
+
itemRefsMap.current.set(key, el);
|
|
24
|
+
}, []);
|
|
25
|
+
const [itemHeights, setItemHeights] = useState([]);
|
|
26
|
+
const collectItemSizes = useCallback(() => {
|
|
27
|
+
if (!items || items.length === 0) {
|
|
28
|
+
setItemHeights([]);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const nextHeights = items.map((item, index) => {
|
|
32
|
+
const key = item.key ?? index;
|
|
33
|
+
const el = itemRefsMap.current.get(key);
|
|
34
|
+
return [
|
|
35
|
+
key,
|
|
36
|
+
el ? el.getBoundingClientRect().height : 0,
|
|
37
|
+
item.column
|
|
38
|
+
];
|
|
39
|
+
});
|
|
40
|
+
setItemHeights((prev) => {
|
|
41
|
+
return prev.length === nextHeights.length && prev.every((p, i) => p[0] === nextHeights[i][0] && p[1] === nextHeights[i][1]) ? prev : nextHeights;
|
|
42
|
+
});
|
|
43
|
+
}, [items]);
|
|
44
|
+
const [itemPositions, totalHeight] = usePositions(itemHeights, columnCount, verticalGutter);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
collectItemSizes();
|
|
47
|
+
}, [
|
|
48
|
+
items,
|
|
49
|
+
columnCount,
|
|
50
|
+
collectItemSizes
|
|
51
|
+
]);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
54
|
+
const observer = new ResizeObserver(() => {
|
|
55
|
+
collectItemSizes();
|
|
56
|
+
});
|
|
57
|
+
for (const [, el] of itemRefsMap.current) if (el) observer.observe(el);
|
|
58
|
+
return () => observer.disconnect();
|
|
59
|
+
}, [items, collectItemSizes]);
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (!onLayoutChange || !items || items.length === 0) return;
|
|
62
|
+
if (!items.every((item) => itemPositions.has(item.key))) return;
|
|
63
|
+
onLayoutChange(items.map((item) => ({
|
|
64
|
+
key: item.key,
|
|
65
|
+
column: itemPositions.get(item.key).column
|
|
66
|
+
})));
|
|
67
|
+
}, [
|
|
68
|
+
itemPositions,
|
|
69
|
+
items,
|
|
70
|
+
onLayoutChange
|
|
71
|
+
]);
|
|
72
|
+
const prevItemsRef = useRef(items || []);
|
|
73
|
+
const [exitingItems, setExitingItems] = useState(/* @__PURE__ */ new Map());
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
const currentKeys = new Set((items || []).map((item, i) => item.key ?? i));
|
|
76
|
+
const removed = /* @__PURE__ */ new Map();
|
|
77
|
+
prevItemsRef.current.forEach((item, index) => {
|
|
78
|
+
const key = item.key ?? index;
|
|
79
|
+
if (!currentKeys.has(key)) removed.set(key, item);
|
|
80
|
+
});
|
|
81
|
+
if (removed.size > 0) setExitingItems((prev) => {
|
|
82
|
+
const next = new Map(prev);
|
|
83
|
+
removed.forEach((item, key) => next.set(key, item));
|
|
84
|
+
return next;
|
|
85
|
+
});
|
|
86
|
+
prevItemsRef.current = items || [];
|
|
87
|
+
}, [items]);
|
|
88
|
+
const handleExited = useCallback((key) => {
|
|
89
|
+
itemRefsMap.current.delete(key);
|
|
90
|
+
setExitingItems((prev) => {
|
|
91
|
+
const next = new Map(prev);
|
|
92
|
+
next.delete(key);
|
|
93
|
+
return next;
|
|
94
|
+
});
|
|
95
|
+
collectItemSizes();
|
|
96
|
+
}, [collectItemSizes]);
|
|
97
|
+
const cls = classNames(prefixCls, className);
|
|
98
|
+
const containerStyle = {
|
|
99
|
+
...style,
|
|
100
|
+
position: "relative",
|
|
101
|
+
height: totalHeight || void 0
|
|
102
|
+
};
|
|
103
|
+
const mergedItems = items || [];
|
|
104
|
+
const renderItem = (item, index, isExiting) => {
|
|
105
|
+
const key = item.key ?? index;
|
|
106
|
+
const position = itemPositions.get(key);
|
|
107
|
+
const hasPosition = !!position;
|
|
108
|
+
const columnIndex = position?.column ?? 0;
|
|
109
|
+
const itemStyle = {
|
|
110
|
+
position: "absolute",
|
|
111
|
+
width: `calc((100% - ${horizontalGutter * (columnCount - 1)}px) / ${columnCount})`,
|
|
112
|
+
left: `calc((100% - ${horizontalGutter * (columnCount - 1)}px) / ${columnCount} * ${columnIndex} + ${horizontalGutter * columnIndex}px)`,
|
|
113
|
+
top: position?.top ?? 0,
|
|
114
|
+
transition: hasPosition ? "top 0.3s ease, left 0.3s ease, opacity 0.3s ease" : "none",
|
|
115
|
+
opacity: hasPosition ? 1 : 0
|
|
116
|
+
};
|
|
117
|
+
const content = item.children ?? itemRender?.({
|
|
118
|
+
...item,
|
|
119
|
+
index,
|
|
120
|
+
column: columnIndex
|
|
121
|
+
});
|
|
122
|
+
return /* @__PURE__ */ jsx(transition_default, {
|
|
123
|
+
in: !isExiting,
|
|
124
|
+
timeout: 300,
|
|
125
|
+
appear: false,
|
|
126
|
+
unmountOnExit: true,
|
|
127
|
+
classNames: `${prefixCls}__item-fade`,
|
|
128
|
+
onExited: () => handleExited(key),
|
|
129
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
130
|
+
ref: (el) => setItemRef(key, el),
|
|
131
|
+
className: `${prefixCls}__item`,
|
|
132
|
+
style: itemStyle,
|
|
133
|
+
children: content
|
|
134
|
+
})
|
|
135
|
+
}, key);
|
|
136
|
+
};
|
|
137
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
138
|
+
ref,
|
|
139
|
+
...otherProps,
|
|
140
|
+
className: cls,
|
|
141
|
+
style: containerStyle,
|
|
142
|
+
onLoad: collectItemSizes,
|
|
143
|
+
onError: collectItemSizes,
|
|
144
|
+
children: [mergedItems.map((item, index) => renderItem(item, index, false)), Array.from(exitingItems.entries()).map(([key, item]) => renderItem(item, Number(key), true))]
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
Waterfall.displayName = "Waterfall";
|
|
148
|
+
//#endregion
|
|
149
|
+
export { Waterfall as default };
|
|
150
|
+
|
|
151
|
+
//# sourceMappingURL=waterfall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waterfall.js","names":["Transition"],"sources":["../../src/waterfall/waterfall.tsx"],"sourcesContent":["import React, { useCallback, useContext, useEffect, useRef, useState } from 'react';\nimport classNames from 'classnames';\nimport Transition from '../transition';\nimport { ConfigContext } from '../config-provider/config-context';\nimport { getPrefixCls } from '../_utils/general';\nimport { Breakpoint, WaterfallItem, WaterfallProps } from './types';\nimport useBreakpoint, { responsiveArray } from './hooks/use-breakpoint';\nimport usePositions, { ItemHeightData } from './hooks/use-positions';\n\nconst Waterfall = React.forwardRef<HTMLDivElement, WaterfallProps>((props, ref) => {\n const {\n prefixCls: customisedCls,\n className,\n style,\n columns = 3,\n gutter = 0,\n items,\n itemRender,\n onLayoutChange,\n ...otherProps\n } = props;\n\n const configContext = useContext(ConfigContext);\n const prefixCls = getPrefixCls('waterfall', configContext.prefixCls, customisedCls);\n\n // ===================== Breakpoint =====================\n const screens = useBreakpoint();\n\n const columnCount = React.useMemo<number>(() => {\n if (typeof columns === 'number') {\n return columns;\n }\n\n const matchingBreakpoint = responsiveArray.find(\n (bp: Breakpoint) => screens[bp] && columns[bp] !== undefined,\n );\n\n if (matchingBreakpoint) {\n return columns[matchingBreakpoint] as number;\n }\n\n return columns.xs ?? 1;\n }, [columns, screens]);\n\n // ====================== Gutter ======================\n const [horizontalGutter, verticalGutter] = Array.isArray(gutter)\n ? gutter\n : [gutter, gutter];\n\n // =================== Item Refs ===================\n const itemRefsMap = useRef<Map<React.Key, HTMLDivElement | null>>(new Map());\n\n const setItemRef = useCallback((key: React.Key, el: HTMLDivElement | null) => {\n itemRefsMap.current.set(key, el);\n }, []);\n\n // ================= Item Heights ==================\n const [itemHeights, setItemHeights] = useState<ItemHeightData[]>([]);\n\n const collectItemSizes = useCallback(() => {\n if (!items || items.length === 0) {\n setItemHeights([]);\n return;\n }\n\n const nextHeights = items.map<ItemHeightData>((item, index) => {\n const key = item.key ?? index;\n const el = itemRefsMap.current.get(key);\n const height = el ? el.getBoundingClientRect().height : 0;\n return [key, height, item.column];\n });\n\n setItemHeights((prev) => {\n const isSame =\n prev.length === nextHeights.length &&\n prev.every((p, i) => p[0] === nextHeights[i][0] && p[1] === nextHeights[i][1]);\n return isSame ? prev : nextHeights;\n });\n }, [items]);\n\n // ================= Positions ==================\n const [itemPositions, totalHeight] = usePositions(itemHeights, columnCount, verticalGutter);\n\n // Collect sizes on items/columns change\n useEffect(() => {\n collectItemSizes();\n }, [items, columnCount, collectItemSizes]);\n\n // ResizeObserver for dynamic content\n useEffect(() => {\n if (typeof ResizeObserver === 'undefined') return;\n\n const observer = new ResizeObserver(() => {\n collectItemSizes();\n });\n\n for (const [, el] of itemRefsMap.current) {\n if (el) observer.observe(el);\n }\n\n return () => observer.disconnect();\n }, [items, collectItemSizes]);\n\n // ================ onLayoutChange ================\n useEffect(() => {\n if (!onLayoutChange || !items || items.length === 0) return;\n\n const allPositioned = items.every((item) => itemPositions.has(item.key));\n if (!allPositioned) return;\n\n const sortInfo = items.map((item) => ({\n key: item.key,\n column: itemPositions.get(item.key)!.column,\n }));\n onLayoutChange(sortInfo);\n }, [itemPositions, items, onLayoutChange]);\n\n // ============== Exiting items (replaces TransitionGroup) ==============\n const prevItemsRef = useRef<WaterfallItem[]>(items || []);\n const [exitingItems, setExitingItems] = useState<Map<React.Key, WaterfallItem>>(new Map());\n\n useEffect(() => {\n const currentKeys = new Set((items || []).map((item, i) => item.key ?? i));\n const removed = new Map<React.Key, WaterfallItem>();\n\n prevItemsRef.current.forEach((item, index) => {\n const key = item.key ?? index;\n if (!currentKeys.has(key)) {\n removed.set(key, item);\n }\n });\n\n if (removed.size > 0) {\n setExitingItems((prev) => {\n const next = new Map(prev);\n removed.forEach((item, key) => next.set(key, item));\n return next;\n });\n }\n\n prevItemsRef.current = items || [];\n }, [items]);\n\n const handleExited = useCallback((key: React.Key) => {\n itemRefsMap.current.delete(key);\n setExitingItems((prev) => {\n const next = new Map(prev);\n next.delete(key);\n return next;\n });\n collectItemSizes();\n }, [collectItemSizes]);\n\n // ==================== Render ====================\n const cls = classNames(prefixCls, className);\n\n const containerStyle: React.CSSProperties = {\n ...style,\n position: 'relative',\n height: totalHeight || undefined,\n };\n\n const mergedItems = items || [];\n\n const renderItem = (item: WaterfallItem, index: number, isExiting: boolean) => {\n const key = item.key ?? index;\n const position = itemPositions.get(key);\n const hasPosition = !!position;\n const columnIndex = position?.column ?? 0;\n\n const itemStyle: React.CSSProperties = {\n position: 'absolute',\n width: `calc((100% - ${horizontalGutter * (columnCount - 1)}px) / ${columnCount})`,\n left: `calc((100% - ${horizontalGutter * (columnCount - 1)}px) / ${columnCount} * ${columnIndex} + ${horizontalGutter * columnIndex}px)`,\n top: position?.top ?? 0,\n // Only transition position changes after initial placement\n transition: hasPosition ? 'top 0.3s ease, left 0.3s ease, opacity 0.3s ease' : 'none',\n // Hide until position is computed so items don't flash at (0,0)\n opacity: hasPosition ? 1 : 0,\n };\n\n const content = item.children ?? itemRender?.({ ...item, index, column: columnIndex });\n\n return (\n <Transition\n key={key}\n in={!isExiting}\n timeout={300}\n appear={false}\n unmountOnExit={true}\n classNames={`${prefixCls}__item-fade`}\n onExited={() => handleExited(key)}\n >\n <div\n ref={(el) => setItemRef(key, el)}\n className={`${prefixCls}__item`}\n style={itemStyle}\n >\n {content}\n </div>\n </Transition>\n );\n };\n\n return (\n <div\n ref={ref}\n {...otherProps}\n className={cls}\n style={containerStyle}\n onLoad={collectItemSizes}\n onError={collectItemSizes}\n >\n {mergedItems.map((item, index) => renderItem(item, index, false))}\n {Array.from(exitingItems.entries()).map(([key, item]) =>\n renderItem(item, Number(key), true)\n )}\n </div>\n );\n});\n\nWaterfall.displayName = 'Waterfall';\n\nexport default Waterf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,KAAK,MAAM,UAAU,WAAW,MAAM,OAAO,MAAM,CAAC,EAChE,MAAM,KAAK,aAAa,SAAS,CAAC,CAAC,KAAK,CAAC,KAAK,UAC7C,WAAW,MAAM,OAAO,IAAI,EAAE,KAAK,CACpC,CACG;;EAER;AAEF,UAAU,cAAc"}
|
package/lib/drawer/drawer.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const require_runtime = require("../_virtual/_rolldown/runtime.js");
|
|
2
2
|
const require_config_context = require("../config-provider/config-context.js");
|
|
3
3
|
const require_general = require("../_utils/general.js");
|
|
4
|
-
const require_index = require("../
|
|
4
|
+
const require_index = require("../transition/index.js");
|
|
5
|
+
const require_index$1 = require("../overlay/index.js");
|
|
5
6
|
let react = require("react");
|
|
6
7
|
react = require_runtime.__toESM(react);
|
|
7
8
|
let classnames = require("classnames");
|
|
8
9
|
classnames = require_runtime.__toESM(classnames);
|
|
9
10
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
-
let react_transition_group = require("react-transition-group");
|
|
11
11
|
//#region src/drawer/drawer.tsx
|
|
12
12
|
const Drawer = react.default.forwardRef((props, ref) => {
|
|
13
13
|
const { visible, placement = "right", size = 256, closable = true, unmountOnClose = true, maskType = "default", maskClosable = true, onClose, prefixCls: customisedCls, afterClose, zIndex = 1e3, header, footer, className, maskStyle, style, children } = props;
|
|
@@ -54,7 +54,7 @@ const Drawer = react.default.forwardRef((props, ref) => {
|
|
|
54
54
|
previousFocusRef.current?.focus();
|
|
55
55
|
};
|
|
56
56
|
}, [visible, onClose]);
|
|
57
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.default, {
|
|
57
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index$1.default, {
|
|
58
58
|
onEnter: () => setDrawerVisible(true),
|
|
59
59
|
onExit: () => setDrawerVisible(false),
|
|
60
60
|
zIndex,
|
|
@@ -73,11 +73,12 @@ const Drawer = react.default.forwardRef((props, ref) => {
|
|
|
73
73
|
...style,
|
|
74
74
|
...sty
|
|
75
75
|
},
|
|
76
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
76
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.default, {
|
|
77
77
|
appear: true,
|
|
78
78
|
nodeRef,
|
|
79
79
|
in: drawerVisible,
|
|
80
80
|
timeout: 0,
|
|
81
|
+
unmountOnExit: false,
|
|
81
82
|
classNames: `${prefixCls}__content_move`,
|
|
82
83
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
83
84
|
ref: nodeRef,
|
package/lib/drawer/drawer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drawer.js","names":["React","getPrefixCls","ConfigContext","Overlay","
|
|
1
|
+
{"version":3,"file":"drawer.js","names":["React","getPrefixCls","ConfigContext","Overlay","Transition"],"sources":["../../src/drawer/drawer.tsx"],"sourcesContent":["import React, { useContext, useEffect, useId, useRef, useState } from 'react';\nimport classNames from 'classnames';\nimport Transition from '../transition';\nimport Overlay from '../overlay';\nimport { ConfigContext } from '../config-provider/config-context';\nimport { getPrefixCls } from '../_utils/general';\nimport { DrawerProps } from './types';\n\nconst Drawer = React.forwardRef<HTMLDivElement, DrawerProps>((props, ref) => {\n const {\n visible,\n placement = 'right',\n size = 256,\n closable = true,\n unmountOnClose = true,\n maskType = 'default',\n maskClosable = true,\n onClose,\n prefixCls: customisedCls,\n afterClose,\n zIndex = 1000,\n header,\n footer,\n className,\n maskStyle,\n style,\n children,\n } = props;\n const [drawerVisible, setDrawerVisible] = useState(visible);\n const configContext = useContext(ConfigContext);\n const prefixCls = getPrefixCls('drawer', configContext.prefixCls, customisedCls);\n const cls = classNames(prefixCls, className, `${prefixCls}_${placement}`);\n const sty: React.CSSProperties =\n placement === 'top' || placement === 'bottom' ? { height: size } : { width: size };\n const nodeRef = useRef<HTMLDivElement>(null);\n const previousFocusRef = useRef<HTMLElement | null>(null);\n const titleId = useId();\n\n // Focus trap + Escape key\n useEffect(() => {\n if (!visible) return;\n previousFocusRef.current = document.activeElement as HTMLElement;\n\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n onClose?.(e as unknown as React.MouseEvent);\n return;\n }\n if (e.key === 'Tab' && nodeRef.current) {\n const focusable = nodeRef.current.querySelectorAll<HTMLElement>(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])'\n );\n if (focusable.length === 0) return;\n const first = focusable[0];\n const last = focusable[focusable.length - 1];\n if (e.shiftKey) {\n if (document.activeElement === first) { e.preventDefault(); last.focus(); }\n } else {\n if (document.activeElement === last) { e.preventDefault(); first.focus(); }\n }\n }\n };\n document.addEventListener('keydown', handleKeyDown);\n\n requestAnimationFrame(() => {\n if (nodeRef.current) {\n const focusable = nodeRef.current.querySelectorAll<HTMLElement>(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])'\n );\n if (focusable.length > 0) focusable[0].focus();\n }\n });\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n previousFocusRef.current?.focus();\n };\n }, [visible, onClose]);\n\n return (\n <Overlay\n onEnter={(): void => setDrawerVisible(true)}\n onExit={(): void => setDrawerVisible(false)}\n zIndex={zIndex}\n type={maskType}\n unmountOnExit={unmountOnClose}\n isShow={visible}\n onExited={afterClose}\n clickCallback={(e: React.MouseEvent): void => {\n maskClosable && onClose ? onClose(e) : undefined;\n }}\n style={maskStyle}>\n <div ref={ref} className={cls} style={{ ...style, ...sty }}>\n <Transition\n appear={true}\n nodeRef={nodeRef}\n in={drawerVisible}\n timeout={0}\n unmountOnExit={false}\n classNames={`${prefixCls}__content_move`}>\n <div\n ref={nodeRef}\n className={`${prefixCls}__content`}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={header ? titleId : undefined}\n onClick={(e) => e.stopPropagation()}>\n {closable && (\n <button type=\"button\" className={`${prefixCls}__close-btn`} onClick={onClose} aria-label=\"Close\">\n ✕\n </button>\n )}\n {header && <div className={`${prefixCls}__header`} id={titleId}>{header}</div>}\n <div className={`${prefixCls}__body`}>{children}</div>\n {footer && <div className={`${prefixCls}__footer`}>{footer}</div>}\n </div>\n </Transition>\n </div>\n </Overlay>\n );\n});\n\nDrawer.displayName = 'Drawer';\n\nexport default Drawer;\n"],"mappings":";;;;;;;;;;;AAQA,MAAM,SAASA,MAAAA,QAAM,YAAyC,OAAO,QAAQ;CAC3E,MAAM,EACJ,SACA,YAAY,SACZ,OAAO,KACP,WAAW,MACX,iBAAiB,MACjB,WAAW,WACX,eAAe,MACf,SACA,WAAW,eACX,YACA,SAAS,KACT,QACA,QACA,WACA,WACA,OACA,aACE;CACJ,MAAM,CAAC,eAAe,qBAAA,GAAA,MAAA,UAA6B,QAAQ;CAE3D,MAAM,YAAYC,gBAAAA,aAAa,WAAA,GAAA,MAAA,YADEC,uBAAAA,cAAc,CACQ,WAAW,cAAc;CAChF,MAAM,OAAA,GAAA,WAAA,SAAiB,WAAW,WAAW,GAAG,UAAU,GAAG,YAAY;CACzE,MAAM,MACJ,cAAc,SAAS,cAAc,WAAW,EAAE,QAAQ,MAAM,GAAG,EAAE,OAAO,MAAM;CACpF,MAAM,WAAA,GAAA,MAAA,QAAiC,KAAK;CAC5C,MAAM,oBAAA,GAAA,MAAA,QAA8C,KAAK;CACzD,MAAM,WAAA,GAAA,MAAA,QAAiB;AAGvB,EAAA,GAAA,MAAA,iBAAgB;AACd,MAAI,CAAC,QAAS;AACd,mBAAiB,UAAU,SAAS;EAEpC,MAAM,iBAAiB,MAAqB;AAC1C,OAAI,EAAE,QAAQ,UAAU;AACtB,cAAU,EAAiC;AAC3C;;AAEF,OAAI,EAAE,QAAQ,SAAS,QAAQ,SAAS;IACtC,MAAM,YAAY,QAAQ,QAAQ,iBAChC,6EACD;AACD,QAAI,UAAU,WAAW,EAAG;IAC5B,MAAM,QAAQ,UAAU;IACxB,MAAM,OAAO,UAAU,UAAU,SAAS;AAC1C,QAAI,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AI;iBAAU;OAAa,CAAA;MAC9E,iBAAA,GAAA,kBAAA,KAAC,OAAD;OAAK,WAAW,GAAG,UAAU;OAAU;OAAe,CAAA;MACrD,UAAU,iBAAA,GAAA,kBAAA,KAAC,OAAD;OAAK,WAAW,GAAG,UAAU;iBAAY;OAAa,CAAA;MAC7D;;IACK,CAAA;GACT,CAAA;EACE,CAAA;EAEZ;AAEF,OAAO,cAAc"}
|
package/lib/index.d.ts
CHANGED
|
@@ -80,10 +80,11 @@ import { Transition } from "./transition/transition.js";
|
|
|
80
80
|
import { Tree } from "./tree/tree.js";
|
|
81
81
|
import { DefaultTypo } from "./typography/index.js";
|
|
82
82
|
import { Upload } from "./upload/upload.js";
|
|
83
|
+
import { Waterfall } from "./waterfall/waterfall.js";
|
|
83
84
|
import { withLocale } from "./intl-provider/with-locale.js";
|
|
84
85
|
import { withSpin } from "./with-spin/with-spin.js";
|
|
85
86
|
import { en_US } from "./locale/en_US.js";
|
|
86
87
|
import { zh_CN } from "./locale/zh_CN.js";
|
|
87
88
|
import { useLocale } from "./_utils/use-locale.js";
|
|
88
89
|
import { ThemeMode, useTheme } from "./_utils/use-theme.js";
|
|
89
|
-
export { Alert, DefaultAnchor as Anchor, AspectRatio, AutoComplete, DefaultAvatar as Avatar, BackTop, Badge, DefaultBreadcrumb as Breadcrumb, DefaultButton as Button, Calendar, DefaultCard as Card, DefaultCarousel as Carousel, Cascader, DefaultCheckbox as Checkbox, Col, DefaultCollapse as Collapse, ColorPicker, ConfigProvider, CopyToClipboard, Countdown, DatePicker, DefaultDesc as Descriptions, Divider, Drawer, Dropdown, Empty, Flex, DefaultFlip as Flip, DefaultForm as Form, Image, DefaultInput as Input, InputNumber, InputOTP, InputPassword, IntlProvider, Keyboard, DefaultLayout as Layout, Link, DefaultList as List, Loader, _default as LoadingBar, type Locale, DefaultMenu as Menu, messageContainer as Message, ModalWithContext as Modal, DefaultSelect as NativeSelect, notificationContainer as Notification, Overlay, Pagination, PopConfirm, Popover, Progress, DefaultRadio as Radio, Rate, Result, Row, ScrollIndicator, Segmented, DefaultSelect$1 as Select, Skeleton, Slider, Space, DefaultSpeedDial as SpeedDial, Split, SplitButton, Statistic, DefaultSteps as Steps, Sticky, StrengthIndicator, Switch, Table, DefaultTabs as Tabs, DefaultTag as Tag, Textarea, type ThemeMode, TimePicker, DefaultTimeline as Timeline, Tooltip, Transfer, Transition, Tree, DefaultTypo as Typography, Upload, en_US, useLocale, useTheme, withLocale, withSpin, zh_CN };
|
|
90
|
+
export { Alert, DefaultAnchor as Anchor, AspectRatio, AutoComplete, DefaultAvatar as Avatar, BackTop, Badge, DefaultBreadcrumb as Breadcrumb, DefaultButton as Button, Calendar, DefaultCard as Card, DefaultCarousel as Carousel, Cascader, DefaultCheckbox as Checkbox, Col, DefaultCollapse as Collapse, ColorPicker, ConfigProvider, CopyToClipboard, Countdown, DatePicker, DefaultDesc as Descriptions, Divider, Drawer, Dropdown, Empty, Flex, DefaultFlip as Flip, DefaultForm as Form, Image, DefaultInput as Input, InputNumber, InputOTP, InputPassword, IntlProvider, Keyboard, DefaultLayout as Layout, Link, DefaultList as List, Loader, _default as LoadingBar, type Locale, DefaultMenu as Menu, messageContainer as Message, ModalWithContext as Modal, DefaultSelect as NativeSelect, notificationContainer as Notification, Overlay, Pagination, PopConfirm, Popover, Progress, DefaultRadio as Radio, Rate, Result, Row, ScrollIndicator, Segmented, DefaultSelect$1 as Select, Skeleton, Slider, Space, DefaultSpeedDial as SpeedDial, Split, SplitButton, Statistic, DefaultSteps as Steps, Sticky, StrengthIndicator, Switch, Table, DefaultTabs as Tabs, DefaultTag as Tag, Textarea, type ThemeMode, TimePicker, DefaultTimeline as Timeline, Tooltip, Transfer, Transition, Tree, DefaultTypo as Typography, Upload, Waterfall, en_US, useLocale, useTheme, withLocale, withSpin, zh_CN };
|
package/lib/index.js
CHANGED
|
@@ -83,6 +83,7 @@ const require_index$77 = require("./transfer/index.js");
|
|
|
83
83
|
const require_index$78 = require("./tree/index.js");
|
|
84
84
|
const require_index$79 = require("./typography/index.js");
|
|
85
85
|
const require_index$80 = require("./upload/index.js");
|
|
86
|
+
const require_index$81 = require("./waterfall/index.js");
|
|
86
87
|
const require_with_locale = require("./intl-provider/with-locale.js");
|
|
87
88
|
const require_with_spin = require("./with-spin/with-spin.js");
|
|
88
89
|
const require_zh_CN = require("./locale/zh_CN.js");
|
|
@@ -168,6 +169,7 @@ exports.Transition = require_index;
|
|
|
168
169
|
exports.Tree = require_index$78;
|
|
169
170
|
exports.Typography = require_index$79;
|
|
170
171
|
exports.Upload = require_index$80;
|
|
172
|
+
exports.Waterfall = require_index$81;
|
|
171
173
|
exports.en_US = require_en_US;
|
|
172
174
|
exports.useLocale = require_use_locale.useLocale;
|
|
173
175
|
exports.useTheme = require_use_theme.useTheme;
|
package/lib/message/message.js
CHANGED
|
@@ -2,12 +2,12 @@ const require_runtime = require("../_virtual/_rolldown/runtime.js");
|
|
|
2
2
|
const require_config_context = require("../config-provider/config-context.js");
|
|
3
3
|
const require_general = require("../_utils/general.js");
|
|
4
4
|
const require_components = require("../_utils/components.js");
|
|
5
|
+
const require_index = require("../transition/index.js");
|
|
5
6
|
let react = require("react");
|
|
6
7
|
react = require_runtime.__toESM(react);
|
|
7
8
|
let classnames = require("classnames");
|
|
8
9
|
classnames = require_runtime.__toESM(classnames);
|
|
9
10
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
-
let react_transition_group = require("react-transition-group");
|
|
11
11
|
//#region src/message/message.tsx
|
|
12
12
|
const Message = (props) => {
|
|
13
13
|
const { type, icon, content, duration, willUnmount, extra, className, style, prefixCls: customisedCls } = props;
|
|
@@ -52,11 +52,12 @@ const Message = (props) => {
|
|
|
52
52
|
window.clearTimeout(timer);
|
|
53
53
|
};
|
|
54
54
|
}, [duration, willUnmount]);
|
|
55
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
55
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.default, {
|
|
56
56
|
nodeRef: ref,
|
|
57
57
|
in: visible,
|
|
58
58
|
appear: true,
|
|
59
59
|
timeout: 0,
|
|
60
|
+
unmountOnExit: false,
|
|
60
61
|
classNames: `${prefixCls}_fade-slide`,
|
|
61
62
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
62
63
|
role: "alert",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","names":["getPrefixCls","ConfigContext","React","CheckCircle","InfoCircle","WarningCircle","CloseCircle","LoadingCircle","
|
|
1
|
+
{"version":3,"file":"message.js","names":["getPrefixCls","ConfigContext","React","CheckCircle","InfoCircle","WarningCircle","CloseCircle","LoadingCircle","Transition"],"sources":["../../src/message/message.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState, useContext } from 'react';\nimport classNames from 'classnames';\nimport Transition from '../transition';\nimport { ConfigContext } from '../config-provider/config-context';\nimport { getPrefixCls } from '../_utils/general';\nimport {\n CheckCircle,\n CloseCircle,\n InfoCircle,\n LoadingCircle,\n WarningCircle,\n} from '../_utils/components';\nimport { MessageProps } from './types';\n\nconst Message = (props: MessageProps): JSX.Element => {\n const {\n type,\n icon,\n content,\n duration,\n willUnmount,\n extra,\n className,\n style,\n prefixCls: customisedCls,\n } = props;\n const configContext = useContext(ConfigContext);\n const prefixCls = getPrefixCls('message', configContext.prefixCls, customisedCls);\n const cls = classNames(prefixCls, className);\n const ref = useRef<HTMLDivElement | null>(null);\n const [visible, setVisible] = useState(true);\n\n const renderIcon = (): React.ReactNode => {\n if (React.isValidElement(icon)) {\n return icon;\n } else if (typeof type === 'string') {\n switch (type) {\n case 'success':\n return <CheckCircle size={16} className={`${prefixCls}__icon`} />;\n case 'info':\n return <InfoCircle size={16} className={`${prefixCls}__icon`} />;\n case 'warning':\n return <WarningCircle size={16} className={`${prefixCls}__icon`} />;\n case 'error':\n return <CloseCircle size={16} className={`${prefixCls}__icon`} />;\n case 'loading':\n return (\n <LoadingCircle\n size={16}\n className={classNames(`${prefixCls}__icon`, {\n [`${prefixCls}__icon_loading`]: type === 'loading',\n })}\n />\n );\n }\n }\n\n return null;\n };\n\n useEffect(() => {\n const node = ref.current;\n const height = (node && node.offsetHeight) || 0;\n const timer = window.setTimeout(() => {\n setVisible(false);\n willUnmount(height);\n }, duration);\n\n return (): void => {\n window.clearTimeout(timer);\n };\n }, [duration, willUnmount]);\n\n return (\n <Transition nodeRef={ref} in={visible} appear={true} timeout={0} unmountOnExit={false} classNames={`${prefixCls}_fade-slide`}>\n <div role=\"alert\" className={cls} style={style} ref={ref}>\n {renderIcon()}\n <span className={`${prefixCls}__content`}>{content}</span>\n {extra && <div className={`${prefixCls}__extra`}>{extra}</div>}\n </div>\n </Transition>\n );\n};\n\nMessage.displayName = 'Message';\n\nexport default Message;\n"],"mappings":";;;;;;;;;;;AAcA,MAAM,WAAW,UAAqC;CACpD,MAAM,EACJ,MACA,MACA,SACA,UACA,aACA,OACA,WACA,OACA,WAAW,kBACT;CAEJ,MAAM,YAAYA,gBAAAA,aAAa,YAAA,GAAA,MAAA,YADEC,uBAAAA,cAAc,CACS,WAAW,cAAc;CACjF,MAAM,OAAA,GAAA,WAAA,SAAiB,WAAW,UAAU;CAC5C,MAAM,OAAA,GAAA,MAAA,QAAoC,KAAK;CAC/C,MAAM,CAAC,SAAS,eAAA,GAAA,MAAA,UAAuB,KAAK;CAE5C,MAAM,mBAAoC;AACxC,MAAIC,MAAAA,QAAM,eAAe,KAAK,CAC5B,QAAO;WACE,OAAO,SAAS,SACzB,SAAQ,MAAR;GACE,KAAK,UACH,QAAO,iBAAA,GAAA,kBAAA,KAACC,mBAAAA,aAAD;IAAa,MAAM;IAAI,WAAW,GAAG,UAAU;IAAW,CAAA;GACnE,KAAK,OACH,QAAO,iBAAA,GAAA,kBAAA,KAACC,mBAAAA,YAAD;IAAY,MAAM;IAAI,WAAW,GAAG,UAAU;IAAW,CAAA;GAClE,KAAK,UACH,QAAO,iBAAA,GAAA,kBAAA,KAACC,mBAAAA,eAAD;IAAe,MAAM;IAAI,WAAW,GAAG,UAAU;IAAW,CAAA;GACrE,KAAK,QACH,QAAO,iBAAA,GAAA,kBAAA,KAACC,mBAAAA,aAAD;IAAa,MAAM;IAAI,WAAW,GAAG,UAAU;IAAW,CAAA;GACnE,KAAK,UACH,QACE,iBAAA,GAAA,kBAAA,KAACC,mBAAAA,eAAD;IACE,MAAM;IACN,YAAA,GAAA,WAAA,SAAsB,GAAG,UAAU,SAAS,GACzC,GAAG,UAAU,kBAAkB,SAAS,WAC1C,CAAC;IACF,CAAA;;AAKV,SAAO;;AAGT,EAAA,GAAA,MAAA,iBAAgB;EACd,MAAM,OAAO,IAAI;EACjB,MAAM,SAAU,QAAQ,KAAK,gBAAiB;EAC9C,MAAM,QAAQ,OAAO,iBAAiB;AACpC,cAAW,MAAM;AACjB,eAAY,OAAO;KAClB,SAAS;AAEZ,eAAmB;AACjB,UAAO,aAAa,MAAM;;IAE3B,CAAC,UAAU,YAAY,CAAC;AAE3B,QACE,iBAAA,GAAA,kBAAA,KAACC,cAAAA,SAAD;EAAY,SAAS;EAAK,IAAI;EAAS,QAAQ;EAAM,SAAS;EAAG,eAAe;EAAO,YAAY,GAAG,UAAU;YAC9G,iBAAA,GAAA,kBAAA,MAAC,OAAD;GAAK,MAAK;GAAQ,WAAW;GAAY;GAAY;aAArD;IACG,YAAY;IACb,iBAAA,GAAA,kBAAA,KAAC,QAAD;KAAM,WAAW,GAAG,UAAU;eAAa;KAAe,CAAA;IACzD,SAAS,iBAAA,GAAA,kBAAA,KAAC,OAAD;KAAK,WAAW,GAAG,UAAU;eAAW;KAAY,CAAA;IAC1D;;EACK,CAAA;;AAIjB,QAAQ,cAAc"}
|
package/lib/modal/modal.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
const require_runtime = require("../_virtual/_rolldown/runtime.js");
|
|
2
2
|
const require_config_context = require("../config-provider/config-context.js");
|
|
3
3
|
const require_general = require("../_utils/general.js");
|
|
4
|
+
const require_index = require("../transition/index.js");
|
|
4
5
|
const require_button = require("../button/button.js");
|
|
5
6
|
const require_use_locale = require("../_utils/use-locale.js");
|
|
6
|
-
const require_index = require("../overlay/index.js");
|
|
7
|
+
const require_index$1 = require("../overlay/index.js");
|
|
7
8
|
const require_flex = require("../flex/flex.js");
|
|
8
9
|
let react = require("react");
|
|
9
10
|
react = require_runtime.__toESM(react);
|
|
10
11
|
let classnames = require("classnames");
|
|
11
12
|
classnames = require_runtime.__toESM(classnames);
|
|
12
13
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
13
|
-
let react_transition_group = require("react-transition-group");
|
|
14
14
|
//#region src/modal/modal.tsx
|
|
15
15
|
const Modal = react.default.forwardRef((props, ref) => {
|
|
16
16
|
const locale = require_use_locale.useLocale();
|
|
@@ -81,7 +81,7 @@ const Modal = react.default.forwardRef((props, ref) => {
|
|
|
81
81
|
})]
|
|
82
82
|
});
|
|
83
83
|
};
|
|
84
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.default, {
|
|
84
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index$1.default, {
|
|
85
85
|
onEnter: () => setModalVisible(true),
|
|
86
86
|
onExit: () => setModalVisible(false),
|
|
87
87
|
zIndex,
|
|
@@ -102,11 +102,12 @@ const Modal = react.default.forwardRef((props, ref) => {
|
|
|
102
102
|
width,
|
|
103
103
|
...style
|
|
104
104
|
},
|
|
105
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
105
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.default, {
|
|
106
106
|
appear: true,
|
|
107
107
|
nodeRef,
|
|
108
108
|
in: modalVisible,
|
|
109
109
|
classNames: `${prefixCls}__content_${animation}`,
|
|
110
|
+
unmountOnExit: false,
|
|
110
111
|
timeout: 0,
|
|
111
112
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
112
113
|
ref: nodeRef,
|
package/lib/modal/modal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.js","names":["React","useLocale","getPrefixCls","ConfigContext","Flex","Button","Overlay","
|
|
1
|
+
{"version":3,"file":"modal.js","names":["React","useLocale","getPrefixCls","ConfigContext","Flex","Button","Overlay","Transition"],"sources":["../../src/modal/modal.tsx"],"sourcesContent":["import React, { useContext, useEffect, useId, useRef, useState } from 'react';\nimport classNames from 'classnames';\nimport Transition from '../transition';\nimport Overlay from '../overlay';\nimport Button from '../button/button';\nimport Flex from '../flex/flex';\nimport { ConfigContext } from '../config-provider/config-context';\nimport { getPrefixCls } from '../_utils/general';\nimport { useLocale } from '../_utils/use-locale';\nimport { ModalProps } from './types';\n\nconst Modal = React.forwardRef<HTMLDivElement, ModalProps>((props, ref) => {\n const locale = useLocale();\n const {\n visible = false,\n width = 520,\n centered = false,\n closable = true,\n unmountOnClose = true,\n maskType = 'default',\n maskClosable = true,\n confirmText = locale.Modal.okText,\n cancelText = locale.Modal.cancelText,\n confirmLoading = false,\n animation = 'slide',\n zIndex = 1000,\n onConfirm,\n onCancel: onCancelProp,\n onClose: onCloseProp,\n top,\n header,\n footer,\n afterClose,\n confirmButtonProps,\n cancelButtonProps,\n className,\n children,\n style,\n maskStyle,\n headerStyle,\n bodyStyle,\n footerStyle,\n prefixCls: customisedCls,\n } = props;\n const onCancel = onCloseProp ?? onCancelProp;\n const [modalVisible, setModalVisible] = useState(visible);\n const configContext = useContext(ConfigContext);\n const prefixCls = getPrefixCls('modal', configContext.prefixCls, customisedCls);\n const cls = classNames(prefixCls, className, { [`${prefixCls}_centered`]: centered });\n const nodeRef = useRef<HTMLDivElement>(null);\n const previousFocusRef = useRef<HTMLElement | null>(null);\n const titleId = useId();\n\n // Focus trap + Escape key\n useEffect(() => {\n if (!visible) return;\n previousFocusRef.current = document.activeElement as HTMLElement;\n\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n onCancel?.(e as unknown as React.MouseEvent);\n return;\n }\n if (e.key === 'Tab' && nodeRef.current) {\n const focusable = nodeRef.current.querySelectorAll<HTMLElement>(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])'\n );\n if (focusable.length === 0) return;\n const first = focusable[0];\n const last = focusable[focusable.length - 1];\n if (e.shiftKey) {\n if (document.activeElement === first) { e.preventDefault(); last.focus(); }\n } else {\n if (document.activeElement === last) { e.preventDefault(); first.focus(); }\n }\n }\n };\n document.addEventListener('keydown', handleKeyDown);\n\n // Focus first focusable element\n requestAnimationFrame(() => {\n if (nodeRef.current) {\n const focusable = nodeRef.current.querySelectorAll<HTMLElement>(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])'\n );\n if (focusable.length > 0) focusable[0].focus();\n }\n });\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n previousFocusRef.current?.focus();\n };\n }, [visible, onCancel]);\n\n const renderFooter = (): React.ReactNode => {\n if (React.isValidElement(footer)) {\n return footer;\n } else if (footer === null) {\n return null;\n } else {\n return (\n <Flex gap=\"sm\" justify='end' className={`${prefixCls}__footer`} style={footerStyle}>\n <Button onClick={onCancel} className={`${prefixCls}__footer-btn`} {...cancelButtonProps}>\n {cancelText}\n </Button>\n <Button\n loading={confirmLoading}\n onClick={onConfirm}\n btnType=\"primary\"\n className={`${prefixCls}__footer-btn`}\n {...confirmButtonProps}>\n {confirmText}\n </Button>\n </Flex>\n );\n }\n };\n\n return (\n <Overlay\n onEnter={(): void => setModalVisible(true)}\n onExit={(): void => setModalVisible(false)}\n zIndex={zIndex}\n type={maskType}\n unmountOnExit={unmountOnClose}\n isShow={visible}\n onExited={afterClose}\n clickCallback={(e: React.MouseEvent): void => {\n maskClosable && onCancel ? onCancel(e) : undefined;\n }}\n style={maskStyle}>\n <div ref={ref} className={cls} style={{ top }}>\n <div style={{ width, ...style }}>\n <Transition\n appear={true}\n nodeRef={nodeRef}\n in={modalVisible}\n classNames={`${prefixCls}__content_${animation}`}\n unmountOnExit={false}\n timeout={0}>\n <div\n ref={nodeRef}\n className={`${prefixCls}__content`}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={header ? titleId : undefined}\n onClick={(e): void => e.stopPropagation()}>\n {closable && (\n <button type=\"button\" className={`${prefixCls}__close-btn`} onClick={onCancel} aria-label=\"Close\">\n ✕\n </button>\n )}\n {header && (\n <div className={`${prefixCls}__header`} style={headerStyle}>\n <div className={`${prefixCls}__title`} id={titleId}>{header}</div>\n </div>\n )}\n <div className={`${prefixCls}__body`} style={bodyStyle}>\n {children}\n </div>\n {renderFooter()}\n </div>\n </Transition>\n </div>\n </div>\n </Overlay>\n );\n});\n\nModal.displayName = 'Modal';\n\nexport default Modal;\n"],"mappings":";;;;;;;;;;;;;;AAWA,MAAM,QAAQA,MAAAA,QAAM,YAAwC,OAAO,QAAQ;CACzE,MAAM,SAASC,mBAAAA,WAAW;CAC1B,MAAM,EACJ,UAAU,OACV,QAAQ,KACR,WAAW,OACX,WAAW,MACX,iBAAiB,MACjB,WAAW,WACX,eAAe,MACf,cAAc,OAAO,MAAM,QAC3B,aAAa,OAAO,MAAM,YAC1B,iBAAiB,OACjB,YAAY,SACZ,SAAS,KACT,WACA,UAAU,cACV,SAAS,aACT,KACA,QACA,QACA,YACA,oBACA,mBACA,WACA,UACA,OACA,WACA,aACA,WACA,aACA,WAAW,kBACT;CACJ,MAAM,WAAW,eAAe;CAChC,MAAM,CAAC,cAAc,oBAAA,GAAA,MAAA,UAA4B,QAAQ;CAEzD,MAAM,YAAYC,gBAAAA,aAAa,UAAA,GAAA,MAAA,YADEC,uBAAAA,cAAc,CACO,WAAW,cAAc;CAC/E,MAAM,OAAA,GAAA,WAAA,SAAiB,WAAW,WAAW,GAAG,GAAG,UAAU,aAAa,UAAU,CAAC;CACrF,MAAM,WAAA,GAAA,MAAA,QAAiC,KAAK;CAC5C,MAAM,oBAAA,GAAA,MAAA,QAA8C,KAAK;CACzD,MAAM,WAAA,GAAA,MAAA,QAAiB;AAGv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|
|
1
1
|
const require_runtime = require("../_virtual/_rolldown/runtime.js");
|
|
2
2
|
const require_config_context = require("../config-provider/config-context.js");
|
|
3
3
|
const require_general = require("../_utils/general.js");
|
|
4
|
-
const require_index = require("../
|
|
4
|
+
const require_index = require("../transition/index.js");
|
|
5
|
+
const require_index$1 = require("../portal/index.js");
|
|
5
6
|
let react = require("react");
|
|
6
7
|
let classnames = require("classnames");
|
|
7
8
|
classnames = require_runtime.__toESM(classnames);
|
|
8
9
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
-
let react_transition_group = require("react-transition-group");
|
|
10
10
|
//#region src/overlay/overlay.tsx
|
|
11
11
|
let scrollLockCount = 0;
|
|
12
12
|
const Overlay = (props) => {
|
|
@@ -29,7 +29,7 @@ const Overlay = (props) => {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
}, [isShow]);
|
|
32
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.default, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
32
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index$1.default, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.default, {
|
|
33
33
|
appear: true,
|
|
34
34
|
nodeRef,
|
|
35
35
|
onEnter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.js","names":["getPrefixCls","ConfigContext","Portal","
|
|
1
|
+
{"version":3,"file":"overlay.js","names":["getPrefixCls","ConfigContext","Portal","Transition"],"sources":["../../src/overlay/overlay.tsx"],"sourcesContent":["import { useContext, useEffect, useRef } from 'react';\nimport classNames from 'classnames';\nimport Portal from '../portal';\nimport Transition from '../transition';\nimport { ConfigContext } from '../config-provider/config-context';\nimport { getPrefixCls } from '../_utils/general';\nimport { OverlayProps } from './types';\n\nlet scrollLockCount = 0;\n\nconst Overlay = (props: OverlayProps): JSX.Element => {\n const {\n isShow = false,\n blurred = false,\n unmountOnExit = true,\n zIndex = 1000,\n type = 'default',\n clickCallback,\n onEnter,\n onEntered,\n onExit,\n onExited,\n children,\n style,\n prefixCls: customisedCls,\n } = props;\n const configContext = useContext(ConfigContext);\n const prefixCls = getPrefixCls('overlay', configContext.prefixCls, customisedCls);\n const cls = classNames(prefixCls, `${prefixCls}_${type}`, { [`${prefixCls}_blurred`]: blurred });\n const nodeRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (isShow) {\n scrollLockCount++;\n document.body.style.overflow = 'hidden';\n }\n return () => {\n if (isShow) {\n scrollLockCount--;\n if (scrollLockCount <= 0) {\n scrollLockCount = 0;\n document.body.style.overflow = '';\n }\n }\n };\n }, [isShow]);\n\n return (\n <Portal>\n <Transition\n appear={true}\n nodeRef={nodeRef}\n onEnter={onEnter}\n onEntered={onEntered}\n onExit={onExit}\n onExited={onExited}\n in={isShow}\n mountOnEnter={true}\n unmountOnExit={unmountOnExit}\n classNames={`${prefixCls}_fade`}\n timeout={{ exit: 300, enter: 0 }}>\n <div ref={nodeRef} tabIndex={-1} className={cls} onClick={clickCallback} style={{ zIndex, ...style }}>\n {children}\n </div>\n </Transition>\n </Portal>\n );\n};\n\nOverlay.displayName = 'Overlay';\n\nexport default Overlay;\n"],"mappings":";;;;;;;;;;AAQA,IAAI,kBAAkB;AAEtB,MAAM,WAAW,UAAqC;CACpD,MAAM,EACJ,SAAS,OACT,UAAU,OACV,gBAAgB,MAChB,SAAS,KACT,OAAO,WACP,eACA,SACA,WACA,QACA,UACA,UACA,OACA,WAAW,kBACT;CAEJ,MAAM,YAAYA,gBAAAA,aAAa,YAAA,GAAA,MAAA,YADEC,uBAAAA,cAAc,CACS,WAAW,cAAc;CACjF,MAAM,OAAA,GAAA,WAAA,SAAiB,WAAW,GAAG,UAAU,GAAG,QAAQ,GAAG,GAAG,UAAU,YAAY,SAAS,CAAC;CAChG,MAAM,WAAA,GAAA,MAAA,QAAiC,KAAK;AAE5C,EAAA,GAAA,MAAA,iBAAgB;AACd,MAAI,QAAQ;AACV;AACA,YAAS,KAAK,MAAM,WAAW;;AAEjC,eAAa;AACX,OAAI,QAAQ;AACV;AACA,QAAI,mBAAmB,GAAG;AACxB,uBAAkB;AAClB,cAAS,KAAK,MAAM,WAAW;;;;IAIpC,CAAC,OAAO,CAAC;AAEZ,QACE,iBAAA,GAAA,kBAAA,KAACC,gBAAAA,SAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,KAACC,cAAAA,SAAD;EACE,QAAQ;EACC;EACA;EACE;EACH;EACE;EACV,IAAI;EACJ,cAAc;EACC;EACf,YAAY,GAAG,UAAU;EACzB,SAAS;GAAE,MAAM;GAAK,OAAO;GAAG;YAChC,iBAAA,GAAA,kBAAA,KAAC,OAAD;GAAK,KAAK;GAAS,UAAU;GAAI,WAAW;GAAK,SAAS;GAAe,OAAO;IAAE;IAAQ,GAAG;IAAO;GACjG;GACG,CAAA;EACK,CAAA,EACN,CAAA;;AAIb,QAAQ,cAAc"}
|