@mcurros2/microm 1.1.415-0 → 1.1.417-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4377,9 +4377,6 @@ function $896277638843ba48$export$894a0a0a56a800a7() {
4377
4377
  operation: "other",
4378
4378
  okButtonText: $896277638843ba48$export$f5e2cdf14a0d5fe.continueLabel,
4379
4379
  cancelButtonText: $896277638843ba48$export$f5e2cdf14a0d5fe.cancelLabel,
4380
- cancelButtonProps: {
4381
- color: 'gray'
4382
- },
4383
4380
  onOK: async ()=>{
4384
4381
  confirmed = true;
4385
4382
  await modals.close();
@@ -4400,11 +4397,7 @@ function $896277638843ba48$export$894a0a0a56a800a7() {
4400
4397
  children: $896277638843ba48$export$f5e2cdf14a0d5fe.warningTitle
4401
4398
  })
4402
4399
  ]
4403
- }),
4404
- size: 'md',
4405
- withCloseButton: false,
4406
- closeOnClickOutside: false,
4407
- closeOnEscape: false
4400
+ })
4408
4401
  },
4409
4402
  // single resolution point: fires on any close, so an external close counts as cancel
4410
4403
  onClosed: ()=>resolve(confirmed)
@@ -4686,7 +4679,7 @@ const $6d150b07756690a5$export$1c1b666b210bfb32 = {
4686
4679
  formHeight: '100%'
4687
4680
  };
4688
4681
  function $6d150b07756690a5$export$6d892edbc3527d79(props) {
4689
- const { formAPI: formAPI, children: children, showOK: showOK, showCancel: showCancel, showErrors: showErrors, showFormValidationNotification: showFormValidationNotification, showLoadingProgress: showLoadingProgress, OKText: OKText, CancelText: CancelText, invalidFieldsLabel: invalidFieldsLabel, showHelpButton: showHelpButton, preventEnterSubmission: preventEnterSubmission, CloseText: CloseText, buttons: buttons, isDirtyColor: isDirtyColor, cancelButtonVariant: cancelButtonVariant, okButtonVariant: okButtonVariant, disableOKIfNotDirty: disableOKIfNotDirty, formHeight: formHeight, disableOK: disableOK } = (0, $b4te3$mantinecore.useComponentDefaultProps)('EntityForm', $6d150b07756690a5$export$1c1b666b210bfb32, props);
4682
+ const { formAPI: formAPI, children: children, showOK: showOK, showCancel: showCancel, showErrors: showErrors, showFormValidationNotification: showFormValidationNotification, showLoadingProgress: showLoadingProgress, OKText: OKText, CancelText: CancelText, invalidFieldsLabel: invalidFieldsLabel, showHelpButton: showHelpButton, preventEnterSubmission: preventEnterSubmission, CloseText: CloseText, buttons: buttons, isDirtyColor: isDirtyColor, cancelButtonVariant: cancelButtonVariant, okButtonVariant: okButtonVariant, disableOKIfNotDirty: disableOKIfNotDirty, formHeight: formHeight, disableOK: disableOK, loadingOK: loadingOK } = (0, $b4te3$mantinecore.useComponentDefaultProps)('EntityForm', $6d150b07756690a5$export$1c1b666b210bfb32, props);
4690
4683
  const { entity: entity } = formAPI;
4691
4684
  const theme = (0, $b4te3$mantinecore.useMantineTheme)();
4692
4685
  const { handleCancel: handleCancel, handleSubmit: handleSubmit, notifyValidationErrorState: notifyValidationErrorState, status: status, form: form, formMode: formMode, showDescriptionState: showDescriptionState, isFormValid: isFormValid, asyncErrors: asyncErrors } = formAPI;
@@ -4789,7 +4782,7 @@ function $6d150b07756690a5$export$6d892edbc3527d79(props) {
4789
4782
  variant: okButtonVariant,
4790
4783
  type: "submit",
4791
4784
  color: form.isDirty() ? isDirtyColor : theme.primaryColor,
4792
- loading: status?.loading,
4785
+ loading: loadingOK || status?.loading,
4793
4786
  disabled: disableOK === true || disableOKIfNotDirty && !form.isDirty(),
4794
4787
  leftIcon: /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$tablericonsreact.IconCircleCheck), {
4795
4788
  size: "1.125rem"
@@ -6996,60 +6989,77 @@ const $7f5304fd68d04ed6$var$areParentKeysArraysEqual = (left, right)=>{
6996
6989
  return leftNames.length === rightNames.length && leftNames.every((name)=>leftKeys[name] === rightKeys[name]);
6997
6990
  });
6998
6991
  };
6992
+ const $7f5304fd68d04ed6$var$areStringArraysEqual = (left, right)=>{
6993
+ if (left === undefined || right === undefined) return left === right;
6994
+ return left.length === right.length && left.every((value, index)=>value === right[index]);
6995
+ };
6999
6996
  function $7f5304fd68d04ed6$export$1dc6a021c60990b5(props) {
7000
6997
  const { formAPI: formAPI, hierarchy: hierarchy, mappedHierarchy: mappedHierarchy } = props;
7001
- const [parentKeysArray, setParentKeysArray] = (0, $b4te3$react.useState)(()=>$7f5304fd68d04ed6$var$generateParentKeysArray(hierarchy, mappedHierarchy, formAPI.form.values));
7002
- const parentKeysArrayRef = (0, $b4te3$react.useRef)(parentKeysArray);
7003
- // Previous values are handled in hierarchy order and are not affected by mapping.
7004
- const previousHierarchyValues = (0, $b4te3$react.useRef)(hierarchy.map((name)=>formAPI.form.values[name]));
7005
- const processedGetStatus = (0, $b4te3$react.useRef)(undefined);
7006
- (0, $b4te3$react.useEffect)(()=>{
7007
- const currentHierarchyValues = hierarchy.map((name)=>formAPI.form.values[name]);
7008
- const isGetLoading = formAPI.status.operationType === 'get' && formAPI.status.loading === true;
7009
- // Values applied by a get are authoritative. Wait for the get to finish, then
7010
- // synchronize the hierarchy without treating those values as user changes.
7011
- if (isGetLoading) return;
7012
- const isExistingRecordMode = formAPI.formMode === 'edit' || formAPI.formMode === 'view';
7013
- const isNewCompletedGet = isExistingRecordMode && formAPI.status.operationType === 'get' && formAPI.status.loading === false && processedGetStatus.current !== formAPI.status;
7014
- if (isNewCompletedGet) {
7015
- const fetchedParentKeysArray = $7f5304fd68d04ed6$var$generateParentKeysArray(hierarchy, mappedHierarchy, formAPI.form.values);
7016
- if (!$7f5304fd68d04ed6$var$areParentKeysArraysEqual(parentKeysArrayRef.current, fetchedParentKeysArray)) {
7017
- // eslint-disable-next-line react-hooks/set-state-in-effect
7018
- setParentKeysArray(fetchedParentKeysArray);
7019
- parentKeysArrayRef.current = fetchedParentKeysArray;
7020
- }
7021
- previousHierarchyValues.current = currentHierarchyValues;
7022
- processedGetStatus.current = formAPI.status;
7023
- return;
7024
- }
7025
- // Use the deepest changed level so controls that update several valid hierarchy
7026
- // levels together only invalidate values below the last value they supplied.
7027
- let changedIndex = -1;
7028
- currentHierarchyValues.forEach((value, index)=>{
7029
- if (previousHierarchyValues.current[index] !== value) changedIndex = index;
7030
- });
7031
- if (changedIndex === -1) return;
6998
+ const [hierarchyState, setHierarchyState] = (0, $b4te3$react.useState)(()=>({
6999
+ parentKeysArray: $7f5304fd68d04ed6$var$generateParentKeysArray(hierarchy, mappedHierarchy, formAPI.form.values),
7000
+ hierarchyValues: hierarchy.map((name)=>formAPI.form.values[name]),
7001
+ hierarchy: [
7002
+ ...hierarchy
7003
+ ],
7004
+ mappedHierarchy: mappedHierarchy ? [
7005
+ ...mappedHierarchy
7006
+ ] : undefined,
7007
+ changeRevision: 0
7008
+ }));
7009
+ const currentHierarchyValues = hierarchy.map((name)=>formAPI.form.values[name]);
7010
+ const isGetLoading = formAPI.status.operationType === 'get' && formAPI.status.loading === true;
7011
+ const isExistingRecordMode = formAPI.formMode === 'edit' || formAPI.formMode === 'view';
7012
+ const isNewCompletedGet = isExistingRecordMode && formAPI.status.operationType === 'get' && formAPI.status.loading === false && hierarchyState.processedGetStatus !== formAPI.status;
7013
+ const hierarchyConfigurationChanged = !$7f5304fd68d04ed6$var$areStringArraysEqual(hierarchyState.hierarchy, hierarchy) || !$7f5304fd68d04ed6$var$areStringArraysEqual(hierarchyState.mappedHierarchy, mappedHierarchy);
7014
+ let detectedChangedIndex = -1;
7015
+ if (!isGetLoading && !isNewCompletedGet && !hierarchyConfigurationChanged) // Use the deepest changed level so controls that update several valid hierarchy
7016
+ // levels together only invalidate values below the last value they supplied.
7017
+ currentHierarchyValues.forEach((value, index)=>{
7018
+ if (hierarchyState.hierarchyValues[index] !== value) detectedChangedIndex = index;
7019
+ });
7020
+ let resolvedHierarchyState = hierarchyState;
7021
+ if (!isGetLoading) {
7022
+ const changedIndex = isNewCompletedGet || hierarchyConfigurationChanged ? undefined : detectedChangedIndex === -1 ? hierarchyState.changedIndex : detectedChangedIndex;
7032
7023
  const newParentKeysArray = $7f5304fd68d04ed6$var$generateParentKeysArray(hierarchy, mappedHierarchy, formAPI.form.values, changedIndex);
7033
- if (!$7f5304fd68d04ed6$var$areParentKeysArraysEqual(parentKeysArrayRef.current, newParentKeysArray)) {
7034
- // eslint-disable-next-line react-hooks/set-state-in-effect
7035
- setParentKeysArray(newParentKeysArray);
7036
- parentKeysArrayRef.current = newParentKeysArray;
7024
+ const parentKeysChanged = !$7f5304fd68d04ed6$var$areParentKeysArraysEqual(hierarchyState.parentKeysArray, newParentKeysArray);
7025
+ const hierarchyChanged = isNewCompletedGet || hierarchyConfigurationChanged || detectedChangedIndex !== -1;
7026
+ if (parentKeysChanged || hierarchyChanged) {
7027
+ // Reconcile before children render so callbacks and effects cannot capture
7028
+ // form values from this render with parent keys from the previous render.
7029
+ const newHierarchyState = {
7030
+ parentKeysArray: parentKeysChanged ? newParentKeysArray : hierarchyState.parentKeysArray,
7031
+ hierarchyValues: currentHierarchyValues,
7032
+ hierarchy: [
7033
+ ...hierarchy
7034
+ ],
7035
+ mappedHierarchy: mappedHierarchy ? [
7036
+ ...mappedHierarchy
7037
+ ] : undefined,
7038
+ processedGetStatus: isNewCompletedGet ? formAPI.status : hierarchyState.processedGetStatus,
7039
+ changedIndex: changedIndex,
7040
+ changeRevision: detectedChangedIndex === -1 ? hierarchyState.changeRevision : hierarchyState.changeRevision + 1
7041
+ };
7042
+ setHierarchyState(newHierarchyState);
7043
+ resolvedHierarchyState = newHierarchyState;
7037
7044
  }
7038
- previousHierarchyValues.current = currentHierarchyValues;
7045
+ }
7046
+ const committedChangedIndex = hierarchyState.changedIndex;
7047
+ const committedChangeRevision = hierarchyState.changeRevision;
7048
+ const committedHierarchy = hierarchyState.hierarchy;
7049
+ (0, $b4te3$react.useEffect)(()=>{
7050
+ if (committedChangedIndex === undefined) return;
7039
7051
  // Changing the bound value is handled by the control. Descendants must be
7040
7052
  // changed through the form controls receive the update.
7041
- hierarchy.slice(changedIndex + 1).forEach((name)=>{
7053
+ committedHierarchy.slice(committedChangedIndex + 1).forEach((name)=>{
7042
7054
  formAPI.form.setFieldValue(name, '');
7043
7055
  });
7044
7056
  }, [
7045
- formAPI.form,
7046
- formAPI.form.values,
7047
- formAPI.formMode,
7048
- formAPI.status,
7049
- hierarchy,
7050
- mappedHierarchy
7057
+ committedChangedIndex,
7058
+ committedChangeRevision,
7059
+ committedHierarchy,
7060
+ formAPI.form
7051
7061
  ]);
7052
- return parentKeysArray;
7062
+ return resolvedHierarchyState.parentKeysArray;
7053
7063
  }
7054
7064
 
7055
7065
  });