@waveinno/ui 0.3.0 → 0.5.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 +36 -0
- package/README.md +31 -13
- 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/index.d.ts +1 -0
- package/dist/components/patterns/index.js +1 -1
- package/dist/components/patterns/org-chart.d.ts +48 -0
- package/dist/components/patterns/org-chart.js +1 -0
- 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/accordion.d.ts +30 -0
- package/dist/components/ui/accordion.js +1 -0
- package/dist/components/ui/alert.js +1 -1
- 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/calendar.js +1 -1
- package/dist/components/ui/carousel.d.ts +27 -0
- package/dist/components/ui/carousel.js +1 -0
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/color-picker.d.ts +14 -0
- package/dist/components/ui/color-picker.js +1 -0
- package/dist/components/ui/combobox.js +1 -1
- package/dist/components/ui/confirm-dialog.d.ts +24 -11
- package/dist/components/ui/confirm-dialog.js +1 -1
- package/dist/components/ui/date-picker.d.ts +18 -1
- package/dist/components/ui/date-picker.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 +12 -4
- package/dist/components/ui/file-upload.js +1 -1
- package/dist/components/ui/hover-card.d.ts +17 -0
- package/dist/components/ui/hover-card.js +1 -0
- package/dist/components/ui/index.d.ts +10 -0
- package/dist/components/ui/index.js +1 -1
- package/dist/components/ui/kbd.js +1 -1
- package/dist/components/ui/menu.d.ts +24 -0
- package/dist/components/ui/menu.js +1 -1
- package/dist/components/ui/pagination.d.ts +51 -0
- package/dist/components/ui/pagination.js +1 -0
- package/dist/components/ui/password-input.js +1 -1
- package/dist/components/ui/pin-input.js +1 -1
- package/dist/components/ui/popover.js +1 -1
- package/dist/components/ui/progress.js +1 -1
- package/dist/components/ui/radio-group.js +1 -1
- package/dist/components/ui/rating.d.ts +27 -0
- package/dist/components/ui/rating.js +1 -0
- package/dist/components/ui/scroll-area.d.ts +17 -0
- package/dist/components/ui/scroll-area.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 +18 -6
- package/dist/components/ui/slider.js +1 -1
- package/dist/components/ui/spinner.js +1 -1
- package/dist/components/ui/steps.d.ts +36 -0
- package/dist/components/ui/steps.js +1 -0
- package/dist/components/ui/tabs.js +1 -1
- package/dist/components/ui/tag-input.d.ts +33 -0
- package/dist/components/ui/tag-input.js +1 -0
- package/dist/components/ui/toast.js +1 -1
- package/dist/components/ui/tree-view.d.ts +38 -0
- package/dist/components/ui/tree-view.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 +91 -5
- package/package.json +14 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import{ArrowDownRight as $,ArrowUpRight as k}from"lucide-react";import*as z from"react";import{cn as d}from"../../lib/utils.js";import{useCurrency as C}from"../../store/settings-store.js";import{WaveinnoSymbol as S}from"../brand/waveinno-logo.js";import{ProgressRing as L}from"../ui/progress.js";const M={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"},P={neutral:"var(--muted)",info:"var(--primary)",success:"var(--success)",warning:"var(--warning)",danger:"var(--danger)",accent:"var(--accent)"};function T({delta:a,invert:m,label:i,onBrand:n}){const s=m?a<0:a>0;return t("span",{className:"flex flex-wrap items-center gap-1.5 text-[12px]",children:[t("span",{className:d("num inline-flex items-center gap-0.5 rounded-full px-1.5 py-0.5 font-semibold",n?"bg-white/18 text-white":s?"bg-success-subtle text-success":"bg-danger-subtle text-danger"),children:[a>=0?e(k,{className:"size-3"}):e($,{className:"size-3"}),Math.abs(a).toFixed(1),"%"]}),i?e("span",{className:n?"text-white/70":"text-muted",children:i}):null]})}function A(a){const m=Math.max(...a),i=Math.min(...a),n=m-i||1,s=a.map((r,p)=>[p/(a.length-1)*100,36-(r-i)/n*30]);let
|
|
1
|
+
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import{ArrowDownRight as $,ArrowUpRight as k}from"lucide-react";import*as z from"react";import{cn as d}from"../../lib/utils.js";import{useCurrency as C}from"../../store/settings-store.js";import{WaveinnoSymbol as S}from"../brand/waveinno-logo.js";import{ProgressRing as L}from"../ui/progress.js";const M={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"},P={neutral:"var(--muted)",info:"var(--primary)",success:"var(--success)",warning:"var(--warning)",danger:"var(--danger)",accent:"var(--accent)"};function T({delta:a,invert:m,label:i,onBrand:n}){const s=m?a<0:a>0;return t("span",{className:"flex flex-wrap items-center gap-1.5 text-[12px]",children:[t("span",{className:d("num inline-flex items-center gap-0.5 rounded-full px-1.5 py-0.5 font-semibold",n?"bg-white/18 text-white":s?"bg-success-subtle text-success":"bg-danger-subtle text-danger"),children:[a>=0?e(k,{className:"size-3"}):e($,{className:"size-3"}),Math.abs(a).toFixed(1),"%"]}),i?e("span",{className:n?"text-white/70":"text-muted",children:i}):null]})}function A(a){const m=Math.max(...a),i=Math.min(...a),n=m-i||1,s=a.map((r,p)=>[p/(a.length-1)*100,36-(r-i)/n*30]);let b=`M${s[0][0]},${s[0][1]}`;for(let r=1;r<s.length;r++){const[p,v]=s[r-1],[l,g]=s[r],u=(p+l)/2;b+=` C${u},${v} ${u},${g} ${l},${g}`}return{line:b,area:`${b} L100,40 L0,40 Z`,last:s[s.length-1]}}function E({label:a,value:m,currency:i,delta:n,invertDelta:s,deltaLabel:b,hint:r,icon:p,tone:v="info",variant:l="icon",spark:g,target:u,parts:f,className:R}){const h=C(),w=z.useId().replace(/:/g,""),x=l==="gradient",y=t("span",{className:"num disp text-[28px] font-semibold leading-none tracking-[-0.01em]",children:[i&&h.position==="before"?e("span",{className:"mr-0.5 text-[0.62em] font-medium opacity-70",children:h.symbol}):null,m,i&&h.position==="after"?e("span",{className:"ml-1 text-[0.62em] font-medium opacity-70",children:h.symbol}):null]});return t("div",{className:d("relative isolate flex flex-col overflow-hidden rounded-[calc(16px*var(--radius-scale))] border p-[18px] transition-[transform,box-shadow] duration-200 hover:-translate-y-0.5",x?"border-transparent [--text:#ffffff] bg-[linear-gradient(140deg,var(--brand-1),color-mix(in_srgb,var(--brand-1)_78%,#000)_45%,var(--brand-2))] text-white shadow-[inset_0_1px_0_rgba(255,255,255,.25),0_14px_30px_-14px_color-mix(in_srgb,var(--brand-1)_70%,transparent)]":"border-border bg-surface text-text shadow-[var(--lit)] hover:shadow-[var(--lit),0_10px_24px_-14px_rgba(5,8,22,.25)]",R),children:[x?e(S,{mono:!0,title:"",className:"pointer-events-none absolute -bottom-4 -right-6 -z-10 h-auto w-40 rotate-[-12deg] text-white opacity-[.12]"}):null,t("div",{className:"flex items-start justify-between gap-3",children:[e("p",{className:d("text-[12px] font-medium",x?"text-white/80":"text-muted"),children:a}),p&&l!=="target"?e("span",{className:d("grid size-9 shrink-0 place-items-center rounded-[calc(10px*var(--radius-scale))] [&_svg]:size-[18px]",x?"bg-white/15 text-white ring-1 ring-inset ring-white/25":M[v]),children:p}):null]}),l==="target"&&u?t("div",{className:"mt-2 flex items-center justify-between gap-3",children:[t("div",{className:"min-w-0",children:[y,e("p",{className:"mt-2 text-[12px] text-muted",children:u.label})]}),e(L,{value:u.percent,size:68,thickness:7,gradient:!0,label:a})]}):l==="comparison"&&f?t("div",{className:"mt-2",children:[e("div",{className:"grid grid-cols-2 gap-3",children:f.map((o,c)=>t("div",{className:d(c===1&&"border-l border-border pl-3"),children:[t("p",{className:"flex items-center gap-1.5 text-[11.5px] text-muted",children:[e("span",{className:d("size-2 rounded-full",c===0?"bg-primary":"bg-accent")}),o.label]}),e("p",{className:"num disp mt-1 text-[22px] font-semibold leading-none text-text",children:o.display??o.value.toLocaleString()})]},o.label))}),(()=>{const o=f[0].value+f[1].value||1,c=f[0].value/o*100;return t("div",{className:"mt-3",children:[t("div",{className:"flex h-2 gap-0.5 overflow-hidden rounded-full",children:[e("div",{className:"h-full rounded-l-full bg-[linear-gradient(90deg,var(--brand-1),var(--primary))]",style:{width:`${c}%`}}),e("div",{className:"h-full flex-1 rounded-r-full bg-[linear-gradient(90deg,#7c3aed,#a78bfa)]"})]}),t("div",{className:"num mt-1.5 flex justify-between text-[11px] text-muted",children:[t("span",{children:[c.toFixed(0),"%"]}),t("span",{children:[(100-c).toFixed(0),"%"]})]})]})})()]}):e("div",{className:"mt-2",children:y}),n!==void 0||r?t("div",{className:"mt-2.5 flex flex-wrap items-center gap-2",children:[n!==void 0?e(T,{delta:n,invert:s,label:b,onBrand:x}):null,r?e("span",{className:d("text-[12px]",x?"text-white/70":"text-muted"),children:r}):null]}):null,l==="spark"&&g&&g.length>1?(()=>{const{line:o,area:c,last:_}=A(g),N=P[n===void 0?v:(s?n<0:n>0)?"success":"danger"];return t("svg",{viewBox:"0 0 100 40",preserveAspectRatio:"none",className:"-mx-[18px] -mb-[18px] mt-3 h-16 w-[calc(100%+36px)]","aria-hidden":!0,children:[e("defs",{children:t("linearGradient",{id:`${w}-a`,x1:"0",y1:"0",x2:"0",y2:"1",children:[e("stop",{offset:"0",stopColor:N,stopOpacity:".28"}),e("stop",{offset:"1",stopColor:N,stopOpacity:"0"})]})}),e("path",{d:c,fill:`url(#${w}-a)`}),e("path",{d:o,fill:"none",stroke:N,strokeWidth:"1.6",vectorEffect:"non-scaling-stroke"}),e("circle",{cx:_[0],cy:_[1],r:"1.6",fill:N,vectorEffect:"non-scaling-stroke"})]})})():null]})}function O({children:a,className:m}){return e("div",{className:d("stagger grid gap-3 sm:grid-cols-2 xl:grid-cols-4",m),children:a})}export{E as StatCard,O as StatGrid};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import{ChevronDown as
|
|
1
|
+
"use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import{ChevronDown as h,CornerDownRight as y,MessageSquare as w,Pin as R,Send as k}from"lucide-react";import*as b from"react";import{cn as p}from"../../lib/utils.js";import{Avatar as f}from"../ui/avatar.js";import{Badge as N}from"../ui/badge.js";import{Button as z}from"../ui/button.js";const T={neutral:"bg-raised text-muted ring-border",info:"bg-primary-subtle text-primary ring-primary/25",success:"bg-success-subtle text-success ring-success/25",warning:"bg-warning-subtle text-warning ring-warning/25",danger:"bg-danger-subtle text-danger ring-danger/25",accent:"bg-primary-subtle text-accent ring-accent/25"};function D({items:r,className:m}){const o=[];for(const n of r){const l=n.group??"",s=o[o.length-1];s&&s[0]===l?s[1].push(n):o.push([l,[n]])}return e("div",{className:p("space-y-5",m),children:o.map(([n,l])=>a("section",{children:[n?a("h4",{className:"mb-3 flex items-center gap-3 text-[11px] font-semibold uppercase tracking-[0.08em] text-muted",children:[n,e("span",{className:"h-px flex-1 bg-border"})]}):null,e("ol",{className:"relative",children:l.map((s,c)=>a("li",{className:"relative flex gap-3.5 pb-5 last:pb-0",children:[c<l.length-1?e("span",{"aria-hidden":!0,className:"absolute left-[15px] top-8 bottom-0 w-px bg-border"}):null,e("span",{className:p("relative z-[1] grid size-8 shrink-0 place-items-center rounded-full ring-1 [&_svg]:size-4",T[s.tone??"neutral"]),children:s.icon??e("i",{className:"size-2 rounded-full bg-current"})}),a("div",{className:"min-w-0 flex-1 pt-1",children:[a("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[a("p",{className:"text-[13px] text-body",children:[s.actor?a("span",{className:"font-semibold text-text",children:[s.actor.name," "]}):null,s.title]}),s.meta,e("time",{className:"ml-auto shrink-0 text-[11.5px] text-muted",children:s.time})]}),s.description?e("div",{className:"mt-1 text-[12.5px] leading-[18px] text-muted",children:s.description}):null]})]},s.id))})]},n||"_"))})}function O({entries:r,defaultOpen:m=1,labels:o,className:n}){const l={changes:t=>`${t} ${t===1?"change":"changes"}`,empty:"(empty)",...o},[s,c]=b.useState(()=>new Set(r.slice(0,m).map(t=>t.id))),u=t=>c(g=>{const d=new Set(g);return d.has(t)?d.delete(t):d.add(t),d});return e("ol",{className:p("relative space-y-3",n),children:r.map((t,g)=>{const d=s.has(t.id),i=t.changes?.length??0;return a("li",{className:"relative flex gap-3.5",children:[g<r.length-1?e("span",{"aria-hidden":!0,className:"absolute left-[17px] top-10 -bottom-3 w-px bg-border"}):null,e(f,{name:t.actor.name,src:t.actor.src,size:"md",className:"relative z-[1] mt-1 ring-4 ring-canvas"}),a("div",{className:"min-w-0 flex-1 overflow-hidden rounded-[calc(12px*var(--radius-scale))] border border-border bg-raised shadow-[var(--lit)]",children:[a("button",{type:"button",onClick:()=>i&&u(t.id),className:p("flex w-full items-start gap-2 px-3.5 py-3 text-left",i?"cursor-pointer hover:bg-hover/50":"cursor-default"),"aria-expanded":i?d:void 0,children:[a("div",{className:"min-w-0 flex-1",children:[a("p",{className:"text-[13px] text-body",children:[e("span",{className:"font-semibold text-text",children:t.actor.name}),t.actor.role?a("span",{className:"text-muted",children:[" \xB7 ",t.actor.role]}):null]}),a("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[e(N,{tone:t.tone??"info",variant:"soft",children:t.action}),t.version?e("span",{className:"num rounded-[calc(5px*var(--radius-scale))] border border-border bg-surface px-1.5 text-[11px] font-medium leading-[18px] text-muted",children:t.version}):null,i?e("span",{className:"text-[11.5px] text-muted",children:l.changes(i)}):null]})]}),e("time",{className:"shrink-0 pt-0.5 text-[11.5px] text-muted",children:t.at}),i?e(h,{className:p("mt-0.5 size-4 shrink-0 text-muted transition-transform",d&&"rotate-180")}):null]}),t.note?a("p",{className:"mx-3.5 mb-3 rounded-[calc(8px*var(--radius-scale))] border-l-2 border-primary/40 bg-surface px-2.5 py-1.5 text-[12.5px] italic leading-[18px] text-body",children:["\u201C",t.note,"\u201D"]}):null,i&&d?e("dl",{className:"divide-y divide-border border-t border-border bg-surface/60",children:t.changes.map(x=>a("div",{className:"grid grid-cols-[110px_1fr] items-center gap-3 px-3.5 py-2 text-[12.5px] sm:grid-cols-[140px_1fr]",children:[e("dt",{className:"truncate font-medium text-muted",children:x.field}),a("dd",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[e("span",{className:"num rounded-[calc(5px*var(--radius-scale))] bg-danger-subtle px-1.5 py-0.5 text-danger line-through decoration-danger/50",children:x.from??l.empty}),e("span",{className:"text-muted",children:"\u2192"}),e("span",{className:"num rounded-[calc(5px*var(--radius-scale))] bg-success-subtle px-1.5 py-0.5 font-medium text-success",children:x.to??l.empty})]})]},x.field))}):null]})]},t.id)})})}function v({note:r,depth:m,onReply:o,labels:n}){const[l,s]=b.useState(m<1),[c,u]=b.useState(!1),[t,g]=b.useState(""),d=r.replies??[];return e("li",{className:"relative",children:a("div",{className:"flex gap-3",children:[e(f,{name:r.author.name,src:r.author.src,size:m?"sm":"md",className:"relative z-[1] mt-0.5 ring-4 ring-canvas"}),a("div",{className:"min-w-0 flex-1",children:[a("div",{className:p("rounded-[calc(12px*var(--radius-scale))] border px-3.5 py-2.5",r.pinned?"border-primary/30 bg-primary-subtle/40":"border-border bg-raised"),children:[a("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[e("span",{className:"text-[13px] font-semibold text-text",children:r.author.name}),r.author.role?e("span",{className:"text-[11.5px] text-muted",children:r.author.role}):null,r.tag?e(N,{tone:r.tag.tone??"neutral",variant:"outline",children:r.tag.label}):null,r.pinned?e(R,{className:"size-3 text-primary","aria-label":"pinned"}):null,e("time",{className:"ml-auto text-[11.5px] text-muted",children:r.at})]}),e("div",{className:"mt-1 text-[13px] leading-5 text-body",children:r.text})]}),a("div",{className:"mt-1 flex items-center gap-3 pl-1 text-[12px]",children:[o?a("button",{type:"button",onClick:()=>u(i=>!i),className:"flex cursor-pointer items-center gap-1 font-medium text-muted hover:text-primary",children:[e(y,{className:"size-3.5"})," ",n.reply]}):null,d.length?a("button",{type:"button",onClick:()=>s(i=>!i),className:"flex cursor-pointer items-center gap-1 font-medium text-primary",children:[e(w,{className:"size-3.5"})," ",l?n.hide:n.replies(d.length)]}):null]}),c&&o?a("form",{className:"mt-2 flex items-start gap-2",onSubmit:i=>{i.preventDefault(),t.trim()&&(o(r.id,t.trim()),g(""),u(!1),s(!0))},children:[e("textarea",{autoFocus:!0,value:t,onChange:i=>g(i.target.value),rows:2,placeholder:n.placeholder,className:"min-h-16 flex-1 resize-y rounded-[calc(10px*var(--radius-scale))] border border-border2 bg-raised px-3 py-2 text-[13px] text-text outline-none placeholder:text-placeholder focus:border-primary focus:ring-2 focus:ring-primary/20"}),e(z,{type:"submit",variant:"primary",size:"icon","aria-label":n.send,disabled:!t.trim(),children:e(k,{})})]}):null,d.length&&l?e("ul",{className:"relative mt-3 space-y-3 before:absolute before:-left-[22px] before:top-0 before:bottom-3 before:w-px before:bg-border",children:d.map(i=>e(v,{note:i,depth:m+1,onReply:o,labels:n},i.id))}):null]})]})})}function _({notes:r,onReply:m,labels:o,className:n}){const l={reply:"Reply",replies:c=>`${c} ${c===1?"reply":"replies"}`,hide:"Hide replies",placeholder:"Write a reply\u2026",send:"Send",...o},s=[...r].sort((c,u)=>+!!u.pinned-+!!c.pinned);return e("ul",{className:p("space-y-4",n),children:s.map(c=>e(v,{note:c,depth:0,onReply:m,labels:l},c.id))})}export{D as ActivityTimeline,O as ChangeHistory,_ as ChangeNotes};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Accordion — questions and sections that fold, so a long page reads as a list
|
|
5
|
+
* of headings first. (One panel that hides and shows is just a button.)
|
|
6
|
+
*
|
|
7
|
+
* Looks — set `variant` on Accordion:
|
|
8
|
+
* line — the default: hairlines between items. FAQs, settings, help.
|
|
9
|
+
* card — each item its own card, the open one lifted. Onboarding, plans.
|
|
10
|
+
* contained — one bordered box, items divided inside. Inside forms and drawers.
|
|
11
|
+
* `indicator`: a chevron that turns (default) or a plus that becomes a cross.
|
|
12
|
+
* Items take an `icon`, a second-line `description` and a `badge`. Opening is
|
|
13
|
+
* animated to the content's real height; keyboard and ARIA are Radix's.
|
|
14
|
+
*/
|
|
15
|
+
export type AccordionVariant = "line" | "card" | "contained";
|
|
16
|
+
type RootProps = React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Root> & {
|
|
17
|
+
variant?: AccordionVariant;
|
|
18
|
+
indicator?: "chevron" | "plus";
|
|
19
|
+
};
|
|
20
|
+
export declare const Accordion: React.ForwardRefExoticComponent<RootProps & React.RefAttributes<HTMLDivElement>>;
|
|
21
|
+
export interface AccordionItemProps extends Omit<React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>, "title"> {
|
|
22
|
+
title: React.ReactNode;
|
|
23
|
+
/** A muted line under the title. */
|
|
24
|
+
description?: React.ReactNode;
|
|
25
|
+
icon?: React.ReactNode;
|
|
26
|
+
/** Beside the title: a count, "New". */
|
|
27
|
+
badge?: React.ReactNode;
|
|
28
|
+
}
|
|
29
|
+
export declare const AccordionItem: React.ForwardRefExoticComponent<AccordionItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsx as e,jsxs as s}from"react/jsx-runtime";import*as o from"@radix-ui/react-accordion";import{ChevronDown as f,Plus as g}from"lucide-react";import*as n from"react";import{cn as c}from"../../lib/utils.js";const m=n.createContext({variant:"line",indicator:"chevron"}),R={line:"divide-y divide-border border-y border-border",card:"space-y-2.5",contained:"divide-y divide-border overflow-hidden rounded-card border border-border bg-raised shadow-[var(--lit)]"},y=n.forwardRef(({variant:a="line",indicator:i="chevron",className:r,...d},p)=>e(m.Provider,{value:{variant:a,indicator:i},children:e(o.Root,{ref:p,className:c(R[a],r),...d})}));y.displayName="Accordion";const h={line:"",card:"rounded-[calc(14px*var(--radius-scale))] border border-border bg-raised shadow-[var(--lit)] transition-[box-shadow,border-color] duration-200 data-[state=open]:border-primary/25 data-[state=open]:shadow-[var(--lit),0_10px_28px_-16px_color-mix(in_srgb,var(--primary)_45%,transparent)]",contained:"data-[state=open]:bg-surface/60"},A=n.forwardRef(({title:a,description:i,icon:r,badge:d,className:p,children:u,...v},x)=>{const{variant:t,indicator:b}=n.useContext(m),l=t==="line"?"px-1":"px-4";return s(o.Item,{ref:x,className:c("group/acc",h[t],p),...v,children:[e(o.Header,{asChild:!0,children:e("h3",{children:s(o.Trigger,{className:c("flex w-full cursor-pointer items-center gap-3 py-3.5 text-left outline-none transition-colors","focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary/40 disabled:cursor-not-allowed disabled:opacity-50",t==="line"&&"hover:text-primary",t!=="line"&&"rounded-[inherit]",l),children:[r?e("span",{className:"grid size-8 shrink-0 place-items-center rounded-[calc(9px*var(--radius-scale))] border border-border bg-surface text-muted transition-colors group-data-[state=open]/acc:border-primary/25 group-data-[state=open]/acc:bg-primary-subtle group-data-[state=open]/acc:text-primary [&_svg]:size-4",children:r}):null,s("span",{className:"min-w-0 flex-1",children:[s("span",{className:"flex items-center gap-2",children:[e("span",{className:"text-[14px] font-semibold text-text",children:a}),d]}),i?e("span",{className:"mt-0.5 block text-[12.5px] leading-[18px] text-muted",children:i}):null]}),b==="plus"?e("span",{className:"grid size-6 shrink-0 place-items-center rounded-full border border-border bg-raised text-muted transition-colors group-data-[state=open]/acc:border-primary/30 group-data-[state=open]/acc:text-primary",children:e(g,{className:"size-3.5 transition-transform duration-300 ease-[var(--ease)] group-data-[state=open]/acc:rotate-45"})}):e(f,{className:"size-4 shrink-0 text-muted transition-transform duration-300 ease-[var(--ease)] group-data-[state=open]/acc:rotate-180 group-data-[state=open]/acc:text-primary"})]})})}),e(o.Content,{className:"overflow-hidden data-[state=closed]:animate-[wm-acc-up_220ms_var(--ease)] data-[state=open]:animate-[wm-acc-down_260ms_var(--ease)]",children:e("div",{className:c("pb-4 text-[13.5px] leading-[1.65] text-body",l,r&&(t==="line"?"pl-[48px]":"pl-[60px]")),children:u})})]})});A.displayName="AccordionItem";export{y as Accordion,A as AccordionItem};
|
|
@@ -1 +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:
|
|
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
|
|
1
|
+
"use client";import{jsx as a,jsxs as N}from"react/jsx-runtime";import{ChevronLeft as X,ChevronRight as Z}from"lucide-react";import*as y from"react";import{cn as p}from"../../lib/utils.js";function ut(t){const e=/^(\d{4})-(\d{2})-(\d{2})/.exec(t??"");return e?new Date(Number(e[1]),Number(e[2])-1,Number(e[3])):null}function m(t){return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}const h=(t,e)=>new Date(t.getFullYear(),t.getMonth(),t.getDate()+e),_=t=>new Date(t.getFullYear(),t.getMonth(),1),w=(t,e)=>!!t&&!!e&&m(t)===m(e);function f(t,e){const c=new Date(t.getFullYear(),t.getMonth()+e,1),g=new Date(c.getFullYear(),c.getMonth()+1,0).getDate();return new Date(c.getFullYear(),c.getMonth(),Math.min(t.getDate(),g))}function O(t,e){const c=_(t),g=(c.getDay()-e+7)%7;return Array.from({length:42},(S,I)=>h(c,I-g))}function st(t){return y.useMemo(()=>({title:new Intl.DateTimeFormat(t,{month:"long",year:"numeric"}),month:new Intl.DateTimeFormat(t,{month:"short"}),year:new Intl.DateTimeFormat(t,{year:"numeric"}),weekday:new Intl.DateTimeFormat(t,{weekday:"short"}),day:new Intl.DateTimeFormat(t,{day:"numeric"}),full:new Intl.DateTimeFormat(t,{weekday:"long",day:"numeric",month:"long",year:"numeric"})}),[t])}const C="grid size-8 cursor-pointer place-items-center rounded-ctl text-muted transition-colors hover:bg-hover hover:text-text disabled:pointer-events-none disabled:opacity-30";function ct({selected:t=null,range:e,onDayClick:c,min:g=null,max:S=null,locale:I="en-GB",weekStartsOn:R=1,numberOfMonths:F=1,defaultMonth:tt,autoFocus:et,className:K}){const d=st(I),L=y.useMemo(()=>new Date,[]),H=t??e?.from??L,[l,v]=y.useState(()=>_(tt??H)),[r,B]=y.useState(H),[u,T]=y.useState("days"),[E,W]=y.useState(null),Y=y.useRef(null),A=y.useRef(!!et),G=o=>(!g||m(o)>=m(g))&&(!S||m(o)<=m(S));y.useEffect(()=>{!A.current||u!=="days"||(A.current=!1,Y.current?.querySelector(`[data-day="${m(r)}"]`)?.focus({preventScroll:!0}))},[r,l,u]);const ot=o=>{A.current=!0,B(o);const s=f(l,F-1);(o<l||o>=f(_(s),1))&&v(_(o))},nt=o=>{const s=(r.getDay()-R+7)%7,b={ArrowLeft:()=>h(r,-1),ArrowRight:()=>h(r,1),ArrowUp:()=>h(r,-7),ArrowDown:()=>h(r,7),PageUp:()=>f(r,o.shiftKey?-12:-1),PageDown:()=>f(r,o.shiftKey?12:1),Home:()=>h(r,-s),End:()=>h(r,6-s)};b[o.key]?(o.preventDefault(),ot(b[o.key]())):(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),G(r)&&c(r))},at=O(new Date(2026,0,1),R).slice(0,7),k=e?e.to??(e.from&&E&&E>=e.from?E:null):null,rt=o=>!!e?.from&&!!k&&o>e.from&&o<k;if(u!=="days"){const o=l.getFullYear(),s=o-o%12,b=u==="months"?Array.from({length:12},(i,D)=>new Date(o,D,1)):Array.from({length:12},(i,D)=>new Date(s+D,l.getMonth(),1)),n=i=>u==="months"?i.getMonth()===l.getMonth():i.getFullYear()===o;return N("div",{ref:Y,className:p("w-[268px]",K),children:[N("div",{className:"mb-2 flex items-center justify-between",children:[a("button",{type:"button","aria-label":"Previous",className:C,onClick:()=>v(f(l,u==="months"?-12:-144)),children:a(X,{className:"size-4"})}),a("button",{type:"button",onClick:()=>T(u==="months"?"years":"days"),className:"disp cursor-pointer rounded-ctl px-2 py-1 text-[13.5px] font-semibold text-text transition-colors hover:bg-hover",children:u==="months"?d.year.format(l):`${d.year.format(new Date(s,0))} \u2013 ${d.year.format(new Date(s+11,0))}`}),a("button",{type:"button","aria-label":"Next",className:C,onClick:()=>v(f(l,u==="months"?12:144)),children:a(Z,{className:"size-4"})})]}),a("div",{className:"grid grid-cols-3 gap-1.5",children:b.map(i=>a("button",{type:"button",onClick:()=>{v(i),T(u==="years"?"months":"days")},className:p("num h-11 cursor-pointer rounded-ctl text-[13px] transition-colors",n(i)?"bg-primary font-semibold text-white shadow-[0_1px_2px_rgba(5,8,22,.14)]":"text-text hover:bg-hover"),children:u==="months"?d.month.format(i):d.year.format(i)},i.toISOString()))})]})}return a("div",{ref:Y,className:p("flex gap-5",K),onMouseLeave:()=>W(null),children:Array.from({length:F},(o,s)=>{const b=f(l,s);return N("div",{className:"w-[268px]",children:[N("div",{className:"mb-2 flex items-center justify-between",children:[a("button",{type:"button","aria-label":"Previous month",className:p(C,s>0&&"invisible"),onClick:()=>v(f(l,-1)),children:a(X,{className:"size-4"})}),a("button",{type:"button","aria-live":"polite",onClick:()=>T("months"),className:"disp cursor-pointer rounded-ctl px-2 py-1 text-[13.5px] font-semibold text-text transition-colors hover:bg-hover",children:d.title.format(b)}),a("button",{type:"button","aria-label":"Next month",className:p(C,s<F-1&&"invisible"),onClick:()=>v(f(l,1)),children:a(Z,{className:"size-4"})})]}),a("div",{className:"grid grid-cols-7 pb-1",children:at.map(n=>a("div",{className:"py-1 text-center text-[11px] font-medium text-muted",children:d.weekday.format(n)},n.getDay()))}),a("div",{role:"grid",onKeyDown:nt,className:"grid grid-cols-7 gap-y-1",children:O(b,R).map((n,i)=>{const D=n.getMonth()===b.getMonth();if(!D&&F>1)return a("div",{"aria-hidden":!0},m(n));const z=G(n),U=!!e&&w(n,e.from),P=!!e&&w(n,k),x=e?U||P:w(n,t),M=rt(n),j=w(n,L),q=!!e&&!e.to,$=q?"bg-primary-subtle/55":"bg-primary-subtle",V=!!e?.from&&!!k&&!w(e.from,k),J=i%7===0||n.getDate()===1,Q=i%7===6||h(n,1).getMonth()!==n.getMonth();return N("div",{className:p("relative",M&&$,M&&J&&"rounded-l-[calc(10px*var(--radius-scale))]",M&&Q&&"rounded-r-[calc(10px*var(--radius-scale))]"),children:[V&&U&&!Q?a("span",{"aria-hidden":!0,className:p("absolute inset-y-0 left-1/2 right-0",$)}):null,V&&P&&!J?a("span",{"aria-hidden":!0,className:p("absolute inset-y-0 left-0 right-1/2",$)}):null,N("button",{type:"button",role:"gridcell","data-day":m(n),tabIndex:w(n,r)?0:-1,"aria-selected":x,"aria-label":d.full.format(n),disabled:!z,onClick:()=>c(n),onFocus:()=>B(n),onMouseEnter:()=>e&&W(n),className:p("num relative grid h-9 w-full cursor-pointer place-items-center rounded-ctl text-[13px] outline-none transition-[background-color,color,box-shadow,transform] duration-150",D?"text-text":"text-muted/55",z&&!x&&!M&&"hover:bg-hover",M&&"rounded-none text-primary hover:bg-primary/10","focus-visible:ring-2 focus-visible:ring-primary/40",x&&(e?"rounded-[calc(10px*var(--radius-scale))] bg-[linear-gradient(135deg,var(--brand-1),var(--brand-2))] font-semibold text-white shadow-[inset_0_1px_0_rgba(255,255,255,.25),0_6px_14px_-6px_color-mix(in_srgb,var(--brand-1)_70%,transparent)]":"bg-primary font-semibold text-white shadow-[0_1px_2px_rgba(5,8,22,.14)]"),x&&q&&P&&"opacity-70",j&&!x&&"font-semibold text-primary",!z&&"cursor-not-allowed opacity-30"),children:[d.day.format(n),j&&!x?a("span",{className:"absolute bottom-1 left-1/2 size-1 -translate-x-1/2 rounded-full bg-primary"}):null]})]},m(n))})})]},s)})})}export{ct as Calendar,h as addDays,f as addMonths,ut as parseIsoDay,m as toIsoDay};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Carousel — a row of cards that scrolls sideways: site photos, plans,
|
|
4
|
+
* announcements. Built on the browser's own scroll-snap, so touch, trackpad
|
|
5
|
+
* and scrollbars behave natively and nothing is re-implemented.
|
|
6
|
+
*
|
|
7
|
+
* `slideClassName` sets how many show at once ("basis-full sm:basis-1/2
|
|
8
|
+
* lg:basis-1/3"). Arrows sit `inside` (over the slides) or `outside` (above,
|
|
9
|
+
* right); the indicator is `dots` or a `bar`. `autoplay` (ms) advances on its
|
|
10
|
+
* own, stops while hovered or focused, and never runs for people who ask for
|
|
11
|
+
* reduced motion. `loop` wraps at the ends. ← and → move when it has focus.
|
|
12
|
+
*/
|
|
13
|
+
export interface CarouselProps {
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
slideClassName?: string;
|
|
16
|
+
/** Space between slides, px. */
|
|
17
|
+
gap?: number;
|
|
18
|
+
arrows?: "inside" | "outside" | "none";
|
|
19
|
+
indicator?: "dots" | "bar" | "none";
|
|
20
|
+
autoplay?: number;
|
|
21
|
+
loop?: boolean;
|
|
22
|
+
/** Above the slides, left of outside arrows. */
|
|
23
|
+
title?: React.ReactNode;
|
|
24
|
+
"aria-label"?: string;
|
|
25
|
+
className?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function Carousel({ children, slideClassName, gap, arrows, indicator, autoplay, loop, title, "aria-label": ariaLabel, className, }: CarouselProps): React.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{Fragment as z,jsx as r,jsxs as i}from"react/jsx-runtime";import{ChevronLeft as S,ChevronRight as $}from"lucide-react";import*as n from"react";import{cn as v}from"../../lib/utils.js";function G({children:R,slideClassName:M="basis-full",gap:p=12,arrows:l="inside",indicator:g="dots",autoplay:m,loop:h=!1,title:x,"aria-label":P="Carousel",className:T}){const o=n.useRef(null),d=n.Children.toArray(R),[w,I]=n.useState(0),[c,_]=n.useState({start:!0,end:!1}),[D,W]=n.useState(0),[y,u]=n.useState(!1),a=n.useCallback(()=>{const e=o.current;if(!e)return;const t=e.scrollWidth-e.clientWidth,s=e.scrollLeft>=t-1;_({start:e.scrollLeft<=1,end:s}),W(t>0?e.scrollLeft/t:1);const L=Array.from(e.children);let k=0,C=1/0;L.forEach((A,H)=>{const E=Math.abs(A.offsetLeft-e.offsetLeft-e.scrollLeft);E<C&&(C=E,k=H)}),I(s&&t>0?L.length-1:k)},[]);n.useEffect(()=>{const e=o.current;if(!e)return;a(),e.addEventListener("scroll",a,{passive:!0});const t=new ResizeObserver(a);return t.observe(e),()=>{e.removeEventListener("scroll",a),t.disconnect()}},[a,d.length]);const N=e=>{const t=o.current,s=t?.children[e];!t||!s||t.scrollTo({left:s.offsetLeft-t.offsetLeft,behavior:"smooth"})},f=e=>{const t=o.current;if(!t)return;if(e===1&&c.end)return h?N(0):void 0;if(e===-1&&c.start)return h?t.scrollTo({left:t.scrollWidth,behavior:"smooth"}):void 0;const s=t.children[0];t.scrollBy({left:e*((s?.offsetWidth??t.clientWidth)+p),behavior:"smooth"})};n.useEffect(()=>{if(!m||y||window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const e=window.setInterval(()=>f(1),m);return()=>window.clearInterval(e)});const b=e=>{const t=!h&&(e===1?c.end:c.start),s=e===1?$:S;return r("button",{type:"button","aria-label":e===1?"Next slide":"Previous slide",disabled:t,onClick:()=>f(e),className:v("grid size-9 cursor-pointer place-items-center rounded-full outline-none transition-[opacity,background-color,transform] duration-200 focus-visible:ring-2 focus-visible:ring-primary/45 disabled:pointer-events-none disabled:opacity-0 [&_svg]:size-[18px]",l==="inside"?"border border-white/50 bg-raised/80 text-text shadow-[0_4px_14px_-4px_rgba(5,8,22,.35)] backdrop-blur-md hover:scale-105 hover:bg-raised dark:border-white/10":"border border-border bg-raised text-body shadow-[var(--lit)] hover:bg-hover hover:text-text disabled:opacity-40"),children:r(s,{})})};return i("section",{"aria-roledescription":"carousel","aria-label":P,className:v("relative",T),onPointerEnter:()=>u(!0),onPointerLeave:()=>u(!1),onFocusCapture:()=>u(!0),onBlurCapture:()=>u(!1),children:[x||l==="outside"?i("div",{className:"mb-3 flex items-center gap-3",children:[r("div",{className:"min-w-0 flex-1",children:x}),l==="outside"?i("div",{className:"flex gap-1.5",children:[b(-1),b(1)]}):null]}):null,i("div",{className:"relative",children:[r("div",{ref:o,tabIndex:0,"aria-live":m&&!y?"off":"polite",onKeyDown:e=>{e.key==="ArrowRight"?(e.preventDefault(),f(1)):e.key==="ArrowLeft"&&(e.preventDefault(),f(-1))},className:"no-bar flex snap-x snap-mandatory overflow-x-auto overscroll-x-contain rounded-[calc(14px*var(--radius-scale))] outline-none focus-visible:ring-2 focus-visible:ring-primary/40",style:{gap:p},children:d.map((e,t)=>r("div",{role:"group","aria-roledescription":"slide","aria-label":`${t+1} of ${d.length}`,className:v("min-w-0 shrink-0 grow-0 snap-start",M),children:e},t))}),l==="inside"?i(z,{children:[r("div",{className:"absolute left-3 top-1/2 -translate-y-1/2",children:b(-1)}),r("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:b(1)})]}):null]}),g==="dots"?r("div",{className:"mt-3 flex justify-center gap-1.5",children:d.map((e,t)=>r("button",{type:"button","aria-label":`Go to slide ${t+1}`,"aria-current":t===w?"true":void 0,onClick:()=>N(t),className:v("h-1.5 cursor-pointer rounded-full transition-[width,background-color] duration-300 ease-[var(--ease)]",t===w?"w-5 bg-[linear-gradient(90deg,var(--brand-1),var(--brand-2))]":"w-1.5 bg-border2 hover:bg-muted")},t))}):g==="bar"?r("div",{className:"mx-auto mt-3 h-1 max-w-[220px] overflow-hidden rounded-full bg-hover","aria-hidden":!0,children:r("div",{className:"h-full rounded-full bg-[linear-gradient(90deg,var(--brand-1),var(--brand-2))] transition-[width] duration-150",style:{width:`${Math.max(8,D*100)}%`}})}):null]})}export{G as Carousel};
|
|
@@ -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};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface ColorPickerProps {
|
|
3
|
+
value?: string;
|
|
4
|
+
defaultValue?: string;
|
|
5
|
+
onValueChange?: (hex: string) => void;
|
|
6
|
+
/** Quick choices under the strip; `false` for none. */
|
|
7
|
+
swatches?: string[] | false;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function ColorPicker({ value, defaultValue, onValueChange, swatches, className }: ColorPickerProps): React.JSX.Element;
|
|
11
|
+
/** The picker behind a field-like button showing the colour and its hex. */
|
|
12
|
+
export declare function ColorPickerPopover({ value, defaultValue, onValueChange, swatches, "aria-label": ariaLabel, className, }: ColorPickerProps & {
|
|
13
|
+
"aria-label"?: string;
|
|
14
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsx as l,jsxs as m}from"react/jsx-runtime";import*as x from"@radix-ui/react-popover";import{Pipette as $}from"lucide-react";import*as p from"react";import{cn as P}from"../../lib/utils.js";function _(o){let t=o.trim().replace(/^#/,"");if(t.length===3&&(t=[...t].map(e=>e+e).join("")),!/^[0-9a-f]{6}$/i.test(t))return null;const a=parseInt(t,16);return[a>>16&255,a>>8&255,a&255]}const H=(o,t,a)=>`#${[o,t,a].map(e=>Math.round(e).toString(16).padStart(2,"0")).join("")}`;function N(o,t,a){o/=255,t/=255,a/=255;const e=Math.max(o,t,a),i=e-Math.min(o,t,a);let d=0;return i&&(d=e===o?(t-a)/i%6:e===t?(a-o)/i+2:(o-t)/i+4),{h:(d*60+360)%360,s:e?i/e:0,v:e}}function k({h:o,s:t,v:a}){const e=i=>{const d=(i+o/60)%6;return(a-a*t*Math.max(0,Math.min(d,4-d,1)))*255};return H(e(5),e(3),e(1))}const S=["#4f46e5","#1f45ea","#7c3aed","#db2777","#e11d48","#ea580c","#d97706","#16a34a","#059669","#0d9488","#0284c7","#334155"];function T(o){const t=p.useRef(null),a=e=>{const i=t.current.getBoundingClientRect();o(Math.min(1,Math.max(0,(e.clientX-i.left)/i.width)),Math.min(1,Math.max(0,(e.clientY-i.top)/i.height)))};return{ref:t,onPointerDown:e=>{e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),e.currentTarget.focus(),a(e)},onPointerMove:e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&a(e)}}}function L({value:o,defaultValue:t="#4f46e5",onValueChange:a,swatches:e=S,className:i}){const[d,b]=p.useState(t),c=(o??d).toLowerCase(),[s,g]=p.useState(()=>N(..._(c)??[79,70,229])),[h,w]=p.useState(c);p.useEffect(()=>{if(k(s)!==c){const r=_(c);if(r){const n=N(...r);g(u=>({h:n.s===0||n.v===0?u.h:n.h,s:n.v===0?u.s:n.s,v:n.v}))}}w(c)},[c]);const v=r=>{g(r);const n=k(r);o===void 0&&b(n),a?.(n)},y=r=>{const n=_(r);if(!n)return;const u=H(...n);o===void 0&&b(u),a?.(u)},E=T((r,n)=>v({...s,s:r,v:1-n})),R=T(r=>v({...s,h:r*360})),M=(r,n)=>{const u=r.shiftKey?.1:.02,f={ArrowLeft:[-u,0],ArrowRight:[u,0],ArrowUp:[0,u],ArrowDown:[0,-u]}[r.key];f&&(r.preventDefault(),v(n==="area"?{...s,s:Math.min(1,Math.max(0,s.s+f[0])),v:Math.min(1,Math.max(0,s.v+f[1]))}:{...s,h:(s.h+(f[0]+f[1])*360+360)%360}))},D=typeof window<"u"&&"EyeDropper"in window,C=k({h:s.h,s:1,v:1});return m("div",{className:P("w-64 space-y-3",i),children:[l("div",{...E,role:"slider",tabIndex:0,"aria-label":"Saturation and brightness","aria-valuetext":`Saturation ${Math.round(s.s*100)}%, brightness ${Math.round(s.v*100)}%`,onKeyDown:r=>M(r,"area"),className:"relative h-40 cursor-crosshair touch-none rounded-[calc(10px*var(--radius-scale))] outline-none ring-offset-2 ring-offset-[var(--raised)] focus-visible:ring-2 focus-visible:ring-primary/50",style:{background:`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, ${C})`},children:l("span",{"aria-hidden":!0,className:"pointer-events-none absolute size-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgba(5,8,22,.25),0_2px_6px_rgba(5,8,22,.35)]",style:{left:`${s.s*100}%`,top:`${(1-s.v)*100}%`,background:c}})}),l("div",{...R,role:"slider",tabIndex:0,"aria-label":"Hue","aria-valuemin":0,"aria-valuemax":360,"aria-valuenow":Math.round(s.h),onKeyDown:r=>M(r,"hue"),className:"relative h-3 cursor-pointer touch-none rounded-full outline-none ring-offset-2 ring-offset-[var(--raised)] focus-visible:ring-2 focus-visible:ring-primary/50",style:{background:"linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00)"},children:l("span",{"aria-hidden":!0,className:"pointer-events-none absolute top-1/2 size-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgba(5,8,22,.25),0_2px_6px_rgba(5,8,22,.35)]",style:{left:`${s.h/360*100}%`,background:C}})}),m("div",{className:"flex items-center gap-2",children:[l("span",{className:"size-8 shrink-0 rounded-[calc(8px*var(--radius-scale))] shadow-[inset_0_0_0_1px_rgba(5,8,22,.12)]",style:{background:c}}),m("label",{className:"flex h-8 min-w-0 flex-1 items-center gap-1 rounded-ctl border border-border2 bg-raised px-2 focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/20",children:[l("span",{className:"text-[12px] text-muted",children:"#"}),l("input",{value:h.replace(/^#/,""),"aria-label":"Hex colour",spellCheck:!1,maxLength:7,onChange:r=>{const n=`#${r.target.value.replace(/[^0-9a-f]/gi,"").slice(0,6)}`;w(n),n.length===7&&y(n)},onBlur:()=>w(c),className:"num min-w-0 flex-1 bg-transparent font-mono text-[12.5px] uppercase text-text outline-none"})]}),D?l("button",{type:"button","aria-label":"Pick a colour from the screen",onClick:async()=>{try{const r=await new window.EyeDropper().open();y(r.sRGBHex)}catch{}},className:"grid size-8 shrink-0 cursor-pointer place-items-center rounded-ctl border border-border2 bg-raised text-muted transition-colors hover:bg-hover hover:text-text",children:l($,{className:"size-4"})}):null]}),e&&e.length?l("div",{className:"grid grid-cols-6 gap-1.5",children:e.map(r=>{const n=r.toLowerCase()===c;return l("button",{type:"button","aria-label":r,"aria-pressed":n,onClick:()=>y(r),className:P("h-7 cursor-pointer rounded-[calc(7px*var(--radius-scale))] shadow-[inset_0_0_0_1px_rgba(5,8,22,.12)] transition-transform hover:scale-110",n&&"ring-2 ring-[var(--text)] ring-offset-2 ring-offset-[var(--raised)]"),style:{background:r}},r)})}):null]})}function B({value:o,defaultValue:t="#4f46e5",onValueChange:a,swatches:e,"aria-label":i="Colour",className:d}){const[b,c]=p.useState(t),s=o??b,g=h=>{o===void 0&&c(h),a?.(h)};return m(x.Root,{children:[m(x.Trigger,{"aria-label":`${i}: ${s}`,className:P("inline-flex h-ctl cursor-pointer items-center gap-2 rounded-ctl border border-border2 bg-raised pl-1.5 pr-3 text-[13px] text-text outline-none transition-[border-color,box-shadow]","hover:border-muted/50 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",d),children:[l("span",{className:"size-6 rounded-[calc(6px*var(--radius-scale))] shadow-[inset_0_0_0_1px_rgba(5,8,22,.12)]",style:{background:s}}),l("span",{className:"num font-mono text-[12.5px] uppercase",children:s})]}),l(x.Portal,{children:l(x.Content,{"data-pop":"",align:"start",sideOffset:6,collisionPadding:12,className:"z-50 rounded-dlg border border-border bg-raised p-3 shadow-elev3 outline-none",children:l(L,{value:s,onValueChange:g,swatches:e})})})]})}export{L as ColorPicker,B as ColorPickerPopover};
|
|
@@ -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,34 +1,47 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
/**
|
|
3
|
-
* Confirmation for actions that
|
|
4
|
-
*
|
|
3
|
+
* Confirmation for actions that matter — delete, suspend, void, revoke, and
|
|
4
|
+
* the big good ones too (publish, send a payout).
|
|
5
5
|
*
|
|
6
|
-
* Built to slow the hand down just enough: a clear icon in
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* names the action and the count ("Delete 12 rows"), never just "OK".
|
|
11
|
-
*
|
|
6
|
+
* Built to slow the hand down just enough: a clear icon in its tone, the
|
|
7
|
+
* consequence in one sentence, the actual things affected (first few by name,
|
|
8
|
+
* then "+ n more"), and for big or irreversible actions either a word to type
|
|
9
|
+
* (`confirmWord`) or a button to press and hold (`hold`). The confirm button
|
|
10
|
+
* names the action and the count ("Delete 12 rows"), never just "OK". Focus
|
|
11
|
+
* starts on Cancel, so Enter alone never does anything.
|
|
12
|
+
*
|
|
13
|
+
* Looks:
|
|
14
|
+
* center — the default: icon in a halo, centred text. Most confirmations.
|
|
15
|
+
* split — icon beside left-aligned text, buttons on the right. Desktop tools, dense apps.
|
|
16
|
+
* banner — a band of the tone across the top with a large icon. The irreversible ones.
|
|
17
|
+
* sheet — rises from the bottom edge, full width on phones. Touch-first screens.
|
|
18
|
+
* Tones: danger (default), warning, primary (a positive action worth a pause).
|
|
12
19
|
*/
|
|
20
|
+
export type ConfirmTone = "danger" | "warning" | "primary";
|
|
21
|
+
export type ConfirmVariant = "center" | "split" | "banner" | "sheet";
|
|
13
22
|
export interface ConfirmDialogProps {
|
|
14
23
|
open: boolean;
|
|
15
24
|
onOpenChange: (open: boolean) => void;
|
|
16
25
|
title: React.ReactNode;
|
|
17
26
|
description?: React.ReactNode;
|
|
18
|
-
/** What
|
|
27
|
+
/** What is affected: names shown in a list (first `previewCount`, then "+ n more"). */
|
|
19
28
|
items?: string[];
|
|
20
29
|
previewCount?: number;
|
|
21
30
|
/** Require typing this word (e.g. "DELETE") before the button unlocks. */
|
|
22
31
|
confirmWord?: string;
|
|
32
|
+
/** Press and hold the button to confirm; a number sets the hold in ms (default 1200). */
|
|
33
|
+
hold?: boolean | number;
|
|
23
34
|
confirmLabel: React.ReactNode;
|
|
24
35
|
cancelLabel?: React.ReactNode;
|
|
25
|
-
tone?:
|
|
36
|
+
tone?: ConfirmTone;
|
|
37
|
+
variant?: ConfirmVariant;
|
|
26
38
|
icon?: React.ReactNode;
|
|
27
39
|
/** Runs on confirm; the button spins until it settles, the dialog closes on success. */
|
|
28
40
|
onConfirm: () => void | Promise<void>;
|
|
29
41
|
labels?: {
|
|
30
42
|
typeToConfirm?: (word: string) => string;
|
|
31
43
|
more?: (n: number) => string;
|
|
44
|
+
hold?: string;
|
|
32
45
|
};
|
|
33
46
|
}
|
|
34
|
-
export declare function ConfirmDialog({ open, onOpenChange, title, description, items, previewCount, confirmWord, confirmLabel, cancelLabel, tone, icon, onConfirm, labels, }: ConfirmDialogProps): React.JSX.Element;
|
|
47
|
+
export declare function ConfirmDialog({ open, onOpenChange, title, description, items, previewCount, confirmWord, hold, confirmLabel, cancelLabel, tone, variant, icon, onConfirm, labels, }: ConfirmDialogProps): React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as
|
|
1
|
+
"use client";import{Fragment as Z,jsx as e,jsxs as r}from"react/jsx-runtime";import*as f from"@radix-ui/react-dialog";import{CircleAlert as I,CircleCheck as q,ShieldAlert as G,Trash2 as J}from"lucide-react";import*as i from"react";import{cn as d}from"../../lib/utils.js";import{Button as A}from"./button.js";import{DialogOverlay as Q}from"./dialog.js";import{Input as X}from"./input.js";const N={danger:{c:"var(--danger)",s:"var(--danger-subtle)",icon:e(J,{}),grad:"linear-gradient(180deg,#ef4444,#dc2626)",glow:"rgba(220,38,38,.7)"},warning:{c:"var(--warning)",s:"var(--warning-subtle)",icon:e(G,{}),grad:"linear-gradient(180deg,#f59e0b,#b45309)",glow:"rgba(180,83,9,.7)"},primary:{c:"var(--primary)",s:"var(--primary-subtle)",icon:e(q,{}),grad:"linear-gradient(135deg,var(--brand-1),var(--brand-2))",glow:"color-mix(in srgb,var(--brand-1) 70%,transparent)"}};function Y({ms:m,tone:c,disabled:x,busy:u,label:g,hint:v,onDone:l}){const[p,b]=i.useState(!1),h=i.useRef(void 0),s=()=>{x||u||(b(!0),h.current=window.setTimeout(()=>{b(!1),l()},m))},t=()=>{window.clearTimeout(h.current),b(!1)};return i.useEffect(()=>t,[]),r("button",{type:"button",disabled:x||u,onPointerDown:s,onPointerUp:t,onPointerLeave:t,onKeyDown:o=>{(o.key===" "||o.key==="Enter")&&!o.repeat&&s()},onKeyUp:o=>{(o.key===" "||o.key==="Enter")&&t()},"aria-label":typeof g=="string"?`${g} (${v})`:void 0,className:"relative isolate h-ctl cursor-pointer select-none overflow-hidden rounded-ctl px-4 text-[13px] font-semibold text-white outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--raised)] disabled:cursor-not-allowed disabled:opacity-50",style:{background:`color-mix(in srgb, ${N[c].c} 55%, #1a113e)`,boxShadow:`0 6px 16px -8px ${N[c].glow}`},children:[e("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 -z-10",style:{width:p?"100%":"0%",background:N[c].grad,transition:p?`width ${m}ms linear`:"width 200ms ease-out"}}),r("span",{className:"flex items-center justify-center gap-2",children:[u?e("span",{className:"size-3.5 animate-spin rounded-full border-2 border-white/40 border-t-white"}):null,p?v:g]})]})}function ne({open:m,onOpenChange:c,title:x,description:u,items:g,previewCount:v=3,confirmWord:l,hold:p,confirmLabel:b,cancelLabel:h="Cancel",tone:s="danger",variant:t="center",icon:o,onConfirm:F,labels:H}){const[C,z]=i.useState(""),[w,$]=i.useState(!1),[S,k]=i.useState(null),B=i.useRef(null);i.useEffect(()=>{m&&(z(""),k(null))},[m]);const R=!!l&&C.trim().toUpperCase()!==l.toUpperCase(),_={typeToConfirm:a=>`Type ${a} to confirm`,more:a=>`+ ${a} more`,hold:"Keep holding\u2026",...H},n=N[s],D=g?.slice(0,v)??[],E=(g?.length??0)-D.length,L=p===!0?1200:typeof p=="number"?p:0,U=t==="center"||t==="banner",j=async()=>{$(!0),k(null);try{await F(),c(!1)}catch(a){k(a instanceof Error?a.message:String(a))}finally{$(!1)}},T=a=>e("span",{className:d("relative grid shrink-0 place-items-center rounded-full text-white shadow-[inset_0_1px_0_rgba(255,255,255,.3)]",a==="lg"?"size-14 [&_svg]:size-6":"size-9 [&_svg]:size-[18px]"),style:{background:n.grad,boxShadow:`inset 0 1px 0 rgba(255,255,255,.3), 0 6px 16px -6px ${n.glow}`},children:o??n.icon}),P=r(Z,{children:[e(f.Title,{className:d("disp text-[17px] font-semibold leading-6 text-text",t==="banner"&&"text-[19px]"),children:x}),u?e(f.Description,{className:d("mt-1.5 text-[13px] leading-5 text-muted",U&&"mx-auto max-w-[36ch]"),children:u}):null,D.length?r("ul",{className:"mt-4 space-y-1 rounded-[calc(12px*var(--radius-scale))] border border-border bg-surface p-2 text-left",children:[D.map((a,y)=>r("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:"size-1.5 shrink-0 rounded-full",style:{background:n.c}}),e("span",{className:"truncate",children:a})]},`${a}-${y}`)),E>0?e("li",{className:"px-2 py-1 text-[12px] font-medium text-muted",children:_.more(E)}):null]}):null,l?r("div",{className:"mt-4 text-left",children:[e("label",{className:"mb-1.5 block text-[12px] font-medium text-muted",children:_.typeToConfirm(l).split(l).map((a,y,M)=>r(i.Fragment,{children:[a,y<M.length-1?e("b",{className:"font-semibold",style:{color:n.c},children:l}):null]},y))}),e(X,{value:C,onChange:a=>z(a.target.value),autoComplete:"off",spellCheck:!1,className:"text-center font-medium uppercase tracking-[0.2em]",state:!R&&C?"success":"default"})]}):null,S?r("p",{role:"alert",className:d("mt-3 flex items-center gap-1.5 text-[12.5px] text-danger",U&&"justify-center"),children:[e(I,{className:"size-3.5"})," ",S]}):null]}),K=L?e(Y,{ms:L,tone:s,disabled:R,busy:w,label:b,hint:_.hold,onDone:j}):e(A,{variant:s==="danger"?"danger":s==="primary"?"gradient":"primary",disabled:R,loading:w,style:s==="warning"?{background:n.grad}:void 0,className:d(s!=="primary"&&"shadow-[0_6px_16px_-8px_rgba(220,38,38,.8)]"),onClick:j,children:b}),O=e(A,{ref:B,disabled:w,onClick:()=>c(!1),children:h}),V={center:"left-1/2 top-1/2 w-[calc(100vw-32px)] max-w-[440px] -translate-x-1/2 -translate-y-1/2 rounded-[calc(18px*var(--radius-scale))]",banner:"left-1/2 top-1/2 w-[calc(100vw-32px)] max-w-[460px] -translate-x-1/2 -translate-y-1/2 rounded-[calc(20px*var(--radius-scale))]",split:"left-1/2 top-1/2 w-[calc(100vw-32px)] max-w-[520px] -translate-x-1/2 -translate-y-1/2 rounded-[calc(14px*var(--radius-scale))]",sheet:"inset-x-0 bottom-0 mx-auto w-full max-w-[560px] rounded-t-[calc(22px*var(--radius-scale))] sm:bottom-4 sm:w-[calc(100vw-32px)] sm:rounded-[calc(22px*var(--radius-scale))]"};return e(f.Root,{open:m,onOpenChange:a=>!w&&c(a),children:r(f.Portal,{children:[e(Q,{}),r(f.Content,{"data-dialog":t==="sheet"?void 0:"","data-confirm-sheet":t==="sheet"?"":void 0,onOpenAutoFocus:a=>{a.preventDefault(),B.current?.focus()},className:d("fixed z-50 overflow-hidden border border-border bg-raised shadow-elev3 outline-none",V[t]),style:{"--tone":n.c,"--tone-subtle":n.s},children:[t==="sheet"?e("span",{"aria-hidden":!0,className:"mx-auto mt-2.5 block h-1 w-10 rounded-full bg-border2 sm:hidden"}):null,t==="banner"?r("div",{className:"relative grid h-32 place-items-center overflow-hidden",style:{background:n.grad},children:[e("span",{"aria-hidden":!0,className:"absolute inset-0 bg-[radial-gradient(60%_80%_at_50%_120%,rgba(255,255,255,.35),transparent_70%)]"}),e("span",{"aria-hidden":!0,className:"absolute -left-10 -top-10 size-40 rounded-full border border-white/15"}),e("span",{"aria-hidden":!0,className:"absolute -bottom-16 -right-8 size-48 rounded-full border border-white/15"}),e("span",{className:"relative grid size-16 place-items-center rounded-[calc(18px*var(--radius-scale))] bg-white/15 text-white shadow-[inset_0_1px_0_rgba(255,255,255,.35),0_12px_30px_-10px_rgba(5,8,22,.5)] ring-1 ring-white/30 backdrop-blur [&_svg]:size-7",children:o??n.icon})]}):null,t==="center"?e("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-x-0 top-0 h-28",style:{background:`radial-gradient(70% 100% at 50% 0%, ${n.s}, transparent)`}}):null,t==="split"?r("div",{className:"relative flex gap-4 px-6 pb-5 pt-6",children:[T("md"),e("div",{className:"min-w-0 flex-1 pt-1",children:P})]}):t==="sheet"?e("div",{className:"relative px-6 pb-4 pt-5",children:r("div",{className:"flex items-start gap-3.5",children:[T("md"),e("div",{className:"min-w-0 flex-1 pt-1",children:P})]})}):r("div",{className:d("relative px-6 pb-5 text-center",t==="banner"?"pt-5":"pt-7"),children:[t==="center"?r("div",{className:"relative mx-auto mb-4 grid size-14 place-items-center",children:[e("span",{className:"absolute inset-0 rounded-full opacity-10",style:{background:n.c}}),e("span",{className:"absolute inset-[7px] rounded-full opacity-15",style:{background:n.c}}),T("md")]}):null,P]}),r("div",{className:d("relative gap-2 border-t border-border bg-surface/70 px-6 py-4",t==="split"?"flex justify-end":t==="sheet"?"grid grid-cols-2 sm:flex sm:justify-end":"grid grid-cols-2"),children:[O,K]})]})]})})}export{ne as ConfirmDialog};
|
|
@@ -64,7 +64,17 @@ export interface DateRangePreset {
|
|
|
64
64
|
}
|
|
65
65
|
/** The presets reports reach for most. Pass your own (translated) list to replace them. */
|
|
66
66
|
export declare const DEFAULT_RANGE_PRESETS: DateRangePreset[];
|
|
67
|
-
|
|
67
|
+
/**
|
|
68
|
+
* DateRangePicker — a span of days for a report, a booking, an export.
|
|
69
|
+
*
|
|
70
|
+
* The field shows both ends and the length ("1 Oct → 7 Oct · 7 days"). In the
|
|
71
|
+
* panel, the Start and End slots say which end is being picked, presets show
|
|
72
|
+
* the dates they stand for, the band previews the span as you move toward
|
|
73
|
+
* the end, and nothing is committed until Apply (Escape or Cancel leaves the
|
|
74
|
+
* value as it was). `applyOnSelect` commits on the second click instead, for
|
|
75
|
+
* filters that should react at once.
|
|
76
|
+
*/
|
|
77
|
+
export declare function DateRangePicker({ value, onChange, id, placeholder, min, max, presets, numberOfMonths, applyOnSelect, disabled, clearable, className, locale, weekStartsOn, labels, }: Shared & {
|
|
68
78
|
value: DateRangeValue;
|
|
69
79
|
onChange: (value: DateRangeValue) => void;
|
|
70
80
|
min?: string;
|
|
@@ -72,9 +82,16 @@ export declare function DateRangePicker({ value, onChange, id, placeholder, min,
|
|
|
72
82
|
/** Quick ranges on the left; [] hides the list. */
|
|
73
83
|
presets?: DateRangePreset[];
|
|
74
84
|
numberOfMonths?: 1 | 2;
|
|
85
|
+
/** Commit when the last day is picked, with no Apply button. */
|
|
86
|
+
applyOnSelect?: boolean;
|
|
75
87
|
labels?: {
|
|
76
88
|
clear?: string;
|
|
77
89
|
pickEnd?: string;
|
|
90
|
+
start?: string;
|
|
91
|
+
end?: string;
|
|
92
|
+
apply?: string;
|
|
93
|
+
cancel?: string;
|
|
94
|
+
days?: (n: number) => string;
|
|
78
95
|
};
|
|
79
96
|
}): React.JSX.Element;
|
|
80
97
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as s}from"react/jsx-runtime";import*as g from"@radix-ui/react-popover";import{CalendarClock as j,CalendarDays as W,CalendarRange as _,X as H}from"lucide-react";import*as A from"react";import{cn as v}from"../../lib/utils.js";import{addDays as E,addMonths as G,Calendar as I,parseIsoDay as x,toIsoDay as r}from"./calendar.js";import{inputClass as U}from"./input.js";import{formatTime as X,parseTime as q,TimeColumns as J,toTime as Y}from"./time-picker.js";const S="cursor-pointer rounded-ctl px-2 py-1 text-[12.5px] transition-colors disabled:cursor-not-allowed disabled:opacity-40",z="z-[60] rounded-dlg border border-border bg-raised p-3 shadow-elev3 outline-none";function B({id:t,icon:a,text:u,placeholder:N,open:P,disabled:h,onClear:l,clearLabel:p,className:C}){return s("div",{className:v("relative",C),children:[e(g.Trigger,{asChild:!0,disabled:h,children:s("button",{id:t,type:"button",className:v(U,"flex cursor-pointer items-center gap-2 text-left",P&&"border-primary ring-2 ring-primary/20",l&&u&&"pr-9"),children:[e(a,{className:"size-4 shrink-0 text-muted"}),e("span",{className:v("num min-w-0 flex-1 truncate",!u&&"text-placeholder"),children:u??N})]})}),l&&u&&!h?e("button",{type:"button","aria-label":p,onClick:l,className:"absolute right-2 top-1/2 grid size-6 -translate-y-1/2 cursor-pointer place-items-center rounded-full text-muted transition-colors hover:bg-hover hover:text-text",children:e(H,{className:"size-3.5"})}):null]})}const V=t=>new Intl.DateTimeFormat(t,{weekday:"short",day:"numeric",month:"short",year:"numeric"});function ne({value:t,onChange:a,id:u,placeholder:N="Pick a date",min:P,max:h,disabled:l,clearable:p=!0,className:C,locale:T="en-GB",weekStartsOn:F=1,labels:R}){const[y,O]=A.useState(!1),D=x(t),b=x(P),n=x(h),o=new Date,c=(!b||r(o)>=r(b))&&(!n||r(o)<=r(n)),w={today:"Today",clear:"Clear",...R},f=m=>{a(r(m)),O(!1)};return s(g.Root,{open:y,onOpenChange:O,children:[e(B,{id:u,icon:W,text:D?V(T).format(D):null,placeholder:N,open:y,disabled:l,onClear:p?()=>a(""):void 0,clearLabel:w.clear,className:C}),e(g.Portal,{children:s(g.Content,{"data-pop":"",align:"start",sideOffset:6,collisionPadding:12,onOpenAutoFocus:m=>m.preventDefault(),className:z,children:[e(I,{selected:D,onDayClick:f,min:b,max:n,locale:T,weekStartsOn:F,autoFocus:!0}),s("div",{className:"mt-2 flex items-center justify-between border-t border-border pt-2",children:[e("button",{type:"button",disabled:!c,onClick:()=>f(o),className:v(S,"font-medium text-primary hover:bg-primary-subtle"),children:w.today}),p&&D?e("button",{type:"button",onClick:()=>{a(""),O(!1)},className:v(S,"text-muted hover:bg-hover hover:text-text"),children:w.clear}):null]})]})})]})}function re({value:t,onChange:a,id:u,placeholder:N="Pick a date and time",min:P,max:h,step:l=5,hourCycle:p=24,defaultTime:C="09:00",disabled:T,clearable:F=!0,className:R,locale:y="en-GB",weekStartsOn:O=1,labels:D}){const[b,n]=A.useState(!1),o=x(t),c=q(t.split("T")[1]),w=x(P),f=x(h),m={now:"Now",done:"Done",clear:"Clear",time:"Time",...D},L=(d,M)=>a(`${r(d)}T${M}`),$=o&&w&&r(o)===r(w)?P.split("T")[1]:void 0,i=o&&f&&r(o)===r(f)?h.split("T")[1]:void 0,k=o&&c?`${V(y).format(o)} \xB7 ${X(Y(c),{locale:y,hourCycle:p})}`:null;return s(g.Root,{open:b,onOpenChange:n,children:[e(B,{id:u,icon:j,text:k,placeholder:N,open:b,disabled:T,onClear:F?()=>a(""):void 0,clearLabel:m.clear,className:R}),e(g.Portal,{children:s(g.Content,{"data-pop":"",align:"start",sideOffset:6,collisionPadding:12,onOpenAutoFocus:d=>d.preventDefault(),className:z,children:[s("div",{className:"flex flex-col gap-4 sm:flex-row",children:[e(I,{selected:o,onDayClick:d=>L(d,c?Y(c):C),min:w,max:f,locale:y,weekStartsOn:O,autoFocus:!0}),s("div",{className:"border-border sm:border-l sm:pl-4",children:[e("p",{className:"disp mb-2 hidden h-8 items-center text-[13.5px] font-semibold text-text sm:flex",children:m.time}),e(J,{value:c,onChange:d=>L(o??new Date,Y(d)),step:l,hourCycle:p,min:$,max:i,locale:y})]})]}),s("div",{className:"mt-3 flex items-center justify-between border-t border-border pt-2",children:[e("button",{type:"button",onClick:()=>{const d=new Date,M=Math.round(d.getMinutes()/l)*l;L(d,Y({h:(d.getHours()+Math.floor(M/60))%24,m:M%60}))},className:v(S,"font-medium text-primary hover:bg-primary-subtle"),children:m.now}),s("div",{className:"flex items-center gap-1",children:[F&&k?e("button",{type:"button",onClick:()=>a(""),className:v(S,"text-muted hover:bg-hover hover:text-text"),children:m.clear}):null,e("button",{type:"button",onClick:()=>n(!1),className:v(S,"bg-primary px-3 font-medium text-white hover:bg-primary-hover"),children:m.done})]})]})]})})]})}const K=[{label:"Today",range:()=>({from:new Date,to:new Date})},{label:"Yesterday",range:()=>({from:E(new Date,-1),to:E(new Date,-1)})},{label:"Last 7 days",range:()=>({from:E(new Date,-6),to:new Date})},{label:"Last 30 days",range:()=>({from:E(new Date,-29),to:new Date})},{label:"This month",range:()=>{const t=new Date;return{from:new Date(t.getFullYear(),t.getMonth(),1),to:t}}},{label:"Last month",range:()=>{const t=G(new Date(new Date().getFullYear(),new Date().getMonth(),1),-1);return{from:t,to:new Date(t.getFullYear(),t.getMonth()+1,0)}}}];function ae({value:t,onChange:a,id:u,placeholder:N="Pick a date range",min:P,max:h,presets:l=K,numberOfMonths:p=2,disabled:C,clearable:T=!0,className:F,locale:R="en-GB",weekStartsOn:y=1,labels:O}){const[D,b]=A.useState(!1),n=x(t.from),o=x(t.to),c={clear:"Clear",pickEnd:"Now pick the last day",...O},w=new Intl.DateTimeFormat(R,{day:"numeric",month:"short"}),f=new Intl.DateTimeFormat(R,{day:"numeric",month:"short",year:"numeric"}),m=n&&o?r(n)===r(o)?f.format(n):`${(n.getFullYear()===o.getFullYear()?w:f).format(n)} \u2013 ${f.format(o)}`:null,L=i=>{if(!n||o||i<n)return a({from:r(i),to:""});a({from:t.from,to:r(i)}),b(!1)},$=i=>{const k=i.range();return t.from===r(k.from)&&t.to===r(k.to)};return s(g.Root,{open:D,onOpenChange:b,children:[e(B,{id:u,icon:_,text:m,placeholder:N,open:D,disabled:C,onClear:T?()=>a({from:"",to:""}):void 0,clearLabel:c.clear,className:F}),e(g.Portal,{children:e(g.Content,{"data-pop":"",align:"start",sideOffset:6,collisionPadding:12,onOpenAutoFocus:i=>i.preventDefault(),className:z,children:s("div",{className:"flex flex-col gap-3 sm:flex-row",children:[l.length?e("ul",{className:"flex shrink-0 gap-1 overflow-x-auto border-border pb-2 sm:w-36 sm:flex-col sm:overflow-visible sm:border-r sm:pb-0 sm:pr-3",children:l.map(i=>e("li",{children:e("button",{type:"button",onClick:()=>{const k=i.range();a({from:r(k.from),to:r(k.to)}),b(!1)},className:v("w-full cursor-pointer whitespace-nowrap rounded-ctl px-2.5 py-1.5 text-left text-[13px] transition-colors",$(i)?"bg-primary-subtle font-medium text-primary":"text-body hover:bg-hover hover:text-text"),children:i.label})},i.label))}):null,s("div",{children:[e(I,{range:{from:n,to:o},onDayClick:L,min:x(P),max:x(h),locale:R,weekStartsOn:y,numberOfMonths:p,defaultMonth:n??(p===2?G(new Date,-1):void 0),autoFocus:!0}),s("div",{className:"mt-2 flex min-h-8 items-center justify-between border-t border-border pt-2",children:[e("p",{className:"num text-[12px] text-muted",children:n&&!o?c.pickEnd:m}),T&&(n||o)?e("button",{type:"button",onClick:()=>a({from:"",to:""}),className:v(S,"text-muted hover:bg-hover hover:text-text"),children:c.clear}):null]})]})]})})})]})}export{K as DEFAULT_RANGE_PRESETS,ne as DatePicker,ae as DateRangePicker,re as DateTimePicker};
|
|
1
|
+
"use client";import{Fragment as j,jsx as e,jsxs as a}from"react/jsx-runtime";import*as v from"@radix-ui/react-popover";import{CalendarClock as ie,CalendarDays as le,CalendarRange as me,X as J}from"lucide-react";import*as z from"react";import{cn as n}from"../../lib/utils.js";import{addDays as Y,addMonths as Q,Calendar as W,parseIsoDay as d,toIsoDay as s}from"./calendar.js";import{inputClass as Z}from"./input.js";import{formatTime as de,parseTime as ce,TimeColumns as pe,toTime as B}from"./time-picker.js";const O="cursor-pointer rounded-ctl px-2 py-1 text-[12.5px] transition-colors disabled:cursor-not-allowed disabled:opacity-40",ee="z-[60] rounded-dlg border border-border bg-raised p-3 shadow-elev3 outline-none";function te({id:o,icon:u,text:y,placeholder:S,open:C,disabled:w,onClear:b,clearLabel:h,className:N}){return a("div",{className:n("relative",N),children:[e(v.Trigger,{asChild:!0,disabled:w,children:a("button",{id:o,type:"button",className:n(Z,"flex cursor-pointer items-center gap-2 text-left",C&&"border-primary ring-2 ring-primary/20",b&&y&&"pr-9"),children:[e(u,{className:"size-4 shrink-0 text-muted"}),e("span",{className:n("num min-w-0 flex-1 truncate",!y&&"text-placeholder"),children:y??S})]})}),b&&y&&!w?e("button",{type:"button","aria-label":h,onClick:b,className:"absolute right-2 top-1/2 grid size-6 -translate-y-1/2 cursor-pointer place-items-center rounded-full text-muted transition-colors hover:bg-hover hover:text-text",children:e(J,{className:"size-3.5"})}):null]})}const re=o=>new Intl.DateTimeFormat(o,{weekday:"short",day:"numeric",month:"short",year:"numeric"});function ye({value:o,onChange:u,id:y,placeholder:S="Pick a date",min:C,max:w,disabled:b,clearable:h=!0,className:N,locale:E="en-GB",weekStartsOn:T=1,labels:V}){const[g,L]=z.useState(!1),R=d(o),f=d(C),D=d(w),i=new Date,c=(!f||s(i)>=s(f))&&(!D||s(i)<=s(D)),k={today:"Today",clear:"Clear",...V},_=l=>{u(s(l)),L(!1)};return a(v.Root,{open:g,onOpenChange:L,children:[e(te,{id:y,icon:le,text:R?re(E).format(R):null,placeholder:S,open:g,disabled:b,onClear:h?()=>u(""):void 0,clearLabel:k.clear,className:N}),e(v.Portal,{children:a(v.Content,{"data-pop":"",align:"start",sideOffset:6,collisionPadding:12,onOpenAutoFocus:l=>l.preventDefault(),className:ee,children:[e(W,{selected:R,onDayClick:_,min:f,max:D,locale:E,weekStartsOn:T,autoFocus:!0}),a("div",{className:"mt-2 flex items-center justify-between border-t border-border pt-2",children:[e("button",{type:"button",disabled:!c,onClick:()=>_(i),className:n(O,"font-medium text-primary hover:bg-primary-subtle"),children:k.today}),h&&R?e("button",{type:"button",onClick:()=>{u(""),L(!1)},className:n(O,"text-muted hover:bg-hover hover:text-text"),children:k.clear}):null]})]})})]})}function he({value:o,onChange:u,id:y,placeholder:S="Pick a date and time",min:C,max:w,step:b=5,hourCycle:h=24,defaultTime:N="09:00",disabled:E,clearable:T=!0,className:V,locale:g="en-GB",weekStartsOn:L=1,labels:R}){const[f,D]=z.useState(!1),i=d(o),c=ce(o.split("T")[1]),k=d(C),_=d(w),l={now:"Now",done:"Done",clear:"Clear",time:"Time",...R},F=(m,M)=>u(`${s(m)}T${M}`),$=i&&k&&s(i)===s(k)?C.split("T")[1]:void 0,G=i&&_&&s(i)===s(_)?w.split("T")[1]:void 0,A=i&&c?`${re(g).format(i)} \xB7 ${de(B(c),{locale:g,hourCycle:h})}`:null;return a(v.Root,{open:f,onOpenChange:D,children:[e(te,{id:y,icon:ie,text:A,placeholder:S,open:f,disabled:E,onClear:T?()=>u(""):void 0,clearLabel:l.clear,className:V}),e(v.Portal,{children:a(v.Content,{"data-pop":"",align:"start",sideOffset:6,collisionPadding:12,onOpenAutoFocus:m=>m.preventDefault(),className:ee,children:[a("div",{className:"flex flex-col gap-4 sm:flex-row",children:[e(W,{selected:i,onDayClick:m=>F(m,c?B(c):N),min:k,max:_,locale:g,weekStartsOn:L,autoFocus:!0}),a("div",{className:"border-border sm:border-l sm:pl-4",children:[e("p",{className:"disp mb-2 hidden h-8 items-center text-[13.5px] font-semibold text-text sm:flex",children:l.time}),e(pe,{value:c,onChange:m=>F(i??new Date,B(m)),step:b,hourCycle:h,min:$,max:G,locale:g})]})]}),a("div",{className:"mt-3 flex items-center justify-between border-t border-border pt-2",children:[e("button",{type:"button",onClick:()=>{const m=new Date,M=Math.round(m.getMinutes()/b)*b;F(m,B({h:(m.getHours()+Math.floor(M/60))%24,m:M%60}))},className:n(O,"font-medium text-primary hover:bg-primary-subtle"),children:l.now}),a("div",{className:"flex items-center gap-1",children:[T&&A?e("button",{type:"button",onClick:()=>u(""),className:n(O,"text-muted hover:bg-hover hover:text-text"),children:l.clear}):null,e("button",{type:"button",onClick:()=>D(!1),className:n(O,"bg-primary px-3 font-medium text-white hover:bg-primary-hover"),children:l.done})]})]})]})})]})}const ue=[{label:"Today",range:()=>({from:new Date,to:new Date})},{label:"Yesterday",range:()=>({from:Y(new Date,-1),to:Y(new Date,-1)})},{label:"Last 7 days",range:()=>({from:Y(new Date,-6),to:new Date})},{label:"Last 30 days",range:()=>({from:Y(new Date,-29),to:new Date})},{label:"This month",range:()=>{const o=new Date;return{from:new Date(o.getFullYear(),o.getMonth(),1),to:o}}},{label:"Last month",range:()=>{const o=Q(new Date(new Date().getFullYear(),new Date().getMonth(),1),-1);return{from:o,to:new Date(o.getFullYear(),o.getMonth()+1,0)}}}];function De({value:o,onChange:u,id:y,placeholder:S="Pick a date range",min:C,max:w,presets:b=ue,numberOfMonths:h=2,applyOnSelect:N=!1,disabled:E,clearable:T=!0,className:V,locale:g="en-GB",weekStartsOn:L=1,labels:R}){const[f,D]=z.useState(!1),[i,c]=z.useState(o),[k,_]=z.useState(0);z.useEffect(()=>{f&&c(o)},[f]);const l={clear:"Clear",pickEnd:"Now pick the last day",start:"Start",end:"End",apply:"Apply",cancel:"Cancel",days:r=>`${r} ${r===1?"day":"days"}`,...R},F=new Intl.DateTimeFormat(g,{day:"numeric",month:"short"}),$=new Intl.DateTimeFormat(g,{day:"numeric",month:"short",year:"numeric"}),G=new Intl.DateTimeFormat(g,{weekday:"short"}),A=(r,t)=>Math.round((t.getTime()-r.getTime())/864e5)+1,m=r=>{const t=d(r.from),p=d(r.to);return!t||!p?null:s(t)===s(p)?$.format(t):`${(t.getFullYear()===p.getFullYear()?F:$).format(t)} \u2192 ${$.format(p)}`},M=d(o.from),H=d(o.to),x=d(i.from),P=d(i.to),ae=x&&!P?"end":"start",K=r=>{u(r),D(!1)},oe=r=>{if(!x||P||r<x)return c({from:s(r),to:""});const t={from:i.from,to:s(r)};c(t),N&&K(t)},ne=(r,t)=>{const p=r.range();return t.from===s(p.from)&&t.to===s(p.to)},U=(r,t)=>{const p=ae===r;return a("div",{className:n("min-w-0 flex-1 rounded-[calc(10px*var(--radius-scale))] border px-3 py-2 transition-[border-color,box-shadow,background-color] duration-200",p?"border-primary bg-raised shadow-[0_0_0_3px_var(--primary-subtle)]":"border-border bg-surface"),children:[e("p",{className:n("text-[10.5px] font-semibold uppercase tracking-[0.08em]",p?"text-primary":"text-muted"),children:r==="start"?l.start:l.end}),e("p",{className:n("num truncate text-[13.5px] font-semibold",t?"text-text":"text-placeholder"),children:t?a(j,{children:[$.format(t)," ",a("span",{className:"font-normal text-muted",children:["\xB7 ",G.format(t)]})]}):"\u2014"})]})},I=m(o),X=M&&H?A(M,H):0;return a(v.Root,{open:f,onOpenChange:D,children:[a("div",{className:n("relative",V),children:[e(v.Trigger,{asChild:!0,disabled:E,children:a("button",{id:y,type:"button",className:n(Z,"flex cursor-pointer items-center gap-2 text-left",f&&"border-primary ring-2 ring-primary/20",T&&I&&"pr-9"),children:[e(me,{className:n("size-4 shrink-0",I?"text-primary":"text-muted")}),e("span",{className:n("num min-w-0 flex-1 truncate",!I&&"text-placeholder"),children:I??S}),X>1?e("span",{className:"num shrink-0 rounded-full bg-primary-subtle px-2 py-px text-[11px] font-semibold text-primary",children:l.days(X)}):null]})}),T&&I&&!E?e("button",{type:"button","aria-label":l.clear,onClick:()=>u({from:"",to:""}),className:"absolute right-2 top-1/2 grid size-6 -translate-y-1/2 cursor-pointer place-items-center rounded-full text-muted transition-colors hover:bg-hover hover:text-text",children:e(J,{className:"size-3.5"})}):null]}),e(v.Portal,{children:e(v.Content,{"data-pop":"",align:"start",sideOffset:6,collisionPadding:12,onOpenAutoFocus:r=>r.preventDefault(),className:"z-[60] overflow-hidden rounded-dlg border border-border bg-raised shadow-elev3 outline-none",children:a("div",{className:"flex flex-col sm:flex-row",children:[b.length?e("ul",{className:"flex shrink-0 gap-1 overflow-x-auto border-b border-border bg-surface p-2 sm:w-44 sm:flex-col sm:overflow-visible sm:border-b-0 sm:border-r",children:b.map(r=>{const t=r.range(),p=ne(r,i);return e("li",{children:a("button",{type:"button",onClick:()=>{const q={from:s(t.from),to:s(t.to)};c(q),_(se=>se+1),N&&K(q)},className:n("group/p w-full cursor-pointer whitespace-nowrap rounded-[calc(9px*var(--radius-scale))] px-2.5 py-2 text-left transition-colors",p?"bg-raised shadow-[var(--lit),0_1px_2px_rgba(5,8,22,.06),0_4px_12px_-6px_rgba(5,8,22,.2)] ring-1 ring-border":"hover:bg-hover"),children:[e("span",{className:n("block text-[13px] font-medium",p?"text-primary":"text-text"),children:r.label}),e("span",{className:"num hidden text-[11px] text-muted sm:block",children:s(t.from)===s(t.to)?F.format(t.from):`${F.format(t.from)} \u2013 ${F.format(t.to)}`})]})},r.label)})}):null,a("div",{className:"p-3",children:[a("div",{className:"mb-3 flex items-center gap-2",children:[U("start",x),e("span",{className:"grid size-6 shrink-0 place-items-center text-muted",children:"\u2192"}),U("end",P)]}),e(W,{range:{from:x,to:P},onDayClick:oe,min:d(C),max:d(w),locale:g,weekStartsOn:L,numberOfMonths:h,defaultMonth:x??(h===2?Q(new Date,-1):void 0),autoFocus:!0},k),a("div",{className:"mt-3 flex min-h-9 flex-wrap items-center gap-2 border-t border-border pt-3",children:[e("p",{className:"num mr-auto text-[12.5px] text-muted",children:x&&!P?e("span",{className:"text-primary",children:l.pickEnd}):x&&P?a(j,{children:[e("span",{className:"font-semibold text-text",children:l.days(A(x,P))})," \xB7 ",m(i)]}):null}),T&&(x||P)?e("button",{type:"button",onClick:()=>c({from:"",to:""}),className:n(O,"text-muted hover:bg-hover hover:text-text"),children:l.clear}):null,N?null:a(j,{children:[e("button",{type:"button",onClick:()=>D(!1),className:n(O,"border border-border px-3 font-medium text-body hover:bg-hover"),children:l.cancel}),e("button",{type:"button",disabled:!!x&&!P,onClick:()=>K(i),className:n(O,"bg-[linear-gradient(135deg,var(--brand-1),var(--brand-2))] px-3.5 font-medium text-white shadow-[inset_0_1px_0_rgba(255,255,255,.25),0_6px_14px_-8px_var(--brand-1)] hover:brightness-110"),children:l.apply})]})]})]})]})})})]})}export{ue as DEFAULT_RANGE_PRESETS,ye as DatePicker,De as DateRangePicker,he as DateTimePicker};
|