@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.
@@ -1,5 +1,5 @@
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
  */
@@ -15328,7 +15328,7 @@
15328
15328
  return cache[key];
15329
15329
  }
15330
15330
 
15331
- const NEBULA_VERSION_HASH = "c721" ;
15331
+ const NEBULA_VERSION_HASH = "593e" ;
15332
15332
  ClassNameGenerator$1.configure(componentName => {
15333
15333
  return "njs-".concat(NEBULA_VERSION_HASH, "-").concat(componentName.replace('Mui', ''));
15334
15334
  });
@@ -15383,419 +15383,108 @@
15383
15383
  return [useKeyStore, store];
15384
15384
  });
15385
15385
 
15386
- const [useRpcResultStore, rpcResultStore] = createKeyStore({});
15387
- const [useRpcRequestStore, rpcRequestStore] = createKeyStore({});
15388
- const [useRpcRequestSessionModelStore, rpcRequestSessionModelStore] = createKeyStore({});
15389
- const [useRpcRequestModelStore, rpcRequestModelStore] = createKeyStore({});
15390
- const [useModelChangedStore, modelChangedStore] = createKeyStore({});
15391
- const [, modelInitializedStore] = createKeyStore({});
15392
- const modelStoreMiddleware = _ref => {
15386
+ const [useAppSelectionsStore, appSelectionsStore] = createKeyStore({});
15387
+ const [useAppModalStore, appModalStore] = createKeyStore({});
15388
+ const [useObjectSelectionsStore, objectSelectionsStore] = createKeyStore({});
15389
+ const [useModalObjectStore, modalObjectStore] = createKeyStore({});
15390
+
15391
+ /* eslint no-underscore-dangle: 0 */
15392
+ function createAppSelections(_ref) {
15393
15393
  let {
15394
- type,
15395
- value: model
15394
+ app
15396
15395
  } = _ref;
15397
- const initialized = modelInitializedStore.get(model.id);
15398
- modelInitializedStore.set(model.id, {});
15399
- const onChanged = () => {
15400
- rpcRequestStore.clear(model.id);
15401
- modelChangedStore.set(model.id, {});
15402
- modelChangedStore.dispatch(true); // Force new state to trigger hooks
15396
+ const key = "".concat(app.id);
15397
+ const end = async function () {
15398
+ let accept = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
15399
+ const model = modalObjectStore.get(key);
15400
+ if (model) {
15401
+ await model.endSelections(accept);
15402
+ modalObjectStore.clear(key);
15403
+ const objectSelections = objectSelectionsStore.get(model.id);
15404
+ objectSelections.emit('deactivated');
15405
+ }
15403
15406
  };
15407
+ const begin = async function (model, path) {
15408
+ let accept = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
15409
+ // Quick return if it's already in modal
15410
+ if (model === modalObjectStore.get(key)) {
15411
+ return;
15412
+ }
15404
15413
 
15405
- const unsubscribe = () => {
15406
- model.removeListener('changed', onChanged);
15407
- rpcResultStore.clear(model.id);
15408
- rpcRequestStore.clear(model.id);
15409
- rpcRequestSessionModelStore.clear(model.id);
15410
- rpcRequestModelStore.clear(model.id);
15411
- modelChangedStore.clear(model.id);
15412
- modelInitializedStore.clear(model.id);
15413
- };
15414
- switch (type) {
15415
- case 'SET':
15416
- if (!initialized) {
15417
- model.on('changed', onChanged);
15418
- model.once('closed', () => {
15419
- unsubscribe();
15420
- });
15421
- }
15422
- break;
15423
- }
15424
- return unsubscribe;
15425
- };
15426
- const [useModelStore, modelStore] = createKeyStore({}, modelStoreMiddleware);
15427
- const subscribe = model => {
15428
- const unsubscribe = modelStoreMiddleware({
15429
- type: 'SET',
15430
- value: model
15431
- });
15432
- return () => {
15433
- unsubscribe();
15434
- modelStore.clear(model.id);
15435
- };
15436
- };
15414
+ // If other model is in modal state end it
15415
+ end(accept);
15437
15416
 
15438
- const rpcReducer = (state, action) => {
15439
- const {
15440
- rpcResultStore,
15441
- key,
15442
- method
15443
- } = action;
15444
- let newState;
15445
- switch (action.type) {
15446
- case 'INVALID':
15447
- {
15448
- newState = _objectSpread2(_objectSpread2({}, state), {}, {
15449
- valid: false,
15450
- invalid: true,
15451
- validating: true,
15452
- canCancel: true,
15453
- canRetry: false,
15454
- rpcRetry: false
15455
- });
15456
- break;
15457
- }
15458
- case 'VALID':
15459
- {
15460
- newState = {
15461
- result: _objectSpread2({}, action.result),
15462
- invalid: false,
15463
- valid: true,
15464
- validating: false,
15465
- canCancel: false,
15466
- canRetry: false,
15467
- rpcRetry: false
15468
- };
15469
- break;
15470
- }
15471
- case 'CANCELLED':
15472
- {
15473
- newState = _objectSpread2(_objectSpread2({}, state), {}, {
15474
- invalid: true,
15475
- valid: false,
15476
- validating: false,
15477
- canCancel: false,
15478
- canRetry: true,
15479
- rpcRetry: false
15480
- });
15481
- break;
15482
- }
15483
- default:
15484
- throw new Error('Undefined action');
15485
- }
15486
- let sharedState = rpcResultStore.get(key);
15487
- if (!sharedState) {
15488
- sharedState = {};
15489
- }
15490
- sharedState[method] = newState;
15491
- rpcResultStore.set(key, sharedState);
15492
- return newState;
15493
- };
15494
- function useRpc(model, method) {
15495
- const key = model ? "".concat(model.id) : null;
15496
- const [rpcResultStore] = useRpcResultStore();
15497
- const [state, dispatch] = reactExports.useReducer(rpcReducer, key ? rpcResultStore.get(key) : null);
15498
- const [modelChangedStore] = useModelChangedStore();
15499
- const [rpcRequestStore] = useRpcRequestStore();
15500
- let rpcShared;
15501
- if (key) {
15502
- rpcShared = rpcRequestStore.get(key);
15503
- if (!rpcShared) {
15504
- rpcShared = {};
15505
- rpcRequestStore.set(key, rpcShared);
15506
- }
15507
- }
15508
- const call = async skipRetry => {
15509
- let cache = rpcShared[method];
15510
- if (!cache || cache && cache.rpcRetry) {
15511
- const rpc = model[method]();
15512
- cache = {
15513
- rpc,
15514
- rpcRetry: false
15515
- };
15516
- rpcShared[method] = cache;
15517
- dispatch({
15518
- type: 'INVALID',
15519
- method,
15520
- key,
15521
- model,
15522
- rpcResultStore,
15523
- canCancel: true
15524
- });
15525
- }
15526
- try {
15527
- // await sleep(5000);
15528
- const result = await cache.rpc;
15529
- dispatch({
15530
- type: 'VALID',
15531
- result,
15532
- key,
15533
- method,
15534
- model,
15535
- rpcResultStore
15536
- });
15537
- } catch (err) {
15538
- if (err.code === 15 && !skipRetry) {
15539
- // Request aborted. This will be called multiple times by hooks only retry once
15540
- if (!cache.rpcRetry) {
15541
- cache.rpcRetry = true;
15417
+ // Pending modal
15418
+ modalObjectStore.set(key, model);
15419
+ const p = Array.isArray(path) ? path : [path];
15420
+ const beginSelections = async skipRetry => {
15421
+ try {
15422
+ await model.beginSelections(p);
15423
+ modalObjectStore.set(key, model); // We have a modal
15424
+ } catch (err) {
15425
+ if (err.code === 6003 && !skipRetry) {
15426
+ await app.abortModal(accept);
15427
+ beginSelections(true);
15428
+ } else {
15429
+ modalObjectStore.clear(key); // No modal
15542
15430
  }
15543
- call(true);
15544
15431
  }
15545
- }
15432
+ };
15433
+
15434
+ await beginSelections();
15546
15435
  };
15547
- const longrunning = {
15548
- cancel: async () => {
15549
- const global = model.session.getObjectApi({
15550
- handle: -1
15551
- });
15552
- await global.cancelRequest(rpcShared[method].rpc.requestId);
15553
- dispatch({
15554
- type: 'CANCELLED',
15555
- key,
15556
- method,
15557
- model,
15558
- rpcResultStore
15559
- });
15436
+ const appModal = {
15437
+ begin,
15438
+ end
15439
+ };
15440
+ appModalStore.set(key, appModal);
15441
+
15442
+ /**
15443
+ * @class
15444
+ * @alias AppSelections
15445
+ */
15446
+ const appSelections = {
15447
+ model: app,
15448
+ isInModal() {
15449
+ return !!modalObjectStore.get(key);
15560
15450
  },
15561
- retry: () => {
15562
- rpcShared[method].rpcRetry = true;
15563
- call();
15451
+ isModal(object) {
15452
+ // TODO check model state
15453
+ return object ? modalObjectStore.get(key) === object : !!modalObjectStore.get(key);
15454
+ },
15455
+ forward() {
15456
+ return appModal.end().then(() => app.forward());
15457
+ },
15458
+ back() {
15459
+ return appModal.end().then(() => app.back());
15460
+ },
15461
+ clear() {
15462
+ return appModal.end().then(() => app.clearAll());
15463
+ },
15464
+ clearField(field) {
15465
+ let state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '$';
15466
+ return appModal.end().then(() => app.getField(field, state).then(f => f.clear()));
15564
15467
  }
15565
15468
  };
15566
- reactExports.useEffect(() => {
15567
- if (!model) return undefined;
15568
- call();
15569
- return undefined;
15570
- }, [model, modelChangedStore.get(model && model.id), key, method]);
15571
- return [
15572
- // Result
15573
- state && state.result, {
15574
- validating: state && state.validating,
15575
- canCancel: state && state.canCancel,
15576
- canRetry: state && state.canRetry
15577
- },
15578
- // Long running api e.g cancel retry
15579
- longrunning];
15580
- }
15581
-
15582
- function useLayout$1(model) {
15583
- return useRpc(model, 'getLayout');
15584
- }
15585
- function useAppLayout$1(model) {
15586
- return useRpc(model, 'getAppLayout');
15587
- }
15588
-
15589
- function useSessionModel(definition, app) {
15590
- const key = app ? "".concat(app.id, "/").concat(JSON.stringify(definition)) : null;
15591
- const [modelStore] = useModelStore();
15592
- const [rpcRequestSessionModelStore] = useRpcRequestSessionModelStore();
15593
- const [model, setModel] = reactExports.useState();
15594
- let rpcShared;
15595
- if (key) {
15596
- rpcShared = rpcRequestSessionModelStore.get(key);
15597
- }
15598
- for (var _len = arguments.length, deps = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
15599
- deps[_key - 2] = arguments[_key];
15600
- }
15601
- reactExports.useEffect(() => {
15602
- if (!app) {
15603
- return;
15604
- }
15605
- // Create new session object
15606
- const create = async () => {
15607
- if (!rpcShared) {
15608
- const rpc = app.createSessionObject(definition);
15609
- rpcShared = rpc;
15610
- rpcRequestSessionModelStore.set(key, rpcShared);
15611
- }
15612
- const newModel = await rpcShared;
15613
- modelStore.set(key, newModel);
15614
- setModel(newModel);
15615
- };
15616
- create();
15617
- }, [app, ...deps]);
15618
- return [model];
15619
- }
15620
-
15621
- const definition = {
15622
- qInfo: {
15623
- qType: 'current-selections'
15624
- },
15625
- qSelectionObjectDef: {
15626
- qStateName: '$'
15627
- },
15628
- alternateStates: []
15629
- };
15630
- function useCurrentSelectionsModel(app) {
15631
- return useSessionModel(definition, app);
15632
- }
15633
-
15634
- const patchAlternateState = (currentSelectionsModel, currentSelectionsLayout, appLayout) => {
15635
- const states = [...(appLayout.qStateNames || [])].map(s => ({
15636
- stateName: s,
15637
- // need this as reference in selection toolbar since qSelectionObject.qStateName is not in the layout
15638
- qSelectionObjectDef: {
15639
- qStateName: s
15640
- }
15641
- }));
15642
- const existingStates = (currentSelectionsLayout && currentSelectionsLayout.alternateStates ? currentSelectionsLayout.alternateStates.map(s => s.stateName) : []).join('::');
15643
- const newStates = (appLayout.qStateNames || []).map(s => s).join('::');
15644
- if (existingStates !== newStates) {
15645
- currentSelectionsModel.applyPatches([{
15646
- qOp: 'replace',
15647
- qPath: '/alternateStates',
15648
- qValue: JSON.stringify(states)
15649
- }], true);
15650
- }
15651
- };
15652
- function useAppSelectionsNavigation(app) {
15653
- const [currentSelectionsModel] = useCurrentSelectionsModel(app);
15654
- const [currentSelectionsLayout] = useLayout$1(currentSelectionsModel);
15655
- const [appLayout] = useAppLayout$1(app);
15656
- const [navigationState, setNavigationState] = reactExports.useState(null);
15657
- reactExports.useEffect(() => {
15658
- if (!appLayout || !currentSelectionsModel || !currentSelectionsLayout) return;
15659
- patchAlternateState(currentSelectionsModel, currentSelectionsLayout, appLayout);
15660
- }, [appLayout, currentSelectionsModel, currentSelectionsLayout]);
15661
- reactExports.useEffect(() => {
15662
- if (!currentSelectionsLayout) return;
15663
- let canGoBack = false;
15664
- let canGoForward = false;
15665
- let canClear = false;
15666
- [currentSelectionsLayout, ...(currentSelectionsLayout.alternateStates || [])].forEach(state => {
15667
- canGoBack = canGoBack || state.qSelectionObject && state.qSelectionObject.qBackCount > 0;
15668
- canGoForward = canGoForward || state.qSelectionObject && state.qSelectionObject.qForwardCount > 0;
15669
- canClear = canClear || (state.qSelectionObject && state.qSelectionObject.qSelections || []).filter(s => s.qLocked !== true).length > 0;
15670
- });
15671
- setNavigationState({
15672
- canGoBack,
15673
- canGoForward,
15674
- canClear
15675
- });
15676
- }, [currentSelectionsLayout]);
15677
- return [navigationState, currentSelectionsModel, currentSelectionsLayout];
15678
- }
15679
-
15680
- const [useAppSelectionsStore, appSelectionsStore] = createKeyStore({});
15681
- const [useAppModalStore, appModalStore] = createKeyStore({});
15682
- const [useObjectSelectionsStore, objectSelectionsStore] = createKeyStore({});
15683
- const [useModalObjectStore, modalObjectStore] = createKeyStore({});
15684
-
15685
- /* eslint no-underscore-dangle: 0 */
15686
- function createAppSelections(_ref) {
15687
- let {
15688
- app,
15689
- currentSelectionsLayout,
15690
- navState
15691
- } = _ref;
15692
- const key = "".concat(app.id);
15693
- const end = async function () {
15694
- let accept = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
15695
- const model = modalObjectStore.get(key);
15696
- if (model) {
15697
- await model.endSelections(accept);
15698
- modalObjectStore.clear(key);
15699
- const objectSelections = objectSelectionsStore.get(model.id);
15700
- objectSelections.emit('deactivated');
15701
- }
15702
- };
15703
- const begin = async function (model, path) {
15704
- let accept = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
15705
- // Quick return if it's already in modal
15706
- if (model === modalObjectStore.get(key)) {
15707
- return;
15708
- }
15709
-
15710
- // If other model is in modal state end it
15711
- end(accept);
15712
-
15713
- // Pending modal
15714
- modalObjectStore.set(key, model);
15715
- const p = Array.isArray(path) ? path : [path];
15716
- const beginSelections = async skipRetry => {
15717
- try {
15718
- await model.beginSelections(p);
15719
- modalObjectStore.set(key, model); // We have a modal
15720
- } catch (err) {
15721
- if (err.code === 6003 && !skipRetry) {
15722
- await app.abortModal(accept);
15723
- beginSelections(true);
15724
- } else {
15725
- modalObjectStore.clear(key); // No modal
15726
- }
15727
- }
15728
- };
15729
-
15730
- await beginSelections();
15731
- };
15732
- const appModal = {
15733
- begin,
15734
- end
15735
- };
15736
- appModalStore.set(key, appModal);
15737
-
15738
- /**
15739
- * @class
15740
- * @alias AppSelections
15741
- */
15742
- const appSelections = {
15743
- model: app,
15744
- isInModal() {
15745
- return !!modalObjectStore.get(key);
15746
- },
15747
- isModal(object) {
15748
- // TODO check model state
15749
- return object ? modalObjectStore.get(key) === object : !!modalObjectStore.get(key);
15750
- },
15751
- canGoForward() {
15752
- return navState.canGoForward;
15753
- },
15754
- canGoBack() {
15755
- return navState.canGoBack;
15756
- },
15757
- canClear() {
15758
- return navState.canClear;
15759
- },
15760
- layout() {
15761
- return currentSelectionsLayout;
15762
- },
15763
- forward() {
15764
- return appModal.end().then(() => app.forward());
15765
- },
15766
- back() {
15767
- return appModal.end().then(() => app.back());
15768
- },
15769
- clear() {
15770
- return appModal.end().then(() => app.clearAll());
15771
- },
15772
- clearField(field) {
15773
- let state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '$';
15774
- return appModal.end().then(() => app.getField(field, state).then(f => f.clear()));
15775
- }
15776
- };
15777
- return appSelections;
15469
+ return appSelections;
15778
15470
  }
15779
15471
  function useAppSelections(app) {
15780
15472
  if (!app.session) {
15781
15473
  // assume the app is mocked if session is undefined
15782
15474
  return [];
15783
15475
  }
15784
- const [navState, currentSelectionsModel, currentSelectionsLayout] = useAppSelectionsNavigation(app);
15785
15476
  const [appSelectionsStore] = useAppSelectionsStore();
15786
15477
  const key = app ? app.id : null;
15787
15478
  let appSelections = appSelectionsStore.get(key);
15788
15479
  reactExports.useEffect(() => {
15789
- if (!app || !currentSelectionsModel || !currentSelectionsLayout || !navState || appSelections) return;
15480
+ if (!app || appSelections) return;
15790
15481
  appSelections = createAppSelections({
15791
- app,
15792
- currentSelectionsLayout,
15793
- navState
15482
+ app
15794
15483
  });
15795
15484
  appSelectionsStore.set(key, appSelections);
15796
15485
  appSelectionsStore.dispatch(true);
15797
- }, [app, currentSelectionsModel, currentSelectionsLayout, navState]);
15798
- return [appSelections, navState];
15486
+ }, [app]);
15487
+ return [appSelections];
15799
15488
  }
15800
15489
 
15801
15490
  const NebulaApp = reactExports.forwardRef((_ref, ref) => {
@@ -15824,7 +15513,7 @@
15824
15513
  }
15825
15514
  },
15826
15515
  setMuiThemeName,
15827
- setContext,
15516
+ setContext: ctx => setContext(oldContext => JSON.stringify(oldContext) !== JSON.stringify(ctx) ? ctx : oldContext),
15828
15517
  getAppSelections: () => appSelections
15829
15518
  }));
15830
15519
  return /*#__PURE__*/React.createElement(StyledEngineProvider, {
@@ -15847,7 +15536,7 @@
15847
15536
  const appRef = React.createRef();
15848
15537
  const element = document.createElement('div');
15849
15538
  element.style.display = 'none';
15850
- element.setAttribute('data-nebulajs-version', "3.3.0-alpha.0" );
15539
+ element.setAttribute('data-nebulajs-version', "3.3.0" );
15851
15540
  element.setAttribute('data-app-id', app.id);
15852
15541
  document.body.appendChild(element);
15853
15542
  ReactDOM.render( /*#__PURE__*/React.createElement(NebulaApp, {
@@ -21175,261 +20864,509 @@
21175
20864
  });
21176
20865
  var Tooltip$1 = Tooltip;
21177
20866
 
21178
- function useRect$1() {
21179
- const [node, setNode] = reactExports.useState();
21180
- const [rect, setRect] = reactExports.useState();
21181
- const callbackRef = reactExports.useCallback(ref => {
21182
- if (!ref) {
21183
- return;
21184
- }
21185
- setNode(ref);
21186
- }, []);
21187
- const handleResize = () => {
21188
- const {
21189
- left,
21190
- top,
21191
- width,
21192
- height
21193
- } = node.getBoundingClientRect();
21194
- setRect({
21195
- left,
21196
- top,
21197
- width,
21198
- height
21199
- });
20867
+ const [useRpcResultStore, rpcResultStore] = createKeyStore({});
20868
+ const [useRpcRequestStore, rpcRequestStore] = createKeyStore({});
20869
+ const [useRpcRequestSessionModelStore, rpcRequestSessionModelStore] = createKeyStore({});
20870
+ const [useRpcRequestModelStore, rpcRequestModelStore] = createKeyStore({});
20871
+ const [useModelChangedStore, modelChangedStore] = createKeyStore({});
20872
+ const [, modelInitializedStore] = createKeyStore({});
20873
+ const modelStoreMiddleware = _ref => {
20874
+ let {
20875
+ type,
20876
+ value: model
20877
+ } = _ref;
20878
+ const initialized = modelInitializedStore.get(model.id);
20879
+ modelInitializedStore.set(model.id, {});
20880
+ const onChanged = () => {
20881
+ rpcRequestStore.clear(model.id);
20882
+ modelChangedStore.set(model.id, {});
20883
+ modelChangedStore.dispatch(true); // Force new state to trigger hooks
21200
20884
  };
21201
- reactExports.useLayoutEffect(() => {
21202
- if (!node) {
21203
- return undefined;
21204
- }
21205
- if (typeof ResizeObserver === 'function') {
21206
- let resizeObserver = new ResizeObserver(handleResize);
21207
- resizeObserver.observe(node);
21208
- return () => {
21209
- resizeObserver.unobserve(node);
21210
- resizeObserver.disconnect(node);
21211
- resizeObserver = null;
21212
- };
21213
- }
21214
- handleResize();
21215
- window.addEventListener('resize', handleResize);
21216
- return () => {
21217
- window.removeEventListener('resize', handleResize);
21218
- };
21219
- }, [node]);
21220
- return [callbackRef, rect, node];
21221
- }
21222
20885
 
21223
- function getFontSize(size) {
21224
- if (size === 'large') {
21225
- return '20px';
21226
- }
21227
- if (size === 'small') {
21228
- return '12px';
20886
+ const unsubscribe = () => {
20887
+ model.removeListener('changed', onChanged);
20888
+ rpcResultStore.clear(model.id);
20889
+ rpcRequestStore.clear(model.id);
20890
+ rpcRequestSessionModelStore.clear(model.id);
20891
+ rpcRequestModelStore.clear(model.id);
20892
+ modelChangedStore.clear(model.id);
20893
+ modelInitializedStore.clear(model.id);
20894
+ };
20895
+ switch (type) {
20896
+ case 'SET':
20897
+ if (!initialized) {
20898
+ model.on('changed', onChanged);
20899
+ model.once('closed', () => {
20900
+ unsubscribe();
20901
+ });
20902
+ }
20903
+ break;
21229
20904
  }
21230
- return '16px';
21231
- }
21232
- function SvgIcon(_ref) {
21233
- let {
21234
- size,
21235
- style = {},
21236
- viewBox = '0 0 16 16',
21237
- shapes = []
21238
- } = _ref;
21239
- const s = _objectSpread2({
21240
- fontSize: getFontSize(size),
21241
- display: 'inline-block',
21242
- fontStyle: 'normal',
21243
- lineHeight: '0',
21244
- textAlign: 'center',
21245
- textTransform: 'none',
21246
- verticalAlign: '-.125em',
21247
- textRendering: 'optimizeLegibility',
21248
- WebkitFontSmoothing: 'antialiased',
21249
- MozOsxFontSmoothing: 'grayscale'
21250
- }, style);
21251
- return /*#__PURE__*/React.createElement("i", {
21252
- style: s
21253
- }, /*#__PURE__*/React.createElement("svg", {
21254
- xmlns: "http://www.w3.org/2000/svg",
21255
- width: "1em",
21256
- height: "1em",
21257
- viewBox: viewBox,
21258
- fill: "currentColor"
21259
- }, shapes.map((_ref2, ix) => {
21260
- let {
21261
- type: Type,
21262
- attrs
21263
- } = _ref2;
21264
- return (
21265
- /*#__PURE__*/
21266
- // eslint-disable-next-line react/no-array-index-key
21267
- React.createElement(Type, _extends$8({
21268
- key: ix
21269
- }, attrs))
21270
- );
21271
- })));
21272
- }
21273
-
21274
- const remove = props => _objectSpread2(_objectSpread2({}, props), {}, {
21275
- shapes: [{
21276
- type: 'path',
21277
- attrs: {
21278
- 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'
21279
- }
21280
- }]
21281
- });
21282
- var Remove = (props => SvgIcon(remove(props)));
21283
-
21284
- const lock = props => _objectSpread2(_objectSpread2({}, props), {}, {
21285
- shapes: [{
21286
- type: 'path',
21287
- attrs: {
21288
- 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'
21289
- }
21290
- }]
21291
- });
21292
- var Lock = (props => SvgIcon(lock(props)));
20905
+ return unsubscribe;
20906
+ };
20907
+ const [useModelStore, modelStore] = createKeyStore({}, modelStoreMiddleware);
20908
+ const subscribe = model => {
20909
+ const unsubscribe = modelStoreMiddleware({
20910
+ type: 'SET',
20911
+ value: model
20912
+ });
20913
+ return () => {
20914
+ unsubscribe();
20915
+ modelStore.clear(model.id);
20916
+ };
20917
+ };
21293
20918
 
21294
- const unlock = props => _objectSpread2(_objectSpread2({}, props), {}, {
21295
- shapes: [{
21296
- type: 'path',
21297
- attrs: {
21298
- 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'
20919
+ function useSessionModel(definition, app) {
20920
+ const key = app ? "".concat(app.id, "/").concat(JSON.stringify(definition)) : null;
20921
+ const [modelStore] = useModelStore();
20922
+ const [rpcRequestSessionModelStore] = useRpcRequestSessionModelStore();
20923
+ const [model, setModel] = reactExports.useState();
20924
+ let rpcShared;
20925
+ if (key) {
20926
+ rpcShared = rpcRequestSessionModelStore.get(key);
20927
+ }
20928
+ for (var _len = arguments.length, deps = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
20929
+ deps[_key - 2] = arguments[_key];
20930
+ }
20931
+ reactExports.useEffect(() => {
20932
+ if (!app) {
20933
+ return;
21299
20934
  }
21300
- }]
21301
- });
21302
- var Unlock = (props => SvgIcon(unlock(props)));
21303
-
21304
- function isRangeVisible(_ref) {
21305
- var lastRenderedStartIndex = _ref.lastRenderedStartIndex,
21306
- lastRenderedStopIndex = _ref.lastRenderedStopIndex,
21307
- startIndex = _ref.startIndex,
21308
- stopIndex = _ref.stopIndex;
21309
-
21310
- return !(startIndex > lastRenderedStopIndex || stopIndex < lastRenderedStartIndex);
20935
+ // Create new session object
20936
+ const create = async () => {
20937
+ if (!rpcShared) {
20938
+ const rpc = app.createSessionObject(definition);
20939
+ rpcShared = rpc;
20940
+ rpcRequestSessionModelStore.set(key, rpcShared);
20941
+ }
20942
+ const newModel = await rpcShared;
20943
+ modelStore.set(key, newModel);
20944
+ setModel(newModel);
20945
+ };
20946
+ create();
20947
+ }, [app, ...deps]);
20948
+ return [model];
21311
20949
  }
21312
20950
 
21313
- function scanForUnloadedRanges(_ref) {
21314
- var isItemLoaded = _ref.isItemLoaded,
21315
- itemCount = _ref.itemCount,
21316
- minimumBatchSize = _ref.minimumBatchSize,
21317
- startIndex = _ref.startIndex,
21318
- stopIndex = _ref.stopIndex;
21319
-
21320
- var unloadedRanges = [];
21321
-
21322
- var rangeStartIndex = null;
21323
- var rangeStopIndex = null;
21324
-
21325
- for (var _index = startIndex; _index <= stopIndex; _index++) {
21326
- var loaded = isItemLoaded(_index);
20951
+ const definition = {
20952
+ qInfo: {
20953
+ qType: 'current-selections'
20954
+ },
20955
+ qSelectionObjectDef: {
20956
+ qStateName: '$'
20957
+ },
20958
+ alternateStates: []
20959
+ };
20960
+ function useCurrentSelectionsModel(app) {
20961
+ return useSessionModel(definition, app);
20962
+ }
21327
20963
 
21328
- if (!loaded) {
21329
- rangeStopIndex = _index;
21330
- if (rangeStartIndex === null) {
21331
- rangeStartIndex = _index;
20964
+ const rpcReducer = (state, action) => {
20965
+ const {
20966
+ rpcResultStore,
20967
+ key,
20968
+ method
20969
+ } = action;
20970
+ let newState;
20971
+ switch (action.type) {
20972
+ case 'INVALID':
20973
+ {
20974
+ newState = _objectSpread2(_objectSpread2({}, state), {}, {
20975
+ valid: false,
20976
+ invalid: true,
20977
+ validating: true,
20978
+ canCancel: true,
20979
+ canRetry: false,
20980
+ rpcRetry: false
20981
+ });
20982
+ break;
21332
20983
  }
21333
- } else if (rangeStopIndex !== null) {
21334
- unloadedRanges.push(rangeStartIndex, rangeStopIndex);
21335
-
21336
- rangeStartIndex = rangeStopIndex = null;
21337
- }
21338
- }
21339
-
21340
- // If :rangeStopIndex is not null it means we haven't ran out of unloaded rows.
21341
- // Scan forward to try filling our :minimumBatchSize.
21342
- if (rangeStopIndex !== null) {
21343
- var potentialStopIndex = Math.min(Math.max(rangeStopIndex, rangeStartIndex + minimumBatchSize - 1), itemCount - 1);
21344
-
21345
- for (var _index2 = rangeStopIndex + 1; _index2 <= potentialStopIndex; _index2++) {
21346
- if (!isItemLoaded(_index2)) {
21347
- rangeStopIndex = _index2;
21348
- } else {
20984
+ case 'VALID':
20985
+ {
20986
+ newState = {
20987
+ result: _objectSpread2({}, action.result),
20988
+ invalid: false,
20989
+ valid: true,
20990
+ validating: false,
20991
+ canCancel: false,
20992
+ canRetry: false,
20993
+ rpcRetry: false
20994
+ };
21349
20995
  break;
21350
20996
  }
21351
- }
21352
-
21353
- unloadedRanges.push(rangeStartIndex, rangeStopIndex);
21354
- }
21355
-
21356
- // Check to see if our first range ended prematurely.
21357
- // In this case we should scan backwards to try filling our :minimumBatchSize.
21358
- if (unloadedRanges.length) {
21359
- while (unloadedRanges[1] - unloadedRanges[0] + 1 < minimumBatchSize && unloadedRanges[0] > 0) {
21360
- var _index3 = unloadedRanges[0] - 1;
21361
-
21362
- if (!isItemLoaded(_index3)) {
21363
- unloadedRanges[0] = _index3;
21364
- } else {
20997
+ case 'CANCELLED':
20998
+ {
20999
+ newState = _objectSpread2(_objectSpread2({}, state), {}, {
21000
+ invalid: true,
21001
+ valid: false,
21002
+ validating: false,
21003
+ canCancel: false,
21004
+ canRetry: true,
21005
+ rpcRetry: false
21006
+ });
21365
21007
  break;
21366
21008
  }
21367
- }
21009
+ default:
21010
+ throw new Error('Undefined action');
21368
21011
  }
21369
-
21370
- return unloadedRanges;
21371
- }
21372
-
21373
- var classCallCheck$1 = function (instance, Constructor) {
21374
- if (!(instance instanceof Constructor)) {
21375
- throw new TypeError("Cannot call a class as a function");
21012
+ let sharedState = rpcResultStore.get(key);
21013
+ if (!sharedState) {
21014
+ sharedState = {};
21376
21015
  }
21016
+ sharedState[method] = newState;
21017
+ rpcResultStore.set(key, sharedState);
21018
+ return newState;
21377
21019
  };
21378
-
21379
- var createClass$1 = function () {
21380
- function defineProperties(target, props) {
21381
- for (var i = 0; i < props.length; i++) {
21382
- var descriptor = props[i];
21383
- descriptor.enumerable = descriptor.enumerable || false;
21384
- descriptor.configurable = true;
21385
- if ("value" in descriptor) descriptor.writable = true;
21386
- Object.defineProperty(target, descriptor.key, descriptor);
21020
+ function useRpc(model, method) {
21021
+ const key = model ? "".concat(model.id) : null;
21022
+ const [rpcResultStore] = useRpcResultStore();
21023
+ const [state, dispatch] = reactExports.useReducer(rpcReducer, key ? rpcResultStore.get(key) : null);
21024
+ const [modelChangedStore] = useModelChangedStore();
21025
+ const [rpcRequestStore] = useRpcRequestStore();
21026
+ let rpcShared;
21027
+ if (key) {
21028
+ rpcShared = rpcRequestStore.get(key);
21029
+ if (!rpcShared) {
21030
+ rpcShared = {};
21031
+ rpcRequestStore.set(key, rpcShared);
21387
21032
  }
21388
21033
  }
21389
-
21390
- return function (Constructor, protoProps, staticProps) {
21391
- if (protoProps) defineProperties(Constructor.prototype, protoProps);
21392
- if (staticProps) defineProperties(Constructor, staticProps);
21393
- return Constructor;
21034
+ const call = async skipRetry => {
21035
+ let cache = rpcShared[method];
21036
+ if (!cache || cache && cache.rpcRetry) {
21037
+ const rpc = model[method]();
21038
+ cache = {
21039
+ rpc,
21040
+ rpcRetry: false
21041
+ };
21042
+ rpcShared[method] = cache;
21043
+ dispatch({
21044
+ type: 'INVALID',
21045
+ method,
21046
+ key,
21047
+ model,
21048
+ rpcResultStore,
21049
+ canCancel: true
21050
+ });
21051
+ }
21052
+ try {
21053
+ // await sleep(5000);
21054
+ const result = await cache.rpc;
21055
+ dispatch({
21056
+ type: 'VALID',
21057
+ result,
21058
+ key,
21059
+ method,
21060
+ model,
21061
+ rpcResultStore
21062
+ });
21063
+ } catch (err) {
21064
+ if (err.code === 15 && !skipRetry) {
21065
+ // Request aborted. This will be called multiple times by hooks only retry once
21066
+ if (!cache.rpcRetry) {
21067
+ cache.rpcRetry = true;
21068
+ }
21069
+ call(true);
21070
+ }
21071
+ }
21394
21072
  };
21395
- }();
21073
+ const longrunning = {
21074
+ cancel: async () => {
21075
+ const global = model.session.getObjectApi({
21076
+ handle: -1
21077
+ });
21078
+ await global.cancelRequest(rpcShared[method].rpc.requestId);
21079
+ dispatch({
21080
+ type: 'CANCELLED',
21081
+ key,
21082
+ method,
21083
+ model,
21084
+ rpcResultStore
21085
+ });
21086
+ },
21087
+ retry: () => {
21088
+ rpcShared[method].rpcRetry = true;
21089
+ call();
21090
+ }
21091
+ };
21092
+ reactExports.useEffect(() => {
21093
+ if (!model) return undefined;
21094
+ call();
21095
+ return undefined;
21096
+ }, [model, modelChangedStore.get(model && model.id), key, method]);
21097
+ return [
21098
+ // Result
21099
+ state && state.result, {
21100
+ validating: state && state.validating,
21101
+ canCancel: state && state.canCancel,
21102
+ canRetry: state && state.canRetry
21103
+ },
21104
+ // Long running api e.g cancel retry
21105
+ longrunning];
21106
+ }
21396
21107
 
21397
- var inherits$1 = function (subClass, superClass) {
21398
- if (typeof superClass !== "function" && superClass !== null) {
21399
- throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
21400
- }
21108
+ function useLayout$1(model) {
21109
+ return useRpc(model, 'getLayout');
21110
+ }
21111
+ function useAppLayout$1(model) {
21112
+ return useRpc(model, 'getAppLayout');
21113
+ }
21401
21114
 
21402
- subClass.prototype = Object.create(superClass && superClass.prototype, {
21403
- constructor: {
21404
- value: subClass,
21405
- enumerable: false,
21406
- writable: true,
21407
- configurable: true
21115
+ function useRect$1() {
21116
+ const [node, setNode] = reactExports.useState();
21117
+ const [rect, setRect] = reactExports.useState();
21118
+ const callbackRef = reactExports.useCallback(ref => {
21119
+ if (!ref) {
21120
+ return;
21408
21121
  }
21409
- });
21410
- if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
21411
- };
21122
+ setNode(ref);
21123
+ }, []);
21124
+ const handleResize = () => {
21125
+ const {
21126
+ left,
21127
+ top,
21128
+ width,
21129
+ height
21130
+ } = node.getBoundingClientRect();
21131
+ setRect({
21132
+ left,
21133
+ top,
21134
+ width,
21135
+ height
21136
+ });
21137
+ };
21138
+ reactExports.useLayoutEffect(() => {
21139
+ if (!node) {
21140
+ return undefined;
21141
+ }
21142
+ if (typeof ResizeObserver === 'function') {
21143
+ let resizeObserver = new ResizeObserver(handleResize);
21144
+ resizeObserver.observe(node);
21145
+ return () => {
21146
+ resizeObserver.unobserve(node);
21147
+ resizeObserver.disconnect(node);
21148
+ resizeObserver = null;
21149
+ };
21150
+ }
21151
+ handleResize();
21152
+ window.addEventListener('resize', handleResize);
21153
+ return () => {
21154
+ window.removeEventListener('resize', handleResize);
21155
+ };
21156
+ }, [node]);
21157
+ return [callbackRef, rect, node];
21158
+ }
21412
21159
 
21413
- var possibleConstructorReturn$1 = function (self, call) {
21414
- if (!self) {
21415
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
21160
+ function getFontSize(size) {
21161
+ if (size === 'large') {
21162
+ return '20px';
21163
+ }
21164
+ if (size === 'small') {
21165
+ return '12px';
21416
21166
  }
21167
+ return '16px';
21168
+ }
21169
+ function SvgIcon(_ref) {
21170
+ let {
21171
+ size,
21172
+ style = {},
21173
+ viewBox = '0 0 16 16',
21174
+ shapes = []
21175
+ } = _ref;
21176
+ const s = _objectSpread2({
21177
+ fontSize: getFontSize(size),
21178
+ display: 'inline-block',
21179
+ fontStyle: 'normal',
21180
+ lineHeight: '0',
21181
+ textAlign: 'center',
21182
+ textTransform: 'none',
21183
+ verticalAlign: '-.125em',
21184
+ textRendering: 'optimizeLegibility',
21185
+ WebkitFontSmoothing: 'antialiased',
21186
+ MozOsxFontSmoothing: 'grayscale'
21187
+ }, style);
21188
+ return /*#__PURE__*/React.createElement("i", {
21189
+ style: s
21190
+ }, /*#__PURE__*/React.createElement("svg", {
21191
+ xmlns: "http://www.w3.org/2000/svg",
21192
+ width: "1em",
21193
+ height: "1em",
21194
+ viewBox: viewBox,
21195
+ fill: "currentColor"
21196
+ }, shapes.map((_ref2, ix) => {
21197
+ let {
21198
+ type: Type,
21199
+ attrs
21200
+ } = _ref2;
21201
+ return (
21202
+ /*#__PURE__*/
21203
+ // eslint-disable-next-line react/no-array-index-key
21204
+ React.createElement(Type, _extends$8({
21205
+ key: ix
21206
+ }, attrs))
21207
+ );
21208
+ })));
21209
+ }
21417
21210
 
21418
- return call && (typeof call === "object" || typeof call === "function") ? call : self;
21419
- };
21211
+ const remove = props => _objectSpread2(_objectSpread2({}, props), {}, {
21212
+ shapes: [{
21213
+ type: 'path',
21214
+ attrs: {
21215
+ 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'
21216
+ }
21217
+ }]
21218
+ });
21219
+ var Remove = (props => SvgIcon(remove(props)));
21420
21220
 
21421
- var InfiniteLoader = function (_PureComponent) {
21422
- inherits$1(InfiniteLoader, _PureComponent);
21221
+ const lock = props => _objectSpread2(_objectSpread2({}, props), {}, {
21222
+ shapes: [{
21223
+ type: 'path',
21224
+ attrs: {
21225
+ 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'
21226
+ }
21227
+ }]
21228
+ });
21229
+ var Lock = (props => SvgIcon(lock(props)));
21423
21230
 
21424
- function InfiniteLoader() {
21425
- var _ref;
21231
+ const unlock = props => _objectSpread2(_objectSpread2({}, props), {}, {
21232
+ shapes: [{
21233
+ type: 'path',
21234
+ attrs: {
21235
+ 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'
21236
+ }
21237
+ }]
21238
+ });
21239
+ var Unlock = (props => SvgIcon(unlock(props)));
21426
21240
 
21427
- var _temp, _this, _ret;
21241
+ function isRangeVisible(_ref) {
21242
+ var lastRenderedStartIndex = _ref.lastRenderedStartIndex,
21243
+ lastRenderedStopIndex = _ref.lastRenderedStopIndex,
21244
+ startIndex = _ref.startIndex,
21245
+ stopIndex = _ref.stopIndex;
21428
21246
 
21429
- classCallCheck$1(this, InfiniteLoader);
21247
+ return !(startIndex > lastRenderedStopIndex || stopIndex < lastRenderedStartIndex);
21248
+ }
21430
21249
 
21431
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
21432
- args[_key] = arguments[_key];
21250
+ function scanForUnloadedRanges(_ref) {
21251
+ var isItemLoaded = _ref.isItemLoaded,
21252
+ itemCount = _ref.itemCount,
21253
+ minimumBatchSize = _ref.minimumBatchSize,
21254
+ startIndex = _ref.startIndex,
21255
+ stopIndex = _ref.stopIndex;
21256
+
21257
+ var unloadedRanges = [];
21258
+
21259
+ var rangeStartIndex = null;
21260
+ var rangeStopIndex = null;
21261
+
21262
+ for (var _index = startIndex; _index <= stopIndex; _index++) {
21263
+ var loaded = isItemLoaded(_index);
21264
+
21265
+ if (!loaded) {
21266
+ rangeStopIndex = _index;
21267
+ if (rangeStartIndex === null) {
21268
+ rangeStartIndex = _index;
21269
+ }
21270
+ } else if (rangeStopIndex !== null) {
21271
+ unloadedRanges.push(rangeStartIndex, rangeStopIndex);
21272
+
21273
+ rangeStartIndex = rangeStopIndex = null;
21274
+ }
21275
+ }
21276
+
21277
+ // If :rangeStopIndex is not null it means we haven't ran out of unloaded rows.
21278
+ // Scan forward to try filling our :minimumBatchSize.
21279
+ if (rangeStopIndex !== null) {
21280
+ var potentialStopIndex = Math.min(Math.max(rangeStopIndex, rangeStartIndex + minimumBatchSize - 1), itemCount - 1);
21281
+
21282
+ for (var _index2 = rangeStopIndex + 1; _index2 <= potentialStopIndex; _index2++) {
21283
+ if (!isItemLoaded(_index2)) {
21284
+ rangeStopIndex = _index2;
21285
+ } else {
21286
+ break;
21287
+ }
21288
+ }
21289
+
21290
+ unloadedRanges.push(rangeStartIndex, rangeStopIndex);
21291
+ }
21292
+
21293
+ // Check to see if our first range ended prematurely.
21294
+ // In this case we should scan backwards to try filling our :minimumBatchSize.
21295
+ if (unloadedRanges.length) {
21296
+ while (unloadedRanges[1] - unloadedRanges[0] + 1 < minimumBatchSize && unloadedRanges[0] > 0) {
21297
+ var _index3 = unloadedRanges[0] - 1;
21298
+
21299
+ if (!isItemLoaded(_index3)) {
21300
+ unloadedRanges[0] = _index3;
21301
+ } else {
21302
+ break;
21303
+ }
21304
+ }
21305
+ }
21306
+
21307
+ return unloadedRanges;
21308
+ }
21309
+
21310
+ var classCallCheck$1 = function (instance, Constructor) {
21311
+ if (!(instance instanceof Constructor)) {
21312
+ throw new TypeError("Cannot call a class as a function");
21313
+ }
21314
+ };
21315
+
21316
+ var createClass$1 = function () {
21317
+ function defineProperties(target, props) {
21318
+ for (var i = 0; i < props.length; i++) {
21319
+ var descriptor = props[i];
21320
+ descriptor.enumerable = descriptor.enumerable || false;
21321
+ descriptor.configurable = true;
21322
+ if ("value" in descriptor) descriptor.writable = true;
21323
+ Object.defineProperty(target, descriptor.key, descriptor);
21324
+ }
21325
+ }
21326
+
21327
+ return function (Constructor, protoProps, staticProps) {
21328
+ if (protoProps) defineProperties(Constructor.prototype, protoProps);
21329
+ if (staticProps) defineProperties(Constructor, staticProps);
21330
+ return Constructor;
21331
+ };
21332
+ }();
21333
+
21334
+ var inherits$1 = function (subClass, superClass) {
21335
+ if (typeof superClass !== "function" && superClass !== null) {
21336
+ throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
21337
+ }
21338
+
21339
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
21340
+ constructor: {
21341
+ value: subClass,
21342
+ enumerable: false,
21343
+ writable: true,
21344
+ configurable: true
21345
+ }
21346
+ });
21347
+ if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
21348
+ };
21349
+
21350
+ var possibleConstructorReturn$1 = function (self, call) {
21351
+ if (!self) {
21352
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
21353
+ }
21354
+
21355
+ return call && (typeof call === "object" || typeof call === "function") ? call : self;
21356
+ };
21357
+
21358
+ var InfiniteLoader = function (_PureComponent) {
21359
+ inherits$1(InfiniteLoader, _PureComponent);
21360
+
21361
+ function InfiniteLoader() {
21362
+ var _ref;
21363
+
21364
+ var _temp, _this, _ret;
21365
+
21366
+ classCallCheck$1(this, InfiniteLoader);
21367
+
21368
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
21369
+ args[_key] = arguments[_key];
21433
21370
  }
21434
21371
 
21435
21372
  return _ret = (_temp = (_this = possibleConstructorReturn$1(this, (_ref = InfiniteLoader.__proto__ || Object.getPrototypeOf(InfiniteLoader)).call.apply(_ref, [this].concat(args))), _this), _this._lastRenderedStartIndex = -1, _this._lastRenderedStopIndex = -1, _this._memoizedUnloadedRanges = [], _this._onItemsRendered = function (_ref2) {
@@ -21813,57 +21750,590 @@
21813
21750
  if (selectingValues || !pages || !checkboxes && !mouseDown) {
21814
21751
  return;
21815
21752
  }
21816
- // Render pre-selections before they have been selected in Engine.
21817
- const newPages = applySelectionsOnPages(pages, preSelected, isSingleSelect);
21818
- setInstantPages(newPages);
21819
- }, [preSelected]);
21820
- const interactionEvents = {};
21821
- if (checkboxes) {
21822
- Object.assign(interactionEvents, {
21823
- onClick
21824
- });
21825
- } else {
21826
- Object.assign(interactionEvents, {
21827
- onMouseUp,
21828
- onMouseDown,
21829
- onMouseEnter
21830
- });
21831
- }
21832
- return {
21833
- instantPages,
21834
- interactionEvents,
21835
- select: selectManually // preselect and select without having to trigger an event
21753
+ // Render pre-selections before they have been selected in Engine.
21754
+ const newPages = applySelectionsOnPages(pages, preSelected, isSingleSelect);
21755
+ setInstantPages(newPages);
21756
+ }, [preSelected]);
21757
+ const interactionEvents = {};
21758
+ if (checkboxes) {
21759
+ Object.assign(interactionEvents, {
21760
+ onClick
21761
+ });
21762
+ } else {
21763
+ Object.assign(interactionEvents, {
21764
+ onMouseUp,
21765
+ onMouseDown,
21766
+ onMouseEnter
21767
+ });
21768
+ }
21769
+ return {
21770
+ instantPages,
21771
+ interactionEvents,
21772
+ select: selectManually // preselect and select without having to trigger an event
21773
+ };
21774
+ }
21775
+
21776
+ const tick = props => _objectSpread2(_objectSpread2({}, props), {}, {
21777
+ shapes: [{
21778
+ type: 'path',
21779
+ attrs: {
21780
+ d: 'M6,10 L13,3 L15,5 L8,12 L6,14 L1,9 L3,7 L6,10 Z'
21781
+ }
21782
+ }]
21783
+ });
21784
+ var Tick = (props => SvgIcon(tick(props)));
21785
+
21786
+ /**
21787
+ * @ignore
21788
+ * @interface Range
21789
+ * @property {number} qCharPos The (absolute) index where the highlighted range starts.
21790
+ * @property {number} qCharCount The length of the sub-string (starting from qChartPos) that should be highlighted.
21791
+ */
21792
+
21793
+ /**
21794
+ * @ignore
21795
+ * @interface Segment
21796
+ * @property {string} segment The sub-string/segment cut out from the original label.
21797
+ * @property {boolean} highlighted A flag which tells whether the segment should be highlighted or not.
21798
+ */
21799
+
21800
+ /**
21801
+ * @ignore
21802
+ * @param {string} label The label we want to create segments out of.
21803
+ * @param {Range} range The indexes which define how to create the segments.
21804
+ * @param {number=} [startIndex] An optional index which tells where we want to start the first segment from
21805
+ * (only relevant for creating the first unhighlighted segment of a string/sub-string).
21806
+ * @returns {Segment[]} An array of segments.
21807
+ */
21808
+ function getSegmentsFromRange(label, range) {
21809
+ let startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
21810
+ const {
21811
+ qCharPos,
21812
+ qCharCount
21813
+ } = range;
21814
+ const segments = [];
21815
+ if (qCharPos > startIndex) {
21816
+ // Create a non-highlighted section before the highighted section.
21817
+ segments.push([label.slice(startIndex, qCharPos), false]);
21818
+ }
21819
+
21820
+ // Highlighted segment.
21821
+ segments.push([label.slice(qCharPos, qCharPos + qCharCount), true]);
21822
+ return segments;
21823
+ }
21824
+
21825
+ /**
21826
+ * @ignore
21827
+ * @param {string} label The label we want to create segments out of.
21828
+ * @param {Range[]} ranges The ranges defining indices for cutting the string into segments.
21829
+ * @returns {Segment[]} An array of segments, covering the entire string label.
21830
+ */
21831
+ function getSegmentsFromRanges(label, ranges) {
21832
+ if (!ranges.length) {
21833
+ return [];
21834
+ }
21835
+ const labels = ranges.reduce((acc, curr, ix) => {
21836
+ const startIndex = ix === 0 ? 0 : ranges[ix - 1].qCharPos + ranges[ix - 1].qCharCount;
21837
+ acc.push(...getSegmentsFromRange(label, curr, startIndex));
21838
+
21839
+ // Last non highlighted segment
21840
+ const isLastRange = ix === ranges.length - 1;
21841
+ const endIndex = ranges[ix].qCharPos + ranges[ix].qCharCount;
21842
+ if (isLastRange && endIndex < label.length) {
21843
+ acc.push([label.slice(endIndex), false]);
21844
+ }
21845
+ return acc;
21846
+ }, []);
21847
+ return labels;
21848
+ }
21849
+
21850
+ const KEYS = Object.freeze({
21851
+ ENTER: 13,
21852
+ ESCAPE: 27,
21853
+ SPACE: 32,
21854
+ TAB: 9,
21855
+ BACKSPACE: 8,
21856
+ DELETE: 46,
21857
+ ALT: 18,
21858
+ CTRL: 17,
21859
+ SHIFT: 16,
21860
+ ARROW_UP: 38,
21861
+ ARROW_DOWN: 40,
21862
+ ARROW_LEFT: 37,
21863
+ ARROW_RIGHT: 39,
21864
+ PAGE_DOWN: 34,
21865
+ PAGE_UP: 33,
21866
+ HOME: 36,
21867
+ END: 35,
21868
+ F10: 121,
21869
+ A: 65,
21870
+ F: 70,
21871
+ ZERO: 48,
21872
+ NINE: 57,
21873
+ NUMPAD_ZERO: 96,
21874
+ NUMPAD_NINE: 105,
21875
+ SUBTRACTION: 189,
21876
+ DECIMAL: 190,
21877
+ NUMPAD_DECIMAL: 110,
21878
+ isArrow: key => key === KEYS.ARROW_UP || key === KEYS.ARROW_DOWN || key === KEYS.ARROW_LEFT || key === KEYS.ARROW_RIGHT
21879
+ });
21880
+
21881
+ function getFieldKeyboardNavigation(_ref) {
21882
+ let {
21883
+ select,
21884
+ confirm,
21885
+ cancel,
21886
+ setScrollPosition,
21887
+ focusListItems
21888
+ } = _ref;
21889
+ const getElement = function (elm) {
21890
+ let next = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
21891
+ const parentElm = elm && elm.parentElement[next ? 'nextElementSibling' : 'previousElementSibling'];
21892
+ return parentElm && parentElm.querySelector('[role]');
21893
+ };
21894
+ let startedRange = false;
21895
+ const setStartedRange = val => {
21896
+ startedRange = val;
21897
+ };
21898
+ const handleKeyDown = event => {
21899
+ let elementToFocus;
21900
+ const {
21901
+ keyCode,
21902
+ shiftKey = false,
21903
+ ctrlKey = false
21904
+ } = event.nativeEvent;
21905
+ switch (keyCode) {
21906
+ case KEYS.SHIFT:
21907
+ // This is to ensure we include the first value when starting a range selection.
21908
+ setStartedRange(true);
21909
+ break;
21910
+ case KEYS.SPACE:
21911
+ select([+event.currentTarget.getAttribute('data-n')]);
21912
+ break;
21913
+ case KEYS.ARROW_DOWN:
21914
+ case KEYS.ARROW_RIGHT:
21915
+ elementToFocus = getElement(event.currentTarget, true);
21916
+ if (shiftKey && elementToFocus) {
21917
+ if (startedRange) {
21918
+ select([+event.currentTarget.getAttribute('data-n')], true);
21919
+ setStartedRange(false);
21920
+ }
21921
+ select([+elementToFocus.getAttribute('data-n')], true);
21922
+ }
21923
+ break;
21924
+ case KEYS.ARROW_UP:
21925
+ case KEYS.ARROW_LEFT:
21926
+ elementToFocus = getElement(event.currentTarget, false);
21927
+ if (shiftKey && elementToFocus) {
21928
+ if (startedRange) {
21929
+ select([+event.currentTarget.getAttribute('data-n')], true);
21930
+ setStartedRange(false);
21931
+ }
21932
+ select([+elementToFocus.getAttribute('data-n')], true);
21933
+ }
21934
+ break;
21935
+ case KEYS.ENTER:
21936
+ confirm();
21937
+ break;
21938
+ case KEYS.ESCAPE:
21939
+ cancel();
21940
+ return;
21941
+ // let it propagate to top-level
21942
+ case KEYS.HOME:
21943
+ focusListItems.setFirst(true);
21944
+ if (ctrlKey) {
21945
+ setScrollPosition === null || setScrollPosition === void 0 ? void 0 : setScrollPosition('overflowStart');
21946
+ break;
21947
+ }
21948
+ setScrollPosition === null || setScrollPosition === void 0 ? void 0 : setScrollPosition('start');
21949
+ break;
21950
+ case KEYS.END:
21951
+ focusListItems.setLast(true);
21952
+ if (ctrlKey) {
21953
+ setScrollPosition === null || setScrollPosition === void 0 ? void 0 : setScrollPosition('overflowEnd');
21954
+ break;
21955
+ }
21956
+ setScrollPosition === null || setScrollPosition === void 0 ? void 0 : setScrollPosition('end');
21957
+ break;
21958
+ default:
21959
+ return;
21960
+ // don't stop propagation since we want to outsource keydown to other handlers.
21961
+ }
21962
+
21963
+ if (elementToFocus) {
21964
+ elementToFocus.focus();
21965
+ }
21966
+ event.preventDefault();
21967
+ event.stopPropagation();
21968
+ };
21969
+ return handleKeyDown;
21970
+ }
21971
+ function getListboxInlineKeyboardNavigation(_ref2) {
21972
+ let {
21973
+ setKeyboardActive,
21974
+ hovering,
21975
+ setHovering,
21976
+ updateKeyScroll,
21977
+ containerRef,
21978
+ currentScrollIndex,
21979
+ app,
21980
+ appSelections,
21981
+ constraints
21982
+ } = _ref2;
21983
+ const focusInsideListbox = element => {
21984
+ const fieldElement = element.querySelector('.search input, .value.selector, .value, .ActionsToolbar-* button');
21985
+ setKeyboardActive(true);
21986
+ if (fieldElement) {
21987
+ fieldElement.focus();
21988
+ }
21989
+ };
21990
+ const focusContainer = element => {
21991
+ setKeyboardActive(false);
21992
+ element.focus();
21993
+ };
21994
+ const updateKeyScrollOnHover = newState => {
21995
+ if (hovering) {
21996
+ updateKeyScroll(newState);
21997
+ }
21998
+ };
21999
+ const handleKeyDown = event => {
22000
+ const {
22001
+ keyCode,
22002
+ ctrlKey = false,
22003
+ shiftKey = false
22004
+ } = event.nativeEvent;
22005
+ switch (keyCode) {
22006
+ // case KEYS.TAB: TODO: Focus confirm button using keyboard.focusSelection when we can access the useKeyboard hook.
22007
+ case KEYS.ENTER:
22008
+ case KEYS.SPACE:
22009
+ if (!event.target.classList.contains('listbox-container')) {
22010
+ return; // don't mess with keydown handlers within the listbox
22011
+ }
22012
+
22013
+ focusInsideListbox(event.currentTarget);
22014
+ break;
22015
+ case KEYS.ESCAPE:
22016
+ focusContainer(event.currentTarget);
22017
+ break;
22018
+ case KEYS.ARROW_UP:
22019
+ updateKeyScrollOnHover({
22020
+ up: 1
22021
+ });
22022
+ break;
22023
+ case KEYS.ARROW_DOWN:
22024
+ updateKeyScrollOnHover({
22025
+ down: 1
22026
+ });
22027
+ break;
22028
+ case KEYS.PAGE_UP:
22029
+ updateKeyScrollOnHover({
22030
+ up: currentScrollIndex.stop - currentScrollIndex.start
22031
+ });
22032
+ break;
22033
+ case KEYS.PAGE_DOWN:
22034
+ updateKeyScrollOnHover({
22035
+ down: currentScrollIndex.stop - currentScrollIndex.start
22036
+ });
22037
+ break;
22038
+ case KEYS.HOME:
22039
+ updateKeyScrollOnHover({
22040
+ scrollPosition: ctrlKey && shiftKey ? 'overflowStart' : 'start'
22041
+ });
22042
+ break;
22043
+ case KEYS.END:
22044
+ updateKeyScrollOnHover({
22045
+ scrollPosition: ctrlKey && shiftKey ? 'overflowEnd' : 'end'
22046
+ });
22047
+ break;
22048
+ default:
22049
+ return;
22050
+ }
22051
+
22052
+ // Note: We should not stop propagation here as it will block the containing app
22053
+ // from handling keydown events.
22054
+ event.preventDefault();
22055
+ };
22056
+ const focusOnHoverDisabled = () => {
22057
+ var _app$isInModalSelecti, _app$isInModalSelecti2;
22058
+ const selectNotAllowed = (constraints === null || constraints === void 0 ? void 0 : constraints.select) || (constraints === null || constraints === void 0 ? void 0 : constraints.active);
22059
+ 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();
22060
+ return selectNotAllowed || appInModal;
22061
+ };
22062
+ const handleOnMouseEnter = () => {
22063
+ if (!focusOnHoverDisabled()) {
22064
+ var _containerRef$current, _containerRef$current2;
22065
+ setHovering(true);
22066
+ 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);
22067
+ }
22068
+ };
22069
+ const handleOnMouseLeave = () => {
22070
+ if (hovering) {
22071
+ var _containerRef$current3, _containerRef$current4;
22072
+ setHovering(false);
22073
+ 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);
22074
+ }
22075
+ };
22076
+ return {
22077
+ handleKeyDown,
22078
+ handleOnMouseEnter,
22079
+ handleOnMouseLeave
22080
+ };
22081
+ }
22082
+
22083
+ const PREFIX$c = 'RowColumn';
22084
+ const rowColClasses = {
22085
+ row: "".concat(PREFIX$c, "-row"),
22086
+ rowBorderBottom: "".concat(PREFIX$c, "-rowBorderBottom"),
22087
+ column: "".concat(PREFIX$c, "-column"),
22088
+ fieldRoot: "".concat(PREFIX$c, "-fieldRoot"),
22089
+ cell: "".concat(PREFIX$c, "-cell"),
22090
+ labelText: "".concat(PREFIX$c, "-labelText"),
22091
+ labelDense: "".concat(PREFIX$c, "-labelDense"),
22092
+ highlighted: "".concat(PREFIX$c, "-highlighted"),
22093
+ checkboxLabel: "".concat(PREFIX$c, "-checkboxLabel"),
22094
+ icon: "".concat(PREFIX$c, "-icon"),
22095
+ S: "".concat(PREFIX$c, "-S"),
22096
+ XS: "".concat(PREFIX$c, "-XS"),
22097
+ A: "".concat(PREFIX$c, "-A"),
22098
+ X: "".concat(PREFIX$c, "-X"),
22099
+ frequencyCount: "".concat(PREFIX$c, "-frequencyCount"),
22100
+ barContainer: "".concat(PREFIX$c, "-barContainer"),
22101
+ bar: "".concat(PREFIX$c, "-bar"),
22102
+ barSelected: "".concat(PREFIX$c, "-barSelected"),
22103
+ barWithCheckbox: "".concat(PREFIX$c, "-barWithCheckbox"),
22104
+ barSelectedWithCheckbox: "".concat(PREFIX$c, "-barSelectedWithCheckbox"),
22105
+ excludedTextWithCheckbox: "".concat(PREFIX$c, "-excludedTextWithCheckbox")
22106
+ };
22107
+
22108
+ const isExcluded = c => c ? c.qState === 'X' || c.qState === 'XS' || c.qState === 'XL' : null;
22109
+ const isAlternative = c => c ? c.qState === 'A' : null;
22110
+ const excludedOrAlternative = _ref => {
22111
+ let {
22112
+ cell,
22113
+ checkboxes
22114
+ } = _ref;
22115
+ return (isAlternative(cell) || isExcluded(cell)) && checkboxes;
22116
+ };
22117
+
22118
+ const frequencyTextNone = '-';
22119
+ const barPadPx = 4;
22120
+ const barBorderWidthPx = 1;
22121
+ const barWithCheckboxLeftPadPx = 29;
22122
+
22123
+ const joinClassNames = namesArray => namesArray.filter(c => !!c).join(' ').trim();
22124
+ const getBarWidth = _ref => {
22125
+ let {
22126
+ qFrequency,
22127
+ checkboxes,
22128
+ frequencyMax
22129
+ } = _ref;
22130
+ const freqStr = String(qFrequency);
22131
+ const isPercent = freqStr.substring(freqStr.length - 1) === '%';
22132
+ const freq = parseFloat(isPercent ? freqStr : qFrequency);
22133
+ const rightSlice = checkboxes ? "(".concat(barWithCheckboxLeftPadPx, "px + ").concat(barPadPx + barBorderWidthPx * 2, "px)") : "".concat(barPadPx * 2 + barBorderWidthPx * 2, "px");
22134
+ const width = isPercent ? freq : freq / frequencyMax * 100;
22135
+ return "calc(".concat(width, "% - ").concat(rightSlice, ")");
22136
+ };
22137
+ const getFrequencyText = _ref2 => {
22138
+ let {
22139
+ cell
22140
+ } = _ref2;
22141
+ if (cell) {
22142
+ return cell.qFrequency ? cell.qFrequency : frequencyTextNone;
22143
+ }
22144
+ return '';
22145
+ };
22146
+
22147
+ const getSelectedStyle = _ref => {
22148
+ let {
22149
+ theme
22150
+ } = _ref;
22151
+ return {
22152
+ background: theme.palette.selected.main,
22153
+ color: theme.palette.selected.mainContrastText,
22154
+ '&:focus': {
22155
+ boxShadow: "inset 0 0 0 2px ".concat(theme.palette.custom.focusBorder),
22156
+ outline: 'none'
22157
+ },
22158
+ '& $cell': {
22159
+ paddingRight: 0
22160
+ }
22161
+ };
22162
+ };
22163
+ const ellipsis = {
22164
+ width: '100%',
22165
+ overflow: 'hidden',
22166
+ textOverflow: 'ellipsis'
22167
+ };
22168
+ const RowColRoot = styled$1('div', {
22169
+ shouldForwardProp: prop => !['flexBasisProp', 'isGridMode', 'isGridCol', 'dense'].includes(prop)
22170
+ })(_ref2 => {
22171
+ 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;
22172
+ let {
22173
+ theme,
22174
+ flexBasisProp,
22175
+ isGridMode,
22176
+ isGridCol,
22177
+ dense
22178
+ } = _ref2;
22179
+ return {
22180
+ '&:focus': {
22181
+ boxShadow: "inset 0 0 0 2px ".concat(theme.palette.custom.focusBorder, " !important")
22182
+ },
22183
+ '&:focus-visible': {
22184
+ outline: 'none'
22185
+ },
22186
+ ["& .".concat(rowColClasses.row)]: {
22187
+ flexWrap: 'nowrap',
22188
+ 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
22189
+ },
22190
+ ["& .".concat(rowColClasses.rowBorderBottom)]: {
22191
+ borderBottom: isGridCol ? 'none' : "1px solid ".concat(theme.palette.divider),
22192
+ borderLeft: isGridCol ? "1px solid ".concat(theme.palette.divider) : 'none'
22193
+ },
22194
+ ["& .".concat(rowColClasses.column)]: {
22195
+ flexWrap: 'nowrap',
22196
+ borderRight: "1px solid ".concat(theme.palette.divider),
22197
+ 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
22198
+ },
22199
+ // The interior wrapper for all field content.
22200
+ ["& .".concat(rowColClasses.cell)]: {
22201
+ display: 'flex',
22202
+ alignItems: 'center',
22203
+ minWidth: 0,
22204
+ flexGrow: 1,
22205
+ // Note that this padding is overridden when using checkboxes.
22206
+ paddingLeft: '9px',
22207
+ paddingRight: '9px'
22208
+ },
22209
+ // The leaf node, containing the label text.
22210
+ ["& .".concat(rowColClasses.labelText)]: _objectSpread2(_objectSpread2({
22211
+ flexBasis: flexBasisProp,
22212
+ lineHeight: '16px',
22213
+ userSelect: 'none',
22214
+ whiteSpace: 'pre',
22215
+ // to keep white-space on highlight
22216
+ paddingRight: '9px'
22217
+ }, ellipsis), {}, {
22218
+ 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,
22219
+ 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
22220
+ }),
22221
+ ["& .".concat(rowColClasses.labelDense)]: {
22222
+ fontSize: 12
22223
+ },
22224
+ // Highlight is added to labelText spans, which are created as siblings to original labelText,
22225
+ // when a search string is matched.
22226
+ ["& .".concat(rowColClasses.highlighted)]: {
22227
+ overflow: 'visible',
22228
+ width: '100%',
22229
+ '& > span': {
22230
+ width: '100%',
22231
+ backgroundColor: '#FFC72A'
22232
+ }
22233
+ },
22234
+ // Checkbox and label container.
22235
+ ["& .".concat(rowColClasses.checkboxLabel)]: {
22236
+ margin: 0,
22237
+ width: '100%',
22238
+ height: '100%',
22239
+ overflow: 'hidden',
22240
+ // The checkbox's span
22241
+ '& > span:nth-of-type(1)': {
22242
+ paddingRight: '8px'
22243
+ },
22244
+ // The checkbox's label container.
22245
+ '& > span:nth-of-type(2)': _objectSpread2(_objectSpread2({}, ellipsis), {}, {
22246
+ display: 'flex',
22247
+ alignItems: 'center',
22248
+ paddingLeft: 0,
22249
+ paddingRight: '2px'
22250
+ })
22251
+ },
22252
+ // The icons container holding tick and lock, shown inside fields.
22253
+ ["& .".concat(rowColClasses.icon)]: {
22254
+ display: 'flex',
22255
+ padding: theme.spacing(1, 1, 1, 0)
22256
+ },
22257
+ // Selection styles (S=Selected, XS=ExcludedSelected, A=Available, X=Excluded).
22258
+ ["& .".concat(rowColClasses.S)]: _objectSpread2(_objectSpread2({}, getSelectedStyle({
22259
+ theme
22260
+ })), {}, {
22261
+ border: isGridMode ? 'none' : undefined
22262
+ }),
22263
+ ["& .".concat(rowColClasses.XS)]: _objectSpread2(_objectSpread2({}, getSelectedStyle({
22264
+ theme
22265
+ })), {}, {
22266
+ background: theme.palette.selected.excluded,
22267
+ color: theme.palette.selected.mainContrastText,
22268
+ border: isGridMode ? 'none' : undefined
22269
+ }),
22270
+ ["& .".concat(rowColClasses.A)]: {
22271
+ background: theme.palette.selected.alternative,
22272
+ color: theme.palette.selected.alternativeContrastText,
22273
+ border: isGridMode ? 'none' : undefined
22274
+ },
22275
+ ["& .".concat(rowColClasses.X)]: {
22276
+ background: theme.palette.selected.excluded,
22277
+ color: theme.palette.selected.excludedContrastText,
22278
+ border: isGridMode ? 'none' : undefined
22279
+ },
22280
+ ["& .".concat(rowColClasses.frequencyCount)]: {
22281
+ width: '66px',
22282
+ justifyContent: 'flex-end'
22283
+ },
22284
+ ["&.".concat(rowColClasses.barContainer)]: {
22285
+ height: '100%',
22286
+ display: 'flex',
22287
+ alignItems: 'center'
22288
+ },
22289
+ ["& .".concat(rowColClasses.bar)]: {
22290
+ border: "".concat(barBorderWidthPx, "px solid"),
22291
+ borderColor: '#D9D9D9',
22292
+ height: dense ? '16px' : '20px',
22293
+ position: 'absolute',
22294
+ zIndex: '-1',
22295
+ alignSelf: 'center',
22296
+ left: "".concat(barPadPx, "px"),
22297
+ transition: 'width 0.2s',
22298
+ backgroundColor: '#FAFAFA'
22299
+ },
22300
+ ["& .".concat(rowColClasses.barSelected)]: {
22301
+ opacity: '30%',
22302
+ zIndex: '0',
22303
+ background: theme.palette.background.lighter
22304
+ },
22305
+ ["& .".concat(rowColClasses.barWithCheckbox)]: {
22306
+ left: "".concat(barWithCheckboxLeftPadPx, "px")
22307
+ },
22308
+ ["& .".concat(rowColClasses.barSelectedWithCheckbox)]: {
22309
+ background: '#BFE5D0',
22310
+ borderColor: '#BFE5D0'
22311
+ },
22312
+ ["& .".concat(rowColClasses.excludedTextWithCheckbox)]: {
22313
+ color: '#828282',
22314
+ fontStyle: 'italic'
22315
+ }
21836
22316
  };
21837
- }
21838
-
21839
- const tick = props => _objectSpread2(_objectSpread2({}, props), {}, {
21840
- shapes: [{
21841
- type: 'path',
21842
- attrs: {
21843
- d: 'M6,10 L13,3 L15,5 L8,12 L6,14 L1,9 L3,7 L6,10 Z'
21844
- }
21845
- }]
21846
22317
  });
21847
- var Tick = (props => SvgIcon(tick(props)));
21848
22318
 
21849
22319
  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\")";
21850
22320
 
21851
- const PREFIX$c = 'ListBoxCheckbox';
22321
+ const PREFIX$b = 'ListBoxCheckbox';
21852
22322
  const borderRadius = 3;
21853
- const classes$c = {
21854
- cbIcon: "".concat(PREFIX$c, "-cbIcon"),
21855
- cbIconChecked: "".concat(PREFIX$c, "-cbIconChecked"),
21856
- cbIconExcluded: "".concat(PREFIX$c, "-cbIconExcluded"),
21857
- cbIconAlternative: "".concat(PREFIX$c, "-cbIconAlternative"),
21858
- checkbox: "".concat(PREFIX$c, "-checkbox"),
21859
- dense: "".concat(PREFIX$c, "-dense")
22323
+ const classes$b = {
22324
+ cbIcon: "".concat(PREFIX$b, "-cbIcon"),
22325
+ cbIconChecked: "".concat(PREFIX$b, "-cbIconChecked"),
22326
+ cbIconExcluded: "".concat(PREFIX$b, "-cbIconExcluded"),
22327
+ cbIconAlternative: "".concat(PREFIX$b, "-cbIconAlternative"),
22328
+ checkbox: "".concat(PREFIX$b, "-checkbox"),
22329
+ dense: "".concat(PREFIX$b, "-dense")
21860
22330
  };
21861
22331
  const StyledCheckbox = styled$1(Checkbox$1)(_ref => {
21862
22332
  let {
21863
22333
  theme
21864
22334
  } = _ref;
21865
22335
  return {
21866
- ["& .".concat(classes$c.cbIcon)]: {
22336
+ ["& .".concat(classes$b.cbIcon)]: {
21867
22337
  borderRadius,
21868
22338
  width: 16,
21869
22339
  height: 16,
@@ -21874,7 +22344,7 @@
21874
22344
  alignItems: 'center',
21875
22345
  justifyContent: 'center'
21876
22346
  },
21877
- ["& .".concat(classes$c.cbIconChecked)]: {
22347
+ ["& .".concat(classes$b.cbIconChecked)]: {
21878
22348
  borderRadius,
21879
22349
  backgroundColor: theme.palette.selected.main,
21880
22350
  backgroundImage: 'linear-gradient(180deg,hsla(0,0%,100%,.1),hsla(0,0%,100%,0))',
@@ -21886,25 +22356,25 @@
21886
22356
  content: '""'
21887
22357
  }
21888
22358
  },
21889
- ["& .".concat(classes$c.cbIconExcluded)]: {
22359
+ ["& .".concat(classes$b.cbIconExcluded)]: {
21890
22360
  borderRadius: borderRadius - 1,
21891
22361
  width: 12,
21892
22362
  height: 12,
21893
22363
  backgroundColor: theme.palette.selected.excluded
21894
22364
  },
21895
- ["& .".concat(classes$c.cbIconAlternative)]: {
22365
+ ["& .".concat(classes$b.cbIconAlternative)]: {
21896
22366
  borderRadius: borderRadius - 1,
21897
22367
  width: 12,
21898
22368
  height: 12,
21899
22369
  backgroundColor: theme.palette.selected.alternative
21900
22370
  },
21901
- ["&.".concat(classes$c.checkbox)]: {
22371
+ ["&.".concat(classes$b.checkbox)]: {
21902
22372
  margin: 0,
21903
22373
  '&:hover': {
21904
22374
  backgroundColor: 'inherit !important'
21905
22375
  }
21906
22376
  },
21907
- ["&.".concat(classes$c.dense)]: {
22377
+ ["&.".concat(classes$b.dense)]: {
21908
22378
  padding: '4px 8px'
21909
22379
  }
21910
22380
  };
@@ -21930,86 +22400,22 @@
21930
22400
  edge: "start",
21931
22401
  checked: checked,
21932
22402
  disableRipple: true,
21933
- className: [classes$c.checkbox, dense && classes$c.dense].filter(Boolean).join(' '),
22403
+ className: [classes$b.checkbox, dense && classes$b.dense].filter(Boolean).join(' '),
21934
22404
  inputProps: {
21935
22405
  'aria-labelledby': label
21936
22406
  },
21937
22407
  name: label,
21938
- icon: getIcon(classes$c, showGray, excluded),
22408
+ icon: getIcon(classes$b, showGray, excluded),
21939
22409
  checkedIcon: /*#__PURE__*/React.createElement("span", {
21940
- className: classes$c.cbIconChecked
22410
+ className: classes$b.cbIconChecked
21941
22411
  })
21942
22412
  });
21943
22413
  }
21944
22414
 
21945
- /**
21946
- * @ignore
21947
- * @interface Range
21948
- * @property {number} qCharPos The (absolute) index where the highlighted range starts.
21949
- * @property {number} qCharCount The length of the sub-string (starting from qChartPos) that should be highlighted.
21950
- */
21951
-
21952
- /**
21953
- * @ignore
21954
- * @interface Segment
21955
- * @property {string} segment The sub-string/segment cut out from the original label.
21956
- * @property {boolean} highlighted A flag which tells whether the segment should be highlighted or not.
21957
- */
21958
-
21959
- /**
21960
- * @ignore
21961
- * @param {string} label The label we want to create segments out of.
21962
- * @param {Range} range The indexes which define how to create the segments.
21963
- * @param {number=} [startIndex] An optional index which tells where we want to start the first segment from
21964
- * (only relevant for creating the first unhighlighted segment of a string/sub-string).
21965
- * @returns {Segment[]} An array of segments.
21966
- */
21967
- function getSegmentsFromRange(label, range) {
21968
- let startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
21969
- const {
21970
- qCharPos,
21971
- qCharCount
21972
- } = range;
21973
- const segments = [];
21974
- if (qCharPos > startIndex) {
21975
- // Create a non-highlighted section before the highighted section.
21976
- segments.push([label.slice(startIndex, qCharPos), false]);
21977
- }
21978
-
21979
- // Highlighted segment.
21980
- segments.push([label.slice(qCharPos, qCharPos + qCharCount), true]);
21981
- return segments;
21982
- }
21983
-
21984
- /**
21985
- * @ignore
21986
- * @param {string} label The label we want to create segments out of.
21987
- * @param {Range[]} ranges The ranges defining indices for cutting the string into segments.
21988
- * @returns {Segment[]} An array of segments, covering the entire string label.
21989
- */
21990
- function getSegmentsFromRanges(label, ranges) {
21991
- if (!ranges.length) {
21992
- return [];
21993
- }
21994
- const labels = ranges.reduce((acc, curr, ix) => {
21995
- const startIndex = ix === 0 ? 0 : ranges[ix - 1].qCharPos + ranges[ix - 1].qCharCount;
21996
- acc.push(...getSegmentsFromRange(label, curr, startIndex));
21997
-
21998
- // Last non highlighted segment
21999
- const isLastRange = ix === ranges.length - 1;
22000
- const endIndex = ranges[ix].qCharPos + ranges[ix].qCharCount;
22001
- if (isLastRange && endIndex < label.length) {
22002
- acc.push([label.slice(endIndex), false]);
22003
- }
22004
- return acc;
22005
- }, []);
22006
- return labels;
22007
- }
22008
-
22009
- const PREFIX$b = 'ListBoxRadioButton';
22010
- const classes$b = {
22011
- denseRadioButton: "".concat(PREFIX$b, "-denseRadioButton"),
22012
- radioButton: "".concat(PREFIX$b, "-radioButton")
22415
+ const PREFIX$a = 'ListBoxRadioButton';
22416
+ const classes$a = {
22417
+ denseRadioButton: "".concat(PREFIX$a, "-denseRadioButton"),
22418
+ radioButton: "".concat(PREFIX$a, "-radioButton")
22013
22419
  };
22014
22420
  const StyledRadio = styled$1(Radio$1)(_ref => {
22015
22421
  let {
@@ -22017,7 +22423,7 @@
22017
22423
  checked
22018
22424
  } = _ref;
22019
22425
  return {
22020
- ["&.".concat(classes$b.radioButton)]: {
22426
+ ["&.".concat(classes$a.radioButton)]: {
22021
22427
  right: '5px',
22022
22428
  color: checked ? theme.palette.selected.main : theme.palette.main
22023
22429
  }
@@ -22033,7 +22439,7 @@
22033
22439
  checked: checked,
22034
22440
  value: label,
22035
22441
  name: label,
22036
- className: classes$b.radioButton,
22442
+ className: classes$a.radioButton,
22037
22443
  style: {
22038
22444
  backgroundColor: 'transparent'
22039
22445
  },
@@ -22045,237 +22451,251 @@
22045
22451
  });
22046
22452
  }
22047
22453
 
22048
- const KEYS = Object.freeze({
22049
- ENTER: 13,
22050
- ESCAPE: 27,
22051
- SPACE: 32,
22052
- TAB: 9,
22053
- BACKSPACE: 8,
22054
- DELETE: 46,
22055
- ALT: 18,
22056
- CTRL: 17,
22057
- SHIFT: 16,
22058
- ARROW_UP: 38,
22059
- ARROW_DOWN: 40,
22060
- ARROW_LEFT: 37,
22061
- ARROW_RIGHT: 39,
22062
- PAGE_DOWN: 34,
22063
- PAGE_UP: 33,
22064
- HOME: 36,
22065
- END: 35,
22066
- F10: 121,
22067
- A: 65,
22068
- F: 70,
22069
- ZERO: 48,
22070
- NINE: 57,
22071
- NUMPAD_ZERO: 96,
22072
- NUMPAD_NINE: 105,
22073
- SUBTRACTION: 189,
22074
- DECIMAL: 190,
22075
- NUMPAD_DECIMAL: 110,
22076
- isArrow: key => key === KEYS.ARROW_UP || key === KEYS.ARROW_DOWN || key === KEYS.ARROW_LEFT || key === KEYS.ARROW_RIGHT
22077
- });
22078
-
22079
- function getFieldKeyboardNavigation(_ref) {
22454
+ function ValueField(_ref) {
22080
22455
  let {
22081
- select,
22082
- confirm,
22083
- cancel,
22084
- setScrollPosition,
22085
- focusListItems
22456
+ label,
22457
+ color,
22458
+ highlighted = false,
22459
+ dense,
22460
+ showGray = true,
22461
+ checkboxes,
22462
+ cell,
22463
+ valueTextAlign
22086
22464
  } = _ref;
22087
- const getElement = function (elm) {
22088
- let next = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
22089
- const parentElm = elm && elm.parentElement[next ? 'nextElementSibling' : 'previousElementSibling'];
22090
- return parentElm && parentElm.querySelector('[role]');
22091
- };
22092
- let startedRange = false;
22093
- const setStartedRange = val => {
22094
- startedRange = val;
22095
- };
22096
- const handleKeyDown = event => {
22097
- let elementToFocus;
22098
- const {
22099
- keyCode,
22100
- shiftKey = false,
22101
- ctrlKey = false
22102
- } = event.nativeEvent;
22103
- switch (keyCode) {
22104
- case KEYS.SHIFT:
22105
- // This is to ensure we include the first value when starting a range selection.
22106
- setStartedRange(true);
22107
- break;
22108
- case KEYS.SPACE:
22109
- select([+event.currentTarget.getAttribute('data-n')]);
22110
- break;
22111
- case KEYS.ARROW_DOWN:
22112
- case KEYS.ARROW_RIGHT:
22113
- elementToFocus = getElement(event.currentTarget, true);
22114
- if (shiftKey && elementToFocus) {
22115
- if (startedRange) {
22116
- select([+event.currentTarget.getAttribute('data-n')], true);
22117
- setStartedRange(false);
22118
- }
22119
- select([+elementToFocus.getAttribute('data-n')], true);
22120
- }
22121
- break;
22122
- case KEYS.ARROW_UP:
22123
- case KEYS.ARROW_LEFT:
22124
- elementToFocus = getElement(event.currentTarget, false);
22125
- if (shiftKey && elementToFocus) {
22126
- if (startedRange) {
22127
- select([+event.currentTarget.getAttribute('data-n')], true);
22128
- setStartedRange(false);
22129
- }
22130
- select([+elementToFocus.getAttribute('data-n')], true);
22131
- }
22132
- break;
22133
- case KEYS.ENTER:
22134
- confirm();
22135
- break;
22136
- case KEYS.ESCAPE:
22137
- cancel();
22138
- return;
22139
- // let it propagate to top-level
22140
- case KEYS.HOME:
22141
- focusListItems.setFirst(true);
22142
- if (ctrlKey) {
22143
- setScrollPosition === null || setScrollPosition === void 0 ? void 0 : setScrollPosition('overflowStart');
22144
- break;
22145
- }
22146
- setScrollPosition === null || setScrollPosition === void 0 ? void 0 : setScrollPosition('start');
22147
- break;
22148
- case KEYS.END:
22149
- focusListItems.setLast(true);
22150
- if (ctrlKey) {
22151
- setScrollPosition === null || setScrollPosition === void 0 ? void 0 : setScrollPosition('overflowEnd');
22152
- break;
22153
- }
22154
- setScrollPosition === null || setScrollPosition === void 0 ? void 0 : setScrollPosition('end');
22155
- break;
22156
- default:
22157
- return;
22158
- // don't stop propagation since we want to outsource keydown to other handlers.
22465
+ return /*#__PURE__*/React.createElement(Typography$1, {
22466
+ component: "span",
22467
+ variant: "body2",
22468
+ className: joinClassNames([rowColClasses.labelText, highlighted && rowColClasses.highlighted, dense && rowColClasses.labelDense, showGray && excludedOrAlternative({
22469
+ cell,
22470
+ checkboxes
22471
+ }) && rowColClasses.excludedTextWithCheckbox]),
22472
+ color: color,
22473
+ justifyContent: valueTextAlign
22474
+ }, /*#__PURE__*/React.createElement("span", {
22475
+ style: {
22476
+ whiteSpace: 'pre'
22159
22477
  }
22478
+ }, label));
22479
+ }
22160
22480
 
22161
- if (elementToFocus) {
22162
- elementToFocus.focus();
22163
- }
22164
- event.preventDefault();
22165
- event.stopPropagation();
22166
- };
22167
- return handleKeyDown;
22481
+ function LabelTag(_ref) {
22482
+ let {
22483
+ label,
22484
+ color,
22485
+ highlighted,
22486
+ dense,
22487
+ showGray,
22488
+ checkboxes,
22489
+ cell,
22490
+ valueTextAlign
22491
+ } = _ref;
22492
+ if (typeof label === 'string') {
22493
+ return /*#__PURE__*/React.createElement(ValueField, {
22494
+ label: label,
22495
+ color: color,
22496
+ highlighted: highlighted,
22497
+ dense: dense,
22498
+ showGray: showGray,
22499
+ checkboxes: checkboxes,
22500
+ cell: cell,
22501
+ valueTextAlign: valueTextAlign
22502
+ });
22503
+ }
22504
+ return label;
22168
22505
  }
22169
- function getListboxInlineKeyboardNavigation(_ref2) {
22506
+
22507
+ function CheckboxField(_ref) {
22170
22508
  let {
22171
- setKeyboardActive,
22172
- hovering,
22173
- setHovering,
22174
- updateKeyScroll,
22175
- containerRef,
22176
- currentScrollIndex,
22177
- app,
22178
- appSelections,
22179
- constraints
22180
- } = _ref2;
22181
- const focusInsideListbox = element => {
22182
- const fieldElement = element.querySelector('.search input, .value.selector, .value, .ActionsToolbar-* button');
22183
- setKeyboardActive(true);
22184
- if (fieldElement) {
22185
- fieldElement.focus();
22186
- }
22187
- };
22188
- const focusContainer = element => {
22189
- setKeyboardActive(false);
22190
- element.focus();
22191
- };
22192
- const updateKeyScrollOnHover = newState => {
22193
- if (hovering) {
22194
- updateKeyScroll(newState);
22195
- }
22196
- };
22197
- const handleKeyDown = event => {
22198
- const {
22199
- keyCode,
22200
- ctrlKey = false,
22201
- shiftKey = false
22202
- } = event.nativeEvent;
22203
- switch (keyCode) {
22204
- // case KEYS.TAB: TODO: Focus confirm button using keyboard.focusSelection when we can access the useKeyboard hook.
22205
- case KEYS.ENTER:
22206
- case KEYS.SPACE:
22207
- if (!event.target.classList.contains('listbox-container')) {
22208
- return; // don't mess with keydown handlers within the listbox
22209
- }
22509
+ label,
22510
+ color,
22511
+ qElemNumber,
22512
+ isSelected,
22513
+ dense,
22514
+ cell,
22515
+ isGridCol,
22516
+ showGray,
22517
+ isSingleSelect,
22518
+ highlighted,
22519
+ checkboxes,
22520
+ valueTextAlign
22521
+ } = _ref;
22522
+ const cb = /*#__PURE__*/React.createElement(ListboxCheckbox, {
22523
+ label: label,
22524
+ checked: isSelected,
22525
+ dense: dense,
22526
+ excluded: isExcluded(cell),
22527
+ isGridCol: isGridCol,
22528
+ showGray: showGray
22529
+ });
22530
+ const rb = /*#__PURE__*/React.createElement(ListBoxRadioButton, {
22531
+ label: label,
22532
+ checked: isSelected,
22533
+ dense: dense
22534
+ });
22535
+ return /*#__PURE__*/React.createElement(FormControlLabel$1, {
22536
+ color: color,
22537
+ control: isSingleSelect ? rb : cb,
22538
+ className: rowColClasses.checkboxLabel,
22539
+ label: /*#__PURE__*/React.createElement(LabelTag, {
22540
+ label: label,
22541
+ color: color,
22542
+ highlighted: highlighted,
22543
+ dense: dense,
22544
+ showGray: showGray,
22545
+ checkboxes: checkboxes,
22546
+ cell: cell,
22547
+ valueTextAlign: valueTextAlign
22548
+ }),
22549
+ key: qElemNumber
22550
+ });
22551
+ }
22210
22552
 
22211
- focusInsideListbox(event.currentTarget);
22212
- break;
22213
- case KEYS.ESCAPE:
22214
- focusContainer(event.currentTarget);
22215
- break;
22216
- case KEYS.ARROW_UP:
22217
- updateKeyScrollOnHover({
22218
- up: 1
22219
- });
22220
- break;
22221
- case KEYS.ARROW_DOWN:
22222
- updateKeyScrollOnHover({
22223
- down: 1
22224
- });
22225
- break;
22226
- case KEYS.PAGE_UP:
22227
- updateKeyScrollOnHover({
22228
- up: currentScrollIndex.stop - currentScrollIndex.start
22229
- });
22230
- break;
22231
- case KEYS.PAGE_DOWN:
22232
- updateKeyScrollOnHover({
22233
- down: currentScrollIndex.stop - currentScrollIndex.start
22234
- });
22235
- break;
22236
- case KEYS.HOME:
22237
- updateKeyScrollOnHover({
22238
- scrollPosition: ctrlKey && shiftKey ? 'overflowStart' : 'start'
22239
- });
22240
- break;
22241
- case KEYS.END:
22242
- updateKeyScrollOnHover({
22243
- scrollPosition: ctrlKey && shiftKey ? 'overflowEnd' : 'end'
22244
- });
22245
- break;
22246
- default:
22247
- return;
22248
- }
22553
+ function LabelsWithRanges(_ref) {
22554
+ let {
22555
+ labels,
22556
+ dense,
22557
+ showGray,
22558
+ checkboxes
22559
+ } = _ref;
22560
+ return /*#__PURE__*/React.createElement(React.Fragment, null, labels.map(_ref2 => {
22561
+ let [label, highlighted] = _ref2;
22562
+ return /*#__PURE__*/React.createElement(ValueField, {
22563
+ label: label,
22564
+ key: label,
22565
+ highlighted: highlighted,
22566
+ dense: dense,
22567
+ showGray: showGray,
22568
+ checkboxes: checkboxes
22569
+ });
22570
+ }));
22571
+ }
22572
+ function FieldWithRanges(_ref3) {
22573
+ let {
22574
+ labels,
22575
+ checkboxes,
22576
+ dense,
22577
+ showGray,
22578
+ color,
22579
+ qElemNumber,
22580
+ isSelected,
22581
+ cell,
22582
+ isGridCol,
22583
+ isSingleSelect,
22584
+ valueTextAlign
22585
+ } = _ref3;
22586
+ const LWR = /*#__PURE__*/React.createElement(LabelsWithRanges, {
22587
+ labels: labels,
22588
+ dense: dense,
22589
+ showGray: showGray,
22590
+ checkboxes: checkboxes
22591
+ });
22592
+ return checkboxes ? /*#__PURE__*/React.createElement(CheckboxField, {
22593
+ label: LWR,
22594
+ color: color,
22595
+ qElemNumber: qElemNumber,
22596
+ isSelected: isSelected,
22597
+ dense: dense,
22598
+ cell: cell,
22599
+ isGridCol: isGridCol,
22600
+ showGray: showGray,
22601
+ isSingleSelect: isSingleSelect,
22602
+ checkboxes: checkboxes,
22603
+ valueTextAlign: valueTextAlign
22604
+ }) : LWR;
22605
+ }
22249
22606
 
22250
- // Note: We should not stop propagation here as it will block the containing app
22251
- // from handling keydown events.
22252
- event.preventDefault();
22253
- };
22254
- const focusOnHoverDisabled = () => {
22255
- var _app$isInModalSelecti, _app$isInModalSelecti2;
22256
- const selectNotAllowed = (constraints === null || constraints === void 0 ? void 0 : constraints.select) || (constraints === null || constraints === void 0 ? void 0 : constraints.active);
22257
- 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();
22258
- return selectNotAllowed || appInModal;
22259
- };
22260
- const handleOnMouseEnter = () => {
22261
- if (!focusOnHoverDisabled()) {
22262
- var _containerRef$current, _containerRef$current2;
22263
- setHovering(true);
22264
- 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);
22265
- }
22266
- };
22267
- const handleOnMouseLeave = () => {
22268
- if (hovering) {
22269
- var _containerRef$current3, _containerRef$current4;
22270
- setHovering(false);
22271
- 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);
22607
+ function Field(_ref) {
22608
+ let {
22609
+ label,
22610
+ color,
22611
+ qElemNumber,
22612
+ isSelected,
22613
+ dense,
22614
+ cell,
22615
+ isGridCol,
22616
+ showGray,
22617
+ isSingleSelect,
22618
+ highlighted,
22619
+ checkboxes,
22620
+ valueTextAlign
22621
+ } = _ref;
22622
+ return checkboxes ? /*#__PURE__*/React.createElement(CheckboxField, {
22623
+ label: label,
22624
+ color: color,
22625
+ qElemNumber: qElemNumber,
22626
+ isSelected: isSelected,
22627
+ dense: dense,
22628
+ cell: cell,
22629
+ isGridCol: isGridCol,
22630
+ showGray: showGray,
22631
+ isSingleSelect: isSingleSelect,
22632
+ highlighted: highlighted,
22633
+ checkboxes: checkboxes,
22634
+ valueTextAlign: valueTextAlign
22635
+ }) : /*#__PURE__*/React.createElement(ValueField, {
22636
+ label: label,
22637
+ color: color,
22638
+ highlighted: false,
22639
+ dense: dense,
22640
+ showGray: true,
22641
+ checkboxes: checkboxes,
22642
+ cell: cell,
22643
+ valueTextAlign: valueTextAlign
22644
+ });
22645
+ }
22646
+
22647
+ function Histogram(_ref) {
22648
+ let {
22649
+ cell,
22650
+ histogram,
22651
+ checkboxes,
22652
+ isSelected,
22653
+ frequencyMax
22654
+ } = _ref;
22655
+ const hasHistogramBar = cell && histogram && getFrequencyText({
22656
+ cell
22657
+ }) !== frequencyTextNone;
22658
+ if (!hasHistogramBar) {
22659
+ return undefined;
22660
+ }
22661
+ const width = getBarWidth({
22662
+ qFrequency: cell.qFrequency,
22663
+ checkboxes,
22664
+ frequencyMax
22665
+ });
22666
+ return /*#__PURE__*/React.createElement("div", {
22667
+ className: joinClassNames([rowColClasses.bar, checkboxes && rowColClasses.barWithCheckbox, isSelected && (checkboxes ? rowColClasses.barSelectedWithCheckbox : rowColClasses.barSelected)]),
22668
+ style: {
22669
+ width
22272
22670
  }
22273
- };
22274
- return {
22275
- handleKeyDown,
22276
- handleOnMouseEnter,
22277
- handleOnMouseLeave
22278
- };
22671
+ });
22672
+ }
22673
+
22674
+ function Frequency(_ref) {
22675
+ let {
22676
+ cell,
22677
+ checkboxes,
22678
+ dense,
22679
+ showGray
22680
+ } = _ref;
22681
+ return /*#__PURE__*/React.createElement(Grid$1, {
22682
+ item: true,
22683
+ style: {
22684
+ display: 'flex',
22685
+ alignItems: 'center'
22686
+ },
22687
+ className: rowColClasses.frequencyCount
22688
+ }, /*#__PURE__*/React.createElement(Typography$1, {
22689
+ noWrap: true,
22690
+ color: "inherit",
22691
+ variant: "body2",
22692
+ className: joinClassNames([dense && rowColClasses.labelDense, rowColClasses.labelText, showGray && excludedOrAlternative({
22693
+ cell,
22694
+ checkboxes
22695
+ }) && rowColClasses.excludedTextWithCheckbox])
22696
+ }, getFrequencyText({
22697
+ cell
22698
+ })));
22279
22699
  }
22280
22700
 
22281
22701
  function getGridItemSizes(_ref) {
@@ -22295,234 +22715,36 @@
22295
22715
  case 'row':
22296
22716
  return {
22297
22717
  height: "calc(100% - ".concat(itemPadding, "px)"),
22298
- width: "calc(100% - ".concat(2 * itemPadding, "px)")
22299
- };
22300
- case 'column':
22301
- return {
22302
- height: "calc(100% - ".concat(itemPadding, "px)"),
22303
- width: "calc(100% - ".concat(2 * itemPadding, "px)")
22304
- };
22305
- default:
22306
- return {};
22307
- }
22308
- }
22309
-
22310
- const PREFIX$a = 'RowColumn';
22311
- const classes$a = {
22312
- row: "".concat(PREFIX$a, "-row"),
22313
- rowBorderBottom: "".concat(PREFIX$a, "-rowBorderBottom"),
22314
- column: "".concat(PREFIX$a, "-column"),
22315
- fieldRoot: "".concat(PREFIX$a, "-fieldRoot"),
22316
- cell: "".concat(PREFIX$a, "-cell"),
22317
- labelText: "".concat(PREFIX$a, "-labelText"),
22318
- labelDense: "".concat(PREFIX$a, "-labelDense"),
22319
- highlighted: "".concat(PREFIX$a, "-highlighted"),
22320
- checkboxLabel: "".concat(PREFIX$a, "-checkboxLabel"),
22321
- icon: "".concat(PREFIX$a, "-icon"),
22322
- S: "".concat(PREFIX$a, "-S"),
22323
- XS: "".concat(PREFIX$a, "-XS"),
22324
- A: "".concat(PREFIX$a, "-A"),
22325
- X: "".concat(PREFIX$a, "-X"),
22326
- frequencyCount: "".concat(PREFIX$a, "-frequencyCount"),
22327
- barContainer: "".concat(PREFIX$a, "-barContainer"),
22328
- bar: "".concat(PREFIX$a, "-bar"),
22329
- barSelected: "".concat(PREFIX$a, "-barSelected"),
22330
- barWithCheckbox: "".concat(PREFIX$a, "-barWithCheckbox"),
22331
- barSelectedWithCheckbox: "".concat(PREFIX$a, "-barSelectedWithCheckbox"),
22332
- excludedTextWithCheckbox: "".concat(PREFIX$a, "-excludedTextWithCheckbox")
22333
- };
22334
- const ellipsis = {
22335
- width: '100%',
22336
- overflow: 'hidden',
22337
- textOverflow: 'ellipsis'
22338
- };
22339
- const barPadPx = 4;
22340
- const barBorderWidthPx = 1;
22341
- const barWithCheckboxLeftPadPx = 29;
22342
- const frequencyTextNone = '-';
22343
- const getSelectedStyle = _ref => {
22344
- let {
22345
- theme
22346
- } = _ref;
22347
- return {
22348
- background: theme.palette.selected.main,
22349
- color: theme.palette.selected.mainContrastText,
22350
- '&:focus': {
22351
- boxShadow: "inset 0 0 0 2px ".concat(theme.palette.custom.focusBorder),
22352
- outline: 'none'
22353
- },
22354
- '& $cell': {
22355
- paddingRight: 0
22356
- }
22357
- };
22358
- };
22718
+ width: "calc(100% - ".concat(2 * itemPadding, "px)")
22719
+ };
22720
+ case 'column':
22721
+ return {
22722
+ height: "calc(100% - ".concat(itemPadding, "px)"),
22723
+ width: "calc(100% - ".concat(2 * itemPadding, "px)")
22724
+ };
22725
+ default:
22726
+ return {};
22727
+ }
22728
+ }
22729
+
22359
22730
  const ItemGrid = styled$1(Grid$1, {
22360
22731
  shouldForwardProp: prop => !['dataLayout', 'layoutOrder', 'itemPadding'].includes(prop)
22361
- })(_ref2 => {
22732
+ })(_ref => {
22362
22733
  let {
22363
22734
  dataLayout,
22364
22735
  layoutOrder,
22365
22736
  itemPadding
22366
- } = _ref2;
22737
+ } = _ref;
22367
22738
  return {
22368
- ["&.".concat(classes$a.fieldRoot)]: getGridItemSizes({
22739
+ ["&.".concat(rowColClasses.fieldRoot)]: getGridItemSizes({
22369
22740
  dataLayout,
22370
22741
  layoutOrder,
22371
22742
  itemPadding
22372
22743
  })
22373
22744
  };
22374
22745
  });
22375
- const Root$1 = styled$1('div', {
22376
- shouldForwardProp: prop => !['flexBasisProp', 'isGridMode', 'isGridCol', 'dense'].includes(prop)
22377
- })(_ref3 => {
22378
- 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;
22379
- let {
22380
- theme,
22381
- flexBasisProp,
22382
- isGridMode,
22383
- isGridCol,
22384
- dense
22385
- } = _ref3;
22386
- return {
22387
- '&:focus': {
22388
- boxShadow: "inset 0 0 0 2px ".concat(theme.palette.custom.focusBorder, " !important")
22389
- },
22390
- '&:focus-visible': {
22391
- outline: 'none'
22392
- },
22393
- ["& .".concat(classes$a.row)]: {
22394
- flexWrap: 'nowrap',
22395
- 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
22396
- },
22397
- ["& .".concat(classes$a.rowBorderBottom)]: {
22398
- borderBottom: isGridCol ? 'none' : "1px solid ".concat(theme.palette.divider),
22399
- borderLeft: isGridCol ? "1px solid ".concat(theme.palette.divider) : 'none'
22400
- },
22401
- ["& .".concat(classes$a.column)]: {
22402
- flexWrap: 'nowrap',
22403
- borderRight: "1px solid ".concat(theme.palette.divider),
22404
- 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
22405
- },
22406
- // The interior wrapper for all field content.
22407
- ["& .".concat(classes$a.cell)]: {
22408
- display: 'flex',
22409
- alignItems: 'center',
22410
- minWidth: 0,
22411
- flexGrow: 1,
22412
- // Note that this padding is overridden when using checkboxes.
22413
- paddingLeft: '9px',
22414
- paddingRight: '9px'
22415
- },
22416
- // The leaf node, containing the label text.
22417
- ["& .".concat(classes$a.labelText)]: _objectSpread2(_objectSpread2({
22418
- flexBasis: flexBasisProp,
22419
- lineHeight: '16px',
22420
- userSelect: 'none',
22421
- whiteSpace: 'pre',
22422
- // to keep white-space on highlight
22423
- paddingRight: '9px'
22424
- }, ellipsis), {}, {
22425
- 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,
22426
- 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
22427
- }),
22428
- ["& .".concat(classes$a.labelDense)]: {
22429
- fontSize: 12
22430
- },
22431
- // Highlight is added to labelText spans, which are created as siblings to original labelText,
22432
- // when a search string is matched.
22433
- ["& .".concat(classes$a.highlighted)]: {
22434
- overflow: 'visible',
22435
- width: '100%',
22436
- '& > span': {
22437
- width: '100%',
22438
- backgroundColor: '#FFC72A'
22439
- }
22440
- },
22441
- // Checkbox and label container.
22442
- ["& .".concat(classes$a.checkboxLabel)]: {
22443
- margin: 0,
22444
- width: '100%',
22445
- height: '100%',
22446
- overflow: 'hidden',
22447
- // The checkbox's span
22448
- '& > span:nth-of-type(1)': {
22449
- paddingRight: '8px'
22450
- },
22451
- // The checkbox's label container.
22452
- '& > span:nth-of-type(2)': _objectSpread2(_objectSpread2({}, ellipsis), {}, {
22453
- display: 'flex',
22454
- alignItems: 'center',
22455
- paddingLeft: 0,
22456
- paddingRight: '2px'
22457
- })
22458
- },
22459
- // The icons container holding tick and lock, shown inside fields.
22460
- ["& .".concat(classes$a.icon)]: {
22461
- display: 'flex',
22462
- padding: theme.spacing(1, 1, 1, 0)
22463
- },
22464
- // Selection styles (S=Selected, XS=ExcludedSelected, A=Available, X=Excluded).
22465
- ["& .".concat(classes$a.S)]: _objectSpread2(_objectSpread2({}, getSelectedStyle({
22466
- theme
22467
- })), {}, {
22468
- border: isGridMode ? 'none' : undefined
22469
- }),
22470
- ["& .".concat(classes$a.XS)]: _objectSpread2(_objectSpread2({}, getSelectedStyle({
22471
- theme
22472
- })), {}, {
22473
- background: theme.palette.selected.excluded,
22474
- color: theme.palette.selected.mainContrastText,
22475
- border: isGridMode ? 'none' : undefined
22476
- }),
22477
- ["& .".concat(classes$a.A)]: {
22478
- background: theme.palette.selected.alternative,
22479
- color: theme.palette.selected.alternativeContrastText,
22480
- border: isGridMode ? 'none' : undefined
22481
- },
22482
- ["& .".concat(classes$a.X)]: {
22483
- background: theme.palette.selected.excluded,
22484
- color: theme.palette.selected.excludedContrastText,
22485
- border: isGridMode ? 'none' : undefined
22486
- },
22487
- ["& .".concat(classes$a.frequencyCount)]: {
22488
- width: '66px',
22489
- justifyContent: 'flex-end'
22490
- },
22491
- ["&.".concat(classes$a.barContainer)]: {
22492
- height: '100%',
22493
- display: 'flex',
22494
- alignItems: 'center'
22495
- },
22496
- ["& .".concat(classes$a.bar)]: {
22497
- border: "".concat(barBorderWidthPx, "px solid"),
22498
- borderColor: '#D9D9D9',
22499
- height: dense ? '16px' : '20px',
22500
- position: 'absolute',
22501
- zIndex: '-1',
22502
- alignSelf: 'center',
22503
- left: "".concat(barPadPx, "px"),
22504
- transition: 'width 0.2s',
22505
- backgroundColor: '#FAFAFA'
22506
- },
22507
- ["& .".concat(classes$a.barSelected)]: {
22508
- opacity: '30%',
22509
- zIndex: '0',
22510
- background: theme.palette.background.lighter
22511
- },
22512
- ["& .".concat(classes$a.barWithCheckbox)]: {
22513
- left: "".concat(barWithCheckboxLeftPadPx, "px")
22514
- },
22515
- ["& .".concat(classes$a.barSelectedWithCheckbox)]: {
22516
- background: '#BFE5D0',
22517
- borderColor: '#BFE5D0'
22518
- },
22519
- ["& .".concat(classes$a.excludedTextWithCheckbox)]: {
22520
- color: '#828282',
22521
- fontStyle: 'italic'
22522
- }
22523
- };
22524
- });
22525
- function RowColumn(_ref4) {
22746
+
22747
+ function RowColumn(_ref) {
22526
22748
  var _cell$qText;
22527
22749
  let {
22528
22750
  index,
@@ -22530,7 +22752,7 @@
22530
22752
  columnIndex,
22531
22753
  style,
22532
22754
  data
22533
- } = _ref4;
22755
+ } = _ref;
22534
22756
  const {
22535
22757
  onClick,
22536
22758
  onMouseDown,
@@ -22624,25 +22846,23 @@
22624
22846
  }
22625
22847
  setCell(c);
22626
22848
  }, [pages]);
22627
- const isExcluded = c => c ? c.qState === 'X' || c.qState === 'XS' || c.qState === 'XL' : null;
22628
- const isAlternative = c => c ? c.qState === 'A' : null;
22629
22849
  reactExports.useEffect(() => {
22630
22850
  if (!cell) {
22631
22851
  return;
22632
22852
  }
22633
22853
  const selected = cell.qState === 'S' || cell.qState === 'XS' || cell.qState === 'L';
22634
22854
  setSelected(selected);
22635
- const clazzArr = [column ? classes$a.column : classes$a.row];
22636
- if (!(histogram && (dense || checkboxes))) clazzArr.push(classes$a.rowBorderBottom);
22855
+ const clazzArr = [column ? rowColClasses.column : rowColClasses.row];
22856
+ if (!(histogram && (dense || checkboxes))) clazzArr.push(rowColClasses.rowBorderBottom);
22637
22857
  if (!checkboxes) {
22638
22858
  if (cell.qState === 'XS') {
22639
- clazzArr.push(showGray ? classes$a.XS : classes$a.S);
22859
+ clazzArr.push(showGray ? rowColClasses.XS : rowColClasses.S);
22640
22860
  } else if (cell.qState === 'S' || cell.qState === 'L') {
22641
- clazzArr.push(classes$a.S);
22861
+ clazzArr.push(rowColClasses.S);
22642
22862
  } else if (showGray && isAlternative(cell)) {
22643
- clazzArr.push(classes$a.A);
22863
+ clazzArr.push(rowColClasses.A);
22644
22864
  } else if (showGray && isExcluded(cell)) {
22645
- clazzArr.push(classes$a.X);
22865
+ clazzArr.push(rowColClasses.X);
22646
22866
  }
22647
22867
  }
22648
22868
  setClassArr(clazzArr);
@@ -22651,8 +22871,6 @@
22651
22871
  return null; // prevent rendering empty rows
22652
22872
  }
22653
22873
 
22654
- const joinClassNames = namesArray => namesArray.filter(c => !!c).join(' ').trim();
22655
- const excludedOrAlternative = () => (isAlternative(cell) || isExcluded(cell)) && checkboxes;
22656
22874
  const isNumeric = !['NaN', undefined].includes(cell === null || cell === void 0 ? void 0 : cell.qNum);
22657
22875
  let valueTextAlign;
22658
22876
  const isAutoTextAlign = !textAlign || textAlign.auto;
@@ -22665,26 +22883,6 @@
22665
22883
  } else {
22666
22884
  valueTextAlign = (textAlign === null || textAlign === void 0 ? void 0 : textAlign.align) || 'left';
22667
22885
  }
22668
- const getValueField = _ref5 => {
22669
- let {
22670
- lbl,
22671
- ix,
22672
- color,
22673
- highlighted = false
22674
- } = _ref5;
22675
- return /*#__PURE__*/React.createElement(Typography$1, {
22676
- component: "span",
22677
- variant: "body2",
22678
- key: ix,
22679
- className: joinClassNames([classes$a.labelText, highlighted && classes$a.highlighted, dense && classes$a.labelDense, showGray && excludedOrAlternative() && classes$a.excludedTextWithCheckbox]),
22680
- color: color,
22681
- justifyContent: valueTextAlign
22682
- }, /*#__PURE__*/React.createElement("span", {
22683
- style: {
22684
- whiteSpace: 'pre'
22685
- }
22686
- }, lbl));
22687
- };
22688
22886
  const preventContextMenu = event => {
22689
22887
  if (checkboxes) {
22690
22888
  // Event will not propagate in the checkbox/radiobutton case
@@ -22693,66 +22891,11 @@
22693
22891
  event.preventDefault();
22694
22892
  };
22695
22893
  const isGridCol = dataLayout === 'grid' && layoutOrder === 'column';
22696
- const getCheckboxField = _ref6 => {
22697
- let {
22698
- lbl,
22699
- color,
22700
- qElemNumber
22701
- } = _ref6;
22702
- const cb = /*#__PURE__*/React.createElement(ListboxCheckbox, {
22703
- label: lbl,
22704
- checked: isSelected,
22705
- dense: dense,
22706
- excluded: isExcluded(cell),
22707
- isGridCol: isGridCol,
22708
- showGray: showGray
22709
- });
22710
- const rb = /*#__PURE__*/React.createElement(ListBoxRadioButton, {
22711
- label: lbl,
22712
- checked: isSelected,
22713
- dense: dense
22714
- });
22715
- const labelTag = typeof lbl === 'string' ? getValueField({
22716
- lbl,
22717
- color,
22718
- highlighted: false
22719
- }) : lbl;
22720
- return /*#__PURE__*/React.createElement(FormControlLabel$1, {
22721
- color: color,
22722
- control: isSingleSelect ? rb : cb,
22723
- className: classes$a.checkboxLabel,
22724
- label: labelTag,
22725
- key: qElemNumber
22726
- });
22727
- };
22728
22894
  const label = (_cell$qText = cell === null || cell === void 0 ? void 0 : cell.qText) !== null && _cell$qText !== void 0 ? _cell$qText : '';
22729
- const getFrequencyText = () => {
22730
- if (cell) {
22731
- return cell.qFrequency ? cell.qFrequency : frequencyTextNone;
22732
- }
22733
- return '';
22734
- };
22735
22895
 
22736
22896
  // Search highlights. Split up labelText span into several and add the highlighted class to matching sub-strings.
22737
22897
  const ranges = cell && cell.qHighlightRanges && cell.qHighlightRanges.qRanges.sort((a, b) => a.qCharPos - b.qCharPos) || [];
22738
22898
  const labels = getSegmentsFromRanges(label, ranges);
22739
- const getField = checkboxes ? getCheckboxField : getValueField;
22740
- const getFieldWithRanges = _ref7 => {
22741
- let {
22742
- lbls
22743
- } = _ref7;
22744
- const labelsWithRanges = lbls.map((_ref8, ix) => {
22745
- let [lbl, highlighted] = _ref8;
22746
- return getValueField({
22747
- ix,
22748
- highlighted,
22749
- lbl
22750
- });
22751
- });
22752
- return checkboxes ? getCheckboxField({
22753
- lbl: labelsWithRanges
22754
- }) : labelsWithRanges;
22755
- };
22756
22899
  const iconStyles = {
22757
22900
  alignItems: 'center',
22758
22901
  display: 'flex',
@@ -22768,19 +22911,10 @@
22768
22911
  padding: checkboxes ? 0 : undefined,
22769
22912
  justifyContent: valueTextAlign
22770
22913
  };
22771
- const hasHistogramBar = () => cell && histogram && getFrequencyText() !== frequencyTextNone;
22772
- const getBarWidth = qFrequency => {
22773
- const freqStr = String(qFrequency);
22774
- const isPercent = freqStr.substring(freqStr.length - 1) === '%';
22775
- const freq = parseFloat(isPercent ? freqStr : qFrequency);
22776
- const rightSlice = checkboxes ? "(".concat(barWithCheckboxLeftPadPx, "px + ").concat(barPadPx + barBorderWidthPx * 2, "px)") : "".concat(barPadPx * 2 + barBorderWidthPx * 2, "px");
22777
- const width = isPercent ? freq : freq / frequencyMax * 100;
22778
- return "calc(".concat(width, "% - ").concat(rightSlice, ")");
22779
- };
22780
22914
  const isFirstElement = index === 0;
22781
22915
  const flexBasisVal = checkboxes ? 'auto' : 'max-content';
22782
- return /*#__PURE__*/React.createElement(Root$1, {
22783
- className: classes$a.barContainer,
22916
+ return /*#__PURE__*/React.createElement(RowColRoot, {
22917
+ className: rowColClasses.barContainer,
22784
22918
  flexBasisProp: flexBasisVal,
22785
22919
  style: styles,
22786
22920
  isGridCol: isGridCol,
@@ -22795,7 +22929,7 @@
22795
22929
  gap: 0,
22796
22930
  className: joinClassNames(['value', ...classArr]),
22797
22931
  classes: {
22798
- root: classes$a.fieldRoot
22932
+ root: rowColClasses.fieldRoot
22799
22933
  },
22800
22934
  onClick: onClick,
22801
22935
  onMouseDown: onMouseDown,
@@ -22806,36 +22940,49 @@
22806
22940
  role: column ? 'column' : 'row',
22807
22941
  tabIndex: isFirstElement && (!keyboard.enabled || keyboard.active) ? 0 : -1,
22808
22942
  "data-n": cell && cell.qElemNumber
22809
- }, hasHistogramBar() && /*#__PURE__*/React.createElement("div", {
22810
- className: joinClassNames([classes$a.bar, checkboxes && classes$a.barWithCheckbox, isSelected && (checkboxes ? classes$a.barSelectedWithCheckbox : classes$a.barSelected)]),
22811
- style: {
22812
- width: getBarWidth(cell.qFrequency)
22813
- }
22943
+ }, /*#__PURE__*/React.createElement(Histogram, {
22944
+ cell: cell,
22945
+ histogram: histogram,
22946
+ checkboxes: checkboxes,
22947
+ isSelected: isSelected,
22948
+ frequencyMax: frequencyMax
22814
22949
  }), /*#__PURE__*/React.createElement(Grid$1, {
22815
22950
  item: true,
22816
22951
  style: cellStyle,
22817
- className: joinClassNames([classes$a.cell, classes$a.selectedCell]),
22952
+ className: joinClassNames([rowColClasses.cell, rowColClasses.selectedCell]),
22818
22953
  title: "".concat(label)
22819
- }, ranges.length === 0 ? getField({
22820
- lbl: label,
22821
- color: 'inherit'
22822
- }) : getFieldWithRanges({
22823
- lbls: labels
22824
- })), freqIsAllowed && /*#__PURE__*/React.createElement(Grid$1, {
22825
- item: true,
22826
- style: {
22827
- display: 'flex',
22828
- alignItems: 'center'
22829
- },
22830
- className: classes$a.frequencyCount
22831
- }, /*#__PURE__*/React.createElement(Typography$1, {
22832
- noWrap: true,
22954
+ }, ranges.length === 0 ? /*#__PURE__*/React.createElement(Field, {
22955
+ label: label,
22833
22956
  color: "inherit",
22834
- variant: "body2",
22835
- className: joinClassNames([dense && classes$a.labelDense, classes$a.labelText, showGray && excludedOrAlternative() && classes$a.excludedTextWithCheckbox])
22836
- }, getFrequencyText())), !checkboxes && /*#__PURE__*/React.createElement(Grid$1, {
22957
+ qElemNumber: cell.qElemNumber,
22958
+ isSelected: isSelected,
22959
+ dense: dense,
22960
+ cell: cell,
22961
+ isGridCol: isGridCol,
22962
+ showGray: showGray,
22963
+ isSingleSelect: isSingleSelect,
22964
+ checkboxes: checkboxes
22965
+ }) : /*#__PURE__*/React.createElement(FieldWithRanges, {
22966
+ labels: labels,
22967
+ checkboxes: checkboxes,
22968
+ dense: dense,
22969
+ showGray: showGray,
22970
+ color: "inherit" // TODO: Check this
22971
+ ,
22972
+ qElemNumber: cell.qElemNumber,
22973
+ isSelected: isSelected,
22974
+ cell: cell,
22975
+ isGridCol: isGridCol,
22976
+ isSingleSelect: isSingleSelect,
22977
+ valueTextAlign: valueTextAlign
22978
+ })), freqIsAllowed && /*#__PURE__*/React.createElement(Frequency, {
22979
+ cell: cell,
22980
+ checkboxes: checkboxes,
22981
+ dense: dense,
22982
+ showGray: showGray
22983
+ }), !checkboxes && /*#__PURE__*/React.createElement(Grid$1, {
22837
22984
  item: true,
22838
- className: classes$a.icon
22985
+ className: rowColClasses.icon
22839
22986
  }, !showLock && !showTick && /*#__PURE__*/React.createElement("span", {
22840
22987
  style: {
22841
22988
  minWidth: '12px'
@@ -25039,6 +25186,7 @@
25039
25186
  var _layout$qListObject$q, _loaderRef$current, _loaderRef$current$_l, _loaderRef$current$_l2;
25040
25187
  let {
25041
25188
  model,
25189
+ layout,
25042
25190
  selections,
25043
25191
  direction,
25044
25192
  checkboxes: checkboxOption,
@@ -25063,7 +25211,6 @@
25063
25211
  }
25064
25212
  } = _ref;
25065
25213
  const [initScrollPosIsSet, setInitScrollPosIsSet] = reactExports.useState(false);
25066
- const [layout] = useLayout$1(model);
25067
25214
  const isSingleSelect = !!(layout && layout.qListObject.qDimensionInfo.qIsOneAndOnlyOne);
25068
25215
  const {
25069
25216
  checkboxes = checkboxOption,
@@ -26477,6 +26624,7 @@
26477
26624
  autoFocus: autoFocus !== null && autoFocus !== void 0 ? autoFocus : true
26478
26625
  }), /*#__PURE__*/React.createElement(ListBox, {
26479
26626
  model: model,
26627
+ layout: layout,
26480
26628
  selections: selections,
26481
26629
  direction: "ltr",
26482
26630
  onSetListCount: c => setListCount(c)
@@ -27107,6 +27255,52 @@
27107
27255
  });
27108
27256
  var SelectionsForward = (props => SvgIcon(selectionsForward(props)));
27109
27257
 
27258
+ const patchAlternateState = (currentSelectionsModel, currentSelectionsLayout, appLayout) => {
27259
+ const states = [...(appLayout.qStateNames || [])].map(s => ({
27260
+ stateName: s,
27261
+ // need this as reference in selection toolbar since qSelectionObject.qStateName is not in the layout
27262
+ qSelectionObjectDef: {
27263
+ qStateName: s
27264
+ }
27265
+ }));
27266
+ const existingStates = (currentSelectionsLayout && currentSelectionsLayout.alternateStates ? currentSelectionsLayout.alternateStates.map(s => s.stateName) : []).join('::');
27267
+ const newStates = (appLayout.qStateNames || []).map(s => s).join('::');
27268
+ if (existingStates !== newStates) {
27269
+ currentSelectionsModel.applyPatches([{
27270
+ qOp: 'replace',
27271
+ qPath: '/alternateStates',
27272
+ qValue: JSON.stringify(states)
27273
+ }], true);
27274
+ }
27275
+ };
27276
+ function useAppSelectionsNavigation(app) {
27277
+ const [currentSelectionsModel] = useCurrentSelectionsModel(app);
27278
+ const [currentSelectionsLayout] = useLayout$1(currentSelectionsModel);
27279
+ const [appLayout] = useAppLayout$1(app);
27280
+ const [navigationState, setNavigationState] = reactExports.useState(null);
27281
+ reactExports.useEffect(() => {
27282
+ if (!appLayout || !currentSelectionsModel || !currentSelectionsLayout) return;
27283
+ patchAlternateState(currentSelectionsModel, currentSelectionsLayout, appLayout);
27284
+ }, [appLayout, currentSelectionsModel, currentSelectionsLayout]);
27285
+ reactExports.useEffect(() => {
27286
+ if (!currentSelectionsLayout) return;
27287
+ let canGoBack = false;
27288
+ let canGoForward = false;
27289
+ let canClear = false;
27290
+ [currentSelectionsLayout, ...(currentSelectionsLayout.alternateStates || [])].forEach(state => {
27291
+ canGoBack = canGoBack || state.qSelectionObject && state.qSelectionObject.qBackCount > 0;
27292
+ canGoForward = canGoForward || state.qSelectionObject && state.qSelectionObject.qForwardCount > 0;
27293
+ canClear = canClear || (state.qSelectionObject && state.qSelectionObject.qSelections || []).filter(s => s.qLocked !== true).length > 0;
27294
+ });
27295
+ setNavigationState({
27296
+ canGoBack,
27297
+ canGoForward,
27298
+ canClear
27299
+ });
27300
+ }, [currentSelectionsLayout]);
27301
+ return [navigationState, currentSelectionsModel, currentSelectionsLayout];
27302
+ }
27303
+
27110
27304
  function Nav(_ref) {
27111
27305
  let {
27112
27306
  api,
@@ -27750,7 +27944,8 @@
27750
27944
  function ListBoxInline(_ref3) {
27751
27945
  var _layout$layoutOptions, _layout$layoutOptions2;
27752
27946
  let {
27753
- options = {}
27947
+ options,
27948
+ layout
27754
27949
  } = _ref3;
27755
27950
  const {
27756
27951
  app,
@@ -27800,7 +27995,6 @@
27800
27995
  const moreAlignTo = reactExports.useRef();
27801
27996
  const containerRef = reactExports.useRef();
27802
27997
  const [searchContainer, searchContainerRef] = useRefWithCallback();
27803
- const [layout] = useLayout$1(model);
27804
27998
  const [showToolbar, setShowToolbar] = reactExports.useState(false);
27805
27999
  const [showSearch, setShowSearch] = reactExports.useState(false);
27806
28000
  const [keyboardActive, setKeyboardActive] = reactExports.useState(false);
@@ -28025,6 +28219,7 @@
28025
28219
  } = _ref4;
28026
28220
  return /*#__PURE__*/React.createElement(ListBox, {
28027
28221
  model: model,
28222
+ layout: layout,
28028
28223
  selections: selections,
28029
28224
  direction: direction,
28030
28225
  listLayout: listLayout,
@@ -28056,6 +28251,20 @@
28056
28251
  });
28057
28252
  }))));
28058
28253
  }
28254
+ const ListBoxInlineMemoed = React.memo(ListBoxInline);
28255
+ function IsolateUseLayoutWrapper(_ref5) {
28256
+ let {
28257
+ options = {}
28258
+ } = _ref5;
28259
+ const {
28260
+ model
28261
+ } = options;
28262
+ const [layout] = useLayout$1(model);
28263
+ return /*#__PURE__*/React.createElement(ListBoxInlineMemoed, {
28264
+ options: options,
28265
+ layout: layout
28266
+ });
28267
+ }
28059
28268
 
28060
28269
  function useExistingModel(_ref) {
28061
28270
  let {
@@ -28318,15 +28527,15 @@
28318
28527
  });
28319
28528
  const elementRef = reactExports.useRef(element);
28320
28529
  const selections = hasExternalSelectionsApi ? options.selectionsApi : useObjectSelections(app, model, [elementRef, '.njs-action-toolbar-more'], options)[0];
28321
- if (!selections || !model) {
28322
- return null;
28323
- }
28324
- const opts = _objectSpread2(_objectSpread2({}, options), {}, {
28530
+ const opts = reactExports.useMemo(() => _objectSpread2(_objectSpread2({}, options), {}, {
28325
28531
  selections,
28326
28532
  model,
28327
28533
  app
28328
- });
28329
- return /*#__PURE__*/React.createElement(ListBoxInline, {
28534
+ }), [options, selections, model, app]);
28535
+ if (!selections || !model) {
28536
+ return null;
28537
+ }
28538
+ return /*#__PURE__*/React.createElement(IsolateUseLayoutWrapper, {
28330
28539
  options: opts
28331
28540
  });
28332
28541
  }