@tecsinapse/react-native-kit 1.12.4 → 1.12.8

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 (43) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/components/atoms/BottomNavigator/styled.js +4 -2
  3. package/dist/components/atoms/BottomNavigator/styled.js.map +1 -1
  4. package/dist/components/atoms/Input/styled.js +1 -1
  5. package/dist/components/atoms/Input/styled.js.map +1 -1
  6. package/dist/components/atoms/Modal/ModalGroupManager.d.ts +4 -0
  7. package/dist/components/atoms/Modal/ModalGroupManager.js +41 -0
  8. package/dist/components/atoms/Modal/ModalGroupManager.js.map +1 -0
  9. package/dist/components/atoms/Modal/ModalLifecycleHandler.d.ts +23 -0
  10. package/dist/components/atoms/Modal/ModalLifecycleHandler.js +110 -0
  11. package/dist/components/atoms/Modal/ModalLifecycleHandler.js.map +1 -0
  12. package/dist/components/atoms/Modal/index.d.ts +5 -0
  13. package/dist/components/atoms/Modal/index.js +71 -0
  14. package/dist/components/atoms/Modal/index.js.map +1 -0
  15. package/dist/components/atoms/Modal/ui/BaseModalView.d.ts +3 -0
  16. package/dist/components/atoms/Modal/ui/BaseModalView.js +140 -0
  17. package/dist/components/atoms/Modal/ui/BaseModalView.js.map +1 -0
  18. package/dist/components/atoms/Modal/ui/styled.d.ts +6 -0
  19. package/dist/components/atoms/Modal/ui/styled.js +38 -0
  20. package/dist/components/atoms/Modal/ui/styled.js.map +1 -0
  21. package/dist/components/atoms/Modal/ui/types.d.ts +9 -0
  22. package/dist/components/atoms/Modal/ui/types.js +6 -0
  23. package/dist/components/atoms/Modal/ui/types.js.map +1 -0
  24. package/dist/components/atoms/Modal/useModalManager.d.ts +6 -0
  25. package/dist/components/atoms/Modal/useModalManager.js +35 -0
  26. package/dist/components/atoms/Modal/useModalManager.js.map +1 -0
  27. package/dist/components/atoms/Select/styled.js +2 -2
  28. package/dist/components/atoms/Select/styled.js.map +1 -1
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.js +38 -1
  31. package/dist/index.js.map +1 -1
  32. package/package.json +9 -4
  33. package/src/components/atoms/BottomNavigator/styled.ts +3 -3
  34. package/src/components/atoms/Input/styled.ts +3 -2
  35. package/src/components/atoms/Modal/ModalGroupManager.tsx +28 -0
  36. package/src/components/atoms/Modal/ModalLifecycleHandler.ts +141 -0
  37. package/src/components/atoms/Modal/index.ts +5 -0
  38. package/src/components/atoms/Modal/ui/BaseModalView.tsx +127 -0
  39. package/src/components/atoms/Modal/ui/styled.ts +23 -0
  40. package/src/components/atoms/Modal/ui/types.ts +12 -0
  41. package/src/components/atoms/Modal/useModalManager.ts +35 -0
  42. package/src/components/atoms/Select/styled.ts +4 -3
  43. package/src/index.ts +1 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,38 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.12.8](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-native-kit@1.12.7...@tecsinapse/react-native-kit@1.12.8) (2022-01-05)
7
+
8
+ **Note:** Version bump only for package @tecsinapse/react-native-kit
9
+
10
+
11
+
12
+
13
+
14
+ ## [1.12.7](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-native-kit@1.12.6...@tecsinapse/react-native-kit@1.12.7) (2022-01-04)
15
+
16
+ **Note:** Version bump only for package @tecsinapse/react-native-kit
17
+
18
+
19
+
20
+
21
+
22
+ ## [1.12.6](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-native-kit@1.12.5...@tecsinapse/react-native-kit@1.12.6) (2021-12-29)
23
+
24
+ **Note:** Version bump only for package @tecsinapse/react-native-kit
25
+
26
+
27
+
28
+
29
+
30
+ ## [1.12.5](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-native-kit@1.12.4...@tecsinapse/react-native-kit@1.12.5) (2021-12-29)
31
+
32
+ **Note:** Version bump only for package @tecsinapse/react-native-kit
33
+
34
+
35
+
36
+
37
+
6
38
  ## [1.12.4](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-native-kit@1.12.3...@tecsinapse/react-native-kit@1.12.4) (2021-12-23)
7
39
 
8
40
  **Note:** Version bump only for package @tecsinapse/react-native-kit
@@ -7,6 +7,8 @@ exports.CustomTabContent = exports.TabContent = exports.TabContainer = exports.S
7
7
 
8
8
  var _native = _interopRequireDefault(require("@emotion/native"));
9
9
 
10
+ var _reactCore = require("@tecsinapse/react-core");
11
+
10
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
13
 
12
14
  const StyledView = _native.default.View`
@@ -33,7 +35,7 @@ const TabContainer = _native.default.Pressable`
33
35
  }) => theme.spacing.deca};
34
36
  border-top-width: ${({
35
37
  selected
36
- }) => selected ? '2px' : 0};
38
+ }) => selected ? (0, _reactCore.RFValueStr)('2px') : 0};
37
39
  border-color: ${({
38
40
  theme
39
41
  }) => theme.color.primary.medium};
@@ -45,7 +47,7 @@ const TabContent = _native.default.View`
45
47
  aspect-ratio: 1;
46
48
  justify-content: center;
47
49
  align-items: center;
48
- min-height: 48px;
50
+ min-height: ${(0, _reactCore.RFValueStr)('48px')};
49
51
  background-color: ${({
50
52
  theme
51
53
  }) => theme.color.primary.xlight};
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/atoms/BottomNavigator/styled.ts"],"names":["StyledView","styled","View","theme","spacing","deca","kilo","miscellaneous","surfaceColor","TabContainer","Pressable","mili","selected","color","primary","medium","TabContent","xlight","borderRadius","CustomTabContent"],"mappings":";;;;;;;AAAA;;;;AAIO,MAAMA,UAAU,GAAGC,gBAAOC,IAAsC;AACvE;AACA;AACA,wBAAwB,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,OAAN,CAAcC,IAAK;AAC1D,oBAAoB,CAAC;AAAEF,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,OAAN,CAAcE,IAAK;AACtD,sBAAsB,CAAC;AAAEH,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACI,aAAN,CAAoBC,YAAa;AACtE,CANO;;AAQA,MAAMC,YAAY,GAAGR,gBAAOS,SAEjC;AACF;AACA,uBAAuB,CAAC;AAAEP,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,OAAN,CAAcO,IAAK;AACzD,iBAAiB,CAAC;AAAER,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,OAAN,CAAcC,IAAK;AACnD,sBAAsB,CAAC;AAAEO,EAAAA;AAAF,CAAD,KAAmBA,QAAQ,GAAG,KAAH,GAAW,CAAG;AAC/D,kBAAkB,CAAC;AAAET,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACU,KAAN,CAAYC,OAAZ,CAAoBC,MAAO;AAC5D;AACA;AACA,CAVO;;AAYA,MAAMC,UAAU,GAAGf,gBAAOC,IAAsC;AACvE;AACA;AACA;AACA;AACA,sBAAsB,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACU,KAAN,CAAYC,OAAZ,CAAoBG,MAAO;AAChE,mBAAmB,CAAC;AAAEd,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACe,YAAN,CAAmB,MAAnB,CAA2B;AAC7D,CAPO;;AASA,MAAMC,gBAAgB,GAAGlB,gBAAOC,IAAsC,EAAtE","sourcesContent":["import styled from '@emotion/native';\nimport { StyleProps } from '@tecsinapse/react-core';\nimport { PressableProps, ViewProps } from 'react-native';\n\nexport const StyledView = styled.View<ViewProps & Partial<StyleProps>>`\n flex-direction: row;\n justify-content: space-between;\n padding-horizontal: ${({ theme }) => theme.spacing.deca};\n padding-bottom: ${({ theme }) => theme.spacing.kilo};\n background-color: ${({ theme }) => theme.miscellaneous.surfaceColor};\n`;\n\nexport const TabContainer = styled.Pressable<\n { selected: boolean } & PressableProps & Partial<StyleProps>\n>`\n flex: 1;\n margin-horizontal: ${({ theme }) => theme.spacing.mili};\n padding-top: ${({ theme }) => theme.spacing.deca};\n border-top-width: ${({ selected }) => (selected ? '2px' : 0)};\n border-color: ${({ theme }) => theme.color.primary.medium};\n align-items: center;\n justify-content: flex-end;\n`;\n\nexport const TabContent = styled.View<ViewProps & Partial<StyleProps>>`\n aspect-ratio: 1;\n justify-content: center;\n align-items: center;\n min-height: 48px;\n background-color: ${({ theme }) => theme.color.primary.xlight};\n border-radius: ${({ theme }) => theme.borderRadius['mili']};\n`;\n\nexport const CustomTabContent = styled.View<ViewProps & Partial<StyleProps>>``;\n"],"file":"styled.js"}
1
+ {"version":3,"sources":["../../../../src/components/atoms/BottomNavigator/styled.ts"],"names":["StyledView","styled","View","theme","spacing","deca","kilo","miscellaneous","surfaceColor","TabContainer","Pressable","mili","selected","color","primary","medium","TabContent","xlight","borderRadius","CustomTabContent"],"mappings":";;;;;;;AAAA;;AACA;;;;AAGO,MAAMA,UAAU,GAAGC,gBAAOC,IAAsC;AACvE;AACA;AACA,wBAAwB,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,OAAN,CAAcC,IAAK;AAC1D,oBAAoB,CAAC;AAAEF,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,OAAN,CAAcE,IAAK;AACtD,sBAAsB,CAAC;AAAEH,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACI,aAAN,CAAoBC,YAAa;AACtE,CANO;;AAQA,MAAMC,YAAY,GAAGR,gBAAOS,SAEjC;AACF;AACA,uBAAuB,CAAC;AAAEP,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,OAAN,CAAcO,IAAK;AACzD,iBAAiB,CAAC;AAAER,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,OAAN,CAAcC,IAAK;AACnD,sBAAsB,CAAC;AAAEO,EAAAA;AAAF,CAAD,KAAmBA,QAAQ,GAAG,2BAAW,KAAX,CAAH,GAAuB,CAAG;AAC3E,kBAAkB,CAAC;AAAET,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACU,KAAN,CAAYC,OAAZ,CAAoBC,MAAO;AAC5D;AACA;AACA,CAVO;;AAYA,MAAMC,UAAU,GAAGf,gBAAOC,IAAsC;AACvE;AACA;AACA;AACA,gBAAgB,2BAAW,MAAX,CAAmB;AACnC,sBAAsB,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACU,KAAN,CAAYC,OAAZ,CAAoBG,MAAO;AAChE,mBAAmB,CAAC;AAAEd,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACe,YAAN,CAAmB,MAAnB,CAA2B;AAC7D,CAPO;;AASA,MAAMC,gBAAgB,GAAGlB,gBAAOC,IAAsC,EAAtE","sourcesContent":["import styled from '@emotion/native';\nimport { RFValueStr, StyleProps } from '@tecsinapse/react-core';\nimport { PressableProps, ViewProps } from 'react-native';\n\nexport const StyledView = styled.View<ViewProps & Partial<StyleProps>>`\n flex-direction: row;\n justify-content: space-between;\n padding-horizontal: ${({ theme }) => theme.spacing.deca};\n padding-bottom: ${({ theme }) => theme.spacing.kilo};\n background-color: ${({ theme }) => theme.miscellaneous.surfaceColor};\n`;\n\nexport const TabContainer = styled.Pressable<\n { selected: boolean } & PressableProps & Partial<StyleProps>\n>`\n flex: 1;\n margin-horizontal: ${({ theme }) => theme.spacing.mili};\n padding-top: ${({ theme }) => theme.spacing.deca};\n border-top-width: ${({ selected }) => (selected ? RFValueStr('2px') : 0)};\n border-color: ${({ theme }) => theme.color.primary.medium};\n align-items: center;\n justify-content: flex-end;\n`;\n\nexport const TabContent = styled.View<ViewProps & Partial<StyleProps>>`\n aspect-ratio: 1;\n justify-content: center;\n align-items: center;\n min-height: ${RFValueStr('48px')};\n background-color: ${({ theme }) => theme.color.primary.xlight};\n border-radius: ${({ theme }) => theme.borderRadius['mili']};\n`;\n\nexport const CustomTabContent = styled.View<ViewProps & Partial<StyleProps>>``;\n"],"file":"styled.js"}
@@ -14,7 +14,7 @@ var _styled = require("../Text/styled");
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
16
  const StyledInputContainer = (0, _native.default)(_reactCore.InputContainer)`
17
- min-height: 50px;
17
+ min-height: ${(0, _reactCore.RFValueStr)('50px')};
18
18
  `;
19
19
  exports.StyledInputContainer = StyledInputContainer;
20
20
  const StyledNativeInputBase = (0, _native.default)(_reactCore.InputElement)`
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/atoms/Input/styled.ts"],"names":["StyledInputContainer","InputContainer","StyledNativeInputBase","InputElement","theme","typography","h5","lineHeight","StyledNativeInput","fontStyles"],"mappings":";;;;;;;AAAA;;AACA;;AAKA;;;;AAGO,MAAMA,oBAAoB,GAAG,qBAAOC,yBAAP,CAA4C;AAChF;AACA,CAFO;;AAIP,MAAMC,qBAAqB,GAAG,qBAAOC,uBAAP,CAE5B;AACF,YAAY,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,UAAN,CAAiBC,EAAjB,CAAoBC,UAAW;AAC1D;AACA;AACA,CANA;AAQO,MAAMC,iBAAiB,GAAG,qBAAON,qBAAP,EAE/BO,kBAF+B,CAA1B","sourcesContent":["import styled from '@emotion/native';\nimport {\n InputContainer,\n InputElement,\n StyleProps,\n} from '@tecsinapse/react-core';\nimport { Font, fontStyles } from '../Text/styled';\nimport { InputNativeProps } from './Input';\n\nexport const StyledInputContainer = styled(InputContainer)<Partial<StyleProps>>`\n min-height: 50px;\n`;\n\nconst StyledNativeInputBase = styled(InputElement)<\n Partial<InputNativeProps> & Partial<StyleProps>\n>`\n height: ${({ theme }) => theme.typography.h5.lineHeight};\n width: 100%;\n padding: 0;\n`;\n\nexport const StyledNativeInput = styled(StyledNativeInputBase)<\n Font & Partial<InputNativeProps> & Partial<StyleProps>\n>(fontStyles);\n"],"file":"styled.js"}
1
+ {"version":3,"sources":["../../../../src/components/atoms/Input/styled.ts"],"names":["StyledInputContainer","InputContainer","StyledNativeInputBase","InputElement","theme","typography","h5","lineHeight","StyledNativeInput","fontStyles"],"mappings":";;;;;;;AAAA;;AACA;;AAMA;;;;AAGO,MAAMA,oBAAoB,GAAG,qBAAOC,yBAAP,CAA4C;AAChF,gBAAgB,2BAAW,MAAX,CAAmB;AACnC,CAFO;;AAIP,MAAMC,qBAAqB,GAAG,qBAAOC,uBAAP,CAE5B;AACF,YAAY,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,UAAN,CAAiBC,EAAjB,CAAoBC,UAAW;AAC1D;AACA;AACA,CANA;AAQO,MAAMC,iBAAiB,GAAG,qBAAON,qBAAP,EAE/BO,kBAF+B,CAA1B","sourcesContent":["import styled from '@emotion/native';\nimport {\n InputContainer,\n InputElement,\n RFValueStr,\n StyleProps\n} from '@tecsinapse/react-core';\nimport { Font, fontStyles } from '../Text/styled';\nimport { InputNativeProps } from './Input';\n\nexport const StyledInputContainer = styled(InputContainer)<Partial<StyleProps>>`\n min-height: ${RFValueStr('50px')};\n`;\n\nconst StyledNativeInputBase = styled(InputElement)<\n Partial<InputNativeProps> & Partial<StyleProps>\n>`\n height: ${({ theme }) => theme.typography.h5.lineHeight};\n width: 100%;\n padding: 0;\n`;\n\nexport const StyledNativeInput = styled(StyledNativeInputBase)<\n Font & Partial<InputNativeProps> & Partial<StyleProps>\n>(fontStyles);\n"],"file":"styled.js"}
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ import { ModalProps } from 'react-native';
3
+ export declare const modalLifecycle: import("./ModalLifecycleHandler").ModalLifecycleHandler;
4
+ export declare const ModalGroupManager: FC<ModalProps>;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ModalGroupManager = exports.modalLifecycle = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ var _ModalLifecycleHandler = require("./ModalLifecycleHandler");
13
+
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
+
16
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
+
18
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
19
+
20
+ const modalLifecycle = (0, _ModalLifecycleHandler.createModalLifecycleHandler)();
21
+ exports.modalLifecycle = modalLifecycle;
22
+
23
+ const ModalGroupManager = ({
24
+ children,
25
+ ...others
26
+ }) => {
27
+ modalLifecycle.attach((0, _react.useState)([]));
28
+
29
+ const _render = modalLifecycle.render();
30
+
31
+ const hasModals = _render.length > 0;
32
+ return _react.default.createElement(_react.default.Fragment, null, children, _react.default.createElement(_reactNative.Modal, _extends({
33
+ transparent: true,
34
+ statusBarTranslucent: true,
35
+ animationType: "none",
36
+ visible: hasModals
37
+ }, others), _render));
38
+ };
39
+
40
+ exports.ModalGroupManager = ModalGroupManager;
41
+ //# sourceMappingURL=ModalGroupManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/atoms/Modal/ModalGroupManager.tsx"],"names":["modalLifecycle","ModalGroupManager","children","others","attach","_render","render","hasModals","length"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;;;AAGO,MAAMA,cAAc,GAAG,yDAAvB;;;AAQA,MAAMC,iBAAiC,GAAG,CAAC;AAAEC,EAAAA,QAAF;AAAY,KAAGC;AAAf,CAAD,KAA6B;AAE1EH,EAAAA,cAAc,CAACI,MAAf,CAAsB,qBAAqC,EAArC,CAAtB;;AACA,QAAMC,OAAO,GAAGL,cAAc,CAACM,MAAf,EAAhB;;AACA,QAAMC,SAAS,GAAGF,OAAO,CAACG,MAAR,GAAiB,CAAnC;AAEA,SACI,4DACKN,QADL,EAEI,6BAAC,kBAAD;AAAS,IAAA,WAAW,MAApB;AAAqB,IAAA,oBAAoB,MAAzC;AAA0C,IAAA,aAAa,EAAC,MAAxD;AAA+D,IAAA,OAAO,EAAEK;AAAxE,KAAuFJ,MAAvF,GACKE,OADL,CAFJ,CADJ;AAQH,CAdM","sourcesContent":["import React, { FC, ReactElement, useState } from 'react';\nimport { Modal as RNModal, ModalProps } from 'react-native';\nimport { createModalLifecycleHandler } from './ModalLifecycleHandler';\nimport { IBaseModal } from './ui/types';\n\nexport const modalLifecycle = createModalLifecycleHandler()\n\n/**\n * It's responsable for rendering all the modal components.\n * \n * @param param0 \n * @returns \n */\nexport const ModalGroupManager: FC<ModalProps> = ({ children, ...others }) => {\n\n modalLifecycle.attach(useState<ReactElement<IBaseModal>[]>([]))\n const _render = modalLifecycle.render()\n const hasModals = _render.length > 0\n \n return (\n <>\n {children}\n <RNModal transparent statusBarTranslucent animationType='none' visible={hasModals} {...others}>\n {_render}\n </RNModal>\n </>\n )\n}\n"],"file":"ModalGroupManager.js"}
@@ -0,0 +1,23 @@
1
+ import { Dispatch, ReactElement } from "react";
2
+ import { IBaseModal } from "./ui/types";
3
+ interface ModalNode {
4
+ id: string;
5
+ visible?: boolean;
6
+ lastVisualization?: Date;
7
+ modal: () => ReactElement<IBaseModal>;
8
+ }
9
+ export declare class ModalLifecycleHandler {
10
+ nodeGroup: Map<string, ModalNode>;
11
+ state: [ReactElement<IBaseModal>[], Dispatch<ReactElement<IBaseModal>[]>] | undefined;
12
+ constructor();
13
+ attach: (state: [ReactElement<IBaseModal>[], Dispatch<ReactElement<IBaseModal>[]>]) => void;
14
+ update: () => void;
15
+ render: () => ReactElement<IBaseModal>[];
16
+ sync: (id: string, modal: () => ReactElement<IBaseModal>) => void;
17
+ destroy: (id: string) => void;
18
+ private remove;
19
+ show: (id: string) => void;
20
+ close: (id: string) => void;
21
+ }
22
+ export declare const createModalLifecycleHandler: () => ModalLifecycleHandler;
23
+ export {};
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createModalLifecycleHandler = exports.ModalLifecycleHandler = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
+
14
+ class ModalLifecycleHandler {
15
+ constructor() {
16
+ _defineProperty(this, "attach", state => {
17
+ this.state = state;
18
+ });
19
+
20
+ _defineProperty(this, "update", () => {
21
+ const nodes = Array.from(this.nodeGroup.values()).filter(node => node.visible || !!node.lastVisualization).sort((nodeA, nodeB) => {
22
+ var _nodeA$lastVisualizat, _nodeB$lastVisualizat;
23
+
24
+ return (((_nodeA$lastVisualizat = nodeA.lastVisualization) === null || _nodeA$lastVisualizat === void 0 ? void 0 : _nodeA$lastVisualizat.getTime()) || 0) - (((_nodeB$lastVisualizat = nodeB.lastVisualization) === null || _nodeB$lastVisualizat === void 0 ? void 0 : _nodeB$lastVisualizat.getTime()) || 0);
25
+ }).map((node, index, filteredNodes) => {
26
+ let modalElement = node.modal();
27
+ let {
28
+ props
29
+ } = modalElement;
30
+ return _react.default.cloneElement(modalElement, { ...props,
31
+ key: node.id,
32
+ visible: node.visible,
33
+ isLastShown: filteredNodes.length - 1 === index,
34
+ close: () => this.close(node.id),
35
+ onClose: () => {
36
+ var _props$onClose;
37
+
38
+ this.remove(node.id);
39
+ (_props$onClose = props.onClose) === null || _props$onClose === void 0 ? void 0 : _props$onClose.call(props);
40
+ }
41
+ });
42
+ });
43
+ const [, updateState] = this.state || [];
44
+ updateState === null || updateState === void 0 ? void 0 : updateState(nodes);
45
+ });
46
+
47
+ _defineProperty(this, "render", () => {
48
+ const [modals] = this.state || [];
49
+ return modals || [];
50
+ });
51
+
52
+ _defineProperty(this, "sync", (id, modal) => {
53
+ if (this.nodeGroup.has(id)) {
54
+ const savedNode = this.nodeGroup.get(id);
55
+ savedNode && this.nodeGroup.set(id, { ...savedNode,
56
+ modal
57
+ });
58
+ return;
59
+ }
60
+
61
+ this.nodeGroup.set(id, {
62
+ id,
63
+ modal
64
+ });
65
+ });
66
+
67
+ _defineProperty(this, "destroy", id => {
68
+ this.nodeGroup.delete(id);
69
+ this.update();
70
+ });
71
+
72
+ _defineProperty(this, "remove", id => {
73
+ const savedNode = this.nodeGroup.get(id);
74
+ savedNode && this.nodeGroup.set(id, { ...savedNode,
75
+ lastVisualization: undefined
76
+ });
77
+ this.update();
78
+ });
79
+
80
+ _defineProperty(this, "show", id => {
81
+ const savedNode = this.nodeGroup.get(id);
82
+ savedNode && this.nodeGroup.set(id, { ...savedNode,
83
+ visible: true,
84
+ lastVisualization: new Date()
85
+ });
86
+ this.update();
87
+ });
88
+
89
+ _defineProperty(this, "close", id => {
90
+ const savedNode = this.nodeGroup.get(id);
91
+ savedNode && this.nodeGroup.set(id, { ...savedNode,
92
+ visible: false
93
+ });
94
+ this.update();
95
+ });
96
+
97
+ this.nodeGroup = new Map();
98
+ this.state = undefined;
99
+ }
100
+
101
+ }
102
+
103
+ exports.ModalLifecycleHandler = ModalLifecycleHandler;
104
+
105
+ const createModalLifecycleHandler = () => {
106
+ return new ModalLifecycleHandler();
107
+ };
108
+
109
+ exports.createModalLifecycleHandler = createModalLifecycleHandler;
110
+ //# sourceMappingURL=ModalLifecycleHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/atoms/Modal/ModalLifecycleHandler.ts"],"names":["ModalLifecycleHandler","constructor","state","nodes","Array","from","nodeGroup","values","filter","node","visible","lastVisualization","sort","nodeA","nodeB","getTime","map","index","filteredNodes","modalElement","modal","props","React","cloneElement","key","id","isLastShown","length","close","onClose","remove","updateState","modals","has","savedNode","get","set","delete","update","undefined","Date","Map","createModalLifecycleHandler"],"mappings":";;;;;;;AAAA;;;;;;AAgBO,MAAMA,qBAAN,CAA4B;AAK/BC,EAAAA,WAAW,GAAG;AAAA,oCAUGC,KAAD,IAA+E;AAC3F,WAAKA,KAAL,GAAaA,KAAb;AACH,KAZa;;AAAA,oCAiBE,MAAM;AAClB,YAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAW,KAAKC,SAAL,CAAeC,MAAf,EAAX,EACTC,MADS,CACFC,IAAI,IAAIA,IAAI,CAACC,OAAL,IAAgB,CAAC,CAACD,IAAI,CAACE,iBAD7B,EAETC,IAFS,CAEJ,CAACC,KAAD,EAAQC,KAAR;AAAA;;AAAA,eAAkB,CAAC,0BAAAD,KAAK,CAACF,iBAAN,gFAAyBI,OAAzB,OAAsC,CAAvC,KAA6C,0BAAAD,KAAK,CAACH,iBAAN,gFAAyBI,OAAzB,OAAsC,CAAnF,CAAlB;AAAA,OAFI,EAGTC,GAHS,CAGL,CAACP,IAAD,EAAOQ,KAAP,EAAcC,aAAd,KAAgC;AACjC,YAAIC,YAAY,GAAGV,IAAI,CAACW,KAAL,EAAnB;AACA,YAAI;AAAEC,UAAAA;AAAF,YAAYF,YAAhB;AACA,eAAOG,eAAMC,YAAN,CAAmBJ,YAAnB,EAAiC,EACpC,GAAGE,KADiC;AAEpCG,UAAAA,GAAG,EAAEf,IAAI,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L;AACH,KA3Ea;;AAAA,oCAmFIb,EAAD,IAAgB;AAC7B,YAAMS,SAAS,GAAG,KAAK5B,SAAL,CAAe6B,GAAf,CAAmBV,EAAnB,CAAlB;AACAS,MAAAA,SAAS,IAAI,KAAK5B,SAAL,CAAe8B,GAAf,CAAmBX,EAAnB,EAAuB,EAAE,GAAGS,SAAL;AAAgBvB,QAAAA,iBAAiB,EAAE4B;AAAnC,OAAvB,CAAb;AACA,WAAKD,MAAL;AACH,KAvFa;;AAAA,kCA8FCb,EAAD,IAAgB;AAC1B,YAAMS,SAAS,GAAG,KAAK5B,SAAL,CAAe6B,GAAf,CAAmBV,EAAnB,CAAlB;AACAS,MAAAA,SAAS,IAAI,KAAK5B,SAAL,CAAe8B,GAAf,CAAmBX,EAAnB,EAAuB,EAAE,GAAGS,SAAL;AAAgBxB,QAAAA,OAAO,EAAE,IAAzB;AAA+BC,QAAAA,iBAAiB,EAAE,IAAI6B,IAAJ;AAAlD,OAAvB,CAAb;AACA,WAAKF,MAAL;AACH,KAlGa;;AAAA,mCAyGEb,EAAD,IAAgB;AAC3B,YAAMS,SAAS,GAAG,KAAK5B,SAAL,CAAe6B,GAAf,CAAmBV,EAAnB,CAAlB;AACAS,MAAAA,SAAS,IAAI,KAAK5B,SAAL,CAAe8B,GAAf,CAAmBX,EAAnB,EAAuB,EAAE,GAAGS,SAAL;AAAgBxB,QAAAA,OAAO,EAAE;AAAzB,OAAvB,CAAb;AACA,WAAK4B,MAAL;AACH,KA7Ga;;AACV,SAAKhC,SAAL,GAAiB,IAAImC,GAAJ,EAAjB;AACA,SAAKvC,KAAL,GAAaqC,SAAb;AACH;;AAR8B;;;;AA0H5B,MAAMG,2BAA2B,GAAG,MAAM;AAC7C,SAAO,IAAI1C,qBAAJ,EAAP;AACH,CAFM","sourcesContent":["import React, { Dispatch, ReactElement } from \"react\"\nimport { IBaseModal } from \"./ui/types\"\n\n/**\n * It Represents a node (usually a modal component) in the modal's lifecycle handler.\n */\ninterface ModalNode {\n id: string\n visible?: boolean\n lastVisualization?: Date\n modal: () => ReactElement<IBaseModal>\n}\n\n/**\n * Manage all modal's lifecycle.\n */\nexport class ModalLifecycleHandler {\n \n nodeGroup: Map<string, ModalNode>\n state: [ReactElement<IBaseModal>[], Dispatch<ReactElement<IBaseModal>[]>] | undefined\n\n constructor() {\n this.nodeGroup = new Map()\n this.state = undefined\n }\n\n /**\n * Holds the ModalGroupManager state.\n * \n * @param state \n */\n public attach = (state: [ReactElement<IBaseModal>[], Dispatch<ReactElement<IBaseModal>[]>]) => {\n this.state = state\n }\n\n /**\n * Updates all the modal components.\n */\n public update = () => {\n const nodes = Array.from(this.nodeGroup.values())\n .filter(node => node.visible || !!node.lastVisualization)\n .sort((nodeA, nodeB) => (nodeA.lastVisualization?.getTime() || 0) - (nodeB.lastVisualization?.getTime() || 0))\n .map((node, index, filteredNodes) => {\n let modalElement = node.modal()\n let { props } = modalElement\n return React.cloneElement(modalElement, {\n ...props,\n key: node.id,\n visible: node.visible,\n isLastShown: filteredNodes.length - 1 === index,\n close: () => this.close(node.id),\n onClose: () => {\n this.remove(node.id)\n props.onClose?.()\n }\n })\n })\n \n const [, updateState ] = this.state || []\n updateState?.(nodes)\n }\n\n /**\n * Renders all selected modals.\n * \n * @returns \n */\n public render = (): ReactElement<IBaseModal>[] => {\n const [ modals ] = this.state || []\n return modals || []\n }\n\n /**\n * Tells to the lifecycle handler that a modal component needs to be handled.\n * \n * @param id \n * @param modal \n * @returns \n */\n public sync = (id: string, modal: () => ReactElement<IBaseModal>) => {\n if (this.nodeGroup.has(id)) {\n const savedNode = this.nodeGroup.get(id)\n savedNode && this.nodeGroup.set(id, { ...savedNode, modal })\n return\n }\n this.nodeGroup.set(id, { id, modal })\n }\n\n /**\n * Destroy a modal from the lifecycle handler.\n * \n * @param id \n */\n public destroy = (id: string) => {\n this.nodeGroup.delete(id)\n this.update()\n }\n\n /**\n * Removes a modal from the rendering stack. It tells to the lifecycle handler that a modal \n * component is no longer used by the application.\n * \n * @param id \n */\n private remove = (id: string) => {\n const savedNode = this.nodeGroup.get(id)\n savedNode && this.nodeGroup.set(id, { ...savedNode, lastVisualization: undefined })\n this.update()\n }\n\n /**\n * Makes a modal appears.\n * \n * @param id \n */\n public show = (id: string) => {\n const savedNode = this.nodeGroup.get(id)\n savedNode && this.nodeGroup.set(id, { ...savedNode, visible: true, lastVisualization: new Date() })\n this.update()\n }\n\n /**\n * Makes a modal disappears.\n * \n * @param id \n */\n public close = (id: string) => {\n const savedNode = this.nodeGroup.get(id)\n savedNode && this.nodeGroup.set(id, { ...savedNode, visible: false })\n this.update()\n }\n}\n\n/**\n * Creates a new ModalLifecycleHandlere instance.\n * \n * @returns \n */\nexport const createModalLifecycleHandler = () => {\n return new ModalLifecycleHandler()\n}\n"],"file":"ModalLifecycleHandler.js"}
@@ -0,0 +1,5 @@
1
+ export * from './ModalGroupManager';
2
+ export * from './ModalLifecycleHandler';
3
+ export * from './ui/BaseModalView';
4
+ export * from './ui/types';
5
+ export * from './useModalManager';
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _ModalGroupManager = require("./ModalGroupManager");
8
+
9
+ Object.keys(_ModalGroupManager).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _ModalGroupManager[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _ModalGroupManager[key];
16
+ }
17
+ });
18
+ });
19
+
20
+ var _ModalLifecycleHandler = require("./ModalLifecycleHandler");
21
+
22
+ Object.keys(_ModalLifecycleHandler).forEach(function (key) {
23
+ if (key === "default" || key === "__esModule") return;
24
+ if (key in exports && exports[key] === _ModalLifecycleHandler[key]) return;
25
+ Object.defineProperty(exports, key, {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _ModalLifecycleHandler[key];
29
+ }
30
+ });
31
+ });
32
+
33
+ var _BaseModalView = require("./ui/BaseModalView");
34
+
35
+ Object.keys(_BaseModalView).forEach(function (key) {
36
+ if (key === "default" || key === "__esModule") return;
37
+ if (key in exports && exports[key] === _BaseModalView[key]) return;
38
+ Object.defineProperty(exports, key, {
39
+ enumerable: true,
40
+ get: function () {
41
+ return _BaseModalView[key];
42
+ }
43
+ });
44
+ });
45
+
46
+ var _types = require("./ui/types");
47
+
48
+ Object.keys(_types).forEach(function (key) {
49
+ if (key === "default" || key === "__esModule") return;
50
+ if (key in exports && exports[key] === _types[key]) return;
51
+ Object.defineProperty(exports, key, {
52
+ enumerable: true,
53
+ get: function () {
54
+ return _types[key];
55
+ }
56
+ });
57
+ });
58
+
59
+ var _useModalManager = require("./useModalManager");
60
+
61
+ Object.keys(_useModalManager).forEach(function (key) {
62
+ if (key === "default" || key === "__esModule") return;
63
+ if (key in exports && exports[key] === _useModalManager[key]) return;
64
+ Object.defineProperty(exports, key, {
65
+ enumerable: true,
66
+ get: function () {
67
+ return _useModalManager[key];
68
+ }
69
+ });
70
+ });
71
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/atoms/Modal/index.ts"],"names":[],"mappings":";;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export * from './ModalGroupManager'\nexport * from './ModalLifecycleHandler'\nexport * from './ui/BaseModalView'\nexport * from './ui/types'\nexport * from './useModalManager'"],"file":"index.js"}
@@ -0,0 +1,3 @@
1
+ import { FC } from "react";
2
+ import { IBaseModal } from "./types";
3
+ export declare const ModalView: FC<IBaseModal>;
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ModalView = void 0;
7
+
8
+ var _reactCore = require("@tecsinapse/react-core");
9
+
10
+ var _react = _interopRequireWildcard(require("react"));
11
+
12
+ var _reactNative = require("react-native");
13
+
14
+ var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
15
+
16
+ var _styled = require("./styled");
17
+
18
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
+
20
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
+
22
+ const BACKDROP_ALPHA = .65;
23
+ const INTERPOLATION_STEPS = 10;
24
+ const INTERPOLATION_DURATION = 195;
25
+ const OPACITY_DURATION = 25;
26
+
27
+ const ModalView = ({
28
+ children,
29
+ visible,
30
+ BoxComponent = _reactCore.BoxContent,
31
+ frozen,
32
+ isLastShown,
33
+ close,
34
+ onClose
35
+ }) => {
36
+ const {
37
+ bottom
38
+ } = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
39
+ const [ready, setReady] = (0, _react.useState)(false);
40
+ const [keyboardOpened, setKeyboardOpened] = (0, _react.useState)(false);
41
+ const [boxHeight, setBoxHeight] = (0, _react.useState)(0);
42
+ const backgroundCarrier = (0, _react.useRef)(new _reactNative.Animated.Value(0)).current;
43
+ const translationCarrier = (0, _react.useRef)(new _reactNative.Animated.Value(0)).current;
44
+ const opacityCarrier = (0, _react.useRef)(new _reactNative.Animated.Value(0)).current;
45
+ const offset = isLastShown && keyboardOpened ? 0 : bottom;
46
+ const show = (0, _react.useCallback)(() => {
47
+ _reactNative.Animated.sequence([_reactNative.Animated.timing(backgroundCarrier, {
48
+ toValue: INTERPOLATION_STEPS,
49
+ duration: INTERPOLATION_DURATION,
50
+ easing: _reactNative.Easing.out(_reactNative.Easing.circle),
51
+ useNativeDriver: false
52
+ }), _reactNative.Animated.timing(opacityCarrier, {
53
+ toValue: 1,
54
+ duration: OPACITY_DURATION,
55
+ useNativeDriver: true
56
+ }), _reactNative.Animated.timing(translationCarrier, {
57
+ toValue: 0,
58
+ duration: INTERPOLATION_DURATION,
59
+ easing: _reactNative.Easing.out(_reactNative.Easing.circle),
60
+ useNativeDriver: true
61
+ })]).start();
62
+ }, []);
63
+ const hide = (0, _react.useCallback)(to => {
64
+ _reactNative.Animated.sequence([_reactNative.Animated.parallel([_reactNative.Animated.timing(translationCarrier, {
65
+ toValue: to,
66
+ duration: INTERPOLATION_DURATION,
67
+ easing: _reactNative.Easing.out(_reactNative.Easing.circle),
68
+ useNativeDriver: true
69
+ }), _reactNative.Animated.timing(opacityCarrier, {
70
+ toValue: 0,
71
+ duration: INTERPOLATION_DURATION,
72
+ useNativeDriver: true
73
+ })]), _reactNative.Animated.timing(backgroundCarrier, {
74
+ toValue: 0,
75
+ duration: INTERPOLATION_DURATION,
76
+ easing: _reactNative.Easing.out(_reactNative.Easing.circle),
77
+ useNativeDriver: false
78
+ })]).start(onClose);
79
+ }, [onClose]);
80
+ const backgroundInterpolation = backgroundCarrier.interpolate({
81
+ inputRange: [0, INTERPOLATION_STEPS],
82
+ outputRange: ['rgba(0, 0, 0, 0)', `rgba(0, 0, 0, ${BACKDROP_ALPHA})`]
83
+ });
84
+ const handleBoxLayoutChanges = (0, _react.useCallback)(lce => {
85
+ let boxHeightEvent = lce.nativeEvent.layout.height;
86
+ setBoxHeight(boxHeightEvent);
87
+
88
+ if (visible && !ready) {
89
+ translationCarrier.setValue(boxHeightEvent);
90
+ setReady(true);
91
+ }
92
+ }, [show, ready, visible, setReady]);
93
+ (0, _react.useEffect)(() => {
94
+ if (visible && ready) requestAnimationFrame(() => show());
95
+
96
+ if (!visible && !ready) {
97
+ _reactNative.Keyboard.dismiss();
98
+
99
+ requestAnimationFrame(() => hide(boxHeight));
100
+ }
101
+
102
+ if (!visible && ready) setReady(false);
103
+ }, [ready, visible]);
104
+ (0, _react.useEffect)(() => {
105
+ const showEvent = _reactNative.Keyboard.addListener('keyboardDidShow', () => setKeyboardOpened(true));
106
+
107
+ const hideEvent = _reactNative.Keyboard.addListener('keyboardDidHide', () => setKeyboardOpened(false));
108
+
109
+ return () => {
110
+ showEvent.remove();
111
+ hideEvent.remove();
112
+ };
113
+ }, []);
114
+ return _react.default.createElement(_styled.StyledPressableBackDrop, {
115
+ onPress: !frozen ? close : undefined
116
+ }, _react.default.createElement(_styled.BackDropView, {
117
+ style: {
118
+ backgroundColor: backgroundInterpolation
119
+ }
120
+ }, _react.default.createElement(_reactNative.KeyboardAvoidingView, {
121
+ enabled: isLastShown,
122
+ behavior: "padding"
123
+ }, _react.default.createElement(_reactNative.Animated.View, {
124
+ style: {
125
+ opacity: opacityCarrier,
126
+ transform: [{
127
+ translateY: translationCarrier
128
+ }]
129
+ }
130
+ }, _react.default.createElement(_reactNative.Pressable, null, _react.default.createElement(BoxComponent, {
131
+ onLayout: handleBoxLayoutChanges,
132
+ style: {
133
+ paddingBottom: offset
134
+ },
135
+ variant: "bottom"
136
+ }, _react.default.createElement(_styled.CloseBar, null), children))))));
137
+ };
138
+
139
+ exports.ModalView = ModalView;
140
+ //# sourceMappingURL=BaseModalView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/components/atoms/Modal/ui/BaseModalView.tsx"],"names":["BACKDROP_ALPHA","INTERPOLATION_STEPS","INTERPOLATION_DURATION","OPACITY_DURATION","ModalView","children","visible","BoxComponent","BoxContent","frozen","isLastShown","close","onClose","bottom","ready","setReady","keyboardOpened","setKeyboardOpened","boxHeight","setBoxHeight","backgroundCarrier","Animated","Value","current","translationCarrier","opacityCarrier","offset","show","sequence","timing","toValue","duration","easing","Easing","out","circle","useNativeDriver","start","hide","to","parallel","backgroundInterpolation","interpolate","inputRange","outputRange","handleBoxLayoutChanges","lce","boxHeightEvent","nativeEvent","layout","height","setValue","requestAnimationFrame","Keyboard","dismiss","showEvent","addListener","hideEvent","remove","undefined","backgroundColor","opacity","transform","translateY","paddingBottom"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;AAGA,MAAMA,cAAc,GAAG,GAAvB;AACA,MAAMC,mBAAmB,GAAG,EAA5B;AACA,MAAMC,sBAAsB,GAAG,GAA/B;AACA,MAAMC,gBAAgB,GAAG,EAAzB;;AAEO,MAAMC,SAAyB,GAAG,CAAC;AACtCC,EAAAA,QADsC;AAEtCC,EAAAA,OAFsC;AAGtCC,EAAAA,YAAY,GAAGC,qBAHuB;AAItCC,EAAAA,MAJsC;AAKtCC,EAAAA,WALsC;AAMtCC,EAAAA,KANsC;AAOtCC,EAAAA;AAPsC,CAAD,KAQnC;AAEF,QAAM;AAAEC,IAAAA;AAAF,MAAa,oDAAnB;AACA,QAAM,CAAEC,KAAF,EAASC,QAAT,IAAsB,qBAAS,KAAT,CAA5B;AACA,QAAM,CAAEC,cAAF,EAAkBC,iBAAlB,IAAwC,qBAAS,KAAT,CAA9C;AACA,QAAM,CAAEC,SAAF,EAAaC,YAAb,IAA8B,qBAAS,CAAT,CAApC;AACA,QAAMC,iBAAiB,GAAG,mBA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EvC;AAAd,OAAD;AAAtC;AAAtB,KACI,6BAAC,sBAAD,QACI,6BAAC,YAAD;AAAc,IAAA,QAAQ,EAAEqB,sBAAxB;AAAgD,IAAA,KAAK,EAAE;AAAEmB,MAAAA,aAAa,EAAEtC;AAAjB,KAAvD;AAAkF,IAAA,OAAO,EAAC;AAA1F,KACI,6BAAC,gBAAD,OADJ,EAEKrB,QAFL,CADJ,CADJ,CADJ,CADJ,CADJ,CADJ;AAgBH,CAlHM","sourcesContent":["import { BoxContent } from \"@tecsinapse/react-core\";\nimport React, { FC, useCallback, useEffect, useRef, useState } from \"react\";\nimport { Animated, Easing, Keyboard, KeyboardAvoidingView, LayoutChangeEvent, Pressable } from \"react-native\";\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport { BackDropView, CloseBar, StyledPressableBackDrop } from \"./styled\";\nimport { IBaseModal } from \"./types\";\n\nconst BACKDROP_ALPHA = .65\nconst INTERPOLATION_STEPS = 10\nconst INTERPOLATION_DURATION = 195 //ms\nconst OPACITY_DURATION = 25 //ms\n\nexport const ModalView: FC<IBaseModal> = ({\n children,\n visible,\n BoxComponent = BoxContent,\n frozen,\n isLastShown,\n close,\n onClose\n}) => {\n \n const { bottom } = useSafeAreaInsets()\n const [ ready, setReady ] = useState(false)\n const [ keyboardOpened, setKeyboardOpened ] = useState(false)\n const [ boxHeight, setBoxHeight ] = useState(0)\n const backgroundCarrier = useRef(new Animated.Value(0)).current\n const translationCarrier = useRef(new Animated.Value(0)).current\n const opacityCarrier = useRef(new Animated.Value(0)).current\n const offset = isLastShown && keyboardOpened ? 0 : bottom\n\n const show = useCallback(() => {\n Animated.sequence([\n Animated.timing(backgroundCarrier, {\n toValue: INTERPOLATION_STEPS,\n duration: INTERPOLATION_DURATION,\n easing: Easing.out(Easing.circle),\n useNativeDriver: false\n }),\n Animated.timing(opacityCarrier, {\n toValue: 1,\n duration: OPACITY_DURATION,\n useNativeDriver: true\n }),\n Animated.timing(translationCarrier, {\n toValue: 0,\n duration: INTERPOLATION_DURATION,\n easing: Easing.out(Easing.circle),\n useNativeDriver: true\n })\n ]).start()\n }, [])\n\n const hide = useCallback((to: number) => {\n Animated.sequence([\n Animated.parallel([\n Animated.timing(translationCarrier, {\n toValue: to,\n duration: INTERPOLATION_DURATION,\n easing: Easing.out(Easing.circle),\n useNativeDriver: true\n }),\n Animated.timing(opacityCarrier, {\n toValue: 0,\n duration: INTERPOLATION_DURATION,\n useNativeDriver: true\n }) \n ]),\n Animated.timing(backgroundCarrier, {\n toValue: 0,\n duration: INTERPOLATION_DURATION,\n easing: Easing.out(Easing.circle),\n useNativeDriver: false\n }),\n ]).start(onClose)\n }, [onClose])\n\n const backgroundInterpolation = backgroundCarrier.interpolate({\n inputRange: [0, INTERPOLATION_STEPS],\n outputRange: ['rgba(0, 0, 0, 0)', `rgba(0, 0, 0, ${BACKDROP_ALPHA})`]\n })\n\n const handleBoxLayoutChanges = useCallback((lce: LayoutChangeEvent) => {\n let boxHeightEvent = lce.nativeEvent.layout.height\n setBoxHeight(boxHeightEvent)\n \n if (visible && !ready) {\n translationCarrier.setValue(boxHeightEvent)\n setReady(true)\n }\n }, [show, ready, visible, setReady])\n\n useEffect(() => {\n if (visible && ready) requestAnimationFrame(() => show())\n if (!visible && !ready) {\n Keyboard.dismiss()\n requestAnimationFrame(() => hide(boxHeight))\n }\n if (!visible && ready) setReady(false)\n }, [ready, visible])\n\n useEffect(() => {\n const showEvent = Keyboard.addListener('keyboardDidShow', () => setKeyboardOpened(true))\n const hideEvent = Keyboard.addListener('keyboardDidHide', () => setKeyboardOpened(false))\n return () => {\n showEvent.remove()\n hideEvent.remove()\n }\n }, [])\n\n return (\n <StyledPressableBackDrop onPress={!frozen ? close : undefined}>\n <BackDropView style={{ backgroundColor: backgroundInterpolation }}>\n <KeyboardAvoidingView enabled={isLastShown} behavior=\"padding\">\n <Animated.View style={{ opacity: opacityCarrier, transform: [{ translateY: translationCarrier }]}}>\n <Pressable>\n <BoxComponent onLayout={handleBoxLayoutChanges} style={{ paddingBottom: offset }} variant=\"bottom\">\n <CloseBar/>\n {children}\n </BoxComponent>\n </Pressable>\n </Animated.View>\n </KeyboardAvoidingView>\n </BackDropView>\n </StyledPressableBackDrop>\n )\n}"],"file":"BaseModalView.js"}
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export declare const StyledPressableBackDrop: import("@emotion/native").StyledComponent<any, {}, {}>;
3
+ export declare const BackDropView: import("@emotion/native").StyledComponent<any, {}, {}>;
4
+ export declare const CloseBar: import("@emotion/native").StyledComponent<any, {}, {
5
+ ref?: import("react").Ref<import("react-native").View> | undefined;
6
+ }>;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CloseBar = exports.BackDropView = exports.StyledPressableBackDrop = void 0;
7
+
8
+ var _native = _interopRequireDefault(require("@emotion/native"));
9
+
10
+ var _reactCore = require("@tecsinapse/react-core");
11
+
12
+ var _reactNative = require("react-native");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ const StyledPressableBackDrop = _native.default.Pressable`
17
+ flex: 1;
18
+ position: absolute;
19
+ width: 100%;
20
+ height: 100%;
21
+ `;
22
+ exports.StyledPressableBackDrop = StyledPressableBackDrop;
23
+ const BackDropView = (0, _native.default)(_reactNative.Animated.View)`
24
+ justify-content: flex-end;
25
+ flex: 1;
26
+ `;
27
+ exports.BackDropView = BackDropView;
28
+ const CloseBar = _native.default.View`
29
+ background-color: ${({
30
+ theme
31
+ }) => theme.color.secondary.light};
32
+ border-radius: ${(0, _reactCore.RFValueStr)('10px')};
33
+ margin: ${`${(0, _reactCore.RFValueStr)('5px')} auto`};
34
+ width: ${(0, _reactCore.RFValueStr)('42px')};
35
+ height: ${(0, _reactCore.RFValueStr)('5px')};
36
+ `;
37
+ exports.CloseBar = CloseBar;
38
+ //# sourceMappingURL=styled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/components/atoms/Modal/ui/styled.ts"],"names":["StyledPressableBackDrop","styled","Pressable","BackDropView","Animated","View","CloseBar","theme","color","secondary","light"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAEO,MAAMA,uBAAuB,GAAGC,gBAAOC,SAA+B;AAC7E;AACA;AACA;AACA;AACA,CALO;;AAOA,MAAMC,YAAY,GAAG,qBAAOC,sBAASC,IAAhB,CAA2C;AACvE;AACA;AACA,CAHO;;AAKA,MAAMC,QAAQ,GAAGL,gBAAOI,IAA0B;AACzD,wBAAwB,CAAC;AAAEE,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,KAAN,CAAYC,SAAZ,CAAsBC,KAAM;AACnE,qBAAqB,2BAAW,MAAX,CAAmB;AACxC,cAAe,GAAE,2BAAW,KAAX,CAAkB,OAAO;AAC1C,aAAa,2BAAW,MAAX,CAAmB;AAChC,cAAc,2BAAW,KAAX,CAAkB;AAChC,CANO","sourcesContent":["import styled from \"@emotion/native\";\nimport { RFValueStr, StyleProps } from \"@tecsinapse/react-core\";\nimport { Animated } from \"react-native\";\n\nexport const StyledPressableBackDrop = styled.Pressable<Partial<StyleProps>>`\n flex: 1;\n position: absolute;\n width: 100%;\n height: 100%;\n`\n\nexport const BackDropView = styled(Animated.View)<Partial<StyleProps>>`\n justify-content: flex-end;\n flex: 1;\n`\n\nexport const CloseBar = styled.View<Partial<StyleProps>>`\n background-color: ${({ theme }) => theme.color.secondary.light};\n border-radius: ${RFValueStr('10px')};\n margin: ${`${RFValueStr('5px')} auto`};\n width: ${RFValueStr('42px')};\n height: ${RFValueStr('5px')};\n`"],"file":"styled.js"}
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ export interface IBaseModal {
3
+ visible?: boolean;
4
+ BoxComponent?: React.FC<any>;
5
+ frozen?: boolean;
6
+ isLastShown?: boolean;
7
+ close?: () => void;
8
+ onClose?: () => void;
9
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"types.js"}
@@ -0,0 +1,6 @@
1
+ import { ReactElement } from "react";
2
+ import { IBaseModal } from "./ui/types";
3
+ export declare const useModalManager: (modal: () => ReactElement<IBaseModal>) => {
4
+ show: () => void;
5
+ close: () => void;
6
+ };