@internetarchive/collection-browser 4.3.1-alpha-webdev8257.0 → 4.3.1
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/dist/index.d.ts +0 -1
- package/dist/index.js.map +1 -1
- package/dist/src/app-root.d.ts +0 -8
- package/dist/src/app-root.js +672 -698
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/collection-browser.d.ts +0 -8
- package/dist/src/collection-browser.js +762 -779
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/tiles/base-tile-component.d.ts +1 -17
- package/dist/src/tiles/base-tile-component.js +1 -48
- package/dist/src/tiles/base-tile-component.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.js +138 -139
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact-header.js +46 -66
- package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact.d.ts +1 -1
- package/dist/src/tiles/list/tile-list-compact.js +100 -132
- package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
- package/dist/src/tiles/list/tile-list.d.ts +1 -1
- package/dist/src/tiles/list/tile-list.js +298 -316
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/src/tiles/models.d.ts +0 -14
- package/dist/src/tiles/models.js.map +1 -1
- package/dist/src/tiles/tile-dispatcher.d.ts +0 -14
- package/dist/src/tiles/tile-dispatcher.js +216 -319
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/index.ts +28 -29
- package/package.json +2 -2
- package/src/app-root.ts +1251 -1281
- package/src/collection-browser.ts +3049 -3063
- package/src/tiles/base-tile-component.ts +65 -121
- package/src/tiles/grid/item-tile.ts +346 -347
- package/src/tiles/list/tile-list-compact-header.ts +86 -106
- package/src/tiles/list/tile-list-compact.ts +239 -273
- package/src/tiles/list/tile-list.ts +700 -718
- package/src/tiles/models.ts +8 -24
- package/src/tiles/tile-dispatcher.ts +527 -637
- package/dist/src/styles/tile-action-styles.d.ts +0 -14
- package/dist/src/styles/tile-action-styles.js +0 -52
- package/dist/src/styles/tile-action-styles.js.map +0 -1
- package/src/styles/tile-action-styles.ts +0 -52
|
@@ -1,121 +1,65 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { property } from 'lit/decorators.js';
|
|
3
|
-
import type { SortParam } from '@internetarchive/search-service';
|
|
4
|
-
import { TileDisplayValueProvider } from './tile-display-value-provider';
|
|
5
|
-
import type { TileModel } from '../models';
|
|
6
|
-
import { DateFormat, formatDate } from '../utils/format-date';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
@property({ type:
|
|
14
|
-
|
|
15
|
-
@property({ type:
|
|
16
|
-
|
|
17
|
-
@property({ type:
|
|
18
|
-
|
|
19
|
-
@property({ type: String })
|
|
20
|
-
|
|
21
|
-
@property({ type:
|
|
22
|
-
|
|
23
|
-
@property({ type:
|
|
24
|
-
|
|
25
|
-
@property({ type:
|
|
26
|
-
|
|
27
|
-
@property({ type:
|
|
28
|
-
|
|
29
|
-
@property({ type:
|
|
30
|
-
|
|
31
|
-
@property({ type:
|
|
32
|
-
|
|
33
|
-
@property({ type: Boolean })
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
changed.has('
|
|
45
|
-
changed.has('
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const { useLocalTime } = this;
|
|
67
|
-
return formatDate(date, format, { useLocalTime });
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Renders the action buttons configured for this tile, or `nothing` if
|
|
72
|
-
* there are none. Optional `extraClass` is appended to the container's
|
|
73
|
-
* class list so subclasses can target their own layout tweaks.
|
|
74
|
-
*/
|
|
75
|
-
protected renderTileActions(
|
|
76
|
-
extraClass: string = '',
|
|
77
|
-
): TemplateResult | typeof nothing {
|
|
78
|
-
if (!this.tileActions.length) return nothing;
|
|
79
|
-
|
|
80
|
-
const containerClass = extraClass
|
|
81
|
-
? `tile-actions ${extraClass}`
|
|
82
|
-
: 'tile-actions';
|
|
83
|
-
return html`
|
|
84
|
-
<div class=${containerClass}>
|
|
85
|
-
${this.tileActions.map(
|
|
86
|
-
action => html`
|
|
87
|
-
<button
|
|
88
|
-
class="tile-action-btn"
|
|
89
|
-
@click=${(e: Event) => this.handleTileActionClick(e, action)}
|
|
90
|
-
>
|
|
91
|
-
${action.label}
|
|
92
|
-
</button>
|
|
93
|
-
`,
|
|
94
|
-
)}
|
|
95
|
-
</div>
|
|
96
|
-
`;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Click handler for tile action buttons. Stops propagation so the click
|
|
101
|
-
* doesn't activate a wrapping tile link, and dispatches a
|
|
102
|
-
* `tileActionClicked` event (bubbling + composed) carrying the action ID
|
|
103
|
-
* and the tile model.
|
|
104
|
-
*/
|
|
105
|
-
protected handleTileActionClick(e: Event, action: TileAction): void {
|
|
106
|
-
e.preventDefault();
|
|
107
|
-
e.stopPropagation();
|
|
108
|
-
// Pre-set the hover pane controller's clicking flag so that focus
|
|
109
|
-
// restoration after a consumer-opened modal won't trigger the hover pane.
|
|
110
|
-
this.dispatchEvent(
|
|
111
|
-
new PointerEvent('pointerdown', { bubbles: true, composed: true }),
|
|
112
|
-
);
|
|
113
|
-
this.dispatchEvent(
|
|
114
|
-
new CustomEvent('tileActionClicked', {
|
|
115
|
-
detail: { actionId: action.id, model: this.model },
|
|
116
|
-
bubbles: true,
|
|
117
|
-
composed: true,
|
|
118
|
-
}),
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
1
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import type { SortParam } from '@internetarchive/search-service';
|
|
4
|
+
import { TileDisplayValueProvider } from './tile-display-value-provider';
|
|
5
|
+
import type { TileModel } from '../models';
|
|
6
|
+
import { DateFormat, formatDate } from '../utils/format-date';
|
|
7
|
+
|
|
8
|
+
export abstract class BaseTileComponent extends LitElement {
|
|
9
|
+
@property({ type: Object }) model?: TileModel;
|
|
10
|
+
|
|
11
|
+
@property({ type: Number }) currentWidth?: number;
|
|
12
|
+
|
|
13
|
+
@property({ type: Number }) currentHeight?: number;
|
|
14
|
+
|
|
15
|
+
@property({ type: String }) baseNavigationUrl?: string;
|
|
16
|
+
|
|
17
|
+
@property({ type: String }) baseImageUrl?: string;
|
|
18
|
+
|
|
19
|
+
@property({ type: String }) collectionPagePath?: string;
|
|
20
|
+
|
|
21
|
+
@property({ type: Object }) sortParam: SortParam | null = null;
|
|
22
|
+
|
|
23
|
+
@property({ type: Object }) defaultSortParam: SortParam | null = null;
|
|
24
|
+
|
|
25
|
+
@property({ type: String }) creatorFilter?: string;
|
|
26
|
+
|
|
27
|
+
@property({ type: Number }) mobileBreakpoint?: number;
|
|
28
|
+
|
|
29
|
+
@property({ type: Boolean }) loggedIn = false;
|
|
30
|
+
|
|
31
|
+
@property({ type: Boolean }) suppressBlurring = false;
|
|
32
|
+
|
|
33
|
+
@property({ type: Boolean }) useLocalTime = false;
|
|
34
|
+
|
|
35
|
+
protected displayValueProvider = new TileDisplayValueProvider();
|
|
36
|
+
|
|
37
|
+
protected willUpdate(changed: PropertyValues<this>) {
|
|
38
|
+
// Ensure the TileDisplayValueProvider stays up-to-date as properties change
|
|
39
|
+
if (
|
|
40
|
+
changed.has('model') ||
|
|
41
|
+
changed.has('baseNavigationUrl') ||
|
|
42
|
+
changed.has('collectionPagePath') ||
|
|
43
|
+
changed.has('sortParam') ||
|
|
44
|
+
changed.has('defaultSortParam') ||
|
|
45
|
+
changed.has('creatorFilter')
|
|
46
|
+
) {
|
|
47
|
+
this.displayValueProvider = new TileDisplayValueProvider({
|
|
48
|
+
model: this.model,
|
|
49
|
+
baseNavigationUrl: this.baseNavigationUrl,
|
|
50
|
+
collectionPagePath: this.collectionPagePath,
|
|
51
|
+
sortParam: this.sortParam ?? this.defaultSortParam ?? undefined,
|
|
52
|
+
creatorFilter: this.creatorFilter,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The formatted date string for given date and format type, taking into
|
|
59
|
+
* account whether this tile component should be using local time or UTC.
|
|
60
|
+
*/
|
|
61
|
+
protected getFormattedDate(date?: Date, format?: DateFormat): string {
|
|
62
|
+
const { useLocalTime } = this;
|
|
63
|
+
return formatDate(date, format, { useLocalTime });
|
|
64
|
+
}
|
|
65
|
+
}
|