@pushwoosh/dumb-components 1.1.166 → 1.1.168

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.
@@ -2,7 +2,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { CSSTransition } from 'react-transition-group';
3
3
  import styled, { createGlobalStyle } from 'styled-components';
4
4
  import { Color, ShapeRadius } from '@pushwoosh/kit-constants';
5
- const animationTimeout = 300;
5
+ const ENTER_DURATION = 200;
6
+ const EXIT_DURATION = 150;
7
+ const SLIDE_DISTANCE = '16px';
8
+ const VIEWPORT_INSET = '56px';
6
9
  export const LockBody = createGlobalStyle(["body{overflow:hidden;position:relative;height:100%;}"]);
7
10
  export const ModalBox = styled.div.attrs(({
8
11
  $zIndex
@@ -17,7 +20,7 @@ export const ModalBox = styled.div.attrs(({
17
20
  export const ModalInner = styled.div.withConfig({
18
21
  displayName: "ModalInner",
19
22
  componentId: "sc-lejcgu-1"
20
- })(["display:flex;align-items:flex-start;justify-content:center;width:100vw;height:100vh;padding:56px 0;"]);
23
+ })(["display:flex;align-items:flex-start;justify-content:center;width:100%;height:100%;padding:", ";"], VIEWPORT_INSET);
21
24
  function ModalBoxBase(props) {
22
25
  const {
23
26
  isOpen,
@@ -28,7 +31,11 @@ function ModalBoxBase(props) {
28
31
  return _jsx(CSSTransition, {
29
32
  appear: true,
30
33
  in: isOpen,
31
- timeout: animationTimeout,
34
+ timeout: {
35
+ appear: ENTER_DURATION,
36
+ enter: ENTER_DURATION,
37
+ exit: EXIT_DURATION
38
+ },
32
39
  classNames: className,
33
40
  unmountOnExit: true,
34
41
  nodeRef: nodeRef,
@@ -40,13 +47,13 @@ const backdropVisible = 'rgb(0 0 0 / 70%)';
40
47
  export const ModalBoxTrans = styled(ModalBoxBase).withConfig({
41
48
  displayName: "ModalBoxTrans",
42
49
  componentId: "sc-lejcgu-2"
43
- })(["&-appear,&-enter{background-color:", ";", "{opacity:0;transform:scale(0.5);}}&-appear-active,&-enter-active{background-color:", ";transition:background-color ", "ms;", "{opacity:1;transform:scale(1);transition:opacity ", "ms,transform ", "ms;}}&-appear-done,&-enter-done{background-color:", ";}&-exit{background-color:", ";}&-exit-active{background-color:", ";transition:background-color ", "ms;", "{opacity:0;transform:scale(0.5);transition:opacity ", "ms,transform ", "ms;}}"], backdropHidden, ModalInner, backdropVisible, animationTimeout, ModalInner, animationTimeout, animationTimeout, backdropVisible, backdropVisible, backdropHidden, animationTimeout, ModalInner, animationTimeout, animationTimeout);
50
+ })(["&-appear,&-enter{background-color:", ";", "{opacity:0;transform:translateY(", ");}}&-appear-active,&-enter-active{background-color:", ";transition:background-color ", "ms ease-out;", "{opacity:1;transform:translateY(0);transition:opacity ", "ms ease-out,transform ", "ms ease-out;}}&-appear-done,&-enter-done,&-exit{background-color:", ";", "{opacity:1;transform:translateY(0);}}&-exit-active{background-color:", ";transition:background-color ", "ms ease-in;", "{opacity:0;transform:translateY(", ");transition:opacity ", "ms ease-in,transform ", "ms ease-in;}}"], backdropHidden, ModalInner, SLIDE_DISTANCE, backdropVisible, ENTER_DURATION, ModalInner, ENTER_DURATION, ENTER_DURATION, backdropVisible, ModalInner, backdropHidden, EXIT_DURATION, ModalInner, SLIDE_DISTANCE, EXIT_DURATION, EXIT_DURATION);
44
51
  export const ModalContainer = styled.div.withConfig({
45
52
  displayName: "ModalContainer",
46
53
  componentId: "sc-lejcgu-3"
47
- })(["display:inline-flex;flex-direction:column;align-items:stretch;justify-content:flex-start;position:relative;width:", ";max-height:calc(100vh - 2 * 56px);vertical-align:middle;z-index:10;background:", ";border-radius:", ";& > *{&:first-child{border-top-left-radius:", ";border-top-right-radius:", ";}&:last-child{border-bottom-left-radius:", ";border-bottom-right-radius:", ";}}"], ({
54
+ })(["display:flex;flex-direction:column;position:relative;width:", ";max-height:calc(100vh - 2 * ", ");background-color:", ";border-radius:", ";"], ({
48
55
  $width
49
- }) => $width, Color.CLEAR, ShapeRadius.DIALOG, ShapeRadius.DIALOG, ShapeRadius.DIALOG, ShapeRadius.DIALOG, ShapeRadius.DIALOG);
56
+ }) => $width, VIEWPORT_INSET, Color.CLEAR, ShapeRadius.DIALOG);
50
57
  ModalBox.displayName = 'ModalBox';
51
58
  ModalInner.displayName = 'ModalInner';
52
59
  ModalContainer.displayName = 'ModalContainer';
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState, useCallback } from 'react';
3
- import { Vertical, Horizontal } from '@pushwoosh/kit-helpers';
3
+ import { Horizontal } from '@pushwoosh/kit-helpers';
4
4
  import { Banner } from '../../../Banner';
5
5
  import { Button } from '../../../Button';
6
6
  import { useLang } from '../../polyglot';
@@ -58,16 +58,13 @@ export function ModalConfirm(props) {
58
58
  size: size,
59
59
  isOpen: isOpen,
60
60
  onClose: onCancel,
61
- children: [_jsx(ModalHeader, {
62
- children: _jsxs(Vertical, {
63
- "$gap": 8,
64
- children: [_jsx(ModalTitle, {
65
- children: resolvedTitle
66
- }), errorMessage && _jsx(Banner, {
67
- type: "error",
68
- title: errorMessage
69
- })]
70
- })
61
+ children: [_jsxs(ModalHeader, {
62
+ children: [_jsx(ModalTitle, {
63
+ children: resolvedTitle
64
+ }), errorMessage && _jsx(Banner, {
65
+ type: "error",
66
+ title: errorMessage
67
+ })]
71
68
  }), description && _jsx(ModalBody, {
72
69
  children: description
73
70
  }), _jsx(ModalFooter, {
@@ -1,5 +1,24 @@
1
+ import { UnitSize } from '@pushwoosh/kit-constants';
1
2
  /** Top section of a {@link Modal}; typically wraps a {@link ModalTitle}. */
2
- export declare const ModalHeader: import("styled-components").StyledComponent<"div", any, {}, never>;
3
+ export declare const ModalHeader: import("styled-components").StyledComponent<"div", any, import("@pushwoosh/kit-helpers/styled-helpers").CommonBoxProps & {
4
+ $alignContent?: import("@pushwoosh/kit-helpers/styled-helpers").AlignContentValue | undefined;
5
+ $alignItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
6
+ $gap?: import("@pushwoosh/kit-helpers/styled-helpers").StrNum | undefined;
7
+ $justifyContent?: import("@pushwoosh/kit-helpers/styled-helpers").JustifyContentValue | undefined;
8
+ } & {
9
+ $gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
10
+ $justifyItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
11
+ $placeItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
12
+ } & {
13
+ $gridAutoFlow: string;
14
+ } & {
15
+ $gap: number;
16
+ $padding: {
17
+ horizontal: UnitSize;
18
+ top: UnitSize;
19
+ bottom: number;
20
+ };
21
+ }, "$gridAutoFlow" | "$padding" | "$gap">;
3
22
  /** Groups {@link ModalBodyItem}s with hairline dividers between them, inside a {@link ModalBody}. */
4
23
  export declare const ModalBodyGroup: import("styled-components").StyledComponent<"div", any, import("@pushwoosh/kit-helpers/styled-helpers").CommonBoxProps & {
5
24
  $alignContent?: import("@pushwoosh/kit-helpers/styled-helpers").AlignContentValue | undefined;
@@ -13,10 +32,8 @@ export declare const ModalBodyGroup: import("styled-components").StyledComponent
13
32
  } & {
14
33
  $gridAutoFlow: string;
15
34
  }, "$gridAutoFlow">;
16
- /** A single row within a {@link ModalBodyGroup}; pass `$vPadding` to add vertical padding. */
17
- export declare const ModalBodyItem: import("styled-components").StyledComponent<"div", any, {
18
- $vPadding?: boolean;
19
- }, never>;
35
+ /** A single row within a {@link ModalBodyGroup}, divided from its siblings by hairlines. */
36
+ export declare const ModalBodyItem: import("styled-components").StyledComponent<"div", any, {}, never>;
20
37
  /** Scrollable main content area of a {@link Modal}; self-pads unless it holds a {@link ModalBodyGroup}. */
21
38
  export declare const ModalBody: import("styled-components").StyledComponent<"div", any, {}, never>;
22
39
  /** Bottom action bar of a {@link Modal}, divided from the body; typically holds buttons. */
@@ -1,34 +1,40 @@
1
1
  import styled from 'styled-components';
2
- import { Color } from '@pushwoosh/kit-constants';
2
+ import { Color, UnitSize } from '@pushwoosh/kit-constants';
3
3
  import { Vertical } from '@pushwoosh/kit-helpers';
4
4
  /** Top section of a {@link Modal}; typically wraps a {@link ModalTitle}. */
5
- export const ModalHeader = styled.div.withConfig({
5
+ export const ModalHeader = styled(Vertical).attrs({
6
+ $gap: 8,
7
+ $padding: {
8
+ horizontal: UnitSize.POPUP_PADDING,
9
+ top: UnitSize.POPUP_PADDING,
10
+ bottom: 8
11
+ }
12
+ }).withConfig({
6
13
  displayName: "ModalHeader",
7
14
  componentId: "sc-1b5r517-0"
8
- })(["padding:24px 24px 8px;background-color:", ";"], Color.CLEAR);
15
+ })([""]);
9
16
  ModalHeader.displayName = 'ModalHeader';
10
17
  /** Groups {@link ModalBodyItem}s with hairline dividers between them, inside a {@link ModalBody}. */
11
18
  export const ModalBodyGroup = styled(Vertical).withConfig({
12
19
  displayName: "ModalBodyGroup",
13
20
  componentId: "sc-1b5r517-1"
14
- })(["background-color:", ";gap:1px;"], Color.DIVIDER);
21
+ })([""]);
15
22
  ModalBodyGroup.displayName = 'ModalBodyGroup';
16
- /** A single row within a {@link ModalBodyGroup}; pass `$vPadding` to add vertical padding. */
23
+ /** A single row within a {@link ModalBodyGroup}, divided from its siblings by hairlines. */
17
24
  export const ModalBodyItem = styled.div.withConfig({
18
25
  displayName: "ModalBodyItem",
19
26
  componentId: "sc-1b5r517-2"
20
- })(["padding:", " 24px;background-color:", ";"], ({
21
- $vPadding
22
- }) => $vPadding ? '24px' : 0, Color.CLEAR);
27
+ })(["padding:", ";&:not(:last-child){border-bottom:1px solid ", ";}", " > &:first-child{padding-top:0;}"], UnitSize.POPUP_PADDING, Color.DIVIDER, ModalBodyGroup);
28
+ ModalBodyItem.displayName = 'ModalBodyItem';
23
29
  /** Scrollable main content area of a {@link Modal}; self-pads unless it holds a {@link ModalBodyGroup}. */
24
30
  export const ModalBody = styled.div.withConfig({
25
31
  displayName: "ModalBody",
26
32
  componentId: "sc-1b5r517-3"
27
- })(["background-color:", ";overflow-y:auto;&:not(:has(> ", ")){padding:24px;&:not(:first-child){padding-top:0;}}"], Color.CLEAR, ModalBodyGroup);
33
+ })(["min-height:0;overflow-y:auto;overscroll-behavior:contain;&:not(:has(> ", ")){padding:", ";}", " + &{padding-top:0;}"], ModalBodyGroup, UnitSize.POPUP_PADDING, ModalHeader);
28
34
  ModalBody.displayName = 'ModalBody';
29
35
  /** Bottom action bar of a {@link Modal}, divided from the body; typically holds buttons. */
30
36
  export const ModalFooter = styled.div.withConfig({
31
37
  displayName: "ModalFooter",
32
38
  componentId: "sc-1b5r517-4"
33
- })(["padding:24px;background-color:", ";border-top:1px solid ", ";"], Color.CLEAR, Color.DIVIDER);
39
+ })(["padding:", ";border-top:1px solid ", ";"], UnitSize.POPUP_PADDING, Color.DIVIDER);
34
40
  ModalFooter.displayName = 'ModalFooter';
@@ -1,7 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { CloseIcon } from '@pushwoosh/kit-icons';
3
- import { ModalTitleBox } from './styles';
4
- import { GhostButton } from '../../../Button';
3
+ import { ModalTitleBox, ModalTitleClose, ModalTitleText } from './styles';
4
+ import { Button } from '../../../Button';
5
+ import { useLang } from '../../polyglot';
5
6
  /**
6
7
  * Modal heading row with an optional close button; place inside {@link ModalHeader}.
7
8
  *
@@ -14,12 +15,22 @@ export function ModalTitle(props) {
14
15
  onClose,
15
16
  ...rest
16
17
  } = props;
18
+ const lang = useLang();
17
19
  return _jsxs(ModalTitleBox, {
18
20
  ...rest,
19
- children: [children, onClose && _jsx(GhostButton, {
20
- onClick: onClose,
21
- children: _jsx(CloseIcon, {
22
- size: "medium"
21
+ children: [_jsx(ModalTitleText, {
22
+ children: children
23
+ }), onClose && _jsx(ModalTitleClose, {
24
+ children: _jsx(Button, {
25
+ color: "secondary",
26
+ view: "ghost",
27
+ onClick: onClose,
28
+ icon: _jsx(CloseIcon, {
29
+ size: "medium"
30
+ }),
31
+ "aria-label": lang({
32
+ message: 'DUMB.MODAL.CLOSE'
33
+ })
23
34
  })
24
35
  })]
25
36
  });
@@ -1 +1,21 @@
1
- export declare const ModalTitleBox: import("styled-components").StyledComponent<"h2", any, {}, never>;
1
+ import { H3 } from '@pushwoosh/kit-typography';
2
+ export declare const ModalTitleBox: import("styled-components").StyledComponent<typeof H3, any, {}, never>;
3
+ export declare const ModalTitleText: import("styled-components").StyledComponent<"span", any, {}, never>;
4
+ export declare const ModalTitleClose: import("styled-components").StyledComponent<"div", any, import("@pushwoosh/kit-helpers/styled-helpers").CommonBoxProps & {
5
+ $alignContent?: import("@pushwoosh/kit-helpers/styled-helpers").AlignContentValue;
6
+ $alignItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue;
7
+ $gap?: import("@pushwoosh/kit-helpers/styled-helpers").StrNum;
8
+ $justifyContent?: import("@pushwoosh/kit-helpers/styled-helpers").JustifyContentValue;
9
+ } & {
10
+ $flexDirection?: "row" | "row-reverse" | "column" | "column-reverse";
11
+ $flexWrap?: "nowrap" | "wrap" | "wrap-reverse";
12
+ } & {
13
+ $alignItems: string;
14
+ $justifyContent: string;
15
+ $shrink: number;
16
+ $width: number;
17
+ $height: number;
18
+ $margin: {
19
+ left: string;
20
+ };
21
+ }, "$height" | "$margin" | "$shrink" | "$width" | "$alignItems" | "$justifyContent">;
@@ -1,8 +1,29 @@
1
1
  import styled from 'styled-components';
2
- import { Color, FontSize, FontWeight } from '@pushwoosh/kit-constants';
3
- import { GhostButton } from '../../../Button';
4
- export const ModalTitleBox = styled.h2.withConfig({
2
+ import { FlexContainer } from '@pushwoosh/kit-helpers';
3
+ import { H3 } from '@pushwoosh/kit-typography';
4
+ const TITLE_GAP = '8px';
5
+ const CLOSE_BOX_SIZE = 24;
6
+ export const ModalTitleBox = styled(H3).withConfig({
5
7
  displayName: "ModalTitleBox",
6
8
  componentId: "sc-8qbijb-0"
7
- })(["display:flex;flex-wrap:nowrap;align-items:center;justify-content:space-between;font-size:", ";font-weight:", ";line-height:22px;letter-spacing:0;margin:0;", "{color:", ";cursor:pointer;&:hover{color:", ";}}"], FontSize.HEADING2, FontWeight.BOLD, GhostButton, Color.LOCKED, Color.MAIN);
8
- ModalTitleBox.displayName = 'ModalTitleBox';
9
+ })(["display:flex;align-items:center;gap:", ";"], TITLE_GAP);
10
+ ModalTitleBox.displayName = 'ModalTitleBox';
11
+ export const ModalTitleText = styled.span.withConfig({
12
+ displayName: "ModalTitleText",
13
+ componentId: "sc-8qbijb-1"
14
+ })(["flex:1 1 auto;min-width:0;display:flex;align-items:center;gap:", ";"], TITLE_GAP);
15
+ ModalTitleText.displayName = 'ModalTitleText';
16
+ export const ModalTitleClose = styled(FlexContainer).attrs({
17
+ $alignItems: 'center',
18
+ $justifyContent: 'center',
19
+ $shrink: 0,
20
+ $width: CLOSE_BOX_SIZE,
21
+ $height: CLOSE_BOX_SIZE,
22
+ $margin: {
23
+ left: 'auto'
24
+ }
25
+ }).withConfig({
26
+ displayName: "ModalTitleClose",
27
+ componentId: "sc-8qbijb-2"
28
+ })([""]);
29
+ ModalTitleClose.displayName = 'ModalTitleClose';
@@ -2,5 +2,6 @@ export const messages = {
2
2
  'DUMB.MODAL.UNEXPECTED_ERROR': 'حدث خطأ غير متوقع',
3
3
  'DUMB.MODAL.CONFIRM_TITLE': 'تأكيد الإجراء',
4
4
  'DUMB.MODAL.CONFIRM': 'تأكيد',
5
- 'DUMB.MODAL.CANCEL': 'إلغاء'
5
+ 'DUMB.MODAL.CANCEL': 'إلغاء',
6
+ 'DUMB.MODAL.CLOSE': 'إغلاق'
6
7
  };
@@ -2,5 +2,6 @@ export const messages = {
2
2
  'DUMB.MODAL.UNEXPECTED_ERROR': 'একটি অপ্রত্যাশিত ত্রুটি ঘটেছে',
3
3
  'DUMB.MODAL.CONFIRM_TITLE': 'ক্রিয়াটি নিশ্চিত করুন',
4
4
  'DUMB.MODAL.CONFIRM': 'নিশ্চিত করুন',
5
- 'DUMB.MODAL.CANCEL': 'বাতিল করুন'
5
+ 'DUMB.MODAL.CANCEL': 'বাতিল করুন',
6
+ 'DUMB.MODAL.CLOSE': 'বন্ধ করুন'
6
7
  };
@@ -2,5 +2,6 @@ export const messages = {
2
2
  'DUMB.MODAL.UNEXPECTED_ERROR': 'Ein unerwarteter Fehler ist aufgetreten',
3
3
  'DUMB.MODAL.CONFIRM_TITLE': 'Aktion bestätigen',
4
4
  'DUMB.MODAL.CONFIRM': 'Bestätigen',
5
- 'DUMB.MODAL.CANCEL': 'Abbrechen'
5
+ 'DUMB.MODAL.CANCEL': 'Abbrechen',
6
+ 'DUMB.MODAL.CLOSE': 'Schließen'
6
7
  };
@@ -2,5 +2,6 @@ export const messages = {
2
2
  'DUMB.MODAL.UNEXPECTED_ERROR': 'Unexpected error occurred',
3
3
  'DUMB.MODAL.CONFIRM_TITLE': 'Confirm action',
4
4
  'DUMB.MODAL.CONFIRM': 'Confirm',
5
- 'DUMB.MODAL.CANCEL': 'Cancel'
5
+ 'DUMB.MODAL.CANCEL': 'Cancel',
6
+ 'DUMB.MODAL.CLOSE': 'Close'
6
7
  };
@@ -2,5 +2,6 @@ export const messages = {
2
2
  'DUMB.MODAL.UNEXPECTED_ERROR': 'Se produjo un error inesperado',
3
3
  'DUMB.MODAL.CONFIRM_TITLE': 'Confirmar acción',
4
4
  'DUMB.MODAL.CONFIRM': 'Confirmar',
5
- 'DUMB.MODAL.CANCEL': 'Cancelar'
5
+ 'DUMB.MODAL.CANCEL': 'Cancelar',
6
+ 'DUMB.MODAL.CLOSE': 'Cerrar'
6
7
  };
@@ -2,5 +2,6 @@ export const messages = {
2
2
  'DUMB.MODAL.UNEXPECTED_ERROR': 'Une erreur inattendue s’est produite',
3
3
  'DUMB.MODAL.CONFIRM_TITLE': 'Confirmer l’action',
4
4
  'DUMB.MODAL.CONFIRM': 'Confirmer',
5
- 'DUMB.MODAL.CANCEL': 'Annuler'
5
+ 'DUMB.MODAL.CANCEL': 'Annuler',
6
+ 'DUMB.MODAL.CLOSE': 'Fermer'
6
7
  };
@@ -2,5 +2,6 @@ export const messages = {
2
2
  'DUMB.MODAL.UNEXPECTED_ERROR': 'אירעה שגיאה בלתי צפויה',
3
3
  'DUMB.MODAL.CONFIRM_TITLE': 'אישור פעולה',
4
4
  'DUMB.MODAL.CONFIRM': 'אישור',
5
- 'DUMB.MODAL.CANCEL': 'ביטול'
5
+ 'DUMB.MODAL.CANCEL': 'ביטול',
6
+ 'DUMB.MODAL.CLOSE': 'סגירה'
6
7
  };
@@ -2,5 +2,6 @@ export const messages = {
2
2
  'DUMB.MODAL.UNEXPECTED_ERROR': 'एक अप्रत्याशित त्रुटि हुई',
3
3
  'DUMB.MODAL.CONFIRM_TITLE': 'कार्रवाई की पुष्टि करें',
4
4
  'DUMB.MODAL.CONFIRM': 'पुष्टि करें',
5
- 'DUMB.MODAL.CANCEL': 'रद्द करें'
5
+ 'DUMB.MODAL.CANCEL': 'रद्द करें',
6
+ 'DUMB.MODAL.CLOSE': 'बंद करें'
6
7
  };
@@ -2,5 +2,6 @@ export const messages = {
2
2
  'DUMB.MODAL.UNEXPECTED_ERROR': '予期しないエラーが発生しました',
3
3
  'DUMB.MODAL.CONFIRM_TITLE': '操作の確認',
4
4
  'DUMB.MODAL.CONFIRM': '確認',
5
- 'DUMB.MODAL.CANCEL': 'キャンセル'
5
+ 'DUMB.MODAL.CANCEL': 'キャンセル',
6
+ 'DUMB.MODAL.CLOSE': '閉じる'
6
7
  };
@@ -2,5 +2,6 @@ export const messages = {
2
2
  'DUMB.MODAL.UNEXPECTED_ERROR': '예기치 않은 오류가 발생했습니다',
3
3
  'DUMB.MODAL.CONFIRM_TITLE': '작업 확인',
4
4
  'DUMB.MODAL.CONFIRM': '확인',
5
- 'DUMB.MODAL.CANCEL': '취소'
5
+ 'DUMB.MODAL.CANCEL': '취소',
6
+ 'DUMB.MODAL.CLOSE': '닫기'
6
7
  };
@@ -2,5 +2,6 @@ export const messages = {
2
2
  'DUMB.MODAL.UNEXPECTED_ERROR': 'Ocorreu um erro inesperado',
3
3
  'DUMB.MODAL.CONFIRM_TITLE': 'Confirmar ação',
4
4
  'DUMB.MODAL.CONFIRM': 'Confirmar',
5
- 'DUMB.MODAL.CANCEL': 'Cancelar'
5
+ 'DUMB.MODAL.CANCEL': 'Cancelar',
6
+ 'DUMB.MODAL.CLOSE': 'Fechar'
6
7
  };
@@ -2,5 +2,6 @@ export const messages = {
2
2
  'DUMB.MODAL.UNEXPECTED_ERROR': 'Произошла непредвиденная ошибка',
3
3
  'DUMB.MODAL.CONFIRM_TITLE': 'Подтвердите действие',
4
4
  'DUMB.MODAL.CONFIRM': 'Подтвердить',
5
- 'DUMB.MODAL.CANCEL': 'Отмена'
5
+ 'DUMB.MODAL.CANCEL': 'Отмена',
6
+ 'DUMB.MODAL.CLOSE': 'Закрыть'
6
7
  };
@@ -2,5 +2,6 @@ export const messages = {
2
2
  'DUMB.MODAL.UNEXPECTED_ERROR': 'เกิดข้อผิดพลาดที่ไม่คาดคิด',
3
3
  'DUMB.MODAL.CONFIRM_TITLE': 'ยืนยันการดำเนินการ',
4
4
  'DUMB.MODAL.CONFIRM': 'ยืนยัน',
5
- 'DUMB.MODAL.CANCEL': 'ยกเลิก'
5
+ 'DUMB.MODAL.CANCEL': 'ยกเลิก',
6
+ 'DUMB.MODAL.CLOSE': 'ปิด'
6
7
  };
@@ -2,5 +2,6 @@ export const messages = {
2
2
  'DUMB.MODAL.UNEXPECTED_ERROR': '发生了意外错误',
3
3
  'DUMB.MODAL.CONFIRM_TITLE': '确认操作',
4
4
  'DUMB.MODAL.CONFIRM': '确认',
5
- 'DUMB.MODAL.CANCEL': '取消'
5
+ 'DUMB.MODAL.CANCEL': '取消',
6
+ 'DUMB.MODAL.CLOSE': '关闭'
6
7
  };
@@ -4,4 +4,5 @@ export type ModalMessages = {
4
4
  'DUMB.MODAL.CONFIRM_TITLE': NoParams;
5
5
  'DUMB.MODAL.CONFIRM': NoParams;
6
6
  'DUMB.MODAL.CANCEL': NoParams;
7
+ 'DUMB.MODAL.CLOSE': NoParams;
7
8
  };
@@ -8,6 +8,7 @@ import { NativeRichMediaDim } from './components/NativeRichMediaDim';
8
8
  import { NativeRichMediaMuteChip } from './components/NativeRichMediaMuteChip';
9
9
  import { EDGE_INSET, clampIndex } from './helpers';
10
10
  import { parseNativeRichMediaConfig } from './parseNativeRichMediaConfig';
11
+ import { resolveLocalization } from './resolveLocalization';
11
12
  import { BackdropLayer, ContentFlow, PreviewHost, ScrollLayer, SpinnerLayer } from './styles';
12
13
  import { NativeRichMediaBannerView, NativeRichMediaCarouselView, NativeRichMediaFullscreenView, NativeRichMediaInvalidView, NativeRichMediaModalView, NativeRichMediaPipView, NativeRichMediaScratchcardView, NativeRichMediaSheetView, NativeRichMediaSpinwheelView, NativeRichMediaStoriesView, NativeRichMediaVideoView } from './views';
13
14
  import { GradientOverlay } from './views/shared/styles';
@@ -184,13 +185,21 @@ function renderConfig(config, activeIndex) {
184
185
  export function NativeRichMediaPreview(props) {
185
186
  const {
186
187
  content,
188
+ localization,
189
+ language,
187
190
  width,
188
191
  height,
189
192
  activeIndex = 0,
190
193
  isLoading = false,
191
194
  withBackground = true
192
195
  } = props;
193
- const config = useMemo(() => parseNativeRichMediaConfig(content), [content]);
196
+ const config = useMemo(() => {
197
+ const parsed = parseNativeRichMediaConfig(content);
198
+ if (!parsed) {
199
+ return null;
200
+ }
201
+ return parseNativeRichMediaConfig(resolveLocalization(parsed, localization, language));
202
+ }, [content, localization, language]);
194
203
  const shouldDim = !isLoading && dimsScreen(config);
195
204
  return _jsxs(PreviewHost, {
196
205
  width: width,
@@ -1,4 +1,4 @@
1
- export type { NativeRichMediaConfig, NativeRichMediaDisplayType, NativeRichMediaText, NativeRichMediaBorder, NativeRichMediaCover, NativeRichMediaAction, NativeRichMediaButton, NativeRichMediaReward, NativeRichMediaModalBlock, NativeRichMediaSheetBlock, NativeRichMediaCarouselBlock, NativeRichMediaStoriesBlock, NativeRichMediaBannerBlock, NativeRichMediaFullscreenBlock, NativeRichMediaVideoBlock, NativeRichMediaPipBlock, NativeRichMediaScratchcardBlock, NativeRichMediaSpinwheelBlock, NativeRichMediaPreviewProps, } from './types';
1
+ export type { NativeRichMediaConfig, NativeRichMediaDisplayType, NativeRichMediaText, NativeRichMediaBorder, NativeRichMediaCover, NativeRichMediaAction, NativeRichMediaButton, NativeRichMediaReward, NativeRichMediaModalBlock, NativeRichMediaSheetBlock, NativeRichMediaCarouselBlock, NativeRichMediaStoriesBlock, NativeRichMediaBannerBlock, NativeRichMediaFullscreenBlock, NativeRichMediaVideoBlock, NativeRichMediaPipBlock, NativeRichMediaScratchcardBlock, NativeRichMediaSpinwheelBlock, NativeRichMediaPreviewProps, NativeRichMediaLocalization, } from './types';
2
2
  export { NATIVE_RICH_MEDIA_DISPLAY_TYPES } from './types';
3
3
  export { parseNativeRichMediaConfig } from './parseNativeRichMediaConfig';
4
4
  export { NativeRichMediaPreview } from './NativeRichMediaPreview';
@@ -0,0 +1,9 @@
1
+ import type { NativeRichMediaConfig, NativeRichMediaLocalization } from './types';
2
+ /**
3
+ * Replaces every `{{key|type}}` (or `{{key|type|default}}`) placeholder in a
4
+ * parsed config with the text from `localization[language][key]`, falling back
5
+ * to the `default` bucket and then to the placeholder's default segment (or the
6
+ * key itself when it has none). Returns a new config; non-placeholder (already
7
+ * literal) values are copied through unchanged.
8
+ */
9
+ export declare function resolveLocalization(config: NativeRichMediaConfig, localization: NativeRichMediaLocalization | undefined, language: string | undefined): NativeRichMediaConfig;
@@ -0,0 +1,45 @@
1
+ const PLACEHOLDER_RE = /^\{\{([^|}]+)\|[^|}]*(?:\|([^}]*))?\}\}$/;
2
+ function resolveValue(value, localization, language) {
3
+ var _localization$languag, _localization$default;
4
+ const match = PLACEHOLDER_RE.exec(value);
5
+ if (!match) {
6
+ return value;
7
+ }
8
+ const key = match[1];
9
+ const fallback = match[2] ?? key;
10
+ const languageValue = language ? localization === null || localization === void 0 || (_localization$languag = localization[language]) === null || _localization$languag === void 0 ? void 0 : _localization$languag[key] : undefined;
11
+ if (typeof languageValue === 'string') {
12
+ return languageValue;
13
+ }
14
+ const defaultValue = localization === null || localization === void 0 || (_localization$default = localization.default) === null || _localization$default === void 0 ? void 0 : _localization$default[key];
15
+ if (typeof defaultValue === 'string') {
16
+ return defaultValue;
17
+ }
18
+ return fallback;
19
+ }
20
+ function resolveNode(node, localization, language) {
21
+ if (typeof node === 'string') {
22
+ return resolveValue(node, localization, language);
23
+ }
24
+ if (Array.isArray(node)) {
25
+ return node.map(item => resolveNode(item, localization, language));
26
+ }
27
+ if (node !== null && typeof node === 'object') {
28
+ const result = {};
29
+ Object.entries(node).forEach(([key, value]) => {
30
+ result[key] = resolveNode(value, localization, language);
31
+ });
32
+ return result;
33
+ }
34
+ return node;
35
+ }
36
+ /**
37
+ * Replaces every `{{key|type}}` (or `{{key|type|default}}`) placeholder in a
38
+ * parsed config with the text from `localization[language][key]`, falling back
39
+ * to the `default` bucket and then to the placeholder's default segment (or the
40
+ * key itself when it has none). Returns a new config; non-placeholder (already
41
+ * literal) values are copied through unchanged.
42
+ */
43
+ export function resolveLocalization(config, localization, language) {
44
+ return resolveNode(config, localization, language);
45
+ }
@@ -283,10 +283,20 @@ export type NativeRichMediaConfig = {
283
283
  export type NativeRichMediaDisplayType = NativeRichMediaConfig['displayType'];
284
284
  /** All supported {@link NativeRichMediaDisplayType} values. */
285
285
  export declare const NATIVE_RICH_MEDIA_DISPLAY_TYPES: NativeRichMediaDisplayType[];
286
+ /**
287
+ * Per-language text for `{{key|type|default}}` placeholders in the config:
288
+ * `{ [language]: { [key]: text } }`, plus a `default` bucket used as the
289
+ * fallback. Text lives here rather than inline in `content`.
290
+ */
291
+ export type NativeRichMediaLocalization = Record<string, Record<string, string>>;
286
292
  /** Props of {@link NativeRichMediaPreview}. */
287
293
  export type NativeRichMediaPreviewProps = {
288
294
  /** Rich media config, as an object or a JSON string. */
289
295
  content: string | NativeRichMediaConfig;
296
+ /** Per-language text for placeholders in `content`; when given, placeholders are resolved for `language` (falling back to `default`). */
297
+ localization?: NativeRichMediaLocalization;
298
+ /** Language code to resolve placeholders for; falls back to the `default` bucket. */
299
+ language?: string;
290
300
  /** Preview box width; number is treated as px. */
291
301
  width: string | number;
292
302
  /** Preview box height; number is treated as px. */
package/index.d.ts CHANGED
@@ -44,7 +44,7 @@ export { EnhancedInput, SearchInput } from './EnhancedInput';
44
44
  export { Chip, type ChipProps, type ChipVariant } from './Chip';
45
45
  export { RichmediaPreview, useRichmediaHtml } from './RichmediaPreview';
46
46
  export { NativeRichMediaPreview, parseNativeRichMediaConfig, NATIVE_RICH_MEDIA_DISPLAY_TYPES } from './NativeRichMediaPreview';
47
- export type { NativeRichMediaConfig, NativeRichMediaDisplayType, NativeRichMediaText, NativeRichMediaBorder, NativeRichMediaCover, NativeRichMediaAction, NativeRichMediaButton, NativeRichMediaReward, NativeRichMediaModalBlock, NativeRichMediaSheetBlock, NativeRichMediaCarouselBlock, NativeRichMediaStoriesBlock, NativeRichMediaBannerBlock, NativeRichMediaFullscreenBlock, NativeRichMediaVideoBlock, NativeRichMediaPipBlock, NativeRichMediaScratchcardBlock, NativeRichMediaSpinwheelBlock, NativeRichMediaPreviewProps, } from './NativeRichMediaPreview';
47
+ export type { NativeRichMediaConfig, NativeRichMediaDisplayType, NativeRichMediaText, NativeRichMediaBorder, NativeRichMediaCover, NativeRichMediaAction, NativeRichMediaButton, NativeRichMediaReward, NativeRichMediaModalBlock, NativeRichMediaSheetBlock, NativeRichMediaCarouselBlock, NativeRichMediaStoriesBlock, NativeRichMediaBannerBlock, NativeRichMediaFullscreenBlock, NativeRichMediaVideoBlock, NativeRichMediaPipBlock, NativeRichMediaScratchcardBlock, NativeRichMediaSpinwheelBlock, NativeRichMediaPreviewProps, NativeRichMediaLocalization, } from './NativeRichMediaPreview';
48
48
  export { RichMessageEditor, RichMessageViewer, type DynamicContent, } from './RichMessageEditor';
49
49
  export { FrequencyCappingEdit, FrequencyCappingReadonly, FrequencyCappingInApps, type LocalCapping, type CappingInAppBase, } from './FrequencyCapping';
50
50
  export { SendRateEdit, SendRateReadonly, type SendRateBase, type SendRateEditProps, type SendRateReadonlyProps, } from './SendRate';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.1.166",
3
+ "version": "1.1.168",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",