@openmrs/esm-styleguide 8.0.1-pre.3648 → 8.0.1-pre.3662

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.
@@ -13,6 +13,6 @@
13
13
  [0] │ You can limit the size of your bundles by using import() to lazy load some parts of your application.
14
14
  [0] │ For more info visit https://www.rspack.dev/guide/optimization/code-splitting
15
15
  [0]
16
- [0] Rspack compiled with 3 warnings in 10.31 s
16
+ [0] Rspack compiled with 3 warnings in 9.49 s
17
17
  [0] rspack --mode=production exited with code 0
18
18
  [1] tsc --project tsconfig.build.json exited with code 0
@@ -75,6 +75,10 @@ type PromptReason = {
75
75
  explicit: boolean;
76
76
  windowName: string;
77
77
  workspaceName: string;
78
+ } | {
79
+ reason: 'CLOSE_OTHER_WINDOWS';
80
+ explicit: false;
81
+ windowNameToSpare: string;
78
82
  };
79
83
  /**
80
84
  * A user can perform actions that explicitly result in closing workspaces
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-styleguide",
3
- "version": "8.0.1-pre.3648",
3
+ "version": "8.0.1-pre.3662",
4
4
  "license": "MPL-2.0",
5
5
  "description": "The styleguide for OpenMRS SPA",
6
6
  "main": "dist/openmrs-esm-styleguide.js",
@@ -98,17 +98,17 @@
98
98
  "swr": "2.x"
99
99
  },
100
100
  "devDependencies": {
101
- "@openmrs/esm-api": "8.0.1-pre.3648",
102
- "@openmrs/esm-config": "8.0.1-pre.3648",
103
- "@openmrs/esm-emr-api": "8.0.1-pre.3648",
104
- "@openmrs/esm-error-handling": "8.0.1-pre.3648",
105
- "@openmrs/esm-extensions": "8.0.1-pre.3648",
106
- "@openmrs/esm-globals": "8.0.1-pre.3648",
107
- "@openmrs/esm-navigation": "8.0.1-pre.3648",
108
- "@openmrs/esm-react-utils": "8.0.1-pre.3648",
109
- "@openmrs/esm-state": "8.0.1-pre.3648",
110
- "@openmrs/esm-translations": "8.0.1-pre.3648",
111
- "@openmrs/esm-utils": "8.0.1-pre.3648",
101
+ "@openmrs/esm-api": "8.0.1-pre.3662",
102
+ "@openmrs/esm-config": "8.0.1-pre.3662",
103
+ "@openmrs/esm-emr-api": "8.0.1-pre.3662",
104
+ "@openmrs/esm-error-handling": "8.0.1-pre.3662",
105
+ "@openmrs/esm-extensions": "8.0.1-pre.3662",
106
+ "@openmrs/esm-globals": "8.0.1-pre.3662",
107
+ "@openmrs/esm-navigation": "8.0.1-pre.3662",
108
+ "@openmrs/esm-react-utils": "8.0.1-pre.3662",
109
+ "@openmrs/esm-state": "8.0.1-pre.3662",
110
+ "@openmrs/esm-translations": "8.0.1-pre.3662",
111
+ "@openmrs/esm-utils": "8.0.1-pre.3662",
112
112
  "@rspack/cli": "^1.3.11",
113
113
  "@rspack/core": "^1.3.11",
114
114
  "@types/geopattern": "^1.2.9",
@@ -115,7 +115,8 @@ export const Workspace2: React.FC<Workspace2Props> = ({ title, children, hasUnsa
115
115
  }
116
116
 
117
117
  const { icon, canMaximize } = windowDef;
118
- const canHide = !!icon;
118
+ const canCloseGroup = group.persistence === 'closable';
119
+ const canHide = !!icon && !canCloseGroup;
119
120
  const { maximized } = openedWindow;
120
121
  const width = windowDef?.width ?? 'narrow';
121
122
 
@@ -173,12 +174,14 @@ export const Workspace2: React.FC<Workspace2Props> = ({ title, children, hasUnsa
173
174
  <ArrowRightIcon />
174
175
  </HeaderGlobalAction>
175
176
  ) : (
176
- <HeaderGlobalAction
177
- aria-label={getCoreTranslation('close')}
178
- onClick={() => closeWorkspace({ closeWindow: true })}
179
- >
180
- <CloseIcon />
181
- </HeaderGlobalAction>
177
+ !canCloseGroup && (
178
+ <HeaderGlobalAction
179
+ aria-label={getCoreTranslation('close')}
180
+ onClick={() => closeWorkspace({ closeWindow: true })}
181
+ >
182
+ <CloseIcon />
183
+ </HeaderGlobalAction>
184
+ )
182
185
  )}
183
186
  </>
184
187
  ) : (
@@ -272,6 +272,33 @@ export async function launchWorkspace2<
272
272
  return false;
273
273
  }
274
274
  }
275
+ } else if (groupDef.persistence == 'closable') {
276
+ const okToCloseWorkspaces = await promptForClosingWorkspaces({
277
+ reason: 'CLOSE_OTHER_WINDOWS',
278
+ explicit: false,
279
+ windowNameToSpare: windowDef.name,
280
+ });
281
+ if (okToCloseWorkspaces) {
282
+ workspace2Store.setState({
283
+ ...storeState,
284
+ openedGroup: {
285
+ groupName: groupDef.name,
286
+ props: groupProps ?? storeState?.openedGroup?.props ?? null,
287
+ },
288
+ openedWindows: [
289
+ {
290
+ windowName: windowName,
291
+ openedWorkspaces: [newOpenedWorkspace(workspaceName, workspaceProps)], // root workspace at index 0
292
+ props: windowProps,
293
+ maximized: false,
294
+ },
295
+ ],
296
+ isMostRecentlyOpenedWindowHidden: false,
297
+ });
298
+ return true;
299
+ } else {
300
+ return false;
301
+ }
275
302
  } else {
276
303
  workspace2Store.setState({
277
304
  ...storeState,
@@ -316,7 +343,8 @@ function arePropsCompatible(a: Record<string, any> | null, b: Record<string, any
316
343
  type PromptReason =
317
344
  | { reason: 'CLOSE_WORKSPACE_GROUP'; explicit: boolean }
318
345
  | { reason: 'CLOSE_WINDOW'; explicit: boolean; windowName: string }
319
- | { reason: 'CLOSE_WORKSPACE'; explicit: boolean; windowName: string; workspaceName: string };
346
+ | { reason: 'CLOSE_WORKSPACE'; explicit: boolean; windowName: string; workspaceName: string }
347
+ | { reason: 'CLOSE_OTHER_WINDOWS'; explicit: false; windowNameToSpare: string };
320
348
 
321
349
  /**
322
350
  * A user can perform actions that explicitly result in closing workspaces
@@ -340,7 +368,7 @@ export function promptForClosingWorkspaces(promptReason: PromptReason): Promise<
340
368
  for (let i = openedWindow.openedWorkspaces.length - 1; i >= 0; i--) {
341
369
  const openedWorkspace = openedWindow.openedWorkspaces[i];
342
370
 
343
- if (openedWorkspace.hasUnsavedChanges || !promptReason.explicit) {
371
+ if (openedWorkspace.hasUnsavedChanges) {
344
372
  ret.push(openedWorkspace);
345
373
  }
346
374
  if (onlyUpToThisWorkspace && openedWorkspace.workspaceName === onlyUpToThisWorkspace) {
@@ -371,6 +399,12 @@ export function promptForClosingWorkspaces(promptReason: PromptReason): Promise<
371
399
  throw new Error(`Window ${promptReason.windowName} not found in opened windows.`);
372
400
  }
373
401
  affectedWorkspaces = getAffectedWorkspacesInWindow(openedWindow, promptReason.workspaceName);
402
+ break;
403
+ }
404
+ case 'CLOSE_OTHER_WINDOWS': {
405
+ const windowsToClose = openedWindows.filter((window) => window.windowName !== promptReason.windowNameToSpare);
406
+ affectedWorkspaces = windowsToClose.flatMap((w) => getAffectedWorkspacesInWindow(w));
407
+ break;
374
408
  }
375
409
  }
376
410