tempest-react-sdk 0.64.0 → 0.66.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/README.md +4 -4
- package/dist/auth/create-tempest-auth.cjs +1 -1
- package/dist/auth/create-tempest-auth.cjs.map +1 -1
- package/dist/auth/create-tempest-auth.js +31 -36
- package/dist/auth/create-tempest-auth.js.map +1 -1
- package/dist/components/Command/Command.module.cjs.map +1 -1
- package/dist/components/Command/Command.module.js.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.module.cjs.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.module.js.map +1 -1
- package/dist/components/DataTable/DataTable.cjs +1 -1
- package/dist/components/DataTable/DataTable.cjs.map +1 -1
- package/dist/components/DataTable/DataTable.js +1 -0
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/components/DataTable/use-dev-warnings.cjs +1 -1
- package/dist/components/DataTable/use-dev-warnings.cjs.map +1 -1
- package/dist/components/DataTable/use-dev-warnings.js +4 -3
- package/dist/components/DataTable/use-dev-warnings.js.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.module.cjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.module.js.map +1 -1
- package/dist/components/InstallBanner/InstallBanner.cjs +1 -1
- package/dist/components/InstallBanner/InstallBanner.cjs.map +1 -1
- package/dist/components/InstallBanner/InstallBanner.js +62 -37
- package/dist/components/InstallBanner/InstallBanner.js.map +1 -1
- package/dist/components/InstallBanner/InstallBanner.module.cjs +1 -1
- package/dist/components/InstallBanner/InstallBanner.module.cjs.map +1 -1
- package/dist/components/InstallBanner/InstallBanner.module.js +4 -3
- package/dist/components/InstallBanner/InstallBanner.module.js.map +1 -1
- package/dist/components/InstallButton/InstallButton.cjs +1 -1
- package/dist/components/InstallButton/InstallButton.cjs.map +1 -1
- package/dist/components/InstallButton/InstallButton.js +34 -10
- package/dist/components/InstallButton/InstallButton.js.map +1 -1
- package/dist/components/InstallButton/InstallButton.module.cjs +3 -0
- package/dist/components/InstallButton/InstallButton.module.cjs.map +1 -0
- package/dist/components/InstallButton/InstallButton.module.js +10 -0
- package/dist/components/InstallButton/InstallButton.module.js.map +1 -0
- package/dist/components/InstallButton/install-hints.cjs +2 -0
- package/dist/components/InstallButton/install-hints.cjs.map +1 -0
- package/dist/components/InstallButton/install-hints.js +32 -0
- package/dist/components/InstallButton/install-hints.js.map +1 -0
- package/dist/components/SegmentedControl/SegmentedControl.module.cjs.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.module.js.map +1 -1
- package/dist/components/Select/Select.cjs +1 -1
- package/dist/components/Select/Select.cjs.map +1 -1
- package/dist/components/Select/Select.js +43 -40
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Select/Select.module.cjs +1 -1
- package/dist/components/Select/Select.module.cjs.map +1 -1
- package/dist/components/Select/Select.module.js +5 -3
- package/dist/components/Select/Select.module.js.map +1 -1
- package/dist/hooks/use-install-prompt.cjs +1 -1
- package/dist/hooks/use-install-prompt.cjs.map +1 -1
- package/dist/hooks/use-install-prompt.js +9 -2
- package/dist/hooks/use-install-prompt.js.map +1 -1
- package/dist/http/api-client.cjs +1 -1
- package/dist/http/api-client.cjs.map +1 -1
- package/dist/http/api-client.js +93 -85
- package/dist/http/api-client.js.map +1 -1
- package/dist/http/credential-scope.cjs +2 -0
- package/dist/http/credential-scope.cjs.map +1 -0
- package/dist/http/credential-scope.js +23 -0
- package/dist/http/credential-scope.js.map +1 -0
- package/dist/http/decode-response.cjs +2 -0
- package/dist/http/decode-response.cjs.map +1 -0
- package/dist/http/decode-response.js +28 -0
- package/dist/http/decode-response.js.map +1 -0
- package/dist/http/resumable-upload.cjs +1 -1
- package/dist/http/resumable-upload.cjs.map +1 -1
- package/dist/http/resumable-upload.js +121 -120
- package/dist/http/resumable-upload.js.map +1 -1
- package/dist/http/upload-with-progress.cjs +1 -1
- package/dist/http/upload-with-progress.cjs.map +1 -1
- package/dist/http/upload-with-progress.js +35 -34
- package/dist/http/upload-with-progress.js.map +1 -1
- package/dist/styles/InstallButton.css +2 -0
- package/dist/styles/actions.css +6 -1
- package/dist/styles/advanced.css +2 -2
- package/dist/styles/component/Command.css +1 -1
- package/dist/styles/component/ContextMenu.css +1 -1
- package/dist/styles/component/DropdownMenu.css +1 -1
- package/dist/styles/component/InstallBanner.css +2 -0
- package/dist/styles/component/InstallButton.css +4 -0
- package/dist/styles/component/SegmentedControl.css +1 -1
- package/dist/styles/component/Select.css +4 -0
- package/dist/styles/core.css +2 -2
- package/dist/styles/forms.css +4 -0
- package/dist/styles/manifest.json +2 -1
- package/dist/styles/navigation.css +1 -1
- package/dist/styles/tokens.css +2 -2
- package/dist/styles.css +1 -1
- package/dist/tempest-react-sdk.cjs +1 -1
- package/dist/tempest-react-sdk.d.ts +473 -40
- package/dist/tempest-react-sdk.js +321 -318
- package/dist/theme/ThemeProvider.cjs +1 -1
- package/dist/theme/ThemeProvider.cjs.map +1 -1
- package/dist/theme/ThemeProvider.js +40 -45
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/dist/theme/create-theme.cjs +1 -1
- package/dist/theme/create-theme.cjs.map +1 -1
- package/dist/theme/create-theme.js +1 -1
- package/dist/theme/create-theme.js.map +1 -1
- package/dist/theme/initial-theme.cjs +2 -2
- package/dist/theme/initial-theme.cjs.map +1 -1
- package/dist/theme/initial-theme.js +7 -12
- package/dist/theme/initial-theme.js.map +1 -1
- package/dist/utils/absent.cjs +2 -0
- package/dist/utils/absent.cjs.map +1 -0
- package/dist/utils/absent.js +12 -0
- package/dist/utils/absent.js.map +1 -0
- package/dist/utils/format.cjs +1 -1
- package/dist/utils/format.cjs.map +1 -1
- package/dist/utils/format.js +42 -35
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/numbers.cjs +1 -1
- package/dist/utils/numbers.cjs.map +1 -1
- package/dist/utils/numbers.js +14 -12
- package/dist/utils/numbers.js.map +1 -1
- package/dist/utils/storage.cjs +1 -1
- package/dist/utils/storage.cjs.map +1 -1
- package/dist/utils/storage.js +13 -0
- package/dist/utils/storage.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../Button/Button.cjs"),
|
|
1
|
+
const e=require("../../utils/cn.cjs"),t=require("../Button/Button.cjs"),n=require("../../hooks/use-install-prompt.cjs"),r=require("./install-hints.cjs"),i=require("./InstallButton.module.cjs");let a=require("react"),o=require("react/jsx-runtime");function s({label:s=`Instalar app`,hintLabel:c=`Como instalar`,onResult:l,renderHint:u=r.defaultInstallHint,manualFallbackDelayMs:d,wrapperClassName:f,...p}){let{method:m,openInChromeIntent:h,install:g}=n.useInstallPrompt({manualFallbackDelayMs:d}),[_,v]=(0,a.useState)(!1),y=(0,a.useId)();if(m===`none`)return null;if(m===`native`)return(0,o.jsx)(t.Button,{onClick:async()=>{let e=await g();l?.(e?`accepted`:`dismissed`)},...p,children:s});let b=u({method:m,openInChromeIntent:h});return(0,o.jsxs)(`div`,{className:e.cn(i.default.wrapper,f),children:[(0,o.jsx)(t.Button,{"aria-expanded":_,"aria-controls":_&&b?y:void 0,onClick:()=>v(e=>!e),...p,children:c}),_&&b?(0,o.jsx)(`p`,{className:i.default.hint,id:y,children:b}):null]})}exports.InstallButton=s;
|
|
2
2
|
//# sourceMappingURL=InstallButton.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstallButton.cjs","names":[],"sources":["../../../src/components/InstallButton/InstallButton.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { Button, type ButtonProps } from \"@/components/Button\";\nimport {
|
|
1
|
+
{"version":3,"file":"InstallButton.cjs","names":[],"sources":["../../../src/components/InstallButton/InstallButton.tsx"],"sourcesContent":["import { useId, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { Button, type ButtonProps } from \"@/components/Button\";\nimport { useInstallPrompt } from \"@/hooks/use-install-prompt\";\nimport { cn } from \"@/utils/cn\";\nimport { defaultInstallHint, type RenderInstallHint } from \"./install-hints\";\nimport styles from \"./InstallButton.module.css\";\n\nexport type InstallOutcome = \"accepted\" | \"dismissed\" | \"unsupported\";\n\nexport interface InstallButtonProps extends Omit<ButtonProps, \"onClick\" | \"children\"> {\n /** Button label. Default `\"Instalar app\"`. */\n label?: ReactNode;\n /**\n * Label used when the browser cannot be prompted and the button reveals the\n * manual instruction instead. Default `\"Como instalar\"`.\n */\n hintLabel?: ReactNode;\n /** Called with the user's choice after the install prompt resolves. */\n onResult?: (outcome: InstallOutcome) => void;\n /**\n * Replaces the instruction shown for the `\"ios\"` and `\"manual\"` methods.\n *\n * The default copy is in PT-BR and names the real menu entries. Pass this to\n * translate it, to shorten it, or to point at a screenshot of your own.\n */\n renderHint?: RenderInstallHint;\n /**\n * How long, in ms, to wait for `beforeinstallprompt` before falling back to\n * the manual instruction. Forwarded to {@link useInstallPrompt}; defaults to\n * 3000 there.\n */\n manualFallbackDelayMs?: number;\n /** Class applied to the wrapper that holds the button and the instruction. */\n wrapperClassName?: string;\n}\n\n/**\n * Button wired to PWA installation, through {@link useInstallPrompt}.\n *\n * Where the browser fires `beforeinstallprompt`, the click installs. Where it\n * does not — iOS Safari, and the Android Chromium forks (Mi Browser, UC, Opera\n * Mini, Huawei) that strip the API — the click reveals the instruction for that\n * platform instead of the button disappearing.\n *\n * That disappearance was the defect: the component was built on\n * `useBeforeInstallPrompt`, so it rendered `null` exactly where the user needs\n * the most help, and every app re-implemented the iOS and manual paths locally.\n * Nothing renders only when there is genuinely nothing to offer — already\n * installed, running standalone, or inside the decline cooldown.\n *\n * Inherits every {@link Button} prop (`variant`, `size`, `leftIcon`, …).\n *\n * @example\n * <InstallButton variant=\"primary\" leftIcon={<Download />} />\n *\n * @example\n * <InstallButton renderHint={({ method }) => (method === \"ios\" ? <IOSSteps /> : <MenuSteps />)} />\n */\nexport function InstallButton({\n label = \"Instalar app\",\n hintLabel = \"Como instalar\",\n onResult,\n renderHint = defaultInstallHint,\n manualFallbackDelayMs,\n wrapperClassName,\n ...props\n}: InstallButtonProps) {\n const { method, openInChromeIntent, install } = useInstallPrompt({ manualFallbackDelayMs });\n const [hintOpen, setHintOpen] = useState(false);\n const hintId = useId();\n\n if (method === \"none\") return null;\n\n if (method === \"native\") {\n return (\n <Button\n onClick={async () => {\n const accepted = await install();\n onResult?.(accepted ? \"accepted\" : \"dismissed\");\n }}\n {...props}\n >\n {label}\n </Button>\n );\n }\n\n const hint = renderHint({ method, openInChromeIntent });\n\n return (\n <div className={cn(styles.wrapper, wrapperClassName)}>\n <Button\n aria-expanded={hintOpen}\n aria-controls={hintOpen && hint ? hintId : undefined}\n onClick={() => setHintOpen((open) => !open)}\n {...props}\n >\n {hintLabel}\n </Button>\n {hintOpen && hint ? (\n <p className={styles.hint} id={hintId}>\n {hint}\n </p>\n ) : null}\n </div>\n );\n}\n"],"mappings":"uPA2DA,SAAgB,EAAc,CAC1B,QAAQ,eACR,YAAY,gBACZ,WACA,aAAa,EAAA,mBACb,wBACA,mBACA,GAAG,GACgB,CACnB,GAAM,CAAE,SAAQ,qBAAoB,WAAY,EAAA,iBAAiB,CAAE,uBAAsB,CAAC,EACpF,CAAC,EAAU,IAAA,EAAe,EAAA,SAAA,CAAS,EAAK,EACxC,GAAA,EAAS,EAAA,MAAA,CAAM,EAErB,GAAI,IAAW,OAAQ,OAAO,KAE9B,GAAI,IAAW,SACX,OACI,EAAA,EAAA,IAAA,CAAC,EAAA,OAAD,CACI,QAAS,SAAY,CACjB,IAAM,EAAW,MAAM,EAAQ,EAC/B,IAAW,EAAW,WAAa,WAAW,CAClD,EACA,GAAI,EAEH,SAAA,CACG,CAAA,EAIhB,IAAM,EAAO,EAAW,CAAE,SAAQ,oBAAmB,CAAC,EAEtD,OACI,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAW,EAAA,GAAG,EAAA,QAAO,QAAS,CAAgB,EAAnD,SAAA,EACI,EAAA,EAAA,IAAA,CAAC,EAAA,OAAD,CACI,gBAAe,EACf,gBAAe,GAAY,EAAO,EAAS,IAAA,GAC3C,YAAe,EAAa,GAAS,CAAC,CAAI,EAC1C,GAAI,EAEH,SAAA,CACG,CAAA,EACP,GAAY,GACT,EAAA,EAAA,IAAA,CAAC,IAAD,CAAG,UAAW,EAAA,QAAO,KAAM,GAAI,EAC1B,SAAA,CACF,CAAA,EACH,IACH,GAEb"}
|
|
@@ -1,18 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { cn as e } from "../../utils/cn.js";
|
|
2
|
+
import { Button as t } from "../Button/Button.js";
|
|
3
|
+
import { useInstallPrompt as n } from "../../hooks/use-install-prompt.js";
|
|
4
|
+
import { defaultInstallHint as r } from "./install-hints.js";
|
|
5
|
+
import i from "./InstallButton.module.js";
|
|
6
|
+
import { useId as a, useState as o } from "react";
|
|
7
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
4
8
|
//#region src/components/InstallButton/InstallButton.tsx
|
|
5
|
-
function
|
|
6
|
-
let {
|
|
7
|
-
|
|
9
|
+
function l({ label: l = "Instalar app", hintLabel: u = "Como instalar", onResult: d, renderHint: f = r, manualFallbackDelayMs: p, wrapperClassName: m, ...h }) {
|
|
10
|
+
let { method: g, openInChromeIntent: _, install: v } = n({ manualFallbackDelayMs: p }), [y, b] = o(!1), x = a();
|
|
11
|
+
if (g === "none") return null;
|
|
12
|
+
if (g === "native") return /* @__PURE__ */ s(t, {
|
|
8
13
|
onClick: async () => {
|
|
9
|
-
|
|
14
|
+
let e = await v();
|
|
15
|
+
d?.(e ? "accepted" : "dismissed");
|
|
10
16
|
},
|
|
11
|
-
...
|
|
12
|
-
children:
|
|
17
|
+
...h,
|
|
18
|
+
children: l
|
|
19
|
+
});
|
|
20
|
+
let S = f({
|
|
21
|
+
method: g,
|
|
22
|
+
openInChromeIntent: _
|
|
23
|
+
});
|
|
24
|
+
return /* @__PURE__ */ c("div", {
|
|
25
|
+
className: e(i.wrapper, m),
|
|
26
|
+
children: [/* @__PURE__ */ s(t, {
|
|
27
|
+
"aria-expanded": y,
|
|
28
|
+
"aria-controls": y && S ? x : void 0,
|
|
29
|
+
onClick: () => b((e) => !e),
|
|
30
|
+
...h,
|
|
31
|
+
children: u
|
|
32
|
+
}), y && S ? /* @__PURE__ */ s("p", {
|
|
33
|
+
className: i.hint,
|
|
34
|
+
id: x,
|
|
35
|
+
children: S
|
|
36
|
+
}) : null]
|
|
13
37
|
});
|
|
14
38
|
}
|
|
15
39
|
//#endregion
|
|
16
|
-
export {
|
|
40
|
+
export { l as InstallButton };
|
|
17
41
|
|
|
18
42
|
//# sourceMappingURL=InstallButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstallButton.js","names":[],"sources":["../../../src/components/InstallButton/InstallButton.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { Button, type ButtonProps } from \"@/components/Button\";\nimport {
|
|
1
|
+
{"version":3,"file":"InstallButton.js","names":[],"sources":["../../../src/components/InstallButton/InstallButton.tsx"],"sourcesContent":["import { useId, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { Button, type ButtonProps } from \"@/components/Button\";\nimport { useInstallPrompt } from \"@/hooks/use-install-prompt\";\nimport { cn } from \"@/utils/cn\";\nimport { defaultInstallHint, type RenderInstallHint } from \"./install-hints\";\nimport styles from \"./InstallButton.module.css\";\n\nexport type InstallOutcome = \"accepted\" | \"dismissed\" | \"unsupported\";\n\nexport interface InstallButtonProps extends Omit<ButtonProps, \"onClick\" | \"children\"> {\n /** Button label. Default `\"Instalar app\"`. */\n label?: ReactNode;\n /**\n * Label used when the browser cannot be prompted and the button reveals the\n * manual instruction instead. Default `\"Como instalar\"`.\n */\n hintLabel?: ReactNode;\n /** Called with the user's choice after the install prompt resolves. */\n onResult?: (outcome: InstallOutcome) => void;\n /**\n * Replaces the instruction shown for the `\"ios\"` and `\"manual\"` methods.\n *\n * The default copy is in PT-BR and names the real menu entries. Pass this to\n * translate it, to shorten it, or to point at a screenshot of your own.\n */\n renderHint?: RenderInstallHint;\n /**\n * How long, in ms, to wait for `beforeinstallprompt` before falling back to\n * the manual instruction. Forwarded to {@link useInstallPrompt}; defaults to\n * 3000 there.\n */\n manualFallbackDelayMs?: number;\n /** Class applied to the wrapper that holds the button and the instruction. */\n wrapperClassName?: string;\n}\n\n/**\n * Button wired to PWA installation, through {@link useInstallPrompt}.\n *\n * Where the browser fires `beforeinstallprompt`, the click installs. Where it\n * does not — iOS Safari, and the Android Chromium forks (Mi Browser, UC, Opera\n * Mini, Huawei) that strip the API — the click reveals the instruction for that\n * platform instead of the button disappearing.\n *\n * That disappearance was the defect: the component was built on\n * `useBeforeInstallPrompt`, so it rendered `null` exactly where the user needs\n * the most help, and every app re-implemented the iOS and manual paths locally.\n * Nothing renders only when there is genuinely nothing to offer — already\n * installed, running standalone, or inside the decline cooldown.\n *\n * Inherits every {@link Button} prop (`variant`, `size`, `leftIcon`, …).\n *\n * @example\n * <InstallButton variant=\"primary\" leftIcon={<Download />} />\n *\n * @example\n * <InstallButton renderHint={({ method }) => (method === \"ios\" ? <IOSSteps /> : <MenuSteps />)} />\n */\nexport function InstallButton({\n label = \"Instalar app\",\n hintLabel = \"Como instalar\",\n onResult,\n renderHint = defaultInstallHint,\n manualFallbackDelayMs,\n wrapperClassName,\n ...props\n}: InstallButtonProps) {\n const { method, openInChromeIntent, install } = useInstallPrompt({ manualFallbackDelayMs });\n const [hintOpen, setHintOpen] = useState(false);\n const hintId = useId();\n\n if (method === \"none\") return null;\n\n if (method === \"native\") {\n return (\n <Button\n onClick={async () => {\n const accepted = await install();\n onResult?.(accepted ? \"accepted\" : \"dismissed\");\n }}\n {...props}\n >\n {label}\n </Button>\n );\n }\n\n const hint = renderHint({ method, openInChromeIntent });\n\n return (\n <div className={cn(styles.wrapper, wrapperClassName)}>\n <Button\n aria-expanded={hintOpen}\n aria-controls={hintOpen && hint ? hintId : undefined}\n onClick={() => setHintOpen((open) => !open)}\n {...props}\n >\n {hintLabel}\n </Button>\n {hintOpen && hint ? (\n <p className={styles.hint} id={hintId}>\n {hint}\n </p>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;AA2DA,SAAgB,EAAc,EAC1B,WAAQ,gBACR,eAAY,iBACZ,aACA,gBAAa,GACb,0BACA,qBACA,GAAG,KACgB;CACnB,IAAM,EAAE,WAAQ,uBAAoB,eAAY,EAAiB,EAAE,yBAAsB,CAAC,GACpF,CAAC,GAAU,KAAe,EAAS,EAAK,GACxC,IAAS,EAAM;CAErB,IAAI,MAAW,QAAQ,OAAO;CAE9B,IAAI,MAAW,UACX,OACI,kBAAC,GAAD;EACI,SAAS,YAAY;GACjB,IAAM,IAAW,MAAM,EAAQ;GAC/B,IAAW,IAAW,aAAa,WAAW;EAClD;EACA,GAAI;EAEH,UAAA;CACG,CAAA;CAIhB,IAAM,IAAO,EAAW;EAAE;EAAQ;CAAmB,CAAC;CAEtD,OACI,kBAAC,OAAD;EAAK,WAAW,EAAG,EAAO,SAAS,CAAgB;EAAnD,UAAA,CACI,kBAAC,GAAD;GACI,iBAAe;GACf,iBAAe,KAAY,IAAO,IAAS,KAAA;GAC3C,eAAe,GAAa,MAAS,CAAC,CAAI;GAC1C,GAAI;GAEH,UAAA;EACG,CAAA,GACP,KAAY,IACT,kBAAC,KAAD;GAAG,WAAW,EAAO;GAAM,IAAI;GAC1B,UAAA;EACF,CAAA,IACH,IACH;;AAEb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InstallButton.module.cjs","names":[],"sources":["../../../src/components/InstallButton/InstallButton.module.css"],"sourcesContent":[".wrapper {\n display: inline-flex;\n flex-direction: column;\n align-items: flex-start;\n gap: var(--tempest-space-2);\n font-family: var(--tempest-font-sans);\n}\n\n.hint {\n margin: 0;\n max-width: 36ch;\n color: var(--tempest-text-muted);\n font-size: var(--tempest-text-sm);\n line-height: var(--tempest-leading-snug);\n}\n\n.hint a {\n color: var(--tempest-primary);\n}\n"],"mappings":";"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "../../styles/component/InstallButton.css";
|
|
2
|
+
//#region src/components/InstallButton/InstallButton.module.css
|
|
3
|
+
var e = "tempest_wrapper_M6K7s", t = "tempest_hint_4lawL", n = {
|
|
4
|
+
wrapper: e,
|
|
5
|
+
hint: t
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { n as default, t as hint, e as wrapper };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=InstallButton.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InstallButton.module.js","names":[],"sources":["../../../src/components/InstallButton/InstallButton.module.css"],"sourcesContent":[".wrapper {\n display: inline-flex;\n flex-direction: column;\n align-items: flex-start;\n gap: var(--tempest-space-2);\n font-family: var(--tempest-font-sans);\n}\n\n.hint {\n margin: 0;\n max-width: 36ch;\n color: var(--tempest-text-muted);\n font-size: var(--tempest-text-sm);\n line-height: var(--tempest-leading-snug);\n}\n\n.hint a {\n color: var(--tempest-primary);\n}\n"],"mappings":";"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
let e=require("react/jsx-runtime");function t({method:t,openInChromeIntent:n}){return t===`ios`?(0,e.jsxs)(e.Fragment,{children:[`Toque em `,(0,e.jsx)(`strong`,{children:`Compartilhar`}),` e escolha`,` `,(0,e.jsx)(`strong`,{children:`Adicionar à Tela de Início`}),`.`]}):t===`manual`?(0,e.jsxs)(e.Fragment,{children:[`Abra o menu do navegador (`,(0,e.jsx)(`strong`,{children:`⋮`}),`) e escolha`,` `,(0,e.jsx)(`strong`,{children:`Instalar app`}),`.`,n?(0,e.jsxs)(e.Fragment,{children:[` `,`Se não houver essa opção, `,(0,e.jsx)(`a`,{href:n,children:`abra no Chrome`}),`.`]}):null]}):null}exports.defaultInstallHint=t;
|
|
2
|
+
//# sourceMappingURL=install-hints.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-hints.cjs","names":[],"sources":["../../../src/components/InstallButton/install-hints.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\n\nimport type { InstallMethod } from \"@/hooks/use-install-prompt\";\n\n/** What an install affordance needs to render the instruction for a method. */\nexport interface InstallHintInput {\n /** The strategy `useInstallPrompt` resolved. */\n method: InstallMethod;\n /** An `intent://` URL that re-opens the page in Chrome on Android, if any. */\n openInChromeIntent: string | null;\n}\n\n/** Renders the instruction shown when the browser has no install prompt. */\nexport type RenderInstallHint = (input: InstallHintInput) => ReactNode;\n\n/**\n * The default instruction for a browser that cannot be prompted.\n *\n * Written out rather than left to the app because every app wrote the same two\n * sentences, and getting them wrong is invisible: an iOS user who is told to\n * look for an \"Install\" menu never finds one, because Safari puts it behind the\n * Share sheet.\n *\n * On an Android fork the copy also offers the `intent://` link the SDK already\n * builds — reopening the page in Chrome is the only path that reaches a real\n * install on a browser whose menu has no install entry at all.\n *\n * @param input - The resolved method and the optional Chrome intent.\n * @returns The instruction, or `null` when the method needs none.\n */\nexport function defaultInstallHint({ method, openInChromeIntent }: InstallHintInput): ReactNode {\n if (method === \"ios\") {\n return (\n <>\n Toque em <strong>Compartilhar</strong> e escolha{\" \"}\n <strong>Adicionar à Tela de Início</strong>.\n </>\n );\n }\n if (method === \"manual\") {\n return (\n <>\n Abra o menu do navegador (<strong>⋮</strong>) e escolha{\" \"}\n <strong>Instalar app</strong>.\n {openInChromeIntent ? (\n <>\n {\" \"}\n Se não houver essa opção, <a href={openInChromeIntent}>abra no Chrome</a>.\n </>\n ) : null}\n </>\n );\n }\n return null;\n}\n"],"mappings":"mCA8BA,SAAgB,EAAmB,CAAE,SAAQ,sBAAmD,CAuB5F,OAtBI,IAAW,OAEP,EAAA,EAAA,KAAA,CAAA,EAAA,SAAA,CAAA,SAAA,CAAE,aACW,EAAA,EAAA,IAAA,CAAC,SAAD,CAAA,SAAQ,cAAoB,CAAA,EAAC,aAAW,KACjD,EAAA,EAAA,IAAA,CAAC,SAAD,CAAA,SAAQ,4BAAkC,CAAA,EAAC,GAC7C,CAAA,CAAA,EAGN,IAAW,UAEP,EAAA,EAAA,KAAA,CAAA,EAAA,SAAA,CAAA,SAAA,CAAE,8BAC4B,EAAA,EAAA,IAAA,CAAC,SAAD,CAAA,SAAQ,GAAS,CAAA,EAAC,cAAY,KACxD,EAAA,EAAA,IAAA,CAAC,SAAD,CAAA,SAAQ,cAAoB,CAAA,EAAC,IAC5B,GACG,EAAA,EAAA,KAAA,CAAA,EAAA,SAAA,CAAA,SAAA,CACK,IAAI,8BACqB,EAAA,EAAA,IAAA,CAAC,IAAD,CAAG,KAAM,EAAoB,SAAA,gBAAiB,CAAA,EAAC,GAC3E,CAAA,CAAA,EACF,IACN,CAAA,CAAA,EAGH,IACX"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Fragment as e, jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
2
|
+
//#region src/components/InstallButton/install-hints.tsx
|
|
3
|
+
function r({ method: r, openInChromeIntent: i }) {
|
|
4
|
+
return r === "ios" ? /* @__PURE__ */ n(e, { children: [
|
|
5
|
+
"Toque em ",
|
|
6
|
+
/* @__PURE__ */ t("strong", { children: "Compartilhar" }),
|
|
7
|
+
" e escolha",
|
|
8
|
+
" ",
|
|
9
|
+
/* @__PURE__ */ t("strong", { children: "Adicionar à Tela de Início" }),
|
|
10
|
+
"."
|
|
11
|
+
] }) : r === "manual" ? /* @__PURE__ */ n(e, { children: [
|
|
12
|
+
"Abra o menu do navegador (",
|
|
13
|
+
/* @__PURE__ */ t("strong", { children: "⋮" }),
|
|
14
|
+
") e escolha",
|
|
15
|
+
" ",
|
|
16
|
+
/* @__PURE__ */ t("strong", { children: "Instalar app" }),
|
|
17
|
+
".",
|
|
18
|
+
i ? /* @__PURE__ */ n(e, { children: [
|
|
19
|
+
" ",
|
|
20
|
+
"Se não houver essa opção, ",
|
|
21
|
+
/* @__PURE__ */ t("a", {
|
|
22
|
+
href: i,
|
|
23
|
+
children: "abra no Chrome"
|
|
24
|
+
}),
|
|
25
|
+
"."
|
|
26
|
+
] }) : null
|
|
27
|
+
] }) : null;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { r as defaultInstallHint };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=install-hints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-hints.js","names":[],"sources":["../../../src/components/InstallButton/install-hints.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\n\nimport type { InstallMethod } from \"@/hooks/use-install-prompt\";\n\n/** What an install affordance needs to render the instruction for a method. */\nexport interface InstallHintInput {\n /** The strategy `useInstallPrompt` resolved. */\n method: InstallMethod;\n /** An `intent://` URL that re-opens the page in Chrome on Android, if any. */\n openInChromeIntent: string | null;\n}\n\n/** Renders the instruction shown when the browser has no install prompt. */\nexport type RenderInstallHint = (input: InstallHintInput) => ReactNode;\n\n/**\n * The default instruction for a browser that cannot be prompted.\n *\n * Written out rather than left to the app because every app wrote the same two\n * sentences, and getting them wrong is invisible: an iOS user who is told to\n * look for an \"Install\" menu never finds one, because Safari puts it behind the\n * Share sheet.\n *\n * On an Android fork the copy also offers the `intent://` link the SDK already\n * builds — reopening the page in Chrome is the only path that reaches a real\n * install on a browser whose menu has no install entry at all.\n *\n * @param input - The resolved method and the optional Chrome intent.\n * @returns The instruction, or `null` when the method needs none.\n */\nexport function defaultInstallHint({ method, openInChromeIntent }: InstallHintInput): ReactNode {\n if (method === \"ios\") {\n return (\n <>\n Toque em <strong>Compartilhar</strong> e escolha{\" \"}\n <strong>Adicionar à Tela de Início</strong>.\n </>\n );\n }\n if (method === \"manual\") {\n return (\n <>\n Abra o menu do navegador (<strong>⋮</strong>) e escolha{\" \"}\n <strong>Instalar app</strong>.\n {openInChromeIntent ? (\n <>\n {\" \"}\n Se não houver essa opção, <a href={openInChromeIntent}>abra no Chrome</a>.\n </>\n ) : null}\n </>\n );\n }\n return null;\n}\n"],"mappings":";;AA8BA,SAAgB,EAAmB,EAAE,WAAQ,yBAAmD;CAuB5F,OAtBI,MAAW,QAEP,kBAAA,GAAA,EAAA,UAAA;EAAE;EACW,kBAAC,UAAD,EAAA,UAAQ,eAAoB,CAAA;EAAC;EAAW;EACjD,kBAAC,UAAD,EAAA,UAAQ,6BAAkC,CAAA;EAAC;CAC7C,EAAA,CAAA,IAGN,MAAW,WAEP,kBAAA,GAAA,EAAA,UAAA;EAAE;EAC4B,kBAAC,UAAD,EAAA,UAAQ,IAAS,CAAA;EAAC;EAAY;EACxD,kBAAC,UAAD,EAAA,UAAQ,eAAoB,CAAA;EAAC;EAC5B,IACG,kBAAA,GAAA,EAAA,UAAA;GACK;GAAI;GACqB,kBAAC,KAAD;IAAG,MAAM;IAAoB,UAAA;GAAiB,CAAA;GAAC;EAC3E,EAAA,CAAA,IACF;CACN,EAAA,CAAA,IAGH;AACX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl.module.cjs","names":[],"sources":["../../../src/components/SegmentedControl/SegmentedControl.module.css"],"sourcesContent":[".group {\n display: inline-flex;\n background: var(--tempest-surface-2);\n border-radius: var(--tempest-radius-md);\n padding: 2px;\n font-family: var(--tempest-font-sans);\n gap: 0;\n}\n\n.group.fullWidth {\n display: flex;\n width: 100%;\n}\n\n.segment {\n flex: 1 1 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: var(--tempest-space-1);\n padding: 6px 12px;\n border: 0;\n background: transparent;\n color: var(--tempest-text-muted);\n cursor: pointer;\n border-radius: calc(var(--tempest-radius-md) - 2px);\n font-weight: var(--tempest-weight-medium);\n transition:\n background var(--tempest-duration-fast, 120ms),\n color var(--tempest-duration-fast, 120ms);\n white-space: nowrap;\n}\n\n.group.sm .segment {\n padding: 4px 10px;\n font-size: var(--tempest-text-xs);\n min-height: 24px;\n}\n\n.group.md .segment {\n padding: 6px 12px;\n font-size: var(--tempest-text-sm);\n min-height: 32px;\n}\n\n.group.lg .segment {\n padding: 8px 14px;\n font-size: var(--tempest-text-md);\n min-height: 40px;\n}\n\n.segment:hover {\n color: var(--tempest-text);\n}\n\n.segment.active {\n background: var(--tempest-
|
|
1
|
+
{"version":3,"file":"SegmentedControl.module.cjs","names":[],"sources":["../../../src/components/SegmentedControl/SegmentedControl.module.css"],"sourcesContent":[".group {\n display: inline-flex;\n background: var(--tempest-surface-2);\n border-radius: var(--tempest-radius-md);\n padding: 2px;\n font-family: var(--tempest-font-sans);\n gap: 0;\n}\n\n.group.fullWidth {\n display: flex;\n width: 100%;\n}\n\n.segment {\n flex: 1 1 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: var(--tempest-space-1);\n padding: 6px 12px;\n border: 0;\n background: transparent;\n color: var(--tempest-text-muted);\n cursor: pointer;\n border-radius: calc(var(--tempest-radius-md) - 2px);\n font-weight: var(--tempest-weight-medium);\n transition:\n background var(--tempest-duration-fast, 120ms),\n color var(--tempest-duration-fast, 120ms);\n white-space: nowrap;\n}\n\n.group.sm .segment {\n padding: 4px 10px;\n font-size: var(--tempest-text-xs);\n min-height: 24px;\n}\n\n.group.md .segment {\n padding: 6px 12px;\n font-size: var(--tempest-text-sm);\n min-height: 32px;\n}\n\n.group.lg .segment {\n padding: 8px 14px;\n font-size: var(--tempest-text-md);\n min-height: 40px;\n}\n\n.segment:hover {\n color: var(--tempest-text);\n}\n\n.segment.active {\n background: var(--tempest-primary-soft);\n color: var(--tempest-primary-on-soft);\n box-shadow:\n inset 0 0 0 2px var(--tempest-selected-indicator),\n var(--tempest-shadow-xs, 0 1px 2px rgb(0 0 0 / 0.08));\n}\n\n.segment:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n.icon {\n display: inline-flex;\n align-items: center;\n}\n\n.label {\n line-height: 1;\n}\n"],"mappings":";"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl.module.js","names":[],"sources":["../../../src/components/SegmentedControl/SegmentedControl.module.css"],"sourcesContent":[".group {\n display: inline-flex;\n background: var(--tempest-surface-2);\n border-radius: var(--tempest-radius-md);\n padding: 2px;\n font-family: var(--tempest-font-sans);\n gap: 0;\n}\n\n.group.fullWidth {\n display: flex;\n width: 100%;\n}\n\n.segment {\n flex: 1 1 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: var(--tempest-space-1);\n padding: 6px 12px;\n border: 0;\n background: transparent;\n color: var(--tempest-text-muted);\n cursor: pointer;\n border-radius: calc(var(--tempest-radius-md) - 2px);\n font-weight: var(--tempest-weight-medium);\n transition:\n background var(--tempest-duration-fast, 120ms),\n color var(--tempest-duration-fast, 120ms);\n white-space: nowrap;\n}\n\n.group.sm .segment {\n padding: 4px 10px;\n font-size: var(--tempest-text-xs);\n min-height: 24px;\n}\n\n.group.md .segment {\n padding: 6px 12px;\n font-size: var(--tempest-text-sm);\n min-height: 32px;\n}\n\n.group.lg .segment {\n padding: 8px 14px;\n font-size: var(--tempest-text-md);\n min-height: 40px;\n}\n\n.segment:hover {\n color: var(--tempest-text);\n}\n\n.segment.active {\n background: var(--tempest-
|
|
1
|
+
{"version":3,"file":"SegmentedControl.module.js","names":[],"sources":["../../../src/components/SegmentedControl/SegmentedControl.module.css"],"sourcesContent":[".group {\n display: inline-flex;\n background: var(--tempest-surface-2);\n border-radius: var(--tempest-radius-md);\n padding: 2px;\n font-family: var(--tempest-font-sans);\n gap: 0;\n}\n\n.group.fullWidth {\n display: flex;\n width: 100%;\n}\n\n.segment {\n flex: 1 1 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: var(--tempest-space-1);\n padding: 6px 12px;\n border: 0;\n background: transparent;\n color: var(--tempest-text-muted);\n cursor: pointer;\n border-radius: calc(var(--tempest-radius-md) - 2px);\n font-weight: var(--tempest-weight-medium);\n transition:\n background var(--tempest-duration-fast, 120ms),\n color var(--tempest-duration-fast, 120ms);\n white-space: nowrap;\n}\n\n.group.sm .segment {\n padding: 4px 10px;\n font-size: var(--tempest-text-xs);\n min-height: 24px;\n}\n\n.group.md .segment {\n padding: 6px 12px;\n font-size: var(--tempest-text-sm);\n min-height: 32px;\n}\n\n.group.lg .segment {\n padding: 8px 14px;\n font-size: var(--tempest-text-md);\n min-height: 40px;\n}\n\n.segment:hover {\n color: var(--tempest-text);\n}\n\n.segment.active {\n background: var(--tempest-primary-soft);\n color: var(--tempest-primary-on-soft);\n box-shadow:\n inset 0 0 0 2px var(--tempest-selected-indicator),\n var(--tempest-shadow-xs, 0 1px 2px rgb(0 0 0 / 0.08));\n}\n\n.segment:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n.icon {\n display: inline-flex;\n align-items: center;\n}\n\n.label {\n line-height: 1;\n}\n"],"mappings":";"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../../utils/cn.cjs"),t=require("./Select.module.cjs");let n=require("react"),r=require("react/jsx-runtime");var i=(0,n.forwardRef)(function(
|
|
1
|
+
const e=require("../../utils/cn.cjs"),t=require("./Select.module.cjs");let n=require("react"),r=require("react/jsx-runtime");var i=(0,n.forwardRef)(function(i,o){let{options:s,placeholder:c,wrapperClassName:l,className:u,children:d,id:f,required:p,variant:m=`field`,label:h,helperText:g,error:_,...v}=i,y=m===`chip`,b=(0,n.useId)(),x=f??b,S=(0,r.jsxs)(`div`,{className:e.cn(t.default.field,y&&t.default.chip),children:[(0,r.jsxs)(`select`,{ref:o,id:x,"aria-invalid":!!_,required:p,className:e.cn(t.default.select,u),...v,children:[c&&(0,r.jsx)(`option`,{value:``,disabled:!0,hidden:!0,children:c}),s?.map(e=>(0,r.jsx)(`option`,{value:e.value,disabled:e.disabled,children:e.label},e.value)),d]}),(0,r.jsx)(`span`,{className:t.default.caret,"aria-hidden":!0,children:(0,r.jsx)(a,{})})]});return y?(0,r.jsx)(`div`,{className:e.cn(t.default.chipWrapper,l),children:S}):(0,r.jsxs)(`div`,{className:e.cn(t.default.wrapper,_&&t.default.error,l),children:[h&&(0,r.jsxs)(`label`,{htmlFor:x,className:t.default.label,children:[h,p&&(0,r.jsx)(`span`,{className:t.default.required,children:`*`})]}),S,_?(0,r.jsx)(`span`,{className:t.default.errorText,children:_}):g?(0,r.jsx)(`span`,{className:t.default.helper,children:g}):null]})});function a(){return(0,r.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,children:(0,r.jsx)(`path`,{d:`M6 9l6 6 6-6`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}exports.Select=i;
|
|
2
2
|
//# sourceMappingURL=Select.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.cjs","names":[],"sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["import { forwardRef, useId } from \"react\";\nimport type { SelectHTMLAttributes } from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport styles from \"./Select.module.css\";\n\nexport interface SelectOption {\n value: string | number;\n label: string;\n disabled?: boolean;\n}\n\nexport interface
|
|
1
|
+
{"version":3,"file":"Select.cjs","names":[],"sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["import { forwardRef, useId } from \"react\";\nimport type { SelectHTMLAttributes } from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport styles from \"./Select.module.css\";\n\nexport interface SelectOption {\n value: string | number;\n label: string;\n disabled?: boolean;\n}\n\n/** What both variants of {@link Select} accept. */\nexport interface SelectBaseProps extends SelectHTMLAttributes<HTMLSelectElement> {\n options?: SelectOption[];\n placeholder?: string;\n wrapperClassName?: string;\n}\n\n/** The full form field: label, control, helper text and error slot. */\nexport interface SelectFieldProps extends SelectBaseProps {\n variant?: \"field\";\n label?: string;\n helperText?: string;\n error?: string;\n}\n\n/**\n * The bare control, sized to its content.\n *\n * `aria-label` is required rather than optional, because the variant removes the\n * only visible label the component had. A settings row names the control in the\n * row's own text, which the `<select>` has no relationship to — so without this\n * the screen reader announces a combobox with no name at all.\n */\nexport interface SelectChipProps extends SelectBaseProps {\n variant: \"chip\";\n \"aria-label\": string;\n}\n\nexport type SelectProps = SelectFieldProps | SelectChipProps;\n\n/**\n * Native `<select>` wrapper. Either provide `options` for a quick render, or\n * pass `<option>` children directly.\n *\n * Two variants:\n *\n * - `\"field\"` (default) — label, control, helper text and error slot, for a form.\n * - `\"chip\"` — the control alone, sized to its content, for a settings row where\n * the icon and the label are already on the left and the control belongs on the\n * right. Rendering the full field there stacks two labelled fields inside one\n * list item, which is why every app ended up hand-rolling a native `<select>`\n * with `appearance: none` — and hand-rolling it loses the focus ring, the\n * disabled styling and the caret this component already solves.\n *\n * @example\n * <Select label=\"Estado\" options={states} placeholder=\"Selecione\" />\n *\n * @example\n * <ListTile title=\"Idioma\" trailing={<Select variant=\"chip\" aria-label=\"Idioma\" options={langs} />} />\n */\nexport const Select = forwardRef<HTMLSelectElement, SelectProps>(function Select(props, ref) {\n const {\n options,\n placeholder,\n wrapperClassName,\n className,\n children,\n id,\n required,\n variant = \"field\",\n label,\n helperText,\n error,\n ...rest\n } = props as SelectBaseProps & {\n variant?: \"field\" | \"chip\";\n label?: string;\n helperText?: string;\n error?: string;\n };\n const isChip = variant === \"chip\";\n const generatedId = useId();\n const selectId = id ?? generatedId;\n\n const control = (\n <div className={cn(styles.field, isChip && styles.chip)}>\n <select\n ref={ref}\n id={selectId}\n aria-invalid={!!error}\n required={required}\n className={cn(styles.select, className)}\n {...rest}\n >\n {placeholder && (\n <option value=\"\" disabled hidden>\n {placeholder}\n </option>\n )}\n {options?.map((opt) => (\n <option key={opt.value} value={opt.value} disabled={opt.disabled}>\n {opt.label}\n </option>\n ))}\n {children}\n </select>\n <span className={styles.caret} aria-hidden>\n <CaretIcon />\n </span>\n </div>\n );\n\n if (isChip) {\n return <div className={cn(styles.chipWrapper, wrapperClassName)}>{control}</div>;\n }\n\n return (\n <div className={cn(styles.wrapper, error && styles.error, wrapperClassName)}>\n {label && (\n <label htmlFor={selectId} className={styles.label}>\n {label}\n {required && <span className={styles.required}>*</span>}\n </label>\n )}\n {control}\n {error ? (\n <span className={styles.errorText}>{error}</span>\n ) : helperText ? (\n <span className={styles.helper}>{helperText}</span>\n ) : null}\n </div>\n );\n});\n\nfunction CaretIcon() {\n return (\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\">\n <path\n d=\"M6 9l6 6 6-6\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n );\n}\n"],"mappings":"6HA6DA,IAAa,GAAA,EAAS,EAAA,WAAA,CAA2C,SAAgB,EAAO,EAAK,CACzF,GAAM,CACF,UACA,cACA,mBACA,YACA,WACA,KACA,WACA,UAAU,QACV,QACA,aACA,QACA,GAAG,GACH,EAME,EAAS,IAAY,OACrB,GAAA,EAAc,EAAA,MAAA,CAAM,EACpB,EAAW,GAAM,EAEjB,GACF,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAW,EAAA,GAAG,EAAA,QAAO,MAAO,GAAU,EAAA,QAAO,IAAI,EAAtD,SAAA,EACI,EAAA,EAAA,KAAA,CAAC,SAAD,CACS,MACL,GAAI,EACJ,eAAc,CAAC,CAAC,EACN,WACV,UAAW,EAAA,GAAG,EAAA,QAAO,OAAQ,CAAS,EACtC,GAAI,EANR,SAAA,CAQK,IACG,EAAA,EAAA,IAAA,CAAC,SAAD,CAAQ,MAAM,GAAG,SAAA,GAAS,OAAA,GACrB,SAAA,CACG,CAAA,EAEX,GAAS,IAAK,IACX,EAAA,EAAA,IAAA,CAAC,SAAD,CAAwB,MAAO,EAAI,MAAO,SAAU,EAAI,SACnD,SAAA,EAAI,KACD,EAFK,EAAI,KAET,CACX,EACA,CACG,CACR,CAAA,GAAA,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAW,EAAA,QAAO,MAAO,cAAA,GAC3B,UAAA,EAAA,EAAA,IAAA,CAAC,EAAD,CAAY,CAAA,CACV,CAAA,CACL,IAOT,OAJI,GACO,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAW,EAAA,GAAG,EAAA,QAAO,YAAa,CAAgB,EAAI,SAAA,CAAa,CAAA,GAI/E,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAW,EAAA,GAAG,EAAA,QAAO,QAAS,GAAS,EAAA,QAAO,MAAO,CAAgB,EAA1E,SAAA,CACK,IACG,EAAA,EAAA,KAAA,CAAC,QAAD,CAAO,QAAS,EAAU,UAAW,EAAA,QAAO,MAA5C,SAAA,CACK,EACA,IAAY,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAW,EAAA,QAAO,SAAU,SAAA,GAAO,CAAA,CACnD,IAEV,EACA,GACG,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAW,EAAA,QAAO,UAAY,SAAA,CAAY,CAAA,EAChD,GACA,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAW,EAAA,QAAO,OAAS,SAAA,CAAiB,CAAA,EAClD,IACH,GAEb,CAAC,EAED,SAAS,GAAY,CACjB,OACI,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OACjD,UAAA,EAAA,EAAA,IAAA,CAAC,OAAD,CACI,EAAE,eACF,OAAO,eACP,YAAY,IACZ,cAAc,QACd,eAAe,OAClB,CAAA,CACA,CAAA,CAEb"}
|
|
@@ -3,54 +3,57 @@ import t from "./Select.module.js";
|
|
|
3
3
|
import { forwardRef as n, useId as r } from "react";
|
|
4
4
|
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
5
5
|
//#region src/components/Select/Select.tsx
|
|
6
|
-
var o = n(function(
|
|
7
|
-
let v = r(),
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
var o = n(function(n, o) {
|
|
7
|
+
let { options: c, placeholder: l, wrapperClassName: u, className: d, children: f, id: p, required: m, variant: h = "field", label: g, helperText: _, error: v, ...y } = n, b = h === "chip", x = r(), S = p ?? x, C = /* @__PURE__ */ a("div", {
|
|
8
|
+
className: e(t.field, b && t.chip),
|
|
9
|
+
children: [/* @__PURE__ */ a("select", {
|
|
10
|
+
ref: o,
|
|
11
|
+
id: S,
|
|
12
|
+
"aria-invalid": !!v,
|
|
13
|
+
required: m,
|
|
14
|
+
className: e(t.select, d),
|
|
15
|
+
...y,
|
|
16
|
+
children: [
|
|
17
|
+
l && /* @__PURE__ */ i("option", {
|
|
18
|
+
value: "",
|
|
19
|
+
disabled: !0,
|
|
20
|
+
hidden: !0,
|
|
21
|
+
children: l
|
|
22
|
+
}),
|
|
23
|
+
c?.map((e) => /* @__PURE__ */ i("option", {
|
|
24
|
+
value: e.value,
|
|
25
|
+
disabled: e.disabled,
|
|
26
|
+
children: e.label
|
|
27
|
+
}, e.value)),
|
|
28
|
+
f
|
|
29
|
+
]
|
|
30
|
+
}), /* @__PURE__ */ i("span", {
|
|
31
|
+
className: t.caret,
|
|
32
|
+
"aria-hidden": !0,
|
|
33
|
+
children: /* @__PURE__ */ i(s, {})
|
|
34
|
+
})]
|
|
35
|
+
});
|
|
36
|
+
return b ? /* @__PURE__ */ i("div", {
|
|
37
|
+
className: e(t.chipWrapper, u),
|
|
38
|
+
children: C
|
|
39
|
+
}) : /* @__PURE__ */ a("div", {
|
|
40
|
+
className: e(t.wrapper, v && t.error, u),
|
|
10
41
|
children: [
|
|
11
|
-
|
|
12
|
-
htmlFor:
|
|
42
|
+
g && /* @__PURE__ */ a("label", {
|
|
43
|
+
htmlFor: S,
|
|
13
44
|
className: t.label,
|
|
14
|
-
children: [
|
|
45
|
+
children: [g, m && /* @__PURE__ */ i("span", {
|
|
15
46
|
className: t.required,
|
|
16
47
|
children: "*"
|
|
17
48
|
})]
|
|
18
49
|
}),
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
children: [/* @__PURE__ */ a("select", {
|
|
22
|
-
ref: _,
|
|
23
|
-
id: y,
|
|
24
|
-
"aria-invalid": !!c,
|
|
25
|
-
required: h,
|
|
26
|
-
className: e(t.select, f),
|
|
27
|
-
...g,
|
|
28
|
-
children: [
|
|
29
|
-
u && /* @__PURE__ */ i("option", {
|
|
30
|
-
value: "",
|
|
31
|
-
disabled: !0,
|
|
32
|
-
hidden: !0,
|
|
33
|
-
children: u
|
|
34
|
-
}),
|
|
35
|
-
l?.map((e) => /* @__PURE__ */ i("option", {
|
|
36
|
-
value: e.value,
|
|
37
|
-
disabled: e.disabled,
|
|
38
|
-
children: e.label
|
|
39
|
-
}, e.value)),
|
|
40
|
-
p
|
|
41
|
-
]
|
|
42
|
-
}), /* @__PURE__ */ i("span", {
|
|
43
|
-
className: t.caret,
|
|
44
|
-
"aria-hidden": !0,
|
|
45
|
-
children: /* @__PURE__ */ i(s, {})
|
|
46
|
-
})]
|
|
47
|
-
}),
|
|
48
|
-
c ? /* @__PURE__ */ i("span", {
|
|
50
|
+
C,
|
|
51
|
+
v ? /* @__PURE__ */ i("span", {
|
|
49
52
|
className: t.errorText,
|
|
50
|
-
children:
|
|
51
|
-
}) :
|
|
53
|
+
children: v
|
|
54
|
+
}) : _ ? /* @__PURE__ */ i("span", {
|
|
52
55
|
className: t.helper,
|
|
53
|
-
children:
|
|
56
|
+
children: _
|
|
54
57
|
}) : null
|
|
55
58
|
]
|
|
56
59
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","names":[],"sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["import { forwardRef, useId } from \"react\";\nimport type { SelectHTMLAttributes } from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport styles from \"./Select.module.css\";\n\nexport interface SelectOption {\n value: string | number;\n label: string;\n disabled?: boolean;\n}\n\nexport interface
|
|
1
|
+
{"version":3,"file":"Select.js","names":[],"sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["import { forwardRef, useId } from \"react\";\nimport type { SelectHTMLAttributes } from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport styles from \"./Select.module.css\";\n\nexport interface SelectOption {\n value: string | number;\n label: string;\n disabled?: boolean;\n}\n\n/** What both variants of {@link Select} accept. */\nexport interface SelectBaseProps extends SelectHTMLAttributes<HTMLSelectElement> {\n options?: SelectOption[];\n placeholder?: string;\n wrapperClassName?: string;\n}\n\n/** The full form field: label, control, helper text and error slot. */\nexport interface SelectFieldProps extends SelectBaseProps {\n variant?: \"field\";\n label?: string;\n helperText?: string;\n error?: string;\n}\n\n/**\n * The bare control, sized to its content.\n *\n * `aria-label` is required rather than optional, because the variant removes the\n * only visible label the component had. A settings row names the control in the\n * row's own text, which the `<select>` has no relationship to — so without this\n * the screen reader announces a combobox with no name at all.\n */\nexport interface SelectChipProps extends SelectBaseProps {\n variant: \"chip\";\n \"aria-label\": string;\n}\n\nexport type SelectProps = SelectFieldProps | SelectChipProps;\n\n/**\n * Native `<select>` wrapper. Either provide `options` for a quick render, or\n * pass `<option>` children directly.\n *\n * Two variants:\n *\n * - `\"field\"` (default) — label, control, helper text and error slot, for a form.\n * - `\"chip\"` — the control alone, sized to its content, for a settings row where\n * the icon and the label are already on the left and the control belongs on the\n * right. Rendering the full field there stacks two labelled fields inside one\n * list item, which is why every app ended up hand-rolling a native `<select>`\n * with `appearance: none` — and hand-rolling it loses the focus ring, the\n * disabled styling and the caret this component already solves.\n *\n * @example\n * <Select label=\"Estado\" options={states} placeholder=\"Selecione\" />\n *\n * @example\n * <ListTile title=\"Idioma\" trailing={<Select variant=\"chip\" aria-label=\"Idioma\" options={langs} />} />\n */\nexport const Select = forwardRef<HTMLSelectElement, SelectProps>(function Select(props, ref) {\n const {\n options,\n placeholder,\n wrapperClassName,\n className,\n children,\n id,\n required,\n variant = \"field\",\n label,\n helperText,\n error,\n ...rest\n } = props as SelectBaseProps & {\n variant?: \"field\" | \"chip\";\n label?: string;\n helperText?: string;\n error?: string;\n };\n const isChip = variant === \"chip\";\n const generatedId = useId();\n const selectId = id ?? generatedId;\n\n const control = (\n <div className={cn(styles.field, isChip && styles.chip)}>\n <select\n ref={ref}\n id={selectId}\n aria-invalid={!!error}\n required={required}\n className={cn(styles.select, className)}\n {...rest}\n >\n {placeholder && (\n <option value=\"\" disabled hidden>\n {placeholder}\n </option>\n )}\n {options?.map((opt) => (\n <option key={opt.value} value={opt.value} disabled={opt.disabled}>\n {opt.label}\n </option>\n ))}\n {children}\n </select>\n <span className={styles.caret} aria-hidden>\n <CaretIcon />\n </span>\n </div>\n );\n\n if (isChip) {\n return <div className={cn(styles.chipWrapper, wrapperClassName)}>{control}</div>;\n }\n\n return (\n <div className={cn(styles.wrapper, error && styles.error, wrapperClassName)}>\n {label && (\n <label htmlFor={selectId} className={styles.label}>\n {label}\n {required && <span className={styles.required}>*</span>}\n </label>\n )}\n {control}\n {error ? (\n <span className={styles.errorText}>{error}</span>\n ) : helperText ? (\n <span className={styles.helper}>{helperText}</span>\n ) : null}\n </div>\n );\n});\n\nfunction CaretIcon() {\n return (\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\">\n <path\n d=\"M6 9l6 6 6-6\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n );\n}\n"],"mappings":";;;;;AA6DA,IAAa,IAAS,EAA2C,SAAgB,GAAO,GAAK;CACzF,IAAM,EACF,YACA,gBACA,qBACA,cACA,aACA,OACA,aACA,aAAU,SACV,UACA,eACA,UACA,GAAG,MACH,GAME,IAAS,MAAY,QACrB,IAAc,EAAM,GACpB,IAAW,KAAM,GAEjB,IACF,kBAAC,OAAD;EAAK,WAAW,EAAG,EAAO,OAAO,KAAU,EAAO,IAAI;EAAtD,UAAA,CACI,kBAAC,UAAD;GACS;GACL,IAAI;GACJ,gBAAc,CAAC,CAAC;GACN;GACV,WAAW,EAAG,EAAO,QAAQ,CAAS;GACtC,GAAI;GANR,UAAA;IAQK,KACG,kBAAC,UAAD;KAAQ,OAAM;KAAG,UAAA;KAAS,QAAA;KACrB,UAAA;IACG,CAAA;IAEX,GAAS,KAAK,MACX,kBAAC,UAAD;KAAwB,OAAO,EAAI;KAAO,UAAU,EAAI;KACnD,UAAA,EAAI;IACD,GAFK,EAAI,KAET,CACX;IACA;GACG;EACR,CAAA,GAAA,kBAAC,QAAD;GAAM,WAAW,EAAO;GAAO,eAAA;GAC3B,UAAA,kBAAC,GAAD,CAAY,CAAA;EACV,CAAA,CACL;;CAOT,OAJI,IACO,kBAAC,OAAD;EAAK,WAAW,EAAG,EAAO,aAAa,CAAgB;EAAI,UAAA;CAAa,CAAA,IAI/E,kBAAC,OAAD;EAAK,WAAW,EAAG,EAAO,SAAS,KAAS,EAAO,OAAO,CAAgB;EAA1E,UAAA;GACK,KACG,kBAAC,SAAD;IAAO,SAAS;IAAU,WAAW,EAAO;IAA5C,UAAA,CACK,GACA,KAAY,kBAAC,QAAD;KAAM,WAAW,EAAO;KAAU,UAAA;IAAO,CAAA,CACnD;;GAEV;GACA,IACG,kBAAC,QAAD;IAAM,WAAW,EAAO;IAAY,UAAA;GAAY,CAAA,IAChD,IACA,kBAAC,QAAD;IAAM,WAAW,EAAO;IAAS,UAAA;GAAiB,CAAA,IAClD;EACH;;AAEb,CAAC;AAED,SAAS,IAAY;CACjB,OACI,kBAAC,OAAD;EAAK,OAAM;EAAK,QAAO;EAAK,SAAQ;EAAY,MAAK;EACjD,UAAA,kBAAC,QAAD;GACI,GAAE;GACF,QAAO;GACP,aAAY;GACZ,eAAc;GACd,gBAAe;EAClB,CAAA;CACA,CAAA;AAEb"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
require("../../styles/component/Select.css");
|
|
2
|
-
var e=`tempest_wrapper_KS2K3`,t=`tempest_label_Lmgos`,n=`tempest_required_PvDVJ`,r=`tempest_field_h-wBy`,i=`tempest_select_cjdcr`,a=`tempest_caret_MdCao`,o=`tempest_error_sw9MU`,s=`tempest_helper_frosK`,c=`tempest_errorText_-zd6i`,l={wrapper:e,label:t,required:n,field:r,select:i,caret:a,error:o,helper:s,errorText:c};exports.caret=a,exports.
|
|
2
|
+
var e=`tempest_wrapper_KS2K3`,t=`tempest_label_Lmgos`,n=`tempest_required_PvDVJ`,r=`tempest_field_h-wBy`,i=`tempest_select_cjdcr`,a=`tempest_caret_MdCao`,o=`tempest_error_sw9MU`,s=`tempest_helper_frosK`,c=`tempest_errorText_-zd6i`,l=`tempest_chipWrapper_5keyI`,u=`tempest_chip_r4NVm`,d={wrapper:e,label:t,required:n,field:r,select:i,caret:a,error:o,helper:s,errorText:c,chipWrapper:l,chip:u};exports.caret=a,exports.chip=u,exports.chipWrapper=l,exports.default=d,exports.error=o,exports.errorText=c,exports.field=r,exports.helper=s,exports.label=t,exports.required=n,exports.select=i,exports.wrapper=e;
|
|
3
3
|
//# sourceMappingURL=Select.module.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.module.cjs","names":[],"sources":["../../../src/components/Select/Select.module.css"],"sourcesContent":[".wrapper {\n display: flex;\n flex-direction: column;\n gap: var(--tempest-space-1);\n width: 100%;\n}\n\n.label {\n font-size: var(--tempest-text-sm);\n font-weight: var(--tempest-weight-semibold);\n color: var(--tempest-text);\n line-height: var(--tempest-leading-snug);\n}\n\n.required {\n color: var(--tempest-danger);\n margin-left: 2px;\n}\n\n.field {\n position: relative;\n display: flex;\n align-items: center;\n}\n\n.select {\n width: 100%;\n height: var(--tempest-control-height-md);\n padding: 0 36px 0 var(--tempest-control-padding-md);\n border: 1px solid var(--tempest-border);\n border-radius: var(--tempest-control-radius);\n background-color: var(--tempest-bg);\n color: var(--tempest-text);\n font-family: var(--tempest-font-sans);\n font-size: var(--tempest-control-font-md);\n line-height: var(--tempest-leading-snug);\n appearance: none;\n cursor: pointer;\n box-shadow: var(--tempest-shadow-xs);\n transition: var(--tempest-transition-color), var(--tempest-transition-shadow);\n}\n\n.select:hover:not(:disabled):not(:focus) {\n border-color: var(--tempest-border-strong);\n}\n\n.select:focus {\n outline: none;\n border-color: var(--tempest-primary);\n box-shadow: 0 0 0 var(--tempest-focus-ring-width) var(--tempest-focus-ring-color);\n}\n\n.select:disabled {\n background-color: var(--tempest-surface);\n cursor: not-allowed;\n color: var(--tempest-text-muted);\n box-shadow: none;\n}\n\n.caret {\n position: absolute;\n right: 12px;\n pointer-events: none;\n color: var(--tempest-text-muted);\n}\n\n.error .select {\n border-color: var(--tempest-danger);\n}\n\n.error .select:focus {\n box-shadow: 0 0 0 var(--tempest-focus-ring-width)\n color-mix(in srgb, var(--tempest-danger) 25%, transparent);\n}\n\n.helper {\n font-size: var(--tempest-text-xs);\n color: var(--tempest-text-muted);\n line-height: var(--tempest-leading-snug);\n}\n\n.errorText {\n font-size: var(--tempest-text-xs);\n color: var(--tempest-danger);\n line-height: var(--tempest-leading-snug);\n}\n"],"mappings":";"}
|
|
1
|
+
{"version":3,"file":"Select.module.cjs","names":[],"sources":["../../../src/components/Select/Select.module.css"],"sourcesContent":[".wrapper {\n display: flex;\n flex-direction: column;\n gap: var(--tempest-space-1);\n width: 100%;\n}\n\n.label {\n font-size: var(--tempest-text-sm);\n font-weight: var(--tempest-weight-semibold);\n color: var(--tempest-text);\n line-height: var(--tempest-leading-snug);\n}\n\n.required {\n color: var(--tempest-danger);\n margin-left: 2px;\n}\n\n.field {\n position: relative;\n display: flex;\n align-items: center;\n}\n\n.select {\n width: 100%;\n height: var(--tempest-control-height-md);\n padding: 0 36px 0 var(--tempest-control-padding-md);\n border: 1px solid var(--tempest-border);\n border-radius: var(--tempest-control-radius);\n background-color: var(--tempest-bg);\n color: var(--tempest-text);\n font-family: var(--tempest-font-sans);\n font-size: var(--tempest-control-font-md);\n line-height: var(--tempest-leading-snug);\n appearance: none;\n cursor: pointer;\n box-shadow: var(--tempest-shadow-xs);\n transition: var(--tempest-transition-color), var(--tempest-transition-shadow);\n}\n\n.select:hover:not(:disabled):not(:focus) {\n border-color: var(--tempest-border-strong);\n}\n\n.select:focus {\n outline: none;\n border-color: var(--tempest-primary);\n box-shadow: 0 0 0 var(--tempest-focus-ring-width) var(--tempest-focus-ring-color);\n}\n\n.select:disabled {\n background-color: var(--tempest-surface);\n cursor: not-allowed;\n color: var(--tempest-text-muted);\n box-shadow: none;\n}\n\n.caret {\n position: absolute;\n right: 12px;\n pointer-events: none;\n color: var(--tempest-text-muted);\n}\n\n.error .select {\n border-color: var(--tempest-danger);\n}\n\n.error .select:focus {\n box-shadow: 0 0 0 var(--tempest-focus-ring-width)\n color-mix(in srgb, var(--tempest-danger) 25%, transparent);\n}\n\n.helper {\n font-size: var(--tempest-text-xs);\n color: var(--tempest-text-muted);\n line-height: var(--tempest-leading-snug);\n}\n\n.errorText {\n font-size: var(--tempest-text-xs);\n color: var(--tempest-danger);\n line-height: var(--tempest-leading-snug);\n}\n\n.chipWrapper {\n display: inline-flex;\n}\n\n.chip {\n width: auto;\n}\n\n.chip .select {\n width: auto;\n height: var(--tempest-control-height-sm);\n padding: 0 30px 0 var(--tempest-space-3);\n border-radius: var(--tempest-radius-full);\n background-color: var(--tempest-surface);\n font-size: var(--tempest-text-sm);\n box-shadow: none;\n}\n\n.chip .caret {\n right: 10px;\n}\n"],"mappings":";"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../../styles/component/Select.css";
|
|
2
2
|
//#region src/components/Select/Select.module.css
|
|
3
|
-
var e = "tempest_wrapper_KS2K3", t = "tempest_label_Lmgos", n = "tempest_required_PvDVJ", r = "tempest_field_h-wBy", i = "tempest_select_cjdcr", a = "tempest_caret_MdCao", o = "tempest_error_sw9MU", s = "tempest_helper_frosK", c = "tempest_errorText_-zd6i", l = {
|
|
3
|
+
var e = "tempest_wrapper_KS2K3", t = "tempest_label_Lmgos", n = "tempest_required_PvDVJ", r = "tempest_field_h-wBy", i = "tempest_select_cjdcr", a = "tempest_caret_MdCao", o = "tempest_error_sw9MU", s = "tempest_helper_frosK", c = "tempest_errorText_-zd6i", l = "tempest_chipWrapper_5keyI", u = "tempest_chip_r4NVm", d = {
|
|
4
4
|
wrapper: e,
|
|
5
5
|
label: t,
|
|
6
6
|
required: n,
|
|
@@ -9,9 +9,11 @@ var e = "tempest_wrapper_KS2K3", t = "tempest_label_Lmgos", n = "tempest_require
|
|
|
9
9
|
caret: a,
|
|
10
10
|
error: o,
|
|
11
11
|
helper: s,
|
|
12
|
-
errorText: c
|
|
12
|
+
errorText: c,
|
|
13
|
+
chipWrapper: l,
|
|
14
|
+
chip: u
|
|
13
15
|
};
|
|
14
16
|
//#endregion
|
|
15
|
-
export { a as caret, l as default, o as error, c as errorText, r as field, s as helper, t as label, n as required, i as select, e as wrapper };
|
|
17
|
+
export { a as caret, u as chip, l as chipWrapper, d as default, o as error, c as errorText, r as field, s as helper, t as label, n as required, i as select, e as wrapper };
|
|
16
18
|
|
|
17
19
|
//# sourceMappingURL=Select.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.module.js","names":[],"sources":["../../../src/components/Select/Select.module.css"],"sourcesContent":[".wrapper {\n display: flex;\n flex-direction: column;\n gap: var(--tempest-space-1);\n width: 100%;\n}\n\n.label {\n font-size: var(--tempest-text-sm);\n font-weight: var(--tempest-weight-semibold);\n color: var(--tempest-text);\n line-height: var(--tempest-leading-snug);\n}\n\n.required {\n color: var(--tempest-danger);\n margin-left: 2px;\n}\n\n.field {\n position: relative;\n display: flex;\n align-items: center;\n}\n\n.select {\n width: 100%;\n height: var(--tempest-control-height-md);\n padding: 0 36px 0 var(--tempest-control-padding-md);\n border: 1px solid var(--tempest-border);\n border-radius: var(--tempest-control-radius);\n background-color: var(--tempest-bg);\n color: var(--tempest-text);\n font-family: var(--tempest-font-sans);\n font-size: var(--tempest-control-font-md);\n line-height: var(--tempest-leading-snug);\n appearance: none;\n cursor: pointer;\n box-shadow: var(--tempest-shadow-xs);\n transition: var(--tempest-transition-color), var(--tempest-transition-shadow);\n}\n\n.select:hover:not(:disabled):not(:focus) {\n border-color: var(--tempest-border-strong);\n}\n\n.select:focus {\n outline: none;\n border-color: var(--tempest-primary);\n box-shadow: 0 0 0 var(--tempest-focus-ring-width) var(--tempest-focus-ring-color);\n}\n\n.select:disabled {\n background-color: var(--tempest-surface);\n cursor: not-allowed;\n color: var(--tempest-text-muted);\n box-shadow: none;\n}\n\n.caret {\n position: absolute;\n right: 12px;\n pointer-events: none;\n color: var(--tempest-text-muted);\n}\n\n.error .select {\n border-color: var(--tempest-danger);\n}\n\n.error .select:focus {\n box-shadow: 0 0 0 var(--tempest-focus-ring-width)\n color-mix(in srgb, var(--tempest-danger) 25%, transparent);\n}\n\n.helper {\n font-size: var(--tempest-text-xs);\n color: var(--tempest-text-muted);\n line-height: var(--tempest-leading-snug);\n}\n\n.errorText {\n font-size: var(--tempest-text-xs);\n color: var(--tempest-danger);\n line-height: var(--tempest-leading-snug);\n}\n"],"mappings":";"}
|
|
1
|
+
{"version":3,"file":"Select.module.js","names":[],"sources":["../../../src/components/Select/Select.module.css"],"sourcesContent":[".wrapper {\n display: flex;\n flex-direction: column;\n gap: var(--tempest-space-1);\n width: 100%;\n}\n\n.label {\n font-size: var(--tempest-text-sm);\n font-weight: var(--tempest-weight-semibold);\n color: var(--tempest-text);\n line-height: var(--tempest-leading-snug);\n}\n\n.required {\n color: var(--tempest-danger);\n margin-left: 2px;\n}\n\n.field {\n position: relative;\n display: flex;\n align-items: center;\n}\n\n.select {\n width: 100%;\n height: var(--tempest-control-height-md);\n padding: 0 36px 0 var(--tempest-control-padding-md);\n border: 1px solid var(--tempest-border);\n border-radius: var(--tempest-control-radius);\n background-color: var(--tempest-bg);\n color: var(--tempest-text);\n font-family: var(--tempest-font-sans);\n font-size: var(--tempest-control-font-md);\n line-height: var(--tempest-leading-snug);\n appearance: none;\n cursor: pointer;\n box-shadow: var(--tempest-shadow-xs);\n transition: var(--tempest-transition-color), var(--tempest-transition-shadow);\n}\n\n.select:hover:not(:disabled):not(:focus) {\n border-color: var(--tempest-border-strong);\n}\n\n.select:focus {\n outline: none;\n border-color: var(--tempest-primary);\n box-shadow: 0 0 0 var(--tempest-focus-ring-width) var(--tempest-focus-ring-color);\n}\n\n.select:disabled {\n background-color: var(--tempest-surface);\n cursor: not-allowed;\n color: var(--tempest-text-muted);\n box-shadow: none;\n}\n\n.caret {\n position: absolute;\n right: 12px;\n pointer-events: none;\n color: var(--tempest-text-muted);\n}\n\n.error .select {\n border-color: var(--tempest-danger);\n}\n\n.error .select:focus {\n box-shadow: 0 0 0 var(--tempest-focus-ring-width)\n color-mix(in srgb, var(--tempest-danger) 25%, transparent);\n}\n\n.helper {\n font-size: var(--tempest-text-xs);\n color: var(--tempest-text-muted);\n line-height: var(--tempest-leading-snug);\n}\n\n.errorText {\n font-size: var(--tempest-text-xs);\n color: var(--tempest-danger);\n line-height: var(--tempest-leading-snug);\n}\n\n.chipWrapper {\n display: inline-flex;\n}\n\n.chip {\n width: auto;\n}\n\n.chip .select {\n width: auto;\n height: var(--tempest-control-height-sm);\n padding: 0 30px 0 var(--tempest-space-3);\n border-radius: var(--tempest-radius-full);\n background-color: var(--tempest-surface);\n font-size: var(--tempest-text-sm);\n box-shadow: none;\n}\n\n.chip .caret {\n right: 10px;\n}\n"],"mappings":";"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./pwa-env.cjs");let t=require("react");var n=6048e5,r=3e3,i=`tempest:install-declined-at`,a=null,o=new Set;typeof window<`u`&&(window.addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),a=e,o.forEach(e=>e(a))}),window.addEventListener(`appinstalled`,()=>{a=null,o.forEach(e=>e(null))}));function s(e,t){if(typeof window>`u`)return!1;let n=window.localStorage.getItem(e)
|
|
1
|
+
const e=require("./pwa-env.cjs");let t=require("react");var n=6048e5,r=3e3,i=`tempest:install-declined-at`,a=null,o=new Set;typeof window<`u`&&(window.addEventListener(`beforeinstallprompt`,e=>{e.preventDefault(),a=e,o.forEach(e=>e(a))}),window.addEventListener(`appinstalled`,()=>{a=null,o.forEach(e=>e(null))}));function s(e,t){if(typeof window>`u`)return!1;let n;try{n=window.localStorage.getItem(e)}catch{return!1}if(!n)return!1;let r=Number(n);return Number.isFinite(r)?Date.now()-r<t:!1}function c(c={}){let{declineStorageKey:l=i,declineCooldownMs:u=n,manualFallbackDelayMs:d=r}=c,[f,p]=(0,t.useState)(a),[m,h]=(0,t.useState)(e.isStandalone()),[g,_]=(0,t.useState)(!1);(0,t.useEffect)(()=>(o.add(p),()=>{o.delete(p)}),[]),(0,t.useEffect)(()=>{if(typeof window>`u`)return;let t=window.matchMedia?.(`(display-mode: standalone)`),n=()=>h(e.isStandalone());return t?.addEventListener?.(`change`,n),window.addEventListener(`appinstalled`,n),()=>{t?.removeEventListener?.(`change`,n),window.removeEventListener(`appinstalled`,n)}},[]),(0,t.useEffect)(()=>{if(f){_(!1);return}let e=window.setTimeout(()=>{a||_(!0)},d);return()=>window.clearTimeout(e)},[f,d]);let v=e.isIOS(),y=e.isAndroidWithoutPromptApi(),b=s(l,u),x=`none`;!m&&!b&&(f?x=`native`:v?x=`ios`:(y||g)&&(x=`manual`));let S=()=>{if(!(typeof window>`u`))try{window.localStorage.setItem(l,String(Date.now()))}catch{}};return{deferredPrompt:f,canInstall:x!==`none`,isIOS:v,isStandalone:m,isManualAndroid:y,promptTimedOut:g,method:x,openInChromeIntent:e.buildOpenInChromeIntent(),install:async()=>{if(!f)return!1;await f.prompt();let e=await f.userChoice;return e.outcome===`dismissed`&&S(),a=null,o.forEach(e=>e(null)),e.outcome===`accepted`},recordDecline:S}}exports.useInstallPrompt=c;
|
|
2
2
|
//# sourceMappingURL=use-install-prompt.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-install-prompt.cjs","names":[],"sources":["../../src/hooks/use-install-prompt.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport {\n buildOpenInChromeIntent,\n isAndroidWithoutPromptApi,\n isIOS,\n isStandalone,\n type BeforeInstallPromptEvent,\n} from \"./pwa-env\";\n\nconst DEFAULT_DECLINE_COOLDOWN_MS = 7 * 24 * 60 * 60 * 1000;\nconst DEFAULT_MANUAL_FALLBACK_DELAY_MS = 3000;\nconst DEFAULT_DECLINE_STORAGE_KEY = \"tempest:install-declined-at\";\n\nlet cachedEvent: BeforeInstallPromptEvent | null = null;\nconst eventSubscribers = new Set<(event: BeforeInstallPromptEvent | null) => void>();\n\nif (typeof window !== \"undefined\") {\n window.addEventListener(\"beforeinstallprompt\", (event: Event) => {\n event.preventDefault();\n cachedEvent = event as BeforeInstallPromptEvent;\n eventSubscribers.forEach((fn) => fn(cachedEvent));\n });\n window.addEventListener(\"appinstalled\", () => {\n cachedEvent = null;\n eventSubscribers.forEach((fn) => fn(null));\n });\n}\n\n/**\n * Strategy the UI should use to install the app:\n *\n * - `\"native\"`: trigger `BeforeInstallPromptEvent.prompt()`.\n * - `\"ios\"`: show iOS Safari Share → Add to Home Screen instructions.\n * - `\"manual\"`: show generic browser-menu instructions (Chromium forks that\n * strip the prompt API, plus the timeout fallback when no event arrives).\n * - `\"none\"`: nothing to offer (already installed or unsupported runtime).\n */\nexport type InstallMethod = \"native\" | \"ios\" | \"manual\" | \"none\";\n\n/** Options for {@link useInstallPrompt}. */\nexport interface UseInstallPromptOptions {\n /**\n * `localStorage` key used to persist the decline timestamp. Defaults to\n * `\"tempest:install-declined-at\"`.\n */\n declineStorageKey?: string;\n /**\n * How long, in ms, the install CTA stays hidden after the user declines.\n * Defaults to 7 days.\n */\n declineCooldownMs?: number;\n /**\n * How long, in ms, to wait for a `beforeinstallprompt` event before\n * resolving to the `\"manual\"` method. Defaults to `3000`.\n */\n manualFallbackDelayMs?: number;\n}\n\n/** State returned by {@link useInstallPrompt}. */\nexport interface UseInstallPromptResult {\n /** The cached `beforeinstallprompt` event, or `null` when unavailable. */\n deferredPrompt: BeforeInstallPromptEvent | null;\n /** True when the app can be installed through any supported method. */\n canInstall: boolean;\n /** True when running on iOS/iPadOS Safari. */\n isIOS: boolean;\n /** True when already running as an installed PWA. */\n isStandalone: boolean;\n /** True when the browser is an Android Chromium fork with no prompt API. */\n isManualAndroid: boolean;\n /** True when no `beforeinstallprompt` arrived within the timeout window. */\n promptTimedOut: boolean;\n /** The resolved install strategy the UI should follow. */\n method: InstallMethod;\n /** An `intent://` URL to re-open the page in Chrome on Android, else `null`. */\n openInChromeIntent: string | null;\n /**\n * Triggers the native prompt.\n *\n * @returns `true` when the user accepted the install, `false` otherwise.\n */\n install: () => Promise<boolean>;\n /** Records that the user declined the CTA, starting the cooldown window. */\n recordDecline: () => void;\n}\n\nfunction readDecline(key: string, cooldownMs: number): boolean {\n if (typeof window === \"undefined\") return false;\n const raw = window.localStorage.getItem(key);\n if (!raw) return false;\n const ts = Number(raw);\n if (!Number.isFinite(ts)) return false;\n return Date.now() - ts < cooldownMs;\n}\n\n/**\n * React hook that resolves how (and whether) to offer PWA installation.\n *\n * It caches the `beforeinstallprompt` event, detects iOS/iPadOS, detects\n * Android Chromium forks that lack the prompt API, detects standalone display\n * mode, and applies a decline cooldown persisted in `localStorage`. The\n * resulting `method` tells the UI which install affordance to render.\n *\n * The decline persistence is pluggable through\n * {@link UseInstallPromptOptions.declineStorageKey} and\n * {@link UseInstallPromptOptions.declineCooldownMs} — no app-specific storage\n * layer is required, and it is SSR-guarded.\n *\n * @param options - Optional storage key, cooldown, and fallback-delay tuning.\n * @returns The install state plus `install()` and `recordDecline()` actions.\n *\n * @example\n * const { method, install } = useInstallPrompt();\n * if (method === \"native\") return <button onClick={install}>Install</button>;\n */\nexport function useInstallPrompt(options: UseInstallPromptOptions = {}): UseInstallPromptResult {\n const {\n declineStorageKey = DEFAULT_DECLINE_STORAGE_KEY,\n declineCooldownMs = DEFAULT_DECLINE_COOLDOWN_MS,\n manualFallbackDelayMs = DEFAULT_MANUAL_FALLBACK_DELAY_MS,\n } = options;\n\n const [event, setEvent] = useState<BeforeInstallPromptEvent | null>(cachedEvent);\n const [standalone, setStandalone] = useState<boolean>(isStandalone());\n const [promptTimedOut, setPromptTimedOut] = useState<boolean>(false);\n\n useEffect(() => {\n eventSubscribers.add(setEvent);\n return () => {\n eventSubscribers.delete(setEvent);\n };\n }, []);\n\n useEffect(() => {\n if (typeof window === \"undefined\") return;\n const mq = window.matchMedia?.(\"(display-mode: standalone)\");\n const handler = (): void => setStandalone(isStandalone());\n mq?.addEventListener?.(\"change\", handler);\n window.addEventListener(\"appinstalled\", handler);\n return () => {\n mq?.removeEventListener?.(\"change\", handler);\n window.removeEventListener(\"appinstalled\", handler);\n };\n }, []);\n\n useEffect(() => {\n if (event) {\n setPromptTimedOut(false);\n return;\n }\n const timer = window.setTimeout(() => {\n if (!cachedEvent) setPromptTimedOut(true);\n }, manualFallbackDelayMs);\n return () => window.clearTimeout(timer);\n }, [event, manualFallbackDelayMs]);\n\n const ios = isIOS();\n const manualAndroid = isAndroidWithoutPromptApi();\n\n const declineActive = readDecline(declineStorageKey, declineCooldownMs);\n\n let method: InstallMethod = \"none\";\n if (!standalone && !declineActive) {\n if (event) method = \"native\";\n else if (ios) method = \"ios\";\n else if (manualAndroid || promptTimedOut) method = \"manual\";\n }\n\n const recordDecline = (): void => {\n if (typeof window === \"undefined\") return;\n window.localStorage.setItem(declineStorageKey, String(Date.now()));\n };\n\n const install = async (): Promise<boolean> => {\n if (!event) return false;\n await event.prompt();\n const choice = await event.userChoice;\n if (choice.outcome === \"dismissed\") recordDecline();\n cachedEvent = null;\n eventSubscribers.forEach((fn) => fn(null));\n return choice.outcome === \"accepted\";\n };\n\n return {\n deferredPrompt: event,\n canInstall: method !== \"none\",\n isIOS: ios,\n isStandalone: standalone,\n isManualAndroid: manualAndroid,\n promptTimedOut,\n method,\n openInChromeIntent: buildOpenInChromeIntent(),\n install,\n recordDecline,\n };\n}\n"],"mappings":"wDASA,IAAM,EAA8B,OAC9B,EAAmC,IACnC,EAA8B,8BAEhC,EAA+C,KAC7C,EAAmB,IAAI,IAEzB,OAAO,OAAW,MAClB,OAAO,iBAAiB,sBAAwB,GAAiB,CAC7D,EAAM,eAAe,EACrB,EAAc,EACd,EAAiB,QAAS,GAAO,EAAG,CAAW,CAAC,CACpD,CAAC,EACD,OAAO,iBAAiB,mBAAsB,CAC1C,EAAc,KACd,EAAiB,QAAS,GAAO,EAAG,IAAI,CAAC,CAC7C,CAAC,GA6DL,SAAS,EAAY,EAAa,EAA6B,CAC3D,GAAI,OAAO,OAAW,IAAa,MAAO,GAC1C,IAAM,EAAM,OAAO,aAAa,QAAQ,CAAG,EAC3C,GAAI,CAAC,EAAK,MAAO,GACjB,IAAM,EAAK,OAAO,CAAG,EAErB,OADK,OAAO,SAAS,CAAE,EAChB,KAAK,IAAI,EAAI,EAAK,EADQ,EAErC,CAsBA,SAAgB,EAAiB,EAAmC,CAAC,EAA2B,CAC5F,GAAM,CACF,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,GACxB,EAEE,CAAC,EAAO,IAAA,EAAY,EAAA,SAAA,CAA0C,CAAW,EACzE,CAAC,EAAY,IAAA,EAAiB,EAAA,SAAA,CAAkB,EAAA,aAAa,CAAC,EAC9D,CAAC,EAAgB,IAAA,EAAqB,EAAA,SAAA,CAAkB,EAAK,GAEnE,EAAA,EAAA,UAAA,MACI,EAAiB,IAAI,CAAQ,MAChB,CACT,EAAiB,OAAO,CAAQ,CACpC,GACD,CAAC,CAAC,GAEL,EAAA,EAAA,UAAA,KAAgB,CACZ,GAAI,OAAO,OAAW,IAAa,OACnC,IAAM,EAAK,OAAO,aAAa,4BAA4B,EACrD,MAAsB,EAAc,EAAA,aAAa,CAAC,EAGxD,OAFA,GAAI,mBAAmB,SAAU,CAAO,EACxC,OAAO,iBAAiB,eAAgB,CAAO,MAClC,CACT,GAAI,sBAAsB,SAAU,CAAO,EAC3C,OAAO,oBAAoB,eAAgB,CAAO,CACtD,CACJ,EAAG,CAAC,CAAC,GAEL,EAAA,EAAA,UAAA,KAAgB,CACZ,GAAI,EAAO,CACP,EAAkB,EAAK,EACvB,MACJ,CACA,IAAM,EAAQ,OAAO,eAAiB,CAC7B,GAAa,EAAkB,EAAI,CAC5C,EAAG,CAAqB,EACxB,UAAa,OAAO,aAAa,CAAK,CAC1C,EAAG,CAAC,EAAO,CAAqB,CAAC,EAEjC,IAAM,EAAM,EAAA,MAAM,EACZ,EAAgB,EAAA,0BAA0B,EAE1C,EAAgB,EAAY,EAAmB,CAAiB,EAElE,EAAwB,OACxB,CAAC,GAAc,CAAC,IACZ,EAAO,EAAS,SACX,EAAK,EAAS,OACd,GAAiB,KAAgB,EAAS,WAGvD,IAAM,MAA4B,CAC1B,OAAO,OAAW,KACtB,OAAO,aAAa,QAAQ,EAAmB,OAAO,KAAK,IAAI,CAAC,CAAC,CACrE,EAYA,MAAO,CACH,eAAgB,EAChB,WAAY,IAAW,OACvB,MAAO,EACP,aAAc,EACd,gBAAiB,EACjB,iBACA,SACA,mBAAoB,EAAA,wBAAwB,EAC5C,iBAnB0C,CAC1C,GAAI,CAAC,EAAO,MAAO,GACnB,MAAM,EAAM,OAAO,EACnB,IAAM,EAAS,MAAM,EAAM,WAI3B,OAHI,EAAO,UAAY,aAAa,EAAc,EAClD,EAAc,KACd,EAAiB,QAAS,GAAO,EAAG,IAAI,CAAC,EAClC,EAAO,UAAY,UAC9B,EAYI,eACJ,CACJ"}
|
|
1
|
+
{"version":3,"file":"use-install-prompt.cjs","names":[],"sources":["../../src/hooks/use-install-prompt.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport {\n buildOpenInChromeIntent,\n isAndroidWithoutPromptApi,\n isIOS,\n isStandalone,\n type BeforeInstallPromptEvent,\n} from \"./pwa-env\";\n\nconst DEFAULT_DECLINE_COOLDOWN_MS = 7 * 24 * 60 * 60 * 1000;\nconst DEFAULT_MANUAL_FALLBACK_DELAY_MS = 3000;\nconst DEFAULT_DECLINE_STORAGE_KEY = \"tempest:install-declined-at\";\n\nlet cachedEvent: BeforeInstallPromptEvent | null = null;\nconst eventSubscribers = new Set<(event: BeforeInstallPromptEvent | null) => void>();\n\nif (typeof window !== \"undefined\") {\n window.addEventListener(\"beforeinstallprompt\", (event: Event) => {\n event.preventDefault();\n cachedEvent = event as BeforeInstallPromptEvent;\n eventSubscribers.forEach((fn) => fn(cachedEvent));\n });\n window.addEventListener(\"appinstalled\", () => {\n cachedEvent = null;\n eventSubscribers.forEach((fn) => fn(null));\n });\n}\n\n/**\n * Strategy the UI should use to install the app:\n *\n * - `\"native\"`: trigger `BeforeInstallPromptEvent.prompt()`.\n * - `\"ios\"`: show iOS Safari Share → Add to Home Screen instructions.\n * - `\"manual\"`: show generic browser-menu instructions (Chromium forks that\n * strip the prompt API, plus the timeout fallback when no event arrives).\n * - `\"none\"`: nothing to offer (already installed or unsupported runtime).\n */\nexport type InstallMethod = \"native\" | \"ios\" | \"manual\" | \"none\";\n\n/** Options for {@link useInstallPrompt}. */\nexport interface UseInstallPromptOptions {\n /**\n * `localStorage` key used to persist the decline timestamp. Defaults to\n * `\"tempest:install-declined-at\"`.\n */\n declineStorageKey?: string;\n /**\n * How long, in ms, the install CTA stays hidden after the user declines.\n * Defaults to 7 days.\n */\n declineCooldownMs?: number;\n /**\n * How long, in ms, to wait for a `beforeinstallprompt` event before\n * resolving to the `\"manual\"` method. Defaults to `3000`.\n */\n manualFallbackDelayMs?: number;\n}\n\n/** State returned by {@link useInstallPrompt}. */\nexport interface UseInstallPromptResult {\n /** The cached `beforeinstallprompt` event, or `null` when unavailable. */\n deferredPrompt: BeforeInstallPromptEvent | null;\n /** True when the app can be installed through any supported method. */\n canInstall: boolean;\n /** True when running on iOS/iPadOS Safari. */\n isIOS: boolean;\n /** True when already running as an installed PWA. */\n isStandalone: boolean;\n /** True when the browser is an Android Chromium fork with no prompt API. */\n isManualAndroid: boolean;\n /** True when no `beforeinstallprompt` arrived within the timeout window. */\n promptTimedOut: boolean;\n /** The resolved install strategy the UI should follow. */\n method: InstallMethod;\n /** An `intent://` URL to re-open the page in Chrome on Android, else `null`. */\n openInChromeIntent: string | null;\n /**\n * Triggers the native prompt.\n *\n * @returns `true` when the user accepted the install, `false` otherwise.\n */\n install: () => Promise<boolean>;\n /** Records that the user declined the CTA, starting the cooldown window. */\n recordDecline: () => void;\n}\n\n/**\n * Whether a recorded decline is still inside its cooldown window.\n *\n * Reading is guarded because `localStorage.getItem` **throws** where this hook\n * matters most: Safari private mode and a cross-origin frame with storage\n * blocked. Unguarded, that exception escapes during render and takes the page\n * down — the install CTA is a courtesy, and no courtesy is worth a blank screen.\n *\n * @param key - Storage key holding the decline timestamp.\n * @param cooldownMs - How long a decline suppresses the CTA.\n * @returns Whether the CTA should stay hidden.\n */\nfunction readDecline(key: string, cooldownMs: number): boolean {\n if (typeof window === \"undefined\") return false;\n let raw: string | null;\n try {\n raw = window.localStorage.getItem(key);\n } catch {\n return false;\n }\n if (!raw) return false;\n const ts = Number(raw);\n if (!Number.isFinite(ts)) return false;\n return Date.now() - ts < cooldownMs;\n}\n\n/**\n * React hook that resolves how (and whether) to offer PWA installation.\n *\n * It caches the `beforeinstallprompt` event, detects iOS/iPadOS, detects\n * Android Chromium forks that lack the prompt API, detects standalone display\n * mode, and applies a decline cooldown persisted in `localStorage`. The\n * resulting `method` tells the UI which install affordance to render.\n *\n * Both sides of that persistence are best-effort: `localStorage` throws in\n * Safari private mode and in a cross-origin frame with storage blocked, and an\n * exception raised while resolving an install CTA would take the page down with\n * it. A refused read means \"no decline recorded\"; a refused write means the CTA\n * may come back next visit.\n *\n * The decline persistence is pluggable through\n * {@link UseInstallPromptOptions.declineStorageKey} and\n * {@link UseInstallPromptOptions.declineCooldownMs} — no app-specific storage\n * layer is required, and it is SSR-guarded.\n *\n * @param options - Optional storage key, cooldown, and fallback-delay tuning.\n * @returns The install state plus `install()` and `recordDecline()` actions.\n *\n * @example\n * const { method, install } = useInstallPrompt();\n * if (method === \"native\") return <button onClick={install}>Install</button>;\n */\nexport function useInstallPrompt(options: UseInstallPromptOptions = {}): UseInstallPromptResult {\n const {\n declineStorageKey = DEFAULT_DECLINE_STORAGE_KEY,\n declineCooldownMs = DEFAULT_DECLINE_COOLDOWN_MS,\n manualFallbackDelayMs = DEFAULT_MANUAL_FALLBACK_DELAY_MS,\n } = options;\n\n const [event, setEvent] = useState<BeforeInstallPromptEvent | null>(cachedEvent);\n const [standalone, setStandalone] = useState<boolean>(isStandalone());\n const [promptTimedOut, setPromptTimedOut] = useState<boolean>(false);\n\n useEffect(() => {\n eventSubscribers.add(setEvent);\n return () => {\n eventSubscribers.delete(setEvent);\n };\n }, []);\n\n useEffect(() => {\n if (typeof window === \"undefined\") return;\n const mq = window.matchMedia?.(\"(display-mode: standalone)\");\n const handler = (): void => setStandalone(isStandalone());\n mq?.addEventListener?.(\"change\", handler);\n window.addEventListener(\"appinstalled\", handler);\n return () => {\n mq?.removeEventListener?.(\"change\", handler);\n window.removeEventListener(\"appinstalled\", handler);\n };\n }, []);\n\n useEffect(() => {\n if (event) {\n setPromptTimedOut(false);\n return;\n }\n const timer = window.setTimeout(() => {\n if (!cachedEvent) setPromptTimedOut(true);\n }, manualFallbackDelayMs);\n return () => window.clearTimeout(timer);\n }, [event, manualFallbackDelayMs]);\n\n const ios = isIOS();\n const manualAndroid = isAndroidWithoutPromptApi();\n\n const declineActive = readDecline(declineStorageKey, declineCooldownMs);\n\n let method: InstallMethod = \"none\";\n if (!standalone && !declineActive) {\n if (event) method = \"native\";\n else if (ios) method = \"ios\";\n else if (manualAndroid || promptTimedOut) method = \"manual\";\n }\n\n const recordDecline = (): void => {\n if (typeof window === \"undefined\") return;\n try {\n window.localStorage.setItem(declineStorageKey, String(Date.now()));\n } catch {\n /* empty */\n }\n };\n\n const install = async (): Promise<boolean> => {\n if (!event) return false;\n await event.prompt();\n const choice = await event.userChoice;\n if (choice.outcome === \"dismissed\") recordDecline();\n cachedEvent = null;\n eventSubscribers.forEach((fn) => fn(null));\n return choice.outcome === \"accepted\";\n };\n\n return {\n deferredPrompt: event,\n canInstall: method !== \"none\",\n isIOS: ios,\n isStandalone: standalone,\n isManualAndroid: manualAndroid,\n promptTimedOut,\n method,\n openInChromeIntent: buildOpenInChromeIntent(),\n install,\n recordDecline,\n };\n}\n"],"mappings":"wDASA,IAAM,EAA8B,OAC9B,EAAmC,IACnC,EAA8B,8BAEhC,EAA+C,KAC7C,EAAmB,IAAI,IAEzB,OAAO,OAAW,MAClB,OAAO,iBAAiB,sBAAwB,GAAiB,CAC7D,EAAM,eAAe,EACrB,EAAc,EACd,EAAiB,QAAS,GAAO,EAAG,CAAW,CAAC,CACpD,CAAC,EACD,OAAO,iBAAiB,mBAAsB,CAC1C,EAAc,KACd,EAAiB,QAAS,GAAO,EAAG,IAAI,CAAC,CAC7C,CAAC,GAyEL,SAAS,EAAY,EAAa,EAA6B,CAC3D,GAAI,OAAO,OAAW,IAAa,MAAO,GAC1C,IAAI,EACJ,GAAI,CACA,EAAM,OAAO,aAAa,QAAQ,CAAG,CACzC,MAAQ,CACJ,MAAO,EACX,CACA,GAAI,CAAC,EAAK,MAAO,GACjB,IAAM,EAAK,OAAO,CAAG,EAErB,OADK,OAAO,SAAS,CAAE,EAChB,KAAK,IAAI,EAAI,EAAK,EADQ,EAErC,CA4BA,SAAgB,EAAiB,EAAmC,CAAC,EAA2B,CAC5F,GAAM,CACF,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,GACxB,EAEE,CAAC,EAAO,IAAA,EAAY,EAAA,SAAA,CAA0C,CAAW,EACzE,CAAC,EAAY,IAAA,EAAiB,EAAA,SAAA,CAAkB,EAAA,aAAa,CAAC,EAC9D,CAAC,EAAgB,IAAA,EAAqB,EAAA,SAAA,CAAkB,EAAK,GAEnE,EAAA,EAAA,UAAA,MACI,EAAiB,IAAI,CAAQ,MAChB,CACT,EAAiB,OAAO,CAAQ,CACpC,GACD,CAAC,CAAC,GAEL,EAAA,EAAA,UAAA,KAAgB,CACZ,GAAI,OAAO,OAAW,IAAa,OACnC,IAAM,EAAK,OAAO,aAAa,4BAA4B,EACrD,MAAsB,EAAc,EAAA,aAAa,CAAC,EAGxD,OAFA,GAAI,mBAAmB,SAAU,CAAO,EACxC,OAAO,iBAAiB,eAAgB,CAAO,MAClC,CACT,GAAI,sBAAsB,SAAU,CAAO,EAC3C,OAAO,oBAAoB,eAAgB,CAAO,CACtD,CACJ,EAAG,CAAC,CAAC,GAEL,EAAA,EAAA,UAAA,KAAgB,CACZ,GAAI,EAAO,CACP,EAAkB,EAAK,EACvB,MACJ,CACA,IAAM,EAAQ,OAAO,eAAiB,CAC7B,GAAa,EAAkB,EAAI,CAC5C,EAAG,CAAqB,EACxB,UAAa,OAAO,aAAa,CAAK,CAC1C,EAAG,CAAC,EAAO,CAAqB,CAAC,EAEjC,IAAM,EAAM,EAAA,MAAM,EACZ,EAAgB,EAAA,0BAA0B,EAE1C,EAAgB,EAAY,EAAmB,CAAiB,EAElE,EAAwB,OACxB,CAAC,GAAc,CAAC,IACZ,EAAO,EAAS,SACX,EAAK,EAAS,OACd,GAAiB,KAAgB,EAAS,WAGvD,IAAM,MAA4B,CAC1B,YAAO,OAAW,KACtB,GAAI,CACA,OAAO,aAAa,QAAQ,EAAmB,OAAO,KAAK,IAAI,CAAC,CAAC,CACrE,MAAQ,CAER,CACJ,EAYA,MAAO,CACH,eAAgB,EAChB,WAAY,IAAW,OACvB,MAAO,EACP,aAAc,EACd,gBAAiB,EACjB,iBACA,SACA,mBAAoB,EAAA,wBAAwB,EAC5C,iBAnB0C,CAC1C,GAAI,CAAC,EAAO,MAAO,GACnB,MAAM,EAAM,OAAO,EACnB,IAAM,EAAS,MAAM,EAAM,WAI3B,OAHI,EAAO,UAAY,aAAa,EAAc,EAClD,EAAc,KACd,EAAiB,QAAS,GAAO,EAAG,IAAI,CAAC,EAClC,EAAO,UAAY,UAC9B,EAYI,eACJ,CACJ"}
|
|
@@ -9,7 +9,12 @@ typeof window < "u" && (window.addEventListener("beforeinstallprompt", (e) => {
|
|
|
9
9
|
}));
|
|
10
10
|
function d(e, t) {
|
|
11
11
|
if (typeof window > "u") return !1;
|
|
12
|
-
let n
|
|
12
|
+
let n;
|
|
13
|
+
try {
|
|
14
|
+
n = window.localStorage.getItem(e);
|
|
15
|
+
} catch {
|
|
16
|
+
return !1;
|
|
17
|
+
}
|
|
13
18
|
if (!n) return !1;
|
|
14
19
|
let r = Number(n);
|
|
15
20
|
return Number.isFinite(r) ? Date.now() - r < t : !1;
|
|
@@ -37,7 +42,9 @@ function f(f = {}) {
|
|
|
37
42
|
let S = n(), C = t(), w = d(p, m), T = "none";
|
|
38
43
|
!v && !w && (g ? T = "native" : S ? T = "ios" : (C || b) && (T = "manual"));
|
|
39
44
|
let E = () => {
|
|
40
|
-
typeof window > "u"
|
|
45
|
+
if (!(typeof window > "u")) try {
|
|
46
|
+
window.localStorage.setItem(p, String(Date.now()));
|
|
47
|
+
} catch {}
|
|
41
48
|
};
|
|
42
49
|
return {
|
|
43
50
|
deferredPrompt: g,
|