ngx-dev-toolbar 1.0.0-beta.2 → 1.0.0
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/README.md +254 -4
- package/eslint.config.cjs +47 -0
- package/ng-package.json +7 -0
- package/package.json +8 -23
- package/project.json +37 -0
- package/src/components/button/button.component.scss +49 -0
- package/src/components/button/button.component.ts +36 -0
- package/src/components/card/card.component.scss +18 -0
- package/src/components/card/card.component.ts +30 -0
- package/src/components/clickable-card/clickable-card.component.scss +39 -0
- package/src/components/clickable-card/clickable-card.component.ts +34 -0
- package/src/components/icons/angular-icon.component.ts +35 -0
- package/src/components/icons/bug-icon.component.ts +23 -0
- package/src/components/icons/code-icon.component.ts +24 -0
- package/src/components/icons/database-icon.component.ts +27 -0
- package/src/components/icons/discord-icon.component.ts +23 -0
- package/src/components/icons/docs-icon.component.ts +23 -0
- package/src/components/icons/export-icon.component.ts +23 -0
- package/src/components/icons/gauge-icon.component.ts +27 -0
- package/src/components/icons/gear-icon.component.ts +27 -0
- package/src/components/icons/git-branch-icon.component.ts +27 -0
- package/src/components/icons/icon.component.ts +129 -0
- package/src/components/icons/icon.models.ts +27 -0
- package/src/components/icons/import-icon.component.ts +23 -0
- package/src/components/icons/layout-icon.component.ts +24 -0
- package/src/components/icons/lightbulb-icon.component.ts +23 -0
- package/src/components/icons/lighting-icon.component.ts +24 -0
- package/src/components/icons/moon-icon.component.ts +27 -0
- package/src/components/icons/network-icon.component.ts +27 -0
- package/src/components/icons/puzzle-icon.component.ts +27 -0
- package/src/components/icons/refresh-icon.component.ts +27 -0
- package/src/components/icons/star-icon.component.ts +27 -0
- package/src/components/icons/sun-icon.component.ts +27 -0
- package/src/components/icons/terminal-icon.component.ts +27 -0
- package/src/components/icons/toggle-left-icon.component.ts +27 -0
- package/src/components/icons/translate-icon.component.ts +23 -0
- package/src/components/icons/trash-icon.component.ts +23 -0
- package/src/components/icons/users-icon.component.ts +27 -0
- package/src/components/input/input.component.ts +67 -0
- package/src/components/link-button/link-button.component.scss +36 -0
- package/src/components/link-button/link-button.component.ts +29 -0
- package/src/components/select/select.component.scss +162 -0
- package/src/components/select/select.component.ts +127 -0
- package/src/components/tool-button/tool-button.component.scss +67 -0
- package/src/components/tool-button/tool-button.component.ts +126 -0
- package/src/components/toolbar-tool/toolbar-tool.component.scss +9 -0
- package/src/components/toolbar-tool/toolbar-tool.component.ts +169 -0
- package/src/components/toolbar-tool/toolbar-tool.models.ts +33 -0
- package/src/components/window/window.component.scss +95 -0
- package/src/components/window/window.component.ts +69 -0
- package/src/dev-toolbar-state.service.ts +89 -0
- package/src/dev-toolbar.component.scss +22 -0
- package/src/dev-toolbar.component.ts +105 -0
- package/src/index.ts +10 -0
- package/src/models/dev-tools.interface.ts +19 -0
- package/src/styles.scss +342 -0
- package/src/test-setup.ts +12 -0
- package/src/tools/feature-flags-tool/feature-flags-internal.service.ts +96 -0
- package/src/tools/feature-flags-tool/feature-flags-tool.component.ts +261 -0
- package/src/tools/feature-flags-tool/feature-flags.models.ts +10 -0
- package/src/tools/feature-flags-tool/feature-flags.service.ts +28 -0
- package/src/tools/home-tool/home-tool.component.scss +67 -0
- package/src/tools/home-tool/home-tool.component.ts +197 -0
- package/{tools/settings-tool/settings.models.d.ts → src/tools/home-tool/settings.models.ts} +1 -1
- package/src/tools/home-tool/settings.service.spec.ts +59 -0
- package/src/tools/home-tool/settings.service.ts +21 -0
- package/src/tools/language-tool/language-internal.service.ts +51 -0
- package/src/tools/language-tool/language-tool.component.scss +7 -0
- package/src/tools/language-tool/language-tool.component.ts +71 -0
- package/src/tools/language-tool/language.models.ts +4 -0
- package/src/tools/language-tool/language.service.ts +26 -0
- package/src/utils/storage.service.spec.ts +179 -0
- package/src/utils/storage.service.ts +80 -0
- package/tsconfig.json +28 -0
- package/tsconfig.lib.json +28 -0
- package/tsconfig.lib.prod.json +9 -0
- package/tsconfig.spec.json +29 -0
- package/vite.config.mts +27 -0
- package/components/button/button.component.d.ts +0 -12
- package/components/icons/angular-icon.component.d.ts +0 -5
- package/components/icons/bug-icon.component.d.ts +0 -6
- package/components/icons/code-icon.component.d.ts +0 -6
- package/components/icons/database-icon.component.d.ts +0 -6
- package/components/icons/gauge-icon.component.d.ts +0 -6
- package/components/icons/gear-icon.component.d.ts +0 -6
- package/components/icons/git-branch-icon.component.d.ts +0 -6
- package/components/icons/icon.component.d.ts +0 -9
- package/components/icons/icon.models.d.ts +0 -1
- package/components/icons/layout-icon.component.d.ts +0 -6
- package/components/icons/lighting-icon.component.d.ts +0 -6
- package/components/icons/moon-icon.component.d.ts +0 -6
- package/components/icons/network-icon.component.d.ts +0 -6
- package/components/icons/puzzle-icon.component.d.ts +0 -6
- package/components/icons/refresh-icon.component.d.ts +0 -6
- package/components/icons/star-icon.component.d.ts +0 -6
- package/components/icons/sun-icon.component.d.ts +0 -6
- package/components/icons/terminal-icon.component.d.ts +0 -6
- package/components/icons/toggle-left-icon.component.d.ts +0 -6
- package/components/icons/users-icon.component.d.ts +0 -6
- package/components/input/input.component.d.ts +0 -10
- package/components/select/select.component.d.ts +0 -14
- package/components/tool-button/tool-button.component.d.ts +0 -23
- package/components/toolbar-tool/toolbar-tool.component.d.ts +0 -28
- package/components/window/window.component.d.ts +0 -16
- package/components/window/window.models.d.ts +0 -20
- package/dev-toolbar-state.service.d.ts +0 -18
- package/dev-toolbar.component.d.ts +0 -17
- package/fesm2022/ngx-dev-toolbar.mjs +0 -2073
- package/fesm2022/ngx-dev-toolbar.mjs.map +0 -1
- package/index.d.ts +0 -3
- package/tools/feature-flags-tool/feature-flags-tool.component.d.ts +0 -33
- package/tools/feature-flags-tool/feature-flags.models.d.ts +0 -9
- package/tools/feature-flags-tool/feature-flags.service.d.ts +0 -35
- package/tools/settings-tool/settings-tool.component.d.ts +0 -15
- package/tools/settings-tool/settings.service.d.ts +0 -10
- package/utils/storage.service.d.ts +0 -9
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Component({
|
|
4
|
+
selector: 'ndt-toggle-left-icon',
|
|
5
|
+
standalone: true,
|
|
6
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
7
|
+
template: `
|
|
8
|
+
<svg
|
|
9
|
+
[attr.fill]="fill()"
|
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
+
width="24"
|
|
12
|
+
height="24"
|
|
13
|
+
viewBox="0 0 256 256"
|
|
14
|
+
>
|
|
15
|
+
<path
|
|
16
|
+
d="M112,128A32,32,0,1,1,80,96,32,32,0,0,1,112,128Z"
|
|
17
|
+
opacity="0.2"
|
|
18
|
+
></path>
|
|
19
|
+
<path
|
|
20
|
+
d="M176,56H80a72,72,0,0,0,0,144h96a72,72,0,0,0,0-144Zm0,128H80A56,56,0,0,1,80,72h96a56,56,0,0,1,0,112ZM80,88a40,40,0,1,0,40,40A40,40,0,0,0,80,88Zm0,64a24,24,0,1,1,24-24A24,24,0,0,1,80,152Z"
|
|
21
|
+
></path>
|
|
22
|
+
</svg>
|
|
23
|
+
`,
|
|
24
|
+
})
|
|
25
|
+
export class ToggleLeftIconComponent {
|
|
26
|
+
fill = input<string>('#FFFF');
|
|
27
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Component({
|
|
4
|
+
selector: 'ndt-translate-icon',
|
|
5
|
+
standalone: true,
|
|
6
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
7
|
+
template: `
|
|
8
|
+
<svg
|
|
9
|
+
[attr.fill]="fill()"
|
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
+
width="24"
|
|
12
|
+
height="24"
|
|
13
|
+
viewBox="0 0 256 256"
|
|
14
|
+
>
|
|
15
|
+
<path
|
|
16
|
+
d="M250.73,210.63l-56-112a12,12,0,0,0-21.46,0l-20.52,41A84.2,84.2,0,0,1,114,126.22,107.48,107.48,0,0,0,139.33,68H160a12,12,0,0,0,0-24H108V32a12,12,0,0,0-24,0V44H32a12,12,0,0,0,0,24h83.13A83.69,83.69,0,0,1,96,110.35,84,84,0,0,1,83.6,91a12,12,0,1,0-21.81,10A107.55,107.55,0,0,0,78,126.24,83.54,83.54,0,0,1,32,140a12,12,0,0,0,0,24,107.47,107.47,0,0,0,64-21.07,108.4,108.4,0,0,0,45.39,19.44l-24.13,48.26a12,12,0,1,0,21.46,10.73L151.41,196h65.17l12.68,25.36a12,12,0,1,0,21.47-10.73ZM163.41,172,184,130.83,204.58,172Z"
|
|
17
|
+
></path>
|
|
18
|
+
</svg>
|
|
19
|
+
`,
|
|
20
|
+
})
|
|
21
|
+
export class TranslateIconComponent {
|
|
22
|
+
fill = input<string>('#FFFF');
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Component({
|
|
4
|
+
selector: 'ndt-trash-icon',
|
|
5
|
+
standalone: true,
|
|
6
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
7
|
+
template: `
|
|
8
|
+
<svg
|
|
9
|
+
[attr.fill]="fill()"
|
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
+
width="24"
|
|
12
|
+
height="24"
|
|
13
|
+
viewBox="0 0 256 256"
|
|
14
|
+
>
|
|
15
|
+
<path
|
|
16
|
+
d="M216,48H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v8H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM96,40a8,8,0,0,1,8-8h48a8,8,0,0,1,8,8v8H96Zm96,168H64V64H192ZM112,104v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm48,0v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Z"
|
|
17
|
+
></path>
|
|
18
|
+
</svg>
|
|
19
|
+
`,
|
|
20
|
+
})
|
|
21
|
+
export class TrashIconComponent {
|
|
22
|
+
fill = input<string>('#FFFF');
|
|
23
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Component({
|
|
4
|
+
selector: 'ndt-users-icon',
|
|
5
|
+
standalone: true,
|
|
6
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
7
|
+
template: `
|
|
8
|
+
<svg
|
|
9
|
+
[attr.fill]="fill()"
|
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
+
width="24"
|
|
12
|
+
height="24"
|
|
13
|
+
viewBox="0 0 256 256"
|
|
14
|
+
>
|
|
15
|
+
<path
|
|
16
|
+
d="M224,128a95.76,95.76,0,0,1-31.8,71.37A72,72,0,0,0,128,160a40,40,0,1,0-40-40,40,40,0,0,0,40,40,72,72,0,0,0-64.2,39.37h0A96,96,0,1,1,224,128Z"
|
|
17
|
+
opacity="0.2"
|
|
18
|
+
></path>
|
|
19
|
+
<path
|
|
20
|
+
d="M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24ZM74.08,197.5a64,64,0,0,1,107.84,0,87.83,87.83,0,0,1-107.84,0ZM96,120a32,32,0,1,1,32,32A32,32,0,0,1,96,120Zm97.76,66.41a79.66,79.66,0,0,0-36.06-28.75,48,48,0,1,0-59.4,0,79.66,79.66,0,0,0-36.06,28.75,88,88,0,1,1,131.52,0Z"
|
|
21
|
+
></path>
|
|
22
|
+
</svg>
|
|
23
|
+
`,
|
|
24
|
+
})
|
|
25
|
+
export class UsersIconComponent {
|
|
26
|
+
fill = input<string>('#FFFF');
|
|
27
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
input,
|
|
5
|
+
model,
|
|
6
|
+
} from '@angular/core';
|
|
7
|
+
import { FormsModule } from '@angular/forms';
|
|
8
|
+
|
|
9
|
+
@Component({
|
|
10
|
+
selector: 'ndt-input',
|
|
11
|
+
standalone: true,
|
|
12
|
+
imports: [FormsModule],
|
|
13
|
+
template: `
|
|
14
|
+
<input
|
|
15
|
+
[attr.aria-label]="ariaLabel()"
|
|
16
|
+
[type]="type()"
|
|
17
|
+
[class]="inputClass()"
|
|
18
|
+
[ngModel]="value()"
|
|
19
|
+
[placeholder]="placeholder()"
|
|
20
|
+
(ngModelChange)="value.set($event)"
|
|
21
|
+
/>
|
|
22
|
+
`,
|
|
23
|
+
styles: [
|
|
24
|
+
`
|
|
25
|
+
:host {
|
|
26
|
+
display: block;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.input {
|
|
30
|
+
width: 100%;
|
|
31
|
+
padding: var(--ndt-spacing-sm) var(--ndt-spacing-md);
|
|
32
|
+
border: 1px solid var(--ndt-border-primary);
|
|
33
|
+
border-radius: var(--ndt-border-radius-small);
|
|
34
|
+
background-color: var(--ndt-bg-primary);
|
|
35
|
+
color: var(--ndt-text-primary);
|
|
36
|
+
font-size: var(--ndt-font-size-sm);
|
|
37
|
+
transition: var(--ndt-transition-default);
|
|
38
|
+
box-sizing: border-box;
|
|
39
|
+
|
|
40
|
+
&::placeholder {
|
|
41
|
+
color: var(--ndt-text-muted);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&:focus {
|
|
45
|
+
outline: none;
|
|
46
|
+
border-color: var(--ndt-primary);
|
|
47
|
+
box-shadow: 0 0 0 2px rgba(var(--ndt-primary-rgb), 0.2);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&:disabled {
|
|
51
|
+
background-color: var(--ndt-bg-secondary);
|
|
52
|
+
cursor: not-allowed;
|
|
53
|
+
color: var(--ndt-text-muted);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
`,
|
|
57
|
+
],
|
|
58
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
59
|
+
})
|
|
60
|
+
export class DevToolbarInputComponent {
|
|
61
|
+
value = model.required<string>();
|
|
62
|
+
|
|
63
|
+
type = input<string>('text');
|
|
64
|
+
placeholder = input<string>('');
|
|
65
|
+
ariaLabel = input<string>('');
|
|
66
|
+
inputClass = input<string>('input');
|
|
67
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
.link-button {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
align-items: center;
|
|
5
|
+
gap: var(--ndt-spacing-xs);
|
|
6
|
+
text-decoration: none;
|
|
7
|
+
color: var(--ndt-text-muted);
|
|
8
|
+
transition: var(--ndt-transition-default);
|
|
9
|
+
|
|
10
|
+
&:hover {
|
|
11
|
+
color: var(--ndt-text-primary);
|
|
12
|
+
|
|
13
|
+
.link-button__icon {
|
|
14
|
+
outline: 2px solid var(--ndt-primary);
|
|
15
|
+
outline-offset: 2px;
|
|
16
|
+
box-shadow: 0 0 8px var(--ndt-primary);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&__icon {
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
width: 40px;
|
|
25
|
+
height: 40px;
|
|
26
|
+
border-radius: var(--ndt-border-radius-medium);
|
|
27
|
+
background: var(--ndt-hover-bg);
|
|
28
|
+
transition: all 0.2s ease-in-out;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&__text {
|
|
32
|
+
font-size: var(--ndt-font-size-xs);
|
|
33
|
+
text-align: center;
|
|
34
|
+
white-space: nowrap;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Component, input } from '@angular/core';
|
|
2
|
+
import { DevToolbarIconComponent } from '../icons/icon.component';
|
|
3
|
+
import { IconName } from '../icons/icon.models';
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
selector: 'ndt-link-button',
|
|
7
|
+
standalone: true,
|
|
8
|
+
imports: [DevToolbarIconComponent],
|
|
9
|
+
template: `
|
|
10
|
+
<a
|
|
11
|
+
[href]="url()"
|
|
12
|
+
target="_blank"
|
|
13
|
+
rel="noopener noreferrer"
|
|
14
|
+
class="link-button"
|
|
15
|
+
>
|
|
16
|
+
<div class="link-button__icon">
|
|
17
|
+
<ndt-icon [name]="icon()" />
|
|
18
|
+
</div>
|
|
19
|
+
<span class="link-button__text">
|
|
20
|
+
<ng-content></ng-content>
|
|
21
|
+
</span>
|
|
22
|
+
</a>
|
|
23
|
+
`,
|
|
24
|
+
styleUrls: ['./link-button.component.scss'],
|
|
25
|
+
})
|
|
26
|
+
export class DevToolbarLinkButtonComponent {
|
|
27
|
+
readonly url = input.required<string>();
|
|
28
|
+
readonly icon = input.required<IconName>();
|
|
29
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
@use '../../styles' as devtools;
|
|
2
|
+
@use 'sass:map';
|
|
3
|
+
|
|
4
|
+
.select {
|
|
5
|
+
position: relative;
|
|
6
|
+
width: 100%;
|
|
7
|
+
min-width: 120px;
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: space-between;
|
|
11
|
+
padding: var(--ndt-spacing-sm) var(--ndt-spacing-md);
|
|
12
|
+
border: 1px solid var(--ndt-border-primary);
|
|
13
|
+
border-radius: var(--ndt-border-radius-small);
|
|
14
|
+
background-color: var(--ndt-bg-primary);
|
|
15
|
+
color: var(--ndt-text-primary);
|
|
16
|
+
font-size: var(--ndt-font-size-sm);
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
user-select: none;
|
|
19
|
+
transition: var(--ndt-transition-default);
|
|
20
|
+
outline: none;
|
|
21
|
+
height: 32px;
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
|
|
24
|
+
&:hover {
|
|
25
|
+
background-color: var(--ndt-hover-bg);
|
|
26
|
+
border-color: var(--ndt-primary);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&:focus-visible {
|
|
30
|
+
outline: none;
|
|
31
|
+
border-color: var(--ndt-primary);
|
|
32
|
+
box-shadow: 0 0 0 2px rgba(var(--ndt-primary-rgb), 0.2);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&.small {
|
|
36
|
+
padding: var(--ndt-spacing-xs) var(--ndt-spacing-sm);
|
|
37
|
+
font-size: var(--ndt-font-size-sm);
|
|
38
|
+
height: 24px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&.open {
|
|
42
|
+
border-color: var(--ndt-primary);
|
|
43
|
+
box-shadow: 0 0 0 2px rgba(var(--ndt-primary-rgb), 0.2);
|
|
44
|
+
|
|
45
|
+
.select__arrow {
|
|
46
|
+
transform: rotate(180deg);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&__value {
|
|
51
|
+
flex: 1;
|
|
52
|
+
white-space: nowrap;
|
|
53
|
+
overflow: hidden;
|
|
54
|
+
text-overflow: ellipsis;
|
|
55
|
+
line-height: 1;
|
|
56
|
+
margin-right: var(--ndt-spacing-sm);
|
|
57
|
+
min-width: 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
&__arrow {
|
|
61
|
+
width: 16px;
|
|
62
|
+
height: 16px;
|
|
63
|
+
flex-shrink: 0;
|
|
64
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
|
|
65
|
+
background-repeat: no-repeat;
|
|
66
|
+
background-position: center;
|
|
67
|
+
background-size: contain;
|
|
68
|
+
transition: transform 0.2s ease;
|
|
69
|
+
opacity: 0.9;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.select-menu {
|
|
74
|
+
display: inline-flex;
|
|
75
|
+
flex-direction: column;
|
|
76
|
+
min-width: 180px;
|
|
77
|
+
background-color: var(--ndt-bg-primary);
|
|
78
|
+
padding: var(--ndt-spacing-xs) 0;
|
|
79
|
+
border: 1px solid var(--ndt-border-primary);
|
|
80
|
+
border-radius: var(--ndt-border-radius-small);
|
|
81
|
+
box-shadow: var(--ndt-shadow-window);
|
|
82
|
+
color: var(--ndt-text-primary);
|
|
83
|
+
max-height: min(400px, 70vh);
|
|
84
|
+
overflow-y: auto;
|
|
85
|
+
backdrop-filter: blur(8px);
|
|
86
|
+
|
|
87
|
+
/* Scrollbar Styles */
|
|
88
|
+
&::-webkit-scrollbar {
|
|
89
|
+
width: 8px;
|
|
90
|
+
height: 8px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
&::-webkit-scrollbar-track {
|
|
94
|
+
background: transparent;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
&::-webkit-scrollbar-thumb {
|
|
98
|
+
background-color: var(--ndt-border-primary);
|
|
99
|
+
border-radius: 4px;
|
|
100
|
+
border: 2px solid var(--ndt-bg-primary);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.select-menu-item {
|
|
105
|
+
background-color: transparent;
|
|
106
|
+
cursor: pointer;
|
|
107
|
+
border: none;
|
|
108
|
+
color: inherit;
|
|
109
|
+
user-select: none;
|
|
110
|
+
min-width: 64px;
|
|
111
|
+
line-height: 36px;
|
|
112
|
+
padding: 0 var(--ndt-spacing-md);
|
|
113
|
+
display: flex;
|
|
114
|
+
align-items: center;
|
|
115
|
+
flex-direction: row;
|
|
116
|
+
flex: 1;
|
|
117
|
+
font-size: var(--ndt-font-size-sm);
|
|
118
|
+
font-family: inherit;
|
|
119
|
+
position: relative;
|
|
120
|
+
white-space: nowrap;
|
|
121
|
+
text-overflow: ellipsis;
|
|
122
|
+
overflow: hidden;
|
|
123
|
+
|
|
124
|
+
&:hover {
|
|
125
|
+
background-color: var(--ndt-hover-bg);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&:active {
|
|
129
|
+
background-color: rgba(var(--ndt-primary-rgb), 0.15);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
&.selected {
|
|
133
|
+
color: var(--ndt-primary);
|
|
134
|
+
background-color: rgba(var(--ndt-primary-rgb), 0.1);
|
|
135
|
+
font-weight: 500;
|
|
136
|
+
|
|
137
|
+
&:hover {
|
|
138
|
+
background-color: rgba(var(--ndt-primary-rgb), 0.15);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
&::before {
|
|
142
|
+
content: '';
|
|
143
|
+
position: absolute;
|
|
144
|
+
left: 0;
|
|
145
|
+
top: 8px;
|
|
146
|
+
width: 3px;
|
|
147
|
+
height: calc(100% - 16px);
|
|
148
|
+
background-color: var(--ndt-primary);
|
|
149
|
+
border-radius: 2px;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
&:focus-visible {
|
|
154
|
+
outline: none;
|
|
155
|
+
background-color: var(--ndt-hover-bg);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Ensure proper theme inheritance in overlay
|
|
160
|
+
.select-overlay {
|
|
161
|
+
backdrop-filter: blur(8px);
|
|
162
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { CdkMenuModule } from '@angular/cdk/menu';
|
|
2
|
+
import { ConnectedPosition, OverlayModule } from '@angular/cdk/overlay';
|
|
3
|
+
import { CommonModule } from '@angular/common';
|
|
4
|
+
import {
|
|
5
|
+
ChangeDetectionStrategy,
|
|
6
|
+
Component,
|
|
7
|
+
computed,
|
|
8
|
+
inject,
|
|
9
|
+
input,
|
|
10
|
+
model,
|
|
11
|
+
signal,
|
|
12
|
+
} from '@angular/core';
|
|
13
|
+
import { FormsModule } from '@angular/forms';
|
|
14
|
+
import { DevToolbarStateService } from '../../dev-toolbar-state.service';
|
|
15
|
+
|
|
16
|
+
export interface SelectOption {
|
|
17
|
+
value: string;
|
|
18
|
+
label: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@Component({
|
|
22
|
+
selector: 'ndt-select',
|
|
23
|
+
standalone: true,
|
|
24
|
+
imports: [CommonModule, FormsModule, OverlayModule, CdkMenuModule],
|
|
25
|
+
template: `
|
|
26
|
+
<div
|
|
27
|
+
class="dev-toolbar select"
|
|
28
|
+
[class.small]="size() === 'small'"
|
|
29
|
+
[class.open]="isOpen()"
|
|
30
|
+
[attr.aria-label]="ariaLabel()"
|
|
31
|
+
[attr.aria-expanded]="isOpen()"
|
|
32
|
+
[attr.aria-controls]="selectMenuId"
|
|
33
|
+
[attr.data-theme]="theme()"
|
|
34
|
+
cdkOverlayOrigin
|
|
35
|
+
#trigger="cdkOverlayOrigin"
|
|
36
|
+
(click)="toggle()"
|
|
37
|
+
(keydown.enter)="toggle()"
|
|
38
|
+
(keydown.space)="toggle()"
|
|
39
|
+
tabindex="0"
|
|
40
|
+
role="combobox"
|
|
41
|
+
>
|
|
42
|
+
<span class="select__value">{{ selectedLabel() }}</span>
|
|
43
|
+
<span class="select__arrow" aria-hidden="true"></span>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<ng-template
|
|
47
|
+
cdkConnectedOverlay
|
|
48
|
+
[cdkConnectedOverlayOrigin]="trigger"
|
|
49
|
+
[cdkConnectedOverlayOpen]="isOpen()"
|
|
50
|
+
[cdkConnectedOverlayPositions]="positions"
|
|
51
|
+
(overlayOutsideClick)="close()"
|
|
52
|
+
>
|
|
53
|
+
<div
|
|
54
|
+
[id]="selectMenuId"
|
|
55
|
+
class="dev-toolbar select-menu"
|
|
56
|
+
cdkMenu
|
|
57
|
+
role="listbox"
|
|
58
|
+
[attr.data-theme]="theme()"
|
|
59
|
+
>
|
|
60
|
+
@for (option of options(); track option.value) {
|
|
61
|
+
<button
|
|
62
|
+
class="select-menu-item"
|
|
63
|
+
[class.selected]="option.value === value()"
|
|
64
|
+
[attr.aria-selected]="option.value === value()"
|
|
65
|
+
cdkMenuItem
|
|
66
|
+
type="button"
|
|
67
|
+
(click)="selectOption(option)"
|
|
68
|
+
>
|
|
69
|
+
{{ option.label }}
|
|
70
|
+
</button>
|
|
71
|
+
}
|
|
72
|
+
</div>
|
|
73
|
+
</ng-template>
|
|
74
|
+
`,
|
|
75
|
+
styleUrls: ['./select.component.scss'],
|
|
76
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
77
|
+
})
|
|
78
|
+
export class DevToolbarSelectComponent {
|
|
79
|
+
readonly devToolbarStateService = inject(DevToolbarStateService);
|
|
80
|
+
|
|
81
|
+
value = model<string>();
|
|
82
|
+
options = input.required<SelectOption[]>();
|
|
83
|
+
ariaLabel = input<string>('');
|
|
84
|
+
label = input<string>('');
|
|
85
|
+
size = input<'small' | 'medium'>('medium');
|
|
86
|
+
readonly theme = computed(() => this.devToolbarStateService.theme());
|
|
87
|
+
|
|
88
|
+
protected readonly selectMenuId = `select-menu-${Math.random()
|
|
89
|
+
.toString(36)
|
|
90
|
+
.slice(2, 11)}`;
|
|
91
|
+
isOpen = signal(false);
|
|
92
|
+
|
|
93
|
+
selectedLabel = computed(() => {
|
|
94
|
+
const selected = this.options()?.find((opt) => opt.value === this.value());
|
|
95
|
+
return selected?.label ?? '';
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
positions: ConnectedPosition[] = [
|
|
99
|
+
{
|
|
100
|
+
originX: 'end',
|
|
101
|
+
originY: 'bottom',
|
|
102
|
+
overlayX: 'end',
|
|
103
|
+
overlayY: 'top',
|
|
104
|
+
offsetY: 4,
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
originX: 'end',
|
|
108
|
+
originY: 'top',
|
|
109
|
+
overlayX: 'end',
|
|
110
|
+
overlayY: 'bottom',
|
|
111
|
+
offsetY: -4,
|
|
112
|
+
},
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
toggle() {
|
|
116
|
+
this.isOpen.update((v) => !v);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
close() {
|
|
120
|
+
this.isOpen.set(false);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
selectOption(option: SelectOption) {
|
|
124
|
+
this.value.set(option.value);
|
|
125
|
+
this.close();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
@use '../../styles' as devtools;
|
|
2
|
+
@use 'sass:map';
|
|
3
|
+
$dimensions: devtools.$dimensions;
|
|
4
|
+
|
|
5
|
+
.tool-button {
|
|
6
|
+
display: flex;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
align-items: center;
|
|
9
|
+
width: map.get($dimensions, toolbar-button-width);
|
|
10
|
+
height: map.get($dimensions, toolbar-height);
|
|
11
|
+
border: 0;
|
|
12
|
+
background: transparent;
|
|
13
|
+
color: var(--ndt-text-primary);
|
|
14
|
+
transition: var(--ndt-transition-default);
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
opacity: 0.5;
|
|
17
|
+
position: relative;
|
|
18
|
+
|
|
19
|
+
&--active {
|
|
20
|
+
background: var(--ndt-hover-bg);
|
|
21
|
+
opacity: 1;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&:hover {
|
|
25
|
+
background: var(--ndt-hover-bg);
|
|
26
|
+
opacity: 1;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
::ng-deep svg {
|
|
30
|
+
width: 24px;
|
|
31
|
+
height: 24px;
|
|
32
|
+
display: block;
|
|
33
|
+
margin: auto;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&__badge {
|
|
37
|
+
position: absolute;
|
|
38
|
+
top: -0.25rem;
|
|
39
|
+
right: -0.25rem;
|
|
40
|
+
background-color: var(--ndt-hover-danger);
|
|
41
|
+
color: var(--ndt-text-primary);
|
|
42
|
+
border-radius: var(--ndt-border-radius-full);
|
|
43
|
+
min-width: 1rem;
|
|
44
|
+
height: 1rem;
|
|
45
|
+
font-size: 0.75rem;
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
justify-content: center;
|
|
49
|
+
padding: 0.125rem;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.tooltip {
|
|
54
|
+
position: absolute;
|
|
55
|
+
bottom: calc(100% + 1.2rem);
|
|
56
|
+
left: 50%;
|
|
57
|
+
transform: translateX(-50%);
|
|
58
|
+
background: var(--ndt-bg-primary);
|
|
59
|
+
color: var(--ndt-text-primary);
|
|
60
|
+
padding: 0.5rem 0.75rem;
|
|
61
|
+
border-radius: var(--ndt-border-radius-medium);
|
|
62
|
+
font-size: 0.75rem;
|
|
63
|
+
white-space: nowrap;
|
|
64
|
+
pointer-events: none;
|
|
65
|
+
z-index: 1000;
|
|
66
|
+
box-shadow: var(--ndt-shadow-tooltip);
|
|
67
|
+
}
|