@sisense/sdk-ui 1.23.0 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai.cjs +29 -29
- package/dist/ai.js +332 -325
- package/dist/analytics-composer.cjs +1 -1
- package/dist/analytics-composer.js +3 -3
- package/dist/index.cjs +119 -118
- package/dist/index.js +6943 -7725
- package/dist/packages/sdk-ui/src/ai/chart/chart-insights.d.ts +2 -1
- package/dist/packages/sdk-ui/src/ai/chart/nlq-chart-widget.d.ts +7 -2
- package/dist/packages/sdk-ui/src/ai/icons/exclamation-mark-brand-icon.d.ts +3 -0
- package/dist/packages/sdk-ui/src/analytics-composer/common/utils.d.ts +2 -0
- package/dist/packages/sdk-ui/src/analytics-composer/types.d.ts +5 -1
- package/dist/packages/sdk-ui/src/analytics-composer/widget/to-widget-code.d.ts +2 -2
- package/dist/packages/sdk-ui/src/analytics-composer/widget/widget-composer.d.ts +1 -0
- package/dist/packages/sdk-ui/src/api/rest-api.d.ts +12 -1
- package/dist/packages/sdk-ui/src/chart/advanced-chart.d.ts +1 -1
- package/dist/packages/sdk-ui/src/chart/regular-chart.d.ts +3 -0
- package/dist/packages/sdk-ui/src/chart-options-processor/category-chart-options.d.ts +2 -1
- package/dist/packages/sdk-ui/src/chart-options-processor/translations/sunburst/sunburst-options.d.ts +2 -1
- package/dist/packages/sdk-ui/src/chart-options-processor/translations/treemap/treemap-options.d.ts +2 -1
- package/dist/packages/sdk-ui/src/chart-options-processor/translations/treemap/treemap-tooltip.d.ts +3 -2
- package/dist/packages/sdk-ui/src/chart-options-processor/translations/types.d.ts +2 -0
- package/dist/packages/sdk-ui/src/dashboard/components/dashboard-container.d.ts +1 -1
- package/dist/packages/sdk-ui/src/dashboard/components/horizontal-collapse.d.ts +6 -0
- package/dist/packages/sdk-ui/src/dashboard/dashboard.d.ts +6 -1
- package/dist/packages/sdk-ui/src/dashboard/hooks/use-filters-panel-collapsed-state.d.ts +8 -0
- package/dist/packages/sdk-ui/src/dashboard/types.d.ts +19 -1
- package/dist/packages/sdk-ui/src/decorators/component-decorators/with-error-boundary.d.ts +3 -1
- package/dist/packages/sdk-ui/src/error-boundary/error-boundary.d.ts +4 -2
- package/dist/packages/sdk-ui/src/filters/components/cascading-filter-tile/cascading-filter-tile.d.ts +2 -0
- package/dist/packages/sdk-ui/src/filters/components/criteria-filter-tile/criteria-filter-tile.d.ts +2 -0
- package/dist/packages/sdk-ui/src/filters/components/custom-filter-tile.d.ts +2 -0
- package/dist/packages/sdk-ui/src/filters/components/date-filter/date-range-filter-tile/date-range-filter-tile.d.ts +2 -0
- package/dist/packages/sdk-ui/src/filters/components/date-filter/relative-date-filter-tile/helpers.d.ts +6 -0
- package/dist/packages/sdk-ui/src/filters/components/date-filter/relative-date-filter-tile/relative-date-filter-tile.d.ts +2 -0
- package/dist/packages/sdk-ui/src/filters/components/date-filter/relative-date-filter-tile/relative-date-filter.d.ts +2 -1
- package/dist/packages/sdk-ui/src/filters/components/filter-tile.d.ts +1 -0
- package/dist/packages/sdk-ui/src/filters/components/filters-panel/filters-panel-tile.d.ts +3 -1
- package/dist/packages/sdk-ui/src/filters/components/icons/trash-icon.d.ts +1 -1
- package/dist/packages/sdk-ui/src/filters/components/member-filter-tile/member-filter-tile.d.ts +2 -0
- package/dist/packages/sdk-ui/src/filters/components/unsupported-filter-tile.d.ts +3 -1
- package/dist/packages/sdk-ui/src/index.d.ts +3 -1
- package/dist/packages/sdk-ui/src/models/dashboard/use-dashboard-model/use-dasboard-model-utils.d.ts +2 -4
- package/dist/packages/sdk-ui/src/models/dashboard/use-dashboard-model/use-dashboard-model-reducer.d.ts +24 -16
- package/dist/packages/sdk-ui/src/models/dashboard/use-dashboard-model/use-dashboard-model.d.ts +1 -0
- package/dist/packages/sdk-ui/src/models/hierarchy/get-hierarchy-models.d.ts +6 -1
- package/dist/packages/sdk-ui/src/models/hierarchy/types.d.ts +3 -0
- package/dist/packages/sdk-ui/src/models/hierarchy/use-get-hierarchy-models.d.ts +4 -4
- package/dist/packages/sdk-ui/src/models/widget/widget-model-translator.d.ts +11 -1
- package/dist/packages/sdk-ui/src/pivot-table/hooks/use-render-pivot.d.ts +3 -1
- package/dist/packages/sdk-ui/src/props.d.ts +11 -3
- package/dist/packages/sdk-ui/src/sisense-context/sisense-context.d.ts +2 -0
- package/dist/packages/sdk-ui/src/table/table-component.d.ts +1 -1
- package/dist/packages/sdk-ui/src/translation/resources/en.d.ts +10 -0
- package/dist/packages/sdk-ui/src/translation/resources/index.d.ts +20 -0
- package/dist/packages/sdk-ui/src/widget-by-id/translate-widget-data-options.d.ts +2 -2
- package/dist/packages/sdk-ui/src/widget-by-id/utils.d.ts +9 -0
- package/dist/packages/sdk-ui/src/widgets/common/widget-container.d.ts +2 -0
- package/dist/packages/sdk-ui/src/widgets/common/widget-errors-and-warnings-context.d.ts +14 -0
- package/dist/packages/sdk-ui/src/widgets/common/widget-header-info-button.d.ts +3 -1
- package/dist/packages/sdk-ui/src/widgets/common/widget-header.d.ts +2 -0
- package/dist/useQuery-CIeSzN0Z.js +7945 -0
- package/dist/useQuery-LqaaNBLw.cjs +175 -0
- package/dist/widget-composer-CvgsMHyb.cjs +237 -0
- package/dist/widget-composer-L8kmRhgX.js +624 -0
- package/dist/widget-model-translator-CYeCKnTa.js +116687 -0
- package/dist/widget-model-translator-_Z-8UaTN.cjs +917 -0
- package/package.json +7 -7
- package/dist/derive-chart-family-CTpRObm1.js +0 -44117
- package/dist/derive-chart-family-DcALKnKU.cjs +0 -271
- package/dist/packages/sdk-ui/src/dashboard/components/HorizontalCollapse.d.ts +0 -5
- package/dist/useQuery-1xZMqnAI.js +0 -79308
- package/dist/useQuery-D9rZ58KS.cjs +0 -821
- package/dist/widget-composer-B17DVa2A.cjs +0 -101
- package/dist/widget-composer-DqjH_6dw.js +0 -448
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";var P=Object.defineProperty;var C=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var E=(e,t,r)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,m=(e,t)=>{for(var r in t||(t={}))I.call(t,r)&&E(e,r,t[r]);if(C)for(var r of C(t))L.call(t,r)&&E(e,r,t[r]);return e};const o=require("./derive-chart-family-DcALKnKU.cjs");class j extends o.DimensionalElement{constructor(t,r){var a;super((a=t.jaql.title)!==null&&a!==void 0?a:"",r),this.expression=t.jaql.dim||t.jaql.formula,this.metadataItem=t,t.jaql.agg?this.aggregation=t.jaql.agg:delete this.aggregation,t.jaql.formula?this.formula=t.jaql.formula:delete this.formula,t.jaql.sort?this.sortType=o.getSortType(t.jaql.sort):delete this.sortType,this.skipValidation=!0}get id(){return this.expression}jaql(){return this.metadataItem}}const N={text:o.MetadataTypes.TextAttribute,numeric:o.MetadataTypes.NumericAttribute,datetime:o.MetadataTypes.DateLevel};function M(e){var t;return new j(e,(t=N[e.jaql.datatype])!==null&&t!==void 0?t:"numeric")}const B={jaql:{datasource:{title:""},metadata:[]},queryTitle:"",chartRecommendations:{}},v={model:"",metadata:[],chart:{},queryTitle:""},z=e=>"widgetProps"in e,w=e=>"dashboardOid"in e&&"widgetOid"in e;function U(e){return e.replace(/\s+/g,"-").replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function Y(e){return e.charAt(0).toUpperCase()+e.slice(1)}function k(e){const t=/\[(.+?)\s\(Calendar\)\]/;return e.replace(t,"[$1]").trim()}function Q(e){if(e)if(e.metadata){if(!e.model)throw new o.TranslatableError("errors.missingModelTitle")}else throw new o.TranslatableError("errors.missingMetadata");else throw new o.TranslatableError("errors.emptyModel");return e}function J(e){return!e||!e.jaql.datasource.title||!e.jaql.metadata.length}function f(e){return e&&e.replace(new RegExp("(?<!\\\\)'","g"),"\\'")}const R={react:{baseChartTmpl:`import { {{componentString}} } from '@sisense/sdk-ui';
|
|
2
|
-
{{extraImportsString}}
|
|
3
|
-
import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
|
|
4
|
-
|
|
5
|
-
export default function CodeExample() {
|
|
6
|
-
return (
|
|
7
|
-
<{{componentString}}
|
|
8
|
-
title={'{{titleString}}'}
|
|
9
|
-
dataSource={DM.DataSource}
|
|
10
|
-
chartType={'{{chartTypeString}}'}
|
|
11
|
-
dataOptions={ {{dataOptionsString}} }
|
|
12
|
-
filters={ {{filtersString}} }
|
|
13
|
-
/>
|
|
14
|
-
);
|
|
15
|
-
}`,chartTmpl:"{{baseChartTmpl}}",chartWidgetTmpl:"{{baseChartTmpl}}",widgetByIdTmpl:`import { WidgetById } from '@sisense/sdk-ui';
|
|
16
|
-
|
|
17
|
-
const CodeExample = () => {
|
|
18
|
-
return (
|
|
19
|
-
<>
|
|
20
|
-
<WidgetById
|
|
21
|
-
widgetOid="{{widgetOid}}"
|
|
22
|
-
dashboardOid="{{dashboardOid}}"
|
|
23
|
-
includeDashboardFilters={true}
|
|
24
|
-
/>
|
|
25
|
-
</>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default CodeExample;
|
|
30
|
-
`},angular:{baseChartTmpl:`import { Component } from '@angular/core';
|
|
31
|
-
{{extraImportsString}}
|
|
32
|
-
import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
|
|
33
|
-
|
|
34
|
-
@Component({
|
|
35
|
-
selector: 'code-example',
|
|
36
|
-
template: \`
|
|
37
|
-
<csdk-chart-widget
|
|
38
|
-
chartType='{{chartTypeString}}'
|
|
39
|
-
[dataSource]='DM.DataSource'
|
|
40
|
-
[dataOptions]='dataOptions'
|
|
41
|
-
[filters]='filters'
|
|
42
|
-
/>
|
|
43
|
-
\`
|
|
44
|
-
})
|
|
45
|
-
export class CodeExample {
|
|
46
|
-
DM = DM;
|
|
47
|
-
dataOptions = {{dataOptionsString}};
|
|
48
|
-
filters = {{filtersString}};
|
|
49
|
-
}`,chartTmpl:"{{baseChartTmpl}}",chartWidgetTmpl:"{{baseChartTmpl}}",widgetByIdTmpl:`import { Component } from '@angular/core';
|
|
50
|
-
|
|
51
|
-
@Component({
|
|
52
|
-
selector: 'code-example',
|
|
53
|
-
template: \`
|
|
54
|
-
<csdk-widget-by-id
|
|
55
|
-
[widgetOid]="widgetOid"
|
|
56
|
-
[dashboardOid]="dashboardOid"
|
|
57
|
-
[includeDashboardFilters]="includeDashboardFilters"
|
|
58
|
-
/>
|
|
59
|
-
\`,
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
export class CodeExample {
|
|
63
|
-
widgetOid = "{{widgetOid}}";
|
|
64
|
-
dashboardOid = "{{dashboardOid}}";
|
|
65
|
-
includeDashboardFilters = true;
|
|
66
|
-
}`},vue:{baseChartTmpl:`<script setup lang="ts">
|
|
67
|
-
import { ref } from 'vue';
|
|
68
|
-
import { {{componentString}} } from '@sisense/sdk-ui-vue';
|
|
69
|
-
{{extraImportsString}}
|
|
70
|
-
import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
|
|
71
|
-
|
|
72
|
-
const dataOptions = ref({{dataOptionsString}});
|
|
73
|
-
const filters = ref({{filtersString}});
|
|
74
|
-
<\/script>
|
|
75
|
-
|
|
76
|
-
<template>
|
|
77
|
-
<{{componentString}}
|
|
78
|
-
chartType="{{chartTypeString}}"
|
|
79
|
-
:dataOptions="dataOptions"
|
|
80
|
-
:filters="filters"
|
|
81
|
-
:dataSource="DM.DataSource"
|
|
82
|
-
title="{{titleString}}" />
|
|
83
|
-
</template>`,chartTmpl:"{{baseChartTmpl}}",chartWidgetTmpl:"{{baseChartTmpl}}",widgetByIdTmpl:`<script setup lang="ts">
|
|
84
|
-
import { WidgetById } from '@sisense/sdk-ui-vue';
|
|
85
|
-
<\/script>
|
|
86
|
-
<template>
|
|
87
|
-
<WidgetById
|
|
88
|
-
:widgetOid="{{widgetOid}}"
|
|
89
|
-
:dashboardOid="{{dashboardOid}}"
|
|
90
|
-
/>
|
|
91
|
-
</template>
|
|
92
|
-
`}},F=(e,t)=>R[t][e].replace(/{{(.*?)Tmpl}}/g,(a,n)=>F(`${n}Tmpl`,t)),q=(e,t)=>e.replace(/{{(.*?)}}/g,(r,a)=>a in t?t[a]:(console.warn(`Placeholder ${a} not found in data`),r)),A=(e,t,r="react")=>{const a=F(e,r);return q(a,t)},g=`
|
|
93
|
-
`,S="UNKNOWN",K=(e,t)=>{let r="";return r+=`measureFactory.customFormula(
|
|
94
|
-
`,r+=" ".repeat(t),r+=` '${f(e.title)}',
|
|
95
|
-
`,r+=" ".repeat(t),r+=` '${e.formula}',
|
|
96
|
-
`,r+=" ".repeat(t),r+=` {
|
|
97
|
-
`,Object.entries(e.context).forEach(([a,n])=>{const i=o.normalizeAttributeName(n.table||S,n.column||S,void 0,"DM");r+=" ".repeat(t),r+=` '${a.slice(1,-1)}': ${i},
|
|
98
|
-
`}),r+=" ".repeat(t),r+=` }
|
|
99
|
-
`,r+=" ".repeat(t),r+=")",r},V=(e,t)=>{const{level:r,table:a,column:n,agg:i,sort:s,title:c}=e;let l;return a&&n&&(l=o.normalizeAttributeName(a,n,r,"DM")),i&&a&&n&&c&&(l=`measureFactory.${o.DimensionalBaseMeasure.aggregationFromJAQL(i)}(${l}, '${f(c)}')`),s&&(l=`{column: ${l}, sortType: '${o.getSortType(s)}'}`),l?`${" ".repeat(t)}${l}`:S},X=(e,t)=>{const r=e.jaql().jaql;return"formula"in r?K(r,t):g+V(r,t)},h=(e,t=0,r=!1)=>{if(!e)return"";if(typeof e=="string")return`'${f(e)}'`;if(e instanceof j)return X(e,t);let a="";return Array.isArray(e)?a+=`[${e.map(n=>h(n,t+2))}${e.length?g+" ".repeat(t+2):""}]`:(a+=`{${g}`,Object.entries(e).forEach(([n,i])=>{r&&(n=`'${f(n)}'`),a+=" ".repeat(t+2),Array.isArray(i)?a+=`${n}: [${i.map(s=>h(s,t+4,r))}${i.length?g+" ".repeat(t+2):""}]`:typeof i=="object"?a+=`${n}: ${h(i,t+2,r)}`:["number","boolean","undefined",null].includes(typeof i)?a+=`${n}: ${i}`:a+=`${n}: '${f(i)}'`,a+=`,${g}`}),a+=" ".repeat(t),a+="}"),a},$=`
|
|
100
|
-
`,Z=(e,t)=>{if(e.composeCode)return`${$}${" ".repeat(t)}${e.composeCode}`;const r=e.jaql().jaql;return`${$}${" ".repeat(t)}filterFactory.customFilter(${h(r,t,!0)})`},G=(e,t=0)=>{if(!e)return"";let r="";return r+=`[${e.map(a=>Z(a,t+2))}${e.length?`
|
|
101
|
-
`+" ".repeat(t+2):""}]`,r},H=e=>{if(!e)return"";if(Array.isArray(e))return G(e,2);throw new o.TranslatableError("errors.filterRelationsNotSupported")},ee=e=>{if(!e)throw new o.TranslatableError("errors.undefinedDataSource");let t;return typeof e=="object"&&"title"in e?t=e.title:t=e,U(t)},te=e=>e,re=e=>h(e,2),ae=e=>{const t=["measureFactory"],{filters:r}=e;return Array.isArray(r)&&r.length>0&&t.push("filterFactory"),`import { ${t.join(", ")} } from '@sisense/sdk-data';`},ie=(e,t)=>{const r={titleString:e.title,dataSourceString:ee(e.dataSource),chartTypeString:te(e.chartType),dataOptionsString:re(e.dataOptions),filtersString:H(e.filters),componentString:"ChartWidget",extraImportsString:ae(e)};return A("chartWidgetTmpl",r,t)},ne=({dashboardOid:e,widgetOid:t,uiFramework:r="react"})=>A("widgetByIdTmpl",{dashboardOid:e,widgetOid:t},r),se=({widgetProps:e,uiFramework:t="react"})=>{if(o.isChartWidgetProps(e))return ie(e,t);throw new o.TranslatableError("errors.otherWidgetTypesNotSupported")},oe=e=>({dataOptions:{columns:e.map(M)}}),le=Object.freeze({convolution:{enabled:!0,selectedConvolutionType:"bySlicesCount",independentSlicesCount:7},lineWidth:{width:"bold"},markers:{enabled:!1},legend:{enabled:!1},yAxis:{gridLines:!1},xAxis:{gridLines:!1}}),D=Object.freeze({line:"line/spline",pie:"pie/donut",bar:"bar/stacked",column:"column/stackedcolumn"}),ce=(e,t)=>{const{axesMapping:r={},chartFamily:a}=t,n=e.reduce((s,c)=>(s[c.jaql.title]=c,s),{}),i=Object.entries(r).reduce((s,c)=>{const[l,u]=c;return s[`${l}`]=Array.isArray(u)?u.map(y=>{var T,b;const d=n[y.name];if(!d)return{column:{type:"",name:y.name}};const p=M(d);if(d.panel==="measures")return{column:p,sortType:"sortNone"};if(o.isDatetime(p.type)){const O=(b=(T=d.format)==null?void 0:T.mask)==null?void 0:b[d.jaql.level];if(O)return{column:p,dateFormat:O}}return p}):u,s},{});switch(a){case"cartesian":return m({category:[],value:[],breakBy:[]},i);case"categorical":return m({category:[],value:[]},i);case"scatter":return Object.keys(i).forEach(s=>{i[`${s}`]=i[`${s}`][0]}),i;case"scattermap":return Object.keys(i).forEach(s=>{s!=="geo"&&(i[`${s}`]=i[`${s}`][0])}),i;case"table":return Object.keys(i).length===0?oe(e).dataOptions:i;case"boxplot":case"areamap":case"indicator":default:return i}},x=(e,t)=>{var r,a,n,i;return t==="x"?(a=(r=e.axesMapping.category)!=null?r:e.axesMapping.x)==null?void 0:a.map(s=>s.name).join(", "):(i=(n=e.axesMapping.value)!=null?n:e.axesMapping.y)==null?void 0:i.map(s=>s.name).join(", ")},de=(e,t,r=!0)=>{const a=ce(e,t);let n;return r&&t.chartType in D?n=o.merge(o.merge(le,{subtype:D[t.chartType]}),{legend:{enabled:!0,position:"right"},yAxis:{title:{enabled:!0,text:x(t,"y")}},xAxis:{title:{enabled:!0,text:x(t,"x")}}}):n=o.getDefaultStyleOptions(),{dataOptions:a,chartStyleOptions:n}},pe=e=>"chartType"in e?e:{chartType:"table",chartFamily:"table",axesMapping:{}},ue=e=>e.map(t=>o.createFilterFromJaql(t.jaql)),me=e=>e.reduce((t,r)=>{if((r.panel==="scope"||r.jaql.filter)&&t.metadataFilters.push(o.cloneDeep(r)),r.panel!=="scope"){const a=o.cloneDeep(r);delete a.jaql.filter,t.metadataColumns.push(a)}return t},{metadataColumns:[],metadataFilters:[]}),ge=(e,t)=>{if(!J(e))try{const{useCustomizedStyleOptions:r=!1}=t||{},{jaql:a,chartRecommendations:n,queryTitle:i}=e,{metadata:s,datasource:{title:c}}=a,l=pe(n),u=l.chartType.toLowerCase(),y={cornerRadius:"Small",header:{renderToolbar:()=>null}},{metadataColumns:d,metadataFilters:p}=me(s),T=ue(p),{dataOptions:b,chartStyleOptions:O}=de(d,l,r),_=m(m({},O),y);return{widgetType:"chart",id:i,title:i,chartType:u,dataSource:c,dataOptions:b,filters:T,styleOptions:_}}catch(r){console.error(r);return}},W=(e,t)=>ge(e,t),fe=e=>w(e)?ne(e):se(e),he=Object.freeze(Object.defineProperty({__proto__:null,toWidgetCode:fe,toWidgetProps:W},Symbol.toStringTag,{value:"Module"}));exports.EMPTY_EXPANDED_QUERY_MODEL=B;exports.EMPTY_SIMPLE_QUERY_MODEL=v;exports.capitalizeFirstLetter=Y;exports.isByIdWidgetCodeParams=w;exports.isClientSideWidgetCodeParams=z;exports.populatePlaceholders=q;exports.sanitizeDimensionId=k;exports.toWidgetProps=W;exports.validateQueryModel=Q;exports.widgetComposer=he;
|
|
@@ -1,448 +0,0 @@
|
|
|
1
|
-
var L = Object.defineProperty;
|
|
2
|
-
var $ = Object.getOwnPropertySymbols;
|
|
3
|
-
var P = Object.prototype.hasOwnProperty, B = Object.prototype.propertyIsEnumerable;
|
|
4
|
-
var x = (t, e, r) => e in t ? L(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, m = (t, e) => {
|
|
5
|
-
for (var r in e || (e = {}))
|
|
6
|
-
P.call(e, r) && x(t, r, e[r]);
|
|
7
|
-
if ($)
|
|
8
|
-
for (var r of $(e))
|
|
9
|
-
B.call(e, r) && x(t, r, e[r]);
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { cU as v, h as F, M as S, T as p, cV as q, $ as U, a4 as k, m as j, cW as z, z as Y, F as J, aY as D } from "./derive-chart-family-CTpRObm1.js";
|
|
13
|
-
class A extends v {
|
|
14
|
-
constructor(e, r) {
|
|
15
|
-
var a;
|
|
16
|
-
super((a = e.jaql.title) !== null && a !== void 0 ? a : "", r), this.expression = e.jaql.dim || e.jaql.formula, this.metadataItem = e, e.jaql.agg ? this.aggregation = e.jaql.agg : delete this.aggregation, e.jaql.formula ? this.formula = e.jaql.formula : delete this.formula, e.jaql.sort ? this.sortType = F(e.jaql.sort) : delete this.sortType, this.skipValidation = !0;
|
|
17
|
-
}
|
|
18
|
-
get id() {
|
|
19
|
-
return this.expression;
|
|
20
|
-
}
|
|
21
|
-
jaql() {
|
|
22
|
-
return this.metadataItem;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
const Q = {
|
|
26
|
-
text: S.TextAttribute,
|
|
27
|
-
numeric: S.NumericAttribute,
|
|
28
|
-
datetime: S.DateLevel
|
|
29
|
-
};
|
|
30
|
-
function W(t) {
|
|
31
|
-
var e;
|
|
32
|
-
return new A(t, (e = Q[t.jaql.datatype]) !== null && e !== void 0 ? e : "numeric");
|
|
33
|
-
}
|
|
34
|
-
const $t = {
|
|
35
|
-
jaql: { datasource: { title: "" }, metadata: [] },
|
|
36
|
-
queryTitle: "",
|
|
37
|
-
chartRecommendations: {}
|
|
38
|
-
}, xt = {
|
|
39
|
-
model: "",
|
|
40
|
-
metadata: [],
|
|
41
|
-
chart: {},
|
|
42
|
-
queryTitle: ""
|
|
43
|
-
}, jt = (t) => "widgetProps" in t, K = (t) => "dashboardOid" in t && "widgetOid" in t;
|
|
44
|
-
function R(t) {
|
|
45
|
-
return t.replace(/\s+/g, "-").replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
46
|
-
}
|
|
47
|
-
function Dt(t) {
|
|
48
|
-
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
49
|
-
}
|
|
50
|
-
function Et(t) {
|
|
51
|
-
const e = /\[(.+?)\s\(Calendar\)\]/;
|
|
52
|
-
return t.replace(e, "[$1]").trim();
|
|
53
|
-
}
|
|
54
|
-
function wt(t) {
|
|
55
|
-
if (t)
|
|
56
|
-
if (t.metadata) {
|
|
57
|
-
if (!t.model)
|
|
58
|
-
throw new p("errors.missingModelTitle");
|
|
59
|
-
} else
|
|
60
|
-
throw new p("errors.missingMetadata");
|
|
61
|
-
else
|
|
62
|
-
throw new p("errors.emptyModel");
|
|
63
|
-
return t;
|
|
64
|
-
}
|
|
65
|
-
function V(t) {
|
|
66
|
-
return !t || !t.jaql.datasource.title || !t.jaql.metadata.length;
|
|
67
|
-
}
|
|
68
|
-
function f(t) {
|
|
69
|
-
return t && t.replace(new RegExp("(?<!\\\\)'", "g"), "\\'");
|
|
70
|
-
}
|
|
71
|
-
const X = {
|
|
72
|
-
react: {
|
|
73
|
-
baseChartTmpl: `import { {{componentString}} } from '@sisense/sdk-ui';
|
|
74
|
-
{{extraImportsString}}
|
|
75
|
-
import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
|
|
76
|
-
|
|
77
|
-
export default function CodeExample() {
|
|
78
|
-
return (
|
|
79
|
-
<{{componentString}}
|
|
80
|
-
title={'{{titleString}}'}
|
|
81
|
-
dataSource={DM.DataSource}
|
|
82
|
-
chartType={'{{chartTypeString}}'}
|
|
83
|
-
dataOptions={ {{dataOptionsString}} }
|
|
84
|
-
filters={ {{filtersString}} }
|
|
85
|
-
/>
|
|
86
|
-
);
|
|
87
|
-
}`,
|
|
88
|
-
chartTmpl: "{{baseChartTmpl}}",
|
|
89
|
-
chartWidgetTmpl: "{{baseChartTmpl}}",
|
|
90
|
-
widgetByIdTmpl: `import { WidgetById } from '@sisense/sdk-ui';
|
|
91
|
-
|
|
92
|
-
const CodeExample = () => {
|
|
93
|
-
return (
|
|
94
|
-
<>
|
|
95
|
-
<WidgetById
|
|
96
|
-
widgetOid="{{widgetOid}}"
|
|
97
|
-
dashboardOid="{{dashboardOid}}"
|
|
98
|
-
includeDashboardFilters={true}
|
|
99
|
-
/>
|
|
100
|
-
</>
|
|
101
|
-
);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export default CodeExample;
|
|
105
|
-
`
|
|
106
|
-
},
|
|
107
|
-
angular: {
|
|
108
|
-
baseChartTmpl: `import { Component } from '@angular/core';
|
|
109
|
-
{{extraImportsString}}
|
|
110
|
-
import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
|
|
111
|
-
|
|
112
|
-
@Component({
|
|
113
|
-
selector: 'code-example',
|
|
114
|
-
template: \`
|
|
115
|
-
<csdk-chart-widget
|
|
116
|
-
chartType='{{chartTypeString}}'
|
|
117
|
-
[dataSource]='DM.DataSource'
|
|
118
|
-
[dataOptions]='dataOptions'
|
|
119
|
-
[filters]='filters'
|
|
120
|
-
/>
|
|
121
|
-
\`
|
|
122
|
-
})
|
|
123
|
-
export class CodeExample {
|
|
124
|
-
DM = DM;
|
|
125
|
-
dataOptions = {{dataOptionsString}};
|
|
126
|
-
filters = {{filtersString}};
|
|
127
|
-
}`,
|
|
128
|
-
chartTmpl: "{{baseChartTmpl}}",
|
|
129
|
-
chartWidgetTmpl: "{{baseChartTmpl}}",
|
|
130
|
-
widgetByIdTmpl: `import { Component } from '@angular/core';
|
|
131
|
-
|
|
132
|
-
@Component({
|
|
133
|
-
selector: 'code-example',
|
|
134
|
-
template: \`
|
|
135
|
-
<csdk-widget-by-id
|
|
136
|
-
[widgetOid]="widgetOid"
|
|
137
|
-
[dashboardOid]="dashboardOid"
|
|
138
|
-
[includeDashboardFilters]="includeDashboardFilters"
|
|
139
|
-
/>
|
|
140
|
-
\`,
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
export class CodeExample {
|
|
144
|
-
widgetOid = "{{widgetOid}}";
|
|
145
|
-
dashboardOid = "{{dashboardOid}}";
|
|
146
|
-
includeDashboardFilters = true;
|
|
147
|
-
}`
|
|
148
|
-
},
|
|
149
|
-
vue: {
|
|
150
|
-
baseChartTmpl: `<script setup lang="ts">
|
|
151
|
-
import { ref } from 'vue';
|
|
152
|
-
import { {{componentString}} } from '@sisense/sdk-ui-vue';
|
|
153
|
-
{{extraImportsString}}
|
|
154
|
-
import * as DM from './{{dataSourceString}}'; // generated with @sisense/sdk-cli
|
|
155
|
-
|
|
156
|
-
const dataOptions = ref({{dataOptionsString}});
|
|
157
|
-
const filters = ref({{filtersString}});
|
|
158
|
-
<\/script>
|
|
159
|
-
|
|
160
|
-
<template>
|
|
161
|
-
<{{componentString}}
|
|
162
|
-
chartType="{{chartTypeString}}"
|
|
163
|
-
:dataOptions="dataOptions"
|
|
164
|
-
:filters="filters"
|
|
165
|
-
:dataSource="DM.DataSource"
|
|
166
|
-
title="{{titleString}}" />
|
|
167
|
-
</template>`,
|
|
168
|
-
chartTmpl: "{{baseChartTmpl}}",
|
|
169
|
-
chartWidgetTmpl: "{{baseChartTmpl}}",
|
|
170
|
-
widgetByIdTmpl: `<script setup lang="ts">
|
|
171
|
-
import { WidgetById } from '@sisense/sdk-ui-vue';
|
|
172
|
-
<\/script>
|
|
173
|
-
<template>
|
|
174
|
-
<WidgetById
|
|
175
|
-
:widgetOid="{{widgetOid}}"
|
|
176
|
-
:dashboardOid="{{dashboardOid}}"
|
|
177
|
-
/>
|
|
178
|
-
</template>
|
|
179
|
-
`
|
|
180
|
-
}
|
|
181
|
-
}, I = (t, e) => X[e][t].replace(
|
|
182
|
-
/{{(.*?)Tmpl}}/g,
|
|
183
|
-
(a, i) => I(`${i}Tmpl`, e)
|
|
184
|
-
), Z = (t, e) => t.replace(/{{(.*?)}}/g, (r, a) => a in e ? e[a] : (console.warn(`Placeholder ${a} not found in data`), r)), _ = (t, e, r = "react") => {
|
|
185
|
-
const a = I(t, r);
|
|
186
|
-
return Z(a, e);
|
|
187
|
-
}, g = `
|
|
188
|
-
`, C = "UNKNOWN", G = (t, e) => {
|
|
189
|
-
let r = "";
|
|
190
|
-
return r += `measureFactory.customFormula(
|
|
191
|
-
`, r += " ".repeat(e), r += ` '${f(t.title)}',
|
|
192
|
-
`, r += " ".repeat(e), r += ` '${t.formula}',
|
|
193
|
-
`, r += " ".repeat(e), r += ` {
|
|
194
|
-
`, Object.entries(t.context).forEach(([a, i]) => {
|
|
195
|
-
const s = q(
|
|
196
|
-
i.table || C,
|
|
197
|
-
i.column || C,
|
|
198
|
-
void 0,
|
|
199
|
-
"DM"
|
|
200
|
-
);
|
|
201
|
-
r += " ".repeat(e), r += ` '${a.slice(1, -1)}': ${s},
|
|
202
|
-
`;
|
|
203
|
-
}), r += " ".repeat(e), r += ` }
|
|
204
|
-
`, r += " ".repeat(e), r += ")", r;
|
|
205
|
-
}, H = (t, e) => {
|
|
206
|
-
const { level: r, table: a, column: i, agg: s, sort: n, title: l } = t;
|
|
207
|
-
let o;
|
|
208
|
-
return a && i && (o = q(a, i, r, "DM")), s && a && i && l && (o = `measureFactory.${U.aggregationFromJAQL(
|
|
209
|
-
s
|
|
210
|
-
)}(${o}, '${f(l)}')`), n && (o = `{column: ${o}, sortType: '${F(n)}'}`), o ? `${" ".repeat(e)}${o}` : C;
|
|
211
|
-
}, tt = (t, e) => {
|
|
212
|
-
const r = t.jaql().jaql;
|
|
213
|
-
return "formula" in r ? G(r, e) : g + H(r, e);
|
|
214
|
-
}, h = (t, e = 0, r = !1) => {
|
|
215
|
-
if (!t)
|
|
216
|
-
return "";
|
|
217
|
-
if (typeof t == "string")
|
|
218
|
-
return `'${f(t)}'`;
|
|
219
|
-
if (t instanceof A)
|
|
220
|
-
return tt(t, e);
|
|
221
|
-
let a = "";
|
|
222
|
-
return Array.isArray(t) ? a += `[${t.map((i) => h(i, e + 2))}${t.length ? g + " ".repeat(e + 2) : ""}]` : (a += `{${g}`, Object.entries(t).forEach(([i, s]) => {
|
|
223
|
-
r && (i = `'${f(i)}'`), a += " ".repeat(e + 2), Array.isArray(s) ? a += `${i}: [${s.map((n) => h(n, e + 4, r))}${s.length ? g + " ".repeat(e + 2) : ""}]` : typeof s == "object" ? a += `${i}: ${h(s, e + 2, r)}` : ["number", "boolean", "undefined", null].includes(typeof s) ? a += `${i}: ${s}` : a += `${i}: '${f(s)}'`, a += `,${g}`;
|
|
224
|
-
}), a += " ".repeat(e), a += "}"), a;
|
|
225
|
-
}, E = `
|
|
226
|
-
`, et = (t, e) => {
|
|
227
|
-
if (t.composeCode)
|
|
228
|
-
return `${E}${" ".repeat(e)}${t.composeCode}`;
|
|
229
|
-
const r = t.jaql().jaql;
|
|
230
|
-
return `${E}${" ".repeat(e)}filterFactory.customFilter(${h(
|
|
231
|
-
r,
|
|
232
|
-
e,
|
|
233
|
-
!0
|
|
234
|
-
)})`;
|
|
235
|
-
}, rt = (t, e = 0) => {
|
|
236
|
-
if (!t)
|
|
237
|
-
return "";
|
|
238
|
-
let r = "";
|
|
239
|
-
return r += `[${t.map((a) => et(a, e + 2))}${t.length ? `
|
|
240
|
-
` + " ".repeat(e + 2) : ""}]`, r;
|
|
241
|
-
}, at = (t) => {
|
|
242
|
-
if (!t)
|
|
243
|
-
return "";
|
|
244
|
-
if (Array.isArray(t))
|
|
245
|
-
return rt(t, 2);
|
|
246
|
-
throw new p("errors.filterRelationsNotSupported");
|
|
247
|
-
}, st = (t) => {
|
|
248
|
-
if (!t)
|
|
249
|
-
throw new p("errors.undefinedDataSource");
|
|
250
|
-
let e;
|
|
251
|
-
return typeof t == "object" && "title" in t ? e = t.title : e = t, R(e);
|
|
252
|
-
}, it = (t) => t, nt = (t) => h(t, 2), ot = (t) => {
|
|
253
|
-
const e = ["measureFactory"], { filters: r } = t;
|
|
254
|
-
return Array.isArray(r) && r.length > 0 && e.push("filterFactory"), `import { ${e.join(", ")} } from '@sisense/sdk-data';`;
|
|
255
|
-
}, lt = (t, e) => {
|
|
256
|
-
const r = {
|
|
257
|
-
titleString: t.title,
|
|
258
|
-
dataSourceString: st(t.dataSource),
|
|
259
|
-
chartTypeString: it(t.chartType),
|
|
260
|
-
dataOptionsString: nt(t.dataOptions),
|
|
261
|
-
filtersString: at(t.filters),
|
|
262
|
-
componentString: "ChartWidget",
|
|
263
|
-
extraImportsString: ot(t)
|
|
264
|
-
};
|
|
265
|
-
return _("chartWidgetTmpl", r, e);
|
|
266
|
-
}, ct = ({
|
|
267
|
-
dashboardOid: t,
|
|
268
|
-
widgetOid: e,
|
|
269
|
-
uiFramework: r = "react"
|
|
270
|
-
}) => _("widgetByIdTmpl", { dashboardOid: t, widgetOid: e }, r), dt = ({
|
|
271
|
-
widgetProps: t,
|
|
272
|
-
uiFramework: e = "react"
|
|
273
|
-
}) => {
|
|
274
|
-
if (k(t))
|
|
275
|
-
return lt(t, e);
|
|
276
|
-
throw new p("errors.otherWidgetTypesNotSupported");
|
|
277
|
-
}, pt = (t) => ({
|
|
278
|
-
dataOptions: { columns: t.map(W) }
|
|
279
|
-
}), ut = Object.freeze({
|
|
280
|
-
convolution: {
|
|
281
|
-
enabled: !0,
|
|
282
|
-
selectedConvolutionType: "bySlicesCount",
|
|
283
|
-
independentSlicesCount: 7
|
|
284
|
-
},
|
|
285
|
-
lineWidth: { width: "bold" },
|
|
286
|
-
markers: {
|
|
287
|
-
enabled: !1
|
|
288
|
-
},
|
|
289
|
-
legend: {
|
|
290
|
-
enabled: !1
|
|
291
|
-
},
|
|
292
|
-
yAxis: {
|
|
293
|
-
gridLines: !1
|
|
294
|
-
},
|
|
295
|
-
xAxis: {
|
|
296
|
-
gridLines: !1
|
|
297
|
-
}
|
|
298
|
-
}), w = Object.freeze({
|
|
299
|
-
line: "line/spline",
|
|
300
|
-
pie: "pie/donut",
|
|
301
|
-
bar: "bar/stacked",
|
|
302
|
-
column: "column/stackedcolumn"
|
|
303
|
-
}), mt = (t, e) => {
|
|
304
|
-
const { axesMapping: r = {}, chartFamily: a } = e, i = t.reduce((n, l) => (n[l.jaql.title] = l, n), {}), s = Object.entries(r).reduce((n, l) => {
|
|
305
|
-
const [o, u] = l;
|
|
306
|
-
return n[`${o}`] = Array.isArray(u) ? u.map((y) => {
|
|
307
|
-
var T, b;
|
|
308
|
-
const c = i[y.name];
|
|
309
|
-
if (!c)
|
|
310
|
-
return { column: { type: "", name: y.name } };
|
|
311
|
-
const d = W(c);
|
|
312
|
-
if (c.panel === "measures")
|
|
313
|
-
return {
|
|
314
|
-
column: d,
|
|
315
|
-
sortType: "sortNone"
|
|
316
|
-
};
|
|
317
|
-
if (Y(d.type)) {
|
|
318
|
-
const O = (b = (T = c.format) == null ? void 0 : T.mask) == null ? void 0 : b[c.jaql.level];
|
|
319
|
-
if (O)
|
|
320
|
-
return {
|
|
321
|
-
column: d,
|
|
322
|
-
dateFormat: O
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
return d;
|
|
326
|
-
}) : u, n;
|
|
327
|
-
}, {});
|
|
328
|
-
switch (a) {
|
|
329
|
-
case "cartesian":
|
|
330
|
-
return m({
|
|
331
|
-
category: [],
|
|
332
|
-
value: [],
|
|
333
|
-
breakBy: []
|
|
334
|
-
}, s);
|
|
335
|
-
case "categorical":
|
|
336
|
-
return m({
|
|
337
|
-
category: [],
|
|
338
|
-
value: []
|
|
339
|
-
}, s);
|
|
340
|
-
case "scatter":
|
|
341
|
-
return Object.keys(s).forEach((n) => {
|
|
342
|
-
s[`${n}`] = s[`${n}`][0];
|
|
343
|
-
}), s;
|
|
344
|
-
case "scattermap":
|
|
345
|
-
return Object.keys(s).forEach((n) => {
|
|
346
|
-
n !== "geo" && (s[`${n}`] = s[`${n}`][0]);
|
|
347
|
-
}), s;
|
|
348
|
-
case "table":
|
|
349
|
-
return Object.keys(s).length === 0 ? pt(t).dataOptions : s;
|
|
350
|
-
case "boxplot":
|
|
351
|
-
case "areamap":
|
|
352
|
-
case "indicator":
|
|
353
|
-
default:
|
|
354
|
-
return s;
|
|
355
|
-
}
|
|
356
|
-
}, M = (t, e) => {
|
|
357
|
-
var r, a, i, s;
|
|
358
|
-
return e === "x" ? (a = (r = t.axesMapping.category) != null ? r : t.axesMapping.x) == null ? void 0 : a.map((n) => n.name).join(", ") : (s = (i = t.axesMapping.value) != null ? i : t.axesMapping.y) == null ? void 0 : s.map((n) => n.name).join(", ");
|
|
359
|
-
}, gt = (t, e, r = !0) => {
|
|
360
|
-
const a = mt(t, e);
|
|
361
|
-
let i;
|
|
362
|
-
return r && e.chartType in w ? i = j(
|
|
363
|
-
j(ut, {
|
|
364
|
-
subtype: w[e.chartType]
|
|
365
|
-
}),
|
|
366
|
-
{
|
|
367
|
-
legend: {
|
|
368
|
-
enabled: !0,
|
|
369
|
-
position: "right"
|
|
370
|
-
},
|
|
371
|
-
yAxis: {
|
|
372
|
-
title: {
|
|
373
|
-
enabled: !0,
|
|
374
|
-
text: M(e, "y")
|
|
375
|
-
}
|
|
376
|
-
},
|
|
377
|
-
xAxis: {
|
|
378
|
-
title: {
|
|
379
|
-
enabled: !0,
|
|
380
|
-
text: M(e, "x")
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
) : i = z(), {
|
|
385
|
-
dataOptions: a,
|
|
386
|
-
chartStyleOptions: i
|
|
387
|
-
};
|
|
388
|
-
}, ft = (t) => "chartType" in t ? t : {
|
|
389
|
-
chartType: "table",
|
|
390
|
-
chartFamily: "table",
|
|
391
|
-
axesMapping: {}
|
|
392
|
-
}, ht = (t) => t.map((e) => J(e.jaql)), yt = (t) => t.reduce(
|
|
393
|
-
(e, r) => {
|
|
394
|
-
if ((r.panel === "scope" || r.jaql.filter) && e.metadataFilters.push(D(r)), r.panel !== "scope") {
|
|
395
|
-
const a = D(r);
|
|
396
|
-
delete a.jaql.filter, e.metadataColumns.push(a);
|
|
397
|
-
}
|
|
398
|
-
return e;
|
|
399
|
-
},
|
|
400
|
-
{ metadataColumns: [], metadataFilters: [] }
|
|
401
|
-
), Tt = (t, e) => {
|
|
402
|
-
if (!V(t))
|
|
403
|
-
try {
|
|
404
|
-
const { useCustomizedStyleOptions: r = !1 } = e || {}, { jaql: a, chartRecommendations: i, queryTitle: s } = t, {
|
|
405
|
-
metadata: n,
|
|
406
|
-
datasource: { title: l }
|
|
407
|
-
} = a, o = ft(i), u = o.chartType.toLowerCase(), y = {
|
|
408
|
-
cornerRadius: "Small",
|
|
409
|
-
header: {
|
|
410
|
-
// remove info button and render empty toolbar instead
|
|
411
|
-
renderToolbar: () => null
|
|
412
|
-
}
|
|
413
|
-
}, { metadataColumns: c, metadataFilters: d } = yt(n), T = ht(d), { dataOptions: b, chartStyleOptions: O } = gt(
|
|
414
|
-
c,
|
|
415
|
-
o,
|
|
416
|
-
r
|
|
417
|
-
), N = m(m({}, O), y);
|
|
418
|
-
return {
|
|
419
|
-
widgetType: "chart",
|
|
420
|
-
id: s,
|
|
421
|
-
title: s,
|
|
422
|
-
chartType: u,
|
|
423
|
-
dataSource: l,
|
|
424
|
-
dataOptions: b,
|
|
425
|
-
filters: T,
|
|
426
|
-
styleOptions: N
|
|
427
|
-
};
|
|
428
|
-
} catch (r) {
|
|
429
|
-
console.error(r);
|
|
430
|
-
return;
|
|
431
|
-
}
|
|
432
|
-
}, bt = (t, e) => Tt(t, e), Ot = (t) => K(t) ? ct(t) : dt(t), Mt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
433
|
-
__proto__: null,
|
|
434
|
-
toWidgetCode: Ot,
|
|
435
|
-
toWidgetProps: bt
|
|
436
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
437
|
-
export {
|
|
438
|
-
xt as E,
|
|
439
|
-
$t as a,
|
|
440
|
-
K as b,
|
|
441
|
-
Dt as c,
|
|
442
|
-
jt as i,
|
|
443
|
-
Z as p,
|
|
444
|
-
Et as s,
|
|
445
|
-
bt as t,
|
|
446
|
-
wt as v,
|
|
447
|
-
Mt as w
|
|
448
|
-
};
|