material-plus-ui 1.5.0 → 1.6.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/dist/components/accordion/MPAccordion.js +1 -1
- package/dist/components/alert/MPAlert.js +1 -1
- package/dist/components/animate-lighting/MPAnimateLighting.js +1 -1
- package/dist/components/aspect-ratio/MPAspectRatio.js +1 -1
- package/dist/components/avatar/MPAvatar.js +1 -1
- package/dist/components/avatar-group/MPAvatarGroup.js +1 -1
- package/dist/components/badge/MPBadge.js +1 -1
- package/dist/components/blockquote/MPBlockquote.js +1 -1
- package/dist/components/bottom-navigation/MPBottomNavigation.d.ts +17 -0
- package/dist/components/bottom-navigation/MPBottomNavigation.js +1 -1
- package/dist/components/breadcrumb/MPBreadcrumb.js +1 -1
- package/dist/components/button/MPButton.d.ts +49 -3
- package/dist/components/button/MPButton.js +1 -1
- package/dist/components/calendar/MPCalendar.d.ts +160 -0
- package/dist/components/calendar/MPCalendar.js +2 -0
- package/dist/components/calendar/index.d.ts +2 -0
- package/dist/components/calendar/index.js +1 -0
- package/dist/components/card/MPCard.js +1 -1
- package/dist/components/carousel/MPCarousel.js +1 -1
- package/dist/components/chat-bubble/MPChatBubble.js +1 -1
- package/dist/components/checkbox/MPCheckbox.js +1 -1
- package/dist/components/chip/MPChip.d.ts +21 -6
- package/dist/components/chip/MPChip.js +1 -1
- package/dist/components/collapsible/MPCollapsible.js +1 -1
- package/dist/components/color-picker/MPColorPicker.js +1 -1
- package/dist/components/combobox/MPCombobox.d.ts +52 -3
- package/dist/components/combobox/MPCombobox.js +1 -1
- package/dist/components/command-palette/MPCommandPalette.d.ts +1 -1
- package/dist/components/command-palette/MPCommandPalette.js +1 -1
- package/dist/components/config/MPConfigProvider.d.ts +124 -0
- package/dist/components/config/MPConfigProvider.js +2 -0
- package/dist/components/config/index.d.ts +2 -0
- package/dist/components/config/index.js +1 -0
- package/dist/components/confirm/MPConfirmProvider.d.ts +143 -0
- package/dist/components/confirm/MPConfirmProvider.js +2 -0
- package/dist/components/confirm/index.d.ts +2 -0
- package/dist/components/confirm/index.js +1 -0
- package/dist/components/container/MPContainer.js +1 -1
- package/dist/components/date-picker/MPDatePicker.d.ts +53 -2
- package/dist/components/date-picker/MPDatePicker.js +1 -1
- package/dist/components/date-picker/index.d.ts +1 -1
- package/dist/components/date-range-picker/MPDateRangePicker.js +1 -1
- package/dist/components/date-time-picker/MPDateTimePicker.js +1 -1
- package/dist/components/dialog/MPDialog.d.ts +16 -3
- package/dist/components/dialog/MPDialog.js +1 -1
- package/dist/components/divider/MPDivider.js +1 -1
- package/dist/components/drawer/MPDrawer.d.ts +1 -1
- package/dist/components/drawer/MPDrawer.js +1 -1
- package/dist/components/empty/MPEmpty.js +1 -1
- package/dist/components/file-picker/MPFilePicker.js +1 -1
- package/dist/components/floating-action-button/MPFloatingActionButton.js +1 -1
- package/dist/components/footer/MPFooter.js +1 -1
- package/dist/components/grid/MPGrid.d.ts +23 -1
- package/dist/components/grid/MPGrid.js +1 -1
- package/dist/components/header/MPHeader.js +1 -1
- package/dist/components/image/MPImage.d.ts +112 -0
- package/dist/components/image/MPImage.js +2 -0
- package/dist/components/image/index.d.ts +2 -0
- package/dist/components/image/index.js +1 -0
- package/dist/components/list/MPList.d.ts +28 -0
- package/dist/components/list/MPList.js +1 -1
- package/dist/components/menu/MPMenu.d.ts +21 -2
- package/dist/components/menu/MPMenu.js +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.d.ts +3 -3
- package/dist/components/number-field/MPNumberField.js +1 -1
- package/dist/components/otp-field/MPOtpField.js +1 -1
- package/dist/components/overlay/MPOverlay.d.ts +1 -1
- package/dist/components/overlay/MPOverlay.js +1 -1
- package/dist/components/pagination/MPPagination.js +1 -1
- package/dist/components/panes/MPPanes.js +1 -1
- package/dist/components/pill/MPPill.js +1 -1
- package/dist/components/popconfirm/MPPopconfirm.d.ts +92 -0
- package/dist/components/popconfirm/MPPopconfirm.js +2 -0
- package/dist/components/popconfirm/index.d.ts +2 -0
- package/dist/components/popconfirm/index.js +1 -0
- package/dist/components/popover/MPPopover.d.ts +1 -1
- package/dist/components/popover/MPPopover.js +1 -1
- package/dist/components/progress-box/MPProgressBox.js +1 -1
- package/dist/components/progress-circular/MPProgressCircular.js +1 -1
- package/dist/components/progress-linear/MPProgressLinear.js +1 -1
- package/dist/components/radio-group/MPRadioGroup.js +1 -1
- package/dist/components/rating/MPRating.js +1 -1
- package/dist/components/segmented-button/MPSegmentedButton.js +1 -1
- package/dist/components/select/MPSelect.d.ts +2 -2
- package/dist/components/select/MPSelect.js +1 -1
- package/dist/components/shortcut/MPShortcut.js +1 -1
- package/dist/components/sidebar/MPSidebar.js +1 -1
- package/dist/components/skeleton/MPSkeleton.js +1 -1
- package/dist/components/slider/MPSlider.d.ts +27 -0
- package/dist/components/slider/MPSlider.js +1 -1
- package/dist/components/snackbar/MPSnackbar.d.ts +20 -1
- package/dist/components/snackbar/MPSnackbar.js +1 -1
- package/dist/components/spoiler/MPSpoiler.js +1 -1
- package/dist/components/stepper/MPStepper.d.ts +153 -0
- package/dist/components/stepper/MPStepper.js +2 -0
- package/dist/components/stepper/index.d.ts +2 -0
- package/dist/components/stepper/index.js +1 -0
- package/dist/components/switch/MPSwitch.js +1 -1
- package/dist/components/table/MPTable.d.ts +1 -1
- package/dist/components/table/MPTable.js +1 -1
- package/dist/components/tabs/MPTabs.js +1 -1
- package/dist/components/text-field/MPTextField.d.ts +38 -14
- package/dist/components/text-field/MPTextField.js +1 -1
- package/dist/components/time-picker/MPTimePicker.js +1 -1
- package/dist/components/timeline/MPTimeline.d.ts +10 -2
- package/dist/components/timeline/MPTimeline.js +1 -1
- package/dist/components/toggle/MPToggle.js +1 -1
- package/dist/components/transfer/MPTransfer.js +1 -1
- package/dist/components/typography/MPTypography.d.ts +7 -0
- package/dist/components/typography/MPTypography.js +1 -2
- package/dist/components/visually-hidden/MPVisuallyHidden.d.ts +60 -0
- package/dist/components/visually-hidden/MPVisuallyHidden.js +2 -0
- package/dist/components/visually-hidden/index.d.ts +2 -0
- package/dist/components/visually-hidden/index.js +1 -0
- package/dist/constants/glyphs.d.ts +2 -0
- package/dist/constants/glyphs.js +1 -1
- package/dist/constants/icons.d.ts +1 -0
- package/dist/constants/icons.js +1 -1
- package/dist/hooks/index.d.ts +23 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useMPColorScheme.d.ts +135 -0
- package/dist/hooks/useMPColorScheme.js +1 -0
- package/dist/hooks/useMPReducedMotion.d.ts +32 -0
- package/dist/hooks/useMPReducedMotion.js +1 -0
- package/dist/hooks/useMPShortcut.d.ts +105 -0
- package/dist/hooks/useMPShortcut.js +2 -0
- package/dist/hooks/useMPWindowClass.d.ts +48 -0
- package/dist/hooks/useMPWindowClass.js +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +1 -1
- package/dist/internal/Calendar.d.ts +19 -4
- package/dist/internal/Calendar.js +1 -1
- package/dist/internal/Picker.d.ts +15 -3
- package/dist/internal/Picker.js +1 -1
- package/dist/internal/color-scheme.d.ts +28 -0
- package/dist/internal/color-scheme.js +2 -0
- package/dist/internal/config.d.ts +43 -0
- package/dist/internal/config.js +2 -0
- package/dist/internal/date.d.ts +50 -3
- package/dist/internal/date.js +1 -1
- package/dist/internal/i18n.d.ts +26 -1
- package/dist/internal/messages/confirm.d.ts +3 -0
- package/dist/internal/messages/confirm.js +1 -0
- package/dist/internal/messages/picker.js +1 -1
- package/dist/internal/progress.d.ts +14 -0
- package/dist/internal/step.d.ts +71 -0
- package/dist/internal/step.js +1 -0
- package/dist/internal/window-class.d.ts +21 -0
- package/dist/internal/window-class.js +2 -0
- 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/animate-lighting.css +1 -1
- package/dist/styles/aspect-ratio.css +1 -1
- package/dist/styles/bottom-navigation.css +1 -1
- package/dist/styles/calendar.css +2 -0
- package/dist/styles/chip.css +1 -1
- package/dist/styles/combobox.css +1 -1
- package/dist/styles/config.css +2 -0
- package/dist/styles/confirm.css +2 -0
- package/dist/styles/grid.css +1 -1
- package/dist/styles/highlight.css +1 -1
- package/dist/styles/image.css +2 -0
- package/dist/styles/list.css +1 -1
- package/dist/styles/panes.css +1 -1
- package/dist/styles/popconfirm.css +2 -0
- package/dist/styles/progress-box.css +1 -1
- package/dist/styles/progress-circular.css +1 -1
- package/dist/styles/progress-linear.css +1 -1
- package/dist/styles/rating.css +1 -1
- package/dist/styles/shortcut.css +1 -1
- package/dist/styles/slider.css +1 -1
- package/dist/styles/snackbar.css +1 -1
- package/dist/styles/stepper.css +2 -0
- package/dist/styles/text-field.css +1 -1
- package/dist/styles/timeline.css +1 -1
- package/dist/styles/tokens.css +1 -1
- package/dist/styles/transfer.css +1 -1
- package/dist/styles/typography.css +1 -1
- package/dist/styles/visually-hidden.css +2 -0
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +91 -5
- package/dist/types.d.ts +64 -0
- package/package.json +6 -1
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPColor, MPSize } from '../../types.js';
|
|
3
|
+
/** What a confirmation asks, and how it is drawn. */
|
|
4
|
+
export interface MPConfirmOptions {
|
|
5
|
+
/** The question, as a heading. */
|
|
6
|
+
title?: React.ReactNode;
|
|
7
|
+
/** The sentence under it — what happens, and to what. */
|
|
8
|
+
description?: React.ReactNode;
|
|
9
|
+
/** A glyph above the title, the way `MPDialog` draws one. */
|
|
10
|
+
icon?: React.ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Anything else the dialog should hold — a field, a list of what is about to
|
|
13
|
+
* be deleted, a checkbox that says "do not ask again".
|
|
14
|
+
*/
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
/** What the yes button says. @default the translation of `Confirm` */
|
|
17
|
+
confirmLabel?: React.ReactNode;
|
|
18
|
+
/** What the no button says. @default the translation of `Cancel` */
|
|
19
|
+
cancelLabel?: React.ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* The accent the yes button is drawn in.
|
|
22
|
+
*
|
|
23
|
+
* `'error'` is what a destructive confirmation wants, and it is not the
|
|
24
|
+
* default: most confirmations are not destructive, and a red button on every
|
|
25
|
+
* one of them stops being a warning.
|
|
26
|
+
* @default 'primary'
|
|
27
|
+
*/
|
|
28
|
+
color?: MPColor;
|
|
29
|
+
/** @default 'md' */
|
|
30
|
+
size?: MPSize;
|
|
31
|
+
/**
|
|
32
|
+
* Whether Escape and a press outside answer **no**.
|
|
33
|
+
*
|
|
34
|
+
* On by default, because a dialog a reader cannot leave is a trap and because
|
|
35
|
+
* the safe answer to "are you sure" is no. Switch it off for a question that
|
|
36
|
+
* genuinely has to be answered — and be sure it does, because the reader then
|
|
37
|
+
* has exactly two ways out and both of them are your buttons.
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
dismissible?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface MPConfirmResult {
|
|
43
|
+
/**
|
|
44
|
+
* Asks, and resolves with the answer.
|
|
45
|
+
*
|
|
46
|
+
* `true` for the confirm button, `false` for cancel — and `false` for Escape,
|
|
47
|
+
* a press outside, and anything else that closes the dialog. There is no third
|
|
48
|
+
* answer, so a caller writes one `if`.
|
|
49
|
+
*/
|
|
50
|
+
confirm: (options: MPConfirmOptions) => Promise<boolean>;
|
|
51
|
+
/**
|
|
52
|
+
* Tells, and resolves once it has been acknowledged.
|
|
53
|
+
*
|
|
54
|
+
* One button, because there is nothing to refuse. `Promise<void>` rather than
|
|
55
|
+
* `Promise<boolean>` for the same reason: an acknowledgement has no answer,
|
|
56
|
+
* and a boolean nobody can vary is a value a caller would have to learn to
|
|
57
|
+
* ignore.
|
|
58
|
+
*/
|
|
59
|
+
alert: (options: MPConfirmOptions) => Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
export interface MPConfirmProviderProps {
|
|
62
|
+
/**
|
|
63
|
+
* Defaults for every confirmation raised under this — a `size` to match the
|
|
64
|
+
* application, an accent, a `cancelLabel` in your own words. Each call still
|
|
65
|
+
* says whatever it needs to and wins.
|
|
66
|
+
*/
|
|
67
|
+
defaults?: Omit<MPConfirmOptions, 'title' | 'description' | 'children'>;
|
|
68
|
+
children?: React.ReactNode;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Holds the one dialog every `confirm()` in the application is drawn in.
|
|
72
|
+
*
|
|
73
|
+
* Wrap the application, the way `MPSnackbarProvider` is wrapped, and for the
|
|
74
|
+
* same reason: what a caller has at the moment a question is warranted is a
|
|
75
|
+
* click handler, not a place in the tree.
|
|
76
|
+
*
|
|
77
|
+
* ```tsx
|
|
78
|
+
* <MPConfirmProvider>
|
|
79
|
+
* <App />
|
|
80
|
+
* </MPConfirmProvider>
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* ## One at a time
|
|
84
|
+
*
|
|
85
|
+
* A second `confirm()` raised while one is open **replaces** it, and the first
|
|
86
|
+
* promise resolves `false`. Not a queue, deliberately: a queue would ask a
|
|
87
|
+
* question about something the reader has already moved on from, and the answer
|
|
88
|
+
* to a stale question is not information. Two confirmations racing is a bug in
|
|
89
|
+
* the calling code, and resolving the first as *no* is the safe reading of it.
|
|
90
|
+
*/
|
|
91
|
+
export declare function MPConfirmProvider({ defaults, children }: MPConfirmProviderProps): React.JSX.Element;
|
|
92
|
+
/**
|
|
93
|
+
* Asks a question and waits for the answer.
|
|
94
|
+
*
|
|
95
|
+
* ```tsx
|
|
96
|
+
* const { confirm } = useMPConfirm();
|
|
97
|
+
*
|
|
98
|
+
* async function remove() {
|
|
99
|
+
* const sure = await confirm({
|
|
100
|
+
* title: 'Delete this project?',
|
|
101
|
+
* description: 'Everything in it goes too, and it cannot be undone.',
|
|
102
|
+
* confirmLabel: 'Delete',
|
|
103
|
+
* color: 'error'
|
|
104
|
+
* });
|
|
105
|
+
*
|
|
106
|
+
* if (sure) {
|
|
107
|
+
* await api.delete(id);
|
|
108
|
+
* }
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* ## Why this rather than a dialog of your own
|
|
113
|
+
*
|
|
114
|
+
* Because the dialog is not the hard part. "Are you sure" needs a piece of open
|
|
115
|
+
* state, a piece of state for *what* is being confirmed, two handlers, and a
|
|
116
|
+
* dialog kept mounted somewhere it does not belong — per call site. What the
|
|
117
|
+
* caller actually has at that moment is a click handler, and what they want back
|
|
118
|
+
* is a boolean.
|
|
119
|
+
*
|
|
120
|
+
* It is the same trade `useMPSnackbar` makes, run the other way: a snackbar is
|
|
121
|
+
* something to say, this is something to ask.
|
|
122
|
+
*
|
|
123
|
+
* ## `false` is every other answer
|
|
124
|
+
*
|
|
125
|
+
* The confirm button resolves `true`; the cancel button, Escape, a press outside
|
|
126
|
+
* and any other close resolve `false`. There is no third outcome and the promise
|
|
127
|
+
* never rejects, so a caller writes an `if` and not a `try`.
|
|
128
|
+
*
|
|
129
|
+
* `alert()` is the one-button form and resolves `void` once it has been
|
|
130
|
+
* acknowledged — an acknowledgement has nothing to refuse, and a boolean nobody
|
|
131
|
+
* can vary is a value a caller would have to learn to ignore.
|
|
132
|
+
*
|
|
133
|
+
* ## Sharp edges
|
|
134
|
+
*
|
|
135
|
+
* - **It needs an `MPConfirmProvider` above it.** Without one the hook throws,
|
|
136
|
+
* rather than returning a function that silently never resolves — a promise
|
|
137
|
+
* that never settles is the hardest possible way to be told about a missing
|
|
138
|
+
* provider.
|
|
139
|
+
* - **One at a time.** A second `confirm()` raised while one is open replaces it
|
|
140
|
+
* and resolves the first `false`. See the provider for why that is not a queue.
|
|
141
|
+
* - **Do not `await` it inside a render.** It is a click handler's tool.
|
|
142
|
+
*/
|
|
143
|
+
export declare function useMPConfirm(): MPConfirmResult;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as e,Fragment as r,jsxs as n}from"react/jsx-runtime";import*as o from"react";import{MPButton as i}from"../button/MPButton.js";import{MPDialog as t}from"../dialog/MPDialog.js";import{useMPLocale as l,useMPMessages as c}from"../../internal/locale.js";import{CONFIRM as a}from"../../internal/messages/confirm.js";const s=/*@__PURE__*/o.createContext(null);export function MPConfirmProvider({defaults:m,children:u}){const[d,f]=o.useState(null),p=c(a,l()),h=o.useRef(null),C=o.useCallback((e,r)=>new Promise(n=>{h.current?.(!1),h.current=n,f({...m,...e,acknowledge:r})}),[m]),P=o.useMemo(()=>({confirm:e=>C(e,!1),alert:e=>C(e,!0).then(()=>{})}),[C]),x=e=>{h.current?.(e),h.current=null,f(null)},g=d?.acknowledge??!1;return n(s.Provider,{value:P,children:[u,e(t,{open:null!==d,onOpenChange:e=>{e||x(g)},icon:d?.icon,title:d?.title,description:d?.description,size:d?.size??"md",color:d?.color??"primary",dismissible:d?.dismissible??!0,actions:n(r,{children:[g?null:e(i,{variant:"text",onClick:()=>x(!1),children:d?.cancelLabel??p.cancel}),e(i,{variant:"text",color:d?.color??"primary",onClick:()=>x(!0),children:d?.confirmLabel??(g?p.ok:p.confirm)})]}),children:d?.children})]})}export function useMPConfirm(){const e=o.useContext(s);if(!e)throw new Error("useMPConfirm was called outside an <MPConfirmProvider>. Wrap the application in one — the provider is what holds the dialog every confirm() is drawn in.");return e}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPConfirmProvider,useMPConfirm}from"./MPConfirmProvider.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import{useRender as r}from"@base-ui/react/use-render";import{MEASURE as n,SHEET_PAD_X as o}from"../../internal/scale.js";export const MPContainer=/*@__PURE__*/e.forwardRef(function({maxWidth:e="none",padded:
|
|
1
|
+
import*as e from"react";import{useRender as r}from"@base-ui/react/use-render";import{MEASURE as n,SHEET_PAD_X as o}from"../../internal/scale.js";import{useMPSize as a}from"../../internal/config.js";export const MPContainer=/*@__PURE__*/e.forwardRef(function({maxWidth:e="none",padded:t=!0,size:i,centered:s=!0,render:c,className:m,children:d,...l},f){const p=a(i);return r({render:c,ref:f,props:{"data-mp-size":p,className:["mp-container block w-full","box-border","none"===e?"":n[e],s?"mx-auto":"",t?o[p]:"",m??""].filter(Boolean).join(" "),children:d,...l}})});
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type MPPickerLabels } from '../../internal/Calendar.js';
|
|
3
3
|
import { type MPPickerShellProps } from '../../internal/Picker.js';
|
|
4
|
+
import { type MPDatePrecision } from '../../internal/date.js';
|
|
4
5
|
import type { MPWeekday } from '../../types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Which unit a picker asks for.
|
|
8
|
+
*
|
|
9
|
+
* Re-exported so a caller storing the answer can name what they are holding —
|
|
10
|
+
* a `'month'` picker's value is a month, and the day inside it is an artefact.
|
|
11
|
+
*/
|
|
12
|
+
export type { MPDatePrecision };
|
|
5
13
|
export interface MPDatePickerProps extends MPPickerShellProps {
|
|
6
14
|
/** The chosen day. Use with `onValueChange` for a controlled picker. */
|
|
7
15
|
value?: Date | null;
|
|
@@ -13,18 +21,45 @@ export interface MPDatePickerProps extends MPPickerShellProps {
|
|
|
13
21
|
open?: boolean;
|
|
14
22
|
defaultOpen?: boolean;
|
|
15
23
|
onOpenChange?: (open: boolean) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Which unit the picker asks for.
|
|
26
|
+
*
|
|
27
|
+
* `'month'` stops the calendar at its grid of twelve months and answers with
|
|
28
|
+
* the 1st of the one that is pressed; `'year'` stops at the grid of years and
|
|
29
|
+
* answers with the 1st of January. A card's expiry, a fiscal year, the month a
|
|
30
|
+
* report covers — the questions where a day is not something the reader has to
|
|
31
|
+
* give and the value should not pretend they did.
|
|
32
|
+
*
|
|
33
|
+
* The finer views are not hidden so much as absent: a month picker never draws
|
|
34
|
+
* a day grid, so there is no way through it to a day. What follows the
|
|
35
|
+
* precision with it is the trigger's default `format`, what the hidden input
|
|
36
|
+
* submits, and the word on the footer's shortcut.
|
|
37
|
+
* @default 'day'
|
|
38
|
+
*/
|
|
39
|
+
precision?: MPDatePrecision;
|
|
16
40
|
/**
|
|
17
41
|
* Which month the calendar opens on when there is no value.
|
|
18
42
|
* @default this month
|
|
19
43
|
*/
|
|
20
44
|
defaultMonth?: Date;
|
|
21
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* The earliest day that may be chosen. Day-granular — the time is ignored.
|
|
47
|
+
*
|
|
48
|
+
* Read at whatever `precision` asks for: a minimum of 10 July still leaves
|
|
49
|
+
* July pickable on a month picker, because there the bound is about which
|
|
50
|
+
* months exist.
|
|
51
|
+
*/
|
|
22
52
|
minDate?: Date | null;
|
|
23
53
|
/** The latest day that may be chosen. */
|
|
24
54
|
maxDate?: Date | null;
|
|
25
55
|
/**
|
|
26
56
|
* Blocks individual days that are inside the range but still not available —
|
|
27
57
|
* weekends, holidays, a room that is already booked.
|
|
58
|
+
*
|
|
59
|
+
* Asked about days and only about days, so a picker whose `precision` is a
|
|
60
|
+
* month or a year never consults it: a rule written about weekends has no
|
|
61
|
+
* answer for "is July available", and inventing one out of the 1st would block
|
|
62
|
+
* whichever months happened to start on a Sunday.
|
|
28
63
|
*/
|
|
29
64
|
shouldDisableDate?: (date: Date) => boolean;
|
|
30
65
|
/**
|
|
@@ -42,6 +77,8 @@ export interface MPDatePickerProps extends MPPickerShellProps {
|
|
|
42
77
|
*
|
|
43
78
|
* An object written inline is fine: what the picker keeps between renders is
|
|
44
79
|
* keyed on what the format *says*, not on the object that says it.
|
|
80
|
+
*
|
|
81
|
+
* Left out, it follows `precision`: a medium date, `July 2026`, or `2026`.
|
|
45
82
|
* @default { dateStyle: 'medium' }
|
|
46
83
|
*/
|
|
47
84
|
format?: Intl.DateTimeFormatOptions;
|
|
@@ -54,6 +91,9 @@ export interface MPDatePickerProps extends MPPickerShellProps {
|
|
|
54
91
|
clearable?: boolean;
|
|
55
92
|
/**
|
|
56
93
|
* Offers the shortcut to today in the footer.
|
|
94
|
+
*
|
|
95
|
+
* It lands on whatever unit is being asked for, and says so: *Today*, *This
|
|
96
|
+
* month* or *This year*.
|
|
57
97
|
* @default true
|
|
58
98
|
*/
|
|
59
99
|
showTodayButton?: boolean;
|
|
@@ -67,7 +107,10 @@ export interface MPDatePickerProps extends MPPickerShellProps {
|
|
|
67
107
|
* given falls back to the translation for `locale`, and then to English.
|
|
68
108
|
*/
|
|
69
109
|
labels?: Partial<MPPickerLabels>;
|
|
70
|
-
/**
|
|
110
|
+
/**
|
|
111
|
+
* Identifies the field when a form is submitted, as `YYYY-MM-DD` — or as
|
|
112
|
+
* `YYYY-MM` or `YYYY` when `precision` asks for less.
|
|
113
|
+
*/
|
|
71
114
|
name?: string;
|
|
72
115
|
}
|
|
73
116
|
/**
|
|
@@ -86,6 +129,14 @@ export interface MPDatePickerProps extends MPPickerShellProps {
|
|
|
86
129
|
* picker, and this is drawn on MD3's own numbers: a 40dp cell, a filled circle
|
|
87
130
|
* for the chosen day, an outlined one for today.
|
|
88
131
|
*
|
|
132
|
+
* ## A day, a month, or a year
|
|
133
|
+
*
|
|
134
|
+
* `precision` decides which of the three the calendar stops at, and it stops by
|
|
135
|
+
* leaving the finer views out rather than by refusing them: a month picker opens
|
|
136
|
+
* on the twelve months and has no day grid to reach, a year picker opens on the
|
|
137
|
+
* years. Everything downstream follows — how the trigger writes the value, what
|
|
138
|
+
* a form submits, and whether the footer's shortcut says *Today* or *This year*.
|
|
139
|
+
*
|
|
89
140
|
* ## Every string comes from the platform
|
|
90
141
|
*
|
|
91
142
|
* The month names, the weekday initials, the order of the header's two buttons
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as
|
|
2
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as o from"react";import{MPButton as t}from"../button/MPButton.js";import{MPIcon as n}from"../icon/MPIcon.js";import{CalendarIcon as l}from"../../constants/icons.js";import{Calendar as r}from"../../internal/Calendar.js";import{FOOTER_SIZE as i,MPPickerFooter as s,MPPickerShell as c,useDisplaySamples as m}from"../../internal/Picker.js";import{useMPLocale as d,useMPMessages as u}from"../../internal/locale.js";import{PICKER as p}from"../../internal/messages/picker.js";import{CONTROL_ICON as f}from"../../internal/scale.js";import{formatDate as h,isUnitOutside as y,isValidDate as j,localeWeekStart as b,mergeDateAndTime as g,startOfMonth as v,startOfUnit as x,toISODate as D,toISOMonth as k,toISOYear as C,today as O,withPlaceholder as S}from"../../internal/date.js";import{useMPColor as z,useMPSize as M}from"../../internal/config.js";const P={day:{dateStyle:"medium"},month:{year:"numeric",month:"long"},year:{year:"numeric"}},w={day:D,month:k,year:C};export const MPDatePicker=/*@__PURE__*/o.forwardRef(function({value:D,defaultValue:k,onValueChange:C,open:I,defaultOpen:V,onOpenChange:B,precision:R="day",defaultMonth:E,minDate:F,maxDate:N,shouldDisableDate:T,locale:Y,weekStartsOn:q,format:A,placeholder:G,clearable:H=!1,showTodayButton:J=!0,closeOnSelect:K=!0,labels:L,name:Q,size:U,color:W,readOnly:X=!1,disabled:Z=!1,startIcon:$,..._},ee){const ae=M(U),oe=z(W),te=d(Y),ne=u(p,te,L),le=q??b(te),re=A??P[R],[ie,se]=o.useState(k??null),ce=void 0!==D?D:ie,[me,de]=o.useState(V??!1),ue=I??me,[pe,fe]=o.useState(()=>v(j(ce)?ce:E??O()));o.useEffect(()=>{ue&&fe(v(j(ce)?ce:E??O()))},[ue]);const he=e=>{e&&(X||Z)||(void 0===I&&de(e),B?.(e))},ye=e=>{void 0===D&&se(e),C?.(e)},je=e=>{const a=x(e,R),o=j(ce)?g(a,ce):a;ye(o),fe(v(o)),K&&he(!1)},be=O(),ge=y(be,R,F,N)||"day"===R&&(T?.(be)??!1),ve="year"===R?ne.thisYear:"month"===R?ne.thisMonth:ne.today,xe=J||H,De=S(m(te,re),G);return e(c,{..._,slug:"date-picker",size:ae,color:oe,readOnly:X,disabled:Z,triggerRef:ee,startIcon:void 0===$?e(n,{icon:l,size:f[ae]}):$,display:j(ce)?h(ce,te,re):G??"",samples:De,empty:!j(ce),clearable:H,onClear:()=>ye(null),open:ue,onOpenChange:he,labels:ne,hiddenValues:Q?[{name:Q,value:j(ce)?w[R](ce):""}]:void 0,children:a("div",{className:"flex flex-col "+(xe?"gap-1.5":""),children:[e(r,{size:ae,color:oe,locale:te,weekStartsOn:le,month:pe,onMonthChange:fe,selected:[ce],onSelect:je,minDate:F,maxDate:N,shouldDisableDate:T,precision:R,labels:ne,autoFocus:!0}),xe?a(s,{children:[H?e(t,{variant:"text",size:i[ae],color:oe,onClick:()=>{ye(null),he(!1)},children:ne.clear}):null,J?e(t,{variant:"text",size:i[ae],color:oe,disabled:ge,onClick:()=>je(be),children:ve}):null]}):null]})})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { MPDatePicker } from './MPDatePicker.js';
|
|
2
|
-
export type { MPDatePickerProps } from './MPDatePicker.js';
|
|
2
|
+
export type { MPDatePickerProps, MPDatePrecision } from './MPDatePicker.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as n from"react";import{MPButton as a}from"../button/MPButton.js";import{MPIcon as t}from"../icon/MPIcon.js";import{ArrowRightIcon as r,CalendarIcon as s}from"../../constants/icons.js";import{
|
|
2
|
+
import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as n from"react";import{MPButton as a}from"../button/MPButton.js";import{MPIcon as t}from"../icon/MPIcon.js";import{ArrowRightIcon as r,CalendarIcon as s}from"../../constants/icons.js";import{Calendar as o}from"../../internal/Calendar.js";import{FOOTER_SIZE as i,MPPickerFooter as c,MPPickerShell as u,useDisplaySamples as m}from"../../internal/Picker.js";import{useMPLocale as d,useMPMessages as p}from"../../internal/locale.js";import{PICKER as f}from"../../internal/messages/picker.js";import{MPWidthSizer as h}from"../../internal/WidthSizer.js";import{CONTROL_ICON as v,META_TEXT as x}from"../../internal/scale.js";import{addMonths as g,compareDay as j,formatDate as b,isValidDate as w,localeWeekStart as N,startOfDay as S,startOfMonth as C,toISODate as D,today as k,withPlaceholder as y}from"../../internal/date.js";import{useMPColor as O,useMPSize as P}from"../../internal/config.js";const z={start:null,end:null};export const MPDateRangePicker=/*@__PURE__*/n.forwardRef(function({value:M,defaultValue:B,onValueChange:I,open:R,defaultOpen:V,onOpenChange:E,defaultMonth:F,minDate:W,maxDate:$,shouldDisableDate:_,locale:q,weekStartsOn:A,format:G={dateStyle:"medium"},monthCount:H=2,startPlaceholder:J,endPlaceholder:K,presets:L,clearable:Q=!1,closeOnSelect:T=!0,labels:U,name:X,size:Y,color:Z,readOnly:ee=!1,disabled:le=!1,startIcon:ne,...ae},te){const re=P(Y),se=O(Z),oe=d(q),ie=p(f,oe,U),ce=A??N(oe),[ue,me]=n.useState(B??z),de=void 0!==M?M??z:ue,pe=w(de.start)?de.start:null,fe=w(de.end)?de.end:null,[he,ve]=n.useState(V??!1),xe=R??he,[ge,je]=n.useState(null),[be,we]=n.useState(null),[Ne,Se]=n.useState(()=>C(pe??F??k()));n.useEffect(()=>{xe?Se(C(pe??F??k())):(je(null),we(null))},[xe]);const Ce=e=>{e&&(ee||le)||(void 0===R&&ve(e),E?.(e))},De=e=>{void 0===M&&me(e),I?.(e)},ke=ge??pe,ye=null!==ge?be:fe,Oe=(l,n)=>w(l)?b(l,oe,G):e("span",{className:"text-mp-on-surface-variant",children:n??""}),Pe=g(Ne,1),ze=2===H,Me=m(oe,G),Be=null!==ge?ie.end:null===pe?ie.start:null,Ie={size:re,color:se,locale:oe,weekStartsOn:ce,selected:[pe,fe,ge],rangeStart:ke,rangeEnd:ye,onSelect:e=>{const l=S(e);if(null===ge)return je(l),we(l),void De({start:l,end:null});const[n,a]=j(l,ge)<0?[l,ge]:[ge,l];je(null),we(null),De({start:n,end:a}),T&&Ce(!1)},onPreviewChange:e=>{null!==ge&&we(e??ge)},minDate:W,maxDate:$,shouldDisableDate:_,showOutsideDays:!1,labels:ie};return e(u,{...ae,slug:"date-range-picker",size:re,color:se,readOnly:ee,disabled:le,triggerRef:te,startIcon:void 0===ne?e(t,{icon:s,size:v[re]}):ne,display:l("span",{className:"flex min-w-0 items-center gap-1.5",children:[l("span",{className:"flex min-w-0 flex-col",children:[e("span",{className:"truncate",children:Oe(pe,J)}),e(h,{samples:y(Me,J)})]}),e("span",{"aria-hidden":"true",className:"text-mp-on-surface-variant flex shrink-0 items-center rtl:rotate-180",children:e(t,{icon:r,size:v[re]})}),l("span",{className:"flex min-w-0 flex-col",children:[e("span",{className:"truncate",children:Oe(fe,K)}),e(h,{samples:y(Me,K)})]})]}),empty:null===pe&&null===fe,clearable:Q,onClear:()=>De(z),open:xe,onOpenChange:Ce,labels:ie,hiddenValues:X?[{name:X,value:pe?D(pe):""},{name:X,value:fe?D(fe):""}]:void 0,children:l("div",{className:"flex flex-col gap-1.5",children:[l("div",{className:"flex items-stretch gap-2",children:[L&&L.length>0?e("div",{className:"border-mp-outline-variant flex max-h-[calc(var(--_mp-cell,2.5rem)*8)] flex-col overflow-y-auto border-e pe-1.5",children:L.map((l,n)=>e(a,{variant:"text",size:i[re],color:se,className:"justify-start whitespace-nowrap",onClick:()=>(e=>{const l="function"==typeof e.value?e.value():e.value;je(null),we(null),De(l),w(l.start)&&Se(C(l.start)),T&&Ce(!1)})(l),children:l.label},n))}):null,e(o,{...Ie,month:Ne,onMonthChange:Se,showNextButton:!ze,autoFocus:!0}),ze?e(o,{...Ie,month:Pe,onMonthChange:e=>Se(g(e,-1)),showPreviousButton:!1}):null]}),Q||null!==Be?l(c,{children:[null!==Be?e("span",{className:`text-mp-on-surface-variant me-auto ${x}`,children:Be}):null,Q?e(a,{variant:"text",size:i[re],color:se,onClick:()=>{je(null),we(null),De(z),Ce(!1)},children:ie.clear}):null]}):null]})})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as o}from"react/jsx-runtime";import*as t from"react";import{MPButton as l}from"../button/MPButton.js";import{MPIcon as
|
|
2
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import*as t from"react";import{MPButton as l}from"../button/MPButton.js";import{MPIcon as n}from"../icon/MPIcon.js";import{CalendarIcon as a}from"../../constants/icons.js";import{Calendar as s,MPTimeGrid as r}from"../../internal/Calendar.js";import{FOOTER_SIZE as i,MPPickerDivider as c,MPPickerFooter as m,MPPickerShell as d,useDisplaySamples as u}from"../../internal/Picker.js";import{useMPLocale as p,useMPMessages as h}from"../../internal/locale.js";import{PICKER as f}from"../../internal/messages/picker.js";import{CONTROL_ICON as S}from"../../internal/scale.js";import{formatDate as g,isDayOutside as b,isHour12 as j,isValidDate as v,localeWeekStart as D,mergeDateAndTime as x,startOfDay as C,startOfMonth as k,timeUnitSpan as w,toISODateTime as z,today as O,withPlaceholder as y,withTime as T}from"../../internal/date.js";import{useMPColor as M,useMPSize as P}from"../../internal/config.js";export const MPDateTimePicker=/*@__PURE__*/t.forwardRef(function({value:I,defaultValue:N,onValueChange:V,open:B,defaultOpen:R,onOpenChange:E,defaultMonth:F,minDate:q,maxDate:A,shouldDisableDate:G,shouldDisableTime:H,locale:J,weekStartsOn:K,format:L,hour12:Q,showSeconds:U=!1,hourStep:W=1,minuteStep:X=1,secondStep:Y=1,placeholder:Z,clearable:$=!1,showNowButton:_=!0,closeOnSelect:ee=!1,labels:oe,name:te,size:le,color:ne,readOnly:ae=!1,disabled:se=!1,startIcon:re,...ie},ce){const me=P(le),de=M(ne),ue=p(J),pe=h(f,ue,oe),he=K??D(ue),fe=Q??j(ue),[Se,ge]=t.useState(N??null),be=void 0!==I?I:Se,[je,ve]=t.useState(R??!1),De=B??je,[xe,Ce]=t.useState(()=>k(v(be)?be:F??O()));t.useEffect(()=>{De&&Ce(k(v(be)?be:F??O()))},[De]);const ke=e=>{e&&(ae||se)||(void 0===B&&ve(e),E?.(e))},we=e=>{void 0===I&&ge(e),V?.(e)},ze=t.useCallback((e,o)=>{const[t,l]=w(o,e),n=C(e).getTime();return!!(v(q)&&n+1e3*l<q.getTime())||(!!(v(A)&&n+1e3*t>A.getTime())||(H?.(e,o)??!1))},[q,A,H]),Oe=L??{dateStyle:"medium",timeStyle:"short",hour12:fe},ye=new Date,Te=T(ye,{seconds:U?ye.getSeconds():0}),Me=b(Te,q,A)||(G?.(Te)??!1)||ze(Te,"second"),Pe=y(u(ue,Oe),Z);return e(d,{...ie,slug:"date-time-picker",size:me,color:de,readOnly:ae,disabled:se,triggerRef:ce,startIcon:void 0===re?e(n,{icon:a,size:S[me]}):re,display:v(be)?g(be,ue,Oe):Z??"",samples:Pe,empty:!v(be),clearable:$,onClear:()=>we(null),open:De,onOpenChange:ke,labels:pe,hiddenValues:te?[{name:te,value:v(be)?z(be,U):""}]:void 0,children:o("div",{className:"flex flex-col gap-1.5",children:[o("div",{className:"flex items-stretch gap-2",children:[e(s,{size:me,color:de,locale:ue,weekStartsOn:he,month:xe,onMonthChange:Ce,selected:[be],onSelect:e=>{const o=v(be)?x(e,be):C(e);we(o),Ce(k(o)),ee&&ke(!1)},minDate:q,maxDate:A,shouldDisableDate:G,labels:pe,autoFocus:!0}),e(c,{}),e(r,{size:me,locale:ue,value:v(be)?be:null,referenceDate:v(be)?be:O(),onChange:we,hour12:fe,showSeconds:U,hourStep:W,minuteStep:X,secondStep:Y,shouldDisableTime:ze,labels:pe})]}),o(m,{children:[$?e(l,{variant:"text",size:i[me],color:de,onClick:()=>{we(null),ke(!1)},children:pe.clear}):null,_?e(l,{variant:"text",size:i[me],color:de,disabled:Me,onClick:()=>{we(Te),Ce(k(Te))},children:pe.now}):null,e(l,{variant:"filled",size:i[me],color:de,onClick:()=>ke(!1),children:pe.done})]})]})})});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Dialog } from '@base-ui/react/dialog';
|
|
3
|
-
import type { MPColor, MPSize } from '../../types.js';
|
|
3
|
+
import type { MPColor, MPControlEventProps, MPSize } from '../../types.js';
|
|
4
4
|
/**
|
|
5
5
|
* A dialog takes `size` and `color` and stops there.
|
|
6
6
|
*
|
|
@@ -8,7 +8,20 @@ import type { MPColor, MPSize } from '../../types.js';
|
|
|
8
8
|
* paint against the page around it", and a modal has already taken the page.
|
|
9
9
|
* There is no `elevation` prop either — see the note on the sheet below.
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* A dialog's sheet, which is where an event handler lands.
|
|
13
|
+
*
|
|
14
|
+
* The same rule the eight controls follow, applied to the one component that had
|
|
15
|
+
* no element a caller could reach at all: a class describes the whole dialog and
|
|
16
|
+
* lands on its outermost element, an event came from somewhere inside the sheet
|
|
17
|
+
* and lands on the sheet. So `onKeyDown` is a keystroke inside the dialog and
|
|
18
|
+
* never one on the trigger that opened it, and never one on the page behind.
|
|
19
|
+
*
|
|
20
|
+
* It is the popup rather than the backdrop deliberately. A key pressed while the
|
|
21
|
+
* dialog holds focus reaches the popup by bubbling; a click on the scrim does
|
|
22
|
+
* not, which is `dismissible`'s job and not this one's.
|
|
23
|
+
*/
|
|
24
|
+
export interface MPDialogProps extends MPControlEventProps<HTMLElement> {
|
|
12
25
|
/** The dialog is shown. Use with `onOpenChange` for a controlled dialog. */
|
|
13
26
|
open?: boolean;
|
|
14
27
|
/** Whether the dialog starts open, for an uncontrolled one. */
|
|
@@ -147,4 +160,4 @@ export declare const MPDialogClose: React.ForwardRefExoticComponent<Omit<import(
|
|
|
147
160
|
* is no `variant`: a dialog that could be told to sit flat on the page would be a
|
|
148
161
|
* dialog that could be told to stop being a dialog.
|
|
149
162
|
*/
|
|
150
|
-
export declare function MPDialog({ open, defaultOpen, onOpenChange, trigger, icon, title, description, actions, dividers, showClose, closeLabel, locale: localeProp, width, fullWidth, fullScreen, modal, dismissible, size, color, className, style, children }: MPDialogProps): React.JSX.Element;
|
|
163
|
+
export declare function MPDialog({ open, defaultOpen, onOpenChange, trigger, icon, title, description, actions, dividers, showClose, closeLabel, locale: localeProp, width, fullWidth, fullScreen, modal, dismissible, size: sizeProp, color, onKeyDown, onKeyUp, onFocus, onBlur, onClick, onDoubleClick, onContextMenu, className, style, children }: MPDialogProps): React.JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as l}from"react/jsx-runtime";import{Dialog as
|
|
2
|
+
import{jsx as e,jsxs as l}from"react/jsx-runtime";import{Dialog as n}from"@base-ui/react/dialog";import{MPIcon as o}from"../icon/MPIcon.js";import{CloseIcon as t}from"../../constants/icons.js";import{accentSlots as i}from"../../internal/accent.js";import{cssLength as s}from"../../internal/length.js";import{useMPLocale as a,useMPMessages as r}from"../../internal/locale.js";import{COMMON as m}from"../../internal/messages/common.js";import{MPStateLayer as c}from"../../internal/StateLayer.js";import{SHEET_GAP as p,hasContent as d}from"../../internal/scale.js";import{FADE as x,PORTAL_LAYER as f,SCRIM as u,SHEET_MOTION as h}from"../../internal/surface.js";import{useMPSize as g}from"../../internal/config.js";const y={xs:"max-w-[320px]",sm:"max-w-[400px]",md:"max-w-[560px]",lg:"max-w-[720px]",xl:"max-w-[960px]"},j=`transition-[opacity,scale] ${h}`,b=/*@__PURE__*/["motion-safe:data-starting-style:scale-95","motion-safe:data-ending-style:scale-95"].join(" "),v={xs:"p-3",sm:"p-4",md:"p-6",lg:"p-7",xl:"p-8"},w={xs:"px-3",sm:"px-4",md:"px-6",lg:"px-7",xl:"px-8"},C={xs:"py-3",sm:"py-4",md:"py-6",lg:"py-7",xl:"py-8"},N={xs:"text-mp-title-medium",sm:"text-mp-title-large",md:"text-mp-headline-small",lg:"text-mp-headline-medium",xl:"text-mp-headline-large"},k={xs:"text-mp-body-small",sm:"text-mp-body-small",md:"text-mp-body-medium",lg:"text-mp-body-large",xl:"text-mp-body-large"},$={xs:20,sm:22,md:24,lg:28,xl:32};export const MPDialogClose=n.Close;export function MPDialog({open:h,defaultOpen:D,onOpenChange:B,trigger:P,icon:M,title:z,description:K,actions:O,dividers:F=!1,showClose:L,closeLabel:S,locale:T,width:U,fullWidth:W=!0,fullScreen:I=!1,modal:R=!0,dismissible:V=!0,size:_,color:q="secondary",onKeyDown:A,onKeyUp:E,onFocus:G,onBlur:H,onClick:J,onDoubleClick:Q,onContextMenu:X,className:Y,style:Z,children:ee}){const le=g(_),ne=a(T),oe=r(m,ne),te=L??I,ie=d(M),se=d(z)||d(K)||ie,ae=d(O),re=F?v[le]:w[le],me="border-mp-outline-variant border-t";return l(n.Root,{open:h,defaultOpen:D,modal:R,disablePointerDismissal:!V,onOpenChange:(e,l)=>{V||e||"escape-key"!==l.reason?B?.(e):l.cancel()},children:[P?e(n.Trigger,{render:P}):null,l(n.Portal,{children:[e(n.Backdrop,{className:`${f} fixed inset-0 ${x} ${u}`}),e(n.Viewport,{className:[f,"fixed inset-0 flex justify-center",I?"items-stretch":"items-center p-4"].join(" "),children:l(n.Popup,{"data-mp-size":le,onKeyDown:A,onKeyUp:E,onFocus:G,onBlur:H,onClick:J,onDoubleClick:Q,onContextMenu:X,className:["mp-dialog relative flex w-full flex-col overflow-hidden","bg-mp-surface-container-high text-mp-on-surface shadow-mp-3 outline-none",I?"h-full max-w-none rounded-none":`rounded-mp-xl max-h-full ${void 0===U?y[le]:""}`,I||W?"":"w-auto",F?"":`${C[le]} ${p[le]}`,j,I?"":b,Y??""].filter(Boolean).join(" "),style:{...i(q),...void 0===U||I?null:{maxWidth:s(U)},...Z},children:[se||te?l("div",{className:["flex shrink-0 items-start gap-3",re,ie&&!te?"flex-col items-center text-center":""].filter(Boolean).join(" "),children:[ie?e("span",{className:"flex shrink-0 items-center justify-center text-(--_mp-accent)",children:M}):null,l("div",{className:`flex min-w-0 flex-1 flex-col ${p[le]}`,children:[d(z)?e(n.Title,{className:`m-0 ${N[le]}`,children:z}):null,d(K)?e(n.Description,{className:`text-mp-on-surface-variant m-0 ${k[le]}`,children:K}):null]}),te?l(n.Close,{"aria-label":S??oe.close,className:["group text-mp-on-surface-variant relative flex size-10 shrink-0","rounded-mp-full cursor-pointer items-center justify-center","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none"].join(" "),children:[e(c,{}),e(o,{icon:t,size:$[le]})]}):null]}):null,d(ee)?e("div",{className:["min-h-0 flex-1 overflow-y-auto overscroll-contain",k[le],re,F&&(se||te)?me:""].filter(Boolean).join(" "),children:ee}):null,ae?e("div",{className:["flex shrink-0 flex-wrap items-center justify-end gap-2",re,F?me:""].filter(Boolean).join(" "),children:O}):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{Separator as l}from"@base-ui/react/separator";import{hasContent as a}from"../../internal/scale.js";import{cssLength as i}from"../../internal/length.js";const
|
|
2
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as t from"react";import{Separator as l}from"@base-ui/react/separator";import{hasContent as a}from"../../internal/scale.js";import{cssLength as i}from"../../internal/length.js";import{useMPSize as o}from"../../internal/config.js";const n="[border-color:var(--_mp-line)]",s={horizontal:{start:["w-4 shrink-0","flex-1"],center:["flex-1","flex-1"],end:["flex-1","w-4 shrink-0"]},vertical:{start:["h-4 shrink-0","flex-1"],center:["flex-1","flex-1"],end:["flex-1","h-4 shrink-0"]}},m={xs:"text-mp-label-small",sm:"text-mp-label-small",md:"text-mp-label-medium",lg:"text-mp-label-large",xl:"text-mp-label-large"},p={xs:"gap-1.5",sm:"gap-2",md:"gap-3",lg:"gap-3.5",xl:"gap-4"};export const MPDivider=/*@__PURE__*/t.forwardRef(function({orientation:t="horizontal",color:d,size:c,length:f,thickness:h,textAlign:x="center",className:u,style:v,children:b,...g},w){const j=o(c),_="vertical"===t,$=a(b),k={"--_mp-line":d?`var(--_mp-color-${d})`:"var(--_mp-color-outline-variant)","--_mp-rule":i(h)??"1px"},N=i(f),z={...k,...void 0===N?null:_?{height:N}:{width:N},...v};if(!$)return e(l,{ref:w,orientation:t,"data-mp-size":j,className:["mp-divider",_?"w-0 border-l [border-left-width:var(--_mp-rule)] "+(void 0===N?"self-stretch":""):"h-0 w-full border-t [border-top-width:var(--_mp-rule)]",n,u??""].filter(Boolean).join(" "),style:z,...g});const[y,B]=s[t][x],A=_?"w-0 border-l [border-left-width:var(--_mp-rule)]":"h-0 border-t [border-top-width:var(--_mp-rule)]";return r(l,{ref:w,orientation:t,"aria-label":"string"==typeof b?b:void 0,"data-mp-size":j,className:["mp-divider flex items-center",_?"w-auto flex-col "+(void 0===N?"self-stretch":""):"w-full",p[j],u??""].filter(Boolean).join(" "),style:z,...g,children:[e("span",{"aria-hidden":"true",className:`${A} ${y} ${n}`}),e("span",{className:["text-mp-on-surface-variant shrink-0 whitespace-nowrap",m[j],_?"[writing-mode:vertical-rl]":""].filter(Boolean).join(" "),children:b}),e("span",{"aria-hidden":"true",className:`${A} ${B} ${n}`})]})});
|
|
@@ -184,4 +184,4 @@ export declare const MPDrawerClose: React.ForwardRefExoticComponent<Omit<import(
|
|
|
184
184
|
* `SLIDE` gives a reader who asked for less motion the old behaviour exactly:
|
|
185
185
|
* the fade, with nowhere to travel from.
|
|
186
186
|
*/
|
|
187
|
-
export declare function MPDrawer({ side, mode, open, defaultOpen, onOpenChange, trigger, title, description, actions, dividers, showClose, closeLabel, locale: localeProp, extent, rounded, dismissible, size, className, style, children }: MPDrawerProps): React.JSX.Element | null;
|
|
187
|
+
export declare function MPDrawer({ side, mode, open, defaultOpen, onOpenChange, trigger, title, description, actions, dividers, showClose, closeLabel, locale: localeProp, extent, rounded, dismissible, size: sizeProp, className, style, children }: MPDrawerProps): React.JSX.Element | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t,Fragment as l}from"react/jsx-runtime";import*as a from"react";import{Dialog as o}from"@base-ui/react/dialog";import{MPIcon as n}from"../icon/MPIcon.js";import{CloseIcon as r}from"../../constants/icons.js";import{useMPLocale as i,useMPMessages as s}from"../../internal/locale.js";import{COMMON as d}from"../../internal/messages/common.js";import{MPStateLayer as m}from"../../internal/StateLayer.js";import{cssLength as f}from"../../internal/length.js";import{hasContent as c,META_TEXT as p,PROSE_TEXT as u,SHEET_GAP as x,SHEET_PAD_X as h,SHEET_PAD_Y as g,SHEET_TITLE as b}from"../../internal/scale.js";import{FADE as y,PORTAL_LAYER as
|
|
2
|
+
import{jsx as e,jsxs as t,Fragment as l}from"react/jsx-runtime";import*as a from"react";import{Dialog as o}from"@base-ui/react/dialog";import{MPIcon as n}from"../icon/MPIcon.js";import{CloseIcon as r}from"../../constants/icons.js";import{useMPLocale as i,useMPMessages as s}from"../../internal/locale.js";import{COMMON as d}from"../../internal/messages/common.js";import{MPStateLayer as m}from"../../internal/StateLayer.js";import{cssLength as f}from"../../internal/length.js";import{hasContent as c,META_TEXT as p,PROSE_TEXT as u,SHEET_GAP as x,SHEET_PAD_X as h,SHEET_PAD_Y as g,SHEET_TITLE as b}from"../../internal/scale.js";import{FADE as y,PORTAL_LAYER as j,SCRIM as v,SHEET_MOTION as w}from"../../internal/surface.js";import{useMPSize as $}from"../../internal/config.js";const N={xs:"w-60",sm:"w-72",md:"w-90",lg:"w-104",xl:"w-120"},C={left:"rounded-r-mp-lg",right:"rounded-l-mp-lg",top:"rounded-b-mp-xl",bottom:"rounded-t-mp-xl"},k={left:"border-r",right:"border-l",top:"border-b",bottom:"border-t"},z={left:"flex-row justify-start",right:"flex-row justify-end",top:"flex-col justify-start",bottom:"flex-col justify-end"},P={left:"motion-safe:data-starting-style:-translate-x-full motion-safe:data-ending-style:-translate-x-full",right:"motion-safe:data-starting-style:translate-x-full motion-safe:data-ending-style:translate-x-full",top:"motion-safe:data-starting-style:-translate-y-full motion-safe:data-ending-style:-translate-y-full",bottom:"motion-safe:data-starting-style:translate-y-full motion-safe:data-ending-style:translate-y-full"},B=`transition-[opacity,translate] ${w}`,D="border-mp-outline-variant border-t";export const MPDrawerClose=o.Close;export function MPDrawer({side:w="left",mode:O="modal",open:M,defaultOpen:L,onOpenChange:S,trigger:T,title:F,description:I,actions:R,dividers:V=!1,showClose:q,closeLabel:A,locale:E,extent:G,rounded:H=!0,dismissible:J=!0,size:K,className:Q,style:U,children:W}){const X=$(K),Y=i(E),Z=s(d,Y),_="modal"===O,ee="left"===w||"right"===w,te=q??_,le=A??Z.close,[ae,oe]=a.useState(L??!0),ne=M??ae,re=h[X],ie=g[X],se=V?`${re} ${ie}`:re,de=c(F)||c(I),me=c(R),fe=void 0===G?null:{[ee?"width":"height"]:f(G)},ce=["mp-drawer relative flex flex-col overflow-hidden box-border","border-mp-outline-variant outline-none",_?"bg-mp-surface-container-low shadow-mp-1":"bg-mp-surface","text-mp-on-surface",u[X],k[w],H?C[w]:"",_?`${B} ${P[w]}`:"",ee?`h-full max-w-full ${void 0===G?N[X]:""}`:"w-full "+(void 0===G?"max-h-[85%]":""),V?"":`${ie} ${x[X]}`,Q??""].filter(Boolean).join(" "),pe=_?o.Title:"h2",ue=_?o.Description:"p",xe=/*@__PURE__*/["group text-mp-on-surface-variant relative flex size-10 shrink-0","rounded-mp-full cursor-pointer items-center justify-center","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(" "),he=t(l,{children:[de||te?t("div",{className:`flex shrink-0 items-start gap-3 ${se}`,children:[t("div",{className:"flex min-w-0 flex-1 flex-col",children:[c(F)?e(pe,{className:`m-0 ${b[X]}`,children:F}):null,c(I)?e(ue,{className:`text-mp-on-surface-variant m-0 ${p}`,children:I}):null]}),te?_?t(o.Close,{"aria-label":le,className:xe,children:[e(m,{}),e(n,{icon:r,size:20})]}):t("button",{type:"button","aria-label":le,className:xe,onClick:()=>{void 0===M&&oe(!1),S?.(!1)},children:[e(m,{}),e(n,{icon:r,size:20})]}):null]}):null,c(W)?e("div",{className:["min-h-0 flex-1 overflow-y-auto overscroll-contain",se,V&&(de||te)?D:"",V?"":"-my-1 py-1"].filter(Boolean).join(" "),children:W}):null,me?e("div",{className:["flex shrink-0 flex-wrap items-center justify-end gap-2",se,V?D:""].filter(Boolean).join(" "),children:R}):null]});return _?t(o.Root,{open:M,defaultOpen:L,disablePointerDismissal:!J,onOpenChange:(e,t)=>{J||e||"escape-key"!==t.reason?S?.(e):t.cancel()},children:[T?e(o.Trigger,{render:T}):null,t(o.Portal,{children:[e(o.Backdrop,{className:`${j} fixed inset-0 ${y} ${v}`}),e(o.Viewport,{className:`${j} fixed inset-0 flex ${z[w]}`,children:e(o.Popup,{"data-mp-size":X,"data-mp-side":w,"data-mp-mode":O,className:ce,style:{...fe,...U},children:he})})]})]}):ne?e("div",{"data-mp-size":X,"data-mp-side":w,"data-mp-mode":O,className:ce,style:{...fe,...U},children:he}):null}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import*as
|
|
2
|
+
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import*as n from"react";import{useRender as s}from"@base-ui/react/use-render";import{useMPLocale as a,useMPMessages as l}from"../../internal/locale.js";import{EMPTY as i}from"../../internal/messages/empty.js";import{hasContent as o,PROSE_TEXT as m,SHEET_GAP as c,SHEET_PAD_X as d,SHEET_TITLE as p}from"../../internal/scale.js";import{CONTAINER_SURFACE as f}from"../../internal/surface.js";import{useMPSize as x}from"../../internal/config.js";const u={xs:"py-5",sm:"py-6",md:"py-8",lg:"py-10",xl:"py-12"},h={xs:"text-[1.5rem]",sm:"text-[1.75rem]",md:"text-[2.25rem]",lg:"text-[2.75rem]",xl:"text-[3.25rem]"};function v(){return t("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"size-[1em]",children:[e("path",{d:"M1.75 9.75h3l.9 1.6h4.7l.9-1.6h3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"m1.75 9.75 2.1-6a1.5 1.5 0 0 1 1.42-1h5.46a1.5 1.5 0 0 1 1.42 1l2.1 6v2a1.5 1.5 0 0 1-1.5 1.5h-9.5a1.5 1.5 0 0 1-1.5-1.5Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"})]})}export const MPEmpty=/*@__PURE__*/n.forwardRef(function({variant:n="text",size:j,title:y,icon:g,action:N,locale:k,render:w,className:z,style:$,children:L,...B},C){const M=x(j),W=a(k),b=l(i,W),E=void 0===y?b.title:y,F=void 0===g?e(v,{}):g,P=o(E),R=["mp-empty flex w-full flex-col items-center justify-center text-center",d[M],u[M],"text"===n?"":"rounded-mp-md",c[M],f[n],"text-mp-on-surface",z??""].filter(Boolean).join(" ");return s({render:w,ref:C,props:{role:"status","data-mp-size":M,"data-mp-variant":n,className:R,style:$,children:t(r,{children:[o(F)?e("span",{className:`text-mp-on-surface-variant flex items-center ${h[M]} [&>svg]:size-[1em]`,children:F}):null,P||o(L)?t("div",{className:`flex max-w-prose flex-col items-center ${c[M]}`,children:[P?e("div",{className:p[M],children:E}):null,o(L)?e("div",{className:`${m[M]} ${P?"text-mp-on-surface-variant":""}`,children:L}):null]}):null,o(N)?e("div",{className:"flex flex-wrap items-center justify-center gap-2",children:N}):null]}),...B}})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as n from"react";import{MPIcon as t}from"../icon/MPIcon.js";import{CloseIcon as a,UploadIcon as i}from"../../constants/icons.js";import{fillMessage as l}from"../../internal/i18n.js";import{useMPLocale as o,useMPMessages as s}from"../../internal/locale.js";import{COMMON as c}from"../../internal/messages/common.js";import{FILE_PICKER as m}from"../../internal/messages/file-picker.js";import{MPStateLayer as p}from"../../internal/StateLayer.js";import{CONTROL_ICON as u,META_TEXT as d,PROSE_TEXT as f,STACK_GAP as h,hasContent as x}from"../../internal/scale.js";const
|
|
2
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as n from"react";import{MPIcon as t}from"../icon/MPIcon.js";import{CloseIcon as a,UploadIcon as i}from"../../constants/icons.js";import{fillMessage as l}from"../../internal/i18n.js";import{useMPLocale as o,useMPMessages as s}from"../../internal/locale.js";import{COMMON as c}from"../../internal/messages/common.js";import{FILE_PICKER as m}from"../../internal/messages/file-picker.js";import{MPStateLayer as p}from"../../internal/StateLayer.js";import{CONTROL_ICON as u,META_TEXT as d,PROSE_TEXT as f,STACK_GAP as h,hasContent as x}from"../../internal/scale.js";import{useMPSize as b}from"../../internal/config.js";const v={xs:"p-4",sm:"p-5",md:"p-6",lg:"p-8",xl:"p-10"};export function formatFileSize(e){if(e<1e3)return`${e} B`;const r=["kB","MB","GB","TB"];let n=e/1e3,t=0;for(;n>=1e3&&t<r.length-1;)n/=1e3,t+=1;return`${n<10?n.toFixed(1):Math.round(n)} ${r[t]}`}function g(e,r){const n=e.name.toLowerCase(),t=e.type.toLowerCase();return r.split(",").map(e=>e.trim().toLowerCase()).filter(Boolean).some(e=>e.startsWith(".")?n.endsWith(e):e.endsWith("/*")?t.startsWith(e.slice(0,-1)):t===e)}export const MPFilePicker=/*@__PURE__*/n.forwardRef(function({accept:j,multiple:y=!1,maxSize:N,maxFiles:k,value:z,defaultValue:w,onFilesChange:C,onReject:I,label:B,description:D,errorMessage:F,title:L,hint:M,icon:S,showList:$=!0,removeLabel:T,locale:W,size:_,fullWidth:P=!0,required:R=!1,disabled:E=!1,readOnly:O=!1,name:q,id:A,className:V,style:G},H){const Y=b(_),J=o(W),K=s(c,J),Q=s(m,J),U=n.useRef(null);n.useImperativeHandle(H,()=>U.current,[]);const[X,Z]=n.useState(()=>[...w??[]]),ee=z?[...z]:X,re=n.useRef(0),[ne,te]=n.useState(!1),ae=x(F),ie=E||O,le=n.useId(),oe=n.useId(),se=n.useCallback(e=>{z||Z(e),C?.(e)},[C,z]),ce=n.useCallback(e=>{const r=[],n=[],t=y?k??Number.POSITIVE_INFINITY:1,a=y?ee.length:0;for(const i of e)j&&!g(i,j)?n.push({file:i,reason:"type"}):void 0!==N&&i.size>N?n.push({file:i,reason:"size"}):a+r.length>=t?n.push({file:i,reason:"count"}):r.push(i);return{kept:r,rejections:n}},[j,ee.length,k,N,y]),me=n.useCallback(e=>{const{kept:r,rejections:n}=ce(e);n.length>0&&I?.(n),r.length>0&&se(y?[...ee,...r]:r)},[ce,se,ee,y,I]);return r("div",{className:["mp-file-picker flex-col align-top",h[Y],P?"flex w-full":"inline-flex",V??""].filter(Boolean).join(" "),style:G,"data-mp-size":Y,"data-disabled":E||void 0,"data-invalid":ae||void 0,children:[x(B)?r("span",{id:oe,className:[d,E?"text-mp-on-surface/38":ae?"text-mp-error":"text-mp-on-surface-variant"].join(" "),children:[B,R?e("span",{"aria-hidden":"true",children:" *"}):null]}):null,r("div",{className:"relative flex w-full flex-col",onDragEnter:e=>{ie||(e.preventDefault(),re.current+=1,te(!0))},onDragOver:e=>{ie||(e.preventDefault(),e.dataTransfer.dropEffect="copy")},onDragLeave:()=>{ie||(re.current=Math.max(0,re.current-1),0===re.current&&te(!1))},onDrop:e=>{ie||(e.preventDefault(),re.current=0,te(!1),me(Array.from(e.dataTransfer.files)))},children:[r("button",{type:"button",id:A,disabled:E,"aria-describedby":x(D)||ae?le:void 0,"aria-invalid":ae||void 0,className:["mp-file-picker__zone group relative flex w-full flex-col items-center","justify-center gap-2 text-center","rounded-mp-md box-border border-2 border-dashed","appearance-none bg-transparent font-[inherit] outline-none","transition-[border-color,background-color] duration-(--mp-sys-motion-duration-short4)",v[Y],f[Y],E?"border-mp-on-surface/12 text-mp-on-surface/38 cursor-default":[O?"cursor-default":"cursor-pointer",ae?"border-mp-error":"border-mp-outline-variant","text-mp-on-surface",ne?"border-mp-primary bg-mp-primary/8":""].filter(Boolean).join(" ")].filter(Boolean).join(" "),onClick:()=>{!ie&&U.current&&(U.current.value="",U.current.click())},children:[ie?null:e(p,{layer:"inset-0 rounded-[inherit] bg-mp-primary"}),void 0===S?e(t,{icon:i,size:1.6*u[Y],className:E?"":"text-mp-primary"}):x(S)?e("span",{className:E?"":"text-mp-primary",children:S}):null,e("span",{className:"font-medium",children:L??Q.prompt}),x(M)?e("span",{className:[d,E?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:M}):null]}),e("input",{ref:U,type:"file",name:q,accept:j,multiple:y,required:R&&0===ee.length,disabled:ie,tabIndex:-1,"aria-labelledby":x(B)?oe:void 0,"aria-describedby":x(D)||ae?le:void 0,className:"absolute size-px overflow-hidden opacity-0 [clip-path:inset(50%)]",onChange:e=>me(Array.from(e.target.files??[]))})]}),$&&ee.length>0?e("ul",{className:["mp-file-picker__list m-0 flex w-full list-none flex-col p-0",h[Y]].join(" "),children:ee.map((n,i)=>r("li",{className:["rounded-mp-xs bg-mp-surface-container-low flex w-full items-center gap-3","px-3 py-2",f[Y],E?"text-mp-on-surface/38":"text-mp-on-surface"].join(" "),children:[e("span",{className:"min-w-0 flex-1 truncate",children:n.name}),e("span",{className:[d,"shrink-0 tabular-nums",E?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:formatFileSize(n.size)}),ie?null:r("button",{type:"button","aria-label":T?T(n.name):l(K.removeNamed,{label:n.name}),className:["group text-mp-on-surface-variant relative flex size-8 shrink-0","cursor-pointer appearance-none items-center justify-center rounded-full","bg-transparent p-0 font-[inherit] outline-none"].join(" "),onClick:()=>se(ee.filter((e,r)=>r!==i)),children:[e(p,{}),e(t,{icon:a,size:18})]})]},`${n.name}-${n.size}-${n.lastModified}-${i}`))}):null,ae?e("span",{id:le,className:[d,"text-mp-error"].join(" "),children:F}):x(D)?e("span",{id:le,className:[d,E?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:D}):null]})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as t,jsxs as e}from"react/jsx-runtime";import*as
|
|
2
|
+
import{jsx as t,jsxs as e}from"react/jsx-runtime";import*as n from"react";import{Button as o}from"@base-ui/react/button";import{accentSlots as a}from"../../internal/accent.js";import{cssLength as i}from"../../internal/length.js";import{MPStateLayer as s}from"../../internal/StateLayer.js";import{hasContent as r}from"../../internal/scale.js";import{useMPColor as m,useMPSize as l}from"../../internal/config.js";const p={filled:"bg-(--_mp-accent) text-(--_mp-on-accent)",tonal:"bg-(--_mp-accent-container) text-(--_mp-on-accent-container)",elevated:"bg-mp-surface-container-high text-(--_mp-accent)"},d={xs:"h-10",sm:"h-12",md:"h-14",lg:"h-18",xl:"h-24"},f={xs:"min-w-10 gap-0 px-0",sm:"min-w-12 gap-0 px-0",md:"min-w-14 gap-0 px-0",lg:"min-w-18 gap-0 px-0",xl:"min-w-24 gap-0 px-0"},c={xs:"rounded-mp-md",sm:"rounded-mp-lg",md:"rounded-mp-lg",lg:"rounded-mp-xl",xl:"rounded-mp-xl"},x={xs:24,sm:24,md:24,lg:30,xl:36},u={xs:"text-mp-label-large",sm:"text-mp-label-large",md:"text-mp-label-large",lg:"text-mp-title-medium",xl:"text-mp-title-medium"},g={xs:"min-w-16 gap-1.5 px-3",sm:"min-w-18 gap-2 px-4",md:"min-w-20 gap-2 px-4",lg:"min-w-24 gap-2.5 px-5",xl:"min-w-28 gap-3 px-6"},b={absolute:"absolute z-30",sticky:"sticky z-30",fixed:"fixed z-40"},h={"top-start":"top-(--_mp-fab-offset) start-(--_mp-fab-offset)","top-end":"top-(--_mp-fab-offset) end-(--_mp-fab-offset)","bottom-start":"bottom-(--_mp-fab-offset) start-(--_mp-fab-offset)","bottom-end":"bottom-(--_mp-fab-offset) end-(--_mp-fab-offset)"};export const MPFloatingActionButton=/*@__PURE__*/n.forwardRef(function({icon:n,label:w,extended:_=!1,variant:y="tonal",color:j,size:v,position:k="fixed",corner:z="bottom-end",offset:N=16,disabled:B=!1,type:$="button",className:A,style:F,...L},M){const P=m(j),R=l(v);return e(o,{ref:M,type:$,disabled:B,"aria-label":w,"data-mp-size":R,"data-mp-variant":y,className:["mp-fab group inline-flex shrink-0 items-center justify-center","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,box-shadow,color,min-width,padding,gap]","duration-(--mp-sys-motion-duration-short4) ease-mp-standard",c[R],d[R],u[R],_?g[R]:f[R],B?"bg-mp-on-surface/12 text-mp-on-surface/38 cursor-default shadow-none":`${p[y]} shadow-mp-3`,"static"===k?"relative":`${b[k]} ${h[z]}`,A??""].filter(Boolean).join(" "),style:{...a(P),"--_mp-fab-offset":i(N),...F},...L,children:[B?null:t(s,{}),r(n)?t("span",{className:"relative flex shrink-0 items-center justify-center",style:{width:x[R],height:x[R]},children:n}):null,t("span",{className:["relative grid transition-[grid-template-columns]","duration-(--mp-sys-motion-duration-short4) ease-mp-standard",_?"grid-cols-[1fr]":"grid-cols-[0fr]"].join(" "),children:t("span",{className:"min-w-0 truncate",children:w})})]})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e}from"react/jsx-runtime";import*as t from"react";import{useRender as o}from"@base-ui/react/use-render";import{BAR_SURFACE as r,MPPageLayoutContext as a}from"../../internal/page-layout.js";import{MEASURE as i,SHEET_PAD_X as n,SHEET_PAD_Y as s}from"../../internal/scale.js";const
|
|
2
|
+
import{jsx as e}from"react/jsx-runtime";import*as t from"react";import{useRender as o}from"@base-ui/react/use-render";import{BAR_SURFACE as r,MPPageLayoutContext as a}from"../../internal/page-layout.js";import{MEASURE as i,SHEET_PAD_X as n,SHEET_PAD_Y as s}from"../../internal/scale.js";import{useMPSize as l}from"../../internal/config.js";const m={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 MPFooter=/*@__PURE__*/t.forwardRef(function({position:f="static",variant:c="outlined",size:d,maxWidth:p="none",padded:u=!0,label:b,render:x,className:j,children:z,...h},v){const w=l(d),{register:y}=t.useContext(a),g=t.useCallback(e=>{y("footer",e),"function"==typeof v?v(e):v&&(v.current=e)},[y,v]);return o({render:x??e("footer",{}),ref:g,props:{"aria-label":b,"data-mp-size":w,"data-mp-variant":c,className:["mp-footer text-mp-on-surface box-border w-full min-w-0",r[c],"outlined"===c?"border-mp-outline-variant border-t":"",m[f],j??""].filter(Boolean).join(" "),children:e("div",{className:["mp-footer__inner w-full",u?`${n[w]} ${s[w]}`:"","none"===p?"":`${i[p]} mx-auto`].filter(Boolean).join(" "),children:z}),...h}})});
|