@ioca/react 1.5.13 → 1.5.14
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/lib/cjs/components/dropdown/dropdown.js +6 -3
- package/lib/cjs/components/dropdown/dropdown.js.map +1 -1
- package/lib/cjs/components/dropdown/item.js +20 -4
- package/lib/cjs/components/dropdown/item.js.map +1 -1
- package/lib/cjs/components/editor/editor.js +27 -11
- package/lib/cjs/components/editor/editor.js.map +1 -1
- package/lib/cjs/components/loading/loading.js +4 -3
- package/lib/cjs/components/loading/loading.js.map +1 -1
- package/lib/cjs/components/popup/popup.js +7 -17
- package/lib/cjs/components/popup/popup.js.map +1 -1
- package/lib/cjs/components/scroll/index.js +10 -0
- package/lib/cjs/components/scroll/index.js.map +1 -0
- package/lib/cjs/components/scroll/scroll.js +78 -0
- package/lib/cjs/components/scroll/scroll.js.map +1 -0
- package/lib/cjs/components/upload/upload.js +5 -5
- package/lib/cjs/components/upload/upload.js.map +1 -1
- package/lib/cjs/index.js +2 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/css/colors.css +784 -784
- package/lib/css/index.css +1 -1
- package/lib/css/index.css.map +1 -1
- package/lib/es/components/dropdown/dropdown.js +7 -5
- package/lib/es/components/dropdown/dropdown.js.map +1 -1
- package/lib/es/components/dropdown/item.js +20 -4
- package/lib/es/components/dropdown/item.js.map +1 -1
- package/lib/es/components/editor/editor.js +27 -11
- package/lib/es/components/editor/editor.js.map +1 -1
- package/lib/es/components/loading/loading.js +4 -3
- package/lib/es/components/loading/loading.js.map +1 -1
- package/lib/es/components/popup/popup.js +7 -17
- package/lib/es/components/popup/popup.js.map +1 -1
- package/lib/es/components/scroll/index.js +6 -0
- package/lib/es/components/scroll/index.js.map +1 -0
- package/lib/es/components/scroll/scroll.js +70 -0
- package/lib/es/components/scroll/scroll.js.map +1 -0
- package/lib/es/components/upload/upload.js +7 -7
- package/lib/es/components/upload/upload.js.map +1 -1
- package/lib/es/index.js +1 -0
- package/lib/es/index.js.map +1 -1
- package/lib/index.js +132 -45
- package/lib/types/components/dropdown/dropdown.d.ts +1 -1
- package/lib/types/components/editor/type.d.ts +1 -1
- package/lib/types/components/scroll/index.d.ts +5 -0
- package/lib/types/components/scroll/scroll.d.ts +6 -0
- package/lib/types/components/scroll/type.d.ts +7 -0
- package/lib/types/components/upload/type.d.ts +1 -0
- package/lib/types/index.d.ts +1 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { debounce, uid, throttle } from 'radash';
|
|
4
|
-
import { useState, useRef, useEffect, useCallback, useMemo, Children, cloneElement, createElement, isValidElement, memo, Fragment as Fragment$1, useTransition, forwardRef, useLayoutEffect,
|
|
5
|
-
import { SkipPreviousRound, CloseRound, MinusRound, PlusRound, InboxTwotone, UndoRound, RedoRound, FormatBoldRound, FormatItalicRound, FormatUnderlinedRound, StrikethroughSRound, ClearAllRound, PlayArrowRound, PauseRound, StopRound, VolumeDownRound, VolumeOffRound, FullscreenRound, FullscreenExitRound, FeedOutlined, AspectRatioRound, OpenInNewRound, FileDownloadOutlined, RotateRightRound, RotateLeftRound, KeyboardArrowLeftRound, KeyboardArrowRightRound, KeyboardDoubleArrowUpRound, SyncAltRound, VisibilityRound, VisibilityOffRound, MoreHorizRound, SearchRound, CheckRound, UnfoldMoreRound, CalendarMonthTwotone, AccessTimeRound, InfoOutlined, KeyboardArrowDownRound, MoveToInboxTwotone, OutboxTwotone, FilePresentOutlined, DriveFolderUploadOutlined
|
|
4
|
+
import { useState, useRef, useEffect, useCallback, useMemo, Children, cloneElement, createElement, isValidElement, memo, Fragment as Fragment$1, useTransition, forwardRef, useLayoutEffect, useContext, createContext, useImperativeHandle } from 'react';
|
|
5
|
+
import { SkipPreviousRound, CloseRound, MinusRound, PlusRound, InboxTwotone, UndoRound, RedoRound, FormatBoldRound, FormatItalicRound, FormatUnderlinedRound, StrikethroughSRound, ClearAllRound, PlayArrowRound, PauseRound, StopRound, VolumeDownRound, VolumeOffRound, FullscreenRound, FullscreenExitRound, FeedOutlined, AspectRatioRound, OpenInNewRound, FileDownloadOutlined, RotateRightRound, RotateLeftRound, KeyboardArrowLeftRound, KeyboardArrowRightRound, KeyboardDoubleArrowUpRound, SyncAltRound, VisibilityRound, VisibilityOffRound, MoreHorizRound, SearchRound, CheckRound, UnfoldMoreRound, CalendarMonthTwotone, AccessTimeRound, InfoOutlined, KeyboardArrowDownRound, MoveToInboxTwotone, OutboxTwotone, FilePresentOutlined, DriveFolderUploadOutlined } from '@ricons/material';
|
|
6
6
|
import { createRoot } from 'react-dom/client';
|
|
7
7
|
import { getScrollbarSize, List as List$2 } from 'react-window';
|
|
8
8
|
import { createPortal } from 'react-dom';
|
|
@@ -62,14 +62,15 @@ function createRipple() {
|
|
|
62
62
|
|
|
63
63
|
const Loading = (props) => {
|
|
64
64
|
const { icon, text, size, absolute, style, className, ...restProps } = props;
|
|
65
|
+
const iconSize = size != null
|
|
66
|
+
? { fontSize: typeof size === "number" ? `${size}px` : size }
|
|
67
|
+
: undefined;
|
|
65
68
|
return (jsxs("div", { className: classNames("i-loading-container", {
|
|
66
69
|
absolute,
|
|
67
70
|
}, className), style: {
|
|
68
71
|
...style,
|
|
69
72
|
inset: absolute ? 0 : "unset",
|
|
70
|
-
}, ...restProps, children: [icon ??
|
|
71
|
-
fontSize: size,
|
|
72
|
-
}, children: jsx("circle", { cx: '12', cy: '12', r: '9.5', fill: 'none', strokeWidth: '3', strokeLinecap: 'round', strokeDasharray: 40, strokeDashoffset: 0 }) })), text] }));
|
|
73
|
+
}, ...restProps, children: [icon ?? jsx("span", { className: "i-loading-icon", style: iconSize }), text] }));
|
|
73
74
|
};
|
|
74
75
|
|
|
75
76
|
const os = window.navigator.platform;
|
|
@@ -1839,19 +1840,7 @@ function Popup(props) {
|
|
|
1839
1840
|
const [show, setShow] = useState(false);
|
|
1840
1841
|
const showRef = useRef(false);
|
|
1841
1842
|
showRef.current = show;
|
|
1842
|
-
const latestRef = useRef({
|
|
1843
|
-
disabled,
|
|
1844
|
-
trigger,
|
|
1845
|
-
touchable,
|
|
1846
|
-
showDelay,
|
|
1847
|
-
hideDelay,
|
|
1848
|
-
position,
|
|
1849
|
-
gap,
|
|
1850
|
-
offset,
|
|
1851
|
-
align,
|
|
1852
|
-
fitSize,
|
|
1853
|
-
onVisibleChange,
|
|
1854
|
-
});
|
|
1843
|
+
const latestRef = useRef({});
|
|
1855
1844
|
latestRef.current = {
|
|
1856
1845
|
disabled,
|
|
1857
1846
|
trigger,
|
|
@@ -1905,9 +1894,8 @@ function Popup(props) {
|
|
|
1905
1894
|
};
|
|
1906
1895
|
const applyFitSize = () => {
|
|
1907
1896
|
const o = latestRef.current;
|
|
1908
|
-
const triggerEl = triggerRef.current;
|
|
1909
1897
|
const contentEl = contentRef.current;
|
|
1910
|
-
if (!
|
|
1898
|
+
if (!contentEl)
|
|
1911
1899
|
return;
|
|
1912
1900
|
const vertical = ["top", "bottom"].includes(o.position);
|
|
1913
1901
|
const key = vertical ? "width" : "height";
|
|
@@ -1915,6 +1903,9 @@ function Popup(props) {
|
|
|
1915
1903
|
contentEl.style[key] = "";
|
|
1916
1904
|
return;
|
|
1917
1905
|
}
|
|
1906
|
+
const triggerEl = triggerRef.current;
|
|
1907
|
+
if (!triggerEl)
|
|
1908
|
+
return;
|
|
1918
1909
|
const size = triggerEl[vertical ? "offsetWidth" : "offsetHeight"];
|
|
1919
1910
|
contentEl.style[key] =
|
|
1920
1911
|
typeof size === "number" ? `${size}px` : "";
|
|
@@ -2151,8 +2142,8 @@ function Popup(props) {
|
|
|
2151
2142
|
e.stopPropagation();
|
|
2152
2143
|
setTriggerEl(e);
|
|
2153
2144
|
pointRef.current = {
|
|
2154
|
-
pageX: e.
|
|
2155
|
-
pageY: e.
|
|
2145
|
+
pageX: e.clientX,
|
|
2146
|
+
pageY: e.clientY,
|
|
2156
2147
|
};
|
|
2157
2148
|
if (showRef.current) {
|
|
2158
2149
|
ensureBaseStyle();
|
|
@@ -2309,22 +2300,38 @@ function Popup(props) {
|
|
|
2309
2300
|
|
|
2310
2301
|
const { Item: ListItem } = List$1;
|
|
2311
2302
|
const Item$3 = (props) => {
|
|
2312
|
-
const { more, moreProps, onClick, ...restProps } = props;
|
|
2313
|
-
const
|
|
2303
|
+
const { more, moreProps, onClick, ref: itemRef, children, ...restProps } = props;
|
|
2304
|
+
const close = useContext(DropdownCloseCtx);
|
|
2305
|
+
const liRef = useRef(null);
|
|
2306
|
+
const [position, setPosition] = useState("right");
|
|
2307
|
+
const { position: morePosition, onVisibleChange: moreOnVisibleChange, width: moreWidth, ...restMoreProps } = moreProps ?? {};
|
|
2308
|
+
const effectivePosition = morePosition ?? position;
|
|
2309
|
+
const handleVisibleChange = (v) => {
|
|
2310
|
+
if (v && liRef.current) {
|
|
2311
|
+
const rect = liRef.current.getBoundingClientRect();
|
|
2312
|
+
setPosition(rect.left > window.innerWidth / 2 ? "left" : "right");
|
|
2313
|
+
}
|
|
2314
|
+
moreOnVisibleChange?.(v);
|
|
2315
|
+
};
|
|
2316
|
+
const Li = (jsx(ListItem, { ref: itemRef ?? liRef, onClick: (e) => {
|
|
2314
2317
|
e.stopPropagation();
|
|
2318
|
+
if (!more)
|
|
2319
|
+
close?.();
|
|
2315
2320
|
onClick?.(e);
|
|
2316
|
-
}, ...restProps }));
|
|
2321
|
+
}, ...restProps, children: children }));
|
|
2317
2322
|
if (!more)
|
|
2318
2323
|
return Li;
|
|
2319
|
-
return (jsx(Popup, { position:
|
|
2324
|
+
return (jsx(Popup, { ...restMoreProps, position: effectivePosition, touchable: true, arrow: false, align: "start", offset: 11, hideDelay: 240, onVisibleChange: handleVisibleChange, content: jsx(List$1, { className: "i-dropdown-content", style: { minWidth: moreWidth }, onClick: (e) => e.stopPropagation(), children: more }), children: Li }));
|
|
2320
2325
|
};
|
|
2321
2326
|
|
|
2327
|
+
const DropdownCloseCtx = createContext(null);
|
|
2322
2328
|
const Dropdown = (props) => {
|
|
2323
2329
|
const { visible, width, content, children, ...restProps } = props;
|
|
2324
2330
|
const [active, setActive] = useState(visible);
|
|
2325
2331
|
if (!content) {
|
|
2326
2332
|
return children;
|
|
2327
2333
|
}
|
|
2334
|
+
const close = () => setActive(false);
|
|
2328
2335
|
const handleVisibleChange = (v) => {
|
|
2329
2336
|
setActive(v);
|
|
2330
2337
|
if (props.onVisibleChange) {
|
|
@@ -2334,9 +2341,9 @@ const Dropdown = (props) => {
|
|
|
2334
2341
|
useEffect(() => {
|
|
2335
2342
|
setActive(visible);
|
|
2336
2343
|
}, [visible]);
|
|
2337
|
-
return (jsx(Popup, { trigger: 'click', position: 'bottom', content: jsx(List$1, { className: 'i-dropdown-content', style: { minWidth: width }, children: typeof content === "function"
|
|
2338
|
-
|
|
2339
|
-
|
|
2344
|
+
return (jsx(Popup, { trigger: 'click', position: 'bottom', content: jsx(DropdownCloseCtx.Provider, { value: close, children: jsx(List$1, { className: 'i-dropdown-content', style: { minWidth: width }, children: typeof content === "function"
|
|
2345
|
+
? content(close)
|
|
2346
|
+
: content }) }), ...restProps, touchable: true, visible: active, onVisibleChange: handleVisibleChange, children: children }));
|
|
2340
2347
|
};
|
|
2341
2348
|
Dropdown.Item = Item$3;
|
|
2342
2349
|
|
|
@@ -2690,7 +2697,13 @@ const Editor = (props) => {
|
|
|
2690
2697
|
const [memtionRect, setMemtionRect] = useState(null);
|
|
2691
2698
|
const [memtionKeyword, setMemtionKeyword] = useState("");
|
|
2692
2699
|
const [memtionActiveIndex, setMemtionActiveIndex] = useState(0);
|
|
2693
|
-
const
|
|
2700
|
+
const [activeMemtionIndex, setActiveMemtionIndex] = useState(-1);
|
|
2701
|
+
const memtionOptions = useMemo(() => {
|
|
2702
|
+
if (activeMemtionIndex < 0 || !memtion?.length)
|
|
2703
|
+
return [];
|
|
2704
|
+
const active = memtion?.[activeMemtionIndex];
|
|
2705
|
+
return filterMemtionOptions(active?.options ?? [], memtionKeyword);
|
|
2706
|
+
}, [memtion, memtionKeyword, activeMemtionIndex]);
|
|
2694
2707
|
const sanitizeValue = (nextValue) => {
|
|
2695
2708
|
if (isPlaintextMode) {
|
|
2696
2709
|
return nextValue === "\n" ? "" : nextValue;
|
|
@@ -2745,18 +2758,20 @@ const Editor = (props) => {
|
|
|
2745
2758
|
setMemtionRect(null);
|
|
2746
2759
|
setMemtionKeyword("");
|
|
2747
2760
|
setMemtionActiveIndex(0);
|
|
2761
|
+
setActiveMemtionIndex(-1);
|
|
2748
2762
|
};
|
|
2749
2763
|
const syncEditorState = () => {
|
|
2750
2764
|
selectionRef.current = null;
|
|
2751
2765
|
hideMemtion();
|
|
2752
2766
|
};
|
|
2753
2767
|
const insertMemtion = (option) => {
|
|
2768
|
+
const activeMemtion = memtion?.[activeMemtionIndex];
|
|
2754
2769
|
const replaceRange = getMemtionReplaceRange(memtionTriggerRangeRef.current, selectionRef.current);
|
|
2755
2770
|
const range = insertMemtionOption({
|
|
2756
2771
|
editor: editorRef.current,
|
|
2757
2772
|
range: replaceRange,
|
|
2758
2773
|
mode,
|
|
2759
|
-
memtion,
|
|
2774
|
+
memtion: activeMemtion,
|
|
2760
2775
|
option,
|
|
2761
2776
|
sanitizeValue,
|
|
2762
2777
|
});
|
|
@@ -2792,7 +2807,6 @@ const Editor = (props) => {
|
|
|
2792
2807
|
editorRef.current?.dispatchEvent(new Event("input", { bubbles: true }));
|
|
2793
2808
|
return;
|
|
2794
2809
|
}
|
|
2795
|
-
const memtionKey = memtion?.key ?? "@";
|
|
2796
2810
|
if (memtionVisible && e.key === " ") {
|
|
2797
2811
|
hideMemtion();
|
|
2798
2812
|
}
|
|
@@ -2812,11 +2826,15 @@ const Editor = (props) => {
|
|
|
2812
2826
|
return;
|
|
2813
2827
|
}
|
|
2814
2828
|
}
|
|
2815
|
-
if (memtion
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2829
|
+
if (memtion?.length) {
|
|
2830
|
+
const matchedIndex = memtion.findIndex((m) => e.key === m.key);
|
|
2831
|
+
if (matchedIndex >= 0) {
|
|
2832
|
+
rememberSelection();
|
|
2833
|
+
memtionTriggerRangeRef.current =
|
|
2834
|
+
selectionRef.current?.cloneRange() ?? null;
|
|
2835
|
+
pendingMemtionRef.current = true;
|
|
2836
|
+
setActiveMemtionIndex(matchedIndex);
|
|
2837
|
+
}
|
|
2820
2838
|
}
|
|
2821
2839
|
switch (e.key) {
|
|
2822
2840
|
case "Tab":
|
|
@@ -2864,8 +2882,13 @@ const Editor = (props) => {
|
|
|
2864
2882
|
setEditorValue(nextValue);
|
|
2865
2883
|
}
|
|
2866
2884
|
rememberSelection();
|
|
2867
|
-
if (
|
|
2868
|
-
const
|
|
2885
|
+
if (activeMemtionIndex >= 0 && (pendingMemtionRef.current || memtionVisible)) {
|
|
2886
|
+
const active = memtion?.[activeMemtionIndex];
|
|
2887
|
+
if (!active) {
|
|
2888
|
+
hideMemtion();
|
|
2889
|
+
return;
|
|
2890
|
+
}
|
|
2891
|
+
const memtionKey = active.key ?? "@";
|
|
2869
2892
|
const memtionText = getMemtionText(memtionTriggerRangeRef.current, selectionRef.current);
|
|
2870
2893
|
if (!memtionText.startsWith(memtionKey) || /\s/.test(memtionText)) {
|
|
2871
2894
|
hideMemtion();
|
|
@@ -2920,7 +2943,7 @@ const Editor = (props) => {
|
|
|
2920
2943
|
...style,
|
|
2921
2944
|
[autosize ? "minHeight" : "height"]: height,
|
|
2922
2945
|
width,
|
|
2923
|
-
}, children: [!hideControl && (jsx("div", { className: "i-editor-controls", children: controls })), memtion && (jsx(Memtion$1, { visible: memtionVisible, rect: memtionRect, options: memtionOptions, activeIndex: memtionActiveIndex, onActiveChange: setMemtionActiveIndex, onSelect: insertMemtion })), jsx("div", { ref: handleRef, className: "i-editor-content", "data-placeholder": placeholder, contentEditable: isPlaintextMode ? "plaintext-only" : true, onFocus: handleFocus, onBlur: handleBlur, onMouseUp: handleMouseUp, onPaste: handlePaste, onInput: handleInput, onKeyUp: handleKeyUp, onKeyDown: handleKeyDown, ...restProps })] }));
|
|
2946
|
+
}, children: [!hideControl && (jsx("div", { className: "i-editor-controls", children: controls })), memtion?.length && (jsx(Memtion$1, { visible: memtionVisible, rect: memtionRect, options: memtionOptions, activeIndex: memtionActiveIndex, onActiveChange: setMemtionActiveIndex, onSelect: insertMemtion })), jsx("div", { ref: handleRef, className: "i-editor-content", "data-placeholder": placeholder, contentEditable: isPlaintextMode ? "plaintext-only" : true, onFocus: handleFocus, onBlur: handleBlur, onMouseUp: handleMouseUp, onPaste: handlePaste, onInput: handleInput, onKeyUp: handleKeyUp, onKeyDown: handleKeyDown, ...restProps })] }));
|
|
2924
2947
|
};
|
|
2925
2948
|
|
|
2926
2949
|
const Flex = (props) => {
|
|
@@ -5231,6 +5254,70 @@ const River = (props) => {
|
|
|
5231
5254
|
})] }) }));
|
|
5232
5255
|
};
|
|
5233
5256
|
|
|
5257
|
+
const Scroll = (props) => {
|
|
5258
|
+
const { style, className, draggable, onScroll, children, ...restProps } = props;
|
|
5259
|
+
const scrollRef = useRef(null);
|
|
5260
|
+
const [dragging, setDragging] = useState(false);
|
|
5261
|
+
const dragState = useRef({ down: false, startX: 0, scrollLeft: 0 });
|
|
5262
|
+
useEffect(() => {
|
|
5263
|
+
const el = scrollRef.current;
|
|
5264
|
+
if (!el)
|
|
5265
|
+
return;
|
|
5266
|
+
const onWheel = (e) => {
|
|
5267
|
+
const canScroll = el.scrollWidth > el.clientWidth + 1;
|
|
5268
|
+
if (!canScroll)
|
|
5269
|
+
return;
|
|
5270
|
+
e.preventDefault();
|
|
5271
|
+
e.stopPropagation();
|
|
5272
|
+
const delta = Math.abs(e.deltaX) > Math.abs(e.deltaY)
|
|
5273
|
+
? e.deltaX
|
|
5274
|
+
: e.deltaY;
|
|
5275
|
+
el.scrollLeft += delta;
|
|
5276
|
+
};
|
|
5277
|
+
const opts = {
|
|
5278
|
+
passive: false,
|
|
5279
|
+
capture: true,
|
|
5280
|
+
};
|
|
5281
|
+
el.addEventListener("wheel", onWheel, opts);
|
|
5282
|
+
return () => el.removeEventListener("wheel", onWheel, opts);
|
|
5283
|
+
}, []);
|
|
5284
|
+
useEffect(() => {
|
|
5285
|
+
if (!draggable)
|
|
5286
|
+
return;
|
|
5287
|
+
const handleMouseMove = (e) => {
|
|
5288
|
+
if (!dragState.current.down || !scrollRef.current)
|
|
5289
|
+
return;
|
|
5290
|
+
const x = e.clientX - dragState.current.startX;
|
|
5291
|
+
scrollRef.current.scrollLeft =
|
|
5292
|
+
dragState.current.scrollLeft - x;
|
|
5293
|
+
};
|
|
5294
|
+
const handleMouseUp = () => {
|
|
5295
|
+
dragState.current.down = false;
|
|
5296
|
+
setDragging(false);
|
|
5297
|
+
};
|
|
5298
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
5299
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
5300
|
+
return () => {
|
|
5301
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
5302
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
5303
|
+
};
|
|
5304
|
+
}, [draggable]);
|
|
5305
|
+
const handleMouseDown = (e) => {
|
|
5306
|
+
if (!draggable || !scrollRef.current)
|
|
5307
|
+
return;
|
|
5308
|
+
setDragging(true);
|
|
5309
|
+
dragState.current = {
|
|
5310
|
+
down: true,
|
|
5311
|
+
startX: e.clientX,
|
|
5312
|
+
scrollLeft: scrollRef.current.scrollLeft,
|
|
5313
|
+
};
|
|
5314
|
+
};
|
|
5315
|
+
return (jsx("div", { ref: scrollRef, className: classNames("i-scroll", className, {
|
|
5316
|
+
"i-scroll-draggable": draggable,
|
|
5317
|
+
"i-scroll-dragging": dragging,
|
|
5318
|
+
}), style: style, onScroll: onScroll, onMouseDown: handleMouseDown, ...restProps, children: children }));
|
|
5319
|
+
};
|
|
5320
|
+
|
|
5234
5321
|
function Divider() {
|
|
5235
5322
|
return jsx("i", { className: 'i-step-divider' });
|
|
5236
5323
|
}
|
|
@@ -6151,7 +6238,7 @@ const normalizeFiles = (files) => (files ?? []).map((item) => {
|
|
|
6151
6238
|
};
|
|
6152
6239
|
});
|
|
6153
6240
|
const Upload = (props) => {
|
|
6154
|
-
const { label, labelInline, value, files, placeholder, status = "normal", message, className, style, children, droppable, dropbox, getDropboxContainer, defaultButtonProps, mode = "default", cardSize = "3.2em", disabled, sortable, limit = props.multiple ? Infinity : 1, multiple, renderItem, shouldUpload = () => true, uploader, onChange, onFilesChange, onUpload, onRemove, ...restProps } = props;
|
|
6241
|
+
const { label, labelInline, value, files, placeholder, status = "normal", message, icon = jsx(Icon, { icon: jsx(DriveFolderUploadOutlined, {}) }), className, style, children, droppable, dropbox, getDropboxContainer, defaultButtonProps, mode = "default", cardSize = "3.2em", disabled, sortable, limit = props.multiple ? Infinity : 1, multiple, renderItem, shouldUpload = () => true, uploader, onChange, onFilesChange, onUpload, onRemove, ...restProps } = props;
|
|
6155
6242
|
const [internalFileList, setInternalFileList] = useState([]);
|
|
6156
6243
|
const isControlled = useMemo(() => value !== undefined || files !== undefined, [value, files]);
|
|
6157
6244
|
const fileList = isControlled
|
|
@@ -6161,7 +6248,7 @@ const Upload = (props) => {
|
|
|
6161
6248
|
const inputRef = useRef(null);
|
|
6162
6249
|
const preview = usePreview();
|
|
6163
6250
|
const defBtnProps = useMemo(() => ({
|
|
6164
|
-
children:
|
|
6251
|
+
children: jsxs(Fragment, { children: [icon, " \u4E0A\u4F20"] }),
|
|
6165
6252
|
...defaultButtonProps,
|
|
6166
6253
|
}), [defaultButtonProps]);
|
|
6167
6254
|
const trigger = useMemo(() => {
|
|
@@ -6169,11 +6256,11 @@ const Upload = (props) => {
|
|
|
6169
6256
|
return children;
|
|
6170
6257
|
switch (mode) {
|
|
6171
6258
|
case "card":
|
|
6172
|
-
return (jsx(Button, { className: "i-upload-card-btn color-5", square: true, flat: true, outline: true, disabled: disabled, children:
|
|
6259
|
+
return (jsx(Button, { className: "i-upload-card-btn color-5", square: true, flat: true, outline: true, disabled: disabled, children: icon }));
|
|
6173
6260
|
default:
|
|
6174
6261
|
return (jsx(Button, { ...defBtnProps, className: classNames("i-upload-btn", defBtnProps.className), disabled: disabled }));
|
|
6175
6262
|
}
|
|
6176
|
-
}, [mode, children, disabled, defBtnProps]);
|
|
6263
|
+
}, [mode, children, disabled, defBtnProps, icon]);
|
|
6177
6264
|
const handleUpload = useCallback(async (files) => {
|
|
6178
6265
|
if (!uploader)
|
|
6179
6266
|
return;
|
|
@@ -6416,4 +6503,4 @@ const useTheme = (props) => {
|
|
|
6416
6503
|
};
|
|
6417
6504
|
};
|
|
6418
6505
|
|
|
6419
|
-
export { Affix, Badge, Button, Card, Checkbox, Collapse, ColorPicker, Datagrid, Datepicker as DatePicker, Description, Drawer, Dropdown, Editor, Flex, Form, Icon, MemoImage as Image, Input, List$1 as List, Loading, message as Message, Modal, Pagination, Popconfirm, Popup, Progress, Radio, Resizable, River, Select, Step, Swiper, Tabs, Tag, Text, TimePicker, Tree, Upload, Video, usePreview, useTheme };
|
|
6506
|
+
export { Affix, Badge, Button, Card, Checkbox, Collapse, ColorPicker, Datagrid, Datepicker as DatePicker, Description, Drawer, Dropdown, Editor, Flex, Form, Icon, MemoImage as Image, Input, List$1 as List, Loading, message as Message, Modal, Pagination, Popconfirm, Popup, Progress, Radio, Resizable, River, Scroll, Select, Step, Swiper, Tabs, Tag, Text, TimePicker, Tree, Upload, Video, usePreview, useTheme };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IDropdown, IDropItem } from './type.js';
|
|
2
|
-
import * as react from 'react';
|
|
3
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import * as react from 'react';
|
|
4
4
|
|
|
5
5
|
declare const Dropdown: {
|
|
6
6
|
(props: IDropdown): string | number | bigint | boolean | react_jsx_runtime.JSX.Element | Iterable<react.ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode>>;
|
|
@@ -23,7 +23,7 @@ interface IEditor extends Omit<HTMLAttributes<HTMLDivElement>, "onInput" | "onCh
|
|
|
23
23
|
mode?: "rich" | "plaintext" | "plaintextOnMemtion";
|
|
24
24
|
hideControl?: boolean;
|
|
25
25
|
addtionControls?: IEditorAddtionControl[];
|
|
26
|
-
memtion?: IEditorMemtion;
|
|
26
|
+
memtion?: IEditorMemtion[];
|
|
27
27
|
border?: boolean;
|
|
28
28
|
onChange?: (value: string, e: SyntheticEvent<HTMLDivElement>) => void;
|
|
29
29
|
onEnter?: (e: KeyboardEvent<HTMLDivElement>) => void;
|
|
@@ -14,6 +14,7 @@ interface IUpload extends Omit<BaseInput, "ref">, Omit<InputHTMLAttributes<HTMLI
|
|
|
14
14
|
dropbox?: (dragging?: boolean) => ReactNode;
|
|
15
15
|
getDropboxContainer?: () => HTMLElement;
|
|
16
16
|
cardSize?: string;
|
|
17
|
+
icon?: ReactNode;
|
|
17
18
|
defaultButtonProps?: IButton;
|
|
18
19
|
shouldUpload?: (file: IFile) => boolean;
|
|
19
20
|
uploader?: (file: IFile) => Promise<IFile>;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export { default as Progress } from './components/progress/progress.js';
|
|
|
28
28
|
export { default as Radio } from './components/radio/radio.js';
|
|
29
29
|
export { default as Resizable } from './components/resizable/resizable.js';
|
|
30
30
|
export { default as River } from './components/river/river.js';
|
|
31
|
+
export { default as Scroll } from './components/scroll/scroll.js';
|
|
31
32
|
export { default as Select } from './components/select/select.js';
|
|
32
33
|
export { default as Step } from './components/step/step.js';
|
|
33
34
|
export { default as Swiper } from './components/swiper/swiper.js';
|