Skip to content

Commit dcad5f1

Browse files
committed
Merge branch 'v8-master'
2 parents a6ebc29 + 81aadbc commit dcad5f1

File tree

11 files changed

+5072
-4351
lines changed

11 files changed

+5072
-4351
lines changed

packages/changeset-form/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,13 @@
203203

204204
- Updated dependencies [157b860]
205205
- @ember-eui/core@8.1.0
206+
## 8.0.48
207+
208+
### Patch Changes
209+
210+
- Adds eui-wrapping-popover component
211+
- Updated dependencies
212+
- @ember-eui/core@8.0.48
206213

207214
## 8.0.47
208215

packages/core/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@
141141
### Minor Changes
142142

143143
- 157b860: Fixes issues
144+
## 8.0.48
145+
146+
### Patch Changes
147+
148+
- Adds eui-wrapping-popover component
144149

145150
## 8.0.47
146151

packages/core/docs/layout/popover/demo/d12-popover-using-and-html-element-as-the-anchor.md

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,64 @@ order: 12
55
# Popover using an HTML Element as the anchor
66

77
```hbs template
8-
<TodoText @text='To do'/>
9-
```
8+
{{#each this.buttons key='id' as |ele|}}
9+
{{ele.button}}
10+
{{/each}}
11+
12+
{{#if this.isOpen}}
13+
<EuiWrappingPopover
14+
@button={{this.button}}
15+
@isOpen={{this.isOpen}}
16+
@closePopover={{this.closePopover}}
17+
>
18+
<div>Normal JSX content populates the popover.</div>
19+
</EuiWrappingPopover>
20+
{{/if}}
21+
```
22+
23+
```javascript component
24+
import Component from '@glimmer/component';
25+
import { action } from '@ember/object';
26+
import { tracked } from '@glimmer/tracking';
27+
import { next } from '@ember/runloop';
28+
29+
export default class PopoverDemo1 extends Component {
30+
@tracked isOpen = false;
31+
@tracked button = null;
32+
@tracked counter = 1;
33+
34+
@tracked buttons = [];
35+
36+
closePopover = () => {
37+
this.isOpen = false;
38+
this.createButton();
39+
};
40+
41+
createButton = () => {
42+
const button = document.createElement('div');
43+
44+
button.innerHTML = `This is a dynamically inserted html node with <b>ID = ${this.counter}</b>, if you click, you will get a popover on it.`;
45+
46+
button.addEventListener('click', () => {
47+
this.isOpen = true;
48+
this.button = button;
49+
});
50+
51+
const ele = {
52+
button,
53+
id: `${this.counter}`
54+
};
55+
56+
this.buttons = [...this.buttons, ele];
57+
this.counter++;
58+
};
59+
60+
constructor() {
61+
super(...arguments);
62+
63+
next(() => {
64+
this.createButton();
65+
});
66+
}
67+
}
68+
```

packages/core/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@
417417
"./components/eui-toast.js": "./dist/_app_/components/eui-toast.js",
418418
"./components/eui-tool-tip-popover.js": "./dist/_app_/components/eui-tool-tip-popover.js",
419419
"./components/eui-tool-tip.js": "./dist/_app_/components/eui-tool-tip.js",
420+
"./components/eui-wrapping-popover.js": "./dist/_app_/components/eui-wrapping-popover.js",
420421
"./components/text-block.js": "./dist/_app_/components/text-block.js",
421422
"./helpers/arg-or-default.js": "./dist/_app_/helpers/arg-or-default.js",
422423
"./helpers/cast-to.js": "./dist/_app_/helpers/cast-to.js",

packages/core/src/components/eui-portal.gts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type EuiPortalInsertPosition = keyof typeof insertPositions;
2222

2323
export interface EuiPortalArgs {
2424
insert?: { sibling: HTMLElement; position: EuiPortalInsertPosition };
25-
portalRef?: (ref: HTMLDivElement | null) => void;
25+
portalRef?: (ref: HTMLElement) => void;
2626
}
2727

2828
export interface EuiPortalSignature {
@@ -53,6 +53,10 @@ export default class EuiPortal extends Component<EuiPortalSignature> {
5353
this.portalNode
5454
);
5555
}
56+
57+
if (this.args.portalRef) {
58+
this.args.portalRef(this.portalNode);
59+
}
5660
}
5761

5862
willDestroy(): void {
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import Component from '@glimmer/component';
2+
import { tracked } from '@glimmer/tracking';
3+
4+
import { modifier } from 'ember-modifier';
5+
6+
import EuiPopover from './eui-popover.gts';
7+
import EuiPortal from './eui-portal.gts';
8+
9+
import type { EuiPopoverSignature } from './eui-popover.gts';
10+
11+
export interface EuiWrappingPopoverSignature {
12+
Element: EuiPopoverSignature['Element'];
13+
Args: EuiPopoverSignature['Args'] & {
14+
button?: HTMLElement;
15+
};
16+
Blocks: {
17+
default: [];
18+
};
19+
}
20+
21+
export default class EuiWrappingPopover extends Component<EuiWrappingPopoverSignature> {
22+
private portal: HTMLElement | null = null;
23+
private anchor: HTMLElement | null = null;
24+
25+
setAnchorRef = modifier((element: HTMLElement) => {
26+
this.anchor = element;
27+
this.anchor.insertAdjacentElement('beforebegin', this.args.button!);
28+
});
29+
30+
setPortalRef = (element: HTMLElement) => {
31+
this.portal = element;
32+
};
33+
34+
get insert(): { sibling: HTMLElement; position: 'after' } | undefined {
35+
if (this.args.button) {
36+
return {
37+
sibling: this.args.button,
38+
position: 'after'
39+
};
40+
}
41+
42+
return;
43+
}
44+
45+
willDestroy() {
46+
super.willDestroy();
47+
48+
if (this.args.button && this.args.button.parentNode) {
49+
if (this.portal) {
50+
this.portal.insertAdjacentElement('beforebegin', this.args.button);
51+
}
52+
}
53+
}
54+
55+
<template>
56+
<EuiPortal @portalRef={{this.setPortalRef}} @insert={{this.insert}}>
57+
<EuiPopover
58+
@closePopover={{@closePopover}}
59+
@isOpen={{@isOpen}}
60+
@anchorClassName={{@anchorClassName}}
61+
@anchorPosition={{@anchorPosition}}
62+
@attachToAnchor={{@attachToAnchor}}
63+
@container={{@container}}
64+
@display={{@display}}
65+
@hasArrow={{@hasArrow}}
66+
@initialFocus={{@initialFocus}}
67+
@ownFocus={{@ownFocus}}
68+
@panelClassName={{@panelClassName}}
69+
@panelPaddingSize={{@panelPaddingSize}}
70+
@panelStyle={{@panelStyle}}
71+
@panelRef={{@panelRef}}
72+
@popoverRef={{@popoverRef}}
73+
...attributes
74+
>
75+
<:button>
76+
<div {{this.setAnchorRef}} class="euiWrappingPopover__anchor" />
77+
</:button>
78+
79+
<:content>
80+
{{yield}}
81+
</:content>
82+
</EuiPopover>
83+
</EuiPortal>
84+
</template>
85+
}

packages/flatpickr/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,13 @@
203203

204204
- Updated dependencies [157b860]
205205
- @ember-eui/core@8.1.0
206+
## 8.0.48
207+
208+
### Patch Changes
209+
210+
- Adds eui-wrapping-popover component
211+
- Updated dependencies
212+
- @ember-eui/core@8.0.48
206213

207214
## 8.0.47
208215

packages/pikaday/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,13 @@
203203

204204
- Updated dependencies [157b860]
205205
- @ember-eui/core@8.1.0
206+
## 8.0.48
207+
208+
### Patch Changes
209+
210+
- Adds eui-wrapping-popover component
211+
- Updated dependencies
212+
- @ember-eui/core@8.0.48
206213

207214
## 8.0.47
208215

packages/validated-form/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,13 @@
203203

204204
- Updated dependencies [157b860]
205205
- @ember-eui/core@8.1.0
206+
## 8.0.48
207+
208+
### Patch Changes
209+
210+
- Adds eui-wrapping-popover component
211+
- Updated dependencies
212+
- @ember-eui/core@8.0.48
206213

207214
## 8.0.47
208215

0 commit comments

Comments
 (0)