@antscorp/antsomi-ui 1.3.3-beta.82 → 1.3.3-beta.84
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/InputDynamic/InputDynamic.js +3 -2
- package/es/components/atoms/InputDynamic/types.d.ts +1 -0
- package/es/components/atoms/SlideBar/SlideBar.d.ts +31 -0
- package/es/components/atoms/SlideBar/SlideBar.js +272 -0
- package/es/components/atoms/SlideBar/constants.d.ts +10 -0
- package/es/components/atoms/SlideBar/constants.js +10 -0
- package/es/components/atoms/SlideBar/index.d.ts +1 -0
- package/es/components/atoms/SlideBar/index.js +1 -0
- package/es/components/atoms/SlideBar/styled.d.ts +20 -0
- package/es/components/atoms/SlideBar/styled.js +136 -0
- package/es/components/atoms/index.d.ts +1 -0
- package/es/components/atoms/index.js +1 -0
- package/es/components/common/ConfigProvider/ConfigProvider.js +5 -0
- package/es/components/molecules/DatePicker/components/AdvancedPicker/AdvancedPicker.d.ts +1 -0
- package/es/components/molecules/DatePicker/components/AdvancedPicker/AdvancedPicker.js +31 -23
- package/es/components/molecules/DatePicker/components/AdvancedPicker/utils.js +5 -0
- package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.d.ts +1 -0
- package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.js +3 -3
- package/es/locales/en/translation.json +6 -0
- package/es/locales/i18n.d.ts +6 -0
- package/es/locales/translations.d.ts +6 -0
- package/es/test.js +34 -4
- package/package.json +10 -8
|
@@ -27,6 +27,7 @@ const defaultProps = {
|
|
|
27
27
|
isViewMode: false,
|
|
28
28
|
isRealTime: true,
|
|
29
29
|
errors: [],
|
|
30
|
+
ms: 450,
|
|
30
31
|
canMultipleLine: false,
|
|
31
32
|
apiConfig: {
|
|
32
33
|
domain: 'https://sandbox-media-template.antsomi.com/cdp',
|
|
@@ -44,7 +45,7 @@ const defaultProps = {
|
|
|
44
45
|
addMessageToQueue: () => { },
|
|
45
46
|
};
|
|
46
47
|
export const InputDynamic = (props) => {
|
|
47
|
-
const { value, isViewMode, isRealTime, errors, disabledOpts, disabled, canMultipleLine, allowDynamicOptions, showIndex, showDisplayFormat, isShowCustomFunction, apiConfig, onError, onChange, addMessageToQueue, } = props;
|
|
48
|
+
const { value, isViewMode, isRealTime, ms, errors, disabledOpts, disabled, canMultipleLine, allowDynamicOptions, showIndex, showDisplayFormat, isShowCustomFunction, apiConfig, onError, onChange, addMessageToQueue, } = props;
|
|
48
49
|
// States
|
|
49
50
|
const [textValue, setTextValue] = useState(initialValue(value));
|
|
50
51
|
const [initSelectedProperties, setInitSelectedProperties] = useState({
|
|
@@ -251,7 +252,7 @@ export const InputDynamic = (props) => {
|
|
|
251
252
|
timerRef.current = setTimeout(() => {
|
|
252
253
|
caretPositionRef.current = CaretPositioning.saveSelection(personalizationInputRef.current);
|
|
253
254
|
onTriggerChange();
|
|
254
|
-
},
|
|
255
|
+
}, ms);
|
|
255
256
|
};
|
|
256
257
|
const handleKeyPress = (e) => {
|
|
257
258
|
if (isRealTime) {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { slideActionType } from './constants';
|
|
3
|
+
export type SlideBarOptionProps = {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
};
|
|
7
|
+
export type SlideBarLimitProps = {
|
|
8
|
+
max: number;
|
|
9
|
+
min: number;
|
|
10
|
+
};
|
|
11
|
+
export type ActionType = (typeof slideActionType)[keyof typeof slideActionType];
|
|
12
|
+
export type SlideBarState = {
|
|
13
|
+
cacheInfoClicked: SlideBarOptionProps;
|
|
14
|
+
disabledPrev: boolean;
|
|
15
|
+
disabledNext: boolean;
|
|
16
|
+
notiUpdateScroll: number;
|
|
17
|
+
};
|
|
18
|
+
export interface SlideBarProps {
|
|
19
|
+
isViewMode?: boolean;
|
|
20
|
+
isShowLabelSequentially?: boolean;
|
|
21
|
+
isShowAdd?: boolean;
|
|
22
|
+
isDragDisabled?: boolean;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
activeId: string;
|
|
25
|
+
prefix?: string;
|
|
26
|
+
options: SlideBarOptionProps[];
|
|
27
|
+
limit?: SlideBarLimitProps;
|
|
28
|
+
errors: any;
|
|
29
|
+
callback?: (type: ActionType, data?: SlideBarOptionProps | SlideBarOptionProps[]) => any;
|
|
30
|
+
}
|
|
31
|
+
export declare const SlideBar: FC<SlideBarProps>;
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import React, { useRef, useEffect, useState, useMemo } from 'react';
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
import { DragDropContext, Draggable, Droppable } from 'react-beautiful-dnd';
|
|
5
|
+
// Components
|
|
6
|
+
import { Icon } from '../Icon';
|
|
7
|
+
import { Popover } from '../Popover';
|
|
8
|
+
// Styled
|
|
9
|
+
import { ContainerSlideBar, MainContent, MenuItem, MenuList, SlideItem, SliderWrapper, SlideText, WrapperDisable, WrapperOverflow, } from './styled';
|
|
10
|
+
import { PlusCircleFilled } from '@ant-design/icons';
|
|
11
|
+
// Constants
|
|
12
|
+
import { THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
13
|
+
import { BTN_ADD_SIZE, slideActionType, WIDTH_SLIDE_ITEM } from './constants';
|
|
14
|
+
// Utils
|
|
15
|
+
import { getObjectPropSafely, handleError } from '@antscorp/antsomi-ui/es/utils';
|
|
16
|
+
// Locales
|
|
17
|
+
import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
|
|
18
|
+
import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
|
|
19
|
+
const getItemStyle = (isDragging, draggableStyle) => (Object.assign({
|
|
20
|
+
// some basic styles to make the items look a bit nicer
|
|
21
|
+
userSelect: 'none', borderLeft: isDragging ? '1px solid #e0e0e0' : 'none' }, draggableStyle));
|
|
22
|
+
const PATH = 'src/components/atoms/SlideBar/SlideBar.tsx';
|
|
23
|
+
export const SlideBar = props => {
|
|
24
|
+
var _a, _b, _c, _d;
|
|
25
|
+
const { isViewMode, isShowLabelSequentially, isDragDisabled, isShowAdd, disabled, prefix, options, activeId, limit, errors, callback, } = props;
|
|
26
|
+
// States
|
|
27
|
+
const [state, setState] = useState({
|
|
28
|
+
cacheInfoClicked: {
|
|
29
|
+
label: '',
|
|
30
|
+
value: '',
|
|
31
|
+
},
|
|
32
|
+
disabledPrev: true,
|
|
33
|
+
disabledNext: true,
|
|
34
|
+
notiUpdateScroll: 1,
|
|
35
|
+
});
|
|
36
|
+
// Refs
|
|
37
|
+
const wrapperOverflowRef = useRef(null);
|
|
38
|
+
const disabledAdd = useMemo(() => disabled || isViewMode || (limit && options.length >= (limit === null || limit === void 0 ? void 0 : limit.max)), [disabled, isViewMode, limit, options.length]);
|
|
39
|
+
const disabledDuplicate = useMemo(() => (limit && options.length >= (limit === null || limit === void 0 ? void 0 : limit.max)) || isViewMode || disabled, [disabled, isViewMode, limit, options.length]);
|
|
40
|
+
const disabledDelete = useMemo(() => (limit && options.length <= (limit === null || limit === void 0 ? void 0 : limit.min)) || isViewMode || disabled, [disabled, isViewMode, limit, options.length]);
|
|
41
|
+
// Locales
|
|
42
|
+
const { t } = i18nInstance;
|
|
43
|
+
const handleClick = (event, slideInfo) => {
|
|
44
|
+
event.stopPropagation();
|
|
45
|
+
setState(prev => (Object.assign(Object.assign({}, prev), { cacheInfoClicked: slideInfo })));
|
|
46
|
+
};
|
|
47
|
+
const reorder = (list, startIndex, endIndex) => {
|
|
48
|
+
const result = Array.from(list);
|
|
49
|
+
const [removed] = result.splice(startIndex, 1);
|
|
50
|
+
result.splice(endIndex, 0, removed);
|
|
51
|
+
return result;
|
|
52
|
+
};
|
|
53
|
+
const handleDragEnd = result => {
|
|
54
|
+
try {
|
|
55
|
+
// dropped outside the list
|
|
56
|
+
if (!result.destination) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const items = reorder(options, result.source.index, result.destination.index);
|
|
60
|
+
if (typeof callback === 'function') {
|
|
61
|
+
callback(slideActionType.RE_ORDERS, items);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
handleError(error, {
|
|
66
|
+
path: PATH,
|
|
67
|
+
name: 'handleDragEnd',
|
|
68
|
+
args: {
|
|
69
|
+
error,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
// eslint-disable-next-line no-console
|
|
73
|
+
console.log('error :>', error);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const handleActiveSlide = (e, slideInfo) => {
|
|
77
|
+
try {
|
|
78
|
+
e.stopPropagation();
|
|
79
|
+
if (typeof callback === 'function' && !_.isEmpty(slideInfo) && activeId !== slideInfo.value) {
|
|
80
|
+
callback(slideActionType.ACTIVE, slideInfo);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
handleError(error, {
|
|
85
|
+
path: PATH,
|
|
86
|
+
name: 'handleActiveSlide',
|
|
87
|
+
args: {
|
|
88
|
+
error,
|
|
89
|
+
slideInfo,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
// eslint-disable-next-line no-console
|
|
93
|
+
console.log(error);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const handleDuplicateSlide = (slideInfo) => {
|
|
97
|
+
try {
|
|
98
|
+
if (typeof callback === 'function' && !_.isEmpty(slideInfo)) {
|
|
99
|
+
callback(slideActionType.DUPLICATE, slideInfo);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
handleError(error, {
|
|
104
|
+
path: PATH,
|
|
105
|
+
name: 'handleDuplicateSlide',
|
|
106
|
+
args: {
|
|
107
|
+
error,
|
|
108
|
+
slideInfo,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
// eslint-disable-next-line no-console
|
|
112
|
+
console.log(error);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const handleDeleteSlide = (slideInfo) => {
|
|
116
|
+
try {
|
|
117
|
+
if (typeof callback === 'function' && !_.isEmpty(slideInfo)) {
|
|
118
|
+
callback(slideActionType.DELETE, slideInfo);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
handleError(error, {
|
|
123
|
+
path: PATH,
|
|
124
|
+
name: 'handleDeleteSlide',
|
|
125
|
+
args: {
|
|
126
|
+
error,
|
|
127
|
+
slideInfo,
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
// eslint-disable-next-line no-console
|
|
131
|
+
console.log(error);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const handleChangeScrollDirection = (type = '') => {
|
|
135
|
+
try {
|
|
136
|
+
if (_.isEmpty(wrapperOverflowRef.current))
|
|
137
|
+
return;
|
|
138
|
+
if (type === 'PREVIOUS') {
|
|
139
|
+
if (wrapperOverflowRef.current.scrollLeft < WIDTH_SLIDE_ITEM) {
|
|
140
|
+
wrapperOverflowRef.current.scrollLeft = 0;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
wrapperOverflowRef.current.scrollLeft -= WIDTH_SLIDE_ITEM;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
else if (type === 'NEXT') {
|
|
147
|
+
wrapperOverflowRef.current.scrollLeft += WIDTH_SLIDE_ITEM;
|
|
148
|
+
}
|
|
149
|
+
setState(prev => (Object.assign(Object.assign({}, prev), { notiUpdateScroll: prev.notiUpdateScroll + 1 })));
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
handleError(error, {
|
|
153
|
+
path: PATH,
|
|
154
|
+
name: 'handleChangePrev',
|
|
155
|
+
args: {
|
|
156
|
+
type,
|
|
157
|
+
error,
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
// eslint-disable-next-line no-console
|
|
161
|
+
console.log(error);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
const handleAddSlide = () => {
|
|
165
|
+
try {
|
|
166
|
+
if (typeof callback === 'function') {
|
|
167
|
+
callback(slideActionType.ADD);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
handleError(error, {
|
|
172
|
+
path: PATH,
|
|
173
|
+
name: 'handleAddSlide',
|
|
174
|
+
args: {
|
|
175
|
+
error,
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
useEffect(() => () => {
|
|
181
|
+
setState(prev => (Object.assign(Object.assign({}, prev), { cacheInfoClicked: { label: '', value: '' } })));
|
|
182
|
+
}, []);
|
|
183
|
+
// Calculator center selected template
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
const selectedSlideEle = document.getElementById(`template-slide-${activeId}`);
|
|
186
|
+
if (selectedSlideEle instanceof HTMLElement &&
|
|
187
|
+
wrapperOverflowRef &&
|
|
188
|
+
wrapperOverflowRef.current) {
|
|
189
|
+
// Calculate the scroll position to center the element
|
|
190
|
+
const elementLeftOffset = selectedSlideEle.offsetLeft;
|
|
191
|
+
const containerWidth = wrapperOverflowRef.current.clientWidth;
|
|
192
|
+
const elementWidth = selectedSlideEle.clientWidth;
|
|
193
|
+
const scrollPosition = elementLeftOffset - (containerWidth - elementWidth) / 2;
|
|
194
|
+
// Set the scroll position of the container
|
|
195
|
+
wrapperOverflowRef.current.scrollLeft = scrollPosition;
|
|
196
|
+
}
|
|
197
|
+
}, [activeId]);
|
|
198
|
+
useEffect(() => {
|
|
199
|
+
if (!_.isEmpty(wrapperOverflowRef.current)) {
|
|
200
|
+
const isDisabledPrevTmp = getObjectPropSafely(() => { var _a; return ((_a = wrapperOverflowRef.current) === null || _a === void 0 ? void 0 : _a.scrollLeft) === 0; });
|
|
201
|
+
const isDisabledNextTmp = getObjectPropSafely(() => {
|
|
202
|
+
const { scrollLeft = 0, offsetWidth = 0, scrollWidth = 0, } = wrapperOverflowRef.current || {};
|
|
203
|
+
return offsetWidth === scrollWidth || scrollWidth <= Math.ceil(scrollLeft) + offsetWidth;
|
|
204
|
+
});
|
|
205
|
+
setState(prev => (Object.assign(Object.assign({}, prev), { disabledPrev: isDisabledPrevTmp, disabledNext: isDisabledNextTmp })));
|
|
206
|
+
}
|
|
207
|
+
}, [options, state.notiUpdateScroll]);
|
|
208
|
+
const renderMainContent = () => options.map((item, index) => {
|
|
209
|
+
let { label } = _.cloneDeep(item);
|
|
210
|
+
if (isShowLabelSequentially) {
|
|
211
|
+
label = `${prefix} ${index + 1}`;
|
|
212
|
+
}
|
|
213
|
+
return (React.createElement(Draggable, { key: item.value, isDragDisabled: isViewMode || disabled || isDragDisabled, draggableId: item.value, index: index }, (providedDraggable, snapshotDraggable) => {
|
|
214
|
+
var _a, _b;
|
|
215
|
+
return (React.createElement(SlideItem, Object.assign({ id: `template-slide-${item.value}`, isActive: activeId === item.value, className: "slide-item", ref: providedDraggable.innerRef }, providedDraggable.draggableProps, providedDraggable.dragHandleProps, { isSlideError: Array.isArray(errors) && errors.includes(item.value), style: getItemStyle(snapshotDraggable.isDragging, providedDraggable.draggableProps.style), onClick: (e) => {
|
|
216
|
+
e.stopPropagation();
|
|
217
|
+
handleActiveSlide(e, item);
|
|
218
|
+
} }),
|
|
219
|
+
React.createElement(SlideText, { isActive: activeId === item.value }, label),
|
|
220
|
+
!isViewMode && (React.createElement(Popover, { placement: "bottomLeft", trigger: "click", content: React.createElement(MenuList, null,
|
|
221
|
+
React.createElement(WrapperDisable, { disabled: disabledDuplicate },
|
|
222
|
+
React.createElement(MenuItem, { isDisabled: disabledDuplicate, onClick: (e) => {
|
|
223
|
+
e.stopPropagation();
|
|
224
|
+
if (!disabledDuplicate) {
|
|
225
|
+
handleDuplicateSlide(state.cacheInfoClicked);
|
|
226
|
+
}
|
|
227
|
+
} }, t(translations.duplicate.title))),
|
|
228
|
+
React.createElement(WrapperDisable, { disabled: disabledDelete },
|
|
229
|
+
React.createElement(MenuItem, { isDisabled: disabledDelete, onClick: (e) => {
|
|
230
|
+
e.stopPropagation();
|
|
231
|
+
if (!disabledDelete) {
|
|
232
|
+
handleDeleteSlide(state.cacheInfoClicked);
|
|
233
|
+
}
|
|
234
|
+
} }, t(translations.delete.title)))), arrow: false },
|
|
235
|
+
React.createElement(Icon, { type: "icon-ants-three-dot-vertical", color: activeId === item.value ? (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorPrimary : (_b = THEME.token) === null || _b === void 0 ? void 0 : _b.colorText, size: "20px", onClick: (event) => handleClick(event, item), disabled: false })))));
|
|
236
|
+
}));
|
|
237
|
+
});
|
|
238
|
+
const renderSliderDragDrop = () => (React.createElement(WrapperOverflow, { ref: wrapperOverflowRef, id: "wrapper-overflow" },
|
|
239
|
+
React.createElement(DragDropContext, { onDragEnd: handleDragEnd },
|
|
240
|
+
React.createElement(Droppable, { droppableId: "droppable", direction: "horizontal" }, (providedDroppable, _snapshotDroppable) => (React.createElement(MainContent, Object.assign({ ref: providedDroppable.innerRef }, providedDroppable.droppableProps), renderMainContent()))))));
|
|
241
|
+
return (React.createElement(ContainerSlideBar, null,
|
|
242
|
+
React.createElement(SliderWrapper, { isViewMode: isViewMode },
|
|
243
|
+
React.createElement(Icon, { type: "icon-ants-angle-left", style: { fontSize: '16px', cursor: 'pointer', color: (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorPrimary }, className: "btn-arrow-left btn-action-slide-template", disabled: state.disabledPrev, onClick: (e) => {
|
|
244
|
+
e.stopPropagation();
|
|
245
|
+
handleChangeScrollDirection('PREVIOUS');
|
|
246
|
+
} }),
|
|
247
|
+
renderSliderDragDrop(),
|
|
248
|
+
React.createElement(Icon, { type: "icon-ants-angle-right", style: { fontSize: '16px', cursor: 'pointer', color: (_b = THEME.token) === null || _b === void 0 ? void 0 : _b.colorPrimary }, className: "btn-arrow-right btn-action-slide-template", disabled: state.disabledNext, onClick: (e) => {
|
|
249
|
+
e.stopPropagation();
|
|
250
|
+
handleChangeScrollDirection('NEXT');
|
|
251
|
+
} })),
|
|
252
|
+
isShowAdd && (React.createElement(PlusCircleFilled, { style: {
|
|
253
|
+
fontSize: `${BTN_ADD_SIZE}px`,
|
|
254
|
+
cursor: disabledAdd ? 'not-allowed' : 'pointer',
|
|
255
|
+
color: disabledAdd ? (_c = THEME.token) === null || _c === void 0 ? void 0 : _c.colorTextDisabled : (_d = THEME.token) === null || _d === void 0 ? void 0 : _d.colorPrimary,
|
|
256
|
+
}, disabled: disabledAdd, onClick: (e) => {
|
|
257
|
+
e.stopPropagation();
|
|
258
|
+
if (!disabledAdd) {
|
|
259
|
+
handleAddSlide();
|
|
260
|
+
}
|
|
261
|
+
} }))));
|
|
262
|
+
};
|
|
263
|
+
SlideBar.defaultProps = {
|
|
264
|
+
isViewMode: false,
|
|
265
|
+
disabled: false,
|
|
266
|
+
isShowLabelSequentially: true,
|
|
267
|
+
isShowAdd: true,
|
|
268
|
+
isDragDisabled: false,
|
|
269
|
+
activeId: '',
|
|
270
|
+
prefix: 'Slide',
|
|
271
|
+
options: [],
|
|
272
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const OFFSET_SIZE_SLIDE = 32;
|
|
2
|
+
export declare const BTN_ADD_SIZE = 32;
|
|
3
|
+
export declare const WIDTH_SLIDE_ITEM = 105;
|
|
4
|
+
export declare const slideActionType: {
|
|
5
|
+
readonly ADD: "ADD_SLIDE";
|
|
6
|
+
readonly RE_ORDERS: "RE_ORDERS_SLIDE_LIST";
|
|
7
|
+
readonly ACTIVE: "ACTIVE_SLIDE";
|
|
8
|
+
readonly DUPLICATE: "DUPLICATE_SLIDE";
|
|
9
|
+
readonly DELETE: "DELETE_SLIDE";
|
|
10
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const OFFSET_SIZE_SLIDE = 32;
|
|
2
|
+
export const BTN_ADD_SIZE = 32;
|
|
3
|
+
export const WIDTH_SLIDE_ITEM = 105;
|
|
4
|
+
export const slideActionType = {
|
|
5
|
+
ADD: 'ADD_SLIDE',
|
|
6
|
+
RE_ORDERS: 'RE_ORDERS_SLIDE_LIST',
|
|
7
|
+
ACTIVE: 'ACTIVE_SLIDE',
|
|
8
|
+
DUPLICATE: 'DUPLICATE_SLIDE',
|
|
9
|
+
DELETE: 'DELETE_SLIDE',
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SlideBar';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SlideBar';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const SliderWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
2
|
+
isViewMode?: boolean | undefined;
|
|
3
|
+
}, never>;
|
|
4
|
+
export declare const WrapperOverflow: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
+
export declare const MainContent: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
|
+
export declare const SlideItem: import("styled-components").StyledComponent<"div", any, {
|
|
7
|
+
isActive?: boolean | undefined;
|
|
8
|
+
isSlideError?: boolean | undefined;
|
|
9
|
+
}, never>;
|
|
10
|
+
export declare const SlideText: import("styled-components").StyledComponent<"div", any, {
|
|
11
|
+
isActive?: boolean | undefined;
|
|
12
|
+
}, never>;
|
|
13
|
+
export declare const MenuList: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
14
|
+
export declare const MenuItem: import("styled-components").StyledComponent<"div", any, {
|
|
15
|
+
isDisabled?: boolean | undefined;
|
|
16
|
+
}, never>;
|
|
17
|
+
export declare const ContainerSlideBar: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
18
|
+
export declare const WrapperDisable: import("styled-components").StyledComponent<"div", any, {
|
|
19
|
+
disabled?: boolean | undefined;
|
|
20
|
+
}, never>;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
2
|
+
/* eslint-disable indent */
|
|
3
|
+
// Styled
|
|
4
|
+
import styled, { css } from 'styled-components';
|
|
5
|
+
// Constants
|
|
6
|
+
import { THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
7
|
+
import { BTN_ADD_SIZE, OFFSET_SIZE_SLIDE, WIDTH_SLIDE_ITEM } from './constants';
|
|
8
|
+
export const SliderWrapper = styled.div `
|
|
9
|
+
position: relative;
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
border-radius: 4px;
|
|
13
|
+
border: 1px solid ${(_a = THEME.token) === null || _a === void 0 ? void 0 : _a.accent1};
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
// max-width: ${props => (props.isViewMode ? '100%' : 'calc(100% - 40px)')};
|
|
16
|
+
width: calc(100% - ${BTN_ADD_SIZE}px - ${OFFSET_SIZE_SLIDE * 2}px);
|
|
17
|
+
flex: 1;
|
|
18
|
+
height: ${OFFSET_SIZE_SLIDE}px;
|
|
19
|
+
padding: 0px ${OFFSET_SIZE_SLIDE}px;
|
|
20
|
+
|
|
21
|
+
.btn-action-slide-template {
|
|
22
|
+
width: ${OFFSET_SIZE_SLIDE}px !important;
|
|
23
|
+
height: ${OFFSET_SIZE_SLIDE - 2}px !important;
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
|
|
29
|
+
&.btn-arrow-left {
|
|
30
|
+
position: absolute;
|
|
31
|
+
top: 0px;
|
|
32
|
+
left: 0;
|
|
33
|
+
border-right: 1px solid ${(_b = THEME.token) === null || _b === void 0 ? void 0 : _b.accent1};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&.btn-arrow-right {
|
|
37
|
+
position: absolute;
|
|
38
|
+
top: 0px;
|
|
39
|
+
right: 0px;
|
|
40
|
+
border-left: 1px solid ${(_c = THEME.token) === null || _c === void 0 ? void 0 : _c.accent1};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
export const WrapperOverflow = styled.div `
|
|
45
|
+
overflow-x: auto;
|
|
46
|
+
overflow-y: hidden;
|
|
47
|
+
flex: 1;
|
|
48
|
+
|
|
49
|
+
&::-webkit-scrollbar {
|
|
50
|
+
-webkit-appearance: none;
|
|
51
|
+
background-color: #eee;
|
|
52
|
+
width: 0px;
|
|
53
|
+
height: 0px;
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
export const MainContent = styled.div `
|
|
57
|
+
display: flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
height: 100%;
|
|
60
|
+
|
|
61
|
+
.slide-item {
|
|
62
|
+
border-right: 1px solid ${(_d = THEME.token) === null || _d === void 0 ? void 0 : _d.accent1};
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
65
|
+
export const SlideItem = styled.div `
|
|
66
|
+
display: flex;
|
|
67
|
+
justify-content: space-between;
|
|
68
|
+
align-items: center;
|
|
69
|
+
flex-shrink: 0;
|
|
70
|
+
|
|
71
|
+
border-top: 1px solid ${(_e = THEME.token) === null || _e === void 0 ? void 0 : _e.accent1};
|
|
72
|
+
border-bottom: 1px solid ${(_f = THEME.token) === null || _f === void 0 ? void 0 : _f.accent1};
|
|
73
|
+
height: ${OFFSET_SIZE_SLIDE}px;
|
|
74
|
+
width: ${WIDTH_SLIDE_ITEM}px;
|
|
75
|
+
padding: 0px 10px;
|
|
76
|
+
cursor: pointer;
|
|
77
|
+
background-color: ${props => { var _a, _b; return (props.isActive ? (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorTextActive : (_b = THEME.token) === null || _b === void 0 ? void 0 : _b.bw0); }};
|
|
78
|
+
|
|
79
|
+
.icon-more-vertical {
|
|
80
|
+
font-weight: 600;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
${props => {
|
|
84
|
+
var _a;
|
|
85
|
+
return props.isSlideError &&
|
|
86
|
+
css `
|
|
87
|
+
border: 1px solid ${(_a = THEME.token) === null || _a === void 0 ? void 0 : _a.red8} !important;
|
|
88
|
+
`;
|
|
89
|
+
}}
|
|
90
|
+
`;
|
|
91
|
+
export const SlideText = styled.div `
|
|
92
|
+
font-size: ${(_g = THEME.token) === null || _g === void 0 ? void 0 : _g.fontSize}px;
|
|
93
|
+
font-weight: 400;
|
|
94
|
+
line-height: ${OFFSET_SIZE_SLIDE}px;
|
|
95
|
+
overflow: hidden;
|
|
96
|
+
white-space: nowrap;
|
|
97
|
+
text-overflow: ellipsis;
|
|
98
|
+
|
|
99
|
+
color: ${props => { var _a, _b; return (props.isActive ? (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorPrimary : (_b = THEME.token) === null || _b === void 0 ? void 0 : _b.colorText); }};
|
|
100
|
+
`;
|
|
101
|
+
export const MenuList = styled.div `
|
|
102
|
+
display: flex;
|
|
103
|
+
flex-direction: column;
|
|
104
|
+
align-items: flex-start;
|
|
105
|
+
justify-content: center;
|
|
106
|
+
gap: 8px;
|
|
107
|
+
`;
|
|
108
|
+
export const MenuItem = styled.div `
|
|
109
|
+
font-size: ${(_h = THEME.token) === null || _h === void 0 ? void 0 : _h.fontSize}px;
|
|
110
|
+
line-height: 14px;
|
|
111
|
+
color: ${(_j = THEME.token) === null || _j === void 0 ? void 0 : _j.colorText};
|
|
112
|
+
|
|
113
|
+
${props => props.isDisabled &&
|
|
114
|
+
css `
|
|
115
|
+
pointer-events: none;
|
|
116
|
+
`}
|
|
117
|
+
`;
|
|
118
|
+
export const ContainerSlideBar = styled.div `
|
|
119
|
+
display: flex;
|
|
120
|
+
width: 100%;
|
|
121
|
+
align-items: center;
|
|
122
|
+
justify-content: flex-start;
|
|
123
|
+
gap: 10px;
|
|
124
|
+
* > * {
|
|
125
|
+
box-sizing: border-box;
|
|
126
|
+
}
|
|
127
|
+
`;
|
|
128
|
+
export const WrapperDisable = styled.div `
|
|
129
|
+
cursor: pointer;
|
|
130
|
+
|
|
131
|
+
${props => props.disabled &&
|
|
132
|
+
css `
|
|
133
|
+
cursor: not-allowed;
|
|
134
|
+
opacity: 0.6;
|
|
135
|
+
`}
|
|
136
|
+
`;
|
|
@@ -36,6 +36,7 @@ export * from './RateV2';
|
|
|
36
36
|
export { InputDynamic } from './InputDynamic';
|
|
37
37
|
export * from './PreviewTabs';
|
|
38
38
|
export * from './MobileFrame';
|
|
39
|
+
export * from './SlideBar';
|
|
39
40
|
export type { SliderProps } from './Slider';
|
|
40
41
|
export type { PaginationProps } from './Pagination';
|
|
41
42
|
export type { InputDynamicProps } from './InputDynamic';
|
|
@@ -16,6 +16,9 @@ import dayjs from 'dayjs';
|
|
|
16
16
|
import React, { useEffect } from 'react';
|
|
17
17
|
import weekday from 'dayjs/plugin/weekday';
|
|
18
18
|
import localeData from 'dayjs/plugin/localeData';
|
|
19
|
+
/** dayjs plugins for timezone */
|
|
20
|
+
import utc from 'dayjs/plugin/utc';
|
|
21
|
+
import timezone from 'dayjs/plugin/timezone';
|
|
19
22
|
// Constants
|
|
20
23
|
import { THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
21
24
|
// Style
|
|
@@ -27,6 +30,8 @@ import i18next from '@antscorp/antsomi-ui/es/locales/i18n';
|
|
|
27
30
|
// NOTE: HOT fix DatePicker Advanced
|
|
28
31
|
dayjs.extend(weekday);
|
|
29
32
|
dayjs.extend(localeData);
|
|
33
|
+
dayjs.extend(utc);
|
|
34
|
+
dayjs.extend(timezone);
|
|
30
35
|
const ConfigProvider = props => {
|
|
31
36
|
// Props
|
|
32
37
|
const { children, locale } = props, restOfProps = __rest(props, ["children", "locale"]);
|
|
@@ -28,7 +28,7 @@ const { Text } = Typography;
|
|
|
28
28
|
export const AdvancedPicker = props => {
|
|
29
29
|
var _a, _b;
|
|
30
30
|
// Props
|
|
31
|
-
const { label, inputStyle, dateTypeKeysShow, calculationTypeKeysShow, showCalculationTypeCondition, defaultDateTypeKey, valueType, option: propsOption, operatorKey, type, date: propsDate, format, formatInputDisplay, errorMessage, disableAfterDate, disableBeforeDate, showTime, disabled, onUpdatedNewDate, onApply, } = props;
|
|
31
|
+
const { label, inputStyle, dateTypeKeysShow, calculationTypeKeysShow, showCalculationTypeCondition, defaultDateTypeKey, valueType, option: propsOption, operatorKey, type, date: propsDate, format, formatInputDisplay, errorMessage, disableAfterDate, disableBeforeDate, showTime, disabled, timezone, onUpdatedNewDate, onApply, } = props;
|
|
32
32
|
// Memo
|
|
33
33
|
const newDateTypes = useMemo(() => {
|
|
34
34
|
if (dateTypeKeysShow && dateTypeKeysShow.length) {
|
|
@@ -60,11 +60,11 @@ export const AdvancedPicker = props => {
|
|
|
60
60
|
calculationDate: newCalculationDates[0],
|
|
61
61
|
value: 0,
|
|
62
62
|
},
|
|
63
|
-
date: dayjs().format(format),
|
|
64
|
-
dateDisplay: dayjs().format(format),
|
|
63
|
+
date: dayjs().tz(timezone).format(format),
|
|
64
|
+
dateDisplay: dayjs().tz(timezone).format(format),
|
|
65
65
|
});
|
|
66
66
|
const { isOpen, option, date, dateDisplay } = state;
|
|
67
|
-
const currDate = dayjs(date, format);
|
|
67
|
+
const currDate = dayjs(date, format).tz(timezone);
|
|
68
68
|
const currWeek = currDate.isoWeek();
|
|
69
69
|
const currDay = currDate.day();
|
|
70
70
|
const currDayOfMonth = currDate.date();
|
|
@@ -97,9 +97,10 @@ export const AdvancedPicker = props => {
|
|
|
97
97
|
boxShadow: token.boxShadowSecondary,
|
|
98
98
|
};
|
|
99
99
|
const selectedDateTitle = useMemo(() => dayjs(dateDisplay, format)
|
|
100
|
+
.tz(timezone)
|
|
100
101
|
.format(formatDisplay)
|
|
101
102
|
.replace(QUARTER_PLACEHOLDER, 'Quarter ')
|
|
102
|
-
.replace(WEEK_PLACEHOLDER, 'Week '), [dateDisplay, format, formatDisplay]);
|
|
103
|
+
.replace(WEEK_PLACEHOLDER, 'Week '), [dateDisplay, format, formatDisplay, timezone]);
|
|
103
104
|
const onChangeOption = (params) => {
|
|
104
105
|
try {
|
|
105
106
|
setState(state => (Object.assign(Object.assign({}, state), { option: Object.assign(Object.assign({}, state.option), params) })));
|
|
@@ -154,8 +155,8 @@ export const AdvancedPicker = props => {
|
|
|
154
155
|
let newDate = '';
|
|
155
156
|
if (newDateType) {
|
|
156
157
|
if (newDateType.value === 'fixed') {
|
|
157
|
-
newDate = dayjs(propsDate, format, true).isValid()
|
|
158
|
-
? dayjs(propsDate, format).format(format)
|
|
158
|
+
newDate = dayjs(propsDate, format, true).tz(timezone).isValid()
|
|
159
|
+
? dayjs(propsDate, format).tz(timezone).format(format)
|
|
159
160
|
: propsDate;
|
|
160
161
|
setState(state => (Object.assign(Object.assign({}, state), { date: newDate, dateDisplay: newDate, optionSelected: Object.assign(Object.assign({}, option), { dateType: newDateType }) })));
|
|
161
162
|
}
|
|
@@ -195,7 +196,8 @@ export const AdvancedPicker = props => {
|
|
|
195
196
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
196
197
|
}, [propsOption, newCalculationDates, propsDate, format]);
|
|
197
198
|
// Handlers
|
|
198
|
-
const disableDate = current => current > dayjs(disableAfterDate, format) ||
|
|
199
|
+
const disableDate = current => current > dayjs(disableAfterDate, format).tz(timezone) ||
|
|
200
|
+
current < dayjs(disableBeforeDate, format).tz(timezone);
|
|
199
201
|
const toggleOpenDropdown = () => {
|
|
200
202
|
try {
|
|
201
203
|
setState(() => (Object.assign(Object.assign({}, state), { isOpen: !state.isOpen })));
|
|
@@ -238,7 +240,7 @@ export const AdvancedPicker = props => {
|
|
|
238
240
|
};
|
|
239
241
|
const onClickNow = () => {
|
|
240
242
|
try {
|
|
241
|
-
setState(state => (Object.assign(Object.assign({}, state), { date: dayjs().format(format) })));
|
|
243
|
+
setState(state => (Object.assign(Object.assign({}, state), { date: dayjs().tz(timezone).format(format) })));
|
|
242
244
|
}
|
|
243
245
|
catch (error) {
|
|
244
246
|
handleError(error, {
|
|
@@ -288,15 +290,19 @@ export const AdvancedPicker = props => {
|
|
|
288
290
|
const getNewDate = (item, index) => {
|
|
289
291
|
switch (valueType) {
|
|
290
292
|
case 'WEEK':
|
|
291
|
-
return dayjs(date).isoWeek(item);
|
|
293
|
+
return dayjs(date).tz(timezone).isoWeek(item);
|
|
292
294
|
case 'DAY_OF_WEEK':
|
|
293
|
-
return dayjs(date).day(index);
|
|
295
|
+
return dayjs(date).tz(timezone).day(index);
|
|
294
296
|
case 'MONTH_DAY':
|
|
295
|
-
return dayjs(date)
|
|
297
|
+
return dayjs(date)
|
|
298
|
+
.tz(timezone)
|
|
299
|
+
.year(ANCHOR_LEAP_YEAR)
|
|
300
|
+
.month(currMonthSelected)
|
|
301
|
+
.date(item);
|
|
296
302
|
case 'DAY':
|
|
297
|
-
return dayjs(date).year(ANCHOR_LEAP_YEAR).month(0).date(item);
|
|
303
|
+
return dayjs(date).tz(timezone).year(ANCHOR_LEAP_YEAR).month(0).date(item);
|
|
298
304
|
default:
|
|
299
|
-
return dayjs(date);
|
|
305
|
+
return dayjs(date).tz(timezone);
|
|
300
306
|
}
|
|
301
307
|
};
|
|
302
308
|
return (React.createElement("div", { style: contentStyle },
|
|
@@ -313,7 +319,7 @@ export const AdvancedPicker = props => {
|
|
|
313
319
|
'custom-picker-item-selected': getCellSelected(item, index),
|
|
314
320
|
}), onClick: () => {
|
|
315
321
|
const newDate = getNewDate(item, index);
|
|
316
|
-
setState(state => (Object.assign(Object.assign({}, state), { date: dayjs(newDate).format(format) })));
|
|
322
|
+
setState(state => (Object.assign(Object.assign({}, state), { date: dayjs(newDate).tz(timezone).format(format) })));
|
|
317
323
|
} }, item)))))) : (React.createElement(React.Fragment, null,
|
|
318
324
|
React.createElement(Select, { getPopupContainer: triggerNode => triggerNode.parentNode, options: newCalculationTypes, value: option.calculationType.value, onChange: value => {
|
|
319
325
|
const calculationType = CALCULATION_TYPES.find(calculationType => calculationType.value === value);
|
|
@@ -330,7 +336,7 @@ export const AdvancedPicker = props => {
|
|
|
330
336
|
const cellRender = useCallback((current, info) => {
|
|
331
337
|
const onChangeDatePicker = (value) => {
|
|
332
338
|
try {
|
|
333
|
-
setState(state => (Object.assign(Object.assign({}, state), { date: dayjs(value).format(format) })));
|
|
339
|
+
setState(state => (Object.assign(Object.assign({}, state), { date: dayjs(value).tz(timezone).format(format) })));
|
|
334
340
|
}
|
|
335
341
|
catch (error) {
|
|
336
342
|
handleError(error, {
|
|
@@ -347,13 +353,13 @@ export const AdvancedPicker = props => {
|
|
|
347
353
|
let newDate;
|
|
348
354
|
switch (info.subType) {
|
|
349
355
|
case 'hour':
|
|
350
|
-
newDate = dayjs(date).hour(current);
|
|
356
|
+
newDate = dayjs(date).tz(timezone).hour(current);
|
|
351
357
|
break;
|
|
352
358
|
case 'minute':
|
|
353
|
-
newDate = dayjs(date).minute(current);
|
|
359
|
+
newDate = dayjs(date).tz(timezone).minute(current);
|
|
354
360
|
break;
|
|
355
361
|
case 'second':
|
|
356
|
-
newDate = dayjs(date).second(current);
|
|
362
|
+
newDate = dayjs(date).tz(timezone).second(current);
|
|
357
363
|
break;
|
|
358
364
|
default:
|
|
359
365
|
break;
|
|
@@ -370,14 +376,16 @@ export const AdvancedPicker = props => {
|
|
|
370
376
|
e.stopPropagation();
|
|
371
377
|
onChangeDatePicker(current);
|
|
372
378
|
} }, getCellRender(current, valueType, info)));
|
|
373
|
-
}, [valueType, format, date]);
|
|
379
|
+
}, [valueType, format, date, timezone]);
|
|
374
380
|
return (React.createElement(Space, { direction: "vertical", size: 5, className: "antsomi-advanced-picker-container" },
|
|
375
381
|
!!label && typeof label === 'string' ? (React.createElement(Text, { style: { color: '#666666' } }, label)) : (label),
|
|
376
382
|
option.dateType.value === 'fixed' &&
|
|
377
383
|
!['WEEK', 'DAY_OF_WEEK', 'MONTH_DAY', 'DAY'].includes(valueType) ? (React.createElement(Tooltip, { title: selectedDateTitle },
|
|
378
|
-
React.createElement(DatePicker, { disabled: disabled, open: !disabled && isOpen, allowClear: false, inputReadOnly: true, status: errorMessage ? 'error' : '', inputRender: () => (React.createElement(DatePickerCustomInput, { readOnly: true, placeholder: "Select Date", value: selectedDateTitle, onClick: () => toggleOpenDropdown() })), value: currDate,
|
|
379
|
-
|
|
380
|
-
|
|
384
|
+
React.createElement(DatePicker, { disabled: disabled, open: !disabled && isOpen, allowClear: false, inputReadOnly: true, status: errorMessage ? 'error' : '', inputRender: () => (React.createElement(DatePickerCustomInput, { readOnly: true, placeholder: "Select Date", value: selectedDateTitle, onClick: () => toggleOpenDropdown() })), value: currDate,
|
|
385
|
+
// style={{
|
|
386
|
+
// width: 120,
|
|
387
|
+
// }}
|
|
388
|
+
disabledDate: disableDate, format: formatDisplay, showToday: false, popupClassName: clsx('antsomi-picker-dropdown__advanced', {
|
|
381
389
|
'--error': errorMessage,
|
|
382
390
|
'hide-picker-header': ['QUARTER', 'MONTH'].includes(valueType),
|
|
383
391
|
'only-show-time-picker': ['HOUR', 'MINUTE'].includes(valueType),
|
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
import dayjs from 'dayjs';
|
|
4
4
|
import isoWeek from 'dayjs/plugin/isoWeek';
|
|
5
5
|
import quarterOfYear from 'dayjs/plugin/quarterOfYear';
|
|
6
|
+
/** dayjs plugins for timezone */
|
|
7
|
+
import utc from 'dayjs/plugin/utc';
|
|
8
|
+
import timezone from 'dayjs/plugin/timezone';
|
|
6
9
|
// Constants
|
|
7
10
|
import { DATE_TYPE_MAPPING, DEFAULT_DATE_FORMAT, MONTH_LABEL_SHORT, QUARTER_PLACEHOLDER, WEEK_PLACEHOLDER, } from './constants';
|
|
8
11
|
dayjs.extend(isoWeek);
|
|
9
12
|
dayjs.extend(quarterOfYear);
|
|
13
|
+
dayjs.extend(utc);
|
|
14
|
+
dayjs.extend(timezone);
|
|
10
15
|
/**
|
|
11
16
|
* Calculates a new date based on the given parameters.
|
|
12
17
|
* @param {string} [dateTypeKey='today'] - Key to determine the type of date to be used as the starting point.
|
package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export interface AdvancedRangePickerProps {
|
|
|
11
11
|
errorMessage?: string;
|
|
12
12
|
showLabel?: boolean;
|
|
13
13
|
showTime?: boolean;
|
|
14
|
+
timezone?: string;
|
|
14
15
|
onChange?: ({ timeRange, mode }: TOnChangePayload) => void;
|
|
15
16
|
}
|
|
16
17
|
export declare const AdvancedRangePicker: React.FC<AdvancedRangePickerProps>;
|
package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.js
CHANGED
|
@@ -19,7 +19,7 @@ const PATH = '@antscorp/antsomi-ui/es/components/molecules/DatePicker/components
|
|
|
19
19
|
export const AdvancedRangePicker = props => {
|
|
20
20
|
const { t } = i18nInstance;
|
|
21
21
|
// Props
|
|
22
|
-
const { valueType, timeRange, errorMessage, showLabel, startDateConfig, endDateConfig, showTime, showCalculationTypeCondition, disabled, onChange, } = props;
|
|
22
|
+
const { valueType, timeRange, errorMessage, showLabel, startDateConfig, endDateConfig, showTime, showCalculationTypeCondition, disabled, timezone, onChange, } = props;
|
|
23
23
|
const [timeRangeState, setTimeRange] = useState(timeRange);
|
|
24
24
|
useDeepCompareEffect(() => {
|
|
25
25
|
if (typeof onChange === 'function') {
|
|
@@ -55,8 +55,8 @@ export const AdvancedRangePicker = props => {
|
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
return (React.createElement(Space, { size: 20 },
|
|
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') })));
|
|
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, timezone: timezone, 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, timezone: timezone, onUpdatedNewDate: ({ date }) => onUpdateTimeRange('endDate', { date }, 'system'), onApply: ({ date, option }) => onUpdateTimeRange('endDate', Object.assign({ date }, option), 'user') })));
|
|
60
60
|
};
|
|
61
61
|
AdvancedRangePicker.defaultProps = {
|
|
62
62
|
timeRange: {
|
package/es/locales/i18n.d.ts
CHANGED
|
@@ -36,6 +36,12 @@ export declare const convertLanguageJsonToObject: (json: any, objToConvertTo?: C
|
|
|
36
36
|
title: string;
|
|
37
37
|
description: string;
|
|
38
38
|
};
|
|
39
|
+
duplicate: {
|
|
40
|
+
title: string;
|
|
41
|
+
};
|
|
42
|
+
delete: {
|
|
43
|
+
title: string;
|
|
44
|
+
};
|
|
39
45
|
messageError: {
|
|
40
46
|
createColorProfile: {
|
|
41
47
|
message: string;
|
package/es/test.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
3
|
import { createRoot } from 'react-dom/client';
|
|
4
4
|
import '@antscorp/icons/main.css';
|
|
5
|
-
import { ConfigProvider, InputDynamic, SettingWrapper, UploadImage, } from './components';
|
|
5
|
+
import { ConfigProvider, InputDynamic, SettingWrapper, UploadImage, SlideBar, } from './components';
|
|
6
6
|
// Queries configs
|
|
7
7
|
import { queryClientAntsomiUI, QueryClientProviderAntsomiUI } from './queries';
|
|
8
8
|
export const BACKGROUND_COLOR_STYLE = {
|
|
@@ -45,6 +45,23 @@ export const App = () => {
|
|
|
45
45
|
color: 'green',
|
|
46
46
|
customColors,
|
|
47
47
|
});
|
|
48
|
+
const [stateSlideBar, setStateSlideBar] = useState({
|
|
49
|
+
errors: [],
|
|
50
|
+
disabled: true,
|
|
51
|
+
prefix: 'Item',
|
|
52
|
+
isViewMode: false,
|
|
53
|
+
isShowAdd: true,
|
|
54
|
+
limit: {
|
|
55
|
+
min: 1,
|
|
56
|
+
max: 2,
|
|
57
|
+
},
|
|
58
|
+
activeId: '1',
|
|
59
|
+
options: Array.from({ length: 5 }, (_, index) => ({
|
|
60
|
+
label: `Item ${index + 1}`,
|
|
61
|
+
value: `${index + 1}`,
|
|
62
|
+
})),
|
|
63
|
+
isShowLabelSequentially: false,
|
|
64
|
+
});
|
|
48
65
|
const [radioValue, setRadioValue] = useState('color');
|
|
49
66
|
const [sliderValue, setSliderValue] = useState(10);
|
|
50
67
|
const [edge, setEdge] = useState(['auto', 'auto', 700, 700]);
|
|
@@ -79,6 +96,20 @@ export const App = () => {
|
|
|
79
96
|
const handleSetIcon = value => {
|
|
80
97
|
setIcon(value);
|
|
81
98
|
};
|
|
99
|
+
const callbackSlideBar = (type, data) => {
|
|
100
|
+
console.log({ type, data });
|
|
101
|
+
};
|
|
102
|
+
// --------------------------- Test SlideBar start -------------------------------------------
|
|
103
|
+
return (React.createElement("div", { style: {
|
|
104
|
+
width: 500,
|
|
105
|
+
height: 500,
|
|
106
|
+
border: '1px solid black',
|
|
107
|
+
margin: '0 auto',
|
|
108
|
+
padding: 12,
|
|
109
|
+
borderRadius: '10px',
|
|
110
|
+
} },
|
|
111
|
+
React.createElement(SlideBar, Object.assign({}, stateSlideBar, { callback: callbackSlideBar }))));
|
|
112
|
+
// --------------------------- Test SlideBar end -------------------------------------------
|
|
82
113
|
// ---------------------------- Test Input Dynamic start ------------------------------
|
|
83
114
|
// return (
|
|
84
115
|
// <div
|
|
@@ -288,6 +319,5 @@ export const App = () => {
|
|
|
288
319
|
};
|
|
289
320
|
const container = document.getElementById('root');
|
|
290
321
|
const root = createRoot(container);
|
|
291
|
-
root.render(React.createElement(
|
|
292
|
-
React.createElement(
|
|
293
|
-
React.createElement(App, null))));
|
|
322
|
+
root.render(React.createElement(ConfigProvider, { locale: "en" },
|
|
323
|
+
React.createElement(App, null)));
|
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.84",
|
|
4
4
|
"description": "An enterprise-class UI design language and React UI library.",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"dist/*",
|
|
@@ -67,11 +67,15 @@
|
|
|
67
67
|
"@fortawesome/free-regular-svg-icons": "6.1.1",
|
|
68
68
|
"@fortawesome/free-solid-svg-icons": "6.1.1",
|
|
69
69
|
"@fortawesome/react-fontawesome": "0.2.0",
|
|
70
|
+
"@tanstack/react-query": "4.20.4",
|
|
71
|
+
"@tanstack/react-query-devtools": "4.20.4",
|
|
70
72
|
"@tinymce/tinymce-react": "^3.7.0",
|
|
71
73
|
"@types/currency-formatter": "1.5.1",
|
|
74
|
+
"ace-builds": "1.4.14",
|
|
72
75
|
"antd": "5.12.6",
|
|
73
76
|
"axios": "^1.4.0",
|
|
74
77
|
"babel-plugin-file-loader": "^2.0.0",
|
|
78
|
+
"currency-formatter": "1.5.9",
|
|
75
79
|
"dayjs": "^1.11.10",
|
|
76
80
|
"font-awesome": "4.7.0",
|
|
77
81
|
"highlight.js": "^11.8.0",
|
|
@@ -79,17 +83,14 @@
|
|
|
79
83
|
"html-to-image": "^1.11.11",
|
|
80
84
|
"html2canvas": "^1.4.1",
|
|
81
85
|
"i18next": "21.6.16",
|
|
82
|
-
"currency-formatter": "1.5.9",
|
|
83
|
-
"@tanstack/react-query": "4.20.4",
|
|
84
|
-
"@tanstack/react-query-devtools": "4.20.4",
|
|
85
|
-
"pako": "2.0.4",
|
|
86
|
-
"ace-builds": "1.4.14",
|
|
87
|
-
"react-ace": "9.5.0",
|
|
88
86
|
"i18next-browser-languagedetector": "6.1.2",
|
|
89
87
|
"immer": "3.0.0",
|
|
90
88
|
"lodash": "^4.17.21",
|
|
91
89
|
"moment": "2.29.2",
|
|
90
|
+
"pako": "2.0.4",
|
|
92
91
|
"qs": "6.10.3",
|
|
92
|
+
"react-ace": "9.5.0",
|
|
93
|
+
"react-beautiful-dnd": "^13.1.1",
|
|
93
94
|
"react-color": "2.19.3",
|
|
94
95
|
"react-draggable": "^4.4.5",
|
|
95
96
|
"react-markdown": "^8.0.7",
|
|
@@ -102,7 +103,6 @@
|
|
|
102
103
|
"devDependencies": {
|
|
103
104
|
"@ant-design/cssinjs": "^1.6.2",
|
|
104
105
|
"@antscorp/eslint-config-antsomi": "1.0.4",
|
|
105
|
-
"@types/pako": "2.0.0",
|
|
106
106
|
"@babel/cli": "^7.23.4",
|
|
107
107
|
"@babel/core": "^7.21.3",
|
|
108
108
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
@@ -132,7 +132,9 @@
|
|
|
132
132
|
"@testing-library/react": "^14.0.0",
|
|
133
133
|
"@types/jest": "^29.5.0",
|
|
134
134
|
"@types/node": "^18.15.10",
|
|
135
|
+
"@types/pako": "2.0.0",
|
|
135
136
|
"@types/react": "^18.0.33",
|
|
137
|
+
"@types/react-beautiful-dnd": "^13.1.8",
|
|
136
138
|
"@types/react-dom": "^18.0.11",
|
|
137
139
|
"@types/react-test-renderer": "^18.0.0",
|
|
138
140
|
"@types/styled-components": "^5.1.26",
|