diff --git a/packages/framework/esm-framework/docs/API.md b/packages/framework/esm-framework/docs/API.md index 4d08d29ba..2ccadfbb8 100644 --- a/packages/framework/esm-framework/docs/API.md +++ b/packages/framework/esm-framework/docs/API.md @@ -5619,7 +5619,7 @@ Function to close an opened workspace | Name | Type | Description | | :------ | :------ | :------ | | `name` | `string` | Workspace registration name | -| `options` | `CloseWorkspaceOptions` | Options to close workspace | +| `options` | [`CloseWorkspaceOptions`](interfaces/CloseWorkspaceOptions.md) | Options to close workspace | #### Returns @@ -5701,11 +5701,11 @@ ___ ### useWorkspaces -▸ **useWorkspaces**(): `WorkspacesInfo` +▸ **useWorkspaces**(): [`WorkspacesInfo`](interfaces/WorkspacesInfo.md) #### Returns -`WorkspacesInfo` +[`WorkspacesInfo`](interfaces/WorkspacesInfo.md) #### Defined in diff --git a/packages/framework/esm-framework/docs/interfaces/CloseWorkspaceOptions.md b/packages/framework/esm-framework/docs/interfaces/CloseWorkspaceOptions.md new file mode 100644 index 000000000..6295fa041 --- /dev/null +++ b/packages/framework/esm-framework/docs/interfaces/CloseWorkspaceOptions.md @@ -0,0 +1,48 @@ +[@openmrs/esm-framework](../API.md) / CloseWorkspaceOptions + +# Interface: CloseWorkspaceOptions + +## Table of contents + +### Properties + +- [ignoreChanges](CloseWorkspaceOptions.md#ignorechanges) + +### Methods + +- [onWorkspaceClose](CloseWorkspaceOptions.md#onworkspaceclose) + +## Properties + +### ignoreChanges + +• `Optional` **ignoreChanges**: `boolean` + +Whether to close the workspace ignoring all the changes present in the workspace. + +If ignoreChanges is true, the user will not be prompted to save changes before closing +even if the `testFcn` passed to `promptBeforeClosing` returns `true`. + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/types.ts:10](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/types.ts#L10) + +## Methods + +### onWorkspaceClose + +▸ `Optional` **onWorkspaceClose**(): `void` + +If you want to take an action after the workspace is closed, you can pass your function as +`onWorkspaceClose`. This function will be called only after the workspace is closed, given +that the user might be shown a prompt. + +#### Returns + +`void` + +void + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/types.ts:17](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/types.ts#L17) diff --git a/packages/framework/esm-framework/docs/interfaces/DefaultWorkspaceProps.md b/packages/framework/esm-framework/docs/interfaces/DefaultWorkspaceProps.md index 90f5988a9..e5bff46c3 100644 --- a/packages/framework/esm-framework/docs/interfaces/DefaultWorkspaceProps.md +++ b/packages/framework/esm-framework/docs/interfaces/DefaultWorkspaceProps.md @@ -29,7 +29,7 @@ closed, given the user forcefully closes the workspace. | Name | Type | | :------ | :------ | -| `closeWorkspaceOptions?` | `CloseWorkspaceOptions` | +| `closeWorkspaceOptions?` | [`CloseWorkspaceOptions`](CloseWorkspaceOptions.md) | #### Returns @@ -52,7 +52,7 @@ will directly close the workspace without any prompt | Name | Type | | :------ | :------ | -| `closeWorkspaceOptions?` | `CloseWorkspaceOptions` | +| `closeWorkspaceOptions?` | [`CloseWorkspaceOptions`](CloseWorkspaceOptions.md) | #### Returns diff --git a/packages/framework/esm-framework/docs/interfaces/OpenWorkspace.md b/packages/framework/esm-framework/docs/interfaces/OpenWorkspace.md new file mode 100644 index 000000000..663e76bb7 --- /dev/null +++ b/packages/framework/esm-framework/docs/interfaces/OpenWorkspace.md @@ -0,0 +1,235 @@ +[@openmrs/esm-framework](../API.md) / OpenWorkspace + +# Interface: OpenWorkspace + +## Hierarchy + +- [`WorkspaceRegistration`](WorkspaceRegistration.md) + + ↳ **`OpenWorkspace`** + +## Table of contents + +### Workspace Properties + +- [additionalProps](OpenWorkspace.md#additionalprops) +- [canHide](OpenWorkspace.md#canhide) +- [canMaximize](OpenWorkspace.md#canmaximize) +- [moduleName](OpenWorkspace.md#modulename) +- [name](OpenWorkspace.md#name) +- [preferredWindowSize](OpenWorkspace.md#preferredwindowsize) +- [title](OpenWorkspace.md#title) +- [type](OpenWorkspace.md#type) +- [width](OpenWorkspace.md#width) + +### Other Methods + +- [closeWorkspace](OpenWorkspace.md#closeworkspace) +- [closeWorkspaceWithSavedChanges](OpenWorkspace.md#closeworkspacewithsavedchanges) +- [promptBeforeClosing](OpenWorkspace.md#promptbeforeclosing) + +### Workspace Methods + +- [load](OpenWorkspace.md#load) + +## Workspace Properties + +### additionalProps + +• **additionalProps**: `object` + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:49](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L49) + +___ + +### canHide + +• **canHide**: `boolean` + +#### Inherited from + +[WorkspaceRegistration](WorkspaceRegistration.md).[canHide](WorkspaceRegistration.md#canhide) + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:40](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L40) + +___ + +### canMaximize + +• **canMaximize**: `boolean` + +#### Inherited from + +[WorkspaceRegistration](WorkspaceRegistration.md).[canMaximize](WorkspaceRegistration.md#canmaximize) + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:41](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L41) + +___ + +### moduleName + +• **moduleName**: `string` + +#### Inherited from + +[WorkspaceRegistration](WorkspaceRegistration.md).[moduleName](WorkspaceRegistration.md#modulename) + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:45](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L45) + +___ + +### name + +• **name**: `string` + +#### Inherited from + +[WorkspaceRegistration](WorkspaceRegistration.md).[name](WorkspaceRegistration.md#name) + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:37](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L37) + +___ + +### preferredWindowSize + +• **preferredWindowSize**: [`WorkspaceWindowState`](../API.md#workspacewindowstate) + +#### Inherited from + +[WorkspaceRegistration](WorkspaceRegistration.md).[preferredWindowSize](WorkspaceRegistration.md#preferredwindowsize) + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:43](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L43) + +___ + +### title + +• **title**: `string` + +#### Inherited from + +[WorkspaceRegistration](WorkspaceRegistration.md).[title](WorkspaceRegistration.md#title) + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:38](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L38) + +___ + +### type + +• **type**: `string` + +#### Inherited from + +[WorkspaceRegistration](WorkspaceRegistration.md).[type](WorkspaceRegistration.md#type) + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:39](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L39) + +___ + +### width + +• **width**: ``"narrow"`` \| ``"wider"`` + +#### Inherited from + +[WorkspaceRegistration](WorkspaceRegistration.md).[width](WorkspaceRegistration.md#width) + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:42](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L42) + +## Other Methods + +### closeWorkspace + +▸ **closeWorkspace**(`closeWorkspaceOptions?`): `boolean` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `closeWorkspaceOptions?` | [`CloseWorkspaceOptions`](CloseWorkspaceOptions.md) | + +#### Returns + +`boolean` + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:50](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L50) + +___ + +### closeWorkspaceWithSavedChanges + +▸ **closeWorkspaceWithSavedChanges**(`closeWorkspaceOptions?`): `boolean` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `closeWorkspaceOptions?` | [`CloseWorkspaceOptions`](CloseWorkspaceOptions.md) | + +#### Returns + +`boolean` + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:51](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L51) + +___ + +### promptBeforeClosing + +▸ **promptBeforeClosing**(`testFcn`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `testFcn` | () => `boolean` | + +#### Returns + +`void` + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:52](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L52) + +___ + +## Workspace Methods + +### load + +▸ **load**(): `Promise`<{ `default?`: `LifeCycles`<{}\> } & `LifeCycles`<{}\>\> + +#### Returns + +`Promise`<{ `default?`: `LifeCycles`<{}\> } & `LifeCycles`<{}\>\> + +#### Inherited from + +[WorkspaceRegistration](WorkspaceRegistration.md).[load](WorkspaceRegistration.md#load) + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:44](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L44) diff --git a/packages/framework/esm-framework/docs/interfaces/Prompt.md b/packages/framework/esm-framework/docs/interfaces/Prompt.md new file mode 100644 index 000000000..f4a1d16c0 --- /dev/null +++ b/packages/framework/esm-framework/docs/interfaces/Prompt.md @@ -0,0 +1,74 @@ +[@openmrs/esm-framework](../API.md) / Prompt + +# Interface: Prompt + +## Table of contents + +### Workspace Properties + +- [body](Prompt.md#body) +- [cancelText](Prompt.md#canceltext) +- [confirmText](Prompt.md#confirmtext) +- [title](Prompt.md#title) + +### Methods + +- [onConfirm](Prompt.md#onconfirm) + +## Workspace Properties + +### body + +• **body**: `string` + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:20](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L20) + +___ + +### cancelText + +• `Optional` **cancelText**: `string` + +Defaults to "Cancel" + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:25](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L25) + +___ + +### confirmText + +• `Optional` **confirmText**: `string` + +Defaults to "Confirm" + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:22](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L22) + +___ + +### title + +• **title**: `string` + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:19](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L19) + +## Methods + +### onConfirm + +▸ **onConfirm**(): `void` + +#### Returns + +`void` + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:23](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L23) diff --git a/packages/framework/esm-framework/docs/interfaces/WorkspaceRegistration.md b/packages/framework/esm-framework/docs/interfaces/WorkspaceRegistration.md new file mode 100644 index 000000000..55bda4c38 --- /dev/null +++ b/packages/framework/esm-framework/docs/interfaces/WorkspaceRegistration.md @@ -0,0 +1,122 @@ +[@openmrs/esm-framework](../API.md) / WorkspaceRegistration + +# Interface: WorkspaceRegistration + +See [WorkspaceDefinition](../API.md#workspacedefinition) for more information about these properties + +## Hierarchy + +- **`WorkspaceRegistration`** + + ↳ [`OpenWorkspace`](OpenWorkspace.md) + +## Table of contents + +### Workspace Properties + +- [canHide](WorkspaceRegistration.md#canhide) +- [canMaximize](WorkspaceRegistration.md#canmaximize) +- [moduleName](WorkspaceRegistration.md#modulename) +- [name](WorkspaceRegistration.md#name) +- [preferredWindowSize](WorkspaceRegistration.md#preferredwindowsize) +- [title](WorkspaceRegistration.md#title) +- [type](WorkspaceRegistration.md#type) +- [width](WorkspaceRegistration.md#width) + +### Workspace Methods + +- [load](WorkspaceRegistration.md#load) + +## Workspace Properties + +### canHide + +• **canHide**: `boolean` + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:40](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L40) + +___ + +### canMaximize + +• **canMaximize**: `boolean` + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:41](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L41) + +___ + +### moduleName + +• **moduleName**: `string` + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:45](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L45) + +___ + +### name + +• **name**: `string` + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:37](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L37) + +___ + +### preferredWindowSize + +• **preferredWindowSize**: [`WorkspaceWindowState`](../API.md#workspacewindowstate) + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:43](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L43) + +___ + +### title + +• **title**: `string` + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:38](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L38) + +___ + +### type + +• **type**: `string` + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:39](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L39) + +___ + +### width + +• **width**: ``"narrow"`` \| ``"wider"`` + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:42](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L42) + +## Workspace Methods + +### load + +▸ **load**(): `Promise`<{ `default?`: `LifeCycles`<{}\> } & `LifeCycles`<{}\>\> + +#### Returns + +`Promise`<{ `default?`: `LifeCycles`<{}\> } & `LifeCycles`<{}\>\> + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:44](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L44) diff --git a/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md b/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md new file mode 100644 index 000000000..6180ee74a --- /dev/null +++ b/packages/framework/esm-framework/docs/interfaces/WorkspacesInfo.md @@ -0,0 +1,52 @@ +[@openmrs/esm-framework](../API.md) / WorkspacesInfo + +# Interface: WorkspacesInfo + +## Table of contents + +### Workspace Properties + +- [active](WorkspacesInfo.md#active) +- [prompt](WorkspacesInfo.md#prompt) +- [workspaceWindowState](WorkspacesInfo.md#workspacewindowstate) +- [workspaces](WorkspacesInfo.md#workspaces) + +## Workspace Properties + +### active + +• **active**: `boolean` + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:399](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L399) + +___ + +### prompt + +• **prompt**: ``null`` \| [`Prompt`](Prompt.md) + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:400](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L400) + +___ + +### workspaceWindowState + +• **workspaceWindowState**: [`WorkspaceWindowState`](../API.md#workspacewindowstate) + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:401](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L401) + +___ + +### workspaces + +• **workspaces**: [`OpenWorkspace`](OpenWorkspace.md)[] + +#### Defined in + +[packages/framework/esm-styleguide/src/workspaces/workspaces.ts:402](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-styleguide/src/workspaces/workspaces.ts#L402) diff --git a/packages/framework/esm-framework/mock.tsx b/packages/framework/esm-framework/mock.tsx index 80cc2680b..c9b32b634 100644 --- a/packages/framework/esm-framework/mock.tsx +++ b/packages/framework/esm-framework/mock.tsx @@ -79,6 +79,10 @@ export const usePatientPhoto = jest.fn(() => ({ data: null, error: null, })); +export const closeWorkspace = jest.fn(); +export const launchWorkspace = jest.fn(); +export const navigateAndLaunchWorkspace = jest.fn(); +export const useWorkspaces = jest.fn(); /* esm-utils */ export { getDefaultsFromConfigSchema, parseDate, formatDate, formatDatetime, formatTime } from '@openmrs/esm-utils'; diff --git a/packages/framework/esm-styleguide/src/workspaces/public.ts b/packages/framework/esm-styleguide/src/workspaces/public.ts index 199d9433d..cdd2bbc2b 100644 --- a/packages/framework/esm-styleguide/src/workspaces/public.ts +++ b/packages/framework/esm-styleguide/src/workspaces/public.ts @@ -2,5 +2,6 @@ export * from './action-menu/action-menu.component'; export * from './action-menu-button/action-menu-button.component'; export * from './overlay/workspace-overlay.component'; export * from './window/workspace-window.component'; -export { type DefaultWorkspaceProps } from './types'; +export { type DefaultWorkspaceProps, type CloseWorkspaceOptions } from './types'; export { closeWorkspace, launchWorkspace, navigateAndLaunchWorkspace, useWorkspaces } from './workspaces'; +export { type OpenWorkspace, type WorkspaceRegistration, type WorkspacesInfo, type Prompt } from './workspaces';