@microbit/ui 0.1.0-alpha.11 → 0.1.0-alpha.13
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/package.json +9 -2
- package/src/ButtonGroup.tsx +6 -3
- package/src/Toast.tsx +11 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microbit/ui",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.13",
|
|
4
4
|
"description": "micro:bit design-system primitives: react-aria-components + Panda CSS with a design language ported from Chakra UI v2. Ships as source; see README for the consumption setup.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
"scripts": {
|
|
26
26
|
"panda": "panda codegen",
|
|
27
27
|
"typecheck": "npm run panda && tsc --noEmit",
|
|
28
|
+
"pretest": "npm run panda",
|
|
29
|
+
"test": "vitest run",
|
|
28
30
|
"prestorybook": "npm run panda",
|
|
29
31
|
"storybook": "storybook dev -p 6006 --no-open",
|
|
30
32
|
"prebuild-storybook": "npm run panda",
|
|
@@ -40,9 +42,13 @@
|
|
|
40
42
|
"devDependencies": {
|
|
41
43
|
"@pandacss/dev": "^1.11.4",
|
|
42
44
|
"@storybook/react-vite": "^10.5.2",
|
|
45
|
+
"@testing-library/react": "^16.3.2",
|
|
46
|
+
"@testing-library/user-event": "^14.6.1",
|
|
47
|
+
"@types/node": "^26.1.1",
|
|
43
48
|
"@types/react": "^18.3.3",
|
|
44
49
|
"@types/react-dom": "^18.3.0",
|
|
45
50
|
"@vitejs/plugin-react": "^4.5.2",
|
|
51
|
+
"jsdom": "^29.1.1",
|
|
46
52
|
"react": "^18.3.1",
|
|
47
53
|
"react-aria-components": "^1.19.0",
|
|
48
54
|
"react-dom": "^18.3.1",
|
|
@@ -50,7 +56,8 @@
|
|
|
50
56
|
"react-intl": "^6.6.8",
|
|
51
57
|
"storybook": "^10.5.2",
|
|
52
58
|
"typescript": "^5.4.2",
|
|
53
|
-
"vite": "^6.3.5"
|
|
59
|
+
"vite": "^6.3.5",
|
|
60
|
+
"vitest": "^4.1.10"
|
|
54
61
|
},
|
|
55
62
|
"publishConfig": {
|
|
56
63
|
"tag": "alpha"
|
package/src/ButtonGroup.tsx
CHANGED
|
@@ -32,9 +32,12 @@ export const ButtonGroup = forwardRef<HTMLDivElement, ButtonGroupProps>(
|
|
|
32
32
|
display: "inline-flex",
|
|
33
33
|
alignItems: "center",
|
|
34
34
|
// Buttons are position: relative, so without this an attached
|
|
35
|
-
// sibling paints over the focused button's focus-ring shadow
|
|
36
|
-
//
|
|
37
|
-
|
|
35
|
+
// sibling paints over the focused button's focus-ring shadow.
|
|
36
|
+
// Chakra raised on :focus, but with the attached -1px overlap a
|
|
37
|
+
// raised button also paints over a seam its neighbour draws
|
|
38
|
+
// (e.g. a solid split button's white borderLeft), so raise only
|
|
39
|
+
// when the ring is actually shown.
|
|
40
|
+
"& > *": { _focusVisible: { zIndex: 1 } },
|
|
38
41
|
}),
|
|
39
42
|
isAttached
|
|
40
43
|
? css({
|
package/src/Toast.tsx
CHANGED
|
@@ -102,11 +102,13 @@ export const ToastProvider = () => {
|
|
|
102
102
|
};
|
|
103
103
|
|
|
104
104
|
export interface ToastOptions extends ToastContent {
|
|
105
|
+
/** Auto-dismiss after this many ms. Default 5000. Ignored when `persistent`. */
|
|
106
|
+
duration?: number;
|
|
105
107
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
+
* Never auto-dismiss. The close button is forced on so the toast is not
|
|
109
|
+
* permanent and unremovable.
|
|
108
110
|
*/
|
|
109
|
-
|
|
111
|
+
persistent?: boolean;
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
export interface ToastFn {
|
|
@@ -123,8 +125,9 @@ export interface ToastFn {
|
|
|
123
125
|
}
|
|
124
126
|
|
|
125
127
|
/**
|
|
126
|
-
* useToast — imperative toast trigger
|
|
127
|
-
*
|
|
128
|
+
* useToast — imperative toast trigger in the shape of Chakra's `useToast()`
|
|
129
|
+
* call sites: `toast({ title, description, status, duration })`. Unlike
|
|
130
|
+
* Chakra there is no `duration: null`; use `persistent: true` instead.
|
|
128
131
|
*/
|
|
129
132
|
export const useToast = (): ToastFn =>
|
|
130
133
|
useMemo(() => {
|
|
@@ -137,6 +140,7 @@ export const useToast = (): ToastFn =>
|
|
|
137
140
|
status,
|
|
138
141
|
isClosable,
|
|
139
142
|
duration,
|
|
143
|
+
persistent,
|
|
140
144
|
}: ToastOptions) => {
|
|
141
145
|
if (id && isActive(id)) {
|
|
142
146
|
return;
|
|
@@ -147,11 +151,9 @@ export const useToast = (): ToastFn =>
|
|
|
147
151
|
title,
|
|
148
152
|
description,
|
|
149
153
|
status,
|
|
150
|
-
|
|
151
|
-
// permanent and unremovable; force the close button on.
|
|
152
|
-
isClosable: isClosable || duration == null,
|
|
154
|
+
isClosable: isClosable || persistent,
|
|
153
155
|
},
|
|
154
|
-
{ timeout: duration ??
|
|
156
|
+
{ timeout: persistent ? undefined : duration ?? 5000 },
|
|
155
157
|
);
|
|
156
158
|
};
|
|
157
159
|
const update = (id: string, options: ToastOptions) => {
|