@ioca/react 1.3.87 → 1.3.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/button/button.js +2 -0
- package/lib/cjs/components/button/button.js.map +1 -1
- package/lib/cjs/components/button/confirm.js +58 -0
- package/lib/cjs/components/button/confirm.js.map +1 -0
- package/lib/cjs/components/drawer/drawer.js +33 -27
- package/lib/cjs/components/drawer/drawer.js.map +1 -1
- package/lib/cjs/components/dropdown/dropdown.js +6 -2
- package/lib/cjs/components/dropdown/dropdown.js.map +1 -1
- package/lib/cjs/components/input/input.js +1 -1
- package/lib/cjs/components/input/input.js.map +1 -1
- package/lib/cjs/components/input/number.js +1 -1
- package/lib/cjs/components/input/number.js.map +1 -1
- package/lib/cjs/components/input/range.js +8 -9
- package/lib/cjs/components/input/range.js.map +1 -1
- package/lib/cjs/components/input/textarea.js +1 -1
- package/lib/cjs/components/input/textarea.js.map +1 -1
- package/lib/cjs/components/modal/hookModal.js +2 -2
- package/lib/cjs/components/modal/hookModal.js.map +1 -1
- package/lib/cjs/components/modal/modal.js +14 -8
- package/lib/cjs/components/modal/modal.js.map +1 -1
- package/lib/cjs/components/picker/dates/index.js +4 -2
- package/lib/cjs/components/picker/dates/index.js.map +1 -1
- package/lib/cjs/components/picker/time/index.js +7 -2
- package/lib/cjs/components/picker/time/index.js.map +1 -1
- package/lib/cjs/components/progress/progress.js +3 -3
- package/lib/cjs/components/progress/progress.js.map +1 -1
- package/lib/css/index.css +1 -1
- package/lib/css/index.css.map +1 -1
- package/lib/es/components/button/button.js +2 -0
- package/lib/es/components/button/button.js.map +1 -1
- package/lib/es/components/button/confirm.js +54 -0
- package/lib/es/components/button/confirm.js.map +1 -0
- package/lib/es/components/drawer/drawer.js +34 -28
- package/lib/es/components/drawer/drawer.js.map +1 -1
- package/lib/es/components/dropdown/dropdown.js +6 -2
- package/lib/es/components/dropdown/dropdown.js.map +1 -1
- package/lib/es/components/input/input.js +1 -1
- package/lib/es/components/input/input.js.map +1 -1
- package/lib/es/components/input/number.js +1 -1
- package/lib/es/components/input/number.js.map +1 -1
- package/lib/es/components/input/range.js +8 -9
- package/lib/es/components/input/range.js.map +1 -1
- package/lib/es/components/input/textarea.js +1 -1
- package/lib/es/components/input/textarea.js.map +1 -1
- package/lib/es/components/modal/hookModal.js +2 -2
- package/lib/es/components/modal/hookModal.js.map +1 -1
- package/lib/es/components/modal/modal.js +14 -8
- package/lib/es/components/modal/modal.js.map +1 -1
- package/lib/es/components/picker/dates/index.js +3 -2
- package/lib/es/components/picker/dates/index.js.map +1 -1
- package/lib/es/components/picker/time/index.js +3 -2
- package/lib/es/components/picker/time/index.js.map +1 -1
- package/lib/es/components/progress/progress.js +4 -4
- package/lib/es/components/progress/progress.js.map +1 -1
- package/lib/index.js +128 -65
- package/lib/types/components/button/confirm.d.ts +6 -0
- package/lib/types/components/button/type.d.ts +9 -1
- package/lib/types/components/dropdown/type.d.ts +2 -1
- package/lib/types/type/index.d.ts +0 -1
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { AccessTimeRound } from '@ricons/material';
|
|
3
3
|
import { useReactive } from 'ahooks';
|
|
4
|
+
import classNames from 'classnames';
|
|
4
5
|
import { useState, useEffect } from 'react';
|
|
5
6
|
import Icon from '../../icon/icon.js';
|
|
6
7
|
import Input from '../../input/input.js';
|
|
@@ -9,7 +10,7 @@ import Panel from './panel.js';
|
|
|
9
10
|
|
|
10
11
|
const FORMAT = "hh:mm:ss";
|
|
11
12
|
function TimePicker(props) {
|
|
12
|
-
const { name, value, format = FORMAT, periods, placeholder = props.format ?? FORMAT, renderItem, onChange, onBlur, popupProps, ...restProps } = props;
|
|
13
|
+
const { name, value, format = FORMAT, periods, placeholder = props.format ?? FORMAT, className, renderItem, onChange, onBlur, popupProps, ...restProps } = props;
|
|
13
14
|
const state = useReactive({
|
|
14
15
|
value,
|
|
15
16
|
safeValue: undefined,
|
|
@@ -38,7 +39,7 @@ function TimePicker(props) {
|
|
|
38
39
|
useEffect(() => {
|
|
39
40
|
state.value = value;
|
|
40
41
|
}, [value]);
|
|
41
|
-
return (jsx(Popup, { visible: active, trigger: 'click', position: 'bottom', arrow: false, align: 'start', watchResize: true, ...popupProps, onVisibleChange: handleVisibleChange, content: jsx(Panel, { value: state.value, format: format, periods: periods, renderItem: renderItem, onChange: handleChange, onFallback: handleFallback }), children: jsx(Input, { value: state.value, placeholder: placeholder, append: jsx(Icon, { icon: jsx(AccessTimeRound, {}), className: 'i-timepicker-icon', size: '1em' }), onChange: handleChange, onBlur: handleBlur, ...restProps }) }));
|
|
42
|
+
return (jsx(Popup, { visible: active, trigger: 'click', position: 'bottom', arrow: false, align: 'start', watchResize: true, ...popupProps, onVisibleChange: handleVisibleChange, content: jsx(Panel, { value: state.value, format: format, periods: periods, renderItem: renderItem, onChange: handleChange, onFallback: handleFallback }), children: jsx(Input, { value: state.value, placeholder: placeholder, append: jsx(Icon, { icon: jsx(AccessTimeRound, {}), className: 'i-timepicker-icon', size: '1em' }), onChange: handleChange, onBlur: handleBlur, className: classNames("i-timepicker-label", className), ...restProps }) }));
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
export { TimePicker as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../packages/components/picker/time/index.tsx"],"sourcesContent":["import { AccessTimeRound } from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport { useEffect, useState } from \"react\";\nimport Icon from \"../../icon\";\nimport Input from \"../../input\";\nimport Popup from \"../../popup\";\nimport { ITimePicker } from \"../type\";\nimport Panel from \"./panel\";\n\nconst FORMAT = \"hh:mm:ss\";\n\nexport default function TimePicker(props: ITimePicker) {\n\tconst {\n\t\tname,\n\t\tvalue,\n\t\tformat = FORMAT,\n\t\tperiods,\n\t\tplaceholder = props.format ?? FORMAT,\n\t\trenderItem,\n\t\tonChange,\n\t\tonBlur,\n\t\tpopupProps,\n\t\t...restProps\n\t} = props;\n\tconst state = useReactive({\n\t\tvalue,\n\t\tsafeValue: undefined,\n\t});\n\tconst [active, setActive] = useState<boolean>(false);\n\n\tconst handleChange = (v) => {\n\t\tstate.value = v;\n\t};\n\n\tconst handleFallback = (v) => {\n\t\tstate.safeValue = v;\n\t};\n\n\tconst handleValidTime = () => {\n\t\tif (!state.value) return;\n\n\t\tstate.value = state.safeValue;\n\t\thandleChange(state.safeValue);\n\t};\n\n\tconst handleBlur = (e) => {\n\t\tonBlur?.(e);\n\t\thandleValidTime();\n\t};\n\n\tconst handleVisibleChange = (v) => {\n\t\tpopupProps?.onVisibleChange?.(v);\n\t\tsetActive(v);\n\t};\n\n\tuseEffect(() => {\n\t\tstate.value = value;\n\t}, [value]);\n\n\treturn (\n\t\t<Popup\n\t\t\tvisible={active}\n\t\t\ttrigger='click'\n\t\t\tposition='bottom'\n\t\t\tarrow={false}\n\t\t\talign='start'\n\t\t\twatchResize\n\t\t\t{...popupProps}\n\t\t\tonVisibleChange={handleVisibleChange}\n\t\t\tcontent={\n\t\t\t\t<Panel\n\t\t\t\t\tvalue={state.value}\n\t\t\t\t\tformat={format}\n\t\t\t\t\tperiods={periods}\n\t\t\t\t\trenderItem={renderItem}\n\t\t\t\t\tonChange={handleChange}\n\t\t\t\t\tonFallback={handleFallback}\n\t\t\t\t/>\n\t\t\t}\n\t\t>\n\t\t\t<Input\n\t\t\t\tvalue={state.value}\n\t\t\t\tplaceholder={placeholder}\n\t\t\t\tappend={\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={<AccessTimeRound />}\n\t\t\t\t\t\tclassName='i-timepicker-icon'\n\t\t\t\t\t\tsize='1em'\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\tonChange={handleChange}\n\t\t\t\tonBlur={handleBlur}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t</Popup>\n\t);\n}\n"],"names":["_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../packages/components/picker/time/index.tsx"],"sourcesContent":["import { AccessTimeRound } from \"@ricons/material\";\nimport { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { useEffect, useState } from \"react\";\nimport Icon from \"../../icon\";\nimport Input from \"../../input\";\nimport Popup from \"../../popup\";\nimport { ITimePicker } from \"../type\";\nimport Panel from \"./panel\";\n\nconst FORMAT = \"hh:mm:ss\";\n\nexport default function TimePicker(props: ITimePicker) {\n\tconst {\n\t\tname,\n\t\tvalue,\n\t\tformat = FORMAT,\n\t\tperiods,\n\t\tplaceholder = props.format ?? FORMAT,\n\t\tclassName,\n\t\trenderItem,\n\t\tonChange,\n\t\tonBlur,\n\t\tpopupProps,\n\t\t...restProps\n\t} = props;\n\tconst state = useReactive({\n\t\tvalue,\n\t\tsafeValue: undefined,\n\t});\n\tconst [active, setActive] = useState<boolean>(false);\n\n\tconst handleChange = (v) => {\n\t\tstate.value = v;\n\t};\n\n\tconst handleFallback = (v) => {\n\t\tstate.safeValue = v;\n\t};\n\n\tconst handleValidTime = () => {\n\t\tif (!state.value) return;\n\n\t\tstate.value = state.safeValue;\n\t\thandleChange(state.safeValue);\n\t};\n\n\tconst handleBlur = (e) => {\n\t\tonBlur?.(e);\n\t\thandleValidTime();\n\t};\n\n\tconst handleVisibleChange = (v) => {\n\t\tpopupProps?.onVisibleChange?.(v);\n\t\tsetActive(v);\n\t};\n\n\tuseEffect(() => {\n\t\tstate.value = value;\n\t}, [value]);\n\n\treturn (\n\t\t<Popup\n\t\t\tvisible={active}\n\t\t\ttrigger='click'\n\t\t\tposition='bottom'\n\t\t\tarrow={false}\n\t\t\talign='start'\n\t\t\twatchResize\n\t\t\t{...popupProps}\n\t\t\tonVisibleChange={handleVisibleChange}\n\t\t\tcontent={\n\t\t\t\t<Panel\n\t\t\t\t\tvalue={state.value}\n\t\t\t\t\tformat={format}\n\t\t\t\t\tperiods={periods}\n\t\t\t\t\trenderItem={renderItem}\n\t\t\t\t\tonChange={handleChange}\n\t\t\t\t\tonFallback={handleFallback}\n\t\t\t\t/>\n\t\t\t}\n\t\t>\n\t\t\t<Input\n\t\t\t\tvalue={state.value}\n\t\t\t\tplaceholder={placeholder}\n\t\t\t\tappend={\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={<AccessTimeRound />}\n\t\t\t\t\t\tclassName='i-timepicker-icon'\n\t\t\t\t\t\tsize='1em'\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\tonChange={handleChange}\n\t\t\t\tonBlur={handleBlur}\n\t\t\t\tclassName={classNames(\"i-timepicker-label\", className)}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t</Popup>\n\t);\n}\n"],"names":["_jsx"],"mappings":";;;;;;;;;;AAUA,MAAM,MAAM,GAAG,UAAU;AAED,SAAA,UAAU,CAAC,KAAkB,EAAA;AACpD,IAAA,MAAM,EACL,IAAI,EACJ,KAAK,EACL,MAAM,GAAG,MAAM,EACf,OAAO,EACP,WAAW,GAAG,KAAK,CAAC,MAAM,IAAI,MAAM,EACpC,SAAS,EACT,UAAU,EACV,QAAQ,EACR,MAAM,EACN,UAAU,EACV,GAAG,SAAS,EACZ,GAAG,KAAK;IACT,MAAM,KAAK,GAAG,WAAW,CAAC;QACzB,KAAK;AACL,QAAA,SAAS,EAAE,SAAS;AACpB,KAAA,CAAC;IACF,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC;AAEpD,IAAA,MAAM,YAAY,GAAG,CAAC,CAAC,KAAI;AAC1B,QAAA,KAAK,CAAC,KAAK,GAAG,CAAC;AAChB,KAAC;AAED,IAAA,MAAM,cAAc,GAAG,CAAC,CAAC,KAAI;AAC5B,QAAA,KAAK,CAAC,SAAS,GAAG,CAAC;AACpB,KAAC;IAED,MAAM,eAAe,GAAG,MAAK;QAC5B,IAAI,CAAC,KAAK,CAAC,KAAK;YAAE;AAElB,QAAA,KAAK,CAAC,KAAK,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E,SAAS,CAAC,EAAA,GAClD,SAAS,EAAA,CACZ,EACK,CAAA;AAEV;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useReactive } from 'ahooks';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import { useRef,
|
|
4
|
+
import { useRef, useEffect } from 'react';
|
|
5
5
|
import { useMouseMove, useMouseUp } from '../../js/hooks.js';
|
|
6
6
|
import Circle from './circle.js';
|
|
7
7
|
import Line from './line.js';
|
|
@@ -18,12 +18,12 @@ const Progress = (props) => {
|
|
|
18
18
|
const pageXY = vertical ? "pageY" : "pageX";
|
|
19
19
|
const rectTL = vertical ? "top" : "left";
|
|
20
20
|
const rectWH = vertical ? "height" : "width";
|
|
21
|
-
const
|
|
21
|
+
const getFixedValue = () => {
|
|
22
22
|
let value = +state.value.toFixed(precision);
|
|
23
23
|
value = Math.min(100, value);
|
|
24
24
|
value = Math.max(0, value);
|
|
25
25
|
return value;
|
|
26
|
-
}
|
|
26
|
+
};
|
|
27
27
|
const handleMouseDown = (e) => {
|
|
28
28
|
if (!ref.current || !draggable)
|
|
29
29
|
return;
|
|
@@ -57,7 +57,7 @@ const Progress = (props) => {
|
|
|
57
57
|
const handleMouseUp = () => {
|
|
58
58
|
if (!state.dragging || !draggable)
|
|
59
59
|
return;
|
|
60
|
-
onChange?.(
|
|
60
|
+
onChange?.(getFixedValue());
|
|
61
61
|
state.dragging = false;
|
|
62
62
|
onDraggingChange?.(false);
|
|
63
63
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress.js","sources":["../../../../packages/components/progress/progress.tsx"],"sourcesContent":["import { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { useEffect,
|
|
1
|
+
{"version":3,"file":"progress.js","sources":["../../../../packages/components/progress/progress.tsx"],"sourcesContent":["import { useReactive } from \"ahooks\";\nimport classNames from \"classnames\";\nimport { useEffect, useRef } from \"react\";\nimport \"../../css/input.css\";\nimport { useMouseMove, useMouseUp } from \"../../js/hooks\";\nimport Circle from \"./circle\";\nimport \"./index.css\";\nimport Line from \"./line\";\nimport { IProgress } from \"./type\";\n\nconst Progress = (props: IProgress) => {\n\tconst {\n\t\tvalue = 0,\n\t\tlineWidth = 8,\n\t\tcircleSize = 40,\n\t\tprecision = 0,\n\t\tstyle,\n\t\tdraggable = true,\n\t\ttype = \"line\",\n\t\tbarClass,\n\t\tvertical,\n\t\tlabel,\n\t\tlabelInline,\n\t\tclassName,\n\t\trenderCursor,\n\t\tonChange,\n\t\tonDraggingChange,\n\t} = props;\n\n\tconst ref = useRef<HTMLDivElement>(null);\n\tconst state = useReactive({\n\t\tvalue,\n\t\tdragging: false,\n\t\tsize: 0,\n\t\tstart: 0,\n\t});\n\n\tconst pageXY = vertical ? \"pageY\" : \"pageX\";\n\tconst rectTL = vertical ? \"top\" : \"left\";\n\tconst rectWH = vertical ? \"height\" : \"width\";\n\n\tconst getFixedValue = () => {\n\t\tlet value = +state.value.toFixed(precision);\n\t\tvalue = Math.min(100, value);\n\t\tvalue = Math.max(0, value);\n\n\t\treturn value;\n\t};\n\n\tconst handleMouseDown = (e) => {\n\t\tif (!ref.current || !draggable) return;\n\n\t\tif (e.touches) {\n\t\t\te = e.touches[0];\n\t\t}\n\n\t\tconst rect = ref.current.getBoundingClientRect();\n\t\tconst value = ((e[pageXY] - rect[rectTL]) * 100) / rect[rectWH];\n\n\t\tObject.assign(state, {\n\t\t\tvalue: vertical ? 100 - value : value,\n\t\t\tsize: rect[rectWH],\n\t\t\tstart: rect[rectTL],\n\t\t\tdragging: true,\n\t\t});\n\t\tonDraggingChange?.(true);\n\t};\n\n\tconst handleMouseMove = (e) => {\n\t\tif (!state.dragging || !draggable) return;\n\t\te.preventDefault();\n\n\t\tif (e.touches) {\n\t\t\te = e.touches[0];\n\t\t}\n\n\t\tconst { start, size } = state;\n\t\tconst offset = e[pageXY] - start;\n\n\t\tif (offset < 0 || offset > size) return;\n\n\t\tconst value = ((e[pageXY] - start) * 100) / size;\n\t\tstate.value = vertical ? 100 - value : value;\n\t};\n\n\tconst handleMouseUp = () => {\n\t\tif (!state.dragging || !draggable) return;\n\n\t\tonChange?.(getFixedValue());\n\t\tstate.dragging = false;\n\t\tonDraggingChange?.(false);\n\t};\n\n\tuseMouseMove(handleMouseMove);\n\tuseMouseUp(handleMouseUp);\n\n\tuseEffect(() => {\n\t\tif (value > 100) {\n\t\t\tstate.value = 100;\n\t\t\treturn;\n\t\t}\n\n\t\tif (value < 0) {\n\t\t\tstate.value = 0;\n\t\t\treturn;\n\t\t}\n\n\t\tstate.value = value;\n\t}, [value]);\n\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames(\"i-input-label\", className, {\n\t\t\t\t\"i-input-inline\": labelInline,\n\t\t\t})}\n\t\t\tstyle={style}\n\t\t>\n\t\t\t{label && <span className='i-input-label-text'>{label}</span>}\n\n\t\t\t{type === \"line\" && (\n\t\t\t\t<Line\n\t\t\t\t\tref={ref}\n\t\t\t\t\tvertical={vertical}\n\t\t\t\t\tlineWidth={lineWidth}\n\t\t\t\t\tbarClass={barClass}\n\t\t\t\t\tdragging={state.dragging}\n\t\t\t\t\tvalue={state.value}\n\t\t\t\t\trenderCursor={renderCursor}\n\t\t\t\t\tonMouseDown={handleMouseDown}\n\t\t\t\t\tonTouchStart={handleMouseDown}\n\t\t\t\t/>\n\t\t\t)}\n\n\t\t\t{type === \"circle\" && (\n\t\t\t\t<Circle\n\t\t\t\t\tvalue={state.value}\n\t\t\t\t\tcircleSize={circleSize}\n\t\t\t\t\tlineWidth={lineWidth}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n\nexport default Progress;\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;AAUA,MAAM,QAAQ,GAAG,CAAC,KAAgB,KAAI;IACrC,MAAM,EACL,KAAK,GAAG,CAAC,EACT,SAAS,GAAG,CAAC,EACb,UAAU,GAAG,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, throttle, pick, title } from 'radash';
|
|
4
|
-
import { useMemo, Children, cloneElement, useEffect, createElement, isValidElement, useState, useRef, Fragment as Fragment$1, useLayoutEffect, useImperativeHandle, createContext, useContext } from 'react';
|
|
4
|
+
import { useMemo, Children, cloneElement, useEffect, createElement, isValidElement, useState, useRef, Fragment as Fragment$1, useTransition, useLayoutEffect, useImperativeHandle, createContext, useContext } from 'react';
|
|
5
5
|
import { SkipPreviousRound, CloseRound, MinusRound, PlusRound, InboxTwotone, FormatBoldRound, FormatItalicRound, FormatUnderlinedRound, StrikethroughSRound, RedoRound, UndoRound, ClearAllRound, PauseRound, PlayArrowRound, StopRound, VolumeOffRound, VolumeDownRound, FullscreenExitRound, FullscreenRound, FeedOutlined, AspectRatioRound, OpenInNewRound, FileDownloadOutlined, RotateRightRound, RotateLeftRound, KeyboardArrowLeftRound, KeyboardArrowRightRound, HideImageTwotone, SyncAltRound, VisibilityRound, VisibilityOffRound, MoreHorizRound, SearchRound, CheckRound, UnfoldMoreRound, CalendarMonthTwotone, AccessTimeRound, InfoOutlined, KeyboardArrowDownRound, ListAltRound, DriveFolderUploadOutlined, PlusSharp } from '@ricons/material';
|
|
6
6
|
import { useReactive, useCreation, useSize } from 'ahooks';
|
|
7
7
|
import { createRoot } from 'react-dom/client';
|
|
@@ -71,6 +71,54 @@ const Loading = (props) => {
|
|
|
71
71
|
}, children: jsx("circle", { cx: '12', cy: '12', r: '9.5', fill: 'none', strokeWidth: '3', strokeLinecap: 'round', strokeDasharray: 40, strokeDashoffset: 0 }) })), text] }));
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
+
const defaultOk$1 = {
|
|
75
|
+
children: "确定",
|
|
76
|
+
className: "bg-error",
|
|
77
|
+
};
|
|
78
|
+
const defaultCancel$1 = {
|
|
79
|
+
children: "取消",
|
|
80
|
+
secondary: true,
|
|
81
|
+
};
|
|
82
|
+
function Confirm(props) {
|
|
83
|
+
const { ref, okButtonProps, cancelButtonProps, onOk, onCancel, onClick, ...restProps } = props;
|
|
84
|
+
const state = useReactive({
|
|
85
|
+
active: false,
|
|
86
|
+
loading: false,
|
|
87
|
+
});
|
|
88
|
+
const ok = okButtonProps
|
|
89
|
+
? Object.assign({}, defaultOk$1, okButtonProps)
|
|
90
|
+
: defaultOk$1;
|
|
91
|
+
const cancel = cancelButtonProps
|
|
92
|
+
? Object.assign({}, defaultCancel$1, cancelButtonProps)
|
|
93
|
+
: defaultCancel$1;
|
|
94
|
+
const handleClick = (e) => {
|
|
95
|
+
onClick?.(e);
|
|
96
|
+
state.active = true;
|
|
97
|
+
};
|
|
98
|
+
const hanldeOk = async () => {
|
|
99
|
+
if (state.loading)
|
|
100
|
+
return;
|
|
101
|
+
state.loading = true;
|
|
102
|
+
try {
|
|
103
|
+
const res = await onOk?.();
|
|
104
|
+
if (res !== false) {
|
|
105
|
+
state.active = false;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
finally {
|
|
109
|
+
state.loading = false;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const handleCancel = () => {
|
|
113
|
+
onCancel?.();
|
|
114
|
+
state.active = false;
|
|
115
|
+
};
|
|
116
|
+
if (!state.active) {
|
|
117
|
+
return jsx(Button, { ref: ref, ...restProps, onClick: handleClick });
|
|
118
|
+
}
|
|
119
|
+
return (jsxs(Button.Group, { children: [jsx(Button, { ...ok, loading: state.loading, onClick: hanldeOk }), jsx(Button, { ...cancel, disabled: state.loading, onClick: handleCancel })] }));
|
|
120
|
+
}
|
|
121
|
+
|
|
74
122
|
function Group(props) {
|
|
75
123
|
const { children, vertical, buttonProps, className, style } = props;
|
|
76
124
|
const nodes = useMemo(() => {
|
|
@@ -173,6 +221,7 @@ const Button = (props) => {
|
|
|
173
221
|
}, childNodes);
|
|
174
222
|
};
|
|
175
223
|
Button.Toggle = Toggle;
|
|
224
|
+
Button.Confirm = Confirm;
|
|
176
225
|
Button.Group = Group;
|
|
177
226
|
|
|
178
227
|
const Icon = (props) => {
|
|
@@ -1048,38 +1097,42 @@ function Drawer(props) {
|
|
|
1048
1097
|
const state = useReactive({
|
|
1049
1098
|
show: visible,
|
|
1050
1099
|
active: visible,
|
|
1051
|
-
init: false,
|
|
1052
1100
|
});
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
const handleShow = () => {
|
|
1057
|
-
if (!toggable.current)
|
|
1101
|
+
const [isPending, startTransition] = useTransition();
|
|
1102
|
+
const handleHide = () => {
|
|
1103
|
+
if (!toggable.current || isPending)
|
|
1058
1104
|
return;
|
|
1059
|
-
state.show = true;
|
|
1060
|
-
onVisibleChange?.(true);
|
|
1061
1105
|
toggable.current = false;
|
|
1062
|
-
|
|
1063
|
-
state.active =
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1106
|
+
startTransition(() => {
|
|
1107
|
+
state.active = false;
|
|
1108
|
+
setTimeout(() => {
|
|
1109
|
+
if (!keepDOM) {
|
|
1110
|
+
state.show = false;
|
|
1111
|
+
}
|
|
1112
|
+
onVisibleChange?.(false);
|
|
1113
|
+
toggable.current = true;
|
|
1114
|
+
onClose?.();
|
|
1115
|
+
}, 240);
|
|
1116
|
+
});
|
|
1067
1117
|
};
|
|
1068
|
-
const
|
|
1069
|
-
if (!toggable.current)
|
|
1118
|
+
const handleShow = () => {
|
|
1119
|
+
if (!toggable.current || isPending)
|
|
1070
1120
|
return;
|
|
1121
|
+
state.show = true;
|
|
1122
|
+
onVisibleChange?.(true);
|
|
1071
1123
|
toggable.current = false;
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
state.
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
onClose?.();
|
|
1080
|
-
}, 240);
|
|
1124
|
+
startTransition(() => {
|
|
1125
|
+
// 确保 DOM 已经挂载
|
|
1126
|
+
requestAnimationFrame(() => {
|
|
1127
|
+
state.active = true;
|
|
1128
|
+
toggable.current = true;
|
|
1129
|
+
});
|
|
1130
|
+
});
|
|
1081
1131
|
};
|
|
1082
|
-
|
|
1132
|
+
useEffect(() => {
|
|
1133
|
+
visible ? handleShow() : handleHide();
|
|
1134
|
+
}, [visible]);
|
|
1135
|
+
const handleBackdropClick = () => {
|
|
1083
1136
|
backdropClosable && handleHide();
|
|
1084
1137
|
};
|
|
1085
1138
|
useKeydown((e) => {
|
|
@@ -1089,9 +1142,11 @@ function Drawer(props) {
|
|
|
1089
1142
|
}, {
|
|
1090
1143
|
disabled: disabledEsc,
|
|
1091
1144
|
});
|
|
1092
|
-
|
|
1145
|
+
if (!state.show)
|
|
1146
|
+
return null;
|
|
1147
|
+
return createPortal(jsx("div", { className: classNames("i-backdrop-drawer", className, {
|
|
1093
1148
|
"i-active": state.active,
|
|
1094
|
-
}), onClick: handleBackdropClick, ...restProps, children: jsxs("div", { className: classNames("i-drawer", `i-drawer-${position}`), onClick: (e) => e.stopPropagation(), children: [jsxs("header", { className: 'i-drawer-header', children: [header, jsx(Helpericon, {
|
|
1149
|
+
}), onClick: handleBackdropClick, ...restProps, children: jsxs("div", { className: classNames("i-drawer", `i-drawer-${position}`), onClick: (e) => e.stopPropagation(), children: [header && (jsxs("header", { className: 'i-drawer-header', children: [header, !hideCloseButton && (jsx(Helpericon, { className: 'i-drawer-close', onClick: handleHide }))] })), jsx("div", { className: 'i-drawer-content', children: children }), footer && jsx("div", { className: 'i-drawer-footer', children: footer })] }) }), document.body);
|
|
1095
1150
|
}
|
|
1096
1151
|
|
|
1097
1152
|
const Item$4 = (props) => {
|
|
@@ -1382,8 +1437,11 @@ const Item$3 = (props) => {
|
|
|
1382
1437
|
};
|
|
1383
1438
|
|
|
1384
1439
|
const Dropdown = (props) => {
|
|
1385
|
-
const { width, content, children, ...restProps } = props;
|
|
1386
|
-
|
|
1440
|
+
const { visible, width, content, children, ...restProps } = props;
|
|
1441
|
+
const [active, setActive] = useState(visible);
|
|
1442
|
+
return (jsx(Popup, { trigger: 'click', position: 'bottom', content: jsx(List$1, { className: 'i-dropdown-content', style: { minWidth: width }, children: typeof content === "function"
|
|
1443
|
+
? content(() => setActive(false))
|
|
1444
|
+
: content }), ...restProps, touchable: true, visible: active, onVisibleChange: setActive, children: children }));
|
|
1387
1445
|
};
|
|
1388
1446
|
Dropdown.Item = Item$3;
|
|
1389
1447
|
|
|
@@ -1880,17 +1938,19 @@ function Modal(props) {
|
|
|
1880
1938
|
const [show, setShow] = useState(visible);
|
|
1881
1939
|
const [active, setActive] = useState(false);
|
|
1882
1940
|
const [bounced, setBounced] = useState(false);
|
|
1941
|
+
const [mounted, setMounted] = useState(false);
|
|
1883
1942
|
const toggable = useRef(true);
|
|
1884
1943
|
const handleShow = async () => {
|
|
1885
1944
|
if (!toggable.current)
|
|
1886
1945
|
return;
|
|
1887
1946
|
(!keepDOM || !show) && setShow(true);
|
|
1888
1947
|
toggable.current = false;
|
|
1889
|
-
setTimeout(() => {
|
|
1948
|
+
const timer = setTimeout(() => {
|
|
1890
1949
|
setActive(true);
|
|
1891
1950
|
onVisibleChange?.(true);
|
|
1892
1951
|
toggable.current = true;
|
|
1893
1952
|
}, 24);
|
|
1953
|
+
return () => clearTimeout(timer);
|
|
1894
1954
|
};
|
|
1895
1955
|
const handleHide = () => {
|
|
1896
1956
|
if (!toggable.current)
|
|
@@ -1898,21 +1958,22 @@ function Modal(props) {
|
|
|
1898
1958
|
toggable.current = false;
|
|
1899
1959
|
if (!closable) {
|
|
1900
1960
|
setBounced(true);
|
|
1901
|
-
setTimeout(() => {
|
|
1961
|
+
const timer = setTimeout(() => {
|
|
1902
1962
|
setBounced(false);
|
|
1903
1963
|
toggable.current = true;
|
|
1904
1964
|
}, 400);
|
|
1905
|
-
return;
|
|
1965
|
+
return () => clearTimeout(timer);
|
|
1906
1966
|
}
|
|
1907
1967
|
setActive(false);
|
|
1908
|
-
setTimeout(() => {
|
|
1968
|
+
const timer = setTimeout(() => {
|
|
1909
1969
|
!keepDOM && setShow(false);
|
|
1910
1970
|
toggable.current = true;
|
|
1911
1971
|
onVisibleChange?.(false);
|
|
1912
1972
|
onClose?.();
|
|
1913
1973
|
}, 240);
|
|
1974
|
+
return () => clearTimeout(timer);
|
|
1914
1975
|
};
|
|
1915
|
-
const handleBackdropClick =
|
|
1976
|
+
const handleBackdropClick = () => {
|
|
1916
1977
|
backdropClosable && handleHide();
|
|
1917
1978
|
};
|
|
1918
1979
|
useKeydown((e) => {
|
|
@@ -1923,19 +1984,22 @@ function Modal(props) {
|
|
|
1923
1984
|
useEffect(() => {
|
|
1924
1985
|
visible ? handleShow() : handleHide();
|
|
1925
1986
|
}, [visible]);
|
|
1987
|
+
useEffect(() => {
|
|
1988
|
+
setMounted(true);
|
|
1989
|
+
}, []);
|
|
1926
1990
|
const handleClick = () => {
|
|
1927
1991
|
if (typeof document === "undefined")
|
|
1928
1992
|
return;
|
|
1929
1993
|
document.documentElement.click();
|
|
1930
1994
|
};
|
|
1931
|
-
if (!show)
|
|
1995
|
+
if (!show || !mounted)
|
|
1932
1996
|
return null;
|
|
1933
1997
|
return createPortal(jsx("div", { className: classNames("i-modal-container", {
|
|
1934
1998
|
"i-modal-backdrop": !hideBackdrop,
|
|
1935
1999
|
"i-modal-customized": customized,
|
|
1936
2000
|
"i-modal-active": active,
|
|
1937
2001
|
fixed,
|
|
1938
|
-
}, className), style: style, onClick: handleBackdropClick, children: jsxs("div", { className: classNames("i-modal", {
|
|
2002
|
+
}, className), style: style, onClick: handleBackdropClick, "aria-modal": 'true', "aria-hidden": !active, children: jsxs("div", { className: classNames("i-modal", {
|
|
1939
2003
|
bounced,
|
|
1940
2004
|
shadow: !hideShadow,
|
|
1941
2005
|
}), style: {
|
|
@@ -1945,14 +2009,14 @@ function Modal(props) {
|
|
|
1945
2009
|
e.stopPropagation();
|
|
1946
2010
|
handleClick();
|
|
1947
2011
|
onClick?.(e);
|
|
1948
|
-
}, ...restProps, children: [customized && children, !customized && (jsx(Content$1, { title: title, hideCloseButton: hideCloseButton, footer: footer, okButtonProps: okButtonProps, cancelButtonProps: cancelButtonProps, children: children, footerLeft: footerLeft, onOk: onOk, onClose: handleHide }))] }) }), document?.body ?? null);
|
|
2012
|
+
}, role: 'dialog', "aria-labelledby": title ? "modal-title" : undefined, ...restProps, children: [customized && children, !customized && (jsx(Content$1, { title: title, hideCloseButton: hideCloseButton, footer: footer, okButtonProps: okButtonProps, cancelButtonProps: cancelButtonProps, children: children, footerLeft: footerLeft, onOk: onOk, onClose: handleHide }))] }) }), document?.body ?? null);
|
|
1949
2013
|
}
|
|
1950
2014
|
Modal.useModal = useModal;
|
|
1951
2015
|
|
|
1952
2016
|
const HookModal = (props) => {
|
|
1953
|
-
const { ref } = props;
|
|
2017
|
+
const { ref, ...restProps } = props;
|
|
1954
2018
|
const state = useReactive({});
|
|
1955
|
-
const mergedProps = Object.assign({},
|
|
2019
|
+
const mergedProps = Object.assign({}, restProps, state);
|
|
1956
2020
|
useImperativeHandle(ref, () => ({
|
|
1957
2021
|
update: (config = {}) => {
|
|
1958
2022
|
Object.assign(state, config);
|
|
@@ -1990,7 +2054,7 @@ function HighLight(props) {
|
|
|
1990
2054
|
return jsx(Text, { ...restProps, children: content });
|
|
1991
2055
|
}
|
|
1992
2056
|
|
|
1993
|
-
function Number$
|
|
2057
|
+
function Number$3(props) {
|
|
1994
2058
|
const { count, to, decimal, thousand = ",", duration = 2400, easing, ...restProps } = props;
|
|
1995
2059
|
const [n, setN] = useState(count);
|
|
1996
2060
|
const number = useMemo(() => {
|
|
@@ -2010,7 +2074,7 @@ function Number$2(props) {
|
|
|
2010
2074
|
return jsx(Text, { ...restProps, children: number });
|
|
2011
2075
|
}
|
|
2012
2076
|
|
|
2013
|
-
function Number$
|
|
2077
|
+
function Number$2(props) {
|
|
2014
2078
|
const { seconds, zero, units, ...restProps } = props;
|
|
2015
2079
|
const text = useMemo(() => {
|
|
2016
2080
|
if (seconds === undefined)
|
|
@@ -2044,8 +2108,8 @@ const Text = (props) => {
|
|
|
2044
2108
|
"i-text-gradient-wave": wave,
|
|
2045
2109
|
}), children: children }));
|
|
2046
2110
|
};
|
|
2047
|
-
Text.Number = Number$
|
|
2048
|
-
Text.Time = Number$
|
|
2111
|
+
Text.Number = Number$3;
|
|
2112
|
+
Text.Time = Number$2;
|
|
2049
2113
|
Text.HighLight = HighLight;
|
|
2050
2114
|
|
|
2051
2115
|
function Circle(props) {
|
|
@@ -2076,12 +2140,12 @@ const Progress = (props) => {
|
|
|
2076
2140
|
const pageXY = vertical ? "pageY" : "pageX";
|
|
2077
2141
|
const rectTL = vertical ? "top" : "left";
|
|
2078
2142
|
const rectWH = vertical ? "height" : "width";
|
|
2079
|
-
const
|
|
2143
|
+
const getFixedValue = () => {
|
|
2080
2144
|
let value = +state.value.toFixed(precision);
|
|
2081
2145
|
value = Math.min(100, value);
|
|
2082
2146
|
value = Math.max(0, value);
|
|
2083
2147
|
return value;
|
|
2084
|
-
}
|
|
2148
|
+
};
|
|
2085
2149
|
const handleMouseDown = (e) => {
|
|
2086
2150
|
if (!ref.current || !draggable)
|
|
2087
2151
|
return;
|
|
@@ -2115,7 +2179,7 @@ const Progress = (props) => {
|
|
|
2115
2179
|
const handleMouseUp = () => {
|
|
2116
2180
|
if (!state.dragging || !draggable)
|
|
2117
2181
|
return;
|
|
2118
|
-
onChange?.(
|
|
2182
|
+
onChange?.(getFixedValue());
|
|
2119
2183
|
state.dragging = false;
|
|
2120
2184
|
onDraggingChange?.(false);
|
|
2121
2185
|
};
|
|
@@ -2568,8 +2632,8 @@ function InputContainer(props) {
|
|
|
2568
2632
|
}), children: tip }))] }));
|
|
2569
2633
|
}
|
|
2570
2634
|
|
|
2571
|
-
const Number = (props) => {
|
|
2572
|
-
const { ref, label, name, value =
|
|
2635
|
+
const Number$1 = (props) => {
|
|
2636
|
+
const { ref, label, name, value = "", labelInline, step = 1, min = -Infinity, max = Infinity, thousand, precision, type, className, width, status = "normal", append, border, prepend, disabled, message, tip, hideControl, style, onChange, onEnter, onInput, onBlur, ...restProps } = props;
|
|
2573
2637
|
const state = useReactive({
|
|
2574
2638
|
value,
|
|
2575
2639
|
});
|
|
@@ -2613,7 +2677,7 @@ const Number = (props) => {
|
|
|
2613
2677
|
};
|
|
2614
2678
|
|
|
2615
2679
|
const Range = (props) => {
|
|
2616
|
-
const { label, name, value
|
|
2680
|
+
const { label, name, value, labelInline, min = -Infinity, max = Infinity, type, className, status = "normal", message, tip, append, prepend, step = 1, width, thousand, precision, hideControl, placeholder, border, autoSwitch, onChange, onBlur, style, ...restProps } = props;
|
|
2617
2681
|
const state = useReactive({
|
|
2618
2682
|
value,
|
|
2619
2683
|
});
|
|
@@ -2648,9 +2712,7 @@ const Range = (props) => {
|
|
|
2648
2712
|
e?.preventDefault();
|
|
2649
2713
|
e?.stopPropagation();
|
|
2650
2714
|
const range = state.value ? state.value : [];
|
|
2651
|
-
|
|
2652
|
-
range[0] = range[1];
|
|
2653
|
-
range[1] = v;
|
|
2715
|
+
[range[0], range[1]] = [range[1], range[0]];
|
|
2654
2716
|
state.value = range;
|
|
2655
2717
|
onChange?.(range);
|
|
2656
2718
|
};
|
|
@@ -2663,14 +2725,15 @@ const Range = (props) => {
|
|
|
2663
2725
|
...restProps,
|
|
2664
2726
|
};
|
|
2665
2727
|
const handleBlur = () => {
|
|
2728
|
+
if (!autoSwitch)
|
|
2729
|
+
return;
|
|
2666
2730
|
const range = Array.isArray(state.value) ? state.value : [];
|
|
2667
2731
|
if (range.length < 2)
|
|
2668
2732
|
return;
|
|
2669
|
-
const
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
handleSwitch();
|
|
2733
|
+
const [left, right] = range.map(Number);
|
|
2734
|
+
if (left > right) {
|
|
2735
|
+
handleSwitch();
|
|
2736
|
+
}
|
|
2674
2737
|
};
|
|
2675
2738
|
return (jsx(InputContainer, { label: label, labelInline: labelInline, className: className, style: { width, ...style }, tip: message ?? tip, status: status, children: jsxs("div", { className: classNames("i-input-item", {
|
|
2676
2739
|
[`i-input-${status}`]: status !== "normal",
|
|
@@ -2679,7 +2742,7 @@ const Range = (props) => {
|
|
|
2679
2742
|
};
|
|
2680
2743
|
|
|
2681
2744
|
const Textarea = (props) => {
|
|
2682
|
-
const { ref, label, name, value =
|
|
2745
|
+
const { ref, label, name, value = "", labelInline, className, status = "normal", message, tip, autoSize, border, width, style, onChange, onEnter, ...restProps } = props;
|
|
2683
2746
|
const state = useReactive({
|
|
2684
2747
|
value,
|
|
2685
2748
|
});
|
|
@@ -2718,7 +2781,7 @@ const Textarea = (props) => {
|
|
|
2718
2781
|
};
|
|
2719
2782
|
|
|
2720
2783
|
const Input = ((props) => {
|
|
2721
|
-
const { ref, type = "text", label, name, value =
|
|
2784
|
+
const { ref, type = "text", label, name, value = "", prepend, append, labelInline, className, status = "normal", message, tip, clear, width, hideVisible, border, underline, required, maxLength, onChange, onEnter, style, ...restProps } = props;
|
|
2722
2785
|
const state = useReactive({
|
|
2723
2786
|
value,
|
|
2724
2787
|
type,
|
|
@@ -2772,7 +2835,7 @@ const Input = ((props) => {
|
|
|
2772
2835
|
}), children: [prepend && jsx("div", { className: 'i-input-prepend', children: prepend }), jsx("input", { ...inputProps }), maxLength && state.value?.length > 0 && (jsxs("span", { className: 'color-8 pr-4 font-sm', children: [state.value.length, " / ", maxLength] })), jsx(Helpericon, { active: !!clearable || showHelper, icon: HelperIcon, onClick: handleHelperClick }), append && jsx("div", { className: 'i-input-append', children: append })] }) }));
|
|
2773
2836
|
});
|
|
2774
2837
|
Input.Textarea = Textarea;
|
|
2775
|
-
Input.Number = Number;
|
|
2838
|
+
Input.Number = Number$1;
|
|
2776
2839
|
Input.Range = Range;
|
|
2777
2840
|
|
|
2778
2841
|
const AlignMap = {
|
|
@@ -3316,7 +3379,7 @@ dayjs.extend(customParseFormat);
|
|
|
3316
3379
|
const FORMATTYPES = ["YYYY-MM-DD", "YYYY-M-D", "YYYY/MM/DD", "YYYY/M/D"];
|
|
3317
3380
|
const FORMAT$1 = "YYYY-MM-DD";
|
|
3318
3381
|
const Datepicker = (props) => {
|
|
3319
|
-
const { name, value, weeks, format = FORMAT$1, placeholder = props.format ?? FORMAT$1, renderDate, renderMonth, renderYear, popupProps, disabledDate, onDateClick, onChange, onBlur, ...restProps } = props;
|
|
3382
|
+
const { name, value, weeks, format = FORMAT$1, placeholder = props.format ?? FORMAT$1, className, renderDate, renderMonth, renderYear, popupProps, disabledDate, onDateClick, onChange, onBlur, ...restProps } = props;
|
|
3320
3383
|
const state = useReactive({
|
|
3321
3384
|
value,
|
|
3322
3385
|
});
|
|
@@ -3357,7 +3420,7 @@ const Datepicker = (props) => {
|
|
|
3357
3420
|
useEffect(() => {
|
|
3358
3421
|
state.value = value;
|
|
3359
3422
|
}, [value]);
|
|
3360
|
-
return (jsx(Popup, { visible: active, trigger: 'click', position: 'bottom', arrow: false, align: 'start', onVisibleChange: handleVisibleChange, watchResize: true, content: jsx(Panel$1, { value: dayJsValue, weeks: weeks, renderDate: renderDate, renderMonth: renderMonth, renderYear: renderYear, disabledDate: disabledDate, onDateClick: handleDateClick }), ...popupProps, children: jsx(Input, { value: state.value, append: jsx(Icon, { icon: jsx(CalendarMonthTwotone, {}), className: 'i-datepicker-icon', size: '1em' }), placeholder: placeholder, onChange: handleChange, onBlur: handleBlur, onEnter: handleSetDate, ...restProps }) }));
|
|
3423
|
+
return (jsx(Popup, { visible: active, trigger: 'click', position: 'bottom', arrow: false, align: 'start', onVisibleChange: handleVisibleChange, watchResize: true, content: jsx(Panel$1, { value: dayJsValue, weeks: weeks, renderDate: renderDate, renderMonth: renderMonth, renderYear: renderYear, disabledDate: disabledDate, onDateClick: handleDateClick }), ...popupProps, children: jsx(Input, { value: state.value, append: jsx(Icon, { icon: jsx(CalendarMonthTwotone, {}), className: 'i-datepicker-icon', size: '1em' }), placeholder: placeholder, onChange: handleChange, onBlur: handleBlur, onEnter: handleSetDate, className: classNames("i-datepicker-label", className), ...restProps }) }));
|
|
3361
3424
|
};
|
|
3362
3425
|
|
|
3363
3426
|
function Items(props) {
|
|
@@ -3448,7 +3511,7 @@ function Panel(props) {
|
|
|
3448
3511
|
|
|
3449
3512
|
const FORMAT = "hh:mm:ss";
|
|
3450
3513
|
function TimePicker(props) {
|
|
3451
|
-
const { name, value, format = FORMAT, periods, placeholder = props.format ?? FORMAT, renderItem, onChange, onBlur, popupProps, ...restProps } = props;
|
|
3514
|
+
const { name, value, format = FORMAT, periods, placeholder = props.format ?? FORMAT, className, renderItem, onChange, onBlur, popupProps, ...restProps } = props;
|
|
3452
3515
|
const state = useReactive({
|
|
3453
3516
|
value,
|
|
3454
3517
|
safeValue: undefined,
|
|
@@ -3477,7 +3540,7 @@ function TimePicker(props) {
|
|
|
3477
3540
|
useEffect(() => {
|
|
3478
3541
|
state.value = value;
|
|
3479
3542
|
}, [value]);
|
|
3480
|
-
return (jsx(Popup, { visible: active, trigger: 'click', position: 'bottom', arrow: false, align: 'start', watchResize: true, ...popupProps, onVisibleChange: handleVisibleChange, content: jsx(Panel, { value: state.value, format: format, periods: periods, renderItem: renderItem, onChange: handleChange, onFallback: handleFallback }), children: jsx(Input, { value: state.value, placeholder: placeholder, append: jsx(Icon, { icon: jsx(AccessTimeRound, {}), className: 'i-timepicker-icon', size: '1em' }), onChange: handleChange, onBlur: handleBlur, ...restProps }) }));
|
|
3543
|
+
return (jsx(Popup, { visible: active, trigger: 'click', position: 'bottom', arrow: false, align: 'start', watchResize: true, ...popupProps, onVisibleChange: handleVisibleChange, content: jsx(Panel, { value: state.value, format: format, periods: periods, renderItem: renderItem, onChange: handleChange, onFallback: handleFallback }), children: jsx(Input, { value: state.value, placeholder: placeholder, append: jsx(Icon, { icon: jsx(AccessTimeRound, {}), className: 'i-timepicker-icon', size: '1em' }), onChange: handleChange, onBlur: handleBlur, className: classNames("i-timepicker-label", className), ...restProps }) }));
|
|
3481
3544
|
}
|
|
3482
3545
|
|
|
3483
3546
|
const defaultOk = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ForwardRefExoticComponent, RefAttributes, ButtonHTMLAttributes, AnchorHTMLAttributes, ReactNode, CSSProperties, RefObject } from 'react';
|
|
2
2
|
import { LinkProps } from 'react-router';
|
|
3
|
+
import Confirm from './confirm.js';
|
|
3
4
|
import Group from './group.js';
|
|
4
5
|
import Toggle from './toggle.js';
|
|
5
6
|
|
|
@@ -29,6 +30,12 @@ interface IButtonToggle extends IButton {
|
|
|
29
30
|
toggable?: () => boolean | Promise<boolean>;
|
|
30
31
|
onToggle?: (active: boolean) => void;
|
|
31
32
|
}
|
|
33
|
+
interface IButtonConfirm extends IButton {
|
|
34
|
+
okButtonProps?: IButton;
|
|
35
|
+
cancelButtonProps?: IButton;
|
|
36
|
+
onOk?: () => void | boolean | Promise<void | boolean>;
|
|
37
|
+
onCancel?: () => void;
|
|
38
|
+
}
|
|
32
39
|
interface IButtonGroup {
|
|
33
40
|
children?: ReactNode;
|
|
34
41
|
vertical?: boolean;
|
|
@@ -39,6 +46,7 @@ interface IButtonGroup {
|
|
|
39
46
|
interface CompositionButton extends ForwardRefExoticComponent<IButton & RefAttributes<HTMLElement>> {
|
|
40
47
|
Toggle: typeof Toggle;
|
|
41
48
|
Group: typeof Group;
|
|
49
|
+
Confirm: typeof Confirm;
|
|
42
50
|
}
|
|
43
51
|
|
|
44
|
-
export type { CompositionButton, IButton, IButtonGroup, IButtonToggle };
|
|
52
|
+
export type { CompositionButton, IButton, IButtonConfirm, IButtonGroup, IButtonToggle };
|
|
@@ -2,8 +2,9 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import { IListItem } from '../list/type.js';
|
|
3
3
|
import { IPopup } from '../popup/type.js';
|
|
4
4
|
|
|
5
|
-
interface IDropdown extends IPopup {
|
|
5
|
+
interface IDropdown extends Omit<IPopup, "content"> {
|
|
6
6
|
width?: string | number;
|
|
7
|
+
content?: ReactNode | ((close: () => void) => ReactNode);
|
|
7
8
|
}
|
|
8
9
|
interface IDropItem extends IListItem {
|
|
9
10
|
more?: ReactNode;
|