@ioca/react 1.3.73 → 1.3.75
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/affix/totop.js +1 -1
- package/lib/cjs/components/button/index.js +2 -4
- package/lib/cjs/components/button/index.js.map +1 -1
- package/lib/cjs/components/button/merged.js +13 -0
- package/lib/cjs/components/button/merged.js.map +1 -0
- package/lib/cjs/components/editor/controls.js +1 -1
- package/lib/cjs/components/image/image.js +4 -2
- package/lib/cjs/components/image/image.js.map +1 -1
- package/lib/cjs/components/image/index.js +1 -2
- package/lib/cjs/components/image/index.js.map +1 -1
- package/lib/cjs/components/input/index.js +1 -6
- package/lib/cjs/components/input/index.js.map +1 -1
- package/lib/cjs/components/input/input.js +6 -0
- package/lib/cjs/components/input/input.js.map +1 -1
- package/lib/cjs/components/list/item.js +2 -1
- package/lib/cjs/components/list/item.js.map +1 -1
- package/lib/cjs/components/list/list.js +3 -2
- package/lib/cjs/components/list/list.js.map +1 -1
- package/lib/cjs/components/modal/modal.js +1 -1
- package/lib/cjs/components/picker/colors/footer.js +2 -3
- package/lib/cjs/components/picker/colors/footer.js.map +1 -1
- package/lib/cjs/components/picker/dates/index.js +1 -2
- package/lib/cjs/components/picker/dates/index.js.map +1 -1
- package/lib/cjs/components/picker/time/index.js +1 -2
- package/lib/cjs/components/picker/time/index.js.map +1 -1
- package/lib/cjs/components/popconfirm/popconfirm.js +1 -1
- package/lib/cjs/components/popup/popup.js +2 -2
- package/lib/cjs/components/popup/popup.js.map +1 -1
- package/lib/cjs/components/progress/circle.js +0 -1
- package/lib/cjs/components/progress/circle.js.map +1 -1
- package/lib/cjs/components/tabs/tabs.js +3 -3
- package/lib/cjs/components/tabs/tabs.js.map +1 -1
- package/lib/cjs/components/text/index.js +1 -6
- package/lib/cjs/components/text/index.js.map +1 -1
- package/lib/cjs/components/text/text.js +6 -0
- package/lib/cjs/components/text/text.js.map +1 -1
- package/lib/cjs/components/upload/renderFile.js +1 -2
- package/lib/cjs/components/upload/renderFile.js.map +1 -1
- package/lib/cjs/components/upload/upload.js +1 -1
- package/lib/cjs/components/video/video.js +2 -3
- package/lib/cjs/components/video/video.js.map +1 -1
- package/lib/cjs/index.js +7 -10
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/js/hooks.js +3 -3
- package/lib/cjs/js/hooks.js.map +1 -1
- package/lib/cjs/js/usePreview/content.js +1 -1
- package/lib/css/index.css +1 -1
- package/lib/css/index.css.map +1 -1
- package/lib/es/components/affix/totop.js +1 -1
- package/lib/es/components/button/index.js +2 -4
- package/lib/es/components/button/index.js.map +1 -1
- package/lib/es/components/button/merged.js +9 -0
- package/lib/es/components/button/merged.js.map +1 -0
- package/lib/es/components/editor/controls.js +1 -1
- package/lib/es/components/image/image.js +4 -2
- package/lib/es/components/image/image.js.map +1 -1
- package/lib/es/components/image/index.js +1 -2
- package/lib/es/components/image/index.js.map +1 -1
- package/lib/es/components/input/index.js +1 -6
- package/lib/es/components/input/index.js.map +1 -1
- package/lib/es/components/input/input.js +6 -0
- package/lib/es/components/input/input.js.map +1 -1
- package/lib/es/components/list/item.js +2 -1
- package/lib/es/components/list/item.js.map +1 -1
- package/lib/es/components/list/list.js +3 -2
- package/lib/es/components/list/list.js.map +1 -1
- package/lib/es/components/modal/modal.js +1 -1
- package/lib/es/components/picker/colors/footer.js +2 -3
- package/lib/es/components/picker/colors/footer.js.map +1 -1
- package/lib/es/components/picker/dates/index.js +1 -2
- package/lib/es/components/picker/dates/index.js.map +1 -1
- package/lib/es/components/picker/time/index.js +1 -2
- package/lib/es/components/picker/time/index.js.map +1 -1
- package/lib/es/components/popconfirm/popconfirm.js +1 -1
- package/lib/es/components/popup/popup.js +2 -2
- package/lib/es/components/popup/popup.js.map +1 -1
- package/lib/es/components/progress/circle.js +0 -1
- package/lib/es/components/progress/circle.js.map +1 -1
- package/lib/es/components/tabs/tabs.js +3 -3
- package/lib/es/components/tabs/tabs.js.map +1 -1
- package/lib/es/components/text/index.js +1 -6
- package/lib/es/components/text/index.js.map +1 -1
- package/lib/es/components/text/text.js +6 -0
- package/lib/es/components/text/text.js.map +1 -1
- package/lib/es/components/upload/renderFile.js +1 -2
- package/lib/es/components/upload/renderFile.js.map +1 -1
- package/lib/es/components/upload/upload.js +1 -1
- package/lib/es/components/video/video.js +2 -3
- package/lib/es/components/video/video.js.map +1 -1
- package/lib/es/index.js +4 -7
- package/lib/es/index.js.map +1 -1
- package/lib/es/js/hooks.js +3 -3
- package/lib/es/js/hooks.js.map +1 -1
- package/lib/es/js/usePreview/content.js +1 -1
- package/lib/index.js +123 -124
- package/lib/types/components/button/merged.d.ts +5 -0
- package/lib/types/components/list/type.d.ts +2 -1
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { debounce, uid, throttle, pick, title } from 'radash';
|
|
4
4
|
import { createElement, useEffect, useMemo, Children, cloneElement, isValidElement, useState, useRef, Fragment as Fragment$1, useLayoutEffect, useImperativeHandle, createContext, useContext } from 'react';
|
|
5
|
-
import { SkipPreviousRound, CloseRound, MinusRound, PlusRound, InboxTwotone, FormatBoldRound, FormatItalicRound, FormatUnderlinedRound, StrikethroughSRound, RedoRound, UndoRound, ClearAllRound, PauseRound, PlayArrowRound, StopRound, VolumeOffRound, VolumeDownRound, FullscreenExitRound, FullscreenRound, FeedOutlined, AspectRatioRound, OpenInNewRound, FileDownloadOutlined, RotateRightRound, RotateLeftRound, KeyboardArrowLeftRound, KeyboardArrowRightRound, HideImageTwotone, VisibilityRound, VisibilityOffRound,
|
|
5
|
+
import { SkipPreviousRound, CloseRound, MinusRound, PlusRound, InboxTwotone, FormatBoldRound, FormatItalicRound, FormatUnderlinedRound, StrikethroughSRound, RedoRound, UndoRound, ClearAllRound, PauseRound, PlayArrowRound, StopRound, VolumeOffRound, VolumeDownRound, FullscreenExitRound, FullscreenRound, FeedOutlined, AspectRatioRound, OpenInNewRound, FileDownloadOutlined, RotateRightRound, RotateLeftRound, KeyboardArrowLeftRound, KeyboardArrowRightRound, HideImageTwotone, SyncAltRound, VisibilityRound, VisibilityOffRound, MoreHorizRound, SearchRound, CheckRound, UnfoldMoreRound, CalendarMonthTwotone, AccessTimeRound, InfoOutlined, KeyboardArrowDownRound, ListAltRound, PlusSharp } from '@ricons/material';
|
|
6
6
|
import { useReactive, useCreation, useSize } from 'ahooks';
|
|
7
7
|
import { createRoot } from 'react-dom/client';
|
|
8
8
|
import { createPortal } from 'react-dom';
|
|
@@ -173,8 +173,8 @@ function Toggle(props) {
|
|
|
173
173
|
}), children: state.active ? after ?? children : children }) }));
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
Button.Toggle = Toggle;
|
|
177
176
|
Button.Group = Group;
|
|
177
|
+
Button.Toggle = Toggle;
|
|
178
178
|
|
|
179
179
|
const Icon = (props) => {
|
|
180
180
|
const { ref, icon, size = "1.425em", rotate, style, className, ...restProps } = props;
|
|
@@ -763,9 +763,9 @@ function useKeydown(listener, options) {
|
|
|
763
763
|
}, [listener]);
|
|
764
764
|
}
|
|
765
765
|
const defaultObserver = {
|
|
766
|
-
observe:
|
|
767
|
-
unobserve:
|
|
768
|
-
disconnect:
|
|
766
|
+
observe: undefined,
|
|
767
|
+
unobserve: undefined,
|
|
768
|
+
disconnect: undefined,
|
|
769
769
|
};
|
|
770
770
|
function useIntersectionObserver(configs) {
|
|
771
771
|
if (typeof window === "undefined") {
|
|
@@ -1076,16 +1076,17 @@ function Drawer(props) {
|
|
|
1076
1076
|
}
|
|
1077
1077
|
|
|
1078
1078
|
const Item$4 = (props) => {
|
|
1079
|
-
const { ref, active, type, align, disabled, label, style, className, children, ...restProps } = props;
|
|
1079
|
+
const { ref, active, type, align, disabled, label, style, border, className, children, ...restProps } = props;
|
|
1080
1080
|
return (jsxs("li", { ref: ref, className: classNames("i-list-item", className, {
|
|
1081
1081
|
"i-list-item-active": active,
|
|
1082
1082
|
"i-list-option": type === "option",
|
|
1083
|
+
"i-list-item-bordered": border,
|
|
1083
1084
|
disabled,
|
|
1084
1085
|
}), style: { alignItems: align, ...style }, ...restProps, children: [label !== undefined && (jsx("span", { className: 'i-list-item-label', children: label })), children] }));
|
|
1085
1086
|
};
|
|
1086
1087
|
|
|
1087
1088
|
const List$1 = (props) => {
|
|
1088
|
-
const { label, type, className, children, ...restProps } = props;
|
|
1089
|
+
const { label, type, border, className, children, ...restProps } = props;
|
|
1089
1090
|
return (jsx("ul", { className: classNames("i-list", className), ...restProps, children: Children.map(children, (node, i) => {
|
|
1090
1091
|
const renderLabel = typeof label === "function" ? label(i) : label;
|
|
1091
1092
|
const { type, props: nodeProps } = node;
|
|
@@ -1093,7 +1094,8 @@ const List$1 = (props) => {
|
|
|
1093
1094
|
return cloneElement(node, {
|
|
1094
1095
|
label: renderLabel,
|
|
1095
1096
|
...nodeProps,
|
|
1096
|
-
type,
|
|
1097
|
+
type: props.type,
|
|
1098
|
+
border,
|
|
1097
1099
|
});
|
|
1098
1100
|
}
|
|
1099
1101
|
return node;
|
|
@@ -1300,10 +1302,10 @@ function Popup(props) {
|
|
|
1300
1302
|
arrowProps: { left: arrowX, top: arrowY, pos: arrowPos },
|
|
1301
1303
|
});
|
|
1302
1304
|
};
|
|
1305
|
+
const { observe, unobserve, disconnect } = useResizeObserver();
|
|
1303
1306
|
useEffect(() => {
|
|
1304
|
-
if (trigger === "contextmenu")
|
|
1307
|
+
if (trigger === "contextmenu" || !observe)
|
|
1305
1308
|
return;
|
|
1306
|
-
const { observe, unobserve, disconnect } = useResizeObserver();
|
|
1307
1309
|
triggerRef.current && observe(triggerRef.current, computePosition);
|
|
1308
1310
|
if (!watchResize || !contentRef.current)
|
|
1309
1311
|
return;
|
|
@@ -1911,28 +1913,6 @@ const HookModal = (props) => {
|
|
|
1911
1913
|
return jsx(Modal, { ...mergedProps });
|
|
1912
1914
|
};
|
|
1913
1915
|
|
|
1914
|
-
const Text = (props) => {
|
|
1915
|
-
const { as: Tag = "span", size, weight, decoration, gradient, wave, style, className, children, } = props;
|
|
1916
|
-
const gradients = useMemo(() => {
|
|
1917
|
-
if (!gradient || !Array.isArray(gradient))
|
|
1918
|
-
return {};
|
|
1919
|
-
return {
|
|
1920
|
-
backgroundImage: `-webkit-linear-gradient(${gradient.join(",")})`,
|
|
1921
|
-
backgroundClip: "text",
|
|
1922
|
-
};
|
|
1923
|
-
}, [gradient]);
|
|
1924
|
-
return (jsx(Tag, { style: {
|
|
1925
|
-
fontSize: size,
|
|
1926
|
-
fontWeight: weight,
|
|
1927
|
-
textDecoration: decoration,
|
|
1928
|
-
...gradients,
|
|
1929
|
-
...style,
|
|
1930
|
-
}, className: classNames(className, {
|
|
1931
|
-
"i-text-gradient": gradient,
|
|
1932
|
-
"i-text-gradient-wave": wave,
|
|
1933
|
-
}), children: children }));
|
|
1934
|
-
};
|
|
1935
|
-
|
|
1936
1916
|
function HighLight(props) {
|
|
1937
1917
|
const { keyword, text, escape, caseSensitive, renderWord = (word) => jsx("mark", { children: word }), ...restProps } = props;
|
|
1938
1918
|
const content = useMemo(() => {
|
|
@@ -1987,6 +1967,27 @@ function Number$1(props) {
|
|
|
1987
1967
|
return jsx(Text, { ...restProps, children: text });
|
|
1988
1968
|
}
|
|
1989
1969
|
|
|
1970
|
+
const Text = (props) => {
|
|
1971
|
+
const { as: Tag = "span", size, weight, decoration, gradient, wave, style, className, children, } = props;
|
|
1972
|
+
const gradients = useMemo(() => {
|
|
1973
|
+
if (!gradient || !Array.isArray(gradient))
|
|
1974
|
+
return {};
|
|
1975
|
+
return {
|
|
1976
|
+
backgroundImage: `-webkit-linear-gradient(${gradient.join(",")})`,
|
|
1977
|
+
backgroundClip: "text",
|
|
1978
|
+
};
|
|
1979
|
+
}, [gradient]);
|
|
1980
|
+
return (jsx(Tag, { style: {
|
|
1981
|
+
fontSize: size,
|
|
1982
|
+
fontWeight: weight,
|
|
1983
|
+
textDecoration: decoration,
|
|
1984
|
+
...gradients,
|
|
1985
|
+
...style,
|
|
1986
|
+
}, className: classNames(className, {
|
|
1987
|
+
"i-text-gradient": gradient,
|
|
1988
|
+
"i-text-gradient-wave": wave,
|
|
1989
|
+
}), children: children }));
|
|
1990
|
+
};
|
|
1990
1991
|
Text.Number = Number$2;
|
|
1991
1992
|
Text.Time = Number$1;
|
|
1992
1993
|
Text.HighLight = HighLight;
|
|
@@ -2405,6 +2406,40 @@ function usePreview() {
|
|
|
2405
2406
|
return preview;
|
|
2406
2407
|
}
|
|
2407
2408
|
|
|
2409
|
+
function List(props) {
|
|
2410
|
+
const { items = [], gap = 8, columns, wrap, direction, usePreview: previewable, onClick, ...restProps } = props;
|
|
2411
|
+
const preview = usePreview();
|
|
2412
|
+
const files = useMemo(() => {
|
|
2413
|
+
return items.map((item) => {
|
|
2414
|
+
const o = {
|
|
2415
|
+
src: "",
|
|
2416
|
+
};
|
|
2417
|
+
if (typeof item === "string") {
|
|
2418
|
+
o.src = item;
|
|
2419
|
+
}
|
|
2420
|
+
else {
|
|
2421
|
+
Object.assign(o, item);
|
|
2422
|
+
}
|
|
2423
|
+
o.suffix = getSuffixByUrl(o.src) || "";
|
|
2424
|
+
o.type = getFileType(o.suffix, item["type"]);
|
|
2425
|
+
return o;
|
|
2426
|
+
});
|
|
2427
|
+
}, [items]);
|
|
2428
|
+
const handleClick = (e, i) => {
|
|
2429
|
+
onClick?.(e);
|
|
2430
|
+
previewable &&
|
|
2431
|
+
preview({
|
|
2432
|
+
items: files,
|
|
2433
|
+
initial: i,
|
|
2434
|
+
});
|
|
2435
|
+
};
|
|
2436
|
+
if (!files.length)
|
|
2437
|
+
return "";
|
|
2438
|
+
return (jsx(Flex, { className: 'i-image-list', gap: gap, columns: columns, wrap: wrap, direction: direction, children: files.map((img, i) => {
|
|
2439
|
+
return (jsx(Image, { src: img.src, size: 60, usePreview: false, onClick: (e) => handleClick(e, i), ...restProps }, i));
|
|
2440
|
+
}) }));
|
|
2441
|
+
}
|
|
2442
|
+
|
|
2408
2443
|
const Image = (props) => {
|
|
2409
2444
|
const { src, round, size, initSize, lazyload, fallback = (jsx(Icon, { icon: jsx(HideImageTwotone, {}), size: '2em', className: 'color-5' })), fit, style, className, cover, coverClass, usePreview: previewable, onLoad, onError, onClick, ...restProps } = props;
|
|
2410
2445
|
const state = useReactive({
|
|
@@ -2441,7 +2476,7 @@ const Image = (props) => {
|
|
|
2441
2476
|
if (!ref.current?.complete) {
|
|
2442
2477
|
state.status = "loading";
|
|
2443
2478
|
}
|
|
2444
|
-
if (!lazyload || !ref.current)
|
|
2479
|
+
if (!lazyload || !ref.current || !observe)
|
|
2445
2480
|
return;
|
|
2446
2481
|
observe(ref.current, (tar, visible) => {
|
|
2447
2482
|
if (!visible)
|
|
@@ -2452,7 +2487,7 @@ const Image = (props) => {
|
|
|
2452
2487
|
return () => {
|
|
2453
2488
|
ref.current && unobserve(ref.current);
|
|
2454
2489
|
};
|
|
2455
|
-
}, [src]);
|
|
2490
|
+
}, [src, observe]);
|
|
2456
2491
|
restProps[lazyload ? "data-src" : "src"] = src;
|
|
2457
2492
|
const iSize = state.status === "loading" ? initSize : undefined;
|
|
2458
2493
|
return (jsx("div", { style: {
|
|
@@ -2464,41 +2499,6 @@ const Image = (props) => {
|
|
|
2464
2499
|
[`i-image-${state.status}`]: state.status,
|
|
2465
2500
|
}), children: state.status === "error" ? (fallback) : (jsxs(Fragment, { children: [src && (jsx("img", { ref: ref, style: { objectFit: fit, width: wh, height: wh }, ...restProps, onLoad: handleLoad, onError: handleError, onClick: handleClick })), src && state.status === "loading" && jsx(Loading, { absolute: true }), cover && (jsx("div", { className: classNames("i-image-cover", coverClass), onClick: handleClick, children: cover }))] })) }));
|
|
2466
2501
|
};
|
|
2467
|
-
|
|
2468
|
-
function List(props) {
|
|
2469
|
-
const { items = [], gap = 8, columns, wrap, direction, usePreview: previewable, onClick, ...restProps } = props;
|
|
2470
|
-
const preview = usePreview();
|
|
2471
|
-
const files = useMemo(() => {
|
|
2472
|
-
return items.map((item) => {
|
|
2473
|
-
const o = {
|
|
2474
|
-
src: "",
|
|
2475
|
-
};
|
|
2476
|
-
if (typeof item === "string") {
|
|
2477
|
-
o.src = item;
|
|
2478
|
-
}
|
|
2479
|
-
else {
|
|
2480
|
-
Object.assign(o, item);
|
|
2481
|
-
}
|
|
2482
|
-
o.suffix = getSuffixByUrl(o.src) || "";
|
|
2483
|
-
o.type = getFileType(o.suffix, item["type"]);
|
|
2484
|
-
return o;
|
|
2485
|
-
});
|
|
2486
|
-
}, [items]);
|
|
2487
|
-
const handleClick = (e, i) => {
|
|
2488
|
-
onClick?.(e);
|
|
2489
|
-
previewable &&
|
|
2490
|
-
preview({
|
|
2491
|
-
items: files,
|
|
2492
|
-
initial: i,
|
|
2493
|
-
});
|
|
2494
|
-
};
|
|
2495
|
-
if (!files.length)
|
|
2496
|
-
return "";
|
|
2497
|
-
return (jsx(Flex, { className: 'i-image-list', gap: gap, columns: columns, wrap: wrap, direction: direction, children: files.map((img, i) => {
|
|
2498
|
-
return (jsx(Image, { src: img.src, size: 60, usePreview: false, onClick: (e) => handleClick(e, i), ...restProps }, i));
|
|
2499
|
-
}) }));
|
|
2500
|
-
}
|
|
2501
|
-
|
|
2502
2502
|
Image.List = List;
|
|
2503
2503
|
|
|
2504
2504
|
function InputContainer(props) {
|
|
@@ -2510,59 +2510,6 @@ function InputContainer(props) {
|
|
|
2510
2510
|
}), children: tip }))] }));
|
|
2511
2511
|
}
|
|
2512
2512
|
|
|
2513
|
-
const Input = ((props) => {
|
|
2514
|
-
const { ref, type = "text", label, name, value = props.initValue ?? "", initValue = "", prepend, append, labelInline, className, status = "normal", message, tip, clear, hideVisible, border, required, onChange, onEnter, style, ...restProps } = props;
|
|
2515
|
-
const state = useReactive({
|
|
2516
|
-
value,
|
|
2517
|
-
type,
|
|
2518
|
-
visible: false,
|
|
2519
|
-
});
|
|
2520
|
-
const handleChange = (e) => {
|
|
2521
|
-
const v = e.target.value;
|
|
2522
|
-
state.value = v;
|
|
2523
|
-
onChange?.(v, e);
|
|
2524
|
-
};
|
|
2525
|
-
const handleKeydown = (e) => {
|
|
2526
|
-
e.code === "Enter" && onEnter?.(e);
|
|
2527
|
-
};
|
|
2528
|
-
const handleHelperClick = () => {
|
|
2529
|
-
if (type === "password" && !hideVisible) {
|
|
2530
|
-
Object.assign(state, {
|
|
2531
|
-
visible: !state.visible,
|
|
2532
|
-
type: !state.visible ? "text" : "password",
|
|
2533
|
-
});
|
|
2534
|
-
return;
|
|
2535
|
-
}
|
|
2536
|
-
const v = "";
|
|
2537
|
-
onChange?.(v);
|
|
2538
|
-
};
|
|
2539
|
-
const HelperIcon = useMemo(() => {
|
|
2540
|
-
if (type === "password") {
|
|
2541
|
-
return state.visible ? jsx(VisibilityRound, {}) : jsx(VisibilityOffRound, {});
|
|
2542
|
-
}
|
|
2543
|
-
return undefined;
|
|
2544
|
-
}, [state.visible]);
|
|
2545
|
-
useEffect(() => {
|
|
2546
|
-
state.value = value;
|
|
2547
|
-
}, [value]);
|
|
2548
|
-
const inputProps = {
|
|
2549
|
-
ref,
|
|
2550
|
-
type: state.type,
|
|
2551
|
-
name,
|
|
2552
|
-
value: state.value,
|
|
2553
|
-
className: classNames("i-input", `i-input-${type}`),
|
|
2554
|
-
onChange: handleChange,
|
|
2555
|
-
onKeyDown: handleKeydown,
|
|
2556
|
-
...restProps,
|
|
2557
|
-
};
|
|
2558
|
-
const clearable = clear && state.value;
|
|
2559
|
-
const showHelper = type === "password" && !!state.value;
|
|
2560
|
-
return (jsx(InputContainer, { label: label, labelInline: labelInline, className: className, style: style, tip: message ?? tip, status: status, required: required, children: jsxs("div", { className: classNames("i-input-item", {
|
|
2561
|
-
[`i-input-${status}`]: status !== "normal",
|
|
2562
|
-
"i-input-borderless": !border,
|
|
2563
|
-
}), children: [prepend && jsx("div", { className: 'i-input-prepend', children: prepend }), jsx("input", { ...inputProps }), jsx(Helpericon, { active: !!clearable || showHelper, icon: HelperIcon, onClick: handleHelperClick }), append && jsx("div", { className: 'i-input-append', children: append })] }) }));
|
|
2564
|
-
});
|
|
2565
|
-
|
|
2566
2513
|
const Number = (props) => {
|
|
2567
2514
|
const { ref, label, name, value = props.initValue ?? "", initValue, labelInline, step = 1, min = -Infinity, max = Infinity, thousand, precision, type, className, status = "normal", append, border, prepend, message, tip, hideControl, style, onChange, onEnter, onInput, onBlur, ...restProps } = props;
|
|
2568
2515
|
const state = useReactive({
|
|
@@ -2701,6 +2648,58 @@ const Textarea = (props) => {
|
|
|
2701
2648
|
}), children: jsx("textarea", { ...inputProps }) }) }));
|
|
2702
2649
|
};
|
|
2703
2650
|
|
|
2651
|
+
const Input = ((props) => {
|
|
2652
|
+
const { ref, type = "text", label, name, value = props.initValue ?? "", initValue = "", prepend, append, labelInline, className, status = "normal", message, tip, clear, hideVisible, border, required, onChange, onEnter, style, ...restProps } = props;
|
|
2653
|
+
const state = useReactive({
|
|
2654
|
+
value,
|
|
2655
|
+
type,
|
|
2656
|
+
visible: false,
|
|
2657
|
+
});
|
|
2658
|
+
const handleChange = (e) => {
|
|
2659
|
+
const v = e.target.value;
|
|
2660
|
+
state.value = v;
|
|
2661
|
+
onChange?.(v, e);
|
|
2662
|
+
};
|
|
2663
|
+
const handleKeydown = (e) => {
|
|
2664
|
+
e.code === "Enter" && onEnter?.(e);
|
|
2665
|
+
};
|
|
2666
|
+
const handleHelperClick = () => {
|
|
2667
|
+
if (type === "password" && !hideVisible) {
|
|
2668
|
+
Object.assign(state, {
|
|
2669
|
+
visible: !state.visible,
|
|
2670
|
+
type: !state.visible ? "text" : "password",
|
|
2671
|
+
});
|
|
2672
|
+
return;
|
|
2673
|
+
}
|
|
2674
|
+
const v = "";
|
|
2675
|
+
onChange?.(v);
|
|
2676
|
+
};
|
|
2677
|
+
const HelperIcon = useMemo(() => {
|
|
2678
|
+
if (type === "password") {
|
|
2679
|
+
return state.visible ? jsx(VisibilityRound, {}) : jsx(VisibilityOffRound, {});
|
|
2680
|
+
}
|
|
2681
|
+
return undefined;
|
|
2682
|
+
}, [state.visible]);
|
|
2683
|
+
useEffect(() => {
|
|
2684
|
+
state.value = value;
|
|
2685
|
+
}, [value]);
|
|
2686
|
+
const inputProps = {
|
|
2687
|
+
ref,
|
|
2688
|
+
type: state.type,
|
|
2689
|
+
name,
|
|
2690
|
+
value: state.value,
|
|
2691
|
+
className: classNames("i-input", `i-input-${type}`),
|
|
2692
|
+
onChange: handleChange,
|
|
2693
|
+
onKeyDown: handleKeydown,
|
|
2694
|
+
...restProps,
|
|
2695
|
+
};
|
|
2696
|
+
const clearable = clear && state.value;
|
|
2697
|
+
const showHelper = type === "password" && !!state.value;
|
|
2698
|
+
return (jsx(InputContainer, { label: label, labelInline: labelInline, className: className, style: style, tip: message ?? tip, status: status, required: required, children: jsxs("div", { className: classNames("i-input-item", {
|
|
2699
|
+
[`i-input-${status}`]: status !== "normal",
|
|
2700
|
+
"i-input-borderless": !border,
|
|
2701
|
+
}), children: [prepend && jsx("div", { className: 'i-input-prepend', children: prepend }), jsx("input", { ...inputProps }), jsx(Helpericon, { active: !!clearable || showHelper, icon: HelperIcon, onClick: handleHelperClick }), append && jsx("div", { className: 'i-input-append', children: append })] }) }));
|
|
2702
|
+
});
|
|
2704
2703
|
Input.Textarea = Textarea;
|
|
2705
2704
|
Input.Number = Number;
|
|
2706
2705
|
Input.Range = Range;
|
|
@@ -3925,7 +3924,7 @@ const Tabs = ((props) => {
|
|
|
3925
3924
|
state.active = key;
|
|
3926
3925
|
};
|
|
3927
3926
|
useEffect(() => {
|
|
3928
|
-
if (!size || hideMore)
|
|
3927
|
+
if (!size || hideMore || !observe)
|
|
3929
3928
|
return;
|
|
3930
3929
|
const { scrollHeight, scrollWidth } = navsRef.current;
|
|
3931
3930
|
const { width, height } = size;
|
|
@@ -3971,7 +3970,7 @@ const Tabs = ((props) => {
|
|
|
3971
3970
|
open(active);
|
|
3972
3971
|
}, [active]);
|
|
3973
3972
|
useEffect(() => {
|
|
3974
|
-
if (hideMore)
|
|
3973
|
+
if (hideMore || !unobserve)
|
|
3975
3974
|
return;
|
|
3976
3975
|
return () => {
|
|
3977
3976
|
navRefs.current?.map(unobserve);
|
|
@@ -3,8 +3,9 @@ import { HTMLAttributes, ReactNode, RefObject } from 'react';
|
|
|
3
3
|
interface IList extends HTMLAttributes<HTMLUListElement> {
|
|
4
4
|
label?: ReactNode | ((i: number) => ReactNode);
|
|
5
5
|
type?: "option" | "default";
|
|
6
|
+
border?: boolean;
|
|
6
7
|
}
|
|
7
|
-
interface IListItem extends HTMLAttributes<HTMLLIElement>, Pick<IList, "type"> {
|
|
8
|
+
interface IListItem extends HTMLAttributes<HTMLLIElement>, Pick<IList, "type" | "border"> {
|
|
8
9
|
ref?: RefObject<HTMLLIElement | null>;
|
|
9
10
|
active?: boolean;
|
|
10
11
|
align?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ioca/react",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.75",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"rollup-plugin-dts": "^6.1.1",
|
|
45
45
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
46
46
|
"rollup-plugin-scss": "^4.0.0",
|
|
47
|
-
"sass": "^1.
|
|
47
|
+
"sass": "^1.86.0",
|
|
48
48
|
"typescript": "^5.7.2",
|
|
49
49
|
"vite": "^6.0.2",
|
|
50
50
|
"vite-plugin-dynamic-import": "^1.6.0"
|