@ioca/react 1.3.72 → 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.
Files changed (96) hide show
  1. package/lib/cjs/components/affix/totop.js +1 -2
  2. package/lib/cjs/components/affix/totop.js.map +1 -1
  3. package/lib/cjs/components/button/button.js +4 -0
  4. package/lib/cjs/components/button/button.js.map +1 -1
  5. package/lib/cjs/components/button/index.js +1 -4
  6. package/lib/cjs/components/button/index.js.map +1 -1
  7. package/lib/cjs/components/editor/controls.js +1 -2
  8. package/lib/cjs/components/editor/controls.js.map +1 -1
  9. package/lib/cjs/components/image/image.js +2 -0
  10. package/lib/cjs/components/image/image.js.map +1 -1
  11. package/lib/cjs/components/image/index.js +1 -2
  12. package/lib/cjs/components/image/index.js.map +1 -1
  13. package/lib/cjs/components/input/index.js +1 -6
  14. package/lib/cjs/components/input/index.js.map +1 -1
  15. package/lib/cjs/components/input/input.js +6 -0
  16. package/lib/cjs/components/input/input.js.map +1 -1
  17. package/lib/cjs/components/modal/index.js +1 -2
  18. package/lib/cjs/components/modal/index.js.map +1 -1
  19. package/lib/cjs/components/modal/modal.js +3 -2
  20. package/lib/cjs/components/modal/modal.js.map +1 -1
  21. package/lib/cjs/components/picker/colors/footer.js +2 -4
  22. package/lib/cjs/components/picker/colors/footer.js.map +1 -1
  23. package/lib/cjs/components/picker/dates/index.js +1 -2
  24. package/lib/cjs/components/picker/dates/index.js.map +1 -1
  25. package/lib/cjs/components/picker/time/index.js +1 -2
  26. package/lib/cjs/components/picker/time/index.js.map +1 -1
  27. package/lib/cjs/components/popconfirm/popconfirm.js +1 -2
  28. package/lib/cjs/components/popconfirm/popconfirm.js.map +1 -1
  29. package/lib/cjs/components/progress/circle.js +0 -1
  30. package/lib/cjs/components/progress/circle.js.map +1 -1
  31. package/lib/cjs/components/tabs/tabs.js +1 -2
  32. package/lib/cjs/components/tabs/tabs.js.map +1 -1
  33. package/lib/cjs/components/text/index.js +1 -6
  34. package/lib/cjs/components/text/index.js.map +1 -1
  35. package/lib/cjs/components/text/text.js +6 -0
  36. package/lib/cjs/components/text/text.js.map +1 -1
  37. package/lib/cjs/components/upload/renderFile.js +1 -2
  38. package/lib/cjs/components/upload/renderFile.js.map +1 -1
  39. package/lib/cjs/components/upload/upload.js +1 -2
  40. package/lib/cjs/components/upload/upload.js.map +1 -1
  41. package/lib/cjs/components/video/video.js +1 -3
  42. package/lib/cjs/components/video/video.js.map +1 -1
  43. package/lib/cjs/index.js +10 -15
  44. package/lib/cjs/index.js.map +1 -1
  45. package/lib/cjs/js/usePreview/content.js +1 -2
  46. package/lib/cjs/js/usePreview/content.js.map +1 -1
  47. package/lib/css/index.css +1 -1
  48. package/lib/css/index.css.map +1 -1
  49. package/lib/es/components/affix/totop.js +1 -2
  50. package/lib/es/components/affix/totop.js.map +1 -1
  51. package/lib/es/components/button/button.js +4 -0
  52. package/lib/es/components/button/button.js.map +1 -1
  53. package/lib/es/components/button/index.js +1 -4
  54. package/lib/es/components/button/index.js.map +1 -1
  55. package/lib/es/components/editor/controls.js +1 -2
  56. package/lib/es/components/editor/controls.js.map +1 -1
  57. package/lib/es/components/image/image.js +2 -0
  58. package/lib/es/components/image/image.js.map +1 -1
  59. package/lib/es/components/image/index.js +1 -2
  60. package/lib/es/components/image/index.js.map +1 -1
  61. package/lib/es/components/input/index.js +1 -6
  62. package/lib/es/components/input/index.js.map +1 -1
  63. package/lib/es/components/input/input.js +6 -0
  64. package/lib/es/components/input/input.js.map +1 -1
  65. package/lib/es/components/modal/index.js +1 -2
  66. package/lib/es/components/modal/index.js.map +1 -1
  67. package/lib/es/components/modal/modal.js +3 -2
  68. package/lib/es/components/modal/modal.js.map +1 -1
  69. package/lib/es/components/picker/colors/footer.js +2 -4
  70. package/lib/es/components/picker/colors/footer.js.map +1 -1
  71. package/lib/es/components/picker/dates/index.js +1 -2
  72. package/lib/es/components/picker/dates/index.js.map +1 -1
  73. package/lib/es/components/picker/time/index.js +1 -2
  74. package/lib/es/components/picker/time/index.js.map +1 -1
  75. package/lib/es/components/popconfirm/popconfirm.js +1 -2
  76. package/lib/es/components/popconfirm/popconfirm.js.map +1 -1
  77. package/lib/es/components/progress/circle.js +0 -1
  78. package/lib/es/components/progress/circle.js.map +1 -1
  79. package/lib/es/components/tabs/tabs.js +1 -2
  80. package/lib/es/components/tabs/tabs.js.map +1 -1
  81. package/lib/es/components/text/index.js +1 -6
  82. package/lib/es/components/text/index.js.map +1 -1
  83. package/lib/es/components/text/text.js +6 -0
  84. package/lib/es/components/text/text.js.map +1 -1
  85. package/lib/es/components/upload/renderFile.js +1 -2
  86. package/lib/es/components/upload/renderFile.js.map +1 -1
  87. package/lib/es/components/upload/upload.js +1 -2
  88. package/lib/es/components/upload/upload.js.map +1 -1
  89. package/lib/es/components/video/video.js +1 -3
  90. package/lib/es/components/video/video.js.map +1 -1
  91. package/lib/es/index.js +5 -10
  92. package/lib/es/index.js.map +1 -1
  93. package/lib/es/js/usePreview/content.js +1 -2
  94. package/lib/es/js/usePreview/content.js.map +1 -1
  95. package/lib/index.js +186 -191
  96. 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 { 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, SyncAltRound, MoreHorizRound, SearchRound, CheckRound, UnfoldMoreRound, CalendarMonthTwotone, AccessTimeRound, InfoOutlined, KeyboardArrowDownRound, ListAltRound, PlusSharp } from '@ricons/material';
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
 
@@ -1765,6 +1764,33 @@ const Form = (props) => {
1765
1764
  Form.useForm = useForm;
1766
1765
  Form.Field = Field;
1767
1766
 
1767
+ function useModal() {
1768
+ const ref = useRef(null);
1769
+ const handleOpen = (props) => {
1770
+ const unMount = renderNode(jsx(HookModal, { ref: ref, visible: true, ...props, onClose: () => {
1771
+ props.onClose?.();
1772
+ unMount?.();
1773
+ } }));
1774
+ };
1775
+ const handleUpdate = (props) => {
1776
+ if (!ref.current)
1777
+ return;
1778
+ const { update } = ref.current;
1779
+ update(props);
1780
+ };
1781
+ const handleClose = () => {
1782
+ if (!ref.current)
1783
+ return;
1784
+ const { close } = ref.current;
1785
+ close();
1786
+ };
1787
+ return {
1788
+ open: handleOpen,
1789
+ update: handleUpdate,
1790
+ close: handleClose,
1791
+ };
1792
+ }
1793
+
1768
1794
  function DefaultContent(props) {
1769
1795
  const { title, footer, hideCloseButton, footerLeft, okButtonProps, cancelButtonProps, children, onOk, onClose, } = props;
1770
1796
  const showHeader = title || !hideCloseButton;
@@ -1862,6 +1888,7 @@ function Modal(props) {
1862
1888
  onClick?.(e);
1863
1889
  }, ...restProps, children: [customized && children, !customized && (jsx(DefaultContent, { title: title, hideCloseButton: hideCloseButton, footer: footer, okButtonProps: okButtonProps, cancelButtonProps: cancelButtonProps, children: children, footerLeft: footerLeft, onOk: onOk, onClose: handleHide }))] }) }), document?.body ?? null);
1864
1890
  }
1891
+ Modal.useModal = useModal;
1865
1892
 
1866
1893
  const HookModal = (props) => {
1867
1894
  const { ref } = props;
@@ -1883,28 +1910,6 @@ const HookModal = (props) => {
1883
1910
  return jsx(Modal, { ...mergedProps });
1884
1911
  };
1885
1912
 
1886
- const Text = (props) => {
1887
- const { as: Tag = "span", size, weight, decoration, gradient, wave, style, className, children, } = props;
1888
- const gradients = useMemo(() => {
1889
- if (!gradient || !Array.isArray(gradient))
1890
- return {};
1891
- return {
1892
- backgroundImage: `-webkit-linear-gradient(${gradient.join(",")})`,
1893
- backgroundClip: "text",
1894
- };
1895
- }, [gradient]);
1896
- return (jsx(Tag, { style: {
1897
- fontSize: size,
1898
- fontWeight: weight,
1899
- textDecoration: decoration,
1900
- ...gradients,
1901
- ...style,
1902
- }, className: classNames(className, {
1903
- "i-text-gradient": gradient,
1904
- "i-text-gradient-wave": wave,
1905
- }), children: children }));
1906
- };
1907
-
1908
1913
  function HighLight(props) {
1909
1914
  const { keyword, text, escape, caseSensitive, renderWord = (word) => jsx("mark", { children: word }), ...restProps } = props;
1910
1915
  const content = useMemo(() => {
@@ -1959,6 +1964,27 @@ function Number$1(props) {
1959
1964
  return jsx(Text, { ...restProps, children: text });
1960
1965
  }
1961
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
+ };
1962
1988
  Text.Number = Number$2;
1963
1989
  Text.Time = Number$1;
1964
1990
  Text.HighLight = HighLight;
@@ -2377,6 +2403,40 @@ function usePreview() {
2377
2403
  return preview;
2378
2404
  }
2379
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
+
2380
2440
  const Image = (props) => {
2381
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;
2382
2442
  const state = useReactive({
@@ -2436,41 +2496,6 @@ const Image = (props) => {
2436
2496
  [`i-image-${state.status}`]: state.status,
2437
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 }))] })) }));
2438
2498
  };
2439
-
2440
- function List(props) {
2441
- const { items = [], gap = 8, columns, wrap, direction, usePreview: previewable, onClick, ...restProps } = props;
2442
- const preview = usePreview();
2443
- const files = useMemo(() => {
2444
- return items.map((item) => {
2445
- const o = {
2446
- src: "",
2447
- };
2448
- if (typeof item === "string") {
2449
- o.src = item;
2450
- }
2451
- else {
2452
- Object.assign(o, item);
2453
- }
2454
- o.suffix = getSuffixByUrl(o.src) || "";
2455
- o.type = getFileType(o.suffix, item["type"]);
2456
- return o;
2457
- });
2458
- }, [items]);
2459
- const handleClick = (e, i) => {
2460
- onClick?.(e);
2461
- previewable &&
2462
- preview({
2463
- items: files,
2464
- initial: i,
2465
- });
2466
- };
2467
- if (!files.length)
2468
- return "";
2469
- return (jsx(Flex, { className: 'i-image-list', gap: gap, columns: columns, wrap: wrap, direction: direction, children: files.map((img, i) => {
2470
- return (jsx(Image, { src: img.src, size: 60, usePreview: false, onClick: (e) => handleClick(e, i), ...restProps }, i));
2471
- }) }));
2472
- }
2473
-
2474
2499
  Image.List = List;
2475
2500
 
2476
2501
  function InputContainer(props) {
@@ -2482,59 +2507,6 @@ function InputContainer(props) {
2482
2507
  }), children: tip }))] }));
2483
2508
  }
2484
2509
 
2485
- const Input = ((props) => {
2486
- 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;
2487
- const state = useReactive({
2488
- value,
2489
- type,
2490
- visible: false,
2491
- });
2492
- const handleChange = (e) => {
2493
- const v = e.target.value;
2494
- state.value = v;
2495
- onChange?.(v, e);
2496
- };
2497
- const handleKeydown = (e) => {
2498
- e.code === "Enter" && onEnter?.(e);
2499
- };
2500
- const handleHelperClick = () => {
2501
- if (type === "password" && !hideVisible) {
2502
- Object.assign(state, {
2503
- visible: !state.visible,
2504
- type: !state.visible ? "text" : "password",
2505
- });
2506
- return;
2507
- }
2508
- const v = "";
2509
- onChange?.(v);
2510
- };
2511
- const HelperIcon = useMemo(() => {
2512
- if (type === "password") {
2513
- return state.visible ? jsx(VisibilityRound, {}) : jsx(VisibilityOffRound, {});
2514
- }
2515
- return undefined;
2516
- }, [state.visible]);
2517
- useEffect(() => {
2518
- state.value = value;
2519
- }, [value]);
2520
- const inputProps = {
2521
- ref,
2522
- type: state.type,
2523
- name,
2524
- value: state.value,
2525
- className: classNames("i-input", `i-input-${type}`),
2526
- onChange: handleChange,
2527
- onKeyDown: handleKeydown,
2528
- ...restProps,
2529
- };
2530
- const clearable = clear && state.value;
2531
- const showHelper = type === "password" && !!state.value;
2532
- 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", {
2533
- [`i-input-${status}`]: status !== "normal",
2534
- "i-input-borderless": !border,
2535
- }), 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 })] }) }));
2536
- });
2537
-
2538
2510
  const Number = (props) => {
2539
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;
2540
2512
  const state = useReactive({
@@ -2673,6 +2645,58 @@ const Textarea = (props) => {
2673
2645
  }), children: jsx("textarea", { ...inputProps }) }) }));
2674
2646
  };
2675
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
+ });
2676
2700
  Input.Textarea = Textarea;
2677
2701
  Input.Number = Number;
2678
2702
  Input.Range = Range;
@@ -2852,35 +2876,6 @@ if (typeof window !== "undefined") {
2852
2876
  }
2853
2877
  }
2854
2878
 
2855
- function useModal() {
2856
- const ref = useRef(null);
2857
- const handleOpen = (props) => {
2858
- const unMount = renderNode(jsx(HookModal, { ref: ref, visible: true, ...props, onClose: () => {
2859
- props.onClose?.();
2860
- unMount?.();
2861
- } }));
2862
- };
2863
- const handleUpdate = (props) => {
2864
- if (!ref.current)
2865
- return;
2866
- const { update } = ref.current;
2867
- update(props);
2868
- };
2869
- const handleClose = () => {
2870
- if (!ref.current)
2871
- return;
2872
- const { close } = ref.current;
2873
- close();
2874
- };
2875
- return {
2876
- open: handleOpen,
2877
- update: handleUpdate,
2878
- close: handleClose,
2879
- };
2880
- }
2881
-
2882
- Modal.useModal = useModal;
2883
-
2884
2879
  const Page = (props) => {
2885
2880
  const { page, active, children, onChange } = props;
2886
2881
  const [loading, setLoading] = useState(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ioca/react",
3
- "version": "1.3.72",
3
+ "version": "1.3.74",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",