@triptease/tt-navbar 0.0.2 → 0.0.5
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/.storybook/preview-head.html +7 -0
- package/dist/src/TtNavbar.d.ts +5 -3
- package/dist/src/TtNavbar.js +98 -18
- package/dist/src/TtNavbar.js.map +1 -1
- package/dist/src/styles.d.ts +1 -0
- package/dist/src/styles.js +21 -0
- package/dist/src/styles.js.map +1 -0
- package/dist/stories/index.stories.d.ts +1 -27
- package/dist/stories/index.stories.js +6 -28
- package/dist/stories/index.stories.js.map +1 -1
- package/dist/test/tt-navbar.test.js +58 -16
- package/dist/test/tt-navbar.test.js.map +1 -1
- package/dist/web/TtNavbar.js +116 -18
- package/dist/web/TtNavbar.js.map +4 -4
- package/dist/web/index.js +116 -18
- package/dist/web/index.js.map +4 -4
- package/dist/web/styles.js +613 -0
- package/dist/web/styles.js.map +7 -0
- package/dist/web/tt-navbar.js +116 -18
- package/dist/web/tt-navbar.js.map +4 -4
- package/package.json +1 -1
- package/src/TtNavbar.ts +100 -15
- package/src/styles.ts +21 -0
- package/stories/index.stories.ts +8 -48
- package/test/tt-navbar.test.ts +66 -18
package/dist/src/TtNavbar.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
2
|
export declare class TtNavbar extends LitElement {
|
|
3
3
|
static styles: import("lit").CSSResult;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
navigate: ((e: MouseEvent) => void) | undefined;
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
clientKey?: string;
|
|
7
|
+
private buildUrl;
|
|
8
|
+
private onAnchorClick;
|
|
7
9
|
render(): import("lit-html").TemplateResult<1>;
|
|
8
10
|
}
|
package/dist/src/TtNavbar.js
CHANGED
|
@@ -1,33 +1,113 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { html,
|
|
2
|
+
import { html, LitElement } from 'lit';
|
|
3
3
|
import { property } from 'lit/decorators.js';
|
|
4
|
+
import { styles } from './styles.js';
|
|
4
5
|
export class TtNavbar extends LitElement {
|
|
5
6
|
constructor() {
|
|
6
7
|
super(...arguments);
|
|
7
|
-
this.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
this.buildUrl = (path) => {
|
|
9
|
+
if (!this.clientKey)
|
|
10
|
+
throw new Error('clientKey is required');
|
|
11
|
+
const formattedPath = path.replace('$CLIENT_KEY', this.clientKey);
|
|
12
|
+
if (!this.baseUrl)
|
|
13
|
+
return formattedPath;
|
|
14
|
+
return new URL(formattedPath, this.baseUrl).toString();
|
|
15
|
+
};
|
|
16
|
+
this.onAnchorClick = (e) => {
|
|
17
|
+
if (this.navigate) {
|
|
18
|
+
this.navigate(e);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
12
21
|
}
|
|
13
22
|
render() {
|
|
14
23
|
return html `
|
|
15
|
-
<
|
|
16
|
-
|
|
24
|
+
<nav id=${this.id}>
|
|
25
|
+
<a href=${this.buildUrl('/')} @click=${this.onAnchorClick}>Dashboard</a>
|
|
26
|
+
<a href="https://app.campaign-manager.triptease.io">Campaigns</a>
|
|
27
|
+
<a href=${this.buildUrl('/channels')} @click=${this.onAnchorClick}
|
|
28
|
+
>Channels</a
|
|
29
|
+
>
|
|
30
|
+
<details>
|
|
31
|
+
<summary>Market Insights</summary>
|
|
32
|
+
<div>
|
|
33
|
+
<a
|
|
34
|
+
href=${this.buildUrl('/parity/$CLIENT_KEY')}
|
|
35
|
+
@click=${this.onAnchorClick}
|
|
36
|
+
>Parity</a
|
|
37
|
+
>
|
|
38
|
+
<a
|
|
39
|
+
href=${this.buildUrl('/guest-insights/$CLIENT_KEY')}
|
|
40
|
+
@click=${this.onAnchorClick}
|
|
41
|
+
>Guest insights</a
|
|
42
|
+
>
|
|
43
|
+
</div>
|
|
44
|
+
</details>
|
|
45
|
+
<details>
|
|
46
|
+
<summary>Settings</summary>
|
|
47
|
+
<div>
|
|
48
|
+
<a
|
|
49
|
+
href=${this.buildUrl('/$CLIENT_KEY/guest-behavioural-data')}
|
|
50
|
+
@click=${this.onAnchorClick}
|
|
51
|
+
>Email setup</a
|
|
52
|
+
>
|
|
53
|
+
<a
|
|
54
|
+
href=${this.buildUrl('/$CLIENT_KEY/crm-config')}
|
|
55
|
+
@click=${this.onAnchorClick}
|
|
56
|
+
>CRM connectivity</a
|
|
57
|
+
>
|
|
58
|
+
<a
|
|
59
|
+
href=${this.buildUrl('/settings/group')}
|
|
60
|
+
@click=${this.onAnchorClick}
|
|
61
|
+
>Group settings</a
|
|
62
|
+
>
|
|
63
|
+
<a
|
|
64
|
+
href=${this.buildUrl('/settings/$CLIENT_KEY/hotels/')}
|
|
65
|
+
@click=${this.onAnchorClick}
|
|
66
|
+
>Property settings</a
|
|
67
|
+
>
|
|
68
|
+
</div>
|
|
69
|
+
</details>
|
|
70
|
+
<hr />
|
|
71
|
+
<details>
|
|
72
|
+
<summary>Account</summary>
|
|
73
|
+
<div>
|
|
74
|
+
<a href=${this.buildUrl('/account')} @click=${this.onAnchorClick}
|
|
75
|
+
>User settings</a
|
|
76
|
+
>
|
|
77
|
+
<a
|
|
78
|
+
href=${this.buildUrl('/account/team/$CLIENT_KEY')}
|
|
79
|
+
@click=${this.onAnchorClick}
|
|
80
|
+
>Team and permissions</a
|
|
81
|
+
>
|
|
82
|
+
</div>
|
|
83
|
+
</details>
|
|
84
|
+
<details>
|
|
85
|
+
<summary>Billing</summary>
|
|
86
|
+
<div>
|
|
87
|
+
<a
|
|
88
|
+
href=${this.buildUrl('/account/billing-management/$CLIENT_KEY')}
|
|
89
|
+
@click=${this.onAnchorClick}
|
|
90
|
+
>Booking reconciliation</a
|
|
91
|
+
>
|
|
92
|
+
<a
|
|
93
|
+
href=${this.buildUrl('/subscriptions/$CLIENT_KEY')}
|
|
94
|
+
@click=${this.onAnchorClick}
|
|
95
|
+
>Subscriptions</a
|
|
96
|
+
>
|
|
97
|
+
</div>
|
|
98
|
+
</details>
|
|
99
|
+
</nav>
|
|
17
100
|
`;
|
|
18
101
|
}
|
|
19
102
|
}
|
|
20
|
-
TtNavbar.styles =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
color: var(--tt-navbar-text-color, #000);
|
|
25
|
-
}
|
|
26
|
-
`;
|
|
103
|
+
TtNavbar.styles = styles;
|
|
104
|
+
__decorate([
|
|
105
|
+
property({ type: Function })
|
|
106
|
+
], TtNavbar.prototype, "navigate", void 0);
|
|
27
107
|
__decorate([
|
|
28
108
|
property({ type: String })
|
|
29
|
-
], TtNavbar.prototype, "
|
|
109
|
+
], TtNavbar.prototype, "baseUrl", void 0);
|
|
30
110
|
__decorate([
|
|
31
|
-
property({ type:
|
|
32
|
-
], TtNavbar.prototype, "
|
|
111
|
+
property({ type: String })
|
|
112
|
+
], TtNavbar.prototype, "clientKey", void 0);
|
|
33
113
|
//# sourceMappingURL=TtNavbar.js.map
|
package/dist/src/TtNavbar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TtNavbar.js","sourceRoot":"","sources":["../../src/TtNavbar.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"TtNavbar.js","sourceRoot":"","sources":["../../src/TtNavbar.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,OAAO,QAAS,SAAQ,UAAU;IAAxC;;QAYU,aAAQ,GAAG,CAAC,IAAY,EAAU,EAAE;YAC1C,IAAI,CAAC,IAAI,CAAC,SAAS;gBAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;YAE9D,MAAM,aAAa,GAAG,IA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CAAC,aAAa;;;;;;;;;qBASpB,IAAI,CAAC,QAAQ,CAAC,yCAAyC,CAAC;uBACtD,IAAI,CAAC,aAAa;;;;qBAIpB,IAAI,CAAC,QAAQ,CAAC,4BAA4B,CAAC;uBACzC,IAAI,CAAC,aAAa;;;;;;KAMpC,CAAC;IACJ,CAAC;;AAzGM,eAAM,GAAG,MAAM,AAAT,CAAU;AAGvB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;0CACmB;AAGhD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCACV;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CACR","sourcesContent":["import { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { styles } from './styles.js';\n\nexport class TtNavbar extends LitElement {\n static styles = styles;\n\n @property({ type: Function })\n navigate: ((e: MouseEvent) => void) | undefined;\n\n @property({ type: String })\n baseUrl?: string;\n\n @property({ type: String })\n clientKey?: string;\n\n private buildUrl = (path: string): string => {\n if (!this.clientKey) throw new Error('clientKey is required');\n\n const formattedPath = path.replace('$CLIENT_KEY', this.clientKey);\n if (!this.baseUrl) return formattedPath;\n\n return new URL(formattedPath, this.baseUrl).toString();\n };\n\n private onAnchorClick = (e: MouseEvent) => {\n if (this.navigate) {\n this.navigate(e);\n }\n };\n\n render() {\n return html`\n <nav id=${this.id}>\n <a href=${this.buildUrl('/')} @click=${this.onAnchorClick}>Dashboard</a>\n <a href=\"https://app.campaign-manager.triptease.io\">Campaigns</a>\n <a href=${this.buildUrl('/channels')} @click=${this.onAnchorClick}\n >Channels</a\n >\n <details>\n <summary>Market Insights</summary>\n <div>\n <a\n href=${this.buildUrl('/parity/$CLIENT_KEY')}\n @click=${this.onAnchorClick}\n >Parity</a\n >\n <a\n href=${this.buildUrl('/guest-insights/$CLIENT_KEY')}\n @click=${this.onAnchorClick}\n >Guest insights</a\n >\n </div>\n </details>\n <details>\n <summary>Settings</summary>\n <div>\n <a\n href=${this.buildUrl('/$CLIENT_KEY/guest-behavioural-data')}\n @click=${this.onAnchorClick}\n >Email setup</a\n >\n <a\n href=${this.buildUrl('/$CLIENT_KEY/crm-config')}\n @click=${this.onAnchorClick}\n >CRM connectivity</a\n >\n <a\n href=${this.buildUrl('/settings/group')}\n @click=${this.onAnchorClick}\n >Group settings</a\n >\n <a\n href=${this.buildUrl('/settings/$CLIENT_KEY/hotels/')}\n @click=${this.onAnchorClick}\n >Property settings</a\n >\n </div>\n </details>\n <hr />\n <details>\n <summary>Account</summary>\n <div>\n <a href=${this.buildUrl('/account')} @click=${this.onAnchorClick}\n >User settings</a\n >\n <a\n href=${this.buildUrl('/account/team/$CLIENT_KEY')}\n @click=${this.onAnchorClick}\n >Team and permissions</a\n >\n </div>\n </details>\n <details>\n <summary>Billing</summary>\n <div>\n <a\n href=${this.buildUrl('/account/billing-management/$CLIENT_KEY')}\n @click=${this.onAnchorClick}\n >Booking reconciliation</a\n >\n <a\n href=${this.buildUrl('/subscriptions/$CLIENT_KEY')}\n @click=${this.onAnchorClick}\n >Subscriptions</a\n >\n </div>\n </details>\n </nav>\n `;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const styles = css `
|
|
3
|
+
nav {
|
|
4
|
+
max-width: 260px;
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
nav details div {
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
hr {
|
|
15
|
+
background: black;
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 1px;
|
|
18
|
+
border: none;
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;CAkBxB,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css`\n nav {\n max-width: 260px;\n display: flex;\n flex-direction: column;\n }\n\n nav details div {\n display: flex;\n flex-direction: column;\n }\n\n hr {\n background: black;\n width: 100%;\n height: 1px;\n border: none;\n }\n`;\n"]}
|
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
import { TemplateResult } from 'lit';
|
|
2
1
|
import '../src/tt-navbar.js';
|
|
3
2
|
declare const _default: {
|
|
4
3
|
title: string;
|
|
5
4
|
component: string;
|
|
6
|
-
argTypes: {
|
|
7
|
-
header: {
|
|
8
|
-
control: string;
|
|
9
|
-
};
|
|
10
|
-
counter: {
|
|
11
|
-
control: string;
|
|
12
|
-
};
|
|
13
|
-
textColor: {
|
|
14
|
-
control: string;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
5
|
};
|
|
18
6
|
export default _default;
|
|
19
|
-
|
|
20
|
-
(args: T): TemplateResult;
|
|
21
|
-
args?: Partial<T>;
|
|
22
|
-
argTypes?: Record<string, unknown>;
|
|
23
|
-
}
|
|
24
|
-
interface ArgTypes {
|
|
25
|
-
header?: string;
|
|
26
|
-
counter?: number;
|
|
27
|
-
textColor?: string;
|
|
28
|
-
slot?: TemplateResult;
|
|
29
|
-
}
|
|
30
|
-
export declare const Regular: Story<ArgTypes>;
|
|
31
|
-
export declare const CustomHeader: Story<ArgTypes>;
|
|
32
|
-
export declare const CustomCounter: Story<ArgTypes>;
|
|
33
|
-
export declare const SlottedContent: Story<ArgTypes>;
|
|
7
|
+
export declare const Regular: () => import("lit-html").TemplateResult<1>;
|
|
@@ -3,35 +3,13 @@ import '../src/tt-navbar.js';
|
|
|
3
3
|
export default {
|
|
4
4
|
title: 'TtNavbar',
|
|
5
5
|
component: 'tt-navbar',
|
|
6
|
-
argTypes: {
|
|
7
|
-
header: { control: 'text' },
|
|
8
|
-
counter: { control: 'number' },
|
|
9
|
-
textColor: { control: 'color' },
|
|
10
|
-
},
|
|
11
6
|
};
|
|
12
|
-
const Template = (
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
${slot}
|
|
19
|
-
</tt-navbar>
|
|
7
|
+
const Template = () => html `
|
|
8
|
+
<div>
|
|
9
|
+
<tt-navbar clientKey="zxd47KQGAP">
|
|
10
|
+
</tt-navbar>
|
|
11
|
+
</div>
|
|
12
|
+
|
|
20
13
|
`;
|
|
21
14
|
export const Regular = Template.bind({});
|
|
22
|
-
export const CustomHeader = Template.bind({});
|
|
23
|
-
CustomHeader.args = {
|
|
24
|
-
header: 'My header',
|
|
25
|
-
};
|
|
26
|
-
export const CustomCounter = Template.bind({});
|
|
27
|
-
CustomCounter.args = {
|
|
28
|
-
counter: 123456,
|
|
29
|
-
};
|
|
30
|
-
export const SlottedContent = Template.bind({});
|
|
31
|
-
SlottedContent.args = {
|
|
32
|
-
slot: html `<p>Slotted content</p>`,
|
|
33
|
-
};
|
|
34
|
-
SlottedContent.argTypes = {
|
|
35
|
-
slot: { table: { disable: true } },
|
|
36
|
-
};
|
|
37
15
|
//# sourceMappingURL=index.stories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.stories.js","sourceRoot":"","sources":["../../stories/index.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"index.stories.js","sourceRoot":"","sources":["../../stories/index.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,qBAAqB,CAAC;AAE7B,eAAe;IACb,KAAK,EAAE,UAAU;IACjB,SAAS,EAAE,WAAW;CACvB,CAAC;AAKF,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,IAAI,CAAA;;;;;;CAM1B,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC","sourcesContent":["import { html } from 'lit';\nimport '../src/tt-navbar.js';\n\nexport default {\n title: 'TtNavbar',\n component: 'tt-navbar',\n};\n\n\n\n\nconst Template = () => html`\n <div>\n <tt-navbar clientKey=\"zxd47KQGAP\">\n </tt-navbar>\n </div>\n\n`;\n\nexport const Regular = Template.bind({});\n"]}
|
|
@@ -1,24 +1,66 @@
|
|
|
1
|
-
import { html } from 'lit';
|
|
2
|
-
import { fixture, expect } from '@open-wc/testing';
|
|
3
1
|
import '../src/tt-navbar.js';
|
|
2
|
+
import { expect, fixture, waitUntil } from '@open-wc/testing';
|
|
3
|
+
// eslint-disable-next-line no-undef
|
|
4
|
+
const getLinkByHref = (links, href) => {
|
|
5
|
+
for (const link of links) {
|
|
6
|
+
if (link.getAttribute('href') === href) {
|
|
7
|
+
return link;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return undefined;
|
|
11
|
+
};
|
|
12
|
+
const CLIENT_KEY = 'zxd47KQGAP';
|
|
4
13
|
describe('TtNavbar', () => {
|
|
5
|
-
it(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
14
|
+
it("should throw an error if the clientKey is not provided", async () => {
|
|
15
|
+
try {
|
|
16
|
+
await fixture(`<tt-navbar></tt-navbar>`);
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
expect(e).to.match(/clientKey is required/);
|
|
20
|
+
}
|
|
9
21
|
});
|
|
10
|
-
it('
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
expect(
|
|
22
|
+
it('should render with the default links', async () => {
|
|
23
|
+
const navbar = await fixture(`<tt-navbar clientKey=${CLIENT_KEY}></tt-navbar>`);
|
|
24
|
+
const links = navbar.shadowRoot?.querySelectorAll('a');
|
|
25
|
+
expect(links?.length).to.equal(13);
|
|
26
|
+
if (links) {
|
|
27
|
+
expect(getLinkByHref(links, '/')).to.exist;
|
|
28
|
+
expect(getLinkByHref(links, 'https://app.campaign-manager.triptease.io')).to.exist;
|
|
29
|
+
expect(getLinkByHref(links, '/channels')).to.exist;
|
|
30
|
+
expect(getLinkByHref(links, `/parity/${CLIENT_KEY}`)).to.exist;
|
|
31
|
+
expect(getLinkByHref(links, `/guest-insights/${CLIENT_KEY}`)).to.exist;
|
|
32
|
+
expect(getLinkByHref(links, `/${CLIENT_KEY}/guest-behavioural-data`)).to.exist;
|
|
33
|
+
expect(getLinkByHref(links, `/${CLIENT_KEY}/crm-config`)).to.exist;
|
|
34
|
+
expect(getLinkByHref(links, `/settings/group`)).to.exist;
|
|
35
|
+
expect(getLinkByHref(links, `/settings/${CLIENT_KEY}/hotels/`)).to.exist;
|
|
36
|
+
expect(getLinkByHref(links, `/account`)).to.exist;
|
|
37
|
+
expect(getLinkByHref(links, `/account/team/${CLIENT_KEY}`)).to.exist;
|
|
38
|
+
expect(getLinkByHref(links, `/account/billing-management/${CLIENT_KEY}`)).to.exist;
|
|
39
|
+
expect(getLinkByHref(links, `/subscriptions/${CLIENT_KEY}`)).to.exist;
|
|
40
|
+
}
|
|
14
41
|
});
|
|
15
|
-
it('
|
|
16
|
-
const
|
|
17
|
-
|
|
42
|
+
it('should render platform URLs against the base URL when it is defined', async () => {
|
|
43
|
+
const baseUrl = 'https://app.triptease.io';
|
|
44
|
+
const navbar = await fixture(`<tt-navbar clientKey=${CLIENT_KEY} baseUrl="${baseUrl}"></tt-navbar>`);
|
|
45
|
+
const links = navbar.shadowRoot?.querySelectorAll('a');
|
|
46
|
+
if (links) {
|
|
47
|
+
expect(getLinkByHref(links, `${baseUrl}/`)).to.exist;
|
|
48
|
+
expect(getLinkByHref(links, 'https://app.campaign-manager.triptease.io')).to.exist; // This shouldn't change
|
|
49
|
+
expect(getLinkByHref(links, `${baseUrl}/channels`)).to.exist;
|
|
50
|
+
}
|
|
18
51
|
});
|
|
19
|
-
it('
|
|
20
|
-
|
|
21
|
-
|
|
52
|
+
it('should allow navigation events to be handled externally', async () => {
|
|
53
|
+
let navigateEventCount = 0;
|
|
54
|
+
const onNavigate = (e) => {
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
navigateEventCount += 1;
|
|
57
|
+
};
|
|
58
|
+
const navbar = await fixture(`<tt-navbar clientKey=${CLIENT_KEY}></tt-navbar>`);
|
|
59
|
+
navbar.navigate = onNavigate;
|
|
60
|
+
await navbar.updateComplete;
|
|
61
|
+
const links = navbar.shadowRoot?.querySelectorAll('a');
|
|
62
|
+
links?.forEach(l => l.click());
|
|
63
|
+
await waitUntil(() => expect(navigateEventCount).to.equal(12), 'navigate event did not fire');
|
|
22
64
|
});
|
|
23
65
|
});
|
|
24
66
|
//# sourceMappingURL=tt-navbar.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tt-navbar.test.js","sourceRoot":"","sources":["../../test/tt-navbar.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"tt-navbar.test.js","sourceRoot":"","sources":["../../test/tt-navbar.test.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG9D,oCAAoC;AACpC,MAAM,aAAa,GAAG,CAAC,KAAsC,EAAG,IAAY,EAAC,EAAE;IAC7E,KAAI,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACxB,IAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC;YACtC,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,YAAY,CAAC;AAEhC,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5G,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,GAAG,OAAO,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC/D,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yDAAyD,EAAE,KAAK,IAAI,EAAE;QACvE,IAAI,kBAAkB,GAAG,CAAC,CAAC;QAE3B,MAAM,UAAU,GAAG,CAAC,CAAa,EAAE,EAAE;YACnC,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,kBAAkB,IAAI,CAAC,CAAC;QAC1B,CAAC,CAAA;QAED,MAAM,MAAM,GAAG,MAAM,OAAO,CAAW,wBAAwB,UAAU,eAAe,CAAC,CAAC;QAC1F,MAAM,CAAC,QAAQ,GAAG,UAAU,CAAC;QAC7B,MAAM,MAAM,CAAC,cAAc,CAAC;QAE5B,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC;QACvD,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;QAE/B,MAAM,SAAS,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,6BAA6B,CAAC,CAAC;IAChG,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import '../src/tt-navbar.js';\nimport { expect, fixture, waitUntil } from '@open-wc/testing';\nimport { TtNavbar } from '../src/index.js';\n\n// eslint-disable-next-line no-undef\nconst getLinkByHref = (links: NodeListOf<HTMLAnchorElement> , href: string)=> {\n for(const link of links) {\n if(link.getAttribute('href') === href) {\n return link;\n }\n }\n\n return undefined\n}\n\nconst CLIENT_KEY = 'zxd47KQGAP';\n\ndescribe('TtNavbar', () => {\n\n it(\"should throw an error if the clientKey is not provided\", async () => {\n try {\n await fixture<TtNavbar>(`<tt-navbar></tt-navbar>`);\n } catch(e) {\n expect(e).to.match(/clientKey is required/);\n }\n })\n it('should render with the default links', async () => {\n const navbar = await fixture<TtNavbar>(`<tt-navbar clientKey=${CLIENT_KEY}></tt-navbar>`);\n const links = navbar.shadowRoot?.querySelectorAll('a');\n\n expect(links?.length).to.equal(13);\n\n if(links) {\n expect(getLinkByHref(links, '/')).to.exist;\n expect(getLinkByHref(links, 'https://app.campaign-manager.triptease.io')).to.exist;\n expect(getLinkByHref(links, '/channels')).to.exist;\n expect(getLinkByHref(links, `/parity/${CLIENT_KEY}`)).to.exist;\n expect(getLinkByHref(links, `/guest-insights/${CLIENT_KEY}`)).to.exist;\n expect(getLinkByHref(links, `/${CLIENT_KEY}/guest-behavioural-data`)).to.exist;\n expect(getLinkByHref(links, `/${CLIENT_KEY}/crm-config`)).to.exist;\n expect(getLinkByHref(links, `/settings/group`)).to.exist;\n expect(getLinkByHref(links, `/settings/${CLIENT_KEY}/hotels/`)).to.exist;\n expect(getLinkByHref(links, `/account`)).to.exist;\n expect(getLinkByHref(links, `/account/team/${CLIENT_KEY}`)).to.exist;\n expect(getLinkByHref(links, `/account/billing-management/${CLIENT_KEY}`)).to.exist;\n expect(getLinkByHref(links, `/subscriptions/${CLIENT_KEY}`)).to.exist;\n }\n\n });\n\n it('should render platform URLs against the base URL when it is defined', async () => {\n const baseUrl = 'https://app.triptease.io';\n const navbar = await fixture<TtNavbar>(`<tt-navbar clientKey=${CLIENT_KEY} baseUrl=\"${baseUrl}\"></tt-navbar>`);\n const links = navbar.shadowRoot?.querySelectorAll('a');\n\n if(links) {\n expect(getLinkByHref(links, `${baseUrl}/`)).to.exist;\n expect(getLinkByHref(links, 'https://app.campaign-manager.triptease.io')).to.exist; // This shouldn't change\n expect(getLinkByHref(links, `${baseUrl}/channels`)).to.exist;\n }\n });\n\n it('should allow navigation events to be handled externally', async () => {\n let navigateEventCount = 0;\n\n const onNavigate = (e: MouseEvent) => {\n e.preventDefault();\n navigateEventCount += 1;\n }\n\n const navbar = await fixture<TtNavbar>(`<tt-navbar clientKey=${CLIENT_KEY}></tt-navbar>`);\n navbar.navigate = onNavigate;\n await navbar.updateComplete;\n\n const links = navbar.shadowRoot?.querySelectorAll('a');\n links?.forEach(l => l.click());\n\n await waitUntil(() => expect(navigateEventCount).to.equal(12), 'navigate event did not fire');\n });\n});\n"]}
|
package/dist/web/TtNavbar.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @triptease/tt-navbar v0.0.
|
|
2
|
+
* @triptease/tt-navbar v0.0.5
|
|
3
3
|
*/
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -590,36 +590,134 @@ function n4(t3) {
|
|
|
590
590
|
})(t3, e5, o6);
|
|
591
591
|
}
|
|
592
592
|
|
|
593
|
+
// src/styles.ts
|
|
594
|
+
var styles = i`
|
|
595
|
+
nav {
|
|
596
|
+
max-width: 260px;
|
|
597
|
+
display: flex;
|
|
598
|
+
flex-direction: column;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
nav details div {
|
|
602
|
+
display: flex;
|
|
603
|
+
flex-direction: column;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
hr {
|
|
607
|
+
background: black;
|
|
608
|
+
width: 100%;
|
|
609
|
+
height: 1px;
|
|
610
|
+
border: none;
|
|
611
|
+
}
|
|
612
|
+
`;
|
|
613
|
+
|
|
593
614
|
// src/TtNavbar.ts
|
|
594
615
|
var TtNavbar = class extends i4 {
|
|
595
616
|
constructor() {
|
|
596
617
|
super(...arguments);
|
|
597
|
-
this.
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
618
|
+
this.buildUrl = (path) => {
|
|
619
|
+
if (!this.clientKey) throw new Error("clientKey is required");
|
|
620
|
+
const formattedPath = path.replace("$CLIENT_KEY", this.clientKey);
|
|
621
|
+
if (!this.baseUrl) return formattedPath;
|
|
622
|
+
return new URL(formattedPath, this.baseUrl).toString();
|
|
623
|
+
};
|
|
624
|
+
this.onAnchorClick = (e5) => {
|
|
625
|
+
if (this.navigate) {
|
|
626
|
+
this.navigate(e5);
|
|
627
|
+
}
|
|
628
|
+
};
|
|
602
629
|
}
|
|
603
630
|
render() {
|
|
604
631
|
return x`
|
|
605
|
-
<
|
|
606
|
-
|
|
632
|
+
<nav id=${this.id}>
|
|
633
|
+
<a href=${this.buildUrl("/")} @click=${this.onAnchorClick}>Dashboard</a>
|
|
634
|
+
<a href="https://app.campaign-manager.triptease.io">Campaigns</a>
|
|
635
|
+
<a href=${this.buildUrl("/channels")} @click=${this.onAnchorClick}
|
|
636
|
+
>Channels</a
|
|
637
|
+
>
|
|
638
|
+
<details>
|
|
639
|
+
<summary>Market Insights</summary>
|
|
640
|
+
<div>
|
|
641
|
+
<a
|
|
642
|
+
href=${this.buildUrl("/parity/$CLIENT_KEY")}
|
|
643
|
+
@click=${this.onAnchorClick}
|
|
644
|
+
>Parity</a
|
|
645
|
+
>
|
|
646
|
+
<a
|
|
647
|
+
href=${this.buildUrl("/guest-insights/$CLIENT_KEY")}
|
|
648
|
+
@click=${this.onAnchorClick}
|
|
649
|
+
>Guest insights</a
|
|
650
|
+
>
|
|
651
|
+
</div>
|
|
652
|
+
</details>
|
|
653
|
+
<details>
|
|
654
|
+
<summary>Settings</summary>
|
|
655
|
+
<div>
|
|
656
|
+
<a
|
|
657
|
+
href=${this.buildUrl("/$CLIENT_KEY/guest-behavioural-data")}
|
|
658
|
+
@click=${this.onAnchorClick}
|
|
659
|
+
>Email setup</a
|
|
660
|
+
>
|
|
661
|
+
<a
|
|
662
|
+
href=${this.buildUrl("/$CLIENT_KEY/crm-config")}
|
|
663
|
+
@click=${this.onAnchorClick}
|
|
664
|
+
>CRM connectivity</a
|
|
665
|
+
>
|
|
666
|
+
<a
|
|
667
|
+
href=${this.buildUrl("/settings/group")}
|
|
668
|
+
@click=${this.onAnchorClick}
|
|
669
|
+
>Group settings</a
|
|
670
|
+
>
|
|
671
|
+
<a
|
|
672
|
+
href=${this.buildUrl("/settings/$CLIENT_KEY/hotels/")}
|
|
673
|
+
@click=${this.onAnchorClick}
|
|
674
|
+
>Property settings</a
|
|
675
|
+
>
|
|
676
|
+
</div>
|
|
677
|
+
</details>
|
|
678
|
+
<hr />
|
|
679
|
+
<details>
|
|
680
|
+
<summary>Account</summary>
|
|
681
|
+
<div>
|
|
682
|
+
<a href=${this.buildUrl("/account")} @click=${this.onAnchorClick}
|
|
683
|
+
>User settings</a
|
|
684
|
+
>
|
|
685
|
+
<a
|
|
686
|
+
href=${this.buildUrl("/account/team/$CLIENT_KEY")}
|
|
687
|
+
@click=${this.onAnchorClick}
|
|
688
|
+
>Team and permissions</a
|
|
689
|
+
>
|
|
690
|
+
</div>
|
|
691
|
+
</details>
|
|
692
|
+
<details>
|
|
693
|
+
<summary>Billing</summary>
|
|
694
|
+
<div>
|
|
695
|
+
<a
|
|
696
|
+
href=${this.buildUrl("/account/billing-management/$CLIENT_KEY")}
|
|
697
|
+
@click=${this.onAnchorClick}
|
|
698
|
+
>Booking reconciliation</a
|
|
699
|
+
>
|
|
700
|
+
<a
|
|
701
|
+
href=${this.buildUrl("/subscriptions/$CLIENT_KEY")}
|
|
702
|
+
@click=${this.onAnchorClick}
|
|
703
|
+
>Subscriptions</a
|
|
704
|
+
>
|
|
705
|
+
</div>
|
|
706
|
+
</details>
|
|
707
|
+
</nav>
|
|
607
708
|
`;
|
|
608
709
|
}
|
|
609
710
|
};
|
|
610
|
-
TtNavbar.styles =
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
color: var(--tt-navbar-text-color, #000);
|
|
615
|
-
}
|
|
616
|
-
`;
|
|
711
|
+
TtNavbar.styles = styles;
|
|
712
|
+
__decorateClass([
|
|
713
|
+
n4({ type: Function })
|
|
714
|
+
], TtNavbar.prototype, "navigate", 2);
|
|
617
715
|
__decorateClass([
|
|
618
716
|
n4({ type: String })
|
|
619
|
-
], TtNavbar.prototype, "
|
|
717
|
+
], TtNavbar.prototype, "baseUrl", 2);
|
|
620
718
|
__decorateClass([
|
|
621
|
-
n4({ type:
|
|
622
|
-
], TtNavbar.prototype, "
|
|
719
|
+
n4({ type: String })
|
|
720
|
+
], TtNavbar.prototype, "clientKey", 2);
|
|
623
721
|
export {
|
|
624
722
|
TtNavbar
|
|
625
723
|
};
|