@xplortech/insights-elements 0.0.1-draft.7729525
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/LICENSE +21 -0
- package/README.md +24 -0
- package/dist/cjs/apollo-data.esm-by4pfDU4.js +30 -0
- package/dist/cjs/apollo-data.esm-by4pfDU4.js.map +1 -0
- package/dist/cjs/app-globals-D-MP41KM.js +62 -0
- package/dist/cjs/app-globals-D-MP41KM.js.map +1 -0
- package/dist/cjs/index-CyoztwkV.js +40 -0
- package/dist/cjs/index-CyoztwkV.js.map +1 -0
- package/dist/cjs/index-DtrFwwSq.js +1472 -0
- package/dist/cjs/index-DtrFwwSq.js.map +1 -0
- package/dist/cjs/index.cjs.js +8 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/insights-bar-chart.cjs.entry.js +42 -0
- package/dist/cjs/insights-bar-chart.entry.cjs.js.map +1 -0
- package/dist/cjs/insights-chart-base-D6QbrWmD.js +102 -0
- package/dist/cjs/insights-chart-base-D6QbrWmD.js.map +1 -0
- package/dist/cjs/insights-donut-chart.cjs.entry.js +42 -0
- package/dist/cjs/insights-donut-chart.entry.cjs.js.map +1 -0
- package/dist/cjs/insights-elements.cjs.js +26 -0
- package/dist/cjs/insights-elements.cjs.js.map +1 -0
- package/dist/cjs/insights-wrapper.cjs.entry.js +1087 -0
- package/dist/cjs/insights-wrapper.entry.cjs.js.map +1 -0
- package/dist/cjs/loader.cjs.js +14 -0
- package/dist/cjs/loader.cjs.js.map +1 -0
- package/dist/collection/collection-manifest.json +15 -0
- package/dist/collection/components/insights-bar-chart/insights-bar-chart.css +87 -0
- package/dist/collection/components/insights-bar-chart/insights-bar-chart.js +51 -0
- package/dist/collection/components/insights-bar-chart/insights-bar-chart.js.map +1 -0
- package/dist/collection/components/insights-chart-base.js +213 -0
- package/dist/collection/components/insights-chart-base.js.map +1 -0
- package/dist/collection/components/insights-donut-chart/insights-donut-chart.css +87 -0
- package/dist/collection/components/insights-donut-chart/insights-donut-chart.js +51 -0
- package/dist/collection/components/insights-donut-chart/insights-donut-chart.js.map +1 -0
- package/dist/collection/components/insights-wrapper/insights-wrapper.css +17 -0
- package/dist/collection/components/insights-wrapper/insights-wrapper.js +402 -0
- package/dist/collection/components/insights-wrapper/insights-wrapper.js.map +1 -0
- package/dist/collection/global/app.js +35 -0
- package/dist/collection/global/app.js.map +1 -0
- package/dist/collection/index.js +12 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/utils/chart-types.js +16 -0
- package/dist/collection/utils/chart-types.js.map +1 -0
- package/dist/collection/utils/code-generator.js +201 -0
- package/dist/collection/utils/code-generator.js.map +1 -0
- package/dist/collection/utils/insights-context.js +33 -0
- package/dist/collection/utils/insights-context.js.map +1 -0
- package/dist/components/index.d.ts +33 -0
- package/dist/components/index.js +44 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/insights-bar-chart.d.ts +11 -0
- package/dist/components/insights-bar-chart.js +73 -0
- package/dist/components/insights-bar-chart.js.map +1 -0
- package/dist/components/insights-donut-chart.d.ts +11 -0
- package/dist/components/insights-donut-chart.js +73 -0
- package/dist/components/insights-donut-chart.js.map +1 -0
- package/dist/components/insights-wrapper.d.ts +11 -0
- package/dist/components/insights-wrapper.js +1123 -0
- package/dist/components/insights-wrapper.js.map +1 -0
- package/dist/components/p-CSTD3N9t.js +37 -0
- package/dist/components/p-CSTD3N9t.js.map +1 -0
- package/dist/components/p-DFvs3VMW.js +1195 -0
- package/dist/components/p-DFvs3VMW.js.map +1 -0
- package/dist/components/p-DHA6uI9u.js +9 -0
- package/dist/components/p-DHA6uI9u.js.map +1 -0
- package/dist/components/p-Dv82-c17.js +100 -0
- package/dist/components/p-Dv82-c17.js.map +1 -0
- package/dist/esm/apollo-data.esm-DHA6uI9u.js +9 -0
- package/dist/esm/apollo-data.esm-DHA6uI9u.js.map +1 -0
- package/dist/esm/app-globals-BtE_P06_.js +41 -0
- package/dist/esm/app-globals-BtE_P06_.js.map +1 -0
- package/dist/esm/index-BAqvP5--.js +1447 -0
- package/dist/esm/index-BAqvP5--.js.map +1 -0
- package/dist/esm/index-CSTD3N9t.js +37 -0
- package/dist/esm/index-CSTD3N9t.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/insights-bar-chart.entry.js +40 -0
- package/dist/esm/insights-bar-chart.entry.js.map +1 -0
- package/dist/esm/insights-chart-base-uNbdsloe.js +100 -0
- package/dist/esm/insights-chart-base-uNbdsloe.js.map +1 -0
- package/dist/esm/insights-donut-chart.entry.js +40 -0
- package/dist/esm/insights-donut-chart.entry.js.map +1 -0
- package/dist/esm/insights-elements.js +22 -0
- package/dist/esm/insights-elements.js.map +1 -0
- package/dist/esm/insights-wrapper.entry.js +1085 -0
- package/dist/esm/insights-wrapper.entry.js.map +1 -0
- package/dist/esm/loader.js +12 -0
- package/dist/esm/loader.js.map +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/insights-elements/index.esm.js +2 -0
- package/dist/insights-elements/index.esm.js.map +1 -0
- package/dist/insights-elements/insights-bar-chart.entry.esm.js.map +1 -0
- package/dist/insights-elements/insights-donut-chart.entry.esm.js.map +1 -0
- package/dist/insights-elements/insights-elements.esm.js +2 -0
- package/dist/insights-elements/insights-elements.esm.js.map +1 -0
- package/dist/insights-elements/insights-wrapper.entry.esm.js.map +1 -0
- package/dist/insights-elements/loader.esm.js.map +1 -0
- package/dist/insights-elements/p-247183e1.entry.js +2 -0
- package/dist/insights-elements/p-247183e1.entry.js.map +1 -0
- package/dist/insights-elements/p-29ce0a90.entry.js +2 -0
- package/dist/insights-elements/p-29ce0a90.entry.js.map +1 -0
- package/dist/insights-elements/p-BAqvP5--.js +3 -0
- package/dist/insights-elements/p-BAqvP5--.js.map +1 -0
- package/dist/insights-elements/p-CSTD3N9t.js +2 -0
- package/dist/insights-elements/p-CSTD3N9t.js.map +1 -0
- package/dist/insights-elements/p-DE0h_D1B.js +2 -0
- package/dist/insights-elements/p-DE0h_D1B.js.map +1 -0
- package/dist/insights-elements/p-DHA6uI9u.js +3 -0
- package/dist/insights-elements/p-DHA6uI9u.js.map +1 -0
- package/dist/insights-elements/p-DVNwzSpV.js +2 -0
- package/dist/insights-elements/p-DVNwzSpV.js.map +1 -0
- package/dist/insights-elements/p-e48a7068.entry.js +2 -0
- package/dist/insights-elements/p-e48a7068.entry.js.map +1 -0
- package/dist/types/components/insights-bar-chart/insights-bar-chart.d.ts +9 -0
- package/dist/types/components/insights-chart-base.d.ts +54 -0
- package/dist/types/components/insights-donut-chart/insights-donut-chart.d.ts +9 -0
- package/dist/types/components/insights-wrapper/insights-wrapper.d.ts +46 -0
- package/dist/types/components.d.ts +201 -0
- package/dist/types/global/app.d.ts +6 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/stencil-public-runtime.d.ts +1756 -0
- package/dist/types/utils/chart-types.d.ts +53 -0
- package/dist/types/utils/code-generator.d.ts +31 -0
- package/dist/types/utils/insights-context.d.ts +39 -0
- package/insights-loader/cdn.js +1 -0
- package/insights-loader/index.cjs.js +1 -0
- package/insights-loader/index.d.ts +24 -0
- package/insights-loader/index.es2017.js +1 -0
- package/insights-loader/index.js +2 -0
- package/loader/index.cjs.js +8 -0
- package/loader/index.d.ts +5 -0
- package/loader/index.js +7 -0
- package/package.json +92 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code generator for insights chart components
|
|
3
|
+
* Generates framework-specific code examples based on current story args
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Convert kebab-case to PascalCase
|
|
7
|
+
* e.g. 'insights-bar-chart' -> 'InsightsBarChart'
|
|
8
|
+
*/
|
|
9
|
+
function toPascalCase(str) {
|
|
10
|
+
return str
|
|
11
|
+
.split('-')
|
|
12
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
13
|
+
.join('');
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Convert kebab-case to camelCase
|
|
17
|
+
* e.g. 'insights-bar-chart' -> 'insightsBarChart'
|
|
18
|
+
*/
|
|
19
|
+
function toCamelCase(str) {
|
|
20
|
+
const pascal = toPascalCase(str);
|
|
21
|
+
return pascal.charAt(0).toLowerCase() + pascal.slice(1);
|
|
22
|
+
}
|
|
23
|
+
function buildNormalizeMappingCode(mappings) {
|
|
24
|
+
return (mappings
|
|
25
|
+
?.filter(m => m.outputKey && m.sourceField)
|
|
26
|
+
.map(m => ` ${m.outputKey}: row['${m.sourceField}']`)
|
|
27
|
+
.join(',\n') || '');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Build the getQueryByFilters function code with dynamic filter references
|
|
31
|
+
* Values like "filters_location_id" become filters.location_id
|
|
32
|
+
*/
|
|
33
|
+
function buildGetQueryByFiltersCode(props, indent = ' ') {
|
|
34
|
+
const lines = [];
|
|
35
|
+
lines.push(`const getQueryByFilters = (filters) => ({`);
|
|
36
|
+
const safeColumns = Array.isArray(props.columns) ? props.columns : [];
|
|
37
|
+
const safeQueryFilters = Array.isArray(props.queryFilters) ? props.queryFilters : [];
|
|
38
|
+
const safeOrder = props.order && typeof props.order === 'object' ? props.order : {};
|
|
39
|
+
const safeTotals = Array.isArray(props.totals) ? props.totals : [];
|
|
40
|
+
if (safeColumns.length) {
|
|
41
|
+
lines.push(`${indent}columns: ${JSON.stringify(safeColumns)},`);
|
|
42
|
+
}
|
|
43
|
+
if (safeQueryFilters.length) {
|
|
44
|
+
lines.push(`${indent}filters: [`);
|
|
45
|
+
safeQueryFilters.forEach((f, i) => {
|
|
46
|
+
if (!f || typeof f !== 'object')
|
|
47
|
+
return;
|
|
48
|
+
const values = Array.isArray(f.values) ? f.values : [];
|
|
49
|
+
const valuesCode = values
|
|
50
|
+
.map((v) => {
|
|
51
|
+
if (typeof v === 'string' && v.startsWith('filters_')) {
|
|
52
|
+
const key = v.replace('filters_', '');
|
|
53
|
+
return `filters.${key}`;
|
|
54
|
+
}
|
|
55
|
+
return JSON.stringify(v);
|
|
56
|
+
})
|
|
57
|
+
.join(', ');
|
|
58
|
+
const comma = i < safeQueryFilters.length - 1 ? ',' : '';
|
|
59
|
+
lines.push(`${indent} { member: '${f.member || ''}', operator: '${f.operator || 'equals'}', values: [${valuesCode}] }${comma}`);
|
|
60
|
+
});
|
|
61
|
+
lines.push(`${indent}],`);
|
|
62
|
+
}
|
|
63
|
+
if (Object.keys(safeOrder).length) {
|
|
64
|
+
lines.push(`${indent}order: ${JSON.stringify(safeOrder)},`);
|
|
65
|
+
}
|
|
66
|
+
if (safeTotals.length) {
|
|
67
|
+
lines.push(`${indent}totals: ${JSON.stringify(safeTotals.filter(t => t && t.member))},`);
|
|
68
|
+
}
|
|
69
|
+
if (props.limit) {
|
|
70
|
+
lines.push(`${indent}limit: ${props.limit},`);
|
|
71
|
+
}
|
|
72
|
+
lines.push(`});`);
|
|
73
|
+
return lines.join('\n');
|
|
74
|
+
}
|
|
75
|
+
export function generateReactCode(props) {
|
|
76
|
+
const normalizeCode = buildNormalizeMappingCode(props.normalizeMapping);
|
|
77
|
+
const apiUrl = props.apiUrl || 'http://localhost:3000/v1';
|
|
78
|
+
const filtersStr = JSON.stringify(props.filters || {}, null, 2).replace(/\n/g, '\n ');
|
|
79
|
+
const getQueryCode = buildGetQueryByFiltersCode(props, ' ');
|
|
80
|
+
const componentName = props.componentName || 'insights-donut-chart';
|
|
81
|
+
const reactComponent = toPascalCase(componentName);
|
|
82
|
+
const functionName = 'My' + toPascalCase(componentName.replace('insights-', ''));
|
|
83
|
+
return `import { InsightsWrapper, ${reactComponent} } from '@xplortech/insights-elements-react';
|
|
84
|
+
|
|
85
|
+
function ${functionName}() {
|
|
86
|
+
const filters = ${filtersStr};
|
|
87
|
+
|
|
88
|
+
${getQueryCode}
|
|
89
|
+
|
|
90
|
+
const normalizeRawResponse = (response) => {
|
|
91
|
+
return response.getData().map(row => ({
|
|
92
|
+
${normalizeCode}
|
|
93
|
+
}));
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<InsightsWrapper apiUrl="${apiUrl}" token="YOUR_TOKEN">
|
|
98
|
+
<${reactComponent}
|
|
99
|
+
reportName="${props.reportName}"
|
|
100
|
+
filters={filters}
|
|
101
|
+
spec={${JSON.stringify(props.spec)}}
|
|
102
|
+
getQueryByFilters={getQueryByFilters}
|
|
103
|
+
normalizeRawResponse={normalizeRawResponse}
|
|
104
|
+
/>
|
|
105
|
+
</InsightsWrapper>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export default ${functionName};`;
|
|
110
|
+
}
|
|
111
|
+
export function generateVueCode(props) {
|
|
112
|
+
const normalizeCode = buildNormalizeMappingCode(props.normalizeMapping);
|
|
113
|
+
const apiUrl = props.apiUrl || 'http://localhost:3000/v1';
|
|
114
|
+
const getQueryCode = buildGetQueryByFiltersCode(props, ' ');
|
|
115
|
+
const componentName = props.componentName || 'insights-donut-chart';
|
|
116
|
+
const vueComponent = toPascalCase(componentName);
|
|
117
|
+
return `<template>
|
|
118
|
+
<InsightsWrapper :api-url="apiUrl" :token="token">
|
|
119
|
+
<${vueComponent}
|
|
120
|
+
:report-name="reportName"
|
|
121
|
+
:filters="filters"
|
|
122
|
+
:spec="spec"
|
|
123
|
+
:get-query-by-filters="getQueryByFilters"
|
|
124
|
+
:normalize-raw-response="normalizeRawResponse"
|
|
125
|
+
/>
|
|
126
|
+
</InsightsWrapper>
|
|
127
|
+
</template>
|
|
128
|
+
|
|
129
|
+
<script setup lang="ts">
|
|
130
|
+
import { InsightsWrapper, ${vueComponent} } from '@xplortech/insights-elements-vue';
|
|
131
|
+
|
|
132
|
+
const apiUrl = '${apiUrl}';
|
|
133
|
+
const token = 'YOUR_TOKEN';
|
|
134
|
+
const reportName = '${props.reportName}';
|
|
135
|
+
const filters = ${JSON.stringify(props.filters || {}, null, 2)};
|
|
136
|
+
const spec = ${JSON.stringify(props.spec)};
|
|
137
|
+
|
|
138
|
+
${getQueryCode}
|
|
139
|
+
|
|
140
|
+
const normalizeRawResponse = (response) => {
|
|
141
|
+
return response.getData().map(row => ({
|
|
142
|
+
${normalizeCode}
|
|
143
|
+
}));
|
|
144
|
+
};
|
|
145
|
+
</script>`;
|
|
146
|
+
}
|
|
147
|
+
export function generateWebComponentCode(props) {
|
|
148
|
+
const normalizeCode = buildNormalizeMappingCode(props.normalizeMapping);
|
|
149
|
+
const apiUrl = props.apiUrl || 'http://localhost:3000/v1';
|
|
150
|
+
const getQueryCode = buildGetQueryByFiltersCode(props, ' ');
|
|
151
|
+
const componentName = props.componentName || 'insights-donut-chart';
|
|
152
|
+
const chartId = toCamelCase(componentName.replace('insights-', ''));
|
|
153
|
+
return `<!DOCTYPE html>
|
|
154
|
+
<html>
|
|
155
|
+
<head>
|
|
156
|
+
<script type="module">
|
|
157
|
+
import { defineCustomElements } from '@xplortech/insights-elements/loader';
|
|
158
|
+
defineCustomElements();
|
|
159
|
+
</script>
|
|
160
|
+
</head>
|
|
161
|
+
<body>
|
|
162
|
+
<insights-wrapper api-url="${apiUrl}" token="YOUR_TOKEN">
|
|
163
|
+
<${componentName}
|
|
164
|
+
id="${chartId}"
|
|
165
|
+
report-name="${props.reportName}"
|
|
166
|
+
></${componentName}>
|
|
167
|
+
</insights-wrapper>
|
|
168
|
+
|
|
169
|
+
<script>
|
|
170
|
+
const chart = document.getElementById('${chartId}');
|
|
171
|
+
|
|
172
|
+
chart.filters = ${JSON.stringify(props.filters || {}, null, 2).replace(/\n/g, '\n ')};
|
|
173
|
+
chart.spec = ${JSON.stringify(props.spec)};
|
|
174
|
+
|
|
175
|
+
${getQueryCode.replace(/\n/g, '\n ')}
|
|
176
|
+
chart.getQueryByFilters = getQueryByFilters;
|
|
177
|
+
|
|
178
|
+
chart.normalizeRawResponse = (response) => {
|
|
179
|
+
return response.getData().map(row => ({
|
|
180
|
+
${normalizeCode
|
|
181
|
+
.split('\n')
|
|
182
|
+
.map(l => ' ' + l)
|
|
183
|
+
.join('\n')}
|
|
184
|
+
}));
|
|
185
|
+
};
|
|
186
|
+
</script>
|
|
187
|
+
</body>
|
|
188
|
+
</html>`;
|
|
189
|
+
}
|
|
190
|
+
export function getCodeForFramework(props, framework = 'webcomponent') {
|
|
191
|
+
switch (framework) {
|
|
192
|
+
case 'react':
|
|
193
|
+
return generateReactCode(props);
|
|
194
|
+
case 'vue':
|
|
195
|
+
return generateVueCode(props);
|
|
196
|
+
case 'webcomponent':
|
|
197
|
+
default:
|
|
198
|
+
return generateWebComponentCode(props);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=code-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-generator.js","sourceRoot":"","sources":["../../src/utils/code-generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH;;;GAGG;AACH,SAAS,YAAY,CAAC,GAAW;IAC/B,OAAO,GAAG;SACP,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACzD,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,SAAS,WAAW,CAAC,GAAW;IAC9B,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,yBAAyB,CAAC,QAA2D;IAC5F,OAAO,CACL,QAAQ;QACN,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,WAAW,CAAC;SAC1C,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,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,CAAC,OAAO,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC;mBACxE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC;;MAEvC,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC;;;;;EAKzC,aAAa;SACZ,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;SACpB,IAAI,CAAC,IAAI,CAAC;;;;;QAKL,CAAC;AACT,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAU,EAAE,YAAoB,cAAc;IAChF,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,OAAO;YACV,OAAO,iBAAiB,CAAC,KAAqB,CAAC,CAAC;QAClD,KAAK,KAAK;YACR,OAAO,eAAe,CAAC,KAAqB,CAAC,CAAC;QAChD,KAAK,cAAc,CAAC;QACpB;YACE,OAAO,wBAAwB,CAAC,KAAqB,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC","sourcesContent":["/**\n * Code generator for insights chart components\n * Generates framework-specific code examples based on current story args\n */\n\nexport interface CodeGenProps {\n reportName: string;\n filters: Record<string, any>;\n columns: string[];\n queryFilters: Array<{ member: string; operator: string; values: any[] }>;\n order: Record<string, 'asc' | 'desc'>;\n totals: Array<{ fn: string; member: string }>;\n limit: number;\n normalizeMapping: Array<{ outputKey: string; sourceField: string }>;\n spec: any;\n apiUrl?: string;\n componentName?: string; // e.g. 'insights-bar-chart', 'insights-donut-chart'\n}\n\n/**\n * Convert kebab-case to PascalCase\n * e.g. 'insights-bar-chart' -> 'InsightsBarChart'\n */\nfunction toPascalCase(str: string): string {\n return str\n .split('-')\n .map(word => word.charAt(0).toUpperCase() + word.slice(1))\n .join('');\n}\n\n/**\n * Convert kebab-case to camelCase\n * e.g. 'insights-bar-chart' -> 'insightsBarChart'\n */\nfunction toCamelCase(str: string): string {\n const pascal = toPascalCase(str);\n return pascal.charAt(0).toLowerCase() + pascal.slice(1);\n}\n\nfunction buildNormalizeMappingCode(mappings: Array<{ outputKey: string; sourceField: string }>): string {\n return (\n mappings\n ?.filter(m => m.outputKey && m.sourceField)\n .map(m => ` ${m.outputKey}: row['${m.sourceField}']`)\n .join(',\\n') || ''\n );\n}\n\n/**\n * Build the getQueryByFilters function code with dynamic filter references\n * Values like \"filters_location_id\" become filters.location_id\n */\nfunction buildGetQueryByFiltersCode(props: CodeGenProps, indent: string = ' '): string {\n const lines: string[] = [];\n lines.push(`const getQueryByFilters = (filters) => ({`);\n\n const safeColumns = Array.isArray(props.columns) ? props.columns : [];\n const safeQueryFilters = Array.isArray(props.queryFilters) ? props.queryFilters : [];\n const safeOrder = props.order && typeof props.order === 'object' ? props.order : {};\n const safeTotals = Array.isArray(props.totals) ? props.totals : [];\n\n if (safeColumns.length) {\n lines.push(`${indent}columns: ${JSON.stringify(safeColumns)},`);\n }\n\n if (safeQueryFilters.length) {\n lines.push(`${indent}filters: [`);\n safeQueryFilters.forEach((f, i) => {\n if (!f || typeof f !== 'object') return;\n const values = Array.isArray(f.values) ? f.values : [];\n const valuesCode = values\n .map((v: any) => {\n if (typeof v === 'string' && v.startsWith('filters_')) {\n const key = v.replace('filters_', '');\n return `filters.${key}`;\n }\n return JSON.stringify(v);\n })\n .join(', ');\n const comma = i < safeQueryFilters.length - 1 ? ',' : '';\n lines.push(`${indent} { member: '${f.member || ''}', operator: '${f.operator || 'equals'}', values: [${valuesCode}] }${comma}`);\n });\n lines.push(`${indent}],`);\n }\n\n if (Object.keys(safeOrder).length) {\n lines.push(`${indent}order: ${JSON.stringify(safeOrder)},`);\n }\n\n if (safeTotals.length) {\n lines.push(`${indent}totals: ${JSON.stringify(safeTotals.filter(t => t && t.member))},`);\n }\n\n if (props.limit) {\n lines.push(`${indent}limit: ${props.limit},`);\n }\n\n lines.push(`});`);\n return lines.join('\\n');\n}\n\nexport function generateReactCode(props: CodeGenProps): string {\n const normalizeCode = buildNormalizeMappingCode(props.normalizeMapping);\n const apiUrl = props.apiUrl || 'http://localhost:3000/v1';\n const filtersStr = JSON.stringify(props.filters || {}, null, 2).replace(/\\n/g, '\\n ');\n const getQueryCode = buildGetQueryByFiltersCode(props, ' ');\n\n const componentName = props.componentName || 'insights-donut-chart';\n const reactComponent = toPascalCase(componentName);\n const functionName = 'My' + toPascalCase(componentName.replace('insights-', ''));\n\n return `import { InsightsWrapper, ${reactComponent} } from '@xplortech/insights-elements-react';\n\nfunction ${functionName}() {\n const filters = ${filtersStr};\n\n ${getQueryCode}\n\n const normalizeRawResponse = (response) => {\n return response.getData().map(row => ({\n${normalizeCode}\n }));\n };\n\n return (\n <InsightsWrapper apiUrl=\"${apiUrl}\" token=\"YOUR_TOKEN\">\n <${reactComponent}\n reportName=\"${props.reportName}\"\n filters={filters}\n spec={${JSON.stringify(props.spec)}}\n getQueryByFilters={getQueryByFilters}\n normalizeRawResponse={normalizeRawResponse}\n />\n </InsightsWrapper>\n );\n}\n\nexport default ${functionName};`;\n}\n\nexport function generateVueCode(props: CodeGenProps): string {\n const normalizeCode = buildNormalizeMappingCode(props.normalizeMapping);\n const apiUrl = props.apiUrl || 'http://localhost:3000/v1';\n const getQueryCode = buildGetQueryByFiltersCode(props, ' ');\n\n const componentName = props.componentName || 'insights-donut-chart';\n const vueComponent = toPascalCase(componentName);\n\n return `<template>\n <InsightsWrapper :api-url=\"apiUrl\" :token=\"token\">\n <${vueComponent}\n :report-name=\"reportName\"\n :filters=\"filters\"\n :spec=\"spec\"\n :get-query-by-filters=\"getQueryByFilters\"\n :normalize-raw-response=\"normalizeRawResponse\"\n />\n </InsightsWrapper>\n</template>\n\n<script setup lang=\"ts\">\nimport { InsightsWrapper, ${vueComponent} } from '@xplortech/insights-elements-vue';\n\nconst apiUrl = '${apiUrl}';\nconst token = 'YOUR_TOKEN';\nconst reportName = '${props.reportName}';\nconst filters = ${JSON.stringify(props.filters || {}, null, 2)};\nconst spec = ${JSON.stringify(props.spec)};\n\n${getQueryCode}\n\nconst normalizeRawResponse = (response) => {\n return response.getData().map(row => ({\n${normalizeCode}\n }));\n};\n</script>`;\n}\n\nexport function generateWebComponentCode(props: CodeGenProps): string {\n const normalizeCode = buildNormalizeMappingCode(props.normalizeMapping);\n const apiUrl = props.apiUrl || 'http://localhost:3000/v1';\n const getQueryCode = buildGetQueryByFiltersCode(props, ' ');\n\n const componentName = props.componentName || 'insights-donut-chart';\n const chartId = toCamelCase(componentName.replace('insights-', ''));\n\n return `<!DOCTYPE html>\n<html>\n<head>\n <script type=\"module\">\n import { defineCustomElements } from '@xplortech/insights-elements/loader';\n defineCustomElements();\n </script>\n</head>\n<body>\n <insights-wrapper api-url=\"${apiUrl}\" token=\"YOUR_TOKEN\">\n <${componentName} \n id=\"${chartId}\"\n report-name=\"${props.reportName}\"\n ></${componentName}>\n </insights-wrapper>\n\n <script>\n const chart = document.getElementById('${chartId}');\n \n chart.filters = ${JSON.stringify(props.filters || {}, null, 2).replace(/\\n/g, '\\n ')};\n chart.spec = ${JSON.stringify(props.spec)};\n \n ${getQueryCode.replace(/\\n/g, '\\n ')}\n chart.getQueryByFilters = getQueryByFilters;\n \n chart.normalizeRawResponse = (response) => {\n return response.getData().map(row => ({\n${normalizeCode\n .split('\\n')\n .map(l => ' ' + l)\n .join('\\n')}\n }));\n };\n </script>\n</body>\n</html>`;\n}\n\nexport function getCodeForFramework(props: any, framework: string = 'webcomponent'): string {\n switch (framework) {\n case 'react':\n return generateReactCode(props as CodeGenProps);\n case 'vue':\n return generateVueCode(props as CodeGenProps);\n case 'webcomponent':\n default:\n return generateWebComponentCode(props as CodeGenProps);\n }\n}\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Global configuration store
|
|
2
|
+
let globalConfigurations = {};
|
|
3
|
+
/**
|
|
4
|
+
* Setup multiple configurations for insights
|
|
5
|
+
* @param configurations - Map of configuration names to configuration items
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* setupConfiguration({
|
|
9
|
+
* default: {
|
|
10
|
+
* apiUrl: 'https://api.example.com',
|
|
11
|
+
* token: 'token123',
|
|
12
|
+
* refreshToken: async () => 'newToken',
|
|
13
|
+
* onEventEmitted: (event) => console.log(event)
|
|
14
|
+
* },
|
|
15
|
+
* europe: {
|
|
16
|
+
* apiUrl: 'https://api.eu.example.com',
|
|
17
|
+
* token: 'euToken123'
|
|
18
|
+
* }
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export const setupConfiguration = (configurations) => {
|
|
23
|
+
globalConfigurations = configurations;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Get configuration by name
|
|
27
|
+
* @param configName - Name of the configuration to retrieve (defaults to 'default')
|
|
28
|
+
*/
|
|
29
|
+
export const getConfiguration = (configName) => {
|
|
30
|
+
const name = configName || 'default';
|
|
31
|
+
return globalConfigurations[name];
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=insights-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insights-context.js","sourceRoot":"","sources":["../../src/utils/insights-context.ts"],"names":[],"mappings":"AAkBA,6BAA6B;AAC7B,IAAI,oBAAoB,GAAkB,EAAE,CAAC;AAE7C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,cAA6B,EAAE,EAAE;IAClE,oBAAoB,GAAG,cAAc,CAAC;AACxC,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,UAAmB,EAAiC,EAAE;IACrF,MAAM,IAAI,GAAG,UAAU,IAAI,SAAS,CAAC;IACrC,OAAO,oBAAoB,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC,CAAC","sourcesContent":["export type EventType = 'error' | 'warning';\n\nexport interface EventData {\n eventType: EventType;\n data: any;\n}\n\nexport interface ConfigurationItem {\n apiUrl: string;\n token?: string;\n refreshToken?: () => Promise<string> | string;\n onEventEmitted?: (event: EventData) => void;\n}\n\nexport interface Configuration {\n [configName: string]: ConfigurationItem;\n}\n\n// Global configuration store\nlet globalConfigurations: Configuration = {};\n\n/**\n * Setup multiple configurations for insights\n * @param configurations - Map of configuration names to configuration items\n * @example\n * ```typescript\n * setupConfiguration({\n * default: {\n * apiUrl: 'https://api.example.com',\n * token: 'token123',\n * refreshToken: async () => 'newToken',\n * onEventEmitted: (event) => console.log(event)\n * },\n * europe: {\n * apiUrl: 'https://api.eu.example.com',\n * token: 'euToken123'\n * }\n * });\n * ```\n */\nexport const setupConfiguration = (configurations: Configuration) => {\n globalConfigurations = configurations;\n};\n\n/**\n * Get configuration by name\n * @param configName - Name of the configuration to retrieve (defaults to 'default')\n */\nexport const getConfiguration = (configName?: string): ConfigurationItem | undefined => {\n const name = configName || 'default';\n return globalConfigurations[name];\n};\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the base path to where the assets can be found. Use "setAssetPath(path)"
|
|
3
|
+
* if the path needs to be customized.
|
|
4
|
+
*/
|
|
5
|
+
export declare const getAssetPath: (path: string) => string;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Used to manually set the base path where assets can be found.
|
|
9
|
+
* If the script is used as "module", it's recommended to use "import.meta.url",
|
|
10
|
+
* such as "setAssetPath(import.meta.url)". Other options include
|
|
11
|
+
* "setAssetPath(document.currentScript.src)", or using a bundler's replace plugin to
|
|
12
|
+
* dynamically set the path at build time, such as "setAssetPath(process.env.ASSET_PATH)".
|
|
13
|
+
* But do note that this configuration depends on how your script is bundled, or lack of
|
|
14
|
+
* bundling, and where your assets can be loaded from. Additionally custom bundling
|
|
15
|
+
* will have to ensure the static assets are copied to its build directory.
|
|
16
|
+
*/
|
|
17
|
+
export declare const setAssetPath: (path: string) => void;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Used to specify a nonce value that corresponds with an application's CSP.
|
|
21
|
+
* When set, the nonce will be added to all dynamically created script and style tags at runtime.
|
|
22
|
+
* Alternatively, the nonce value can be set on a meta tag in the DOM head
|
|
23
|
+
* (<meta name="csp-nonce" content="{ nonce value here }" />) which
|
|
24
|
+
* will result in the same behavior.
|
|
25
|
+
*/
|
|
26
|
+
export declare const setNonce: (nonce: string) => void
|
|
27
|
+
|
|
28
|
+
export interface SetPlatformOptions {
|
|
29
|
+
raf?: (c: FrameRequestCallback) => number;
|
|
30
|
+
ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
31
|
+
rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
32
|
+
}
|
|
33
|
+
export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export { g as getAssetPath, r as render, s as setAssetPath, a as setNonce, b as setPlatformOptions } from './p-DFvs3VMW.js';
|
|
2
|
+
export { s as setupConfiguration } from './p-CSTD3N9t.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Global script for insights-elements
|
|
6
|
+
* Auto-loads apollo-data components when the library initializes
|
|
7
|
+
*/
|
|
8
|
+
var appGlobalScript = async () => {
|
|
9
|
+
if (typeof window === 'undefined')
|
|
10
|
+
return;
|
|
11
|
+
// Auto-load apollo-data when insights-elements initializes
|
|
12
|
+
try {
|
|
13
|
+
// Determine the base URL for apollo-data based on the current script location
|
|
14
|
+
let apolloDataUrl;
|
|
15
|
+
if (typeof import.meta?.url === 'string') {
|
|
16
|
+
const baseUrl = new URL('.', import.meta.url).href;
|
|
17
|
+
apolloDataUrl = new URL('apollo-data/apollo-data.esm.js', baseUrl).href;
|
|
18
|
+
}
|
|
19
|
+
if (apolloDataUrl) {
|
|
20
|
+
// Try loading from the co-located apollo-data folder first (works for both dev and bundled scenarios)
|
|
21
|
+
try {
|
|
22
|
+
await import(/* @vite-ignore */ apolloDataUrl);
|
|
23
|
+
console.log('✓ apollo-data loaded from co-located bundle', { apolloDataUrl });
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// Fall through to npm package import
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// Fallback: Import from npm package (for bundlers that handle this)
|
|
31
|
+
await import('./p-DHA6uI9u.js');
|
|
32
|
+
console.log('✓ apollo-data loaded from npm package');
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
console.warn('ℹ apollo-data not available:', error?.message || error);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const globalScripts = appGlobalScript;
|
|
40
|
+
|
|
41
|
+
globalScripts();
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"index.js","mappings":";;;AAAA;;;AAGG;AACH,sBAAe,YAAW;IACxB,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE;;AAGnC,IAAA,IAAI;;AAEF,QAAA,IAAI,aAAiC;QAErC,IAAI,OAAO,MAAM,CAAC,IAAI,EAAE,GAAG,KAAK,QAAQ,EAAE;AACxC,YAAA,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI;YAClD,aAAa,GAAG,IAAI,GAAG,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC,IAAI;;QAGzE,IAAI,aAAa,EAAE;;AAEjB,YAAA,IAAI;AACF,gBAAA,MAAM,0BAA0B,aAAa,CAAC;gBAC9C,OAAO,CAAC,GAAG,CAAC,6CAA6C,EAAE,EAAE,aAAa,EAAE,CAAC;gBAC7E;;AACA,YAAA,MAAM;;;;;AAMV,QAAA,MAAM,OAAO,iBAAwB,CAAC;AACtC,QAAA,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC;;IACpD,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,IAAI,CAAC,8BAA8B,EAAG,KAAe,EAAE,OAAO,IAAI,KAAK,CAAC;;AAEpF,CAAC;;ACjCM,MAAM,aAAa,GAAG,eAAe;;","names":[],"sources":["src/global/app.ts","@stencil/core/internal/app-globals"],"sourcesContent":["/**\n * Global script for insights-elements\n * Auto-loads apollo-data components when the library initializes\n */\nexport default async () => {\n if (typeof window === 'undefined') return;\n\n // Auto-load apollo-data when insights-elements initializes\n try {\n // Determine the base URL for apollo-data based on the current script location\n let apolloDataUrl: string | undefined;\n\n if (typeof import.meta?.url === 'string') {\n const baseUrl = new URL('.', import.meta.url).href;\n apolloDataUrl = new URL('apollo-data/apollo-data.esm.js', baseUrl).href;\n }\n\n if (apolloDataUrl) {\n // Try loading from the co-located apollo-data folder first (works for both dev and bundled scenarios)\n try {\n await import(/* @vite-ignore */ apolloDataUrl);\n console.log('✓ apollo-data loaded from co-located bundle', { apolloDataUrl });\n return;\n } catch {\n // Fall through to npm package import\n }\n }\n\n // Fallback: Import from npm package (for bundlers that handle this)\n await import('@xplortech/apollo-data');\n console.log('✓ apollo-data loaded from npm package');\n } catch (error) {\n console.warn('ℹ apollo-data not available:', (error as Error)?.message || error);\n }\n};\n","import appGlobalScript from '/home/runner/work/insights-api/insights-api/packages/insights-elements/src/global/app.ts';\nexport const globalScripts = appGlobalScript;\nexport const globalStyles = \"\";\n"],"version":3}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface InsightsBarChart extends Components.InsightsBarChart, HTMLElement {}
|
|
4
|
+
export const InsightsBarChart: {
|
|
5
|
+
prototype: InsightsBarChart;
|
|
6
|
+
new (): InsightsBarChart;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { p as proxyCustomElement, h } from './p-DFvs3VMW.js';
|
|
2
|
+
import { I as InsightsChartBase } from './p-Dv82-c17.js';
|
|
3
|
+
|
|
4
|
+
const insightsBarChartCss = ":host{display:block}.insights-bar-chart{width:100%;height:100%;min-height:300px;font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif}.loading-container{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;min-height:300px}.spinner{width:40px;height:40px;border:4px solid #f3f3f3;border-top:4px solid #3498db;border-radius:50%;animation:spin 1s linear infinite}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.loading-container p{margin-top:16px;color:#666}.error-container{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;min-height:300px;padding:20px}.error-message{color:#e74c3c;margin-bottom:16px;text-align:center}.error-container button{padding:8px 16px;background-color:#3498db;color:white;border:none;border-radius:4px;cursor:pointer;font-size:14px}.error-container button:hover{background-color:#2980b9}.chart-container{width:100%;height:100%;padding:20px}.no-data{display:flex;align-items:center;justify-content:center;height:100%;min-height:300px;color:#999}";
|
|
5
|
+
|
|
6
|
+
const InsightsBarChart$1 = /*@__PURE__*/ proxyCustomElement(class InsightsBarChart extends InsightsChartBase {
|
|
7
|
+
constructor(registerHost) {
|
|
8
|
+
super(false);
|
|
9
|
+
if (registerHost !== false) {
|
|
10
|
+
this.__registerHost();
|
|
11
|
+
}
|
|
12
|
+
this.__attachShadow();
|
|
13
|
+
}
|
|
14
|
+
get el() { return this; }
|
|
15
|
+
componentWillLoad() {
|
|
16
|
+
this.fetchChartData();
|
|
17
|
+
}
|
|
18
|
+
handlePropsChange() {
|
|
19
|
+
this.fetchChartData();
|
|
20
|
+
}
|
|
21
|
+
renderChart() {
|
|
22
|
+
if (!this.data || this.data.length === 0) {
|
|
23
|
+
return h("div", { class: "no-data" }, "No data available");
|
|
24
|
+
}
|
|
25
|
+
return (h("div", { class: "chart-container" }, h("apollo-data-bar-chart", { ref: el => {
|
|
26
|
+
if (el) {
|
|
27
|
+
el.adData = this.data;
|
|
28
|
+
el.adSpec = this.spec || {};
|
|
29
|
+
}
|
|
30
|
+
} })));
|
|
31
|
+
}
|
|
32
|
+
render() {
|
|
33
|
+
return (h("div", { key: 'cc42b49e957eba1e8cfef55ff2e4a212456489c6', class: "insights-bar-chart" }, this.loading && (h("div", { key: 'c82db2f39efa98f3429d21608afaced7623bac6a', class: "loading-container" }, h("div", { key: '05e31d66e3c0ee4f58bde4e4ddc16fcd969f3e80', class: "spinner" }), h("p", { key: 'e6626e2ae87ba94aed71d9610f5f54e8c1978899' }, "Loading chart data..."))), this.error && (h("div", { key: 'c77589a081583bfb82ac224c7969db69391a7a24', class: "error-container" }, h("p", { key: '53578a6f3344a29aa4f54f8a1b3f2f8a6bc8e32e', class: "error-message" }, this.error), h("button", { key: 'bf102ad25e23c2b894d1c0d49ac788f9c5979fac', onClick: () => this.fetchChartData() }, "Retry"))), !this.loading && !this.error && this.renderChart()));
|
|
34
|
+
}
|
|
35
|
+
static get watchers() { return {
|
|
36
|
+
"reportName": ["handlePropsChange"],
|
|
37
|
+
"filters": ["handlePropsChange"]
|
|
38
|
+
}; }
|
|
39
|
+
static get style() { return insightsBarChartCss; }
|
|
40
|
+
}, [769, "insights-bar-chart", {
|
|
41
|
+
"reportName": [1, "report-name"],
|
|
42
|
+
"filters": [16],
|
|
43
|
+
"getQueryByFilters": [16],
|
|
44
|
+
"normalizeRawResponse": [16],
|
|
45
|
+
"spec": [16],
|
|
46
|
+
"loading": [32],
|
|
47
|
+
"data": [32],
|
|
48
|
+
"error": [32]
|
|
49
|
+
}, undefined, {
|
|
50
|
+
"reportName": ["handlePropsChange"],
|
|
51
|
+
"filters": ["handlePropsChange"]
|
|
52
|
+
}]);
|
|
53
|
+
function defineCustomElement$1() {
|
|
54
|
+
if (typeof customElements === "undefined") {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const components = ["insights-bar-chart"];
|
|
58
|
+
components.forEach(tagName => { switch (tagName) {
|
|
59
|
+
case "insights-bar-chart":
|
|
60
|
+
if (!customElements.get(tagName)) {
|
|
61
|
+
customElements.define(tagName, InsightsBarChart$1);
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
} });
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const InsightsBarChart = InsightsBarChart$1;
|
|
68
|
+
const defineCustomElement = defineCustomElement$1;
|
|
69
|
+
|
|
70
|
+
export { InsightsBarChart, defineCustomElement };
|
|
71
|
+
//# sourceMappingURL=insights-bar-chart.js.map
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=insights-bar-chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"insights-bar-chart.js","mappings":";;;AAAA,MAAM,mBAAmB,GAAG,wpCAAwpC;;MCSvqCA,kBAAiB,iBAAAC,kBAAA,CAAA,MAAA,gBAAA,SAAQ,iBAAyC,CAAA;;;;;;;;;IAG7E,iBAAiB,GAAA;QACf,IAAI,CAAC,cAAc,EAAE;;IAKvB,iBAAiB,GAAA;QACf,IAAI,CAAC,cAAc,EAAE;;IAGf,WAAW,GAAA;AACjB,QAAA,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;AACxC,YAAA,OAAO,CAAK,CAAA,KAAA,EAAA,EAAA,KAAK,EAAC,SAAS,wBAAwB;;QAGrD,QACE,CAAA,CAAA,KAAA,EAAA,EAAK,KAAK,EAAC,iBAAiB,EAAA,EAC1B,CAAA,CAAA,uBAAA,EAAA,EACE,GAAG,EAAE,EAAE,IAAG;gBACR,IAAI,EAAE,EAAE;AACN,oBAAA,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI;oBACrB,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE;;AAE/B,aAAC,EAAA,CACD,CACE;;IAIV,MAAM,GAAA;AACJ,QAAA,QACE,CAAA,CAAA,KAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAK,KAAK,EAAC,oBAAoB,EAAA,EAC5B,IAAI,CAAC,OAAO,KACX,CAAK,CAAA,KAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,KAAK,EAAC,mBAAmB,EAAA,EAC5B,CAAK,CAAA,KAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,KAAK,EAAC,SAAS,EAAO,CAAA,EAC3B,CAAA,CAAA,GAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,EAAA,uBAAA,CAA4B,CACxB,CACP,EAEA,IAAI,CAAC,KAAK,KACT,CAAK,CAAA,KAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,KAAK,EAAC,iBAAiB,EAAA,EAC1B,CAAA,CAAA,GAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAG,KAAK,EAAC,eAAe,IAAE,IAAI,CAAC,KAAK,CAAK,EACzC,CAAQ,CAAA,QAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,OAAO,EAAE,MAAM,IAAI,CAAC,cAAc,EAAE,EAAgB,EAAA,OAAA,CAAA,CACxD,CACP,EAEA,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,WAAW,EAAE,CAC/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["InsightsBarChart","__stencil_proxyCustomElement"],"sources":["src/components/insights-bar-chart/insights-bar-chart.css?tag=insights-bar-chart&encapsulation=shadow","src/components/insights-bar-chart/insights-bar-chart.tsx"],"sourcesContent":[":host {\n display: block;\n}\n\n.insights-bar-chart {\n width: 100%;\n height: 100%;\n min-height: 300px;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n}\n\n.loading-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n height: 100%;\n min-height: 300px;\n}\n\n.spinner {\n width: 40px;\n height: 40px;\n border: 4px solid #f3f3f3;\n border-top: 4px solid #3498db;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n}\n\n@keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n\n.loading-container p {\n margin-top: 16px;\n color: #666;\n}\n\n.error-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n height: 100%;\n min-height: 300px;\n padding: 20px;\n}\n\n.error-message {\n color: #e74c3c;\n margin-bottom: 16px;\n text-align: center;\n}\n\n.error-container button {\n padding: 8px 16px;\n background-color: #3498db;\n color: white;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n}\n\n.error-container button:hover {\n background-color: #2980b9;\n}\n\n.chart-container {\n width: 100%;\n height: 100%;\n padding: 20px;\n}\n\n.no-data {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n min-height: 300px;\n color: #999;\n}\n","import { Component, h, Watch, Element } from '@stencil/core';\nimport type { BarDataItem, BarSpec } from '@xplortech/apollo-data/dist/types/components.d.ts';\nimport { InsightsChartBase } from '../insights-chart-base';\n\n@Component({\n tag: 'insights-bar-chart',\n styleUrl: 'insights-bar-chart.css',\n shadow: true,\n})\nexport class InsightsBarChart extends InsightsChartBase<BarDataItem[], BarSpec> {\n @Element() el: HTMLElement = null;\n\n componentWillLoad() {\n this.fetchChartData();\n }\n\n @Watch('reportName')\n @Watch('filters')\n handlePropsChange() {\n this.fetchChartData();\n }\n\n private renderChart() {\n if (!this.data || this.data.length === 0) {\n return <div class=\"no-data\">No data available</div>;\n }\n\n return (\n <div class=\"chart-container\">\n <apollo-data-bar-chart\n ref={el => {\n if (el) {\n el.adData = this.data;\n el.adSpec = this.spec || {};\n }\n }}\n />\n </div>\n );\n }\n\n render() {\n return (\n <div class=\"insights-bar-chart\">\n {this.loading && (\n <div class=\"loading-container\">\n <div class=\"spinner\"></div>\n <p>Loading chart data...</p>\n </div>\n )}\n\n {this.error && (\n <div class=\"error-container\">\n <p class=\"error-message\">{this.error}</p>\n <button onClick={() => this.fetchChartData()}>Retry</button>\n </div>\n )}\n\n {!this.loading && !this.error && this.renderChart()}\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface InsightsDonutChart extends Components.InsightsDonutChart, HTMLElement {}
|
|
4
|
+
export const InsightsDonutChart: {
|
|
5
|
+
prototype: InsightsDonutChart;
|
|
6
|
+
new (): InsightsDonutChart;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { p as proxyCustomElement, h } from './p-DFvs3VMW.js';
|
|
2
|
+
import { I as InsightsChartBase } from './p-Dv82-c17.js';
|
|
3
|
+
|
|
4
|
+
const insightsDonutChartCss = ":host{display:block}.insights-donut-chart{width:100%;height:100%;min-height:300px;font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif}.loading-container{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;min-height:300px}.spinner{width:40px;height:40px;border:4px solid #f3f3f3;border-top:4px solid #3498db;border-radius:50%;animation:spin 1s linear infinite}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.loading-container p{margin-top:16px;color:#666}.error-container{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;min-height:300px;padding:20px}.error-message{color:#e74c3c;margin-bottom:16px;text-align:center}.error-container button{padding:8px 16px;background-color:#3498db;color:white;border:none;border-radius:4px;cursor:pointer;font-size:14px}.error-container button:hover{background-color:#2980b9}.chart-container{width:100%;height:100%;padding:20px}.no-data{display:flex;align-items:center;justify-content:center;height:100%;min-height:300px;color:#999}";
|
|
5
|
+
|
|
6
|
+
const InsightsDonutChart$1 = /*@__PURE__*/ proxyCustomElement(class InsightsDonutChart extends InsightsChartBase {
|
|
7
|
+
constructor(registerHost) {
|
|
8
|
+
super(false);
|
|
9
|
+
if (registerHost !== false) {
|
|
10
|
+
this.__registerHost();
|
|
11
|
+
}
|
|
12
|
+
this.__attachShadow();
|
|
13
|
+
}
|
|
14
|
+
get el() { return this; }
|
|
15
|
+
componentWillLoad() {
|
|
16
|
+
this.fetchChartData();
|
|
17
|
+
}
|
|
18
|
+
handlePropsChange() {
|
|
19
|
+
this.fetchChartData();
|
|
20
|
+
}
|
|
21
|
+
renderChart() {
|
|
22
|
+
if (!this.data || this.data.length === 0) {
|
|
23
|
+
return h("div", { class: "no-data" }, "No data available");
|
|
24
|
+
}
|
|
25
|
+
return (h("div", { class: "chart-container" }, h("apollo-data-donut-chart", { ref: el => {
|
|
26
|
+
if (el) {
|
|
27
|
+
el.adData = this.data;
|
|
28
|
+
el.adSpec = this.spec || {};
|
|
29
|
+
}
|
|
30
|
+
} })));
|
|
31
|
+
}
|
|
32
|
+
render() {
|
|
33
|
+
return (h("div", { key: 'b459affa996f96b3d3c6d3be1b434bfd3bf9a434', class: "insights-donut-chart" }, this.loading && (h("div", { key: 'd657d9c5561521a87e9c89e53604f2f29d4ee672', class: "loading-container" }, h("div", { key: '4bba1ebc4c1ff611c156c89ca172f8a5962c22df', class: "spinner" }), h("p", { key: 'c769618075a47539d7e00c0d88951e9ec230211b' }, "Loading chart data..."))), this.error && (h("div", { key: '4d7222db52e39e475e865d5dd82f800d87f80f6c', class: "error-container" }, h("p", { key: 'a56ae48922b31cd0fe23b682580e05eafd052288', class: "error-message" }, this.error), h("button", { key: '0cd6d156f31fcddc624b1332d012a59f7f265092', onClick: () => this.fetchChartData() }, "Retry"))), !this.loading && !this.error && this.renderChart()));
|
|
34
|
+
}
|
|
35
|
+
static get watchers() { return {
|
|
36
|
+
"reportName": ["handlePropsChange"],
|
|
37
|
+
"filters": ["handlePropsChange"]
|
|
38
|
+
}; }
|
|
39
|
+
static get style() { return insightsDonutChartCss; }
|
|
40
|
+
}, [769, "insights-donut-chart", {
|
|
41
|
+
"reportName": [1, "report-name"],
|
|
42
|
+
"filters": [16],
|
|
43
|
+
"getQueryByFilters": [16],
|
|
44
|
+
"normalizeRawResponse": [16],
|
|
45
|
+
"spec": [16],
|
|
46
|
+
"loading": [32],
|
|
47
|
+
"data": [32],
|
|
48
|
+
"error": [32]
|
|
49
|
+
}, undefined, {
|
|
50
|
+
"reportName": ["handlePropsChange"],
|
|
51
|
+
"filters": ["handlePropsChange"]
|
|
52
|
+
}]);
|
|
53
|
+
function defineCustomElement$1() {
|
|
54
|
+
if (typeof customElements === "undefined") {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const components = ["insights-donut-chart"];
|
|
58
|
+
components.forEach(tagName => { switch (tagName) {
|
|
59
|
+
case "insights-donut-chart":
|
|
60
|
+
if (!customElements.get(tagName)) {
|
|
61
|
+
customElements.define(tagName, InsightsDonutChart$1);
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
} });
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const InsightsDonutChart = InsightsDonutChart$1;
|
|
68
|
+
const defineCustomElement = defineCustomElement$1;
|
|
69
|
+
|
|
70
|
+
export { InsightsDonutChart, defineCustomElement };
|
|
71
|
+
//# sourceMappingURL=insights-donut-chart.js.map
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=insights-donut-chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"insights-donut-chart.js","mappings":";;;AAAA,MAAM,qBAAqB,GAAG,0pCAA0pC;;M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A,EAAA,GAAA,EAAA,0CAAA,EAAG,KAAK,EAAC,eAAe,IAAE,IAAI,CAAC,KAAK,CAAK,EACzC,CAAQ,CAAA,QAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,OAAO,EAAE,MAAM,IAAI,CAAC,cAAc,EAAE,EAAgB,EAAA,OAAA,CAAA,CACxD,CACP,EAEA,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,WAAW,EAAE,CAC/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["InsightsDonutChart","__stencil_proxyCustomElement"],"sources":["src/components/insights-donut-chart/insights-donut-chart.css?tag=insights-donut-chart&encapsulation=shadow","src/components/insights-donut-chart/insights-donut-chart.tsx"],"sourcesContent":[":host {\n display: block;\n}\n\n.insights-donut-chart {\n width: 100%;\n height: 100%;\n min-height: 300px;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n}\n\n.loading-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n height: 100%;\n min-height: 300px;\n}\n\n.spinner {\n width: 40px;\n height: 40px;\n border: 4px solid #f3f3f3;\n border-top: 4px solid #3498db;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n}\n\n@keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n\n.loading-container p {\n margin-top: 16px;\n color: #666;\n}\n\n.error-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n height: 100%;\n min-height: 300px;\n padding: 20px;\n}\n\n.error-message {\n color: #e74c3c;\n margin-bottom: 16px;\n text-align: center;\n}\n\n.error-container button {\n padding: 8px 16px;\n background-color: #3498db;\n color: white;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n}\n\n.error-container button:hover {\n background-color: #2980b9;\n}\n\n.chart-container {\n width: 100%;\n height: 100%;\n padding: 20px;\n}\n\n.no-data {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n min-height: 300px;\n color: #999;\n}\n","import { Component, h, Watch, Element } from '@stencil/core';\nimport type { DonutDataItem, DonutSpec } from '@xplortech/apollo-data/dist/types/components.d.ts';\nimport { InsightsChartBase } from '../insights-chart-base';\n\n@Component({\n tag: 'insights-donut-chart',\n styleUrl: 'insights-donut-chart.css',\n shadow: true,\n})\nexport class InsightsDonutChart extends InsightsChartBase<DonutDataItem[], DonutSpec> {\n @Element() el: HTMLElement = null;\n\n componentWillLoad() {\n this.fetchChartData();\n }\n\n @Watch('reportName')\n @Watch('filters')\n handlePropsChange() {\n this.fetchChartData();\n }\n\n private renderChart() {\n if (!this.data || this.data.length === 0) {\n return <div class=\"no-data\">No data available</div>;\n }\n\n return (\n <div class=\"chart-container\">\n <apollo-data-donut-chart\n ref={el => {\n if (el) {\n el.adData = this.data;\n el.adSpec = this.spec || {};\n }\n }}\n />\n </div>\n );\n }\n\n render() {\n return (\n <div class=\"insights-donut-chart\">\n {this.loading && (\n <div class=\"loading-container\">\n <div class=\"spinner\"></div>\n <p>Loading chart data...</p>\n </div>\n )}\n\n {this.error && (\n <div class=\"error-container\">\n <p class=\"error-message\">{this.error}</p>\n <button onClick={() => this.fetchChartData()}>Retry</button>\n </div>\n )}\n\n {!this.loading && !this.error && this.renderChart()}\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface InsightsWrapper extends Components.InsightsWrapper, HTMLElement {}
|
|
4
|
+
export const InsightsWrapper: {
|
|
5
|
+
prototype: InsightsWrapper;
|
|
6
|
+
new (): InsightsWrapper;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|