@refraction-ui/react 0.2.0 → 0.2.1
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/index.cjs +69 -94
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +69 -95
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -179,6 +179,7 @@ __export(index_exports, {
|
|
|
179
179
|
PRESENCE_STATUS_COLORS: () => STATUS_COLORS,
|
|
180
180
|
PRESENCE_STATUS_LABELS: () => STATUS_LABELS,
|
|
181
181
|
Pagination: () => Pagination,
|
|
182
|
+
Payment: () => Payment,
|
|
182
183
|
Popover: () => Popover,
|
|
183
184
|
PopoverClose: () => PopoverClose,
|
|
184
185
|
PopoverContent: () => PopoverContent,
|
|
@@ -1160,106 +1161,16 @@ function getAssignableRoles(user) {
|
|
|
1160
1161
|
if (hasRole(user, "reviewer")) return ["student"];
|
|
1161
1162
|
return [];
|
|
1162
1163
|
}
|
|
1163
|
-
function createMockAdapter(initialUser) {
|
|
1164
|
-
let currentUser = initialUser ?? null;
|
|
1165
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
1166
|
-
function notify() {
|
|
1167
|
-
for (const fn of listeners) {
|
|
1168
|
-
fn(currentUser);
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
return {
|
|
1172
|
-
async signIn(email, _password) {
|
|
1173
|
-
currentUser = {
|
|
1174
|
-
uid: "mock-" + email,
|
|
1175
|
-
email,
|
|
1176
|
-
displayName: email.split("@")[0],
|
|
1177
|
-
photoURL: null,
|
|
1178
|
-
roles: ["student"]
|
|
1179
|
-
};
|
|
1180
|
-
notify();
|
|
1181
|
-
return currentUser;
|
|
1182
|
-
},
|
|
1183
|
-
async signInWithOAuth(_provider) {
|
|
1184
|
-
currentUser = {
|
|
1185
|
-
uid: "mock-oauth",
|
|
1186
|
-
email: "oauth@example.com",
|
|
1187
|
-
displayName: "OAuth User",
|
|
1188
|
-
photoURL: null,
|
|
1189
|
-
roles: ["student"]
|
|
1190
|
-
};
|
|
1191
|
-
notify();
|
|
1192
|
-
return currentUser;
|
|
1193
|
-
},
|
|
1194
|
-
async signUp(email, _password, displayName) {
|
|
1195
|
-
currentUser = {
|
|
1196
|
-
uid: "mock-" + email,
|
|
1197
|
-
email,
|
|
1198
|
-
displayName,
|
|
1199
|
-
photoURL: null,
|
|
1200
|
-
roles: ["student"]
|
|
1201
|
-
};
|
|
1202
|
-
notify();
|
|
1203
|
-
return currentUser;
|
|
1204
|
-
},
|
|
1205
|
-
async signOut() {
|
|
1206
|
-
currentUser = null;
|
|
1207
|
-
notify();
|
|
1208
|
-
},
|
|
1209
|
-
async resetPassword(_email) {
|
|
1210
|
-
},
|
|
1211
|
-
async getToken() {
|
|
1212
|
-
return currentUser ? "mock-token-" + currentUser.uid : null;
|
|
1213
|
-
},
|
|
1214
|
-
onAuthStateChange(callback) {
|
|
1215
|
-
listeners.add(callback);
|
|
1216
|
-
callback(currentUser);
|
|
1217
|
-
return () => {
|
|
1218
|
-
listeners.delete(callback);
|
|
1219
|
-
};
|
|
1220
|
-
}
|
|
1221
|
-
};
|
|
1222
|
-
}
|
|
1223
|
-
function resolveAdapter(provider) {
|
|
1224
|
-
const resolved = provider ?? detectProvider();
|
|
1225
|
-
switch (resolved) {
|
|
1226
|
-
case "firebase":
|
|
1227
|
-
if (typeof console !== "undefined") {
|
|
1228
|
-
console.warn("[refraction-ui/auth] Firebase adapter not yet implemented. Using mock adapter.");
|
|
1229
|
-
}
|
|
1230
|
-
return createMockAdapter();
|
|
1231
|
-
case "supabase":
|
|
1232
|
-
if (typeof console !== "undefined") {
|
|
1233
|
-
console.warn("[refraction-ui/auth] Supabase adapter not yet implemented. Using mock adapter.");
|
|
1234
|
-
}
|
|
1235
|
-
return createMockAdapter();
|
|
1236
|
-
case "mock":
|
|
1237
|
-
return createMockAdapter();
|
|
1238
|
-
case "none":
|
|
1239
|
-
default:
|
|
1240
|
-
return createMockAdapter();
|
|
1241
|
-
}
|
|
1242
|
-
}
|
|
1243
|
-
function detectProvider() {
|
|
1244
|
-
const env = typeof process !== "undefined" ? process.env : {};
|
|
1245
|
-
const explicit = env["REFRACTION_AUTH_PROVIDER"];
|
|
1246
|
-
if (explicit) return explicit;
|
|
1247
|
-
if (env["FIREBASE_API_KEY"] || env["NEXT_PUBLIC_FIREBASE_API_KEY"]) {
|
|
1248
|
-
return "firebase";
|
|
1249
|
-
}
|
|
1250
|
-
if (env["SUPABASE_URL"] || env["NEXT_PUBLIC_SUPABASE_URL"]) {
|
|
1251
|
-
return "supabase";
|
|
1252
|
-
}
|
|
1253
|
-
return "none";
|
|
1254
|
-
}
|
|
1255
1164
|
|
|
1256
1165
|
// ../react-auth/dist/index.js
|
|
1257
1166
|
var AuthContext = React41__namespace.createContext(null);
|
|
1258
1167
|
function AuthProvider({ children, ...config }) {
|
|
1259
1168
|
const authRef = React41__namespace.useRef(null);
|
|
1260
1169
|
if (!authRef.current) {
|
|
1261
|
-
|
|
1262
|
-
|
|
1170
|
+
if (!config.adapter) {
|
|
1171
|
+
throw new Error("[refraction-ui/react-auth] You must provide an `adapter` to AuthProvider.");
|
|
1172
|
+
}
|
|
1173
|
+
authRef.current = createAuth(config.adapter, config);
|
|
1263
1174
|
}
|
|
1264
1175
|
const [state, setState] = React41__namespace.useState(() => authRef.current.getState());
|
|
1265
1176
|
React41__namespace.useEffect(() => {
|
|
@@ -12348,6 +12259,69 @@ var CardGrid = React41__namespace.forwardRef(
|
|
|
12348
12259
|
);
|
|
12349
12260
|
CardGrid.displayName = "CardGrid";
|
|
12350
12261
|
|
|
12262
|
+
// ../payment/dist/index.js
|
|
12263
|
+
function createPayment(props = {}) {
|
|
12264
|
+
return {
|
|
12265
|
+
props: {
|
|
12266
|
+
...props,
|
|
12267
|
+
"data-slot": "payment"
|
|
12268
|
+
}
|
|
12269
|
+
};
|
|
12270
|
+
}
|
|
12271
|
+
var Payment = React41__namespace.forwardRef(
|
|
12272
|
+
({ className, disabled, ...props }, ref) => {
|
|
12273
|
+
const api = createPayment({ disabled });
|
|
12274
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12275
|
+
"div",
|
|
12276
|
+
{
|
|
12277
|
+
ref,
|
|
12278
|
+
className: cn(
|
|
12279
|
+
"w-full max-w-md mx-auto p-6 border border-border rounded-xl bg-card text-card-foreground shadow-sm",
|
|
12280
|
+
disabled && "opacity-50 pointer-events-none",
|
|
12281
|
+
className
|
|
12282
|
+
),
|
|
12283
|
+
...api.props,
|
|
12284
|
+
...props
|
|
12285
|
+
}
|
|
12286
|
+
);
|
|
12287
|
+
}
|
|
12288
|
+
);
|
|
12289
|
+
Payment.displayName = "Payment";
|
|
12290
|
+
var PaymentHeader = React41__namespace.forwardRef(
|
|
12291
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("mb-6 flex flex-col gap-1.5", className), ...props })
|
|
12292
|
+
);
|
|
12293
|
+
PaymentHeader.displayName = "PaymentHeader";
|
|
12294
|
+
var PaymentTitle = React41__namespace.forwardRef(
|
|
12295
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("h3", { ref, className: cn("text-xl font-semibold leading-none tracking-tight", className), ...props })
|
|
12296
|
+
);
|
|
12297
|
+
PaymentTitle.displayName = "PaymentTitle";
|
|
12298
|
+
var PaymentDescription = React41__namespace.forwardRef(
|
|
12299
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("p", { ref, className: cn("text-sm text-muted-foreground", className), ...props })
|
|
12300
|
+
);
|
|
12301
|
+
PaymentDescription.displayName = "PaymentDescription";
|
|
12302
|
+
var PaymentContent = React41__namespace.forwardRef(
|
|
12303
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("flex flex-col gap-4", className), ...props })
|
|
12304
|
+
);
|
|
12305
|
+
PaymentContent.displayName = "PaymentContent";
|
|
12306
|
+
var PaymentFooter = React41__namespace.forwardRef(
|
|
12307
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("mt-6 flex flex-col gap-3", className), ...props })
|
|
12308
|
+
);
|
|
12309
|
+
PaymentFooter.displayName = "PaymentFooter";
|
|
12310
|
+
var PaymentButton = React41__namespace.forwardRef(
|
|
12311
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
12312
|
+
"button",
|
|
12313
|
+
{
|
|
12314
|
+
ref,
|
|
12315
|
+
className: cn(
|
|
12316
|
+
"inline-flex w-full items-center justify-center whitespace-nowrap rounded-md bg-primary px-4 py-2.5 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
|
|
12317
|
+
className
|
|
12318
|
+
),
|
|
12319
|
+
...props
|
|
12320
|
+
}
|
|
12321
|
+
)
|
|
12322
|
+
);
|
|
12323
|
+
PaymentButton.displayName = "PaymentButton";
|
|
12324
|
+
|
|
12351
12325
|
exports.Accordion = Accordion;
|
|
12352
12326
|
exports.AccordionContent = AccordionContent;
|
|
12353
12327
|
exports.AccordionItem = AccordionItem;
|
|
@@ -12440,6 +12414,7 @@ exports.OtpInput = OtpInput;
|
|
|
12440
12414
|
exports.PRESENCE_STATUS_COLORS = STATUS_COLORS;
|
|
12441
12415
|
exports.PRESENCE_STATUS_LABELS = STATUS_LABELS;
|
|
12442
12416
|
exports.Pagination = Pagination;
|
|
12417
|
+
exports.Payment = Payment;
|
|
12443
12418
|
exports.Popover = Popover;
|
|
12444
12419
|
exports.PopoverClose = PopoverClose;
|
|
12445
12420
|
exports.PopoverContent = PopoverContent;
|