@ioca/react 1.3.6 → 1.3.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/affix/affix.js +5 -1
- package/lib/cjs/components/affix/affix.js.map +1 -1
- package/lib/cjs/components/affix/totop.js +5 -1
- package/lib/cjs/components/affix/totop.js.map +1 -1
- package/lib/cjs/components/badge/badge.js +5 -1
- package/lib/cjs/components/badge/badge.js.map +1 -1
- package/lib/cjs/components/button/button.js +5 -1
- package/lib/cjs/components/button/button.js.map +1 -1
- package/lib/cjs/components/button/group.js +5 -1
- package/lib/cjs/components/button/group.js.map +1 -1
- package/lib/cjs/components/button/toggle.js +5 -1
- package/lib/cjs/components/button/toggle.js.map +1 -1
- package/lib/cjs/components/card/card.js +5 -1
- package/lib/cjs/components/card/card.js.map +1 -1
- package/lib/cjs/components/checkbox/checkbox.js +6 -2
- package/lib/cjs/components/checkbox/checkbox.js.map +1 -1
- package/lib/cjs/components/checkbox/item.js +6 -2
- package/lib/cjs/components/checkbox/item.js.map +1 -1
- package/lib/cjs/components/collapse/collapse.js +6 -2
- package/lib/cjs/components/collapse/collapse.js.map +1 -1
- package/lib/cjs/components/datagrid/cell.js +6 -2
- package/lib/cjs/components/datagrid/cell.js.map +1 -1
- package/lib/cjs/components/datagrid/datagrid.js +6 -2
- package/lib/cjs/components/datagrid/datagrid.js.map +1 -1
- package/lib/cjs/components/datagrid/row.js +6 -2
- package/lib/cjs/components/datagrid/row.js.map +1 -1
- package/lib/cjs/components/datagrid/sorter.js +5 -1
- package/lib/cjs/components/datagrid/sorter.js.map +1 -1
- package/lib/cjs/components/description/description.js +6 -2
- package/lib/cjs/components/description/description.js.map +1 -1
- package/lib/cjs/components/drawer/drawer.js +6 -2
- package/lib/cjs/components/drawer/drawer.js.map +1 -1
- package/lib/cjs/components/editor/editor.js +8 -3
- package/lib/cjs/components/editor/editor.js.map +1 -1
- package/lib/cjs/components/flex/flex.js +5 -1
- package/lib/cjs/components/flex/flex.js.map +1 -1
- package/lib/cjs/components/form/field.js +9 -5
- package/lib/cjs/components/form/field.js.map +1 -1
- package/lib/cjs/components/form/form.js +8 -3
- package/lib/cjs/components/form/form.js.map +1 -1
- package/lib/cjs/components/form/useForm.js +11 -7
- package/lib/cjs/components/form/useForm.js.map +1 -1
- package/lib/cjs/components/icon/icon.js +5 -1
- package/lib/cjs/components/icon/icon.js.map +1 -1
- package/lib/cjs/components/image/image.js +6 -2
- package/lib/cjs/components/image/image.js.map +1 -1
- package/lib/cjs/components/input/container.js +6 -2
- package/lib/cjs/components/input/container.js.map +1 -1
- package/lib/cjs/components/input/input.js +6 -2
- package/lib/cjs/components/input/input.js.map +1 -1
- package/lib/cjs/components/input/number.js +5 -1
- package/lib/cjs/components/input/number.js.map +1 -1
- package/lib/cjs/components/input/range.js +5 -1
- package/lib/cjs/components/input/range.js.map +1 -1
- package/lib/cjs/components/input/textarea.js +5 -1
- package/lib/cjs/components/input/textarea.js.map +1 -1
- package/lib/cjs/components/list/item.js +5 -1
- package/lib/cjs/components/list/item.js.map +1 -1
- package/lib/cjs/components/list/list.js +5 -1
- package/lib/cjs/components/list/list.js.map +1 -1
- package/lib/cjs/components/loading/loading.js +5 -1
- package/lib/cjs/components/loading/loading.js.map +1 -1
- package/lib/cjs/components/message/message.js +5 -1
- package/lib/cjs/components/message/message.js.map +1 -1
- package/lib/cjs/components/modal/modal.js +6 -2
- package/lib/cjs/components/modal/modal.js.map +1 -1
- package/lib/cjs/components/pagination/page.js +5 -1
- package/lib/cjs/components/pagination/page.js.map +1 -1
- package/lib/cjs/components/pagination/pagination.js +5 -1
- package/lib/cjs/components/pagination/pagination.js.map +1 -1
- package/lib/cjs/components/picker/colors/handle.js +5 -1
- package/lib/cjs/components/picker/colors/handle.js.map +1 -1
- package/lib/cjs/components/picker/colors/index.js +6 -2
- package/lib/cjs/components/picker/colors/index.js.map +1 -1
- package/lib/cjs/components/picker/dates/dates.js +7 -2
- package/lib/cjs/components/picker/dates/dates.js.map +1 -1
- package/lib/cjs/components/picker/dates/index.js +8 -3
- package/lib/cjs/components/picker/dates/index.js.map +1 -1
- package/lib/cjs/components/picker/dates/panel.js +11 -6
- package/lib/cjs/components/picker/dates/panel.js.map +1 -1
- package/lib/cjs/components/picker/time/item.js +5 -1
- package/lib/cjs/components/picker/time/item.js.map +1 -1
- package/lib/cjs/components/popup/content.js +5 -1
- package/lib/cjs/components/popup/content.js.map +1 -1
- package/lib/cjs/components/progress/line.js +6 -2
- package/lib/cjs/components/progress/line.js.map +1 -1
- package/lib/cjs/components/progress/progress.js +5 -1
- package/lib/cjs/components/progress/progress.js.map +1 -1
- package/lib/cjs/components/radio/item.js +6 -2
- package/lib/cjs/components/radio/item.js.map +1 -1
- package/lib/cjs/components/radio/radio.js +6 -2
- package/lib/cjs/components/radio/radio.js.map +1 -1
- package/lib/cjs/components/resizable/resizable.js +6 -2
- package/lib/cjs/components/resizable/resizable.js.map +1 -1
- package/lib/cjs/components/select/options.js +5 -1
- package/lib/cjs/components/select/options.js.map +1 -1
- package/lib/cjs/components/select/select.js +7 -3
- package/lib/cjs/components/select/select.js.map +1 -1
- package/lib/cjs/components/step/item.js +5 -1
- package/lib/cjs/components/step/item.js.map +1 -1
- package/lib/cjs/components/step/step.js +5 -1
- package/lib/cjs/components/step/step.js.map +1 -1
- package/lib/cjs/components/swiper/item.js +5 -1
- package/lib/cjs/components/swiper/item.js.map +1 -1
- package/lib/cjs/components/swiper/swiper.js +8 -4
- package/lib/cjs/components/swiper/swiper.js.map +1 -1
- package/lib/cjs/components/tabs/tabs.js +10 -6
- package/lib/cjs/components/tabs/tabs.js.map +1 -1
- package/lib/cjs/components/tag/tag.js +6 -2
- package/lib/cjs/components/tag/tag.js.map +1 -1
- package/lib/cjs/components/text/text.js +5 -1
- package/lib/cjs/components/text/text.js.map +1 -1
- package/lib/cjs/components/tree/item.js +7 -3
- package/lib/cjs/components/tree/item.js.map +1 -1
- package/lib/cjs/components/upload/renderFile.js +5 -1
- package/lib/cjs/components/upload/renderFile.js.map +1 -1
- package/lib/cjs/components/upload/upload.js +5 -1
- package/lib/cjs/components/upload/upload.js.map +1 -1
- package/lib/cjs/components/utils/empty/index.js +5 -1
- package/lib/cjs/components/utils/empty/index.js.map +1 -1
- package/lib/cjs/components/utils/helpericon/helpericon.js +5 -1
- package/lib/cjs/components/utils/helpericon/helpericon.js.map +1 -1
- package/lib/cjs/components/video/video.js +5 -1
- package/lib/cjs/components/video/video.js.map +1 -1
- package/lib/cjs/js/usePreview/content.js +6 -2
- package/lib/cjs/js/usePreview/content.js.map +1 -1
- package/lib/css/index.css +1 -1
- package/lib/css/index.css.map +1 -1
- package/package.json +3 -2
|
@@ -10,6 +10,10 @@ var react = require('react');
|
|
|
10
10
|
var helpericon = require('../utils/helpericon/helpericon.js');
|
|
11
11
|
var container = require('./container.js');
|
|
12
12
|
|
|
13
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
14
|
+
|
|
15
|
+
var classNames__default = /*#__PURE__*/_interopDefaultCompat(classNames);
|
|
16
|
+
|
|
13
17
|
const Input = ((props) => {
|
|
14
18
|
const { ref, type = "text", label, name, value = props.initValue ?? "", initValue = "", prepend, append, labelInline, className, status = "normal", message, tip, clear, hideVisible, border, required, onChange, onEnter, style, ...restProps } = props;
|
|
15
19
|
const state = ahooks.useReactive({
|
|
@@ -50,14 +54,14 @@ const Input = ((props) => {
|
|
|
50
54
|
type: state.type,
|
|
51
55
|
name,
|
|
52
56
|
value: state.value,
|
|
53
|
-
className:
|
|
57
|
+
className: classNames__default("i-input", `i-input-${type}`),
|
|
54
58
|
onChange: handleChange,
|
|
55
59
|
onKeyDown: handleKeydown,
|
|
56
60
|
...restProps,
|
|
57
61
|
};
|
|
58
62
|
const clearable = clear && state.value;
|
|
59
63
|
const showHelper = type === "password" && !!state.value;
|
|
60
|
-
return (jsxRuntime.jsx(container.default, { label: label, labelInline: labelInline, className: className, style: style, tip: message ?? tip, status: status, required: required, children: jsxRuntime.jsxs("div", { className:
|
|
64
|
+
return (jsxRuntime.jsx(container.default, { label: label, labelInline: labelInline, className: className, style: style, tip: message ?? tip, status: status, required: required, children: jsxRuntime.jsxs("div", { className: classNames__default("i-input-item", {
|
|
61
65
|
[`i-input-${status}`]: status !== "normal",
|
|
62
66
|
"i-input-borderless": !border,
|
|
63
67
|
}), 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 })] }) }));
|
|
@@ -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 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\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={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\nexport default Input;\n"],"names":["useReactive","useMemo","_jsx","VisibilityRound","VisibilityOffRound","useEffect","InputContainer","_jsxs","Helpericon"],"mappings":"
|
|
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 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\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={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\nexport default Input;\n"],"names":["useReactive","useMemo","_jsx","VisibilityRound","VisibilityOffRound","useEffect","classNames","InputContainer","_jsxs","Helpericon"],"mappings":";;;;;;;;;;;;;;;;AASA,MAAM,KAAK,IAAI,CAAC,KAAa,KAAI;IAChC,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,E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EACjC,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,iBAAiB,EAAA,CACzB,EAED,MAAM,IAAIP,cAAK,CAAA,KAAA,EAAA,EAAA,SAAS,EAAC,gBAAgB,EAAA,QAAA,EAAE,MAAM,EAAO,CAAA,CAAA,EAAA,CACpD,EACU,CAAA;AAEnB,CAAC;;;;"}
|
|
@@ -11,6 +11,10 @@ var utils = require('../../js/utils.js');
|
|
|
11
11
|
var helpericon = require('../utils/helpericon/helpericon.js');
|
|
12
12
|
var container = require('./container.js');
|
|
13
13
|
|
|
14
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
15
|
+
|
|
16
|
+
var classNames__default = /*#__PURE__*/_interopDefaultCompat(classNames);
|
|
17
|
+
|
|
14
18
|
const Number = (props) => {
|
|
15
19
|
const { ref, label, name, value = props.initValue ?? "", initValue, labelInline, step = 1, min = -Infinity, max = Infinity, thousand, precision, type, className, status = "normal", append, border, prepend, message, tip, hideControl, style, onChange, onEnter, onInput, onBlur, ...restProps } = props;
|
|
16
20
|
const state = ahooks.useReactive({
|
|
@@ -48,7 +52,7 @@ const Number = (props) => {
|
|
|
48
52
|
onChange: handleChange,
|
|
49
53
|
...restProps,
|
|
50
54
|
};
|
|
51
|
-
return (jsxRuntime.jsx(container.default, { label: label, labelInline: labelInline, className: className, style: style, tip: message ?? tip, status: status, children: jsxRuntime.jsxs("div", { className:
|
|
55
|
+
return (jsxRuntime.jsx(container.default, { label: label, labelInline: labelInline, className: className, style: style, tip: message ?? tip, status: status, children: jsxRuntime.jsxs("div", { className: classNames__default("i-input-item", {
|
|
52
56
|
[`i-input-${status}`]: status !== "normal",
|
|
53
57
|
"i-input-borderless": !border,
|
|
54
58
|
}), children: [prepend && jsxRuntime.jsx("div", { className: 'i-input-prepend', children: prepend }), !hideControl && (jsxRuntime.jsx(helpericon.default, { active: true, icon: jsxRuntime.jsx(material.MinusRound, {}), onClick: () => handleOperate(-step) })), jsxRuntime.jsx("input", { ...inputProps }), !hideControl && (jsxRuntime.jsx(helpericon.default, { active: true, icon: jsxRuntime.jsx(material.PlusRound, {}), onClick: () => handleOperate(step) })), append && jsxRuntime.jsx("div", { className: 'i-input-append', children: append })] }) }));
|
|
@@ -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 = props.initValue ?? \"\",\n\t\tinitValue,\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\tstatus = \"normal\",\n\t\tappend,\n\t\tborder,\n\t\tprepend,\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\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={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={() => 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 && (\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":["useReactive","clamp","formatNumber","useEffect","_jsx","InputContainer","_jsxs","Helpericon","MinusRound","PlusRound"],"mappings":"
|
|
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 = props.initValue ?? \"\",\n\t\tinitValue,\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\tstatus = \"normal\",\n\t\tappend,\n\t\tborder,\n\t\tprepend,\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\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={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={() => 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 && (\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":["useReactive","clamp","formatNumber","useEffect","_jsx","InputContainer","_jsxs","classNames","Helpericon","MinusRound","PlusRound"],"mappings":";;;;;;;;;;;;;;;;;AAUA,MAAM,MAAM,GAAG,CAAC,KAAmB,KAAI;AACtC,IAAA,MAAM,EACL,GAAG,EACH,KAAK,EACL,IAAI,EACJ,KAAK,GAAG,KAAK,CAAC,SAAS,IAAI,EAAE,EAC7B,SAAS,EACT,WAAW,EACX,IAAI,GAAG,CAAC,EACR,GAAG,GAAG,CAAC,QAAQ,EACf,GAAG,GAAG,QAAQ,EACd,QAAQ,EACR,SAA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AAA,EAAA,IAAI,EAAEJ,cAAC,CAAAM,kBAAS,KAAG,EACnB,OAAO,EAAE,MAAM,aAAa,CAAC,IAAI,CAAC,GACjC,CACF,EAEA,MAAM,IAAIN,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,gBAAgB,EAAE,QAAA,EAAA,MAAM,GAAO,CACpD,EAAA,CAAA,EAAA,CACU;AAEnB;;;;"}
|
|
@@ -11,6 +11,10 @@ var utils = require('../../js/utils.js');
|
|
|
11
11
|
var helpericon = require('../utils/helpericon/helpericon.js');
|
|
12
12
|
var container = require('./container.js');
|
|
13
13
|
|
|
14
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
15
|
+
|
|
16
|
+
var classNames__default = /*#__PURE__*/_interopDefaultCompat(classNames);
|
|
17
|
+
|
|
14
18
|
const Range = (props) => {
|
|
15
19
|
const { label, name, value = props.initValue ?? "", initValue, labelInline, min = -Infinity, max = Infinity, type, className, status = "normal", message, tip, append, prepend, step = 1, thousand, precision, hideControl, placeholder, border, onChange, onBlur, style, ...restProps } = props;
|
|
16
20
|
const state = ahooks.useReactive({
|
|
@@ -61,7 +65,7 @@ const Range = (props) => {
|
|
|
61
65
|
className: "i-input i-input-number",
|
|
62
66
|
...restProps,
|
|
63
67
|
};
|
|
64
|
-
return (jsxRuntime.jsx(container.default, { label: label, labelInline: labelInline, className: className, style: style, tip: message ?? tip, status: status, children: jsxRuntime.jsxs("div", { className:
|
|
68
|
+
return (jsxRuntime.jsx(container.default, { label: label, labelInline: labelInline, className: className, style: style, tip: message ?? tip, status: status, children: jsxRuntime.jsxs("div", { className: classNames__default("i-input-item", {
|
|
65
69
|
[`i-input-${status}`]: status !== "normal",
|
|
66
70
|
"i-input-borderless": !border,
|
|
67
71
|
}), children: [prepend && jsxRuntime.jsx("div", { className: 'i-input-prepend', children: prepend }), !hideControl && (jsxRuntime.jsx(helpericon.default, { active: true, icon: jsxRuntime.jsx(material.MinusRound, {}), onClick: (e) => handleOperate(e, -step, 0) })), jsxRuntime.jsx("input", { value: state.value?.[0] || "", placeholder: placeholder?.[0], ...inputProps, onChange: (e) => handleChange(e, 0) }), !hideControl && (jsxRuntime.jsx(helpericon.default, { active: true, icon: jsxRuntime.jsx(material.PlusRound, {}), onClick: (e) => handleOperate(e, step, 0) })), jsxRuntime.jsx(helpericon.default, { active: true, icon: jsxRuntime.jsx(material.SyncAltRound, {}), style: { margin: 0 }, onClick: handleSwitch }), !hideControl && (jsxRuntime.jsx(helpericon.default, { active: true, icon: jsxRuntime.jsx(material.MinusRound, {}), onClick: (e) => handleOperate(e, -step, 1) })), jsxRuntime.jsx("input", { value: state.value?.[1] || "", placeholder: placeholder?.[1], ...inputProps, onChange: (e) => handleChange(e, 1) }), !hideControl && (jsxRuntime.jsx(helpericon.default, { active: true, icon: jsxRuntime.jsx(material.PlusRound, {}), onClick: (e) => handleOperate(e, step, 1) })), append && jsxRuntime.jsx("div", { className: 'i-input-append', children: append })] }) }));
|
|
@@ -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 = props.initValue ?? \"\",\n\t\tinitValue,\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\tthousand,\n\t\tprecision,\n\t\thideControl,\n\t\tplaceholder,\n\t\tborder,\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\n\t\tconst range = Array.isArray(state.value) ? state.value : [];\n\t\trange[i] = +v;\n\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\tconst v = range[0];\n\t\trange[0] = range[1];\n\t\trange[1] = v;\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\treturn (\n\t\t<InputContainer\n\t\t\tlabel={label}\n\t\t\tlabelInline={labelInline}\n\t\t\tclassName={className}\n\t\t\tstyle={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\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\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":["useReactive","clamp","formatNumber","useEffect","_jsx","InputContainer","_jsxs","Helpericon","MinusRound","PlusRound","SyncAltRound"],"mappings":"
|
|
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 = props.initValue ?? \"\",\n\t\tinitValue,\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\tthousand,\n\t\tprecision,\n\t\thideControl,\n\t\tplaceholder,\n\t\tborder,\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\n\t\tconst range = Array.isArray(state.value) ? state.value : [];\n\t\trange[i] = +v;\n\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\tconst v = range[0];\n\t\trange[0] = range[1];\n\t\trange[1] = v;\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\treturn (\n\t\t<InputContainer\n\t\t\tlabel={label}\n\t\t\tlabelInline={labelInline}\n\t\t\tclassName={className}\n\t\t\tstyle={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\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\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":["useReactive","clamp","formatNumber","useEffect","_jsx","InputContainer","_jsxs","classNames","Helpericon","MinusRound","PlusRound","SyncAltRound"],"mappings":";;;;;;;;;;;;;;;;;AAU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;;"}
|
|
@@ -8,6 +8,10 @@ var classNames = require('classnames');
|
|
|
8
8
|
var react = require('react');
|
|
9
9
|
var container = require('./container.js');
|
|
10
10
|
|
|
11
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
12
|
+
|
|
13
|
+
var classNames__default = /*#__PURE__*/_interopDefaultCompat(classNames);
|
|
14
|
+
|
|
11
15
|
const Textarea = (props) => {
|
|
12
16
|
const { ref, label, name, value = props.initValue, initValue, labelInline, className, status = "normal", message, tip, autoSize, border, style, onChange, onEnter, ...restProps } = props;
|
|
13
17
|
const state = ahooks.useReactive({
|
|
@@ -41,7 +45,7 @@ const Textarea = (props) => {
|
|
|
41
45
|
onKeyDown: handleKeydown,
|
|
42
46
|
...restProps,
|
|
43
47
|
};
|
|
44
|
-
return (jsxRuntime.jsx(container.default, { label: label, labelInline: labelInline, className: className, style: style, tip: message ?? tip, status: status, children: jsxRuntime.jsx("div", { ref: refTextarea, className:
|
|
48
|
+
return (jsxRuntime.jsx(container.default, { label: label, labelInline: labelInline, className: className, style: style, tip: message ?? tip, status: status, children: jsxRuntime.jsx("div", { ref: refTextarea, className: classNames__default("i-input-item", {
|
|
45
49
|
[`i-input-${status}`]: status !== "normal",
|
|
46
50
|
"i-input-borderless": !border,
|
|
47
51
|
}), children: jsxRuntime.jsx("textarea", { ...inputProps }) }) }));
|
|
@@ -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 = props.initValue,\n\t\tinitValue,\n\t\tlabelInline,\n\t\tclassName,\n\t\tstatus = \"normal\",\n\t\tmessage,\n\t\ttip,\n\t\tautoSize,\n\t\tborder,\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={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":["useReactive","useRef","useEffect","_jsx","InputContainer"],"mappings":"
|
|
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 = props.initValue,\n\t\tinitValue,\n\t\tlabelInline,\n\t\tclassName,\n\t\tstatus = \"normal\",\n\t\tmessage,\n\t\ttip,\n\t\tautoSize,\n\t\tborder,\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={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":["useReactive","useRef","useEffect","_jsx","InputContainer","classNames"],"mappings":";;;;;;;;;;;;;;AAOA,MAAM,QAAQ,GAAG,CAAC,KAAgB,KAAI;AACrC,IAAA,MAAM,EACL,GAAG,EACH,KAAK,EACL,IAAI,EACJ,KAAK,GAAG,KAAK,CAAC,SAAS,EACvB,SAAS,EACT,WAAW,EACX,SAAS,EACT,MAAM,GAAG,QAAQ,EACjB,OAAO,EACP,GAAG,EACH,QAAQ,EACR,MAAM,EACN,KAAK,EACL,QAAQ,EACR,OAAO,EACP,GAAG,SAAS,EACZ,GAAG,KAAK;IAET,MAAM,KAAK,GAAGA,kBAAW,CAAC;QACzB,KAAK;AACL,KAAA,CAAC;AACF,IAAA,MAAM,WAAW,GAAGC,YAAM,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;IAEDC,eAAS,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;AAED,IAAA,QACCC,cAAC,CAAAC,iBAAc,IACd,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,OAAO,IAAI,GAAG,EACnB,MAAM,EAAE,MAAM,EAEd,QAAA,EAAAD,cAAA,CAAA,KAAA,EAAA,EACC,GAAG,EAAE,WAAW,EAChB,SAAS,EAAEE,mBAAU,CAAC,cAAc,EAAE;AACrC,gBAAA,CAAC,WAAW,MAAM,CAAA,CAAE,GAAG,MAAM,KAAK,QAAQ;gBAC1C,oBAAoB,EAAE,CAAC,MAAM;AAC7B,aAAA,CAAC,YAEFF,cAAc,CAAA,UAAA,EAAA,EAAA,GAAA,UAAU,GAAI,EACvB,CAAA,EAAA,CACU;AAEnB;;;;"}
|
|
@@ -5,9 +5,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var classNames = require('classnames');
|
|
7
7
|
|
|
8
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
9
|
+
|
|
10
|
+
var classNames__default = /*#__PURE__*/_interopDefaultCompat(classNames);
|
|
11
|
+
|
|
8
12
|
const Item = (props) => {
|
|
9
13
|
const { ref, active, type, align, disabled, label, style, className, children, ...restProps } = props;
|
|
10
|
-
return (jsxRuntime.jsxs("li", { ref: ref, className:
|
|
14
|
+
return (jsxRuntime.jsxs("li", { ref: ref, className: classNames__default("i-list-item", className, {
|
|
11
15
|
"i-list-item-active": active,
|
|
12
16
|
"i-list-option": type === "option",
|
|
13
17
|
disabled,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.js","sources":["../../../../packages/components/list/item.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport { IListItem } from \"./type\";\n\nconst Item = (props: IListItem) => {\n\tconst {\n\t\tref,\n\t\tactive,\n\t\ttype,\n\t\talign,\n\t\tdisabled,\n\t\tlabel,\n\t\tstyle,\n\t\tclassName,\n\t\tchildren,\n\t\t...restProps\n\t} = props;\n\n\treturn (\n\t\t<li\n\t\t\tref={ref}\n\t\t\tclassName={classNames(\"i-list-item\", className, {\n\t\t\t\t\"i-list-item-active\": active,\n\t\t\t\t\"i-list-option\": type === \"option\",\n\t\t\t\tdisabled,\n\t\t\t})}\n\t\t\tstyle={{ alignItems: align, ...style }}\n\t\t\t{...restProps}\n\t\t>\n\t\t\t{label !== undefined && (\n\t\t\t\t<span className='i-list-item-label'>{label}</span>\n\t\t\t)}\n\t\t\t{children}\n\t\t</li>\n\t);\n};\n\nexport default Item;\n"],"names":["_jsxs","_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"item.js","sources":["../../../../packages/components/list/item.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport { IListItem } from \"./type\";\n\nconst Item = (props: IListItem) => {\n\tconst {\n\t\tref,\n\t\tactive,\n\t\ttype,\n\t\talign,\n\t\tdisabled,\n\t\tlabel,\n\t\tstyle,\n\t\tclassName,\n\t\tchildren,\n\t\t...restProps\n\t} = props;\n\n\treturn (\n\t\t<li\n\t\t\tref={ref}\n\t\t\tclassName={classNames(\"i-list-item\", className, {\n\t\t\t\t\"i-list-item-active\": active,\n\t\t\t\t\"i-list-option\": type === \"option\",\n\t\t\t\tdisabled,\n\t\t\t})}\n\t\t\tstyle={{ alignItems: align, ...style }}\n\t\t\t{...restProps}\n\t\t>\n\t\t\t{label !== undefined && (\n\t\t\t\t<span className='i-list-item-label'>{label}</span>\n\t\t\t)}\n\t\t\t{children}\n\t\t</li>\n\t);\n};\n\nexport default Item;\n"],"names":["_jsxs","classNames","_jsx"],"mappings":";;;;;;;;;;;AAGA,MAAM,IAAI,GAAG,CAAC,KAAgB,KAAI;IACjC,MAAM,EACL,GAAG,EACH,MAAM,EACN,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,KAAK,EACL,KAAK,EACL,SAAS,EACT,QAAQ,EACR,GAAG,SAAS,EACZ,GAAG,KAAK;AAET,IAAA,QACCA,eAAA,CAAA,IAAA,EAAA,EACC,GAAG,EAAE,GAAG,EACR,SAAS,EAAEC,mBAAU,CAAC,aAAa,EAAE,SAAS,EAAE;AAC/C,YAAA,oBAAoB,EAAE,MAAM;YAC5B,eAAe,EAAE,IAAI,KAAK,QAAQ;YAClC,QAAQ;AACR,SAAA,CAAC,EACF,KAAK,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAA,GAClC,SAAS,EAEZ,QAAA,EAAA,CAAA,KAAK,KAAK,SAAS,KACnBC,cAAM,CAAA,MAAA,EAAA,EAAA,SAAS,EAAC,mBAAmB,EAAA,QAAA,EAAE,KAAK,EAAA,CAAQ,CAClD,EACA,QAAQ,CAAA,EAAA,CACL;AAEP;;;;"}
|
|
@@ -7,9 +7,13 @@ var classNames = require('classnames');
|
|
|
7
7
|
var react = require('react');
|
|
8
8
|
var item = require('./item.js');
|
|
9
9
|
|
|
10
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
11
|
+
|
|
12
|
+
var classNames__default = /*#__PURE__*/_interopDefaultCompat(classNames);
|
|
13
|
+
|
|
10
14
|
const List = (props) => {
|
|
11
15
|
const { label, type, className, children, ...restProps } = props;
|
|
12
|
-
return (jsxRuntime.jsx("ul", { className:
|
|
16
|
+
return (jsxRuntime.jsx("ul", { className: classNames__default("i-list", className), ...restProps, children: react.Children.map(children, (node, i) => {
|
|
13
17
|
const renderLabel = typeof label === "function" ? label(i) : label;
|
|
14
18
|
const { type, props: nodeProps } = node;
|
|
15
19
|
if (type === item.default) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sources":["../../../../packages/components/list/list.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport { Children, cloneElement } from \"react\";\nimport \"./index.css\";\nimport Item from \"./item\";\nimport { IList } from \"./type\";\n\nconst List = (props: IList) => {\n\tconst { label, type, className, children, ...restProps } = props;\n\n\treturn (\n\t\t<ul className={classNames(\"i-list\", className)} {...restProps}>\n\t\t\t{Children.map(children, (node: any, i) => {\n\t\t\t\tconst renderLabel =\n\t\t\t\t\ttypeof label === \"function\" ? label(i) : label;\n\n\t\t\t\tconst { type, props: nodeProps } = node;\n\n\t\t\t\tif (type === Item) {\n\t\t\t\t\treturn cloneElement(node, {\n\t\t\t\t\t\tlabel: renderLabel,\n\t\t\t\t\t\t...nodeProps,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn node;\n\t\t\t})}\n\t\t</ul>\n\t);\n};\n\nList.Item = Item;\n\nexport default List;\n"],"names":["_jsx","Children","Item","cloneElement"],"mappings":"
|
|
1
|
+
{"version":3,"file":"list.js","sources":["../../../../packages/components/list/list.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport { Children, cloneElement } from \"react\";\nimport \"./index.css\";\nimport Item from \"./item\";\nimport { IList } from \"./type\";\n\nconst List = (props: IList) => {\n\tconst { label, type, className, children, ...restProps } = props;\n\n\treturn (\n\t\t<ul className={classNames(\"i-list\", className)} {...restProps}>\n\t\t\t{Children.map(children, (node: any, i) => {\n\t\t\t\tconst renderLabel =\n\t\t\t\t\ttypeof label === \"function\" ? label(i) : label;\n\n\t\t\t\tconst { type, props: nodeProps } = node;\n\n\t\t\t\tif (type === Item) {\n\t\t\t\t\treturn cloneElement(node, {\n\t\t\t\t\t\tlabel: renderLabel,\n\t\t\t\t\t\t...nodeProps,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn node;\n\t\t\t})}\n\t\t</ul>\n\t);\n};\n\nList.Item = Item;\n\nexport default List;\n"],"names":["_jsx","classNames","Children","Item","cloneElement"],"mappings":";;;;;;;;;;;;;AAMA,MAAM,IAAI,GAAG,CAAC,KAAY,KAAI;AAC7B,IAAA,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK;IAEhE,QACCA,cAAI,CAAA,IAAA,EAAA,EAAA,SAAS,EAAEC,mBAAU,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAM,GAAA,SAAS,YAC3DC,cAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAS,EAAE,CAAC,KAAI;AACxC,YAAA,MAAM,WAAW,GAChB,OAAO,KAAK,KAAK,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK;YAE/C,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI;AAEvC,YAAA,IAAI,IAAI,KAAKC,YAAI,EAAE;gBAClB,OAAOC,kBAAY,CAAC,IAAI,EAAE;AACzB,oBAAA,KAAK,EAAE,WAAW;AAClB,oBAAA,GAAG,SAAS;oBACZ,IAAI;AACJ,iBAAA,CAAC;;AAGH,YAAA,OAAO,IAAI;SACX,CAAC,EACE,CAAA;AAEP;AAEA,IAAI,CAAC,IAAI,GAAGD,YAAI;;;;"}
|
|
@@ -5,9 +5,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var classNames = require('classnames');
|
|
7
7
|
|
|
8
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
9
|
+
|
|
10
|
+
var classNames__default = /*#__PURE__*/_interopDefaultCompat(classNames);
|
|
11
|
+
|
|
8
12
|
const Loading = (props) => {
|
|
9
13
|
const { icon, text, size, absolute, style, className, ...restProps } = props;
|
|
10
|
-
return (jsxRuntime.jsxs("div", { className:
|
|
14
|
+
return (jsxRuntime.jsxs("div", { className: classNames__default("i-loading-container", {
|
|
11
15
|
absolute,
|
|
12
16
|
}, className), style: {
|
|
13
17
|
...style,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loading.js","sources":["../../../../packages/components/loading/loading.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport \"./index.css\";\nimport { ILoading } from \"./type\";\n\nconst Loading = (props: ILoading) => {\n\tconst { icon, text, size, absolute, style, className, ...restProps } =\n\t\tprops;\n\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames(\n\t\t\t\t\"i-loading-container\",\n\t\t\t\t{\n\t\t\t\t\tabsolute,\n\t\t\t\t},\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tstyle={{\n\t\t\t\t...style,\n\t\t\t\tinset: absolute ? 0 : \"unset\",\n\t\t\t}}\n\t\t\t{...restProps}\n\t\t>\n\t\t\t{icon ?? (\n\t\t\t\t<svg\n\t\t\t\t\twidth='24'\n\t\t\t\t\theight='24'\n\t\t\t\t\tstroke='#000'\n\t\t\t\t\tviewBox='0 0 24 24'\n\t\t\t\t\txmlns='http://www.w3.org/2000/svg'\n\t\t\t\t\tclassName='i-loading-icon'\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tfontSize: size,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<circle\n\t\t\t\t\t\tcx='12'\n\t\t\t\t\t\tcy='12'\n\t\t\t\t\t\tr='9.5'\n\t\t\t\t\t\tfill='none'\n\t\t\t\t\t\tstrokeWidth='3'\n\t\t\t\t\t\tstrokeLinecap='round'\n\t\t\t\t\t\tstrokeDasharray={40}\n\t\t\t\t\t\tstrokeDashoffset={0}\n\t\t\t\t\t/>\n\t\t\t\t</svg>\n\t\t\t)}\n\n\t\t\t{text}\n\t\t</div>\n\t);\n};\n\nexport default Loading;\n"],"names":["_jsxs","_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"loading.js","sources":["../../../../packages/components/loading/loading.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport \"./index.css\";\nimport { ILoading } from \"./type\";\n\nconst Loading = (props: ILoading) => {\n\tconst { icon, text, size, absolute, style, className, ...restProps } =\n\t\tprops;\n\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames(\n\t\t\t\t\"i-loading-container\",\n\t\t\t\t{\n\t\t\t\t\tabsolute,\n\t\t\t\t},\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tstyle={{\n\t\t\t\t...style,\n\t\t\t\tinset: absolute ? 0 : \"unset\",\n\t\t\t}}\n\t\t\t{...restProps}\n\t\t>\n\t\t\t{icon ?? (\n\t\t\t\t<svg\n\t\t\t\t\twidth='24'\n\t\t\t\t\theight='24'\n\t\t\t\t\tstroke='#000'\n\t\t\t\t\tviewBox='0 0 24 24'\n\t\t\t\t\txmlns='http://www.w3.org/2000/svg'\n\t\t\t\t\tclassName='i-loading-icon'\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tfontSize: size,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<circle\n\t\t\t\t\t\tcx='12'\n\t\t\t\t\t\tcy='12'\n\t\t\t\t\t\tr='9.5'\n\t\t\t\t\t\tfill='none'\n\t\t\t\t\t\tstrokeWidth='3'\n\t\t\t\t\t\tstrokeLinecap='round'\n\t\t\t\t\t\tstrokeDasharray={40}\n\t\t\t\t\t\tstrokeDashoffset={0}\n\t\t\t\t\t/>\n\t\t\t\t</svg>\n\t\t\t)}\n\n\t\t\t{text}\n\t\t</div>\n\t);\n};\n\nexport default Loading;\n"],"names":["_jsxs","classNames","_jsx"],"mappings":";;;;;;;;;;;AAIA,MAAM,OAAO,GAAG,CAAC,KAAe,KAAI;AACnC,IAAA,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,GACnE,KAAK;AAEN,IAAA,QACCA,eACC,CAAA,KAAA,EAAA,EAAA,SAAS,EAAEC,mBAAU,CACpB,qBAAqB,EACrB;YACC,QAAQ;AACR,SAAA,EACD,SAAS,CACT,EACD,KAAK,EAAE;AACN,YAAA,GAAG,KAAK;YACR,KAAK,EAAE,QAAQ,GAAG,CAAC,GAAG,OAAO;AAC7B,SAAA,EAAA,GACG,SAAS,EAAA,QAAA,EAAA,CAEZ,IAAI,KACJC,cAAA,CAAA,KAAA,EAAA,EACC,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,MAAM,EAAC,MAAM,EACb,OAAO,EAAC,WAAW,EACnB,KAAK,EAAC,4BAA4B,EAClC,SAAS,EAAC,gBAAgB,EAC1B,KAAK,EAAE;AACN,oBAAA,QAAQ,EAAE,IAAI;AACd,iBAAA,EAAA,QAAA,EAEDA,2BACC,EAAE,EAAC,IAAI,EACP,EAAE,EAAC,IAAI,EACP,CAAC,EAAC,KAAK,EACP,IAAI,EAAC,MAAM,EACX,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,eAAe,EAAE,EAAE,EACnB,gBAAgB,EAAE,CAAC,GAClB,EACG,CAAA,CACN,EAEA,IAAI,CAAA,EAAA,CACA;AAER;;;;"}
|
|
@@ -9,6 +9,10 @@ var radash = require('radash');
|
|
|
9
9
|
var react = require('react');
|
|
10
10
|
var client = require('react-dom/client');
|
|
11
11
|
|
|
12
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
13
|
+
|
|
14
|
+
var classNames__default = /*#__PURE__*/_interopDefaultCompat(classNames);
|
|
15
|
+
|
|
12
16
|
const AlignMap = {
|
|
13
17
|
left: "flex-start",
|
|
14
18
|
center: "center",
|
|
@@ -42,7 +46,7 @@ const heights = {
|
|
|
42
46
|
};
|
|
43
47
|
client.createRoot(container).render(jsxRuntime.jsx(Messages, {}));
|
|
44
48
|
const MessageItem = function ({ ref, active, content, top, className, style, onClick, }) {
|
|
45
|
-
return (jsxRuntime.jsx("div", { ref: ref, className:
|
|
49
|
+
return (jsxRuntime.jsx("div", { ref: ref, className: classNames__default("i-message", className, {
|
|
46
50
|
"i-message-active": active,
|
|
47
51
|
}), style: {
|
|
48
52
|
...style,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sources":["../../../../packages/components/message/message.tsx"],"sourcesContent":["import { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { uid } from \"radash\";\nimport { ReactNode, isValidElement, useEffect, useRef } from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport \"./index.css\";\nimport type { IMessage, IMessageItem, THeights, TMessageQueue } from \"./type\";\n\nconst AlignMap = {\n\tleft: \"flex-start\",\n\tcenter: \"center\",\n\tright: \"flex-end\",\n};\n\nconst GlobalConfig = {\n\talign: \"center\",\n\toffset: \"12px\",\n\tgap: 12,\n};\n\nconst ItemDefaultConfig = {\n\tduration: 3000,\n\tclosable: true,\n\tactive: false,\n};\n\nconst container = createContainer();\nconst handler: {\n\toneInstance: null | IMessage;\n\tcallout: (item: IMessage) => void;\n\tclose: () => void;\n} = {\n\toneInstance: null,\n\tcallout(item: IMessage) {},\n\tclose() {},\n};\n\nconst queue: TMessageQueue = {\n\tleft: [],\n\tcenter: [],\n\tright: [],\n};\nconst heights: THeights = {\n\tleft: [],\n\tcenter: [],\n\tright: [],\n};\n\ncreateRoot(container).render(<Messages />);\n\nconst MessageItem = function ({\n\tref,\n\tactive,\n\tcontent,\n\ttop,\n\tclassName,\n\tstyle,\n\tonClick,\n}: IMessageItem) {\n\treturn (\n\t\t<div\n\t\t\tref={ref}\n\t\t\tclassName={classNames(\"i-message\", className, {\n\t\t\t\t\"i-message-active\": active,\n\t\t\t})}\n\t\t\tstyle={{\n\t\t\t\t...style,\n\t\t\t\ttop,\n\t\t\t}}\n\t\t\tonClick={onClick}\n\t\t>\n\t\t\t{content}\n\t\t</div>\n\t);\n};\n\nfunction Messages() {\n\tconst ref = useRef<HTMLDivElement>(null);\n\tconst state = useReactive<{\n\t\ttops: THeights;\n\t\titems: TMessageQueue;\n\t}>({\n\t\titems: {\n\t\t\tleft: [],\n\t\t\tcenter: [],\n\t\t\tright: [],\n\t\t},\n\t\ttops: {\n\t\t\tleft: [],\n\t\t\tcenter: [],\n\t\t\tright: [],\n\t\t},\n\t});\n\tconst offsetTop = {\n\t\tleft: 0,\n\t\tcenter: 0,\n\t\tright: 0,\n\t};\n\n\tuseEffect(() => {\n\t\tObject.assign(handler, {\n\t\t\tcallout: function (item: IMessage) {\n\t\t\t\tconst { align = \"center\", unshift, onShow } = item;\n\t\t\t\tconst size = queue[align][unshift ? \"unshift\" : \"push\"](item);\n\t\t\t\tstate.items[align] = [...queue[align]];\n\t\t\t\titem.close = this.close.bind(item);\n\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tconst h = ref.current?.offsetHeight || 0;\n\n\t\t\t\t\tqueue[align][unshift ? 0 : size - 1].active = true;\n\t\t\t\t\tstate.items[align] = [...queue[align]];\n\t\t\t\t\theights[align][unshift ? \"unshift\" : \"push\"](h);\n\t\t\t\t\tstate.tops[align] = [...heights[align]];\n\t\t\t\t\tonShow?.();\n\t\t\t\t}, 12);\n\n\t\t\t\tif (item.duration !== 0) {\n\t\t\t\t\titem.timer = setTimeout(() => {\n\t\t\t\t\t\tthis.close.call(item);\n\t\t\t\t\t}, item.duration);\n\t\t\t\t}\n\t\t\t},\n\t\t\tclose: function () {\n\t\t\t\tconst item = this as IMessage;\n\t\t\t\tconst { align = \"center\", onHide } = item;\n\t\t\t\tconst index = queue[align].findIndex((i) => i.id === item.id);\n\t\t\t\tif (index < 0) return;\n\n\t\t\t\tqueue[align][index].active = false;\n\t\t\t\tstate.items[align] = [...queue[align]];\n\n\t\t\t\titem.timer = setTimeout(() => {\n\t\t\t\t\tconst index = queue[align].findIndex(\n\t\t\t\t\t\t(i) => i.id === item.id\n\t\t\t\t\t);\n\n\t\t\t\t\tqueue[align].splice(index, 1);\n\t\t\t\t\theights[align].splice(index, 1);\n\t\t\t\t\tstate.tops[align] = [...heights[align]];\n\t\t\t\t\tstate.items[align] = [...queue[align]];\n\t\t\t\t\titem.timer && clearTimeout(item.timer);\n\t\t\t\t\tonHide?.();\n\t\t\t\t}, 240);\n\t\t\t},\n\t\t});\n\t}, []);\n\n\tconst renderItems = (item, i) => {\n\t\tif (!item) return <></>;\n\n\t\tconst { id, active, content, align = \"center\", className } = item;\n\t\toffsetTop[align] += state.tops[align][i - 1] || 0;\n\t\tconst top = GlobalConfig.gap * i + offsetTop[align];\n\n\t\treturn (\n\t\t\t<MessageItem\n\t\t\t\tkey={id}\n\t\t\t\tref={ref}\n\t\t\t\tactive={active}\n\t\t\t\tcontent={content}\n\t\t\t\ttop={top}\n\t\t\t\tclassName={className}\n\t\t\t\tstyle={{ alignSelf: AlignMap[align] }}\n\t\t\t\tonClick={handler.close.bind(item)}\n\t\t\t/>\n\t\t);\n\t};\n\n\treturn (\n\t\t<div className='i-messages'>\n\t\t\t{state.items.left.map(renderItems)}\n\t\t\t{state.items.center.map(renderItems)}\n\t\t\t{state.items.right.map(renderItems)}\n\t\t</div>\n\t);\n}\n\nexport function setMessageConfig(config: IMessage) {\n\tObject.assign(GlobalConfig, config);\n}\n\nfunction message(config: IMessage | ReactNode) {\n\tif (\n\t\t[\"string\", \"number\"].includes(typeof config) ||\n\t\tisValidElement(config)\n\t) {\n\t\tconfig = { content: config as ReactNode };\n\t}\n\n\tconfig = Object.assign(\n\t\t{ id: uid(7) },\n\t\tItemDefaultConfig,\n\t\tconfig as IMessage\n\t);\n\n\thandler.callout(config as IMessage);\n\n\treturn {\n\t\tinstance: config,\n\t\tclose: handler.close.bind(config),\n\t};\n}\n\nfunction createContainer() {\n\tconst container = document.createElement(\"div\");\n\tcontainer.dataset.id = \"messages\";\n\tdocument.body.append(container);\n\n\treturn container;\n}\n\nmessage.error = (content: ReactNode) => {\n\treturn message({\n\t\tcontent,\n\t\tclassName: \"bg-error\",\n\t});\n};\n\nmessage.success = (content: ReactNode) => {\n\treturn message({\n\t\tcontent,\n\t\tclassName: \"bg-success\",\n\t});\n};\n\nmessage.warning = (content: ReactNode) => {\n\treturn message({\n\t\tcontent,\n\t\tclassName: \"bg-warning\",\n\t});\n};\n\nmessage.one = (config: IMessage) => {\n\tconst o = handler.oneInstance;\n\n\tif (o) {\n\t\tif (o.active && o.duration !== 0) {\n\t\t\tclearTimeout(o.timer);\n\t\t\to.timer = setTimeout(() => {\n\t\t\t\to.close?.();\n\t\t\t}, o.duration);\n\t\t} else {\n\t\t\thandler.callout(o);\n\t\t}\n\t} else {\n\t\tconst { instance } = message(config);\n\t\thandler.oneInstance = instance;\n\t}\n};\n\nexport default message;\n"],"names":["createRoot","_jsx","useRef","useReactive","useEffect","_jsxs","isValidElement","uid"],"mappings":";;;;;;;;;;;AAQA,MAAM,QAAQ,GAAG;AAChB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,KAAK,EAAE,UAAU;CACjB;AAED,MAAM,YAAY,GAAG;AACpB,IAAA,KAAK,EAAE,QAAQ;AACf,IAAA,MAAM,EAAE,MAAM;AACd,IAAA,GAAG,EAAE,EAAE;CACP;AAED,MAAM,iBAAiB,GAAG;AACzB,IAAA,QAAQ,EAAE,IAAI;AACd,IAAA,QAAQ,EAAE,IAAI;AACd,IAAA,MAAM,EAAE,KAAK;CACb;AAED,MAAM,SAAS,GAAG,eAAe,EAAE;AACnC,MAAM,OAAO,GAIT;AACH,IAAA,WAAW,EAAE,IAAI;IACjB,OAAO,CAAC,IAAc,EAAA,GAAI;AAC1B,IAAA,KAAK,MAAK;CACV;AAED,MAAM,KAAK,GAAkB;AAC5B,IAAA,IAAI,EAAE,EAAE;AACR,IAAA,MAAM,EAAE,EAAE;AACV,IAAA,KAAK,EAAE,EAAE;CACT;AACD,MA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OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;;;SAEb;QACN,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;AACpC,QAAA,OAAO,CAAC,WAAW,GAAG,QAAQ;;AAEhC,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"message.js","sources":["../../../../packages/components/message/message.tsx"],"sourcesContent":["import { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { uid } from \"radash\";\nimport { ReactNode, isValidElement, useEffect, useRef } from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport \"./index.css\";\nimport type { IMessage, IMessageItem, THeights, TMessageQueue } from \"./type\";\n\nconst AlignMap = {\n\tleft: \"flex-start\",\n\tcenter: \"center\",\n\tright: \"flex-end\",\n};\n\nconst GlobalConfig = {\n\talign: \"center\",\n\toffset: \"12px\",\n\tgap: 12,\n};\n\nconst ItemDefaultConfig = {\n\tduration: 3000,\n\tclosable: true,\n\tactive: false,\n};\n\nconst container = createContainer();\nconst handler: {\n\toneInstance: null | IMessage;\n\tcallout: (item: IMessage) => void;\n\tclose: () => void;\n} = {\n\toneInstance: null,\n\tcallout(item: IMessage) {},\n\tclose() {},\n};\n\nconst queue: TMessageQueue = {\n\tleft: [],\n\tcenter: [],\n\tright: [],\n};\nconst heights: THeights = {\n\tleft: [],\n\tcenter: [],\n\tright: [],\n};\n\ncreateRoot(container).render(<Messages />);\n\nconst MessageItem = function ({\n\tref,\n\tactive,\n\tcontent,\n\ttop,\n\tclassName,\n\tstyle,\n\tonClick,\n}: IMessageItem) {\n\treturn (\n\t\t<div\n\t\t\tref={ref}\n\t\t\tclassName={classNames(\"i-message\", className, {\n\t\t\t\t\"i-message-active\": active,\n\t\t\t})}\n\t\t\tstyle={{\n\t\t\t\t...style,\n\t\t\t\ttop,\n\t\t\t}}\n\t\t\tonClick={onClick}\n\t\t>\n\t\t\t{content}\n\t\t</div>\n\t);\n};\n\nfunction Messages() {\n\tconst ref = useRef<HTMLDivElement>(null);\n\tconst state = useReactive<{\n\t\ttops: THeights;\n\t\titems: TMessageQueue;\n\t}>({\n\t\titems: {\n\t\t\tleft: [],\n\t\t\tcenter: [],\n\t\t\tright: [],\n\t\t},\n\t\ttops: {\n\t\t\tleft: [],\n\t\t\tcenter: [],\n\t\t\tright: [],\n\t\t},\n\t});\n\tconst offsetTop = {\n\t\tleft: 0,\n\t\tcenter: 0,\n\t\tright: 0,\n\t};\n\n\tuseEffect(() => {\n\t\tObject.assign(handler, {\n\t\t\tcallout: function (item: IMessage) {\n\t\t\t\tconst { align = \"center\", unshift, onShow } = item;\n\t\t\t\tconst size = queue[align][unshift ? \"unshift\" : \"push\"](item);\n\t\t\t\tstate.items[align] = [...queue[align]];\n\t\t\t\titem.close = this.close.bind(item);\n\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tconst h = ref.current?.offsetHeight || 0;\n\n\t\t\t\t\tqueue[align][unshift ? 0 : size - 1].active = true;\n\t\t\t\t\tstate.items[align] = [...queue[align]];\n\t\t\t\t\theights[align][unshift ? \"unshift\" : \"push\"](h);\n\t\t\t\t\tstate.tops[align] = [...heights[align]];\n\t\t\t\t\tonShow?.();\n\t\t\t\t}, 12);\n\n\t\t\t\tif (item.duration !== 0) {\n\t\t\t\t\titem.timer = setTimeout(() => {\n\t\t\t\t\t\tthis.close.call(item);\n\t\t\t\t\t}, item.duration);\n\t\t\t\t}\n\t\t\t},\n\t\t\tclose: function () {\n\t\t\t\tconst item = this as IMessage;\n\t\t\t\tconst { align = \"center\", onHide } = item;\n\t\t\t\tconst index = queue[align].findIndex((i) => i.id === item.id);\n\t\t\t\tif (index < 0) return;\n\n\t\t\t\tqueue[align][index].active = false;\n\t\t\t\tstate.items[align] = [...queue[align]];\n\n\t\t\t\titem.timer = setTimeout(() => {\n\t\t\t\t\tconst index = queue[align].findIndex(\n\t\t\t\t\t\t(i) => i.id === item.id\n\t\t\t\t\t);\n\n\t\t\t\t\tqueue[align].splice(index, 1);\n\t\t\t\t\theights[align].splice(index, 1);\n\t\t\t\t\tstate.tops[align] = [...heights[align]];\n\t\t\t\t\tstate.items[align] = [...queue[align]];\n\t\t\t\t\titem.timer && clearTimeout(item.timer);\n\t\t\t\t\tonHide?.();\n\t\t\t\t}, 240);\n\t\t\t},\n\t\t});\n\t}, []);\n\n\tconst renderItems = (item, i) => {\n\t\tif (!item) return <></>;\n\n\t\tconst { id, active, content, align = \"center\", className } = item;\n\t\toffsetTop[align] += state.tops[align][i - 1] || 0;\n\t\tconst top = GlobalConfig.gap * i + offsetTop[align];\n\n\t\treturn (\n\t\t\t<MessageItem\n\t\t\t\tkey={id}\n\t\t\t\tref={ref}\n\t\t\t\tactive={active}\n\t\t\t\tcontent={content}\n\t\t\t\ttop={top}\n\t\t\t\tclassName={className}\n\t\t\t\tstyle={{ alignSelf: AlignMap[align] }}\n\t\t\t\tonClick={handler.close.bind(item)}\n\t\t\t/>\n\t\t);\n\t};\n\n\treturn (\n\t\t<div className='i-messages'>\n\t\t\t{state.items.left.map(renderItems)}\n\t\t\t{state.items.center.map(renderItems)}\n\t\t\t{state.items.right.map(renderItems)}\n\t\t</div>\n\t);\n}\n\nexport function setMessageConfig(config: IMessage) {\n\tObject.assign(GlobalConfig, config);\n}\n\nfunction message(config: IMessage | ReactNode) {\n\tif (\n\t\t[\"string\", \"number\"].includes(typeof config) ||\n\t\tisValidElement(config)\n\t) {\n\t\tconfig = { content: config as ReactNode };\n\t}\n\n\tconfig = Object.assign(\n\t\t{ id: uid(7) },\n\t\tItemDefaultConfig,\n\t\tconfig as IMessage\n\t);\n\n\thandler.callout(config as IMessage);\n\n\treturn {\n\t\tinstance: config,\n\t\tclose: handler.close.bind(config),\n\t};\n}\n\nfunction createContainer() {\n\tconst container = document.createElement(\"div\");\n\tcontainer.dataset.id = \"messages\";\n\tdocument.body.append(container);\n\n\treturn container;\n}\n\nmessage.error = (content: ReactNode) => {\n\treturn message({\n\t\tcontent,\n\t\tclassName: \"bg-error\",\n\t});\n};\n\nmessage.success = (content: ReactNode) => {\n\treturn message({\n\t\tcontent,\n\t\tclassName: \"bg-success\",\n\t});\n};\n\nmessage.warning = (content: ReactNode) => {\n\treturn message({\n\t\tcontent,\n\t\tclassName: \"bg-warning\",\n\t});\n};\n\nmessage.one = (config: IMessage) => {\n\tconst o = handler.oneInstance;\n\n\tif (o) {\n\t\tif (o.active && o.duration !== 0) {\n\t\t\tclearTimeout(o.timer);\n\t\t\to.timer = setTimeout(() => {\n\t\t\t\to.close?.();\n\t\t\t}, o.duration);\n\t\t} else {\n\t\t\thandler.callout(o);\n\t\t}\n\t} else {\n\t\tconst { instance } = message(config);\n\t\thandler.oneInstance = instance;\n\t}\n};\n\nexport default message;\n"],"names":["createRoot","_jsx","classNames","useRef","useReactive","useEffect","_jsxs","isValidElement","uid"],"mappings":";;;;;;;;;;;;;;;AAQA,MAAM,QAAQ,GAAG;AAChB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,KAAK,EAAE,UAAU;CACjB;AAED,MAAM,YAAY,GAAG;AACpB,IAAA,KAAK,EAAE,QAAQ;AACf,IAAA,MAAM,EAAE,MAAM;AACd,IAAA,GAAG,EAAE,EAAE;CACP;AAED,MAAM,iBAAiB,GAAG;AACzB,IAAA,QAAQ,EAAE,IAAI;AACd,IAAA,QAAQ,EAAE,IAAI;AACd,IAAA,MAAM,EAAE,KAAK;CACb;AAED,MAAM,SAAS,GAAG,eAAe,EAAE;AACnC,MAAM,OAAO,GAIT;AACH,IAAA,WAAW,EAAE,IAAI;IACjB,OAAO,CAAC,IAAc,EAAA,GAAI;AAC1B,IAAA,KAAK,MAAK;CACV;AAED,MAAM,KAAK,GAAkB;AAC5B,IAAA,IAAI,EAAE,EAAE;AACR,IAAA,MAAM,EAAE,EAAE;AACV,IAAA,KAAK,EAAE,EAAE;CACT;AACD,MAAM,OAAO,GAAa;AACzB,IAAA,IAAI,EAAE,EAAE;AACR,IAAA,MAAM,EAAE,EAAE;A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E,GAAG,OAAO,CAAC,MAAM,CAAC;AACpC,QAAA,OAAO,CAAC,WAAW,GAAG,QAAQ;;AAEhC,CAAC;;;;"}
|
|
@@ -11,6 +11,10 @@ require('../button/index.js');
|
|
|
11
11
|
var helpericon = require('../utils/helpericon/helpericon.js');
|
|
12
12
|
var button = require('../button/button.js');
|
|
13
13
|
|
|
14
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
15
|
+
|
|
16
|
+
var classNames__default = /*#__PURE__*/_interopDefaultCompat(classNames);
|
|
17
|
+
|
|
14
18
|
function DefaultContent(props) {
|
|
15
19
|
const { title, footer, hideCloseButton, footerLeft, okButtonProps, cancelButtonProps, children, onOk, onClose, } = props;
|
|
16
20
|
const showHeader = title || !hideCloseButton;
|
|
@@ -86,12 +90,12 @@ function Modal(props) {
|
|
|
86
90
|
}, [visible]);
|
|
87
91
|
if (!show)
|
|
88
92
|
return null;
|
|
89
|
-
return reactDom.createPortal(jsxRuntime.jsx("div", { className:
|
|
93
|
+
return reactDom.createPortal(jsxRuntime.jsx("div", { className: classNames__default("i-modal-container", {
|
|
90
94
|
"i-modal-backdrop": !hideBackdrop,
|
|
91
95
|
"i-modal-customized": customized,
|
|
92
96
|
"i-modal-active": active,
|
|
93
97
|
fixed,
|
|
94
|
-
}, className), style: style, onClick: handleBackdropClick, children: jsxRuntime.jsxs("div", { className:
|
|
98
|
+
}, className), style: style, onClick: handleBackdropClick, children: jsxRuntime.jsxs("div", { className: classNames__default("i-modal", {
|
|
95
99
|
bounced,
|
|
96
100
|
shadow: !hideShadow,
|
|
97
101
|
}), style: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.js","sources":["../../../../packages/components/modal/modal.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { useKeydown } from \"../../js/hooks\";\nimport Button from \"../button\";\nimport Helpericon from \"../utils/helpericon\";\nimport \"./index.css\";\nimport { CompositionModal, IModal, IModalContent } from \"./type\";\n\nfunction DefaultContent(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) 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\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 = () => {\n\t\tif (!toggable.current) return;\n\n\t\t(!keepDOM || !show) && setShow(true);\n\t\ttoggable.current = false;\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\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\tdocument.documentElement.click();\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<DefaultContent\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\n\t);\n}\n\nexport default Modal as CompositionModal;\n"],"names":["useMemo","_jsxs","_Fragment","_jsx","Button","Helpericon","useState","useRef","useKeydown","useEffect","createPortal"],"mappings":"
|
|
1
|
+
{"version":3,"file":"modal.js","sources":["../../../../packages/components/modal/modal.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { useKeydown } from \"../../js/hooks\";\nimport Button from \"../button\";\nimport Helpericon from \"../utils/helpericon\";\nimport \"./index.css\";\nimport { CompositionModal, IModal, IModalContent } from \"./type\";\n\nfunction DefaultContent(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) 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\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 = () => {\n\t\tif (!toggable.current) return;\n\n\t\t(!keepDOM || !show) && setShow(true);\n\t\ttoggable.current = false;\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\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\tdocument.documentElement.click();\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<DefaultContent\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\n\t);\n}\n\nexport default Modal as CompositionModal;\n"],"names":["useMemo","_jsxs","_Fragment","_jsx","Button","Helpericon","useState","useRef","useKeydown","useEffect","createPortal","classNames"],"mappings":";;;;;;;;;;;;;;;;;AASA,SAAS,cAAc,CAAC,KAAoB,EAAA;IAC3C,MAAM,EACL,KAAK,EACL,MAAM,EACN,eAAe,EACf,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,Q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,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,mBAAmB,YAE5BV,eACC,CAAA,KAAA,EAAA,EAAA,SAAS,EAAEU,mBAAU,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,QAAQ,CAAC,eAAe,CAAC,KAAK,EAAE;AAChC,gBAAA,OAAO,GAAG,CAAC,CAAC;aACZ,EAAA,GACG,SAAS,EAAA,QAAA,EAAA,CAEZ,UAAU,IAAI,QAAQ,EAEtB,CAAC,UAAU,KACXR,cAAC,CAAA,cAAc,EACd,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,EAAA,CAClB,CACF,CAAA,EAAA,CACI,EACD,CAAA,EACN,QAAQ,CAAC,IAAI,CACb;AACF;;;;"}
|
|
@@ -7,6 +7,10 @@ var classNames = require('classnames');
|
|
|
7
7
|
var react = require('react');
|
|
8
8
|
var loading = require('../loading/loading.js');
|
|
9
9
|
|
|
10
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
11
|
+
|
|
12
|
+
var classNames__default = /*#__PURE__*/_interopDefaultCompat(classNames);
|
|
13
|
+
|
|
10
14
|
const Page = (props) => {
|
|
11
15
|
const { page, active, children, onChange } = props;
|
|
12
16
|
const [loading$1, setLoading] = react.useState(false);
|
|
@@ -17,7 +21,7 @@ const Page = (props) => {
|
|
|
17
21
|
await onChange?.(page);
|
|
18
22
|
setLoading(false);
|
|
19
23
|
};
|
|
20
|
-
return (jsxRuntime.jsxs("a", { className:
|
|
24
|
+
return (jsxRuntime.jsxs("a", { className: classNames__default("i-page", {
|
|
21
25
|
"i-page-active": active,
|
|
22
26
|
"i-page-loading": loading$1,
|
|
23
27
|
"i-page-disabled": false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.js","sources":["../../../../packages/components/pagination/page.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport { useState } from \"react\";\nimport Loading from \"../loading\";\nimport { IPageItem } from \"./type\";\n\nconst Page = (props: IPageItem) => {\n\tconst { page, active, children, onChange } = props;\n\tconst [loading, setLoading] = useState(false);\n\n\tconst handleClick = async () => {\n\t\tif (active || loading) return;\n\n\t\tsetLoading(true);\n\t\tawait onChange?.(page);\n\t\tsetLoading(false);\n\t};\n\n\treturn (\n\t\t<a\n\t\t\tclassName={classNames(\"i-page\", {\n\t\t\t\t\"i-page-active\": active,\n\t\t\t\t\"i-page-loading\": loading,\n\t\t\t\t\"i-page-disabled\": false,\n\t\t\t})}\n\t\t\tdata-page={page}\n\t\t\tonClick={handleClick}\n\t\t>\n\t\t\t{loading && <Loading />}\n\t\t\t{children}\n\t\t</a>\n\t);\n};\n\nexport default Page;\n"],"names":["loading","useState","_jsxs","_jsx","Loading"],"mappings":"
|
|
1
|
+
{"version":3,"file":"page.js","sources":["../../../../packages/components/pagination/page.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport { useState } from \"react\";\nimport Loading from \"../loading\";\nimport { IPageItem } from \"./type\";\n\nconst Page = (props: IPageItem) => {\n\tconst { page, active, children, onChange } = props;\n\tconst [loading, setLoading] = useState(false);\n\n\tconst handleClick = async () => {\n\t\tif (active || loading) return;\n\n\t\tsetLoading(true);\n\t\tawait onChange?.(page);\n\t\tsetLoading(false);\n\t};\n\n\treturn (\n\t\t<a\n\t\t\tclassName={classNames(\"i-page\", {\n\t\t\t\t\"i-page-active\": active,\n\t\t\t\t\"i-page-loading\": loading,\n\t\t\t\t\"i-page-disabled\": false,\n\t\t\t})}\n\t\t\tdata-page={page}\n\t\t\tonClick={handleClick}\n\t\t>\n\t\t\t{loading && <Loading />}\n\t\t\t{children}\n\t\t</a>\n\t);\n};\n\nexport default Page;\n"],"names":["loading","useState","_jsxs","classNames","_jsx","Loading"],"mappings":";;;;;;;;;;;;;AAKA,MAAM,IAAI,GAAG,CAAC,KAAgB,KAAI;IACjC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK;IAClD,MAAM,CAACA,SAAO,EAAE,UAAU,CAAC,GAAGC,cAAQ,CAAC,KAAK,CAAC;AAE7C,IAAA,MAAM,WAAW,GAAG,YAAW;QAC9B,IAAI,MAAM,IAAID,SAAO;YAAE;QAEvB,UAAU,CAAC,IAAI,CAAC;AAChB,QAAA,MAAM,QAAQ,GAAG,IAAI,CAAC;QACtB,UAAU,CAAC,KAAK,CAAC;AAClB,KAAC;AAED,IAAA,QACCE,eACC,CAAA,GAAA,EAAA,EAAA,SAAS,EAAEC,mBAAU,CAAC,QAAQ,EAAE;AAC/B,YAAA,eAAe,EAAE,MAAM;AACvB,YAAA,gBAAgB,EAAEH,SAAO;AACzB,YAAA,iBAAiB,EAAE,KAAK;AACxB,SAAA,CAAC,eACS,IAAI,EACf,OAAO,EAAE,WAAW,EAEnB,QAAA,EAAA,CAAAA,SAAO,IAAII,cAAA,CAACC,eAAO,EAAG,EAAA,CAAA,EACtB,QAAQ,CAAA,EAAA,CACN;AAEN;;;;"}
|
|
@@ -9,6 +9,10 @@ var react = require('react');
|
|
|
9
9
|
var icon = require('../icon/icon.js');
|
|
10
10
|
var page = require('./page.js');
|
|
11
11
|
|
|
12
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
13
|
+
|
|
14
|
+
var classNames__default = /*#__PURE__*/_interopDefaultCompat(classNames);
|
|
15
|
+
|
|
12
16
|
const Pagination = (props) => {
|
|
13
17
|
const { page: defaultPage = 1, size = 10, total = 0, sibling = 2, prev = jsxRuntime.jsx(icon.default, { icon: jsxRuntime.jsx(material.KeyboardArrowLeftRound, {}) }), next = jsxRuntime.jsx(icon.default, { icon: jsxRuntime.jsx(material.KeyboardArrowRightRound, {}) }), simple, jumper, className, renderEllipsis = () => (jsxRuntime.jsx(icon.default, { icon: jsxRuntime.jsx(material.MoreHorizRound, {}), className: 'color-7' })), renderPage = (i) => i, onChange, ...restProps } = props;
|
|
14
18
|
const [page$1, setPage] = react.useState(defaultPage);
|
|
@@ -39,7 +43,7 @@ const Pagination = (props) => {
|
|
|
39
43
|
});
|
|
40
44
|
};
|
|
41
45
|
react.useEffect(() => setPage(defaultPage), [defaultPage]);
|
|
42
|
-
return (jsxRuntime.jsxs("div", { className:
|
|
46
|
+
return (jsxRuntime.jsxs("div", { className: classNames__default("i-pagination", className), ...restProps, children: [prev && (jsxRuntime.jsx(page.default, { page: page$1 - 1 || 1, onChange: handlePageChange, children: prev })), start > 1 && (jsxRuntime.jsx(page.default, { page: 1, onChange: handlePageChange, children: renderPage(1) })), start > 2 && renderEllipsis(), loop.map((p) => {
|
|
43
47
|
return (jsxRuntime.jsx(page.default, { page: p, active: p === page$1, onChange: handlePageChange, children: renderPage(p) }, p));
|
|
44
48
|
}), end < totalPage - 1 && renderEllipsis(), end < totalPage && (jsxRuntime.jsx(page.default, { page: totalPage, onChange: handlePageChange, children: renderPage(totalPage) })), next && (jsxRuntime.jsx(page.default, { page: page$1 + 1, onChange: handlePageChange, children: next }))] }));
|
|
45
49
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.js","sources":["../../../../packages/components/pagination/pagination.tsx"],"sourcesContent":["import {\n\tKeyboardArrowLeftRound,\n\tKeyboardArrowRightRound,\n\tMoreHorizRound,\n} from \"@ricons/material\";\nimport classNames from \"classnames\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport Icon from \"../icon\";\nimport \"./index.css\";\nimport Page from \"./page\";\nimport { IPagination } from \"./type\";\n\nconst Pagination = (props: IPagination) => {\n\tconst {\n\t\tpage: defaultPage = 1,\n\t\tsize = 10,\n\t\ttotal = 0,\n\t\tsibling = 2,\n\t\tprev = <Icon icon={<KeyboardArrowLeftRound />} />,\n\t\tnext = <Icon icon={<KeyboardArrowRightRound />} />,\n\t\tsimple,\n\t\tjumper,\n\t\tclassName,\n\t\trenderEllipsis = () => (\n\t\t\t<Icon icon={<MoreHorizRound />} className='color-7' />\n\t\t),\n\t\trenderPage = (i) => i,\n\t\tonChange,\n\t\t...restProps\n\t} = props;\n\n\tconst [page, setPage] = useState(defaultPage);\n\tconst [loading, setLoading] = useState(false);\n\n\tconst totalPage = useMemo(() => Math.ceil(total / size), [size, total]);\n\n\tconst [start, end, loop] = useMemo(() => {\n\t\tconst start = Math.max(1, page - sibling);\n\t\tconst end = Math.min(totalPage, page + sibling);\n\n\t\treturn [\n\t\t\tstart,\n\t\t\tend,\n\t\t\tArray.from({ length: end - start + 1 }).map((n, i) => start + i),\n\t\t];\n\t}, [page, totalPage, sibling]);\n\n\tif (totalPage <= page && page === 1) return <></>;\n\n\tconst handlePageChange = async (p?: number) => {\n\t\tif (!onChange || loading) return;\n\t\tsetLoading(true);\n\n\t\treturn new Promise<void>(async (resolve) => {\n\t\t\tif (p === undefined) return;\n\t\t\tawait onChange(p);\n\t\t\tsetPage(p);\n\t\t\tsetLoading(false);\n\t\t\tresolve();\n\t\t});\n\t};\n\n\tuseEffect(() => setPage(defaultPage), [defaultPage]);\n\n\treturn (\n\t\t<div className={classNames(\"i-pagination\", className)} {...restProps}>\n\t\t\t{prev && (\n\t\t\t\t<Page page={page - 1 || 1} onChange={handlePageChange}>\n\t\t\t\t\t{prev}\n\t\t\t\t</Page>\n\t\t\t)}\n\n\t\t\t{start > 1 && (\n\t\t\t\t<Page page={1} onChange={handlePageChange}>\n\t\t\t\t\t{renderPage(1)}\n\t\t\t\t</Page>\n\t\t\t)}\n\n\t\t\t{start > 2 && renderEllipsis()}\n\n\t\t\t{loop.map((p) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Page\n\t\t\t\t\t\tkey={p}\n\t\t\t\t\t\tpage={p}\n\t\t\t\t\t\tactive={p === page}\n\t\t\t\t\t\tonChange={handlePageChange}\n\t\t\t\t\t>\n\t\t\t\t\t\t{renderPage(p)}\n\t\t\t\t\t</Page>\n\t\t\t\t);\n\t\t\t})}\n\n\t\t\t{end < totalPage - 1 && renderEllipsis()}\n\n\t\t\t{end < totalPage && (\n\t\t\t\t<Page page={totalPage} onChange={handlePageChange}>\n\t\t\t\t\t{renderPage(totalPage)}\n\t\t\t\t</Page>\n\t\t\t)}\n\n\t\t\t{next && (\n\t\t\t\t<Page page={page + 1} onChange={handlePageChange}>\n\t\t\t\t\t{next}\n\t\t\t\t</Page>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n\nexport default Pagination;\n"],"names":["_jsx","Icon","KeyboardArrowLeftRound","KeyboardArrowRightRound","MoreHorizRound","page","useState","useMemo","useEffect","_jsxs","Page"],"mappings":"
|
|
1
|
+
{"version":3,"file":"pagination.js","sources":["../../../../packages/components/pagination/pagination.tsx"],"sourcesContent":["import {\n\tKeyboardArrowLeftRound,\n\tKeyboardArrowRightRound,\n\tMoreHorizRound,\n} from \"@ricons/material\";\nimport classNames from \"classnames\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport Icon from \"../icon\";\nimport \"./index.css\";\nimport Page from \"./page\";\nimport { IPagination } from \"./type\";\n\nconst Pagination = (props: IPagination) => {\n\tconst {\n\t\tpage: defaultPage = 1,\n\t\tsize = 10,\n\t\ttotal = 0,\n\t\tsibling = 2,\n\t\tprev = <Icon icon={<KeyboardArrowLeftRound />} />,\n\t\tnext = <Icon icon={<KeyboardArrowRightRound />} />,\n\t\tsimple,\n\t\tjumper,\n\t\tclassName,\n\t\trenderEllipsis = () => (\n\t\t\t<Icon icon={<MoreHorizRound />} className='color-7' />\n\t\t),\n\t\trenderPage = (i) => i,\n\t\tonChange,\n\t\t...restProps\n\t} = props;\n\n\tconst [page, setPage] = useState(defaultPage);\n\tconst [loading, setLoading] = useState(false);\n\n\tconst totalPage = useMemo(() => Math.ceil(total / size), [size, total]);\n\n\tconst [start, end, loop] = useMemo(() => {\n\t\tconst start = Math.max(1, page - sibling);\n\t\tconst end = Math.min(totalPage, page + sibling);\n\n\t\treturn [\n\t\t\tstart,\n\t\t\tend,\n\t\t\tArray.from({ length: end - start + 1 }).map((n, i) => start + i),\n\t\t];\n\t}, [page, totalPage, sibling]);\n\n\tif (totalPage <= page && page === 1) return <></>;\n\n\tconst handlePageChange = async (p?: number) => {\n\t\tif (!onChange || loading) return;\n\t\tsetLoading(true);\n\n\t\treturn new Promise<void>(async (resolve) => {\n\t\t\tif (p === undefined) return;\n\t\t\tawait onChange(p);\n\t\t\tsetPage(p);\n\t\t\tsetLoading(false);\n\t\t\tresolve();\n\t\t});\n\t};\n\n\tuseEffect(() => setPage(defaultPage), [defaultPage]);\n\n\treturn (\n\t\t<div className={classNames(\"i-pagination\", className)} {...restProps}>\n\t\t\t{prev && (\n\t\t\t\t<Page page={page - 1 || 1} onChange={handlePageChange}>\n\t\t\t\t\t{prev}\n\t\t\t\t</Page>\n\t\t\t)}\n\n\t\t\t{start > 1 && (\n\t\t\t\t<Page page={1} onChange={handlePageChange}>\n\t\t\t\t\t{renderPage(1)}\n\t\t\t\t</Page>\n\t\t\t)}\n\n\t\t\t{start > 2 && renderEllipsis()}\n\n\t\t\t{loop.map((p) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Page\n\t\t\t\t\t\tkey={p}\n\t\t\t\t\t\tpage={p}\n\t\t\t\t\t\tactive={p === page}\n\t\t\t\t\t\tonChange={handlePageChange}\n\t\t\t\t\t>\n\t\t\t\t\t\t{renderPage(p)}\n\t\t\t\t\t</Page>\n\t\t\t\t);\n\t\t\t})}\n\n\t\t\t{end < totalPage - 1 && renderEllipsis()}\n\n\t\t\t{end < totalPage && (\n\t\t\t\t<Page page={totalPage} onChange={handlePageChange}>\n\t\t\t\t\t{renderPage(totalPage)}\n\t\t\t\t</Page>\n\t\t\t)}\n\n\t\t\t{next && (\n\t\t\t\t<Page page={page + 1} onChange={handlePageChange}>\n\t\t\t\t\t{next}\n\t\t\t\t</Page>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n\nexport default Pagination;\n"],"names":["_jsx","Icon","KeyboardArrowLeftRound","KeyboardArrowRightRound","MoreHorizRound","page","useState","useMemo","useEffect","_jsxs","classNames","Page"],"mappings":";;;;;;;;;;;;;;;AAYA,MAAM,UAAU,GAAG,CAAC,KAAkB,KAAI;AACzC,IAAA,MAAM,EACL,IAAI,EAAE,WAAW,GAAG,CAAC,EACrB,IAAI,GAAG,EAAE,EACT,KAAK,GAAG,CAAC,EACT,OAAO,GAAG,CAAC,EACX,IAAI,GAAGA,cAAA,CAACC,YAAI,EAAC,EAAA,IAAI,EAAED,cAAC,CAAAE,+BAAsB,KAAG,EAAI,CAAA,EACjD,IAAI,GAAGF,cAAA,CAACC,YAAI,EAAC,EAAA,IAAI,EAAED,cAAC,CAAAG,gCAAuB,KAAG,EAAI,CAAA,EAClD,MAAM,EACN,MAAM,EACN,SAAS,EACT,cAAc,GAAG,OAChBH,cAAA,CAACC,YAAI,EAAC,EAAA,IAAI,EAAED,cAAC,CAAAI,uBAAc,KAAG,EAAE,SAAS,EAAC,SAAS,GAAG,CACtD,EACD,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,EACrB,QAAQ,EACR,GAAG,SAAS,EACZ,GAAG,KAAK;IAET,MAAM,CAACC,MAAI,EAAE,OAAO,CAAC,GAAGC,cAAQ,CAAC,WAAW,CAAC;IAC7C,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC;IAE7C,MAAM,SAAS,GAAGC,aAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,CAA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KACJV,cAAA,CAACW,YAAI,EAAA,EAAC,IAAI,EAAEN,MAAI,GAAG,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,gBAAgB,EAAA,QAAA,EACnD,IAAI,EAAA,CACC,CACP,EAEA,KAAK,GAAG,CAAC,KACTL,cAAC,CAAAW,YAAI,IAAC,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,gBAAgB,EACvC,QAAA,EAAA,UAAU,CAAC,CAAC,CAAC,EACR,CAAA,CACP,EAEA,KAAK,GAAG,CAAC,IAAI,cAAc,EAAE,EAE7B,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,KAAI;gBACf,QACCX,cAAC,CAAAW,YAAI,EAEJ,EAAA,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,CAAC,KAAKN,MAAI,EAClB,QAAQ,EAAE,gBAAgB,EAAA,QAAA,EAEzB,UAAU,CAAC,CAAC,CAAC,EALT,EAAA,CAAC,CAMA;aAER,CAAC,EAED,GAAG,GAAG,SAAS,GAAG,CAAC,IAAI,cAAc,EAAE,EAEvC,GAAG,GAAG,SAAS,KACfL,cAAA,CAACW,YAAI,EAAA,EAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB,EAAA,QAAA,EAC/C,UAAU,CAAC,SAAS,CAAC,EAAA,CAChB,CACP,EAEA,IAAI,KACJX,cAAA,CAACW,YAAI,EAAA,EAAC,IAAI,EAAEN,MAAI,GAAG,CAAC,EAAE,QAAQ,EAAE,gBAAgB,EAC9C,QAAA,EAAA,IAAI,EACC,CAAA,CACP,CACI,EAAA,CAAA;AAER;;;;"}
|
|
@@ -5,9 +5,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var classNames = require('classnames');
|
|
7
7
|
|
|
8
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
9
|
+
|
|
10
|
+
var classNames__default = /*#__PURE__*/_interopDefaultCompat(classNames);
|
|
11
|
+
|
|
8
12
|
const Handle = (props) => {
|
|
9
13
|
const { ref, color, handle, placeholder, className, ...restProps } = props;
|
|
10
|
-
return (jsxRuntime.jsxs("div", { ref: ref, className:
|
|
14
|
+
return (jsxRuntime.jsxs("div", { ref: ref, className: classNames__default("i-colorpicker-handle", className), ...restProps, children: [handle !== "text" && (jsxRuntime.jsx("i", { className: 'i-colorpicker-square', style: { background: color } })), handle !== "square" && (jsxRuntime.jsx("span", { className: 'i-colorpicker-text', style: { color }, children: color ?? placeholder }))] }));
|
|
11
15
|
};
|
|
12
16
|
|
|
13
17
|
exports.default = Handle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle.js","sources":["../../../../../packages/components/picker/colors/handle.tsx"],"sourcesContent":["import classNames from \"classnames\";\n\nconst Handle = (props) => {\n\tconst { ref, color, handle, placeholder, className, ...restProps } = props;\n\n\treturn (\n\t\t<div\n\t\t\tref={ref}\n\t\t\tclassName={classNames(\"i-colorpicker-handle\", className)}\n\t\t\t{...restProps}\n\t\t>\n\t\t\t{handle !== \"text\" && (\n\t\t\t\t<i\n\t\t\t\t\tclassName='i-colorpicker-square'\n\t\t\t\t\tstyle={{ background: color }}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t{handle !== \"square\" && (\n\t\t\t\t<span className='i-colorpicker-text' style={{ color }}>\n\t\t\t\t\t{color ?? placeholder}\n\t\t\t\t</span>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n\nexport default Handle;\n"],"names":["_jsxs","_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"handle.js","sources":["../../../../../packages/components/picker/colors/handle.tsx"],"sourcesContent":["import classNames from \"classnames\";\n\nconst Handle = (props) => {\n\tconst { ref, color, handle, placeholder, className, ...restProps } = props;\n\n\treturn (\n\t\t<div\n\t\t\tref={ref}\n\t\t\tclassName={classNames(\"i-colorpicker-handle\", className)}\n\t\t\t{...restProps}\n\t\t>\n\t\t\t{handle !== \"text\" && (\n\t\t\t\t<i\n\t\t\t\t\tclassName='i-colorpicker-square'\n\t\t\t\t\tstyle={{ background: color }}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t{handle !== \"square\" && (\n\t\t\t\t<span className='i-colorpicker-text' style={{ color }}>\n\t\t\t\t\t{color ?? placeholder}\n\t\t\t\t</span>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n\nexport default Handle;\n"],"names":["_jsxs","classNames","_jsx"],"mappings":";;;;;;;;;;;AAEA,MAAM,MAAM,GAAG,CAAC,KAAK,KAAI;AACxB,IAAA,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK;AAE1E,IAAA,QACCA,eAAA,CAAA,KAAA,EAAA,EACC,GAAG,EAAE,GAAG,EACR,SAAS,EAAEC,mBAAU,CAAC,sBAAsB,EAAE,SAAS,CAAC,EACpD,GAAA,SAAS,EAEZ,QAAA,EAAA,CAAA,MAAM,KAAK,MAAM,KACjBC,cACC,CAAA,GAAA,EAAA,EAAA,SAAS,EAAC,sBAAsB,EAChC,KAAK,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,EAC3B,CAAA,CACF,EAEA,MAAM,KAAK,QAAQ,KACnBA,cAAM,CAAA,MAAA,EAAA,EAAA,SAAS,EAAC,oBAAoB,EAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EACnD,QAAA,EAAA,KAAK,IAAI,WAAW,EACf,CAAA,CACP,CACI,EAAA,CAAA;AAER;;;;"}
|