@usethrottle/storefront-react 0.0.0-stage → 0.1.0
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/CLAUDE.md +67 -0
- package/README.md +119 -2
- package/dist/StorefrontProvider-Br4wUHui.d.cts +559 -0
- package/dist/StorefrontProvider-DLEPEjg6.d.ts +559 -0
- package/dist/account/index.cjs +69 -0
- package/dist/account/index.cjs.map +1 -0
- package/dist/account/index.d.cts +23 -0
- package/dist/account/index.d.ts +23 -0
- package/dist/account/index.js +68 -0
- package/dist/account/index.js.map +1 -0
- package/dist/chunk-2LCPIY2P.cjs +16 -0
- package/dist/chunk-2LCPIY2P.cjs.map +1 -0
- package/dist/chunk-3A72UY6T.js +2126 -0
- package/dist/chunk-3A72UY6T.js.map +1 -0
- package/dist/chunk-3JMIVAHN.js +185 -0
- package/dist/chunk-3JMIVAHN.js.map +1 -0
- package/dist/chunk-4J6AGWNC.cjs +24 -0
- package/dist/chunk-4J6AGWNC.cjs.map +1 -0
- package/dist/chunk-4U6MYDZV.js +17 -0
- package/dist/chunk-4U6MYDZV.js.map +1 -0
- package/dist/chunk-66HDJVPS.js +22 -0
- package/dist/chunk-66HDJVPS.js.map +1 -0
- package/dist/chunk-6X2OZSNV.cjs +83 -0
- package/dist/chunk-6X2OZSNV.cjs.map +1 -0
- package/dist/chunk-6ZMMZ245.cjs +2127 -0
- package/dist/chunk-6ZMMZ245.cjs.map +1 -0
- package/dist/chunk-7R37CVAB.cjs +23 -0
- package/dist/chunk-7R37CVAB.cjs.map +1 -0
- package/dist/chunk-A3IFWQUV.js +368 -0
- package/dist/chunk-A3IFWQUV.js.map +1 -0
- package/dist/chunk-AYC2YK4E.cjs +95 -0
- package/dist/chunk-AYC2YK4E.cjs.map +1 -0
- package/dist/chunk-AZV5U7YB.cjs +18 -0
- package/dist/chunk-AZV5U7YB.cjs.map +1 -0
- package/dist/chunk-CE2SKNQP.cjs +71 -0
- package/dist/chunk-CE2SKNQP.cjs.map +1 -0
- package/dist/chunk-D76CRI4X.js +2175 -0
- package/dist/chunk-D76CRI4X.js.map +1 -0
- package/dist/chunk-DOAII637.cjs +186 -0
- package/dist/chunk-DOAII637.cjs.map +1 -0
- package/dist/chunk-DYHHAOMG.cjs +17 -0
- package/dist/chunk-DYHHAOMG.cjs.map +1 -0
- package/dist/chunk-EYSVU5SJ.js +196 -0
- package/dist/chunk-EYSVU5SJ.js.map +1 -0
- package/dist/chunk-HSUUDZWS.js +37 -0
- package/dist/chunk-HSUUDZWS.js.map +1 -0
- package/dist/chunk-HZ6VEN6Q.cjs +101 -0
- package/dist/chunk-HZ6VEN6Q.cjs.map +1 -0
- package/dist/chunk-IJOTLGPT.js +16 -0
- package/dist/chunk-IJOTLGPT.js.map +1 -0
- package/dist/chunk-ISDATHVC.js +219 -0
- package/dist/chunk-ISDATHVC.js.map +1 -0
- package/dist/chunk-LW2A6USV.js +100 -0
- package/dist/chunk-LW2A6USV.js.map +1 -0
- package/dist/chunk-M4YXSLRG.cjs +369 -0
- package/dist/chunk-M4YXSLRG.cjs.map +1 -0
- package/dist/chunk-NDUEJJLP.cjs +2176 -0
- package/dist/chunk-NDUEJJLP.cjs.map +1 -0
- package/dist/chunk-NNE4FYRT.js +820 -0
- package/dist/chunk-NNE4FYRT.js.map +1 -0
- package/dist/chunk-NW3EFHY2.js +15 -0
- package/dist/chunk-NW3EFHY2.js.map +1 -0
- package/dist/chunk-NZRUQUN5.js +167 -0
- package/dist/chunk-NZRUQUN5.js.map +1 -0
- package/dist/chunk-P6HHE57S.cjs +38 -0
- package/dist/chunk-P6HHE57S.cjs.map +1 -0
- package/dist/chunk-PHY7AY27.cjs +197 -0
- package/dist/chunk-PHY7AY27.cjs.map +1 -0
- package/dist/chunk-PNJOFFTL.cjs +128 -0
- package/dist/chunk-PNJOFFTL.cjs.map +1 -0
- package/dist/chunk-PXZQ4ONA.js +127 -0
- package/dist/chunk-PXZQ4ONA.js.map +1 -0
- package/dist/chunk-Q3VTUBPP.js +82 -0
- package/dist/chunk-Q3VTUBPP.js.map +1 -0
- package/dist/chunk-Q3XFD5UI.js +45 -0
- package/dist/chunk-Q3XFD5UI.js.map +1 -0
- package/dist/chunk-QM7KTT7F.js +94 -0
- package/dist/chunk-QM7KTT7F.js.map +1 -0
- package/dist/chunk-RLWZOLXL.js +70 -0
- package/dist/chunk-RLWZOLXL.js.map +1 -0
- package/dist/chunk-SV53BRP2.js +23 -0
- package/dist/chunk-SV53BRP2.js.map +1 -0
- package/dist/chunk-VWXJO427.cjs +821 -0
- package/dist/chunk-VWXJO427.cjs.map +1 -0
- package/dist/chunk-WIIOJDHR.cjs +220 -0
- package/dist/chunk-WIIOJDHR.cjs.map +1 -0
- package/dist/chunk-XQHGFWLG.cjs +46 -0
- package/dist/chunk-XQHGFWLG.cjs.map +1 -0
- package/dist/chunk-ZHCXI2ZZ.cjs +168 -0
- package/dist/chunk-ZHCXI2ZZ.cjs.map +1 -0
- package/dist/index-RSj2Rg62.d.cts +8 -0
- package/dist/index-RSj2Rg62.d.ts +8 -0
- package/dist/index.cjs +2829 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1718 -0
- package/dist/index.d.ts +1718 -0
- package/dist/index.js +2828 -0
- package/dist/index.js.map +1 -0
- package/dist/metadata-QhKw-tvz.d.cts +188 -0
- package/dist/metadata-QhKw-tvz.d.ts +188 -0
- package/dist/next/client.cjs +84 -0
- package/dist/next/client.cjs.map +1 -0
- package/dist/next/client.d.cts +40 -0
- package/dist/next/client.d.ts +40 -0
- package/dist/next/client.js +83 -0
- package/dist/next/client.js.map +1 -0
- package/dist/next/index.cjs +1090 -0
- package/dist/next/index.cjs.map +1 -0
- package/dist/next/index.d.cts +218 -0
- package/dist/next/index.d.ts +218 -0
- package/dist/next/index.js +1049 -0
- package/dist/next/index.js.map +1 -0
- package/dist/server/index.cjs +994 -0
- package/dist/server/index.cjs.map +1 -0
- package/dist/server/index.d.cts +229 -0
- package/dist/server/index.d.ts +229 -0
- package/dist/server/index.js +951 -0
- package/dist/server/index.js.map +1 -0
- package/dist/styles.css +2111 -0
- package/dist/use-part-DCfFk7kf.d.ts +24 -0
- package/dist/use-part-DgjPBL_O.d.cts +24 -0
- package/package.json +121 -3
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { U as UsePartLocal } from '../use-part-DCfFk7kf.js';
|
|
3
|
+
import '../index-RSj2Rg62.js';
|
|
4
|
+
|
|
5
|
+
/** The account page of `@usethrottle/auth`, drawn with the storefront's theme. */
|
|
6
|
+
type AccountPageProps = UsePartLocal & {
|
|
7
|
+
/**
|
|
8
|
+
* `dashboard` (default): the account for a signed-in shopper, sign-in for a signed-out one.
|
|
9
|
+
* `sign-in` and `sign-up`: that form.
|
|
10
|
+
*/
|
|
11
|
+
view?: 'dashboard' | 'sign-in' | 'sign-up';
|
|
12
|
+
/** Called after a successful sign-in or sign-up. */
|
|
13
|
+
onSuccess?(): void;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The account page: auth's `AccountDashboard`, `SignIn` or `SignUp` under a `ThrottleProvider` keyed by
|
|
17
|
+
* the storefront's publishable key (the `throttlePublishableKey` prop of `StorefrontProvider`, else the
|
|
18
|
+
* Builder's connections). With no key it shows a set-up notice. The storefront's theme reaches the auth
|
|
19
|
+
* components through `appearance`; auth keeps its own `throttle-` classes, so its styles stay its own.
|
|
20
|
+
*/
|
|
21
|
+
declare function AccountPage(props: AccountPageProps): react_jsx_runtime.JSX.Element;
|
|
22
|
+
|
|
23
|
+
export { AccountPage, type AccountPageProps };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useMediaQuery
|
|
4
|
+
} from "../chunk-SV53BRP2.js";
|
|
5
|
+
import {
|
|
6
|
+
useStrings
|
|
7
|
+
} from "../chunk-Q3XFD5UI.js";
|
|
8
|
+
import {
|
|
9
|
+
usePart,
|
|
10
|
+
useStorefront
|
|
11
|
+
} from "../chunk-NNE4FYRT.js";
|
|
12
|
+
|
|
13
|
+
// src/account/AccountPage.tsx
|
|
14
|
+
import {
|
|
15
|
+
AccountDashboard,
|
|
16
|
+
SignedIn,
|
|
17
|
+
SignedOut,
|
|
18
|
+
SignIn,
|
|
19
|
+
SignUp,
|
|
20
|
+
ThrottleProvider
|
|
21
|
+
} from "@usethrottle/auth/components";
|
|
22
|
+
import { AppearanceContext } from "@usethrottle/ui";
|
|
23
|
+
import { useContext, useMemo } from "react";
|
|
24
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
25
|
+
function useAuthAppearance() {
|
|
26
|
+
const ambient = useContext(AppearanceContext);
|
|
27
|
+
const prefersDark = useMediaQuery("(prefers-color-scheme: dark)");
|
|
28
|
+
return useMemo(() => {
|
|
29
|
+
const scheme = ambient?.theme ?? "light";
|
|
30
|
+
const dark = scheme === "dark" || scheme === "auto" && prefersDark;
|
|
31
|
+
const variables = dark ? { ...ambient?.variables, ...ambient?.darkVariables } : { ...ambient?.variables };
|
|
32
|
+
const value = { theme: dark ? "dark" : "light", variables };
|
|
33
|
+
if (ambient?.darkVariables) value.darkVariables = ambient.darkVariables;
|
|
34
|
+
if (ambient?.elements) value.elements = ambient.elements;
|
|
35
|
+
if (ambient?.components) value.components = ambient.components;
|
|
36
|
+
return value;
|
|
37
|
+
}, [ambient, prefersDark]);
|
|
38
|
+
}
|
|
39
|
+
function AccountPage(props) {
|
|
40
|
+
const { view = "dashboard", onSuccess } = props;
|
|
41
|
+
const { throttlePublishableKey } = useStorefront();
|
|
42
|
+
const { t } = useStrings();
|
|
43
|
+
const appearance = useAuthAppearance();
|
|
44
|
+
const root = usePart("account-page", props);
|
|
45
|
+
const title = usePart("account-page-title", props);
|
|
46
|
+
const notice = usePart("account-page-setup-notice", props);
|
|
47
|
+
const noticeTitle = usePart("account-page-setup-title", props);
|
|
48
|
+
const noticeBody = usePart("account-page-setup-body", props);
|
|
49
|
+
if (!throttlePublishableKey) {
|
|
50
|
+
return /* @__PURE__ */ jsxs("section", { ...notice, role: "note", children: [
|
|
51
|
+
/* @__PURE__ */ jsx("h1", { ...noticeTitle, children: t("pages.account.setupTitle") }),
|
|
52
|
+
/* @__PURE__ */ jsx("p", { ...noticeBody, children: t("pages.account.setupBody") })
|
|
53
|
+
] });
|
|
54
|
+
}
|
|
55
|
+
return /* @__PURE__ */ jsx(ThrottleProvider, { publishableKey: throttlePublishableKey, appearance, children: /* @__PURE__ */ jsxs("div", { ...root, "data-view": view, children: [
|
|
56
|
+
/* @__PURE__ */ jsx("h1", { ...title, children: t(view === "sign-in" ? "pages.account.signIn" : view === "sign-up" ? "pages.account.signUp" : "nav.account") }),
|
|
57
|
+
view === "sign-in" ? /* @__PURE__ */ jsx(SignIn, { onSuccess }) : null,
|
|
58
|
+
view === "sign-up" ? /* @__PURE__ */ jsx(SignUp, { onSuccess }) : null,
|
|
59
|
+
view === "dashboard" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
60
|
+
/* @__PURE__ */ jsx(SignedIn, { children: /* @__PURE__ */ jsx(AccountDashboard, {}) }),
|
|
61
|
+
/* @__PURE__ */ jsx(SignedOut, { children: /* @__PURE__ */ jsx(SignIn, { onSuccess }) })
|
|
62
|
+
] }) : null
|
|
63
|
+
] }) });
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
AccountPage
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/account/AccountPage.tsx"],"sourcesContent":["import {\n AccountDashboard,\n SignedIn,\n SignedOut,\n SignIn,\n SignUp,\n ThrottleProvider,\n type ThrottleAppearance as AuthAppearance,\n} from '@usethrottle/auth/components';\nimport { AppearanceContext } from '@usethrottle/ui';\nimport { useContext, useMemo } from 'react';\nimport { useMediaQuery } from '../frame/use-media-query';\nimport { usePart, type UsePartLocal } from '../parts';\nimport { useStorefront } from '../provider/context';\nimport { useStrings } from '../strings';\n\n/** The account page of `@usethrottle/auth`, drawn with the storefront's theme. */\nexport type AccountPageProps = UsePartLocal & {\n /**\n * `dashboard` (default): the account for a signed-in shopper, sign-in for a signed-out one.\n * `sign-in` and `sign-up`: that form.\n */\n view?: 'dashboard' | 'sign-in' | 'sign-up';\n /** Called after a successful sign-in or sign-up. */\n onSuccess?(): void;\n};\n\n/**\n * The storefront's appearance as auth takes it. Auth's components do not read `darkVariables` (it keeps\n * its own dark rule for its default palette), so the scheme is resolved here: the dark palette when the\n * site is dark, or auto and the shopper's system is dark. `darkVariables` is still passed, for the\n * day auth reads it.\n */\nfunction useAuthAppearance(): AuthAppearance {\n const ambient = useContext(AppearanceContext);\n const prefersDark = useMediaQuery('(prefers-color-scheme: dark)');\n return useMemo(() => {\n const scheme = ambient?.theme ?? 'light';\n const dark = scheme === 'dark' || (scheme === 'auto' && prefersDark);\n const variables = dark ? { ...ambient?.variables, ...ambient?.darkVariables } : { ...ambient?.variables };\n const value: Record<string, unknown> = { theme: dark ? 'dark' : 'light', variables };\n if (ambient?.darkVariables) value.darkVariables = ambient.darkVariables;\n if (ambient?.elements) value.elements = ambient.elements;\n if (ambient?.components) value.components = ambient.components;\n return value as AuthAppearance;\n }, [ambient, prefersDark]);\n}\n\n/**\n * The account page: auth's `AccountDashboard`, `SignIn` or `SignUp` under a `ThrottleProvider` keyed by\n * the storefront's publishable key (the `throttlePublishableKey` prop of `StorefrontProvider`, else the\n * Builder's connections). With no key it shows a set-up notice. The storefront's theme reaches the auth\n * components through `appearance`; auth keeps its own `throttle-` classes, so its styles stay its own.\n */\nexport function AccountPage(props: AccountPageProps) {\n const { view = 'dashboard', onSuccess } = props;\n const { throttlePublishableKey } = useStorefront();\n const { t } = useStrings();\n const appearance = useAuthAppearance();\n const root = usePart('account-page', props);\n const title = usePart('account-page-title', props);\n const notice = usePart('account-page-setup-notice', props);\n const noticeTitle = usePart('account-page-setup-title', props);\n const noticeBody = usePart('account-page-setup-body', props);\n\n if (!throttlePublishableKey) {\n return (\n <section {...notice} role=\"note\">\n <h1 {...noticeTitle}>{t('pages.account.setupTitle')}</h1>\n <p {...noticeBody}>{t('pages.account.setupBody')}</p>\n </section>\n );\n }\n return (\n <ThrottleProvider publishableKey={throttlePublishableKey} appearance={appearance}>\n <div {...root} data-view={view}>\n <h1 {...title}>{t(view === 'sign-in' ? 'pages.account.signIn' : view === 'sign-up' ? 'pages.account.signUp' : 'nav.account')}</h1>\n {view === 'sign-in' ? <SignIn onSuccess={onSuccess} /> : null}\n {view === 'sign-up' ? <SignUp onSuccess={onSuccess} /> : null}\n {view === 'dashboard' ? (\n <>\n <SignedIn>\n <AccountDashboard />\n </SignedIn>\n <SignedOut>\n <SignIn onSuccess={onSuccess} />\n </SignedOut>\n </>\n ) : null}\n </div>\n </ThrottleProvider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,yBAAyB;AAClC,SAAS,YAAY,eAAe;AAyD9B,SAaI,UAZF,KADF;AAlCN,SAAS,oBAAoC;AAC3C,QAAM,UAAU,WAAW,iBAAiB;AAC5C,QAAM,cAAc,cAAc,8BAA8B;AAChE,SAAO,QAAQ,MAAM;AACnB,UAAM,SAAS,SAAS,SAAS;AACjC,UAAM,OAAO,WAAW,UAAW,WAAW,UAAU;AACxD,UAAM,YAAY,OAAO,EAAE,GAAG,SAAS,WAAW,GAAG,SAAS,cAAc,IAAI,EAAE,GAAG,SAAS,UAAU;AACxG,UAAM,QAAiC,EAAE,OAAO,OAAO,SAAS,SAAS,UAAU;AACnF,QAAI,SAAS,cAAe,OAAM,gBAAgB,QAAQ;AAC1D,QAAI,SAAS,SAAU,OAAM,WAAW,QAAQ;AAChD,QAAI,SAAS,WAAY,OAAM,aAAa,QAAQ;AACpD,WAAO;AAAA,EACT,GAAG,CAAC,SAAS,WAAW,CAAC;AAC3B;AAQO,SAAS,YAAY,OAAyB;AACnD,QAAM,EAAE,OAAO,aAAa,UAAU,IAAI;AAC1C,QAAM,EAAE,uBAAuB,IAAI,cAAc;AACjD,QAAM,EAAE,EAAE,IAAI,WAAW;AACzB,QAAM,aAAa,kBAAkB;AACrC,QAAM,OAAO,QAAQ,gBAAgB,KAAK;AAC1C,QAAM,QAAQ,QAAQ,sBAAsB,KAAK;AACjD,QAAM,SAAS,QAAQ,6BAA6B,KAAK;AACzD,QAAM,cAAc,QAAQ,4BAA4B,KAAK;AAC7D,QAAM,aAAa,QAAQ,2BAA2B,KAAK;AAE3D,MAAI,CAAC,wBAAwB;AAC3B,WACE,qBAAC,aAAS,GAAG,QAAQ,MAAK,QACxB;AAAA,0BAAC,QAAI,GAAG,aAAc,YAAE,0BAA0B,GAAE;AAAA,MACpD,oBAAC,OAAG,GAAG,YAAa,YAAE,yBAAyB,GAAE;AAAA,OACnD;AAAA,EAEJ;AACA,SACE,oBAAC,oBAAiB,gBAAgB,wBAAwB,YACxD,+BAAC,SAAK,GAAG,MAAM,aAAW,MACxB;AAAA,wBAAC,QAAI,GAAG,OAAQ,YAAE,SAAS,YAAY,yBAAyB,SAAS,YAAY,yBAAyB,aAAa,GAAE;AAAA,IAC5H,SAAS,YAAY,oBAAC,UAAO,WAAsB,IAAK;AAAA,IACxD,SAAS,YAAY,oBAAC,UAAO,WAAsB,IAAK;AAAA,IACxD,SAAS,cACR,iCACE;AAAA,0BAAC,YACC,8BAAC,oBAAiB,GACpB;AAAA,MACA,oBAAC,aACC,8BAAC,UAAO,WAAsB,GAChC;AAAA,OACF,IACE;AAAA,KACN,GACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
3
|
+
|
|
4
|
+
// src/provider/cart-drawer.ts
|
|
5
|
+
var _react = require('react');
|
|
6
|
+
var CartDrawerContext = _react.createContext.call(void 0, { open: false, setOpen: () => {
|
|
7
|
+
} });
|
|
8
|
+
function useCartDrawer() {
|
|
9
|
+
return _react.useContext.call(void 0, CartDrawerContext);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
exports.CartDrawerContext = CartDrawerContext; exports.useCartDrawer = useCartDrawer;
|
|
16
|
+
//# sourceMappingURL=chunk-2LCPIY2P.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/app-throttle/app-throttle/packages/storefront-react/dist/chunk-2LCPIY2P.cjs","../src/provider/cart-drawer.ts"],"names":[],"mappings":"AAAA,qFAAY;AACZ;AACA;ACFA,8BAA0C;AAInC,IAAM,kBAAA,EAAoB,kCAAA,EAAiC,IAAA,EAAM,KAAA,EAAO,OAAA,EAAS,CAAA,EAAA,GAAM;AAAC,EAAE,CAAC,CAAA;AAG3F,SAAS,aAAA,CAAA,EAAiC;AAC/C,EAAA,OAAO,+BAAA,iBAA4B,CAAA;AACrC;ADAA;AACA;AACE;AACA;AACF,qFAAC","file":"/home/runner/work/app-throttle/app-throttle/packages/storefront-react/dist/chunk-2LCPIY2P.cjs","sourcesContent":[null,"import { createContext, useContext } from 'react';\n\nexport type CartDrawerState = { open: boolean; setOpen(open: boolean): void };\n\nexport const CartDrawerContext = createContext<CartDrawerState>({ open: false, setOpen: () => {} });\n\n/** Whether the cart drawer is open, and a way to change it. `StorefrontProvider` owns the state. */\nexport function useCartDrawer(): CartDrawerState {\n return useContext(CartDrawerContext);\n}\n"]}
|