neba 1.8.1 → 1.9.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/README.md +7 -7
- package/dist/components/accordion/Accordion.js +1 -1
- package/dist/components/alert/Alert.js +1 -1
- package/dist/components/anchor/Anchor.d.ts +73 -0
- package/dist/components/anchor/Anchor.js +1 -0
- package/dist/components/anchor/index.d.ts +2 -0
- package/dist/components/anchor/index.js +1 -0
- package/dist/components/animate-marquee/AnimateMarquee.js +1 -1
- package/dist/components/app-logo/AppLogo.js +1 -1
- package/dist/components/aspect-ratio/AspectRatio.js +1 -1
- package/dist/components/avatar/Avatar.js +1 -1
- package/dist/components/avatar-group/AvatarGroup.d.ts +47 -0
- package/dist/components/avatar-group/AvatarGroup.js +1 -0
- package/dist/components/avatar-group/index.d.ts +2 -0
- package/dist/components/avatar-group/index.js +1 -0
- package/dist/components/badge/Badge.js +1 -1
- package/dist/components/blockquote/Blockquote.js +1 -1
- package/dist/components/box/Box.js +1 -1
- package/dist/components/button/Button.js +1 -1
- package/dist/components/button-group/ButtonGroup.js +1 -1
- package/dist/components/card/Card.js +1 -1
- package/dist/components/carousel/Carousel.js +1 -1
- package/dist/components/chat-bubble/ChatBubble.js +1 -1
- package/dist/components/checkbox/Checkbox.js +1 -1
- package/dist/components/combobox/Combobox.js +1 -1
- package/dist/components/command-palette/CommandPalette.d.ts +88 -0
- package/dist/components/command-palette/CommandPalette.js +1 -0
- package/dist/components/command-palette/index.d.ts +2 -0
- package/dist/components/command-palette/index.js +1 -0
- package/dist/components/container/Container.js +1 -1
- package/dist/components/data-list/DataList.d.ts +55 -0
- package/dist/components/data-list/DataList.js +1 -0
- package/dist/components/data-list/index.d.ts +2 -0
- package/dist/components/data-list/index.js +1 -0
- package/dist/components/data-table/DataTable.js +1 -1
- package/dist/components/dialog/Dialog.js +1 -1
- package/dist/components/divider/Divider.js +1 -1
- package/dist/components/drawer/Drawer.js +1 -1
- package/dist/components/empty/Empty.js +1 -1
- package/dist/components/fieldset/Fieldset.d.ts +33 -0
- package/dist/components/fieldset/Fieldset.js +1 -0
- package/dist/components/fieldset/index.d.ts +2 -0
- package/dist/components/fieldset/index.js +1 -0
- package/dist/components/file-picker/FilePicker.js +1 -1
- package/dist/components/floating-bottom-navigation/FloatingBottomNavigation.js +1 -1
- package/dist/components/form/Form.d.ts +58 -0
- package/dist/components/form/Form.js +1 -0
- package/dist/components/form/index.d.ts +2 -0
- package/dist/components/form/index.js +1 -0
- package/dist/components/gauge-chart/GaugeChart.d.ts +62 -0
- package/dist/components/gauge-chart/GaugeChart.js +1 -0
- package/dist/components/gauge-chart/index.d.ts +2 -0
- package/dist/components/gauge-chart/index.js +1 -0
- package/dist/components/grid/Grid.js +1 -1
- package/dist/components/grid-container/GridContainer.js +1 -1
- package/dist/components/heatmap-chart/HeatmapChart.js +1 -1
- package/dist/components/highlight/Highlight.js +1 -1
- package/dist/components/hover-card/HoverCard.d.ts +78 -0
- package/dist/components/hover-card/HoverCard.js +1 -0
- package/dist/components/hover-card/index.d.ts +2 -0
- package/dist/components/hover-card/index.js +1 -0
- package/dist/components/how-to-steps/HowToSteps.d.ts +11 -25
- package/dist/components/how-to-steps/HowToSteps.js +1 -1
- package/dist/components/icon/Icon.js +1 -1
- package/dist/components/list/List.js +1 -1
- package/dist/components/menu/Menu.d.ts +16 -4
- package/dist/components/menu/Menu.js +1 -1
- package/dist/components/menubar/Menubar.d.ts +56 -0
- package/dist/components/menubar/Menubar.js +1 -0
- package/dist/components/menubar/index.d.ts +2 -0
- package/dist/components/menubar/index.js +1 -0
- package/dist/components/meter/Meter.d.ts +52 -0
- package/dist/components/meter/Meter.js +1 -0
- package/dist/components/meter/index.d.ts +2 -0
- package/dist/components/meter/index.js +1 -0
- package/dist/components/mockup/Mockup.js +1 -1
- package/dist/components/navigation-menu/NavigationMenu.d.ts +100 -0
- package/dist/components/navigation-menu/NavigationMenu.js +1 -0
- package/dist/components/navigation-menu/index.d.ts +2 -0
- package/dist/components/navigation-menu/index.js +1 -0
- package/dist/components/number-field/NumberField.js +1 -1
- package/dist/components/otp-field/OtpField.js +1 -1
- package/dist/components/overlay/Overlay.js +1 -1
- package/dist/components/page-layout/PageLayout.js +1 -1
- package/dist/components/pagination/Pagination.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/popover/Popover.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/radio-group/RadioGroup.js +1 -1
- package/dist/components/rating/Rating.js +1 -1
- package/dist/components/scroll-area/ScrollArea.d.ts +50 -0
- package/dist/components/scroll-area/ScrollArea.js +1 -0
- package/dist/components/scroll-area/index.d.ts +2 -0
- package/dist/components/scroll-area/index.js +1 -0
- package/dist/components/scroll-zone/ScrollZone.d.ts +35 -17
- 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/shortcut/Shortcut.js +1 -1
- package/dist/components/sidebar/Sidebar.js +1 -1
- package/dist/components/skeleton/Skeleton.js +1 -1
- package/dist/components/slider/Slider.js +1 -1
- package/dist/components/spoiler/Spoiler.js +1 -1
- package/dist/components/statistic/Statistic.js +1 -1
- package/dist/components/switch/Switch.js +1 -1
- package/dist/components/table/Table.js +1 -1
- 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/toast/Toast.js +1 -1
- package/dist/components/toggle/Toggle.d.ts +53 -0
- package/dist/components/toggle/Toggle.js +1 -0
- package/dist/components/toggle/index.d.ts +2 -0
- package/dist/components/toggle/index.js +1 -0
- package/dist/components/toggle-group/ToggleGroup.d.ts +51 -0
- package/dist/components/toggle-group/ToggleGroup.js +1 -0
- package/dist/components/toggle-group/index.d.ts +2 -0
- package/dist/components/toggle-group/index.js +1 -0
- package/dist/components/toolbar/Toolbar.js +1 -1
- package/dist/components/tooltip/Tooltip.js +1 -1
- package/dist/components/tour/Tour.d.ts +82 -0
- package/dist/components/tour/Tour.js +1 -0
- package/dist/components/tour/index.d.ts +2 -0
- package/dist/components/tour/index.js +1 -0
- package/dist/components/transfer/Transfer.d.ts +52 -0
- package/dist/components/transfer/Transfer.js +1 -0
- package/dist/components/transfer/index.d.ts +2 -0
- package/dist/components/transfer/index.js +1 -0
- package/dist/components/tree-view/TreeView.js +1 -1
- package/dist/components/typography/Typography.js +1 -1
- package/dist/components/window-pane/WindowPane.js +1 -1
- package/dist/index.d.ts +16 -0
- package/dist/index.js +1 -1
- package/dist/internal/animate.d.ts +7 -1
- package/dist/internal/animate.js +1 -1
- package/dist/internal/avatar-group.d.ts +22 -0
- package/dist/internal/avatar-group.js +1 -0
- package/dist/internal/button-group.d.ts +6 -2
- package/dist/internal/chart-frame.d.ts +18 -1
- package/dist/internal/chart-frame.js +1 -1
- package/dist/internal/data-table.d.ts +0 -14
- package/dist/internal/data-table.js +1 -1
- package/dist/internal/drag.d.ts +62 -0
- package/dist/internal/drag.js +1 -0
- package/dist/internal/highlight.js +1 -1
- package/dist/internal/i18n.d.ts +82 -0
- package/dist/internal/i18n.js +1 -1
- package/dist/internal/link.d.ts +19 -0
- package/dist/internal/link.js +1 -0
- package/dist/internal/media.d.ts +29 -0
- package/dist/internal/media.js +1 -0
- package/dist/internal/observe.d.ts +42 -0
- package/dist/internal/observe.js +1 -0
- package/dist/internal/page-layout.js +1 -1
- package/dist/internal/picker.js +1 -1
- package/dist/internal/progress.d.ts +5 -0
- package/dist/internal/search.d.ts +33 -0
- package/dist/internal/search.js +1 -0
- package/dist/internal/styles.d.ts +39 -0
- 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 +104 -0
- package/dist/types.d.ts +16 -0
- package/package.json +2 -2
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ChartBaseProps } from '../../internal/chart-frame.js';
|
|
3
|
+
import type { NebaThreshold } from '../../types.js';
|
|
4
|
+
export interface GaugeChartProps extends Omit<ChartBaseProps, 'legend' | 'tooltip'> {
|
|
5
|
+
/**
|
|
6
|
+
* The reading. `null` draws the dial with nothing on it, which is the honest
|
|
7
|
+
* picture of an instrument that has not been told anything.
|
|
8
|
+
*/
|
|
9
|
+
value: number | null;
|
|
10
|
+
/** @default 0 */
|
|
11
|
+
min?: number;
|
|
12
|
+
/** @default 100 */
|
|
13
|
+
max?: number;
|
|
14
|
+
/**
|
|
15
|
+
* How far round the dial goes, in degrees, opened symmetrically about twelve
|
|
16
|
+
* o'clock. `180` is the half-dial a dashboard tile wants; `270` is the
|
|
17
|
+
* instrument shape; `360` is a ring.
|
|
18
|
+
* @default 180
|
|
19
|
+
*/
|
|
20
|
+
sweep?: number;
|
|
21
|
+
/** How thick the arc is, as a fraction of its radius. @default 0.22 */
|
|
22
|
+
thickness?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Where the arc changes colour — the same `{ from, color }` entries a
|
|
25
|
+
* [Meter](../feedback/meter) takes, and with the same rule: the last one the
|
|
26
|
+
* value has reached wins, and below all of them `color` stands.
|
|
27
|
+
*/
|
|
28
|
+
thresholds?: readonly NebaThreshold[];
|
|
29
|
+
/**
|
|
30
|
+
* How many marks are drawn around the dial, ends included. `false` — the
|
|
31
|
+
* default — draws none: a gauge on a dashboard is read as a proportion, and
|
|
32
|
+
* ticks are for an instrument somebody takes a *number* off.
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
ticks?: number | false;
|
|
36
|
+
/** Writes `min` and `max` at the two ends of the arc. @default true */
|
|
37
|
+
showRange?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* What goes in the middle. Left out, it is the value written through `format`
|
|
40
|
+
* — which is what the dial is for, so replacing it is for adding to it rather
|
|
41
|
+
* than for taking it away.
|
|
42
|
+
*/
|
|
43
|
+
center?: React.ReactNode;
|
|
44
|
+
/** A line under the value: the unit, or what is being measured. */
|
|
45
|
+
caption?: React.ReactNode;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* One number on a scale that is known in advance, drawn as a dial.
|
|
49
|
+
*
|
|
50
|
+
* It is a [Meter](../feedback/meter) bent into an arc, and the two are
|
|
51
|
+
* deliberately the same component in two shapes: `value`, `min`, `max` and
|
|
52
|
+
* `thresholds` mean exactly what they mean there, so a page can move a reading
|
|
53
|
+
* from a bar to a dial without changing what it says. Reach for the bar in a
|
|
54
|
+
* row of fields and for this one in a tile of its own, where a dial reads at a
|
|
55
|
+
* glance from across a room and a four-pixel bar does not.
|
|
56
|
+
*
|
|
57
|
+
* It is not a [PieChart](./pie-chart) with `shape="semi"`. A pie is *parts of a
|
|
58
|
+
* whole* and every slice is a category; this is one value against a scale, and
|
|
59
|
+
* the unfilled part of the arc is not a second category — it is the rest of the
|
|
60
|
+
* dial.
|
|
61
|
+
*/
|
|
62
|
+
export declare function GaugeChart({ value, min, max, sweep, thickness, thresholds, ticks, showRange, center, caption, height, format, locale, label, empty, size, variant, color, padded, className, ...box }: GaugeChartProps): React.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsx as t,jsxs as e,Fragment as a}from"react/jsx-runtime";import*as n from"react";import{ChartSurface as l,useMeasuredWidth as r}from"../../internal/chart-frame.js";import{arcPath as i,chartFontSizes as s,compactNumber as o,plotHeights as m}from"../../internal/chart.js";import{numberFormatter as h}from"../../internal/format.js";import{emptyMessages as c,useMessages as d}from"../../internal/i18n.js";import{cx as u,metaTextClasses as f}from"../../internal/styles.js";function x(t,e,a,n){const l=(n-90)*Math.PI/180;return[t+a*Math.cos(l),e+a*Math.sin(l)]}export function GaugeChart({value:p,min:b=0,max:v=100,sweep:g=180,thickness:M=.22,thresholds:y,ticks:N=!1,showRange:j=!0,center:k,caption:$,height:w,format:z,locale:I,label:P,empty:S,size:A="md",variant:C="text",color:R="primary",padded:B=!1,className:F,...G}){const L=n.useRef(null),W=r(L),Y=d(c,I),q=n.useCallback(t=>z?h(I,z).format(t):o(t,I),[z,I]),D=Math.max(1,Math.min(360,g)),E=D/2,H=-E,J=E,K=v-b,O=null===p||Number.isNaN(p)||0===K?null:Math.min(1,Math.max(0,(p-b)/K)),Q=null===p?R:function(t,e,a){if(!a||0===a.length)return e;let n=e;for(const e of a)t>=e.from&&(n=e.color);return n}(p,R,y),T="number"==typeof w?w:m[A],U=s[A],V=D>=360?1:Math.max(0,-Math.cos(E*Math.PI/180)),X=D>=180?1:Math.sin(E*Math.PI/180),Z=U*(j?1.6:.6),_=Math.max(0,Math.min((W-2*Z)/(2*X),(T-Z*(V>0?2:1))/(1+V))),tt=_*(1-Math.min(.9,Math.max(.05,M))),et=W/2,at=Z+_,nt=_<=0||0===K,lt=null===O?H:H+D*O,rt=at-_+_*(1+V)/2,it=!1===N?0:Math.max(2,Math.floor(N));return t(l,{...G,variant:C,color:R,size:A,padded:B,legendSide:"bottom",className:F,legend:null,table:null,children:t("div",{ref:L,className:"relative w-full",style:{height:T},role:void 0===P?void 0:"img","aria-label":void 0===P?void 0:null===p?P:`${P}: ${q(p)} / ${q(v)}`,children:nt?t("div",{className:u("flex h-full items-center justify-center text-(--neba-muted-fg)",f[A]),children:S??Y.title}):W>0?e(a,{children:[e("svg",{width:W,height:T,viewBox:`0 0 ${W} ${T}`,"aria-hidden":"true",className:"block",children:[t("path",{d:i(et,at,_,tt,H,J),fill:`var(--neba-${R}-soft)`}),null!==O&&O>0?t("path",{d:i(et,at,_,tt,H,lt),fill:`var(--neba-${Q}-fill)`,style:{transition:"fill var(--neba-duration) var(--neba-ease)"}}):null,it>0?Array.from({length:it},(e,a)=>{const n=H+D*a/(it-1),[l,r]=x(et,at,_+.25*U,n),[i,s]=x(et,at,_+.6*U,n);return t("line",{x1:l,y1:r,x2:i,y2:s,stroke:"var(--neba-chart-grid)",strokeWidth:1,strokeLinecap:"round"},a)}):null,j?[[b,H,"start"],[v,J,"end"]].map(([e,a,n])=>{const[l,r]=x(et,at,(_+tt)/2,a);return t("text",{x:l+(D>=300?0:"start"===n?.6*-U:.6*U),y:r+U*(D>=300?1.4:.35),textAnchor:D>=300?"middle":"start"===n?"end":"start",fontSize:U,fill:"var(--neba-muted-fg)",children:q(e)},n)}):null]}),e("div",{className:"pointer-events-none absolute inset-x-0 flex flex-col items-center gap-0.5",style:{top:rt,transform:"translateY(-50%)"},children:[t("span",{className:"font-semibold tabular-nums text-(--neba-fg)",style:{fontSize:2*U},children:k??(null===p?"—":q(p))}),$?t("span",{className:u("text-(--neba-muted-fg)",f[A]),children:$}):null]})]}):null})})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{GaugeChart}from"./GaugeChart.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import*as e from"react";import{useRender as r}from"@base-ui/react/use-render";import{alignSelfClasses as
|
|
1
|
+
"use client";import*as e from"react";import{useRender as r}from"@base-ui/react/use-render";import{alignSelfClasses as s,offsetValue as t,responsiveSlots as n,spanValue as i}from"../../internal/grid.js";import{cx as o}from"../../internal/styles.js";export const Grid=/*@__PURE__*/e.forwardRef(function({span:e,offset:a,alignSelf:f,render:l,className:m,style:c,children:d,...p},u){const g=o("neba-grid-item",f?s[f]:"",m??"");return r({render:l,ref:u,props:{className:g,style:{...n("span",e,i),...n("offset",a,t),...c},children:d,...p}})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import*as e from"react";import{useRender as r}from"@base-ui/react/use-render";import{alignContentClasses as n,alignItemsClasses as a,columnCount as
|
|
1
|
+
"use client";import*as e from"react";import{useRender as r}from"@base-ui/react/use-render";import{alignContentClasses as n,alignItemsClasses as a,columnCount as t,justifyContentClasses as o,responsiveSlots as s,spacingValue as i,withBaseline as p}from"../../internal/grid.js";import{boxPaddingClasses as l}from"../box/Box.js";import{cx as c}from"../../internal/styles.js";export const GridContainer=/*@__PURE__*/e.forwardRef(function({columns:e,spacing:m,rowSpacing:d,columnSpacing:f,justifyContent:g,alignItems:u,alignContent:x,wrap:y=!0,padded:w=!0,size:j="md",density:b="default",render:C,className:h,style:N,children:S,...z},B){const G=c("neba-grid flex",y?"flex-wrap":"flex-nowrap","gap-x-(--n-gap-x) gap-y-(--n-gap-y)",w?l[b][j]:"",g?o[g]:"",u?a[u]:"",x?n[x]:"",h??"");return r({render:C,ref:B,props:{className:G,style:{...s("cols",p(e,12),t),...s("gap-x",p(f??m,2),i),...s("gap-y",p(d??m,2),i),...N},children:S,...z}})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as l from"react";import{ChartScaleLegend as n,
|
|
1
|
+
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as l from"react";import{ChartScaleLegend as n,ChartStatus as i,ChartSurface as a,ChartTooltipPanel as r,useMeasuredWidth as o}from"../../internal/chart-frame.js";import{categoryAt as d,chartFontSizes as h,compactNumber as s,formatCategory as c,markGap as m,plotHeights as u,rampFill as x,rampInk as f,rampStep as g,rampSteps as p,squarify as v,textWidth as w,toValues as b,truncate as y}from"../../internal/chart.js";import{numberFormatter as M}from"../../internal/format.js";import{cx as $,metaTextClasses as j,srOnlyClasses as k}from"../../internal/styles.js";import{chartMessages as A,emptyMessages as N,useMessages as z}from"../../internal/i18n.js";export function HeatmapChart({series:S,categories:B,shape:C="grid",scale:I="sequential",midpoint:_=0,min:D,max:L,valueLabels:P="none",height:R,format:q,locale:H,label:K,legend:U,tooltip:W,empty:F,size:G="md",variant:J="text",padded:O=!1,className:Q,...T}){const V=l.useRef(null),X=o(V),Y=z(N,H),Z=z(A,H),ee=l.useId(),[te,le]=l.useState(null),ne=l.useCallback(e=>q?M(H,q).format(e):s(e,H),[q,H]),ie=l.useMemo(()=>b(S),[S]),ae=ie.reduce((e,t)=>Math.max(e,t.length),0),re=l.useMemo(()=>Array.from({length:ae},(e,t)=>d(t,B,ie)),[ae,B,ie]),oe=l.useMemo(()=>S.map((e,t)=>e.name??`${t+1}`),[S]),de=l.useMemo(()=>{let e=1/0,t=-1/0,l=!1;for(const n of ie)for(const i of n)null!==i.value&&(l=!0,e=Math.min(e,i.value),t=Math.max(t,i.value));return l?{min:e,max:t}:null},[ie]),he=D??de?.min??0,se=L??de?.max??1,ce=l.useCallback(e=>g(e,he,se,I,_),[he,se,I,_]),me="number"==typeof R?R:u[G]??220,ue=h[G],xe=!0===U||void 0===U||!1===U?{}:U,fe=!1!==U,ge=xe.side??"bottom",pe=!1===W?{mode:"none"}:!0===W||void 0===W?{}:W,ve="none"===pe.mode,we=null===de||0===ae||0===S.length,be=l.useMemo(()=>{if("treemap"===C||X<=0)return{texts:[],band:0};const e=Math.min(150,.25*X),t=oe.map(t=>y(t,e,ue));return{texts:t,band:t.reduce((e,t)=>Math.max(e,w(t,ue)),0)+10}},[C,oe,X,ue]),ye="treemap"===C?0:ue+8,Me={left:be.band,width:Math.max(0,X-be.band),height:Math.max(0,me-ye)},$e=l.useMemo(()=>{if(Me.width<=0||Me.height<=0)return[];if("treemap"===C){const e=[];return ie.forEach((t,l)=>t.forEach((t,n)=>{null!==t.value&&e.push({row:l,index:n,cell:t})})),v(e.map(e=>Math.max(0,e.cell.value??0)),Me.width,Me.height).map(t=>({row:e[t.index].row,index:e[t.index].index,cell:e[t.index].cell,x:Me.left+t.x,y:t.y,width:t.width,height:t.height}))}const e=Me.height/Math.max(1,S.length),t=Me.width/Math.max(1,ae),l=[];return ie.forEach((n,i)=>n.forEach((n,a)=>{null!==n.value&&l.push({row:i,index:a,cell:n,x:Me.left+a*t,y:i*e,width:t,height:e})})),l},[C,ie,S.length,ae,Me.left,Me.width,Me.height]),je=l.useCallback(e=>c(e.cell.x??B?.[e.index]??re[e.index]??e.index,H),[B,re,H]),ke=null===te?null:$e.find(e=>e.row===te.row&&e.index===te.index)??null,Ae=null===ke?[]:[{seriesIndex:ke.row,color:ke.cell.color??x(ce(ke.cell.value??0),I),value:ke.cell.value,formatted:ne(ke.cell.value??0),label:ke.cell.label}],Ne=Array.from({length:p},(e,t)=>x(t,I));return t(a,{...T,size:G,variant:J,padded:O,className:Q,legendSide:ge,legend:fe&&!we?e(n,{steps:Ne,from:ne("diverging"===I?-E(he,se,_)+_:he),to:ne("diverging"===I?E(he,se,_)+_:se),middle:"diverging"===I?ne(_):void 0,align:xe.align??"center",vertical:"left"===ge||"right"===ge,size:G}):null,table:we?null:t("table",{id:ee,className:k,children:[K?e("caption",{children:K}):null,e("thead",{children:t("tr",{children:[e("th",{scope:"col"}),re.map((t,l)=>e("th",{scope:"col",children:c(t,H)},l))]})}),e("tbody",{children:ie.map((l,n)=>t("tr",{children:[e("th",{scope:"row",children:oe[n]}),re.map((t,n)=>{const i=l[n];return e("td",{children:void 0!==i?.label?i.label:null==i?.value?"":ne(i.value)},n)})]},n))})]}),children:[t("div",{ref:V,role:"img",tabIndex:we?void 0:0,"aria-label":K??Z.label,"aria-describedby":we?void 0:ee,onPointerLeave:()=>le(null),onBlur:()=>le(null),onKeyDown:e=>{if(ve||0===$e.length)return;const t=null===te?-1:$e.findIndex(e=>e.row===te.row&&e.index===te.index);if("ArrowRight"===e.key||"ArrowDown"===e.key){const e=$e[Math.min($e.length-1,t+1)];le({row:e.row,index:e.index})}else if("ArrowLeft"===e.key||"ArrowUp"===e.key){const e=$e[Math.max(0,(-1===t?$e.length:t)-1)];le({row:e.row,index:e.index})}else{if("Escape"!==e.key)return;le(null)}e.preventDefault()},className:$("relative w-full rounded-(--neba-radius-xs)","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2"),style:{height:me},children:[we?e("div",{className:$("flex h-full items-center justify-center text-(--neba-muted-fg)",j[G]),children:F??Y.title}):X>0?t("svg",{width:X,height:me,viewBox:`0 0 ${X} ${me}`,"aria-hidden":"true",className:"block",children:[$e.map(l=>{const n=ce(l.cell.value??0),i=te?.row===l.row&&te?.index===l.index,a=Math.max(0,l.width-m),r=Math.max(0,l.height-m);if(a<=0||r<=0)return null;const o=ne(l.cell.value??0),d="treemap"===C?"all"===P?[je(l),o]:[je(l)]:"all"===P?[o]:[],h=d.filter(e=>function(e,t,l,n){return l>=1.8*n&&t>=Math.min(w(e,n),2.5*n)+8}(e,a,r/d.length,ue)),s=l.cell.color?"var(--neba-surface)":f(n,I);return t("g",{children:[e("rect",{x:l.x+m/2,y:l.y+m/2,width:a,height:r,rx:Math.min(3,a/2,r/2),fill:l.cell.color??x(n,I),opacity:i?1:.94,onPointerEnter:ve?void 0:()=>le({row:l.row,index:l.index}),className:"[transition:opacity_var(--neba-duration)_var(--neba-ease)]"}),h.map((t,n)=>e("text",{x:l.x+l.width/2,y:l.y+l.height/2+(n-(h.length-1)/2)*(ue+2),textAnchor:"middle",dominantBaseline:"central",fontSize:ue,fontWeight:0===n?500:400,fill:s,opacity:0===n?1:.85,pointerEvents:"none",className:0===n&&"treemap"===C?void 0:"tabular-nums",children:y(t,l.width-8,ue)},n))]},`${l.row}-${l.index}`)}),"grid"===C?be.texts.map((t,l)=>e("text",{x:Me.left-8,y:(l+.5)*Me.height/Math.max(1,S.length),textAnchor:"end",dominantBaseline:"central",fontSize:ue,fill:"var(--neba-muted-fg)",children:t},`row-${l}`)):null,"grid"===C?re.map((t,l)=>{const n=Me.width/Math.max(1,ae),i=c(t,H);return l%Math.max(1,Math.ceil((w(i,ue)+8)/Math.max(1,n)))!==0?null:e("text",{x:Me.left+(l+.5)*n,y:Me.height+ue,textAnchor:"middle",fontSize:ue,fill:"var(--neba-muted-fg)",children:i},`col-${l}`)}):null]}):null,ke&&!ve?pe.render?e("div",{className:"pointer-events-none absolute z-10",style:{left:ke.x+ke.width/2,top:ke.y},children:pe.render({index:ke.index,category:ke.cell.x??re[ke.index]??ke.index,items:Ae})}):e(r,{heading:`${oe[ke.row]} · ${je(ke)}`,items:Ae,x:ke.x+ke.width/2,y:ke.y,flip:ke.x+ke.width/2>.6*X,size:G}):null]}),ve?null:e(i,{heading:ke?`${oe[ke.row]} · ${je(ke)}`:void 0,items:Ae})]})}function E(e,t,l){return Math.max(Math.abs(t-l),Math.abs(l-e))}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as n}from"react/jsx-runtime";import*as e from"react";import{transitionClasses as
|
|
1
|
+
"use client";import{jsx as n}from"react/jsx-runtime";import*as e from"react";import{cx as t,transitionClasses as r}from"../../internal/styles.js";const o={solid:"bg-(--n-fill) text-(--n-on-solid)",outline:"border bg-(--n-panel) text-(--n-accent) [border-color:var(--n-line)]",text:"bg-transparent text-(--n-accent)"},l={regular:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},i=/[\p{L}\p{N}_]/u;function a(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function s(n,e,t){const r=e>0?n[e-1]:"",o=t<n.length?n[t]:"";return!i.test(r)&&!i.test(o)}function c(n,e,t,r){e.lastIndex=0;const o=[];let l,i=0;for(;null!==(l=e.exec(n));){if(""===l[0]){e.lastIndex+=1;continue}const a=l.index,c=a+l[0].length;!t||s(n,a,c)?(a>i&&o.push(n.slice(i,a)),o.push(r(l[0],`${a}`)),i=c):e.lastIndex=a+1}return 0===o.length?n:(i<n.length&&o.push(n.slice(i)),o)}function u(n,t,r,o){if("string"==typeof n)return c(n,t,r,o);if("number"==typeof n)return c(String(n),t,r,o);if(Array.isArray(n))return e.Children.map(n,n=>u(n,t,r,o));if(e.isValidElement(n)){const l=n.props.children;return void 0===l||"function"==typeof l?n:e.cloneElement(n,void 0,u(l,t,r,o))}return n}export const Highlight=/*@__PURE__*/e.forwardRef(function({query:i,variant:s="solid",color:c="warning",caseSensitive:f=!1,wholeWord:d=!1,underline:m=!1,weight:g,className:p,style:h,children:x,...b},y){const v=e.useMemo(()=>function(n,e){if(n instanceof RegExp)return new RegExp(n.source,n.global?n.flags:`${n.flags}g`);const t=(Array.isArray(n)?n:[n]).map(n=>n.trim()).filter(Boolean).sort((n,e)=>e.length-n.length);return 0===t.length?null:new RegExp(t.map(a).join("|"),e?"gu":"giu")}(i,f),[i,f]),$=t("rounded-[0.25rem] px-0.5 -mx-0.5","box-decoration-clone",o[s],m?"underline decoration-2 underline-offset-2":"",g?l[g]:"",r),w=v?u(x,v,d,(e,t)=>n("mark",{className:$,children:e},t)):x;return n("span",{ref:y,className:p,style:{"--n-fill":`var(--neba-${c}-fill)`,"--n-on-solid":`var(--neba-${c}-on-solid)`,"--n-accent":`var(--neba-${c}-accent)`,"--n-panel":`var(--neba-${c}-panel)`,"--n-line":`var(--neba-${c}-line)`,...h},...b,children:w})});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { NebaAlign, NebaSide, NebaStyleProps } from '../../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* The same three axes a [Popover](./popover) takes, and for the same reasons:
|
|
5
|
+
* no `variant`, because a surface that had to be hovered has already asserted
|
|
6
|
+
* itself, and no `elevation`, because a card floating over the page is the
|
|
7
|
+
* whole idea and a prop that could sit it flat would undo it.
|
|
8
|
+
*/
|
|
9
|
+
export interface HoverCardProps extends Pick<NebaStyleProps, 'size' | 'color' | 'density'>, Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'title' | 'children'> {
|
|
10
|
+
/**
|
|
11
|
+
* What the card hangs off. Exactly one element, which must accept a ref and
|
|
12
|
+
* spread props — every Neba component does.
|
|
13
|
+
*
|
|
14
|
+
* Usually a [TextLink](../display/text-link) or an
|
|
15
|
+
* [Avatar](../display/avatar): the two things a reader wants to know more
|
|
16
|
+
* about without leaving the sentence they are in.
|
|
17
|
+
*/
|
|
18
|
+
trigger: React.ReactElement;
|
|
19
|
+
/** The heading, rendered as the element that names the card. */
|
|
20
|
+
title?: React.ReactNode;
|
|
21
|
+
/** A line under the title. */
|
|
22
|
+
description?: React.ReactNode;
|
|
23
|
+
/** The body. */
|
|
24
|
+
children?: React.ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* Which edge of the trigger it appears on. Flips when there is no room.
|
|
27
|
+
* @default 'bottom'
|
|
28
|
+
*/
|
|
29
|
+
side?: NebaSide;
|
|
30
|
+
/** Where it sits along that edge. @default 'center' */
|
|
31
|
+
align?: NebaAlign;
|
|
32
|
+
/** Distance from the trigger, in pixels. @default 6 */
|
|
33
|
+
sideOffset?: number;
|
|
34
|
+
/** Shift along that edge, in pixels. @default 0 */
|
|
35
|
+
alignOffset?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Draws the wedge pointing at the trigger. Off by default, exactly as on
|
|
38
|
+
* Popover: this surface is translucent over a blurred backdrop, and a wedge
|
|
39
|
+
* sticking out past the card's own box cannot carry that backdrop with it.
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
arrow?: boolean;
|
|
43
|
+
/** Whether the card is open. Use with `onOpenChange` for a controlled one. */
|
|
44
|
+
open?: boolean;
|
|
45
|
+
/** Whether it starts open, for an uncontrolled one. */
|
|
46
|
+
defaultOpen?: boolean;
|
|
47
|
+
onOpenChange?: (open: boolean) => void;
|
|
48
|
+
/**
|
|
49
|
+
* How long the pointer has to rest on the trigger before the card opens, in
|
|
50
|
+
* milliseconds. The default is long enough that crossing a paragraph of links
|
|
51
|
+
* does not open four of them.
|
|
52
|
+
*/
|
|
53
|
+
delay?: number;
|
|
54
|
+
/**
|
|
55
|
+
* How long the card stays after the pointer has left, in milliseconds. This
|
|
56
|
+
* is what makes the gap between the trigger and the card crossable.
|
|
57
|
+
*/
|
|
58
|
+
closeDelay?: number;
|
|
59
|
+
/** A hard cap on the card's width, overriding the one `size` implies. */
|
|
60
|
+
width?: number | string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A card that opens when the pointer rests on something, and holds a preview of
|
|
64
|
+
* what is on the other side of it.
|
|
65
|
+
*
|
|
66
|
+
* It sits between the library's other two popups, and the distance is short in
|
|
67
|
+
* both directions. A [Tooltip](../feedback/tooltip) is a label — one line, no
|
|
68
|
+
* interaction, and the pointer never reaches it. A [Popover](./popover) is a
|
|
69
|
+
* panel that was *asked for* by a press, so it can hold a form. This one is
|
|
70
|
+
* uninvited like a tooltip and reachable like a popover: the pointer can cross
|
|
71
|
+
* into it, and a link inside it can be followed.
|
|
72
|
+
*
|
|
73
|
+
* Because it is uninvited, it is never the only way to something. Whatever is in
|
|
74
|
+
* here has to exist on the page the trigger leads to as well — a keyboard
|
|
75
|
+
* without hover, a touchscreen with no pointer at all, and a screen reader all
|
|
76
|
+
* arrive by that route instead.
|
|
77
|
+
*/
|
|
78
|
+
export declare function HoverCard({ size, color, density, trigger, title, description, children, side, align, sideOffset, alignOffset, arrow, open, defaultOpen, onOpenChange, delay, closeDelay, width, className, style, ...props }: HoverCardProps): React.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import{PreviewCard as t}from"@base-ui/react/preview-card";import{boxPaddingXClasses as l,boxPaddingYClasses as i}from"../box/Box.js";import{cx as n,hasContent as o,metaTextClasses as r,radiusClasses as s,sheetBodyClasses as d,sheetHeaderGapClasses as c,sheetSectionGapClasses as m,sheetTitleClasses as p,surfaceClasses as f,surfaceSlots as x,toLength as h}from"../../internal/styles.js";const g={xs:"max-w-64",sm:"max-w-72",md:"max-w-84",lg:"max-w-md",xl:"max-w-xl"},u=[f,"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]","[transition:opacity_var(--neba-duration)_var(--neba-ease)]","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0"].join(" "),b={xs:8,sm:9,md:10,lg:11,xl:12};export function HoverCard({size:f="md",color:v="primary",density:w="default",trigger:y,title:N,description:O,children:j,side:k="bottom",align:z="center",sideOffset:C=6,alignOffset:P=0,arrow:$=!1,open:B,defaultOpen:D,onOpenChange:M,delay:W,closeDelay:_,width:A,className:E,style:H,...L}){const R=l[w][f],T=i[w][f],q=b[f],F=o(N)||o(O),G=h(A);return a(t.Root,{open:B,defaultOpen:D,onOpenChange:e=>M?.(e),children:[e(t.Trigger,{render:y,delay:W,closeDelay:_}),e(t.Portal,{children:e(t.Positioner,{className:"neba-portal z-50 [outline:none]",side:k,align:z,sideOffset:C,alignOffset:P,children:a(t.Popup,{className:n(u,s[f],d[f],m[f],R,T,void 0===G?g[f]:"",E??""),style:{...x(v,3),...void 0===G?null:{maxWidth:G},...H},...L,children:[$?e(t.Arrow,{className:["data-[side=top]:bottom-[-1px]","data-[side=bottom]:top-[-1px] data-[side=bottom]:rotate-180","data-[side=left]:right-[-1px] data-[side=left]:-rotate-90","data-[side=right]:left-[-1px] data-[side=right]:rotate-90"].join(" "),children:a("svg",{width:q,height:q/2,viewBox:"0 0 10 5","aria-hidden":"true",className:"block",children:[e("path",{d:"M0 0h10L5 5z",fill:"var(--n-panel-press)"}),e("path",{d:"M0 0 5 5 10 0",fill:"none",stroke:"var(--n-line)",strokeWidth:"1",vectorEffect:"non-scaling-stroke"})]})}):null,F?a("div",{className:`flex min-w-0 flex-col ${c[f]}`,children:[o(N)?e("div",{className:`m-0 font-semibold ${p[f]}`,children:N}):null,o(O)?e("div",{className:`m-0 text-(--neba-muted-fg) ${r[f]}`,children:O}):null]}):null,o(j)?e("div",{className:"min-w-0",children:j}):null]})})})]})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{HoverCard}from"./HoverCard.js";
|
|
@@ -34,6 +34,17 @@ export interface HowToStepsProps extends Omit<React.ComponentPropsWithoutRef<'di
|
|
|
34
34
|
steps: HowToStep[];
|
|
35
35
|
/** The guide's own heading, over both columns. */
|
|
36
36
|
title?: React.ReactNode;
|
|
37
|
+
/**
|
|
38
|
+
* Which heading level `title` is written at, and the step's title one below
|
|
39
|
+
* it.
|
|
40
|
+
*
|
|
41
|
+
* A heading level is a claim about the *page*, not about the component: a
|
|
42
|
+
* guide under an `<h1>` is an `<h2>` and the same guide inside a section is an
|
|
43
|
+
* `<h4>`, and a component that decides for itself breaks the outline of every
|
|
44
|
+
* page it does not happen to suit.
|
|
45
|
+
* @default 3
|
|
46
|
+
*/
|
|
47
|
+
headingLevel?: 2 | 3 | 4 | 5;
|
|
37
48
|
/** Which step is showing. Pass it to drive the guide yourself. */
|
|
38
49
|
step?: number;
|
|
39
50
|
/** Where an uncontrolled guide starts. @default 0 */
|
|
@@ -139,29 +150,4 @@ export interface HowToStepsProps extends Omit<React.ComponentPropsWithoutRef<'di
|
|
|
139
150
|
doneLabel?: string;
|
|
140
151
|
restartLabel?: string;
|
|
141
152
|
}
|
|
142
|
-
/**
|
|
143
|
-
* A guide the reader walks through: numbered steps down one side, one step's
|
|
144
|
-
* instructions at a time beside them, and a way forward under those.
|
|
145
|
-
*
|
|
146
|
-
* It is [Timeline]'s interactive sibling, and the two are deliberately not one
|
|
147
|
-
* component. A Timeline *reports* — this happened, then this did, and here is
|
|
148
|
-
* where things have got to — and nothing in it is pressed. A HowToSteps *asks*:
|
|
149
|
-
* the reader is meant to do the thing on the screen and then say they have,
|
|
150
|
-
* which needs a current step, a way to change it, and an end.
|
|
151
|
-
*
|
|
152
|
-
* Two things about how it is built are load-bearing rather than incidental.
|
|
153
|
-
*
|
|
154
|
-
* **Every step's body is rendered into the same grid cell**, with the ones not
|
|
155
|
-
* showing left in the document, `invisible` and `inert`. The panel is therefore
|
|
156
|
-
* as tall as the tallest step at every moment, so moving between a one-line
|
|
157
|
-
* step and a five-line one does not resize the card the guide sits in — which,
|
|
158
|
-
* on a page the reader has already scrolled, moves everything under it. The
|
|
159
|
-
* finished panel is in that cell too, for the same reason.
|
|
160
|
-
*
|
|
161
|
-
* **The list is a list of buttons and not a tablist.** A stepper looks like
|
|
162
|
-
* tabs and is not one: the panels are ordered, the reader is expected to arrive
|
|
163
|
-
* at them in that order, and `aria-current="step"` is the attribute that says
|
|
164
|
-
* so. A tablist's roving focus would tell a screen reader that these are
|
|
165
|
-
* interchangeable views of one thing.
|
|
166
|
-
*/
|
|
167
153
|
export declare const HowToSteps: React.ForwardRefExoticComponent<HowToStepsProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import*as l from"react";import{Button as
|
|
1
|
+
"use client";import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import*as l from"react";import{Button as a}from"../button/Button.js";import{boxPaddingClasses as r}from"../box/Box.js";import{CheckIcon as i,ChevronIcon as o,RestartIcon as s,SuccessIcon as c}from"../../internal/icons.js";import{fill as m,stepsMessages as d,useMessages as p}from"../../internal/i18n.js";import{transitionProps as f}from"../../internal/animate.js";import{cx as x,hasContent as u,iconClasses as b,metaTextClasses as h,radiusClasses as g,sheetBodyClasses as v,sheetSectionGapClasses as N,sheetTitleClasses as w,srOnlyClasses as y,surfaceClasses as k,surfaceSlots as j,toLength as C,transitionClasses as z}from"../../internal/styles.js";const S={xs:{box:"1.25rem",text:"text-[0.625rem]"},sm:{box:"1.5rem",text:"text-[0.6875rem]"},md:{box:"1.75rem",text:"text-[0.75rem]"},lg:{box:"2rem",text:"text-[0.8125rem]"},xl:{box:"2.25rem",text:"text-[0.875rem]"}},L={default:{xs:"gap-0.5",sm:"gap-1",md:"gap-1",lg:"gap-1.5",xl:"gap-2"},compact:{xs:"gap-0",sm:"gap-0",md:"gap-0.5",lg:"gap-0.5",xl:"gap-1"}},I={solid:[k,"text-(--neba-fg) bg-(--n-panel-hover)","[box-shadow:var(--n-elev),var(--neba-plate-solid)]"].join(" "),outline:[k,"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 M(e){return"string"==typeof e?e:""}function R({level:e,...t}){return l.createElement(`h${Math.min(6,Math.max(1,e))}`,t)}export const HowToSteps=/*@__PURE__*/l.forwardRef(function({steps:k,title:B,headingLevel:_=3,step:H,defaultStep:T=0,onStepChange:$,completed:E,defaultCompleted:A=!1,onCompletedChange:F,orientation:W="vertical",maxHeight:q,railWidth:D="15rem",navigation:G=!0,divider:J=!0,transition:K="fade",completion:O=!0,completedContent:P,variant:Q="outline",size:U="md",color:V="primary",density:X="default",elevation:Y=0,locale:Z,previousLabel:ee,nextLabel:te,doneLabel:ne,restartLabel:le,className:ae,style:re,...ie},oe){const se=p(d,Z),ce=l.useId(),[me,de]=l.useState(T),[pe,fe]=l.useState(A),xe=void 0!==H,ue=void 0!==E,be=k.length,he=Math.min(Math.max(xe?H:me,0),Math.max(be-1,0)),ge=O&&(ue?E:pe),ve=void 0!==q,Ne="vertical"===W,we=l.useRef(null),ye=l.useRef(null);if(l.useEffect(()=>{const e=we.current,t=ye.current;if(!e||!t)return;const n=e.getBoundingClientRect(),l=t.getBoundingClientRect();Ne?l.top<n.top?e.scrollTop-=n.top-l.top:l.bottom>n.bottom&&(e.scrollTop+=l.bottom-n.bottom):l.left<n.left?e.scrollLeft-=n.left-l.left:l.right>n.right&&(e.scrollLeft+=l.right-n.right)},[he,Ne]),0===be)return null;const ke=(e,t=!1)=>{ue||fe(t),ge!==t&&F?.(t),t||(xe||de(e),e!==he&&$?.(e))},je=0===he,Ce=he===be-1,ze="none"===K?null:f(K),Se=t=>{const n=ge||t<he,l=!ge&&t===he;return e("span",{"aria-hidden":"true",className:x("z-1 flex shrink-0 items-center justify-center rounded-full border font-medium","size-(--n-step-mark) [&_svg]:size-[1.15em]",S[U].text,z,n?"bg-(--n-fill) text-(--n-on-solid) [border-color:transparent]":l?"bg-(--neba-surface) text-(--n-accent) [border-color:var(--n-accent)]":"bg-(--neba-surface) text-(--neba-muted-fg) [border-color:var(--n-line)]"),children:n?e(i,{}):t+1})},Le=e("ol",{ref:we,"aria-label":se.steps,className:x("m-0 flex list-none p-0",Ne?"flex-col":"flex-row",L[X][U],ve&&Ne?"min-h-0 overflow-y-auto overscroll-contain":"",Ne?"":"overflow-x-auto overscroll-contain"),children:k.map((n,l)=>{const a=ge||l<he,r=!ge&&l===he;return t("li",{ref:r?ye:void 0,className:x("relative",Ne?"":"min-w-0 flex-1"),children:[l<be-1?e("span",{"aria-hidden":"true",className:x("absolute",z,a?"bg-(--n-fill)":"bg-(--n-line)",Ne?["w-px","[inset-inline-start:calc(0.25rem+var(--n-step-mark)/2)]","[top:calc(0.25rem+var(--n-step-mark))]","[height:calc(100%-var(--n-step-mark))]"].join(" "):["h-px","[inset-inline-start:calc(50%+var(--n-step-mark)/2)]","[top:calc(0.25rem+var(--n-step-mark)/2)]","[width:calc(100%-var(--n-step-mark))]"].join(" "))}):null,t("button",{type:"button",onClick:()=>ke(l),"aria-current":r?"step":void 0,className:x("flex w-full cursor-pointer items-center p-1 text-start",Ne?"gap-3":"flex-col gap-1.5 text-center",g.sm,"hover:bg-(--n-soft)",z,"focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-1"),children:[Se(l),e("span",{className:x("min-w-0",Ne?"truncate":"",h[U],r?"font-medium text-(--neba-fg)":"text-(--neba-muted-fg)"),children:n.title}),e("span",{className:y,children:m(se.step,{index:String(l+1),title:M(n.title)})})]})]},l)})}),Ie=t("div",{className:x("grid flex-1 grid-cols-1",ve?"min-h-0":""),children:[k.map((n,l)=>{const a=ge||l!==he;return t("div",{"aria-hidden":a,inert:a||void 0,className:x("col-start-1 row-start-1 min-w-0",ve?"overflow-y-auto overscroll-contain":"",a?"invisible":ze?.className??""),style:a?void 0:ze?.style,children:[t("div",{className:"mb-3 flex items-baseline gap-3",children:[u(n.icon)?e("span",{"aria-hidden":"true",className:x("flex h-[1lh] shrink-0 items-center text-(--n-accent)",w[U],b),children:n.icon}):null,e(R,{level:_+1,className:x("m-0 min-w-0 flex-1 font-medium",w[U]),children:n.title}),e("span",{className:x("shrink-0 text-(--neba-muted-fg) tabular-nums",h[U]),children:m(se.position,{index:String(l+1),total:String(be)})})]}),n.image?e("img",{src:n.image,alt:n.imageAlt??M(n.title),loading:"lazy",decoding:"async",className:x("mb-3 max-h-72 w-full object-contain",g[U])}):null,u(n.content)?e("div",{className:x("min-w-0",v[U]),children:n.content}):null]},l)}),O?t("div",{"aria-hidden":!ge,inert:!ge||void 0,className:x("col-start-1 row-start-1 flex min-w-0 flex-col items-center justify-center gap-2 py-4 text-center",ge?ze?.className??"":"invisible"),style:ge?ze?.style:void 0,children:[e("span",{"aria-hidden":"true",className:"text-(--n-accent) [&_svg]:size-9",children:e(c,{})}),e("p",{className:x("m-0 font-medium",v[U]),children:P??se.completed})]}):null]});return t("div",{ref:oe,"aria-labelledby":u(B)?ce:void 0,className:x("flex min-w-0 flex-col",g[U],r[X][U],N[U],I[Q],z,ae),style:{...j(V,Y),"--n-fill":`var(--neba-${V}-fill)`,"--n-on-solid":`var(--neba-${V}-on-solid)`,"--n-step-mark":S[U].box,"--n-step-rail":C(D),...ve?{maxHeight:C(q)}:null,...re},...ie,children:[u(B)?e(R,{level:_,id:ce,className:x("m-0 shrink-0 font-medium",w[U]),children:B}):null,t("div",{className:x("flex min-w-0 flex-1 flex-col",ve?"min-h-0":"",Ne?"gap-4 sm:flex-row sm:gap-5":"gap-4"),children:[e("div",{className:x("flex min-w-0 flex-col",ve?"min-h-0":"",Ne?"sm:w-(--n-step-rail) sm:shrink-0":"",J?Ne?"border-b pb-4 sm:border-b-0 sm:border-e sm:pb-0 sm:pe-5":"border-b pb-4":"",J?"[border-color:var(--n-line)]":""),children:Le}),t("div",{className:x("flex min-w-0 flex-1 flex-col",ve?"min-h-0":"",N[U]),children:[Ie,G?e("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-2",children:ge?e(a,{size:U,variant:"outline",color:V,startIcon:e(s,{}),onClick:()=>ke(0),children:le??se.restart}):t(n,{children:[e(a,{size:U,variant:"outline",color:V,disabled:je,startIcon:e("span",{className:"rotate-90 rtl:-rotate-90",children:e(o,{})}),onClick:()=>ke(he-1),children:ee??se.previous}),e(a,Ce&&O?{size:U,variant:"solid",color:V,startIcon:e(i,{}),onClick:()=>ke(he,!0),children:ne??se.done}:{size:U,variant:"solid",color:V,disabled:Ce,endIcon:e("span",{className:"-rotate-90 rtl:rotate-90",children:e(o,{})}),onClick:()=>ke(he+1),children:te??se.next})]})}):null]})]})]})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e}from"react/jsx-runtime";import*as t from"react";import{transitionProps as i}from"../../internal/animate.js";import{iconSizeClasses as
|
|
1
|
+
"use client";import{jsx as e}from"react/jsx-runtime";import*as t from"react";import{transitionProps as i}from"../../internal/animate.js";import{cx as n,iconSizeClasses as r}from"../../internal/styles.js";const s={xs:"text-[0.875rem]",sm:"text-[1rem]",md:"text-[1.25rem]",lg:"text-[1.5rem]",xl:"text-[1.75rem]"};export const Icon=/*@__PURE__*/t.forwardRef(function({icon:t,size:l="md",color:a="inherit",label:m,transition:o,className:c,style:f,...x},d){const g=i(o),u=n("inline-flex shrink-0 items-center justify-center align-middle",r[l],"[&>svg]:block [&>svg]:size-full [&>img]:block [&>img]:size-full",`leading-none ${s[l]}`,"inherit"===a?"":"text-(--n-accent)",g.className,c??"");return e("span",{ref:d,className:u,style:"inherit"===a?{...g.style,...f}:{"--n-accent":`var(--neba-${a}-accent)`,...g.style,...f},role:m?"img":void 0,"aria-label":m,"aria-hidden":!m||void 0,...x,children:t})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as
|
|
1
|
+
"use client";import{jsx as e,jsxs as r,Fragment as s}from"react/jsx-runtime";import*as n from"react";import{useRender as t}from"@base-ui/react/use-render";import{boxPaddingXClasses as l}from"../box/Box.js";import{cx as a,focusRingClasses as i,gapClasses as o,hasContent as d,iconClasses as c,metaTextClasses as m,radiusClasses as f,sheetBodyClasses as x,surfaceClasses as p,surfaceSlots as u,transitionClasses as h}from"../../internal/styles.js";const b=/*@__PURE__*/n.createContext({size:"md",density:"default",dividers:!1}),v={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"},g={default:{xs:"py-1",sm:"py-1.5",md:"py-2",lg:"py-2.5",xl:"py-3"},compact:{xs:"py-0.5",sm:"py-0.5",md:"py-1",lg:"py-1.5",xl:"py-2"}},y={xs:f.xs,sm:f.xs,md:f.sm,lg:f.sm,xl:f.md};export const List=/*@__PURE__*/n.forwardRef(function({variant:r="outline",size:s="md",color:l="primary",density:i="default",elevation:o=0,dividers:d=!1,render:c,className:m,style:x,children:p,...g},y){const N=n.useMemo(()=>({size:s,density:i,dividers:d}),[s,i,d]),w=a("flex flex-col",f[s],v[r],h,d?"overflow-hidden [&>li+li]:border-t [&>li+li]:[border-color:var(--n-line)]":"p-1",m??""),j=t({render:c,ref:y,props:{role:"list",className:w,style:{...u(l,o),...x},children:p,...g}});return e(b.Provider,{value:N,children:j})});export const ListItem=/*@__PURE__*/n.forwardRef(function({startIcon:t,endIcon:f,description:p,action:u,href:v,selected:N=!1,disabled:w=!1,className:j,children:k,onClick:C,...z},I){const{size:$,density:B,dividers:L}=n.useContext(b),R=Boolean(C||v)&&!w,F=l[B][$],M=g[B][$],P=a("flex min-w-0 flex-1 items-center text-start",F,M,o[$],x[$],h,c,L?"":y[$],w?"cursor-not-allowed text-(--neba-disabled-fg)":N?"bg-(--n-soft-press) font-medium text-(--n-accent)":"",R?`cursor-pointer ${i}`:"",R&&!N?"hover:bg-(--n-soft)":"",R&&N?"hover:bg-(--n-soft-press)":""),q=r(s,{children:[d(t)?e("span",{className:"flex h-[1lh] shrink-0 items-center text-(--neba-muted-fg)",children:t}):null,r("span",{className:"flex min-w-0 flex-1 flex-col",children:[d(k)?e("span",{className:"truncate",children:k}):null,d(p)?e("span",{className:`truncate text-(--neba-muted-fg) ${m[$]}`,children:p}):null]}),d(f)?e("span",{className:"flex h-[1lh] shrink-0 items-center text-(--neba-muted-fg)",children:f}):null]});return r("li",{ref:I,className:a("flex w-full items-center",j??""),...z,children:[R&&v?e("a",{href:v,className:P,"aria-current":N?"page":void 0,onClick:C,children:q}):R?e("button",{type:"button",className:P,"aria-current":!!N||void 0,onClick:C,children:q}):e("div",{className:P,"aria-disabled":w||void 0,children:q}),d(u)?e("div",{className:`flex shrink-0 items-center ${F}`,children:u}):null]})});
|
|
@@ -32,6 +32,11 @@ export interface MenuProps extends MenuSurfaceProps {
|
|
|
32
32
|
sideOffset?: number;
|
|
33
33
|
/**
|
|
34
34
|
* Whether the page behind is taken away while the menu is open.
|
|
35
|
+
*
|
|
36
|
+
* Left undefined rather than defaulted here on purpose: Base UI's own default
|
|
37
|
+
* is the same `true`, and it warns when the prop is set on a menu that turns
|
|
38
|
+
* out to be nested — which is every menu on a [Menubar](./menubar) and every
|
|
39
|
+
* submenu. Not passing it is how the default stays a default.
|
|
35
40
|
* @default true
|
|
36
41
|
*/
|
|
37
42
|
modal?: boolean;
|
|
@@ -71,8 +76,15 @@ export interface MenuItemProps {
|
|
|
71
76
|
onClick?: (event: React.MouseEvent<HTMLElement>) => void;
|
|
72
77
|
/** Renders the row as a real `<a>`. A menu of links has to be links. */
|
|
73
78
|
href?: string;
|
|
74
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* Where the link opens — `_blank` and the rest. Ignored without `href`.
|
|
81
|
+
*
|
|
82
|
+
* Anything other than this tab also gets `rel="noopener noreferrer"`, merged
|
|
83
|
+
* with whatever `rel` was asked for, exactly as on [TextLink].
|
|
84
|
+
*/
|
|
75
85
|
target?: string;
|
|
86
|
+
/** The link's `rel`. The two tokens a new tab needs are added to it. */
|
|
87
|
+
rel?: string;
|
|
76
88
|
/** Content before the label — an icon, a swatch, a check. */
|
|
77
89
|
startIcon?: React.ReactNode;
|
|
78
90
|
/** Content after the label, before any `shortcut`. */
|
|
@@ -123,7 +135,7 @@ export interface MenuGroupProps {
|
|
|
123
135
|
children?: React.ReactNode;
|
|
124
136
|
className?: string;
|
|
125
137
|
}
|
|
126
|
-
export interface MenuCheckboxItemProps extends Omit<MenuItemProps, 'href' | 'target' | 'startIcon' | 'onClick'> {
|
|
138
|
+
export interface MenuCheckboxItemProps extends Omit<MenuItemProps, 'href' | 'target' | 'rel' | 'startIcon' | 'onClick'> {
|
|
127
139
|
checked?: boolean;
|
|
128
140
|
defaultChecked?: boolean;
|
|
129
141
|
onCheckedChange?: (checked: boolean) => void;
|
|
@@ -143,7 +155,7 @@ export interface MenuRadioGroupProps {
|
|
|
143
155
|
children?: React.ReactNode;
|
|
144
156
|
className?: string;
|
|
145
157
|
}
|
|
146
|
-
export interface MenuRadioItemProps extends Omit<MenuItemProps, 'href' | 'target' | 'startIcon' | 'onClick'> {
|
|
158
|
+
export interface MenuRadioItemProps extends Omit<MenuItemProps, 'href' | 'target' | 'rel' | 'startIcon' | 'onClick'> {
|
|
147
159
|
/** What this row sets the group to. */
|
|
148
160
|
value: string | number;
|
|
149
161
|
/** @default false */
|
|
@@ -158,7 +170,7 @@ export type MenuSeparatorProps = React.ComponentPropsWithoutRef<'div'>;
|
|
|
158
170
|
* links that are not links cannot be opened in a new tab, cannot be copied, and
|
|
159
171
|
* tells a screen reader the wrong thing about every one of them.
|
|
160
172
|
*/
|
|
161
|
-
export declare function MenuItem({ onClick, href, target, startIcon, endIcon, shortcut, description, color, closeOnClick, disabled, label, children, className, style }: MenuItemProps): React.JSX.Element;
|
|
173
|
+
export declare function MenuItem({ onClick, href, target, rel, startIcon, endIcon, shortcut, description, color, closeOnClick, disabled, label, children, className, style }: MenuItemProps): React.JSX.Element;
|
|
162
174
|
/** A row that ticks. The tick lands in the same slot a `startIcon` would. */
|
|
163
175
|
export declare function MenuCheckboxItem({ checked, defaultChecked, onCheckedChange, endIcon, shortcut, description, color, closeOnClick, disabled, label, children, className, style }: MenuCheckboxItemProps): React.JSX.Element;
|
|
164
176
|
/** One choice out of a set. Wraps the rows that make up the set. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as n,Fragment as
|
|
1
|
+
"use client";import{jsx as e,jsxs as n,Fragment as t}from"react/jsx-runtime";import*as a from"react";import{Menu as l}from"@base-ui/react/menu";import{ContextMenu as s}from"@base-ui/react/context-menu";import{MenuContext as i}from"../../internal/menu.js";import{CheckIcon as o,ChevronIcon as r,DotIcon as c}from"../../internal/icons.js";import{safeRel as d}from"../../internal/link.js";import{controlTextLeadingClasses as u,cx as m,gapClasses as p,hasContent as h,iconClasses as x,metaTextClasses as f,radiusClasses as b,surfaceClasses as g,surfaceSlots as y,transitionClasses as N}from"../../internal/styles.js";const C=[g,"max-h-[min(24rem,var(--available-height))] min-w-40 overflow-y-auto overscroll-contain","border bg-(--n-panel-press) p-1","[border-color:var(--n-line)]","[box-shadow:var(--neba-shadow-3),var(--neba-plate-glass)]","[outline:none]","[transition:opacity_var(--neba-duration)_var(--neba-ease)]","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0"].join(" "),v={default:{xs:"px-1.5 py-0.5",sm:"px-2 py-1",md:"px-2.5 py-1.5",lg:"px-3 py-2",xl:"px-3.5 py-2.5"},compact:{xs:"px-1 py-0.5",sm:"px-1.5 py-0.5",md:"px-2 py-1",lg:"px-2.5 py-1",xl:"px-3 py-1.5"}},k={xs:b.xs,sm:b.xs,md:b.sm,lg:b.sm,xl:b.md};function O(e,n,t,a){return m("relative flex w-full cursor-pointer items-center select-none",t?"text-(--n-accent)":"text-(--neba-fg)",v[n][e],k[e],p[e],u[e],N,x,"data-[highlighted]:bg-(--n-soft-hover)","data-[popup-open]:bg-(--n-soft)","data-[disabled]:cursor-not-allowed data-[disabled]:text-(--neba-disabled-fg)","[outline:none]",a??"")}const z="flex h-[1lh] w-[1.2em] shrink-0 items-center justify-center";function I({children:t,description:a,size:l}){return h(a)?n("span",{className:"flex min-w-0 flex-1 flex-col text-start",children:[e("span",{className:"truncate",children:t}),e("span",{className:`truncate text-(--neba-muted-fg) ${f[l]}`,children:a})]}):e("span",{className:"min-w-0 flex-1 truncate text-start",children:t})}export function MenuItem({onClick:s,href:o,target:r,rel:c,startIcon:u,endIcon:m,shortcut:p,description:x,color:b,closeOnClick:g=!0,disabled:N=!1,label:C,children:v,className:k,style:M}){const j=a.useContext(i),{size:$,density:w}=j,P=n(t,{children:[h(u)?e("span",{className:`${z} text-(--neba-muted-fg)`,children:u}):null,e(I,{description:x,size:$,children:v}),h(m)?e("span",{className:`${z} text-(--neba-muted-fg)`,children:m}):null,h(p)?e("span",{className:`ms-2 shrink-0 text-(--neba-muted-fg) tabular-nums ${f[$]}`,children:p}):null]}),R=b?y(b,0):void 0,F=R||M?{...R,...M}:void 0;return void 0!==o?e(l.LinkItem,{href:o,target:r,rel:d(r,c),label:C,closeOnClick:g,onClick:s,className:O($,w,Boolean(b),k),style:F,children:P}):e(l.Item,{disabled:N,label:C,closeOnClick:g,onClick:s,className:O($,w,Boolean(b),k),style:F,children:P})}export function MenuCheckboxItem({checked:t,defaultChecked:s,onCheckedChange:r,endIcon:c,shortcut:d,description:u,color:m,closeOnClick:p=!1,disabled:x=!1,label:b,children:g,className:N,style:C}){const{size:v,density:k}=a.useContext(i),M=m?y(m,0):void 0;return n(l.CheckboxItem,{checked:t,defaultChecked:s,onCheckedChange:e=>r?.(e),disabled:x,label:b,closeOnClick:p,className:O(v,k,Boolean(m),N),style:M||C?{...M,...C}:void 0,children:[e("span",{className:`${z} text-(--n-accent)`,children:e(l.CheckboxItemIndicator,{className:"flex items-center justify-center",children:e(o,{})})}),e(I,{description:u,size:v,children:g}),h(c)?e("span",{className:`${z} text-(--neba-muted-fg)`,children:c}):null,h(d)?e("span",{className:`ms-2 shrink-0 text-(--neba-muted-fg) tabular-nums ${f[v]}`,children:d}):null]})}export function MenuRadioGroup({value:n,defaultValue:t,onValueChange:a,disabled:s=!1,children:i,className:o}){return e(l.RadioGroup,{value:n,defaultValue:t,onValueChange:e=>a?.(e),disabled:s,className:o,children:i})}export function MenuRadioItem({value:t,endIcon:s,shortcut:o,description:r,color:d,closeOnClick:u=!1,disabled:m=!1,label:p,children:x,className:b,style:g}){const{size:N,density:C}=a.useContext(i),v=d?y(d,0):void 0;return n(l.RadioItem,{value:t,disabled:m,label:p,closeOnClick:u,className:O(N,C,Boolean(d),b),style:v||g?{...v,...g}:void 0,children:[e("span",{className:`${z} text-(--n-accent)`,children:e(l.RadioItemIndicator,{className:"flex items-center justify-center",children:e(c,{})})}),e(I,{description:r,size:N,children:x}),h(s)?e("span",{className:`${z} text-(--neba-muted-fg)`,children:s}):null,h(o)?e("span",{className:`ms-2 shrink-0 text-(--neba-muted-fg) tabular-nums ${f[N]}`,children:o}):null]})}export function MenuGroup({label:t,children:s,className:o}){const{size:r,density:c}=a.useContext(i);return n(l.Group,{className:o,children:[h(t)?e(l.GroupLabel,{className:[v[c][r],f[r],"font-semibold tracking-wide text-(--neba-muted-fg) uppercase"].join(" "),children:t}):null,s]})}export function MenuSeparator({className:n,...t}){return e(l.Separator,{className:m("-mx-1 my-1 h-px bg-(--n-line)",n??""),...t})}export function MenuSubmenu({label:t,startIcon:s,disabled:o=!1,side:c="right",sideOffset:d=4,children:p,className:x,style:f}){const g=a.useContext(i),{size:N,density:v,color:k}=g;return n(l.SubmenuRoot,{children:[n(l.SubmenuTrigger,{disabled:o,className:O(N,v,!1),children:[h(s)?e("span",{className:`${z} text-(--neba-muted-fg)`,children:s}):null,e("span",{className:"min-w-0 flex-1 truncate text-start",children:t}),e("span",{className:`${z} text-(--neba-muted-fg) -rotate-90`,children:e(r,{})})]}),e(l.Portal,{children:e(l.Positioner,{className:"neba-portal z-50 [outline:none]",side:c,sideOffset:d,align:"start",children:e(l.Popup,{className:m(C,b[N],u[N],x??""),style:{...y(k,3),...f},children:p})})})]})}export function Menu({size:t="md",color:s="primary",density:o="default",trigger:r,open:c,defaultOpen:d,onOpenChange:p,side:h="bottom",align:x="start",sideOffset:f=6,modal:g,openOnHover:N=!1,loopFocus:v=!0,disabled:k=!1,className:O,style:z,children:I}){const M=a.useMemo(()=>({size:t,color:s,density:o}),[t,s,o]);return e(i.Provider,{value:M,children:n(l.Root,{open:c,defaultOpen:d,onOpenChange:e=>p?.(e),modal:g,loopFocus:v,disabled:k,children:[r?e(l.Trigger,{render:r,openOnHover:N,disabled:k}):null,e(l.Portal,{children:e(l.Positioner,{className:"neba-portal z-50 [outline:none]",side:h,align:x,sideOffset:f,children:e(l.Popup,{className:m(C,b[t],u[t],O??""),style:{...y(s,3),...z},children:I})})})]})})}export function ContextMenu({size:t="md",color:l="primary",density:o="default",content:r,children:c,open:d,defaultOpen:p,onOpenChange:h,loopFocus:x=!0,disabled:f=!1,className:g,style:N}){const v=a.useMemo(()=>({size:t,color:l,density:o}),[t,l,o]);return e(i.Provider,{value:v,children:n(s.Root,{open:d,defaultOpen:p,onOpenChange:e=>h?.(e),loopFocus:x,disabled:f,children:[e(s.Trigger,{children:c}),e(s.Portal,{children:e(s.Positioner,{className:"neba-portal z-50 [outline:none]",children:e(s.Popup,{className:m(C,b[t],u[t],g??""),style:{...y(l,3),...N},children:r})})})]})})}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { NebaOrientation, NebaStyleProps } from '../../types.js';
|
|
3
|
+
export interface MenubarProps extends Pick<NebaStyleProps, 'size' | 'color' | 'density'>, Omit<React.ComponentPropsWithoutRef<'div'>, 'color'> {
|
|
4
|
+
/**
|
|
5
|
+
* Which way the bar runs. `vertical` is the shape a side rail of menus takes;
|
|
6
|
+
* the arrow keys follow it either way.
|
|
7
|
+
* @default 'horizontal'
|
|
8
|
+
*/
|
|
9
|
+
orientation?: NebaOrientation;
|
|
10
|
+
/**
|
|
11
|
+
* Whether an open menu takes the page away. On — the default, and Base UI's —
|
|
12
|
+
* an open menu is what the pointer is talking to.
|
|
13
|
+
* @default true
|
|
14
|
+
*/
|
|
15
|
+
modal?: boolean;
|
|
16
|
+
/** Whether the arrow keys wrap around at the ends of the bar. @default true */
|
|
17
|
+
loopFocus?: boolean;
|
|
18
|
+
/** Disables every menu on the bar at once. */
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/** The menus. */
|
|
21
|
+
children?: React.ReactNode;
|
|
22
|
+
}
|
|
23
|
+
export interface MenubarMenuProps {
|
|
24
|
+
/** The word on the bar. */
|
|
25
|
+
label: React.ReactNode;
|
|
26
|
+
/** Content before the label. Sized in `em`, so it tracks it. */
|
|
27
|
+
startIcon?: React.ReactNode;
|
|
28
|
+
/** Unavailable. The word stays on the bar and opens nothing. */
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
/** The rows, written exactly as they are inside a [Menu](./menu). */
|
|
31
|
+
children?: React.ReactNode;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* One menu on the bar: the word, and the rows behind it.
|
|
35
|
+
*
|
|
36
|
+
* It has no `size`, `color` or `density` of its own — all three belong to the
|
|
37
|
+
* bar, which is the only place they can be set once and hold for every menu on
|
|
38
|
+
* it. The rows inside are the same `MenuItem`, `MenuSeparator`, `MenuGroup` and
|
|
39
|
+
* `MenuSubmenu` a [Menu](./menu) takes, because it is the same menu.
|
|
40
|
+
*/
|
|
41
|
+
export declare function MenubarMenu({ label, startIcon, disabled, children }: MenubarMenuProps): React.JSX.Element;
|
|
42
|
+
/**
|
|
43
|
+
* The strip of words at the top of an application — File, Edit, View — each of
|
|
44
|
+
* which opens a menu.
|
|
45
|
+
*
|
|
46
|
+
* What makes it a bar rather than a row of separate menus is what happens once
|
|
47
|
+
* one is open: moving along the strip walks through the others instead of
|
|
48
|
+
* closing the one you left, and the arrow keys move between the menus as well as
|
|
49
|
+
* inside them. Base UI owns all of that, along with the `menubar` role.
|
|
50
|
+
*
|
|
51
|
+
* It draws no surface of its own. A menu bar sits *on* something — a
|
|
52
|
+
* [Toolbar](../surfaces/toolbar), a [WindowPane](../surfaces/window-pane)'s
|
|
53
|
+
* title bar, a [Header](../layout/header) — and a sheet under a strip that is
|
|
54
|
+
* already on a sheet is two sheets.
|
|
55
|
+
*/
|
|
56
|
+
export declare const Menubar: React.ForwardRefExoticComponent<MenubarProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsxs as e,jsx as n}from"react/jsx-runtime";import*as t from"react";import{Menubar as o}from"@base-ui/react/menubar";import{Menu as r}from"../menu/Menu.js";import{MenuContext as s}from"../../internal/menu.js";import{controlTextClasses as a,cx as i,gapClasses as l,hasContent as c,iconClasses as d,paddingXClasses as u,radiusClasses as f,transitionClasses as m}from"../../internal/styles.js";const p={xs:"h-4.5",sm:"h-5.5",md:"h-6.5",lg:"h-8",xl:"h-10"},b=["inline-flex shrink-0 cursor-pointer select-none items-center justify-center","whitespace-nowrap font-medium leading-none","text-(--neba-fg) bg-transparent","[-webkit-tap-highlight-color:transparent] [touch-action:manipulation]",m,d,"hover:bg-(--n-soft)","data-[popup-open]:bg-(--n-soft-hover) data-[popup-open]:text-(--n-accent)","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:[outline-offset:-2px]","disabled:cursor-not-allowed disabled:text-(--neba-disabled-fg) disabled:hover:bg-transparent"].join(" ");export function MenubarMenu({label:o,startIcon:i,disabled:d=!1,children:m}){const{size:h,color:x,density:v}=t.useContext(s);return n(r,{size:h,color:x,density:v,disabled:d,openOnHover:!0,sideOffset:4,trigger:e("button",{type:"button",disabled:d,className:[b,p[h],a[h],l[h],u["default"===v?"compact":v][h],f[h]].join(" "),children:[c(i)?i:null,o]}),children:m})}export const Menubar=/*@__PURE__*/t.forwardRef(function({size:e="md",color:r="primary",density:a="default",orientation:c="horizontal",modal:d=!0,loopFocus:u=!0,disabled:f=!1,className:m,style:p,children:b,...h},x){const v=t.useMemo(()=>({size:e,color:r,density:a}),[e,r,a]);return n(s.Provider,{value:v,children:n(o,{ref:x,orientation:c,modal:d,loopFocus:u,disabled:f,className:i("flex items-center","vertical"===c?"flex-col items-stretch":"flex-row",l[e],m??""),style:{"--n-soft":`var(--neba-${r}-soft)`,"--n-soft-hover":`var(--neba-${r}-soft-hover)`,"--n-accent":`var(--neba-${r}-accent)`,"--n-ring":`var(--neba-${r}-ring)`,...p},...h,children:b})})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{Menubar,MenubarMenu}from"./Menubar.js";
|