@steroidsjs/core 2.1.0-beta.2 → 2.1.0-beta.20

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.
Files changed (136) hide show
  1. package/actions/form.d.ts +9 -0
  2. package/actions/form.js +11 -1
  3. package/actions/list.d.ts +1 -0
  4. package/actions/list.js +1 -0
  5. package/components/ClientStorageComponent.d.ts +3 -3
  6. package/components/ClientStorageComponent.js +28 -22
  7. package/components/HttpComponent.js +32 -15
  8. package/components/LocaleComponent.js +9 -9
  9. package/components/MetricsComponent.js +3 -1
  10. package/components/StoreComponent.d.ts +6 -0
  11. package/components/StoreComponent.js +6 -7
  12. package/components/UiComponent.d.ts +1 -1
  13. package/components/WebSocketComponent.d.ts +1 -1
  14. package/hoc/components.d.ts +1 -1
  15. package/hoc/components.js +1 -1
  16. package/hoc/file.d.ts +1 -0
  17. package/hooks/index.d.ts +2 -1
  18. package/hooks/index.js +3 -1
  19. package/hooks/useAbsolutePositioning.d.ts +5 -0
  20. package/hooks/useAbsolutePositioning.js +6 -6
  21. package/hooks/useApplication.d.ts +29 -26
  22. package/hooks/useApplication.js +17 -82
  23. package/hooks/useComponents.d.ts +1 -14
  24. package/hooks/useComponents.js +5 -5
  25. package/hooks/useDataProvider.js +4 -2
  26. package/hooks/useDataSelect.d.ts +12 -6
  27. package/hooks/useDataSelect.js +5 -3
  28. package/hooks/useFetch.d.ts +11 -3
  29. package/hooks/useFetch.js +34 -31
  30. package/hooks/useFile.js +14 -2
  31. package/hooks/useLayout.d.ts +9 -0
  32. package/hooks/useLayout.js +64 -44
  33. package/hooks/useList.d.ts +45 -0
  34. package/hooks/useList.js +83 -53
  35. package/hooks/useModel.js +1 -1
  36. package/hooks/useScreen.d.ts +1 -1
  37. package/hooks/useScreen.js +2 -2
  38. package/hooks/useSsr.d.ts +2 -0
  39. package/hooks/useSsr.js +8 -0
  40. package/index.d.ts +8 -2
  41. package/package.json +6 -3
  42. package/providers/ComponentsProvider.d.ts +26 -0
  43. package/providers/ComponentsProvider.js +28 -0
  44. package/providers/ScreenProvider.d.ts +20 -0
  45. package/providers/ScreenProvider.js +87 -0
  46. package/providers/SsrProvider.d.ts +17 -0
  47. package/providers/SsrProvider.js +32 -0
  48. package/providers/index.d.ts +4 -0
  49. package/providers/index.js +12 -0
  50. package/reducers/form.d.ts +1 -1
  51. package/reducers/form.js +3 -1
  52. package/reducers/index.js +1 -1
  53. package/reducers/list.js +1 -3
  54. package/reducers/router.js +1 -1
  55. package/ui/content/Alert/Alert.d.ts +50 -0
  56. package/ui/content/Alert/Alert.js +39 -0
  57. package/ui/content/Alert/index.d.ts +2 -0
  58. package/ui/content/Alert/index.js +7 -0
  59. package/ui/content/Avatar/Avatar.d.ts +53 -12
  60. package/ui/content/Avatar/Avatar.js +25 -4
  61. package/ui/content/Avatar/index.d.ts +6 -1
  62. package/ui/content/Avatar/index.js +4 -0
  63. package/ui/content/Card/Card.d.ts +61 -13
  64. package/ui/content/Card/Card.js +3 -2
  65. package/ui/content/Collapse/Collapse.d.ts +63 -0
  66. package/ui/content/Collapse/Collapse.js +75 -0
  67. package/ui/content/Collapse/CollapseItem.d.ts +67 -0
  68. package/ui/content/Collapse/CollapseItem.js +22 -0
  69. package/ui/content/Collapse/index.d.ts +7 -0
  70. package/ui/content/Collapse/index.js +8 -0
  71. package/ui/content/Detail/Detail.d.ts +102 -0
  72. package/ui/content/Detail/Detail.js +155 -0
  73. package/ui/content/Detail/DetailItem.d.ts +43 -0
  74. package/ui/content/Detail/DetailItem.js +10 -0
  75. package/ui/content/Detail/demo/basic.d.ts +8 -0
  76. package/ui/content/Detail/demo/basic.js +56 -0
  77. package/ui/content/Detail/demo/controls.d.ts +8 -0
  78. package/ui/content/Detail/demo/controls.js +56 -0
  79. package/ui/content/Detail/demo/layout.d.ts +8 -0
  80. package/ui/content/Detail/demo/layout.js +56 -0
  81. package/ui/content/Detail/demo/responsive.d.ts +8 -0
  82. package/ui/content/Detail/demo/responsive.js +71 -0
  83. package/ui/content/Detail/demo/sizes.d.ts +8 -0
  84. package/ui/content/Detail/demo/sizes.js +61 -0
  85. package/ui/content/Detail/index.d.ts +3 -0
  86. package/ui/content/Detail/index.js +10 -0
  87. package/ui/content/DropDown/DropDown.d.ts +1 -0
  88. package/ui/content/DropDown/DropDown.js +1 -0
  89. package/ui/content/index.d.ts +13 -0
  90. package/ui/content/index.js +22 -0
  91. package/ui/crud/Crud/Crud.d.ts +1 -1
  92. package/ui/crud/Crud/Crud.js +1 -1
  93. package/ui/crud/index.d.ts +1 -0
  94. package/ui/form/Button/Button.d.ts +1 -0
  95. package/ui/form/Button/Button.js +1 -0
  96. package/ui/form/DateField/useDateInputState.d.ts +4 -0
  97. package/ui/form/DateField/useDateInputState.js +3 -3
  98. package/ui/form/DateField/useDateTime.js +9 -7
  99. package/ui/form/DateTimeField/DateTimeField.js +2 -1
  100. package/ui/form/DropDownField/DropDownField.js +10 -3
  101. package/ui/form/Form/Form.js +118 -106
  102. package/ui/form/ImageField/ImageField.d.ts +87 -0
  103. package/ui/form/ImageField/ImageField.js +145 -0
  104. package/ui/form/ImageField/index.d.ts +2 -0
  105. package/ui/form/ImageField/index.js +7 -0
  106. package/ui/form/InputField/InputField.d.ts +7 -0
  107. package/ui/form/InputField/InputField.js +26 -22
  108. package/ui/form/TextField/TextField.d.ts +2 -1
  109. package/ui/form/TextField/TextField.js +1 -1
  110. package/ui/icon/Icon/Icon.js +3 -0
  111. package/ui/layout/Meta/Meta.d.ts +56 -0
  112. package/ui/layout/Meta/Meta.js +38 -0
  113. package/ui/layout/Meta/index.d.ts +2 -0
  114. package/ui/layout/Meta/index.js +7 -0
  115. package/ui/layout/Notifications/Notifications.js +1 -1
  116. package/ui/layout/Portal.js +3 -0
  117. package/ui/layout/ProgressBar/ProgressBar.d.ts +55 -0
  118. package/ui/layout/ProgressBar/ProgressBar.js +52 -0
  119. package/ui/layout/ProgressBar/index.d.ts +2 -0
  120. package/ui/layout/ProgressBar/index.js +7 -0
  121. package/ui/layout/Skeleton/Skeleton.d.ts +25 -0
  122. package/ui/layout/Skeleton/Skeleton.js +11 -0
  123. package/ui/layout/Skeleton/index.d.ts +2 -0
  124. package/ui/layout/Skeleton/index.js +7 -0
  125. package/ui/list/Steps/Steps.d.ts +32 -0
  126. package/ui/list/Steps/Steps.js +23 -0
  127. package/ui/list/Steps/index.d.ts +2 -0
  128. package/ui/list/Steps/index.js +7 -0
  129. package/ui/nav/Router/Router.d.ts +13 -0
  130. package/ui/nav/Router/Router.js +1 -1
  131. package/utils/calendar.d.ts +1 -1
  132. package/utils/calendar.js +8 -1
  133. package/ui/content/Avatar/SizeContext.d.ts +0 -1
  134. package/ui/content/Avatar/SizeContext.js +0 -14
  135. package/ui/nav/Router/SsrProvider.d.ts +0 -15
  136. package/ui/nav/Router/SsrProvider.js +0 -55
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ interface IAlertProps {
3
+ view?: any;
4
+ className?: CssClassName;
5
+ /**
6
+ * Дочерние элементы
7
+ */
8
+ action?: React.ReactNode;
9
+ type: 'success' | 'info' | 'warning' | 'error' | string;
10
+ /** Основное сообщения Оповещения
11
+ * @example {'Sending is confirmed!'}
12
+ */
13
+ message: string;
14
+ /** Дополнительное содрежание сообщения.
15
+ * @example {'Please, check your email.'}
16
+ */
17
+ description?: string;
18
+ style?: React.CSSProperties;
19
+ showClose?: boolean;
20
+ showIcon?: boolean | string;
21
+ /**
22
+ * Callback функция вызываемая при нажатии на кнопку закрытия
23
+ * @example {() => console.log('this is callback')}
24
+ */
25
+ onClose?: () => void;
26
+ animation?: boolean;
27
+ /**
28
+ * Время анимации в миллисекундах
29
+ * @example {1000}
30
+ */
31
+ animationDuration?: number;
32
+ }
33
+ export interface IAlertViewProps extends IAlertProps {
34
+ isExist: boolean;
35
+ isVisible: boolean;
36
+ onClose: () => void;
37
+ onClick?: (e: MouseEvent) => void;
38
+ }
39
+ declare function Alert(props: IAlertProps): JSX.Element;
40
+ declare namespace Alert {
41
+ var defaultProps: {
42
+ type: string;
43
+ message: string;
44
+ showClose: boolean;
45
+ showIcon: boolean;
46
+ animation: boolean;
47
+ animationDuration: number;
48
+ };
49
+ }
50
+ export default Alert;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ exports.__esModule = true;
14
+ var react_1 = require("react");
15
+ var hooks_1 = require("@steroidsjs/core/hooks");
16
+ function Alert(props) {
17
+ var components = hooks_1.useComponents();
18
+ var _a = react_1.useState(true), isExist = _a[0], setIsExist = _a[1];
19
+ var _b = react_1.useState(true), isVisible = _b[0], setIsVisible = _b[1];
20
+ var onClose = react_1.useCallback(function () {
21
+ setIsVisible(false);
22
+ setTimeout(function () { return setIsExist(false); }, props.animationDuration);
23
+ if (props.onClose) {
24
+ props.onClose();
25
+ }
26
+ }, []);
27
+ return components.ui.renderView(props.view || 'content.AlertView', __assign(__assign({}, props), { isExist: isExist,
28
+ isVisible: isVisible,
29
+ onClose: onClose }));
30
+ }
31
+ Alert.defaultProps = {
32
+ type: 'success',
33
+ message: 'Message',
34
+ showClose: false,
35
+ showIcon: true,
36
+ animation: false,
37
+ animationDuration: 390
38
+ };
39
+ exports["default"] = Alert;
@@ -0,0 +1,2 @@
1
+ import Alert from './Alert';
2
+ export default Alert;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ exports.__esModule = true;
6
+ var Alert_1 = __importDefault(require("./Alert"));
7
+ exports["default"] = Alert_1["default"];
@@ -1,24 +1,65 @@
1
- import React from 'react';
2
1
  interface IAvatarProps {
3
- avatarUrl?: string;
4
- title?: string;
5
- src?: React.ReactNode;
6
- srcSet?: string;
2
+ /**
3
+ * Альтернативный текст для изображения
4
+ * @example {'default image'}
5
+ */
7
6
  alt?: string;
8
- size?: Size;
9
- shape?: 'circle' | 'square';
7
+ /**
8
+ * Дополнительный CSS-класс
9
+ */
10
10
  className?: CssClassName;
11
- view?: any;
12
- children?: React.ReactNode;
13
- style?: React.CSSProperties;
11
+ /**
12
+ * Дочерние элементы
13
+ */
14
+ children?: CustomView;
15
+ /**
16
+ * Размер аватара
17
+ * @example {'md'}
18
+ */
19
+ size?: Size | 'x-large' | number;
20
+ /**
21
+ * Форма аватара
22
+ * @example {'circle'}
23
+ */
24
+ shape?: 'circle' | 'square' | string;
25
+ /**
26
+ * Ссылка на изображение для аватара
27
+ * @example {'https://user/avatar.png'}
28
+ */
29
+ src?: string;
30
+ srcSet?: string;
31
+ /**
32
+ * Статус онлайна
33
+ * @example {true}
34
+ */
35
+ status?: boolean;
36
+ /**
37
+ * Объект CSS стилей
38
+ * @example {width: '30px'}
39
+ */
40
+ style?: CustomStyle;
41
+ /**
42
+ * Заголовок аватарки
43
+ * @example {'Avatar'}
44
+ */
45
+ title?: string;
46
+ /**
47
+ * Переопределение view React компонента для кастомизации отображения
48
+ * @example MyCustomView
49
+ */
50
+ view?: CustomView;
51
+ }
52
+ export interface IAvatarViewProps extends IAvatarProps {
53
+ isError: boolean;
54
+ onError: () => void;
55
+ formattedTitle: () => void;
14
56
  }
15
- export declare type IAvatarViewProps = IAvatarProps;
16
- export declare type Size = 'large' | 'medium' | 'small' | number;
17
57
  declare function Avatar(props: IAvatarProps): any;
18
58
  declare namespace Avatar {
19
59
  var defaultProps: {
20
60
  size: string;
21
61
  shape: string;
62
+ status: boolean;
22
63
  };
23
64
  }
24
65
  export default Avatar;
@@ -11,13 +11,34 @@ var __assign = (this && this.__assign) || function () {
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
13
  exports.__esModule = true;
14
- var hooks_1 = require("../../../hooks");
14
+ var react_1 = require("react");
15
+ var hooks_1 = require("@steroidsjs/core/hooks");
15
16
  function Avatar(props) {
16
17
  var components = hooks_1.useComponents();
17
- return components.ui.renderView(props.view || 'content.AvatarView', __assign({}, props));
18
+ var _a = react_1.useState(false), isError = _a[0], setIsError = _a[1];
19
+ var onError = react_1.useCallback(function () {
20
+ if (!isError) {
21
+ setIsError(true);
22
+ }
23
+ }, [isError]);
24
+ var formattedTitle = react_1.useMemo(function () {
25
+ var resultTitle = '';
26
+ if (props.title) {
27
+ var title = props.title.split(' ');
28
+ resultTitle = title[0][0].toUpperCase();
29
+ if (title.length > 1) {
30
+ resultTitle += title[1][0].toUpperCase();
31
+ }
32
+ }
33
+ return resultTitle;
34
+ }, [props.title]);
35
+ return components.ui.renderView(props.view || 'content.AvatarView', __assign(__assign({}, props), { isError: isError,
36
+ onError: onError,
37
+ formattedTitle: formattedTitle }));
18
38
  }
19
39
  Avatar.defaultProps = {
20
- size: 'medium',
21
- shape: 'circle'
40
+ size: 'middle',
41
+ shape: 'circle',
42
+ status: false
22
43
  };
23
44
  exports["default"] = Avatar;
@@ -1,3 +1,8 @@
1
1
  import Avatar from './Avatar';
2
2
  import AvatarGroup from './AvatarGroup';
3
- export { Avatar, AvatarGroup };
3
+ export { Avatar, AvatarGroup, };
4
+ declare const _default: {
5
+ Avatar: typeof Avatar;
6
+ AvatarGroup: typeof AvatarGroup;
7
+ };
8
+ export default _default;
@@ -8,3 +8,7 @@ var Avatar_1 = __importDefault(require("./Avatar"));
8
8
  exports.Avatar = Avatar_1["default"];
9
9
  var AvatarGroup_1 = __importDefault(require("./AvatarGroup"));
10
10
  exports.AvatarGroup = AvatarGroup_1["default"];
11
+ exports["default"] = {
12
+ Avatar: Avatar_1["default"],
13
+ AvatarGroup: AvatarGroup_1["default"]
14
+ };
@@ -1,24 +1,72 @@
1
- import React from 'react';
2
1
  interface ICardProps {
3
- view?: any;
4
- children?: React.ReactNode;
5
- title?: string;
6
- more?: React.ReactNode;
7
- bordered?: boolean | React.CSSProperties;
2
+ /**
3
+ * Цвет границы (если передать false, то граница будет скрыта)
4
+ * @example success
5
+ */
6
+ borderColor?: ColorName | 'default' | boolean;
7
+ /**
8
+ * Дополнительный CSS-класс
9
+ */
8
10
  className?: CssClassName;
9
- description?: React.ReactNode;
10
- cover?: React.ReactNode;
11
- actions?: React.ReactNode[];
12
- size?: Size;
11
+ /**
12
+ * Дочерние элементы
13
+ */
14
+ children?: CustomView;
15
+ /**
16
+ * Цвет состояния
17
+ * @example success
18
+ */
19
+ color?: ColorName;
20
+ /**
21
+ * Обложка для карточки, нужно передать ссылку на изображение
22
+ * @example 'https://cat/cat.png'
23
+ */
24
+ cover?: string;
25
+ /**
26
+ * Описание карточки
27
+ * @example {'Scroll to see more...'}
28
+ */
29
+ description?: string;
30
+ /**
31
+ * Текст для header
32
+ */
33
+ header?: string;
34
+ /**
35
+ * Текст для footer
36
+ */
37
+ footer?: string;
38
+ /**
39
+ * Ориентация карточки, горизонтальная и вертикальная
40
+ * @example {'vertical-reverse'}
41
+ */
42
+ orientation?: 'vertical' | 'vertical-reverse' | 'horizontal';
43
+ /**
44
+ * Ориентация карточки, горизонтальная и вертикальная
45
+ * @example {'vertical-reverse'}
46
+ */
13
47
  shape?: 'square' | 'circle';
14
- style?: React.CSSProperties;
48
+ /**
49
+ * Объект CSS стилей
50
+ * @example {width: '30px'}
51
+ */
52
+ style?: CustomStyle;
53
+ /**
54
+ * Заголовок карточки
55
+ * @example {'Main card'}
56
+ */
57
+ title?: string;
58
+ /**
59
+ * Переопределение view React компонента для кастомизации отображения
60
+ * @example MyCustomView
61
+ */
62
+ view?: CustomView;
15
63
  }
16
64
  export declare type ICardViewProps = ICardProps;
17
- export declare type Size = 'large' | 'medium' | 'small';
18
65
  declare function Card(props: ICardProps): any;
19
66
  declare namespace Card {
20
67
  var defaultProps: {
21
- size: string;
68
+ borderColor: string;
69
+ orientation: string;
22
70
  shape: string;
23
71
  };
24
72
  }
@@ -11,13 +11,14 @@ var __assign = (this && this.__assign) || function () {
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
13
  exports.__esModule = true;
14
- var hooks_1 = require("../../../hooks");
14
+ var hooks_1 = require("@steroidsjs/core/hooks");
15
15
  function Card(props) {
16
16
  var components = hooks_1.useComponents();
17
17
  return components.ui.renderView(props.view || 'content.CardView', __assign({}, props));
18
18
  }
19
19
  Card.defaultProps = {
20
- size: 'medium',
20
+ borderColor: 'default',
21
+ orientation: 'vertical',
21
22
  shape: 'circle'
22
23
  };
23
24
  exports["default"] = Card;
@@ -0,0 +1,63 @@
1
+ import * as React from 'react';
2
+ interface ICollapseProps {
3
+ view?: any;
4
+ style?: React.CSSProperties;
5
+ children?: any;
6
+ /**
7
+ * Дополнительный CSS-класс
8
+ */
9
+ className?: CssClassName;
10
+ /**
11
+ * @example {true}
12
+ */
13
+ disabled?: boolean;
14
+ /**
15
+ * Кастомная иконка svg или название иконки
16
+ * @example {'circle'}
17
+ */
18
+ icon?: React.ReactNode | string;
19
+ /**
20
+ * Показ иконки, которая показывает состояние CollapseItem. Поумолчанию включены.
21
+ * @example {false}
22
+ */
23
+ showIcon?: boolean;
24
+ /**
25
+ * Позиция иконки-индикатора
26
+ * @example {'left'}
27
+ */
28
+ iconPosition?: 'left' | 'right';
29
+ /**
30
+ * Включает режим Аккордиона (только один CollapseItem может быть открыт)
31
+ * @example {true}
32
+ */
33
+ isAccordion?: boolean;
34
+ /**
35
+ * Номер активного CollapseItem, который может меняться динамический или быть статичным
36
+ * @example
37
+ */
38
+ activeKey?: number;
39
+ /**
40
+ * Вызываемая функция при каждом изменении состояния
41
+ * @example {() => {console.log('success')}}
42
+ */
43
+ onChange?: () => void;
44
+ /**
45
+ * Отключение внешних рамок
46
+ * @example {true}
47
+ */
48
+ borderless?: boolean;
49
+ }
50
+ export interface ICollapseViewProps extends ICollapseProps {
51
+ toggleCollapse: (number: any) => void;
52
+ toggleAccordion: (number: any) => void;
53
+ childIndex: number;
54
+ isShowMore?: boolean;
55
+ }
56
+ declare function Collapse(props: ICollapseProps): JSX.Element;
57
+ declare namespace Collapse {
58
+ var defaultProps: {
59
+ iconPosition: string;
60
+ showIcon: boolean;
61
+ };
62
+ }
63
+ export default Collapse;
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || function (mod) {
26
+ if (mod && mod.__esModule) return mod;
27
+ var result = {};
28
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
+ __setModuleDefault(result, mod);
30
+ return result;
31
+ };
32
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
33
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
34
+ to[j] = from[i];
35
+ return to;
36
+ };
37
+ exports.__esModule = true;
38
+ var React = __importStar(require("react"));
39
+ var hooks_1 = require("@steroidsjs/core/hooks");
40
+ function Collapse(props) {
41
+ var _a = React.useState([]), state = _a[0], setState = _a[1];
42
+ React.useEffect(props.onChange, [state]);
43
+ var toggleCollapse = function (indexSelected) {
44
+ if (state.includes(indexSelected)) {
45
+ var newState = __spreadArray([], state);
46
+ var indexInArray = state.indexOf(indexSelected);
47
+ newState.splice(indexInArray, 1);
48
+ setState(newState);
49
+ }
50
+ else {
51
+ var newState = __spreadArray([], state);
52
+ newState.push(indexSelected);
53
+ setState(newState);
54
+ }
55
+ };
56
+ var toggleAccordion = function (indexSelected) {
57
+ if (state.includes(indexSelected)) {
58
+ setState([]);
59
+ }
60
+ else {
61
+ var newState = [];
62
+ newState.push(indexSelected);
63
+ setState(newState);
64
+ }
65
+ };
66
+ var components = hooks_1.useComponents();
67
+ var CollapseView = components.ui.getView(props.view || 'content.CollapseView');
68
+ return (React.createElement(CollapseView, __assign({}, props), React.Children.map(props.children, function (child, index) { return React.cloneElement(child, __assign({ activeKey: props.activeKey, isAccordion: props.isAccordion, childIndex: index, toggleAccordion: toggleAccordion,
69
+ toggleCollapse: toggleCollapse, isShowMore: (state || []).includes(index), showIcon: props.showIcon, iconPosition: props.iconPosition, borderless: props.borderless }, child.props)); })));
70
+ }
71
+ Collapse.defaultProps = {
72
+ iconPosition: 'right',
73
+ showIcon: true
74
+ };
75
+ exports["default"] = Collapse;
@@ -0,0 +1,67 @@
1
+ import * as React from 'react';
2
+ interface ICollapseItemProps {
3
+ view?: any;
4
+ style?: React.CSSProperties;
5
+ children?: any;
6
+ /**
7
+ * Дополнительный CSS-класс
8
+ */
9
+ className?: CssClassName;
10
+ /**
11
+ * Название CollapseItem
12
+ * @example {'Подробнее'}
13
+ */
14
+ title?: string;
15
+ /**
16
+ * @example {true}
17
+ */
18
+ disabled?: boolean;
19
+ /**
20
+ * Кастомная иконка svg или название иконки
21
+ * @example {'circle'}
22
+ */
23
+ icon?: React.ReactNode | string;
24
+ /**
25
+ * Показ иконки, которая показывает состояние CollapseItem. Поумолчанию включены.
26
+ * @example {false}
27
+ */
28
+ showIcon?: boolean;
29
+ /**
30
+ * Позиция иконки-индикатора
31
+ * @example {'left'}
32
+ */
33
+ iconPosition?: 'left' | 'right';
34
+ /**
35
+ * Включает режим Аккордиона (только один CollapseItem может быть открыт)
36
+ * @example {true}
37
+ */
38
+ isAccordion?: boolean;
39
+ /**
40
+ * Номер активного CollapseItem, который может меняться динамический или быть статичным
41
+ * @example
42
+ */
43
+ activeKey?: number;
44
+ /**
45
+ * Вызываемая функция при каждом изменении состояния
46
+ * @example {() => {console.log('success')}}
47
+ */
48
+ onChange?: () => void;
49
+ /**
50
+ * Отключение внешних рамок
51
+ * @example {true}
52
+ */
53
+ borderless?: boolean;
54
+ }
55
+ export interface ICollapseItemViewProps extends ICollapseItemProps {
56
+ toggleCollapse?: (number: any) => void;
57
+ toggleAccordion?: (number: any) => void;
58
+ childIndex?: number;
59
+ isShowMore?: boolean;
60
+ }
61
+ declare function CollapseItem(props: ICollapseItemProps): any;
62
+ declare namespace CollapseItem {
63
+ var defaultProps: {
64
+ title: string;
65
+ };
66
+ }
67
+ export default CollapseItem;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ exports.__esModule = true;
14
+ var hooks_1 = require("@steroidsjs/core/hooks");
15
+ function CollapseItem(props) {
16
+ var components = hooks_1.useComponents();
17
+ return components.ui.renderView(props.view || 'content.CollapseItemView', __assign({}, props));
18
+ }
19
+ CollapseItem.defaultProps = {
20
+ title: 'Collapse'
21
+ };
22
+ exports["default"] = CollapseItem;
@@ -0,0 +1,7 @@
1
+ import CollapseItem from './CollapseItem';
2
+ import Collapse from './Collapse';
3
+ declare const _default: {
4
+ CollapseItem: typeof CollapseItem;
5
+ Collapse: typeof Collapse;
6
+ };
7
+ export default _default;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ exports.__esModule = true;
6
+ var CollapseItem_1 = __importDefault(require("./CollapseItem"));
7
+ var Collapse_1 = __importDefault(require("./Collapse"));
8
+ exports["default"] = { CollapseItem: CollapseItem_1["default"], Collapse: Collapse_1["default"] };