@ioca/react 1.3.86 → 1.3.88
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/button/button.js +2 -0
- package/lib/cjs/components/button/button.js.map +1 -1
- package/lib/cjs/components/button/confirm.js +58 -0
- package/lib/cjs/components/button/confirm.js.map +1 -0
- package/lib/cjs/components/drawer/drawer.js +33 -27
- package/lib/cjs/components/drawer/drawer.js.map +1 -1
- package/lib/cjs/components/dropdown/dropdown.js +6 -2
- package/lib/cjs/components/dropdown/dropdown.js.map +1 -1
- package/lib/cjs/components/form/useForm.js +8 -2
- package/lib/cjs/components/form/useForm.js.map +1 -1
- package/lib/cjs/components/input/input.js +2 -1
- package/lib/cjs/components/input/input.js.map +1 -1
- package/lib/cjs/components/input/number.js +1 -1
- package/lib/cjs/components/input/number.js.map +1 -1
- package/lib/cjs/components/input/range.js +8 -9
- package/lib/cjs/components/input/range.js.map +1 -1
- package/lib/cjs/components/input/textarea.js +1 -1
- package/lib/cjs/components/input/textarea.js.map +1 -1
- package/lib/cjs/components/modal/modal.js +14 -8
- package/lib/cjs/components/modal/modal.js.map +1 -1
- package/lib/cjs/components/popconfirm/popconfirm.js +1 -1
- package/lib/cjs/components/popconfirm/popconfirm.js.map +1 -1
- package/lib/cjs/components/progress/progress.js +3 -3
- package/lib/cjs/components/progress/progress.js.map +1 -1
- package/lib/css/index.css +1 -1
- package/lib/css/index.css.map +1 -1
- package/lib/es/components/button/button.js +2 -0
- package/lib/es/components/button/button.js.map +1 -1
- package/lib/es/components/button/confirm.js +54 -0
- package/lib/es/components/button/confirm.js.map +1 -0
- package/lib/es/components/drawer/drawer.js +34 -28
- package/lib/es/components/drawer/drawer.js.map +1 -1
- package/lib/es/components/dropdown/dropdown.js +6 -2
- package/lib/es/components/dropdown/dropdown.js.map +1 -1
- package/lib/es/components/form/useForm.js +8 -2
- package/lib/es/components/form/useForm.js.map +1 -1
- package/lib/es/components/input/input.js +2 -1
- package/lib/es/components/input/input.js.map +1 -1
- package/lib/es/components/input/number.js +1 -1
- package/lib/es/components/input/number.js.map +1 -1
- package/lib/es/components/input/range.js +8 -9
- package/lib/es/components/input/range.js.map +1 -1
- package/lib/es/components/input/textarea.js +1 -1
- package/lib/es/components/input/textarea.js.map +1 -1
- package/lib/es/components/modal/modal.js +14 -8
- package/lib/es/components/modal/modal.js.map +1 -1
- package/lib/es/components/popconfirm/popconfirm.js +1 -1
- package/lib/es/components/popconfirm/popconfirm.js.map +1 -1
- package/lib/es/components/progress/progress.js +4 -4
- package/lib/es/components/progress/progress.js.map +1 -1
- package/lib/index.js +132 -62
- package/lib/types/components/button/confirm.d.ts +6 -0
- package/lib/types/components/button/type.d.ts +9 -1
- package/lib/types/components/dropdown/type.d.ts +2 -1
- package/lib/types/components/form/type.d.ts +1 -1
- package/lib/types/type/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirm.js","sources":["../../../../packages/components/button/confirm.tsx"],"sourcesContent":["import { useReactive } from \"ahooks\";\nimport Button from \"./button\";\nimport type { IButton, IButtonConfirm } from \"./type\";\n\nconst defaultOk = {\n\tchildren: \"确定\",\n\tclassName: \"bg-error\",\n};\n\nconst defaultCancel = {\n\tchildren: \"取消\",\n\tsecondary: true,\n};\n\nexport default function Confirm(props: IButtonConfirm) {\n\tconst {\n\t\tref,\n\t\tokButtonProps,\n\t\tcancelButtonProps,\n\t\tonOk,\n\t\tonCancel,\n\t\tonClick,\n\t\t...restProps\n\t} = props;\n\n\tconst state = useReactive({\n\t\tactive: false,\n\t\tloading: false,\n\t});\n\n\tconst ok: IButton = okButtonProps\n\t\t? Object.assign({}, defaultOk, okButtonProps)\n\t\t: defaultOk;\n\tconst cancel: IButton = cancelButtonProps\n\t\t? Object.assign({}, defaultCancel, cancelButtonProps)\n\t\t: defaultCancel;\n\n\tconst handleClick = (e) => {\n\t\tonClick?.(e);\n\t\tstate.active = true;\n\t};\n\n\tconst hanldeOk = async () => {\n\t\tif (state.loading) return;\n\t\tstate.loading = true;\n\n\t\ttry {\n\t\t\tconst res = await onOk?.();\n\n\t\t\tif (res !== false) {\n\t\t\t\tstate.active = false;\n\t\t\t}\n\t\t} finally {\n\t\t\tstate.loading = false;\n\t\t}\n\t};\n\n\tconst handleCancel = () => {\n\t\tonCancel?.();\n\t\tstate.active = false;\n\t};\n\n\tif (!state.active) {\n\t\treturn <Button ref={ref} {...restProps} onClick={handleClick} />;\n\t}\n\n\treturn (\n\t\t<Button.Group>\n\t\t\t<Button {...ok} loading={state.loading} onClick={hanldeOk} />\n\t\t\t<Button\n\t\t\t\t{...cancel}\n\t\t\t\tdisabled={state.loading}\n\t\t\t\tonClick={handleCancel}\n\t\t\t/>\n\t\t</Button.Group>\n\t);\n}\n"],"names":["_jsx","_jsxs"],"mappings":";;;;AAIA,MAAM,SAAS,GAAG;AACjB,IAAA,QAAQ,EAAE,IAAI;AACd,IAAA,SAAS,EAAE,UAAU;CACrB;AAED,MAAM,aAAa,GAAG;AACrB,IAAA,QAAQ,EAAE,IAAI;AACd,IAAA,SAAS,EAAE,IAAI;CACf;AAEuB,SAAA,OAAO,CAAC,KAAqB,EAAA;AACpD,IAAA,MAAM,EACL,GAAG,EACH,aAAa,EACb,iBAAiB,EACjB,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,GAAG,SAAS,EACZ,GAAG,KAAK;IAET,MAAM,KAAK,GAAG,WAAW,CAAC;AACzB,QAAA,MAAM,EAAE,KAAK;AACb,QAAA,OAAO,EAAE,KAAK;AACd,KAAA,CAAC;IAEF,MAAM,EAAE,GAAY;UACjB,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,aAAa;UAC1C,SAAS;IACZ,MAAM,MAAM,GAAY;UACrB,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,aAAa,EAAE,iBAAiB;UAClD,aAAa;AAEhB,IAAA,MAAM,WAAW,GAAG,CAAC,CAAC,KAAI;AACzB,QAAA,OAAO,GAAG,CAAC,CAAC;AACZ,QAAA,KAAK,CAAC,MAAM,GAAG,IAAI;AACpB,KAAC;AAED,IAAA,MAAM,QAAQ,GAAG,YAAW;QAC3B,IAAI,KAAK,CAAC,OAAO;YAAE;AACnB,QAAA,KAAK,CAAC,OAAO,GAAG,IAAI;AAEpB,QAAA,IAAI;AACH,YAAA,MAAM,GAAG,GAAG,MAAM,IAAI,IAAI;AAE1B,YAAA,IAAI,GAAG,KAAK,KAAK,EAAE;AAClB,gBAAA,KAAK,CAAC,MAAM,GAAG,KAAK;;;gBAEZ;AACT,YAAA,KAAK,CAAC,OAAO,GAAG,KAAK;;AAEvB,KAAC;IAED,MAAM,YAAY,GAAG,MAAK;QACzB,QAAQ,IAAI;AACZ,QAAA,KAAK,CAAC,MAAM,GAAG,KAAK;AACrB,KAAC;AAED,IAAA,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;AAClB,QAAA,OAAOA,GAAC,CAAA,MAAM,EAAC,EAAA,GAAG,EAAE,GAAG,EAAM,GAAA,SAAS,EAAE,OAAO,EAAE,WAAW,GAAI;;AAGjE,IAAA,QACCC,IAAC,CAAA,MAAM,CAAC,KAAK,eACZD,GAAC,CAAA,MAAM,EAAK,EAAA,GAAA,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAA,CAAI,EAC7DA,GAAC,CAAA,MAAM,OACF,MAAM,EACV,QAAQ,EAAE,KAAK,CAAC,OAAO,EACvB,OAAO,EAAE,YAAY,EACpB,CAAA,CAAA,EAAA,CACY;AAEjB;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { useReactive } from 'ahooks';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import { useRef, useEffect } from 'react';
|
|
4
|
+
import { useRef, useTransition, useEffect } from 'react';
|
|
5
5
|
import { createPortal } from 'react-dom';
|
|
6
6
|
import { useKeydown } from '../../js/hooks.js';
|
|
7
7
|
import Helpericon from '../utils/helpericon/helpericon.js';
|
|
@@ -12,38 +12,42 @@ function Drawer(props) {
|
|
|
12
12
|
const state = useReactive({
|
|
13
13
|
show: visible,
|
|
14
14
|
active: visible,
|
|
15
|
-
init: false,
|
|
16
15
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const handleShow = () => {
|
|
21
|
-
if (!toggable.current)
|
|
16
|
+
const [isPending, startTransition] = useTransition();
|
|
17
|
+
const handleHide = () => {
|
|
18
|
+
if (!toggable.current || isPending)
|
|
22
19
|
return;
|
|
23
|
-
state.show = true;
|
|
24
|
-
onVisibleChange?.(true);
|
|
25
20
|
toggable.current = false;
|
|
26
|
-
|
|
27
|
-
state.active =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
startTransition(() => {
|
|
22
|
+
state.active = false;
|
|
23
|
+
setTimeout(() => {
|
|
24
|
+
if (!keepDOM) {
|
|
25
|
+
state.show = false;
|
|
26
|
+
}
|
|
27
|
+
onVisibleChange?.(false);
|
|
28
|
+
toggable.current = true;
|
|
29
|
+
onClose?.();
|
|
30
|
+
}, 240);
|
|
31
|
+
});
|
|
31
32
|
};
|
|
32
|
-
const
|
|
33
|
-
if (!toggable.current)
|
|
33
|
+
const handleShow = () => {
|
|
34
|
+
if (!toggable.current || isPending)
|
|
34
35
|
return;
|
|
36
|
+
state.show = true;
|
|
37
|
+
onVisibleChange?.(true);
|
|
35
38
|
toggable.current = false;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
state.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
onClose?.();
|
|
44
|
-
}, 240);
|
|
39
|
+
startTransition(() => {
|
|
40
|
+
// 确保 DOM 已经挂载
|
|
41
|
+
requestAnimationFrame(() => {
|
|
42
|
+
state.active = true;
|
|
43
|
+
toggable.current = true;
|
|
44
|
+
});
|
|
45
|
+
});
|
|
45
46
|
};
|
|
46
|
-
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
visible ? handleShow() : handleHide();
|
|
49
|
+
}, [visible]);
|
|
50
|
+
const handleBackdropClick = () => {
|
|
47
51
|
backdropClosable && handleHide();
|
|
48
52
|
};
|
|
49
53
|
useKeydown((e) => {
|
|
@@ -53,9 +57,11 @@ function Drawer(props) {
|
|
|
53
57
|
}, {
|
|
54
58
|
disabled: disabledEsc,
|
|
55
59
|
});
|
|
56
|
-
|
|
60
|
+
if (!state.show)
|
|
61
|
+
return null;
|
|
62
|
+
return createPortal(jsx("div", { className: classNames("i-backdrop-drawer", className, {
|
|
57
63
|
"i-active": state.active,
|
|
58
|
-
}), onClick: handleBackdropClick, ...restProps, children: jsxs("div", { className: classNames("i-drawer", `i-drawer-${position}`), onClick: (e) => e.stopPropagation(), children: [jsxs("header", { className: 'i-drawer-header', children: [header, jsx(Helpericon, {
|
|
64
|
+
}), onClick: handleBackdropClick, ...restProps, children: jsxs("div", { className: classNames("i-drawer", `i-drawer-${position}`), onClick: (e) => e.stopPropagation(), children: [header && (jsxs("header", { className: 'i-drawer-header', children: [header, !hideCloseButton && (jsx(Helpericon, { className: 'i-drawer-close', onClick: handleHide }))] })), jsx("div", { className: 'i-drawer-content', children: children }), footer && jsx("div", { className: 'i-drawer-footer', children: footer })] }) }), document.body);
|
|
59
65
|
}
|
|
60
66
|
|
|
61
67
|
export { Drawer as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drawer.js","sources":["../../../../packages/components/drawer/drawer.tsx"],"sourcesContent":["import { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { useEffect, useRef } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { useKeydown } from \"../../js/hooks\";\nimport Helpericon from \"../utils/helpericon\";\nimport \"./index.css\";\nimport { IDrawer } from \"./type\";\n\nfunction Drawer(props: IDrawer) {\n\tconst {\n\t\tvisible,\n\t\tposition = \"left\",\n\t\theader,\n\t\tfooter,\n\t\tbackdropClosable = true,\n\t\thideCloseButton,\n\t\tkeepDOM,\n\t\tclassName,\n\t\tdisabledEsc,\n\t\tchildren,\n\t\tonVisibleChange,\n\t\tonClose,\n\t\t...restProps\n\t} = props;\n\tconst toggable = useRef(true);\n\tconst state = useReactive({\n\t\tshow: visible,\n\t\tactive: visible,\n\t
|
|
1
|
+
{"version":3,"file":"drawer.js","sources":["../../../../packages/components/drawer/drawer.tsx"],"sourcesContent":["import { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { useEffect, useRef, useTransition } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { useKeydown } from \"../../js/hooks\";\nimport Helpericon from \"../utils/helpericon\";\nimport \"./index.css\";\nimport { IDrawer } from \"./type\";\n\nfunction Drawer(props: IDrawer) {\n\tconst {\n\t\tvisible,\n\t\tposition = \"left\",\n\t\theader,\n\t\tfooter,\n\t\tbackdropClosable = true,\n\t\thideCloseButton,\n\t\tkeepDOM,\n\t\tclassName,\n\t\tdisabledEsc,\n\t\tchildren,\n\t\tonVisibleChange,\n\t\tonClose,\n\t\t...restProps\n\t} = props;\n\n\tconst toggable = useRef(true);\n\tconst state = useReactive({\n\t\tshow: visible,\n\t\tactive: visible,\n\t});\n\tconst [isPending, startTransition] = useTransition();\n\n\tconst handleHide = () => {\n\t\tif (!toggable.current || isPending) return;\n\t\ttoggable.current = false;\n\n\t\tstartTransition(() => {\n\t\t\tstate.active = false;\n\n\t\t\tsetTimeout(() => {\n\t\t\t\tif (!keepDOM) {\n\t\t\t\t\tstate.show = false;\n\t\t\t\t}\n\t\t\t\tonVisibleChange?.(false);\n\t\t\t\ttoggable.current = true;\n\t\t\t\tonClose?.();\n\t\t\t}, 240);\n\t\t});\n\t};\n\n\tconst handleShow = () => {\n\t\tif (!toggable.current || isPending) return;\n\n\t\tstate.show = true;\n\t\tonVisibleChange?.(true);\n\t\ttoggable.current = false;\n\n\t\tstartTransition(() => {\n\t\t\t// 确保 DOM 已经挂载\n\t\t\trequestAnimationFrame(() => {\n\t\t\t\tstate.active = true;\n\t\t\t\ttoggable.current = true;\n\t\t\t});\n\t\t});\n\t};\n\n\tuseEffect(() => {\n\t\tvisible ? handleShow() : handleHide();\n\t}, [visible]);\n\n\tconst handleBackdropClick = () => {\n\t\tbackdropClosable && handleHide();\n\t};\n\n\tuseKeydown(\n\t\t(e) => {\n\t\t\tif (e.code !== \"Escape\" || !visible) return;\n\t\t\thandleHide();\n\t\t},\n\t\t{\n\t\t\tdisabled: disabledEsc,\n\t\t}\n\t);\n\n\tif (!state.show) return null;\n\n\treturn createPortal(\n\t\t<div\n\t\t\tclassName={classNames(\"i-backdrop-drawer\", className, {\n\t\t\t\t\"i-active\": state.active,\n\t\t\t})}\n\t\t\tonClick={handleBackdropClick}\n\t\t\t{...restProps}\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName={classNames(\"i-drawer\", `i-drawer-${position}`)}\n\t\t\t\tonClick={(e) => e.stopPropagation()}\n\t\t\t>\n\t\t\t\t{header && (\n\t\t\t\t\t<header className='i-drawer-header'>\n\t\t\t\t\t\t{header}\n\n\t\t\t\t\t\t{!hideCloseButton && (\n\t\t\t\t\t\t\t<Helpericon\n\t\t\t\t\t\t\t\tclassName='i-drawer-close'\n\t\t\t\t\t\t\t\tonClick={handleHide}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</header>\n\t\t\t\t)}\n\n\t\t\t\t<div className='i-drawer-content'>{children}</div>\n\n\t\t\t\t{footer && <div className='i-drawer-footer'>{footer}</div>}\n\t\t\t</div>\n\t\t</div>,\n\t\tdocument.body\n\t);\n}\n\nexport default Drawer;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;AASA,SAAS,MAAM,CAAC,KAAc,EAAA;AAC7B,IAAA,MAAM,EACL,OAAO,EACP,QAAQ,GAAG,MAAM,EACjB,MAAM,EACN,MAAM,EACN,gBAAgB,GAAG,IAAI,EACvB,eAAe,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CAAC,IAAI,CACb;AACF;;;;"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useState } from 'react';
|
|
2
3
|
import List from '../list/list.js';
|
|
3
4
|
import Popup from '../popup/popup.js';
|
|
4
5
|
import Item from './item.js';
|
|
5
6
|
|
|
6
7
|
const Dropdown = (props) => {
|
|
7
|
-
const { width, content, children, ...restProps } = props;
|
|
8
|
-
|
|
8
|
+
const { visible, width, content, children, ...restProps } = props;
|
|
9
|
+
const [active, setActive] = useState(visible);
|
|
10
|
+
return (jsx(Popup, { trigger: 'click', position: 'bottom', content: jsx(List, { className: 'i-dropdown-content', style: { minWidth: width }, children: typeof content === "function"
|
|
11
|
+
? content(() => setActive(false))
|
|
12
|
+
: content }), ...restProps, touchable: true, visible: active, onVisibleChange: setActive, children: children }));
|
|
9
13
|
};
|
|
10
14
|
Dropdown.Item = Item;
|
|
11
15
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown.js","sources":["../../../../packages/components/dropdown/dropdown.tsx"],"sourcesContent":["import List from \"../list\";\nimport Popup from \"../popup\";\nimport \"./index.css\";\nimport Item from \"./item\";\nimport { IDropdown } from \"./type\";\n\nconst Dropdown = (props: IDropdown) => {\n\tconst { width, content, children, ...restProps } = props;\n\n\treturn (\n\t\t<Popup\n\t\t\ttrigger='click'\n\t\t\tposition='bottom'\n\t\t\
|
|
1
|
+
{"version":3,"file":"dropdown.js","sources":["../../../../packages/components/dropdown/dropdown.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport List from \"../list\";\nimport Popup from \"../popup\";\nimport \"./index.css\";\nimport Item from \"./item\";\nimport { IDropdown } from \"./type\";\n\nconst Dropdown = (props: IDropdown) => {\n\tconst { visible, width, content, children, ...restProps } = props;\n\tconst [active, setActive] = useState(visible);\n\n\treturn (\n\t\t<Popup\n\t\t\ttrigger='click'\n\t\t\tposition='bottom'\n\t\t\tcontent={\n\t\t\t\t<List\n\t\t\t\t\tclassName='i-dropdown-content'\n\t\t\t\t\tstyle={{ minWidth: width }}\n\t\t\t\t>\n\t\t\t\t\t{typeof content === \"function\"\n\t\t\t\t\t\t? content(() => setActive(false))\n\t\t\t\t\t\t: content}\n\t\t\t\t</List>\n\t\t\t}\n\t\t\t{...restProps}\n\t\t\ttouchable\n\t\t\tvisible={active}\n\t\t\tonVisibleChange={setActive}\n\t\t>\n\t\t\t{children}\n\t\t</Popup>\n\t);\n};\n\nDropdown.Item = Item;\n\nexport default Dropdown;\n"],"names":["_jsx"],"mappings":";;;;;;AAOA,MAAM,QAAQ,GAAG,CAAC,KAAgB,KAAI;AACrC,IAAA,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK;IACjE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC;AAE7C,IAAA,QACCA,GAAA,CAAC,KAAK,EAAA,EACL,OAAO,EAAC,OAAO,EACf,QAAQ,EAAC,QAAQ,EACjB,OAAO,EACNA,GAAC,CAAA,IAAI,EACJ,EAAA,SAAS,EAAC,oBAAoB,EAC9B,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAA,QAAA,EAEzB,OAAO,OAAO,KAAK;kBACjB,OAAO,CAAC,MAAM,SAAS,CAAC,KAAK,CAAC;AAChC,kBAAE,OAAO,EAAA,CACJ,KAEJ,SAAS,EACb,SAAS,EACT,IAAA,EAAA,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,SAAS,YAEzB,QAAQ,EAAA,CACF;AAEV;AAEA,QAAQ,CAAC,IAAI,GAAG,IAAI;;;;"}
|
|
@@ -65,7 +65,10 @@ class IFormInstance {
|
|
|
65
65
|
Object.assign(rule, o);
|
|
66
66
|
}
|
|
67
67
|
const isValid = rule.validator?.(data[field], this);
|
|
68
|
-
if (
|
|
68
|
+
if (typeof isValid === "string") {
|
|
69
|
+
rule.message = isValid;
|
|
70
|
+
}
|
|
71
|
+
if (isValid !== true) {
|
|
69
72
|
PubSub.publish(`${id}:invalid:${field}`, {
|
|
70
73
|
message: rule.message,
|
|
71
74
|
status: "error",
|
|
@@ -98,7 +101,10 @@ class IFormInstance {
|
|
|
98
101
|
Object.assign(rule, o);
|
|
99
102
|
}
|
|
100
103
|
const isValid = rule.validator?.(data[name], this);
|
|
101
|
-
if (
|
|
104
|
+
if (typeof isValid === "string") {
|
|
105
|
+
rule.message = isValid;
|
|
106
|
+
}
|
|
107
|
+
if (isValid !== true) {
|
|
102
108
|
PubSub.publish(`${id}:invalid:${name}`, {
|
|
103
109
|
message: rule.message,
|
|
104
110
|
status: "error",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useForm.js","sources":["../../../../packages/components/form/useForm.ts"],"sourcesContent":["import PubSub from \"pubsub-js\";\nimport { uid } from \"radash\";\nimport { useRef } from \"react\";\nimport { IForm, TRule } from \"./type\";\n\nexport class IFormInstance {\n\treadonly id?: string;\n\tdata: Record<string, any> = {};\n\tcacheData: Record<string, any> = {};\n\trules?: Pick<IForm, \"rules\"> = {};\n\n\tconstructor() {\n\t\tthis.id = uid(8);\n\t\tthis.data = {};\n\t}\n\n\tget(field?: string) {\n\t\treturn field ? this.data[field] : this.data;\n\t}\n\n\tset(field: any, value?: any) {\n\t\tconst id = this.id;\n\t\tif (!this.data) return;\n\n\t\tif (typeof field === \"string\") {\n\t\t\tthis.data[field] = value;\n\t\t\tthis.cacheData[field] = value;\n\t\t\tPubSub.publish(`${id}:set:${field}`, value);\n\t\t\treturn;\n\t\t}\n\n\t\tObject.keys(field).map((name) => {\n\t\t\tthis.data[name] = field[name];\n\t\t\tthis.cacheData[name] = field[name];\n\t\t\tPubSub.publish(`${id}:set:${name}`, field[name]);\n\t\t});\n\t}\n\n\tdelete(field) {\n\t\tdelete this.data[field];\n\t}\n\n\tclear() {\n\t\tif (!this.data) return;\n\t\tthis.cacheData = {};\n\n\t\tObject.keys(this.data).map((name) => {\n\t\t\tPubSub.publish(`${this.id}:set:${name}`, undefined);\n\t\t\tthis.data[name] = undefined;\n\t\t});\n\t}\n\n\tasync validate(field?: string) {\n\t\tconst { id, rules, data } = this;\n\t\tif (!rules) return data;\n\n\t\tif (field) {\n\t\t\tconst o = rules[field];\n\t\t\tconst rule: TRule = {\n\t\t\t\tvalidator: (v) =>\n\t\t\t\t\tArray.isArray(v)\n\t\t\t\t\t\t? v.length > 0\n\t\t\t\t\t\t: ![undefined, null, \"\"].includes(v),\n\t\t\t\tmessage: undefined,\n\t\t\t};\n\n\t\t\tif (typeof o === \"function\") {\n\t\t\t\trule.validator = o;\n\t\t\t} else if (o === true) {\n\t\t\t\trule.validator = (v) => ![undefined, null, \"\"].includes(v);\n\t\t\t\trule.message = \"required\";\n\t\t\t} else {\n\t\t\t\tObject.assign(rule, o);\n\t\t\t}\n\n\t\t\tconst isValid = rule.validator?.(data[field], this);\n\n\t\t\tif (
|
|
1
|
+
{"version":3,"file":"useForm.js","sources":["../../../../packages/components/form/useForm.ts"],"sourcesContent":["import PubSub from \"pubsub-js\";\nimport { uid } from \"radash\";\nimport { useRef } from \"react\";\nimport { IForm, TRule } from \"./type\";\n\nexport class IFormInstance {\n\treadonly id?: string;\n\tdata: Record<string, any> = {};\n\tcacheData: Record<string, any> = {};\n\trules?: Pick<IForm, \"rules\"> = {};\n\n\tconstructor() {\n\t\tthis.id = uid(8);\n\t\tthis.data = {};\n\t}\n\n\tget(field?: string) {\n\t\treturn field ? this.data[field] : this.data;\n\t}\n\n\tset(field: any, value?: any) {\n\t\tconst id = this.id;\n\t\tif (!this.data) return;\n\n\t\tif (typeof field === \"string\") {\n\t\t\tthis.data[field] = value;\n\t\t\tthis.cacheData[field] = value;\n\t\t\tPubSub.publish(`${id}:set:${field}`, value);\n\t\t\treturn;\n\t\t}\n\n\t\tObject.keys(field).map((name) => {\n\t\t\tthis.data[name] = field[name];\n\t\t\tthis.cacheData[name] = field[name];\n\t\t\tPubSub.publish(`${id}:set:${name}`, field[name]);\n\t\t});\n\t}\n\n\tdelete(field) {\n\t\tdelete this.data[field];\n\t}\n\n\tclear() {\n\t\tif (!this.data) return;\n\t\tthis.cacheData = {};\n\n\t\tObject.keys(this.data).map((name) => {\n\t\t\tPubSub.publish(`${this.id}:set:${name}`, undefined);\n\t\t\tthis.data[name] = undefined;\n\t\t});\n\t}\n\n\tasync validate(field?: string) {\n\t\tconst { id, rules, data } = this;\n\t\tif (!rules) return data;\n\n\t\tif (field) {\n\t\t\tconst o = rules[field];\n\t\t\tconst rule: TRule = {\n\t\t\t\tvalidator: (v) =>\n\t\t\t\t\tArray.isArray(v)\n\t\t\t\t\t\t? v.length > 0\n\t\t\t\t\t\t: ![undefined, null, \"\"].includes(v),\n\t\t\t\tmessage: undefined,\n\t\t\t};\n\n\t\t\tif (typeof o === \"function\") {\n\t\t\t\trule.validator = o;\n\t\t\t} else if (o === true) {\n\t\t\t\trule.validator = (v) => ![undefined, null, \"\"].includes(v);\n\t\t\t\trule.message = \"required\";\n\t\t\t} else {\n\t\t\t\tObject.assign(rule, o);\n\t\t\t}\n\n\t\t\tconst isValid = rule.validator?.(data[field], this);\n\t\t\tif (typeof isValid === \"string\") {\n\t\t\t\trule.message = isValid;\n\t\t\t}\n\n\t\t\tif (isValid !== true) {\n\t\t\t\tPubSub.publish(`${id}:invalid:${field}`, {\n\t\t\t\t\tmessage: rule.message,\n\t\t\t\t\tstatus: \"error\",\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tPubSub.publish(`${id}:invalid:${name}`, {\n\t\t\t\tmessage: null,\n\t\t\t\tstatus: \"normal\",\n\t\t\t});\n\t\t\treturn true;\n\t\t}\n\n\t\tlet isAllValid = true;\n\n\t\tObject.keys(data).map((name) => {\n\t\t\tconst o = rules[name];\n\t\t\tif (o === undefined) return;\n\n\t\t\tconst rule: TRule = {\n\t\t\t\tvalidator: (v) => (Array.isArray(v) ? v.length > 0 : !!v),\n\t\t\t\tmessage: undefined,\n\t\t\t};\n\n\t\t\tif (typeof o === \"function\") {\n\t\t\t\trule.validator = o;\n\t\t\t} else if (o === true) {\n\t\t\t\trule.validator = (v) => ![undefined, null, \"\"].includes(v);\n\t\t\t\trule.message = \"required\";\n\t\t\t} else {\n\t\t\t\tObject.assign(rule, o);\n\t\t\t}\n\n\t\t\tconst isValid = rule.validator?.(data[name], this);\n\t\t\tif (typeof isValid === \"string\") {\n\t\t\t\trule.message = isValid;\n\t\t\t}\n\n\t\t\tif (isValid !== true) {\n\t\t\t\tPubSub.publish(`${id}:invalid:${name}`, {\n\t\t\t\t\tmessage: rule.message,\n\t\t\t\t\tstatus: \"error\",\n\t\t\t\t});\n\t\t\t\tisAllValid = false;\n\t\t\t} else {\n\t\t\t\tPubSub.publish(`${id}:invalid:${name}`, {\n\t\t\t\t\tmessage: null,\n\t\t\t\t\tstatus: \"normal\",\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\treturn isAllValid ? Promise.resolve(data) : false;\n\t}\n}\n\nexport default function useForm(form?: IFormInstance) {\n\tconst formRef = useRef<IFormInstance>(null);\n\n\tif (!formRef.current) {\n\t\tformRef.current = form ?? new IFormInstance();\n\t}\n\n\treturn formRef.current;\n}\n"],"names":[],"mappings":";;;;MAKa,aAAa,CAAA;AAChB,IAAA,EAAE;IACX,IAAI,GAAwB,EAAE;IAC9B,SAAS,GAAwB,EAAE;IACnC,KAAK,GAA0B,EAAE;AAEjC,IAAA,WAAA,GAAA;AACC,QAAA,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;AAChB,QAAA,IAAI,CAAC,IAAI,GAAG,EAAE;;AAGf,IAAA,GAAG,CAAC,KAAc,EAAA;AACjB,QAAA,OAAO,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI;;IAG5C,GAAG,CAAC,KAAU,EAAE,KAAW,EAAA;AAC1B,QAAA,MA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,OAAO;;AAGvB,YAAA,IAAI,OAAO,KAAK,IAAI,EAAE;gBACrB,MAAM,CAAC,OAAO,CAAC,CAAA,EAAG,EAAE,CAAY,SAAA,EAAA,IAAI,EAAE,EAAE;oBACvC,OAAO,EAAE,IAAI,CAAC,OAAO;AACrB,oBAAA,MAAM,EAAE,OAAO;AACf,iBAAA,CAAC;gBACF,UAAU,GAAG,KAAK;;iBACZ;gBACN,MAAM,CAAC,OAAO,CAAC,CAAA,EAAG,EAAE,CAAY,SAAA,EAAA,IAAI,EAAE,EAAE;AACvC,oBAAA,OAAO,EAAE,IAAI;AACb,oBAAA,MAAM,EAAE,QAAQ;AAChB,iBAAA,CAAC;;AAEJ,SAAC,CAAC;AAEF,QAAA,OAAO,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK;;AAElD;AAEuB,SAAA,OAAO,CAAC,IAAoB,EAAA;AACnD,IAAA,MAAM,OAAO,GAAG,MAAM,CAAgB,IAAI,CAAC;AAE3C,IAAA,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;QACrB,OAAO,CAAC,OAAO,GAAG,IAAI,IAAI,IAAI,aAAa,EAAE;;IAG9C,OAAO,OAAO,CAAC,OAAO;AACvB;;;;"}
|
|
@@ -10,7 +10,7 @@ import Range from './range.js';
|
|
|
10
10
|
import Textarea from './textarea.js';
|
|
11
11
|
|
|
12
12
|
const Input = ((props) => {
|
|
13
|
-
const { ref, type = "text", label, name, value =
|
|
13
|
+
const { ref, type = "text", label, name, value = "", prepend, append, labelInline, className, status = "normal", message, tip, clear, width, hideVisible, border, underline, required, maxLength, onChange, onEnter, style, ...restProps } = props;
|
|
14
14
|
const state = useReactive({
|
|
15
15
|
value,
|
|
16
16
|
type,
|
|
@@ -60,6 +60,7 @@ const Input = ((props) => {
|
|
|
60
60
|
return (jsx(InputContainer, { label: label, labelInline: labelInline, className: className, style: { width, ...style }, tip: message ?? tip, status: status, required: required, children: jsxs("div", { className: classNames("i-input-item", {
|
|
61
61
|
[`i-input-${status}`]: status !== "normal",
|
|
62
62
|
"i-input-borderless": !border,
|
|
63
|
+
"i-input-underline": underline,
|
|
63
64
|
}), children: [prepend && jsx("div", { className: 'i-input-prepend', children: prepend }), jsx("input", { ...inputProps }), maxLength && state.value?.length > 0 && (jsxs("span", { className: 'color-8 pr-4 font-sm', children: [state.value.length, " / ", maxLength] })), jsx(Helpericon, { active: !!clearable || showHelper, icon: HelperIcon, onClick: handleHelperClick }), append && jsx("div", { className: 'i-input-append', children: append })] }) }));
|
|
64
65
|
});
|
|
65
66
|
Input.Textarea = Textarea;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","sources":["../../../../packages/components/input/input.tsx"],"sourcesContent":["import { VisibilityOffRound, VisibilityRound } from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { ChangeEvent, useEffect, useMemo } from \"react\";\nimport \"../../css/input.css\";\nimport Helpericon from \"../utils/helpericon\";\nimport InputContainer from \"./container\";\nimport Number from \"./number\";\nimport Range from \"./range\";\nimport Textarea from \"./textarea\";\nimport type { CompositionInput, IInput } from \"./type\";\n\nconst Input = ((props: IInput) => {\n\tconst {\n\t\tref,\n\t\ttype = \"text\",\n\t\tlabel,\n\t\tname,\n\t\tvalue =
|
|
1
|
+
{"version":3,"file":"input.js","sources":["../../../../packages/components/input/input.tsx"],"sourcesContent":["import { VisibilityOffRound, VisibilityRound } from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { ChangeEvent, useEffect, useMemo } from \"react\";\nimport \"../../css/input.css\";\nimport Helpericon from \"../utils/helpericon\";\nimport InputContainer from \"./container\";\nimport Number from \"./number\";\nimport Range from \"./range\";\nimport Textarea from \"./textarea\";\nimport type { CompositionInput, IInput } from \"./type\";\n\nconst Input = ((props: IInput) => {\n\tconst {\n\t\tref,\n\t\ttype = \"text\",\n\t\tlabel,\n\t\tname,\n\t\tvalue = \"\",\n\t\tprepend,\n\t\tappend,\n\t\tlabelInline,\n\t\tclassName,\n\t\tstatus = \"normal\",\n\t\tmessage,\n\t\ttip,\n\t\tclear,\n\t\twidth,\n\t\thideVisible,\n\t\tborder,\n\t\tunderline,\n\t\trequired,\n\t\tmaxLength,\n\t\tonChange,\n\t\tonEnter,\n\t\tstyle,\n\t\t...restProps\n\t} = props;\n\n\tconst state = useReactive({\n\t\tvalue,\n\t\ttype,\n\t\tvisible: false,\n\t});\n\n\tconst handleChange = (e: ChangeEvent<HTMLInputElement>) => {\n\t\tconst v = e.target.value;\n\n\t\tstate.value = v;\n\t\tonChange?.(v, e);\n\t};\n\n\tconst handleKeydown = (e) => {\n\t\te.code === \"Enter\" && onEnter?.(e);\n\t};\n\n\tconst handleHelperClick = () => {\n\t\tif (type === \"password\" && !hideVisible) {\n\t\t\tObject.assign(state, {\n\t\t\t\tvisible: !state.visible,\n\t\t\t\ttype: !state.visible ? \"text\" : \"password\",\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst v = \"\";\n\t\tonChange?.(v);\n\t};\n\n\tconst HelperIcon = useMemo(() => {\n\t\tif (type === \"password\") {\n\t\t\treturn state.visible ? <VisibilityRound /> : <VisibilityOffRound />;\n\t\t}\n\n\t\treturn undefined;\n\t}, [state.visible]);\n\n\tuseEffect(() => {\n\t\tstate.value = value;\n\t}, [value]);\n\n\tconst inputProps = {\n\t\tref,\n\t\ttype: state.type,\n\t\tname,\n\t\tvalue: state.value,\n\t\tmaxLength,\n\t\tclassName: classNames(\"i-input\", `i-input-${type}`),\n\t\tonChange: handleChange,\n\t\tonKeyDown: handleKeydown,\n\t\t...restProps,\n\t};\n\n\tconst clearable = clear && state.value;\n\tconst showHelper = type === \"password\" && !!state.value;\n\n\treturn (\n\t\t<InputContainer\n\t\t\tlabel={label}\n\t\t\tlabelInline={labelInline}\n\t\t\tclassName={className}\n\t\t\tstyle={{ width, ...style }}\n\t\t\ttip={message ?? tip}\n\t\t\tstatus={status}\n\t\t\trequired={required}\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName={classNames(\"i-input-item\", {\n\t\t\t\t\t[`i-input-${status}`]: status !== \"normal\",\n\t\t\t\t\t\"i-input-borderless\": !border,\n\t\t\t\t\t\"i-input-underline\": underline,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t{prepend && <div className='i-input-prepend'>{prepend}</div>}\n\n\t\t\t\t<input {...inputProps} />\n\n\t\t\t\t{maxLength && state.value?.length > 0 && (\n\t\t\t\t\t<span className='color-8 pr-4 font-sm'>\n\t\t\t\t\t\t{state.value.length} / {maxLength}\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\n\t\t\t\t<Helpericon\n\t\t\t\t\tactive={!!clearable || showHelper}\n\t\t\t\t\ticon={HelperIcon}\n\t\t\t\t\tonClick={handleHelperClick}\n\t\t\t\t/>\n\n\t\t\t\t{append && <div className='i-input-append'>{append}</div>}\n\t\t\t</div>\n\t\t</InputContainer>\n\t);\n}) as CompositionInput;\n\nInput.Textarea = Textarea;\nInput.Number = Number;\nInput.Range = Range;\n\nexport default Input;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;AAYA,MAAM,KAAK,IAAI,CAAC,KAAa,KAAI;IAChC,MAAM,EACL,GAAG,EACH,IAAI,GAAG,MAAM,EACb,KAAK,EACL,IAAI,EACJ,KAAK,GAAG,EAAE,EACV,OAAO,EACP,MAAM,EACN,WAAW,EACX,SAAS,EACT,MAAM,GAAG,QAAQ,EACjB,OAAO,EACP,GAAG,EACH,KAAK,EACL,KAAK,EACL,WAAW,EACX,MAAM,EACN,SAAS,EACT,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,OAAO,EACP,KAAK,EACL,GAAG,SAAS,EACZ,GAAG,KAAK;IAET,MAAM,KAAK,GAAG,WAAW,CAAC;QACzB,KAAK;QACL,IAAI;AACJ,QAAA,OAAO,EAAE,KAAK;AACd,KAAA,CAAC;AAEF,IAAA,MAAM,YAAY,GAAG,CAAC,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,EACjC,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,iBAAiB,EAAA,CACzB,EAED,MAAM,IAAIA,GAAK,CAAA,KAAA,EAAA,EAAA,SAAS,EAAC,gBAAgB,YAAE,MAAM,EAAA,CAAO,CACpD,EAAA,CAAA,EAAA,CACU;AAEnB,CAAC;AAED,KAAK,CAAC,QAAQ,GAAG,QAAQ;AACzB,KAAK,CAAC,MAAM,GAAG,MAAM;AACrB,KAAK,CAAC,KAAK,GAAG,KAAK;;;;"}
|
|
@@ -8,7 +8,7 @@ import Helpericon from '../utils/helpericon/helpericon.js';
|
|
|
8
8
|
import InputContainer from './container.js';
|
|
9
9
|
|
|
10
10
|
const Number = (props) => {
|
|
11
|
-
const { ref, label, name, value =
|
|
11
|
+
const { ref, label, name, value = "", labelInline, step = 1, min = -Infinity, max = Infinity, thousand, precision, type, className, width, status = "normal", append, border, prepend, disabled, message, tip, hideControl, style, onChange, onEnter, onInput, onBlur, ...restProps } = props;
|
|
12
12
|
const state = useReactive({
|
|
13
13
|
value,
|
|
14
14
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.js","sources":["../../../../packages/components/input/number.tsx"],"sourcesContent":["import { MinusRound, PlusRound } from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { ChangeEvent, useEffect } from \"react\";\nimport \"../../css/input.css\";\nimport { clamp, formatNumber } from \"../../js/utils\";\nimport Helpericon from \"../utils/helpericon\";\nimport InputContainer from \"./container\";\nimport type { IInputNumber } from \"./type\";\n\nconst Number = (props: IInputNumber) => {\n\tconst {\n\t\tref,\n\t\tlabel,\n\t\tname,\n\t\tvalue =
|
|
1
|
+
{"version":3,"file":"number.js","sources":["../../../../packages/components/input/number.tsx"],"sourcesContent":["import { MinusRound, PlusRound } from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { ChangeEvent, useEffect } from \"react\";\nimport \"../../css/input.css\";\nimport { clamp, formatNumber } from \"../../js/utils\";\nimport Helpericon from \"../utils/helpericon\";\nimport InputContainer from \"./container\";\nimport type { IInputNumber } from \"./type\";\n\nconst Number = (props: IInputNumber) => {\n\tconst {\n\t\tref,\n\t\tlabel,\n\t\tname,\n\t\tvalue = \"\",\n\t\tlabelInline,\n\t\tstep = 1,\n\t\tmin = -Infinity,\n\t\tmax = Infinity,\n\t\tthousand,\n\t\tprecision,\n\t\ttype,\n\t\tclassName,\n\t\twidth,\n\t\tstatus = \"normal\",\n\t\tappend,\n\t\tborder,\n\t\tprepend,\n\t\tdisabled,\n\t\tmessage,\n\t\ttip,\n\t\thideControl,\n\t\tstyle,\n\t\tonChange,\n\t\tonEnter,\n\t\tonInput,\n\t\tonBlur,\n\t\t...restProps\n\t} = props;\n\n\tconst state = useReactive({\n\t\tvalue,\n\t});\n\n\tconst getRangeNumber = (v: number) => clamp(v, min, max);\n\n\tconst getFormatNumber = (v: number) =>\n\t\tformatNumber(v, { precision, thousand });\n\n\tconst formatInputValue = (v?: string | number) => {\n\t\tif (!v) return \"\";\n\t\tif (typeof v === \"number\" || !thousand) return v;\n\n\t\treturn v.replaceAll(thousand, \"\");\n\t};\n\n\tconst handleChange = (e: ChangeEvent<HTMLInputElement>) => {\n\t\tconst { value } = e.target;\n\t\tconst v = formatInputValue(value.replace(/[^\\d\\.-]/g, \"\"));\n\n\t\tstate.value = v;\n\t\tonChange?.(+v, e);\n\t};\n\n\tconst handleOperate = (param: number) => {\n\t\tconst value = formatInputValue(state.value) ?? 0;\n\t\tconst result = getRangeNumber(+value + param);\n\n\t\tstate.value = getFormatNumber(result);\n\n\t\tonChange?.(result);\n\t};\n\n\tuseEffect(() => {\n\t\tstate.value = value;\n\t}, [value]);\n\n\tconst inputProps = {\n\t\tref,\n\t\tname,\n\t\tdisabled,\n\t\tvalue: state.value,\n\t\tclassName: \"i-input i-input-number\",\n\t\tonChange: handleChange,\n\t\t...restProps,\n\t};\n\n\treturn (\n\t\t<InputContainer\n\t\t\tlabel={label}\n\t\t\tlabelInline={labelInline}\n\t\t\tclassName={className}\n\t\t\tstyle={{ width, ...style }}\n\t\t\ttip={message ?? tip}\n\t\t\tstatus={status}\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName={classNames(\"i-input-item\", {\n\t\t\t\t\t[`i-input-${status}`]: status !== \"normal\",\n\t\t\t\t\t\"i-input-borderless\": !border,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t{prepend && <div className='i-input-prepend'>{prepend}</div>}\n\n\t\t\t\t{!hideControl && !disabled && (\n\t\t\t\t\t<Helpericon\n\t\t\t\t\t\tactive\n\t\t\t\t\t\ticon={<MinusRound />}\n\t\t\t\t\t\tonClick={() => handleOperate(-step)}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\n\t\t\t\t<input {...inputProps} />\n\n\t\t\t\t{!hideControl && !disabled && (\n\t\t\t\t\t<Helpericon\n\t\t\t\t\t\tactive\n\t\t\t\t\t\ticon={<PlusRound />}\n\t\t\t\t\t\tonClick={() => handleOperate(step)}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\n\t\t\t\t{append && <div className='i-input-append'>{append}</div>}\n\t\t\t</div>\n\t\t</InputContainer>\n\t);\n};\n\nexport default Number;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;AAUA,MAAM,MAAM,GAAG,CAAC,KAAmB,KAAI;AACtC,IAAA,MAAM,EACL,GAAG,EACH,KAAK,EACL,IAAI,EACJ,KAAK,GAAG,EAAE,EACV,WAAW,EACX,IAAI,GAAG,CAAC,EACR,GAAG,GAAG,CAAC,QAAQ,EACf,GAAG,GAAG,QAAQ,EACd,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,SAAS,EACT,KAAK,EACL,MAAM,GAAG,QAAQ,EACjB,MAAM,EACN,MAAM,EACN,OAAO,EACP,QAAQ,EACR,OAAO,EACP,GAAG,EACH,WAAW,EACX,KAAK,EACL,QAAQ,EACR,OAAO,EACP,OAAO,EACP,MAAM,EACN,GA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AIA,aAAK,SAAS,EAAC,gBAAgB,EAAE,QAAA,EAAA,MAAM,GAAO,CACpD,EAAA,CAAA,EAAA,CACU;AAEnB;;;;"}
|
|
@@ -8,7 +8,7 @@ import Helpericon from '../utils/helpericon/helpericon.js';
|
|
|
8
8
|
import InputContainer from './container.js';
|
|
9
9
|
|
|
10
10
|
const Range = (props) => {
|
|
11
|
-
const { label, name, value
|
|
11
|
+
const { label, name, value, labelInline, min = -Infinity, max = Infinity, type, className, status = "normal", message, tip, append, prepend, step = 1, width, thousand, precision, hideControl, placeholder, border, autoSwitch, onChange, onBlur, style, ...restProps } = props;
|
|
12
12
|
const state = useReactive({
|
|
13
13
|
value,
|
|
14
14
|
});
|
|
@@ -43,9 +43,7 @@ const Range = (props) => {
|
|
|
43
43
|
e?.preventDefault();
|
|
44
44
|
e?.stopPropagation();
|
|
45
45
|
const range = state.value ? state.value : [];
|
|
46
|
-
|
|
47
|
-
range[0] = range[1];
|
|
48
|
-
range[1] = v;
|
|
46
|
+
[range[0], range[1]] = [range[1], range[0]];
|
|
49
47
|
state.value = range;
|
|
50
48
|
onChange?.(range);
|
|
51
49
|
};
|
|
@@ -58,14 +56,15 @@ const Range = (props) => {
|
|
|
58
56
|
...restProps,
|
|
59
57
|
};
|
|
60
58
|
const handleBlur = () => {
|
|
59
|
+
if (!autoSwitch)
|
|
60
|
+
return;
|
|
61
61
|
const range = Array.isArray(state.value) ? state.value : [];
|
|
62
62
|
if (range.length < 2)
|
|
63
63
|
return;
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
handleSwitch();
|
|
64
|
+
const [left, right] = range.map(Number);
|
|
65
|
+
if (left > right) {
|
|
66
|
+
handleSwitch();
|
|
67
|
+
}
|
|
69
68
|
};
|
|
70
69
|
return (jsx(InputContainer, { label: label, labelInline: labelInline, className: className, style: { width, ...style }, tip: message ?? tip, status: status, children: jsxs("div", { className: classNames("i-input-item", {
|
|
71
70
|
[`i-input-${status}`]: status !== "normal",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"range.js","sources":["../../../../packages/components/input/range.tsx"],"sourcesContent":["import { MinusRound, PlusRound, SyncAltRound } from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { ChangeEvent, MouseEvent, useEffect } from \"react\";\nimport \"../../css/input.css\";\nimport { clamp, formatNumber } from \"../../js/utils\";\nimport Helpericon from \"../utils/helpericon\";\nimport InputContainer from \"./container\";\nimport type { IInputRange } from \"./type\";\n\nconst Range = (props: IInputRange) => {\n\tconst {\n\t\tlabel,\n\t\tname,\n\t\tvalue
|
|
1
|
+
{"version":3,"file":"range.js","sources":["../../../../packages/components/input/range.tsx"],"sourcesContent":["import { MinusRound, PlusRound, SyncAltRound } from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { ChangeEvent, MouseEvent, useEffect } from \"react\";\nimport \"../../css/input.css\";\nimport { clamp, formatNumber } from \"../../js/utils\";\nimport Helpericon from \"../utils/helpericon\";\nimport InputContainer from \"./container\";\nimport type { IInputRange } from \"./type\";\n\nconst Range = (props: IInputRange) => {\n\tconst {\n\t\tlabel,\n\t\tname,\n\t\tvalue,\n\t\tlabelInline,\n\t\tmin = -Infinity,\n\t\tmax = Infinity,\n\t\ttype,\n\t\tclassName,\n\t\tstatus = \"normal\",\n\t\tmessage,\n\t\ttip,\n\t\tappend,\n\t\tprepend,\n\t\tstep = 1,\n\t\twidth,\n\t\tthousand,\n\t\tprecision,\n\t\thideControl,\n\t\tplaceholder,\n\t\tborder,\n\t\tautoSwitch,\n\t\tonChange,\n\t\tonBlur,\n\t\tstyle,\n\t\t...restProps\n\t} = props;\n\n\tconst state = useReactive({\n\t\tvalue,\n\t});\n\n\tconst getRangeNumber = (v: number) => clamp(v, min, max);\n\n\tconst getFormatNumber = (v: number) =>\n\t\tformatNumber(v, { precision, thousand });\n\n\tconst formatInputValue = (v?: string | number) => {\n\t\tif (!v) return \"\";\n\t\tif (typeof v === \"number\" || !thousand) return v;\n\n\t\treturn v.replaceAll(thousand, \"\");\n\t};\n\n\tconst handleChange = (e: ChangeEvent<HTMLInputElement>, i: number) => {\n\t\tconst { value } = e.target;\n\t\tconst v = formatInputValue(value.replace(/[^\\d\\.-]/g, \"\"));\n\t\tconst range = Array.isArray(state.value) ? state.value : [];\n\n\t\trange[i] = v;\n\t\tstate.value = range;\n\t\tonChange?.(range, e);\n\t};\n\n\tconst handleOperate = (\n\t\te: MouseEvent<Element>,\n\t\tparam: number,\n\t\ti: number\n\t) => {\n\t\te.preventDefault();\n\t\te.stopPropagation();\n\n\t\tconst range = Array.isArray(state.value) ? state.value : [];\n\t\tconst value = formatInputValue(range[i]) ?? 0;\n\t\tconst result = getRangeNumber(+value + param);\n\n\t\trange[i] = getFormatNumber(result);\n\n\t\tstate.value = range;\n\t\tonChange?.(range, e);\n\t};\n\n\tconst handleSwitch = (e?: MouseEvent) => {\n\t\te?.preventDefault();\n\t\te?.stopPropagation();\n\t\tconst range = state.value ? state.value : [];\n\t\t[range[0], range[1]] = [range[1], range[0]];\n\n\t\tstate.value = range;\n\t\tonChange?.(range);\n\t};\n\n\tuseEffect(() => {\n\t\tstate.value = value;\n\t}, [value]);\n\n\tconst inputProps = {\n\t\tname,\n\t\tclassName: \"i-input i-input-number\",\n\t\t...restProps,\n\t};\n\n\tconst handleBlur = () => {\n\t\tif (!autoSwitch) return;\n\t\tconst range = Array.isArray(state.value) ? state.value : [];\n\n\t\tif (range.length < 2) return;\n\n\t\tconst [left, right] = range.map(Number);\n\t\tif (left > right) {\n\t\t\thandleSwitch();\n\t\t}\n\t};\n\n\treturn (\n\t\t<InputContainer\n\t\t\tlabel={label}\n\t\t\tlabelInline={labelInline}\n\t\t\tclassName={className}\n\t\t\tstyle={{ width, ...style }}\n\t\t\ttip={message ?? tip}\n\t\t\tstatus={status}\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName={classNames(\"i-input-item\", {\n\t\t\t\t\t[`i-input-${status}`]: status !== \"normal\",\n\t\t\t\t\t\"i-input-borderless\": !border,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t{prepend && <div className='i-input-prepend'>{prepend}</div>}\n\n\t\t\t\t{!hideControl && (\n\t\t\t\t\t<Helpericon\n\t\t\t\t\t\tactive\n\t\t\t\t\t\ticon={<MinusRound />}\n\t\t\t\t\t\tonClick={(e) => handleOperate(e, -step, 0)}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\n\t\t\t\t<input\n\t\t\t\t\tvalue={state.value?.[0] || \"\"}\n\t\t\t\t\tplaceholder={placeholder?.[0]}\n\t\t\t\t\t{...inputProps}\n\t\t\t\t\tonBlur={handleBlur}\n\t\t\t\t\tonChange={(e) => handleChange(e, 0)}\n\t\t\t\t/>\n\n\t\t\t\t{!hideControl && (\n\t\t\t\t\t<Helpericon\n\t\t\t\t\t\tactive\n\t\t\t\t\t\ticon={<PlusRound />}\n\t\t\t\t\t\tonClick={(e) => handleOperate(e, step, 0)}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t<Helpericon\n\t\t\t\t\tactive\n\t\t\t\t\ticon={<SyncAltRound />}\n\t\t\t\t\tstyle={{ margin: 0 }}\n\t\t\t\t\tonClick={handleSwitch}\n\t\t\t\t/>\n\t\t\t\t{!hideControl && (\n\t\t\t\t\t<Helpericon\n\t\t\t\t\t\tactive\n\t\t\t\t\t\ticon={<MinusRound />}\n\t\t\t\t\t\tonClick={(e) => handleOperate(e, -step, 1)}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\n\t\t\t\t<input\n\t\t\t\t\tvalue={state.value?.[1] || \"\"}\n\t\t\t\t\tplaceholder={placeholder?.[1]}\n\t\t\t\t\t{...inputProps}\n\t\t\t\t\tonBlur={handleBlur}\n\t\t\t\t\tonChange={(e) => handleChange(e, 1)}\n\t\t\t\t/>\n\n\t\t\t\t{!hideControl && (\n\t\t\t\t\t<Helpericon\n\t\t\t\t\t\tactive\n\t\t\t\t\t\ticon={<PlusRound />}\n\t\t\t\t\t\tonClick={(e) => handleOperate(e, step, 1)}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\n\t\t\t\t{append && <div className='i-input-append'>{append}</div>}\n\t\t\t</div>\n\t\t</InputContainer>\n\t);\n};\n\nexport default Range;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;AAUA,MAAM,KAAK,GAAG,CAAC,KAAkB,KAAI;AACpC,IAAA,MAAM,EACL,KAAK,EACL,IAAI,EACJ,KAAK,EACL,WAAW,EACX,GAAG,GAAG,CAAC,QAAQ,EACf,GAAG,GAAG,QAAQ,EACd,IAAI,EACJ,SAAS,EACT,MAAM,GAAG,QAAQ,EACjB,OAAO,EACP,GAAG,EACH,MAAM,EACN,OAAO,EACP,IAAI,GAAG,CAAC,EACR,KAAK,EACL,QAAQ,EACR,SAAS,EACT,WAAW,EACX,WAAW,EACX,MAAM,EACN,UAAU,EACV,QAAQ,EACR,MAAM,EACN,KAAK,EACL,GAAG,SAAS,EACZ,GAAG,KAAK;IAET,MAAM,KAAK,GAAG,WAAW,CAAC;QACzB,KAAK;AACL,KAAA,CAAC;AAEF,IAAA,MAAM,cAAc,GAAG,CAAC,CAAS,KAAK,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC;AAExD,IAAA,MAAM,eAAe,GAAG,CAAC,CAAS,KACjC,YAAY,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;AAEzC,IAAA,MAAM,gBAAgB,GAAG,CAAC,CAAmB,KAAI;AAChD,QAAA,IAAI,CAAC,CAAC;AAAE,YAAA,OAAO,EAAE;AACjB,QAAA,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,QAAQ;AAAE,YAAA,OAAO,CAAC;QAEhD,OAAO,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC;AAClC,KAAC;AAED,IAAA,MAAM,YAAY,GAAG,CAAC,CAAgC,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ACC,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,IAAI,EAAE,EAC7B,WAAW,EAAE,WAAW,GAAG,CAAC,CAAC,EAAA,GACzB,UAAU,EACd,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,CAAC,CAAC,KAAK,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,EAClC,CAAA,EAED,CAAC,WAAW,KACZA,GAAC,CAAA,UAAU,EACV,EAAA,MAAM,EACN,IAAA,EAAA,IAAI,EAAEA,GAAC,CAAA,SAAS,EAAG,EAAA,CAAA,EACnB,OAAO,EAAE,CAAC,CAAC,KAAK,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EACxC,CAAA,CACF,EAEA,MAAM,IAAIA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,gBAAgB,EAAA,QAAA,EAAE,MAAM,EAAA,CAAO,CACpD,EAAA,CAAA,EAAA,CACU;AAEnB;;;;"}
|
|
@@ -5,7 +5,7 @@ import { useRef, useEffect } from 'react';
|
|
|
5
5
|
import InputContainer from './container.js';
|
|
6
6
|
|
|
7
7
|
const Textarea = (props) => {
|
|
8
|
-
const { ref, label, name, value =
|
|
8
|
+
const { ref, label, name, value = "", labelInline, className, status = "normal", message, tip, autoSize, border, width, style, onChange, onEnter, ...restProps } = props;
|
|
9
9
|
const state = useReactive({
|
|
10
10
|
value,
|
|
11
11
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textarea.js","sources":["../../../../packages/components/input/textarea.tsx"],"sourcesContent":["import { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { ChangeEvent, useEffect, useRef } from \"react\";\nimport \"../../css/input.css\";\nimport InputContainer from \"./container\";\nimport type { ITextarea } from \"./type\";\n\nconst Textarea = (props: ITextarea) => {\n\tconst {\n\t\tref,\n\t\tlabel,\n\t\tname,\n\t\tvalue =
|
|
1
|
+
{"version":3,"file":"textarea.js","sources":["../../../../packages/components/input/textarea.tsx"],"sourcesContent":["import { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { ChangeEvent, useEffect, useRef } from \"react\";\nimport \"../../css/input.css\";\nimport InputContainer from \"./container\";\nimport type { ITextarea } from \"./type\";\n\nconst Textarea = (props: ITextarea) => {\n\tconst {\n\t\tref,\n\t\tlabel,\n\t\tname,\n\t\tvalue = \"\",\n\t\tlabelInline,\n\t\tclassName,\n\t\tstatus = \"normal\",\n\t\tmessage,\n\t\ttip,\n\t\tautoSize,\n\t\tborder,\n\t\twidth,\n\t\tstyle,\n\t\tonChange,\n\t\tonEnter,\n\t\t...restProps\n\t} = props;\n\n\tconst state = useReactive({\n\t\tvalue,\n\t});\n\tconst refTextarea = useRef<HTMLDivElement>(null);\n\n\tconst handleChange = (\n\t\te: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>\n\t) => {\n\t\tconst v = e.target.value;\n\n\t\tstate.value = v;\n\n\t\tconst ta = refTextarea.current?.firstChild as HTMLElement;\n\t\tif (autoSize && ta) {\n\t\t\tta.style.height = `${ta.scrollHeight}px`;\n\t\t}\n\n\t\tonChange?.(v, e);\n\t};\n\n\tconst handleKeydown = (e) => {\n\t\tif (e.code !== \"Enter\") return;\n\n\t\te.stopPropagation();\n\t\tonEnter?.(e);\n\t};\n\n\tuseEffect(() => {\n\t\tstate.value = value;\n\t}, [value]);\n\n\tconst inputProps = {\n\t\tref,\n\t\tname,\n\t\tvalue: state.value,\n\t\tclassName: \"i-input i-textarea\",\n\t\tonChange: handleChange,\n\t\tonKeyDown: handleKeydown,\n\t\t...restProps,\n\t};\n\n\treturn (\n\t\t<InputContainer\n\t\t\tlabel={label}\n\t\t\tlabelInline={labelInline}\n\t\t\tclassName={className}\n\t\t\tstyle={{ width, ...style }}\n\t\t\ttip={message ?? tip}\n\t\t\tstatus={status}\n\t\t>\n\t\t\t<div\n\t\t\t\tref={refTextarea}\n\t\t\t\tclassName={classNames(\"i-input-item\", {\n\t\t\t\t\t[`i-input-${status}`]: status !== \"normal\",\n\t\t\t\t\t\"i-input-borderless\": !border,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t<textarea {...inputProps} />\n\t\t\t</div>\n\t\t</InputContainer>\n\t);\n};\n\nexport default Textarea;\n"],"names":["_jsx"],"mappings":";;;;;;AAOA,MAAM,QAAQ,GAAG,CAAC,KAAgB,KAAI;AACrC,IAAA,MAAM,EACL,GAAG,EACH,KAAK,EACL,IAAI,EACJ,KAAK,GAAG,EAAE,EACV,WAAW,EACX,SAAS,EACT,MAAM,GAAG,QAAQ,EACjB,OAAO,EACP,GAAG,EACH,QAAQ,EACR,MAAM,EACN,KAAK,EACL,KAAK,EACL,QAAQ,EACR,OAAO,EACP,GAAG,SAAS,EACZ,GAAG,KAAK;IAET,MAAM,KAAK,GAAG,WAAW,CAAC;QACzB,KAAK;AACL,KAAA,CAAC;AACF,IAAA,MAAM,WAAW,GAAG,MAAM,CAAiB,IAAI,CAAC;AAEhD,IAAA,MAAM,YAAY,GAAG,CACpB,CAAsD,KACnD;AACH,QAAA,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK;AAExB,QAAA,KAAK,CAAC,KAAK,GAAG,CAAC;AAEf,QAAA,MAAM,EAAE,GAAG,WAAW,CAAC,OAAO,EAAE,UAAyB;AACzD,QAAA,IAAI,QAAQ,IAAI,EAAE,EAAE;YACnB,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAA,EAAA,CAAI;;AAGzC,QAAA,QAAQ,GAAG,CAAC,EAAE,CAAC,CAAC;AACjB,KAAC;AAED,IAAA,MAAM,aAAa,GAAG,CAAC,CAAC,KAAI;AAC3B,QAAA,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO;YAAE;QAExB,CAAC,CAAC,eAAe,EAAE;AACnB,QAAA,OAAO,GAAG,CAAC,CAAC;AACb,KAAC;IAED,SAAS,CAAC,MAAK;AACd,QAAA,KAAK,CAAC,KAAK,GAAG,KAAK;AACpB,KAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AAEX,IAAA,MAAM,UAAU,GAAG;QAClB,GAAG;QACH,IAAI;QACJ,KAAK,EAAE,KAAK,CAAC,KAAK;AAClB,QAAA,SAAS,EAAE,oBAAoB;AAC/B,QAAA,QAAQ,EAAE,YAAY;AACtB,QAAA,SAAS,EAAE,aAAa;AACxB,QAAA,GAAG,SAAS;KACZ;IAED,QACCA,IAAC,cAAc,EAAA,EACd,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAC1B,GAAG,EAAE,OAAO,IAAI,GAAG,EACnB,MAAM,EAAE,MAAM,YAEdA,GACC,CAAA,KAAA,EAAA,EAAA,GAAG,EAAE,WAAW,EAChB,SAAS,EAAE,UAAU,CAAC,cAAc,EAAE;AACrC,gBAAA,CAAC,WAAW,MAAM,CAAA,CAAE,GAAG,MAAM,KAAK,QAAQ;gBAC1C,oBAAoB,EAAE,CAAC,MAAM;AAC7B,aAAA,CAAC,YAEFA,GAAc,CAAA,UAAA,EAAA,EAAA,GAAA,UAAU,GAAI,EACvB,CAAA,EAAA,CACU;AAEnB;;;;"}
|
|
@@ -11,17 +11,19 @@ function Modal(props) {
|
|
|
11
11
|
const [show, setShow] = useState(visible);
|
|
12
12
|
const [active, setActive] = useState(false);
|
|
13
13
|
const [bounced, setBounced] = useState(false);
|
|
14
|
+
const [client, setClient] = useState(false);
|
|
14
15
|
const toggable = useRef(true);
|
|
15
16
|
const handleShow = async () => {
|
|
16
17
|
if (!toggable.current)
|
|
17
18
|
return;
|
|
18
19
|
(!keepDOM || !show) && setShow(true);
|
|
19
20
|
toggable.current = false;
|
|
20
|
-
setTimeout(() => {
|
|
21
|
+
const timer = setTimeout(() => {
|
|
21
22
|
setActive(true);
|
|
22
23
|
onVisibleChange?.(true);
|
|
23
24
|
toggable.current = true;
|
|
24
25
|
}, 24);
|
|
26
|
+
return () => clearTimeout(timer);
|
|
25
27
|
};
|
|
26
28
|
const handleHide = () => {
|
|
27
29
|
if (!toggable.current)
|
|
@@ -29,21 +31,22 @@ function Modal(props) {
|
|
|
29
31
|
toggable.current = false;
|
|
30
32
|
if (!closable) {
|
|
31
33
|
setBounced(true);
|
|
32
|
-
setTimeout(() => {
|
|
34
|
+
const timer = setTimeout(() => {
|
|
33
35
|
setBounced(false);
|
|
34
36
|
toggable.current = true;
|
|
35
37
|
}, 400);
|
|
36
|
-
return;
|
|
38
|
+
return () => clearTimeout(timer);
|
|
37
39
|
}
|
|
38
40
|
setActive(false);
|
|
39
|
-
setTimeout(() => {
|
|
41
|
+
const timer = setTimeout(() => {
|
|
40
42
|
!keepDOM && setShow(false);
|
|
41
43
|
toggable.current = true;
|
|
42
44
|
onVisibleChange?.(false);
|
|
43
45
|
onClose?.();
|
|
44
46
|
}, 240);
|
|
47
|
+
return () => clearTimeout(timer);
|
|
45
48
|
};
|
|
46
|
-
const handleBackdropClick =
|
|
49
|
+
const handleBackdropClick = () => {
|
|
47
50
|
backdropClosable && handleHide();
|
|
48
51
|
};
|
|
49
52
|
useKeydown((e) => {
|
|
@@ -54,19 +57,22 @@ function Modal(props) {
|
|
|
54
57
|
useEffect(() => {
|
|
55
58
|
visible ? handleShow() : handleHide();
|
|
56
59
|
}, [visible]);
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
setClient(true);
|
|
62
|
+
}, []);
|
|
57
63
|
const handleClick = () => {
|
|
58
64
|
if (typeof document === "undefined")
|
|
59
65
|
return;
|
|
60
66
|
document.documentElement.click();
|
|
61
67
|
};
|
|
62
|
-
if (!show)
|
|
68
|
+
if (!show || !client)
|
|
63
69
|
return null;
|
|
64
70
|
return createPortal(jsx("div", { className: classNames("i-modal-container", {
|
|
65
71
|
"i-modal-backdrop": !hideBackdrop,
|
|
66
72
|
"i-modal-customized": customized,
|
|
67
73
|
"i-modal-active": active,
|
|
68
74
|
fixed,
|
|
69
|
-
}, className), style: style, onClick: handleBackdropClick, children: jsxs("div", { className: classNames("i-modal", {
|
|
75
|
+
}, className), style: style, onClick: handleBackdropClick, "aria-modal": 'true', "aria-hidden": !active, children: jsxs("div", { className: classNames("i-modal", {
|
|
70
76
|
bounced,
|
|
71
77
|
shadow: !hideShadow,
|
|
72
78
|
}), style: {
|
|
@@ -76,7 +82,7 @@ function Modal(props) {
|
|
|
76
82
|
e.stopPropagation();
|
|
77
83
|
handleClick();
|
|
78
84
|
onClick?.(e);
|
|
79
|
-
}, ...restProps, children: [customized && children, !customized && (jsx(Content, { title: title, hideCloseButton: hideCloseButton, footer: footer, okButtonProps: okButtonProps, cancelButtonProps: cancelButtonProps, children: children, footerLeft: footerLeft, onOk: onOk, onClose: handleHide }))] }) }), document?.body ?? null);
|
|
85
|
+
}, role: 'dialog', "aria-labelledby": title ? "modal-title" : undefined, ...restProps, children: [customized && children, !customized && (jsx(Content, { title: title, hideCloseButton: hideCloseButton, footer: footer, okButtonProps: okButtonProps, cancelButtonProps: cancelButtonProps, children: children, footerLeft: footerLeft, onOk: onOk, onClose: handleHide }))] }) }), document?.body ?? null);
|
|
80
86
|
}
|
|
81
87
|
Modal.useModal = useModal;
|
|
82
88
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.js","sources":["../../../../packages/components/modal/modal.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { useKeydown } from \"../../js/hooks\";\nimport Content from \"./content\";\nimport \"./index.css\";\nimport { CompositionModal, IModal } from \"./type\";\nimport useModal from \"./useModal\";\n\nfunction Modal(props: IModal) {\n\tconst {\n\t\tvisible,\n\t\ttitle,\n\t\tfooter,\n\t\tokButtonProps,\n\t\tcancelButtonProps,\n\t\tclosable = true,\n\t\thideBackdrop,\n\t\tbackdropClosable = true,\n\t\thideCloseButton,\n\t\tdisableEsc,\n\t\twidth,\n\t\theight,\n\t\tcustomized,\n\t\tfixed,\n\t\thideShadow,\n\t\tchildren,\n\t\tstyle,\n\t\tclassName,\n\t\tkeepDOM,\n\t\tfooterLeft,\n\t\tonClick,\n\t\tonVisibleChange,\n\t\tonClose,\n\t\tonOk,\n\t\t...restProps\n\t} = props;\n\tconst [show, setShow] = useState(visible);\n\tconst [active, setActive] = useState(false);\n\tconst [bounced, setBounced] = useState(false);\n\tconst toggable = useRef(true);\n\n\tconst handleShow = async () => {\n\t\tif (!toggable.current) return;\n\n\t\t(!keepDOM || !show) && setShow(true);\n\t\ttoggable.current = false;\n\n\t\
|
|
1
|
+
{"version":3,"file":"modal.js","sources":["../../../../packages/components/modal/modal.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { useKeydown } from \"../../js/hooks\";\nimport Content from \"./content\";\nimport \"./index.css\";\nimport { CompositionModal, IModal } from \"./type\";\nimport useModal from \"./useModal\";\n\nfunction Modal(props: IModal) {\n\tconst {\n\t\tvisible,\n\t\ttitle,\n\t\tfooter,\n\t\tokButtonProps,\n\t\tcancelButtonProps,\n\t\tclosable = true,\n\t\thideBackdrop,\n\t\tbackdropClosable = true,\n\t\thideCloseButton,\n\t\tdisableEsc,\n\t\twidth,\n\t\theight,\n\t\tcustomized,\n\t\tfixed,\n\t\thideShadow,\n\t\tchildren,\n\t\tstyle,\n\t\tclassName,\n\t\tkeepDOM,\n\t\tfooterLeft,\n\t\tonClick,\n\t\tonVisibleChange,\n\t\tonClose,\n\t\tonOk,\n\t\t...restProps\n\t} = props;\n\n\tconst [show, setShow] = useState(visible);\n\tconst [active, setActive] = useState(false);\n\tconst [bounced, setBounced] = useState(false);\n\tconst [client, setClient] = useState(false);\n\tconst toggable = useRef(true);\n\n\tconst handleShow = async () => {\n\t\tif (!toggable.current) return;\n\n\t\t(!keepDOM || !show) && setShow(true);\n\t\ttoggable.current = false;\n\n\t\tconst timer = setTimeout(() => {\n\t\t\tsetActive(true);\n\t\t\tonVisibleChange?.(true);\n\t\t\ttoggable.current = true;\n\t\t}, 24);\n\n\t\treturn () => clearTimeout(timer);\n\t};\n\n\tconst handleHide = () => {\n\t\tif (!toggable.current) return;\n\t\ttoggable.current = false;\n\n\t\tif (!closable) {\n\t\t\tsetBounced(true);\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\tsetBounced(false);\n\t\t\t\ttoggable.current = true;\n\t\t\t}, 400);\n\t\t\treturn () => clearTimeout(timer);\n\t\t}\n\n\t\tsetActive(false);\n\t\tconst timer = setTimeout(() => {\n\t\t\t!keepDOM && setShow(false);\n\t\t\ttoggable.current = true;\n\t\t\tonVisibleChange?.(false);\n\t\t\tonClose?.();\n\t\t}, 240);\n\n\t\treturn () => clearTimeout(timer);\n\t};\n\n\tconst handleBackdropClick = () => {\n\t\tbackdropClosable && handleHide();\n\t};\n\n\tuseKeydown(\n\t\t(e) => {\n\t\t\tif (e.code !== \"Escape\" || !visible) return;\n\t\t\thandleHide();\n\t\t},\n\t\t{ disabled: disableEsc }\n\t);\n\n\tuseEffect(() => {\n\t\tvisible ? handleShow() : handleHide();\n\t}, [visible]);\n\n\tuseEffect(() => {\n\t\tsetClient(true);\n\t}, []);\n\n\tconst handleClick = () => {\n\t\tif (typeof document === \"undefined\") return;\n\t\tdocument.documentElement.click();\n\t};\n\n\tif (!show || !client) return null;\n\n\treturn createPortal(\n\t\t<div\n\t\t\tclassName={classNames(\n\t\t\t\t\"i-modal-container\",\n\t\t\t\t{\n\t\t\t\t\t\"i-modal-backdrop\": !hideBackdrop,\n\t\t\t\t\t\"i-modal-customized\": customized,\n\t\t\t\t\t\"i-modal-active\": active,\n\t\t\t\t\tfixed,\n\t\t\t\t},\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tstyle={style}\n\t\t\tonClick={handleBackdropClick}\n\t\t\taria-modal='true'\n\t\t\taria-hidden={!active}\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName={classNames(\"i-modal\", {\n\t\t\t\t\tbounced,\n\t\t\t\t\tshadow: !hideShadow,\n\t\t\t\t})}\n\t\t\t\tstyle={{\n\t\t\t\t\twidth,\n\t\t\t\t\theight,\n\t\t\t\t}}\n\t\t\t\tonClick={(e) => {\n\t\t\t\t\te.stopPropagation();\n\t\t\t\t\thandleClick();\n\t\t\t\t\tonClick?.(e);\n\t\t\t\t}}\n\t\t\t\trole='dialog'\n\t\t\t\taria-labelledby={title ? \"modal-title\" : undefined}\n\t\t\t\t{...restProps}\n\t\t\t>\n\t\t\t\t{customized && children}\n\n\t\t\t\t{!customized && (\n\t\t\t\t\t<Content\n\t\t\t\t\t\ttitle={title}\n\t\t\t\t\t\thideCloseButton={hideCloseButton}\n\t\t\t\t\t\tfooter={footer}\n\t\t\t\t\t\tokButtonProps={okButtonProps}\n\t\t\t\t\t\tcancelButtonProps={cancelButtonProps}\n\t\t\t\t\t\tchildren={children}\n\t\t\t\t\t\tfooterLeft={footerLeft}\n\t\t\t\t\t\tonOk={onOk}\n\t\t\t\t\t\tonClose={handleHide}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</div>,\n\t\tdocument?.body ?? null\n\t);\n}\n\nModal.useModal = useModal;\n\nexport default Modal as CompositionModal;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;AASA,SAAS,KAAK,CAAC,KAAa,EAAA;IAC3B,MAAM,EACL,OAAO,EACP,KAAK,EACL,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,QAAQ,GAAG,IAAI,EACf,YAAY,EACZ,gBAAgB,GAAG,IAAI,EACvB,eAAe,EACf,UAAU,EACV,KAAK,EACL,MAAM,EACN,UAAU,EACV,KAAK,EACL,UAAU,EACV,QAAQ,EACR,KAAK,EACL,SAAS,EACT,OAAO,EACP,UAAU,EACV,OAAO,EACP,eAAe,EACf,OAAO,EACP,IAAI,EACJ,GAAG,SAAS,EACZ,GAAG,KAAK;IAET,MAAM,CAAC,IAAI,EAAE,OAAO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KAAA,EAAA,EACC,SAAS,EAAE,UAAU,CAAC,SAAS,EAAE;gBAChC,OAAO;gBACP,MAAM,EAAE,CAAC,UAAU;aACnB,CAAC,EACF,KAAK,EAAE;gBACN,KAAK;gBACL,MAAM;AACN,aAAA,EACD,OAAO,EAAE,CAAC,CAAC,KAAI;gBACd,CAAC,CAAC,eAAe,EAAE;AACnB,gBAAA,WAAW,EAAE;AACb,gBAAA,OAAO,GAAG,CAAC,CAAC;AACb,aAAC,EACD,IAAI,EAAC,QAAQ,qBACI,KAAK,GAAG,aAAa,GAAG,SAAS,KAC9C,SAAS,EAAA,QAAA,EAAA,CAEZ,UAAU,IAAI,QAAQ,EAEtB,CAAC,UAAU,KACXD,GAAC,CAAA,OAAO,EACP,EAAA,KAAK,EAAE,KAAK,EACZ,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,iBAAiB,EACpC,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,UAAU,GAClB,CACF,CAAA,EAAA,CACI,EACD,CAAA,EACN,QAAQ,EAAE,IAAI,IAAI,IAAI,CACtB;AACF;AAEA,KAAK,CAAC,QAAQ,GAAG,QAAQ;;;;"}
|
|
@@ -45,7 +45,7 @@ const Popconfirm = (props) => {
|
|
|
45
45
|
await onClose?.();
|
|
46
46
|
state.visible = false;
|
|
47
47
|
};
|
|
48
|
-
const popconfirmContent = (jsxs("div", { className: 'i-popconfirm', children: [jsxs(Flex, { gap: '.5em', children: [icon, jsx("div", { className: 'i-popconfirm-content', children: content })] }), jsxs(Flex, { gap: 12, justify: 'flex-end', className: '
|
|
48
|
+
const popconfirmContent = (jsxs("div", { className: 'i-popconfirm', children: [jsxs(Flex, { gap: '.5em', children: [icon, jsx("div", { className: 'i-popconfirm-content', children: content })] }), jsxs(Flex, { gap: 12, justify: 'flex-end', className: 'i-popconfirm-footer', children: [cancelButtonProps !== null && (jsx(Button, { ...cancel, onClick: handleCancel })), extra, okButtonProps !== null && (jsx(Button, { loading: state.loading, ...ok, onClick: handleOk }))] })] }));
|
|
49
49
|
return (jsx(Popup, { content: popconfirmContent, ...restProps, trigger: trigger, visible: state.visible, align: align, offset: offset, position: position, onVisibleChange: handleVisibleChange, children: children }));
|
|
50
50
|
};
|
|
51
51
|
|