neba 1.9.0 → 1.11.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 +35 -5
- package/dist/components/accordion/Accordion.js +1 -1
- package/dist/components/alert/Alert.js +1 -1
- package/dist/components/anchor/Anchor.js +1 -1
- package/dist/components/animate-lighting/AnimateLighting.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.js +1 -1
- package/dist/components/badge/Badge.js +1 -1
- package/dist/components/bar-chart/BarChart.d.ts +1 -1
- package/dist/components/bar-chart/BarChart.js +1 -1
- package/dist/components/blockquote/Blockquote.js +1 -1
- package/dist/components/bottom-navigation/BottomNavigation.js +1 -1
- package/dist/components/box/Box.js +1 -1
- package/dist/components/breadcrumb/Breadcrumb.js +1 -1
- package/dist/components/button/Button.js +1 -1
- package/dist/components/button-group/ButtonGroup.js +1 -1
- package/dist/components/calendar/Calendar.d.ts +72 -0
- package/dist/components/calendar/Calendar.js +1 -0
- package/dist/components/calendar/index.d.ts +2 -0
- package/dist/components/calendar/index.js +1 -0
- 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.d.ts +13 -1
- package/dist/components/checkbox/Checkbox.js +1 -1
- package/dist/components/chip/Chip.js +1 -1
- package/dist/components/code-block/CodeBlock.js +1 -1
- package/dist/components/collapsible/Collapsible.js +1 -1
- package/dist/components/color-picker/ColorPicker.js +1 -1
- package/dist/components/combobox/Combobox.d.ts +29 -2
- package/dist/components/combobox/Combobox.js +1 -1
- package/dist/components/command-palette/CommandPalette.d.ts +19 -2
- package/dist/components/command-palette/CommandPalette.js +1 -1
- package/dist/components/confirm/Confirm.d.ts +83 -0
- package/dist/components/confirm/Confirm.js +1 -0
- package/dist/components/confirm/index.d.ts +2 -0
- package/dist/components/confirm/index.js +1 -0
- package/dist/components/container/Container.js +1 -1
- package/dist/components/data-list/DataList.js +1 -1
- package/dist/components/data-table/DataTable.d.ts +104 -1
- package/dist/components/data-table/DataTable.js +1 -1
- package/dist/components/date-picker/DatePicker.d.ts +40 -8
- package/dist/components/date-picker/DatePicker.js +1 -1
- package/dist/components/date-range-picker/DateRangePicker.js +1 -1
- package/dist/components/date-time-picker/DateTimePicker.js +1 -1
- package/dist/components/dialog/Dialog.d.ts +19 -2
- package/dist/components/dialog/Dialog.js +1 -1
- package/dist/components/divider/Divider.js +1 -1
- package/dist/components/drawer/Drawer.d.ts +1 -1
- package/dist/components/drawer/Drawer.js +1 -1
- package/dist/components/empty/Empty.js +1 -1
- package/dist/components/file-picker/FilePicker.js +1 -1
- package/dist/components/floating-action-button/FloatingActionButton.js +1 -1
- package/dist/components/floating-bottom-navigation/FloatingBottomNavigation.js +1 -1
- package/dist/components/footer/Footer.js +1 -1
- package/dist/components/gauge-chart/GaugeChart.d.ts +1 -1
- package/dist/components/gauge-chart/GaugeChart.js +1 -1
- package/dist/components/grid-container/GridContainer.js +1 -1
- package/dist/components/header/Header.js +1 -1
- package/dist/components/heatmap-chart/HeatmapChart.d.ts +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 +1 -1
- package/dist/components/hover-card/HoverCard.js +1 -1
- package/dist/components/how-to-steps/HowToSteps.js +1 -1
- package/dist/components/image/Image.d.ts +70 -0
- package/dist/components/image/Image.js +1 -0
- package/dist/components/image/index.d.ts +2 -0
- package/dist/components/image/index.js +1 -0
- package/dist/components/list/List.js +1 -1
- package/dist/components/menubar/Menubar.js +1 -1
- package/dist/components/meter/Meter.js +1 -1
- package/dist/components/mockup/Mockup.js +1 -1
- package/dist/components/number-field/NumberField.d.ts +27 -2
- package/dist/components/number-field/NumberField.js +1 -1
- package/dist/components/otp-field/OtpField.js +1 -1
- package/dist/components/overlay/Overlay.d.ts +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.d.ts +1 -1
- package/dist/components/pie-chart/PieChart.js +1 -1
- package/dist/components/pill/Pill.js +1 -1
- package/dist/components/popconfirm/Popconfirm.d.ts +71 -0
- package/dist/components/popconfirm/Popconfirm.js +1 -0
- package/dist/components/popconfirm/index.d.ts +2 -0
- package/dist/components/popconfirm/index.js +1 -0
- package/dist/components/popover/Popover.d.ts +1 -1
- package/dist/components/popover/Popover.js +1 -1
- package/dist/components/portal/Portal.d.ts +48 -0
- package/dist/components/portal/Portal.js +1 -0
- package/dist/components/portal/index.d.ts +2 -0
- package/dist/components/portal/index.js +1 -0
- 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/provider/NebaProvider.d.ts +99 -0
- package/dist/components/provider/NebaProvider.js +1 -0
- package/dist/components/provider/index.d.ts +3 -0
- package/dist/components/provider/index.js +1 -0
- package/dist/components/radio-group/RadioGroup.d.ts +22 -1
- package/dist/components/radio-group/RadioGroup.js +1 -1
- package/dist/components/rating/Rating.js +1 -1
- package/dist/components/scatter-chart/ScatterChart.d.ts +1 -1
- package/dist/components/scatter-chart/ScatterChart.js +1 -1
- package/dist/components/scroll-area/ScrollArea.js +1 -1
- package/dist/components/scroll-zone/ScrollZone.js +1 -1
- package/dist/components/select/Select.d.ts +16 -1
- package/dist/components/select/Select.js +1 -1
- package/dist/components/shortcut/Shortcut.d.ts +2 -1
- package/dist/components/shortcut/Shortcut.js +1 -1
- package/dist/components/sidebar/Sidebar.js +1 -1
- package/dist/components/sidebar/SidebarTrigger.js +1 -1
- package/dist/components/skeleton/Skeleton.js +1 -1
- package/dist/components/slider/Slider.js +1 -1
- package/dist/components/sparkline/Sparkline.js +1 -1
- package/dist/components/spoiler/Spoiler.js +1 -1
- package/dist/components/statistic/Statistic.js +1 -1
- package/dist/components/switch/Switch.d.ts +13 -1
- package/dist/components/switch/Switch.js +1 -1
- package/dist/components/table/Table.d.ts +21 -2
- package/dist/components/table/Table.js +1 -1
- package/dist/components/text-field/TextField.d.ts +27 -1
- package/dist/components/text-field/TextField.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 +1 -1
- package/dist/components/timeline-chart/TimelineChart.js +1 -1
- package/dist/components/toast/Toast.d.ts +17 -2
- package/dist/components/toast/Toast.js +1 -1
- package/dist/components/toggle/Toggle.js +1 -1
- package/dist/components/toggle-group/ToggleGroup.js +1 -1
- package/dist/components/toolbar/Toolbar.js +1 -1
- package/dist/components/tooltip/Tooltip.d.ts +1 -1
- package/dist/components/tooltip/Tooltip.js +1 -1
- package/dist/components/tour/Tour.d.ts +17 -2
- package/dist/components/tour/Tour.js +1 -1
- package/dist/components/transfer/Transfer.js +1 -1
- package/dist/components/tree-select/TreeSelect.d.ts +88 -0
- package/dist/components/tree-select/TreeSelect.js +1 -0
- package/dist/components/tree-select/index.d.ts +2 -0
- package/dist/components/tree-select/index.js +1 -0
- package/dist/components/tree-view/TreeView.js +1 -1
- package/dist/components/visually-hidden/VisuallyHidden.d.ts +37 -0
- package/dist/components/visually-hidden/VisuallyHidden.js +1 -0
- package/dist/components/visually-hidden/index.d.ts +2 -0
- package/dist/components/visually-hidden/index.js +1 -0
- package/dist/components/window-pane/WindowPane.js +1 -1
- package/dist/hooks/index.d.ts +10 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useDisclosure.d.ts +21 -0
- package/dist/hooks/useDisclosure.js +1 -0
- package/dist/hooks/useElementSize.d.ts +23 -0
- package/dist/hooks/useElementSize.js +1 -0
- package/dist/hooks/useMediaQuery.d.ts +27 -0
- package/dist/hooks/useMediaQuery.js +1 -0
- package/dist/hooks/useOnScreen.d.ts +24 -0
- package/dist/hooks/useOnScreen.js +1 -0
- package/dist/hooks/useShortcut.d.ts +34 -0
- package/dist/hooks/useShortcut.js +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1 -1
- package/dist/internal/calendar.d.ts +31 -5
- package/dist/internal/calendar.js +1 -1
- package/dist/internal/csv.d.ts +40 -0
- package/dist/internal/csv.js +1 -0
- package/dist/internal/date.d.ts +39 -1
- package/dist/internal/date.js +1 -1
- package/dist/internal/defaults.d.ts +46 -0
- package/dist/internal/defaults.js +1 -0
- package/dist/internal/i18n.d.ts +23 -0
- package/dist/internal/i18n.js +1 -1
- package/dist/internal/keys.d.ts +92 -0
- package/dist/internal/keys.js +1 -0
- package/dist/internal/media.d.ts +27 -0
- package/dist/internal/media.js +1 -1
- package/dist/internal/page-layout.d.ts +7 -0
- package/dist/internal/page-layout.js +1 -1
- package/dist/internal/picker.d.ts +7 -1
- package/dist/internal/picker.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/types.d.ts +73 -0
- package/package.json +6 -1
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { NebaElevation, NebaStyleProps } from '../../types.js';
|
|
2
|
+
import type { NebaElevation, NebaFieldSlot, NebaShortcuts, NebaSlots, NebaStyleProps } from '../../types.js';
|
|
3
3
|
/** How the multiline control may be resized by the user. Ignored when single line. */
|
|
4
4
|
export type TextFieldResize = 'none' | 'vertical' | 'horizontal' | 'both';
|
|
5
|
+
/**
|
|
6
|
+
* The parts a TextField draws behind its root.
|
|
7
|
+
*
|
|
8
|
+
* `shell` is the framed box the control sits in — the thing wearing the border,
|
|
9
|
+
* the fill and the focus ring. It is a part rather than an implementation
|
|
10
|
+
* detail because it, and not the `<input>`, is what a caller means by "the
|
|
11
|
+
* field" when they want to change its shape.
|
|
12
|
+
*/
|
|
13
|
+
export type TextFieldSlot = NebaFieldSlot | 'shell';
|
|
5
14
|
/**
|
|
6
15
|
* Native `<input>` attributes, minus the three that collide with the shared
|
|
7
16
|
* vocabulary: `color` and `size` are Neba props here, and `onChange` is widened
|
|
@@ -57,6 +66,23 @@ export interface TextFieldProps extends NebaStyleProps, NativeControlProps {
|
|
|
57
66
|
loading?: boolean;
|
|
58
67
|
/** Stretches to the width of the container. */
|
|
59
68
|
fullWidth?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Class names for the parts behind the root. `className` is the root — the
|
|
71
|
+
* column that holds the label, the shell and the two lines under it — so the
|
|
72
|
+
* control itself is reached through `classNames.control`.
|
|
73
|
+
*/
|
|
74
|
+
classNames?: NebaSlots<TextFieldSlot>;
|
|
75
|
+
/**
|
|
76
|
+
* Key combinations to act on, spelled the way
|
|
77
|
+
* [Shortcut](../display/shortcut) draws them — `{ 'Mod+Enter': send }`. Bound
|
|
78
|
+
* to the control, so `event.currentTarget` is the `<input>` or the
|
|
79
|
+
* `<textarea>` and `event.currentTarget.value` is what was typed.
|
|
80
|
+
*
|
|
81
|
+
* It runs *before* `onKeyDown`, which still sees every keystroke; neither
|
|
82
|
+
* replaces the other. Nothing is prevented on the caller's behalf — a
|
|
83
|
+
* shortcut that must not also insert a newline calls `preventDefault` itself.
|
|
84
|
+
*/
|
|
85
|
+
shortcuts?: NebaShortcuts<HTMLInputElement | HTMLTextAreaElement>;
|
|
60
86
|
onChange?: React.ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
|
61
87
|
}
|
|
62
88
|
export declare const TextField: React.ForwardRefExoticComponent<TextFieldProps & React.RefAttributes<HTMLInputElement | HTMLTextAreaElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{Field as r}from"@base-ui/react/field";import{Input as i}from"@base-ui/react/input";import{controlHeightClasses as l,controlTextLeadingClasses as
|
|
1
|
+
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{Field as r}from"@base-ui/react/field";import{Input as i}from"@base-ui/react/input";import{controlHeightClasses as l,controlTextLeadingClasses as s,cx as a,disabledClasses as o,fieldReadOnlyClasses as c,fieldRestClasses as d,focusWithinRingClasses as m,gapClasses as u,iconClasses as p,metaTextClasses as f,paddingXClasses as x,radiusClasses as h,stackGapClasses as b,surfaceSlots as g,transitionClasses as y}from"../../internal/styles.js";import{keyHandler as $}from"../../internal/keys.js";import{useStyleDefaults as w}from"../../internal/defaults.js";const v={xs:`${u.xs} ${h.xs} ${s.xs}`,sm:`${u.sm} ${h.sm} ${s.sm}`,md:`${u.md} ${h.md} ${s.md}`,lg:`${u.lg} ${h.lg} ${s.lg}`,xl:`${u.xl} ${h.xl} ${s.xl}`},N={xs:"min-h-5.5 py-[3px]",sm:"min-h-6.5 py-[4px]",md:"min-h-8 py-[5px]",lg:"min-h-10 py-[8px]",xl:"min-h-12 py-[10px]"},k={none:"resize-none",vertical:"resize-y",horizontal:"resize-x",both:"resize"},z=["group relative flex w-full cursor-text","[-webkit-tap-highlight-color:transparent]",y,"focus-within:[transition-duration:0ms]",m,p].join(" "),j=d,D=c;function C(){return t("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"animate-spin",children:[e("circle",{cx:"8",cy:"8",r:"6.5",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"2"}),e("path",{d:"M14.5 8A6.5 6.5 0 0 0 8 1.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}export const TextField=/*@__PURE__*/n.forwardRef(function(s,c){const{variant:d="outline",size:m="md",color:u="primary",density:p="default",elevation:h=0,multiline:y=!1,rows:O=3,resize:R="vertical",label:W,description:I,error:K,invalid:L,startIcon:T,endIcon:A,loading:B=!1,fullWidth:E=!1,classNames:F,shortcuts:M,onKeyDown:P,readOnly:q=!1,disabled:G=!1,type:H="text",className:J,style:Q,...S}=w(s,["size","density","variant"]),U=null!=K&&!1!==K&&""!==K,V=L??U,X=V?"danger":u,Y=n.useRef(null),Z=n.useCallback(e=>{Y.current=e,"function"==typeof c?c(e):c&&(c.current=e)},[c]),_=a(z,v[m],y?`${N[m]} items-start`:`${l[m]} items-center`,x[p][m],G?o[d]:q?D[d]:j[d],F?.shell),ee=a("min-w-0 flex-1 bg-transparent [font:inherit] text-inherit","[outline:none]","placeholder:text-(--neba-muted-fg)","caret-(--n-accent) selection:bg-(--n-soft-press)","disabled:cursor-not-allowed",y?`block ${k[R]}`:"self-stretch",F?.control),te="inline-flex h-[1lh] shrink-0 items-center text-(--neba-muted-fg) transition-[color] duration-(--neba-duration) group-focus-within:text-(--n-accent)";return t(r.Root,{disabled:G,invalid:V,className:a("flex-col align-top",b[m],E?"flex w-full":"inline-flex",J??""),style:{...g(X,h),...Q},children:[W?e(r.Label,{className:a(f[m],"font-medium",G?"text-(--neba-disabled-fg)":"text-(--neba-fg)",F?.label),children:W}):null,t("span",{className:_,onPointerDown:e=>{e.target!==e.currentTarget||G||(e.preventDefault(),Y.current?.focus())},children:[T?e("span",{className:te,children:T}):null,e(i,{ref:Z,className:ee,disabled:G,readOnly:q,"aria-busy":B||void 0,"data-loading":B||void 0,...y?{render:e("textarea",{rows:O})}:{type:H},...S,onKeyDown:$(M,P)}),B?e("span",{className:te,children:e(C,{})}):A?e("span",{className:te,children:A}):null]}),I?e(r.Description,{className:a(f[m],"text-(--neba-muted-fg)",F?.description),children:I}):null,e(r.Error,U?{match:!0,className:a(f[m],"text-(--n-accent)",F?.error),children:K}:{className:a(f[m],"text-(--n-accent)",F?.error)})]})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as n,Fragment as e,jsxs as r}from"react/jsx-runtime";import*as i from"react";import{useRender as a}from"@base-ui/react/use-render";import{linkMessages as o,useMessages as t}from"../../internal/i18n.js";import{ExternalLinkIcon as l,LinkIcon as s}from"../../internal/icons.js";import{safeRel as c}from"../../internal/link.js";import{controlTextLeadingClasses as m,cx as u,focusRingClasses as d,srOnlyClasses as p}from"../../internal/styles.js";const
|
|
1
|
+
"use client";import{jsx as n,Fragment as e,jsxs as r}from"react/jsx-runtime";import*as i from"react";import{useRender as a}from"@base-ui/react/use-render";import{linkMessages as o,useMessages as t}from"../../internal/i18n.js";import{ExternalLinkIcon as l,LinkIcon as s}from"../../internal/icons.js";import{safeRel as c}from"../../internal/link.js";import{controlTextLeadingClasses as m,cx as u,focusRingClasses as d,srOnlyClasses as p}from"../../internal/styles.js";import{useStyleDefaults as b}from"../../internal/defaults.js";const f={always:"[&.neba-link]:underline",hover:"[&.neba-link]:no-underline [&.neba-link]:hover:underline",none:"[&.neba-link]:no-underline"},v=["neba-link","cursor-pointer","[&_svg]:pointer-events-none [&_svg]:inline [&_svg]:size-[0.95em] [&_svg]:shrink-0",["[transition-property:color,text-decoration-color]","[transition-duration:var(--neba-duration)]","[transition-timing-function:var(--neba-ease)]"].join(" "),d,"focus-visible:rounded-[0.25rem]"].join(" ");export const TextLink=/*@__PURE__*/i.forwardRef(function(i,d){const{href:h,underline:k="always",color:j,size:g,newTab:x=!1,icon:y,locale:w,render:_,className:N,style:z,children:T,...C}=b(i,["size","locale"]),$=t(o,w),F=y??x,L=!0===F?n(x?l:s,{}):F,R=u(v,g?m[g]:"",f[k],j?"[&.neba-link]:text-(--n-accent)":"[&.neba-link]:text-inherit",N??""),q={"--n-underline":"color-mix(in oklab, currentColor 45%, transparent)","--n-underline-hover":"currentColor","--n-ring":`var(--neba-${j??"primary"}-ring)`,...j?{"--n-accent":`var(--neba-${j}-accent)`}:null},A=x?"_blank":void 0,{rel:B,...D}=C,E=c(A,B);return a({render:_??n("a",{}),ref:d,props:{href:h,target:A,className:R,style:{...q,...z},children:r(e,{children:[T,L?n("span",{className:"ms-[0.25em]",children:L}):null,x?r(e,{children:[" ",n("span",{className:p,children:$.newTab})]}):null]}),...D,rel:E}})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as n}from"react/jsx-runtime";import*as o from"react";import{Button as t}from"../button/Button.js";import{TimeGrid as l,usePickerLabels as a}from"../../internal/calendar.js";import{ClockIcon as s}from"../../internal/icons.js";import{PickerFooter as i,PickerShell as r}from"../../internal/picker.js";import{displaySamples as c,formatDate as d,isHour12 as u,isValidDate as m,secondsOfDay as p,timeUnitSpan as h,toISOTime as f,withPlaceholder as
|
|
1
|
+
"use client";import{jsx as e,jsxs as n}from"react/jsx-runtime";import*as o from"react";import{Button as t}from"../button/Button.js";import{TimeGrid as l,usePickerLabels as a}from"../../internal/calendar.js";import{ClockIcon as s}from"../../internal/icons.js";import{PickerFooter as i,PickerShell as r}from"../../internal/picker.js";import{displaySamples as c,formatDate as d,isHour12 as u,isValidDate as m,secondsOfDay as p,timeUnitSpan as h,toISOTime as f,withPlaceholder as y,withTime as S}from"../../internal/date.js";import{cx as b}from"../../internal/styles.js";import{useStyleDefaults as g}from"../../internal/defaults.js";export const TimePicker=/*@__PURE__*/o.forwardRef(function(v,j){const{value:x,defaultValue:C,onValueChange:w,open:z,defaultOpen:k,onOpenChange:D,referenceDate:O,minTime:T,maxTime:M,shouldDisableTime:V,hour12:B,showSeconds:I=!1,hourStep:N=1,minuteStep:R=1,secondStep:F=1,locale:H,format:P,placeholder:q,clearable:A=!1,showNowButton:E=!0,closeOnSelect:G=!1,labels:J,name:K,size:L="md",color:Q="primary",density:U="default",readOnly:W=!1,disabled:X=!1,startIcon:Y,...Z}=g(v,["size","density","locale"]),$=a(J),_=B??u(H),[ee,ne]=o.useState(C??null),oe=void 0!==x?x:ee,[te,le]=o.useState(k??!1),ae=z??te,[se]=o.useState(()=>O??new Date),ie=e=>{e&&(W||X)||(void 0===z&&le(e),D?.(e))},re=e=>{void 0===x&&ne(e),w?.(e)},ce=o.useCallback((e,n)=>{const[o,t]=h(n,e);return!!(m(T)&&t<p(T))||(!!(m(M)&&o>p(M))||(V?.(e,n)??!1))},[T,M,V]),de=o.useMemo(()=>P??{hour:"numeric",minute:"2-digit",...I?{second:"2-digit"}:{}},[P,I]),ue=new Date,me=S(O??se,{hours:ue.getHours(),minutes:ue.getMinutes(),seconds:I?ue.getSeconds():0}),pe=E||A||!G,he=o.useMemo(()=>y(c(H,de),q),[H,de,q]);return e(r,{...Z,size:L,color:Q,density:U,readOnly:W,disabled:X,triggerRef:j,startIcon:Y??e(s,{}),display:m(oe)?d(oe,H,de):q??"",samples:he,empty:!m(oe),clearable:A,onClear:()=>re(null),open:ae,onOpenChange:ie,labels:$,hiddenValues:K?[{name:K,value:m(oe)?f(oe,I):""}]:void 0,children:n("div",{className:b("flex flex-col",pe&&"gap-1.5"),children:[e(l,{size:L,density:U,locale:H,value:m(oe)?oe:null,referenceDate:O??se,onChange:e=>{re(e),G&&ie(!1)},hour12:_,showSeconds:I,hourStep:N,minuteStep:R,secondStep:F,shouldDisableTime:ce,labels:$,autoFocus:!0}),pe?n(i,{size:L,children:[A?e(t,{variant:"text",size:L,color:Q,density:"compact",onClick:()=>{re(null),ie(!1)},children:$.clear}):null,E?e(t,{variant:"text",size:L,color:Q,density:"compact",disabled:ce(me,"second"),onClick:()=>{re(me),ie(!1)},children:$.now}):null,G?null:e(t,{variant:"solid",size:L,color:Q,density:"compact",onClick:()=>ie(!1),children:$.done})]}):null]})})});
|
|
@@ -41,4 +41,4 @@ export interface TimelineChartProps extends Omit<CartesianChartProps, 'series' |
|
|
|
41
41
|
* steps and draws no axis at all. That one is for a sequence of events; this
|
|
42
42
|
* one is for how long each of them took.
|
|
43
43
|
*/
|
|
44
|
-
export declare function TimelineChart(
|
|
44
|
+
export declare function TimelineChart(rawProps: TimelineChartProps): React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as n}from"react/jsx-runtime";import*as t from"react";import{CartesianChart as o}from"../../internal/chart-frame.js";import{barBandRatio as r,barMaxThickness as a,barRadius as s,formatTimeTicks as l,formatTimeValue as i,markGap as c,resolveColor as m,seriesColor as d,timeScale as u,toNumber as h}from"../../internal/chart.js";import{srOnlyClasses as
|
|
1
|
+
"use client";import{jsx as e,jsxs as n}from"react/jsx-runtime";import*as t from"react";import{CartesianChart as o}from"../../internal/chart-frame.js";import{barBandRatio as r,barMaxThickness as a,barRadius as s,formatTimeTicks as l,formatTimeValue as i,markGap as c,resolveColor as m,seriesColor as d,timeScale as u,toNumber as h}from"../../internal/chart.js";import{srOnlyClasses as f}from"../../internal/styles.js";import{useStyleDefaults as x}from"../../internal/defaults.js";export function TimelineChart(n){const{series:s,min:m,max:f,barSize:y,rounded:k=!0,size:g="md",density:v="default",xAxis:j,yAxis:$,locale:C,...z}=x(n,["size","density","locale"]),w=t.useMemo(()=>s.map(p),[s]),A=t.useMemo(()=>w.map(e=>e.spans),[w]),E=t.useMemo(()=>{let e=1/0,n=-1/0,t=!1;for(const o of A)for(const r of o)r&&(t=!0,e=Math.min(e,r.from),n=Math.max(n,r.to));return t?{min:e,max:n}:null},[A]),P=t.useMemo(()=>u(E,{min:h(m)??void 0,max:h(f)??void 0,tickCount:$?.tickCount}),[E,m,f,$?.tickCount]),B=t.useMemo(()=>l(P.ticks,P.unit,C),[P,C]),I=t.useMemo(()=>s.map((e,n)=>d(e,n)),[s]),T=t.useMemo(()=>[{data:A.map(e=>e.some(Boolean)?1:null)}],[A]),F=t.useMemo(()=>s.map((e,n)=>e.name??`${n+1}`),[s]),N=y??a[g],R=t.useCallback(e=>{const n=[];return w.forEach((t,o)=>{const r=Math.min(N,Math.max(1,(e.band.band-c*(t.lanes-1))/t.lanes)),a=r*t.lanes+c*(t.lanes-1),s=e.plot.top+e.categoryPx(o)-a/2+r/2;t.spans.forEach((t,a)=>{if(!t)return;const l=e.valuePx(t.from),i=e.valuePx(t.to);n.push({series:o,index:a,x:(l+i)/2,y:s+t.lane*(r+c),r:r/2,rx:Math.max(0,(i-l)/2),ry:r/2})})}),n},[w,N]),S=t.useCallback(e=>{const n=A[e.series]?.[e.index];if(!n)return null;const t=[{seriesIndex:e.series,name:F[e.series],color:n.color??I[e.series],value:n.to-n.from,formatted:`${i(n.from,P.unit,C)} – ${i(n.to,P.unit,C)}`}];return{heading:n.span.label??F[e.series],items:t}},[A,F,I,P.unit,C]);return e(o,{...z,series:T,categories:F,size:g,density:v,locale:C,horizontal:!0,scale:P,xAxis:j,yAxis:{tickFormat:(e,n)=>B[n]??"",...$},legend:!1,bandRatio:r[v],marks:R,markTooltip:S,table:n=>e(b,{id:n,names:F,series:s,spans:A,unit:P.unit,label:z.label,corner:j?.label,locale:C}),children:n=>e(M,{context:n,spans:A,colors:I,rounded:k})})}function p(e){const n=e.data.map(e=>{const n=h(e.start),t=h(e.end);return null===n||null===t?null:{from:Math.min(n,t),to:Math.max(n,t),lane:0,color:e.color?m(e.color):void 0,span:e}}),t=[];return n.map((e,n)=>({one:e,index:n})).filter(e=>Boolean(e.one)).sort((e,n)=>e.one.from-n.one.from).forEach(({one:e})=>{const n=t.findIndex(n=>n<=e.from),o=-1===n?t.length:n;t[o]=e.to,e.lane=o}),{spans:n,lanes:Math.max(1,t.length)}}function M({context:n,spans:t,colors:o,rounded:r}){const{marks:a,activeMark:l,plot:i}=n,c=r?s:0;return e("g",{children:a.map(n=>{const r=t[n.series]?.[n.index];if(!r)return null;const a=l?.series===n.series&&l?.index===n.index,s=n.rx??n.r,m=2*(n.ry??n.r),d=Math.max(i.left,n.x-s),u=Math.min(i.left+i.width,n.x+s);if(u<i.left||d>i.left+i.width)return null;const h=Math.max(1,u-d);return e("rect",{x:d,y:n.y-m/2,width:h,height:m,rx:Math.min(c,h/2,m/2),fill:r.color??o[n.series],opacity:a?1:.92},`${n.series}-${n.index}`)})})}function b({id:t,names:o,series:r,spans:a,unit:s,label:l,corner:c,locale:m}){const d=r.some(e=>e.data.some(e=>void 0!==e.label));return n("table",{id:t,className:f,children:[l?e("caption",{children:l}):null,e("thead",{children:n("tr",{children:[e("th",{scope:"col",children:c??""}),d?e("th",{scope:"col",children:"label"}):null,e("th",{scope:"col",children:"start"}),e("th",{scope:"col",children:"end"})]})}),e("tbody",{children:a.flatMap((t,a)=>t.map((t,l)=>n("tr",{children:[e("th",{scope:"row",children:o[a]}),d?e("td",{children:r[a].data[l]?.label??""}):null,e("td",{children:t?i(t.from,s,m):""}),e("td",{children:t?i(t.to,s,m):""})]},`${a}-${l}`)))})]})}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { NebaAlign, NebaColor, NebaStyleProps, NebaVariant } from '../../types.js';
|
|
2
|
+
import type { NebaAlign, NebaColor, NebaSlots, NebaStyleProps, NebaVariant } from '../../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Where the stack sits.
|
|
5
5
|
*
|
|
@@ -50,6 +50,16 @@ export interface ToastOptions extends ToastData {
|
|
|
50
50
|
/** Called once it has finished animating out and left the DOM. */
|
|
51
51
|
onRemove?: () => void;
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* The parts the toast stack draws.
|
|
55
|
+
*
|
|
56
|
+
* There is no `className` on the provider and there is deliberately no `root`
|
|
57
|
+
* slot: a ToastProvider renders no element of its own — it wraps the app and
|
|
58
|
+
* puts a portalled stack on the page — so there is nothing for a root class
|
|
59
|
+
* name to land on. `viewport` is the strip the toasts are stacked in and
|
|
60
|
+
* `toast` is one of them.
|
|
61
|
+
*/
|
|
62
|
+
export type ToastSlot = 'viewport' | 'toast' | 'title' | 'description' | 'action' | 'close';
|
|
53
63
|
export interface ToastProviderProps extends Pick<NebaStyleProps, 'variant' | 'size' | 'density'> {
|
|
54
64
|
/** The default colour family. A single toast overrides it in `add`. */
|
|
55
65
|
color?: NebaColor;
|
|
@@ -79,6 +89,11 @@ export interface ToastProviderProps extends Pick<NebaStyleProps, 'variant' | 'si
|
|
|
79
89
|
locale?: string;
|
|
80
90
|
/** Accessible name of every toast's × button. Defaults to the `locale`'s word. */
|
|
81
91
|
closeLabel?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Class names for the parts of the stack. There is no `className` here — a
|
|
94
|
+
* provider renders no element of its own to put one on.
|
|
95
|
+
*/
|
|
96
|
+
classNames?: NebaSlots<ToastSlot>;
|
|
82
97
|
children?: React.ReactNode;
|
|
83
98
|
}
|
|
84
99
|
/**
|
|
@@ -121,4 +136,4 @@ export declare function useToast(): {
|
|
|
121
136
|
* limit, the swipe, the F6 focus hotkey, and the live region that makes a
|
|
122
137
|
* message that appeared out of nowhere reach a screen reader at all.
|
|
123
138
|
*/
|
|
124
|
-
export declare function ToastProvider(
|
|
139
|
+
export declare function ToastProvider(rawProps: ToastProviderProps): React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as o from"react";import{Toast as
|
|
1
|
+
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as o from"react";import{Toast as s}from"@base-ui/react/toast";import{boxPaddingClasses as i}from"../box/Box.js";import{actionMessages as a,useMessages as n}from"../../internal/i18n.js";import{CloseIcon as r,severityIcon as l}from"../../internal/icons.js";import{controlSlots as c,cx as d,focusRingClasses as m,hasContent as p,iconClasses as u,metaTextClasses as f,radiusClasses as b,sheetBodyClasses as v,sheetHeaderGapClasses as x,sheetSectionGapClasses as h,sheetTitleClasses as y,surfaceClasses as g}from"../../internal/styles.js";import{useStyleDefaults as w}from"../../internal/defaults.js";const N={"top-start":"top-0 items-start","top-center":"top-0 items-center","top-end":"top-0 items-end","bottom-start":"bottom-0 items-start flex-col-reverse","bottom-center":"bottom-0 items-center flex-col-reverse","bottom-end":"bottom-0 items-end flex-col-reverse"},j={solid:[g,"text-(--n-on-solid) bg-(--n-fill)","[box-shadow:var(--neba-shadow-3),var(--neba-plate-solid)]"].join(" "),outline:[g,"border text-(--neba-fg) bg-(--n-panel-press)","[border-color:var(--n-line)]","[box-shadow:var(--neba-shadow-3),var(--neba-plate-glass)]"].join(" "),text:[g,"text-(--neba-fg) bg-(--n-panel-press)","[box-shadow:var(--neba-shadow-3),var(--neba-plate-glass)]"].join(" ")},_={solid:"",outline:"text-(--n-accent)",text:"text-(--n-accent)"};function z(e){const{color:t,variant:o,icon:s,actionLabel:i,onAction:a,...n}=e;return{...n,data:{color:t,variant:o,icon:s},actionProps:void 0===i?void 0:{children:i,onClick:a}}}export function useToast(){const e=s.useToastManager();return o.useMemo(()=>({add:t=>e.add(z(t)),close:t=>e.close(t),update:(t,o)=>e.update(t,z(o)),promise:(t,o)=>e.promise(t,{loading:z(o.loading),success:e=>z("function"==typeof o.success?o.success(e):o.success),error:e=>z("function"==typeof o.error?o.error(e):o.error)}),toasts:e.toasts}),[e])}function T({toast:o,variant:a,color:n,size:g,density:w,closeLabel:N,swipeDirection:z,classNames:T}){const k=o.data?.variant??a??"outline",D=o.data?.color??n,L=void 0===o.data?.icon?l(D):o.data.icon,M=_[k],P=p(o.title);return t(s.Root,{toast:o,swipeDirection:z,className:d("pointer-events-auto flex w-full items-start",i[w??"default"][g],b[g],h[g],v[g],j[k],u,"[transition:opacity_var(--neba-duration)_var(--neba-ease)]","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0","data-[limited]:hidden",m,"[outline:none]",T?.toast),style:c(D,3,k),children:[p(L)?e("span",{className:`flex h-[1lh] shrink-0 items-center ${M}`,children:L}):null,t("div",{className:`flex min-w-0 flex-1 flex-col ${x[g]}`,children:[e(s.Title,{className:d("neba-title font-semibold",y[g],M,T?.title)}),e(s.Description,{className:d(P&&"solid"!==k?"text-(--neba-muted-fg)":"",T?.description)})]}),e(s.Action,{className:d("flex h-[1lh] shrink-0 cursor-pointer items-center rounded-full px-2","font-medium underline-offset-2",M||"text-(--n-on-solid)","hover:underline","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2",f[g],T?.action)}),e("span",{className:"flex h-[1lh] shrink-0 items-center",children:e(s.Close,{"aria-label":N,className:d("inline-flex size-[1.15em] cursor-pointer items-center justify-center rounded-full","opacity-70 [transition:opacity_var(--neba-duration)_var(--neba-ease)]","hover:opacity-100 focus-visible:opacity-100","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2",T?.close),children:e(r,{})})})]})}function k(t){const{toasts:i}=s.useToastManager(),{position:a,width:n,classNames:r,...l}=t,c=o.useMemo(()=>[a.startsWith("top")?"up":"down","left","right"],[a]);return e(s.Portal,{children:e(s.Viewport,{className:d("neba-portal pointer-events-none fixed inset-x-0 z-50 flex flex-col gap-2 p-4",N[a],r?.viewport),children:i.map(t=>e("div",{className:"w-full",style:{maxWidth:"number"==typeof n?`${n}px`:n},children:e(T,{toast:t,swipeDirection:c,classNames:r,...l})},t.id))})})}export function ToastProvider(o){const{variant:i="outline",size:r="md",color:l="primary",density:c="default",position:d="bottom-end",timeout:m=5e3,limit:p=3,width:u=380,locale:f,closeLabel:b,classNames:v,children:x}=w(o,["size","density","variant","locale"]),h=n(a,f);return t(s.Provider,{timeout:m,limit:p,children:[x,e(k,{position:d,variant:i,size:r,color:l,density:c,width:u,closeLabel:b??h.close,classNames:v})]})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsxs as e}from"react/jsx-runtime";import*as
|
|
1
|
+
"use client";import{jsxs as e}from"react/jsx-runtime";import*as t from"react";import{Toggle as n}from"@base-ui/react/toggle";import{ButtonGroupContext as o}from"../../internal/button-group.js";import{controlHeightClasses as r,controlSlots as s,controlSquareClasses as a,controlTextClasses as l,cx as i,disabledClasses as d,focusRingClasses as v,gapClasses as g,iconClasses as b,paddingXClasses as p,pressTransitionClasses as x,radiusClasses as f,surfaceClasses as m,transitionClasses as c}from"../../internal/styles.js";import{useStyleDefaults as h}from"../../internal/defaults.js";const u={xs:`${r.xs} ${g.xs} ${f.xs} ${l.xs}`,sm:`${r.sm} ${g.sm} ${f.sm} ${l.sm}`,md:`${r.md} ${g.md} ${f.md} ${l.md}`,lg:`${r.lg} ${g.lg} ${f.lg} ${l.lg}`,xl:`${r.xl} ${g.xl} ${f.xl} ${l.xl}`},$={xs:`${a.xs} px-0`,sm:`${a.sm} px-0`,md:`${a.md} px-0`,lg:`${a.lg} px-0`,xl:`${a.xl} px-0`},j=["relative inline-flex shrink-0 cursor-pointer select-none items-center justify-center","whitespace-nowrap align-middle font-medium leading-none","[-webkit-tap-highlight-color:transparent] [touch-action:manipulation]",c,x,v,b].join(" "),y={solid:[m,"text-(--neba-muted-fg) bg-(--n-panel-hover)","[box-shadow:var(--n-elev),var(--neba-plate-solid)]","hover:bg-(--n-panel-press) hover:text-(--neba-fg)","active:bg-(--n-panel-press)"].join(" "),outline:[m,"border text-(--neba-muted-fg) bg-(--n-panel)","[border-color:var(--n-line)]","[box-shadow:var(--n-elev),var(--neba-plate-glass)]","hover:bg-(--n-panel-hover) hover:text-(--neba-fg) hover:[border-color:var(--n-line-hover)]","active:bg-(--n-panel-press)"].join(" "),text:["text-(--neba-muted-fg) bg-transparent","hover:bg-(--n-soft) hover:text-(--neba-fg)","active:bg-(--n-soft-hover)"].join(" ")},w={solid:[m,"text-(--n-on-solid) bg-(--n-fill)","[box-shadow:var(--n-elev),var(--neba-plate-solid)]","hover:bg-(--n-fill-hover)","active:bg-(--n-fill-active)"].join(" "),outline:[m,"border text-(--n-accent) bg-(--n-soft)","[border-color:var(--n-line-hover)]","[box-shadow:var(--n-elev),var(--neba-plate-glass)]","hover:bg-(--n-soft-hover)","active:bg-(--n-soft-press)"].join(" "),text:["text-(--n-accent) bg-(--n-soft)","hover:bg-(--n-soft-hover)","active:bg-(--n-soft-press)"].join(" ")};export const Toggle=/*@__PURE__*/t.forwardRef(function(r,a){const{variant:l,size:v,color:g,density:b,elevation:x,pressed:f,defaultPressed:m,onPressedChange:c,value:P,startIcon:z,endIcon:C,fullWidth:T=!1,disabled:k,className:E,style:I,children:M,onPointerMove:N,...R}=h(r,["size","density","variant"]),W=t.useContext(o),X=l??W?.variant??"outline",Y=v??W?.size??"md",q=g??W?.color??"primary",A=b??W?.density??"default",B=x??W?.elevation??0,D=k??W?.disabled??!1,F=null==M||!1===M;return e(n,{ref:a,value:P,pressed:f,defaultPressed:m,onPressedChange:e=>c?.(e),disabled:D,className:e=>i(j,u[Y],F?$[Y]:p[A][Y],D?d[X]:e.pressed?w[X]:y[X],D?"":"neba-glow",T?"w-full":"",E??""),style:{...s(q,B,X),...I},onPointerMove:e=>{if(!D){const t=e.currentTarget;t.style.setProperty("--n-mx",`${e.nativeEvent.offsetX}px`),t.style.setProperty("--n-my",`${e.nativeEvent.offsetY}px`)}N?.(e)},...R,children:[z,M,C]})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e}from"react/jsx-runtime";import*as o from"react";import{ToggleGroup as l}from"@base-ui/react/toggle-group";import{ButtonGroupContext as i}from"../../internal/button-group.js";import{cx as t}from"../../internal/styles.js";const
|
|
1
|
+
"use client";import{jsx as e}from"react/jsx-runtime";import*as o from"react";import{ToggleGroup as l}from"@base-ui/react/toggle-group";import{ButtonGroupContext as i}from"../../internal/button-group.js";import{cx as t}from"../../internal/styles.js";import{useStyleDefaults as n}from"../../internal/defaults.js";const r={horizontal:"[&>*:not(:first-child)]:rounded-s-none [&>*:not(:last-child)]:rounded-e-none",vertical:"[&>*:not(:first-child)]:rounded-t-none [&>*:not(:last-child)]:rounded-b-none"},a={horizontal:"[&>*:not(:first-child)]:-ms-px",vertical:"[&>*:not(:first-child)]:-mt-px"},s=["inline-flex align-middle","[&>*]:relative [&>*:hover]:z-10 [&>*:focus-visible]:z-10","[&>*]:shrink-0"].join(" ");export const ToggleGroup=/*@__PURE__*/o.forwardRef(function(d,u){const{variant:c,size:f,color:m,density:h,elevation:p,value:v,defaultValue:g,onValueChange:x,multiple:z=!1,orientation:b="horizontal",disabled:j,loopFocus:y=!0,fullWidth:V=!1,className:w,children:C,...F}=n(d,["size","density","variant"]),G=o.useMemo(()=>({variant:c,size:f,color:m,density:h,elevation:p,disabled:j}),[c,f,m,h,p,j]);return e(i.Provider,{value:G,children:e(l,{ref:u,value:v,defaultValue:g,onValueChange:e=>x?.(e),multiple:z,orientation:b,disabled:j,loopFocus:y,className:t(s,"vertical"===b?"flex-col":"flex-row",r[b],"outline"===(c??"outline")?a[b]:"",V?"flex w-full [&>*]:flex-1":"",w??""),...F,children:C})})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,Fragment as t,jsxs as r}from"react/jsx-runtime";import*as o from"react";import{useRender as n}from"@base-ui/react/use-render";import{boxPaddingXClasses as i,boxPaddingYClasses as s}from"../box/Box.js";import{cx as a,hasContent as l,radiusClasses as
|
|
1
|
+
"use client";import{jsx as e,Fragment as t,jsxs as r}from"react/jsx-runtime";import*as o from"react";import{useRender as n}from"@base-ui/react/use-render";import{boxPaddingXClasses as i,boxPaddingYClasses as s}from"../box/Box.js";import{cx as a,hasContent as l,radiusClasses as d,sheetSectionGapClasses as m,surfaceClasses as c,surfaceSlots as b,transitionClasses as p}from"../../internal/styles.js";import{useStyleDefaults as f}from"../../internal/defaults.js";const x={solid:[c,"text-(--neba-fg) bg-(--n-panel-hover)","[box-shadow:var(--n-elev),var(--neba-plate-solid)]"].join(" "),outline:[c,"border text-(--neba-fg) bg-(--n-panel)","[border-color:var(--n-line)]","[box-shadow:var(--n-elev),var(--neba-plate-glass)]"].join(" "),text:"text-(--neba-fg) bg-transparent"},v={static:{top:"",bottom:""},sticky:{top:"sticky top-0 z-20",bottom:"sticky bottom-0 z-20"},fixed:{top:"fixed inset-x-0 top-0 z-30",bottom:"fixed inset-x-0 bottom-0 z-30"}},u={top:"border-b [border-color:var(--n-line)]",bottom:"border-t [border-color:var(--n-line)]"};export const Toolbar=/*@__PURE__*/o.forwardRef(function(o,c){const{variant:g="outline",size:h="md",color:y="primary",density:j="default",elevation:w=0,position:z="static",side:k="top",divider:N=!1,start:B,end:F,render:R,className:T,style:q,children:A,...C}=f(o,["size","density","variant"]),D=a("flex w-full min-w-0 items-center",i[j][h],s[j][h],m[h],"static"===z?d[h]:"",x[g],N?u[k]:"",v[z][k],p,T??"");return n({render:R,ref:c,props:{className:D,style:{...b(y,w),...q},children:r(t,{children:[l(B)?e("div",{className:"flex min-w-0 shrink-0 items-center gap-2",children:B}):null,e("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:A}),l(F)?e("div",{className:"flex min-w-0 shrink-0 items-center gap-2",children:F}):null]}),...C}})});
|
|
@@ -76,4 +76,4 @@ export type TooltipProviderProps = React.ComponentProps<typeof BaseUITooltip.Pro
|
|
|
76
76
|
* this component wires both, and drops the reference while it is closed rather
|
|
77
77
|
* than pointing at an element that is not in the document.
|
|
78
78
|
*/
|
|
79
|
-
export declare function Tooltip(
|
|
79
|
+
export declare function Tooltip(rawProps: TooltipProps): React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as a from"react";import{Tooltip as o}from"@base-ui/react/tooltip";import{controlSlots as i,cx as s,metaTextClasses as n,paddingXClasses as
|
|
1
|
+
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as a from"react";import{Tooltip as o}from"@base-ui/react/tooltip";import{controlSlots as i,cx as s,metaTextClasses as n,paddingXClasses as r,radiusClasses as l,surfaceClasses as d}from"../../internal/styles.js";import{useStyleDefaults as p}from"../../internal/defaults.js";export const TooltipProvider=o.Provider;const c=[d,"max-w-64 text-(--n-on-solid) bg-(--n-fill)","[box-shadow:var(--neba-shadow-3),var(--neba-plate-solid)]","[outline:none]","[transition:opacity_var(--neba-duration)_var(--neba-ease)]","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0","data-[instant]:[transition-duration:0ms]"].join(" "),m={xs:"py-0.5",sm:"py-0.5",md:"py-1",lg:"py-1.5",xl:"py-2"},y={xs:6,sm:7,md:8,lg:9,xl:10};export function Tooltip(d){const{content:f,children:h,size:u="sm",color:x="secondary",density:b="default",side:g="top",align:v="center",sideOffset:j=6,delay:w,closeDelay:O,arrow:N=!0,open:P,defaultOpen:z,onOpenChange:T,disabled:C=!1,className:D,style:_,...k}=p(d,["size","density"]),A=y[u],B=a.useId(),[I,L]=a.useState(z??!1),M=P??I;return t(o.Root,{open:P,defaultOpen:z,onOpenChange:e=>{void 0===P&&L(e),T?.(e)},children:[e(o.Trigger,{render:h,delay:w,closeDelay:O,disabled:C,"aria-describedby":M?B:void 0}),e(o.Portal,{children:e(o.Positioner,{className:"neba-portal z-50 [outline:none]",side:g,align:v,sideOffset:j,children:t(o.Popup,{id:B,role:"tooltip",className:s(c,l[u],r[b][u],m[u],n[u],D??""),style:{...i(x,3,"solid"),..._},...k,children:[N?e(o.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:e("svg",{width:A,height:A/2,viewBox:"0 0 10 5","aria-hidden":"true",className:"block",children:e("path",{d:"M0 0h10L5 5z",fill:"var(--n-fill)"})})}):null,f]})})})]})}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { NebaAlign, NebaSide, NebaStyleProps } from '../../types.js';
|
|
2
|
+
import type { NebaAlign, NebaSide, NebaSlots, NebaStyleProps } from '../../types.js';
|
|
3
3
|
/** One stop on the tour. */
|
|
4
4
|
export interface TourStep {
|
|
5
5
|
/**
|
|
@@ -23,6 +23,14 @@ export interface TourStep {
|
|
|
23
23
|
*/
|
|
24
24
|
padding?: number;
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* The parts a Tour draws around its card.
|
|
28
|
+
*
|
|
29
|
+
* `className` is the card — the popup the steps are written on — and `mask` is
|
|
30
|
+
* the dimming behind it, which is a sibling of the popup rather than a
|
|
31
|
+
* descendant and so has no other way in.
|
|
32
|
+
*/
|
|
33
|
+
export type TourSlot = 'mask' | 'title' | 'description' | 'close' | 'footer';
|
|
26
34
|
export interface TourProps extends Pick<NebaStyleProps, 'size' | 'color' | 'density'> {
|
|
27
35
|
/** The stops, in order. */
|
|
28
36
|
steps: readonly TourStep[];
|
|
@@ -63,6 +71,13 @@ export interface TourProps extends Pick<NebaStyleProps, 'size' | 'color' | 'dens
|
|
|
63
71
|
doneLabel?: React.ReactNode;
|
|
64
72
|
/** The Skip button. */
|
|
65
73
|
skipLabel?: React.ReactNode;
|
|
74
|
+
/** Class names for the card. */
|
|
75
|
+
className?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Class names for the parts around it. `className` is the card, so the
|
|
78
|
+
* dimming behind it is `classNames.mask`.
|
|
79
|
+
*/
|
|
80
|
+
classNames?: NebaSlots<TourSlot>;
|
|
66
81
|
}
|
|
67
82
|
/**
|
|
68
83
|
* A guided walk over a page that already exists — the three things a new reader
|
|
@@ -79,4 +94,4 @@ export interface TourProps extends Pick<NebaStyleProps, 'size' | 'color' | 'dens
|
|
|
79
94
|
* pointed at while the card is up, which is the difference between a tour and a
|
|
80
95
|
* sequence of dialogs.
|
|
81
96
|
*/
|
|
82
|
-
export declare function Tour(
|
|
97
|
+
export declare function Tour(rawProps: TourProps): React.JSX.Element | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{Popover as
|
|
1
|
+
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{Popover as s}from"@base-ui/react/popover";import{Button as i}from"../button/Button.js";import{boxPaddingXClasses as o,boxPaddingYClasses as a}from"../box/Box.js";import{actionMessages as r,fill as l,stepsMessages as c,useMessages as d}from"../../internal/i18n.js";import{CloseIcon as m}from"../../internal/icons.js";import{observeResize as u}from"../../internal/observe.js";import{cx as p,hasContent as f,metaTextClasses as h,radiusClasses as g,sheetBodyClasses as b,sheetHeaderGapClasses as v,sheetSectionGapClasses as x,sheetTitleClasses as w,surfaceClasses as y,surfaceSlots as N}from"../../internal/styles.js";import{useStyleDefaults as k}from"../../internal/defaults.js";const _=[y,"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(" "),j={xs:"max-w-56",sm:"max-w-64",md:"max-w-80",lg:"max-w-96",xl:"max-w-lg"},z={xs:"xs",sm:"xs",md:"sm",lg:"sm",xl:"md"};function L({spot:t,radius:n,className:s}){return e("div",null===t?{"aria-hidden":"true",className:p("pointer-events-none fixed inset-0 z-40 bg-(--neba-scrim)",s)}:{"aria-hidden":"true",className:p("pointer-events-none fixed z-40 [box-shadow:0_0_0_9999px_var(--neba-scrim)]",s),style:{top:t.top,left:t.left,width:t.width,height:t.height,borderRadius:n}})}export function Tour(y){const{steps:S,open:C,defaultOpen:E=!1,onOpenChange:P,step:O,defaultStep:q=0,onStepChange:B,onFinish:F,mask:M=!0,skippable:R=!0,dismissible:T=!0,scrollIntoView:A=!0,locale:I,previousLabel:V,nextLabel:$,doneLabel:D,skipLabel:H,size:G="md",color:J="primary",density:K="default",className:Q,classNames:U}=k(y,["size","density","locale"]),W=d(c,I),X=d(r,I),[Y,Z]=n.useState(E),[ee,te]=n.useState(q),ne=C??Y,se=Math.min(O??ee,Math.max(0,S.length-1)),ie=S[se],[oe,ae]=n.useState(null),re=e=>{void 0===C&&Z(e),P?.(e)},le=e=>{void 0===O&&te(e),B?.(e)};if(n.useEffect(()=>{const e=ie?.target;if(!ne||!e)return;const t=document.querySelector(e);if(!(t instanceof HTMLElement))return;A&&t.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"});const n=ie?.padding??6;let s=0;const i=()=>{s=0;const i=t.getBoundingClientRect();ae({selector:e,spot:{top:i.top-n,left:i.left-n,width:i.width+2*n,height:i.height+2*n}})},o=()=>{0===s&&(s=requestAnimationFrame(i))};i();const a=u(t,o);return window.addEventListener("scroll",o,{passive:!0,capture:!0}),window.addEventListener("resize",o,{passive:!0}),()=>{0!==s&&cancelAnimationFrame(s),a(),window.removeEventListener("scroll",o,!0),window.removeEventListener("resize",o)}},[ne,ie?.target,ie?.padding,A]),0===S.length)return null;const ce=ne&&ie?.target&&oe?.selector===ie.target?oe.spot:null,de=0===se,me=se===S.length-1,ue=o[K][G],pe=a[K][G],fe=z[G],he=f(ie?.title)||f(ie?.content);return t(s.Root,{open:ne,onOpenChange:(e,t)=>{(e||T||"escape-key"!==t.reason)&&(e||"outside-press"!==t.reason&&"focus-out"!==t.reason)?re(e):t.cancel()},children:[ne&&M?e(L,{spot:ce,radius:ce?8:0,className:U?.mask}):null,e(s.Portal,{children:e(s.Positioner,{className:"neba-portal z-50 [outline:none]",side:ie?.side??"bottom",align:ie?.align??"center",sideOffset:10,collisionPadding:12,anchor:()=>{if(!ie?.target)return null;const e=document.querySelector(ie.target);return e instanceof Element?e:null},children:t(s.Popup,{className:p(_,g[G],b[G],x[G],j[G],ue,pe,Q),style:N(J,3),children:[he?t("div",{className:"flex items-start gap-3",children:[t("div",{className:`flex min-w-0 flex-1 flex-col ${v[G]}`,children:[f(ie?.title)?e(s.Title,{className:p("m-0 font-semibold",w[G],U?.title),children:ie?.title}):null,f(ie?.content)?e(s.Description,{className:p("m-0 min-w-0",U?.description),children:ie?.content}):null]}),T?e("button",{type:"button","aria-label":X.close,onClick:()=>re(!1),className:p("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",U?.close),children:e(m,{})}):null]}):null,t("div",{className:p("flex items-center gap-2",U?.footer),children:[e("span",{className:`shrink-0 tabular-nums text-(--neba-muted-fg) ${h[G]}`,children:l(W.position,{index:String(se+1),total:String(S.length)})}),t("div",{className:"ms-auto flex items-center gap-2",children:[R&&!me?e(i,{size:fe,variant:"text",color:"secondary",onClick:()=>re(!1),children:H??W.skip}):null,de?null:e(i,{size:fe,variant:"outline",color:J,onClick:()=>le(se-1),children:V??W.previous}),e(i,{size:fe,color:J,onClick:()=>me?(F?.(),void re(!1)):le(se+1),children:me?D??W.done:$??W.next})]})]})]})})})]})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as a from"react";import{Checkbox as t}from"../checkbox/Checkbox.js";import{IconButton as s}from"../icon-button/IconButton.js";import{ScrollArea as r}from"../scroll-area/ScrollArea.js";import{TextField as i}from"../text-field/TextField.js";import{transferMessages as n,useMessages as o}from"../../internal/i18n.js";import{ArrowRightIcon as c}from"../../internal/icons.js";import{searchText as d}from"../../internal/search.js";import{cx as
|
|
1
|
+
"use client";import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as a from"react";import{Checkbox as t}from"../checkbox/Checkbox.js";import{IconButton as s}from"../icon-button/IconButton.js";import{ScrollArea as r}from"../scroll-area/ScrollArea.js";import{TextField as i}from"../text-field/TextField.js";import{transferMessages as n,useMessages as o}from"../../internal/i18n.js";import{ArrowRightIcon as c}from"../../internal/icons.js";import{searchText as d}from"../../internal/search.js";import{cx as m,fieldRestClasses as h,hasContent as u,metaTextClasses as f,paddingXClasses as b,radiusClasses as p,surfaceSlots as g,toLength as v}from"../../internal/styles.js";import{useStyleDefaults as x}from"../../internal/defaults.js";const y={xs:"py-1",sm:"py-1.5",md:"py-2",lg:"py-2.5",xl:"py-3"},k={xs:"py-0.5",sm:"py-1",md:"py-1",lg:"py-1.5",xl:"py-2"};function S({title:a,rows:s,ticked:n,onTick:o,onTickAll:c,search:d,onSearch:m,searchable:u,disabled:v,height:x,emptyMessage:S,searchLabel:w,selectAllLabel:j,style:N}){const{size:z,variant:$="outline",color:A="primary",density:C="default"}=N,T=s.filter(e=>!e.disabled),L=T.filter(e=>n.has(e.value)),M=T.length>0&&L.length===T.length,V=L.length>0&&!M,_=b[C][z];return l("div",{className:["flex min-w-0 flex-col overflow-hidden",h[$],p[z]].join(" "),style:g(A,0),children:[l("div",{className:`flex items-center gap-2 border-b [border-color:var(--neba-border)] ${_} ${y[z]}`,children:[e(t,{size:z,color:A,checked:M,indeterminate:V,disabled:v||0===T.length,"aria-label":j,onCheckedChange:e=>c(!0===e)}),e("span",{className:`min-w-0 flex-1 truncate font-medium ${f[z]}`,children:a}),l("span",{className:`shrink-0 tabular-nums text-(--neba-muted-fg) ${f[z]}`,children:[L.length,"/",s.length]})]}),u?e("div",{className:`${_} ${y[z]}`,children:e(i,{size:z,color:A,density:C,fullWidth:!0,variant:"text",disabled:v,placeholder:w,"aria-label":w,value:d,onChange:e=>m(e.target.value)})}):null,e(r,{size:z,color:A,height:x,fade:!0,children:e("div",{className:`flex flex-col ${_} ${y[z]}`,children:0===s.length?e("span",{className:`text-(--neba-muted-fg) ${f[z]} ${k[z]}`,children:S}):s.map(l=>e(t,{size:z,color:A,className:k[z],label:l.label,checked:n.has(l.value),disabled:v||l.disabled,onCheckedChange:e=>o(l.value,!0===e)},l.value))})})]})}function w(e,l){const a=d(l);return""===a?e:e.filter(e=>"string"!=typeof e.label||d(e.label).includes(a))}export const Transfer=/*@__PURE__*/a.forwardRef(function(t,r){const{items:i,value:d,defaultValue:h,onValueChange:f,sourceLabel:b,targetLabel:p,searchable:g=!1,height:y=220,disabled:k=!1,locale:j,variant:N="outline",size:z="md",color:$="primary",density:A="default",className:C,...T}=x(t,["size","density","variant","locale"]),L=o(n,j),[M,V]=a.useState(h??[]),_=d??M,[B,F]=a.useState(()=>new Set),[I,R]=a.useState(""),[W,q]=a.useState(""),D=a.useMemo(()=>new Set(_),[_]),E=a.useMemo(()=>i.filter(e=>!D.has(e.value)),[i,D]),G=a.useMemo(()=>i.filter(e=>D.has(e.value)),[i,D]),H=(e,l)=>{F(a=>{const t=new Set(a);return l?t.add(e):t.delete(e),t})},J=(e,l)=>{F(a=>{const t=new Set(a);for(const a of e)a.disabled||(l?t.add(a.value):t.delete(a.value));return t})},K=(e,l)=>{const a=e.filter(e=>!e.disabled&&B.has(e.value));if(0===a.length)return;const t=new Set(a.map(e=>e.value)),s=l?i.filter(e=>D.has(e.value)||t.has(e.value)).map(e=>e.value):_.filter(e=>!t.has(e));F(e=>new Set([...e].filter(e=>!t.has(e)))),(e=>{void 0===d&&V(e),f?.(e)})(s)},O=w(E,I),P=w(G,W),Q=O.some(e=>!e.disabled&&B.has(e.value)),U=P.some(e=>!e.disabled&&B.has(e.value)),X=v(y),Y={variant:N,size:z,color:$,density:A};return l("div",{ref:r,className:m("grid w-full items-center gap-3","[grid-template-columns:minmax(0,1fr)_auto_minmax(0,1fr)]",C??""),...T,children:[e(S,{title:u(b)?b:L.source,rows:O,ticked:B,onTick:H,onTickAll:e=>J(O,e),search:I,onSearch:R,searchable:g,disabled:k,height:X,emptyMessage:L.empty,searchLabel:L.search,selectAllLabel:L.selectAll,style:Y}),l("div",{className:"flex flex-col gap-2",children:[e(s,{size:z,color:$,variant:"text"===N?"text":"outline",label:L.toTarget,disabled:k||!Q,onClick:()=>K(O,!0),icon:e(c,{})}),e(s,{size:z,color:$,variant:"text"===N?"text":"outline",label:L.toSource,disabled:k||!U,onClick:()=>K(P,!1),icon:e("span",{className:"flex rotate-180",children:e(c,{})})})]}),e(S,{title:u(p)?p:L.target,rows:P,ticked:B,onTick:H,onTickAll:e=>J(P,e),search:W,onSearch:q,searchable:g,disabled:k,height:X,emptyMessage:L.empty,searchLabel:L.search,selectAllLabel:L.selectAll,style:Y})]})});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type TreeViewValue } from '../tree-view/TreeView.js';
|
|
3
|
+
import { type PickerShellProps } from '../../internal/picker.js';
|
|
4
|
+
import type { NebaSlots } from '../../types.js';
|
|
5
|
+
/** One node of the tree the reader is choosing from. */
|
|
6
|
+
export interface TreeSelectItem {
|
|
7
|
+
/** What is stored when this node is chosen. Unique across the whole tree. */
|
|
8
|
+
value: TreeViewValue;
|
|
9
|
+
label: React.ReactNode;
|
|
10
|
+
/** What a search matches against. Falls back to `label` when it is a string. */
|
|
11
|
+
searchLabel?: string;
|
|
12
|
+
startIcon?: React.ReactNode;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether this node may itself be chosen.
|
|
16
|
+
*
|
|
17
|
+
* `false` makes it a heading with children under it — a "Europe" that groups
|
|
18
|
+
* countries without being one. Defaults to `true` for a leaf and follows
|
|
19
|
+
* `selectableBranches` for a node that has children.
|
|
20
|
+
*/
|
|
21
|
+
selectable?: boolean;
|
|
22
|
+
children?: TreeSelectItem[];
|
|
23
|
+
}
|
|
24
|
+
/** The parts a TreeSelect draws behind its root. */
|
|
25
|
+
export type TreeSelectSlot = 'popup' | 'tree' | 'item' | 'empty';
|
|
26
|
+
export interface TreeSelectProps extends PickerShellProps {
|
|
27
|
+
/** The tree, as nested items. */
|
|
28
|
+
items?: TreeSelectItem[];
|
|
29
|
+
/** The chosen value, or values when `multiple`. */
|
|
30
|
+
value?: TreeViewValue | TreeViewValue[] | null;
|
|
31
|
+
defaultValue?: TreeViewValue | TreeViewValue[] | null;
|
|
32
|
+
onValueChange?: (value: TreeViewValue[]) => void;
|
|
33
|
+
/** Whether more than one node may be held. @default false */
|
|
34
|
+
multiple?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Whether a node that has children may itself be chosen.
|
|
37
|
+
*
|
|
38
|
+
* Off by default, which is the shape most trees actually have: the branches
|
|
39
|
+
* are the taxonomy and the leaves are the answers. An item's own
|
|
40
|
+
* `selectable` overrides it either way.
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
selectableBranches?: boolean;
|
|
44
|
+
/** Which branches start open. */
|
|
45
|
+
defaultExpanded?: TreeViewValue[];
|
|
46
|
+
expanded?: TreeViewValue[];
|
|
47
|
+
onExpandedChange?: (expanded: TreeViewValue[]) => void;
|
|
48
|
+
/** Whether the popup is open. Use with `onOpenChange` to control it. */
|
|
49
|
+
open?: boolean;
|
|
50
|
+
defaultOpen?: boolean;
|
|
51
|
+
onOpenChange?: (open: boolean) => void;
|
|
52
|
+
/** Shown in the trigger while nothing is chosen. */
|
|
53
|
+
placeholder?: React.ReactNode;
|
|
54
|
+
/** Offers the × that empties the control. @default false */
|
|
55
|
+
clearable?: boolean;
|
|
56
|
+
/** Closes the popup as soon as a node is chosen. @default !multiple */
|
|
57
|
+
closeOnSelect?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Offers a field above the tree that filters it.
|
|
60
|
+
*
|
|
61
|
+
* A match keeps its ancestors, because a node with its parents cut away is a
|
|
62
|
+
* node the reader cannot place — "Seoul" under nothing at all.
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
searchable?: boolean;
|
|
66
|
+
searchPlaceholder?: string;
|
|
67
|
+
/** BCP 47 tag deciding the strings this draws on its own behalf. */
|
|
68
|
+
locale?: string;
|
|
69
|
+
/** How the trigger writes what is held. Defaults to the labels, comma-joined. */
|
|
70
|
+
format?: (chosen: TreeSelectItem[]) => React.ReactNode;
|
|
71
|
+
/** Identifies the field when a form is submitted. One input per value. */
|
|
72
|
+
name?: string;
|
|
73
|
+
classNames?: NebaSlots<TreeSelectSlot>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* A value chosen from a tree rather than from a list.
|
|
77
|
+
*
|
|
78
|
+
* The gap between [Select](./select) and [TreeView](../display/tree-view): the
|
|
79
|
+
* first is a flat list behind a field, the second is a hierarchy that shows
|
|
80
|
+
* what it holds but has no field. A category, a folder, an org chart node and a
|
|
81
|
+
* region are all chosen from a shape a flat list flattens away.
|
|
82
|
+
*
|
|
83
|
+
* `selectableBranches` is off by default because that is the shape most of
|
|
84
|
+
* these trees have — the branches are the taxonomy and the leaves are the
|
|
85
|
+
* answers, and a "Europe" that can be chosen alongside "France" is usually a
|
|
86
|
+
* data model nobody meant. An item's own `selectable` overrides it either way.
|
|
87
|
+
*/
|
|
88
|
+
export declare const TreeSelect: React.ForwardRefExoticComponent<TreeSelectProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as a from"react";import{TreeItem as n,TreeView as r}from"../tree-view/TreeView.js";import{PickerShell as t}from"../../internal/picker.js";import{defaultPickerLabels as i}from"../../internal/calendar.js";import{searchHaystack as o,searchText as s}from"../../internal/search.js";import{commandMessages as c,comboboxMessages as d,useMessages as u}from"../../internal/i18n.js";import{useStyleDefaults as p}from"../../internal/defaults.js";function h(e,l=new Map){for(const a of e)l.set(a.value,a),a.children&&h(a.children,l);return l}function m(e){return o([e.searchLabel??("string"==typeof e.label?e.label:String(e.value))])}function f(e,l){if(""===l)return e;const a=[];for(const n of e){const e=n.children?f(n.children,l):void 0,r=m(n).includes(l);(r||e&&e.length>0)&&a.push({...n,children:r?n.children:e})}return a}function g(e,l=[]){for(const a of e)a.children&&a.children.length>0&&(l.push(a.value),g(a.children,l));return l}export const TreeSelect=/*@__PURE__*/a.forwardRef(function(o,m){const{items:v=[],value:b,defaultValue:x,onValueChange:y,multiple:j=!1,selectableBranches:C=!1,defaultExpanded:S,expanded:w,onExpandedChange:N,open:O,defaultOpen:z,onOpenChange:M,placeholder:V,clearable:E=!1,closeOnSelect:T,searchable:k=!1,searchPlaceholder:A,locale:I,format:R,name:B,size:L="md",color:P="primary",readOnly:$=!1,disabled:q=!1,classNames:D,...F}=p(o,["size","locale"]),G=u(d,I),H=u(c,I),J=e=>null==e?[]:Array.isArray(e)?e:[e],[K,Q]=a.useState(()=>J(x)),U=void 0!==b?J(b):K,[W,X]=a.useState(z??!1),Y=O??W,[Z,_]=a.useState(""),ee=a.useMemo(()=>h(v),[v]),le=s(Z),ae=a.useMemo(()=>f(v,le),[v,le]),ne=a.useMemo(()=>""===le?void 0:g(ae),[le,ae]),[re,te]=a.useState(()=>S??[]),ie=ne??w??re,oe=e=>{e&&($||q)||(void 0===O&&X(e),e||_(""),M?.(e))},se=e=>{void 0===b&&Q(e),y?.(e)},ce=e=>e.selectable??(!(e.children&&e.children.length>0)||C),de=U.map(e=>ee.get(e)).filter(e=>void 0!==e),ue=0===de.length?V??"":R?R(de):de.map(e=>e.label).reduce((e,l,a)=>0===a?[l]:[...e,", ",l],[]),pe=l=>l.map(l=>e(n,{value:l.value,label:l.label,startIcon:l.startIcon,disabled:l.disabled||!ce(l),className:D?.item,children:l.children?pe(l.children):null},l.value));return e(t,{...F,size:L,color:P,readOnly:$,disabled:q,triggerRef:m,display:ue,empty:0===de.length,clearable:E,onClear:()=>se([]),open:Y,onOpenChange:oe,labels:i,popupClassName:D?.popup,hiddenValues:B?U.map(e=>({name:B,value:String(e)})):void 0,children:l("div",{className:"flex max-h-80 w-64 flex-col gap-2 overflow-hidden",children:[k?e("input",{type:"text",value:Z,placeholder:A??H.search,"aria-label":A??H.search,onChange:e=>_(e.currentTarget.value),className:"w-full shrink-0 bg-transparent px-1 py-1 [font:inherit] text-(--neba-fg) [outline:none] placeholder:text-(--neba-muted-fg)"}):null,e("div",{className:"min-h-0 flex-1 overflow-auto",children:0===ae.length?e("p",{className:`px-1 py-2 text-(--neba-muted-fg) ${D?.empty??""}`,children:G.empty}):e(r,{size:L,color:P,multiple:j,selected:U,onSelectedChange:e=>{const l=e.filter(e=>{const l=ee.get(e);return void 0!==l&&ce(l)&&!l.disabled});se(j?l:l.slice(-1)),(T??!j)&&oe(!1)},expanded:ie,onExpandedChange:ne?()=>{}:e=>{void 0===w&&te(e),N?.(e)},className:D?.tree,children:pe(ae)})})]})})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{TreeSelect}from"./TreeSelect.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,Fragment as t,jsxs as r}from"react/jsx-runtime";import*as n from"react";import{ChevronIcon as a}from"../../internal/icons.js";import{controlTextClasses as l,cx as s,gapClasses as o,hasContent as i,iconClasses as c,radiusClasses as d,surfaceClasses as u,surfaceSlots as m,transitionClasses as f}from"../../internal/styles.js";const
|
|
1
|
+
"use client";import{jsx as e,Fragment as t,jsxs as r}from"react/jsx-runtime";import*as n from"react";import{ChevronIcon as a}from"../../internal/icons.js";import{controlTextClasses as l,cx as s,gapClasses as o,hasContent as i,iconClasses as c,radiusClasses as d,surfaceClasses as u,surfaceSlots as m,transitionClasses as f}from"../../internal/styles.js";import{useStyleDefaults as p}from"../../internal/defaults.js";const x=/*@__PURE__*/n.createContext({size:"md",density:"default",disabled:!1,expandedKeys:new Set,selectedKeys:new Set,activeKey:null,toggle:()=>{},select:()=>{},activate:()=>{},register:()=>()=>{}}),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"},b={xs:"0.875rem",sm:"1rem",md:"1.25rem",lg:"1.5rem",xl:"1.75rem"},h={xs:"1.375rem",sm:"1.625rem",md:"2rem",lg:"2.5rem",xl:"3rem"},v={default:{xs:"px-1.5",sm:"px-2",md:"px-2.5",lg:"px-3",xl:"px-3.5"},compact:{xs:"px-1",sm:"px-1",md:"px-1.5",lg:"px-2",xl:"px-2.5"}},y={xs:"rounded-[0.3125rem]",sm:"rounded-[0.375rem]",md:"rounded-[0.5rem]",lg:"rounded-[0.625rem]",xl:"rounded-[0.75rem]"},w={none:"",simple:"neba-tree-simple",folder:"neba-tree-folder"};function k(e){return Array.from(e.querySelectorAll('[role="treeitem"]'))}const C=e=>String(e);export const TreeView=/*@__PURE__*/n.forwardRef(function(t,r){const{variant:a="outline",size:l="md",color:o="primary",density:i="default",elevation:c=0,lines:u="simple",expanded:v,defaultExpanded:y,onExpandedChange:N,selected:S,defaultSelected:j,onSelectedChange:K,multiple:A=!1,disabled:D=!1,label:R,className:E,style:I,children:P,onKeyDown:z,...M}=p(t,["size","density","variant"]),[V,_]=n.useState(y??[]),[L,T]=n.useState(j??[]),[q,F]=n.useState(null),H=v??V,O=S??L,U=n.useRef(null),B=n.useCallback(e=>{U.current=e,"function"==typeof r?r(e):r&&(r.current=e)},[r]),G=n.useCallback(e=>{const t=C(e),r=v??V,n=r.some(e=>C(e)===t)?r.filter(e=>C(e)!==t):[...r,e];void 0===v&&_(n),N?.(n)},[v,V,N]),J=n.useCallback(e=>{const t=C(e),r=S??L,n=r.some(e=>C(e)===t),a=A?n?r.filter(e=>C(e)!==t):[...r,e]:[e];void 0===S&&T(a),K?.(a)},[A,S,L,K]),Q=n.useRef(new Map),W=n.useCallback((e,t)=>(Q.current.set(e,t),()=>{Q.current.delete(e)}),[]),X=n.useMemo(()=>H.map(C).join("\0"),[H]),Y=n.useMemo(()=>O.map(C).join("\0"),[O]),Z=n.useMemo(()=>({size:l,density:i,disabled:D,expandedKeys:new Set(H.map(C)),selectedKeys:new Set(O.map(C)),activeKey:q,toggle:G,select:J,activate:F,register:W}),[l,i,D,X,Y,q,G,J,W]);n.useEffect(()=>{if(null!==q&&Q.current.has(q))return;const e=U.current;if(!e)return;const t=k(e);0!==t.length&&F(t[0].dataset.nebaValue??null)});const $=s("flex list-none flex-col p-1",d[l],g[a],f,w[u],E);return e(x.Provider,{value:Z,children:e("ul",{ref:B,role:"tree","aria-label":R,"aria-multiselectable":A||void 0,className:$,style:{...m(o,c),"--n-tree-indent":b[l],"--n-tree-row":h[l],...I},onKeyDown:function(e){if(z?.(e),e.defaultPrevented)return;const t=U.current,r=e.target?.closest?.('[role="treeitem"]');if(!t||!r||!t.contains(r))return;const n=k(t),a=n.indexOf(r);if(-1===a)return;const l=t=>{t&&(e.preventDefault(),F(t.dataset.nebaValue??null),t.focus())},s=e=>{const t=e.dataset.nebaValue;t&&Q.current.get(t)?.toggle()},o="rtl"===getComputedStyle(t).direction,i=o?"ArrowLeft":"ArrowRight",c=o?"ArrowRight":"ArrowLeft",d=r.getAttribute("aria-expanded");switch(e.key){case"ArrowDown":l(n[a+1]);break;case"ArrowUp":l(n[a-1]);break;case"Home":l(n[0]);break;case"End":l(n[n.length-1]);break;case i:"false"===d?(e.preventDefault(),s(r)):"true"===d&&l(n[a+1]);break;case c:"true"===d?(e.preventDefault(),s(r)):l(r.parentElement?.closest('[role="treeitem"]'));break;case"Enter":case" ":e.preventDefault(),r.click()}},...M,children:P})})});export const TreeItem=/*@__PURE__*/n.forwardRef(function({value:d,label:u,startIcon:m,endIcon:p,action:g,href:b,expandable:h,disabled:w=!1,className:k,children:N,onClick:S,...j},K){const{size:A,density:D,disabled:R,expandedKeys:E,selectedKeys:I,activeKey:P,toggle:z,select:M,activate:V,register:_}=n.useContext(x),L=n.useId(),T=d??L,q=C(T),F=n.useRef(null),H=n.useCallback(e=>{F.current=e,"function"==typeof K?K(e):K&&(K.current=e)},[K]),O=n.Children.toArray(N),U=h??O.length>0,B=U&&E.has(q),G=I.has(q),J=w||R,Q=n.useRef({toggle:()=>{}});Q.current.toggle=()=>{!J&&U&&z(T)},n.useEffect(()=>_(q,Q.current),[q,_]);const W=s("flex min-w-0 flex-1 cursor-pointer items-center text-start","h-(--n-tree-row)",v[D][A],y[A],o[A],l[A],f,c,"group-focus-visible/tree-item:[outline:2px_solid_var(--n-ring)]","group-focus-visible/tree-item:outline-offset-[-2px]",J?"cursor-not-allowed text-(--neba-disabled-fg)":G?"bg-(--n-soft-press) font-medium text-(--n-accent) hover:bg-(--n-soft-press)":"hover:bg-(--n-soft)"),X=r(t,{children:[e("span",{"aria-hidden":"true",onClick:e=>{!J&&U&&(e.stopPropagation(),e.preventDefault(),F.current?.focus(),V(q),z(T))},className:s("flex h-[1lh] w-[1.15em] shrink-0 items-center justify-center","[transition:rotate_var(--neba-duration)_var(--neba-ease)]",U?"text-(--neba-muted-fg)":"",B?"rotate-0":"-rotate-90 rtl:rotate-90"),children:U?e(a,{}):null}),i(m)?e("span",{className:"flex h-[1lh] shrink-0 items-center text-(--neba-muted-fg)",children:m}):null,e("span",{className:"min-w-0 flex-1 truncate",children:u}),i(p)?e("span",{className:"flex h-[1lh] shrink-0 items-center text-(--neba-muted-fg)",children:p}):null]});return r("li",{ref:H,role:"treeitem","aria-expanded":U?B:void 0,"aria-selected":!!G||void 0,"aria-disabled":J||void 0,"data-neba-value":q,tabIndex:P===q?0:-1,className:s("group/tree-item relative block [outline:none]",k),onClick:function(e){e.stopPropagation(),J?e.preventDefault():(F.current?.focus(),V(q),S?.(e),e.defaultPrevented||(U&&z(T),M(T)))},...j,children:[r("div",{className:"flex w-full items-center",children:[b&&!J?e("a",{href:b,tabIndex:-1,className:W,"aria-current":G?"page":void 0,children:X}):e("div",{className:W,children:X}),i(g)?e("span",{className:s("flex shrink-0 items-center",v[D][A]),onClick:e=>e.stopPropagation(),children:g}):null]}),U&&B&&O.length>0?e("ul",{role:"group",className:"list-none ps-(--n-tree-indent)",children:N}):null]})});
|