@antscorp/antsomi-ui 1.3.6-beta.63 → 1.3.6-beta.65
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/molecules/SearchPopover/components/PopoverSelect/PopoverSelect.js +9 -3
- package/es/components/molecules/SearchPopover/components/PopoverSelect/styled.d.ts +2 -0
- package/es/components/molecules/SearchPopover/components/PopoverSelect/styled.js +17 -0
- package/es/components/molecules/SearchPopover/types.d.ts +2 -0
- package/es/components/organism/PreviewCollections/WhatsappMessage/CarouselMessage/index.js +24 -25
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import './styles.scss';
|
|
|
5
5
|
import { Button } from '../../../../atoms/Button';
|
|
6
6
|
import { Checkbox } from '../../../../atoms/Checkbox';
|
|
7
7
|
import { Typography } from '../../../../atoms/Typography';
|
|
8
|
-
import { StyledAction, StyledFooter, StyledListFieldsWrapper } from './styled';
|
|
8
|
+
import { StyledAction, StyledFooter, StyledInputValue, StyledInputValueWrapper, StyledListFieldsWrapper, } from './styled';
|
|
9
9
|
import { EmptyData } from '../../../EmptyData';
|
|
10
10
|
import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
|
|
11
11
|
import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
|
|
@@ -14,7 +14,7 @@ import { VirtualizedMenu } from '../../../VirtualizedMenu';
|
|
|
14
14
|
import { ITEM_SIZE, ITEM_SPACING } from '../../../VirtualizedMenu/config';
|
|
15
15
|
const { t } = i18nInstance;
|
|
16
16
|
export const PopoverSelect = (props) => {
|
|
17
|
-
const { open: openProp, selected, options: optionsProp = [], inputSearchProps = {}, children, showAllLabel = 'Show all', showSelectedLabel = 'Show selected', selectAllLabel = 'Select all', deselectAllLabel = 'Unselect all', menuProps = {}, isAllowEmpty = false, onCancel, onApply, onSearchPredicate, ...rest } = props;
|
|
17
|
+
const { open: openProp, selected, options: optionsProp = [], inputSearchProps = {}, children, showAllLabel = 'Show all', showSelectedLabel = 'Show selected', selectAllLabel = 'Select all', deselectAllLabel = 'Unselect all', menuProps = {}, isAllowEmpty = false, inputValue = false, onCancel, onApply, onSearchPredicate, onClickInputValue, ...rest } = props;
|
|
18
18
|
const itemSize = menuProps.itemSize || ITEM_SIZE;
|
|
19
19
|
const itemSpacing = menuProps.itemSpacing || ITEM_SPACING;
|
|
20
20
|
const { value: searchValue, searchConfig, ...restInputSearchProps } = inputSearchProps;
|
|
@@ -101,6 +101,12 @@ export const PopoverSelect = (props) => {
|
|
|
101
101
|
const handleOpenChange = (visible) => {
|
|
102
102
|
setOpen(visible);
|
|
103
103
|
};
|
|
104
|
+
const handleInputValue = () => {
|
|
105
|
+
if (typeof onClickInputValue === 'function') {
|
|
106
|
+
onClickInputValue();
|
|
107
|
+
}
|
|
108
|
+
setOpen(false);
|
|
109
|
+
};
|
|
104
110
|
const renderCheckBoxLabel = (option) => {
|
|
105
111
|
if (typeof option.label === 'function') {
|
|
106
112
|
return option.label({ selected: selectedKeys.has(option.key) });
|
|
@@ -117,7 +123,7 @@ export const PopoverSelect = (props) => {
|
|
|
117
123
|
listLength: filteredOptions.length,
|
|
118
124
|
itemSize,
|
|
119
125
|
itemSpacing,
|
|
120
|
-
}), children: _jsx(VirtualizedMenu, { ...menuProps, itemSize: itemSize, items: items }) })) : (_jsx(EmptyData, { showIcon: false, description: t(translations.noData).toString() })), _jsxs(StyledFooter, { children: [_jsx(Button, { onClick: handleCancel, children: "Cancel" }), _jsx(Button, { onClick: handleApply, disabled: applyDisabled, type: "primary", children: "Apply" })] })] }), trigger: ['click'], open: open, inputSearchProps: {
|
|
126
|
+
}), children: _jsx(VirtualizedMenu, { ...menuProps, itemSize: itemSize, items: items }) })) : (_jsx(EmptyData, { showIcon: false, description: t(translations.noData).toString() })), inputValue && (_jsx(StyledInputValueWrapper, { children: _jsx(StyledInputValue, { onClick: handleInputValue, children: "Input value" }) })), _jsxs(StyledFooter, { children: [_jsx(Button, { onClick: handleCancel, children: "Cancel" }), _jsx(Button, { onClick: handleApply, disabled: applyDisabled, type: "primary", children: "Apply" })] })] }), trigger: ['click'], open: open, inputSearchProps: {
|
|
121
127
|
...restInputSearchProps,
|
|
122
128
|
value: search,
|
|
123
129
|
onAfterChange: handleOnSearch,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export declare const StyledInputValueWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
+
export declare const StyledInputValue: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
1
3
|
export declare const StyledFooter: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
4
|
export declare const StyledAction: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
5
|
export declare const StyledListFieldsWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
|
+
import { THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
3
|
+
export const StyledInputValueWrapper = styled.div `
|
|
4
|
+
border-top: 1px solid var(--divider-1);
|
|
5
|
+
padding: 8px 0px;
|
|
6
|
+
`;
|
|
7
|
+
export const StyledInputValue = styled.div `
|
|
8
|
+
height: 30px;
|
|
9
|
+
width: 100%;
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
padding: 0 10px;
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
|
|
15
|
+
&:hover {
|
|
16
|
+
background-color: ${THEME?.components?.Menu?.itemHoverBg};
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
2
19
|
export const StyledFooter = styled.div `
|
|
3
20
|
gap: 10px;
|
|
4
21
|
padding: 10px;
|
|
@@ -32,9 +32,11 @@ export type PopoverSelectProps<TOption extends Option = Option> = SearchPopoverP
|
|
|
32
32
|
deselectAllLabel: string;
|
|
33
33
|
selectAllLabel: string;
|
|
34
34
|
menuProps: Pick<MenuInlineProps, 'onClick' | 'inlineIndent' | 'inlinePadding' | 'itemSpacing' | 'className' | 'itemSize'>;
|
|
35
|
+
inputValue?: boolean;
|
|
35
36
|
onSearchPredicate: (option: Option) => boolean;
|
|
36
37
|
onCancel: () => void;
|
|
37
38
|
onApply: (selected: string[]) => void;
|
|
39
|
+
onClickInputValue?: () => void;
|
|
38
40
|
}>;
|
|
39
41
|
export type PopoverAddFieldProps = Omit<PopoverSelectProps, 'options'> & {
|
|
40
42
|
fields: Field[];
|
|
@@ -27,44 +27,43 @@ export default React.memo((props) => {
|
|
|
27
27
|
// Refs
|
|
28
28
|
const navigationPrevRef = useRef(null);
|
|
29
29
|
const navigationNextRef = useRef(null);
|
|
30
|
-
const
|
|
30
|
+
const isInitializedRef = useRef(false);
|
|
31
|
+
const onBeforeInit = (swiper) => {
|
|
32
|
+
if (isInitializedRef.current)
|
|
33
|
+
return;
|
|
34
|
+
if (swiper.params.navigation && typeof swiper.params.navigation !== 'boolean') {
|
|
35
|
+
if (navigationPrevRef.current && navigationNextRef.current) {
|
|
36
|
+
swiper.params.navigation.prevEl = navigationPrevRef.current;
|
|
37
|
+
swiper.params.navigation.nextEl = navigationNextRef.current;
|
|
38
|
+
try {
|
|
39
|
+
swiper.navigation.destroy();
|
|
40
|
+
swiper.navigation.init();
|
|
41
|
+
swiper.navigation.update();
|
|
42
|
+
isInitializedRef.current = true;
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
console.error('Swiper navigation initialization failed:', error);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
31
50
|
const renderCarouseMessage = useCallback((cards) => {
|
|
32
51
|
if (cards.length === 0)
|
|
33
52
|
return null;
|
|
34
|
-
return (_jsxs(CarouselMessageContainer, { className: cls('carousel-message'), children: [_jsx(Swiper, { virtual: true, grabCursor: true, freeMode: true, slidesPerView: 1, spaceBetween: 10, modules: [Virtual, Navigation, A11y], className: "carousel-message-swiper", navigation: {
|
|
53
|
+
return (_jsxs(CarouselMessageContainer, { className: cls('carousel-message'), children: [_jsx("div", { ref: navigationPrevRef, className: classNames({ 'carousel-button-prev': true }), children: _jsx(Icon, { type: "icon-ants-expand-more" }) }), _jsx("div", { ref: navigationNextRef, className: classNames({ 'carousel-button-next': true }), children: _jsx(Icon, { type: "icon-ants-expand-more" }) }), _jsx(Swiper, { virtual: true, grabCursor: true, freeMode: true, slidesPerView: 1, spaceBetween: 10, modules: [Virtual, Navigation, A11y], className: "carousel-message-swiper", navigation: {
|
|
35
54
|
prevEl: navigationPrevRef.current,
|
|
36
55
|
nextEl: navigationNextRef.current,
|
|
37
|
-
}, onBeforeInit:
|
|
38
|
-
if (initTimerRef.current) {
|
|
39
|
-
clearTimeout(initTimerRef.current);
|
|
40
|
-
}
|
|
41
|
-
initTimerRef.current = setTimeout(() => {
|
|
42
|
-
// Override prevEl & nextEl now that refs are defined
|
|
43
|
-
if (swiper.params.navigation && typeof swiper.params.navigation !== 'boolean') {
|
|
44
|
-
swiper.params.navigation.prevEl = navigationPrevRef.current;
|
|
45
|
-
swiper.params.navigation.nextEl = navigationNextRef.current;
|
|
46
|
-
// Re-init navigation
|
|
47
|
-
swiper.navigation.destroy();
|
|
48
|
-
swiper.navigation.init();
|
|
49
|
-
swiper.navigation.update();
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}, children: cards.map((message, cardIdx) => {
|
|
56
|
+
}, onBeforeInit: onBeforeInit, children: cards.map((message, cardIdx) => {
|
|
53
57
|
const { header, body, buttons } = message;
|
|
54
58
|
const isHeaderTxt = header?.format === 'TEXT';
|
|
55
59
|
const isDoc = header?.format === 'DOCUMENT';
|
|
56
60
|
const isFixed = isFixedMedia(header?.format);
|
|
57
61
|
const fixedSrc = header?.format ? MEDIA[header.format] : null;
|
|
58
|
-
return (_jsx(SwiperSlideItem, { virtualIndex: cardIdx, children: _jsx(SkeletonMessage, { size: "large", messagePadding: 0,
|
|
59
|
-
// messageMargin={getMarginMessage({
|
|
60
|
-
// isFirst: isFirstMessage,
|
|
61
|
-
// isLast: isLastMessage,
|
|
62
|
-
// })}
|
|
63
|
-
styles: {
|
|
62
|
+
return (_jsx(SwiperSlideItem, { virtualIndex: cardIdx, children: _jsx(SkeletonMessage, { size: "large", messagePadding: 0, styles: {
|
|
64
63
|
header: headerStyle,
|
|
65
64
|
body: bodyStyle,
|
|
66
65
|
}, media: isFixed ? (_jsx(MediaMessage, { src: isFixed ? fixedSrc : null, format: header?.format })) : null, header: isHeaderTxt || isDoc ? _jsx(HeaderMessage, { ...header }) : null, body: _jsx(BodyMessage, { ...body }), footer: _jsx(FooterMessage, { buttons: buttons }) }) }, cardIdx));
|
|
67
|
-
}) })
|
|
66
|
+
}) })] }));
|
|
68
67
|
}, []);
|
|
69
68
|
return (_jsxs("div", { children: [_jsx("div", { style: { marginLeft: MARGIN_MESSAGE, marginBottom: MARGIN_MESSAGE }, children: _jsx(PureMessage, { size: "medium", ellipsis: { rows: 3, tooltip: true }, content: body.text }) }), renderCarouseMessage(carousel?.cards || [])] }));
|
|
70
69
|
});
|