Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 76 additions & 27 deletions packages/main/src/components/Modals/Modals.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,33 @@ describe('Modals - static helpers', () => {
>
Show Popover
</Button>
<br />
<Button
onClick={() => {
Modals.showPopover(
{
opener: 'modals-show-popover',
children: 'Popover 2',
},
{ autoClosePopovers: true },
);
}}
>
Show Popover 2
</Button>
</>
);
};
cy.mount(<TestComp />);

cy.mount(<TestComp />);
cy.findByText('Show Popover').click();
cy.findByText('Popover Content').should('be.visible');
cy.findByText('Show Popover').click();
cy.get('[ui5-popover]').should('have.length', 2);

cy.findByText('Show Popover').click();
cy.findByText('Popover Content').should('be.visible');
cy.findByText('Close').click();
cy.findByText('Dialog Content').should('not.exist');
};
cy.findByText('Show Popover 2').click();
cy.findByText('Popover 2').should('be.visible');
cy.get('[ui5-popover]').should('have.length', 1);
});

it('showResponsivePopover', () => {
Expand All @@ -63,27 +80,43 @@ describe('Modals - static helpers', () => {
<>
<Modals />
<Button
id="modals-show-popover"
id="modals-show-responsive-popover"
onClick={() => {
const { close } = Modals.showResponsivePopover({
opener: 'modals-show-popover',
children: 'Popover Content',
footer: <Bar endContent={<Button onClick={() => close()}>Close</Button>} />,
Modals.showResponsivePopover({
opener: 'modals-show-responsive-popover',
children: 'ResponsivePopover Content',
});
}}
>
Show Popover
Show ResponsivePopover
</Button>
<br />
<Button
onClick={() => {
Modals.showResponsivePopover(
{
opener: 'modals-show-responsive-popover',
children: 'ResponsivePopover 2',
},
{ autoClosePopovers: true },
);
}}
>
Show ResponsivePopover 2
</Button>
</>
);
};
cy.mount(<TestComp />);

cy.mount(<TestComp />);
cy.findByText('Show ResponsivePopover').click();
cy.findByText('ResponsivePopover Content').should('be.visible');
cy.findByText('Show ResponsivePopover').click();
cy.get('[ui5-responsive-popover]').should('have.length', 2);

cy.findByText('Show Popover').click();
cy.findByText('Popover Content').should('be.visible');
cy.findByText('Close').click();
cy.findByText('Dialog Content').should('not.exist');
};
cy.findByText('Show ResponsivePopover 2').click();
cy.findByText('ResponsivePopover 2').should('be.visible');
cy.get('[ui5-responsive-popover]').should('have.length', 1);
});

it('showMenu', () => {
Expand All @@ -92,26 +125,42 @@ describe('Modals - static helpers', () => {
<>
<Modals />
<Button
id="modals-show-popover"
id="modals-show-menu"
onClick={() => {
Modals.showMenu({
opener: 'modals-show-popover',
children: <MenuItem text="MenuItem" />,
opener: 'modals-show-menu',
children: <MenuItem text="MenuItem 1" />,
});
}}
>
Show Menu
</Button>
<Button
onClick={() => {
Modals.showMenu(
{
opener: 'modals-show-menu',
children: <MenuItem text="MenuItem 2" />,
},
{ autoClosePopovers: true },
);
}}
>
Show Menu 2
</Button>
</>
);
};
cy.mount(<TestComp />);

cy.mount(<TestComp />);
cy.findByText('Show Menu').click();
cy.get('[ui5-menu-item][text="MenuItem 1"]').should('be.visible');
cy.findByText('Show Menu').click();
cy.get('[ui5-menu]').should('have.length', 2);

cy.findByText('Show Menu').click();
cy.findByText('MenuItem').should('be.visible');
cy.findByText('MenuItem').click();
cy.findByText('MenuItem').should('not.exist');
};
cy.findByText('Show Menu 2').click();
cy.get('[ui5-menu-item][text="MenuItem 2"]').should('be.visible');
cy.get('[ui5-menu]').should('have.length', 1);
});

it('showMessageBox', () => {
Expand Down
121 changes: 95 additions & 26 deletions packages/main/src/components/Modals/Modals.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,26 @@ root.render(
```typescript
import { Modals } from '@ui5/webcomponents-react/Modals';

// Recommended: using config object
const { ref, close } = Modals.showDialog(props, config);

// Legacy: using container directly
const { ref, close } = Modals.showDialog(props, container);
```

**Parameters**

| Parameter | Description |
| ------------- | ------------------------------------------------------------------------------------- |
| `props` | All supported `Dialog` props (see table below). `open` will always be set to `true`. |
| _`container`_ | Optional container where the `Dialog` should be mounted. Defaults to `document.body`. |
| Parameter | Description |
| ------------- | ------------------------------------------------------------------------------------------------------- |
| `props` | All supported `Dialog` props (see table below). `open` will always be set to `true`. |
| _`config`_ | Optional configuration object. See config options below. |
| _`container`_ | _(deprecated)_ Optional container where the `Dialog` should be mounted. Use `config.container` instead. |

**Config Options** _(since 2.19.0)_

| Property | Description |
| ----------- | -------------------------------------------------------------------------------------- |
| `container` | Optional container where the component should be mounted. Defaults to `document.body`. |

**Return Value**

Expand All @@ -71,15 +82,27 @@ The `showDialog` method returns an object with the following properties:
```typescript
import { Modals } from '@ui5/webcomponents-react/Modals';

// Recommended: using config object
const { ref, close } = Modals.showPopover(props, config);

// Legacy: using container directly
const { ref, close } = Modals.showPopover(props, container);
```

**Parameters**

| Parameter | Description |
| ------------- | -------------------------------------------------------------------------------------- |
| `props` | All supported `Popover` props (see table below).`open` will always be set to `true`. |
| _`container`_ | Optional container where the `Popover` should be mounted. Defaults to `document.body`. |
| Parameter | Description |
| ------------- | -------------------------------------------------------------------------------------------------------- |
| `props` | All supported `Popover` props (see table below). `open` will always be set to `true`. |
| _`config`_ | Optional configuration object. See config options below. |
| _`container`_ | _(deprecated)_ Optional container where the `Popover` should be mounted. Use `config.container` instead. |

**Config Options** _(since 2.19.0)_

| Property | Description |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `container` | Optional container where the component should be mounted. Defaults to `document.body`. |
| `autoClosePopovers` | If set to `true`, opening a new Popover will automatically close all currently opened Popovers that share the same opener. Only affects Popover, Menu, and ResponsivePopover. |

**Return Value**

Expand All @@ -103,15 +126,27 @@ The `showPopover` method returns an object with the following properties:
```typescript
import { Modals } from '@ui5/webcomponents-react/Modals';

// Recommended: using config object
const { ref, close } = Modals.showResponsivePopover(props, config);

// Legacy: using container directly
const { ref, close } = Modals.showResponsivePopover(props, container);
```

**Parameters**

| Parameter | Description |
| ------------- | ------------------------------------------------------------------------------------------------ |
| `props` | All supported `ResponsivePopover` props (see table below). `open` will always be set to `true`. |
| _`container`_ | Optional container where the `ResponsivePopover` should be mounted. Defaults to `document.body`. |
| Parameter | Description |
| ------------- | ------------------------------------------------------------------------------------------------------------------ |
| `props` | All supported `ResponsivePopover` props (see table below). `open` will always be set to `true`. |
| _`config`_ | Optional configuration object. See config options below. |
| _`container`_ | _(deprecated)_ Optional container where the `ResponsivePopover` should be mounted. Use `config.container` instead. |

**Config Options** _(since 2.19.0)_

| Property | Description |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `container` | Optional container where the component should be mounted. Defaults to `document.body`. |
| `autoClosePopovers` | If set to `true`, opening a new Popover will automatically close all currently opened Popovers that share the same opener. Only affects Popover, Menu, and ResponsivePopover. |

**Return Value**

Expand All @@ -137,19 +172,31 @@ The `showResponsivePopover` method returns an object with the following properti
```typescript
import { Modals } from '@ui5/webcomponents-react/Modals';

// Recommended: using config object
const { ref, close } = Modals.showMenu(props, config);

// Legacy: using container directly
const { ref, close } = Modals.showMenu(props, container);
```

**Parameters**

| Parameter | Description |
| ------------- | ----------------------------------------------------------------------------------- |
| `props` | All supported `Menu` props (see table below). `open` will always be set to `true`. |
| _`container`_ | Optional container where the `Menu` should be mounted. Defaults to `document.body`. |
| Parameter | Description |
| ------------- | ----------------------------------------------------------------------------------------------------- |
| `props` | All supported `Menu` props (see table below). `open` will always be set to `true`. |
| _`config`_ | Optional configuration object. See config options below. |
| _`container`_ | _(deprecated)_ Optional container where the `Menu` should be mounted. Use `config.container` instead. |

**Config Options** _(since 2.19.0)_

| Property | Description |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `container` | Optional container where the component should be mounted. Defaults to `document.body`. |
| `autoClosePopovers` | If set to `true`, opening a new Popover will automatically close all currently opened Popovers that share the same opener. Only affects Popover, Menu, and ResponsivePopover. |

**Return Value**

The `Menu` method returns an object with the following properties:
The `showMenu` method returns an object with the following properties:

| Property | Description |
| --------- | ---------------------------------------------------------------- |
Expand All @@ -169,15 +216,26 @@ The `Menu` method returns an object with the following properties:
```typescript
import { Modals } from '@ui5/webcomponents-react/Modals';

// Recommended: using config object
const { ref, close } = Modals.showMessageBox(props, config);

// Legacy: using container directly
const { ref, close } = Modals.showMessageBox(props, container);
```

**Parameters**

| Parameter | Description |
| ------------- | ----------------------------------------------------------------------------------------- |
| `props` | All supported `MessageBox` props (see table below). `open` will always be set to `true`. |
| _`container`_ | Optional container where the `MessageBox` should be mounted. Defaults to `document.body`. |
| Parameter | Description |
| ------------- | ----------------------------------------------------------------------------------------------------------- |
| `props` | All supported `MessageBox` props (see table below). `open` will always be set to `true`. |
| _`config`_ | Optional configuration object. See config options below. |
| _`container`_ | _(deprecated)_ Optional container where the `MessageBox` should be mounted. Use `config.container` instead. |

**Config Options** _(since 2.19.0)_

| Property | Description |
| ----------- | -------------------------------------------------------------------------------------- |
| `container` | Optional container where the component should be mounted. Defaults to `document.body`. |

**Return Value**

Expand All @@ -201,19 +259,30 @@ The `showMessageBox` method returns an object with the following properties:
```typescript
import { Modals } from '@ui5/webcomponents-react/Modals';

// Recommended: using config object
const { ref } = Modals.showToast(props, config);

// Legacy: using container directly
const { ref } = Modals.showToast(props, container);
```

**Parameters**

| Parameter | Description |
| ------------- | ----------------------------------------------------------------------------------- |
| `props` | All supported `Toast` props(see table below). |
| _`container`_ | Optional container where the `Toast` should be mounted.Defaults to `document.body`. |
| Parameter | Description |
| ------------- | ------------------------------------------------------------------------------------------------------ |
| `props` | All supported `Toast` props (see table below). |
| _`config`_ | Optional configuration object. See config options below. |
| _`container`_ | _(deprecated)_ Optional container where the `Toast` should be mounted. Use `config.container` instead. |

**Config Options** _(since 2.19.0)_

| Property | Description |
| ----------- | -------------------------------------------------------------------------------------- |
| `container` | Optional container where the component should be mounted. Defaults to `document.body`. |

**Return Value**

The`showToast` method returns an object with the following properties:
The `showToast` method returns an object with the following properties:

| Property | Description |
| -------- | ----------------------------------------------------------------- |
Expand Down
Loading
Loading