@pollinations/ui 0.1.0-alpha.4 → 0.1.0-alpha.40
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 +16 -8
- package/dist/{Button-ByKwRtdw.d.cts → Button-Bt_eMnOx.d.ts} +4 -2
- package/dist/app-user-menu/sdk.d.ts +17 -5
- package/dist/app-user-menu/sdk.js +104 -774
- package/dist/app-user-menu/sdk.js.map +1 -1
- package/dist/app.css +21 -0
- package/dist/auth/index.d.ts +12 -5
- package/dist/auth/index.js +170 -1159
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/sdk.d.ts +1 -1
- package/dist/auth/sdk.js +9 -205
- package/dist/auth/sdk.js.map +1 -1
- package/dist/brand/badge-made-with.svg +1 -0
- package/dist/brand/polli/polli-lockup-horizontal-black.png +0 -0
- package/dist/brand/polli/polli-lockup-horizontal-white.png +0 -0
- package/dist/brand/polli/polli.png +0 -0
- package/dist/chunk-B7T42IY2.js +255 -0
- package/dist/chunk-B7T42IY2.js.map +1 -0
- package/dist/chunk-DFYLQTCM.js +107 -0
- package/dist/chunk-DFYLQTCM.js.map +1 -0
- package/dist/chunk-EHOK3XKM.js +112 -0
- package/dist/chunk-EHOK3XKM.js.map +1 -0
- package/dist/chunk-FZXMS7HJ.js +93 -0
- package/dist/chunk-FZXMS7HJ.js.map +1 -0
- package/dist/chunk-KLAOGE6Y.js +125 -0
- package/dist/chunk-KLAOGE6Y.js.map +1 -0
- package/dist/chunk-KTGSOTNW.js +534 -0
- package/dist/chunk-KTGSOTNW.js.map +1 -0
- package/dist/chunk-LAZ5O2ZK.js +105 -0
- package/dist/chunk-LAZ5O2ZK.js.map +1 -0
- package/dist/chunk-MS2GGEMU.js +311 -0
- package/dist/chunk-MS2GGEMU.js.map +1 -0
- package/dist/chunk-MU7JQOTF.js +170 -0
- package/dist/chunk-MU7JQOTF.js.map +1 -0
- package/dist/chunk-OWQ2HDQB.js +50 -0
- package/dist/chunk-OWQ2HDQB.js.map +1 -0
- package/dist/chunk-QPNEXTZ5.js +88 -0
- package/dist/chunk-QPNEXTZ5.js.map +1 -0
- package/dist/{app-user-menu/sdk.cjs → chunk-R3RMENGN.js} +114 -773
- package/dist/chunk-R3RMENGN.js.map +1 -0
- package/dist/chunk-WV4XTYMU.js +58 -0
- package/dist/chunk-WV4XTYMU.js.map +1 -0
- package/dist/chunk-WVDV47XQ.js +651 -0
- package/dist/chunk-WVDV47XQ.js.map +1 -0
- package/dist/connect.js +100 -0
- package/dist/connect.js.map +1 -0
- package/dist/gen/index.d.ts +14 -7
- package/dist/gen/index.js +59 -474
- package/dist/gen/index.js.map +1 -1
- package/dist/index-BR4r9rhQ.d.ts +90 -0
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.d.ts +195 -103
- package/dist/index.js +1051 -2801
- package/dist/index.js.map +1 -1
- package/dist/licenses/Octicons-MIT.txt +21 -0
- package/dist/markdown.d.ts +3 -1
- package/dist/markdown.js +69 -598
- package/dist/markdown.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/theme.css +12 -0
- package/dist/types-CCy9JNu9.d.ts +6 -0
- package/dist/wallet/index.d.ts +20 -1
- package/dist/wallet/index.js +19 -370
- package/dist/wallet/index.js.map +1 -1
- package/package.json +18 -22
- package/dist/Button-ByKwRtdw.d.ts +0 -29
- package/dist/Chip-v-ADv6cz.d.cts +0 -18
- package/dist/Dialog-D3Nqt8cE.d.cts +0 -66
- package/dist/app-user-menu/sdk.cjs.map +0 -1
- package/dist/app-user-menu/sdk.d.cts +0 -33
- package/dist/auth/index.cjs +0 -1512
- package/dist/auth/index.cjs.map +0 -1
- package/dist/auth/index.d.cts +0 -112
- package/dist/auth/sdk.cjs +0 -244
- package/dist/auth/sdk.cjs.map +0 -1
- package/dist/auth/sdk.d.cts +0 -40
- package/dist/gen/index.cjs +0 -687
- package/dist/gen/index.cjs.map +0 -1
- package/dist/gen/index.d.cts +0 -84
- package/dist/index.cjs +0 -5183
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -933
- package/dist/markdown.cjs +0 -826
- package/dist/markdown.cjs.map +0 -1
- package/dist/markdown.d.cts +0 -16
- package/dist/wallet/index.cjs +0 -429
- package/dist/wallet/index.cjs.map +0 -1
- package/dist/wallet/index.d.cts +0 -53
package/dist/auth/sdk.cjs
DELETED
|
@@ -1,244 +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)({ prefix: "polli" });
|
|
38
|
-
function cn(...inputs) {
|
|
39
|
-
return twMerge((0, import_clsx.clsx)(...inputs));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// src/primitives/Button.tsx
|
|
43
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
44
|
-
var pillSizes = {
|
|
45
|
-
icon: "polli:h-12 polli:w-12 polli:p-0",
|
|
46
|
-
xs: "polli:h-5 polli:px-1.5 polli:py-0 polli:text-[11px] polli:leading-none",
|
|
47
|
-
sm: "polli:min-h-7 polli:px-2 polli:pt-0.5 polli:pb-1",
|
|
48
|
-
md: "polli:min-h-9 polli:px-4 polli:pt-1.5 polli:pb-2",
|
|
49
|
-
lg: "polli:min-h-12 polli:px-6 polli:py-3 polli:text-base"
|
|
50
|
-
};
|
|
51
|
-
var raisedSizes = {
|
|
52
|
-
icon: "polli:h-12 polli:w-12 polli:p-0",
|
|
53
|
-
xs: "polli:px-2 polli:py-1 polli:text-xs",
|
|
54
|
-
sm: "polli:px-4 polli:py-2 polli:text-sm",
|
|
55
|
-
md: "polli:px-7 polli:py-3.5 polli:text-base",
|
|
56
|
-
lg: "polli:px-8 polli:py-4 polli:text-lg"
|
|
57
|
-
};
|
|
58
|
-
var appearanceClasses = {
|
|
59
|
-
pill: "polli:rounded-full",
|
|
60
|
-
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"
|
|
61
|
-
};
|
|
62
|
-
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";
|
|
63
|
-
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";
|
|
64
|
-
var intentClasses = {
|
|
65
|
-
brand: `${outlined} polli:hover:bg-theme-bg-active/50 polli:[.dark_&]:hover:bg-theme-text-soft/10`,
|
|
66
|
-
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`,
|
|
67
|
-
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",
|
|
68
|
-
info: "polli:bg-intent-info-bg-light polli:text-intent-info-text polli:hover:bg-intent-info-bg-hover polli:transition-colors",
|
|
69
|
-
// Secondary actions never take the accent: one step stronger grey on hover.
|
|
70
|
-
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"
|
|
71
|
-
};
|
|
72
|
-
var buttonClasses = ({
|
|
73
|
-
intent,
|
|
74
|
-
appearance = "pill",
|
|
75
|
-
size,
|
|
76
|
-
className,
|
|
77
|
-
disabled,
|
|
78
|
-
busy
|
|
79
|
-
}) => {
|
|
80
|
-
const colorClasses = intent ? intentClasses[intent] : themeClasses;
|
|
81
|
-
const sizeClasses = appearance === "raised" ? raisedSizes : pillSizes;
|
|
82
|
-
return cn(
|
|
83
|
-
"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",
|
|
84
|
-
// A busy button is working, not unavailable: it keeps its strength.
|
|
85
|
-
busy ? "polli:cursor-progress" : disabled ? "polli:opacity-50 polli:cursor-not-allowed" : "polli:hover:filter polli:hover:brightness-105 polli:cursor-pointer",
|
|
86
|
-
colorClasses,
|
|
87
|
-
appearanceClasses[appearance],
|
|
88
|
-
sizeClasses[size || "md"],
|
|
89
|
-
className
|
|
90
|
-
);
|
|
91
|
-
};
|
|
92
|
-
function Button({
|
|
93
|
-
as,
|
|
94
|
-
children,
|
|
95
|
-
icon,
|
|
96
|
-
intent,
|
|
97
|
-
appearance,
|
|
98
|
-
size,
|
|
99
|
-
className,
|
|
100
|
-
disabled,
|
|
101
|
-
...buttonProps
|
|
102
|
-
}) {
|
|
103
|
-
const Component = as || "button";
|
|
104
|
-
const isButton = Component === "button";
|
|
105
|
-
const isAnchor = Component === "a";
|
|
106
|
-
const buttonType = buttonProps.type;
|
|
107
|
-
const onClick = buttonProps.onClick;
|
|
108
|
-
const ariaBusy = buttonProps["aria-busy"];
|
|
109
|
-
const busy = ariaBusy === true || ariaBusy === "true";
|
|
110
|
-
const handleClick = disabled ? (event) => {
|
|
111
|
-
event.preventDefault();
|
|
112
|
-
event.stopPropagation();
|
|
113
|
-
} : onClick;
|
|
114
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
115
|
-
Component,
|
|
116
|
-
{
|
|
117
|
-
...buttonProps,
|
|
118
|
-
"data-intent": intent,
|
|
119
|
-
...isButton ? { type: buttonType ?? "button", disabled } : {},
|
|
120
|
-
...!isButton && disabled ? { "aria-disabled": true, tabIndex: -1 } : {},
|
|
121
|
-
...isAnchor && disabled ? { href: void 0 } : {},
|
|
122
|
-
onClick: handleClick,
|
|
123
|
-
className: buttonClasses({
|
|
124
|
-
intent,
|
|
125
|
-
appearance,
|
|
126
|
-
size,
|
|
127
|
-
className,
|
|
128
|
-
disabled,
|
|
129
|
-
busy
|
|
130
|
-
}),
|
|
131
|
-
children: [
|
|
132
|
-
icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
133
|
-
"span",
|
|
134
|
-
{
|
|
135
|
-
"aria-hidden": "true",
|
|
136
|
-
className: "polli:mr-2 polli:flex polli:size-4 polli:shrink-0 polli:[&>svg]:size-full",
|
|
137
|
-
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
|
|
138
|
-
}
|
|
139
|
-
),
|
|
140
|
-
children
|
|
141
|
-
]
|
|
142
|
-
}
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// src/modules/auth/LoginButton.tsx
|
|
147
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
148
|
-
function LoginButton({ children, ...buttonProps }) {
|
|
149
|
-
const { isLoggedIn } = (0, import_react.useAuthState)();
|
|
150
|
-
const { login } = (0, import_react.useAuthActions)();
|
|
151
|
-
if (isLoggedIn) return null;
|
|
152
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Button, { ...buttonProps, onClick: () => login(), children });
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// src/modules/auth/UserAvatar.tsx
|
|
156
|
-
var import_react2 = require("@pollinations/sdk/react");
|
|
157
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
158
|
-
var sizeClass = {
|
|
159
|
-
sm: "polli:w-6 polli:h-6 polli:text-xs",
|
|
160
|
-
md: "polli:w-9 polli:h-9 polli:text-sm",
|
|
161
|
-
lg: "polli:w-12 polli:h-12 polli:text-base"
|
|
162
|
-
};
|
|
163
|
-
function initials(name) {
|
|
164
|
-
const parts = name.trim().split(/\s+/).filter(Boolean);
|
|
165
|
-
if (parts.length === 0) return null;
|
|
166
|
-
if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase() || null;
|
|
167
|
-
const first = parts[0][0] ?? "";
|
|
168
|
-
const last = parts[parts.length - 1][0] ?? "";
|
|
169
|
-
return (first + last).toUpperCase() || null;
|
|
170
|
-
}
|
|
171
|
-
function UserAvatar({ size = "md", className }) {
|
|
172
|
-
const { isLoggedIn } = (0, import_react2.useAuthState)();
|
|
173
|
-
const { data: profile } = (0, import_react2.useAccountProfile)({ enabled: isLoggedIn });
|
|
174
|
-
if (!isLoggedIn) return null;
|
|
175
|
-
const base = cn(
|
|
176
|
-
"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",
|
|
177
|
-
sizeClass[size],
|
|
178
|
-
className
|
|
179
|
-
);
|
|
180
|
-
if (profile?.image) {
|
|
181
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
182
|
-
"img",
|
|
183
|
-
{
|
|
184
|
-
"data-polli": "user-avatar",
|
|
185
|
-
src: profile.image,
|
|
186
|
-
alt: profile.name ?? "",
|
|
187
|
-
className: base
|
|
188
|
-
}
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
const label = profile?.name ? initials(profile.name) : null;
|
|
192
|
-
if (!label) return null;
|
|
193
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
194
|
-
"div",
|
|
195
|
-
{
|
|
196
|
-
"data-polli": "user-avatar",
|
|
197
|
-
role: "img",
|
|
198
|
-
"aria-label": profile?.name ?? void 0,
|
|
199
|
-
className: base,
|
|
200
|
-
children: label
|
|
201
|
-
}
|
|
202
|
-
);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// src/modules/auth/UserName.tsx
|
|
206
|
-
var import_react3 = require("@pollinations/sdk/react");
|
|
207
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
208
|
-
function UserName({ className }) {
|
|
209
|
-
const { isLoggedIn } = (0, import_react3.useAuthState)();
|
|
210
|
-
const { data: profile } = (0, import_react3.useAccountProfile)({ enabled: isLoggedIn });
|
|
211
|
-
if (!isLoggedIn || !profile) return null;
|
|
212
|
-
const display = profile.name || profile.githubUsername;
|
|
213
|
-
if (!display) return null;
|
|
214
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-polli": "user-name", className, children: display });
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// src/modules/auth/WhenLoggedIn.tsx
|
|
218
|
-
var import_react4 = require("@pollinations/sdk/react");
|
|
219
|
-
var import_react5 = require("react");
|
|
220
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
221
|
-
function WhenLoggedIn({ children }) {
|
|
222
|
-
const { isLoggedIn } = (0, import_react4.useAuthState)();
|
|
223
|
-
if (!isLoggedIn) return null;
|
|
224
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react5.Fragment, { children });
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// src/modules/auth/WhenLoggedOut.tsx
|
|
228
|
-
var import_react6 = require("@pollinations/sdk/react");
|
|
229
|
-
var import_react7 = require("react");
|
|
230
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
231
|
-
function WhenLoggedOut({ children }) {
|
|
232
|
-
const { isLoggedIn } = (0, import_react6.useAuthState)();
|
|
233
|
-
if (isLoggedIn) return null;
|
|
234
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react7.Fragment, { children });
|
|
235
|
-
}
|
|
236
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
237
|
-
0 && (module.exports = {
|
|
238
|
-
LoginButton,
|
|
239
|
-
UserAvatar,
|
|
240
|
-
UserName,
|
|
241
|
-
WhenLoggedIn,
|
|
242
|
-
WhenLoggedOut
|
|
243
|
-
});
|
|
244
|
-
//# sourceMappingURL=sdk.cjs.map
|
package/dist/auth/sdk.cjs.map
DELETED
|
@@ -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\nconst twMerge = extendTailwindMerge({ prefix: \"polli\" });\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 = \"danger\" | \"info\" | \"neutral\" | \"brand\" | \"commit\";\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 // 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;AAEpC,IAAM,cAAU,2CAAoB,EAAE,QAAQ,QAAQ,CAAC;AAGhD,SAAS,MAAM,QAA+C;AACjE,SAAO,YAAQ,kBAAK,GAAG,MAAM,CAAC;AAClC;;;ACoIQ;AAjIR,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;AACR;AAEA,IAAM,oBAAsD;AAAA,EACxD,MAAM;AAAA,EACN,QACI;AAER;AAGA,IAAM,eACF;AAKJ,IAAM,WACF;AAEJ,IAAM,gBAA8C;AAAA,EAChD,OAAO,GAAG,QAAQ;AAAA,EAClB,QACI,GAAG,QAAQ;AAAA,EAGf,QACI;AAAA,EAGJ,MACI;AAAA;AAAA,EAGJ,SACI;AAER;AAaA,IAAM,gBAAgB,CAAC;AAAA,EACnB;AAAA,EACA,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,MAAgE;AAC5D,QAAM,eAAe,SAAS,cAAc,MAAM,IAAI;AACtD,QAAM,cAAc,eAAe,WAAW,cAAc;AAC5D,SAAO;AAAA,IACH;AAAA;AAAA,IAEA,OACM,0BACA,WACE,8CACA;AAAA,IACR;AAAA,IACA,kBAAkB,UAAU;AAAA,IAC5B,Y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IAAAC,gBAAgD;AAgBxC,IAAAC,sBAAA;AAPD,SAAS,SAAS,EAAE,UAAU,GAAkB;AACnD,QAAM,EAAE,WAAW,QAAI,4BAAa;AACpC,QAAM,EAAE,MAAM,QAAQ,QAAI,iCAAkB,EAAE,SAAS,WAAW,CAAC;AACnE,MAAI,CAAC,cAAc,CAAC,QAAS,QAAO;AACpC,QAAM,UAAU,QAAQ,QAAQ,QAAQ;AACxC,MAAI,CAAC,QAAS,QAAO;AACrB,SACI,6CAAC,UAAK,cAAW,aAAY,WACxB,mBACL;AAER;;;ACpBA,IAAAC,gBAA6B;AAC7B,IAAAA,gBAAyC;AAQ9B,IAAAC,sBAAA;AAHJ,SAAS,aAAa,EAAE,SAAS,GAAsB;AAC1D,QAAM,EAAE,WAAW,QAAI,4BAAa;AACpC,MAAI,CAAC,WAAY,QAAO;AACxB,SAAO,6CAAC,0BAAU,UAAS;AAC/B;;;ACVA,IAAAC,gBAA6B;AAC7B,IAAAA,gBAAyC;AAQ9B,IAAAC,sBAAA;AAHJ,SAAS,cAAc,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"]}
|
package/dist/auth/sdk.d.cts
DELETED
|
@@ -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-ByKwRtdw.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 };
|