neba 1.17.1 → 1.18.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/dist/a2ui/adapter-catalog.json +1 -1
- package/dist/a2ui/catalog.json +2 -2
- package/dist/a2ui/index.d.ts +2 -0
- package/dist/a2ui/schema.d.ts +11 -1
- package/dist/a2ui/schema.js +1 -1
- package/dist/components/alert/Alert.js +1 -1
- package/dist/components/animate-counter/AnimateCounter.d.ts +6 -0
- package/dist/components/animate-counter/AnimateCounter.js +1 -1
- package/dist/components/animate-headline/AnimateHeadline.js +1 -1
- package/dist/components/animate-scramble/AnimateScramble.d.ts +9 -3
- package/dist/components/animate-scramble/AnimateScramble.js +1 -1
- package/dist/components/animate-split/AnimateSplit.d.ts +7 -1
- package/dist/components/animate-split/AnimateSplit.js +1 -1
- package/dist/components/animate-typing/AnimateTyping.d.ts +6 -0
- 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/breadcrumb/Breadcrumb.d.ts +16 -0
- package/dist/components/breadcrumb/Breadcrumb.js +1 -1
- package/dist/components/calendar/Calendar.js +1 -1
- package/dist/components/card/Card.js +1 -1
- package/dist/components/carousel/Carousel.d.ts +3 -2
- package/dist/components/carousel/Carousel.js +1 -1
- package/dist/components/chat-bubble/ChatBubble.d.ts +6 -0
- package/dist/components/chat-bubble/ChatBubble.js +1 -1
- package/dist/components/code-block/CodeBlock.d.ts +2 -2
- package/dist/components/code-block/CodeBlock.js +1 -1
- package/dist/components/code-block/index.d.ts +2 -1
- package/dist/components/code-block/index.js +1 -1
- package/dist/components/color-picker/ColorPicker.js +1 -1
- package/dist/components/combobox/Combobox.js +1 -1
- package/dist/components/context-window/ContextWindow.js +1 -1
- package/dist/components/data-table/DataTable.d.ts +13 -1
- package/dist/components/data-table/DataTable.js +1 -1
- package/dist/components/date-picker/DatePicker.js +1 -1
- package/dist/components/date-range-picker/DateRangePicker.js +1 -1
- package/dist/components/date-time-picker/DateTimePicker.js +1 -1
- package/dist/components/drawer/Drawer.d.ts +21 -0
- package/dist/components/drawer/Drawer.js +1 -1
- package/dist/components/empty/Empty.js +1 -1
- package/dist/components/file-picker/FilePicker.d.ts +0 -8
- package/dist/components/file-picker/FilePicker.js +1 -1
- package/dist/components/file-picker/formatFileSize.d.ts +8 -0
- package/dist/components/file-picker/formatFileSize.js +1 -0
- package/dist/components/file-picker/index.d.ts +2 -1
- package/dist/components/file-picker/index.js +1 -1
- package/dist/components/floating-bottom-navigation/FloatingBottomNavigation.js +1 -1
- package/dist/components/gallery/Gallery.d.ts +45 -3
- package/dist/components/gallery/Gallery.js +1 -1
- package/dist/components/gallery/GalleryViewer.js +1 -1
- package/dist/components/gauge-chart/GaugeChart.js +1 -1
- package/dist/components/heatmap-chart/HeatmapChart.js +1 -1
- package/dist/components/how-to-steps/HowToSteps.d.ts +14 -0
- package/dist/components/how-to-steps/HowToSteps.js +1 -1
- package/dist/components/image/Image.d.ts +31 -6
- package/dist/components/image/Image.js +1 -1
- package/dist/components/menu/Menu.d.ts +17 -0
- package/dist/components/menu/Menu.js +1 -1
- package/dist/components/meter/Meter.js +1 -1
- package/dist/components/mockup/Mockup.js +1 -1
- package/dist/components/number-field/NumberField.js +1 -1
- package/dist/components/page-layout/PageLayout.js +1 -1
- 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/progress-box/ProgressBox.js +1 -1
- package/dist/components/progress-circular/ProgressCircular.js +1 -1
- package/dist/components/progress-linear/ProgressLinear.js +1 -1
- package/dist/components/prompt-input/PromptInput.js +1 -1
- package/dist/components/provider/NebaProvider.d.ts +0 -20
- package/dist/components/provider/NebaProvider.js +1 -1
- package/dist/components/provider/colorSchemeScript.d.ts +23 -0
- package/dist/components/provider/colorSchemeScript.js +1 -0
- package/dist/components/provider/index.d.ts +2 -1
- package/dist/components/provider/index.js +1 -1
- package/dist/components/reasoning/Reasoning.d.ts +21 -0
- package/dist/components/reasoning/Reasoning.js +1 -1
- package/dist/components/scatter-chart/ScatterChart.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.js +1 -1
- package/dist/components/sidebar/Sidebar.d.ts +13 -0
- package/dist/components/sidebar/Sidebar.js +1 -1
- package/dist/components/slider/Slider.js +1 -1
- package/dist/components/sources/Sources.d.ts +11 -0
- package/dist/components/sources/Sources.js +1 -1
- package/dist/components/spoiler/Spoiler.js +1 -1
- package/dist/components/statistic/Statistic.js +1 -1
- package/dist/components/streaming-text/StreamingText.d.ts +22 -11
- package/dist/components/streaming-text/StreamingText.js +1 -1
- package/dist/components/tabs/Tabs.d.ts +12 -1
- package/dist/components/tabs/Tabs.js +1 -1
- package/dist/components/text-link/TextLink.d.ts +7 -0
- package/dist/components/text-link/TextLink.js +1 -1
- package/dist/components/time-picker/TimePicker.js +1 -1
- package/dist/components/timeline-chart/TimelineChart.js +1 -1
- package/dist/components/toast/Toast.js +1 -1
- package/dist/components/tool-call/ToolCall.d.ts +11 -0
- package/dist/components/tool-call/ToolCall.js +1 -1
- package/dist/components/tour/Tour.js +1 -1
- package/dist/components/tree-view/TreeView.d.ts +13 -1
- package/dist/components/tree-view/TreeView.js +1 -1
- package/dist/components/typography/Typography.d.ts +7 -0
- package/dist/components/typography/Typography.js +1 -1
- package/dist/components/window-pane/WindowPane.js +1 -1
- package/dist/hooks/useElementSize.js +1 -1
- package/dist/internal/animate.js +1 -1
- package/dist/internal/calendar.d.ts +2 -2
- package/dist/internal/calendar.js +1 -1
- package/dist/internal/chart-frame.d.ts +59 -2
- package/dist/internal/chart-frame.js +1 -1
- package/dist/internal/chart-line.js +1 -1
- package/dist/internal/format.d.ts +7 -0
- package/dist/internal/format.js +1 -1
- package/dist/internal/highlight.d.ts +9 -0
- package/dist/internal/highlight.js +1 -1
- package/dist/internal/layout-effect.d.ts +17 -0
- package/dist/internal/layout-effect.js +1 -0
- package/dist/internal/media.d.ts +20 -0
- package/dist/internal/media.js +1 -1
- package/dist/internal/menu.d.ts +5 -0
- package/dist/internal/observe.d.ts +4 -1
- package/dist/internal/observe.js +1 -1
- package/dist/internal/overrides.d.ts +55 -0
- package/dist/internal/overrides.js +1 -0
- package/dist/internal/page-layout.d.ts +26 -1
- package/dist/internal/page-layout.js +1 -1
- package/dist/internal/run.d.ts +6 -1
- package/dist/internal/run.js +1 -1
- package/dist/internal/sizer.d.ts +10 -0
- package/dist/internal/sizer.js +1 -1
- package/dist/internal/styles.d.ts +28 -2
- package/dist/internal/styles.js +1 -1
- package/dist/internal/text.d.ts +25 -3
- package/dist/internal/text.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +91 -72
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as a from"react";import{Button as n}from"../button/Button.js";import{Calendar as t,usePickerLabels as
|
|
1
|
+
"use client";import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as a from"react";import{Button as n}from"../button/Button.js";import{Calendar as t,usePickerLabels as r}from"../../internal/calendar.js";import{ArrowRightIcon as s,CalendarIcon as o}from"../../internal/icons.js";import{PickerFooter as i,PickerShell as c}from"../../internal/picker.js";import{WidthSizer as u}from"../../internal/sizer.js";import{addMonths as m,compareDay as d,displaySamples as p,formatDate as h,isValidDate as f,localeWeekStart as x,startOfDay as v,startOfMonth as b,toISODate as g,today as y,withPlaceholder as j}from"../../internal/date.js";import{cx as w,gapClasses as N,metaTextClasses as D}from"../../internal/styles.js";import{useStyleDefaults as S}from"../../internal/defaults.js";import{useIntlLocale as C}from"../../internal/media.js";const O={start:null,end:null};export const DateRangePicker=/*@__PURE__*/a.forwardRef(function DateRangePicker(k,z){const{value:P,defaultValue:R,onValueChange:B,open:M,defaultOpen:V,onOpenChange:E,defaultMonth:I,minDate:F,maxDate:L,shouldDisableDate:q,locale:A,weekStartsOn:G,format:H={dateStyle:"medium"},monthCount:J=2,startPlaceholder:K,endPlaceholder:Q,presets:T,clearable:U=!1,closeOnSelect:W=!0,labels:X,name:Y,size:Z="md",color:$="primary",readOnly:_=!1,disabled:ee=!1,startIcon:le,...ae}=S(k,["size","density","variant","locale","labelPlacement"]),ne=r(X,A),te=C(A),re=G??x(te),[se,oe]=a.useState(R??O),ie=void 0!==P?P??O:se,ce=f(ie.start)?ie.start:null,ue=f(ie.end)?ie.end:null,[me,de]=a.useState(V??!1),pe=M??me,[he,fe]=a.useState(null),[xe,ve]=a.useState(null),[be,ge]=a.useState(()=>b(ce??I??y()));a.useEffect(()=>{pe?ge(b(ce??I??y())):(fe(null),ve(null))},[pe]);const ye=e=>{e&&(_||ee)||(void 0===M&&de(e),E?.(e))},je=e=>{void 0===P&&oe(e),B?.(e)},we=he??ce,Ne=null!==he?xe:ue,De=(l,a)=>f(l)?h(l,te,H):e("span",{className:"text-(--neba-muted-fg)",children:a??""}),Se=m(be,1),Ce=2===J,Oe=p(te,H),ke=null!==he?ne.end:null===ce?ne.start:null,ze={size:Z,color:$,locale:A,weekStartsOn:re,selected:[ce,ue,he],rangeStart:we,rangeEnd:Ne,onSelect:e=>{const l=v(e);return null===he||d(l,he)<0?(fe(l),void ve(l)):(fe(null),ve(null),je({start:he,end:l}),void(W&&ye(!1)))},onPreviewChange:e=>{null!==he&&ve(e??he)},minDate:F,maxDate:L,shouldDisableDate:q,showOutsideDays:!1,multiselectable:!0,labels:ne};return e(c,{...ae,size:Z,color:$,readOnly:_,disabled:ee,triggerRef:z,startIcon:le??e(o,{}),display:l("span",{className:"flex min-w-0 items-center gap-1.5",children:[l("span",{className:"flex min-w-0 flex-col",children:[e("span",{className:"truncate",children:De(ce,K)}),e(u,{samples:j(Oe,K)})]}),e("span",{"aria-hidden":"true",className:"flex shrink-0 items-center text-(--neba-muted-fg) rtl:rotate-180",children:e(s,{})}),l("span",{className:"flex min-w-0 flex-col",children:[e("span",{className:"truncate",children:De(ue,Q)}),e(u,{samples:j(Oe,Q)})]})]}),empty:null===ce&&null===ue,clearable:U,onClear:()=>je(O),open:pe,onOpenChange:ye,clearLabel:ne.clear,hiddenValues:Y?[{name:Y,value:ce?g(ce):""},{name:Y,value:ue?g(ue):""}]:void 0,repeats:!0,children:l("div",{className:"flex flex-col gap-1.5",children:[l("div",{className:w("flex items-stretch",N[Z]),children:[T&&T.length>0?e("div",{className:w("flex max-h-[calc(var(--n-cell,2rem)*8)] flex-col overflow-y-auto border-e pe-1.5","[border-color:var(--n-line)]"),children:T.map((l,a)=>e(n,{variant:"text",size:Z,color:$,density:"compact",className:"justify-start whitespace-nowrap",onClick:()=>(e=>{const l="function"==typeof e.value?e.value():e.value;fe(null),ve(null),je(l),f(l.start)&&ge(b(l.start)),W&&ye(!1)})(l),children:l.label},a))}):null,e(t,{...ze,month:be,onMonthChange:ge,showNextButton:!Ce,autoFocus:!0}),Ce?e(t,{...ze,month:Se,onMonthChange:e=>ge(m(e,-1)),showPreviousButton:!1}):null]}),U||null!==ke?l(i,{size:Z,children:[null!==ke?e("span",{className:w("me-auto text-(--neba-muted-fg)",D[Z]),children:ke}):null,U?e(n,{variant:"text",size:Z,color:$,density:"compact",onClick:()=>{fe(null),ve(null),je(O),ye(!1)},children:ne.clear}):null]}):null]})})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as l from"react";import{Button as a}from"../button/Button.js";import{Calendar as n,TimeGrid as o,usePickerLabels as s}from"../../internal/calendar.js";import{CalendarIcon as i}from"../../internal/icons.js";import{PickerDivider as r,PickerFooter as c,PickerShell as d}from"../../internal/picker.js";import{clampDate as m,displaySamples as u,formatDate as p,isDayOutside as h,isHour12 as f,isValidDate as S,localeWeekStart as b,mergeDateAndTime as y,startOfDay as D,startOfMonth as g,timeUnitRange as v,toISODateTime as
|
|
1
|
+
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as l from"react";import{Button as a}from"../button/Button.js";import{Calendar as n,TimeGrid as o,usePickerLabels as s}from"../../internal/calendar.js";import{CalendarIcon as i}from"../../internal/icons.js";import{PickerDivider as r,PickerFooter as c,PickerShell as d}from"../../internal/picker.js";import{clampDate as m,displaySamples as u,formatDate as p,isDayOutside as h,isHour12 as f,isValidDate as S,localeWeekStart as b,mergeDateAndTime as y,startOfDay as D,startOfMonth as g,timeUnitRange as v,toISODateTime as j,today as x,withPlaceholder as C,withTime as k}from"../../internal/date.js";import{cx as w,gapClasses as z}from"../../internal/styles.js";import{useStyleDefaults as O}from"../../internal/defaults.js";import{useIntlLocale as T}from"../../internal/media.js";export const DateTimePicker=/*@__PURE__*/l.forwardRef(function DateTimePicker(N,P){const{value:V,defaultValue:B,onValueChange:I,open:M,defaultOpen:R,onOpenChange:E,defaultMonth:F,minDate:L,maxDate:q,shouldDisableDate:A,shouldDisableTime:G,locale:H,weekStartsOn:J,format:K={dateStyle:"medium",timeStyle:"short"},hour12:Q,showSeconds:U=!1,hourStep:W=1,minuteStep:X=1,secondStep:Y=1,placeholder:Z,clearable:$=!1,showNowButton:_=!0,closeOnSelect:ee=!1,labels:te,name:le,size:ae="md",color:ne="primary",density:oe="default",readOnly:se=!1,disabled:ie=!1,startIcon:re,...ce}=O(N,["size","density","variant","locale","labelPlacement"]),de=s(te,H),me=T(H),ue=J??b(me),pe=Q??f(me),[he,fe]=l.useState(B??null),Se=void 0!==V?V:he,[be,ye]=l.useState(R??!1),De=M??be,[ge,ve]=l.useState(()=>g(S(Se)?Se:F??x()));l.useEffect(()=>{De&&ve(g(S(Se)?Se:F??x()))},[De]);const je=e=>{e&&(se||ie)||(void 0===M&&ye(e),E?.(e))},xe=e=>{const t=null===e?null:m(e,L,q);void 0===V&&fe(t),I?.(t)},Ce=l.useCallback((e,t)=>{const[l,a]=v(t,e);return!!(S(L)&&a.getTime()<L.getTime())||(!!(S(q)&&l.getTime()>q.getTime())||(G?.(e,t)??!1))},[L,q,G]),ke=new Date,we=k(ke,{seconds:U?ke.getSeconds():0}),ze=h(we,L,q)||(A?.(we)??!1)||Ce(we,"second"),Oe=C(u(me,K),Z);return e(d,{...ce,size:ae,color:ne,density:oe,readOnly:se,disabled:ie,triggerRef:P,startIcon:re??e(i,{}),display:S(Se)?p(Se,me,K):Z??"",samples:Oe,empty:!S(Se),clearable:$,onClear:()=>xe(null),open:De,onOpenChange:je,clearLabel:de.clear,hiddenValues:le?[{name:le,value:S(Se)?j(Se,U):""}]:void 0,children:t("div",{className:"flex flex-col gap-1.5",children:[t("div",{className:w("flex items-stretch",z[ae]),children:[e(n,{size:ae,color:ne,locale:H,weekStartsOn:ue,month:ge,onMonthChange:ve,selected:[Se],onSelect:e=>{const t=S(Se)?y(e,Se):D(e);xe(t),ve(g(t)),ee&&je(!1)},minDate:L,maxDate:q,shouldDisableDate:A,labels:de,autoFocus:!0}),e(r,{}),e(o,{size:ae,density:oe,locale:H,value:S(Se)?Se:null,referenceDate:S(Se)?Se:x(),onChange:xe,hour12:pe,showSeconds:U,hourStep:W,minuteStep:X,secondStep:Y,shouldDisableTime:Ce,labels:de})]}),t(c,{size:ae,children:[$?e(a,{variant:"text",size:ae,color:ne,density:"compact",onClick:()=>{xe(null),je(!1)},children:de.clear}):null,_?e(a,{variant:"text",size:ae,color:ne,density:"compact",disabled:ze,onClick:()=>{xe(we),ve(g(we))},children:de.now}):null,e(a,{variant:"solid",size:ae,color:ne,density:"compact",onClick:()=>je(!1),children:de.done})]})]})})});
|
|
@@ -54,6 +54,15 @@ export interface DrawerProps extends Pick<NebaStyleProps, 'size' | 'color' | 'de
|
|
|
54
54
|
trigger?: React.ReactElement;
|
|
55
55
|
/** The heading. Rendered as the element that names the drawer. */
|
|
56
56
|
title?: React.ReactNode;
|
|
57
|
+
/**
|
|
58
|
+
* Which heading the title is, in the page's own outline. An `inline` drawer
|
|
59
|
+
* is part of the page, so its heading is too: one beside an `<h1>` wants `2`,
|
|
60
|
+
* and one inside a section headed `<h2>` wants `3`. An `overlay` drawer is a
|
|
61
|
+
* dialog and starts an outline of its own, where the default is what it
|
|
62
|
+
* wants.
|
|
63
|
+
* @default 2
|
|
64
|
+
*/
|
|
65
|
+
headingLevel?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
57
66
|
/** A line under the title, and the drawer's accessible description. */
|
|
58
67
|
description?: React.ReactNode;
|
|
59
68
|
/**
|
|
@@ -122,6 +131,18 @@ export interface DrawerProps extends Pick<NebaStyleProps, 'size' | 'color' | 'de
|
|
|
122
131
|
* @default true
|
|
123
132
|
*/
|
|
124
133
|
safeArea?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Keeps the panel and its contents in the DOM while the drawer is closed,
|
|
136
|
+
* hidden, rather than building them each time it opens.
|
|
137
|
+
*
|
|
138
|
+
* For a drawer of links that should be in the page a crawler renders — the
|
|
139
|
+
* navigation a Sidebar becomes on a narrow screen above all. An `overlay`
|
|
140
|
+
* drawer is portalled, and a portal has nowhere to go until there is a
|
|
141
|
+
* document, so its contents arrive once the page has hydrated rather than in
|
|
142
|
+
* the server's HTML. An `inline` one is in the server's HTML as well.
|
|
143
|
+
* @default false
|
|
144
|
+
*/
|
|
145
|
+
keepMounted?: boolean;
|
|
125
146
|
/** The body. */
|
|
126
147
|
children?: React.ReactNode;
|
|
127
148
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as a,Fragment as r}from"react/jsx-runtime";import*as
|
|
1
|
+
"use client";import{jsx as e,jsxs as a,Fragment as r}from"react/jsx-runtime";import*as n from"react";import{Dialog as t}from"@base-ui/react/dialog";import{boxPaddingXClasses as l,boxPaddingYClasses as s}from"../box/Box.js";import{actionMessages as o,useMessages as d}from"../../internal/i18n.js";import{CloseIcon as i}from"../../internal/icons.js";import{cx as b,hasContent as m,headingTitleClasses as u,metaTextClasses as c,popupFadeClasses as f,sheetBodyClasses as p,sheetCloseClasses as h,sheetHeaderGapClasses as x,sheetSectionGapClasses as g,surfaceClasses as v,surfaceSlots as y}from"../../internal/styles.js";import{useStyleDefaults as w}from"../../internal/defaults.js";const j={xs:"w-56",sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[28rem]"},N={left:{xs:"rounded-r-(--neba-radius-xs)",sm:"rounded-r-(--neba-radius-sm)",md:"rounded-r-(--neba-radius-md)",lg:"rounded-r-(--neba-radius-lg)",xl:"rounded-r-(--neba-radius-xl)"},right:{xs:"rounded-l-(--neba-radius-xs)",sm:"rounded-l-(--neba-radius-sm)",md:"rounded-l-(--neba-radius-md)",lg:"rounded-l-(--neba-radius-lg)",xl:"rounded-l-(--neba-radius-xl)"},top:{xs:"rounded-b-(--neba-radius-xs)",sm:"rounded-b-(--neba-radius-sm)",md:"rounded-b-(--neba-radius-md)",lg:"rounded-b-(--neba-radius-lg)",xl:"rounded-b-(--neba-radius-xl)"},bottom:{xs:"rounded-t-(--neba-radius-xs)",sm:"rounded-t-(--neba-radius-sm)",md:"rounded-t-(--neba-radius-md)",lg:"rounded-t-(--neba-radius-lg)",xl:"rounded-t-(--neba-radius-xl)"}},$={left:"border-r",right:"border-l",top:"border-b",bottom:"border-t"},_={left:"data-[starting-style]:[translate:-100%_0] data-[ending-style]:[translate:-100%_0]",right:"data-[starting-style]:[translate:100%_0] data-[ending-style]:[translate:100%_0]",top:"data-[starting-style]:[translate:0_-100%] data-[ending-style]:[translate:0_-100%]",bottom:"data-[starting-style]:[translate:0_100%] data-[ending-style]:[translate:0_100%]"},k={left:"flex-row justify-start",right:"flex-row justify-end",top:"flex-col justify-start",bottom:"flex-col justify-end"},C=[v,"relative flex flex-col overflow-hidden","[&[hidden]]:hidden","text-(--neba-fg) bg-(--n-panel-press)","[border-color:var(--n-line)]","[outline:none]"].join(" "),z=["fixed inset-0 z-(--neba-z-portal) bg-(--neba-scrim)","[backdrop-filter:blur(2px)]",f].join(" "),B="env(safe-area-inset-top) solid transparent",D="env(safe-area-inset-bottom) solid transparent",L="env(safe-area-inset-left) solid transparent",T="env(safe-area-inset-right) solid transparent",O={top:{borderTop:B,borderLeft:L,borderRight:T},bottom:{borderBottom:D,borderLeft:L,borderRight:T},left:{borderTop:B,borderBottom:D,borderLeft:L},right:{borderTop:B,borderBottom:D,borderRight:T}},R="border-t [border-color:var(--n-line)]";export const DrawerClose=t.Close;export function Drawer(f){const{side:v="left",mode:B="overlay",size:D="md",color:L="primary",density:T="default",open:P,defaultOpen:E,onOpenChange:M,trigger:A,title:F,headingLevel:S=2,description:V,actions:q,dividers:G=!1,showClose:H,locale:I,closeLabel:J,extent:K,rounded:Q=!0,modal:U=!0,dismissible:W=!0,safeArea:X=!0,keepMounted:Y=!1,className:Z,style:ee,children:ae,...re}=w(f,["size","density","locale"]),ne=d(o,I),te="overlay"===B,le="left"===v||"right"===v,se=H??te,[oe,de]=n.useState(E??!0),ie=l[T][D],be=s[T][D],me=G?`${ie} ${be}`:ie,ue=m(F)||m(V),ce=m(q),fe=void 0===K?null:{[le?"width":"height"]:"number"==typeof K?`${K}px`:K},pe=b(C,p[D],$[v],Q?N[v][D]:"",te?"[box-shadow:var(--neba-shadow-3),var(--neba-plate-glass)]":"[box-shadow:var(--neba-plate-glass)]",te?`[transition:translate_var(--neba-duration)_var(--neba-ease)] ${_[v]}`:"",le?`h-full max-w-full ${void 0===K?j[D]:""}`:"w-full "+(void 0===K?"max-h-[85%]":""),G?"":`${be} ${g[D]}`,Z??""),he=`h${S}`,xe=te?t.Description:"p",ge=b("neba-heading","[&.neba-heading]:m-0 [&.neba-heading]:font-semibold [&.neba-heading]:text-inherit",u[D]),ve=a(r,{children:[ue||se?a("div",{className:`flex shrink-0 items-start gap-3 ${me}`,children:[a("div",{className:`flex min-w-0 flex-1 flex-col ${x[D]}`,children:[m(F)?te?e(t.Title,{render:n.createElement(he),className:ge,children:F}):n.createElement(he,{className:ge},F):null,m(V)?e(xe,{className:`m-0 text-(--neba-muted-fg) ${c[D]}`,children:V}):null]}),se?te?e(t.Close,{"aria-label":J??ne.close,className:h,children:e(i,{})}):e("button",{type:"button","aria-label":J??ne.close,className:h,onClick:()=>{void 0===P&&de(!1),M?.(!1)},children:e(i,{})}):null]}):null,m(ae)?e("div",{className:b("min-h-0 flex-1 overflow-y-auto overscroll-contain",me,G&&(ue||se)?R:"",G?"":"py-1 -my-1"),children:ae}):null,ce?e("div",{className:b("flex shrink-0 flex-wrap items-center justify-end gap-2",me,G?R:""),children:q}):null]});if(!te){const a=P??oe;return a||Y?e("div",{hidden:!a||void 0,className:pe,style:{...y(L,0),...fe,...ee},...re,children:ve}):null}return a(t.Root,{open:P,defaultOpen:E,modal:U,disablePointerDismissal:!W,onOpenChange:(e,a)=>{W||e||"escape-key"!==a.reason?M?.(e):a.cancel()},children:[A?e(t.Trigger,{render:A}):null,a(t.Portal,{keepMounted:Y,children:[e(t.Backdrop,{className:b("neba-portal",z,!0===U?"":"pointer-events-none")}),e(t.Viewport,{className:b("neba-portal fixed inset-0 z-(--neba-z-portal) flex [&[hidden]]:hidden",k[v],!0===U?"":"pointer-events-none"),children:e(t.Popup,{className:b(pe,!0===U?"":"pointer-events-auto"),style:{...y(L,3),...fe,...X?O[v]:null,...ee},...re,children:ve})})]})]})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import*as n from"react";import{useRender as l}from"@base-ui/react/use-render";import{boxPaddingXClasses as a}from"../box/Box.js";import{transitionProps as s}from"../../internal/animate.js";import{emptyMessages as o,useMessages as i}from"../../internal/i18n.js";import{cx as m,hasContent as c,iconClasses as d,radiusClasses as p,sheetBodyClasses as x,sheetHeaderGapClasses as f,sheetSectionGapClasses as u,sheetTitleClasses as y,
|
|
1
|
+
"use client";import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import*as n from"react";import{useRender as l}from"@base-ui/react/use-render";import{boxPaddingXClasses as a}from"../box/Box.js";import{transitionProps as s}from"../../internal/animate.js";import{emptyMessages as o,useMessages as i}from"../../internal/i18n.js";import{cx as m,hasContent as c,iconClasses as d,radiusClasses as p,sheetBodyClasses as x,sheetHeaderGapClasses as f,sheetSectionGapClasses as u,sheetTitleClasses as y,sheetTitleHeadingClasses as h,surfaceClasses as v,surfaceSlots as b,transitionClasses as g}from"../../internal/styles.js";import{useStyleDefaults as j}from"../../internal/defaults.js";const N={default:{xs:"py-5",sm:"py-6",md:"py-8",lg:"py-10",xl:"py-12"},compact:{xs:"py-3",sm:"py-3.5",md:"py-4",lg:"py-5",xl:"py-6"}},k={xs:"text-[1.25rem]",sm:"text-[1.5rem]",md:"text-[1.75rem]",lg:"text-[2.125rem]",xl:"text-[2.5rem]"},w={solid:[v,"text-(--neba-fg) bg-(--n-panel-hover)","[box-shadow:var(--n-elev),var(--neba-plate-solid)]"].join(" "),outline:[v,"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"};function TrayIcon(){return t("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[e("path",{d:"M1.75 9.75h3l.9 1.6h4.7l.9-1.6h3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"m1.75 9.75 2.1-6a1.5 1.5 0 0 1 1.42-1h5.46a1.5 1.5 0 0 1 1.42 1l2.1 6v2a1.5 1.5 0 0 1-1.5 1.5h-9.5a1.5 1.5 0 0 1-1.5-1.5Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"})]})}export const Empty=/*@__PURE__*/n.forwardRef(function Empty(v,$){const{variant:E="text",size:L="md",color:z="secondary",density:B="default",elevation:C=0,title:I,icon:T,action:W,locale:F,transition:M,render:R,className:V,style:Z,children:q,...A}=j(v,["size","density","variant","locale"]),D=i(o,F),G=void 0===I?D.title:I,H=void 0===T?e(TrayIcon,{}):T,J=s(M),K=c(G),O=n.isValidElement(R)&&("td"===R.type||"th"===R.type),{role:P,...Q}=A,S="role"in A?P:"status",U=m("flex w-full flex-col items-center justify-center text-center",a[B][L],N[B][L],p[L],u[L],g,w[E],J.className),X={...b(z,C),...J.style},Y=t(r,{children:[c(H)?e("span",{className:`flex items-center text-(--neba-muted-fg) ${k[L]} ${d}`,children:H}):null,K||c(q)?t("div",{className:`flex max-w-prose flex-col items-center ${f[L]}`,children:[K?e("div",{className:`${h} font-semibold ${y[L]}`,children:G}):null,c(q)?e("div",{className:`${x[L]} ${K?"text-(--neba-muted-fg)":""}`,children:q}):null]}):null,c(W)?e("div",{className:"flex flex-wrap items-center justify-center gap-2",children:W}):null]});return l({render:R,ref:$,props:O?{className:V,style:Z,children:e("div",{role:S,className:U,style:X,children:Y}),...Q}:{role:S,className:m(U,V??""),style:{...X,...Z},children:Y,...Q}})});
|
|
@@ -82,14 +82,6 @@ export interface FilePickerProps extends NebaStyleProps, Omit<React.ComponentPro
|
|
|
82
82
|
*/
|
|
83
83
|
id?: string;
|
|
84
84
|
}
|
|
85
|
-
/**
|
|
86
|
-
* `1.4 MB`, in the units a person reading a file list expects.
|
|
87
|
-
*
|
|
88
|
-
* Base 1000 rather than 1024, and `MB` rather than `MiB`: it is the number every
|
|
89
|
-
* operating system's file browser shows, and a picker that disagrees with the
|
|
90
|
-
* Finder about how big the file is has picked a fight it cannot win.
|
|
91
|
-
*/
|
|
92
|
-
export declare function formatFileSize(bytes: number): string;
|
|
93
85
|
/**
|
|
94
86
|
* A box you drop files on, or click to open the file dialog.
|
|
95
87
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as n}from"react/jsx-runtime";import*as
|
|
1
|
+
"use client";import{jsx as e,jsxs as n}from"react/jsx-runtime";import*as r from"react";import{formatFileSize as t}from"./formatFileSize.js";import{useLayoutEffectOnClient as l}from"../../internal/layout-effect.js";import{useDropZone as a}from"../../internal/drop.js";import{glowClasses as o,spotlightSlot as i,trackPointer as s}from"../../internal/glow.js";import{CloseIcon as c}from"../../internal/icons.js";import{fileMessages as d,fillMessage as u,useMessages as f}from"../../internal/i18n.js";import{controlTextLeadingClasses as m,cx as p,disabledClasses as b,gapClasses as h,hasContent as v,hitAreaClasses as x,iconClasses as g,metaTextClasses as y,radiusClasses as j,readOnlyFilterClasses as k,sheetTitleClasses as N,stackGapClasses as $,surfaceClasses as w,surfaceSlots as z,transitionClasses as C}from"../../internal/styles.js";import{useStyleDefaults as I}from"../../internal/defaults.js";import{useFieldsetDisabled as _}from"../../internal/fieldset.js";const L={default:{xs:"p-4",sm:"p-5",md:"p-6",lg:"p-8",xl:"p-10"},compact:{xs:"p-2",sm:"p-3",md:"p-4",lg:"p-5",xl:"p-6"}},M={solid:[w,"border-2 border-dashed text-(--neba-fg) bg-(--n-panel-hover)","[border-color:var(--n-line)]","[box-shadow:var(--n-elev),var(--neba-plate-glass)]"].join(" "),outline:[w,"border-2 border-dashed text-(--neba-fg) bg-(--n-panel)","[border-color:var(--n-line)]","[box-shadow:var(--n-elev),var(--neba-plate-glass)]"].join(" "),text:"border-2 border-dashed text-(--neba-fg) bg-transparent [border-color:var(--n-line)]"},W={solid:"hover:bg-(--n-panel-press) hover:[border-color:var(--n-line-hover)]",outline:"hover:bg-(--n-panel-hover) hover:[border-color:var(--n-line-hover)]",text:"hover:bg-(--n-soft) hover:[border-color:var(--n-line-hover)]"};function UploadIcon(){return n("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[e("path",{d:"M8 10.5V2.75m0 0L5.25 5.5M8 2.75 10.75 5.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M2.75 9.75v1.75a1.75 1.75 0 0 0 1.75 1.75h7a1.75 1.75 0 0 0 1.75-1.75V9.75",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function E(e,n){const r=e.name.toLowerCase(),t=e.type.toLowerCase();return n.split(",").map(e=>e.trim().toLowerCase()).filter(Boolean).some(e=>e.startsWith(".")?r.endsWith(e):e.endsWith("/*")?t.startsWith(`${e.slice(0,-1)}`):t===e)}export const FilePicker=/*@__PURE__*/r.forwardRef(function FilePicker(w,F){const{variant:R="outline",size:S="md",color:T="primary",density:P="default",elevation:V=0,accept:q,multiple:A=!1,maxSize:B,maxFiles:D,value:O,defaultValue:U,onFilesChange:H,onReject:Y,label:G,description:J,error:K,invalid:Q,title:X,hint:Z,icon:ee,showList:ne=!0,removeLabel:re,fullWidth:te=!0,disabled:le,readOnly:ae=!1,required:oe=!1,name:ie,id:se,locale:ce,className:de,style:ue,...fe}=I(w,["size","density","variant","locale"]),me=_(le),pe=f(d,ce),be=re??(e=>u(pe.remove,{name:e})),he=r.useRef(null);r.useImperativeHandle(F,()=>he.current);const[ve,xe]=r.useState(()=>[...U??[]]),ge=r.useMemo(()=>O?[...O]:ve,[O,ve]),ye=v(K),je=Q??ye,ke=je?"danger":T,Ne=me||ae,$e=r.useId(),we=r.useId(),ze=r.useId(),Ce=se??ze,Ie=r.useCallback(e=>{O||xe(e),H?.(e)},[H,O]),_e=r.useCallback(e=>{const n=[],r=[],t=A?D??Number.POSITIVE_INFINITY:1,l=A?ge.length:0;for(const a of e)q&&!E(a,q)?r.push({file:a,reason:"type"}):void 0!==B&&a.size>B?r.push({file:a,reason:"size"}):l+n.length>=t?r.push({file:a,reason:"count"}):n.push(a);return{kept:n,rejections:r}},[q,ge.length,D,B,A]),Le=r.useCallback(e=>{const{kept:n,rejections:r}=_e(e);r.length>0&&Y?.(r),n.length>0&&Ie(A?[...ge,...n]:n)},[_e,Ie,ge,A,Y]),{over:Me,handlers:We}=a(Ne?void 0:Le),Ee=r.useRef(null),Fe=r.useRef(null),Re=r.useRef(null);l(()=>{const e=Re.current;if(null===e)return;Re.current=null;const n=Fe.current?.querySelectorAll("li button")??[],r=n[Math.min(e,n.length-1)]??Ee.current;r?.focus()},[ge]);const Se=r.useCallback(()=>{const e=he.current;if(e&&"undefined"!=typeof DataTransfer)try{const n=new DataTransfer;ge.forEach(e=>n.items.add(e)),e.files=n.files}catch{}},[ge]);r.useEffect(()=>{Se();const e=he.current;return e?.addEventListener("cancel",Se),()=>e?.removeEventListener("cancel",Se)},[Se]);const Te=p("flex w-full flex-col items-center justify-center text-center","cursor-pointer select-none",L[P][S],j[S],h[S],C,g,"focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2",me?`${b[R]} border-2 border-dashed`:ae?`${M[R]} ${k} cursor-default`:M[R],Ne?"":`${W[R]} ${o}`,Me&&!Ne?"bg-(--n-soft-press) [border-color:var(--n-ring)]":"");return n("div",{className:p("flex-col align-top",$[S],te?"flex w-full":"inline-flex",de??""),style:{...z(ke,V),...Ne?void 0:i,...ue},...fe,children:[v(G)?e("span",{id:we,className:[y[S],"font-medium",me?"text-(--neba-disabled-fg)":"text-(--neba-fg)"].join(" "),children:G}):null,n("div",{className:"flex w-full flex-col",...We,children:[n("button",{ref:Ee,onPointerMove:s(void 0,!Ne),type:"button",id:Ce,disabled:me,"aria-labelledby":v(G)?`${we} ${Ce}`:void 0,"aria-describedby":v(J)||ye?$e:void 0,"aria-invalid":je||void 0,className:Te,onClick:()=>{Ne||he.current&&(he.current.value="",he.current.click())},children:[void 0===ee?e("span",{className:"flex items-center text-(--n-accent) [&_svg]:size-[1.8em]",children:e(UploadIcon,{})}):v(ee)?e("span",{className:"flex items-center text-(--n-accent) [&_svg]:size-[1.8em]",children:ee}):null,e("span",{className:`font-medium ${N[S]}`,children:X??pe.title}),v(Z)?e("span",{className:`text-(--neba-muted-fg) ${y[S]}`,children:Z}):null]}),e("input",{ref:he,type:"file",name:ie,accept:q,multiple:A,required:oe&&0===ge.length,disabled:me,tabIndex:-1,"aria-hidden":"true",className:"absolute size-px overflow-hidden opacity-0 [clip-path:inset(50%)]",onChange:e=>Le(Array.from(e.target.files??[]))})]}),ne&&ge.length>0?e("ul",{ref:Fe,role:"list",className:`flex w-full flex-col ${$[S]} m-0 list-none p-0`,children:ge.map((r,l)=>n("li",{className:["flex w-full items-center gap-2 px-2 py-1.5",j.xs,m[S],"bg-(--n-soft) text-(--neba-fg)"].join(" "),children:[e("span",{className:"min-w-0 flex-1 truncate",children:r.name}),e("span",{className:`shrink-0 text-(--neba-muted-fg) tabular-nums ${y[S]}`,children:t(r.size)}),Ne?null:e("button",{type:"button","aria-label":be(r.name),className:["relative inline-flex shrink-0 cursor-pointer items-center justify-center rounded-full",x,"size-[1.3em] text-(--neba-muted-fg) opacity-70","[transition:opacity_var(--neba-duration)_var(--neba-ease),color_var(--neba-duration)_var(--neba-ease)]","[&_svg]:size-[0.9em]","hover:text-(--neba-fg) hover:opacity-100 focus-visible:opacity-100","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-1"].join(" "),onClick:e=>{Re.current=e.currentTarget===document.activeElement?l:null,Ie(ge.filter((e,n)=>n!==l))},children:e(c,{})})]},`${r.name}-${r.size}-${r.lastModified}-${l}`))}):null,v(J)&&!ye?e("span",{id:$e,className:`${y[S]} text-(--neba-muted-fg)`,children:J}):null,ye?e("span",{id:$e,className:`${y[S]} text-(--n-accent)`,children:K}):null]})});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `1.4 MB`, in the units a person reading a file list expects.
|
|
3
|
+
*
|
|
4
|
+
* Base 1000 rather than 1024, and `MB` rather than `MiB`: it is the number every
|
|
5
|
+
* operating system's file browser shows, and a picker that disagrees with the
|
|
6
|
+
* Finder about how big the file is has picked a fight it cannot win.
|
|
7
|
+
*/
|
|
8
|
+
export declare function formatFileSize(bytes: number): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function formatFileSize(e){if(e<1e3)return`${e} B`;const t=["kB","MB","GB","TB"];let r=e/1e3,n=0;for(;r>=1e3&&n<t.length-1;)r/=1e3,n+=1;return`${r<10?r.toFixed(1):Math.round(r)} ${t[n]}`}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{FilePicker
|
|
1
|
+
export{FilePicker}from"./FilePicker.js";export{formatFileSize}from"./formatFileSize.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as a from"react";import{
|
|
1
|
+
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as a from"react";import{useLayoutEffectOnClient as n}from"../../internal/layout-effect.js";import{useRender as r}from"@base-ui/react/use-render";import{barMinHeightClasses as o,BottomNavigationContext as s}from"../../internal/bottom-navigation.js";import{observeResize as i}from"../../internal/observe.js";import{cx as l,surfaceClasses as d,surfaceSlots as f,transitionClasses as u}from"../../internal/styles.js";import{useStyleDefaults as p}from"../../internal/defaults.js";const m={solid:[d,"text-(--neba-fg) bg-(--n-panel-press)","[box-shadow:var(--n-elev),var(--neba-plate-solid)]"].join(" "),outline:[d,"border text-(--neba-fg) bg-(--n-panel-hover)","[border-color:var(--n-line)]","[box-shadow:var(--n-elev),var(--neba-plate-glass)]"].join(" "),text:"text-(--neba-fg) bg-transparent"},v={static:"relative mx-auto w-fit",absolute:"absolute inset-x-0 bottom-(--n-nav-offset) z-30 mx-auto w-fit",sticky:"sticky bottom-(--n-nav-offset) z-30 mx-auto w-fit",fixed:"fixed inset-x-0 bottom-(--n-nav-offset) z-40 mx-auto w-fit"},c={default:{xs:"p-1",sm:"p-1",md:"p-1.5",lg:"p-1.5",xl:"p-2"},compact:{xs:"p-0.5",sm:"p-0.5",md:"p-1",lg:"p-1",xl:"p-1"}},b={solid:`${d} bg-(--n-panel-hover) [box-shadow:var(--neba-shadow-1),var(--neba-plate-glass)]`,outline:`${d} bg-(--n-soft-hover) [box-shadow:var(--neba-shadow-1),var(--neba-plate-glass)]`,text:"bg-(--n-soft-hover)"},x={xs:"gap-0.5",sm:"gap-0.5",md:"gap-1",lg:"gap-1",xl:"gap-1.5"};export const FloatingBottomNavigation=/*@__PURE__*/a.forwardRef(function FloatingBottomNavigation(d,g){const{variant:y="outline",size:h="md",color:w="primary",density:j="default",elevation:$=2,value:z,defaultValue:N=null,onValueChange:k,position:A="fixed",offset:P=16,labels:C="selected",safeArea:E=!0,disabled:L=!1,label:R,render:B,className:F,style:S,children:V,...W}=p(d,["size","density","variant"]),[q,H]=a.useState(N),M=void 0!==z,T=M?z:q,D=a.useCallback(e=>{M||H(e),k?.(e)},[M,k]),G=a.useMemo(()=>({value:T??null,change:D,size:h,density:j,labels:C,disabled:L,floating:!0}),[T,D,h,j,C,L]),I=a.useRef(null),J=a.useRef(null),K=a.useCallback(e=>{I.current=e,"function"==typeof g?g(e):g&&(g.current=e)},[g]),O=a.useCallback(e=>{const t=I.current,a=J.current;if(!t||!a)return;const n=t.querySelector("[data-nav-item][aria-current]");if(a.hidden=!n,!n)return void a.removeAttribute("data-ready");const r=!e||!a.hasAttribute("data-ready");r&&a.removeAttribute("data-ready"),a.style.setProperty("--n-nav-x",`${n.offsetLeft}px`),a.style.setProperty("--n-nav-y",`${n.offsetTop}px`),a.style.setProperty("--n-nav-w",`${n.offsetWidth}px`),a.style.setProperty("--n-nav-h",`${n.offsetHeight}px`),r&&a.offsetWidth,a.setAttribute("data-ready","")},[]);n(()=>{O(!0)},[O,T,y,h,j,C,V]),a.useEffect(()=>{const e=I.current;if(!e)return;const t=e=>{"grid-template-columns"===e.propertyName&&O(!0)},a=i(e,()=>O(!1));return e.addEventListener("transitionend",t),()=>{a(),e.removeEventListener("transitionend",t)}},[O]);const Q="number"==typeof P?`${P}px`:P,U=l("flex max-w-full min-w-0 items-center rounded-full",o[h],c[j][h],x[h],m[y],v[A],u,F);return r({render:B??e("nav",{}),ref:K,props:{"aria-label":R,className:U,style:{...f(w,$),"--n-nav-offset":E?`calc(${Q} + env(safe-area-inset-bottom))`:Q,...S},children:t(s.Provider,{value:G,children:[null!=T?e("span",{ref:J,"aria-hidden":"true",className:l("pointer-events-none absolute rounded-full","top-(--n-nav-y) left-(--n-nav-x) h-(--n-nav-h) w-(--n-nav-w)",b[y],"[transition-property:left,top,width,height]","[transition-timing-function:var(--neba-ease)]","[transition-duration:0ms] data-[ready]:[transition-duration:var(--neba-duration)]","motion-reduce:[transition-duration:0ms]")}):null,V]}),...W}})});
|
|
@@ -35,6 +35,19 @@ export interface NebaGalleryItem {
|
|
|
35
35
|
title?: React.ReactNode;
|
|
36
36
|
/** The second, one step down the scale and muted. */
|
|
37
37
|
description?: React.ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* The same picture at other widths, as an `<img>` takes them, so a tile drawn
|
|
40
|
+
* 300 pixels wide is not sent a 4000-pixel original. The viewer is handed it
|
|
41
|
+
* too when the item has no `full`, and chooses a candidate for its own size.
|
|
42
|
+
*/
|
|
43
|
+
srcSet?: string;
|
|
44
|
+
/**
|
|
45
|
+
* How wide the tile is drawn, for the browser to choose from `srcSet` by:
|
|
46
|
+
* `'(min-width: 64rem) 25vw, (min-width: 40rem) 33vw, 50vw'` for the default
|
|
47
|
+
* columns across the whole page. Left out, the browser assumes the tile is as
|
|
48
|
+
* wide as the window.
|
|
49
|
+
*/
|
|
50
|
+
sizes?: string;
|
|
38
51
|
/**
|
|
39
52
|
* A larger file for the viewer, when the tile is a thumbnail. Falls back to
|
|
40
53
|
* `src`, so a set that has only one size of each picture needs nothing here.
|
|
@@ -122,10 +135,21 @@ export interface GalleryProps extends Omit<React.ComponentPropsWithoutRef<'ul'>,
|
|
|
122
135
|
* When the tiles' files load. `lazy` waits until a tile is near the screen,
|
|
123
136
|
* so a wall of forty photographs asks for the few a reader can see rather
|
|
124
137
|
* than all forty at once. Set `eager` when the gallery is the largest thing
|
|
125
|
-
* above the fold, where a lazy first row arrives later than it should
|
|
138
|
+
* above the fold, where a lazy first row arrives later than it should, or
|
|
139
|
+
* leave this alone and give `priority` the length of that row.
|
|
126
140
|
* @default 'lazy'
|
|
127
141
|
*/
|
|
128
142
|
loading?: 'lazy' | 'eager';
|
|
143
|
+
/**
|
|
144
|
+
* How many tiles, counted from the first item, are pictures the page is
|
|
145
|
+
* judged by. Each of them is an Image with `priority`: fetched early and
|
|
146
|
+
* never lazily whatever `loading` says, and drawn from the first paint with
|
|
147
|
+
* no fade and no Skeleton. For a gallery whose first row is the largest thing
|
|
148
|
+
* above the fold, it is the length of that row; the tiles after it keep
|
|
149
|
+
* `loading`.
|
|
150
|
+
* @default 0
|
|
151
|
+
*/
|
|
152
|
+
priority?: number;
|
|
129
153
|
/**
|
|
130
154
|
* Where a tile's `title` and `description` go. `below` puts them under the
|
|
131
155
|
* picture, `overlay` writes them across the foot of it, and `hover` is
|
|
@@ -148,8 +172,9 @@ export interface GalleryProps extends Omit<React.ComponentPropsWithoutRef<'ul'>,
|
|
|
148
172
|
* Opens the picture full size when a tile is clicked, with the rest of the
|
|
149
173
|
* set an arrow key away.
|
|
150
174
|
*
|
|
151
|
-
* The viewer is fetched
|
|
152
|
-
*
|
|
175
|
+
* The viewer is fetched when a pointer, the focus or a finger first reaches
|
|
176
|
+
* the gallery, and mounted by the press that opens it: a Gallery nobody
|
|
177
|
+
* reaches for does not carry it, and a server render does not wait on it.
|
|
153
178
|
* @default false
|
|
154
179
|
*/
|
|
155
180
|
preview?: boolean;
|
|
@@ -175,6 +200,23 @@ export interface GalleryProps extends Omit<React.ComponentPropsWithoutRef<'ul'>,
|
|
|
175
200
|
/** Class names for the parts behind the root. */
|
|
176
201
|
classNames?: NebaSlots<GallerySlot>;
|
|
177
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* The one request for the viewer's chunk, shared by everything that asks.
|
|
205
|
+
*
|
|
206
|
+
* Asked for when a pointer arrives over the gallery, when the focus reaches a
|
|
207
|
+
* tile or when a finger lands on one, so the download is under way before the
|
|
208
|
+
* press that opens it; and by `React.lazy` at that press, which is handed the
|
|
209
|
+
* same promise and waits only for what is left of it. A request that fails is
|
|
210
|
+
* forgotten, so the next one tries again rather than failing for good.
|
|
211
|
+
*
|
|
212
|
+
* An object rather than a function so a test can spy on it. Exported for that,
|
|
213
|
+
* and deliberately left out of the barrel.
|
|
214
|
+
*/
|
|
215
|
+
export declare const viewerChunk: {
|
|
216
|
+
load(): Promise<{
|
|
217
|
+
default: typeof import("./GalleryViewer.js").GalleryViewer;
|
|
218
|
+
}>;
|
|
219
|
+
};
|
|
178
220
|
/**
|
|
179
221
|
* Whether an item is turned onto its side, whatever number its turn was written
|
|
180
222
|
* as. Exported for the viewer, and deliberately left out of the barrel.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as t,Fragment as i}from"react/jsx-runtime";import*as
|
|
1
|
+
"use client";import{jsx as e,jsxs as t,Fragment as i}from"react/jsx-runtime";import*as o from"react";import{Image as r}from"../image/Image.js";import{breakpoints as a,hiddenBelowClasses as l,hiddenFromClasses as n,responsiveSlots as s,valueAt as u,withBaseline as c}from"../../internal/responsive.js";import{useBreakpointValue as d}from"../../hooks/useMediaQuery.js";import{useHydrated as m}from"../../internal/media.js";import{fillMessage as p,galleryMessages as f,useMessages as h}from"../../internal/i18n.js";import{cx as g,hasContent as x,metaTextClasses as b,radiusClasses as v,sheetTitleClasses as w,toLength as y,transitionClasses as j}from"../../internal/styles.js";import{useStyleDefaults as N}from"../../internal/defaults.js";let k;export const viewerChunk={load:()=>(k??=import("./GalleryViewer.js").then(e=>({default:e.GalleryViewer})).catch(e=>{throw k=void 0,e}),k)};const M=o.lazy(()=>viewerChunk.load()),$={xs:2,sm:3,lg:4},S={xs:"0.25rem",sm:"0.375rem",md:"0.5rem",lg:"0.75rem",xl:"1rem"};function _(e,t){if(void 0===e)return t;if("number"==typeof e)return e>0?e:t;const[i,o]=e.split("/"),r=void 0===o?Number(i):Number(i)/Number(o);return Number.isFinite(r)&&r>0?r:t}export function isSideways(e){return Math.abs(Math.round((e.rotate??0)/90))%2==1}export function shownRatioOf(e,t){const i=_(e.ratio,t);return void 0!==e.ratio&&isSideways(e)?1/i:i}const z={none:"",lift:"group-hover/tile:[box-shadow:var(--neba-shadow-2)] group-has-[:focus-visible]/tile:[box-shadow:var(--neba-shadow-2)] supports-[not_selector(:has(*))]:group-focus-within/tile:[box-shadow:var(--neba-shadow-2)]",dim:"",zoom:""},R={none:"",lift:"",dim:"group-hover/tile:[filter:brightness(0.82)] group-has-[:focus-visible]/tile:[filter:brightness(0.82)] supports-[not_selector(:has(*))]:group-focus-within/tile:[filter:brightness(0.82)]",zoom:"group-hover/tile:[transform:scale(1.06)] group-has-[:focus-visible]/tile:[transform:scale(1.06)] supports-[not_selector(:has(*))]:group-focus-within/tile:[transform:scale(1.06)]"};export const Gallery=/*@__PURE__*/o.forwardRef(function Gallery(k,C){const{items:q,layout:F="grid",columns:G,gap:A="md",ratio:I=1,rowHeight:O=220,rounded:E="md",fit:T="cover",letterbox:P,loading:V="lazy",priority:B=0,caption:H="none",hover:Q="lift",preview:W=!1,onItemSelect:D,filter:J,frame:K,watermark:L,protect:U=!1,label:X,locale:Y,empty:Z,className:ee,classNames:te,style:ie,onPointerEnter:oe,onFocus:re,onTouchStart:ae,...le}=N(k,["locale"]),ne=h(f,Y),se=o.useId(),[ue,ce]=o.useState(null),[de,me]=o.useState(!1),pe=o.useRef(!1),fe=()=>{W&&!pe.current&&(pe.current=!0,viewerChunk.load().catch(()=>{}))},he=c(G??$,2),ge=Math.max(1,d(he)??2),xe=m(),be="string"==typeof A&&A in S?S[A]:y(A)??S.md,ve=!1===E?"":v[!0===E?"md":E],we=_(I,1),ye=(o,a,l)=>{const n=x(o.title)||x(o.description),s="none"!==H&&n,u="overlay"===H||"hover"===H,c=`${se}-${a}-title`,d=`${se}-${a}-description`,m=`${se}-${a}-position`,f=p(ne.item,{index:String(a+1),total:String(q.length)}),h=a<B,v=e(r,{src:o.src,srcSet:o.srcSet,sizes:o.sizes,alt:o.alt,ratio:"grid"===F?I:"quilted"===F?"auto":void 0!==o.ratio&&isSideways(o)?shownRatioOf(o,we):o.ratio??I,fit:T,position:o.position,letterbox:P,rotate:o.rotate,flip:o.flip,placeholder:o.placeholder,loading:h?void 0:V,priority:h,rounded:!1,filter:J,frame:K,watermark:L,protect:U,className:g("size-full",te?.image),classNames:{image:g("motion-reduce:[transition-duration:0ms]",R[Q])}}),y=s?t("span",{className:g("min-w-0",u?g("pointer-events-none absolute inset-x-0 bottom-0 flex flex-col gap-0.5 p-2.5 text-white","[background:linear-gradient(to_top,color-mix(in_oklab,#000_72%,transparent),transparent)]","hover"===H?"opacity-0 group-hover/tile:opacity-100 group-has-[:focus-visible]/tile:opacity-100 supports-[not_selector(:has(*))]:group-focus-within/tile:opacity-100 [@media(hover:none)]:opacity-100 [transition:opacity_var(--neba-duration-fill)_var(--neba-ease)]":""):"flex flex-col gap-0.5 pt-1.5",te?.caption),children:[x(o.title)?e("span",{id:c,className:g("truncate font-medium",w.sm,u?"":"text-(--neba-fg)",te?.title),children:o.title}):null,x(o.description)?e("span",{id:d,className:g("truncate",b.md,u?"text-white/80":"text-(--neba-muted-fg)",te?.description),children:o.description}):null]}):null,N=t("span",{className:g("relative block overflow-hidden",ve,"quilted"===F||"justified"===F?"size-full":"","[transition:box-shadow_var(--neba-duration)_var(--neba-ease)]",z[Q]),children:[v,u?y:null]}),k=u||!s?N:t(i,{children:[N,y]});return e("li",{className:g("group/tile relative m-0 min-w-0 list-none","justified"===F?"flex flex-col":"",te?.item),style:l,children:W||D?t("button",{type:"button","aria-label":s?void 0:`${o.alt} — ${f}`,"aria-labelledby":s?`${x(o.title)?c:d} ${m}`:void 0,"aria-haspopup":W?"dialog":void 0,"aria-describedby":s&&x(o.title)&&x(o.description)?d:void 0,className:g("block w-full text-start",W?"cursor-zoom-in":"cursor-pointer",j,"focus-visible:[outline:2px_solid_var(--n-ring,var(--neba-primary-ring))] focus-visible:[outline-offset:2px]",ve,"justified"===F?"flex-1":""),onClick:()=>(e=>{D?.(q[e],e),W&&(me(!0),ce(e))})(a),children:[k,s?e("span",{id:m,hidden:!0,children:f}):null]}):k},o.id??o.src)},je=g("neba-gallery m-0 list-none p-0","justified"===F?"neba-gallery-justified flex flex-wrap":"","masonry"===F?"flex items-start":"","grid"===F||"quilted"===F?"grid":"",ee??""),Ne={gap:be,...s("cols",he,e=>String(Math.max(1,Math.round(e)))),..."grid"===F||"quilted"===F?{gridTemplateColumns:"repeat(var(--n-cols), minmax(0, 1fr))"}:null,..."quilted"===F?{gridAutoRows:`${O}px`,gridAutoFlow:"dense"}:null,...ie};let ke;if("masonry"===F){const t=q.map(e=>shownRatioOf(e,we)),i=(i,o)=>function(e,t){const i=Array.from({length:t},()=>[]),o=new Array(t).fill(0);return e.forEach((e,r)=>{let a=0;for(let e=1;e<t;e+=1)o[e]<o[a]&&(a=e);i[a].push(r),o[a]+=1/e}),i}(t,i).map((t,r)=>e("li",{className:g("m-0 flex min-w-0 flex-1 list-none flex-col",o),style:{gap:be},children:e("ul",{className:"m-0 flex list-none flex-col p-0",style:{gap:be},children:t.map(e=>ye(q[e],e,{}))})},`${i}-${r}`)),o=a.map(e=>({breakpoint:e,count:Math.max(1,Math.round(u(he,e)??2))})),r=o.filter((e,t)=>0===t||e.count!==o[t-1].count);ke=xe||1===r.length?i(Math.max(1,Math.round(ge)),""):r.flatMap((e,t)=>{const o=r[t+1];return i(e.count,g(l[e.breakpoint],o?n[o.breakpoint]:""))})}else ke="justified"===F?q.map((e,t)=>{const i=shownRatioOf(e,we);return ye(e,t,{flexGrow:i,flexBasis:i*O+"px",maxWidth:"100%"})}):q.map((e,t)=>ye(e,t,"quilted"===F?{gridColumn:`span ${Math.max(1,Math.round(e.cols??1))}`,gridRow:`span ${Math.max(1,Math.round(e.rows??1))}`}:{}));return 0===q.length&&x(Z)?e(i,{children:Z}):t(i,{children:[e("ul",{ref:C,role:"list","aria-label":X??ne.label,className:je,style:Ne,...le,onPointerEnter:e=>{fe(),oe?.(e)},onFocus:e=>{fe(),re?.(e)},onTouchStart:e=>{fe(),ae?.(e)},children:ke}),W&&de?e(o.Suspense,{fallback:null,children:e(M,{items:q,index:ue,onIndexChange:ce,locale:Y,watermark:L,protect:U,messages:ne})}):null]})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Dialog as l}from"../dialog/Dialog.js";import{IconButton as n}from"../icon-button/IconButton.js";import{Image as
|
|
1
|
+
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Dialog as l}from"../dialog/Dialog.js";import{IconButton as n}from"../icon-button/IconButton.js";import{Image as i}from"../image/Image.js";import{ChevronIcon as a}from"../../internal/icons.js";import{fillMessage as r}from"../../internal/i18n.js";import{cx as o,hasContent as s,metaTextClasses as c,srOnlyClasses as m}from"../../internal/styles.js";import{isSideways as d,shownRatioOf as u}from"./Gallery.js";export function GalleryViewer({items:p,index:f,onIndexChange:h,locale:v,watermark:x,protect:g,messages:b}){const j=null!==f,y=null===f?void 0:p[f],N=null===f||f<=0,w=null===f||f>=p.length-1,k=y?.title??y?.alt,D=void 0!==y&&d(y),C=D&&void 0!==y.ratio?u(y,1):null,S=e=>{e>=0&&e<p.length&&h(e)};return e(l,{open:j,onOpenChange:e=>{e||h(null)},size:"xl",locale:v,title:y?.title??y?.alt??"",description:y?.description,onKeyDown:e=>{if(null===f||e.metaKey||e.ctrlKey||e.altKey)return;const t="rtl"===getComputedStyle(e.currentTarget).direction?-1:1;"ArrowRight"===e.key?(e.preventDefault(),S(f+t)):"ArrowLeft"===e.key&&(e.preventDefault(),S(f-t))},children:t("div",{className:"flex flex-col gap-3",children:[t("div",{className:"relative flex items-center justify-center",children:[y?e(i,{src:y.full??y.src,srcSet:void 0===y.full?y.srcSet:void 0,alt:y.alt,ratio:C??"auto",fit:"contain",rounded:"md",rotate:y.rotate,flip:y.flip,watermark:x,protect:g,className:D?null===C?"max-h-[70vh]":void 0:"max-h-[70vh] w-auto",classNames:D?void 0:{image:"max-h-[70vh] w-auto object-contain"},style:D?{width:null===C?"100%":`min(100%, calc(70vh * ${C}))`}:void 0},y.id??y.src):null,p.length>1?t("div",{className:"pointer-events-none absolute inset-x-0 flex items-center justify-between px-1",children:[e(n,{variant:"solid",elevation:1,label:b.previous,disabled:N,focusableWhenDisabled:!0,className:"pointer-events-auto",icon:e("span",{className:"flex items-center rotate-90 rtl:-rotate-90",children:e(a,{})}),onClick:()=>S((f??0)-1)}),e(n,{variant:"solid",elevation:1,label:b.next,disabled:w,focusableWhenDisabled:!0,className:"pointer-events-auto",icon:e("span",{className:"flex items-center -rotate-90 rtl:rotate-90",children:e(a,{})}),onClick:()=>S((f??0)+1)})]}):null]}),p.length>1?t("p",{className:o("m-0 text-center text-(--neba-muted-fg)",c.md),"aria-live":"polite","aria-atomic":"true",children:[s(k)?t("span",{className:m,children:[k,", "]}):null,e("span",{children:r(b.item,{index:String((f??0)+1),total:String(p.length)})})]}):null]})})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as t,jsxs as a,Fragment as e}from"react/jsx-runtime";import*as n from"react";import{ChartSurface as r,useMeasuredWidth as l,chartHeight as s,useMeasuredHeight as i}from"../../internal/chart-frame.js";import{arcPath as o,chartFontSizes as m,compactNumber as h,ringPath as c,textWidth as f,truncate as u}from"../../internal/chart.js";import{numberFormatter as d}from"../../internal/format.js";import{emptyMessages as x,useMessages as p}from"../../internal/i18n.js";import{thresholdColor as M}from"../../internal/progress.js";import{cx as g,hasContent as b,metaTextClasses as v}from"../../internal/styles.js";import{useStyleDefaults as y}from"../../internal/defaults.js";function N(t,a,e,n){const r=(n-90)*Math.PI/180;return[t+e*Math.cos(r),a+e*Math.sin(r)]}export function GaugeChart(
|
|
1
|
+
"use client";import{jsx as t,jsxs as a,Fragment as e}from"react/jsx-runtime";import*as n from"react";import{ChartSurface as r,useMeasuredWidth as l,chartHeight as s,useMeasuredHeight as i}from"../../internal/chart-frame.js";import{arcPath as o,chartFontSizes as m,compactNumber as h,ringPath as c,textWidth as f,truncate as u}from"../../internal/chart.js";import{numberFormatter as d}from"../../internal/format.js";import{emptyMessages as x,useMessages as p}from"../../internal/i18n.js";import{thresholdColor as M}from"../../internal/progress.js";import{cx as g,hasContent as b,metaTextClasses as v}from"../../internal/styles.js";import{useStyleDefaults as y}from"../../internal/defaults.js";import{useIntlLocale as j}from"../../internal/media.js";function N(t,a,e,n){const r=(n-90)*Math.PI/180;return[t+e*Math.cos(r),a+e*Math.sin(r)]}export function GaugeChart(k){const{value:w,min:z=0,max:S=100,sweep:$=180,thickness:W=.22,thresholds:q,ticks:A=!1,showRange:B=!0,center:C,caption:D,height:I,format:L,locale:P,label:R,empty:F,size:G="md",variant:Y="text",color:E="primary",padded:H=!1,className:J,...K}=y(k,["size","variant","locale"]),O=n.useRef(null),Q=l(O),T=p(x,P),U=j(P),V=n.useCallback(t=>L?d(U,L).format(t):h(t,U),[L,U]),X=Math.max(1,Math.min(360,$)),Z=X/2,_=-Z,tt=Z,at=S-z,et=null===w||Number.isNaN(w)||0===at?null:Math.min(1,Math.max(0,(w-z)/at)),nt=null===w?E:M(w,E,q),rt=i(O,"string"==typeof I),lt=s(I,G,rt),st=m[G],it=Math.min(.9,Math.max(.05,W)),ot=Z*Math.PI/180,mt=X>=360?1:Math.max(0,-Math.cos(ot)),ht=X>=180?1:Math.sin(ot),ct=Math.sin(ot),ft=-Math.cos(ot),ut=B&&X<330?[z,S].map(t=>u(V(t),Math.max(0,.28*Q),st)):[],dt=ut.reduce((t,a)=>Math.max(t,f(a,st)),0),xt=.35*st,pt=!1===A?0:.85*st,Mt=ft<=.25,gt=Mt?0:.5*st,bt=Mt?st:st*(.35+.55*ft),vt=ut.length>0?ft*gt+bt+.25*st:0,yt=Math.max(xt,pt),jt=Math.max(xt,pt),Nt=Math.max(xt,pt,vt),kt=[(Q/2-yt)/Math.max(.05,ht),(lt-jt-Nt)/(1+mt)];if(dt>0&&ct>.05){const t=Mt?dt/2:dt;kt.push(Math.max(0,Q/2-xt-t)/ct-gt)}const wt=Math.max(0,Math.min(...kt)),zt=wt*(1-it),St=Q/2,$t=jt+wt*(1+mt)+Nt,Wt=jt+wt+Math.max(0,(lt-$t)/2),qt=Q>0,At=0===at||qt&&wt<=0,Bt=b(D)?1.85*st:0,Ct=Wt-zt*(1-Math.min(1,mt))/2,Dt=Math.min(zt,Math.abs(Wt-Ct)),It=Math.min(zt,Math.abs(Wt-Ct-Bt/2)),Lt=2*Math.sqrt(Math.max(0,zt*zt-It*It)),Pt=C??(null===w?"—":V(w)),Rt="string"==typeof Pt?f(Pt,1):0,Ft=Rt>0?Math.max(st,Math.min(2*st,function(t,a,e,n,r){const l=t*t/(4*r*r)+n*n,s=2*a*n,i=a*a-e*e;return l<=0||i>=0?0:(Math.sqrt(s*s-4*l*i)-s)/(2*l)}(Rt,Dt,zt,.42,.86))):2*st,Gt=!1===A?0:Math.max(2,Math.floor(A));return t(r,{...K,variant:Y,color:E,size:G,padded:H,legendSide:"bottom",className:J,legend:null,table:null,children:t("div",{ref:O,className:"relative w-full",style:{height:"string"==typeof I?I:lt},...void 0===R?{}:null===et||null===w?{role:"img","aria-label":R}:{role:"meter","aria-label":R,"aria-valuenow":w,"aria-valuemin":z,"aria-valuemax":S,"aria-valuetext":["string"==typeof Pt||"number"==typeof Pt?String(Pt):V(w),"string"==typeof D||"number"==typeof D?String(D):""].filter(Boolean).join(" ")},children:At?t("div",{className:g("flex h-full items-center justify-center text-(--neba-muted-fg)",v[G]),children:F??T.title}):qt?a(e,{children:[a("svg",{width:Q,height:lt,viewBox:`0 0 ${Q} ${lt}`,"aria-hidden":"true",className:"block",children:[t("path",{d:o(St,Wt,wt,zt,_,tt),fill:`var(--neba-${E}-soft)`}),null!==et?t("path",{d:c(St,Wt,(wt+zt)/2,_,tt),fill:"none",stroke:`var(--neba-${nt}-fill)`,strokeWidth:wt-zt,pathLength:"1",strokeDasharray:"1",strokeDashoffset:1-et,style:{transition:"stroke-dashoffset var(--neba-duration-fill) var(--neba-ease), stroke var(--neba-duration) var(--neba-ease)"}}):null,Gt>0?Array.from({length:Gt},(a,e)=>{const n=_+X*e/(Gt-1),[r,l]=N(St,Wt,wt+.25*st,n),[s,i]=N(St,Wt,wt+.6*st,n);return t("line",{x1:r,y1:l,x2:s,y2:i,stroke:"var(--neba-chart-grid)",strokeWidth:1,strokeLinecap:"round"},e)}):null,ut.length>0?[[ut[0],_,"start"],[ut[1],tt,"end"]].map(([a,e,n])=>{const[r,l]=N(St,Wt,wt+gt,e);return t("text",{x:r,y:l+bt,textAnchor:Mt?"middle":"start"===n?"end":"start",fontSize:st,fill:"var(--neba-muted-fg)",children:a},n)}):null]}),a("div",{className:"pointer-events-none absolute inset-x-0 mx-auto flex flex-col items-center gap-0.5 text-center",style:{top:Ct+Bt/2,maxWidth:Lt,transform:"translateY(-50%)"},children:[t("span",{className:"font-semibold tabular-nums text-(--neba-fg)",style:{fontSize:Ft},children:Pt}),D?t("span",{className:g("text-(--neba-muted-fg)",v[G]),children:D}):null]})]}):a("div",{className:"flex h-full flex-col items-center justify-center gap-0.5 text-center",children:[t("span",{className:"font-semibold tabular-nums text-(--neba-fg)",style:{fontSize:2*st},children:Pt}),D?t("span",{className:g("text-(--neba-muted-fg)",v[G]),children:D}):null]})})})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as
|
|
1
|
+
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{chartTableClasses as l,ChartExport as i,ChartScaleLegend as a,ChartStatus as r,ChartSummary as o,ChartSurface as d,ChartTooltipPanel as s,markTransitionClasses as h,summarise as m,useDeferredRows as c,useMeasuredWidth as u,useReleaseOutside as x,chartHeight as f,useMeasuredHeight as p}from"../../internal/chart-frame.js";import{categoryAt as g,chartFontSizes as w,compactNumber as v,formatCategory as b,markGap as y,rampFill as M,rampInk as k,rampStep as A,rampSteps as $,squarify as N,textWidth as j,toValues as z,truncate as E,turnedAxis as S}from"../../internal/chart.js";import{numberFormatter as B}from"../../internal/format.js";import{cx as C,metaTextClasses as D}from"../../internal/styles.js";import{chartMessages as I,emptyMessages as F,useMessages as L}from"../../internal/i18n.js";import{useStyleDefaults as W}from"../../internal/defaults.js";import{useIntlLocale as H}from"../../internal/media.js";export function HeatmapChart(l){const{series:c,categories:T,shape:U="grid",scale:_="sequential",midpoint:q=0,min:J,max:K,valueLabels:O="none",xAxis:G,yAxis:Q,height:V,format:X,locale:Y,label:Z,legend:ee,tooltip:te,empty:ne,exportable:le=!1,exportFileName:ie="chart.csv",onExport:ae,size:re="md",variant:oe="text",padded:de=!1,className:se,...he}=W(l,["size","variant","locale"]),me=n.useRef(null),ce=u(me),ue=L(F,Y),xe=L(I,Y),fe=H(Y),pe=n.useId(),[ge,we]=n.useState(null);x(me,null!==ge,()=>we(null));const ve=n.useId(),be=X?JSON.stringify(X):"",ye=n.useCallback(e=>X?B(fe,X).format(e):v(e,fe),[be,fe]),Me=n.useMemo(()=>z(c),[c]),ke=Me.reduce((e,t)=>Math.max(e,t.length),0),Ae=n.useMemo(()=>Array.from({length:ke},(e,t)=>g(t,T,Me)),[ke,T,Me]),$e=n.useMemo(()=>c.map((e,t)=>e.name??`${t+1}`),[c]),Ne=n.useMemo(()=>{let e=1/0,t=-1/0,n=!1;for(const l of Me)for(const i of l)null!==i.value&&(n=!0,e=Math.min(e,i.value),t=Math.max(t,i.value));return n?{min:e,max:t}:null},[Me]),je=J??Ne?.min??0,ze=K??Ne?.max??1,Ee=n.useCallback(e=>A(e,je,ze,_,q),[je,ze,_,q]),Se=p(me,"string"==typeof V),Be=f(V,re,Se),Ce=w[re],De=!0===ee||void 0===ee||!1===ee?{}:ee,Ie=!1!==ee,Fe=De.side??"bottom",Le=!1===te?{mode:"none"}:!0===te||void 0===te?{}:te,We="none"===Le.mode,He=null===Ne||0===ke||0===c.length,Pe=Q?.tickFormat,Re="treemap"===U||Q?.hidden,Te=n.useMemo(()=>{if(Re||ce<=0)return{texts:[],band:0};const e=Math.min(150,.25*ce),t=$e.map((t,n)=>E(Pe?String(Pe(t,n)):t,e,Ce));return{texts:t,band:t.reduce((e,t)=>Math.max(e,j(t,Ce)),0)+10}},[Re,$e,Pe,ce,Ce]),Ue="treemap"===U?0:G?.tickAngle,_e=n.useMemo(()=>S(Ue,Ce),[Ue,Ce]),qe=G?.tickFormat,Je=n.useMemo(()=>Ae.map((e,t)=>qe?String(qe(e,t)):b(e,fe)),[Ae,qe,fe]),Ke=Math.min(140,.4*Be),Oe=n.useMemo(()=>0===_e.angle?Je:Je.map(e=>E(e,_e.cut(Ke),Ce)),[Je,_e,Ke,Ce]),Ge=Oe.reduce((e,t)=>Math.max(e,j(t,Ce)),0),Qe=Ce+6,Ve="treemap"===U||G?.hidden?0:_e.depth(Ge)+8+(G?.label?Qe:0),Xe=Boolean(Q?.label)&&!Re,Ye=(Xe?Qe+2:0)+(le?20:0),Ze={left:Q?.thickness??Te.band,top:Ye,width:Math.max(0,ce-(Q?.thickness??Te.band)),height:Math.max(0,Be-(G?.thickness??Ve)-Ye)},et=n.useMemo(()=>{if(Ze.width<=0||Ze.height<=0)return[];if("treemap"===U){const e=[];return Me.forEach((t,n)=>t.forEach((t,l)=>{null!==t.value&&e.push({row:n,index:l,cell:t})})),N(e.map(e=>Math.max(0,e.cell.value??0)),Ze.width,Ze.height).map(t=>({row:e[t.index].row,index:e[t.index].index,cell:e[t.index].cell,x:Ze.left+t.x,y:Ze.top+t.y,width:t.width,height:t.height}))}const e=Ze.height/Math.max(1,c.length),t=Ze.width/Math.max(1,ke),n=[];return Me.forEach((l,i)=>l.forEach((l,a)=>{null!==l.value&&n.push({row:i,index:a,cell:l,x:Ze.left+a*t,y:Ze.top+i*e,width:t,height:e})})),n},[U,Me,c.length,ke,Ze.left,Ze.top,Ze.width,Ze.height]),tt=n.useCallback(e=>b(e.cell.x??T?.[e.index]??Ae[e.index]??e.index,fe),[T,Ae,fe]),nt=n.useMemo(()=>{const e=Me.reduce((e,t)=>e+t.length,0);if("treemap"!==U)return{heads:Ae.map(e=>b(e,fe)),rows:Me.map(e=>Ae.map((t,n)=>e[n])),points:e};const t=[],n=new Map,l=Me.map(e=>{const l=[];return e.forEach((e,i)=>{const a=b(e.x??T?.[i]??Ae[i]??i,fe);let r=n.get(a);void 0===r&&(r=t.length,n.set(a,r),t.push(a)),l[r]=e}),l});return{heads:t,rows:l,points:e}},[U,Ae,Me,T,fe]),lt=null===ge?null:et.find(e=>e.row===ge.row&&e.index===ge.index)??null,it=null===lt?[]:[{seriesIndex:lt.row,color:lt.cell.color??M(Ee(lt.cell.value??0),_),value:lt.cell.value,formatted:ye(lt.cell.value??0),label:lt.cell.label}],at=Array.from({length:$},(e,t)=>M(t,_));return t(d,{...he,size:re,variant:oe,padded:de,className:se,legendSide:Fe,legend:Ie&&!He?e(a,{steps:at,from:ye("diverging"===_?-R(je,ze,q)+q:je),to:ye("diverging"===_?R(je,ze,q)+q:ze),middle:"diverging"===_?ye(q):void 0,align:De.align??"center",vertical:"left"===Fe||"right"===Fe,size:re}):null,table:He?null:e(P,{id:pe,caption:Z,heads:nt.heads,rows:nt.rows,names:$e,points:nt.points,format:ye}),children:[le&&!He?e(i,{rows:()=>[["",...nt.heads],...nt.rows.map((e,t)=>[$e[t],...nt.heads.map((t,n)=>e[n]?.value??null)])],fileName:ie,onExport:ae,label:xe.exportCsv}):null,t("div",{ref:me,role:"img",tabIndex:He?void 0:0,"aria-label":Z??xe.label,"aria-describedby":He?void 0:ve,onPointerLeave:e=>{"touch"!==e.pointerType&&we(null)},onBlur:()=>we(null),onKeyDown:e=>{if(We||0===et.length)return;const t=null===ge?-1:et.findIndex(e=>e.row===ge.row&&e.index===ge.index),n="treemap"!==U&&-1!==t,l="ArrowRight"===e.key||"ArrowDown"===e.key;if(!n||"ArrowDown"!==e.key&&"ArrowUp"!==e.key)if(l||"ArrowLeft"===e.key||"ArrowUp"===e.key){const e=l?et[Math.min(et.length-1,t+1)]:et[Math.max(0,(-1===t?et.length:t)-1)];we({row:e.row,index:e.index})}else{if("Escape"!==e.key)return;we(null)}else{const n=et[t],l="ArrowDown"===e.key,i=et.filter(e=>e.index===n.index&&(l?e.row>n.row:e.row<n.row)).sort((e,t)=>l?e.row-t.row:t.row-e.row)[0];i&&we({row:i.row,index:i.index})}e.preventDefault()},className:C("relative w-full rounded-(--neba-radius-xs)","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2"),style:{height:"string"==typeof V?V:Be},children:[He?e("div",{className:C("flex h-full items-center justify-center text-(--neba-muted-fg)",D[re]),children:ne??ue.title}):ce>0?t("svg",{width:ce,height:Be,viewBox:`0 0 ${ce} ${Be}`,"aria-hidden":"true",className:"block",children:[et.map(n=>{const l=Ee(n.cell.value??0),i=ge?.row===n.row&&ge?.index===n.index,a=Math.max(0,n.width-y),r=Math.max(0,n.height-y);if(a<=0||r<=0)return null;const o=ye(n.cell.value??0),d="treemap"===U?"all"===O?[tt(n),o]:[tt(n)]:"all"===O?[o]:[],s=d.filter(e=>function(e,t,n,l){return n>=1.8*l&&t>=Math.min(j(e,l),2.5*l)+8}(e,a,r/d.length,Ce)),m=n.cell.color?"var(--neba-surface)":k(l,_);return t("g",{children:[e("rect",{x:n.x+y/2,y:n.y+y/2,width:a,height:r,rx:Math.min(3,a/2,r/2),fill:n.cell.color??M(l,_),opacity:i?1:.94,onPointerEnter:We?void 0:()=>we({row:n.row,index:n.index}),className:h}),s.map((t,l)=>e("text",{x:n.x+n.width/2,y:n.y+n.height/2+(l-(s.length-1)/2)*(Ce+2),textAnchor:"middle",dominantBaseline:"central",fontSize:Ce,fontWeight:0===l?500:400,fill:m,opacity:0===l?1:.85,pointerEvents:"none",className:0===l&&"treemap"===U?void 0:"tabular-nums",children:E(t,n.width-8,Ce)},l))]},`${n.row}-${n.index}`)}),"grid"!==U||Q?.hidden?null:Te.texts.map((t,n)=>e("text",{x:Ze.left-8,y:Ze.top+(n+.5)*Ze.height/Math.max(1,c.length),textAnchor:"end",dominantBaseline:"central",fontSize:Ce,fill:"var(--neba-muted-fg)",children:t},`row-${n}`)),"grid"!==U||G?.hidden?null:Oe.map((t,n)=>{const l=Ze.width/Math.max(1,ke);if(n%Math.max(1,Math.ceil(_e.room(Ge)/Math.max(1,l)))!==0)return null;const i=Ze.left+(n+.5)*l,a=Ze.top+Ze.height+_e.offset-6;return e("text",{x:i,y:a,textAnchor:_e.anchor,transform:0===_e.angle?void 0:`rotate(${_e.angle} ${i} ${a})`,dominantBaseline:0===_e.angle?void 0:"central",fontSize:Ce,fill:"var(--neba-muted-fg)",children:t},`col-${n}`)}),Xe?e("text",{x:Ze.left,y:Ce+2,textAnchor:"start",fontSize:Ce,fill:"var(--neba-muted-fg)",fontWeight:500,children:Q?.label}):null,"grid"===U&&G?.label&&!G.hidden?e("text",{x:Ze.left+Ze.width,y:Ze.top+Ze.height+_e.depth(Ge)+Ce+8,textAnchor:"end",fontSize:Ce,fill:"var(--neba-muted-fg)",fontWeight:500,children:G.label}):null]}):null,lt&&!We?Le.render?e("div",{className:"pointer-events-none absolute z-10",style:{left:lt.x+lt.width/2,top:lt.y},children:Le.render({index:lt.index,category:lt.cell.x??Ae[lt.index]??lt.index,items:it})}):e(s,{heading:`${$e[lt.row]} · ${tt(lt)}`,items:it,x:lt.x+lt.width/2,y:lt.y,flip:lt.x+lt.width/2>.6*ce,size:re}):null]}),He?null:e(o,{id:ve,template:xe.summary,locale:fe,...m(Me,ye)}),We?null:e(r,{heading:lt?`${$e[lt.row]} · ${tt(lt)}`:void 0,items:it})]})}const P=/*@__PURE__*/n.memo(function HeatmapTable({id:n,caption:i,heads:a,rows:r,names:o,points:d,format:s}){const h=c({rows:r.length,points:d,columns:a.length+1});return t("table",{id:n,className:l,"aria-busy":h<r.length||void 0,children:[i?e("caption",{children:i}):null,e("thead",{children:t("tr",{children:[e("th",{scope:"col"}),a.map((t,n)=>e("th",{scope:"col",children:t},n))]})}),e("tbody",{children:r.slice(0,h).map((n,l)=>t("tr",{children:[e("th",{scope:"row",children:o[l]}),a.map((t,l)=>{const i=n[l];return e("td",{children:void 0!==i?.label?i.label:null==i?.value?"":s(i.value)},l)})]},l))})]})});function R(e,t,n){return Math.max(Math.abs(t-n),Math.abs(n-e))}
|
|
@@ -20,6 +20,20 @@ export interface HowToStep {
|
|
|
20
20
|
image?: string;
|
|
21
21
|
/** What that picture says for a reader who cannot see it. Defaults to `title`. */
|
|
22
22
|
imageAlt?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The picture's own pixel dimensions, as an `<img>` takes them. Together they
|
|
25
|
+
* are its proportion, which the browser reserves before the file arrives, so
|
|
26
|
+
* the panel is the right height from the first paint rather than growing as
|
|
27
|
+
* the pictures land. They are not a size: the picture still spans the panel.
|
|
28
|
+
*/
|
|
29
|
+
imageWidth?: number;
|
|
30
|
+
imageHeight?: number;
|
|
31
|
+
/**
|
|
32
|
+
* When the picture is fetched. `lazy` waits until the guide is near the
|
|
33
|
+
* screen; `eager` is for a guide at the top of the page.
|
|
34
|
+
* @default 'lazy'
|
|
35
|
+
*/
|
|
36
|
+
imageLoading?: 'lazy' | 'eager';
|
|
23
37
|
}
|
|
24
38
|
export interface HowToStepsProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'title' | 'content'> {
|
|
25
39
|
/**
|