@pinnacle0/web-ui 0.6.46 → 0.7.0-beta.2
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/admin/AdminApp/Default/NavigatorSide/index.js +1 -1
- package/admin/AdminApp/Default/NavigatorSide/index.js.map +1 -1
- package/core/Amount/AmountPercentage.d.ts +1 -4
- package/core/Amount/AmountPercentage.js +5 -8
- package/core/Amount/AmountPercentage.js.map +1 -1
- package/core/Amount/index.d.ts +3 -8
- package/core/Amount/index.js +27 -35
- package/core/Amount/index.js.map +1 -1
- package/core/AuthenticationCodeInput/index.less +1 -1
- package/core/AutoCompleteInput/index.d.ts +2 -5
- package/core/AutoCompleteInput/index.js +5 -7
- package/core/AutoCompleteInput/index.js.map +1 -1
- package/core/BoolSwitch/index.d.ts +5 -7
- package/core/BoolSwitch/index.js +11 -13
- package/core/BoolSwitch/index.js.map +1 -1
- package/core/Breadcrumb/index.d.ts +1 -5
- package/core/Breadcrumb/index.js +8 -16
- package/core/Breadcrumb/index.js.map +1 -1
- package/core/Button/index.d.ts +2 -2
- package/core/Button/index.js +3 -2
- package/core/Button/index.js.map +1 -1
- package/core/Card/index.d.ts +3 -6
- package/core/Card/index.js +4 -7
- package/core/Card/index.js.map +1 -1
- package/core/Carousel/index.d.ts +1 -4
- package/core/Carousel/index.js +4 -7
- package/core/Carousel/index.js.map +1 -1
- package/core/Carousel3D/index.d.ts +1 -21
- package/core/Carousel3D/index.js +76 -83
- package/core/Carousel3D/index.js.map +1 -1
- package/core/Cascader/InitialNullable.d.ts +1 -4
- package/core/Cascader/InitialNullable.js +5 -8
- package/core/Cascader/InitialNullable.js.map +1 -1
- package/core/Cascader/Nullable.d.ts +2 -7
- package/core/Cascader/Nullable.js +10 -12
- package/core/Cascader/Nullable.js.map +1 -1
- package/core/Cascader/index.d.ts +4 -13
- package/core/Cascader/index.js +18 -20
- package/core/Cascader/index.js.map +1 -1
- package/core/Checkbox/index.d.ts +4 -7
- package/core/Checkbox/index.js +4 -9
- package/core/Checkbox/index.js.map +1 -1
- package/core/Collapse/index.d.ts +2 -7
- package/core/Collapse/index.js +4 -6
- package/core/Collapse/index.js.map +1 -1
- package/core/Countdown/SlidingDigit.d.ts +1 -10
- package/core/Countdown/SlidingDigit.js +16 -21
- package/core/Countdown/SlidingDigit.js.map +1 -1
- package/core/Countdown/index.d.ts +1 -18
- package/core/Countdown/index.js +53 -74
- package/core/Countdown/index.js.map +1 -1
- package/core/DarkOverlay/index.d.ts +1 -4
- package/core/DarkOverlay/index.js +4 -7
- package/core/DarkOverlay/index.js.map +1 -1
- package/core/DateCalendar/index.d.ts +2 -13
- package/core/DateCalendar/index.js +12 -14
- package/core/DateCalendar/index.js.map +1 -1
- package/core/DatePicker/index.d.ts +1 -7
- package/core/DatePicker/index.js +9 -16
- package/core/DatePicker/index.js.map +1 -1
- package/core/DateRangePicker/index.d.ts +1 -14
- package/core/DateRangePicker/index.js +25 -34
- package/core/DateRangePicker/index.js.map +1 -1
- package/core/DateTimePicker/index.d.ts +1 -7
- package/core/DateTimePicker/index.js +12 -21
- package/core/DateTimePicker/index.js.map +1 -1
- package/core/DateTimeRangePicker/index.d.ts +1 -17
- package/core/DateTimeRangePicker/index.js +21 -31
- package/core/DateTimeRangePicker/index.js.map +1 -1
- package/core/Descriptions/index.d.ts +3 -8
- package/core/Descriptions/index.js +7 -13
- package/core/Descriptions/index.js.map +1 -1
- package/core/Descriptions/index.less +0 -8
- package/core/DocumentTitle/index.d.ts +4 -13
- package/core/DocumentTitle/index.js +18 -31
- package/core/DocumentTitle/index.js.map +1 -1
- package/core/Drawer/index.d.ts +1 -3
- package/core/Drawer/index.js +4 -5
- package/core/Drawer/index.js.map +1 -1
- package/core/Dropdown/index.d.ts +3 -4
- package/core/Dropdown/index.js +4 -3
- package/core/Dropdown/index.js.map +1 -1
- package/core/EnumCheckboxGroup/Map.d.ts +1 -4
- package/core/EnumCheckboxGroup/Map.js +5 -9
- package/core/EnumCheckboxGroup/Map.js.map +1 -1
- package/core/EnumCheckboxGroup/index.d.ts +3 -4
- package/core/EnumCheckboxGroup/index.js +11 -12
- package/core/EnumCheckboxGroup/index.js.map +1 -1
- package/core/EnumRadio/InitialNullable.d.ts +1 -5
- package/core/EnumRadio/InitialNullable.js +6 -9
- package/core/EnumRadio/InitialNullable.js.map +1 -1
- package/core/EnumRadio/Map.d.ts +1 -4
- package/core/EnumRadio/Map.js +6 -9
- package/core/EnumRadio/Map.js.map +1 -1
- package/core/EnumRadio/Nullable.d.ts +1 -5
- package/core/EnumRadio/Nullable.js +12 -14
- package/core/EnumRadio/Nullable.js.map +1 -1
- package/core/EnumRadio/index.d.ts +5 -12
- package/core/EnumRadio/index.js +9 -17
- package/core/EnumRadio/index.js.map +1 -1
- package/core/EnumSelect/InitialNullable.d.ts +1 -4
- package/core/EnumSelect/InitialNullable.js +4 -8
- package/core/EnumSelect/InitialNullable.js.map +1 -1
- package/core/EnumSelect/Map.d.ts +1 -4
- package/core/EnumSelect/Map.js +6 -9
- package/core/EnumSelect/Map.js.map +1 -1
- package/core/EnumSelect/Nullable.d.ts +1 -5
- package/core/EnumSelect/Nullable.js +12 -14
- package/core/EnumSelect/Nullable.js.map +1 -1
- package/core/EnumSelect/index.d.ts +5 -15
- package/core/EnumSelect/index.js +19 -27
- package/core/EnumSelect/index.js.map +1 -1
- package/core/EnumSelect/index.less +1 -1
- package/core/FlatList/Content/Footer/index.js +3 -2
- package/core/FlatList/Content/Footer/index.js.map +1 -1
- package/core/FlatList/Content/index.d.ts +1 -1
- package/core/FlatList/Content/index.js +10 -8
- package/core/FlatList/Content/index.js.map +1 -1
- package/core/FlatList/FloatingLoader/index.js +3 -2
- package/core/FlatList/FloatingLoader/index.js.map +1 -1
- package/core/FlatList/Refresh/index.js +3 -2
- package/core/FlatList/Refresh/index.js.map +1 -1
- package/core/FlatList/index.d.ts +1 -1
- package/core/FlatList/index.js +10 -9
- package/core/FlatList/index.js.map +1 -1
- package/core/FlatList/shared/Loader/index.js +3 -2
- package/core/FlatList/shared/Loader/index.js.map +1 -1
- package/core/Form/Item.d.ts +1 -16
- package/core/Form/Item.js +28 -40
- package/core/Form/Item.js.map +1 -1
- package/core/Form/index.d.ts +6 -17
- package/core/Form/index.js +29 -46
- package/core/Form/index.js.map +1 -1
- package/core/Form/index.less +1 -1
- package/core/Grid/index.d.ts +2 -2
- package/core/Grid/index.js +2 -1
- package/core/Grid/index.js.map +1 -1
- package/core/HTMLContent/index.d.ts +1 -4
- package/core/HTMLContent/index.js +4 -7
- package/core/HTMLContent/index.js.map +1 -1
- package/core/Image/index.d.ts +3 -6
- package/core/Image/index.js +6 -7
- package/core/Image/index.js.map +1 -1
- package/core/ImageUploader/index.d.ts +2 -11
- package/core/ImageUploader/index.js +17 -25
- package/core/ImageUploader/index.js.map +1 -1
- package/core/Input/index.d.ts +12 -18
- package/core/Input/index.js +37 -41
- package/core/Input/index.js.map +1 -1
- package/core/LabelledSelect/index.d.ts +3 -5
- package/core/LabelledSelect/index.js +4 -7
- package/core/LabelledSelect/index.js.map +1 -1
- package/core/Link/index.d.ts +1 -4
- package/core/Link/index.js +16 -19
- package/core/Link/index.js.map +1 -1
- package/core/LocalImporter/index.d.ts +1 -10
- package/core/LocalImporter/index.js +11 -18
- package/core/LocalImporter/index.js.map +1 -1
- package/core/LocaleSelect/index.d.ts +1 -10
- package/core/LocaleSelect/index.js +16 -18
- package/core/LocaleSelect/index.js.map +1 -1
- package/core/Markdown/index.d.ts +1 -7
- package/core/Markdown/index.js +13 -16
- package/core/Markdown/index.js.map +1 -1
- package/core/Modal/index.less +1 -1
- package/core/MultipleCascader/index.d.ts +1 -9
- package/core/MultipleCascader/index.js +15 -19
- package/core/MultipleCascader/index.js.map +1 -1
- package/core/MultipleEnumSelect/index.d.ts +1 -8
- package/core/MultipleEnumSelect/index.js +9 -15
- package/core/MultipleEnumSelect/index.js.map +1 -1
- package/core/MultipleSelector/TablePopover.d.ts +1 -7
- package/core/MultipleSelector/TablePopover.js +23 -26
- package/core/MultipleSelector/TablePopover.js.map +1 -1
- package/core/MultipleSelector/index.d.ts +1 -9
- package/core/MultipleSelector/index.js +18 -26
- package/core/MultipleSelector/index.js.map +1 -1
- package/core/MutableTable/index.d.ts +1 -13
- package/core/MutableTable/index.js +25 -35
- package/core/MutableTable/index.js.map +1 -1
- package/core/NumberInput/NumberInputPercentage.d.ts +1 -8
- package/core/NumberInput/NumberInputPercentage.js +8 -25
- package/core/NumberInput/NumberInputPercentage.js.map +1 -1
- package/core/NumberInput/index.d.ts +5 -33
- package/core/NumberInput/index.js +44 -72
- package/core/NumberInput/index.js.map +1 -1
- package/core/OverflowableText/index.d.ts +1 -12
- package/core/OverflowableText/index.js +11 -28
- package/core/OverflowableText/index.js.map +1 -1
- package/core/Pagination/index.d.ts +1 -7
- package/core/Pagination/index.js +17 -19
- package/core/Pagination/index.js.map +1 -1
- package/core/Popover/index.d.ts +0 -1
- package/core/Popover/index.js +2 -5
- package/core/Popover/index.js.map +1 -1
- package/core/Progress/index.d.ts +1 -4
- package/core/Progress/index.js +4 -6
- package/core/Progress/index.js.map +1 -1
- package/core/Radio/index.d.ts +5 -7
- package/core/Radio/index.js +2 -8
- package/core/Radio/index.js.map +1 -1
- package/core/RelativeTime/index.d.ts +1 -15
- package/core/RelativeTime/index.js +17 -31
- package/core/RelativeTime/index.js.map +1 -1
- package/core/Resizable/index.js +3 -2
- package/core/Resizable/index.js.map +1 -1
- package/core/SearchableSelect/index.d.ts +3 -5
- package/core/SearchableSelect/index.js +4 -7
- package/core/SearchableSelect/index.js.map +1 -1
- package/core/Select/index.d.ts +8 -7
- package/core/Select/index.js +8 -8
- package/core/Select/index.js.map +1 -1
- package/core/SignedAmountInput/index.d.ts +1 -8
- package/core/SignedAmountInput/index.js +16 -24
- package/core/SignedAmountInput/index.js.map +1 -1
- package/core/Skeleton/index.d.ts +1 -4
- package/core/Skeleton/index.js +4 -7
- package/core/Skeleton/index.js.map +1 -1
- package/core/Slider/RangeSlider.d.ts +2 -6
- package/core/Slider/RangeSlider.js +4 -7
- package/core/Slider/RangeSlider.js.map +1 -1
- package/core/Slider/index.d.ts +3 -7
- package/core/Slider/index.js +15 -20
- package/core/Slider/index.js.map +1 -1
- package/core/Space/index.d.ts +3 -5
- package/core/Space/index.js +4 -7
- package/core/Space/index.js.map +1 -1
- package/core/Spin/index.d.ts +3 -6
- package/core/Spin/index.js +4 -7
- package/core/Spin/index.js.map +1 -1
- package/core/StepFormContainer/index.d.ts +2 -7
- package/core/StepFormContainer/index.js +13 -17
- package/core/StepFormContainer/index.js.map +1 -1
- package/core/Steps/index.d.ts +3 -6
- package/core/Steps/index.js +4 -6
- package/core/Steps/index.js.map +1 -1
- package/core/Table/index.d.ts +6 -34
- package/core/Table/index.js +64 -80
- package/core/Table/index.js.map +1 -1
- package/core/Tabs/Single.d.ts +1 -4
- package/core/Tabs/Single.js +4 -7
- package/core/Tabs/Single.js.map +1 -1
- package/core/Tabs/index.d.ts +3 -13
- package/core/Tabs/index.js +27 -35
- package/core/Tabs/index.js.map +1 -1
- package/core/Tag/index.d.ts +2 -5
- package/core/Tag/index.js +4 -6
- package/core/Tag/index.js.map +1 -1
- package/core/TagInput/index.d.ts +2 -15
- package/core/TagInput/index.js +25 -41
- package/core/TagInput/index.js.map +1 -1
- package/core/Tags/index.d.ts +1 -6
- package/core/Tags/index.js +9 -13
- package/core/Tags/index.js.map +1 -1
- package/core/TimePicker/index.d.ts +1 -7
- package/core/TimePicker/index.js +8 -11
- package/core/TimePicker/index.js.map +1 -1
- package/core/TimeRangePicker/index.d.ts +1 -14
- package/core/TimeRangePicker/index.js +21 -27
- package/core/TimeRangePicker/index.js.map +1 -1
- package/core/Tooltip/index.d.ts +3 -4
- package/core/Tooltip/index.js +2 -5
- package/core/Tooltip/index.js.map +1 -1
- package/core/TypedTabs/index.d.ts +1 -4
- package/core/TypedTabs/index.js +16 -18
- package/core/TypedTabs/index.js.map +1 -1
- package/core/Uploader/index.d.ts +1 -17
- package/core/Uploader/index.js +25 -31
- package/core/Uploader/index.js.map +1 -1
- package/core/VirtualList/index.d.ts +1 -1
- package/core/VirtualList/index.js +3 -2
- package/core/VirtualList/index.js.map +1 -1
- package/core/VirtualTable/{TableHeader.js → OldVirtualTable/TableHeader.js} +2 -2
- package/core/VirtualTable/OldVirtualTable/TableHeader.js.map +1 -0
- package/core/VirtualTable/{TableRow.js → OldVirtualTable/TableRow.js} +2 -2
- package/core/VirtualTable/OldVirtualTable/TableRow.js.map +1 -0
- package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useColumnWidths.js +1 -1
- package/core/VirtualTable/OldVirtualTable/hooks/useColumnWidths.js.map +1 -0
- package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useColumnsStickyPosition.js +1 -1
- package/core/VirtualTable/OldVirtualTable/hooks/useColumnsStickyPosition.js.map +1 -0
- package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useRowSelection.d.ts +1 -1
- package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useRowSelection.js +2 -2
- package/core/VirtualTable/OldVirtualTable/hooks/useRowSelection.js.map +1 -0
- package/core/VirtualTable/OldVirtualTable/hooks/useScroll.js.map +1 -0
- package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useScrollBarSize.js +1 -1
- package/core/VirtualTable/OldVirtualTable/hooks/useScrollBarSize.js.map +1 -0
- package/core/VirtualTable/OldVirtualTable/index.d.ts +28 -0
- package/core/VirtualTable/OldVirtualTable/index.js +58 -0
- package/core/VirtualTable/OldVirtualTable/index.js.map +1 -0
- package/core/VirtualTable/OldVirtualTable/index.old.less +160 -0
- package/core/VirtualTable/OldVirtualTable/type.js.map +1 -0
- package/core/VirtualTable/index.d.ts +24 -23
- package/core/VirtualTable/index.js +36 -50
- package/core/VirtualTable/index.js.map +1 -1
- package/core/VirtualTable/index.less +28 -140
- package/core/WithExplanation/index.d.ts +1 -6
- package/core/WithExplanation/index.js +11 -20
- package/core/WithExplanation/index.js.map +1 -1
- package/core/WithTooltipList/index.d.ts +1 -9
- package/core/WithTooltipList/index.js +28 -27
- package/core/WithTooltipList/index.js.map +1 -1
- package/core/YearMonthSelector/index.d.ts +1 -7
- package/core/YearMonthSelector/index.js +9 -15
- package/core/YearMonthSelector/index.js.map +1 -1
- package/css/global.less +0 -9
- package/hooks/useParentResizeObserver/index.d.ts +2 -0
- package/hooks/useParentResizeObserver/index.js +17 -0
- package/hooks/useParentResizeObserver/index.js.map +1 -0
- package/hooks/useResizeObserver/index.d.ts +1 -1
- package/hooks/useResizeObserver/index.js +6 -10
- package/hooks/useResizeObserver/index.js.map +1 -1
- package/package.json +6 -6
- package/util/ModalUtil/index.less +1 -1
- package/util/OrientationUtil/index.js +22 -37
- package/util/OrientationUtil/index.js.map +1 -1
- package/util/PromptUtil/PromptBody.d.ts +4 -13
- package/util/PromptUtil/PromptBody.js +19 -28
- package/util/PromptUtil/PromptBody.js.map +1 -1
- package/util/PromptUtil/index.js +1 -1
- package/util/PromptUtil/index.js.map +1 -1
- package/util/ReactUtil/index.d.ts +20 -0
- package/util/ReactUtil/index.js +35 -0
- package/util/ReactUtil/index.js.map +1 -1
- package/core/VirtualTable/TableHeader.js.map +0 -1
- package/core/VirtualTable/TableRow.js.map +0 -1
- package/core/VirtualTable/hooks/useColumnWidths.js.map +0 -1
- package/core/VirtualTable/hooks/useColumnsStickyPosition.js.map +0 -1
- package/core/VirtualTable/hooks/useRowSelection.js.map +0 -1
- package/core/VirtualTable/hooks/useScroll.js.map +0 -1
- package/core/VirtualTable/hooks/useScrollBarSize.js.map +0 -1
- package/core/VirtualTable/type.js.map +0 -1
- /package/core/VirtualTable/{TableHeader.d.ts → OldVirtualTable/TableHeader.d.ts} +0 -0
- /package/core/VirtualTable/{TableRow.d.ts → OldVirtualTable/TableRow.d.ts} +0 -0
- /package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useColumnWidths.d.ts +0 -0
- /package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useColumnsStickyPosition.d.ts +0 -0
- /package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useScroll.d.ts +0 -0
- /package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useScroll.js +0 -0
- /package/core/VirtualTable/{hooks → OldVirtualTable/hooks}/useScrollBarSize.d.ts +0 -0
- /package/core/VirtualTable/{type.d.ts → OldVirtualTable/type.d.ts} +0 -0
- /package/core/VirtualTable/{type.js → OldVirtualTable/type.js} +0 -0
package/core/Form/Item.js
CHANGED
|
@@ -2,45 +2,33 @@ import React from "react";
|
|
|
2
2
|
import { classNames } from "../../util/ClassNames";
|
|
3
3
|
import { Tooltip } from "../Tooltip";
|
|
4
4
|
import { FormValidationContext } from "./context";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
componentDidMount() {
|
|
14
|
-
this.context.registerValidator(this.validate);
|
|
15
|
-
}
|
|
16
|
-
componentWillUnmount() {
|
|
17
|
-
this.context.unregisterValidator(this.validate);
|
|
18
|
-
}
|
|
19
|
-
validate = async () => {
|
|
20
|
-
const { validator } = this.props;
|
|
21
|
-
if (validator) {
|
|
22
|
-
const errorMessage = await validator();
|
|
23
|
-
this.setState({ errorMessage });
|
|
24
|
-
return errorMessage === null;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
5
|
+
import { ReactUtil } from "../../util/ReactUtil";
|
|
6
|
+
const overlayStyle = { color: "red" };
|
|
7
|
+
export const Item = ReactUtil.memo("Item", (props) => {
|
|
8
|
+
const { label, children, className, required, extra, labelStyle, widthMode, validator } = props;
|
|
9
|
+
const { registerValidator, unregisterValidator, errorDisplayMode } = React.useContext(FormValidationContext);
|
|
10
|
+
const [errorMessage, setErrorMessage] = React.useState(null);
|
|
11
|
+
const validate = React.useCallback(async () => {
|
|
12
|
+
if (!validator)
|
|
27
13
|
return true;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
14
|
+
const errorMessage = await validator();
|
|
15
|
+
setErrorMessage(errorMessage);
|
|
16
|
+
return errorMessage === null;
|
|
17
|
+
}, [validator]);
|
|
18
|
+
React.useEffect(() => {
|
|
19
|
+
registerValidator(validate);
|
|
20
|
+
return () => unregisterValidator(validate);
|
|
21
|
+
}, [registerValidator, unregisterValidator, validate]);
|
|
22
|
+
const childrenNode = typeof children === "number" || typeof children === "string" ? React.createElement("span", { className: "pure-text" }, children) : children;
|
|
23
|
+
const extraMessageNode = extra && React.createElement("div", { className: "message" }, extra);
|
|
24
|
+
const errorDisplay = errorDisplayMode();
|
|
25
|
+
return (React.createElement("div", { className: classNames("g-form-item", className) },
|
|
26
|
+
React.createElement("div", { className: classNames("g-form-item-label", { required }), style: labelStyle }, label && React.createElement("label", null, label)),
|
|
27
|
+
React.createElement("div", { className: classNames("g-form-item-children", { "has-error": errorMessage }, widthMode ? `width-${widthMode}` : "") }, errorDisplay.type === "extra" ? (React.createElement(React.Fragment, null,
|
|
28
|
+
childrenNode,
|
|
29
|
+
extraMessageNode,
|
|
30
|
+
errorMessage && React.createElement("div", { className: "message error" }, errorMessage))) : (React.createElement(React.Fragment, null,
|
|
31
|
+
React.createElement(Tooltip, { title: errorMessage, open: errorMessage !== null, placement: errorDisplay.placement || "right", color: "white", styles: { container: overlayStyle } }, childrenNode),
|
|
32
|
+
extraMessageNode)))));
|
|
33
|
+
});
|
|
46
34
|
//# sourceMappingURL=Item.js.map
|
package/core/Form/Item.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Item.js","sourceRoot":"","sources":["../../../src/core/Form/Item.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;A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AI,EAAE,YAAY,KAAK,IAAI,EAAE,SAAS,EAAE,YAAY,CAAC,SAAS,IAAI,OAAO,EAAE,KAAK,EAAC,OAAO,EAAC,MAAM,EAAE,EAAC,SAAS,EAAE,YAAY,EAAC,IACnJ,YAAY,CACP;YACT,gBAAgB,CACJ,CACpB,CACC,CACJ,CACT,CAAC;AACN,CAAC,CAAC,CAAC"}
|
package/core/Form/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Item } from "./Item";
|
|
3
|
-
import type { PickOptional } from "../../internal/type";
|
|
4
2
|
import type { FormErrorDisplayMode } from "./context";
|
|
5
3
|
import "./index.less";
|
|
6
4
|
export type { Props as FormItemProps, FormValidator } from "./Item";
|
|
5
|
+
export interface FormHandler {
|
|
6
|
+
triggerSubmit: () => Promise<boolean>;
|
|
7
|
+
}
|
|
7
8
|
export interface Props {
|
|
8
9
|
children: React.ReactNode;
|
|
9
10
|
id?: string;
|
|
@@ -20,18 +21,6 @@ export interface Props {
|
|
|
20
21
|
buttonRenderer?: ((submitButton: React.ReactElement, isValidating: boolean, loading?: boolean) => React.ReactElement) | null;
|
|
21
22
|
allowBrowserAutoComplete?: boolean;
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
export declare class Form extends React.PureComponent<Props, State> {
|
|
27
|
-
static displayName: string;
|
|
28
|
-
static defaultProps: PickOptional<Props>;
|
|
29
|
-
static Item: typeof Item;
|
|
30
|
-
private readonly validationContext;
|
|
31
|
-
private validators;
|
|
32
|
-
constructor(props: Props);
|
|
33
|
-
triggerSubmit: () => Promise<boolean>;
|
|
34
|
-
onSubmit: (event: React.FormEvent) => Promise<void>;
|
|
35
|
-
renderSubmitButton(): React.JSX.Element | null;
|
|
36
|
-
render(): React.JSX.Element;
|
|
37
|
-
}
|
|
24
|
+
export declare const Form: React.ForwardRefExoticComponent<Props & React.RefAttributes<FormHandler>> & {
|
|
25
|
+
Item: (props: import("./Item").Props) => React.JSX.Element;
|
|
26
|
+
};
|
package/core/Form/index.js
CHANGED
|
@@ -5,37 +5,30 @@ import { FormValidationContext } from "./context";
|
|
|
5
5
|
import { i18n } from "../../internal/i18n/core";
|
|
6
6
|
import { Item } from "./Item";
|
|
7
7
|
import "./index.less";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
import { ReactUtil } from "../../util/ReactUtil";
|
|
9
|
+
export const Form = ReactUtil.compound("Form", { Item }, React.forwardRef((props, forwardRef) => {
|
|
10
|
+
const { children, id, className, style, layout = "horizontal", allowBrowserAutoComplete, loading, buttonRenderer: defaultButtonRenderer, buttonStyle, buttonText, buttonIcon, buttonDisabled, onFinish, errorDisplayMode = { type: "extra" }, } = props;
|
|
11
|
+
const [isValidating, setIsValidating] = React.useState(false);
|
|
12
|
+
const [validators, setValidators] = React.useState([]);
|
|
13
|
+
const registerValidator = React.useCallback((validator) => setValidators(prev => [...prev, validator]), []);
|
|
14
|
+
const unregisterValidator = React.useCallback((validator) => setValidators(prev => prev.filter(v => v !== validator)), []);
|
|
15
|
+
const validationContext = {
|
|
16
|
+
registerValidator,
|
|
17
|
+
unregisterValidator,
|
|
18
|
+
errorDisplayMode: () => errorDisplayMode,
|
|
13
19
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
registerValidator: validator => this.validators.push(validator),
|
|
24
|
-
unregisterValidator: validator => {
|
|
25
|
-
const index = this.validators.indexOf(validator);
|
|
26
|
-
if (index >= 0) {
|
|
27
|
-
this.validators.splice(index, 1);
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
errorDisplayMode: () => this.props.errorDisplayMode,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
// Exposed for outer ref use, not recommended
|
|
34
|
-
triggerSubmit = async () => {
|
|
35
|
-
const { onFinish } = this.props;
|
|
20
|
+
React.useImperativeHandle(forwardRef, () => ({
|
|
21
|
+
triggerSubmit,
|
|
22
|
+
}));
|
|
23
|
+
const onSubmit = async (event) => {
|
|
24
|
+
event.preventDefault();
|
|
25
|
+
event.stopPropagation();
|
|
26
|
+
await triggerSubmit();
|
|
27
|
+
};
|
|
28
|
+
const triggerSubmit = async () => {
|
|
36
29
|
try {
|
|
37
|
-
|
|
38
|
-
const validatorResults = await Promise.all(
|
|
30
|
+
setIsValidating(true);
|
|
31
|
+
const validatorResults = await Promise.all(validators.map(_ => _()));
|
|
39
32
|
if (validatorResults.every(_ => _)) {
|
|
40
33
|
// Also true even if validatorResults is []
|
|
41
34
|
onFinish?.();
|
|
@@ -44,27 +37,17 @@ export class Form extends React.PureComponent {
|
|
|
44
37
|
return false;
|
|
45
38
|
}
|
|
46
39
|
finally {
|
|
47
|
-
|
|
40
|
+
setIsValidating(false);
|
|
48
41
|
}
|
|
49
42
|
};
|
|
50
|
-
|
|
51
|
-
event.preventDefault();
|
|
52
|
-
event.stopPropagation();
|
|
53
|
-
await this.triggerSubmit();
|
|
54
|
-
};
|
|
55
|
-
renderSubmitButton() {
|
|
56
|
-
const { loading, buttonRenderer: defaultButtonRenderer, buttonStyle, buttonText, buttonIcon, buttonDisabled } = this.props;
|
|
57
|
-
const { isValidating } = this.state;
|
|
43
|
+
const renderSubmitButton = () => {
|
|
58
44
|
const buttonRenderer = defaultButtonRenderer === undefined ? (submitButton) => submitButton : defaultButtonRenderer;
|
|
59
45
|
const t = i18n();
|
|
60
46
|
const submitButton = (React.createElement(Button, { className: "g-form-submit-button", htmlType: "submit", type: "primary", key: "submitButton", style: buttonStyle, loading: isValidating || loading, icon: buttonIcon, disabled: buttonDisabled || isValidating || loading }, buttonText || t.submit));
|
|
61
47
|
return buttonRenderer !== null ? React.createElement(Form.Item, { className: "g-form-submit-form-item" }, buttonRenderer(submitButton, isValidating, loading)) : null;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
this.renderSubmitButton()));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
48
|
+
};
|
|
49
|
+
return (React.createElement("form", { autoComplete: allowBrowserAutoComplete ? undefined : "off", id: id, className: classNames("g-form", `g-form-${layout}`, className), style: style, onSubmit: onSubmit },
|
|
50
|
+
React.createElement(FormValidationContext.Provider, { value: validationContext }, children),
|
|
51
|
+
renderSubmitButton()));
|
|
52
|
+
}));
|
|
70
53
|
//# sourceMappingURL=index.js.map
|
package/core/Form/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/Form/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AACjC,OAAO,EAAC,qBAAqB,EAAC,MAAM,WAAW,CAAC;AAChD,OAAO,EAAC,IAAI,EAAC,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/Form/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AACjC,OAAO,EAAC,qBAAqB,EAAC,MAAM,WAAW,CAAC;AAChD,OAAO,EAAC,IAAI,EAAC,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAE5B,OAAO,cAAc,CAAC;AACtB,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAyB/C,MAAM,CAAC,MAAM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,KAAK,IAAI,CAAC,CAAC,CAAC,oBAAC,IAAI,CAAC,IAAI,IAAC,SAAS,EAAC,yBAAyB,IAAE,cAAc,CAAC,YAAY,EAAE,YAAY,EAAE,OAAO,CAAC,CAAa,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7J,CAAC,CAAC;IAEF,OAAO,CACH,8BAAM,YAAY,EAAE,wBAAwB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,QAAQ,EAAE,UAAU,MAAM,EAAE,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ;QACtK,oBAAC,qBAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,iBAAiB,IAAG,QAAQ,CAAkC;QACpG,kBAAkB,EAAE,CAClB,CACV,CAAC;AACN,CAAC,CAAC,CACL,CAAC"}
|
package/core/Form/index.less
CHANGED
package/core/Grid/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const Grid:
|
|
1
|
+
export declare const Grid: {
|
|
2
2
|
Row: import("react").ForwardRefExoticComponent<import("antd").RowProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
3
3
|
Column: import("react").ForwardRefExoticComponent<import("antd").ColProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
4
|
-
}
|
|
4
|
+
};
|
package/core/Grid/index.js
CHANGED
package/core/Grid/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/Grid/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,GAAG,EAAC,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/Grid/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,GAAG,EAAC,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAE/C,MAAM,CAAC,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE;IAC1C,GAAG;IACH,MAAM,EAAE,GAAG;CACd,CAAC,CAAC"}
|
|
@@ -4,8 +4,5 @@ interface Props {
|
|
|
4
4
|
html: string;
|
|
5
5
|
className?: string;
|
|
6
6
|
}
|
|
7
|
-
export declare
|
|
8
|
-
static displayName: string;
|
|
9
|
-
render(): React.JSX.Element;
|
|
10
|
-
}
|
|
7
|
+
export declare const HTMLContent: ({ html, className }: Props) => React.JSX.Element;
|
|
11
8
|
export {};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { classNames } from "../../util/ClassNames";
|
|
3
|
+
import { ReactUtil } from "../../util/ReactUtil";
|
|
3
4
|
import "./index.less";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const { html, className } = this.props;
|
|
8
|
-
return React.createElement("div", { className: classNames("g-html-content", className), dangerouslySetInnerHTML: { __html: html } });
|
|
9
|
-
}
|
|
10
|
-
}
|
|
5
|
+
export const HTMLContent = ReactUtil.memo("HTMLContent", ({ html, className }) => {
|
|
6
|
+
return React.createElement("div", { className: classNames("g-html-content", className), dangerouslySetInnerHTML: { __html: html } });
|
|
7
|
+
});
|
|
11
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/HTMLContent/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/HTMLContent/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAC/C,OAAO,cAAc,CAAC;AAOtB,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,EAAC,IAAI,EAAE,SAAS,EAAQ,EAAE,EAAE;IAClF,OAAO,6BAAK,SAAS,EAAE,UAAU,CAAC,gBAAgB,EAAE,SAAS,CAAC,EAAE,uBAAuB,EAAE,EAAC,MAAM,EAAE,IAAI,EAAC,GAAI,CAAC;AAChH,CAAC,CAAC,CAAC"}
|
package/core/Image/index.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import type { ImageProps } from "antd/es/image";
|
|
2
|
-
import AntImage from "antd/es/image";
|
|
3
2
|
import React from "react";
|
|
4
3
|
export interface Props extends ImageProps {
|
|
5
4
|
}
|
|
6
|
-
export declare
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
render(): React.JSX.Element;
|
|
10
|
-
}
|
|
5
|
+
export declare const Image: ((props: Props) => React.JSX.Element) & {
|
|
6
|
+
PreviewGroup: React.FC<import("antd/es/image/PreviewGroup").PreviewGroupProps>;
|
|
7
|
+
};
|
package/core/Image/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import AntImage from "antd/es/image";
|
|
2
2
|
import React from "react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
3
|
+
import { ReactUtil } from "../../util/ReactUtil";
|
|
4
|
+
export const Image = ReactUtil.compound("Image", {
|
|
5
|
+
PreviewGroup: AntImage.PreviewGroup,
|
|
6
|
+
}, (props) => {
|
|
7
|
+
return React.createElement(AntImage, { ...props });
|
|
8
|
+
});
|
|
10
9
|
//# sourceMappingURL=index.js.map
|
package/core/Image/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/Image/index.tsx"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/Image/index.tsx"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAI/C,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CACnC,OAAO,EACP;IACI,YAAY,EAAE,QAAQ,CAAC,YAAY;CACtC,EACD,CAAC,KAAY,EAAE,EAAE;IACb,OAAO,oBAAC,QAAQ,OAAK,KAAK,GAAI,CAAC;AACnC,CAAC,CACJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { UploaderProps
|
|
2
|
+
import type { UploaderProps } from "../../util/UploadUtil/type";
|
|
3
3
|
import "./index.less";
|
|
4
4
|
export interface Props<SuccessResponseType, ErrorResponseType> extends UploaderProps<SuccessResponseType, ErrorResponseType> {
|
|
5
5
|
imageURL: string | null;
|
|
@@ -12,13 +12,4 @@ export interface Props<SuccessResponseType, ErrorResponseType> extends UploaderP
|
|
|
12
12
|
className?: string;
|
|
13
13
|
style?: React.CSSProperties;
|
|
14
14
|
}
|
|
15
|
-
export declare
|
|
16
|
-
static displayName: string;
|
|
17
|
-
openPreviewModal: (e: React.MouseEvent) => Promise<void>;
|
|
18
|
-
removeImage: (e: React.MouseEvent) => Promise<void>;
|
|
19
|
-
beforeUpload: (file: File) => boolean;
|
|
20
|
-
preventUploadBehavior: (e: React.MouseEvent) => void;
|
|
21
|
-
onUploadSuccess: (logEntry: UploadSuccessLogEntry, response: SuccessResponseType) => void;
|
|
22
|
-
renderActionIcon: (name: string, icon: React.ReactElement) => React.JSX.Element;
|
|
23
|
-
render(): React.JSX.Element;
|
|
24
|
-
}
|
|
15
|
+
export declare const ImageUploader: <Res, Err>(props: Props<Res, Err>) => React.JSX.Element;
|
|
@@ -8,53 +8,45 @@ import { MediaUtil } from "../../util/MediaUtil";
|
|
|
8
8
|
import { i18n } from "../../internal/i18n/core";
|
|
9
9
|
import { Uploader } from "../../core/Uploader";
|
|
10
10
|
import { Tooltip } from "../../core/Tooltip";
|
|
11
|
+
import { ReactUtil } from "../../util/ReactUtil";
|
|
11
12
|
import "./index.less";
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
export const ImageUploader = ReactUtil.memo("ImageUploader", (props) => {
|
|
14
|
+
const { uploadURL, formField, className, style, imageURL, disabled, width, height, onRemove, onUploadFailure, fileSizeLimitMB, onChange, onUploadSuccess } = props;
|
|
15
|
+
const t = i18n();
|
|
16
|
+
const openPreviewModal = async (e) => {
|
|
15
17
|
e.stopPropagation();
|
|
16
|
-
|
|
17
|
-
if (imageURL) {
|
|
18
|
+
if (imageURL)
|
|
18
19
|
await MediaUtil.openImage(imageURL);
|
|
19
|
-
}
|
|
20
20
|
};
|
|
21
|
-
removeImage = async (e) => {
|
|
21
|
+
const removeImage = async (e) => {
|
|
22
22
|
e.stopPropagation();
|
|
23
|
-
const { onRemove } = this.props;
|
|
24
|
-
const t = i18n();
|
|
25
23
|
if (await ModalUtil.confirm(t.confirmImageRemoval)) {
|
|
26
24
|
onRemove?.();
|
|
27
25
|
}
|
|
28
26
|
};
|
|
29
|
-
beforeUpload = (file) => {
|
|
30
|
-
const { fileSizeLimitMB } = this.props;
|
|
27
|
+
const beforeUpload = (file) => {
|
|
31
28
|
if (fileSizeLimitMB && file.size > 1024 * 1024 * fileSizeLimitMB) {
|
|
32
29
|
return false;
|
|
33
30
|
}
|
|
34
31
|
return true;
|
|
35
32
|
};
|
|
36
|
-
preventUploadBehavior = (e) => {
|
|
33
|
+
const preventUploadBehavior = (e) => {
|
|
37
34
|
if (e.target === e.currentTarget) {
|
|
38
35
|
// Only trigger for clicking "Upload" icon
|
|
39
36
|
e.stopPropagation();
|
|
40
37
|
}
|
|
41
38
|
};
|
|
42
|
-
|
|
43
|
-
const { onChange, onUploadSuccess } = this.props;
|
|
39
|
+
const onAntUploadSuccess = (logEntry, response) => {
|
|
44
40
|
onChange(response);
|
|
45
41
|
onUploadSuccess?.(logEntry, response);
|
|
46
42
|
};
|
|
47
|
-
renderActionIcon = (name, icon) => {
|
|
43
|
+
const renderActionIcon = (name, icon) => {
|
|
48
44
|
return (React.createElement(Tooltip, { title: name, childContainerProps: { className: "action" } }, icon));
|
|
49
45
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
React.createElement(
|
|
55
|
-
|
|
56
|
-
!disabled && this.renderActionIcon(t.upload, React.createElement(CloudUploadOutlined, null)),
|
|
57
|
-
!disabled && onRemove && this.renderActionIcon(t.delete, React.createElement(DeleteOutlined, { onClick: this.removeImage }))))) : (t.uploadHint)));
|
|
58
|
-
}
|
|
59
|
-
}
|
|
46
|
+
return (React.createElement(Uploader, { accept: "image/*", formField: formField, uploadURL: uploadURL, onUploadFailure: onUploadFailure, onUploadSuccess: onAntUploadSuccess, style: { ...style, width, height }, className: classNames("g-image-uploader", className), disabled: disabled, beforeUpload: beforeUpload }, imageURL ? (React.createElement("div", { className: "image-container", style: { backgroundImage: `url(${imageURL})`, height } },
|
|
47
|
+
React.createElement("div", { className: "overlay", onClick: preventUploadBehavior },
|
|
48
|
+
renderActionIcon(t.preview, React.createElement(EyeOutlined, { onClick: openPreviewModal })),
|
|
49
|
+
!disabled && renderActionIcon(t.upload, React.createElement(CloudUploadOutlined, null)),
|
|
50
|
+
!disabled && onRemove && renderActionIcon(t.delete, React.createElement(DeleteOutlined, { onClick: removeImage }))))) : (t.uploadHint)));
|
|
51
|
+
});
|
|
60
52
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/ImageUploader/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,mBAAmB,MAAM,uCAAuC,CAAC;AACxE,OAAO,cAAc,MAAM,kCAAkC,CAAC;AAC9D,OAAO,WAAW,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAC,IAAI,EAAC,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAC3C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/ImageUploader/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,mBAAmB,MAAM,uCAAuC,CAAC;AACxE,OAAO,cAAc,MAAM,kCAAkC,CAAC;AAC9D,OAAO,WAAW,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAC,IAAI,EAAC,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAC/C,OAAO,cAAc,CAAC;AActB,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC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|
package/core/Input/index.d.ts
CHANGED
|
@@ -22,22 +22,16 @@ export interface Props extends Omit<InputProps, ExcludedAntInputKeys>, Controlle
|
|
|
22
22
|
focus?: FocusType;
|
|
23
23
|
inputRef?: React.RefObject<InputRef | null>;
|
|
24
24
|
}
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
private handleClick;
|
|
38
|
-
componentDidMount(): void;
|
|
39
|
-
blur: () => void | undefined;
|
|
40
|
-
focus: (focusType?: FocusType) => void | undefined;
|
|
41
|
-
render(): React.JSX.Element;
|
|
42
|
-
}
|
|
25
|
+
export interface InputHandler {
|
|
26
|
+
blur: () => void;
|
|
27
|
+
focus: (focusType?: FocusType) => void;
|
|
28
|
+
}
|
|
29
|
+
export declare const Input: React.ForwardRefExoticComponent<Props & React.RefAttributes<InputHandler>> & {
|
|
30
|
+
Readonly: (props: InputReadonlyProps) => React.JSX.Element;
|
|
31
|
+
Search: ({ onChange, ...rest }: InputSearchProps) => React.JSX.Element;
|
|
32
|
+
TextArea: ({ onChange, ...rest }: InputTextAreaProps) => React.JSX.Element;
|
|
33
|
+
Password: ({ onChange, ...rest }: InputPasswordProps) => React.JSX.Element;
|
|
34
|
+
Nullable: ({ value, onChange, ...rest }: InputNullableProps) => React.JSX.Element;
|
|
35
|
+
NullableTextArea: ({ value, onChange, ...rest }: InputNullableTextAreaProps) => React.JSX.Element;
|
|
36
|
+
};
|
|
43
37
|
export {};
|
package/core/Input/index.js
CHANGED
|
@@ -1,50 +1,46 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import AntInput from "antd/es/input";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
3
|
+
import { ReactUtil } from "../../util/ReactUtil";
|
|
4
|
+
import { useDidMountEffect } from "../../hooks/useDidMountEffect";
|
|
5
|
+
const handleInputChange = (e, onValueChange, autoTrim) => {
|
|
6
|
+
if (autoTrim) {
|
|
7
|
+
e.target.value = e.target.value.trim();
|
|
8
|
+
}
|
|
9
|
+
onValueChange(e.target.value);
|
|
10
|
+
};
|
|
11
|
+
export const Input = ReactUtil.compound("Input", {
|
|
12
|
+
Readonly: (props) => React.createElement(AntInput, { onChange: () => { }, readOnly: true, disabled: true, ...props }),
|
|
13
|
+
Search: ({ onChange, ...rest }) => React.createElement(AntInput.Search, { onChange: e => handleInputChange(e, onChange), ...rest }),
|
|
14
|
+
TextArea: ({ onChange, ...rest }) => React.createElement(AntInput.TextArea, { onChange: e => handleInputChange(e, onChange), ...rest }),
|
|
15
|
+
Password: ({ onChange, ...rest }) => React.createElement(AntInput.Password, { onChange: e => handleInputChange(e, onChange), ...rest }),
|
|
16
|
+
Nullable: ({ value, onChange, ...rest }) => React.createElement(Input, { value: value || "", onChange: value => onChange(value.trim() ? value : null), ...rest }),
|
|
17
|
+
NullableTextArea: ({ value, onChange, ...rest }) => React.createElement(Input.TextArea, { value: value || "", onChange: value => onChange(value.trim() ? value : null), ...rest }),
|
|
18
|
+
}, React.forwardRef((props, forwardRef) => {
|
|
19
|
+
const { onChange, autoFocus, autoTrim, inputRef, focus: focusProp, onClick, ...restProps } = props;
|
|
20
|
+
const antInputRef = React.useRef(null);
|
|
21
|
+
const ref = inputRef ?? antInputRef;
|
|
22
|
+
const createFocusOptions = (focusType) => {
|
|
23
|
+
if (!focusType)
|
|
22
24
|
return undefined;
|
|
23
|
-
if (
|
|
25
|
+
if (focusType === "prevent-scroll") {
|
|
24
26
|
return { preventScroll: true };
|
|
25
27
|
}
|
|
26
28
|
else {
|
|
27
|
-
return { cursor:
|
|
29
|
+
return { cursor: focusType === "cursor-at-start" ? "start" : focusType === "cursor-at-last" ? "end" : "all" };
|
|
28
30
|
}
|
|
29
|
-
}
|
|
30
|
-
handleClick = event => {
|
|
31
|
-
this.getRef().current?.focus(this.createFocusOptions());
|
|
32
|
-
this.props.onClick?.(event);
|
|
33
31
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
}
|
|
32
|
+
React.useImperativeHandle(forwardRef, () => ({
|
|
33
|
+
blur: () => ref.current?.blur(),
|
|
34
|
+
focus: (focusType) => ref.current?.focus(createFocusOptions(focusType || focusProp)),
|
|
35
|
+
}));
|
|
36
|
+
useDidMountEffect(() => {
|
|
37
|
+
if (autoFocus)
|
|
38
|
+
ref.current?.focus(createFocusOptions(focusProp));
|
|
39
|
+
});
|
|
40
|
+
const handleClick = event => {
|
|
41
|
+
ref.current?.focus(createFocusOptions(focusProp));
|
|
42
|
+
onClick?.(event);
|
|
43
|
+
};
|
|
44
|
+
return React.createElement(AntInput, { ...restProps, ref: inputRef || antInputRef, onClick: handleClick, onChange: e => handleInputChange(e, onChange, autoTrim) });
|
|
45
|
+
}));
|
|
50
46
|
//# sourceMappingURL=index.js.map
|