@gopherium/godmin 0.17.0 → 0.19.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.
package/README.md CHANGED
@@ -52,7 +52,7 @@ two lines do for you.
52
52
 
53
53
  | Entry point | Contents |
54
54
  | --- | --- |
55
- | `@gopherium/godmin` | `AdminRoot`, `Frame`, `Page`, `PageTitle`, `PageTabs`, `PageTab`, `SectionTitle`, `InitialsAvatar`, `NavScreen`, `ErrorNotice`, `LoadMore`, `LogList`, `LogItem`, `LogTime`, `LoadingScreen`, `LoadingRows`, `Toaster`, `useToaster`, `RepeatRows`, `RowControls`, `useRowKeys`, `keyFromLabel`, `listChromeCatalogFor`, `LIST_CHROME_DOMAIN`, `ListEmpty`, `ConfirmBody`, `RenameBody`, `FileButton`, `useServerPaging`, `pageWindow`, `paginationOf`, `runEach`, `bulkNotes`, `useMediaQuery`, `useTokenDocument`, the breakpoints, `SUPPORTED_WPDS` |
55
+ | `@gopherium/godmin` | `AdminRoot`, `Frame`, `Page`, `PageTitle`, `PageTabs`, `PageTab`, `SectionTitle`, `InitialsAvatar`, `NavScreen`, `ErrorNotice`, `LoadMore`, `LogList`, `LogItem`, `LogTime`, `LoadingScreen`, `LoadingRows`, `Toaster`, `useToaster`, `RepeatRows`, `RowControls`, `useRowKeys`, `keyFromLabel`, `listChromeCatalogFor`, `LIST_CHROME_DOMAIN`, `startListDates`, `listDate`, `ListEmpty`, `ConfirmBody`, `RenameBody`, `FileButton`, `useServerPaging`, `pageWindow`, `paginationOf`, `runEach`, `bulkNotes`, `useMediaQuery`, `useTokenDocument`, the breakpoints, `SUPPORTED_WPDS` |
56
56
  | `@gopherium/godmin/base.css` | Cascade layer order, design tokens, host rules, frame and screen styles |
57
57
  | `@gopherium/godmin/router` | `useListView`, `listSearch`, `openOnTap`, `useCanvas`, `useFrameLocation`, the `canvas` route static data |
58
58
  | `@gopherium/godmin/testing` | `installTestEnvironment`, `renderAdmin`, `setViewport`, `getAnnouncement`, `clearAnnouncements`, `assertElementPatched`, `WPDS_IGNORE_SELECTOR`, `textClasses`, `badgeClasses`, `buttonClasses` |
package/dist/avatar.d.ts CHANGED
@@ -14,10 +14,12 @@ export interface InitialsAvatarProps {
14
14
  name: string;
15
15
  /** The avatar's width and height in pixels, the stylesheet size when absent. */
16
16
  size?: number;
17
+ /** The address of a picture shown in place of the letter, the letter when absent, empty or failing to load. */
18
+ src?: string;
17
19
  }
18
20
  /**
19
- * Renders a round avatar with the first letter of a name, in the letter colour of the circle colour the name picks.
20
- * @param props - The name the avatar stands for and its size.
21
+ * Renders a round avatar with a picture, or the first letter of a name in the colours the name picks.
22
+ * @param props - The name the avatar stands for, its size and the address of its picture.
21
23
  * @returns The avatar element.
22
24
  */
23
- export declare function InitialsAvatar({ name, size }: InitialsAvatarProps): import("react").JSX.Element;
25
+ export declare function InitialsAvatar({ name, size, src }: InitialsAvatarProps): import("react").JSX.Element;
package/dist/avatar.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ /* oxlint-disable react/only-export-components -- the palette ships beside the avatar that paints with it. */
3
+ import { useState } from 'react';
2
4
  /**
3
5
  * The colours an initials avatar paints with, the WordPress blue, raspberry and purple first with their pale letters.
4
6
  */
@@ -17,7 +19,7 @@ export const AVATAR_COLORS = [
17
19
  */
18
20
  function colorFor(name) {
19
21
  let hash = 0;
20
- for (const letter of name.trim().toLocaleLowerCase()) {
22
+ for (const letter of name.trim().toLowerCase()) {
21
23
  hash = (hash * 31 + letter.codePointAt(0)) % 2147483647;
22
24
  }
23
25
  return AVATAR_COLORS[hash % AVATAR_COLORS.length];
@@ -29,7 +31,7 @@ function colorFor(name) {
29
31
  */
30
32
  function initialOf(name) {
31
33
  const [first = ''] = Array.from(name.trim());
32
- return first.toLocaleUpperCase();
34
+ return first.toUpperCase();
33
35
  }
34
36
  /**
35
37
  * The share of the circle a letter takes, 12px in the 32px stylesheet circle.
@@ -47,11 +49,34 @@ function sizedBy(size) {
47
49
  return { inlineSize: size, blockSize: size, fontSize: size * LETTER_SHARE };
48
50
  }
49
51
  /**
50
- * Renders a round avatar with the first letter of a name, in the letter colour of the circle colour the name picks.
52
+ * Renders a round avatar with a picture, or the first letter of a name in the colours the name picks.
53
+ * @param props - The name the avatar stands for, its size and the address of its picture.
54
+ * @returns The avatar element.
55
+ */
56
+ export function InitialsAvatar({ name, size, src }) {
57
+ if (!src) {
58
+ return _jsx(LetterAvatar, { name: name, size: size });
59
+ }
60
+ return _jsx(PictureAvatar, { name: name, size: size, src: src }, src);
61
+ }
62
+ /**
63
+ * Renders the picture at one address, or the letter once that picture fails to load.
64
+ * @param props - The name the avatar stands for, its size and the address of its picture.
65
+ * @returns The avatar element.
66
+ */
67
+ function PictureAvatar({ name, size, src }) {
68
+ const [failed, setFailed] = useState(false);
69
+ if (failed) {
70
+ return _jsx(LetterAvatar, { name: name, size: size });
71
+ }
72
+ return (_jsx("span", { className: "godmin-avatar", "aria-hidden": "true", style: sizedBy(size), children: _jsx("img", { className: "godmin-avatar__image", src: src, alt: "", onError: () => setFailed(true) }) }));
73
+ }
74
+ /**
75
+ * Renders the first letter of a name in the circle and letter colours the name picks.
51
76
  * @param props - The name the avatar stands for and its size.
52
77
  * @returns The avatar element.
53
78
  */
54
- export function InitialsAvatar({ name, size }) {
79
+ function LetterAvatar({ name, size }) {
55
80
  const { background, letter } = colorFor(name);
56
81
  return (_jsx("span", { className: "godmin-avatar", "aria-hidden": "true", style: { backgroundColor: background, color: letter, ...sizedBy(size) }, children: initialOf(name) }));
57
82
  }
package/dist/base.css CHANGED
@@ -618,6 +618,14 @@ body {
618
618
  user-select: none;
619
619
  }
620
620
 
621
+ .godmin-avatar__image {
622
+ display: block;
623
+ inline-size: 100%;
624
+ block-size: 100%;
625
+ border-radius: 50%;
626
+ object-fit: cover;
627
+ }
628
+
621
629
  .godmin-table__actions * {
622
630
  white-space: nowrap;
623
631
  }
package/dist/index.d.ts CHANGED
@@ -15,6 +15,7 @@ export { keyFromLabel } from './keys.js';
15
15
  export type { KeyOptions, KeyStyle } from './keys.js';
16
16
  export { LIST_CHROME_DOMAIN, listChromeCatalogFor } from './list-chrome.js';
17
17
  export type { ListChromeCatalog } from './list-chrome.js';
18
+ export { listDate, startListDates } from './list-dates.js';
18
19
  export { ListEmpty } from './list-empty.js';
19
20
  export type { ListEmptyProps } from './list-empty.js';
20
21
  export { LoadingRows, LoadingScreen } from './loading.js';
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ export { FileButton } from './file-button.js';
8
8
  export { Frame } from './frame.js';
9
9
  export { keyFromLabel } from './keys.js';
10
10
  export { LIST_CHROME_DOMAIN, listChromeCatalogFor } from './list-chrome.js';
11
+ export { listDate, startListDates } from './list-dates.js';
11
12
  export { ListEmpty } from './list-empty.js';
12
13
  export { LoadingRows, LoadingScreen } from './loading.js';
13
14
  export { LogItem, LogList, LogTime } from './log-list.js';
@@ -1,4 +1,4 @@
1
1
  import type { ListChromeCatalog } from '../list-chrome.js';
2
- /** The Spanish list chrome, compiled from the es-ES.po source beside it. */
2
+ /** The Spanish list chrome and list dates, compiled from the es-ES.po source beside it. */
3
3
  declare const catalog: ListChromeCatalog;
4
4
  export default catalog;
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- /** The Spanish list chrome, compiled from the es-ES.po source beside it. */
2
+ /** The Spanish list chrome and list dates, compiled from the es-ES.po source beside it. */
3
3
  const catalog = {
4
4
  '': { lang: 'es-ES', 'plural-forms': 'nplurals=2; plural=(n != 1);' },
5
5
  '%1$d of %2$d Item': ['%1$d de %2$d elemento', '%1$d de %2$d elementos'],
@@ -67,12 +67,17 @@ const catalog = {
67
67
  '<Name>%1$s starts with: </Name><Value>%2$s</Value>': [
68
68
  '<Name>%1$s empieza por: </Name><Value>%2$s</Value>',
69
69
  ],
70
+ AM: ['AM'],
70
71
  Actions: ['Acciones'],
71
72
  Activity: ['Actividad'],
72
73
  'Add filter': ['Añadir filtro'],
73
74
  After: ['Después'],
74
75
  'After (inc)': ['Después (incl.)'],
75
76
  Appearance: ['Apariencia'],
77
+ April: ['abril'],
78
+ 'April abbreviation\u0004Apr': ['Abr'],
79
+ August: ['agosto'],
80
+ 'August abbreviation\u0004Aug': ['Ago'],
76
81
  'Automatically load more content as you scroll, instead of showing pagination links.': [
77
82
  'Carga automáticamente más contenido a medida que navegas, en lugar de mostrar enlaces de paginación.',
78
83
  ],
@@ -88,6 +93,8 @@ const catalog = {
88
93
  'Date calendar': ['Calendario de fechas'],
89
94
  'Date range calendar': ['Calendario de rango de fechas'],
90
95
  'Date time': ['Fecha y hora'],
96
+ December: ['diciembre'],
97
+ 'December abbreviation\u0004Dec': ['Dic'],
91
98
  Density: ['Densidad'],
92
99
  'Density option for DataView layout\u0004Balanced': ['Equilibrado'],
93
100
  'Density option for DataView layout\u0004Comfortable': ['Cómodo'],
@@ -95,8 +102,13 @@ const catalog = {
95
102
  'Deselect all': ['Anular selección de todo'],
96
103
  "Doesn't contain": ['No contiene'],
97
104
  'Enable infinite scroll': ['Activar el desplazamiento infinito'],
105
+ 'F j, Y g:i a': ['j \\d\\e F \\d\\e Y H:i'],
98
106
  False: ['Falso'],
107
+ February: ['febrero'],
108
+ 'February abbreviation\u0004Feb': ['Feb'],
99
109
  'Filter by: %1$s': ['Filtrar por: %1$s'],
110
+ Fri: ['Vie'],
111
+ Friday: ['viernes'],
100
112
  'Greater than': ['Mayor que'],
101
113
  'Greater than or equal': ['Superior a o igual'],
102
114
  Grid: ['Cuadrícula'],
@@ -110,11 +122,24 @@ const catalog = {
110
122
  'Is none of': ['No es ninguno de'],
111
123
  'Is not': ['No es'],
112
124
  'Items per page': ['Elementos por página'],
125
+ January: ['enero'],
126
+ 'January abbreviation\u0004Jan': ['Ene'],
127
+ July: ['julio'],
128
+ 'July abbreviation\u0004Jul': ['Jul'],
129
+ June: ['junio'],
130
+ 'June abbreviation\u0004Jun': ['Jun'],
113
131
  Layout: ['Estructura'],
114
132
  'Less than': ['Menor que'],
115
133
  'Less than or equal': ['Inferior a o igual'],
116
134
  List: ['Lista'],
117
135
  'List of: %1$s': ['Lista de: %1$s'],
136
+ 'M j, Y g:i a': ['j M Y H:i'],
137
+ March: ['marzo'],
138
+ 'March abbreviation\u0004Mar': ['Mar'],
139
+ May: ['mayo'],
140
+ 'May abbreviation\u0004May': ['May'],
141
+ Mon: ['Lun'],
142
+ Monday: ['lunes'],
118
143
  'Move left': ['Mover a la izquierda'],
119
144
  'Move right': ['Mover a la derecha'],
120
145
  'Navigate to item': ['Navegar hasta el elemento'],
@@ -125,11 +150,16 @@ const catalog = {
125
150
  'No results': ['No hay resultados'],
126
151
  'No results found': ['No se encontraron resultados'],
127
152
  'Not on': ['No el'],
153
+ November: ['noviembre'],
154
+ 'November abbreviation\u0004Nov': ['Nov'],
155
+ October: ['octubre'],
156
+ 'October abbreviation\u0004Oct': ['Oct'],
128
157
  On: ['El'],
129
158
  Optional: ['Opcional'],
130
159
  Order: ['Orden'],
131
160
  'Original aspect ratio': ['Proporción original'],
132
161
  Over: ['Hace más de'],
162
+ PM: ['PM'],
133
163
  'Page %1$d of %2$d': ['Página %1$d de %2$d'],
134
164
  'Preview size': ['Tamaño de la vista previa'],
135
165
  'Previous month': ['Mes anterior'],
@@ -141,21 +171,36 @@ const catalog = {
141
171
  'Reset search': ['Restablecer la búsqueda'],
142
172
  'Reset view': ['Restablecer vista'],
143
173
  'Row %d': ['Fila %d'],
174
+ Sat: ['Sáb'],
175
+ Saturday: ['sábado'],
144
176
  Search: ['Buscar'],
145
177
  'Search items': ['Buscar elementos'],
146
178
  'Select all': ['Seleccionar todo'],
179
+ September: ['septiembre'],
180
+ 'September abbreviation\u0004Sep': ['Sep'],
147
181
  'Sort ascending': ['Orden ascendente'],
148
182
  'Sort by': ['Ordenar por'],
149
183
  'Sort descending': ['Orden descendente'],
150
184
  'Starts with': ['Empieza con'],
185
+ Sun: ['Dom'],
186
+ Sunday: ['domingo'],
151
187
  Table: ['Tabla'],
188
+ Thu: ['Jue'],
189
+ Thursday: ['jueves'],
152
190
  'Timezone: %s': ['Zona horaria: %s'],
153
191
  'Today, %s': ['Hoy, %s'],
154
192
  'Today, %s, selected': ['Hoy, %s, seleccionado'],
155
193
  True: ['Verdadero'],
194
+ Tue: ['Mar'],
195
+ Tuesday: ['martes'],
156
196
  'Unknown status for %1$s': ['Estado desconocido para %1$s'],
157
197
  'View is used as a noun\u0004View options': ['Ver opciones'],
198
+ Wed: ['Mié'],
199
+ Wednesday: ['miércoles'],
200
+ am: ['am'],
158
201
  'paging\u0004<div>Page</div>%1$s<div>of %2$d</div>': ['<div>Página</div>%1$s<div>de %2$d</div>'],
202
+ pm: ['pm'],
203
+ 'start of week\u00041': ['1'],
159
204
  'verb\u0004Filter': ['Filtrar'],
160
205
  };
161
206
  export default catalog;
@@ -0,0 +1,4 @@
1
+ import type { ListChromeCatalog } from '../list-chrome.js';
2
+ /** The French list dates, compiled from the fr-FR.po source beside it. */
3
+ declare const catalog: ListChromeCatalog;
4
+ export default catalog;
@@ -0,0 +1,51 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /** The French list dates, compiled from the fr-FR.po source beside it. */
3
+ const catalog = {
4
+ '': { lang: 'fr-FR', 'plural-forms': 'nplurals=2; plural=(n > 1);' },
5
+ AM: ['AM'],
6
+ April: ['avril'],
7
+ 'April abbreviation\u0004Apr': ['Avr'],
8
+ August: ['août'],
9
+ 'August abbreviation\u0004Aug': ['Août'],
10
+ December: ['décembre'],
11
+ 'December abbreviation\u0004Dec': ['Déc'],
12
+ 'F j, Y g:i a': ['d F Y G\\hi'],
13
+ February: ['février'],
14
+ 'February abbreviation\u0004Feb': ['Fév'],
15
+ Fri: ['Ven'],
16
+ Friday: ['vendredi'],
17
+ January: ['janvier'],
18
+ 'January abbreviation\u0004Jan': ['Jan'],
19
+ July: ['juillet'],
20
+ 'July abbreviation\u0004Jul': ['Juil'],
21
+ June: ['juin'],
22
+ 'June abbreviation\u0004Jun': ['Juin'],
23
+ 'M j, Y g:i a': ['d F Y G\\hi'],
24
+ March: ['mars'],
25
+ 'March abbreviation\u0004Mar': ['Mar'],
26
+ May: ['mai'],
27
+ 'May abbreviation\u0004May': ['Mai'],
28
+ Mon: ['Lun'],
29
+ Monday: ['lundi'],
30
+ November: ['novembre'],
31
+ 'November abbreviation\u0004Nov': ['Nov'],
32
+ October: ['octobre'],
33
+ 'October abbreviation\u0004Oct': ['Oct'],
34
+ PM: ['PM'],
35
+ Sat: ['Sam'],
36
+ Saturday: ['samedi'],
37
+ September: ['septembre'],
38
+ 'September abbreviation\u0004Sep': ['Sep'],
39
+ Sun: ['Dim'],
40
+ Sunday: ['dimanche'],
41
+ Thu: ['Jeu'],
42
+ Thursday: ['jeudi'],
43
+ Tue: ['Mar'],
44
+ Tuesday: ['mardi'],
45
+ Wed: ['Mer'],
46
+ Wednesday: ['mercredi'],
47
+ am: ['am'],
48
+ pm: ['pm'],
49
+ 'start of week\u00041': ['1'],
50
+ };
51
+ export default catalog;
@@ -1,6 +1,6 @@
1
1
  /** A compiled catalogue as the i18n runtime reads it, the metadata entry first. */
2
2
  export type ListChromeCatalog = Record<string, string[] | Record<string, string>>;
3
- /** The text domain the WordPress list chrome reads its strings from. */
3
+ /** The text domain the WordPress list chrome and list dates read their strings from. */
4
4
  export declare const LIST_CHROME_DOMAIN = "default";
5
5
  /**
6
6
  * Returns the list chrome catalogue this package ships for a language.
@@ -1,9 +1,10 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- /** The text domain the WordPress list chrome reads its strings from. */
2
+ /** The text domain the WordPress list chrome and list dates read their strings from. */
3
3
  export const LIST_CHROME_DOMAIN = 'default';
4
- /** The list chrome catalogue this package ships for each language it has one for. */
4
+ /** The list chrome and list dates catalogue this package ships for each language it has one for. */
5
5
  const SHIPPED = {
6
6
  'es-ES': () => import('./list-chrome/es-ES.js'),
7
+ 'fr-FR': () => import('./list-chrome/fr-FR.js'),
7
8
  };
8
9
  /**
9
10
  * Returns the list chrome catalogue this package ships for a language.
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Hands the date package the WordPress words and formats of the loaded catalogue, the first weekday and a time zone.
3
+ * @param locale - The language the reader settled on, such as es-ES.
4
+ * @param timeZone - The IANA time zone list dates show, the browser's own when left out.
5
+ */
6
+ export declare function startListDates(locale: string, timeZone?: string): void;
7
+ /**
8
+ * Returns a moment in the abbreviated date and time WordPress lists show.
9
+ * @param at - The moment, as a Date or as the text a server stored.
10
+ * @returns The date and time, such as Oct 13, 2026 5:04 pm.
11
+ */
12
+ export declare function listDate(at: Date | string): string;
@@ -0,0 +1,142 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import { dateI18n, getDate, getSettings, setSettings } from '@wordpress/date';
3
+ import { __, _x } from '@wordpress/i18n';
4
+ /** The days a week may start on, Sunday first, as the date settings number them. */
5
+ const WEEK_DAYS = [0, 1, 2, 3, 4, 5, 6];
6
+ /** The word sets each language was booted with, each kept under a private name of its own. */
7
+ const wordSets = new Map();
8
+ /**
9
+ * Returns the month names of the loaded catalogue, January first.
10
+ * @returns The twelve month names.
11
+ */
12
+ function monthNames() {
13
+ return [
14
+ __('January'),
15
+ __('February'),
16
+ __('March'),
17
+ __('April'),
18
+ __('May'),
19
+ __('June'),
20
+ __('July'),
21
+ __('August'),
22
+ __('September'),
23
+ __('October'),
24
+ __('November'),
25
+ __('December'),
26
+ ];
27
+ }
28
+ /**
29
+ * Returns the month abbreviations of the loaded catalogue, January first.
30
+ * @returns The twelve month abbreviations.
31
+ */
32
+ function monthAbbreviations() {
33
+ return [
34
+ _x('Jan', 'January abbreviation'),
35
+ _x('Feb', 'February abbreviation'),
36
+ _x('Mar', 'March abbreviation'),
37
+ _x('Apr', 'April abbreviation'),
38
+ _x('May', 'May abbreviation'),
39
+ _x('Jun', 'June abbreviation'),
40
+ _x('Jul', 'July abbreviation'),
41
+ _x('Aug', 'August abbreviation'),
42
+ _x('Sep', 'September abbreviation'),
43
+ _x('Oct', 'October abbreviation'),
44
+ _x('Nov', 'November abbreviation'),
45
+ _x('Dec', 'December abbreviation'),
46
+ ];
47
+ }
48
+ /**
49
+ * Returns the weekday names of the loaded catalogue, Sunday first.
50
+ * @returns The seven weekday names.
51
+ */
52
+ function weekdayNames() {
53
+ return [__('Sunday'), __('Monday'), __('Tuesday'), __('Wednesday'), __('Thursday'), __('Friday'), __('Saturday')];
54
+ }
55
+ /**
56
+ * Returns the weekday abbreviations of the loaded catalogue, Sunday first.
57
+ * @returns The seven weekday abbreviations.
58
+ */
59
+ function weekdayAbbreviations() {
60
+ return [__('Sun'), __('Mon'), __('Tue'), __('Wed'), __('Thu'), __('Fri'), __('Sat')];
61
+ }
62
+ /**
63
+ * Returns the am and pm words of the loaded catalogue.
64
+ * @returns The lower and upper case words.
65
+ */
66
+ function meridiem() {
67
+ return { am: __('am'), pm: __('pm'), AM: __('AM'), PM: __('PM') };
68
+ }
69
+ /**
70
+ * Returns the first weekday the loaded catalogue names, Monday when it names none.
71
+ * @returns The first day of the week, Sunday being 0.
72
+ */
73
+ function startOfWeek() {
74
+ const named = _x('1', 'start of week');
75
+ return WEEK_DAYS.find((day) => String(day) === named) ?? 1;
76
+ }
77
+ /**
78
+ * Returns an hour offset written as WordPress writes it, such as 5:30.
79
+ * @param offset - The offset in hours.
80
+ * @returns The offset with its fraction written as minutes.
81
+ */
82
+ function offsetText(offset) {
83
+ return String(offset).replace('.25', ':15').replace('.5', ':30').replace('.75', ':45');
84
+ }
85
+ /**
86
+ * Returns the time zone settings of a zone at this moment, as WordPress hands them to the date package.
87
+ * @param zone - The IANA time zone.
88
+ * @returns The offset, its written form, the zone and its abbreviation.
89
+ */
90
+ function zoneSettings(zone) {
91
+ const now = new Date();
92
+ const offset = Number(dateI18n('Z', now, zone)) / 3600;
93
+ return { offset, offsetFormatted: offsetText(offset), string: zone, abbr: dateI18n('T', now, zone) };
94
+ }
95
+ /**
96
+ * Returns the private name the date package keeps a word set under, so no language registered elsewhere holds it.
97
+ * @param locale - The language the reader settled on.
98
+ * @param words - The words of this boot, as JSON.
99
+ * @returns The language with a private use suffix naming this word set.
100
+ */
101
+ function localeName(locale, words) {
102
+ const sets = wordSets.get(locale) ?? [];
103
+ if (!sets.includes(words)) {
104
+ sets.push(words);
105
+ }
106
+ wordSets.set(locale, sets);
107
+ return `${locale}-x-g${sets.indexOf(words)}`;
108
+ }
109
+ /**
110
+ * Hands the date package the WordPress words and formats of the loaded catalogue, the first weekday and a time zone.
111
+ * @param locale - The language the reader settled on, such as es-ES.
112
+ * @param timeZone - The IANA time zone list dates show, the browser's own when left out.
113
+ */
114
+ export function startListDates(locale, timeZone) {
115
+ const held = getSettings();
116
+ const words = {
117
+ months: monthNames(),
118
+ monthsShort: monthAbbreviations(),
119
+ weekdays: weekdayNames(),
120
+ weekdaysShort: weekdayAbbreviations(),
121
+ meridiem: meridiem(),
122
+ };
123
+ setSettings({
124
+ ...held,
125
+ formats: { ...held.formats, datetime: __('F j, Y g:i a'), datetimeAbbreviated: __('M j, Y g:i a') },
126
+ l10n: {
127
+ ...held.l10n,
128
+ ...words,
129
+ locale: localeName(locale, JSON.stringify(words)),
130
+ startOfWeek: startOfWeek(),
131
+ },
132
+ timezone: zoneSettings(timeZone ?? Intl.DateTimeFormat().resolvedOptions().timeZone),
133
+ });
134
+ }
135
+ /**
136
+ * Returns a moment in the abbreviated date and time WordPress lists show.
137
+ * @param at - The moment, as a Date or as the text a server stored.
138
+ * @returns The date and time, such as Oct 13, 2026 5:04 pm.
139
+ */
140
+ export function listDate(at) {
141
+ return dateI18n(getSettings().formats.datetimeAbbreviated, typeof at === 'string' ? getDate(at) : at);
142
+ }
package/dist/vite.js CHANGED
@@ -6,6 +6,7 @@ export const godminDedupe = [
6
6
  'react',
7
7
  'react-dom',
8
8
  '@wordpress/a11y',
9
+ '@wordpress/date',
9
10
  '@wordpress/element',
10
11
  '@wordpress/i18n',
11
12
  '@wordpress/theme',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gopherium/godmin",
3
- "version": "0.17.0",
3
+ "version": "0.19.0",
4
4
  "description": "The admin kit for Gopherium projects: host layer for React admin applications on the WordPress Design System.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -59,6 +59,8 @@
59
59
  "@tanstack/react-router": "^1.170.0",
60
60
  "@testing-library/react": "^16.3.2",
61
61
  "@wordpress/a11y": ">=4.57.0 <5.0.0",
62
+ "@wordpress/date": ">=5.57.0 <6.0.0",
63
+ "@wordpress/i18n": ">=6.30.0 <7.0.0",
62
64
  "@wordpress/icons": ">=18.0.0 <19.0.0",
63
65
  "@wordpress/style-runtime": ">=0.13.0 <0.14.0",
64
66
  "@wordpress/theme": ">=2.3.0 <3.0.0",
@@ -91,7 +93,9 @@
91
93
  "@vitest/coverage-v8": "^5.0.3",
92
94
  "@wordpress/a11y": "4.57.0",
93
95
  "@wordpress/dataviews": "20.0.0",
96
+ "@wordpress/date": "5.57.0",
94
97
  "@wordpress/element": "9.0.0",
98
+ "@wordpress/i18n": "6.30.0",
95
99
  "@wordpress/icons": "18.0.0",
96
100
  "@wordpress/style-runtime": "0.13.0",
97
101
  "@wordpress/theme": "2.3.0",