@antscorp/antsomi-ui 1.3.3-beta.82 → 1.3.3-beta.83

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.
@@ -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
- }, 1000);
255
+ }, ms);
255
256
  };
256
257
  const handleKeyPress = (e) => {
257
258
  if (isRealTime) {
@@ -12,6 +12,7 @@ export type InputDynamicProps = {
12
12
  value: string;
13
13
  isViewMode?: boolean;
14
14
  isRealTime?: boolean;
15
+ ms?: number;
15
16
  errors?: string[];
16
17
  disabled?: boolean;
17
18
  disabledOpts?: DisableShortLinkTypeProps;
@@ -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';
@@ -36,3 +36,4 @@ export * from './RateV2';
36
36
  export { InputDynamic } from './InputDynamic';
37
37
  export * from './PreviewTabs';
38
38
  export * from './MobileFrame';
39
+ export * from './SlideBar';
@@ -34,6 +34,12 @@
34
34
  "title": "Edit",
35
35
  "description": ""
36
36
  },
37
+ "duplicate": {
38
+ "title": "Duplicate"
39
+ },
40
+ "delete": {
41
+ "title": "Delete"
42
+ },
37
43
  "messageError": {
38
44
  "createColorProfile": {
39
45
  "message": "Create Color Profile Failed",
@@ -36,6 +36,12 @@ export declare const translationsJson: {
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;
@@ -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(React.StrictMode, null,
292
- React.createElement(ConfigProvider, { locale: "en" },
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.82",
3
+ "version": "1.3.3-beta.83",
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",