material-plus-ui 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/a2ui/extended/api.d.ts +4 -4
- package/dist/components/accordion/MPAccordion.d.ts +13 -0
- package/dist/components/accordion/MPAccordion.js +1 -1
- package/dist/components/accordion/index.d.ts +1 -1
- package/dist/components/animate-counter/MPAnimateCounter.js +1 -1
- package/dist/components/animate-headline/MPAnimateHeadline.d.ts +8 -0
- package/dist/components/animate-headline/MPAnimateHeadline.js +1 -1
- package/dist/components/animate-lighting/MPAnimateLighting.js +1 -1
- package/dist/components/animate-marquee/MPAnimateMarquee.js +1 -1
- package/dist/components/animate-scramble/MPAnimateScramble.d.ts +8 -0
- package/dist/components/animate-scramble/MPAnimateScramble.js +1 -1
- package/dist/components/animate-split/MPAnimateSplit.d.ts +8 -0
- package/dist/components/animate-split/MPAnimateSplit.js +1 -1
- package/dist/components/animate-typing/MPAnimateTyping.d.ts +10 -2
- package/dist/components/animate-typing/MPAnimateTyping.js +1 -1
- package/dist/components/app-logo/MPAppLogo.d.ts +6 -1
- package/dist/components/area-chart/MPAreaChart.js +1 -1
- package/dist/components/avatar/MPAvatar.d.ts +16 -0
- package/dist/components/avatar/MPAvatar.js +1 -1
- package/dist/components/bar-chart/MPBarChart.js +1 -1
- package/dist/components/breadcrumb/MPBreadcrumb.d.ts +8 -0
- package/dist/components/breadcrumb/MPBreadcrumb.js +1 -1
- package/dist/components/carousel/MPCarousel.js +1 -1
- package/dist/components/checkbox/MPCheckbox.js +1 -1
- package/dist/components/code-block/MPCodeBlock.js +1 -1
- package/dist/components/combobox/MPCombobox.js +1 -1
- package/dist/components/command-palette/MPCommandPalette.js +1 -1
- package/dist/components/config/MPConfigProvider.d.ts +17 -1
- package/dist/components/config/MPConfigProvider.js +1 -1
- package/dist/components/confirm/MPConfirmProvider.js +1 -1
- package/dist/components/data-table/MPDataTable.d.ts +0 -34
- package/dist/components/data-table/MPDataTable.js +1 -1
- package/dist/components/date-range-picker/MPDateRangePicker.js +1 -1
- package/dist/components/drawer/MPDrawer.d.ts +13 -1
- package/dist/components/drawer/MPDrawer.js +1 -1
- package/dist/components/file-picker/MPFilePicker.js +1 -1
- package/dist/components/form/MPForm.d.ts +3 -0
- package/dist/components/form/MPForm.js +1 -1
- package/dist/components/gauge-chart/MPGaugeChart.js +1 -1
- package/dist/components/header/MPHeader.js +1 -1
- package/dist/components/heatmap-chart/MPHeatmapChart.js +1 -1
- package/dist/components/image/MPImage.d.ts +5 -0
- package/dist/components/image/MPImage.js +1 -1
- package/dist/components/line-chart/MPLineChart.js +1 -1
- package/dist/components/locale/MPLocaleProvider.d.ts +15 -30
- package/dist/components/locale/MPLocaleProvider.js +1 -1
- package/dist/components/menu/MPMenu.d.ts +9 -1
- package/dist/components/menu/MPMenu.js +1 -1
- package/dist/components/meter/MPMeter.d.ts +5 -0
- package/dist/components/meter/MPMeter.js +1 -1
- package/dist/components/mockup/MPMockup.js +1 -1
- package/dist/components/navigation-menu/MPNavigationMenu.d.ts +27 -1
- package/dist/components/navigation-menu/MPNavigationMenu.js +1 -1
- package/dist/components/number-field/MPNumberField.d.ts +2 -1
- package/dist/components/number-field/MPNumberField.js +1 -1
- package/dist/components/otp-field/MPOtpField.js +1 -1
- package/dist/components/page-layout/MPPageLayout.js +1 -1
- package/dist/components/pagination/MPPagination.d.ts +8 -0
- package/dist/components/pagination/MPPagination.js +1 -1
- package/dist/components/panes/MPPanes.js +1 -1
- package/dist/components/pie-chart/MPPieChart.js +1 -1
- package/dist/components/pill/MPPill.js +1 -1
- package/dist/components/progress-box/MPProgressBox.js +1 -1
- package/dist/components/progress-circular/MPProgressCircular.js +1 -1
- package/dist/components/progress-linear/MPProgressLinear.js +1 -1
- package/dist/components/radio-group/MPRadioGroup.js +1 -1
- package/dist/components/scatter-chart/MPScatterChart.js +1 -1
- package/dist/components/sidebar/MPSidebar.d.ts +11 -0
- package/dist/components/sidebar/MPSidebar.js +1 -1
- package/dist/components/slider/MPSlider.d.ts +5 -0
- package/dist/components/slider/MPSlider.js +1 -1
- package/dist/components/snackbar/MPSnackbar.js +1 -1
- package/dist/components/switch/MPSwitch.js +1 -1
- package/dist/components/tabs/MPTabs.js +1 -1
- package/dist/components/text-field/MPTextField.js +1 -1
- package/dist/components/timeline-chart/MPTimelineChart.js +1 -1
- package/dist/components/tour/MPTour.js +1 -1
- package/dist/components/transfer/MPTransfer.js +1 -1
- package/dist/components/tree-select/MPTreeSelect.js +1 -1
- package/dist/components/tree-view/MPTreeView.d.ts +8 -0
- package/dist/components/tree-view/MPTreeView.js +1 -1
- package/dist/hooks/index.d.ts +4 -2
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/mpColorSchemeScript.d.ts +46 -0
- package/dist/hooks/mpColorSchemeScript.js +1 -0
- package/dist/hooks/useMPColorScheme.d.ts +2 -47
- package/dist/hooks/useMPColorScheme.js +1 -1
- package/dist/hooks/useMPMediaQuery.js +1 -1
- package/dist/hooks/useMPOnScreen.js +1 -1
- package/dist/internal/Calendar.js +1 -1
- package/dist/internal/ChartChrome.d.ts +11 -2
- package/dist/internal/ChartChrome.js +1 -1
- package/dist/internal/ChartFrame.js +1 -1
- package/dist/internal/FieldOutline.d.ts +9 -1
- package/dist/internal/FieldOutline.js +1 -1
- package/dist/internal/RenderedLink.d.ts +20 -0
- package/dist/internal/RenderedLink.js +2 -0
- package/dist/internal/SupportingText.js +1 -1
- package/dist/internal/animate.d.ts +4 -0
- package/dist/internal/animate.js +1 -1
- package/dist/internal/box-size.d.ts +22 -0
- package/dist/internal/box-size.js +2 -0
- package/dist/internal/chart.d.ts +21 -11
- package/dist/internal/chart.js +1 -1
- package/dist/internal/color-scheme-keys.d.ts +13 -0
- package/dist/internal/color-scheme-keys.js +1 -0
- package/dist/internal/color-scheme.d.ts +11 -2
- package/dist/internal/color-scheme.js +1 -1
- package/dist/internal/config.d.ts +2 -0
- package/dist/internal/date.d.ts +2 -8
- package/dist/internal/date.js +1 -1
- package/dist/internal/highlight.js +1 -1
- package/dist/internal/i18n.d.ts +0 -53
- package/dist/internal/i18n.js +1 -1
- package/dist/internal/intersection.d.ts +50 -0
- package/dist/internal/intersection.js +2 -0
- package/dist/internal/intl.d.ts +22 -21
- package/dist/internal/intl.js +1 -1
- package/dist/internal/keys.d.ts +0 -9
- package/dist/internal/keys.js +1 -1
- package/dist/internal/layout-effect.d.ts +7 -0
- package/dist/internal/layout-effect.js +2 -0
- package/dist/internal/locale.d.ts +10 -2
- package/dist/internal/media.d.ts +1 -0
- package/dist/internal/media.js +1 -0
- package/dist/internal/occurrence.d.ts +18 -0
- package/dist/internal/occurrence.js +1 -0
- package/dist/internal/page-layout.js +1 -1
- package/dist/internal/progress.d.ts +5 -0
- package/dist/internal/ref.d.ts +9 -0
- package/dist/internal/ref.js +1 -0
- package/dist/internal/remember.d.ts +36 -0
- package/dist/internal/remember.js +1 -0
- package/dist/internal/surface.d.ts +7 -1
- package/dist/internal/surface.js +1 -1
- package/dist/internal/text.d.ts +10 -4
- package/dist/internal/text.js +1 -1
- package/dist/internal/window-class.d.ts +8 -0
- package/dist/internal/window-class.js +1 -1
- package/dist/styles/accordion.css +1 -1
- package/dist/styles/alert.css +1 -1
- package/dist/styles/animate-appear.css +1 -1
- package/dist/styles/animate-blink.css +1 -1
- package/dist/styles/animate-counter.css +1 -1
- package/dist/styles/animate-fade.css +1 -1
- package/dist/styles/animate-float.css +1 -1
- package/dist/styles/animate-grow.css +1 -1
- package/dist/styles/animate-headline.css +1 -1
- package/dist/styles/animate-lighting.css +1 -1
- package/dist/styles/animate-marquee.css +1 -1
- package/dist/styles/animate-reveal.css +1 -1
- package/dist/styles/animate-rotate.css +1 -1
- package/dist/styles/animate-scramble.css +1 -1
- package/dist/styles/animate-shake.css +1 -1
- package/dist/styles/animate-slide.css +1 -1
- package/dist/styles/animate-split.css +1 -1
- package/dist/styles/animate-typing.css +1 -1
- package/dist/styles/animate-zoom.css +1 -1
- package/dist/styles/avatar.css +1 -1
- package/dist/styles/blockquote.css +1 -1
- package/dist/styles/box.css +1 -1
- package/dist/styles/breadcrumb.css +1 -1
- package/dist/styles/calendar.css +1 -1
- package/dist/styles/card.css +1 -1
- package/dist/styles/carousel.css +1 -1
- package/dist/styles/checkbox.css +1 -1
- package/dist/styles/chip.css +1 -1
- package/dist/styles/collapsible.css +1 -1
- package/dist/styles/color-picker.css +1 -1
- package/dist/styles/combobox.css +1 -1
- package/dist/styles/command-palette.css +1 -1
- package/dist/styles/confirm.css +1 -1
- package/dist/styles/data-table.css +1 -1
- package/dist/styles/date-picker.css +1 -1
- package/dist/styles/date-range-picker.css +1 -1
- package/dist/styles/date-time-picker.css +1 -1
- package/dist/styles/dialog.css +1 -1
- package/dist/styles/drawer.css +1 -1
- package/dist/styles/empty.css +1 -1
- package/dist/styles/floating-bottom-navigation.css +1 -1
- package/dist/styles/footer.css +1 -1
- package/dist/styles/gauge-chart.css +1 -1
- package/dist/styles/header.css +1 -1
- package/dist/styles/highlight.css +1 -1
- package/dist/styles/hover-card.css +1 -1
- package/dist/styles/image.css +1 -1
- package/dist/styles/list.css +1 -1
- package/dist/styles/menu.css +1 -1
- package/dist/styles/menubar.css +1 -1
- package/dist/styles/meter.css +1 -1
- package/dist/styles/navigation-menu.css +1 -1
- package/dist/styles/number-field.css +1 -1
- package/dist/styles/otp-field.css +1 -1
- package/dist/styles/overlay.css +1 -1
- package/dist/styles/page-layout.css +1 -1
- package/dist/styles/pill.css +1 -1
- package/dist/styles/popconfirm.css +1 -1
- package/dist/styles/popover.css +1 -1
- package/dist/styles/progress-box.css +1 -1
- package/dist/styles/progress-circular.css +1 -1
- package/dist/styles/progress-linear.css +1 -1
- package/dist/styles/radio-group.css +1 -1
- package/dist/styles/select.css +1 -1
- package/dist/styles/sidebar.css +1 -1
- package/dist/styles/slider.css +1 -1
- package/dist/styles/snackbar.css +1 -1
- package/dist/styles/spoiler.css +1 -1
- package/dist/styles/stack.css +1 -1
- package/dist/styles/switch.css +1 -1
- package/dist/styles/table.css +1 -1
- package/dist/styles/tabs.css +1 -1
- package/dist/styles/text-field.css +1 -1
- package/dist/styles/time-picker.css +1 -1
- package/dist/styles/tokens.css +1 -1
- package/dist/styles/toolbar.css +1 -1
- package/dist/styles/tour.css +1 -1
- package/dist/styles/transfer.css +1 -1
- package/dist/styles/tree-select.css +1 -1
- package/dist/styles/tree-view.css +1 -1
- package/dist/styles/typography.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +116 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ It also goes on past where the specification stops. The button ladder keeps the
|
|
|
23
23
|
- **IME-safe by construction.** Korean, Japanese and Chinese composition survives whatever your `onChange` does with the value.
|
|
24
24
|
- **Bring your own icons.** `MPIcon` takes a component or an element from any set. `lucide-react` ships with the package, gathered in one readable constants file.
|
|
25
25
|
- **Works in a Next.js server component**, and in any bundler: the components carry `"use client"`, the barrel and the data do not, and every specifier in `dist/` names a file — so webpack, Vite, esbuild, Rollup and plain Node all resolve it.
|
|
26
|
-
- **ESM only**, TypeScript declarations included, and tree-shakeable for real: one component is 3.8 kB gzipped and five are 9.
|
|
26
|
+
- **ESM only**, TypeScript declarations included, and tree-shakeable for real: one component is 3.8 kB gzipped and five are 9.9 kB, against 137.5 kB for every export there is. `npm run measure` prints those numbers off a real bundler, so they cannot quietly stop being true. The stylesheet splits the same way.
|
|
27
27
|
- **Two runtime dependencies**, and the second is loaded rather than bundled: `lucide-react` for the glyphs, and `highlight.js` behind `MPCodeBlock` — every grammar sits behind an `import()`, so a page that renders no code block never downloads one. React 18 or 19, Node.js 22 or later.
|
|
28
28
|
|
|
29
29
|
## Documentation
|
|
@@ -79,7 +79,7 @@ If Tailwind v4 is already in your project, import the token sheet instead:
|
|
|
79
79
|
@import 'material-plus-ui/tailwind.css';
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
-
A page that renders a handful of components can take the tokens and a sheet each instead of the whole
|
|
82
|
+
A page that renders a handful of components can take the tokens and a sheet each instead of the whole 174.3 kB — 6.3 kB gzipped for one component against 23.7 kB for the lot. [The guide](https://material-plus.cdget.com/guide/getting-started#if-you-only-render-a-few-components) has the numbers and where the two paths cross.
|
|
83
83
|
|
|
84
84
|
```ts
|
|
85
85
|
import 'material-plus-ui/styles/tokens.css';
|
|
@@ -252,11 +252,11 @@ export declare const DataTableApi: {
|
|
|
252
252
|
paged?: boolean | undefined;
|
|
253
253
|
pageSize?: number | undefined;
|
|
254
254
|
striped?: boolean | undefined;
|
|
255
|
+
rowKey?: string | undefined;
|
|
256
|
+
selection?: "none" | "multiple" | "single" | undefined;
|
|
255
257
|
selectedKeys?: string[] | {
|
|
256
258
|
path: string;
|
|
257
259
|
} | undefined;
|
|
258
|
-
rowKey?: string | undefined;
|
|
259
|
-
selection?: "none" | "multiple" | "single" | undefined;
|
|
260
260
|
accessibility?: {
|
|
261
261
|
label?: string | {
|
|
262
262
|
path: string;
|
|
@@ -308,11 +308,11 @@ export declare const DataTableApi: {
|
|
|
308
308
|
paged?: boolean | undefined;
|
|
309
309
|
pageSize?: number | undefined;
|
|
310
310
|
striped?: boolean | undefined;
|
|
311
|
+
rowKey?: string | undefined;
|
|
312
|
+
selection?: "none" | "multiple" | "single" | undefined;
|
|
311
313
|
selectedKeys?: string[] | {
|
|
312
314
|
path: string;
|
|
313
315
|
} | undefined;
|
|
314
|
-
rowKey?: string | undefined;
|
|
315
|
-
selection?: "none" | "multiple" | "single" | undefined;
|
|
316
316
|
accessibility?: {
|
|
317
317
|
label?: string | {
|
|
318
318
|
path: string;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { MPDensity, MPSize, MPElevation, MPVariant } from '../../types.js';
|
|
3
|
+
/** The heading level each section's title is written at. */
|
|
4
|
+
export type MPAccordionHeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
3
5
|
export interface MPAccordionProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'defaultValue' | 'onChange'> {
|
|
4
6
|
/**
|
|
5
7
|
* Whether more than one section may be open at once.
|
|
@@ -68,6 +70,17 @@ export interface MPAccordionProps extends Omit<React.ComponentPropsWithoutRef<'d
|
|
|
68
70
|
* @default false
|
|
69
71
|
*/
|
|
70
72
|
keepMounted?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* The heading level each section's title is written at.
|
|
75
|
+
*
|
|
76
|
+
* Each title is a heading, because a section of a page is what it names, and
|
|
77
|
+
* the level is the page's to decide: an accordion of questions under an `h2`
|
|
78
|
+
* is a run of `h3`s, and the same accordion under an `h3` is a run of `h4`s.
|
|
79
|
+
* A level that skips one breaks the outline a screen reader navigates by and a
|
|
80
|
+
* search engine reads the page's structure from.
|
|
81
|
+
* @default 3
|
|
82
|
+
*/
|
|
83
|
+
headingLevel?: MPAccordionHeadingLevel;
|
|
71
84
|
/** The `MPAccordionItem`s. */
|
|
72
85
|
children?: React.ReactNode;
|
|
73
86
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{Accordion as i}from"@base-ui/react/accordion";import{MPIcon as a}from"../icon/MPIcon.js";import{ChevronDownIcon as r}from"../../constants/icons.js";import{MPStateLayer as o}from"../../internal/StateLayer.js";import{CONTROL_GAP as s,CONTROL_ICON as l,hasContent as d,META_TEXT as c,PROSE_TEXT as m,SHEET_TITLE as u}from"../../internal/scale.js";import{sheetPadX as p,sheetPadY as f}from"../../internal/density.js";import{containerSurface as h}from"../../internal/elevation.js";import{useMPDensity as v,useMPSize as x}from"../../internal/config.js";const b=/*@__PURE__*/n.createContext({size:"md",density:0,dividers:!0}),g=/*@__PURE__*/["h-(--accordion-panel-height) overflow-hidden","transition-[height] duration-(--mp-sys-motion-duration-short4) ease-mp-standard","motion-reduce:transition-none","data-starting-style:h-0 data-ending-style:h-0"].join(" ");const
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{Accordion as i}from"@base-ui/react/accordion";import{MPIcon as a}from"../icon/MPIcon.js";import{ChevronDownIcon as r}from"../../constants/icons.js";import{MPStateLayer as o}from"../../internal/StateLayer.js";import{CONTROL_GAP as s,CONTROL_ICON as l,hasContent as d,META_TEXT as c,PROSE_TEXT as m,SHEET_TITLE as u}from"../../internal/scale.js";import{sheetPadX as p,sheetPadY as f}from"../../internal/density.js";import{containerSurface as h}from"../../internal/elevation.js";import{useMPDensity as v,useMPSize as x}from"../../internal/config.js";const b=/*@__PURE__*/n.createContext({size:"md",density:0,dividers:!0,headingLevel:3}),g={1:e("h1",{}),2:e("h2",{}),3:e("h3",{}),4:e("h4",{}),5:e("h5",{}),6:e("h6",{})},j=/*@__PURE__*/["h-(--accordion-panel-height) overflow-hidden","transition-[height] duration-(--mp-sys-motion-duration-short4) ease-mp-standard","motion-reduce:transition-none","data-starting-style:h-0 data-ending-style:h-0"].join(" ");const N={xs:"pb-2.5",sm:"pb-3",md:"pb-4",lg:"pb-5",xl:"pb-6"};export const MPAccordion=/*@__PURE__*/n.forwardRef(function({multiple:t=!1,value:a,defaultValue:r,onValueChange:o,dividers:s=!0,disabled:l=!1,variant:d="outlined",elevation:c,size:m,density:u,hiddenUntilFound:p=!1,keepMounted:f=!1,headingLevel:g=3,className:j,children:N,...y},w){const _=x(m),k=v(u),z=n.useMemo(()=>({size:_,density:k,dividers:s,headingLevel:g}),[_,k,s,g]);return e(b.Provider,{value:z,children:e(i.Root,{ref:w,multiple:t,value:a,defaultValue:r,onValueChange:e=>o?.(e),disabled:l,hiddenUntilFound:p,keepMounted:f,"data-mp-size":_,"data-mp-variant":d,className:["mp-accordion rounded-mp-md flex w-full flex-col",h(d,c),"text-mp-on-surface",s?"overflow-hidden [&>div+div]:border-mp-outline-variant [&>div+div]:border-t":"p-1",j??""].filter(Boolean).join(" "),...y,children:N})})});export const MPAccordionItem=/*@__PURE__*/n.forwardRef(function({value:h,title:v,subtitle:x,startIcon:y,action:w,disabled:_=!1,className:k,children:z,...C},M){const{size:A,density:L,dividers:P,headingLevel:B}=n.useContext(b),I=p(A,L),R=f(A,L),V=n.useRef(null),[F,S]=n.useState(!1),$=n.useCallback(e=>{var t;V.current=e,e&&S(e.hasAttribute("data-open")&&!((t=e).hasAttribute("data-starting-style")&&parseFloat(getComputedStyle(t).transitionDuration)>0))},[]);return t(i.Item,{ref:M,value:h,disabled:_,className:["mp-accordion__item flex flex-col",k??""].filter(Boolean).join(" "),...C,children:[t(i.Header,{render:g[B]??g[3],className:"m-0 flex w-full items-center font-[inherit]",children:[t(i.Trigger,{className:["group relative flex min-w-0 flex-1 cursor-pointer items-center text-start","appearance-none border-0 bg-transparent font-[inherit] text-inherit",I,R,s[A],P?"":"rounded-mp-sm","outline-mp-secondary focus-visible:outline-2 focus-visible:-outline-offset-2","focus-visible:outline-solid outline-none","disabled:text-mp-on-surface/38 disabled:cursor-default"].filter(Boolean).join(" "),children:[e(o,{}),d(y)?e("span",{className:"text-mp-on-surface-variant flex h-[1lh] shrink-0 items-center",children:y}):null,t("span",{className:"mp-accordion__text flex min-w-0 flex-1 flex-col",children:[d(v)?e("span",{className:`mp-accordion__title truncate ${u[A]}`,children:v}):null,d(x)?e("span",{className:`mp-accordion__subtitle text-mp-on-surface-variant truncate ${c}`,children:x}):null]}),e("span",{className:["text-mp-on-surface-variant flex h-[1lh] shrink-0 items-center","transition-[rotate] duration-(--mp-sys-motion-duration-short4)","ease-mp-standard motion-reduce:transition-none","group-data-panel-open:rotate-180"].join(" "),children:e(a,{icon:r,size:l[A]})})]}),d(w)?e("span",{className:`flex shrink-0 items-center ${I}`,children:w}):null]}),e(i.Panel,{ref:$,className:[j,F?"data-open:overflow-visible":""].filter(Boolean).join(" "),onTransitionEnd:e=>{e.target===V.current&&"height"===e.propertyName&&S(V.current.hasAttribute("data-open"))},children:e("div",{className:["min-w-0",m[A],"text-mp-on-surface-variant",I,N[A]].join(" "),children:z})})]})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { MPAccordion, MPAccordionItem } from './MPAccordion.js';
|
|
2
|
-
export type { MPAccordionItemProps, MPAccordionProps } from './MPAccordion.js';
|
|
2
|
+
export type { MPAccordionHeadingLevel, MPAccordionItemProps, MPAccordionProps } from './MPAccordion.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{numberFormatter as a}from"../../internal/intl.js";import{useAnimateElement as
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{watchIntersection as r}from"../../internal/intersection.js";import{numberFormatter as a}from"../../internal/intl.js";import{useMPLocale as i}from"../../internal/locale.js";import{useAnimateElement as s}from"../../internal/animate.js";import{VISUALLY_HIDDEN as o}from"../../internal/visually-hidden.js";export const MPAnimateCounter=/*@__PURE__*/n.forwardRef(function({value:l,from:m=0,options:u,locale:c,format:f,duration:p,delay:d=0,easing:y,paused:g,trigger:h="mount",play:j,once:N=!0,threshold:v=.2,timeline:A,range:F,className:S,style:b,...q},x){const C=s({effect:"count",effectClass:"mp-anim-count",duration:p,delay:d,easing:y,repeat:1,from:m,to:l,trigger:h,play:j,once:N,threshold:v,paused:g,infinite:!1,timeline:A,range:F}),w=i(c),I=f??(e=>a(w,u).format(e)),O=n.useRef(null),[P,R]=n.useState(m),B=JSON.stringify(C.style),E=C.props["data-mp-state"],J=C.run;return n.useEffect(()=>{const e=O.current;if(!e||"undefined"==typeof requestAnimationFrame)return;let t=0,n=!0;const a="view"===A&&CSS.supports("animation-timeline","view()");let i=!0;const s=()=>{if(t=0,!n)return;const r=e.getAnimations().filter(e=>"mp-anim-count"===e.animationName),o=r.every(e=>"finished"===e.playState),m=r.length>0&&r.every(e=>"paused"===e.playState);if(0===r.length||o&&!a)R(l);else{const t=Number.parseFloat(getComputedStyle(e).getPropertyValue("--mp-count"));Number.isFinite(t)&&R(t)}r.length>0&&!m&&(a?i:!o)&&(t=requestAnimationFrame(s))};t=requestAnimationFrame(s);const o=a&&"undefined"!=typeof IntersectionObserver?r(e,e=>{i=e.isIntersecting,0===t&&(t=requestAnimationFrame(s))}):null;return()=>{n=!1,cancelAnimationFrame(t),o?.()}},[B,E,J,A,l]),t("span",{ref:e=>{O.current=e,C.ref(e),"function"==typeof x?x(e):x&&(x.current=e)},className:[C.className,S].filter(Boolean).join(" "),style:{...C.style,...b},...C.props,...q,children:[e("span",{className:o,children:I(l)}),e("span",{"aria-hidden":"true",className:"tabular-nums",children:I(P)})]})});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
2
3
|
import type { MPAnimateProps } from '../../types.js';
|
|
3
4
|
export interface MPAnimateHeadlineProps extends Omit<MPAnimateProps, 'alternate'>, React.ComponentPropsWithoutRef<'div'> {
|
|
4
5
|
/**
|
|
@@ -34,6 +35,13 @@ export interface MPAnimateHeadlineProps extends Omit<MPAnimateProps, 'alternate'
|
|
|
34
35
|
rise?: number | string;
|
|
35
36
|
/** The lines, in the order they should be read. */
|
|
36
37
|
children?: React.ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* Renders something other than a `<div>` — a `<span>` to sit inside a
|
|
40
|
+
* paragraph, where a `<div>` would end the paragraph in the server's markup
|
|
41
|
+
* and leave the browser's tree disagreeing with React's. Base UI's own escape
|
|
42
|
+
* hatch, as on `MPAnimateFade`.
|
|
43
|
+
*/
|
|
44
|
+
render?: useRender.RenderProp;
|
|
37
45
|
}
|
|
38
46
|
/**
|
|
39
47
|
* One line replacing the one above it, on a timer.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e}from"react/jsx-runtime";import*as
|
|
2
|
+
import{jsx as e,Fragment as t}from"react/jsx-runtime";import*as n from"react";import{useRender as r}from"@base-ui/react/use-render";import{easingValue as a,isInfinite as i,lengthValue as s,useAnimationRun as o,usePrefersReducedMotion as l}from"../../internal/animate.js";export const MPAnimateHeadline=/*@__PURE__*/n.forwardRef(function({duration:m,delay:u=0,easing:c,repeat:d="infinite",paused:f,trigger:p="mount",play:h,once:g=!0,threshold:v=.2,interval:x=2600,index:y,defaultIndex:j=0,onIndexChange:E,loop:N=!0,rise:T="100%",render:_,className:C,style:M,children:R,...b},k){const A=o({trigger:p,play:h,once:g,threshold:v,paused:f,infinite:i(d)}),B=l(),I=n.Children.toArray(R),S=I.length,[w,F]=n.useState(j),H=Math.min(y??w,Math.max(S-1,0)),[P,V]=n.useState(null),$=n.useRef(H);n.useEffect(()=>{$.current!==H&&(V($.current),$.current=H)},[H]);const q=m??500;n.useEffect(()=>{if(null===P)return;const e=setTimeout(()=>V(null),q);return()=>clearTimeout(e)},[P,q]);const z=n.useCallback(()=>{const e=H+1;if(e>=S){if(!N)return;return void 0===y&&F(0),void E?.(0)}void 0===y&&F(e),E?.(e)},[H,S,N,y,E]),D=n.useRef(!1);return n.useEffect(()=>{if(void 0!==y||S<2||"running"!==A.state)return;if(!N&&H===S-1)return;const e=setTimeout(()=>{D.current=!0,z()},x+(D.current?0:u));return()=>clearTimeout(e)},[y,S,A.state,x,u,z,N,H]),r({render:_,ref:[k,A.ref],props:{className:["mp-headline",C??""].filter(Boolean).join(" "),style:{...void 0===m?{}:{"--_mp-anim-duration":`${m}ms`},"--_mp-anim-rise":s(T),...c?{"--_mp-anim-ease":a(c)}:{},"--_mp-anim-state":A.state,...M},"data-mp-animation":"headline","data-mp-state":A.state,...A.handlers,...b,children:e(t,{children:I.map((t,r)=>{const a=r===H?"active":r!==P||B?void 0:"leaving";if(!n.isValidElement(t))return e("span",{className:"mp-headline-item","data-mp-state":a,children:t},r);const i=t.props;return n.cloneElement(t,{key:r,className:["mp-headline-item",i.className].filter(Boolean).join(" "),"data-mp-state":a})})})}})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import*as e from"react";import{useRender as r}from"@base-ui/react/use-render";import{accentSlots as
|
|
2
|
+
import*as e from"react";import{useRender as r}from"@base-ui/react/use-render";import{accentSlots as n}from"../../internal/accent.js";import{isInfinite as a,repeatValue as t,useAnimationRun as i}from"../../internal/animate.js";import{useMPColor as m,useMPSize as o}from"../../internal/config.js";import{useOffscreenPause as s}from"../../internal/intersection.js";const l={xs:"rounded-mp-xs",sm:"rounded-mp-sm",md:"rounded-mp-md",lg:"rounded-mp-lg",xl:"rounded-mp-xl"};export const MPAnimateLighting=/*@__PURE__*/e.forwardRef(function({duration:e=3e3,delay:p=0,repeat:d="infinite",alternate:c,paused:g,trigger:u="mount",play:f,once:h=!0,threshold:_=.2,color:x,size:y,spread:j=3,arc:w=50,blur:$=4,reverse:b=!1,render:v,className:z,style:N,children:A,...B},L){const M=m(x),P=o(y),R=i({trigger:u,play:f,once:h,threshold:_,paused:g,infinite:a(d)}),k=s(a(d));return r({render:v,ref:[L,R.ref,k],props:{...B,"data-mp-size":P,className:["mp-anim-lighting",l[P],z].filter(Boolean).join(" "),style:{...n(M),"--_mp-anim-duration":`${e}ms`,"--_mp-anim-delay":`${p}ms`,"--_mp-anim-repeat":t(d),"--_mp-anim-direction":b?c?"alternate-reverse":"reverse":c?"alternate":"normal","--_mp-anim-state":R.state,"--_mp-anim-glow-width":`${j}px`,"--_mp-anim-glow-arc":`${w}deg`,"--_mp-anim-glow-blur":`${$}px`,...N},...R.handlers,"data-mp-animation":"lighting","data-mp-state":R.state,children:A}})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e}from"react/jsx-runtime";import*as r from"react";import{easingValue as t,isInfinite as a,lengthValue as n,repeatValue as i,useAnimationRun as o}from"../../internal/animate.js";import{inertProps as s}from"../../internal/inert.js";export const MPAnimateMarquee=/*@__PURE__*/r.forwardRef(function({duration:m,delay:p=0,easing:l,repeat:u="infinite",alternate:c,paused:d,trigger:f="mount",play:h,once:v=!0,threshold:g=.2,orientation:y="horizontal",reverse:_=!1,speed:j=60,gap:q="2rem",copies:R=2,pauseOnHover:b=!0,className:x,style:M,children:w,...z},N){const O=o({trigger:f,play:h,once:v,threshold:g,paused:d,infinite:a(u)}),A=r.useRef(null),G=r.useRef(null),[H,S]=r.useState(0),$="vertical"===y;r.useEffect(()=>{const e=A.current,r=G.current;if(!e||!r)return;const t=()=>{const t=getComputedStyle(e),a=parseFloat($?t.rowGap:t.columnGap)||0,n=$?r.offsetHeight:r.offsetWidth;S(n+a)};if(t(),"undefined"==typeof ResizeObserver)return;const a=new ResizeObserver(t);return a.observe(r),a.observe(e),()=>a.disconnect()},[$,
|
|
2
|
+
import{jsx as e}from"react/jsx-runtime";import*as r from"react";import{easingValue as t,isInfinite as a,lengthValue as n,repeatValue as i,useAnimationRun as o}from"../../internal/animate.js";import{inertProps as s}from"../../internal/inert.js";export const MPAnimateMarquee=/*@__PURE__*/r.forwardRef(function({duration:m,delay:p=0,easing:l,repeat:u="infinite",alternate:c,paused:d,trigger:f="mount",play:h,once:v=!0,threshold:g=.2,orientation:y="horizontal",reverse:_=!1,speed:j=60,gap:q="2rem",copies:R=2,pauseOnHover:b=!0,className:x,style:M,children:w,...z},N){const O=o({trigger:f,play:h,once:v,threshold:g,paused:d,infinite:a(u)}),A=r.useRef(null),G=r.useRef(null),[H,S]=r.useState(0),$="vertical"===y;r.useEffect(()=>{const e=A.current,r=G.current;if(!e||!r)return;const t=()=>{const t=getComputedStyle(e),a=parseFloat($?t.rowGap:t.columnGap)||0,n=$?r.offsetHeight:r.offsetWidth;S(n+a)};if(t(),"undefined"==typeof ResizeObserver)return;const a=new ResizeObserver(t);return a.observe(r),a.observe(e),()=>a.disconnect()},[$,q]);const k=m??(H>0?H/j*1e3:12e3);return e("div",{ref:e=>{A.current=e,O.ref(e),"function"==typeof N?N(e):N&&(N.current=e)},className:["mp-marquee",$?"mp-marquee-vertical":"",x??""].filter(Boolean).join(" "),style:{"--_mp-anim-gap":n(q),...l?{"--_mp-anim-ease":t(l)}:{},"--_mp-anim-duration":`${Math.round(k)}ms`,"--_mp-anim-delay":`${p}ms`,"--_mp-anim-repeat":i(u),"--_mp-anim-direction":_?c?"alternate-reverse":"reverse":c?"alternate":"normal","--_mp-anim-state":O.state,...M},"data-mp-animation":"marquee","data-mp-state":O.state,"data-mp-pause-on-hover":b?"":void 0,...O.handlers,...z,children:Array.from({length:Math.max(1,R)},(r,t)=>(r=>e("div",{ref:0===r?G:void 0,className:"mp-marquee-track","aria-hidden":0===r?void 0:"true",...s(0!==r),children:w},r))(t))})});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
2
3
|
import type { MPAnimateProps } from '../../types.js';
|
|
3
4
|
export interface MPAnimateScrambleProps extends Omit<MPAnimateProps, 'alternate' | 'easing'>, Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> {
|
|
4
5
|
/** The text, when it is easier to pass than to nest. Overrides `children`. */
|
|
@@ -27,6 +28,13 @@ export interface MPAnimateScrambleProps extends Omit<MPAnimateProps, 'alternate'
|
|
|
27
28
|
locale?: string;
|
|
28
29
|
/** The text to settle. Only text is settled — see below. */
|
|
29
30
|
children?: React.ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* Renders something other than a `<div>` — a `<span>` to sit inside a
|
|
33
|
+
* paragraph, where a `<div>` would end the paragraph in the server's markup
|
|
34
|
+
* and leave the browser's tree disagreeing with React's. Base UI's own escape
|
|
35
|
+
* hatch, as on `MPAnimateFade`.
|
|
36
|
+
*/
|
|
37
|
+
render?: useRender.RenderProp;
|
|
30
38
|
}
|
|
31
39
|
/**
|
|
32
40
|
* Text settling out of noise.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as
|
|
2
|
+
import{jsx as e,Fragment as t,jsxs as r}from"react/jsx-runtime";import*as a from"react";import{useRender as n}from"@base-ui/react/use-render";import{isInfinite as s,useAnimationRun as i,usePrefersReducedMotion as o}from"../../internal/animate.js";import{graphemesOf as m,textOf as l}from"../../internal/text.js";import{VISUALLY_HIDDEN as c}from"../../internal/visually-hidden.js";export const MPAnimateScramble=/*@__PURE__*/a.forwardRef(function({text:d,duration:u=1200,spread:p=.4,tick:h=50,characters:f="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#%&@$?!",locale:g,delay:x=0,repeat:M=1,paused:j,trigger:y="mount",play:b,once:A=!0,threshold:F=.2,render:N,className:v,style:w,children:S,...q},E){const P=o(),R=i({trigger:y,play:b,once:A,threshold:F,paused:j,infinite:s(M)}),k=d??l(S),B=a.useMemo(()=>m(k,g),[k,g]),[C,D]=a.useState(0),G="running"===R.state&&!P;a.useEffect(()=>{if(P)return void D(1);if(!G)return void D(0);let e=0,t=0;const r=a=>{0===t&&(t=a);const n=a-t-x,s=u>0?Math.min(1,Math.max(0,n/u)):1;D(s),s<1&&(e=requestAnimationFrame(r))};return e=requestAnimationFrame(r),()=>cancelAnimationFrame(e)},[G,P,u,x,R.started]);const H=P?k:B.map((e,t)=>(e=>{const t=B.length>1?e/(B.length-1):0;return C>=t*p+(1-p)})(t)?e:(e=>{const t=(2654435761*e+40503*Math.floor(C*u/Math.max(1,h)))%f.length;return f[Math.abs(t)]??f[0]})(t)).join("");return n({render:N,ref:[E,R.ref],props:{className:v,style:w,"data-mp-animation":"scramble","data-mp-state":R.state,...R.handlers,...q,children:r(t,{children:[e("span",{className:c,children:k}),e("span",{"aria-hidden":"true",className:"tabular-nums whitespace-pre-wrap",children:H})]})}})});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
2
3
|
import type { MPAnimateProps, MPAnimateTimelineProps, MPSide } from '../../types.js';
|
|
3
4
|
/** What a line is cut into before it is animated. */
|
|
4
5
|
export type MPAnimateSplitBy = 'word' | 'character';
|
|
@@ -52,5 +53,12 @@ export interface MPAnimateSplitProps extends MPAnimateProps, MPAnimateTimelinePr
|
|
|
52
53
|
locale?: string;
|
|
53
54
|
/** The text to split. Only text is split — see below. */
|
|
54
55
|
children?: React.ReactNode;
|
|
56
|
+
/**
|
|
57
|
+
* Renders something other than a `<div>` — a `<span>` to sit inside a
|
|
58
|
+
* paragraph, where a `<div>` would end the paragraph in the server's markup
|
|
59
|
+
* and leave the browser's tree disagreeing with React's. Base UI's own escape
|
|
60
|
+
* hatch, as on `MPAnimateFade`.
|
|
61
|
+
*/
|
|
62
|
+
render?: useRender.RenderProp;
|
|
55
63
|
}
|
|
56
64
|
export declare const MPAnimateSplit: React.ForwardRefExoticComponent<MPAnimateSplitProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as
|
|
2
|
+
import{jsx as e,Fragment as a,jsxs as t}from"react/jsx-runtime";import*as r from"react";import{useRender as n}from"@base-ui/react/use-render";import{ANIMATION_CLASS as i,ANIM_BASE as s,animationSlots as l,isInfinite as m,slideOffsets as o,useAnimationRun as d}from"../../internal/animate.js";import{graphemesOf as p,textOf as c,wordsOf as u}from"../../internal/text.js";import{VISUALLY_HIDDEN as f}from"../../internal/visually-hidden.js";export const MPAnimateSplit=/*@__PURE__*/r.forwardRef(function({text:r,by:h="word",duration:y,delay:g=0,easing:x,repeat:j=1,alternate:b,paused:N,trigger:w="mount",play:_,once:v=!0,threshold:$=.2,timeline:k,range:S,stagger:A=40,durationStep:F=0,reverse:M=!1,from:O="bottom",distance:P="0.5rem",fade:R=!0,locale:q,render:z,className:B,style:C,children:D,...E},G){const H=d({trigger:w,play:_,once:v,threshold:$,paused:N,infinite:m(j)}),I="view"===k?N?"paused":"running":H.state,J=r??c(D),{x:K,y:L}=o(O,P),Q=u(J,q),T="character"===h?Q.map(e=>p(e,q)):Q.map(e=>[e]),U=`${s} ${i.slide} inline-block`,V=T.reduce((e,a)=>e+a.length,0);let W=-1;const X={effect:"slide",duration:y,delay:g,easing:x,repeat:j,alternate:b,timeline:k,range:S,x:K,y:L,opacity:R?0:1};return n({render:z,ref:[G,H.ref],props:{className:B,style:{"--_mp-anim-state":I,...C},"data-mp-animation":"split","data-mp-state":I,...H.handlers,...E,children:t(a,{children:[e("span",{className:f,children:J}),e("span",{"aria-hidden":"true",style:l(X),children:T.map((a,t)=>e("span",{className:"inline-block whitespace-pre",children:a.map((a,t)=>{W+=1;const r=M?V-1-W:W;return e("span",{className:U,style:{"--_mp-anim-delay":`${g+r*A}ms`,...0===F?null:{"--_mp-anim-duration":l({...X,durationOffset:r*F})["--_mp-anim-duration"]}},children:a},t)})},t))})]})}})});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
2
3
|
import type { MPAnimateProps } from '../../types.js';
|
|
3
4
|
export interface MPAnimateTypingProps extends Omit<MPAnimateProps, 'alternate' | 'easing'>, Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> {
|
|
4
5
|
/** The text, when it is easier to pass than to nest. Overrides `children`. */
|
|
@@ -37,6 +38,13 @@ export interface MPAnimateTypingProps extends Omit<MPAnimateProps, 'alternate' |
|
|
|
37
38
|
caretChar?: React.ReactNode;
|
|
38
39
|
/** The text to type. Only text is typed — see below. */
|
|
39
40
|
children?: React.ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* Renders something other than a `<div>` — a `<span>` to sit inside a
|
|
43
|
+
* paragraph, where a `<div>` would end the paragraph in the server's markup
|
|
44
|
+
* and leave the browser's tree disagreeing with React's. Base UI's own escape
|
|
45
|
+
* hatch, as on `MPAnimateFade`.
|
|
46
|
+
*/
|
|
47
|
+
render?: useRender.RenderProp;
|
|
40
48
|
}
|
|
41
49
|
/**
|
|
42
50
|
* Text appearing one character at a time.
|
|
@@ -53,7 +61,7 @@ export interface MPAnimateTypingProps extends Omit<MPAnimateProps, 'alternate' |
|
|
|
53
61
|
* a line that is being replaced rather than rewritten.
|
|
54
62
|
*
|
|
55
63
|
* Only **text** is typed. Pass a string, or strings; an element among the
|
|
56
|
-
* children
|
|
57
|
-
*
|
|
64
|
+
* children gives its text and drops its markup, because there is no honest way
|
|
65
|
+
* to reveal half of a link.
|
|
58
66
|
*/
|
|
59
67
|
export declare const MPAnimateTyping: React.ForwardRefExoticComponent<MPAnimateTypingProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as
|
|
2
|
+
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import*as a from"react";import{useRender as i}from"@base-ui/react/use-render";import{isInfinite as n,useAnimationRun as s,usePrefersReducedMotion as o}from"../../internal/animate.js";import{graphemesOf as m,textOf as u}from"../../internal/text.js";import{VISUALLY_HIDDEN as c}from"../../internal/visually-hidden.js";export const MPAnimateTyping=/*@__PURE__*/a.forwardRef(function({text:d,speed:l=24,hold:p=1400,erase:f=!1,eraseSpeed:h,caret:g=!0,caretChar:x="|",duration:y,delay:T=0,repeat:j=1,paused:v,trigger:M="mount",play:N,once:w=!0,threshold:E=.2,render:R,className:S,style:b,children:A,...C},F){const P=s({trigger:M,play:N,once:w,threshold:E,paused:v,infinite:n(j)}),k=o(),q=d??u(A),z=a.useMemo(()=>m(q),[q]),B=z.length,[D,G]=a.useState(0),H=a.useRef(0),I=y&&B>0?y/B:1e3/Math.max(l,1),J=1e3/Math.max(h??2*l,1);return a.useEffect(()=>{H.current=0},[B]),a.useEffect(()=>{if(k||0===B)return void G(B);if(!P.started)return H.current=0,void G(0);if(v)return;let e,t=!1,r=H.current,a=1,i=!1;const n="infinite"===j?1/0:Math.max(1,j);if(r>=B&&1===n)return;const s=()=>{if(!t){if(i)return r-=1,H.current=r,G(r),r<=0&&(i=!1,a+=1),void(e=setTimeout(s,i?J:I));if(r+=1,H.current=r,G(r),r<B)e=setTimeout(s,I);else if(!(a>=n)){if(f)return i=!0,void(e=setTimeout(s,p));a+=1,e=setTimeout(()=>{t||(r=0,H.current=0,G(0),e=setTimeout(s,I))},p)}}};return G(r),e=setTimeout(s,0===r?T:I),()=>{t=!0,clearTimeout(e)}},[P.started,v,k,B,I,J,T,p,f,j]),i({render:R,ref:[F,P.ref],props:{className:S,style:b,"data-mp-animation":"typing","data-mp-state":P.state,...P.handlers,...C,children:t(r,{children:[e("span",{className:c,children:q}),t("span",{"aria-hidden":"true",className:"whitespace-pre-wrap",children:[z.slice(0,D).join(""),g?e("span",{className:"mp-typing-caret",children:x}):null]})]})}})});
|
|
@@ -113,7 +113,12 @@ export interface MPAppLogoProps extends Omit<React.ComponentPropsWithoutRef<'a'>
|
|
|
113
113
|
* so a logo that also needs `nofollow` spells all three out.
|
|
114
114
|
*/
|
|
115
115
|
rel?: string;
|
|
116
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* Anything else the `<img>` needs — `loading`, `decoding`, `crossOrigin`.
|
|
118
|
+
* On `bare`, the file's own `width` and `height` too: they reserve the mark's
|
|
119
|
+
* width from their ratio, so the name beside it does not move when the file
|
|
120
|
+
* arrives.
|
|
121
|
+
*/
|
|
117
122
|
imageProps?: Omit<React.ComponentPropsWithoutRef<'img'>, 'src' | 'srcSet' | 'alt'>;
|
|
118
123
|
/**
|
|
119
124
|
* Renders something other than a `<span>`, or than the `<a>` an `href` makes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as
|
|
2
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import{CartesianFrame as n}from"../../internal/ChartFrame.js";import{BRIDGE_DASH as t,LINE_WIDTH as l,MARKER_RADIUS as o,MARK_GAP as a,bandPath as s,bridgePath as u,linePath as i,valueLabelTest as c,withoutGaps as h}from"../../internal/chart.js";export function MPAreaChart({curve:p="linear",stacked:d=!1,markers:f="auto",gaps:m="break",valueLabels:x="none",...k}){return e(n,{...k,inset:!0,stacked:d,includeZero:!0,headroom:"none"===x?0:14,children:({plot:n,values:k,visible:v,colors:y,labelInk:b,point:g,zeroPx:j,size:z,hovered:L,activeIndex:w,format:A,share:M})=>{const W=l[z],_=o[z],C=k.reduce((e,r)=>Math.max(e,r.length),0),I=C>1?n.width/(C-1):n.width,P="auto"===f?!d&&I>=6*_:f,$=k.map(()=>({top:[],base:[]})),D="percent"===d?Array.from({length:C},(e,r)=>k.reduce((e,n,t)=>{const l=v[t]?n[r]?.value??0:0;return e+(l>0?l:0)},0)):null,E=(e,r)=>null===D?e:e>=0&&D[r]>0?e/D[r]:null;for(let e=0;e<C;e+=1){let r=0,n=0;k.forEach((t,l)=>{const o=t[e]?.value??null,s=null===o&&"zero"===m?0:o,u=null===s?null:E(s,e);if(!v[l]||null===u)return $[l].top.push(null),void $[l].base.push(null);if(!d){const r=g(e,u);return $[l].top.push(r),void $[l].base.push({x:r.x,y:j})}const i=u>=0?r:n,c=i+u;u>=0?r=c:n=c;const h=g(e,c),p=g(e,i);$[l].top.push(h),$[l].base.push({x:p.x,y:0===i?p.y:p.y-Math.sign(u||1)*a})})}return e("g",{className:"mp-area-chart__marks",children:k.map((l,o)=>{if(!v[o])return null;const{top:a,base:f}=$[o],k=y[o],g=null!==L&&L!==o,j=c(l,x);return r("g",{opacity:g?.25:1,children:[e("path",{d:"connect"===m?s(h(a),h(f),p):s(a,f,p),fill:k,fillOpacity:d?.85:.18,stroke:"none"}),e("path",{d:i(a,p),fill:"none",stroke:k,strokeWidth:W,strokeLinecap:"round",strokeLinejoin:"round"}),"connect"===m?e("path",{d:u(a),fill:"none",stroke:k,strokeWidth:W,strokeDasharray:`${W*t} ${W*t}`,strokeLinecap:"round"}):null,a.map((r,n)=>{if(!r)return null;const t=w===n;return P||t?e("circle",{cx:r.x,cy:r.y,r:t?_+1:_,fill:k,stroke:"var(--_mp-color-surface)",strokeWidth:2},n):null}),"none"===x?null:l.map((r,t)=>{const l=a[t];if(!l||null===r.value)return null;if(!j(t))return null;const s=l.x>n.left+n.width-24?"end":l.x<n.left+24?"start":"middle";return e("text",{x:l.x,y:l.y-_-5,textAnchor:s,fill:b(o),fontSize:"xs"===z||"sm"===z?10:11,children:r.label??(null===D?A(r.value):M(E(r.value,t)??0))},t)})]},o)})})}})}
|
|
@@ -80,6 +80,22 @@ export interface MPAvatarProps extends Omit<React.ComponentPropsWithoutRef<'span
|
|
|
80
80
|
imageProps?: Omit<React.ComponentPropsWithoutRef<'img'>, 'src' | 'srcSet' | 'alt' | 'className'>;
|
|
81
81
|
/** Called as the picture moves between `idle`, `loading`, `loaded` and `error`. */
|
|
82
82
|
onLoadingStatusChange?: (status: MPAvatarLoadingStatus) => void;
|
|
83
|
+
/**
|
|
84
|
+
* Draws the `<img>` in the markup and lets it load in place, instead of
|
|
85
|
+
* fetching the picture in script and drawing it once it has arrived.
|
|
86
|
+
*
|
|
87
|
+
* By default the picture is fetched from a script after the page has
|
|
88
|
+
* hydrated, so it is in no server's markup, the browser's preload scanner
|
|
89
|
+
* never sees it, and `loading="lazy"` in `imageProps` is ignored — a list of
|
|
90
|
+
* fifty avatars downloads all fifty the moment the page hydrates, while the
|
|
91
|
+
* page's own largest picture is still loading. With `keepMounted` each is an
|
|
92
|
+
* `<img>` from the start, fetched by the browser on its own terms and lazily
|
|
93
|
+
* when asked to be; the initials show under it until it has loaded.
|
|
94
|
+
*
|
|
95
|
+
* Needs `@base-ui/react` 1.8 or later.
|
|
96
|
+
* @default false
|
|
97
|
+
*/
|
|
98
|
+
keepMounted?: boolean;
|
|
83
99
|
/**
|
|
84
100
|
* The fallback, drawn instead of the initials. An icon, a logo, a single emoji
|
|
85
101
|
* — whatever stands in for this particular thing when there is no picture of
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as a from"react";import{Avatar as n}from"@base-ui/react/avatar";import{accentSlots as r}from"../../internal/accent.js";import{transitionProps as i}from"../../internal/transition.js";import{CONTROL_SQUARE as
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as a from"react";import{Avatar as n}from"@base-ui/react/avatar";import{accentSlots as r}from"../../internal/accent.js";import{transitionProps as i}from"../../internal/transition.js";import{CONTROL_SQUARE as l,hasContent as o}from"../../internal/scale.js";import{initialsOf as s}from"../../internal/initials.js";import{VISUALLY_HIDDEN as m}from"../../internal/visually-hidden.js";import{useMPColor as c,useMPSize as d}from"../../internal/config.js";const p={xs:"text-mp-label-medium",sm:"text-mp-label-large",md:"text-mp-title-large",lg:"text-mp-headline-small",xl:"text-mp-headline-medium"},u={xs:"rounded-mp-xs",sm:"rounded-mp-sm",md:"rounded-mp-md",lg:"rounded-mp-md",xl:"rounded-mp-md"},f={filled:"bg-(--_mp-accent) text-(--_mp-on-accent)",tonal:"bg-(--_mp-accent-container) text-(--_mp-on-accent-container)",elevated:"shadow-mp-1 bg-mp-surface-container-low text-(--_mp-accent)",outlined:"border-mp-outline border bg-transparent text-(--_mp-accent)",text:"text-mp-on-surface-variant bg-transparent"};function x(){return t("svg",{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",className:"size-[60%]",children:[e("path",{d:"M12 12a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9Z"}),e("path",{d:"M12 14.25c-4.28 0-7.75 2.42-7.75 5.4 0 .75.6 1.35 1.35 1.35h12.8c.75 0 1.35-.6 1.35-1.35 0-2.98-3.47-5.4-7.75-5.4Z"})]})}export const MPAvatar=/*@__PURE__*/a.forwardRef(function({src:a,srcSet:g,alt:h,name:v,initials:y,shape:b,variant:j,size:N,color:w,delay:_,imageProps:z,onLoadingStatusChange:M,keepMounted:k=!1,transition:B,className:S,style:C,children:$,...A},L){const P=i(B),R=b??"circle",Z=j??"tonal",F=d(N),I=c(w),q=v?s(v):"",D=h??v,E=o($)?$:(y??q)||e(x,{}),G=o($)||Boolean(y??q),H=["mp-avatar relative inline-flex shrink-0 items-center justify-center overflow-hidden","align-middle leading-none font-medium whitespace-nowrap select-none",l[F],p[F],"circle"===R?"rounded-mp-full":u[F],f[Z],S??""].filter(Boolean).join(" ");return t(n.Root,{ref:L,"data-mp-size":F,"data-mp-variant":Z,className:`${H}${P.className?` ${P.className}`:""}`,style:{...r(I),...P.style,...C},...A,children:[a?e(n.Image,{src:a,srcSet:g,alt:D??"",onLoadingStatusChange:M,...k?{keepMounted:!0}:null,...z,className:["size-full object-cover","transition-opacity duration-(--mp-sys-motion-duration-short4)","ease-mp-standard","data-starting-style:opacity-0 data-ending-style:opacity-0",k?"absolute inset-0 data-error:invisible data-loading:opacity-0":""].filter(Boolean).join(" ")}):null,t(n.Fallback,{delay:a?_:void 0,className:"flex size-full items-center justify-center",children:[D&&G?e("span",{className:m,children:D}):null,e("span",{"aria-hidden":!(!D||!G)||void 0,className:"contents",children:E})]})]})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as t,jsxs as e}from"react/jsx-runtime";import*as
|
|
2
|
+
import{jsx as t,jsxs as e}from"react/jsx-runtime";import*as n from"react";import{CartesianFrame as r}from"../../internal/ChartFrame.js";import{useMPLocale as l}from"../../internal/locale.js";import{useMPSize as a}from"../../internal/config.js";import{BAR_BAND_RATIO as o,BAR_MAX_THICKNESS as i,BAR_RADIUS as u,CHART_FONT_SIZE as s,MARK_GAP as c,barPath as m,formatStatistic as h,textWidth as f,toValues as d,valueLabelTest as p}from"../../internal/chart.js";export function MPBarChart({stacked:x=!1,horizontal:v=!1,valueLabels:b="none",...y}){const g=a(y.size),M=l(y.locale),k=n.useMemo(()=>{const t=s[g];if("none"===b||x)return 0;if(!v)return t+8;return d(y.series).flat().reduce((e,n)=>null===n.value?e:Math.max(e,f(String(n.label??h(n.value,M,y.format,!0)),t)),0)+10},[b,x,v,g,M,y.series,y.format]);return t(r,{...y,inset:!1,stacked:x,horizontal:v,bandRatio:o,includeZero:!0,headroom:k,children:({plot:n,values:r,visible:l,colors:a,labelInk:o,band:h,valuePx:f,categoryPx:d,zeroPx:y,hovered:M,activeIndex:k,format:j})=>{const z=r.reduce((t,e)=>Math.max(t,e.length),0),w=r.map((t,e)=>e).filter(t=>l[t]),P="percent"===x?Array.from({length:z},(t,e)=>w.reduce((t,n)=>{const l=r[n][e]?.value??0;return t+(l>0?l:0)},0)):null,_=(t,e)=>{const n=r[t][e]?.value??null;return null===n||null===P?n:n>=0&&P[e]>0?n/P[e]:null},A=x?h.band:h.band/Math.max(1,w.length),B=Math.max(1,Math.min(A-(x?0:c),i[g]));return e("g",{className:"mp-bar-chart__marks",children:[r.map((r,i)=>{if(!l[i])return null;const y=a[i],P=null!==M&&M!==i,C=p(r,b,z-1),I=w.indexOf(i);return e("g",{opacity:P?.25:1,children:[Array.from({length:z},(e,r)=>{const l=_(i,r);if(null===l)return null;let a=0,o=i;if(x){let t=0,e=0;for(const n of w){const u=_(n,r);null!==u&&(n===i&&(a=u>=0?t:e),u>=0?t+=u:e+=u,u>=0==l>=0&&(o=n))}}const s=f(a),p=f(l+(x?a:0)),b=x&&0!==a?s+(p>s?c:-c):s,g=Math.abs(p-b);if(g<=0||p>s!=p>b)return null;const M=(v?n.top:n.left)+d(r)-h.band/2+(x?0:I*A)+(A-B)/2,j=i!==o?"none":v?l>=0?"right":"left":l>=0?"top":"bottom",z=v?{x:Math.min(b,p),y:M,w:g,h:B}:{x:M,y:Math.min(b,p),w:B,h:g},P=k===r;return t("path",{d:m(z.x,z.y,z.w,z.h,u,j),fill:y,opacity:null===k||P?1:.55},r)}),"none"===b||x?null:r.map((e,r)=>{if(null===e.value)return null;if(!C(r))return null;const l=f(e.value),a=(v?n.top:n.left)+d(r)-h.band/2+I*A+A/2,u=e.value>=0?-6:6;return t("text",{x:v?l-u:a,y:v?a:l+u,textAnchor:v?e.value>=0?"start":"end":"middle",dominantBaseline:v?"central":"auto",fill:o(i),fontSize:s[g]-1,children:e.label??j(e.value)},r)})]},i)}),t("line",v?{x1:y,x2:y,y1:n.top,y2:n.top+n.height,stroke:"var(--_mp-color-outline)",strokeWidth:1}:{x1:n.left,x2:n.left+n.width,y1:y,y2:y,stroke:"var(--_mp-color-outline)",strokeWidth:1})]})}})}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import type { useRender } from '@base-ui/react/use-render';
|
|
2
3
|
import type { MPColor, MPSize } from '../../types.js';
|
|
3
4
|
/**
|
|
4
5
|
* What is drawn between two steps of the trail.
|
|
@@ -88,6 +89,13 @@ export interface MPBreadcrumbProps extends Omit<React.ComponentPropsWithoutRef<'
|
|
|
88
89
|
export interface MPBreadcrumbItemProps extends Omit<React.ComponentPropsWithoutRef<'li'>, 'color' | 'onClick'> {
|
|
89
90
|
/** Renders the step as a link. */
|
|
90
91
|
href?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Renders the step's `<a>` as something else — a router's `Link`, so a press is a
|
|
94
|
+
* client-side navigation and the page is prefetched. `href` and the classes
|
|
95
|
+
* still go through, so `render={<NextLink />}` needs the URL written once.
|
|
96
|
+
* Ignored where there is no link to replace.
|
|
97
|
+
*/
|
|
98
|
+
render?: useRender.RenderProp;
|
|
91
99
|
/** Fires when the step is pressed. Renders it as a button when there is no `href`. */
|
|
92
100
|
onClick?: React.MouseEventHandler<HTMLElement>;
|
|
93
101
|
/** Content before the label — a home glyph, a repository avatar. */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as n,Fragment as
|
|
2
|
+
import{jsx as e,jsxs as n,Fragment as r}from"react/jsx-runtime";import*as t from"react";import{RenderedLink as o}from"../../internal/RenderedLink.js";import{MPIcon as i}from"../icon/MPIcon.js";import{ArrowRightIcon as a,ChevronRightIcon as s,MoreIcon as l}from"../../constants/icons.js";import{accentSlots as c}from"../../internal/accent.js";import{useMPLocale as m,useMPMessages as d}from"../../internal/locale.js";import{BREADCRUMB as p}from"../../internal/messages/breadcrumb.js";import{CONTROL_GAP as u,hasContent as h,PROSE_TEXT as f}from"../../internal/scale.js";import{useMPColor as x,useMPSize as b}from"../../internal/config.js";const v=/*@__PURE__*/t.createContext({size:"md",last:!1,position:null,folded:!1}),g={xs:"gap-1",sm:"gap-1.5",md:"gap-2",lg:"gap-2.5",xl:"gap-3"},j={xs:"rounded-mp-xs",sm:"rounded-mp-xs",md:"rounded-mp-xs",lg:"rounded-mp-sm",xl:"rounded-mp-sm"};const N=["chevron","arrow","slash","dot"];export const MPBreadcrumb=/*@__PURE__*/t.forwardRef(function({size:r,color:o,separator:u="chevron",maxItems:h,itemsBeforeCollapse:j=1,itemsAfterCollapse:y=1,expandable:k=!0,label:z,expandLabel:B,locale:C,structuredData:w=!1,className:P,style:M,children:I,...L},S){const _=b(r),A=x(o),R=d(p,m(C)),[E,F]=t.useState(!1),T=t.Children.toArray(I).filter(t.isValidElement),D=T.length,V=T.some(e=>!0===e.props.current),$=!E&&!w&&void 0!==h&&D>Math.max(h,1)&&D-j-y>1,q=Math.max(0,j),G=D-Math.max(0,y),H=$?[...T.slice(0,q),null,...T.slice(q,G),...T.slice(G)]:T,J=$?q+1:-1,K=$?G+1:-1,O="string"==typeof(Q=u)&&N.includes(Q)?function(n){switch(n){case"chevron":return e(i,{icon:s,size:"1.1em",className:"rtl:rotate-180"});case"arrow":return e(i,{icon:a,size:"1em",className:"rtl:rotate-180"});case"slash":return e("span",{"aria-hidden":"true",children:"/"});case"dot":return e("span",{"aria-hidden":"true",children:"·"});default:return null}}(u):u;var Q;const U=t.useMemo(()=>Array.from({length:H.length},(e,n)=>{const r=n>=J&&n<K;return{size:_,last:!V&&!r&&n===H.length-1,position:w?n+1:null,folded:r}}),[_,V,H.length,w,J,K]),W=["rounded-mp-xs text-mp-on-surface-variant inline-flex items-center px-0.5","appearance-none border-0 bg-transparent font-[inherit]","transition-[background-color,color] duration-(--mp-sys-motion-duration-short4)",k?["cursor-pointer hover:bg-(--_mp-accent-container) hover:text-(--_mp-on-accent-container)","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-1","focus-visible:outline-solid outline-none"].join(" "):""].filter(Boolean).join(" ");return e("nav",{ref:S,"aria-label":z??R.label,"data-mp-size":_,className:["mp-breadcrumb flex",f[_],P??""].filter(Boolean).join(" "),style:{...c(A),...M},...L,children:e("ol",{role:"list",itemScope:w||void 0,itemType:w?"https://schema.org/BreadcrumbList":void 0,className:`m-0 flex list-none flex-wrap items-center p-0 ${g[_]}`,children:H.map((r,o)=>n(t.Fragment,{children:[o>0?e("li",{"aria-hidden":"true",hidden:U[o].folded||void 0,className:"text-mp-on-surface-variant flex shrink-0 items-center select-none [&[hidden]]:hidden",children:O}):null,r?e(v.Provider,{value:U[o],children:r}):e("li",{className:"flex shrink-0 items-center",children:k?e("button",{type:"button",className:W,"aria-label":B??R.expand,onClick:()=>F(!0),children:e(i,{icon:l,size:"1.1em"})}):e("span",{className:W,"aria-hidden":"true",children:e(i,{icon:l,size:"1.1em"})})})]},r?r.key??o:"fold"))})})});export const MPBreadcrumbItem=/*@__PURE__*/t.forwardRef(function({href:i,onClick:a,render:s,startIcon:l,endIcon:c,current:m,disabled:d=!1,className:p,children:f,...x},b){const{size:g,last:N,position:y,folded:k}=t.useContext(v),z=m??N,B=Boolean(i||a)&&!z&&!d,C=null!==y,w=["inline-flex min-w-0 items-center px-1 no-underline","appearance-none border-0 bg-transparent font-[inherit] text-[inherit]",u[g],j[g],"transition-[background-color,color] duration-(--mp-sys-motion-duration-short4)",d?"text-mp-on-surface/38 cursor-default":z?"text-mp-on-surface font-medium":B?["text-mp-on-surface-variant cursor-pointer","hover:bg-(--_mp-accent-container) hover:text-(--_mp-on-accent-container)","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-1","focus-visible:outline-solid outline-none"].join(" "):"text-mp-on-surface-variant"].filter(Boolean).join(" "),P=n(r,{children:[h(l)?e("span",{className:"flex h-[1lh] shrink-0 items-center",children:l}):null,e("span",{className:"truncate",itemProp:C?"name":void 0,children:f}),h(c)?e("span",{className:"flex h-[1lh] shrink-0 items-center",children:c}):null]});return n("li",{ref:b,itemProp:C?"itemListElement":void 0,itemScope:C||void 0,itemType:C?"https://schema.org/ListItem":void 0,hidden:k||void 0,className:["flex min-w-0 items-center [&[hidden]]:hidden",p??""].filter(Boolean).join(" "),...x,children:[C?e("meta",{itemProp:"position",content:String(y)}):null,B&&i?e(o,{render:s,props:{href:i,itemProp:C?"item":void 0,className:w,onClick:a,children:P}}):B?e("button",{type:"button",className:w,onClick:a,children:P}):e("span",{className:w,"aria-current":z?"page":void 0,"aria-disabled":d||void 0,children:P})]})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as r from"react";import{watchIntersection as n}from"../../internal/intersection.js";import{MPIconButton as o}from"../icon-button/MPIconButton.js";import{MPIcon as i}from"../icon/MPIcon.js";import{ChevronLeftIcon as a,ChevronRightIcon as s}from"../../constants/icons.js";import{accentSlots as l}from"../../internal/accent.js";import{fillMessage as c}from"../../internal/i18n.js";import{useMPLocale as u,useMPMessages as d}from"../../internal/locale.js";import{CAROUSEL as m}from"../../internal/messages/carousel.js";import{CONTROL_ICON as f}from"../../internal/scale.js";import{CONTAINER_SURFACE as p}from"../../internal/surface.js";import{VISUALLY_HIDDEN as h}from"../../internal/visually-hidden.js";import{useMPColor as b,useMPSize as v}from"../../internal/config.js";const g=/*@__PURE__*/["pointer-events-auto","not-disabled:bg-(--_mp-accent)/85","not-disabled:hover:bg-(--_mp-accent)","not-disabled:focus-visible:bg-(--_mp-accent)","not-disabled:active:bg-(--_mp-accent)","transition-[background-color] duration-(--mp-sys-motion-duration-short4)","ease-mp-standard motion-reduce:transition-none"].join(" "),w={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"},x={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"}};export const MPCarousel=/*@__PURE__*/r.forwardRef(function({value:j,defaultValue:y=0,onValueChange:N,loop:M=!0,autoPlay:R=!1,interval:k=5e3,arrows:C=!0,indicators:I=!0,variant:S="outlined",size:z,color:P,label:T,previousLabel:E,nextLabel:L,slideLabel:_,locale:B,className:W,style:$,children:A,...F},V){const q=v(z),H=b(P),O=d(m,u(B)),D=T??O.label,G=_??((e,t)=>c(O.slide,{index:String(e),total:String(t)})),J=r.Children.toArray(A),K=J.length,[Q,U]=r.useState(y),X=Math.min(Math.max(j??Q,0),Math.max(K-1,0)),Y=r.useRef(null),Z=r.useRef([]),ee=r.useRef(!1),te=r.useRef(!1),re=r.useRef(!1),[ne,oe]=r.useState(!1),[ie,ae]=r.useState(!1),se=ne||ie,le=r.useRef(X),ce=r.useRef(N);le.current=X,ce.current=N;const ue=r.useCallback((e,t=!1)=>{if(0===K)return;const r=M?(e%K+K)%K:Math.min(Math.max(e,0),K-1);ee.current=t,void 0===j&&U(r),r!==le.current&&ce.current?.(r)},[K,M,j]);r.useEffect(()=>{if(ee.current)return void(ee.current=!1);const e=Y.current;if(!e)return;const t=("rtl"===getComputedStyle(e).direction?-1:1)*X*e.clientWidth;if(!te.current)return te.current=!0,void(0!==X&&e.scrollTo({left:t,behavior:"instant"}));const r=e.getBoundingClientRect(),n=r.bottom<=0||r.right<=0||r.top>=window.innerHeight||r.left>=window.innerWidth;e.scrollTo(n?{left:t,behavior:"instant"}:{left:t}),re.current=!0;const o=window.setTimeout(()=>{re.current=!1},700);return()=>window.clearTimeout(o)},[X]);const de=r.useRef(!0);r.useEffect(()=>{const e=Y.current;if(!R||!e||"undefined"==typeof IntersectionObserver)return;de.current=!1;const t=n(e,e=>{de.current=e.isIntersecting});return()=>{t(),de.current=!0}},[R]),r.useEffect(()=>{if(!R||se||K<2)return;if(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;const e=window.setInterval(()=>{!document.hidden&&de.current&&ue(le.current+1)},k);return()=>window.clearInterval(e)},[R,se,K,k,ue]);const me=r.useRef(0);r.useEffect(()=>()=>cancelAnimationFrame(me.current),[]);const fe=X<=0,pe=X>=K-1;return t("div",{ref:V,role:"region","aria-roledescription":"carousel","aria-label":D,"data-mp-size":q,"data-mp-variant":S,className:["mp-carousel flex w-full flex-col",W??""].filter(Boolean).join(" "),style:{...l(H),...$},onPointerEnter:()=>oe(!0),onPointerLeave:()=>oe(!1),onFocus:()=>ae(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||ae(!1)},...F,children:[t("div",{className:["relative min-w-0 overflow-hidden","rounded-mp-md box-border",p[S],"text-mp-on-surface"].join(" "),children:[e("div",{ref:Y,tabIndex:0,role:"group","aria-label":D,className:["flex min-w-0 snap-x snap-mandatory overflow-x-auto scroll-smooth","motion-reduce:scroll-auto","[scrollbar-width:none] [&::-webkit-scrollbar]:hidden","outline-mp-secondary focus-visible:outline-2 focus-visible:-outline-offset-2","focus-visible:outline-solid outline-none"].join(" "),onScroll:()=>{me.current||(me.current=requestAnimationFrame(()=>{me.current=0;const e=Y.current;if(!e||0===e.clientWidth||re.current)return;const t=Math.round(Math.abs(e.scrollLeft)/e.clientWidth);t!==le.current&&t>=0&&t<K&&ue(t,!0)}))},children:J.map((t,r)=>e("div",{ref:e=>{Z.current[r]=e,Z.current.length=K},role:"group","aria-roledescription":"slide","aria-label":G(r+1,K),className:"w-full shrink-0 grow-0 basis-full snap-start",children:t},r))}),C&&K>1?t("div",{className:`pointer-events-none absolute inset-y-0 flex items-center ${w[q]}`,children:[e(o,{variant:"filled",size:q,color:H,label:E??O.previous,disabled:!M&&fe,className:g,icon:e(i,{icon:a,size:f[q],className:"rtl:rotate-180"}),onClick:()=>ue(X-1)}),e("span",{className:"flex-1"}),e(o,{variant:"filled",size:q,color:H,label:L??O.next,disabled:!M&&pe,className:g,icon:e(i,{icon:s,size:f[q],className:"rtl:rotate-180"}),onClick:()=>ue(X+1)})]}):null]}),I&&K>1?e("div",{className:`flex shrink-0 items-center justify-center pt-2 ${x[q].gap}`,children:J.map((t,r)=>e("button",{type:"button","aria-label":G(r+1,K),"aria-current":r===X?"true":void 0,className:["rounded-mp-full cursor-pointer appearance-none border-0 p-0","transition-[width,background-color] duration-(--mp-sys-motion-duration-short4)","ease-mp-standard motion-reduce:transition-none","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none",r===X?`${x[q].current} bg-(--_mp-accent)`:`${x[q].rest} bg-mp-outline-variant hover:bg-mp-outline`].join(" "),onClick:()=>ue(r)},r))}):null,e("span",{className:h,"aria-live":R?"off":"polite",children:K>0?G(X+1,K):""})]})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as a from"react";import{Checkbox as
|
|
2
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as a from"react";import{Checkbox as n}from"@base-ui/react/checkbox";import{Field as t}from"@base-ui/react/field";import{MPIcon as o}from"../icon/MPIcon.js";import{CheckIcon as i,RemoveIcon as s}from"../../constants/icons.js";import{accentSlots as c}from"../../internal/accent.js";import{MARK_MOTION as l}from"../../internal/mark.js";import{MPStateLayer as d}from"../../internal/StateLayer.js";import{MPSupportingText as m}from"../../internal/SupportingText.js";import{PROSE_TEXT as p,hasContent as h}from"../../internal/scale.js";import{useMPColor as u,useMPSize as f}from"../../internal/config.js";const b={xs:{box:"size-3.5",halo:"size-8",glyph:12},sm:{box:"size-4",halo:"size-9",glyph:14},md:{box:"size-[18px]",halo:"size-10",glyph:16},lg:{box:"size-5",halo:"size-11",glyph:18},xl:{box:"size-[22px]",halo:"size-12",glyph:20}};export const MPCheckbox=/*@__PURE__*/a.forwardRef(function({checked:x,defaultChecked:g,onCheckedChange:k,indeterminate:j=!1,label:y,description:z,errorMessage:N,size:_,color:v,required:C=!1,disabled:M=!1,readOnly:w=!1,name:I,value:R,id:q,className:L,style:O},P){const S=f(_),B=u(v),T=h(N),W=T?"error":B,$=b[S],A=a.useId(),D=q??A;return e(t.Root,{className:["mp-checkbox inline-block max-w-full align-top",L??""].filter(Boolean).join(" "),disabled:M,invalid:T,"data-mp-size":S,style:{...c(W),...O},children:r("div",{className:["flex items-start gap-3",p[S]].join(" "),children:[e("span",{className:"flex h-[1lh] shrink-0 items-center",children:r(n.Root,{ref:P,id:D,name:I,value:R,checked:x,defaultChecked:g,indeterminate:j,required:C,disabled:M,readOnly:w,onCheckedChange:e=>k?.(e),className:["mp-checkbox__tick group relative inline-flex shrink-0 items-center","box-border justify-center border-2 p-0","rounded-[calc(var(--mp-sys-shape-corner-extra-small)/2)]","appearance-none bg-transparent font-[inherit] outline-none","transition-[background-color,border-color]","duration-(--mp-sys-motion-duration-short4)",$.box,M?["border-mp-on-surface/38 cursor-default","data-checked:bg-mp-on-surface/38 data-checked:border-transparent","data-indeterminate:bg-mp-on-surface/38 data-indeterminate:border-transparent"].join(" "):[w?"cursor-default":"cursor-pointer",T?"border-mp-error":"border-mp-on-surface-variant","data-checked:border-transparent data-checked:bg-(--_mp-accent)","data-checked:text-(--_mp-on-accent)","data-indeterminate:border-transparent data-indeterminate:bg-(--_mp-accent)","data-indeterminate:text-(--_mp-on-accent)"].join(" ")].join(" "),children:[M?null:e(d,{layer:["top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full",$.halo,"bg-mp-on-surface","group-data-checked:bg-(--_mp-accent)","group-data-indeterminate:bg-(--_mp-accent)"].join(" ")}),e(n.Indicator,{className:`flex items-center justify-center ${l}`,children:e(o,{icon:j?s:i,size:$.glyph,strokeWidth:3})})]})}),h(y)||h(z)||T?r("span",{className:"flex min-w-0 flex-col gap-0.5",children:[h(y)?r(t.Label,{className:["leading-[1.4]",M?"text-mp-on-surface/38 cursor-default":w?"text-mp-on-surface":"text-mp-on-surface cursor-pointer"].join(" "),children:[y,C?e("span",{"aria-hidden":"true",children:" *"}):null]}):null,e(m,{description:z,errorMessage:N})]}):null]})})});
|