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,60 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
export interface MPVisuallyHiddenProps extends React.ComponentPropsWithoutRef<'span'> {
|
|
4
|
+
/** Renders something other than a `<span>`. Base UI's own escape hatch. */
|
|
5
|
+
render?: useRender.RenderProp;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Text for a screen reader and nobody else.
|
|
10
|
+
*
|
|
11
|
+
* The sentence behind a bare number on a badge, the "opens in a new tab" after a
|
|
12
|
+
* link's label, the name an avatar's initials stand in for, the direction a
|
|
13
|
+
* sorted column is sorted in. In every one of those the visible mark is a
|
|
14
|
+
* shorthand a reader who can see it expands instantly and a reader who cannot
|
|
15
|
+
* gets nothing at all from.
|
|
16
|
+
*
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <button>
|
|
19
|
+
* <MPIcon icon={ICONS.close} />
|
|
20
|
+
* <MPVisuallyHidden>Close this dialog</MPVisuallyHidden>
|
|
21
|
+
* </button>
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* Nine components in this library were already drawing themselves with it —
|
|
25
|
+
* `MPPagination`'s live region, `MPRating`'s radios, `MPShortcut`'s key names,
|
|
26
|
+
* `MPCarousel`'s slide announcement — and an application putting a bare glyph in
|
|
27
|
+
* a button of its own had no way to reach the same treatment. It had the rule,
|
|
28
|
+
* not the name.
|
|
29
|
+
*
|
|
30
|
+
* ## Not `hidden`, not `display: none`, not `opacity: 0`
|
|
31
|
+
*
|
|
32
|
+
* The first two take the text off the accessibility tree along with the screen,
|
|
33
|
+
* which is the opposite of what is wanted, and the third leaves a clickable ghost
|
|
34
|
+
* the size of the words. A 1px clipped box is the one form that is invisible to
|
|
35
|
+
* a sighted reader and present to every other kind.
|
|
36
|
+
*
|
|
37
|
+
* ## Why not `sr-only`
|
|
38
|
+
*
|
|
39
|
+
* Which is Tailwind's own utility for this, and it is what the rule below is
|
|
40
|
+
* written out from. It is written out because `sr-only` is *generated*: a
|
|
41
|
+
* project running its own Tailwind build with a `prefix` configured generates it
|
|
42
|
+
* under a different name, and a component that hardcoded `sr-only` would come
|
|
43
|
+
* out visible on their page. The arbitrary properties survive any prefix.
|
|
44
|
+
*
|
|
45
|
+
* ## It stays in the layout
|
|
46
|
+
*
|
|
47
|
+
* `position: absolute`, so it takes no room — but it is still *in* the document,
|
|
48
|
+
* which is the whole point: it is read in the order it is written. Put it where
|
|
49
|
+
* the sentence belongs rather than at the end of the block.
|
|
50
|
+
*
|
|
51
|
+
* ## Sharp edges
|
|
52
|
+
*
|
|
53
|
+
* - **A focusable thing inside this stays focusable**, and a reader tabbing into
|
|
54
|
+
* it lands somewhere they cannot see. Anything that can take focus wants
|
|
55
|
+
* `aria-label` on the control instead.
|
|
56
|
+
* - **It is not a live region.** Text swapped inside it is not announced unless
|
|
57
|
+
* the element also carries `aria-live` — which is exactly what the components
|
|
58
|
+
* above pass through.
|
|
59
|
+
*/
|
|
60
|
+
export declare const MPVisuallyHidden: React.ForwardRefExoticComponent<MPVisuallyHiddenProps & React.RefAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as r}from"react/jsx-runtime";import*as e from"react";import{useRender as n}from"@base-ui/react/use-render";import{VISUALLY_HIDDEN as a}from"../../internal/visually-hidden.js";export const MPVisuallyHidden=/*@__PURE__*/e.forwardRef(function({render:e,className:i,children:o,...s},t){return n({render:e??r("span",{}),ref:t,props:{...s,className:[a,i].filter(Boolean).join(" "),children:o}})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPVisuallyHidden}from"./MPVisuallyHidden.js";
|
|
@@ -34,6 +34,8 @@ export declare const LinkIcon: import("react").ForwardRefExoticComponent<Omit<im
|
|
|
34
34
|
export declare const ExternalLinkIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
35
35
|
/** Copy to clipboard. */
|
|
36
36
|
export declare const CopyIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
37
|
+
/** A picture that could not be fetched — `MPImage`'s own fallback. */
|
|
38
|
+
export declare const BrokenImageIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
37
39
|
/** Severity: something worth knowing. */
|
|
38
40
|
export declare const InfoIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
39
41
|
/** Severity: it worked. */
|
package/dist/constants/glyphs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{ArrowDown as o,ArrowRight as n,ArrowUp as t,CalendarDays as c,Check as r,ChevronDown as e,ChevronLeft as s,ChevronRight as p,ChevronsLeft as
|
|
2
|
+
import{ArrowDown as o,ArrowRight as n,ArrowUp as t,CalendarDays as c,Check as r,ChevronDown as e,ChevronLeft as s,ChevronRight as p,ChevronsLeft as I,ChevronsRight as x,ChevronUp as i,CircleAlert as h,CircleCheck as C,Clock as a,Copy as l,Ellipsis as v,ExternalLink as f,Eye as d,ImageOff as g,EyeOff as k,Info as w,Link as m,LoaderCircle as A,Menu as L,Minus as R,Plus as S,Search as u,Star as y,TriangleAlert as U,Upload as b,X as D}from"lucide-react";export const VisibilityIcon=d;export const VisibilityOffIcon=k;export const CloseIcon=D;export const CheckIcon=r;export const ChevronDownIcon=e;export const ChevronUpIcon=i;export const ChevronLeftIcon=s;export const ChevronRightIcon=p;export const ChevronsLeftIcon=I;export const ChevronsRightIcon=x;export const SearchIcon=u;export const ArrowUpIcon=t;export const ArrowDownIcon=o;export const ArrowRightIcon=n;export const MoreIcon=v;export const LinkIcon=m;export const ExternalLinkIcon=f;export const CopyIcon=l;export const BrokenImageIcon=g;export const InfoIcon=w;export const SuccessIcon=C;export const WarningIcon=U;export const ErrorIcon=h;export const AddIcon=S;export const RemoveIcon=R;export const UploadIcon=b;export const CalendarIcon=c;export const ClockIcon=a;export const StarIcon=y;export const SpinnerIcon=A;export const MenuIcon=L;
|
|
@@ -60,6 +60,7 @@ export declare const ICONS: {
|
|
|
60
60
|
readonly link: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
61
61
|
readonly 'external-link': import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
62
62
|
readonly copy: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
63
|
+
readonly 'broken-image': import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
63
64
|
readonly info: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
64
65
|
readonly success: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
65
66
|
readonly warning: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
package/dist/constants/icons.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./glyphs.js";import{VisibilityIcon as r,VisibilityOffIcon as o,CloseIcon as e,CheckIcon as n,ChevronDownIcon as
|
|
1
|
+
export*from"./glyphs.js";import{VisibilityIcon as r,VisibilityOffIcon as o,CloseIcon as e,CheckIcon as n,ChevronDownIcon as i,ChevronUpIcon as c,ChevronLeftIcon as s,ChevronRightIcon as h,ChevronsLeftIcon as l,ChevronsRightIcon as t,SearchIcon as a,ArrowUpIcon as p,ArrowDownIcon as v,ArrowRightIcon as f,MoreIcon as g,MenuIcon as m,LinkIcon as d,ExternalLinkIcon as w,CopyIcon as k,BrokenImageIcon as u,InfoIcon as y,SuccessIcon as b,WarningIcon as x,ErrorIcon as j,AddIcon as C,RemoveIcon as I,UploadIcon as N,CalendarIcon as O,ClockIcon as S,StarIcon as q,SpinnerIcon as z}from"./glyphs.js";export const ICONS={visibility:r,"visibility-off":o,close:e,check:n,"chevron-down":i,"chevron-up":c,"chevron-left":s,"chevron-right":h,"chevrons-left":l,"chevrons-right":t,search:a,"arrow-up":p,"arrow-down":v,"arrow-right":f,more:g,menu:m,link:d,"external-link":w,copy:k,"broken-image":u,info:y,success:b,warning:x,error:j,add:C,remove:I,upload:N,calendar:O,clock:S,star:q,spinner:z};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The machinery this library was already running, with a name a consumer can
|
|
3
|
+
* import.
|
|
4
|
+
*
|
|
5
|
+
* Every hook here existed in `internal/` before it existed here, and each was
|
|
6
|
+
* exported for the same reason: an application that has told the library
|
|
7
|
+
* something — or that has to answer a question the library has already answered
|
|
8
|
+
* for itself — should not have to answer it a second time, in numbers or in
|
|
9
|
+
* detection code that can drift away from what the components are using.
|
|
10
|
+
*
|
|
11
|
+
* `useMPLocale` and `useMPSnackbar` are not here. They belong to a provider and
|
|
12
|
+
* live with it, the way a hook that reads a context should.
|
|
13
|
+
*
|
|
14
|
+
* `useMPColorScheme` is the one that is more than a rename: the stylesheet
|
|
15
|
+
* had the switch and nothing to drive it with, so every application wrote the
|
|
16
|
+
* same state, the same storage round trip and the same `<head>` script.
|
|
17
|
+
*/
|
|
18
|
+
export { useMPColorScheme, mpColorSchemeScript } from './useMPColorScheme.js';
|
|
19
|
+
export type { MPColorScheme, MPResolvedColorScheme, MPColorSchemeOptions, MPColorSchemeResult } from './useMPColorScheme.js';
|
|
20
|
+
export { useMPWindowClass } from './useMPWindowClass.js';
|
|
21
|
+
export { useMPReducedMotion } from './useMPReducedMotion.js';
|
|
22
|
+
export { useMPShortcut, useMPPlatform } from './useMPShortcut.js';
|
|
23
|
+
export type { MPShortcutOptions, MPResolvedOS } from './useMPShortcut.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{useMPColorScheme,mpColorSchemeScript}from"./useMPColorScheme.js";export{useMPWindowClass}from"./useMPWindowClass.js";export{useMPReducedMotion}from"./useMPReducedMotion.js";export{useMPShortcut,useMPPlatform}from"./useMPShortcut.js";
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { type MPColorScheme, type MPResolvedColorScheme } from '../internal/color-scheme.js';
|
|
2
|
+
export type { MPColorScheme, MPResolvedColorScheme };
|
|
3
|
+
export interface MPColorSchemeOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Where the choice is remembered, in `localStorage`.
|
|
6
|
+
*
|
|
7
|
+
* Change it to keep two applications on one origin from sharing a theme, or
|
|
8
|
+
* to namespace it under a product. It has to match the key given to
|
|
9
|
+
* `mpColorSchemeScript`, or the page paints one scheme and then corrects
|
|
10
|
+
* itself to the other.
|
|
11
|
+
* @default 'mp-color-scheme'
|
|
12
|
+
*/
|
|
13
|
+
storageKey?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface MPColorSchemeResult {
|
|
16
|
+
/**
|
|
17
|
+
* What has been **chosen** — including `'system'`, which is the absence of a
|
|
18
|
+
* choice rather than a third scheme. This is what a settings control should be
|
|
19
|
+
* bound to: a three-way radio group is honest about the state, and a two-way
|
|
20
|
+
* toggle bound to this cannot show "follow the system" at all.
|
|
21
|
+
*/
|
|
22
|
+
scheme: MPColorScheme;
|
|
23
|
+
/**
|
|
24
|
+
* What is actually **painted**, with `'system'` resolved against the operating
|
|
25
|
+
* system. This is what a page reads to draw a sun or a moon, or to pick an
|
|
26
|
+
* image.
|
|
27
|
+
*/
|
|
28
|
+
resolved: MPResolvedColorScheme;
|
|
29
|
+
/** Whether the choice is `'system'`, spelled out because it reads better. */
|
|
30
|
+
isSystem: boolean;
|
|
31
|
+
/** Chooses a scheme. `'system'` gives the choice back to the operating system. */
|
|
32
|
+
setScheme: (scheme: MPColorScheme) => void;
|
|
33
|
+
/**
|
|
34
|
+
* The other one of the two.
|
|
35
|
+
*
|
|
36
|
+
* From `'system'` it goes to the opposite of whatever is currently painted,
|
|
37
|
+
* which is what a reader pressing a single button means by it — never back to
|
|
38
|
+
* the scheme they are already looking at.
|
|
39
|
+
*/
|
|
40
|
+
toggle: () => void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The page's colour scheme: what it is, and how to change it.
|
|
44
|
+
*
|
|
45
|
+
* The stylesheet has always had the switch — `prefers-color-scheme`, and
|
|
46
|
+
* `data-mp-scheme` for a page that drives it itself. What it did not have was
|
|
47
|
+
* anything to drive it *with*, so every application wrote the same three things:
|
|
48
|
+
* a piece of state, a `localStorage` round trip, and a script in the `<head>` to
|
|
49
|
+
* stop the first paint flashing.
|
|
50
|
+
*
|
|
51
|
+
* ```tsx
|
|
52
|
+
* const { resolved, toggle } = useMPColorScheme();
|
|
53
|
+
*
|
|
54
|
+
* <MPIconButton
|
|
55
|
+
* icon={<MPIcon icon={resolved === 'dark' ? SunIcon : MoonIcon} />}
|
|
56
|
+
* label="Switch theme"
|
|
57
|
+
* onClick={toggle}
|
|
58
|
+
* />;
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* ## Three states, not two
|
|
62
|
+
*
|
|
63
|
+
* `'system'` is the absence of a choice rather than a third scheme, and keeping
|
|
64
|
+
* it is the point. A reader who has never touched the toggle should follow their
|
|
65
|
+
* operating system *as it changes* — including at sunset, which is when a
|
|
66
|
+
* two-state hook stops tracking and a page goes light in a dark room.
|
|
67
|
+
*
|
|
68
|
+
* `scheme` is what was chosen and `resolved` is what is painted. Bind a settings
|
|
69
|
+
* control to the first and draw with the second.
|
|
70
|
+
*
|
|
71
|
+
* ## One page, one answer
|
|
72
|
+
*
|
|
73
|
+
* The choice lives in a module-level store rather than in each caller's state,
|
|
74
|
+
* so a header's toggle and a settings screen's radio group are looking at the
|
|
75
|
+
* same thing. Two components holding `useState` would each show what they last
|
|
76
|
+
* set and neither would hear about the other.
|
|
77
|
+
*
|
|
78
|
+
* ## What it writes
|
|
79
|
+
*
|
|
80
|
+
* `data-mp-scheme` on `<html>`, and `'system'` **removes** it rather than
|
|
81
|
+
* writing the word — that is how the media query gets its say back.
|
|
82
|
+
*
|
|
83
|
+
* It deliberately does not touch `.dark`. That class is what a project's own
|
|
84
|
+
* Tailwind keys on, and a library reaching in to toggle a class it did not put
|
|
85
|
+
* there is a library editing somebody else's markup. A page that wants both is
|
|
86
|
+
* one line of its own in an effect.
|
|
87
|
+
*
|
|
88
|
+
* ## Storage can fail, and that is fine
|
|
89
|
+
*
|
|
90
|
+
* Reading and writing `localStorage` throws in a private window in some browsers
|
|
91
|
+
* and behind some cookie policies. Both are caught: the toggle still works for
|
|
92
|
+
* the visit and the choice is simply not remembered, which is much better than a
|
|
93
|
+
* theme button that crashes the render.
|
|
94
|
+
*
|
|
95
|
+
* ## The first paint
|
|
96
|
+
*
|
|
97
|
+
* A hook cannot run before the page paints, so a remembered `dark` arrives one
|
|
98
|
+
* frame late and the reader sees white. That is what `mpColorSchemeScript` is
|
|
99
|
+
* for — see it for the two lines that go in the `<head>`.
|
|
100
|
+
*/
|
|
101
|
+
export declare function useMPColorScheme(options?: MPColorSchemeOptions): MPColorSchemeResult;
|
|
102
|
+
/**
|
|
103
|
+
* The two lines that stop the first paint flashing, as a string to inline.
|
|
104
|
+
*
|
|
105
|
+
* A hook runs after the browser has already painted, so a reader who chose dark
|
|
106
|
+
* gets a white page for a frame and then the right one. The only thing that can
|
|
107
|
+
* run earlier is a **synchronous script in the `<head>`**, before the body is
|
|
108
|
+
* parsed, and this is that script.
|
|
109
|
+
*
|
|
110
|
+
* ```tsx
|
|
111
|
+
* // app/layout.tsx
|
|
112
|
+
* <head>
|
|
113
|
+
* <script dangerouslySetInnerHTML={{ __html: mpColorSchemeScript() }} />
|
|
114
|
+
* </head>
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* It reads the same key the hook does, writes the same attribute, and does
|
|
118
|
+
* nothing at all when the stored value is absent or `system` — leaving the media
|
|
119
|
+
* query to answer, which it does before the first paint anyway.
|
|
120
|
+
*
|
|
121
|
+
* Pass the same `storageKey` you pass the hook. Two different keys is a page
|
|
122
|
+
* that paints one scheme and then corrects itself to the other, which is the
|
|
123
|
+
* flash this exists to remove.
|
|
124
|
+
*
|
|
125
|
+
* The output is a JavaScript source string and contains no interpolated markup:
|
|
126
|
+
* the key is JSON-encoded, so a key with a quote in it cannot end the script
|
|
127
|
+
* early.
|
|
128
|
+
*
|
|
129
|
+
* ## It has to be inline
|
|
130
|
+
*
|
|
131
|
+
* A `<script src>` is fetched, and a fetch is exactly the delay being avoided.
|
|
132
|
+
* If the page has a Content Security Policy without `unsafe-inline`, give the
|
|
133
|
+
* tag a nonce — this returns the source, not the tag, so the tag is yours.
|
|
134
|
+
*/
|
|
135
|
+
export declare function mpColorSchemeScript(options?: MPColorSchemeOptions): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"react";import{DEFAULT_STORAGE_KEY as t,SCHEME_ATTRIBUTE as r,setScheme as s,useChosenScheme as o,useSystemScheme as c}from"../internal/color-scheme.js";export function useMPColorScheme(r={}){const{storageKey:m=t}=r,a=o(m),i=c(),l="system"===a?i:a,n=e.useCallback(e=>s(m,e),[m]),u=e.useCallback(()=>s(m,"dark"===l?"light":"dark"),[m,l]);return e.useMemo(()=>({scheme:a,resolved:l,isSystem:"system"===a,setScheme:n,toggle:u}),[a,l,n,u])}export function mpColorSchemeScript(e={}){const{storageKey:s=t}=e;return`try{var s=localStorage.getItem(${JSON.stringify(s)});if(s==="dark"||s==="light")document.documentElement.setAttribute(${JSON.stringify(r)},s)}catch(e){}`}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the reader has asked for less motion.
|
|
3
|
+
*
|
|
4
|
+
* `prefers-reduced-motion: reduce`, which every `MPAnimate*` component in this
|
|
5
|
+
* library already consults on its own — a fade becomes an appearance, a
|
|
6
|
+
* typewriter prints its sentence, a marquee stops. This is the same answer,
|
|
7
|
+
* exported so an application's own motion can be held to the preference the
|
|
8
|
+
* library is already holding itself to, rather than each of them asking
|
|
9
|
+
* separately and one of them forgetting.
|
|
10
|
+
*
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const still = useMPReducedMotion();
|
|
13
|
+
*
|
|
14
|
+
* <video autoPlay={!still} />;
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* ## Why not `usePrefersReducedMotion`
|
|
18
|
+
*
|
|
19
|
+
* Which is what it is called internally, and what the ecosystem calls it. The
|
|
20
|
+
* `MP` prefix is on every name this package exports for the reason the icons
|
|
21
|
+
* carry it: a file importing from four libraries should be able to tell which
|
|
22
|
+
* one a name came from without going back to the import block.
|
|
23
|
+
*
|
|
24
|
+
* ## On a server
|
|
25
|
+
*
|
|
26
|
+
* `false` — motion allowed. A preference is a property of a reader and a server
|
|
27
|
+
* has none, and the alternative would be a first paint that suppressed animation
|
|
28
|
+
* for everybody and then started it a moment later for most of them, which is a
|
|
29
|
+
* flash rather than a preference. `useSyncExternalStore` under this hands over
|
|
30
|
+
* to the browser's real answer on hydration.
|
|
31
|
+
*/
|
|
32
|
+
export declare function useMPReducedMotion(): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{usePrefersReducedMotion as e}from"../internal/animate.js";export function useMPReducedMotion(){return e()}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { type MPResolvedOS } from '../internal/keys.js';
|
|
2
|
+
/** The three platforms a shortcut is spelled for. */
|
|
3
|
+
export type { MPResolvedOS };
|
|
4
|
+
/** Where the keystroke is listened for, and what happens to it. */
|
|
5
|
+
export interface MPShortcutOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Turns the binding off without unmounting whatever holds it. A shortcut
|
|
8
|
+
* behind a feature flag, or one that belongs to a panel that is closed.
|
|
9
|
+
* @default true
|
|
10
|
+
*/
|
|
11
|
+
enabled?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Calls `preventDefault()` on the matching keystroke.
|
|
14
|
+
*
|
|
15
|
+
* On by default, and it is the honest default: some browsers put their own
|
|
16
|
+
* search bar on `Mod+K`, and a page binding that combination has said the key
|
|
17
|
+
* is theirs. Switch it off for a shortcut that means to run *alongside* the
|
|
18
|
+
* browser's, which is rare enough to be worth writing down.
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
preventDefault?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Ignores the keystroke while the focus is in a text input, a textarea or
|
|
24
|
+
* anything `contenteditable`.
|
|
25
|
+
*
|
|
26
|
+
* Off by default, because the shortcut most pages bind has a modifier and
|
|
27
|
+
* `Mod+K` typed into a search field still means "open the palette". Switch it
|
|
28
|
+
* on for a **bare** key — `/` to focus search, `?` for help — which would
|
|
29
|
+
* otherwise be swallowed out of the middle of somebody's sentence.
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
ignoreInputs?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* What the listener is attached to.
|
|
35
|
+
* @default the window
|
|
36
|
+
*/
|
|
37
|
+
target?: EventTarget | null;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Runs something when a keystroke arrives, spelled the way this library spells
|
|
41
|
+
* shortcuts everywhere else.
|
|
42
|
+
*
|
|
43
|
+
* `MPShortcut` **writes** a shortcut down, `MPCommandPalette` **reads** one off
|
|
44
|
+
* a real keyboard, and both have always gone through one matcher so that a label
|
|
45
|
+
* on the screen and the binding under it cannot disagree — see `internal/keys.ts`
|
|
46
|
+
* for the day they did. This is that matcher, for the shortcuts an application
|
|
47
|
+
* binds itself.
|
|
48
|
+
*
|
|
49
|
+
* ```tsx
|
|
50
|
+
* useMPShortcut('Mod+K', () => setOpen(true));
|
|
51
|
+
* useMPShortcut('/', focusSearch, { ignoreInputs: true });
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* ## `Mod` is the whole point
|
|
55
|
+
*
|
|
56
|
+
* It resolves to Command on a Mac and Control everywhere else, which is what
|
|
57
|
+
* lets one string be both the binding and the label:
|
|
58
|
+
*
|
|
59
|
+
* ```tsx
|
|
60
|
+
* <MPShortcut keys="Mod+K" />;
|
|
61
|
+
* useMPShortcut('Mod+K', open);
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* Two lines, one spelling, and no way for the page to draw `⌘K` while listening
|
|
65
|
+
* for `Ctrl+K`.
|
|
66
|
+
*
|
|
67
|
+
* Modifiers are matched in **both** directions: `Mod+K` does not fire when Shift
|
|
68
|
+
* is also held, because that combination may belong to something else. A
|
|
69
|
+
* shortcut that ignored extra modifiers would be quietly taking keystrokes it
|
|
70
|
+
* was not given.
|
|
71
|
+
*
|
|
72
|
+
* ## The handler is not a dependency
|
|
73
|
+
*
|
|
74
|
+
* It is kept in a ref and read at the moment the key arrives, so an inline arrow
|
|
75
|
+
* function is fine and does not rebind the listener on every render. What *does*
|
|
76
|
+
* rebind is the shortcut itself, `enabled`, and `target` — the things that change
|
|
77
|
+
* what is being listened for.
|
|
78
|
+
*
|
|
79
|
+
* ## Sharp edges
|
|
80
|
+
*
|
|
81
|
+
* - **It listens on the window**, so it fires wherever the focus is unless
|
|
82
|
+
* `ignoreInputs` says otherwise. That is what a page-wide shortcut wants and
|
|
83
|
+
* not what a shortcut belonging to one panel wants — pass that panel's element
|
|
84
|
+
* as `target`.
|
|
85
|
+
* - **It does not stop propagation.** A page with two hooks bound to one
|
|
86
|
+
* combination runs both, which is a collision the page has to resolve rather
|
|
87
|
+
* than something the hook can guess at.
|
|
88
|
+
* - **The platform is detected once.** It cannot change under a running page.
|
|
89
|
+
*/
|
|
90
|
+
export declare function useMPShortcut(keys: string | string[], handler: (event: KeyboardEvent) => void, options?: MPShortcutOptions): void;
|
|
91
|
+
/**
|
|
92
|
+
* Which keyboard the reader is on — `'mac'`, `'windows'` or `'linux'`.
|
|
93
|
+
*
|
|
94
|
+
* The same detection `MPShortcut` prints its key caps from, exported so an
|
|
95
|
+
* application writing a key cap of its own cannot end up on a different answer
|
|
96
|
+
* from the component beside it. Three sources are matched at once —
|
|
97
|
+
* `userAgentData.platform`, `navigator.platform` and the user agent string —
|
|
98
|
+
* because the question is coarse and browsers freeze or lie about each of them
|
|
99
|
+
* separately.
|
|
100
|
+
*
|
|
101
|
+
* `'windows'` on a server, and corrected on hydration through
|
|
102
|
+
* `useSyncExternalStore` — which is the one API that tells React the two renders
|
|
103
|
+
* are *meant* to differ, and is exactly the sequence a Mac reader sees.
|
|
104
|
+
*/
|
|
105
|
+
export declare function useMPPlatform(): MPResolvedOS;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import*as e from"react";import{matchesShortcut as t,useDetectedOS as n}from"../internal/keys.js";const r=/^(input|textarea|select)$/i;export function useMPShortcut(o,i,s={}){const{enabled:u=!0,preventDefault:a=!0,ignoreInputs:c=!1,target:f}=s,d=n(),l=e.useRef(i);l.current=i;const p=Array.isArray(o)?o.join("+"):o;e.useEffect(()=>{if(!u)return;const e=void 0===f?"undefined"==typeof window?null:window:f;if(!e)return;const n=e=>{const n=e;c&&function(e){return e instanceof HTMLElement&&(r.test(e.tagName)||e.isContentEditable)}(n.target)||t(n,p,d)&&(a&&n.preventDefault(),l.current(n))};return e.addEventListener("keydown",n),()=>e.removeEventListener("keydown",n)},[p,d,u,a,c,f])}export function useMPPlatform(){return n()}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { MPWindowClass } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Which of Material's five window size classes the window is in.
|
|
4
|
+
*
|
|
5
|
+
* The library has always had this axis — `MPGrid` reflows along it, `MPResponsive`
|
|
6
|
+
* is written in terms of it, `MPSidebar` collapses at it — and a consumer could
|
|
7
|
+
* name the classes in a prop without ever being able to *ask* which one they
|
|
8
|
+
* were in. So a page that wanted one more decision than a prop covers had to
|
|
9
|
+
* write the four breakpoints out again, in numbers that had to match the
|
|
10
|
+
* library's or the layout would disagree with itself at one width.
|
|
11
|
+
*
|
|
12
|
+
* ```tsx
|
|
13
|
+
* const size = useMPWindowClass();
|
|
14
|
+
*
|
|
15
|
+
* return size === 'compact' ? <MPDrawer>{nav}</MPDrawer> : <MPSidebar>{nav}</MPSidebar>;
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* ## It reads the media queries, not the width
|
|
19
|
+
*
|
|
20
|
+
* Which is what keeps it agreeing with the stylesheet. `innerWidth` counts a
|
|
21
|
+
* classic scrollbar and a media query does not, so a 615px window with a 15px
|
|
22
|
+
* scrollbar is `medium` to CSS and `compact` to arithmetic — a layout whose
|
|
23
|
+
* JavaScript and whose CSS part company at exactly one width, which is the
|
|
24
|
+
* hardest kind of bug to be shown.
|
|
25
|
+
*
|
|
26
|
+
* It also subscribes to the four boundaries rather than to `resize`. A window
|
|
27
|
+
* dragged from 500 to 1900 wakes this four times; a `resize` listener wakes
|
|
28
|
+
* several hundred, for the same four answers.
|
|
29
|
+
*
|
|
30
|
+
* ## On a server
|
|
31
|
+
*
|
|
32
|
+
* There is no window, so there is no true answer — and this returns `onServer`,
|
|
33
|
+
* which is `'expanded'` unless you say otherwise. That is a **guess**, and the
|
|
34
|
+
* argument is there because an application usually knows better than the library
|
|
35
|
+
* does: a marketing site's first paint is mostly phones and `'compact'` is the
|
|
36
|
+
* closer bet, an internal dashboard's is not.
|
|
37
|
+
*
|
|
38
|
+
* The client corrects it on hydration. `useSyncExternalStore` is what makes that
|
|
39
|
+
* correction legitimate rather than a mismatch React warns about — but the
|
|
40
|
+
* correction is a second render, so a component that swaps a whole navigation
|
|
41
|
+
* pattern on this will do so visibly on a first load. Where that matters, the
|
|
42
|
+
* CSS answer is the one that has no first render to be wrong: `MPGrid`'s
|
|
43
|
+
* responsive props and Tailwind's own variants are resolved by the browser
|
|
44
|
+
* before anything paints.
|
|
45
|
+
*
|
|
46
|
+
* @param onServer what to answer where there is no window. @default 'expanded'
|
|
47
|
+
*/
|
|
48
|
+
export declare function useMPWindowClass(onServer?: MPWindowClass): MPWindowClass;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useWindowClass as n}from"../internal/window-class.js";export function useMPWindowClass(e="expanded"){return n(e)}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './types.js';
|
|
2
2
|
export { registerMPMessages, type MPLocale, type MPMessages, type MPPartialMessages } from './internal/i18n.js';
|
|
3
3
|
export * from './constants/icons.js';
|
|
4
|
+
export * from './hooks/index.js';
|
|
4
5
|
export * from './components/accordion/index.js';
|
|
5
6
|
export * from './components/alert/index.js';
|
|
6
7
|
export * from './components/animate-appear/index.js';
|
|
@@ -24,12 +25,15 @@ export * from './components/box/index.js';
|
|
|
24
25
|
export * from './components/breadcrumb/index.js';
|
|
25
26
|
export * from './components/button/index.js';
|
|
26
27
|
export * from './components/button-group/index.js';
|
|
28
|
+
export * from './components/calendar/index.js';
|
|
27
29
|
export * from './components/card/index.js';
|
|
28
30
|
export * from './components/carousel/index.js';
|
|
29
31
|
export * from './components/chat-bubble/index.js';
|
|
30
32
|
export * from './components/checkbox/index.js';
|
|
31
33
|
export * from './components/chip/index.js';
|
|
32
34
|
export * from './components/collapsible/index.js';
|
|
35
|
+
export * from './components/config/index.js';
|
|
36
|
+
export * from './components/confirm/index.js';
|
|
33
37
|
export * from './components/color-picker/index.js';
|
|
34
38
|
export * from './components/combobox/index.js';
|
|
35
39
|
export * from './components/command-palette/index.js';
|
|
@@ -51,6 +55,7 @@ export * from './components/header/index.js';
|
|
|
51
55
|
export * from './components/highlight/index.js';
|
|
52
56
|
export * from './components/icon/index.js';
|
|
53
57
|
export * from './components/icon-button/index.js';
|
|
58
|
+
export * from './components/image/index.js';
|
|
54
59
|
export * from './components/list/index.js';
|
|
55
60
|
export * from './components/locale/index.js';
|
|
56
61
|
export * from './components/menu/index.js';
|
|
@@ -63,6 +68,7 @@ export * from './components/page-layout/index.js';
|
|
|
63
68
|
export * from './components/pagination/index.js';
|
|
64
69
|
export * from './components/panes/index.js';
|
|
65
70
|
export * from './components/pill/index.js';
|
|
71
|
+
export * from './components/popconfirm/index.js';
|
|
66
72
|
export * from './components/popover/index.js';
|
|
67
73
|
export * from './components/progress-box/index.js';
|
|
68
74
|
export * from './components/progress-circular/index.js';
|
|
@@ -77,6 +83,7 @@ export * from './components/skeleton/index.js';
|
|
|
77
83
|
export * from './components/slider/index.js';
|
|
78
84
|
export * from './components/snackbar/index.js';
|
|
79
85
|
export * from './components/spoiler/index.js';
|
|
86
|
+
export * from './components/stepper/index.js';
|
|
80
87
|
export * from './components/switch/index.js';
|
|
81
88
|
export * from './components/table/index.js';
|
|
82
89
|
export * from './components/tabs/index.js';
|
|
@@ -89,3 +96,4 @@ export * from './components/toggle-group/index.js';
|
|
|
89
96
|
export * from './components/tooltip/index.js';
|
|
90
97
|
export * from './components/transfer/index.js';
|
|
91
98
|
export * from './components/typography/index.js';
|
|
99
|
+
export * from './components/visually-hidden/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./types.js";export{registerMPMessages}from"./internal/i18n.js";export*from"./constants/icons.js";export*from"./components/accordion/index.js";export*from"./components/alert/index.js";export*from"./components/animate-appear/index.js";export*from"./components/animate-blink/index.js";export*from"./components/animate-fade/index.js";export*from"./components/animate-grow/index.js";export*from"./components/animate-headline/index.js";export*from"./components/animate-lighting/index.js";export*from"./components/animate-marquee/index.js";export*from"./components/animate-rotate/index.js";export*from"./components/animate-slide/index.js";export*from"./components/animate-typing/index.js";export*from"./components/animate-zoom/index.js";export*from"./components/aspect-ratio/index.js";export*from"./components/avatar/index.js";export*from"./components/avatar-group/index.js";export*from"./components/badge/index.js";export*from"./components/blockquote/index.js";export*from"./components/bottom-navigation/index.js";export*from"./components/box/index.js";export*from"./components/breadcrumb/index.js";export*from"./components/button/index.js";export*from"./components/button-group/index.js";export*from"./components/card/index.js";export*from"./components/carousel/index.js";export*from"./components/chat-bubble/index.js";export*from"./components/checkbox/index.js";export*from"./components/chip/index.js";export*from"./components/collapsible/index.js";export*from"./components/color-picker/index.js";export*from"./components/combobox/index.js";export*from"./components/command-palette/index.js";export*from"./components/container/index.js";export*from"./components/date-picker/index.js";export*from"./components/date-range-picker/index.js";export*from"./components/date-time-picker/index.js";export*from"./components/dialog/index.js";export*from"./components/divider/index.js";export*from"./components/drawer/index.js";export*from"./components/empty/index.js";export*from"./components/fieldset/index.js";export*from"./components/file-picker/index.js";export*from"./components/floating-action-button/index.js";export*from"./components/footer/index.js";export*from"./components/form/index.js";export*from"./components/grid/index.js";export*from"./components/header/index.js";export*from"./components/highlight/index.js";export*from"./components/icon/index.js";export*from"./components/icon-button/index.js";export*from"./components/list/index.js";export*from"./components/locale/index.js";export*from"./components/menu/index.js";export*from"./components/menubar/index.js";export*from"./components/navigation-menu/index.js";export*from"./components/number-field/index.js";export*from"./components/otp-field/index.js";export*from"./components/overlay/index.js";export*from"./components/page-layout/index.js";export*from"./components/pagination/index.js";export*from"./components/panes/index.js";export*from"./components/pill/index.js";export*from"./components/popover/index.js";export*from"./components/progress-box/index.js";export*from"./components/progress-circular/index.js";export*from"./components/progress-linear/index.js";export*from"./components/radio-group/index.js";export*from"./components/rating/index.js";export*from"./components/segmented-button/index.js";export*from"./components/select/index.js";export*from"./components/shortcut/index.js";export*from"./components/sidebar/index.js";export*from"./components/skeleton/index.js";export*from"./components/slider/index.js";export*from"./components/snackbar/index.js";export*from"./components/spoiler/index.js";export*from"./components/switch/index.js";export*from"./components/table/index.js";export*from"./components/tabs/index.js";export*from"./components/text-field/index.js";export*from"./components/text-link/index.js";export*from"./components/time-picker/index.js";export*from"./components/timeline/index.js";export*from"./components/toggle/index.js";export*from"./components/toggle-group/index.js";export*from"./components/tooltip/index.js";export*from"./components/transfer/index.js";export*from"./components/typography/index.js";
|
|
1
|
+
export*from"./types.js";export{registerMPMessages}from"./internal/i18n.js";export*from"./constants/icons.js";export*from"./hooks/index.js";export*from"./components/accordion/index.js";export*from"./components/alert/index.js";export*from"./components/animate-appear/index.js";export*from"./components/animate-blink/index.js";export*from"./components/animate-fade/index.js";export*from"./components/animate-grow/index.js";export*from"./components/animate-headline/index.js";export*from"./components/animate-lighting/index.js";export*from"./components/animate-marquee/index.js";export*from"./components/animate-rotate/index.js";export*from"./components/animate-slide/index.js";export*from"./components/animate-typing/index.js";export*from"./components/animate-zoom/index.js";export*from"./components/aspect-ratio/index.js";export*from"./components/avatar/index.js";export*from"./components/avatar-group/index.js";export*from"./components/badge/index.js";export*from"./components/blockquote/index.js";export*from"./components/bottom-navigation/index.js";export*from"./components/box/index.js";export*from"./components/breadcrumb/index.js";export*from"./components/button/index.js";export*from"./components/button-group/index.js";export*from"./components/calendar/index.js";export*from"./components/card/index.js";export*from"./components/carousel/index.js";export*from"./components/chat-bubble/index.js";export*from"./components/checkbox/index.js";export*from"./components/chip/index.js";export*from"./components/collapsible/index.js";export*from"./components/config/index.js";export*from"./components/confirm/index.js";export*from"./components/color-picker/index.js";export*from"./components/combobox/index.js";export*from"./components/command-palette/index.js";export*from"./components/container/index.js";export*from"./components/date-picker/index.js";export*from"./components/date-range-picker/index.js";export*from"./components/date-time-picker/index.js";export*from"./components/dialog/index.js";export*from"./components/divider/index.js";export*from"./components/drawer/index.js";export*from"./components/empty/index.js";export*from"./components/fieldset/index.js";export*from"./components/file-picker/index.js";export*from"./components/floating-action-button/index.js";export*from"./components/footer/index.js";export*from"./components/form/index.js";export*from"./components/grid/index.js";export*from"./components/header/index.js";export*from"./components/highlight/index.js";export*from"./components/icon/index.js";export*from"./components/icon-button/index.js";export*from"./components/image/index.js";export*from"./components/list/index.js";export*from"./components/locale/index.js";export*from"./components/menu/index.js";export*from"./components/menubar/index.js";export*from"./components/navigation-menu/index.js";export*from"./components/number-field/index.js";export*from"./components/otp-field/index.js";export*from"./components/overlay/index.js";export*from"./components/page-layout/index.js";export*from"./components/pagination/index.js";export*from"./components/panes/index.js";export*from"./components/pill/index.js";export*from"./components/popconfirm/index.js";export*from"./components/popover/index.js";export*from"./components/progress-box/index.js";export*from"./components/progress-circular/index.js";export*from"./components/progress-linear/index.js";export*from"./components/radio-group/index.js";export*from"./components/rating/index.js";export*from"./components/segmented-button/index.js";export*from"./components/select/index.js";export*from"./components/shortcut/index.js";export*from"./components/sidebar/index.js";export*from"./components/skeleton/index.js";export*from"./components/slider/index.js";export*from"./components/snackbar/index.js";export*from"./components/spoiler/index.js";export*from"./components/stepper/index.js";export*from"./components/switch/index.js";export*from"./components/table/index.js";export*from"./components/tabs/index.js";export*from"./components/text-field/index.js";export*from"./components/text-link/index.js";export*from"./components/time-picker/index.js";export*from"./components/timeline/index.js";export*from"./components/toggle/index.js";export*from"./components/toggle-group/index.js";export*from"./components/tooltip/index.js";export*from"./components/transfer/index.js";export*from"./components/typography/index.js";export*from"./components/visually-hidden/index.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { type MPTimeUnit } from './date.js';
|
|
2
|
+
import { type MPCalendarView, type MPTimeUnit } from './date.js';
|
|
3
3
|
import type { MPMessages } from './i18n.js';
|
|
4
4
|
import type { MPColor, MPSize, MPWeekday } from '../types.js';
|
|
5
5
|
/**
|
|
@@ -10,7 +10,15 @@ import type { MPColor, MPSize, MPWeekday } from '../types.js';
|
|
|
10
10
|
* calendars, so three components need this and none of them should have to
|
|
11
11
|
* import another. The two things it reaches *up* for are `MPButton` and
|
|
12
12
|
* `MPIconButton` — the header's steppers are buttons, they are not a new kind of
|
|
13
|
-
* control.
|
|
13
|
+
* control.
|
|
14
|
+
*
|
|
15
|
+
* Nothing here is exported from `src/index.ts` under its own name. `Calendar` is
|
|
16
|
+
* reachable from outside through `MPCalendar`, which is a wrapper rather than a
|
|
17
|
+
* re-export: everything below is fully controlled and takes its `labels` already
|
|
18
|
+
* resolved, because four callers had already decided those things. A consumer
|
|
19
|
+
* has not, so the public component is where the state and the translation are
|
|
20
|
+
* put back. That is also why the name went the other way round — the `MP` prefix
|
|
21
|
+
* belongs to what a consumer can import.
|
|
14
22
|
*
|
|
15
23
|
* The day cells are deliberately *not* buttons in that sense. A cell has states
|
|
16
24
|
* a button has no vocabulary for — inside a range, at the end of a range, today,
|
|
@@ -19,7 +27,7 @@ import type { MPColor, MPSize, MPWeekday } from '../types.js';
|
|
|
19
27
|
*/
|
|
20
28
|
/** The strings a picker says that `Intl` has no opinion about. */
|
|
21
29
|
export type MPPickerLabels = MPMessages['picker'];
|
|
22
|
-
export interface
|
|
30
|
+
export interface CalendarProps {
|
|
23
31
|
size: MPSize;
|
|
24
32
|
color: MPColor;
|
|
25
33
|
locale?: string;
|
|
@@ -54,6 +62,13 @@ export interface MPCalendarProps {
|
|
|
54
62
|
autoFocus?: boolean;
|
|
55
63
|
showPreviousButton?: boolean;
|
|
56
64
|
showNextButton?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* The finest view the calendar offers, and therefore what a press answers
|
|
67
|
+
* with. `'month'` never draws a day grid and `'year'` never draws either of
|
|
68
|
+
* the other two.
|
|
69
|
+
* @default 'day'
|
|
70
|
+
*/
|
|
71
|
+
precision?: MPCalendarView;
|
|
57
72
|
labels: MPPickerLabels;
|
|
58
73
|
}
|
|
59
74
|
/**
|
|
@@ -71,7 +86,7 @@ export interface MPCalendarProps {
|
|
|
71
86
|
* grid instead of walking forty-two cells — the pattern the ARIA date-picker
|
|
72
87
|
* practice describes, and the reason none of the cells is a `disabled` button.
|
|
73
88
|
*/
|
|
74
|
-
export declare function
|
|
89
|
+
export declare function Calendar({ size, color, locale, weekStartsOn, month, onMonthChange, selected, rangeStart, rangeEnd, onSelect, onPreviewChange, minDate, maxDate, shouldDisableDate, showOutsideDays, autoFocus, showPreviousButton, showNextButton, precision, labels }: CalendarProps): React.JSX.Element;
|
|
75
90
|
export interface MPTimeGridProps {
|
|
76
91
|
size: MPSize;
|
|
77
92
|
locale?: string;
|