@nebula.js/stardust 4.0.3 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/core/esm/dev.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * @nebula.js/stardust v4.0.3
2
+ * @nebula.js/stardust v4.0.4
3
3
  * Copyright (c) 2023 QlikTech International AB
4
4
  * Released under the MIT license.
5
5
  */
@@ -8389,7 +8389,7 @@ function create$3(definition) {
8389
8389
  return cache[key];
8390
8390
  }
8391
8391
 
8392
- const NEBULA_VERSION_HASH = "f855" ;
8392
+ const NEBULA_VERSION_HASH = "ef4e" ;
8393
8393
  ClassNameGenerator$1.configure(componentName => {
8394
8394
  return "njs-".concat(NEBULA_VERSION_HASH, "-").concat(componentName.replace('Mui', ''));
8395
8395
  });
@@ -8447,7 +8447,6 @@ var createKeyStore = (function () {
8447
8447
 
8448
8448
  const [useAppSelectionsStore, appSelectionsStore] = createKeyStore({});
8449
8449
  const [useAppModalStore, appModalStore] = createKeyStore({});
8450
- const [useObjectSelectionsStore, objectSelectionsStore] = createKeyStore({});
8451
8450
  const [useModalObjectStore, modalObjectStore] = createKeyStore({});
8452
8451
 
8453
8452
  /* eslint no-underscore-dangle: 0 */
@@ -8458,18 +8457,26 @@ function createAppSelections(_ref) {
8458
8457
  const key = "".concat(app.id);
8459
8458
  const end = async function () {
8460
8459
  let accept = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
8461
- const model = modalObjectStore.get(key);
8460
+ const {
8461
+ model,
8462
+ objectSelections
8463
+ } = modalObjectStore.get(key) || {};
8462
8464
  if (model) {
8463
8465
  await model.endSelections(accept);
8464
8466
  modalObjectStore.clear(key);
8465
- const objectSelections = objectSelectionsStore.get(model.id);
8466
8467
  objectSelections.emit('deactivated');
8467
8468
  }
8468
8469
  };
8469
- const begin = async function (model, path) {
8470
- let accept = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
8470
+ const begin = async _ref2 => {
8471
+ var _modalObjectStore$get;
8472
+ let {
8473
+ model,
8474
+ paths,
8475
+ accept = true,
8476
+ objectSelections
8477
+ } = _ref2;
8471
8478
  // Quick return if it's already in modal
8472
- if (model === modalObjectStore.get(key)) {
8479
+ if (objectSelections === ((_modalObjectStore$get = modalObjectStore.get(key)) === null || _modalObjectStore$get === void 0 ? void 0 : _modalObjectStore$get.objectSelections)) {
8473
8480
  return;
8474
8481
  }
8475
8482
 
@@ -8477,12 +8484,18 @@ function createAppSelections(_ref) {
8477
8484
  end(accept);
8478
8485
 
8479
8486
  // Pending modal
8480
- modalObjectStore.set(key, model);
8481
- const p = Array.isArray(path) ? path : [path];
8487
+ modalObjectStore.set(key, {
8488
+ model,
8489
+ objectSelections
8490
+ });
8491
+ const p = Array.isArray(paths) ? paths : [paths];
8482
8492
  const beginSelections = async skipRetry => {
8483
8493
  try {
8484
8494
  await model.beginSelections(p);
8485
- modalObjectStore.set(key, model); // We have a modal
8495
+ modalObjectStore.set(key, {
8496
+ model,
8497
+ objectSelections
8498
+ }); // We have a modal
8486
8499
  } catch (err) {
8487
8500
  if (err.code === 6003 && !skipRetry) {
8488
8501
  await app.abortModal(accept);
@@ -8510,9 +8523,10 @@ function createAppSelections(_ref) {
8510
8523
  isInModal() {
8511
8524
  return !!modalObjectStore.get(key);
8512
8525
  },
8513
- isModal(object) {
8526
+ isModal(objectSelections) {
8527
+ var _modalObjectStore$get2;
8514
8528
  // TODO check model state
8515
- return object ? modalObjectStore.get(key) === object : !!modalObjectStore.get(key);
8529
+ return objectSelections ? ((_modalObjectStore$get2 = modalObjectStore.get(key)) === null || _modalObjectStore$get2 === void 0 ? void 0 : _modalObjectStore$get2.objectSelections) === objectSelections : !!modalObjectStore.get(key);
8516
8530
  },
8517
8531
  forward() {
8518
8532
  return appModal.end().then(() => app.forward());
@@ -8636,7 +8650,7 @@ function boot(_ref2) {
8636
8650
  const appRef = React__default.createRef();
8637
8651
  const element = document.createElement('div');
8638
8652
  element.style.display = 'none';
8639
- element.setAttribute('data-nebulajs-version', "4.0.3" );
8653
+ element.setAttribute('data-nebulajs-version', "4.0.4" );
8640
8654
  element.setAttribute('data-app-id', app.id);
8641
8655
  document.body.appendChild(element);
8642
8656
  if (context) {
@@ -14900,7 +14914,12 @@ const createObjectSelections = _ref2 => {
14900
14914
  }
14901
14915
  isActive = true;
14902
14916
  this.emit('activated');
14903
- return appModal.begin(model, paths, true);
14917
+ return appModal.begin({
14918
+ model,
14919
+ paths,
14920
+ accept: true,
14921
+ objectSelections: api
14922
+ });
14904
14923
  },
14905
14924
  /**
14906
14925
  * @returns {Promise<undefined>}
@@ -14987,12 +15006,17 @@ const createObjectSelections = _ref2 => {
14987
15006
  /**
14988
15007
  * @returns {boolean}
14989
15008
  */
14990
- isModal: () => appSelections.isModal(model),
15009
+ isModal: () => appSelections.isModal(api),
14991
15010
  /**
14992
15011
  * @param {string[]} paths
14993
15012
  * @returns {Promise<undefined>}
14994
15013
  */
14995
- goModal: paths => appModal.begin(model, paths, false),
15014
+ goModal: paths => appModal.begin({
15015
+ model,
15016
+ paths,
15017
+ accept: false,
15018
+ objectSelections: api
15019
+ }),
14996
15020
  /**
14997
15021
  * @param {boolean} [accept=false]
14998
15022
  * @returns {Promise<undefined>}
@@ -15032,20 +15056,16 @@ function useObjectSelections(app, model, elements, options) {
15032
15056
  const elementsArr = Array.isArray(elements) ? elements : [elements];
15033
15057
  const [appSelections] = useAppSelections(app);
15034
15058
  const [layout] = useLayout$1(model);
15035
- const key = model ? model.id : null;
15036
15059
  const [appModalStore] = useAppModalStore();
15037
- const [objectSelectionsStore] = useObjectSelectionsStore();
15038
15060
  const appModal = appModalStore.get(app.id);
15039
- let objectSelections = objectSelectionsStore.get(key);
15061
+ const [objectSelections, setObjectSelections] = useState$1();
15040
15062
  useEffect$1(() => {
15041
15063
  if (!appSelections || !model || objectSelections) return;
15042
- objectSelections = createObjectSelections({
15064
+ setObjectSelections(createObjectSelections({
15043
15065
  appSelections,
15044
15066
  appModal,
15045
15067
  model
15046
- });
15047
- objectSelectionsStore.set(key, objectSelections);
15048
- objectSelectionsStore.dispatch(true);
15068
+ }));
15049
15069
  }, [appSelections, model]);
15050
15070
  useEffect$1(() => {
15051
15071
  if (!objectSelections) return () => {};
@@ -15910,8 +15930,10 @@ function SelectedFields(_ref) {
15910
15930
  const [containerRef, containerRect] = useRect$1();
15911
15931
  const [maxItems, setMaxItems] = useState$1(0);
15912
15932
  const isInListboxPopover = () => {
15913
- const object = modalObjectStore.get(app.id);
15914
- return object && object.genericType === 'njsListbox';
15933
+ const {
15934
+ model
15935
+ } = modalObjectStore.get(app.id) || {};
15936
+ return (model === null || model === void 0 ? void 0 : model.genericType) === 'njsListbox';
15915
15937
  };
15916
15938
  useEffect$1(() => {
15917
15939
  if (!containerRect) return;