@waveinno/ui 0.2.0 → 0.4.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/CHANGELOG.md +33 -0
- package/README.md +30 -12
- package/dist/components/brand/waveinno-logo.js +1 -1
- package/dist/components/charts/bar-list.js +1 -1
- package/dist/components/charts/heatmap.js +1 -1
- package/dist/components/patterns/activity-feed.js +1 -1
- package/dist/components/patterns/app-launcher.js +1 -1
- package/dist/components/patterns/data-table-edit.js +1 -1
- package/dist/components/patterns/data-table-filters.js +1 -1
- package/dist/components/patterns/data-table.js +1 -1
- package/dist/components/patterns/page-header.js +1 -1
- package/dist/components/patterns/page-hero.js +1 -1
- package/dist/components/patterns/stat-card.js +1 -1
- package/dist/components/patterns/timeline.js +1 -1
- package/dist/components/ui/alert.d.ts +28 -0
- package/dist/components/ui/alert.js +1 -0
- package/dist/components/ui/avatar.js +1 -1
- package/dist/components/ui/badge.js +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/combobox.js +1 -1
- package/dist/components/ui/confirm-dialog.js +1 -1
- package/dist/components/ui/dialog.js +1 -1
- package/dist/components/ui/dropdown-menu.js +1 -1
- package/dist/components/ui/file-upload.d.ts +36 -0
- package/dist/components/ui/file-upload.js +1 -0
- package/dist/components/ui/index.d.ts +11 -1
- package/dist/components/ui/index.js +1 -1
- package/dist/components/ui/kbd.d.ts +13 -0
- package/dist/components/ui/kbd.js +1 -0
- package/dist/components/ui/menu.js +1 -1
- package/dist/components/ui/number-input.d.ts +30 -0
- package/dist/components/ui/number-input.js +1 -0
- package/dist/components/ui/password-input.d.ts +18 -0
- package/dist/components/ui/password-input.js +1 -0
- package/dist/components/ui/pin-input.d.ts +32 -0
- package/dist/components/ui/pin-input.js +1 -0
- package/dist/components/ui/popover.js +1 -1
- package/dist/components/ui/progress.js +1 -1
- package/dist/components/ui/radio-group.d.ts +27 -0
- package/dist/components/ui/radio-group.js +1 -0
- package/dist/components/ui/segmented.d.ts +1 -1
- package/dist/components/ui/segmented.js +1 -1
- package/dist/components/ui/sheet.js +1 -1
- package/dist/components/ui/slider.d.ts +24 -0
- package/dist/components/ui/slider.js +1 -0
- package/dist/components/ui/spinner.d.ts +27 -0
- package/dist/components/ui/spinner.js +1 -0
- package/dist/components/ui/tabs.js +1 -1
- package/dist/components/ui/toast.d.ts +13 -0
- package/dist/components/ui/toast.js +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/use-router.d.ts +41 -0
- package/dist/hooks/use-router.js +1 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +1 -1
- package/dist/lib/theme.d.ts +48 -0
- package/dist/lib/theme.js +7 -0
- package/dist/next/index.d.ts +6 -0
- package/dist/next/index.js +1 -0
- package/dist/shell/app-shell.js +1 -1
- package/dist/shell/app-switcher.js +1 -1
- package/dist/shell/command-palette.js +1 -1
- package/dist/shell/icon-rail.js +1 -1
- package/dist/shell/mobile-nav.js +1 -1
- package/dist/shell/module-sidebar.js +1 -1
- package/dist/shell/notifications.js +1 -1
- package/dist/shell/placeholder-screen.js +1 -1
- package/dist/shell/topbar.js +1 -1
- package/dist/shell/use-active.js +1 -1
- package/dist/shell/user-menu.js +1 -1
- package/dist/styles.css +47 -5
- package/package.json +13 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Alert — a message that stays on the page until it is dealt with: a payout
|
|
4
|
+
* on hold, a gate offline, a plan about to lapse. (One that comes and goes is
|
|
5
|
+
* a toast.)
|
|
6
|
+
*
|
|
7
|
+
* Tones: info, success, warning, danger, neutral — each with its own icon, so
|
|
8
|
+
* the tone is never colour alone. Looks:
|
|
9
|
+
* soft — the default: a tinted box. In a page or a form.
|
|
10
|
+
* outline — a hairline in the tone on the surface: calmer, for lists of notices.
|
|
11
|
+
* solid — filled with the tone: the one message nobody may miss.
|
|
12
|
+
* accent — a bar on the left on a raised card: inside cards and drawers.
|
|
13
|
+
* Danger and warning are announced as they appear (role="alert"); the rest are polite.
|
|
14
|
+
*/
|
|
15
|
+
export type AlertTone = "info" | "success" | "warning" | "danger" | "neutral";
|
|
16
|
+
export type AlertVariant = "soft" | "outline" | "solid" | "accent";
|
|
17
|
+
export interface AlertProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {
|
|
18
|
+
tone?: AlertTone;
|
|
19
|
+
variant?: AlertVariant;
|
|
20
|
+
title?: React.ReactNode;
|
|
21
|
+
/** Replace the tone's icon, or `false` for none. */
|
|
22
|
+
icon?: React.ReactNode | false;
|
|
23
|
+
/** Buttons under the text: "Retry", "Review". */
|
|
24
|
+
action?: React.ReactNode;
|
|
25
|
+
/** Shows a close button; called when it is pressed. */
|
|
26
|
+
onDismiss?: () => void;
|
|
27
|
+
}
|
|
28
|
+
export declare const Alert: React.ForwardRefExoticComponent<AlertProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsx as e,jsxs as x}from"react/jsx-runtime";import{CircleAlert as m,CircleCheck as f,Info as b,TriangleAlert as _,X as w}from"lucide-react";import*as h from"react";import{cn as t}from"../../lib/utils.js";const y={info:{c:"var(--info)",s:"var(--info-subtle)",icon:e(b,{})},success:{c:"var(--success)",s:"var(--success-subtle)",icon:e(f,{})},warning:{c:"var(--warning)",s:"var(--warning-subtle)",icon:e(_,{})},danger:{c:"var(--danger)",s:"var(--danger-subtle)",icon:e(m,{})},neutral:{c:"var(--muted)",s:"var(--hover)",icon:e(b,{})}},R={soft:{box:"border border-[color-mix(in_srgb,var(--tone)_22%,transparent)] bg-[var(--tone-subtle)]",icon:"text-[var(--tone)]",title:"text-text",body:"text-body"},outline:{box:"border border-[color-mix(in_srgb,var(--tone)_45%,transparent)] bg-raised",icon:"text-[var(--tone)]",title:"text-text",body:"text-body"},solid:{box:"border border-transparent bg-[var(--tone)] text-white shadow-[inset_0_1px_0_rgba(255,255,255,.18),0_8px_20px_-10px_var(--tone)]",icon:"text-white",title:"text-white",body:"text-white/85"},accent:{box:"border border-border bg-raised pl-5 shadow-[var(--lit),0_1px_2px_rgba(5,8,22,.04)] before:absolute before:inset-y-2.5 before:left-2 before:w-[3px] before:rounded-full before:bg-[var(--tone)]",icon:"text-[var(--tone)]",title:"text-text",body:"text-body"}},A=h.forwardRef(({tone:o="info",variant:s="soft",title:a,icon:i,action:l,onDismiss:c,className:v,style:p,children:d,...g},u)=>{const n=y[o],r=R[s];return x("div",{ref:u,role:o==="danger"||o==="warning"?"alert":"status",style:{"--tone":n.c,"--tone-subtle":n.s,...p},className:t("relative flex gap-3 rounded-[calc(12px*var(--radius-scale))] p-3.5 text-[13px] animate-[wave-in_220ms_var(--ease)]",r.box,v),...g,children:[i!==!1?e("span",{className:t("mt-px shrink-0 [&_svg]:size-[18px]",r.icon),children:i??n.icon}):null,x("div",{className:"min-w-0 flex-1",children:[a?e("p",{className:t("font-semibold leading-5",r.title),children:a}):null,d?e("div",{className:t("leading-5",a&&"mt-0.5",r.body),children:d}):null,l?e("div",{className:"mt-2.5 flex flex-wrap items-center gap-2",children:l}):null]}),c?e("button",{type:"button",onClick:c,"aria-label":"Dismiss",className:t("-m-1 grid size-7 shrink-0 cursor-pointer place-items-center rounded-[calc(7px*var(--radius-scale))] transition-colors [&_svg]:size-3.5",s==="solid"?"text-white/80 hover:bg-white/15 hover:text-white":"text-muted hover:bg-[color-mix(in_srgb,var(--tone)_12%,transparent)] hover:text-text"),children:e(w,{})}):null]})});A.displayName="Alert";export{A as Alert};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as t,jsxs as o}from"react/jsx-runtime";import*as m from"@radix-ui/react-avatar";import{BadgeCheck as x}from"lucide-react";import{cn as r,initials as v}from"../../lib/utils.js";const b={sm:"size-6 text-[10px]",md:"size-8 text-xs",lg:"size-10 text-[13px]",xl:"size-14 text-[17px]","2xl":"size-20 text-[24px]"},p={sm:"size-2",md:"size-2.5",lg:"size-3",xl:"size-3.5","2xl":"size-4"},u=["linear-gradient(135deg,#1f45ea,#5b4af5)","linear-gradient(135deg,#7560fd,#a78bfa)","linear-gradient(135deg,#0891b2,#22d3ee)","linear-gradient(135deg,#047857,#10b981)","linear-gradient(135deg,#d97706,#f59e0b)","linear-gradient(135deg,#db2777,#f472b6)","linear-gradient(135deg,#1a113e,#4338ca)"];function z(e){let a=0;for(const s of e)a=a*31+s.charCodeAt(0)>>>0;return u[a%u.length]}const h={online:"bg-success",away:"bg-warning",busy:"bg-danger",offline:"bg-border2"};function k({name:e,src:a,size:s="md",status:i,verified:l,ring:n,shape:c="circle",className:f}){const d=c==="circle"?"rounded-full":"rounded-[28%]",g=o(m.Root,{className:r("relative grid shrink-0 place-items-center overflow-hidden font-semibold text-white select-none shadow-[inset_0_1px_0_rgba(255,255,255,.25)]",d,b[s],!n&&f),style:{background:z(e)},children:[a?t(m.Image,{src:a,alt:e,className:"size-full object-cover"}):null,t(m.Fallback,{className:"grid size-full place-items-center",children:v(e)})]});return!n&&!i&&!l?g:o("span",{className:r("relative inline-grid shrink-0",n&&f),children:[n?t("span",{className:r("bg-[conic-gradient(from_200deg,var(--brand-1),var(--brand-2),#22d3ee,var(--brand-1))] p-[2px]",d),children:t("span",{className:r("block bg-canvas p-[2px]",d),children:g})}):g,i?t("span",{className:r("absolute bottom-0 right-0 rounded-full ring-2 ring-canvas",h[i],p[s]),"aria-label":i}):null,l?t(x,{className:r("absolute -right-1 -top-1 fill-primary text-canvas",p[s]==="size-2"?"size-3":"size-4"),"aria-label":"verified"}):null]})}function S({names:e,max:a=4,size:s="sm"}){const i=e.slice(0,a),l=e.length-i.length;return o("div",{className:"flex items-center",children:[i.map((n,c)=>t(k,{name:n,size:s,className:"-ml-1.5 ring-2 ring-surface first:ml-0"},n+c)),l>0?o("span",{className:r("num -ml-1.5 grid place-items-center rounded-full bg-hover font-semibold text-muted ring-2 ring-surface",b[s]),children:["+",l]}):null]})}export{k as Avatar,S as AvatarStack};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as r,jsxs as o}from"react/jsx-runtime";import{cva as
|
|
1
|
+
import{jsx as r,jsxs as o}from"react/jsx-runtime";import{cva as c}from"class-variance-authority";import{cn as s}from"../../lib/utils.js";const i=c("inline-flex items-center gap-[5px] h-[22px] px-[9px] rounded-full text-xs font-medium leading-none whitespace-nowrap",{variants:{tone:{neutral:"bg-hover text-muted",info:"bg-primary-subtle text-primary",success:"bg-success-subtle text-success",warning:"bg-warning-subtle text-warning",danger:"bg-danger-subtle text-danger",accent:"bg-primary-subtle text-accent"}},defaultVariants:{tone:"neutral"}}),u={neutral:"var(--muted)",info:"var(--primary)",success:"var(--success)",warning:"var(--warning)",danger:"var(--danger)",accent:"var(--accent)"},b={solid:"text-white bg-[var(--tone)] shadow-[inset_0_1px_0_rgba(255,255,255,.2)]",outline:"bg-transparent text-[var(--tone)] ring-1 ring-inset ring-[color-mix(in_srgb,var(--tone)_40%,transparent)]",dot:"bg-raised text-body ring-1 ring-inset ring-border",gradient:"text-white bg-[linear-gradient(135deg,var(--brand-1),var(--brand-2))] shadow-[inset_0_1px_0_rgba(255,255,255,.25),0_2px_8px_-2px_color-mix(in_srgb,var(--brand-1)_50%,transparent)]",live:""};function x({className:n,tone:t,dot:a=!0,variant:e="soft",style:g,children:l,...d}){const p=t??"neutral";return o("span",{className:s(i({tone:t}),e!=="soft"&&e!=="live"&&b[e],n),style:{"--tone":u[p],...g},...d,children:[a?o("span",{className:"relative grid size-1.5 shrink-0 place-items-center","aria-hidden":!0,children:[e==="live"?r("span",{className:"absolute inline-flex size-full animate-ping rounded-full bg-current opacity-60"}):null,r("i",{className:s("relative size-1.5 rounded-full",e==="dot"?"bg-[var(--tone)]":"bg-current")})]}):null,l]})}function _({label:n,tone:t="neutral",variant:a,className:e}){return r(x,{tone:t,variant:a,className:e,children:n})}function w({value:n,tone:t="neutral",className:a}){return r("span",{className:s("num inline-grid min-w-4 place-items-center rounded-full px-1 text-[10px] font-semibold leading-4 text-white",t==="danger"?"bg-danger":"bg-muted",a),children:n})}export{x as Badge,w as CountBadge,_ as StatusBadge,i as badgeVariants};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as x,jsxs as f}from"react/jsx-runtime";import{Slot as d}from"@radix-ui/react-slot";import{cva as l}from"class-variance-authority";import{Loader2 as h}from"lucide-react";import*as m from"react";import{cn as s}from"../../lib/utils.js";const r=l("relative isolate inline-flex items-center justify-center gap-[7px] whitespace-nowrap rounded-ctl text-[13px] font-medium leading-none transition-[background-color,border-color,color,box-shadow,transform,filter] duration-150 ease-wave active:scale-[.98] disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0 cursor-pointer",{variants:{variant:{primary:"bg-primary text-white hover:bg-primary-hover",secondary:"bg-raised text-text border border-border2 hover:bg-hover",ghost:"text-muted hover:bg-hover hover:text-text",subtle:"bg-primary-subtle text-primary hover:brightness-[.97]",danger:"bg-danger text-white hover:brightness-110",link:"text-primary underline-offset-4 hover:underline px-0",gradient:"overflow-hidden text-white bg-[linear-gradient(135deg,var(--brand-1),color-mix(in_srgb,var(--brand-1)_78%,#000)_40%,var(--brand-2))] shadow-[inset_0_1px_0_rgba(255,255,255,.3),0_1px_2px_rgba(5,8,22,.2),0_8px_20px_-8px_color-mix(in_srgb,var(--brand-1)_60%,transparent)] hover:brightness-110 hover:shadow-[inset_0_1px_0_rgba(255,255,255,.3),0_1px_2px_rgba(5,8,22,.2),0_12px_26px_-8px_color-mix(in_srgb,var(--brand-1)_70%,transparent)] after:absolute after:inset-y-0 after:-left-full after:w-1/2 after:-skew-x-12 after:bg-[linear-gradient(90deg,transparent,rgba(255,255,255,.35),transparent)] after:transition-[left] after:duration-700 hover:after:left-[150%]",glow:"bg-primary text-white shadow-[0_0_0_1px_color-mix(in_srgb,var(--primary)_40%,transparent),0_6px_22px_-4px_color-mix(in_srgb,var(--primary)_65%,transparent)] hover:shadow-[0_0_0_1px_color-mix(in_srgb,var(--primary)_55%,transparent),0_8px_30px_-4px_color-mix(in_srgb,var(--primary)_80%,transparent)] hover:bg-primary-hover",dark:"text-white bg-[linear-gradient(180deg,#2a1f66,#1a113e)] shadow-[inset_0_1px_0_rgba(255,255,255,.14),0_1px_2px_rgba(5,8,22,.3),0_6px_16px_-8px_rgba(26,17,62,.7)] hover:brightness-125 dark:ring-1 dark:ring-white/15",outline:"border border-primary/40 text-primary hover:bg-primary-subtle hover:border-primary",elevated:"bg-raised text-text shadow-[var(--lit),0_1px_2px_rgba(5,8,22,.08),0_6px_16px_-6px_rgba(5,8,22,.18)] ring-1 ring-border hover:-translate-y-px hover:shadow-[var(--lit),0_2px_4px_rgba(5,8,22,.08),0_10px_22px_-8px_rgba(5,8,22,.25)]",glass:"text-white backdrop-blur-xl backdrop-saturate-150 [text-shadow:0_1px_1px_rgba(5,8,22,.3)] bg-[linear-gradient(180deg,rgba(255,255,255,.28),rgba(255,255,255,.1))] ring-1 ring-inset ring-white/40 shadow-[inset_0_1px_0_rgba(255,255,255,.5),inset_0_-1px_0_rgba(255,255,255,.08),0_8px_24px_-10px_rgba(5,8,22,.55)] hover:bg-[linear-gradient(180deg,rgba(255,255,255,.36),rgba(255,255,255,.16))] hover:ring-white/60",white:"bg-white text-[#1a113e] shadow-[inset_0_-1px_0_rgba(26,17,62,.08),0_1px_2px_rgba(5,8,22,.2),0_10px_24px_-10px_rgba(5,8,22,.6)] hover:bg-[#f4f5fb]"},shape:{default:"",pill:"rounded-full"},size:{default:"h-ctl px-[14px]",sm:"h-8 px-3 text-xs",lg:"h-11 px-5 text-sm",xl:"h-[52px] px-7 text-[15px] font-semibold [&_svg]:size-5",icon:"h-ctl w-ctl px-0",iconSm:"h-8 w-8 px-0"}},defaultVariants:{variant:"secondary",size:"default",shape:"default"}}),v=m.forwardRef(({className:e,variant:t,size:a,shape:o,asChild:b=!1,loading:i,children:n,disabled:g,...p},_)=>b?x(d,{ref:_,className:s(r({variant:t,size:a,shape:o}),e),...p,children:n}):f("button",{ref:_,className:s(r({variant:t,size:a,shape:o}),e),disabled:g||i,...p,children:[i?x(h,{className:"animate-spin"}):null,n]}));v.displayName="Button";export{v as Button,r as buttonVariants};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e}from"react/jsx-runtime";import*as r from"@radix-ui/react-checkbox";import{Check as a,Minus as c}from"lucide-react";import*as
|
|
1
|
+
"use client";import{jsx as e}from"react/jsx-runtime";import*as r from"@radix-ui/react-checkbox";import{Check as a,Minus as c}from"lucide-react";import*as s from"react";import{cn as d}from"../../lib/utils.js";const m=s.forwardRef(({className:o,...t},i)=>e(r.Root,{ref:i,className:d("peer size-4 shrink-0 cursor-pointer rounded-[calc(4px*var(--radius-scale))] border border-border2 bg-raised transition-colors duration-100 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary disabled:cursor-not-allowed disabled:opacity-50",o),...t,children:e(r.Indicator,{className:"grid place-items-center text-white",children:t.checked==="indeterminate"?e(c,{className:"size-3",strokeWidth:3}):e(a,{className:"size-3",strokeWidth:3})})}));m.displayName="Checkbox";export{m as Checkbox};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{Fragment as $,jsx as t,jsxs as o}from"react/jsx-runtime";import{Check as q,ChevronsUpDown as F,Search as W,SearchX as G,X as R}from"lucide-react";import*as d from"react";import{cn as x}from"../../lib/utils.js";import{Popover as Q,PopoverContent as j,PopoverTrigger as J}from"./popover.js";const V={placeholder:"Choose\u2026",search:"Search\u2026",clear:"Clear",empty:r=>`Nothing matches \u201C${r}\u201D`,count:(r,a)=>`${r} of ${a}`,total:r=>`${r} options`},Y="\u09E6\u09E7\u09E8\u09E9\u09EA\u09EB\u09EC\u09ED\u09EE\u09EF";function h(r){return r.normalize("NFKD").replace(/[̀-ͯ]/g,"").replace(/[০-৯]/g,a=>String(Y.indexOf(a))).toLowerCase().trim()}function Z(r,a){const i=h(r.label);return i.startsWith(a)?0:i.split(/[\s\-–—(),./]+/).some(v=>v.startsWith(a))?1:[i,h(r.hint??""),...(r.keywords??[]).map(h)].some(v=>v.includes(a))?2:-1}function ee({text:r,q:a}){if(!a)return t($,{children:r});const i=h(r).indexOf(a);return i<0||h(r).length!==r.length?t($,{children:r}):o($,{children:[r.slice(0,i),t("mark",{className:"rounded-[3px] bg-primary-subtle px-px text-primary",children:r.slice(i,i+a.length)}),r.slice(i+a.length)]})}function ae({id:r,value:a,onChange:i,options:f,placeholder:v,searchPlaceholder:z,clearable:L=!1,disabled:E,className:H,contentClassName:I,hintInValue:O=!1,labels:B,"aria-invalid":U}){const u={...V,...B},[m,k]=d.useState(!1),[N,w]=d.useState(""),[p,D]=d.useState(0),K=d.useRef(null),y=d.useId(),c=f.find(e=>e.value===a)??null,g=h(N),A=d.useMemo(()=>g?f.map((e,s)=>({o:e,i:s,r:Z(e,g)})).filter(e=>e.r>=0).sort((e,s)=>e.r-s.r||e.i-s.i).map(e=>e.o):f,[f,g]),M=d.useMemo(()=>{const e=new Map;for(const s of A){const n=s.group??"";e.has(n)||e.set(n,[]),e.get(n).push(s)}return[...e.entries()]},[A]),l=d.useMemo(()=>M.flatMap(([,e])=>e),[M]);d.useEffect(()=>{if(!m)return;const e=g?l.findIndex(s=>!s.disabled):Math.max(0,l.findIndex(s=>s.value===a));D(e<0?0:e)},[m,g]),d.useEffect(()=>{if(!m)return;K.current?.querySelector(`[data-index="${p}"]`)?.scrollIntoView({block:"nearest"})},[p,m]);const P=e=>{e.disabled||(i(e.value),k(!1))},C=(e,s=p)=>{if(!l.length)return;let n=s;for(let b=0;b<l.length;b++)if(n=(n+e+l.length)%l.length,!l[n].disabled)return D(n)},X=e=>{if(e.key==="ArrowDown")C(1);else if(e.key==="ArrowUp")C(-1);else if(e.key==="Home")C(1,-1);else if(e.key==="End")C(-1,l.length);else if(e.key==="Enter")l[p]&&P(l[p]);else return;e.preventDefault()},_=e=>{k(e),e||w("")};let T=-1;return o(Q,{open:m,onOpenChange:_,children:[o("div",{className:x("relative",H),children:[t(J,{asChild:!0,disabled:E,children:o("button",{id:r,type:"button",role:"combobox","aria-expanded":m,"aria-controls":`${y}-list`,"aria-haspopup":"listbox","aria-invalid":U,onKeyDown:e=>{!m&&e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key!==" "?(w(e.key),k(!0),e.preventDefault()):!m&&(e.key==="ArrowDown"||e.key==="ArrowUp")&&(k(!0),e.preventDefault())},className:x("group flex h-ctl w-full cursor-pointer items-center gap-2 rounded-ctl border border-border2 bg-raised pl-3 text-left text-[13px] text-text outline-none transition-[border-color,box-shadow]","focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary/20 data-[state=open]:border-primary data-[state=open]:ring-2 data-[state=open]:ring-primary/20","disabled:cursor-not-allowed disabled:bg-hover disabled:text-muted aria-[invalid=true]:border-danger",L&&c?"pr-14":"pr-8"),children:[c?.icon?t("span",{className:"grid shrink-0 place-items-center text-muted",children:c.icon}):null,o("span",{className:x("min-w-0 flex-1 truncate",!c&&"text-placeholder"),children:[c?c.label:v??u.placeholder,c&&O?o("span",{className:"ml-1.5 text-muted",children:["\xB7 ",typeof O=="function"?O(c):c.hint]}):null]})]})}),L&&c&&!E?t("button",{type:"button","aria-label":u.clear,onClick:()=>i(null),className:"absolute right-7 top-1/2 grid size-6 -translate-y-1/2 cursor-pointer place-items-center rounded-md text-muted hover:bg-hover hover:text-text",children:t(R,{className:"size-3.5"})}):null,t(F,{className:"pointer-events-none absolute right-2.5 top-1/2 size-4 -translate-y-1/2 text-muted"})]}),o(j,{align:"start",className:x("w-[var(--radix-popover-trigger-width)] min-w-[260px] overflow-hidden p-0",I),onOpenAutoFocus:e=>{e.preventDefault(),e.currentTarget.querySelector("input")?.focus()},children:[o("div",{className:"flex items-center gap-2 border-b border-border px-3",children:[t(W,{className:"size-4 shrink-0 text-muted"}),t("input",{value:N,onChange:e=>w(e.target.value),onKeyDown:X,placeholder:z??u.search,"aria-label":z??u.search,"aria-controls":`${y}-list`,"aria-activedescendant":l[p]?`${y}-${p}`:void 0,autoComplete:"off",spellCheck:!1,className:"h-11 min-w-0 flex-1 bg-transparent text-[13.5px] text-text outline-none placeholder:text-placeholder"}),N?t("button",{type:"button","aria-label":u.clear,onClick:()=>w(""),className:"grid size-6 cursor-pointer place-items-center rounded-md text-muted hover:bg-hover hover:text-text",children:t(R,{className:"size-3.5"})}):null]}),t("div",{ref:K,id:`${y}-list`,role:"listbox",className:"max-h-[296px] overflow-y-auto overscroll-contain p-1.5",children:l.length===0?o("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-center",children:[t(G,{className:"size-6 text-muted"}),t("p",{className:"text-[13px] text-muted",children:u.empty(N)})]}):M.map(([e,s])=>o("div",{role:"group","aria-label":e||void 0,children:[e?t("p",{className:"sticky top-0 z-10 bg-raised px-2 pb-1 pt-2 text-[10.5px] font-semibold uppercase tracking-[0.08em] text-muted",children:e}):null,s.map(n=>{T++;const b=T,S=n.value===a;return o("div",{id:`${y}-${b}`,"data-index":b,role:"option","aria-selected":S,"aria-disabled":n.disabled,onMouseMove:()=>!n.disabled&&p!==b&&D(b),onClick:()=>P(n),className:x("flex cursor-pointer items-center gap-2.5 rounded-[8px] px-2 py-1.5 text-[13px]",b===p&&"bg-hover",n.disabled&&"cursor-not-allowed opacity-45"),children:[n.icon?t("span",{className:"grid size-7 shrink-0 place-items-center rounded-[7px] bg-surface text-muted",children:n.icon}):null,o("span",{className:"min-w-0 flex-1",children:[t("span",{className:x("block truncate text-text",S&&"font-medium"),children:t(ee,{text:n.label,q:g})}),n.hint?t("span",{className:"block truncate text-[11.5px] text-muted",children:n.hint}):null]}),t(q,{className:x("size-4 shrink-0 text-primary",!S&&"invisible")})]},n.value)})]},e||"_"))}),o("div",{className:"flex items-center justify-between border-t border-border bg-surface px-3 py-1.5 text-[11px] text-muted",children:[t("span",{className:"num",children:g?u.count(l.length,f.length):u.total(f.length)}),o("span",{className:"hidden items-center gap-1 sm:flex",children:[t("kbd",{className:"rounded border border-border bg-raised px-1 font-sans",children:"\u2191\u2193"}),t("kbd",{className:"rounded border border-border bg-raised px-1 font-sans",children:"\u21B5"}),t("kbd",{className:"rounded border border-border bg-raised px-1 font-sans",children:"esc"})]})]})]})]})}export{V as COMBOBOX_LABELS,ae as Combobox};
|
|
1
|
+
"use client";import{Fragment as $,jsx as t,jsxs as o}from"react/jsx-runtime";import{Check as q,ChevronsUpDown as F,Search as W,SearchX as G,X as R}from"lucide-react";import*as d from"react";import{cn as x}from"../../lib/utils.js";import{Popover as Q,PopoverContent as j,PopoverTrigger as J}from"./popover.js";const V={placeholder:"Choose\u2026",search:"Search\u2026",clear:"Clear",empty:r=>`Nothing matches \u201C${r}\u201D`,count:(r,a)=>`${r} of ${a}`,total:r=>`${r} options`},Y="\u09E6\u09E7\u09E8\u09E9\u09EA\u09EB\u09EC\u09ED\u09EE\u09EF";function h(r){return r.normalize("NFKD").replace(/[̀-ͯ]/g,"").replace(/[০-৯]/g,a=>String(Y.indexOf(a))).toLowerCase().trim()}function Z(r,a){const i=h(r.label);return i.startsWith(a)?0:i.split(/[\s\-–—(),./]+/).some(v=>v.startsWith(a))?1:[i,h(r.hint??""),...(r.keywords??[]).map(h)].some(v=>v.includes(a))?2:-1}function ee({text:r,q:a}){if(!a)return t($,{children:r});const i=h(r).indexOf(a);return i<0||h(r).length!==r.length?t($,{children:r}):o($,{children:[r.slice(0,i),t("mark",{className:"rounded-[3px] bg-primary-subtle px-px text-primary",children:r.slice(i,i+a.length)}),r.slice(i+a.length)]})}function ae({id:r,value:a,onChange:i,options:f,placeholder:v,searchPlaceholder:z,clearable:L=!1,disabled:E,className:H,contentClassName:I,hintInValue:O=!1,labels:B,"aria-invalid":U}){const u={...V,...B},[m,k]=d.useState(!1),[N,w]=d.useState(""),[p,D]=d.useState(0),K=d.useRef(null),y=d.useId(),c=f.find(e=>e.value===a)??null,g=h(N),A=d.useMemo(()=>g?f.map((e,s)=>({o:e,i:s,r:Z(e,g)})).filter(e=>e.r>=0).sort((e,s)=>e.r-s.r||e.i-s.i).map(e=>e.o):f,[f,g]),M=d.useMemo(()=>{const e=new Map;for(const s of A){const n=s.group??"";e.has(n)||e.set(n,[]),e.get(n).push(s)}return[...e.entries()]},[A]),l=d.useMemo(()=>M.flatMap(([,e])=>e),[M]);d.useEffect(()=>{if(!m)return;const e=g?l.findIndex(s=>!s.disabled):Math.max(0,l.findIndex(s=>s.value===a));D(e<0?0:e)},[m,g]),d.useEffect(()=>{if(!m)return;K.current?.querySelector(`[data-index="${p}"]`)?.scrollIntoView({block:"nearest"})},[p,m]);const P=e=>{e.disabled||(i(e.value),k(!1))},C=(e,s=p)=>{if(!l.length)return;let n=s;for(let b=0;b<l.length;b++)if(n=(n+e+l.length)%l.length,!l[n].disabled)return D(n)},X=e=>{if(e.key==="ArrowDown")C(1);else if(e.key==="ArrowUp")C(-1);else if(e.key==="Home")C(1,-1);else if(e.key==="End")C(-1,l.length);else if(e.key==="Enter")l[p]&&P(l[p]);else return;e.preventDefault()},_=e=>{k(e),e||w("")};let T=-1;return o(Q,{open:m,onOpenChange:_,children:[o("div",{className:x("relative",H),children:[t(J,{asChild:!0,disabled:E,children:o("button",{id:r,type:"button",role:"combobox","aria-expanded":m,"aria-controls":`${y}-list`,"aria-haspopup":"listbox","aria-invalid":U,onKeyDown:e=>{!m&&e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key!==" "?(w(e.key),k(!0),e.preventDefault()):!m&&(e.key==="ArrowDown"||e.key==="ArrowUp")&&(k(!0),e.preventDefault())},className:x("group flex h-ctl w-full cursor-pointer items-center gap-2 rounded-ctl border border-border2 bg-raised pl-3 text-left text-[13px] text-text outline-none transition-[border-color,box-shadow]","focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary/20 data-[state=open]:border-primary data-[state=open]:ring-2 data-[state=open]:ring-primary/20","disabled:cursor-not-allowed disabled:bg-hover disabled:text-muted aria-[invalid=true]:border-danger",L&&c?"pr-14":"pr-8"),children:[c?.icon?t("span",{className:"grid shrink-0 place-items-center text-muted",children:c.icon}):null,o("span",{className:x("min-w-0 flex-1 truncate",!c&&"text-placeholder"),children:[c?c.label:v??u.placeholder,c&&O?o("span",{className:"ml-1.5 text-muted",children:["\xB7 ",typeof O=="function"?O(c):c.hint]}):null]})]})}),L&&c&&!E?t("button",{type:"button","aria-label":u.clear,onClick:()=>i(null),className:"absolute right-7 top-1/2 grid size-6 -translate-y-1/2 cursor-pointer place-items-center rounded-md text-muted hover:bg-hover hover:text-text",children:t(R,{className:"size-3.5"})}):null,t(F,{className:"pointer-events-none absolute right-2.5 top-1/2 size-4 -translate-y-1/2 text-muted"})]}),o(j,{align:"start",className:x("w-[var(--radix-popover-trigger-width)] min-w-[260px] overflow-hidden p-0",I),onOpenAutoFocus:e=>{e.preventDefault(),e.currentTarget.querySelector("input")?.focus()},children:[o("div",{className:"flex items-center gap-2 border-b border-border px-3",children:[t(W,{className:"size-4 shrink-0 text-muted"}),t("input",{value:N,onChange:e=>w(e.target.value),onKeyDown:X,placeholder:z??u.search,"aria-label":z??u.search,"aria-controls":`${y}-list`,"aria-activedescendant":l[p]?`${y}-${p}`:void 0,autoComplete:"off",spellCheck:!1,className:"h-11 min-w-0 flex-1 bg-transparent text-[13.5px] text-text outline-none placeholder:text-placeholder"}),N?t("button",{type:"button","aria-label":u.clear,onClick:()=>w(""),className:"grid size-6 cursor-pointer place-items-center rounded-md text-muted hover:bg-hover hover:text-text",children:t(R,{className:"size-3.5"})}):null]}),t("div",{ref:K,id:`${y}-list`,role:"listbox",className:"max-h-[296px] overflow-y-auto overscroll-contain p-1.5",children:l.length===0?o("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-center",children:[t(G,{className:"size-6 text-muted"}),t("p",{className:"text-[13px] text-muted",children:u.empty(N)})]}):M.map(([e,s])=>o("div",{role:"group","aria-label":e||void 0,children:[e?t("p",{className:"sticky top-0 z-10 bg-raised px-2 pb-1 pt-2 text-[10.5px] font-semibold uppercase tracking-[0.08em] text-muted",children:e}):null,s.map(n=>{T++;const b=T,S=n.value===a;return o("div",{id:`${y}-${b}`,"data-index":b,role:"option","aria-selected":S,"aria-disabled":n.disabled,onMouseMove:()=>!n.disabled&&p!==b&&D(b),onClick:()=>P(n),className:x("flex cursor-pointer items-center gap-2.5 rounded-[calc(8px*var(--radius-scale))] px-2 py-1.5 text-[13px]",b===p&&"bg-hover",n.disabled&&"cursor-not-allowed opacity-45"),children:[n.icon?t("span",{className:"grid size-7 shrink-0 place-items-center rounded-[calc(7px*var(--radius-scale))] bg-surface text-muted",children:n.icon}):null,o("span",{className:"min-w-0 flex-1",children:[t("span",{className:x("block truncate text-text",S&&"font-medium"),children:t(ee,{text:n.label,q:g})}),n.hint?t("span",{className:"block truncate text-[11.5px] text-muted",children:n.hint}):null]}),t(q,{className:x("size-4 shrink-0 text-primary",!S&&"invisible")})]},n.value)})]},e||"_"))}),o("div",{className:"flex items-center justify-between border-t border-border bg-surface px-3 py-1.5 text-[11px] text-muted",children:[t("span",{className:"num",children:g?u.count(l.length,f.length):u.total(f.length)}),o("span",{className:"hidden items-center gap-1 sm:flex",children:[t("kbd",{className:"rounded border border-border bg-raised px-1 font-sans",children:"\u2191\u2193"}),t("kbd",{className:"rounded border border-border bg-raised px-1 font-sans",children:"\u21B5"}),t("kbd",{className:"rounded border border-border bg-raised px-1 font-sans",children:"esc"})]})]})]})]})}export{V as COMBOBOX_LABELS,ae as Combobox};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as i from"@radix-ui/react-dialog";import{CircleAlert as L,ShieldAlert as $,Trash2 as A}from"lucide-react";import*as s from"react";import{cn as n}from"../../lib/utils.js";import{Button as C}from"./button.js";import{DialogOverlay as F}from"./dialog.js";import{Input as O}from"./input.js";function q({open:
|
|
1
|
+
"use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as i from"@radix-ui/react-dialog";import{CircleAlert as L,ShieldAlert as $,Trash2 as A}from"lucide-react";import*as s from"react";import{cn as n}from"../../lib/utils.js";import{Button as C}from"./button.js";import{DialogOverlay as F}from"./dialog.js";import{Input as O}from"./input.js";function q({open:c,onOpenChange:d,title:R,description:x,items:b,previewCount:D=3,confirmWord:l,confirmLabel:P,cancelLabel:k="Cancel",tone:T="danger",icon:z,onConfirm:B,labels:S}){const[p,f]=s.useState(""),[m,v]=s.useState(!1),[N,g]=s.useState(null),_=s.useRef(null);s.useEffect(()=>{c&&(f(""),g(null))},[c]);const y=!!l&&p.trim().toUpperCase()!==l.toUpperCase(),h={typeToConfirm:t=>`Type ${t} to confirm`,more:t=>`+ ${t} more`,...S},r=T==="danger",u=b?.slice(0,D)??[],w=(b?.length??0)-u.length;return e(i.Root,{open:c,onOpenChange:t=>!m&&d(t),children:a(i.Portal,{children:[e(F,{}),a(i.Content,{"data-dialog":"",onOpenAutoFocus:t=>{t.preventDefault(),_.current?.focus()},className:"fixed left-1/2 top-1/2 z-50 w-[calc(100vw-32px)] max-w-[440px] -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-[calc(18px*var(--radius-scale))] border border-border bg-raised outline-none",children:[e("div",{"aria-hidden":!0,className:n("pointer-events-none absolute inset-x-0 top-0 h-28",r?"bg-[radial-gradient(70%_100%_at_50%_0%,var(--danger-subtle),transparent)]":"bg-[radial-gradient(70%_100%_at_50%_0%,var(--warning-subtle),transparent)]")}),a("div",{className:"relative px-6 pb-5 pt-7 text-center",children:[a("div",{className:"relative mx-auto mb-4 grid size-14 place-items-center",children:[e("span",{className:n("absolute inset-0 rounded-full",r?"bg-danger/10":"bg-warning/10")}),e("span",{className:n("absolute inset-[7px] rounded-full",r?"bg-danger/15":"bg-warning/15")}),e("span",{className:n("relative grid size-9 place-items-center rounded-full text-white shadow-[inset_0_1px_0_rgba(255,255,255,.3)]",r?"bg-[linear-gradient(180deg,#ef4444,#dc2626)] shadow-[0_6px_16px_-6px_rgba(220,38,38,.7)]":"bg-[linear-gradient(180deg,#f59e0b,#b45309)] shadow-[0_6px_16px_-6px_rgba(180,83,9,.7)]","[&_svg]:size-[18px]"),children:z??(r?e(A,{}):e($,{}))})]}),e(i.Title,{className:"disp text-[17px] font-semibold leading-6 text-text",children:R}),x?e(i.Description,{className:"mx-auto mt-1.5 max-w-[34ch] text-[13px] leading-5 text-muted",children:x}):null,u.length?a("ul",{className:"mt-4 space-y-1 rounded-[calc(12px*var(--radius-scale))] border border-border bg-surface p-2 text-left",children:[u.map((t,o)=>a("li",{className:"flex items-center gap-2 rounded-[calc(8px*var(--radius-scale))] px-2 py-1.5 text-[13px] text-body",children:[e("span",{className:n("size-1.5 shrink-0 rounded-full",r?"bg-danger":"bg-warning")}),e("span",{className:"truncate",children:t})]},`${t}-${o}`)),w>0?e("li",{className:"px-2 py-1 text-[12px] font-medium text-muted",children:h.more(w)}):null]}):null,l?a("div",{className:"mt-4 text-left",children:[e("label",{className:"mb-1.5 block text-[12px] font-medium text-muted",children:h.typeToConfirm(l).split(l).map((t,o,E)=>a(s.Fragment,{children:[t,o<E.length-1?e("b",{className:n("font-semibold",r?"text-danger":"text-warning"),children:l}):null]},o))}),e(O,{value:p,onChange:t=>f(t.target.value),autoComplete:"off",spellCheck:!1,className:"text-center font-medium tracking-[0.2em] uppercase",state:!y&&p?"success":"default"})]}):null,N?a("p",{role:"alert",className:"mt-3 flex items-center justify-center gap-1.5 text-[12.5px] text-danger",children:[e(L,{className:"size-3.5"})," ",N]}):null]}),a("div",{className:"relative grid grid-cols-2 gap-2 border-t border-border bg-surface/70 px-6 py-4",children:[e(C,{ref:_,disabled:m,onClick:()=>d(!1),children:k}),e(C,{variant:r?"danger":"primary",disabled:y,loading:m,className:n(r&&"shadow-[0_6px_16px_-8px_rgba(220,38,38,.8)]"),onClick:async()=>{v(!0),g(null);try{await B(),d(!1)}catch(t){g(t instanceof Error?t.message:String(t))}finally{v(!1)}},children:P})]})]})]})})}export{q as ConfirmDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{Fragment as T,jsx as e,jsxs as s}from"react/jsx-runtime";import*as l from"@radix-ui/react-dialog";import{Maximize2 as y,Minimize2 as w,PanelRightClose as D,PanelRightOpen as R,X as N}from"lucide-react";import*as
|
|
1
|
+
"use client";import{Fragment as T,jsx as e,jsxs as s}from"react/jsx-runtime";import*as l from"@radix-ui/react-dialog";import{Maximize2 as y,Minimize2 as w,PanelRightClose as D,PanelRightOpen as R,X as N}from"lucide-react";import*as d from"react";import{cn as i}from"../../lib/utils.js";const C={sm:"max-w-[420px]",md:"max-w-[520px]",lg:"max-w-[680px]",xl:"max-w-[880px]"},E=l.Root,H=l.Trigger,W=l.Close,f=d.forwardRef(({className:r,...t},o)=>e(l.Overlay,{ref:o,"data-scrim":"",className:i("fixed inset-0 z-50 bg-[rgba(5,8,22,.42)] backdrop-blur-[3px]",r),...t}));f.displayName="DialogOverlay";const z=d.forwardRef(({className:r,children:t,width:o,size:c="md",hideClose:p,variant:n="drawer",resizable:u=!0,...g},v)=>{const[a,b]=d.useState("base"),m=n==="drawer",h=!m||a==="base"?o??C[c]:a==="wide"?"max-w-[min(1040px,calc(100vw-16px))]":"max-w-none sm:left-2",x="hidden size-8 cursor-pointer place-items-center rounded-full border border-border bg-raised/80 text-muted backdrop-blur transition-[background-color,color,transform] hover:bg-hover hover:text-text active:scale-95 sm:grid";return s(l.Portal,{children:[e(f,{}),s(l.Content,{ref:v,...n==="drawer"?{"data-sheet":"right"}:{"data-dialog":""},className:i("z-50 flex flex-col overflow-hidden bg-raised outline-none",n==="drawer"?"fixed inset-y-0 right-0 h-dvh w-full border-border max-sm:border-l sm:inset-y-2 sm:right-2 sm:h-[calc(100dvh-16px)] sm:rounded-[calc(16px*var(--radius-scale))] sm:border":"fixed left-1/2 top-1/2 w-[calc(100vw-32px)] -translate-x-1/2 -translate-y-1/2 max-h-[calc(100dvh-48px)] rounded-[calc(16px*var(--radius-scale))] border border-border",h,m&&"transition-[max-width,left] duration-300 ease-[cubic-bezier(.3,.7,.2,1)]",r),...g,children:[t,p?null:s("div",{className:i("absolute z-10 flex items-center gap-1.5",n==="drawer"?"right-4 top-4":"right-3 top-3"),children:[m&&u?s(T,{children:[e("button",{type:"button","aria-label":a==="wide"?"Back to normal width":"Widen",title:a==="wide"?"Back to normal width":"Widen",onClick:()=>b(a==="wide"?"base":"wide"),className:i(x,a==="wide"&&"border-primary/40 bg-primary-subtle text-primary"),children:a==="wide"?e(D,{className:"size-4"}):e(R,{className:"size-4"})}),e("button",{type:"button","aria-label":a==="full"?"Exit full width":"Full width",title:a==="full"?"Exit full width":"Full width",onClick:()=>b(a==="full"?"base":"full"),className:i(x,a==="full"&&"border-primary/40 bg-primary-subtle text-primary"),children:a==="full"?e(w,{className:"size-3.5"}):e(y,{className:"size-3.5"})})]}):null,e("kbd",{className:"hidden rounded-[calc(5px*var(--radius-scale))] border border-border bg-surface px-1.5 py-0.5 font-sans text-[10.5px] text-muted sm:block",children:"esc"}),s(l.Close,{className:"grid size-8 cursor-pointer place-items-center rounded-full border border-border bg-raised/80 text-muted backdrop-blur transition-[background-color,color,transform] hover:bg-hover hover:text-text active:scale-95",children:[e(N,{className:"size-4"}),e("span",{className:"sr-only",children:"Close"})]})]})]})]})});z.displayName="DialogContent";const L=({className:r,icon:t,eyebrow:o,children:c,...p})=>s("div",{className:i("relative isolate flex shrink-0 items-start gap-3.5 border-b border-border px-6 pb-4 pt-5 pr-28 sm:pr-48","before:absolute before:inset-0 before:-z-10 before:bg-[radial-gradient(120%_100%_at_0%_0%,var(--primary-subtle),transparent_60%)] before:opacity-70",r),...p,children:[t?e("span",{className:"grid size-10 shrink-0 place-items-center rounded-[calc(11px*var(--radius-scale))] border border-primary/15 bg-raised text-primary shadow-[0_1px_2px_rgba(5,8,22,.14)] [&>svg]:size-5",children:t}):null,s("div",{className:"min-w-0 flex-1",children:[o?e("p",{className:"mb-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-primary",children:o}):null,c]})]}),O=({className:r,...t})=>e("div",{className:i("min-h-0 flex-1 overflow-y-auto px-6 py-5",r),...t}),S=({className:r,...t})=>e("div",{className:i("mt-auto flex shrink-0 items-center justify-end gap-2 border-t border-border bg-raised/85 px-6 py-4 backdrop-blur-md",r),...t}),P=d.forwardRef(({className:r,...t},o)=>e(l.Title,{ref:o,className:i("disp text-[16px] font-semibold leading-6 text-text",r),...t}));P.displayName="DialogTitle";const k=d.forwardRef(({className:r,...t},o)=>e(l.Description,{ref:o,className:i("mt-1 text-[13px] leading-5 text-muted",r),...t}));k.displayName="DialogDescription";export{E as Dialog,O as DialogBody,W as DialogClose,z as DialogContent,k as DialogDescription,S as DialogFooter,L as DialogHeader,f as DialogOverlay,P as DialogTitle,H as DialogTrigger};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{Fragment as I,jsx as t,jsxs as d}from"react/jsx-runtime";import*as a from"@radix-ui/react-dropdown-menu";import{Check as l,ChevronRight as
|
|
1
|
+
"use client";import{Fragment as I,jsx as t,jsxs as d}from"react/jsx-runtime";import*as a from"@radix-ui/react-dropdown-menu";import{Check as l,ChevronRight as h}from"lucide-react";import*as s from"react";import{cn as i}from"../../lib/utils.js";const S=a.Root,T=a.Trigger,W=a.Group,_=a.Sub,z=a.RadioGroup,f="z-50 min-w-48 overflow-hidden rounded-dlg border border-border bg-raised p-1 shadow-elev3",b=s.createContext("default"),x={default:"",glass:"border-white/40 bg-raised/70 backdrop-blur-xl backdrop-saturate-150 dark:border-white/10",dark:"dark border-white/10 bg-[var(--ink)] text-white [--hover:rgba(255,255,255,.08)] [--text:#f5f6fa] [--body:#d6d8e6] [--muted:#9aa1bd] [--border:rgba(255,255,255,.1)]"},w=s.forwardRef(({className:o,sideOffset:e=6,variant:n="default",...r},p)=>t(b.Provider,{value:n,children:t(a.Portal,{children:t(a.Content,{ref:p,"data-pop":"",sideOffset:e,className:i(f,x[n],o),...r})})}));w.displayName="DropdownMenuContent";const m="relative flex cursor-pointer select-none items-center gap-2.5 rounded-ctl px-2.5 py-2 text-[13px] text-body outline-none transition-colors data-[highlighted]:bg-hover data-[highlighted]:text-text data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:text-muted",C=s.forwardRef(({className:o,danger:e,icon:n,description:r,shortcut:p,badge:c,children:u,...g},R)=>{const v=n!==void 0||r!==void 0||p!==void 0||c!==void 0;return t(a.Item,{ref:R,className:i(m,r&&"items-start py-2",e&&"text-danger data-[highlighted]:bg-danger-subtle data-[highlighted]:text-danger [&_svg]:text-danger",o),...g,children:v?d(I,{children:[n?t("span",{className:i("grid shrink-0 place-items-center rounded-[calc(8px*var(--radius-scale))] border border-border bg-surface",r?"size-8":"size-6",e&&"border-danger/20 bg-danger-subtle"),children:n}):null,d("span",{className:"min-w-0 flex-1",children:[d("span",{className:"flex items-center gap-2",children:[t("span",{className:"truncate",children:u}),c]}),r?t("span",{className:"mt-0.5 block text-[11.5px] leading-4 text-muted",children:r}):null]}),p?t("kbd",{className:"ml-auto self-center rounded-[calc(5px*var(--radius-scale))] border border-border bg-surface px-1.5 py-px font-sans text-[10.5px] text-muted",children:p}):null]}):u})});C.displayName="DropdownMenuItem";const N=s.forwardRef(({className:o,children:e,...n},r)=>d(a.CheckboxItem,{ref:r,className:i(m,"pr-8",o),...n,children:[e,t(a.ItemIndicator,{className:"absolute right-2.5",children:t(l,{className:"size-3.5 !text-primary",strokeWidth:3})})]}));N.displayName="DropdownMenuCheckboxItem";const P=s.forwardRef(({className:o,children:e,...n},r)=>d(a.RadioItem,{ref:r,className:i(m,"pr-8",o),...n,children:[e,t(a.ItemIndicator,{className:"absolute right-2.5",children:t(l,{className:"size-3.5 !text-primary",strokeWidth:3})})]}));P.displayName="DropdownMenuRadioItem";const V=({className:o,...e})=>t(a.Label,{className:i("ov px-2.5 pb-1 pt-2",o),...e}),L=({className:o,...e})=>t(a.Separator,{className:i("-mx-1 my-1 h-px bg-border",o),...e}),G=({className:o,...e})=>t("span",{className:i("ml-auto text-[11px] tracking-wide text-muted",o),...e}),y=s.forwardRef(({className:o,children:e,...n},r)=>d(a.SubTrigger,{ref:r,className:i(m,"data-[state=open]:bg-hover",o),...n,children:[e,t(h,{className:"ml-auto size-3.5"})]}));y.displayName="DropdownMenuSubTrigger";const M=s.forwardRef(({className:o,...e},n)=>{const r=s.useContext(b);return t(a.Portal,{children:t(a.SubContent,{ref:n,"data-pop":"",className:i(f,x[r],o),...e})})});M.displayName="DropdownMenuSubContent";function H({title:o,subtitle:e,media:n,className:r}){return d("div",{className:i("flex items-center gap-3 rounded-[calc(10px*var(--radius-scale))] bg-[radial-gradient(120%_120%_at_0%_0%,var(--primary-subtle),transparent_60%)] px-2.5 py-2.5",r),children:[n,d("div",{className:"min-w-0",children:[t("p",{className:"truncate text-[13px] font-semibold text-text",children:o}),e?t("p",{className:"truncate text-[11.5px] text-muted",children:e}):null]})]})}export{S as DropdownMenu,N as DropdownMenuCheckboxItem,w as DropdownMenuContent,W as DropdownMenuGroup,H as DropdownMenuHeader,C as DropdownMenuItem,V as DropdownMenuLabel,z as DropdownMenuRadioGroup,P as DropdownMenuRadioItem,L as DropdownMenuSeparator,G as DropdownMenuShortcut,_ as DropdownMenuSub,M as DropdownMenuSubContent,y as DropdownMenuSubTrigger,T as DropdownMenuTrigger};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* FileUpload — drop files or pick them, and see what was taken and what was not.
|
|
4
|
+
*
|
|
5
|
+
* Files that break `accept` or `maxSize` are not silently dropped: they are
|
|
6
|
+
* listed with the reason, so the person knows to shrink the photo rather than
|
|
7
|
+
* wonder why nothing happened. Images get a thumbnail; everything else a type
|
|
8
|
+
* icon. Pass `progress` (by file name, 0–100) to show uploads moving, and
|
|
9
|
+
* `failed` for the ones to retry.
|
|
10
|
+
*
|
|
11
|
+
* Looks: `dropzone` (default, a dashed area) and `compact` (one row with a
|
|
12
|
+
* button, for a form with other fields).
|
|
13
|
+
*/
|
|
14
|
+
export type FileUploadVariant = "dropzone" | "compact";
|
|
15
|
+
export interface FileUploadProps {
|
|
16
|
+
value?: File[];
|
|
17
|
+
defaultValue?: File[];
|
|
18
|
+
onValueChange?: (files: File[]) => void;
|
|
19
|
+
/** As on <input type="file">: "image/*", ".csv,.xlsx". */
|
|
20
|
+
accept?: string;
|
|
21
|
+
multiple?: boolean;
|
|
22
|
+
/** Bytes. */
|
|
23
|
+
maxSize?: number;
|
|
24
|
+
maxFiles?: number;
|
|
25
|
+
variant?: FileUploadVariant;
|
|
26
|
+
title?: React.ReactNode;
|
|
27
|
+
hint?: React.ReactNode;
|
|
28
|
+
/** Upload progress by file name, 0–100. */
|
|
29
|
+
progress?: Record<string, number>;
|
|
30
|
+
/** Names of files whose upload failed; they get a retry button. */
|
|
31
|
+
failed?: string[];
|
|
32
|
+
onRetry?: (file: File) => void;
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
className?: string;
|
|
35
|
+
}
|
|
36
|
+
export declare function FileUpload({ value, defaultValue, onValueChange, accept, multiple, maxSize, maxFiles, variant, title, hint, progress, failed, onRetry, disabled, className, }: FileUploadProps): React.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{Fragment as Q,jsx as r,jsxs as n}from"react/jsx-runtime";import{CloudUpload as j,File as A,FileImage as H,FileSpreadsheet as K,FileText as X,RotateCcw as q,X as E}from"lucide-react";import*as d from"react";import{cn as f}from"../../lib/utils.js";const k=t=>t<1024*1024?`${Math.max(1,Math.round(t/1024))} KB`:`${(t/1024/1024).toFixed(1)} MB`;function G(t,i){return i?i.split(",").some(u=>{const s=u.trim().toLowerCase();return s.startsWith(".")?t.name.toLowerCase().endsWith(s):s.endsWith("/*")?t.type.startsWith(s.slice(0,-1)):t.type===s}):!0}function O({file:t}){const i=t.name.toLowerCase();return t.type.startsWith("image/")?r(H,{}):/\.(csv|xlsx?|ods)$/.test(i)?r(K,{}):/\.(pdf|docx?|txt|md)$/.test(i)?r(X,{}):r(A,{})}function J({file:t}){const[i,u]=d.useState(null);return d.useEffect(()=>{if(!t.type.startsWith("image/"))return;const s=URL.createObjectURL(t);return u(s),()=>URL.revokeObjectURL(s)},[t]),r("span",{className:"grid size-10 shrink-0 place-items-center overflow-hidden rounded-[calc(9px*var(--radius-scale))] border border-border bg-surface text-muted [&_svg]:size-[18px]",children:i?r("img",{src:i,alt:"",className:"size-full object-cover"}):r(O,{file:t})})}function ee({value:t,defaultValue:i=[],onValueChange:u,accept:s,multiple:v=!0,maxSize:m,maxFiles:p,variant:M="dropzone",title:z,hint:W,progress:I,failed:T,onRetry:F,disabled:b,className:B}){const[V,P]=d.useState(i),g=t??V,[_,R]=d.useState([]),[x,y]=d.useState(!1),N=d.useRef(null),h=d.useRef(0),$=e=>{t===void 0&&P(e),u?.(e)},C=e=>{if(!e)return;const a=[],o=[];for(const c of Array.from(e))G(c,s)?m&&c.size>m?o.push({file:c,reason:`Over ${k(m)}`}):a.push(c):o.push({file:c,reason:"Not an accepted type"});let l=v?[...g,...a.filter(c=>!g.some(L=>L.name===c.name&&L.size===c.size))]:a.slice(0,1);p&&l.length>p&&(l.slice(p).forEach(c=>o.push({file:c,reason:`Only ${p} file${p>1?"s":""}`})),l=l.slice(0,p)),R(o),$(l)},S=e=>$(g.filter(a=>a!==e)),w=W??[s?.split(",").map(e=>e.trim().replace(/^\./,"").toUpperCase()).join(", "),m?`up to ${k(m)}`:null].filter(Boolean).join(" \xB7 "),D=r("input",{ref:N,type:"file",className:"sr-only",tabIndex:-1,accept:s,multiple:v,disabled:b,onChange:e=>{C(e.target.files),e.target.value=""}}),U={onDragEnter:e=>{e.preventDefault(),h.current+=1,y(!0)},onDragOver:e=>e.preventDefault(),onDragLeave:()=>{h.current-=1,h.current<=0&&y(!1)},onDrop:e=>{e.preventDefault(),h.current=0,y(!1),b||C(e.dataTransfer.files)}};return n("div",{className:f("w-full space-y-2.5",B),children:[M==="dropzone"?n("button",{type:"button",disabled:b,onClick:()=>N.current?.click(),...U,className:f("group relative flex w-full cursor-pointer flex-col items-center justify-center gap-2 overflow-hidden rounded-[calc(14px*var(--radius-scale))] border-[1.5px] border-dashed border-border2 bg-surface px-6 py-8 text-center outline-none","transition-[border-color,background-color,box-shadow] duration-200 hover:border-primary/50 hover:bg-primary-subtle/30 focus-visible:ring-2 focus-visible:ring-primary/35",x&&"border-primary bg-primary-subtle/50 shadow-[0_0_0_4px_var(--primary-subtle)]",b&&"cursor-not-allowed opacity-50"),children:[r("span",{className:f("grid size-12 place-items-center rounded-[calc(14px*var(--radius-scale))] border border-border bg-raised text-primary shadow-[var(--lit),0_4px_12px_-6px_color-mix(in_srgb,var(--primary)_45%,transparent)] transition-transform duration-300 ease-[cubic-bezier(.3,1.5,.5,1)] [&_svg]:size-[22px]",x?"-translate-y-1 scale-110":"group-hover:-translate-y-0.5"),children:r(j,{})}),r("span",{className:"text-[13.5px] font-semibold text-text",children:x?"Drop to add":z??n(Q,{children:[n("span",{className:"text-primary",children:["Choose ",v?"files":"a file"]})," or drag ",v?"them":"it"," here"]})}),w?r("span",{className:"text-[12px] text-muted",children:w}):null,D]}):n("div",{...U,className:f("flex items-center gap-3 rounded-ctl border border-dashed border-border2 bg-surface p-2 pl-3 transition-colors",x&&"border-primary bg-primary-subtle/50"),children:[r(j,{className:"size-4 shrink-0 text-muted"}),r("span",{className:"min-w-0 flex-1 truncate text-[12.5px] text-muted",children:x?"Drop to add":z??w??"Drag files here"}),r("button",{type:"button",disabled:b,onClick:()=>N.current?.click(),className:"h-7 shrink-0 cursor-pointer rounded-[calc(7px*var(--radius-scale))] border border-border2 bg-raised px-2.5 text-[12px] font-medium text-text shadow-[0_1px_1px_rgba(5,8,22,.05)] transition-colors hover:bg-hover disabled:cursor-not-allowed disabled:opacity-50",children:"Browse"}),D]}),g.length||_.length?n("ul",{className:"space-y-1.5",children:[g.map(e=>{const a=I?.[e.name],o=T?.includes(e.name),l=a!==void 0&&a<100&&!o;return n("li",{className:"flex items-center gap-3 rounded-[calc(11px*var(--radius-scale))] border border-border bg-raised p-2 pr-2.5 animate-[wave-in_220ms_var(--ease)]",children:[r(J,{file:e}),n("span",{className:"min-w-0 flex-1",children:[r("span",{className:"block truncate text-[13px] font-medium text-text",children:e.name}),n("span",{className:f("num flex items-center gap-1.5 text-[11.5px]",o?"text-danger":"text-muted"),children:[k(e.size),o?" \xB7 Upload failed":a===100?" \xB7 Uploaded":l?` \xB7 ${Math.round(a)}%`:null]}),l?r("span",{className:"mt-1.5 block h-1 overflow-hidden rounded-full bg-hover",children:r("span",{className:"block h-full rounded-full bg-[linear-gradient(90deg,var(--brand-1),var(--brand-2))] transition-[width] duration-300",style:{width:`${a}%`}})}):null]}),o&&F?r("button",{type:"button",onClick:()=>F(e),"aria-label":`Retry ${e.name}`,className:"grid size-7 cursor-pointer place-items-center rounded-[calc(7px*var(--radius-scale))] text-danger transition-colors hover:bg-danger-subtle [&_svg]:size-3.5",children:r(q,{})}):null,r("button",{type:"button",onClick:()=>S(e),"aria-label":`Remove ${e.name}`,className:"grid size-7 cursor-pointer place-items-center rounded-[calc(7px*var(--radius-scale))] text-muted transition-colors hover:bg-hover hover:text-text [&_svg]:size-3.5",children:r(E,{})})]},`${e.name}-${e.size}-${e.lastModified}`)}),_.map(({file:e,reason:a})=>n("li",{className:"flex items-center gap-3 rounded-[calc(11px*var(--radius-scale))] border border-danger/25 bg-danger-subtle/50 p-2 pr-2.5",role:"alert",children:[r("span",{className:"grid size-10 shrink-0 place-items-center rounded-[calc(9px*var(--radius-scale))] border border-danger/20 bg-raised text-danger [&_svg]:size-[18px]",children:r(O,{file:e})}),n("span",{className:"min-w-0 flex-1",children:[r("span",{className:"block truncate text-[13px] font-medium text-text",children:e.name}),n("span",{className:"text-[11.5px] text-danger",children:[a," \xB7 not added"]})]}),r("button",{type:"button",onClick:()=>R(o=>o.filter(l=>l.file!==e)),"aria-label":`Dismiss ${e.name}`,className:"grid size-7 cursor-pointer place-items-center rounded-[calc(7px*var(--radius-scale))] text-muted transition-colors hover:bg-raised hover:text-text [&_svg]:size-3.5",children:r(E,{})})]},`x-${e.name}-${e.size}`))]}):null]})}export{ee as FileUpload};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** Primitives: small, unopinionated building blocks (Radix underneath where it helps). */
|
|
2
|
+
export * from "./alert";
|
|
2
3
|
export * from "./avatar";
|
|
3
4
|
export * from "./badge";
|
|
4
5
|
export * from "./button";
|
|
@@ -7,21 +8,30 @@ export * from "./card";
|
|
|
7
8
|
export * from "./checkbox";
|
|
8
9
|
export * from "./combobox";
|
|
9
10
|
export * from "./confirm-dialog";
|
|
11
|
+
export * from "./date-picker";
|
|
10
12
|
export * from "./dialog";
|
|
11
13
|
export * from "./dropdown-menu";
|
|
14
|
+
export * from "./file-upload";
|
|
12
15
|
export * from "./form-field";
|
|
13
16
|
export * from "./input";
|
|
17
|
+
export * from "./kbd";
|
|
14
18
|
export * from "./label";
|
|
15
19
|
export * from "./menu";
|
|
20
|
+
export * from "./number-input";
|
|
21
|
+
export * from "./password-input";
|
|
22
|
+
export * from "./pin-input";
|
|
16
23
|
export * from "./popover";
|
|
17
|
-
export * from "./date-picker";
|
|
18
24
|
export * from "./progress";
|
|
25
|
+
export * from "./radio-group";
|
|
19
26
|
export * from "./segmented";
|
|
20
27
|
export * from "./select";
|
|
21
28
|
export * from "./separator";
|
|
22
29
|
export * from "./sheet";
|
|
23
30
|
export * from "./skeleton";
|
|
31
|
+
export * from "./slider";
|
|
32
|
+
export * from "./spinner";
|
|
24
33
|
export * from "./switch";
|
|
25
34
|
export * from "./tabs";
|
|
26
35
|
export * from "./time-picker";
|
|
36
|
+
export * from "./toast";
|
|
27
37
|
export * from "./tooltip";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./avatar.js";export*from"./badge.js";export*from"./button.js";export*from"./calendar.js";export*from"./card.js";export*from"./checkbox.js";export*from"./combobox.js";export*from"./confirm-dialog.js";export*from"./dialog.js";export*from"./dropdown-menu.js";export*from"./form-field.js";export*from"./input.js";export*from"./label.js";export*from"./menu.js";export*from"./
|
|
1
|
+
export*from"./alert.js";export*from"./avatar.js";export*from"./badge.js";export*from"./button.js";export*from"./calendar.js";export*from"./card.js";export*from"./checkbox.js";export*from"./combobox.js";export*from"./confirm-dialog.js";export*from"./date-picker.js";export*from"./dialog.js";export*from"./dropdown-menu.js";export*from"./file-upload.js";export*from"./form-field.js";export*from"./input.js";export*from"./kbd.js";export*from"./label.js";export*from"./menu.js";export*from"./number-input.js";export*from"./password-input.js";export*from"./pin-input.js";export*from"./popover.js";export*from"./progress.js";export*from"./radio-group.js";export*from"./segmented.js";export*from"./select.js";export*from"./separator.js";export*from"./sheet.js";export*from"./skeleton.js";export*from"./slider.js";export*from"./spinner.js";export*from"./switch.js";export*from"./tabs.js";export*from"./time-picker.js";export*from"./toast.js";export*from"./tooltip.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Kbd — a key, drawn as a key: a lip along the bottom, so "⌘K" reads as
|
|
4
|
+
* something to press and not as text. Pass `keys` for a combination; they
|
|
5
|
+
* are set apart with a thin joiner, and read out with "+".
|
|
6
|
+
*/
|
|
7
|
+
export declare function Kbd({ keys, size, className, children, }: {
|
|
8
|
+
/** A combination: ["⌘", "K"]. */
|
|
9
|
+
keys?: string[];
|
|
10
|
+
size?: "sm" | "md";
|
|
11
|
+
className?: string;
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as p}from"react/jsx-runtime";import*as o from"react";import{cn as r}from"../../lib/utils.js";function b({keys:a,size:i="md",className:t,children:s}){const d=r("inline-grid place-items-center rounded-[calc(6px*var(--radius-scale))] border border-border2 border-b-[2.5px] bg-raised font-sans font-medium text-body","shadow-[inset_0_-1px_0_var(--border),0_1px_1px_rgba(5,8,22,.06)]",i==="sm"?"h-5 min-w-5 px-1 text-[10.5px]":"h-6 min-w-6 px-1.5 text-[11.5px]");return a?e("kbd",{className:r("inline-flex items-center gap-1",t),"aria-label":a.join(" + "),children:a.map((m,n)=>p(o.Fragment,{children:[n>0?e("span",{"aria-hidden":!0,className:"text-[10px] text-placeholder",children:"+"}):null,e("kbd",{className:d,"aria-hidden":!0,children:m})]},n))}):e("kbd",{className:r(d,t),children:s})}export{b as Kbd};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{Fragment as D,jsx as o,jsxs as M}from"react/jsx-runtime";import{Slot as V}from"@radix-ui/react-slot";import{ChevronRight as q}from"lucide-react";import*as r from"react";import{cn as u}from"../../lib/utils.js";const S={soft:{root:"",indicator:"-z-10 rounded-[9px] bg-primary-subtle ring-1 ring-inset ring-primary/10",item:["text-body hover:bg-hover hover:text-text","text-primary"],icon:["text-muted group-hover/item:text-text","text-primary"],tile:["border-border bg-surface","border-primary/20 bg-raised shadow-[0_2px_6px_-2px_rgba(79,70,229,.35)]"],description:["text-muted","text-primary/70"],count:["bg-hover text-muted","bg-primary text-white"],kbd:["border-border bg-surface text-muted","border-primary/20 bg-raised text-primary"]},line:{root:"pl-3 before:absolute before:inset-y-1 before:left-[5px] before:w-px before:bg-border",indicator:"z-[1] rounded-full bg-[linear-gradient(180deg,#5b4af5,#1f45ea)] shadow-[0_0_0_3px_var(--canvas),0_0_12px_rgba(91,74,245,.55)]",item:["text-muted hover:bg-hover/70 hover:text-text","bg-[linear-gradient(90deg,var(--primary-subtle),transparent_85%)] text-text"],icon:["text-muted group-hover/item:text-text","text-primary"],tile:["border-border bg-surface","border-primary/20 bg-primary-subtle"],description:["text-muted","text-muted"],count:["bg-hover text-muted","bg-primary-subtle text-primary"],kbd:["border-border bg-surface text-muted","border-border bg-raised text-text"]},raised:{root:"rounded-[14px] border border-border bg-surface p-1.5 shadow-[inset_0_1px_2px_rgba(5,8,22,.04)]",indicator:"-z-10 rounded-[10px] bg-raised ring-1 ring-border/70 shadow-[var(--lit),0_1px_2px_rgba(5,8,22,.06),0_6px_16px_-6px_rgba(5,8,22,.16)]",item:["text-muted hover:bg-raised/60 hover:text-text","text-text"],icon:["text-muted group-hover/item:text-text","text-primary"],tile:["border-border bg-raised","border-primary/15 bg-primary-subtle"],description:["text-muted","text-muted"],count:["bg-hover text-muted","bg-primary-subtle text-primary"],kbd:["border-border bg-raised text-muted","border-border bg-surface text-text"]},gradient:{root:"",indicator:"-z-10 rounded-[10px] bg-[linear-gradient(135deg,#1f45ea,#5b4af5)] shadow-[inset_0_1px_0_rgba(255,255,255,.25),0_8px_20px_-8px_rgba(20,55,211,.7)]",item:["text-body hover:bg-hover hover:text-text","text-white"],icon:["text-muted group-hover/item:text-text","text-white"],tile:["border-border bg-surface","border-white/20 bg-white/15 shadow-[inset_0_1px_0_rgba(255,255,255,.2)]"],description:["text-muted","text-white/75"],count:["bg-hover text-muted","bg-white/20 text-white"],kbd:["border-border bg-surface text-muted","border-white/25 bg-white/10 text-white/85"]},dark:{root:"rounded-[16px] border border-white/10 p-1.5 text-white bg-[#120b2e] bg-[image:radial-gradient(120%_70%_at_0%_0%,rgba(91,74,245,.30),transparent_60%),radial-gradient(90%_60%_at_100%_100%,rgba(31,69,234,.18),transparent_60%)] shadow-[inset_0_1px_0_rgba(255,255,255,.06),0_18px_40px_-16px_rgba(5,8,22,.6)] [--hover:rgba(255,255,255,.06)] [--surface:rgba(255,255,255,.05)] [--raised:rgba(255,255,255,.08)] [--text:#f5f6fa] [--body:#c9cce0] [--muted:#8d93b3] [--border:rgba(255,255,255,.1)] [--primary:#a5a8ff] [--primary-subtle:rgba(139,143,248,.16)] [--danger:#f87171] [--danger-subtle:rgba(239,68,68,.16)] [--canvas:#120b2e]",indicator:"-z-10 rounded-[10px] bg-white/[.07] ring-1 ring-inset ring-white/10 shadow-[inset_0_1px_0_rgba(255,255,255,.08)] before:absolute before:inset-y-2 before:left-0 before:w-[3px] before:rounded-r-full before:bg-[#a5a8ff] before:shadow-[0_0_12px_2px_rgba(139,143,248,.65)]",item:["text-body hover:bg-hover hover:text-text","text-white"],icon:["text-muted group-hover/item:text-text","text-[#a5a8ff]"],tile:["border-border bg-surface","border-[#a5a8ff]/30 bg-[#a5a8ff]/15"],description:["text-muted","text-white/55"],count:["bg-white/[.06] text-muted","bg-[#a5a8ff]/20 text-white"],kbd:["border-border bg-surface text-muted","border-white/15 bg-white/10 text-white/70"]},panel:{root:"rounded-[14px] border border-border bg-surface px-2.5 py-3",indicator:"-z-10 rounded-ctl bg-primary-subtle",item:["font-normal text-body hover:bg-hover hover:text-text","text-primary"],icon:["text-muted group-hover/item:text-text","text-primary"],tile:["border-border bg-raised","border-primary/20 bg-raised"],description:["text-muted","text-primary/70"],count:["bg-transparent px-0 text-[12px] font-normal text-muted","bg-transparent px-0 text-[12px] font-normal text-primary"],kbd:["border-border bg-raised text-muted","border-primary/20 bg-raised text-primary"]},rail:{root:"w-[72px] items-center rounded-[14px] border border-border bg-surface py-2",indicator:"-z-10 rounded-ctl bg-primary-subtle before:absolute before:inset-y-2.5 before:left-[var(--bar-x)] before:w-[3px] before:rounded-r-[3px] before:bg-primary",item:["text-muted hover:bg-hover hover:text-text","text-primary"],icon:["",""],tile:["",""],description:["",""],count:["bg-raised text-body ring-2 ring-surface","bg-primary text-white ring-2 ring-surface"],kbd:["",""],rail:!0}},P=r.createContext({look:"soft",value:void 0,select:()=>{}}),O=r.createContext(null),I="[data-menu-item]",z='[data-menu-sub-body][data-state="closed"]';function K(t){let a=t.querySelector(`${I}[data-active]`),n=a?.closest(z)??null;for(;a&&n&&t.contains(n);)a=n.parentElement?.querySelector(":scope > [data-menu-trigger]")??null,n=n.parentElement?.closest(z)??null;return a}function $(t,a){let n=0,b=0,i=t;for(;i&&i!==a;)n+=i.offsetLeft,b+=i.offsetTop,i=i.offsetParent;return i===a?{x:n,y:b,w:t.offsetWidth,h:t.offsetHeight}:null}const j=r.forwardRef(({variant:t="soft",value:a,defaultValue:n,onValueChange:b,heading:i,className:_,children:N,onKeyDown:y,...E},s)=>{const d=r.useRef(null),[H,l]=r.useState(n),L=a!==void 0?a:H,[x,f]=r.useState(null),c=r.useCallback(e=>{a===void 0&&l(e),b?.(e)},[a,b]),R=r.useMemo(()=>({look:t,value:L,select:c}),[t,L,c]);r.useLayoutEffect(()=>{const e=d.current;if(!e)return;const h=()=>{const T=K(e),p=T?$(T,e):null;f(g=>g&&p&&g.x===p.x&&g.y===p.y&&g.w===p.w&&g.h===p.h?g:p)};h();const C=new MutationObserver(h);C.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["data-active","data-state"]});const m=new ResizeObserver(h);return m.observe(e),e.addEventListener("transitionend",h),()=>{C.disconnect(),m.disconnect(),e.removeEventListener("transitionend",h)}},[t]);const v=e=>{y?.(e);const h=d.current;if(e.defaultPrevented||!h)return;const C=document.activeElement,m=Array.from(h.querySelectorAll(I)).filter(g=>!g.closest("[inert]")&&!g.hasAttribute("disabled")&&g.getAttribute("aria-disabled")!=="true"),T=C?m.indexOf(C):-1;if(T<0)return;let p;e.key==="ArrowDown"?p=m[(T+1)%m.length]:e.key==="ArrowUp"?p=m[(T-1+m.length)%m.length]:e.key==="Home"?p=m[0]:e.key==="End"?p=m[m.length-1]:e.key==="ArrowLeft"&&(p=C.closest("[data-menu-sub-body]")?.parentElement?.querySelector(":scope > [data-menu-trigger]")),p&&(e.preventDefault(),p.focus())},k=S[t],w=t==="line";return o(P.Provider,{value:R,children:M("nav",{ref:e=>{d.current=e,typeof s=="function"?s(e):s&&(s.current=e)},"data-variant":t,className:u("relative isolate flex flex-col gap-0.5 text-[13px]",k.root,_),onKeyDown:v,...E,children:[i?k.rail?o("div",{className:"mb-3 grid shrink-0 place-items-center",children:i}):o("h2",{className:"px-2.5 pb-2.5 pt-1.5 text-[13px] font-semibold leading-[18px] text-text",children:i}):null,N,x?o("span",{"aria-hidden":!0,className:u("pointer-events-none absolute left-0 top-0 transition-[transform,width,height] duration-300 ease-[cubic-bezier(.3,.7,.2,1)]",k.indicator),style:w?{transform:`translate3d(4px, ${x.y+7}px, 0)`,width:3,height:Math.max(x.h-14,8)}:{transform:`translate3d(${x.x}px, ${x.y}px, 0)`,width:x.w,height:x.h,"--bar-x":`${-x.x}px`}}):null]})})});j.displayName="Menu";function A({label:t,icon:a,description:n,badge:b,count:i,shortcut:_,on:N,danger:y,trailing:E}){const s=S[r.useContext(P).look],d=N?1:0;return s.rail?M(D,{children:[a,o("span",{className:"w-full truncate px-0.5 text-center text-[10px] font-medium leading-3",children:t}),i!==void 0?o("span",{className:u("num absolute right-1 top-1 min-w-4 rounded-full px-1 text-center text-[9.5px] font-semibold leading-4 transition-colors",s.count[d]),children:i}):null]}):M(D,{children:[a?n?o("span",{className:u("grid size-8 shrink-0 place-items-center rounded-[9px] border transition-colors",y?"border-danger/20 bg-danger-subtle text-danger":u(s.tile[d],s.icon[d])),children:a}):o("span",{className:u("grid shrink-0 place-items-center transition-colors",y?"text-danger":s.icon[d]),children:a}):null,M("span",{className:"min-w-0 flex-1",children:[M("span",{className:"flex items-center gap-2",children:[o("span",{className:"truncate",children:t}),b]}),n?o("span",{className:u("mt-0.5 block truncate text-[11.5px] font-normal leading-4",y?"text-danger/70":s.description[d]),children:n}):null]}),i!==void 0?o("span",{className:u("num min-w-5 shrink-0 rounded-full px-1.5 text-center text-[10.5px] font-semibold leading-[18px] transition-colors",s.count[d]),children:i}):null,_?o("kbd",{className:u("shrink-0 rounded-[5px] border px-1.5 py-px font-sans text-[10.5px] font-medium transition-colors",s.kbd[d]),children:_}):null,E]})}const F="mx-auto min-h-14 w-[60px] flex-col justify-center gap-[3px] px-0.5 py-1.5 [&_svg]:size-[19px]",B="group/item relative flex min-h-item w-full cursor-pointer select-none items-center gap-2.5 rounded-[9px] px-2.5 py-1.5 text-left font-medium outline-none transition-[color,background-color] duration-150 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary/45 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0",G=r.forwardRef(({value:t,active:a,danger:n,asChild:b,icon:i,description:_,badge:N,count:y,shortcut:E,className:s,children:d,onClick:H,...l},L)=>{const x=r.useContext(P),f=r.useContext(O),c=!n&&(a??(t!==void 0&&x.value===t)),R=S[x.look];r.useEffect(()=>{if(!(!c||!f))return f.reveal(),f.mark(1),()=>f.mark(-1)},[c,f]);const v={"data-menu-item":"","data-active":c?"":void 0,"aria-current":c?"page":void 0,className:u(B,R.rail&&F,n?"text-danger hover:bg-danger-subtle":R.item[c?1:0],s),onClick:w=>{H?.(w),!w.defaultPrevented&&t!==void 0&&x.select(t)}},k=w=>o(A,{label:w,icon:i,description:_,badge:N,count:y,shortcut:E,on:c,danger:n});return b&&r.isValidElement(d)?o(V,{ref:L,...v,...l,children:r.cloneElement(d,void 0,k(d.props.children))}):o("button",{ref:L,type:"button",...v,...l,children:k(d)})});G.displayName="MenuItem";function J({label:t,defaultOpen:a=!1,open:n,onOpenChange:b,disabled:i,className:_,children:N,...y}){const E=r.useContext(P),s=r.useContext(O),[d,H]=r.useState(a),l=n??d,[L,x]=r.useState(0),f=r.useId(),c=r.useCallback(e=>{n===void 0&&H(e),b?.(e)},[n,b]),R=r.useMemo(()=>({reveal:()=>{c(!0),s?.reveal()},mark:e=>x(h=>h+e)}),[c,s]),v=L>0;r.useEffect(()=>{if(!(!v||!s))return s.mark(1),()=>s.mark(-1)},[v,s]);const k=S[E.look],w=v&&!l;return M("div",{"data-menu-sub":"",className:_,children:[o("button",{type:"button","data-menu-item":"","data-menu-trigger":"","data-state":l?"open":"closed","aria-expanded":l,"aria-controls":f,disabled:i,className:u(B,k.item[w?1:0],v&&l&&"text-text"),onClick:()=>c(!l),onKeyDown:e=>{e.key==="ArrowRight"?(e.preventDefault(),l?document.getElementById(f)?.querySelector(I)?.focus():c(!0)):e.key==="ArrowLeft"&&l&&(e.preventDefault(),c(!1))},children:o(A,{label:t,...y,on:w,trailing:o(q,{className:u("!size-3.5 shrink-0 opacity-60 transition-transform duration-200",l&&"rotate-90"),"aria-hidden":!0})})}),o("div",{id:f,"data-menu-sub-body":"","data-state":l?"open":"closed",inert:!l,className:u("grid transition-[grid-template-rows,opacity] duration-300 ease-[var(--ease)]",l?"grid-rows-[1fr] opacity-100":"grid-rows-[0fr] opacity-0"),children:o("div",{className:"min-h-0 overflow-hidden",children:o("div",{className:"relative ml-[18px] flex flex-col gap-0.5 py-0.5 pl-3 before:absolute before:inset-y-1 before:left-0 before:w-px before:bg-border",children:o(O.Provider,{value:R,children:N})})})})]})}function Q({label:t,action:a,className:n,children:b}){const i=r.useId();return S[r.useContext(P).look].rail?o("div",{role:"group","aria-label":typeof t=="string"?t:void 0,className:u("flex w-full flex-col items-center gap-0.5 [&:not(:first-child)]:before:my-1.5 [&:not(:first-child)]:before:h-px [&:not(:first-child)]:before:w-8 [&:not(:first-child)]:before:bg-border2",n),children:b}):M("div",{role:"group","aria-labelledby":t?i:void 0,className:u("flex flex-col gap-0.5 [&:not(:first-child)]:mt-2",n),children:[t?M("div",{className:"flex items-center justify-between gap-2 px-2.5 pb-1 pt-1.5",children:[o("p",{id:i,className:"ov",children:t}),a]}):null,b]})}function X({className:t}){return o("div",{role:"separator",className:u("mx-1 my-1.5 h-px shrink-0 bg-border",t)})}export{j as Menu,Q as MenuGroup,G as MenuItem,X as MenuSeparator,J as MenuSub};
|
|
1
|
+
"use client";import{Fragment as D,jsx as o,jsxs as M}from"react/jsx-runtime";import{Slot as V}from"@radix-ui/react-slot";import{ChevronRight as q}from"lucide-react";import*as r from"react";import{cn as u}from"../../lib/utils.js";const S={soft:{root:"",indicator:"-z-10 rounded-[calc(9px*var(--radius-scale))] bg-primary-subtle ring-1 ring-inset ring-primary/10",item:["text-body hover:bg-hover hover:text-text","text-primary"],icon:["text-muted group-hover/item:text-text","text-primary"],tile:["border-border bg-surface","border-primary/20 bg-raised shadow-[0_2px_6px_-2px_color-mix(in_srgb,var(--primary)_35%,transparent)]"],description:["text-muted","text-primary/70"],count:["bg-hover text-muted","bg-primary text-white"],kbd:["border-border bg-surface text-muted","border-primary/20 bg-raised text-primary"]},line:{root:"pl-3 before:absolute before:inset-y-1 before:left-[5px] before:w-px before:bg-border",indicator:"z-[1] rounded-full bg-[linear-gradient(180deg,var(--brand-2),var(--brand-1))] shadow-[0_0_0_3px_var(--canvas),0_0_12px_color-mix(in_srgb,var(--brand-2)_55%,transparent)]",item:["text-muted hover:bg-hover/70 hover:text-text","bg-[linear-gradient(90deg,var(--primary-subtle),transparent_85%)] text-text"],icon:["text-muted group-hover/item:text-text","text-primary"],tile:["border-border bg-surface","border-primary/20 bg-primary-subtle"],description:["text-muted","text-muted"],count:["bg-hover text-muted","bg-primary-subtle text-primary"],kbd:["border-border bg-surface text-muted","border-border bg-raised text-text"]},raised:{root:"rounded-[calc(14px*var(--radius-scale))] border border-border bg-surface p-1.5 shadow-[inset_0_1px_2px_rgba(5,8,22,.04)]",indicator:"-z-10 rounded-[calc(10px*var(--radius-scale))] bg-raised ring-1 ring-border/70 shadow-[var(--lit),0_1px_2px_rgba(5,8,22,.06),0_6px_16px_-6px_rgba(5,8,22,.16)]",item:["text-muted hover:bg-raised/60 hover:text-text","text-text"],icon:["text-muted group-hover/item:text-text","text-primary"],tile:["border-border bg-raised","border-primary/15 bg-primary-subtle"],description:["text-muted","text-muted"],count:["bg-hover text-muted","bg-primary-subtle text-primary"],kbd:["border-border bg-raised text-muted","border-border bg-surface text-text"]},gradient:{root:"",indicator:"-z-10 rounded-[calc(10px*var(--radius-scale))] bg-[linear-gradient(135deg,var(--brand-1),var(--brand-2))] shadow-[inset_0_1px_0_rgba(255,255,255,.25),0_8px_20px_-8px_color-mix(in_srgb,var(--brand-1)_70%,transparent)]",item:["text-body hover:bg-hover hover:text-text","text-white"],icon:["text-muted group-hover/item:text-text","text-white"],tile:["border-border bg-surface","border-white/20 bg-white/15 shadow-[inset_0_1px_0_rgba(255,255,255,.2)]"],description:["text-muted","text-white/75"],count:["bg-hover text-muted","bg-white/20 text-white"],kbd:["border-border bg-surface text-muted","border-white/25 bg-white/10 text-white/85"]},dark:{root:"rounded-[calc(16px*var(--radius-scale))] border border-white/10 p-1.5 text-white bg-[var(--ink)] bg-[image:radial-gradient(120%_70%_at_0%_0%,color-mix(in_srgb,var(--brand-2)_30%,transparent),transparent_60%),radial-gradient(90%_60%_at_100%_100%,color-mix(in_srgb,var(--brand-1)_18%,transparent),transparent_60%)] shadow-[inset_0_1px_0_rgba(255,255,255,.06),0_18px_40px_-16px_rgba(5,8,22,.6)] [--hover:rgba(255,255,255,.06)] [--surface:rgba(255,255,255,.05)] [--raised:rgba(255,255,255,.08)] [--text:#f5f6fa] [--body:#c9cce0] [--muted:#8d93b3] [--border:rgba(255,255,255,.1)] [--primary:#a5a8ff] [--primary-subtle:rgba(139,143,248,.16)] [--danger:#f87171] [--danger-subtle:rgba(239,68,68,.16)] [--canvas:var(--ink)]",indicator:"-z-10 rounded-[calc(10px*var(--radius-scale))] bg-white/[.07] ring-1 ring-inset ring-white/10 shadow-[inset_0_1px_0_rgba(255,255,255,.08)] before:absolute before:inset-y-2 before:left-0 before:w-[3px] before:rounded-r-full before:bg-[#a5a8ff] before:shadow-[0_0_12px_2px_rgba(139,143,248,.65)]",item:["text-body hover:bg-hover hover:text-text","text-white"],icon:["text-muted group-hover/item:text-text","text-[#a5a8ff]"],tile:["border-border bg-surface","border-[#a5a8ff]/30 bg-[#a5a8ff]/15"],description:["text-muted","text-white/55"],count:["bg-white/[.06] text-muted","bg-[#a5a8ff]/20 text-white"],kbd:["border-border bg-surface text-muted","border-white/15 bg-white/10 text-white/70"]},panel:{root:"rounded-[calc(14px*var(--radius-scale))] border border-border bg-surface px-2.5 py-3",indicator:"-z-10 rounded-ctl bg-primary-subtle",item:["font-normal text-body hover:bg-hover hover:text-text","text-primary"],icon:["text-muted group-hover/item:text-text","text-primary"],tile:["border-border bg-raised","border-primary/20 bg-raised"],description:["text-muted","text-primary/70"],count:["bg-transparent px-0 text-[12px] font-normal text-muted","bg-transparent px-0 text-[12px] font-normal text-primary"],kbd:["border-border bg-raised text-muted","border-primary/20 bg-raised text-primary"]},rail:{root:"w-[72px] items-center rounded-[calc(14px*var(--radius-scale))] border border-border bg-surface py-2",indicator:"-z-10 rounded-ctl bg-primary-subtle before:absolute before:inset-y-2.5 before:left-[var(--bar-x)] before:w-[3px] before:rounded-r-[3px] before:bg-primary",item:["text-muted hover:bg-hover hover:text-text","text-primary"],icon:["",""],tile:["",""],description:["",""],count:["bg-raised text-body ring-2 ring-surface","bg-primary text-white ring-2 ring-surface"],kbd:["",""],rail:!0}},P=r.createContext({look:"soft",value:void 0,select:()=>{}}),O=r.createContext(null),I="[data-menu-item]",z='[data-menu-sub-body][data-state="closed"]';function K(t){let a=t.querySelector(`${I}[data-active]`),n=a?.closest(z)??null;for(;a&&n&&t.contains(n);)a=n.parentElement?.querySelector(":scope > [data-menu-trigger]")??null,n=n.parentElement?.closest(z)??null;return a}function $(t,a){let n=0,c=0,i=t;for(;i&&i!==a;)n+=i.offsetLeft,c+=i.offsetTop,i=i.offsetParent;return i===a?{x:n,y:c,w:t.offsetWidth,h:t.offsetHeight}:null}const j=r.forwardRef(({variant:t="soft",value:a,defaultValue:n,onValueChange:c,heading:i,className:_,children:N,onKeyDown:v,...E},s)=>{const d=r.useRef(null),[H,l]=r.useState(n),L=a!==void 0?a:H,[x,f]=r.useState(null),b=r.useCallback(e=>{a===void 0&&l(e),c?.(e)},[a,c]),R=r.useMemo(()=>({look:t,value:L,select:b}),[t,L,b]);r.useLayoutEffect(()=>{const e=d.current;if(!e)return;const h=()=>{const T=K(e),p=T?$(T,e):null;f(g=>g&&p&&g.x===p.x&&g.y===p.y&&g.w===p.w&&g.h===p.h?g:p)};h();const C=new MutationObserver(h);C.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["data-active","data-state"]});const m=new ResizeObserver(h);return m.observe(e),e.addEventListener("transitionend",h),()=>{C.disconnect(),m.disconnect(),e.removeEventListener("transitionend",h)}},[t]);const y=e=>{v?.(e);const h=d.current;if(e.defaultPrevented||!h)return;const C=document.activeElement,m=Array.from(h.querySelectorAll(I)).filter(g=>!g.closest("[inert]")&&!g.hasAttribute("disabled")&&g.getAttribute("aria-disabled")!=="true"),T=C?m.indexOf(C):-1;if(T<0)return;let p;e.key==="ArrowDown"?p=m[(T+1)%m.length]:e.key==="ArrowUp"?p=m[(T-1+m.length)%m.length]:e.key==="Home"?p=m[0]:e.key==="End"?p=m[m.length-1]:e.key==="ArrowLeft"&&(p=C.closest("[data-menu-sub-body]")?.parentElement?.querySelector(":scope > [data-menu-trigger]")),p&&(e.preventDefault(),p.focus())},k=S[t],w=t==="line";return o(P.Provider,{value:R,children:M("nav",{ref:e=>{d.current=e,typeof s=="function"?s(e):s&&(s.current=e)},"data-variant":t,className:u("relative isolate flex flex-col gap-0.5 text-[13px]",k.root,_),onKeyDown:y,...E,children:[i?k.rail?o("div",{className:"mb-3 grid shrink-0 place-items-center",children:i}):o("h2",{className:"px-2.5 pb-2.5 pt-1.5 text-[13px] font-semibold leading-[18px] text-text",children:i}):null,N,x?o("span",{"aria-hidden":!0,className:u("pointer-events-none absolute left-0 top-0 transition-[transform,width,height] duration-300 ease-[cubic-bezier(.3,.7,.2,1)]",k.indicator),style:w?{transform:`translate3d(4px, ${x.y+7}px, 0)`,width:3,height:Math.max(x.h-14,8)}:{transform:`translate3d(${x.x}px, ${x.y}px, 0)`,width:x.w,height:x.h,"--bar-x":`${-x.x}px`}}):null]})})});j.displayName="Menu";function A({label:t,icon:a,description:n,badge:c,count:i,shortcut:_,on:N,danger:v,trailing:E}){const s=S[r.useContext(P).look],d=N?1:0;return s.rail?M(D,{children:[a,o("span",{className:"w-full truncate px-0.5 text-center text-[10px] font-medium leading-3",children:t}),i!==void 0?o("span",{className:u("num absolute right-1 top-1 min-w-4 rounded-full px-1 text-center text-[9.5px] font-semibold leading-4 transition-colors",s.count[d]),children:i}):null]}):M(D,{children:[a?n?o("span",{className:u("grid size-8 shrink-0 place-items-center rounded-[calc(9px*var(--radius-scale))] border transition-colors",v?"border-danger/20 bg-danger-subtle text-danger":u(s.tile[d],s.icon[d])),children:a}):o("span",{className:u("grid shrink-0 place-items-center transition-colors",v?"text-danger":s.icon[d]),children:a}):null,M("span",{className:"min-w-0 flex-1",children:[M("span",{className:"flex items-center gap-2",children:[o("span",{className:"truncate",children:t}),c]}),n?o("span",{className:u("mt-0.5 block truncate text-[11.5px] font-normal leading-4",v?"text-danger/70":s.description[d]),children:n}):null]}),i!==void 0?o("span",{className:u("num min-w-5 shrink-0 rounded-full px-1.5 text-center text-[10.5px] font-semibold leading-[18px] transition-colors",s.count[d]),children:i}):null,_?o("kbd",{className:u("shrink-0 rounded-[calc(5px*var(--radius-scale))] border px-1.5 py-px font-sans text-[10.5px] font-medium transition-colors",s.kbd[d]),children:_}):null,E]})}const F="mx-auto min-h-14 w-[60px] flex-col justify-center gap-[3px] px-0.5 py-1.5 [&_svg]:size-[19px]",B="group/item relative flex min-h-item w-full cursor-pointer select-none items-center gap-2.5 rounded-[calc(9px*var(--radius-scale))] px-2.5 py-1.5 text-left font-medium outline-none transition-[color,background-color] duration-150 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary/45 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0",G=r.forwardRef(({value:t,active:a,danger:n,asChild:c,icon:i,description:_,badge:N,count:v,shortcut:E,className:s,children:d,onClick:H,...l},L)=>{const x=r.useContext(P),f=r.useContext(O),b=!n&&(a??(t!==void 0&&x.value===t)),R=S[x.look];r.useEffect(()=>{if(!(!b||!f))return f.reveal(),f.mark(1),()=>f.mark(-1)},[b,f]);const y={"data-menu-item":"","data-active":b?"":void 0,"aria-current":b?"page":void 0,className:u(B,R.rail&&F,n?"text-danger hover:bg-danger-subtle":R.item[b?1:0],s),onClick:w=>{H?.(w),!w.defaultPrevented&&t!==void 0&&x.select(t)}},k=w=>o(A,{label:w,icon:i,description:_,badge:N,count:v,shortcut:E,on:b,danger:n});return c&&r.isValidElement(d)?o(V,{ref:L,...y,...l,children:r.cloneElement(d,void 0,k(d.props.children))}):o("button",{ref:L,type:"button",...y,...l,children:k(d)})});G.displayName="MenuItem";function J({label:t,defaultOpen:a=!1,open:n,onOpenChange:c,disabled:i,className:_,children:N,...v}){const E=r.useContext(P),s=r.useContext(O),[d,H]=r.useState(a),l=n??d,[L,x]=r.useState(0),f=r.useId(),b=r.useCallback(e=>{n===void 0&&H(e),c?.(e)},[n,c]),R=r.useMemo(()=>({reveal:()=>{b(!0),s?.reveal()},mark:e=>x(h=>h+e)}),[b,s]),y=L>0;r.useEffect(()=>{if(!(!y||!s))return s.mark(1),()=>s.mark(-1)},[y,s]);const k=S[E.look],w=y&&!l;return M("div",{"data-menu-sub":"",className:_,children:[o("button",{type:"button","data-menu-item":"","data-menu-trigger":"","data-state":l?"open":"closed","aria-expanded":l,"aria-controls":f,disabled:i,className:u(B,k.item[w?1:0],y&&l&&"text-text"),onClick:()=>b(!l),onKeyDown:e=>{e.key==="ArrowRight"?(e.preventDefault(),l?document.getElementById(f)?.querySelector(I)?.focus():b(!0)):e.key==="ArrowLeft"&&l&&(e.preventDefault(),b(!1))},children:o(A,{label:t,...v,on:w,trailing:o(q,{className:u("!size-3.5 shrink-0 opacity-60 transition-transform duration-200",l&&"rotate-90"),"aria-hidden":!0})})}),o("div",{id:f,"data-menu-sub-body":"","data-state":l?"open":"closed",inert:!l,className:u("grid transition-[grid-template-rows,opacity] duration-300 ease-[var(--ease)]",l?"grid-rows-[1fr] opacity-100":"grid-rows-[0fr] opacity-0"),children:o("div",{className:"min-h-0 overflow-hidden",children:o("div",{className:"relative ml-[18px] flex flex-col gap-0.5 py-0.5 pl-3 before:absolute before:inset-y-1 before:left-0 before:w-px before:bg-border",children:o(O.Provider,{value:R,children:N})})})})]})}function Q({label:t,action:a,className:n,children:c}){const i=r.useId();return S[r.useContext(P).look].rail?o("div",{role:"group","aria-label":typeof t=="string"?t:void 0,className:u("flex w-full flex-col items-center gap-0.5 [&:not(:first-child)]:before:my-1.5 [&:not(:first-child)]:before:h-px [&:not(:first-child)]:before:w-8 [&:not(:first-child)]:before:bg-border2",n),children:c}):M("div",{role:"group","aria-labelledby":t?i:void 0,className:u("flex flex-col gap-0.5 [&:not(:first-child)]:mt-2",n),children:[t?M("div",{className:"flex items-center justify-between gap-2 px-2.5 pb-1 pt-1.5",children:[o("p",{id:i,className:"ov",children:t}),a]}):null,c]})}function X({className:t}){return o("div",{role:"separator",className:u("mx-1 my-1.5 h-px shrink-0 bg-border",t)})}export{j as Menu,Q as MenuGroup,G as MenuItem,X as MenuSeparator,J as MenuSub};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type InputState } from "./input";
|
|
3
|
+
/**
|
|
4
|
+
* NumberInput — a number you type or step: a rate, a capacity, a quantity.
|
|
5
|
+
*
|
|
6
|
+
* ↑ / ↓ step it (Shift for ten steps), the buttons repeat while held, and the
|
|
7
|
+
* value is clamped to min / max when the field is left, not while typing, so
|
|
8
|
+
* "1" on the way to "150" is never snapped to the minimum. Out of focus it
|
|
9
|
+
* shows grouped ("12,500"); in focus, the raw number, ready to edit.
|
|
10
|
+
*
|
|
11
|
+
* `stepper`: "split" puts − and + either side (counts, quantities), "stack"
|
|
12
|
+
* puts small chevrons on the right (forms full of numbers), "none" hides them.
|
|
13
|
+
*/
|
|
14
|
+
export interface NumberInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "value" | "defaultValue" | "onChange" | "type" | "min" | "max" | "step" | "prefix"> {
|
|
15
|
+
value?: number | null;
|
|
16
|
+
defaultValue?: number | null;
|
|
17
|
+
onValueChange?: (value: number | null) => void;
|
|
18
|
+
min?: number;
|
|
19
|
+
max?: number;
|
|
20
|
+
step?: number;
|
|
21
|
+
/** Decimal places kept. Default: as many as `step` has. */
|
|
22
|
+
precision?: number;
|
|
23
|
+
/** Inside the box, before the number: "৳", "+880". */
|
|
24
|
+
prefix?: React.ReactNode;
|
|
25
|
+
/** After it: "min", "cars", "%". */
|
|
26
|
+
suffix?: React.ReactNode;
|
|
27
|
+
stepper?: "split" | "stack" | "none";
|
|
28
|
+
state?: InputState;
|
|
29
|
+
}
|
|
30
|
+
export declare const NumberInput: React.ForwardRefExoticComponent<NumberInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsx as r,jsxs as k}from"react/jsx-runtime";import{ChevronDown as j,ChevronUp as q,Minus as G,Plus as J}from"lucide-react";import*as s from"react";import{cn as u}from"../../lib/utils.js";import{inputClass as Q}from"./input.js";const X=l=>(String(l).split(".")[1]??"").length,Y=s.forwardRef(({value:l,defaultValue:T=null,onValueChange:P,min:i=-1/0,max:c=1/0,step:v=1,precision:z,prefix:D,suffix:M,stepper:d="split",state:h="default",className:A,disabled:b,onBlur:H,onFocus:W,onKeyDown:_,...N},K)=>{const m=z??X(v),[O,V]=s.useState(T),t=l!==void 0?l:O,[B,S]=s.useState(!1),[$,y]=s.useState(""),R=e=>Number(e.toFixed(m)),F=e=>Math.min(c,Math.max(i,e)),w=e=>{l===void 0&&V(e),P?.(e)},L=B?$:t===null?"":t.toLocaleString(void 0,{minimumFractionDigits:m,maximumFractionDigits:m}),I=s.useRef(t);I.current=t;const p=s.useCallback((e,n=1)=>{const a=I.current??(i>-1/0?i:0),f=F(R(a+e*v*n));I.current=f,w(f),y(String(f))},[i,c,v,m,l,P]),U=s.useRef(void 0),o=()=>window.clearTimeout(U.current),x=e=>n=>{if(n.button!==0)return;n.preventDefault(),p(e);const a=f=>{U.current=window.setTimeout(()=>{p(e),a(Math.max(40,f*.85))},f)};a(400)};s.useEffect(()=>o,[]);const C=t!==null&&t<=i,E=t!==null&&t>=c,g="grid shrink-0 cursor-pointer place-items-center text-muted transition-colors hover:bg-hover hover:text-text active:bg-[var(--selected)] disabled:pointer-events-none disabled:opacity-35";return k("div",{className:u(Q,"flex items-stretch overflow-hidden p-0 focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/20",h==="error"&&"border-danger bg-danger-subtle/30 focus-within:border-danger focus-within:ring-danger/20 wm-shake",h==="warning"&&"border-warning focus-within:border-warning focus-within:ring-warning/20",h==="success"&&"border-success focus-within:border-success focus-within:ring-success/20",b&&"cursor-not-allowed bg-hover",A),children:[d==="split"?r("button",{type:"button",tabIndex:-1,"aria-label":"Decrease",disabled:b||C,onPointerDown:x(-1),onPointerUp:o,onPointerLeave:o,className:u(g,"w-9 border-r border-border [&_svg]:size-3.5"),children:r(G,{strokeWidth:2.4})}):null,k("div",{className:u("flex min-w-0 flex-1 items-center gap-1.5 px-3",d==="split"&&"justify-center"),children:[D?r("span",{className:"shrink-0 text-[13px] text-muted",children:D}):null,r("input",{ref:K,type:"text",inputMode:m>0||i<0?"decimal":"numeric",role:"spinbutton","aria-valuenow":t??void 0,"aria-valuemin":Number.isFinite(i)?i:void 0,"aria-valuemax":Number.isFinite(c)?c:void 0,"aria-invalid":h==="error"?!0:N["aria-invalid"],disabled:b,value:L,style:d==="split"?{width:`${Math.max(2,(L||String(N.placeholder??"")).length+1)}ch`}:void 0,className:u("num h-full min-w-0 bg-transparent text-[13px] text-text outline-none placeholder:text-placeholder disabled:cursor-not-allowed",d==="split"?"max-w-full flex-none text-center":"w-full"),onFocus:e=>{y(t===null?"":String(t)),S(!0),W?.(e)},onChange:e=>{const n=e.target.value.replace(/[^\d.,-]/g,"");y(n);const a=Number(n.replace(/,/g,""));n===""||n==="-"?w(null):Number.isNaN(a)||w(a)},onBlur:e=>{if(S(!1),t!==null){const n=F(R(t));n!==t&&w(n)}H?.(e)},onKeyDown:e=>{_?.(e),!e.defaultPrevented&&(e.key==="ArrowUp"||e.key==="ArrowDown"?(e.preventDefault(),p(e.key==="ArrowUp"?1:-1,e.shiftKey?10:1)):e.key==="Home"&&Number.isFinite(i)?(e.preventDefault(),p(-1,1/0)):e.key==="End"&&Number.isFinite(c)&&(e.preventDefault(),p(1,1/0)))},...N}),M?r("span",{className:"shrink-0 text-[12.5px] text-muted",children:M}):null]}),d==="split"?r("button",{type:"button",tabIndex:-1,"aria-label":"Increase",disabled:b||E,onPointerDown:x(1),onPointerUp:o,onPointerLeave:o,className:u(g,"w-9 border-l border-border [&_svg]:size-3.5"),children:r(J,{strokeWidth:2.4})}):d==="stack"?k("div",{className:"flex w-7 shrink-0 flex-col border-l border-border [&_svg]:size-3",children:[r("button",{type:"button",tabIndex:-1,"aria-label":"Increase",disabled:b||E,onPointerDown:x(1),onPointerUp:o,onPointerLeave:o,className:u(g,"flex-1 border-b border-border"),children:r(q,{strokeWidth:2.4})}),r("button",{type:"button",tabIndex:-1,"aria-label":"Decrease",disabled:b||C,onPointerDown:x(-1),onPointerUp:o,onPointerLeave:o,className:u(g,"flex-1"),children:r(j,{strokeWidth:2.4})})]}):null]})});Y.displayName="NumberInput";export{Y as NumberInput};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type InputState } from "./input";
|
|
3
|
+
/**
|
|
4
|
+
* PasswordInput — a password field that can be read back before it is sent.
|
|
5
|
+
*
|
|
6
|
+
* The eye shows and hides it. Caps Lock is called out while it is on, because
|
|
7
|
+
* a password that "will not work" is most often typed in capitals. `strength`
|
|
8
|
+
* adds a four-step meter under the field for new passwords (not for sign-in,
|
|
9
|
+
* where it only gets in the way).
|
|
10
|
+
*/
|
|
11
|
+
export interface PasswordInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "type"> {
|
|
12
|
+
state?: InputState;
|
|
13
|
+
/** A meter under the field: for choosing a new password. */
|
|
14
|
+
strength?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** 0–4. Length counts most; each kind of character adds one. */
|
|
17
|
+
export declare function passwordScore(pw: string): number;
|
|
18
|
+
export declare const PasswordInput: React.ForwardRefExoticComponent<PasswordInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsx as t,jsxs as p}from"react/jsx-runtime";import{ArrowBigUpDash as k,Eye as C,EyeOff as L}from"lucide-react";import*as i from"react";import{cn as u}from"../../lib/utils.js";import{Input as E}from"./input.js";const M=[{label:"Too short",tone:"bg-danger",text:"text-danger"},{label:"Weak",tone:"bg-danger",text:"text-danger"},{label:"Fair",tone:"bg-warning",text:"text-warning"},{label:"Good",tone:"bg-[#4f9d2a]",text:"text-[#4f9d2a]"},{label:"Strong",tone:"bg-success",text:"text-success"}];function P(a){if(a.length<6)return 0;const s=[/[a-z]/,/[A-Z]/,/\d/,/[^A-Za-z0-9]/].filter(c=>c.test(a)).length;let n=a.length>=12?2:a.length>=8?1:0;return n+=Math.max(0,s-1),Math.min(4,Math.max(1,n))}const z=i.forwardRef(({className:a,strength:s,onKeyUp:n,onKeyDown:c,onBlur:w,onChange:h,value:o,defaultValue:m,...v},y)=>{const[r,S]=i.useState(!1),[g,f]=i.useState(!1),[N,I]=i.useState(String(m??"")),l=o!==void 0?String(o):N,x=P(l),d=M[x],b=e=>f(e.getModifierState?.("CapsLock")??!1);return p("div",{className:u("w-full",a),children:[t(E,{ref:y,type:r?"text":"password",autoComplete:s?"new-password":"current-password",spellCheck:!1,value:o,defaultValue:m,onChange:e=>{o===void 0&&I(e.target.value),h?.(e)},onKeyUp:e=>{b(e),n?.(e)},onKeyDown:e=>{b(e),c?.(e)},onBlur:e=>{f(!1),w?.(e)},trailing:p("span",{className:"flex items-center gap-1",children:[g?p("span",{title:"Caps Lock is on",className:"grid size-6 place-items-center rounded-[calc(6px*var(--radius-scale))] bg-warning-subtle text-warning animate-[wm-pop_180ms_var(--ease)] [&_svg]:!size-3.5",children:[t(k,{}),t("span",{className:"sr-only",children:"Caps Lock is on"})]}):null,t("button",{type:"button",onClick:()=>S(e=>!e),"aria-label":r?"Hide password":"Show password","aria-pressed":r,className:"grid size-7 cursor-pointer place-items-center rounded-[calc(6px*var(--radius-scale))] text-muted transition-colors hover:bg-hover hover:text-text",children:r?t(L,{}):t(C,{})})]}),className:g?"pr-[72px]":"pr-11",...v}),s?p("div",{className:"mt-2 flex items-center gap-3","aria-live":"polite",children:[t("div",{className:"flex flex-1 gap-1",children:[1,2,3,4].map(e=>t("span",{className:"h-1 flex-1 overflow-hidden rounded-full bg-hover",children:t("span",{className:u("block h-full rounded-full transition-[width,background-color] duration-300",d.tone),style:{width:l&&x>=e?"100%":"0%"}})},e))}),t("span",{className:u("w-16 text-right text-[11.5px] font-medium",l?d.text:"text-muted"),children:l?d.label:"Strength"})]}):null]})});z.displayName="PasswordInput";export{z as PasswordInput,P as passwordScore};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* PinInput — a one-time code or a PIN, one box per character.
|
|
4
|
+
*
|
|
5
|
+
* Typing moves to the next box, Backspace to the previous, and a pasted code
|
|
6
|
+
* (or the SMS code the phone offers) fills every box at once. `onComplete`
|
|
7
|
+
* fires when the last box is filled, so a verify screen needs no button.
|
|
8
|
+
*
|
|
9
|
+
* Looks: `boxed` (default), `underline` (quiet, on a card), `split` (two
|
|
10
|
+
* halves with a dash between: 123–456, the way people read codes aloud).
|
|
11
|
+
*/
|
|
12
|
+
export type PinInputVariant = "boxed" | "underline" | "split";
|
|
13
|
+
export interface PinInputProps {
|
|
14
|
+
length?: number;
|
|
15
|
+
value?: string;
|
|
16
|
+
defaultValue?: string;
|
|
17
|
+
onValueChange?: (value: string) => void;
|
|
18
|
+
onComplete?: (value: string) => void;
|
|
19
|
+
/** `numeric` (default) brings up the number pad; `alphanumeric` takes letters too. */
|
|
20
|
+
type?: "numeric" | "alphanumeric";
|
|
21
|
+
/** Dots instead of characters: PINs, not one-time codes. */
|
|
22
|
+
mask?: boolean;
|
|
23
|
+
variant?: PinInputVariant;
|
|
24
|
+
size?: "md" | "lg";
|
|
25
|
+
error?: boolean;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
autoFocus?: boolean;
|
|
28
|
+
/** Read aloud as the group's name. */
|
|
29
|
+
"aria-label"?: string;
|
|
30
|
+
className?: string;
|
|
31
|
+
}
|
|
32
|
+
export declare function PinInput({ length, value, defaultValue, onValueChange, onComplete, type, mask, variant, size, error, disabled, autoFocus, "aria-label": ariaLabel, className, }: PinInputProps): React.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsx as u,jsxs as z}from"react/jsx-runtime";import*as c from"react";import{cn as y}from"../../lib/utils.js";const N={boxed:"rounded-[calc(10px*var(--radius-scale))] border border-border2 bg-raised shadow-[inset_0_1px_1px_rgba(5,8,22,.05)] focus:border-primary focus:ring-[3px] focus:ring-primary/20 data-[filled]:border-border2",split:"rounded-[calc(10px*var(--radius-scale))] border border-border2 bg-raised shadow-[inset_0_1px_1px_rgba(5,8,22,.05)] focus:border-primary focus:ring-[3px] focus:ring-primary/20",underline:"rounded-none border-0 border-b-2 border-border2 bg-transparent focus:border-primary"};function O({length:n=6,value:p,defaultValue:v="",onValueChange:w,onComplete:h,type:f="numeric",mask:_,variant:b="boxed",size:P="md",error:l,disabled:k,autoFocus:D,"aria-label":I="Verification code",className:C}){const[V,A]=c.useState(v.slice(0,n)),i=(p??V).slice(0,n),m=c.useRef([]),F=f==="numeric"?/\d/:/[a-z0-9]/i,g=t=>{p===void 0&&A(t),w?.(t),t.length===n&&!t.includes(" ")&&h?.(t)},d=t=>{const e=m.current[Math.max(0,Math.min(n-1,t))];e?.focus(),e?.select()},x=(t,e)=>{const o=[...e].filter(a=>F.test(a)).map(a=>a.toUpperCase());if(!o.length)return;const r=Array.from({length:n},(a,s)=>i[s]??" ");o.slice(0,n-t).forEach((a,s)=>r[t+s]=a),g(r.join("").trimEnd()),d(t+o.length)},M=Math.ceil(n/2),R=P==="lg";return u("div",{role:"group","aria-label":I,className:y("flex items-center gap-2",l&&"wm-shake",C),children:Array.from({length:n},(t,e)=>{const o=i[e]&&i[e]!==" "?i[e]:"";return z(c.Fragment,{children:[b==="split"&&e===M?u("span",{"aria-hidden":!0,className:"h-0.5 w-3 rounded-full bg-border2"}):null,u("input",{ref:r=>{m.current[e]=r},"aria-label":`Character ${e+1} of ${n}`,inputMode:f==="numeric"?"numeric":"text",autoComplete:e===0?"one-time-code":"off",autoFocus:D&&e===0,disabled:k,type:_?"password":"text",value:o,"data-filled":o?"":void 0,"aria-invalid":l||void 0,onFocus:r=>r.target.select(),onChange:r=>{const a=r.target.value.replace(o,"")||r.target.value;x(e,a.length>1?a:a.slice(-1))},onPaste:r=>{r.preventDefault(),x(e,r.clipboardData.getData("text"))},onKeyDown:r=>{if(r.key==="Backspace"){r.preventDefault();const a=Array.from({length:n},(B,E)=>i[E]??" "),s=o?e:e-1;if(s<0)return;a[s]=" ",g(a.join("").trimEnd()),d(s)}else r.key==="ArrowLeft"?(r.preventDefault(),d(e-1)):r.key==="ArrowRight"&&(r.preventDefault(),d(e+1))},className:y("num text-center font-semibold text-text caret-primary outline-none transition-[border-color,box-shadow,transform] duration-150","disabled:cursor-not-allowed disabled:opacity-50 data-[filled]:animate-[wm-pop_160ms_var(--ease)]",R?"h-14 w-12 text-[22px]":"h-11 w-10 text-[18px]",N[b],l&&"border-danger focus:border-danger focus:ring-danger/20 data-[filled]:border-danger")})]},e)})})}export{O as PinInput};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as o,jsxs as
|
|
1
|
+
"use client";import{jsx as o,jsxs as n}from"react/jsx-runtime";import*as r from"@radix-ui/react-popover";import*as c from"react";import{cn as s}from"../../lib/utils.js";const g=r.Root,x=r.Trigger,P=r.Anchor,p={default:{box:"border-border bg-raised",arrow:"fill-[var(--raised)]"},glass:{box:"border-white/40 bg-raised/70 backdrop-blur-xl backdrop-saturate-150 dark:border-white/10",arrow:"fill-[var(--raised)] opacity-80"},dark:{box:"border-white/10 bg-[var(--ink)] text-[#d6d8e6] [--text:#f5f6fa] [--body:#d6d8e6] [--muted:#9aa1bd] [--border:rgba(255,255,255,.1)] [--hover:rgba(255,255,255,.08)]",arrow:"fill-[var(--ink)]"},brand:{box:"border-transparent bg-[linear-gradient(135deg,var(--brand-1),var(--brand-2))] text-white/90 [--text:#ffffff] [--body:rgba(255,255,255,.9)] [--muted:rgba(255,255,255,.72)] [--border:rgba(255,255,255,.2)] [--hover:rgba(255,255,255,.12)]",arrow:"fill-[color-mix(in_srgb,var(--brand-1)_50%,var(--brand-2))]"}},m=c.forwardRef(({className:i,align:t="start",sideOffset:e=6,variant:a="default",arrow:d=!1,children:l,...b},v)=>o(r.Portal,{children:n(r.Content,{ref:v,"data-pop":"",align:t,sideOffset:d?e+2:e,className:s("z-50 w-72 rounded-dlg border p-3 shadow-elev3 outline-none",p[a].box,i),...b,children:[l,d?o(r.Arrow,{width:14,height:7,className:p[a].arrow}):null]})}));m.displayName="PopoverContent";function u({title:i,description:t,icon:e,className:a}){return n("div",{className:s("mb-2.5 flex items-start gap-2.5",a),children:[e?o("span",{className:"mt-px grid size-7 shrink-0 place-items-center rounded-[calc(8px*var(--radius-scale))] bg-[var(--hover)] text-[var(--text)] [&_svg]:size-4",children:e}):null,n("div",{className:"min-w-0",children:[o("p",{className:"text-[13.5px] font-semibold text-text",children:i}),t?o("p",{className:"mt-0.5 text-[12.5px] leading-[18px] text-muted",children:t}):null]})]})}export{g as Popover,P as PopoverAnchor,m as PopoverContent,u as PopoverHeader,x as PopoverTrigger};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as a,jsxs as l}from"react/jsx-runtime";import*as w from"react";import{cn as s}from"../../lib/utils.js";const v={neutral:"bg-muted",info:"bg-primary",success:"bg-success",warning:"bg-warning",danger:"bg-danger",accent:"bg-accent"},x={neutral:"var(--muted)",info:"var(--primary)",success:"var(--success)",warning:"var(--warning)",danger:"var(--danger)",accent:"var(--accent)"},p={sm:"h-1.5",md:"h-2.5",lg:"h-3.5"};function N({value:i,tone:e="info",className:o,label:m,variant:n="bar",size:d="sm",segments:c=5,showValue:g=!1}){const
|
|
1
|
+
"use client";import{jsx as a,jsxs as l}from"react/jsx-runtime";import*as w from"react";import{cn as s}from"../../lib/utils.js";const v={neutral:"bg-muted",info:"bg-primary",success:"bg-success",warning:"bg-warning",danger:"bg-danger",accent:"bg-accent"},x={neutral:"var(--muted)",info:"var(--primary)",success:"var(--success)",warning:"var(--warning)",danger:"var(--danger)",accent:"var(--accent)"},p={sm:"h-1.5",md:"h-2.5",lg:"h-3.5"};function N({value:i,tone:e="info",className:o,label:m,variant:n="bar",size:d="sm",segments:c=5,showValue:g=!1}){const r=typeof i=="number",t=r?Math.max(0,Math.min(100,i)):0,u=n==="segmented"?a("div",{className:s("flex w-full gap-1",p[d]),children:Array.from({length:c},(f,h)=>{const b=Math.max(0,Math.min(1,t/100*c-h));return a("div",{className:"h-full flex-1 overflow-hidden rounded-full bg-hover",children:a("div",{className:s("h-full rounded-full transition-[width] duration-500 ease-wave",v[e]),style:{width:`${b*100}%`}})},h)})}):a("div",{className:s("relative w-full overflow-hidden rounded-full bg-hover",p[d]),children:a("div",{className:s("relative h-full overflow-hidden rounded-full transition-[width] duration-500 ease-wave",!r&&"wm-indeterminate absolute w-2/5",n==="gradient"?"bg-[linear-gradient(90deg,var(--brand-1),var(--brand-2))]":v[e],n==="striped"&&"wm-stripes"),style:r?{width:`${t}%`}:void 0,children:n==="gradient"?a("span",{className:"wm-sheen absolute inset-y-0 w-1/3 bg-[linear-gradient(90deg,transparent,rgba(255,255,255,.45),transparent)]"}):null})});return l("div",{role:"progressbar","aria-valuenow":r?t:void 0,"aria-valuemin":0,"aria-valuemax":100,"aria-label":m,className:s("flex w-full items-center gap-3",o),children:[u,g&&r?l("span",{className:"num w-10 shrink-0 text-right text-[12px] font-medium text-text",children:[Math.round(t),"%"]}):null]})}function k({value:i,size:e=64,thickness:o=6,tone:m="info",gradient:n=!1,label:d,children:c,className:g}){const r=Math.max(0,Math.min(100,i)),t=(e-o)/2,u=2*Math.PI*t,f=w.useId().replace(/:/g,"");return l("div",{role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":d,className:s("relative inline-grid shrink-0 place-items-center",g),style:{width:e,height:e},children:[l("svg",{width:e,height:e,className:"-rotate-90",children:[n?a("defs",{children:l("linearGradient",{id:`${f}-g`,x1:"0",y1:"0",x2:"1",y2:"1",children:[a("stop",{offset:"0",style:{stopColor:"var(--brand-1)"}}),a("stop",{offset:"1",style:{stopColor:"var(--brand-2)"}})]})}):null,a("circle",{cx:e/2,cy:e/2,r:t,fill:"none",stroke:"var(--hover)",strokeWidth:o}),a("circle",{cx:e/2,cy:e/2,r:t,fill:"none",stroke:n?`url(#${f}-g)`:x[m],strokeWidth:o,strokeLinecap:"round",strokeDasharray:u,strokeDashoffset:u*(1-r/100),style:{transition:"stroke-dashoffset 600ms var(--ease)"}})]}),a("span",{className:"num absolute text-[13px] font-semibold text-text",style:{fontSize:Math.max(11,e*.22)},children:c??`${Math.round(r)}%`})]})}export{N as Progress,k as ProgressRing};
|