@ioca/react 1.3.73 → 1.3.74
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 -2
- package/lib/cjs/components/affix/totop.js.map +1 -1
- package/lib/cjs/components/button/button.js +4 -0
- package/lib/cjs/components/button/button.js.map +1 -1
- package/lib/cjs/components/button/index.js +1 -4
- package/lib/cjs/components/button/index.js.map +1 -1
- package/lib/cjs/components/editor/controls.js +1 -2
- package/lib/cjs/components/editor/controls.js.map +1 -1
- package/lib/cjs/components/image/image.js +2 -0
- 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/modal/modal.js +1 -2
- package/lib/cjs/components/modal/modal.js.map +1 -1
- package/lib/cjs/components/picker/colors/footer.js +2 -4
- 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 -2
- package/lib/cjs/components/popconfirm/popconfirm.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 +1 -2
- 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 -2
- package/lib/cjs/components/upload/upload.js.map +1 -1
- package/lib/cjs/components/video/video.js +1 -3
- package/lib/cjs/components/video/video.js.map +1 -1
- package/lib/cjs/index.js +8 -12
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/js/usePreview/content.js +1 -2
- package/lib/cjs/js/usePreview/content.js.map +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 -2
- package/lib/es/components/affix/totop.js.map +1 -1
- package/lib/es/components/button/button.js +4 -0
- package/lib/es/components/button/button.js.map +1 -1
- package/lib/es/components/button/index.js +1 -4
- package/lib/es/components/button/index.js.map +1 -1
- package/lib/es/components/editor/controls.js +1 -2
- package/lib/es/components/editor/controls.js.map +1 -1
- package/lib/es/components/image/image.js +2 -0
- 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/modal/modal.js +1 -2
- package/lib/es/components/modal/modal.js.map +1 -1
- package/lib/es/components/picker/colors/footer.js +2 -4
- 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 -2
- package/lib/es/components/popconfirm/popconfirm.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 +1 -2
- 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 -2
- package/lib/es/components/upload/upload.js.map +1 -1
- package/lib/es/components/video/video.js +1 -3
- package/lib/es/components/video/video.js.map +1 -1
- package/lib/es/index.js +4 -8
- package/lib/es/index.js.map +1 -1
- package/lib/es/js/usePreview/content.js +1 -2
- package/lib/es/js/usePreview/content.js.map +1 -1
- package/lib/index.js +158 -162
- 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, pick, title } from 'radash';
|
|
4
|
-
import {
|
|
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,
|
|
4
|
+
import { useMemo, Children, cloneElement, useEffect, createElement, 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, 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';
|
|
@@ -71,56 +71,6 @@ const Loading = (props) => {
|
|
|
71
71
|
}, children: jsx("circle", { cx: '12', cy: '12', r: '9.5', fill: 'none', strokeWidth: '3', strokeLinecap: 'round', strokeDasharray: 40, strokeDashoffset: 0 }) })), text] }));
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
-
const formatClass = ({ outline, flat, loading, disabled, size = "normal", block, round, square, secondary, className, }) => classNames("i-btn", className, {
|
|
75
|
-
"i-btn-outline": outline,
|
|
76
|
-
"i-btn-flat": flat,
|
|
77
|
-
"i-btn-block": block,
|
|
78
|
-
"i-btn-loading": loading,
|
|
79
|
-
"i-btn-square": square,
|
|
80
|
-
"i-btn-secondary": secondary,
|
|
81
|
-
[`i-btn-${size}`]: size !== "normal",
|
|
82
|
-
round,
|
|
83
|
-
disabled,
|
|
84
|
-
});
|
|
85
|
-
const Button = (props) => {
|
|
86
|
-
const { as: As = "a", ref, children, className, loading, flat, outline, square, secondary, size, round, href, ripple = true, onClick, ...restProps } = props;
|
|
87
|
-
const handleClick = (e) => {
|
|
88
|
-
if (loading || restProps.disabled) {
|
|
89
|
-
e.stopPropagation();
|
|
90
|
-
e.preventDefault();
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
onClick?.(e);
|
|
94
|
-
};
|
|
95
|
-
if (!children)
|
|
96
|
-
return jsx(Fragment, {});
|
|
97
|
-
const childNodes = [
|
|
98
|
-
loading && jsx(Loading, {}, 'loading'),
|
|
99
|
-
createElement("span", { key: "content", className: "i-btn-content" }, children),
|
|
100
|
-
];
|
|
101
|
-
const attrs = {
|
|
102
|
-
className: formatClass(props),
|
|
103
|
-
["data-ripple"]: ripple && !loading && !restProps.disabled ? "" : undefined,
|
|
104
|
-
onClick: handleClick,
|
|
105
|
-
};
|
|
106
|
-
useEffect(() => {
|
|
107
|
-
ripple && useRipple();
|
|
108
|
-
}, [ripple]);
|
|
109
|
-
if (typeof As === "string") {
|
|
110
|
-
return createElement(As, {
|
|
111
|
-
ref,
|
|
112
|
-
href,
|
|
113
|
-
...attrs,
|
|
114
|
-
...restProps,
|
|
115
|
-
}, childNodes);
|
|
116
|
-
}
|
|
117
|
-
return createElement(As, {
|
|
118
|
-
to: href || "",
|
|
119
|
-
...attrs,
|
|
120
|
-
...restProps,
|
|
121
|
-
}, childNodes);
|
|
122
|
-
};
|
|
123
|
-
|
|
124
74
|
function Group(props) {
|
|
125
75
|
const { children, vertical, buttonProps, className, style } = props;
|
|
126
76
|
const nodes = useMemo(() => {
|
|
@@ -173,6 +123,55 @@ function Toggle(props) {
|
|
|
173
123
|
}), children: state.active ? after ?? children : children }) }));
|
|
174
124
|
}
|
|
175
125
|
|
|
126
|
+
const formatClass = ({ outline, flat, loading, disabled, size = "normal", block, round, square, secondary, className, }) => classNames("i-btn", className, {
|
|
127
|
+
"i-btn-outline": outline,
|
|
128
|
+
"i-btn-flat": flat,
|
|
129
|
+
"i-btn-block": block,
|
|
130
|
+
"i-btn-loading": loading,
|
|
131
|
+
"i-btn-square": square,
|
|
132
|
+
"i-btn-secondary": secondary,
|
|
133
|
+
[`i-btn-${size}`]: size !== "normal",
|
|
134
|
+
round,
|
|
135
|
+
disabled,
|
|
136
|
+
});
|
|
137
|
+
const Button = (props) => {
|
|
138
|
+
const { as: As = "a", ref, children, className, loading, flat, outline, square, secondary, size, round, href, ripple = true, onClick, ...restProps } = props;
|
|
139
|
+
const handleClick = (e) => {
|
|
140
|
+
if (loading || restProps.disabled) {
|
|
141
|
+
e.stopPropagation();
|
|
142
|
+
e.preventDefault();
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
onClick?.(e);
|
|
146
|
+
};
|
|
147
|
+
if (!children)
|
|
148
|
+
return jsx(Fragment, {});
|
|
149
|
+
const childNodes = [
|
|
150
|
+
loading && jsx(Loading, {}, 'loading'),
|
|
151
|
+
createElement("span", { key: "content", className: "i-btn-content" }, children),
|
|
152
|
+
];
|
|
153
|
+
const attrs = {
|
|
154
|
+
className: formatClass(props),
|
|
155
|
+
["data-ripple"]: ripple && !loading && !restProps.disabled ? "" : undefined,
|
|
156
|
+
onClick: handleClick,
|
|
157
|
+
};
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
ripple && useRipple();
|
|
160
|
+
}, [ripple]);
|
|
161
|
+
if (typeof As === "string") {
|
|
162
|
+
return createElement(As, {
|
|
163
|
+
ref,
|
|
164
|
+
href,
|
|
165
|
+
...attrs,
|
|
166
|
+
...restProps,
|
|
167
|
+
}, childNodes);
|
|
168
|
+
}
|
|
169
|
+
return createElement(As, {
|
|
170
|
+
to: href || "",
|
|
171
|
+
...attrs,
|
|
172
|
+
...restProps,
|
|
173
|
+
}, childNodes);
|
|
174
|
+
};
|
|
176
175
|
Button.Toggle = Toggle;
|
|
177
176
|
Button.Group = Group;
|
|
178
177
|
|
|
@@ -1911,28 +1910,6 @@ const HookModal = (props) => {
|
|
|
1911
1910
|
return jsx(Modal, { ...mergedProps });
|
|
1912
1911
|
};
|
|
1913
1912
|
|
|
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
1913
|
function HighLight(props) {
|
|
1937
1914
|
const { keyword, text, escape, caseSensitive, renderWord = (word) => jsx("mark", { children: word }), ...restProps } = props;
|
|
1938
1915
|
const content = useMemo(() => {
|
|
@@ -1987,6 +1964,27 @@ function Number$1(props) {
|
|
|
1987
1964
|
return jsx(Text, { ...restProps, children: text });
|
|
1988
1965
|
}
|
|
1989
1966
|
|
|
1967
|
+
const Text = (props) => {
|
|
1968
|
+
const { as: Tag = "span", size, weight, decoration, gradient, wave, style, className, children, } = props;
|
|
1969
|
+
const gradients = useMemo(() => {
|
|
1970
|
+
if (!gradient || !Array.isArray(gradient))
|
|
1971
|
+
return {};
|
|
1972
|
+
return {
|
|
1973
|
+
backgroundImage: `-webkit-linear-gradient(${gradient.join(",")})`,
|
|
1974
|
+
backgroundClip: "text",
|
|
1975
|
+
};
|
|
1976
|
+
}, [gradient]);
|
|
1977
|
+
return (jsx(Tag, { style: {
|
|
1978
|
+
fontSize: size,
|
|
1979
|
+
fontWeight: weight,
|
|
1980
|
+
textDecoration: decoration,
|
|
1981
|
+
...gradients,
|
|
1982
|
+
...style,
|
|
1983
|
+
}, className: classNames(className, {
|
|
1984
|
+
"i-text-gradient": gradient,
|
|
1985
|
+
"i-text-gradient-wave": wave,
|
|
1986
|
+
}), children: children }));
|
|
1987
|
+
};
|
|
1990
1988
|
Text.Number = Number$2;
|
|
1991
1989
|
Text.Time = Number$1;
|
|
1992
1990
|
Text.HighLight = HighLight;
|
|
@@ -2405,6 +2403,40 @@ function usePreview() {
|
|
|
2405
2403
|
return preview;
|
|
2406
2404
|
}
|
|
2407
2405
|
|
|
2406
|
+
function List(props) {
|
|
2407
|
+
const { items = [], gap = 8, columns, wrap, direction, usePreview: previewable, onClick, ...restProps } = props;
|
|
2408
|
+
const preview = usePreview();
|
|
2409
|
+
const files = useMemo(() => {
|
|
2410
|
+
return items.map((item) => {
|
|
2411
|
+
const o = {
|
|
2412
|
+
src: "",
|
|
2413
|
+
};
|
|
2414
|
+
if (typeof item === "string") {
|
|
2415
|
+
o.src = item;
|
|
2416
|
+
}
|
|
2417
|
+
else {
|
|
2418
|
+
Object.assign(o, item);
|
|
2419
|
+
}
|
|
2420
|
+
o.suffix = getSuffixByUrl(o.src) || "";
|
|
2421
|
+
o.type = getFileType(o.suffix, item["type"]);
|
|
2422
|
+
return o;
|
|
2423
|
+
});
|
|
2424
|
+
}, [items]);
|
|
2425
|
+
const handleClick = (e, i) => {
|
|
2426
|
+
onClick?.(e);
|
|
2427
|
+
previewable &&
|
|
2428
|
+
preview({
|
|
2429
|
+
items: files,
|
|
2430
|
+
initial: i,
|
|
2431
|
+
});
|
|
2432
|
+
};
|
|
2433
|
+
if (!files.length)
|
|
2434
|
+
return "";
|
|
2435
|
+
return (jsx(Flex, { className: 'i-image-list', gap: gap, columns: columns, wrap: wrap, direction: direction, children: files.map((img, i) => {
|
|
2436
|
+
return (jsx(Image, { src: img.src, size: 60, usePreview: false, onClick: (e) => handleClick(e, i), ...restProps }, i));
|
|
2437
|
+
}) }));
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2408
2440
|
const Image = (props) => {
|
|
2409
2441
|
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
2442
|
const state = useReactive({
|
|
@@ -2464,41 +2496,6 @@ const Image = (props) => {
|
|
|
2464
2496
|
[`i-image-${state.status}`]: state.status,
|
|
2465
2497
|
}), 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
2498
|
};
|
|
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
2499
|
Image.List = List;
|
|
2503
2500
|
|
|
2504
2501
|
function InputContainer(props) {
|
|
@@ -2510,59 +2507,6 @@ function InputContainer(props) {
|
|
|
2510
2507
|
}), children: tip }))] }));
|
|
2511
2508
|
}
|
|
2512
2509
|
|
|
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
2510
|
const Number = (props) => {
|
|
2567
2511
|
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
2512
|
const state = useReactive({
|
|
@@ -2701,6 +2645,58 @@ const Textarea = (props) => {
|
|
|
2701
2645
|
}), children: jsx("textarea", { ...inputProps }) }) }));
|
|
2702
2646
|
};
|
|
2703
2647
|
|
|
2648
|
+
const Input = ((props) => {
|
|
2649
|
+
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;
|
|
2650
|
+
const state = useReactive({
|
|
2651
|
+
value,
|
|
2652
|
+
type,
|
|
2653
|
+
visible: false,
|
|
2654
|
+
});
|
|
2655
|
+
const handleChange = (e) => {
|
|
2656
|
+
const v = e.target.value;
|
|
2657
|
+
state.value = v;
|
|
2658
|
+
onChange?.(v, e);
|
|
2659
|
+
};
|
|
2660
|
+
const handleKeydown = (e) => {
|
|
2661
|
+
e.code === "Enter" && onEnter?.(e);
|
|
2662
|
+
};
|
|
2663
|
+
const handleHelperClick = () => {
|
|
2664
|
+
if (type === "password" && !hideVisible) {
|
|
2665
|
+
Object.assign(state, {
|
|
2666
|
+
visible: !state.visible,
|
|
2667
|
+
type: !state.visible ? "text" : "password",
|
|
2668
|
+
});
|
|
2669
|
+
return;
|
|
2670
|
+
}
|
|
2671
|
+
const v = "";
|
|
2672
|
+
onChange?.(v);
|
|
2673
|
+
};
|
|
2674
|
+
const HelperIcon = useMemo(() => {
|
|
2675
|
+
if (type === "password") {
|
|
2676
|
+
return state.visible ? jsx(VisibilityRound, {}) : jsx(VisibilityOffRound, {});
|
|
2677
|
+
}
|
|
2678
|
+
return undefined;
|
|
2679
|
+
}, [state.visible]);
|
|
2680
|
+
useEffect(() => {
|
|
2681
|
+
state.value = value;
|
|
2682
|
+
}, [value]);
|
|
2683
|
+
const inputProps = {
|
|
2684
|
+
ref,
|
|
2685
|
+
type: state.type,
|
|
2686
|
+
name,
|
|
2687
|
+
value: state.value,
|
|
2688
|
+
className: classNames("i-input", `i-input-${type}`),
|
|
2689
|
+
onChange: handleChange,
|
|
2690
|
+
onKeyDown: handleKeydown,
|
|
2691
|
+
...restProps,
|
|
2692
|
+
};
|
|
2693
|
+
const clearable = clear && state.value;
|
|
2694
|
+
const showHelper = type === "password" && !!state.value;
|
|
2695
|
+
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", {
|
|
2696
|
+
[`i-input-${status}`]: status !== "normal",
|
|
2697
|
+
"i-input-borderless": !border,
|
|
2698
|
+
}), 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 })] }) }));
|
|
2699
|
+
});
|
|
2704
2700
|
Input.Textarea = Textarea;
|
|
2705
2701
|
Input.Number = Number;
|
|
2706
2702
|
Input.Range = Range;
|