@pollinations/ui 0.1.0-alpha.14 → 0.1.0-alpha.16

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 (71) hide show
  1. package/README.md +5 -3
  2. package/dist/app-user-menu/sdk.js +50 -752
  3. package/dist/app-user-menu/sdk.js.map +1 -1
  4. package/dist/auth/index.js +91 -1131
  5. package/dist/auth/index.js.map +1 -1
  6. package/dist/auth/sdk.js +9 -211
  7. package/dist/auth/sdk.js.map +1 -1
  8. package/dist/chunk-3VM5R3OI.js +50 -0
  9. package/dist/chunk-3VM5R3OI.js.map +1 -0
  10. package/dist/chunk-7GDUPN6U.js +115 -0
  11. package/dist/chunk-7GDUPN6U.js.map +1 -0
  12. package/dist/{app-user-menu/sdk.cjs → chunk-7WXDUAJU.js} +96 -751
  13. package/dist/chunk-7WXDUAJU.js.map +1 -0
  14. package/dist/chunk-7XDOOFTL.js +105 -0
  15. package/dist/chunk-7XDOOFTL.js.map +1 -0
  16. package/dist/chunk-DD7MHUFD.js +93 -0
  17. package/dist/chunk-DD7MHUFD.js.map +1 -0
  18. package/dist/chunk-FLQFOTMR.js +107 -0
  19. package/dist/chunk-FLQFOTMR.js.map +1 -0
  20. package/dist/chunk-IS4CNKV3.js +252 -0
  21. package/dist/chunk-IS4CNKV3.js.map +1 -0
  22. package/dist/chunk-IX6BJNHM.js +58 -0
  23. package/dist/chunk-IX6BJNHM.js.map +1 -0
  24. package/dist/chunk-K2H3JFQK.js +576 -0
  25. package/dist/chunk-K2H3JFQK.js.map +1 -0
  26. package/dist/chunk-LKUZU37X.js +15 -0
  27. package/dist/chunk-LKUZU37X.js.map +1 -0
  28. package/dist/chunk-QAR2WP3L.js +364 -0
  29. package/dist/chunk-QAR2WP3L.js.map +1 -0
  30. package/dist/chunk-QFR7XRUE.js +534 -0
  31. package/dist/chunk-QFR7XRUE.js.map +1 -0
  32. package/dist/chunk-TVPFAM3B.js +88 -0
  33. package/dist/chunk-TVPFAM3B.js.map +1 -0
  34. package/dist/chunk-ZLD4VLUG.js +112 -0
  35. package/dist/chunk-ZLD4VLUG.js.map +1 -0
  36. package/dist/gen/index.js +49 -494
  37. package/dist/gen/index.js.map +1 -1
  38. package/dist/index.browser.min.js +1 -1
  39. package/dist/index.browser.min.js.map +1 -1
  40. package/dist/index.js +577 -2630
  41. package/dist/index.js.map +1 -1
  42. package/dist/markdown.js +45 -599
  43. package/dist/markdown.js.map +1 -1
  44. package/dist/styles.css +1 -1
  45. package/dist/wallet/index.js +17 -374
  46. package/dist/wallet/index.js.map +1 -1
  47. package/package.json +10 -16
  48. package/dist/Button-BGqClaBr.d.cts +0 -29
  49. package/dist/Chip-v-ADv6cz.d.cts +0 -18
  50. package/dist/Dialog-D3Nqt8cE.d.cts +0 -66
  51. package/dist/app-user-menu/sdk.cjs.map +0 -1
  52. package/dist/app-user-menu/sdk.d.cts +0 -29
  53. package/dist/auth/index.cjs +0 -1537
  54. package/dist/auth/index.cjs.map +0 -1
  55. package/dist/auth/index.d.cts +0 -114
  56. package/dist/auth/sdk.cjs +0 -250
  57. package/dist/auth/sdk.cjs.map +0 -1
  58. package/dist/auth/sdk.d.cts +0 -40
  59. package/dist/gen/index.cjs +0 -718
  60. package/dist/gen/index.cjs.map +0 -1
  61. package/dist/gen/index.d.cts +0 -91
  62. package/dist/index.cjs +0 -5365
  63. package/dist/index.cjs.map +0 -1
  64. package/dist/index.d.cts +0 -1051
  65. package/dist/markdown.cjs +0 -838
  66. package/dist/markdown.cjs.map +0 -1
  67. package/dist/markdown.d.cts +0 -16
  68. package/dist/types-CCy9JNu9.d.cts +0 -6
  69. package/dist/wallet/index.cjs +0 -433
  70. package/dist/wallet/index.cjs.map +0 -1
  71. package/dist/wallet/index.d.cts +0 -53
package/dist/auth/sdk.cjs DELETED
@@ -1,250 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/modules/auth/sdk.ts
21
- var sdk_exports = {};
22
- __export(sdk_exports, {
23
- LoginButton: () => LoginButton,
24
- UserAvatar: () => UserAvatar,
25
- UserName: () => UserName,
26
- WhenLoggedIn: () => WhenLoggedIn,
27
- WhenLoggedOut: () => WhenLoggedOut
28
- });
29
- module.exports = __toCommonJS(sdk_exports);
30
-
31
- // src/modules/auth/LoginButton.tsx
32
- var import_react = require("@pollinations/sdk/react");
33
-
34
- // src/lib/cn.ts
35
- var import_clsx = require("clsx");
36
- var import_tailwind_merge = require("tailwind-merge");
37
- var twMerge = (0, import_tailwind_merge.extendTailwindMerge)({
38
- prefix: "polli",
39
- extend: { theme: { text: ["micro"] } }
40
- });
41
- function cn(...inputs) {
42
- return twMerge((0, import_clsx.clsx)(...inputs));
43
- }
44
-
45
- // src/primitives/Button.tsx
46
- var import_jsx_runtime = require("react/jsx-runtime");
47
- var pillSizes = {
48
- icon: "polli:h-12 polli:w-12 polli:p-0",
49
- xs: "polli:h-5 polli:px-1.5 polli:py-0 polli:text-[11px] polli:leading-none",
50
- sm: "polli:min-h-7 polli:px-2 polli:pt-0.5 polli:pb-1",
51
- md: "polli:min-h-9 polli:px-4 polli:pt-1.5 polli:pb-2",
52
- lg: "polli:min-h-12 polli:px-6 polli:py-3 polli:text-base"
53
- };
54
- var raisedSizes = {
55
- icon: "polli:h-12 polli:w-12 polli:p-0",
56
- xs: "polli:px-2 polli:py-1 polli:text-xs",
57
- sm: "polli:px-4 polli:py-2 polli:text-sm",
58
- md: "polli:px-7 polli:py-3.5 polli:text-base",
59
- lg: "polli:px-8 polli:py-4 polli:text-lg"
60
- };
61
- var appearanceClasses = {
62
- pill: "polli:rounded-full",
63
- raised: "polli:rounded-xl polli:border-r-[3px] polli:border-b-[3px] polli:border-solid polli:border-theme-text-strong/20 polli:hover:border-theme-text-strong/45"
64
- };
65
- var themeClasses = "polli:bg-theme-bg-active polli:text-theme-text-strong polli:hover:bg-theme-bg-hover polli:hover:text-theme-text-hover polli:transition-colors";
66
- var outlined = "polli:border polli:border-theme-text-soft polli:bg-theme-bg-active/30 polli:text-theme-text-strong polli:transition-colors polli:[.dark_&]:bg-transparent";
67
- var intentClasses = {
68
- brand: `${outlined} polli:hover:bg-theme-bg-active/50 polli:[.dark_&]:hover:bg-theme-text-soft/10`,
69
- commit: `${outlined} polli:hover:border-theme-bg-active polli:hover:bg-theme-bg-active polli:focus-visible:border-theme-bg-active polli:focus-visible:bg-theme-bg-active polli:[.dark_&]:hover:bg-theme-bg-active polli:[.dark_&]:focus-visible:bg-theme-bg-active`,
70
- danger: "polli:border polli:border-intent-danger-text polli:bg-intent-danger-bg-light polli:text-intent-danger-text polli:hover:bg-intent-danger-bg-hover polli:focus-visible:bg-intent-danger-bg-hover polli:transition-colors polli:[.dark_&]:bg-transparent polli:[.dark_&]:hover:bg-intent-danger-bg-hover polli:[.dark_&]:focus-visible:bg-intent-danger-bg-hover",
71
- info: "polli:bg-intent-info-bg-light polli:text-intent-info-text polli:hover:bg-intent-info-bg-hover polli:transition-colors",
72
- // A quiet white pill on the desk, like the colour toggle; hover previews
73
- // the accent as the ambient button does.
74
- surface: "polli:bg-surface-opaque polli:text-theme-text-strong polli:hover:bg-theme-bg-hover polli:hover:text-theme-text-hover polli:transition-colors",
75
- // Secondary actions never take the accent: one step stronger grey on hover.
76
- neutral: "polli:bg-theme-bg-subtle polli:text-theme-text-base polli:hover:bg-theme-text-muted/25 polli:hover:text-theme-text-strong polli:transition-colors"
77
- };
78
- var buttonClasses = ({
79
- intent,
80
- appearance = "pill",
81
- size,
82
- className,
83
- disabled,
84
- busy
85
- }) => {
86
- const colorClasses = intent ? intentClasses[intent] : themeClasses;
87
- const sizeClasses = appearance === "raised" ? raisedSizes : pillSizes;
88
- return cn(
89
- "polli-control polli:inline-flex polli:items-center polli:justify-center polli:self-center polli:font-body polli:text-sm polli:font-medium polli:leading-normal polli:box-border polli:border polli:border-transparent",
90
- // A busy button is working, not unavailable: it keeps its strength.
91
- busy ? "polli:cursor-progress" : disabled ? "polli:opacity-50 polli:cursor-not-allowed" : "polli:hover:filter polli:hover:brightness-105 polli:cursor-pointer",
92
- colorClasses,
93
- appearanceClasses[appearance],
94
- sizeClasses[size || "md"],
95
- className
96
- );
97
- };
98
- function Button({
99
- as,
100
- children,
101
- icon,
102
- intent,
103
- appearance,
104
- size,
105
- className,
106
- disabled,
107
- ...buttonProps
108
- }) {
109
- const Component = as || "button";
110
- const isButton = Component === "button";
111
- const isAnchor = Component === "a";
112
- const buttonType = buttonProps.type;
113
- const onClick = buttonProps.onClick;
114
- const ariaBusy = buttonProps["aria-busy"];
115
- const busy = ariaBusy === true || ariaBusy === "true";
116
- const handleClick = disabled ? (event) => {
117
- event.preventDefault();
118
- event.stopPropagation();
119
- } : onClick;
120
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
121
- Component,
122
- {
123
- ...buttonProps,
124
- "data-intent": intent,
125
- ...isButton ? { type: buttonType ?? "button", disabled } : {},
126
- ...!isButton && disabled ? { "aria-disabled": true, tabIndex: -1 } : {},
127
- ...isAnchor && disabled ? { href: void 0 } : {},
128
- onClick: handleClick,
129
- className: buttonClasses({
130
- intent,
131
- appearance,
132
- size,
133
- className,
134
- disabled,
135
- busy
136
- }),
137
- children: [
138
- icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
139
- "span",
140
- {
141
- "aria-hidden": "true",
142
- className: "polli:mr-2 polli:flex polli:size-4 polli:shrink-0 polli:[&>svg]:size-full",
143
- children: busy ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "polli:block polli:size-full polli:animate-spin polli:rounded-full polli:border-2 polli:border-current polli:border-r-transparent polli:motion-reduce:animate-none" }) : icon
144
- }
145
- ),
146
- children
147
- ]
148
- }
149
- );
150
- }
151
-
152
- // src/modules/auth/LoginButton.tsx
153
- var import_jsx_runtime2 = require("react/jsx-runtime");
154
- function LoginButton({ children, ...buttonProps }) {
155
- const { isLoggedIn } = (0, import_react.useAuthState)();
156
- const { login } = (0, import_react.useAuthActions)();
157
- if (isLoggedIn) return null;
158
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Button, { ...buttonProps, onClick: () => login(), children });
159
- }
160
-
161
- // src/modules/auth/UserAvatar.tsx
162
- var import_react2 = require("@pollinations/sdk/react");
163
- var import_jsx_runtime3 = require("react/jsx-runtime");
164
- var sizeClass = {
165
- sm: "polli:w-6 polli:h-6 polli:text-xs",
166
- md: "polli:w-9 polli:h-9 polli:text-sm",
167
- lg: "polli:w-12 polli:h-12 polli:text-base"
168
- };
169
- function initials(name) {
170
- const parts = name.trim().split(/\s+/).filter(Boolean);
171
- if (parts.length === 0) return null;
172
- if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase() || null;
173
- const first = parts[0][0] ?? "";
174
- const last = parts[parts.length - 1][0] ?? "";
175
- return (first + last).toUpperCase() || null;
176
- }
177
- function UserAvatar({ size = "md", className }) {
178
- const { isLoggedIn } = (0, import_react2.useAuthState)();
179
- const { data: profile } = (0, import_react2.useAccountProfile)({ enabled: isLoggedIn });
180
- if (!isLoggedIn) return null;
181
- const base = cn(
182
- "polli:inline-flex polli:items-center polli:justify-center polli:rounded-full polli:overflow-hidden polli:bg-theme-bg-pale polli:text-theme-text-strong polli:font-semibold polli:select-none",
183
- sizeClass[size],
184
- className
185
- );
186
- if (profile?.image) {
187
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
188
- "img",
189
- {
190
- "data-polli": "user-avatar",
191
- src: profile.image,
192
- alt: profile.name ?? "",
193
- className: base
194
- }
195
- );
196
- }
197
- const label = profile?.name ? initials(profile.name) : null;
198
- if (!label) return null;
199
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
200
- "div",
201
- {
202
- "data-polli": "user-avatar",
203
- role: "img",
204
- "aria-label": profile?.name ?? void 0,
205
- className: base,
206
- children: label
207
- }
208
- );
209
- }
210
-
211
- // src/modules/auth/UserName.tsx
212
- var import_react3 = require("@pollinations/sdk/react");
213
- var import_jsx_runtime4 = require("react/jsx-runtime");
214
- function UserName({ className }) {
215
- const { isLoggedIn } = (0, import_react3.useAuthState)();
216
- const { data: profile } = (0, import_react3.useAccountProfile)({ enabled: isLoggedIn });
217
- if (!isLoggedIn || !profile) return null;
218
- const display = profile.name || profile.githubUsername;
219
- if (!display) return null;
220
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-polli": "user-name", className, children: display });
221
- }
222
-
223
- // src/modules/auth/WhenLoggedIn.tsx
224
- var import_react4 = require("@pollinations/sdk/react");
225
- var import_react5 = require("react");
226
- var import_jsx_runtime5 = require("react/jsx-runtime");
227
- function WhenLoggedIn({ children }) {
228
- const { isLoggedIn } = (0, import_react4.useAuthState)();
229
- if (!isLoggedIn) return null;
230
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react5.Fragment, { children });
231
- }
232
-
233
- // src/modules/auth/WhenLoggedOut.tsx
234
- var import_react6 = require("@pollinations/sdk/react");
235
- var import_react7 = require("react");
236
- var import_jsx_runtime6 = require("react/jsx-runtime");
237
- function WhenLoggedOut({ children }) {
238
- const { isLoggedIn } = (0, import_react6.useAuthState)();
239
- if (isLoggedIn) return null;
240
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react7.Fragment, { children });
241
- }
242
- // Annotate the CommonJS export names for ESM import in node:
243
- 0 && (module.exports = {
244
- LoginButton,
245
- UserAvatar,
246
- UserName,
247
- WhenLoggedIn,
248
- WhenLoggedOut
249
- });
250
- //# sourceMappingURL=sdk.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/modules/auth/sdk.ts","../../src/modules/auth/LoginButton.tsx","../../src/lib/cn.ts","../../src/primitives/Button.tsx","../../src/modules/auth/UserAvatar.tsx","../../src/modules/auth/UserName.tsx","../../src/modules/auth/WhenLoggedIn.tsx","../../src/modules/auth/WhenLoggedOut.tsx"],"sourcesContent":["export { LoginButton, type LoginButtonProps } from \"./LoginButton.tsx\";\nexport { UserAvatar, type UserAvatarProps } from \"./UserAvatar.tsx\";\nexport { UserName, type UserNameProps } from \"./UserName.tsx\";\nexport { WhenLoggedIn, type WhenLoggedInProps } from \"./WhenLoggedIn.tsx\";\nexport { WhenLoggedOut, type WhenLoggedOutProps } from \"./WhenLoggedOut.tsx\";\n","import { useAuthActions, useAuthState } from \"@pollinations/sdk/react\";\nimport type { ReactNode } from \"react\";\nimport { Button, type ButtonProps } from \"../../primitives/Button.tsx\";\n\nexport type LoginButtonProps = Omit<\n ButtonProps<\"button\">,\n \"as\" | \"onClick\" | \"children\"\n> & {\n children: ReactNode;\n};\n\n/** Button that kicks off the auth redirect. `null` when already logged in. */\nexport function LoginButton({ children, ...buttonProps }: LoginButtonProps) {\n const { isLoggedIn } = useAuthState();\n const { login } = useAuthActions();\n if (isLoggedIn) return null;\n return (\n <Button {...buttonProps} onClick={() => login()}>\n {children}\n </Button>\n );\n}\n","import { clsx } from \"clsx\";\nimport { extendTailwindMerge } from \"tailwind-merge\";\n\n// `text-micro` is a font size (theme.css), not a colour; without this,\n// tailwind-merge drops it next to a `text-theme-*` colour class.\nconst twMerge = extendTailwindMerge({\n prefix: \"polli\",\n extend: { theme: { text: [\"micro\"] } },\n});\n\n/** Internal class merge for polli:-prefixed package primitive classes. */\nexport function cn(...inputs: (string | undefined | null | false)[]) {\n return twMerge(clsx(...inputs));\n}\n","import type {\n PropsWithChildren,\n MouseEvent as ReactMouseEvent,\n ReactNode,\n} from \"react\";\nimport { cn } from \"../lib/cn.ts\";\n\n/** Semantic action roles. Label recipes live on Chip. */\ntype ButtonIntent =\n | \"danger\"\n | \"info\"\n | \"neutral\"\n | \"brand\"\n | \"commit\"\n | \"surface\";\nexport type ButtonAppearance = \"pill\" | \"raised\";\n\nconst pillSizes = {\n icon: \"polli:h-12 polli:w-12 polli:p-0\",\n xs: \"polli:h-5 polli:px-1.5 polli:py-0 polli:text-[11px] polli:leading-none\",\n sm: \"polli:min-h-7 polli:px-2 polli:pt-0.5 polli:pb-1\",\n md: \"polli:min-h-9 polli:px-4 polli:pt-1.5 polli:pb-2\",\n lg: \"polli:min-h-12 polli:px-6 polli:py-3 polli:text-base\",\n} as const;\n\nconst raisedSizes = {\n icon: \"polli:h-12 polli:w-12 polli:p-0\",\n xs: \"polli:px-2 polli:py-1 polli:text-xs\",\n sm: \"polli:px-4 polli:py-2 polli:text-sm\",\n md: \"polli:px-7 polli:py-3.5 polli:text-base\",\n lg: \"polli:px-8 polli:py-4 polli:text-lg\",\n} as const;\n\nconst appearanceClasses: Record<ButtonAppearance, string> = {\n pill: \"polli:rounded-full\",\n raised:\n \"polli:rounded-xl polli:border-r-[3px] polli:border-b-[3px] polli:border-solid \" +\n \"polli:border-theme-text-strong/20 polli:hover:border-theme-text-strong/45\",\n};\n\n// Cascade-driven base — reads [data-theme] vars.\nconst themeClasses =\n \"polli:bg-theme-bg-active polli:text-theme-text-strong \" +\n \"polli:hover:bg-theme-bg-hover polli:hover:text-theme-text-hover polli:transition-colors\";\n\n// Primary actions have a soft accent fill in light mode and an outline in dark.\n// `brand` keeps a calm hover; `commit` strengthens the fill on hover and focus.\nconst outlined =\n \"polli:border polli:border-theme-text-soft polli:bg-theme-bg-active/30 polli:text-theme-text-strong \" +\n \"polli:transition-colors polli:[.dark_&]:bg-transparent\";\nconst intentClasses: Record<ButtonIntent, string> = {\n brand: `${outlined} polli:hover:bg-theme-bg-active/50 polli:[.dark_&]:hover:bg-theme-text-soft/10`,\n commit:\n `${outlined} polli:hover:border-theme-bg-active polli:hover:bg-theme-bg-active ` +\n \"polli:focus-visible:border-theme-bg-active polli:focus-visible:bg-theme-bg-active \" +\n \"polli:[.dark_&]:hover:bg-theme-bg-active polli:[.dark_&]:focus-visible:bg-theme-bg-active\",\n danger:\n \"polli:border polli:border-intent-danger-text polli:bg-intent-danger-bg-light polli:text-intent-danger-text \" +\n \"polli:hover:bg-intent-danger-bg-hover polli:focus-visible:bg-intent-danger-bg-hover polli:transition-colors \" +\n \"polli:[.dark_&]:bg-transparent polli:[.dark_&]:hover:bg-intent-danger-bg-hover polli:[.dark_&]:focus-visible:bg-intent-danger-bg-hover\",\n info:\n \"polli:bg-intent-info-bg-light polli:text-intent-info-text \" +\n \"polli:hover:bg-intent-info-bg-hover polli:transition-colors\",\n // A quiet white pill on the desk, like the colour toggle; hover previews\n // the accent as the ambient button does.\n surface:\n \"polli:bg-surface-opaque polli:text-theme-text-strong \" +\n \"polli:hover:bg-theme-bg-hover polli:hover:text-theme-text-hover polli:transition-colors\",\n // Secondary actions never take the accent: one step stronger grey on hover.\n neutral:\n \"polli:bg-theme-bg-subtle polli:text-theme-text-base \" +\n \"polli:hover:bg-theme-text-muted/25 polli:hover:text-theme-text-strong polli:transition-colors\",\n};\n\ntype BaseButtonProps = {\n icon?: ReactNode;\n /** Optional semantic recipe; omit for the ambient theme button. */\n intent?: ButtonIntent;\n /** `raised` is the stronger website CTA treatment. */\n appearance?: ButtonAppearance;\n size?: keyof typeof pillSizes;\n className?: string;\n disabled?: boolean;\n};\n\nconst buttonClasses = ({\n intent,\n appearance = \"pill\",\n size,\n className,\n disabled,\n busy,\n}: BaseButtonProps & { disabled?: boolean; busy?: boolean }) => {\n const colorClasses = intent ? intentClasses[intent] : themeClasses;\n const sizeClasses = appearance === \"raised\" ? raisedSizes : pillSizes;\n return cn(\n \"polli-control polli:inline-flex polli:items-center polli:justify-center polli:self-center polli:font-body polli:text-sm polli:font-medium polli:leading-normal polli:box-border polli:border polli:border-transparent\",\n // A busy button is working, not unavailable: it keeps its strength.\n busy\n ? \"polli:cursor-progress\"\n : disabled\n ? \"polli:opacity-50 polli:cursor-not-allowed\"\n : \"polli:hover:filter polli:hover:brightness-105 polli:cursor-pointer\",\n colorClasses,\n appearanceClasses[appearance],\n sizeClasses[size || \"md\"],\n className,\n );\n};\n\nexport type ButtonProps<T extends React.ElementType = \"button\"> =\n PropsWithChildren<BaseButtonProps> & {\n as?: T;\n } & Omit<React.ComponentPropsWithoutRef<T>, keyof BaseButtonProps | \"as\">;\n\nexport function Button<T extends React.ElementType = \"button\">({\n as,\n children,\n icon,\n intent,\n appearance,\n size,\n className,\n disabled,\n ...buttonProps\n}: ButtonProps<T>) {\n const Component: React.ElementType = as || \"button\";\n const isButton = Component === \"button\";\n const isAnchor = Component === \"a\";\n const buttonType = (\n buttonProps as {\n type?: \"button\" | \"submit\" | \"reset\";\n }\n ).type;\n const onClick = (\n buttonProps as {\n onClick?: (event: ReactMouseEvent) => void;\n }\n ).onClick;\n const ariaBusy = (\n buttonProps as { \"aria-busy\"?: boolean | \"true\" | \"false\" }\n )[\"aria-busy\"];\n const busy = ariaBusy === true || ariaBusy === \"true\";\n const handleClick = disabled\n ? (event: ReactMouseEvent) => {\n event.preventDefault();\n event.stopPropagation();\n }\n : onClick;\n\n return (\n <Component\n {...buttonProps}\n data-intent={intent}\n {...(isButton ? { type: buttonType ?? \"button\", disabled } : {})}\n {...(!isButton && disabled\n ? { \"aria-disabled\": true, tabIndex: -1 }\n : {})}\n {...(isAnchor && disabled ? { href: undefined } : {})}\n onClick={handleClick}\n className={buttonClasses({\n intent,\n appearance,\n size,\n className,\n disabled,\n busy,\n })}\n >\n {icon && (\n <span\n aria-hidden=\"true\"\n className=\"polli:mr-2 polli:flex polli:size-4 polli:shrink-0 polli:[&>svg]:size-full\"\n >\n {busy ? (\n <span className=\"polli:block polli:size-full polli:animate-spin polli:rounded-full polli:border-2 polli:border-current polli:border-r-transparent polli:motion-reduce:animate-none\" />\n ) : (\n icon\n )}\n </span>\n )}\n {children}\n </Component>\n );\n}\n","import { useAccountProfile, useAuthState } from \"@pollinations/sdk/react\";\nimport { cn } from \"../../lib/cn.ts\";\n\nexport type UserAvatarProps = {\n size?: \"sm\" | \"md\" | \"lg\";\n className?: string;\n};\n\nconst sizeClass = {\n sm: \"polli:w-6 polli:h-6 polli:text-xs\",\n md: \"polli:w-9 polli:h-9 polli:text-sm\",\n lg: \"polli:w-12 polli:h-12 polli:text-base\",\n} as const;\n\nfunction initials(name: string): string | null {\n const parts = name.trim().split(/\\s+/).filter(Boolean);\n if (parts.length === 0) return null;\n if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase() || null;\n const first = parts[0][0] ?? \"\";\n const last = parts[parts.length - 1][0] ?? \"\";\n return (first + last).toUpperCase() || null;\n}\n\n/** Avatar from `profile.image`, or initials from `profile.name`. `null` otherwise. */\nexport function UserAvatar({ size = \"md\", className }: UserAvatarProps) {\n const { isLoggedIn } = useAuthState();\n const { data: profile } = useAccountProfile({ enabled: isLoggedIn });\n if (!isLoggedIn) return null;\n\n const base = cn(\n \"polli:inline-flex polli:items-center polli:justify-center polli:rounded-full polli:overflow-hidden polli:bg-theme-bg-pale polli:text-theme-text-strong polli:font-semibold polli:select-none\",\n sizeClass[size],\n className,\n );\n\n if (profile?.image) {\n return (\n <img\n data-polli=\"user-avatar\"\n src={profile.image}\n alt={profile.name ?? \"\"}\n className={base}\n />\n );\n }\n const label = profile?.name ? initials(profile.name) : null;\n if (!label) return null;\n return (\n <div\n data-polli=\"user-avatar\"\n role=\"img\"\n aria-label={profile?.name ?? undefined}\n className={base}\n >\n {label}\n </div>\n );\n}\n","import { useAccountProfile, useAuthState } from \"@pollinations/sdk/react\";\n\nexport type UserNameProps = { className?: string };\n\n/**\n * Renders the user's display name. Falls back to GitHub username when the\n * `profile` scope was not granted (or `name` is empty). `null` when logged\n * out, or when neither name nor GitHub username is available.\n */\nexport function UserName({ className }: UserNameProps) {\n const { isLoggedIn } = useAuthState();\n const { data: profile } = useAccountProfile({ enabled: isLoggedIn });\n if (!isLoggedIn || !profile) return null;\n const display = profile.name || profile.githubUsername;\n if (!display) return null;\n return (\n <span data-polli=\"user-name\" className={className}>\n {display}\n </span>\n );\n}\n","import { useAuthState } from \"@pollinations/sdk/react\";\nimport { Fragment, type ReactNode } from \"react\";\n\nexport type WhenLoggedInProps = { children: ReactNode };\n\n/** Renders `children` only when a user is signed in. */\nexport function WhenLoggedIn({ children }: WhenLoggedInProps) {\n const { isLoggedIn } = useAuthState();\n if (!isLoggedIn) return null;\n return <Fragment>{children}</Fragment>;\n}\n","import { useAuthState } from \"@pollinations/sdk/react\";\nimport { Fragment, type ReactNode } from \"react\";\n\nexport type WhenLoggedOutProps = { children: ReactNode };\n\n/** Renders `children` only when no user is signed in. */\nexport function WhenLoggedOut({ children }: WhenLoggedOutProps) {\n const { isLoggedIn } = useAuthState();\n if (isLoggedIn) return null;\n return <Fragment>{children}</Fragment>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA6C;;;ACA7C,kBAAqB;AACrB,4BAAoC;AAIpC,IAAM,cAAU,2CAAoB;AAAA,EAChC,QAAQ;AAAA,EACR,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE;AACzC,CAAC;AAGM,SAAS,MAAM,QAA+C;AACjE,SAAO,YAAQ,kBAAK,GAAG,MAAM,CAAC;AAClC;;;AC0IQ;AAtIR,IAAM,YAAY;AAAA,EACd,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACR;AAEA,IAAM,cAAc;AAAA,EAChB,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAC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,EAAE,SAAS,GAAuB;AAC5D,QAAM,EAAE,WAAW,QAAI,4BAAa;AACpC,MAAI,WAAY,QAAO;AACvB,SAAO,6CAAC,0BAAU,UAAS;AAC/B;","names":["import_jsx_runtime","import_react","import_jsx_runtime","import_react","import_jsx_runtime","import_react","import_jsx_runtime","import_react","import_jsx_runtime"]}
@@ -1,40 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ReactNode } from 'react';
3
- import { B as ButtonProps } from '../Button-BGqClaBr.cjs';
4
-
5
- type LoginButtonProps = Omit<ButtonProps<"button">, "as" | "onClick" | "children"> & {
6
- children: ReactNode;
7
- };
8
- /** Button that kicks off the auth redirect. `null` when already logged in. */
9
- declare function LoginButton({ children, ...buttonProps }: LoginButtonProps): react_jsx_runtime.JSX.Element | null;
10
-
11
- type UserAvatarProps = {
12
- size?: "sm" | "md" | "lg";
13
- className?: string;
14
- };
15
- /** Avatar from `profile.image`, or initials from `profile.name`. `null` otherwise. */
16
- declare function UserAvatar({ size, className }: UserAvatarProps): react_jsx_runtime.JSX.Element | null;
17
-
18
- type UserNameProps = {
19
- className?: string;
20
- };
21
- /**
22
- * Renders the user's display name. Falls back to GitHub username when the
23
- * `profile` scope was not granted (or `name` is empty). `null` when logged
24
- * out, or when neither name nor GitHub username is available.
25
- */
26
- declare function UserName({ className }: UserNameProps): react_jsx_runtime.JSX.Element | null;
27
-
28
- type WhenLoggedInProps = {
29
- children: ReactNode;
30
- };
31
- /** Renders `children` only when a user is signed in. */
32
- declare function WhenLoggedIn({ children }: WhenLoggedInProps): react_jsx_runtime.JSX.Element | null;
33
-
34
- type WhenLoggedOutProps = {
35
- children: ReactNode;
36
- };
37
- /** Renders `children` only when no user is signed in. */
38
- declare function WhenLoggedOut({ children }: WhenLoggedOutProps): react_jsx_runtime.JSX.Element | null;
39
-
40
- export { LoginButton, type LoginButtonProps, UserAvatar, type UserAvatarProps, UserName, type UserNameProps, WhenLoggedIn, type WhenLoggedInProps, WhenLoggedOut, type WhenLoggedOutProps };