tycho-components 0.2.5-SNAPSHOT-2 → 0.2.6-SNAPSHOT-1

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.
@@ -8,5 +8,8 @@ declare const CookieStorage: {
8
8
  setRedirectUri: typeof setRedirectUri;
9
9
  getRedirectUri: typeof getRedirectUri;
10
10
  removeRedirectUri: typeof removeRedirectUri;
11
+ set: (key: string, value: string) => void;
12
+ get: (key: string) => string | undefined;
13
+ remove: (key: string) => void;
11
14
  };
12
15
  export default CookieStorage;
@@ -2,6 +2,16 @@ import Cookies from 'js-cookie';
2
2
  const REDIRECT_URI = 'redirect_uri_tycho';
3
3
  const JWT_TOKEN = 'jwt_token_tycho';
4
4
  const expireDays = 7;
5
+ const set = (key, value) => {
6
+ Cookies.set(key, value, { expires: expireDays });
7
+ };
8
+ const get = (key) => {
9
+ const cookie = Cookies.get(key);
10
+ return cookie === 'undefined' ? '' : cookie;
11
+ };
12
+ const remove = (key) => {
13
+ return Cookies.remove(key);
14
+ };
5
15
  const setJwtToken = (jwtToken) => {
6
16
  Cookies.set(JWT_TOKEN, jwtToken, { expires: expireDays });
7
17
  };
@@ -28,5 +38,8 @@ const CookieStorage = {
28
38
  setRedirectUri,
29
39
  getRedirectUri,
30
40
  removeRedirectUri,
41
+ set,
42
+ get,
43
+ remove,
31
44
  };
32
45
  export default CookieStorage;
@@ -5,5 +5,6 @@ declare const UsabilityUtils: {
5
5
  goToAnchor: (anchorId: string, e?: any) => void;
6
6
  isDesktop: () => boolean;
7
7
  attachEnter: (event: React.KeyboardEvent<HTMLInputElement>, handleEnter: () => void) => void;
8
+ copy: (text: string, callback?: () => void) => void;
8
9
  };
9
10
  export default UsabilityUtils;
@@ -1,4 +1,9 @@
1
1
  const isDesktop = () => import.meta.env.VITE_APP_ENV === 'desktop';
2
+ const copy = (text, callback) => {
3
+ navigator.clipboard.writeText(text).then(() => {
4
+ callback && callback();
5
+ });
6
+ };
2
7
  const attachEnter = (event, handleEnter) => {
3
8
  // 'keypress' event misbehaves on mobile so we track 'Enter' key via 'keydown' event
4
9
  if (event.key === 'Enter') {
@@ -37,5 +42,6 @@ const UsabilityUtils = {
37
42
  goToAnchor,
38
43
  isDesktop,
39
44
  attachEnter,
45
+ copy,
40
46
  };
41
47
  export default UsabilityUtils;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.2.5-SNAPSHOT-2",
4
+ "version": "0.2.6-SNAPSHOT-1",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {