neba 1.16.2 → 1.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/a2ui/adapter-catalog.json +1 -0
- package/dist/a2ui/catalog.json +632 -145
- package/dist/a2ui/components.js +1 -1
- package/dist/a2ui/index.d.ts +22 -10
- package/dist/a2ui/index.js +1 -1
- package/dist/a2ui/schema.d.ts +8 -6
- package/dist/a2ui/schema.js +1 -1
- package/dist/components/accordion/Accordion.js +1 -1
- package/dist/components/agent-steps/AgentSteps.js +1 -1
- package/dist/components/alert/Alert.js +1 -1
- package/dist/components/anchor/Anchor.d.ts +3 -1
- package/dist/components/anchor/Anchor.js +1 -1
- package/dist/components/animate-counter/AnimateCounter.d.ts +11 -4
- package/dist/components/animate-counter/AnimateCounter.js +1 -1
- package/dist/components/animate-scramble/AnimateScramble.d.ts +6 -3
- package/dist/components/animate-scramble/AnimateScramble.js +1 -1
- package/dist/components/animate-split/AnimateSplit.d.ts +6 -3
- package/dist/components/animate-split/AnimateSplit.js +1 -1
- package/dist/components/animate-typing/AnimateTyping.js +1 -1
- package/dist/components/app-logo/AppLogo.js +1 -1
- package/dist/components/approval/Approval.js +1 -1
- package/dist/components/avatar/Avatar.js +1 -1
- package/dist/components/bar-chart/BarChart.js +1 -1
- package/dist/components/bottom-navigation/BottomNavigation.js +1 -1
- package/dist/components/box/Box.js +1 -1
- package/dist/components/breadcrumb/Breadcrumb.d.ts +3 -3
- package/dist/components/breadcrumb/Breadcrumb.js +1 -1
- package/dist/components/card/Card.js +1 -1
- package/dist/components/chat-bubble/ChatBubble.js +1 -1
- package/dist/components/chip/Chip.d.ts +4 -1
- package/dist/components/chip/Chip.js +1 -1
- package/dist/components/code-block/CodeBlock.js +1 -1
- package/dist/components/collapsible/Collapsible.js +1 -1
- package/dist/components/color-picker/ColorPicker.d.ts +3 -1
- package/dist/components/color-picker/ColorPicker.js +1 -1
- package/dist/components/combobox/Combobox.js +1 -1
- package/dist/components/command-palette/CommandPalette.js +1 -1
- package/dist/components/confirm/Confirm.js +1 -1
- package/dist/components/context-window/ContextWindow.d.ts +4 -1
- package/dist/components/context-window/ContextWindow.js +1 -1
- package/dist/components/data-list/DataList.d.ts +3 -2
- package/dist/components/data-list/DataList.js +1 -1
- package/dist/components/data-table/DataTable.d.ts +11 -5
- package/dist/components/data-table/DataTable.js +1 -1
- package/dist/components/date-range-picker/DateRangePicker.d.ts +3 -2
- package/dist/components/date-range-picker/DateRangePicker.js +1 -1
- package/dist/components/dialog/Dialog.js +1 -1
- package/dist/components/drawer/Drawer.js +1 -1
- package/dist/components/fieldset/Fieldset.js +1 -1
- package/dist/components/file-picker/FilePicker.d.ts +4 -0
- package/dist/components/file-picker/FilePicker.js +1 -1
- package/dist/components/footer/Footer.d.ts +4 -2
- package/dist/components/form/Form.d.ts +0 -14
- package/dist/components/form/Form.js +1 -1
- package/dist/components/gallery/Gallery.js +1 -1
- package/dist/components/gallery/GalleryViewer.js +1 -1
- package/dist/components/header/Header.d.ts +4 -3
- package/dist/components/heatmap-chart/HeatmapChart.js +1 -1
- package/dist/components/hover-card/HoverCard.d.ts +1 -1
- package/dist/components/how-to-steps/HowToSteps.d.ts +2 -1
- package/dist/components/how-to-steps/HowToSteps.js +1 -1
- package/dist/components/image/Image.d.ts +4 -1
- package/dist/components/image/Image.js +1 -1
- package/dist/components/inline-citation/InlineCitation.d.ts +4 -2
- package/dist/components/inline-citation/InlineCitation.js +1 -1
- package/dist/components/menu/Menu.d.ts +6 -2
- package/dist/components/menu/Menu.js +1 -1
- package/dist/components/mockup/Mockup.js +1 -1
- package/dist/components/navigation-menu/NavigationMenu.d.ts +1 -1
- package/dist/components/navigation-menu/NavigationMenu.js +1 -1
- package/dist/components/number-field/NumberField.js +1 -1
- package/dist/components/overlay/Overlay.d.ts +1 -1
- package/dist/components/page-layout/PageLayout.js +1 -1
- package/dist/components/pagination/Pagination.d.ts +3 -2
- package/dist/components/panes/Panes.js +1 -1
- package/dist/components/pie-chart/PieChart.js +1 -1
- package/dist/components/pill/Pill.js +1 -1
- package/dist/components/popover/Popover.js +1 -1
- package/dist/components/progress-box/ProgressBox.js +1 -1
- package/dist/components/prompt-input/PromptInput.d.ts +5 -3
- package/dist/components/prompt-input/PromptInput.js +1 -1
- package/dist/components/radio-group/RadioGroup.js +1 -1
- package/dist/components/rating/Rating.js +1 -1
- package/dist/components/reasoning/Reasoning.d.ts +7 -4
- package/dist/components/reasoning/Reasoning.js +1 -1
- package/dist/components/scatter-chart/ScatterChart.d.ts +7 -1
- package/dist/components/scatter-chart/ScatterChart.js +1 -1
- package/dist/components/scroll-area/ScrollArea.d.ts +12 -0
- package/dist/components/scroll-area/ScrollArea.js +1 -1
- package/dist/components/scroll-zone/ScrollZone.js +1 -1
- package/dist/components/segmented-button/SegmentedButton.js +1 -1
- package/dist/components/select/Select.d.ts +2 -1
- package/dist/components/select/Select.js +1 -1
- package/dist/components/sidebar/Sidebar.js +1 -1
- package/dist/components/sidebar/SidebarTrigger.js +1 -1
- package/dist/components/skeleton/Skeleton.js +1 -1
- package/dist/components/sources/Sources.d.ts +1 -1
- package/dist/components/sources/Sources.js +1 -1
- package/dist/components/stack/Stack.js +1 -1
- package/dist/components/streaming-text/StreamingText.js +1 -1
- package/dist/components/switch/Switch.d.ts +13 -2
- package/dist/components/switch/Switch.js +1 -1
- package/dist/components/switch/index.d.ts +1 -1
- package/dist/components/table/Table.d.ts +4 -2
- package/dist/components/tabs/Tabs.js +1 -1
- package/dist/components/text-field/TextField.js +1 -1
- package/dist/components/text-link/TextLink.js +1 -1
- package/dist/components/timeline-chart/TimelineChart.d.ts +6 -1
- package/dist/components/timeline-chart/TimelineChart.js +1 -1
- package/dist/components/toggle/Toggle.js +1 -1
- package/dist/components/tool-call/ToolCall.js +1 -1
- package/dist/components/tour/Tour.js +1 -1
- package/dist/components/transfer/Transfer.js +1 -1
- package/dist/components/tree-select/TreeSelect.js +1 -1
- package/dist/components/tree-view/TreeView.js +1 -1
- package/dist/components/typography/Typography.js +1 -1
- package/dist/components/visually-hidden/VisuallyHidden.d.ts +2 -2
- package/dist/components/window-pane/WindowPane.js +1 -1
- package/dist/hooks/useElementSize.d.ts +6 -2
- package/dist/hooks/useElementSize.js +1 -1
- package/dist/hooks/useMediaQuery.d.ts +3 -2
- package/dist/hooks/useOnScreen.d.ts +2 -2
- package/dist/hooks/useShortcut.d.ts +11 -3
- package/dist/hooks/useShortcut.js +1 -1
- package/dist/internal/animate.d.ts +8 -0
- package/dist/internal/animate.js +1 -1
- package/dist/internal/calendar.js +1 -1
- package/dist/internal/chart-brush.d.ts +3 -1
- package/dist/internal/chart-brush.js +1 -1
- package/dist/internal/chart-frame.d.ts +28 -2
- package/dist/internal/chart-frame.js +1 -1
- package/dist/internal/chart-line.js +1 -1
- package/dist/internal/chart.d.ts +21 -0
- package/dist/internal/chart.js +1 -1
- package/dist/internal/drag.d.ts +15 -0
- package/dist/internal/drag.js +1 -1
- package/dist/internal/drop.d.ts +12 -8
- package/dist/internal/drop.js +1 -1
- package/dist/internal/highlight.js +1 -1
- package/dist/internal/i18n.d.ts +40 -4
- package/dist/internal/i18n.js +1 -1
- package/dist/internal/icons.d.ts +3 -0
- package/dist/internal/icons.js +1 -1
- package/dist/internal/link.d.ts +27 -0
- package/dist/internal/link.js +1 -1
- package/dist/internal/new-tab.d.ts +21 -0
- package/dist/internal/new-tab.js +1 -0
- package/dist/internal/notch.d.ts +23 -1
- package/dist/internal/notch.js +1 -1
- package/dist/internal/observe.d.ts +3 -4
- package/dist/internal/picker.d.ts +21 -3
- package/dist/internal/picker.js +1 -1
- package/dist/internal/run.d.ts +7 -5
- package/dist/internal/run.js +1 -1
- package/dist/internal/search.d.ts +3 -3
- package/dist/internal/styles.d.ts +33 -1
- package/dist/internal/styles.js +1 -1
- package/dist/locales/ar.js +1 -1
- package/dist/locales/de.js +1 -1
- package/dist/locales/es.js +1 -1
- package/dist/locales/fr.js +1 -1
- package/dist/locales/hi.js +1 -1
- package/dist/locales/id.js +1 -1
- package/dist/locales/it.js +1 -1
- package/dist/locales/ja.js +1 -1
- package/dist/locales/ko.js +1 -1
- package/dist/locales/nl.js +1 -1
- package/dist/locales/pl.js +1 -1
- package/dist/locales/pt.js +1 -1
- package/dist/locales/ru.js +1 -1
- package/dist/locales/th.js +1 -1
- package/dist/locales/tr.js +1 -1
- package/dist/locales/vi.js +1 -1
- package/dist/locales/zh-hans.js +1 -1
- package/dist/locales/zh-hant.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +31 -4
- package/package.json +9 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as
|
|
1
|
+
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as l from"react";import{Field as n}from"@base-ui/react/field";import{Input as r}from"@base-ui/react/input";import{fieldLight as a,fieldSpotlightSlot as s,glowClasses as i}from"../../internal/glow.js";import{SpinnerIcon as o}from"../../internal/icons.js";import{controlTextLeadingClasses as c,cx as m,disabledClasses as d,fieldFocusTransitionClasses as p,fieldHeightClasses as x,fieldReadOnlyClasses as f,fieldRestClasses as u,fieldRingClasses as b,fieldSheetClasses as h,fieldSheetDisabledClasses as g,fieldSheetReadOnlyClasses as y,gapClasses as $,hasContent as v,iconClasses as N,metaTextClasses as w,paddingXClasses as j,radiusClasses as z,readOnlyFilterClasses as k,stackGapClasses as D,surfaceSlots as C,transitionClasses as O}from"../../internal/styles.js";import{keyHandler as P}from"../../internal/keys.js";import{FieldNotch as R,NotchFrame as T,restEndOf as E}from"../../internal/notch.js";import{useStyleDefaults as F}from"../../internal/defaults.js";import{useFieldsetDisabled as I}from"../../internal/fieldset.js";const K={xs:`${$.xs} ${z.xs} ${c.xs}`,sm:`${$.sm} ${z.sm} ${c.sm}`,md:`${$.md} ${z.md} ${c.md}`,lg:`${$.lg} ${z.lg} ${c.lg}`,xl:`${$.xl} ${z.xl} ${c.xl}`},L={xs:"min-h-5.5 py-[3px]",sm:"min-h-6.5 py-[4px]",md:"min-h-8 py-[5px]",lg:"min-h-10 py-[8px]",xl:"min-h-12 py-[10px]"},W={xs:"3px",sm:"4px",md:"5px",lg:"8px",xl:"10px"},q={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"},A=["group relative flex w-full","[-webkit-tap-highlight-color:transparent]",O,p,N].join(" "),B=u,G=f;export const TextField=/*@__PURE__*/l.forwardRef(function TextField(c,p){const{variant:f="outline",size:u="md",color:$="primary",density:N="default",elevation:z=0,multiline:O=!1,rows:H=3,resize:J="vertical",label:M,labelPlacement:Q="top",description:S,error:U,invalid:V,startIcon:X,endIcon:Y,loading:Z=!1,fullWidth:_=!1,classNames:ee,shortcuts:te,onKeyDown:le,readOnly:ne=!1,disabled:re,type:ae="text",placeholder:se,className:ie,style:oe,...ce}=F(c,["size","density","variant","labelPlacement"]),me=I(re),de=!me&&!ne,pe=null!=U&&!1!==U&&""!==U,xe=V??pe,fe=xe?"danger":$,ue="top"!==Q&&v(M),be=ue&&"float"===Q&&!v(X),he=l.useRef(null),ge=l.useCallback(e=>{he.current=e,"function"==typeof p?p(e):p&&(p.current=e)},[p]),ye=m(A,K[u],O?`${L[u]} items-start`:`${x[u]} items-center`,j[N][u],ue?"":b,me?(ue?g:d)[f]:ne?ue?`${y[f]} ${k}`:G[f]:`${(ue?h:B)[f]} ${i}`,me?"":"cursor-text",ee?.shell),$e=m("neba-input min-w-0 flex-1 bg-transparent [font:inherit] text-inherit","[outline:none]","placeholder:text-(--neba-muted-fg)","caret-(--n-accent) selection:bg-(--n-soft-press)","disabled:cursor-not-allowed",O?`block ${q[J]}`:"self-stretch",be?"neba-float-control":"",ee?.control),ve="inline-flex h-[1lh] shrink-0 items-center text-(--neba-muted-fg) transition-[color] duration-(--neba-duration) group-focus-within:text-(--n-accent)",Ne=t("span",{className:ye,...a(de),onPointerDown:e=>{e.target!==e.currentTarget||me||(e.preventDefault(),he.current?.focus())},children:[X?e("span",{className:ve,children:X}):null,e(r,{ref:ge,className:$e,disabled:me,readOnly:ne,"aria-busy":Z||void 0,"data-loading":Z||void 0,placeholder:be?se||" ":se,...O?{render:e("textarea",{rows:H})}:{type:ae},...ce,onKeyDown:P(te,le)}),Z?e("span",{className:ve,children:e(o,{})}):Y?e("span",{className:ve,children:Y}):null,ue?e(R,{label:M,variant:f,disabled:me,readOnly:ne,rests:be,labelClassName:ee?.label}):null]});return t(n.Root,{disabled:me,invalid:xe,className:m("flex-col align-top",D[u],_?"flex w-full":"inline-flex",ie??""),style:{...C(fe,z),...de?s:void 0,...oe},children:[M&&!ue?e(n.Label,{className:m(w[u],"font-medium",me?"text-(--neba-disabled-fg)":"text-(--neba-fg)",ee?.label),children:M}):null,ue?e(T,{label:M,size:u,density:N,variant:f,firstLine:O?W[u]:void 0,rests:be,restEnd:E(u,Z||Y?[1.2]:[]),labelClassName:ee?.label,children:Ne}):Ne,S?e(n.Description,{className:m(w[u],"text-(--neba-muted-fg)",ee?.description),children:S}):null,e(n.Error,pe?{match:!0,className:m(w[u],"text-(--n-accent)",ee?.error),children:U}:{className:m(w[u],"text-(--n-accent)",ee?.error)})]})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as n,
|
|
1
|
+
"use client";import{jsx as n,jsxs as e,Fragment as r}from"react/jsx-runtime";import*as i from"react";import{useRender as a}from"@base-ui/react/use-render";import{linkMessages as t,useMessages as o}from"../../internal/i18n.js";import{ExternalLinkIcon as l,LinkIcon as s}from"../../internal/icons.js";import{opensElsewhere as c,safeHref as m,safeRel as u}from"../../internal/link.js";import{controlTextLeadingClasses as d,cx as p,focusRingClasses as b,srOnlyClasses as f}from"../../internal/styles.js";import{useStyleDefaults as k}from"../../internal/defaults.js";const v={always:"[&.neba-link]:underline",hover:"[&.neba-link]:no-underline [&.neba-link]:hover:underline",none:"[&.neba-link]:no-underline"},h=["neba-link","cursor-pointer","[&_svg]:pointer-events-none [&_svg]:inline [&_svg]:size-[0.95em] [&_svg]:shrink-0",["[transition-property:color,text-decoration-color]","[transition-duration:var(--neba-duration)]","[transition-timing-function:var(--neba-ease)]"].join(" "),b,"focus-visible:rounded-[0.25rem]"].join(" ");export const TextLink=/*@__PURE__*/i.forwardRef(function TextLink(i,b){const{href:g,underline:j="always",color:x,size:y,newTab:w=!1,icon:_,locale:N,render:T,className:z,style:C,children:L,...$}=k(i,["locale"]),F=o(t,N),R=_??w,q=!0===R?n(w?l:s,{}):R,A=p(h,y?d[y]:"",v[j],x?"[&.neba-link]:text-(--n-accent)":"[&.neba-link]:text-inherit",z??""),B={"--n-underline":"color-mix(in oklab, currentColor 45%, transparent)","--n-underline-hover":"currentColor","--n-ring":`var(--neba-${x??"primary"}-ring)`,...x?{"--n-accent":`var(--neba-${x}-accent)`}:null},{rel:D,target:E,...G}=$,H=w?"_blank":E,I=u(H,D),J=c(H);return a({render:T??n("a",{}),ref:b,props:{href:m(g),target:H,className:A,style:{...B,...C},children:e(r,{children:[L,q?n("span",{className:"ms-[0.25em]",children:q}):null,J?e("span",{className:f,children:[" ",F.newTab]}):null]}),...G,rel:I}})});
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type CartesianChartProps } from '../../internal/chart-frame.js';
|
|
3
3
|
import type { NebaChartCategory, NebaTimelineSeries } from '../../types.js';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* `brush` is left out because a timeline cannot honour it: the window is cut
|
|
6
|
+
* by row, and every span on a row outside it would still be drawn past the
|
|
7
|
+
* plot. `secondaryAxis` goes with it — there is one axis of time.
|
|
8
|
+
*/
|
|
9
|
+
export interface TimelineChartProps extends Omit<CartesianChartProps, 'series' | 'categories' | 'legend' | 'brush' | 'secondaryAxis'> {
|
|
5
10
|
/**
|
|
6
11
|
* One row per series, and the spans on it. A row's name is what the axis
|
|
7
12
|
* says down the left-hand side.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as
|
|
1
|
+
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{CartesianChart as o,markTransitionClasses as r}from"../../internal/chart-frame.js";import{barBandRatio as a,barMaxThickness as s,barRadius as l,formatTimeTicks as i,formatTimeValue as c,markGap as m,resolveColor as u,seriesColor as d,timeScale as f,toNumber as h}from"../../internal/chart.js";import{chartMessages as x,useMessages as p}from"../../internal/i18n.js";import{srOnlyClasses as M}from"../../internal/styles.js";import{useStyleDefaults as b}from"../../internal/defaults.js";export function TimelineChart(t){const{series:r,min:l,max:u,barSize:M,rounded:j=!0,size:$="md",density:C="default",xAxis:T,yAxis:z,locale:A,references:D,...E}=b(t,["size","density","locale"]),P=n.useMemo(()=>r.map(y),[r]),S=n.useMemo(()=>P.map(e=>e.spans),[P]),B=n.useMemo(()=>{let e=1/0,t=-1/0,n=!1;for(const o of S)for(const r of o)r&&(n=!0,e=Math.min(e,r.from),t=Math.max(t,r.to));for(const o of D??[])if("value"===(o.axis??"value"))for(const r of void 0===o.to?[o.value]:[o.value,o.to])n=!0,e=Math.min(e,r),t=Math.max(t,r);return n?{min:e,max:t}:null},[S,D]),F=n.useMemo(()=>f(B,{min:h(l)??void 0,max:h(u)??void 0,tickCount:z?.tickCount}),[B,l,u,z?.tickCount]),I=n.useMemo(()=>i(F.ticks,F.unit,A),[F,A]),N=n.useMemo(()=>r.map((e,t)=>d(e,t)),[r]),R=n.useMemo(()=>[{data:S.map(e=>e.some(Boolean)?1:null)}],[S]),q=n.useMemo(()=>{const e=g(F.unit);return("day"===e||"week"===e)&&S.some(e=>e.some(e=>null!==e&&(v(e.from)||v(e.to))))},[S,F.unit]),Y=n.useMemo(()=>{let e=0,t=1/0,n=-1/0;for(const o of S)for(const r of o)r&&(e+=1,t=Math.min(t,r.from),n=Math.max(n,r.to));return 0===e?{count:e,min:"",max:""}:{count:e,min:c(t,g(F.unit),A,q),max:c(n,g(F.unit),A,q)}},[S,F.unit,A,q]),G=n.useMemo(()=>r.map((e,t)=>e.name??`${t+1}`),[r]),H=M??s[$],J=p(x,A),K=n.useCallback(e=>{const t=[];return P.forEach((n,o)=>{const r=Math.min(H,Math.max(1,(e.band.band-m*(n.lanes-1))/n.lanes)),a=r*n.lanes+m*(n.lanes-1),s=e.plot.top+e.categoryPx(o)-a/2+r/2;n.spans.forEach((n,a)=>{if(!n||n.to<e.scale.min||n.from>e.scale.max)return;const l=e.valuePx(n.from),i=e.valuePx(n.to);t.push({series:o,index:a,x:(l+i)/2,y:s+n.lane*(r+m),r:r/2,rx:Math.max(0,(i-l)/2),ry:r/2})})}),t},[P,H]),L=n.useCallback(e=>{const t=S[e.series]?.[e.index];if(!t)return null;const n=[{seriesIndex:e.series,name:G[e.series],color:t.color??N[e.series],value:t.to-t.from,formatted:`${c(t.from,g(F.unit),A,q)} – ${c(t.to,g(F.unit),A,q)}`}];return{heading:t.span.label??G[e.series],items:n}},[S,G,N,F.unit,A,q]);return e(o,{...E,series:R,categories:G,size:$,density:C,locale:A,horizontal:!0,scale:F,references:D,brush:void 0,secondaryAxis:void 0,xAxis:T,yAxis:{tickFormat:(e,t)=>I[t]??"",...z},legend:!1,bandRatio:a[C],marks:K,markTooltip:L,summary:Y,exportRows:()=>function(e,t,n,o,r){const a=t.some(e=>e.data.some(e=>void 0!==e.label));return[["string"==typeof o?o:"",...a?[r.title]:[],r.start,r.end],...n.flatMap((n,o)=>n.map((n,r)=>[e[o],...a?[k(t[o].data[r]?.label)]:[],n?new Date(n.from):null,n?new Date(n.to):null]))]}(G,r,S,T?.label,J),table:t=>e(w,{id:t,names:G,series:r,spans:S,unit:g(F.unit),clock:q,label:E.label,corner:T?.label,locale:A}),children:t=>e(Spans,{context:t,spans:S,colors:N,rounded:j})})}function y(e){const t=e.data.map(e=>{const t=h(e.start),n=h(e.end);return null===t||null===n?null:{from:Math.min(t,n),to:Math.max(t,n),lane:0,color:e.color?u(e.color):void 0,span:e}}),n=[];return t.map((e,t)=>({one:e,index:t})).filter(e=>Boolean(e.one)).sort((e,t)=>e.one.from-t.one.from).forEach(({one:e})=>{const t=n.findIndex(t=>t<=e.from),o=-1===t?n.length:t;n[o]=e.to,e.lane=o}),{spans:t,lanes:Math.max(1,n.length)}}function Spans({context:t,spans:n,colors:o,rounded:a}){const{marks:s,activeMark:i,plot:c}=t,m=a?l:0;return e("g",{children:s.map(t=>{const a=n[t.series]?.[t.index];if(!a)return null;const s=i?.series===t.series&&i?.index===t.index,l=t.rx??t.r,u=2*(t.ry??t.r),d=Math.max(c.left,t.x-l),f=Math.min(c.left+c.width,t.x+l);if(f<c.left||d>c.left+c.width)return null;const h=Math.max(1,f-d);return e("rect",{x:d,y:t.y-u/2,width:h,height:u,rx:Math.min(m,h/2,u/2),fill:a.color??o[t.series],opacity:s?1:.92,className:r},`${t.series}-${t.index}`)})})}function v(e){const t=new Date(e);return t.getTime()!==new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()}function g(e){return"month"===e||"quarter"===e||"year"===e?"day":e}const k=e=>"string"==typeof e||"number"==typeof e?e:null;const w=/*@__PURE__*/n.memo(function TimelineTable({id:n,names:o,series:r,spans:a,unit:s,clock:l,label:i,corner:m,locale:u}){const d=p(x,u),f=r.some(e=>e.data.some(e=>void 0!==e.label));return t("table",{id:n,className:M,children:[i?e("caption",{children:i}):null,e("thead",{children:t("tr",{children:[e("th",{scope:"col",children:m??""}),f?e("th",{scope:"col",children:d.title}):null,e("th",{scope:"col",children:d.start}),e("th",{scope:"col",children:d.end})]})}),e("tbody",{children:a.flatMap((n,a)=>n.map((n,i)=>t("tr",{children:[e("th",{scope:"row",children:o[a]}),f?e("td",{children:r[a].data[i]?.label??""}):null,e("td",{children:n?c(n.from,s,u,l):""}),e("td",{children:n?c(n.to,s,u,l):""})]},`${a}-${i}`)))})]})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsxs as e}from"react/jsx-runtime";import*as n from"react";import{Toggle as
|
|
1
|
+
"use client";import{jsxs as e}from"react/jsx-runtime";import*as n from"react";import{Toggle as o}from"@base-ui/react/toggle";import{ButtonGroupContext as t}from"../../internal/button-group.js";import{trackPointer as r}from"../../internal/glow.js";import{controlHeightClasses as a,controlSlots as s,controlSquareClasses as l,controlTextClasses as i,cx as d,disabledClasses as b,focusRingClasses as g,gapClasses as v,iconClasses as p,paddingXClasses as m,pressTransitionClasses as x,radiusClasses as c,surfaceClasses as f,transitionClasses as h}from"../../internal/styles.js";import{useStyleDefaults as u}from"../../internal/defaults.js";const $={xs:`${a.xs} ${v.xs} ${c.xs} ${i.xs}`,sm:`${a.sm} ${v.sm} ${c.sm} ${i.sm}`,md:`${a.md} ${v.md} ${c.md} ${i.md}`,lg:`${a.lg} ${v.lg} ${c.lg} ${i.lg}`,xl:`${a.xl} ${v.xl} ${c.xl} ${i.xl}`},j={xs:`${l.xs} px-0`,sm:`${l.sm} px-0`,md:`${l.md} px-0`,lg:`${l.lg} px-0`,xl:`${l.xl} px-0`},w=["neba-toggle relative inline-flex shrink-0 select-none items-center justify-center","whitespace-nowrap align-middle font-medium leading-none","[-webkit-tap-highlight-color:transparent] [touch-action:manipulation]",h,x,g,p].join(" "),y={solid:[f,"text-(--neba-muted-fg) bg-(--neba-panel-hover)","[box-shadow:var(--n-elev),var(--neba-plate-solid)]","hover:bg-(--neba-panel-press) hover:text-(--neba-fg)","active:bg-(--neba-panel-press)"].join(" "),outline:[f,"border text-(--neba-muted-fg) bg-(--neba-panel)","[border-color:var(--neba-border)]","[box-shadow:var(--n-elev),var(--neba-plate-glass)]","hover:bg-(--neba-panel-hover) hover:text-(--neba-fg)","active:bg-(--neba-panel-press)"].join(" "),text:["text-(--neba-muted-fg) bg-transparent","hover:bg-(--n-soft) hover:text-(--neba-fg)","active:bg-(--n-soft-hover)"].join(" ")},P={solid:[f,"text-(--n-on-solid) bg-(--n-fill)","[box-shadow:var(--n-elev),var(--neba-plate-solid)]","hover:bg-(--n-fill-hover)","active:bg-(--n-fill-active)"].join(" "),outline:[f,"border text-(--n-on-tint) bg-(--n-panel-press)","[border-color:var(--n-line-hover)]","[box-shadow:var(--n-elev),var(--neba-plate-glass)]","hover:[border-color:var(--n-accent)] hover:text-(--neba-fg)","active:[border-color:var(--n-accent)]"].join(" "),text:["text-(--n-on-tint) bg-(--n-soft-hover)","hover:bg-(--n-soft-press)","active:bg-(--n-soft-press)"].join(" ")};export const Toggle=/*@__PURE__*/n.forwardRef(function Toggle(a,l){const i=n.useContext(t),{variant:g,size:v,color:p,density:x,elevation:c,pressed:f,defaultPressed:h,onPressedChange:z,value:C,startIcon:T,endIcon:k,fullWidth:I=!1,disabled:M,className:N,style:R,children:W,onPointerMove:q,...A}=u(a,["size","density","variant"],i),B=g??i?.variant??"outline",D=v??i?.size??"md",E=p??i?.color??"primary",F=x??i?.density??"default",G=c??i?.elevation??0,H=M??i?.disabled??!1,J=null==W||!1===W;return e(o,{ref:l,value:C,pressed:f,defaultPressed:h,onPressedChange:e=>z?.(e),disabled:H,className:e=>d(w,$[D],J?j[D]:m[F][D],H?b[B]:e.pressed?P[B]:y[B],H?"":"neba-glow cursor-pointer",I?"w-full":"",N??""),style:{...s(E,G,B),...R},onPointerMove:r(q,!H),...A,children:[T,W,k]})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,Fragment as a,jsxs as n}from"react/jsx-runtime";import*as l from"react";import{Collapsible as
|
|
1
|
+
"use client";import{jsx as e,Fragment as a,jsxs as n}from"react/jsx-runtime";import*as l from"react";import{Collapsible as s}from"@base-ui/react/collapsible";import{boxPaddingXClasses as r,boxPaddingYClasses as t}from"../box/Box.js";import{ChevronIcon as o}from"../../internal/icons.js";import{formatDuration as i,runColor as c,runIcon as m,useElapsed as d}from"../../internal/run.js";import{runMessages as u,toolMessages as f,useMessages as p}from"../../internal/i18n.js";import{collapsiblePanelClasses as x,cx as b,gapClasses as h,hasContent as g,iconClasses as v,metaTextClasses as N,preformattedClasses as j,radiusClasses as w,sheetBodyClasses as y,sheetTitleClasses as k,srOnlyClasses as z,surfaceClasses as C,surfaceSlots as B,transitionClasses as O,disclosureChevronClasses as R,disclosureTriggerClasses as T}from"../../internal/styles.js";import{useStyleDefaults as _}from"../../internal/defaults.js";const E={solid:[C,"text-(--neba-fg) bg-(--n-panel-hover)","[box-shadow:var(--n-elev),var(--neba-plate-solid)]"].join(" "),outline:[C,"border text-(--neba-fg) bg-(--n-panel)","[border-color:var(--n-line)]","[box-shadow:var(--n-elev),var(--neba-plate-glass)]"].join(" "),text:"text-(--neba-fg) bg-transparent"},F=k;export const ToolCall=/*@__PURE__*/l.forwardRef(function ToolCall(j,k){const{variant:C="outline",size:P="md",color:S="primary",density:$="default",elevation:q=0,name:A,status:D="pending",args:G,result:H,error:I,duration:J,meta:K,icon:L,open:M,defaultOpen:Q=!1,onOpenChange:U,locale:V,labels:W,classNames:X,className:Y,style:Z,children:ee,...ae}=_(j,["size","density","variant","locale"]),ne=p(u,V),le=p(f,V),se={...ne,...le,...W},[re,te]=l.useState(Q),oe=void 0!==M,ie=oe?M:re,ce=l.useRef(D);l.useEffect(()=>{ce.current===D||"error"!==D||oe||te(!0),ce.current=D},[D,oe]);const me=d("running"===D,J),de=c(D,S),ue=void 0===L?m(D):L,fe=function(e,a,n){return"error"===e&&g(n)?n:a}(D,H,I),pe=g(G)||g(fe)||g(ee),xe=r[$][P],be=t[$][P],he=n(a,{children:[g(ue)?e("span",{className:"flex h-[1lh] shrink-0 items-center text-(--n-accent)",children:ue}):null,e("span",{className:b("min-w-0 truncate font-mono font-semibold",F[P]),children:A}),e("span",{className:z,children:se[D]}),g(K)?e("span",{className:b("min-w-0 truncate text-(--neba-muted-fg)",N[P]),children:K}):null,e("span",{className:"flex-1"}),null===me?null:e("span",{className:b("shrink-0 tabular-nums text-(--neba-muted-fg)",N[P]),children:i(me,V)})]}),ge=b("flex flex-col overflow-hidden",w[P],E[C],O,v,Y??""),ve={...B(de,q),...Z};return pe?n(s.Root,{ref:k,open:ie,onOpenChange:e=>{oe||te(e),U?.(e)},"data-status":D,className:ge,style:ve,...ae,children:[n(s.Trigger,{className:b("flex w-full cursor-pointer items-center text-start",T,xe,be,h[P],O,"hover:bg-(--n-soft)","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:[outline-offset:-2px]",X?.header??""),children:[he,e("span",{className:`${R} text-(--neba-muted-fg)`,children:e(o,{})})]}),e(s.Panel,{className:x,children:n("div",{className:b("flex min-w-0 flex-col gap-2 pb-4",xe,y[P],"compact"===$?"pb-2":"",X?.body??""),children:[g(G)?e(Block,{size:P,label:se.arguments,className:X?.args,value:G}):null,g(fe)?e(Block,{size:P,label:"error"===D&&g(I)?ne.error:se.result,className:X?.result,value:fe,accent:"error"===D}):null,ee]})})]}):e("div",{ref:k,"data-status":D,className:ge,style:ve,...ae,children:e("div",{className:b("flex items-center",xe,be,h[P],X?.header??""),children:he})})});function Block({size:a,label:l,value:s,className:r,accent:t=!1}){return n("div",{className:b("flex min-w-0 flex-col gap-1",r??""),children:[e("span",{className:b("font-medium tracking-wide text-(--neba-muted-fg) uppercase",N[a]),children:l}),"string"==typeof s?e("pre",{className:b(j,"max-h-64",t?"text-(--n-accent)":""),children:s}):e("div",{className:t?"text-(--n-accent)":void 0,children:s})]})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{Popover as s}from"@base-ui/react/popover";import{Button as i}from"../button/Button.js";import{boxPaddingXClasses as o,boxPaddingYClasses as l}from"../box/Box.js";import{actionMessages as
|
|
1
|
+
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{Popover as s}from"@base-ui/react/popover";import{Button as i}from"../button/Button.js";import{boxPaddingXClasses as o,boxPaddingYClasses as l}from"../box/Box.js";import{actionMessages as a,fillMessage as r,stepsMessages as c,useMessages as d}from"../../internal/i18n.js";import{CloseIcon as m}from"../../internal/icons.js";import{queryMatches as p,reducedMotionQuery as u}from"../../internal/media.js";import{observeResize as h}from"../../internal/observe.js";import{cx as f,hasContent as g,metaTextClasses as x,popupFadeClasses as b,radiusClasses as v,sheetBodyClasses as w,sheetCloseClasses as N,sheetHeaderGapClasses as k,sheetSectionGapClasses as y,sheetTitleClasses as j,srOnlyClasses as S,surfaceClasses as z,surfaceSlots as L}from"../../internal/styles.js";import{useStyleDefaults as C}from"../../internal/defaults.js";const E=[z,"relative flex flex-col","border text-(--neba-fg) bg-(--n-panel-press)","[border-color:var(--n-line)]","[box-shadow:var(--neba-shadow-3),var(--neba-plate-glass)]","[outline:none]",b].join(" "),M={xs:"max-w-56",sm:"max-w-64",md:"max-w-80",lg:"max-w-96",xl:"max-w-lg"},P={xs:"xs",sm:"xs",md:"sm",lg:"sm",xl:"md"};function O(e){try{return document.querySelector(e)}catch{return null}}function Mask({spot:t,radius:n,className:s}){return e("div",null===t?{"aria-hidden":"true",className:f("pointer-events-none fixed inset-0 z-40 bg-(--neba-scrim)",s)}:{"aria-hidden":"true",className:f("pointer-events-none fixed z-40 [box-shadow:0_0_0_9999px_var(--neba-scrim)]",s),style:{top:t.top,left:t.left,width:t.width,height:t.height,borderRadius:n}})}export function Tour(b){const{steps:z,open:_,defaultOpen:B=!1,onOpenChange:F,step:R,defaultStep:T=0,onStepChange:q,onFinish:A,mask:I=!0,skippable:V=!0,dismissible:$=!0,scrollIntoView:D=!0,locale:H,previousLabel:G,nextLabel:J,doneLabel:K,skipLabel:Q,closeLabel:U,size:W="md",color:X="primary",density:Y="default",className:Z,classNames:ee}=C(b,["size","density","locale"]),te=d(c,H),ne=d(a,H),[se,ie]=n.useState(B),[oe,le]=n.useState(T),ae=_??se,re=Math.min(R??oe,Math.max(0,z.length-1)),ce=z[re],[de,me]=n.useState(null),pe=e=>{void 0===_&&ie(e),F?.(e)},ue=e=>{void 0===R&&le(e),q?.(e)},[he,fe]=n.useState(null);if(n.useLayoutEffect(()=>{const e=ce?.target;fe(ae&&e?O(e):null)},[ae,ce?.target]),n.useEffect(()=>{const e=ce?.target;if(!ae||!e)return;const t=O(e);if(!(t instanceof HTMLElement))return;D&&t.scrollIntoView({block:"center",inline:"nearest",behavior:p(u)?"auto":"smooth"});const n=ce?.padding??6;let s=0;const i=()=>{s=0;const i=t.getBoundingClientRect(),o={top:i.top-n,left:i.left-n,width:i.width+2*n,height:i.height+2*n};me(t=>t?.selector===e&&t.spot.top===o.top&&t.spot.left===o.left&&t.spot.width===o.width&&t.spot.height===o.height?t:{selector:e,spot:o})},o=()=>{0===s&&(s=requestAnimationFrame(i))};i();const l=h(t,o);return window.addEventListener("scroll",o,{passive:!0,capture:!0}),window.addEventListener("resize",o,{passive:!0}),()=>{0!==s&&cancelAnimationFrame(s),l(),window.removeEventListener("scroll",o,!0),window.removeEventListener("resize",o)}},[ae,ce?.target,ce?.padding,D]),0===z.length)return null;const ge=ae&&ce?.target&&de?.selector===ce.target?de.spot:null,xe=0===re,be=re===z.length-1,ve=o[Y][W],we=l[Y][W],Ne=P[W],ke=g(ce?.title)||g(ce?.content);return e(s.Root,{open:ae,onOpenChange:(e,t)=>{(e||$||"escape-key"!==t.reason)&&(e||"outside-press"!==t.reason&&"focus-out"!==t.reason)?pe(e):t.cancel()},children:t(s.Portal,{children:[ae&&I?e(Mask,{spot:ge,radius:ge?8:0,className:ee?.mask}):null,e(s.Positioner,{className:"neba-portal z-(--neba-z-portal) [outline:none]",side:ce?.side??"bottom",align:ce?.align??"center",sideOffset:10,collisionPadding:12,anchor:he,children:t(s.Popup,{className:f(E,v[W],w[W],y[W],M[W],ve,we,Z),style:L(X,3),children:[e("span",{className:S,"aria-live":"polite",children:"string"==typeof ce?.title?r(te.step,{index:String(re+1),title:ce.title}):r(te.position,{index:String(re+1),total:String(z.length)})}),ke?t("div",{className:"flex items-start gap-3",children:[t("div",{className:`flex min-w-0 flex-1 flex-col ${k[W]}`,children:[g(ce?.title)?e(s.Title,{className:f("m-0 font-semibold",j[W],ee?.title),children:ce?.title}):null,g(ce?.content)?e(s.Description,{className:f("m-0 min-w-0",ee?.description),children:ce?.content}):null]}),$?e("button",{type:"button","aria-label":U??ne.close,onClick:()=>pe(!1),className:f(N,ee?.close),children:e(m,{})}):null]}):null,t("div",{className:f("flex items-center gap-2",ee?.footer),children:[e("span",{className:`shrink-0 tabular-nums text-(--neba-muted-fg) ${x[W]}`,children:r(te.position,{index:String(re+1),total:String(z.length)})}),t("div",{className:"ms-auto flex items-center gap-2",children:[V&&!be?e(i,{size:Ne,variant:"text",color:"secondary",onClick:()=>pe(!1),children:Q??te.skip}):null,xe?null:e(i,{size:Ne,variant:"outline",color:X,onClick:()=>ue(re-1),children:G??te.previous}),e(i,{size:Ne,color:X,onClick:()=>be?(A?.(),void pe(!1)):ue(re+1),children:be?K??te.done:J??te.next})]})]})]})})]})})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as l from"react";import{Checkbox as t}from"../checkbox/Checkbox.js";import{IconButton as s}from"../icon-button/IconButton.js";import{ScrollArea as r}from"../scroll-area/ScrollArea.js";import{TextField as
|
|
1
|
+
"use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as l from"react";import{Checkbox as t}from"../checkbox/Checkbox.js";import{IconButton as s}from"../icon-button/IconButton.js";import{ScrollArea as r}from"../scroll-area/ScrollArea.js";import{TextField as n}from"../text-field/TextField.js";import{fillMessage as i,transferMessages as o,useMessages as c}from"../../internal/i18n.js";import{ArrowRightIcon as d}from"../../internal/icons.js";import{searchText as u}from"../../internal/search.js";import{cx as m,fieldRestClasses as h,hasContent as f,metaTextClasses as b,paddingXClasses as p,radiusClasses as v,srOnlyClasses as g,surfaceSlots as x,toLength as y}from"../../internal/styles.js";import{useStyleDefaults as S}from"../../internal/defaults.js";const k={xs:"py-1",sm:"py-1.5",md:"py-2",lg:"py-2.5",xl:"py-3"},w={xs:"py-0.5",sm:"py-1",md:"py-1",lg:"py-1.5",xl:"py-2"};function Panel({title:s,rows:i,arrived:o,ticked:c,onTick:d,onTickAll:u,search:f,onSearch:g,searchable:y,disabled:S,height:N,emptyMessage:j,searchLabel:T,selectAllLabel:z,style:M}){const{size:$,variant:A="outline",color:C="primary",density:L="default"}=M,_=i.filter(e=>!e.disabled),P=_.filter(e=>c.has(e.value)),W=_.length>0&&P.length===_.length,D=P.length>0&&!W,I=p[L][$],R=l.useId();return a("div",{role:"group","aria-labelledby":R,className:["flex min-w-0 flex-col overflow-hidden",h[A],v[$]].join(" "),style:x(C,0),children:[a("div",{className:`flex items-center gap-2 border-b [border-color:var(--neba-border)] ${I} ${k[$]}`,children:[e(t,{size:$,color:C,checked:W,indeterminate:D,disabled:S||0===_.length,"aria-label":z,onCheckedChange:e=>u(!0===e)}),e("span",{id:R,className:`min-w-0 flex-1 truncate font-medium ${b[$]}`,children:s}),a("span",{className:`shrink-0 tabular-nums text-(--neba-muted-fg) ${b[$]}`,children:[P.length,"/",i.length]})]}),y?e("div",{className:`${I} ${k[$]}`,children:e(n,{size:$,color:C,density:L,fullWidth:!0,variant:"text",disabled:S,placeholder:T,"aria-label":T,value:f,onChange:e=>g(e.target.value)})}):null,e(r,{size:$,color:C,height:N,fade:!0,children:e("div",{className:`flex flex-col ${I} ${k[$]}`,children:0===i.length?e("span",{className:`text-(--neba-muted-fg) ${b[$]} ${w[$]}`,children:j}):i.map(a=>e(t,{size:$,color:C,className:m(w[$],o.has(a.value)?"[animation:neba-anim-fade_var(--neba-duration-fill)_var(--neba-ease)_both]":""),label:a.label,checked:c.has(a.value),disabled:S||a.disabled,onCheckedChange:e=>d(a.value,!0===e)},a.value))})})]})}function N(e,a,l){const t=u(a);return""===t?e:e.filter(e=>{const a=l.get(e.value);return void 0===a||a.includes(t)})}export const Transfer=/*@__PURE__*/l.forwardRef(function Transfer(t,r){const{items:n,value:h,defaultValue:b,onValueChange:p,sourceLabel:v,targetLabel:x,searchable:k=!1,height:w=220,disabled:j=!1,locale:T,variant:z="outline",size:M="md",color:$="primary",density:A="default",className:C,...L}=S(t,["size","density","variant","locale"]),_=c(o,T),[P,W]=l.useState(b??[]),D=h??P,[I,R]=l.useState(()=>new Set),[V,B]=l.useState(()=>new Set),[E,F]=l.useState(""),[q,G]=l.useState(""),[H,J]=l.useState(""),K=l.useRef(void 0);l.useEffect(()=>()=>clearTimeout(K.current),[]);const O=l.useMemo(()=>new Set(D),[D]),Q=l.useMemo(()=>n.filter(e=>!O.has(e.value)),[n,O]),U=l.useMemo(()=>n.filter(e=>O.has(e.value)),[n,O]),X=(e,a)=>{R(l=>{const t=new Set(l);return a?t.add(e):t.delete(e),t})},Y=(e,a)=>{R(l=>{const t=new Set(l);for(const l of e)l.disabled||(a?t.add(l.value):t.delete(l.value));return t})},Z=(e,a)=>{const l=e.filter(e=>!e.disabled&&I.has(e.value));if(0===l.length)return;const t=new Set(l.map(e=>e.value)),s=new Set(n.map(e=>e.value)),r=D.filter(e=>!s.has(e)),o=a?[...n.filter(e=>O.has(e.value)||t.has(e.value)).map(e=>e.value),...r]:D.filter(e=>!t.has(e));R(e=>new Set([...e].filter(e=>!t.has(e)))),B(t),(e=>{void 0===h&&W(e),p?.(e)})(o);const c=a?x:v,d=i(_.moved,{count:String(l.length),list:"string"==typeof c&&c.trim()?c:a?_.target:_.source});clearTimeout(K.current),J(""),K.current=setTimeout(()=>J(d),100)},ee=l.useMemo(()=>function(e){const a=new Map;for(const l of e)"string"==typeof l.label&&a.set(l.value,u(l.label));return a}(n),[n]),ae=l.useMemo(()=>N(Q,E,ee),[Q,E,ee]),le=l.useMemo(()=>N(U,q,ee),[U,q,ee]),te=ae.some(e=>!e.disabled&&I.has(e.value)),se=le.some(e=>!e.disabled&&I.has(e.value)),re=y(w),ne={variant:z,size:M,color:$,density:A};return a("div",{ref:r,className:m("grid w-full items-center gap-3","[grid-template-columns:minmax(0,1fr)_auto_minmax(0,1fr)]",C??""),...L,children:[e(Panel,{title:f(v)?v:_.source,rows:ae,arrived:V,ticked:I,onTick:X,onTickAll:e=>Y(ae,e),search:E,onSearch:F,searchable:k,disabled:j,height:re,emptyMessage:_.empty,searchLabel:_.search,selectAllLabel:_.selectAll,style:ne}),a("div",{className:"flex flex-col gap-2",children:[e(s,{size:M,color:$,variant:"text"===z?"text":"outline",label:_.toTarget,disabled:j||!te,focusableWhenDisabled:!j,onClick:()=>Z(ae,!0),icon:e("span",{className:"flex rtl:rotate-180",children:e(d,{})})}),e(s,{size:M,color:$,variant:"text"===z?"text":"outline",label:_.toSource,disabled:j||!se,focusableWhenDisabled:!j,onClick:()=>Z(le,!1),icon:e("span",{className:"flex rotate-180 rtl:rotate-0",children:e(d,{})})})]}),e(Panel,{title:f(x)?x:_.target,rows:le,arrived:V,ticked:I,onTick:X,onTickAll:e=>Y(le,e),search:q,onSearch:G,searchable:k,disabled:j,height:re,emptyMessage:_.empty,searchLabel:_.search,selectAllLabel:_.selectAll,style:ne}),e("span",{role:"status",className:g,children:H})]})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as a from"react";import{TreeItem as n,TreeView as r}from"../tree-view/TreeView.js";import{PickerShell as t}from"../../internal/picker.js";import{searchHaystack as
|
|
1
|
+
"use client";import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as a from"react";import{TreeItem as n,TreeView as r}from"../tree-view/TreeView.js";import{PickerShell as t}from"../../internal/picker.js";import{searchHaystack as i,searchText as o}from"../../internal/search.js";import{actionMessages as s,commandMessages as c,comboboxMessages as d,useMessages as u}from"../../internal/i18n.js";import{useStyleDefaults as p}from"../../internal/defaults.js";function h(e,l=new Map){for(const a of e)l.set(a.value,a),a.children&&h(a.children,l);return l}function m(e,l=new Map){for(const a of e)l.set(a,i([a.searchLabel??("string"==typeof a.label?a.label:String(a.value))])),a.children&&m(a.children,l);return l}function f(e,l,a){if(""===l)return e;const n=[];for(const r of e){const e=r.children?f(r.children,l,a):void 0,t=(a.get(r)??"").includes(l);(t||e&&e.length>0)&&n.push({...r,children:t?r.children:e})}return n}function g(e,l=[]){for(const a of e)a.children&&a.children.length>0&&(l.push(a.value),g(a.children,l));return l}export const TreeSelect=/*@__PURE__*/a.forwardRef(function TreeSelect(i,b){const{items:v=[],value:x,defaultValue:y,onValueChange:S,multiple:w=!1,selectableBranches:C=!1,defaultExpanded:j,expanded:N,onExpandedChange:M,open:O,defaultOpen:z,onOpenChange:T,placeholder:V,clearable:E=!1,clearLabel:L,closeOnSelect:k,searchable:A=!1,searchPlaceholder:I,locale:P,format:R,name:B,size:F="md",color:$="primary",readOnly:q=!1,disabled:D=!1,classNames:G,...H}=p(i,["size","density","variant","locale","labelPlacement"]),J=u(d,P),K=u(c,P),Q=u(s,P),U=e=>null==e?[]:Array.isArray(e)?e:[e],[W,X]=a.useState(()=>U(y)),Y=void 0!==x?U(x):W,[Z,_]=a.useState(z??!1),ee=O??Z,[le,ae]=a.useState(""),ne=a.useMemo(()=>h(v),[v]),re=a.useMemo(()=>m(v),[v]),te=o(le),ie=a.useMemo(()=>f(v,te,re),[v,te,re]),oe=a.useMemo(()=>""===te?void 0:g(ie),[te,ie]),[se,ce]=a.useState(()=>j??[]),de=oe??N??se,ue=e=>{e&&(q||D)||(void 0===O&&_(e),e||ae(""),T?.(e))},pe=e=>{void 0===x&&X(e),S?.(e)},he=e=>e.selectable??(!(e.children&&e.children.length>0)||C),me=Y.map(e=>ne.get(e)).filter(e=>void 0!==e),fe=0===me.length?V??"":R?R(me):me.map(e=>e.label).reduce((e,l,a)=>0===a?[l]:[...e,", ",l],[]),ge=l=>l.map(l=>e(n,{value:l.value,label:l.label,startIcon:l.startIcon,disabled:l.disabled,selectable:he(l),className:G?.item,children:l.children?ge(l.children):null},l.value));return e(t,{...H,size:F,color:$,readOnly:q,disabled:D,triggerRef:b,display:fe,empty:0===me.length,clearable:E,onClear:()=>pe([]),open:ee,onOpenChange:ue,clearLabel:L??Q.clear,popupClassName:G?.popup,initialFocus:!0,hiddenValues:B?Y.map(e=>({name:B,value:String(e)})):void 0,repeats:w,children:l("div",{className:"flex max-h-80 w-64 flex-col gap-2 overflow-hidden",children:[A?e("input",{type:"text",value:le,placeholder:I??K.search,"aria-label":I??K.search,onChange:e=>ae(e.currentTarget.value),className:"neba-input w-full shrink-0 bg-transparent px-1 py-1 [font:inherit] text-(--neba-fg) [outline:none] placeholder:text-(--neba-muted-fg)"}):null,e("div",{className:"min-h-0 flex-1 overflow-auto",children:0===ie.length?e("p",{className:`px-1 py-2 text-(--neba-muted-fg) ${G?.empty??""}`,children:J.empty}):e(r,{size:F,color:$,multiple:w,selected:Y,onSelectedChange:e=>{const l=e.filter(e=>{const l=ne.get(e);return void 0!==l&&he(l)&&!l.disabled});pe(w?l:l.slice(-1)),(k??!w)&&ue(!1)},expanded:de,onExpandedChange:oe?()=>{}:e=>{void 0===N&&ce(e),M?.(e)},className:G?.tree,children:ge(ie)})})]})})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,Fragment as t,jsxs as n}from"react/jsx-runtime";import*as r from"react";import{
|
|
1
|
+
"use client";import{jsx as e,Fragment as t,jsxs as n}from"react/jsx-runtime";import*as r from"react";import{inertValue as a}from"../../internal/inert.js";import{safeHref as l}from"../../internal/link.js";import{searchText as s}from"../../internal/search.js";import{ChevronIcon as o}from"../../internal/icons.js";import{controlTextClasses as i,cx as d,gapClasses as c,hasContent as u,iconClasses as m,radiusClasses as f,surfaceClasses as p,surfaceSlots as g,transitionClasses as x}from"../../internal/styles.js";import{useStyleDefaults as b}from"../../internal/defaults.js";const h=/*@__PURE__*/r.createContext({size:"md",density:"default",disabled:!1,multiple:!1,expandedKeys:new Set,selectedKeys:new Set,activeKey:null,toggle:()=>{},select:()=>{},activate:()=>{},register:()=>()=>{}}),v=/*@__PURE__*/r.createContext(!1),y={solid:[p,"text-(--neba-fg) bg-(--n-panel-hover)","[box-shadow:var(--n-elev),var(--neba-plate-solid)]"].join(" "),outline:[p,"border text-(--neba-fg) bg-(--n-panel)","[border-color:var(--n-line)]","[box-shadow:var(--n-elev),var(--neba-plate-glass)]"].join(" "),text:"text-(--neba-fg) bg-transparent"},w={xs:"0.875rem",sm:"1rem",md:"1.25rem",lg:"1.5rem",xl:"1.75rem"},k={xs:"1.375rem",sm:"1.625rem",md:"2rem",lg:"2.5rem",xl:"3rem"},C={default:{xs:"px-1.5",sm:"px-2",md:"px-2.5",lg:"px-3",xl:"px-3.5"},compact:{xs:"px-1",sm:"px-1",md:"px-1.5",lg:"px-2",xl:"px-2.5"}},S={xs:"rounded-[0.3125rem]",sm:"rounded-[0.375rem]",md:"rounded-[0.5rem]",lg:"rounded-[0.625rem]",xl:"rounded-[0.75rem]"},E={none:"",simple:"neba-tree-simple",folder:"neba-tree-folder"};function N(e){return Array.from(e.querySelectorAll('[role="treeitem"]')).filter(e=>null===e.closest("[data-closing]"))}const j=e=>String(e);export const TreeView=/*@__PURE__*/r.forwardRef(function TreeView(t,n){const{variant:a="outline",size:l="md",color:o="primary",density:i="default",elevation:c=0,lines:u="simple",expanded:m,defaultExpanded:p,onExpandedChange:v,selected:C,defaultSelected:S,onSelectedChange:K,multiple:A=!1,disabled:V=!1,label:D,className:R,style:I,children:P,onKeyDown:T,..._}=b(t,["size","density","variant"]),[z,q]=r.useState(p??[]),[F,M]=r.useState(S??[]),[L,H]=r.useState(null),O=m??z,U=C??F,W=r.useRef(null),B=r.useCallback(e=>{W.current=e,"function"==typeof n?n(e):n&&(n.current=e)},[n]),G=r.useRef({expandedValues:O,selectedValues:U,controlledExpanded:void 0!==m,controlledSelected:void 0!==C,multiple:A,onExpandedChange:v,onSelectedChange:K});G.current={expandedValues:O,selectedValues:U,controlledExpanded:void 0!==m,controlledSelected:void 0!==C,multiple:A,onExpandedChange:v,onSelectedChange:K};const J=r.useCallback(e=>{const{expandedValues:t,controlledExpanded:n,onExpandedChange:r}=G.current,a=j(e),l=t.some(e=>j(e)===a)?t.filter(e=>j(e)!==a):[...t,e];n||q(l),r?.(l)},[]),Q=r.useCallback(e=>{const{selectedValues:t,controlledSelected:n,multiple:r,onSelectedChange:a}=G.current,l=j(e),s=t.some(e=>j(e)===l),o=r?s?t.filter(e=>j(e)!==l):[...t,e]:[e];n||M(o),a?.(o)},[]),X=r.useRef(new Map),Y=r.useCallback((e,t)=>(X.current.set(e,t),()=>{X.current.delete(e)}),[]),Z=r.useMemo(()=>O.map(j).join("\0"),[O]),$=r.useMemo(()=>U.map(j).join("\0"),[U]),ee=r.useMemo(()=>({size:l,density:i,disabled:V,multiple:A,expandedKeys:new Set(O.map(j)),selectedKeys:new Set(U.map(j)),activeKey:L,toggle:J,select:Q,activate:H,register:Y}),[l,i,V,A,Z,$,L,J,Q,Y]);r.useEffect(()=>{if(null!==L&&X.current.has(L))return;const e=W.current;if(!e)return;const t=N(e);if(0===t.length)return;const n=t.find(e=>"true"===e.getAttribute("aria-selected"))??t[0];H(n.dataset.nebaValue??null)});const te=d("flex list-none flex-col p-1",f[l],y[a],x,E[u],R);return e(h.Provider,{value:ee,children:e("ul",{ref:B,role:"tree","aria-label":D,"aria-multiselectable":A||void 0,className:te,style:{...g(o,c),"--n-tree-indent":w[l],"--n-tree-row":k[l],...I},onKeyDown:function(e){if(T?.(e),e.defaultPrevented)return;const t=W.current,n=e.target?.closest?.('[role="treeitem"]');if(!t||!n||!t.contains(n))return;if(e.target!==n)return;const r=N(t),a=r.indexOf(n);if(-1===a)return;const l=t=>{t&&(e.preventDefault(),H(t.dataset.nebaValue??null),t.focus())},o=e=>{const t=e.dataset.nebaValue;t&&X.current.get(t)?.toggle()},i="rtl"===getComputedStyle(t).direction,d=i?"ArrowLeft":"ArrowRight",c=i?"ArrowRight":"ArrowLeft",u=n.getAttribute("aria-expanded");switch(e.key){case"ArrowDown":l(r[a+1]);break;case"ArrowUp":l(r[a-1]);break;case"Home":l(r[0]);break;case"End":l(r[r.length-1]);break;case d:"false"===u?(e.preventDefault(),o(n)):"true"===u&&l(r[a+1]);break;case c:"true"===u?(e.preventDefault(),o(n)):l(n.parentElement?.closest('[role="treeitem"]'));break;case"Enter":case" ":e.preventDefault();(("Enter"===e.key?n.querySelector(":scope > div > a[href]"):null)??n).click();break;default:if(1===[...e.key].length&&" "!==e.key&&!e.ctrlKey&&!e.metaKey&&!e.altKey){const t=s(e.key);l([...r.slice(a+1),...r.slice(0,a)].find(e=>s(e.querySelector("[data-neba-label]")?.textContent??"").startsWith(t)))}}},..._,children:P})})});export const TreeItem=/*@__PURE__*/r.forwardRef(function TreeItem({value:s,label:f,startIcon:p,endIcon:g,action:b,href:y,expandable:w,disabled:k=!1,selectable:E=!0,className:N,children:K,onClick:A,...V},D){const{size:R,density:I,disabled:P,expandedKeys:T,selectedKeys:_,activeKey:z,toggle:q,select:F,activate:M,register:L,multiple:H}=r.useContext(h),O=r.useId(),U=s??O,W=j(U),B=r.useRef(null),G=r.useCallback(e=>{B.current=e,"function"==typeof D?D(e):D&&(D.current=e)},[D]),J=r.Children.toArray(K),Q=w??J.length>0,X=Q&&T.has(W),Y=_.has(W),Z=k||P,$=r.useRef({toggle:()=>{}});$.current.toggle=()=>{!Z&&Q&&q(U)};const ee=r.useContext(v);r.useEffect(()=>ee?void 0:L(W,$.current),[ee,W,L]);const[te,ne]=r.useState(X),[re,ae]=r.useState(X),le=r.useRef(null);r.useEffect(()=>{if(X){ne(!0);const e=requestAnimationFrame(()=>ae(!0));return()=>cancelAnimationFrame(e)}ae(!1);const e=le.current;(null===e||getComputedStyle(e).transitionDuration.split(",").every(e=>0===parseFloat(e)))&&ne(!1)},[X]);const se=d("flex min-w-0 flex-1 cursor-pointer items-center text-start","h-(--n-tree-row)",C[I][R],S[R],c[R],i[R],x,m,"group-focus-visible/tree-item:[outline:2px_solid_var(--n-ring)]","group-focus-visible/tree-item:outline-offset-[-2px]",Z?"cursor-not-allowed text-(--neba-disabled-fg)":Y?"bg-(--n-soft-press) font-medium text-(--n-on-tint) hover:bg-(--n-soft-press)":"hover:bg-(--n-soft)"),oe=n(t,{children:[e("span",{"aria-hidden":"true",onClick:e=>{!Z&&Q&&(e.stopPropagation(),e.preventDefault(),B.current?.focus(),M(W),q(U))},className:d("flex h-[1lh] w-[1.15em] shrink-0 items-center justify-center","[transition:rotate_var(--neba-duration)_var(--neba-ease)]",Q?"text-(--neba-muted-fg)":"",X?"rotate-0":"-rotate-90 rtl:rotate-90"),children:Q?e(o,{}):null}),u(p)?e("span",{className:"flex h-[1lh] shrink-0 items-center text-(--neba-muted-fg)",children:p}):null,e("span",{"data-neba-label":"",className:"min-w-0 flex-1 truncate",children:f}),u(g)?e("span",{className:"flex h-[1lh] shrink-0 items-center text-(--neba-muted-fg)",children:g}):null]});return n("li",{ref:G,role:"treeitem","aria-expanded":Q?X:void 0,"aria-selected":!!Y||(!H||!E)&&void 0,"aria-disabled":Z||void 0,"data-neba-value":W,tabIndex:z===W?0:-1,className:d("group/tree-item relative block [outline:none]",N),onClick:function(e){e.stopPropagation(),Z?e.preventDefault():(B.current?.focus(),M(W),A?.(e),e.defaultPrevented||(Q&&q(U),E&&F(U)))},...V,children:[n("div",{className:"flex w-full items-center",children:[void 0===l(y)||Z?e("div",{className:se,children:oe}):e("a",{href:l(y),tabIndex:-1,className:se,"aria-current":Y?"page":void 0,children:oe}),u(b)?e("span",{className:d("flex shrink-0 items-center",C[I][R]),onClick:e=>e.stopPropagation(),children:b}):null]}),Q&&te&&J.length>0?e("div",{ref:le,"data-closing":X?void 0:"",inert:a(!X),className:d("grid [transition:grid-template-rows_var(--neba-duration)_var(--neba-ease)]",re?"[grid-template-rows:1fr]":"[grid-template-rows:0fr] pointer-events-none"),onTransitionEnd:e=>{e.target!==e.currentTarget||"grid-template-rows"!==e.propertyName||X||ne(!1)},children:e("ul",{role:"group",className:"min-h-0 list-none overflow-hidden ps-(--n-tree-indent)",children:e(v.Provider,{value:ee||!X,children:K})})}):null]})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import*as e from"react";import{useRender as a}from"@base-ui/react/use-render";import{transitionProps as t}from"../../internal/animate.js";import{clampClasses as r,clampSlot as n,cx as p}from"../../internal/styles.js";const o={h1:"[&.neba-typography]:text-[1.875rem]/[1.2] [&.neba-typography]:tracking-[-0.02em]",h2:"[&.neba-typography]:text-[1.5rem]/[1.25] [&.neba-typography]:tracking-[-0.015em]",h3:"[&.neba-typography]:text-[1.25rem]/[1.3] [&.neba-typography]:tracking-[-0.01em]",h4:"[&.neba-typography]:text-[1.0625rem]/[1.41176] [&.neba-typography]:tracking-normal",h5:"[&.neba-typography]:text-[0.9375rem]/[1.46667] [&.neba-typography]:tracking-normal",h6:"[&.neba-typography]:text-[0.8125rem]/[1.53846] [&.neba-typography]:tracking-normal",lead:"[&.neba-typography]:text-[1.0625rem]/[1.64706] [&.neba-typography]:tracking-normal",body:"[&.neba-typography]:text-[0.8125rem]/[1.69231] [&.neba-typography]:tracking-normal",caption:"[&.neba-typography]:text-[0.75rem]/[1.5] [&.neba-typography]:tracking-normal",overline:"[&.neba-typography]:text-[0.6875rem]/[1.45455] [&.neba-typography]:tracking-[0.08em] uppercase"},y={h1:"semibold",h2:"semibold",h3:"semibold",h4:"semibold",h5:"semibold",h6:"semibold",lead:"regular",body:"regular",caption:"regular",overline:"medium"},h={h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",lead:"p",body:"p",caption:"span",overline:"span"},b=new Set(["caption","overline"]),m={h1:"[&.neba-typography]:mb-4",h2:"[&.neba-typography]:mb-3.5",h3:"[&.neba-typography]:mb-3",h4:"[&.neba-typography]:mb-2.5",h5:"[&.neba-typography]:mb-2",h6:"[&.neba-typography]:mb-2",lead:"[&.neba-typography]:mb-4",body:"[&.neba-typography]:mb-3",caption:"[&.neba-typography]:mb-2",overline:"[&.neba-typography]:mb-2"},g={regular:"[&.neba-typography]:font-normal",medium:"[&.neba-typography]:font-medium",semibold:"[&.neba-typography]:font-semibold",bold:"[&.neba-typography]:font-bold"},i={start:"text-start",center:"text-center",end:"text-end",justify:"text-justify"};export const Typography=/*@__PURE__*/e.forwardRef(function Typography({level:l="body",color:s,weight:c,align:d,lines:u,gutter:x=!1,transition:f,render:k,className:v,style:j,children:w,...N},T){const E=t(f),R=p("neba-typography",o[l],g[c??y[l]],d?i[d]:"","span"
|
|
1
|
+
"use client";import*as e from"react";import{useRender as a}from"@base-ui/react/use-render";import{transitionProps as t}from"../../internal/animate.js";import{clampClasses as r,clampSlot as n,cx as p}from"../../internal/styles.js";const o={h1:"[&.neba-typography]:text-[1.875rem]/[1.2] [&.neba-typography]:tracking-[-0.02em]",h2:"[&.neba-typography]:text-[1.5rem]/[1.25] [&.neba-typography]:tracking-[-0.015em]",h3:"[&.neba-typography]:text-[1.25rem]/[1.3] [&.neba-typography]:tracking-[-0.01em]",h4:"[&.neba-typography]:text-[1.0625rem]/[1.41176] [&.neba-typography]:tracking-normal",h5:"[&.neba-typography]:text-[0.9375rem]/[1.46667] [&.neba-typography]:tracking-normal",h6:"[&.neba-typography]:text-[0.8125rem]/[1.53846] [&.neba-typography]:tracking-normal",lead:"[&.neba-typography]:text-[1.0625rem]/[1.64706] [&.neba-typography]:tracking-normal",body:"[&.neba-typography]:text-[0.8125rem]/[1.69231] [&.neba-typography]:tracking-normal",caption:"[&.neba-typography]:text-[0.75rem]/[1.5] [&.neba-typography]:tracking-normal",overline:"[&.neba-typography]:text-[0.6875rem]/[1.45455] [&.neba-typography]:tracking-[0.08em] uppercase"},y={h1:"semibold",h2:"semibold",h3:"semibold",h4:"semibold",h5:"semibold",h6:"semibold",lead:"regular",body:"regular",caption:"regular",overline:"medium"},h={h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",lead:"p",body:"p",caption:"span",overline:"span"},b=new Set(["caption","overline"]),m={h1:"[&.neba-typography]:mb-4",h2:"[&.neba-typography]:mb-3.5",h3:"[&.neba-typography]:mb-3",h4:"[&.neba-typography]:mb-2.5",h5:"[&.neba-typography]:mb-2",h6:"[&.neba-typography]:mb-2",lead:"[&.neba-typography]:mb-4",body:"[&.neba-typography]:mb-3",caption:"[&.neba-typography]:mb-2",overline:"[&.neba-typography]:mb-2"},g={regular:"[&.neba-typography]:font-normal",medium:"[&.neba-typography]:font-medium",semibold:"[&.neba-typography]:font-semibold",bold:"[&.neba-typography]:font-bold"},i={start:"text-start",center:"text-center",end:"text-end",justify:"text-justify"};export const Typography=/*@__PURE__*/e.forwardRef(function Typography({level:l="body",color:s,weight:c,align:d,lines:u,gutter:x=!1,transition:f,render:k,className:v,style:j,children:w,...N},T){const E=t(f),R=p("neba-typography",o[l],g[c??y[l]],d?i[d]:"","span"!==h[l]||!d&&!x||void 0!==u&&u>1?"":"block",u?r(u):"",x?m[l]:"[&.neba-typography]:my-0",s?"[&.neba-typography]:text-(--n-accent)":b.has(l)?"[&.neba-typography]:text-(--neba-muted-fg)":"",E.className,v??"");return a({render:k??e.createElement(h[l]),ref:T,props:{className:R,style:s?{"--n-accent":`var(--neba-${s}-accent)`,...n(u),...E.style,...j}:{...n(u),...E.style,...j},children:w,...N}})});
|
|
@@ -17,8 +17,8 @@ export interface VisuallyHiddenProps extends React.ComponentPropsWithoutRef<'spa
|
|
|
17
17
|
* Content that is in the accessibility tree and not on the screen.
|
|
18
18
|
*
|
|
19
19
|
* The library has needed this everywhere from the beginning and kept it to
|
|
20
|
-
* itself: the word
|
|
21
|
-
* the page
|
|
20
|
+
* itself: the status word beside a ToolCall's mark, the count behind a
|
|
21
|
+
* Badge's dot, the page a Pagination announces, the table a chart draws for a
|
|
22
22
|
* screen reader instead of a picture. This is the same 1px clipped box, offered
|
|
23
23
|
* so an application's own markup can say the same things.
|
|
24
24
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import*as i from"react";import{useRender as o}from"@base-ui/react/use-render";import{beginPointerDrag as r}from"../../internal/drag.js";import{actionMessages as
|
|
1
|
+
"use client";import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import*as i from"react";import{useRender as o}from"@base-ui/react/use-render";import{beginPointerDrag as r,drawnScale as s}from"../../internal/drag.js";import{actionMessages as a,useMessages as l,windowMessages as d}from"../../internal/i18n.js";import{cx as c,hasContent as u,iconClasses as h,surfaceClasses as m}from"../../internal/styles.js";import{WindowControls as f,orderControls as g,windowChrome as w,windowMetrics as p,windowSlots as b}from"../../internal/window.js";import{inertValue as x}from"../../internal/inert.js";import{useStyleDefaults as v}from"../../internal/defaults.js";function y(e,t,n){const[o,r]=i.useState(t),s=void 0!==e;return[s?e:o,i.useCallback(e=>{s||r(e),n?.(e)},[s,n])]}const z=[{edge:"n",className:"inset-x-3 top-0 h-1.5 cursor-ns-resize"},{edge:"s",className:"inset-x-3 bottom-0 h-1.5 cursor-ns-resize"},{edge:"w",className:"inset-y-3 left-0 w-1.5 cursor-ew-resize"},{edge:"e",className:"inset-y-3 right-0 w-1.5 cursor-ew-resize"},{edge:"nw",className:"top-0 left-0 size-3 cursor-nwse-resize"},{edge:"ne",className:"top-0 right-0 size-3 cursor-nesw-resize"},{edge:"sw",className:"bottom-0 left-0 size-3 cursor-nesw-resize"},{edge:"se",className:"right-0 bottom-0 size-3 cursor-nwse-resize"}],M=[];export const WindowPane=/*@__PURE__*/i.forwardRef(function WindowPane(E,N){const{os:S="macos",title:H,icon:k,actions:C,controls:L=!0,size:W="md",color:j="primary",accent:I=!1,transparency:P=0,active:D,elevation:T=2,position:A="static",draggable:O=!1,resizable:R=!1,width:B,height:X,minWidth:$=180,minHeight:F,offset:Y,defaultOffset:_,onOffsetChange:q,onResize:K,open:U,defaultOpen:G=!0,onOpenChange:J,minimized:Q,defaultMinimized:V=!1,onMinimizedChange:Z,maximized:ee,defaultMaximized:te=!1,onMaximizedChange:ne,scroll:ie=!0,locale:oe,minimizeLabel:re,maximizeLabel:se,restoreLabel:ae,closeLabel:le,resizeLabel:de,render:ce,className:ue,style:he,children:me,...fe}=v(E,["size","locale"]),ge=l(d,oe),we=i.useId(),pe=l(a,oe),be=w(S),xe=p(S,W),ve=i.useId(),[ye,ze]=y(U,G,J),[Me,Ee]=y(Q,V,Z),[Ne,Se]=y(ee,te,ne),[He,ke]=y(Y,_??{x:0,y:0},q),[Ce,Le]=i.useState(null),[We,je]=i.useState({width:B,height:X});We.width===B&&We.height===X||(je({width:B,height:X}),Le(null));const[Ie,Pe]=i.useState(!0),De=D??Ie,[Te,Ae]=i.useState(null),[Oe,Re]=i.useState(null),[Be,Xe]=i.useState(!1),[$e,Fe]=i.useState(!1),[Ye,_e]=i.useState(ye);Ye!==ye&&(_e(ye),Fe(!ye)),i.useEffect(()=>{if(!$e)return;const e=window.setTimeout(()=>Fe(!1),260);return()=>window.clearTimeout(e)},[$e]);const qe=i.useRef(null),Ke=i.useCallback(e=>{qe.current=e,"function"==typeof N?N(e):N&&(N.current=e)},[N]);i.useEffect(()=>{if(void 0!==D||!ye)return;const e=qe.current;if(!e)return;const t=e=>Pe(e);M.push(t);const n=n=>{const i=n.target;if(!(i instanceof Node))return;if(e.contains(i))return M.splice(M.indexOf(t),1),M.push(t),void Pe(!0);const o=i instanceof Element?i:i.parentElement;o?.closest(".neba-window")&&Pe(!1)};return document.addEventListener("pointerdown",n,!0),document.addEventListener("focusin",n,!0),()=>{document.removeEventListener("pointerdown",n,!0),document.removeEventListener("focusin",n,!0);const e=M.indexOf(t),i=e===M.length-1;M.splice(e,1),i&&M[M.length-1]?.(!0)}},[D,ye]);const Ue=i.useRef(null);function Ge(e,t){if(0!==e.button)return;Ue.current?.();const n=e.currentTarget,i=e.clientX,o=e.clientY,a=qe.current,l=a?s(a):{x:1,y:1};Xe(!0);const d=()=>{Ue.current=null,Xe(!1)},c=r({target:n,pointerId:e.pointerId,onMove:e=>t((e.clientX-i)/l.x,(e.clientY-o)/l.y),onEnd:d});Ue.current=()=>{c(),d()}}i.useEffect(()=>()=>Ue.current?.(),[]);const Je={width:Math.max(0,$),height:Math.max(xe.bar,F??xe.bar)};function Qe(e){Le(e),K?.(e)}const Ve=g(S,!0===L?["minimize","maximize","close"]:!1===L?[]:L),Ze=Ve.includes("maximize");i.useLayoutEffect(()=>{if(!Me||null!==Te)return;const e=qe.current,t=e?.firstElementChild;e&&t instanceof HTMLElement&&Ae(t.offsetHeight+(e.offsetHeight-e.clientHeight))},[Me,Te]),i.useEffect(()=>{if(Me||null===Oe)return;const e=window.setTimeout(()=>Re(null),400);return()=>window.clearTimeout(e)},[Me,Oe]);const et={minimize:re??ge.minimize,maximize:se??ge.maximize,restore:ae??ge.restore,close:le??pe.close},tt=e(f,{os:S,metrics:xe,controls:Ve,maximized:Ne,active:De,labels:et,onCommand:function(e){"close"===e?ze(!1):"minimize"===e?function(e){const t=qe.current,n=t?.firstElementChild;if(t&&n instanceof HTMLElement&&Ae(n.offsetHeight+(t.offsetHeight-t.clientHeight)),e&&void 0===(Ce?.height??X)&&t)return Re(t.offsetHeight),void requestAnimationFrame(()=>Ee(!0));Ee(e)}(!Me):Se(!Ne)}}),nt=u(H)?e("span",{id:ve,className:"min-w-0 truncate",children:H}):null,it=u(k)?e("span",{className:"flex shrink-0 items-center",children:k}):null,ot=t("div",{className:c("relative flex shrink-0 items-center select-none",h,O&&!Ne?"cursor-grab touch-none active:cursor-grabbing":""),style:{height:xe.bar,textShadow:"var(--n-window-bar-shadow)",fontWeight:xe.weight,paddingInlineStart:xe.padX,paddingInlineEnd:xe.padEnd,gap:Math.round(.7*xe.title),fontSize:xe.title,backgroundColor:"var(--n-window-bar)",backgroundImage:"var(--n-window-bar-image)",color:"var(--n-window-bar-fg)",borderBlockEnd:be.rule?"1px solid var(--n-window-line)":void 0},onPointerDown:function(e){if(!O||Ne)return;const t={...He},n=qe.current,i="fixed"===A?{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight}:"absolute"===A&&n?.offsetParent instanceof HTMLElement?{width:n.offsetParent.clientWidth,height:n.offsetParent.clientHeight}:null,o=n?.offsetWidth??0,r=Math.min(o,48);Ge(e,(e,n)=>{const s=t.x+e,a=t.y+n;ke(i?{x:Math.min(Math.max(s,r-o),i.width-r),y:Math.min(Math.max(a,0),Math.max(0,i.height-xe.bar))}:{x:s,y:a})})},onDoubleClick:Ze?()=>Se(!Ne):void 0,children:["start"===be.controlsSide?tt:null,"center"===be.titleAlign?e("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 flex items-center justify-center",style:{paddingInline:xe.controlsWidth(Ve.length)+2*xe.padX},children:t("span",{className:"flex min-w-0 items-center",style:{gap:Math.round(.5*xe.title)},children:[it,nt]})}):t(n,{children:[it,nt]}),e("span",{className:"flex-1"}),u(C)?e("span",{className:"flex shrink-0 items-center",style:{gap:Math.round(.5*xe.title)},onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:C}):null,"end"===be.controlsSide?tt:null]}),rt=Ne?{left:0,top:0,width:"100%",height:"100%"}:{left:He.x,top:He.y,width:Ce?.width??B,height:Me?Te??xe.bar:Ce?.height??X??Oe??void 0},st=o({render:ce,ref:Ke,props:{role:"group","aria-labelledby":nt?ve:void 0,className:c("neba-window relative flex min-w-0 flex-col overflow-hidden",P>0?m:"",be.glass&&0===P?"[backdrop-filter:var(--neba-blur)]":"","[transition-property:left,top,width,height,opacity,box-shadow,background-color,border-color,border-radius]","[transition-duration:var(--neba-duration-window)]","[transition-timing-function:var(--neba-ease)]","motion-reduce:[transition-duration:0ms]","data-[gesture]:[transition-property:none]",ue),"data-gesture":Be?"":void 0,inert:x(!ye),style:{opacity:ye?void 0:0,...b({os:S,color:j,accent:I,transparency:P,active:De,elevation:T}),position:"static"===A?"relative":A,...rt,borderRadius:Ne?0:`${xe.radius}px ${xe.radius}px ${xe.radiusBottom}px ${xe.radiusBottom}px`,borderStyle:"solid",borderWidth:xe.frame,borderColor:"var(--n-window-line)",backgroundColor:"var(--n-window-band)",boxShadow:"var(--n-window-shadow), var(--neba-plate-glass)",...he},children:t(n,{children:[ot,e("div",{className:c("min-h-0 flex-1",ie?"overflow-auto":"overflow-hidden"),style:{backgroundColor:"var(--n-window-body)",marginInline:xe.band.side,marginBottom:xe.band.bottom,boxShadow:xe.band.side>0?"inset 0 0 0 1px rgb(0 0 0 / 0.12)":void 0},inert:x(Me),children:me}),!R||Ne||Me?null:e("span",{id:we,hidden:!0,children:ge.resizeHint}),!R||Ne||Me?null:z.map(t=>{const n="se"===t.edge;return e("div",{role:n?"button":void 0,tabIndex:n?0:void 0,"aria-label":n?de??ge.resize:void 0,"aria-describedby":n?we:void 0,"aria-hidden":n?void 0:"true",className:c("absolute z-10 touch-none",t.className,n?"neba-hit":"",n?"focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:[outline-offset:-2px]":""),onPointerDown:e=>function(e,t){const n=qe.current;if(!n||Ne)return;const i={width:n.offsetWidth,height:n.offsetHeight,x:He.x,y:He.y},o=e.includes("e"),r=e.includes("w"),s=e.includes("n"),a=e.includes("s");Ge(t,(e,t)=>{let{width:n,height:l}=i,{x:d,y:c}=i;o&&(n=Math.max(Je.width,i.width+e)),a&&(l=Math.max(Je.height,i.height+t)),r&&(n=Math.max(Je.width,i.width-e),d=i.x+(i.width-n)),s&&(l=Math.max(Je.height,i.height-t),c=i.y+(i.height-l)),Qe({width:n,height:l}),(r||s)&&ke({x:d,y:c})})}(t.edge,e),onKeyDown:n?e=>{const t={ArrowRight:[16,0],ArrowLeft:[-16,0],ArrowDown:[0,16],ArrowUp:[0,-16]}[e.key];t&&(e.preventDefault(),function(e,t){const n=qe.current;n&&Qe({width:Math.max(Je.width,n.offsetWidth+e),height:Math.max(Je.height,n.offsetHeight+t)})}(t[0],t[1]))}:void 0},t.edge)})]}),...fe}});return ye||$e?st:null});
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* A box, in CSS pixels: the element's own layout box, in whole pixels, before any
|
|
4
|
+
* transform on it or above it. `0` × `0` before the first measurement and on a
|
|
5
|
+
* server.
|
|
6
|
+
*/
|
|
3
7
|
export interface ElementSize {
|
|
4
8
|
width: number;
|
|
5
9
|
height: number;
|
|
@@ -7,7 +11,7 @@ export interface ElementSize {
|
|
|
7
11
|
/**
|
|
8
12
|
* One element's size, kept up to date.
|
|
9
13
|
*
|
|
10
|
-
* The same shared `ResizeObserver`
|
|
14
|
+
* The same shared `ResizeObserver` the library's own components measure
|
|
11
15
|
* themselves with — one observer for the whole page rather than one per
|
|
12
16
|
* subscriber, because a dashboard of eight charts inside a PageLayout with a
|
|
13
17
|
* Panes in it was a dozen registrations the browser walked on every layout.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import*as t from"react";import{attachedRef as e,observeResize as i}from"../internal/observe.js";export function useElementSize(){const[n,h]=t.useState(null),[
|
|
1
|
+
"use client";import*as t from"react";import{attachedRef as e,observeResize as i}from"../internal/observe.js";export function useElementSize(){const[n,h]=t.useState(null),[o]=t.useState(()=>e(h)),[r,s]=t.useState({width:0,height:0});return t.useLayoutEffect(()=>{if(!n)return;const t=()=>{const t=function(t){return t instanceof HTMLElement?{width:t.offsetWidth,height:t.offsetHeight}:t.getBoundingClientRect()}(n);s(e=>e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})};return t(),i(n,t)},[n]),[o,r]}
|
|
@@ -21,8 +21,9 @@ export declare function useMediaQuery(query: string): boolean;
|
|
|
21
21
|
*
|
|
22
22
|
* `useBreakpoint('md')` is `md:` in a class name, in JavaScript — the widths are
|
|
23
23
|
* one table, so a component that branches here and a utility that branches in
|
|
24
|
-
* CSS change at the same pixel. `xs` is `0rem` and therefore always true
|
|
25
|
-
* is the value with no media query around it
|
|
24
|
+
* CSS change at the same pixel. `xs` is `0rem` and therefore always true once
|
|
25
|
+
* the page has hydrated, which is the value with no media query around it; on a
|
|
26
|
+
* server it is `false`, like every query.
|
|
26
27
|
*/
|
|
27
28
|
export declare function useBreakpoint(breakpoint: NebaBreakpoint): boolean;
|
|
28
29
|
/**
|
|
@@ -13,8 +13,8 @@ export interface OnScreenOptions {
|
|
|
13
13
|
/**
|
|
14
14
|
* Whether an element is on screen.
|
|
15
15
|
*
|
|
16
|
-
* The same shared `IntersectionObserver` the
|
|
17
|
-
*
|
|
16
|
+
* The same shared `IntersectionObserver` the `Animate*` wrappers watch for
|
|
17
|
+
* their own element with — one per threshold for the whole page, because a
|
|
18
18
|
* page of them was one registration each.
|
|
19
19
|
*
|
|
20
20
|
* It answers `true` where there is no `IntersectionObserver` rather than
|
|
@@ -2,8 +2,8 @@ export interface ShortcutOptions {
|
|
|
2
2
|
/** Stop listening without unmounting — a modal is open, a field has focus. @default true */
|
|
3
3
|
enabled?: boolean;
|
|
4
4
|
/**
|
|
5
|
-
* Ignore the key while the reader is typing into an input, a textarea
|
|
6
|
-
* anything `contenteditable`.
|
|
5
|
+
* Ignore the key while the reader is typing into an input, a textarea, a
|
|
6
|
+
* select or anything `contenteditable`.
|
|
7
7
|
*
|
|
8
8
|
* On by default, and it is the reason a bare `/` or `?` can be bound at all:
|
|
9
9
|
* a page-wide single-letter shortcut that fires inside a search box is a
|
|
@@ -17,10 +17,18 @@ export interface ShortcutOptions {
|
|
|
17
17
|
* opinion about, like `Mod+K` or `Mod+S`. @default true
|
|
18
18
|
*/
|
|
19
19
|
preventDefault?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Call the handler again for every repeat of a held key. Off by default: a
|
|
22
|
+
* shortcut held down a moment too long opened a panel and then opened it
|
|
23
|
+
* again twenty times a second. The repeats still have their default
|
|
24
|
+
* prevented, or holding `Mod+S` would save once and then open the browser's
|
|
25
|
+
* own dialog. @default false
|
|
26
|
+
*/
|
|
27
|
+
repeat?: boolean;
|
|
20
28
|
}
|
|
21
29
|
/**
|
|
22
30
|
* A key combination bound on the window, spelled the way
|
|
23
|
-
* [Shortcut](../components/shortcut) draws it — `'Mod+K'`, `'Mod+Shift+P'`,
|
|
31
|
+
* [Shortcut](../components/display/shortcut) draws it — `'Mod+K'`, `'Mod+Shift+P'`,
|
|
24
32
|
* `'?'`.
|
|
25
33
|
*
|
|
26
34
|
* This is what `CommandPalette` binds its own opener with, offered because an
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import*as e from"react";import{matchesShortcut as t}from"../internal/keys.js";export function useShortcut(
|
|
1
|
+
"use client";import*as e from"react";import{matchesShortcut as t}from"../internal/keys.js";const n=new WeakSet;export function useShortcut(r,a,o={}){const{enabled:i=!0,ignoreWhileTyping:s=!0,preventDefault:u=!0,repeat:f=!1}=o,c=e.useRef(a);e.useEffect(()=>{c.current=a}),e.useEffect(()=>{if(!1===r||!i)return;const e=e=>{var a;e.defaultPrevented&&!n.has(e)||(s&&(a=e.target,a instanceof HTMLElement&&(a.isContentEditable||"INPUT"===a.tagName||"TEXTAREA"===a.tagName||"SELECT"===a.tagName))||t(e,r)&&(u&&(e.preventDefault(),n.add(e)),e.repeat&&!f||c.current(e)))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r,i,s,u,f])}
|
|
@@ -202,6 +202,14 @@ export interface AnimationRun {
|
|
|
202
202
|
state: 'running' | 'paused';
|
|
203
203
|
/** Whether the animation has been let go at all, for `data-state`. */
|
|
204
204
|
started: boolean;
|
|
205
|
+
/**
|
|
206
|
+
* How many times it has been let go. `started` stays `true` from one run to
|
|
207
|
+
* the next — a `play` that counts up, a second hover on a finite effect — so
|
|
208
|
+
* a loop written in JavaScript starts over when this changes rather than
|
|
209
|
+
* when `started` does. The CSS effects need none of it: the rewind below is
|
|
210
|
+
* keyed on the same number.
|
|
211
|
+
*/
|
|
212
|
+
run: number;
|
|
205
213
|
/**
|
|
206
214
|
* Spread onto the element after the caller's props when `trigger` is
|
|
207
215
|
* `hover`, with the caller's handlers already inside; empty otherwise.
|
package/dist/internal/animate.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e}from"react/jsx-runtime";import*as n from"react";import{observeVisibility as t}from"./observe.js";import{cx as a}from"./styles.js";export const animationClasses={fade:"neba-anim-fade",grow:"neba-anim-scale",slide:"neba-anim-slide",zoom:"neba-anim-scale",rotate:"neba-anim-rotate",blink:"neba-anim-blink",reveal:"neba-anim-reveal"};export const animBaseClass="neba-anim";export const childAnimations=":scope > .neba-anim";export const defaultDurations={fade:320,grow:340,slide:380,zoom:340,rotate:460,blink:900,reveal:620};export function revealClip(e){switch(e){case"top":return"inset(0 0 100% 0)";case"bottom":return"inset(100% 0 0 0)";case"right":return"inset(0 0 0 100%)";default:return"inset(0 100% 0 0)"}}export function lengthValue(e){return"number"==typeof e?`${e}px`:e}export function isInfinite(e){return"infinite"===e}export function animationSlots(e){const n={"--n-anim-duration":`${e.duration}ms`,"--n-anim-delay":`${e.delay}ms`,"--n-anim-repeat":(r=e.repeat,"infinite"===r?"infinite":String(r)),"--n-anim-direction":(t=e.mode??"in",a=e.alternate,"out"===t?a?"alternate-reverse":"reverse":a?"alternate":"normal")};var t,a,r;return e.easing&&(n["--n-anim-ease"]=e.easing),void 0!==e.opacity&&(n["--n-anim-opacity"]=String(e.opacity)),void 0!==e.scale&&(n["--n-anim-scale"]=String(e.scale)),void 0!==e.x&&(n["--n-anim-x"]=e.x),void 0!==e.y&&(n["--n-anim-y"]=e.y),void 0!==e.angle&&(n["--n-anim-angle"]=e.angle),void 0!==e.angleTo&&(n["--n-anim-angle-to"]=e.angleTo),void 0!==e.clip&&(n["--n-anim-clip"]=e.clip),"view"===e.timeline&&(n["--n-anim-timeline"]="view()",n["--n-anim-range"]=e.range??"entry 0% cover 45%"),n}export function slideOffsets(e,n){const t=lengthValue(n),a="number"==typeof n?-n+"px":`calc(-1 * ${t})`;switch(e){case"top":return{x:"0px",y:a};case"bottom":return{x:"0px",y:t};case"left":return{x:a,y:"0px"};default:return{x:t,y:"0px"}}}export function staggers({stagger:e,durationStep:n}){return 0!==e||0!==n}export function staggerChildren(t,r,i,{stagger:s,durationStep:o,reverse:l}){const c=n.Children.toArray(t);return c.map((t,u)=>{const m=l?c.length-1-u:u,f=animationSlots({...i,delay:i.delay+m*s,duration:Math.max(0,i.duration+m*o)});if(!n.isValidElement(t))return e("span",{className:r,style:f,children:t},u);const d=t.props;return n.cloneElement(t,{className:a(r,d.className),style:{...f,...d.style}})})}export const MIN_BLINK_DURATION=334;export function transitionProps(e){const n=transitionParts(e);return n?{className:`neba-anim ${animationClasses[n.effect]}`,style:{...animationSlots(n.slots),"--n-anim-state":"running"}}:{className:"",style:{}}}export function transitionParts(e){if(!e)return null;const n="string"==typeof e?{type:e}:e,{type:t}=n,a=n.duration??defaultDurations[t],r={duration:"blink"===t?Math.max(a,334):a,delay:n.delay??0,easing:n.easing,repeat:n.repeat??("blink"===t?"infinite":1),alternate:n.alternate,timeline:n.timeline,range:n.range};if("grow"!==t&&"zoom"!==t||(r.scale=n.scale??("zoom"===t?.4:.8)),"slide"===t){const{x:e,y:t}=slideOffsets(n.from??"bottom",n.distance??"100%");r.x=e,r.y=t}return"rotate"===t&&(r.angle=`${n.angle??-180}deg`),"reveal"===t&&(r.clip=revealClip(n.side??"left")),{effect:t,slots:r}}export{usePrefersReducedMotion}from"./media.js";export function useAnimationRun({trigger:e,play:a,once:r,threshold:i,paused:s,infinite:o,caller:l,parts:c}){const u=n.useRef(null),[m,f]=n.useState("mount"===e),[d,p]=n.useState(0),[g,y]=n.useState(!1),x=n.useCallback(()=>{f(!0),p(e=>e+1)},[]);n.useLayoutEffect(()=>{const e=u.current;if(!e||0===d)return;const n=[e,...c?e.querySelectorAll(c):[]];for(const e of n)e.style.animationName="none";e.offsetWidth;for(const e of n)e.style.animationName=""},[d,c]),n.useEffect(()=>{if("visible"!==e)return;const n=u.current;if(!n)return;let a=null;if(a=t(n,i,e=>{e?(x(),r&&(a?.(),a=null)):r||f(!1)}),a)return()=>a?.();f(!0)},[e,r,i,x]),n.useEffect(()=>{const e=u.current;if(o&&e)return t(e,0,e=>y(!e))??void 0},[o]),n.useEffect(()=>{"manual"===e&&(a?x():f(!1))},[e,a,x]);const v=e=>e.relatedTarget instanceof Node&&e.currentTarget.contains(e.relatedTarget),b="hover"===e?{onPointerEnter:e=>{l?.onPointerEnter?.(e),x()},onFocus:e=>{l?.onFocus?.(e),v(e)||x()},onPointerLeave:e=>{l?.onPointerLeave?.(e),o&&f(!1)},onBlur:e=>{l?.onBlur?.(e),o&&!v(e)&&f(!1)}}:{};return{ref:n.useCallback(e=>{u.current=e},[]),state:!m||s||o&&g?"paused":"running",started:m,handlers:b,offscreen:o&&g}}export function useAnimateElement(e){const{effect:n,trigger:t,play:a,once:r,threshold:i,paused:s,infinite:o,caller:l,children:c,stagger:u=0,durationStep:m=0,reverse:f=!1,effectClass:d,name:p,...g}=e,y=n?animationClasses[n]:d,x=y?`neba-anim ${y}`:"",v=""!==x&&staggers({stagger:u,durationStep:m,reverse:f}),b=useAnimationRun({trigger:t,play:a,once:r,threshold:i,paused:s,infinite:o,caller:l,parts:v?childAnimations:void 0}),h="view"===g.timeline?"running":b.state;return{ref:b.ref,className:v?"":x,style:v?{"--n-anim-state":h}:{...animationSlots(g),"--n-anim-state":h},props:{...b.handlers,"data-neba-animation":p??n??void 0,"data-state":h},children:v?staggerChildren(c,x,g,{stagger:u,durationStep:m,reverse:f}):c}}
|
|
1
|
+
"use client";import{jsx as e}from"react/jsx-runtime";import*as n from"react";import{observeVisibility as t}from"./observe.js";import{cx as a}from"./styles.js";export const animationClasses={fade:"neba-anim-fade",grow:"neba-anim-scale",slide:"neba-anim-slide",zoom:"neba-anim-scale",rotate:"neba-anim-rotate",blink:"neba-anim-blink",reveal:"neba-anim-reveal"};export const animBaseClass="neba-anim";export const childAnimations=":scope > .neba-anim";export const defaultDurations={fade:320,grow:340,slide:380,zoom:340,rotate:460,blink:900,reveal:620};export function revealClip(e){switch(e){case"top":return"inset(0 0 100% 0)";case"bottom":return"inset(100% 0 0 0)";case"right":return"inset(0 0 0 100%)";default:return"inset(0 100% 0 0)"}}export function lengthValue(e){return"number"==typeof e?`${e}px`:e}export function isInfinite(e){return"infinite"===e}export function animationSlots(e){const n={"--n-anim-duration":`${e.duration}ms`,"--n-anim-delay":`${e.delay}ms`,"--n-anim-repeat":(r=e.repeat,"infinite"===r?"infinite":String(r)),"--n-anim-direction":(t=e.mode??"in",a=e.alternate,"out"===t?a?"alternate-reverse":"reverse":a?"alternate":"normal")};var t,a,r;return e.easing&&(n["--n-anim-ease"]=e.easing),void 0!==e.opacity&&(n["--n-anim-opacity"]=String(e.opacity)),void 0!==e.scale&&(n["--n-anim-scale"]=String(e.scale)),void 0!==e.x&&(n["--n-anim-x"]=e.x),void 0!==e.y&&(n["--n-anim-y"]=e.y),void 0!==e.angle&&(n["--n-anim-angle"]=e.angle),void 0!==e.angleTo&&(n["--n-anim-angle-to"]=e.angleTo),void 0!==e.clip&&(n["--n-anim-clip"]=e.clip),"view"===e.timeline&&(n["--n-anim-timeline"]="view()",n["--n-anim-range"]=e.range??"entry 0% cover 45%"),n}export function slideOffsets(e,n){const t=lengthValue(n),a="number"==typeof n?-n+"px":`calc(-1 * ${t})`;switch(e){case"top":return{x:"0px",y:a};case"bottom":return{x:"0px",y:t};case"left":return{x:a,y:"0px"};default:return{x:t,y:"0px"}}}export function staggers({stagger:e,durationStep:n}){return 0!==e||0!==n}export function staggerChildren(t,r,i,{stagger:s,durationStep:o,reverse:l}){const c=n.Children.toArray(t);return c.map((t,u)=>{const m=l?c.length-1-u:u,f=animationSlots({...i,delay:i.delay+m*s,duration:Math.max(0,i.duration+m*o)});if(!n.isValidElement(t))return e("span",{className:r,style:f,children:t},u);const d=t.props;return n.cloneElement(t,{className:a(r,d.className),style:{...f,...d.style}})})}export const MIN_BLINK_DURATION=334;export function transitionProps(e){const n=transitionParts(e);return n?{className:`neba-anim ${animationClasses[n.effect]}`,style:{...animationSlots(n.slots),"--n-anim-state":"running"}}:{className:"",style:{}}}export function transitionParts(e){if(!e)return null;const n="string"==typeof e?{type:e}:e,{type:t}=n,a=n.duration??defaultDurations[t],r={duration:"blink"===t?Math.max(a,334):a,delay:n.delay??0,easing:n.easing,repeat:n.repeat??("blink"===t?"infinite":1),alternate:n.alternate,timeline:n.timeline,range:n.range};if("grow"!==t&&"zoom"!==t||(r.scale=n.scale??("zoom"===t?.4:.8)),"slide"===t){const{x:e,y:t}=slideOffsets(n.from??"bottom",n.distance??"100%");r.x=e,r.y=t}return"rotate"===t&&(r.angle=`${n.angle??-180}deg`),"reveal"===t&&(r.clip=revealClip(n.side??"left")),{effect:t,slots:r}}export{usePrefersReducedMotion}from"./media.js";export function useAnimationRun({trigger:e,play:a,once:r,threshold:i,paused:s,infinite:o,caller:l,parts:c}){const u=n.useRef(null),[m,f]=n.useState("mount"===e),[d,p]=n.useState(0),[g,y]=n.useState(!1),x=n.useCallback(()=>{f(!0),p(e=>e+1)},[]);n.useLayoutEffect(()=>{const e=u.current;if(!e||0===d)return;const n=[e,...c?e.querySelectorAll(c):[]];for(const e of n)e.style.animationName="none";e.offsetWidth;for(const e of n)e.style.animationName=""},[d,c]),n.useEffect(()=>{if("visible"!==e)return;const n=u.current;if(!n)return;let a=null;if(a=t(n,i,e=>{e?(x(),r&&(a?.(),a=null)):r||f(!1)}),a)return()=>a?.();f(!0)},[e,r,i,x]),n.useEffect(()=>{const e=u.current;if(o&&e)return t(e,0,e=>y(!e))??void 0},[o]),n.useEffect(()=>{"manual"===e&&(a?x():f(!1))},[e,a,x]);const v=e=>e.relatedTarget instanceof Node&&e.currentTarget.contains(e.relatedTarget),b="hover"===e?{onPointerEnter:e=>{l?.onPointerEnter?.(e),x()},onFocus:e=>{l?.onFocus?.(e),v(e)||x()},onPointerLeave:e=>{l?.onPointerLeave?.(e),o&&f(!1)},onBlur:e=>{l?.onBlur?.(e),o&&!v(e)&&f(!1)}}:{};return{ref:n.useCallback(e=>{u.current=e},[]),state:!m||s||o&&g?"paused":"running",started:m,run:d,handlers:b,offscreen:o&&g}}export function useAnimateElement(e){const{effect:n,trigger:t,play:a,once:r,threshold:i,paused:s,infinite:o,caller:l,children:c,stagger:u=0,durationStep:m=0,reverse:f=!1,effectClass:d,name:p,...g}=e,y=n?animationClasses[n]:d,x=y?`neba-anim ${y}`:"",v=""!==x&&staggers({stagger:u,durationStep:m,reverse:f}),b=useAnimationRun({trigger:t,play:a,once:r,threshold:i,paused:s,infinite:o,caller:l,parts:v?childAnimations:void 0}),h="view"===g.timeline?"running":b.state;return{ref:b.ref,className:v?"":x,style:v?{"--n-anim-state":h}:{...animationSlots(g),"--n-anim-state":h},props:{...b.handlers,"data-neba-animation":p??n??void 0,"data-state":h},children:v?staggerChildren(c,x,g,{stagger:u,durationStep:m,reverse:f}):c}}
|