@nebula.js/stardust 3.3.0-alpha.0 → 3.3.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/core/esm/dev.js CHANGED
@@ -1,14 +1,14 @@
1
1
  /*
2
- * @nebula.js/stardust v3.3.0-alpha.0
2
+ * @nebula.js/stardust v3.3.0
3
3
  * Copyright (c) 2023 QlikTech International AB
4
4
  * Released under the MIT license.
5
5
  */
6
6
 
7
7
  import * as React from 'react';
8
- import React__default, { useState as useState$1, useEffect as useEffect$1, useReducer, forwardRef, useMemo as useMemo$1, useImperativeHandle as useImperativeHandle$1, useCallback, useLayoutEffect as useLayoutEffect$1, PureComponent, useRef, createElement, useContext } from 'react';
8
+ import React__default, { useState as useState$1, useEffect as useEffect$1, forwardRef, useMemo as useMemo$1, useImperativeHandle as useImperativeHandle$1, useReducer, useCallback, useLayoutEffect as useLayoutEffect$1, PureComponent, useRef, createElement, useContext } from 'react';
9
9
  import ReactDOM from 'react-dom';
10
10
  import { CacheProvider, ThemeContext as ThemeContext$2 } from '@emotion/react';
11
- import { Checkbox, Radio, Grid, Typography, FormControlLabel, Tooltip, Paper, IconButton, Popover, MenuList, MenuItem, ListItemIcon, Divider, InputAdornment, OutlinedInput, Badge, List, ListItem, Button, Box, Icon, CircularProgress } from '@mui/material';
11
+ import { Checkbox, Radio, Typography, FormControlLabel, Grid, Tooltip, Paper, IconButton, Popover, MenuList, MenuItem, ListItemIcon, Divider, InputAdornment, OutlinedInput, Badge, List, ListItem, Button, Box, Icon, CircularProgress } from '@mui/material';
12
12
  import styled$3 from '@emotion/styled';
13
13
 
14
14
  function getAugmentedNamespace(n) {
@@ -7972,7 +7972,7 @@ function create$3(definition) {
7972
7972
  return cache[key];
7973
7973
  }
7974
7974
 
7975
- const NEBULA_VERSION_HASH = "c721" ;
7975
+ const NEBULA_VERSION_HASH = "593e" ;
7976
7976
  ClassNameGenerator$1.configure(componentName => {
7977
7977
  return "njs-".concat(NEBULA_VERSION_HASH, "-").concat(componentName.replace('Mui', ''));
7978
7978
  });
@@ -8027,6 +8027,212 @@ var createKeyStore = (function () {
8027
8027
  return [useKeyStore, store];
8028
8028
  });
8029
8029
 
8030
+ const [useAppSelectionsStore, appSelectionsStore] = createKeyStore({});
8031
+ const [useAppModalStore, appModalStore] = createKeyStore({});
8032
+ const [useObjectSelectionsStore, objectSelectionsStore] = createKeyStore({});
8033
+ const [useModalObjectStore, modalObjectStore] = createKeyStore({});
8034
+
8035
+ /* eslint no-underscore-dangle: 0 */
8036
+ function createAppSelections(_ref) {
8037
+ let {
8038
+ app
8039
+ } = _ref;
8040
+ const key = "".concat(app.id);
8041
+ const end = async function () {
8042
+ let accept = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
8043
+ const model = modalObjectStore.get(key);
8044
+ if (model) {
8045
+ await model.endSelections(accept);
8046
+ modalObjectStore.clear(key);
8047
+ const objectSelections = objectSelectionsStore.get(model.id);
8048
+ objectSelections.emit('deactivated');
8049
+ }
8050
+ };
8051
+ const begin = async function (model, path) {
8052
+ let accept = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
8053
+ // Quick return if it's already in modal
8054
+ if (model === modalObjectStore.get(key)) {
8055
+ return;
8056
+ }
8057
+
8058
+ // If other model is in modal state end it
8059
+ end(accept);
8060
+
8061
+ // Pending modal
8062
+ modalObjectStore.set(key, model);
8063
+ const p = Array.isArray(path) ? path : [path];
8064
+ const beginSelections = async skipRetry => {
8065
+ try {
8066
+ await model.beginSelections(p);
8067
+ modalObjectStore.set(key, model); // We have a modal
8068
+ } catch (err) {
8069
+ if (err.code === 6003 && !skipRetry) {
8070
+ await app.abortModal(accept);
8071
+ beginSelections(true);
8072
+ } else {
8073
+ modalObjectStore.clear(key); // No modal
8074
+ }
8075
+ }
8076
+ };
8077
+
8078
+ await beginSelections();
8079
+ };
8080
+ const appModal = {
8081
+ begin,
8082
+ end
8083
+ };
8084
+ appModalStore.set(key, appModal);
8085
+
8086
+ /**
8087
+ * @class
8088
+ * @alias AppSelections
8089
+ */
8090
+ const appSelections = {
8091
+ model: app,
8092
+ isInModal() {
8093
+ return !!modalObjectStore.get(key);
8094
+ },
8095
+ isModal(object) {
8096
+ // TODO check model state
8097
+ return object ? modalObjectStore.get(key) === object : !!modalObjectStore.get(key);
8098
+ },
8099
+ forward() {
8100
+ return appModal.end().then(() => app.forward());
8101
+ },
8102
+ back() {
8103
+ return appModal.end().then(() => app.back());
8104
+ },
8105
+ clear() {
8106
+ return appModal.end().then(() => app.clearAll());
8107
+ },
8108
+ clearField(field) {
8109
+ let state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '$';
8110
+ return appModal.end().then(() => app.getField(field, state).then(f => f.clear()));
8111
+ }
8112
+ };
8113
+ return appSelections;
8114
+ }
8115
+ function useAppSelections(app) {
8116
+ if (!app.session) {
8117
+ // assume the app is mocked if session is undefined
8118
+ return [];
8119
+ }
8120
+ const [appSelectionsStore] = useAppSelectionsStore();
8121
+ const key = app ? app.id : null;
8122
+ let appSelections = appSelectionsStore.get(key);
8123
+ useEffect$1(() => {
8124
+ if (!app || appSelections) return;
8125
+ appSelections = createAppSelections({
8126
+ app
8127
+ });
8128
+ appSelectionsStore.set(key, appSelections);
8129
+ appSelectionsStore.dispatch(true);
8130
+ }, [app]);
8131
+ return [appSelections];
8132
+ }
8133
+
8134
+ const NebulaApp = forwardRef((_ref, ref) => {
8135
+ let {
8136
+ initialContext,
8137
+ app
8138
+ } = _ref;
8139
+ const [appSelections] = useAppSelections(app);
8140
+ const [context, setContext] = useState$1(initialContext);
8141
+ const [muiThemeName, setMuiThemeName] = useState$1();
8142
+ const {
8143
+ theme
8144
+ } = useMemo$1(() => ({
8145
+ theme: create$3(muiThemeName)
8146
+ }), [muiThemeName]);
8147
+ const [components, setComponents] = useState$1([]);
8148
+ useImperativeHandle$1(ref, () => ({
8149
+ addComponent(component) {
8150
+ setComponents([...components, component]);
8151
+ },
8152
+ removeComponent(component) {
8153
+ const ix = components.indexOf(component);
8154
+ if (ix !== -1) {
8155
+ components.splice(ix, 1);
8156
+ setComponents([...components]);
8157
+ }
8158
+ },
8159
+ setMuiThemeName,
8160
+ setContext: ctx => setContext(oldContext => JSON.stringify(oldContext) !== JSON.stringify(ctx) ? ctx : oldContext),
8161
+ getAppSelections: () => appSelections
8162
+ }));
8163
+ return /*#__PURE__*/React__default.createElement(StyledEngineProvider, {
8164
+ injectFirst: true
8165
+ }, /*#__PURE__*/React__default.createElement(ThemeProvider, {
8166
+ theme: theme
8167
+ }, /*#__PURE__*/React__default.createElement(InstanceContext.Provider, {
8168
+ value: context
8169
+ }, components)));
8170
+ });
8171
+ function boot(_ref2) {
8172
+ let {
8173
+ app,
8174
+ context
8175
+ } = _ref2;
8176
+ let resolveRender;
8177
+ const rendered = new Promise(resolve => {
8178
+ resolveRender = resolve;
8179
+ });
8180
+ const appRef = React__default.createRef();
8181
+ const element = document.createElement('div');
8182
+ element.style.display = 'none';
8183
+ element.setAttribute('data-nebulajs-version', "3.3.0" );
8184
+ element.setAttribute('data-app-id', app.id);
8185
+ document.body.appendChild(element);
8186
+ ReactDOM.render( /*#__PURE__*/React__default.createElement(NebulaApp, {
8187
+ ref: appRef,
8188
+ app: app,
8189
+ initialContext: context
8190
+ }), element, resolveRender);
8191
+ const cells = {};
8192
+ return [{
8193
+ toggleFocusOfCells(cellIdToFocus) {
8194
+ Object.keys(cells).forEach(i => {
8195
+ cells[i].current.toggleFocus(i === cellIdToFocus);
8196
+ });
8197
+ },
8198
+ cells,
8199
+ addCell(id, cell) {
8200
+ cells[id] = cell;
8201
+ },
8202
+ removeCell(id) {
8203
+ delete cells[id];
8204
+ },
8205
+ add(component) {
8206
+ (async () => {
8207
+ await rendered;
8208
+ appRef.current.addComponent(component);
8209
+ })();
8210
+ },
8211
+ remove(component) {
8212
+ (async () => {
8213
+ await rendered;
8214
+ appRef.current.removeComponent(component);
8215
+ })();
8216
+ },
8217
+ setMuiThemeName(themeName) {
8218
+ (async () => {
8219
+ await rendered;
8220
+ appRef.current.setMuiThemeName(themeName);
8221
+ })();
8222
+ },
8223
+ context(ctx) {
8224
+ (async () => {
8225
+ await rendered;
8226
+ appRef.current.setContext(ctx);
8227
+ })();
8228
+ },
8229
+ getAppSelections: async () => {
8230
+ await rendered;
8231
+ return appRef.current.getAppSelections();
8232
+ }
8233
+ }, appRef, rendered];
8234
+ }
8235
+
8030
8236
  const [useRpcResultStore, rpcResultStore] = createKeyStore({});
8031
8237
  const [useRpcRequestStore, rpcRequestStore] = createKeyStore({});
8032
8238
  const [useRpcRequestSessionModelStore, rpcRequestSessionModelStore] = createKeyStore({});
@@ -8079,6 +8285,51 @@ const subscribe = model => {
8079
8285
  };
8080
8286
  };
8081
8287
 
8288
+ function useSessionModel(definition, app) {
8289
+ const key = app ? "".concat(app.id, "/").concat(JSON.stringify(definition)) : null;
8290
+ const [modelStore] = useModelStore();
8291
+ const [rpcRequestSessionModelStore] = useRpcRequestSessionModelStore();
8292
+ const [model, setModel] = useState$1();
8293
+ let rpcShared;
8294
+ if (key) {
8295
+ rpcShared = rpcRequestSessionModelStore.get(key);
8296
+ }
8297
+ for (var _len = arguments.length, deps = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
8298
+ deps[_key - 2] = arguments[_key];
8299
+ }
8300
+ useEffect$1(() => {
8301
+ if (!app) {
8302
+ return;
8303
+ }
8304
+ // Create new session object
8305
+ const create = async () => {
8306
+ if (!rpcShared) {
8307
+ const rpc = app.createSessionObject(definition);
8308
+ rpcShared = rpc;
8309
+ rpcRequestSessionModelStore.set(key, rpcShared);
8310
+ }
8311
+ const newModel = await rpcShared;
8312
+ modelStore.set(key, newModel);
8313
+ setModel(newModel);
8314
+ };
8315
+ create();
8316
+ }, [app, ...deps]);
8317
+ return [model];
8318
+ }
8319
+
8320
+ const definition = {
8321
+ qInfo: {
8322
+ qType: 'current-selections'
8323
+ },
8324
+ qSelectionObjectDef: {
8325
+ qStateName: '$'
8326
+ },
8327
+ alternateStates: []
8328
+ };
8329
+ function useCurrentSelectionsModel(app) {
8330
+ return useSessionModel(definition, app);
8331
+ }
8332
+
8082
8333
  const rpcReducer = (state, action) => {
8083
8334
  const {
8084
8335
  rpcResultStore,
@@ -8230,530 +8481,216 @@ function useAppLayout$1(model) {
8230
8481
  return useRpc(model, 'getAppLayout');
8231
8482
  }
8232
8483
 
8233
- function useSessionModel(definition, app) {
8234
- const key = app ? "".concat(app.id, "/").concat(JSON.stringify(definition)) : null;
8235
- const [modelStore] = useModelStore();
8236
- const [rpcRequestSessionModelStore] = useRpcRequestSessionModelStore();
8237
- const [model, setModel] = useState$1();
8238
- let rpcShared;
8239
- if (key) {
8240
- rpcShared = rpcRequestSessionModelStore.get(key);
8241
- }
8242
- for (var _len = arguments.length, deps = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
8243
- deps[_key - 2] = arguments[_key];
8244
- }
8245
- useEffect$1(() => {
8246
- if (!app) {
8484
+ function useRect$1() {
8485
+ const [node, setNode] = useState$1();
8486
+ const [rect, setRect] = useState$1();
8487
+ const callbackRef = useCallback(ref => {
8488
+ if (!ref) {
8247
8489
  return;
8248
8490
  }
8249
- // Create new session object
8250
- const create = async () => {
8251
- if (!rpcShared) {
8252
- const rpc = app.createSessionObject(definition);
8253
- rpcShared = rpc;
8254
- rpcRequestSessionModelStore.set(key, rpcShared);
8255
- }
8256
- const newModel = await rpcShared;
8257
- modelStore.set(key, newModel);
8258
- setModel(newModel);
8491
+ setNode(ref);
8492
+ }, []);
8493
+ const handleResize = () => {
8494
+ const {
8495
+ left,
8496
+ top,
8497
+ width,
8498
+ height
8499
+ } = node.getBoundingClientRect();
8500
+ setRect({
8501
+ left,
8502
+ top,
8503
+ width,
8504
+ height
8505
+ });
8506
+ };
8507
+ useLayoutEffect$1(() => {
8508
+ if (!node) {
8509
+ return undefined;
8510
+ }
8511
+ if (typeof ResizeObserver === 'function') {
8512
+ let resizeObserver = new ResizeObserver(handleResize);
8513
+ resizeObserver.observe(node);
8514
+ return () => {
8515
+ resizeObserver.unobserve(node);
8516
+ resizeObserver.disconnect(node);
8517
+ resizeObserver = null;
8518
+ };
8519
+ }
8520
+ handleResize();
8521
+ window.addEventListener('resize', handleResize);
8522
+ return () => {
8523
+ window.removeEventListener('resize', handleResize);
8259
8524
  };
8260
- create();
8261
- }, [app, ...deps]);
8262
- return [model];
8263
- }
8264
-
8265
- const definition = {
8266
- qInfo: {
8267
- qType: 'current-selections'
8268
- },
8269
- qSelectionObjectDef: {
8270
- qStateName: '$'
8271
- },
8272
- alternateStates: []
8273
- };
8274
- function useCurrentSelectionsModel(app) {
8275
- return useSessionModel(definition, app);
8525
+ }, [node]);
8526
+ return [callbackRef, rect, node];
8276
8527
  }
8277
8528
 
8278
- const patchAlternateState = (currentSelectionsModel, currentSelectionsLayout, appLayout) => {
8279
- const states = [...(appLayout.qStateNames || [])].map(s => ({
8280
- stateName: s,
8281
- // need this as reference in selection toolbar since qSelectionObject.qStateName is not in the layout
8282
- qSelectionObjectDef: {
8283
- qStateName: s
8284
- }
8285
- }));
8286
- const existingStates = (currentSelectionsLayout && currentSelectionsLayout.alternateStates ? currentSelectionsLayout.alternateStates.map(s => s.stateName) : []).join('::');
8287
- const newStates = (appLayout.qStateNames || []).map(s => s).join('::');
8288
- if (existingStates !== newStates) {
8289
- currentSelectionsModel.applyPatches([{
8290
- qOp: 'replace',
8291
- qPath: '/alternateStates',
8292
- qValue: JSON.stringify(states)
8293
- }], true);
8529
+ function getFontSize(size) {
8530
+ if (size === 'large') {
8531
+ return '20px';
8294
8532
  }
8295
- };
8296
- function useAppSelectionsNavigation(app) {
8297
- const [currentSelectionsModel] = useCurrentSelectionsModel(app);
8298
- const [currentSelectionsLayout] = useLayout$1(currentSelectionsModel);
8299
- const [appLayout] = useAppLayout$1(app);
8300
- const [navigationState, setNavigationState] = useState$1(null);
8301
- useEffect$1(() => {
8302
- if (!appLayout || !currentSelectionsModel || !currentSelectionsLayout) return;
8303
- patchAlternateState(currentSelectionsModel, currentSelectionsLayout, appLayout);
8304
- }, [appLayout, currentSelectionsModel, currentSelectionsLayout]);
8305
- useEffect$1(() => {
8306
- if (!currentSelectionsLayout) return;
8307
- let canGoBack = false;
8308
- let canGoForward = false;
8309
- let canClear = false;
8310
- [currentSelectionsLayout, ...(currentSelectionsLayout.alternateStates || [])].forEach(state => {
8311
- canGoBack = canGoBack || state.qSelectionObject && state.qSelectionObject.qBackCount > 0;
8312
- canGoForward = canGoForward || state.qSelectionObject && state.qSelectionObject.qForwardCount > 0;
8313
- canClear = canClear || (state.qSelectionObject && state.qSelectionObject.qSelections || []).filter(s => s.qLocked !== true).length > 0;
8314
- });
8315
- setNavigationState({
8316
- canGoBack,
8317
- canGoForward,
8318
- canClear
8319
- });
8320
- }, [currentSelectionsLayout]);
8321
- return [navigationState, currentSelectionsModel, currentSelectionsLayout];
8533
+ if (size === 'small') {
8534
+ return '12px';
8535
+ }
8536
+ return '16px';
8322
8537
  }
8323
-
8324
- const [useAppSelectionsStore, appSelectionsStore] = createKeyStore({});
8325
- const [useAppModalStore, appModalStore] = createKeyStore({});
8326
- const [useObjectSelectionsStore, objectSelectionsStore] = createKeyStore({});
8327
- const [useModalObjectStore, modalObjectStore] = createKeyStore({});
8328
-
8329
- /* eslint no-underscore-dangle: 0 */
8330
- function createAppSelections(_ref) {
8538
+ function SvgIcon$2(_ref) {
8331
8539
  let {
8332
- app,
8333
- currentSelectionsLayout,
8334
- navState
8540
+ size,
8541
+ style = {},
8542
+ viewBox = '0 0 16 16',
8543
+ shapes = []
8335
8544
  } = _ref;
8336
- const key = "".concat(app.id);
8337
- const end = async function () {
8338
- let accept = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
8339
- const model = modalObjectStore.get(key);
8340
- if (model) {
8341
- await model.endSelections(accept);
8342
- modalObjectStore.clear(key);
8343
- const objectSelections = objectSelectionsStore.get(model.id);
8344
- objectSelections.emit('deactivated');
8545
+ const s = _objectSpread2({
8546
+ fontSize: getFontSize(size),
8547
+ display: 'inline-block',
8548
+ fontStyle: 'normal',
8549
+ lineHeight: '0',
8550
+ textAlign: 'center',
8551
+ textTransform: 'none',
8552
+ verticalAlign: '-.125em',
8553
+ textRendering: 'optimizeLegibility',
8554
+ WebkitFontSmoothing: 'antialiased',
8555
+ MozOsxFontSmoothing: 'grayscale'
8556
+ }, style);
8557
+ return /*#__PURE__*/React__default.createElement("i", {
8558
+ style: s
8559
+ }, /*#__PURE__*/React__default.createElement("svg", {
8560
+ xmlns: "http://www.w3.org/2000/svg",
8561
+ width: "1em",
8562
+ height: "1em",
8563
+ viewBox: viewBox,
8564
+ fill: "currentColor"
8565
+ }, shapes.map((_ref2, ix) => {
8566
+ let {
8567
+ type: Type,
8568
+ attrs
8569
+ } = _ref2;
8570
+ return (
8571
+ /*#__PURE__*/
8572
+ // eslint-disable-next-line react/no-array-index-key
8573
+ React__default.createElement(Type, _extends$6({
8574
+ key: ix
8575
+ }, attrs))
8576
+ );
8577
+ })));
8578
+ }
8579
+
8580
+ const remove = props => _objectSpread2(_objectSpread2({}, props), {}, {
8581
+ shapes: [{
8582
+ type: 'path',
8583
+ attrs: {
8584
+ d: 'M9.41421356,8 L11.8890873,5.52512627 C12.065864,5.34834957 12.0305087,4.95944084 11.8183766,4.74730881 L11.2526912,4.18162338 C11.0405592,3.96949135 10.6516504,3.93413601 10.4748737,4.1109127 L8,6.58578644 L5.52512627,4.1109127 C5.34834957,3.93413601 4.95944084,3.96949135 4.74730881,4.18162338 L4.25233406,4.67659813 C3.96949135,4.95944084 3.93413601,5.34834957 4.1109127,5.52512627 L6.58578644,8 L4.1109127,10.4748737 C3.93413601,10.6516504 3.96949135,11.0405592 4.18162338,11.2526912 L4.67659813,11.7476659 C4.95944084,12.0305087 5.34834957,12.065864 5.52512627,11.8890873 L8,9.41421356 L10.4748737,11.8890873 C10.6516504,12.065864 11.0405592,12.0305087 11.2526912,11.8183766 L11.8183766,11.2526912 C12.0305087,11.0405592 12.065864,10.6516504 11.8890873,10.4748737 L9.41421356,8 Z M8,0 C12.4,0 16,3.6 16,8 C16,12.4 12.4,16 8,16 C3.6,16 0,12.4 0,8 C0,3.6 3.6,0 8,0 Z'
8345
8585
  }
8346
- };
8347
- const begin = async function (model, path) {
8348
- let accept = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
8349
- // Quick return if it's already in modal
8350
- if (model === modalObjectStore.get(key)) {
8351
- return;
8586
+ }]
8587
+ });
8588
+ var Remove = (props => SvgIcon$2(remove(props)));
8589
+
8590
+ const lock = props => _objectSpread2(_objectSpread2({}, props), {}, {
8591
+ shapes: [{
8592
+ type: 'path',
8593
+ attrs: {
8594
+ d: 'M8 10a1 1 0 0 1 .5 1.866v.634a.5.5 0 0 1-1 0v-.634A1 1 0 0 1 8 10ZM3.625 7.035A2 2 0 0 0 2 9v5a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V9a2 2 0 0 0-1.625-1.965V5.383a4.375 4.375 0 0 0-8.75 0v1.652ZM3 9a1 1 0 0 1 .931-.998h8.138A1 1 0 0 1 13 9v5a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V9Zm8.375-3.617V7h-6.75V5.383a3.375 3.375 0 0 1 6.75 0Z'
8352
8595
  }
8596
+ }]
8597
+ });
8598
+ var Lock = (props => SvgIcon$2(lock(props)));
8353
8599
 
8354
- // If other model is in modal state end it
8355
- end(accept);
8600
+ const unlock = props => _objectSpread2(_objectSpread2({}, props), {}, {
8601
+ shapes: [{
8602
+ type: 'path',
8603
+ attrs: {
8604
+ d: 'M2.5,7 L11,7 C11.5522847,7 12,7.44771525 12,8 L12,15 C12,15.5522847 11.5522847,16 11,16 L1,16 C0.44771525,16 0,15.5522847 0,15 L0,8 C0,7.44771525 0.44771525,7 1,7 L1,4.98151367 C1,2.23029964 3.23857625,0 6,0 C8.4241995,0 10.4454541,1.71883353 10.9029715,4 L9.34209114,4 C8.9671727,2.54028848 7.9088888,1.5 6,1.5 C3.54860291,1.5 2.5,3.21561511 2.5,5.33193359 L2.5,7 Z'
8605
+ }
8606
+ }]
8607
+ });
8608
+ var Unlock = (props => SvgIcon$2(unlock(props)));
8356
8609
 
8357
- // Pending modal
8358
- modalObjectStore.set(key, model);
8359
- const p = Array.isArray(path) ? path : [path];
8360
- const beginSelections = async skipRetry => {
8361
- try {
8362
- await model.beginSelections(p);
8363
- modalObjectStore.set(key, model); // We have a modal
8364
- } catch (err) {
8365
- if (err.code === 6003 && !skipRetry) {
8366
- await app.abortModal(accept);
8367
- beginSelections(true);
8368
- } else {
8369
- modalObjectStore.clear(key); // No modal
8370
- }
8371
- }
8372
- };
8610
+ function isRangeVisible(_ref) {
8611
+ var lastRenderedStartIndex = _ref.lastRenderedStartIndex,
8612
+ lastRenderedStopIndex = _ref.lastRenderedStopIndex,
8613
+ startIndex = _ref.startIndex,
8614
+ stopIndex = _ref.stopIndex;
8373
8615
 
8374
- await beginSelections();
8375
- };
8376
- const appModal = {
8377
- begin,
8378
- end
8379
- };
8380
- appModalStore.set(key, appModal);
8616
+ return !(startIndex > lastRenderedStopIndex || stopIndex < lastRenderedStartIndex);
8617
+ }
8381
8618
 
8382
- /**
8383
- * @class
8384
- * @alias AppSelections
8385
- */
8386
- const appSelections = {
8387
- model: app,
8388
- isInModal() {
8389
- return !!modalObjectStore.get(key);
8390
- },
8391
- isModal(object) {
8392
- // TODO check model state
8393
- return object ? modalObjectStore.get(key) === object : !!modalObjectStore.get(key);
8394
- },
8395
- canGoForward() {
8396
- return navState.canGoForward;
8397
- },
8398
- canGoBack() {
8399
- return navState.canGoBack;
8400
- },
8401
- canClear() {
8402
- return navState.canClear;
8403
- },
8404
- layout() {
8405
- return currentSelectionsLayout;
8406
- },
8407
- forward() {
8408
- return appModal.end().then(() => app.forward());
8409
- },
8410
- back() {
8411
- return appModal.end().then(() => app.back());
8412
- },
8413
- clear() {
8414
- return appModal.end().then(() => app.clearAll());
8415
- },
8416
- clearField(field) {
8417
- let state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '$';
8418
- return appModal.end().then(() => app.getField(field, state).then(f => f.clear()));
8619
+ function scanForUnloadedRanges(_ref) {
8620
+ var isItemLoaded = _ref.isItemLoaded,
8621
+ itemCount = _ref.itemCount,
8622
+ minimumBatchSize = _ref.minimumBatchSize,
8623
+ startIndex = _ref.startIndex,
8624
+ stopIndex = _ref.stopIndex;
8625
+
8626
+ var unloadedRanges = [];
8627
+
8628
+ var rangeStartIndex = null;
8629
+ var rangeStopIndex = null;
8630
+
8631
+ for (var _index = startIndex; _index <= stopIndex; _index++) {
8632
+ var loaded = isItemLoaded(_index);
8633
+
8634
+ if (!loaded) {
8635
+ rangeStopIndex = _index;
8636
+ if (rangeStartIndex === null) {
8637
+ rangeStartIndex = _index;
8638
+ }
8639
+ } else if (rangeStopIndex !== null) {
8640
+ unloadedRanges.push(rangeStartIndex, rangeStopIndex);
8641
+
8642
+ rangeStartIndex = rangeStopIndex = null;
8419
8643
  }
8420
- };
8421
- return appSelections;
8422
- }
8423
- function useAppSelections(app) {
8424
- if (!app.session) {
8425
- // assume the app is mocked if session is undefined
8426
- return [];
8427
8644
  }
8428
- const [navState, currentSelectionsModel, currentSelectionsLayout] = useAppSelectionsNavigation(app);
8429
- const [appSelectionsStore] = useAppSelectionsStore();
8430
- const key = app ? app.id : null;
8431
- let appSelections = appSelectionsStore.get(key);
8432
- useEffect$1(() => {
8433
- if (!app || !currentSelectionsModel || !currentSelectionsLayout || !navState || appSelections) return;
8434
- appSelections = createAppSelections({
8435
- app,
8436
- currentSelectionsLayout,
8437
- navState
8438
- });
8439
- appSelectionsStore.set(key, appSelections);
8440
- appSelectionsStore.dispatch(true);
8441
- }, [app, currentSelectionsModel, currentSelectionsLayout, navState]);
8442
- return [appSelections, navState];
8443
- }
8444
8645
 
8445
- const NebulaApp = forwardRef((_ref, ref) => {
8446
- let {
8447
- initialContext,
8448
- app
8449
- } = _ref;
8450
- const [appSelections] = useAppSelections(app);
8451
- const [context, setContext] = useState$1(initialContext);
8452
- const [muiThemeName, setMuiThemeName] = useState$1();
8453
- const {
8454
- theme
8455
- } = useMemo$1(() => ({
8456
- theme: create$3(muiThemeName)
8457
- }), [muiThemeName]);
8458
- const [components, setComponents] = useState$1([]);
8459
- useImperativeHandle$1(ref, () => ({
8460
- addComponent(component) {
8461
- setComponents([...components, component]);
8462
- },
8463
- removeComponent(component) {
8464
- const ix = components.indexOf(component);
8465
- if (ix !== -1) {
8466
- components.splice(ix, 1);
8467
- setComponents([...components]);
8646
+ // If :rangeStopIndex is not null it means we haven't ran out of unloaded rows.
8647
+ // Scan forward to try filling our :minimumBatchSize.
8648
+ if (rangeStopIndex !== null) {
8649
+ var potentialStopIndex = Math.min(Math.max(rangeStopIndex, rangeStartIndex + minimumBatchSize - 1), itemCount - 1);
8650
+
8651
+ for (var _index2 = rangeStopIndex + 1; _index2 <= potentialStopIndex; _index2++) {
8652
+ if (!isItemLoaded(_index2)) {
8653
+ rangeStopIndex = _index2;
8654
+ } else {
8655
+ break;
8468
8656
  }
8469
- },
8470
- setMuiThemeName,
8471
- setContext,
8472
- getAppSelections: () => appSelections
8473
- }));
8474
- return /*#__PURE__*/React__default.createElement(StyledEngineProvider, {
8475
- injectFirst: true
8476
- }, /*#__PURE__*/React__default.createElement(ThemeProvider, {
8477
- theme: theme
8478
- }, /*#__PURE__*/React__default.createElement(InstanceContext.Provider, {
8479
- value: context
8480
- }, components)));
8481
- });
8482
- function boot(_ref2) {
8483
- let {
8484
- app,
8485
- context
8486
- } = _ref2;
8487
- let resolveRender;
8488
- const rendered = new Promise(resolve => {
8489
- resolveRender = resolve;
8490
- });
8491
- const appRef = React__default.createRef();
8492
- const element = document.createElement('div');
8493
- element.style.display = 'none';
8494
- element.setAttribute('data-nebulajs-version', "3.3.0-alpha.0" );
8495
- element.setAttribute('data-app-id', app.id);
8496
- document.body.appendChild(element);
8497
- ReactDOM.render( /*#__PURE__*/React__default.createElement(NebulaApp, {
8498
- ref: appRef,
8499
- app: app,
8500
- initialContext: context
8501
- }), element, resolveRender);
8502
- const cells = {};
8503
- return [{
8504
- toggleFocusOfCells(cellIdToFocus) {
8505
- Object.keys(cells).forEach(i => {
8506
- cells[i].current.toggleFocus(i === cellIdToFocus);
8507
- });
8508
- },
8509
- cells,
8510
- addCell(id, cell) {
8511
- cells[id] = cell;
8512
- },
8513
- removeCell(id) {
8514
- delete cells[id];
8515
- },
8516
- add(component) {
8517
- (async () => {
8518
- await rendered;
8519
- appRef.current.addComponent(component);
8520
- })();
8521
- },
8522
- remove(component) {
8523
- (async () => {
8524
- await rendered;
8525
- appRef.current.removeComponent(component);
8526
- })();
8527
- },
8528
- setMuiThemeName(themeName) {
8529
- (async () => {
8530
- await rendered;
8531
- appRef.current.setMuiThemeName(themeName);
8532
- })();
8533
- },
8534
- context(ctx) {
8535
- (async () => {
8536
- await rendered;
8537
- appRef.current.setContext(ctx);
8538
- })();
8539
- },
8540
- getAppSelections: async () => {
8541
- await rendered;
8542
- return appRef.current.getAppSelections();
8543
8657
  }
8544
- }, appRef, rendered];
8545
- }
8546
8658
 
8547
- function useRect$1() {
8548
- const [node, setNode] = useState$1();
8549
- const [rect, setRect] = useState$1();
8550
- const callbackRef = useCallback(ref => {
8551
- if (!ref) {
8552
- return;
8553
- }
8554
- setNode(ref);
8555
- }, []);
8556
- const handleResize = () => {
8557
- const {
8558
- left,
8559
- top,
8560
- width,
8561
- height
8562
- } = node.getBoundingClientRect();
8563
- setRect({
8564
- left,
8565
- top,
8566
- width,
8567
- height
8568
- });
8569
- };
8570
- useLayoutEffect$1(() => {
8571
- if (!node) {
8572
- return undefined;
8573
- }
8574
- if (typeof ResizeObserver === 'function') {
8575
- let resizeObserver = new ResizeObserver(handleResize);
8576
- resizeObserver.observe(node);
8577
- return () => {
8578
- resizeObserver.unobserve(node);
8579
- resizeObserver.disconnect(node);
8580
- resizeObserver = null;
8581
- };
8659
+ unloadedRanges.push(rangeStartIndex, rangeStopIndex);
8660
+ }
8661
+
8662
+ // Check to see if our first range ended prematurely.
8663
+ // In this case we should scan backwards to try filling our :minimumBatchSize.
8664
+ if (unloadedRanges.length) {
8665
+ while (unloadedRanges[1] - unloadedRanges[0] + 1 < minimumBatchSize && unloadedRanges[0] > 0) {
8666
+ var _index3 = unloadedRanges[0] - 1;
8667
+
8668
+ if (!isItemLoaded(_index3)) {
8669
+ unloadedRanges[0] = _index3;
8670
+ } else {
8671
+ break;
8672
+ }
8582
8673
  }
8583
- handleResize();
8584
- window.addEventListener('resize', handleResize);
8585
- return () => {
8586
- window.removeEventListener('resize', handleResize);
8587
- };
8588
- }, [node]);
8589
- return [callbackRef, rect, node];
8674
+ }
8675
+
8676
+ return unloadedRanges;
8590
8677
  }
8591
8678
 
8592
- function getFontSize(size) {
8593
- if (size === 'large') {
8594
- return '20px';
8679
+ var classCallCheck$1 = function (instance, Constructor) {
8680
+ if (!(instance instanceof Constructor)) {
8681
+ throw new TypeError("Cannot call a class as a function");
8595
8682
  }
8596
- if (size === 'small') {
8597
- return '12px';
8598
- }
8599
- return '16px';
8600
- }
8601
- function SvgIcon$2(_ref) {
8602
- let {
8603
- size,
8604
- style = {},
8605
- viewBox = '0 0 16 16',
8606
- shapes = []
8607
- } = _ref;
8608
- const s = _objectSpread2({
8609
- fontSize: getFontSize(size),
8610
- display: 'inline-block',
8611
- fontStyle: 'normal',
8612
- lineHeight: '0',
8613
- textAlign: 'center',
8614
- textTransform: 'none',
8615
- verticalAlign: '-.125em',
8616
- textRendering: 'optimizeLegibility',
8617
- WebkitFontSmoothing: 'antialiased',
8618
- MozOsxFontSmoothing: 'grayscale'
8619
- }, style);
8620
- return /*#__PURE__*/React__default.createElement("i", {
8621
- style: s
8622
- }, /*#__PURE__*/React__default.createElement("svg", {
8623
- xmlns: "http://www.w3.org/2000/svg",
8624
- width: "1em",
8625
- height: "1em",
8626
- viewBox: viewBox,
8627
- fill: "currentColor"
8628
- }, shapes.map((_ref2, ix) => {
8629
- let {
8630
- type: Type,
8631
- attrs
8632
- } = _ref2;
8633
- return (
8634
- /*#__PURE__*/
8635
- // eslint-disable-next-line react/no-array-index-key
8636
- React__default.createElement(Type, _extends$6({
8637
- key: ix
8638
- }, attrs))
8639
- );
8640
- })));
8641
- }
8642
-
8643
- const remove = props => _objectSpread2(_objectSpread2({}, props), {}, {
8644
- shapes: [{
8645
- type: 'path',
8646
- attrs: {
8647
- d: 'M9.41421356,8 L11.8890873,5.52512627 C12.065864,5.34834957 12.0305087,4.95944084 11.8183766,4.74730881 L11.2526912,4.18162338 C11.0405592,3.96949135 10.6516504,3.93413601 10.4748737,4.1109127 L8,6.58578644 L5.52512627,4.1109127 C5.34834957,3.93413601 4.95944084,3.96949135 4.74730881,4.18162338 L4.25233406,4.67659813 C3.96949135,4.95944084 3.93413601,5.34834957 4.1109127,5.52512627 L6.58578644,8 L4.1109127,10.4748737 C3.93413601,10.6516504 3.96949135,11.0405592 4.18162338,11.2526912 L4.67659813,11.7476659 C4.95944084,12.0305087 5.34834957,12.065864 5.52512627,11.8890873 L8,9.41421356 L10.4748737,11.8890873 C10.6516504,12.065864 11.0405592,12.0305087 11.2526912,11.8183766 L11.8183766,11.2526912 C12.0305087,11.0405592 12.065864,10.6516504 11.8890873,10.4748737 L9.41421356,8 Z M8,0 C12.4,0 16,3.6 16,8 C16,12.4 12.4,16 8,16 C3.6,16 0,12.4 0,8 C0,3.6 3.6,0 8,0 Z'
8648
- }
8649
- }]
8650
- });
8651
- var Remove = (props => SvgIcon$2(remove(props)));
8652
-
8653
- const lock = props => _objectSpread2(_objectSpread2({}, props), {}, {
8654
- shapes: [{
8655
- type: 'path',
8656
- attrs: {
8657
- d: 'M8 10a1 1 0 0 1 .5 1.866v.634a.5.5 0 0 1-1 0v-.634A1 1 0 0 1 8 10ZM3.625 7.035A2 2 0 0 0 2 9v5a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V9a2 2 0 0 0-1.625-1.965V5.383a4.375 4.375 0 0 0-8.75 0v1.652ZM3 9a1 1 0 0 1 .931-.998h8.138A1 1 0 0 1 13 9v5a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V9Zm8.375-3.617V7h-6.75V5.383a3.375 3.375 0 0 1 6.75 0Z'
8658
- }
8659
- }]
8660
- });
8661
- var Lock = (props => SvgIcon$2(lock(props)));
8662
-
8663
- const unlock = props => _objectSpread2(_objectSpread2({}, props), {}, {
8664
- shapes: [{
8665
- type: 'path',
8666
- attrs: {
8667
- d: 'M2.5,7 L11,7 C11.5522847,7 12,7.44771525 12,8 L12,15 C12,15.5522847 11.5522847,16 11,16 L1,16 C0.44771525,16 0,15.5522847 0,15 L0,8 C0,7.44771525 0.44771525,7 1,7 L1,4.98151367 C1,2.23029964 3.23857625,0 6,0 C8.4241995,0 10.4454541,1.71883353 10.9029715,4 L9.34209114,4 C8.9671727,2.54028848 7.9088888,1.5 6,1.5 C3.54860291,1.5 2.5,3.21561511 2.5,5.33193359 L2.5,7 Z'
8668
- }
8669
- }]
8670
- });
8671
- var Unlock = (props => SvgIcon$2(unlock(props)));
8672
-
8673
- function isRangeVisible(_ref) {
8674
- var lastRenderedStartIndex = _ref.lastRenderedStartIndex,
8675
- lastRenderedStopIndex = _ref.lastRenderedStopIndex,
8676
- startIndex = _ref.startIndex,
8677
- stopIndex = _ref.stopIndex;
8678
-
8679
- return !(startIndex > lastRenderedStopIndex || stopIndex < lastRenderedStartIndex);
8680
- }
8681
-
8682
- function scanForUnloadedRanges(_ref) {
8683
- var isItemLoaded = _ref.isItemLoaded,
8684
- itemCount = _ref.itemCount,
8685
- minimumBatchSize = _ref.minimumBatchSize,
8686
- startIndex = _ref.startIndex,
8687
- stopIndex = _ref.stopIndex;
8688
-
8689
- var unloadedRanges = [];
8690
-
8691
- var rangeStartIndex = null;
8692
- var rangeStopIndex = null;
8693
-
8694
- for (var _index = startIndex; _index <= stopIndex; _index++) {
8695
- var loaded = isItemLoaded(_index);
8696
-
8697
- if (!loaded) {
8698
- rangeStopIndex = _index;
8699
- if (rangeStartIndex === null) {
8700
- rangeStartIndex = _index;
8701
- }
8702
- } else if (rangeStopIndex !== null) {
8703
- unloadedRanges.push(rangeStartIndex, rangeStopIndex);
8704
-
8705
- rangeStartIndex = rangeStopIndex = null;
8706
- }
8707
- }
8708
-
8709
- // If :rangeStopIndex is not null it means we haven't ran out of unloaded rows.
8710
- // Scan forward to try filling our :minimumBatchSize.
8711
- if (rangeStopIndex !== null) {
8712
- var potentialStopIndex = Math.min(Math.max(rangeStopIndex, rangeStartIndex + minimumBatchSize - 1), itemCount - 1);
8713
-
8714
- for (var _index2 = rangeStopIndex + 1; _index2 <= potentialStopIndex; _index2++) {
8715
- if (!isItemLoaded(_index2)) {
8716
- rangeStopIndex = _index2;
8717
- } else {
8718
- break;
8719
- }
8720
- }
8721
-
8722
- unloadedRanges.push(rangeStartIndex, rangeStopIndex);
8723
- }
8724
-
8725
- // Check to see if our first range ended prematurely.
8726
- // In this case we should scan backwards to try filling our :minimumBatchSize.
8727
- if (unloadedRanges.length) {
8728
- while (unloadedRanges[1] - unloadedRanges[0] + 1 < minimumBatchSize && unloadedRanges[0] > 0) {
8729
- var _index3 = unloadedRanges[0] - 1;
8730
-
8731
- if (!isItemLoaded(_index3)) {
8732
- unloadedRanges[0] = _index3;
8733
- } else {
8734
- break;
8735
- }
8736
- }
8737
- }
8738
-
8739
- return unloadedRanges;
8740
- }
8741
-
8742
- var classCallCheck$1 = function (instance, Constructor) {
8743
- if (!(instance instanceof Constructor)) {
8744
- throw new TypeError("Cannot call a class as a function");
8745
- }
8746
- };
8747
-
8748
- var createClass$1 = function () {
8749
- function defineProperties(target, props) {
8750
- for (var i = 0; i < props.length; i++) {
8751
- var descriptor = props[i];
8752
- descriptor.enumerable = descriptor.enumerable || false;
8753
- descriptor.configurable = true;
8754
- if ("value" in descriptor) descriptor.writable = true;
8755
- Object.defineProperty(target, descriptor.key, descriptor);
8756
- }
8683
+ };
8684
+
8685
+ var createClass$1 = function () {
8686
+ function defineProperties(target, props) {
8687
+ for (var i = 0; i < props.length; i++) {
8688
+ var descriptor = props[i];
8689
+ descriptor.enumerable = descriptor.enumerable || false;
8690
+ descriptor.configurable = true;
8691
+ if ("value" in descriptor) descriptor.writable = true;
8692
+ Object.defineProperty(target, descriptor.key, descriptor);
8693
+ }
8757
8694
  }
8758
8695
 
8759
8696
  return function (Constructor, protoProps, staticProps) {
@@ -9182,57 +9119,590 @@ function useSelectionsInteractions(_ref) {
9182
9119
  if (selectingValues || !pages || !checkboxes && !mouseDown) {
9183
9120
  return;
9184
9121
  }
9185
- // Render pre-selections before they have been selected in Engine.
9186
- const newPages = applySelectionsOnPages(pages, preSelected, isSingleSelect);
9187
- setInstantPages(newPages);
9188
- }, [preSelected]);
9189
- const interactionEvents = {};
9190
- if (checkboxes) {
9191
- Object.assign(interactionEvents, {
9192
- onClick
9193
- });
9194
- } else {
9195
- Object.assign(interactionEvents, {
9196
- onMouseUp,
9197
- onMouseDown,
9198
- onMouseEnter
9199
- });
9200
- }
9201
- return {
9202
- instantPages,
9203
- interactionEvents,
9204
- select: selectManually // preselect and select without having to trigger an event
9122
+ // Render pre-selections before they have been selected in Engine.
9123
+ const newPages = applySelectionsOnPages(pages, preSelected, isSingleSelect);
9124
+ setInstantPages(newPages);
9125
+ }, [preSelected]);
9126
+ const interactionEvents = {};
9127
+ if (checkboxes) {
9128
+ Object.assign(interactionEvents, {
9129
+ onClick
9130
+ });
9131
+ } else {
9132
+ Object.assign(interactionEvents, {
9133
+ onMouseUp,
9134
+ onMouseDown,
9135
+ onMouseEnter
9136
+ });
9137
+ }
9138
+ return {
9139
+ instantPages,
9140
+ interactionEvents,
9141
+ select: selectManually // preselect and select without having to trigger an event
9142
+ };
9143
+ }
9144
+
9145
+ const tick = props => _objectSpread2(_objectSpread2({}, props), {}, {
9146
+ shapes: [{
9147
+ type: 'path',
9148
+ attrs: {
9149
+ d: 'M6,10 L13,3 L15,5 L8,12 L6,14 L1,9 L3,7 L6,10 Z'
9150
+ }
9151
+ }]
9152
+ });
9153
+ var Tick = (props => SvgIcon$2(tick(props)));
9154
+
9155
+ /**
9156
+ * @ignore
9157
+ * @interface Range
9158
+ * @property {number} qCharPos The (absolute) index where the highlighted range starts.
9159
+ * @property {number} qCharCount The length of the sub-string (starting from qChartPos) that should be highlighted.
9160
+ */
9161
+
9162
+ /**
9163
+ * @ignore
9164
+ * @interface Segment
9165
+ * @property {string} segment The sub-string/segment cut out from the original label.
9166
+ * @property {boolean} highlighted A flag which tells whether the segment should be highlighted or not.
9167
+ */
9168
+
9169
+ /**
9170
+ * @ignore
9171
+ * @param {string} label The label we want to create segments out of.
9172
+ * @param {Range} range The indexes which define how to create the segments.
9173
+ * @param {number=} [startIndex] An optional index which tells where we want to start the first segment from
9174
+ * (only relevant for creating the first unhighlighted segment of a string/sub-string).
9175
+ * @returns {Segment[]} An array of segments.
9176
+ */
9177
+ function getSegmentsFromRange(label, range) {
9178
+ let startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
9179
+ const {
9180
+ qCharPos,
9181
+ qCharCount
9182
+ } = range;
9183
+ const segments = [];
9184
+ if (qCharPos > startIndex) {
9185
+ // Create a non-highlighted section before the highighted section.
9186
+ segments.push([label.slice(startIndex, qCharPos), false]);
9187
+ }
9188
+
9189
+ // Highlighted segment.
9190
+ segments.push([label.slice(qCharPos, qCharPos + qCharCount), true]);
9191
+ return segments;
9192
+ }
9193
+
9194
+ /**
9195
+ * @ignore
9196
+ * @param {string} label The label we want to create segments out of.
9197
+ * @param {Range[]} ranges The ranges defining indices for cutting the string into segments.
9198
+ * @returns {Segment[]} An array of segments, covering the entire string label.
9199
+ */
9200
+ function getSegmentsFromRanges(label, ranges) {
9201
+ if (!ranges.length) {
9202
+ return [];
9203
+ }
9204
+ const labels = ranges.reduce((acc, curr, ix) => {
9205
+ const startIndex = ix === 0 ? 0 : ranges[ix - 1].qCharPos + ranges[ix - 1].qCharCount;
9206
+ acc.push(...getSegmentsFromRange(label, curr, startIndex));
9207
+
9208
+ // Last non highlighted segment
9209
+ const isLastRange = ix === ranges.length - 1;
9210
+ const endIndex = ranges[ix].qCharPos + ranges[ix].qCharCount;
9211
+ if (isLastRange && endIndex < label.length) {
9212
+ acc.push([label.slice(endIndex), false]);
9213
+ }
9214
+ return acc;
9215
+ }, []);
9216
+ return labels;
9217
+ }
9218
+
9219
+ const KEYS = Object.freeze({
9220
+ ENTER: 13,
9221
+ ESCAPE: 27,
9222
+ SPACE: 32,
9223
+ TAB: 9,
9224
+ BACKSPACE: 8,
9225
+ DELETE: 46,
9226
+ ALT: 18,
9227
+ CTRL: 17,
9228
+ SHIFT: 16,
9229
+ ARROW_UP: 38,
9230
+ ARROW_DOWN: 40,
9231
+ ARROW_LEFT: 37,
9232
+ ARROW_RIGHT: 39,
9233
+ PAGE_DOWN: 34,
9234
+ PAGE_UP: 33,
9235
+ HOME: 36,
9236
+ END: 35,
9237
+ F10: 121,
9238
+ A: 65,
9239
+ F: 70,
9240
+ ZERO: 48,
9241
+ NINE: 57,
9242
+ NUMPAD_ZERO: 96,
9243
+ NUMPAD_NINE: 105,
9244
+ SUBTRACTION: 189,
9245
+ DECIMAL: 190,
9246
+ NUMPAD_DECIMAL: 110,
9247
+ isArrow: key => key === KEYS.ARROW_UP || key === KEYS.ARROW_DOWN || key === KEYS.ARROW_LEFT || key === KEYS.ARROW_RIGHT
9248
+ });
9249
+
9250
+ function getFieldKeyboardNavigation(_ref) {
9251
+ let {
9252
+ select,
9253
+ confirm,
9254
+ cancel,
9255
+ setScrollPosition,
9256
+ focusListItems
9257
+ } = _ref;
9258
+ const getElement = function (elm) {
9259
+ let next = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
9260
+ const parentElm = elm && elm.parentElement[next ? 'nextElementSibling' : 'previousElementSibling'];
9261
+ return parentElm && parentElm.querySelector('[role]');
9262
+ };
9263
+ let startedRange = false;
9264
+ const setStartedRange = val => {
9265
+ startedRange = val;
9266
+ };
9267
+ const handleKeyDown = event => {
9268
+ let elementToFocus;
9269
+ const {
9270
+ keyCode,
9271
+ shiftKey = false,
9272
+ ctrlKey = false
9273
+ } = event.nativeEvent;
9274
+ switch (keyCode) {
9275
+ case KEYS.SHIFT:
9276
+ // This is to ensure we include the first value when starting a range selection.
9277
+ setStartedRange(true);
9278
+ break;
9279
+ case KEYS.SPACE:
9280
+ select([+event.currentTarget.getAttribute('data-n')]);
9281
+ break;
9282
+ case KEYS.ARROW_DOWN:
9283
+ case KEYS.ARROW_RIGHT:
9284
+ elementToFocus = getElement(event.currentTarget, true);
9285
+ if (shiftKey && elementToFocus) {
9286
+ if (startedRange) {
9287
+ select([+event.currentTarget.getAttribute('data-n')], true);
9288
+ setStartedRange(false);
9289
+ }
9290
+ select([+elementToFocus.getAttribute('data-n')], true);
9291
+ }
9292
+ break;
9293
+ case KEYS.ARROW_UP:
9294
+ case KEYS.ARROW_LEFT:
9295
+ elementToFocus = getElement(event.currentTarget, false);
9296
+ if (shiftKey && elementToFocus) {
9297
+ if (startedRange) {
9298
+ select([+event.currentTarget.getAttribute('data-n')], true);
9299
+ setStartedRange(false);
9300
+ }
9301
+ select([+elementToFocus.getAttribute('data-n')], true);
9302
+ }
9303
+ break;
9304
+ case KEYS.ENTER:
9305
+ confirm();
9306
+ break;
9307
+ case KEYS.ESCAPE:
9308
+ cancel();
9309
+ return;
9310
+ // let it propagate to top-level
9311
+ case KEYS.HOME:
9312
+ focusListItems.setFirst(true);
9313
+ if (ctrlKey) {
9314
+ setScrollPosition === null || setScrollPosition === void 0 ? void 0 : setScrollPosition('overflowStart');
9315
+ break;
9316
+ }
9317
+ setScrollPosition === null || setScrollPosition === void 0 ? void 0 : setScrollPosition('start');
9318
+ break;
9319
+ case KEYS.END:
9320
+ focusListItems.setLast(true);
9321
+ if (ctrlKey) {
9322
+ setScrollPosition === null || setScrollPosition === void 0 ? void 0 : setScrollPosition('overflowEnd');
9323
+ break;
9324
+ }
9325
+ setScrollPosition === null || setScrollPosition === void 0 ? void 0 : setScrollPosition('end');
9326
+ break;
9327
+ default:
9328
+ return;
9329
+ // don't stop propagation since we want to outsource keydown to other handlers.
9330
+ }
9331
+
9332
+ if (elementToFocus) {
9333
+ elementToFocus.focus();
9334
+ }
9335
+ event.preventDefault();
9336
+ event.stopPropagation();
9337
+ };
9338
+ return handleKeyDown;
9339
+ }
9340
+ function getListboxInlineKeyboardNavigation(_ref2) {
9341
+ let {
9342
+ setKeyboardActive,
9343
+ hovering,
9344
+ setHovering,
9345
+ updateKeyScroll,
9346
+ containerRef,
9347
+ currentScrollIndex,
9348
+ app,
9349
+ appSelections,
9350
+ constraints
9351
+ } = _ref2;
9352
+ const focusInsideListbox = element => {
9353
+ const fieldElement = element.querySelector('.search input, .value.selector, .value, .ActionsToolbar-* button');
9354
+ setKeyboardActive(true);
9355
+ if (fieldElement) {
9356
+ fieldElement.focus();
9357
+ }
9358
+ };
9359
+ const focusContainer = element => {
9360
+ setKeyboardActive(false);
9361
+ element.focus();
9362
+ };
9363
+ const updateKeyScrollOnHover = newState => {
9364
+ if (hovering) {
9365
+ updateKeyScroll(newState);
9366
+ }
9367
+ };
9368
+ const handleKeyDown = event => {
9369
+ const {
9370
+ keyCode,
9371
+ ctrlKey = false,
9372
+ shiftKey = false
9373
+ } = event.nativeEvent;
9374
+ switch (keyCode) {
9375
+ // case KEYS.TAB: TODO: Focus confirm button using keyboard.focusSelection when we can access the useKeyboard hook.
9376
+ case KEYS.ENTER:
9377
+ case KEYS.SPACE:
9378
+ if (!event.target.classList.contains('listbox-container')) {
9379
+ return; // don't mess with keydown handlers within the listbox
9380
+ }
9381
+
9382
+ focusInsideListbox(event.currentTarget);
9383
+ break;
9384
+ case KEYS.ESCAPE:
9385
+ focusContainer(event.currentTarget);
9386
+ break;
9387
+ case KEYS.ARROW_UP:
9388
+ updateKeyScrollOnHover({
9389
+ up: 1
9390
+ });
9391
+ break;
9392
+ case KEYS.ARROW_DOWN:
9393
+ updateKeyScrollOnHover({
9394
+ down: 1
9395
+ });
9396
+ break;
9397
+ case KEYS.PAGE_UP:
9398
+ updateKeyScrollOnHover({
9399
+ up: currentScrollIndex.stop - currentScrollIndex.start
9400
+ });
9401
+ break;
9402
+ case KEYS.PAGE_DOWN:
9403
+ updateKeyScrollOnHover({
9404
+ down: currentScrollIndex.stop - currentScrollIndex.start
9405
+ });
9406
+ break;
9407
+ case KEYS.HOME:
9408
+ updateKeyScrollOnHover({
9409
+ scrollPosition: ctrlKey && shiftKey ? 'overflowStart' : 'start'
9410
+ });
9411
+ break;
9412
+ case KEYS.END:
9413
+ updateKeyScrollOnHover({
9414
+ scrollPosition: ctrlKey && shiftKey ? 'overflowEnd' : 'end'
9415
+ });
9416
+ break;
9417
+ default:
9418
+ return;
9419
+ }
9420
+
9421
+ // Note: We should not stop propagation here as it will block the containing app
9422
+ // from handling keydown events.
9423
+ event.preventDefault();
9424
+ };
9425
+ const focusOnHoverDisabled = () => {
9426
+ var _app$isInModalSelecti, _app$isInModalSelecti2;
9427
+ const selectNotAllowed = (constraints === null || constraints === void 0 ? void 0 : constraints.select) || (constraints === null || constraints === void 0 ? void 0 : constraints.active);
9428
+ const appInModal = (_app$isInModalSelecti = (_app$isInModalSelecti2 = app.isInModalSelection) === null || _app$isInModalSelecti2 === void 0 ? void 0 : _app$isInModalSelecti2.call(app)) !== null && _app$isInModalSelecti !== void 0 ? _app$isInModalSelecti : appSelections.isInModal();
9429
+ return selectNotAllowed || appInModal;
9430
+ };
9431
+ const handleOnMouseEnter = () => {
9432
+ if (!focusOnHoverDisabled()) {
9433
+ var _containerRef$current, _containerRef$current2;
9434
+ setHovering(true);
9435
+ containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : (_containerRef$current2 = _containerRef$current.focus) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.call(_containerRef$current);
9436
+ }
9437
+ };
9438
+ const handleOnMouseLeave = () => {
9439
+ if (hovering) {
9440
+ var _containerRef$current3, _containerRef$current4;
9441
+ setHovering(false);
9442
+ containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : (_containerRef$current4 = _containerRef$current3.blur) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.call(_containerRef$current3);
9443
+ }
9444
+ };
9445
+ return {
9446
+ handleKeyDown,
9447
+ handleOnMouseEnter,
9448
+ handleOnMouseLeave
9449
+ };
9450
+ }
9451
+
9452
+ const PREFIX$c = 'RowColumn';
9453
+ const rowColClasses = {
9454
+ row: "".concat(PREFIX$c, "-row"),
9455
+ rowBorderBottom: "".concat(PREFIX$c, "-rowBorderBottom"),
9456
+ column: "".concat(PREFIX$c, "-column"),
9457
+ fieldRoot: "".concat(PREFIX$c, "-fieldRoot"),
9458
+ cell: "".concat(PREFIX$c, "-cell"),
9459
+ labelText: "".concat(PREFIX$c, "-labelText"),
9460
+ labelDense: "".concat(PREFIX$c, "-labelDense"),
9461
+ highlighted: "".concat(PREFIX$c, "-highlighted"),
9462
+ checkboxLabel: "".concat(PREFIX$c, "-checkboxLabel"),
9463
+ icon: "".concat(PREFIX$c, "-icon"),
9464
+ S: "".concat(PREFIX$c, "-S"),
9465
+ XS: "".concat(PREFIX$c, "-XS"),
9466
+ A: "".concat(PREFIX$c, "-A"),
9467
+ X: "".concat(PREFIX$c, "-X"),
9468
+ frequencyCount: "".concat(PREFIX$c, "-frequencyCount"),
9469
+ barContainer: "".concat(PREFIX$c, "-barContainer"),
9470
+ bar: "".concat(PREFIX$c, "-bar"),
9471
+ barSelected: "".concat(PREFIX$c, "-barSelected"),
9472
+ barWithCheckbox: "".concat(PREFIX$c, "-barWithCheckbox"),
9473
+ barSelectedWithCheckbox: "".concat(PREFIX$c, "-barSelectedWithCheckbox"),
9474
+ excludedTextWithCheckbox: "".concat(PREFIX$c, "-excludedTextWithCheckbox")
9475
+ };
9476
+
9477
+ const isExcluded = c => c ? c.qState === 'X' || c.qState === 'XS' || c.qState === 'XL' : null;
9478
+ const isAlternative = c => c ? c.qState === 'A' : null;
9479
+ const excludedOrAlternative = _ref => {
9480
+ let {
9481
+ cell,
9482
+ checkboxes
9483
+ } = _ref;
9484
+ return (isAlternative(cell) || isExcluded(cell)) && checkboxes;
9485
+ };
9486
+
9487
+ const frequencyTextNone = '-';
9488
+ const barPadPx = 4;
9489
+ const barBorderWidthPx = 1;
9490
+ const barWithCheckboxLeftPadPx = 29;
9491
+
9492
+ const joinClassNames = namesArray => namesArray.filter(c => !!c).join(' ').trim();
9493
+ const getBarWidth = _ref => {
9494
+ let {
9495
+ qFrequency,
9496
+ checkboxes,
9497
+ frequencyMax
9498
+ } = _ref;
9499
+ const freqStr = String(qFrequency);
9500
+ const isPercent = freqStr.substring(freqStr.length - 1) === '%';
9501
+ const freq = parseFloat(isPercent ? freqStr : qFrequency);
9502
+ const rightSlice = checkboxes ? "(".concat(barWithCheckboxLeftPadPx, "px + ").concat(barPadPx + barBorderWidthPx * 2, "px)") : "".concat(barPadPx * 2 + barBorderWidthPx * 2, "px");
9503
+ const width = isPercent ? freq : freq / frequencyMax * 100;
9504
+ return "calc(".concat(width, "% - ").concat(rightSlice, ")");
9505
+ };
9506
+ const getFrequencyText = _ref2 => {
9507
+ let {
9508
+ cell
9509
+ } = _ref2;
9510
+ if (cell) {
9511
+ return cell.qFrequency ? cell.qFrequency : frequencyTextNone;
9512
+ }
9513
+ return '';
9514
+ };
9515
+
9516
+ const getSelectedStyle = _ref => {
9517
+ let {
9518
+ theme
9519
+ } = _ref;
9520
+ return {
9521
+ background: theme.palette.selected.main,
9522
+ color: theme.palette.selected.mainContrastText,
9523
+ '&:focus': {
9524
+ boxShadow: "inset 0 0 0 2px ".concat(theme.palette.custom.focusBorder),
9525
+ outline: 'none'
9526
+ },
9527
+ '& $cell': {
9528
+ paddingRight: 0
9529
+ }
9530
+ };
9531
+ };
9532
+ const ellipsis = {
9533
+ width: '100%',
9534
+ overflow: 'hidden',
9535
+ textOverflow: 'ellipsis'
9536
+ };
9537
+ const RowColRoot = styled$1('div', {
9538
+ shouldForwardProp: prop => !['flexBasisProp', 'isGridMode', 'isGridCol', 'dense'].includes(prop)
9539
+ })(_ref2 => {
9540
+ var _theme$listBox$conten, _theme$listBox, _theme$listBox$conten2, _theme$listBox$conten3, _theme$listBox2, _theme$listBox2$conte, _theme$listBox3, _theme$listBox3$conte, _theme$listBox4, _theme$listBox4$conte;
9541
+ let {
9542
+ theme,
9543
+ flexBasisProp,
9544
+ isGridMode,
9545
+ isGridCol,
9546
+ dense
9547
+ } = _ref2;
9548
+ return {
9549
+ '&:focus': {
9550
+ boxShadow: "inset 0 0 0 2px ".concat(theme.palette.custom.focusBorder, " !important")
9551
+ },
9552
+ '&:focus-visible': {
9553
+ outline: 'none'
9554
+ },
9555
+ ["& .".concat(rowColClasses.row)]: {
9556
+ flexWrap: 'nowrap',
9557
+ color: (_theme$listBox$conten = (_theme$listBox = theme.listBox) === null || _theme$listBox === void 0 ? void 0 : (_theme$listBox$conten2 = _theme$listBox.content) === null || _theme$listBox$conten2 === void 0 ? void 0 : _theme$listBox$conten2.color) !== null && _theme$listBox$conten !== void 0 ? _theme$listBox$conten : theme.palette.text.primary
9558
+ },
9559
+ ["& .".concat(rowColClasses.rowBorderBottom)]: {
9560
+ borderBottom: isGridCol ? 'none' : "1px solid ".concat(theme.palette.divider),
9561
+ borderLeft: isGridCol ? "1px solid ".concat(theme.palette.divider) : 'none'
9562
+ },
9563
+ ["& .".concat(rowColClasses.column)]: {
9564
+ flexWrap: 'nowrap',
9565
+ borderRight: "1px solid ".concat(theme.palette.divider),
9566
+ color: (_theme$listBox$conten3 = (_theme$listBox2 = theme.listBox) === null || _theme$listBox2 === void 0 ? void 0 : (_theme$listBox2$conte = _theme$listBox2.content) === null || _theme$listBox2$conte === void 0 ? void 0 : _theme$listBox2$conte.color) !== null && _theme$listBox$conten3 !== void 0 ? _theme$listBox$conten3 : theme.palette.text.primary
9567
+ },
9568
+ // The interior wrapper for all field content.
9569
+ ["& .".concat(rowColClasses.cell)]: {
9570
+ display: 'flex',
9571
+ alignItems: 'center',
9572
+ minWidth: 0,
9573
+ flexGrow: 1,
9574
+ // Note that this padding is overridden when using checkboxes.
9575
+ paddingLeft: '9px',
9576
+ paddingRight: '9px'
9577
+ },
9578
+ // The leaf node, containing the label text.
9579
+ ["& .".concat(rowColClasses.labelText)]: _objectSpread2(_objectSpread2({
9580
+ flexBasis: flexBasisProp,
9581
+ lineHeight: '16px',
9582
+ userSelect: 'none',
9583
+ whiteSpace: 'pre',
9584
+ // to keep white-space on highlight
9585
+ paddingRight: '9px'
9586
+ }, ellipsis), {}, {
9587
+ fontSize: (_theme$listBox3 = theme.listBox) === null || _theme$listBox3 === void 0 ? void 0 : (_theme$listBox3$conte = _theme$listBox3.content) === null || _theme$listBox3$conte === void 0 ? void 0 : _theme$listBox3$conte.fontSize,
9588
+ fontFamily: (_theme$listBox4 = theme.listBox) === null || _theme$listBox4 === void 0 ? void 0 : (_theme$listBox4$conte = _theme$listBox4.content) === null || _theme$listBox4$conte === void 0 ? void 0 : _theme$listBox4$conte.fontFamily
9589
+ }),
9590
+ ["& .".concat(rowColClasses.labelDense)]: {
9591
+ fontSize: 12
9592
+ },
9593
+ // Highlight is added to labelText spans, which are created as siblings to original labelText,
9594
+ // when a search string is matched.
9595
+ ["& .".concat(rowColClasses.highlighted)]: {
9596
+ overflow: 'visible',
9597
+ width: '100%',
9598
+ '& > span': {
9599
+ width: '100%',
9600
+ backgroundColor: '#FFC72A'
9601
+ }
9602
+ },
9603
+ // Checkbox and label container.
9604
+ ["& .".concat(rowColClasses.checkboxLabel)]: {
9605
+ margin: 0,
9606
+ width: '100%',
9607
+ height: '100%',
9608
+ overflow: 'hidden',
9609
+ // The checkbox's span
9610
+ '& > span:nth-of-type(1)': {
9611
+ paddingRight: '8px'
9612
+ },
9613
+ // The checkbox's label container.
9614
+ '& > span:nth-of-type(2)': _objectSpread2(_objectSpread2({}, ellipsis), {}, {
9615
+ display: 'flex',
9616
+ alignItems: 'center',
9617
+ paddingLeft: 0,
9618
+ paddingRight: '2px'
9619
+ })
9620
+ },
9621
+ // The icons container holding tick and lock, shown inside fields.
9622
+ ["& .".concat(rowColClasses.icon)]: {
9623
+ display: 'flex',
9624
+ padding: theme.spacing(1, 1, 1, 0)
9625
+ },
9626
+ // Selection styles (S=Selected, XS=ExcludedSelected, A=Available, X=Excluded).
9627
+ ["& .".concat(rowColClasses.S)]: _objectSpread2(_objectSpread2({}, getSelectedStyle({
9628
+ theme
9629
+ })), {}, {
9630
+ border: isGridMode ? 'none' : undefined
9631
+ }),
9632
+ ["& .".concat(rowColClasses.XS)]: _objectSpread2(_objectSpread2({}, getSelectedStyle({
9633
+ theme
9634
+ })), {}, {
9635
+ background: theme.palette.selected.excluded,
9636
+ color: theme.palette.selected.mainContrastText,
9637
+ border: isGridMode ? 'none' : undefined
9638
+ }),
9639
+ ["& .".concat(rowColClasses.A)]: {
9640
+ background: theme.palette.selected.alternative,
9641
+ color: theme.palette.selected.alternativeContrastText,
9642
+ border: isGridMode ? 'none' : undefined
9643
+ },
9644
+ ["& .".concat(rowColClasses.X)]: {
9645
+ background: theme.palette.selected.excluded,
9646
+ color: theme.palette.selected.excludedContrastText,
9647
+ border: isGridMode ? 'none' : undefined
9648
+ },
9649
+ ["& .".concat(rowColClasses.frequencyCount)]: {
9650
+ width: '66px',
9651
+ justifyContent: 'flex-end'
9652
+ },
9653
+ ["&.".concat(rowColClasses.barContainer)]: {
9654
+ height: '100%',
9655
+ display: 'flex',
9656
+ alignItems: 'center'
9657
+ },
9658
+ ["& .".concat(rowColClasses.bar)]: {
9659
+ border: "".concat(barBorderWidthPx, "px solid"),
9660
+ borderColor: '#D9D9D9',
9661
+ height: dense ? '16px' : '20px',
9662
+ position: 'absolute',
9663
+ zIndex: '-1',
9664
+ alignSelf: 'center',
9665
+ left: "".concat(barPadPx, "px"),
9666
+ transition: 'width 0.2s',
9667
+ backgroundColor: '#FAFAFA'
9668
+ },
9669
+ ["& .".concat(rowColClasses.barSelected)]: {
9670
+ opacity: '30%',
9671
+ zIndex: '0',
9672
+ background: theme.palette.background.lighter
9673
+ },
9674
+ ["& .".concat(rowColClasses.barWithCheckbox)]: {
9675
+ left: "".concat(barWithCheckboxLeftPadPx, "px")
9676
+ },
9677
+ ["& .".concat(rowColClasses.barSelectedWithCheckbox)]: {
9678
+ background: '#BFE5D0',
9679
+ borderColor: '#BFE5D0'
9680
+ },
9681
+ ["& .".concat(rowColClasses.excludedTextWithCheckbox)]: {
9682
+ color: '#828282',
9683
+ fontStyle: 'italic'
9684
+ }
9205
9685
  };
9206
- }
9207
-
9208
- const tick = props => _objectSpread2(_objectSpread2({}, props), {}, {
9209
- shapes: [{
9210
- type: 'path',
9211
- attrs: {
9212
- d: 'M6,10 L13,3 L15,5 L8,12 L6,14 L1,9 L3,7 L6,10 Z'
9213
- }
9214
- }]
9215
9686
  });
9216
- var Tick = (props => SvgIcon$2(tick(props)));
9217
9687
 
9218
9688
  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\")";
9219
9689
 
9220
- const PREFIX$c = 'ListBoxCheckbox';
9690
+ const PREFIX$b = 'ListBoxCheckbox';
9221
9691
  const borderRadius = 3;
9222
- const classes$c = {
9223
- cbIcon: "".concat(PREFIX$c, "-cbIcon"),
9224
- cbIconChecked: "".concat(PREFIX$c, "-cbIconChecked"),
9225
- cbIconExcluded: "".concat(PREFIX$c, "-cbIconExcluded"),
9226
- cbIconAlternative: "".concat(PREFIX$c, "-cbIconAlternative"),
9227
- checkbox: "".concat(PREFIX$c, "-checkbox"),
9228
- dense: "".concat(PREFIX$c, "-dense")
9692
+ const classes$b = {
9693
+ cbIcon: "".concat(PREFIX$b, "-cbIcon"),
9694
+ cbIconChecked: "".concat(PREFIX$b, "-cbIconChecked"),
9695
+ cbIconExcluded: "".concat(PREFIX$b, "-cbIconExcluded"),
9696
+ cbIconAlternative: "".concat(PREFIX$b, "-cbIconAlternative"),
9697
+ checkbox: "".concat(PREFIX$b, "-checkbox"),
9698
+ dense: "".concat(PREFIX$b, "-dense")
9229
9699
  };
9230
9700
  const StyledCheckbox = styled$1(Checkbox)(_ref => {
9231
9701
  let {
9232
9702
  theme
9233
9703
  } = _ref;
9234
9704
  return {
9235
- ["& .".concat(classes$c.cbIcon)]: {
9705
+ ["& .".concat(classes$b.cbIcon)]: {
9236
9706
  borderRadius,
9237
9707
  width: 16,
9238
9708
  height: 16,
@@ -9243,7 +9713,7 @@ const StyledCheckbox = styled$1(Checkbox)(_ref => {
9243
9713
  alignItems: 'center',
9244
9714
  justifyContent: 'center'
9245
9715
  },
9246
- ["& .".concat(classes$c.cbIconChecked)]: {
9716
+ ["& .".concat(classes$b.cbIconChecked)]: {
9247
9717
  borderRadius,
9248
9718
  backgroundColor: theme.palette.selected.main,
9249
9719
  backgroundImage: 'linear-gradient(180deg,hsla(0,0%,100%,.1),hsla(0,0%,100%,0))',
@@ -9255,25 +9725,25 @@ const StyledCheckbox = styled$1(Checkbox)(_ref => {
9255
9725
  content: '""'
9256
9726
  }
9257
9727
  },
9258
- ["& .".concat(classes$c.cbIconExcluded)]: {
9728
+ ["& .".concat(classes$b.cbIconExcluded)]: {
9259
9729
  borderRadius: borderRadius - 1,
9260
9730
  width: 12,
9261
9731
  height: 12,
9262
9732
  backgroundColor: theme.palette.selected.excluded
9263
9733
  },
9264
- ["& .".concat(classes$c.cbIconAlternative)]: {
9734
+ ["& .".concat(classes$b.cbIconAlternative)]: {
9265
9735
  borderRadius: borderRadius - 1,
9266
9736
  width: 12,
9267
9737
  height: 12,
9268
9738
  backgroundColor: theme.palette.selected.alternative
9269
9739
  },
9270
- ["&.".concat(classes$c.checkbox)]: {
9740
+ ["&.".concat(classes$b.checkbox)]: {
9271
9741
  margin: 0,
9272
9742
  '&:hover': {
9273
9743
  backgroundColor: 'inherit !important'
9274
9744
  }
9275
9745
  },
9276
- ["&.".concat(classes$c.dense)]: {
9746
+ ["&.".concat(classes$b.dense)]: {
9277
9747
  padding: '4px 8px'
9278
9748
  }
9279
9749
  };
@@ -9299,86 +9769,22 @@ function ListboxCheckbox(_ref2) {
9299
9769
  edge: "start",
9300
9770
  checked: checked,
9301
9771
  disableRipple: true,
9302
- className: [classes$c.checkbox, dense && classes$c.dense].filter(Boolean).join(' '),
9772
+ className: [classes$b.checkbox, dense && classes$b.dense].filter(Boolean).join(' '),
9303
9773
  inputProps: {
9304
9774
  'aria-labelledby': label
9305
9775
  },
9306
9776
  name: label,
9307
- icon: getIcon(classes$c, showGray, excluded),
9777
+ icon: getIcon(classes$b, showGray, excluded),
9308
9778
  checkedIcon: /*#__PURE__*/React__default.createElement("span", {
9309
- className: classes$c.cbIconChecked
9779
+ className: classes$b.cbIconChecked
9310
9780
  })
9311
9781
  });
9312
9782
  }
9313
9783
 
9314
- /**
9315
- * @ignore
9316
- * @interface Range
9317
- * @property {number} qCharPos The (absolute) index where the highlighted range starts.
9318
- * @property {number} qCharCount The length of the sub-string (starting from qChartPos) that should be highlighted.
9319
- */
9320
-
9321
- /**
9322
- * @ignore
9323
- * @interface Segment
9324
- * @property {string} segment The sub-string/segment cut out from the original label.
9325
- * @property {boolean} highlighted A flag which tells whether the segment should be highlighted or not.
9326
- */
9327
-
9328
- /**
9329
- * @ignore
9330
- * @param {string} label The label we want to create segments out of.
9331
- * @param {Range} range The indexes which define how to create the segments.
9332
- * @param {number=} [startIndex] An optional index which tells where we want to start the first segment from
9333
- * (only relevant for creating the first unhighlighted segment of a string/sub-string).
9334
- * @returns {Segment[]} An array of segments.
9335
- */
9336
- function getSegmentsFromRange(label, range) {
9337
- let startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
9338
- const {
9339
- qCharPos,
9340
- qCharCount
9341
- } = range;
9342
- const segments = [];
9343
- if (qCharPos > startIndex) {
9344
- // Create a non-highlighted section before the highighted section.
9345
- segments.push([label.slice(startIndex, qCharPos), false]);
9346
- }
9347
-
9348
- // Highlighted segment.
9349
- segments.push([label.slice(qCharPos, qCharPos + qCharCount), true]);
9350
- return segments;
9351
- }
9352
-
9353
- /**
9354
- * @ignore
9355
- * @param {string} label The label we want to create segments out of.
9356
- * @param {Range[]} ranges The ranges defining indices for cutting the string into segments.
9357
- * @returns {Segment[]} An array of segments, covering the entire string label.
9358
- */
9359
- function getSegmentsFromRanges(label, ranges) {
9360
- if (!ranges.length) {
9361
- return [];
9362
- }
9363
- const labels = ranges.reduce((acc, curr, ix) => {
9364
- const startIndex = ix === 0 ? 0 : ranges[ix - 1].qCharPos + ranges[ix - 1].qCharCount;
9365
- acc.push(...getSegmentsFromRange(label, curr, startIndex));
9366
-
9367
- // Last non highlighted segment
9368
- const isLastRange = ix === ranges.length - 1;
9369
- const endIndex = ranges[ix].qCharPos + ranges[ix].qCharCount;
9370
- if (isLastRange && endIndex < label.length) {
9371
- acc.push([label.slice(endIndex), false]);
9372
- }
9373
- return acc;
9374
- }, []);
9375
- return labels;
9376
- }
9377
-
9378
- const PREFIX$b = 'ListBoxRadioButton';
9379
- const classes$b = {
9380
- denseRadioButton: "".concat(PREFIX$b, "-denseRadioButton"),
9381
- radioButton: "".concat(PREFIX$b, "-radioButton")
9784
+ const PREFIX$a = 'ListBoxRadioButton';
9785
+ const classes$a = {
9786
+ denseRadioButton: "".concat(PREFIX$a, "-denseRadioButton"),
9787
+ radioButton: "".concat(PREFIX$a, "-radioButton")
9382
9788
  };
9383
9789
  const StyledRadio = styled$1(Radio)(_ref => {
9384
9790
  let {
@@ -9386,7 +9792,7 @@ const StyledRadio = styled$1(Radio)(_ref => {
9386
9792
  checked
9387
9793
  } = _ref;
9388
9794
  return {
9389
- ["&.".concat(classes$b.radioButton)]: {
9795
+ ["&.".concat(classes$a.radioButton)]: {
9390
9796
  right: '5px',
9391
9797
  color: checked ? theme.palette.selected.main : theme.palette.main
9392
9798
  }
@@ -9402,7 +9808,7 @@ function ListBoxRadioButton(_ref2) {
9402
9808
  checked: checked,
9403
9809
  value: label,
9404
9810
  name: label,
9405
- className: classes$b.radioButton,
9811
+ className: classes$a.radioButton,
9406
9812
  style: {
9407
9813
  backgroundColor: 'transparent'
9408
9814
  },
@@ -9414,237 +9820,251 @@ function ListBoxRadioButton(_ref2) {
9414
9820
  });
9415
9821
  }
9416
9822
 
9417
- const KEYS = Object.freeze({
9418
- ENTER: 13,
9419
- ESCAPE: 27,
9420
- SPACE: 32,
9421
- TAB: 9,
9422
- BACKSPACE: 8,
9423
- DELETE: 46,
9424
- ALT: 18,
9425
- CTRL: 17,
9426
- SHIFT: 16,
9427
- ARROW_UP: 38,
9428
- ARROW_DOWN: 40,
9429
- ARROW_LEFT: 37,
9430
- ARROW_RIGHT: 39,
9431
- PAGE_DOWN: 34,
9432
- PAGE_UP: 33,
9433
- HOME: 36,
9434
- END: 35,
9435
- F10: 121,
9436
- A: 65,
9437
- F: 70,
9438
- ZERO: 48,
9439
- NINE: 57,
9440
- NUMPAD_ZERO: 96,
9441
- NUMPAD_NINE: 105,
9442
- SUBTRACTION: 189,
9443
- DECIMAL: 190,
9444
- NUMPAD_DECIMAL: 110,
9445
- isArrow: key => key === KEYS.ARROW_UP || key === KEYS.ARROW_DOWN || key === KEYS.ARROW_LEFT || key === KEYS.ARROW_RIGHT
9446
- });
9447
-
9448
- function getFieldKeyboardNavigation(_ref) {
9823
+ function ValueField(_ref) {
9449
9824
  let {
9450
- select,
9451
- confirm,
9452
- cancel,
9453
- setScrollPosition,
9454
- focusListItems
9825
+ label,
9826
+ color,
9827
+ highlighted = false,
9828
+ dense,
9829
+ showGray = true,
9830
+ checkboxes,
9831
+ cell,
9832
+ valueTextAlign
9455
9833
  } = _ref;
9456
- const getElement = function (elm) {
9457
- let next = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
9458
- const parentElm = elm && elm.parentElement[next ? 'nextElementSibling' : 'previousElementSibling'];
9459
- return parentElm && parentElm.querySelector('[role]');
9460
- };
9461
- let startedRange = false;
9462
- const setStartedRange = val => {
9463
- startedRange = val;
9464
- };
9465
- const handleKeyDown = event => {
9466
- let elementToFocus;
9467
- const {
9468
- keyCode,
9469
- shiftKey = false,
9470
- ctrlKey = false
9471
- } = event.nativeEvent;
9472
- switch (keyCode) {
9473
- case KEYS.SHIFT:
9474
- // This is to ensure we include the first value when starting a range selection.
9475
- setStartedRange(true);
9476
- break;
9477
- case KEYS.SPACE:
9478
- select([+event.currentTarget.getAttribute('data-n')]);
9479
- break;
9480
- case KEYS.ARROW_DOWN:
9481
- case KEYS.ARROW_RIGHT:
9482
- elementToFocus = getElement(event.currentTarget, true);
9483
- if (shiftKey && elementToFocus) {
9484
- if (startedRange) {
9485
- select([+event.currentTarget.getAttribute('data-n')], true);
9486
- setStartedRange(false);
9487
- }
9488
- select([+elementToFocus.getAttribute('data-n')], true);
9489
- }
9490
- break;
9491
- case KEYS.ARROW_UP:
9492
- case KEYS.ARROW_LEFT:
9493
- elementToFocus = getElement(event.currentTarget, false);
9494
- if (shiftKey && elementToFocus) {
9495
- if (startedRange) {
9496
- select([+event.currentTarget.getAttribute('data-n')], true);
9497
- setStartedRange(false);
9498
- }
9499
- select([+elementToFocus.getAttribute('data-n')], true);
9500
- }
9501
- break;
9502
- case KEYS.ENTER:
9503
- confirm();
9504
- break;
9505
- case KEYS.ESCAPE:
9506
- cancel();
9507
- return;
9508
- // let it propagate to top-level
9509
- case KEYS.HOME:
9510
- focusListItems.setFirst(true);
9511
- if (ctrlKey) {
9512
- setScrollPosition === null || setScrollPosition === void 0 ? void 0 : setScrollPosition('overflowStart');
9513
- break;
9514
- }
9515
- setScrollPosition === null || setScrollPosition === void 0 ? void 0 : setScrollPosition('start');
9516
- break;
9517
- case KEYS.END:
9518
- focusListItems.setLast(true);
9519
- if (ctrlKey) {
9520
- setScrollPosition === null || setScrollPosition === void 0 ? void 0 : setScrollPosition('overflowEnd');
9521
- break;
9522
- }
9523
- setScrollPosition === null || setScrollPosition === void 0 ? void 0 : setScrollPosition('end');
9524
- break;
9525
- default:
9526
- return;
9527
- // don't stop propagation since we want to outsource keydown to other handlers.
9528
- }
9529
-
9530
- if (elementToFocus) {
9531
- elementToFocus.focus();
9834
+ return /*#__PURE__*/React__default.createElement(Typography, {
9835
+ component: "span",
9836
+ variant: "body2",
9837
+ className: joinClassNames([rowColClasses.labelText, highlighted && rowColClasses.highlighted, dense && rowColClasses.labelDense, showGray && excludedOrAlternative({
9838
+ cell,
9839
+ checkboxes
9840
+ }) && rowColClasses.excludedTextWithCheckbox]),
9841
+ color: color,
9842
+ justifyContent: valueTextAlign
9843
+ }, /*#__PURE__*/React__default.createElement("span", {
9844
+ style: {
9845
+ whiteSpace: 'pre'
9532
9846
  }
9533
- event.preventDefault();
9534
- event.stopPropagation();
9535
- };
9536
- return handleKeyDown;
9847
+ }, label));
9537
9848
  }
9538
- function getListboxInlineKeyboardNavigation(_ref2) {
9849
+
9850
+ function LabelTag(_ref) {
9539
9851
  let {
9540
- setKeyboardActive,
9541
- hovering,
9542
- setHovering,
9543
- updateKeyScroll,
9544
- containerRef,
9545
- currentScrollIndex,
9546
- app,
9547
- appSelections,
9548
- constraints
9549
- } = _ref2;
9550
- const focusInsideListbox = element => {
9551
- const fieldElement = element.querySelector('.search input, .value.selector, .value, .ActionsToolbar-* button');
9552
- setKeyboardActive(true);
9553
- if (fieldElement) {
9554
- fieldElement.focus();
9555
- }
9556
- };
9557
- const focusContainer = element => {
9558
- setKeyboardActive(false);
9559
- element.focus();
9560
- };
9561
- const updateKeyScrollOnHover = newState => {
9562
- if (hovering) {
9563
- updateKeyScroll(newState);
9564
- }
9565
- };
9566
- const handleKeyDown = event => {
9567
- const {
9568
- keyCode,
9569
- ctrlKey = false,
9570
- shiftKey = false
9571
- } = event.nativeEvent;
9572
- switch (keyCode) {
9573
- // case KEYS.TAB: TODO: Focus confirm button using keyboard.focusSelection when we can access the useKeyboard hook.
9574
- case KEYS.ENTER:
9575
- case KEYS.SPACE:
9576
- if (!event.target.classList.contains('listbox-container')) {
9577
- return; // don't mess with keydown handlers within the listbox
9578
- }
9852
+ label,
9853
+ color,
9854
+ highlighted,
9855
+ dense,
9856
+ showGray,
9857
+ checkboxes,
9858
+ cell,
9859
+ valueTextAlign
9860
+ } = _ref;
9861
+ if (typeof label === 'string') {
9862
+ return /*#__PURE__*/React__default.createElement(ValueField, {
9863
+ label: label,
9864
+ color: color,
9865
+ highlighted: highlighted,
9866
+ dense: dense,
9867
+ showGray: showGray,
9868
+ checkboxes: checkboxes,
9869
+ cell: cell,
9870
+ valueTextAlign: valueTextAlign
9871
+ });
9872
+ }
9873
+ return label;
9874
+ }
9579
9875
 
9580
- focusInsideListbox(event.currentTarget);
9581
- break;
9582
- case KEYS.ESCAPE:
9583
- focusContainer(event.currentTarget);
9584
- break;
9585
- case KEYS.ARROW_UP:
9586
- updateKeyScrollOnHover({
9587
- up: 1
9588
- });
9589
- break;
9590
- case KEYS.ARROW_DOWN:
9591
- updateKeyScrollOnHover({
9592
- down: 1
9593
- });
9594
- break;
9595
- case KEYS.PAGE_UP:
9596
- updateKeyScrollOnHover({
9597
- up: currentScrollIndex.stop - currentScrollIndex.start
9598
- });
9599
- break;
9600
- case KEYS.PAGE_DOWN:
9601
- updateKeyScrollOnHover({
9602
- down: currentScrollIndex.stop - currentScrollIndex.start
9603
- });
9604
- break;
9605
- case KEYS.HOME:
9606
- updateKeyScrollOnHover({
9607
- scrollPosition: ctrlKey && shiftKey ? 'overflowStart' : 'start'
9608
- });
9609
- break;
9610
- case KEYS.END:
9611
- updateKeyScrollOnHover({
9612
- scrollPosition: ctrlKey && shiftKey ? 'overflowEnd' : 'end'
9613
- });
9614
- break;
9615
- default:
9616
- return;
9617
- }
9876
+ function CheckboxField(_ref) {
9877
+ let {
9878
+ label,
9879
+ color,
9880
+ qElemNumber,
9881
+ isSelected,
9882
+ dense,
9883
+ cell,
9884
+ isGridCol,
9885
+ showGray,
9886
+ isSingleSelect,
9887
+ highlighted,
9888
+ checkboxes,
9889
+ valueTextAlign
9890
+ } = _ref;
9891
+ const cb = /*#__PURE__*/React__default.createElement(ListboxCheckbox, {
9892
+ label: label,
9893
+ checked: isSelected,
9894
+ dense: dense,
9895
+ excluded: isExcluded(cell),
9896
+ isGridCol: isGridCol,
9897
+ showGray: showGray
9898
+ });
9899
+ const rb = /*#__PURE__*/React__default.createElement(ListBoxRadioButton, {
9900
+ label: label,
9901
+ checked: isSelected,
9902
+ dense: dense
9903
+ });
9904
+ return /*#__PURE__*/React__default.createElement(FormControlLabel, {
9905
+ color: color,
9906
+ control: isSingleSelect ? rb : cb,
9907
+ className: rowColClasses.checkboxLabel,
9908
+ label: /*#__PURE__*/React__default.createElement(LabelTag, {
9909
+ label: label,
9910
+ color: color,
9911
+ highlighted: highlighted,
9912
+ dense: dense,
9913
+ showGray: showGray,
9914
+ checkboxes: checkboxes,
9915
+ cell: cell,
9916
+ valueTextAlign: valueTextAlign
9917
+ }),
9918
+ key: qElemNumber
9919
+ });
9920
+ }
9618
9921
 
9619
- // Note: We should not stop propagation here as it will block the containing app
9620
- // from handling keydown events.
9621
- event.preventDefault();
9622
- };
9623
- const focusOnHoverDisabled = () => {
9624
- var _app$isInModalSelecti, _app$isInModalSelecti2;
9625
- const selectNotAllowed = (constraints === null || constraints === void 0 ? void 0 : constraints.select) || (constraints === null || constraints === void 0 ? void 0 : constraints.active);
9626
- const appInModal = (_app$isInModalSelecti = (_app$isInModalSelecti2 = app.isInModalSelection) === null || _app$isInModalSelecti2 === void 0 ? void 0 : _app$isInModalSelecti2.call(app)) !== null && _app$isInModalSelecti !== void 0 ? _app$isInModalSelecti : appSelections.isInModal();
9627
- return selectNotAllowed || appInModal;
9628
- };
9629
- const handleOnMouseEnter = () => {
9630
- if (!focusOnHoverDisabled()) {
9631
- var _containerRef$current, _containerRef$current2;
9632
- setHovering(true);
9633
- containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : (_containerRef$current2 = _containerRef$current.focus) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.call(_containerRef$current);
9634
- }
9635
- };
9636
- const handleOnMouseLeave = () => {
9637
- if (hovering) {
9638
- var _containerRef$current3, _containerRef$current4;
9639
- setHovering(false);
9640
- containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : (_containerRef$current4 = _containerRef$current3.blur) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.call(_containerRef$current3);
9922
+ function LabelsWithRanges(_ref) {
9923
+ let {
9924
+ labels,
9925
+ dense,
9926
+ showGray,
9927
+ checkboxes
9928
+ } = _ref;
9929
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, labels.map(_ref2 => {
9930
+ let [label, highlighted] = _ref2;
9931
+ return /*#__PURE__*/React__default.createElement(ValueField, {
9932
+ label: label,
9933
+ key: label,
9934
+ highlighted: highlighted,
9935
+ dense: dense,
9936
+ showGray: showGray,
9937
+ checkboxes: checkboxes
9938
+ });
9939
+ }));
9940
+ }
9941
+ function FieldWithRanges(_ref3) {
9942
+ let {
9943
+ labels,
9944
+ checkboxes,
9945
+ dense,
9946
+ showGray,
9947
+ color,
9948
+ qElemNumber,
9949
+ isSelected,
9950
+ cell,
9951
+ isGridCol,
9952
+ isSingleSelect,
9953
+ valueTextAlign
9954
+ } = _ref3;
9955
+ const LWR = /*#__PURE__*/React__default.createElement(LabelsWithRanges, {
9956
+ labels: labels,
9957
+ dense: dense,
9958
+ showGray: showGray,
9959
+ checkboxes: checkboxes
9960
+ });
9961
+ return checkboxes ? /*#__PURE__*/React__default.createElement(CheckboxField, {
9962
+ label: LWR,
9963
+ color: color,
9964
+ qElemNumber: qElemNumber,
9965
+ isSelected: isSelected,
9966
+ dense: dense,
9967
+ cell: cell,
9968
+ isGridCol: isGridCol,
9969
+ showGray: showGray,
9970
+ isSingleSelect: isSingleSelect,
9971
+ checkboxes: checkboxes,
9972
+ valueTextAlign: valueTextAlign
9973
+ }) : LWR;
9974
+ }
9975
+
9976
+ function Field(_ref) {
9977
+ let {
9978
+ label,
9979
+ color,
9980
+ qElemNumber,
9981
+ isSelected,
9982
+ dense,
9983
+ cell,
9984
+ isGridCol,
9985
+ showGray,
9986
+ isSingleSelect,
9987
+ highlighted,
9988
+ checkboxes,
9989
+ valueTextAlign
9990
+ } = _ref;
9991
+ return checkboxes ? /*#__PURE__*/React__default.createElement(CheckboxField, {
9992
+ label: label,
9993
+ color: color,
9994
+ qElemNumber: qElemNumber,
9995
+ isSelected: isSelected,
9996
+ dense: dense,
9997
+ cell: cell,
9998
+ isGridCol: isGridCol,
9999
+ showGray: showGray,
10000
+ isSingleSelect: isSingleSelect,
10001
+ highlighted: highlighted,
10002
+ checkboxes: checkboxes,
10003
+ valueTextAlign: valueTextAlign
10004
+ }) : /*#__PURE__*/React__default.createElement(ValueField, {
10005
+ label: label,
10006
+ color: color,
10007
+ highlighted: false,
10008
+ dense: dense,
10009
+ showGray: true,
10010
+ checkboxes: checkboxes,
10011
+ cell: cell,
10012
+ valueTextAlign: valueTextAlign
10013
+ });
10014
+ }
10015
+
10016
+ function Histogram(_ref) {
10017
+ let {
10018
+ cell,
10019
+ histogram,
10020
+ checkboxes,
10021
+ isSelected,
10022
+ frequencyMax
10023
+ } = _ref;
10024
+ const hasHistogramBar = cell && histogram && getFrequencyText({
10025
+ cell
10026
+ }) !== frequencyTextNone;
10027
+ if (!hasHistogramBar) {
10028
+ return undefined;
10029
+ }
10030
+ const width = getBarWidth({
10031
+ qFrequency: cell.qFrequency,
10032
+ checkboxes,
10033
+ frequencyMax
10034
+ });
10035
+ return /*#__PURE__*/React__default.createElement("div", {
10036
+ className: joinClassNames([rowColClasses.bar, checkboxes && rowColClasses.barWithCheckbox, isSelected && (checkboxes ? rowColClasses.barSelectedWithCheckbox : rowColClasses.barSelected)]),
10037
+ style: {
10038
+ width
9641
10039
  }
9642
- };
9643
- return {
9644
- handleKeyDown,
9645
- handleOnMouseEnter,
9646
- handleOnMouseLeave
9647
- };
10040
+ });
10041
+ }
10042
+
10043
+ function Frequency(_ref) {
10044
+ let {
10045
+ cell,
10046
+ checkboxes,
10047
+ dense,
10048
+ showGray
10049
+ } = _ref;
10050
+ return /*#__PURE__*/React__default.createElement(Grid, {
10051
+ item: true,
10052
+ style: {
10053
+ display: 'flex',
10054
+ alignItems: 'center'
10055
+ },
10056
+ className: rowColClasses.frequencyCount
10057
+ }, /*#__PURE__*/React__default.createElement(Typography, {
10058
+ noWrap: true,
10059
+ color: "inherit",
10060
+ variant: "body2",
10061
+ className: joinClassNames([dense && rowColClasses.labelDense, rowColClasses.labelText, showGray && excludedOrAlternative({
10062
+ cell,
10063
+ checkboxes
10064
+ }) && rowColClasses.excludedTextWithCheckbox])
10065
+ }, getFrequencyText({
10066
+ cell
10067
+ })));
9648
10068
  }
9649
10069
 
9650
10070
  function getGridItemSizes(_ref) {
@@ -9663,235 +10083,37 @@ function getGridItemSizes(_ref) {
9663
10083
  switch (layoutOrder) {
9664
10084
  case 'row':
9665
10085
  return {
9666
- height: "calc(100% - ".concat(itemPadding, "px)"),
9667
- width: "calc(100% - ".concat(2 * itemPadding, "px)")
9668
- };
9669
- case 'column':
9670
- return {
9671
- height: "calc(100% - ".concat(itemPadding, "px)"),
9672
- width: "calc(100% - ".concat(2 * itemPadding, "px)")
9673
- };
9674
- default:
9675
- return {};
9676
- }
9677
- }
9678
-
9679
- const PREFIX$a = 'RowColumn';
9680
- const classes$a = {
9681
- row: "".concat(PREFIX$a, "-row"),
9682
- rowBorderBottom: "".concat(PREFIX$a, "-rowBorderBottom"),
9683
- column: "".concat(PREFIX$a, "-column"),
9684
- fieldRoot: "".concat(PREFIX$a, "-fieldRoot"),
9685
- cell: "".concat(PREFIX$a, "-cell"),
9686
- labelText: "".concat(PREFIX$a, "-labelText"),
9687
- labelDense: "".concat(PREFIX$a, "-labelDense"),
9688
- highlighted: "".concat(PREFIX$a, "-highlighted"),
9689
- checkboxLabel: "".concat(PREFIX$a, "-checkboxLabel"),
9690
- icon: "".concat(PREFIX$a, "-icon"),
9691
- S: "".concat(PREFIX$a, "-S"),
9692
- XS: "".concat(PREFIX$a, "-XS"),
9693
- A: "".concat(PREFIX$a, "-A"),
9694
- X: "".concat(PREFIX$a, "-X"),
9695
- frequencyCount: "".concat(PREFIX$a, "-frequencyCount"),
9696
- barContainer: "".concat(PREFIX$a, "-barContainer"),
9697
- bar: "".concat(PREFIX$a, "-bar"),
9698
- barSelected: "".concat(PREFIX$a, "-barSelected"),
9699
- barWithCheckbox: "".concat(PREFIX$a, "-barWithCheckbox"),
9700
- barSelectedWithCheckbox: "".concat(PREFIX$a, "-barSelectedWithCheckbox"),
9701
- excludedTextWithCheckbox: "".concat(PREFIX$a, "-excludedTextWithCheckbox")
9702
- };
9703
- const ellipsis = {
9704
- width: '100%',
9705
- overflow: 'hidden',
9706
- textOverflow: 'ellipsis'
9707
- };
9708
- const barPadPx = 4;
9709
- const barBorderWidthPx = 1;
9710
- const barWithCheckboxLeftPadPx = 29;
9711
- const frequencyTextNone = '-';
9712
- const getSelectedStyle = _ref => {
9713
- let {
9714
- theme
9715
- } = _ref;
9716
- return {
9717
- background: theme.palette.selected.main,
9718
- color: theme.palette.selected.mainContrastText,
9719
- '&:focus': {
9720
- boxShadow: "inset 0 0 0 2px ".concat(theme.palette.custom.focusBorder),
9721
- outline: 'none'
9722
- },
9723
- '& $cell': {
9724
- paddingRight: 0
9725
- }
9726
- };
9727
- };
10086
+ height: "calc(100% - ".concat(itemPadding, "px)"),
10087
+ width: "calc(100% - ".concat(2 * itemPadding, "px)")
10088
+ };
10089
+ case 'column':
10090
+ return {
10091
+ height: "calc(100% - ".concat(itemPadding, "px)"),
10092
+ width: "calc(100% - ".concat(2 * itemPadding, "px)")
10093
+ };
10094
+ default:
10095
+ return {};
10096
+ }
10097
+ }
10098
+
9728
10099
  const ItemGrid = styled$1(Grid, {
9729
10100
  shouldForwardProp: prop => !['dataLayout', 'layoutOrder', 'itemPadding'].includes(prop)
9730
- })(_ref2 => {
10101
+ })(_ref => {
9731
10102
  let {
9732
10103
  dataLayout,
9733
10104
  layoutOrder,
9734
10105
  itemPadding
9735
- } = _ref2;
10106
+ } = _ref;
9736
10107
  return {
9737
- ["&.".concat(classes$a.fieldRoot)]: getGridItemSizes({
10108
+ ["&.".concat(rowColClasses.fieldRoot)]: getGridItemSizes({
9738
10109
  dataLayout,
9739
10110
  layoutOrder,
9740
10111
  itemPadding
9741
10112
  })
9742
10113
  };
9743
10114
  });
9744
- const Root$1 = styled$1('div', {
9745
- shouldForwardProp: prop => !['flexBasisProp', 'isGridMode', 'isGridCol', 'dense'].includes(prop)
9746
- })(_ref3 => {
9747
- var _theme$listBox$conten, _theme$listBox, _theme$listBox$conten2, _theme$listBox$conten3, _theme$listBox2, _theme$listBox2$conte, _theme$listBox3, _theme$listBox3$conte, _theme$listBox4, _theme$listBox4$conte;
9748
- let {
9749
- theme,
9750
- flexBasisProp,
9751
- isGridMode,
9752
- isGridCol,
9753
- dense
9754
- } = _ref3;
9755
- return {
9756
- '&:focus': {
9757
- boxShadow: "inset 0 0 0 2px ".concat(theme.palette.custom.focusBorder, " !important")
9758
- },
9759
- '&:focus-visible': {
9760
- outline: 'none'
9761
- },
9762
- ["& .".concat(classes$a.row)]: {
9763
- flexWrap: 'nowrap',
9764
- color: (_theme$listBox$conten = (_theme$listBox = theme.listBox) === null || _theme$listBox === void 0 ? void 0 : (_theme$listBox$conten2 = _theme$listBox.content) === null || _theme$listBox$conten2 === void 0 ? void 0 : _theme$listBox$conten2.color) !== null && _theme$listBox$conten !== void 0 ? _theme$listBox$conten : theme.palette.text.primary
9765
- },
9766
- ["& .".concat(classes$a.rowBorderBottom)]: {
9767
- borderBottom: isGridCol ? 'none' : "1px solid ".concat(theme.palette.divider),
9768
- borderLeft: isGridCol ? "1px solid ".concat(theme.palette.divider) : 'none'
9769
- },
9770
- ["& .".concat(classes$a.column)]: {
9771
- flexWrap: 'nowrap',
9772
- borderRight: "1px solid ".concat(theme.palette.divider),
9773
- color: (_theme$listBox$conten3 = (_theme$listBox2 = theme.listBox) === null || _theme$listBox2 === void 0 ? void 0 : (_theme$listBox2$conte = _theme$listBox2.content) === null || _theme$listBox2$conte === void 0 ? void 0 : _theme$listBox2$conte.color) !== null && _theme$listBox$conten3 !== void 0 ? _theme$listBox$conten3 : theme.palette.text.primary
9774
- },
9775
- // The interior wrapper for all field content.
9776
- ["& .".concat(classes$a.cell)]: {
9777
- display: 'flex',
9778
- alignItems: 'center',
9779
- minWidth: 0,
9780
- flexGrow: 1,
9781
- // Note that this padding is overridden when using checkboxes.
9782
- paddingLeft: '9px',
9783
- paddingRight: '9px'
9784
- },
9785
- // The leaf node, containing the label text.
9786
- ["& .".concat(classes$a.labelText)]: _objectSpread2(_objectSpread2({
9787
- flexBasis: flexBasisProp,
9788
- lineHeight: '16px',
9789
- userSelect: 'none',
9790
- whiteSpace: 'pre',
9791
- // to keep white-space on highlight
9792
- paddingRight: '9px'
9793
- }, ellipsis), {}, {
9794
- fontSize: (_theme$listBox3 = theme.listBox) === null || _theme$listBox3 === void 0 ? void 0 : (_theme$listBox3$conte = _theme$listBox3.content) === null || _theme$listBox3$conte === void 0 ? void 0 : _theme$listBox3$conte.fontSize,
9795
- fontFamily: (_theme$listBox4 = theme.listBox) === null || _theme$listBox4 === void 0 ? void 0 : (_theme$listBox4$conte = _theme$listBox4.content) === null || _theme$listBox4$conte === void 0 ? void 0 : _theme$listBox4$conte.fontFamily
9796
- }),
9797
- ["& .".concat(classes$a.labelDense)]: {
9798
- fontSize: 12
9799
- },
9800
- // Highlight is added to labelText spans, which are created as siblings to original labelText,
9801
- // when a search string is matched.
9802
- ["& .".concat(classes$a.highlighted)]: {
9803
- overflow: 'visible',
9804
- width: '100%',
9805
- '& > span': {
9806
- width: '100%',
9807
- backgroundColor: '#FFC72A'
9808
- }
9809
- },
9810
- // Checkbox and label container.
9811
- ["& .".concat(classes$a.checkboxLabel)]: {
9812
- margin: 0,
9813
- width: '100%',
9814
- height: '100%',
9815
- overflow: 'hidden',
9816
- // The checkbox's span
9817
- '& > span:nth-of-type(1)': {
9818
- paddingRight: '8px'
9819
- },
9820
- // The checkbox's label container.
9821
- '& > span:nth-of-type(2)': _objectSpread2(_objectSpread2({}, ellipsis), {}, {
9822
- display: 'flex',
9823
- alignItems: 'center',
9824
- paddingLeft: 0,
9825
- paddingRight: '2px'
9826
- })
9827
- },
9828
- // The icons container holding tick and lock, shown inside fields.
9829
- ["& .".concat(classes$a.icon)]: {
9830
- display: 'flex',
9831
- padding: theme.spacing(1, 1, 1, 0)
9832
- },
9833
- // Selection styles (S=Selected, XS=ExcludedSelected, A=Available, X=Excluded).
9834
- ["& .".concat(classes$a.S)]: _objectSpread2(_objectSpread2({}, getSelectedStyle({
9835
- theme
9836
- })), {}, {
9837
- border: isGridMode ? 'none' : undefined
9838
- }),
9839
- ["& .".concat(classes$a.XS)]: _objectSpread2(_objectSpread2({}, getSelectedStyle({
9840
- theme
9841
- })), {}, {
9842
- background: theme.palette.selected.excluded,
9843
- color: theme.palette.selected.mainContrastText,
9844
- border: isGridMode ? 'none' : undefined
9845
- }),
9846
- ["& .".concat(classes$a.A)]: {
9847
- background: theme.palette.selected.alternative,
9848
- color: theme.palette.selected.alternativeContrastText,
9849
- border: isGridMode ? 'none' : undefined
9850
- },
9851
- ["& .".concat(classes$a.X)]: {
9852
- background: theme.palette.selected.excluded,
9853
- color: theme.palette.selected.excludedContrastText,
9854
- border: isGridMode ? 'none' : undefined
9855
- },
9856
- ["& .".concat(classes$a.frequencyCount)]: {
9857
- width: '66px',
9858
- justifyContent: 'flex-end'
9859
- },
9860
- ["&.".concat(classes$a.barContainer)]: {
9861
- height: '100%',
9862
- display: 'flex',
9863
- alignItems: 'center'
9864
- },
9865
- ["& .".concat(classes$a.bar)]: {
9866
- border: "".concat(barBorderWidthPx, "px solid"),
9867
- borderColor: '#D9D9D9',
9868
- height: dense ? '16px' : '20px',
9869
- position: 'absolute',
9870
- zIndex: '-1',
9871
- alignSelf: 'center',
9872
- left: "".concat(barPadPx, "px"),
9873
- transition: 'width 0.2s',
9874
- backgroundColor: '#FAFAFA'
9875
- },
9876
- ["& .".concat(classes$a.barSelected)]: {
9877
- opacity: '30%',
9878
- zIndex: '0',
9879
- background: theme.palette.background.lighter
9880
- },
9881
- ["& .".concat(classes$a.barWithCheckbox)]: {
9882
- left: "".concat(barWithCheckboxLeftPadPx, "px")
9883
- },
9884
- ["& .".concat(classes$a.barSelectedWithCheckbox)]: {
9885
- background: '#BFE5D0',
9886
- borderColor: '#BFE5D0'
9887
- },
9888
- ["& .".concat(classes$a.excludedTextWithCheckbox)]: {
9889
- color: '#828282',
9890
- fontStyle: 'italic'
9891
- }
9892
- };
9893
- });
9894
- function RowColumn(_ref4) {
10115
+
10116
+ function RowColumn(_ref) {
9895
10117
  var _cell$qText;
9896
10118
  let {
9897
10119
  index,
@@ -9899,7 +10121,7 @@ function RowColumn(_ref4) {
9899
10121
  columnIndex,
9900
10122
  style,
9901
10123
  data
9902
- } = _ref4;
10124
+ } = _ref;
9903
10125
  const {
9904
10126
  onClick,
9905
10127
  onMouseDown,
@@ -9993,25 +10215,23 @@ function RowColumn(_ref4) {
9993
10215
  }
9994
10216
  setCell(c);
9995
10217
  }, [pages]);
9996
- const isExcluded = c => c ? c.qState === 'X' || c.qState === 'XS' || c.qState === 'XL' : null;
9997
- const isAlternative = c => c ? c.qState === 'A' : null;
9998
10218
  useEffect$1(() => {
9999
10219
  if (!cell) {
10000
10220
  return;
10001
10221
  }
10002
10222
  const selected = cell.qState === 'S' || cell.qState === 'XS' || cell.qState === 'L';
10003
10223
  setSelected(selected);
10004
- const clazzArr = [column ? classes$a.column : classes$a.row];
10005
- if (!(histogram && (dense || checkboxes))) clazzArr.push(classes$a.rowBorderBottom);
10224
+ const clazzArr = [column ? rowColClasses.column : rowColClasses.row];
10225
+ if (!(histogram && (dense || checkboxes))) clazzArr.push(rowColClasses.rowBorderBottom);
10006
10226
  if (!checkboxes) {
10007
10227
  if (cell.qState === 'XS') {
10008
- clazzArr.push(showGray ? classes$a.XS : classes$a.S);
10228
+ clazzArr.push(showGray ? rowColClasses.XS : rowColClasses.S);
10009
10229
  } else if (cell.qState === 'S' || cell.qState === 'L') {
10010
- clazzArr.push(classes$a.S);
10230
+ clazzArr.push(rowColClasses.S);
10011
10231
  } else if (showGray && isAlternative(cell)) {
10012
- clazzArr.push(classes$a.A);
10232
+ clazzArr.push(rowColClasses.A);
10013
10233
  } else if (showGray && isExcluded(cell)) {
10014
- clazzArr.push(classes$a.X);
10234
+ clazzArr.push(rowColClasses.X);
10015
10235
  }
10016
10236
  }
10017
10237
  setClassArr(clazzArr);
@@ -10020,8 +10240,6 @@ function RowColumn(_ref4) {
10020
10240
  return null; // prevent rendering empty rows
10021
10241
  }
10022
10242
 
10023
- const joinClassNames = namesArray => namesArray.filter(c => !!c).join(' ').trim();
10024
- const excludedOrAlternative = () => (isAlternative(cell) || isExcluded(cell)) && checkboxes;
10025
10243
  const isNumeric = !['NaN', undefined].includes(cell === null || cell === void 0 ? void 0 : cell.qNum);
10026
10244
  let valueTextAlign;
10027
10245
  const isAutoTextAlign = !textAlign || textAlign.auto;
@@ -10034,26 +10252,6 @@ function RowColumn(_ref4) {
10034
10252
  } else {
10035
10253
  valueTextAlign = (textAlign === null || textAlign === void 0 ? void 0 : textAlign.align) || 'left';
10036
10254
  }
10037
- const getValueField = _ref5 => {
10038
- let {
10039
- lbl,
10040
- ix,
10041
- color,
10042
- highlighted = false
10043
- } = _ref5;
10044
- return /*#__PURE__*/React__default.createElement(Typography, {
10045
- component: "span",
10046
- variant: "body2",
10047
- key: ix,
10048
- className: joinClassNames([classes$a.labelText, highlighted && classes$a.highlighted, dense && classes$a.labelDense, showGray && excludedOrAlternative() && classes$a.excludedTextWithCheckbox]),
10049
- color: color,
10050
- justifyContent: valueTextAlign
10051
- }, /*#__PURE__*/React__default.createElement("span", {
10052
- style: {
10053
- whiteSpace: 'pre'
10054
- }
10055
- }, lbl));
10056
- };
10057
10255
  const preventContextMenu = event => {
10058
10256
  if (checkboxes) {
10059
10257
  // Event will not propagate in the checkbox/radiobutton case
@@ -10062,66 +10260,11 @@ function RowColumn(_ref4) {
10062
10260
  event.preventDefault();
10063
10261
  };
10064
10262
  const isGridCol = dataLayout === 'grid' && layoutOrder === 'column';
10065
- const getCheckboxField = _ref6 => {
10066
- let {
10067
- lbl,
10068
- color,
10069
- qElemNumber
10070
- } = _ref6;
10071
- const cb = /*#__PURE__*/React__default.createElement(ListboxCheckbox, {
10072
- label: lbl,
10073
- checked: isSelected,
10074
- dense: dense,
10075
- excluded: isExcluded(cell),
10076
- isGridCol: isGridCol,
10077
- showGray: showGray
10078
- });
10079
- const rb = /*#__PURE__*/React__default.createElement(ListBoxRadioButton, {
10080
- label: lbl,
10081
- checked: isSelected,
10082
- dense: dense
10083
- });
10084
- const labelTag = typeof lbl === 'string' ? getValueField({
10085
- lbl,
10086
- color,
10087
- highlighted: false
10088
- }) : lbl;
10089
- return /*#__PURE__*/React__default.createElement(FormControlLabel, {
10090
- color: color,
10091
- control: isSingleSelect ? rb : cb,
10092
- className: classes$a.checkboxLabel,
10093
- label: labelTag,
10094
- key: qElemNumber
10095
- });
10096
- };
10097
10263
  const label = (_cell$qText = cell === null || cell === void 0 ? void 0 : cell.qText) !== null && _cell$qText !== void 0 ? _cell$qText : '';
10098
- const getFrequencyText = () => {
10099
- if (cell) {
10100
- return cell.qFrequency ? cell.qFrequency : frequencyTextNone;
10101
- }
10102
- return '';
10103
- };
10104
10264
 
10105
10265
  // Search highlights. Split up labelText span into several and add the highlighted class to matching sub-strings.
10106
10266
  const ranges = cell && cell.qHighlightRanges && cell.qHighlightRanges.qRanges.sort((a, b) => a.qCharPos - b.qCharPos) || [];
10107
10267
  const labels = getSegmentsFromRanges(label, ranges);
10108
- const getField = checkboxes ? getCheckboxField : getValueField;
10109
- const getFieldWithRanges = _ref7 => {
10110
- let {
10111
- lbls
10112
- } = _ref7;
10113
- const labelsWithRanges = lbls.map((_ref8, ix) => {
10114
- let [lbl, highlighted] = _ref8;
10115
- return getValueField({
10116
- ix,
10117
- highlighted,
10118
- lbl
10119
- });
10120
- });
10121
- return checkboxes ? getCheckboxField({
10122
- lbl: labelsWithRanges
10123
- }) : labelsWithRanges;
10124
- };
10125
10268
  const iconStyles = {
10126
10269
  alignItems: 'center',
10127
10270
  display: 'flex',
@@ -10137,19 +10280,10 @@ function RowColumn(_ref4) {
10137
10280
  padding: checkboxes ? 0 : undefined,
10138
10281
  justifyContent: valueTextAlign
10139
10282
  };
10140
- const hasHistogramBar = () => cell && histogram && getFrequencyText() !== frequencyTextNone;
10141
- const getBarWidth = qFrequency => {
10142
- const freqStr = String(qFrequency);
10143
- const isPercent = freqStr.substring(freqStr.length - 1) === '%';
10144
- const freq = parseFloat(isPercent ? freqStr : qFrequency);
10145
- const rightSlice = checkboxes ? "(".concat(barWithCheckboxLeftPadPx, "px + ").concat(barPadPx + barBorderWidthPx * 2, "px)") : "".concat(barPadPx * 2 + barBorderWidthPx * 2, "px");
10146
- const width = isPercent ? freq : freq / frequencyMax * 100;
10147
- return "calc(".concat(width, "% - ").concat(rightSlice, ")");
10148
- };
10149
10283
  const isFirstElement = index === 0;
10150
10284
  const flexBasisVal = checkboxes ? 'auto' : 'max-content';
10151
- return /*#__PURE__*/React__default.createElement(Root$1, {
10152
- className: classes$a.barContainer,
10285
+ return /*#__PURE__*/React__default.createElement(RowColRoot, {
10286
+ className: rowColClasses.barContainer,
10153
10287
  flexBasisProp: flexBasisVal,
10154
10288
  style: styles,
10155
10289
  isGridCol: isGridCol,
@@ -10164,7 +10298,7 @@ function RowColumn(_ref4) {
10164
10298
  gap: 0,
10165
10299
  className: joinClassNames(['value', ...classArr]),
10166
10300
  classes: {
10167
- root: classes$a.fieldRoot
10301
+ root: rowColClasses.fieldRoot
10168
10302
  },
10169
10303
  onClick: onClick,
10170
10304
  onMouseDown: onMouseDown,
@@ -10175,36 +10309,49 @@ function RowColumn(_ref4) {
10175
10309
  role: column ? 'column' : 'row',
10176
10310
  tabIndex: isFirstElement && (!keyboard.enabled || keyboard.active) ? 0 : -1,
10177
10311
  "data-n": cell && cell.qElemNumber
10178
- }, hasHistogramBar() && /*#__PURE__*/React__default.createElement("div", {
10179
- className: joinClassNames([classes$a.bar, checkboxes && classes$a.barWithCheckbox, isSelected && (checkboxes ? classes$a.barSelectedWithCheckbox : classes$a.barSelected)]),
10180
- style: {
10181
- width: getBarWidth(cell.qFrequency)
10182
- }
10312
+ }, /*#__PURE__*/React__default.createElement(Histogram, {
10313
+ cell: cell,
10314
+ histogram: histogram,
10315
+ checkboxes: checkboxes,
10316
+ isSelected: isSelected,
10317
+ frequencyMax: frequencyMax
10183
10318
  }), /*#__PURE__*/React__default.createElement(Grid, {
10184
10319
  item: true,
10185
10320
  style: cellStyle,
10186
- className: joinClassNames([classes$a.cell, classes$a.selectedCell]),
10321
+ className: joinClassNames([rowColClasses.cell, rowColClasses.selectedCell]),
10187
10322
  title: "".concat(label)
10188
- }, ranges.length === 0 ? getField({
10189
- lbl: label,
10190
- color: 'inherit'
10191
- }) : getFieldWithRanges({
10192
- lbls: labels
10193
- })), freqIsAllowed && /*#__PURE__*/React__default.createElement(Grid, {
10194
- item: true,
10195
- style: {
10196
- display: 'flex',
10197
- alignItems: 'center'
10198
- },
10199
- className: classes$a.frequencyCount
10200
- }, /*#__PURE__*/React__default.createElement(Typography, {
10201
- noWrap: true,
10323
+ }, ranges.length === 0 ? /*#__PURE__*/React__default.createElement(Field, {
10324
+ label: label,
10202
10325
  color: "inherit",
10203
- variant: "body2",
10204
- className: joinClassNames([dense && classes$a.labelDense, classes$a.labelText, showGray && excludedOrAlternative() && classes$a.excludedTextWithCheckbox])
10205
- }, getFrequencyText())), !checkboxes && /*#__PURE__*/React__default.createElement(Grid, {
10326
+ qElemNumber: cell.qElemNumber,
10327
+ isSelected: isSelected,
10328
+ dense: dense,
10329
+ cell: cell,
10330
+ isGridCol: isGridCol,
10331
+ showGray: showGray,
10332
+ isSingleSelect: isSingleSelect,
10333
+ checkboxes: checkboxes
10334
+ }) : /*#__PURE__*/React__default.createElement(FieldWithRanges, {
10335
+ labels: labels,
10336
+ checkboxes: checkboxes,
10337
+ dense: dense,
10338
+ showGray: showGray,
10339
+ color: "inherit" // TODO: Check this
10340
+ ,
10341
+ qElemNumber: cell.qElemNumber,
10342
+ isSelected: isSelected,
10343
+ cell: cell,
10344
+ isGridCol: isGridCol,
10345
+ isSingleSelect: isSingleSelect,
10346
+ valueTextAlign: valueTextAlign
10347
+ })), freqIsAllowed && /*#__PURE__*/React__default.createElement(Frequency, {
10348
+ cell: cell,
10349
+ checkboxes: checkboxes,
10350
+ dense: dense,
10351
+ showGray: showGray
10352
+ }), !checkboxes && /*#__PURE__*/React__default.createElement(Grid, {
10206
10353
  item: true,
10207
- className: classes$a.icon
10354
+ className: rowColClasses.icon
10208
10355
  }, !showLock && !showTick && /*#__PURE__*/React__default.createElement("span", {
10209
10356
  style: {
10210
10357
  minWidth: '12px'
@@ -12554,6 +12701,7 @@ function ListBox(_ref) {
12554
12701
  var _layout$qListObject$q, _loaderRef$current, _loaderRef$current$_l, _loaderRef$current$_l2;
12555
12702
  let {
12556
12703
  model,
12704
+ layout,
12557
12705
  selections,
12558
12706
  direction,
12559
12707
  checkboxes: checkboxOption,
@@ -12578,7 +12726,6 @@ function ListBox(_ref) {
12578
12726
  }
12579
12727
  } = _ref;
12580
12728
  const [initScrollPosIsSet, setInitScrollPosIsSet] = useState$1(false);
12581
- const [layout] = useLayout$1(model);
12582
12729
  const isSingleSelect = !!(layout && layout.qListObject.qDimensionInfo.qIsOneAndOnlyOne);
12583
12730
  const {
12584
12731
  checkboxes = checkboxOption,
@@ -13992,6 +14139,7 @@ function ListBoxPopover(_ref) {
13992
14139
  autoFocus: autoFocus !== null && autoFocus !== void 0 ? autoFocus : true
13993
14140
  }), /*#__PURE__*/React__default.createElement(ListBox, {
13994
14141
  model: model,
14142
+ layout: layout,
13995
14143
  selections: selections,
13996
14144
  direction: "ltr",
13997
14145
  onSetListCount: c => setListCount(c)
@@ -14622,6 +14770,52 @@ const selectionsForward = props => _objectSpread2(_objectSpread2({}, props), {},
14622
14770
  });
14623
14771
  var SelectionsForward = (props => SvgIcon$2(selectionsForward(props)));
14624
14772
 
14773
+ const patchAlternateState = (currentSelectionsModel, currentSelectionsLayout, appLayout) => {
14774
+ const states = [...(appLayout.qStateNames || [])].map(s => ({
14775
+ stateName: s,
14776
+ // need this as reference in selection toolbar since qSelectionObject.qStateName is not in the layout
14777
+ qSelectionObjectDef: {
14778
+ qStateName: s
14779
+ }
14780
+ }));
14781
+ const existingStates = (currentSelectionsLayout && currentSelectionsLayout.alternateStates ? currentSelectionsLayout.alternateStates.map(s => s.stateName) : []).join('::');
14782
+ const newStates = (appLayout.qStateNames || []).map(s => s).join('::');
14783
+ if (existingStates !== newStates) {
14784
+ currentSelectionsModel.applyPatches([{
14785
+ qOp: 'replace',
14786
+ qPath: '/alternateStates',
14787
+ qValue: JSON.stringify(states)
14788
+ }], true);
14789
+ }
14790
+ };
14791
+ function useAppSelectionsNavigation(app) {
14792
+ const [currentSelectionsModel] = useCurrentSelectionsModel(app);
14793
+ const [currentSelectionsLayout] = useLayout$1(currentSelectionsModel);
14794
+ const [appLayout] = useAppLayout$1(app);
14795
+ const [navigationState, setNavigationState] = useState$1(null);
14796
+ useEffect$1(() => {
14797
+ if (!appLayout || !currentSelectionsModel || !currentSelectionsLayout) return;
14798
+ patchAlternateState(currentSelectionsModel, currentSelectionsLayout, appLayout);
14799
+ }, [appLayout, currentSelectionsModel, currentSelectionsLayout]);
14800
+ useEffect$1(() => {
14801
+ if (!currentSelectionsLayout) return;
14802
+ let canGoBack = false;
14803
+ let canGoForward = false;
14804
+ let canClear = false;
14805
+ [currentSelectionsLayout, ...(currentSelectionsLayout.alternateStates || [])].forEach(state => {
14806
+ canGoBack = canGoBack || state.qSelectionObject && state.qSelectionObject.qBackCount > 0;
14807
+ canGoForward = canGoForward || state.qSelectionObject && state.qSelectionObject.qForwardCount > 0;
14808
+ canClear = canClear || (state.qSelectionObject && state.qSelectionObject.qSelections || []).filter(s => s.qLocked !== true).length > 0;
14809
+ });
14810
+ setNavigationState({
14811
+ canGoBack,
14812
+ canGoForward,
14813
+ canClear
14814
+ });
14815
+ }, [currentSelectionsLayout]);
14816
+ return [navigationState, currentSelectionsModel, currentSelectionsLayout];
14817
+ }
14818
+
14625
14819
  function Nav(_ref) {
14626
14820
  let {
14627
14821
  api,
@@ -15265,7 +15459,8 @@ const Title = styled$1(Typography)(_ref2 => {
15265
15459
  function ListBoxInline(_ref3) {
15266
15460
  var _layout$layoutOptions, _layout$layoutOptions2;
15267
15461
  let {
15268
- options = {}
15462
+ options,
15463
+ layout
15269
15464
  } = _ref3;
15270
15465
  const {
15271
15466
  app,
@@ -15315,7 +15510,6 @@ function ListBoxInline(_ref3) {
15315
15510
  const moreAlignTo = useRef();
15316
15511
  const containerRef = useRef();
15317
15512
  const [searchContainer, searchContainerRef] = useRefWithCallback();
15318
- const [layout] = useLayout$1(model);
15319
15513
  const [showToolbar, setShowToolbar] = useState$1(false);
15320
15514
  const [showSearch, setShowSearch] = useState$1(false);
15321
15515
  const [keyboardActive, setKeyboardActive] = useState$1(false);
@@ -15540,6 +15734,7 @@ function ListBoxInline(_ref3) {
15540
15734
  } = _ref4;
15541
15735
  return /*#__PURE__*/React__default.createElement(ListBox, {
15542
15736
  model: model,
15737
+ layout: layout,
15543
15738
  selections: selections,
15544
15739
  direction: direction,
15545
15740
  listLayout: listLayout,
@@ -15571,6 +15766,20 @@ function ListBoxInline(_ref3) {
15571
15766
  });
15572
15767
  }))));
15573
15768
  }
15769
+ const ListBoxInlineMemoed = React__default.memo(ListBoxInline);
15770
+ function IsolateUseLayoutWrapper(_ref5) {
15771
+ let {
15772
+ options = {}
15773
+ } = _ref5;
15774
+ const {
15775
+ model
15776
+ } = options;
15777
+ const [layout] = useLayout$1(model);
15778
+ return /*#__PURE__*/React__default.createElement(ListBoxInlineMemoed, {
15779
+ options: options,
15780
+ layout: layout
15781
+ });
15782
+ }
15574
15783
 
15575
15784
  function useExistingModel(_ref) {
15576
15785
  let {
@@ -15833,15 +16042,15 @@ function ListBoxWrapper(_ref) {
15833
16042
  });
15834
16043
  const elementRef = useRef(element);
15835
16044
  const selections = hasExternalSelectionsApi ? options.selectionsApi : useObjectSelections(app, model, [elementRef, '.njs-action-toolbar-more'], options)[0];
15836
- if (!selections || !model) {
15837
- return null;
15838
- }
15839
- const opts = _objectSpread2(_objectSpread2({}, options), {}, {
16045
+ const opts = useMemo$1(() => _objectSpread2(_objectSpread2({}, options), {}, {
15840
16046
  selections,
15841
16047
  model,
15842
16048
  app
15843
- });
15844
- return /*#__PURE__*/React__default.createElement(ListBoxInline, {
16049
+ }), [options, selections, model, app]);
16050
+ if (!selections || !model) {
16051
+ return null;
16052
+ }
16053
+ return /*#__PURE__*/React__default.createElement(IsolateUseLayoutWrapper, {
15845
16054
  options: opts
15846
16055
  });
15847
16056
  }