material-plus-ui 0.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -28
- package/dist/components/accordion/MPAccordion.d.ts +115 -0
- package/dist/components/accordion/MPAccordion.js +1 -0
- package/dist/components/accordion/index.d.ts +2 -0
- package/dist/components/accordion/index.js +1 -0
- package/dist/components/alert/MPAlert.d.ts +91 -0
- package/dist/components/alert/MPAlert.js +1 -0
- package/dist/components/alert/index.d.ts +2 -0
- package/dist/components/alert/index.js +1 -0
- package/dist/components/animate-appear/MPAnimateAppear.d.ts +56 -0
- package/dist/components/animate-appear/MPAnimateAppear.js +1 -0
- package/dist/components/animate-appear/index.d.ts +2 -0
- package/dist/components/animate-appear/index.js +1 -0
- package/dist/components/animate-blink/MPAnimateBlink.d.ts +41 -0
- package/dist/components/animate-blink/MPAnimateBlink.js +1 -0
- package/dist/components/animate-blink/index.d.ts +2 -0
- package/dist/components/animate-blink/index.js +1 -0
- package/dist/components/animate-fade/MPAnimateFade.d.ts +38 -0
- package/dist/components/animate-fade/MPAnimateFade.js +1 -0
- package/dist/components/animate-fade/index.d.ts +2 -0
- package/dist/components/animate-fade/index.js +1 -0
- package/dist/components/animate-grow/MPAnimateGrow.d.ts +52 -0
- package/dist/components/animate-grow/MPAnimateGrow.js +1 -0
- package/dist/components/animate-grow/index.d.ts +2 -0
- package/dist/components/animate-grow/index.js +1 -0
- package/dist/components/animate-headline/MPAnimateHeadline.d.ts +63 -0
- package/dist/components/animate-headline/MPAnimateHeadline.js +1 -0
- package/dist/components/animate-headline/index.d.ts +2 -0
- package/dist/components/animate-headline/index.js +1 -0
- package/dist/components/animate-lighting/MPAnimateLighting.d.ts +68 -0
- package/dist/components/animate-lighting/MPAnimateLighting.js +1 -0
- package/dist/components/animate-lighting/index.d.ts +2 -0
- package/dist/components/animate-lighting/index.js +1 -0
- package/dist/components/animate-marquee/MPAnimateMarquee.d.ts +66 -0
- package/dist/components/animate-marquee/MPAnimateMarquee.js +1 -0
- package/dist/components/animate-marquee/index.d.ts +2 -0
- package/dist/components/animate-marquee/index.js +1 -0
- package/dist/components/animate-rotate/MPAnimateRotate.d.ts +56 -0
- package/dist/components/animate-rotate/MPAnimateRotate.js +1 -0
- package/dist/components/animate-rotate/index.d.ts +2 -0
- package/dist/components/animate-rotate/index.js +1 -0
- package/dist/components/animate-slide/MPAnimateSlide.d.ts +53 -0
- package/dist/components/animate-slide/MPAnimateSlide.js +1 -0
- package/dist/components/animate-slide/index.d.ts +2 -0
- package/dist/components/animate-slide/index.js +1 -0
- package/dist/components/animate-typing/MPAnimateTyping.d.ts +59 -0
- package/dist/components/animate-typing/MPAnimateTyping.js +1 -0
- package/dist/components/animate-typing/index.d.ts +2 -0
- package/dist/components/animate-typing/index.js +1 -0
- package/dist/components/animate-zoom/MPAnimateZoom.d.ts +44 -0
- package/dist/components/animate-zoom/MPAnimateZoom.js +1 -0
- package/dist/components/animate-zoom/index.d.ts +2 -0
- package/dist/components/animate-zoom/index.js +1 -0
- package/dist/components/aspect-ratio/MPAspectRatio.d.ts +69 -0
- package/dist/components/aspect-ratio/MPAspectRatio.js +1 -0
- package/dist/components/aspect-ratio/index.d.ts +2 -0
- package/dist/components/aspect-ratio/index.js +1 -0
- package/dist/components/avatar/MPAvatar.d.ts +104 -0
- package/dist/components/avatar/MPAvatar.js +1 -0
- package/dist/components/avatar/index.d.ts +2 -0
- package/dist/components/avatar/index.js +1 -0
- package/dist/components/badge/MPBadge.d.ts +104 -0
- package/dist/components/badge/MPBadge.js +1 -0
- package/dist/components/badge/index.d.ts +2 -0
- package/dist/components/badge/index.js +1 -0
- package/dist/components/blockquote/MPBlockquote.d.ts +73 -0
- package/dist/components/blockquote/MPBlockquote.js +1 -0
- package/dist/components/blockquote/index.d.ts +2 -0
- package/dist/components/blockquote/index.js +1 -0
- package/dist/components/bottom-navigation/MPBottomNavigation.d.ts +144 -0
- package/dist/components/bottom-navigation/MPBottomNavigation.js +1 -0
- package/dist/components/bottom-navigation/index.d.ts +2 -0
- package/dist/components/bottom-navigation/index.js +1 -0
- package/dist/components/box/MPBox.d.ts +78 -0
- package/dist/components/box/MPBox.js +1 -0
- package/dist/components/box/index.d.ts +2 -0
- package/dist/components/box/index.js +1 -0
- package/dist/components/breadcrumb/MPBreadcrumb.d.ts +127 -0
- package/dist/components/breadcrumb/MPBreadcrumb.js +1 -0
- package/dist/components/breadcrumb/index.d.ts +2 -0
- package/dist/components/breadcrumb/index.js +1 -0
- package/dist/components/button/MPButton.d.ts +75 -0
- package/dist/components/button/MPButton.js +1 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/button/index.js +1 -0
- package/dist/components/button-group/MPButtonGroup.d.ts +31 -0
- package/dist/components/button-group/MPButtonGroup.js +1 -0
- package/dist/components/button-group/index.d.ts +2 -0
- package/dist/components/button-group/index.js +1 -0
- package/dist/components/card/MPCard.d.ts +73 -0
- package/dist/components/card/MPCard.js +1 -0
- package/dist/components/card/index.d.ts +2 -0
- package/dist/components/card/index.js +1 -0
- package/dist/components/carousel/MPCarousel.d.ts +116 -0
- package/dist/components/carousel/MPCarousel.js +1 -0
- package/dist/components/carousel/index.d.ts +2 -0
- package/dist/components/carousel/index.js +1 -0
- package/dist/components/chat-bubble/MPChatBubble.d.ts +132 -0
- package/dist/components/chat-bubble/MPChatBubble.js +1 -0
- package/dist/components/chat-bubble/index.d.ts +2 -0
- package/dist/components/chat-bubble/index.js +1 -0
- package/dist/components/checkbox/MPCheckbox.d.ts +76 -0
- package/dist/components/checkbox/MPCheckbox.js +1 -0
- package/dist/components/checkbox/index.d.ts +2 -0
- package/dist/components/checkbox/index.js +1 -0
- package/dist/components/chip/MPChip.d.ts +74 -0
- package/dist/components/chip/MPChip.js +1 -0
- package/dist/components/chip/index.d.ts +2 -0
- package/dist/components/chip/index.js +1 -0
- package/dist/components/collapsible/MPCollapsible.d.ts +97 -0
- package/dist/components/collapsible/MPCollapsible.js +1 -0
- package/dist/components/collapsible/index.d.ts +2 -0
- package/dist/components/collapsible/index.js +1 -0
- package/dist/components/color-picker/MPColorPicker.d.ts +131 -0
- package/dist/components/color-picker/MPColorPicker.js +1 -0
- package/dist/components/color-picker/index.d.ts +2 -0
- package/dist/components/color-picker/index.js +1 -0
- package/dist/components/combobox/MPCombobox.d.ts +175 -0
- package/dist/components/combobox/MPCombobox.js +1 -0
- package/dist/components/combobox/index.d.ts +2 -0
- package/dist/components/combobox/index.js +1 -0
- package/dist/components/container/MPContainer.d.ts +75 -0
- package/dist/components/container/MPContainer.js +1 -0
- package/dist/components/container/index.d.ts +2 -0
- package/dist/components/container/index.js +1 -0
- package/dist/components/date-picker/MPDatePicker.d.ts +98 -0
- package/dist/components/date-picker/MPDatePicker.js +1 -0
- package/dist/components/date-picker/index.d.ts +2 -0
- package/dist/components/date-picker/index.js +1 -0
- package/dist/components/date-range-picker/MPDateRangePicker.d.ts +98 -0
- package/dist/components/date-range-picker/MPDateRangePicker.js +1 -0
- package/dist/components/date-range-picker/index.d.ts +2 -0
- package/dist/components/date-range-picker/index.js +1 -0
- package/dist/components/date-time-picker/MPDateTimePicker.d.ts +78 -0
- package/dist/components/date-time-picker/MPDateTimePicker.js +1 -0
- package/dist/components/date-time-picker/index.d.ts +2 -0
- package/dist/components/date-time-picker/index.js +1 -0
- package/dist/components/dialog/MPDialog.d.ts +150 -0
- package/dist/components/dialog/MPDialog.js +1 -0
- package/dist/components/dialog/index.d.ts +2 -0
- package/dist/components/dialog/index.js +1 -0
- package/dist/components/divider/MPDivider.d.ts +80 -0
- package/dist/components/divider/MPDivider.js +1 -0
- package/dist/components/divider/index.d.ts +2 -0
- package/dist/components/divider/index.js +1 -0
- package/dist/components/drawer/MPDrawer.d.ts +168 -0
- package/dist/components/drawer/MPDrawer.js +1 -0
- package/dist/components/drawer/index.d.ts +2 -0
- package/dist/components/drawer/index.js +1 -0
- package/dist/components/empty/MPEmpty.d.ts +74 -0
- package/dist/components/empty/MPEmpty.js +1 -0
- package/dist/components/empty/index.d.ts +2 -0
- package/dist/components/empty/index.js +1 -0
- package/dist/components/file-picker/MPFilePicker.d.ts +113 -0
- package/dist/components/file-picker/MPFilePicker.js +1 -0
- package/dist/components/file-picker/index.d.ts +2 -0
- package/dist/components/file-picker/index.js +1 -0
- package/dist/components/floating-action-button/MPFloatingActionButton.d.ts +126 -0
- package/dist/components/floating-action-button/MPFloatingActionButton.js +1 -0
- package/dist/components/floating-action-button/index.d.ts +2 -0
- package/dist/components/floating-action-button/index.js +1 -0
- package/dist/components/grid/MPGrid.d.ts +155 -0
- package/dist/components/grid/MPGrid.js +1 -0
- package/dist/components/grid/index.d.ts +2 -0
- package/dist/components/grid/index.js +1 -0
- package/dist/components/highlight/MPHighlight.d.ts +95 -0
- package/dist/components/highlight/MPHighlight.js +1 -0
- package/dist/components/highlight/index.d.ts +2 -0
- package/dist/components/highlight/index.js +1 -0
- package/dist/components/icon-button/MPIconButton.d.ts +59 -0
- package/dist/components/icon-button/MPIconButton.js +1 -0
- package/dist/components/icon-button/index.d.ts +2 -0
- package/dist/components/icon-button/index.js +1 -0
- package/dist/components/list/MPList.d.ts +96 -0
- package/dist/components/list/MPList.js +1 -0
- package/dist/components/list/index.d.ts +2 -0
- package/dist/components/list/index.js +1 -0
- package/dist/components/locale/MPLocaleProvider.d.ts +63 -0
- package/dist/components/locale/MPLocaleProvider.js +1 -0
- package/dist/components/locale/index.d.ts +2 -0
- package/dist/components/locale/index.js +1 -0
- package/dist/components/menu/MPMenu.d.ts +232 -0
- package/dist/components/menu/MPMenu.js +1 -0
- package/dist/components/menu/index.d.ts +2 -0
- package/dist/components/menu/index.js +1 -0
- package/dist/components/number-field/MPNumberField.d.ts +117 -0
- package/dist/components/number-field/MPNumberField.js +1 -0
- package/dist/components/number-field/index.d.ts +2 -0
- package/dist/components/number-field/index.js +1 -0
- package/dist/components/otp-field/MPOtpField.d.ts +89 -0
- package/dist/components/otp-field/MPOtpField.js +1 -0
- package/dist/components/otp-field/index.d.ts +2 -0
- package/dist/components/otp-field/index.js +1 -0
- package/dist/components/overlay/MPOverlay.d.ts +96 -0
- package/dist/components/overlay/MPOverlay.js +1 -0
- package/dist/components/overlay/index.d.ts +2 -0
- package/dist/components/overlay/index.js +1 -0
- package/dist/components/pagination/MPPagination.d.ts +106 -0
- package/dist/components/pagination/MPPagination.js +1 -0
- package/dist/components/pagination/index.d.ts +2 -0
- package/dist/components/pagination/index.js +1 -0
- package/dist/components/panes/MPPanes.d.ts +100 -0
- package/dist/components/panes/MPPanes.js +1 -0
- package/dist/components/panes/index.d.ts +2 -0
- package/dist/components/panes/index.js +1 -0
- package/dist/components/pill/MPPill.d.ts +117 -0
- package/dist/components/pill/MPPill.js +1 -0
- package/dist/components/pill/index.d.ts +2 -0
- package/dist/components/pill/index.js +1 -0
- package/dist/components/popover/MPPopover.d.ts +143 -0
- package/dist/components/popover/MPPopover.js +1 -0
- package/dist/components/popover/index.d.ts +2 -0
- package/dist/components/popover/index.js +1 -0
- package/dist/components/progress-box/MPProgressBox.d.ts +40 -0
- package/dist/components/progress-box/MPProgressBox.js +1 -0
- package/dist/components/progress-box/index.d.ts +2 -0
- package/dist/components/progress-box/index.js +1 -0
- package/dist/components/progress-circular/MPProgressCircular.d.ts +32 -0
- package/dist/components/progress-circular/MPProgressCircular.js +1 -0
- package/dist/components/progress-circular/index.d.ts +2 -0
- package/dist/components/progress-circular/index.js +1 -0
- package/dist/components/progress-linear/MPProgressLinear.d.ts +32 -0
- package/dist/components/progress-linear/MPProgressLinear.js +1 -0
- package/dist/components/progress-linear/index.d.ts +2 -0
- package/dist/components/progress-linear/index.js +1 -0
- package/dist/components/radio-group/MPRadioGroup.d.ts +81 -0
- package/dist/components/radio-group/MPRadioGroup.js +1 -0
- package/dist/components/radio-group/index.d.ts +2 -0
- package/dist/components/radio-group/index.js +1 -0
- package/dist/components/rating/MPRating.d.ts +135 -0
- package/dist/components/rating/MPRating.js +1 -0
- package/dist/components/rating/index.d.ts +2 -0
- package/dist/components/rating/index.js +1 -0
- package/dist/components/segmented-button/MPSegmentedButton.d.ts +75 -0
- package/dist/components/segmented-button/MPSegmentedButton.js +1 -0
- package/dist/components/segmented-button/index.d.ts +2 -0
- package/dist/components/segmented-button/index.js +1 -0
- package/dist/components/select/MPSelect.d.ts +103 -0
- package/dist/components/select/MPSelect.js +1 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/index.js +1 -0
- package/dist/components/shortcut/MPShortcut.d.ts +67 -0
- package/dist/components/shortcut/MPShortcut.js +1 -0
- package/dist/components/shortcut/index.d.ts +2 -0
- package/dist/components/shortcut/index.js +1 -0
- package/dist/components/skeleton/MPSkeleton.d.ts +76 -0
- package/dist/components/skeleton/MPSkeleton.js +1 -0
- package/dist/components/skeleton/index.d.ts +2 -0
- package/dist/components/skeleton/index.js +1 -0
- package/dist/components/slider/MPSlider.d.ts +77 -0
- package/dist/components/slider/MPSlider.js +1 -0
- package/dist/components/slider/index.d.ts +2 -0
- package/dist/components/slider/index.js +1 -0
- package/dist/components/snackbar/MPSnackbar.d.ts +175 -0
- package/dist/components/snackbar/MPSnackbar.js +1 -0
- package/dist/components/snackbar/index.d.ts +2 -0
- package/dist/components/snackbar/index.js +1 -0
- package/dist/components/spoiler/MPSpoiler.d.ts +106 -0
- package/dist/components/spoiler/MPSpoiler.js +1 -0
- package/dist/components/spoiler/index.d.ts +2 -0
- package/dist/components/spoiler/index.js +1 -0
- package/dist/components/switch/MPSwitch.d.ts +75 -0
- package/dist/components/switch/MPSwitch.js +1 -0
- package/dist/components/switch/index.d.ts +2 -0
- package/dist/components/switch/index.js +1 -0
- package/dist/components/table/MPTable.d.ts +120 -0
- package/dist/components/table/MPTable.js +1 -0
- package/dist/components/table/index.d.ts +2 -0
- package/dist/components/table/index.js +1 -0
- package/dist/components/tabs/MPTabs.d.ts +145 -0
- package/dist/components/tabs/MPTabs.js +1 -0
- package/dist/components/tabs/index.d.ts +2 -0
- package/dist/components/tabs/index.js +1 -0
- package/dist/components/text-field/MPTextField.d.ts +51 -22
- package/dist/components/text-field/MPTextField.js +1 -1
- package/dist/components/text-link/MPTextLink.d.ts +88 -0
- package/dist/components/text-link/MPTextLink.js +1 -0
- package/dist/components/text-link/index.d.ts +2 -0
- package/dist/components/text-link/index.js +1 -0
- package/dist/components/time-picker/MPTimePicker.d.ts +108 -0
- package/dist/components/time-picker/MPTimePicker.js +1 -0
- package/dist/components/time-picker/index.d.ts +2 -0
- package/dist/components/time-picker/index.js +1 -0
- package/dist/components/timeline/MPTimeline.d.ts +96 -0
- package/dist/components/timeline/MPTimeline.js +1 -0
- package/dist/components/timeline/index.d.ts +2 -0
- package/dist/components/timeline/index.js +1 -0
- package/dist/components/tooltip/MPTooltip.d.ts +117 -0
- package/dist/components/tooltip/MPTooltip.js +1 -0
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/components/tooltip/index.js +1 -0
- package/dist/components/typography/MPTypography.d.ts +94 -0
- package/dist/components/typography/MPTypography.js +1 -0
- package/dist/components/typography/index.d.ts +2 -0
- package/dist/components/typography/index.js +1 -0
- package/dist/constants/icons.d.ts +49 -0
- package/dist/constants/icons.js +1 -1
- package/dist/index.d.ts +73 -0
- package/dist/index.js +1 -1
- package/dist/internal/Calendar.d.ts +118 -0
- package/dist/internal/Calendar.js +1 -0
- package/dist/internal/FieldOutline.d.ts +109 -0
- package/dist/internal/FieldOutline.js +1 -0
- package/dist/internal/Picker.d.ts +153 -0
- package/dist/internal/Picker.js +1 -0
- package/dist/internal/StateLayer.d.ts +45 -0
- package/dist/internal/StateLayer.js +1 -0
- package/dist/internal/SupportingText.d.ts +23 -0
- package/dist/internal/SupportingText.js +1 -0
- package/dist/internal/WidthSizer.d.ts +31 -0
- package/dist/internal/WidthSizer.js +1 -0
- package/dist/internal/accent.d.ts +39 -0
- package/dist/internal/accent.js +1 -0
- package/dist/internal/animate.d.ts +179 -0
- package/dist/internal/animate.js +1 -0
- package/dist/internal/button-group.d.ts +21 -0
- package/dist/internal/button-group.js +1 -0
- package/dist/internal/color.d.ts +125 -0
- package/dist/internal/color.js +1 -0
- package/dist/internal/date.d.ts +179 -0
- package/dist/internal/date.js +1 -0
- package/dist/internal/i18n.d.ts +241 -0
- package/dist/internal/i18n.js +1 -0
- package/dist/internal/inert.d.ts +11 -0
- package/dist/internal/inert.js +1 -0
- package/dist/internal/locale.d.ts +43 -0
- package/dist/internal/locale.js +1 -0
- package/dist/internal/menu.d.ts +23 -0
- package/dist/internal/menu.js +1 -0
- package/dist/internal/progress.d.ts +126 -0
- package/dist/internal/progress.js +1 -0
- package/dist/internal/scale.d.ts +127 -0
- package/dist/internal/scale.js +1 -0
- package/dist/internal/surface.d.ts +76 -0
- package/dist/internal/surface.js +1 -0
- package/dist/internal/visually-hidden.d.ts +23 -0
- package/dist/internal/visually-hidden.js +1 -0
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +1871 -20
- package/dist/types.d.ts +262 -16
- package/package.json +16 -21
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,77 @@
|
|
|
1
1
|
export * from './types';
|
|
2
2
|
export * from './constants/icons';
|
|
3
|
+
export * from './components/accordion';
|
|
4
|
+
export * from './components/alert';
|
|
5
|
+
export * from './components/animate-appear';
|
|
6
|
+
export * from './components/animate-blink';
|
|
7
|
+
export * from './components/animate-fade';
|
|
8
|
+
export * from './components/animate-grow';
|
|
9
|
+
export * from './components/animate-headline';
|
|
10
|
+
export * from './components/animate-lighting';
|
|
11
|
+
export * from './components/animate-marquee';
|
|
12
|
+
export * from './components/animate-rotate';
|
|
13
|
+
export * from './components/animate-slide';
|
|
14
|
+
export * from './components/animate-typing';
|
|
15
|
+
export * from './components/animate-zoom';
|
|
16
|
+
export * from './components/aspect-ratio';
|
|
17
|
+
export * from './components/avatar';
|
|
18
|
+
export * from './components/badge';
|
|
19
|
+
export * from './components/blockquote';
|
|
20
|
+
export * from './components/bottom-navigation';
|
|
21
|
+
export * from './components/box';
|
|
22
|
+
export * from './components/breadcrumb';
|
|
23
|
+
export * from './components/button';
|
|
24
|
+
export * from './components/button-group';
|
|
25
|
+
export * from './components/card';
|
|
26
|
+
export * from './components/carousel';
|
|
27
|
+
export * from './components/chat-bubble';
|
|
28
|
+
export * from './components/checkbox';
|
|
29
|
+
export * from './components/chip';
|
|
30
|
+
export * from './components/collapsible';
|
|
31
|
+
export * from './components/color-picker';
|
|
32
|
+
export * from './components/combobox';
|
|
33
|
+
export * from './components/container';
|
|
34
|
+
export * from './components/date-picker';
|
|
35
|
+
export * from './components/date-range-picker';
|
|
36
|
+
export * from './components/date-time-picker';
|
|
37
|
+
export * from './components/dialog';
|
|
38
|
+
export * from './components/divider';
|
|
39
|
+
export * from './components/drawer';
|
|
40
|
+
export * from './components/empty';
|
|
41
|
+
export * from './components/file-picker';
|
|
42
|
+
export * from './components/floating-action-button';
|
|
43
|
+
export * from './components/grid';
|
|
44
|
+
export * from './components/highlight';
|
|
3
45
|
export * from './components/icon';
|
|
46
|
+
export * from './components/icon-button';
|
|
47
|
+
export * from './components/list';
|
|
48
|
+
export * from './components/locale';
|
|
49
|
+
export * from './components/menu';
|
|
50
|
+
export * from './components/number-field';
|
|
51
|
+
export * from './components/otp-field';
|
|
52
|
+
export * from './components/overlay';
|
|
53
|
+
export * from './components/pagination';
|
|
54
|
+
export * from './components/panes';
|
|
55
|
+
export * from './components/pill';
|
|
56
|
+
export * from './components/popover';
|
|
57
|
+
export * from './components/progress-box';
|
|
58
|
+
export * from './components/progress-circular';
|
|
59
|
+
export * from './components/progress-linear';
|
|
60
|
+
export * from './components/radio-group';
|
|
61
|
+
export * from './components/rating';
|
|
62
|
+
export * from './components/segmented-button';
|
|
63
|
+
export * from './components/select';
|
|
64
|
+
export * from './components/shortcut';
|
|
65
|
+
export * from './components/skeleton';
|
|
66
|
+
export * from './components/slider';
|
|
67
|
+
export * from './components/snackbar';
|
|
68
|
+
export * from './components/spoiler';
|
|
69
|
+
export * from './components/switch';
|
|
70
|
+
export * from './components/table';
|
|
71
|
+
export * from './components/tabs';
|
|
4
72
|
export * from './components/text-field';
|
|
73
|
+
export * from './components/text-link';
|
|
74
|
+
export * from './components/time-picker';
|
|
75
|
+
export * from './components/timeline';
|
|
76
|
+
export * from './components/tooltip';
|
|
77
|
+
export * from './components/typography';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./types";export*from"./constants/icons";export*from"./components/icon";export*from"./components/text-field";
|
|
1
|
+
export*from"./types";export*from"./constants/icons";export*from"./components/accordion";export*from"./components/alert";export*from"./components/animate-appear";export*from"./components/animate-blink";export*from"./components/animate-fade";export*from"./components/animate-grow";export*from"./components/animate-headline";export*from"./components/animate-lighting";export*from"./components/animate-marquee";export*from"./components/animate-rotate";export*from"./components/animate-slide";export*from"./components/animate-typing";export*from"./components/animate-zoom";export*from"./components/aspect-ratio";export*from"./components/avatar";export*from"./components/badge";export*from"./components/blockquote";export*from"./components/bottom-navigation";export*from"./components/box";export*from"./components/breadcrumb";export*from"./components/button";export*from"./components/button-group";export*from"./components/card";export*from"./components/carousel";export*from"./components/chat-bubble";export*from"./components/checkbox";export*from"./components/chip";export*from"./components/collapsible";export*from"./components/color-picker";export*from"./components/combobox";export*from"./components/container";export*from"./components/date-picker";export*from"./components/date-range-picker";export*from"./components/date-time-picker";export*from"./components/dialog";export*from"./components/divider";export*from"./components/drawer";export*from"./components/empty";export*from"./components/file-picker";export*from"./components/floating-action-button";export*from"./components/grid";export*from"./components/highlight";export*from"./components/icon";export*from"./components/icon-button";export*from"./components/list";export*from"./components/locale";export*from"./components/menu";export*from"./components/number-field";export*from"./components/otp-field";export*from"./components/overlay";export*from"./components/pagination";export*from"./components/panes";export*from"./components/pill";export*from"./components/popover";export*from"./components/progress-box";export*from"./components/progress-circular";export*from"./components/progress-linear";export*from"./components/radio-group";export*from"./components/rating";export*from"./components/segmented-button";export*from"./components/select";export*from"./components/shortcut";export*from"./components/skeleton";export*from"./components/slider";export*from"./components/snackbar";export*from"./components/spoiler";export*from"./components/switch";export*from"./components/table";export*from"./components/tabs";export*from"./components/text-field";export*from"./components/text-link";export*from"./components/time-picker";export*from"./components/timeline";export*from"./components/tooltip";export*from"./components/typography";
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type MPTimeUnit } from './date';
|
|
3
|
+
import type { MPMessages } from './i18n';
|
|
4
|
+
import type { MPColor, MPSize, MPWeekday } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* The calendar grid and the clock columns, written once for the four pickers.
|
|
7
|
+
*
|
|
8
|
+
* They live in `internal/` for the reason `menu.ts` does: a date-time picker is a
|
|
9
|
+
* date picker and a time picker in one popup, and a range picker is two
|
|
10
|
+
* calendars, so three components need this and none of them should have to
|
|
11
|
+
* import another. The two things it reaches *up* for are `MPButton` and
|
|
12
|
+
* `MPIconButton` — the header's steppers are buttons, they are not a new kind of
|
|
13
|
+
* control. Nothing here is exported from `src/index.ts`.
|
|
14
|
+
*
|
|
15
|
+
* The day cells are deliberately *not* buttons in that sense. A cell has states
|
|
16
|
+
* a button has no vocabulary for — inside a range, at the end of a range, today,
|
|
17
|
+
* belonging to the month next door — and four of them have to be told apart at a
|
|
18
|
+
* glance in a grid of forty-two.
|
|
19
|
+
*/
|
|
20
|
+
/** The strings a picker says that `Intl` has no opinion about. */
|
|
21
|
+
export type MPPickerLabels = MPMessages['picker'];
|
|
22
|
+
export interface MPCalendarProps {
|
|
23
|
+
size: MPSize;
|
|
24
|
+
color: MPColor;
|
|
25
|
+
locale?: string;
|
|
26
|
+
weekStartsOn: MPWeekday;
|
|
27
|
+
/** The month on screen. Controlled, so two panels can be kept a month apart. */
|
|
28
|
+
month: Date;
|
|
29
|
+
onMonthChange: (month: Date) => void;
|
|
30
|
+
/** The days drawn filled — one for a single picker, up to two for a range. */
|
|
31
|
+
selected: readonly (Date | null | undefined)[];
|
|
32
|
+
/** The two ends the band is drawn between. Both `null` outside range mode. */
|
|
33
|
+
rangeStart?: Date | null;
|
|
34
|
+
rangeEnd?: Date | null;
|
|
35
|
+
onSelect: (date: Date) => void;
|
|
36
|
+
/** The day under the pointer, for a range that is only half chosen. */
|
|
37
|
+
onPreviewChange?: (date: Date | null) => void;
|
|
38
|
+
minDate?: Date | null;
|
|
39
|
+
maxDate?: Date | null;
|
|
40
|
+
shouldDisableDate?: (date: Date) => boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Draws the leading and trailing days that belong to the neighbouring months.
|
|
43
|
+
*
|
|
44
|
+
* On by default, because clicking the 1st of next month from this month's
|
|
45
|
+
* panel is a real shortcut. A two-month range picker turns it *off*, and not
|
|
46
|
+
* as a matter of taste: with both panels showing six full weeks, the 1st of
|
|
47
|
+
* August appears twice — once as a trailing day of July and once as itself —
|
|
48
|
+
* and two cells with the same name in one popup is ambiguous to a pointer and
|
|
49
|
+
* outright broken to a screen reader.
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
52
|
+
showOutsideDays?: boolean;
|
|
53
|
+
/** Takes the focus on mount — the popup has just opened. */
|
|
54
|
+
autoFocus?: boolean;
|
|
55
|
+
showPreviousButton?: boolean;
|
|
56
|
+
showNextButton?: boolean;
|
|
57
|
+
labels: MPPickerLabels;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* One month, with a way to reach every other one.
|
|
61
|
+
*
|
|
62
|
+
* Three views on the same footprint: the days of a month, the twelve months of a
|
|
63
|
+
* year, twelve years at a time. They are deliberately the same width *and* the
|
|
64
|
+
* same height — the day view is seven rows counting its header, and the other
|
|
65
|
+
* two stretch four rows and three rows across that same height — so switching
|
|
66
|
+
* view never resizes the popup under the pointer that opened it.
|
|
67
|
+
*
|
|
68
|
+
* Arrow keys move by one cell, `PageUp`/`PageDown` by a month (a year with
|
|
69
|
+
* Shift), `Home`/`End` to the ends of the week, and running off an edge steps
|
|
70
|
+
* the calendar rather than stopping. One roving tab stop, so `Tab` leaves the
|
|
71
|
+
* grid instead of walking forty-two cells — the pattern the ARIA date-picker
|
|
72
|
+
* practice describes, and the reason none of the cells is a `disabled` button.
|
|
73
|
+
*/
|
|
74
|
+
export declare function MPCalendar({ size, color, locale, weekStartsOn, month, onMonthChange, selected, rangeStart, rangeEnd, onSelect, onPreviewChange, minDate, maxDate, shouldDisableDate, showOutsideDays, autoFocus, showPreviousButton, showNextButton, labels }: MPCalendarProps): React.JSX.Element;
|
|
75
|
+
export interface MPTimeGridProps {
|
|
76
|
+
size: MPSize;
|
|
77
|
+
locale?: string;
|
|
78
|
+
/** The time on screen, or `null` while nothing has been chosen. */
|
|
79
|
+
value: Date | null;
|
|
80
|
+
/** The day the columns write into while `value` is still `null`. */
|
|
81
|
+
referenceDate: Date;
|
|
82
|
+
onChange: (value: Date) => void;
|
|
83
|
+
/** A 12-hour dial with an AM/PM column. */
|
|
84
|
+
hour12: boolean;
|
|
85
|
+
showSeconds: boolean;
|
|
86
|
+
hourStep: number;
|
|
87
|
+
minuteStep: number;
|
|
88
|
+
secondStep: number;
|
|
89
|
+
shouldDisableTime?: (value: Date, unit: MPTimeUnit) => boolean;
|
|
90
|
+
/** Takes the focus on mount — the popup has just opened. */
|
|
91
|
+
autoFocus?: boolean;
|
|
92
|
+
labels: MPPickerLabels;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Hours, minutes and — when asked for — seconds, as columns you scroll.
|
|
96
|
+
*
|
|
97
|
+
* ## Why this is not MD3's dial
|
|
98
|
+
*
|
|
99
|
+
* The specification's time picker is a clock face, and this is not one. That is
|
|
100
|
+
* a deliberate departure, and the only one of its size in this library, so it is
|
|
101
|
+
* worth stating the reason plainly: a dial is a *pointer* control. Reading it
|
|
102
|
+
* takes a glance at an analogue clock, setting it takes a drag, and the
|
|
103
|
+
* keyboard and screen-reader path is a separate "time input" mode that MD3
|
|
104
|
+
* ships precisely because the dial cannot serve one. That leaves a component
|
|
105
|
+
* with two implementations of the same question, of which the accessible one is
|
|
106
|
+
* the one nobody sees.
|
|
107
|
+
*
|
|
108
|
+
* Columns answer both readers with one control. "Half past nine" is two glances,
|
|
109
|
+
* "any time at all, on the hour" is a column you never touch, and every row is a
|
|
110
|
+
* real option in a real listbox that arrow keys already reach. The library's own
|
|
111
|
+
* ladder, corners and state layers do the rest of the work of looking like
|
|
112
|
+
* Material.
|
|
113
|
+
*
|
|
114
|
+
* The chosen row in each column is scrolled into view once, on open. That is the
|
|
115
|
+
* only imperative work here and it is not optional: a column of sixty minutes
|
|
116
|
+
* that opens at `00` while the value is `45` has hidden its own answer.
|
|
117
|
+
*/
|
|
118
|
+
export declare function MPTimeGrid({ size, locale, value, referenceDate, onChange, hour12, showSeconds, hourStep, minuteStep, secondStep, shouldDisableTime, autoFocus, labels }: MPTimeGridProps): React.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as o,Fragment as t}from"react/jsx-runtime";import*as n from"react";import{MPButton as r}from"../components/button/MPButton";import{MPIcon as l}from"../components/icon/MPIcon";import{MPIconButton as a}from"../components/icon-button/MPIconButton";import{ChevronDownIcon as s,ChevronLeftIcon as c,ChevronRightIcon as i}from"../constants/icons";import{MPStateLayer as u}from"./StateLayer";import{CONTROL_ICON as m,META_TEXT as d,PROSE_TEXT as h}from"./scale";import{VISUALLY_HIDDEN as p}from"./visually-hidden";import{addDays as f,addMonths as g,addYears as v,calendarWeeks as w,compareDay as x,dateFormatter as b,daysInMonth as y,isDayOutside as D,isMonthBeforeYear as S,isSameDay as M,isSameMonth as N,isValidDate as P,makeDate as C,meridiemLabels as _,monthLabels as k,startOfDay as z,startOfMonth as F,today as Y,weekdayLabels as A,withTime as j,YEAR_PAGE_SIZE as E,yearPageStart as B}from"./date";const R={xs:"1.75rem",sm:"2rem",md:"2.5rem",lg:"2.75rem",xl:"3rem"},T={xs:"xs",sm:"xs",md:"sm",lg:"sm",xl:"md"},$=["group relative flex cursor-pointer items-center justify-center overflow-hidden","box-border appearance-none bg-transparent font-[inherit] tabular-nums select-none","transition-[background-color,border-color,color]","duration-(--mp-sys-motion-duration-short4)","outline-mp-secondary focus-visible:z-10 focus-visible:outline-2","focus-visible:outline-offset-[-2px] focus-visible:outline-solid outline-none"].join(" ");function H({children:t,label:n,selected:r,inRange:l=!1,rangeEdge:a=null,current:s=!1,muted:c=!1,disabled:i=!1,focused:m=!1,className:d,onClick:h,onPointerEnter:p,onKeyDown:f}){return o("button",{type:"button",role:"gridcell","aria-label":n,"aria-selected":r,"aria-current":s?"date":void 0,"aria-disabled":i||void 0,tabIndex:m?0:-1,"data-focus-target":m?"true":void 0,className:[$,"start"===a?"rounded-s-mp-full":"end"===a?"rounded-e-mp-full":"middle"===a?"rounded-none":"rounded-mp-full",i?"cursor-default text-mp-on-surface/38":r?"bg-(--_mp-accent) text-(--_mp-on-accent)":l?"bg-(--_mp-accent-container) text-(--_mp-on-accent-container)":s?"border border-(--_mp-accent) text-(--_mp-accent)":c?"text-mp-on-surface-variant":"text-mp-on-surface",d??""].filter(Boolean).join(" "),onClick:()=>{i||h()},onPointerEnter:p,onKeyDown:f,children:[i?null:e(u,{}),t]})}function K({size:n,color:u,view:d,month:p,locale:f,labels:g,showPreviousButton:v,showNextButton:w,onStep:x,onViewChange:b}){const y=k(f,"long")[p.getMonth()],D=String(p.getFullYear()),M=S(f),N=T[n],P="day"===d?[g.previousMonth,g.nextMonth]:"month"===d?[g.previousYear,g.nextYear]:[g.previousYears,g.nextYears],C=(o,t)=>t?e(a,{size:N,color:u,label:P[-1===o?0:1],icon:e(l,{icon:-1===o?c:i,size:m[N],className:"rtl:rotate-180"}),onClick:()=>x(o)}):e("span",{"aria-hidden":"true",className:"size-(--_mp-cell)"}),_=o=>e(l,{icon:s,size:m[N],className:["transition-transform duration-(--mp-sys-motion-duration-short4)",o?"rotate-180":""].filter(Boolean).join(" ")}),z=e(r,{variant:"text",size:N,color:u,"aria-label":g.chooseMonth,"aria-expanded":"month"===d,endIcon:_("month"===d),onClick:()=>b("month"===d?"day":"month"),children:y},"month"),F=e(r,{variant:"text",size:N,color:u,className:"tabular-nums","aria-label":g.chooseYear,"aria-expanded":"year"===d,endIcon:_("year"===d),onClick:()=>b("year"===d?"day":"year"),children:D},"year"),Y=B(p.getFullYear());return o("div",{className:"flex items-center justify-between gap-1",children:[C(-1,v),e("div",{className:"flex min-w-0 flex-1 items-center justify-center gap-1",children:"year"===d?e("span",{className:`text-mp-on-surface flex h-(--_mp-cell) items-center tabular-nums ${h[n]}`,children:`${Y}–${Y+E-1}`}):"month"===d?F:o(t,M?{children:[z,F]}:{children:[F,z]})}),C(1,w)]})}export function MPCalendar({size:t,color:r,locale:l,weekStartsOn:a,month:s,onMonthChange:c,selected:i,rangeStart:u=null,rangeEnd:m=null,onSelect:d,onPreviewChange:h,minDate:p,maxDate:f,shouldDisableDate:w,showOutsideDays:x=!0,autoFocus:b=!1,showPreviousButton:y=!0,showNextButton:S=!0,labels:M}){const[_,k]=n.useState("day"),A=n.useMemo(()=>i.filter(P),[i]),[j,B]=n.useState(()=>{const e=A.find(e=>N(e,s));return e?z(e):N(Y(),s)?Y():F(s)}),T=n.useRef(b),$=n.useRef(null);n.useEffect(()=>{B(e=>N(e,s)?e:F(s))},[s]),n.useLayoutEffect(()=>{T.current&&(T.current=!1,$.current?.querySelector('[data-focus-target="true"]')?.focus({preventScroll:!0}))});const H=n.useCallback(e=>D(e,p,f)||(w?.(e)??!1),[p,f,w]),q=e=>{T.current=!0,k(e)},I=e=>{T.current=!0,c(e)};return o("div",{ref:$,className:"mp-calendar flex flex-col gap-1",style:{"--_mp-cell":R[t]},onPointerLeave:()=>h?.(null),children:[e(K,{size:t,color:r,view:_,month:s,locale:l,labels:M,showPreviousButton:y,showNextButton:S,onStep:e=>{c("day"===_?g(s,e):v(s,"month"===_?e:e*E))},onViewChange:q}),e("div",{className:"h-[calc(var(--_mp-cell)*7)] w-[calc(var(--_mp-cell)*7)]",children:"day"===_?e(L,{size:t,locale:l,weekStartsOn:a,month:s,chosen:A,rangeStart:u,rangeEnd:m,focusedDate:j,showOutsideDays:x,isDisabled:H,onSelect:e=>{B(e),d(e)},onPreviewChange:h,onMoveFocus:e=>{T.current=!0,B(e),N(e,s)||c(F(e))}}):"month"===_?e(O,{size:t,locale:l,month:s,chosen:A,minDate:p,maxDate:f,onMoveCursor:I,onPick:e=>{c(C(s.getFullYear(),e,1)),q("day")}}):e(U,{size:t,month:s,chosen:A,minDate:p,maxDate:f,onMoveCursor:I,onPick:e=>{c(C(e,s.getMonth(),1)),q("month")}})})]})}function L({size:t,locale:r,weekStartsOn:l,month:a,chosen:s,rangeStart:c,rangeEnd:i,focusedDate:u,showOutsideDays:m,isDisabled:p,onSelect:v,onPreviewChange:y,onMoveFocus:D}){const S=A(r,l,"narrow"),C=A(r,l,"long"),_=(z=i,P(k=c)&&P(z)?x(k,z)<=0?[k,z]:[z,k]:null);var k,z;const F=Y(),j=n.useMemo(()=>{const e=b(r,{dateStyle:"full"});return w(a,l).map(o=>o.map(o=>({date:o,label:e.format(o)})))},[a,l,r]);return o("div",{role:"grid","aria-label":b(r,{year:"numeric",month:"long"}).format(a),className:"flex h-full flex-col",children:[e("div",{role:"row",className:"grid grid-cols-7",children:S.map((o,t)=>e("span",{role:"columnheader","aria-label":C[t],className:`text-mp-on-surface-variant flex h-(--_mp-cell) items-center justify-center select-none ${d}`,children:o},t))}),j.map((o,n)=>e("div",{role:"row",className:"grid grid-cols-7",children:o.map(({date:o,label:n})=>{const r=!N(o,a);if(r&&!m)return e("span",{role:"gridcell","aria-hidden":"true",className:"size-(--_mp-cell)"},o.getTime());const c=s.some(e=>M(e,o)),i=null!==_&&x(o,_[0])>=0&&x(o,_[1])<=0,d=null!==_&&i&&M(o,_[0]),w=null!==_&&i&&M(o,_[1]);return e(H,{label:n,selected:c,inRange:i&&!c,rangeEdge:i?d&&w?"both":d?"start":w?"end":"middle":null,current:M(o,F)&&!c,muted:r,disabled:p(o),focused:M(o,u),className:`size-(--_mp-cell) ${h[t]}`,onClick:()=>v(o),onPointerEnter:()=>y?.(o),onKeyDown:e=>((e,o)=>{const t=(o.getDay()-l+7)%7,n={ArrowLeft:()=>f(o,-1),ArrowRight:()=>f(o,1),ArrowUp:()=>f(o,-7),ArrowDown:()=>f(o,7),Home:()=>f(o,-t),End:()=>f(o,6-t),PageUp:()=>g(o,e.shiftKey?-12:-1),PageDown:()=>g(o,e.shiftKey?12:1)}[e.key];n&&(e.preventDefault(),D(n()))})(e,o),children:o.getDate()},o.getTime())})},n))]})}function O({size:o,locale:t,month:n,chosen:r,minDate:l,maxDate:a,onMoveCursor:s,onPick:c}){const i=k(t,"short"),u=k(t,"long"),m=n.getFullYear(),d=new Date,p=e=>{const o={ArrowLeft:-1,ArrowRight:1,ArrowUp:-3,ArrowDown:3,PageUp:-12,PageDown:12}[e.key];void 0!==o&&(e.preventDefault(),s(g(F(n),o)))};return e("div",{role:"grid",className:"flex h-full flex-col justify-evenly",children:[0,1,2,3].map(t=>e("div",{role:"row",className:"grid grid-cols-3 gap-1",children:[0,1,2].map(s=>{const f=3*t+s,g=C(m,f,1),v=C(m,f,y(m,f));return e(H,{label:`${u[f]} ${m}`,selected:r.some(e=>e.getFullYear()===m&&e.getMonth()===f),current:d.getFullYear()===m&&d.getMonth()===f,disabled:P(l)&&x(v,l)<0||P(a)&&x(g,a)>0,focused:f===n.getMonth(),className:`h-(--_mp-cell) w-full ${h[o]}`,onClick:()=>c(f),onKeyDown:p,children:i[f]},f)})},t))})}function U({size:o,month:t,chosen:n,minDate:r,maxDate:l,onMoveCursor:a,onPick:s}){const c=B(t.getFullYear()),i=(new Date).getFullYear(),u=e=>{const o={ArrowLeft:-1,ArrowRight:1,ArrowUp:-4,ArrowDown:4,PageUp:-E,PageDown:E}[e.key];void 0!==o&&(e.preventDefault(),a(v(F(t),o)))};return e("div",{role:"grid",className:"flex h-full flex-col justify-evenly",children:[0,1,2].map(a=>e("div",{role:"row",className:"grid grid-cols-4 gap-1",children:[0,1,2,3].map(m=>{const d=c+4*a+m;return e(H,{label:String(d),selected:n.some(e=>e.getFullYear()===d),current:d===i,disabled:P(r)&&d<r.getFullYear()||P(l)&&d>l.getFullYear(),focused:d===t.getFullYear(),className:`h-(--_mp-cell) w-full ${h[o]}`,onClick:()=>s(d),onKeyDown:u,children:d},d)})},a))})}function q(e){const o=e.parentElement;if(!o)return;const t=e.getBoundingClientRect(),n=o.getBoundingClientRect(),r=t.top-n.top-o.clientTop+o.scrollTop,l=r+t.height;r<o.scrollTop?o.scrollTop=r:l>o.scrollTop+o.clientHeight&&(o.scrollTop=l-o.clientHeight)}export function MPTimeGrid({size:t,locale:r,value:l,referenceDate:a,onChange:s,hour12:c,showSeconds:i,hourStep:m,minuteStep:d,secondStep:f,shouldDisableTime:g,autoFocus:v=!1,labels:w}){const x=l??a,y=n.useRef(null),[D,S]=n.useMemo(()=>_(r),[r]);n.useEffect(()=>{const e=y.current;if(e?.querySelectorAll('[data-chosen="true"]').forEach(q),v){const o=e?.querySelector('[role="listbox"]');(o?.querySelector('[data-chosen="true"]')??o?.querySelector('[role="option"]'))?.focus({preventScroll:!0})}},[v]);const M=n.useMemo(()=>{const e=Math.ceil((c?12:24)/m),o=Array.from({length:e},(e,o)=>o*m);return c?o.map(e=>0===e?12:e):o},[c,m]),N=n.useMemo(()=>Array.from({length:Math.ceil(60/d)},(e,o)=>o*d),[d]),P=n.useMemo(()=>Array.from({length:Math.ceil(60/f)},(e,o)=>o*f),[f]),C=e=>String(e).padStart(2,"0"),k=c?x.getHours()%12||12:x.getHours(),z=(n,r,a,i,m)=>e("div",{role:"listbox","aria-label":r,className:["mp-time-grid__column flex flex-col gap-0.5 overflow-y-auto overscroll-contain","h-[calc(var(--_mp-cell)*7)] w-[calc(var(--_mp-cell)*1.75)]","scroll-py-0.5 [scrollbar-width:thin]"].join(" "),children:a.map(r=>{const a=((e,o)=>j(x,"hour"===e?{hours:c?o%12+(x.getHours()>=12?12:0):o}:"minute"===e?{minutes:o}:"second"===e?{seconds:o}:{hours:x.getHours()%12+12*o}))(n,r),d=null!==l&&i(r),p=g?.(a,n)??!1;return o("button",{type:"button",role:"option","aria-selected":d,"aria-disabled":p||void 0,"data-chosen":d?"true":void 0,className:[$,"rounded-mp-full h-(--_mp-cell) w-full shrink-0",h[t],p?"cursor-default text-mp-on-surface/38":d?"bg-(--_mp-accent) text-(--_mp-on-accent)":"text-mp-on-surface"].join(" "),onClick:()=>{p||s(a)},children:[p?null:e(u,{}),m(r)]},r)})},n);return o("div",{ref:y,className:"mp-time-grid flex gap-1",style:{"--_mp-cell":R[t]},children:[z("hour",w.hour,M,e=>e===k,e=>c?String(e):C(e)),z("minute",w.minute,N,e=>e===x.getMinutes(),C),i?z("second",w.second,P,e=>e===x.getSeconds(),C):null,c?z("meridiem",w.meridiem,[0,1],e=>(x.getHours()>=12?1:0)===e,e=>0===e?D:S):null,e("span",{className:p,"aria-live":"polite",children:null===l?"":b(r,{hour:"numeric",minute:"2-digit",...i?{second:"2-digit"}:{}}).format(l)})]})}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPSize } from '../types';
|
|
3
|
+
export interface MPFieldOutlineProps {
|
|
4
|
+
/** The label, which is what cuts the notch. Without one the outline is closed. */
|
|
5
|
+
label?: React.ReactNode;
|
|
6
|
+
required?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Whether the notch is cut. `false` closes it, for the moment the label is
|
|
9
|
+
* resting on the control's line and there is nothing on the border to make
|
|
10
|
+
* room for.
|
|
11
|
+
* @default true
|
|
12
|
+
*/
|
|
13
|
+
notched?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The outline itself.
|
|
17
|
+
*
|
|
18
|
+
* A `<legend>` inside a `<fieldset>` natively interrupts the top border, which
|
|
19
|
+
* is exactly the notch an outlined text field has — sized to the text, with no
|
|
20
|
+
* measuring in JavaScript. The legend is hidden with `invisible` rather than
|
|
21
|
+
* removed, because a legend with no content reserves no gap.
|
|
22
|
+
*
|
|
23
|
+
* Decorative, and hidden from the accessibility tree: the accessible name comes
|
|
24
|
+
* from the real `<label>`, and announcing a `<fieldset>` as a group around a
|
|
25
|
+
* single control is noise a screen reader does not need.
|
|
26
|
+
*/
|
|
27
|
+
export declare function MPFieldOutline({ label, required, notched }: MPFieldOutlineProps): React.JSX.Element;
|
|
28
|
+
export interface MPFieldLabelProps extends MPFieldOutlineProps {
|
|
29
|
+
/**
|
|
30
|
+
* Which rung the control is drawn at. Read twice: for the inline offset, so
|
|
31
|
+
* the label lands over the gap the container's padding put the notch in, and
|
|
32
|
+
* for the type scale it rests at.
|
|
33
|
+
*/
|
|
34
|
+
size: MPSize;
|
|
35
|
+
/** The control the label names. */
|
|
36
|
+
htmlFor?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Whether the label is up in the notch. `false` rests it on the control's own
|
|
39
|
+
* line, at the control's own type scale, where it reads as the placeholder.
|
|
40
|
+
* @default true
|
|
41
|
+
*/
|
|
42
|
+
shrunk?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Whether the control is a `<textarea>`, which is the one case a resting
|
|
45
|
+
* label cannot simply be centred in. See `MULTILINE_REST`.
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
multiline?: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The label a reader actually gets.
|
|
52
|
+
*
|
|
53
|
+
* A real `<label>`, associated with the control by Base UI, sitting on the
|
|
54
|
+
* border line where the legend cut it away. It cannot *be* the legend: the
|
|
55
|
+
* outline is `pointer-events-none` so that clicks land on the control
|
|
56
|
+
* underneath, and a label inside it would stop being clickable.
|
|
57
|
+
*
|
|
58
|
+
* Resting, it is `pointer-events-none` instead — it is lying over the text the
|
|
59
|
+
* caret goes into, and a click on it has to reach the control so the caret
|
|
60
|
+
* lands where the pointer did. A `<label for>` would only have focused the
|
|
61
|
+
* control, which puts the caret at the end of the text rather than under the
|
|
62
|
+
* pointer.
|
|
63
|
+
*/
|
|
64
|
+
export declare function MPFieldLabel({ size, label, required, htmlFor, shrunk, multiline }: MPFieldLabelProps): React.JSX.Element;
|
|
65
|
+
export interface MPFloatingLabel {
|
|
66
|
+
/** Whether the label is up in the notch right now. */
|
|
67
|
+
shrunk: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Spread on the element the control sits inside — the `Field.Root`, or the
|
|
70
|
+
* shell `<div>` under it. Anything focusable within it counts as the field
|
|
71
|
+
* being focused, which is what a reader tabbing onto a password toggle or a
|
|
72
|
+
* stepper means by it.
|
|
73
|
+
*/
|
|
74
|
+
focusProps: {
|
|
75
|
+
onFocusCapture: React.FocusEventHandler<HTMLElement>;
|
|
76
|
+
onBlurCapture: React.FocusEventHandler<HTMLElement>;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export interface MPFloatingLabelOptions {
|
|
80
|
+
/**
|
|
81
|
+
* Whether the label floats at all. `false` pins it in the notch — which is
|
|
82
|
+
* also what a control with no label wants, since there is nothing to rest.
|
|
83
|
+
*/
|
|
84
|
+
floating: boolean;
|
|
85
|
+
/** Whether the control holds anything. A filled control keeps its label up. */
|
|
86
|
+
filled: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Anything else that holds the label up: a start adornment already occupying
|
|
89
|
+
* the resting label's place, or a popup the focus has moved into.
|
|
90
|
+
* @default false
|
|
91
|
+
*/
|
|
92
|
+
pinned?: boolean;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Which of its two places the label is in, and how the field learns it moved.
|
|
96
|
+
*
|
|
97
|
+
* Focus is tracked here rather than read from Base UI's `data-focused` because
|
|
98
|
+
* the two do not agree on what a field is. `data-focused` follows the one
|
|
99
|
+
* control the `Field` owns, and half the shells here have a button beside it —
|
|
100
|
+
* a reveal toggle, a stepper, a clear × — that a reader on the keyboard is
|
|
101
|
+
* plainly still *in* the field for. `focus-within` on the shell is the honest
|
|
102
|
+
* boundary, and a capture-phase pair is how React spells it without a
|
|
103
|
+
* `:focus-within` selector, which cannot be read back as a value.
|
|
104
|
+
*
|
|
105
|
+
* The `relatedTarget` test is what keeps the label still while focus moves
|
|
106
|
+
* between two things inside the same shell. Without it, tabbing from the input
|
|
107
|
+
* to the toggle drops the label and lifts it again in the same frame.
|
|
108
|
+
*/
|
|
109
|
+
export declare function useFloatingLabel({ floating, filled, pinned }: MPFloatingLabelOptions): MPFloatingLabel;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as r,Fragment as e,jsxs as t}from"react/jsx-runtime";import*as o from"react";import{Field as n}from"@base-ui/react/field";import{PROSE_TEXT as a}from"./scale";const i={xs:"left-1",sm:"left-2",md:"left-3",lg:"left-3",xl:"left-4"},s={xs:"top-[18px]",sm:"top-[18px]",md:"top-5",lg:"top-5",xl:"top-5"};function d(o,n){return t(e,{children:[o,n?r("span",{"aria-hidden":"true",children:" *"}):null]})}export function MPFieldOutline({label:e,required:t=!1,notched:o=!0}){return r("fieldset",{"aria-hidden":"true",className:["pointer-events-none absolute inset-0 -top-[5px] m-0 min-w-0 px-2 pt-0","rounded-mp-xs border border-mp-outline","transition-[border-color] duration-(--mp-sys-motion-duration-short4)","group-hover:border-mp-on-surface","group-focus-within:border-2 group-focus-within:border-mp-primary","group-data-focused:border-2 group-data-focused:border-mp-primary","group-data-invalid:border-mp-error","group-data-disabled:border-mp-on-surface/12"].join(" "),children:e?r("legend",{className:["text-mp-body-small invisible float-none block h-[11px] w-auto overflow-hidden p-0","leading-none","ease-mp-standard transition-[max-width,padding]","duration-(--mp-sys-motion-duration-short4)",o?"max-w-full px-1":"max-w-0 px-0"].join(" "),children:d(e,t)}):null})}export function MPFieldLabel({size:e,label:t,required:o=!1,htmlFor:p,shrunk:l=!0,multiline:u=!1}){return r(n.Label,{htmlFor:p,"data-mp-shrunk":l?"":void 0,className:["text-mp-on-surface-variant","ease-mp-standard transition-[color,top,font-size,max-width]","duration-(--mp-sys-motion-duration-short4)","absolute -translate-y-1/2 px-1 leading-none",i[e],l?"text-mp-body-small pointer-events-auto top-0 max-w-none":[a[e],"pointer-events-none max-w-[calc(100%-2rem)] truncate",u?s[e]:"top-1/2"].join(" "),"group-focus-within:text-mp-primary","group-data-focused:text-mp-primary","group-data-invalid:text-mp-error","group-data-disabled:text-mp-on-surface/38"].join(" "),children:d(t,o)})}export function useFloatingLabel({floating:r,filled:e,pinned:t=!1}){const[n,a]=o.useState(!1);return{shrunk:!r||e||n||t,focusProps:{onFocusCapture:()=>a(!0),onBlurCapture:r=>{r.currentTarget.contains(r.relatedTarget)||a(!1)}}}}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPPickerLabels } from './Calendar';
|
|
3
|
+
import type { MPColor, MPSize, MPStyleProps } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* The strings a trigger is held open by, kept across renders that did not
|
|
6
|
+
* change what it could say.
|
|
7
|
+
*
|
|
8
|
+
* `displaySamples` formats two dozen instants and deduplicates them, which is
|
|
9
|
+
* cheap once and not cheap sixty times a second — and sixty times a second is
|
|
10
|
+
* exactly what a range picker asks for, because moving the pointer across the
|
|
11
|
+
* calendar re-renders the whole control to redraw the band.
|
|
12
|
+
*
|
|
13
|
+
* ## Why it is keyed on the format's *contents*
|
|
14
|
+
*
|
|
15
|
+
* Because an options object is nearly always a fresh one. Three of the four
|
|
16
|
+
* pickers build theirs from a default parameter or a literal, so it is a new
|
|
17
|
+
* object on every render by construction; and a caller who writes
|
|
18
|
+
* `format={{ dateStyle: 'full' }}` inline hands over a new object too. Keyed on
|
|
19
|
+
* identity, the memo would miss every single time — which is what it was doing.
|
|
20
|
+
*
|
|
21
|
+
* Serialising instead means the memo holds for as long as the format *says* the
|
|
22
|
+
* same thing, whoever built the object. `internal/date.ts` keys its formatter
|
|
23
|
+
* cache the same way, and inherits the same harmless quirk: two objects whose
|
|
24
|
+
* keys are in a different order read as two formats. That costs one extra miss,
|
|
25
|
+
* never a wrong answer.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useDisplaySamples(locale: string | undefined, options: Intl.DateTimeFormatOptions): string[];
|
|
28
|
+
/**
|
|
29
|
+
* The props a picker takes from its shell rather than inventing.
|
|
30
|
+
*
|
|
31
|
+
* Written out here rather than left to `MPStyleProps` alone because these are
|
|
32
|
+
* the rows a reader of the docs is actually looking at — every one of the four
|
|
33
|
+
* pickers lists them, and they mean the same thing on all four.
|
|
34
|
+
*/
|
|
35
|
+
export interface MPPickerShellProps extends MPStyleProps {
|
|
36
|
+
/**
|
|
37
|
+
* Which accent family the popup reads: the chosen day's fill, the band across
|
|
38
|
+
* a range, today's outline, the footer's confirm button.
|
|
39
|
+
* @default 'primary'
|
|
40
|
+
*/
|
|
41
|
+
color?: MPColor;
|
|
42
|
+
/**
|
|
43
|
+
* Label for the picker, drawn in the outline's notch and — while nothing is
|
|
44
|
+
* chosen, the popup is shut and there is no leading glyph — resting on the
|
|
45
|
+
* trigger's own line where the placeholder would be. See `floatingLabel`.
|
|
46
|
+
*/
|
|
47
|
+
label?: React.ReactNode;
|
|
48
|
+
/**
|
|
49
|
+
* Whether the label rests on the trigger's line while there is nothing to make
|
|
50
|
+
* room for, and rises into the notch on focus or on the first choice.
|
|
51
|
+
*
|
|
52
|
+
* A picker draws its own glyph before the value, and that glyph stands exactly
|
|
53
|
+
* where a resting label would — so in practice this only takes effect on a
|
|
54
|
+
* picker asked for without one, `startIcon={null}`. Two things cannot share a
|
|
55
|
+
* spot, and of the two the glyph is what says the trigger opens a calendar.
|
|
56
|
+
* @default true
|
|
57
|
+
*/
|
|
58
|
+
floatingLabel?: boolean;
|
|
59
|
+
/** The line under the control. Replaced by `errorMessage` when there is one. */
|
|
60
|
+
description?: React.ReactNode;
|
|
61
|
+
/**
|
|
62
|
+
* The message under the control. Its presence is also what puts the picker
|
|
63
|
+
* into its error state — there is no separate `error` boolean, so there is no
|
|
64
|
+
* way to render a control that is visibly wrong with no explanation of why.
|
|
65
|
+
*/
|
|
66
|
+
errorMessage?: React.ReactNode;
|
|
67
|
+
/**
|
|
68
|
+
* Content placed before the value. Defaults to the picker's own glyph, and
|
|
69
|
+
* `null` is how that glyph is asked for by name to go away.
|
|
70
|
+
*/
|
|
71
|
+
startIcon?: React.ReactNode;
|
|
72
|
+
/** Marks the picker required, both to assistive technology and to the label. */
|
|
73
|
+
required?: boolean;
|
|
74
|
+
/** Greys the picker out and stops it opening. */
|
|
75
|
+
disabled?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Shows the value without allowing it to be changed, and stays focusable.
|
|
78
|
+
*
|
|
79
|
+
* The popup does not open either. What a read-only picker holds is something
|
|
80
|
+
* to read, and a calendar whose every cell was inert would be a menu of
|
|
81
|
+
* nothing.
|
|
82
|
+
*/
|
|
83
|
+
readOnly?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* The id put on the trigger and pointed at by the label. Generated when it is
|
|
86
|
+
* left out.
|
|
87
|
+
*/
|
|
88
|
+
id?: string;
|
|
89
|
+
className?: string;
|
|
90
|
+
style?: React.CSSProperties;
|
|
91
|
+
}
|
|
92
|
+
interface InternalShellProps extends MPPickerShellProps {
|
|
93
|
+
/** Which component this is, for the class hook and the generated id. */
|
|
94
|
+
slug: string;
|
|
95
|
+
/** What the trigger reads. A placeholder when `empty`. */
|
|
96
|
+
display: React.ReactNode;
|
|
97
|
+
/**
|
|
98
|
+
* Every string the display could hold, so the trigger stops changing width
|
|
99
|
+
* with its value. `displaySamples` in `internal/date` produces them and
|
|
100
|
+
* `MPWidthSizer` is what lays them out.
|
|
101
|
+
*/
|
|
102
|
+
samples?: string[];
|
|
103
|
+
/** Nothing has been chosen yet, so the display is muted. */
|
|
104
|
+
empty: boolean;
|
|
105
|
+
/** Offers the × that empties the control. */
|
|
106
|
+
clearable?: boolean;
|
|
107
|
+
onClear: () => void;
|
|
108
|
+
open: boolean;
|
|
109
|
+
onOpenChange: (open: boolean) => void;
|
|
110
|
+
labels: MPPickerLabels;
|
|
111
|
+
/**
|
|
112
|
+
* `<input type="hidden">` rows, so the control submits with a form.
|
|
113
|
+
*
|
|
114
|
+
* Each row carries its own name, which is why the shell takes no `name` of
|
|
115
|
+
* its own: a range picker submits two of them under one name, and the id the
|
|
116
|
+
* label points at is generated rather than derived from it.
|
|
117
|
+
*/
|
|
118
|
+
hiddenValues?: Array<{
|
|
119
|
+
name: string;
|
|
120
|
+
value: string;
|
|
121
|
+
}>;
|
|
122
|
+
children: React.ReactNode;
|
|
123
|
+
triggerRef?: React.Ref<HTMLButtonElement>;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* A trigger, a label, the line of text under it, and a popup.
|
|
127
|
+
*
|
|
128
|
+
* Everything about it that is visible is a decision already made elsewhere: the
|
|
129
|
+
* notched outline, the label in the notch, the supporting text, the disabled
|
|
130
|
+
* treatment, and the popup's `surface-container` at elevation 2 — which is the
|
|
131
|
+
* same floating sheet a menu and a select's list are drawn on.
|
|
132
|
+
*/
|
|
133
|
+
export declare function MPPickerShell({ slug, size, color, fullWidth, label, floatingLabel, description, errorMessage, startIcon, required, disabled, readOnly, id, className, style, display, samples, empty, clearable, onClear, open, onOpenChange, labels, hiddenValues, children, triggerRef }: InternalShellProps): React.JSX.Element;
|
|
134
|
+
/**
|
|
135
|
+
* The row of shortcuts under a picker's panel.
|
|
136
|
+
*
|
|
137
|
+
* A hairline above it rather than a gap, because the actions act on the panel
|
|
138
|
+
* and a gap would read as a second popup stacked under the first.
|
|
139
|
+
*/
|
|
140
|
+
export declare function MPPickerFooter({ children }: {
|
|
141
|
+
children: React.ReactNode;
|
|
142
|
+
}): React.JSX.Element;
|
|
143
|
+
/** The vertical hairline between a calendar and the clock beside it. */
|
|
144
|
+
export declare function MPPickerDivider(): React.JSX.Element;
|
|
145
|
+
/**
|
|
146
|
+
* What a picker's footer buttons are drawn at.
|
|
147
|
+
*
|
|
148
|
+
* The same rung the calendar's header uses, for the same reason: a `md` picker's
|
|
149
|
+
* footer sitting at the control ladder's 56px would be taller than two rows of
|
|
150
|
+
* the calendar above it.
|
|
151
|
+
*/
|
|
152
|
+
export declare const FOOTER_SIZE: Record<MPSize, MPSize>;
|
|
153
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as i from"react";import{Field as n}from"@base-ui/react/field";import{Popover as t}from"@base-ui/react/popover";import{MPIcon as o}from"../components/icon/MPIcon";import{CloseIcon as a}from"../constants/icons";import{accentSlots as l}from"./accent";import{MPFieldLabel as s,MPFieldOutline as p,useFloatingLabel as c}from"./FieldOutline";import{MPStateLayer as m}from"./StateLayer";import{MPSupportingText as d}from"./SupportingText";import{MPWidthSizer as u}from"./WidthSizer";import{displaySamples as f}from"./date";import{CONTROL_ICON as h,hasContent as g,PROSE_TEXT as x}from"./scale";import{FADE as b,PORTAL_LAYER as v}from"./surface";export function useDisplaySamples(e,r){const n=`${e??""} ${JSON.stringify(r)}`;return i.useMemo(()=>f(e,r),[n])}const y={xs:{padding:"px-2",height:"h-8"},sm:{padding:"px-3",height:"h-10"},md:{padding:"px-4",height:"h-14"},lg:{padding:"px-4",height:"h-16"},xl:{padding:"px-5",height:"h-18"}},N={xs:"p-1.5",sm:"p-2",md:"p-2.5",lg:"p-3",xl:"p-3.5"};export function MPPickerShell({slug:f,size:j="md",color:P="primary",fullWidth:w=!1,label:O,floatingLabel:k=!0,description:M,errorMessage:S,startIcon:z,required:F=!1,disabled:B=!1,readOnly:C=!1,id:I,className:R,style:$,display:q,samples:T,empty:_,clearable:D=!1,onClear:E,open:L,onOpenChange:W,labels:J,hiddenValues:V,children:Z,triggerRef:A}){const G=g(S),H=y[j],K=i.useId(),Q=I??K,U=D&&!_&&!(B||C),{shrunk:X,focusProps:Y}=c({floating:k&&g(O),filled:!_,pinned:L||g(z)});return r(n.Root,{disabled:B,invalid:G,"data-mp-size":j,className:[`mp-${f} group flex-col align-top`,w?"flex w-full":"inline-flex w-fit",R??""].filter(Boolean).join(" "),style:{...l(P),...$},...Y,children:[r(t.Root,{open:L,onOpenChange:W,children:[r("div",{className:"relative w-full",children:[r(t.Trigger,{id:Q,ref:A,disabled:B,nativeButton:!0,className:["relative flex w-full items-center gap-2 select-none","appearance-none bg-transparent font-[inherit] outline-none",H.padding,U?"pe-10":"",H.height,x[j],B?"text-mp-on-surface/38 cursor-default":"text-mp-on-surface "+(C?"cursor-default":"cursor-pointer")].filter(Boolean).join(" "),children:[z?e("span",{className:["flex shrink-0 items-center",B?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:z}):null,r("span",{className:"flex min-w-0 flex-1 flex-col",children:[e("span",{className:["w-full truncate text-start",_&&!B?"text-mp-on-surface-variant":""].filter(Boolean).join(" "),children:_&&!X?null:q}),e(u,{samples:T??[]})]})]}),U?r("button",{type:"button","aria-label":J.clear,onClick:E,className:["group/clear rounded-mp-full text-mp-on-surface-variant absolute inset-y-0","end-1 my-auto flex size-8 cursor-pointer items-center justify-center","appearance-none border-0 bg-transparent font-[inherit]","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-1","focus-visible:outline-solid outline-none"].join(" "),children:[e(m,{className:"group-hover/clear:opacity-8 group-focus-visible/clear:opacity-10"}),e(o,{icon:a,size:h[j]})]}):null,e(p,{label:O,required:F,notched:X}),g(O)?e(s,{size:j,label:O,required:F,htmlFor:Q,shrunk:X}):null]}),e(t.Portal,{children:e(t.Positioner,{className:v,sideOffset:4,align:"start",children:e(t.Popup,{initialFocus:!1,className:[`mp-${f}__popup rounded-mp-md shadow-mp-2 bg-mp-surface-container`,"text-mp-on-surface outline-none",N[j],x[j],b].join(" "),children:Z})})})]}),e(d,{description:M,errorMessage:S,className:H.padding}),V?.map((r,i)=>e("input",{type:"hidden",name:r.name,value:r.value},i))]})}export function MPPickerFooter({children:r}){return e("div",{className:"border-mp-outline-variant flex items-center justify-end gap-1 border-t pt-1.5",children:r})}export function MPPickerDivider(){return e("div",{"aria-hidden":"true",className:"bg-mp-outline-variant w-px self-stretch"})}export const FOOTER_SIZE={xs:"xs",sm:"xs",md:"sm",lg:"sm",xl:"md"};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Material's state layer.
|
|
4
|
+
*
|
|
5
|
+
* MD3 does not express hover, focus and press as three more colours. It puts a
|
|
6
|
+
* translucent wash of the *content* colour over the container — 8% hovered, 10%
|
|
7
|
+
* focused or pressed — so one rule covers a filled button, an outlined one and a
|
|
8
|
+
* bare text one without any of them naming a second background.
|
|
9
|
+
*
|
|
10
|
+
* That is the whole reason this is an element rather than a `hover:bg-…` on the
|
|
11
|
+
* control itself. A background can only be replaced, and replacing it is what
|
|
12
|
+
* makes a text button's hover state opaque and an outlined button's hover state
|
|
13
|
+
* cover its own border. A layer composites instead, so whatever was underneath —
|
|
14
|
+
* a fill, a hairline, nothing at all — is still there under the wash.
|
|
15
|
+
*
|
|
16
|
+
* `bg-current` is what makes it one rule: the layer takes the colour of the
|
|
17
|
+
* label it sits behind, which is already the right ink for the surface. A caller
|
|
18
|
+
* that needs a different one sets `text-…` on the layer.
|
|
19
|
+
*
|
|
20
|
+
* ## How it is wired
|
|
21
|
+
*
|
|
22
|
+
* The control carries `group` and `relative`; this carries `group-hover:` and
|
|
23
|
+
* friends. It cannot key off its own `:hover` because it covers the control and
|
|
24
|
+
* has to be `pointer-events-none` for clicks to reach it — and an element that
|
|
25
|
+
* takes no pointer events is never hovered.
|
|
26
|
+
*
|
|
27
|
+
* `rounded-[inherit]` rather than a radius of its own: the layer is the control's
|
|
28
|
+
* shape, and a pill with a square wash in it is worse than no wash.
|
|
29
|
+
*
|
|
30
|
+
* ## `layer` replaces the appearance rather than adding to it
|
|
31
|
+
*
|
|
32
|
+
* The shape and the colour arrive as one string because a tick's layer is
|
|
33
|
+
* neither. MD3 draws it as a 40dp circle *around* an 18dp box, in `on-surface`
|
|
34
|
+
* rather than in the ink — which for a ticked checkbox is white, and a white
|
|
35
|
+
* halo is not a state. Appending those classes to the defaults would leave two
|
|
36
|
+
* `background-color` declarations of equal specificity fighting, and which one
|
|
37
|
+
* wins is decided by their order in the generated stylesheet. So the caller
|
|
38
|
+
* replaces the set rather than adding to it, and only the opacity ladder — the
|
|
39
|
+
* part that is genuinely the same everywhere — is fixed here.
|
|
40
|
+
*/
|
|
41
|
+
export declare function MPStateLayer({ layer, className }: {
|
|
42
|
+
/** Shape, position and colour. Replaces the defaults; it does not extend them. */
|
|
43
|
+
layer?: string;
|
|
44
|
+
className?: string;
|
|
45
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as o}from"react/jsx-runtime";export function MPStateLayer({layer:t="inset-0 rounded-[inherit] bg-current",className:a}){return o("span",{"aria-hidden":"true",className:["pointer-events-none absolute opacity-0",t,"transition-opacity duration-(--mp-sys-motion-duration-short4)","group-hover:opacity-8","group-active:opacity-10","group-focus-visible:opacity-10","group-disabled:opacity-0 group-data-disabled:opacity-0",a??""].filter(Boolean).join(" ")})}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The line under a control.
|
|
4
|
+
*
|
|
5
|
+
* Material calls it supporting text and gives it one slot, not two — which is
|
|
6
|
+
* why this renders *either* the description or the error rather than stacking
|
|
7
|
+
* them. An error is not additional information about a field, it is the field's
|
|
8
|
+
* current problem, and pushing the description down a line to make room leaves
|
|
9
|
+
* the reader reading a sentence that has just stopped applying.
|
|
10
|
+
*
|
|
11
|
+
* Both parts come from Base UI's `Field`, so whichever one is showing is wired
|
|
12
|
+
* to the control by `aria-describedby` without anybody generating an id.
|
|
13
|
+
* `Field.Error` needs `match` because it normally waits for the browser's own
|
|
14
|
+
* validity state; here the message's presence *is* the state, which is the same
|
|
15
|
+
* bargain `MPTextField.errorMessage` makes — there is no way to render a control
|
|
16
|
+
* that is visibly wrong with no explanation of why.
|
|
17
|
+
*/
|
|
18
|
+
export declare function MPSupportingText({ description, errorMessage, className }: {
|
|
19
|
+
description?: React.ReactNode;
|
|
20
|
+
errorMessage?: React.ReactNode;
|
|
21
|
+
/** Whatever inset lines the text up with the control it belongs to. */
|
|
22
|
+
className?: string;
|
|
23
|
+
}): React.JSX.Element | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import{Field as e}from"@base-ui/react/field";import{META_TEXT as t,hasContent as o}from"./scale";export function MPSupportingText({description:a,errorMessage:s,className:i}){const n=["mp-supporting-text block",t,"data-disabled:text-mp-on-surface/38",i??""].filter(Boolean).join(" ");return o(s)?r(e.Error,{match:!0,className:`${n} text-mp-error`,children:s}):o(a)?r(e.Description,{className:`${n} text-mp-on-surface-variant`,children:a}):null}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Holds a control open at the width of the widest thing it could ever say.
|
|
4
|
+
*
|
|
5
|
+
* A control that is not `fullWidth` is sized by what it is *currently* saying,
|
|
6
|
+
* which for anything whose value changes means the box changes with it. A date
|
|
7
|
+
* picker on the 1st is a dozen pixels narrower than the same picker on the 28th,
|
|
8
|
+
* and `Sep` is wider than `May`. Either way the field moves under the pointer
|
|
9
|
+
* that just used it, and the whole row of controls beside it shuffles along.
|
|
10
|
+
*
|
|
11
|
+
* So the alternatives are laid out too, stacked in a box clipped to no height.
|
|
12
|
+
* The control's intrinsic width becomes the widest of them and stops depending
|
|
13
|
+
* on the value.
|
|
14
|
+
*
|
|
15
|
+
* Three things it deliberately is not:
|
|
16
|
+
*
|
|
17
|
+
* - **Not `hidden`, and not `display: none`.** Both take the box out of layout,
|
|
18
|
+
* and a box that is not laid out reserves nothing.
|
|
19
|
+
* - **Not read out.** `aria-hidden`, or a screen reader would announce every
|
|
20
|
+
* date the control might hold before the one it does.
|
|
21
|
+
* - **Not text.** A sample is drawn as generated content off a data attribute
|
|
22
|
+
* rather than as a text node. `content: attr(…)` lays out exactly like text,
|
|
23
|
+
* so it reserves the same width — but it leaves nothing for `getByText` or a
|
|
24
|
+
* browser's find-in-page to trip over, so a caller's test asking for the date
|
|
25
|
+
* they chose keeps finding one element rather than two.
|
|
26
|
+
*/
|
|
27
|
+
export declare function MPWidthSizer({ samples }: {
|
|
28
|
+
samples: readonly string[];
|
|
29
|
+
}): React.JSX.Element | null;
|
|
30
|
+
/** The props a component hands over when it wants one of these. */
|
|
31
|
+
export type MPWidthSizerProps = React.ComponentProps<typeof MPWidthSizer>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";export function MPWidthSizer({samples:a}){return 0===a.length?null:e("span",{"aria-hidden":"true",className:"invisible h-0 min-h-0 overflow-hidden",children:a.map((a,n)=>e("span",{"data-sample":a,className:"block whitespace-nowrap before:content-[attr(data-sample)]"},`${n}:${a}`))})}
|