@nebula.js/stardust 2.9.0 → 2.10.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/CHANGELOG.md +6 -0
- package/core/esm/dev.js +657 -55
- package/core/esm/dev.js.map +1 -1
- package/core/esm/index.js +2 -2
- package/core/esm/index.js.map +1 -1
- package/dist/stardust.dev.js +30972 -30433
- package/dist/stardust.dev.js.map +1 -1
- package/dist/stardust.js +29 -35
- package/dist/stardust.js.map +1 -1
- package/package.json +9 -8
- package/types/index.d.ts +0 -15
package/core/esm/dev.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* @nebula.js/stardust v2.
|
|
2
|
+
* @nebula.js/stardust v2.10.0
|
|
3
3
|
* Copyright (c) 2022 QlikTech International AB
|
|
4
4
|
* Released under the MIT license.
|
|
5
5
|
*/
|
|
@@ -9,6 +9,8 @@ import ReactDOM from 'react-dom';
|
|
|
9
9
|
import { createGenerateClassName, StylesProvider, ThemeProvider, makeStyles, useTheme as useTheme$1 } from '@material-ui/styles';
|
|
10
10
|
import { Checkbox, Radio, Grid, FormControlLabel, Typography, IconButton, makeStyles as makeStyles$1, Popover, MenuList, MenuItem, ListItemIcon, Divider, OutlinedInput, InputAdornment, Badge, List, ListItem, Button, Box, Icon, CircularProgress, Paper } from '@material-ui/core';
|
|
11
11
|
|
|
12
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
13
|
+
|
|
12
14
|
var runtime = {exports: {}};
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -5275,7 +5277,7 @@ function useAppSelections(app) {
|
|
|
5275
5277
|
return [appSelections, navState];
|
|
5276
5278
|
}
|
|
5277
5279
|
|
|
5278
|
-
const NEBULA_VERSION_HASH = "
|
|
5280
|
+
const NEBULA_VERSION_HASH = "fcc9" ;
|
|
5279
5281
|
let counter = 0;
|
|
5280
5282
|
const NebulaApp = forwardRef((_ref, ref) => {
|
|
5281
5283
|
let {
|
|
@@ -5335,7 +5337,7 @@ function boot(_ref2) {
|
|
|
5335
5337
|
const appRef = React.createRef();
|
|
5336
5338
|
const element = document.createElement('div');
|
|
5337
5339
|
element.style.display = 'none';
|
|
5338
|
-
element.setAttribute('data-nebulajs-version', "2.
|
|
5340
|
+
element.setAttribute('data-nebulajs-version', "2.10.0" );
|
|
5339
5341
|
element.setAttribute('data-app-id', app.id);
|
|
5340
5342
|
document.body.appendChild(element);
|
|
5341
5343
|
ReactDOM.render( /*#__PURE__*/React.createElement(NebulaApp, {
|
|
@@ -6617,7 +6619,6 @@ function useSelectionsInteractions(_ref) {
|
|
|
6617
6619
|
layout,
|
|
6618
6620
|
selections,
|
|
6619
6621
|
pages = [],
|
|
6620
|
-
rangeSelect = true,
|
|
6621
6622
|
checkboxes = false,
|
|
6622
6623
|
selectDisabled,
|
|
6623
6624
|
doc = document,
|
|
@@ -6711,7 +6712,7 @@ function useSelectionsInteractions(_ref) {
|
|
|
6711
6712
|
const onMouseUp = useCallback(event => {
|
|
6712
6713
|
const elemNumber = +event.currentTarget.getAttribute('data-n');
|
|
6713
6714
|
|
|
6714
|
-
if (isSingleSelect || !
|
|
6715
|
+
if (isSingleSelect || !mouseDown || selectingValues || preSelected.length === 1 && preSelected[0] === elemNumber // prevent toggling again on mouseup
|
|
6715
6716
|
) {
|
|
6716
6717
|
return;
|
|
6717
6718
|
}
|
|
@@ -6775,17 +6776,12 @@ function useSelectionsInteractions(_ref) {
|
|
|
6775
6776
|
Object.assign(interactionEvents, {
|
|
6776
6777
|
onClick
|
|
6777
6778
|
});
|
|
6778
|
-
} else
|
|
6779
|
+
} else {
|
|
6779
6780
|
Object.assign(interactionEvents, {
|
|
6780
6781
|
onMouseUp,
|
|
6781
6782
|
onMouseDown,
|
|
6782
6783
|
onMouseEnter
|
|
6783
6784
|
});
|
|
6784
|
-
} else {
|
|
6785
|
-
Object.assign(interactionEvents, {
|
|
6786
|
-
onMouseUp,
|
|
6787
|
-
onMouseDown
|
|
6788
|
-
});
|
|
6789
6785
|
}
|
|
6790
6786
|
|
|
6791
6787
|
return {
|
|
@@ -6810,7 +6806,7 @@ var Tick = (props => SvgIcon(tick(props)));
|
|
|
6810
6806
|
const CheckboxChecked = "url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath" + " fill-rule='evenodd' clip-rule='evenodd' d='M12 5c-.28 0-.53.11-.71.29L7 9.59l-2.29-2.3a1.003 " + "1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29s.53-.11.71-.29l5-5A1.003 1.003 0 0012 5z' fill='%23fff'/%3E%3C/svg%3E\")";
|
|
6811
6807
|
|
|
6812
6808
|
const borderRadius = 2;
|
|
6813
|
-
const useStyles$
|
|
6809
|
+
const useStyles$e = makeStyles(theme => ({
|
|
6814
6810
|
cbIcon: {
|
|
6815
6811
|
borderRadius,
|
|
6816
6812
|
width: 16,
|
|
@@ -6858,12 +6854,13 @@ const useStyles$d = makeStyles(theme => ({
|
|
|
6858
6854
|
}));
|
|
6859
6855
|
|
|
6860
6856
|
const getIcon = function (styles) {
|
|
6861
|
-
let
|
|
6862
|
-
let
|
|
6857
|
+
let showGray = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
6858
|
+
let excluded = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
6859
|
+
let alternative = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
6863
6860
|
return /*#__PURE__*/React.createElement("span", {
|
|
6864
6861
|
className: styles.cbIcon
|
|
6865
6862
|
}, (excluded || alternative) && /*#__PURE__*/React.createElement("span", {
|
|
6866
|
-
className: [excluded && styles.cbIconExcluded, alternative && styles.cbIconAlternative].filter(Boolean).join(' ')
|
|
6863
|
+
className: [showGray && excluded && styles.cbIconExcluded, showGray && alternative && styles.cbIconAlternative].filter(Boolean).join(' ')
|
|
6867
6864
|
}));
|
|
6868
6865
|
};
|
|
6869
6866
|
|
|
@@ -6873,9 +6870,10 @@ function ListboxCheckbox(_ref) {
|
|
|
6873
6870
|
label,
|
|
6874
6871
|
dense,
|
|
6875
6872
|
excluded,
|
|
6876
|
-
alternative
|
|
6873
|
+
alternative,
|
|
6874
|
+
showGray = true
|
|
6877
6875
|
} = _ref;
|
|
6878
|
-
const styles = useStyles$
|
|
6876
|
+
const styles = useStyles$e();
|
|
6879
6877
|
return /*#__PURE__*/React.createElement(Checkbox, {
|
|
6880
6878
|
edge: "start",
|
|
6881
6879
|
checked: checked,
|
|
@@ -6885,7 +6883,7 @@ function ListboxCheckbox(_ref) {
|
|
|
6885
6883
|
'aria-labelledby': label
|
|
6886
6884
|
},
|
|
6887
6885
|
name: label,
|
|
6888
|
-
icon: getIcon(styles, excluded, alternative),
|
|
6886
|
+
icon: getIcon(styles, showGray, excluded, alternative),
|
|
6889
6887
|
checkedIcon: /*#__PURE__*/React.createElement("span", {
|
|
6890
6888
|
className: styles.cbIconChecked
|
|
6891
6889
|
})
|
|
@@ -6960,7 +6958,7 @@ function getSegmentsFromRanges(label, ranges) {
|
|
|
6960
6958
|
return labels;
|
|
6961
6959
|
}
|
|
6962
6960
|
|
|
6963
|
-
const useStyles$
|
|
6961
|
+
const useStyles$d = makeStyles(() => ({
|
|
6964
6962
|
denseRadioButton: {
|
|
6965
6963
|
height: '100%',
|
|
6966
6964
|
boxSizing: 'border-box',
|
|
@@ -6979,7 +6977,7 @@ function ListBoxRadioButton(_ref) {
|
|
|
6979
6977
|
label,
|
|
6980
6978
|
dense
|
|
6981
6979
|
} = _ref;
|
|
6982
|
-
const styles = useStyles$
|
|
6980
|
+
const styles = useStyles$d();
|
|
6983
6981
|
return /*#__PURE__*/React.createElement(Radio, {
|
|
6984
6982
|
checked: checked,
|
|
6985
6983
|
value: label,
|
|
@@ -7190,7 +7188,7 @@ const getSelectedStyle = _ref => {
|
|
|
7190
7188
|
};
|
|
7191
7189
|
};
|
|
7192
7190
|
|
|
7193
|
-
const useStyles$
|
|
7191
|
+
const useStyles$c = makeStyles(theme => ({
|
|
7194
7192
|
row: {
|
|
7195
7193
|
flexWrap: 'nowrap',
|
|
7196
7194
|
borderBottom: "1px solid ".concat(theme.palette.divider),
|
|
@@ -7333,12 +7331,13 @@ function RowColumn(_ref2) {
|
|
|
7333
7331
|
actions,
|
|
7334
7332
|
frequencyMax = '',
|
|
7335
7333
|
histogram = false,
|
|
7336
|
-
keyboard
|
|
7334
|
+
keyboard,
|
|
7335
|
+
showGray = true
|
|
7337
7336
|
} = data;
|
|
7338
7337
|
const handleKeyDownCallback = useCallback(getFieldKeyboardNavigation(actions), [actions]);
|
|
7339
7338
|
const [isSelected, setSelected] = useState$1(false);
|
|
7340
7339
|
const [cell, setCell] = useState$1();
|
|
7341
|
-
const classes = useStyles$
|
|
7340
|
+
const classes = useStyles$c();
|
|
7342
7341
|
const [classArr, setClassArr] = useState$1([]);
|
|
7343
7342
|
useEffect$1(() => {
|
|
7344
7343
|
if (!pages) {
|
|
@@ -7374,12 +7373,12 @@ function RowColumn(_ref2) {
|
|
|
7374
7373
|
|
|
7375
7374
|
if (!checkboxes) {
|
|
7376
7375
|
if (cell.qState === 'XS') {
|
|
7377
|
-
clazzArr.push(classes.XS);
|
|
7376
|
+
clazzArr.push(showGray ? classes.XS : classes.S);
|
|
7378
7377
|
} else if (cell.qState === 'S' || cell.qState === 'L') {
|
|
7379
7378
|
clazzArr.push(classes.S);
|
|
7380
|
-
} else if (isAlternative(cell)) {
|
|
7379
|
+
} else if (showGray && isAlternative(cell)) {
|
|
7381
7380
|
clazzArr.push(classes.A);
|
|
7382
|
-
} else if (isExcluded(cell)) {
|
|
7381
|
+
} else if (showGray && isExcluded(cell)) {
|
|
7383
7382
|
clazzArr.push(classes.X);
|
|
7384
7383
|
}
|
|
7385
7384
|
}
|
|
@@ -7402,7 +7401,7 @@ function RowColumn(_ref2) {
|
|
|
7402
7401
|
component: "span",
|
|
7403
7402
|
variant: "body2",
|
|
7404
7403
|
key: ix,
|
|
7405
|
-
className: joinClassNames([classes.labelText, highlighted && classes.highlighted, dense && classes.labelDense, excludedOrAlternative() && classes.excludedTextWithCheckbox]),
|
|
7404
|
+
className: joinClassNames([classes.labelText, highlighted && classes.highlighted, dense && classes.labelDense, showGray && excludedOrAlternative() && classes.excludedTextWithCheckbox]),
|
|
7406
7405
|
color: color
|
|
7407
7406
|
}, /*#__PURE__*/React.createElement("span", {
|
|
7408
7407
|
style: {
|
|
@@ -7431,7 +7430,8 @@ function RowColumn(_ref2) {
|
|
|
7431
7430
|
checked: isSelected,
|
|
7432
7431
|
dense: dense,
|
|
7433
7432
|
excluded: isExcluded(cell),
|
|
7434
|
-
alternative: isAlternative(cell)
|
|
7433
|
+
alternative: isAlternative(cell),
|
|
7434
|
+
showGray: showGray
|
|
7435
7435
|
});
|
|
7436
7436
|
const rb = /*#__PURE__*/React.createElement(ListBoxRadioButton, {
|
|
7437
7437
|
label: lbl,
|
|
@@ -7555,7 +7555,7 @@ function RowColumn(_ref2) {
|
|
|
7555
7555
|
noWrap: true,
|
|
7556
7556
|
color: "inherit",
|
|
7557
7557
|
variant: "body2",
|
|
7558
|
-
className: joinClassNames([dense && classes.labelDense, classes.labelText, excludedOrAlternative() && classes.excludedTextWithCheckbox])
|
|
7558
|
+
className: joinClassNames([dense && classes.labelDense, classes.labelText, showGray && excludedOrAlternative() && classes.excludedTextWithCheckbox])
|
|
7559
7559
|
}, getFrequencyText())), (showLock || showTick) && /*#__PURE__*/React.createElement(Grid, {
|
|
7560
7560
|
item: true,
|
|
7561
7561
|
className: classes.icon
|
|
@@ -7568,6 +7568,29 @@ function RowColumn(_ref2) {
|
|
|
7568
7568
|
}))));
|
|
7569
7569
|
}
|
|
7570
7570
|
|
|
7571
|
+
const scrollBarThumb = '#BBB';
|
|
7572
|
+
const scrollBarThumbHover = '#555';
|
|
7573
|
+
const scrollBarBackground = '#f1f1f1';
|
|
7574
|
+
const useStyles$b = makeStyles(() => ({
|
|
7575
|
+
styledScrollbars: {
|
|
7576
|
+
scrollbarColor: "".concat(scrollBarThumb, " ").concat(scrollBarBackground),
|
|
7577
|
+
'&::-webkit-scrollbar': {
|
|
7578
|
+
width: 10,
|
|
7579
|
+
height: 10
|
|
7580
|
+
},
|
|
7581
|
+
'&::-webkit-scrollbar-track': {
|
|
7582
|
+
backgroundColor: scrollBarBackground
|
|
7583
|
+
},
|
|
7584
|
+
'&::-webkit-scrollbar-thumb': {
|
|
7585
|
+
backgroundColor: scrollBarThumb,
|
|
7586
|
+
borderRadius: '1rem'
|
|
7587
|
+
},
|
|
7588
|
+
'&::-webkit-scrollbar-thumb:hover': {
|
|
7589
|
+
backgroundColor: scrollBarThumbHover
|
|
7590
|
+
}
|
|
7591
|
+
}
|
|
7592
|
+
}));
|
|
7593
|
+
|
|
7571
7594
|
function getSizeInfo(_ref) {
|
|
7572
7595
|
let {
|
|
7573
7596
|
isVertical,
|
|
@@ -7599,17 +7622,19 @@ function ListBox(_ref2) {
|
|
|
7599
7622
|
listLayout = 'vertical',
|
|
7600
7623
|
frequencyMode = 'N',
|
|
7601
7624
|
histogram = false,
|
|
7602
|
-
rangeSelect = true,
|
|
7603
7625
|
checkboxes = false,
|
|
7604
7626
|
update = undefined,
|
|
7627
|
+
fetchStart = undefined,
|
|
7605
7628
|
dense = false,
|
|
7606
7629
|
keyboard = {},
|
|
7630
|
+
showGray = true,
|
|
7607
7631
|
selectDisabled = () => false
|
|
7608
7632
|
} = _ref2;
|
|
7609
7633
|
const [layout] = useLayout$1(model);
|
|
7610
7634
|
const isSingleSelect = !!(layout && layout.qListObject.qDimensionInfo.qIsOneAndOnlyOne);
|
|
7611
7635
|
const [pages, setPages] = useState$1(null);
|
|
7612
7636
|
const [isLoadingData, setIsLoadingData] = useState$1(false);
|
|
7637
|
+
const styles = useStyles$b();
|
|
7613
7638
|
const {
|
|
7614
7639
|
instantPages = [],
|
|
7615
7640
|
interactionEvents,
|
|
@@ -7618,7 +7643,6 @@ function ListBox(_ref2) {
|
|
|
7618
7643
|
layout,
|
|
7619
7644
|
selections,
|
|
7620
7645
|
pages,
|
|
7621
|
-
rangeSelect,
|
|
7622
7646
|
checkboxes,
|
|
7623
7647
|
selectDisabled,
|
|
7624
7648
|
doc: document,
|
|
@@ -7643,7 +7667,9 @@ function ListBox(_ref2) {
|
|
|
7643
7667
|
|
|
7644
7668
|
const page = pages.filter(p => isLoaded(p))[0];
|
|
7645
7669
|
return page && isLoaded(page);
|
|
7646
|
-
}, [layout, pages]);
|
|
7670
|
+
}, [layout, pages]); // The time from scroll end until new data is being fetched, may be exposed in API later on.
|
|
7671
|
+
|
|
7672
|
+
const scrollTimeout = 0;
|
|
7647
7673
|
const loadMoreItems = useCallback((startIndex, stopIndex) => {
|
|
7648
7674
|
local.current.queue.push({
|
|
7649
7675
|
start: startIndex,
|
|
@@ -7660,7 +7686,7 @@ function ListBox(_ref2) {
|
|
|
7660
7686
|
return new Promise(resolve => {
|
|
7661
7687
|
local.current.timeout = setTimeout(() => {
|
|
7662
7688
|
const sorted = local.current.queue.slice(-2).sort((a, b) => a.start - b.start);
|
|
7663
|
-
model.getListObjectData('/qListObjectDef', sorted.map(s => ({
|
|
7689
|
+
const reqPromise = model.getListObjectData('/qListObjectDef', sorted.map(s => ({
|
|
7664
7690
|
qTop: s.start,
|
|
7665
7691
|
qHeight: s.stop - s.start + 1,
|
|
7666
7692
|
qLeft: 0,
|
|
@@ -7672,7 +7698,8 @@ function ListBox(_ref2) {
|
|
|
7672
7698
|
setIsLoadingData(false);
|
|
7673
7699
|
resolve();
|
|
7674
7700
|
});
|
|
7675
|
-
|
|
7701
|
+
fetchStart && fetchStart(reqPromise);
|
|
7702
|
+
}, isScrolling ? scrollTimeout : 0);
|
|
7676
7703
|
});
|
|
7677
7704
|
}, [layout]);
|
|
7678
7705
|
|
|
@@ -7748,6 +7775,7 @@ function ListBox(_ref2) {
|
|
|
7748
7775
|
width: width,
|
|
7749
7776
|
itemCount: count,
|
|
7750
7777
|
layout: listLayout,
|
|
7778
|
+
className: styles.styledScrollbars,
|
|
7751
7779
|
itemData: _objectSpread2(_objectSpread2({
|
|
7752
7780
|
isLocked,
|
|
7753
7781
|
column: !isVertical,
|
|
@@ -7764,7 +7792,8 @@ function ListBox(_ref2) {
|
|
|
7764
7792
|
},
|
|
7765
7793
|
frequencyMax,
|
|
7766
7794
|
histogram,
|
|
7767
|
-
keyboard
|
|
7795
|
+
keyboard,
|
|
7796
|
+
showGray
|
|
7768
7797
|
}),
|
|
7769
7798
|
itemSize: itemSize,
|
|
7770
7799
|
onItemsRendered: onItemsRendered,
|
|
@@ -10014,8 +10043,10 @@ function ListBoxInline(_ref) {
|
|
|
10014
10043
|
sessionModel = undefined,
|
|
10015
10044
|
selectionsApi = undefined,
|
|
10016
10045
|
update = undefined,
|
|
10046
|
+
fetchStart = undefined,
|
|
10017
10047
|
dense = false,
|
|
10018
|
-
selectDisabled = () => false
|
|
10048
|
+
selectDisabled = () => false,
|
|
10049
|
+
showGray = true
|
|
10019
10050
|
} = options;
|
|
10020
10051
|
let {
|
|
10021
10052
|
frequencyMode,
|
|
@@ -10295,9 +10326,11 @@ function ListBoxInline(_ref) {
|
|
|
10295
10326
|
height: height,
|
|
10296
10327
|
width: width,
|
|
10297
10328
|
update: update,
|
|
10329
|
+
fetchStart: fetchStart,
|
|
10298
10330
|
dense: dense,
|
|
10299
10331
|
selectDisabled: selectDisabled,
|
|
10300
|
-
keyboard: keyboard
|
|
10332
|
+
keyboard: keyboard,
|
|
10333
|
+
showGray: showGray
|
|
10301
10334
|
});
|
|
10302
10335
|
})));
|
|
10303
10336
|
}
|
|
@@ -11671,7 +11704,7 @@ function Error$1(_ref3) {
|
|
|
11671
11704
|
}));
|
|
11672
11705
|
}
|
|
11673
11706
|
|
|
11674
|
-
const _excluded$
|
|
11707
|
+
const _excluded$2 = ["size"];
|
|
11675
11708
|
const useStyles$3 = makeStyles(theme => ({
|
|
11676
11709
|
root: {
|
|
11677
11710
|
position: 'relative',
|
|
@@ -11697,7 +11730,7 @@ function Progress(_ref) {
|
|
|
11697
11730
|
let {
|
|
11698
11731
|
size = 'medium'
|
|
11699
11732
|
} = _ref,
|
|
11700
|
-
props = _objectWithoutProperties$1(_ref, _excluded$
|
|
11733
|
+
props = _objectWithoutProperties$1(_ref, _excluded$2);
|
|
11701
11734
|
|
|
11702
11735
|
const classes = useStyles$3();
|
|
11703
11736
|
const s = SIZES[size];
|
|
@@ -11718,7 +11751,7 @@ function Progress(_ref) {
|
|
|
11718
11751
|
}, props)));
|
|
11719
11752
|
}
|
|
11720
11753
|
|
|
11721
|
-
const _excluded = ["cancel", "translator"],
|
|
11754
|
+
const _excluded$1 = ["cancel", "translator"],
|
|
11722
11755
|
_excluded2 = ["retry", "translator"];
|
|
11723
11756
|
const useStyles$2 = makeStyles$1(() => ({
|
|
11724
11757
|
stripes: {
|
|
@@ -11740,7 +11773,7 @@ function Cancel(_ref) {
|
|
|
11740
11773
|
cancel,
|
|
11741
11774
|
translator
|
|
11742
11775
|
} = _ref,
|
|
11743
|
-
props = _objectWithoutProperties$1(_ref, _excluded);
|
|
11776
|
+
props = _objectWithoutProperties$1(_ref, _excluded$1);
|
|
11744
11777
|
|
|
11745
11778
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Grid, {
|
|
11746
11779
|
container: true,
|
|
@@ -13070,6 +13103,10 @@ function viz() {
|
|
|
13070
13103
|
|
|
13071
13104
|
takeSnapshot() {
|
|
13072
13105
|
return cellRef.current.takeSnapshot();
|
|
13106
|
+
},
|
|
13107
|
+
|
|
13108
|
+
getModel() {
|
|
13109
|
+
return model;
|
|
13073
13110
|
}
|
|
13074
13111
|
|
|
13075
13112
|
} // old QVisualization API
|
|
@@ -17343,9 +17380,9 @@ function create(_ref) {
|
|
|
17343
17380
|
};
|
|
17344
17381
|
}
|
|
17345
17382
|
|
|
17383
|
+
const _excluded = ["__DO_NOT_USE__"];
|
|
17346
17384
|
/**
|
|
17347
17385
|
* @interface Context
|
|
17348
|
-
* @property {boolean=} disableCellPadding
|
|
17349
17386
|
* @property {boolean=} keyboardNavigation
|
|
17350
17387
|
* @property {object=} constraints
|
|
17351
17388
|
* @property {boolean=} constraints.active
|
|
@@ -17460,6 +17497,59 @@ const mergeConfigs = (base, c) => ({
|
|
|
17460
17497
|
flags: mergeObj(base.flags, c.flags),
|
|
17461
17498
|
anything: mergeObj(base.anything, c.anything)
|
|
17462
17499
|
});
|
|
17500
|
+
/**
|
|
17501
|
+
* @ignore
|
|
17502
|
+
* @typedef {function(promise)} PromiseFunction A callback function which receives a request promise as the first argument.
|
|
17503
|
+
*/
|
|
17504
|
+
|
|
17505
|
+
/**
|
|
17506
|
+
* @ignore
|
|
17507
|
+
* @typedef {function(function)} ReceiverFunction A callback function which receives another function as input.
|
|
17508
|
+
*/
|
|
17509
|
+
|
|
17510
|
+
/**
|
|
17511
|
+
* @ignore
|
|
17512
|
+
* @typedef {object} DoNotUseOptions Options strictly recommended not to use as they might change anytime. Documenting them to keep track of them, but not exposing them to API docs.
|
|
17513
|
+
* @property {boolean=} [focusSearch=false] Initialize the Listbox with the search input focused. Only applicable when
|
|
17514
|
+
* search is true, since toggling will always focus the search input on show.
|
|
17515
|
+
* @property {boolean=} [options.showGray=true] Render fields or checkboxes in shades of gray instead of white when their state is excluded or alternative.
|
|
17516
|
+
* @property {object} [options.sessionModel] Use a custom sessionModel.
|
|
17517
|
+
* @property {object} [options.selectionsApi] Use a custom selectionsApi to customize how values are selected.
|
|
17518
|
+
* @property {function():boolean} [options.selectDisabled=] Define a function which tells when selections are disabled (true) or enabled (false). By default, always returns false.
|
|
17519
|
+
* @property {PromiseFunction} [options.fetchStart] A function called when the Listbox starts fetching data. Receives the fetch request promise as an argument.
|
|
17520
|
+
* @property {ReceiverFunction} [options.update] A function which receives an update function which upon call will trigger a data fetch.
|
|
17521
|
+
*/
|
|
17522
|
+
|
|
17523
|
+
/**
|
|
17524
|
+
* @ignore
|
|
17525
|
+
* @param {object} usersOptions Options sent in to fieldInstance.mount.
|
|
17526
|
+
* @param {DoNotUseOptions} __DO_NOT_USE__
|
|
17527
|
+
* @returns {object} Squashed options with defaults given for non-exposed options.
|
|
17528
|
+
*/
|
|
17529
|
+
|
|
17530
|
+
|
|
17531
|
+
const getOptions = function () {
|
|
17532
|
+
let usersOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
17533
|
+
|
|
17534
|
+
const {
|
|
17535
|
+
__DO_NOT_USE__ = {}
|
|
17536
|
+
} = usersOptions,
|
|
17537
|
+
exposedOptions = _objectWithoutProperties$1(usersOptions, _excluded);
|
|
17538
|
+
|
|
17539
|
+
const DO_NOT_USE_DEFAULTS = {
|
|
17540
|
+
update: undefined,
|
|
17541
|
+
fetchStart: undefined,
|
|
17542
|
+
showGray: true,
|
|
17543
|
+
focusSearch: false,
|
|
17544
|
+
sessionModel: undefined,
|
|
17545
|
+
selectionsApi: undefined,
|
|
17546
|
+
selectDisabled: undefined
|
|
17547
|
+
};
|
|
17548
|
+
|
|
17549
|
+
const squashedOptions = _objectSpread2(_objectSpread2(_objectSpread2({}, exposedOptions), DO_NOT_USE_DEFAULTS), __DO_NOT_USE__);
|
|
17550
|
+
|
|
17551
|
+
return squashedOptions;
|
|
17552
|
+
};
|
|
17463
17553
|
|
|
17464
17554
|
function nuked() {
|
|
17465
17555
|
let configuration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -17703,10 +17793,6 @@ function nuked() {
|
|
|
17703
17793
|
* @typedef { boolean | 'toggle' } SearchMode
|
|
17704
17794
|
*/
|
|
17705
17795
|
|
|
17706
|
-
/**
|
|
17707
|
-
* @typedef {function(function)} ReceiverFunction A callback function which receives another function as input.
|
|
17708
|
-
*/
|
|
17709
|
-
|
|
17710
17796
|
/**
|
|
17711
17797
|
* @class
|
|
17712
17798
|
* @alias FieldInstance
|
|
@@ -17727,18 +17813,12 @@ function nuked() {
|
|
|
17727
17813
|
* @param {FrequencyMode=} [options.frequencyMode=none] Show frequency none|value|percent|relative
|
|
17728
17814
|
* @param {boolean=} [options.histogram=false] Show histogram bar
|
|
17729
17815
|
* @param {SearchMode=} [options.search=true] Show the search bar permanently or using the toggle button: false|true|toggle|toggleShow
|
|
17730
|
-
* @param {boolean=} [options.focusSearch=false] Initialize the Listbox with the search input focused. Only applicable when
|
|
17731
|
-
* search is true, since toggling will always focus the search input on show.
|
|
17732
17816
|
* @param {boolean=} [options.toolbar=true] Show the toolbar
|
|
17733
17817
|
* @param {boolean=} [options.checkboxes=false] Show values as checkboxes instead of as fields
|
|
17734
|
-
* @param {boolean=} [options.rangeSelect=true] Enable range selection
|
|
17735
17818
|
* @param {boolean=} [options.dense=false] Reduces padding and text size
|
|
17736
17819
|
* @param {boolean=} [options.stateName="$"] Sets the state to make selections in
|
|
17737
17820
|
* @param {object=} [options.properties={}] Properties object to extend default properties with
|
|
17738
|
-
*
|
|
17739
|
-
* @param {object} [options.selectionsApi] Use a custom selectionsApi to customize how values are selected.
|
|
17740
|
-
* @param {function():boolean} [options.selectDisabled=] Define a function which tells when selections are disabled (true) or enabled (false). By default, always returns false.
|
|
17741
|
-
* @param {ReceiverFunction} [options.update] A function which receives an update function which upon call will trigger a data fetch.
|
|
17821
|
+
*
|
|
17742
17822
|
* @since 1.1.0
|
|
17743
17823
|
* @instance
|
|
17744
17824
|
* @example
|
|
@@ -17759,7 +17839,7 @@ function nuked() {
|
|
|
17759
17839
|
element,
|
|
17760
17840
|
app,
|
|
17761
17841
|
fieldIdentifier,
|
|
17762
|
-
options,
|
|
17842
|
+
options: getOptions(options),
|
|
17763
17843
|
stateName: options.stateName || '$'
|
|
17764
17844
|
});
|
|
17765
17845
|
root.add(this._instance);
|
|
@@ -17856,13 +17936,535 @@ function nuked() {
|
|
|
17856
17936
|
|
|
17857
17937
|
var index = nuked(DEFAULT_CONFIG);
|
|
17858
17938
|
|
|
17939
|
+
var enigmaMocker_dev = {exports: {}};
|
|
17940
|
+
|
|
17941
|
+
/*
|
|
17942
|
+
* @nebula.js/enigma-mocker v2.9.0
|
|
17943
|
+
* Copyright (c) 2022 QlikTech International AB
|
|
17944
|
+
* Released under the MIT license.
|
|
17945
|
+
*/
|
|
17946
|
+
|
|
17947
|
+
(function (module, exports) {
|
|
17948
|
+
(function (global, factory) {
|
|
17949
|
+
module.exports = factory() ;
|
|
17950
|
+
})(commonjsGlobal, function () {
|
|
17951
|
+
|
|
17952
|
+
function SessionMock() {
|
|
17953
|
+
return {
|
|
17954
|
+
getObjectApi() {
|
|
17955
|
+
return Promise.resolve({
|
|
17956
|
+
id: "sessapi - ".concat(+Date.now())
|
|
17957
|
+
});
|
|
17958
|
+
}
|
|
17959
|
+
|
|
17960
|
+
};
|
|
17961
|
+
}
|
|
17962
|
+
|
|
17963
|
+
function ownKeys(object, enumerableOnly) {
|
|
17964
|
+
var keys = Object.keys(object);
|
|
17965
|
+
|
|
17966
|
+
if (Object.getOwnPropertySymbols) {
|
|
17967
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
17968
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
17969
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
17970
|
+
})), keys.push.apply(keys, symbols);
|
|
17971
|
+
}
|
|
17972
|
+
|
|
17973
|
+
return keys;
|
|
17974
|
+
}
|
|
17975
|
+
|
|
17976
|
+
function _objectSpread2(target) {
|
|
17977
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
17978
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
17979
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
17980
|
+
_defineProperty(target, key, source[key]);
|
|
17981
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
17982
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
17983
|
+
});
|
|
17984
|
+
}
|
|
17985
|
+
|
|
17986
|
+
return target;
|
|
17987
|
+
}
|
|
17988
|
+
|
|
17989
|
+
function _defineProperty(obj, key, value) {
|
|
17990
|
+
if (key in obj) {
|
|
17991
|
+
Object.defineProperty(obj, key, {
|
|
17992
|
+
value: value,
|
|
17993
|
+
enumerable: true,
|
|
17994
|
+
configurable: true,
|
|
17995
|
+
writable: true
|
|
17996
|
+
});
|
|
17997
|
+
} else {
|
|
17998
|
+
obj[key] = value;
|
|
17999
|
+
}
|
|
18000
|
+
|
|
18001
|
+
return obj;
|
|
18002
|
+
}
|
|
18003
|
+
|
|
18004
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
18005
|
+
if (source == null) return {};
|
|
18006
|
+
var target = {};
|
|
18007
|
+
var sourceKeys = Object.keys(source);
|
|
18008
|
+
var key, i;
|
|
18009
|
+
|
|
18010
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
18011
|
+
key = sourceKeys[i];
|
|
18012
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
18013
|
+
target[key] = source[key];
|
|
18014
|
+
}
|
|
18015
|
+
|
|
18016
|
+
return target;
|
|
18017
|
+
}
|
|
18018
|
+
|
|
18019
|
+
function _objectWithoutProperties(source, excluded) {
|
|
18020
|
+
if (source == null) return {};
|
|
18021
|
+
|
|
18022
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
18023
|
+
|
|
18024
|
+
var key, i;
|
|
18025
|
+
|
|
18026
|
+
if (Object.getOwnPropertySymbols) {
|
|
18027
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
18028
|
+
|
|
18029
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
18030
|
+
key = sourceSymbolKeys[i];
|
|
18031
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
18032
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
18033
|
+
target[key] = source[key];
|
|
18034
|
+
}
|
|
18035
|
+
}
|
|
18036
|
+
|
|
18037
|
+
return target;
|
|
18038
|
+
}
|
|
18039
|
+
|
|
18040
|
+
var hasOwn = Object.prototype.hasOwnProperty;
|
|
18041
|
+
var toStr = Object.prototype.toString;
|
|
18042
|
+
var defineProperty = Object.defineProperty;
|
|
18043
|
+
var gOPD = Object.getOwnPropertyDescriptor;
|
|
18044
|
+
|
|
18045
|
+
var isArray = function isArray(arr) {
|
|
18046
|
+
if (typeof Array.isArray === 'function') {
|
|
18047
|
+
return Array.isArray(arr);
|
|
18048
|
+
}
|
|
18049
|
+
|
|
18050
|
+
return toStr.call(arr) === '[object Array]';
|
|
18051
|
+
};
|
|
18052
|
+
|
|
18053
|
+
var isPlainObject = function isPlainObject(obj) {
|
|
18054
|
+
if (!obj || toStr.call(obj) !== '[object Object]') {
|
|
18055
|
+
return false;
|
|
18056
|
+
}
|
|
18057
|
+
|
|
18058
|
+
var hasOwnConstructor = hasOwn.call(obj, 'constructor');
|
|
18059
|
+
var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf'); // Not own constructor property must be Object
|
|
18060
|
+
|
|
18061
|
+
if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
|
|
18062
|
+
return false;
|
|
18063
|
+
} // Own properties are enumerated firstly, so to speed up,
|
|
18064
|
+
// if last one is own, then all properties are own.
|
|
18065
|
+
|
|
18066
|
+
|
|
18067
|
+
var key;
|
|
18068
|
+
|
|
18069
|
+
for (key in obj) {
|
|
18070
|
+
/**/
|
|
18071
|
+
}
|
|
18072
|
+
|
|
18073
|
+
return typeof key === 'undefined' || hasOwn.call(obj, key);
|
|
18074
|
+
}; // If name is '__proto__', and Object.defineProperty is available, define __proto__ as an own property on target
|
|
18075
|
+
|
|
18076
|
+
|
|
18077
|
+
var setProperty = function setProperty(target, options) {
|
|
18078
|
+
if (defineProperty && options.name === '__proto__') {
|
|
18079
|
+
defineProperty(target, options.name, {
|
|
18080
|
+
enumerable: true,
|
|
18081
|
+
configurable: true,
|
|
18082
|
+
value: options.newValue,
|
|
18083
|
+
writable: true
|
|
18084
|
+
});
|
|
18085
|
+
} else {
|
|
18086
|
+
target[options.name] = options.newValue;
|
|
18087
|
+
}
|
|
18088
|
+
}; // Return undefined instead of __proto__ if '__proto__' is not an own property
|
|
18089
|
+
|
|
18090
|
+
|
|
18091
|
+
var getProperty = function getProperty(obj, name) {
|
|
18092
|
+
if (name === '__proto__') {
|
|
18093
|
+
if (!hasOwn.call(obj, name)) {
|
|
18094
|
+
return void 0;
|
|
18095
|
+
} else if (gOPD) {
|
|
18096
|
+
// In early versions of node, obj['__proto__'] is buggy when obj has
|
|
18097
|
+
// __proto__ as an own property. Object.getOwnPropertyDescriptor() works.
|
|
18098
|
+
return gOPD(obj, name).value;
|
|
18099
|
+
}
|
|
18100
|
+
}
|
|
18101
|
+
|
|
18102
|
+
return obj[name];
|
|
18103
|
+
};
|
|
18104
|
+
|
|
18105
|
+
var extend = function extend() {
|
|
18106
|
+
var options, name, src, copy, copyIsArray, clone;
|
|
18107
|
+
var target = arguments[0];
|
|
18108
|
+
var i = 1;
|
|
18109
|
+
var length = arguments.length;
|
|
18110
|
+
var deep = false; // Handle a deep copy situation
|
|
18111
|
+
|
|
18112
|
+
if (typeof target === 'boolean') {
|
|
18113
|
+
deep = target;
|
|
18114
|
+
target = arguments[1] || {}; // skip the boolean and the target
|
|
18115
|
+
|
|
18116
|
+
i = 2;
|
|
18117
|
+
}
|
|
18118
|
+
|
|
18119
|
+
if (target == null || typeof target !== 'object' && typeof target !== 'function') {
|
|
18120
|
+
target = {};
|
|
18121
|
+
}
|
|
18122
|
+
|
|
18123
|
+
for (; i < length; ++i) {
|
|
18124
|
+
options = arguments[i]; // Only deal with non-null/undefined values
|
|
18125
|
+
|
|
18126
|
+
if (options != null) {
|
|
18127
|
+
// Extend the base object
|
|
18128
|
+
for (name in options) {
|
|
18129
|
+
src = getProperty(target, name);
|
|
18130
|
+
copy = getProperty(options, name); // Prevent never-ending loop
|
|
18131
|
+
|
|
18132
|
+
if (target !== copy) {
|
|
18133
|
+
// Recurse if we're merging plain objects or arrays
|
|
18134
|
+
if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
|
|
18135
|
+
if (copyIsArray) {
|
|
18136
|
+
copyIsArray = false;
|
|
18137
|
+
clone = src && isArray(src) ? src : [];
|
|
18138
|
+
} else {
|
|
18139
|
+
clone = src && isPlainObject(src) ? src : {};
|
|
18140
|
+
} // Never move original objects, clone them
|
|
18141
|
+
|
|
18142
|
+
|
|
18143
|
+
setProperty(target, {
|
|
18144
|
+
name: name,
|
|
18145
|
+
newValue: extend(deep, clone, copy)
|
|
18146
|
+
}); // Don't bring in undefined values
|
|
18147
|
+
} else if (typeof copy !== 'undefined') {
|
|
18148
|
+
setProperty(target, {
|
|
18149
|
+
name: name,
|
|
18150
|
+
newValue: copy
|
|
18151
|
+
});
|
|
18152
|
+
}
|
|
18153
|
+
}
|
|
18154
|
+
}
|
|
18155
|
+
}
|
|
18156
|
+
} // Return the modified object
|
|
18157
|
+
|
|
18158
|
+
|
|
18159
|
+
return target;
|
|
18160
|
+
};
|
|
18161
|
+
|
|
18162
|
+
function CreateSessionObjectMock() {
|
|
18163
|
+
return props => {
|
|
18164
|
+
const mockedInclusions = props ? props._mock : null;
|
|
18165
|
+
let layout = props;
|
|
18166
|
+
|
|
18167
|
+
if (mockedInclusions) {
|
|
18168
|
+
delete props._mock; // eslint-disable-line no-param-reassign
|
|
18169
|
+
|
|
18170
|
+
layout = extend({}, props, mockedInclusions);
|
|
18171
|
+
}
|
|
18172
|
+
|
|
18173
|
+
return Promise.resolve(_objectSpread2({
|
|
18174
|
+
on: () => {},
|
|
18175
|
+
once: () => {},
|
|
18176
|
+
getLayout: () => Promise.resolve(layout),
|
|
18177
|
+
getProperties: () => Promise.resolve(props),
|
|
18178
|
+
getEffectiveProperties: () => Promise.resolve(props),
|
|
18179
|
+
id: props && props.qInfo && props.qInfo.qId ? props.qInfo.qId : "sel - ".concat(+Date.now())
|
|
18180
|
+
}, props));
|
|
18181
|
+
};
|
|
18182
|
+
}
|
|
18183
|
+
/**
|
|
18184
|
+
* Get value for a fixture property.
|
|
18185
|
+
*
|
|
18186
|
+
* The value is either static (e.g. pass a string / object / similar) or dynamic when passing a function.
|
|
18187
|
+
*
|
|
18188
|
+
* It falls back to the default value in case the fixture has no value specified.
|
|
18189
|
+
*
|
|
18190
|
+
* Example
|
|
18191
|
+
* ```js
|
|
18192
|
+
* const fixture = {
|
|
18193
|
+
* id: 'grid-chart-1',
|
|
18194
|
+
* };
|
|
18195
|
+
* const app = {
|
|
18196
|
+
* id: getValue(fixture.id, { defaultValue: 'object-id-${+Date.now()}'}),
|
|
18197
|
+
* }
|
|
18198
|
+
* ```
|
|
18199
|
+
*
|
|
18200
|
+
* @param {any} prop Fixture property. Either a fixed value (string / object / boolean / ...) or a function invoked when the value is needed.
|
|
18201
|
+
* @param {object} options Options.
|
|
18202
|
+
* @param {Array<any>} options.args Arguments used to evaluate the property value.
|
|
18203
|
+
* @param {any} options.defaultValue Default value in case not value is defined in fixture.
|
|
18204
|
+
* @returns The property value.
|
|
18205
|
+
*/
|
|
18206
|
+
|
|
18207
|
+
|
|
18208
|
+
const getPropValue = function (prop) {
|
|
18209
|
+
let {
|
|
18210
|
+
args = [],
|
|
18211
|
+
defaultValue
|
|
18212
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
18213
|
+
|
|
18214
|
+
if (typeof prop === 'function') {
|
|
18215
|
+
return prop(...args);
|
|
18216
|
+
}
|
|
18217
|
+
|
|
18218
|
+
if (prop !== undefined) {
|
|
18219
|
+
return prop;
|
|
18220
|
+
}
|
|
18221
|
+
|
|
18222
|
+
return defaultValue;
|
|
18223
|
+
};
|
|
18224
|
+
/**
|
|
18225
|
+
* Get function for a fixture property.
|
|
18226
|
+
*
|
|
18227
|
+
* When the returned function is invoked it resolves the value - using `defaultValue` as fallback - and returns it. The value is returned as a promise if `option.usePromise` is `true`.
|
|
18228
|
+
*
|
|
18229
|
+
* Example:
|
|
18230
|
+
* ```js
|
|
18231
|
+
* const fixture = {
|
|
18232
|
+
* getHyperCubeData(path, page) {
|
|
18233
|
+
* return [ ... ];
|
|
18234
|
+
* }
|
|
18235
|
+
* }
|
|
18236
|
+
* const app = {
|
|
18237
|
+
* getHyperCubeData: getPropFn(fixture.getHyperCubeData, { defaultValue: [], usePromise: true })
|
|
18238
|
+
* };
|
|
18239
|
+
* ```
|
|
18240
|
+
*
|
|
18241
|
+
* @param {any} prop Fixture property. Either a fixed value (string / object / boolean / ...) or a function invoked when the value is needed.
|
|
18242
|
+
* @param {object} options Options.
|
|
18243
|
+
* @param {any} options.defaultValue Default value in case not value is defined in fixture.
|
|
18244
|
+
* @param {boolean} options.async When `true` the returns value is wrapped in a promise, otherwise the value is directly returned.
|
|
18245
|
+
* @param {number} options.number Delay before value is returned.
|
|
18246
|
+
* @returns A fixture property function
|
|
18247
|
+
*/
|
|
18248
|
+
|
|
18249
|
+
|
|
18250
|
+
const getPropFn = function (prop) {
|
|
18251
|
+
let {
|
|
18252
|
+
defaultValue,
|
|
18253
|
+
async = true,
|
|
18254
|
+
delay = 0
|
|
18255
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
18256
|
+
return function () {
|
|
18257
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
18258
|
+
args[_key] = arguments[_key];
|
|
18259
|
+
}
|
|
18260
|
+
|
|
18261
|
+
const value = getPropValue(prop, {
|
|
18262
|
+
defaultValue,
|
|
18263
|
+
args
|
|
18264
|
+
});
|
|
18265
|
+
return async ? new Promise(resolve => {
|
|
18266
|
+
setTimeout(() => resolve(value), delay);
|
|
18267
|
+
}) : value;
|
|
18268
|
+
};
|
|
18269
|
+
};
|
|
18270
|
+
|
|
18271
|
+
const _excluded = ["id", "session"];
|
|
18272
|
+
/**
|
|
18273
|
+
* Properties on `getObject()` operating synchronously.
|
|
18274
|
+
*/
|
|
18275
|
+
|
|
18276
|
+
const PROPS_SYNC = ['addListener', 'emit', 'listeners', 'on', 'once', 'removeAllListeners', 'removeListener', 'setMaxListerners'];
|
|
18277
|
+
/**
|
|
18278
|
+
* Is property operating asynchrously.
|
|
18279
|
+
* @param {string} name Property name.
|
|
18280
|
+
* @returns `true` if property is operating asynchrously, otherwise `false`.
|
|
18281
|
+
*/
|
|
18282
|
+
|
|
18283
|
+
function isPropAsync(name) {
|
|
18284
|
+
return !PROPS_SYNC.includes(name);
|
|
18285
|
+
}
|
|
18286
|
+
/**
|
|
18287
|
+
* Get `qId` for visualization.
|
|
18288
|
+
* @param {object} genericObject Generic object describing behaviour of mock
|
|
18289
|
+
* @returns The `qId`, undefined if not present
|
|
18290
|
+
*/
|
|
18291
|
+
|
|
18292
|
+
|
|
18293
|
+
function getQId(genericObject) {
|
|
18294
|
+
const layout = getPropValue(genericObject.getLayout);
|
|
18295
|
+
return layout.qInfo && layout.qInfo.qId;
|
|
18296
|
+
}
|
|
18297
|
+
/**
|
|
18298
|
+
* Create a mock of a generic object. Mandatory properties are added, functions returns async values where applicable etc.
|
|
18299
|
+
* @param {object} genericObject Generic object describing behaviour of mock
|
|
18300
|
+
* @param {EnigmaMockerOptions} options Options.
|
|
18301
|
+
* @returns The mocked object
|
|
18302
|
+
*/
|
|
18303
|
+
|
|
18304
|
+
|
|
18305
|
+
function createMock(genericObject, options) {
|
|
18306
|
+
const qId = getQId(genericObject);
|
|
18307
|
+
const {
|
|
18308
|
+
delay
|
|
18309
|
+
} = options;
|
|
18310
|
+
|
|
18311
|
+
const {
|
|
18312
|
+
id,
|
|
18313
|
+
session
|
|
18314
|
+
} = genericObject,
|
|
18315
|
+
props = _objectWithoutProperties(genericObject, _excluded);
|
|
18316
|
+
|
|
18317
|
+
const mock = _objectSpread2({
|
|
18318
|
+
id: getPropValue(id, {
|
|
18319
|
+
defaultValue: "object - ".concat(+Date.now())
|
|
18320
|
+
}),
|
|
18321
|
+
session: getPropValue(session, {
|
|
18322
|
+
defaultValue: true
|
|
18323
|
+
}),
|
|
18324
|
+
on: () => {},
|
|
18325
|
+
once: () => {}
|
|
18326
|
+
}, Object.entries(props).reduce((fns, _ref) => {
|
|
18327
|
+
let [name, value] = _ref;
|
|
18328
|
+
return _objectSpread2(_objectSpread2({}, fns), {}, {
|
|
18329
|
+
[name]: getPropFn(value, {
|
|
18330
|
+
async: isPropAsync(name),
|
|
18331
|
+
delay
|
|
18332
|
+
})
|
|
18333
|
+
});
|
|
18334
|
+
}, {}));
|
|
18335
|
+
|
|
18336
|
+
return {
|
|
18337
|
+
[qId]: mock
|
|
18338
|
+
};
|
|
18339
|
+
}
|
|
18340
|
+
/**
|
|
18341
|
+
* Create mocked objects from list of generic objects.
|
|
18342
|
+
* @param {Array<object>} genericObjects Generic objects describing behaviour of mock
|
|
18343
|
+
* @param {EnigmaMockerOptions} options options
|
|
18344
|
+
* @returns Object with mocks where key is `qId` and value is the mocked object.
|
|
18345
|
+
*/
|
|
18346
|
+
|
|
18347
|
+
|
|
18348
|
+
function createMocks(genericObjects, options) {
|
|
18349
|
+
return genericObjects.reduce((mocks, genericObject) => _objectSpread2(_objectSpread2({}, mocks), createMock(genericObject, options)), {});
|
|
18350
|
+
}
|
|
18351
|
+
/**
|
|
18352
|
+
* Validates if mandatory information is available.
|
|
18353
|
+
* @param {object} genericObject Generic object to validate
|
|
18354
|
+
* @throws {}
|
|
18355
|
+
* <ul>
|
|
18356
|
+
* <li>{Error} If getLayout is missing</li>
|
|
18357
|
+
* <li>{Error} If getLayout.qInfo.qId is missing</li>
|
|
18358
|
+
* </ul>
|
|
18359
|
+
*/
|
|
18360
|
+
|
|
18361
|
+
|
|
18362
|
+
function validate(genericObject) {
|
|
18363
|
+
if (!genericObject.getLayout) {
|
|
18364
|
+
throw new Error('Generic object is missing "getLayout"');
|
|
18365
|
+
}
|
|
18366
|
+
|
|
18367
|
+
const qId = getQId(genericObject);
|
|
18368
|
+
|
|
18369
|
+
if (!qId) {
|
|
18370
|
+
throw new Error('Generic object is missing "qId" for path "getLayout().qInfo.qId"');
|
|
18371
|
+
}
|
|
18372
|
+
}
|
|
18373
|
+
/**
|
|
18374
|
+
* Creates mock of `getObject(id)` based on an array of generic objects.
|
|
18375
|
+
* @param {Array<object>} genericObjects Generic objects.
|
|
18376
|
+
* @param {EnigmaMockerOptions} options Options.
|
|
18377
|
+
* @returns Function to retrieve the mocked generic object with the corresponding id.
|
|
18378
|
+
*/
|
|
18379
|
+
|
|
18380
|
+
|
|
18381
|
+
function GetObjectMock() {
|
|
18382
|
+
let genericObjects = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
18383
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
18384
|
+
|
|
18385
|
+
if (!Array.isArray(genericObjects) || genericObjects.length === 0) {
|
|
18386
|
+
return () => {
|
|
18387
|
+
throw new Error('No "genericObjects" specified');
|
|
18388
|
+
};
|
|
18389
|
+
}
|
|
18390
|
+
|
|
18391
|
+
genericObjects.forEach(validate);
|
|
18392
|
+
const mocks = createMocks(genericObjects, options);
|
|
18393
|
+
return async id => Promise.resolve(mocks[id]);
|
|
18394
|
+
}
|
|
18395
|
+
|
|
18396
|
+
function GetAppLayoutMock() {
|
|
18397
|
+
return () => Promise.resolve({
|
|
18398
|
+
id: 'app-layout'
|
|
18399
|
+
});
|
|
18400
|
+
}
|
|
18401
|
+
/**
|
|
18402
|
+
* @interface EnigmaMockerOptions
|
|
18403
|
+
* @property {number} delay Simulate delay (in ms) for calls in enigma-mocker.
|
|
18404
|
+
*/
|
|
18405
|
+
|
|
18406
|
+
/**
|
|
18407
|
+
* Mocks Engima app functionality. It accepts one / many generic objects as input argument and returns the mocked Enigma app. Each generic object represents one visulization and specifies how it behaves. For example, what layout to use the data to present.
|
|
18408
|
+
*
|
|
18409
|
+
* The generic object is represented with a Javascript object with a number of properties. The name of the property correlates to the name in the Enigma model for `app.getObject(id)`. For example, the property `getLayout` in the generic object is used to define `app.getObject(id).getLayout()`. Any property can be added to the fixture (just make sure it exists and behaves as in the Enigma model!).
|
|
18410
|
+
*
|
|
18411
|
+
* The value for each property is either fixed (string / boolean / number / object) or a function. Arguments are forwarded to the function to allow for greater flexibility. For example, this can be used to return different hypercube data when scrolling in the chart.
|
|
18412
|
+
*
|
|
18413
|
+
* @param {Array<object>} genericObjects Generic objects controling behaviour of visualizations.
|
|
18414
|
+
* @param {EnigmaMockerOptions} options Options
|
|
18415
|
+
* @returns {Promise<enigma.Doc>}
|
|
18416
|
+
* @example
|
|
18417
|
+
* const genericObject = {
|
|
18418
|
+
* getLayout() {
|
|
18419
|
+
* return {
|
|
18420
|
+
* qInfo: {
|
|
18421
|
+
* qId: 'qqj4zx',
|
|
18422
|
+
* qType: 'sn-grid-chart'
|
|
18423
|
+
* },
|
|
18424
|
+
* ...
|
|
18425
|
+
* }
|
|
18426
|
+
* },
|
|
18427
|
+
* getHyperCubeData(path, page) {
|
|
18428
|
+
* return [ ... ];
|
|
18429
|
+
* }
|
|
18430
|
+
* };
|
|
18431
|
+
* const app = await EnigmaMocker.fromGenericObjects([genericObject]);
|
|
18432
|
+
*/
|
|
18433
|
+
|
|
18434
|
+
|
|
18435
|
+
var fromGenericObjects = function (genericObjects) {
|
|
18436
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
18437
|
+
const session = new SessionMock();
|
|
18438
|
+
const createSessionObject = new CreateSessionObjectMock();
|
|
18439
|
+
const getObject = new GetObjectMock(genericObjects, options);
|
|
18440
|
+
const getAppLayout = new GetAppLayoutMock();
|
|
18441
|
+
const app = {
|
|
18442
|
+
id: "app - ".concat(+Date.now()),
|
|
18443
|
+
session,
|
|
18444
|
+
createSessionObject,
|
|
18445
|
+
getObject,
|
|
18446
|
+
getAppLayout
|
|
18447
|
+
};
|
|
18448
|
+
return Promise.resolve(app);
|
|
18449
|
+
};
|
|
18450
|
+
|
|
18451
|
+
var index = {
|
|
18452
|
+
fromGenericObjects
|
|
18453
|
+
};
|
|
18454
|
+
return index;
|
|
18455
|
+
});
|
|
18456
|
+
})(enigmaMocker_dev);
|
|
18457
|
+
|
|
18458
|
+
var enigmaMocker = enigmaMocker_dev.exports;
|
|
18459
|
+
|
|
17859
18460
|
/* eslint no-underscore-dangle: 0 */
|
|
17860
18461
|
|
|
17861
18462
|
const __DO_NOT_USE__ = {
|
|
17862
18463
|
generator: generatorFn,
|
|
17863
18464
|
hook,
|
|
17864
18465
|
theme,
|
|
17865
|
-
locale
|
|
18466
|
+
locale,
|
|
18467
|
+
EnigmaMocker: enigmaMocker
|
|
17866
18468
|
};
|
|
17867
18469
|
|
|
17868
18470
|
export { __DO_NOT_USE__, conversion, index as embed, onTakeSnapshot, useAction, useApp, useAppLayout, useConstraints, useDeviceType, useEffect, useElement, useEmbed, useGlobal, useImperativeHandle, useKeyboard, useLayout, useMemo, useModel, useOptions, usePlugins, usePromise, useRect, useRenderState, useSelections, useStaleLayout, useState, useTheme, useTranslator };
|