dry-ux 1.0.0 → 1.2.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.
@@ -0,0 +1,48 @@
1
+ import * as React from "react";
2
+ export const preventDefault = (handler) => {
3
+ return (event) => {
4
+ event.preventDefault();
5
+ handler && handler(event);
6
+ };
7
+ };
8
+ export const importScript = (resourceUrl, singleton = true) => {
9
+ return new Promise(resolve => {
10
+ React.useEffect(() => {
11
+ const script = document.createElement("script");
12
+ if (!$(`script[src='${resourceUrl}']`).length) {
13
+ script.src = resourceUrl;
14
+ script.async = true;
15
+ script.onload = () => resolve();
16
+ document.body.appendChild(script);
17
+ }
18
+ else {
19
+ resolve();
20
+ }
21
+ return () => !singleton && script.remove();
22
+ }, []);
23
+ });
24
+ };
25
+ export const importStyleSheet = (resourceUrl) => {
26
+ React.useEffect(() => {
27
+ if (!$(`link[href='${resourceUrl}']`).length) {
28
+ const link = document.createElement("link");
29
+ link.href = resourceUrl;
30
+ link.rel = "stylesheet";
31
+ link.type = "text/css";
32
+ document.head.appendChild(link);
33
+ }
34
+ }, []);
35
+ };
36
+ export const useCountdown = (seconds, onExpiry) => {
37
+ const [secondsRemaining, setSecondsRemaining] = React.useState(seconds);
38
+ const interval = setInterval(() => {
39
+ if (secondsRemaining === 1) {
40
+ clearInterval(interval);
41
+ onExpiry();
42
+ }
43
+ setSecondsRemaining(secondsRemaining - 1);
44
+ }, 1000);
45
+ React.useEffect(() => () => clearInterval(interval));
46
+ return secondsRemaining;
47
+ };
48
+ //# sourceMappingURL=utilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../src/helpers/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAA8B,EAAE,EAAE;IAC7D,OAAO,CAAC,KAAU,EAAE,EAAE;QAClB,KAAK,CAAC,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AC,WAAW,CAAC,IAAI,CAAC,CAAC;SACnC;IACL,CAAC,EAAE,EAAE,CAAC,CAAC;AACX,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAe,EAAE,QAAoB,EAAE,EAAE;IAClE,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAS,OAAO,CAAC,CAAC;IAEhF,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE;QAC9B,IAAI,gBAAgB,KAAK,CAAC,EAAE;YACxB,aAAa,CAAC,QAAQ,CAAC,CAAC;YACxB,QAAQ,EAAE,CAAC;SACd;QACD,mBAAmB,CAAC,gBAAgB,GAAG,CAAC,CAAC,CAAC;IAC9C,CAAC,EAAE,IAAI,CAAC,CAAC;IAET,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrD,OAAO,gBAAgB,CAAC;AAC5B,CAAC,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export { useUIUtilContext } from "./ui-utils/UIUtilProvider";
2
2
  export { DryUXProvider } from "./provider";
3
+ export * from "./helpers/utilities";
3
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,cAAc,qBAAqB,CAAC"}
package/package.json CHANGED
@@ -1,18 +1,22 @@
1
1
  {
2
2
  "name": "dry-ux",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "build": "tsc",
8
8
  "format": "prettier --write \"src/**/*.ts\" \"src/**/*.tsx\"",
9
- "lint": "tslint -p tsconfig.json"
9
+ "update:version": "npm version minor --no-git-tag-version",
10
+ "prepublish": "npm run format && npm run build && npm run update:version",
11
+ "publish": "npm run prepublish && npm publish"
10
12
  },
11
13
  "repository": {
12
14
  "type": "git",
13
15
  "url": "git+https://github.com/navedr/dry-ux.git"
14
16
  },
15
- "files": ["dist/**/*"],
17
+ "files": [
18
+ "dist/**/*"
19
+ ],
16
20
  "keywords": [],
17
21
  "author": "Naved Rangwala",
18
22
  "license": "ISC",