@internetarchive/collection-browser 3.2.0 → 3.3.1-alpha1
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/.editorconfig +29 -29
- package/.github/workflows/ci.yml +27 -27
- package/.github/workflows/gh-pages-main.yml +39 -39
- package/.github/workflows/npm-publish.yml +39 -39
- package/.github/workflows/pr-preview.yml +38 -38
- package/.husky/pre-commit +4 -4
- package/.prettierignore +1 -1
- package/LICENSE +661 -661
- package/README.md +83 -83
- package/dist/src/collection-browser.d.ts +4 -0
- package/dist/src/collection-browser.js +702 -682
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets/more-facets-content.js +118 -118
- package/dist/src/collection-facets/more-facets-content.js.map +1 -1
- package/dist/src/collection-facets.js +266 -266
- package/dist/src/collection-facets.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
- package/dist/src/data-source/models.js.map +1 -1
- package/dist/src/tiles/base-tile-component.d.ts +7 -0
- package/dist/src/tiles/base-tile-component.js +13 -0
- package/dist/src/tiles/base-tile-component.js.map +1 -1
- package/dist/src/tiles/grid/account-tile.js +37 -36
- package/dist/src/tiles/grid/account-tile.js.map +1 -1
- package/dist/src/tiles/grid/collection-tile.js +78 -77
- package/dist/src/tiles/grid/collection-tile.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.d.ts +1 -1
- package/dist/src/tiles/grid/item-tile.js +139 -140
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact.js +100 -98
- package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
- package/dist/src/tiles/list/tile-list.js +300 -300
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/src/tiles/tile-dispatcher.js +204 -200
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/dist/src/utils/format-date.d.ts +15 -1
- package/dist/src/utils/format-date.js +8 -3
- package/dist/src/utils/format-date.js.map +1 -1
- package/dist/test/collection-browser.test.js +189 -189
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/tiles/grid/item-tile.test.js +115 -64
- package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
- package/dist/test/tiles/list/tile-list-compact.test.js +108 -57
- package/dist/test/tiles/list/tile-list-compact.test.js.map +1 -1
- package/dist/test/tiles/list/tile-list.test.js +164 -113
- package/dist/test/tiles/list/tile-list.test.js.map +1 -1
- package/dist/test/utils/format-date.test.js +31 -1
- package/dist/test/utils/format-date.test.js.map +1 -1
- package/eslint.config.mjs +53 -53
- package/index.html +24 -24
- package/local.archive.org.cert +86 -86
- package/local.archive.org.key +27 -27
- package/package.json +117 -117
- package/renovate.json +6 -6
- package/src/collection-browser.ts +2829 -2804
- package/src/collection-facets/more-facets-content.ts +639 -639
- package/src/collection-facets.ts +995 -995
- package/src/data-source/collection-browser-data-source.ts +1401 -1401
- package/src/data-source/collection-browser-query-state.ts +65 -65
- package/src/data-source/models.ts +43 -43
- package/src/tiles/base-tile-component.ts +65 -53
- package/src/tiles/grid/account-tile.ts +113 -112
- package/src/tiles/grid/collection-tile.ts +163 -162
- package/src/tiles/grid/item-tile.ts +340 -339
- package/src/tiles/list/tile-list-compact.ts +239 -236
- package/src/tiles/list/tile-list.ts +700 -696
- package/src/tiles/tile-dispatcher.ts +490 -486
- package/src/utils/format-date.ts +62 -42
- package/test/collection-browser.test.ts +2403 -2403
- package/test/tiles/grid/item-tile.test.ts +520 -464
- package/test/tiles/list/tile-list-compact.test.ts +282 -228
- package/test/tiles/list/tile-list.test.ts +552 -497
- package/test/utils/format-date.test.ts +89 -39
- package/tsconfig.json +20 -20
- package/web-dev-server.config.mjs +30 -30
- package/web-test-runner.config.mjs +41 -41
|
@@ -1,39 +1,89 @@
|
|
|
1
|
-
import { expect } from '@open-wc/testing';
|
|
2
|
-
import { formatDate } from '../../src/utils/format-date';
|
|
3
|
-
|
|
4
|
-
const testDate = new Date(2020, 11, 9);
|
|
5
|
-
|
|
6
|
-
describe('formatDate', () => {
|
|
7
|
-
it('returns blank when undefined date', () => {
|
|
8
|
-
expect(formatDate(undefined)).to.equal('');
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it('returns short date when no DateFormat', () => {
|
|
12
|
-
expect(formatDate(testDate)).to.equal('Dec 2020');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('returns long date when long DateFormat', () => {
|
|
16
|
-
expect(formatDate(testDate, 'long')).to.equal('Dec 09, 2020');
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('returns year-only date when year-only DateFormat', () => {
|
|
20
|
-
expect(formatDate(testDate, 'year-only')).to.equal('2020');
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('returns correct year for old "Jan 1 at midnight" dates and year-only DateFormat', () => {
|
|
24
|
-
// Many standard timezones have a discontinuity in date parsing at some point during
|
|
25
|
-
// the 19th or 20th century, corresponding to the creation of the timezone.
|
|
26
|
-
// Dates prior to the discontinuity generally have a non-hour-aligned timezone offset
|
|
27
|
-
// which can throw off the calculated year for dates which are close to a year boundary.
|
|
28
|
-
// This is particularly problematic for "Jan 1 at midnight" dates, which are what we
|
|
29
|
-
// receive from the search engine for date metadata that only specifies the year.
|
|
30
|
-
// So we must ensure these older dates still output the correct year, not the prior one.
|
|
31
|
-
expect(formatDate(new Date('1234-01-01T00:00:00Z'), 'year-only')).to.equal(
|
|
32
|
-
'1234',
|
|
33
|
-
);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { formatDate } from '../../src/utils/format-date';
|
|
3
|
+
|
|
4
|
+
const testDate = new Date(2020, 11, 9);
|
|
5
|
+
|
|
6
|
+
describe('formatDate', () => {
|
|
7
|
+
it('returns blank when undefined date', () => {
|
|
8
|
+
expect(formatDate(undefined)).to.equal('');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('returns short date when no DateFormat', () => {
|
|
12
|
+
expect(formatDate(testDate)).to.equal('Dec 2020');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('returns long date when long DateFormat', () => {
|
|
16
|
+
expect(formatDate(testDate, 'long')).to.equal('Dec 09, 2020');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('returns year-only date when year-only DateFormat', () => {
|
|
20
|
+
expect(formatDate(testDate, 'year-only')).to.equal('2020');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('returns correct year for old "Jan 1 at midnight" dates and year-only DateFormat', () => {
|
|
24
|
+
// Many standard timezones have a discontinuity in date parsing at some point during
|
|
25
|
+
// the 19th or 20th century, corresponding to the creation of the timezone.
|
|
26
|
+
// Dates prior to the discontinuity generally have a non-hour-aligned timezone offset
|
|
27
|
+
// which can throw off the calculated year for dates which are close to a year boundary.
|
|
28
|
+
// This is particularly problematic for "Jan 1 at midnight" dates, which are what we
|
|
29
|
+
// receive from the search engine for date metadata that only specifies the year.
|
|
30
|
+
// So we must ensure these older dates still output the correct year, not the prior one.
|
|
31
|
+
expect(formatDate(new Date('1234-01-01T00:00:00Z'), 'year-only')).to.equal(
|
|
32
|
+
'1234',
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('uses UTC time zone by default or when useLocalTime is explicitly false', () => {
|
|
37
|
+
// Default options
|
|
38
|
+
expect(formatDate(new Date('2025-02-15T00:00:00Z'), 'long')).to.equal(
|
|
39
|
+
'Feb 15, 2025',
|
|
40
|
+
);
|
|
41
|
+
expect(formatDate(new Date('2025-02-15T23:59:59Z'), 'long')).to.equal(
|
|
42
|
+
'Feb 15, 2025',
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
// Explicit `useLocalTime: false` option
|
|
46
|
+
const options = { useLocalTime: false };
|
|
47
|
+
expect(
|
|
48
|
+
formatDate(new Date('2025-02-15T00:00:00Z'), 'long', options),
|
|
49
|
+
).to.equal('Feb 15, 2025');
|
|
50
|
+
expect(
|
|
51
|
+
formatDate(new Date('2025-02-15T23:59:59Z'), 'long', options),
|
|
52
|
+
).to.equal('Feb 15, 2025');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('uses local time zone when specified', () => {
|
|
56
|
+
// N.B.:
|
|
57
|
+
// - Positive offset corresponds to UTC-x zones
|
|
58
|
+
// - Negative offset corresponds to UTC+x zones
|
|
59
|
+
const offset = new Date().getTimezoneOffset();
|
|
60
|
+
const options = { useLocalTime: true };
|
|
61
|
+
|
|
62
|
+
// The expected behavior depends on the local time where the tests are run:
|
|
63
|
+
if (offset > 0) {
|
|
64
|
+
// If we're testing under a positive offset, the first second of the UTC day should locally fall on the previous day
|
|
65
|
+
expect(
|
|
66
|
+
formatDate(new Date('2025-02-15T00:00:00Z'), 'long', options),
|
|
67
|
+
).to.equal('Feb 14, 2025');
|
|
68
|
+
} else if (offset < 0) {
|
|
69
|
+
// If we're testing under a negative offset, the last second of the UTC day should locally fall on the next day
|
|
70
|
+
expect(
|
|
71
|
+
formatDate(new Date('2025-02-15T23:59:59Z'), 'long', options),
|
|
72
|
+
).to.equal('Feb 16, 2025');
|
|
73
|
+
} else {
|
|
74
|
+
// If we're testing *in* UTC, then both seconds should locally fall on the same day
|
|
75
|
+
expect(
|
|
76
|
+
formatDate(new Date('2025-02-15T00:00:00Z'), 'long', options),
|
|
77
|
+
).to.equal('Feb 15, 2025');
|
|
78
|
+
expect(
|
|
79
|
+
formatDate(new Date('2025-02-15T23:59:59Z'), 'long', options),
|
|
80
|
+
).to.equal('Feb 15, 2025');
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('returns locale formatted date', () => {
|
|
85
|
+
expect(formatDate(testDate, 'long', { locale: 'de-DE' })).to.equal(
|
|
86
|
+
'09. Dez. 2020',
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
});
|
package/tsconfig.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es2018",
|
|
4
|
-
"module": "esnext",
|
|
5
|
-
"moduleResolution": "node",
|
|
6
|
-
"noEmitOnError": true,
|
|
7
|
-
"lib": ["es2017", "dom", "dom.iterable"],
|
|
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
|
-
},
|
|
19
|
-
"include": ["src", "test", "index.ts", "types"],
|
|
20
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2018",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"noEmitOnError": true,
|
|
7
|
+
"lib": ["es2017", "dom", "dom.iterable"],
|
|
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
|
+
},
|
|
19
|
+
"include": ["src", "test", "index.ts", "types"],
|
|
20
|
+
}
|
|
@@ -1,30 +1,30 @@
|
|
|
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: '/',
|
|
9
|
-
watch: !hmr,
|
|
10
|
-
|
|
11
|
-
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
|
|
12
|
-
// esbuildTarget: 'auto'
|
|
13
|
-
|
|
14
|
-
/** Set appIndex to enable SPA routing */
|
|
15
|
-
// appIndex: 'demo/index.html',
|
|
16
|
-
|
|
17
|
-
/** Confgure bare import resolve plugin */
|
|
18
|
-
// nodeResolve: {
|
|
19
|
-
// exportConditions: ['browser', 'development']
|
|
20
|
-
// },
|
|
21
|
-
|
|
22
|
-
plugins: [
|
|
23
|
-
/** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
|
|
24
|
-
// hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
|
|
25
|
-
],
|
|
26
|
-
|
|
27
|
-
http2: true,
|
|
28
|
-
sslCert: './local.archive.org.cert',
|
|
29
|
-
sslKey: './local.archive.org.key',
|
|
30
|
-
});
|
|
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: '/',
|
|
9
|
+
watch: !hmr,
|
|
10
|
+
|
|
11
|
+
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
|
|
12
|
+
// esbuildTarget: 'auto'
|
|
13
|
+
|
|
14
|
+
/** Set appIndex to enable SPA routing */
|
|
15
|
+
// appIndex: 'demo/index.html',
|
|
16
|
+
|
|
17
|
+
/** Confgure bare import resolve plugin */
|
|
18
|
+
// nodeResolve: {
|
|
19
|
+
// exportConditions: ['browser', 'development']
|
|
20
|
+
// },
|
|
21
|
+
|
|
22
|
+
plugins: [
|
|
23
|
+
/** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
|
|
24
|
+
// hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
|
|
25
|
+
],
|
|
26
|
+
|
|
27
|
+
http2: true,
|
|
28
|
+
sslCert: './local.archive.org.cert',
|
|
29
|
+
sslKey: './local.archive.org.key',
|
|
30
|
+
});
|
|
@@ -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
|
+
});
|