@cubejs-client/react 0.33.47 → 0.33.55

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/index.d.ts CHANGED
@@ -34,8 +34,13 @@ declare module '@cubejs-client/react' {
34
34
  QueryRecordType,
35
35
  } from '@cubejs-client/core';
36
36
 
37
+ type CubeProviderOptions = {
38
+ castNumerics?: boolean;
39
+ }
40
+
37
41
  type CubeProviderProps = {
38
42
  cubejsApi: CubejsApi | null;
43
+ options?: CubeProviderOptions;
39
44
  children: React.ReactNode;
40
45
  };
41
46
 
@@ -69,6 +74,7 @@ declare module '@cubejs-client/react' {
69
74
 
70
75
  type CubeContextProps = {
71
76
  cubejsApi: CubejsApi;
77
+ options?: CubeProviderOptions;
72
78
  };
73
79
 
74
80
  /**
@@ -466,6 +472,10 @@ declare module '@cubejs-client/react' {
466
472
  * When `true` the resultSet will be reset to `null` first
467
473
  */
468
474
  resetResultSetOnChange?: boolean;
475
+ /**
476
+ * If enabled, all members of the 'number' type will be automatically converted to numerical values on the client side
477
+ */
478
+ castNumerics?: boolean;
469
479
  };
470
480
 
471
481
  type UseCubeQueryResult<TData> = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cubejs-client/react",
3
- "version": "0.33.47",
3
+ "version": "0.33.55",
4
4
  "author": "Cube Dev, Inc.",
5
5
  "license": "MIT",
6
6
  "engines": {},
@@ -24,7 +24,7 @@
24
24
  ],
25
25
  "dependencies": {
26
26
  "@babel/runtime": "^7.1.2",
27
- "@cubejs-client/core": "^0.33.47",
27
+ "@cubejs-client/core": "^0.33.55",
28
28
  "core-js": "^3.6.5",
29
29
  "ramda": "^0.27.2"
30
30
  },
@@ -42,5 +42,5 @@
42
42
  "peerDependencies": {
43
43
  "react": ">=16.10.2"
44
44
  },
45
- "gitHead": "56fdafca61e135266bc19d2c34497f7affcdb4da"
45
+ "gitHead": "7cb9ace521ab59474e54e4f7cbfb98acb91c9008"
46
46
  }
@@ -1,6 +1,14 @@
1
1
  import React from 'react';
2
2
  import CubeContext from './CubeContext';
3
3
 
4
- export default function CubeProvider({ cubejsApi, children }) {
5
- return <CubeContext.Provider value={{ cubejsApi }}>{children}</CubeContext.Provider>;
4
+ export default function CubeProvider({ cubejsApi, children, options = {} }) {
5
+ return (
6
+ <CubeContext.Provider value={{
7
+ cubejsApi,
8
+ options
9
+ }}
10
+ >
11
+ {children}
12
+ </CubeContext.Provider>
13
+ );
6
14
  }
@@ -24,7 +24,7 @@ export function useCubeQuery(query, options = {}) {
24
24
  const cubejsApi = options.cubejsApi || context?.cubejsApi;
25
25
 
26
26
  if (!cubejsApi) {
27
- throw new Error('Cube.js API client is not provided');
27
+ throw new Error('Cube API client is not provided');
28
28
  }
29
29
 
30
30
  if (resetResultSetOnChange) {
@@ -33,12 +33,13 @@ export function useCubeQuery(query, options = {}) {
33
33
 
34
34
  setError(null);
35
35
  setLoading(true);
36
-
36
+
37
37
  try {
38
38
  const response = await cubejsApi.load(query, {
39
39
  mutexObj: mutexRef.current,
40
40
  mutexKey: 'query',
41
41
  progressCallback,
42
+ castNumerics: Boolean(typeof options.castNumerics === 'boolean' ? options.castNumerics : context?.options?.castNumerics)
42
43
  });
43
44
 
44
45
  if (isMounted()) {
@@ -64,7 +65,7 @@ export function useCubeQuery(query, options = {}) {
64
65
  const cubejsApi = options.cubejsApi || context?.cubejsApi;
65
66
 
66
67
  if (!cubejsApi) {
67
- throw new Error('Cube.js API client is not provided');
68
+ throw new Error('Cube API client is not provided');
68
69
  }
69
70
 
70
71
  async function loadQuery() {