@internetarchive/ia-topnav 1.4.1 → 2.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.
Files changed (68) hide show
  1. package/.prettierignore +1 -1
  2. package/LICENSE +661 -661
  3. package/README.md +147 -147
  4. package/demo/index.html +28 -28
  5. package/dist/src/data/menus.js +0 -2
  6. package/dist/src/data/menus.js.map +1 -1
  7. package/dist/src/ia-topnav.d.ts +7 -10
  8. package/dist/src/ia-topnav.js +95 -133
  9. package/dist/src/ia-topnav.js.map +1 -1
  10. package/dist/src/login-button.js +17 -17
  11. package/dist/src/login-button.js.map +1 -1
  12. package/dist/src/models.d.ts +0 -4
  13. package/dist/src/models.js.map +1 -1
  14. package/dist/src/primary-nav.d.ts +5 -4
  15. package/dist/src/primary-nav.js +98 -119
  16. package/dist/src/primary-nav.js.map +1 -1
  17. package/dist/src/styles/ia-topnav.js +82 -87
  18. package/dist/src/styles/ia-topnav.js.map +1 -1
  19. package/dist/src/styles/primary-nav.js +353 -308
  20. package/dist/src/styles/primary-nav.js.map +1 -1
  21. package/dist/test/ia-topnav.test.js +27 -69
  22. package/dist/test/ia-topnav.test.js.map +1 -1
  23. package/dist/test/primary-nav.test.js +38 -9
  24. package/dist/test/primary-nav.test.js.map +1 -1
  25. package/eslint.config.mjs +53 -53
  26. package/package.json +72 -72
  27. package/prettier.config.js +9 -9
  28. package/src/data/menus.ts +650 -652
  29. package/src/ia-topnav.ts +318 -366
  30. package/src/login-button.ts +78 -78
  31. package/src/models.ts +58 -63
  32. package/src/primary-nav.ts +277 -296
  33. package/src/styles/ia-topnav.ts +85 -90
  34. package/src/styles/primary-nav.ts +356 -311
  35. package/ssl/server.key +28 -28
  36. package/test/ia-topnav.test.ts +282 -343
  37. package/test/primary-nav.test.ts +135 -94
  38. package/tsconfig.json +31 -31
  39. package/web-dev-server.config.mjs +32 -32
  40. package/web-test-runner.config.mjs +41 -41
  41. package/dist/src/lib/location-handler.d.ts +0 -1
  42. package/dist/src/lib/location-handler.js +0 -5
  43. package/dist/src/lib/location-handler.js.map +0 -1
  44. package/dist/src/nav-search.d.ts +0 -19
  45. package/dist/src/nav-search.js +0 -127
  46. package/dist/src/nav-search.js.map +0 -1
  47. package/dist/src/search-menu.d.ts +0 -20
  48. package/dist/src/search-menu.js +0 -162
  49. package/dist/src/search-menu.js.map +0 -1
  50. package/dist/src/styles/nav-search.d.ts +0 -2
  51. package/dist/src/styles/nav-search.js +0 -136
  52. package/dist/src/styles/nav-search.js.map +0 -1
  53. package/dist/src/styles/search-menu.d.ts +0 -2
  54. package/dist/src/styles/search-menu.js +0 -118
  55. package/dist/src/styles/search-menu.js.map +0 -1
  56. package/dist/test/nav-search.test.d.ts +0 -1
  57. package/dist/test/nav-search.test.js +0 -47
  58. package/dist/test/nav-search.test.js.map +0 -1
  59. package/dist/test/search-menu.test.d.ts +0 -1
  60. package/dist/test/search-menu.test.js +0 -42
  61. package/dist/test/search-menu.test.js.map +0 -1
  62. package/src/lib/location-handler.ts +0 -5
  63. package/src/nav-search.ts +0 -117
  64. package/src/search-menu.ts +0 -156
  65. package/src/styles/nav-search.ts +0 -136
  66. package/src/styles/search-menu.ts +0 -118
  67. package/test/nav-search.test.ts +0 -70
  68. package/test/search-menu.test.ts +0 -58
@@ -1,94 +1,135 @@
1
- import {
2
- html,
3
- fixture,
4
- expect,
5
- fixtureCleanup,
6
- elementUpdated,
7
- } from '@open-wc/testing';
8
-
9
- import '../src/primary-nav';
10
- import { IATopNavConfig, IATopNavSecondIdentitySlotMode } from '../src/models';
11
- import { PrimaryNav } from '../src/primary-nav';
12
-
13
- const component = ({
14
- baseHost = 'archive.org',
15
- username = '',
16
- screenName = '',
17
- hideSearch = false,
18
- config = {},
19
- secondIdentitySlotMode = 'allow',
20
- }: {
21
- baseHost?: string;
22
- username?: string;
23
- screenName?: string;
24
- hideSearch?: boolean;
25
- config?: IATopNavConfig;
26
- secondIdentitySlotMode?: IATopNavSecondIdentitySlotMode;
27
- }) =>
28
- html` <primary-nav
29
- .baseHost=${baseHost}
30
- .username=${username}
31
- .screenName=${screenName}
32
- ?hideSearch=${hideSearch}
33
- .config=${config}
34
- .secondIdentitySlotMode=${secondIdentitySlotMode}
35
- ></primary-nav>`;
36
-
37
- afterEach(() => {
38
- fixtureCleanup();
39
- });
40
-
41
- describe('<primary-nav>', () => {
42
- it('renders the login link when no username present', async () => {
43
- const el = await fixture<PrimaryNav>(
44
- component({
45
- baseHost: 'archive.org',
46
- username: '',
47
- }),
48
- );
49
-
50
- expect(el.shadowRoot?.querySelector('login-button')).to.not.be.undefined;
51
- });
52
-
53
- it('does not render search menu toggle and search form if hideSearch true', async () => {
54
- const el = await fixture<PrimaryNav>(
55
- component({
56
- baseHost: 'archive.org',
57
- username: 'shaneriley',
58
- screenName: 'shaneriley',
59
- hideSearch: true,
60
- }),
61
- );
62
-
63
- expect(el.shadowRoot?.querySelector('.search-trigger')).to.equal(null);
64
- expect(el.shadowRoot?.querySelector('nav-search')).to.equal(null);
65
- });
66
-
67
- it('opens a slot with `secondIdentitySlotMode`', async () => {
68
- const el = await fixture<PrimaryNav>(
69
- component({
70
- baseHost: 'archive.org',
71
- username: 'boop',
72
- screenName: 'somesuperlongscreenname',
73
- secondIdentitySlotMode: 'allow',
74
- }),
75
- );
76
-
77
- const brandingBlock = el.shadowRoot?.querySelector('div.branding');
78
- expect(brandingBlock?.getAttribute('class')).to.contain(
79
- 'branding second-logo',
80
- );
81
-
82
- const slot = brandingBlock?.querySelector('slot');
83
- expect(slot).to.exist;
84
- expect(slot?.getAttribute('name')).to.equal('opt-sec-logo');
85
-
86
- el.secondIdentitySlotMode = '';
87
- await elementUpdated(el);
88
- const noSlotBrandingBlock = el.shadowRoot?.querySelector('div.branding');
89
- expect(noSlotBrandingBlock?.getAttribute('class')).to.contain('branding');
90
-
91
- const noSlot = noSlotBrandingBlock?.querySelector('slot');
92
- expect(noSlot).to.not.exist;
93
- });
94
- });
1
+ import {
2
+ html,
3
+ fixture,
4
+ expect,
5
+ fixtureCleanup,
6
+ elementUpdated,
7
+ } from '@open-wc/testing';
8
+
9
+ import '../src/primary-nav';
10
+ import { IATopNavConfig, IATopNavSecondIdentitySlotMode } from '../src/models';
11
+ import { PrimaryNav } from '../src/primary-nav';
12
+
13
+ const component = ({
14
+ baseHost = 'archive.org',
15
+ username = '',
16
+ screenName = '',
17
+ hideSearch = false,
18
+ config = {},
19
+ secondIdentitySlotMode = 'allow',
20
+ }: {
21
+ baseHost?: string;
22
+ username?: string;
23
+ screenName?: string;
24
+ hideSearch?: boolean;
25
+ config?: IATopNavConfig;
26
+ secondIdentitySlotMode?: IATopNavSecondIdentitySlotMode;
27
+ }) =>
28
+ html` <primary-nav
29
+ .baseHost=${baseHost}
30
+ .username=${username}
31
+ .screenName=${screenName}
32
+ ?hideSearch=${hideSearch}
33
+ .config=${config}
34
+ .secondIdentitySlotMode=${secondIdentitySlotMode}
35
+ ></primary-nav>`;
36
+
37
+ afterEach(() => {
38
+ fixtureCleanup();
39
+ });
40
+
41
+ describe('<primary-nav>', () => {
42
+ it('renders the login link when no username present', async () => {
43
+ const el = await fixture<PrimaryNav>(
44
+ component({
45
+ baseHost: 'archive.org',
46
+ username: '',
47
+ }),
48
+ );
49
+
50
+ expect(el.shadowRoot?.querySelector('login-button')).to.not.be.undefined;
51
+ });
52
+
53
+ it('does not render search trigger or search slot if hideSearch true', async () => {
54
+ const el = await fixture<PrimaryNav>(
55
+ component({
56
+ baseHost: 'archive.org',
57
+ username: 'shaneriley',
58
+ screenName: 'shaneriley',
59
+ hideSearch: true,
60
+ }),
61
+ );
62
+
63
+ expect(el.shadowRoot?.querySelector('.search-trigger')).to.equal(null);
64
+ expect(el.shadowRoot?.querySelector('.search-container')).to.not.exist;
65
+ });
66
+
67
+ it('renders search slot container', async () => {
68
+ const el = await fixture<PrimaryNav>(
69
+ component({
70
+ baseHost: 'archive.org',
71
+ username: 'testuser',
72
+ screenName: 'testuser',
73
+ }),
74
+ );
75
+
76
+ expect(el.shadowRoot?.querySelector('.search-container')).to.exist;
77
+
78
+ const slot = el.shadowRoot?.querySelector<HTMLSlotElement>(
79
+ 'slot[name="search"]',
80
+ );
81
+ expect(slot).to.exist;
82
+ });
83
+
84
+ it('renders search trigger button for mobile toggle', async () => {
85
+ const el = await fixture<PrimaryNav>(
86
+ component({
87
+ baseHost: 'archive.org',
88
+ username: 'testuser',
89
+ screenName: 'testuser',
90
+ }),
91
+ );
92
+
93
+ expect(el.shadowRoot?.querySelector('.search-trigger')).to.exist;
94
+ });
95
+
96
+ it('does not render nav-search', async () => {
97
+ const el = await fixture<PrimaryNav>(
98
+ component({
99
+ baseHost: 'archive.org',
100
+ username: 'testuser',
101
+ screenName: 'testuser',
102
+ }),
103
+ );
104
+
105
+ expect(el.shadowRoot?.querySelector('nav-search')).to.not.exist;
106
+ });
107
+
108
+ it('opens a slot with `secondIdentitySlotMode`', async () => {
109
+ const el = await fixture<PrimaryNav>(
110
+ component({
111
+ baseHost: 'archive.org',
112
+ username: 'boop',
113
+ screenName: 'somesuperlongscreenname',
114
+ secondIdentitySlotMode: 'allow',
115
+ }),
116
+ );
117
+
118
+ const brandingBlock = el.shadowRoot?.querySelector('div.branding');
119
+ expect(brandingBlock?.getAttribute('class')).to.contain(
120
+ 'branding second-logo',
121
+ );
122
+
123
+ const slot = brandingBlock?.querySelector('slot');
124
+ expect(slot).to.exist;
125
+ expect(slot?.getAttribute('name')).to.equal('opt-sec-logo');
126
+
127
+ el.secondIdentitySlotMode = '';
128
+ await elementUpdated(el);
129
+ const noSlotBrandingBlock = el.shadowRoot?.querySelector('div.branding');
130
+ expect(noSlotBrandingBlock?.getAttribute('class')).to.contain('branding');
131
+
132
+ const noSlot = noSlotBrandingBlock?.querySelector('slot');
133
+ expect(noSlot).to.not.exist;
134
+ });
135
+ });
package/tsconfig.json CHANGED
@@ -1,31 +1,31 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2018",
4
- "module": "esnext",
5
- "moduleResolution": "node",
6
- "noEmitOnError": true,
7
- "lib": ["es2017", "dom"],
8
- "strict": true,
9
- "esModuleInterop": false,
10
- "allowSyntheticDefaultImports": true,
11
- "experimentalDecorators": true,
12
- "importHelpers": true,
13
- "outDir": "dist",
14
- "sourceMap": true,
15
- "inlineSources": true,
16
- "rootDir": "./",
17
- "declaration": true,
18
- "plugins": [
19
- {
20
- "name": "ts-lit-plugin"
21
- }
22
- ],
23
- "paths": {
24
- // workaround for: https://github.com/vitest-dev/vitest/issues/4567
25
- "rollup/parseAst": [
26
- "./node_modules/rollup/dist/parseAst"
27
- ]
28
- }
29
- },
30
- "include": ["**/*.ts"]
31
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2018",
4
+ "module": "esnext",
5
+ "moduleResolution": "node",
6
+ "noEmitOnError": true,
7
+ "lib": ["es2017", "dom"],
8
+ "strict": true,
9
+ "esModuleInterop": false,
10
+ "allowSyntheticDefaultImports": true,
11
+ "experimentalDecorators": true,
12
+ "importHelpers": true,
13
+ "outDir": "dist",
14
+ "sourceMap": true,
15
+ "inlineSources": true,
16
+ "rootDir": "./",
17
+ "declaration": true,
18
+ "plugins": [
19
+ {
20
+ "name": "ts-lit-plugin"
21
+ }
22
+ ],
23
+ "paths": {
24
+ // workaround for: https://github.com/vitest-dev/vitest/issues/4567
25
+ "rollup/parseAst": [
26
+ "./node_modules/rollup/dist/parseAst"
27
+ ]
28
+ }
29
+ },
30
+ "include": ["**/*.ts"]
31
+ }
@@ -1,32 +1,32 @@
1
- // import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
2
-
3
- /** Use Hot Module replacement by adding --hmr to the start command */
4
- const hmr = process.argv.includes('--hmr');
5
-
6
- export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
7
- nodeResolve: true,
8
- open: '/demo',
9
- watch: !hmr,
10
- sslCert: './ssl/server.crt',
11
- sslKey: './ssl/server.key',
12
- hostname: 'local.archive.org',
13
- http2: true,
14
-
15
- /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
16
- // esbuildTarget: 'auto'
17
-
18
- /** Set appIndex to enable SPA routing */
19
- // appIndex: 'demo/index.html',
20
-
21
- /** Configure bare import resolve plugin */
22
- // nodeResolve: {
23
- // exportConditions: ['browser', 'development']
24
- // },
25
-
26
- plugins: [
27
- /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
28
- // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
29
- ],
30
-
31
- // See documentation for all available options
32
- });
1
+ // import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
2
+
3
+ /** Use Hot Module replacement by adding --hmr to the start command */
4
+ const hmr = process.argv.includes('--hmr');
5
+
6
+ export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
7
+ nodeResolve: true,
8
+ open: '/demo',
9
+ watch: !hmr,
10
+ sslCert: './ssl/server.crt',
11
+ sslKey: './ssl/server.key',
12
+ hostname: 'local.archive.org',
13
+ http2: true,
14
+
15
+ /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
16
+ // esbuildTarget: 'auto'
17
+
18
+ /** Set appIndex to enable SPA routing */
19
+ // appIndex: 'demo/index.html',
20
+
21
+ /** Configure bare import resolve plugin */
22
+ // nodeResolve: {
23
+ // exportConditions: ['browser', 'development']
24
+ // },
25
+
26
+ plugins: [
27
+ /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
28
+ // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
29
+ ],
30
+
31
+ // See documentation for all available options
32
+ });
@@ -1,41 +1,41 @@
1
- // import { playwrightLauncher } from '@web/test-runner-playwright';
2
-
3
- const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode'];
4
-
5
- export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
6
- /** Test files to run */
7
- files: 'dist/test/**/*.test.js',
8
-
9
- /** Resolve bare module imports */
10
- nodeResolve: {
11
- exportConditions: ['browser', 'development'],
12
- },
13
-
14
- /** Filter out lit dev mode logs */
15
- filterBrowserLogs(log) {
16
- for (const arg of log.args) {
17
- if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) {
18
- return false;
19
- }
20
- }
21
- return true;
22
- },
23
-
24
- /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
25
- // esbuildTarget: 'auto',
26
-
27
- /** Amount of browsers to run concurrently */
28
- // concurrentBrowsers: 2,
29
-
30
- /** Amount of test files per browser to test concurrently */
31
- // concurrency: 1,
32
-
33
- /** Browsers to run tests on */
34
- // browsers: [
35
- // playwrightLauncher({ product: 'chromium' }),
36
- // playwrightLauncher({ product: 'firefox' }),
37
- // playwrightLauncher({ product: 'webkit' }),
38
- // ],
39
-
40
- // See documentation for all available options
41
- });
1
+ // import { playwrightLauncher } from '@web/test-runner-playwright';
2
+
3
+ const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode'];
4
+
5
+ export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
6
+ /** Test files to run */
7
+ files: 'dist/test/**/*.test.js',
8
+
9
+ /** Resolve bare module imports */
10
+ nodeResolve: {
11
+ exportConditions: ['browser', 'development'],
12
+ },
13
+
14
+ /** Filter out lit dev mode logs */
15
+ filterBrowserLogs(log) {
16
+ for (const arg of log.args) {
17
+ if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) {
18
+ return false;
19
+ }
20
+ }
21
+ return true;
22
+ },
23
+
24
+ /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
25
+ // esbuildTarget: 'auto',
26
+
27
+ /** Amount of browsers to run concurrently */
28
+ // concurrentBrowsers: 2,
29
+
30
+ /** Amount of test files per browser to test concurrently */
31
+ // concurrency: 1,
32
+
33
+ /** Browsers to run tests on */
34
+ // browsers: [
35
+ // playwrightLauncher({ product: 'chromium' }),
36
+ // playwrightLauncher({ product: 'firefox' }),
37
+ // playwrightLauncher({ product: 'webkit' }),
38
+ // ],
39
+
40
+ // See documentation for all available options
41
+ });
@@ -1 +0,0 @@
1
- export default function (url: string): void;
@@ -1,5 +0,0 @@
1
- /* istanbul ignore file */
2
- export default function (url) {
3
- window.location.href = url;
4
- }
5
- //# sourceMappingURL=location-handler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"location-handler.js","sourceRoot":"","sources":["../../../src/lib/location-handler.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAE1B,MAAM,CAAC,OAAO,WAAW,GAAW;IAClC,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAC;AAC7B,CAAC","sourcesContent":["/* istanbul ignore file */\n\nexport default function (url: string) {\n window.location.href = url;\n}\n"]}
@@ -1,19 +0,0 @@
1
- import { nothing } from 'lit';
2
- import TrackedElement from './tracked-element';
3
- import { IATopNavConfig } from './models';
4
- export declare class NavSearch extends TrackedElement {
5
- baseHost: string;
6
- config: IATopNavConfig;
7
- locationHandler: (url: string) => void;
8
- open: boolean;
9
- openMenu: string;
10
- searchIn: string;
11
- searchQuery: string;
12
- private queryInput?;
13
- static get styles(): import("lit").CSSResult[];
14
- search(e: CustomEvent): boolean;
15
- toggleSearchMenu(): void;
16
- get searchInsideInput(): import("lit").TemplateResult<1> | typeof nothing;
17
- get searchEndpoint(): string;
18
- render(): import("lit").TemplateResult<1>;
19
- }
@@ -1,127 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { nothing, html } from 'lit';
3
- import TrackedElement from './tracked-element';
4
- import navSearchCSS from './styles/nav-search';
5
- import icons from './assets/img/icons';
6
- import formatUrl from './lib/format-url';
7
- import { customElement, property, query } from 'lit/decorators.js';
8
- import { defaultTopNavConfig } from './data/menus';
9
- import { iaSronlyStyles } from '@internetarchive/ia-styles';
10
- let NavSearch = class NavSearch extends TrackedElement {
11
- constructor() {
12
- super(...arguments);
13
- this.baseHost = '';
14
- this.config = defaultTopNavConfig;
15
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
16
- this.locationHandler = (url) => { };
17
- this.open = false;
18
- this.openMenu = '';
19
- this.searchIn = '';
20
- this.searchQuery = '';
21
- }
22
- static get styles() {
23
- return [navSearchCSS, iaSronlyStyles];
24
- }
25
- search(e) {
26
- var _a;
27
- const query = (_a = this.queryInput) === null || _a === void 0 ? void 0 : _a.value;
28
- if (!query) {
29
- e.preventDefault();
30
- return false;
31
- }
32
- // TV search points to a detail page with a q param instead
33
- if (this.searchIn === 'TV') {
34
- this.locationHandler(formatUrl(`/details/tv?q=${query}`, this.baseHost));
35
- e.preventDefault();
36
- return false;
37
- }
38
- this.trackSubmit(e);
39
- return true;
40
- }
41
- toggleSearchMenu() {
42
- if (this.openMenu === 'search') {
43
- return;
44
- }
45
- this.dispatchEvent(new CustomEvent('menuToggled', {
46
- detail: {
47
- menuName: 'search',
48
- },
49
- composed: true,
50
- bubbles: true,
51
- }));
52
- }
53
- get searchInsideInput() {
54
- return this.searchIn
55
- ? html `<input type="hidden" name="sin" value="${this.searchIn}" />`
56
- : nothing;
57
- }
58
- get searchEndpoint() {
59
- return '/search';
60
- }
61
- render() {
62
- var _a, _b;
63
- const searchMenuClass = this.open ? 'flex' : 'search-inactive';
64
- return html `
65
- <div class="search-activated fade-in ${searchMenuClass}">
66
- <form
67
- id="nav-search"
68
- class="highlight"
69
- .action=${formatUrl(this.searchEndpoint, this.baseHost)}
70
- method="get"
71
- @submit=${this.search}
72
- data-event-submit-tracking="${(_a = this.config) === null || _a === void 0 ? void 0 : _a.eventCategory}|NavSearchSubmit"
73
- >
74
- <label for="query" class="sr-only">Search the Archive</label>
75
- <input
76
- type="text"
77
- name="query"
78
- id="query"
79
- class="search-field"
80
- placeholder="Search"
81
- autocomplete="off"
82
- value=${this.searchQuery || ''}
83
- @focus=${this.toggleSearchMenu}
84
- />
85
- ${this.searchInsideInput}
86
- <button
87
- type="submit"
88
- class="search"
89
- tabindex="-1"
90
- data-event-click-tracking="${(_b = this.config) === null || _b === void 0 ? void 0 : _b.eventCategory}|NavSearchClose"
91
- >
92
- ${icons.search}
93
- </button>
94
- </form>
95
- </div>
96
- `;
97
- }
98
- };
99
- __decorate([
100
- property({ type: String })
101
- ], NavSearch.prototype, "baseHost", void 0);
102
- __decorate([
103
- property({ type: Object })
104
- ], NavSearch.prototype, "config", void 0);
105
- __decorate([
106
- property({ type: Object })
107
- ], NavSearch.prototype, "locationHandler", void 0);
108
- __decorate([
109
- property({ type: Boolean })
110
- ], NavSearch.prototype, "open", void 0);
111
- __decorate([
112
- property({ type: String })
113
- ], NavSearch.prototype, "openMenu", void 0);
114
- __decorate([
115
- property({ type: String })
116
- ], NavSearch.prototype, "searchIn", void 0);
117
- __decorate([
118
- property({ type: String })
119
- ], NavSearch.prototype, "searchQuery", void 0);
120
- __decorate([
121
- query('[name=query]')
122
- ], NavSearch.prototype, "queryInput", void 0);
123
- NavSearch = __decorate([
124
- customElement('nav-search')
125
- ], NavSearch);
126
- export { NavSearch };
127
- //# sourceMappingURL=nav-search.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nav-search.js","sourceRoot":"","sources":["../../src/nav-search.ts"],"names":[],"mappings":"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","sourcesContent":["import { nothing, html } from 'lit';\n\nimport TrackedElement from './tracked-element';\nimport navSearchCSS from './styles/nav-search';\nimport icons from './assets/img/icons';\nimport formatUrl from './lib/format-url';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { defaultTopNavConfig } from './data/menus';\nimport { IATopNavConfig } from './models';\nimport { iaSronlyStyles } from '@internetarchive/ia-styles';\n\n@customElement('nav-search')\nexport class NavSearch extends TrackedElement {\n @property({ type: String }) baseHost = '';\n @property({ type: Object }) config: IATopNavConfig = defaultTopNavConfig;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n @property({ type: Object }) locationHandler = (url: string) => {};\n @property({ type: Boolean }) open = false;\n @property({ type: String }) openMenu = '';\n @property({ type: String }) searchIn = '';\n @property({ type: String }) searchQuery = '';\n\n @query('[name=query]') private queryInput?: HTMLInputElement;\n\n static get styles() {\n return [navSearchCSS, iaSronlyStyles];\n }\n\n search(e: CustomEvent) {\n const query = this.queryInput?.value;\n\n if (!query) {\n e.preventDefault();\n return false;\n }\n\n // TV search points to a detail page with a q param instead\n if (this.searchIn === 'TV') {\n this.locationHandler(\n formatUrl(`/details/tv?q=${query}` as string & Location, this.baseHost),\n );\n e.preventDefault();\n return false;\n }\n\n this.trackSubmit(e);\n return true;\n }\n\n toggleSearchMenu() {\n if (this.openMenu === 'search') {\n return;\n }\n this.dispatchEvent(\n new CustomEvent('menuToggled', {\n detail: {\n menuName: 'search',\n },\n composed: true,\n bubbles: true,\n }),\n );\n }\n\n get searchInsideInput() {\n return this.searchIn\n ? html`<input type=\"hidden\" name=\"sin\" value=\"${this.searchIn}\" />`\n : nothing;\n }\n\n get searchEndpoint() {\n return '/search';\n }\n\n render() {\n const searchMenuClass = this.open ? 'flex' : 'search-inactive';\n\n return html`\n <div class=\"search-activated fade-in ${searchMenuClass}\">\n <form\n id=\"nav-search\"\n class=\"highlight\"\n .action=${formatUrl(\n this.searchEndpoint as string & Location,\n this.baseHost,\n )}\n method=\"get\"\n @submit=${this.search}\n data-event-submit-tracking=\"${this.config\n ?.eventCategory}|NavSearchSubmit\"\n >\n <label for=\"query\" class=\"sr-only\">Search the Archive</label>\n <input\n type=\"text\"\n name=\"query\"\n id=\"query\"\n class=\"search-field\"\n placeholder=\"Search\"\n autocomplete=\"off\"\n value=${this.searchQuery || ''}\n @focus=${this.toggleSearchMenu}\n />\n ${this.searchInsideInput}\n <button\n type=\"submit\"\n class=\"search\"\n tabindex=\"-1\"\n data-event-click-tracking=\"${this.config\n ?.eventCategory}|NavSearchClose\"\n >\n ${icons.search}\n </button>\n </form>\n </div>\n `;\n }\n}\n"]}
@@ -1,20 +0,0 @@
1
- import TrackedElement from './tracked-element';
2
- import { IATopNavConfig } from './models';
3
- export declare class SearchMenu extends TrackedElement {
4
- baseHost: string;
5
- config: IATopNavConfig;
6
- hideSearch: boolean;
7
- openMenu: string;
8
- searchMenuOpen: boolean;
9
- searchMenuAnimate: boolean;
10
- selectedSearchType: string;
11
- static get styles(): import("lit").CSSResult;
12
- firstUpdated(): void;
13
- disconnectedCallback(): void;
14
- private handleKeyDownEvent;
15
- selectSearchType(e: Event): void;
16
- searchInChanged(e: InputEvent): void;
17
- get searchTypesTemplate(): import("lit").TemplateResult<1>[];
18
- get menuClass(): "closed" | "open";
19
- render(): import("lit").TemplateResult<1>;
20
- }