@shware/workflow-ui 0.0.0-stage → 0.0.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/LICENSE +21 -0
- package/README.md +180 -2
- package/dist/assets/iphone-17-pro-DzaacWSl.png +0 -0
- package/dist/assets/pixel-10-pro-back-7MDj1_lz.webp +0 -0
- package/dist/assets/pixel-10-pro-mask-Bi1deQ9Y.webp +0 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +673 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/config.d.mts +247 -0
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +27 -0
- package/dist/config.mjs.map +1 -0
- package/dist/index.d.mts +451 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2722 -0
- package/dist/index.mjs.map +1 -0
- package/dist/postgres.d.mts +34 -0
- package/dist/postgres.d.mts.map +1 -0
- package/dist/postgres.mjs +313 -0
- package/dist/postgres.mjs.map +1 -0
- package/package.json +93 -3
- package/src/app/assets/devices/iphone-17-pro.png +0 -0
- package/src/app/assets/devices/pixel-10-pro-back.webp +0 -0
- package/src/app/assets/devices/pixel-10-pro-mask.webp +0 -0
- package/src/app/assets/flags/AC.svg +1 -0
- package/src/app/assets/flags/AD.svg +1 -0
- package/src/app/assets/flags/AE.svg +1 -0
- package/src/app/assets/flags/AF.svg +1 -0
- package/src/app/assets/flags/AG.svg +1 -0
- package/src/app/assets/flags/AI.svg +1 -0
- package/src/app/assets/flags/AL.svg +1 -0
- package/src/app/assets/flags/AM.svg +1 -0
- package/src/app/assets/flags/AO.svg +1 -0
- package/src/app/assets/flags/AQ.svg +1 -0
- package/src/app/assets/flags/AR.svg +1 -0
- package/src/app/assets/flags/AS.svg +1 -0
- package/src/app/assets/flags/AT.svg +1 -0
- package/src/app/assets/flags/AU.svg +1 -0
- package/src/app/assets/flags/AW.svg +1 -0
- package/src/app/assets/flags/AX.svg +1 -0
- package/src/app/assets/flags/AZ.svg +1 -0
- package/src/app/assets/flags/BA.svg +1 -0
- package/src/app/assets/flags/BB.svg +1 -0
- package/src/app/assets/flags/BD.svg +1 -0
- package/src/app/assets/flags/BE.svg +1 -0
- package/src/app/assets/flags/BF.svg +1 -0
- package/src/app/assets/flags/BG.svg +1 -0
- package/src/app/assets/flags/BH.svg +1 -0
- package/src/app/assets/flags/BI.svg +1 -0
- package/src/app/assets/flags/BJ.svg +1 -0
- package/src/app/assets/flags/BL.svg +1 -0
- package/src/app/assets/flags/BM.svg +1 -0
- package/src/app/assets/flags/BN.svg +1 -0
- package/src/app/assets/flags/BO.svg +1 -0
- package/src/app/assets/flags/BQ-BO.svg +1 -0
- package/src/app/assets/flags/BQ-SA.svg +1 -0
- package/src/app/assets/flags/BQ-SE.svg +1 -0
- package/src/app/assets/flags/BQ.svg +1 -0
- package/src/app/assets/flags/BR.svg +1 -0
- package/src/app/assets/flags/BS.svg +1 -0
- package/src/app/assets/flags/BT.svg +1 -0
- package/src/app/assets/flags/BV.svg +1 -0
- package/src/app/assets/flags/BW.svg +1 -0
- package/src/app/assets/flags/BY.svg +1 -0
- package/src/app/assets/flags/BZ.svg +1 -0
- package/src/app/assets/flags/CA.svg +1 -0
- package/src/app/assets/flags/CC.svg +1 -0
- package/src/app/assets/flags/CD.svg +1 -0
- package/src/app/assets/flags/CF.svg +1 -0
- package/src/app/assets/flags/CG.svg +1 -0
- package/src/app/assets/flags/CH.svg +1 -0
- package/src/app/assets/flags/CI.svg +1 -0
- package/src/app/assets/flags/CK.svg +1 -0
- package/src/app/assets/flags/CL.svg +1 -0
- package/src/app/assets/flags/CM.svg +1 -0
- package/src/app/assets/flags/CN.svg +1 -0
- package/src/app/assets/flags/CO.svg +1 -0
- package/src/app/assets/flags/CR.svg +1 -0
- package/src/app/assets/flags/CU.svg +1 -0
- package/src/app/assets/flags/CV.svg +1 -0
- package/src/app/assets/flags/CW.svg +1 -0
- package/src/app/assets/flags/CX.svg +1 -0
- package/src/app/assets/flags/CY.svg +1 -0
- package/src/app/assets/flags/CZ.svg +1 -0
- package/src/app/assets/flags/DE.svg +1 -0
- package/src/app/assets/flags/DJ.svg +1 -0
- package/src/app/assets/flags/DK.svg +1 -0
- package/src/app/assets/flags/DM.svg +1 -0
- package/src/app/assets/flags/DO.svg +1 -0
- package/src/app/assets/flags/DZ.svg +1 -0
- package/src/app/assets/flags/EC.svg +1 -0
- package/src/app/assets/flags/EE.svg +1 -0
- package/src/app/assets/flags/EG.svg +1 -0
- package/src/app/assets/flags/EH.svg +1 -0
- package/src/app/assets/flags/ER.svg +1 -0
- package/src/app/assets/flags/ES-CT.svg +1 -0
- package/src/app/assets/flags/ES.svg +1 -0
- package/src/app/assets/flags/ET.svg +1 -0
- package/src/app/assets/flags/EU.svg +1 -0
- package/src/app/assets/flags/FI.svg +1 -0
- package/src/app/assets/flags/FJ.svg +1 -0
- package/src/app/assets/flags/FK.svg +1 -0
- package/src/app/assets/flags/FM.svg +1 -0
- package/src/app/assets/flags/FO.svg +1 -0
- package/src/app/assets/flags/FR.svg +1 -0
- package/src/app/assets/flags/GA.svg +1 -0
- package/src/app/assets/flags/GB-ENG.svg +1 -0
- package/src/app/assets/flags/GB-NIR.svg +1 -0
- package/src/app/assets/flags/GB-SCT.svg +1 -0
- package/src/app/assets/flags/GB-WLS.svg +1 -0
- package/src/app/assets/flags/GB.svg +1 -0
- package/src/app/assets/flags/GD.svg +1 -0
- package/src/app/assets/flags/GE.svg +1 -0
- package/src/app/assets/flags/GF.svg +1 -0
- package/src/app/assets/flags/GG.svg +1 -0
- package/src/app/assets/flags/GH.svg +1 -0
- package/src/app/assets/flags/GI.svg +1 -0
- package/src/app/assets/flags/GL.svg +1 -0
- package/src/app/assets/flags/GM.svg +1 -0
- package/src/app/assets/flags/GN.svg +1 -0
- package/src/app/assets/flags/GP.svg +1 -0
- package/src/app/assets/flags/GQ.svg +1 -0
- package/src/app/assets/flags/GR.svg +1 -0
- package/src/app/assets/flags/GS.svg +1 -0
- package/src/app/assets/flags/GT.svg +1 -0
- package/src/app/assets/flags/GU.svg +1 -0
- package/src/app/assets/flags/GW.svg +1 -0
- package/src/app/assets/flags/GY.svg +1 -0
- package/src/app/assets/flags/HK.svg +1 -0
- package/src/app/assets/flags/HM.svg +1 -0
- package/src/app/assets/flags/HN.svg +1 -0
- package/src/app/assets/flags/HR.svg +1 -0
- package/src/app/assets/flags/HT.svg +1 -0
- package/src/app/assets/flags/HU.svg +1 -0
- package/src/app/assets/flags/IC.svg +1 -0
- package/src/app/assets/flags/ID.svg +1 -0
- package/src/app/assets/flags/IE.svg +1 -0
- package/src/app/assets/flags/IL.svg +1 -0
- package/src/app/assets/flags/IM.svg +1 -0
- package/src/app/assets/flags/IN.svg +1 -0
- package/src/app/assets/flags/IO.svg +1 -0
- package/src/app/assets/flags/IQ.svg +1 -0
- package/src/app/assets/flags/IR.svg +1 -0
- package/src/app/assets/flags/IS.svg +1 -0
- package/src/app/assets/flags/IT.svg +1 -0
- package/src/app/assets/flags/JE.svg +1 -0
- package/src/app/assets/flags/JM.svg +1 -0
- package/src/app/assets/flags/JO.svg +1 -0
- package/src/app/assets/flags/JP.svg +1 -0
- package/src/app/assets/flags/KE.svg +1 -0
- package/src/app/assets/flags/KG.svg +1 -0
- package/src/app/assets/flags/KH.svg +1 -0
- package/src/app/assets/flags/KI.svg +1 -0
- package/src/app/assets/flags/KM.svg +1 -0
- package/src/app/assets/flags/KN.svg +1 -0
- package/src/app/assets/flags/KP.svg +1 -0
- package/src/app/assets/flags/KR.svg +1 -0
- package/src/app/assets/flags/KW.svg +1 -0
- package/src/app/assets/flags/KY.svg +1 -0
- package/src/app/assets/flags/KZ.svg +1 -0
- package/src/app/assets/flags/LA.svg +1 -0
- package/src/app/assets/flags/LB.svg +1 -0
- package/src/app/assets/flags/LC.svg +1 -0
- package/src/app/assets/flags/LI.svg +1 -0
- package/src/app/assets/flags/LK.svg +1 -0
- package/src/app/assets/flags/LR.svg +1 -0
- package/src/app/assets/flags/LS.svg +1 -0
- package/src/app/assets/flags/LT.svg +1 -0
- package/src/app/assets/flags/LU.svg +1 -0
- package/src/app/assets/flags/LV.svg +1 -0
- package/src/app/assets/flags/LY.svg +1 -0
- package/src/app/assets/flags/MA.svg +1 -0
- package/src/app/assets/flags/MC.svg +1 -0
- package/src/app/assets/flags/MD.svg +1 -0
- package/src/app/assets/flags/ME.svg +1 -0
- package/src/app/assets/flags/MF.svg +1 -0
- package/src/app/assets/flags/MG.svg +1 -0
- package/src/app/assets/flags/MH.svg +1 -0
- package/src/app/assets/flags/MK.svg +1 -0
- package/src/app/assets/flags/ML.svg +1 -0
- package/src/app/assets/flags/MM.svg +1 -0
- package/src/app/assets/flags/MN.svg +1 -0
- package/src/app/assets/flags/MO.svg +1 -0
- package/src/app/assets/flags/MP.svg +1 -0
- package/src/app/assets/flags/MQ.svg +1 -0
- package/src/app/assets/flags/MR.svg +1 -0
- package/src/app/assets/flags/MS.svg +1 -0
- package/src/app/assets/flags/MT.svg +1 -0
- package/src/app/assets/flags/MU.svg +1 -0
- package/src/app/assets/flags/MV.svg +1 -0
- package/src/app/assets/flags/MW.svg +1 -0
- package/src/app/assets/flags/MX.svg +1 -0
- package/src/app/assets/flags/MY.svg +1 -0
- package/src/app/assets/flags/MZ.svg +1 -0
- package/src/app/assets/flags/NA.svg +1 -0
- package/src/app/assets/flags/NC.svg +1 -0
- package/src/app/assets/flags/NE.svg +1 -0
- package/src/app/assets/flags/NF.svg +1 -0
- package/src/app/assets/flags/NG.svg +1 -0
- package/src/app/assets/flags/NI.svg +1 -0
- package/src/app/assets/flags/NL.svg +1 -0
- package/src/app/assets/flags/NO.svg +1 -0
- package/src/app/assets/flags/NP.svg +1 -0
- package/src/app/assets/flags/NR.svg +1 -0
- package/src/app/assets/flags/NU.svg +1 -0
- package/src/app/assets/flags/NZ.svg +1 -0
- package/src/app/assets/flags/OM.svg +1 -0
- package/src/app/assets/flags/PA.svg +1 -0
- package/src/app/assets/flags/PE.svg +1 -0
- package/src/app/assets/flags/PF.svg +1 -0
- package/src/app/assets/flags/PG.svg +1 -0
- package/src/app/assets/flags/PH.svg +1 -0
- package/src/app/assets/flags/PK.svg +1 -0
- package/src/app/assets/flags/PL.svg +1 -0
- package/src/app/assets/flags/PM.svg +1 -0
- package/src/app/assets/flags/PN.svg +1 -0
- package/src/app/assets/flags/PR.svg +1 -0
- package/src/app/assets/flags/PS.svg +1 -0
- package/src/app/assets/flags/PT.svg +1 -0
- package/src/app/assets/flags/PW.svg +1 -0
- package/src/app/assets/flags/PY.svg +1 -0
- package/src/app/assets/flags/QA.svg +1 -0
- package/src/app/assets/flags/RE.svg +1 -0
- package/src/app/assets/flags/README.md +6 -0
- package/src/app/assets/flags/RO.svg +1 -0
- package/src/app/assets/flags/RS.svg +1 -0
- package/src/app/assets/flags/RU.svg +1 -0
- package/src/app/assets/flags/RW.svg +1 -0
- package/src/app/assets/flags/SA.svg +1 -0
- package/src/app/assets/flags/SB.svg +1 -0
- package/src/app/assets/flags/SC.svg +1 -0
- package/src/app/assets/flags/SD.svg +1 -0
- package/src/app/assets/flags/SE.svg +1 -0
- package/src/app/assets/flags/SG.svg +1 -0
- package/src/app/assets/flags/SH.svg +1 -0
- package/src/app/assets/flags/SI.svg +1 -0
- package/src/app/assets/flags/SJ.svg +1 -0
- package/src/app/assets/flags/SK.svg +1 -0
- package/src/app/assets/flags/SL.svg +1 -0
- package/src/app/assets/flags/SM.svg +1 -0
- package/src/app/assets/flags/SN.svg +1 -0
- package/src/app/assets/flags/SO.svg +1 -0
- package/src/app/assets/flags/SR.svg +1 -0
- package/src/app/assets/flags/SS.svg +1 -0
- package/src/app/assets/flags/ST.svg +1 -0
- package/src/app/assets/flags/SV.svg +1 -0
- package/src/app/assets/flags/SX.svg +1 -0
- package/src/app/assets/flags/SY.svg +1 -0
- package/src/app/assets/flags/SZ.svg +1 -0
- package/src/app/assets/flags/TA.svg +1 -0
- package/src/app/assets/flags/TC.svg +1 -0
- package/src/app/assets/flags/TD.svg +1 -0
- package/src/app/assets/flags/TF.svg +1 -0
- package/src/app/assets/flags/TG.svg +1 -0
- package/src/app/assets/flags/TH.svg +1 -0
- package/src/app/assets/flags/TJ.svg +1 -0
- package/src/app/assets/flags/TK.svg +1 -0
- package/src/app/assets/flags/TL.svg +1 -0
- package/src/app/assets/flags/TM.svg +1 -0
- package/src/app/assets/flags/TN.svg +1 -0
- package/src/app/assets/flags/TO.svg +1 -0
- package/src/app/assets/flags/TR.svg +1 -0
- package/src/app/assets/flags/TT.svg +1 -0
- package/src/app/assets/flags/TV.svg +1 -0
- package/src/app/assets/flags/TW.svg +1 -0
- package/src/app/assets/flags/TZ.svg +1 -0
- package/src/app/assets/flags/UA.svg +1 -0
- package/src/app/assets/flags/UG.svg +1 -0
- package/src/app/assets/flags/UM.svg +1 -0
- package/src/app/assets/flags/US.svg +1 -0
- package/src/app/assets/flags/UY.svg +1 -0
- package/src/app/assets/flags/UZ.svg +1 -0
- package/src/app/assets/flags/VA.svg +1 -0
- package/src/app/assets/flags/VC.svg +1 -0
- package/src/app/assets/flags/VE.svg +1 -0
- package/src/app/assets/flags/VG.svg +1 -0
- package/src/app/assets/flags/VI.svg +1 -0
- package/src/app/assets/flags/VN.svg +1 -0
- package/src/app/assets/flags/VU.svg +1 -0
- package/src/app/assets/flags/WF.svg +1 -0
- package/src/app/assets/flags/WS.svg +1 -0
- package/src/app/assets/flags/XA.svg +1 -0
- package/src/app/assets/flags/XC.svg +1 -0
- package/src/app/assets/flags/XK.svg +1 -0
- package/src/app/assets/flags/XO.svg +1 -0
- package/src/app/assets/flags/YE.svg +1 -0
- package/src/app/assets/flags/YT.svg +1 -0
- package/src/app/assets/flags/ZA.svg +1 -0
- package/src/app/assets/flags/ZM.svg +1 -0
- package/src/app/assets/flags/ZW.svg +1 -0
- package/src/app/email-preview.ts +46 -0
- package/src/app/index.css +203 -0
- package/src/app/index.html +12 -0
- package/src/app/integrations/i18n/react-i18next.d.ts +11 -0
- package/src/app/integrations/i18n/root-provider.tsx +62 -0
- package/src/app/integrations/tanstack-query/devtools.tsx +6 -0
- package/src/app/integrations/tanstack-query/root-provider.tsx +37 -0
- package/src/app/integrations/theme/root-provider.tsx +75 -0
- package/src/app/integrations/toast/toast-provider.tsx +46 -0
- package/src/app/locales/en-US/common.ts +268 -0
- package/src/app/locales/zh-CN/common.ts +263 -0
- package/src/app/main.tsx +40 -0
- package/src/app/page-chrome.tsx +79 -0
- package/src/app/router.tsx +40 -0
- package/src/app/routes/__root.tsx +293 -0
- package/src/app/routes/emails.tsx +199 -0
- package/src/app/routes/home.tsx +87 -0
- package/src/app/routes/index.ts +19 -0
- package/src/app/routes/metrics.tsx +541 -0
- package/src/app/routes/segment-overview.tsx +211 -0
- package/src/app/routes/segments.tsx +236 -0
- package/src/app/routes/settings.tsx +90 -0
- package/src/app/routes/workflows.tsx +348 -0
- package/src/app/studio.ts +16 -0
- package/src/app/svg.d.ts +17 -0
- package/src/app/virtual-config.d.ts +6 -0
- package/src/cli.ts +110 -0
- package/src/components/avatar.tsx +57 -0
- package/src/components/breadcrumb.tsx +49 -0
- package/src/components/button/index.tsx +86 -0
- package/src/components/channel-icon.ts +39 -0
- package/src/components/chat-markup.tsx +109 -0
- package/src/components/corner-shape.ts +13 -0
- package/src/components/date-range.tsx +181 -0
- package/src/components/discord-preview.tsx +165 -0
- package/src/components/dropdown/index.tsx +172 -0
- package/src/components/email-defaults.tsx +40 -0
- package/src/components/email-list.tsx +149 -0
- package/src/components/email-thumbnail.tsx +123 -0
- package/src/components/flag.tsx +40 -0
- package/src/components/input/index.tsx +40 -0
- package/src/components/input/search-input.tsx +24 -0
- package/src/components/layout.ts +403 -0
- package/src/components/menu/index.tsx +118 -0
- package/src/components/metric-card.tsx +321 -0
- package/src/components/modal/index.tsx +70 -0
- package/src/components/nav-drawer.tsx +84 -0
- package/src/components/node-inspector.tsx +242 -0
- package/src/components/profile-drawer.tsx +331 -0
- package/src/components/push-preview.tsx +470 -0
- package/src/components/push-thumbnail.tsx +78 -0
- package/src/components/segment-list.tsx +184 -0
- package/src/components/select/index.tsx +70 -0
- package/src/components/series-chart.tsx +120 -0
- package/src/components/slack-preview.tsx +223 -0
- package/src/components/sparkline.tsx +58 -0
- package/src/components/tabs/index.tsx +45 -0
- package/src/components/template-refs.ts +110 -0
- package/src/components/templates-page.tsx +601 -0
- package/src/components/textarea/index.tsx +37 -0
- package/src/components/thumbnail-window.tsx +65 -0
- package/src/components/workflow-canvas.tsx +503 -0
- package/src/components/workflow-list.tsx +231 -0
- package/src/config.ts +288 -0
- package/src/generate.ts +56 -0
- package/src/index.ts +35 -0
- package/src/postgres.ts +415 -0
- package/src/server/project.ts +290 -0
- package/src/server.ts +500 -0
- package/src/utils/cn.ts +6 -0
- package/src/utils/label.ts +12 -0
- package/src/utils/lookup.ts +11 -0
- package/src/utils/template-content.ts +213 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FloatingFocusManager,
|
|
3
|
+
autoUpdate,
|
|
4
|
+
flip,
|
|
5
|
+
offset,
|
|
6
|
+
size,
|
|
7
|
+
useClick,
|
|
8
|
+
useDismiss,
|
|
9
|
+
useFloating,
|
|
10
|
+
useInteractions,
|
|
11
|
+
useListNavigation,
|
|
12
|
+
useRole,
|
|
13
|
+
} from '@floating-ui/react';
|
|
14
|
+
import { Check, ChevronDown, type LucideIcon } from 'lucide-react';
|
|
15
|
+
import { useRef, useState } from 'react';
|
|
16
|
+
import { cn } from '../../utils/cn';
|
|
17
|
+
import { Button } from '../button';
|
|
18
|
+
import { superellipse } from '../corner-shape';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Custom select for header switchers, built on floating-ui rather than a
|
|
22
|
+
* native `<select>`: the options carry a second, de-emphasised description
|
|
23
|
+
* line, which native popups cannot render. The trigger is deliberately
|
|
24
|
+
* flat — no fill until hover — so it reads as part of the header, not a form.
|
|
25
|
+
*/
|
|
26
|
+
export interface DropdownOption {
|
|
27
|
+
value: string;
|
|
28
|
+
label: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Leading glyph, echoed on the trigger for the selected option. Optional
|
|
32
|
+
* because a set with no natural iconography (Daily / Weekly / Monthly) is
|
|
33
|
+
* better bare than fitted with a decorative stand-in.
|
|
34
|
+
*/
|
|
35
|
+
icon?: LucideIcon;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface Props {
|
|
39
|
+
value?: string;
|
|
40
|
+
options: DropdownOption[];
|
|
41
|
+
onChange?: (value: string) => void;
|
|
42
|
+
placeholder?: string;
|
|
43
|
+
className?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function Dropdown({ value, options, onChange, placeholder, className }: Props) {
|
|
47
|
+
const [open, setOpen] = useState(false);
|
|
48
|
+
const [activeIndex, setActiveIndex] = useState<number | null>(null);
|
|
49
|
+
|
|
50
|
+
const { refs, floatingStyles, context } = useFloating({
|
|
51
|
+
open,
|
|
52
|
+
onOpenChange: setOpen,
|
|
53
|
+
placement: 'bottom-start',
|
|
54
|
+
whileElementsMounted: autoUpdate,
|
|
55
|
+
middleware: [
|
|
56
|
+
offset(4),
|
|
57
|
+
flip({ padding: 8 }),
|
|
58
|
+
size({
|
|
59
|
+
padding: 8,
|
|
60
|
+
apply({ availableHeight, elements }) {
|
|
61
|
+
elements.floating.style.maxHeight = `${Math.max(160, availableHeight)}px`;
|
|
62
|
+
},
|
|
63
|
+
}),
|
|
64
|
+
],
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const listRef = useRef<(HTMLElement | null)[]>([]);
|
|
68
|
+
const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([
|
|
69
|
+
useClick(context),
|
|
70
|
+
useDismiss(context),
|
|
71
|
+
useRole(context, { role: 'listbox' }),
|
|
72
|
+
useListNavigation(context, { listRef, activeIndex, onNavigate: setActiveIndex }),
|
|
73
|
+
]);
|
|
74
|
+
|
|
75
|
+
const selected = options.find((option) => option.value === value);
|
|
76
|
+
const SelectedIcon = selected?.icon;
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<>
|
|
80
|
+
<Button
|
|
81
|
+
ref={refs.setReference}
|
|
82
|
+
size="sm"
|
|
83
|
+
variant="outline"
|
|
84
|
+
className={cn(
|
|
85
|
+
/* `Button` is medium by default; a switcher reads as a value, not a command. */
|
|
86
|
+
'min-w-0 justify-between gap-1.5 font-normal',
|
|
87
|
+
selected === undefined && 'text-placeholder',
|
|
88
|
+
className
|
|
89
|
+
)}
|
|
90
|
+
{...getReferenceProps()}
|
|
91
|
+
>
|
|
92
|
+
{/* Icon and label travel together; `justify-between` only pushes the chevron away. */}
|
|
93
|
+
<span className="flex min-w-0 items-center gap-1.5">
|
|
94
|
+
{SelectedIcon !== undefined && (
|
|
95
|
+
<SelectedIcon
|
|
96
|
+
size={16}
|
|
97
|
+
strokeWidth={2}
|
|
98
|
+
aria-hidden
|
|
99
|
+
className="text-secondary shrink-0"
|
|
100
|
+
/>
|
|
101
|
+
)}
|
|
102
|
+
<span className="truncate">{selected?.label ?? placeholder}</span>
|
|
103
|
+
</span>
|
|
104
|
+
<ChevronDown size={16} strokeWidth={2} aria-hidden className="text-secondary shrink-0" />
|
|
105
|
+
</Button>
|
|
106
|
+
{open && (
|
|
107
|
+
<FloatingFocusManager context={context} modal={false}>
|
|
108
|
+
<div
|
|
109
|
+
ref={refs.setFloating}
|
|
110
|
+
style={floatingStyles}
|
|
111
|
+
className={cn(
|
|
112
|
+
'border-border bg-card z-50 max-w-96 min-w-64 overflow-y-auto rounded-xl border p-1',
|
|
113
|
+
'shadow-card-shadow shadow-lg'
|
|
114
|
+
)}
|
|
115
|
+
{...getFloatingProps()}
|
|
116
|
+
>
|
|
117
|
+
{options.map((option, index) => {
|
|
118
|
+
const OptionIcon = option.icon;
|
|
119
|
+
const isSelected = option.value === value;
|
|
120
|
+
return (
|
|
121
|
+
<button
|
|
122
|
+
key={option.value}
|
|
123
|
+
type="button"
|
|
124
|
+
ref={(node) => {
|
|
125
|
+
listRef.current[index] = node;
|
|
126
|
+
}}
|
|
127
|
+
role="option"
|
|
128
|
+
aria-selected={isSelected}
|
|
129
|
+
tabIndex={activeIndex === index ? 0 : -1}
|
|
130
|
+
className={cn(
|
|
131
|
+
'flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left',
|
|
132
|
+
activeIndex === index && 'bg-selected'
|
|
133
|
+
)}
|
|
134
|
+
style={superellipse}
|
|
135
|
+
{...getItemProps({
|
|
136
|
+
onClick() {
|
|
137
|
+
onChange?.(option.value);
|
|
138
|
+
setOpen(false);
|
|
139
|
+
},
|
|
140
|
+
})}
|
|
141
|
+
>
|
|
142
|
+
{OptionIcon !== undefined && (
|
|
143
|
+
<OptionIcon
|
|
144
|
+
size={16}
|
|
145
|
+
strokeWidth={2}
|
|
146
|
+
aria-hidden
|
|
147
|
+
className="text-secondary shrink-0"
|
|
148
|
+
/>
|
|
149
|
+
)}
|
|
150
|
+
<span className="min-w-0 flex-1">
|
|
151
|
+
{/* One weight for every option: the accent check is what
|
|
152
|
+
marks the current value, and a bolder label on top of
|
|
153
|
+
it says the same thing twice. */}
|
|
154
|
+
<span className="text-primary block truncate text-sm">{option.label}</span>
|
|
155
|
+
{option.description !== undefined && option.description !== '' && (
|
|
156
|
+
<span className="text-muted block truncate text-xs">
|
|
157
|
+
{option.description}
|
|
158
|
+
</span>
|
|
159
|
+
)}
|
|
160
|
+
</span>
|
|
161
|
+
{isSelected && (
|
|
162
|
+
<Check size={16} strokeWidth={2} aria-hidden className="text-accent shrink-0" />
|
|
163
|
+
)}
|
|
164
|
+
</button>
|
|
165
|
+
);
|
|
166
|
+
})}
|
|
167
|
+
</div>
|
|
168
|
+
</FloatingFocusManager>
|
|
169
|
+
)}
|
|
170
|
+
</>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useTranslation } from 'react-i18next';
|
|
2
|
+
import { superellipse } from './corner-shape';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The envelope every email goes out with: `emails.from` / `replyTo` in
|
|
6
|
+
* workflow.config.ts. Read-only — the config is where it changes; the studio
|
|
7
|
+
* refreshes when it does.
|
|
8
|
+
*/
|
|
9
|
+
export interface EmailDefaultsProps {
|
|
10
|
+
from?: string | undefined;
|
|
11
|
+
replyTo?: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function EmailDefaults({ from, replyTo }: EmailDefaultsProps) {
|
|
15
|
+
const { t } = useTranslation();
|
|
16
|
+
const rows = [
|
|
17
|
+
{ label: t('emails.from'), value: from },
|
|
18
|
+
{ label: t('emails.replyTo'), value: replyTo },
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<section
|
|
23
|
+
className="border-border bg-card mt-4 max-w-xl rounded-2xl border p-5"
|
|
24
|
+
style={superellipse}
|
|
25
|
+
>
|
|
26
|
+
<h2 className="text-sm font-medium">{t('settings.emailDefaults')}</h2>
|
|
27
|
+
<p className="text-muted mt-1 text-xs">{t('settings.emailDefaultsHint')}</p>
|
|
28
|
+
<dl className="mt-3 grid grid-cols-[max-content_1fr] gap-x-8 gap-y-2 text-sm">
|
|
29
|
+
{rows.map((row) => (
|
|
30
|
+
<div key={row.label} className="contents">
|
|
31
|
+
<dt className="text-muted">{row.label}</dt>
|
|
32
|
+
<dd className="text-secondary min-w-0 truncate">
|
|
33
|
+
{row.value ?? t('common.notConfigured')}
|
|
34
|
+
</dd>
|
|
35
|
+
</div>
|
|
36
|
+
))}
|
|
37
|
+
</dl>
|
|
38
|
+
</section>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
|
+
import { Bell, Mail, MessageCircle, MessagesSquare } from 'lucide-react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { displayName } from '../utils/label';
|
|
5
|
+
import { superellipse } from './corner-shape';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The templates list, mirroring the workflows table: one row per template with
|
|
9
|
+
* its label and whether content is registered for it. The key the DSL knows it
|
|
10
|
+
* by is still what the search matches.
|
|
11
|
+
*/
|
|
12
|
+
export interface EmailListItem {
|
|
13
|
+
/** Wire key: how workflows reference the template. Identity, not a label. */
|
|
14
|
+
key: string;
|
|
15
|
+
/** Channel from the referencing IR node; picks the row icon. */
|
|
16
|
+
channel?: string;
|
|
17
|
+
/** Human label from the registered module; the list shows this. */
|
|
18
|
+
name?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
/** False when a workflow references the key but no module is registered. */
|
|
21
|
+
registered: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface EmailListProps {
|
|
25
|
+
items: EmailListItem[];
|
|
26
|
+
/** The channel says which registry: one key can name an email and a push. */
|
|
27
|
+
onOpen: (key: string, channel: string | undefined) => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
* Not pinned: the app header is the only sticky chrome, so the head scrolls
|
|
32
|
+
* away with the rows and needs no opaque fill of its own. The radii stay —
|
|
33
|
+
* the card has no `overflow` to clip with, so its top corners are cut here.
|
|
34
|
+
*/
|
|
35
|
+
const HEAD_CELL = 'border-border border-b py-3 first:rounded-tl-2xl last:rounded-tr-2xl';
|
|
36
|
+
/* The row carries the border below md, so the cells drop theirs there. */
|
|
37
|
+
const CELL = 'border-border border-b py-4 max-md:border-b-0 max-md:px-3';
|
|
38
|
+
|
|
39
|
+
/* The template channels, each with its glyph — the same ones `channel-icon.ts` hands the analytics views. */
|
|
40
|
+
function RowIcon({ channel }: { channel: string | undefined }) {
|
|
41
|
+
const Icon =
|
|
42
|
+
channel === 'push'
|
|
43
|
+
? Bell
|
|
44
|
+
: channel === 'discord'
|
|
45
|
+
? MessageCircle
|
|
46
|
+
: channel === 'slack'
|
|
47
|
+
? MessagesSquare
|
|
48
|
+
: Mail;
|
|
49
|
+
return <Icon className="text-muted mt-0.5 size-4 shrink-0" strokeWidth={2} />;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function EmailList({ items, onOpen }: EmailListProps) {
|
|
53
|
+
const { t } = useTranslation();
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
/*
|
|
57
|
+
* No `overflow` on the card, deliberately: any value at all turns it into
|
|
58
|
+
* a scrollport of its own and draws a second bar inset inside the border —
|
|
59
|
+
* the page is the one scroller (see __root). Nothing clips, so the corners
|
|
60
|
+
* are re-cut on the first and last cells below.
|
|
61
|
+
*/
|
|
62
|
+
<div className="border-border bg-card rounded-2xl border" style={superellipse}>
|
|
63
|
+
<table className="w-full table-fixed border-separate border-spacing-0 text-sm max-md:block">
|
|
64
|
+
<thead className="max-md:hidden">
|
|
65
|
+
<tr className="text-muted text-left text-xs font-medium">
|
|
66
|
+
<th className={clsx(HEAD_CELL, 'min-w-0 px-6')} style={superellipse}>
|
|
67
|
+
{t('common.name')}
|
|
68
|
+
</th>
|
|
69
|
+
<th className={clsx(HEAD_CELL, 'w-28 px-3')} style={superellipse} />
|
|
70
|
+
</tr>
|
|
71
|
+
</thead>
|
|
72
|
+
<tbody className="max-md:block">
|
|
73
|
+
{items.map((item) => (
|
|
74
|
+
<tr
|
|
75
|
+
key={`${item.channel ?? ''}:${item.key}`}
|
|
76
|
+
onClick={() => onOpen(item.key, item.channel)}
|
|
77
|
+
/*
|
|
78
|
+
* On desktop the hover fill lives on the cells, not the row: a
|
|
79
|
+
* row box paints its background underneath them, where no cell
|
|
80
|
+
* radius reaches it, so the last row would poke square grey
|
|
81
|
+
* corners out of the unclipped card. Below md the row is an
|
|
82
|
+
* ordinary grid box and takes both itself.
|
|
83
|
+
*/
|
|
84
|
+
className={clsx(
|
|
85
|
+
'cursor-pointer align-top [&>td]:transition-colors',
|
|
86
|
+
/* Below md the row leaves table layout and becomes the card's
|
|
87
|
+
own grid, so the fill and the radius live on it there. */
|
|
88
|
+
'max-md:grid max-md:grid-cols-6 max-md:border-b max-md:px-3',
|
|
89
|
+
'border-border max-md:first:rounded-t-2xl max-md:last:rounded-b-2xl',
|
|
90
|
+
'max-md:hover:bg-hover max-md:last:border-b-0',
|
|
91
|
+
'md:hover:[&>td]:bg-hover last:[&>td]:border-b-0',
|
|
92
|
+
'md:last:[&>td:first-child]:rounded-bl-2xl',
|
|
93
|
+
'md:last:[&>td:last-child]:rounded-br-2xl'
|
|
94
|
+
)}
|
|
95
|
+
style={superellipse}
|
|
96
|
+
>
|
|
97
|
+
<td
|
|
98
|
+
className={clsx(CELL, 'px-6 max-md:order-1 max-md:col-span-6 max-md:pb-2')}
|
|
99
|
+
style={superellipse}
|
|
100
|
+
>
|
|
101
|
+
<div className="flex items-start gap-3">
|
|
102
|
+
<RowIcon channel={item.channel} />
|
|
103
|
+
<div className="min-w-0">
|
|
104
|
+
<div
|
|
105
|
+
className={clsx(
|
|
106
|
+
'font-medium',
|
|
107
|
+
item.name === undefined ? 'text-muted italic' : 'text-primary'
|
|
108
|
+
)}
|
|
109
|
+
>
|
|
110
|
+
{displayName(item.name, t('common.untitled'))}
|
|
111
|
+
</div>
|
|
112
|
+
{item.description !== undefined && (
|
|
113
|
+
<p className="text-muted mt-1 truncate text-sm">{item.description}</p>
|
|
114
|
+
)}
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
</td>
|
|
118
|
+
|
|
119
|
+
<td
|
|
120
|
+
className={clsx(
|
|
121
|
+
CELL,
|
|
122
|
+
'px-3 max-md:order-3 max-md:col-span-6 max-md:pt-0 max-md:pb-4'
|
|
123
|
+
)}
|
|
124
|
+
style={superellipse}
|
|
125
|
+
>
|
|
126
|
+
<span
|
|
127
|
+
className={clsx(
|
|
128
|
+
'inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium whitespace-nowrap',
|
|
129
|
+
item.registered
|
|
130
|
+
? 'bg-green-50 text-green-700 dark:bg-green-400/10 dark:text-green-300'
|
|
131
|
+
: 'bg-amber-100 text-amber-700 dark:bg-amber-400/10 dark:text-amber-300'
|
|
132
|
+
)}
|
|
133
|
+
>
|
|
134
|
+
<span
|
|
135
|
+
className={clsx(
|
|
136
|
+
'size-1.5 rounded-full',
|
|
137
|
+
item.registered ? 'bg-green-500' : 'bg-amber-500'
|
|
138
|
+
)}
|
|
139
|
+
/>
|
|
140
|
+
{item.registered ? t('emails.ready') : t('emails.noContent')}
|
|
141
|
+
</span>
|
|
142
|
+
</td>
|
|
143
|
+
</tr>
|
|
144
|
+
))}
|
|
145
|
+
</tbody>
|
|
146
|
+
</table>
|
|
147
|
+
</div>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { useLayoutEffect, useRef, useState } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { ThumbnailStatus, ThumbnailWindow } from './thumbnail-window';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Dark-mode simulation for a rendered email: emails are authored light, so a
|
|
7
|
+
* dark stage inverts the document and re-inverts imagery. Shared with the
|
|
8
|
+
* templates page so the thumbnail and the full preview agree.
|
|
9
|
+
*/
|
|
10
|
+
export const DARK_SIMULATION =
|
|
11
|
+
'<style>html{background:#fff;filter:invert(0.92) hue-rotate(180deg)}img,video{filter:invert(1) hue-rotate(180deg)}</style>';
|
|
12
|
+
|
|
13
|
+
/** The window scrolls the document; the frame itself must never scroll inside it. */
|
|
14
|
+
const NO_SCROLL = '<style>html,body{overflow:hidden}</style>';
|
|
15
|
+
|
|
16
|
+
/** Emails are laid out for this width; the thumbnail scales that down, never reflows it. */
|
|
17
|
+
const EMAIL_WIDTH = 600;
|
|
18
|
+
|
|
19
|
+
export interface EmailThumbnailProps {
|
|
20
|
+
/** Rendered HTML; absent while loading, on error, or when nothing is registered. */
|
|
21
|
+
html?: string | undefined;
|
|
22
|
+
loading: boolean;
|
|
23
|
+
error?: string | undefined;
|
|
24
|
+
/** False when the IR references a template the email registry does not register. */
|
|
25
|
+
registered: boolean;
|
|
26
|
+
scheme: 'light' | 'dark';
|
|
27
|
+
/** Open the full preview — the button under the window. */
|
|
28
|
+
onOpen: () => void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The email at postage-stamp size: the document renders at its native width
|
|
33
|
+
* in a sandboxed frame and is scaled to the card, so what shows is exactly
|
|
34
|
+
* what the templates page shows, only smaller. The window scrolls through the
|
|
35
|
+
* whole email; a button beneath it opens the full preview.
|
|
36
|
+
*/
|
|
37
|
+
export function EmailThumbnail({
|
|
38
|
+
html,
|
|
39
|
+
loading,
|
|
40
|
+
error,
|
|
41
|
+
registered,
|
|
42
|
+
scheme,
|
|
43
|
+
onOpen,
|
|
44
|
+
}: EmailThumbnailProps) {
|
|
45
|
+
const { t } = useTranslation();
|
|
46
|
+
const boxRef = useRef<HTMLDivElement>(null);
|
|
47
|
+
const [box, setBox] = useState<{ width: number; height: number }>();
|
|
48
|
+
/* Native document height, read once the frame has laid out. */
|
|
49
|
+
const [docHeight, setDocHeight] = useState<number>();
|
|
50
|
+
|
|
51
|
+
/* The scale follows the window's inner width; measure rather than assume it. */
|
|
52
|
+
useLayoutEffect(() => {
|
|
53
|
+
const element = boxRef.current;
|
|
54
|
+
if (element === null) return;
|
|
55
|
+
const measure = () => setBox({ width: element.clientWidth, height: element.clientHeight });
|
|
56
|
+
measure();
|
|
57
|
+
const observer = new ResizeObserver(measure);
|
|
58
|
+
observer.observe(element);
|
|
59
|
+
return () => observer.disconnect();
|
|
60
|
+
}, []);
|
|
61
|
+
|
|
62
|
+
const scale = box === undefined ? undefined : box.width / EMAIL_WIDTH;
|
|
63
|
+
let status: string | undefined;
|
|
64
|
+
if (!registered) status = t('emails.notRegistered');
|
|
65
|
+
else if (error !== undefined) status = error;
|
|
66
|
+
else if (loading || html === undefined) status = t('emails.rendering');
|
|
67
|
+
|
|
68
|
+
/* Until the document reports its height, fill the window so the first paint is not blank. */
|
|
69
|
+
const frameHeight =
|
|
70
|
+
box === undefined || scale === undefined
|
|
71
|
+
? 0
|
|
72
|
+
: Math.max(docHeight ?? 0, Math.ceil(box.height / scale));
|
|
73
|
+
/*
|
|
74
|
+
* The wrapper only grows for a document taller than the window. Otherwise it
|
|
75
|
+
* fills exactly and clips the frame's rounding: the ceil above leaves a
|
|
76
|
+
* fraction of a pixel that would otherwise read as overflow and show a bar.
|
|
77
|
+
*/
|
|
78
|
+
const contentHeight = docHeight !== undefined && scale !== undefined ? docHeight * scale : 0;
|
|
79
|
+
const wrapperHeight =
|
|
80
|
+
box !== undefined && contentHeight > box.height + 1 ? contentHeight : '100%';
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<ThumbnailWindow
|
|
84
|
+
ref={boxRef}
|
|
85
|
+
className="overflow-x-hidden overflow-y-auto"
|
|
86
|
+
style={{ backgroundColor: scheme === 'dark' ? '#161616' : '#fff' }}
|
|
87
|
+
onOpen={registered ? onOpen : undefined}
|
|
88
|
+
>
|
|
89
|
+
{status !== undefined ? (
|
|
90
|
+
<ThumbnailStatus tone={error !== undefined ? 'error' : 'muted'}>
|
|
91
|
+
<span className="whitespace-pre-line">{status}</span>
|
|
92
|
+
</ThumbnailStatus>
|
|
93
|
+
) : (
|
|
94
|
+
scale !== undefined && (
|
|
95
|
+
/* Sized to the scaled document, so the window scrolls the whole email. */
|
|
96
|
+
<div className="overflow-hidden" style={{ height: wrapperHeight }}>
|
|
97
|
+
<iframe
|
|
98
|
+
title={t('inspector.openTemplate')}
|
|
99
|
+
srcDoc={`${html}${scheme === 'dark' ? DARK_SIMULATION : ''}${NO_SCROLL}`}
|
|
100
|
+
/*
|
|
101
|
+
* Same-origin so the document's height is readable; no
|
|
102
|
+
* allow-scripts, so nothing in it runs. A picture of a document.
|
|
103
|
+
*/
|
|
104
|
+
sandbox="allow-same-origin"
|
|
105
|
+
tabIndex={-1}
|
|
106
|
+
aria-hidden
|
|
107
|
+
onLoad={(event) => {
|
|
108
|
+
const height = event.currentTarget.contentDocument?.documentElement.scrollHeight;
|
|
109
|
+
if (height !== undefined && height > 0) setDocHeight(height);
|
|
110
|
+
}}
|
|
111
|
+
className="pointer-events-none block origin-top-left border-0"
|
|
112
|
+
style={{
|
|
113
|
+
width: EMAIL_WIDTH,
|
|
114
|
+
height: frameHeight,
|
|
115
|
+
transform: `scale(${scale})`,
|
|
116
|
+
}}
|
|
117
|
+
/>
|
|
118
|
+
</div>
|
|
119
|
+
)
|
|
120
|
+
)}
|
|
121
|
+
</ThumbnailWindow>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type ComponentType, type SVGProps, useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Country flags, lazy per code: 265 SVGs live in the glob, and eagerly
|
|
5
|
+
* bundling a megabyte of vector flags for the one or two a drawer shows would
|
|
6
|
+
* be absurd. Each flag module loads on first render of its code and is cached
|
|
7
|
+
* by the module system from then on. vite-only (glob + svgr) — this component
|
|
8
|
+
* is app-internal and deliberately not part of the library exports.
|
|
9
|
+
*/
|
|
10
|
+
const FLAGS = import.meta.glob<ComponentType<SVGProps<SVGSVGElement>>>(
|
|
11
|
+
'../app/assets/flags/*.svg',
|
|
12
|
+
{ query: '?react', import: 'default' }
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export interface FlagProps {
|
|
16
|
+
/** ISO 3166-1 alpha-2, case-insensitive. Unknown codes render nothing. */
|
|
17
|
+
code: string;
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function Flag({ code, className }: FlagProps) {
|
|
22
|
+
const [Component, setComponent] = useState<ComponentType<SVGProps<SVGSVGElement>> | undefined>(
|
|
23
|
+
undefined
|
|
24
|
+
);
|
|
25
|
+
const load = FLAGS[`../app/assets/flags/${code.toUpperCase()}.svg`];
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
let alive = true;
|
|
29
|
+
setComponent(undefined);
|
|
30
|
+
void load?.().then((mod) => {
|
|
31
|
+
if (alive) setComponent(() => mod);
|
|
32
|
+
});
|
|
33
|
+
return () => {
|
|
34
|
+
alive = false;
|
|
35
|
+
};
|
|
36
|
+
}, [load]);
|
|
37
|
+
|
|
38
|
+
if (Component === undefined) return null;
|
|
39
|
+
return <Component className={className} aria-hidden />;
|
|
40
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import { cn } from '../../utils/cn';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Ported from the design system in the template project — same API, so the two
|
|
6
|
+
* stay diffable. Colours resolve through the studio's CSS variables
|
|
7
|
+
* (`--color-textfield`, `--color-placeholder`, `--color-accent`).
|
|
8
|
+
*/
|
|
9
|
+
export type Size = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
10
|
+
|
|
11
|
+
interface Props extends Omit<ComponentProps<'input'>, 'size'> {
|
|
12
|
+
size?: Size;
|
|
13
|
+
htmlSize?: number;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const SIZE_STYLE: Record<Size, string> = {
|
|
18
|
+
xs: 'h-7 px-2 text-xs rounded-md focus-visible:ring-2',
|
|
19
|
+
sm: 'h-9 px-2 text-sm rounded-lg focus-visible:ring-3',
|
|
20
|
+
md: 'h-10 px-3 text-sm rounded-xl focus-visible:ring-3',
|
|
21
|
+
lg: 'h-12 px-4 text-md rounded-xl focus-visible:ring-4',
|
|
22
|
+
xl: 'h-14 px-4 text-lg rounded-2xl focus-visible:ring-4',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export function Input({ size = 'md', type = 'text', htmlSize, className, ...props }: Props) {
|
|
26
|
+
return (
|
|
27
|
+
<input
|
|
28
|
+
{...props}
|
|
29
|
+
type={type}
|
|
30
|
+
size={htmlSize}
|
|
31
|
+
className={cn(
|
|
32
|
+
'transition-colors duration-100 focus:outline-none',
|
|
33
|
+
'placeholder-placeholder bg-textfield focus-visible:border-accent border',
|
|
34
|
+
'dark:focus-visible:ring-accent/50 focus-visible:ring-accent/40',
|
|
35
|
+
SIZE_STYLE[size],
|
|
36
|
+
className
|
|
37
|
+
)}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Search } from 'lucide-react';
|
|
2
|
+
import type { ComponentProps } from 'react';
|
|
3
|
+
import { cn } from '../../utils/cn';
|
|
4
|
+
import { Input, type Size } from './index';
|
|
5
|
+
|
|
6
|
+
interface Props extends Omit<ComponentProps<'input'>, 'size' | 'type'> {
|
|
7
|
+
size?: Size;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** The list pages' search field: an `Input` with the studio's standard 16px glass. */
|
|
12
|
+
export function SearchInput({ size = 'sm', className, ...props }: Props) {
|
|
13
|
+
return (
|
|
14
|
+
<div className={cn('relative', className)}>
|
|
15
|
+
<Search
|
|
16
|
+
size={16}
|
|
17
|
+
strokeWidth={2}
|
|
18
|
+
aria-hidden
|
|
19
|
+
className="text-muted pointer-events-none absolute top-1/2 left-2.5 -translate-y-1/2"
|
|
20
|
+
/>
|
|
21
|
+
<Input {...props} size={size} type="search" className="w-full rounded-full pl-8" />
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
24
|
+
}
|