@snack-uikit/modal 0.10.2 → 0.10.3-preview-b7b8cddc.0

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/README.md CHANGED
@@ -66,6 +66,7 @@
66
66
  | cancelButton | `Omit<ButtonOutlineProps, "data-test-id" \| "size">` | - | Кнопка отмены |
67
67
  | additionalButton | `Omit<ButtonSimpleProps, "data-test-id" \| "size">` | - | Вторая кнопка действия |
68
68
  | disclaimer | `{ text: string; link?: Pick<LinkProps, "text" \| "href" \| "target" \| "external">; }` | - | Небольшой текст под кнопками футера с возможностью передать дополнительно ссылку |
69
+ | truncate | `{ title?: number; subtitle?: number; }` | '{ <br>title: 1; <br>subtitle: 2; }' | Максимальное кол-во строк <br> - `title` - в заголовке <br> - `subtitle` - в подзаголовке |
69
70
  | size | "s" \| "m" \| "l" | s | Размер |
70
71
  | align | enum Align: `"vertical"`, `"default"`, `"center"` | default | Выравнивание, для разных размеров доступны разные значения <br> для size=`s` - все <br> для size=`m` - align=`default \| center` <br> для size=`l` - align=`default` |
71
72
  | picture | `JSXElementConstructor<{ size?: number; className?: string; }> \| ModalHeaderImage` | - | Можно передать иконку из пакета `@snack-uikit/icon-predefined`, или путь к картинке и атрибут `alt` |
@@ -1,3 +1,3 @@
1
1
  import { ModalLProps, ModalMProps, ModalSProps } from './types';
2
2
  export type ModalProps = ModalSProps | ModalMProps | ModalLProps;
3
- export declare function Modal({ open, onClose, size, mode, align, title, titleTooltip, subtitle, picture: pictureProp, content, approveButton, cancelButton, additionalButton, disclaimer, className, ...rest }: ModalProps): import("react/jsx-runtime").JSX.Element;
3
+ export declare function Modal({ open, onClose, size, mode, align, title, titleTooltip, subtitle, picture: pictureProp, content, approveButton, cancelButton, additionalButton, disclaimer, truncate, className, ...rest }: ModalProps): import("react/jsx-runtime").JSX.Element;
@@ -19,9 +19,9 @@ import { getAlignProps, getButtonsSize, getPicture } from '../../utils';
19
19
  import { ModalCustom } from '../ModalCustom';
20
20
  import styles from './styles.module.css';
21
21
  export function Modal(_a) {
22
- var { open, onClose, size = SIZE.S, mode = MODE.Regular, align = ALIGN.Default, title, titleTooltip, subtitle, picture: pictureProp, content, approveButton, cancelButton, additionalButton, disclaimer, className } = _a, rest = __rest(_a, ["open", "onClose", "size", "mode", "align", "title", "titleTooltip", "subtitle", "picture", "content", "approveButton", "cancelButton", "additionalButton", "disclaimer", "className"]);
22
+ var { open, onClose, size = SIZE.S, mode = MODE.Regular, align = ALIGN.Default, title, titleTooltip, subtitle, picture: pictureProp, content, approveButton, cancelButton, additionalButton, disclaimer, truncate, className } = _a, rest = __rest(_a, ["open", "onClose", "size", "mode", "align", "title", "titleTooltip", "subtitle", "picture", "content", "approveButton", "cancelButton", "additionalButton", "disclaimer", "truncate", "className"]);
23
23
  const aligns = getAlignProps({ align, size });
24
24
  const buttonsSize = getButtonsSize({ align, size });
25
25
  const picture = getPicture({ size, picture: pictureProp });
26
- return (_jsxs(ModalCustom, Object.assign({ open: open, onClose: onClose, size: size, mode: mode, className: className }, rest, { children: [_jsx(ModalCustom.Header, { title: _jsx(TruncateString, { text: title }), titleTooltip: titleTooltip, subtitle: subtitle, picture: picture, align: aligns.header }), Boolean(content) && _jsx(ModalCustom.Body, { content: content, align: aligns.body }), _jsx(ModalCustom.Footer, { actions: _jsxs(_Fragment, { children: [_jsx(ButtonFilled, Object.assign({}, approveButton, { size: buttonsSize, className: styles.footerButton, "data-test-id": TEST_IDS.approveButton })), cancelButton && (_jsx(ButtonOutline, Object.assign({}, cancelButton, { size: buttonsSize, className: styles.footerButton, "data-test-id": TEST_IDS.cancelButton }))), additionalButton && (_jsx(ButtonSimple, Object.assign({}, additionalButton, { size: buttonsSize, className: styles.footerButton, "data-test-id": TEST_IDS.additionalButton })))] }), disclaimer: disclaimer && (_jsxs(_Fragment, { children: [_jsx(Typography.SansBodyS, { "data-test-id": TEST_IDS.disclaimerText, children: disclaimer.text }), disclaimer.link && (_jsx(Link, Object.assign({ external: true }, disclaimer.link, { size: 's', "data-test-id": TEST_IDS.disclaimerLink })))] })), align: aligns.footer, className: styles.modalFooter })] })));
26
+ return (_jsxs(ModalCustom, Object.assign({ open: open, onClose: onClose, size: size, mode: mode, className: className }, rest, { children: [_jsx(ModalCustom.Header, { title: _jsx(TruncateString, { text: title, maxLines: (truncate === null || truncate === void 0 ? void 0 : truncate.title) || 1 }), titleTooltip: titleTooltip, subtitle: subtitle ? _jsx(TruncateString, { text: subtitle, maxLines: (truncate === null || truncate === void 0 ? void 0 : truncate.subtitle) || 2 }) : undefined, picture: picture, align: aligns.header }), Boolean(content) && _jsx(ModalCustom.Body, { content: content, align: aligns.body }), _jsx(ModalCustom.Footer, { actions: _jsxs(_Fragment, { children: [_jsx(ButtonFilled, Object.assign({ appearance: 'primary' }, approveButton, { size: buttonsSize, className: styles.footerButton, "data-test-id": TEST_IDS.approveButton })), cancelButton && (_jsx(ButtonOutline, Object.assign({ appearance: 'neutral' }, cancelButton, { size: buttonsSize, className: styles.footerButton, "data-test-id": TEST_IDS.cancelButton }))), additionalButton && (_jsx(ButtonSimple, Object.assign({ appearance: 'neutral' }, additionalButton, { size: buttonsSize, className: styles.footerButton, "data-test-id": TEST_IDS.additionalButton })))] }), disclaimer: disclaimer && (_jsxs(_Fragment, { children: [_jsx(Typography.SansBodyS, { "data-test-id": TEST_IDS.disclaimerText, children: disclaimer.text }), disclaimer.link && (_jsx(Link, Object.assign({ external: true }, disclaimer.link, { size: 's', "data-test-id": TEST_IDS.disclaimerLink })))] })), align: aligns.footer, className: styles.modalFooter })] })));
27
27
  }
@@ -24,6 +24,16 @@ type BaseModalProps = Omit<ModalCustomProps, 'children' | 'size'> & {
24
24
  text: string;
25
25
  link?: Pick<LinkProps, 'text' | 'href' | 'target' | 'external'>;
26
26
  };
27
+ /**
28
+ * Максимальное кол-во строк
29
+ * <br> - `title` - в заголовке
30
+ * <br> - `subtitle` - в подзаголовке
31
+ * @default '{ <br>title: 1; <br>subtitle: 2; }'
32
+ */
33
+ truncate?: {
34
+ title?: number;
35
+ subtitle?: number;
36
+ };
27
37
  };
28
38
  export type ModalSProps = BaseModalProps & {
29
39
  /** Размер */
@@ -17,5 +17,5 @@ import { CONTENT_ALIGN, TEST_IDS } from '../../constants';
17
17
  import styles from './styles.module.css';
18
18
  export function ModalBody(_a) {
19
19
  var { content, align = CONTENT_ALIGN.Default, className } = _a, rest = __rest(_a, ["content", "align", "className"]);
20
- return (_jsx(Scroll, Object.assign({ size: 'm', className: cn(styles.modalBody, className) }, extractSupportProps(rest), { "data-align": align, "data-test-id": TEST_IDS.content, children: content })));
20
+ return (_jsx(Scroll, Object.assign({ size: 'm', barHideStrategy: 'never', className: cn(styles.modalBody, className) }, extractSupportProps(rest), { "data-align": align, "data-test-id": TEST_IDS.content, children: content })));
21
21
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Modal",
7
- "version": "0.10.2",
7
+ "version": "0.10.3-preview-b7b8cddc.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -47,5 +47,5 @@
47
47
  "devDependencies": {
48
48
  "@types/react-modal": "3.16.0"
49
49
  },
50
- "gitHead": "a24da7478c0b00f3e60d821466c31b2e9d57a719"
50
+ "gitHead": "51fcb0a1cb316542cb346cf07448b9acf6fb9215"
51
51
  }
@@ -26,6 +26,7 @@ export function Modal({
26
26
  cancelButton,
27
27
  additionalButton,
28
28
  disclaimer,
29
+ truncate,
29
30
  className,
30
31
  ...rest
31
32
  }: ModalProps) {
@@ -36,9 +37,9 @@ export function Modal({
36
37
  return (
37
38
  <ModalCustom open={open} onClose={onClose} size={size} mode={mode} className={className} {...rest}>
38
39
  <ModalCustom.Header
39
- title={<TruncateString text={title} />}
40
+ title={<TruncateString text={title} maxLines={truncate?.title || 1} />}
40
41
  titleTooltip={titleTooltip}
41
- subtitle={subtitle}
42
+ subtitle={subtitle ? <TruncateString text={subtitle} maxLines={truncate?.subtitle || 2} /> : undefined}
42
43
  picture={picture}
43
44
  align={aligns.header}
44
45
  />
@@ -49,6 +50,7 @@ export function Modal({
49
50
  actions={
50
51
  <>
51
52
  <ButtonFilled
53
+ appearance='primary'
52
54
  {...approveButton}
53
55
  size={buttonsSize}
54
56
  className={styles.footerButton}
@@ -57,6 +59,7 @@ export function Modal({
57
59
 
58
60
  {cancelButton && (
59
61
  <ButtonOutline
62
+ appearance='neutral'
60
63
  {...cancelButton}
61
64
  size={buttonsSize}
62
65
  className={styles.footerButton}
@@ -66,6 +69,7 @@ export function Modal({
66
69
 
67
70
  {additionalButton && (
68
71
  <ButtonSimple
72
+ appearance='neutral'
69
73
  {...additionalButton}
70
74
  size={buttonsSize}
71
75
  className={styles.footerButton}
@@ -26,6 +26,16 @@ type BaseModalProps = Omit<ModalCustomProps, 'children' | 'size'> & {
26
26
  text: string;
27
27
  link?: Pick<LinkProps, 'text' | 'href' | 'target' | 'external'>;
28
28
  };
29
+ /**
30
+ * Максимальное кол-во строк
31
+ * <br> - `title` - в заголовке
32
+ * <br> - `subtitle` - в подзаголовке
33
+ * @default '{ <br>title: 1; <br>subtitle: 2; }'
34
+ */
35
+ truncate?: {
36
+ title?: number;
37
+ subtitle?: number;
38
+ };
29
39
  };
30
40
 
31
41
  export type ModalSProps = BaseModalProps & {
@@ -20,6 +20,7 @@ export function ModalBody({ content, align = CONTENT_ALIGN.Default, className, .
20
20
  return (
21
21
  <Scroll
22
22
  size='m'
23
+ barHideStrategy='never'
23
24
  className={cn(styles.modalBody, className)}
24
25
  {...extractSupportProps(rest)}
25
26
  data-align={align}