@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.
Files changed (76) hide show
  1. package/.editorconfig +29 -29
  2. package/.github/workflows/ci.yml +27 -27
  3. package/.github/workflows/gh-pages-main.yml +39 -39
  4. package/.github/workflows/npm-publish.yml +39 -39
  5. package/.github/workflows/pr-preview.yml +38 -38
  6. package/.husky/pre-commit +4 -4
  7. package/.prettierignore +1 -1
  8. package/LICENSE +661 -661
  9. package/README.md +83 -83
  10. package/dist/src/collection-browser.d.ts +4 -0
  11. package/dist/src/collection-browser.js +702 -682
  12. package/dist/src/collection-browser.js.map +1 -1
  13. package/dist/src/collection-facets/more-facets-content.js +118 -118
  14. package/dist/src/collection-facets/more-facets-content.js.map +1 -1
  15. package/dist/src/collection-facets.js +266 -266
  16. package/dist/src/collection-facets.js.map +1 -1
  17. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  18. package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
  19. package/dist/src/data-source/models.js.map +1 -1
  20. package/dist/src/tiles/base-tile-component.d.ts +7 -0
  21. package/dist/src/tiles/base-tile-component.js +13 -0
  22. package/dist/src/tiles/base-tile-component.js.map +1 -1
  23. package/dist/src/tiles/grid/account-tile.js +37 -36
  24. package/dist/src/tiles/grid/account-tile.js.map +1 -1
  25. package/dist/src/tiles/grid/collection-tile.js +78 -77
  26. package/dist/src/tiles/grid/collection-tile.js.map +1 -1
  27. package/dist/src/tiles/grid/item-tile.d.ts +1 -1
  28. package/dist/src/tiles/grid/item-tile.js +139 -140
  29. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  30. package/dist/src/tiles/list/tile-list-compact.js +100 -98
  31. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  32. package/dist/src/tiles/list/tile-list.js +300 -300
  33. package/dist/src/tiles/list/tile-list.js.map +1 -1
  34. package/dist/src/tiles/tile-dispatcher.js +204 -200
  35. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  36. package/dist/src/utils/format-date.d.ts +15 -1
  37. package/dist/src/utils/format-date.js +8 -3
  38. package/dist/src/utils/format-date.js.map +1 -1
  39. package/dist/test/collection-browser.test.js +189 -189
  40. package/dist/test/collection-browser.test.js.map +1 -1
  41. package/dist/test/tiles/grid/item-tile.test.js +115 -64
  42. package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
  43. package/dist/test/tiles/list/tile-list-compact.test.js +108 -57
  44. package/dist/test/tiles/list/tile-list-compact.test.js.map +1 -1
  45. package/dist/test/tiles/list/tile-list.test.js +164 -113
  46. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  47. package/dist/test/utils/format-date.test.js +31 -1
  48. package/dist/test/utils/format-date.test.js.map +1 -1
  49. package/eslint.config.mjs +53 -53
  50. package/index.html +24 -24
  51. package/local.archive.org.cert +86 -86
  52. package/local.archive.org.key +27 -27
  53. package/package.json +117 -117
  54. package/renovate.json +6 -6
  55. package/src/collection-browser.ts +2829 -2804
  56. package/src/collection-facets/more-facets-content.ts +639 -639
  57. package/src/collection-facets.ts +995 -995
  58. package/src/data-source/collection-browser-data-source.ts +1401 -1401
  59. package/src/data-source/collection-browser-query-state.ts +65 -65
  60. package/src/data-source/models.ts +43 -43
  61. package/src/tiles/base-tile-component.ts +65 -53
  62. package/src/tiles/grid/account-tile.ts +113 -112
  63. package/src/tiles/grid/collection-tile.ts +163 -162
  64. package/src/tiles/grid/item-tile.ts +340 -339
  65. package/src/tiles/list/tile-list-compact.ts +239 -236
  66. package/src/tiles/list/tile-list.ts +700 -696
  67. package/src/tiles/tile-dispatcher.ts +490 -486
  68. package/src/utils/format-date.ts +62 -42
  69. package/test/collection-browser.test.ts +2403 -2403
  70. package/test/tiles/grid/item-tile.test.ts +520 -464
  71. package/test/tiles/list/tile-list-compact.test.ts +282 -228
  72. package/test/tiles/list/tile-list.test.ts +552 -497
  73. package/test/utils/format-date.test.ts +89 -39
  74. package/tsconfig.json +20 -20
  75. package/web-dev-server.config.mjs +30 -30
  76. package/web-test-runner.config.mjs +41 -41
@@ -1,42 +1,62 @@
1
- /*
2
- * Display date
3
- * Override browser timezone to always display same date as in data
4
- */
5
- export type DateFormat =
6
- | 'year-only' // 2020
7
- | 'short' // Dec 2020
8
- | 'long'; // Dec 20, 2020
9
-
10
- export function formatDate(
11
- date: Date | undefined,
12
- format: DateFormat = 'short',
13
- locale: string = 'en-US',
14
- ): string {
15
- // Return blank if undefined
16
- if (!date) return '';
17
-
18
- // the date is already in UTC timezone so we should not add timeZone here again.
19
- const options: Intl.DateTimeFormatOptions = {};
20
-
21
- switch (format) {
22
- case 'year-only':
23
- // If we're only using the year, ensure we output the correct UTC year and not
24
- // the local year. If the local timezone is used, we can get strange off-by-one
25
- // errors due to quirks of timezone handling for older years.
26
- return `${date.getUTCFullYear()}`;
27
- case 'short':
28
- options.month = 'short';
29
- options.year = 'numeric';
30
- break;
31
- case 'long':
32
- options.year = 'numeric';
33
- options.month = 'short';
34
- options.day = '2-digit';
35
- break;
36
- default:
37
- break;
38
- }
39
-
40
- const dateFormatter = new Intl.DateTimeFormat(locale, options);
41
- return dateFormatter.format(date);
42
- }
1
+ /*
2
+ * Display date
3
+ * Override browser timezone to always display same date as in data
4
+ */
5
+ export type DateFormat =
6
+ | 'year-only' // 2020
7
+ | 'short' // Dec 2020
8
+ | 'long'; // Dec 20, 2020
9
+
10
+ /**
11
+ * Extra options accepted by the `formatDate` function
12
+ */
13
+ export type FormatDateOptions = {
14
+ /**
15
+ * Which locale to format the date string for (default `'en-US'`)
16
+ */
17
+ locale?: string;
18
+ /**
19
+ * Whether to display the date in the browser's local time zone.
20
+ * Default is `false`, displaying the dates in UTC.
21
+ */
22
+ useLocalTime?: boolean;
23
+ };
24
+
25
+ export function formatDate(
26
+ date: Date | undefined,
27
+ format: DateFormat = 'short',
28
+ { locale = 'en-US', useLocalTime = false }: FormatDateOptions = {},
29
+ ): string {
30
+ // Return blank if undefined
31
+ if (!date) return '';
32
+
33
+ // The dates provided by the backend are assumed to already be with respect to UTC,
34
+ // and by default we specify that they should be rendered as such. If the
35
+ // `useLocalTime` option was set, we omit the UTC time zone from our format options
36
+ // so that the browser's local time zone is used instead.
37
+ const options: Intl.DateTimeFormatOptions = useLocalTime
38
+ ? {}
39
+ : { timeZone: 'UTC' };
40
+
41
+ switch (format) {
42
+ case 'year-only':
43
+ // If we're only using the year, ensure we output the correct UTC year and not
44
+ // the local year. If the local timezone is used, we can get strange off-by-one
45
+ // errors due to quirks of timezone handling for older years.
46
+ return `${date.getUTCFullYear()}`;
47
+ case 'short':
48
+ options.month = 'short';
49
+ options.year = 'numeric';
50
+ break;
51
+ case 'long':
52
+ options.year = 'numeric';
53
+ options.month = 'short';
54
+ options.day = '2-digit';
55
+ break;
56
+ default:
57
+ break;
58
+ }
59
+
60
+ const dateFormatter = new Intl.DateTimeFormat(locale, options);
61
+ return dateFormatter.format(date);
62
+ }