@gopherium/godmin 0.5.0 → 0.6.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/dist/base.css CHANGED
@@ -174,6 +174,14 @@ body {
174
174
  }
175
175
  }
176
176
 
177
+ @media (prefers-reduced-motion: reduce) {
178
+ .godmin-loading-screen,
179
+ .godmin-loading-rows,
180
+ .godmin-arrival {
181
+ animation-duration: 1ms;
182
+ }
183
+ }
184
+
177
185
  .godmin-loading-screen {
178
186
  padding: var(--wpds-dimension-padding-xl);
179
187
  }
package/dist/toaster.d.ts CHANGED
@@ -14,10 +14,11 @@ export declare function useToaster(): ToasterHandle;
14
14
  export interface ToasterProps {
15
15
  children: ReactNode;
16
16
  dismissAfter?: number;
17
+ dismissLabel?: string;
17
18
  }
18
19
  /**
19
20
  * Renders the region holding raised messages around the given tree.
20
- * @param props - The tree the region wraps and how long a toast stays.
21
+ * @param props - The tree the region wraps, how long a toast stays, and the dismiss control name.
21
22
  * @returns The wrapped tree with its region.
22
23
  */
23
- export declare function Toaster({ children, dismissAfter }: ToasterProps): import("react").JSX.Element;
24
+ export declare function Toaster({ children, dismissAfter, dismissLabel, }: ToasterProps): import("react").JSX.Element;
package/dist/toaster.js CHANGED
@@ -7,6 +7,10 @@ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, use
7
7
  * How long a toast nobody touches stays on screen.
8
8
  */
9
9
  const DISMISS_AFTER = 10000;
10
+ /**
11
+ * The name of the control clearing a toast.
12
+ */
13
+ const DISMISS_LABEL = 'Dismiss';
10
14
  const ToasterContext = createContext(null);
11
15
  /**
12
16
  * Returns the handle raising messages in the toast region.
@@ -21,21 +25,21 @@ export function useToaster() {
21
25
  }
22
26
  /**
23
27
  * Renders one raised message with its optional action.
24
- * @param props - The toast and the handler clearing it.
28
+ * @param props - The toast, the handler clearing it, and the dismiss control name.
25
29
  * @returns The toast element.
26
30
  */
27
- function Toast({ toast, onClear }) {
31
+ function Toast({ toast, onClear, dismissLabel, }) {
28
32
  return (_jsxs(Notice.Root, { intent: "neutral", spokenMessage: toast.message, children: [_jsx(Notice.Description, { children: toast.message }), _jsxs(Notice.Actions, { children: [toast.action !== undefined && (_jsx(Notice.ActionButton, { onClick: () => {
29
33
  toast.action?.onAct();
30
34
  onClear(toast.id);
31
- }, children: toast.action.label })), _jsx(Notice.ActionButton, { onClick: () => onClear(toast.id), children: "Dismiss" })] })] }));
35
+ }, children: toast.action.label })), _jsx(Notice.ActionButton, { onClick: () => onClear(toast.id), children: dismissLabel })] })] }));
32
36
  }
33
37
  /**
34
38
  * Renders the region holding raised messages around the given tree.
35
- * @param props - The tree the region wraps and how long a toast stays.
39
+ * @param props - The tree the region wraps, how long a toast stays, and the dismiss control name.
36
40
  * @returns The wrapped tree with its region.
37
41
  */
38
- export function Toaster({ children, dismissAfter = DISMISS_AFTER }) {
42
+ export function Toaster({ children, dismissAfter = DISMISS_AFTER, dismissLabel = DISMISS_LABEL, }) {
39
43
  const [toasts, setToasts] = useState([]);
40
44
  const nextId = useRef(0);
41
45
  const timers = useRef(new Set());
@@ -58,5 +62,5 @@ export function Toaster({ children, dismissAfter = DISMISS_AFTER }) {
58
62
  timers.current.add(setTimeout(() => clear(id), dismissAfter));
59
63
  }, [clear, dismissAfter]);
60
64
  const handle = useMemo(() => ({ show }), [show]);
61
- return (_jsxs(ToasterContext.Provider, { value: handle, children: [children, _jsx(Stack, { direction: "column", gap: "xs", className: "godmin-toasts", children: toasts.map((toast) => (_jsx(Toast, { toast: toast, onClear: clear }, toast.id))) })] }));
65
+ return (_jsxs(ToasterContext.Provider, { value: handle, children: [children, _jsx(Stack, { direction: "column", gap: "xs", className: "godmin-toasts", children: toasts.map((toast) => (_jsx(Toast, { toast: toast, onClear: clear, dismissLabel: dismissLabel }, toast.id))) })] }));
62
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gopherium/godmin",
3
- "version": "0.5.0",
3
+ "version": "0.6.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",
@@ -47,7 +47,7 @@
47
47
  "./package.json": "./package.json"
48
48
  },
49
49
  "scripts": {
50
- "build": "tsc -p tsconfig.build.json && cp src/base.css dist/base.css",
50
+ "build": "rm -rf dist && tsc -p tsconfig.build.json && cp src/base.css dist/base.css",
51
51
  "cover": "vitest run --coverage",
52
52
  "lint": "oxlint",
53
53
  "lint:css": "stylelint 'src/**/*.css'",