@quillsql/react 2.8.7 → 2.8.8
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/dist/AddToDashboardModal.js +181 -146
- package/dist/BarList.js +44 -36
- package/dist/Chart.js +132 -99
- package/dist/ChartBuilder.js +89 -80
- package/dist/ChartEditor.js +21 -14
- package/dist/Context.js +57 -52
- package/dist/Dashboard.js +211 -178
- package/dist/Dashboard.js.map +1 -1
- package/dist/DateRangePicker/Calendar.js +46 -41
- package/dist/DateRangePicker/DateRangePicker.js +61 -32
- package/dist/DateRangePicker/DateRangePickerButton.js +17 -14
- package/dist/DateRangePicker/dateRangePickerUtils.js +90 -76
- package/dist/DateRangePicker/dateRangePickerUtils.js.map +1 -1
- package/dist/DateRangePicker/index.js +9 -1
- package/dist/PieChart.js +70 -35
- package/dist/QuillProvider.js +7 -4
- package/dist/ReportBuilder.js +129 -120
- package/dist/SQLEditor.js +65 -56
- package/dist/Table.js +64 -59
- package/dist/Table.js.map +1 -1
- package/dist/TableChart.js +45 -17
- package/dist/assets/ArrowDownHeadIcon.js +6 -3
- package/dist/assets/ArrowDownIcon.js +6 -3
- package/dist/assets/ArrowDownRightIcon.js +6 -3
- package/dist/assets/ArrowLeftHeadIcon.js +6 -3
- package/dist/assets/ArrowRightHeadIcon.js +6 -3
- package/dist/assets/ArrowRightIcon.js +6 -3
- package/dist/assets/ArrowUpHeadIcon.js +6 -3
- package/dist/assets/ArrowUpIcon.js +6 -3
- package/dist/assets/ArrowUpRightIcon.js +6 -3
- package/dist/assets/CalendarIcon.js +6 -3
- package/dist/assets/CalendarNormalIcon.js +6 -3
- package/dist/assets/DoubleArrowLeftHeadIcon.js +6 -3
- package/dist/assets/DoubleArrowRightHeadIcon.js +6 -3
- package/dist/assets/ExclamationFilledIcon.js +6 -3
- package/dist/assets/FilterIcon.js +6 -3
- package/dist/assets/LoadingSpinner.js +6 -3
- package/dist/assets/RefreshIcon.js +6 -3
- package/dist/assets/SearchIcon.js +6 -3
- package/dist/assets/UpLeftArrowsIcon.js +6 -3
- package/dist/assets/XCircleIcon.js +6 -3
- package/dist/assets/XIcon.js +6 -3
- package/dist/assets/index.js +49 -21
- package/dist/components/BigModal/BigModal.js +39 -13
- package/dist/components/Dropdown/Dropdown.js +53 -24
- package/dist/components/Dropdown/DropdownItem.js +35 -9
- package/dist/components/Dropdown/index.js +11 -2
- package/dist/components/Modal/Modal.js +39 -13
- package/dist/components/Modal/index.js +9 -1
- package/dist/components/QuillCard.js +13 -8
- package/dist/components/SqlTextEditor.js +11 -4
- package/dist/components/SqlTextEditor.js.map +1 -0
- package/dist/components/UiComponents.js +51 -37
- package/dist/components/selectUtils.js +17 -6
- package/dist/contexts/BaseColorContext.js +6 -3
- package/dist/contexts/HoveredValueContext.js +6 -3
- package/dist/contexts/RootStylesContext.js +6 -3
- package/dist/contexts/SelectedValueContext.js +6 -3
- package/dist/contexts/index.js +15 -4
- package/dist/hooks/index.js +15 -4
- package/dist/hooks/useDashboard.js +15 -10
- package/dist/hooks/useDashboard.js.map +1 -0
- package/dist/hooks/useInternalState.js +6 -3
- package/dist/hooks/useOnClickOutside.js +6 -3
- package/dist/hooks/useOnWindowResize.js +7 -4
- package/dist/hooks/useQuill.js +16 -11
- package/dist/hooks/useSelectOnKeyDown.js +7 -4
- package/dist/index.js +33 -13
- package/dist/index.js.map +1 -1
- package/dist/internals/ReportBuilder/PivotList.js +20 -14
- package/dist/internals/ReportBuilder/PivotModal.js +92 -84
- package/dist/internals/ReportBuilder/PivotModal.spec.js +73 -70
- package/dist/lib/font.js +6 -2
- package/dist/lib/index.js +20 -3
- package/dist/lib/inputTypes.js +3 -1
- package/dist/lib/utils.js +19 -8
- package/dist/utils/aggregate.js +35 -28
- package/dist/utils/colorToHex.js +5 -1
- package/dist/utils/dataFetcher.js +8 -2
- package/dist/utils/downloadCSV.js +6 -1
- package/package.json +2 -1
package/dist/ChartBuilder.js
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.numberFormatOptions = exports.snakeCaseToTitleCase = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
2
8
|
// @ts-nocheck
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const Context_1 = require("./Context");
|
|
11
|
+
const dataFetcher_1 = require("./utils/dataFetcher");
|
|
12
|
+
const ReportBuilder_1 = require("./ReportBuilder");
|
|
13
|
+
const PivotModal_1 = require("./internals/ReportBuilder/PivotModal");
|
|
14
|
+
const PivotList_1 = require("./internals/ReportBuilder/PivotList");
|
|
15
|
+
const Chart_1 = __importDefault(require("./Chart"));
|
|
16
|
+
const UiComponents_1 = require("./components/UiComponents");
|
|
11
17
|
const CHART_TYPES = ['column', 'line', 'table', 'metric', 'bar', 'pie'];
|
|
12
|
-
|
|
18
|
+
function snakeCaseToTitleCase(str) {
|
|
13
19
|
if (!str) {
|
|
14
20
|
return str;
|
|
15
21
|
}
|
|
@@ -21,6 +27,7 @@ export function snakeCaseToTitleCase(str) {
|
|
|
21
27
|
: word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
22
28
|
.join(' ');
|
|
23
29
|
}
|
|
30
|
+
exports.snakeCaseToTitleCase = snakeCaseToTitleCase;
|
|
24
31
|
const POSTGRES_DATE_TYPES = [
|
|
25
32
|
'timestamp',
|
|
26
33
|
'date',
|
|
@@ -32,7 +39,7 @@ async function getReferencedTables(client, sqlQuery, dbTables) {
|
|
|
32
39
|
// const parser = new Parser();
|
|
33
40
|
const tables = [];
|
|
34
41
|
const withAliases = [];
|
|
35
|
-
const resp = await getDataFromCloud(client, `astify`, { query: sqlQuery });
|
|
42
|
+
const resp = await (0, dataFetcher_1.getDataFromCloud)(client, `astify`, { query: sqlQuery });
|
|
36
43
|
let ast = resp.ast;
|
|
37
44
|
ast = ast.length ? ast[0] : ast;
|
|
38
45
|
if (ast.with && ast.with.length) {
|
|
@@ -66,7 +73,7 @@ const AGGREGATION_TYPES = [
|
|
|
66
73
|
{ label: 'count', value: 'count' },
|
|
67
74
|
{ label: 'average', value: 'avg' },
|
|
68
75
|
];
|
|
69
|
-
|
|
76
|
+
exports.numberFormatOptions = [
|
|
70
77
|
'whole_number',
|
|
71
78
|
'one_decimal_place',
|
|
72
79
|
'two_decimal_places',
|
|
@@ -90,29 +97,30 @@ const formatOptions = [
|
|
|
90
97
|
{ value: 'percent', label: 'percent' },
|
|
91
98
|
{ value: 'string', label: 'string' },
|
|
92
99
|
];
|
|
93
|
-
|
|
94
|
-
const [theme] = useContext(ThemeContext);
|
|
95
|
-
return (
|
|
100
|
+
function ChartBuilder(props) {
|
|
101
|
+
const [theme] = (0, react_1.useContext)(Context_1.ThemeContext);
|
|
102
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: props.Modal ? ((0, jsx_runtime_1.jsx)(props.Modal, { isOpen: props.isOpen, setIsOpen: props.setIsOpen, title: props.title || 'Add to dashboard', onClose: () => props.setIsOpen(false), theme: theme, children: (0, jsx_runtime_1.jsx)(ChartBuilderForm, { ...props }) })) : ((0, jsx_runtime_1.jsx)(UiComponents_1.MemoizedModal, { setIsOpen: props.setIsOpen, isOpen: props.isOpen, onClose: () => props.setIsOpen(false), title: props.title || 'Add to dashboard', theme: theme, children: (0, jsx_runtime_1.jsx)(ChartBuilderForm, { ...props }) })) }));
|
|
96
103
|
}
|
|
97
|
-
|
|
104
|
+
exports.default = ChartBuilder;
|
|
105
|
+
function ChartBuilderForm({ TextInput = UiComponents_1.MemoizedTextInput, Select = UiComponents_1.MemoizedSelect, Button = UiComponents_1.MemoizedButton, SecondaryButton = UiComponents_1.MemoizedSecondaryButton, Header = UiComponents_1.MemoizedHeader, Label = UiComponents_1.MemoizedLabel, DeleteButton = UiComponents_1.MemoizedDeleteButton, Text = UiComponents_1.MemoizedText, Modal = UiComponents_1.MemoizedModal, Popover = UiComponents_1.MemoizedPopover, isOpen, pivot, setIsOpen, rows, columns, query, queryNoDateColumn, dateRange: dr, formHeaderStyle, formLabelStyle, showTableFormatOptions = false, showDateFieldOptions = false, showAccessControlOptions = false, showDashboardDropdown = true, onAddToDashboardComplete, onDelete, fields: fieldsProp, dashboardItem = undefined, recommendedPivots: rp = [], createdPivots: cp = [], destinationDashboard, dateColumn, buttonLabel, }) {
|
|
98
106
|
const dateRange = dr || [null, null, null];
|
|
99
|
-
const [client] = useContext(ClientContext);
|
|
100
|
-
const [theme] = useContext(ThemeContext);
|
|
101
|
-
const [schema, setSchema] = useContext(SchemaContext);
|
|
102
|
-
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
103
|
-
const [divWidth, setDivWidth] = useState(0);
|
|
104
|
-
const { dispatch } = useContext(DashboardContext);
|
|
107
|
+
const [client] = (0, react_1.useContext)(Context_1.ClientContext);
|
|
108
|
+
const [theme] = (0, react_1.useContext)(Context_1.ThemeContext);
|
|
109
|
+
const [schema, setSchema] = (0, react_1.useContext)(Context_1.SchemaContext);
|
|
110
|
+
const [isSubmitting, setIsSubmitting] = (0, react_1.useState)(false);
|
|
111
|
+
const [divWidth, setDivWidth] = (0, react_1.useState)(0);
|
|
112
|
+
const { dispatch } = (0, react_1.useContext)(Context_1.DashboardContext);
|
|
105
113
|
const fields = fieldsProp?.map((field) => ({
|
|
106
114
|
field: field.name,
|
|
107
|
-
type: getPostgresBasicType(field),
|
|
115
|
+
type: (0, ReportBuilder_1.getPostgresBasicType)(field),
|
|
108
116
|
format: field.format,
|
|
109
117
|
label: field.name,
|
|
110
118
|
})) || [];
|
|
111
|
-
const parentRef = useRef();
|
|
112
|
-
const deleteRef = useRef();
|
|
119
|
+
const parentRef = (0, react_1.useRef)();
|
|
120
|
+
const deleteRef = (0, react_1.useRef)();
|
|
113
121
|
const modalPadding = 20;
|
|
114
122
|
const deleteButtonMargin = -13;
|
|
115
|
-
useEffect(() => {
|
|
123
|
+
(0, react_1.useEffect)(() => {
|
|
116
124
|
const calculateWidth = () => {
|
|
117
125
|
return (parentRef.current.offsetWidth -
|
|
118
126
|
(deleteRef?.current
|
|
@@ -136,11 +144,11 @@ function ChartBuilderForm({ TextInput = MemoizedTextInput, Select = MemoizedSele
|
|
|
136
144
|
};
|
|
137
145
|
}, []);
|
|
138
146
|
// get schema
|
|
139
|
-
useEffect(() => {
|
|
147
|
+
(0, react_1.useEffect)(() => {
|
|
140
148
|
let isSubscribed = true;
|
|
141
149
|
async function getSchema() {
|
|
142
150
|
if (!schema || !schema.length) {
|
|
143
|
-
const resp = await getDataFromCloud(client, `schema2/${client.publicKey}/`, null, 'GET');
|
|
151
|
+
const resp = await (0, dataFetcher_1.getDataFromCloud)(client, `schema2/${client.publicKey}/`, null, 'GET');
|
|
144
152
|
if (isSubscribed) {
|
|
145
153
|
setSchema(resp.tables);
|
|
146
154
|
}
|
|
@@ -154,11 +162,11 @@ function ChartBuilderForm({ TextInput = MemoizedTextInput, Select = MemoizedSele
|
|
|
154
162
|
};
|
|
155
163
|
}, [schema]);
|
|
156
164
|
// get dashboards
|
|
157
|
-
const [dashboardOptions, setDashboardOptions] = useState([]);
|
|
158
|
-
const [defaultDashboardName, setDefaultDashboardName] = useState(destinationDashboard ||
|
|
165
|
+
const [dashboardOptions, setDashboardOptions] = (0, react_1.useState)([]);
|
|
166
|
+
const [defaultDashboardName, setDefaultDashboardName] = (0, react_1.useState)(destinationDashboard ||
|
|
159
167
|
dashboardItem?.dashboardName ||
|
|
160
168
|
dashboardOptions[0]?.label);
|
|
161
|
-
useEffect(() => {
|
|
169
|
+
(0, react_1.useEffect)(() => {
|
|
162
170
|
if (!destinationDashboard &&
|
|
163
171
|
!dashboardItem &&
|
|
164
172
|
dashboardOptions &&
|
|
@@ -166,31 +174,31 @@ function ChartBuilderForm({ TextInput = MemoizedTextInput, Select = MemoizedSele
|
|
|
166
174
|
setDefaultDashboardName(dashboardOptions[0]?.label);
|
|
167
175
|
}
|
|
168
176
|
}, [dashboardOptions]);
|
|
169
|
-
useEffect(() => {
|
|
177
|
+
(0, react_1.useEffect)(() => {
|
|
170
178
|
async function getDashNames() {
|
|
171
|
-
const resp = await getDataFromCloud(client, `dashnames/${client.publicKey}/`, null, 'GET');
|
|
179
|
+
const resp = await (0, dataFetcher_1.getDataFromCloud)(client, `dashnames/${client.publicKey}/`, null, 'GET');
|
|
172
180
|
setDashboardOptions(resp.dashboardNames
|
|
173
181
|
.filter((elem) => elem !== null)
|
|
174
182
|
.map((key) => ({ label: key, value: key })));
|
|
175
183
|
}
|
|
176
184
|
getDashNames();
|
|
177
185
|
}, []);
|
|
178
|
-
const [showPivotPopover, setShowPivotPopover] = useState(false);
|
|
179
|
-
const [isEdittingPivot, setIsEdittingPivot] = useState(false);
|
|
180
|
-
const [selectedPivotIndex, setSelectedPivotIndex] = useState(-1);
|
|
181
|
-
const [tableName, setTableName] = useState(null);
|
|
186
|
+
const [showPivotPopover, setShowPivotPopover] = (0, react_1.useState)(false);
|
|
187
|
+
const [isEdittingPivot, setIsEdittingPivot] = (0, react_1.useState)(false);
|
|
188
|
+
const [selectedPivotIndex, setSelectedPivotIndex] = (0, react_1.useState)(-1);
|
|
189
|
+
const [tableName, setTableName] = (0, react_1.useState)(null);
|
|
182
190
|
const selectedTable = schema?.find((t) => t.displayName === tableName);
|
|
183
|
-
const [pivotPopUpTitle, setPivotPopUpTitle] = useState('Add Pivot');
|
|
184
|
-
const [createdPivots, setCreatedPivots] = useState(pivot ? [pivot] : dashboardItem?.pivot ? [dashboardItem.pivot] : cp);
|
|
185
|
-
const [recommendedPivots, setRecommendedPivots] = useState(rp);
|
|
186
|
-
const [pivotRowField, setPivotRowField] = useState(undefined);
|
|
187
|
-
const [pivotColumnField, setPivotColumnField] = useState(undefined);
|
|
188
|
-
const [pivotValueField, setPivotValueField] = useState(undefined);
|
|
189
|
-
const [pivotAggregation, setPivotAggregation] = useState(undefined);
|
|
191
|
+
const [pivotPopUpTitle, setPivotPopUpTitle] = (0, react_1.useState)('Add Pivot');
|
|
192
|
+
const [createdPivots, setCreatedPivots] = (0, react_1.useState)(pivot ? [pivot] : dashboardItem?.pivot ? [dashboardItem.pivot] : cp);
|
|
193
|
+
const [recommendedPivots, setRecommendedPivots] = (0, react_1.useState)(rp);
|
|
194
|
+
const [pivotRowField, setPivotRowField] = (0, react_1.useState)(undefined);
|
|
195
|
+
const [pivotColumnField, setPivotColumnField] = (0, react_1.useState)(undefined);
|
|
196
|
+
const [pivotValueField, setPivotValueField] = (0, react_1.useState)(undefined);
|
|
197
|
+
const [pivotAggregation, setPivotAggregation] = (0, react_1.useState)(undefined);
|
|
190
198
|
// initial state is the fields array passed in, but can eventually be changed to be the pivot fields
|
|
191
|
-
const [fieldOptions, setFieldOptions] = useState(fields);
|
|
192
|
-
const [dateFieldOptions, setDateFieldOptions] = useState([]);
|
|
193
|
-
useEffect(() => {
|
|
199
|
+
const [fieldOptions, setFieldOptions] = (0, react_1.useState)(fields);
|
|
200
|
+
const [dateFieldOptions, setDateFieldOptions] = (0, react_1.useState)([]);
|
|
201
|
+
(0, react_1.useEffect)(() => {
|
|
194
202
|
const fetchReferencedTables = async () => {
|
|
195
203
|
if (!query) {
|
|
196
204
|
return;
|
|
@@ -215,7 +223,7 @@ function ChartBuilderForm({ TextInput = MemoizedTextInput, Select = MemoizedSele
|
|
|
215
223
|
table: dateFieldOptions[0]?.name,
|
|
216
224
|
field: dateFieldOptions[0]?.columns[0]?.name,
|
|
217
225
|
};
|
|
218
|
-
const firstNumberColumn = columns?.find((col) => numberFormatOptions.includes(col.format));
|
|
226
|
+
const firstNumberColumn = columns?.find((col) => exports.numberFormatOptions.includes(col.format));
|
|
219
227
|
const formEmptyState = {
|
|
220
228
|
name: '',
|
|
221
229
|
dashboardName: dashboardOptions?.[0]?.label,
|
|
@@ -242,13 +250,13 @@ function ChartBuilderForm({ TextInput = MemoizedTextInput, Select = MemoizedSele
|
|
|
242
250
|
// date labels for pivots should be treated like strings since they are
|
|
243
251
|
// formatted in generatePivotTable
|
|
244
252
|
const yAxisIsDate = pivot.columnField
|
|
245
|
-
? isDateField(pivot.columnFieldType)
|
|
253
|
+
? (0, PivotModal_1.isDateField)(pivot.columnFieldType)
|
|
246
254
|
: false;
|
|
247
255
|
return {
|
|
248
256
|
pivot,
|
|
249
257
|
chartType: 'column',
|
|
250
258
|
xAxisField: pivot.rowField,
|
|
251
|
-
xAxisFormat: isDateField(pivot.rowFieldType)
|
|
259
|
+
xAxisFormat: (0, PivotModal_1.isDateField)(pivot.rowFieldType)
|
|
252
260
|
? 'string'
|
|
253
261
|
: columns.find((col) => col.field === pivot.rowField)?.format ||
|
|
254
262
|
'whole_number',
|
|
@@ -265,12 +273,12 @@ function ChartBuilderForm({ TextInput = MemoizedTextInput, Select = MemoizedSele
|
|
|
265
273
|
],
|
|
266
274
|
};
|
|
267
275
|
};
|
|
268
|
-
const [formData, setFormData] = useState(pivot
|
|
276
|
+
const [formData, setFormData] = (0, react_1.useState)(pivot
|
|
269
277
|
? { ...formEmptyState, ...pivotFormData(pivot) }
|
|
270
278
|
: dashboardItem || formEmptyState);
|
|
271
|
-
const selectedPivotTable = useMemo(() => {
|
|
279
|
+
const selectedPivotTable = (0, react_1.useMemo)(() => {
|
|
272
280
|
if (formData.pivot && rows) {
|
|
273
|
-
return generatePivotTable(formData.pivot, rows, dateRange);
|
|
281
|
+
return (0, PivotModal_1.generatePivotTable)(formData.pivot, rows, dateRange);
|
|
274
282
|
}
|
|
275
283
|
else {
|
|
276
284
|
return {};
|
|
@@ -404,7 +412,7 @@ function ChartBuilderForm({ TextInput = MemoizedTextInput, Select = MemoizedSele
|
|
|
404
412
|
customerId: customerId,
|
|
405
413
|
}
|
|
406
414
|
: { clientId: publicKey }).toString();
|
|
407
|
-
const resp = await getDataFromCloud(client, `deletedash/${publicKey}/${customerId}/?${searchParams}`, cloudBody);
|
|
415
|
+
const resp = await (0, dataFetcher_1.getDataFromCloud)(client, `deletedash/${publicKey}/${customerId}/?${searchParams}`, cloudBody);
|
|
408
416
|
if (resp) {
|
|
409
417
|
if (onDelete) {
|
|
410
418
|
onDelete();
|
|
@@ -452,7 +460,7 @@ function ChartBuilderForm({ TextInput = MemoizedTextInput, Select = MemoizedSele
|
|
|
452
460
|
customerId: customerId,
|
|
453
461
|
}
|
|
454
462
|
: { clientId: publicKey }).toString();
|
|
455
|
-
const resp = await getData(client, `dashedit2?${searchParams}`, 'same-origin', hostedBody, cloudBody);
|
|
463
|
+
const resp = await (0, dataFetcher_1.getData)(client, `dashedit2?${searchParams}`, 'same-origin', hostedBody, cloudBody);
|
|
456
464
|
console.log(`RESP: ${resp}`);
|
|
457
465
|
if (resp) {
|
|
458
466
|
dispatch({
|
|
@@ -474,13 +482,13 @@ function ChartBuilderForm({ TextInput = MemoizedTextInput, Select = MemoizedSele
|
|
|
474
482
|
if (!schema) {
|
|
475
483
|
return;
|
|
476
484
|
}
|
|
477
|
-
return (
|
|
485
|
+
return ((0, jsx_runtime_1.jsxs)("div", { id: "quill-chart-modal", style: { padding: modalPadding }, children: [(0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(Chart_1.default, { config: { ...formData, rows }, colors: theme.chartColors, containerStyle: {
|
|
478
486
|
width: formData.chartType === 'table' ? 640 : 'calc(100% - 24px)',
|
|
479
487
|
height: 300,
|
|
480
|
-
} }) }),
|
|
488
|
+
} }) }), (0, jsx_runtime_1.jsx)("div", { style: { height: 20 } }), (0, jsx_runtime_1.jsxs)("form", { ref: parentRef, id: "quill-chart-form", onSubmit: handleSubmit, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'row', gap: 12 }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)(Label, { children: "Name" }), (0, jsx_runtime_1.jsx)(TextInput, { value: formData.name, onChange: (e) => handleChange(e, 'name'), placeholder: "Name" })] }), showDashboardDropdown && !destinationDashboard && ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)(Label, { children: "Dashboard" }), (0, jsx_runtime_1.jsx)(Select, { label: 'Dashboard', value: formData.dashboardName, onChange: (e) => handleChange(e, 'dashboardName'), options: dashboardOptions.map((elem) => ({
|
|
481
489
|
label: elem.label,
|
|
482
490
|
value: elem.label,
|
|
483
|
-
})) })] })),
|
|
491
|
+
})) })] })), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)(Label, { children: "Chart type" }), (0, jsx_runtime_1.jsx)(Select, { label: 'Chart Type', value: formData.chartType, onChange: (e) => handleChange(e, 'chartType'),
|
|
484
492
|
// filter out metric for all pivots
|
|
485
493
|
// filter out bar and pie for row and column pivot
|
|
486
494
|
options: CHART_TYPES.filter((elem) => !firstNumberColumn
|
|
@@ -488,21 +496,21 @@ function ChartBuilderForm({ TextInput = MemoizedTextInput, Select = MemoizedSele
|
|
|
488
496
|
: !((formData.pivot && elem === 'metric') ||
|
|
489
497
|
(formData.pivot &&
|
|
490
498
|
formData.pivot.columnField &&
|
|
491
|
-
(elem === 'bar' || elem === 'pie')))).map((elem) => ({ label: elem, value: elem })) })] })] }),
|
|
499
|
+
(elem === 'bar' || elem === 'pie')))).map((elem) => ({ label: elem, value: elem })) })] })] }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
492
500
|
display: 'flex',
|
|
493
501
|
flexDirection: 'column',
|
|
494
502
|
gap: 12,
|
|
495
503
|
marginTop: 6,
|
|
496
|
-
}, children: [
|
|
504
|
+
}, children: [(0, jsx_runtime_1.jsx)(Header, { children: "Pivot" }), (0, jsx_runtime_1.jsxs)("div", { style: { fontFamily: theme?.fontFamily }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
497
505
|
maxWidth: 200,
|
|
498
506
|
// marginTop: 6,
|
|
499
507
|
display: 'flex',
|
|
500
508
|
flexDirection: 'column',
|
|
501
|
-
}, children:
|
|
509
|
+
}, children: (0, jsx_runtime_1.jsx)(PivotModal_1.PivotModal, { pivotRowField: pivotRowField, setPivotRowField: setPivotRowField, pivotColumnField: pivotColumnField, setPivotColumnField: setPivotColumnField, pivotValueField: pivotValueField, setPivotValueField: setPivotValueField, pivotAggregation: pivotAggregation, setPivotAggregation: setPivotAggregation, createdPivots: createdPivots, setCreatedPivots: setCreatedPivots, recommendedPivots: recommendedPivots, setRecommendedPivots: setRecommendedPivots, popUpTitle: pivotPopUpTitle, setPopUpTitle: setPivotPopUpTitle, selectedTable: selectedTable, SelectComponent: Select, ButtonComponent: Button, PopoverComponent: Popover, LabelComponent: Label, TextComponent: Text, HeaderComponent: Header, theme: theme, isOpen: showPivotPopover, setIsOpen: setShowPivotPopover, showUpdatePivot: isEdittingPivot, setShowUpdatePivot: setIsEdittingPivot, parentRef: parentRef, data: rows, columns: columns, triggerButtonText: 'Add pivot +', selectedPivotIndex: selectedPivotIndex, setSelectedPivotIndex: setSelectedPivotIndex, removePivot: handleDeletePivot, selectPivot: handleAddPivot, dateRange: dateRange, selectPivotOnEdit: true, showTrigger: !formData.pivot }) }), formData.pivot && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
502
510
|
// width: 592,
|
|
503
511
|
paddingRight: deleteRef?.current ? 42 : 0,
|
|
504
512
|
maxWidth: 750,
|
|
505
|
-
}, children:
|
|
513
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { style: { width: divWidth }, children: (0, jsx_runtime_1.jsx)(PivotList_1.PivotCard, { pivotTable: {
|
|
506
514
|
pivot: formData.pivot,
|
|
507
515
|
rows: selectedPivotTable?.rows,
|
|
508
516
|
columns: selectedPivotTable?.columns,
|
|
@@ -514,23 +522,23 @@ function ChartBuilderForm({ TextInput = MemoizedTextInput, Select = MemoizedSele
|
|
|
514
522
|
setPivotValueField(formData.pivot?.valueField);
|
|
515
523
|
setPivotAggregation(formData.pivot?.aggregationType);
|
|
516
524
|
setPivotPopUpTitle('Edit Pivot');
|
|
517
|
-
}, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent: Button, HeaderComponent: Header, showEdit: false, onClose: handleDeletePivot, minHeight: 180, LabelComponent: Label, TextComponent: Text }) }) }))] })] }),
|
|
525
|
+
}, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent: Button, HeaderComponent: Header, showEdit: false, onClose: handleDeletePivot, minHeight: 180, LabelComponent: Label, TextComponent: Text }) }) }))] })] }), (0, jsx_runtime_1.jsx)("br", {}), (formData.pivot || formData.chartType !== 'table') && ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { style: {
|
|
518
526
|
display: 'flex',
|
|
519
527
|
flexDirection: 'column',
|
|
520
528
|
gap: 6,
|
|
521
529
|
marginTop: 6,
|
|
522
|
-
}, children: [
|
|
530
|
+
}, children: [(0, jsx_runtime_1.jsx)(Header, { children: "Chart" }), (0, jsx_runtime_1.jsx)(Label, { children: "X-axis" })] }), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'row', gap: 12 }, children: [(0, jsx_runtime_1.jsx)(Select, { label: 'X-axis Field', value: formData.xAxisField, onChange: (e) => handleChange(e, 'xAxisField'), disabled: formData.pivot !== null, options: fieldOptions.map((elem) => ({
|
|
523
531
|
label: formData.pivot
|
|
524
532
|
? `pivot row (${elem.field})`
|
|
525
533
|
: elem.field,
|
|
526
534
|
value: elem.field,
|
|
527
|
-
})) }),
|
|
535
|
+
})) }), (0, jsx_runtime_1.jsx)(TextInput, { value: formData.xAxisLabel, placeholder: "Column Label", onChange: (e) => handleChange(e, 'xAxisLabel') }), (0, jsx_runtime_1.jsx)(Select, { label: 'X-axis Format', value: formData.xAxisFormat, onChange: (e) => handleChange(e, 'xAxisFormat'), options: formatOptions })] }, 'xAxisField0'), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(Label, { children: "Y-axis" }), (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'column', gap: 10 }, children: formData.yAxisFields.map((yAxisField, index) => ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'row', gap: 12 }, children: [(0, jsx_runtime_1.jsx)(Select, { label: 'Y-axis Field', value: yAxisField.field, onChange: (e) => handleChange(e, 'yAxisFields.field', index), disabled: formData.pivot !== null, options: [
|
|
528
536
|
{ label: 'Select', value: '' },
|
|
529
537
|
...fieldOptions
|
|
530
538
|
.filter((elem) => {
|
|
531
539
|
return (formData.chartType === 'table' ||
|
|
532
540
|
formData.pivot ||
|
|
533
|
-
numberFormatOptions.includes(columns.find((col) => col.field === elem.field)
|
|
541
|
+
exports.numberFormatOptions.includes(columns.find((col) => col.field === elem.field)
|
|
534
542
|
?.format));
|
|
535
543
|
})
|
|
536
544
|
.map((elem) => ({
|
|
@@ -539,28 +547,28 @@ function ChartBuilderForm({ TextInput = MemoizedTextInput, Select = MemoizedSele
|
|
|
539
547
|
: elem.field,
|
|
540
548
|
value: elem.field,
|
|
541
549
|
})),
|
|
542
|
-
] }),
|
|
550
|
+
] }), (0, jsx_runtime_1.jsx)(TextInput, { value: yAxisField.label, placeholder: "Column Label", onChange: (e) => handleChange(e, 'yAxisFields.label', index) }), (0, jsx_runtime_1.jsx)(Select, { label: 'Y-axis Format', value: yAxisField.format, onChange: (e) => handleChange(e, 'yAxisFields.format', index), options: [{ label: 'Select', value: '' }, ...formatOptions] }), formData.pivot === null && ((0, jsx_runtime_1.jsx)("div", { ref: deleteRef, children: (0, jsx_runtime_1.jsx)(DeleteButton, { style: { marginLeft: deleteButtonMargin }, onClick: () => handleRemoveField('yAxisFields', index) }) }))] }, 'yAxisField' + index))) }), formData.pivot === null && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(SecondaryButton, { onClick: () => handleAddField('yAxisFields'), label: "Add field +" })] })), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("br", {})] })), (showTableFormatOptions || formData.chartType === 'table') && ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { style: {
|
|
543
551
|
display: 'flex',
|
|
544
552
|
flexDirection: 'column',
|
|
545
553
|
gap: 6,
|
|
546
554
|
marginTop: 6,
|
|
547
|
-
}, children: [
|
|
555
|
+
}, children: [(0, jsx_runtime_1.jsx)(Header, { children: "Table" }), (0, jsx_runtime_1.jsx)(Label, { children: "Columns" })] }), (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'column', gap: 10 }, children: formData.columns.map((column, index) => ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'row', gap: 12 }, children: [(0, jsx_runtime_1.jsx)(Select, { label: 'Column Field', value: column.field, onChange: (e) => handleChange(e, 'columns.field', index), options: [
|
|
548
556
|
{ label: 'Select', value: '' },
|
|
549
557
|
...fields.map((elem) => ({
|
|
550
558
|
label: elem.field,
|
|
551
559
|
value: elem.field,
|
|
552
560
|
})),
|
|
553
|
-
] }),
|
|
561
|
+
] }), (0, jsx_runtime_1.jsx)(TextInput, { name: "label", value: column.label, placeholder: "Column Label", onChange: (e) => handleChange(e, 'columns.label', index) }), (0, jsx_runtime_1.jsx)(Select, { label: 'Column Format', value: column.format, onChange: (e) => handleChange(e, 'columns.format', index), options: [{ label: 'Select', value: '' }, ...formatOptions] }), (0, jsx_runtime_1.jsx)("div", { ref: deleteRef, children: (0, jsx_runtime_1.jsx)(DeleteButton, { style: { marginLeft: deleteButtonMargin }, onClick: () => handleRemoveField('columns', index) }) })] }, 'column' + index))) }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(SecondaryButton, { onClick: () => handleAddField('columns'), label: "Add column +" }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("br", {})] })), showDateFieldOptions && ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
554
562
|
display: 'flex',
|
|
555
563
|
flexDirection: 'column',
|
|
556
564
|
gap: 6,
|
|
557
565
|
marginTop: 6,
|
|
558
|
-
}, children: [
|
|
566
|
+
}, children: [(0, jsx_runtime_1.jsx)(Header, { children: "Date field" }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
559
567
|
display: 'flex',
|
|
560
568
|
flexDirection: 'row',
|
|
561
569
|
gap: 12,
|
|
562
570
|
// lmao part 2
|
|
563
|
-
}, children: [
|
|
571
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)(Label, { children: "Table" }), (0, jsx_runtime_1.jsx)(Select, { label: 'Date Table', value: formData.dateField.table, onChange: (e) => handleChange(e, 'dateField.table'), options: [
|
|
564
572
|
{
|
|
565
573
|
label: 'Select',
|
|
566
574
|
value: '',
|
|
@@ -569,29 +577,29 @@ function ChartBuilderForm({ TextInput = MemoizedTextInput, Select = MemoizedSele
|
|
|
569
577
|
label: elem.name,
|
|
570
578
|
value: elem.name,
|
|
571
579
|
})),
|
|
572
|
-
] })] }),
|
|
580
|
+
] })] }), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)(Label, { children: "Field" }), (0, jsx_runtime_1.jsx)(Select, { label: 'Date Field', value: formData.dateField.field, onChange: (e) => handleChange(e, 'dateField.field'), options: dateFieldOptions
|
|
573
581
|
?.find((elem) => elem.name === formData.dateField.table)
|
|
574
582
|
?.columns?.map((elem) => ({
|
|
575
583
|
label: elem.name,
|
|
576
584
|
value: elem.name,
|
|
577
|
-
})) || [] })] })] }),
|
|
585
|
+
})) || [] })] })] }), (0, jsx_runtime_1.jsx)("br", {})] })), showAccessControlOptions && ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
578
586
|
display: 'flex',
|
|
579
587
|
flexDirection: 'column',
|
|
580
588
|
gap: 12,
|
|
581
589
|
marginTop: 6,
|
|
582
|
-
}, children: [
|
|
590
|
+
}, children: [(0, jsx_runtime_1.jsx)(Header, { children: "Organization access" }), (0, jsx_runtime_1.jsx)(SegmentedControl, { onChange: (e) => handleChange(e, 'template'), value: formData.template, theme: theme }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("br", {})] })), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
583
591
|
display: 'flex',
|
|
584
592
|
flexDirection: 'row',
|
|
585
593
|
justifyContent: 'flex-end',
|
|
586
594
|
gap: 10,
|
|
587
|
-
}, children: [dashboardItem && (
|
|
595
|
+
}, children: [dashboardItem && ((0, jsx_runtime_1.jsx)(SecondaryButton, { onClick: deleteChart, label: 'Delete' })), (0, jsx_runtime_1.jsx)(Button, { onClick: editChart, label: buttonLabel
|
|
588
596
|
? buttonLabel
|
|
589
597
|
: dashboardItem
|
|
590
598
|
? 'Save changes'
|
|
591
599
|
: 'Add to dashboard' })] })] })] }));
|
|
592
600
|
}
|
|
593
601
|
function SegmentedControl({ onChange, value, theme }) {
|
|
594
|
-
return (
|
|
602
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
595
603
|
display: 'flex',
|
|
596
604
|
flexDirection: 'row',
|
|
597
605
|
alignItems: 'center',
|
|
@@ -599,7 +607,7 @@ function SegmentedControl({ onChange, value, theme }) {
|
|
|
599
607
|
maxWidth: 418,
|
|
600
608
|
padding: 4,
|
|
601
609
|
borderRadius: 6,
|
|
602
|
-
}, children: [
|
|
610
|
+
}, children: [(0, jsx_runtime_1.jsxs)("button", { className: "quill-tab", onClick: () => onChange(true), style: {
|
|
603
611
|
border: value === true ? '1px solid #E7E7E7' : '1px solid transparent',
|
|
604
612
|
outline: 'none',
|
|
605
613
|
width: '100%',
|
|
@@ -612,7 +620,7 @@ function SegmentedControl({ onChange, value, theme }) {
|
|
|
612
620
|
fontWeight: value === true ? 600 : 500,
|
|
613
621
|
fontSize: 14,
|
|
614
622
|
fontFamily: theme?.fontFamily,
|
|
615
|
-
}, children: [
|
|
623
|
+
}, children: [(0, jsx_runtime_1.jsx)("style", { children: `
|
|
616
624
|
.quill-tab {
|
|
617
625
|
background-color: ${value === true ? 'white' : 'transparent'};
|
|
618
626
|
}
|
|
@@ -622,7 +630,7 @@ function SegmentedControl({ onChange, value, theme }) {
|
|
|
622
630
|
.quill-tab:active {
|
|
623
631
|
background-color: "rgba(56, 65, 81, 0.15)";
|
|
624
632
|
}
|
|
625
|
-
` }), 'All Organizations'] }),
|
|
633
|
+
` }), 'All Organizations'] }), (0, jsx_runtime_1.jsxs)("button", { className: "quill-tab2", onClick: () => onChange(false), style: {
|
|
626
634
|
border: value === false ? '1px solid #E7E7E7' : '1px solid transparent',
|
|
627
635
|
boxShadow: value === false
|
|
628
636
|
? '0px 1px 4px 0px rgba(56, 65, 81, 0.08)'
|
|
@@ -635,7 +643,7 @@ function SegmentedControl({ onChange, value, theme }) {
|
|
|
635
643
|
fontWeight: value === false ? 600 : 500,
|
|
636
644
|
fontSize: 14,
|
|
637
645
|
fontFamily: theme?.fontFamily,
|
|
638
|
-
}, children: [
|
|
646
|
+
}, children: [(0, jsx_runtime_1.jsx)("style", { children: `
|
|
639
647
|
.quill-tab2 {
|
|
640
648
|
background-color: ${value === false ? 'white' : 'transparent'};
|
|
641
649
|
}
|
|
@@ -650,3 +658,4 @@ function SegmentedControl({ onChange, value, theme }) {
|
|
|
650
658
|
}
|
|
651
659
|
` }), 'This Organization'] })] }));
|
|
652
660
|
}
|
|
661
|
+
//# sourceMappingURL=ChartBuilder.js.map
|
package/dist/ChartEditor.js
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
2
7
|
// @ts-nocheck
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const { dispatch, dashboard } = useContext(DashboardContext);
|
|
9
|
-
const { dashboardFilters } = useContext(DashboardFiltersContext);
|
|
10
|
-
const [client, _] = useContext(ClientContext);
|
|
11
|
-
const [dashboardItem, setDashboardItem] = useState(dashboard?.[chartId]);
|
|
12
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const ChartBuilder_1 = __importDefault(require("./ChartBuilder"));
|
|
10
|
+
const Context_1 = require("./Context");
|
|
11
|
+
const dataFetcher_1 = require("./utils/dataFetcher");
|
|
12
|
+
function ChartEditor({ isOpen, chartId, admin = false, destinationDashboard, chartBuilderTitle = 'Edit chart', chartBuilderButtonLabel, onDelete, setIsOpen, Select, TextInput, Button, SecondaryButton, Header, Label, Text, DeleteButton, Modal, Popover, }) {
|
|
13
|
+
const { dispatch, dashboard } = (0, react_1.useContext)(Context_1.DashboardContext);
|
|
14
|
+
const { dashboardFilters } = (0, react_1.useContext)(Context_1.DashboardFiltersContext);
|
|
15
|
+
const [client, _] = (0, react_1.useContext)(Context_1.ClientContext);
|
|
16
|
+
const [dashboardItem, setDashboardItem] = (0, react_1.useState)(dashboard?.[chartId]);
|
|
17
|
+
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
|
13
18
|
const dateFilter = Object.values(dashboardFilters).find((filter) => filter.filterType == 'date_range');
|
|
14
19
|
const dateRange = dateFilter?.startDate
|
|
15
20
|
? [dateFilter?.startDate, dateFilter?.endDate, null]
|
|
16
21
|
: [null, null, null];
|
|
17
|
-
useEffect(() => {
|
|
22
|
+
(0, react_1.useEffect)(() => {
|
|
18
23
|
let isSubscribed = true;
|
|
19
24
|
async function getChartOptions() {
|
|
20
25
|
if (isSubscribed && !isLoading) {
|
|
@@ -40,7 +45,7 @@ export default function ChartEditor({ isOpen, chartId, admin = false, destinatio
|
|
|
40
45
|
id: chartId,
|
|
41
46
|
filters: [],
|
|
42
47
|
};
|
|
43
|
-
const resp = await getData(client, 'itempost', 'omit', hostedBody, cloudBody);
|
|
48
|
+
const resp = await (0, dataFetcher_1.getData)(client, 'itempost', 'omit', hostedBody, cloudBody);
|
|
44
49
|
if (resp) {
|
|
45
50
|
setDashboardItem(resp);
|
|
46
51
|
dispatch({
|
|
@@ -66,5 +71,7 @@ export default function ChartEditor({ isOpen, chartId, admin = false, destinatio
|
|
|
66
71
|
isSubscribed = false;
|
|
67
72
|
};
|
|
68
73
|
}, [client, chartId]);
|
|
69
|
-
return (
|
|
74
|
+
return ((0, jsx_runtime_1.jsx)("div", { children: dashboardItem && ((0, jsx_runtime_1.jsx)(ChartBuilder_1.default, { dashboardItem: dashboardItem, rows: dashboardItem.rows, columns: dashboardItem.columns, fields: dashboardItem.fields, query: dashboardItem.queryString, isOpen: isOpen, setIsOpen: setIsOpen, showTableFormatOptions: admin, showDateFieldOptions: admin, showAccessControlOptions: admin, showDashboardDropdown: admin, destinationDashboard: destinationDashboard, dateRange: dateRange, Select: Select, TextInput: TextInput, Button: Button, SecondaryButton: SecondaryButton, Header: Header, Label: Label, Text: Text, DeleteButton: DeleteButton, Modal: Modal, Popover: Popover, onDelete: onDelete, title: chartBuilderTitle, buttonLabel: chartBuilderButtonLabel })) }));
|
|
70
75
|
}
|
|
76
|
+
exports.default = ChartEditor;
|
|
77
|
+
//# sourceMappingURL=ChartEditor.js.map
|