@kujoforall/paper-ui 0.2.1 → 0.2.2
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @kujoforall/paper-ui
|
|
2
2
|
|
|
3
|
+
## 0.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f8b1818: `Button asChild` passes its child straight to Radix's `Slot`. It called `Children.only` first, which throws on the lazy reference a Next server component passes for a client component such as `Link`, so the server render failed and Next fell back to rendering in the browser.
|
|
8
|
+
|
|
3
9
|
## 0.2.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/ui/button.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/ui/button.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAY,KAAK,cAAc,EAAkB,MAAM,OAAO,CAAC;AAatE,QAAA,MAAM,cAAc;;;8EAkDnB,CAAC;AASF,MAAM,WAAW,WAAY,SAAQ,cAAc,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC,OAAO,cAAc,CAAC;IAC9F,kFAAkF;IAClF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iFAAiF;IACjF,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AA2BD,wBAAgB,MAAM,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,OAAe,EAAE,OAAe,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,EAAE,WAAW,+BAsCpI;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Slot } from "@radix-ui/react-slot";
|
|
4
4
|
import { cva } from "class-variance-authority";
|
|
5
|
-
import { Children
|
|
5
|
+
import { Children } from "react";
|
|
6
6
|
import { cn } from "../../lib/utils.js";
|
|
7
7
|
import { Spinner } from "./spinner.js";
|
|
8
8
|
/* Buttons are small (28–40px), lightly weighted and 4px-rounded. The loudest thing a
|
|
@@ -97,9 +97,11 @@ export function Button({ className, variant, size, asChild = false, loading = fa
|
|
|
97
97
|
console.warn("paper-ui: an icon-only Button needs an aria-label (or aria-labelledby, or title) so a screen reader can name it.");
|
|
98
98
|
}
|
|
99
99
|
const classes = cn(buttonVariants({ variant, size }), loading && "text-transparent! [&>svg]:invisible", className);
|
|
100
|
+
// The child goes to Slot as it is. A Next server component that passes a client
|
|
101
|
+
// component (a Link) hands it over as a lazy reference, not an element, and Slot
|
|
102
|
+
// unwraps that; a Children.only here threw on it and failed the server render.
|
|
100
103
|
if (asChild) {
|
|
101
|
-
|
|
102
|
-
return (_jsx(Slot, { className: classes, "aria-busy": loading || undefined, onClick: onClick, ...props, children: isValidElement(child) ? child : children }));
|
|
104
|
+
return (_jsx(Slot, { className: classes, "aria-busy": loading || undefined, onClick: onClick, ...props, children: children }));
|
|
103
105
|
}
|
|
104
106
|
return (_jsxs("button", { type: type ?? "button", className: classes, "aria-busy": loading || undefined, "data-loading": loading || undefined,
|
|
105
107
|
// Not `disabled` while loading: that would drop focus from the button the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../../src/components/ui/button.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,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
import { Slot } from "@radix-ui/react-slot";
|
|
4
4
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
5
|
-
import { Children,
|
|
5
|
+
import { Children, type ComponentProps, type ReactNode } from "react";
|
|
6
6
|
import { cn } from "../../lib/utils.ts";
|
|
7
7
|
import { Spinner } from "./spinner.tsx";
|
|
8
8
|
|
|
@@ -114,11 +114,13 @@ export function Button({ className, variant, size, asChild = false, loading = fa
|
|
|
114
114
|
|
|
115
115
|
const classes = cn(buttonVariants({ variant, size }), loading && "text-transparent! [&>svg]:invisible", className);
|
|
116
116
|
|
|
117
|
+
// The child goes to Slot as it is. A Next server component that passes a client
|
|
118
|
+
// component (a Link) hands it over as a lazy reference, not an element, and Slot
|
|
119
|
+
// unwraps that; a Children.only here threw on it and failed the server render.
|
|
117
120
|
if (asChild) {
|
|
118
|
-
const child = Children.only(children);
|
|
119
121
|
return (
|
|
120
122
|
<Slot className={classes} aria-busy={loading || undefined} onClick={onClick} {...props}>
|
|
121
|
-
{
|
|
123
|
+
{children}
|
|
122
124
|
</Slot>
|
|
123
125
|
);
|
|
124
126
|
}
|