neba 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/dist/components/alert/Alert.d.ts +9 -1
- package/dist/components/alert/Alert.js +1 -1
- package/dist/components/area-chart/AreaChart.d.ts +54 -0
- package/dist/components/area-chart/AreaChart.js +1 -0
- package/dist/components/area-chart/index.d.ts +2 -0
- package/dist/components/area-chart/index.js +1 -0
- package/dist/components/bar-chart/BarChart.d.ts +63 -0
- package/dist/components/bar-chart/BarChart.js +1 -0
- package/dist/components/bar-chart/index.d.ts +2 -0
- package/dist/components/bar-chart/index.js +1 -0
- package/dist/components/bottom-navigation/BottomNavigation.d.ts +111 -0
- package/dist/components/bottom-navigation/BottomNavigation.js +1 -0
- package/dist/components/bottom-navigation/index.d.ts +1 -0
- package/dist/components/bottom-navigation/index.js +1 -0
- package/dist/components/breadcrumb/Breadcrumb.d.ts +35 -2
- package/dist/components/breadcrumb/Breadcrumb.js +1 -1
- package/dist/components/button/Button.d.ts +16 -0
- package/dist/components/button/Button.js +1 -1
- package/dist/components/carousel/Carousel.d.ts +10 -4
- package/dist/components/carousel/Carousel.js +1 -1
- package/dist/components/chip/Chip.d.ts +9 -1
- package/dist/components/chip/Chip.js +1 -1
- package/dist/components/collapsible/Collapsible.d.ts +88 -0
- package/dist/components/collapsible/Collapsible.js +1 -0
- package/dist/components/collapsible/index.d.ts +1 -0
- package/dist/components/collapsible/index.js +1 -0
- package/dist/components/combobox/Combobox.d.ts +19 -7
- package/dist/components/combobox/Combobox.js +1 -1
- package/dist/components/data-table/DataTable.d.ts +323 -0
- package/dist/components/data-table/DataTable.js +1 -0
- package/dist/components/data-table/index.d.ts +2 -0
- package/dist/components/data-table/index.js +1 -0
- package/dist/components/dialog/Dialog.d.ts +11 -5
- package/dist/components/dialog/Dialog.js +1 -1
- package/dist/components/drawer/Drawer.d.ts +11 -5
- package/dist/components/drawer/Drawer.js +1 -1
- package/dist/components/empty/Empty.d.ts +69 -0
- package/dist/components/empty/Empty.js +1 -0
- package/dist/components/empty/index.d.ts +2 -0
- package/dist/components/empty/index.js +1 -0
- package/dist/components/file-picker/FilePicker.d.ts +1 -3
- package/dist/components/file-picker/FilePicker.js +1 -1
- package/dist/components/floating-action-button/FloatingActionButton.d.ts +146 -0
- package/dist/components/floating-action-button/FloatingActionButton.js +1 -0
- package/dist/components/floating-action-button/index.d.ts +1 -0
- package/dist/components/floating-action-button/index.js +1 -0
- package/dist/components/heatmap-chart/HeatmapChart.d.ts +69 -0
- package/dist/components/heatmap-chart/HeatmapChart.js +1 -0
- package/dist/components/heatmap-chart/index.d.ts +2 -0
- package/dist/components/heatmap-chart/index.js +1 -0
- package/dist/components/highlight/Highlight.js +1 -1
- package/dist/components/line-chart/LineChart.d.ts +74 -0
- package/dist/components/line-chart/LineChart.js +1 -0
- package/dist/components/line-chart/index.d.ts +2 -0
- package/dist/components/line-chart/index.js +1 -0
- package/dist/components/mockup/Mockup.d.ts +151 -0
- package/dist/components/mockup/Mockup.js +1 -0
- package/dist/components/mockup/index.d.ts +2 -0
- package/dist/components/mockup/index.js +1 -0
- package/dist/components/number-field/NumberField.d.ts +10 -6
- package/dist/components/number-field/NumberField.js +1 -1
- package/dist/components/overlay/Overlay.d.ts +11 -6
- package/dist/components/overlay/Overlay.js +1 -1
- package/dist/components/pagination/Pagination.d.ts +28 -6
- package/dist/components/pagination/Pagination.js +1 -1
- package/dist/components/panes/Panes.js +1 -1
- package/dist/components/pie-chart/PieChart.d.ts +58 -0
- package/dist/components/pie-chart/PieChart.js +1 -0
- package/dist/components/pie-chart/index.d.ts +2 -0
- package/dist/components/pie-chart/index.js +1 -0
- package/dist/components/popover/Popover.d.ts +11 -5
- 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/rating/Rating.d.ts +100 -0
- package/dist/components/rating/Rating.js +1 -0
- package/dist/components/rating/index.d.ts +1 -0
- package/dist/components/rating/index.js +1 -0
- package/dist/components/scatter-chart/ScatterChart.d.ts +45 -0
- package/dist/components/scatter-chart/ScatterChart.js +1 -0
- package/dist/components/scatter-chart/index.d.ts +2 -0
- package/dist/components/scatter-chart/index.js +1 -0
- package/dist/components/select/Select.d.ts +1 -3
- package/dist/components/select/Select.js +1 -1
- package/dist/components/sparkline/Sparkline.d.ts +67 -0
- package/dist/components/sparkline/Sparkline.js +1 -0
- package/dist/components/sparkline/index.d.ts +2 -0
- package/dist/components/sparkline/index.js +1 -0
- package/dist/components/statistic/Statistic.d.ts +7 -0
- package/dist/components/statistic/Statistic.js +1 -1
- package/dist/components/table/Table.d.ts +13 -2
- package/dist/components/table/Table.js +1 -1
- package/dist/components/text-link/TextLink.js +1 -1
- package/dist/components/time-picker/TimePicker.js +1 -1
- package/dist/components/timeline-chart/TimelineChart.d.ts +44 -0
- package/dist/components/timeline-chart/TimelineChart.js +1 -0
- package/dist/components/timeline-chart/index.d.ts +2 -0
- package/dist/components/timeline-chart/index.js +1 -0
- package/dist/components/toast/Toast.d.ts +10 -2
- package/dist/components/toast/Toast.js +1 -1
- package/dist/components/tooltip/Tooltip.d.ts +2 -4
- package/dist/components/tooltip/Tooltip.js +1 -1
- package/dist/components/tree-view/TreeView.js +1 -1
- package/dist/index.d.ts +15 -0
- package/dist/index.js +1 -1
- package/dist/internal/animate.d.ts +0 -9
- package/dist/internal/animate.js +1 -1
- package/dist/internal/calendar.js +1 -1
- package/dist/internal/chart-frame.d.ts +409 -0
- package/dist/internal/chart-frame.js +1 -0
- package/dist/internal/chart-line.d.ts +44 -0
- package/dist/internal/chart-line.js +1 -0
- package/dist/internal/chart.d.ts +456 -0
- package/dist/internal/chart.js +1 -0
- package/dist/internal/data-table.d.ts +170 -0
- package/dist/internal/data-table.js +1 -0
- package/dist/internal/date.d.ts +0 -2
- package/dist/internal/date.js +1 -1
- package/dist/internal/format.d.ts +29 -0
- package/dist/internal/format.js +1 -0
- package/dist/internal/i18n.d.ts +166 -0
- package/dist/internal/i18n.js +1 -1
- package/dist/internal/icons.d.ts +2 -0
- package/dist/internal/icons.js +1 -1
- package/dist/internal/mockup.d.ts +193 -0
- package/dist/internal/mockup.js +1 -0
- package/dist/internal/picker.d.ts +2 -4
- package/dist/internal/picker.js +1 -1
- package/dist/internal/progress.d.ts +1 -3
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +231 -11
- package/dist/types.d.ts +214 -0
- package/package.json +19 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as a}from"react/jsx-runtime";import{Dialog as
|
|
1
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import{Dialog as n}from"@base-ui/react/dialog";import{boxPaddingXClasses as l,boxPaddingYClasses as i}from"../box/Box";import{useMessages as o}from"../../internal/i18n";import{CloseIcon as r}from"../../internal/icons";import{hasContent as t,metaTextClasses as s,radiusClasses as c,sheetBodyClasses as d,sheetHeaderGapClasses as m,sheetSectionGapClasses as f,sheetTitleClasses as p,surfaceClasses as u,surfaceSlots as x}from"../../internal/styles";const b={xs:"max-w-80",sm:"max-w-96",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl"},h=[u,"relative flex w-full flex-col overflow-hidden","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(" "),g=["fixed inset-0 z-50 bg-(--neba-scrim)","[backdrop-filter:blur(2px)]","[transition:opacity_var(--neba-duration)_var(--neba-ease)]","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0"].join(" "),v="border-t [border-color:var(--n-line)]";export const DialogClose=n.Close;export function Dialog({size:u="md",color:y="primary",density:w="default",open:j,defaultOpen:$,onOpenChange:_,trigger:N,title:k,description:C,actions:z,dividers:B=!1,showClose:D=!0,locale:O,closeLabel:P,width:T,fullWidth:W=!0,fullScreen:L=!1,modal:R=!0,dismissible:S=!0,className:V,style:q,children:A,...E}){const F=o(O),G=l[w][u],H=i[w][u],I=B?`${G} ${H}`:G,J=t(k)||t(C),K=t(z);return a(n.Root,{open:j,defaultOpen:$,modal:R,disablePointerDismissal:!S,onOpenChange:(e,a)=>{S||e||"escape-key"!==a.reason?_?.(e):a.cancel()},children:[N?e(n.Trigger,{render:N}):null,a(n.Portal,{children:[e(n.Backdrop,{className:`neba-portal ${g}`}),e(n.Viewport,{className:["neba-portal fixed inset-0 z-50 flex justify-center",L?"items-stretch":"items-center p-4"].join(" "),children:a(n.Popup,{className:[h,d[u],L?"h-full max-w-none rounded-none":`max-h-full ${c[u]} ${void 0===T?b[u]:""}`,L||W?"":"w-auto",B?"":`${H} ${f[u]}`,V??""].filter(Boolean).join(" "),style:{...x(y,3),...void 0===T?null:{maxWidth:"number"==typeof T?`${T}px`:T},...q},...E,children:[J||D?a("div",{className:`flex shrink-0 items-start gap-3 ${I}`,children:[a("div",{className:`flex min-w-0 flex-1 flex-col ${m[u]}`,children:[t(k)?e(n.Title,{className:`font-semibold ${p[u]} m-0`,children:k}):null,t(C)?e(n.Description,{className:`m-0 text-(--neba-muted-fg) ${s[u]}`,children:C}):null]}),D?e(n.Close,{"aria-label":P??F.action.close,className:["flex size-[1.6em] shrink-0 cursor-pointer items-center justify-center","rounded-full text-(--neba-muted-fg)","[&_svg]:size-[1.1em] [&_svg]:shrink-0","[transition:background-color_var(--neba-duration)_var(--neba-ease),color_var(--neba-duration)_var(--neba-ease)]","hover:bg-(--n-soft) hover:text-(--neba-fg)","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2"].join(" "),children:e(r,{})}):null]}):null,t(A)?e("div",{className:["min-h-0 flex-1 overflow-y-auto overscroll-contain",I,B&&(J||D)?v:"",B?"":"py-1 -my-1"].filter(Boolean).join(" "),children:A}):null,K?e("div",{className:["flex shrink-0 flex-wrap items-center justify-end gap-2",I,B?v:""].filter(Boolean).join(" "),children:z}):null]})})]})]})}
|
|
@@ -24,7 +24,7 @@ export type NebaDrawerMode = 'overlay' | 'inline';
|
|
|
24
24
|
* an `overlay` drawer floats and carries a shadow at level 3, an `inline` one is
|
|
25
25
|
* part of the layout and carries none, and neither is a decision worth offering.
|
|
26
26
|
*/
|
|
27
|
-
export interface DrawerProps extends Pick<NebaStyleProps, 'size' | 'color' | 'density'> {
|
|
27
|
+
export interface DrawerProps extends Pick<NebaStyleProps, 'size' | 'color' | 'density'>, Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'title' | 'children'> {
|
|
28
28
|
/**
|
|
29
29
|
* Which edge the panel is attached to. Physical rather than logical, the way
|
|
30
30
|
* `NebaSide` is everywhere: a drawer along the top of the window is along the
|
|
@@ -76,7 +76,15 @@ export interface DrawerProps extends Pick<NebaStyleProps, 'size' | 'color' | 'de
|
|
|
76
76
|
* one-way door.
|
|
77
77
|
*/
|
|
78
78
|
showClose?: boolean;
|
|
79
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* Which language the × is named in — a BCP 47 tag such as `ko`, `pt-BR` or
|
|
81
|
+
* `zh-Hant`. Unsupported tags fall back to English.
|
|
82
|
+
*
|
|
83
|
+
* `closeLabel` writes the word out instead; this is for the far more common
|
|
84
|
+
* case where the page already knows its own language.
|
|
85
|
+
*/
|
|
86
|
+
locale?: string;
|
|
87
|
+
/** Accessible name of the × button. Defaults to the `locale`'s word for it. */
|
|
80
88
|
closeLabel?: string;
|
|
81
89
|
/**
|
|
82
90
|
* How far the panel reaches in from its edge: a **width** for `left` and
|
|
@@ -109,8 +117,6 @@ export interface DrawerProps extends Pick<NebaStyleProps, 'size' | 'color' | 'de
|
|
|
109
117
|
dismissible?: boolean;
|
|
110
118
|
/** The body. */
|
|
111
119
|
children?: React.ReactNode;
|
|
112
|
-
className?: string;
|
|
113
|
-
style?: React.CSSProperties;
|
|
114
120
|
}
|
|
115
121
|
export type DrawerCloseProps = React.ComponentPropsWithoutRef<typeof BaseUIDialog.Close>;
|
|
116
122
|
/**
|
|
@@ -142,4 +148,4 @@ export declare const DrawerClose: React.ForwardRefExoticComponent<Omit<import("@
|
|
|
142
148
|
* scroll lock, the `aria-labelledby` / `aria-describedby` wiring, restoring
|
|
143
149
|
* focus to the trigger, and the inert page behind.
|
|
144
150
|
*/
|
|
145
|
-
export declare function Drawer({ side, mode, size, color, density, open, defaultOpen, onOpenChange, trigger, title, description, actions, dividers, showClose, closeLabel, extent, rounded, modal, dismissible, className, style, children }: DrawerProps): React.JSX.Element | null;
|
|
151
|
+
export declare function Drawer({ side, mode, size, color, density, open, defaultOpen, onOpenChange, trigger, title, description, actions, dividers, showClose, locale, closeLabel, extent, rounded, modal, dismissible, className, style, children, ...props }: DrawerProps): React.JSX.Element | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as r,Fragment as a}from"react/jsx-runtime";import{Dialog as
|
|
1
|
+
import{jsx as e,jsxs as r,Fragment as a}from"react/jsx-runtime";import{Dialog as n}from"@base-ui/react/dialog";import{boxPaddingXClasses as l,boxPaddingYClasses as o}from"../box/Box";import{useMessages as s}from"../../internal/i18n";import{CloseIcon as i}from"../../internal/icons";import{hasContent as d,metaTextClasses as t,sheetBodyClasses as u,sheetHeaderGapClasses as b,sheetSectionGapClasses as m,sheetTitleClasses as c,surfaceClasses as f,surfaceSlots as x}from"../../internal/styles";const p={xs:"w-56",sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[28rem]"},g={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)"}},h={left:"border-r",right:"border-l",top:"border-b",bottom:"border-t"},v={left:"flex-row justify-start",right:"flex-row justify-end",top:"flex-col justify-start",bottom:"flex-col justify-end"},y=[f,"relative flex flex-col overflow-hidden","text-(--neba-fg) bg-(--n-panel-press)","[border-color:var(--n-line)]","[outline:none]"].join(" "),w=["[transition:opacity_var(--neba-duration)_var(--neba-ease)]","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0"].join(" "),j=["fixed inset-0 z-50 bg-(--neba-scrim)","[backdrop-filter:blur(2px)]",w].join(" "),N="border-t [border-color:var(--n-line)]",$=["flex size-[1.6em] shrink-0 cursor-pointer items-center justify-center","rounded-full text-(--neba-muted-fg)","[&_svg]:size-[1.1em] [&_svg]:shrink-0","[transition:background-color_var(--neba-duration)_var(--neba-ease),color_var(--neba-duration)_var(--neba-ease)]","hover:bg-(--n-soft) hover:text-(--neba-fg)","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2"].join(" ");export const DrawerClose=n.Close;export function Drawer({side:f="left",mode:_="overlay",size:k="md",color:C="primary",density:z="default",open:B,defaultOpen:D,onOpenChange:O,trigger:P,title:T,description:F,actions:L,dividers:R=!1,showClose:V,locale:q,closeLabel:A,extent:E,rounded:G=!0,modal:H=!0,dismissible:I=!0,className:J,style:K,children:M,...Q}){const S=s(q),U="overlay"===_,W="left"===f||"right"===f,X=V??U,Y=l[z][k],Z=o[z][k],ee=R?`${Y} ${Z}`:Y,re=d(T)||d(F),ae=d(L),ne=void 0===E?null:{[W?"width":"height"]:"number"==typeof E?`${E}px`:E},le=[y,u[k],h[f],G?g[f][k]:"",U?"[box-shadow:var(--neba-shadow-3),var(--neba-plate-glass)]":"[box-shadow:var(--neba-plate-glass)]",U?w:"",W?`h-full max-w-full ${void 0===E?p[k]:""}`:"w-full "+(void 0===E?"max-h-[85%]":""),R?"":`${Z} ${m[k]}`,J??""].filter(Boolean).join(" "),oe=U?n.Title:"h2",se=U?n.Description:"p",ie=r(a,{children:[re||X?r("div",{className:`flex shrink-0 items-start gap-3 ${ee}`,children:[r("div",{className:`flex min-w-0 flex-1 flex-col ${b[k]}`,children:[d(T)?e(oe,{className:`m-0 font-semibold ${c[k]}`,children:T}):null,d(F)?e(se,{className:`m-0 text-(--neba-muted-fg) ${t[k]}`,children:F}):null]}),X?U?e(n.Close,{"aria-label":A??S.action.close,className:$,children:e(i,{})}):e("button",{type:"button","aria-label":A??S.action.close,className:$,onClick:()=>O?.(!1),children:e(i,{})}):null]}):null,d(M)?e("div",{className:["min-h-0 flex-1 overflow-y-auto overscroll-contain",ee,R&&(re||X)?N:"",R?"":"py-1 -my-1"].filter(Boolean).join(" "),children:M}):null,ae?e("div",{className:["flex shrink-0 flex-wrap items-center justify-end gap-2",ee,R?N:""].filter(Boolean).join(" "),children:L}):null]});return U?r(n.Root,{open:B,defaultOpen:D,modal:H,disablePointerDismissal:!I,onOpenChange:(e,r)=>{I||e||"escape-key"!==r.reason?O?.(e):r.cancel()},children:[P?e(n.Trigger,{render:P}):null,r(n.Portal,{children:[e(n.Backdrop,{className:`neba-portal ${j}`}),e(n.Viewport,{className:`neba-portal fixed inset-0 z-50 flex ${v[f]}`,children:e(n.Popup,{className:le,style:{...x(C,3),...ne,...K},...Q,children:ie})})]})]}):B??D??1?e("div",{className:le,style:{...x(C,0),...ne,...K},children:ie}):null}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
import type { NebaElevation, NebaStyleProps, NebaTransition } from '../../types';
|
|
4
|
+
export interface EmptyProps extends NebaStyleProps, Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'title'> {
|
|
5
|
+
/**
|
|
6
|
+
* The headline. Defaults to the `locale`'s way of saying that there is
|
|
7
|
+
* nothing here; pass `false` for a state that is a glyph and a sentence with
|
|
8
|
+
* no heading over them.
|
|
9
|
+
*/
|
|
10
|
+
title?: React.ReactNode | false;
|
|
11
|
+
/**
|
|
12
|
+
* The glyph above the headline. Defaults to the empty tray; pass `false` to
|
|
13
|
+
* drop it, or a node — an illustration, a brand mark, an icon from any set —
|
|
14
|
+
* to replace it. An `svg` is sized off the `size` ladder; anything else is
|
|
15
|
+
* left at whatever size it came in at.
|
|
16
|
+
*/
|
|
17
|
+
icon?: React.ReactNode | false;
|
|
18
|
+
/**
|
|
19
|
+
* What to do about it, under the text: a "Create the first one" button, a
|
|
20
|
+
* "Clear filters" link. Several of them sit in a row and wrap together.
|
|
21
|
+
*/
|
|
22
|
+
action?: React.ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* Which language the default headline is written in — a BCP 47 tag. Ignored
|
|
25
|
+
* once `title` is given, and unsupported tags fall back to English.
|
|
26
|
+
* @default 'en'
|
|
27
|
+
*/
|
|
28
|
+
locale?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Drop shadow depth. `0` (the default) is flat, and it is almost always
|
|
31
|
+
* right: an empty state is a hole in a surface that already exists rather
|
|
32
|
+
* than a sheet of its own.
|
|
33
|
+
* @default 0
|
|
34
|
+
*/
|
|
35
|
+
elevation?: NebaElevation;
|
|
36
|
+
/**
|
|
37
|
+
* An entrance animation, run once on mount: `transition="fade"` for a list
|
|
38
|
+
* that has just come back with nothing. For a trigger or a replay, wrap it in
|
|
39
|
+
* an `Animate*` component instead.
|
|
40
|
+
*/
|
|
41
|
+
transition?: NebaTransition;
|
|
42
|
+
/** Renders something other than a `<div>`: `render={<td colSpan={5} />}`. */
|
|
43
|
+
render?: useRender.RenderProp;
|
|
44
|
+
/** The sentence under the headline: why it is empty, or what to do next. */
|
|
45
|
+
children?: React.ReactNode;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* What stands where content would have been: a glyph, a headline, a sentence
|
|
49
|
+
* and a way out.
|
|
50
|
+
*
|
|
51
|
+
* It is the other half of [Skeleton](../feedback/skeleton). A skeleton is the
|
|
52
|
+
* shape of something on its way; this is the shape of something that is not
|
|
53
|
+
* coming — a search with no matches, an inbox nobody has written to, a folder
|
|
54
|
+
* before the first file. The two are never both right at once, and a list that
|
|
55
|
+
* shows neither has a blank rectangle where its answer should be.
|
|
56
|
+
*
|
|
57
|
+
* The headline is the only text in the library a component invents at full
|
|
58
|
+
* size, and it is defaulted rather than required for one reason: the version
|
|
59
|
+
* that says nothing useful is the version that gets shipped. `Nothing here` in
|
|
60
|
+
* the reader's language is a floor, and every slot above it — the glyph, the
|
|
61
|
+
* sentence, the action — is there to be filled with what is actually missing.
|
|
62
|
+
*
|
|
63
|
+
* `surfaceSlots` is the undyed slot set, so `color` reaches the hairline and
|
|
64
|
+
* the ring and stops there. An empty state that arrives in the accent colour is
|
|
65
|
+
* making a claim about content that does not exist; the family is worth
|
|
66
|
+
* changing only when the emptiness is itself a problem (`color="danger"` on a
|
|
67
|
+
* region that failed to load).
|
|
68
|
+
*/
|
|
69
|
+
export declare const Empty: React.ForwardRefExoticComponent<EmptyProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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";import{transitionProps as o}from"../../internal/animate";import{useMessages as s}from"../../internal/i18n";import{hasContent as i,iconClasses as m,radiusClasses as c,sheetBodyClasses as d,sheetHeaderGapClasses as x,sheetSectionGapClasses as p,sheetTitleClasses as f,surfaceClasses as u,surfaceSlots as h,transitionClasses as y}from"../../internal/styles";const v={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"}},b={xs:"text-[1.25rem]",sm:"text-[1.5rem]",md:"text-[1.75rem]",lg:"text-[2.125rem]",xl:"text-[2.5rem]"},g={solid:[u,"text-(--neba-fg) bg-(--n-panel-hover)","[box-shadow:var(--n-elev),var(--neba-plate-solid)]"].join(" "),outline:[u,"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 j(){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=n.forwardRef(function({variant:n="text",size:u="md",color:N="secondary",density:k="default",elevation:w=0,title:$,icon:B,action:L,locale:C,transition:W,render:z,className:E,style:F,children:M,...R},Z){const q=s(C),A=void 0===$?q.empty.title:$,D=void 0===B?e(j,{}):B,G=o(W),H=i(A),I=["flex w-full flex-col items-center justify-center text-center",a[k][u],v[k][u],c[u],p[u],y,g[n],G.className,E??""].filter(Boolean).join(" ");return l({render:z,ref:Z,props:{role:"status",className:I,style:{...h(N,w),...G.style,...F},children:t(r,{children:[i(D)?e("span",{className:`flex items-center text-(--neba-muted-fg) ${b[u]} ${m}`,children:D}):null,H||i(M)?t("div",{className:`flex max-w-prose flex-col items-center ${x[u]}`,children:[H?e("div",{className:`neba-title font-semibold ${f[u]}`,children:A}):null,i(M)?e("div",{className:`${d[u]} ${H?"text-(--neba-muted-fg)":""}`,children:M}):null]}):null,i(L)?e("div",{className:"flex flex-wrap items-center justify-center gap-2",children:L}):null]}),...R}})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{Empty}from"./Empty";
|
|
@@ -6,7 +6,7 @@ export interface FileRejection {
|
|
|
6
6
|
file: File;
|
|
7
7
|
reason: FileRejectionReason;
|
|
8
8
|
}
|
|
9
|
-
export interface FilePickerProps extends NebaStyleProps {
|
|
9
|
+
export interface FilePickerProps extends NebaStyleProps, Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'defaultValue' | 'title' | 'children'> {
|
|
10
10
|
/**
|
|
11
11
|
* Drop shadow depth. `0` (the default) is flat.
|
|
12
12
|
* @default 0
|
|
@@ -69,8 +69,6 @@ export interface FilePickerProps extends NebaStyleProps {
|
|
|
69
69
|
/** Identifies the field when a form is submitted. */
|
|
70
70
|
name?: string;
|
|
71
71
|
id?: string;
|
|
72
|
-
className?: string;
|
|
73
|
-
style?: React.CSSProperties;
|
|
74
72
|
}
|
|
75
73
|
/**
|
|
76
74
|
* `1.4 MB`, in the units a person reading a file list expects.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as n from"react";import{CloseIcon as t}from"../../internal/icons";import{controlTextLeadingClasses as a,disabledClasses as l,gapClasses as o,hasContent as i,iconClasses as s,metaTextClasses as c,radiusClasses as d,readOnlyFilterClasses as u,sheetTitleClasses as f,stackGapClasses as p,surfaceClasses as m,surfaceSlots as h,transitionClasses as b}from"../../internal/styles";const v={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"}},x={solid:[m,"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:[m,"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)]"},g={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 y(){return r("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"})]})}export function formatFileSize(e){if(e<1e3)return`${e} B`;const r=["kB","MB","GB","TB"];let n=e/1e3,t=0;for(;n>=1e3&&t<r.length-1;)n/=1e3,t+=1;return`${n<10?n.toFixed(1):Math.round(n)} ${r[t]}`}function k(e,r){const n=e.name.toLowerCase(),t=e.type.toLowerCase();return r.split(",").map(e=>e.trim().toLowerCase()).filter(Boolean).some(e=>e.startsWith(".")?n.endsWith(e):e.endsWith("/*")?t.startsWith(`${e.slice(0,-1)}`):t===e)}export const FilePicker=n.forwardRef(function({variant:m="outline",size:N="md",color:$="primary",density:j="default",elevation:w=0,accept:z,multiple:C=!1,maxSize:_,maxFiles:L,value:B,defaultValue:D,onFilesChange:I,onReject:
|
|
1
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as n from"react";import{CloseIcon as t}from"../../internal/icons";import{controlTextLeadingClasses as a,disabledClasses as l,gapClasses as o,hasContent as i,iconClasses as s,metaTextClasses as c,radiusClasses as d,readOnlyFilterClasses as u,sheetTitleClasses as f,stackGapClasses as p,surfaceClasses as m,surfaceSlots as h,transitionClasses as b}from"../../internal/styles";const v={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"}},x={solid:[m,"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:[m,"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)]"},g={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 y(){return r("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"})]})}export function formatFileSize(e){if(e<1e3)return`${e} B`;const r=["kB","MB","GB","TB"];let n=e/1e3,t=0;for(;n>=1e3&&t<r.length-1;)n/=1e3,t+=1;return`${n<10?n.toFixed(1):Math.round(n)} ${r[t]}`}function k(e,r){const n=e.name.toLowerCase(),t=e.type.toLowerCase();return r.split(",").map(e=>e.trim().toLowerCase()).filter(Boolean).some(e=>e.startsWith(".")?n.endsWith(e):e.endsWith("/*")?t.startsWith(`${e.slice(0,-1)}`):t===e)}export const FilePicker=n.forwardRef(function({variant:m="outline",size:N="md",color:$="primary",density:j="default",elevation:w=0,accept:z,multiple:C=!1,maxSize:_,maxFiles:L,value:B,defaultValue:D,onFilesChange:I,onReject:M,label:F,description:W,error:S,invalid:R,title:T,hint:V,icon:E,showList:O=!0,removeLabel:q=e=>`Remove ${e}`,fullWidth:A=!0,disabled:P=!1,readOnly:G=!1,required:H=!1,name:Y,id:J,className:K,style:Q,...U},X){const Z=n.useRef(null);n.useImperativeHandle(X,()=>Z.current);const[ee,re]=n.useState(()=>[...D??[]]),ne=n.useMemo(()=>B?[...B]:ee,[B,ee]),te=n.useRef(0),[ae,le]=n.useState(!1),oe=i(S),ie=R??oe,se=ie?"danger":$,ce=P||G,de=n.useId(),ue=n.useCallback(e=>{B||re(e),I?.(e)},[I,B]),fe=n.useCallback(e=>{const r=[],n=[],t=C?L??Number.POSITIVE_INFINITY:1,a=C?ne.length:0;for(const l of e)z&&!k(l,z)?n.push({file:l,reason:"type"}):void 0!==_&&l.size>_?n.push({file:l,reason:"size"}):a+r.length>=t?n.push({file:l,reason:"count"}):r.push(l);return{kept:r,rejections:n}},[z,ne.length,L,_,C]),pe=n.useCallback(e=>{const{kept:r,rejections:n}=fe(e);n.length>0&&M?.(n),r.length>0&&ue(C?[...ne,...r]:r)},[fe,ue,ne,C,M]),me=["flex w-full flex-col items-center justify-center text-center","cursor-pointer select-none",v[j][N],d[N],o[N],b,s,"focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2",P?`${l[m]} border-2 border-dashed`:G?`${x[m]} ${u} cursor-default`:x[m],ce?"":g[m],ae&&!ce?"bg-(--n-soft-press) [border-color:var(--n-ring)]":""].filter(Boolean).join(" ");return r("div",{className:["flex-col align-top",p[N],A?"flex w-full":"inline-flex",K??""].filter(Boolean).join(" "),style:{...h(se,w),...Q},...U,children:[i(F)?e("span",{className:[c[N],"font-medium",P?"text-(--neba-disabled-fg)":"text-(--neba-fg)"].join(" "),children:F}):null,r("div",{className:"flex w-full flex-col",onDragEnter:e=>{ce||(e.preventDefault(),te.current+=1,le(!0))},onDragOver:e=>{ce||(e.preventDefault(),e.dataTransfer.dropEffect="copy")},onDragLeave:()=>{ce||(te.current=Math.max(0,te.current-1),0===te.current&&le(!1))},onDrop:e=>{ce||(e.preventDefault(),te.current=0,le(!1),pe(Array.from(e.dataTransfer.files)))},children:[r("button",{type:"button",id:J,disabled:P,"aria-describedby":i(W)||oe?de:void 0,"aria-invalid":ie||void 0,className:me,onClick:()=>{ce||Z.current&&(Z.current.value="",Z.current.click())},children:[void 0===E?e("span",{className:"flex items-center text-(--n-accent) [&_svg]:size-[1.8em]",children:e(y,{})}):i(E)?e("span",{className:"flex items-center text-(--n-accent) [&_svg]:size-[1.8em]",children:E}):null,e("span",{className:`font-medium ${f[N]}`,children:T??"Drop files here, or click to browse"}),i(V)?e("span",{className:`text-(--neba-muted-fg) ${c[N]}`,children:V}):null]}),e("input",{ref:Z,type:"file",name:Y,accept:z,multiple:C,required:H&&0===ne.length,disabled:ce,tabIndex:-1,"aria-hidden":"true",className:"absolute size-px overflow-hidden opacity-0 [clip-path:inset(50%)]",onChange:e=>pe(Array.from(e.target.files??[]))})]}),O&&ne.length>0?e("ul",{role:"list",className:`flex w-full flex-col ${p[N]} m-0 list-none p-0`,children:ne.map((n,l)=>r("li",{className:["flex w-full items-center gap-2 px-2 py-1.5",d.xs,a[N],"bg-(--n-soft) text-(--neba-fg)"].join(" "),children:[e("span",{className:"min-w-0 flex-1 truncate",children:n.name}),e("span",{className:`shrink-0 text-(--neba-muted-fg) tabular-nums ${c[N]}`,children:formatFileSize(n.size)}),ce?null:e("button",{type:"button","aria-label":q(n.name),className:["inline-flex shrink-0 cursor-pointer items-center justify-center rounded-full","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:()=>ue(ne.filter((e,r)=>r!==l)),children:e(t,{})})]},`${n.name}-${n.size}-${n.lastModified}-${l}`))}):null,i(W)&&!oe?e("span",{id:de,className:`${c[N]} text-(--neba-muted-fg)`,children:W}):null,oe?e("span",{id:de,className:`${c[N]} text-(--n-accent)`,children:S}):null]})});
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { NebaCorner, NebaElevation, NebaPosition, NebaStyleProps } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Where a floating button sits, with one value the shared vocabulary does not
|
|
5
|
+
* have.
|
|
6
|
+
*
|
|
7
|
+
* `absolute` is not a second spelling of anything in `NebaPosition` — it is the
|
|
8
|
+
* fourth CSS value, and it is the one that makes a floating button belong to a
|
|
9
|
+
* *region* rather than to the window: a FAB in a card, in a map, on the screen
|
|
10
|
+
* of a Mockup. Without it, the only way to pin one inside a box is a wrapper
|
|
11
|
+
* with a `position` of its own.
|
|
12
|
+
*/
|
|
13
|
+
export type FloatingActionButtonPosition = NebaPosition | 'absolute';
|
|
14
|
+
/**
|
|
15
|
+
* Which way the actions fan out from the button.
|
|
16
|
+
*
|
|
17
|
+
* Physical rather than logical, for the reason `NebaSide` gives: above is above
|
|
18
|
+
* in every writing direction. The horizontal axis is deliberately not offered —
|
|
19
|
+
* a dial that fans sideways out of a corner fans into the edge of the screen.
|
|
20
|
+
*/
|
|
21
|
+
export type FloatingActionButtonDirection = 'top' | 'bottom';
|
|
22
|
+
export interface FloatingActionButtonProps extends NebaStyleProps, Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'onClick'> {
|
|
23
|
+
/** The glyph on the button. @default a plus */
|
|
24
|
+
icon?: React.ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* What the button does, in words.
|
|
27
|
+
*
|
|
28
|
+
* Required, and the one prop here that is: a button whose whole label is a
|
|
29
|
+
* drawing has no accessible name at all. With `extended` it is also the word
|
|
30
|
+
* written on the button, so the two never say different things.
|
|
31
|
+
*/
|
|
32
|
+
label: string;
|
|
33
|
+
/**
|
|
34
|
+
* Writes `label` beside the glyph, which turns the disc into a stadium — the
|
|
35
|
+
* extended floating button, for the one action a screen is about.
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
extended?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The glyph while the dial is open. Defaults to a × when the button has
|
|
41
|
+
* actions and to nothing at all when it does not; pass the same node as
|
|
42
|
+
* `icon` to keep the glyph unchanged.
|
|
43
|
+
*/
|
|
44
|
+
openIcon?: React.ReactNode;
|
|
45
|
+
/**
|
|
46
|
+
* Drop shadow depth. `2` here, against the `0` everything else defaults to,
|
|
47
|
+
* for the reason Pill's is `2`: this button is defined by not being part of
|
|
48
|
+
* the page. Every other control rests on the page and earns its separation
|
|
49
|
+
* from the acrylic edge; this one hovers over whatever is underneath it.
|
|
50
|
+
* @default 2
|
|
51
|
+
*/
|
|
52
|
+
elevation?: NebaElevation;
|
|
53
|
+
/**
|
|
54
|
+
* How it sits in the page. `fixed` — the default — pins it to a corner of the
|
|
55
|
+
* window; `absolute` pins it to a corner of the nearest positioned ancestor;
|
|
56
|
+
* `static` puts it back in the flow, which is what a floating button inside a
|
|
57
|
+
* Toolbar is.
|
|
58
|
+
* @default 'fixed'
|
|
59
|
+
*/
|
|
60
|
+
position?: FloatingActionButtonPosition;
|
|
61
|
+
/** Which corner it is pinned to. @default 'bottom-end' */
|
|
62
|
+
corner?: NebaCorner;
|
|
63
|
+
/**
|
|
64
|
+
* How far in from both edges, as a CSS length or a number of pixels.
|
|
65
|
+
* @default 16
|
|
66
|
+
*/
|
|
67
|
+
offset?: number | string;
|
|
68
|
+
/**
|
|
69
|
+
* Which way the actions fan out. Taken from `corner` when it is left out — up
|
|
70
|
+
* from the bottom of the screen, down from the top — which is right often
|
|
71
|
+
* enough that it is rarely written down.
|
|
72
|
+
*/
|
|
73
|
+
direction?: FloatingActionButtonDirection;
|
|
74
|
+
/** Whether the dial is open. Use with `onOpenChange` for a controlled dial. */
|
|
75
|
+
open?: boolean;
|
|
76
|
+
/** Where an uncontrolled dial starts. @default false */
|
|
77
|
+
defaultOpen?: boolean;
|
|
78
|
+
onOpenChange?: (open: boolean) => void;
|
|
79
|
+
/**
|
|
80
|
+
* Opens the dial when a mouse comes to rest on the button. Touch and pen are
|
|
81
|
+
* excluded: there is no hovering with a finger, and a dial that opened on the
|
|
82
|
+
* first half of a tap would swallow the second.
|
|
83
|
+
* @default true
|
|
84
|
+
*/
|
|
85
|
+
openOnHover?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Closes the dial when one of the actions is pressed.
|
|
88
|
+
* @default true
|
|
89
|
+
*/
|
|
90
|
+
closeOnAction?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Draws each action's name on a lozenge beside it. Turned off, the names are
|
|
93
|
+
* still read out — they are what `label` is on a FloatingAction.
|
|
94
|
+
* @default true
|
|
95
|
+
*/
|
|
96
|
+
showLabels?: boolean;
|
|
97
|
+
/** Unavailable. The button and every action stop answering. */
|
|
98
|
+
disabled?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Fires when the button itself is pressed. It still fires when the button has
|
|
101
|
+
* actions, where the press also opens and closes the dial.
|
|
102
|
+
*/
|
|
103
|
+
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
104
|
+
/** The FloatingActions, if there are any. */
|
|
105
|
+
children?: React.ReactNode;
|
|
106
|
+
}
|
|
107
|
+
export interface FloatingActionProps extends Omit<React.ComponentPropsWithoutRef<'button'>, 'color'> {
|
|
108
|
+
/** The glyph. */
|
|
109
|
+
icon?: React.ReactNode;
|
|
110
|
+
/** What the action does, in words. Drawn beside it, and always read out. */
|
|
111
|
+
label: string;
|
|
112
|
+
/** Unavailable, but still part of the dial. */
|
|
113
|
+
disabled?: boolean;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The one action a screen is about, floating over it — and, when it is given
|
|
117
|
+
* children, the small set of actions that fan out of it.
|
|
118
|
+
*
|
|
119
|
+
* The button itself is a [Button], unchanged: the variants, the elevation
|
|
120
|
+
* ladder, the pointer light and the press behaviour are the ones every other
|
|
121
|
+
* control has, because two components drawing the same surface from two copies
|
|
122
|
+
* of the same table are two components that will eventually disagree. What is
|
|
123
|
+
* added here is where it sits and what comes out of it.
|
|
124
|
+
*
|
|
125
|
+
* The dial is deliberately not a menu. `role="menu"` is a promise about keyboard
|
|
126
|
+
* behaviour — one tab stop for the set, arrow keys within it, typeahead — and a
|
|
127
|
+
* fan of buttons that claims it without implementing it is worse for a keyboard
|
|
128
|
+
* reader than one that never claimed anything; what a genuine menu wants is
|
|
129
|
+
* [Menu], which is one. What is claimed instead is `aria-expanded` and
|
|
130
|
+
* `aria-controls`, and the actions are ordinary buttons in the tab order right
|
|
131
|
+
* after the one that revealed them.
|
|
132
|
+
*
|
|
133
|
+
* Nothing is transformed on the way in or out. The actions are in the document
|
|
134
|
+
* or they are not, and the glyph swaps rather than spinning — the house rule
|
|
135
|
+
* against moving a control holds hardest on the control that is on top of
|
|
136
|
+
* everything else.
|
|
137
|
+
*/
|
|
138
|
+
export declare const FloatingActionButton: React.ForwardRefExoticComponent<FloatingActionButtonProps & React.RefAttributes<HTMLDivElement>>;
|
|
139
|
+
/**
|
|
140
|
+
* One action in the dial.
|
|
141
|
+
*
|
|
142
|
+
* It has no `size`, no `color` and no `variant` of its own: all three belong to
|
|
143
|
+
* the button it came out of, which is the only place they can be set once and
|
|
144
|
+
* mean the same thing for every action.
|
|
145
|
+
*/
|
|
146
|
+
export declare const FloatingAction: React.ForwardRefExoticComponent<FloatingActionProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as o from"react";import{Button as n}from"../button/Button";import{CloseIcon as s,PlusIcon as a}from"../../internal/icons";import{cx as r,hasContent as i,metaTextClasses as l,radiusClasses as c,surfaceClasses as d}from"../../internal/styles";const f=o.createContext({variant:"solid",size:"md",color:"primary",density:"default",elevation:1,showLabels:!0,reversed:!0,close:()=>{}}),p={xs:"xs",sm:"xs",md:"sm",lg:"md",xl:"lg"},m={static:"",absolute:"absolute z-30",sticky:"sticky z-30",fixed:"fixed z-40"},u={"top-start":"top-(--n-fab-offset) start-(--n-fab-offset)","top-end":"top-(--n-fab-offset) end-(--n-fab-offset)","bottom-start":"bottom-(--n-fab-offset) start-(--n-fab-offset)","bottom-end":"bottom-(--n-fab-offset) end-(--n-fab-offset)"},b=r("pointer-events-none max-w-40 truncate select-none","px-2 py-0.5 text-(--neba-fg) bg-(--n-panel)",d,c.xs,"[box-shadow:var(--neba-shadow-1),var(--neba-plate-glass)]");export const FloatingActionButton=o.forwardRef(function({variant:i="solid",size:l="lg",color:c="primary",density:d="default",elevation:b=2,icon:v,label:x,extended:y=!1,openIcon:h,position:g="fixed",corner:w="bottom-end",offset:z=16,direction:C,open:k,defaultOpen:L=!1,onOpenChange:N,openOnHover:E=!0,closeOnAction:P=!0,showLabels:R=!0,disabled:A=!1,className:I,style:O,children:j,onClick:B,onKeyDown:D,onPointerEnter:F,onPointerLeave:K,...T},W){const H=o.useId(),M=o.useRef(null),S=o.useRef(null),[$,q]=o.useState(L),G=void 0!==k,J=o.Children.toArray(j).length>0,Q=(G?k:$)&&J&&!A,U=o.useCallback(e=>{G||q(e),N?.(e)},[G,N]),V=o.useCallback(()=>U(!1),[U]);o.useEffect(()=>{if(!Q)return;const e=e=>{const t=S.current;t&&e.target instanceof Node&&!t.contains(e.target)&&V()};return document.addEventListener("pointerdown",e),()=>document.removeEventListener("pointerdown",e)},[Q,V]);const X=C??(w.startsWith("bottom")?"top":"bottom"),Y=w.endsWith("end"),Z=o.useMemo(()=>({variant:i,size:p[l],color:c,density:d,elevation:b,showLabels:R,reversed:Y,close:P?V:()=>{}}),[i,l,c,d,b,R,Y,P,V]),_=Q&&!1!==h?h??e(s,{}):v??e(a,{});return t("div",{ref:e=>{S.current=e,"function"==typeof W?W(e):W&&(W.current=e)},className:r("flex w-fit","top"===X?"flex-col-reverse":"flex-col",Y?"items-end":"items-start","xs"===l||"sm"===l?"gap-1.5":"gap-2",m[g],"static"===g?"":u[w],I),style:{"--n-fab-offset":"number"==typeof z?`${z}px`:z,...O},onKeyDown:e=>{"Escape"===e.key&&Q&&(e.stopPropagation(),V(),M.current?.focus()),D?.(e)},onPointerEnter:e=>{E&&J&&!A&&"mouse"===e.pointerType&&U(!0),F?.(e)},onPointerLeave:e=>{E&&"mouse"===e.pointerType&&V(),K?.(e)},...T,children:[e(n,{ref:M,variant:i,size:l,color:c,density:d,elevation:b,disabled:A,"aria-label":x,"aria-expanded":J?Q:void 0,"aria-controls":J&&Q?H:void 0,startIcon:_,style:{borderRadius:"9999px"},onClick:e=>{J&&U(!Q),B?.(e)},children:y?x:void 0}),Q?e("div",{id:H,className:r("flex","top"===X?"flex-col-reverse":"flex-col",Y?"items-end":"items-start","xs"===l||"sm"===l?"gap-1.5":"gap-2"),children:e(f.Provider,{value:Z,children:j})}):null]})});export const FloatingAction=o.forwardRef(function({icon:s,label:a,disabled:c=!1,className:d,onClick:p,...m},u){const v=o.useContext(f);return t("div",{className:r("flex items-center gap-2",v.reversed?"flex-row-reverse":"flex-row",d),children:[e(n,{ref:u,variant:v.variant,size:v.size,color:v.color,density:v.density,elevation:v.elevation,disabled:c,"aria-label":a,startIcon:s,style:{borderRadius:"9999px"},onClick:e=>{p?.(e),v.close()},...m}),v.showLabels&&i(a)?e("span",{"aria-hidden":"true",className:r(b,l[v.size]),children:a}):null]})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FloatingActionButton';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./FloatingActionButton";
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ChartScaleKind } from '../../internal/chart';
|
|
3
|
+
import type { NebaChartCategory, NebaChartLegend, NebaChartSeries } from '../../types';
|
|
4
|
+
import type { ChartBaseProps } from '../../internal/chart-frame';
|
|
5
|
+
export interface HeatmapChartProps extends Omit<ChartBaseProps, 'legend'> {
|
|
6
|
+
/**
|
|
7
|
+
* The rows. Each series is a row of the grid or a group of the treemap, and
|
|
8
|
+
* each datum a cell or a tile.
|
|
9
|
+
*
|
|
10
|
+
* `y` is the magnitude and `x` names the column. A `null` is a gap: the cell
|
|
11
|
+
* is left as surface rather than drawn as the bottom of the scale, because
|
|
12
|
+
* "nothing happened" and "the least of anything" are not the same reading.
|
|
13
|
+
*/
|
|
14
|
+
series: readonly NebaChartSeries[];
|
|
15
|
+
/** The column names. Points may carry their own `x` instead. */
|
|
16
|
+
categories?: readonly NebaChartCategory[];
|
|
17
|
+
/**
|
|
18
|
+
* - `grid` — a cell per row and column, which is the shape for two
|
|
19
|
+
* categorical axes and one magnitude: hours against weekdays, a cohort
|
|
20
|
+
* against a week.
|
|
21
|
+
* - `treemap` — a tile per datum, sized by its share and packed to fill the
|
|
22
|
+
* box. For parts of a whole where the parts are grouped and there are more
|
|
23
|
+
* of them than a [PieChart](./pie-chart) can hold.
|
|
24
|
+
* @default 'grid'
|
|
25
|
+
*/
|
|
26
|
+
shape?: 'grid' | 'treemap';
|
|
27
|
+
/**
|
|
28
|
+
* How the magnitude is coloured.
|
|
29
|
+
*
|
|
30
|
+
* - `sequential` — one hue, pale to deep. The default, and right whenever
|
|
31
|
+
* more is simply more.
|
|
32
|
+
* - `diverging` — two hues either side of a neutral, for a value with a
|
|
33
|
+
* *middle* that means something: over and under target, gained and lost.
|
|
34
|
+
* Reached for on a plain magnitude it invents a boundary the data has none
|
|
35
|
+
* of.
|
|
36
|
+
* @default 'sequential'
|
|
37
|
+
*/
|
|
38
|
+
scale?: ChartScaleKind;
|
|
39
|
+
/** Where a `diverging` scale turns over. @default 0 */
|
|
40
|
+
midpoint?: number;
|
|
41
|
+
/** Where the scale starts and ends. Taken from the data otherwise. */
|
|
42
|
+
min?: number;
|
|
43
|
+
max?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Writes each cell's value on it, where the cell is big enough for the text
|
|
46
|
+
* to fit with room either side. A label that does not fit is dropped rather
|
|
47
|
+
* than clipped — the tooltip and the table still have it.
|
|
48
|
+
* @default 'none'
|
|
49
|
+
*/
|
|
50
|
+
valueLabels?: 'none' | 'all';
|
|
51
|
+
/** Where the scale legend sits. `false` leaves it off. */
|
|
52
|
+
legend?: boolean | Pick<NebaChartLegend, 'side' | 'align'>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A magnitude per cell, coloured rather than measured.
|
|
56
|
+
*
|
|
57
|
+
* Two shapes of the same idea. A `grid` is the one to reach for when both axes
|
|
58
|
+
* are categorical and the question is *where* — which hour of which day, which
|
|
59
|
+
* cohort in which week; a bar chart of the same data would be forty bars nobody
|
|
60
|
+
* can scan. A `treemap` is for parts of a whole with more parts than a
|
|
61
|
+
* [PieChart](./pie-chart) can hold, and it is the same component because the
|
|
62
|
+
* data is the same shape: a row of a heatmap and a group of a treemap are both
|
|
63
|
+
* a named series of named magnitudes.
|
|
64
|
+
*
|
|
65
|
+
* Colour here encodes *size* and not identity, so it comes off a one-hue ramp
|
|
66
|
+
* rather than off the categorical palette — a heatmap in eight hues says its
|
|
67
|
+
* cells are eight unrelated things.
|
|
68
|
+
*/
|
|
69
|
+
export declare function HeatmapChart({ series, categories, shape, scale, midpoint, min, max, valueLabels, height, format, locale, label, legend, tooltip, empty, size, variant, padded, className, ...box }: HeatmapChartProps): React.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as l from"react";import{ChartScaleLegend as n,ChartSurface as i,ChartTooltipPanel as a,useMeasuredWidth as r}from"../../internal/chart-frame";import{categoryAt as o,chartFontSizes as d,compactNumber as h,formatCategory as c,markGap as s,plotHeights as m,rampFill as u,rampInk as x,rampStep as f,rampSteps as g,squarify as p,textWidth as v,toValues as w,truncate as b}from"../../internal/chart";import{numberFormatter as y}from"../../internal/format";import{cx as M,metaTextClasses as k,srOnlyClasses as A}from"../../internal/styles";import{useMessages as N}from"../../internal/i18n";export function HeatmapChart({series:z,categories:E,shape:S="grid",scale:j="sequential",midpoint:B=0,min:C,max:I,valueLabels:_="none",height:D,format:L,locale:P,label:R,legend:q,tooltip:H,empty:K,size:U="md",variant:W="text",padded:F=!1,className:G,...J}){const O=l.useRef(null),Q=r(O),T=N(P),V=l.useId(),[X,Y]=l.useState(null),Z=l.useCallback(e=>L?y(P,L).format(e):h(e,P),[L,P]),ee=l.useMemo(()=>w(z),[z]),te=ee.reduce((e,t)=>Math.max(e,t.length),0),le=l.useMemo(()=>Array.from({length:te},(e,t)=>o(t,E,ee)),[te,E,ee]),ne=l.useMemo(()=>z.map((e,t)=>e.name??`${t+1}`),[z]),ie=l.useMemo(()=>{let e=1/0,t=-1/0,l=!1;for(const n of ee)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},[ee]),ae=C??ie?.min??0,re=I??ie?.max??1,oe=l.useCallback(e=>f(e,ae,re,j,B),[ae,re,j,B]),de="number"==typeof D?D:m[U]??220,he=d[U],ce=!0===q||void 0===q||!1===q?{}:q,se=!1!==q,me=ce.side??"bottom",ue=!1===H?{mode:"none"}:!0===H||void 0===H?{}:H,xe="none"===ue.mode,fe=null===ie||0===te||0===z.length,ge=l.useMemo(()=>{if("treemap"===S||Q<=0)return{texts:[],band:0};const e=Math.min(150,.25*Q),t=ne.map(t=>b(t,e,he));return{texts:t,band:t.reduce((e,t)=>Math.max(e,v(t,he)),0)+10}},[S,ne,Q,he]),pe="treemap"===S?0:he+8,ve={left:ge.band,width:Math.max(0,Q-ge.band),height:Math.max(0,de-pe)},we=l.useMemo(()=>{if(ve.width<=0||ve.height<=0)return[];if("treemap"===S){const e=[];return ee.forEach((t,l)=>t.forEach((t,n)=>{null!==t.value&&e.push({row:l,index:n,cell:t})})),p(e.map(e=>Math.max(0,e.cell.value??0)),ve.width,ve.height).map(t=>({row:e[t.index].row,index:e[t.index].index,cell:e[t.index].cell,x:ve.left+t.x,y:t.y,width:t.width,height:t.height}))}const e=ve.height/Math.max(1,z.length),t=ve.width/Math.max(1,te),l=[];return ee.forEach((n,i)=>n.forEach((n,a)=>{null!==n.value&&l.push({row:i,index:a,cell:n,x:ve.left+a*t,y:i*e,width:t,height:e})})),l},[S,ee,z.length,te,ve.left,ve.width,ve.height]),be=l.useCallback(e=>c(e.cell.x??E?.[e.index]??le[e.index]??e.index,P),[E,le,P]),ye=null===X?null:we.find(e=>e.row===X.row&&e.index===X.index)??null,Me=null===ye?[]:[{seriesIndex:ye.row,color:ye.cell.color??u(oe(ye.cell.value??0),j),value:ye.cell.value,formatted:Z(ye.cell.value??0),label:ye.cell.label}],ke=Array.from({length:g},(e,t)=>u(t,j));return e(i,{...J,size:U,variant:W,padded:F,className:G,legendSide:me,legend:se&&!fe?e(n,{steps:ke,from:Z("diverging"===j?-$(ae,re,B)+B:ae),to:Z("diverging"===j?$(ae,re,B)+B:re),middle:"diverging"===j?Z(B):void 0,align:ce.align??"center",vertical:"left"===me||"right"===me,size:U}):null,table:fe?null:t("table",{id:V,className:A,children:[R?e("caption",{children:R}):null,e("thead",{children:t("tr",{children:[e("th",{scope:"col"}),le.map((t,l)=>e("th",{scope:"col",children:c(t,P)},l))]})}),e("tbody",{children:ee.map((l,n)=>t("tr",{children:[e("th",{scope:"row",children:ne[n]}),le.map((t,n)=>{const i=l[n];return e("td",{children:void 0!==i?.label?i.label:null==i?.value?"":Z(i.value)},n)})]},n))})]}),children:t("div",{ref:O,role:"img",tabIndex:fe?void 0:0,"aria-label":R,"aria-describedby":fe?void 0:V,onPointerLeave:()=>Y(null),onBlur:()=>Y(null),onKeyDown:e=>{if(xe||0===we.length)return;const t=null===X?-1:we.findIndex(e=>e.row===X.row&&e.index===X.index);if("ArrowRight"===e.key||"ArrowDown"===e.key){const e=we[Math.min(we.length-1,t+1)];Y({row:e.row,index:e.index})}else if("ArrowLeft"===e.key||"ArrowUp"===e.key){const e=we[Math.max(0,(-1===t?we.length:t)-1)];Y({row:e.row,index:e.index})}else{if("Escape"!==e.key)return;Y(null)}e.preventDefault()},className:M("relative w-full rounded-(--neba-radius-xs)","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2"),style:{height:de},children:[fe?e("div",{className:M("flex h-full items-center justify-center text-(--neba-muted-fg)",k[U]),children:K??T.empty.title}):Q>0?t("svg",{width:Q,height:de,viewBox:`0 0 ${Q} ${de}`,"aria-hidden":"true",className:"block",children:[we.map(l=>{const n=oe(l.cell.value??0),i=X?.row===l.row&&X?.index===l.index,a=Math.max(0,l.width-s),r=Math.max(0,l.height-s);if(a<=0||r<=0)return null;const o=Z(l.cell.value??0),d="treemap"===S?"all"===_?[be(l),o]:[be(l)]:"all"===_?[o]:[],h=d.filter(e=>function(e,t,l,n){return l>=1.8*n&&t>=Math.min(v(e,n),2.5*n)+8}(e,a,r/d.length,he)),c=l.cell.color?"var(--neba-surface)":x(n,j);return t("g",{children:[e("rect",{x:l.x+s/2,y:l.y+s/2,width:a,height:r,rx:Math.min(3,a/2,r/2),fill:l.cell.color??u(n,j),opacity:i?1:.94,onPointerEnter:xe?void 0:()=>Y({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)*(he+2),textAnchor:"middle",dominantBaseline:"central",fontSize:he,fontWeight:0===n?500:400,fill:c,opacity:0===n?1:.85,pointerEvents:"none",className:0===n&&"treemap"===S?void 0:"tabular-nums",children:b(t,l.width-8,he)},n))]},`${l.row}-${l.index}`)}),"grid"===S?ge.texts.map((t,l)=>e("text",{x:ve.left-8,y:(l+.5)*ve.height/Math.max(1,z.length),textAnchor:"end",dominantBaseline:"central",fontSize:he,fill:"var(--neba-muted-fg)",children:t},`row-${l}`)):null,"grid"===S?le.map((t,l)=>{const n=ve.width/Math.max(1,te),i=c(t,P);return l%Math.max(1,Math.ceil((v(i,he)+8)/Math.max(1,n)))!==0?null:e("text",{x:ve.left+(l+.5)*n,y:ve.height+he,textAnchor:"middle",fontSize:he,fill:"var(--neba-muted-fg)",children:i},`col-${l}`)}):null]}):null,ye&&!xe?ue.render?e("div",{className:"pointer-events-none absolute z-10",style:{left:ye.x+ye.width/2,top:ye.y},children:ue.render({index:ye.index,category:ye.cell.x??le[ye.index]??ye.index,items:Me})}):e(a,{heading:`${ne[ye.row]} · ${be(ye)}`,items:Me,x:ye.x+ye.width/2,y:ye.y,flip:ye.x+ye.width/2>.6*Q,size:U}):null]})})}function $(e,t,l){return Math.max(Math.abs(t-l),Math.abs(l-e))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{HeatmapChart}from"./HeatmapChart";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as n}from"react/jsx-runtime";import*as e from"react";import{transitionClasses as t}from"../../internal/styles";const r={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)"},o={regular:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},l=/[\p{L}\p{N}_]/u;function i(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function a(n,e,t){const r=e>0?n[e-1]:"",o=t<n.length?n[t]:"";return!l.test(r)&&!l.test(o)}function s(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 s=l.index,c=s+l[0].length;t&&!a(n,s,c)||(s>i&&o.push(n.slice(i,s)),o.push(r(l[0],`${s}`)),i=c)}return 0===o.length?n:(i<n.length&&o.push(n.slice(i)),o)}function c(n,t,r,o){if("string"==typeof n)return s(n,t,r,o);if("number"==typeof n)return s(String(n),t,r,o);if(Array.isArray(n))return e.Children.map(n,n=>c(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,c(l,t,r,o))}return n}export const Highlight=e.forwardRef(function({query:l,variant:a="solid",color:s="warning",caseSensitive:u=!1,wholeWord:f=!1,underline:d=!1,weight:m,className:
|
|
1
|
+
import{jsx as n}from"react/jsx-runtime";import*as e from"react";import{transitionClasses as t}from"../../internal/styles";const r={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)"},o={regular:"font-normal",medium:"font-medium",semibold:"font-semibold",bold:"font-bold"},l=/[\p{L}\p{N}_]/u;function i(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function a(n,e,t){const r=e>0?n[e-1]:"",o=t<n.length?n[t]:"";return!l.test(r)&&!l.test(o)}function s(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 s=l.index,c=s+l[0].length;t&&!a(n,s,c)||(s>i&&o.push(n.slice(i,s)),o.push(r(l[0],`${s}`)),i=c)}return 0===o.length?n:(i<n.length&&o.push(n.slice(i)),o)}function c(n,t,r,o){if("string"==typeof n)return s(n,t,r,o);if("number"==typeof n)return s(String(n),t,r,o);if(Array.isArray(n))return e.Children.map(n,n=>c(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,c(l,t,r,o))}return n}export const Highlight=e.forwardRef(function({query:l,variant:a="solid",color:s="warning",caseSensitive:u=!1,wholeWord:f=!1,underline:d=!1,weight:m,className:g,style:p,children:h,...b},x){const y=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(i).join("|"),e?"gu":"giu")}(l,u),[l,u]),v=["rounded-[0.25rem] px-0.5 -mx-0.5","box-decoration-clone",r[a],d?"underline decoration-2 underline-offset-2":"",m?o[m]:"",t].filter(Boolean).join(" "),$=y?c(h,y,f,(e,t)=>n("mark",{className:v,children:e},t)):h;return n("span",{ref:x,className:g,style:{"--n-fill":`var(--neba-${s}-fill)`,"--n-on-solid":`var(--neba-${s}-on-solid)`,"--n-accent":`var(--neba-${s}-accent)`,"--n-panel":`var(--neba-${s}-panel)`,"--n-line":`var(--neba-${s}-line)`,...p},...b,children:$})});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type CartesianChartProps } from '../../internal/chart-frame';
|
|
3
|
+
import { type ChartMarkers } from '../../internal/chart-line';
|
|
4
|
+
import type { NebaChartCurve, NebaChartValueLabels } from '../../types';
|
|
5
|
+
export interface LineChartProps extends CartesianChartProps {
|
|
6
|
+
/**
|
|
7
|
+
* How the line gets from one point to the next.
|
|
8
|
+
*
|
|
9
|
+
* - `linear` — straight segments. The default, and the only one that claims
|
|
10
|
+
* nothing the data did not say.
|
|
11
|
+
* - `smooth` — a monotone cubic. Curved, but it will not dip below a value
|
|
12
|
+
* that both of its neighbours are above; a plain spline would.
|
|
13
|
+
* - `step` — held at each value until the next one. What a rate, a tier or a
|
|
14
|
+
* setting actually did between two readings, rather than a diagonal
|
|
15
|
+
* pretending it drifted.
|
|
16
|
+
* @default 'linear'
|
|
17
|
+
*/
|
|
18
|
+
curve?: NebaChartCurve;
|
|
19
|
+
/**
|
|
20
|
+
* Dots on the points.
|
|
21
|
+
*
|
|
22
|
+
* `auto` — the default — draws them while there are few enough points for a
|
|
23
|
+
* dot to mean something, and stops at fourteen. Whatever this says, the point
|
|
24
|
+
* under the pointer always gets one: that is what tells the reader which
|
|
25
|
+
* column the tooltip is about.
|
|
26
|
+
* @default 'auto'
|
|
27
|
+
*/
|
|
28
|
+
markers?: ChartMarkers;
|
|
29
|
+
/**
|
|
30
|
+
* Fades the line from a paler step of its own hue at the start to the full
|
|
31
|
+
* colour at the end, so the recent end of a long series is the loud one.
|
|
32
|
+
* @default false
|
|
33
|
+
*/
|
|
34
|
+
gradient?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Draws the line straight through a `null` instead of breaking at it.
|
|
37
|
+
*
|
|
38
|
+
* Off, and it should stay off unless the gap is an artefact of how the data
|
|
39
|
+
* was collected. A bridged gap is a number the chart made up.
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
connectNulls?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Which values are written on the line. `last` is the one to reach for — it
|
|
45
|
+
* names where each series ended up, which is the question a line chart is
|
|
46
|
+
* usually being asked.
|
|
47
|
+
* @default 'none'
|
|
48
|
+
*/
|
|
49
|
+
valueLabels?: NebaChartValueLabels;
|
|
50
|
+
/**
|
|
51
|
+
* Stacks the series, each line riding on the total of the ones below it.
|
|
52
|
+
*
|
|
53
|
+
* Rare on a line chart and worth thinking twice about: the reader can follow
|
|
54
|
+
* the bottom series and the top total, and nothing in between. An
|
|
55
|
+
* [AreaChart](./area-chart) is the shape that makes stacking legible.
|
|
56
|
+
* @default false
|
|
57
|
+
*/
|
|
58
|
+
stacked?: boolean;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A value against time, or against anything else with an order to it.
|
|
62
|
+
*
|
|
63
|
+
* The line is the mark that says *change*: it claims the space between two
|
|
64
|
+
* points is a journey rather than two separate facts, which is true of a
|
|
65
|
+
* temperature and false of four product categories. Reach for a
|
|
66
|
+
* [BarChart](./bar-chart) when the categories could be shuffled without losing
|
|
67
|
+
* anything.
|
|
68
|
+
*
|
|
69
|
+
* Everything around the line — the axes, the grid, the crosshair, the legend,
|
|
70
|
+
* the tooltip and the table a screen reader gets instead of the picture — comes
|
|
71
|
+
* from the shared frame, which is what makes a LineChart and a BarChart on one
|
|
72
|
+
* dashboard read as one drawing rather than two.
|
|
73
|
+
*/
|
|
74
|
+
export declare function LineChart({ curve, markers, gradient, connectNulls, valueLabels, stacked, ...props }: LineChartProps): React.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import*as r from"react";import{CartesianChart as t}from"../../internal/chart-frame";import{LineSeries as n}from"../../internal/chart-line";export function LineChart({curve:a="linear",markers:o="auto",gradient:c=!1,connectNulls:i=!1,valueLabels:l="none",stacked:s=!1,...m}){const u=r.useId().replace(/:/g,"");return e(t,{...m,stacked:s,inset:!0,includeZero:!1,headroom:"none"===l?0:10,children:r=>e(n,{context:r,curve:a,filled:!1,stacked:s,markers:o,valueLabels:l,connectNulls:i,gradient:c,idPrefix:u})})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{LineChart}from"./LineChart";
|