@gaddario98/react-core 2.0.1 → 2.0.2

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,84 @@
1
+ 'use strict';var compilerRuntime=require('react/compiler-runtime'),react=require('react'),reactState=require('@gaddario98/react-state');const {
2
+ atom: notificationAtom,
3
+ useValue: useNotificationValue,
4
+ useState: useNotificationState
5
+ } = reactState.atomStateGenerator({
6
+ defaultValue: null,
7
+ key: 'reactNotificationAtom',
8
+ persist: false
9
+ });const useNotificationSet = () => {
10
+ const [, setValue] = useNotificationState();
11
+ return setValue;
12
+ };
13
+ const useNotification = t0 => {
14
+ const $ = compilerRuntime.c(10);
15
+ const ns = t0 === undefined ? "notifications" : t0;
16
+ const setNotification = useNotificationSet();
17
+ let t1;
18
+ if ($[0] !== ns || $[1] !== setNotification) {
19
+ t1 = {
20
+ setNotification,
21
+ ns
22
+ };
23
+ $[0] = ns;
24
+ $[1] = setNotification;
25
+ $[2] = t1;
26
+ } else {
27
+ t1 = $[2];
28
+ }
29
+ const ref = react.useRef(t1);
30
+ let t2;
31
+ let t3;
32
+ if ($[3] !== ns || $[4] !== setNotification) {
33
+ t2 = () => {
34
+ ref.current = {
35
+ setNotification,
36
+ ns
37
+ };
38
+ };
39
+ t3 = [setNotification, ns];
40
+ $[3] = ns;
41
+ $[4] = setNotification;
42
+ $[5] = t2;
43
+ $[6] = t3;
44
+ } else {
45
+ t2 = $[5];
46
+ t3 = $[6];
47
+ }
48
+ react.useEffect(t2, t3);
49
+ let t4;
50
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
51
+ t4 = notification => {
52
+ ref.current.setNotification(Object.assign(Object.assign({
53
+ ns: ref.current.ns
54
+ }, notification), {
55
+ id: Date.now().toString()
56
+ }));
57
+ };
58
+ $[7] = t4;
59
+ } else {
60
+ t4 = $[7];
61
+ }
62
+ const showNotification = t4;
63
+ let t5;
64
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
65
+ t5 = () => {
66
+ ref.current.setNotification(null);
67
+ };
68
+ $[8] = t5;
69
+ } else {
70
+ t5 = $[8];
71
+ }
72
+ const clearNotification = t5;
73
+ let t6;
74
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
75
+ t6 = {
76
+ showNotification,
77
+ clearNotification
78
+ };
79
+ $[9] = t6;
80
+ } else {
81
+ t6 = $[9];
82
+ }
83
+ return t6;
84
+ };exports.notificationAtom=notificationAtom;exports.useNotification=useNotification;exports.useNotificationState=useNotificationState;exports.useNotificationValue=useNotificationValue;//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../notifications/notificationAtom.ts","../../notifications/useNotification.ts"],"sourcesContent":["import { atomStateGenerator } from '@gaddario98/react-state';\nimport type { NotificationMessage } from './types';\n\nconst {\n atom: notificationAtom,\n useValue: useNotificationValue,\n useState: useNotificationState,\n} = atomStateGenerator<NotificationMessage | null>({\n defaultValue: null,\n key: 'reactNotificationAtom',\n persist: false,\n});\n\nexport { notificationAtom, useNotificationValue, useNotificationState };\n","import { useCallback, useEffect, useRef } from 'react';\nimport { useNotificationState } from './notificationAtom';\nimport type { NotificationMessage } from './types';\n\n const useNotificationSet = () => {\n const [, setValue] = useNotificationState();\n return setValue;\n };\n\nexport const useNotification = (ns = 'notifications') => {\n const setNotification = useNotificationSet();\n const ref =useRef({setNotification, ns})\n\n useEffect(() => {\n ref.current = { setNotification, ns };\n }, [setNotification, ns]);\n\n const showNotification = useCallback(\n (notification: Omit<NotificationMessage, 'id'>) => {\n ref.current.setNotification({\n ns: ref.current.ns,\n ...notification,\n id: Date.now().toString(),\n });\n },\n [],\n );\n\n const clearNotification = useCallback(() => {\n ref.current.setNotification(null);\n }, []);\n\n return {\n showNotification,\n clearNotification,\n };\n};\n"],"names":["atom","notificationAtom","useValue","useNotificationValue","useState","useNotificationState","atomStateGenerator","defaultValue","key","persist","useNotificationSet","setValue","useNotification","t0","$","_c","ns","undefined","setNotification","t1","ref","useRef","t2","t3","current","useEffect","t4","Symbol","for","notification","Object","assign","id","Date","now","toString","showNotification","t5","clearNotification","t6"],"mappings":"wIAGA,MAAM;AACJA,EAAAA,IAAI,EAAEC,gBAAgB;AACtBC,EAAAA,QAAQ,EAAEC,oBAAoB;AAC9BC,EAAAA,QAAQ,EAAEC;AAAoB,CAC/B,GAAGC,6BAAkB,CAA6B;AACjDC,EAAAA,YAAY,EAAE,IAAI;AAClBC,EAAAA,GAAG,EAAE,uBAAuB;AAC5BC,EAAAA,OAAO,EAAE;AACV,CAAA,ECPC,MAAMC,kBAAkB,GAAGA,MAAA;AACzB,EAAA,MAAA,GAAAC,QAAA,CAAA,GAAqBN,oBAAoB,EAAE;AAAC,EAAA,OACrCM,QAAQ;AAAA,CAChB;AAEI,MAAMC,eAAe,GAAGC,EAAA,IAAA;EAAA,MAAAC,CAAA,GAAAC,iBAAA,CAAA,EAAA,CAAA;EAAC,MAAAC,EAAA,GAAAH,EAAoB,KAApBI,SAAoB,GAApB,eAAoB,GAApBJ,EAAoB;AAClD,EAAA,MAAAK,eAAA,GAAwBR,kBAAkB,EAAE;AAAC,EAAA,IAAAS,EAAA;AAAA,EAAA,IAAAL,CAAA,CAAA,CAAA,CAAA,KAAAE,EAAA,IAAAF,CAAA,QAAAI,eAAA,EAAA;IAC3BC,EAAA,GAAA;MAAAD,eAAA;AAAAF,MAAAA;KAAqB;AAAAF,IAAAA,CAAA,MAAAE,EAAA;AAAAF,IAAAA,CAAA,MAAAI,eAAA;AAAAJ,IAAAA,CAAA,MAAAK,EAAA;AAAA,EAAA,CAAA,MAAA;AAAAA,IAAAA,EAAA,GAAAL,CAAA,CAAA,CAAA,CAAA;AAAA,EAAA;AAAvC,EAAA,MAAAM,GAAA,GAAWC,YAAM,CAACF,EAAqB,CAAC;AAAA,EAAA,IAAAG,EAAA;AAAA,EAAA,IAAAC,EAAA;AAAA,EAAA,IAAAT,CAAA,CAAA,CAAA,CAAA,KAAAE,EA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AAA,2BAAA,CAAA,EAAA;AAEoCS,IAAAA,EAAA,GAAAA,MAAA;AACpCjB,MAAAA,GAAG,CAAAI,OAAQ,CAAAN,eAAgB,CAAC,IAAI,CAAC;IAAA,CAClC;AAAAJ,IAAAA,CAAA,MAAAuB,EAAA;AAAA,EAAA,CAAA,MAAA;AAAAA,IAAAA,EAAA,GAAAvB,CAAA,CAAA,CAAA,CAAA;AAAA,EAAA;EAFD,MAAAwB,iBAAA,GAA0BD,EAEpB;AAAC,EAAA,IAAAE,EAAA;AAAA,EAAA,IAAAzB,CAAA,CAAA,CAAA,CAAA,KAAAa,MAAA,CAAAC,GAAA,CAAA,2BAAA,CAAA,EAAA;IAEAW,EAAA,GAAA;MAAAH,gBAAA;AAAAE,MAAAA;KAGN;AAAAxB,IAAAA,CAAA,MAAAyB,EAAA;AAAA,EAAA,CAAA,MAAA;AAAAA,IAAAA,EAAA,GAAAzB,CAAA,CAAA,CAAA,CAAA;AAAA,EAAA;AAAA,EAAA,OAHMyB,EAGN;AAAA"}
@@ -0,0 +1,84 @@
1
+ import {c}from'react/compiler-runtime';import {useRef,useEffect}from'react';import {atomStateGenerator}from'@gaddario98/react-state';const {
2
+ atom: notificationAtom,
3
+ useValue: useNotificationValue,
4
+ useState: useNotificationState
5
+ } = atomStateGenerator({
6
+ defaultValue: null,
7
+ key: 'reactNotificationAtom',
8
+ persist: false
9
+ });const useNotificationSet = () => {
10
+ const [, setValue] = useNotificationState();
11
+ return setValue;
12
+ };
13
+ const useNotification = t0 => {
14
+ const $ = c(10);
15
+ const ns = t0 === undefined ? "notifications" : t0;
16
+ const setNotification = useNotificationSet();
17
+ let t1;
18
+ if ($[0] !== ns || $[1] !== setNotification) {
19
+ t1 = {
20
+ setNotification,
21
+ ns
22
+ };
23
+ $[0] = ns;
24
+ $[1] = setNotification;
25
+ $[2] = t1;
26
+ } else {
27
+ t1 = $[2];
28
+ }
29
+ const ref = useRef(t1);
30
+ let t2;
31
+ let t3;
32
+ if ($[3] !== ns || $[4] !== setNotification) {
33
+ t2 = () => {
34
+ ref.current = {
35
+ setNotification,
36
+ ns
37
+ };
38
+ };
39
+ t3 = [setNotification, ns];
40
+ $[3] = ns;
41
+ $[4] = setNotification;
42
+ $[5] = t2;
43
+ $[6] = t3;
44
+ } else {
45
+ t2 = $[5];
46
+ t3 = $[6];
47
+ }
48
+ useEffect(t2, t3);
49
+ let t4;
50
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
51
+ t4 = notification => {
52
+ ref.current.setNotification(Object.assign(Object.assign({
53
+ ns: ref.current.ns
54
+ }, notification), {
55
+ id: Date.now().toString()
56
+ }));
57
+ };
58
+ $[7] = t4;
59
+ } else {
60
+ t4 = $[7];
61
+ }
62
+ const showNotification = t4;
63
+ let t5;
64
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
65
+ t5 = () => {
66
+ ref.current.setNotification(null);
67
+ };
68
+ $[8] = t5;
69
+ } else {
70
+ t5 = $[8];
71
+ }
72
+ const clearNotification = t5;
73
+ let t6;
74
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
75
+ t6 = {
76
+ showNotification,
77
+ clearNotification
78
+ };
79
+ $[9] = t6;
80
+ } else {
81
+ t6 = $[9];
82
+ }
83
+ return t6;
84
+ };export{notificationAtom,useNotification,useNotificationState,useNotificationValue};//# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../notifications/notificationAtom.ts","../../notifications/useNotification.ts"],"sourcesContent":["import { atomStateGenerator } from '@gaddario98/react-state';\nimport type { NotificationMessage } from './types';\n\nconst {\n atom: notificationAtom,\n useValue: useNotificationValue,\n useState: useNotificationState,\n} = atomStateGenerator<NotificationMessage | null>({\n defaultValue: null,\n key: 'reactNotificationAtom',\n persist: false,\n});\n\nexport { notificationAtom, useNotificationValue, useNotificationState };\n","import { useCallback, useEffect, useRef } from 'react';\nimport { useNotificationState } from './notificationAtom';\nimport type { NotificationMessage } from './types';\n\n const useNotificationSet = () => {\n const [, setValue] = useNotificationState();\n return setValue;\n };\n\nexport const useNotification = (ns = 'notifications') => {\n const setNotification = useNotificationSet();\n const ref =useRef({setNotification, ns})\n\n useEffect(() => {\n ref.current = { setNotification, ns };\n }, [setNotification, ns]);\n\n const showNotification = useCallback(\n (notification: Omit<NotificationMessage, 'id'>) => {\n ref.current.setNotification({\n ns: ref.current.ns,\n ...notification,\n id: Date.now().toString(),\n });\n },\n [],\n );\n\n const clearNotification = useCallback(() => {\n ref.current.setNotification(null);\n }, []);\n\n return {\n showNotification,\n clearNotification,\n };\n};\n"],"names":["atom","notificationAtom","useValue","useNotificationValue","useState","useNotificationState","atomStateGenerator","defaultValue","key","persist","useNotificationSet","setValue","useNotification","t0","$","_c","ns","undefined","setNotification","t1","ref","useRef","t2","t3","current","useEffect","t4","Symbol","for","notification","Object","assign","id","Date","now","toString","showNotification","t5","clearNotification","t6"],"mappings":"qIAGA,MAAM;AACJA,EAAAA,IAAI,EAAEC,gBAAgB;AACtBC,EAAAA,QAAQ,EAAEC,oBAAoB;AAC9BC,EAAAA,QAAQ,EAAEC;AAAoB,CAC/B,GAAGC,kBAAkB,CAA6B;AACjDC,EAAAA,YAAY,EAAE,IAAI;AAClBC,EAAAA,GAAG,EAAE,uBAAuB;AAC5BC,EAAAA,OAAO,EAAE;AACV,CAAA,ECPC,MAAMC,kBAAkB,GAAGA,MAAA;AACzB,EAAA,MAAA,GAAAC,QAAA,CAAA,GAAqBN,oBAAoB,EAAE;AAAC,EAAA,OACrCM,QAAQ;AAAA,CAChB;AAEI,MAAMC,eAAe,GAAGC,EAAA,IAAA;EAAA,MAAAC,CAAA,GAAAC,CAAA,CAAA,EAAA,CAAA;EAAC,MAAAC,EAAA,GAAAH,EAAoB,KAApBI,SAAoB,GAApB,eAAoB,GAApBJ,EAAoB;AAClD,EAAA,MAAAK,eAAA,GAAwBR,kBAAkB,EAAE;AAAC,EAAA,IAAAS,EAAA;AAAA,EAAA,IAAAL,CAAA,CAA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dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -64,6 +64,12 @@
64
64
  "require": "./dist/localization/index.js",
65
65
  "default": "./dist/localization/index.js"
66
66
  },
67
+ "./notifications": {
68
+ "types": "./dist/notifications/index.d.ts",
69
+ "import": "./dist/notifications/index.mjs",
70
+ "require": "./dist/notifications/index.js",
71
+ "default": "./dist/notifications/index.js"
72
+ },
67
73
  "./pages": {
68
74
  "types": "./dist/pages/index.d.ts",
69
75
  "import": "./dist/pages/index.mjs",