@tecsinapse/react-native-kit 1.16.2 → 1.17.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.
Files changed (38) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/components/atoms/InputMask/InputMask.d.ts +8 -0
  3. package/dist/components/atoms/InputMask/InputMask.js +87 -0
  4. package/dist/components/atoms/InputMask/InputMask.js.map +1 -0
  5. package/dist/components/atoms/InputMask/index.d.ts +1 -0
  6. package/dist/components/atoms/InputMask/index.js +14 -0
  7. package/dist/components/atoms/InputMask/index.js.map +1 -0
  8. package/dist/components/atoms/InputMask/styled.d.ts +5 -0
  9. package/dist/components/atoms/InputMask/styled.js +27 -0
  10. package/dist/components/atoms/InputMask/styled.js.map +1 -0
  11. package/dist/components/atoms/Modal/ModalLifecycleHandler.d.ts +1 -0
  12. package/dist/components/atoms/Modal/ModalLifecycleHandler.js +10 -4
  13. package/dist/components/atoms/Modal/ModalLifecycleHandler.js.map +1 -1
  14. package/dist/components/atoms/Modal/index.d.ts +1 -0
  15. package/dist/components/atoms/Modal/index.js +8 -0
  16. package/dist/components/atoms/Modal/index.js.map +1 -1
  17. package/dist/components/atoms/Modal/useLazyModalManager.d.ts +1 -1
  18. package/dist/components/atoms/Modal/useLazyModalManager.js +2 -2
  19. package/dist/components/atoms/Modal/useLazyModalManager.js.map +1 -1
  20. package/dist/components/atoms/Modal/useModalManager.d.ts +1 -1
  21. package/dist/components/atoms/Modal/useModalManager.js +2 -2
  22. package/dist/components/atoms/Modal/useModalManager.js.map +1 -1
  23. package/dist/components/atoms/Modal/useModalRemoteControl.d.ts +4 -0
  24. package/dist/components/atoms/Modal/useModalRemoteControl.js +24 -0
  25. package/dist/components/atoms/Modal/useModalRemoteControl.js.map +1 -0
  26. package/dist/index.d.ts +2 -1
  27. package/dist/index.js +10 -1
  28. package/dist/index.js.map +1 -1
  29. package/package.json +3 -3
  30. package/src/components/atoms/InputMask/InputMask.tsx +96 -0
  31. package/src/components/atoms/InputMask/index.ts +1 -0
  32. package/src/components/atoms/InputMask/styled.ts +25 -0
  33. package/src/components/atoms/Modal/ModalLifecycleHandler.ts +15 -4
  34. package/src/components/atoms/Modal/index.ts +2 -1
  35. package/src/components/atoms/Modal/useLazyModalManager.ts +2 -2
  36. package/src/components/atoms/Modal/useModalManager.ts +2 -2
  37. package/src/components/atoms/Modal/useModalRemoteControl.ts +26 -0
  38. package/src/index.ts +2 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
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.17.0](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-native-kit@1.16.2...@tecsinapse/react-native-kit@1.17.0) (2022-05-10)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * inputMask accepting undefined. ([6037162](https://github.com/tecsinapse/design-system/commit/6037162a564c118c8faed8359418ff7eda6d1645))
12
+ * updating skeleton from master. ([9904009](https://github.com/tecsinapse/design-system/commit/990400938c3eb92c78ab60277971726b64410515))
13
+
14
+
15
+
16
+
17
+
6
18
  ## [1.16.2](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-native-kit@1.16.1...@tecsinapse/react-native-kit@1.16.2) (2022-04-21)
7
19
 
8
20
 
@@ -0,0 +1,8 @@
1
+ import { FontStackType, FontWeightType, InputContainerProps, InputMaskElementProps } from '@tecsinapse/react-core';
2
+ import { FC } from 'react';
3
+ export interface InputMaskNativeProps extends Omit<InputMaskElementProps, 'style'>, InputContainerProps {
4
+ inputFontStack?: FontStackType;
5
+ inputFontWeight?: FontWeightType;
6
+ }
7
+ declare const InputMask: FC<InputMaskNativeProps>;
8
+ export default InputMask;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.default = void 0;
5
+
6
+ var _reactCore = require("@tecsinapse/react-core");
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ var _styled = require("./styled");
13
+
14
+ var _Text = require("../Text");
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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 InputMask = _react.default.forwardRef(({
21
+ label,
22
+ labelColor,
23
+ labelColorVariant,
24
+ labelColorTone,
25
+ labelTypography,
26
+ labelStack,
27
+ labelWeight,
28
+ leftComponent,
29
+ rightComponent,
30
+ disabled,
31
+ style,
32
+ borderColor,
33
+ borderColorGradation,
34
+ inputFontStack = 'default',
35
+ inputFontWeight = 'bold',
36
+ inputContainerStyle,
37
+ variant = 'default',
38
+ hintComponent,
39
+ hint,
40
+ onFocus,
41
+ onBlur,
42
+ ...rest
43
+ }, ref) => {
44
+ const _hint = hintComponent || _react.default.createElement(_reactCore.Hint, {
45
+ TextComponent: _Text.Text,
46
+ text: hint,
47
+ variant: variant
48
+ });
49
+
50
+ const {
51
+ focused,
52
+ handleBlur,
53
+ handleFocus
54
+ } = (0, _reactCore.useInputFocus)(onFocus, onBlur, !disabled);
55
+ return _react.default.createElement(_reactNative.View, {
56
+ style: style
57
+ }, _react.default.createElement(_styled.StyledInputContainer, {
58
+ label: label,
59
+ labelColor: labelColor,
60
+ labelColorVariant: labelColorVariant,
61
+ labelColorTone: labelColorTone,
62
+ labelTypography: labelTypography,
63
+ labelStack: labelStack,
64
+ labelWeight: labelWeight,
65
+ LabelComponent: _Text.Text,
66
+ leftComponent: leftComponent,
67
+ rightComponent: rightComponent,
68
+ borderColor: borderColor,
69
+ borderColorGradation: borderColorGradation,
70
+ inputContainerStyle: inputContainerStyle,
71
+ focused: focused,
72
+ disabled: disabled,
73
+ variant: variant
74
+ }, _react.default.createElement(_styled.StyledNativeInputMask, _extends({}, rest, {
75
+ ref: ref,
76
+ fontStack: inputFontStack,
77
+ fontWeight: inputFontWeight,
78
+ disabled: disabled,
79
+ onFocus: handleFocus,
80
+ onBlur: handleBlur
81
+ }))), hint && _hint);
82
+ });
83
+
84
+ InputMask.displayName = 'InputMask';
85
+ var _default = InputMask;
86
+ exports.default = _default;
87
+ //# sourceMappingURL=InputMask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/atoms/InputMask/InputMask.tsx"],"names":["InputMask","React","forwardRef","label","labelColor","labelColorVariant","labelColorTone","labelTypography","labelStack","labelWeight","leftComponent","rightComponent","disabled","style","borderColor","borderColorGradation","inputFontStack","inputFontWeight","inputContainerStyle","variant","hintComponent","hint","onFocus","onBlur","rest","ref","_hint","Text","focused","handleBlur","handleFocus","displayName"],"mappings":";;;;;AAAA;;AAQA;;AACA;;AACA;;AACA;;;;;;AASA,MAAMA,SAAmC,GAAGC,eAAMC,UAAN,CAC1C,CACE;AACEC,EAAAA,KADF;AAEEC,EAAAA,UAFF;AAGEC,EAAAA,iBAHF;AAIEC,EAAAA,cAJF;AAKEC,EAAAA,eALF;AAMEC,EAAAA,UANF;AAOEC,EAAAA,WAPF;AAQEC,EAAAA,aARF;AASEC,EAAAA,cATF;AAUEC,EAAAA,QAVF;AAWEC,EAAAA,KAXF;AAYEC,EAAAA,WAZF;AAaEC,EAAAA,oBAbF;AAcEC,EAAAA,cAAc,GAAG,SAdnB;AAeEC,EAAAA,eAAe,GAAG,MAfpB;AAgBEC,EAAAA,mBAhBF;AAiBEC,EAAAA,OAAO,GAAG,SAjBZ;AAkBEC,EAAAA,aAlBF;AAmBEC,EAAAA,IAnBF;AAoBEC,EAAAA,OApBF;AAqBEC,EAAAA,MArBF;AAsBE,KAAGC;AAtBL,CADF,EAyBEC,GAzBF,KA0BK;AACH,QAAMC,KAAK,GAAGN,aAAa,IACzB,6BAAC,eAAD;AAAM,IAAA,aAAa,EAAEO,UAArB;AAA2B,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ecsinapse/react-core';\nimport React, { FC } from 'react';\nimport { View } from 'react-native';\nimport { StyledInputContainer, StyledNativeInputMask } from './styled';\nimport { Text } from '../Text';\n\nexport interface InputMaskNativeProps\n extends Omit<InputMaskElementProps, 'style'>,\n InputContainerProps {\n inputFontStack?: FontStackType;\n inputFontWeight?: FontWeightType;\n}\n\nconst InputMask: FC<InputMaskNativeProps> = React.forwardRef(\n (\n {\n label,\n labelColor,\n labelColorVariant,\n labelColorTone,\n labelTypography,\n labelStack,\n labelWeight,\n leftComponent,\n rightComponent,\n disabled,\n style,\n borderColor,\n borderColorGradation,\n inputFontStack = 'default',\n inputFontWeight = 'bold',\n inputContainerStyle,\n variant = 'default',\n hintComponent,\n hint,\n onFocus,\n onBlur,\n ...rest\n },\n ref\n ) => {\n const _hint = hintComponent || (\n <Hint TextComponent={Text} text={hint} variant={variant} />\n );\n const { focused, handleBlur, handleFocus } = useInputFocus(\n onFocus,\n onBlur,\n !disabled\n );\n\n return (\n <View style={style}>\n <StyledInputContainer\n label={label}\n labelColor={labelColor}\n labelColorVariant={labelColorVariant}\n labelColorTone={labelColorTone}\n labelTypography={labelTypography}\n labelStack={labelStack}\n labelWeight={labelWeight}\n LabelComponent={Text}\n leftComponent={leftComponent}\n rightComponent={rightComponent}\n borderColor={borderColor}\n borderColorGradation={borderColorGradation}\n inputContainerStyle={inputContainerStyle}\n focused={focused}\n disabled={disabled}\n variant={variant}\n >\n <StyledNativeInputMask\n {...rest}\n ref={ref}\n fontStack={inputFontStack}\n fontWeight={inputFontWeight}\n disabled={disabled}\n onFocus={handleFocus}\n onBlur={handleBlur}\n />\n </StyledInputContainer>\n {hint && _hint}\n </View>\n );\n }\n);\n\nInputMask.displayName = 'InputMask';\n\nexport default InputMask;\n"],"file":"InputMask.js"}
@@ -0,0 +1 @@
1
+ export { default as InputMask, InputMaskNativeProps } from './InputMask';
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.InputMaskNativeProps = exports.InputMask = void 0;
5
+
6
+ var _InputMask = _interopRequireWildcard(require("./InputMask"));
7
+
8
+ exports.InputMask = _InputMask.default;
9
+ exports.InputMaskNativeProps = _InputMask.InputMaskNativeProps;
10
+
11
+ 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); }
12
+
13
+ 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; }
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/atoms/InputMask/index.ts"],"names":[],"mappings":";;;;;AAAA","sourcesContent":["export { default as InputMask, InputMaskNativeProps } from './InputMask';\n"],"file":"index.js"}
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ export declare const StyledInputContainer: import("@emotion/native").StyledComponent<any, {}, {
3
+ ref?: import("react").Ref<any> | undefined;
4
+ }>;
5
+ export declare const StyledNativeInputMask: import("@emotion/native").StyledComponent<any, {}, {}>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.StyledNativeInputMask = exports.StyledInputContainer = void 0;
5
+
6
+ var _native = _interopRequireDefault(require("@emotion/native"));
7
+
8
+ var _reactCore = require("@tecsinapse/react-core");
9
+
10
+ var _styled = require("../Text/styled");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ const StyledInputContainer = (0, _native.default)(_reactCore.InputContainer)`
15
+ min-height: ${(0, _reactCore.RFValueStr)('50px')};
16
+ `;
17
+ exports.StyledInputContainer = StyledInputContainer;
18
+ const StyledNativeInputMaskBase = (0, _native.default)(_reactCore.InputMaskElement)`
19
+ height: ${({
20
+ theme
21
+ }) => theme.typography.h5.lineHeight};
22
+ width: 100%;
23
+ padding: 0;
24
+ `;
25
+ const StyledNativeInputMask = (0, _native.default)(StyledNativeInputMaskBase)(_styled.fontStyles);
26
+ exports.StyledNativeInputMask = StyledNativeInputMask;
27
+ //# sourceMappingURL=styled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/atoms/InputMask/styled.ts"],"names":["StyledInputContainer","InputContainer","StyledNativeInputMaskBase","InputMaskElement","theme","typography","h5","lineHeight","StyledNativeInputMask","fontStyles"],"mappings":";;;;;AAAA;;AACA;;AAMA;;;;AAGO,MAAMA,oBAAoB,GAAG,qBAAOC,yBAAP,CAA4C;AAChF,gBAAgB,2BAAW,MAAX,CAAmB;AACnC,CAFO;;AAIP,MAAMC,yBAAyB,GAAG,qBAAOC,2BAAP,CAEhC;AACF,YAAY,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,UAAN,CAAiBC,EAAjB,CAAoBC,UAAW;AAC1D;AACA;AACA,CANA;AAQO,MAAMC,qBAAqB,GAAG,qBAAON,yBAAP,EAEnCO,kBAFmC,CAA9B","sourcesContent":["import styled from '@emotion/native';\nimport {\n InputContainer,\n InputMaskElement,\n RFValueStr,\n StyleProps,\n} from '@tecsinapse/react-core';\nimport { Font, fontStyles } from '../Text/styled';\nimport { InputMaskNativeProps } from './InputMask';\n\nexport const StyledInputContainer = styled(InputContainer)<Partial<StyleProps>>`\n min-height: ${RFValueStr('50px')};\n`;\n\nconst StyledNativeInputMaskBase = styled(InputMaskElement)<\n Partial<InputMaskNativeProps> & Partial<StyleProps>\n>`\n height: ${({ theme }) => theme.typography.h5.lineHeight};\n width: 100%;\n padding: 0;\n`;\n\nexport const StyledNativeInputMask = styled(StyledNativeInputMaskBase)<\n Font & Partial<InputMaskNativeProps> & Partial<StyleProps>\n>(fontStyles);\n"],"file":"styled.js"}
@@ -16,6 +16,7 @@ export declare class ModalLifecycleHandler {
16
16
  sync: (id: string, modal: () => ReactElement<IBaseModal>) => void;
17
17
  destroy: (id: string) => void;
18
18
  private remove;
19
+ private findNode;
19
20
  show: (id: string) => void;
20
21
  close: (id: string) => void;
21
22
  }
@@ -47,7 +47,7 @@ class ModalLifecycleHandler {
47
47
 
48
48
  this.sync = (id, modal) => {
49
49
  if (this.nodeGroup.has(id)) {
50
- const savedNode = this.nodeGroup.get(id);
50
+ const savedNode = this.findNode(id);
51
51
  savedNode && this.nodeGroup.set(id, { ...savedNode,
52
52
  modal
53
53
  });
@@ -66,15 +66,21 @@ class ModalLifecycleHandler {
66
66
  };
67
67
 
68
68
  this.remove = id => {
69
- const savedNode = this.nodeGroup.get(id);
69
+ const savedNode = this.findNode(id);
70
70
  savedNode && this.nodeGroup.set(id, { ...savedNode,
71
71
  lastVisualization: undefined
72
72
  });
73
73
  this.update();
74
74
  };
75
75
 
76
+ this.findNode = id => {
77
+ const node = this.nodeGroup.get(id);
78
+ !node && console.warn(`No modal was found with the id "${id}"`);
79
+ return node;
80
+ };
81
+
76
82
  this.show = id => {
77
- const savedNode = this.nodeGroup.get(id);
83
+ const savedNode = this.findNode(id);
78
84
  savedNode && this.nodeGroup.set(id, { ...savedNode,
79
85
  visible: true,
80
86
  lastVisualization: new Date()
@@ -83,7 +89,7 @@ class ModalLifecycleHandler {
83
89
  };
84
90
 
85
91
  this.close = id => {
86
- const savedNode = this.nodeGroup.get(id);
92
+ const savedNode = this.findNode(id);
87
93
  savedNode && this.nodeGroup.set(id, { ...savedNode,
88
94
  visible: false
89
95
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/atoms/Modal/ModalLifecycleHandler.ts"],"names":["ModalLifecycleHandler","constructor","attach","state","update","requestAnimationFrame","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","render","modals","sync","has","savedNode","get","set","destroy","delete","undefined","show","Date","Map","createModalLifecycleHandler"],"mappings":";;;;;AAAA;;;;AAgBO,MAAMA,qBAAN,CAA4B;AAK/BC,EAAAA,WAAW,GAAG;AAAA,SAUPC,MAVO,GAUGC,KAAD,IAA+E;AAC3F,WAAKA,KAAL,GAAaA,KAAb;AACH,KAZa;;AAAA,SAiBPC,MAjBO,GAiBE,MAAM;AAClBC,MAAAA,qBAAqB,CAAC,MAAM;AACxB,cAAMC,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,iBAAkB,CAAC,0BAAAD,KAAK,CAACF,iBAAN,2CAAyBI,OAAzB,OAAsC,CAAvC,KAA6C,0BAAAD,KAAK,CAACH,iBAAN,2CAAyBI,OAAzB,OAAsC,CAAnF,CAAlB;AAAA,SAFI,EAGTC,GAHS,CAGL,CAACP,IAAD,EAAOQ,KAAP,EAAcC,aAAd,KAAgC;AACjC,cAAIC,YAAY,GAAGV,IAAI,CAACW,KAAL,EAAnB;AACA,cAAI;AAAEC,YAAAA;AAAF,cAAYF,YAAhB;AACA,iBAAOG,eAAMC,YAAN,CAAmBJ,YAAnB,EAAiC,EACpC,GAAGE,KADiC;AAEpCG,YAAAA,GAAG,EAAEf,IAAI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actElement } 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 requestAnimationFrame(() => {\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 /**\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"}
1
+ {"version":3,"sources":["../../../../src/components/atoms/Modal/ModalLifecycleHandler.ts"],"names":["ModalLifecycleHandler","constructor","attach","state","update","requestAnimationFrame","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","render","modals","sync","has","savedNode","findNode","set","destroy","delete","undefined","get","console","warn","show","Date","Map","createModalLifecycleHandler"],"mappings":";;;;;AAAA;;;;AAgBO,MAAMA,qBAAN,CAA4B;AAK/BC,EAAAA,WAAW,GAAG;AAAA,SAUPC,MAVO,GAUGC,KAAD,IAA+E;AAC3F,WAAKA,KAAL,GAAaA,KAAb;AACH,KAZa;;AAAA,SAiBPC,MAjBO,GAiBE,MAAM;AAClBC,MAAAA,qBAAqB,CAAC,MAAM;AACxB,cAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAW,KAAKC,SAAL,CAAeC,MA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QAAL,CAAcZ,EAAd,CAAlB;AACAW,MAAAA,SAAS,IAAI,KAAK9B,SAAL,CAAegC,GAAf,CAAmBb,EAAnB,EAAuB,EAAE,GAAGW,SAAL;AAAgB1B,QAAAA,OAAO,EAAE,IAAzB;AAA+BC,QAAAA,iBAAiB,EAAE,IAAImC,IAAJ;AAAlD,OAAvB,CAAb;AACA,WAAK7C,MAAL;AACH,KA/Ga;;AAAA,SAsHP2B,KAtHO,GAsHEH,EAAD,IAAgB;AAC3B,YAAMW,SAAS,GAAG,KAAKC,QAAL,CAAcZ,EAAd,CAAlB;AACAW,MAAAA,SAAS,IAAI,KAAK9B,SAAL,CAAegC,GAAf,CAAmBb,EAAnB,EAAuB,EAAE,GAAGW,SAAL;AAAgB1B,QAAAA,OAAO,EAAE;AAAzB,OAAvB,CAAb;AACA,WAAKT,MAAL;AACH,KA1Ha;;AACV,SAAKK,SAAL,GAAiB,IAAIyC,GAAJ,EAAjB;AACA,SAAK/C,KAAL,GAAayC,SAAb;AACH;;AAR8B;;;;AAuI5B,MAAMO,2BAA2B,GAAG,MAAM;AAC7C,SAAO,IAAInD,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 requestAnimationFrame(() => {\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 /**\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.findNode(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.findNode(id)\n savedNode && this.nodeGroup.set(id, { ...savedNode, lastVisualization: undefined })\n this.update()\n }\n\n /**\n * Find a modal node by id.\n * \n * @param id \n */\n private findNode = (id: string) => {\n const node = this.nodeGroup.get(id)\n !node && console.warn(`No modal was found with the id \"${id}\"`)\n return node\n }\n\n /**\n * Makes a modal appears.\n * \n * @param id \n */\n public show = (id: string) => {\n const savedNode = this.findNode(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.findNode(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"}
@@ -4,3 +4,4 @@ export * from './ui/BaseModalView';
4
4
  export * from './ui/types';
5
5
  export * from './useModalManager';
6
6
  export * from './useLazyModalManager';
7
+ export * from './useModalRemoteControl';
@@ -49,4 +49,12 @@ Object.keys(_useLazyModalManager).forEach(function (key) {
49
49
  if (key in exports && exports[key] === _useLazyModalManager[key]) return;
50
50
  exports[key] = _useLazyModalManager[key];
51
51
  });
52
+
53
+ var _useModalRemoteControl = require("./useModalRemoteControl");
54
+
55
+ Object.keys(_useModalRemoteControl).forEach(function (key) {
56
+ if (key === "default" || key === "__esModule") return;
57
+ if (key in exports && exports[key] === _useModalRemoteControl[key]) return;
58
+ exports[key] = _useModalRemoteControl[key];
59
+ });
52
60
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/atoms/Modal/index.ts"],"names":[],"mappings":";;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export * from './ModalGroupManager'\nexport * from './ModalLifecycleHandler'\nexport * from './ui/BaseModalView'\nexport * from './ui/types'\nexport * from './useModalManager'\nexport * from './useLazyModalManager'"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../../src/components/atoms/Modal/index.ts"],"names":[],"mappings":";;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export * from './ModalGroupManager'\nexport * from './ModalLifecycleHandler'\nexport * from './ui/BaseModalView'\nexport * from './ui/types'\nexport * from './useModalManager'\nexport * from './useLazyModalManager'\nexport * from './useModalRemoteControl'"],"file":"index.js"}
@@ -1,6 +1,6 @@
1
1
  import { ReactElement } from "react";
2
2
  import { IBaseModal } from "./ui/types";
3
- export declare const useLazyModalManager: () => {
3
+ export declare const useLazyModalManager: (modalId?: string | undefined) => {
4
4
  requestUpdate: () => void;
5
5
  sync: (modal: ReactElement<IBaseModal>) => null;
6
6
  show: () => void;
@@ -9,8 +9,8 @@ var _uuid = require("uuid");
9
9
 
10
10
  var _ModalGroupManager = require("./ModalGroupManager");
11
11
 
12
- const useLazyModalManager = () => {
13
- const [id] = (0, _react.useState)((0, _uuid.v4)());
12
+ const useLazyModalManager = modalId => {
13
+ const [id] = (0, _react.useState)(modalId ?? (0, _uuid.v4)());
14
14
  const requestUpdate = (0, _react.useCallback)(() => _ModalGroupManager.modalLifecycle.update(), []);
15
15
  const sync = (0, _react.useCallback)(modal => {
16
16
  _ModalGroupManager.modalLifecycle.sync(id, () => modal);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/atoms/Modal/useLazyModalManager.ts"],"names":["useLazyModalManager","id","requestUpdate","modalLifecycle","update","sync","modal","show","close","destroy"],"mappings":";;;;;AAAA;;AACA;;AACA;;AAWO,MAAMA,mBAAmB,GAAG,MAAM;AAErC,QAAM,CAACC,EAAD,IAAO,qBAAS,eAAT,CAAb;AAEA,QAAMC,aAAa,GAAG,wBAAY,MAAMC,kCAAeC,MAAf,EAAlB,EAA2C,EAA3C,CAAtB;AAEA,QAAMC,IAAI,GAAG,wBAAaC,KAAD,IAAqC;AAC1DH,sCAAeE,IAAf,CAAoBJ,EAApB,EAAwB,MAAMK,KAA9B;;AACA,WAAO,IAAP;AACH,GAHY,EAGV,CAACL,EAAD,CAHU,CAAb;AAKA,QAAMM,IAAI,GAAG,wBAAY,MAAM;AAC3BJ,sCAAeI,IAAf,CAAoBN,EAApB;AACH,GAFY,EAEV,CAACA,EAAD,CAFU,CAAb;AAIA,QAAMO,KAAK,GAAG,wBAAY,MAAM;AAC5BL,sCAAeK,KAAf,CAAqBP,EAArB;AACH,GAFa,EAEX,CAACA,EAAD,CAFW,CAAd;AAIA,wBAAU,MAAM;AACZ,WAAO,MAAME,kCAAeM,OAAf,CAAuBR,EAAvB,CAAb;AACH,GAFD,EAEG,EAFH;AAIA,SAAO;AACHC,IAAAA,aADG;AAEHG,IAAAA,IAFG;AAGHE,IAAAA,IAHG;AAIHC,IAAAA;AAJG,GAAP;AAMH,CA7BM","sourcesContent":["import { ReactElement, useCallback, useEffect, useState } from \"react\"\nimport { v4 as uuidv4 } from 'uuid'\nimport { modalLifecycle } from \"./ModalGroupManager\"\nimport { IBaseModal } from \"./ui/types\"\n\n/**\n * Use this hook to tell the modal lifecycle handler that you want to add\n * a new modal component. \n * \n * @param id \n * @param modal \n * @returns\n */\nexport const useLazyModalManager = () => {\n\n const [id] = useState(uuidv4())\n\n const requestUpdate = useCallback(() => modalLifecycle.update(), [])\n\n const sync = useCallback((modal: ReactElement<IBaseModal>) => {\n modalLifecycle.sync(id, () => modal)\n return null\n }, [id])\n\n const show = useCallback(() => {\n modalLifecycle.show(id)\n }, [id])\n\n const close = useCallback(() => {\n modalLifecycle.close(id)\n }, [id])\n \n useEffect(() => {\n return () => modalLifecycle.destroy(id)\n }, [])\n\n return {\n requestUpdate,\n sync,\n show,\n close\n }\n}"],"file":"useLazyModalManager.js"}
1
+ {"version":3,"sources":["../../../../src/components/atoms/Modal/useLazyModalManager.ts"],"names":["useLazyModalManager","modalId","id","requestUpdate","modalLifecycle","update","sync","modal","show","close","destroy"],"mappings":";;;;;AAAA;;AACA;;AACA;;AAWO,MAAMA,mBAAmB,GAAIC,OAAD,IAAsB;AAErD,QAAM,CAACC,EAAD,IAAO,qBAASD,OAAO,IAAI,eAApB,CAAb;AAEA,QAAME,aAAa,GAAG,wBAAY,MAAMC,kCAAeC,MAAf,EAAlB,EAA2C,EAA3C,CAAtB;AAEA,QAAMC,IAAI,GAAG,wBAAaC,KAAD,IAAqC;AAC1DH,sCAAeE,IAAf,CAAoBJ,EAApB,EAAwB,MAAMK,KAA9B;;AACA,WAAO,IAAP;AACH,GAHY,EAGV,CAACL,EAAD,CAHU,CAAb;AAKA,QAAMM,IAAI,GAAG,wBAAY,MAAM;AAC3BJ,sCAAeI,IAAf,CAAoBN,EAApB;AACH,GAFY,EAEV,CAACA,EAAD,CAFU,CAAb;AAIA,QAAMO,KAAK,GAAG,wBAAY,MAAM;AAC5BL,sCAAeK,KAAf,CAAqBP,EAArB;AACH,GAFa,EAEX,CAACA,EAAD,CAFW,CAAd;AAIA,wBAAU,MAAM;AACZ,WAAO,MAAME,kCAAeM,OAAf,CAAuBR,EAAvB,CAAb;AACH,GAFD,EAEG,EAFH;AAIA,SAAO;AACHC,IAAAA,aADG;AAEHG,IAAAA,IAFG;AAGHE,IAAAA,IAHG;AAIHC,IAAAA;AAJG,GAAP;AAMH,CA7BM","sourcesContent":["import { ReactElement, useCallback, useEffect, useState } from \"react\"\nimport { v4 as uuidv4 } from 'uuid'\nimport { modalLifecycle } from \"./ModalGroupManager\"\nimport { IBaseModal } from \"./ui/types\"\n\n/**\n * Use this hook to tell the modal lifecycle handler that you want to add\n * a new modal component. \n * \n * @param id \n * @param modal \n * @returns\n */\nexport const useLazyModalManager = (modalId?: string) => {\n\n const [id] = useState(modalId ?? uuidv4())\n\n const requestUpdate = useCallback(() => modalLifecycle.update(), [])\n\n const sync = useCallback((modal: ReactElement<IBaseModal>) => {\n modalLifecycle.sync(id, () => modal)\n return null\n }, [id])\n\n const show = useCallback(() => {\n modalLifecycle.show(id)\n }, [id])\n\n const close = useCallback(() => {\n modalLifecycle.close(id)\n }, [id])\n \n useEffect(() => {\n return () => modalLifecycle.destroy(id)\n }, [])\n\n return {\n requestUpdate,\n sync,\n show,\n close\n }\n}"],"file":"useLazyModalManager.js"}
@@ -1,6 +1,6 @@
1
1
  import { ReactElement } from "react";
2
2
  import { IBaseModal } from "./ui/types";
3
- export declare const useModalManager: (modal: () => ReactElement<IBaseModal>) => {
3
+ export declare const useModalManager: (modal: () => ReactElement<IBaseModal>, modalId?: string | undefined) => {
4
4
  show: () => void;
5
5
  close: () => void;
6
6
  };
@@ -9,8 +9,8 @@ var _uuid = require("uuid");
9
9
 
10
10
  var _ModalGroupManager = require("./ModalGroupManager");
11
11
 
12
- const useModalManager = modal => {
13
- const [id] = (0, _react.useState)((0, _uuid.v4)());
12
+ const useModalManager = (modal, modalId) => {
13
+ const [id] = (0, _react.useState)(modalId ?? (0, _uuid.v4)());
14
14
 
15
15
  _ModalGroupManager.modalLifecycle.sync(id, modal);
16
16
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/atoms/Modal/useModalManager.ts"],"names":["useModalManager","modal","id","modalLifecycle","sync","show","close","destroy"],"mappings":";;;;;AAAA;;AACA;;AACA;;AAWO,MAAMA,eAAe,GAAIC,KAAD,IAA2C;AAEtE,QAAM,CAACC,EAAD,IAAO,qBAAS,eAAT,CAAb;;AACAC,oCAAeC,IAAf,CAAoBF,EAApB,EAAwBD,KAAxB;;AAEA,QAAMI,IAAI,GAAG,wBAAY,MAAM;AAC3BF,sCAAeE,IAAf,CAAoBH,EAApB;AACH,GAFY,EAEV,CAACA,EAAD,CAFU,CAAb;AAIA,QAAMI,KAAK,GAAG,wBAAY,MAAM;AAC5BH,sCAAeG,KAAf,CAAqBJ,EAArB;AACH,GAFa,EAEX,CAACA,EAAD,CAFW,CAAd;AAIA,wBAAU,MAAM;AACZ,WAAO,MAAMC,kCAAeI,OAAf,CAAuBL,EAAvB,CAAb;AACH,GAFD,EAEG,EAFH;AAIA,SAAO;AACHG,IAAAA,IADG;AAEHC,IAAAA;AAFG,GAAP;AAIH,CArBM","sourcesContent":["import { ReactElement, useCallback, useEffect, useState } from \"react\"\nimport { v4 as uuidv4 } from 'uuid'\nimport { modalLifecycle } from \"./ModalGroupManager\"\nimport { IBaseModal } from \"./ui/types\"\n\n/**\n * Use this hook to tell the modal lifecycle handler that you want to add\n * a new modal component. \n * \n * @param id \n * @param modal \n * @returns\n */\nexport const useModalManager = (modal: () => ReactElement<IBaseModal>) => {\n\n const [id] = useState(uuidv4())\n modalLifecycle.sync(id, modal)\n\n const show = useCallback(() => {\n modalLifecycle.show(id)\n }, [id])\n\n const close = useCallback(() => {\n modalLifecycle.close(id)\n }, [id])\n \n useEffect(() => {\n return () => modalLifecycle.destroy(id)\n }, [])\n\n return {\n show,\n close\n }\n}"],"file":"useModalManager.js"}
1
+ {"version":3,"sources":["../../../../src/components/atoms/Modal/useModalManager.ts"],"names":["useModalManager","modal","modalId","id","modalLifecycle","sync","show","close","destroy"],"mappings":";;;;;AAAA;;AACA;;AACA;;AAWO,MAAMA,eAAe,GAAG,CAACC,KAAD,EAAwCC,OAAxC,KAA6D;AAExF,QAAM,CAACC,EAAD,IAAO,qBAASD,OAAO,IAAI,eAApB,CAAb;;AACAE,oCAAeC,IAAf,CAAoBF,EAApB,EAAwBF,KAAxB;;AAEA,QAAMK,IAAI,GAAG,wBAAY,MAAM;AAC3BF,sCAAeE,IAAf,CAAoBH,EAApB;AACH,GAFY,EAEV,CAACA,EAAD,CAFU,CAAb;AAIA,QAAMI,KAAK,GAAG,wBAAY,MAAM;AAC5BH,sCAAeG,KAAf,CAAqBJ,EAArB;AACH,GAFa,EAEX,CAACA,EAAD,CAFW,CAAd;AAIA,wBAAU,MAAM;AACZ,WAAO,MAAMC,kCAAeI,OAAf,CAAuBL,EAAvB,CAAb;AACH,GAFD,EAEG,EAFH;AAIA,SAAO;AACHG,IAAAA,IADG;AAEHC,IAAAA;AAFG,GAAP;AAIH,CArBM","sourcesContent":["import { ReactElement, useCallback, useEffect, useState } from \"react\"\nimport { v4 as uuidv4 } from 'uuid'\nimport { modalLifecycle } from \"./ModalGroupManager\"\nimport { IBaseModal } from \"./ui/types\"\n\n/**\n * Use this hook to tell the modal lifecycle handler that you want to add\n * a new modal component. \n * \n * @param id \n * @param modal \n * @returns\n */\nexport const useModalManager = (modal: () => ReactElement<IBaseModal>, modalId?: string) => {\n\n const [id] = useState(modalId ?? uuidv4())\n modalLifecycle.sync(id, modal)\n\n const show = useCallback(() => {\n modalLifecycle.show(id)\n }, [id])\n\n const close = useCallback(() => {\n modalLifecycle.close(id)\n }, [id])\n \n useEffect(() => {\n return () => modalLifecycle.destroy(id)\n }, [])\n\n return {\n show,\n close\n }\n}"],"file":"useModalManager.js"}
@@ -0,0 +1,4 @@
1
+ export declare const useModalRemoteControl: (modalId: string) => {
2
+ show: () => void;
3
+ close: () => void;
4
+ };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.useModalRemoteControl = void 0;
5
+
6
+ var _react = require("react");
7
+
8
+ var _ModalGroupManager = require("./ModalGroupManager");
9
+
10
+ const useModalRemoteControl = modalId => {
11
+ const show = (0, _react.useCallback)(() => {
12
+ _ModalGroupManager.modalLifecycle.show(modalId);
13
+ }, [modalId]);
14
+ const close = (0, _react.useCallback)(() => {
15
+ _ModalGroupManager.modalLifecycle.close(modalId);
16
+ }, [modalId]);
17
+ return {
18
+ show,
19
+ close
20
+ };
21
+ };
22
+
23
+ exports.useModalRemoteControl = useModalRemoteControl;
24
+ //# sourceMappingURL=useModalRemoteControl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/atoms/Modal/useModalRemoteControl.ts"],"names":["useModalRemoteControl","modalId","show","modalLifecycle","close"],"mappings":";;;;;AAAA;;AACA;;AASO,MAAMA,qBAAqB,GAAIC,OAAD,IAAqB;AAEtD,QAAMC,IAAI,GAAG,wBAAY,MAAM;AAC3BC,sCAAeD,IAAf,CAAoBD,OAApB;AACH,GAFY,EAEV,CAACA,OAAD,CAFU,CAAb;AAIA,QAAMG,KAAK,GAAG,wBAAY,MAAM;AAC5BD,sCAAeC,KAAf,CAAqBH,OAArB;AACH,GAFa,EAEX,CAACA,OAAD,CAFW,CAAd;AAIA,SAAO;AACHC,IAAAA,IADG;AAEHE,IAAAA;AAFG,GAAP;AAKH,CAfM","sourcesContent":["import { useCallback } from \"react\"\nimport { modalLifecycle } from \"./ModalGroupManager\"\n\n/**\n * Use it to control a specific modal wherever it's.\n * Just provide an id of a specific instance.\n * \n * @param modalId \n * @returns \n */\nexport const useModalRemoteControl = (modalId: string) => {\n\n const show = useCallback(() => {\n modalLifecycle.show(modalId)\n }, [modalId])\n\n const close = useCallback(() => {\n modalLifecycle.close(modalId)\n }, [modalId])\n\n return {\n show,\n close\n }\n\n}"],"file":"useModalRemoteControl.js"}
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * from '@tecsinapse/react-core';
2
2
  export { Header, HeaderProps } from './components/atoms/Header';
3
3
  export { Select, SelectNativeProps } from './components/molecules/Select';
4
4
  export { Input, InputNativeProps } from './components/atoms/Input';
5
+ export { InputMask, InputMaskNativeProps } from './components/atoms/InputMask';
5
6
  export { TextArea, TextAreaProps } from './components/atoms/TextArea';
6
7
  export { Text, TextNativeProps } from './components/atoms/Text';
7
8
  export { Error, Loading, Success, Button, ButtonNativeProps, } from './components/atoms/Button';
@@ -17,5 +18,5 @@ export { DateTimePicker, NativeDateTimePickerProps, } from './components/molecul
17
18
  export { Avatar } from './components/atoms/Avatar';
18
19
  export { Calendar } from './components/molecules/Calendar';
19
20
  export { DateTimeSelector } from './components/molecules/DateTimeSelector';
20
- export { ModalGroupManager, ModalView, ModalLifecycleHandler, useLazyModalManager, useModalManager, IBaseModal, } from './components/atoms/Modal';
21
+ export { ModalGroupManager, ModalView, ModalLifecycleHandler, useLazyModalManager, useModalManager, useModalRemoteControl, IBaseModal, } from './components/atoms/Modal';
21
22
  export { Skeleton, SkeletonProps } from './components/atoms/Skeleton';
package/dist/index.js CHANGED
@@ -8,6 +8,8 @@ var _exportNames = {
8
8
  SelectNativeProps: true,
9
9
  Input: true,
10
10
  InputNativeProps: true,
11
+ InputMask: true,
12
+ InputMaskNativeProps: true,
11
13
  TextArea: true,
12
14
  TextAreaProps: true,
13
15
  Text: true,
@@ -42,11 +44,12 @@ var _exportNames = {
42
44
  ModalLifecycleHandler: true,
43
45
  useLazyModalManager: true,
44
46
  useModalManager: true,
47
+ useModalRemoteControl: true,
45
48
  IBaseModal: true,
46
49
  Skeleton: true,
47
50
  SkeletonProps: true
48
51
  };
49
- exports.SkeletonProps = exports.Skeleton = exports.IBaseModal = exports.useModalManager = exports.useLazyModalManager = exports.ModalLifecycleHandler = exports.ModalView = exports.ModalGroupManager = exports.DateTimeSelector = exports.Calendar = exports.Avatar = exports.NativeDateTimePickerProps = exports.DateTimePicker = exports.NativeDatePickerProps = exports.DatePicker = exports.SnackbarNativeProps = exports.Snackbar = exports.BadgeNativeProps = exports.Badge = exports.SnappingSliderProps = exports.SnappingSlider = exports.TagProps = exports.Tag = exports.BottomNavigatorProps = exports.BottomNavigator = exports.InputPasswordNativeProps = exports.InputPassword = exports.GroupButtonOption = exports.ButtonNativeProps = exports.Button = exports.Success = exports.Loading = exports.Error = exports.TextNativeProps = exports.Text = exports.TextAreaProps = exports.TextArea = exports.InputNativeProps = exports.Input = exports.SelectNativeProps = exports.Select = exports.HeaderProps = exports.Header = void 0;
52
+ exports.SkeletonProps = exports.Skeleton = exports.IBaseModal = exports.useModalRemoteControl = exports.useModalManager = exports.useLazyModalManager = exports.ModalLifecycleHandler = exports.ModalView = exports.ModalGroupManager = exports.DateTimeSelector = exports.Calendar = exports.Avatar = exports.NativeDateTimePickerProps = exports.DateTimePicker = exports.NativeDatePickerProps = exports.DatePicker = exports.SnackbarNativeProps = exports.Snackbar = exports.BadgeNativeProps = exports.Badge = exports.SnappingSliderProps = exports.SnappingSlider = exports.TagProps = exports.Tag = exports.BottomNavigatorProps = exports.BottomNavigator = exports.InputPasswordNativeProps = exports.InputPassword = exports.GroupButtonOption = exports.ButtonNativeProps = exports.Button = exports.Success = exports.Loading = exports.Error = exports.TextNativeProps = exports.Text = exports.TextAreaProps = exports.TextArea = exports.InputMaskNativeProps = exports.InputMask = exports.InputNativeProps = exports.Input = exports.SelectNativeProps = exports.Select = exports.HeaderProps = exports.Header = void 0;
50
53
 
51
54
  var _reactCore = require("@tecsinapse/react-core");
52
55
 
@@ -72,6 +75,11 @@ var _Input = require("./components/atoms/Input");
72
75
  exports.Input = _Input.Input;
73
76
  exports.InputNativeProps = _Input.InputNativeProps;
74
77
 
78
+ var _InputMask = require("./components/atoms/InputMask");
79
+
80
+ exports.InputMask = _InputMask.InputMask;
81
+ exports.InputMaskNativeProps = _InputMask.InputMaskNativeProps;
82
+
75
83
  var _TextArea = require("./components/atoms/TextArea");
76
84
 
77
85
  exports.TextArea = _TextArea.TextArea;
@@ -153,6 +161,7 @@ exports.ModalView = _Modal.ModalView;
153
161
  exports.ModalLifecycleHandler = _Modal.ModalLifecycleHandler;
154
162
  exports.useLazyModalManager = _Modal.useLazyModalManager;
155
163
  exports.useModalManager = _Modal.useModalManager;
164
+ exports.useModalRemoteControl = _Modal.useModalRemoteControl;
156
165
  exports.IBaseModal = _Modal.IBaseModal;
157
166
 
158
167
  var _Skeleton = require("./components/atoms/Skeleton");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;;;;AACA;;;;;AACA;;;;;AACA;;;;;AACA;;;;;AACA;;;;;;;;AAOA;;;;AACA;;;;;AAIA;;;;;AAIA;;;;;AACA;;;;;AAIA;;;;;AACA;;;;;AACA;;;;;AAIA;;;;;AAIA;;;;AACA;;;;AACA;;;;AACA;;;;;;;;;AAQA","sourcesContent":["export * from '@tecsinapse/react-core';\nexport { Header, HeaderProps } from './components/atoms/Header';\nexport { Select, SelectNativeProps } from './components/molecules/Select';\nexport { Input, InputNativeProps } from './components/atoms/Input';\nexport { TextArea, TextAreaProps } from './components/atoms/TextArea';\nexport { Text, TextNativeProps } from './components/atoms/Text';\nexport {\n Error,\n Loading,\n Success,\n Button,\n ButtonNativeProps,\n} from './components/atoms/Button';\nexport { GroupButtonOption } from './components/atoms/GroupButton';\nexport {\n InputPassword,\n InputPasswordNativeProps,\n} from './components/molecules/InputPassword';\nexport {\n BottomNavigator,\n BottomNavigatorProps,\n} from './components/atoms/BottomNavigator';\nexport { Tag, TagProps } from './components/atoms/Tag';\nexport {\n SnappingSlider,\n SnappingSliderProps,\n} from './components/atoms/SnappingSlider';\nexport { Badge, BadgeNativeProps } from './components/atoms/Badge';\nexport { Snackbar, SnackbarNativeProps } from './components/molecules/Snackbar';\nexport {\n DatePicker,\n NativeDatePickerProps,\n} from './components/molecules/DatePicker';\nexport {\n DateTimePicker,\n NativeDateTimePickerProps,\n} from './components/molecules/DateTimePicker';\nexport { Avatar } from './components/atoms/Avatar';\nexport { Calendar } from './components/molecules/Calendar';\nexport { DateTimeSelector } from './components/molecules/DateTimeSelector';\nexport {\n ModalGroupManager,\n ModalView,\n ModalLifecycleHandler,\n useLazyModalManager,\n useModalManager,\n IBaseModal,\n} from './components/atoms/Modal';\nexport { Skeleton, SkeletonProps } from './components/atoms/Skeleton';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;;;;AACA;;;;;AACA;;;;;AACA;;;;;AACA;;;;;AACA;;;;;AACA;;;;;;;;AAOA;;;;AACA;;;;;AAIA;;;;;AAIA;;;;;AACA;;;;;AAIA;;;;;AACA;;;;;AACA;;;;;AAIA;;;;;AAIA;;;;AACA;;;;AACA;;;;AACA;;;;;;;;;;AASA","sourcesContent":["export * from '@tecsinapse/react-core';\nexport { Header, HeaderProps } from './components/atoms/Header';\nexport { Select, SelectNativeProps } from './components/molecules/Select';\nexport { Input, InputNativeProps } from './components/atoms/Input';\nexport { InputMask, InputMaskNativeProps } from './components/atoms/InputMask';\nexport { TextArea, TextAreaProps } from './components/atoms/TextArea';\nexport { Text, TextNativeProps } from './components/atoms/Text';\nexport {\n Error,\n Loading,\n Success,\n Button,\n ButtonNativeProps,\n} from './components/atoms/Button';\nexport { GroupButtonOption } from './components/atoms/GroupButton';\nexport {\n InputPassword,\n InputPasswordNativeProps,\n} from './components/molecules/InputPassword';\nexport {\n BottomNavigator,\n BottomNavigatorProps,\n} from './components/atoms/BottomNavigator';\nexport { Tag, TagProps } from './components/atoms/Tag';\nexport {\n SnappingSlider,\n SnappingSliderProps,\n} from './components/atoms/SnappingSlider';\nexport { Badge, BadgeNativeProps } from './components/atoms/Badge';\nexport { Snackbar, SnackbarNativeProps } from './components/molecules/Snackbar';\nexport {\n DatePicker,\n NativeDatePickerProps,\n} from './components/molecules/DatePicker';\nexport {\n DateTimePicker,\n NativeDateTimePickerProps,\n} from './components/molecules/DateTimePicker';\nexport { Avatar } from './components/atoms/Avatar';\nexport { Calendar } from './components/molecules/Calendar';\nexport { DateTimeSelector } from './components/molecules/DateTimeSelector';\nexport {\n ModalGroupManager,\n ModalView,\n ModalLifecycleHandler,\n useLazyModalManager,\n useModalManager,\n useModalRemoteControl,\n IBaseModal,\n} from './components/atoms/Modal';\nexport { Skeleton, SkeletonProps } from './components/atoms/Skeleton';\n"],"file":"index.js"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tecsinapse/react-native-kit",
3
3
  "description": "TecSinapse React Native components",
4
- "version": "1.16.2",
4
+ "version": "1.17.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "MIT",
@@ -13,7 +13,7 @@
13
13
  "dependencies": {
14
14
  "@emotion/native": "^11.0.0",
15
15
  "@emotion/react": "^11.4.1",
16
- "@tecsinapse/react-core": "^1.15.1",
16
+ "@tecsinapse/react-core": "^1.16.0",
17
17
  "react-native-linear-gradient": "^2.5.6"
18
18
  },
19
19
  "repository": {
@@ -36,5 +36,5 @@
36
36
  "devDependencies": {
37
37
  "@types/uuid": "^8.3.3"
38
38
  },
39
- "gitHead": "b2b885237c90b782b17e4081871b806b6191e3f2"
39
+ "gitHead": "ae6f88727b5e35210ada1c7ea0b54d24094af22c"
40
40
  }
@@ -0,0 +1,96 @@
1
+ import {
2
+ FontStackType,
3
+ FontWeightType,
4
+ Hint,
5
+ InputContainerProps,
6
+ InputMaskElementProps,
7
+ useInputFocus,
8
+ } from '@tecsinapse/react-core';
9
+ import React, { FC } from 'react';
10
+ import { View } from 'react-native';
11
+ import { StyledInputContainer, StyledNativeInputMask } from './styled';
12
+ import { Text } from '../Text';
13
+
14
+ export interface InputMaskNativeProps
15
+ extends Omit<InputMaskElementProps, 'style'>,
16
+ InputContainerProps {
17
+ inputFontStack?: FontStackType;
18
+ inputFontWeight?: FontWeightType;
19
+ }
20
+
21
+ const InputMask: FC<InputMaskNativeProps> = React.forwardRef(
22
+ (
23
+ {
24
+ label,
25
+ labelColor,
26
+ labelColorVariant,
27
+ labelColorTone,
28
+ labelTypography,
29
+ labelStack,
30
+ labelWeight,
31
+ leftComponent,
32
+ rightComponent,
33
+ disabled,
34
+ style,
35
+ borderColor,
36
+ borderColorGradation,
37
+ inputFontStack = 'default',
38
+ inputFontWeight = 'bold',
39
+ inputContainerStyle,
40
+ variant = 'default',
41
+ hintComponent,
42
+ hint,
43
+ onFocus,
44
+ onBlur,
45
+ ...rest
46
+ },
47
+ ref
48
+ ) => {
49
+ const _hint = hintComponent || (
50
+ <Hint TextComponent={Text} text={hint} variant={variant} />
51
+ );
52
+ const { focused, handleBlur, handleFocus } = useInputFocus(
53
+ onFocus,
54
+ onBlur,
55
+ !disabled
56
+ );
57
+
58
+ return (
59
+ <View style={style}>
60
+ <StyledInputContainer
61
+ label={label}
62
+ labelColor={labelColor}
63
+ labelColorVariant={labelColorVariant}
64
+ labelColorTone={labelColorTone}
65
+ labelTypography={labelTypography}
66
+ labelStack={labelStack}
67
+ labelWeight={labelWeight}
68
+ LabelComponent={Text}
69
+ leftComponent={leftComponent}
70
+ rightComponent={rightComponent}
71
+ borderColor={borderColor}
72
+ borderColorGradation={borderColorGradation}
73
+ inputContainerStyle={inputContainerStyle}
74
+ focused={focused}
75
+ disabled={disabled}
76
+ variant={variant}
77
+ >
78
+ <StyledNativeInputMask
79
+ {...rest}
80
+ ref={ref}
81
+ fontStack={inputFontStack}
82
+ fontWeight={inputFontWeight}
83
+ disabled={disabled}
84
+ onFocus={handleFocus}
85
+ onBlur={handleBlur}
86
+ />
87
+ </StyledInputContainer>
88
+ {hint && _hint}
89
+ </View>
90
+ );
91
+ }
92
+ );
93
+
94
+ InputMask.displayName = 'InputMask';
95
+
96
+ export default InputMask;
@@ -0,0 +1 @@
1
+ export { default as InputMask, InputMaskNativeProps } from './InputMask';
@@ -0,0 +1,25 @@
1
+ import styled from '@emotion/native';
2
+ import {
3
+ InputContainer,
4
+ InputMaskElement,
5
+ RFValueStr,
6
+ StyleProps,
7
+ } from '@tecsinapse/react-core';
8
+ import { Font, fontStyles } from '../Text/styled';
9
+ import { InputMaskNativeProps } from './InputMask';
10
+
11
+ export const StyledInputContainer = styled(InputContainer)<Partial<StyleProps>>`
12
+ min-height: ${RFValueStr('50px')};
13
+ `;
14
+
15
+ const StyledNativeInputMaskBase = styled(InputMaskElement)<
16
+ Partial<InputMaskNativeProps> & Partial<StyleProps>
17
+ >`
18
+ height: ${({ theme }) => theme.typography.h5.lineHeight};
19
+ width: 100%;
20
+ padding: 0;
21
+ `;
22
+
23
+ export const StyledNativeInputMask = styled(StyledNativeInputMaskBase)<
24
+ Font & Partial<InputMaskNativeProps> & Partial<StyleProps>
25
+ >(fontStyles);
@@ -81,7 +81,7 @@ export class ModalLifecycleHandler {
81
81
  */
82
82
  public sync = (id: string, modal: () => ReactElement<IBaseModal>) => {
83
83
  if (this.nodeGroup.has(id)) {
84
- const savedNode = this.nodeGroup.get(id)
84
+ const savedNode = this.findNode(id)
85
85
  savedNode && this.nodeGroup.set(id, { ...savedNode, modal })
86
86
  return
87
87
  }
@@ -105,18 +105,29 @@ export class ModalLifecycleHandler {
105
105
  * @param id
106
106
  */
107
107
  private remove = (id: string) => {
108
- const savedNode = this.nodeGroup.get(id)
108
+ const savedNode = this.findNode(id)
109
109
  savedNode && this.nodeGroup.set(id, { ...savedNode, lastVisualization: undefined })
110
110
  this.update()
111
111
  }
112
112
 
113
+ /**
114
+ * Find a modal node by id.
115
+ *
116
+ * @param id
117
+ */
118
+ private findNode = (id: string) => {
119
+ const node = this.nodeGroup.get(id)
120
+ !node && console.warn(`No modal was found with the id "${id}"`)
121
+ return node
122
+ }
123
+
113
124
  /**
114
125
  * Makes a modal appears.
115
126
  *
116
127
  * @param id
117
128
  */
118
129
  public show = (id: string) => {
119
- const savedNode = this.nodeGroup.get(id)
130
+ const savedNode = this.findNode(id)
120
131
  savedNode && this.nodeGroup.set(id, { ...savedNode, visible: true, lastVisualization: new Date() })
121
132
  this.update()
122
133
  }
@@ -127,7 +138,7 @@ export class ModalLifecycleHandler {
127
138
  * @param id
128
139
  */
129
140
  public close = (id: string) => {
130
- const savedNode = this.nodeGroup.get(id)
141
+ const savedNode = this.findNode(id)
131
142
  savedNode && this.nodeGroup.set(id, { ...savedNode, visible: false })
132
143
  this.update()
133
144
  }
@@ -3,4 +3,5 @@ export * from './ModalLifecycleHandler'
3
3
  export * from './ui/BaseModalView'
4
4
  export * from './ui/types'
5
5
  export * from './useModalManager'
6
- export * from './useLazyModalManager'
6
+ export * from './useLazyModalManager'
7
+ export * from './useModalRemoteControl'
@@ -11,9 +11,9 @@ import { IBaseModal } from "./ui/types"
11
11
  * @param modal
12
12
  * @returns
13
13
  */
14
- export const useLazyModalManager = () => {
14
+ export const useLazyModalManager = (modalId?: string) => {
15
15
 
16
- const [id] = useState(uuidv4())
16
+ const [id] = useState(modalId ?? uuidv4())
17
17
 
18
18
  const requestUpdate = useCallback(() => modalLifecycle.update(), [])
19
19
 
@@ -11,9 +11,9 @@ import { IBaseModal } from "./ui/types"
11
11
  * @param modal
12
12
  * @returns
13
13
  */
14
- export const useModalManager = (modal: () => ReactElement<IBaseModal>) => {
14
+ export const useModalManager = (modal: () => ReactElement<IBaseModal>, modalId?: string) => {
15
15
 
16
- const [id] = useState(uuidv4())
16
+ const [id] = useState(modalId ?? uuidv4())
17
17
  modalLifecycle.sync(id, modal)
18
18
 
19
19
  const show = useCallback(() => {
@@ -0,0 +1,26 @@
1
+ import { useCallback } from "react"
2
+ import { modalLifecycle } from "./ModalGroupManager"
3
+
4
+ /**
5
+ * Use it to control a specific modal wherever it's.
6
+ * Just provide an id of a specific instance.
7
+ *
8
+ * @param modalId
9
+ * @returns
10
+ */
11
+ export const useModalRemoteControl = (modalId: string) => {
12
+
13
+ const show = useCallback(() => {
14
+ modalLifecycle.show(modalId)
15
+ }, [modalId])
16
+
17
+ const close = useCallback(() => {
18
+ modalLifecycle.close(modalId)
19
+ }, [modalId])
20
+
21
+ return {
22
+ show,
23
+ close
24
+ }
25
+
26
+ }
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@ export * from '@tecsinapse/react-core';
2
2
  export { Header, HeaderProps } from './components/atoms/Header';
3
3
  export { Select, SelectNativeProps } from './components/molecules/Select';
4
4
  export { Input, InputNativeProps } from './components/atoms/Input';
5
+ export { InputMask, InputMaskNativeProps } from './components/atoms/InputMask';
5
6
  export { TextArea, TextAreaProps } from './components/atoms/TextArea';
6
7
  export { Text, TextNativeProps } from './components/atoms/Text';
7
8
  export {
@@ -44,6 +45,7 @@ export {
44
45
  ModalLifecycleHandler,
45
46
  useLazyModalManager,
46
47
  useModalManager,
48
+ useModalRemoteControl,
47
49
  IBaseModal,
48
50
  } from './components/atoms/Modal';
49
51
  export { Skeleton, SkeletonProps } from './components/atoms/Skeleton';