@spaced-out/ui-design-system 0.1.44 → 0.1.46

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.
@@ -1,8 +1,9 @@
1
1
  amet
2
2
  Anant
3
3
  argstable
4
- atleast
5
4
  ashwini-sensehq
5
+ Ashwini
6
+ atleast
6
7
  autodocs
7
8
  circlehollow
8
9
  CODEOWNERS
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.1.46](https://github.com/spaced-out/ui-design-system/compare/v0.1.45...v0.1.46) (2023-08-29)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * add delay to clear extras data in use modal ([#140](https://github.com/spaced-out/ui-design-system/issues/140)) ([030c841](https://github.com/spaced-out/ui-design-system/commit/030c84138f2582b8769a8bd249ea1f8a9a125e51))
11
+
12
+ ### [0.1.45](https://github.com/spaced-out/ui-design-system/compare/v0.1.44...v0.1.45) (2023-08-29)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * add use modal hook ([#139](https://github.com/spaced-out/ui-design-system/issues/139)) ([bf5a6a9](https://github.com/spaced-out/ui-design-system/commit/bf5a6a99f3fcefb8493f33e0a1a188a5cb619799))
18
+
5
19
  ### [0.1.44](https://github.com/spaced-out/ui-design-system/compare/v0.1.44-beta.0...v0.1.44) (2023-08-28)
6
20
 
7
21
 
@@ -47,6 +47,17 @@ Object.keys(_useLockedBody).forEach(function (key) {
47
47
  }
48
48
  });
49
49
  });
50
+ var _useModal = require("./useModal");
51
+ Object.keys(_useModal).forEach(function (key) {
52
+ if (key === "default" || key === "__esModule") return;
53
+ if (key in exports && exports[key] === _useModal[key]) return;
54
+ Object.defineProperty(exports, key, {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _useModal[key];
58
+ }
59
+ });
60
+ });
50
61
  var _useMountTransition = require("./useMountTransition");
51
62
  Object.keys(_useMountTransition).forEach(function (key) {
52
63
  if (key === "default" || key === "__esModule") return;
@@ -4,6 +4,7 @@ export * from './useCopyToClipboard';
4
4
  export * from './useFileUpload';
5
5
  export * from './useInputState';
6
6
  export * from './useLockedBody';
7
+ export * from './useModal';
7
8
  export * from './useMountTransition';
8
9
  export * from './usePagination';
9
10
  export * from './useToastPortal';
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _useModal = require("./useModal");
7
+ Object.keys(_useModal).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _useModal[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _useModal[key];
14
+ }
15
+ });
16
+ });
@@ -0,0 +1,3 @@
1
+ // @flow strict
2
+
3
+ export * from './useModal';
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useModal = void 0;
7
+ var _react = require("react");
8
+ var _motion = require("../../styles/variables/_motion");
9
+
10
+ const useModal = () => {
11
+ const [isOpen, setIsOpen] = (0, _react.useState)(false);
12
+ const [extras, setExtras] = (0, _react.useState)({});
13
+ const openModal = (0, _react.useCallback)(function () {
14
+ let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
15
+ setExtras(props);
16
+ setIsOpen(true);
17
+ }, []);
18
+ const closeModal = () => {
19
+ setIsOpen(false);
20
+ // Since the Dialog close uses animation and its duration is motionDurationNormal, we should clear the data after the animation duration for better user experience
21
+ setTimeout(() => {
22
+ setExtras({});
23
+ }, parseInt(_motion.motionDurationNormal));
24
+ };
25
+ return {
26
+ isOpen,
27
+ openModal,
28
+ closeModal,
29
+ extras
30
+ };
31
+ };
32
+ exports.useModal = useModal;
@@ -0,0 +1,39 @@
1
+ // @flow strict
2
+
3
+ import {useCallback, useState} from 'react';
4
+
5
+ import {motionDurationNormal} from '../../styles/variables/_motion';
6
+
7
+
8
+ export type UseModalExtras = {
9
+ // TODO(Ashwini): Add type for extras
10
+ // $FlowFixMe
11
+ [key: string]: any,
12
+ };
13
+
14
+ export type UseModalReturnType = {
15
+ isOpen: boolean,
16
+ openModal: (extras?: UseModalExtras) => void,
17
+ closeModal: () => void,
18
+ extras: UseModalExtras,
19
+ };
20
+
21
+ export const useModal = (): UseModalReturnType => {
22
+ const [isOpen, setIsOpen] = useState(false);
23
+ const [extras, setExtras] = useState({});
24
+
25
+ const openModal = useCallback((props?: UseModalExtras = {}) => {
26
+ setExtras(props);
27
+ setIsOpen(true);
28
+ }, []);
29
+
30
+ const closeModal = () => {
31
+ setIsOpen(false);
32
+ // Since the Dialog close uses animation and its duration is motionDurationNormal, we should clear the data after the animation duration for better user experience
33
+ setTimeout(() => {
34
+ setExtras({});
35
+ }, parseInt(motionDurationNormal));
36
+ };
37
+
38
+ return {isOpen, openModal, closeModal, extras};
39
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaced-out/ui-design-system",
3
- "version": "0.1.44",
3
+ "version": "0.1.46",
4
4
  "main": "index.js",
5
5
  "description": "Sense UI components library",
6
6
  "author": {