@neo4j-ndl/react 2.8.12 → 2.9.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,20 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#793](https://github.com/neo4j/needle/pull/793) [`8e7bb553199d7c7f0223dfd52af52358ebaae3cb`](https://github.com/neo4j/needle/commit/8e7bb553199d7c7f0223dfd52af52358ebaae3cb) Thanks [@basickarl](https://github.com/basickarl)! - Added theme agnostic JS token feature
8
+
9
+ ## 2.8.13
10
+
11
+ ### Patch Changes
12
+
13
+ - [#790](https://github.com/neo4j/needle/pull/790) [`fd10ec95be9de5be3afb43ea748e91df117e5a13`](https://github.com/neo4j/needle/commit/fd10ec95be9de5be3afb43ea748e91df117e5a13) Thanks [@basickarl](https://github.com/basickarl)! - Fix for module build error
14
+
15
+ - Updated dependencies [[`fd10ec95be9de5be3afb43ea748e91df117e5a13`](https://github.com/neo4j/needle/commit/fd10ec95be9de5be3afb43ea748e91df117e5a13)]:
16
+ - @neo4j-ndl/base@2.7.9
17
+
3
18
  ## 2.8.12
4
19
 
5
20
  ### Patch Changes
@@ -34,7 +34,7 @@ var __rest = (this && this.__rest) || function (s, e) {
34
34
  return t;
35
35
  };
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.NeedleThemeProvider = exports.useNeedleTheme = exports.ThemeContext = void 0;
37
+ exports.NeedleThemeProvider = exports.useNeedleTheme = exports.TokensContext = exports.ThemeContext = void 0;
38
38
  const jsx_runtime_1 = require("react/jsx-runtime");
39
39
  /**
40
40
  *
@@ -59,6 +59,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
59
59
  const react_1 = __importStar(require("react"));
60
60
  const defaultImports_1 = require("../_common/defaultImports");
61
61
  exports.ThemeContext = (0, react_1.createContext)(undefined);
62
+ exports.TokensContext = (0, react_1.createContext)(undefined);
62
63
  /**
63
64
  * Hook to access the current theme effortlessly
64
65
  */
@@ -71,13 +72,15 @@ const useNeedleTheme = () => {
71
72
  */
72
73
  if (theme === undefined)
73
74
  theme = 'light';
75
+ const tokens = (0, react_1.useContext)(exports.TokensContext);
74
76
  return {
75
77
  theme,
76
78
  themeClassName: `ndl-theme-${theme}`,
79
+ tokens,
77
80
  };
78
81
  };
79
82
  exports.useNeedleTheme = useNeedleTheme;
80
- const NeedleThemeProvider = ({ theme = 'light', children, wrapperProps, }) => {
83
+ const NeedleThemeProvider = ({ theme = 'light', tokens, children, wrapperProps, }) => {
81
84
  const clonedChildren = (0, react_1.useMemo)(() => {
82
85
  const _a = wrapperProps || {}, { isWrappingChildren, className } = _a, restWrapperProps = __rest(_a, ["isWrappingChildren", "className"]);
83
86
  const props = Object.assign(Object.assign({}, restWrapperProps), { className: (0, defaultImports_1.classNames)(className, `ndl-theme-${theme}`) });
@@ -90,7 +93,7 @@ const NeedleThemeProvider = ({ theme = 'light', children, wrapperProps, }) => {
90
93
  return ((0, jsx_runtime_1.jsx)("span", Object.assign({}, props, { className: (0, defaultImports_1.classNames)('ndl-theme-wrapper', props.className), children: children })));
91
94
  }
92
95
  }, [wrapperProps, theme, children]);
93
- return ((0, jsx_runtime_1.jsx)(exports.ThemeContext.Provider, { value: theme, children: clonedChildren }));
96
+ return ((0, jsx_runtime_1.jsx)(exports.ThemeContext.Provider, { value: theme, children: (0, jsx_runtime_1.jsx)(exports.TokensContext.Provider, { value: tokens, children: clonedChildren }) }));
94
97
  };
95
98
  exports.NeedleThemeProvider = NeedleThemeProvider;
96
99
  //# sourceMappingURL=ThemeProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeProvider.js","sourceRoot":"","sources":["../../../src/theme/ThemeProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,+CAMe;AACf,8DAAuD;AA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,EAAC,SAAS,EAAE,aAAa,KAAK,EAAE,CAAC,GACvD,CAAC;QAEF,IAAI,kBAAkB,KAAK,IAAI,EAAE;YAC/B,OAAO,eAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;gBAC5C,OAAO,eAAK,CAAC,YAAY,CAAC,KAAK,kCAC1B,KAAK,KACR,SAAS,EAAE,IAAA,2BAAU,EAAC,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,IAC7D,CAAC;YACL,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,OAAO,CACL,iDACM,KAAK,IACT,SAAS,EAAE,IAAA,2BAAU,EAAC,mBAAmB,EAAE,KAAK,CAAC,SAAS,CAAC,YAE1D,QAAQ,IACJ,CACR,CAAC;SACH;IACH,CAAC,EAAE,CAAC,YAAY,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEpC,OAAO,CACL,uBAAC,oBAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YACjC,uBAAC,qBAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,MAAM,YAClC,cAAc,GACQ,GACH,CACzB,CAAC;AACJ,CAAC,CAAC;AAxCW,QAAA,mBAAmB,uBAwC9B"}
@@ -0,0 +1,55 @@
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.n = void 0;
24
+ const ThemeProvider_1 = require("./ThemeProvider");
25
+ function defaultStringToJson(path, json = {}, theme) {
26
+ const parts = path.split('.');
27
+ let part;
28
+ while ((part = parts.shift())) {
29
+ if (typeof json[part] !== 'object') {
30
+ return json[part];
31
+ }
32
+ json = json[part];
33
+ // Specific for theme tokens
34
+ if (part === 'theme') {
35
+ json = json[theme];
36
+ }
37
+ }
38
+ }
39
+ const useN = (path, stringToJson = defaultStringToJson) => {
40
+ const { theme, tokens } = (0, ThemeProvider_1.useNeedleTheme)();
41
+ if (!tokens) {
42
+ console.error('design tokens not found, you need to set the design tokens in the NeedleThemeProvider');
43
+ return;
44
+ }
45
+ const value = stringToJson(path, tokens, theme);
46
+ if (!value) {
47
+ console.warn(`design token value "${path}" not found, are you sure the string path is correct?`);
48
+ }
49
+ return value;
50
+ };
51
+ // React will complain if we don't use the prefix "use" for
52
+ // holding the useNeedleTheme function call. "n" is a more
53
+ // convenient name for the function.
54
+ exports.n = useN;
55
+ //# sourceMappingURL=agnostic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agnostic.js","sourceRoot":"","sources":["../../../src/theme/agnostic.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,mDAAiD;AAEjD,SAAS,mBAAmB,CAAC,IAAY,EAAE,OAAY,EAAE,EAAE,KAAa;IACtE,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,IAAI,CAAC;IACT,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE;QAC7B,IAAI,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,QAAQ,EAAE;YAClC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;SACnB;QACD,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;QAClB,4BAA4B;QAC5B,IAAI,IAAI,KAAK,OAAO,EAAE;YACpB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;SACpB;KACF;AACH,CAAC;AAED,MAAM,IAAI,GAAG,CACX,IAAY,EACZ,YAAY,GAAG,mBAAmB,EACnB,EAAE;IACjB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAA,8BAAc,GAAE,CAAC;IAC3C,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,CAAC,KAAK,CACX,uFAAuF,CACxF,CAAC;QACF,OAAO;KACR;IACD,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAChD,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,CAAC,IAAI,CACV,uBAAuB,IAAI,uDAAuD,CACnF,CAAC;KACH;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,2DAA2D;AAC3D,0DAA0D;AAC1D,oCAAoC;AACvB,QAAA,CAAC,GAAG,IAAI,CAAC"}
@@ -35,4 +35,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
35
35
  };
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
37
  __exportStar(require("./ThemeProvider"), exports);
38
+ __exportStar(require("./agnostic"), exports);
38
39
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/theme/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;;;;;AAEH,kDAAgC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/theme/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;;;;;AAEH,kDAAgC;AAChC,6CAA2B"}
@@ -33,6 +33,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
33
33
  import React, { createContext, useContext, useMemo, } from 'react';
34
34
  import { classNames } from '../_common/defaultImports';
35
35
  export const ThemeContext = createContext(undefined);
36
+ export const TokensContext = createContext(undefined);
36
37
  /**
37
38
  * Hook to access the current theme effortlessly
38
39
  */
@@ -45,12 +46,14 @@ export const useNeedleTheme = () => {
45
46
  */
46
47
  if (theme === undefined)
47
48
  theme = 'light';
49
+ const tokens = useContext(TokensContext);
48
50
  return {
49
51
  theme,
50
52
  themeClassName: `ndl-theme-${theme}`,
53
+ tokens,
51
54
  };
52
55
  };
53
- export const NeedleThemeProvider = ({ theme = 'light', children, wrapperProps, }) => {
56
+ export const NeedleThemeProvider = ({ theme = 'light', tokens, children, wrapperProps, }) => {
54
57
  const clonedChildren = useMemo(() => {
55
58
  const _a = wrapperProps || {}, { isWrappingChildren, className } = _a, restWrapperProps = __rest(_a, ["isWrappingChildren", "className"]);
56
59
  const props = Object.assign(Object.assign({}, restWrapperProps), { className: classNames(className, `ndl-theme-${theme}`) });
@@ -63,6 +66,6 @@ export const NeedleThemeProvider = ({ theme = 'light', children, wrapperProps, }
63
66
  return (_jsx("span", Object.assign({}, props, { className: classNames('ndl-theme-wrapper', props.className), children: children })));
64
67
  }
65
68
  }, [wrapperProps, theme, children]);
66
- return (_jsx(ThemeContext.Provider, { value: theme, children: clonedChildren }));
69
+ return (_jsx(ThemeContext.Provider, { value: theme, children: _jsx(TokensContext.Provider, { value: tokens, children: clonedChildren }) }));
67
70
  };
68
71
  //# sourceMappingURL=ThemeProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeProvider.js","sourceRoot":"","sources":["../../../src/theme/ThemeProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,EACZ,aAAa,EAGb,UAAU,EACV,OAAO,GACR,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAIvD,MAAM,CAAC,MAAM,YAAY,GA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,CAAC;QAEF,IAAI,kBAAkB,KAAK,IAAI,EAAE;YAC/B,OAAO,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;gBAC5C,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,kCAC1B,KAAK,KACR,SAAS,EAAE,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,IAC7D,CAAC;YACL,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,OAAO,CACL,+BACM,KAAK,IACT,SAAS,EAAE,UAAU,CAAC,mBAAmB,EAAE,KAAK,CAAC,SAAS,CAAC,YAE1D,QAAQ,IACJ,CACR,CAAC;SACH;IACH,CAAC,EAAE,CAAC,YAAY,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEpC,OAAO,CACL,KAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YACjC,KAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,MAAM,YAClC,cAAc,GACQ,GACH,CACzB,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,52 @@
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 { useNeedleTheme } from './ThemeProvider';
22
+ function defaultStringToJson(path, json = {}, theme) {
23
+ const parts = path.split('.');
24
+ let part;
25
+ while ((part = parts.shift())) {
26
+ if (typeof json[part] !== 'object') {
27
+ return json[part];
28
+ }
29
+ json = json[part];
30
+ // Specific for theme tokens
31
+ if (part === 'theme') {
32
+ json = json[theme];
33
+ }
34
+ }
35
+ }
36
+ const useN = (path, stringToJson = defaultStringToJson) => {
37
+ const { theme, tokens } = useNeedleTheme();
38
+ if (!tokens) {
39
+ console.error('design tokens not found, you need to set the design tokens in the NeedleThemeProvider');
40
+ return;
41
+ }
42
+ const value = stringToJson(path, tokens, theme);
43
+ if (!value) {
44
+ console.warn(`design token value "${path}" not found, are you sure the string path is correct?`);
45
+ }
46
+ return value;
47
+ };
48
+ // React will complain if we don't use the prefix "use" for
49
+ // holding the useNeedleTheme function call. "n" is a more
50
+ // convenient name for the function.
51
+ export const n = useN;
52
+ //# sourceMappingURL=agnostic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agnostic.js","sourceRoot":"","sources":["../../../src/theme/agnostic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,SAAS,mBAAmB,CAAC,IAAY,EAAE,OAAY,EAAE,EAAE,KAAa;IACtE,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,IAAI,CAAC;IACT,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE;QAC7B,IAAI,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,QAAQ,EAAE;YAClC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;SACnB;QACD,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;QAClB,4BAA4B;QAC5B,IAAI,IAAI,KAAK,OAAO,EAAE;YACpB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;SACpB;KACF;AACH,CAAC;AAED,MAAM,IAAI,GAAG,CACX,IAAY,EACZ,YAAY,GAAG,mBAAmB,EACnB,EAAE;IACjB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,CAAC;IAC3C,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,CAAC,KAAK,CACX,uFAAuF,CACxF,CAAC;QACF,OAAO;KACR;IACD,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAChD,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,CAAC,IAAI,CACV,uBAAuB,IAAI,uDAAuD,CACnF,CAAC;KACH;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,2DAA2D;AAC3D,0DAA0D;AAC1D,oCAAoC;AACpC,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC"}
@@ -19,4 +19,5 @@
19
19
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
20
  */
21
21
  export * from './ThemeProvider';
22
+ export * from './agnostic';
22
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/theme/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/theme/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC"}
@@ -21,6 +21,10 @@
21
21
  import React, { type HTMLAttributes, type PropsWithChildren } from 'react';
22
22
  type ThemeContextType = 'light' | 'dark';
23
23
  export declare const ThemeContext: React.Context<ThemeContextType | undefined>;
24
+ type TokensContextType = {
25
+ [key: string]: any;
26
+ };
27
+ export declare const TokensContext: React.Context<TokensContextType | undefined>;
24
28
  type NeedleThemeHook = () => {
25
29
  theme: ThemeContextType;
26
30
  /**
@@ -29,6 +33,7 @@ type NeedleThemeHook = () => {
29
33
  * Modals, Popovers, etc.
30
34
  */
31
35
  themeClassName: string;
36
+ tokens?: TokensContextType;
32
37
  };
33
38
  /**
34
39
  * Hook to access the current theme effortlessly
@@ -36,6 +41,7 @@ type NeedleThemeHook = () => {
36
41
  export declare const useNeedleTheme: NeedleThemeHook;
37
42
  export interface NeedleThemeProviderProps extends PropsWithChildren {
38
43
  theme?: 'dark' | 'light';
44
+ tokens?: TokensContextType;
39
45
  children: any;
40
46
  /**
41
47
  * Nested theme providers will receive a wrapping `span` tag
@@ -50,5 +56,5 @@ export interface NeedleThemeProviderProps extends PropsWithChildren {
50
56
  isWrappingChildren?: boolean;
51
57
  };
52
58
  }
53
- export declare const NeedleThemeProvider: ({ theme, children, wrapperProps, }: NeedleThemeProviderProps) => import("react/jsx-runtime").JSX.Element;
59
+ export declare const NeedleThemeProvider: ({ theme, tokens, children, wrapperProps, }: NeedleThemeProviderProps) => import("react/jsx-runtime").JSX.Element;
54
60
  export {};
@@ -0,0 +1,23 @@
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
+ declare function defaultStringToJson(path: string, json: any, theme: string): any;
22
+ export declare const n: (path: string, stringToJson?: typeof defaultStringToJson) => string | void;
23
+ export {};
@@ -19,3 +19,4 @@
19
19
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
20
  */
21
21
  export * from './ThemeProvider';
22
+ export * from './agnostic';
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@neo4j-ndl/react",
3
- "version": "2.8.12",
4
- "type": "module",
3
+ "version": "2.9.0",
5
4
  "sideEffects": false,
6
5
  "description": "React implementation of Neo4j Design System",
7
6
  "keywords": [
@@ -97,7 +96,7 @@
97
96
  "@floating-ui/react": "0.25.1",
98
97
  "@heroicons/react": "2.0.13",
99
98
  "@neo4j-cypher/react-codemirror": "^1.0.1",
100
- "@neo4j-ndl/base": "^2.7.8",
99
+ "@neo4j-ndl/base": "^2.7.9",
101
100
  "@table-nav/core": "0.0.7",
102
101
  "@table-nav/react": "0.0.7",
103
102
  "@tanstack/react-table": "^8.9.3",