@nebula.js/stardust 4.9.0 → 5.0.0-alpha.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 v4.9.0
2
+ * @nebula.js/stardust v5.0.0-alpha.0
3
3
  * Copyright (c) 2023 QlikTech International AB
4
4
  * Released under the MIT license.
5
5
  */
@@ -722,26 +722,26 @@
722
722
  }
723
723
  })(runtime);
724
724
 
725
- function ownKeys(e, r) {
726
- var t = Object.keys(e);
725
+ function ownKeys(object, enumerableOnly) {
726
+ var keys = Object.keys(object);
727
727
  if (Object.getOwnPropertySymbols) {
728
- var o = Object.getOwnPropertySymbols(e);
729
- r && (o = o.filter(function (r) {
730
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
731
- })), t.push.apply(t, o);
732
- }
733
- return t;
734
- }
735
- function _objectSpread2(e) {
736
- for (var r = 1; r < arguments.length; r++) {
737
- var t = null != arguments[r] ? arguments[r] : {};
738
- r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
739
- _defineProperty(e, r, t[r]);
740
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
741
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
728
+ var symbols = Object.getOwnPropertySymbols(object);
729
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
730
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
731
+ })), keys.push.apply(keys, symbols);
732
+ }
733
+ return keys;
734
+ }
735
+ function _objectSpread2(target) {
736
+ for (var i = 1; i < arguments.length; i++) {
737
+ var source = null != arguments[i] ? arguments[i] : {};
738
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
739
+ _defineProperty(target, key, source[key]);
740
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
741
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
742
742
  });
743
743
  }
744
- return e;
744
+ return target;
745
745
  }
746
746
  function _defineProperty(obj, key, value) {
747
747
  key = _toPropertyKey(key);
@@ -3241,15 +3241,14 @@
3241
3241
  },
3242
3242
  dataColors() {
3243
3243
  /** @interface Theme~DataColorSpecials */
3244
- return (/** @lends Theme~DataColorSpecials */{
3245
- /** @type {string} */
3246
- primary: resolvedTheme.dataColors.primaryColor,
3247
- /** @type {string} */
3248
- nil: resolvedTheme.dataColors.nullColor,
3249
- /** @type {string} */
3250
- others: resolvedTheme.dataColors.othersColor
3251
- }
3252
- );
3244
+ return /** @lends Theme~DataColorSpecials */{
3245
+ /** @type {string} */
3246
+ primary: resolvedTheme.dataColors.primaryColor,
3247
+ /** @type {string} */
3248
+ nil: resolvedTheme.dataColors.nullColor,
3249
+ /** @type {string} */
3250
+ others: resolvedTheme.dataColors.othersColor
3251
+ };
3253
3252
  },
3254
3253
  uiColor(c, shift) {
3255
3254
  // eslint-disable-next-line no-param-reassign
@@ -3575,7 +3574,6 @@
3575
3574
  }
3576
3575
  });
3577
3576
  }
3578
-
3579
3577
  styleResolver.resolveRawTheme = raw => {
3580
3578
  // TODO - validate format
3581
3579
  const c = extend$2(true, {}, raw);
@@ -6952,7 +6950,7 @@
6952
6950
  }
6953
6951
 
6954
6952
  /**
6955
- * @mui/styled-engine v5.14.18
6953
+ * @mui/styled-engine v5.14.19
6956
6954
  *
6957
6955
  * @license MIT
6958
6956
  * This source code is licensed under the MIT license found in the
@@ -7463,51 +7461,25 @@
7463
7461
  }
7464
7462
  return `${value}px solid`;
7465
7463
  }
7466
- const border = style$2({
7467
- prop: 'border',
7468
- themeKey: 'borders',
7469
- transform: borderTransform
7470
- });
7471
- const borderTop = style$2({
7472
- prop: 'borderTop',
7473
- themeKey: 'borders',
7474
- transform: borderTransform
7475
- });
7476
- const borderRight = style$2({
7477
- prop: 'borderRight',
7478
- themeKey: 'borders',
7479
- transform: borderTransform
7480
- });
7481
- const borderBottom = style$2({
7482
- prop: 'borderBottom',
7483
- themeKey: 'borders',
7484
- transform: borderTransform
7485
- });
7486
- const borderLeft = style$2({
7487
- prop: 'borderLeft',
7488
- themeKey: 'borders',
7489
- transform: borderTransform
7490
- });
7491
- const borderColor = style$2({
7492
- prop: 'borderColor',
7493
- themeKey: 'palette'
7494
- });
7495
- const borderTopColor = style$2({
7496
- prop: 'borderTopColor',
7497
- themeKey: 'palette'
7498
- });
7499
- const borderRightColor = style$2({
7500
- prop: 'borderRightColor',
7501
- themeKey: 'palette'
7502
- });
7503
- const borderBottomColor = style$2({
7504
- prop: 'borderBottomColor',
7505
- themeKey: 'palette'
7506
- });
7507
- const borderLeftColor = style$2({
7508
- prop: 'borderLeftColor',
7509
- themeKey: 'palette'
7510
- });
7464
+ function createBorderStyle(prop, transform) {
7465
+ return style$2({
7466
+ prop,
7467
+ themeKey: 'borders',
7468
+ transform
7469
+ });
7470
+ }
7471
+ const border = createBorderStyle('border', borderTransform);
7472
+ const borderTop = createBorderStyle('borderTop', borderTransform);
7473
+ const borderRight = createBorderStyle('borderRight', borderTransform);
7474
+ const borderBottom = createBorderStyle('borderBottom', borderTransform);
7475
+ const borderLeft = createBorderStyle('borderLeft', borderTransform);
7476
+ const borderColor = createBorderStyle('borderColor');
7477
+ const borderTopColor = createBorderStyle('borderTopColor');
7478
+ const borderRightColor = createBorderStyle('borderRightColor');
7479
+ const borderBottomColor = createBorderStyle('borderBottomColor');
7480
+ const borderLeftColor = createBorderStyle('borderLeftColor');
7481
+ const outline = createBorderStyle('outline', borderTransform);
7482
+ const outlineColor = createBorderStyle('outlineColor');
7511
7483
 
7512
7484
  // false positive
7513
7485
  // eslint-disable-next-line react/function-component-definition
@@ -7523,7 +7495,7 @@
7523
7495
  };
7524
7496
  borderRadius$1.propTypes = {};
7525
7497
  borderRadius$1.filterProps = ['borderRadius'];
7526
- compose(border, borderTop, borderRight, borderBottom, borderLeft, borderColor, borderTopColor, borderRightColor, borderBottomColor, borderLeftColor, borderRadius$1);
7498
+ compose(border, borderTop, borderRight, borderBottom, borderLeft, borderColor, borderTopColor, borderRightColor, borderBottomColor, borderLeftColor, borderRadius$1, outline, outlineColor);
7527
7499
 
7528
7500
  // false positive
7529
7501
  // eslint-disable-next-line react/function-component-definition
@@ -7721,6 +7693,13 @@
7721
7693
  borderLeftColor: {
7722
7694
  themeKey: 'palette'
7723
7695
  },
7696
+ outline: {
7697
+ themeKey: 'borders',
7698
+ transform: borderTransform
7699
+ },
7700
+ outlineColor: {
7701
+ themeKey: 'palette'
7702
+ },
7724
7703
  borderRadius: {
7725
7704
  themeKey: 'shape.borderRadius',
7726
7705
  style: borderRadius$1
@@ -11820,7 +11799,7 @@
11820
11799
  return cache[key];
11821
11800
  }
11822
11801
 
11823
- const NEBULA_VERSION_HASH = "8934" ;
11802
+ const NEBULA_VERSION_HASH = "117f" ;
11824
11803
  ClassNameGenerator$1.configure(componentName => {
11825
11804
  return "njs-".concat(NEBULA_VERSION_HASH, "-").concat(componentName.replace('Mui', ''));
11826
11805
  });
@@ -11831,9 +11810,49 @@
11831
11810
  translator: null,
11832
11811
  constraints: {},
11833
11812
  interactions: {},
11834
- themeApi: null
11813
+ themeApi: null,
11814
+ modelStore: {},
11815
+ selectionStore: {}
11835
11816
  });
11836
11817
 
11818
+ const DEFAULT_INTERACTIONS = {
11819
+ active: true,
11820
+ select: true,
11821
+ passive: true,
11822
+ edit: false
11823
+ };
11824
+ function pickConstraintsOrInteractions(context) {
11825
+ const {
11826
+ constraints = {},
11827
+ interactions = {}
11828
+ } = context;
11829
+ // If some interaction is defined, then we use that
11830
+ if (Object.keys(interactions).length > 0) {
11831
+ return interactions;
11832
+ }
11833
+ const ret = {};
11834
+ Object.keys(constraints).forEach(state => {
11835
+ ret[state] = !constraints[state];
11836
+ });
11837
+ return ret;
11838
+ }
11839
+ function unifyContraintsAndInteractions(context) {
11840
+ const interactions = {};
11841
+ const constraints = {};
11842
+ const definedSettings = pickConstraintsOrInteractions(context);
11843
+ Object.keys(DEFAULT_INTERACTIONS).forEach(state => {
11844
+ if (definedSettings[state] !== undefined) {
11845
+ interactions[state] = definedSettings[state];
11846
+ constraints[state] = !definedSettings[state];
11847
+ } else {
11848
+ interactions[state] = DEFAULT_INTERACTIONS[state];
11849
+ constraints[state] = !DEFAULT_INTERACTIONS[state];
11850
+ }
11851
+ });
11852
+ context.constraints = constraints;
11853
+ context.interactions = interactions;
11854
+ }
11855
+
11837
11856
  var createKeyStore = (function () {
11838
11857
  let initialState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
11839
11858
  let applyMiddleware = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : () => {};
@@ -11876,169 +11895,97 @@
11876
11895
  return [useKeyStore, store];
11877
11896
  });
11878
11897
 
11879
- const [useAppSelectionsStore, appSelectionsStore] = createKeyStore({});
11880
- const [useAppModalStore, appModalStore] = createKeyStore({});
11881
- const [useModalObjectStore, modalObjectStore] = createKeyStore({});
11882
-
11883
- /* eslint no-underscore-dangle: 0 */
11884
- function createAppSelections(_ref) {
11885
- let {
11886
- app
11887
- } = _ref;
11888
- const key = "".concat(app.id);
11889
- const end = async function () {
11890
- let accept = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
11891
- const {
11892
- model,
11893
- objectSelections
11894
- } = modalObjectStore.get(key) || {};
11895
- if (model) {
11896
- await model.endSelections(accept);
11897
- modalObjectStore.clear(key);
11898
- objectSelections.emit('deactivated');
11899
- }
11900
- };
11901
- const begin = async _ref2 => {
11902
- var _modalObjectStore$get;
11898
+ function initializeStores$1(appId) {
11899
+ const [useRpcResultStore, rpcResultStore] = createKeyStore({});
11900
+ const [useRpcRequestStore, rpcRequestStore] = createKeyStore({});
11901
+ const [useRpcRequestSessionModelStore, rpcRequestSessionModelStore] = createKeyStore({});
11902
+ const [useRpcRequestModelStore, rpcRequestModelStore] = createKeyStore({});
11903
+ const [useModelChangedStore, modelChangedStore] = createKeyStore({});
11904
+ const [, modelInitializedStore] = createKeyStore({});
11905
+ const modelStoreMiddleware = _ref => {
11903
11906
  let {
11904
- model,
11905
- paths,
11906
- accept = true,
11907
- objectSelections
11908
- } = _ref2;
11909
- // Quick return if it's already in modal
11910
- if (objectSelections === ((_modalObjectStore$get = modalObjectStore.get(key)) === null || _modalObjectStore$get === void 0 ? void 0 : _modalObjectStore$get.objectSelections)) {
11911
- return;
11907
+ type,
11908
+ value: model
11909
+ } = _ref;
11910
+ const initialized = modelInitializedStore.get(model.id);
11911
+ modelInitializedStore.set(model.id, {});
11912
+ const onChanged = () => {
11913
+ rpcRequestStore.clear(model.id);
11914
+ modelChangedStore.set(model.id, {});
11915
+ modelChangedStore.dispatch(true); // Force new state to trigger hooks
11916
+ };
11917
+ const unsubscribe = () => {
11918
+ model.removeListener('changed', onChanged);
11919
+ rpcResultStore.clear(model.id);
11920
+ rpcRequestStore.clear(model.id);
11921
+ rpcRequestSessionModelStore.clear(model.id);
11922
+ rpcRequestModelStore.clear(model.id);
11923
+ modelChangedStore.clear(model.id);
11924
+ modelInitializedStore.clear(model.id);
11925
+ };
11926
+ switch (type) {
11927
+ case 'SET':
11928
+ if (!initialized) {
11929
+ model.on('changed', onChanged);
11930
+ model.once('closed', () => {
11931
+ unsubscribe();
11932
+ });
11933
+ }
11934
+ break;
11912
11935
  }
11913
-
11914
- // If other model is in modal state end it
11915
- end(accept);
11916
-
11917
- // Pending modal
11918
- modalObjectStore.set(key, {
11919
- model,
11920
- objectSelections
11936
+ return unsubscribe;
11937
+ };
11938
+ const [useModelStore, modelStore] = createKeyStore({}, modelStoreMiddleware);
11939
+ const subscribe = model => {
11940
+ const unsubscribe = modelStoreMiddleware({
11941
+ type: 'SET',
11942
+ value: model
11921
11943
  });
11922
- const p = Array.isArray(paths) ? paths : [paths];
11923
- const beginSelections = async skipRetry => {
11924
- try {
11925
- await model.beginSelections(p);
11926
- modalObjectStore.set(key, {
11927
- model,
11928
- objectSelections
11929
- }); // We have a modal
11930
- } catch (err) {
11931
- if (err.code === 6003 && !skipRetry) {
11932
- await app.abortModal(accept);
11933
- beginSelections(true);
11934
- } else {
11935
- modalObjectStore.clear(key); // No modal
11936
- }
11937
- }
11944
+ return () => {
11945
+ unsubscribe();
11946
+ modelStore.clear(model.id);
11938
11947
  };
11939
-
11940
- await beginSelections();
11941
11948
  };
11942
- const appModal = {
11943
- begin,
11944
- end
11945
- };
11946
- appModalStore.set(key, appModal);
11947
-
11948
- /**
11949
- * @class
11950
- * @alias AppSelections
11951
- */
11952
- const appSelections = {
11953
- model: app,
11954
- isInModal() {
11955
- return !!modalObjectStore.get(key);
11956
- },
11957
- isModal(objectSelections) {
11958
- var _modalObjectStore$get2;
11959
- // TODO check model state
11960
- return objectSelections ? ((_modalObjectStore$get2 = modalObjectStore.get(key)) === null || _modalObjectStore$get2 === void 0 ? void 0 : _modalObjectStore$get2.objectSelections) === objectSelections : !!modalObjectStore.get(key);
11961
- },
11962
- forward() {
11963
- return appModal.end().then(() => app.forward());
11964
- },
11965
- back() {
11966
- return appModal.end().then(() => app.back());
11967
- },
11968
- clear() {
11969
- return appModal.end().then(() => app.clearAll());
11970
- },
11971
- clearField(field) {
11972
- let state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '$';
11973
- return appModal.end().then(() => app.getField(field, state).then(f => f.clear()));
11974
- }
11949
+ return {
11950
+ subscribe,
11951
+ useModelStore,
11952
+ modelStore,
11953
+ useModelChangedStore,
11954
+ useRpcResultStore,
11955
+ rpcResultStore,
11956
+ useRpcRequestStore,
11957
+ rpcRequestStore,
11958
+ useRpcRequestModelStore,
11959
+ rpcRequestModelStore,
11960
+ useRpcRequestSessionModelStore,
11961
+ rpcRequestSessionModelStore,
11962
+ modelChangedStore,
11963
+ appId
11975
11964
  };
11976
- return appSelections;
11977
- }
11978
- function useAppSelections(app) {
11979
- if (!app.session) {
11980
- // assume the app is mocked if session is undefined
11981
- return [];
11982
- }
11983
- const [appSelectionsStore] = useAppSelectionsStore();
11984
- const key = app ? app.id : null;
11985
- let appSelections = appSelectionsStore.get(key);
11986
- reactExports.useEffect(() => {
11987
- if (!app || appSelections) return;
11988
- appSelections = createAppSelections({
11989
- app
11990
- });
11991
- appSelectionsStore.set(key, appSelections);
11992
- appSelectionsStore.dispatch(true);
11993
- }, [app]);
11994
- return [appSelections];
11995
11965
  }
11996
11966
 
11997
- const DEFAULT_INTERACTIONS = {
11998
- active: true,
11999
- select: true,
12000
- passive: true,
12001
- edit: false
12002
- };
12003
- function pickConstraintsOrInteractions(context) {
12004
- const {
12005
- constraints = {},
12006
- interactions = {}
12007
- } = context;
12008
- // If some interaction is defined, then we use that
12009
- if (Object.keys(interactions).length > 0) {
12010
- return interactions;
12011
- }
12012
- const ret = {};
12013
- Object.keys(constraints).forEach(state => {
12014
- ret[state] = !constraints[state];
12015
- });
12016
- return ret;
12017
- }
12018
- function unifyContraintsAndInteractions(context) {
12019
- const interactions = {};
12020
- const constraints = {};
12021
- const definedSettings = pickConstraintsOrInteractions(context);
12022
- Object.keys(DEFAULT_INTERACTIONS).forEach(state => {
12023
- if (definedSettings[state] !== undefined) {
12024
- interactions[state] = definedSettings[state];
12025
- constraints[state] = !definedSettings[state];
12026
- } else {
12027
- interactions[state] = DEFAULT_INTERACTIONS[state];
12028
- constraints[state] = !DEFAULT_INTERACTIONS[state];
12029
- }
12030
- });
12031
- context.constraints = constraints;
12032
- context.interactions = interactions;
11967
+ function initializeStores(appId) {
11968
+ const [useAppSelectionsStore, appSelectionsStore] = createKeyStore({});
11969
+ const [useAppModalStore, appModalStore] = createKeyStore({});
11970
+ const [useModalObjectStore, modalObjectStore] = createKeyStore({});
11971
+ return {
11972
+ useAppSelectionsStore,
11973
+ useAppModalStore,
11974
+ appSelectionsStore,
11975
+ appModalStore,
11976
+ useModalObjectStore,
11977
+ modalObjectStore,
11978
+ appId
11979
+ };
12033
11980
  }
12034
11981
 
12035
11982
  const NebulaApp = reactExports.forwardRef((_ref, ref) => {
12036
11983
  let {
12037
11984
  initialContext,
12038
- app,
12039
- renderCallback
11985
+ renderCallback,
11986
+ modelStore,
11987
+ selectionStore
12040
11988
  } = _ref;
12041
- const [appSelections] = useAppSelections(app);
12042
11989
  const [context, setContext] = reactExports.useState(initialContext);
12043
11990
  const [muiThemeName, setMuiThemeName] = reactExports.useState();
12044
11991
  const {
@@ -12058,9 +12005,12 @@
12058
12005
  setComponents([...comps]);
12059
12006
  },
12060
12007
  setMuiThemeName,
12061
- setContext: ctx => setContext(oldContext => JSON.stringify(oldContext) !== JSON.stringify(ctx) ? ctx : oldContext),
12062
- getAppSelections: () => appSelections
12008
+ setContext: ctx => setContext(oldContext => JSON.stringify(oldContext) !== JSON.stringify(ctx) ? ctx : oldContext)
12063
12009
  }), []);
12010
+ if (context) {
12011
+ context.modelStore = modelStore;
12012
+ context.selectionStore = selectionStore;
12013
+ }
12064
12014
  return /*#__PURE__*/React.createElement(StyledEngineProvider, {
12065
12015
  injectFirst: true
12066
12016
  }, /*#__PURE__*/React.createElement(ThemeProvider, {
@@ -12081,18 +12031,21 @@
12081
12031
  const appRef = React.createRef();
12082
12032
  const element = document.createElement('div');
12083
12033
  element.style.display = 'none';
12084
- element.setAttribute('data-nebulajs-version', "4.9.0" );
12034
+ element.setAttribute('data-nebulajs-version', "5.0.0-alpha.0" );
12085
12035
  element.setAttribute('data-app-id', app.id);
12086
12036
  document.body.appendChild(element);
12087
12037
  if (context) {
12088
12038
  unifyContraintsAndInteractions(context);
12089
12039
  }
12040
+ const modelStore = initializeStores$1(app.id);
12041
+ const selectionStore = initializeStores(app.id);
12090
12042
  const root = client.createRoot(element);
12091
12043
  root.render( /*#__PURE__*/React.createElement(NebulaApp, {
12092
12044
  ref: appRef,
12093
- app: app,
12094
12045
  initialContext: context,
12095
- renderCallback: resolveRender
12046
+ renderCallback: resolveRender,
12047
+ modelStore: modelStore,
12048
+ selectionStore: selectionStore
12096
12049
  }));
12097
12050
  const cells = {};
12098
12051
  const components = [];
@@ -12141,12 +12094,8 @@
12141
12094
  }
12142
12095
  appRef.current.setContext(ctx);
12143
12096
  })();
12144
- },
12145
- getAppSelections: async () => {
12146
- await rendered;
12147
- return appRef.current.getAppSelections();
12148
12097
  }
12149
- }, appRef, rendered];
12098
+ }, modelStore, selectionStore, appRef, rendered];
12150
12099
  }
12151
12100
 
12152
12101
  function getSvgIconUtilityClass(slot) {
@@ -16888,11 +16837,14 @@
16888
16837
  });
16889
16838
  var Badge$1 = Badge;
16890
16839
 
16840
+ const boxClasses = generateUtilityClasses('MuiBox', ['root']);
16841
+ var boxClasses$1 = boxClasses;
16842
+
16891
16843
  const defaultTheme = createTheme();
16892
16844
  const Box = createBox({
16893
16845
  themeId: THEME_ID,
16894
16846
  defaultTheme,
16895
- defaultClassName: 'MuiBox-root',
16847
+ defaultClassName: boxClasses$1.root,
16896
16848
  generateClassName: ClassNameGenerator$1.generate
16897
16849
  });
16898
16850
  var Box$1 = Box;
@@ -18672,10 +18624,10 @@
18672
18624
  color: "text.secondary",
18673
18625
  children: children
18674
18626
  }) : /*#__PURE__*/jsxRuntimeExports.jsxs(reactExports.Fragment, {
18675
- children: [position === 'start' ? /* notranslate needed while Google Translate will not fix zero-width space issue */_span$1 || (_span$1 = /*#__PURE__*/jsxRuntimeExports.jsx("span", {
18627
+ children: [position === 'start' ? ( /* notranslate needed while Google Translate will not fix zero-width space issue */_span$1 || (_span$1 = /*#__PURE__*/jsxRuntimeExports.jsx("span", {
18676
18628
  className: "notranslate",
18677
18629
  children: "\u200B"
18678
- })) : null, children]
18630
+ }))) : null, children]
18679
18631
  })
18680
18632
  }))
18681
18633
  });
@@ -20849,57 +20801,36 @@
20849
20801
  });
20850
20802
  var Tooltip$1 = Tooltip;
20851
20803
 
20852
- const [useRpcResultStore, rpcResultStore] = createKeyStore({});
20853
- const [useRpcRequestStore, rpcRequestStore] = createKeyStore({});
20854
- const [useRpcRequestSessionModelStore, rpcRequestSessionModelStore] = createKeyStore({});
20855
- const [useRpcRequestModelStore, rpcRequestModelStore] = createKeyStore({});
20856
- const [useModelChangedStore, modelChangedStore] = createKeyStore({});
20857
- const [, modelInitializedStore] = createKeyStore({});
20858
- const modelStoreMiddleware = _ref => {
20859
- let {
20860
- type,
20861
- value: model
20862
- } = _ref;
20863
- const initialized = modelInitializedStore.get(model.id);
20864
- modelInitializedStore.set(model.id, {});
20865
- const onChanged = () => {
20866
- rpcRequestStore.clear(model.id);
20867
- modelChangedStore.set(model.id, {});
20868
- modelChangedStore.dispatch(true); // Force new state to trigger hooks
20869
- };
20870
-
20871
- const unsubscribe = () => {
20872
- model.removeListener('changed', onChanged);
20873
- rpcResultStore.clear(model.id);
20874
- rpcRequestStore.clear(model.id);
20875
- rpcRequestSessionModelStore.clear(model.id);
20876
- rpcRequestModelStore.clear(model.id);
20877
- modelChangedStore.clear(model.id);
20878
- modelInitializedStore.clear(model.id);
20879
- };
20880
- switch (type) {
20881
- case 'SET':
20882
- if (!initialized) {
20883
- model.on('changed', onChanged);
20884
- model.once('closed', () => {
20885
- unsubscribe();
20886
- });
20887
- }
20888
- break;
20889
- }
20890
- return unsubscribe;
20891
- };
20892
- const [useModelStore, modelStore] = createKeyStore({}, modelStoreMiddleware);
20893
- const subscribe = model => {
20894
- const unsubscribe = modelStoreMiddleware({
20895
- type: 'SET',
20896
- value: model
20897
- });
20898
- return () => {
20899
- unsubscribe();
20900
- modelStore.clear(model.id);
20901
- };
20902
- };
20804
+ function useModelStore() {
20805
+ const {
20806
+ useModelStore: useFunc
20807
+ } = reactExports.useContext(InstanceContext).modelStore;
20808
+ return useFunc();
20809
+ }
20810
+ function useModelChangedStore() {
20811
+ const {
20812
+ useModelChangedStore: useFunc
20813
+ } = reactExports.useContext(InstanceContext).modelStore;
20814
+ return useFunc();
20815
+ }
20816
+ function useRpcResultStore() {
20817
+ const {
20818
+ useRpcResultStore: useFunc
20819
+ } = reactExports.useContext(InstanceContext).modelStore;
20820
+ return useFunc();
20821
+ }
20822
+ function useRpcRequestStore() {
20823
+ const {
20824
+ useRpcRequestStore: useFunc
20825
+ } = reactExports.useContext(InstanceContext).modelStore;
20826
+ return useFunc();
20827
+ }
20828
+ function useRpcRequestSessionModelStore() {
20829
+ const {
20830
+ useRpcRequestSessionModelStore: useFunc
20831
+ } = reactExports.useContext(InstanceContext).modelStore;
20832
+ return useFunc();
20833
+ }
20903
20834
 
20904
20835
  function useSessionModel(definition, app) {
20905
20836
  const key = app ? "".concat(app.id, "/").concat(JSON.stringify(definition)) : null;
@@ -22027,7 +21958,6 @@
22027
21958
  if (frequencyMode === 'P') {
22028
21959
  return sizes.freqMinWidth; // because it will never grow beyond "100.0%"
22029
21960
  }
22030
-
22031
21961
  return sizes.freqMaxWidth;
22032
21962
  };
22033
21963
  const getSelectedStyle = _ref3 => {
@@ -23034,7 +22964,6 @@
23034
22964
  } else {
23035
22965
  return; // propagate to other Esc handler
23036
22966
  }
23037
-
23038
22967
  break;
23039
22968
  case KEYS.HOME:
23040
22969
  focusListItems.setFirst(true);
@@ -23068,7 +22997,6 @@
23068
22997
  return;
23069
22998
  // don't stop propagation since we want to outsource keydown to other handlers.
23070
22999
  }
23071
-
23072
23000
  if (elementToFocus) {
23073
23001
  elementToFocus.focus();
23074
23002
  }
@@ -23234,7 +23162,6 @@
23234
23162
  if (!cell) {
23235
23163
  return null; // prevent rendering empty rows
23236
23164
  }
23237
-
23238
23165
  const isGridCol = dataLayout === 'grid' && layoutOrder === 'column';
23239
23166
  const label = (_cell$qText = cell === null || cell === void 0 ? void 0 : cell.qText) !== null && _cell$qText !== void 0 ? _cell$qText : '';
23240
23167
  // Search highlights. Split up labelText span into several and add the highlighted class to matching sub-strings.
@@ -25977,7 +25904,6 @@
25977
25904
  if (s.scrollPosition === 'overflowEnd') {
25978
25905
  return; // Do keyScroll.reset() in fetchData() to avoid scrolling to top.
25979
25906
  }
25980
-
25981
25907
  keyScroll.reset();
25982
25908
  }, [keyScroll.state.up, keyScroll.state.down, keyScroll.state.scrollPosition]);
25983
25909
  const {
@@ -26956,6 +26882,128 @@
26956
26882
  });
26957
26883
  }
26958
26884
 
26885
+ /* eslint no-underscore-dangle: 0 */
26886
+ function createAppSelections(_ref) {
26887
+ let {
26888
+ app,
26889
+ selectionStore
26890
+ } = _ref;
26891
+ const key = "".concat(app.id);
26892
+ const {
26893
+ modalObjectStore,
26894
+ appModalStore
26895
+ } = selectionStore;
26896
+ const end = async function () {
26897
+ let accept = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
26898
+ const {
26899
+ model,
26900
+ objectSelections
26901
+ } = modalObjectStore.get(key) || {};
26902
+ if (model) {
26903
+ await model.endSelections(accept);
26904
+ modalObjectStore.clear(key);
26905
+ objectSelections.emit('deactivated');
26906
+ }
26907
+ };
26908
+ const begin = async _ref2 => {
26909
+ var _modalObjectStore$get;
26910
+ let {
26911
+ model,
26912
+ paths,
26913
+ accept = true,
26914
+ objectSelections
26915
+ } = _ref2;
26916
+ // Quick return if it's already in modal
26917
+ if (objectSelections === ((_modalObjectStore$get = modalObjectStore.get(key)) === null || _modalObjectStore$get === void 0 ? void 0 : _modalObjectStore$get.objectSelections)) {
26918
+ return;
26919
+ }
26920
+
26921
+ // If other model is in modal state end it
26922
+ end(accept);
26923
+
26924
+ // Pending modal
26925
+ modalObjectStore.set(key, {
26926
+ model,
26927
+ objectSelections
26928
+ });
26929
+ const p = Array.isArray(paths) ? paths : [paths];
26930
+ const beginSelections = async skipRetry => {
26931
+ try {
26932
+ await model.beginSelections(p);
26933
+ modalObjectStore.set(key, {
26934
+ model,
26935
+ objectSelections
26936
+ }); // We have a modal
26937
+ } catch (err) {
26938
+ if (err.code === 6003 && !skipRetry) {
26939
+ await app.abortModal(accept);
26940
+ beginSelections(true);
26941
+ } else {
26942
+ modalObjectStore.clear(key); // No modal
26943
+ }
26944
+ }
26945
+ };
26946
+ await beginSelections();
26947
+ };
26948
+ const appModal = {
26949
+ begin,
26950
+ end
26951
+ };
26952
+ appModalStore.set(key, appModal);
26953
+
26954
+ /**
26955
+ * @class
26956
+ * @alias AppSelections
26957
+ */
26958
+ const appSelections = {
26959
+ model: app,
26960
+ isInModal() {
26961
+ return !!modalObjectStore.get(key);
26962
+ },
26963
+ isModal(objectSelections) {
26964
+ var _modalObjectStore$get2;
26965
+ // TODO check model state
26966
+ return objectSelections ? ((_modalObjectStore$get2 = modalObjectStore.get(key)) === null || _modalObjectStore$get2 === void 0 ? void 0 : _modalObjectStore$get2.objectSelections) === objectSelections : !!modalObjectStore.get(key);
26967
+ },
26968
+ forward() {
26969
+ return appModal.end().then(() => app.forward());
26970
+ },
26971
+ back() {
26972
+ return appModal.end().then(() => app.back());
26973
+ },
26974
+ clear() {
26975
+ return appModal.end().then(() => app.clearAll());
26976
+ },
26977
+ clearField(field) {
26978
+ let state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '$';
26979
+ return appModal.end().then(() => app.getField(field, state).then(f => f.clear()));
26980
+ }
26981
+ };
26982
+ return appSelections;
26983
+ }
26984
+ function useAppSelections(app) {
26985
+ if (!app.session) {
26986
+ // assume the app is mocked if session is undefined
26987
+ return [];
26988
+ }
26989
+ const {
26990
+ selectionStore
26991
+ } = reactExports.useContext(InstanceContext);
26992
+ const [appSelectionsStore] = selectionStore.useAppSelectionsStore();
26993
+ const key = app ? app.id : null;
26994
+ let appSelections = appSelectionsStore.get(key);
26995
+ reactExports.useEffect(() => {
26996
+ if (!app || appSelections) return;
26997
+ appSelections = createAppSelections({
26998
+ app,
26999
+ selectionStore
27000
+ });
27001
+ appSelectionsStore.set(key, appSelections);
27002
+ appSelectionsStore.dispatch(true);
27003
+ }, [app]);
27004
+ return [appSelections];
27005
+ }
27006
+
26959
27007
  function eventmixin (obj) {
26960
27008
  /* eslint no-param-reassign: 0 */
26961
27009
  Object.keys(EventEmitter$1.prototype).forEach(key => {
@@ -27199,7 +27247,9 @@
27199
27247
  const elementsArr = Array.isArray(elements) ? elements : [elements];
27200
27248
  const [appSelections] = useAppSelections(app);
27201
27249
  const [layout] = useLayout$1(model);
27202
- const [appModalStore] = useAppModalStore();
27250
+ const {
27251
+ appModalStore
27252
+ } = reactExports.useContext(InstanceContext).selectionStore;
27203
27253
  const appModal = appModalStore.get(app.id);
27204
27254
  const [objectSelections, setObjectSelections] = reactExports.useState();
27205
27255
  reactExports.useEffect(() => {
@@ -28546,7 +28596,6 @@
28546
28596
  this._lumi = 0.299 * this._r + 0.587 * this._g + 0.114 * this._b; // option 2
28547
28597
  // this._lumi = Math.sqrt( 0.241 * this._r * this._r + 0.691 * this._g * this._g + 0.068 * this._b * this._b ); // option 3
28548
28598
  }
28549
-
28550
28599
  return this._lumi;
28551
28600
  }
28552
28601
 
@@ -29599,7 +29648,6 @@
29599
29648
  segments.forEach((s, i) => {
29600
29649
  s.offset = i ? segments[i - 1].offset + segments[i - 1].ratio : 0; // eslint-disable-line
29601
29650
  });
29602
-
29603
29651
  let Header = null;
29604
29652
  let Icon = null;
29605
29653
  let SegmentsIndicator = null;
@@ -30052,7 +30100,9 @@
30052
30100
  items: [],
30053
30101
  more: []
30054
30102
  });
30055
- const [modalObjectStore] = useModalObjectStore();
30103
+ const {
30104
+ modalObjectStore
30105
+ } = reactExports.useContext(InstanceContext).selectionStore;
30056
30106
  const [containerRef, containerRect] = useRect$1();
30057
30107
  const [maxItems, setMaxItems] = reactExports.useState(0);
30058
30108
  const isInListboxPopover = () => {
@@ -30830,7 +30880,6 @@
30830
30880
  if (!event.target.classList.contains('listbox-container')) {
30831
30881
  break; // don't mess with keydown handlers within the listbox (e.g. row seletion)
30832
30882
  }
30833
-
30834
30883
  keyboard.focus();
30835
30884
  prevent();
30836
30885
  break;
@@ -31015,7 +31064,6 @@
31015
31064
  } else {
31016
31065
  containerPadding = undefined; // to prevent overriding any default padding
31017
31066
  }
31018
-
31019
31067
  return containerPadding;
31020
31068
  }
31021
31069
 
@@ -31087,7 +31135,6 @@
31087
31135
  paddingRight: '1px' // make place for italic font style
31088
31136
  });
31089
31137
  });
31090
-
31091
31138
  const isModal = _ref4 => {
31092
31139
  var _app$isInModalSelecti, _app$isInModalSelecti2;
31093
31140
  let {
@@ -31962,7 +32009,6 @@
31962
32009
  frequencyMode: getFrequencyModeLetter(options.frequencyMode) // stick to letter option hereafter
31963
32010
  });
31964
32011
  }
31965
-
31966
32012
  const [changeCount, setChangeCount] = reactExports.useState(0);
31967
32013
  reactExports.useEffect(() => {
31968
32014
  if (changeCount) {
@@ -32364,7 +32410,6 @@
32364
32410
  {
32365
32411
  console.warn('Attempting to add fields to an object without a specified data target'); // eslint-disable-line no-console
32366
32412
  }
32367
-
32368
32413
  return;
32369
32414
  }
32370
32415
  const {
@@ -32463,7 +32508,6 @@
32463
32508
  if (step === '') {
32464
32509
  continue; // eslint-disable-line no-continue
32465
32510
  }
32466
-
32467
32511
  if (dataContainer[step] === undefined || dataContainer[step] === null) {
32468
32512
  return defaultValue;
32469
32513
  }
@@ -32633,7 +32677,6 @@
32633
32677
  function getOthersLabel() {
32634
32678
  return 'Others'; // TODO: translator.get('properties.dimensionLimits.others')
32635
32679
  }
32636
-
32637
32680
  function createDefaultDimension(dimensionDef, dimensionProperties) {
32638
32681
  const def = extend$2(true, {}, dimensionProperties, dimensionDef);
32639
32682
  if (!utils.getValue(def, 'qOtherTotalSpec.qOtherCounted')) {
@@ -33159,7 +33202,6 @@
33159
33202
  }
33160
33203
  return undefined; // TODO: add listbox and other
33161
33204
  };
33162
-
33163
33205
  const getExportPropertiesFnc = qae => {
33164
33206
  if (qae.exportProperties) {
33165
33207
  return qae.exportProperties;
@@ -33174,7 +33216,6 @@
33174
33216
  }
33175
33217
  return undefined; // TODO: add listbox and other
33176
33218
  };
33177
-
33178
33219
  const getImportPropertiesFnc = qae => {
33179
33220
  if (qae.importProperties) {
33180
33221
  return qae.importProperties;
@@ -35212,7 +35253,6 @@
35212
35253
  hooks.macro = null;
35213
35254
  maybeEndChain(hooks); // eslint-disable-line no-use-before-define
35214
35255
  }
35215
-
35216
35256
  function maybeEndChain(hooks) {
35217
35257
  if (hooks.pendingPromises.length || hooks.micro || hooks.macro) {
35218
35258
  return;
@@ -36749,7 +36789,6 @@
36749
36789
  if (steps[i] === '') {
36750
36790
  continue; // eslint-disable-line no-continue
36751
36791
  }
36752
-
36753
36792
  if (typeof dataContainer[steps[i]] === 'undefined') {
36754
36793
  return defaultValue;
36755
36794
  }
@@ -37225,7 +37264,6 @@
37225
37264
  // resize() {},
37226
37265
  // show() {},
37227
37266
  };
37228
-
37229
37267
  return api;
37230
37268
  }
37231
37269
 
@@ -37287,7 +37325,7 @@
37287
37325
  * };
37288
37326
  * nebbie.render(createConfig);
37289
37327
  */
37290
- async function createSessionObject(_ref, halo) {
37328
+ async function createSessionObject(_ref, halo, store) {
37291
37329
  let {
37292
37330
  type,
37293
37331
  version,
@@ -37300,6 +37338,10 @@
37300
37338
  } = _ref;
37301
37339
  let mergedProps = {};
37302
37340
  const children = [];
37341
+ const {
37342
+ modelStore,
37343
+ subscribe
37344
+ } = store;
37303
37345
  let error;
37304
37346
  try {
37305
37347
  const t = halo.types.get({
@@ -37331,7 +37373,6 @@
37331
37373
  };
37332
37374
  // console.error(e); // eslint-disable-line
37333
37375
  }
37334
-
37335
37376
  const model = await halo.app.createSessionObject(mergedProps);
37336
37377
  if (children.length > 0) {
37337
37378
  await model.setFullPropertyTree({
@@ -37365,7 +37406,7 @@
37365
37406
  * @property {EngineAPI.IGenericObjectProperties=} properties
37366
37407
  */
37367
37408
 
37368
- async function createObject(_ref, halo, generateOnly) {
37409
+ async function createObject(_ref, halo, generateOnly, store) {
37369
37410
  let {
37370
37411
  type,
37371
37412
  version,
@@ -37375,6 +37416,9 @@
37375
37416
  } = _ref;
37376
37417
  let mergedProps = {};
37377
37418
  const children = [];
37419
+ const {
37420
+ modelStore
37421
+ } = store;
37378
37422
  // let error;
37379
37423
  try {
37380
37424
  const t = halo.types.get({
@@ -37410,7 +37454,6 @@
37410
37454
  }
37411
37455
  // console.error(e); // eslint-disable-line
37412
37456
  }
37413
-
37414
37457
  if (!generateOnly) {
37415
37458
  const model = await halo.app.createObject(mergedProps);
37416
37459
  if (children.length > 0) {
@@ -37425,13 +37468,17 @@
37425
37468
  return mergedProps;
37426
37469
  }
37427
37470
 
37428
- async function getObject$1(_ref, halo) {
37471
+ async function getObject$1(_ref, halo, store) {
37429
37472
  let {
37430
37473
  id,
37431
37474
  options,
37432
37475
  plugins,
37433
37476
  element
37434
37477
  } = _ref;
37478
+ const {
37479
+ modelStore,
37480
+ rpcRequestModelStore
37481
+ } = store;
37435
37482
  const key = "".concat(id);
37436
37483
  let rpc = rpcRequestModelStore.get(key);
37437
37484
  if (!rpc) {
@@ -37508,7 +37555,8 @@
37508
37555
  } = halo;
37509
37556
  const [layout] = useLayout$1(model);
37510
37557
  const {
37511
- theme: themeName
37558
+ theme: themeName,
37559
+ modelStore
37512
37560
  } = reactExports.useContext(InstanceContext);
37513
37561
  const [cells, setCells] = reactExports.useState([]);
37514
37562
  const [bgColor, setBgColor] = reactExports.useState(undefined);
@@ -37553,7 +37601,7 @@
37553
37601
  }
37554
37602
  const vs = await getObject$1({
37555
37603
  id: c.name
37556
- }, halo);
37604
+ }, halo, modelStore);
37557
37605
  return {
37558
37606
  model: vs.model,
37559
37607
  id: c.name,
@@ -37787,13 +37835,17 @@
37787
37835
  return api;
37788
37836
  }
37789
37837
 
37790
- async function getObject(_ref, halo) {
37838
+ async function getObject(_ref, halo, store) {
37791
37839
  let {
37792
37840
  id,
37793
37841
  options,
37794
37842
  plugins,
37795
37843
  element
37796
37844
  } = _ref;
37845
+ const {
37846
+ modelStore,
37847
+ rpcRequestModelStore
37848
+ } = store;
37797
37849
  const key = "".concat(id);
37798
37850
  let rpc = rpcRequestModelStore.get(key);
37799
37851
  if (!rpc) {
@@ -37822,15 +37874,14 @@
37822
37874
  * @interface Flags
37823
37875
  */
37824
37876
 
37825
- return (/** @lends Flags */{
37826
- /**
37827
- * Checks whether the specified flag is enabled.
37828
- * @param {string} flag - The value flag to check.
37829
- * @returns {boolean} True if the specified flag is enabled, false otherwise.
37830
- */
37831
- isEnabled: f => flags[f] === true
37832
- }
37833
- );
37877
+ return /** @lends Flags */{
37878
+ /**
37879
+ * Checks whether the specified flag is enabled.
37880
+ * @param {string} flag - The value flag to check.
37881
+ * @returns {boolean} True if the specified flag is enabled, false otherwise.
37882
+ */
37883
+ isEnabled: f => flags[f] === true
37884
+ };
37834
37885
  }
37835
37886
 
37836
37887
  var iterator;
@@ -38393,7 +38444,6 @@
38393
38444
  this[LRU_LIST] = new Yallist(); // list of items in order of use recency
38394
38445
  this[LENGTH] = 0; // length of items in the list
38395
38446
  }
38396
-
38397
38447
  dump() {
38398
38448
  return this[LRU_LIST].map(hit => isStale(this, hit) ? false : {
38399
38449
  k: hit.key,
@@ -39752,7 +39802,6 @@
39752
39802
  {
39753
39803
  console.warn(e); // eslint-disable-line no-console
39754
39804
  }
39755
-
39756
39805
  throw new Error("Failed to load visualization: '".concat(sKey, "'"));
39757
39806
  });
39758
39807
  }
@@ -39885,7 +39934,6 @@
39885
39934
  {
39886
39935
  console.warn("Visualization ".concat(name, " is not registered. Adding it now.")); // eslint-disable-line no-console
39887
39936
  }
39888
-
39889
39937
  this.register({
39890
39938
  name,
39891
39939
  version
@@ -39896,7 +39944,6 @@
39896
39944
  {
39897
39945
  console.warn("Version ".concat(version, " of ").concat(name, " is not registered. Falling back to version ").concat(versionToUse)); // eslint-disable-line no-console
39898
39946
  }
39899
-
39900
39947
  version = versionToUse;
39901
39948
  }
39902
39949
  return tc[name].get(version) || p.get(typeInfo);
@@ -40106,7 +40153,7 @@
40106
40153
  let currentContext = _objectSpread2(_objectSpread2({}, configuration.context), {}, {
40107
40154
  translator: locale.translator
40108
40155
  });
40109
- const [root] = boot({
40156
+ const [root, modelStore] = boot({
40110
40157
  app,
40111
40158
  context: currentContext
40112
40159
  });
@@ -40132,7 +40179,6 @@
40132
40179
  translator: locale.translator,
40133
40180
  nebbie: null // actual value is set further down
40134
40181
  };
40135
-
40136
40182
  const halo = {
40137
40183
  app,
40138
40184
  root,
@@ -40200,9 +40246,9 @@
40200
40246
  render: async cfg => {
40201
40247
  await currentThemePromise;
40202
40248
  if (cfg.id) {
40203
- return getObject(cfg, halo);
40249
+ return getObject(cfg, halo, modelStore);
40204
40250
  }
40205
- return createSessionObject(cfg, halo);
40251
+ return createSessionObject(cfg, halo, modelStore);
40206
40252
  },
40207
40253
  /**
40208
40254
  * Creates a visualization model
@@ -40218,7 +40264,7 @@
40218
40264
  * }
40219
40265
  * );
40220
40266
  */
40221
- create: async cfg => createObject(cfg, halo, false),
40267
+ create: async cfg => createObject(cfg, halo, false, modelStore),
40222
40268
  /**
40223
40269
  * Generates properties for a visualization object
40224
40270
  * @param {CreateConfig} cfg The create configuration.
@@ -40281,7 +40327,6 @@
40281
40327
  */
40282
40328
  selections: async () => {
40283
40329
  if (!selectionsApi) {
40284
- // const appSelections = await root.getAppSelections(); // Don't expose this for now
40285
40330
  selectionsApi = /** @lends AppSelections# */{
40286
40331
  /**
40287
40332
  * Mounts the app selection UI into the provided HTMLElement.
@@ -40294,7 +40339,6 @@
40294
40339
  {
40295
40340
  console.error('Already mounted'); // eslint-disable-line no-console
40296
40341
  }
40297
-
40298
40342
  return;
40299
40343
  }
40300
40344
  selectionsComponentReference = mount({