@neo4j-ndl/react 2.0.18 → 2.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#695](https://github.com/neo4j/neo4j-design/pull/695) [`b8274f8`](https://github.com/neo4j/neo4j-design/commit/b8274f877b0d32ad40a12cd864df9287c4552cfc) Thanks [@konsalex](https://github.com/konsalex)! - added new shared react hooks and documentation inside Storybook
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`b8274f8`](https://github.com/neo4j/neo4j-design/commit/b8274f877b0d32ad40a12cd864df9287c4552cfc)]:
12
+ - @neo4j-ndl/base@2.1.0
13
+
3
14
  ## 2.0.18
4
15
 
5
16
  ### Patch Changes
package/lib/LICENSES.txt CHANGED
@@ -14639,6 +14639,32 @@ END OF TERMS AND CONDITIONS
14639
14639
 
14640
14640
  -----
14641
14641
 
14642
+ The following software may be included in this product: usehooks-ts. A copy of the source code may be downloaded from https://github.com/juliencrn/usehooks-ts. This software contains the following license and notice below:
14643
+
14644
+ The MIT License (MIT)
14645
+
14646
+ Copyright (c) 2020 Julien CARON
14647
+
14648
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14649
+ of this software and associated documentation files (the "Software"), to deal
14650
+ in the Software without restriction, including without limitation the rights
14651
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14652
+ copies of the Software, and to permit persons to whom the Software is
14653
+ furnished to do so, subject to the following conditions:
14654
+
14655
+ The above copyright notice and this permission notice shall be included in all
14656
+ copies or substantial portions of the Software.
14657
+
14658
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14659
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14660
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14661
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14662
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
14663
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
14664
+ SOFTWARE.
14665
+
14666
+ -----
14667
+
14642
14668
  The following software may be included in this product: vite. A copy of the source code may be downloaded from git+https://github.com/vitejs/vite.git. This software contains the following license and notice below:
14643
14669
 
14644
14670
  # Vite core license
package/lib/NOTICE.txt CHANGED
@@ -297,6 +297,10 @@ Third-party licenses
297
297
  │ │ ├─ URL: git://github.com/TypeStrong/ts-node.git
298
298
  │ │ ├─ VendorName: Blake Embrey
299
299
  │ │ └─ VendorUrl: https://typestrong.org/ts-node
300
+ │ ├─ usehooks-ts@npm:2.9.1 [a2e03] (via npm:2.9.1 [a2e03])
301
+ │ │ ├─ URL: https://github.com/juliencrn/usehooks-ts
302
+ │ │ ├─ VendorName: Julien CARON
303
+ │ │ └─ VendorUrl: https://usehooks-ts.com
300
304
  │ ├─ vite@npm:4.3.5 [d75d7] (via npm:^4.0.4 [d75d7])
301
305
  │ │ ├─ URL: git+https://github.com/vitejs/vite.git
302
306
  │ │ ├─ VendorName: Evan You
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ /**
3
+ *
4
+ * Copyright (c) "Neo4j"
5
+ * Neo4j Sweden AB [http://neo4j.com]
6
+ *
7
+ * This file is part of Neo4j.
8
+ *
9
+ * Neo4j is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.useRenderCount = exports.useEffectDebugger = exports.usePrevious = exports.useEventListener = exports.useLockedBody = exports.useCopyToClipboard = exports.useMediaQuery = exports.useInterval = exports.useOnClickOutside = exports.useWindowSize = exports.useDebounce = void 0;
24
+ const react_1 = require("react");
25
+ var usehooks_ts_1 = require("usehooks-ts");
26
+ Object.defineProperty(exports, "useDebounce", { enumerable: true, get: function () { return usehooks_ts_1.useDebounce; } });
27
+ Object.defineProperty(exports, "useWindowSize", { enumerable: true, get: function () { return usehooks_ts_1.useWindowSize; } });
28
+ Object.defineProperty(exports, "useOnClickOutside", { enumerable: true, get: function () { return usehooks_ts_1.useOnClickOutside; } });
29
+ Object.defineProperty(exports, "useInterval", { enumerable: true, get: function () { return usehooks_ts_1.useInterval; } });
30
+ Object.defineProperty(exports, "useMediaQuery", { enumerable: true, get: function () { return usehooks_ts_1.useMediaQuery; } });
31
+ Object.defineProperty(exports, "useCopyToClipboard", { enumerable: true, get: function () { return usehooks_ts_1.useCopyToClipboard; } });
32
+ Object.defineProperty(exports, "useLockedBody", { enumerable: true, get: function () { return usehooks_ts_1.useLockedBody; } });
33
+ Object.defineProperty(exports, "useEventListener", { enumerable: true, get: function () { return usehooks_ts_1.useEventListener; } });
34
+ /**
35
+ * Below are hooks that cannot be found in `usehooks-ts`
36
+ * but are used in some projects.
37
+ * 1. usePrevious
38
+ * 2. useEffectDebugger
39
+ * 3. useRenderCount
40
+ */
41
+ /**
42
+ * The `usePrevious` hook tracks a variable's previous value in a functional component,
43
+ * useful for comparing current and past values to trigger actions or render changes.
44
+ */
45
+ function usePrevious(value) {
46
+ // The ref object is a generic container whose current property is mutable
47
+ // and can hold any value, similar to an instance property on a class
48
+ const ref = (0, react_1.useRef)();
49
+ // Store current value in ref
50
+ (0, react_1.useEffect)(() => {
51
+ ref.current = value;
52
+ }, [value]); // Only re-run if value changes
53
+ // Return previous value (happens before update in useEffect above)
54
+ return ref.current;
55
+ }
56
+ exports.usePrevious = usePrevious;
57
+ /**
58
+ * The `useEffectDebugger` hook is a wrapper around the `useEffect` hook
59
+ * that logs the dependencies of the effect when they change.
60
+ *
61
+ * Uses the `usePrevious` hook.
62
+ *
63
+ * Source: https://stackoverflow.com/a/59843241/3247715
64
+ */
65
+ function useEffectDebugger(effectHook, dependencies, dependencyNames = []) {
66
+ const previousDeps = usePrevious(dependencies);
67
+ const changedDeps = dependencies.reduce((accum, dependency, index) => {
68
+ if (previousDeps === undefined) {
69
+ return accum;
70
+ }
71
+ if (dependency !== previousDeps[index]) {
72
+ const keyName = dependencyNames[index] || index;
73
+ return Object.assign(Object.assign({}, accum), { [keyName]: {
74
+ before: previousDeps[index],
75
+ after: dependency,
76
+ } });
77
+ }
78
+ return accum;
79
+ }, {});
80
+ if (Object.keys(changedDeps).length) {
81
+ console.info('[use-effect-debugger] ', changedDeps);
82
+ }
83
+ // eslint-disable-next-line react-hooks/exhaustive-deps
84
+ (0, react_1.useEffect)(effectHook, dependencies);
85
+ }
86
+ exports.useEffectDebugger = useEffectDebugger;
87
+ /**
88
+ * The `useRenderCount` hook returns the number of times a component has rendered.
89
+ */
90
+ function useRenderCount() {
91
+ const count = (0, react_1.useRef)(0);
92
+ count.current++;
93
+ return count.current;
94
+ }
95
+ exports.useRenderCount = useRenderCount;
96
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,iCAA0C;AAE1C,2CASqB;AARnB,0GAAA,WAAW,OAAA;AACX,4GAAA,aAAa,OAAA;AACb,gHAAA,iBAAiB,OAAA;AACjB,0GAAA,WAAW,OAAA;AACX,4GAAA,aAAa,OAAA;AACb,iHAAA,kBAAkB,OAAA;AAClB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AY,CAAC,CAAC;AAC7C,CAAC;AA/BD,8CA+BC;AAED;;GAEG;AACH,SAAgB,cAAc;IAC5B,MAAM,KAAK,GAAG,IAAA,cAAM,EAAC,CAAC,CAAC,CAAC;IAExB,KAAK,CAAC,OAAO,EAAE,CAAC;IAEhB,OAAO,KAAK,CAAC,OAAO,CAAC;AACvB,CAAC;AAND,wCAMC"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ *
3
+ * Copyright (c) "Neo4j"
4
+ * Neo4j Sweden AB [http://neo4j.com]
5
+ *
6
+ * This file is part of Neo4j.
7
+ *
8
+ * Neo4j is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+ import { useEffect, useRef } from 'react';
22
+ export { useDebounce, useWindowSize, useOnClickOutside, useInterval, useMediaQuery, useCopyToClipboard, useLockedBody, useEventListener, } from 'usehooks-ts';
23
+ /**
24
+ * Below are hooks that cannot be found in `usehooks-ts`
25
+ * but are used in some projects.
26
+ * 1. usePrevious
27
+ * 2. useEffectDebugger
28
+ * 3. useRenderCount
29
+ */
30
+ /**
31
+ * The `usePrevious` hook tracks a variable's previous value in a functional component,
32
+ * useful for comparing current and past values to trigger actions or render changes.
33
+ */
34
+ export function usePrevious(value) {
35
+ // The ref object is a generic container whose current property is mutable
36
+ // and can hold any value, similar to an instance property on a class
37
+ const ref = useRef();
38
+ // Store current value in ref
39
+ useEffect(() => {
40
+ ref.current = value;
41
+ }, [value]); // Only re-run if value changes
42
+ // Return previous value (happens before update in useEffect above)
43
+ return ref.current;
44
+ }
45
+ /**
46
+ * The `useEffectDebugger` hook is a wrapper around the `useEffect` hook
47
+ * that logs the dependencies of the effect when they change.
48
+ *
49
+ * Uses the `usePrevious` hook.
50
+ *
51
+ * Source: https://stackoverflow.com/a/59843241/3247715
52
+ */
53
+ export function useEffectDebugger(effectHook, dependencies, dependencyNames = []) {
54
+ const previousDeps = usePrevious(dependencies);
55
+ const changedDeps = dependencies.reduce((accum, dependency, index) => {
56
+ if (previousDeps === undefined) {
57
+ return accum;
58
+ }
59
+ if (dependency !== previousDeps[index]) {
60
+ const keyName = dependencyNames[index] || index;
61
+ return Object.assign(Object.assign({}, accum), { [keyName]: {
62
+ before: previousDeps[index],
63
+ after: dependency,
64
+ } });
65
+ }
66
+ return accum;
67
+ }, {});
68
+ if (Object.keys(changedDeps).length) {
69
+ console.info('[use-effect-debugger] ', changedDeps);
70
+ }
71
+ // eslint-disable-next-line react-hooks/exhaustive-deps
72
+ useEffect(effectHook, dependencies);
73
+ }
74
+ /**
75
+ * The `useRenderCount` hook returns the number of times a component has rendered.
76
+ */
77
+ export function useRenderCount() {
78
+ const count = useRef(0);
79
+ count.current++;
80
+ return count.current;
81
+ }
82
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EACL,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAI,KAAQ;IACrC,0EAA0E;IAC1E,qEAAqE;IACrE,MAAM,GAAG,GAAQ,MAAM,EAAK,CAAC;IAC7B,6BAA6B;IAC7B,SAAS,CAAC,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
22
22
  import { type ElementBase } from '../helpers';
23
- export type AccordionItemId = string | number;
23
+ export type AccordionItemId = string | number | undefined;
24
24
  export interface AccordionBase extends ElementBase<HTMLDivElement> {
25
25
  children: React.ReactNode | string;
26
26
  className?: string;
@@ -0,0 +1,46 @@
1
+ /**
2
+ *
3
+ * Copyright (c) "Neo4j"
4
+ * Neo4j Sweden AB [http://neo4j.com]
5
+ *
6
+ * This file is part of Neo4j.
7
+ *
8
+ * Neo4j is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+ export { useDebounce, useWindowSize, useOnClickOutside, useInterval, useMediaQuery, useCopyToClipboard, useLockedBody, useEventListener, } from 'usehooks-ts';
22
+ /**
23
+ * Below are hooks that cannot be found in `usehooks-ts`
24
+ * but are used in some projects.
25
+ * 1. usePrevious
26
+ * 2. useEffectDebugger
27
+ * 3. useRenderCount
28
+ */
29
+ /**
30
+ * The `usePrevious` hook tracks a variable's previous value in a functional component,
31
+ * useful for comparing current and past values to trigger actions or render changes.
32
+ */
33
+ export declare function usePrevious<T>(value: T): T;
34
+ /**
35
+ * The `useEffectDebugger` hook is a wrapper around the `useEffect` hook
36
+ * that logs the dependencies of the effect when they change.
37
+ *
38
+ * Uses the `usePrevious` hook.
39
+ *
40
+ * Source: https://stackoverflow.com/a/59843241/3247715
41
+ */
42
+ export declare function useEffectDebugger(effectHook: unknown, dependencies: unknown[], dependencyNames?: string[]): void;
43
+ /**
44
+ * The `useRenderCount` hook returns the number of times a component has rendered.
45
+ */
46
+ export declare function useRenderCount(): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neo4j-ndl/react",
3
- "version": "2.0.18",
3
+ "version": "2.1.0",
4
4
  "sideEffects": false,
5
5
  "description": "React implementation of Neo4j Design System",
6
6
  "keywords": [
@@ -93,7 +93,7 @@
93
93
  "@floating-ui/react": "0.25.1",
94
94
  "@heroicons/react": "2.0.13",
95
95
  "@neo4j-cypher/react-codemirror": "^1.0.1",
96
- "@neo4j-ndl/base": "^2.0.9",
96
+ "@neo4j-ndl/base": "^2.1.0",
97
97
  "@table-nav/core": "0.0.7",
98
98
  "@table-nav/react": "0.0.7",
99
99
  "@tanstack/react-table": "^8.9.3",
@@ -109,7 +109,8 @@
109
109
  "react-syntax-highlighter": "^15.5.0",
110
110
  "react-table": "^7.7.0",
111
111
  "react-use": "^17.4.0",
112
- "tinycolor2": "^1.4.2"
112
+ "tinycolor2": "^1.4.2",
113
+ "usehooks-ts": "2.9.1"
113
114
  },
114
115
  "resolutions": {
115
116
  "@types/react": "18.2.18",