@ng-zen/cli 22.5.1 → 22.5.2-next.1
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/package.json +1 -1
- package/schematics/ui/files/popover/host/popover-host.scss +0 -52
- package/schematics/ui/files/popover/host/popover-host.ts +5 -3
- package/schematics/ui/files/popover/popover-positions.type.ts +13 -13
- package/schematics/ui/files/popover/popover.spec.ts +4 -4
- package/schematics/ui/files/popover/popover.stories.ts +13 -12
- package/schematics/ui/files/popover/popover.ts +4 -7
package/package.json
CHANGED
|
@@ -27,56 +27,4 @@
|
|
|
27
27
|
flip-block,
|
|
28
28
|
flip-inline,
|
|
29
29
|
flip-block flip-inline;
|
|
30
|
-
|
|
31
|
-
/* TOP */
|
|
32
|
-
&[data-placement='top'] {
|
|
33
|
-
position-area: top center;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
&[data-placement='top-start'] {
|
|
37
|
-
position-area: top left;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
&[data-placement='top-end'] {
|
|
41
|
-
position-area: top right;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/* BOTTOM */
|
|
45
|
-
&[data-placement='bottom'] {
|
|
46
|
-
position-area: bottom center;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
&[data-placement='bottom-start'] {
|
|
50
|
-
position-area: bottom left;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
&[data-placement='bottom-end'] {
|
|
54
|
-
position-area: bottom right;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/* LEFT */
|
|
58
|
-
&[data-placement='left'] {
|
|
59
|
-
position-area: left center;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
&[data-placement='left-start'] {
|
|
63
|
-
position-area: left top;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
&[data-placement='left-end'] {
|
|
67
|
-
position-area: left bottom;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/* RIGHT */
|
|
71
|
-
&[data-placement='right'] {
|
|
72
|
-
position-area: right center;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
&[data-placement='right-start'] {
|
|
76
|
-
position-area: right top;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
&[data-placement='right-end'] {
|
|
80
|
-
position-area: right bottom;
|
|
81
|
-
}
|
|
82
30
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component, input } from '@angular/core';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { PopoverPosition } from '../popover-positions.type';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* ZenPopoverHost is a minimal host component created dynamically by the `ZenPopover` directive.
|
|
@@ -28,10 +28,12 @@ import { PopoverPlacement } from '../popover-positions.type';
|
|
|
28
28
|
host: {
|
|
29
29
|
popover: 'auto',
|
|
30
30
|
'[attr.id]': 'id()',
|
|
31
|
-
'[
|
|
31
|
+
'[style.position-area]': 'placement()',
|
|
32
|
+
'[style.position-anchor]': 'anchorName()',
|
|
32
33
|
},
|
|
33
34
|
})
|
|
34
35
|
export class ZenPopoverHost {
|
|
35
36
|
readonly id = input.required<string>();
|
|
36
|
-
readonly
|
|
37
|
+
readonly anchorName = input.required<string>();
|
|
38
|
+
readonly placement = input<PopoverPosition>('top');
|
|
37
39
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
|
1
|
+
/** Vertical axis position relative to the host element. */
|
|
2
|
+
export type PopoverVerticalPosition = 'top' | 'bottom' | 'center';
|
|
3
|
+
|
|
4
|
+
/** Horizontal axis position relative to the host element. */
|
|
5
|
+
export type PopoverHorizontalPosition = 'left' | 'right' | 'center';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Position of the popover relative to its trigger.
|
|
9
|
+
* Accepts one or two values (e.g. `'top'`, `'left'`, `'top right'`, `'center left'`).
|
|
10
|
+
* Uses CSS `position-area` under the hood.
|
|
11
|
+
*/
|
|
12
|
+
export type PopoverPosition =
|
|
13
|
+
`${PopoverVerticalPosition} ${PopoverHorizontalPosition}` | PopoverVerticalPosition | PopoverHorizontalPosition;
|
|
@@ -99,14 +99,14 @@ describe('ZenPopover', () => {
|
|
|
99
99
|
expect(getPopoverHostEl(fixture)!.textContent).toContain('Popover content');
|
|
100
100
|
});
|
|
101
101
|
|
|
102
|
-
it('passes placement to host as
|
|
102
|
+
it('passes placement to host as position-area (bottom)', () => {
|
|
103
103
|
const fixture = TestBed.createComponent(TemplateBottomComponent);
|
|
104
104
|
fixture.detectChanges();
|
|
105
105
|
|
|
106
106
|
fixture.nativeElement.querySelector('#trigger-btn').click();
|
|
107
107
|
fixture.detectChanges();
|
|
108
108
|
|
|
109
|
-
expect(getPopoverHostEl(fixture)!.
|
|
109
|
+
expect(getPopoverHostEl(fixture)!.style.getPropertyValue('position-area')).toBe('bottom');
|
|
110
110
|
});
|
|
111
111
|
|
|
112
112
|
it('sets anchor styles on trigger and host', () => {
|
|
@@ -142,7 +142,7 @@ describe('ZenPopover', () => {
|
|
|
142
142
|
});
|
|
143
143
|
});
|
|
144
144
|
|
|
145
|
-
it('reflects placement as
|
|
145
|
+
it('reflects placement as position-area (left)', async () => {
|
|
146
146
|
await TestBed.configureTestingModule({
|
|
147
147
|
imports: [TemplateLeftComponent],
|
|
148
148
|
providers: [provideZonelessChangeDetection()],
|
|
@@ -154,7 +154,7 @@ describe('ZenPopover', () => {
|
|
|
154
154
|
fixture.nativeElement.querySelector('#trigger-btn').click();
|
|
155
155
|
fixture.detectChanges();
|
|
156
156
|
|
|
157
|
-
expect(getPopoverHostEl(fixture)!.
|
|
157
|
+
expect(getPopoverHostEl(fixture)!.style.getPropertyValue('position-area')).toBe('left');
|
|
158
158
|
});
|
|
159
159
|
|
|
160
160
|
it('renders string content as text node in host', async () => {
|
|
@@ -2,7 +2,7 @@ import { argsToTemplate, Meta, moduleMetadata, StoryObj } from '@storybook/angul
|
|
|
2
2
|
|
|
3
3
|
import { ZenButton } from '../button';
|
|
4
4
|
import { ZenPopover } from './popover';
|
|
5
|
-
import type {
|
|
5
|
+
import type { PopoverPosition } from './popover-positions.type';
|
|
6
6
|
|
|
7
7
|
type Story = StoryObj<ZenPopover>;
|
|
8
8
|
|
|
@@ -20,25 +20,26 @@ const meta = {
|
|
|
20
20
|
control: 'select',
|
|
21
21
|
options: [
|
|
22
22
|
'top',
|
|
23
|
-
'top-start',
|
|
24
|
-
'top-end',
|
|
25
23
|
'bottom',
|
|
26
|
-
'
|
|
27
|
-
'bottom-end',
|
|
24
|
+
'center',
|
|
28
25
|
'left',
|
|
29
|
-
'left-start',
|
|
30
|
-
'left-end',
|
|
31
26
|
'right',
|
|
32
|
-
'
|
|
33
|
-
'right
|
|
34
|
-
|
|
27
|
+
'top left',
|
|
28
|
+
'top right',
|
|
29
|
+
'top center',
|
|
30
|
+
'bottom left',
|
|
31
|
+
'bottom right',
|
|
32
|
+
'bottom center',
|
|
33
|
+
'center left',
|
|
34
|
+
'center right',
|
|
35
|
+
] satisfies PopoverPosition[],
|
|
35
36
|
table: {
|
|
36
37
|
category: 'inputs',
|
|
37
38
|
type: {
|
|
38
|
-
summary: '
|
|
39
|
+
summary: 'PopoverPosition',
|
|
39
40
|
},
|
|
40
41
|
defaultValue: {
|
|
41
|
-
summary: 'top' satisfies
|
|
42
|
+
summary: 'top' satisfies PopoverPosition,
|
|
42
43
|
},
|
|
43
44
|
},
|
|
44
45
|
},
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from '@angular/core';
|
|
13
13
|
|
|
14
14
|
import { ZenPopoverHost } from './host/popover-host';
|
|
15
|
-
import {
|
|
15
|
+
import { PopoverPosition } from './popover-positions.type';
|
|
16
16
|
|
|
17
17
|
type HostProperties = keyof ZenPopoverHost;
|
|
18
18
|
|
|
@@ -70,7 +70,6 @@ type HostProperties = keyof ZenPopoverHost;
|
|
|
70
70
|
*/
|
|
71
71
|
@Directive({
|
|
72
72
|
selector: '[zenPopover]',
|
|
73
|
-
standalone: true,
|
|
74
73
|
host: {
|
|
75
74
|
'(click)': 'togglePopover()',
|
|
76
75
|
},
|
|
@@ -81,7 +80,7 @@ export class ZenPopover {
|
|
|
81
80
|
/** Content to display inside the popover. Can be a `string` or a `TemplateRef`.*/
|
|
82
81
|
readonly content = input.required<TemplateRef<unknown> | string>({ alias: 'zenPopover' });
|
|
83
82
|
/** Placement of the popover relative to the trigger element. Defaults to `top`.*/
|
|
84
|
-
readonly placement = input<
|
|
83
|
+
readonly placement = input<PopoverPosition>('top', { alias: 'zenPopoverPlacement' });
|
|
85
84
|
/** The HTML id attribute is used to specify a unique id for an HTML element.*/
|
|
86
85
|
readonly id = input<string>(`zen-popover-${ZenPopover.uniqueId++}`);
|
|
87
86
|
|
|
@@ -125,12 +124,10 @@ export class ZenPopover {
|
|
|
125
124
|
|
|
126
125
|
this.hostRef = this.vcr.createComponent(ZenPopoverHost);
|
|
127
126
|
this.hostRef.setInput('id' satisfies HostProperties, this.id());
|
|
127
|
+
this.hostRef.setInput('anchorName' satisfies HostProperties, this.anchorName);
|
|
128
128
|
this.hostRef.setInput('placement' satisfies HostProperties, this.placement());
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
this.renderer.setStyle(popoverEl, 'position-anchor', this.anchorName);
|
|
132
|
-
|
|
133
|
-
return popoverEl;
|
|
130
|
+
return this.hostRef.location.nativeElement as HTMLElement;
|
|
134
131
|
}
|
|
135
132
|
|
|
136
133
|
private renderContent(popoverEl: HTMLElement) {
|