@ioca/react 1.3.82 → 1.3.84
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/input/input.js +3 -2
- package/lib/cjs/components/input/input.js.map +1 -1
- package/lib/cjs/components/modal/content.js +37 -0
- package/lib/cjs/components/modal/content.js.map +1 -0
- package/lib/cjs/components/modal/modal.js +3 -29
- package/lib/cjs/components/modal/modal.js.map +1 -1
- package/lib/cjs/components/popconfirm/popconfirm.js +2 -2
- package/lib/cjs/components/popconfirm/popconfirm.js.map +1 -1
- package/lib/css/index.css +1 -1
- package/lib/css/index.css.map +1 -1
- package/lib/es/components/input/input.js +3 -2
- package/lib/es/components/input/input.js.map +1 -1
- package/lib/es/components/modal/content.js +33 -0
- package/lib/es/components/modal/content.js.map +1 -0
- package/lib/es/components/modal/modal.js +5 -31
- package/lib/es/components/modal/modal.js.map +1 -1
- package/lib/es/components/popconfirm/popconfirm.js +2 -2
- package/lib/es/components/popconfirm/popconfirm.js.map +1 -1
- package/lib/index.js +35 -33
- package/package.json +1 -1
|
@@ -18,7 +18,7 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
18
18
|
var classNames__default = /*#__PURE__*/_interopDefaultCompat(classNames);
|
|
19
19
|
|
|
20
20
|
const Input = ((props) => {
|
|
21
|
-
const { ref, type = "text", label, name, value = props.initValue ?? "", initValue = "", prepend, append, labelInline, className, status = "normal", message, tip, clear, width, hideVisible, border, required, onChange, onEnter, style, ...restProps } = props;
|
|
21
|
+
const { ref, type = "text", label, name, value = props.initValue ?? "", initValue = "", prepend, append, labelInline, className, status = "normal", message, tip, clear, width, hideVisible, border, required, maxLength, onChange, onEnter, style, ...restProps } = props;
|
|
22
22
|
const state = ahooks.useReactive({
|
|
23
23
|
value,
|
|
24
24
|
type,
|
|
@@ -57,6 +57,7 @@ const Input = ((props) => {
|
|
|
57
57
|
type: state.type,
|
|
58
58
|
name,
|
|
59
59
|
value: state.value,
|
|
60
|
+
maxLength,
|
|
60
61
|
className: classNames__default("i-input", `i-input-${type}`),
|
|
61
62
|
onChange: handleChange,
|
|
62
63
|
onKeyDown: handleKeydown,
|
|
@@ -67,7 +68,7 @@ const Input = ((props) => {
|
|
|
67
68
|
return (jsxRuntime.jsx(container.default, { label: label, labelInline: labelInline, className: className, style: { width, ...style }, tip: message ?? tip, status: status, required: required, children: jsxRuntime.jsxs("div", { className: classNames__default("i-input-item", {
|
|
68
69
|
[`i-input-${status}`]: status !== "normal",
|
|
69
70
|
"i-input-borderless": !border,
|
|
70
|
-
}), children: [prepend && jsxRuntime.jsx("div", { className: 'i-input-prepend', children: prepend }), jsxRuntime.jsx("input", { ...inputProps }), jsxRuntime.jsx(helpericon.default, { active: !!clearable || showHelper, icon: HelperIcon, onClick: handleHelperClick }), append && jsxRuntime.jsx("div", { className: 'i-input-append', children: append })] }) }));
|
|
71
|
+
}), children: [prepend && jsxRuntime.jsx("div", { className: 'i-input-prepend', children: prepend }), jsxRuntime.jsx("input", { ...inputProps }), maxLength && state.value?.length > 0 && (jsxRuntime.jsxs("span", { className: 'color-8 pr-4 font-sm', children: [state.value.length, " / ", maxLength] })), jsxRuntime.jsx(helpericon.default, { active: !!clearable || showHelper, icon: HelperIcon, onClick: handleHelperClick }), append && jsxRuntime.jsx("div", { className: 'i-input-append', children: append })] }) }));
|
|
71
72
|
});
|
|
72
73
|
Input.Textarea = textarea.default;
|
|
73
74
|
Input.Number = number.default;
|
|
@@ -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 = props.initValue ?? \"\",\n\t\tinitValue = \"\",\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\trequired,\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\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})}\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<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":["useReactive","useMemo","_jsx","VisibilityRound","VisibilityOffRound","useEffect","classNames","InputContainer","_jsxs","Helpericon","Textarea","Number","Range"],"mappings":";;;;;;;;;;;;;;;;;;;AAYA,MAAM,KAAK,IAAI,CAAC,KAAa,KAAI;AAChC,IAAA,MAAM,EACL,GAAG,EACH,IAAI,GAAG,MAAM,EACb,KAAK,EACL,IAAI,EACJ,KAAK,GAAG,KAAK,CAAC,SAAS,IAAI,EAAE,EAC7B,SAAS,GAAG,EAAE,EACd,OAAO,EACP,MAAM,EACN,WAAW,EACX,SAAS,EACT,MAAM,GAAG,QAAQ,EACjB,OAAO,EACP,GAAG,EACH,KAAK,EACL,KAAK,EACL,WAAW,EACX,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,KAAK,EACL,GAAG,SAAS,EACZ,GAAG,KAAK;IAET,MAAM,KAAK,GAAGA,kBAAW,CAAC;QACzB,KAAK;QACL,IAAI;AACJ,QAAA,OAAO,EAAE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,KAAK,CAAC,KAAK;QAClB,SAAS,EAAEC,mBAAU,CAAC,SAAS,EAAE,CAAW,QAAA,EAAA,IAAI,EAAE,CAAC;AACnD,QAAA,QAAQ,EAAE,YAAY;AACtB,QAAA,SAAS,EAAE,aAAa;AACxB,QAAA,GAAG,SAAS;KACZ;AAED,IAAA,MAAM,SAAS,GAAG,KAAK,IAAI,KAAK,CAAC,KAAK;IACtC,MAAM,UAAU,GAAG,IAAI,KAAK,UAAU,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK;IAEvD,QACCJ,eAACK,iBAAc,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,EACd,QAAQ,EAAE,QAAQ,EAElB,QAAA,EAAAC,eAAA,CAAA,KAAA,EAAA,EACC,SAAS,EAAEF,mBAAU,CAAC,cAAc,EAAE;AACrC,gBAAA,CAAC,WAAW,MAAM,CAAA,CAAE,GAAG,MAAM,KAAK,QAAQ;gBAC1C,oBAAoB,EAAE,CAAC,MAAM;
|
|
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 = props.initValue ?? \"\",\n\t\tinitValue = \"\",\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\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})}\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":["useReactive","useMemo","_jsx","VisibilityRound","VisibilityOffRound","useEffect","classNames","InputContainer","_jsxs","Helpericon","Textarea","Number","Range"],"mappings":";;;;;;;;;;;;;;;;;;;AAYA,MAAM,KAAK,IAAI,CAAC,KAAa,KAAI;AAChC,IAAA,MAAM,EACL,GAAG,EACH,IAAI,GAAG,MAAM,EACb,KAAK,EACL,IAAI,EACJ,KAAK,GAAG,KAAK,CAAC,SAAS,IAAI,EAAE,EAC7B,SAAS,GAAG,EAAE,EACd,OAAO,EACP,MAAM,EACN,WAAW,EACX,SAAS,EACT,MAAM,GAAG,QAAQ,EACjB,OAAO,EACP,GAAG,EACH,KAAK,EACL,KAAK,EACL,WAAW,EACX,MAAM,EACN,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,OAAO,EACP,KAAK,EACL,GAAG,SAAS,EACZ,GAAG,KAAK;IAET,MAAM,KAAK,GAAGA,kBAAW,CAAC;QACzB,KAAK;QACL,IAAI;AACJ,QAAA,OAAO,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AAA,MAAM,EAAE,CAAC,CAAC,SAAS,IAAI,UAAU,EACjC,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,iBAAiB,EAAA,CACzB,EAED,MAAM,IAAIP,cAAK,CAAA,KAAA,EAAA,EAAA,SAAS,EAAC,gBAAgB,YAAE,MAAM,EAAA,CAAO,CACpD,EAAA,CAAA,EAAA,CACU;AAEnB,CAAC;AAED,KAAK,CAAC,QAAQ,GAAGQ,gBAAQ;AACzB,KAAK,CAAC,MAAM,GAAGC,cAAM;AACrB,KAAK,CAAC,KAAK,GAAGC,aAAK;;;;"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
var button = require('../button/button.js');
|
|
8
|
+
var helpericon = require('../utils/helpericon/helpericon.js');
|
|
9
|
+
|
|
10
|
+
function Content(props) {
|
|
11
|
+
const { title, footer, hideCloseButton, footerLeft, okButtonProps, cancelButtonProps, children, onOk, onClose, } = props;
|
|
12
|
+
const showHeader = title || !hideCloseButton;
|
|
13
|
+
const handleOk = async () => {
|
|
14
|
+
const ret = await onOk?.();
|
|
15
|
+
if (ret === false)
|
|
16
|
+
return;
|
|
17
|
+
onClose?.();
|
|
18
|
+
};
|
|
19
|
+
const renderFooter = react.useMemo(() => {
|
|
20
|
+
if (footer || footer === null)
|
|
21
|
+
return footer;
|
|
22
|
+
const propsOk = Object.assign({
|
|
23
|
+
children: "确定",
|
|
24
|
+
onClick: handleOk,
|
|
25
|
+
}, okButtonProps);
|
|
26
|
+
const propsCancel = Object.assign({
|
|
27
|
+
secondary: true,
|
|
28
|
+
children: "关闭",
|
|
29
|
+
onClick: onClose,
|
|
30
|
+
}, cancelButtonProps);
|
|
31
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [footerLeft, jsxRuntime.jsx(button.default, { ...propsOk }), jsxRuntime.jsx(button.default, { ...propsCancel })] }));
|
|
32
|
+
}, [footer, okButtonProps, cancelButtonProps]);
|
|
33
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [showHeader && (jsxRuntime.jsxs("header", { className: 'i-modal-header', children: [title && jsxRuntime.jsx("b", { children: title }), jsxRuntime.jsx(helpericon.default, { active: !hideCloseButton, className: 'i-modal-close', onClick: onClose })] })), jsxRuntime.jsx("div", { className: 'i-modal-content', children: children }), jsxRuntime.jsx("footer", { className: 'i-modal-footer', children: renderFooter })] }));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
exports.default = Content;
|
|
37
|
+
//# sourceMappingURL=content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.js","sources":["../../../../packages/components/modal/content.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport Button from \"../button\";\nimport Helpericon from \"../utils/helpericon\";\nimport \"./index.css\";\nimport { IModalContent } from \"./type\";\n\nexport default function Content(props: IModalContent) {\n\tconst {\n\t\ttitle,\n\t\tfooter,\n\t\thideCloseButton,\n\t\tfooterLeft,\n\t\tokButtonProps,\n\t\tcancelButtonProps,\n\t\tchildren,\n\t\tonOk,\n\t\tonClose,\n\t} = props;\n\tconst showHeader = title || !hideCloseButton;\n\n\tconst handleOk = async () => {\n\t\tconst ret = await onOk?.();\n\n\t\tif (ret === false) return;\n\n\t\tonClose?.();\n\t};\n\n\tconst renderFooter = useMemo(() => {\n\t\tif (footer || footer === null) return footer;\n\n\t\tconst propsOk = Object.assign(\n\t\t\t{\n\t\t\t\tchildren: \"确定\",\n\t\t\t\tonClick: handleOk,\n\t\t\t},\n\t\t\tokButtonProps\n\t\t);\n\t\tconst propsCancel = Object.assign(\n\t\t\t{\n\t\t\t\tsecondary: true,\n\t\t\t\tchildren: \"关闭\",\n\t\t\t\tonClick: onClose,\n\t\t\t},\n\t\t\tcancelButtonProps\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{footerLeft}\n\t\t\t\t<Button {...propsOk} />\n\t\t\t\t<Button {...propsCancel} />\n\t\t\t</>\n\t\t);\n\t}, [footer, okButtonProps, cancelButtonProps]);\n\n\treturn (\n\t\t<>\n\t\t\t{showHeader && (\n\t\t\t\t<header className='i-modal-header'>\n\t\t\t\t\t{title && <b>{title}</b>}\n\n\t\t\t\t\t<Helpericon\n\t\t\t\t\t\tactive={!hideCloseButton}\n\t\t\t\t\t\tclassName='i-modal-close'\n\t\t\t\t\t\tonClick={onClose}\n\t\t\t\t\t/>\n\t\t\t\t</header>\n\t\t\t)}\n\n\t\t\t<div className='i-modal-content'>{children}</div>\n\n\t\t\t<footer className='i-modal-footer'>{renderFooter}</footer>\n\t\t</>\n\t);\n}\n"],"names":["useMemo","_jsxs","_Fragment","_jsx","Button","Helpericon"],"mappings":";;;;;;;;;AAMwB,SAAA,OAAO,CAAC,KAAoB,EAAA;IACnD,MAAM,EACL,KAAK,EACL,MAAM,EACN,eAAe,EACf,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACR,IAAI,EACJ,OAAO,GACP,GAAG,KAAK;AACT,IAAA,MAAM,UAAU,GAAG,KAAK,IAAI,CAAC,eAAe;AAE5C,IAAA,MAAM,QAAQ,GAAG,YAAW;AAC3B,QAAA,MAAM,GAAG,GAAG,MAAM,IAAI,IAAI;QAE1B,IAAI,GAAG,KAAK,KAAK;YAAE;QAEnB,OAAO,IAAI;AACZ,KAAC;AAED,IAAA,MAAM,YAAY,GAAGA,aAAO,CAAC,MAAK;AACjC,QAAA,IAAI,MAAM,IAAI,MAAM,KAAK,IAAI;AAAE,YAAA,OAAO,MAAM;AAE5C,QAAA,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAC5B;AACC,YAAA,QAAQ,EAAE,IAAI;AACd,YAAA,OAAO,EAAE,QAAQ;SACjB,EACD,aAAa,CACb;AACD,QAAA,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAChC;AACC,YAAA,SAAS,EAAE,IAAI;AACf,YAAA,QAAQ,EAAE,IAAI;AACd,YAAA,OAAO,EAAE,OAAO;SAChB,EACD,iBAAiB,CACjB;AAED,QAAA,QACCC,eACE,CAAAC,mBAAA,EAAA,EAAA,QAAA,EAAA,CAAA,UAAU,EACXC,cAAA,CAACC,cAAM,EAAK,EAAA,GAAA,OAAO,EAAI,CAAA,EACvBD,eAACC,cAAM,EAAA,EAAA,GAAK,WAAW,EAAI,CAAA,CAAA,EAAA,CACzB;KAEJ,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,iBAAiB,CAAC,CAAC;IAE9C,QACCH,eACE,CAAAC,mBAAA,EAAA,EAAA,QAAA,EAAA,CAAA,UAAU,KACVD,4BAAQ,SAAS,EAAC,gBAAgB,EAAA,QAAA,EAAA,CAChC,KAAK,IAAIE,gCAAI,KAAK,EAAA,CAAK,EAExBA,cAAA,CAACE,kBAAU,EAAA,EACV,MAAM,EAAE,CAAC,eAAe,EACxB,SAAS,EAAC,eAAe,EACzB,OAAO,EAAE,OAAO,EACf,CAAA,CAAA,EAAA,CACM,CACT,EAEDF,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,iBAAiB,EAAA,QAAA,EAAE,QAAQ,EAAO,CAAA,EAEjDA,cAAQ,CAAA,QAAA,EAAA,EAAA,SAAS,EAAC,gBAAgB,YAAE,YAAY,EAAA,CAAU,CACxD,EAAA,CAAA;AAEL;;;;"}
|
|
@@ -7,46 +7,20 @@ var classNames = require('classnames');
|
|
|
7
7
|
var react = require('react');
|
|
8
8
|
var reactDom = require('react-dom');
|
|
9
9
|
var hooks = require('../../js/hooks.js');
|
|
10
|
-
var
|
|
11
|
-
var helpericon = require('../utils/helpericon/helpericon.js');
|
|
10
|
+
var content = require('./content.js');
|
|
12
11
|
var useModal = require('./useModal.js');
|
|
13
12
|
|
|
14
13
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
15
14
|
|
|
16
15
|
var classNames__default = /*#__PURE__*/_interopDefaultCompat(classNames);
|
|
17
16
|
|
|
18
|
-
function DefaultContent(props) {
|
|
19
|
-
const { title, footer, hideCloseButton, footerLeft, okButtonProps, cancelButtonProps, children, onOk, onClose, } = props;
|
|
20
|
-
const showHeader = title || !hideCloseButton;
|
|
21
|
-
const handleOk = async () => {
|
|
22
|
-
const ret = await onOk?.();
|
|
23
|
-
if (ret === false)
|
|
24
|
-
return;
|
|
25
|
-
onClose?.();
|
|
26
|
-
};
|
|
27
|
-
const renderFooter = react.useMemo(() => {
|
|
28
|
-
if (footer || footer === null)
|
|
29
|
-
return footer;
|
|
30
|
-
const propsOk = Object.assign({
|
|
31
|
-
children: "确定",
|
|
32
|
-
onClick: handleOk,
|
|
33
|
-
}, okButtonProps);
|
|
34
|
-
const propsCancel = Object.assign({
|
|
35
|
-
secondary: true,
|
|
36
|
-
children: "关闭",
|
|
37
|
-
onClick: onClose,
|
|
38
|
-
}, cancelButtonProps);
|
|
39
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [footerLeft, jsxRuntime.jsx(button.default, { ...propsOk }), jsxRuntime.jsx(button.default, { ...propsCancel })] }));
|
|
40
|
-
}, [footer, okButtonProps, cancelButtonProps]);
|
|
41
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [showHeader && (jsxRuntime.jsxs("header", { className: 'i-modal-header', children: [title && jsxRuntime.jsx("b", { children: title }), jsxRuntime.jsx(helpericon.default, { active: !hideCloseButton, className: 'i-modal-close', onClick: onClose })] })), jsxRuntime.jsx("div", { className: 'i-modal-content', children: children }), jsxRuntime.jsx("footer", { className: 'i-modal-footer', children: renderFooter })] }));
|
|
42
|
-
}
|
|
43
17
|
function Modal(props) {
|
|
44
18
|
const { visible, title, footer, okButtonProps, cancelButtonProps, closable = true, hideBackdrop, backdropClosable = true, hideCloseButton, disableEsc, width, height, customized, fixed, hideShadow, children, style, className, keepDOM, footerLeft, onClick, onVisibleChange, onClose, onOk, ...restProps } = props;
|
|
45
19
|
const [show, setShow] = react.useState(visible);
|
|
46
20
|
const [active, setActive] = react.useState(false);
|
|
47
21
|
const [bounced, setBounced] = react.useState(false);
|
|
48
22
|
const toggable = react.useRef(true);
|
|
49
|
-
const handleShow = () => {
|
|
23
|
+
const handleShow = async () => {
|
|
50
24
|
if (!toggable.current)
|
|
51
25
|
return;
|
|
52
26
|
(!keepDOM || !show) && setShow(true);
|
|
@@ -110,7 +84,7 @@ function Modal(props) {
|
|
|
110
84
|
e.stopPropagation();
|
|
111
85
|
handleClick();
|
|
112
86
|
onClick?.(e);
|
|
113
|
-
}, ...restProps, children: [customized && children, !customized && (jsxRuntime.jsx(
|
|
87
|
+
}, ...restProps, children: [customized && children, !customized && (jsxRuntime.jsx(content.default, { title: title, hideCloseButton: hideCloseButton, footer: footer, okButtonProps: okButtonProps, cancelButtonProps: cancelButtonProps, children: children, footerLeft: footerLeft, onOk: onOk, onClose: handleHide }))] }) }), document?.body ?? null);
|
|
114
88
|
}
|
|
115
89
|
Modal.useModal = useModal.default;
|
|
116
90
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.js","sources":["../../../../packages/components/modal/modal.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport { useEffect,
|
|
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\tsetTimeout(() => {\n\t\t\tsetActive(true);\n\t\t\tonVisibleChange?.(true);\n\t\t\ttoggable.current = true;\n\t\t}, 24);\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\tsetTimeout(() => {\n\t\t\t\tsetBounced(false);\n\t\t\t\ttoggable.current = true;\n\t\t\t}, 400);\n\t\t\treturn;\n\t\t}\n\n\t\tsetActive(false);\n\t\tsetTimeout(() => {\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\t};\n\n\tconst handleBackdropClick = function () {\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\tconst handleClick = () => {\n\t\tif (typeof document === \"undefined\") return;\n\t\tdocument.documentElement.click();\n\t};\n\n\tif (!show) 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>\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\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":["useState","useRef","useKeydown","useEffect","createPortal","_jsx","classNames","_jsxs","Content","useModal"],"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,U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,CAAC,CAAC,eAAe,EAAE;AACnB,gBAAA,WAAW,EAAE;AACb,gBAAA,OAAO,GAAG,CAAC,CAAC;AACb,aAAC,EACG,GAAA,SAAS,EAEZ,QAAA,EAAA,CAAA,UAAU,IAAI,QAAQ,EAEtB,CAAC,UAAU,KACXD,cAAA,CAACG,eAAO,EAAA,EACP,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,EAAA,CAClB,CACF,CAAA,EAAA,CACI,EACD,CAAA,EACN,QAAQ,EAAE,IAAI,IAAI,IAAI,CACtB;AACF;AAEA,KAAK,CAAC,QAAQ,GAAGC,gBAAQ;;;;"}
|
|
@@ -18,7 +18,7 @@ const defaultCancel = {
|
|
|
18
18
|
secondary: true,
|
|
19
19
|
};
|
|
20
20
|
const Popconfirm = (props) => {
|
|
21
|
-
const { trigger = "click", visible, icon: icon$1 = jsxRuntime.jsx(icon.default, { icon: jsxRuntime.jsx(material.InfoOutlined, {}), className: 'error' }), content, okButtonProps, cancelButtonProps, children, align = "end", position = "top", offset = 12, extra, onOk, onClose, ...restProps } = props;
|
|
21
|
+
const { trigger = "click", visible, icon: icon$1 = jsxRuntime.jsx(icon.default, { icon: jsxRuntime.jsx(material.InfoOutlined, {}), className: 'error', size: '1.2em' }), content, okButtonProps, cancelButtonProps, children, align = "end", position = "top", offset = 12, extra, onOk, onClose, ...restProps } = props;
|
|
22
22
|
const state = ahooks.useReactive({
|
|
23
23
|
loading: false,
|
|
24
24
|
visible,
|
|
@@ -49,7 +49,7 @@ const Popconfirm = (props) => {
|
|
|
49
49
|
await onClose?.();
|
|
50
50
|
state.visible = false;
|
|
51
51
|
};
|
|
52
|
-
const popconfirmContent = (jsxRuntime.jsxs("div", { className: 'i-popconfirm', children: [jsxRuntime.jsxs(flex.default, { gap:
|
|
52
|
+
const popconfirmContent = (jsxRuntime.jsxs("div", { className: 'i-popconfirm', children: [jsxRuntime.jsxs(flex.default, { gap: '.5em', children: [icon$1, jsxRuntime.jsx("div", { className: 'i-popconfirm-content', children: content })] }), jsxRuntime.jsxs(flex.default, { gap: 12, justify: 'flex-end', className: 'mt-8 i-popconfirm-footer', children: [cancelButtonProps !== null && (jsxRuntime.jsx(button.default, { ...cancel, onClick: handleCancel })), extra, okButtonProps !== null && (jsxRuntime.jsx(button.default, { loading: state.loading, ...ok, onClick: handleOk }))] })] }));
|
|
53
53
|
return (jsxRuntime.jsx(popup.default, { content: popconfirmContent, ...restProps, trigger: trigger, visible: state.visible, align: align, offset: offset, position: position, onVisibleChange: handleVisibleChange, children: children }));
|
|
54
54
|
};
|
|
55
55
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popconfirm.js","sources":["../../../../packages/components/popconfirm/popconfirm.tsx"],"sourcesContent":["import { InfoOutlined } from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport { MouseEvent } from \"react\";\nimport Button from \"../button\";\nimport { IButton } from \"../button/type\";\nimport Flex from \"../flex\";\nimport Icon from \"../icon\";\nimport Popup from \"../popup\";\nimport \"./index.css\";\nimport { IPopconfirm } from \"./type\";\n\nconst defaultOk = {\n\tchildren: \"确定\",\n};\n\nconst defaultCancel = {\n\tchildren: \"取消\",\n\tsecondary: true,\n};\n\nconst Popconfirm = (props: IPopconfirm) => {\n\tconst {\n\t\ttrigger = \"click\",\n\t\tvisible,\n\t\ticon = <Icon icon={<InfoOutlined />} className='error' />,\n\t\tcontent,\n\t\tokButtonProps,\n\t\tcancelButtonProps,\n\t\tchildren,\n\t\talign = \"end\",\n\t\tposition = \"top\",\n\t\toffset = 12,\n\t\textra,\n\t\tonOk,\n\t\tonClose,\n\t\t...restProps\n\t} = props;\n\n\tconst state = useReactive({\n\t\tloading: false,\n\t\tvisible,\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 handleVisibleChange = (v: boolean) => {\n\t\tstate.visible = v;\n\t\trestProps.onVisibleChange?.(v);\n\t};\n\n\tconst handleOk = async (e: MouseEvent<HTMLElement>) => {\n\t\tstate.loading = true;\n\t\tok.onClick?.(e);\n\n\t\tonOk?.()\n\t\t\t?.then(() => {\n\t\t\t\tstate.visible = false;\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tstate.loading = false;\n\t\t\t});\n\t};\n\n\tconst handleCancel = async (e: MouseEvent<HTMLElement>) => {\n\t\tcancel.onClick?.(e);\n\t\tawait onClose?.();\n\t\tstate.visible = false;\n\t};\n\n\tconst popconfirmContent = (\n\t\t<div className='i-popconfirm'>\n\t\t\t<Flex gap=
|
|
1
|
+
{"version":3,"file":"popconfirm.js","sources":["../../../../packages/components/popconfirm/popconfirm.tsx"],"sourcesContent":["import { InfoOutlined } from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport { MouseEvent } from \"react\";\nimport Button from \"../button\";\nimport { IButton } from \"../button/type\";\nimport Flex from \"../flex\";\nimport Icon from \"../icon\";\nimport Popup from \"../popup\";\nimport \"./index.css\";\nimport { IPopconfirm } from \"./type\";\n\nconst defaultOk = {\n\tchildren: \"确定\",\n};\n\nconst defaultCancel = {\n\tchildren: \"取消\",\n\tsecondary: true,\n};\n\nconst Popconfirm = (props: IPopconfirm) => {\n\tconst {\n\t\ttrigger = \"click\",\n\t\tvisible,\n\t\ticon = <Icon icon={<InfoOutlined />} className='error' size='1.2em' />,\n\t\tcontent,\n\t\tokButtonProps,\n\t\tcancelButtonProps,\n\t\tchildren,\n\t\talign = \"end\",\n\t\tposition = \"top\",\n\t\toffset = 12,\n\t\textra,\n\t\tonOk,\n\t\tonClose,\n\t\t...restProps\n\t} = props;\n\n\tconst state = useReactive({\n\t\tloading: false,\n\t\tvisible,\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 handleVisibleChange = (v: boolean) => {\n\t\tstate.visible = v;\n\t\trestProps.onVisibleChange?.(v);\n\t};\n\n\tconst handleOk = async (e: MouseEvent<HTMLElement>) => {\n\t\tstate.loading = true;\n\t\tok.onClick?.(e);\n\n\t\tonOk?.()\n\t\t\t?.then(() => {\n\t\t\t\tstate.visible = false;\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tstate.loading = false;\n\t\t\t});\n\t};\n\n\tconst handleCancel = async (e: MouseEvent<HTMLElement>) => {\n\t\tcancel.onClick?.(e);\n\t\tawait onClose?.();\n\t\tstate.visible = false;\n\t};\n\n\tconst popconfirmContent = (\n\t\t<div className='i-popconfirm'>\n\t\t\t<Flex gap='.5em'>\n\t\t\t\t{icon}\n\t\t\t\t<div className='i-popconfirm-content'>{content}</div>\n\t\t\t</Flex>\n\n\t\t\t<Flex\n\t\t\t\tgap={12}\n\t\t\t\tjustify='flex-end'\n\t\t\t\tclassName='mt-8 i-popconfirm-footer'\n\t\t\t>\n\t\t\t\t{cancelButtonProps !== null && (\n\t\t\t\t\t<Button {...cancel} onClick={handleCancel} />\n\t\t\t\t)}\n\t\t\t\t{extra}\n\t\t\t\t{okButtonProps !== null && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tloading={state.loading}\n\t\t\t\t\t\t{...ok}\n\t\t\t\t\t\tonClick={handleOk}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</Flex>\n\t\t</div>\n\t);\n\n\treturn (\n\t\t<Popup\n\t\t\tcontent={popconfirmContent}\n\t\t\t{...restProps}\n\t\t\ttrigger={trigger}\n\t\t\tvisible={state.visible}\n\t\t\talign={align}\n\t\t\toffset={offset}\n\t\t\tposition={position}\n\t\t\tonVisibleChange={handleVisibleChange}\n\t\t>\n\t\t\t{children}\n\t\t</Popup>\n\t);\n};\n\nexport default Popconfirm;\n"],"names":["icon","_jsx","Icon","InfoOutlined","useReactive","_jsxs","Flex","Button","Popup"],"mappings":";;;;;;;;;;;;AAWA,MAAM,SAAS,GAAG;AACjB,IAAA,QAAQ,EAAE,IAAI;CACd;AAED,MAAM,aAAa,GAAG;AACrB,IAAA,QAAQ,EAAE,IAAI;AACd,IAAA,SAAS,EAAE,IAAI;CACf;AAED,MAAM,UAAU,GAAG,CAAC,KAAkB,KAAI;IACzC,MAAM,EACL,OAAO,GAAG,OAAO,EACjB,OAAO,QACPA,MAAI,GAAGC,cAAC,CAAAC,YAAI,EAAC,EAAA,IAAI,EAAED,cAAA,CAACE,qBAAY,EAAA,EAAA,CAAG,EAAE,SAAS,EAAC,OAAO,EAAC,IAAI,EAAC,OAAO,EAAG,CAAA,EACtE,OAAO,EACP,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACR,KAAK,GAAG,KAAK,EACb,QAAQ,GAAG,KAAK,EAChB,MAAM,GAAG,EAAE,EACX,KAAK,EACL,IAAI,EACJ,OAAO,EACP,GAAG,SAAS,EACZ,GAAG,KAAK;IAET,MAAM,KAAK,GAAGC,kBAAW,CAAC;AACzB,QAAA,OAAO,EAAE,KAAK;QACd,OAAO;AACP,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,mBAAmB,GAAG,CAAC,CAAU,KAAI;AAC1C,QAAA,KAAK,CAAC,OAAO,GAAG,CAAC;AACjB,QAAA,SAAS,CAAC,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