@infomaximum/ui-kit 0.15.1 → 0.15.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/dist/components/InternalPicker/pickers/RangePicker/RangePicker.js +3 -2
- package/dist/components/InternalPicker/pickers/SinglePicker/SinglePicker.js +3 -2
- package/dist/components/InternalPicker/pickers/SinglePicker/SinglePicker.utils.d.ts +3 -4
- package/dist/components/InternalPicker/pickers/SinglePicker/SinglePicker.utils.js +15 -4
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ import { SwapRightOutlined } from "@infomaximum/icons";
|
|
|
7
7
|
import { getPopupStyle } from "../../styles/Popup.styles.js";
|
|
8
8
|
import { getRangeSelectorStyle } from "../../styles/RangeSelector.styles.js";
|
|
9
9
|
import dayjs from "dayjs";
|
|
10
|
-
import { getFormatByPicker, minDate, defaultProps } from "../SinglePicker/SinglePicker.utils.js";
|
|
10
|
+
import { getFormatByPicker, minDate, getAllowClearValue, defaultProps } from "../SinglePicker/SinglePicker.utils.js";
|
|
11
11
|
import { getRangePlaceholder } from "./RangePicker.utils.js";
|
|
12
12
|
import { FormItemContext } from "../../../Form/components/FormItem/contexts/FormItemContext.js";
|
|
13
13
|
import { useTheme } from "../../../../hooks/useTheme/useTheme.js";
|
|
@@ -21,6 +21,7 @@ const RangePickerComponent = forwardRef((props, ref) => {
|
|
|
21
21
|
components: componentsProp,
|
|
22
22
|
placeholder,
|
|
23
23
|
status: statusProp,
|
|
24
|
+
allowClear: allowClearProp,
|
|
24
25
|
...rest
|
|
25
26
|
} = props;
|
|
26
27
|
const theme = useTheme();
|
|
@@ -42,7 +43,7 @@ const RangePickerComponent = forwardRef((props, ref) => {
|
|
|
42
43
|
cx
|
|
43
44
|
}) => {
|
|
44
45
|
var _a;
|
|
45
|
-
return /* @__PURE__ */ jsx(RangePicker$1, { ref, locale, placeholder: getRangePlaceholder(locale, rest.picker, placeholder), separator: defaultSeparator, format: getFormatByPicker(rest.picker, Boolean(rest.showTime)), minDate, ...defaultProps, ...rest, components, prefixCls, className: cx(css(getRangeSelectorStyle(pickerTokens)(theme)), {
|
|
46
|
+
return /* @__PURE__ */ jsx(RangePicker$1, { ref, locale, placeholder: getRangePlaceholder(locale, rest.picker, placeholder), separator: defaultSeparator, format: getFormatByPicker(rest.picker, Boolean(rest.showTime)), minDate, allowClear: getAllowClearValue(allowClearProp), ...defaultProps, ...rest, components, prefixCls, className: cx(css(getRangeSelectorStyle(pickerTokens)(theme)), {
|
|
46
47
|
[`${prefixCls}-success-status`]: status === "success"
|
|
47
48
|
}, {
|
|
48
49
|
[`${prefixCls}-error-status`]: status === "error"
|
|
@@ -9,7 +9,7 @@ import "react-intersection-observer/test-utils";
|
|
|
9
9
|
import { getPopupStyle } from "../../styles/Popup.styles.js";
|
|
10
10
|
import { getSingleSelectorStyle } from "../../styles/SingleSelector.styles.js";
|
|
11
11
|
import dayjs from "dayjs";
|
|
12
|
-
import { getSinglePlaceholder, getFormatByPicker, minDate, defaultProps } from "./SinglePicker.utils.js";
|
|
12
|
+
import { getSinglePlaceholder, getFormatByPicker, minDate, getAllowClearValue, defaultProps } from "./SinglePicker.utils.js";
|
|
13
13
|
import { FormItemContext } from "../../../Form/components/FormItem/contexts/FormItemContext.js";
|
|
14
14
|
import { useTheme } from "../../../../hooks/useTheme/useTheme.js";
|
|
15
15
|
import { useConfig } from "../../../ConfigProvider/hooks/useConfig/useConfig.js";
|
|
@@ -21,6 +21,7 @@ const SinglePickerComponent = forwardRef((props, ref) => {
|
|
|
21
21
|
components: componentsProp,
|
|
22
22
|
placeholder,
|
|
23
23
|
status: statusProp,
|
|
24
|
+
allowClear: allowClearProp,
|
|
24
25
|
...rest
|
|
25
26
|
} = props;
|
|
26
27
|
const theme = useTheme();
|
|
@@ -42,7 +43,7 @@ const SinglePickerComponent = forwardRef((props, ref) => {
|
|
|
42
43
|
cx
|
|
43
44
|
}) => {
|
|
44
45
|
var _a;
|
|
45
|
-
return /* @__PURE__ */ jsx(Picker, { ref, locale, placeholder: getSinglePlaceholder(locale, rest.picker, placeholder), format: getFormatByPicker(rest.picker, Boolean(rest.showTime)), minDate, ...defaultProps, ...rest, components, prefixCls, className: cx(css(getSingleSelectorStyle(pickerTokens)(theme)), {
|
|
46
|
+
return /* @__PURE__ */ jsx(Picker, { ref, locale, placeholder: getSinglePlaceholder(locale, rest.picker, placeholder), format: getFormatByPicker(rest.picker, Boolean(rest.showTime)), minDate, allowClear: getAllowClearValue(allowClearProp), ...defaultProps, ...rest, components, prefixCls, className: cx(css(getSingleSelectorStyle(pickerTokens)(theme)), {
|
|
46
47
|
[`${prefixCls}-success-status`]: status === "success"
|
|
47
48
|
}, {
|
|
48
49
|
[`${prefixCls}-error-status`]: status === "error"
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Dayjs } from 'dayjs';
|
|
2
2
|
import { GenerateConfig } from 'rc-picker/lib/generate';
|
|
3
|
-
import { Locale } from 'rc-picker/lib/interface';
|
|
3
|
+
import { Locale, SharedPickerProps } from 'rc-picker/lib/interface';
|
|
4
4
|
import { SinglePickerProps } from './SinglePicker.types';
|
|
5
5
|
import { PickerLocale } from '../../config';
|
|
6
|
+
export declare const defaultAllowClearConfig: SharedPickerProps["allowClear"];
|
|
7
|
+
export declare const getAllowClearValue: (allowClearProp: SharedPickerProps["allowClear"]) => SharedPickerProps["allowClear"];
|
|
6
8
|
export declare const defaultProps: {
|
|
7
|
-
allowClear: {
|
|
8
|
-
clearIcon: import("@emotion/react/jsx-runtime").JSX.Element;
|
|
9
|
-
};
|
|
10
9
|
generateConfig: GenerateConfig<Dayjs>;
|
|
11
10
|
};
|
|
12
11
|
export declare const quarterFormats: Partial<Locale>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { CloseCircleFilled } from "@infomaximum/icons";
|
|
3
3
|
import dayjsGenerateConfig from "rc-picker/es/generate/dayjs.js";
|
|
4
|
-
import { upperFirst, isUndefined, isNull, isNumber } from "lodash-es";
|
|
4
|
+
import { upperFirst, isObject, isUndefined, isEmpty, isNull, isNumber } from "lodash-es";
|
|
5
5
|
import dayjs from "dayjs";
|
|
6
6
|
const fieldQuarterFormat = "Q-YYYY";
|
|
7
7
|
const cellQuarterFormat = "Q";
|
|
@@ -57,10 +57,19 @@ const generateConfig = {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
|
+
const defaultAllowClearConfig = {
|
|
61
|
+
clearIcon: /* @__PURE__ */ jsx(CloseCircleFilled, {})
|
|
62
|
+
};
|
|
63
|
+
const getAllowClearValue = (allowClearProp) => {
|
|
64
|
+
if (isObject(allowClearProp) && allowClearProp.clearIcon) {
|
|
65
|
+
return allowClearProp;
|
|
66
|
+
}
|
|
67
|
+
if (allowClearProp === true || isUndefined(allowClearProp) || isObject(allowClearProp) && (isEmpty(allowClearProp) || isUndefined(allowClearProp.clearIcon))) {
|
|
68
|
+
return defaultAllowClearConfig;
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
};
|
|
60
72
|
const defaultProps = {
|
|
61
|
-
allowClear: {
|
|
62
|
-
clearIcon: /* @__PURE__ */ jsx(CloseCircleFilled, {})
|
|
63
|
-
},
|
|
64
73
|
generateConfig
|
|
65
74
|
};
|
|
66
75
|
const defaultFormats = {
|
|
@@ -99,8 +108,10 @@ const getSinglePlaceholder = (locale, picker, placeholder) => {
|
|
|
99
108
|
};
|
|
100
109
|
const minDate = dayjs("1900-01-01");
|
|
101
110
|
export {
|
|
111
|
+
defaultAllowClearConfig,
|
|
102
112
|
defaultFormats,
|
|
103
113
|
defaultProps,
|
|
114
|
+
getAllowClearValue,
|
|
104
115
|
getFormatByPicker,
|
|
105
116
|
getSinglePlaceholder,
|
|
106
117
|
minDate
|