material-plus-ui 1.7.0 → 1.8.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/LICENSE +1 -1
- package/README.md +20 -14
- package/dist/components/alert/MPAlert.d.ts +1 -1
- package/dist/components/alert/MPAlert.js +1 -1
- package/dist/components/anchor/MPAnchor.js +1 -1
- package/dist/components/animate-counter/MPAnimateCounter.js +1 -1
- package/dist/components/app-logo/MPAppLogo.d.ts +16 -1
- package/dist/components/app-logo/MPAppLogo.js +1 -1
- package/dist/components/aspect-ratio/MPAspectRatio.d.ts +1 -1
- package/dist/components/aspect-ratio/MPAspectRatio.js +1 -1
- package/dist/components/blockquote/MPBlockquote.d.ts +8 -0
- package/dist/components/blockquote/MPBlockquote.js +1 -1
- package/dist/components/bottom-navigation/MPBottomNavigation.js +1 -1
- package/dist/components/breadcrumb/MPBreadcrumb.js +1 -1
- package/dist/components/button/MPButton.js +1 -1
- package/dist/components/calendar/MPCalendar.js +1 -1
- package/dist/components/carousel/MPCarousel.js +1 -1
- package/dist/components/checkbox/MPCheckbox.js +1 -1
- package/dist/components/chip/MPChip.d.ts +1 -1
- package/dist/components/chip/MPChip.js +1 -1
- package/dist/components/color-picker/MPColorPicker.js +1 -1
- package/dist/components/combobox/MPCombobox.js +1 -1
- package/dist/components/confirm/MPConfirmProvider.js +1 -1
- package/dist/components/data-table/MPDataTable.d.ts +20 -1
- package/dist/components/data-table/MPDataTable.js +1 -1
- package/dist/components/date-picker/MPDatePicker.js +1 -1
- package/dist/components/floating-action-button/MPFloatingActionButton.js +1 -1
- package/dist/components/grid/MPGrid.d.ts +25 -8
- package/dist/components/grid/MPGrid.js +1 -1
- package/dist/components/hover-card/MPHoverCard.d.ts +1 -0
- package/dist/components/hover-card/MPHoverCard.js +1 -1
- package/dist/components/icon/MPIcon.js +1 -1
- package/dist/components/image/MPImage.d.ts +112 -4
- package/dist/components/image/MPImage.js +1 -1
- package/dist/components/image/index.d.ts +1 -1
- package/dist/components/list/MPList.js +1 -1
- package/dist/components/menu/MPMenu.d.ts +1 -1
- package/dist/components/menubar/MPMenubar.js +1 -1
- package/dist/components/navigation-menu/MPNavigationMenu.js +1 -1
- package/dist/components/number-field/MPNumberField.js +1 -1
- package/dist/components/pie-chart/MPPieChart.js +1 -1
- package/dist/components/pill/MPPill.js +1 -1
- package/dist/components/popconfirm/MPPopconfirm.d.ts +2 -2
- package/dist/components/popover/MPPopover.d.ts +1 -0
- package/dist/components/popover/MPPopover.js +1 -1
- package/dist/components/portal/MPPortal.d.ts +1 -1
- package/dist/components/radio-group/MPRadioGroup.js +1 -1
- package/dist/components/rating/MPRating.js +1 -1
- package/dist/components/segmented-button/MPSegmentedButton.js +1 -1
- package/dist/components/select/MPSelect.js +1 -1
- package/dist/components/sparkline/MPSparkline.js +1 -1
- package/dist/components/statistic/MPStatistic.js +1 -1
- package/dist/components/stepper/MPStepper.js +1 -1
- package/dist/components/table/MPTable.d.ts +1 -1
- package/dist/components/tabs/MPTabs.js +1 -1
- package/dist/components/timeline/MPTimeline.js +1 -1
- package/dist/components/toggle/MPToggle.js +1 -1
- package/dist/components/tooltip/MPTooltip.js +1 -1
- package/dist/components/tour/MPTour.js +1 -1
- package/dist/components/transfer/MPTransfer.js +1 -1
- package/dist/constants/glyphs.d.ts +32 -32
- package/dist/constants/icons.d.ts +32 -32
- package/dist/internal/Calendar.js +1 -1
- package/dist/internal/ChartChrome.d.ts +0 -6
- package/dist/internal/ChartChrome.js +1 -1
- package/dist/internal/FieldOutline.js +1 -1
- package/dist/internal/Picker.js +1 -1
- package/dist/internal/PopupArrow.d.ts +60 -0
- package/dist/internal/PopupArrow.js +2 -0
- package/dist/internal/SupportingText.js +1 -1
- package/dist/internal/chart.d.ts +0 -10
- package/dist/internal/chart.js +1 -1
- package/dist/internal/color-scheme.d.ts +0 -9
- package/dist/internal/color-scheme.js +1 -1
- package/dist/internal/data-table.d.ts +35 -2
- package/dist/internal/data-table.js +1 -1
- package/dist/internal/date.d.ts +22 -18
- package/dist/internal/date.js +1 -1
- package/dist/internal/i18n.d.ts +10 -0
- package/dist/internal/intl.d.ts +64 -0
- package/dist/internal/intl.js +1 -0
- package/dist/internal/messages/transfer.d.ts +1 -1
- package/dist/internal/messages/transfer.js +1 -1
- package/dist/internal/text.js +1 -1
- package/dist/internal/time-scale.js +1 -1
- package/dist/locales/ar.js +1 -1
- package/dist/locales/de.js +1 -1
- package/dist/locales/es.js +1 -1
- package/dist/locales/fr.js +1 -1
- package/dist/locales/hi.js +1 -1
- package/dist/locales/id.js +1 -1
- package/dist/locales/it.js +1 -1
- package/dist/locales/ja.js +1 -1
- package/dist/locales/ko.js +1 -1
- package/dist/locales/nl.js +1 -1
- package/dist/locales/pl.js +1 -1
- package/dist/locales/pt.js +1 -1
- package/dist/locales/ru.js +1 -1
- package/dist/locales/th.js +1 -1
- package/dist/locales/tr.js +1 -1
- package/dist/locales/vi.js +1 -1
- package/dist/locales/zh-hans.js +1 -1
- package/dist/locales/zh-hant.js +1 -1
- package/dist/styles/accordion.css +1 -1
- package/dist/styles/alert.css +1 -1
- package/dist/styles/app-logo.css +1 -1
- package/dist/styles/area-chart.css +1 -1
- package/dist/styles/aspect-ratio.css +1 -1
- package/dist/styles/bar-chart.css +1 -1
- package/dist/styles/blockquote.css +1 -1
- package/dist/styles/bottom-navigation.css +1 -1
- package/dist/styles/breadcrumb.css +1 -1
- package/dist/styles/button.css +1 -1
- package/dist/styles/calendar.css +1 -1
- package/dist/styles/carousel.css +1 -1
- package/dist/styles/chat-bubble.css +1 -1
- package/dist/styles/checkbox.css +1 -1
- package/dist/styles/chip.css +1 -1
- package/dist/styles/code-block.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/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/file-picker.css +1 -1
- package/dist/styles/flex.css +1 -1
- package/dist/styles/floating-action-button.css +1 -1
- package/dist/styles/grid.css +1 -1
- package/dist/styles/heatmap-chart.css +1 -1
- package/dist/styles/icon-button.css +1 -1
- package/dist/styles/icon.css +1 -1
- package/dist/styles/image.css +1 -1
- package/dist/styles/line-chart.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/navigation-menu.css +1 -1
- package/dist/styles/number-field.css +1 -1
- package/dist/styles/otp-field.css +1 -1
- package/dist/styles/pagination.css +1 -1
- package/dist/styles/pie-chart.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/radio-group.css +1 -1
- package/dist/styles/rating.css +1 -1
- package/dist/styles/scatter-chart.css +1 -1
- package/dist/styles/scroll-zone.css +1 -1
- package/dist/styles/segmented-button.css +1 -1
- package/dist/styles/select.css +1 -1
- package/dist/styles/sidebar.css +1 -1
- package/dist/styles/snackbar.css +1 -1
- package/dist/styles/spoiler.css +1 -1
- package/dist/styles/statistic.css +1 -1
- package/dist/styles/stepper.css +1 -1
- package/dist/styles/switch.css +1 -1
- package/dist/styles/tabs.css +1 -1
- package/dist/styles/text-field.css +1 -1
- package/dist/styles/text-link.css +1 -1
- package/dist/styles/time-picker.css +1 -1
- package/dist/styles/timeline-chart.css +1 -1
- package/dist/styles/timeline.css +1 -1
- package/dist/styles/toggle.css +1 -1
- package/dist/styles/tokens.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.css +1 -1
- package/dist/tailwind.css +1253 -55
- package/dist/types.d.ts +2 -2
- package/package.json +24 -24
- package/.fix.py +0 -92
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2026 CDGet
|
|
3
|
+
Copyright (c) 2026 CDGet (https://cdget.com).
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -2,29 +2,29 @@
|
|
|
2
2
|
page on npm as well as the front page on GitHub, `.npmignore` keeps `docs/`
|
|
3
3
|
out of the tarball, and npm resolves a relative image against the published
|
|
4
4
|
package before it falls back to anything else. -->
|
|
5
|
-
<img src="https://raw.githubusercontent.com/jooy2/material-plus/main/docs/public/logo-large.png" alt="Material Plus" width="96" height="96">
|
|
5
|
+
<img src="https://raw.githubusercontent.com/jooy2/material-plus-ui/main/docs/public/logo-large.png" alt="Material Plus" width="96" height="96">
|
|
6
6
|
|
|
7
7
|
# Material Plus
|
|
8
8
|
|
|
9
|
-
[](https://github.com/jooy2/material-plus/blob/main/LICENSE)  [](https://www.npmjs.com/package/material-plus-ui) [](https://www.npmjs.com/package/material-plus-ui) 
|
|
9
|
+
[](https://github.com/jooy2/material-plus-ui/blob/main/LICENSE)  [](https://www.npmjs.com/package/material-plus-ui) [](https://www.npmjs.com/package/material-plus-ui) 
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
This README is the quick start. [The documentation site](https://material-plus.cdget.com) has a page per component, with live previews and the full props table.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+

|
|
14
14
|
|
|
15
15
|
---
|
|
16
16
|
|
|
17
|
-
**Material Plus is a React component library implementing Material Design 3.** It
|
|
17
|
+
**Material Plus is a React component library implementing Material Design 3.** It follows the specification directly rather than wrapping somebody's implementation of it, so its colour roles, type scale and shapes are the ones the spec names.
|
|
18
18
|
|
|
19
|
-
It
|
|
19
|
+
It also goes on past where the specification stops. The button ladder keeps the spec's 32, 40 and 56px and adds 64 and 72 — the next size the spec names is 96, and a 96px button beside a 64px field is not a row — and the charts, the data table and the command palette are components the spec never named at all.
|
|
20
20
|
|
|
21
21
|
- **Themed in one line.** Set `--mp-source-color` and every colour role follows, the way Material generates a scheme from a source colour. No provider, no theme object, no re-render.
|
|
22
22
|
- **It coexists.** Nothing here is page-level — no reset, no provider, no global styling — and it reads the `--md-sys-color-*` tokens your page already has if they are there. A project already running Material keeps its own setup.
|
|
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.
|
|
27
|
-
- **
|
|
26
|
+
- **ESM only**, TypeScript declarations included, and tree-shakeable for real: one component is 3.8 kB gzipped and five are 9.8 kB, against 130.6 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
|
+
- **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
|
|
30
30
|
|
|
@@ -34,6 +34,7 @@ Everything is documented at **[material-plus.cdget.com](https://material-plus.cd
|
|
|
34
34
|
| --- | --- |
|
|
35
35
|
| [**Getting started**](https://material-plus.cdget.com/guide/getting-started) | Install and setup, end to end. |
|
|
36
36
|
| [**All components**](https://material-plus.cdget.com/components/) | Every component, one page each: live previews and the full props table. |
|
|
37
|
+
| [**Browser support**](https://material-plus.cdget.com/browser-support) | Which browsers and versions it runs in, and what is reduced in the older ones. |
|
|
37
38
|
| [**Changelog**](https://material-plus.cdget.com/changelog) | What changed in each release. |
|
|
38
39
|
|
|
39
40
|
Also available in Korean / 한국어 문서: **[material-plus.cdget.com/ko/](https://material-plus.cdget.com/ko/)**
|
|
@@ -74,7 +75,7 @@ If Tailwind v4 is already in your project, import the token sheet instead:
|
|
|
74
75
|
@import 'material-plus-ui/tailwind.css';
|
|
75
76
|
```
|
|
76
77
|
|
|
77
|
-
A page that renders a handful of components can take the tokens and a sheet each instead of the whole
|
|
78
|
+
A page that renders a handful of components can take the tokens and a sheet each instead of the whole 172.2 kB — 6.3 kB gzipped for one component against 23.4 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.
|
|
78
79
|
|
|
79
80
|
```ts
|
|
80
81
|
import 'material-plus-ui/styles/tokens.css';
|
|
@@ -133,10 +134,7 @@ Full details, including scoped and runtime theming, are in [the theming guide](h
|
|
|
133
134
|
|
|
134
135
|
## Components
|
|
135
136
|
|
|
136
|
-
|
|
137
|
-
| --- | --- |
|
|
138
|
-
| [`MPTextField`](https://material-plus.cdget.com/components/inputs/text-field) | An outlined text field that survives an IME, with the label, supporting text, adornments and password toggle already assembled. |
|
|
139
|
-
| [`MPIcon`](https://material-plus.cdget.com/components/display/icon) | A glyph at a known size in a known colour, from whichever icon set you use. |
|
|
137
|
+
There are over 120, grouped into layout, inputs, display, feedback, motion and charts. Each has a page of its own at [material-plus.cdget.com/components/](https://material-plus.cdget.com/components/), with the full props table and previews that are the component running in the page.
|
|
140
138
|
|
|
141
139
|
### Why `MPTextField` exists
|
|
142
140
|
|
|
@@ -151,7 +149,7 @@ A controlled `<input>` renders from its `value`. While an input method is compos
|
|
|
151
149
|
|
|
152
150
|
## Contributing
|
|
153
151
|
|
|
154
|
-
Issues and pull requests are welcome.
|
|
152
|
+
Issues and pull requests are welcome. [CONTRIBUTING.md](CONTRIBUTING.md) has the repository layout, the commands and what a component is expected to own. Participation is subject to the [Code of Conduct](CODE_OF_CONDUCT.md).
|
|
155
153
|
|
|
156
154
|
```bash
|
|
157
155
|
npm install # also builds, via `prepare`
|
|
@@ -160,6 +158,14 @@ npm run typecheck # src, test and docs
|
|
|
160
158
|
npm run docs:dev # the documentation site
|
|
161
159
|
```
|
|
162
160
|
|
|
161
|
+
To report a security issue, follow the process in [SECURITY.md](SECURITY.md) instead of opening a public issue.
|
|
162
|
+
|
|
163
|
+
For anything else that does not belong in a public issue, write to CDGet at [cdget.com/contact](https://cdget.com/contact).
|
|
164
|
+
|
|
165
|
+
## Sponsor
|
|
166
|
+
|
|
167
|
+
Material Plus is free to use and maintained in the open. If it saves you time, you can support the work at [cdget.com/donate](https://cdget.com/donate) or through the Sponsor button on GitHub.
|
|
168
|
+
|
|
163
169
|
## License
|
|
164
170
|
|
|
165
171
|
[MIT](LICENSE) © [CDGet](https://cdget.com)
|
|
@@ -32,7 +32,7 @@ export interface MPAlertProps extends Omit<React.ComponentPropsWithoutRef<'div'>
|
|
|
32
32
|
*
|
|
33
33
|
* Four roles, not a severity ladder — there is no `info`, `success` or
|
|
34
34
|
* `warning` here, because [the specification's colour
|
|
35
|
-
* system](
|
|
35
|
+
* system](../../design/color) has no way to derive them and a library that
|
|
36
36
|
* invented three more families would be promising tokens the sheet cannot
|
|
37
37
|
* produce. `error` is the one severity Material does name, and the rest is an
|
|
38
38
|
* emphasis decision: `primary` for a notice, `secondary` or `tertiary` for one
|
|
@@ -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{MPIcon as r}from"../icon/MPIcon.js";import{CloseIcon as i,ErrorIcon as o,InfoIcon as a}from"../../constants/icons.js";import{accentSlots as l}from"../../internal/accent.js";import{transitionProps as s}from"../../internal/transition.js";import{useMPLocale as c,useMPMessages as m}from"../../internal/locale.js";import{ALERT as d}from"../../internal/messages/alert.js";import{inertProps as p}from"../../internal/inert.js";import{MPStateLayer as f}from"../../internal/StateLayer.js";import{CONTROL_ICON as u,hasContent as x,PROSE_TEXT as v,SHEET_GAP as h,SHEET_TITLE as
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{MPIcon as r}from"../icon/MPIcon.js";import{CloseIcon as i,ErrorIcon as o,InfoIcon as a}from"../../constants/icons.js";import{accentSlots as l}from"../../internal/accent.js";import{transitionProps as s}from"../../internal/transition.js";import{useMPLocale as c,useMPMessages as m}from"../../internal/locale.js";import{ALERT as d}from"../../internal/messages/alert.js";import{inertProps as p}from"../../internal/inert.js";import{MPStateLayer as f}from"../../internal/StateLayer.js";import{CONTROL_ICON as u,hasContent as x,PROSE_TEXT as v,SHEET_GAP as h,SHEET_TITLE as b,STACK_GAP as j}from"../../internal/scale.js";import{sheetPad as y}from"../../internal/density.js";import{useMPColor as g,useMPDensity as N,useMPSize as w}from"../../internal/config.js";const _={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-on-surface",outlined:"border-mp-outline border bg-transparent text-mp-on-surface",text:"bg-transparent text-mp-on-surface"},z={filled:"",tonal:"",elevated:"text-(--_mp-accent)",outlined:"text-(--_mp-accent)",text:"text-(--_mp-accent)"},k={filled:"",tonal:"",elevated:"text-mp-on-surface-variant",outlined:"text-mp-on-surface-variant",text:"text-mp-on-surface-variant"},C={primary:"polite",secondary:"polite",tertiary:"polite",error:"assertive"},B={assertive:"alert",polite:"status",off:void 0};export const MPAlert=/*@__PURE__*/n.forwardRef(function({variant:L="tonal",color:R,size:S,density:E,title:M,icon:P,action:T,live:A,onClose:D,closeLabel:F,locale:I,transition:$,className:q,style:G,children:H,...J},K){const O=s($),Q=g(R),U=w(S),V=N(E),W=c(I),X=m(d,W),[Y,Z]=n.useState(!1),ee=n.useRef(null),te=n.useRef(null),ne=n.useCallback(()=>{const e=ee.current;ee.current=null,e&&D?.(e)},[D]);n.useLayoutEffect(()=>{const e=te.current;Y&&e&&0===parseFloat(getComputedStyle(e).transitionDuration)&&ne()},[Y,ne]);const re=z[L],ie=x(M),oe=void 0===P?e(r,{icon:"error"===Q?o:a,size:u[U]}):P,ae=t("div",{ref:K,role:B[A??C[Q]],"data-mp-size":U,"data-mp-variant":L,...p(Y),className:["mp-alert rounded-mp-md flex w-full items-start","box-border",y(U,V),h[U],v[U],_[L],O.className,q??""].filter(Boolean).join(" "),style:{...l(Q),...O.style,...G},...J,children:[x(oe)?e("span",{className:["flex h-[1lh] shrink-0 items-center",re].filter(Boolean).join(" "),children:oe}):null,t("div",{className:`flex min-w-0 flex-1 flex-col ${j[U]}`,children:[ie?e("div",{className:[b[U],re].filter(Boolean).join(" "),children:M}):null,x(H)?e("div",{className:ie?k[L]:void 0,children:H}):null]}),x(T)?e("div",{className:"flex h-[1lh] shrink-0 items-center",children:T}):null,D?e("span",{className:"flex h-[1lh] shrink-0 items-center",children:t("button",{type:"button","aria-label":F??X.dismiss,disabled:Y,onClick:e=>{ee.current=e,Z(!0)},className:["group rounded-mp-full relative -m-1 flex size-8 cursor-pointer items-center","justify-center appearance-none border-0 bg-transparent p-0 text-inherit","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none"].join(" "),children:[e(f,{}),e(r,{icon:i,size:u[U]})]})}):null]});return D?e("div",{ref:te,className:["mp-alert__reveal grid transition-[grid-template-rows,opacity]","duration-(--mp-sys-motion-duration-short4)","ease-(--mp-sys-motion-easing-emphasized-accelerate)","motion-reduce:transition-none",Y?"grid-rows-[0fr] opacity-0":"grid-rows-[1fr]"].join(" "),onTransitionEnd:e=>{Y&&"grid-template-rows"===e.propertyName&&e.target===e.currentTarget&&ne()},children:e("div",{className:"min-h-0 "+(Y?"overflow-hidden":""),children:ae})}):ae});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e}from"react/jsx-runtime";import*as n from"react";import{accentSlots as
|
|
2
|
+
import{jsx as e}from"react/jsx-runtime";import*as n from"react";import{accentSlots as t}from"../../internal/accent.js";import{useMPLocale as r,useMPMessages as o}from"../../internal/locale.js";import{ANCHOR as i}from"../../internal/messages/anchor.js";import{CONTROL_TEXT as l}from"../../internal/scale.js";import{useMPColor as s,useMPDensity as c,useMPSize as a}from"../../internal/config.js";const m={xs:"py-1",sm:"py-1",md:"py-1.5",lg:"py-2",xl:"py-2.5"},u={xs:["py-0.5","py-0.5","py-0.5"],sm:["py-0.5","py-0.5","py-0.5"],md:["py-1","py-0.5","py-0.5"],lg:["py-1.5","py-1","py-0.5"],xl:["py-2","py-1.5","py-1"]};function p(e,n){return 0===n?m[e]:u[e][-n-1]}const d={xs:8,sm:10,md:12,lg:14,xl:16};export const MPAnchor=/*@__PURE__*/n.forwardRef(function({items:m,activeHref:u,onActiveChange:f,offset:h=0,container:y,rail:g=!0,size:v,color:b,density:x,locale:w,label:j,className:B,style:E,...R},C){const _=a(v),A=s(b),H=c(x),N=o(i,r(w)),[z,L]=n.useState(null),T=void 0!==u,k=T?u:z,I=n.useRef(f);I.current=f;const F=n.useRef(m);F.current=m;const P=m.map(e=>e.href).join(" ");n.useEffect(()=>{if(T)return;const e=y?.current??window;let n=0,t=null;const r=()=>{n=0;const e=function(e,n,t){const r=(t?t.getBoundingClientRect().top:0)+n+1;let o=null;for(const n of e){const e=document.getElementById(n.href.replace(/^#/,""));e&&e.getBoundingClientRect().top<=r&&(o=n.href)}return(t?t.scrollTop+t.clientHeight>=t.scrollHeight-2:window.innerHeight+window.scrollY>=document.documentElement.scrollHeight-2)&&e.length>0?e[e.length-1].href:o}(F.current,h,y?.current??null);e!==t&&(t=e,L(e),I.current?.(e))},o=()=>{0===n&&(n=requestAnimationFrame(r))};return r(),e.addEventListener("scroll",o,{passive:!0}),window.addEventListener("resize",o,{passive:!0}),()=>{0!==n&&cancelAnimationFrame(n),e.removeEventListener("scroll",o),window.removeEventListener("resize",o)}},[P,h,y,T]);const S=y?e=>{if(!e.defaultPrevented)return;const n=e.currentTarget.getAttribute("href"),t=y.current;if(!n?.startsWith("#")||!t)return;const r=document.getElementById(n.slice(1));if(!r)return;const o=t.scrollTop+(r.getBoundingClientRect().top-t.getBoundingClientRect().top)-h;t.scrollTo({top:o})}:void 0;return e("nav",{ref:C,"aria-label":j??N.label,"data-mp-size":_,className:["mp-anchor min-w-0",B??""].filter(Boolean).join(" "),style:{...t(A),...E},...R,children:e("ul",{className:["mp-anchor__list m-0 flex list-none flex-col p-0",g?"border-mp-outline-variant border-s":""].filter(Boolean).join(" "),children:m.map(n=>e("li",{className:g?"-ms-px":void 0,children:e("a",{href:n.href,onClick:S,"aria-current":k===n.href?"location":void 0,className:["mp-anchor__link block min-w-0 truncate no-underline","text-mp-on-surface-variant hover:text-mp-on-surface",l[_],p(_,H),"transition-[color,border-color] duration-(--mp-sys-motion-duration-short4)","ease-mp-standard motion-reduce:transition-none","aria-[current=location]:text-(--_mp-accent) aria-[current=location]:font-medium",g?"border-s border-transparent ps-3 aria-[current=location]:border-(--_mp-accent)":"","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:rounded-mp-xs focus-visible:outline-solid outline-none"].filter(Boolean).join(" "),style:{marginInlineStart:n.depth?n.depth*d[_]:void 0},children:n.label})},n.href))})})});
|
|
@@ -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}from"react/jsx-runtime";import*as n from"react";import{numberFormatter as a}from"../../internal/intl.js";import{useAnimateElement as r}from"../../internal/animate.js";import{VISUALLY_HIDDEN as i}from"../../internal/visually-hidden.js";export const MPAnimateCounter=/*@__PURE__*/n.forwardRef(function({value:s,from:o=0,options:m,locale:l,format:u,duration:c,delay:f=0,easing:p,paused:d,trigger:y="mount",play:g,once:h=!0,threshold:N=.2,timeline:j,range:A,className:F,style:v,...S},x){const C=r({effect:"count",effectClass:"mp-anim-count",duration:c,delay:f,easing:p,repeat:1,from:o,to:s,trigger:y,play:g,once:h,threshold:N,paused:d,infinite:!1,timeline:j,range:A}),b=u??(e=>a(l,m).format(e)),q=n.useRef(null),[w,P]=n.useState(o);return n.useEffect(()=>{const e=q.current;if(!e||"undefined"==typeof requestAnimationFrame)return;let t=0,n=!0;const a="view"===j&&CSS.supports("animation-timeline","view()"),r=()=>{if(!n)return;const i=e.getAnimations().filter(e=>"mp-anim-count"===e.animationName),o=i.every(e=>"finished"===e.playState);if(0===i.length||o&&!a)P(s);else{const t=Number.parseFloat(getComputedStyle(e).getPropertyValue("--mp-count"));Number.isFinite(t)&&P(t)}i.length>0&&(a||!o)&&(t=requestAnimationFrame(r))};return t=requestAnimationFrame(r),()=>{n=!1,cancelAnimationFrame(t)}},[C.style,C.props["data-mp-state"],j,s]),t("span",{ref:e=>{q.current=e,C.ref(e),"function"==typeof x?x(e):x&&(x.current=e)},className:[C.className,F].filter(Boolean).join(" "),style:{...C.style,...v},...C.props,...S,children:[e("span",{className:i,children:b(s)}),e("span",{"aria-hidden":"true",className:"tabular-nums",children:b(w)})]})});
|
|
@@ -19,7 +19,7 @@ import type { MPColor, MPSize, MPVariant } from '../../types.js';
|
|
|
19
19
|
* that a fourth value would be one nobody could see.
|
|
20
20
|
*/
|
|
21
21
|
export type MPAppLogoShape = 'bare' | 'app' | 'circle';
|
|
22
|
-
export interface MPAppLogoProps extends Omit<React.ComponentPropsWithoutRef<'a'>, 'color' | 'href'> {
|
|
22
|
+
export interface MPAppLogoProps extends Omit<React.ComponentPropsWithoutRef<'a'>, 'color' | 'href' | 'target' | 'rel'> {
|
|
23
23
|
/**
|
|
24
24
|
* The artwork, as an image. Beaten by `children`, so a project that inlines
|
|
25
25
|
* its SVG and a project that links a PNG use the same component.
|
|
@@ -98,6 +98,21 @@ export interface MPAppLogoProps extends Omit<React.ComponentPropsWithoutRef<'a'>
|
|
|
98
98
|
* the same thing with one more element in it.
|
|
99
99
|
*/
|
|
100
100
|
href?: string;
|
|
101
|
+
/**
|
|
102
|
+
* Where that link opens. `rel` follows on its own for `_blank` — see `rel`.
|
|
103
|
+
*
|
|
104
|
+
* A logo in a header is usually the way back to the front page and opens in
|
|
105
|
+
* place, so this is rarely set. The one case it is set for is the lockup that
|
|
106
|
+
* links to somebody else's site, which is also the case where the `rel`
|
|
107
|
+
* matters most.
|
|
108
|
+
*/
|
|
109
|
+
target?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Overrides the `rel` a `_blank` lockup would otherwise get, which is
|
|
112
|
+
* `noopener noreferrer`. Writing one **replaces** it rather than adding to it,
|
|
113
|
+
* so a logo that also needs `nofollow` spells all three out.
|
|
114
|
+
*/
|
|
115
|
+
rel?: string;
|
|
101
116
|
/** Anything else the `<img>` needs — `loading`, `decoding`, `crossOrigin`. */
|
|
102
117
|
imageProps?: Omit<React.ComponentPropsWithoutRef<'img'>, 'src' | 'srcSet' | 'alt'>;
|
|
103
118
|
/**
|
|
@@ -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{useRender as r}from"@base-ui/react/use-render";import{accentSlots as a}from"../../internal/accent.js";import{
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{useRender as r}from"@base-ui/react/use-render";import{accentSlots as a}from"../../internal/accent.js";import{linkRel as o}from"../../internal/link.js";import{initialsOf as i}from"../../internal/initials.js";import{cssLength as l}from"../../internal/length.js";import{CONTROL_GAP as m,CONTROL_HEIGHT as s,CONTROL_SQUARE as c,hasContent as d}from"../../internal/scale.js";import{VISUALLY_HIDDEN as p}from"../../internal/visually-hidden.js";import{useMPColor as u,useMPSize as f}from"../../internal/config.js";const x={xs:"text-[0.75rem]",sm:"text-[0.875rem]",md:"text-[1.0625rem]",lg:"text-[1.375rem]",xl:"text-[1.625rem]"},g={xs:"text-[0.75rem]",sm:"text-[0.875rem]",md:"text-[1.0625rem]",lg:"text-[1.3125rem]",xl:"text-[1.5625rem]"},h={xs:"rounded-mp-xs",sm:"rounded-mp-sm",md:"rounded-mp-md",lg:"rounded-mp-md",xl:"rounded-mp-md"},v={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"};export const MPAppLogo=/*@__PURE__*/n.forwardRef(function({src:w,srcSet:j,alt:b,name:_,initials:y,showName:N=!1,shape:k="bare",variant:B="filled",size:z,color:P,padded:S=!0,height:A,href:F,target:L,rel:M,imageProps:R,render:$,className:q,style:C,children:D,...E},G){const H=f(z),I=u(P),J="bare"!==k,K=d(D)?D:w?"image":null,O=J&&S,Q=null===K&&!J,T=N&&!Q&&d(_),U=b??_,V=y??(_?i(_):""),W="image"===K&&!T&&d(U),X=Q||W,Y=!X&&!T&&d(U),Z=l(A),ee=Z?{height:Z,width:J?Z:void 0}:null,te=e("span",{"aria-hidden":!X||void 0,className:["mp-app-logo__mark flex shrink-0 items-center justify-center overflow-hidden","font-semibold tracking-tight whitespace-nowrap",Z?"":s[H],J?[Z?"":c[H],"circle"===k?"rounded-mp-full":h[H],g[H],v[B]].filter(Boolean).join(" "):["text-mp-on-surface w-auto",x[H]].join(" "),"[&_svg]:w-auto [&_svg]:shrink-0",O?"[&_svg]:h-[72%] [&_svg]:max-w-[72%]":"[&_svg]:h-full [&_svg]:max-w-full"].filter(Boolean).join(" "),style:ee??void 0,children:"image"===K?e("img",{src:w,srcSet:j,alt:W?U??"":"",className:["w-auto object-contain",O?"h-[72%] max-w-[72%]":"h-full max-w-full"].join(" "),decoding:"async",...R}):K??(Q?_:V)});return r({render:$??e(F?"a":"span",{}),ref:G,props:{href:F,target:L,rel:o(L,M),"data-mp-size":H,"data-mp-variant":B,className:["mp-app-logo inline-flex max-w-full min-w-0 items-center align-middle","text-mp-on-surface no-underline select-none",m[H],F?"rounded-mp-xs cursor-pointer":"",F?"outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-solid outline-none":"",q??""].filter(Boolean).join(" "),style:{...a(I),...C},children:t(n.Fragment,{children:[te,T?e("span",{className:`mp-app-logo__name min-w-0 truncate font-semibold ${x[H]}`,children:_}):null,Y?e("span",{className:p,children:U}):null]}),...E}})});
|
|
@@ -8,7 +8,7 @@ import type { MPSize } from '../../types.js';
|
|
|
8
8
|
* the same reason `MPSide` keeps `top`/`right`/`bottom`/`left`: inventing
|
|
9
9
|
* `fill-the-box` would only make a reader look up which CSS it maps to.
|
|
10
10
|
*/
|
|
11
|
-
export type MPAspectFit = 'cover' | 'contain' | 'fill' | 'none';
|
|
11
|
+
export type MPAspectFit = 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
|
|
12
12
|
export interface MPAspectRatioProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
13
13
|
/**
|
|
14
14
|
* The proportion the box holds, written the way CSS writes it — a number
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import*as e from"react";import{useRender as o}from"@base-ui/react/use-render";import{useMPSize as i}from"../../internal/config.js";const
|
|
2
|
+
import*as e from"react";import{useRender as o}from"@base-ui/react/use-render";import{useMPSize as i}from"../../internal/config.js";const c={xs:"rounded-mp-xs",sm:"rounded-mp-sm",md:"rounded-mp-md",lg:"rounded-mp-md",xl:"rounded-mp-xl"},t=/*@__PURE__*/["[&>img]:size-full","[&>video]:size-full","[&>canvas]:size-full","[&>svg]:size-full","[&>iframe]:size-full","[&>picture]:size-full","[&>picture>img]:size-full"].join(" "),r={cover:"[&>img]:object-cover [&>video]:object-cover [&>picture>img]:object-cover",contain:"[&>img]:object-contain [&>video]:object-contain [&>picture>img]:object-contain",fill:"[&>img]:object-fill [&>video]:object-fill [&>picture>img]:object-fill",none:"[&>img]:object-none [&>video]:object-none [&>picture>img]:object-none","scale-down":"[&>img]:object-scale-down [&>video]:object-scale-down [&>picture>img]:object-scale-down"};export const MPAspectRatio=/*@__PURE__*/e.forwardRef(function({ratio:e=1,fit:n="cover",rounded:l=!1,size:s,render:d,className:m,style:a,children:u,...f},p){const j=i(s),b=["mp-aspect-ratio relative block w-full overflow-hidden",t,r[n],l?c[j]:"",m??""].filter(Boolean).join(" ");return o({render:d,ref:p,props:{"data-mp-size":j,className:b,style:{aspectRatio:e,...a},children:u,...f}})});
|
|
@@ -73,6 +73,14 @@ export interface MPBlockquoteProps extends Omit<React.ComponentPropsWithoutRef<'
|
|
|
73
73
|
* outrank, so a rule drawn on the quote itself would silently come out grey and
|
|
74
74
|
* a pixel too thin.
|
|
75
75
|
*
|
|
76
|
+
* The one thing said on it is `m-0`, and that is taking something off rather
|
|
77
|
+
* than drawing: a browser gives every `<blockquote>` and every `<figure>` a
|
|
78
|
+
* margin of `1em 40px`, and a page with no reset would otherwise set the words
|
|
79
|
+
* forty pixels in from their own rule. A host that styles `blockquote` by name
|
|
80
|
+
* still outranks the zero, and that is left alone on purpose. A `.prose
|
|
81
|
+
* blockquote` margin is a page deciding how its quotes sit in its text, and a
|
|
82
|
+
* quote dropped into that text should sit the same way.
|
|
83
|
+
*
|
|
76
84
|
* The wrapper is a `<figure>` when there is an attribution and a `<div>` when
|
|
77
85
|
* there is not, because the HTML specification is explicit that the attribution
|
|
78
86
|
* goes *outside* the blockquote — a name inside it claims the speaker said their
|
|
@@ -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{accentSlots as n}from"../../internal/accent.js";import{transitionProps as r}from"../../internal/transition.js";import{hasContent as i,META_TEXT as l,SHEET_PAD as o}from"../../internal/scale.js";import{useMPColor as
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as a from"react";import{accentSlots as n}from"../../internal/accent.js";import{transitionProps as r}from"../../internal/transition.js";import{hasContent as i,META_TEXT as l,SHEET_PAD as o}from"../../internal/scale.js";import{useMPColor as s,useMPSize as c}from"../../internal/config.js";const m={xs:"text-mp-body-medium",sm:"text-mp-body-large",md:"text-mp-title-large",lg:"text-mp-headline-small",xl:"text-mp-headline-medium"},d="border-s-2 [border-inline-start-color:var(--_mp-accent)]",p={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-on-surface",outlined:"border-mp-outline-variant border border-s-2 bg-transparent text-mp-on-surface",text:"bg-transparent text-mp-on-surface"};function u(){return e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"size-full",children:e("path",{d:"M6.4 3.6c-2.3.9-3.7 2.8-3.7 5.1 0 2 1.2 3.3 2.8 3.3 1.4 0 2.5-1 2.5-2.4 0-1.3-.9-2.2-2.1-2.2-.2 0-.4 0-.6.1.3-1 1.1-1.8 2.2-2.3l-1.1-1.6ZM13.3 3.6c-2.3.9-3.7 2.8-3.7 5.1 0 2 1.2 3.3 2.8 3.3 1.4 0 2.5-1 2.5-2.4 0-1.3-.9-2.2-2.1-2.2-.2 0-.4 0-.6.1.3-1 1.1-1.8 2.2-2.3l-1.1-1.6Z",fill:"currentColor"})})}export const MPBlockquote=/*@__PURE__*/a.forwardRef(function({variant:a="text",size:f,color:x,author:h,source:b,cite:g,icon:v,transition:N,className:j,style:y,children:w,...z},_){const k=c(f),q=s(x),B=i(h)||i(b),M=void 0===v?e(u,{}):v,Z="text"!==a,C=r(N),P=["mp-blockquote m-0 flex flex-col",m[k],d,Z?"rounded-mp-md rounded-s-none":"",p[a],Z?o[k]:"ps-4",C.className,j??""].filter(Boolean).join(" "),R=t("blockquote",{cite:g,className:"m-0",children:[i(M)?e("span",{"aria-hidden":"true",className:"mb-1 block size-[2em] opacity-38",children:M}):null,w]}),A={...n(q),...C.style,...y};return B?t("figure",{ref:_,"data-mp-size":k,"data-mp-variant":a,className:P,style:A,...z,children:[R,t("figcaption",{className:["mt-2 flex flex-wrap items-baseline gap-x-1.5",Z?"opacity-80":"text-mp-on-surface-variant",l].join(" "),children:[i(h)?t("span",{className:"font-medium",children:[e("span",{"aria-hidden":"true",children:"— "}),h]}):null,i(b)?e("cite",{className:"not-italic",children:b}):null]})]}):e("div",{ref:_,"data-mp-size":k,"data-mp-variant":a,className:P,style:A,...z,children:R})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import*as a from"react";import{useRender as o}from"@base-ui/react/use-render";import{linkRel as r}from"../../internal/link.js";import{MPStateLayer as i}from"../../internal/StateLayer.js";import{hasContent as l}from"../../internal/scale.js";import{VISUALLY_HIDDEN as s}from"../../internal/visually-hidden.js";import{MPBottomNavigationContext as m}from"../../internal/bottom-navigation.js";import{useMPSize as d}from"../../internal/config.js";const u={xs:"h-14",sm:"h-16",md:"h-20",lg:"h-22",xl:"h-24"},c={xs:{box:"h-6 w-12",open:"w-12",shut:"w-6"},sm:{box:"h-7 w-14",open:"w-14",shut:"w-7"},md:{box:"h-8 w-16",open:"w-16",shut:"w-8"},lg:{box:"h-9 w-18",open:"w-18",shut:"w-9"},xl:{box:"h-10 w-20",open:"w-20",shut:"w-10"}},p={xs:20,sm:22,md:24,lg:26,xl:28},f={xs:"text-mp-label-small",sm:"text-mp-label-small",md:"text-mp-label-medium",lg:"text-mp-label-medium",xl:"text-mp-label-large"},b={xs:"gap-0.5",sm:"gap-0.5",md:"gap-1",lg:"gap-1",xl:"gap-1.5"},x={static:"",absolute:"absolute inset-x-0 bottom-0 z-30",sticky:"sticky bottom-0 z-30",fixed:"fixed inset-x-0 bottom-0 z-40"};export const MPBottomNavigation=/*@__PURE__*/a.forwardRef(function({value:t,defaultValue:n=null,onValueChange:r,position:i="fixed",labels:l="all",size:s,divider:c=!1,safeArea:p=!0,disabled:f=!1,label:b,render:h,className:v,children:g,...w},y){const j=d(s),[z,N]=a.useState(n),k=void 0!==t,C=k?t:z,B=a.useCallback(e=>{k||N(e),r?.(e)},[k,r]),$=a.useMemo(()=>({value:C??null,change:B,size:j,labels:l,disabled:f,floating:!1}),[C,B,j,l,f]);return o({render:h??e("nav",{}),ref:y,props:{"aria-label":b,"data-mp-size":j,className:["mp-bottom-navigation bg-mp-surface-container text-mp-on-surface box-border w-full",c?"border-mp-outline-variant border-t":"",x[i],p?"pb-[env(safe-area-inset-bottom)]":"",v??""].filter(Boolean).join(" "),children:e(m.Provider,{value:$,children:e("div",{className:`flex w-full items-stretch ${u[j]}`,children:g})}),...w}})});export const MPBottomNavigationItem=/*@__PURE__*/a.forwardRef(function({value:o,icon:d,activeIcon:u,href:x,target:v,rel:g,render:w,disabled:y=!1,className:j,children:z,onClick:N,...k},C){const B=a.useContext(m),$=y||B.disabled,M=null!==B.value&&B.value===o,P="all"===B.labels||"selected"===B.labels&&M,I=["mp-bottom-navigation__item group flex min-w-0 flex-col items-center justify-center",B.floating?"shrink-0":"flex-1","box-border appearance-none bg-transparent px-1 font-[inherit] no-underline select-none",b[B.size],"outline-mp-secondary focus-visible:outline-2 focus-visible:-outline-offset-2","focus-visible:outline-solid outline-none",$?"text-mp-on-surface/38 cursor-default":M?"text-mp-on-surface cursor-pointer":"text-mp-on-surface-variant cursor-pointer",j??""].filter(Boolean).join(" "),R=t(n,{children:[l(d)||l(u)?t("span",{className:["relative flex shrink-0 items-center justify-center overflow-hidden","rounded-mp-full","transition-[color] duration-(--mp-sys-motion-duration-short4)",c[B.size].box,M&&!$?"text-mp-on-secondary-container":""].filter(Boolean).join(" "),children:[$?null:e("span",{"aria-hidden":"true",className:["pointer-events-none absolute inset-y-0 left-1/2 -translate-x-1/2","rounded-mp-full bg-mp-secondary-container","transition-[width,opacity] duration-(--mp-sys-motion-duration-short4)","ease-mp-standard",M?`${c[B.size].open} opacity-100`:`${c[B.size].shut} opacity-0`].join(" ")}),$?null:e(i,{}),e("span",{className:"relative flex items-center justify-center",style:{width:p[B.size],height:p[B.size]},children:M?u??d:d})]}):null,l(z)?e("span",{className:P?`max-w-full truncate ${f[B.size]}`:s,children:z}):null]}),S=e=>{$?e.preventDefault():(B.change(o),N?.(e))};return e(h,x?{render:w,props:{ref:C,href:$?void 0:x,target:v,rel:r(v,g),"aria-current":M?"page":void 0,"aria-disabled":$||void 0,className:I,onClick:S,children:R,...k}}:{render:w,props:{ref:C,type:w?void 0:"button",disabled:$,"aria-current":M?"page":void 0,className:I,onClick:S,children:R,...k}})});function h({render:t,props:n}){return o({render:t??(n.href?e("a",{}):e("button",{})),props:n})}
|
|
2
|
+
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import*as a from"react";import{useRender as o}from"@base-ui/react/use-render";import{linkRel as r}from"../../internal/link.js";import{MPStateLayer as i}from"../../internal/StateLayer.js";import{hasContent as l}from"../../internal/scale.js";import{VISUALLY_HIDDEN as s}from"../../internal/visually-hidden.js";import{MPBottomNavigationContext as m}from"../../internal/bottom-navigation.js";import{useMPSize as d}from"../../internal/config.js";const u={xs:"h-14",sm:"h-16",md:"h-20",lg:"h-22",xl:"h-24"},c={xs:{box:"h-6 w-12",open:"w-12",shut:"w-6"},sm:{box:"h-7 w-14",open:"w-14",shut:"w-7"},md:{box:"h-8 w-16",open:"w-16",shut:"w-8"},lg:{box:"h-9 w-18",open:"w-18",shut:"w-9"},xl:{box:"h-10 w-20",open:"w-20",shut:"w-10"}},p={xs:20,sm:22,md:24,lg:26,xl:28},f={xs:"text-mp-label-small",sm:"text-mp-label-small",md:"text-mp-label-medium",lg:"text-mp-label-medium",xl:"text-mp-label-large"},b={xs:"gap-0.5",sm:"gap-0.5",md:"gap-1",lg:"gap-1",xl:"gap-1.5"},x={static:"",absolute:"absolute inset-x-0 bottom-0 z-30",sticky:"sticky bottom-0 z-30",fixed:"fixed inset-x-0 bottom-0 z-40"};export const MPBottomNavigation=/*@__PURE__*/a.forwardRef(function({value:t,defaultValue:n=null,onValueChange:r,position:i="fixed",labels:l="all",size:s,divider:c=!1,safeArea:p=!0,disabled:f=!1,label:b,render:h,className:v,children:g,...w},y){const j=d(s),[z,N]=a.useState(n),k=void 0!==t,C=k?t:z,B=a.useCallback(e=>{k||N(e),r?.(e)},[k,r]),$=a.useMemo(()=>({value:C??null,change:B,size:j,labels:l,disabled:f,floating:!1}),[C,B,j,l,f]);return o({render:h??e("nav",{}),ref:y,props:{"aria-label":b,"data-mp-size":j,className:["mp-bottom-navigation bg-mp-surface-container text-mp-on-surface box-border w-full",c?"border-mp-outline-variant border-t":"",x[i],p?"pb-[env(safe-area-inset-bottom)]":"",v??""].filter(Boolean).join(" "),children:e(m.Provider,{value:$,children:e("div",{className:`flex w-full items-stretch ${u[j]}`,children:g})}),...w}})});export const MPBottomNavigationItem=/*@__PURE__*/a.forwardRef(function({value:o,icon:d,activeIcon:u,href:x,target:v,rel:g,render:w,disabled:y=!1,className:j,children:z,onClick:N,...k},C){const B=a.useContext(m),$=y||B.disabled,M=null!==B.value&&B.value===o,P="all"===B.labels||"selected"===B.labels&&M,I=["mp-bottom-navigation__item group flex min-w-0 flex-col items-center justify-center",B.floating?"shrink-0":"flex-1","box-border appearance-none border-0 bg-transparent px-1 font-[inherit] no-underline select-none",b[B.size],"outline-mp-secondary focus-visible:outline-2 focus-visible:-outline-offset-2","focus-visible:outline-solid outline-none",$?"text-mp-on-surface/38 cursor-default":M?"text-mp-on-surface cursor-pointer":"text-mp-on-surface-variant cursor-pointer",j??""].filter(Boolean).join(" "),R=t(n,{children:[l(d)||l(u)?t("span",{className:["relative flex shrink-0 items-center justify-center overflow-hidden","rounded-mp-full","transition-[color] duration-(--mp-sys-motion-duration-short4)",c[B.size].box,M&&!$?"text-mp-on-secondary-container":""].filter(Boolean).join(" "),children:[$?null:e("span",{"aria-hidden":"true",className:["pointer-events-none absolute inset-y-0 left-1/2 -translate-x-1/2","rounded-mp-full bg-mp-secondary-container","transition-[width,opacity] duration-(--mp-sys-motion-duration-short4)","ease-mp-standard",M?`${c[B.size].open} opacity-100`:`${c[B.size].shut} opacity-0`].join(" ")}),$?null:e(i,{}),e("span",{className:"relative flex items-center justify-center",style:{width:p[B.size],height:p[B.size]},children:M?u??d:d})]}):null,l(z)?e("span",{className:P?`max-w-full truncate ${f[B.size]}`:s,children:z}):null]}),S=e=>{$?e.preventDefault():(B.change(o),N?.(e))};return e(h,x?{render:w,props:{ref:C,href:$?void 0:x,target:v,rel:r(v,g),"aria-current":M?"page":void 0,"aria-disabled":$||void 0,className:I,onClick:S,children:R,...k}}:{render:w,props:{ref:C,type:w?void 0:"button",disabled:$,"aria-current":M?"page":void 0,className:I,onClick:S,children:R,...k}})});function h({render:t,props:n}){return o({render:t??(n.href?e("a",{}):e("button",{})),props:n})}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as n,Fragment as t}from"react/jsx-runtime";import*as r from"react";import{MPIcon as o}from"../icon/MPIcon.js";import{ArrowRightIcon as i,ChevronRightIcon as a,MoreIcon as s}from"../../constants/icons.js";import{accentSlots as l}from"../../internal/accent.js";import{useMPLocale as c,useMPMessages as m}from"../../internal/locale.js";import{BREADCRUMB as d}from"../../internal/messages/breadcrumb.js";import{CONTROL_GAP as u,hasContent as p,PROSE_TEXT as f}from"../../internal/scale.js";import{useMPColor as h,useMPSize as x}from"../../internal/config.js";const b=/*@__PURE__*/r.createContext({size:"md",last:!1,position:null}),v={xs:"gap-1",sm:"gap-1.5",md:"gap-2",lg:"gap-2.5",xl:"gap-3"},g={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__*/r.forwardRef(function({size:t,color:u,separator:p="chevron",maxItems:g,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 _=x(t),A=h(u),E=m(d,c(C)),[F,R]=r.useState(!1),T=r.Children.toArray(I).filter(r.isValidElement),D=T.length,V=T.some(e=>!0===e.props.current),$=!F&&!w&&void 0!==g&&D>Math.max(g,1)&&D-j-y>1?[...T.slice(0,Math.max(0,j)),null,...T.slice(D-Math.max(0,y))]:T,q="string"==typeof(G=p)&&N.includes(G)?function(n){switch(n){case"chevron":return e(o,{icon:a,size:"1.1em",className:"rtl:rotate-180"});case"arrow":return e(o,{icon:i,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}}(p):p;var G;const H=r.useMemo(()=>Array.from({length:$.length},(e,n)=>({size:_,last:!V&&n===$.length-1,position:w?n+1:null})),[_,V,$.length,w]),J=["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??E.label,"data-mp-size":_,className:["mp-breadcrumb flex",f[_],P??""].filter(Boolean).join(" "),style:{...l(A),...M},...L,children:e("ol",{role:"list",itemScope:w||void 0,itemType:w?"https://schema.org/BreadcrumbList":void 0,className:`flex list-none flex-wrap items-center p-0 ${v[_]}`,children:$.map((t,i)=>n(r.Fragment,{children:[i>0?e("li",{"aria-hidden":"true",className:"text-mp-on-surface-variant flex shrink-0 items-center select-none",children:q}):null,t?e(b.Provider,{value:H[i],children:t}):e("li",{className:"flex shrink-0 items-center",children:k?e("button",{type:"button",className:J,"aria-label":B??E.expand,onClick:()=>R(!0),children:e(o,{icon:s,size:"1.1em"})}):e("span",{className:J,"aria-hidden":"true",children:e(o,{icon:s,size:"1.1em"})})})]},t?t.key??i:"fold"))})})});export const MPBreadcrumbItem=/*@__PURE__*/r.forwardRef(function({href:o,onClick:i,startIcon:a,endIcon:s,current:l,disabled:c=!1,className:m,children:d,...f},h){const{size:x,last:v,position:N}=r.useContext(b),j=l??v,y=Boolean(o||i)&&!j&&!c,k=null!==N,z=["inline-flex min-w-0 items-center px-1 no-underline","appearance-none border-0 bg-transparent font-[inherit] text-[inherit]",u[x],g[x],"transition-[background-color,color] duration-(--mp-sys-motion-duration-short4)",c?"text-mp-on-surface/38 cursor-default":j?"text-mp-on-surface font-medium":y?["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(" "),B=n(t,{children:[p(a)?e("span",{className:"flex h-[1lh] shrink-0 items-center",children:a}):null,e("span",{className:"truncate",itemProp:k?"name":void 0,children:d}),p(s)?e("span",{className:"flex h-[1lh] shrink-0 items-center",children:s}):null]});return n("li",{ref:h,itemProp:k?"itemListElement":void 0,itemScope:k||void 0,itemType:k?"https://schema.org/ListItem":void 0,className:["flex min-w-0 items-center",m??""].filter(Boolean).join(" "),...f,children:[k?e("meta",{itemProp:"position",content:String(N)}):null,y&&o?e("a",{href:o,itemProp:k?"item":void 0,className:z,onClick:i,children:B}):y?e("button",{type:"button",className:z,onClick:i,children:B}):e("span",{className:z,"aria-current":j?"page":void 0,"aria-disabled":c||void 0,children:B})]})});
|
|
2
|
+
import{jsx as e,jsxs as n,Fragment as t}from"react/jsx-runtime";import*as r from"react";import{MPIcon as o}from"../icon/MPIcon.js";import{ArrowRightIcon as i,ChevronRightIcon as a,MoreIcon as s}from"../../constants/icons.js";import{accentSlots as l}from"../../internal/accent.js";import{useMPLocale as c,useMPMessages as m}from"../../internal/locale.js";import{BREADCRUMB as d}from"../../internal/messages/breadcrumb.js";import{CONTROL_GAP as u,hasContent as p,PROSE_TEXT as f}from"../../internal/scale.js";import{useMPColor as h,useMPSize as x}from"../../internal/config.js";const b=/*@__PURE__*/r.createContext({size:"md",last:!1,position:null}),v={xs:"gap-1",sm:"gap-1.5",md:"gap-2",lg:"gap-2.5",xl:"gap-3"},g={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__*/r.forwardRef(function({size:t,color:u,separator:p="chevron",maxItems:g,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 _=x(t),A=h(u),E=m(d,c(C)),[F,R]=r.useState(!1),T=r.Children.toArray(I).filter(r.isValidElement),D=T.length,V=T.some(e=>!0===e.props.current),$=!F&&!w&&void 0!==g&&D>Math.max(g,1)&&D-j-y>1?[...T.slice(0,Math.max(0,j)),null,...T.slice(D-Math.max(0,y))]:T,q="string"==typeof(G=p)&&N.includes(G)?function(n){switch(n){case"chevron":return e(o,{icon:a,size:"1.1em",className:"rtl:rotate-180"});case"arrow":return e(o,{icon:i,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}}(p):p;var G;const H=r.useMemo(()=>Array.from({length:$.length},(e,n)=>({size:_,last:!V&&n===$.length-1,position:w?n+1:null})),[_,V,$.length,w]),J=["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??E.label,"data-mp-size":_,className:["mp-breadcrumb flex",f[_],P??""].filter(Boolean).join(" "),style:{...l(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 ${v[_]}`,children:$.map((t,i)=>n(r.Fragment,{children:[i>0?e("li",{"aria-hidden":"true",className:"text-mp-on-surface-variant flex shrink-0 items-center select-none",children:q}):null,t?e(b.Provider,{value:H[i],children:t}):e("li",{className:"flex shrink-0 items-center",children:k?e("button",{type:"button",className:J,"aria-label":B??E.expand,onClick:()=>R(!0),children:e(o,{icon:s,size:"1.1em"})}):e("span",{className:J,"aria-hidden":"true",children:e(o,{icon:s,size:"1.1em"})})})]},t?t.key??i:"fold"))})})});export const MPBreadcrumbItem=/*@__PURE__*/r.forwardRef(function({href:o,onClick:i,startIcon:a,endIcon:s,current:l,disabled:c=!1,className:m,children:d,...f},h){const{size:x,last:v,position:N}=r.useContext(b),j=l??v,y=Boolean(o||i)&&!j&&!c,k=null!==N,z=["inline-flex min-w-0 items-center px-1 no-underline","appearance-none border-0 bg-transparent font-[inherit] text-[inherit]",u[x],g[x],"transition-[background-color,color] duration-(--mp-sys-motion-duration-short4)",c?"text-mp-on-surface/38 cursor-default":j?"text-mp-on-surface font-medium":y?["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(" "),B=n(t,{children:[p(a)?e("span",{className:"flex h-[1lh] shrink-0 items-center",children:a}):null,e("span",{className:"truncate",itemProp:k?"name":void 0,children:d}),p(s)?e("span",{className:"flex h-[1lh] shrink-0 items-center",children:s}):null]});return n("li",{ref:h,itemProp:k?"itemListElement":void 0,itemScope:k||void 0,itemType:k?"https://schema.org/ListItem":void 0,className:["flex min-w-0 items-center",m??""].filter(Boolean).join(" "),...f,children:[k?e("meta",{itemProp:"position",content:String(N)}):null,y&&o?e("a",{href:o,itemProp:k?"item":void 0,className:z,onClick:i,children:B}):y?e("button",{type:"button",className:z,onClick:i,children:B}):e("span",{className:z,"aria-current":j?"page":void 0,"aria-disabled":c||void 0,children:B})]})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as
|
|
2
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import*as t from"react";import{Button as r}from"@base-ui/react/button";import{MPIcon as n}from"../icon/MPIcon.js";import{SpinnerIcon as a}from"../../constants/icons.js";import{accentSlots as i}from"../../internal/accent.js";import{MPButtonGroupContext as s}from"../../internal/button-group.js";import{useMPLocale as l,useMPMessages as c}from"../../internal/locale.js";import{COMMON as d}from"../../internal/messages/common.js";import{MPStateLayer as m}from"../../internal/StateLayer.js";import{CONTROL_GAP as p,CONTROL_HEIGHT as u,CONTROL_ICON as f,CONTROL_PAD_X as b,CONTROL_SQUARE as g,CONTROL_TEXT as x,hasContent as v}from"../../internal/scale.js";import{useMPColor as j,useMPSize as h}from"../../internal/config.js";const w={filled:"border-0 bg-(--_mp-accent) text-(--_mp-on-accent)",tonal:"border-0 bg-(--_mp-accent-container) text-(--_mp-on-accent-container)",elevated:"shadow-mp-1 hover:shadow-mp-2 border-0 bg-mp-surface-container-low text-(--_mp-accent)",outlined:"border-mp-outline border bg-transparent text-(--_mp-accent)",text:"border-0 bg-transparent text-(--_mp-accent)"},y={filled:"border-0 bg-mp-on-surface/12 text-mp-on-surface/38",tonal:"border-0 bg-mp-on-surface/12 text-mp-on-surface/38",elevated:"border-0 bg-mp-on-surface/12 text-mp-on-surface/38 shadow-none",outlined:"border-mp-on-surface/12 border bg-transparent text-mp-on-surface/38",text:"border-0 bg-transparent text-mp-on-surface/38"};export const MPButton=/*@__PURE__*/t.forwardRef(function({variant:_,size:B,color:k,disabled:z,startIcon:C,endIcon:I,loading:N=!1,loadingLabel:P,locale:L,fullWidth:M=!1,type:D="button",render:R,nativeButton:S=!0,className:W,style:$,children:q,onClick:A,...E},F){const G=l(L),H=c(d,G),J=t.useContext(s),K=_??J?.variant??"filled",O=h(B??J?.size),Q=j(k??J?.color),T=z??J?.disabled??!1,U=N||v(C),V=!(v(q)||U&&v(I));return o(r,{ref:F,render:R,nativeButton:S,type:S?D:void 0,disabled:T,"aria-busy":N||void 0,"aria-disabled":N||void 0,"data-mp-size":O,"data-mp-variant":K,"data-loading":N||void 0,className:["mp-button group relative inline-flex shrink-0 items-center justify-center","rounded-mp-full box-border overflow-hidden align-middle whitespace-nowrap select-none","cursor-pointer appearance-none font-[inherit]","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none","transition-[background-color,border-color,box-shadow,color]","duration-(--mp-sys-motion-duration-short4)",u[O],x[O],p[O],V?`${g[O]} px-0`:b[O],T?y[K]:w[K],T?"cursor-default":"",N?"cursor-progress":"",M?"w-full":"",W??""].filter(Boolean).join(" "),style:{...i(Q),...$},onClick:e=>{if(N)return e.preventDefault(),void e.stopPropagation();A?.(e)},...E,children:[T?null:e(m,{}),N?e(n,{icon:a,size:f[O],label:P??H.loading,className:"animate-spin"}):C,q,I]})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as o from"react";import{Calendar as a}from"../../internal/Calendar.js";import{accentSlots as n}from"../../internal/accent.js";import{POPUP_PAD as s}from"../../internal/Picker.js";import{useMPLocale as r,useMPMessages as i}from"../../internal/locale.js";import{PICKER as l}from"../../internal/messages/picker.js";import{CONTAINER_SURFACE as m}from"../../internal/surface.js";import{
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as o from"react";import{Calendar as a}from"../../internal/Calendar.js";import{accentSlots as n}from"../../internal/accent.js";import{POPUP_PAD as s}from"../../internal/Picker.js";import{useMPLocale as r,useMPMessages as i}from"../../internal/locale.js";import{PICKER as l}from"../../internal/messages/picker.js";import{CONTAINER_SURFACE as m}from"../../internal/surface.js";import{TO_ISO as u,isValidDate as c,localeWeekStart as d,mergeDateAndTime as f,startOfMonth as p,startOfUnit as h,today as x}from"../../internal/date.js";import{useMPColor as j,useMPSize as v}from"../../internal/config.js";export const MPCalendar=/*@__PURE__*/o.forwardRef(function({value:D,defaultValue:w,onValueChange:y,month:g,defaultMonth:B,onMonthChange:C,precision:S="day",minDate:b,maxDate:k,shouldDisableDate:M,locale:N,weekStartsOn:O,showOutsideDays:P=!0,showPreviousButton:z=!0,showNextButton:F=!0,autoFocus:V=!1,variant:R="text",size:$,color:q,labels:A,name:E,className:G,style:H,...I},J){const K=v($),L=j(q),Q=r(N),T=i(l,Q,A),U=O??d(Q),[W,X]=o.useState(w??null),Y=void 0!==D?D:W,[Z,_]=o.useState(()=>{const e=D??w;return p(c(e)?e:B??x())}),ee=void 0!==g?p(g):Z,te=e=>{void 0===g&&_(e),C?.(e)};return t("div",{...I,ref:J,"data-mp-size":K,style:{...n(L),...H},className:["mp-calendar-root inline-flex flex-col","text"===R?"":`rounded-mp-md ${s[K]}`,m[R],"text"===R?"":"text-mp-on-surface",G??""].filter(Boolean).join(" "),children:[e(a,{size:K,color:L,locale:Q,weekStartsOn:U,month:ee,onMonthChange:te,selected:[Y],onSelect:e=>{const t=h(e,S),o=c(Y)?f(t,Y):t;void 0===D&&X(o),y?.(o),te(p(o))},minDate:b,maxDate:k,shouldDisableDate:M,showOutsideDays:P,showPreviousButton:z,showNextButton:F,precision:S,labels:T,autoFocus:V}),E?e("input",{type:"hidden",name:E,value:c(Y)?u[S](Y):""}):null]})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as t from"react";import{MPIconButton as n}from"../icon-button/MPIconButton.js";import{MPIcon as o}from"../icon/MPIcon.js";import{ChevronLeftIcon as a,ChevronRightIcon as i}from"../../constants/icons.js";import{accentSlots as s}from"../../internal/accent.js";import{fillMessage as l}from"../../internal/i18n.js";import{useMPLocale as c,useMPMessages as u}from"../../internal/locale.js";import{CAROUSEL as d}from"../../internal/messages/carousel.js";import{CONTROL_ICON as m}from"../../internal/scale.js";import{CONTAINER_SURFACE as f}from"../../internal/surface.js";import{VISUALLY_HIDDEN as p}from"../../internal/visually-hidden.js";import{useMPColor as
|
|
2
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as t from"react";import{MPIconButton as n}from"../icon-button/MPIconButton.js";import{MPIcon as o}from"../icon/MPIcon.js";import{ChevronLeftIcon as a,ChevronRightIcon as i}from"../../constants/icons.js";import{accentSlots as s}from"../../internal/accent.js";import{fillMessage as l}from"../../internal/i18n.js";import{useMPLocale as c,useMPMessages as u}from"../../internal/locale.js";import{CAROUSEL as d}from"../../internal/messages/carousel.js";import{CONTROL_ICON as m}from"../../internal/scale.js";import{CONTAINER_SURFACE as f}from"../../internal/surface.js";import{VISUALLY_HIDDEN as p}from"../../internal/visually-hidden.js";import{useMPColor as b,useMPSize as h}from"../../internal/config.js";const v=/*@__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(" "),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:{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__*/t.forwardRef(function({value:x,defaultValue:j=0,onValueChange:N,loop:y=!0,autoPlay:M=!1,interval:k=5e3,arrows:R=!0,indicators:C=!0,variant:z="outlined",size:I,color:P,label:S,previousLabel:L,nextLabel:_,slideLabel:E,locale:T,className:$,style:A,children:B,...F},V){const W=h(I),q=b(P),D=u(d,c(T)),G=S??D.label,H=E??((e,r)=>l(D.slide,{index:String(e),total:String(r)})),J=t.Children.toArray(B),K=J.length,[O,Q]=t.useState(j),U=Math.min(Math.max(x??O,0),Math.max(K-1,0)),X=t.useRef(null),Y=t.useRef([]),Z=t.useRef(!1),ee=t.useRef(!1),re=t.useRef(!1),[te,ne]=t.useState(!1),[oe,ae]=t.useState(!1),ie=te||oe,se=t.useRef(U),le=t.useRef(N);se.current=U,le.current=N;const ce=t.useCallback((e,r=!1)=>{if(0===K)return;const t=y?(e%K+K)%K:Math.min(Math.max(e,0),K-1);Z.current=r,void 0===x&&Q(t),t!==se.current&&le.current?.(t)},[K,y,x]);t.useEffect(()=>{if(Z.current)return void(Z.current=!1);if(!ee.current)return void(ee.current=!0);Y.current[U]?.scrollIntoView({block:"nearest",inline:"start"}),re.current=!0;const e=window.setTimeout(()=>{re.current=!1},700);return()=>window.clearTimeout(e)},[U]),t.useEffect(()=>{if(!M||ie||K<2)return;if(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;const e=window.setInterval(()=>{document.hidden||ce(se.current+1)},k);return()=>window.clearInterval(e)},[M,ie,K,k,ce]);const ue=t.useRef(0);t.useEffect(()=>()=>cancelAnimationFrame(ue.current),[]);const de=U<=0,me=U>=K-1;return r("div",{ref:V,role:"region","aria-roledescription":"carousel","aria-label":G,"data-mp-size":W,"data-mp-variant":z,className:["mp-carousel flex w-full flex-col",$??""].filter(Boolean).join(" "),style:{...s(q),...A},onPointerEnter:()=>ne(!0),onPointerLeave:()=>ne(!1),onFocus:()=>ae(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||ae(!1)},...F,children:[r("div",{className:["relative min-w-0 overflow-hidden","rounded-mp-md box-border",f[z],"text-mp-on-surface"].join(" "),children:[e("div",{ref:X,tabIndex:0,role:"group","aria-label":G,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:()=>{ue.current||(ue.current=requestAnimationFrame(()=>{ue.current=0;const e=X.current;if(!e||0===e.clientWidth||re.current)return;const r=Math.round(Math.abs(e.scrollLeft)/e.clientWidth);r!==se.current&&r>=0&&r<K&&ce(r,!0)}))},children:J.map((r,t)=>e("div",{ref:e=>{Y.current[t]=e,Y.current.length=K},role:"group","aria-roledescription":"slide","aria-label":H(t+1,K),className:"w-full shrink-0 grow-0 basis-full snap-start",children:r},t))}),R&&K>1?r("div",{className:`pointer-events-none absolute inset-y-0 flex items-center ${g[W]}`,children:[e(n,{variant:"filled",size:W,color:q,label:L??D.previous,disabled:!y&&de,className:v,icon:e(o,{icon:a,size:m[W],className:"rtl:rotate-180"}),onClick:()=>ce(U-1)}),e("span",{className:"flex-1"}),e(n,{variant:"filled",size:W,color:q,label:_??D.next,disabled:!y&&me,className:v,icon:e(o,{icon:i,size:m[W],className:"rtl:rotate-180"}),onClick:()=>ce(U+1)})]}):null]}),C&&K>1?e("div",{className:`flex shrink-0 items-center justify-center pt-2 ${w[W].gap}`,children:J.map((r,t)=>e("button",{type:"button","aria-label":H(t+1,K),"aria-current":t===U?"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",t===U?`${w[W].current} bg-(--_mp-accent)`:`${w[W].rest} bg-mp-outline-variant hover:bg-mp-outline`].join(" "),onClick:()=>ce(t)},t))}):null,e("span",{className:p,"aria-live":M?"off":"polite",children:K>0?H(U+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 t}from"@base-ui/react/checkbox";import{Field as n}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:
|
|
2
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as a from"react";import{Checkbox as t}from"@base-ui/react/checkbox";import{Field as n}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),F=h(N),T=F?"error":B,W=b[S],$=a.useId(),A=q??$;return e(n.Root,{className:["mp-checkbox inline-block max-w-full align-top",L??""].filter(Boolean).join(" "),disabled:M,invalid:F,"data-mp-size":S,style:{...c(T),...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(t.Root,{ref:P,id:A,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)",W.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",F?"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",W.halo,"bg-mp-on-surface","group-data-checked:bg-(--_mp-accent)","group-data-indeterminate:bg-(--_mp-accent)"].join(" ")}),e(t.Indicator,{className:`flex items-center justify-center ${l}`,children:e(o,{icon:j?s:i,size:W.glyph,strokeWidth:3})})]})}),h(y)||h(z)||F?r("span",{className:"flex min-w-0 flex-col gap-0.5",children:[h(y)?r(n.Label,{htmlFor:A,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]})})});
|
|
@@ -87,7 +87,7 @@ export interface MPChipProps extends Omit<React.ComponentPropsWithoutRef<'span'>
|
|
|
87
87
|
* ## Why the shell is the button, and not always a span
|
|
88
88
|
*
|
|
89
89
|
* Because of what wraps a chip. Base UI's `render` — which is how a chip becomes
|
|
90
|
-
* an [MPMenu](
|
|
90
|
+
* an [MPMenu](../inputs/menu)'s trigger, a popover's, a tooltip's — merges its handlers
|
|
91
91
|
* and its ARIA onto the element this component *returns*. With a `<span>` there
|
|
92
92
|
* that meant `aria-haspopup`, `aria-expanded`, `id` and `tabindex` landing on
|
|
93
93
|
* something that was not focusable, a second tab stop on the label button
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,Fragment as n,jsxs as t}from"react/jsx-runtime";import*as o from"react";import{MPIcon as
|
|
2
|
+
import{jsx as e,Fragment as n,jsxs as t}from"react/jsx-runtime";import*as o from"react";import{MPIcon as r}from"../icon/MPIcon.js";import{CloseIcon as a}from"../../constants/icons.js";import{accentSlots as i}from"../../internal/accent.js";import{transitionProps as s}from"../../internal/transition.js";import{useMPLocale as l,useMPMessages as c}from"../../internal/locale.js";import{COMMON as m}from"../../internal/messages/common.js";import{hasContent as p}from"../../internal/scale.js";import{MPStateLayer as d}from"../../internal/StateLayer.js";import{useMPColor as u,useMPSize as b}from"../../internal/config.js";const f={xs:"h-6",sm:"h-7",md:"h-8",lg:"h-10",xl:"h-12"},x={xs:"text-mp-label-medium",sm:"text-mp-label-medium",md:"text-mp-label-large",lg:"text-mp-label-large",xl:"text-mp-title-medium"},g={xs:"px-2",sm:"px-3",md:"px-4",lg:"px-5",xl:"px-6"},h={xs:"gap-1",sm:"gap-1.5",md:"gap-2",lg:"gap-2",xl:"gap-2.5"},v={xs:"rounded-mp-xs",sm:"rounded-mp-sm",md:"rounded-mp-sm",lg:"rounded-mp-sm",xl:"rounded-mp-md"},y={filled:"border-0 bg-(--_mp-accent) text-(--_mp-on-accent)",tonal:"border-0 bg-(--_mp-accent-container) text-(--_mp-on-accent-container)",elevated:"shadow-mp-1 border-0 bg-mp-surface-container-low text-mp-on-surface-variant",outlined:"border-mp-outline text-mp-on-surface-variant border bg-transparent",text:"text-mp-on-surface-variant border-0 bg-transparent"},j={filled:"border-0 bg-(--_mp-accent) text-(--_mp-on-accent)",tonal:"border-0 bg-(--_mp-accent-container) text-(--_mp-on-accent-container)",elevated:"shadow-mp-1 border-0 bg-(--_mp-accent-container) text-(--_mp-on-accent-container)",outlined:"border-mp-outline bg-(--_mp-accent-container) text-(--_mp-on-accent-container) border",text:"border-0 bg-(--_mp-accent-container) text-(--_mp-on-accent-container)"},_={filled:"border-0 bg-mp-on-surface/12 text-mp-on-surface/38",tonal:"border-0 bg-mp-on-surface/12 text-mp-on-surface/38",elevated:"border-0 bg-mp-on-surface/12 text-mp-on-surface/38 shadow-none",outlined:"border-mp-on-surface/12 text-mp-on-surface/38 border bg-transparent",text:"border-0 bg-transparent text-mp-on-surface/38"},w=/*@__PURE__*/["ms-0.5 -me-1 inline-flex shrink-0 cursor-pointer items-center justify-center","appearance-none border-0 bg-transparent p-0 text-inherit [font:inherit]","rounded-mp-full size-[1.35em] opacity-70","transition-opacity duration-(--mp-sys-motion-duration-short4)","hover:opacity-100 focus-visible:opacity-100","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-1","focus-visible:outline-solid outline-none","disabled:cursor-default disabled:opacity-38"].join(" "),k=/*@__PURE__*/["group relative flex min-w-0 flex-1 cursor-pointer items-center justify-center","self-stretch rounded-[inherit] font-[inherit] text-[inherit]","appearance-none border-0 bg-transparent","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none"].join(" "),N=/*@__PURE__*/["group cursor-pointer appearance-none font-[inherit]","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none"].join(" ");export const MPChip=/*@__PURE__*/o.forwardRef(function({variant:o="outlined",size:$,color:C,startIcon:z,endIcon:B,count:I,onDelete:L,deleteLabel:M,locale:P,selected:D,disabled:F=!1,transition:R,className:S,style:q,children:A,onClick:E,...G},H){const J=s(R),K=b($),O=u(C),Q=l(P),T=c(m,Q),U=Boolean(E)&&!F,V=U&&Boolean(L),W=U&&!L,X=["mp-chip relative inline-flex max-w-full shrink-0 items-center","box-border overflow-hidden align-middle leading-none whitespace-nowrap select-none","transition-[background-color,border-color,box-shadow,color]","duration-(--mp-sys-motion-duration-short4)",f[K],x[K],h[K],v[K],F?_[o]:D?j[o]:y[o],V?"ps-0":g[K],L?"pe-2":"",W?N:"",S??""].filter(Boolean).join(" "),Y=t(n,{children:[z,p(A)?e("span",{className:"min-w-0 truncate leading-[normal]",children:A}):null,B,p(I)?e("span",{className:["rounded-mp-full ms-0.5 inline-flex shrink-0 items-center justify-center px-1.5 py-px","text-[0.85em] leading-none font-medium tabular-nums","filled"===o?"bg-(--_mp-on-accent)/20 text-(--_mp-on-accent)":"bg-(--_mp-accent-container) text-(--_mp-on-accent-container)"].join(" "),children:I}):null]}),Z={"data-mp-size":K,"data-mp-variant":o,"data-selected":D||void 0,className:`${X}${J.className?` ${J.className}`:""}`,style:{...i(O),...J.style,...q},...G};return W?t("button",{ref:H,type:"button","aria-pressed":D,onClick:E,...Z,children:[e(d,{}),Y]}):t("span",{ref:H,"aria-disabled":!(!F||U)||void 0,...Z,children:[V?t("button",{type:"button","aria-pressed":D,className:`${k} ${h[K]} ${g[K]}`,onClick:E,children:[e(d,{}),Y]}):Y,L?e("button",{type:"button","aria-label":M??T.remove,disabled:F,className:w,onClick:L,children:e(r,{icon:a,size:"1em"})}):null]})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as r from"react";import{Field as n}from"@base-ui/react/field";import{Popover as t}from"@base-ui/react/popover";import{MPIcon as l}from"../icon/MPIcon.js";import{CheckIcon as o,CloseIcon as i}from"../../constants/icons.js";import{MPFieldLabel as s,MPFieldOutline as u,useFloatingLabel as c}from"../../internal/FieldOutline.js";import{useMPSize as d}from"../../internal/config.js";import{useMPLocale as p,useMPMessages as h}from"../../internal/locale.js";import{COLOR_PICKER as m}from"../../internal/messages/color-picker.js";import{MPStateLayer as f}from"../../internal/StateLayer.js";import{MPSupportingText as g}from"../../internal/SupportingText.js";import{CONTROL_ICON as v,META_TEXT as x,PROSE_TEXT as b,STACK_GAP as y,hasContent as w}from"../../internal/scale.js";import{FADE as j,PORTAL_LAYER as N}from"../../internal/surface.js";import{CHECKER_BACKGROUND as k,DEFAULT_SWATCHES as C,clamp as _,cssColor as z,formatColor as P,parseColor as $,readableInk as M}from"../../internal/color.js";const T={xs:"w-40",sm:"w-44",md:"w-52",lg:"w-60",xl:"w-72"},I={xs:"h-24",sm:"h-28",md:"h-32",lg:"h-40",xl:"h-48"},A={xs:"h-2.5",sm:"h-3",md:"h-3.5",lg:"h-4",xl:"h-5"},R={xs:"gap-2",sm:"gap-2.5",md:"gap-3",lg:"gap-3.5",xl:"gap-4"},O={xs:12,sm:14,md:16,lg:18,xl:20},B={xs:{padding:"px-2",height:"h-8"},sm:{padding:"px-3",height:"h-10"},md:{padding:"px-4",height:"h-14"},lg:{padding:"px-4",height:"h-16"},xl:{padding:"px-5",height:"h-18"}},D="border-mp-outline-variant relative overflow-hidden border",L=/*@__PURE__*/["pointer-events-none absolute rounded-full border-2 border-white","[box-shadow:0_0_0_1px_rgb(0_0_0/0.35),0_1px_3px_rgb(0_0_0/0.4)]"].join(" ");function S(e,a,r){return{x:0===e.width?0:_((a-e.left)/e.width,0,1),y:0===e.height?0:_((r-e.top)/e.height,0,1)}}function q(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 F({hsv:n,alphaValue:t,onChange:i,text:s,onTextChange:u,withAlpha:c,swatches:d,editable:p,size:h,inert:m,labels:f}){const g=O[h],v=-g/2,b=z({h:n.h,s:100,v:100}),y=z(n),w=r.useRef(null),j=r.useRef(null),N=r.useRef(0);r.useEffect(()=>()=>{N.current&&cancelAnimationFrame(N.current)},[]);const C=e=>({onPointerDown:a=>{if(m)return;const r=a.currentTarget.getBoundingClientRect();w.current=r,a.currentTarget.setPointerCapture(a.pointerId),e(S(r,a.clientX,a.clientY))},onPointerMove:a=>{const r=w.current;var n;!m&&r&&a.currentTarget.hasPointerCapture(a.pointerId)&&(n=S(r,a.clientX,a.clientY),j.current=n,N.current||(N.current=requestAnimationFrame(()=>{N.current=0;const a=j.current;j.current=null,a&&e(a)})))},onPointerUp:()=>{w.current=null},onPointerCancel:()=>{w.current=null}}),B=(e,a,r,n)=>({role:"slider",tabIndex:m?-1:0,"aria-label":e,"aria-valuemin":0,"aria-valuemax":r,"aria-valuenow":Math.round(a),"aria-orientation":"horizontal","aria-disabled":m||void 0,onKeyDown:e=>{const a=q(e);!m&&a&&0!==a.x&&(e.preventDefault(),n(a.x))}}),F=/*@__PURE__*/["outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none"].join(" "),V=r.useMemo(()=>d?d.map(e=>{const a=$(e);return{swatch:e,parsed:a,hex:null===a?null:P(a.hsv,a.alpha,"hex")}}):[],[d]),K=P(n,t,"hex");return a("div",{className:`mp-color-picker__panel flex flex-col ${T[h]} ${R[h]}`,children:[e("div",{...C(({x:e,y:a})=>i({hsv:{h:n.h,s:100*e,v:100*(1-a)},alpha:t})),role:"slider",tabIndex:m?-1:0,"aria-label":f.area,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(n.s),"aria-valuetext":`${Math.round(n.s)}%, ${Math.round(n.v)}%`,"aria-disabled":m||void 0,onKeyDown:e=>{const a=q(e);!m&&a&&(e.preventDefault(),i({hsv:{h:n.h,s:_(n.s+a.x,0,100),v:_(n.v+a.y,0,100)},alpha:t}))},className:[D,"rounded-mp-sm",I[h],F,m?"cursor-default":"cursor-crosshair touch-none"].join(" "),style:{backgroundColor:b,backgroundImage:"linear-gradient(to top, #000000, rgb(0 0 0 / 0)), linear-gradient(to right, #ffffff, rgb(255 255 255 / 0))"},children:e("span",{className:L,style:{width:g,height:g,left:`${n.s}%`,top:100-n.v+"%",marginLeft:v,marginTop:v,backgroundColor:y}})}),e("div",{...C(({x:e})=>i({hsv:{...n,h:360*e},alpha:t})),...B(f.hue,n.h,360,e=>i({hsv:{...n,h:(n.h+2*e+360)%360},alpha:t})),className:[D,"rounded-mp-full",A[h],F,m?"cursor-default":"cursor-pointer touch-none"].join(" "),style:{backgroundImage:"linear-gradient(to right, #ff0000 0%, #ffff00 16.66%, #00ff00 33.33%, #00ffff 50%, #0000ff 66.66%, #ff00ff 83.33%, #ff0000 100%)"},children:e("span",{className:L,style:{width:g,height:g,left:n.h/360*100+"%",top:"50%",marginLeft:v,marginTop:v,backgroundColor:b}})}),c?a("div",{...C(({x:e})=>i({hsv:n,alpha:e})),...B(f.alpha,100*t,100,e=>i({hsv:n,alpha:_(t+e/100,0,1)})),className:[D,"rounded-mp-full",A[h],F,m?"cursor-default":"cursor-pointer touch-none"].join(" "),style:k,children:[e("span",{"aria-hidden":"true",className:"absolute inset-0",style:{backgroundImage:`linear-gradient(to right, ${z(n,0)}, ${y})`}}),e("span",{className:L,style:{width:g,height:g,left:100*t+"%",top:"50%",marginLeft:v,marginTop:v,backgroundColor:z(n,t)}})]}):null,p?a("div",{className:`flex items-center ${R[h]}`,children:[e("span",{"aria-hidden":"true",className:"border-mp-outline-variant shrink-0 rounded-full border",style:{width:g+8,height:g+8,...k},children:e("span",{className:"block size-full rounded-full",style:{backgroundColor:z(n,t)}})}),e("input",{type:"text",value:s,readOnly:m,spellCheck:!1,autoComplete:"off","aria-label":f.value,onChange:e=>u(e.target.value),className:["rounded-mp-xs border-mp-outline text-mp-on-surface min-w-0 flex-1 border","bg-transparent px-2 py-1 font-mono lowercase",x,"focus-visible:border-mp-primary outline-none"].join(" ")})]}):null,V.length>0?e("div",{role:"group","aria-label":f.swatches,className:"grid grid-cols-8 gap-1",children:V.map(({swatch:a,parsed:r,hex:n},t)=>{const s=null!==r&&n===K;return e("button",{type:"button",disabled:m,"aria-label":a,"aria-pressed":s,onClick:()=>{r&&i({hsv:r.hsv,alpha:r.alpha})},className:["border-mp-outline-variant flex aspect-square items-center justify-center","rounded-full border","transition-[box-shadow] duration-(--mp-sys-motion-duration-short4)","ease-mp-standard",F,m?"cursor-default":"hover:shadow-mp-1 cursor-pointer"].join(" "),style:{backgroundColor:a},children:e("span",{"aria-hidden":"true",className:["transition-opacity duration-(--mp-sys-motion-duration-short4)","ease-mp-standard",s?"opacity-100":"opacity-0"].join(" "),style:r?{color:M(r.hsv)}:void 0,children:e(l,{icon:o,size:12})})},`${t}:${a}`)})}):null]})}const V={h:202,s:100,v:61};export const MPColorPicker=/*@__PURE__*/r.forwardRef(function({value:o,defaultValue:_="#00639b",onValueChange:M,format:T="hex",alpha:I=!1,swatches:A=C,inline:R=!1,editable:O=!0,label:D,floatingLabel:L=!0,description:S,errorMessage:q,required:K=!1,disabled:E=!1,readOnly:U=!1,clearable:X=!1,name:Y,open:W,defaultOpen:G=!1,onOpenChange:H,locale:J,labels:Q,size:Z,fullWidth:ee=!1,id:ae,className:re,style:ne},te){const le=d(Z),oe=p(J),ie=h(m,oe,Q),se=w(q),ue=B[le],ce=r.useId(),de=ae??ce,[pe,he]=r.useState(_),me=o??pe,[fe,ge]=r.useState(G),ve=W??fe,[xe,be]=r.useState(()=>$(me)??{hsv:V,alpha:1}),[ye,we]=r.useState(()=>me),je=P(xe.hsv,I?xe.alpha:1,T),Ne=""===me;r.useEffect(()=>{const e=$(me);e?P(e.hsv,I?e.alpha:1,T)!==je&&(we(me),be(e)):we(me)},[me,je,I,T]);const ke=E||U,Ce=X&&!ke&&!Ne,{shrunk:_e,focusProps:ze}=c({floating:L&&w(D),filled:!Ne,pinned:ve}),Pe=(e,a)=>{be(e);const r=P(e.hsv,I?e.alpha:1,T);we(a??r),void 0===o&&he(r),M?.(r)},$e=e(F,{hsv:xe.hsv,alphaValue:xe.alpha,onChange:Pe,text:ye,onTextChange:e=>{we(e);const a=$(e);a&&Pe(a,e)},withAlpha:I,swatches:A,editable:O,size:le,inert:ke,labels:ie}),Me=e("span",{"aria-hidden":"true",className:"border-mp-outline-variant block size-5 shrink-0 rounded-full border",style:k,children:e("span",{className:"block size-full rounded-full",style:{backgroundColor:Ne?"transparent":z(xe.hsv,I?xe.alpha:1)}})}),Te=Y?e("input",{type:"hidden",name:Y,value:Ne?"":je}):null;return R?a("div",{ref:te,"data-mp-size":le,className:["mp-color-picker flex flex-col",y[le],re??""].filter(Boolean).join(" "),style:ne,children:[w(D)?a("span",{className:[x,E?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:[D,K?e("span",{"aria-hidden":"true",children:" *"}):null]}):null,$e,w(q)?e("span",{className:`${x} text-mp-error`,children:q}):w(S)?e("span",{className:`${x} text-mp-on-surface-variant`,children:S}):null,Te]}):a(n.Root,{ref:te,disabled:E,invalid:se,"data-mp-size":le,className:["mp-color-picker group flex-col align-top",ee?"flex w-full":"inline-flex w-fit",re??""].filter(Boolean).join(" "),style:ne,...ze,children:[a(t.Root,{open:ve,onOpenChange:e=>{void 0===W&&ge(e),H?.(e)},children:[a("div",{className:"relative w-full",children:[a(t.Trigger,{id:de,disabled:E,nativeButton:!0,className:["relative flex w-full items-center gap-2 select-none","appearance-none bg-transparent font-[inherit] outline-none",ue.padding,Ce?"pe-10":"",ue.height,b[le],E?"text-mp-on-surface/38 cursor-default":"text-mp-on-surface "+(U?"cursor-default":"cursor-pointer")].filter(Boolean).join(" "),children:[Ne&&!_e?null:Me,e("span",{className:["min-w-0 flex-1 truncate text-start",Ne?"text-mp-on-surface-variant":""].filter(Boolean).join(" "),children:Ne?_e?ie.empty:null:je})]}),Ce?a("button",{type:"button","aria-label":ie.clear,onClick:()=>{void 0===o&&he(""),we(""),M?.("")},className:["group/clear rounded-mp-full text-mp-on-surface-variant absolute inset-y-0","end-1 my-auto flex size-8 cursor-pointer items-center justify-center","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-1","focus-visible:outline-solid outline-none"].join(" "),children:[e(f,{className:"group-hover/clear:opacity-8 group-focus-visible/clear:opacity-10"}),e(l,{icon:i,size:v[le]})]}):null,e(u,{label:D,required:K,notched:_e}),w(D)?e(s,{size:le,label:D,required:K,htmlFor:de,shrunk:_e}):null]}),e(t.Portal,{children:e(t.Positioner,{className:N,sideOffset:4,align:"start",children:e(t.Popup,{className:["mp-color-picker__popup rounded-mp-md shadow-mp-2 bg-mp-surface-container","text-mp-on-surface p-3 outline-none",b[le],j].join(" "),children:$e})})})]}),e(g,{description:S,errorMessage:q,className:ue.padding}),Te]})});
|
|
2
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as r from"react";import{Field as n}from"@base-ui/react/field";import{Popover as t}from"@base-ui/react/popover";import{MPIcon as o}from"../icon/MPIcon.js";import{CheckIcon as l,CloseIcon as i}from"../../constants/icons.js";import{MPFieldLabel as s,MPFieldOutline as u,useFloatingLabel as c}from"../../internal/FieldOutline.js";import{useMPSize as d}from"../../internal/config.js";import{useMPLocale as p,useMPMessages as h}from"../../internal/locale.js";import{COLOR_PICKER as m}from"../../internal/messages/color-picker.js";import{MPStateLayer as f}from"../../internal/StateLayer.js";import{MPSupportingText as g}from"../../internal/SupportingText.js";import{CONTROL_ICON as b,META_TEXT as v,PROSE_TEXT as x,STACK_GAP as y,hasContent as w}from"../../internal/scale.js";import{FADE as j,PORTAL_LAYER as N}from"../../internal/surface.js";import{CHECKER_BACKGROUND as k,DEFAULT_SWATCHES as C,clamp as _,cssColor as z,formatColor as P,parseColor as $,readableInk as M}from"../../internal/color.js";const T={xs:"w-40",sm:"w-44",md:"w-52",lg:"w-60",xl:"w-72"},I={xs:"h-24",sm:"h-28",md:"h-32",lg:"h-40",xl:"h-48"},A={xs:"h-2.5",sm:"h-3",md:"h-3.5",lg:"h-4",xl:"h-5"},R={xs:"gap-2",sm:"gap-2.5",md:"gap-3",lg:"gap-3.5",xl:"gap-4"},O={xs:12,sm:14,md:16,lg:18,xl:20},B={xs:{padding:"px-2",height:"h-8"},sm:{padding:"px-3",height:"h-10"},md:{padding:"px-4",height:"h-14"},lg:{padding:"px-4",height:"h-16"},xl:{padding:"px-5",height:"h-18"}},D="border-mp-outline-variant relative overflow-hidden border",L=/*@__PURE__*/["pointer-events-none absolute rounded-full border-2 border-white","[box-shadow:0_0_0_1px_rgb(0_0_0/0.35),0_1px_3px_rgb(0_0_0/0.4)]"].join(" ");function S(e,a,r){return{x:0===e.width?0:_((a-e.left)/e.width,0,1),y:0===e.height?0:_((r-e.top)/e.height,0,1)}}function q(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 F({hsv:n,alphaValue:t,onChange:i,text:s,onTextChange:u,withAlpha:c,swatches:d,editable:p,size:h,inert:m,labels:f}){const g=O[h],b=-g/2,x=z({h:n.h,s:100,v:100}),y=z(n),w=r.useRef(null),j=r.useRef(null),N=r.useRef(0);r.useEffect(()=>()=>{N.current&&cancelAnimationFrame(N.current)},[]);const C=e=>({onPointerDown:a=>{if(m)return;const r=a.currentTarget.getBoundingClientRect();w.current=r,a.currentTarget.setPointerCapture(a.pointerId),e(S(r,a.clientX,a.clientY))},onPointerMove:a=>{const r=w.current;var n;!m&&r&&a.currentTarget.hasPointerCapture(a.pointerId)&&(n=S(r,a.clientX,a.clientY),j.current=n,N.current||(N.current=requestAnimationFrame(()=>{N.current=0;const a=j.current;j.current=null,a&&e(a)})))},onPointerUp:()=>{w.current=null},onPointerCancel:()=>{w.current=null}}),B=(e,a,r,n)=>({role:"slider",tabIndex:m?-1:0,"aria-label":e,"aria-valuemin":0,"aria-valuemax":r,"aria-valuenow":Math.round(a),"aria-orientation":"horizontal","aria-disabled":m||void 0,onKeyDown:e=>{const a=q(e);!m&&a&&0!==a.x&&(e.preventDefault(),n(a.x))}}),F=/*@__PURE__*/["outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none"].join(" "),V=r.useMemo(()=>d?d.map(e=>{const a=$(e);return{swatch:e,parsed:a,hex:null===a?null:P(a.hsv,a.alpha,"hex")}}):[],[d]),K=P(n,t,"hex");return a("div",{className:`mp-color-picker__panel flex flex-col ${T[h]} ${R[h]}`,children:[e("div",{...C(({x:e,y:a})=>i({hsv:{h:n.h,s:100*e,v:100*(1-a)},alpha:t})),role:"slider",tabIndex:m?-1:0,"aria-label":f.area,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(n.s),"aria-valuetext":`${Math.round(n.s)}%, ${Math.round(n.v)}%`,"aria-disabled":m||void 0,onKeyDown:e=>{const a=q(e);!m&&a&&(e.preventDefault(),i({hsv:{h:n.h,s:_(n.s+a.x,0,100),v:_(n.v+a.y,0,100)},alpha:t}))},className:[D,"rounded-mp-sm",I[h],F,m?"cursor-default":"cursor-crosshair touch-none"].join(" "),style:{backgroundColor:x,backgroundImage:"linear-gradient(to top, #000000, rgb(0 0 0 / 0)), linear-gradient(to right, #ffffff, rgb(255 255 255 / 0))"},children:e("span",{className:L,style:{width:g,height:g,left:`${n.s}%`,top:100-n.v+"%",marginLeft:b,marginTop:b,backgroundColor:y}})}),e("div",{...C(({x:e})=>i({hsv:{...n,h:360*e},alpha:t})),...B(f.hue,n.h,360,e=>i({hsv:{...n,h:(n.h+2*e+360)%360},alpha:t})),className:[D,"rounded-mp-full",A[h],F,m?"cursor-default":"cursor-pointer touch-none"].join(" "),style:{backgroundImage:"linear-gradient(to right, #ff0000 0%, #ffff00 16.66%, #00ff00 33.33%, #00ffff 50%, #0000ff 66.66%, #ff00ff 83.33%, #ff0000 100%)"},children:e("span",{className:L,style:{width:g,height:g,left:n.h/360*100+"%",top:"50%",marginLeft:b,marginTop:b,backgroundColor:x}})}),c?a("div",{...C(({x:e})=>i({hsv:n,alpha:e})),...B(f.alpha,100*t,100,e=>i({hsv:n,alpha:_(t+e/100,0,1)})),className:[D,"rounded-mp-full",A[h],F,m?"cursor-default":"cursor-pointer touch-none"].join(" "),style:k,children:[e("span",{"aria-hidden":"true",className:"absolute inset-0",style:{backgroundImage:`linear-gradient(to right, ${z(n,0)}, ${y})`}}),e("span",{className:L,style:{width:g,height:g,left:100*t+"%",top:"50%",marginLeft:b,marginTop:b,backgroundColor:z(n,t)}})]}):null,p?a("div",{className:`flex items-center ${R[h]}`,children:[e("span",{"aria-hidden":"true",className:"border-mp-outline-variant shrink-0 rounded-full border",style:{width:g+8,height:g+8,...k},children:e("span",{className:"block size-full rounded-full",style:{backgroundColor:z(n,t)}})}),e("input",{type:"text",value:s,readOnly:m,spellCheck:!1,autoComplete:"off","aria-label":f.value,onChange:e=>u(e.target.value),className:["rounded-mp-xs border-mp-outline text-mp-on-surface min-w-0 flex-1 border","bg-transparent px-2 py-1 font-mono lowercase",v,"focus-visible:border-mp-primary outline-none"].join(" ")})]}):null,V.length>0?e("div",{role:"group","aria-label":f.swatches,className:"grid grid-cols-8 gap-1",children:V.map(({swatch:a,parsed:r,hex:n},t)=>{const s=null!==r&&n===K;return e("button",{type:"button",disabled:m,"aria-label":a,"aria-pressed":s,onClick:()=>{r&&i({hsv:r.hsv,alpha:r.alpha})},className:["border-mp-outline-variant flex aspect-square items-center justify-center","rounded-full border","transition-[box-shadow] duration-(--mp-sys-motion-duration-short4)","ease-mp-standard",F,m?"cursor-default":"hover:shadow-mp-1 cursor-pointer"].join(" "),style:{backgroundColor:a},children:e("span",{"aria-hidden":"true",className:["transition-opacity duration-(--mp-sys-motion-duration-short4)","ease-mp-standard",s?"opacity-100":"opacity-0"].join(" "),style:r?{color:M(r.hsv)}:void 0,children:e(o,{icon:l,size:12})})},`${t}:${a}`)})}):null]})}const V={h:202,s:100,v:61};export const MPColorPicker=/*@__PURE__*/r.forwardRef(function({value:l,defaultValue:_="#00639b",onValueChange:M,format:T="hex",alpha:I=!1,swatches:A=C,inline:R=!1,editable:O=!0,label:D,floatingLabel:L=!0,description:S,errorMessage:q,required:K=!1,disabled:E=!1,readOnly:U=!1,clearable:X=!1,name:Y,open:W,defaultOpen:G=!1,onOpenChange:H,locale:J,labels:Q,size:Z,fullWidth:ee=!1,id:ae,className:re,style:ne},te){const oe=d(Z),le=p(J),ie=h(m,le,Q),se=w(q),ue=B[oe],ce=r.useId(),de=ae??ce,[pe,he]=r.useState(_),me=l??pe,[fe,ge]=r.useState(G),be=W??fe,[ve,xe]=r.useState(()=>$(me)??{hsv:V,alpha:1}),[ye,we]=r.useState(()=>me),je=P(ve.hsv,I?ve.alpha:1,T),Ne=""===me;r.useEffect(()=>{const e=$(me);e?P(e.hsv,I?e.alpha:1,T)!==je&&(we(me),xe(e)):we(me)},[me,je,I,T]);const ke=E||U,Ce=X&&!ke&&!Ne,{shrunk:_e,focusProps:ze}=c({floating:L&&w(D),filled:!Ne,pinned:be}),Pe=(e,a)=>{xe(e);const r=P(e.hsv,I?e.alpha:1,T);we(a??r),void 0===l&&he(r),M?.(r)},$e=e(F,{hsv:ve.hsv,alphaValue:ve.alpha,onChange:Pe,text:ye,onTextChange:e=>{we(e);const a=$(e);a&&Pe(a,e)},withAlpha:I,swatches:A,editable:O,size:oe,inert:ke,labels:ie}),Me=e("span",{"aria-hidden":"true",className:"border-mp-outline-variant block size-5 shrink-0 rounded-full border",style:k,children:e("span",{className:"block size-full rounded-full",style:{backgroundColor:Ne?"transparent":z(ve.hsv,I?ve.alpha:1)}})}),Te=Y?e("input",{type:"hidden",name:Y,value:Ne?"":je}):null;return R?a("div",{ref:te,"data-mp-size":oe,className:["mp-color-picker flex flex-col",y[oe],re??""].filter(Boolean).join(" "),style:ne,children:[w(D)?a("span",{className:[v,E?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:[D,K?e("span",{"aria-hidden":"true",children:" *"}):null]}):null,$e,w(q)?e("span",{className:`${v} text-mp-error`,children:q}):w(S)?e("span",{className:`${v} text-mp-on-surface-variant`,children:S}):null,Te]}):a(n.Root,{ref:te,disabled:E,invalid:se,"data-mp-size":oe,className:["mp-color-picker group flex-col align-top",ee?"flex w-full":"inline-flex w-fit",re??""].filter(Boolean).join(" "),style:ne,...ze,children:[a(t.Root,{open:be,onOpenChange:e=>{void 0===W&&ge(e),H?.(e)},children:[a("div",{className:"relative w-full",children:[a(t.Trigger,{id:de,disabled:E,nativeButton:!0,className:["relative flex w-full items-center gap-2 select-none","appearance-none border-0 bg-transparent font-[inherit] outline-none",ue.padding,Ce?"pe-10":"",ue.height,x[oe],E?"text-mp-on-surface/38 cursor-default":"text-mp-on-surface "+(U?"cursor-default":"cursor-pointer")].filter(Boolean).join(" "),children:[Ne&&!_e?null:Me,e("span",{className:["min-w-0 flex-1 truncate text-start",Ne?"text-mp-on-surface-variant":""].filter(Boolean).join(" "),children:Ne?_e?ie.empty:null:je})]}),Ce?a("button",{type:"button","aria-label":ie.clear,onClick:()=>{void 0===l&&he(""),we(""),M?.("")},className:["group/clear rounded-mp-full text-mp-on-surface-variant absolute inset-y-0","end-1 my-auto flex size-8 cursor-pointer items-center justify-center","appearance-none border-0 bg-transparent p-0","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-1","focus-visible:outline-solid outline-none"].join(" "),children:[e(f,{className:"group-hover/clear:opacity-8 group-focus-visible/clear:opacity-10"}),e(o,{icon:i,size:b[oe]})]}):null,e(u,{label:D,required:K,notched:_e}),w(D)?e(s,{size:oe,label:D,required:K,htmlFor:de,shrunk:_e}):null]}),e(t.Portal,{children:e(t.Positioner,{className:N,sideOffset:4,align:"start",children:e(t.Popup,{className:["mp-color-picker__popup rounded-mp-md shadow-mp-2 bg-mp-surface-container","text-mp-on-surface p-3 outline-none",x[oe],j].join(" "),children:$e})})})]}),e(g,{description:S,errorMessage:q,className:ue.padding}),Te]})});
|