@quillsql/react 1.7.4 → 1.7.6

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.
Files changed (86) hide show
  1. package/lib/AddToDashboardModal.js +2 -2
  2. package/lib/AddToDashboardModal.js.map +1 -1
  3. package/lib/Chart.js +2 -2
  4. package/lib/Chart.js.map +1 -1
  5. package/lib/Context.d.ts +2 -1
  6. package/lib/Context.js +3 -1
  7. package/lib/Context.js.map +1 -1
  8. package/lib/Dashboard.js +2 -2
  9. package/lib/Dashboard.js.map +1 -1
  10. package/lib/QuillProvider.d.ts +2 -1
  11. package/lib/QuillProvider.js +2 -2
  12. package/lib/QuillProvider.js.map +1 -1
  13. package/lib/ReportBuilder.d.ts +1 -1
  14. package/lib/ReportBuilder.js +3 -2
  15. package/lib/ReportBuilder.js.map +1 -1
  16. package/lib/SQLEditor.js +5 -5
  17. package/lib/SQLEditor.js.map +1 -1
  18. package/lib/Table.js +1 -1
  19. package/lib/Table.js.map +1 -1
  20. package/lib/components/BigModal/BigModal.js +1 -0
  21. package/lib/components/BigModal/BigModal.js.map +1 -1
  22. package/lib/components/Modal/Modal.js +1 -0
  23. package/lib/components/Modal/Modal.js.map +1 -1
  24. package/lib/hooks/useQuill.js +3 -2
  25. package/lib/hooks/useQuill.js.map +1 -1
  26. package/package.json +11 -4
  27. package/.eslintrc.json +0 -19
  28. package/.prettierrc +0 -11
  29. package/.vscode/settings.json +0 -10
  30. package/src/AddToDashboardModal.tsx +0 -1213
  31. package/src/BarList.tsx +0 -580
  32. package/src/Chart.tsx +0 -1336
  33. package/src/Context.tsx +0 -249
  34. package/src/Dashboard.tsx +0 -819
  35. package/src/DateRangePicker/Calendar.tsx +0 -442
  36. package/src/DateRangePicker/DateRangePicker.tsx +0 -261
  37. package/src/DateRangePicker/DateRangePickerButton.tsx +0 -250
  38. package/src/DateRangePicker/dateRangePickerUtils.tsx +0 -480
  39. package/src/DateRangePicker/index.ts +0 -4
  40. package/src/PieChart.tsx +0 -845
  41. package/src/QuillProvider.tsx +0 -78
  42. package/src/ReportBuilder.tsx +0 -2202
  43. package/src/SQLEditor.tsx +0 -1087
  44. package/src/Table.tsx +0 -1074
  45. package/src/TableChart.tsx +0 -428
  46. package/src/assets/ArrowDownHeadIcon.tsx +0 -11
  47. package/src/assets/ArrowDownIcon.tsx +0 -14
  48. package/src/assets/ArrowDownRightIcon.tsx +0 -14
  49. package/src/assets/ArrowLeftHeadIcon.tsx +0 -11
  50. package/src/assets/ArrowRightHeadIcon.tsx +0 -11
  51. package/src/assets/ArrowRightIcon.tsx +0 -14
  52. package/src/assets/ArrowUpHeadIcon.tsx +0 -11
  53. package/src/assets/ArrowUpIcon.tsx +0 -14
  54. package/src/assets/ArrowUpRightIcon.tsx +0 -14
  55. package/src/assets/CalendarIcon.tsx +0 -14
  56. package/src/assets/DoubleArrowLeftHeadIcon.tsx +0 -18
  57. package/src/assets/DoubleArrowRightHeadIcon.tsx +0 -20
  58. package/src/assets/ExclamationFilledIcon.tsx +0 -14
  59. package/src/assets/LoadingSpinner.tsx +0 -11
  60. package/src/assets/SearchIcon.tsx +0 -14
  61. package/src/assets/XCircleIcon.tsx +0 -14
  62. package/src/assets/index.ts +0 -16
  63. package/src/components/BigModal/BigModal.tsx +0 -108
  64. package/src/components/Dropdown/Dropdown.tsx +0 -169
  65. package/src/components/Dropdown/DropdownItem.tsx +0 -68
  66. package/src/components/Dropdown/index.ts +0 -2
  67. package/src/components/Modal/Modal.tsx +0 -132
  68. package/src/components/Modal/index.ts +0 -1
  69. package/src/components/selectUtils.ts +0 -60
  70. package/src/contexts/BaseColorContext.tsx +0 -5
  71. package/src/contexts/HoveredValueContext.tsx +0 -12
  72. package/src/contexts/RootStylesContext.tsx +0 -5
  73. package/src/contexts/SelectedValueContext.tsx +0 -13
  74. package/src/contexts/index.ts +0 -4
  75. package/src/hooks/index.ts +0 -4
  76. package/src/hooks/useInternalState.tsx +0 -18
  77. package/src/hooks/useOnClickOutside.tsx +0 -23
  78. package/src/hooks/useOnWindowResize.tsx +0 -17
  79. package/src/hooks/useQuill.ts +0 -137
  80. package/src/hooks/useSelectOnKeyDown.tsx +0 -80
  81. package/src/index.ts +0 -9
  82. package/src/lib/font.ts +0 -14
  83. package/src/lib/index.ts +0 -3
  84. package/src/lib/inputTypes.ts +0 -81
  85. package/src/lib/utils.tsx +0 -46
  86. package/tsconfig.json +0 -22
@@ -1,137 +0,0 @@
1
- import { useContext, useEffect, useState } from 'react';
2
- import { ClientContext, DashboardContext } from '../Context';
3
- import axios from 'axios';
4
-
5
- interface Column {
6
- _id: string;
7
- label: string;
8
- field: string;
9
- format: string;
10
- }
11
-
12
- interface Field {
13
- name: string;
14
- tableID: number;
15
- columnID: number;
16
- dataTypeID: number;
17
- dataTypeSize: number;
18
- dataTypeModifier: number;
19
- format: string;
20
- }
21
-
22
- interface YAxisField {
23
- label: string;
24
- field: string;
25
- chartType: string;
26
- format: string;
27
- }
28
-
29
- interface Report {
30
- name: string;
31
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
- rows: any[];
33
- columns: Array<Column>;
34
- dashboardName?: string;
35
- chartType: string;
36
- filters?: object;
37
- fields: Array<Field>;
38
- template?: boolean;
39
- editEnabled?: boolean;
40
- xAxisField: string;
41
- yAxisFields: Array<YAxisField>;
42
- xAxisLabel: string;
43
- yAxisLabel: string;
44
- queryString: string;
45
- dateField?: object;
46
- }
47
-
48
- export const useQuill = (
49
- chartId: string
50
- ): {
51
- data: Report | null;
52
- loading: boolean;
53
- error: string | null;
54
- } => {
55
- // @ts-ignore
56
- const { dashboard, dispatch } = useContext(DashboardContext);
57
- const [client] = useContext(ClientContext);
58
- const [data, setData] = useState<Report | null>(null);
59
- const [loading, setLoading] = useState(true);
60
- const [error, setError] = useState<string | null>(null);
61
-
62
- useEffect(() => {
63
- let isSubscribed = true;
64
- async function getChartOptions(id: string) {
65
- if (isSubscribed) {
66
- if (dashboard[id]) {
67
- setData(dashboard[id]);
68
- return;
69
- }
70
- // @ts-ignore
71
- const {
72
- publicKey,
73
- customerId,
74
- environment,
75
- queryEndpoint,
76
- queryHeaders,
77
- } = client;
78
- try {
79
- if (queryEndpoint) {
80
- const resp = await axios.post(
81
- queryEndpoint,
82
- { metadata: { id: chartId, task: 'item' } },
83
- { headers: queryHeaders }
84
- );
85
- setLoading(false);
86
- setData({
87
- ...resp.data,
88
- });
89
- dispatch({ type: 'UPDATE_DASHBOARD_ITEM', id, data: resp.data });
90
- } else {
91
- const resp = await axios.get(
92
- 'https://quill-344421.uc.r.appspot.com/item',
93
- {
94
- params: {
95
- id: chartId,
96
- orgId: customerId,
97
- publicKey: publicKey,
98
- },
99
- headers: {
100
- environment: environment || undefined,
101
- },
102
- }
103
- );
104
- setLoading(false);
105
- setData(resp.data);
106
- dispatch({ type: 'UPDATE_DASHBOARD_ITEM', id, data: resp.data });
107
- }
108
- } catch (e) {
109
- if (typeof e === 'string' || (typeof e === 'object' && e !== null)) {
110
- setError(stringifyIfObject(e));
111
- } else {
112
- setError('error');
113
- }
114
- }
115
- }
116
- }
117
- if (chartId && !data) {
118
- getChartOptions(chartId);
119
- }
120
- return () => {
121
- isSubscribed = false;
122
- };
123
- }, [chartId, dashboard]);
124
-
125
- return { data, loading, error };
126
- };
127
-
128
- function stringifyIfObject(e: string | object) {
129
- if (typeof e === 'string') {
130
- // do nothing if e is a string
131
- return e;
132
- } else if (typeof e === 'object' && e !== null) {
133
- // stringify e if it's an object
134
- return JSON.stringify(e);
135
- }
136
- return e; // returns the input as is for other types
137
- }
@@ -1,80 +0,0 @@
1
- import { useEffect, useState } from "react";
2
-
3
- const useSelectOnKeyDown = (
4
- onValueChange: (value: string) => void,
5
- optionValues: string[],
6
- isFocused: boolean,
7
- handleFocusChange: (isFocused: boolean) => void,
8
- value?: string,
9
- ): [
10
- string | null | undefined,
11
- (e: React.KeyboardEvent<HTMLDivElement | HTMLButtonElement>) => void,
12
- ] => {
13
- const NO_SELECTION_IDX = -1;
14
- const [hoveredIdx, setHoveredIdx] = useState(NO_SELECTION_IDX);
15
-
16
- const getHoveredValue = (hoveredIdx: number, optionValues: string[]) => {
17
- if (hoveredIdx < 0) return undefined;
18
- return optionValues[hoveredIdx];
19
- };
20
-
21
- useEffect(() => {
22
- const getIndexOfSelectedValue = () => {
23
- if (!isFocused) {
24
- setHoveredIdx(NO_SELECTION_IDX);
25
- }
26
- if (!value) return NO_SELECTION_IDX;
27
- const indexOfValue = optionValues.indexOf(value);
28
- return indexOfValue === -1 ? NO_SELECTION_IDX : indexOfValue;
29
- };
30
-
31
- setHoveredIdx(getIndexOfSelectedValue());
32
- }, [value, isFocused]);
33
-
34
- const hoveredValue = getHoveredValue(hoveredIdx, optionValues);
35
-
36
- const getNextIdx = () => {
37
- const nextIdx = hoveredIdx + 1;
38
- return Math.min(nextIdx, optionValues.length - 1);
39
- };
40
-
41
- const getPrevIdx = () => {
42
- const prevIdx = hoveredIdx - 1;
43
- return Math.max(prevIdx, 0);
44
- };
45
-
46
- const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement | HTMLButtonElement>) => {
47
- if (!isFocused) {
48
- return;
49
- }
50
-
51
- switch (e.key) {
52
- case "ArrowUp": {
53
- e.preventDefault();
54
- setHoveredIdx(getPrevIdx());
55
- break;
56
- }
57
- case "ArrowDown": {
58
- e.preventDefault();
59
- setHoveredIdx(getNextIdx());
60
- break;
61
- }
62
- case "Enter": {
63
- e.preventDefault();
64
- if (hoveredValue) {
65
- onValueChange(hoveredValue);
66
- }
67
- break;
68
- }
69
- case "Escape": {
70
- e.preventDefault();
71
- handleFocusChange(false);
72
- setHoveredIdx(NO_SELECTION_IDX);
73
- break;
74
- }
75
- }
76
- };
77
- return [hoveredValue, handleKeyDown];
78
- };
79
-
80
- export default useSelectOnKeyDown;
package/src/index.ts DELETED
@@ -1,9 +0,0 @@
1
- // src/index.ts
2
- export { default as Dashboard } from './Dashboard';
3
- export { default as QuillProvider } from './QuillProvider';
4
- export { default as Chart } from './Chart';
5
- export { default as Table } from './Table';
6
- export { default as SQLEditor } from './SQLEditor';
7
- export { default as ReportBuilder } from './ReportBuilder';
8
- export { default as AddToDashboardModal } from './AddToDashboardModal';
9
- export { useQuill } from './hooks/useQuill';
package/src/lib/font.ts DELETED
@@ -1,14 +0,0 @@
1
- export const fontSize = {
2
- xs: 'qq-text-xs',
3
- sm: 'qq-text-sm',
4
- md: 'qq-text-base',
5
- lg: 'qq-text-lg',
6
- xl: 'qq-text-xl',
7
- threeXl: 'qq-text-3xl',
8
- };
9
-
10
- export const fontWeight = {
11
- sm: 'qq-font-normal',
12
- md: 'qq-font-medium',
13
- lg: 'qq-font-semibold',
14
- };
package/src/lib/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './inputTypes';
2
- export * from './font';
3
- export * from './utils';
@@ -1,81 +0,0 @@
1
- export type ValueFormatter = {
2
- (value: number): string;
3
- };
4
-
5
- const iconVariantValues = [
6
- 'simple',
7
- 'light',
8
- 'shadow',
9
- 'solid',
10
- 'outlined',
11
- ] as const;
12
-
13
- export type IconVariant = (typeof iconVariantValues)[number];
14
-
15
- export type HorizontalPosition = 'left' | 'right';
16
-
17
- export type VerticalPosition = 'top' | 'bottom';
18
-
19
- export type ButtonVariant = 'primary' | 'secondary' | 'light';
20
-
21
- const deltaTypeValues = [
22
- 'increase',
23
- 'moderateIncrease',
24
- 'decrease',
25
- 'moderateDecrease',
26
- 'unchanged',
27
- ] as const;
28
-
29
- export type DeltaType = (typeof deltaTypeValues)[number];
30
-
31
- const sizeValues = ['xs', 'sm', 'md', 'lg', 'xl'] as const;
32
-
33
- export type Size = (typeof sizeValues)[number];
34
-
35
- const colorValues = [
36
- 'slate',
37
- 'gray',
38
- 'zinc',
39
- 'neutral',
40
- 'stone',
41
- 'red',
42
- 'orange',
43
- 'amber',
44
- 'yellow',
45
- 'lime',
46
- 'green',
47
- 'emerald',
48
- 'teal',
49
- 'cyan',
50
- 'sky',
51
- 'blue',
52
- 'indigo',
53
- 'violet',
54
- 'purple',
55
- 'fuchsia',
56
- 'pink',
57
- 'rose',
58
- ] as const;
59
-
60
- export type Color = (typeof colorValues)[number];
61
-
62
- const justifyContentValues = [
63
- 'start',
64
- 'end',
65
- 'center',
66
- 'between',
67
- 'around',
68
- 'evenly',
69
- ] as const;
70
- export type JustifyContent = (typeof justifyContentValues)[number];
71
-
72
- const alignItemsValues = [
73
- 'start',
74
- 'end',
75
- 'center',
76
- 'baseline',
77
- 'stretch',
78
- ] as const;
79
- export type AlignItems = (typeof alignItemsValues)[number];
80
-
81
- export type FlexDirection = 'row' | 'col' | 'row-reverse' | 'col-reverse';
package/src/lib/utils.tsx DELETED
@@ -1,46 +0,0 @@
1
- import { ValueFormatter } from './inputTypes';
2
-
3
- export const defaultValueFormatter: ValueFormatter = (value: number) =>
4
- value.toString();
5
-
6
- export const sumNumericArray = (arr: number[]) =>
7
- arr.reduce((prefixSum, num) => prefixSum + num, 0);
8
-
9
- export const removeValueFromArray = (value: any, array: any[]): any[] => {
10
- const index = array.indexOf(value);
11
- if (index > -1) {
12
- array.splice(index, 1);
13
- }
14
- return array;
15
- };
16
-
17
- export const isValueInArray = (value: any, array: any[]): boolean => {
18
- for (let i = 0; i < array.length; i++) {
19
- if (array[i] === value) {
20
- return true;
21
- }
22
- }
23
- return false;
24
- };
25
-
26
- export const stringIsNumeric = (str: string | undefined): boolean => {
27
- return !isNaN(Number(str)) && str !== undefined;
28
- };
29
-
30
- export const stringEndsWithNumber = (str: string): boolean => {
31
- return stringIsNumeric(str.split('-').pop());
32
- };
33
-
34
- export function mergeRefs<T = any>(
35
- refs: Array<React.MutableRefObject<T> | React.LegacyRef<T>>
36
- ): React.RefCallback<T> {
37
- return value => {
38
- refs.forEach(ref => {
39
- if (typeof ref === 'function') {
40
- ref(value);
41
- } else if (ref != null) {
42
- (ref as React.MutableRefObject<T | null>).current = value;
43
- }
44
- });
45
- };
46
- }
package/tsconfig.json DELETED
@@ -1,22 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2022",
4
- "lib": ["dom", "dom.iterable", "es2022"],
5
- "allowJs": true,
6
- "skipLibCheck": true,
7
- "esModuleInterop": true,
8
- "allowSyntheticDefaultImports": true,
9
- "strict": true,
10
- "forceConsistentCasingInFileNames": true,
11
- "module": "commonjs",
12
- "moduleResolution": "node",
13
- "resolveJsonModule": true,
14
- "isolatedModules": true,
15
- "noEmit": false,
16
- "jsx": "react-jsx",
17
- "declaration": true,
18
- "outDir": "lib",
19
- "sourceMap": true
20
- },
21
- "include": ["src"]
22
- }