@internetarchive/ia-item-navigator 1.0.3 → 1.0.4-a1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +2 -0
  3. package/dist/index.js.map +1 -1
  4. package/dist/src/item-navigator.d.ts +1 -1
  5. package/dist/src/item-navigator.js +1 -1
  6. package/dist/src/item-navigator.js.map +1 -1
  7. package/dist/src/menu-slider/ia-menu-slider.d.ts +30 -0
  8. package/dist/src/menu-slider/ia-menu-slider.js +160 -0
  9. package/dist/src/menu-slider/ia-menu-slider.js.map +1 -0
  10. package/dist/src/menu-slider/menu-button.d.ts +19 -0
  11. package/dist/src/menu-slider/menu-button.js +91 -0
  12. package/dist/src/menu-slider/menu-button.js.map +1 -0
  13. package/dist/src/menu-slider/styles/menu-button.d.ts +2 -0
  14. package/dist/src/menu-slider/styles/menu-button.js +79 -0
  15. package/dist/src/menu-slider/styles/menu-button.js.map +1 -0
  16. package/dist/src/menu-slider/styles/menu-slider.d.ts +2 -0
  17. package/dist/src/menu-slider/styles/menu-slider.js +129 -0
  18. package/dist/src/menu-slider/styles/menu-slider.js.map +1 -0
  19. package/index.ts +2 -0
  20. package/package.json +3 -3
  21. package/src/item-navigator.ts +2 -2
  22. package/src/menu-slider/ia-menu-slider.ts +161 -0
  23. package/src/menu-slider/menu-button.ts +80 -0
  24. package/src/menu-slider/styles/menu-button.ts +79 -0
  25. package/src/menu-slider/styles/menu-slider.ts +130 -0
  26. package/test/ia-menu-slider.test.js +273 -0
  27. package/dist/src/event-interfaces.d.ts +0 -37
  28. package/dist/src/event-interfaces.js +0 -2
  29. package/dist/src/event-interfaces.js.map +0 -1
  30. package/dist/src/grouped-files-provider.d.ts +0 -0
  31. package/dist/src/grouped-files-provider.js +0 -2
  32. package/dist/src/grouped-files-provider.js.map +0 -1
  33. package/dist/src/interfaces/nav-controller-interface.d.ts +0 -20
  34. package/dist/src/interfaces/nav-controller-interface.js +0 -2
  35. package/dist/src/interfaces/nav-controller-interface.js.map +0 -1
  36. package/dist/src/item-inspector/files-by-type/files-by-type-provider.d.ts +0 -14
  37. package/dist/src/item-inspector/files-by-type/files-by-type-provider.js +0 -29
  38. package/dist/src/item-inspector/files-by-type/files-by-type-provider.js.map +0 -1
  39. package/dist/src/item-inspector/files-by-type/ia-files-by-type.d.ts +0 -16
  40. package/dist/src/item-inspector/files-by-type/ia-files-by-type.js +0 -95
  41. package/dist/src/item-inspector/files-by-type/ia-files-by-type.js.map +0 -1
  42. package/dist/src/item-inspector/files-by-type/ia-grouped-files-by-type.d.ts +0 -0
  43. package/dist/src/item-inspector/files-by-type/ia-grouped-files-by-type.js +0 -2
  44. package/dist/src/item-inspector/files-by-type/ia-grouped-files-by-type.js.map +0 -1
  45. package/dist/src/item-inspector/grouped-files/files-by-type-provider.d.ts +0 -15
  46. package/dist/src/item-inspector/grouped-files/files-by-type-provider.js +0 -33
  47. package/dist/src/item-inspector/grouped-files/files-by-type-provider.js.map +0 -1
  48. package/dist/src/item-inspector/grouped-files/grouped-files-provider.d.ts +0 -15
  49. package/dist/src/item-inspector/grouped-files/grouped-files-provider.js +0 -33
  50. package/dist/src/item-inspector/grouped-files/grouped-files-provider.js.map +0 -1
  51. package/dist/src/item-inspector/grouped-files/ia-grouped-files-by-type.d.ts +0 -0
  52. package/dist/src/item-inspector/grouped-files/ia-grouped-files-by-type.js +0 -2
  53. package/dist/src/item-inspector/grouped-files/ia-grouped-files-by-type.js.map +0 -1
  54. package/dist/src/item-inspector/grouped-files/ia-grouped-files.d.ts +0 -0
  55. package/dist/src/item-inspector/grouped-files/ia-grouped-files.js +0 -2
  56. package/dist/src/item-inspector/grouped-files/ia-grouped-files.js.map +0 -1
  57. package/dist/src/item-inspector/grouped-files-provider.d.ts +0 -15
  58. package/dist/src/item-inspector/grouped-files-provider.js +0 -33
  59. package/dist/src/item-inspector/grouped-files-provider.js.map +0 -1
  60. package/dist/src/item-inspector/item-inspector.d.ts +0 -0
  61. package/dist/src/item-inspector/item-inspector.js +0 -254
  62. package/dist/src/item-inspector/item-inspector.js.map +0 -1
  63. package/dist/src/item-inspector/share-provider.d.ts +0 -15
  64. package/dist/src/item-inspector/share-provider.js +0 -35
  65. package/dist/src/item-inspector/share-provider.js.map +0 -1
  66. package/dist/src/item-inspector/visual-mod-provider.d.ts +0 -19
  67. package/dist/src/item-inspector/visual-mod-provider.js +0 -46
  68. package/dist/src/item-inspector/visual-mod-provider.js.map +0 -1
  69. package/dist/src/item-inspector.d.ts +0 -24
  70. package/dist/src/item-inspector.js +0 -92
  71. package/dist/src/item-inspector.js.map +0 -1
  72. package/dist/src/menu-interfaces.d.ts +0 -16
  73. package/dist/src/menu-interfaces.js +0 -2
  74. package/dist/src/menu-interfaces.js.map +0 -1
  75. package/dist/src/nav-controller-interface.d.ts +0 -9
  76. package/dist/src/nav-controller-interface.js +0 -2
  77. package/dist/src/nav-controller-interface.js.map +0 -1
  78. package/dist/src/your-webcomponent.d.ts +0 -8
  79. package/dist/src/your-webcomponent.js +0 -37
  80. package/dist/src/your-webcomponent.js.map +0 -1
  81. package/dist/test/book-nav-stub.d.ts +0 -22
  82. package/dist/test/book-nav-stub.js +0 -49
  83. package/dist/test/book-nav-stub.js.map +0 -1
  84. package/dist/test/ia-stub-goody.d.ts +0 -210
  85. package/dist/test/ia-stub-goody.js +0 -276
  86. package/dist/test/ia-stub-goody.js.map +0 -1
  87. package/dist/test/your-webcomponent.test.d.ts +0 -0
  88. package/dist/test/your-webcomponent.test.js +0 -33
  89. package/dist/test/your-webcomponent.test.js.map +0 -1
@@ -0,0 +1,273 @@
1
+ import { html, fixture, expect } from '@open-wc/testing';
2
+ import '../src/menu-slider/ia-menu-slider';
3
+
4
+ const container = (menus = []) => (
5
+ html`<ia-menu-slider .menus=${menus}></ia-menu-slider>`
6
+ );
7
+
8
+ const menus = [{
9
+ icon: html`<span id="icon-1"></span>`,
10
+ label: 'Icon 1',
11
+ menuDetails: '(this icon is rad)',
12
+ id: 'menu-1',
13
+ component: html`
14
+ <h1>Menu 1</h1>
15
+ `,
16
+ }, {
17
+ icon: html`<b></b>`,
18
+ label: 'Icon 2',
19
+ id: 'menu-2',
20
+ component: html`
21
+ <h1>Menu 2</h1>
22
+ `,
23
+ }, {
24
+ icon: html`<i></i>`,
25
+ label: 'Regular link',
26
+ id: 'regular-link',
27
+ followable: true,
28
+ href: '#',
29
+ }];
30
+
31
+ describe('<ia-menu-slider>', () => {
32
+ it('sets default properties', async () => {
33
+ const el = await fixture(container(menus));
34
+
35
+ expect(el.menus).to.equal(menus);
36
+ expect(el.open).to.be.false;
37
+ expect(el.selectedMenu).to.equal('');
38
+ });
39
+
40
+ it('has a close button', async () => {
41
+ const el = await fixture(container(menus));
42
+ const closebutton = el.shadowRoot
43
+ .querySelector('button.close');
44
+ expect(closebutton).to.not.be.undefined;
45
+ });
46
+
47
+ it('sets the selected menu', async () => {
48
+ const el = await fixture(container(menus));
49
+
50
+ el.setSelectedMenu({ detail: { id: menus[0].id } });
51
+ await el.updateComplete;
52
+
53
+ expect(el.selectedMenu).to.equal(menus[0].id);
54
+ });
55
+
56
+ it('unsets the selected menu when existing selected menu toggled', async () => {
57
+ const el = await fixture(container(menus));
58
+
59
+ el.setSelectedMenu({ detail: { id: menus[0].id } });
60
+ await el.updateComplete;
61
+
62
+ el.setSelectedMenu({ detail: { id: menus[0].id } });
63
+ await el.updateComplete;
64
+
65
+ expect(el.selectedMenu).to.equal('');
66
+ });
67
+
68
+ it('returns open CSS class when menu is open', async () => {
69
+ const el = await fixture(container(menus));
70
+
71
+ el.open = true;
72
+ await el.updateComplete;
73
+
74
+ expect(el.sliderDetailsClass).to.contain('open');
75
+ });
76
+
77
+ it('returns open CSS class when menu is open', async () => {
78
+ const el = await fixture(container(menus));
79
+
80
+ el.selectedMenu = menus[0].id;
81
+ await el.updateComplete;
82
+
83
+ expect(el.selectedMenuClass).to.equal('open');
84
+ });
85
+
86
+ it('dispatches a "menuTypeSelected" event when a menu item clicked', async () => {
87
+ const el = await fixture(container(menus));
88
+
89
+ el
90
+ .shadowRoot
91
+ .querySelector('menu-button')
92
+ .shadowRoot
93
+ .querySelector('button')
94
+ .click();
95
+
96
+ await el.updateComplete;
97
+
98
+ expect(el.selectedMenu).to.equal(menus[0].id);
99
+ });
100
+
101
+ it('renders menu item icons', async () => {
102
+ const el = await fixture(container(menus));
103
+
104
+ const icons = el
105
+ .shadowRoot
106
+ .querySelectorAll('menu-button');
107
+ const icon1 = icons[0].shadowRoot.querySelector('#icon-1');
108
+ const icon2 = icons[1].shadowRoot.querySelector('b');
109
+
110
+ expect(icons).to.exist;
111
+ expect(icon1).to.exist;
112
+ expect(icon2).to.exist;
113
+ });
114
+
115
+ it('renders the menu component when menu button clicked', async () => {
116
+ const el = await fixture(container(menus));
117
+ const h1 = await fixture(menus[0].component);
118
+
119
+ el
120
+ .shadowRoot
121
+ .querySelector('menu-button')
122
+ .shadowRoot
123
+ .querySelector('button')
124
+ .click();
125
+ await el.updateComplete;
126
+ const menuComponent = el
127
+ .shadowRoot
128
+ .querySelector('.content h1');
129
+
130
+ expect(menuComponent).to.not.be.undefined;
131
+ expect(menuComponent.innerText).to.equal(h1.innerText);
132
+ });
133
+
134
+ it('does not capture click events on menu items marked followable', async () => {
135
+ const el = await fixture(container(menus));
136
+
137
+ el
138
+ .shadowRoot
139
+ .querySelectorAll('menu-button')[2]
140
+ .shadowRoot
141
+ .querySelector('a')
142
+ .click();
143
+ await el.updateComplete;
144
+
145
+ expect(el.selectedMenu).to.not.equal(menus[2].id);
146
+ });
147
+
148
+ describe('Menu list', async () => {
149
+ const el = await fixture(container(menus));
150
+ const menuList = el
151
+ .shadowRoot
152
+ .querySelectorAll('menu-button');
153
+
154
+ it('shows menu details when available', () => {
155
+ const firstMenuItem = menuList[0].shadowRoot.querySelector('.menu-details');
156
+ expect(firstMenuItem.innerText).to.equal(menus[0].menuDetails);
157
+
158
+ const secondMenuItem = menuList[1].shadowRoot.querySelector('.menu-details');
159
+ expect(secondMenuItem.innerText).to.be.empty;
160
+ });
161
+ });
162
+
163
+ describe('Header section', () => {
164
+ let extraButtonClicked = false;
165
+ const extraActionClickHandler = () => {
166
+ extraButtonClicked = true;
167
+ };
168
+ const menu = {
169
+ icon: html`<ia-icon icon="audio"></ia-icon>`,
170
+ title: 'Audio Menu',
171
+ menuDetails: '(100,000,000 tracks)',
172
+ actionButton: html`
173
+ <button
174
+ id="custom-action-button"
175
+ style='color: white;'
176
+ @click=${extraActionClickHandler}
177
+ >Foo</button>
178
+ `,
179
+ label: 'Audio',
180
+ id: 'audio',
181
+ component: html`
182
+ <h1>Menu 2</h1>
183
+ `,
184
+ };
185
+
186
+ it('creates a header section', async () => {
187
+ const el = await fixture(container([menu]));
188
+ el
189
+ .shadowRoot
190
+ .querySelectorAll('menu-button')[0]
191
+ .shadowRoot
192
+ .querySelector('button')
193
+ .click();
194
+ await el.updateComplete;
195
+
196
+ const menuHeader = el.shadowRoot.querySelector('.content header');
197
+ expect(menuHeader).to.not.be.undefined;
198
+
199
+ const title = menuHeader.querySelector('h3');
200
+ expect(title).to.not.be.undefined;
201
+ expect(title.innerText).to.equal(menu.label);
202
+
203
+ const description = menuHeader.querySelector('.extra-details');
204
+ expect(description).to.not.be.undefined;
205
+ expect(description.innerText).to.equal(menu.menuDetails);
206
+
207
+ const closeButton = menuHeader.querySelector('.close');
208
+ expect(closeButton).to.not.be.undefined;
209
+
210
+ const actionButton = menuHeader.querySelector('.custom-action');
211
+ expect(actionButton).to.not.be.undefined;
212
+ });
213
+
214
+ it('can click on the custom action', async () => {
215
+ const el = await fixture(container([menu]));
216
+ el
217
+ .shadowRoot
218
+ .querySelectorAll('menu-button')[0]
219
+ .shadowRoot
220
+ .querySelector('button')
221
+ .click();
222
+ await el.updateComplete;
223
+
224
+ const menuHeader = el.shadowRoot.querySelector('.content header');
225
+ const actionButton = menuHeader.querySelector('.custom-action > *');
226
+ expect(el.selectedMenuAction).to.not.be.undefined;
227
+ expect(extraButtonClicked).to.be.false; // has not been clicked
228
+
229
+ const actionClick = new MouseEvent('click');
230
+ actionButton.dispatchEvent(actionClick);
231
+ await el.updateComplete;
232
+ expect(extraButtonClicked).to.be.true;
233
+ });
234
+ });
235
+
236
+ describe('Close behavior', () => {
237
+ it('emits a custom event when the drawer closes', async () => {
238
+ const el = await fixture(container(menus));
239
+ el.open = true;
240
+ await el.updateComplete;
241
+ expect(el.open).to.be.true;
242
+
243
+ const menuHeader = el.shadowRoot.querySelector('.content header');
244
+ const closeButton = menuHeader.querySelector('button.close');
245
+ closeButton.dispatchEvent(new MouseEvent('click'));
246
+ await el.updateComplete;
247
+ expect(el.open).to.be.false;
248
+ });
249
+ it('emits event but does not close drawer if prop `manuallyHandleClose = true`', async () => {
250
+ let sliderEmittedEvent = false;
251
+ const el = await fixture(container(menus));
252
+ el.manuallyHandleClose = true;
253
+ el.open = true;
254
+ await el.updateComplete;
255
+
256
+ // confirm base config
257
+ expect(el.open).to.be.true;
258
+ expect(sliderEmittedEvent).to.be.false;
259
+
260
+ el.addEventListener('menuSliderClosed', () => {
261
+ sliderEmittedEvent = true;
262
+ });
263
+
264
+ const menuHeader = el.shadowRoot.querySelector('.content header');
265
+ const closeButton = menuHeader.querySelector('button.close');
266
+ closeButton.dispatchEvent(new MouseEvent('click'));
267
+ await el.updateComplete;
268
+
269
+ expect(sliderEmittedEvent).to.be.true; // handler received click event
270
+ expect(el.open).to.be.true; // open state is still active, does not close
271
+ });
272
+ });
273
+ });
@@ -1,37 +0,0 @@
1
- import { TemplateResult } from "lit-html";
2
- import { ModalConfig } from "@internetarchive/modal-manager";
3
- import { IntMenuProvider, IntMenuShortcut } from './menu-interfaces';
4
- /** Toggles Menu && Sets open panel */
5
- export interface IntManageSideMenuEvent extends CustomEvent {
6
- detail: {
7
- menuId: string | undefined | '';
8
- action: 'open' | 'toggle' | '';
9
- };
10
- }
11
- /** Sets open panel */
12
- export interface IntSetOpenMenuEvent extends CustomEvent {
13
- detail: {
14
- id: string; /** name of menu to open */
15
- };
16
- }
17
- /** Sets menu order that is displayed */
18
- export interface IntSetMenuContentsEvent extends CustomEvent {
19
- detail: IntMenuProvider[];
20
- }
21
- /** list of shortcut configs that displays in minimized menu */
22
- export interface IntSetMenuShortcuts extends CustomEvent {
23
- detail: IntMenuShortcut[];
24
- }
25
- /** Toggles fullscreen mode */
26
- export interface IntManageFullscreenEvent extends CustomEvent {
27
- detail: {
28
- isFullScreen: boolean;
29
- };
30
- }
31
- /** Toggles modal & sets contents */
32
- export interface IntOpenModalEvent extends CustomEvent {
33
- detail: {
34
- config: ModalConfig;
35
- customModalContent: TemplateResult;
36
- };
37
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=event-interfaces.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"event-interfaces.js","sourceRoot":"","sources":["../../src/event-interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import { TemplateResult } from \"lit-html\";\nimport { ModalConfig } from \"@internetarchive/modal-manager\";\nimport { IntMenuProvider, IntMenuShortcut } from './menu-interfaces';\n\n/** Toggles Menu && Sets open panel */\nexport interface IntManageSideMenuEvent extends CustomEvent {\n detail: {\n menuId: string|undefined|'';\n action: 'open'|'toggle'|'';\n }\n}\n\n/** Sets open panel */\nexport interface IntSetOpenMenuEvent extends CustomEvent {\n detail: {\n id: string; /** name of menu to open */\n }\n}\n\n/** Sets menu order that is displayed */\nexport interface IntSetMenuContentsEvent extends CustomEvent {\n detail: IntMenuProvider[];\n}\n\n/** list of shortcut configs that displays in minimized menu */\nexport interface IntSetMenuShortcuts extends CustomEvent {\n detail: IntMenuShortcut[];\n}\n\n\n/** Toggles fullscreen mode */\nexport interface IntManageFullscreenEvent extends CustomEvent {\n detail: {\n isFullScreen: boolean\n }\n}\n\n/** Toggles modal & sets contents */\nexport interface IntOpenModalEvent extends CustomEvent {\n detail: {\n config: ModalConfig;\n customModalContent: TemplateResult;\n }\n}\n"]}
File without changes
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=grouped-files-provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"grouped-files-provider.js","sourceRoot":"","sources":["../../src/grouped-files-provider.ts"],"names":[],"mappings":"","sourcesContent":[""]}
@@ -1,20 +0,0 @@
1
- import { LitElement } from 'lit-element';
2
- import { MetadataResponse } from '@internetarchive/search-service';
3
- import { ModalManager } from '@internetarchive/modal-manager';
4
- import { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
5
- import { IntMenuProvider, IntMenuShortcut } from './menu-interfaces';
6
- export interface CustomTheaterInterface extends LitElement {
7
- baseHost?: string;
8
- itemMD?: MetadataResponse;
9
- menuProviders?: IntMenuProvider[];
10
- menuShortcuts?: IntMenuShortcut[];
11
- sideMenuOpen: boolean;
12
- signedIn?: boolean | null;
13
- sharedObserver?: SharedResizeObserver;
14
- modal?: ModalManager;
15
- emitLoadingStatusUpdate: (loaded: boolean) => void;
16
- addMenuShortcut: (menuId: string) => void;
17
- removeMenuShortcut: (menuId: string) => void;
18
- sortMenuShortcuts: () => void;
19
- emitMenuShortcutsUpdated: () => void;
20
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=nav-controller-interface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nav-controller-interface.js","sourceRoot":"","sources":["../../../src/interfaces/nav-controller-interface.ts"],"names":[],"mappings":"","sourcesContent":["import { LitElement } from 'lit-element';\nimport { MetadataResponse } from '@internetarchive/search-service';\nimport { ModalManager } from '@internetarchive/modal-manager';\nimport { SharedResizeObserver } from '@internetarchive/shared-resize-observer';\nimport { IntMenuProvider, IntMenuShortcut } from './menu-interfaces';\n\nexport interface CustomTheaterInterface extends LitElement {\n baseHost?: string;\n itemMD?: MetadataResponse;\n menuProviders?: IntMenuProvider[];\n menuShortcuts?: IntMenuShortcut[];\n sideMenuOpen: boolean;\n\n signedIn?: boolean | null;\n\n sharedObserver?: SharedResizeObserver;\n modal?: ModalManager;\n\n emitLoadingStatusUpdate: (loaded: boolean) => void;\n\n addMenuShortcut: (menuId: string) => void;\n removeMenuShortcut: (menuId: string) => void;\n sortMenuShortcuts: () => void;\n emitMenuShortcutsUpdated: () => void;\n}\n"]}
@@ -1,14 +0,0 @@
1
- import { TemplateResult } from 'lit-element';
2
- import './ia-files-by-type';
3
- import '@internetarchive/icon-share/icon-share';
4
- import { IntMenuProvider, IntProviderArgs } from '../../interfaces/menu-interfaces';
5
- export declare class FilesByTypeProvider implements IntMenuProvider {
6
- item: any;
7
- baseHost: string;
8
- icon: TemplateResult;
9
- id: string;
10
- label: string;
11
- component: TemplateResult | null;
12
- subPrefix: string;
13
- constructor(shareArgs: IntProviderArgs);
14
- }
@@ -1,29 +0,0 @@
1
- import { html } from 'lit-element';
2
- import './ia-files-by-type';
3
- import '@internetarchive/icon-share/icon-share';
4
- export class FilesByTypeProvider {
5
- constructor(shareArgs) {
6
- this.item = null;
7
- this.baseHost = 'https://archive.org';
8
- this.icon = html `<p
9
- style="color: #fff; font-size: var(--iconHeight);"
10
- >
11
- F
12
- </p>`;
13
- this.id = 'filesByType';
14
- this.label = 'Files by type';
15
- this.component = null;
16
- this.subPrefix = '';
17
- const { item, baseHost, subPrefix = '' } = shareArgs;
18
- const { title = '' } = item.metadata;
19
- this.item = item;
20
- this.baseHost = baseHost;
21
- this.subPrefix = subPrefix;
22
- this.component = html `<ia-files-by-type
23
- .item=${this.item}
24
- .description="${title}"
25
- .baseHost="${this.baseHost}"
26
- ></ia-files-by-type>`;
27
- }
28
- }
29
- //# sourceMappingURL=files-by-type-provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"files-by-type-provider.js","sourceRoot":"","sources":["../../../../src/item-inspector/files-by-type/files-by-type-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAkB,MAAM,aAAa,CAAC;AAEnD,OAAO,oBAAoB,CAAC;AAC5B,OAAO,wCAAwC,CAAC;AAMhD,MAAM,OAAO,mBAAmB;IAmB9B,YAAY,SAA0B;QAlBtC,SAAI,GAAQ,IAAI,CAAC;QAEjB,aAAQ,GAAW,qBAAqB,CAAC;QAEzC,SAAI,GAAmB,IAAI,CAAA;;;;OAItB,CAAC;QAEN,OAAE,GAAW,aAAa,CAAC;QAE3B,UAAK,GAAW,eAAe,CAAC;QAEhC,cAAS,GAA0B,IAAI,CAAC;QAExC,cAAS,GAAW,EAAE,CAAC;QAGrB,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,GAAG,EAAE,EAAE,GAAG,SAAS,CAAC;QACrD,MAAM,EAAE,KAAK,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC;QAErC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAE3B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAA;cACX,IAAI,CAAC,IAAI;sBACD,KAAK;mBACR,IAAI,CAAC,QAAQ;yBACP,CAAC;IACxB,CAAC;CACF","sourcesContent":["import { html, TemplateResult } from 'lit-element';\n\nimport './ia-files-by-type';\nimport '@internetarchive/icon-share/icon-share';\nimport {\n IntMenuProvider,\n IntProviderArgs,\n} from '../../interfaces/menu-interfaces';\n\nexport class FilesByTypeProvider implements IntMenuProvider {\n item: any = null;\n\n baseHost: string = 'https://archive.org';\n\n icon: TemplateResult = html`<p\n style=\"color: #fff; font-size: var(--iconHeight);\"\n >\n F\n </p>`;\n\n id: string = 'filesByType';\n\n label: string = 'Files by type';\n\n component: TemplateResult | null = null;\n\n subPrefix: string = '';\n\n constructor(shareArgs: IntProviderArgs) {\n const { item, baseHost, subPrefix = '' } = shareArgs;\n const { title = '' } = item.metadata;\n\n this.item = item;\n this.baseHost = baseHost;\n this.subPrefix = subPrefix;\n\n this.component = html`<ia-files-by-type\n .item=${this.item}\n .description=\"${title}\"\n .baseHost=\"${this.baseHost}\"\n ></ia-files-by-type>`;\n }\n}\n"]}
@@ -1,16 +0,0 @@
1
- import { MetadataResponse, File } from '@internetarchive/search-service';
2
- import { LitElement } from 'lit-element';
3
- interface CollapsedFileInt extends File {
4
- [menuId: string]: any;
5
- derivatives: [];
6
- }
7
- export default class IaFilesByType extends LitElement {
8
- item: MetadataResponse;
9
- archivalArtifacts: File[];
10
- collapsedFiles: CollapsedFileInt[];
11
- firstUpdated(): void;
12
- render(): import("lit-element").TemplateResult;
13
- sortByViewer(): boolean;
14
- collapseFiles(): void;
15
- }
16
- export {};
@@ -1,95 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { html, customElement, LitElement, property } from 'lit-element';
3
- let IaFilesByType = class IaFilesByType extends LitElement {
4
- constructor() {
5
- super(...arguments);
6
- this.item = {};
7
- this.archivalArtifacts = [];
8
- this.collapsedFiles = [];
9
- }
10
- firstUpdated() {
11
- this.collapseFiles();
12
- }
13
- render() {
14
- return html `
15
- <div>
16
- <p>there are ${this.collapsedFiles.length} original files</p>
17
-
18
- <p>there are ${this.archivalArtifacts.length} archival artifacts</p>
19
-
20
- <p></p>
21
- </div>
22
- `;
23
- }
24
- sortByViewer() {
25
- // const images = [];
26
- // const books = [];
27
- // const radio = [];
28
- // const audio = [];
29
- // const video = [];
30
- // const albums = [];
31
- // const software = [];
32
- // this.collapsedFiles.forEach((fi) => {
33
- // // if image
34
- // // sort by various viewers
35
- // })
36
- return true;
37
- }
38
- collapseFiles() {
39
- const { files = [] } = this === null || this === void 0 ? void 0 : this.item;
40
- const archivalArtifacts = [];
41
- const origDir = {};
42
- files.forEach(fi => {
43
- const { format, source, name, original = '' } = fi;
44
- if (format.toLowerCase() === 'metadata' ||
45
- format.toLowerCase() === 'item tile') {
46
- archivalArtifacts.push(fi);
47
- return;
48
- }
49
- let origEntry = {};
50
- if (source === 'original') {
51
- origEntry = origDir[name];
52
- if (!origEntry) {
53
- // add new
54
- origDir[name] = { ...fi, derivatives: [] };
55
- origEntry = origDir[name];
56
- }
57
- else {
58
- // update
59
- const merged = { ...origEntry, ...fi };
60
- origDir[name] = merged;
61
- }
62
- return;
63
- }
64
- if (source === 'derivative') {
65
- const keyToFile = original || '';
66
- origEntry = origDir[keyToFile];
67
- if (!origEntry && original) {
68
- // add new
69
- const fileFrame = { derivatives: [] };
70
- origEntry = fileFrame;
71
- origEntry === null || origEntry === void 0 ? void 0 : origEntry.derivatives.push(fi);
72
- origDir[keyToFile] = origEntry;
73
- origEntry = origDir[keyToFile];
74
- }
75
- origEntry === null || origEntry === void 0 ? void 0 : origEntry.derivatives.push(fi);
76
- }
77
- });
78
- this.archivalArtifacts = archivalArtifacts;
79
- this.collapsedFiles = Object.keys(origDir).map((fileName) => origDir[fileName]);
80
- }
81
- };
82
- __decorate([
83
- property({ type: Object })
84
- ], IaFilesByType.prototype, "item", void 0);
85
- __decorate([
86
- property({ type: Array })
87
- ], IaFilesByType.prototype, "archivalArtifacts", void 0);
88
- __decorate([
89
- property({ type: Array })
90
- ], IaFilesByType.prototype, "collapsedFiles", void 0);
91
- IaFilesByType = __decorate([
92
- customElement('ia-files-by-type')
93
- ], IaFilesByType);
94
- export default IaFilesByType;
95
- //# sourceMappingURL=ia-files-by-type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ia-files-by-type.js","sourceRoot":"","sources":["../../../../src/item-inspector/files-by-type/ia-files-by-type.ts"],"names":[],"mappings":"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","sourcesContent":["import { MetadataResponse, File } from '@internetarchive/search-service';\nimport { html, customElement, LitElement, property } from 'lit-element';\n\ninterface CollapsedFileInt extends File {\n [menuId: string]: any;\n derivatives: [];\n}\n\n@customElement('ia-files-by-type')\nexport default class IaFilesByType extends LitElement {\n @property({ type: Object }) item: MetadataResponse = {} as MetadataResponse;\n\n @property({ type: Array }) archivalArtifacts: File[] = [];\n\n @property({ type: Array }) collapsedFiles: CollapsedFileInt[] = [];\n\n firstUpdated() {\n this.collapseFiles();\n }\n\n render() {\n return html`\n <div>\n <p>there are ${this.collapsedFiles.length} original files</p>\n\n <p>there are ${this.archivalArtifacts.length} archival artifacts</p>\n\n <p></p>\n </div>\n `;\n }\n\n sortByViewer() {\n // const images = [];\n // const books = [];\n // const radio = [];\n // const audio = [];\n // const video = [];\n // const albums = [];\n // const software = [];\n // this.collapsedFiles.forEach((fi) => {\n // // if image\n // // sort by various viewers\n // })\n\n return true;\n }\n\n collapseFiles() {\n const { files = [] } = this?.item as MetadataResponse;\n\n const archivalArtifacts: File[] = [];\n const origDir: any = {};\n\n files.forEach(fi => {\n const { format, source, name, original = '' } = fi as File;\n if (\n format.toLowerCase() === 'metadata' ||\n format.toLowerCase() === 'item tile'\n ) {\n archivalArtifacts.push(fi);\n return;\n }\n\n let origEntry: any = {};\n if (source === 'original') {\n origEntry = origDir[name];\n if (!origEntry) {\n // add new\n origDir[name] = { ...fi, derivatives: [] } as CollapsedFileInt;\n origEntry = origDir[name];\n } else {\n // update\n const merged = { ...origEntry, ...fi };\n origDir[name] = merged;\n }\n return;\n }\n\n if (source === 'derivative') {\n const keyToFile = original || '';\n origEntry = origDir[keyToFile];\n if (!origEntry && original) {\n // add new\n const fileFrame = { derivatives: [] } as CollapsedFileInt;\n origEntry = fileFrame;\n origEntry?.derivatives.push(fi);\n origDir[keyToFile] = origEntry;\n origEntry = origDir[keyToFile];\n }\n origEntry?.derivatives.push(fi);\n }\n });\n\n this.archivalArtifacts = archivalArtifacts;\n this.collapsedFiles = Object.keys(origDir).map(\n (fileName: string) => origDir[fileName]\n );\n }\n}\n"]}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=ia-grouped-files-by-type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ia-grouped-files-by-type.js","sourceRoot":"","sources":["../../../../src/item-inspector/files-by-type/ia-grouped-files-by-type.ts"],"names":[],"mappings":"","sourcesContent":[""]}
@@ -1,15 +0,0 @@
1
- import { TemplateResult } from 'lit-element';
2
- import '@internetarchive/ia-sharing-options';
3
- import '@internetarchive/icon-share/icon-share';
4
- import { IntMenuProvider, IntProviderArgs } from '../../interfaces/menu-interfaces';
5
- export declare class GroupedFilesProvider implements IntMenuProvider {
6
- item: any;
7
- baseHost: string;
8
- icon: TemplateResult;
9
- id: string;
10
- label: string;
11
- component: TemplateResult | null;
12
- subPrefix: string;
13
- encodedSubPrefix: string;
14
- constructor(shareArgs: IntProviderArgs);
15
- }
@@ -1,33 +0,0 @@
1
- import { html } from 'lit-element';
2
- import '@internetarchive/ia-sharing-options';
3
- import '@internetarchive/icon-share/icon-share';
4
- export class GroupedFilesProvider {
5
- constructor(shareArgs) {
6
- this.item = null;
7
- this.baseHost = 'https://archive.org';
8
- this.icon = html `<ia-icon-share style="width: var(--iconWidth); height: var(--iconHeight);"></ia-icon-share>`;
9
- this.id = 'share';
10
- this.label = 'Share this item';
11
- this.component = null;
12
- this.subPrefix = '';
13
- this.encodedSubPrefix = '';
14
- const { item, baseHost, subPrefix = '' } = shareArgs;
15
- const { identifier = '', creator = '', title = '' } = item.metadata || {};
16
- const encodedSubPrefix = encodeURIComponent(subPrefix);
17
- const urlIdentifier = subPrefix && subPrefix !== identifier
18
- ? `${identifier}/${encodedSubPrefix}`
19
- : identifier;
20
- this.item = item;
21
- this.baseHost = baseHost;
22
- this.subPrefix = subPrefix;
23
- this.encodedSubPrefix = encodedSubPrefix;
24
- this.component = html `<ia-sharing-options
25
- identifier=${urlIdentifier}
26
- type="item"
27
- creator="${creator}"
28
- description="${title}"
29
- baseHost="${this.baseHost}"
30
- ></ia-sharing-options>`;
31
- }
32
- }
33
- //# sourceMappingURL=files-by-type-provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"files-by-type-provider.js","sourceRoot":"","sources":["../../../../src/item-inspector/grouped-files/files-by-type-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAkB,MAAM,aAAa,CAAC;AAEnD,OAAO,qCAAqC,CAAC;AAC7C,OAAO,wCAAwC,CAAC;AAGhD,MAAM,OAAO,oBAAoB;IAiB/B,YAAY,SAA0B;QAhBtC,SAAI,GAAQ,IAAI,CAAC;QAEjB,aAAQ,GAAW,qBAAqB,CAAC;QAEzC,SAAI,GAAmB,IAAI,CAAA,6FAA6F,CAAC;QAEzH,OAAE,GAAW,OAAO,CAAC;QAErB,UAAK,GAAW,iBAAiB,CAAC;QAElC,cAAS,GAA0B,IAAI,CAAC;QAExC,cAAS,GAAW,EAAE,CAAC;QAEvB,qBAAgB,GAAW,EAAE,CAAC;QAG5B,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,GAAG,EAAE,EAAE,GAAG,SAAS,CAAC;QACrD,MAAM,EAAE,UAAU,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,KAAK,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;QAC1E,MAAM,gBAAgB,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;QACvD,MAAM,aAAa,GACjB,SAAS,IAAI,SAAS,KAAK,UAAU;YACnC,CAAC,CAAC,GAAG,UAAU,IAAI,gBAAgB,EAAE;YACrC,CAAC,CAAC,UAAU,CAAC;QAEjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QAEzC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAA;mBACN,aAAa;;iBAEf,OAAO;qBACH,KAAK;kBACR,IAAI,CAAC,QAAQ;2BACJ,CAAC;IAC1B,CAAC;CACF","sourcesContent":["import { html, TemplateResult } from 'lit-element';\n\nimport '@internetarchive/ia-sharing-options';\nimport '@internetarchive/icon-share/icon-share';\nimport { IntMenuProvider, IntProviderArgs } from '../../interfaces/menu-interfaces';\n\nexport class GroupedFilesProvider implements IntMenuProvider {\n item: any = null;\n\n baseHost: string = 'https://archive.org';\n\n icon: TemplateResult = html`<ia-icon-share style=\"width: var(--iconWidth); height: var(--iconHeight);\"></ia-icon-share>`;\n\n id: string = 'share';\n\n label: string = 'Share this item';\n\n component: TemplateResult | null = null;\n\n subPrefix: string = '';\n\n encodedSubPrefix: string = '';\n\n constructor(shareArgs: IntProviderArgs) {\n const { item, baseHost, subPrefix = '' } = shareArgs;\n const { identifier = '', creator = '', title = '' } = item.metadata || {};\n const encodedSubPrefix = encodeURIComponent(subPrefix);\n const urlIdentifier =\n subPrefix && subPrefix !== identifier\n ? `${identifier}/${encodedSubPrefix}`\n : identifier;\n\n this.item = item;\n this.baseHost = baseHost;\n this.subPrefix = subPrefix;\n this.encodedSubPrefix = encodedSubPrefix;\n\n this.component = html`<ia-sharing-options\n identifier=${urlIdentifier}\n type=\"item\"\n creator=\"${creator}\"\n description=\"${title}\"\n baseHost=\"${this.baseHost}\"\n ></ia-sharing-options>`;\n }\n}\n"]}
@@ -1,15 +0,0 @@
1
- import { TemplateResult } from 'lit-element';
2
- import '@internetarchive/ia-sharing-options';
3
- import '@internetarchive/icon-share/icon-share';
4
- import { IntMenuProvider, IntProviderArgs } from '../../interfaces/menu-interfaces';
5
- export declare class GroupedFilesProvider implements IntMenuProvider {
6
- item: any;
7
- baseHost: string;
8
- icon: TemplateResult;
9
- id: string;
10
- label: string;
11
- component: TemplateResult | null;
12
- subPrefix: string;
13
- encodedSubPrefix: string;
14
- constructor(shareArgs: IntProviderArgs);
15
- }
@@ -1,33 +0,0 @@
1
- import { html } from 'lit-element';
2
- import '@internetarchive/ia-sharing-options';
3
- import '@internetarchive/icon-share/icon-share';
4
- export class GroupedFilesProvider {
5
- constructor(shareArgs) {
6
- this.item = null;
7
- this.baseHost = 'https://archive.org';
8
- this.icon = html `<ia-icon-share style="width: var(--iconWidth); height: var(--iconHeight);"></ia-icon-share>`;
9
- this.id = 'share';
10
- this.label = 'Share this item';
11
- this.component = null;
12
- this.subPrefix = '';
13
- this.encodedSubPrefix = '';
14
- const { item, baseHost, subPrefix = '' } = shareArgs;
15
- const { identifier = '', creator = '', title = '' } = item.metadata || {};
16
- const encodedSubPrefix = encodeURIComponent(subPrefix);
17
- const urlIdentifier = subPrefix && subPrefix !== identifier
18
- ? `${identifier}/${encodedSubPrefix}`
19
- : identifier;
20
- this.item = item;
21
- this.baseHost = baseHost;
22
- this.subPrefix = subPrefix;
23
- this.encodedSubPrefix = encodedSubPrefix;
24
- this.component = html `<ia-sharing-options
25
- identifier=${urlIdentifier}
26
- type="item"
27
- creator="${creator}"
28
- description="${title}"
29
- baseHost="${this.baseHost}"
30
- ></ia-sharing-options>`;
31
- }
32
- }
33
- //# sourceMappingURL=grouped-files-provider.js.map