neba 1.17.1 → 1.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/a2ui/adapter-catalog.json +1 -1
- package/dist/a2ui/catalog.json +2 -2
- package/dist/a2ui/index.d.ts +2 -0
- package/dist/a2ui/schema.d.ts +11 -1
- package/dist/a2ui/schema.js +1 -1
- package/dist/components/alert/Alert.js +1 -1
- package/dist/components/animate-counter/AnimateCounter.d.ts +6 -0
- package/dist/components/animate-counter/AnimateCounter.js +1 -1
- package/dist/components/animate-headline/AnimateHeadline.js +1 -1
- package/dist/components/animate-scramble/AnimateScramble.d.ts +9 -3
- package/dist/components/animate-scramble/AnimateScramble.js +1 -1
- package/dist/components/animate-split/AnimateSplit.d.ts +7 -1
- package/dist/components/animate-split/AnimateSplit.js +1 -1
- package/dist/components/animate-typing/AnimateTyping.d.ts +6 -0
- package/dist/components/animate-typing/AnimateTyping.js +1 -1
- package/dist/components/app-logo/AppLogo.js +1 -1
- package/dist/components/approval/Approval.js +1 -1
- package/dist/components/breadcrumb/Breadcrumb.d.ts +16 -0
- package/dist/components/breadcrumb/Breadcrumb.js +1 -1
- package/dist/components/calendar/Calendar.js +1 -1
- package/dist/components/card/Card.js +1 -1
- package/dist/components/carousel/Carousel.d.ts +3 -2
- package/dist/components/carousel/Carousel.js +1 -1
- package/dist/components/chat-bubble/ChatBubble.d.ts +6 -0
- package/dist/components/chat-bubble/ChatBubble.js +1 -1
- package/dist/components/checkbox/Checkbox.js +1 -1
- package/dist/components/checkbox-group/CheckboxGroup.d.ts +84 -0
- package/dist/components/checkbox-group/CheckboxGroup.js +1 -0
- package/dist/components/checkbox-group/index.d.ts +2 -0
- package/dist/components/checkbox-group/index.js +1 -0
- package/dist/components/code-block/CodeBlock.d.ts +2 -2
- package/dist/components/code-block/CodeBlock.js +1 -1
- package/dist/components/code-block/index.d.ts +2 -1
- package/dist/components/code-block/index.js +1 -1
- package/dist/components/color-picker/ColorPicker.js +1 -1
- package/dist/components/combobox/Combobox.js +1 -1
- package/dist/components/context-window/ContextWindow.js +1 -1
- package/dist/components/data-table/DataTable.d.ts +13 -1
- package/dist/components/data-table/DataTable.js +1 -1
- package/dist/components/date-picker/DatePicker.js +1 -1
- package/dist/components/date-range-picker/DateRangePicker.js +1 -1
- package/dist/components/date-time-picker/DateTimePicker.js +1 -1
- package/dist/components/drawer/Drawer.d.ts +21 -0
- package/dist/components/drawer/Drawer.js +1 -1
- package/dist/components/empty/Empty.js +1 -1
- package/dist/components/fieldset/Fieldset.d.ts +12 -1
- package/dist/components/fieldset/Fieldset.js +1 -1
- package/dist/components/file-picker/FilePicker.d.ts +0 -8
- package/dist/components/file-picker/FilePicker.js +1 -1
- package/dist/components/file-picker/formatFileSize.d.ts +8 -0
- package/dist/components/file-picker/formatFileSize.js +1 -0
- package/dist/components/file-picker/index.d.ts +2 -1
- package/dist/components/file-picker/index.js +1 -1
- package/dist/components/floating-bottom-navigation/FloatingBottomNavigation.js +1 -1
- package/dist/components/form/Form.d.ts +8 -2
- package/dist/components/form/Form.js +1 -1
- package/dist/components/gallery/Gallery.d.ts +45 -3
- package/dist/components/gallery/Gallery.js +1 -1
- package/dist/components/gallery/GalleryViewer.js +1 -1
- package/dist/components/gauge-chart/GaugeChart.js +1 -1
- package/dist/components/heatmap-chart/HeatmapChart.js +1 -1
- package/dist/components/how-to-steps/HowToSteps.d.ts +14 -0
- package/dist/components/how-to-steps/HowToSteps.js +1 -1
- package/dist/components/image/Image.d.ts +31 -6
- package/dist/components/image/Image.js +1 -1
- package/dist/components/list/List.d.ts +9 -0
- package/dist/components/list/List.js +1 -1
- package/dist/components/menu/Menu.d.ts +17 -0
- package/dist/components/menu/Menu.js +1 -1
- package/dist/components/meter/Meter.js +1 -1
- package/dist/components/mockup/Mockup.js +1 -1
- package/dist/components/number-field/NumberField.js +1 -1
- package/dist/components/page-layout/PageLayout.js +1 -1
- package/dist/components/panes/Panes.js +1 -1
- package/dist/components/pie-chart/PieChart.js +1 -1
- package/dist/components/pill/Pill.js +1 -1
- package/dist/components/progress-box/ProgressBox.js +1 -1
- package/dist/components/progress-circular/ProgressCircular.js +1 -1
- package/dist/components/progress-linear/ProgressLinear.js +1 -1
- package/dist/components/prompt-input/PromptInput.js +1 -1
- package/dist/components/provider/NebaProvider.d.ts +3 -22
- package/dist/components/provider/NebaProvider.js +1 -1
- package/dist/components/provider/colorSchemeScript.d.ts +23 -0
- package/dist/components/provider/colorSchemeScript.js +1 -0
- package/dist/components/provider/index.d.ts +2 -1
- package/dist/components/provider/index.js +1 -1
- package/dist/components/radio-group/RadioGroup.d.ts +13 -0
- package/dist/components/radio-group/RadioGroup.js +1 -1
- package/dist/components/reasoning/Reasoning.d.ts +21 -0
- package/dist/components/reasoning/Reasoning.js +1 -1
- package/dist/components/scatter-chart/ScatterChart.js +1 -1
- package/dist/components/scroll-zone/ScrollZone.js +1 -1
- package/dist/components/segmented-button/SegmentedButton.js +1 -1
- package/dist/components/select/Select.js +1 -1
- package/dist/components/sidebar/Sidebar.d.ts +13 -0
- package/dist/components/sidebar/Sidebar.js +1 -1
- package/dist/components/slider/Slider.js +1 -1
- package/dist/components/sources/Sources.d.ts +11 -0
- package/dist/components/sources/Sources.js +1 -1
- package/dist/components/spoiler/Spoiler.js +1 -1
- package/dist/components/statistic/Statistic.js +1 -1
- package/dist/components/streaming-text/StreamingText.d.ts +22 -11
- package/dist/components/streaming-text/StreamingText.js +1 -1
- package/dist/components/tabs/Tabs.d.ts +12 -1
- package/dist/components/tabs/Tabs.js +1 -1
- package/dist/components/text-link/TextLink.d.ts +7 -0
- package/dist/components/text-link/TextLink.js +1 -1
- package/dist/components/time-picker/TimePicker.js +1 -1
- package/dist/components/timeline-chart/TimelineChart.js +1 -1
- package/dist/components/toast/Toast.js +1 -1
- package/dist/components/tool-call/ToolCall.d.ts +11 -0
- package/dist/components/tool-call/ToolCall.js +1 -1
- package/dist/components/tour/Tour.js +1 -1
- package/dist/components/tree-view/TreeView.d.ts +13 -1
- package/dist/components/tree-view/TreeView.js +1 -1
- package/dist/components/typography/Typography.d.ts +7 -0
- package/dist/components/typography/Typography.js +1 -1
- package/dist/components/window-pane/WindowPane.js +1 -1
- package/dist/hooks/useElementSize.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/internal/animate.js +1 -1
- package/dist/internal/calendar.d.ts +2 -2
- package/dist/internal/calendar.js +1 -1
- package/dist/internal/chart-frame.d.ts +59 -2
- package/dist/internal/chart-frame.js +1 -1
- package/dist/internal/chart-line.js +1 -1
- package/dist/internal/checkbox-group.d.ts +29 -0
- package/dist/internal/checkbox-group.js +1 -0
- package/dist/internal/defaults.d.ts +14 -2
- package/dist/internal/format.d.ts +7 -0
- package/dist/internal/format.js +1 -1
- package/dist/internal/highlight.d.ts +9 -0
- package/dist/internal/highlight.js +1 -1
- package/dist/internal/layout-effect.d.ts +17 -0
- package/dist/internal/layout-effect.js +1 -0
- package/dist/internal/media.d.ts +20 -0
- package/dist/internal/media.js +1 -1
- package/dist/internal/menu.d.ts +5 -0
- package/dist/internal/observe.d.ts +4 -1
- package/dist/internal/observe.js +1 -1
- package/dist/internal/overrides.d.ts +55 -0
- package/dist/internal/overrides.js +1 -0
- package/dist/internal/page-layout.d.ts +26 -1
- package/dist/internal/page-layout.js +1 -1
- package/dist/internal/run.d.ts +6 -1
- package/dist/internal/run.js +1 -1
- package/dist/internal/sizer.d.ts +10 -0
- package/dist/internal/sizer.js +1 -1
- package/dist/internal/styles.d.ts +41 -3
- package/dist/internal/styles.js +1 -1
- package/dist/internal/text.d.ts +25 -3
- package/dist/internal/text.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +94 -73
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as l,Fragment as
|
|
1
|
+
"use client";import{jsx as e,jsxs as l,Fragment as s}from"react/jsx-runtime";import*as t from"react";import{Box as n,boxPaddingXClasses as r,boxPaddingYClasses as a}from"../box/Box.js";import{cx as i,hasContent as o,metaTextClasses as c,sheetBodyClasses as d,sheetHeaderGapClasses as m,sheetSectionGapClasses as f,sheetTitleClasses as u,sheetTitleHeadingClasses as x}from"../../internal/styles.js";import{useStyleDefaults as h}from"../../internal/defaults.js";export const Card=/*@__PURE__*/t.forwardRef(function Card(t,p){const{size:N="md",density:$="default",title:y,subtitle:v,headerAction:b,footer:j,dividers:k=!1,className:g,children:w,...z}=h(t,["size","density"]),C=r[$][N],A=a[$][N],B=k?`${C} ${A}`:C,F=o(y)||o(v)||o(b),R=l(s,{children:[o(y)||o(v)?l("div",{className:`flex min-w-0 flex-1 flex-col ${m[N]}`,children:[o(y)?e("div",{className:`${x} font-semibold ${u[N]}`,children:y}):null,o(v)?e("div",{className:`text-(--neba-muted-fg) ${c[N]}`,children:v}):null]}):null,o(b)?e("div",{className:"ms-auto shrink-0",children:b}):null]}),q=[F?{key:"header",className:"flex items-start gap-3",content:R}:null,o(w)?{key:"content",className:d[N],content:w}:null,o(j)?{key:"footer",className:`flex flex-wrap items-center gap-2 ${d[N]}`,content:j}:null].filter(e=>null!==e);return e(n,{ref:p,size:N,density:$,padded:!1,className:i("flex flex-col",k?"":`${A} ${f[N]}`,g??""),...z,children:q.map((l,s)=>e("div",{className:i(B,l.className,k&&s>0?"border-t [border-color:var(--n-line)]":""),children:l.content},l.key))})});
|
|
@@ -24,8 +24,9 @@ export interface CarouselProps extends NebaStyleProps, Omit<React.ComponentProps
|
|
|
24
24
|
*
|
|
25
25
|
* Off by default and deliberately so: a carousel that moves while it is being
|
|
26
26
|
* read is the most complained-about pattern on the web. It pauses on hover,
|
|
27
|
-
* on focus anywhere inside it, while the tab is in the background
|
|
28
|
-
*
|
|
27
|
+
* on focus anywhere inside it, while the tab is in the background and while
|
|
28
|
+
* the strip is scrolled out of view, and it does not start at all for a
|
|
29
|
+
* reader who has asked for reduced motion.
|
|
29
30
|
*
|
|
30
31
|
* Turning it on draws a button that stops it, in the row under the frame
|
|
31
32
|
* beside the dots. There is no prop to take that button away: hover and focus
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as r from"react";import{IconButton as n}from"../icon-button/IconButton.js";import{childKey as a}from"../../internal/children.js";import{carouselMessages as l,fillMessage as o,useMessages as i}from"../../internal/i18n.js";import{ChevronIcon as s,PauseIcon as c,PlayIcon as u}from"../../internal/icons.js";import{usePrefersReducedMotion as d}from"../../internal/media.js";import{cx as
|
|
1
|
+
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as r from"react";import{IconButton as n}from"../icon-button/IconButton.js";import{childKey as a}from"../../internal/children.js";import{carouselMessages as l,fillMessage as o,useMessages as i}from"../../internal/i18n.js";import{ChevronIcon as s,PauseIcon as c,PlayIcon as u}from"../../internal/icons.js";import{usePrefersReducedMotion as d}from"../../internal/media.js";import{observeVisibility as m}from"../../internal/observe.js";import{cx as f,radiusClasses as p,srOnlyClasses as b,surfaceClasses as h,surfaceSlots as v,transitionClasses as g}from"../../internal/styles.js";import{useStyleDefaults as x}from"../../internal/defaults.js";const w={solid:[h,"text-(--neba-fg) bg-(--n-panel-hover)","[box-shadow:var(--n-elev),var(--neba-plate-solid)]"].join(" "),outline:[h,"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"},y={xs:"start-1 end-1",sm:"start-1.5 end-1.5",md:"start-2 end-2",lg:"start-3 end-3",xl:"start-4 end-4"},j={xs:{rest:"h-1 w-1",current:"h-1 w-3",gap:"gap-1"},sm:{rest:"h-1 w-1",current:"h-1 w-3.5",gap:"gap-1"},md:{rest:"h-1.5 w-1.5",current:"h-1.5 w-4",gap:"gap-1.5"},lg:{rest:"h-1.5 w-1.5",current:"h-1.5 w-5",gap:"gap-2"},xl:{rest:"h-2 w-2",current:"h-2 w-6",gap:"gap-2"}},N={xs:"0.25rem",sm:"0.25rem",md:"0.375rem",lg:"0.5rem",xl:"0.5rem"};export const Carousel=/*@__PURE__*/r.forwardRef(function Carousel(h,C){const{variant:k="outline",size:S="md",color:L="primary",density:M="default",elevation:_=0,value:z,defaultValue:E=0,onValueChange:P,loop:R=!0,autoPlay:T=!1,interval:W=5e3,arrows:I=!0,indicators:$=!0,locale:B,label:D,previousLabel:F,nextLabel:V,pauseLabel:A,playLabel:q,slideLabel:G,className:H,style:J,children:K,onPointerEnter:O,onPointerLeave:Q,onFocus:U,onBlur:X,...Y}=x(h,["size","density","variant","locale"]),Z=i(l,B),ee=G??((e,t)=>o(Z.slide,{index:String(e),total:String(t)})),te=r.Children.toArray(K),re=te.length,[ne,ae]=r.useState(E),le=Math.min(Math.max(z??ne,0),Math.max(re-1,0)),oe=r.useRef(null),ie=r.useRef(!1),se=r.useRef(!1),ce=r.useRef(!1),[ue,de]=r.useState(!1),[me,fe]=r.useState(!1),pe=ue||me,[be,he]=r.useState(!1),ve=r.useCallback((e,t=!1)=>{if(0===re)return;const r=R?(e%re+re)%re:Math.min(Math.max(e,0),re-1);ie.current=t,void 0===z&&ae(r),r!==le&&P?.(r)},[re,R,z,le,P]);r.useEffect(()=>{if(ie.current)return void(ie.current=!1);const e=!se.current;if(se.current=!0,e&&0===le)return;const t=oe.current;if(t){const r="rtl"===getComputedStyle(t).direction?-1:1;t.scrollTo({left:r*le*t.clientWidth,...e?{behavior:"instant"}:null})}ce.current=!0;const r=window.setTimeout(()=>{ce.current=!1},700);return()=>window.clearTimeout(r)},[le]);const ge=d(),[xe,we]=r.useState(!1),ye=T&&!be&&!ge&&re>1;r.useEffect(()=>{const e=oe.current;if(ye&&e)return m(e,0,e=>we(!e))??void 0},[ye]),r.useEffect(()=>{if(!T||be||pe||ge||xe||re<2)return;const e=window.setInterval(()=>{document.hidden||ve(le+1)},W);return()=>window.clearInterval(e)},[T,be,pe,ge,xe,re,W,le,ve]);const je=le<=0,Ne=le>=re-1,Ce=T&&!ge&&re>1,ke=$&&re>1;return t("div",{ref:C,role:"region","aria-roledescription":"carousel","aria-label":D??Z.label,className:f("flex flex-col",H??""),style:{...v(L,_),...J},onPointerEnter:e=>{de(!0),O?.(e)},onPointerLeave:e=>{de(!1),Q?.(e)},onFocus:e=>{fe(!0),U?.(e)},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||fe(!1),X?.(e)},...Y,children:[t("div",{className:["relative min-w-0 overflow-hidden",p[S],w[k],g].join(" "),children:[e("div",{ref:oe,tabIndex:0,role:"group","aria-label":D??Z.label,className:["flex min-w-0 snap-x snap-mandatory overflow-x-auto scroll-smooth","motion-reduce:scroll-auto","[scrollbar-width:none] [&::-webkit-scrollbar]:hidden","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:[outline-offset:-2px]"].join(" "),onScroll:()=>{const e=oe.current;if(ce.current||!e||0===e.clientWidth)return;const t=Math.round(Math.abs(e.scrollLeft)/e.clientWidth);t!==le&&t>=0&&t<re&&ve(t,!0)},children:te.map((t,r)=>e("div",{role:"group","aria-roledescription":"slide","aria-label":ee(r+1,re),className:"w-full shrink-0 grow-0 basis-full snap-start",children:t},a(t,r)))}),I&&re>1?t("div",{className:`pointer-events-none absolute inset-y-0 flex items-center ${y[S]}`,children:[e(n,{variant:"solid",size:S,color:L,density:M,elevation:1,label:F??Z.previous,disabled:!R&&je,focusableWhenDisabled:!0,className:"pointer-events-auto",icon:e("span",{className:"flex items-center rotate-90 rtl:-rotate-90",children:e(s,{})}),onClick:()=>ve(le-1)}),e("span",{className:"flex-1"}),e(n,{variant:"solid",size:S,color:L,density:M,elevation:1,label:V??Z.next,disabled:!R&&Ne,focusableWhenDisabled:!0,className:"pointer-events-auto",icon:e("span",{className:"flex items-center -rotate-90 rtl:rotate-90",children:e(s,{})}),onClick:()=>ve(le+1)})]}):null]}),Ce||ke?t("div",{className:"grid shrink-0 grid-cols-[1fr_auto_1fr] items-center pt-2",children:[e("span",{className:"flex justify-start",children:Ce?e(n,{variant:"text",size:S,color:L,density:M,label:be?q??Z.play:A??Z.pause,icon:e(be?u:c,{}),onClick:()=>he(e=>!e)}):null}),e("span",{className:`flex items-center ${j[S].gap}`,style:{"--n-hit-gap":N[S]},children:ke?te.map((t,r)=>e("button",{type:"button","aria-label":ee(r+1,re),"aria-current":r===le?"true":void 0,className:["neba-hit-row relative cursor-pointer rounded-full","[transition-property:width,background-color]","[transition-duration:var(--neba-duration)]","[transition-timing-function:var(--neba-ease)]","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2",r===le?`${j[S].current} bg-(--n-accent)`:`${j[S].rest} bg-(--n-line-hover) hover:bg-(--n-accent)`].join(" "),onClick:()=>ve(r)},r)):null}),e("span",{})]}):null,e("span",{className:b,"aria-live":!Ce||be||pe?"polite":"off",children:re>0?ee(le+1,re):""})]})});
|
|
@@ -31,6 +31,12 @@ export interface ChatBubbleLinkPreview {
|
|
|
31
31
|
site?: React.ReactNode;
|
|
32
32
|
/** Opens the card in a new tab. @default false */
|
|
33
33
|
newTab?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The link's `rel`. A preview of a URL somebody posted is the usual reason:
|
|
36
|
+
* `'ugc nofollow'` tells a search engine the page did not choose the link.
|
|
37
|
+
* With `newTab`, `noopener noreferrer` is added to whatever is written here.
|
|
38
|
+
*/
|
|
39
|
+
rel?: string;
|
|
34
40
|
}
|
|
35
41
|
export interface ChatBubbleProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'title'> {
|
|
36
42
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as n}from"react/jsx-runtime";import*as r from"react";import{chatMessages as l,useMessages as a}from"../../internal/i18n.js";import{CheckIcon as i,ClockIcon as t,DangerIcon as o,LinkIcon as s}from"../../internal/icons.js";import{safeHref as c,safeRel as d}from"../../internal/link.js";import{NewTabNote as m}from"../../internal/new-tab.js";import{controlSlots as p,cx as u,hasContent as f,metaTextClasses as b,radiusClasses as h,sheetBodyClasses as v,sheetHeaderGapClasses as x,srOnlyClasses as g,surfaceClasses as k,transitionClasses as y}from"../../internal/styles.js";import{useStyleDefaults as w}from"../../internal/defaults.js";const N={default:{xs:"px-2 py-1",sm:"px-2.5 py-1.5",md:"px-3 py-2",lg:"px-3.5 py-2.5",xl:"px-4 py-3"},compact:{xs:"px-1.5 py-0.5",sm:"px-2 py-1",md:"px-2.5 py-1.5",lg:"px-3 py-1.5",xl:"px-3.5 py-2"}},j={start:"[border-start-start-radius:0.25rem]",end:"[border-start-end-radius:0.25rem]"},_={solid:[k,"text-(--n-on-solid) bg-(--n-fill)","[box-shadow:var(--n-elev),var(--neba-plate-solid)]"].join(" "),outline:[k,"border text-(--neba-fg) bg-(--n-panel)","[border-color:var(--n-line)]","[box-shadow:var(--n-elev),var(--neba-plate-glass)]"].join(" "),text:"text-(--neba-fg) bg-(--n-soft) [box-shadow:var(--n-elev)]"};const L={sending:e(t,{}),sent:e(i,{}),delivered:e(function DoubleCheckIcon(){return n("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[e("path",{d:"m1.5 8.5 2.75 2.75L9.5 6",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M7 10.75 8.25 12l5.25-5.25",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})]})},{}),read:e(function ReadIcon(){const l=r.useId();return n("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[n("mask",{id:l,children:[e("rect",{width:"16",height:"16",fill:"white"}),n("g",{transform:"translate(2.375 1.25) scale(0.75)",stroke:"black",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e("path",{d:"m1.5 8.5 2.75 2.75L9.5 6"}),e("path",{d:"M7 10.75 8.25 12l5.25-5.25"})]})]}),e("circle",{cx:"8",cy:"8",r:"7.25",fill:"currentColor",mask:`url(#${l})`})]})},{}),failed:e(o,{})},C={sending:"text-(--neba-muted-fg)",sent:"text-(--neba-muted-fg)",delivered:"text-(--neba-muted-fg)",read:"text-(--n-accent)",failed:"text-(--neba-danger-accent)"},z=["block overflow-hidden rounded-(--neba-radius-sm) border no-underline","[border-color:color-mix(in_oklab,currentColor_18%,transparent)]","[background-color:color-mix(in_oklab,currentColor_7%,transparent)]","hover:[background-color:color-mix(in_oklab,currentColor_12%,transparent)]","[transition-property:background-color] [transition-duration:var(--neba-duration)]","[transition-timing-function:var(--neba-ease)]","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2"].join(" "),B=["shrink-0 opacity-0","[transition:opacity_var(--neba-duration)_var(--neba-ease)]","group-hover/bubble:opacity-100 group-focus-within/bubble:opacity-100","[@media(hover:none)]:opacity-100"].join(" ");export const ChatBubble=/*@__PURE__*/r.forwardRef(function ChatBubble(r,i){const{side:t="start",name:o,time:s,avatar:c,status:d,statusLabel:m,typing:k=!1,media:z,preview:D,actions:I,locale:T,variant:W="outline",size:M="md",color:P="primary",density:R="default",elevation:$=0,className:q,style:A,children:E,...F}=w(r,["size","density","variant","locale"]),G=a(l,T),H="end"===t,J=f(o)||f(s),K=k||f(E)||Boolean(D),O=["flex min-w-0 flex-col overflow-hidden",h[M],j[t],_[W],y].join(" "),Q=d?m??G[d]:"";return n("div",{ref:i,className:u("group/bubble flex w-full items-start gap-2",H?"flex-row-reverse":"",q??""),style:{...p(P,$,W),...A},...F,children:[f(c)?e("div",{className:"shrink-0",children:c}):null,n("div",{className:["flex min-w-0 max-w-[min(100%,32rem)] flex-col",x[M],H?"items-end":"items-start"].join(" "),children:[J?n("div",{className:`flex items-baseline gap-2 ${b[M]}`,children:[f(o)?e("span",{className:"font-semibold",children:o}):null,f(s)?e("span",{className:"text-(--neba-muted-fg)",children:s}):null]}):null,n("div",{className:"flex min-w-0 items-center gap-1 "+(H?"flex-row-reverse":""),children:[n("div",{className:O,children:[f(z)?e("div",{className:"[&_img]:block [&_img]:w-full [&_video]:block [&_video]:w-full",children:z}):null,K?n("div",{className:[N[R][M],"flex min-w-0 flex-col gap-2",v[M]].join(" "),children:[k?e(TypingDots,{label:G.typing}):f(E)?e("div",{className:"min-w-0 break-words whitespace-pre-line",children:E}):null,D?e(LinkPreview,{preview:D,locale:T}):null]}):null]}),f(I)?e("div",{className:B,children:I}):null]}),d?n("div",{className:["flex items-center gap-1",b[M],C[d],"[&_svg]:size-[1.15em] [&_svg]:shrink-0"].join(" "),children:[L[d],e("span",{className:g,children:Q})]}):null]})]})});function TypingDots({label:r}){return n("div",{className:"flex items-center gap-1 py-[0.35em]",role:"status",children:[[0,1,2].map(n=>e("span",{"aria-hidden":"true",className:"neba-typing-dot size-[0.45em] rounded-full",style:{"--n-i":n}},n)),e("span",{className:g,children:r})]})}function LinkPreview({preview:r,locale:l}){const{url:a,title:i,description:t,image:o,site:p,newTab:u=!1}=r,
|
|
1
|
+
"use client";import{jsx as e,jsxs as n}from"react/jsx-runtime";import*as r from"react";import{chatMessages as l,useMessages as a}from"../../internal/i18n.js";import{CheckIcon as i,ClockIcon as t,DangerIcon as o,LinkIcon as s}from"../../internal/icons.js";import{safeHref as c,safeRel as d}from"../../internal/link.js";import{NewTabNote as m}from"../../internal/new-tab.js";import{controlSlots as p,cx as u,hasContent as f,metaTextClasses as b,radiusClasses as h,sheetBodyClasses as v,sheetHeaderGapClasses as x,srOnlyClasses as g,surfaceClasses as k,transitionClasses as y}from"../../internal/styles.js";import{useStyleDefaults as w}from"../../internal/defaults.js";const N={default:{xs:"px-2 py-1",sm:"px-2.5 py-1.5",md:"px-3 py-2",lg:"px-3.5 py-2.5",xl:"px-4 py-3"},compact:{xs:"px-1.5 py-0.5",sm:"px-2 py-1",md:"px-2.5 py-1.5",lg:"px-3 py-1.5",xl:"px-3.5 py-2"}},j={start:"[border-start-start-radius:0.25rem]",end:"[border-start-end-radius:0.25rem]"},_={solid:[k,"text-(--n-on-solid) bg-(--n-fill)","[box-shadow:var(--n-elev),var(--neba-plate-solid)]"].join(" "),outline:[k,"border text-(--neba-fg) bg-(--n-panel)","[border-color:var(--n-line)]","[box-shadow:var(--n-elev),var(--neba-plate-glass)]"].join(" "),text:"text-(--neba-fg) bg-(--n-soft) [box-shadow:var(--n-elev)]"};const L={sending:e(t,{}),sent:e(i,{}),delivered:e(function DoubleCheckIcon(){return n("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[e("path",{d:"m1.5 8.5 2.75 2.75L9.5 6",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M7 10.75 8.25 12l5.25-5.25",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})]})},{}),read:e(function ReadIcon(){const l=r.useId();return n("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[n("mask",{id:l,children:[e("rect",{width:"16",height:"16",fill:"white"}),n("g",{transform:"translate(2.375 1.25) scale(0.75)",stroke:"black",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e("path",{d:"m1.5 8.5 2.75 2.75L9.5 6"}),e("path",{d:"M7 10.75 8.25 12l5.25-5.25"})]})]}),e("circle",{cx:"8",cy:"8",r:"7.25",fill:"currentColor",mask:`url(#${l})`})]})},{}),failed:e(o,{})},C={sending:"text-(--neba-muted-fg)",sent:"text-(--neba-muted-fg)",delivered:"text-(--neba-muted-fg)",read:"text-(--n-accent)",failed:"text-(--neba-danger-accent)"},z=["block overflow-hidden rounded-(--neba-radius-sm) border no-underline","[border-color:color-mix(in_oklab,currentColor_18%,transparent)]","[background-color:color-mix(in_oklab,currentColor_7%,transparent)]","hover:[background-color:color-mix(in_oklab,currentColor_12%,transparent)]","[transition-property:background-color] [transition-duration:var(--neba-duration)]","[transition-timing-function:var(--neba-ease)]","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2"].join(" "),B=["shrink-0 opacity-0","[transition:opacity_var(--neba-duration)_var(--neba-ease)]","group-hover/bubble:opacity-100 group-focus-within/bubble:opacity-100","[@media(hover:none)]:opacity-100"].join(" ");export const ChatBubble=/*@__PURE__*/r.forwardRef(function ChatBubble(r,i){const{side:t="start",name:o,time:s,avatar:c,status:d,statusLabel:m,typing:k=!1,media:z,preview:D,actions:I,locale:T,variant:W="outline",size:M="md",color:P="primary",density:R="default",elevation:$=0,className:q,style:A,children:E,...F}=w(r,["size","density","variant","locale"]),G=a(l,T),H="end"===t,J=f(o)||f(s),K=k||f(E)||Boolean(D),O=["flex min-w-0 flex-col overflow-hidden",h[M],j[t],_[W],y].join(" "),Q=d?m??G[d]:"";return n("div",{ref:i,className:u("group/bubble flex w-full items-start gap-2",H?"flex-row-reverse":"",q??""),style:{...p(P,$,W),...A},...F,children:[f(c)?e("div",{className:"shrink-0",children:c}):null,n("div",{className:["flex min-w-0 max-w-[min(100%,32rem)] flex-col",x[M],H?"items-end":"items-start"].join(" "),children:[J?n("div",{className:`flex items-baseline gap-2 ${b[M]}`,children:[f(o)?e("span",{className:"font-semibold",children:o}):null,f(s)?e("span",{className:"text-(--neba-muted-fg)",children:s}):null]}):null,n("div",{className:"flex min-w-0 items-center gap-1 "+(H?"flex-row-reverse":""),children:[n("div",{className:O,children:[f(z)?e("div",{className:"[&_img]:block [&_img]:w-full [&_video]:block [&_video]:w-full",children:z}):null,K?n("div",{className:[N[R][M],"flex min-w-0 flex-col gap-2",v[M]].join(" "),children:[k?e(TypingDots,{label:G.typing}):f(E)?e("div",{className:"min-w-0 break-words whitespace-pre-line",children:E}):null,D?e(LinkPreview,{preview:D,locale:T}):null]}):null]}),f(I)?e("div",{className:B,children:I}):null]}),d?n("div",{className:["flex items-center gap-1",b[M],C[d],"[&_svg]:size-[1.15em] [&_svg]:shrink-0"].join(" "),children:[L[d],e("span",{className:g,children:Q})]}):null]})]})});function TypingDots({label:r}){return n("div",{className:"flex items-center gap-1 py-[0.35em]",role:"status",children:[[0,1,2].map(n=>e("span",{"aria-hidden":"true",className:"neba-typing-dot size-[0.45em] rounded-full",style:{"--n-i":n}},n)),e("span",{className:g,children:r})]})}function LinkPreview({preview:r,locale:l}){const{url:a,title:i,description:t,image:o,site:p,newTab:u=!1,rel:b}=r,h=u?"_blank":void 0;return n("a",{href:c(a),target:h,rel:d(h,b),className:z,children:[o?e("img",{alt:"",loading:"lazy",decoding:"async",className:"block h-28 w-full object-cover",src:o}):null,n("div",{className:"flex flex-col gap-0.5 p-2",children:[f(p)?n("span",{className:"flex items-center gap-1 text-[0.85em] opacity-70 [&_svg]:size-[1em] [&_svg]:shrink-0",children:[e(s,{}),e("span",{className:"truncate",children:p})]}):null,f(i)?e("span",{className:"font-semibold",children:i}):null,f(t)?e("span",{className:"line-clamp-2 text-[0.9em] opacity-80",children:t}):null,e(m,{target:h,locale:l})]})]})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as n from"react";import{Checkbox as r}from"@base-ui/react/checkbox";import{Field as t}from"@base-ui/react/field";import{controlTextClasses as i,cx as o,hitAreaClasses as l,metaTextClasses as s,surfaceClasses as d,tickRadiusClasses as c,tickRowLeadingClasses as h,tickSizeClasses as b,transitionClasses as f}from"../../internal/styles.js";import{useStyleDefaults as
|
|
1
|
+
"use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as n from"react";import{Checkbox as r}from"@base-ui/react/checkbox";import{Field as t}from"@base-ui/react/field";import{controlTextClasses as i,cx as o,hitAreaClasses as l,metaTextClasses as s,surfaceClasses as d,tickRadiusClasses as c,tickRowLeadingClasses as h,tickSizeClasses as b,transitionClasses as f}from"../../internal/styles.js";import{useStyleDefaults as m}from"../../internal/defaults.js";import{useFieldsetDisabled as p}from"../../internal/fieldset.js";import{CheckboxGroupContext as u}from"../../internal/checkbox-group.js";const v=["relative inline-flex shrink-0 items-center justify-center border",l,"[-webkit-tap-highlight-color:transparent] [touch-action:manipulation]",f,"active:[transition-duration:0ms]","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2"].join(" "),g=[d,"cursor-pointer bg-(--n-panel) [border-color:var(--n-line)]","hover:bg-(--n-panel-hover) hover:[border-color:var(--n-line-hover)]","data-[checked]:bg-(--n-fill) data-[checked]:text-(--n-on-solid)","data-[checked]:[border-color:transparent]","data-[checked]:hover:bg-(--n-fill-hover)","data-[indeterminate]:bg-(--n-fill) data-[indeterminate]:text-(--n-on-solid)","data-[indeterminate]:[border-color:transparent]"].join(" "),k=[d,"cursor-default bg-(--n-panel) [border-color:var(--n-line)]","[filter:saturate(0.55)]","data-[checked]:bg-(--n-fill) data-[checked]:text-(--n-on-solid)","data-[checked]:[border-color:transparent]","data-[indeterminate]:bg-(--n-fill) data-[indeterminate]:text-(--n-on-solid)","data-[indeterminate]:[border-color:transparent]"].join(" "),x=["cursor-not-allowed bg-transparent [border-color:var(--neba-disabled-border)]","text-(--neba-disabled-fg) shadow-none","data-[checked]:bg-(--neba-disabled-bg)","data-[indeterminate]:bg-(--neba-disabled-bg)"].join(" "),y=["flex size-[70%] items-center justify-center","[transition:opacity_var(--neba-duration)_var(--neba-ease)]","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0","[&_path]:[stroke-dasharray:1]","[&_path]:[transition:stroke-dashoffset_var(--neba-duration)_var(--neba-ease)]","[&[data-starting-style]_path]:[stroke-dashoffset:1]","[&[data-ending-style]_path]:[stroke-dashoffset:1]"].join(" ");function CheckMark(){return e("svg",{viewBox:"0 0 12 12",fill:"none","aria-hidden":"true",className:"size-full",children:e("path",{d:"M2 6.2 4.6 8.8 10 3.4",pathLength:"1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function DashMark(){return e("svg",{viewBox:"0 0 12 12",fill:"none","aria-hidden":"true",className:"size-full",children:e("path",{d:"M2.5 6h7",pathLength:"1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})}export const Checkbox=/*@__PURE__*/n.forwardRef(function Checkbox(l,d){const f=n.useContext(u),{size:j,color:N,label:_,description:$,error:C,invalid:w,disabled:z,readOnly:L,name:M,className:D,classNames:O,style:R,...B}=m(l,["size"],f),W=j??f?.size??"md",E=N??f?.color??"primary",I=L??f?.readOnly??!1,q=M??f?.name,A=p(z)||!0===f?.disabled,F=null!=C&&!1!==C&&""!==C,G=w??F,H=G||!0===f?.invalid?"danger":E,J={"--n-fill":`var(--neba-${H}-fill)`,"--n-fill-hover":`var(--neba-${H}-fill-hover)`,"--n-on-solid":`var(--neba-${H}-on-solid)`,"--n-accent":`var(--neba-${H}-accent)`,"--n-panel":"var(--neba-panel)","--n-panel-hover":"var(--neba-panel-hover)","--n-line":`var(--neba-${H}-line)`,"--n-line-hover":`var(--neba-${H}-line-hover)`,"--n-ring":`var(--neba-${H}-ring)`},K=[v,b[W],c[W],A?x:I?k:g].join(" ");return a(t.Root,{disabled:A,invalid:G,className:o("inline-flex flex-col gap-1 align-top",D??""),style:{...J,...R},children:[a("div",{className:`flex items-start gap-2 ${i[W]} ${h}`,children:[e("span",{className:"flex h-[1lh] shrink-0 items-center",children:e(r.Root,{ref:d,className:o(K,O?.control),disabled:A,readOnly:I,name:q,...B,children:e(r.Indicator,{className:o(y,O?.indicator),render:(a,n)=>e("span",{...a,children:n.indeterminate?e(DashMark,{}):e(CheckMark,{})})})})}),_||$?a("span",{className:"flex min-w-0 flex-col gap-0.5",children:[_?e(t.Label,{className:o("leading-[1.4]",A?"text-(--neba-disabled-fg)":"cursor-pointer text-(--neba-fg)",O?.label),children:_}):null,$?e(t.Description,{className:o(s[W],"text-(--neba-muted-fg)",O?.description),children:$}):null]}):null]}),e(t.Error,F?{match:!0,className:o(s[W],"text-(--n-accent)",O?.error),children:C}:{className:o(s[W],"text-(--n-accent)",O?.error)})]})});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { CheckboxGroup as BaseUICheckboxGroup } from '@base-ui/react/checkbox-group';
|
|
3
|
+
import type { NebaColor, NebaFieldSlot, NebaOrientation, NebaSize, NebaSlots } from '../../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* The parts a CheckboxGroup draws behind its root. `control` is the element
|
|
6
|
+
* that holds the checkboxes — the one carrying the row or column direction —
|
|
7
|
+
* and not any single Checkbox, which has slots of its own.
|
|
8
|
+
*/
|
|
9
|
+
export type CheckboxGroupSlot = NebaFieldSlot;
|
|
10
|
+
export interface CheckboxGroupProps extends Omit<React.ComponentPropsWithoutRef<typeof BaseUICheckboxGroup>, 'className' | 'style' | 'render'> {
|
|
11
|
+
/**
|
|
12
|
+
* The size of every Checkbox inside, unless one sets its own, and the type
|
|
13
|
+
* scale of the label, the description and the error.
|
|
14
|
+
* @default 'md'
|
|
15
|
+
*/
|
|
16
|
+
size?: NebaSize;
|
|
17
|
+
/** The colour family of every Checkbox inside, unless one sets its own. @default 'primary' */
|
|
18
|
+
color?: NebaColor;
|
|
19
|
+
/**
|
|
20
|
+
* Which way the checkboxes stack. Vertical by default, for RadioGroup's
|
|
21
|
+
* reason: a column is scannable at any length, and a row stops being readable
|
|
22
|
+
* the moment one label runs long.
|
|
23
|
+
* @default 'vertical'
|
|
24
|
+
*/
|
|
25
|
+
orientation?: NebaOrientation;
|
|
26
|
+
/**
|
|
27
|
+
* The gap between the checkboxes, on Tailwind's spacing scale: `3` is
|
|
28
|
+
* `0.75rem`, the same step `gap-3` is. One length on both axes, so a
|
|
29
|
+
* horizontal group that wraps puts its lines as far apart as its options.
|
|
30
|
+
* Left out, a column follows `size` on the ladder a Form stands its fields
|
|
31
|
+
* on, `3` at `md`, and a row keeps `5` along it with the column's step
|
|
32
|
+
* between its lines — RadioGroup's gaps, so the two read as the same kind of
|
|
33
|
+
* question.
|
|
34
|
+
*
|
|
35
|
+
* Not read from a `NebaProvider`: the provider's `spacing` is the gap between
|
|
36
|
+
* fields, and a product that spreads its fields apart should not spread every
|
|
37
|
+
* set of options with them.
|
|
38
|
+
*/
|
|
39
|
+
spacing?: number;
|
|
40
|
+
/** The question the checkboxes answer. It names the group. */
|
|
41
|
+
label?: React.ReactNode;
|
|
42
|
+
/** Helper text under the label. */
|
|
43
|
+
description?: React.ReactNode;
|
|
44
|
+
/** Error message below the checkboxes. Its presence also turns the group invalid. */
|
|
45
|
+
error?: React.ReactNode;
|
|
46
|
+
/** Forces the invalid state without a message. Defaults to `!!error`. */
|
|
47
|
+
invalid?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Shows every checkbox's state without letting it change. Base UI's group
|
|
50
|
+
* has no such state, so this is handed to each Checkbox inside.
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
readOnly?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* The name the ticked values are submitted under. A native submit sends one
|
|
56
|
+
* entry per ticked checkbox, each its `value`, and a Form's `onSubmit` is
|
|
57
|
+
* handed them as an array.
|
|
58
|
+
*/
|
|
59
|
+
name?: string;
|
|
60
|
+
className?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Class names for the parts behind the root. The element holding the
|
|
63
|
+
* checkboxes is `classNames.control`; a single option is styled on the
|
|
64
|
+
* Checkbox itself.
|
|
65
|
+
*/
|
|
66
|
+
classNames?: NebaSlots<CheckboxGroupSlot>;
|
|
67
|
+
style?: React.CSSProperties;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* A set of checkboxes that answer one question, any number of them at once.
|
|
71
|
+
*
|
|
72
|
+
* A column of Checkboxes in a Fieldset already works, and this is what that
|
|
73
|
+
* column was missing: one value for the set — an array of the ticked
|
|
74
|
+
* checkboxes' `value`s, controlled or not — a label and an error that belong to
|
|
75
|
+
* the question rather than to one option, and a parent checkbox that ticks
|
|
76
|
+
* every option at once. `allValues` names every option, and the Checkbox with
|
|
77
|
+
* `parent` is the one that answers for all of them.
|
|
78
|
+
*
|
|
79
|
+
* Base UI's group owns the value and the parent's three states. What it does
|
|
80
|
+
* not carry down is how each option looks, so `size`, `color`, `disabled` and
|
|
81
|
+
* `readOnly` reach every Checkbox through `internal/checkbox-group.ts`, and so
|
|
82
|
+
* does the `name` a native submit needs.
|
|
83
|
+
*/
|
|
84
|
+
export declare const CheckboxGroup: React.ForwardRefExoticComponent<CheckboxGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as a from"react";import{CheckboxGroup as l}from"@base-ui/react/checkbox-group";import{Field as o}from"@base-ui/react/field";import{cx as i,metaTextClasses as t,optionGapClasses as n}from"../../internal/styles.js";import{spacingValue as s}from"../../internal/grid.js";import{useStyleDefaults as c}from"../../internal/defaults.js";import{useFieldsetDisabled as d}from"../../internal/fieldset.js";import{CheckboxGroupContext as m}from"../../internal/checkbox-group.js";export const CheckboxGroup=/*@__PURE__*/a.forwardRef(function CheckboxGroup(f,p){const{size:x="md",color:b="primary",orientation:u="vertical",spacing:h,label:g,description:v,error:j,invalid:N,disabled:y,readOnly:k=!1,name:z,className:w,classNames:C,style:G,children:O,...R}=c(f,["size"]),D=d(y),E=null!=j&&!1!==j&&""!==j,L=N??E,M=L?"danger":b,P=a.useMemo(()=>({size:x,color:b,invalid:L,disabled:D,readOnly:k,name:z}),[x,b,L,D,k,z]);return e(m.Provider,{value:P,children:r(o.Root,{name:z,disabled:D,invalid:L,className:i("flex flex-col gap-1.5",w??""),style:{"--n-accent":`var(--neba-${M}-accent)`,...G},children:[g?e(o.Label,{className:i(t[x],"font-medium",D?"text-(--neba-disabled-fg)":"text-(--neba-fg)",C?.label),children:g}):null,v?e(o.Description,{className:i(t[x],"text-(--neba-muted-fg)",C?.description),children:v}):null,e(l,{ref:p,disabled:D,className:i("flex","horizontal"===u?"flex-row flex-wrap":"flex-col",void 0===h?n[u][x]:"",C?.control),style:void 0===h?void 0:{gap:s(h)},...R,children:O}),e(o.Error,E?{match:!0,className:i(t[x],"text-(--n-accent)",C?.error),children:j}:{className:i(t[x],"text-(--n-accent)",C?.error)})]})})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{CheckboxGroup}from"./CheckboxGroup.js";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { NebaColor, NebaDensity, NebaElevation, NebaSize } from '../../types.js';
|
|
3
|
-
export { registerLanguage } from '../../internal/highlight.js';
|
|
4
3
|
/**
|
|
5
4
|
* Which palette the block wears.
|
|
6
5
|
*
|
|
@@ -65,7 +64,8 @@ export interface CodeBlockProps extends Omit<React.ComponentPropsWithoutRef<'div
|
|
|
65
64
|
* import, so a block that does not highlight costs no more than the text in
|
|
66
65
|
* it. On, the block draws plain on the first frame and colours itself when
|
|
67
66
|
* the grammar lands — a few milliseconds, and never a blank space where the
|
|
68
|
-
* code should be.
|
|
67
|
+
* code should be. A block off screen fetches its grammar just the same, and
|
|
68
|
+
* is coloured once it is within a screen's height of the view.
|
|
69
69
|
* @default true
|
|
70
70
|
*/
|
|
71
71
|
highlight?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{CheckIcon as o,CodeIcon as
|
|
1
|
+
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{CheckIcon as o,CodeIcon as r,CopyIcon as l}from"../../internal/icons.js";import{codeMessages as i,useMessages as a}from"../../internal/i18n.js";import{observeResize as s,observeVisibility as c}from"../../internal/observe.js";import{canonicalLanguage as d,highlight as u,plainLines as m,preloadLanguage as p}from"../../internal/highlight.js";import{cx as f,hasContent as x,metaTextClasses as h,radiusClasses as g,srOnlyClasses as y,surfaceSlots as v,toLength as b,transitionClasses as w}from"../../internal/styles.js";import{useStyleDefaults as N}from"../../internal/defaults.js";const k={xs:"text-[0.6875rem]/[1.55]",sm:"text-[0.75rem]/[1.6]",md:"text-[0.8125rem]/[1.65]",lg:"text-[0.875rem]/[1.7]",xl:"text-[1rem]/[1.7]"},S={default:{xs:"py-2",sm:"py-3",md:"py-3.5",lg:"py-4",xl:"py-5"},compact:{xs:"py-1.5",sm:"py-2",md:"py-2.5",lg:"py-3",xl:"py-3.5"}},T={default:{xs:"px-2",sm:"px-3",md:"px-3.5",lg:"px-4",xl:"px-5"},compact:{xs:"px-1.5",sm:"px-2",md:"px-2.5",lg:"px-3",xl:"px-3.5"}},M={default:{xs:"px-2.5 py-1",sm:"px-3.5 py-1",md:"px-4 py-1.5",lg:"px-4.5 py-2",xl:"px-5.5 py-2"},compact:{xs:"px-2 py-0.5",sm:"px-2.5 py-0.5",md:"px-3 py-1",lg:"px-3.5 py-1",xl:"px-4 py-1.5"}};export const CodeBlock=/*@__PURE__*/n.forwardRef(function CodeBlock(j,C){const{code:E,language:R,theme:A="dark",size:H="md",color:L="primary",density:_="default",elevation:z=0,highlight:F=!0,toolbar:K=!0,title:$,showLanguage:B=!0,copyable:D=!0,rawToggle:I=!1,highlightLines:W,lineNumbers:q=!1,startLine:G=1,prompt:J,wrap:O=!1,maxHeight:P,fontFamily:Q,fontSize:U,lineHeight:V,letterSpacing:X,locale:Y,copyLabel:Z,copiedLabel:ee,rawLabel:te,onCopy:ne,className:oe,style:re,...le}=N(j,["size","density","locale"]),ie=a(i,Y),ae=n.useMemo(()=>E.replace(/\r\n?/g,"\n").trimEnd(),[E]),se=d(R),[ce,de]=n.useState(!1),[ue,me]=n.useState(null),[pe,fe]=n.useState(null),xe=F&&!ce&&null!==se,[he,ge]=n.useState(!1);n.useEffect(()=>{if(!xe||!se)return void fe(null);if(!he)return void p(se);let e=!1;return u(ae,se).then(t=>{e||n.startTransition(()=>fe(t?{source:ae,name:se,lines:t}:null))},()=>{e||fe(null)}),()=>{e=!0}},[ae,se,xe,he]);const ye=n.useMemo(()=>xe&&pe&&pe.source===ae&&pe.name===se?pe.lines:m(ae),[xe,pe,ae,se]),ve=`${String(G+Math.max(ye.length-1,0)).length}ch`,be=n.useRef(void 0),we=n.useRef(void 0),[Ne,ke]=n.useState(null);n.useEffect(()=>()=>{clearTimeout(be.current),clearTimeout(we.current)},[]);const Se=G+Math.max(ye.length-1,0),Te=n.useMemo(()=>function(e,t,n){const o=new Set;if(void 0===e)return o;for(const r of Array.isArray(e)?e:[e])if("number"!=typeof r)for(const e of r.split(",")){const r=/^\s*(\d+)\s*(?:-\s*(\d+)\s*)?$/.exec(e);if(!r)continue;const l=Number(r[1]),i=void 0===r[2]?l:Number(r[2]),a=Math.max(Math.min(l,i),t),s=Math.min(Math.max(l,i),n);for(let e=a;e<=s;e+=1)o.add(e)}else Number.isFinite(r)&&o.add(Math.trunc(r));return o}(W,G,Se),[W,G,Se]),Me=n.useRef(null),je=n.useRef(null),[Ce,Ee]=n.useState(!1);n.useEffect(()=>{const e=je.current;if(!xe||he||!e)return;const t=c(e,0,e=>{e&&ge(!0)},"100% 0px");if(t)return t;ge(!0)},[xe,he]),n.useEffect(()=>{const e=je.current,t=Me.current;if(!e||!t)return;const n=()=>Ee(e.scrollWidth>e.clientWidth+1||e.scrollHeight>e.clientHeight+1);n();const o=s(e,n),r=s(t,n);return()=>{o(),r()}},[]);const Re=Z??ie.copy,Ae=ee??ie.copied,He=te??ie.raw,Le=f("inline-flex shrink-0 cursor-pointer items-center gap-1 border-0 bg-transparent","px-1.5 py-1 text-(--n-code-dim) hover:text-(--n-code-fg) hover:bg-(--n-code-hover)",g.xs,h[H],"[&_svg]:pointer-events-none [&_svg]:size-[1.15em] [&_svg]:shrink-0",w,"focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-1"),_e=n.useId(),ze=x($)&&"string"!=typeof $&&K,Fe="string"==typeof $&&""!==$?$:se??ie.code,Ke=e("div",{ref:je,role:Ce?"region":void 0,"aria-label":Ce&&!ze?Fe:void 0,"aria-labelledby":Ce&&ze?_e:void 0,tabIndex:Ce?0:void 0,onKeyDown:e=>{if(!("a"===e.key||"A"===e.key||!/^[a-z]$/i.test(e.key)&&"KeyA"===e.code))return;if(!e.metaKey&&!e.ctrlKey||e.altKey)return;const t=Me.current,n="undefined"==typeof window?null:window.getSelection();if(!t||!n)return;e.preventDefault();const o=document.createRange();o.selectNodeContents(t),n.removeAllRanges(),n.addRange(o)},className:f("min-h-0 overflow-auto",S[_][H],"focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:-outline-offset-2"),style:void 0===P?void 0:{maxHeight:b(P)},children:e("pre",{ref:Me,className:f("m-0 bg-transparent p-0 font-mono",O?"w-full":"w-max min-w-full"),children:ye.map((t,o)=>{const r=G+o;return e("div",{className:f("neba-code-line",T[_][H]),"data-line":q?r:void 0,"data-mark":Te.has(r)?"":void 0,"data-prompt":J&&t.length>0?J:void 0,children:e("code",{children:t.map((t,o)=>t.token?e("span",{className:t.token,children:t.text},o):e(n.Fragment,{children:t.text},o))})},o)})})});return t("div",{ref:C,className:f("neba-code flex min-w-0 flex-col overflow-hidden",g[H],"border bg-(--n-code-bg) text-(--n-code-fg) [border-color:var(--n-code-rule)]","[box-shadow:var(--n-elev)]",w,oe),"data-code-theme":A,"data-code-wrap":O?"true":void 0,style:{...v(L,z),"--n-code-gutter":ve,...Q?{fontFamily:Q}:null,...void 0===U?null:{fontSize:b(U)},...void 0===V?null:{lineHeight:V},...void 0===X?null:{letterSpacing:b(X)},...re},...le,children:[K&&(B&&se||D||I&&F||x($))?t("div",{className:f("flex min-w-0 items-center gap-1 border-b [border-color:var(--n-code-rule)]",M[_][H]),children:[x($)?e("span",{id:_e,className:f("min-w-0 truncate font-mono",h[H]),children:$}):null,B&&se?e("span",{className:f("min-w-0 truncate font-mono tracking-wide text-(--n-code-dim) uppercase select-none",h[H]),children:se}):null,e("span",{className:"flex-1"}),I&&F?e("button",{type:"button","aria-pressed":ce,"aria-label":He,title:He,onClick:()=>de(e=>!e),className:f(Le,ce?"text-(--n-code-fg) bg-(--n-code-hover)":""),children:e(r,{})}):null,D?t("button",{type:"button",onClick:async()=>{const e=await async function(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}const t=document.activeElement;try{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.setAttribute("aria-hidden","true"),t.style.cssText="position:fixed;top:0;left:0;opacity:0;pointer-events:none",document.body.append(t),t.select();const n=document.execCommand("copy");return t.remove(),n}catch{return!1}finally{t instanceof HTMLElement&&t.isConnected&&t.focus()}}(ae);clearTimeout(be.current),clearTimeout(we.current),me(e),ke(null),we.current=setTimeout(()=>ke(e),100),be.current=setTimeout(()=>{me(null),ke(null)},2e3),e&&ne?.(ae)},className:Le,children:[e(ue?o:l,{}),e("span",{children:null===ue?Re:ue?Ae:ie.copyFailed})]}):null]}):null,e("div",{className:f("flex min-h-0 flex-col",k[H]),children:Ke}),e("span",{"aria-live":"polite",className:y,children:null===Ne?"":Ne?Ae:ie.copyFailed})]})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{CodeBlock
|
|
1
|
+
export{CodeBlock}from"./CodeBlock.js";export{registerLanguage}from"../../internal/highlight.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as r from"react";import{PickerShell as l}from"../../internal/picker.js";import{CheckIcon as n}from"../../internal/icons.js";import{colorMessages as t,fillMessage as o,useMessages as s}from"../../internal/i18n.js";import{numberFormatter as i}from"../../internal/format.js";import{checkerBackground as d,clamp as c,cssColor as u,defaultSwatches as h,formatColor as f,parseColor as p,readableInk as m}from"../../internal/color.js";import{controlTextClasses as b,cx as v,focusRingClasses as g,metaTextClasses as x,radiusClasses as w,stackGapClasses as y,surfaceSlots as k,transitionClasses as C}from"../../internal/styles.js";import{useStyleDefaults as N}from"../../internal/defaults.js";import{useFieldsetDisabled as _}from"../../internal/fieldset.js";const
|
|
1
|
+
"use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as r from"react";import{PickerShell as l}from"../../internal/picker.js";import{CheckIcon as n}from"../../internal/icons.js";import{colorMessages as t,fillMessage as o,useMessages as s}from"../../internal/i18n.js";import{numberFormatter as i}from"../../internal/format.js";import{checkerBackground as d,clamp as c,cssColor as u,defaultSwatches as h,formatColor as f,parseColor as p,readableInk as m}from"../../internal/color.js";import{controlTextClasses as b,cx as v,focusRingClasses as g,metaTextClasses as x,radiusClasses as w,stackGapClasses as y,surfaceSlots as k,transitionClasses as C}from"../../internal/styles.js";import{useStyleDefaults as N}from"../../internal/defaults.js";import{useIntlLocale as j}from"../../internal/media.js";import{useFieldsetDisabled as _}from"../../internal/fieldset.js";const P={xs:"w-40",sm:"w-44",md:"w-52",lg:"w-60",xl:"w-72"},I={xs:"h-24",sm:"h-28",md:"h-32",lg:"h-40",xl:"h-48"},D={xs:"h-2.5",sm:"h-3",md:"h-3.5",lg:"h-4",xl:"h-5"},z={xs:"gap-1.5",sm:"gap-2",md:"gap-2.5",lg:"gap-3",xl:"gap-3.5"},A={xs:10,sm:12,md:14,lg:16,xl:18},T=["relative overflow-hidden border","[border-color:var(--neba-border)]","[box-shadow:var(--neba-plate-glass)]"].join(" "),L=["pointer-events-none absolute rounded-full border-2 border-white","[box-shadow:0_0_0_1px_rgba(0,0,0,0.35),0_1px_3px_rgba(0,0,0,0.4)]"].join(" ");function O(e){const a=e.currentTarget.getBoundingClientRect();return{x:0===a.width?0:c((e.clientX-a.left)/a.width,0,1),y:0===a.height?0:c((e.clientY-a.top)/a.height,0,1)}}function ColorPanel({hsv:r,alphaValue:l,onChange:t,text:s,onTextChange:h,withAlpha:b,swatches:y,editable:k,size:N,inert:_,disabled:V,labels:q,locale:S}){const B=j(S),E=A[N],K=i(B,{style:"percent",maximumFractionDigits:0}),M=i(B,{style:"unit",unit:"degree",unitDisplay:"long",maximumFractionDigits:0}),R=-E/2,U=u({h:r.h,s:100,v:100}),F=u(r),$=e=>({onPointerDown:a=>{_||(a.currentTarget.setPointerCapture(a.pointerId),e(a))},onPointerMove:a=>{!_&&a.currentTarget.hasPointerCapture(a.pointerId)&&e(a)}}),H=(e,a,r,l,n,t,o)=>({role:"slider",tabIndex:_?-1:0,"aria-label":e,"aria-valuemin":0,"aria-valuemax":l,"aria-valuenow":Math.round(r),"aria-valuetext":a,"aria-orientation":"horizontal","aria-disabled":_||void 0,onKeyDown:e=>{const a=function(e,a,r,l,n){const t=(e.shiftKey?10:1)*l;let o;switch(e.key){case"ArrowRight":case"ArrowUp":o=a+t;break;case"ArrowLeft":case"ArrowDown":o=a-t;break;case"PageUp":o=a+10*l;break;case"PageDown":o=a-10*l;break;case"Home":return 0;case"End":return r;default:return null}return n?(o%r+r)%r:c(o,0,r)}(e,r,l,n,t);_||null===a||(e.preventDefault(),o(a))}});return a("div",{className:v("flex flex-col",P[N],z[N]),children:[e("div",{...$(e=>{const{x:a,y:n}=O(e);t({hsv:{h:r.h,s:100*a,v:100*(1-n)},alpha:l})}),role:"slider",tabIndex:_?-1:0,"aria-label":q.area,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(r.s),"aria-valuetext":o(q.areaValue,{saturation:K.format(r.s/100),brightness:K.format(r.v/100)}),"aria-disabled":_||void 0,onKeyDown:e=>{const a=function(e,a,r){const l=e.shiftKey?10:1;switch(e.key){case"ArrowLeft":return{s:a-l,v:r};case"ArrowRight":return{s:a+l,v:r};case"ArrowUp":return{s:a,v:r+l};case"ArrowDown":return{s:a,v:r-l};case"PageUp":return{s:a,v:r+10};case"PageDown":return{s:a,v:r-10};case"Home":return{s:0,v:r};case"End":return{s:100,v:r};default:return null}}(e,r.s,r.v);!_&&a&&(e.preventDefault(),t({hsv:{h:r.h,s:c(a.s,0,100),v:c(a.v,0,100)},alpha:l}))},className:v(T,I[N],w[N],g,_?"cursor-default":"cursor-crosshair touch-none"),style:{backgroundColor:U,backgroundImage:"linear-gradient(to top, #000000, rgba(0, 0, 0, 0)), linear-gradient(to right, #ffffff, rgba(255, 255, 255, 0))"},children:e("span",{className:L,style:{width:E,height:E,left:`${r.s}%`,top:100-r.v+"%",marginLeft:R,marginTop:R,backgroundColor:F}})}),e("div",{...$(e=>t({hsv:{...r,h:360*O(e).x},alpha:l})),...H(q.hue,M.format(r.h),r.h,360,2,!0,e=>t({hsv:{...r,h:e},alpha:l})),className:v(T,D[N],"rounded-full",g,_?"cursor-default":"cursor-pointer touch-none"),style:{backgroundImage:"linear-gradient(to right, #ff0000 0%, #ffff00 16.66%, #00ff00 33.33%, #00ffff 50%, #0000ff 66.66%, #ff00ff 83.33%, #ff0000 100%)"},children:e("span",{className:L,style:{width:E,height:E,left:r.h/360*100+"%",top:"50%",marginLeft:R,marginTop:R,backgroundColor:U}})}),b?a("div",{...$(e=>t({hsv:r,alpha:O(e).x})),...H(q.alpha,K.format(l),100*l,100,1,!1,e=>t({hsv:r,alpha:e/100})),className:v(T,D[N],"rounded-full",g,_?"cursor-default":"cursor-pointer touch-none"),style:d,children:[e("span",{"aria-hidden":"true",className:"absolute inset-0",style:{backgroundImage:`linear-gradient(to right, ${u(r,0)}, ${F})`}}),e("span",{className:L,style:{width:E,height:E,left:100*l+"%",top:"50%",marginLeft:R,marginTop:R,backgroundColor:u(r,l)}})]}):null,k?a("div",{className:v("flex items-center",z[N]),children:[e("span",{"aria-hidden":"true",className:v("shrink-0 rounded-full border","[border-color:var(--neba-border)]"),style:{width:E+6,height:E+6,...d},children:e("span",{className:"block size-full rounded-full",style:{backgroundColor:u(r,l)}})}),e("input",{type:"text",value:s,readOnly:_,disabled:V,spellCheck:!1,autoComplete:"off","aria-label":q.value,onChange:e=>h(e.target.value),className:v("neba-input min-w-0 flex-1 border bg-transparent px-1.5 py-1 font-mono lowercase","[border-color:var(--neba-border)]",w.xs,x[N],"text-(--neba-fg)",C,"focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-1")})]}):null,y&&y.length>0?e("div",{role:"group","aria-label":q.swatches,className:"grid grid-cols-8 gap-1",children:y.map(a=>{const o=p(a),s=null!==o&&f(o.hsv,o.alpha,"hex")===f(r,l,"hex");return e("button",{type:"button",disabled:_,"aria-label":a,"aria-pressed":s,onClick:()=>{o&&t(o)},className:v("flex aspect-square items-center justify-center rounded-full border","[border-color:color-mix(in_oklab,var(--neba-fg)_18%,transparent)]","[transition:box-shadow_var(--neba-duration)_var(--neba-ease)]",g,_?"cursor-default":"cursor-pointer hover:[box-shadow:var(--neba-shadow-1)]","[&_svg]:size-3"),style:{backgroundColor:a},children:s&&o?e("span",{style:{color:m(o.hsv)},children:e(n,{})}):null},a)})}):null]})}function V(e,a){return"hex"===e?[a?"#ffffffff":"#ffffff"]:"rgb"===e?[a?"rgba(255, 255, 255, 0.55)":"rgb(255, 255, 255)"]:[a?"hsla(360, 100%, 100%, 0.55)":"hsl(360, 100%, 100%)"]}const q={h:217,s:87,v:82};export const ColorPicker=/*@__PURE__*/r.forwardRef(function ColorPicker(n,o){const{value:i,defaultValue:c="#1a58d1",onValueChange:m,format:g="hex",alpha:w=!1,swatches:C=h,inline:j=!1,editable:P=!0,label:I,labelPlacement:D,description:z,error:A,invalid:T,required:L=!1,disabled:O,readOnly:S=!1,fullWidth:B=!1,clearable:E=!1,name:K,open:M,defaultOpen:R=!1,onOpenChange:U,locale:F,labels:$,variant:H="outline",size:W="md",color:X="primary",density:Y="default",elevation:G=0,className:J,style:Q,...Z}=N(n,["size","density","variant","locale","labelPlacement"]),ee=_(O),ae=s(t,F),re=r.useMemo(()=>({...ae,...$}),[ae,$]),[le,ne]=r.useState(c),te=i??le,[oe,se]=r.useState(R),ie=M??oe,[de,ce]=r.useState(()=>p(te)??{hsv:q,alpha:1}),[ue,he]=r.useState(()=>te||""),fe=f(de.hsv,w?de.alpha:1,g),pe=""===te;r.useEffect(()=>{const e=p(te);e?f(e.hsv,w?e.alpha:1,g)!==fe&&(he(te),ce(e)):he(te)},[te,fe,w,g]);const me=(e,a)=>{ce(e);const r=f(e.hsv,w?e.alpha:1,g);he(a??r),void 0===i&&ne(r),m?.(r)},be=ee||S,ve=r.useId(),ge=r.useId(),xe=r.useId(),we=e(ColorPanel,{hsv:de.hsv,alphaValue:de.alpha,onChange:me,text:ue,onTextChange:e=>{he(e);const a=p(e);a&&me(a,e)},withAlpha:w,swatches:C,editable:P,size:W,inert:be,disabled:Boolean(ee),labels:re,locale:F}),ye=K?e("input",{type:"hidden",name:K,value:pe?"":fe,disabled:ee}):null,ke=L&&!be?e("input",{"aria-hidden":"true",tabIndex:-1,required:!0,value:pe?"":"chosen",onChange:()=>{},onInvalid:e=>e.currentTarget.parentElement?.querySelector('[role="slider"]')?.focus(),className:"pointer-events-none absolute start-0 bottom-0 size-px overflow-hidden opacity-0 [clip-path:inset(50%)]"}):null;if(j){const r=T??Boolean(A)?"danger":X,l=[z?ge:"",A?xe:""].filter(Boolean).join(" ");return a("div",{ref:o,role:"group","aria-labelledby":I?ve:void 0,"aria-describedby":l||void 0,className:v("relative flex flex-col",y[W],J),style:{...k(r,G),...Q},...Z,children:[I?e("span",{id:ve,className:v(x[W],"font-medium",ee?"text-(--neba-disabled-fg)":"text-(--neba-fg)"),children:I}):null,we,z?e("span",{id:ge,className:v(x[W],"text-(--neba-muted-fg)"),children:z}):null,A?e("span",{id:xe,className:v(x[W],"text-(--n-accent)"),children:A}):null,ye,ke]})}return e("div",{ref:o,className:B?"w-full":"inline-block",...Z,children:e(l,{variant:H,size:W,color:X,density:Y,elevation:G,style:Q,label:I,labelPlacement:D,description:z,error:A,invalid:T,required:L,disabled:ee,readOnly:S,fullWidth:B,className:J,startIcon:e("span",{"aria-hidden":"true",className:v("block size-[1.15em] shrink-0 rounded-full border","[border-color:color-mix(in_oklab,var(--neba-fg)_18%,transparent)]"),style:d,children:e("span",{className:"block size-full rounded-full",style:{backgroundColor:pe?"transparent":u(de.hsv,w?de.alpha:1)}})}),display:pe?re.empty:fe,samples:V(g,w),empty:pe,clearable:E,onClear:()=>{void 0===i&&ne(""),he(""),m?.("")},open:ie,onOpenChange:e=>{void 0===M&&se(e),U?.(e)},clearLabel:re.clear,initialFocus:!0,hiddenValues:K?[{name:K,value:pe?"":fe}]:void 0,children:e("div",{className:b[W],children:we})})})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as a from"react";import{Combobox as t}from"@base-ui/react/combobox";import{Field as n}from"@base-ui/react/field";import{Chip as
|
|
1
|
+
"use client";import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as a from"react";import{Combobox as t}from"@base-ui/react/combobox";import{Field as n}from"@base-ui/react/field";import{Chip as r}from"../chip/Chip.js";import{actionMessages as i,comboboxMessages as o,fillMessage as s,useMessages as c}from"../../internal/i18n.js";import{CheckIcon as d,ChevronIcon as m,CloseIcon as u,PlusIcon as p}from"../../internal/icons.js";import{keyHandler as b}from"../../internal/keys.js";import{FieldNotch as h,NotchFrame as f,restEndOf as g}from"../../internal/notch.js";import{chipRemoveClasses as v,controlTextLeadingClasses as x,cx as y,disabledClasses as N,fieldFocusTransitionClasses as w,fieldHeightClasses as j,fieldReadOnlyClasses as C,fieldRestClasses as L,fieldRingClasses as S,fieldSheetClasses as I,fieldSheetDisabledClasses as z,fieldSheetReadOnlyClasses as $,gapClasses as O,hasContent as V,iconClasses as _,metaTextClasses as M,paddingXClasses as k,popupFadeClasses as P,radiusClasses as A,readOnlyFilterClasses as E,stackGapClasses as F,surfaceClasses as R,surfaceSlots as T,transitionClasses as q}from"../../internal/styles.js";import{useStyleDefaults as B}from"../../internal/defaults.js";import{fieldLight as D,fieldSpotlightSlot as G,glowClasses as H}from"../../internal/glow.js";import{useFieldsetDisabled as K}from"../../internal/fieldset.js";const W=["group relative flex w-full cursor-text items-center","[-webkit-tap-highlight-color:transparent]",q,w,_].join(" "),J={xs:"min-h-5.5 py-0",sm:"min-h-6.5 py-[2px]",md:"min-h-8 py-[3px]",lg:"min-h-10 py-[4px]",xl:"min-h-12 py-[4px]"},Q=[R,"max-h-[min(20rem,var(--available-height))] overflow-y-auto overscroll-contain","w-[var(--anchor-width)] border bg-(--n-panel-press) p-1","[border-color:var(--n-line)]","[box-shadow:var(--neba-shadow-3),var(--neba-plate-glass)]","[outline:none]",P].join(" "),U=["relative flex cursor-pointer items-center gap-2 select-none","rounded-(--neba-radius-xs) py-1.5 pe-2 ps-7",q,"data-[highlighted]:bg-(--n-soft-hover) data-[highlighted]:text-(--n-on-tint)","data-[selected]:text-(--n-on-tint) data-[selected]:font-medium","data-[disabled]:cursor-not-allowed data-[disabled]:text-(--neba-disabled-fg)","[outline:none]"].join(" "),X=["inline-flex h-[1lh] shrink-0 cursor-pointer items-center justify-center","rounded-(--neba-radius-xs) text-(--neba-muted-fg)","[transition:color_var(--neba-duration)_var(--neba-ease)]","hover:text-(--n-accent)","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-1","disabled:cursor-not-allowed disabled:text-(--neba-disabled-fg)"].join(" ");function Y(e){return null==e?[]:Array.isArray(e)?e.slice():[e]}export function Combobox(w){const{variant:_="outline",size:P="md",color:R="primary",density:q="default",elevation:Z=0,items:ee,multiple:le,value:ae,defaultValue:te,onValueChange:ne,filter:re,onInputValueChange:ie,allowCustom:oe=!0,customLabel:se,clearable:ce=!1,locale:de,emptyMessage:me,limit:ue,placeholder:pe,label:be,labelPlacement:he="top",description:fe,error:ge,invalid:ve,startIcon:xe,fullWidth:ye=!1,disabled:Ne,readOnly:we=!1,required:je=!1,name:Ce,open:Le,defaultOpen:Se,onOpenChange:Ie,clearLabel:ze,openLabel:$e,removeLabel:Oe,inputRef:Ve,shortcuts:_e,id:Me,className:ke,classNames:Pe,style:Ae,"aria-label":Ee,"aria-labelledby":Fe,...Re}=B(w,["size","density","variant","locale","labelPlacement"]),Te=K(Ne),qe=!Te&&!we,Be=c(o,de),De=c(i,de),Ge=Oe??(e=>s(Be.remove,{label:e})),He=V(ge),Ke=ve??He,We=Ke?"danger":R,Je=!0===le,Qe=a.useMemo(()=>ee.map(e=>({value:e.value,label:e.label??String(e.value),disabled:e.disabled})),[ee]),[Ue,Xe]=a.useState(()=>Y(te)),Ye=void 0===ae?Ue:Y(ae),[Ze,el]=a.useState(""),ll=a.useMemo(()=>new Map(Qe.map(e=>[e.value,e])),[Qe]),al=a.useCallback(e=>ll.get(e)??{value:e,label:String(e),custom:!0},[ll]),tl=oe&&!we&&!Te,nl=a.useMemo(()=>{if(!tl)return null;const e=new Set;for(const l of Qe)e.add(l.label.toLocaleLowerCase()),e.add(String(l.value).toLocaleLowerCase());return e},[tl,Qe]),rl=Ze.trim();let il=null;if(nl&&""!==rl){const e=rl.toLocaleLowerCase();nl.has(e)||Ye.some(l=>String(l).toLocaleLowerCase()===e)||(il=rl)}const ol=t.useFilter({locale:de}),sl=null!==il&&void 0!==ue&&ue>-1,cl=a.useMemo(()=>{if(null===il)return Qe;const e={value:il,label:il,custom:!0};if(!sl)return[...Qe,e];return[...(!1===re?Qe:Qe.filter(e=>re?re(e,il):ol.contains(e.label,il))).slice(0,ue),e]},[Qe,il,sl,re,ol,ue]),dl=Je?Ye.map(al):Ye.length>0?al(Ye[0]):null;const ml=k[q][P],ul="top"!==he&&V(be),pl=ul&&"float"===he&&!V(xe),bl=[W,x[P],A[P],O[P],Je?J[P]:j[P],`${ml} pe-1.5`,ul?"":S,Te?(ul?z:N)[_]:we?ul?`${$[_]} ${E}`:C[_]:`${(ul?I:L)[_]} ${H}`,Pe?.shell].filter(Boolean).join(" "),hl=["neba-input min-w-0 flex-1 self-stretch 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",pl?"neba-float-control":"",Pe?.control].filter(Boolean).join(" "),fl=l=>e(t.Input,{ref:Ve,"aria-label":Ee,"aria-labelledby":Fe,onKeyDown:b(_e),placeholder:pl?pe||" ":pe,className:Je?`${hl} min-w-16 ${l?"ms-1.5":""}`:hl}),gl=l(t.InputGroup,{className:bl,...D(qe),children:[xe?e("span",{className:"flex h-[1lh] shrink-0 items-center text-(--neba-muted-fg)",children:xe}):null,Je?e(t.Chips,{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:e(t.Value,{children:n=>l(a.Fragment,{children:[n.map(l=>e(t.Chip,{render:e(r,{variant:"outline",size:P,color:We,density:"compact",disabled:Te,className:Pe?.chip,endIcon:we||Te?null:e(t.ChipRemove,{"aria-label":Ge(l.label),className:v,children:e(u,{})})}),children:l.label},String(l.value))),fl(n.length>0)]})})}):fl(!1),ce&&!we?e(t.Clear,{"aria-label":ze??De.clear,className:X,children:e(u,{})}):null,e(t.Trigger,{"aria-label":"string"==typeof be?void 0:$e??Be.open,className:X,children:e(t.Icon,{className:["flex items-center","[transition:rotate_var(--neba-duration)_var(--neba-ease)]","data-[popup-open]:rotate-180"].join(" "),children:e(m,{})})}),ul?e(h,{label:be,variant:_,disabled:Te,readOnly:we,rests:pl,empty:Je?0===Ye.length&&""===Ze:void 0,labelClassName:Pe?.label}):null]});return l(n.Root,{disabled:Te,invalid:Ke,className:y("flex-col align-top",F[P],ye?"flex w-full":"inline-flex",ke??""),style:{...T(We,Z),...qe?G:void 0,...Ae},...Re,children:[be&&!ul?e(n.Label,{className:y(M[P],"font-medium",Te?"text-(--neba-disabled-fg)":"text-(--neba-fg)",Pe?.label),children:be}):null,l(t.Root,{id:Me,name:Ce,items:cl,multiple:Je,value:dl,onValueChange:e=>{!function(e){void 0===ae&&Xe(e),ne?.(Je?e:e[0]??null)}((null===e?[]:Array.isArray(e)?e:[e]).map(e=>e.value))},onInputValueChange:e=>{el(e),ie?.(e)},open:Le,defaultOpen:Se,onOpenChange:e=>Ie?.(e),autoHighlight:!0,itemToStringLabel:e=>e.label,itemToStringValue:e=>String(e.value),isItemEqualToValue:(e,l)=>e.value===l.value,limit:sl?-1:ue,filter:sl||!1===re?null:re?(e,l)=>!0===e.custom||re(e,l):void 0,disabled:Te,readOnly:we,required:je,children:[ul?e(f,{label:be,size:P,density:q,variant:_,rests:pl,restEnd:g(P,ce&&!we?[1.2,1.2]:[1.2]),labelClassName:Pe?.label,children:gl}):gl,e(t.Portal,{children:e(t.Positioner,{className:"neba-portal z-(--neba-z-portal) [outline:none]",sideOffset:6,children:l(t.Popup,{className:y(Q,A[P],x[P],Pe?.popup),style:T(We,3),children:[e(t.Empty,{className:"px-2 py-1.5 text-(--neba-muted-fg) empty:hidden",children:me??Be.empty}),e(t.List,{children:n=>e(t.Item,{value:n,disabled:n.disabled,className:y(U,Pe?.item),children:n.custom?l(a.Fragment,{children:[e("span",{className:"absolute start-1.5 flex size-4 items-center justify-center text-(--n-accent) [&_svg]:size-4",children:e(p,{})}),e("span",{className:"truncate",children:se?se(n.label):s(Be.add,{label:n.label})})]}):l(a.Fragment,{children:[e(t.ItemIndicator,{className:"absolute start-1.5 flex size-4 items-center justify-center",children:e(d,{})}),e("span",{className:"truncate",children:n.label})]})},`${n.custom?"custom:":""}${String(n.value)}`)})]})})})]}),fe?e(n.Description,{className:y(M[P],"text-(--neba-muted-fg)",Pe?.description),children:fe}):null,e(n.Error,He?{match:!0,className:y(M[P],"text-(--n-accent)",Pe?.error),children:ge}:{className:y(M[P],"text-(--n-accent)",Pe?.error)})]})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as s from"react";import{Meter as r}from"@base-ui/react/meter";import{contextMessages as t,fillMessage as l,useMessages as n}from"../../internal/i18n.js";import{numberFormatter as i}from"../../internal/format.js";import{progressFraction as o,progressSlots as
|
|
1
|
+
"use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as s from"react";import{Meter as r}from"@base-ui/react/meter";import{contextMessages as t,fillMessage as l,useMessages as n}from"../../internal/i18n.js";import{numberFormatter as i}from"../../internal/format.js";import{progressFraction as o,progressSlots as m,thresholdColor as c}from"../../internal/progress.js";import{cx as d,gapClasses as f,hasContent as u,metaTextClasses as x,sheetTitleClasses as h,stackGapClasses as p}from"../../internal/styles.js";import{useStyleDefaults as b}from"../../internal/defaults.js";import{useIntlLocale as k}from"../../internal/media.js";const g=[{key:"input",slot:1},{key:"output",slot:2},{key:"reasoning",slot:3},{key:"cached",slot:4}],y={xs:26,sm:30,md:36,lg:44,xl:54},N={xs:3,sm:3.5,md:4,lg:5,xl:6},v={xs:"size-1.5",sm:"size-2",md:"size-2",lg:"size-2.5",xl:"size-3"};export const ContextWindow=/*@__PURE__*/s.forwardRef(function ContextWindow(s,w){const{max:j,used:z,tokens:$,cost:D,currency:W="USD",thresholds:_,label:C,breakdown:L=!0,size:M="md",color:R="primary",locale:V,labels:A,classNames:B,className:F,style:I,children:P,...S}=b(s,["size","locale"]),T=n(t,V),U=k(V),q={...T,...A},E=g.filter(({key:e})=>"number"==typeof $?.[e]),G=z??E.reduce((e,{key:a})=>"cached"===a?e:e+($?.[a]??0),0),H=o(G,0,j),J=c(G,R,_),K=i(U,{notation:"compact",maximumFractionDigits:1}),O=i(U,{style:"currency",currency:W}),Q=l(q.usage,{used:K.format(G),max:K.format(j)}),X=y[M],Y=X/2,Z=N[M],ee=Y-Z/2,ae=2*Math.PI*ee;return a("div",{ref:w,className:d("flex w-full flex-col",p[M],F??""),style:{...m(J),...I},...S,children:[a("div",{className:d("flex items-center",f[M]),children:[a(r.Root,{value:G,min:0,max:j,getAriaValueText:()=>Q,className:d("flex min-w-0 flex-1 items-center",f[M]),children:[a("svg",{className:d("shrink-0",B?.ring??""),width:X,height:X,viewBox:`0 0 ${X} ${X}`,fill:"none","aria-hidden":"true",children:[e("circle",{cx:Y,cy:Y,r:ee,stroke:"var(--n-soft)",strokeWidth:Z}),e("circle",{cx:Y,cy:Y,r:ee,stroke:"var(--n-fill)",strokeWidth:Z,strokeLinecap:"round",strokeDasharray:ae,strokeDashoffset:ae*(1-(H??0)),transform:`rotate(-90 ${Y} ${Y})`,className:"[transition:stroke-dashoffset_var(--neba-duration-fill)_var(--neba-ease),stroke_var(--neba-duration)_var(--neba-ease)]"})]}),a("div",{className:d("flex min-w-0 flex-1 flex-col",B?.label??""),children:[e(r.Label,{className:d("min-w-0 truncate font-medium text-(--neba-fg)",x[M]),children:u(C)?C:q.label}),e(r.Value,{className:d("min-w-0 truncate tabular-nums text-(--neba-fg)",h[M]),children:()=>Q})]})]}),"number"==typeof D?a("div",{className:"flex shrink-0 flex-col items-end",children:[e("span",{className:d("text-(--neba-muted-fg)",x[M]),children:q.cost}),e("span",{className:d("tabular-nums text-(--neba-fg)",h[M]),children:O.format(D)})]}):null]}),L&&E.length>0?e("ul",{className:d("m-0 flex list-none flex-wrap gap-x-4 gap-y-1 p-0",x[M],B?.breakdown??""),children:E.map(({key:s,slot:r})=>a("li",{className:"flex items-center gap-1.5",children:[e("span",{"aria-hidden":"true",className:d("shrink-0 rounded-[2px]",v[M]),style:{background:`var(--neba-chart-${r})`}}),e("span",{className:"text-(--neba-muted-fg)",children:q[s]}),e("span",{className:"tabular-nums text-(--neba-fg)",children:K.format($?.[s]??0)})]},s))}):null,P]})});
|
|
@@ -215,7 +215,9 @@ export interface DataTableProps<Row> extends NebaStyleProps, Omit<React.Componen
|
|
|
215
215
|
/**
|
|
216
216
|
* Leaves the rows that are off screen out of the DOM. Needs a `height` or a
|
|
217
217
|
* `maxHeight` to have anything to measure against; without one every row is
|
|
218
|
-
* rendered whatever this says.
|
|
218
|
+
* rendered whatever this says, and so is every row of a grouped table. A
|
|
219
|
+
* development build says so in the console when either draws more than 500
|
|
220
|
+
* rows; `false` says that every row is meant to be drawn.
|
|
219
221
|
* @default true
|
|
220
222
|
*/
|
|
221
223
|
virtual?: boolean;
|
|
@@ -313,6 +315,16 @@ export interface DataTableProps<Row> extends NebaStyleProps, Omit<React.Componen
|
|
|
313
315
|
/** @default 1 */
|
|
314
316
|
defaultPage?: number;
|
|
315
317
|
onPageChange?: (page: number) => void;
|
|
318
|
+
/**
|
|
319
|
+
* The address of a page, which turns the footer's page numbers into real
|
|
320
|
+
* links — the same prop on Pagination, handed through.
|
|
321
|
+
*
|
|
322
|
+
* Without it the pages are buttons, and a crawler cannot press one, so the
|
|
323
|
+
* rows past the first page are out of its reach. A press on a link still
|
|
324
|
+
* moves the table without leaving the page; a press with a modifier key is
|
|
325
|
+
* left to the browser, which opens the address.
|
|
326
|
+
*/
|
|
327
|
+
getPageHref?: (page: number) => string;
|
|
316
328
|
/** How many rows a page holds. Use with `onPageSizeChange`. */
|
|
317
329
|
pageSize?: number;
|
|
318
330
|
/** @default 25 */
|