react-semaphor 0.1.325 → 0.1.327
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/analytics-protocol/index.cjs +1 -1
- package/dist/analytics-protocol/index.js +260 -226
- package/dist/brand-studio/index.cjs +2 -2
- package/dist/brand-studio/index.js +7 -6
- package/dist/chunks/{braces-ZjRH2Kl7.js → braces-B6qRDu1H.js} +1 -1
- package/dist/chunks/{braces-C7BeIXvM.js → braces-BGWZEnQJ.js} +1 -1
- package/dist/chunks/{calendar-preferences-dialog-DHhT6Sja.js → calendar-preferences-dialog-CjwbE_82.js} +6 -5
- package/dist/chunks/calendar-preferences-dialog-fkLUMJyR.js +1 -0
- package/dist/chunks/{chevrons-up-down-CA-XvN1o.js → chevrons-up-down-BpsogQvv.js} +1 -1
- package/dist/chunks/{chevrons-up-down-Cuilz9aY.js → chevrons-up-down-xG-bVFD9.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-DZiFMK8I.js → dashboard-briefing-launcher-Co57xBfS.js} +2 -2
- package/dist/chunks/{dashboard-briefing-launcher-BzIxRlzW.js → dashboard-briefing-launcher-Cy1nWZRW.js} +714 -719
- package/dist/chunks/{dashboard-controls-DVwsWny9.js → dashboard-controls-BWnVEFJq.js} +10 -9
- package/dist/chunks/{dashboard-controls-BX693lE0.js → dashboard-controls-C7rOGZO-.js} +1 -1
- package/dist/chunks/{dashboard-json-D15C_I9e.js → dashboard-json-BpRNSsF3.js} +7 -6
- package/dist/chunks/dashboard-json-DBPMknGo.js +1 -0
- package/dist/chunks/date-formatter-B4EBSe9C.js +1 -0
- package/dist/chunks/date-formatter-CzcPZx39.js +416 -0
- package/dist/chunks/edit-dashboard-visual-B2vkIKEa.js +178 -0
- package/dist/chunks/{edit-dashboard-visual-wQyJEcVH.js → edit-dashboard-visual-CYf26co_.js} +8243 -7784
- package/dist/chunks/index-BD90s-wf.js +1309 -0
- package/dist/chunks/index-BxM99sFL.js +1 -0
- package/dist/chunks/index-CuHybtft.js +51 -0
- package/dist/chunks/{index-CffvIaZO.js → index-DTlbYpxd.js} +29440 -28968
- package/dist/chunks/{palette-D96DOM7E.js → palette-CSF7IVJn.js} +1 -1
- package/dist/chunks/{palette-CanPG11m.js → palette-CWgEPBoG.js} +1 -1
- package/dist/chunks/{resource-management-panel-DlnrD0y-.js → resource-management-panel-D6nbfJY3.js} +1 -1
- package/dist/chunks/{resource-management-panel-CLoO2DL3.js → resource-management-panel-D893Onv8.js} +6 -5
- package/dist/chunks/{save-CqrBQKG6.js → save-CtQbSub2.js} +1 -1
- package/dist/chunks/{save-DxkSzUTZ.js → save-DRdFKF57.js} +1 -1
- package/dist/chunks/switch-DJJJD_g1.js +168 -0
- package/dist/chunks/{switch-Deo2Ltmj.js → switch-DKf6vHfP.js} +2222 -2228
- package/dist/chunks/{use-create-flow-overlay-state-DocFanjO.js → use-create-flow-overlay-state-C4LgoK8q.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-DsPoCfMu.js → use-create-flow-overlay-state-p21zs2p6.js} +29 -28
- package/dist/chunks/{use-visual-utils-BdO22fQZ.js → use-visual-utils-BKBua6o4.js} +2 -2
- package/dist/chunks/{use-visual-utils-DSbXQQD1.js → use-visual-utils-BqWm0QeW.js} +1 -1
- package/dist/chunks/validators-DDAweCzB.js +371 -0
- package/dist/chunks/validators-odlRJblR.js +2 -0
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.cjs +3 -3
- package/dist/dashboard-authoring/index.js +919 -507
- package/dist/data-app-sdk/index.cjs +1 -0
- package/dist/data-app-sdk/index.js +512 -0
- package/dist/format-utils/index.cjs +4 -4
- package/dist/format-utils/index.js +22 -21
- package/dist/index.cjs +1 -1
- package/dist/index.js +141 -140
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/analytics-protocol.d.ts +326 -2
- package/dist/types/dashboard-authoring.d.ts +102 -3
- package/dist/types/dashboard.d.ts +23 -3
- package/dist/types/data-app-sdk.d.ts +379 -0
- package/dist/types/format-utils.d.ts +25 -0
- package/dist/types/main.d.ts +182 -12
- package/dist/types/shared.d.ts +18 -2
- package/dist/types/surfboard.d.ts +23 -3
- package/dist/types/types.d.ts +38 -4
- package/package.json +6 -1
- package/dist/chunks/calendar-preferences-dialog-BxeROxyq.js +0 -1
- package/dist/chunks/dashboard-json-DxNEFM-p.js +0 -1
- package/dist/chunks/date-formatter-D9Bvw5Qk.js +0 -1
- package/dist/chunks/date-formatter-DyIOb6uC.js +0 -333
- package/dist/chunks/edit-dashboard-visual-90_qEgRc.js +0 -178
- package/dist/chunks/index-YTk9Hab2.js +0 -1303
- package/dist/chunks/switch-BXICAlvS.js +0 -168
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const K=require("../chunks/index-BxM99sFL.js"),T=require("react/jsx-runtime"),u=require("react"),P=require("../chunks/validators-odlRJblR.js");function q(t){var e;return{version:1,kind:"metric",id:t.id,label:t.label,source:g(t),metric:t.metric,metrics:t.metrics,dateField:t.dateField?d(t.dateField,"date"):void 0,timeGrain:t.timeGrain,dimensions:(e=t.dimensions)==null?void 0:e.map(n=>d(n,"dimension")),comparison:L(t.comparison),inputs:b(t.inputs),limit:t.limit}}function E(t){if("sort"in t)throw new Error("useSemaphorRecords supports orderBy for a single deterministic sort. Multiple sort clauses are not supported by the analytics protocol yet.");if(!F(t))throw new Error("useSemaphorRecords needs at least one field, dimension, or measure.");const e=V(t.fields,t.dimensions,t.measures);return{version:1,kind:"records",id:t.id,label:t.label,source:g(t),fields:e,measures:t.measures,dateField:t.dateField?d(t.dateField,"date"):void 0,timeGrain:t.timeGrain,orderBy:t.orderBy,inputs:b(t.inputs),limit:t.limit}}function R(t){return{version:1,kind:"inputOptions",id:t.id,label:t.label,source:g(t),field:d(t.field,"dimension"),search:t.search,limit:t.limit}}function w(t){if("toAnalyticsInput"in t){const e=t.toAnalyticsInput();return{inputId:e.inputId,field:e.field}}return{inputId:t.inputId,field:t.field}}function _(t){const e=b(t);return e.length>0?e:void 0}function x(t){return(t||[]).map(j)}function A(t){return x(t).filter(e=>e.isActive)}function O(t){return t.kind==="filter"?{inputId:t.id,kind:t.kind,label:t.label,field:d(t.field,"dimension"),operator:t.operator||"in",source:t.source}:{inputId:t.id,kind:t.kind,label:t.label}}function $(t=[]){return t.map(e=>typeof e=="object"?e:{label:String(e),value:e})}function h(t){return t==null?!1:Array.isArray(t)?t.length>0:typeof t=="string"?t.trim().length>0:!0}function j(t){return"toAnalyticsInput"in t?t.toAnalyticsInput():"kind"in t&&"isActive"in t?t:{...t,kind:"filter",isActive:h(t.value),value:t.value}}function g(t){if("source"in t&&t.source)return t.source;const e=t.datasetName||t.dataset;if(!e)throw new Error("Semaphor data app source needs datasetName or dataset.");return{kind:"semantic",domainId:t.domainId,datasetName:e,datasetId:t.datasetId,connectionId:t.connectionId,label:t.sourceLabel}}function F(t){var e,n,r;return!!((e=t.fields)!=null&&e.length||(n=t.dimensions)!=null&&n.length||(r=t.measures)!=null&&r.length)}function N(t){return!!(t!=null&&t.length)}function V(t,e,n){const r=[],o=new Set,a=i=>{const c=`${i.role||""}:${i.name}`;o.has(c)||(o.add(c),r.push(i))};return N(t)&&t.map(i=>d(i)).forEach(a),e==null||e.map(i=>d(i,"dimension")).forEach(a),n==null||n.map(i=>d(i,"measure")).forEach(a),r}function d(t,e){return typeof t=="string"?e?{name:t,role:e}:{name:t}:{...t,role:t.role||e}}function b(t){return(t||[]).map(w)}function L(t){if(!(!t||t==="none"))return typeof t=="object"?t:t==="same_period_last_year"?{kind:"previous_year"}:{kind:t}}function M(){return{executeMetric:(t,e)=>S(t,e),executeRecords:(t,e)=>S(t,e),executeInputOptions:(t,e)=>S(t,e)}}async function S(t,e){if(!e.token)throw new Error("SemaphorDataAppProvider needs a token to execute queries.");const n=await fetch(Q(e),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.token}`},body:JSON.stringify({intent:t,activeInputs:e.activeInputs,resultShape:t.kind})}),r=await z(n);if(!n.ok||r.error)throw new Error(r.error||`Semaphor Data App query failed with status ${n.status}.`);return r}async function z(t){const e=await t.text().catch(()=>"");if(!e.trim())return t.ok?{error:"Semaphor Data App query returned an empty response."}:{};try{return JSON.parse(e)}catch{return t.ok?{error:"Semaphor Data App query returned invalid JSON.",details:e}:{error:U(t,e),details:e}}}function U(t,e){const n=t.statusText?` ${t.statusText}`:"",r=e.replace(/\s+/g," ").trim();return r?`Semaphor Data App query failed with status ${t.status}${n}: ${r.slice(0,240)}`:`Semaphor Data App query failed with status ${t.status}${n}.`}function Q(t){const e=G(t).replace(/\/+$/,"");return e?e.endsWith("/api")?`${e}/v1/data-app/query`:`${e}/api/v1/data-app/query`:"/api/v1/data-app/query"}function G(t){if(t.apiBaseUrl)return t.apiBaseUrl;if(!t.token)return"";try{return K.jwtDecode(t.token).apiServiceUrl||""}catch{return""}}const C=u.createContext({});function J({token:t,apiBaseUrl:e,executor:n,children:r}){const o=u.useMemo(()=>M(),[]),a=n||o,i=u.useMemo(()=>({token:t,apiBaseUrl:e,executor:a}),[e,a,t]);return T.jsx(C.Provider,{value:i,children:r})}function B(){return u.useContext(C)}const I={value:null},H={records:[]},v={options:[]};function W(t){const e=A(t.inputs);try{const n=q(t),r=k(n);return r?{error:r,activeInputs:e,queryKey:l(void 0,e,r),idleData:I}:{intent:n,error:null,activeInputs:e,queryKey:l(n,e),idleData:I}}catch(n){const r=f(n);return{error:r,activeInputs:e,queryKey:l(void 0,e,r),idleData:I}}}function X(t){const e=A(t.inputs),n=H;try{const r=E(t),o=k(r);return o?{error:o,activeInputs:e,queryKey:l(void 0,e,o),idleData:n}:{intent:r,error:null,activeInputs:e,queryKey:l(r,e),idleData:n}}catch(r){const o=f(r);return{error:o,activeInputs:e,queryKey:l(void 0,e,o),idleData:n}}}function Y(t){try{const e=R(t),n=k(e);return n?{error:n,queryKey:l(void 0,void 0,n),idleData:v}:{intent:e,error:null,queryKey:l(e),idleData:v}}catch(e){const n=f(e);return{error:n,queryKey:l(void 0,void 0,n),idleData:v}}}function f(t){return t instanceof Error?t:new Error(String(t))}function k(t){const e=P.validateSemaphorAnalyticsIntent(t);if(e.ok)return null;const n=e.errors.map(r=>r.path?`${r.code} at ${r.path}: ${r.message}`:`${r.code}: ${r.message}`).join("; ");return new Error(`Invalid Semaphor analytics intent. ${n}`)}function l(t,e,n){return JSON.stringify({intent:t,activeInputs:e,error:n==null?void 0:n.message})}function Z(t){const[e,n]=u.useState(t.defaultValue),r=Object.prototype.hasOwnProperty.call(t,"value"),o=r?t.value:e,a=u.useMemo(()=>$(t.options),[t.options]),i=u.useCallback(s=>{var m;(m=t.onValueChange)==null||m.call(t,s),r||n(s)},[r,t]),c=u.useCallback(()=>i(void 0),[i]);return u.useMemo(()=>{const s=O(t);return{id:t.id,kind:t.kind,label:t.label,field:s.field,operator:s.operator,source:s.source,controlRole:t.kind==="control"?t.role:void 0,value:o,options:a,isActive:h(o),setValue:i,clear:c,toAnalyticsInput:()=>({inputId:s.inputId,field:s.field,kind:t.kind,label:t.label,value:o,isActive:h(o),operator:s.operator,source:s.source,controlRole:t.kind==="control"?t.role:void 0})}},[c,a,i,t,o])}function tt(t){const e=u.useMemo(()=>W(t),[t]),n=u.useCallback(a=>{var i;return e.intent?(i=a.executor)==null?void 0:i.executeMetric(e.intent,a):void 0},[e.intent]),r=D(e.queryKey,n,e.idleData,e.activeInputs),o=e.error?e.idleData:r.data;return{id:t.id,intent:e.intent,value:(o==null?void 0:o.value)??null,metrics:o==null?void 0:o.metrics,comparisonValue:o==null?void 0:o.comparisonValue,delta:o==null?void 0:o.delta,deltaPercent:o==null?void 0:o.deltaPercent,records:o==null?void 0:o.records,status:e.error?"error":r.status,isLoading:!e.error&&r.status==="loading",error:e.error||r.error}}function et(t){const e=u.useMemo(()=>X(t),[t]),n=u.useCallback(a=>{var i;return e.intent?(i=a.executor)==null?void 0:i.executeRecords(e.intent,a):void 0},[e.intent]),r=D(e.queryKey,n,e.idleData,e.activeInputs),o=e.error?e.idleData:r.data;return{id:t.id,intent:e.intent,records:(o==null?void 0:o.records)||[],columns:o==null?void 0:o.columns,rowCount:o==null?void 0:o.rowCount,status:e.error?"error":r.status,isLoading:!e.error&&r.status==="loading",error:e.error||r.error}}function rt(t){const e=u.useMemo(()=>Y(t),[t]),n=u.useCallback(a=>{var i;return e.intent?(i=a.executor)==null?void 0:i.executeInputOptions(e.intent,a):void 0},[e.intent]),r=D(e.queryKey,n,e.idleData),o=e.error?e.idleData:r.data;return{id:t.id,intent:e.intent,options:(o==null?void 0:o.options)||[],status:e.error?"error":r.status,isLoading:!e.error&&r.status==="loading",error:e.error||r.error}}function D(t,e,n,r){const o=B(),a=u.useRef(e),i=u.useRef(r),[c,s]=u.useState({status:"idle",data:n,error:null});return a.current=e,i.current=r,u.useEffect(()=>{let m;try{m=a.current({...o,activeInputs:i.current})}catch(p){s({status:"error",data:n,error:f(p)});return}if(!m){s({status:"idle",data:n,error:null});return}let y=!1;return s(p=>({status:"loading",data:p.data,error:null})),m.then(p=>{y||s({status:"success",data:p,error:null})}).catch(p=>{y||s({status:"error",data:n,error:f(p)})}),()=>{y=!0}},[n,t,o]),c}exports.SemaphorDataAppProvider=J;exports.createSemaphorDataAppExecutor=M;exports.hasSemaphorInputValue=h;exports.normalizeSemaphorInputOptions=$;exports.toSemaphorActiveInputSnapshots=A;exports.toSemaphorInputBinding=w;exports.toSemaphorInputBindings=_;exports.toSemaphorInputOptionsIntent=R;exports.toSemaphorInputSnapshots=x;exports.toSemaphorInputSpec=O;exports.toSemaphorMetricIntent=q;exports.toSemaphorRecordsIntent=E;exports.useSemaphorDataAppRuntime=B;exports.useSemaphorInput=Z;exports.useSemaphorInputOptions=rt;exports.useSemaphorMetric=tt;exports.useSemaphorRecords=et;
|
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
import { j as x } from "../chunks/index-CuHybtft.js";
|
|
2
|
+
import { jsx as $ } from "react/jsx-runtime";
|
|
3
|
+
import { createContext as O, useMemo as f, useContext as K, useState as q, useCallback as p, useRef as E, useEffect as C } from "react";
|
|
4
|
+
import { v as B } from "../chunks/validators-DDAweCzB.js";
|
|
5
|
+
function T(t) {
|
|
6
|
+
var r;
|
|
7
|
+
return {
|
|
8
|
+
version: 1,
|
|
9
|
+
kind: "metric",
|
|
10
|
+
id: t.id,
|
|
11
|
+
label: t.label,
|
|
12
|
+
source: g(t),
|
|
13
|
+
metric: t.metric,
|
|
14
|
+
metrics: t.metrics,
|
|
15
|
+
dateField: t.dateField ? d(t.dateField, "date") : void 0,
|
|
16
|
+
timeGrain: t.timeGrain,
|
|
17
|
+
dimensions: (r = t.dimensions) == null ? void 0 : r.map((n) => d(n, "dimension")),
|
|
18
|
+
comparison: Q(t.comparison),
|
|
19
|
+
inputs: D(t.inputs),
|
|
20
|
+
limit: t.limit
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function _(t) {
|
|
24
|
+
if ("sort" in t)
|
|
25
|
+
throw new Error(
|
|
26
|
+
"useSemaphorRecords supports orderBy for a single deterministic sort. Multiple sort clauses are not supported by the analytics protocol yet."
|
|
27
|
+
);
|
|
28
|
+
if (!L(t))
|
|
29
|
+
throw new Error(
|
|
30
|
+
"useSemaphorRecords needs at least one field, dimension, or measure."
|
|
31
|
+
);
|
|
32
|
+
const r = z(
|
|
33
|
+
t.fields,
|
|
34
|
+
t.dimensions,
|
|
35
|
+
t.measures
|
|
36
|
+
);
|
|
37
|
+
return {
|
|
38
|
+
version: 1,
|
|
39
|
+
kind: "records",
|
|
40
|
+
id: t.id,
|
|
41
|
+
label: t.label,
|
|
42
|
+
source: g(t),
|
|
43
|
+
fields: r,
|
|
44
|
+
measures: t.measures,
|
|
45
|
+
dateField: t.dateField ? d(t.dateField, "date") : void 0,
|
|
46
|
+
timeGrain: t.timeGrain,
|
|
47
|
+
orderBy: t.orderBy,
|
|
48
|
+
inputs: D(t.inputs),
|
|
49
|
+
limit: t.limit
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function F(t) {
|
|
53
|
+
return {
|
|
54
|
+
version: 1,
|
|
55
|
+
kind: "inputOptions",
|
|
56
|
+
id: t.id,
|
|
57
|
+
label: t.label,
|
|
58
|
+
source: g(t),
|
|
59
|
+
field: d(t.field, "dimension"),
|
|
60
|
+
search: t.search,
|
|
61
|
+
limit: t.limit
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function M(t) {
|
|
65
|
+
if ("toAnalyticsInput" in t) {
|
|
66
|
+
const r = t.toAnalyticsInput();
|
|
67
|
+
return {
|
|
68
|
+
inputId: r.inputId,
|
|
69
|
+
field: r.field
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
inputId: t.inputId,
|
|
74
|
+
field: t.field
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function ut(t) {
|
|
78
|
+
const r = D(t);
|
|
79
|
+
return r.length > 0 ? r : void 0;
|
|
80
|
+
}
|
|
81
|
+
function N(t) {
|
|
82
|
+
return (t || []).map(V);
|
|
83
|
+
}
|
|
84
|
+
function w(t) {
|
|
85
|
+
return N(t).filter((r) => r.isActive);
|
|
86
|
+
}
|
|
87
|
+
function P(t) {
|
|
88
|
+
return t.kind === "filter" ? {
|
|
89
|
+
inputId: t.id,
|
|
90
|
+
kind: t.kind,
|
|
91
|
+
label: t.label,
|
|
92
|
+
field: d(t.field, "dimension"),
|
|
93
|
+
operator: t.operator || "in",
|
|
94
|
+
source: t.source
|
|
95
|
+
} : {
|
|
96
|
+
inputId: t.id,
|
|
97
|
+
kind: t.kind,
|
|
98
|
+
label: t.label
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function j(t = []) {
|
|
102
|
+
return t.map(
|
|
103
|
+
(r) => typeof r == "object" ? r : {
|
|
104
|
+
label: String(r),
|
|
105
|
+
value: r
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
function A(t) {
|
|
110
|
+
return t == null ? !1 : Array.isArray(t) ? t.length > 0 : typeof t == "string" ? t.trim().length > 0 : !0;
|
|
111
|
+
}
|
|
112
|
+
function V(t) {
|
|
113
|
+
return "toAnalyticsInput" in t ? t.toAnalyticsInput() : "kind" in t && "isActive" in t ? t : {
|
|
114
|
+
...t,
|
|
115
|
+
kind: "filter",
|
|
116
|
+
isActive: A(
|
|
117
|
+
t.value
|
|
118
|
+
),
|
|
119
|
+
value: t.value
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function g(t) {
|
|
123
|
+
if ("source" in t && t.source)
|
|
124
|
+
return t.source;
|
|
125
|
+
const r = t.datasetName || t.dataset;
|
|
126
|
+
if (!r)
|
|
127
|
+
throw new Error("Semaphor data app source needs datasetName or dataset.");
|
|
128
|
+
return {
|
|
129
|
+
kind: "semantic",
|
|
130
|
+
domainId: t.domainId,
|
|
131
|
+
datasetName: r,
|
|
132
|
+
datasetId: t.datasetId,
|
|
133
|
+
connectionId: t.connectionId,
|
|
134
|
+
label: t.sourceLabel
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function L(t) {
|
|
138
|
+
var r, n, e;
|
|
139
|
+
return !!((r = t.fields) != null && r.length || (n = t.dimensions) != null && n.length || (e = t.measures) != null && e.length);
|
|
140
|
+
}
|
|
141
|
+
function U(t) {
|
|
142
|
+
return !!(t != null && t.length);
|
|
143
|
+
}
|
|
144
|
+
function z(t, r, n) {
|
|
145
|
+
const e = [], o = /* @__PURE__ */ new Set(), a = (i) => {
|
|
146
|
+
const l = `${i.role || ""}:${i.name}`;
|
|
147
|
+
o.has(l) || (o.add(l), e.push(i));
|
|
148
|
+
};
|
|
149
|
+
return U(t) && t.map((i) => d(i)).forEach(a), r == null || r.map((i) => d(i, "dimension")).forEach(a), n == null || n.map((i) => d(i, "measure")).forEach(a), e;
|
|
150
|
+
}
|
|
151
|
+
function d(t, r) {
|
|
152
|
+
return typeof t == "string" ? r ? { name: t, role: r } : { name: t } : {
|
|
153
|
+
...t,
|
|
154
|
+
role: t.role || r
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function D(t) {
|
|
158
|
+
return (t || []).map(M);
|
|
159
|
+
}
|
|
160
|
+
function Q(t) {
|
|
161
|
+
if (!(!t || t === "none"))
|
|
162
|
+
return typeof t == "object" ? t : t === "same_period_last_year" ? { kind: "previous_year" } : { kind: t };
|
|
163
|
+
}
|
|
164
|
+
function G() {
|
|
165
|
+
return {
|
|
166
|
+
executeMetric: (t, r) => v(t, r),
|
|
167
|
+
executeRecords: (t, r) => v(t, r),
|
|
168
|
+
executeInputOptions: (t, r) => v(t, r)
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
async function v(t, r) {
|
|
172
|
+
if (!r.token)
|
|
173
|
+
throw new Error("SemaphorDataAppProvider needs a token to execute queries.");
|
|
174
|
+
const n = await fetch(W(r), {
|
|
175
|
+
method: "POST",
|
|
176
|
+
headers: {
|
|
177
|
+
"Content-Type": "application/json",
|
|
178
|
+
Authorization: `Bearer ${r.token}`
|
|
179
|
+
},
|
|
180
|
+
body: JSON.stringify({
|
|
181
|
+
intent: t,
|
|
182
|
+
activeInputs: r.activeInputs,
|
|
183
|
+
resultShape: t.kind
|
|
184
|
+
})
|
|
185
|
+
}), e = await J(n);
|
|
186
|
+
if (!n.ok || e.error)
|
|
187
|
+
throw new Error(
|
|
188
|
+
e.error || `Semaphor Data App query failed with status ${n.status}.`
|
|
189
|
+
);
|
|
190
|
+
return e;
|
|
191
|
+
}
|
|
192
|
+
async function J(t) {
|
|
193
|
+
const r = await t.text().catch(() => "");
|
|
194
|
+
if (!r.trim())
|
|
195
|
+
return t.ok ? {
|
|
196
|
+
error: "Semaphor Data App query returned an empty response."
|
|
197
|
+
} : {};
|
|
198
|
+
try {
|
|
199
|
+
return JSON.parse(r);
|
|
200
|
+
} catch {
|
|
201
|
+
return t.ok ? {
|
|
202
|
+
error: "Semaphor Data App query returned invalid JSON.",
|
|
203
|
+
details: r
|
|
204
|
+
} : {
|
|
205
|
+
error: H(t, r),
|
|
206
|
+
details: r
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function H(t, r) {
|
|
211
|
+
const n = t.statusText ? ` ${t.statusText}` : "", e = r.replace(/\s+/g, " ").trim();
|
|
212
|
+
return e ? `Semaphor Data App query failed with status ${t.status}${n}: ${e.slice(0, 240)}` : `Semaphor Data App query failed with status ${t.status}${n}.`;
|
|
213
|
+
}
|
|
214
|
+
function W(t) {
|
|
215
|
+
const r = X(t).replace(/\/+$/, "");
|
|
216
|
+
return r ? r.endsWith("/api") ? `${r}/v1/data-app/query` : `${r}/api/v1/data-app/query` : "/api/v1/data-app/query";
|
|
217
|
+
}
|
|
218
|
+
function X(t) {
|
|
219
|
+
if (t.apiBaseUrl)
|
|
220
|
+
return t.apiBaseUrl;
|
|
221
|
+
if (!t.token)
|
|
222
|
+
return "";
|
|
223
|
+
try {
|
|
224
|
+
return x(t.token).apiServiceUrl || "";
|
|
225
|
+
} catch {
|
|
226
|
+
return "";
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const R = O({});
|
|
230
|
+
function st({
|
|
231
|
+
token: t,
|
|
232
|
+
apiBaseUrl: r,
|
|
233
|
+
executor: n,
|
|
234
|
+
children: e
|
|
235
|
+
}) {
|
|
236
|
+
const o = f(() => G(), []), a = n || o, i = f(
|
|
237
|
+
() => ({ token: t, apiBaseUrl: r, executor: a }),
|
|
238
|
+
[r, a, t]
|
|
239
|
+
);
|
|
240
|
+
return /* @__PURE__ */ $(R.Provider, { value: i, children: e });
|
|
241
|
+
}
|
|
242
|
+
function Y() {
|
|
243
|
+
return K(R);
|
|
244
|
+
}
|
|
245
|
+
const I = { value: null }, Z = { records: [] }, S = { options: [] };
|
|
246
|
+
function tt(t) {
|
|
247
|
+
const r = w(t.inputs);
|
|
248
|
+
try {
|
|
249
|
+
const n = T(t), e = k(n);
|
|
250
|
+
return e ? {
|
|
251
|
+
error: e,
|
|
252
|
+
activeInputs: r,
|
|
253
|
+
queryKey: s(void 0, r, e),
|
|
254
|
+
idleData: I
|
|
255
|
+
} : {
|
|
256
|
+
intent: n,
|
|
257
|
+
error: null,
|
|
258
|
+
activeInputs: r,
|
|
259
|
+
queryKey: s(n, r),
|
|
260
|
+
idleData: I
|
|
261
|
+
};
|
|
262
|
+
} catch (n) {
|
|
263
|
+
const e = h(n);
|
|
264
|
+
return {
|
|
265
|
+
error: e,
|
|
266
|
+
activeInputs: r,
|
|
267
|
+
queryKey: s(void 0, r, e),
|
|
268
|
+
idleData: I
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
function rt(t) {
|
|
273
|
+
const r = w(t.inputs), n = Z;
|
|
274
|
+
try {
|
|
275
|
+
const e = _(t), o = k(e);
|
|
276
|
+
return o ? {
|
|
277
|
+
error: o,
|
|
278
|
+
activeInputs: r,
|
|
279
|
+
queryKey: s(void 0, r, o),
|
|
280
|
+
idleData: n
|
|
281
|
+
} : {
|
|
282
|
+
intent: e,
|
|
283
|
+
error: null,
|
|
284
|
+
activeInputs: r,
|
|
285
|
+
queryKey: s(e, r),
|
|
286
|
+
idleData: n
|
|
287
|
+
};
|
|
288
|
+
} catch (e) {
|
|
289
|
+
const o = h(e);
|
|
290
|
+
return {
|
|
291
|
+
error: o,
|
|
292
|
+
activeInputs: r,
|
|
293
|
+
queryKey: s(void 0, r, o),
|
|
294
|
+
idleData: n
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
function et(t) {
|
|
299
|
+
try {
|
|
300
|
+
const r = F(t), n = k(r);
|
|
301
|
+
return n ? {
|
|
302
|
+
error: n,
|
|
303
|
+
queryKey: s(void 0, void 0, n),
|
|
304
|
+
idleData: S
|
|
305
|
+
} : {
|
|
306
|
+
intent: r,
|
|
307
|
+
error: null,
|
|
308
|
+
queryKey: s(r),
|
|
309
|
+
idleData: S
|
|
310
|
+
};
|
|
311
|
+
} catch (r) {
|
|
312
|
+
const n = h(r);
|
|
313
|
+
return {
|
|
314
|
+
error: n,
|
|
315
|
+
queryKey: s(void 0, void 0, n),
|
|
316
|
+
idleData: S
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
function h(t) {
|
|
321
|
+
return t instanceof Error ? t : new Error(String(t));
|
|
322
|
+
}
|
|
323
|
+
function k(t) {
|
|
324
|
+
const r = B(t);
|
|
325
|
+
if (r.ok)
|
|
326
|
+
return null;
|
|
327
|
+
const n = r.errors.map(
|
|
328
|
+
(e) => e.path ? `${e.code} at ${e.path}: ${e.message}` : `${e.code}: ${e.message}`
|
|
329
|
+
).join("; ");
|
|
330
|
+
return new Error(`Invalid Semaphor analytics intent. ${n}`);
|
|
331
|
+
}
|
|
332
|
+
function s(t, r, n) {
|
|
333
|
+
return JSON.stringify({
|
|
334
|
+
intent: t,
|
|
335
|
+
activeInputs: r,
|
|
336
|
+
error: n == null ? void 0 : n.message
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
function dt(t) {
|
|
340
|
+
const [r, n] = q(t.defaultValue), e = Object.prototype.hasOwnProperty.call(t, "value"), o = e ? t.value : r, a = f(
|
|
341
|
+
() => j(t.options),
|
|
342
|
+
[t.options]
|
|
343
|
+
), i = p(
|
|
344
|
+
(u) => {
|
|
345
|
+
var m;
|
|
346
|
+
(m = t.onValueChange) == null || m.call(t, u), e || n(u);
|
|
347
|
+
},
|
|
348
|
+
[e, t]
|
|
349
|
+
), l = p(() => i(void 0), [i]);
|
|
350
|
+
return f(() => {
|
|
351
|
+
const u = P(t);
|
|
352
|
+
return {
|
|
353
|
+
id: t.id,
|
|
354
|
+
kind: t.kind,
|
|
355
|
+
label: t.label,
|
|
356
|
+
field: u.field,
|
|
357
|
+
operator: u.operator,
|
|
358
|
+
source: u.source,
|
|
359
|
+
controlRole: t.kind === "control" ? t.role : void 0,
|
|
360
|
+
value: o,
|
|
361
|
+
options: a,
|
|
362
|
+
isActive: A(o),
|
|
363
|
+
setValue: i,
|
|
364
|
+
clear: l,
|
|
365
|
+
toAnalyticsInput: () => ({
|
|
366
|
+
inputId: u.inputId,
|
|
367
|
+
field: u.field,
|
|
368
|
+
kind: t.kind,
|
|
369
|
+
label: t.label,
|
|
370
|
+
value: o,
|
|
371
|
+
isActive: A(o),
|
|
372
|
+
operator: u.operator,
|
|
373
|
+
source: u.source,
|
|
374
|
+
controlRole: t.kind === "control" ? t.role : void 0
|
|
375
|
+
})
|
|
376
|
+
};
|
|
377
|
+
}, [l, a, i, t, o]);
|
|
378
|
+
}
|
|
379
|
+
function lt(t) {
|
|
380
|
+
const r = f(() => tt(t), [t]), n = p(
|
|
381
|
+
(a) => {
|
|
382
|
+
var i;
|
|
383
|
+
return r.intent ? (i = a.executor) == null ? void 0 : i.executeMetric(r.intent, a) : void 0;
|
|
384
|
+
},
|
|
385
|
+
[r.intent]
|
|
386
|
+
), e = b(
|
|
387
|
+
r.queryKey,
|
|
388
|
+
n,
|
|
389
|
+
r.idleData,
|
|
390
|
+
r.activeInputs
|
|
391
|
+
), o = r.error ? r.idleData : e.data;
|
|
392
|
+
return {
|
|
393
|
+
id: t.id,
|
|
394
|
+
intent: r.intent,
|
|
395
|
+
value: (o == null ? void 0 : o.value) ?? null,
|
|
396
|
+
metrics: o == null ? void 0 : o.metrics,
|
|
397
|
+
comparisonValue: o == null ? void 0 : o.comparisonValue,
|
|
398
|
+
delta: o == null ? void 0 : o.delta,
|
|
399
|
+
deltaPercent: o == null ? void 0 : o.deltaPercent,
|
|
400
|
+
records: o == null ? void 0 : o.records,
|
|
401
|
+
status: r.error ? "error" : e.status,
|
|
402
|
+
isLoading: !r.error && e.status === "loading",
|
|
403
|
+
error: r.error || e.error
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
function ct(t) {
|
|
407
|
+
const r = f(() => rt(t), [t]), n = p(
|
|
408
|
+
(a) => {
|
|
409
|
+
var i;
|
|
410
|
+
return r.intent ? (i = a.executor) == null ? void 0 : i.executeRecords(r.intent, a) : void 0;
|
|
411
|
+
},
|
|
412
|
+
[r.intent]
|
|
413
|
+
), e = b(
|
|
414
|
+
r.queryKey,
|
|
415
|
+
n,
|
|
416
|
+
r.idleData,
|
|
417
|
+
r.activeInputs
|
|
418
|
+
), o = r.error ? r.idleData : e.data;
|
|
419
|
+
return {
|
|
420
|
+
id: t.id,
|
|
421
|
+
intent: r.intent,
|
|
422
|
+
records: (o == null ? void 0 : o.records) || [],
|
|
423
|
+
columns: o == null ? void 0 : o.columns,
|
|
424
|
+
rowCount: o == null ? void 0 : o.rowCount,
|
|
425
|
+
status: r.error ? "error" : e.status,
|
|
426
|
+
isLoading: !r.error && e.status === "loading",
|
|
427
|
+
error: r.error || e.error
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
function ft(t) {
|
|
431
|
+
const r = f(() => et(t), [t]), n = p(
|
|
432
|
+
(a) => {
|
|
433
|
+
var i;
|
|
434
|
+
return r.intent ? (i = a.executor) == null ? void 0 : i.executeInputOptions(r.intent, a) : void 0;
|
|
435
|
+
},
|
|
436
|
+
[r.intent]
|
|
437
|
+
), e = b(
|
|
438
|
+
r.queryKey,
|
|
439
|
+
n,
|
|
440
|
+
r.idleData
|
|
441
|
+
), o = r.error ? r.idleData : e.data;
|
|
442
|
+
return {
|
|
443
|
+
id: t.id,
|
|
444
|
+
intent: r.intent,
|
|
445
|
+
options: (o == null ? void 0 : o.options) || [],
|
|
446
|
+
status: r.error ? "error" : e.status,
|
|
447
|
+
isLoading: !r.error && e.status === "loading",
|
|
448
|
+
error: r.error || e.error
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
function b(t, r, n, e) {
|
|
452
|
+
const o = Y(), a = E(r), i = E(e), [l, u] = q({
|
|
453
|
+
status: "idle",
|
|
454
|
+
data: n,
|
|
455
|
+
error: null
|
|
456
|
+
});
|
|
457
|
+
return a.current = r, i.current = e, C(() => {
|
|
458
|
+
let m;
|
|
459
|
+
try {
|
|
460
|
+
m = a.current({
|
|
461
|
+
...o,
|
|
462
|
+
activeInputs: i.current
|
|
463
|
+
});
|
|
464
|
+
} catch (c) {
|
|
465
|
+
u({
|
|
466
|
+
status: "error",
|
|
467
|
+
data: n,
|
|
468
|
+
error: h(c)
|
|
469
|
+
});
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
if (!m) {
|
|
473
|
+
u({ status: "idle", data: n, error: null });
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
let y = !1;
|
|
477
|
+
return u((c) => ({
|
|
478
|
+
status: "loading",
|
|
479
|
+
data: c.data,
|
|
480
|
+
error: null
|
|
481
|
+
})), m.then((c) => {
|
|
482
|
+
y || u({ status: "success", data: c, error: null });
|
|
483
|
+
}).catch((c) => {
|
|
484
|
+
y || u({
|
|
485
|
+
status: "error",
|
|
486
|
+
data: n,
|
|
487
|
+
error: h(c)
|
|
488
|
+
});
|
|
489
|
+
}), () => {
|
|
490
|
+
y = !0;
|
|
491
|
+
};
|
|
492
|
+
}, [n, t, o]), l;
|
|
493
|
+
}
|
|
494
|
+
export {
|
|
495
|
+
st as SemaphorDataAppProvider,
|
|
496
|
+
G as createSemaphorDataAppExecutor,
|
|
497
|
+
A as hasSemaphorInputValue,
|
|
498
|
+
j as normalizeSemaphorInputOptions,
|
|
499
|
+
w as toSemaphorActiveInputSnapshots,
|
|
500
|
+
M as toSemaphorInputBinding,
|
|
501
|
+
ut as toSemaphorInputBindings,
|
|
502
|
+
F as toSemaphorInputOptionsIntent,
|
|
503
|
+
N as toSemaphorInputSnapshots,
|
|
504
|
+
P as toSemaphorInputSpec,
|
|
505
|
+
T as toSemaphorMetricIntent,
|
|
506
|
+
_ as toSemaphorRecordsIntent,
|
|
507
|
+
Y as useSemaphorDataAppRuntime,
|
|
508
|
+
dt as useSemaphorInput,
|
|
509
|
+
ft as useSemaphorInputOptions,
|
|
510
|
+
lt as useSemaphorMetric,
|
|
511
|
+
ct as useSemaphorRecords
|
|
512
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../chunks/date-formatter-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../chunks/date-formatter-B4EBSe9C.js");function H(r,e,n,t){const o=r instanceof Date?r.toISOString():String(r),u=(t==null?void 0:t.browserTimezone)||n,s=(t==null?void 0:t.isSqlCard)??!1;if(e!=null&&e.useRelativeTime)return l.formatRelativeTime(o,(e==null?void 0:e.sourceTimezone)||"auto");const i=e!=null&&e.useCustomFormat&&(e!=null&&e.customFormat)?e.customFormat:(e==null?void 0:e.format)||"MM/dd/yyyy";return l.formatDate(o,i,e!=null&&e.timezone&&(e==null?void 0:e.timezone)!=="auto"?e.timezone:s?u:n,(e==null?void 0:e.sourceTimezone)||"auto")}function h(r,e,n){if(r==null)return"";if(!n.useFormattedValues||!e)return String(r);switch(e.type){case"number":return typeof r=="number"?l.formatNumberWithColumnSettings(r,e.numberFormat,n.locale):String(r);case"date":return H(r,e.dateFormat,n.timezone,{browserTimezone:n.browserTimezone,isSqlCard:n.isSqlCard});case"progress":return typeof r=="number"?`${r}%`:String(r);case"badge":case"link":case"text":case"none":default:return String(r)}}function T(r,e){return e.visibleColumns.map(n=>{const t=r[n],o=e.columnSettings[n];return h(t,o,{useFormattedValues:e.useFormattedValues,timezone:e.timezone,locale:e.locale})})}function m(r,e=","){if(r==null)return"";const n=String(r);return n.includes(e)||n.includes('"')||n.includes(`
|
|
2
2
|
`)||n.includes("\r")?`"${n.replace(/"/g,'""')}"`:n}function f(r,e=","){return r.map(n=>m(n,e)).join(e)}function d(r,e={}){const{delimiter:n=",",lineEnding:t=`
|
|
3
|
-
`}=e;return r.map(
|
|
4
|
-
`,includeHeaders:
|
|
5
|
-
`){return y(r,e).join(n)}function j(r,e,n){return r==null?"":n.useFormattedValues?typeof r=="number"&&(e==null?void 0:e.type)==="number"?l.formatNumberWithColumnSettings(r,e.numberFormat,n.locale):typeof r=="number"?r.toLocaleString(n.locale):String(r):String(r)}function V(r,e,n){var
|
|
3
|
+
`}=e;return r.map(o=>f(o,n)).join(t)}function N(r,e={}){if(r.length===0)return"";const{delimiter:n=",",lineEnding:t=`
|
|
4
|
+
`,includeHeaders:o=!0,columns:u}=e,s=u||Object.keys(r[0]),i=[];o&&i.push(s);for(const c of r){const p=s.map(b=>{const a=c[b];return a==null?"":String(a)});i.push(p)}return d(i,{delimiter:n,lineEnding:t})}function y(r,e){const n=[];e.includeHeaders&&n.push(f(e.visibleColumns,e.delimiter));for(const t of r){const o=T(t,e);n.push(o.map(u=>m(u,e.delimiter)).join(e.delimiter))}return n}function v(r,e,n=`
|
|
5
|
+
`){return y(r,e).join(n)}function j(r,e,n){return r==null?"":n.useFormattedValues?typeof r=="number"&&(e==null?void 0:e.type)==="number"?l.formatNumberWithColumnSettings(r,e.numberFormat,n.locale):typeof r=="number"?r.toLocaleString(n.locale):String(r):String(r)}function V(r,e,n){var o,u;const t=[];if(r.isSubtotal&&!r.isGrandTotal){const s=e.groupByColumns.findIndex(i=>i.alias===r.subtotalLevel);e.groupByColumns.forEach((i,c)=>{var p,b,a,S;if(c===s){const A=(b=(p=e.rowAggregates)==null?void 0:p.find(E=>E.groupLevel===r.subtotalLevel))==null?void 0:b.label,L=(S=(a=r.subtotalContext)==null?void 0:a.groupByValues)==null?void 0:S[i.alias];t.push(A??`Subtotal (${L??"Total"})`)}else c<s?t.push(String(r[i.alias]??"")):t.push("")})}else if(r.isGrandTotal){const s=(u=(o=e.rowAggregates)==null?void 0:o.find(i=>i.groupLevel==="ALL"))==null?void 0:u.label;t.push(s||"Grand Total"),e.groupByColumns.slice(1).forEach(()=>t.push(""))}else e.groupByColumns.forEach(s=>{t.push(String(r[s.alias]??""))});return e.pivotSchema.filter(s=>s.isMetricColumn).forEach(s=>{const i=r[s.alias],c=n.columnSettings[s.alias];t.push(j(i,c,n))}),t}function C(r){const e=r.groupByColumns.map(t=>t.label||t.name),n=r.pivotSchema.filter(t=>t.isMetricColumn).map(t=>t.displayLabel||t.metricLabel||t.metricName||t.alias);return[...e,...n]}function D(r,e,n){const t=[];if(n.includeHeaders){const o=C(e);t.push(f(o,n.delimiter))}for(const o of r){const u=V(o,e,n);t.push(u.map(s=>m(s,n.delimiter)).join(n.delimiter))}return t}function w(r,e,n){for(const t of r){if(t.level<n){e[t.level].push(t.name);for(let o=1;o<t.colspan;o++)e[t.level].push("")}t.children?w(t.children,e,n):t.columnKey&&e[n].push(t.name)}}function z(r){const e=r.pivotByColumns.length,n=r.groupByColumns.length,t=Array.from({length:e+1},()=>[]);for(let o=0;o<e;o++)t[o].push(...Array(n).fill(""));if(t[e].push(...r.groupByColumns.map(o=>o.label||o.name)),w(r.columnHeadersTree,t,e),r.showRowTotals){for(let o=0;o<e;o++)t[o].push("");t[e].push("Total")}return t}function P(r,e,n){if(r==null)return"";if(!n.useFormattedValues)return String(r);const t=n.columnSettings[e];return typeof r=="number"&&(t==null?void 0:t.type)==="number"?l.formatNumberWithColumnSettings(r,t.numberFormat,n.locale):typeof r=="number"?r.toLocaleString(n.locale):String(r)}function R(r,e,n){const t=[];r.fieldValues.forEach((u,s)=>{r.isSubtotal&&s===0?t.push(`${u} Total`):r.isSubtotal?t.push(""):t.push(String(u??""))});let o=0;return e.columnHeaders.forEach(u=>{var c;const s=(c=r.cells[u])==null?void 0:c.value,i=P(s,u,n);t.push(i),e.showRowTotals&&typeof s=="number"&&(o+=s)}),e.showRowTotals&&t.push(o.toLocaleString(n.locale)),t}function B(r,e,n){const t=[];if(n.includeHeaders){const o=z(e);for(const u of o)t.push(f(u,n.delimiter))}for(const o of r){const u=R(o,e,n);t.push(u.map(s=>m(s,n.delimiter)).join(n.delimiter))}return t}exports.formatCurrency=l.formatCurrency;exports.formatDate=l.formatDate;exports.formatDuration=l.formatDuration;exports.formatNumber=l.formatNumber;exports.formatNumberCustom=l.formatNumberCustom;exports.formatNumberWithColumnSettings=l.formatNumberWithColumnSettings;exports.formatPercent=l.formatPercent;exports.formatRelativeTime=l.formatRelativeTime;exports.formatScientific=l.formatScientific;exports.getTimezoneAbbreviation=l.getTimezoneAbbreviation;exports.getTimezoneName=l.getTimezoneName;exports.parseWithSourceTimezone=l.parseWithSourceTimezone;exports.resolveTimezone=l.resolveTimezone;exports.arrayToCSV=d;exports.arrayToCSVRow=f;exports.escapeCSVValue=m;exports.formatAggregateRow=V;exports.formatAggregateTableForCSV=D;exports.formatCellValue=h;exports.formatPivotDataRow=R;exports.formatPivotTableForCSV=B;exports.formatRowForExport=T;exports.formatTableForCSV=y;exports.generateAggregateHeaders=C;exports.generatePivotHeaders=z;exports.generateTableCSV=v;exports.objectsToCSV=N;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as h, a as V, b as w } from "../chunks/date-formatter-
|
|
2
|
-
import { d as O, c as W, h as
|
|
1
|
+
import { f as h, a as V, b as w } from "../chunks/date-formatter-CzcPZx39.js";
|
|
2
|
+
import { d as G, i as O, c as W, h as I, e as J, g as K, j as Q, k as U, p as X, r as Y } from "../chunks/date-formatter-CzcPZx39.js";
|
|
3
3
|
function z(r, e, n, s) {
|
|
4
4
|
const u = r instanceof Date ? r.toISOString() : String(r), l = (s == null ? void 0 : s.browserTimezone) || n, t = (s == null ? void 0 : s.isSqlCard) ?? !1;
|
|
5
5
|
if (e != null && e.useRelativeTime)
|
|
@@ -84,11 +84,11 @@ function N(r, e = {}) {
|
|
|
84
84
|
} = e, t = l || Object.keys(r[0]), o = [];
|
|
85
85
|
u && o.push(t);
|
|
86
86
|
for (const i of r) {
|
|
87
|
-
const
|
|
88
|
-
const c = i[
|
|
87
|
+
const a = t.map((m) => {
|
|
88
|
+
const c = i[m];
|
|
89
89
|
return c == null ? "" : String(c);
|
|
90
90
|
});
|
|
91
|
-
o.push(
|
|
91
|
+
o.push(a);
|
|
92
92
|
}
|
|
93
93
|
return E(o, { delimiter: n, lineEnding: s });
|
|
94
94
|
}
|
|
@@ -122,11 +122,11 @@ function A(r, e, n) {
|
|
|
122
122
|
(o) => o.alias === r.subtotalLevel
|
|
123
123
|
);
|
|
124
124
|
e.groupByColumns.forEach((o, i) => {
|
|
125
|
-
var
|
|
125
|
+
var a, m, c, b;
|
|
126
126
|
if (i === t) {
|
|
127
|
-
const d = (
|
|
127
|
+
const d = (m = (a = e.rowAggregates) == null ? void 0 : a.find(
|
|
128
128
|
(T) => T.groupLevel === r.subtotalLevel
|
|
129
|
-
)) == null ? void 0 :
|
|
129
|
+
)) == null ? void 0 : m.label, y = (b = (c = r.subtotalContext) == null ? void 0 : c.groupByValues) == null ? void 0 : b[o.alias];
|
|
130
130
|
s.push(d ?? `Subtotal (${y ?? "Total"})`);
|
|
131
131
|
} else i < t ? s.push(String(r[o.alias] ?? "")) : s.push("");
|
|
132
132
|
});
|
|
@@ -194,7 +194,7 @@ function C(r) {
|
|
|
194
194
|
}
|
|
195
195
|
return s;
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function D(r, e, n) {
|
|
198
198
|
if (r == null)
|
|
199
199
|
return "";
|
|
200
200
|
if (!n.useFormattedValues)
|
|
@@ -206,7 +206,7 @@ function x(r, e, n) {
|
|
|
206
206
|
n.locale
|
|
207
207
|
) : typeof r == "number" ? r.toLocaleString(n.locale) : String(r);
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function x(r, e, n) {
|
|
210
210
|
const s = [];
|
|
211
211
|
r.fieldValues.forEach((l, t) => {
|
|
212
212
|
r.isSubtotal && t === 0 ? s.push(`${l} Total`) : r.isSubtotal ? s.push("") : s.push(String(l ?? ""));
|
|
@@ -214,7 +214,7 @@ function D(r, e, n) {
|
|
|
214
214
|
let u = 0;
|
|
215
215
|
return e.columnHeaders.forEach((l) => {
|
|
216
216
|
var i;
|
|
217
|
-
const t = (i = r.cells[l]) == null ? void 0 : i.value, o =
|
|
217
|
+
const t = (i = r.cells[l]) == null ? void 0 : i.value, o = D(t, l, n);
|
|
218
218
|
s.push(o), e.showRowTotals && typeof t == "number" && (u += t);
|
|
219
219
|
}), e.showRowTotals && s.push(u.toLocaleString(n.locale)), s;
|
|
220
220
|
}
|
|
@@ -226,7 +226,7 @@ function $(r, e, n) {
|
|
|
226
226
|
s.push(f(l, n.delimiter));
|
|
227
227
|
}
|
|
228
228
|
for (const u of r) {
|
|
229
|
-
const l =
|
|
229
|
+
const l = x(
|
|
230
230
|
u,
|
|
231
231
|
e,
|
|
232
232
|
n
|
|
@@ -244,24 +244,25 @@ export {
|
|
|
244
244
|
A as formatAggregateRow,
|
|
245
245
|
q as formatAggregateTableForCSV,
|
|
246
246
|
L as formatCellValue,
|
|
247
|
-
|
|
247
|
+
G as formatCurrency,
|
|
248
248
|
w as formatDate,
|
|
249
|
+
O as formatDuration,
|
|
249
250
|
W as formatNumber,
|
|
250
|
-
|
|
251
|
+
I as formatNumberCustom,
|
|
251
252
|
h as formatNumberWithColumnSettings,
|
|
252
|
-
|
|
253
|
-
|
|
253
|
+
J as formatPercent,
|
|
254
|
+
x as formatPivotDataRow,
|
|
254
255
|
$ as formatPivotTableForCSV,
|
|
255
256
|
V as formatRelativeTime,
|
|
256
257
|
R as formatRowForExport,
|
|
257
|
-
|
|
258
|
+
K as formatScientific,
|
|
258
259
|
H as formatTableForCSV,
|
|
259
260
|
B as generateAggregateHeaders,
|
|
260
261
|
C as generatePivotHeaders,
|
|
261
262
|
P as generateTableCSV,
|
|
262
|
-
|
|
263
|
-
|
|
263
|
+
Q as getTimezoneAbbreviation,
|
|
264
|
+
U as getTimezoneName,
|
|
264
265
|
N as objectsToCSV,
|
|
265
|
-
|
|
266
|
-
|
|
266
|
+
X as parseWithSourceTimezone,
|
|
267
|
+
Y as resolveTimezone
|
|
267
268
|
};
|