mirror of
https://github.com/bitwarden/clients.git
synced 2026-01-31 14:23:38 +08:00
Merge branch 'main' into BRE-1531-add-ability-to-build-web-with-custom-sdk-branch
This commit is contained in:
26
.github/workflows/build-desktop.yml
vendored
26
.github/workflows/build-desktop.yml
vendored
@@ -236,7 +236,7 @@ jobs:
|
||||
npm link ../sdk-internal
|
||||
|
||||
- name: Cache Native Module
|
||||
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
|
||||
uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
|
||||
id: cache
|
||||
with:
|
||||
path: |
|
||||
@@ -399,7 +399,7 @@ jobs:
|
||||
npm link ../sdk-internal
|
||||
|
||||
- name: Cache Native Module
|
||||
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
|
||||
uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
|
||||
id: cache
|
||||
with:
|
||||
path: |
|
||||
@@ -562,7 +562,7 @@ jobs:
|
||||
npm link ../sdk-internal
|
||||
|
||||
- name: Cache Native Module
|
||||
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
|
||||
uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
|
||||
id: cache
|
||||
with:
|
||||
path: |
|
||||
@@ -827,7 +827,7 @@ jobs:
|
||||
npm link ../sdk-internal
|
||||
|
||||
- name: Cache Native Module
|
||||
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
|
||||
uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
|
||||
id: cache
|
||||
with:
|
||||
path: |
|
||||
@@ -1032,14 +1032,14 @@ jobs:
|
||||
|
||||
- name: Cache Build
|
||||
id: build-cache
|
||||
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
|
||||
uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
|
||||
with:
|
||||
path: apps/desktop/build
|
||||
key: ${{ runner.os }}-${{ github.run_id }}-build
|
||||
|
||||
- name: Cache Safari
|
||||
id: safari-cache
|
||||
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
|
||||
uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
|
||||
with:
|
||||
path: apps/browser/dist/Safari
|
||||
key: ${{ runner.os }}-${{ github.run_id }}-safari-extension
|
||||
@@ -1185,7 +1185,7 @@ jobs:
|
||||
npm link ../sdk-internal
|
||||
|
||||
- name: Cache Native Module
|
||||
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
|
||||
uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
|
||||
id: cache
|
||||
with:
|
||||
path: |
|
||||
@@ -1272,14 +1272,14 @@ jobs:
|
||||
|
||||
- name: Get Build Cache
|
||||
id: build-cache
|
||||
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
|
||||
uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
|
||||
with:
|
||||
path: apps/desktop/build
|
||||
key: ${{ runner.os }}-${{ github.run_id }}-build
|
||||
|
||||
- name: Setup Safari Cache
|
||||
id: safari-cache
|
||||
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
|
||||
uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
|
||||
with:
|
||||
path: apps/browser/dist/Safari
|
||||
key: ${{ runner.os }}-${{ github.run_id }}-safari-extension
|
||||
@@ -1409,7 +1409,7 @@ jobs:
|
||||
npm link ../sdk-internal
|
||||
|
||||
- name: Cache Native Module
|
||||
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
|
||||
uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
|
||||
id: cache
|
||||
with:
|
||||
path: |
|
||||
@@ -1547,14 +1547,14 @@ jobs:
|
||||
|
||||
- name: Get Build Cache
|
||||
id: build-cache
|
||||
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
|
||||
uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
|
||||
with:
|
||||
path: apps/desktop/build
|
||||
key: ${{ runner.os }}-${{ github.run_id }}-build
|
||||
|
||||
- name: Setup Safari Cache
|
||||
id: safari-cache
|
||||
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
|
||||
uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
|
||||
with:
|
||||
path: apps/browser/dist/Safari
|
||||
key: ${{ runner.os }}-${{ github.run_id }}-safari-extension
|
||||
@@ -1692,7 +1692,7 @@ jobs:
|
||||
npm link ../sdk-internal
|
||||
|
||||
- name: Cache Native Module
|
||||
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
|
||||
uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
|
||||
id: cache
|
||||
with:
|
||||
path: |
|
||||
|
||||
2
.github/workflows/chromatic.yml
vendored
2
.github/workflows/chromatic.yml
vendored
@@ -65,7 +65,7 @@ jobs:
|
||||
|
||||
- name: Cache NPM
|
||||
id: npm-cache
|
||||
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
|
||||
uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
|
||||
with:
|
||||
path: "~/.npm"
|
||||
key: ${{ runner.os }}-npm-chromatic-${{ hashFiles('**/package-lock.json') }}
|
||||
|
||||
@@ -166,5 +166,13 @@ describe("EmergencyViewDialogComponent", () => {
|
||||
|
||||
expect(component["title"]).toBe("viewItemHeaderNote");
|
||||
});
|
||||
|
||||
it("sets ssh key title", () => {
|
||||
mockCipher.type = CipherType.SshKey;
|
||||
|
||||
component["updateTitle"]();
|
||||
|
||||
expect(component["title"]).toBe("viewItemHeaderSshKey");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -90,6 +90,9 @@ export class EmergencyViewDialogComponent {
|
||||
case CipherType.SecureNote:
|
||||
this.title = this.i18nService.t("viewItemHeaderNote");
|
||||
break;
|
||||
case CipherType.SshKey:
|
||||
this.title = this.i18nService.t("viewItemHeaderSshKey");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
[ngClass]="{ 'tw-grayscale': disabled }"
|
||||
>
|
||||
<div class="tw-m-auto tw-size-20 tw-content-center">
|
||||
<bit-svg [content]="icon" aria-hidden="true"></bit-svg>
|
||||
<bit-svg [content]="icon" aria-hidden="true" class="tw-h-full"></bit-svg>
|
||||
</div>
|
||||
</div>
|
||||
<bit-card-content [ngClass]="{ 'tw-grayscale': disabled }">
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
title="{{ 'editItemWithName' | i18n: cipher.name }}"
|
||||
type="button"
|
||||
appStopProp
|
||||
aria-haspopup="true"
|
||||
aria-haspopup="dialog"
|
||||
>
|
||||
{{ cipher.name }}
|
||||
</button>
|
||||
|
||||
@@ -16,9 +16,9 @@ import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
|
||||
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
|
||||
import { DrawerService } from "../drawer/drawer.service";
|
||||
import { isAtOrLargerThanBreakpoint } from "../utils/responsive-utils";
|
||||
|
||||
import { DrawerService } from "./drawer.service";
|
||||
import { SimpleConfigurableDialogComponent } from "./simple-dialog/simple-configurable-dialog/simple-configurable-dialog.component";
|
||||
import { SimpleDialogOptions } from "./simple-dialog/types";
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
import { CdkScrollable } from "@angular/cdk/scrolling";
|
||||
import { ChangeDetectionStrategy, Component } from "@angular/core";
|
||||
|
||||
import { hasScrolledFrom } from "../utils/has-scrolled-from";
|
||||
|
||||
/**
|
||||
* Body container for `bit-drawer`
|
||||
*/
|
||||
@Component({
|
||||
selector: "bit-drawer-body",
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
imports: [],
|
||||
host: {
|
||||
class:
|
||||
"tw-p-4 tw-pt-0 tw-flex-1 tw-overflow-auto tw-border-solid tw-border tw-border-transparent tw-transition-colors tw-duration-200",
|
||||
"[class.tw-border-t-secondary-300]": "this.hasScrolledFrom().top",
|
||||
},
|
||||
hostDirectives: [
|
||||
{
|
||||
directive: CdkScrollable,
|
||||
},
|
||||
],
|
||||
template: ` <ng-content></ng-content> `,
|
||||
})
|
||||
export class DrawerBodyComponent {
|
||||
protected hasScrolledFrom = hasScrolledFrom();
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
import { Directive, inject } from "@angular/core";
|
||||
|
||||
import { DrawerComponent } from "./drawer.component";
|
||||
|
||||
/**
|
||||
* Closes the ancestor drawer
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```html
|
||||
* <bit-drawer>
|
||||
* <button type="button" bitButton bitDrawerClose>Close</button>
|
||||
* </bit-drawer>
|
||||
* ```
|
||||
**/
|
||||
@Directive({
|
||||
selector: "button[bitDrawerClose]",
|
||||
host: {
|
||||
"(click)": "onClick()",
|
||||
},
|
||||
})
|
||||
export class DrawerCloseDirective {
|
||||
private drawer = inject(DrawerComponent, { optional: true });
|
||||
|
||||
protected onClick() {
|
||||
this.drawer?.open.set(false);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<header class="tw-flex tw-justify-between tw-items-center tw-gap-4">
|
||||
<div class="tw-flex tw-items-center tw-gap-4 tw-overflow-auto">
|
||||
<ng-content select="[slot=start]"></ng-content>
|
||||
<h2 bitTypography="h3" noMargin class="tw-text-main tw-mb-0 tw-truncate" [attr.title]="title()">
|
||||
{{ title() }}
|
||||
</h2>
|
||||
</div>
|
||||
<button bitIconButton="bwi-close" type="button" bitDrawerClose [label]="'close' | i18n"></button>
|
||||
</header>
|
||||
@@ -1,34 +0,0 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { ChangeDetectionStrategy, Component, HostBinding, input } from "@angular/core";
|
||||
|
||||
import { I18nPipe } from "@bitwarden/ui-common";
|
||||
|
||||
import { IconButtonModule } from "../icon-button";
|
||||
import { TypographyModule } from "../typography";
|
||||
|
||||
import { DrawerCloseDirective } from "./drawer-close.directive";
|
||||
|
||||
/**
|
||||
* Header container for `bit-drawer`
|
||||
**/
|
||||
@Component({
|
||||
selector: "bit-drawer-header",
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
imports: [CommonModule, DrawerCloseDirective, TypographyModule, IconButtonModule, I18nPipe],
|
||||
templateUrl: "drawer-header.component.html",
|
||||
host: {
|
||||
class: "tw-block tw-ps-4 tw-pe-2 tw-py-2",
|
||||
},
|
||||
})
|
||||
export class DrawerHeaderComponent {
|
||||
/**
|
||||
* The title to display
|
||||
*/
|
||||
readonly title = input.required<string>();
|
||||
|
||||
/** We don't want to set the HTML title attribute with `this.title` */
|
||||
@HostBinding("attr.title")
|
||||
protected get getTitle(): null {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
import { Portal } from "@angular/cdk/portal";
|
||||
import { Directive, signal } from "@angular/core";
|
||||
|
||||
/**
|
||||
* Host that renders a drawer
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
@Directive({
|
||||
selector: "[bitDrawerHost]",
|
||||
})
|
||||
export class DrawerHostDirective {
|
||||
private readonly _portal = signal<Portal<unknown> | undefined>(undefined);
|
||||
|
||||
/** The portal to display */
|
||||
portal = this._portal.asReadonly();
|
||||
|
||||
open(portal: Portal<unknown>) {
|
||||
this._portal.set(portal);
|
||||
}
|
||||
|
||||
close(portal: Portal<unknown>) {
|
||||
if (portal === this.portal()) {
|
||||
this._portal.set(undefined);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
<ng-container *cdkPortal>
|
||||
<section
|
||||
[attr.role]="role()"
|
||||
class="tw-w-[23rem] tw-sticky tw-top-0 tw-h-full tw-flex tw-flex-col tw-overflow-auto tw-border-0 tw-border-l tw-border-solid tw-border-secondary-300 tw-bg-background"
|
||||
>
|
||||
<ng-content></ng-content>
|
||||
</section>
|
||||
</ng-container>
|
||||
@@ -1,75 +0,0 @@
|
||||
import { CdkPortal, PortalModule } from "@angular/cdk/portal";
|
||||
import { CommonModule } from "@angular/common";
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
effect,
|
||||
inject,
|
||||
input,
|
||||
model,
|
||||
viewChild,
|
||||
} from "@angular/core";
|
||||
|
||||
import { DrawerService } from "./drawer.service";
|
||||
|
||||
/**
|
||||
* A drawer is a panel of supplementary content that is adjacent to the page's main content.
|
||||
*
|
||||
* Drawers render in `bit-layout`. Drawers must be a descendant of `bit-layout`, but they do not need to be a direct descendant.
|
||||
*/
|
||||
@Component({
|
||||
selector: "bit-drawer",
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
imports: [CommonModule, PortalModule],
|
||||
templateUrl: "drawer.component.html",
|
||||
})
|
||||
export class DrawerComponent {
|
||||
private drawerHost = inject(DrawerService);
|
||||
private readonly portal = viewChild.required(CdkPortal);
|
||||
|
||||
/**
|
||||
* Whether or not the drawer is open.
|
||||
*
|
||||
* Note: Does not support implicit boolean transform due to Angular limitation. Must be bound explicitly `[open]="true"` instead of just `open`.
|
||||
* https://github.com/angular/angular/issues/55166#issuecomment-2032150999
|
||||
**/
|
||||
readonly open = model<boolean>(false);
|
||||
|
||||
/**
|
||||
* The ARIA role of the drawer.
|
||||
*
|
||||
* - [complementary](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/complementary_role)
|
||||
* - For drawers that contain content that is complementary to the page's main content. (default)
|
||||
* - [navigation](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/navigation_role)
|
||||
* - For drawers that primary contain links to other content.
|
||||
*/
|
||||
readonly role = input<"complementary" | "navigation">("complementary");
|
||||
|
||||
constructor() {
|
||||
effect(
|
||||
() => {
|
||||
this.open() ? this.drawerHost.open(this.portal()) : this.drawerHost.close(this.portal());
|
||||
},
|
||||
{
|
||||
allowSignalWrites: true,
|
||||
},
|
||||
);
|
||||
|
||||
// Set `open` to `false` when another drawer is opened.
|
||||
effect(
|
||||
() => {
|
||||
if (this.drawerHost.portal() !== this.portal()) {
|
||||
this.open.set(false);
|
||||
}
|
||||
},
|
||||
{
|
||||
allowSignalWrites: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/** Toggle the drawer between open & closed */
|
||||
toggle() {
|
||||
this.open.update((prev) => !prev);
|
||||
}
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
import { Meta, Canvas, Primary, Controls } from "@storybook/addon-docs/blocks";
|
||||
|
||||
import * as stories from "./drawer.stories";
|
||||
|
||||
import { DrawerOpen as KitchenSink } from "../stories/kitchen-sink/kitchen-sink.stories";
|
||||
|
||||
<Meta of={stories} />
|
||||
|
||||
```ts
|
||||
import { DrawerComponent } from "@bitwarden/components";
|
||||
```
|
||||
|
||||
# Drawer
|
||||
|
||||
**Note: `bit-drawer` is deprecated. Use `bit-dialog` and `DialogService.openDrawer(...)` instead.**
|
||||
|
||||
A drawer is a panel of supplementary content that is adjacent to the page's main content.
|
||||
|
||||
<Primary />
|
||||
|
||||
<Controls />
|
||||
|
||||
## Usage
|
||||
|
||||
A `bit-drawer` in a template will not render inline, but rather will render adjacent to the main
|
||||
page content.
|
||||
|
||||
```html
|
||||
<bit-drawer [open]="true">
|
||||
<bit-drawer-header title="Hello Bitwaaaaaaaaaaaaaaaaaaaaaaaaarden!"></bit-drawer-header>
|
||||
<bit-drawer-body>
|
||||
<p>Lorem ipsum dolor...</p>
|
||||
</bit-drawer-body>
|
||||
</bit-drawer>
|
||||
```
|
||||
|
||||
`bit-drawer` must be a descendant of `bit-layout`, but it does not need to be a direct descendant.
|
||||
|
||||
## Header and body
|
||||
|
||||
Header and body content can be provided with the `bit-drawer-header` and `bit-drawer-body`
|
||||
components, respectively.
|
||||
|
||||
A title can be passed to the header by input:
|
||||
`<bit-drawer-header title="Foobar"></bit-drawer-header>`
|
||||
|
||||
Custom content can be rendered before the title with the header's `start` slot:
|
||||
|
||||
```html
|
||||
<bit-drawer-header title="Foobar">
|
||||
<i slot="start" class="bwi bwi-key" aria-hidden="true"></i>
|
||||
</bit-drawer-header>
|
||||
```
|
||||
|
||||
## Opening and closing
|
||||
|
||||
`bit-drawer` opens when its `open` input is `true`:
|
||||
|
||||
```html
|
||||
<bit-drawer [open]="true">...</bit-drawer>
|
||||
```
|
||||
|
||||
Note: Model inputs do not support implicit boolean transformation (see Angular reasoning
|
||||
[here](https://github.com/angular/angular/issues/55166#issuecomment-2032150999)). `open` must be
|
||||
bound explicitly `<bit-drawer [open]="true">` instead of just `<bit-drawer open>`.
|
||||
|
||||
Buttons can be made to open/toggle drawers by referencing a template variable, or by manipulating
|
||||
state that is bound to `open`:
|
||||
|
||||
```html
|
||||
<button (click)="myDrawer.toggle()"></button> <bit-drawer #myDrawer>...</bit-drawer>
|
||||
```
|
||||
|
||||
For convenience, close buttons can be created _inside_ the drawer with the `bitDrawerClose`
|
||||
directive:
|
||||
|
||||
```html
|
||||
<bit-drawer>
|
||||
<button type="button" bitDrawerClose>Close</button>
|
||||
</bit-drawer>
|
||||
```
|
||||
|
||||
## Multiple Drawers
|
||||
|
||||
Only one drawer can be open at a time, and they do not stack. If a drawer is already open, opening
|
||||
another will close and replace the one already open.
|
||||
|
||||
<Canvas of={stories.MultipleDrawers} />
|
||||
|
||||
## Headless
|
||||
|
||||
Omitting `bit-drawer-header` and `bit-drawer-body` allows for fully customizable content.
|
||||
|
||||
<Canvas of={stories.Headless} />
|
||||
|
||||
## Accessibility
|
||||
|
||||
- The drawer should contain an h2 element. If you are using `bit-drawer-header`, this is created for
|
||||
you via the `title` input:
|
||||
|
||||
```html
|
||||
<bit-drawer>
|
||||
<h2 bitTypography="h2">Hello world!</h2>
|
||||
</bit-drawer>
|
||||
|
||||
<!-- or -->
|
||||
|
||||
<bit-drawer>
|
||||
<bit-drawer-header title="Hello world!"></bit-drawer-header>
|
||||
</bit-drawer>
|
||||
```
|
||||
|
||||
- The ARIA role of the drawer can be set with the `role` attribute:
|
||||
- [complementary](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/complementary_role)
|
||||
(default)
|
||||
- For drawers that contain content that is complementary to the page's main content.
|
||||
- [navigation](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/navigation_role)
|
||||
- For drawers that primary contain links to other content.
|
||||
|
||||
## Kitchen Sink
|
||||
|
||||
<Canvas of={KitchenSink} autoplay />
|
||||
@@ -1,12 +0,0 @@
|
||||
import { NgModule } from "@angular/core";
|
||||
|
||||
import { DrawerBodyComponent } from "./drawer-body.component";
|
||||
import { DrawerCloseDirective } from "./drawer-close.directive";
|
||||
import { DrawerHeaderComponent } from "./drawer-header.component";
|
||||
import { DrawerComponent } from "./drawer.component";
|
||||
|
||||
@NgModule({
|
||||
imports: [DrawerComponent, DrawerHeaderComponent, DrawerBodyComponent, DrawerCloseDirective],
|
||||
exports: [DrawerComponent, DrawerHeaderComponent, DrawerBodyComponent, DrawerCloseDirective],
|
||||
})
|
||||
export class DrawerModule {}
|
||||
@@ -1,128 +0,0 @@
|
||||
import { RouterTestingModule } from "@angular/router/testing";
|
||||
import { Meta, StoryObj, applicationConfig, moduleMetadata } from "@storybook/angular";
|
||||
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { GlobalStateProvider } from "@bitwarden/state";
|
||||
|
||||
import { ButtonModule } from "../button";
|
||||
import { CalloutModule } from "../callout";
|
||||
import { LayoutComponent } from "../layout";
|
||||
import { mockLayoutI18n } from "../layout/mocks";
|
||||
import { positionFixedWrapperDecorator } from "../stories/storybook-decorators";
|
||||
import { TypographyModule } from "../typography";
|
||||
import { I18nMockService, StorybookGlobalStateProvider } from "../utils";
|
||||
|
||||
import { DrawerBodyComponent } from "./drawer-body.component";
|
||||
import { DrawerHeaderComponent } from "./drawer-header.component";
|
||||
import { DrawerComponent } from "./drawer.component";
|
||||
import { DrawerModule } from "./drawer.module";
|
||||
|
||||
export default {
|
||||
title: "Component Library/Drawer",
|
||||
component: DrawerComponent,
|
||||
subcomponents: {
|
||||
DrawerHeaderComponent,
|
||||
DrawerBodyComponent,
|
||||
},
|
||||
decorators: [
|
||||
positionFixedWrapperDecorator(),
|
||||
moduleMetadata({
|
||||
imports: [
|
||||
RouterTestingModule,
|
||||
LayoutComponent,
|
||||
DrawerModule,
|
||||
ButtonModule,
|
||||
CalloutModule,
|
||||
TypographyModule,
|
||||
],
|
||||
providers: [
|
||||
{
|
||||
provide: I18nService,
|
||||
useFactory: () => {
|
||||
return new I18nMockService({
|
||||
...mockLayoutI18n,
|
||||
close: "Close",
|
||||
loading: "Loading",
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
applicationConfig({
|
||||
providers: [
|
||||
{
|
||||
provide: GlobalStateProvider,
|
||||
useClass: StorybookGlobalStateProvider,
|
||||
},
|
||||
],
|
||||
}),
|
||||
],
|
||||
} as Meta<DrawerComponent>;
|
||||
|
||||
type Story = StoryObj<DrawerComponent>;
|
||||
|
||||
export const Default: Story = {
|
||||
render: (args) => ({
|
||||
props: args,
|
||||
template: /*html*/ `
|
||||
<bit-layout class="tw-text-main">
|
||||
<p>The drawer is {{ open ? "open" : "closed" }}.<p>
|
||||
<button type="button" bitButton (click)="drawer.toggle()">Toggle</button>
|
||||
|
||||
<!-- Note: bit-drawer does *not* need to be a direct descendant of bit-layout. -->
|
||||
<bit-drawer [(open)]="open" #drawer>
|
||||
<bit-drawer-header title="Hello Bitwaaaaaaaaaaaaaaaaaaaaaaaaarden!">
|
||||
<i slot="start" class="bwi bwi-key" aria-hidden="true"></i>
|
||||
</bit-drawer-header>
|
||||
<bit-drawer-body>
|
||||
<p bitTypography="body1">
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
||||
</p>
|
||||
</bit-drawer-body>
|
||||
</bit-drawer>
|
||||
</bit-layout>
|
||||
`,
|
||||
}),
|
||||
args: {
|
||||
open: true,
|
||||
},
|
||||
};
|
||||
|
||||
export const Headless: Story = {
|
||||
render: (args) => ({
|
||||
props: args,
|
||||
template: /*html*/ `
|
||||
<bit-layout class="tw-text-main">
|
||||
<p>The drawer is {{ open ? "open" : "closed" }}.<p>
|
||||
<button type="button" bitButton (click)="drawer.toggle()">Toggle</button>
|
||||
<bit-drawer [(open)]="open" #drawer>
|
||||
<h2 bitTypography="h2"></h2>
|
||||
Hello world!
|
||||
</bit-drawer>
|
||||
</bit-layout>
|
||||
`,
|
||||
}),
|
||||
args: {
|
||||
open: true,
|
||||
},
|
||||
};
|
||||
|
||||
export const MultipleDrawers: Story = {
|
||||
render: (args) => ({
|
||||
props: args,
|
||||
template: /*html*/ `
|
||||
<bit-layout class="tw-text-main">
|
||||
<button type="button" bitButton (click)="foo.toggle()">{{ !foo.open() ? "Open" : "Close" }} Foo</button>
|
||||
<button type="button" bitButton (click)="bar.toggle()">{{ !bar.open() ? "Open" : "Close" }} Bar</button>
|
||||
|
||||
<bit-drawer #foo>
|
||||
Foo
|
||||
</bit-drawer>
|
||||
|
||||
<bit-drawer #bar [open]="true">
|
||||
Bar
|
||||
</bit-drawer>
|
||||
</bit-layout>
|
||||
`,
|
||||
}),
|
||||
};
|
||||
@@ -1,5 +0,0 @@
|
||||
export * from "./drawer.module";
|
||||
export * from "./drawer.component";
|
||||
export * from "./drawer-body.component";
|
||||
export * from "./drawer-close.directive";
|
||||
export * from "./drawer-header.component";
|
||||
@@ -17,7 +17,6 @@ export * from "./container";
|
||||
export * from "./copy-click";
|
||||
export * from "./dialog";
|
||||
export * from "./disclosure";
|
||||
export * from "./drawer";
|
||||
export * from "./form-field";
|
||||
export * from "./header";
|
||||
export * from "./icon-button";
|
||||
|
||||
@@ -4,8 +4,7 @@ import { CommonModule } from "@angular/common";
|
||||
import { booleanAttribute, Component, ElementRef, inject, input, viewChild } from "@angular/core";
|
||||
import { RouterModule } from "@angular/router";
|
||||
|
||||
import { DrawerHostDirective } from "../drawer/drawer-host.directive";
|
||||
import { DrawerService } from "../drawer/drawer.service";
|
||||
import { DrawerService } from "../dialog/drawer.service";
|
||||
import { LinkModule } from "../link";
|
||||
import { SideNavService } from "../navigation/side-nav.service";
|
||||
import { SharedModule } from "../shared";
|
||||
@@ -31,7 +30,6 @@ import { ScrollLayoutHostDirective } from "./scroll-layout.directive";
|
||||
"(document:keydown.tab)": "handleKeydown($event)",
|
||||
class: "tw-block tw-h-screen",
|
||||
},
|
||||
hostDirectives: [DrawerHostDirective],
|
||||
})
|
||||
export class LayoutComponent {
|
||||
protected sideNavService = inject(SideNavService);
|
||||
|
||||
@@ -13,7 +13,6 @@ import { CalloutModule } from "../../callout";
|
||||
import { CheckboxModule } from "../../checkbox";
|
||||
import { ColorPasswordModule } from "../../color-password";
|
||||
import { DialogModule } from "../../dialog";
|
||||
import { DrawerModule } from "../../drawer";
|
||||
import { FormControlModule } from "../../form-control";
|
||||
import { FormFieldModule } from "../../form-field";
|
||||
import { IconButtonModule } from "../../icon-button";
|
||||
@@ -49,7 +48,6 @@ import { TypographyModule } from "../../typography";
|
||||
ColorPasswordModule,
|
||||
CommonModule,
|
||||
DialogModule,
|
||||
DrawerModule,
|
||||
FormControlModule,
|
||||
FormFieldModule,
|
||||
FormsModule,
|
||||
@@ -87,7 +85,6 @@ import { TypographyModule } from "../../typography";
|
||||
ColorPasswordModule,
|
||||
CommonModule,
|
||||
DialogModule,
|
||||
DrawerModule,
|
||||
FormControlModule,
|
||||
FormFieldModule,
|
||||
FormsModule,
|
||||
|
||||
@@ -54,11 +54,12 @@ export class DefaultWebAuthnPrfUnlockService implements WebAuthnPrfUnlockService
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we're in the browser extension, check if we're in a Chromium browser
|
||||
if (
|
||||
this.platformUtilsService.getClientType() === ClientType.Browser &&
|
||||
!this.platformUtilsService.isChromium()
|
||||
) {
|
||||
// PRF unlock is only supported on Web and Chromium-based browser extensions
|
||||
const clientType = this.platformUtilsService.getClientType();
|
||||
if (clientType === ClientType.Browser && !this.platformUtilsService.isChromium()) {
|
||||
return false;
|
||||
}
|
||||
if (clientType !== ClientType.Web && clientType !== ClientType.Browser) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user