@antscorp/antsomi-ui 1.3.3-beta.73 → 1.3.3-beta.74
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/es/components/atoms/Slider/index.js +8 -3
- package/es/components/molecules/DatePicker/components/AdvancedPicker/AdvancedPicker.js +2 -2
- package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.d.ts +2 -1
- package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.js +21 -9
- package/es/components/molecules/FontSetting/index.js +1 -1
- package/package.json +7 -3
|
@@ -9,15 +9,20 @@ export const Slider = memo(props => {
|
|
|
9
9
|
const { range, value, min = 0, max = 0, className, tooltipVisible } = props;
|
|
10
10
|
const isNegative = useMemo(() => !!(!range && min < 0), [range, min]);
|
|
11
11
|
const calculateWidth = useMemo(() => ((value || 0) * 100) / (Math.abs(max) + Math.abs(min) || 1), [min, max, value]);
|
|
12
|
-
const restProps = tooltipVisible === 'default' ? omit(props, ['tooltipVisible']) : props;
|
|
12
|
+
// const restProps = tooltipVisible === 'default' ? omit(props, ['tooltipVisible']) : props;
|
|
13
|
+
const restProps = omit(props, ['tooltipVisible']);
|
|
13
14
|
if (isNegative) {
|
|
14
15
|
return (React.createElement(SliderWrapper, { isNegative: true, width: calculateWidth, className: className },
|
|
15
|
-
React.createElement(AntdSlider, Object.assign({}, omit(restProps, ['marks', 'className']), {
|
|
16
|
+
React.createElement(AntdSlider, Object.assign({}, omit(restProps, ['marks', 'className']), { tooltip: tooltipVisible !== 'default' && {
|
|
17
|
+
open: tooltipVisible,
|
|
18
|
+
}, marks: {
|
|
16
19
|
0: ' ',
|
|
17
20
|
} }))));
|
|
18
21
|
}
|
|
19
22
|
return (React.createElement(SliderWrapper, { className: className },
|
|
20
|
-
React.createElement(AntdSlider, Object.assign({}, restProps
|
|
23
|
+
React.createElement(AntdSlider, Object.assign({}, restProps, { tooltip: tooltipVisible !== 'default' && {
|
|
24
|
+
open: tooltipVisible,
|
|
25
|
+
} }))));
|
|
21
26
|
});
|
|
22
27
|
Slider.defaultProps = {
|
|
23
28
|
tooltipVisible: false,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable react/no-unused-prop-types */
|
|
2
2
|
// Libraries
|
|
3
|
-
import React, { useMemo, useState } from 'react';
|
|
3
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
4
4
|
import { Tooltip, theme } from 'antd';
|
|
5
5
|
import dayjs from 'dayjs';
|
|
6
6
|
import clsx from 'clsx';
|
|
@@ -169,7 +169,7 @@ export const AdvancedPicker = props => {
|
|
|
169
169
|
boxShadow: token.boxShadowSecondary,
|
|
170
170
|
};
|
|
171
171
|
// Effects
|
|
172
|
-
|
|
172
|
+
useEffect(() => {
|
|
173
173
|
try {
|
|
174
174
|
if (isOpen) {
|
|
175
175
|
setState(state => (Object.assign(Object.assign({}, state), { option: state.optionSelected, date: state.dateDisplay })));
|
package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { TShowCalculationTypeCondition } from '../AdvancedPicker/types';
|
|
2
|
+
import { TShowCalculationTypeCondition, ValueTypes } from '../AdvancedPicker/types';
|
|
3
3
|
import { TDateConfig, TOnChangePayload, TTimeRange } from './types';
|
|
4
4
|
export interface AdvancedRangePickerProps {
|
|
5
|
+
valueType?: ValueTypes;
|
|
5
6
|
disabled?: boolean;
|
|
6
7
|
showCalculationTypeCondition?: TShowCalculationTypeCondition;
|
|
7
8
|
startDateConfig?: TDateConfig;
|
package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// Libraries
|
|
2
2
|
import dayjs from 'dayjs';
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { useState } from 'react';
|
|
4
4
|
import omit from 'lodash/omit';
|
|
5
5
|
import isEqual from 'react-fast-compare';
|
|
6
|
+
import { useDeepCompareEffect } from '../../../../../hooks';
|
|
6
7
|
// Atoms
|
|
7
8
|
import { Space } from '../../../../atoms';
|
|
8
9
|
// Molecules
|
|
@@ -16,20 +17,31 @@ import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
|
|
|
16
17
|
import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
|
|
17
18
|
const PATH = '@antscorp/antsomi-ui/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.tsx';
|
|
18
19
|
export const AdvancedRangePicker = props => {
|
|
19
|
-
// const { t } = useTranslation();
|
|
20
20
|
const { t } = i18nInstance;
|
|
21
21
|
// Props
|
|
22
|
-
const { timeRange, errorMessage, showLabel, startDateConfig, endDateConfig, showTime, showCalculationTypeCondition, disabled, onChange, } = props;
|
|
22
|
+
const { valueType, timeRange, errorMessage, showLabel, startDateConfig, endDateConfig, showTime, showCalculationTypeCondition, disabled, onChange, } = props;
|
|
23
|
+
const [timeRangeState, setTimeRange] = useState(timeRange);
|
|
24
|
+
useDeepCompareEffect(() => {
|
|
25
|
+
if (typeof onChange === 'function') {
|
|
26
|
+
onChange({
|
|
27
|
+
timeRange: timeRangeState,
|
|
28
|
+
mode: 'system',
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}, [timeRangeState]);
|
|
23
32
|
// Handles
|
|
24
33
|
const onUpdateTimeRange = (key, params, mode = 'user') => {
|
|
25
34
|
try {
|
|
26
35
|
if (typeof onChange === 'function') {
|
|
27
36
|
const newTimeRange = Object.assign(Object.assign({}, timeRange), { [key]: Object.assign(Object.assign({}, timeRange[key]), params) });
|
|
28
37
|
if (!isEqual(newTimeRange, timeRange)) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
setTimeRange(prev => (Object.assign(Object.assign({}, prev), { [key]: Object.assign(Object.assign({}, timeRange[key]), params) })));
|
|
39
|
+
if (mode === 'user') {
|
|
40
|
+
onChange({
|
|
41
|
+
timeRange: newTimeRange,
|
|
42
|
+
mode,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
33
45
|
}
|
|
34
46
|
}
|
|
35
47
|
}
|
|
@@ -43,8 +55,8 @@ export const AdvancedRangePicker = props => {
|
|
|
43
55
|
}
|
|
44
56
|
};
|
|
45
57
|
return (React.createElement(Space, { size: 20 },
|
|
46
|
-
React.createElement(AdvancedPicker, { disabled: disabled, label: showLabel ? t(translations.datePicker.startDate) || '' : '', date: timeRange.startDate.date, option: omit(timeRange.startDate, 'date'), operatorKey: "between", type: "startDate", format: ADVANCED_RANGE_PICKER_FORMAT.startDate, errorMessage: errorMessage, disableAfterDate: timeRange.endDate.date, showTime: showTime, calculationTypeKeysShow: startDateConfig === null || startDateConfig === void 0 ? void 0 : startDateConfig.calculationTypeKeysShow, showCalculationTypeCondition: showCalculationTypeCondition, onUpdatedNewDate: date => onUpdateTimeRange('startDate', { date }, 'system'), onApply: ({ date, option }) => onUpdateTimeRange('startDate', Object.assign({ date }, option), 'user') }),
|
|
47
|
-
React.createElement(AdvancedPicker, { disabled: disabled, label: showLabel ? t(translations.datePicker.endDate) || '' : '', date: timeRange.endDate.date, option: omit(timeRange.endDate, 'date'), operatorKey: "between", type: "endDate", format: ADVANCED_RANGE_PICKER_FORMAT.endDate, errorMessage: errorMessage, showTime: showTime, calculationTypeKeysShow: endDateConfig === null || endDateConfig === void 0 ? void 0 : endDateConfig.calculationTypeKeysShow, showCalculationTypeCondition: showCalculationTypeCondition, onUpdatedNewDate: date => onUpdateTimeRange('endDate', { date }, 'system'), onApply: ({ date, option }) => onUpdateTimeRange('endDate', Object.assign({ date }, option), 'user') })));
|
|
58
|
+
React.createElement(AdvancedPicker, { valueType: valueType, disabled: disabled, label: showLabel ? t(translations.datePicker.startDate) || '' : '', date: timeRange.startDate.date, option: omit(timeRange.startDate, 'date'), operatorKey: "between", type: "startDate", format: ADVANCED_RANGE_PICKER_FORMAT.startDate, errorMessage: errorMessage, disableAfterDate: timeRange.endDate.date, showTime: showTime, calculationTypeKeysShow: startDateConfig === null || startDateConfig === void 0 ? void 0 : startDateConfig.calculationTypeKeysShow, showCalculationTypeCondition: showCalculationTypeCondition, onUpdatedNewDate: date => onUpdateTimeRange('startDate', { date }, 'system'), onApply: ({ date, option }) => onUpdateTimeRange('startDate', Object.assign({ date }, option), 'user') }),
|
|
59
|
+
React.createElement(AdvancedPicker, { valueType: valueType, disabled: disabled, label: showLabel ? t(translations.datePicker.endDate) || '' : '', date: timeRange.endDate.date, option: omit(timeRange.endDate, 'date'), operatorKey: "between", type: "endDate", format: ADVANCED_RANGE_PICKER_FORMAT.endDate, errorMessage: errorMessage, showTime: showTime, calculationTypeKeysShow: endDateConfig === null || endDateConfig === void 0 ? void 0 : endDateConfig.calculationTypeKeysShow, showCalculationTypeCondition: showCalculationTypeCondition, onUpdatedNewDate: date => onUpdateTimeRange('endDate', { date }, 'system'), onApply: ({ date, option }) => onUpdateTimeRange('endDate', Object.assign({ date }, option), 'user') })));
|
|
48
60
|
};
|
|
49
61
|
AdvancedRangePicker.defaultProps = {
|
|
50
62
|
timeRange: {
|
|
@@ -37,7 +37,7 @@ export const FontSettingEdit = ({ settings, styles, showSettings, onChange, }) =
|
|
|
37
37
|
[settings]);
|
|
38
38
|
const filteredSetting = useMemo(() => {
|
|
39
39
|
if (!showSettings || (showSettings === null || showSettings === void 0 ? void 0 : showSettings.length) === 0) {
|
|
40
|
-
return Object.keys(settingMap).map(keySetting => settingMap[keySetting]);
|
|
40
|
+
return Object.keys(settingMap).map(keySetting => (React.createElement(React.Fragment, { key: keySetting }, settingMap[keySetting])));
|
|
41
41
|
}
|
|
42
42
|
return showSettings.map(keySetting => settingMap[keySetting]);
|
|
43
43
|
}, [showSettings, settingMap]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antscorp/antsomi-ui",
|
|
3
|
-
"version": "1.3.3-beta.
|
|
3
|
+
"version": "1.3.3-beta.74",
|
|
4
4
|
"description": "An enterprise-class UI design language and React UI library.",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"dist/*",
|
|
@@ -33,9 +33,11 @@
|
|
|
33
33
|
"serve-storybook": "serve storybook-static",
|
|
34
34
|
"version": "auto-changelog -p && git add CHANGELOG.md",
|
|
35
35
|
"test": "jest",
|
|
36
|
+
"test:clean": "rimraf coverage",
|
|
37
|
+
"test:update-snapshot": "jest -u",
|
|
36
38
|
"test:changed": "jest --onlyChanged",
|
|
37
39
|
"test:watch": "jest --watch",
|
|
38
|
-
"test:coverage": "jest --coverage",
|
|
40
|
+
"test:coverage": "yarn test:clean && yarn jest --coverage",
|
|
39
41
|
"ts-compile": "tsc -p tsconfig.esm.json",
|
|
40
42
|
"copy-files": "copyfiles -u 1 src/**/*.json src/**/*.svg src/**/*.scss src/**/*.png es"
|
|
41
43
|
},
|
|
@@ -88,7 +90,6 @@
|
|
|
88
90
|
"lodash": "^4.17.21",
|
|
89
91
|
"moment": "2.29.2",
|
|
90
92
|
"qs": "6.10.3",
|
|
91
|
-
"rc-picker": "^4.1.1",
|
|
92
93
|
"react-color": "2.19.3",
|
|
93
94
|
"react-draggable": "^4.4.5",
|
|
94
95
|
"react-markdown": "^8.0.7",
|
|
@@ -108,6 +109,8 @@
|
|
|
108
109
|
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
|
|
109
110
|
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
|
|
110
111
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
112
|
+
"@babel/plugin-syntax-jsx": "^7.23.3",
|
|
113
|
+
"@babel/plugin-transform-modules-commonjs": "^7.23.3",
|
|
111
114
|
"@babel/plugin-transform-react-jsx": "^7.23.4",
|
|
112
115
|
"@babel/plugin-transform-react-jsx-source": "^7.23.3",
|
|
113
116
|
"@babel/plugin-transform-runtime": "^7.23.6",
|
|
@@ -137,6 +140,7 @@
|
|
|
137
140
|
"@typescript-eslint/parser": "^5.55.0",
|
|
138
141
|
"@vitejs/plugin-react": "^3.1.0",
|
|
139
142
|
"auto-changelog": "^2.4.0",
|
|
143
|
+
"babel-jest": "^29.7.0",
|
|
140
144
|
"babel-loader": "^8.3.0",
|
|
141
145
|
"babel-plugin-import": "^1.13.8",
|
|
142
146
|
"babel-plugin-module-resolver": "^5.0.0",
|