@ioca/react 1.3.79 → 1.3.81
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/editor/editor.js +1 -0
- package/lib/cjs/components/editor/editor.js.map +1 -1
- package/lib/cjs/components/form/useForm.js +2 -0
- package/lib/cjs/components/form/useForm.js.map +1 -1
- package/lib/cjs/components/image/image.js +1 -1
- package/lib/cjs/components/image/image.js.map +1 -1
- package/lib/cjs/components/input/input.js +2 -2
- package/lib/cjs/components/input/input.js.map +1 -1
- package/lib/cjs/components/input/number.js +2 -2
- package/lib/cjs/components/input/number.js.map +1 -1
- package/lib/cjs/components/input/range.js +16 -6
- package/lib/cjs/components/input/range.js.map +1 -1
- package/lib/cjs/components/input/textarea.js +2 -2
- package/lib/cjs/components/input/textarea.js.map +1 -1
- package/lib/cjs/components/modal/modal.js +1 -1
- package/lib/cjs/components/modal/modal.js.map +1 -1
- package/lib/cjs/components/swiper/swiper.js +1 -1
- package/lib/cjs/components/swiper/swiper.js.map +1 -1
- package/lib/css/index.css +1 -1
- package/lib/css/index.css.map +1 -1
- package/lib/es/components/editor/editor.js +1 -0
- package/lib/es/components/editor/editor.js.map +1 -1
- package/lib/es/components/form/useForm.js +2 -0
- package/lib/es/components/form/useForm.js.map +1 -1
- package/lib/es/components/image/image.js +1 -1
- package/lib/es/components/image/image.js.map +1 -1
- package/lib/es/components/input/input.js +2 -2
- package/lib/es/components/input/input.js.map +1 -1
- package/lib/es/components/input/number.js +2 -2
- package/lib/es/components/input/number.js.map +1 -1
- package/lib/es/components/input/range.js +16 -6
- package/lib/es/components/input/range.js.map +1 -1
- package/lib/es/components/input/textarea.js +2 -2
- package/lib/es/components/input/textarea.js.map +1 -1
- package/lib/es/components/modal/modal.js +1 -1
- package/lib/es/components/modal/modal.js.map +1 -1
- package/lib/es/components/swiper/swiper.js +1 -1
- package/lib/es/components/swiper/swiper.js.map +1 -1
- package/lib/index.js +28 -15
- package/lib/types/components/editor/type.d.ts +1 -0
- package/lib/types/components/input/type.d.ts +2 -0
- package/lib/types/components/modal/type.d.ts +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1483,6 +1483,7 @@ const Editor = (props) => {
|
|
|
1483
1483
|
};
|
|
1484
1484
|
useImperativeHandle(ref, () => {
|
|
1485
1485
|
return {
|
|
1486
|
+
input: editorRef.current,
|
|
1486
1487
|
setValue(html) {
|
|
1487
1488
|
if (!editorRef.current)
|
|
1488
1489
|
return;
|
|
@@ -1660,6 +1661,7 @@ class IFormInstance {
|
|
|
1660
1661
|
rule.validator = o;
|
|
1661
1662
|
}
|
|
1662
1663
|
else if (o === true) {
|
|
1664
|
+
rule.validator = (v) => ![undefined, null, ""].includes(v);
|
|
1663
1665
|
rule.message = "required";
|
|
1664
1666
|
}
|
|
1665
1667
|
else {
|
|
@@ -1692,6 +1694,7 @@ class IFormInstance {
|
|
|
1692
1694
|
rule.validator = o;
|
|
1693
1695
|
}
|
|
1694
1696
|
else if (o === true) {
|
|
1697
|
+
rule.validator = (v) => ![undefined, null, ""].includes(v);
|
|
1695
1698
|
rule.message = "required";
|
|
1696
1699
|
}
|
|
1697
1700
|
else {
|
|
@@ -1825,7 +1828,7 @@ function DefaultContent(props) {
|
|
|
1825
1828
|
const showHeader = title || !hideCloseButton;
|
|
1826
1829
|
const handleOk = async () => {
|
|
1827
1830
|
const ret = await onOk?.();
|
|
1828
|
-
if (ret)
|
|
1831
|
+
if (ret === false)
|
|
1829
1832
|
return;
|
|
1830
1833
|
onClose?.();
|
|
1831
1834
|
};
|
|
@@ -2499,7 +2502,7 @@ const Image = (props) => {
|
|
|
2499
2502
|
useEffect(() => {
|
|
2500
2503
|
if (!src)
|
|
2501
2504
|
return;
|
|
2502
|
-
if (!ref.current?.complete && observe) {
|
|
2505
|
+
if (!ref.current?.complete && observe && lazyload) {
|
|
2503
2506
|
state.status = "loading";
|
|
2504
2507
|
}
|
|
2505
2508
|
if (!lazyload || !ref.current || !observe)
|
|
@@ -2537,7 +2540,7 @@ function InputContainer(props) {
|
|
|
2537
2540
|
}
|
|
2538
2541
|
|
|
2539
2542
|
const Number = (props) => {
|
|
2540
|
-
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;
|
|
2543
|
+
const { ref, label, name, value = props.initValue ?? "", initValue, labelInline, step = 1, min = -Infinity, max = Infinity, thousand, precision, type, className, width, status = "normal", append, border, prepend, message, tip, hideControl, style, onChange, onEnter, onInput, onBlur, ...restProps } = props;
|
|
2541
2544
|
const state = useReactive({
|
|
2542
2545
|
value,
|
|
2543
2546
|
});
|
|
@@ -2573,14 +2576,14 @@ const Number = (props) => {
|
|
|
2573
2576
|
onChange: handleChange,
|
|
2574
2577
|
...restProps,
|
|
2575
2578
|
};
|
|
2576
|
-
return (jsx(InputContainer, { label: label, labelInline: labelInline, className: className, style: style, tip: message ?? tip, status: status, children: jsxs("div", { className: classNames("i-input-item", {
|
|
2579
|
+
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", {
|
|
2577
2580
|
[`i-input-${status}`]: status !== "normal",
|
|
2578
2581
|
"i-input-borderless": !border,
|
|
2579
2582
|
}), children: [prepend && jsx("div", { className: 'i-input-prepend', children: prepend }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(MinusRound, {}), onClick: () => handleOperate(-step) })), jsx("input", { ...inputProps }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(PlusRound, {}), onClick: () => handleOperate(step) })), append && jsx("div", { className: 'i-input-append', children: append })] }) }));
|
|
2580
2583
|
};
|
|
2581
2584
|
|
|
2582
2585
|
const Range = (props) => {
|
|
2583
|
-
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;
|
|
2586
|
+
const { label, name, value = props.initValue ?? "", initValue, 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;
|
|
2584
2587
|
const state = useReactive({
|
|
2585
2588
|
value,
|
|
2586
2589
|
});
|
|
@@ -2597,7 +2600,7 @@ const Range = (props) => {
|
|
|
2597
2600
|
const { value } = e.target;
|
|
2598
2601
|
const v = formatInputValue(value.replace(/[^\d\.-]/g, ""));
|
|
2599
2602
|
const range = Array.isArray(state.value) ? state.value : [];
|
|
2600
|
-
range[i] =
|
|
2603
|
+
range[i] = v;
|
|
2601
2604
|
state.value = range;
|
|
2602
2605
|
onChange?.(range, e);
|
|
2603
2606
|
};
|
|
@@ -2612,8 +2615,8 @@ const Range = (props) => {
|
|
|
2612
2615
|
onChange?.(range, e);
|
|
2613
2616
|
};
|
|
2614
2617
|
const handleSwitch = (e) => {
|
|
2615
|
-
e
|
|
2616
|
-
e
|
|
2618
|
+
e?.preventDefault();
|
|
2619
|
+
e?.stopPropagation();
|
|
2617
2620
|
const range = state.value ? state.value : [];
|
|
2618
2621
|
const v = range[0];
|
|
2619
2622
|
range[0] = range[1];
|
|
@@ -2629,14 +2632,24 @@ const Range = (props) => {
|
|
|
2629
2632
|
className: "i-input i-input-number",
|
|
2630
2633
|
...restProps,
|
|
2631
2634
|
};
|
|
2632
|
-
|
|
2635
|
+
const handleBlur = () => {
|
|
2636
|
+
const range = Array.isArray(state.value) ? state.value : [];
|
|
2637
|
+
if (range.length < 2)
|
|
2638
|
+
return;
|
|
2639
|
+
const l = +range[0];
|
|
2640
|
+
const r = +range[1];
|
|
2641
|
+
if (l <= r)
|
|
2642
|
+
return;
|
|
2643
|
+
handleSwitch();
|
|
2644
|
+
};
|
|
2645
|
+
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", {
|
|
2633
2646
|
[`i-input-${status}`]: status !== "normal",
|
|
2634
2647
|
"i-input-borderless": !border,
|
|
2635
|
-
}), children: [prepend && jsx("div", { className: 'i-input-prepend', children: prepend }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(MinusRound, {}), onClick: (e) => handleOperate(e, -step, 0) })), jsx("input", { value: state.value?.[0] || "", placeholder: placeholder?.[0], ...inputProps, onChange: (e) => handleChange(e, 0) }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(PlusRound, {}), onClick: (e) => handleOperate(e, step, 0) })), jsx(Helpericon, { active: true, icon: jsx(SyncAltRound, {}), style: { margin: 0 }, onClick: handleSwitch }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(MinusRound, {}), onClick: (e) => handleOperate(e, -step, 1) })), jsx("input", { value: state.value?.[1] || "", placeholder: placeholder?.[1], ...inputProps, onChange: (e) => handleChange(e, 1) }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(PlusRound, {}), onClick: (e) => handleOperate(e, step, 1) })), append && jsx("div", { className: 'i-input-append', children: append })] }) }));
|
|
2648
|
+
}), children: [prepend && jsx("div", { className: 'i-input-prepend', children: prepend }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(MinusRound, {}), onClick: (e) => handleOperate(e, -step, 0) })), jsx("input", { value: state.value?.[0] || "", placeholder: placeholder?.[0], ...inputProps, onBlur: handleBlur, onChange: (e) => handleChange(e, 0) }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(PlusRound, {}), onClick: (e) => handleOperate(e, step, 0) })), jsx(Helpericon, { active: true, icon: jsx(SyncAltRound, {}), style: { margin: 0 }, onClick: handleSwitch }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(MinusRound, {}), onClick: (e) => handleOperate(e, -step, 1) })), jsx("input", { value: state.value?.[1] || "", placeholder: placeholder?.[1], ...inputProps, onBlur: handleBlur, onChange: (e) => handleChange(e, 1) }), !hideControl && (jsx(Helpericon, { active: true, icon: jsx(PlusRound, {}), onClick: (e) => handleOperate(e, step, 1) })), append && jsx("div", { className: 'i-input-append', children: append })] }) }));
|
|
2636
2649
|
};
|
|
2637
2650
|
|
|
2638
2651
|
const Textarea = (props) => {
|
|
2639
|
-
const { ref, label, name, value = props.initValue, initValue, labelInline, className, status = "normal", message, tip, autoSize, border, style, onChange, onEnter, ...restProps } = props;
|
|
2652
|
+
const { ref, label, name, value = props.initValue, initValue, labelInline, className, status = "normal", message, tip, autoSize, border, width, style, onChange, onEnter, ...restProps } = props;
|
|
2640
2653
|
const state = useReactive({
|
|
2641
2654
|
value,
|
|
2642
2655
|
});
|
|
@@ -2668,14 +2681,14 @@ const Textarea = (props) => {
|
|
|
2668
2681
|
onKeyDown: handleKeydown,
|
|
2669
2682
|
...restProps,
|
|
2670
2683
|
};
|
|
2671
|
-
return (jsx(InputContainer, { label: label, labelInline: labelInline, className: className, style: style, tip: message ?? tip, status: status, children: jsx("div", { ref: refTextarea, className: classNames("i-input-item", {
|
|
2684
|
+
return (jsx(InputContainer, { label: label, labelInline: labelInline, className: className, style: { width, ...style }, tip: message ?? tip, status: status, children: jsx("div", { ref: refTextarea, className: classNames("i-input-item", {
|
|
2672
2685
|
[`i-input-${status}`]: status !== "normal",
|
|
2673
2686
|
"i-input-borderless": !border,
|
|
2674
2687
|
}), children: jsx("textarea", { ...inputProps }) }) }));
|
|
2675
2688
|
};
|
|
2676
2689
|
|
|
2677
2690
|
const Input = ((props) => {
|
|
2678
|
-
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;
|
|
2691
|
+
const { ref, type = "text", label, name, value = props.initValue ?? "", initValue = "", prepend, append, labelInline, className, status = "normal", message, tip, clear, width, hideVisible, border, required, onChange, onEnter, style, ...restProps } = props;
|
|
2679
2692
|
const state = useReactive({
|
|
2680
2693
|
value,
|
|
2681
2694
|
type,
|
|
@@ -2721,7 +2734,7 @@ const Input = ((props) => {
|
|
|
2721
2734
|
};
|
|
2722
2735
|
const clearable = clear && state.value;
|
|
2723
2736
|
const showHelper = type === "password" && !!state.value;
|
|
2724
|
-
return (jsx(InputContainer, { label: label, labelInline: labelInline, className: className, style: style, tip: message ?? tip, status: status, required: required, children: jsxs("div", { className: classNames("i-input-item", {
|
|
2737
|
+
return (jsx(InputContainer, { label: label, labelInline: labelInline, className: className, style: { width, ...style }, tip: message ?? tip, status: status, required: required, children: jsxs("div", { className: classNames("i-input-item", {
|
|
2725
2738
|
[`i-input-${status}`]: status !== "normal",
|
|
2726
2739
|
"i-input-borderless": !border,
|
|
2727
2740
|
}), children: [prepend && jsx("div", { className: 'i-input-prepend', children: prepend }), jsx("input", { ...inputProps }), jsx(Helpericon, { active: !!clearable || showHelper, icon: HelperIcon, onClick: handleHelperClick }), append && jsx("div", { className: 'i-input-append', children: append })] }) }));
|
|
@@ -3846,7 +3859,7 @@ const Swiper = ((props) => {
|
|
|
3846
3859
|
}, onMouseDown: handleMouseDown, onTouchStart: handleMouseDown, children: displayItems.map((item, i) => {
|
|
3847
3860
|
const { props: itemProps } = item;
|
|
3848
3861
|
return (jsx(Item$1, { index: i, itemIndex: (i - extra + size) % size, active: i - extra === state.current, type: type, gap: gap, transition: transition, itemHeight: itemHeight, vertical: vertical, onItemClick: onItemClick, ...itemProps }, i));
|
|
3849
|
-
}) }), arrow && (jsxs(Fragment, { children: [(loop || state.current !== 0) && (jsx("a", { className: 'i-swiper-arrow i-swiper-prev', onClick: swipePrev, children: prev })), (loop || state.current < size - display) && (jsx("a", { className: 'i-swiper-arrow i-swiper-next', onClick: swipeNext, children: next }))] }))] }), indicator && (jsx("div", { className: classNames("i-swiper-indicators", {
|
|
3862
|
+
}) }), arrow && size > 1 && (jsxs(Fragment, { children: [(loop || state.current !== 0) && (jsx("a", { className: 'i-swiper-arrow i-swiper-prev', onClick: swipePrev, children: prev })), (loop || state.current < size - display) && (jsx("a", { className: 'i-swiper-arrow i-swiper-next', onClick: swipeNext, children: next }))] }))] }), indicator && (jsx("div", { className: classNames("i-swiper-indicators", {
|
|
3850
3863
|
"i-swiper-indicators-fixed": fixedIndicator,
|
|
3851
3864
|
}), children: indicatorsLoop.map((_, i) => {
|
|
3852
3865
|
return (jsx("a", { className: classNames("i-swiper-indicator", {
|
|
@@ -12,6 +12,7 @@ interface IEditor extends Omit<HTMLAttributes<HTMLDivElement>, "onInput"> {
|
|
|
12
12
|
onInput?: (html: string, e: FormEvent<HTMLDivElement>) => void;
|
|
13
13
|
}
|
|
14
14
|
interface RefEditor {
|
|
15
|
+
input: HTMLDivElement | null;
|
|
15
16
|
getSafeValue: () => string;
|
|
16
17
|
setValue: (html: string) => void;
|
|
17
18
|
}
|
|
@@ -12,6 +12,7 @@ interface IInput extends BaseInput, Omit<InputHTMLAttributes<HTMLInputElement>,
|
|
|
12
12
|
interface ITextarea extends Omit<BaseInput, "ref">, Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, "value" | "defaultValue" | "onChange"> {
|
|
13
13
|
ref?: RefObject<HTMLTextAreaElement | null>;
|
|
14
14
|
autoSize?: boolean;
|
|
15
|
+
width?: string | number;
|
|
15
16
|
}
|
|
16
17
|
interface IInputNumber extends BaseInput, Omit<InputHTMLAttributes<HTMLInputElement>, "onChange" | "defaultValue"> {
|
|
17
18
|
value?: string | number;
|
|
@@ -35,6 +36,7 @@ interface IInputRange extends Omit<BaseInput, "value" | "onChange">, Omit<InputH
|
|
|
35
36
|
thousand?: string;
|
|
36
37
|
precision?: number;
|
|
37
38
|
hideControl?: boolean;
|
|
39
|
+
autoSwitch?: boolean;
|
|
38
40
|
onChange?: (value: (number | string | undefined)[], e?: ChangeEvent<HTMLInputElement> | MouseEvent<Element>) => void;
|
|
39
41
|
}
|
|
40
42
|
type CompositionInput = ForwardRefExoticComponent<IInput> & {
|
|
@@ -21,7 +21,7 @@ interface IModal extends Omit<HTMLAttributes<HTMLDivElement>, "title"> {
|
|
|
21
21
|
keepDOM?: boolean;
|
|
22
22
|
disableEsc?: boolean;
|
|
23
23
|
onVisibleChange?: (visible: boolean) => void;
|
|
24
|
-
onOk?: () => void | Promise<any>;
|
|
24
|
+
onOk?: () => (void | boolean) | Promise<any>;
|
|
25
25
|
onClose?: () => void;
|
|
26
26
|
}
|
|
27
27
|
interface CompositionModal extends FC<IModal> {
|