plass-ui 1.5.0 → 1.7.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/CHANGELOG.md +336 -0
- package/README.md +29 -7
- package/dist/components/accordion/PlAccordion.d.ts +13 -0
- package/dist/components/accordion/PlAccordion.js +1 -1
- package/dist/components/accordion/index.d.ts +1 -1
- package/dist/components/alert/PlAlert.js +1 -1
- package/dist/components/animate-counter/PlAnimateCounter.js +1 -1
- package/dist/components/animate-float/PlAnimateFloat.js +1 -1
- package/dist/components/animate-headline/PlAnimateHeadline.d.ts +10 -1
- package/dist/components/animate-marquee/PlAnimateMarquee.d.ts +11 -1
- package/dist/components/animate-marquee/PlAnimateMarquee.js +1 -1
- package/dist/components/animate-scramble/PlAnimateScramble.js +1 -1
- package/dist/components/animate-split/PlAnimateSplit.js +1 -1
- package/dist/components/animate-typing/PlAnimateTyping.js +1 -1
- package/dist/components/app-logo/PlAppLogo.js +1 -1
- package/dist/components/area-chart/PlAreaChart.d.ts +35 -6
- package/dist/components/area-chart/PlAreaChart.js +1 -1
- package/dist/components/aspect-ratio/PlAspectRatio.js +1 -1
- package/dist/components/avatar/PlAvatar.js +1 -1
- package/dist/components/back-top/PlBackTop.d.ts +6 -0
- package/dist/components/back-top/PlBackTop.js +1 -1
- package/dist/components/badge/PlBadge.js +1 -1
- package/dist/components/bar-chart/PlBarChart.d.ts +54 -2
- package/dist/components/bar-chart/PlBarChart.js +1 -1
- package/dist/components/blockquote/PlBlockquote.d.ts +2 -2
- package/dist/components/blockquote/PlBlockquote.js +1 -1
- package/dist/components/bottom-navigation/PlBottomNavigation.js +1 -1
- package/dist/components/breadcrumb/PlBreadcrumb.js +1 -1
- package/dist/components/button/PlButton.d.ts +7 -0
- package/dist/components/button/PlButton.js +1 -1
- package/dist/components/calendar/PlCalendar.js +1 -1
- package/dist/components/card/PlCard.d.ts +7 -4
- package/dist/components/carousel/PlCarousel.d.ts +14 -4
- package/dist/components/carousel/PlCarousel.js +1 -1
- package/dist/components/chat-bubble/PlChatBubble.js +1 -1
- package/dist/components/checkbox/PlCheckbox.js +1 -1
- package/dist/components/chip/PlChip.d.ts +2 -1
- package/dist/components/chip/PlChip.js +1 -1
- package/dist/components/collapsible/PlCollapsible.d.ts +11 -0
- package/dist/components/collapsible/PlCollapsible.js +1 -1
- package/dist/components/color-picker/PlColorPicker.d.ts +21 -2
- package/dist/components/color-picker/PlColorPicker.js +1 -1
- package/dist/components/combobox/PlCombobox.d.ts +18 -6
- package/dist/components/combobox/PlCombobox.js +1 -1
- package/dist/components/command-palette/PlCommandPalette.js +1 -1
- package/dist/components/confirm/PlConfirmProvider.js +1 -1
- package/dist/components/data-table/PlDataTable.d.ts +13 -2
- package/dist/components/data-table/PlDataTable.js +1 -1
- package/dist/components/date-picker/PlDatePicker.js +1 -1
- package/dist/components/date-range-picker/PlDateRangePicker.js +1 -1
- package/dist/components/drawer/PlDrawer.js +1 -1
- package/dist/components/empty/PlEmpty.js +1 -1
- package/dist/components/fieldset/PlFieldset.js +1 -1
- package/dist/components/file-picker/PlFilePicker.d.ts +20 -2
- package/dist/components/file-picker/PlFilePicker.js +1 -1
- package/dist/components/floating-action-button/PlFloatingActionButton.d.ts +5 -0
- package/dist/components/floating-action-button/PlFloatingActionButton.js +1 -1
- package/dist/components/floating-bottom-navigation/PlFloatingBottomNavigation.js +1 -1
- package/dist/components/footer/PlFooter.d.ts +3 -1
- package/dist/components/gallery/PlGallery.js +1 -1
- package/dist/components/gauge-chart/PlGaugeChart.js +1 -1
- package/dist/components/header/PlHeader.d.ts +4 -2
- package/dist/components/header/PlHeader.js +1 -1
- package/dist/components/heatmap-chart/PlHeatmapChart.js +1 -1
- package/dist/components/highlight/PlHighlight.d.ts +10 -3
- package/dist/components/hover-card/PlHoverCard.js +1 -1
- package/dist/components/how-to-steps/PlHowToSteps.js +1 -1
- package/dist/components/image/PlImage.js +1 -1
- package/dist/components/line-chart/PlLineChart.d.ts +32 -6
- package/dist/components/line-chart/PlLineChart.js +1 -1
- package/dist/components/list/PlList.js +1 -1
- package/dist/components/menu/PlMenu.js +1 -1
- package/dist/components/mockup/PlMockup.d.ts +5 -0
- package/dist/components/mockup/PlMockup.js +1 -1
- package/dist/components/modal/PlModal.js +1 -1
- package/dist/components/navigation-menu/PlNavigationMenu.d.ts +4 -3
- package/dist/components/navigation-menu/PlNavigationMenu.js +1 -1
- package/dist/components/number-field/PlNumberField.d.ts +14 -4
- package/dist/components/number-field/PlNumberField.js +1 -1
- package/dist/components/otp-field/PlOtpField.d.ts +9 -1
- package/dist/components/otp-field/PlOtpField.js +1 -1
- package/dist/components/overlay/PlOverlay.js +1 -1
- package/dist/components/page-layout/PlPageLayout.d.ts +14 -3
- package/dist/components/page-layout/PlPageLayout.js +1 -1
- package/dist/components/pagination/PlPagination.js +1 -1
- package/dist/components/panes/PlPanes.js +1 -1
- package/dist/components/pie-chart/PlPieChart.d.ts +26 -1
- package/dist/components/pie-chart/PlPieChart.js +1 -1
- package/dist/components/pill/PlPill.js +1 -1
- package/dist/components/popconfirm/PlPopconfirm.d.ts +8 -1
- package/dist/components/popconfirm/PlPopconfirm.js +1 -1
- package/dist/components/popover/PlPopover.js +1 -1
- package/dist/components/progress-box/PlProgressBox.js +1 -1
- package/dist/components/progress-circular/PlProgressCircular.js +1 -1
- package/dist/components/progress-linear/PlProgressLinear.js +1 -1
- package/dist/components/radio-group/PlRadioGroup.js +1 -1
- package/dist/components/rating/PlRating.js +1 -1
- package/dist/components/scatter-chart/PlScatterChart.js +1 -1
- package/dist/components/scroll-area/PlScrollArea.js +1 -1
- package/dist/components/segmented-button/PlSegmentedButton.js +1 -1
- package/dist/components/select/PlSelect.d.ts +11 -2
- package/dist/components/select/PlSelect.js +1 -1
- package/dist/components/sidebar/PlSidebar.js +1 -1
- package/dist/components/slider/PlSlider.js +1 -1
- package/dist/components/sparkline/PlSparkline.js +1 -1
- package/dist/components/stepper/PlStepper.js +1 -1
- package/dist/components/switch/PlSwitch.js +1 -1
- package/dist/components/table/PlTable.d.ts +11 -1
- package/dist/components/table/PlTable.js +1 -1
- package/dist/components/tabs/PlTabs.d.ts +18 -1
- package/dist/components/tabs/PlTabs.js +1 -1
- package/dist/components/text-field/PlTextField.d.ts +13 -5
- package/dist/components/text-field/PlTextField.js +1 -1
- package/dist/components/text-link/PlTextLink.js +1 -1
- package/dist/components/timeline/PlTimeline.js +1 -1
- package/dist/components/timeline-chart/PlTimelineChart.js +1 -1
- package/dist/components/toast/PlToast.js +1 -1
- package/dist/components/toggle/PlToggle.js +1 -1
- package/dist/components/tooltip/PlTooltip.d.ts +4 -0
- package/dist/components/tooltip/PlTooltip.js +1 -1
- package/dist/components/tour/PlTour.js +1 -1
- package/dist/components/transfer/PlTransfer.d.ts +5 -2
- package/dist/components/transfer/PlTransfer.js +1 -1
- package/dist/components/tree/PlTree.js +1 -1
- package/dist/components/tree-select/PlTreeSelect.js +1 -1
- package/dist/components/typography/PlTypography.js +1 -1
- package/dist/components/window-pane/PlWindowPane.d.ts +16 -6
- package/dist/components/window-pane/PlWindowPane.js +1 -1
- package/dist/internal/animate.d.ts +0 -25
- package/dist/internal/animate.js +1 -1
- package/dist/internal/bottom-bar.d.ts +29 -0
- package/dist/internal/bottom-bar.js +1 -0
- package/dist/internal/calendar.js +1 -1
- package/dist/internal/chart-frame.d.ts +90 -27
- package/dist/internal/chart-frame.js +1 -1
- package/dist/internal/chart-line.d.ts +11 -6
- package/dist/internal/chart-line.js +1 -1
- package/dist/internal/chart.d.ts +158 -1
- package/dist/internal/chart.js +1 -1
- package/dist/internal/defaults.d.ts +14 -1
- package/dist/internal/focusable.d.ts +10 -0
- package/dist/internal/focusable.js +1 -1
- package/dist/internal/form.d.ts +29 -0
- package/dist/internal/form.js +1 -1
- package/dist/internal/glow.d.ts +47 -1
- package/dist/internal/glow.js +1 -1
- package/dist/internal/icons.d.ts +24 -0
- package/dist/internal/icons.js +1 -1
- package/dist/internal/labels.d.ts +35 -0
- package/dist/internal/labels.js +1 -1
- package/dist/internal/loading.d.ts +13 -0
- package/dist/internal/loading.js +1 -0
- package/dist/internal/mockup.js +1 -1
- package/dist/internal/notch.d.ts +137 -0
- package/dist/internal/notch.js +1 -0
- package/dist/internal/picker.d.ts +15 -3
- package/dist/internal/picker.js +1 -1
- package/dist/internal/progress.d.ts +17 -6
- package/dist/internal/progress.js +1 -1
- package/dist/internal/sizer.d.ts +12 -11
- package/dist/internal/sizer.js +1 -1
- package/dist/internal/steps.d.ts +0 -15
- package/dist/internal/steps.js +1 -1
- package/dist/internal/styles.d.ts +135 -8
- package/dist/internal/styles.js +1 -1
- package/dist/internal/table-scroll.d.ts +42 -0
- package/dist/internal/table-scroll.js +1 -0
- package/dist/internal/table.js +1 -1
- package/dist/internal/text.d.ts +8 -5
- package/dist/internal/window.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/ja.js +1 -1
- package/dist/locales/ko.js +1 -1
- package/dist/locales/zh-Hans.js +1 -1
- package/dist/provider/PlassProvider.d.ts +4 -3
- package/dist/provider/PlassProvider.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +461 -46
- package/dist/tokens.css +461 -46
- package/dist/types.d.ts +270 -11
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as t from"react";import{useDefaults as o}from"../../internal/defaults.js";import{Calendar as
|
|
1
|
+
"use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as t from"react";import{useDefaults as o}from"../../internal/defaults.js";import{Calendar as l,usePickerLabels as n}from"../../internal/calendar.js";import{popupPaddingClasses as s,popupSlots as r}from"../../internal/picker.js";import{FieldsetDisabledContext as i,useDisabled as m,useFormReport as d}from"../../internal/form.js";import{inertProps as c}from"../../internal/inert.js";import{isValidDate as u,localeWeekStart as f,mergeDateAndTime as h,startOfDay as p,startOfMonth as j,today as v,toISODate as y,toISOMonth as D,toISOYear as x}from"../../internal/date.js";import{controlTextLeadingClasses as b,cx as w,disabledClasses as S,radiusClasses as C,sheetRestClasses as O}from"../../internal/styles.js";const g={day:y,month:D,year:x};export const PlCalendar=/* @__PURE__ */t.forwardRef(function PlCalendar({variant:y="glass",size:D,color:x,elevation:k=1,value:z,defaultValue:M,onValueChange:P,precision:F="day",month:N,defaultMonth:V,onMonthChange:R,minDate:q,maxDate:A,shouldDisableDate:B,locale:E,weekStartsOn:G,showOutsideDays:H=!0,autoFocus:I=!1,disabled:J=!1,name:K,labels:L,className:Q,style:T,...U},W){const X=o(),Y=m(J),Z=E??X.locale,$=D??X.size??"md",_=x??X.color??"primary",ee=n(L),ae=G??X.weekStartsOn??f(Z),[te,oe]=t.useState(M??null),le=void 0!==z?z:te,[ne,se]=t.useState(()=>j(u(le)?le:V??v())),re=N??ne,setMonth=e=>{void 0===N&&se(e),R?.(e)},ie=u(le)?g[F](le):"";return d(K,()=>ie,!Y),a("div",{ref:W,...c(Y),className:w("inline-flex flex-col",O[y],C[$],s[$],b[$],Y?S[y]:"",Q),style:{...r(_,k),...T},...U,children:[e(i.Provider,{value:!1,children:e(l,{size:$,color:_,locale:Z,weekStartsOn:ae,month:re,onMonthChange:setMonth,precision:F,selected:[le],onSelect:e=>{const a=u(le)?h(e,le):p(e);void 0===z&&oe(a),P?.(a),setMonth(j(a))},minDate:q,maxDate:A,shouldDisableDate:B,showOutsideDays:H,autoFocus:I,labels:ee})}),K?e("input",{type:"hidden",name:K,value:ie,disabled:Y}):null]})});
|
|
@@ -51,15 +51,18 @@ export interface PlCardProps extends PlassStyleProps, Omit<React.ComponentPropsW
|
|
|
51
51
|
* pane of glass says it can be picked up.
|
|
52
52
|
*
|
|
53
53
|
* It changes how the card looks and nothing else. A card that is actually
|
|
54
|
-
* clickable
|
|
55
|
-
* `
|
|
56
|
-
*
|
|
54
|
+
* clickable needs a real link: the title's own, stretched over the card by an
|
|
55
|
+
* `::after` with `absolute inset-0` against a `relative` card, so it is
|
|
56
|
+
* focusable, announced, and named by the title alone. A control in a slot
|
|
57
|
+
* takes `relative` and a `z-index` to sit above it. Rendering the whole card
|
|
58
|
+
* as the link puts every slot inside it, and a button in one of them inside a
|
|
59
|
+
* link.
|
|
57
60
|
* @default false
|
|
58
61
|
*/
|
|
59
62
|
interactive?: boolean;
|
|
60
63
|
/**
|
|
61
64
|
* Renders something other than a `<div>`: `render={<section />}`,
|
|
62
|
-
* `render={<li />}`, `render={<
|
|
65
|
+
* `render={<li />}`, `render={<article />}`. Base UI's own escape hatch.
|
|
63
66
|
*/
|
|
64
67
|
render?: useRender.RenderProp;
|
|
65
68
|
/** The card's body. */
|
|
@@ -20,12 +20,18 @@ export interface PlCarouselProps extends PlassStyleProps, Omit<React.ComponentPr
|
|
|
20
20
|
*/
|
|
21
21
|
loop?: boolean;
|
|
22
22
|
/**
|
|
23
|
-
* Advances on its own
|
|
23
|
+
* Advances on its own, with a button over the frame that stops it and starts
|
|
24
|
+
* it again.
|
|
24
25
|
*
|
|
25
26
|
* Off by default and deliberately so: a carousel that moves while it is being
|
|
26
|
-
* read is the most complained-about pattern on the web. It pauses
|
|
27
|
-
*
|
|
28
|
-
*
|
|
27
|
+
* read is the most complained-about pattern on the web. It pauses while the
|
|
28
|
+
* pointer is over it, while a finger is down on the strip, while the tab is
|
|
29
|
+
* in the background, and while it is hidden in a tab panel that is not
|
|
30
|
+
* selected or a closed disclosure; once the finger lifts, or it is shown
|
|
31
|
+
* again, it holds the slide it is on for a whole `interval`. It **stops** once
|
|
32
|
+
* the focus comes into it or an arrow or a dot is clicked, and stays stopped
|
|
33
|
+
* until the button starts it again. For a reader who has asked for reduced
|
|
34
|
+
* motion it starts stopped.
|
|
29
35
|
* @default false
|
|
30
36
|
*/
|
|
31
37
|
autoPlay?: boolean;
|
|
@@ -45,6 +51,10 @@ export interface PlCarouselProps extends PlassStyleProps, Omit<React.ComponentPr
|
|
|
45
51
|
previousLabel?: string;
|
|
46
52
|
/** @default 'Next slide' */
|
|
47
53
|
nextLabel?: string;
|
|
54
|
+
/** What the `autoPlay` button says while the carousel is stopped. @default 'Start slide show' */
|
|
55
|
+
playLabel?: string;
|
|
56
|
+
/** What it says while the carousel is playing. @default 'Stop slide show' */
|
|
57
|
+
stopLabel?: string;
|
|
48
58
|
/**
|
|
49
59
|
* How one slide is named to a screen reader, and how its dot is labelled.
|
|
50
60
|
* @default `Slide {index} of {count}`, from the label pack
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as
|
|
1
|
+
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as r from"react";import{mergeProps as n}from"@base-ui/react/merge-props";import{useDefaults as s}from"../../internal/defaults.js";import{useLabels as o}from"../../internal/labels.js";import{PlIconButton as a}from"../icon-button/PlIconButton.js";import{ChevronIcon as l,PauseIcon as i,PlayIcon as c}from"../../internal/icons.js";import{usePrefersReducedMotion as u}from"../../internal/media.js";import{cx as d,pictureSlotClasses as f,radiusClasses as m,sheetRestClasses as h,srOnlyClasses as p,surfaceSlots as v,transitionClasses as b}from"../../internal/styles.js";const g={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"},w={xs:"top-1 start-1",sm:"top-1.5 start-1.5",md:"top-2 start-2",lg:"top-3 start-3",xl:"top-4 start-4"},x={xs:{rest:"h-1 w-1",current:"h-1 w-3"},sm:{rest:"h-1 w-1",current:"h-1 w-3.5"},md:{rest:"h-1.5 w-1.5",current:"h-1.5 w-4"},lg:{rest:"h-1.5 w-1.5",current:"h-1.5 w-5"},xl:{rest:"h-2 w-2",current:"h-2 w-6"}};function scrollTrackTo(e,t,r){e.scrollTo({left:e.scrollLeft+t.getBoundingClientRect().left-e.getBoundingClientRect().left,behavior:r})}export const PlCarousel=/* @__PURE__ */r.forwardRef(function PlCarousel({variant:y="glass",size:R,color:T,density:N,elevation:k=0,value:C,defaultValue:L=0,onValueChange:j,loop:E=!0,autoPlay:S=!1,interval:z=5e3,arrows:P=!0,indicators:M=!0,label:B,previousLabel:I,nextLabel:W,playLabel:_,stopLabel:V,slideLabel:O,className:$,style:A,children:F,...q},D){const G=s(),H=o(),J=B??H.carousel,K=I??H.carouselPrevious,Q=W??H.carouselNext,U=_??H.carouselPlay,X=V??H.carouselStop,Y=R??G.size??"md",Z=T??G.color??"primary",ee=N??G.density??"default",te=O??H.carouselSlide,re=r.Children.toArray(F),ne=re.length,[se,oe]=r.useState(L),ae=Math.min(Math.max(C??se,0),Math.max(ne-1,0)),le=r.useRef(null),ie=r.useRef([]),ce=r.useRef(!1),ue=r.useRef(!1),de=r.useRef(!1),fe=r.useRef(!1),me=r.useRef(0),[he,pe]=r.useState(0),[ve,be]=r.useState(!1),ge=r.useRef(new Set),[we,xe]=r.useState(!1),[ye,Re]=r.useState(null),Te=u(),Ne=ye??Te,ke=S&&!Ne,Ce=r.useRef(null),Le=r.useRef(!1),je=r.useCallback((e,t=!1)=>{if(0===ne)return;const r=E?(e%ne+ne)%ne:Math.min(Math.max(e,0),ne-1);ce.current=t,void 0===C&&oe(r),r!==ae&&j?.(r)},[ne,E,C,ae,j]),Ee=r.useRef(ae);r.useLayoutEffect(()=>{Ee.current=ae}),r.useLayoutEffect(()=>{const e=le.current;if(!e)return;const place=()=>{const t=ie.current[Ee.current];t&&scrollTrackTo(e,t,"instant")};if("undefined"==typeof ResizeObserver)return void(Ee.current>0&&place());fe.current=0===e.clientWidth,!fe.current&&Ee.current>0&&place();const t=new ResizeObserver(e=>{0===e[e.length-1].contentRect.width?fe.current=!0:fe.current&&(fe.current=!1,place(),me.current+=1,pe(me.current))});return t.observe(e),()=>t.disconnect()},[]),r.useEffect(()=>{if(ce.current)return void(ce.current=!1);if(!ue.current)return void(ue.current=!0);const e=le.current,t=ie.current[ae];e&&t&&scrollTrackTo(e,t),de.current=!0;const r=window.setTimeout(()=>{de.current=!1},700);return()=>window.clearTimeout(r)},[ae]);const Se=r.useRef(je);r.useEffect(()=>{Se.current=je}),r.useEffect(()=>{if(!ke)return;const handleVisibility=()=>{document.hidden||(me.current+=1,pe(me.current))};return document.addEventListener("visibilitychange",handleVisibility),()=>document.removeEventListener("visibilitychange",handleVisibility)},[ke]),r.useEffect(()=>{if(!ke||ve||we||ne<2)return;const e=window.setInterval(()=>{document.hidden||fe.current||me.current!==he||0===le.current?.clientWidth||Se.current(ae+1)},z);return()=>window.clearInterval(e)},[ke,ve,we,ne,z,ae,he]);const handleTouch=e=>{const t="touchstart"===e.type;for(let r=0;r<e.changedTouches.length;r+=1){const{identifier:n}=e.changedTouches[r];t?ge.current.add(n):ge.current.delete(n)}xe(ge.current.size>0)},hold=()=>{S&&!Le.current&&Re(!0)},steer=e=>{hold(),je(e)},ze=ae<=0,Pe=ae>=ne-1;return t("div",{ref:D,role:"region","aria-roledescription":H.carousel,"aria-label":J,className:d("flex flex-col",$),style:{...v(Z,k),...A},...n(q,{onPointerEnter:()=>be(!0),onPointerLeave:()=>be(!1),onFocus:e=>{e.currentTarget.contains(e.relatedTarget)||(Le.current=!1),e.target!==Ce.current&&hold()},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(Le.current=!1)}}),children:[t("div",{className:d("relative min-w-0 overflow-hidden",m[Y],h[y],b),children:[S&&ne>1?e("div",{className:d("absolute z-10 flex",w[Y]),children:e(a,{ref:Ce,variant:"glass",size:Y,color:Z,density:ee,elevation:1,label:Ne?U:X,icon:e(Ne?c:i,{}),onClick:()=>{const e=!Ne;Re(e),Le.current=!e}})}):null,e("div",{ref:le,tabIndex:0,role:"group","aria-label":J,className:d("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(--p-ring)] focus-visible:[outline-offset:-2px]"),onScroll:()=>{const e=le.current;if(de.current||fe.current||!e||0===e.clientWidth)return;const t=Math.round(Math.abs(e.scrollLeft)/e.clientWidth);t!==ae&&t>=0&&t<ne&&je(t,!0)},onTouchStart:handleTouch,onTouchEnd:handleTouch,onTouchCancel:handleTouch,children:re.map((t,n)=>e("div",{ref:e=>{ie.current[n]=e},role:"group","aria-roledescription":H.slide,"aria-label":te(n+1,ne),className:d("w-full shrink-0 grow-0 basis-full snap-start",f),children:t},r.isValidElement(t)?t.key??n:n))}),P&&ne>1?t("div",{className:d("pointer-events-none absolute inset-y-0 flex items-center",g[Y]),children:[e(a,{variant:"glass",size:Y,color:Z,density:ee,elevation:1,label:K,disabled:!E&&ze,className:"pointer-events-auto",icon:e("span",{className:"flex rotate-90 items-center rtl:-rotate-90",children:e(l,{})}),onClick:()=>steer(ae-1)}),e("span",{className:"flex-1"}),e(a,{variant:"glass",size:Y,color:Z,density:ee,elevation:1,label:Q,disabled:!E&&Pe,className:"pointer-events-auto",icon:e("span",{className:"flex -rotate-90 items-center rtl:rotate-90",children:e(l,{})}),onClick:()=>steer(ae+1)})]}):null]}),M&&ne>1?e("div",{className:"flex shrink-0 items-center justify-center",children:re.map((t,r)=>e("button",{type:"button","aria-label":te(r+1,ne),"aria-current":r===ae?"true":void 0,className:d("group flex h-6 min-w-6 cursor-pointer items-center justify-center rounded-full","focus-visible:[outline:2px_solid_var(--p-ring)] focus-visible:outline-offset-0"),onClick:()=>steer(r),children:e("span",{"aria-hidden":"true",className:d("rounded-full","[transition-property:width,background-color]","[transition-duration:var(--plass-duration)]","[transition-timing-function:var(--plass-ease)]","motion-reduce:[transition-duration:0ms]",r===ae?`${x[Y].current} bg-(--p-accent)`:`${x[Y].rest} bg-(--plass-border) group-hover:bg-(--p-accent)`)})},r))}):null,e("span",{className:p,"aria-live":ke?"off":"polite",children:ne>0?te(ae+1,ne):""})]})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as s,Fragment as a}from"react/jsx-runtime";import*as
|
|
1
|
+
"use client";import{jsx as e,jsxs as s,Fragment as a}from"react/jsx-runtime";import*as r from"react";import{useDefaults as n}from"../../internal/defaults.js";import{useLabels as l}from"../../internal/labels.js";import{CheckIcon as i,ClockIcon as t,LinkIcon as o,severityIcon as d}from"../../internal/icons.js";import{safeHref as c}from"../../internal/link.js";import{controlSlots as p,focusRingClasses as m,forcedFieldEdgeClasses as u,glassClasses as g,hasContent as f,metaTextClasses as v,radiusClasses as h,sheetBodyClasses as x,sheetHeaderGapClasses as b,srOnlyClasses as y,transitionClasses as k}from"../../internal/styles.js";const w={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"}},N={start:"[border-start-start-radius:0.25rem]",end:"[border-start-end-radius:0.25rem]"},j={solid:/* @__PURE__ */["text-(--p-on-solid) [background-image:var(--p-fill)]","[box-shadow:var(--p-elev),var(--p-lift)]",u].join(" "),glass:/* @__PURE__ */[g,"border text-(--plass-fg) bg-(--plass-glass)","[border-color:var(--plass-glass-line)]","[box-shadow:var(--p-elev),var(--plass-gloss-glass)]"].join(" "),ghost:"text-(--plass-fg) bg-(--p-soft) [box-shadow:var(--p-elev)]"};function DoubleCheckIcon(){return s("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"})]})}const _={sending:e(t,{}),sent:e(i,{}),delivered:e(DoubleCheckIcon,{}),read:e(DoubleCheckIcon,{}),failed:/* @__PURE__ */d("danger")};function statusWord(e,s){switch(e){case"sending":return s.messageSending;case"sent":return s.messageSent;case"delivered":return s.messageDelivered;case"read":return s.messageRead;case"failed":return s.messageFailed}}const C={sending:"text-(--plass-muted-fg)",sent:"text-(--plass-muted-fg)",delivered:"text-(--plass-muted-fg)",read:"text-(--p-accent)",failed:"text-(--plass-danger-accent)"},L=/* @__PURE__ */["block overflow-hidden rounded-(--plass-radius-sm) border no-underline","[border-color:color-mix(in_oklab,currentColor_18%,transparent)]","[background-color:color-mix(in_oklab,currentColor_7%,transparent)]"].join(" "),z=/* @__PURE__ */[L,"hover:[background-color:color-mix(in_oklab,currentColor_12%,transparent)]","[transition-property:background-color] [transition-duration:var(--plass-duration)]","[transition-timing-function:var(--plass-ease)]","motion-reduce:[transition-duration:0ms]",m].join(" "),D=/* @__PURE__ */["shrink-0 opacity-0","[transition:opacity_var(--plass-duration)_var(--plass-ease)]","motion-reduce:[transition-duration:0ms]","group-hover/bubble:opacity-100 group-focus-within/bubble:opacity-100","[@media(hover:none)]:opacity-100"].join(" ");export const PlChatBubble=/* @__PURE__ */r.forwardRef(function PlChatBubble({side:a="start",name:r,time:i,avatar:t,status:o,statusLabel:d,typing:c=!1,typingLabel:m,media:u,preview:g,actions:L,variant:z="glass",size:B,color:P,density:W,elevation:I=0,className:T,style:F,children:R,...S},M){const $=n(),q=l(),A=m??q.typing,E=B??$.size??"md",G=P??$.color??"primary",H=W??$.density??"default",J="end"===a,K=f(r)||f(i),O=c||f(R)||Boolean(g),Q=["flex min-w-0 flex-col overflow-hidden",h[E],N[a],j[z],k].join(" ");return s("div",{ref:M,className:["group/bubble flex w-full items-start gap-2",J?"flex-row-reverse":"",T??""].filter(Boolean).join(" "),style:{...p(G,I,z),...F},...S,children:[f(t)?e("div",{className:"shrink-0",children:t}):null,s("div",{className:["flex max-w-[min(100%,32rem)] min-w-0 flex-col",b[E],J?"items-end":"items-start"].join(" "),children:[K?s("div",{className:`flex items-baseline gap-2 ${v[E]}`,children:[f(r)?e("span",{className:"font-semibold",children:r}):null,f(i)?e("span",{className:"text-(--plass-muted-fg)",children:i}):null]}):null,s("div",{className:"flex min-w-0 items-center gap-1 "+(J?"flex-row-reverse":""),children:[s("div",{className:Q,children:[f(u)?e("div",{className:"[&_img]:block [&_img]:w-full [&_video]:block [&_video]:w-full [:where(&_img)]:h-auto [:where(&_video)]:h-auto",children:u}):null,O?s("div",{className:[w[H][E],"flex min-w-0 flex-col gap-2",x[E]].join(" "),children:[c?e(TypingDots,{label:A}):f(R)?e("div",{className:"min-w-0 break-words whitespace-pre-line",children:R}):null,g?e(LinkPreview,{preview:g}):null]}):null]}),f(L)?e("div",{className:D,children:L}):null]}),o?s("div",{className:["flex items-center gap-1",v[E],C[o],"[&_svg]:size-[1.15em] [&_svg]:shrink-0"].join(" "),children:[_[o],e("span",{className:y,children:d??statusWord(o,q)})]}):null]})]})});function TypingDots({label:a}){return s("div",{className:"flex items-center gap-1 py-[0.35em]",role:"status",children:[[0,1,2].map(s=>e("span",{"aria-hidden":"true",className:"plass-typing-dot size-[0.45em] rounded-full",style:{"--p-i":s}},s)),e("span",{className:y,children:a})]})}function LinkPreview({preview:r}){const{url:n,title:l,description:i,image:t,site:d,newTab:p=!1}=r,m=c(n),u=s(a,{children:[t?e("img",{src:t,alt:"",loading:"lazy",decoding:"async",className:"block h-28 w-full object-cover"}):null,s("div",{className:"flex flex-col gap-0.5 p-2",children:[f(d)?s("span",{className:"flex items-center gap-1 text-[0.85em] opacity-70 [&_svg]:size-[1em] [&_svg]:shrink-0",children:[e(o,{}),e("span",{className:"truncate",children:d})]}):null,f(l)?e("span",{className:"font-semibold",children:l}):null,f(i)?e("span",{className:"line-clamp-2 text-[0.9em] opacity-80",children:i}):null]})]});return void 0===m?e("div",{className:L,children:u}):e("a",{href:m,target:p?"_blank":void 0,rel:p?"noopener noreferrer":void 0,className:z,children:u})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as a from"react";import{
|
|
1
|
+
"use client";import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as a from"react";import{useDisabled as t}from"../../internal/form.js";import{useDefaults as o}from"../../internal/defaults.js";import{Checkbox as n}from"@base-ui/react/checkbox";import{Field as s}from"@base-ui/react/field";import{controlSlots as i,cx as l,fieldDescriptionClasses as d,focusRingClasses as c,forcedCheckedClasses as p,forcedDisabledCheckedClasses as h,glassClasses as m,hasContent as f,metaTextClasses as u,tickRadiusClasses as k,tickRowTextClasses as b,tickSizeClasses as g,transitionClasses as x}from"../../internal/styles.js";const v=/* @__PURE__ */["relative inline-flex shrink-0 items-center justify-center border","[-webkit-tap-highlight-color:transparent] [touch-action:manipulation]","plass-fill [--p-fill-edge:1px]",x,c].join(" "),j=/* @__PURE__ */["forced-colors:data-[indeterminate]:[background-color:Highlight]","forced-colors:data-[indeterminate]:[border-color:Highlight]","forced-colors:data-[indeterminate]:[color:HighlightText]"].join(" "),N=/* @__PURE__ */[m,"cursor-pointer bg-(--plass-glass) [border-color:var(--plass-border)]","hover:bg-(--plass-glass-hover) hover:[border-color:var(--p-line)]","data-[checked]:[--p-fill-on:1] data-[checked]:text-(--p-on-solid)","data-[checked]:[border-color:transparent] data-[checked]:hover:brightness-105","data-[indeterminate]:[--p-fill-on:1] data-[indeterminate]:text-(--p-on-solid)","data-[indeterminate]:[border-color:transparent]",p,j].join(" "),y=/* @__PURE__ */[m,"cursor-default bg-(--plass-glass) [border-color:var(--plass-border)]","saturate-[0.55]","data-[checked]:[--p-fill-on:1] data-[checked]:text-(--p-on-solid)","data-[checked]:[border-color:transparent]","data-[indeterminate]:[--p-fill-on:1] data-[indeterminate]:text-(--p-on-solid)","data-[indeterminate]:[border-color:transparent]",p,j].join(" "),C=/* @__PURE__ */[m,"cursor-not-allowed bg-(--plass-glass) [border-color:var(--plass-border)]","opacity-50 saturate-[0.35]","data-[checked]:[--p-fill-on:1] data-[checked]:text-(--p-on-solid)","data-[checked]:[border-color:transparent]","data-[indeterminate]:[--p-fill-on:1] data-[indeterminate]:text-(--p-on-solid)","data-[indeterminate]:[border-color:transparent]",h,"forced-colors:data-[indeterminate]:[background-color:GrayText]","forced-colors:data-[indeterminate]:[color:Canvas]"].join(" "),M=/* @__PURE__ */["flex size-[70%] items-center justify-center","[&_path]:[stroke-dasharray:1] [&_path]:[stroke-dashoffset:0]","[&_path]:[transition:stroke-dashoffset_var(--plass-duration)_var(--plass-ease)]","motion-reduce:[&_path]:[transition-duration:0ms]","data-[unchecked]:[&_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 PlCheckbox=/* @__PURE__ */a.forwardRef(function PlCheckbox({size:a,color:c,label:p,description:h,error:m,invalid:x,disabled:j=!1,readOnly:_=!1,className:w,classNames:L,style:z,...B},D){const H=o(),R=t(j),O=a??H.size??"md",P=c??H.color??"primary",T=f(m),W=x??T,E=W?"danger":P,G=l(v,g[O],k[O],R?C:_?y:N,L?.control);return r(s.Root,{disabled:R,invalid:W,className:["inline-flex flex-col gap-1 align-top",w??""].filter(Boolean).join(" "),style:{...i(E,0,"solid"),...z},children:[r("div",{className:`flex items-start gap-2 ${b[O]}`,children:[e("span",{className:"flex h-[1lh] shrink-0 items-center",children:e(n.Root,{ref:D,className:G,disabled:R,readOnly:_,...B,children:e(n.Indicator,{keepMounted:!0,className:M,children:B.indeterminate?e(DashMark,{}):e(CheckMark,{})})})}),p||h?r("span",{className:"flex min-w-0 flex-col gap-0.5",children:[p?e(s.Label,{className:l(R?"text-(--plass-muted-fg)":"cursor-pointer text-(--plass-fg)",L?.label),children:p}):null,h?e(s.Description,{className:l(d(O),L?.description),children:h}):null]}):null]}),e(s.Error,T?{match:!0,className:l(u[O],"text-(--p-accent)",L?.error),children:m}:{className:l(u[O],"text-(--p-accent)",L?.error)})]})});
|
|
@@ -49,7 +49,8 @@ export interface PlChipProps extends PlassStyleProps, Omit<React.ComponentPropsW
|
|
|
49
49
|
* The shell is always a `<span>`. What changes is what is inside it: a plain run
|
|
50
50
|
* of content, or — when `onClick` is given — a real `<button>` wrapping that
|
|
51
51
|
* content, plus a second button for `onDelete`. Both are reachable by keyboard,
|
|
52
|
-
* and neither is nested inside the other.
|
|
52
|
+
* and neither is nested inside the other. `disabled` disables them rather than
|
|
53
|
+
* taking them away.
|
|
53
54
|
*
|
|
54
55
|
* An inert `<span>` carrying a click handler is the single most common way a
|
|
55
56
|
* component library loses its keyboard users, and a `<button>` inside a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,Fragment as s,jsxs as l}from"react/jsx-runtime";import*as
|
|
1
|
+
"use client";import{jsx as e,Fragment as s,jsxs as l}from"react/jsx-runtime";import*as o from"react";import{FadedContext as t}from"../../internal/form.js";import{glowPointerMove as r}from"../../internal/glow.js";import{useDefaults as n}from"../../internal/defaults.js";import{useLabels as a}from"../../internal/labels.js";import{CloseIcon as i}from"../../internal/icons.js";import{textOf as d}from"../../internal/text.js";import{chipRemoveClasses as p,controlHeightClasses as c,controlSlots as m,controlTextClasses as g,disabledClasses as b,disabledLookClasses as f,focusRingClasses as h,forcedEdgeClasses as u,gapClasses as v,glassClasses as x,hasContent as j,iconClasses as w,paddingXClasses as y,radiusClasses as k,transitionClasses as $}from"../../internal/styles.js";const C={xs:"xs",sm:"xs",md:"sm",lg:"md",xl:"lg"},N={solid:`text-(--p-on-solid) [background-image:var(--p-fill)] [box-shadow:var(--p-elev)] ${u}`,glass:/* @__PURE__ */[x,"border text-(--p-accent) bg-(--plass-glass)","[border-color:var(--plass-glass-line)]","[box-shadow:var(--p-elev),var(--plass-gloss-glass)]"].join(" "),ghost:"text-(--p-accent) bg-(--p-soft)"},I={solid:"[box-shadow:var(--p-elev),var(--p-lift)]",glass:"bg-(--plass-glass-press) [border-color:var(--p-line-hover)]",ghost:"bg-(--p-soft-press)"},P={solid:"hover:brightness-105 active:brightness-95",glass:"hover:bg-(--plass-glass-hover) hover:[border-color:var(--p-line)] active:bg-(--plass-glass-press)",ghost:"hover:bg-(--p-soft-hover) active:bg-(--p-soft-press)"},z=/* @__PURE__ */["relative inline-flex max-w-full shrink-0 items-center select-none","align-middle leading-none font-medium whitespace-nowrap","[-webkit-tap-highlight-color:transparent] [touch-action:manipulation]",$,w].join(" "),B=/* @__PURE__ */["flex min-w-0 flex-1 cursor-pointer items-center justify-center self-stretch rounded-[inherit]",h,"disabled:cursor-not-allowed"].join(" ");export const PlChip=/* @__PURE__ */o.forwardRef(function PlChip({variant:h="glass",size:u,color:x,density:w,elevation:$=0,startIcon:M,endIcon:D,count:F,onDelete:L,deleteLabel:R,selected:q=!1,disabled:A=!1,className:E,style:G,children:H,onClick:J,onPointerMove:K,...O},Q){const S=n(),T=a(),U=d(H).trim(),V=R??(U?T.removeItem(U):T.remove),W=u??S.size??"md",X=x??S.color??"primary",Y=w??S.density??"default",Z=o.useContext(t),_=Boolean(J),ee=_&&!A,se=o.useId(),le=o.useId(),oe=C[W],te=y[Y][oe],re=[z,c[oe],g[oe],v[oe],k[oe],A?(Z?f:b)[h]:N[h],!A&&q?I[h]:"",ee?`plass-glow ${P[h]}`:"",_?"ps-0":te,L?"pe-1":_?"pe-0":"",E??""].filter(Boolean).join(" "),ne=l(s,{children:[M,j(H)?e("span",{id:le,className:"min-w-0 truncate leading-[normal]",children:H}):null,D,j(F)?e("span",{className:["ms-0.5 inline-flex shrink-0 items-center justify-center rounded-full px-1.5 py-px","text-[0.85em] leading-none font-semibold tabular-nums","solid"===h?"bg-(--plass-glow-on-fill) text-(--p-on-solid)":"bg-(--p-soft-press) text-(--p-accent)"].join(" "),children:F}):null]});return l("span",{ref:Q,className:re,style:{...m(X,$,h),...G},"aria-disabled":!(!A||_)||void 0,onPointerMove:r(ee,K),...O,children:[_?e("button",{type:"button",disabled:A,"aria-pressed":q,className:`${B} ${v[oe]} ${te}`,onClick:J,children:ne}):ne,L?e("button",{type:"button",id:se,"aria-label":V,"aria-labelledby":void 0===R&&!U&&j(H)?`${se} ${le}`:void 0,disabled:A,className:p,onClick:L,children:e(i,{})}):null]})});
|
|
@@ -39,6 +39,17 @@ export interface PlCollapsibleProps extends PlassStyleProps, Omit<React.Componen
|
|
|
39
39
|
trigger?: React.ReactElement;
|
|
40
40
|
/** The chevron at the end of the header, turned to report the state. @default true */
|
|
41
41
|
indicator?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Holds the header's title and subtitle to one line each, ellipsing whatever
|
|
44
|
+
* runs past.
|
|
45
|
+
*
|
|
46
|
+
* Off, as it is on a `PlAccordionItem`: a fold's title is a heading rather
|
|
47
|
+
* than a cell, and ellipsing one costs the reader the end of it with no
|
|
48
|
+
* tooltip and no way to see it. The place for it is a header carrying a name
|
|
49
|
+
* from a database beside a control.
|
|
50
|
+
* @default false
|
|
51
|
+
*/
|
|
52
|
+
truncate?: boolean;
|
|
42
53
|
/** Unavailable. The trigger stops answering and the panel stays as it is. */
|
|
43
54
|
disabled?: boolean;
|
|
44
55
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as
|
|
1
|
+
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as l from"react";import{useDefaults as s}from"../../internal/defaults.js";import{Collapsible as a}from"@base-ui/react/collapsible";import{ChevronIcon as n}from"../../internal/icons.js";import{cx as i,focusRingInsetClasses as r,gapClasses as o,hasContent as d,iconClasses as p,metaTextClasses as c,radiusClasses as m,sheetBodyClasses as f,sheetHeaderGapClasses as u,sheetPaddingXClasses as h,sheetPaddingYClasses as x,sheetRestClasses as b,sheetTitleClasses as g,surfaceSlots as N,transitionClasses as v}from"../../internal/styles.js";const w={default:{xs:"pt-1.5",sm:"pt-2",md:"pt-3",lg:"pt-3.5",xl:"pt-4"},compact:{xs:"pt-1",sm:"pt-1.5",md:"pt-2",lg:"pt-2.5",xl:"pt-3"}},y={default:{xs:"pb-2.5",sm:"pb-3",md:"pb-5",lg:"pb-6",xl:"pb-7"},compact:{xs:"pb-2",sm:"pb-2.5",md:"pb-3.5",lg:"pb-4",xl:"pb-5"}};export const PlCollapsible=/* @__PURE__ */l.forwardRef(function PlCollapsible({variant:l="glass",size:j,color:k,density:C,elevation:O=0,open:_,defaultOpen:P=!1,onOpenChange:$,title:z,subtitle:F,startIcon:M,action:R,trigger:T,indicator:U=!0,truncate:I=!1,disabled:q=!1,padded:A=!0,hiddenUntilFound:B=!1,keepMounted:D=!1,className:E,style:G,children:H,...J},K){const L=s(),Q=j??L.size??"md",S=k??L.color??"primary",V=C??L.density??"default",W=h[V][Q],X=x[V][Q],Y=I?"truncate":"";return t(a.Root,{ref:K,open:_,defaultOpen:P,onOpenChange:e=>$?.(e),disabled:q,className:i("flex flex-col overflow-hidden",m[Q],b[l],v,E),style:{...N(S,O),...G},...J,children:[T?e(a.Trigger,{render:T}):t("div",{className:"flex w-full items-center",children:[t(a.Trigger,{className:i("flex min-w-0 flex-1 cursor-pointer items-center text-start",W,X,o[Q],v,p,r,"hover:bg-(--p-soft)","data-[panel-open]:bg-(--p-soft) data-[panel-open]:text-(--p-accent)","disabled:cursor-not-allowed disabled:bg-transparent disabled:opacity-50"),children:[d(M)?e("span",{className:"flex h-[1lh] shrink-0 items-center text-(--plass-muted-fg)",children:M}):null,t("span",{className:i("flex min-w-0 flex-1 flex-col",u[Q]),children:[d(z)?e("span",{className:i("plass-title font-semibold",Y,g[Q]),children:z}):null,d(F)?e("span",{className:i("text-(--plass-muted-fg)",Y,c[Q]),children:F}):null]}),U?e("span",{className:i("flex h-[1lh] shrink-0 items-center text-(--plass-muted-fg)","[transition:rotate_var(--plass-duration)_var(--plass-ease)]","motion-reduce:[transition-duration:0ms]","data-[panel-open]:rotate-180"),children:e(n,{})}):null]}),d(R)?e("span",{className:i("flex shrink-0 items-center",W),children:R}):null]}),e(a.Panel,{hiddenUntilFound:B,keepMounted:D,className:i("h-(--collapsible-panel-height) overflow-hidden","[transition:height_var(--plass-duration-slow)_var(--plass-ease)]","motion-reduce:[transition-duration:0ms]","data-[starting-style]:h-0 data-[ending-style]:h-0"),children:e("div",{className:i("min-w-0 text-(--plass-muted-fg)",f[Q],A?`${W} ${w[V][Q]} ${y[V][Q]}`:""),children:H})})]})});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { PlColorFormat } from '../../internal/color.js';
|
|
3
|
-
import type { PlassElevation, PlassStyleProps } from '../../types.js';
|
|
3
|
+
import type { PlassElevation, PlassFieldClassNames, PlassFieldLabelPlacement, PlassStyleProps } from '../../types.js';
|
|
4
4
|
export type { PlColorFormat } from '../../internal/color.js';
|
|
5
5
|
/** The names for the parts of the picker that have no text on them. */
|
|
6
6
|
export interface PlColorPickerLabels {
|
|
@@ -22,6 +22,17 @@ export interface PlColorPickerLabels {
|
|
|
22
22
|
/** The English the picker uses for the parts nobody can read a name off. */
|
|
23
23
|
export declare const defaultColorPickerLabels: PlColorPickerLabels;
|
|
24
24
|
export interface PlColorPickerProps extends PlassStyleProps, Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'defaultValue' | 'onChange'> {
|
|
25
|
+
/**
|
|
26
|
+
* The four parts of a labelled field, as every other one names them: the
|
|
27
|
+
* `label`, the `control`, the `description` and the `error`. `className`
|
|
28
|
+
* itself goes on the stack that holds all four, which is what a caller
|
|
29
|
+
* positions and sizes.
|
|
30
|
+
*
|
|
31
|
+
* `control` is the trigger the panel hangs off, or — with `inline` — the panel
|
|
32
|
+
* itself, because inline there is no trigger and the panel is what a reader
|
|
33
|
+
* acts on.
|
|
34
|
+
*/
|
|
35
|
+
classNames?: PlassFieldClassNames;
|
|
25
36
|
/** The colour, as a CSS string. Pass it to drive the picker yourself. */
|
|
26
37
|
value?: string;
|
|
27
38
|
/** Where an uncontrolled picker starts. @default '#1a58d1' */
|
|
@@ -41,8 +52,16 @@ export interface PlColorPickerProps extends PlassStyleProps, Omit<React.Componen
|
|
|
41
52
|
inline?: boolean;
|
|
42
53
|
/** The field under the panel that the value can be typed into. @default true */
|
|
43
54
|
editable?: boolean;
|
|
44
|
-
/**
|
|
55
|
+
/** The name of what the control holds. */
|
|
45
56
|
label?: React.ReactNode;
|
|
57
|
+
/**
|
|
58
|
+
* Where the `label` goes — above the trigger, or in its top edge. `float`
|
|
59
|
+
* puts it in the edge as well: the swatch at the trigger's start is where a
|
|
60
|
+
* floating label would rest.
|
|
61
|
+
* Falls back to the nearest `PlassProvider`, then to `top`.
|
|
62
|
+
* @default 'top'
|
|
63
|
+
*/
|
|
64
|
+
labelPlacement?: PlassFieldLabelPlacement;
|
|
46
65
|
/** Helper text below it. */
|
|
47
66
|
description?: React.ReactNode;
|
|
48
67
|
/** Error message below. Its presence also turns the control invalid. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as r from"react";import{useDefaults as l}from"../../internal/defaults.js";import{defaultPickerLabels as s}from"../../internal/calendar.js";import{PickerShell as o}from"../../internal/picker.js";import{useFieldsetDisabled as t,useFormReport as
|
|
1
|
+
"use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as r from"react";import{useDefaults as l}from"../../internal/defaults.js";import{defaultPickerLabels as s}from"../../internal/calendar.js";import{PickerShell as o}from"../../internal/picker.js";import{useDisabled as n,useFieldsetDisabled as t,useFormReport as i}from"../../internal/form.js";import{CheckIcon as d}from"../../internal/icons.js";import{checkerBackground as c,clamp as h,cssColor as u,defaultSwatches as f,formatColor as p,parseColor as m,readableInk as v}from"../../internal/color.js";import{controlTextClasses as b,cx as g,fieldDescriptionClasses as x,focusRingClasses as y,metaTextClasses as w,radiusClasses as C,stackGapClasses as k,surfaceSlots as N}from"../../internal/styles.js";export const defaultColorPickerLabels={area:"Saturation and brightness",hue:"Hue",alpha:"Opacity",value:"Colour value",swatches:"Swatches",clear:"Clear",empty:"Pick a colour"};const P={xs:"w-40",sm:"w-44",md:"w-52",lg:"w-60",xl:"w-72"},j={xs:"h-24",sm:"h-28",md:"h-32",lg:"h-40",xl:"h-48"},O={xs:"h-2.5",sm:"h-3",md:"h-3.5",lg:"h-4",xl:"h-5"},S={xs:"gap-1.5",sm:"gap-2",md:"gap-2.5",lg:"gap-3",xl:"gap-3.5"},_={xs:10,sm:12,md:14,lg:16,xl:18},$=/* @__PURE__ */["relative overflow-hidden border","[border-color:var(--plass-border)]","[box-shadow:var(--plass-gloss-glass)]"].join(" "),z=/* @__PURE__ */["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 fractionsOf(e){const a=e.currentTarget.getBoundingClientRect();return{x:0===a.width?0:h((e.clientX-a.left)/a.width,0,1),y:0===a.height?0:h((e.clientY-a.top)/a.height,0,1)}}function arrowStep(e){const a=e.shiftKey?10:1;switch(e.key){case"ArrowLeft":return{x:-a,y:0};case"ArrowRight":return{x:a,y:0};case"ArrowUp":return{x:0,y:a};case"ArrowDown":return{x:0,y:-a};default:return null}}function ColorPanel({hsv:r,alphaValue:l,onChange:s,text:o,onTextChange:n,withAlpha:t,swatches:i,editable:f,size:b,disabled:x,readOnly:k,invalid:N,labels:I,className:T}){const D=x||k,M=_[b],A=-M/2,L=u({h:r.h,s:100,v:100}),V=u(r),q=i?i.flatMap(e=>{const a=m(e);return a?[{swatch:e,parsed:a}]:[]}):[],track=e=>({onPointerDown:a=>{D||(a.currentTarget.setPointerCapture(a.pointerId),e(a))},onPointerMove:a=>{!D&&a.currentTarget.hasPointerCapture(a.pointerId)&&e(a)}}),railProps=(e,a,r,l,s)=>({role:"slider",tabIndex:D?-1:0,"aria-label":e,"aria-valuemin":0,"aria-valuemax":r,"aria-valuenow":Math.round(a),"aria-orientation":"horizontal","aria-disabled":D||void 0,"aria-invalid":N||void 0,onKeyDown:e=>{if(D)return;if("Home"===e.key||"End"===e.key)return e.preventDefault(),void s("Home"===e.key?0:1);const a=arrowStep(e);a&&(e.preventDefault(),l(a.x+a.y))}});return a("div",{className:g("flex flex-col",P[b],S[b],T),children:[e("div",{...track(e=>{const{x:a,y:o}=fractionsOf(e);s({hsv:{h:r.h,s:100*a,v:100*(1-o)},alpha:l})}),role:"slider",tabIndex:D?-1:0,"aria-label":I.area,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(r.s),"aria-valuetext":`${Math.round(r.s)}%, ${Math.round(r.v)}%`,"aria-disabled":D||void 0,"aria-invalid":N||void 0,onKeyDown:e=>{const a=arrowStep(e);if(D||!a)return;e.preventDefault();const o=h(r.s+a.x,0,100),n=h(r.v+a.y,0,100);o===r.s&&n===r.v||s({hsv:{h:r.h,s:o,v:n},alpha:l})},className:g($,j[b],C[b],y,D?"cursor-default":"cursor-crosshair touch-none"),style:{backgroundColor:L,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:z,style:{width:M,height:M,left:`${r.s}%`,top:100-r.v+"%",marginLeft:A,marginTop:A,backgroundColor:V}})}),e("div",{...track(e=>s({hsv:{...r,h:360*fractionsOf(e).x},alpha:l})),...railProps(I.hue,r.h,360,e=>s({hsv:{...r,h:(r.h+2*e+360)%360},alpha:l}),e=>s({hsv:{...r,h:360*e},alpha:l})),className:g($,O[b],"rounded-full",y,D?"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:z,style:{width:M,height:M,left:r.h/360*100+"%",top:"50%",marginLeft:A,marginTop:A,backgroundColor:L}})}),t?a("div",{...track(e=>s({hsv:r,alpha:fractionsOf(e).x})),...railProps(I.alpha,100*l,100,e=>{const a=h(l+e/100,0,1);a!==l&&s({hsv:r,alpha:a})},e=>s({hsv:r,alpha:e})),className:g($,O[b],"rounded-full",y,D?"cursor-default":"cursor-pointer touch-none"),style:c,children:[e("span",{"aria-hidden":"true",className:"absolute inset-0",style:{backgroundImage:`linear-gradient(to right, ${u(r,0)}, ${V})`}}),e("span",{className:z,style:{width:M,height:M,left:100*l+"%",top:"50%",marginLeft:A,marginTop:A,backgroundColor:u(r,l)}})]}):null,f?a("div",{className:g("flex items-center",S[b]),children:[e("span",{"aria-hidden":"true",className:"shrink-0 rounded-full border [border-color:var(--plass-border)]",style:{width:M+6,height:M+6,...c},children:e("span",{className:"block size-full rounded-full",style:{backgroundColor:u(r,l)}})}),e("input",{type:"text",value:o,disabled:x,readOnly:k,spellCheck:!1,autoComplete:"off","aria-label":I.value,onChange:e=>n(e.target.value),className:g("min-w-0 flex-1 border bg-transparent px-1.5 py-1 font-mono lowercase","[border-color:var(--plass-border)]",C.xs,w[b],"text-(--plass-fg)","[outline:none] focus-visible:[outline:2px_solid_var(--p-ring)]","focus-visible:[outline-offset:0px]")})]}):null,q.length>0?e("div",{role:"group","aria-label":I.swatches,className:"grid grid-cols-8 gap-1",children:q.map(({swatch:a,parsed:o})=>{const n=p(o.hsv,o.alpha,"hex")===p(r,l,"hex");return e("button",{type:"button",disabled:D,"aria-label":a,"aria-pressed":n,onClick:()=>s(o),className:g("flex aspect-square items-center justify-center rounded-full border","[border-color:var(--plass-border)]","[transition:box-shadow_var(--plass-duration)_var(--plass-ease)]","motion-reduce:[transition-duration:0ms]",y,"[outline:none]",D?"cursor-default":"cursor-pointer hover:[box-shadow:var(--plass-shadow-1)]","[&_svg]:size-3"),style:{backgroundColor:u(o.hsv,o.alpha)},children:n?e("span",{style:{color:v(o.hsv)},children:e(d,{})}):null},a)})}):null]})}function widthSamples(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 I={h:217,s:87,v:82};export const PlColorPicker=/* @__PURE__ */r.forwardRef(function PlColorPicker({value:d,defaultValue:h="#1a58d1",onValueChange:v,format:y="hex",alpha:C=!1,swatches:P=f,inline:j=!1,editable:O=!0,label:S,labelPlacement:_,description:$,error:z,invalid:T,required:D=!1,disabled:M=!1,readOnly:A=!1,fullWidth:L=!1,clearable:V=!1,name:q,open:B,defaultOpen:H=!1,onOpenChange:K,labels:R,variant:E="glass",size:W,color:U,density:X,elevation:Y=0,className:F,classNames:G,style:J,...Q},Z){const ee=l(),ae=W??ee.size??"md",re=U??ee.color??"primary",le=X??ee.density??"default",se=r.useMemo(()=>({...defaultColorPickerLabels,...R}),[R]),[oe,ne]=r.useState(h),te=d??oe,[ie,de]=r.useState(H),ce=B??ie,[he,ue]=r.useState(()=>m(te)??{hsv:I,alpha:1}),[fe,pe]=r.useState(()=>te),me=p(he.hsv,C?he.alpha:1,y),ve=""===te;r.useEffect(()=>{const e=m(te);e?p(e.hsv,C?e.alpha:1,y)!==me&&(pe(te),ue(e)):pe(te)},[te,me,C,y]);const commit=(e,a)=>{ue(e);const r=p(e.hsv,C?e.alpha:1,y);pe(a??r),void 0===d&&ne(r),v?.(r)},[be,ge]=r.useState(null),xe=r.useCallback(e=>{ge(e),"function"==typeof Z?Z(e):Z&&(Z.current=e)},[Z]),ye=t(be),we=n(M)||ye,Ce=T??Boolean(z),ke=r.useId(),Ne=e(ColorPanel,{hsv:he.hsv,alphaValue:he.alpha,onChange:commit,text:fe,onTextChange:e=>{pe(e);const a=m(e);a&&commit(a,e)},withAlpha:C,swatches:P,editable:O,size:ae,disabled:we,readOnly:A,invalid:j&&Ce,labels:se,className:j?G?.control:void 0});i(q,()=>ve?"":me,j&&!we);const Pe=q?e("input",{type:"hidden",name:q,value:ve?"":me,disabled:we}):null;if(j){const r=Ce?"danger":re,l=[$?`${ke}-description`:null,z?`${ke}-error`:null].filter(Boolean).join(" ")||void 0;return a("div",{ref:xe,role:"group","aria-labelledby":S?`${ke}-label`:void 0,"aria-describedby":l,className:g("flex flex-col",k[ae],F),style:{...N(r,Y),...J},...Q,children:[S?e("span",{id:`${ke}-label`,className:g(w[ae],"font-semibold",we?"text-(--plass-muted-fg)":"text-(--plass-fg)",G?.label),children:S}):null,Ne,$?e("span",{id:`${ke}-description`,className:g(x(ae),G?.description),children:$}):null,z?e("span",{id:`${ke}-error`,className:g(w[ae],"text-(--p-accent)",G?.error),children:z}):null,Pe]})}return e("div",{ref:xe,className:L?"w-full":"inline-block",...Q,children:e(o,{variant:E,size:ae,color:re,density:le,elevation:Y,style:J,label:S,labelPlacement:_,description:$,error:z,invalid:T,required:D,disabled:M,readOnly:A,fullWidth:L,className:F,classNames:G,startIcon:e("span",{"aria-hidden":"true",className:"block size-[1.15em] shrink-0 rounded-full border [border-color:var(--plass-border)]",style:c,children:e("span",{className:"block size-full rounded-full",style:{backgroundColor:ve?"transparent":u(he.hsv,C?he.alpha:1)}})}),display:ve?se.empty:me,samples:widthSamples(y,C),empty:ve,clearable:V,onClear:()=>{void 0===d&&ne(""),pe(""),v?.("")},open:ce,onOpenChange:e=>{void 0===B&&de(e),K?.(e)},labels:{...s,clear:se.clear},name:q,formValue:ve?"":me,children:e("div",{className:b[ae],children:Ne})})})});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { PlassElevation, PlassFieldClassNames, PlassHotKeys, PlassStyleProps } from '../../types.js';
|
|
2
|
+
import type { PlassElevation, PlassFieldClassNames, PlassHotKeys, PlassFieldLabelPlacement, PlassStyleProps } from '../../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* What a combobox's value may be — the same two types a PlSelect submits, and
|
|
5
5
|
* for the same reason: a form control's value is what a form sends, and every
|
|
@@ -43,7 +43,9 @@ export interface PlComboboxProps<Multiple extends boolean | undefined = false> e
|
|
|
43
43
|
items: readonly PlComboboxOption[];
|
|
44
44
|
/**
|
|
45
45
|
* Whether more than one value may be held. The chosen ones become chips
|
|
46
|
-
* inside the field, and the input goes on filtering after each.
|
|
46
|
+
* inside the field, and the input goes on filtering after each. A row taken
|
|
47
|
+
* from a filtered list closes the list and empties the text, as Base UI does;
|
|
48
|
+
* a row taken with nothing typed leaves the list open for the next one.
|
|
47
49
|
* @default false
|
|
48
50
|
*/
|
|
49
51
|
multiple?: Multiple;
|
|
@@ -92,8 +94,17 @@ export interface PlComboboxProps<Multiple extends boolean | undefined = false> e
|
|
|
92
94
|
* @default 0
|
|
93
95
|
*/
|
|
94
96
|
elevation?: PlassElevation;
|
|
95
|
-
/**
|
|
97
|
+
/** The name of what the field holds, wired to it by Base UI's Field. */
|
|
96
98
|
label?: React.ReactNode;
|
|
99
|
+
/**
|
|
100
|
+
* Where the `label` goes — above the field, in its top edge, or inside it
|
|
101
|
+
* where the text would be typed until the field is focused or holds a value.
|
|
102
|
+
* With a `startIcon` a `float` label stays in the edge, because the icon is
|
|
103
|
+
* where it would rest.
|
|
104
|
+
* Falls back to the nearest `PlassProvider`, then to `top`.
|
|
105
|
+
* @default 'top'
|
|
106
|
+
*/
|
|
107
|
+
labelPlacement?: PlassFieldLabelPlacement;
|
|
97
108
|
/** Helper text below the field. */
|
|
98
109
|
description?: React.ReactNode;
|
|
99
110
|
/** Error message below. Its presence also turns the combobox invalid. */
|
|
@@ -140,13 +151,14 @@ export interface PlComboboxProps<Multiple extends boolean | undefined = false> e
|
|
|
140
151
|
* itself, offered as the last row rather than committed silently on blur.
|
|
141
152
|
*
|
|
142
153
|
* With `multiple` the chosen values become PlChips inside the field and the
|
|
143
|
-
* input goes on filtering after each one
|
|
144
|
-
*
|
|
154
|
+
* input goes on filtering after each one. A row taken from a filtered list
|
|
155
|
+
* closes the list and empties the text, which is how Base UI 1.8.0 behaves,
|
|
156
|
+
* and a row taken with nothing typed leaves the list open for the next one.
|
|
145
157
|
*
|
|
146
158
|
* Base UI owns everything hard about this: the filtering and its collator, the
|
|
147
159
|
* popup's positioning and flipping, the `combobox`/`listbox` wiring, arrow-key
|
|
148
160
|
* navigation across both the list and the chips, and the hidden input that makes
|
|
149
161
|
* the whole thing submit with a form.
|
|
150
162
|
*/
|
|
151
|
-
export declare function PlCombobox<Multiple extends boolean | undefined = false>({ variant, size: sizeProp, color: colorProp, density: densityProp, elevation, items, multiple, value, defaultValue, onValueChange, onInputValueChange, allowCustom, customLabel, clearable, emptyMessage: emptyMessageProp, limit, placeholder, label, description, error, invalid, startIcon, fullWidth, disabled, readOnly, required, name, open, defaultOpen, onOpenChange, openLabel: openLabelProp, clearLabel: clearLabelProp, removeLabel: removeLabelProp, inputRef, id, className, hotKeys, classNames, style, ...props }: PlComboboxProps<Multiple>): React.JSX.Element;
|
|
163
|
+
export declare function PlCombobox<Multiple extends boolean | undefined = false>({ variant, size: sizeProp, color: colorProp, density: densityProp, elevation, items, multiple, value, defaultValue, onValueChange, onInputValueChange, allowCustom, customLabel, clearable, emptyMessage: emptyMessageProp, limit, placeholder, label, labelPlacement: labelPlacementProp, description, error, invalid, startIcon, fullWidth, disabled: disabledProp, readOnly, required, name, open, defaultOpen, onOpenChange, openLabel: openLabelProp, clearLabel: clearLabelProp, removeLabel: removeLabelProp, inputRef, id, className, hotKeys, classNames, style, ...props }: PlComboboxProps<Multiple>): React.JSX.Element;
|
|
152
164
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as l from"react";import{
|
|
1
|
+
"use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as l from"react";import{FadedContext as t,useDisabled as s}from"../../internal/form.js";import{useDefaults as n}from"../../internal/defaults.js";import{useLabels as r}from"../../internal/labels.js";import{Combobox as i}from"@base-ui/react/combobox";import{Field as o}from"@base-ui/react/field";import{PlChip as c}from"../chip/PlChip.js";import{CheckIcon as d,ChevronIcon as m,CloseIcon as p,PlusIcon as u}from"../../internal/icons.js";import{hotKeyHandler as h}from"../../internal/keys.js";import{useFieldLight as b}from"../../internal/glow.js";import{FieldNotch as f,floatControlClassName as g,notchShellStyle as v,resolveNotch as x}from"../../internal/notch.js";import{chipRemoveClasses as y,controlHeightClasses as w,controlTextLeadingClasses as N,cx as j,disabledClasses as C,fieldDescriptionClasses as L,fieldReadOnlyClasses as I,fieldRestClasses as S,fieldSlots as z,focusWithinRingClasses as _,forcedHighlightedClasses as O,gapClasses as P,glassClasses as V,hasContent as A,iconClasses as M,metaTextClasses as k,paddingXClasses as R,radiusClasses as F,stackGapClasses as T,surfaceSlots as $,targetClasses as q,transitionClasses as D}from"../../internal/styles.js";const E=/* @__PURE__ */["relative flex w-full cursor-text items-center","[-webkit-tap-highlight-color:transparent] [touch-action:manipulation]",D,M].join(" "),K=_,G={xs:"min-h-6 py-0",sm:"min-h-8 py-0.5",md:"min-h-10 py-1",lg:"min-h-12 py-1.5",xl:"min-h-14 py-2"},H=/* @__PURE__ */[V,"max-h-[min(20rem,var(--available-height))] overflow-y-auto overscroll-contain","w-[var(--anchor-width)] border bg-(--plass-glass-press) p-1","[border-color:var(--plass-glass-line)]","[box-shadow:var(--plass-shadow-3),var(--plass-gloss-glass)]","[outline:none]","[transition:opacity_var(--plass-duration)_var(--plass-ease)]","motion-reduce:[transition-duration:0ms]","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0"].join(" "),W=/* @__PURE__ */["relative flex cursor-pointer items-center gap-2 select-none","rounded-(--plass-radius-xs) py-1.5 pe-2 ps-7",D,"data-[highlighted]:bg-(--p-soft-hover) data-[highlighted]:text-(--p-accent)",O,"data-[selected]:font-semibold data-[selected]:text-(--p-accent)","data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50","[outline:none]"].join(" "),B=/* @__PURE__ */["inline-flex h-[1lh] shrink-0 cursor-pointer items-center justify-center","rounded-(--plass-radius-xs) text-(--plass-muted-fg)","[transition:color_var(--plass-duration)_var(--plass-ease)]","motion-reduce:[transition-duration:0ms]","enabled:hover:text-(--p-accent)","focus-visible:[outline:2px_solid_var(--p-ring)] focus-visible:[outline-offset:1px]","disabled:cursor-not-allowed"].join(" "),J=/* @__PURE__ */j(q,B),Q=[];function toArray(e){return null==e?Q:Array.isArray(e)?e:[e]}export function PlCombobox({variant:_="glass",size:O,color:V,density:M,elevation:q=0,items:D,multiple:Q,value:U,defaultValue:X,onValueChange:Y,onInputValueChange:Z,allowCustom:ee=!0,customLabel:ae,clearable:le=!1,emptyMessage:te,limit:se,placeholder:ne,label:re,labelPlacement:ie,description:oe,error:ce,invalid:de,startIcon:me,fullWidth:pe=!1,disabled:ue=!1,readOnly:he=!1,required:be=!1,name:fe,open:ge,defaultOpen:ve,onOpenChange:xe,openLabel:ye,clearLabel:we,removeLabel:Ne,inputRef:je,id:Ce,className:Le,hotKeys:Ie,classNames:Se,style:ze,..._e}){const Oe=n(),Pe=s(ue),Ve=r(),Ae=ye??Ve.open,Me=we??Ve.clear,ke=te??Ve.empty,Re=Ne??Ve.removeItem,Fe=O??Oe.size??"md",Te=V??Oe.color??"primary",$e=M??Oe.density??"default",qe=ie??Oe.labelPlacement??"top",{notched:De,float:Ee}=x(qe,re,A(me)),Ke=A(ce),Ge=de??Ke,He=Ge?"danger":Te,We=!0===Q,Be=l.useMemo(()=>D.map(e=>({value:e.value,label:e.label??String(e.value),disabled:e.disabled})),[D]),[Je,Qe]=l.useState(()=>toArray(X)),Ue=void 0===U?Je:toArray(U),[Xe,Ye]=l.useState(""),Ze=l.useMemo(()=>new Map(Be.map(e=>[e.value,e])),[Be]),ea=l.useCallback(e=>Ze.get(e)??{value:e,label:String(e),custom:!0},[Ze]),aa=Xe.trim(),la=aa.toLocaleLowerCase(),ta=""===aa||Be.some(e=>e.label.toLocaleLowerCase()===la||String(e.value).toLocaleLowerCase()===la)||Ue.some(e=>String(e).toLocaleLowerCase()===la),sa=!ee||he||Pe||ta?null:aa,na=l.useMemo(()=>null===sa?Be:[...Be,{value:sa,label:sa,custom:!0}],[Be,sa]),ra=l.useMemo(()=>i.createItems(na,{getValue:e=>e.value,getLabel:e=>e.label}),[na]),ia=We?Ue:Ue[0]??null,oa=!Pe&&!he,ca=b(oa),da=j(E,De?"":K,N[Fe],F[Fe],P[Fe],We?G[Fe]:w[Fe],`${R[$e][Fe]} pe-1.5`,Pe?C[_]:he?I[_]:S[_],oa?"plass-glow":""),ma=/* @__PURE__ */["min-w-0 flex-1 self-stretch bg-transparent [font:inherit] text-inherit","[outline:none]","placeholder:text-(--plass-muted-fg)","caret-(--p-accent) selection:bg-(--p-soft-press)","disabled:cursor-not-allowed"].join(" "),renderInput=a=>e(i.Input,{ref:je,placeholder:Ee?ne||" ":ne,onKeyDown:h(Ie,void 0),className:j(ma,We&&"min-w-16",We&&a&&"ms-1.5",Ee&&!a&&g)}),pa=e(o.Label,{className:j(k[Fe],"font-semibold",Pe?"text-(--plass-muted-fg)":"text-(--plass-fg)",Se?.label),children:re});return a(o.Root,{disabled:Pe,invalid:Ge,className:j("flex-col align-top",T[Fe],pe?"flex w-full":"inline-flex",Le),style:{...z(He,q),...ze},..._e,children:[A(re)&&!De?pa:null,a(i.Root,{id:Ce,name:fe,items:ra,multiple:We,value:ia,onValueChange:e=>{const a=toArray(e);0===a.length&&0===Ue.length||function commit(e){void 0===U&&Qe(e),Y?.(We?e:e[0]??null)}(a)},onInputValueChange:e=>{Ye(e),Z?.(e)},open:ge,defaultOpen:ve,onOpenChange:e=>xe?.(e),autoHighlight:!0,itemToStringLabel:String,itemToStringValue:String,limit:se,disabled:Pe,readOnly:he,required:be,children:[e(f,{notched:De,size:Fe,density:$e,variant:_,disabled:Pe,readOnly:he,float:Ee,label:pa,children:a(i.InputGroup,{style:De?v:void 0,...ca,className:j(da,Se?.control),children:[me?e("span",{className:"flex h-[1lh] shrink-0 items-center text-(--plass-muted-fg)",children:me}):null,We?e(i.Chips,{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:e(t.Provider,{value:Pe,children:e(i.Value,{children:t=>a(l.Fragment,{children:[t.map(ea).map(a=>e(i.Chip,{render:e(c,{variant:"glass",size:Fe,color:He,density:"compact",disabled:Pe,endIcon:he||Pe?null:e(i.ChipRemove,{"aria-label":Re(a.label),className:y,children:e(p,{})})}),children:a.label},String(a.value))),renderInput(t.length>0)]})})})}):renderInput(!1),!le||he||Pe?null:e(i.Clear,{"aria-label":Me,className:J,children:e(p,{})}),e(i.Trigger,{"aria-label":Ae,"aria-labelledby":void 0,className:B,children:e(i.Icon,{className:j("flex items-center","[transition:rotate_var(--plass-duration)_var(--plass-ease)]","motion-reduce:[transition-duration:0ms]","data-[popup-open]:rotate-180"),children:e(m,{})})})]})}),e(i.Portal,{children:e(i.Positioner,{className:"plass-portal z-(--plass-z-portal) [outline:none]",sideOffset:6,children:a(i.Popup,{className:j(H,F[Fe],N[Fe]),style:$(He,3),children:[e(i.Empty,{className:"px-2 py-1.5 text-(--plass-muted-fg) empty:hidden",children:ke}),e(i.List,{children:t=>e(i.Item,{value:t.value,disabled:t.disabled,className:W,children:t.custom?a(l.Fragment,{children:[e("span",{className:"absolute start-1.5 flex size-4 items-center justify-center text-(--p-accent) [&_svg]:size-4",children:e(u,{})}),e("span",{className:"truncate",children:ae?ae(t.label):Ve.addCustom(t.label)})]}):a(l.Fragment,{children:[e(i.ItemIndicator,{className:"absolute start-1.5 flex size-4 items-center justify-center",children:e(d,{})}),e("span",{className:"truncate",children:t.label})]})},`${t.custom?"custom:":""}${String(t.value)}`)})]})})})]}),oe?e(o.Description,{className:j(L(Fe),Se?.description),children:oe}):null,e(o.Error,Ke?{match:!0,className:j(k[Fe],"text-(--p-accent)",Se?.error),children:ce}:{className:j(k[Fe],"text-(--p-accent)",Se?.error)})]})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as s}from"react/jsx-runtime";import*as a from"react";import{useDefaults as t}from"../../internal/defaults.js";import{useLabels as l}from"../../internal/labels.js";import{Autocomplete as o}from"@base-ui/react/autocomplete";import{Dialog as r}from"@base-ui/react/dialog";import{PlHotKeys as i}from"../hot-keys/PlHotKeys.js";import{usePlHotKeys as n}from"../../hooks/usePlHotKeys.js";import{searchHaystack as c,searchText as p}from"../../internal/search.js";import{controlTextLeadingClasses as d,cx as m,forcedHighlightedClasses as u,glassClasses as h,hasContent as x,metaTextClasses as f,radiusClasses as g,surfaceSlots as y,toLength as b}from"../../internal/styles.js";const
|
|
1
|
+
"use client";import{jsx as e,jsxs as s}from"react/jsx-runtime";import*as a from"react";import{useDefaults as t}from"../../internal/defaults.js";import{useLabels as l}from"../../internal/labels.js";import{Autocomplete as o}from"@base-ui/react/autocomplete";import{Dialog as r}from"@base-ui/react/dialog";import{PlHotKeys as i}from"../hot-keys/PlHotKeys.js";import{usePlHotKeys as n}from"../../hooks/usePlHotKeys.js";import{searchHaystack as c,searchText as p}from"../../internal/search.js";import{controlTextLeadingClasses as d,cx as m,forcedHighlightedClasses as u,glassClasses as h,hasContent as x,metaTextClasses as f,radiusClasses as g,surfaceSlots as y,toLength as b,transitionClasses as v}from"../../internal/styles.js";const w=/* @__PURE__ */["fixed inset-0 z-(--plass-z-portal) bg-(--plass-scrim)","[backdrop-filter:blur(2px)] [-webkit-backdrop-filter:blur(2px)]","[transition:opacity_var(--plass-duration-slow)_var(--plass-ease)]","motion-reduce:[transition-duration:0ms]","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0"].join(" "),k=/* @__PURE__ */[h,"relative flex w-full flex-col overflow-hidden","border text-(--plass-fg) bg-(--plass-glass-press)","[border-color:var(--plass-glass-line)]","[box-shadow:var(--plass-shadow-3),var(--plass-gloss-glass)]","[outline:none]","[transition:opacity_var(--plass-duration-slow)_var(--plass-ease)]","motion-reduce:[transition-duration:0ms]","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0"].join(" "),N={xs:"max-w-sm",sm:"max-w-md",md:"max-w-xl",lg:"max-w-2xl",xl:"max-w-3xl"},j={xs:"h-9",sm:"h-10",md:"h-12",lg:"h-14",xl:"h-16"},P={xs:"py-1",sm:"py-1.5",md:"py-2",lg:"py-2.5",xl:"py-3"},z={xs:"px-2.5",sm:"px-3",md:"px-3.5",lg:"px-4",xl:"px-5"},C=/* @__PURE__ */["flex cursor-pointer items-center gap-3 select-none",v,"data-[highlighted]:bg-(--p-soft-hover) data-[highlighted]:text-(--p-accent)",u,"data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50","data-[disabled]:saturate-[0.35]"].join(" ");function haystackOf(e){return c([e.label,e.group,...e.keywords??[]])}export function PlCommandPalette({items:c,open:u,defaultOpen:h=!1,onOpenChange:v,onSelect:M,shortcut:O="Mod+K",width:S,maxHeight:_=320,placeholder:H,emptyMessage:K,label:R,size:V,color:E,density:F,className:I,classNames:T,style:B}){const D=t(),L=l(),W=R??L.commandPalette,q=H??L.commandPalettePlaceholder,A=K??L.empty,G=V??D.size??"md",J=E??D.color??"primary",Q=F??D.density??"default",[U,X]=a.useState(h),[Y,Z]=a.useState(""),$=u??U,ee=a.useRef($);a.useEffect(()=>{ee.current&&!$&&Z(""),ee.current=$},[$]);const se=a.useCallback(e=>{void 0===u&&X(e),v?.(e)},[u,v]);n(!1===O?void 0:{[O]:()=>se(!0)},{whileTyping:!0});const ae=a.useMemo(()=>c.map(haystackOf),[c]),te=a.useMemo(()=>{const e=p(Y);return""===e?c:c.filter((s,a)=>ae[a].includes(e))},[c,ae,Y]),le=a.useMemo(()=>te.length>100?te.slice(0,100):te,[te]),oe=te.length-le.length,re=b(S),ie=b(_);return e(r.Root,{open:$,onOpenChange:se,children:s(r.Portal,{children:[e(r.Backdrop,{className:m("plass-portal",w,T?.backdrop)}),e(r.Viewport,{className:"plass-portal fixed inset-0 z-(--plass-z-portal) flex justify-center p-4 pt-[12vh]",children:e(r.Popup,{"aria-label":W,className:m(k,g[G],d[G],void 0===re?N[G]:"","self-start",I),style:{...y(J,3),...void 0===re?null:{maxWidth:re},...B},children:s(o.Root,{open:!0,mode:"list",items:le,filter:null,value:Y,onValueChange:e=>Z(e),itemToStringValue:e=>e.label,children:[e("div",{className:m("flex shrink-0 items-center border-b [border-color:var(--plass-glass-line)]",z[G]),children:e(o.Input,{autoFocus:!0,placeholder:q,className:m("min-w-0 flex-1 bg-transparent [font:inherit] text-inherit [outline:none]","placeholder:text-(--plass-muted-fg) caret-(--p-accent)","selection:bg-(--p-soft-press)",j[G])})}),e(o.List,{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain p-1",style:{maxHeight:ie},children:(t,l)=>s(a.Fragment,{children:[t.group&&t.group!==le[l-1]?.group?e("div",{role:"presentation",className:m(z[G],"pt-2 pb-1 font-medium text-(--plass-muted-fg)",f[G]),children:t.group}):null,s(o.Item,{index:l,value:t,disabled:t.disabled,onClick:()=>(e=>{e.disabled||(e.onSelect?.(),M?.(e),se(!1))})(t),className:m(C,g[G],z[G],P["compact"===Q?"xs":G]),children:[x(t.icon)?e("span",{className:"flex h-[1lh] shrink-0 items-center [&_svg]:size-[1.15em]",children:t.icon}):null,s("span",{className:"flex min-w-0 flex-1 flex-col",children:[e("span",{className:"truncate",children:t.label}),x(t.description)?e("span",{className:m("truncate text-(--plass-muted-fg)",f[G]),children:t.description}):null]}),t.shortcut?e(i,{size:"xs",keys:t.shortcut,className:"shrink-0"}):null]})]},t.value)}),oe>0?e("div",{className:m(z[G],"shrink-0 border-t py-2 text-(--plass-muted-fg) [border-color:var(--plass-glass-line)]",f[G]),children:L.chartMore(oe)}):null,e(o.Empty,{className:m(z[G],"py-6 text-center text-(--plass-muted-fg)",f[G]),children:A})]})})})]})})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as n from"react";import{PlButton as o}from"../button/PlButton.js";import{PlModal as t}from"../modal/PlModal.js";import{useLabels as i}from"../../internal/labels.js";const l=/* @__PURE__ */n.createContext(null);export function PlConfirmProvider({size:c,color:s,confirmLabel:u,cancelLabel:a,acknowledgeLabel:d,width:f,children:m}){const h=i(),[p,
|
|
1
|
+
"use client";import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as n from"react";import{PlButton as o}from"../button/PlButton.js";import{PlModal as t}from"../modal/PlModal.js";import{useLabels as i}from"../../internal/labels.js";const l=/* @__PURE__ */n.createContext(null);export function PlConfirmProvider({size:c,color:s,confirmLabel:u,cancelLabel:a,acknowledgeLabel:d,width:f,children:m}){const h=i(),[p,C]=n.useState(!1),[b,v]=n.useState(null),w=n.useRef(null),P=n.useRef([]),k=n.useRef(0),x=n.useCallback(e=>{const r=w.current;if(!r)return;r.resolve(e);const n=P.current.shift();if(n)return w.current=n,void v(n);w.current=null,C(!1)},[]),z=n.useCallback((e,r)=>new Promise(n=>{k.current+=1;const o={id:k.current,kind:e,options:r,resolve:n};w.current?P.current.push(o):(w.current=o,v(o),C(!0))}),[]),j=n.useMemo(()=>({confirm:e=>z("confirm",e),alert:e=>z("alert",e).then(()=>{})}),[z]);n.useEffect(()=>()=>{w.current?.resolve(!1),P.current.forEach(e=>e.resolve(!1)),w.current=null,P.current=[]},[]);const g=b?.options,L="alert"===b?.kind,F="confirm"===(g?.initialFocus??"cancel")||L;return r(l.Provider,{value:j,children:[m,e(t,{open:p,onOpenChange:e=>{e||x(!1)},showClose:!1,size:g?.size??c,color:g?.color??s,width:g?.width??f,dismissible:g?.dismissible??!0,title:g?.title,description:g?.description,actions:r(n.Fragment,{children:[L?null:e(o,{variant:"ghost",color:"secondary",size:g?.size??c,autoFocus:!F,onClick:()=>x(!1),children:g?.cancelLabel??a??h.cancel}),e(o,{color:g?.color??s,size:g?.size??c,autoFocus:F,onClick:()=>x(!0),children:g?.confirmLabel??(L?d??h.acknowledge:u??h.confirm)})]},b?.id),children:g?.children})]})}export function usePlConfirm(){const e=n.useContext(l);if(!e)throw new Error("[plass-ui] usePlConfirm was called outside a <PlConfirmProvider>.");return e}
|
|
@@ -107,7 +107,8 @@ export interface PlDataTableProps<Row> extends PlassStyleProps, Omit<React.Compo
|
|
|
107
107
|
* It defaults to the row's position in `rows`, which survives a sort, a
|
|
108
108
|
* search and a page, and does not survive `rows` changing: a row added at the
|
|
109
109
|
* top moves every other row's key, so a selection made before it belongs to
|
|
110
|
-
* different rows after it.
|
|
110
|
+
* different rows after it. With `manual` paging the position is counted from
|
|
111
|
+
* the first row of the first page, since `rows` is only the page on screen.
|
|
111
112
|
*
|
|
112
113
|
* `index` here, and in every other callback, is that position in `rows`, not
|
|
113
114
|
* the row's place on the screen.
|
|
@@ -115,6 +116,16 @@ export interface PlDataTableProps<Row> extends PlassStyleProps, Omit<React.Compo
|
|
|
115
116
|
getRowKey?: (row: Row, index: number) => React.Key;
|
|
116
117
|
/** Shown above the grid, and read out as the table's accessible name. */
|
|
117
118
|
caption?: React.ReactNode;
|
|
119
|
+
/**
|
|
120
|
+
* The table's accessible name when there is no `caption` — "Invoices",
|
|
121
|
+
* "Exchange rates".
|
|
122
|
+
*
|
|
123
|
+
* It names the `<table>`, and the box the grid scrolls in too: a grid wider
|
|
124
|
+
* than its sheet, or taller than `maxHeight`, is a tab stop while it
|
|
125
|
+
* scrolls, and a stop is announced by its name. A caption is that name when
|
|
126
|
+
* there is one, and this is not read then.
|
|
127
|
+
*/
|
|
128
|
+
label?: string;
|
|
118
129
|
/** What to show instead of rows when there are none left to show. */
|
|
119
130
|
empty?: React.ReactNode;
|
|
120
131
|
/** Tints every other row. @default false */
|
|
@@ -213,4 +224,4 @@ export interface PlDataTableProps<Row> extends PlassStyleProps, Omit<React.Compo
|
|
|
213
224
|
* Not a `forwardRef`, for `PlTable`'s reason: a component wrapped in
|
|
214
225
|
* `React.forwardRef` loses its type parameter, and `Row` is the whole point.
|
|
215
226
|
*/
|
|
216
|
-
export declare function PlDataTable<Row>({ variant, size: sizeProp, color: colorProp, density: densityProp, elevation, columns, rows, getRowKey, caption, empty: emptyProp, striped, hoverable, stickyHeader, maxHeight, onRowClick, sort: sortProp, defaultSort, onSortChange, searchable, search: searchProp, defaultSearch, onSearchChange, searchPlaceholder, selection, selected: selectedProp, defaultSelected, onSelectedChange, isRowSelectable, paging, pageSize, page: pageProp, defaultPage, onPageChange, rowCount, manual, loading, toolbar, footer, className, style, ...props }: PlDataTableProps<Row>): React.JSX.Element;
|
|
227
|
+
export declare function PlDataTable<Row>({ variant, size: sizeProp, color: colorProp, density: densityProp, elevation, columns, rows, getRowKey, caption, label, empty: emptyProp, striped, hoverable, stickyHeader, maxHeight, onRowClick, sort: sortProp, defaultSort, onSortChange, searchable, search: searchProp, defaultSearch, onSearchChange, searchPlaceholder, selection, selected: selectedProp, defaultSelected, onSelectedChange, isRowSelectable, paging, pageSize, page: pageProp, defaultPage, onPageChange, rowCount, manual, loading, toolbar, footer, className, style, ...props }: PlDataTableProps<Row>): React.JSX.Element;
|