@react-md/core 6.2.1 → 6.3.1
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/_base.scss +1 -1
- package/dist/app-bar/styles.d.ts +0 -2
- package/dist/app-bar/styles.js.map +1 -1
- package/dist/autocomplete/types.d.ts +12 -0
- package/dist/autocomplete/types.js.map +1 -1
- package/dist/avatar/Avatar.d.ts +0 -10
- package/dist/avatar/Avatar.js.map +1 -1
- package/dist/avatar/styles.d.ts +10 -0
- package/dist/avatar/styles.js.map +1 -1
- package/dist/badge/Badge.d.ts +11 -0
- package/dist/badge/Badge.js.map +1 -1
- package/dist/badge/styles.d.ts +0 -8
- package/dist/badge/styles.js.map +1 -1
- package/dist/box/_box.scss +8 -8
- package/dist/box/styles.d.ts +9 -0
- package/dist/box/styles.js.map +1 -1
- package/dist/button/_button.scss +4 -0
- package/dist/button/styles.d.ts +5 -1
- package/dist/button/styles.js.map +1 -1
- package/dist/card/Card.d.ts +0 -7
- package/dist/card/Card.js.map +1 -1
- package/dist/card/styles.d.ts +6 -0
- package/dist/card/styles.js +8 -8
- package/dist/card/styles.js.map +1 -1
- package/dist/chip/Chip.d.ts +6 -13
- package/dist/chip/Chip.js.map +1 -1
- package/dist/chip/styles.d.ts +26 -1
- package/dist/chip/styles.js.map +1 -1
- package/dist/datetime/NativeDateField.d.ts +24 -0
- package/dist/datetime/NativeDateField.js +63 -0
- package/dist/datetime/NativeDateField.js.map +1 -0
- package/dist/datetime/NativeTimeField.d.ts +26 -0
- package/dist/datetime/NativeTimeField.js +63 -0
- package/dist/datetime/NativeTimeField.js.map +1 -0
- package/dist/datetime/useDateField.d.ts +120 -0
- package/dist/datetime/useDateField.js +35 -0
- package/dist/datetime/useDateField.js.map +1 -0
- package/dist/datetime/useTimeField.d.ts +124 -0
- package/dist/datetime/useTimeField.js +65 -0
- package/dist/datetime/useTimeField.js.map +1 -0
- package/dist/datetime/utils.d.ts +34 -0
- package/dist/datetime/utils.js +27 -0
- package/dist/datetime/utils.js.map +1 -0
- package/dist/dialog/styles.d.ts +5 -2
- package/dist/dialog/styles.js.map +1 -1
- package/dist/divider/styles.d.ts +1 -1
- package/dist/divider/styles.js.map +1 -1
- package/dist/draggable/utils.d.ts +3 -6
- package/dist/draggable/utils.js.map +1 -1
- package/dist/error-boundary/ErrorBoundary.js.map +1 -1
- package/dist/expansion-panel/ExpansionList.js +1 -1
- package/dist/expansion-panel/ExpansionList.js.map +1 -1
- package/dist/expansion-panel/useExpansionList.d.ts +2 -7
- package/dist/expansion-panel/useExpansionList.js.map +1 -1
- package/dist/files/validation.js.map +1 -1
- package/dist/form/FormMessage.js +3 -1
- package/dist/form/FormMessage.js.map +1 -1
- package/dist/form/FormMessageContainer.d.ts +2 -1
- package/dist/form/FormMessageContainer.js +3 -2
- package/dist/form/FormMessageContainer.js.map +1 -1
- package/dist/form/FormMessageCounter.d.ts +3 -2
- package/dist/form/FormMessageCounter.js +5 -2
- package/dist/form/FormMessageCounter.js.map +1 -1
- package/dist/form/InputToggle.js.map +1 -1
- package/dist/form/Label.d.ts +0 -10
- package/dist/form/Label.js.map +1 -1
- package/dist/form/Listbox.d.ts +3 -10
- package/dist/form/Listbox.js +8 -27
- package/dist/form/Listbox.js.map +1 -1
- package/dist/form/ListboxProvider.d.ts +17 -0
- package/dist/form/ListboxProvider.js +33 -1
- package/dist/form/ListboxProvider.js.map +1 -1
- package/dist/form/NativeSelect.js +1 -0
- package/dist/form/NativeSelect.js.map +1 -1
- package/dist/form/Slider.d.ts +4 -0
- package/dist/form/Slider.js.map +1 -1
- package/dist/form/Switch.js.map +1 -1
- package/dist/form/TextArea.js +1 -0
- package/dist/form/TextArea.js.map +1 -1
- package/dist/form/TextField.js +1 -0
- package/dist/form/TextField.js.map +1 -1
- package/dist/form/TextFieldContainer.d.ts +0 -13
- package/dist/form/TextFieldContainer.js.map +1 -1
- package/dist/form/_form-message.scss +13 -0
- package/dist/form/_select.scss +5 -1
- package/dist/form/_text-area.scss +2 -1
- package/dist/form/_text-field.scss +13 -3
- package/dist/form/formMessageContainerStyles.d.ts +7 -0
- package/dist/form/formMessageContainerStyles.js +4 -2
- package/dist/form/formMessageContainerStyles.js.map +1 -1
- package/dist/form/sliderUtils.d.ts +3 -7
- package/dist/form/sliderUtils.js.map +1 -1
- package/dist/form/types.d.ts +33 -0
- package/dist/form/types.js.map +1 -1
- package/dist/form/useCombobox.d.ts +6 -2
- package/dist/form/useCombobox.js +8 -9
- package/dist/form/useCombobox.js.map +1 -1
- package/dist/form/useFormReset.d.ts +4 -1
- package/dist/form/useFormReset.js +9 -4
- package/dist/form/useFormReset.js.map +1 -1
- package/dist/form/useNumberField.d.ts +5 -5
- package/dist/form/useNumberField.js +10 -2
- package/dist/form/useNumberField.js.map +1 -1
- package/dist/form/useSelectCombobox.js +2 -2
- package/dist/form/useSelectCombobox.js.map +1 -1
- package/dist/form/useTextField.d.ts +76 -59
- package/dist/form/useTextField.js +7 -1
- package/dist/form/useTextField.js.map +1 -1
- package/dist/interaction/types.d.ts +5 -1
- package/dist/interaction/types.js.map +1 -1
- package/dist/interaction/utils.d.ts +14 -0
- package/dist/interaction/utils.js +23 -12
- package/dist/interaction/utils.js.map +1 -1
- package/dist/link/Link.d.ts +0 -7
- package/dist/link/Link.js.map +1 -1
- package/dist/link/styles.d.ts +7 -0
- package/dist/link/styles.js.map +1 -1
- package/dist/list/List.d.ts +5 -20
- package/dist/list/List.js.map +1 -1
- package/dist/list/ListItem.d.ts +4 -38
- package/dist/list/ListItem.js.map +1 -1
- package/dist/list/listItemStyles.d.ts +24 -2
- package/dist/list/listItemStyles.js.map +1 -1
- package/dist/list/listStyles.d.ts +17 -2
- package/dist/list/listStyles.js.map +1 -1
- package/dist/menu/Menu.js.map +1 -1
- package/dist/menu/MenuBar.js +1 -1
- package/dist/menu/MenuBar.js.map +1 -1
- package/dist/menu/MenuItemTextField.d.ts +1 -2
- package/dist/menu/MenuItemTextField.js.map +1 -1
- package/dist/menu/MenuWidget.js +3 -2
- package/dist/menu/MenuWidget.js.map +1 -1
- package/dist/movement/constants.d.ts +10 -0
- package/dist/movement/constants.js +20 -4
- package/dist/movement/constants.js.map +1 -1
- package/dist/movement/types.d.ts +59 -10
- package/dist/movement/types.js.map +1 -1
- package/dist/movement/useKeyboardMovementProvider.d.ts +5 -1
- package/dist/movement/useKeyboardMovementProvider.js +171 -73
- package/dist/movement/useKeyboardMovementProvider.js.map +1 -1
- package/dist/navigation/NavItem.d.ts +4 -1
- package/dist/navigation/NavItem.js.map +1 -1
- package/dist/navigation/navItemStyles.d.ts +7 -0
- package/dist/navigation/navItemStyles.js.map +1 -1
- package/dist/overlay/Overlay.d.ts +4 -23
- package/dist/overlay/Overlay.js.map +1 -1
- package/dist/overlay/styles.d.ts +26 -8
- package/dist/overlay/styles.js.map +1 -1
- package/dist/progress/LinearProgress.d.ts +4 -9
- package/dist/progress/LinearProgress.js.map +1 -1
- package/dist/progress/circularProgressStyles.d.ts +6 -0
- package/dist/progress/circularProgressStyles.js.map +1 -1
- package/dist/progress/linearProgressStyles.d.ts +20 -5
- package/dist/progress/linearProgressStyles.js.map +1 -1
- package/dist/progress/types.d.ts +0 -9
- package/dist/progress/types.js.map +1 -1
- package/dist/segmented-button/SegmentedButton.d.ts +7 -12
- package/dist/segmented-button/SegmentedButton.js.map +1 -1
- package/dist/segmented-button/segmentedButtonStyles.d.ts +26 -3
- package/dist/segmented-button/segmentedButtonStyles.js.map +1 -1
- package/dist/sheet/Sheet.d.ts +0 -12
- package/dist/sheet/Sheet.js.map +1 -1
- package/dist/sheet/styles.d.ts +12 -0
- package/dist/sheet/styles.js.map +1 -1
- package/dist/snackbar/Toast.d.ts +2 -13
- package/dist/snackbar/Toast.js.map +1 -1
- package/dist/snackbar/ToastManager.js.map +1 -1
- package/dist/snackbar/toastStyles.d.ts +17 -2
- package/dist/snackbar/toastStyles.js.map +1 -1
- package/dist/tabs/Tab.d.ts +2 -41
- package/dist/tabs/Tab.js.map +1 -1
- package/dist/tabs/tabStyles.d.ts +45 -4
- package/dist/tabs/tabStyles.js.map +1 -1
- package/dist/tabs/useTabList.js +1 -1
- package/dist/tabs/useTabList.js.map +1 -1
- package/dist/test-utils/drag.d.ts +6 -9
- package/dist/test-utils/mocks/IntersectionObserver.js.map +1 -1
- package/dist/test-utils/mocks/ResizeObserver.js.map +1 -1
- package/dist/test-utils/utils/createFileList.js.map +1 -1
- package/dist/theme/_theme.scss +0 -1
- package/dist/theme/getDerivedTheme.d.ts +0 -24
- package/dist/theme/getDerivedTheme.js.map +1 -1
- package/dist/theme/types.d.ts +25 -0
- package/dist/theme/types.js.map +1 -1
- package/dist/tooltip/Tooltip.d.ts +4 -32
- package/dist/tooltip/Tooltip.js.map +1 -1
- package/dist/tooltip/styles.d.ts +38 -1
- package/dist/tooltip/styles.js +1 -1
- package/dist/tooltip/styles.js.map +1 -1
- package/dist/transition/SkeletonPlaceholder.d.ts +0 -7
- package/dist/transition/SkeletonPlaceholder.js.map +1 -1
- package/dist/transition/Slide.js.map +1 -1
- package/dist/transition/skeletonPlaceholderUtils.d.ts +7 -0
- package/dist/transition/skeletonPlaceholderUtils.js.map +1 -1
- package/dist/transition/useCarousel.d.ts +2 -2
- package/dist/transition/useCarousel.js.map +1 -1
- package/dist/transition/useMaxWidthTransition.d.ts +14 -2
- package/dist/transition/useMaxWidthTransition.js.map +1 -1
- package/dist/transition/useSlideTransition.d.ts +5 -0
- package/dist/transition/useSlideTransition.js.map +1 -1
- package/dist/tree/Tree.d.ts +5 -9
- package/dist/tree/Tree.js +1 -1
- package/dist/tree/Tree.js.map +1 -1
- package/dist/tree/styles.d.ts +9 -1
- package/dist/tree/styles.js.map +1 -1
- package/dist/tree/useTreeMovement.d.ts +2 -1
- package/dist/tree/useTreeMovement.js +2 -1
- package/dist/tree/useTreeMovement.js.map +1 -1
- package/dist/types.d.ts +14 -0
- package/dist/types.js.map +1 -1
- package/dist/typography/Mark.d.ts +4 -1
- package/dist/typography/Mark.js.map +1 -1
- package/dist/typography/TextContainer.d.ts +0 -6
- package/dist/typography/TextContainer.js.map +1 -1
- package/dist/typography/markStyles.d.ts +5 -0
- package/dist/typography/markStyles.js.map +1 -1
- package/dist/typography/textContainerStyles.d.ts +6 -0
- package/dist/typography/textContainerStyles.js.map +1 -1
- package/dist/typography/typographyStyles.d.ts +9 -0
- package/dist/typography/typographyStyles.js.map +1 -1
- package/dist/useResizeObserver.js.map +1 -1
- package/dist/utils/getMiddleOfRange.d.ts +2 -3
- package/dist/utils/getMiddleOfRange.js.map +1 -1
- package/dist/utils/getPercentage.d.ts +2 -9
- package/dist/utils/getPercentage.js +1 -1
- package/dist/utils/getPercentage.js.map +1 -1
- package/dist/utils/getRangeSteps.d.ts +2 -3
- package/dist/utils/getRangeSteps.js +0 -3
- package/dist/utils/getRangeSteps.js.map +1 -1
- package/dist/utils/nearest.d.ts +2 -3
- package/dist/utils/nearest.js +0 -3
- package/dist/utils/nearest.js.map +1 -1
- package/dist/utils/trigonometry.d.ts +31 -0
- package/dist/utils/trigonometry.js +25 -0
- package/dist/utils/trigonometry.js.map +1 -0
- package/dist/window-splitter/WindowSplitter.d.ts +5 -19
- package/dist/window-splitter/WindowSplitter.js.map +1 -1
- package/dist/window-splitter/styles.d.ts +27 -3
- package/dist/window-splitter/styles.js.map +1 -1
- package/dist/window-splitter/useWindowSplitter.d.ts +1 -1
- package/dist/window-splitter/useWindowSplitter.js.map +1 -1
- package/package.json +8 -8
- package/src/app-bar/styles.ts +0 -2
- package/src/autocomplete/types.ts +17 -0
- package/src/avatar/Avatar.tsx +0 -11
- package/src/avatar/styles.ts +11 -0
- package/src/badge/Badge.tsx +12 -0
- package/src/badge/styles.ts +0 -9
- package/src/box/styles.ts +9 -0
- package/src/button/styles.ts +5 -1
- package/src/card/Card.tsx +0 -8
- package/src/card/styles.ts +15 -8
- package/src/chip/Chip.tsx +9 -15
- package/src/chip/styles.ts +29 -1
- package/src/datetime/NativeDateField.tsx +92 -0
- package/src/datetime/NativeTimeField.tsx +94 -0
- package/src/datetime/useDateField.ts +193 -0
- package/src/datetime/useTimeField.ts +233 -0
- package/src/datetime/utils.ts +48 -0
- package/src/dialog/styles.ts +5 -2
- package/src/divider/styles.ts +1 -1
- package/src/draggable/utils.ts +3 -6
- package/src/expansion-panel/ExpansionList.tsx +2 -1
- package/src/expansion-panel/useExpansionList.ts +6 -12
- package/src/form/FormMessage.tsx +4 -0
- package/src/form/FormMessageContainer.tsx +8 -4
- package/src/form/FormMessageCounter.tsx +17 -6
- package/src/form/InputToggle.tsx +2 -0
- package/src/form/Label.tsx +0 -11
- package/src/form/Listbox.tsx +18 -46
- package/src/form/ListboxProvider.ts +61 -1
- package/src/form/NativeSelect.tsx +1 -0
- package/src/form/Slider.tsx +6 -0
- package/src/form/Switch.tsx +2 -0
- package/src/form/TextArea.tsx +3 -0
- package/src/form/TextField.tsx +1 -0
- package/src/form/TextFieldContainer.tsx +0 -14
- package/src/form/formMessageContainerStyles.ts +10 -2
- package/src/form/sliderUtils.ts +3 -7
- package/src/form/types.ts +44 -0
- package/src/form/useCombobox.ts +15 -10
- package/src/form/useFormReset.ts +12 -5
- package/src/form/useNumberField.ts +17 -14
- package/src/form/useSelectCombobox.ts +2 -2
- package/src/form/useTextField.ts +102 -69
- package/src/interaction/types.ts +5 -1
- package/src/interaction/utils.ts +18 -20
- package/src/link/Link.tsx +0 -8
- package/src/link/styles.ts +8 -0
- package/src/list/List.tsx +7 -24
- package/src/list/ListItem.tsx +7 -43
- package/src/list/listItemStyles.ts +26 -2
- package/src/list/listStyles.ts +18 -2
- package/src/menu/Menu.tsx +2 -0
- package/src/menu/MenuBar.tsx +1 -1
- package/src/menu/MenuItemTextField.tsx +1 -3
- package/src/menu/MenuWidget.tsx +4 -2
- package/src/movement/constants.ts +26 -4
- package/src/movement/types.ts +84 -19
- package/src/movement/useKeyboardMovementProvider.ts +209 -95
- package/src/navigation/NavItem.tsx +6 -2
- package/src/navigation/navItemStyles.ts +8 -0
- package/src/overlay/Overlay.tsx +4 -26
- package/src/overlay/styles.ts +29 -10
- package/src/progress/LinearProgress.tsx +8 -10
- package/src/progress/circularProgressStyles.ts +7 -0
- package/src/progress/linearProgressStyles.ts +22 -5
- package/src/progress/types.ts +0 -10
- package/src/segmented-button/SegmentedButton.tsx +14 -15
- package/src/segmented-button/segmentedButtonStyles.ts +28 -3
- package/src/sheet/Sheet.tsx +0 -13
- package/src/sheet/styles.ts +13 -0
- package/src/snackbar/Toast.tsx +2 -15
- package/src/snackbar/toastStyles.ts +20 -2
- package/src/tabs/Tab.tsx +4 -49
- package/src/tabs/tabStyles.ts +52 -4
- package/src/tabs/useTabList.ts +1 -1
- package/src/test-utils/drag.ts +8 -12
- package/src/theme/getDerivedTheme.ts +0 -26
- package/src/theme/types.ts +26 -0
- package/src/tooltip/Tooltip.tsx +4 -36
- package/src/tooltip/styles.ts +43 -2
- package/src/transition/SkeletonPlaceholder.tsx +0 -8
- package/src/transition/Slide.tsx +2 -0
- package/src/transition/skeletonPlaceholderUtils.ts +8 -0
- package/src/transition/useCarousel.ts +2 -2
- package/src/transition/useMaxWidthTransition.ts +17 -2
- package/src/transition/useSlideTransition.ts +8 -0
- package/src/tree/Tree.tsx +6 -11
- package/src/tree/styles.ts +10 -1
- package/src/tree/useTreeMovement.ts +4 -0
- package/src/types.ts +16 -0
- package/src/typography/Mark.tsx +6 -2
- package/src/typography/TextContainer.tsx +0 -7
- package/src/typography/markStyles.ts +6 -0
- package/src/typography/textContainerStyles.ts +7 -0
- package/src/typography/typographyStyles.ts +10 -0
- package/src/utils/getMiddleOfRange.ts +2 -3
- package/src/utils/getPercentage.ts +3 -11
- package/src/utils/getRangeSteps.ts +3 -3
- package/src/utils/nearest.ts +3 -3
- package/src/utils/trigonometry.ts +46 -0
- package/src/window-splitter/WindowSplitter.tsx +9 -22
- package/src/window-splitter/styles.ts +31 -3
- package/src/window-splitter/useWindowSplitter.ts +3 -2
package/dist/card/Card.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/card/Card.tsx"],"sourcesContent":["import { type HTMLAttributes, forwardRef } from \"react\";\n\nimport { Box } from \"../box/Box.js\";\nimport { type BoxAlignItems, type BoxOptions } from \"../box/styles.js\";\nimport { type CardClassNameOptions, card } from \"./styles.js\";\n\
|
|
1
|
+
{"version":3,"sources":["../../src/card/Card.tsx"],"sourcesContent":["import { type HTMLAttributes, forwardRef } from \"react\";\n\nimport { Box } from \"../box/Box.js\";\nimport { type BoxAlignItems, type BoxOptions } from \"../box/styles.js\";\nimport { type CardClassNameOptions, card } from \"./styles.js\";\n\n/**\n * @since 6.0.0 Extends the {@link CardClassNameOptions} and removed the\n * deprecated `raiseable` prop\n */\nexport interface CardProps\n extends HTMLAttributes<HTMLDivElement>,\n CardClassNameOptions,\n Pick<BoxOptions, \"align\" | \"justify\" | \"fullWidth\" | \"disableWrap\"> {\n /** @defaultValue `\"stretch\"` */\n align?: BoxAlignItems;\n\n /** @defaultValue `\"start\"` */\n justify?: BoxAlignItems;\n}\n\n/**\n * @example Simple Example\n * ```tsx\n * import { Button } from \"@react-md/core/button/Button\";\n * import { Card } from \"@react-md/core/card/Card\";\n * import { CardContent } from \"@react-md/core/card/CardContent\";\n * import { CardFooter } from \"@react-md/core/card/CardFooter\";\n * import { CardHeader } from \"@react-md/core/card/CardHeader\";\n * import { CardTitle } from \"@react-md/core/card/CardTitle\";\n * import { CardSubtitle } from \"@react-md/core/card/CardSubtitle\";\n * import { Typography } from \"@react-md/core/typography/Typography\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return (\n * <Card>\n * <CardHeader>\n * <CardTitle>Main Title</CardTitle>\n * <CardSubtitle>A subtitle</CardSubtitle>\n * </CardHeader>\n * <CardContent>\n * <Typography margin=\"none\">\n * Some paragraph of text.\n * </Typography>\n * </CardContent>\n * <CardFooter>\n * <Button>Action 1</Button>\n * <Button>Action 2</Button>\n * </CardFooter>\n * </Card>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/card | Card Demos}\n * @since 6.0.0 Removed the deprecated `raiseable` prop\n * @since 6.0.0 Uses the `Box` component and displays as `flex` instead of\n * `block`/`inline-block`.\n */\nexport const Card = forwardRef<HTMLDivElement, CardProps>(\n function Card(props, ref) {\n const {\n children,\n className,\n align = \"stretch\",\n justify = \"stretch\",\n bordered,\n raisable,\n interactable,\n ...remaining\n } = props;\n\n return (\n <Box\n align={align}\n justify={justify}\n disableWrap\n {...remaining}\n stacked\n disableGap\n disablePadding\n ref={ref}\n className={card({\n className,\n bordered,\n raisable,\n interactable,\n })}\n >\n {children}\n </Box>\n );\n }\n);\n"],"names":["forwardRef","Box","card","Card","props","ref","children","className","align","justify","bordered","raisable","interactable","remaining","disableWrap","stacked","disableGap","disablePadding"],"mappings":";AAAA,SAA8BA,UAAU,QAAQ,QAAQ;AAExD,SAASC,GAAG,QAAQ,gBAAgB;AAEpC,SAAoCC,IAAI,QAAQ,cAAc;AAiB9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCC,GACD,OAAO,MAAMC,qBAAOH,WAClB,SAASG,KAAKC,KAAK,EAAEC,GAAG;IACtB,MAAM,EACJC,QAAQ,EACRC,SAAS,EACTC,QAAQ,SAAS,EACjBC,UAAU,SAAS,EACnBC,QAAQ,EACRC,QAAQ,EACRC,YAAY,EACZ,GAAGC,WACJ,GAAGT;IAEJ,qBACE,KAACH;QACCO,OAAOA;QACPC,SAASA;QACTK,WAAW;QACV,GAAGD,SAAS;QACbE,OAAO;QACPC,UAAU;QACVC,cAAc;QACdZ,KAAKA;QACLE,WAAWL,KAAK;YACdK;YACAG;YACAC;YACAC;QACF;kBAECN;;AAGP,GACA"}
|
package/dist/card/styles.d.ts
CHANGED
package/dist/card/styles.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { cnb } from "cnbuilder";
|
|
2
2
|
import { cssUtils } from "../cssUtils.js";
|
|
3
3
|
import { bem } from "../utils/bem.js";
|
|
4
|
-
const
|
|
4
|
+
const styles = bem("rmd-card");
|
|
5
5
|
/**
|
|
6
6
|
* @since 6.0.0
|
|
7
7
|
*/ export function card(options = {}) {
|
|
8
8
|
const { className, bordered, raisable, interactable } = options;
|
|
9
|
-
return cnb(
|
|
9
|
+
return cnb(styles({
|
|
10
10
|
bordered,
|
|
11
11
|
shadowed: !bordered,
|
|
12
12
|
raisable: !bordered && raisable,
|
|
@@ -17,7 +17,7 @@ const cardStyles = bem("rmd-card");
|
|
|
17
17
|
* @since 6.0.0
|
|
18
18
|
*/ export function cardHeader(options = {}) {
|
|
19
19
|
const { className, addonAfter = false, addonBefore = false } = options;
|
|
20
|
-
return cnb(
|
|
20
|
+
return cnb(styles("header", {
|
|
21
21
|
"addon-after": addonAfter && !addonBefore,
|
|
22
22
|
"addon-before": addonBefore && !addonAfter,
|
|
23
23
|
surrounded: addonAfter && addonBefore
|
|
@@ -27,25 +27,25 @@ const cardStyles = bem("rmd-card");
|
|
|
27
27
|
* @since 6.0.0
|
|
28
28
|
*/ export function cardHeaderContent(options = {}) {
|
|
29
29
|
const { className } = options;
|
|
30
|
-
return cnb(
|
|
30
|
+
return cnb(styles("header-content"), className);
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* @since 6.0.0
|
|
34
34
|
*/ export function cardTitle(options = {}) {
|
|
35
35
|
const { className } = options;
|
|
36
|
-
return cnb(
|
|
36
|
+
return cnb(styles("title"), className);
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* @since 6.0.0
|
|
40
40
|
*/ export function cardSubtitle(options = {}) {
|
|
41
41
|
const { className } = options;
|
|
42
|
-
return cnb(
|
|
42
|
+
return cnb(styles("subtitle"), className);
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* @since 6.0.0
|
|
46
46
|
*/ export function cardContent(options = {}) {
|
|
47
47
|
const { className, disablePadding, disableSecondaryColor, disableLastChildPadding } = options;
|
|
48
|
-
return cnb(
|
|
48
|
+
return cnb(styles("content", {
|
|
49
49
|
padded: !disablePadding,
|
|
50
50
|
"padding-bottom": !disableLastChildPadding
|
|
51
51
|
}), cssUtils({
|
|
@@ -56,7 +56,7 @@ const cardStyles = bem("rmd-card");
|
|
|
56
56
|
* @since 6.0.0
|
|
57
57
|
*/ export function cardFooter(options = {}) {
|
|
58
58
|
const { className } = options;
|
|
59
|
-
return cnb(
|
|
59
|
+
return cnb(styles("footer"), className);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
//# sourceMappingURL=styles.js.map
|
package/dist/card/styles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/card/styles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { cssUtils } from \"../cssUtils.js\";\nimport { bem } from \"../utils/bem.js\";\n\nconst
|
|
1
|
+
{"version":3,"sources":["../../src/card/styles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { cssUtils } from \"../cssUtils.js\";\nimport { bem } from \"../utils/bem.js\";\n\nconst styles = bem(\"rmd-card\");\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-card-background-color\"?: string;\n \"--rmd-card-color\"?: string;\n }\n}\n\n/** @since 6.0.0 */\nexport interface CardClassNameOptions {\n className?: string;\n\n /**\n * Set this to `true` if the card should use apply an inset `border` instead\n * of `box-shadow`.\n *\n * @defaultValue `false`\n */\n bordered?: boolean;\n\n /**\n * Set this to `true` if the card should gain additional box shadow while\n * hovered.\n *\n * @defaultValue `false`\n */\n raisable?: boolean;\n\n /**\n * Set this to `true` if the card should gain the pointer cursor while\n * hovering and other interaction styles and not using the `ClickableCard`\n * component.\n *\n * @defaultValue `false`\n */\n interactable?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function card(options: CardClassNameOptions = {}): string {\n const { className, bordered, raisable, interactable } = options;\n\n return cnb(\n styles({\n bordered,\n shadowed: !bordered,\n raisable: !bordered && raisable,\n interactable,\n }),\n className\n );\n}\n\n/** @since 6.0.0 */\nexport interface CardHeaderClassNameOptions {\n className?: string;\n\n /** @defaultValue `false` */\n addonAfter?: boolean;\n\n /** @defaultValue `false` */\n addonBefore?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function cardHeader(options: CardHeaderClassNameOptions = {}): string {\n const { className, addonAfter = false, addonBefore = false } = options;\n\n return cnb(\n styles(\"header\", {\n \"addon-after\": addonAfter && !addonBefore,\n \"addon-before\": addonBefore && !addonAfter,\n surrounded: addonAfter && addonBefore,\n }),\n className\n );\n}\n\n/** @since 6.0.0 */\nexport interface CardHeaderContentClassNameOptions {\n className?: string;\n}\n\n/**\n * @since 6.0.0\n */\nexport function cardHeaderContent(\n options: CardHeaderContentClassNameOptions = {}\n): string {\n const { className } = options;\n\n return cnb(styles(\"header-content\"), className);\n}\n\n/** @since 6.0.0 */\nexport interface CardTitleClassNameOptions {\n className?: string;\n}\n\n/**\n * @since 6.0.0\n */\nexport function cardTitle(options: CardTitleClassNameOptions = {}): string {\n const { className } = options;\n\n return cnb(styles(\"title\"), className);\n}\n\n/** @since 6.0.0 */\nexport interface CardSubtitleClassNameOptions {\n className?: string;\n}\n\n/**\n * @since 6.0.0\n */\nexport function cardSubtitle(\n options: CardSubtitleClassNameOptions = {}\n): string {\n const { className } = options;\n\n return cnb(styles(\"subtitle\"), className);\n}\n\n/** @since 6.0.0 */\nexport interface CardContentClassNameOptions {\n className?: string;\n\n /**\n * Set this to `true` to disable the card's padding.\n *\n * @defaultValue `false`\n */\n disablePadding?: boolean;\n\n /**\n * Set this to `true` to disable applying the `text-secondary-color`.\n *\n * @defaultValue `false`\n */\n disableSecondaryColor?: boolean;\n\n /**\n * Set this to `true` to disable applying extra `padding-bottom` if the\n * `CardContent` component is the last child.\n *\n * @defaultValue `false`\n * @since 6.0.0 Renamed from `disableExtraPadding`\n */\n disableLastChildPadding?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function cardContent(options: CardContentClassNameOptions = {}): string {\n const {\n className,\n disablePadding,\n disableSecondaryColor,\n disableLastChildPadding,\n } = options;\n\n return cnb(\n styles(\"content\", {\n padded: !disablePadding,\n \"padding-bottom\": !disableLastChildPadding,\n }),\n cssUtils({\n textColor: !disableSecondaryColor ? \"text-secondary\" : undefined,\n }),\n className\n );\n}\n\n/** @since 6.0.0 */\nexport interface CardFooterClassNameOptions {\n className?: string;\n}\n\n/**\n * @since 6.0.0\n */\nexport function cardFooter(options: CardFooterClassNameOptions = {}): string {\n const { className } = options;\n\n return cnb(styles(\"footer\"), className);\n}\n"],"names":["cnb","cssUtils","bem","styles","card","options","className","bordered","raisable","interactable","shadowed","cardHeader","addonAfter","addonBefore","surrounded","cardHeaderContent","cardTitle","cardSubtitle","cardContent","disablePadding","disableSecondaryColor","disableLastChildPadding","padded","textColor","undefined","cardFooter"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,SAASC,GAAG,QAAQ,kBAAkB;AAEtC,MAAMC,SAASD,IAAI;AAuCnB;;CAEC,GACD,OAAO,SAASE,KAAKC,UAAgC,CAAC,CAAC;IACrD,MAAM,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,YAAY,EAAE,GAAGJ;IAExD,OAAOL,IACLG,OAAO;QACLI;QACAG,UAAU,CAACH;QACXC,UAAU,CAACD,YAAYC;QACvBC;IACF,IACAH;AAEJ;AAaA;;CAEC,GACD,OAAO,SAASK,WAAWN,UAAsC,CAAC,CAAC;IACjE,MAAM,EAAEC,SAAS,EAAEM,aAAa,KAAK,EAAEC,cAAc,KAAK,EAAE,GAAGR;IAE/D,OAAOL,IACLG,OAAO,UAAU;QACf,eAAeS,cAAc,CAACC;QAC9B,gBAAgBA,eAAe,CAACD;QAChCE,YAAYF,cAAcC;IAC5B,IACAP;AAEJ;AAOA;;CAEC,GACD,OAAO,SAASS,kBACdV,UAA6C,CAAC,CAAC;IAE/C,MAAM,EAAEC,SAAS,EAAE,GAAGD;IAEtB,OAAOL,IAAIG,OAAO,mBAAmBG;AACvC;AAOA;;CAEC,GACD,OAAO,SAASU,UAAUX,UAAqC,CAAC,CAAC;IAC/D,MAAM,EAAEC,SAAS,EAAE,GAAGD;IAEtB,OAAOL,IAAIG,OAAO,UAAUG;AAC9B;AAOA;;CAEC,GACD,OAAO,SAASW,aACdZ,UAAwC,CAAC,CAAC;IAE1C,MAAM,EAAEC,SAAS,EAAE,GAAGD;IAEtB,OAAOL,IAAIG,OAAO,aAAaG;AACjC;AA8BA;;CAEC,GACD,OAAO,SAASY,YAAYb,UAAuC,CAAC,CAAC;IACnE,MAAM,EACJC,SAAS,EACTa,cAAc,EACdC,qBAAqB,EACrBC,uBAAuB,EACxB,GAAGhB;IAEJ,OAAOL,IACLG,OAAO,WAAW;QAChBmB,QAAQ,CAACH;QACT,kBAAkB,CAACE;IACrB,IACApB,SAAS;QACPsB,WAAW,CAACH,wBAAwB,mBAAmBI;IACzD,IACAlB;AAEJ;AAOA;;CAEC,GACD,OAAO,SAASmB,WAAWpB,UAAsC,CAAC,CAAC;IACjE,MAAM,EAAEC,SAAS,EAAE,GAAGD;IAEtB,OAAOL,IAAIG,OAAO,WAAWG;AAC/B"}
|
package/dist/chip/Chip.d.ts
CHANGED
|
@@ -1,27 +1,20 @@
|
|
|
1
1
|
import { type ButtonHTMLAttributes, type CSSProperties, type HTMLAttributes, type ReactNode } from "react";
|
|
2
2
|
import { type BackgroundColor } from "../cssUtils.js";
|
|
3
3
|
import { type ComponentWithRippleProps } from "../interaction/types.js";
|
|
4
|
+
import { type BaseMaxWidthTransitionOptions } from "../transition/useMaxWidthTransition.js";
|
|
4
5
|
import { type PropsWithRef } from "../types.js";
|
|
5
|
-
|
|
6
|
-
interface CSSProperties {
|
|
7
|
-
"--rmd-chip-solid-background-color"?: string;
|
|
8
|
-
"--rmd-chip-solid-disabled-background-color"?: string;
|
|
9
|
-
"--rmd-chip-solid-color"?: string;
|
|
10
|
-
"--rmd-chip-theme-background-color"?: string;
|
|
11
|
-
"--rmd-chip-theme-color"?: string;
|
|
12
|
-
"--rmd-chip-outline-background-color"?: string;
|
|
13
|
-
"--rmd-chip-outline-color"?: string;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
6
|
+
import { type ChipTheme } from "./styles.js";
|
|
16
7
|
/**
|
|
17
8
|
* @since 6.0.0 Renamed the `noninteractive` prop to
|
|
18
9
|
* `noninteractable`.
|
|
10
|
+
* @since 6.3.1 Extends BaseMaxWidthTransitionOptions for CSSProperties module
|
|
11
|
+
* augmentation.
|
|
19
12
|
*/
|
|
20
|
-
export interface ChipProps extends ButtonHTMLAttributes<HTMLButtonElement>, ComponentWithRippleProps {
|
|
13
|
+
export interface ChipProps extends ButtonHTMLAttributes<HTMLButtonElement>, BaseMaxWidthTransitionOptions, ComponentWithRippleProps {
|
|
21
14
|
/**
|
|
22
15
|
* @defaultValue `"solid"`
|
|
23
16
|
*/
|
|
24
|
-
theme?:
|
|
17
|
+
theme?: ChipTheme;
|
|
25
18
|
/**
|
|
26
19
|
* Set this to `true` if the chip should gain additional box shadow while the
|
|
27
20
|
* user is pressing down on the chip.
|
package/dist/chip/Chip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/chip/Chip.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport {\n type ButtonHTMLAttributes,\n type CSSProperties,\n type HTMLAttributes,\n type ReactNode,\n forwardRef,\n} from \"react\";\n\nimport { type BackgroundColor } from \"../cssUtils.js\";\nimport { getIcon } from \"../icon/config.js\";\nimport { type ComponentWithRippleProps } from \"../interaction/types.js\";\nimport { useElementInteraction } from \"../interaction/useElementInteraction.js\";\nimport { useHigherContrastChildren } from \"../interaction/useHigherContrastChildren.js\";\nimport { useMaxWidthTransition } from \"../transition/useMaxWidthTransition.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { chip, chipContent } from \"./styles.js\";\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-chip-solid-background-color\"?: string;\n \"--rmd-chip-solid-disabled-background-color\"?: string;\n \"--rmd-chip-solid-color\"?: string;\n \"--rmd-chip-theme-background-color\"?: string;\n \"--rmd-chip-theme-color\"?: string;\n \"--rmd-chip-outline-background-color\"?: string;\n \"--rmd-chip-outline-color\"?: string;\n }\n}\n\n/**\n * @since 6.0.0 Renamed the `noninteractive` prop to\n * `noninteractable`.\n */\nexport interface ChipProps\n extends ButtonHTMLAttributes<HTMLButtonElement>,\n ComponentWithRippleProps {\n /**\n * @defaultValue `\"solid\"`\n */\n theme?: \"outline\" | \"solid\";\n\n /**\n * Set this to `true` if the chip should gain additional box shadow while the\n * user is pressing down on the chip.\n *\n * @defaultValue `false`\n */\n raisable?: boolean;\n\n /**\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * When this is a boolean, a selected icon will be displayed before the\n * `children` and appear/disappear when `true`/`false`.\n *\n * @see {@link selectedIcon}\n * @see {@link selectedIconAfter}\n * @see {@link selectedThemed}\n */\n selected?: boolean;\n\n /**\n * Set this to `true` if the chip should change background color while\n * {@link selected} instead of displaying an icon. The default background\n * color is a lighter swatch of the theme primary color.\n *\n * @defaultValue `false`\n */\n selectedThemed?: boolean;\n\n /**\n * An optional className to provide only while {@link selected} is `true`.\n */\n selectedClassName?: string;\n\n /**\n * This will be ignored if {@link selected} is `undefined`.\n *\n * @defaultValue `getIcon(\"selected\")`\n */\n selectedIcon?: ReactNode;\n\n /**\n * Set this to `true` if the {@link selectedIcon} should display as the\n * {@link rightAddon} instead of the {@link leftAddon}.\n *\n * @defaultValue `false`\n * @since 6.0.0\n */\n selectedIconAfter?: boolean;\n\n /**\n * Set this to `true` if the {@link selectedIcon} should not animate and\n * instead apply `display: none`\n *\n * @defaultValue `false`\n */\n disableIconTransition?: boolean;\n\n /**\n * Set this to `true` to render the chip as a `<span>` instead of a button.\n *\n * @since 2.6.0\n * @since 6.0.0 Renamed from `noninteractable`\n * @defaultValue `false`\n */\n noninteractive?: boolean;\n\n /**\n * An optional background color theme to use.\n *\n * @since 6.0.0\n */\n backgroundColor?: BackgroundColor;\n\n /**\n * An optional icon, avatar, circular progress, or custom component to render\n * before the `children`. This will remove some of the leading horizontal\n * padding on the chip as well.\n */\n leftAddon?: ReactNode;\n\n /**\n * An optional icon, avatar, circular progress, or custom component to render\n * after the `children`. This will remove some of the trailing horizontal\n * padding on the chip as well.\n */\n rightAddon?: ReactNode;\n\n /**\n * Set this to true if the `children` should not be wrapped in a span to apply\n * the {@link chipContent} styles which allow for shrinking text and\n * truncating text with ellipsis.\n *\n * @defaultValue `false`\n */\n disableContentWrap?: boolean;\n\n /**\n * This will be ignored if {@link disableContentWrap} is `true`.\n *\n * @since 6.0.0\n */\n contentProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n\n /**\n * This will be ignored if {@link disableContentWrap} is `true`.\n */\n contentStyle?: CSSProperties;\n\n /**\n * This will be ignored if {@link disableContentWrap} is `true`.\n */\n contentClassName?: string;\n}\n\n/**\n * @example Simple Example\n * ```tsx\n * import { Chip } from \"@react-md/core/chip/Chip\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return <Chip>Content</Chip>;\n * }\n * ```\n *\n * @example Outlined Example\n * ```tsx\n * import { Chip } from \"@react-md/core/chip/Chip\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return <Chip theme=\"outline\">Content</Chip>;\n * }\n * ```\n *\n * @example Addons Example\n * ```tsx\n * import { Avatar } from \"@react-md/core/avatar/Avatar\";\n * import { Chip } from \"@react-md/core/chip/Chip\";\n * import AddCircleIcon from \"@react-md/material-icons/AddCircleIcon\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return (\n * <Chip\n * leftAddon={\n * <Avatar>\n * <img src=\"https://i.pravatar.cc/40?img=3\" alt=\"\" />\n * </Avatar>\n * }\n * rightAddon={<AddCircleIcon />}\n * >\n * Chip\n * </Chip>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/chip | Chip Demos}\n * @since 6.0.0 Renamed the `noninteractable` prop to\n * `noninteractive`.\n */\nexport const Chip = forwardRef<HTMLButtonElement, ChipProps>(\n function Chip(props, ref) {\n const {\n \"aria-pressed\": ariaPressed,\n theme = \"solid\",\n className,\n raisable = false,\n disabled = false,\n selected,\n selectedThemed = false,\n selectedClassName,\n selectedIcon: propSelectedIcon,\n selectedIconAfter = false,\n backgroundColor,\n noninteractive = false,\n disableRipple,\n disableIconTransition = false,\n children: propChildren,\n onClick,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onMouseLeave,\n onDragStart,\n onTouchStart,\n onTouchEnd,\n onTouchMove,\n leftAddon: propLeftAddon,\n rightAddon: propRightAddon,\n contentProps,\n contentStyle,\n contentClassName,\n disableContentWrap = false,\n ...remaining\n } = props;\n\n let buttonProps: ButtonHTMLAttributes<HTMLButtonElement> | undefined;\n if (!noninteractive) {\n buttonProps = {\n \"aria-pressed\": ariaPressed ?? (!!selected || undefined),\n type: \"button\",\n disabled,\n };\n }\n\n let content = propChildren;\n if (!disableContentWrap) {\n content = (\n <span\n style={contentStyle}\n {...contentProps}\n className={cnb(\n chipContent({ className: contentClassName }),\n contentProps?.className\n )}\n >\n {propChildren}\n </span>\n );\n }\n\n let leftAddon = propLeftAddon;\n let rightAddon = propRightAddon;\n const selectedIconNode = getIcon(\"selected\", propSelectedIcon);\n const isTransitionable =\n !selectedThemed &&\n typeof selected === \"boolean\" &&\n typeof (selectedIconAfter ? propRightAddon : propLeftAddon) ===\n \"undefined\";\n const selectedIcon = useMaxWidthTransition({\n element: selectedIconNode,\n transitionIn: !!selected,\n disabled: !isTransitionable,\n disableTransition: disableIconTransition,\n });\n if (isTransitionable) {\n if (selectedIconAfter) {\n rightAddon = selectedIcon;\n } else {\n leftAddon = selectedIcon;\n }\n }\n\n const { pressed, pressedClassName, ripples, handlers } =\n useElementInteraction({\n mode: disableRipple ? \"none\" : undefined,\n onClick,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onMouseLeave,\n onDragStart,\n onTouchStart,\n onTouchEnd,\n onTouchMove,\n disabled: disabled || noninteractive,\n });\n const children = useHigherContrastChildren(content);\n const Component = noninteractive ? \"span\" : \"button\";\n\n return (\n <Component\n {...remaining}\n {...buttonProps}\n {...handlers}\n className={chip({\n className,\n theme,\n pressed: raisable && pressed,\n disabled,\n selected,\n selectedThemed,\n selectedClassName,\n noninteractive,\n backgroundColor,\n pressedClassName,\n leftAddon: !!leftAddon && (selectedIconAfter || selected !== false),\n rightAddon:\n !!rightAddon && (!selectedIconAfter || selected !== false),\n })}\n ref={ref}\n >\n {leftAddon}\n {children}\n {rightAddon}\n {ripples}\n </Component>\n );\n }\n);\n"],"names":["cnb","forwardRef","getIcon","useElementInteraction","useHigherContrastChildren","useMaxWidthTransition","chip","chipContent","Chip","props","ref","ariaPressed","theme","className","raisable","disabled","selected","selectedThemed","selectedClassName","selectedIcon","propSelectedIcon","selectedIconAfter","backgroundColor","noninteractive","disableRipple","disableIconTransition","children","propChildren","onClick","onKeyDown","onKeyUp","onMouseDown","onMouseUp","onMouseLeave","onDragStart","onTouchStart","onTouchEnd","onTouchMove","leftAddon","propLeftAddon","rightAddon","propRightAddon","contentProps","contentStyle","contentClassName","disableContentWrap","remaining","buttonProps","undefined","type","content","span","style","selectedIconNode","isTransitionable","element","transitionIn","disableTransition","pressed","pressedClassName","ripples","handlers","mode","Component"],"mappings":"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"}
|
|
1
|
+
{"version":3,"sources":["../../src/chip/Chip.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport {\n type ButtonHTMLAttributes,\n type CSSProperties,\n type HTMLAttributes,\n type ReactNode,\n forwardRef,\n} from \"react\";\n\nimport { type BackgroundColor } from \"../cssUtils.js\";\nimport { getIcon } from \"../icon/config.js\";\nimport { type ComponentWithRippleProps } from \"../interaction/types.js\";\nimport { useElementInteraction } from \"../interaction/useElementInteraction.js\";\nimport { useHigherContrastChildren } from \"../interaction/useHigherContrastChildren.js\";\nimport {\n type BaseMaxWidthTransitionOptions,\n useMaxWidthTransition,\n} from \"../transition/useMaxWidthTransition.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { type ChipTheme, chip, chipContent } from \"./styles.js\";\n\n/**\n * @since 6.0.0 Renamed the `noninteractive` prop to\n * `noninteractable`.\n * @since 6.3.1 Extends BaseMaxWidthTransitionOptions for CSSProperties module\n * augmentation.\n */\nexport interface ChipProps\n extends ButtonHTMLAttributes<HTMLButtonElement>,\n BaseMaxWidthTransitionOptions,\n ComponentWithRippleProps {\n /**\n * @defaultValue `\"solid\"`\n */\n theme?: ChipTheme;\n\n /**\n * Set this to `true` if the chip should gain additional box shadow while the\n * user is pressing down on the chip.\n *\n * @defaultValue `false`\n */\n raisable?: boolean;\n\n /**\n * @defaultValue `false`\n */\n disabled?: boolean;\n\n /**\n * When this is a boolean, a selected icon will be displayed before the\n * `children` and appear/disappear when `true`/`false`.\n *\n * @see {@link selectedIcon}\n * @see {@link selectedIconAfter}\n * @see {@link selectedThemed}\n */\n selected?: boolean;\n\n /**\n * Set this to `true` if the chip should change background color while\n * {@link selected} instead of displaying an icon. The default background\n * color is a lighter swatch of the theme primary color.\n *\n * @defaultValue `false`\n */\n selectedThemed?: boolean;\n\n /**\n * An optional className to provide only while {@link selected} is `true`.\n */\n selectedClassName?: string;\n\n /**\n * This will be ignored if {@link selected} is `undefined`.\n *\n * @defaultValue `getIcon(\"selected\")`\n */\n selectedIcon?: ReactNode;\n\n /**\n * Set this to `true` if the {@link selectedIcon} should display as the\n * {@link rightAddon} instead of the {@link leftAddon}.\n *\n * @defaultValue `false`\n * @since 6.0.0\n */\n selectedIconAfter?: boolean;\n\n /**\n * Set this to `true` if the {@link selectedIcon} should not animate and\n * instead apply `display: none`\n *\n * @defaultValue `false`\n */\n disableIconTransition?: boolean;\n\n /**\n * Set this to `true` to render the chip as a `<span>` instead of a button.\n *\n * @since 2.6.0\n * @since 6.0.0 Renamed from `noninteractable`\n * @defaultValue `false`\n */\n noninteractive?: boolean;\n\n /**\n * An optional background color theme to use.\n *\n * @since 6.0.0\n */\n backgroundColor?: BackgroundColor;\n\n /**\n * An optional icon, avatar, circular progress, or custom component to render\n * before the `children`. This will remove some of the leading horizontal\n * padding on the chip as well.\n */\n leftAddon?: ReactNode;\n\n /**\n * An optional icon, avatar, circular progress, or custom component to render\n * after the `children`. This will remove some of the trailing horizontal\n * padding on the chip as well.\n */\n rightAddon?: ReactNode;\n\n /**\n * Set this to true if the `children` should not be wrapped in a span to apply\n * the {@link chipContent} styles which allow for shrinking text and\n * truncating text with ellipsis.\n *\n * @defaultValue `false`\n */\n disableContentWrap?: boolean;\n\n /**\n * This will be ignored if {@link disableContentWrap} is `true`.\n *\n * @since 6.0.0\n */\n contentProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n\n /**\n * This will be ignored if {@link disableContentWrap} is `true`.\n */\n contentStyle?: CSSProperties;\n\n /**\n * This will be ignored if {@link disableContentWrap} is `true`.\n */\n contentClassName?: string;\n}\n\n/**\n * @example Simple Example\n * ```tsx\n * import { Chip } from \"@react-md/core/chip/Chip\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return <Chip>Content</Chip>;\n * }\n * ```\n *\n * @example Outlined Example\n * ```tsx\n * import { Chip } from \"@react-md/core/chip/Chip\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return <Chip theme=\"outline\">Content</Chip>;\n * }\n * ```\n *\n * @example Addons Example\n * ```tsx\n * import { Avatar } from \"@react-md/core/avatar/Avatar\";\n * import { Chip } from \"@react-md/core/chip/Chip\";\n * import AddCircleIcon from \"@react-md/material-icons/AddCircleIcon\";\n * import type { ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return (\n * <Chip\n * leftAddon={\n * <Avatar>\n * <img src=\"https://i.pravatar.cc/40?img=3\" alt=\"\" />\n * </Avatar>\n * }\n * rightAddon={<AddCircleIcon />}\n * >\n * Chip\n * </Chip>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/chip | Chip Demos}\n * @since 6.0.0 Renamed the `noninteractable` prop to\n * `noninteractive`.\n */\nexport const Chip = forwardRef<HTMLButtonElement, ChipProps>(\n function Chip(props, ref) {\n const {\n \"aria-pressed\": ariaPressed,\n theme = \"solid\",\n className,\n raisable = false,\n disabled = false,\n selected,\n selectedThemed = false,\n selectedClassName,\n selectedIcon: propSelectedIcon,\n selectedIconAfter = false,\n backgroundColor,\n noninteractive = false,\n disableRipple,\n disableIconTransition = false,\n children: propChildren,\n onClick,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onMouseLeave,\n onDragStart,\n onTouchStart,\n onTouchEnd,\n onTouchMove,\n leftAddon: propLeftAddon,\n rightAddon: propRightAddon,\n contentProps,\n contentStyle,\n contentClassName,\n disableContentWrap = false,\n ...remaining\n } = props;\n\n let buttonProps: ButtonHTMLAttributes<HTMLButtonElement> | undefined;\n if (!noninteractive) {\n buttonProps = {\n \"aria-pressed\": ariaPressed ?? (!!selected || undefined),\n type: \"button\",\n disabled,\n };\n }\n\n let content = propChildren;\n if (!disableContentWrap) {\n content = (\n <span\n style={contentStyle}\n {...contentProps}\n className={cnb(\n chipContent({ className: contentClassName }),\n contentProps?.className\n )}\n >\n {propChildren}\n </span>\n );\n }\n\n let leftAddon = propLeftAddon;\n let rightAddon = propRightAddon;\n const selectedIconNode = getIcon(\"selected\", propSelectedIcon);\n const isTransitionable =\n !selectedThemed &&\n typeof selected === \"boolean\" &&\n typeof (selectedIconAfter ? propRightAddon : propLeftAddon) ===\n \"undefined\";\n const selectedIcon = useMaxWidthTransition({\n element: selectedIconNode,\n transitionIn: !!selected,\n disabled: !isTransitionable,\n disableTransition: disableIconTransition,\n });\n if (isTransitionable) {\n if (selectedIconAfter) {\n rightAddon = selectedIcon;\n } else {\n leftAddon = selectedIcon;\n }\n }\n\n const { pressed, pressedClassName, ripples, handlers } =\n useElementInteraction({\n mode: disableRipple ? \"none\" : undefined,\n onClick,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onMouseLeave,\n onDragStart,\n onTouchStart,\n onTouchEnd,\n onTouchMove,\n disabled: disabled || noninteractive,\n });\n const children = useHigherContrastChildren(content);\n const Component = noninteractive ? \"span\" : \"button\";\n\n return (\n <Component\n {...remaining}\n {...buttonProps}\n {...handlers}\n className={chip({\n className,\n theme,\n pressed: raisable && pressed,\n disabled,\n selected,\n selectedThemed,\n selectedClassName,\n noninteractive,\n backgroundColor,\n pressedClassName,\n leftAddon: !!leftAddon && (selectedIconAfter || selected !== false),\n rightAddon:\n !!rightAddon && (!selectedIconAfter || selected !== false),\n })}\n ref={ref}\n >\n {leftAddon}\n {children}\n {rightAddon}\n {ripples}\n </Component>\n );\n }\n);\n"],"names":["cnb","forwardRef","getIcon","useElementInteraction","useHigherContrastChildren","useMaxWidthTransition","chip","chipContent","Chip","props","ref","ariaPressed","theme","className","raisable","disabled","selected","selectedThemed","selectedClassName","selectedIcon","propSelectedIcon","selectedIconAfter","backgroundColor","noninteractive","disableRipple","disableIconTransition","children","propChildren","onClick","onKeyDown","onKeyUp","onMouseDown","onMouseUp","onMouseLeave","onDragStart","onTouchStart","onTouchEnd","onTouchMove","leftAddon","propLeftAddon","rightAddon","propRightAddon","contentProps","contentStyle","contentClassName","disableContentWrap","remaining","buttonProps","undefined","type","content","span","style","selectedIconNode","isTransitionable","element","transitionIn","disableTransition","pressed","pressedClassName","ripples","handlers","mode","Component"],"mappings":"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"}
|
package/dist/chip/styles.d.ts
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
import { type BackgroundColor } from "../cssUtils.js";
|
|
2
|
+
declare module "react" {
|
|
3
|
+
interface CSSProperties {
|
|
4
|
+
"--rmd-chip-gap"?: string;
|
|
5
|
+
"--rmd-chip-height"?: string;
|
|
6
|
+
"--rmd-chip-border-radius"?: string | number;
|
|
7
|
+
"--rmd-chip-horizontal-padding"?: string | number;
|
|
8
|
+
"--rmd-chip-vertical-padding"?: string | number;
|
|
9
|
+
"--rmd-chip-solid-background-color"?: string;
|
|
10
|
+
"--rmd-chip-solid-disabled-background-color"?: string;
|
|
11
|
+
"--rmd-chip-solid-color"?: string;
|
|
12
|
+
"--rmd-chip-theme-background-color"?: string;
|
|
13
|
+
"--rmd-chip-theme-color"?: string;
|
|
14
|
+
"--rmd-chip-outline-color"?: string;
|
|
15
|
+
"--rmd-chip-outline-width"?: string | number;
|
|
16
|
+
"--rmd-chip-outline-background-color"?: string;
|
|
17
|
+
"--rmd-chip-outline-text-color"?: string;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @since 6.3.1
|
|
22
|
+
*/
|
|
23
|
+
export type ChipTheme = "outline" | "solid";
|
|
2
24
|
/**
|
|
3
25
|
* @since 6.0.0
|
|
4
26
|
*
|
|
@@ -33,9 +55,12 @@ import { type BackgroundColor } from "../cssUtils.js";
|
|
|
33
55
|
*/
|
|
34
56
|
export interface ChipClassNameOptions {
|
|
35
57
|
className?: string;
|
|
58
|
+
/**
|
|
59
|
+
* An optional className to provide only while {@link selected} is `true`.
|
|
60
|
+
*/
|
|
36
61
|
selectedClassName?: string;
|
|
37
62
|
/** @defaultValue `"solid"` */
|
|
38
|
-
theme?:
|
|
63
|
+
theme?: ChipTheme;
|
|
39
64
|
backgroundColor?: BackgroundColor;
|
|
40
65
|
/** @defaultValue `false` */
|
|
41
66
|
disabled?: boolean;
|
package/dist/chip/styles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/chip/styles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { type BackgroundColor, cssUtils } from \"../cssUtils.js\";\nimport { bem } from \"../utils/bem.js\";\n\nconst styles = bem(\"rmd-chip\");\n\n/**\n * @since 6.0.0\n *\n * Note for the future: Once Firefox supports the `:has` selector, the\n * `leftAddon` and `rightAddon` can be removed. The styles would automatically\n * apply the padding instead:\n *\n * ```scss\n * &:has(.rmd-icon:first-child, .rmd-avatar:first-child) {\n * padding-left: $addon-left-padding;\n *\n * @include utils.rtl {\n * padding-left: $horizontal-padding;\n * padding-right; $addon-left-padding;\n * }\n * }\n *\n * $index: if(\n * not core.$interaction-mode or core.$interaction-mode == press,\n * 1,\n * 2 // last child is always the `.rmd-ripple-container`\n * );\n * &:has(.rmd-icon:nth-last-child(#{$index})) {\n * padding-right: $addon-left-padding;\n *\n * @include utils.rtl {\n * padding-left; $addon-left-padding;\n * padding-right: $horizontal-padding;\n * }\n * }\n * ```\n */\nexport interface ChipClassNameOptions {\n className?: string;\n selectedClassName?: string;\n\n /** @defaultValue `\"solid\"` */\n theme?:
|
|
1
|
+
{"version":3,"sources":["../../src/chip/styles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { type BackgroundColor, cssUtils } from \"../cssUtils.js\";\nimport { bem } from \"../utils/bem.js\";\n\nconst styles = bem(\"rmd-chip\");\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-chip-gap\"?: string;\n \"--rmd-chip-height\"?: string;\n \"--rmd-chip-border-radius\"?: string | number;\n \"--rmd-chip-horizontal-padding\"?: string | number;\n \"--rmd-chip-vertical-padding\"?: string | number;\n \"--rmd-chip-solid-background-color\"?: string;\n \"--rmd-chip-solid-disabled-background-color\"?: string;\n \"--rmd-chip-solid-color\"?: string;\n \"--rmd-chip-theme-background-color\"?: string;\n \"--rmd-chip-theme-color\"?: string;\n \"--rmd-chip-outline-color\"?: string;\n \"--rmd-chip-outline-width\"?: string | number;\n \"--rmd-chip-outline-background-color\"?: string;\n \"--rmd-chip-outline-text-color\"?: string;\n }\n}\n\n/**\n * @since 6.3.1\n */\nexport type ChipTheme = \"outline\" | \"solid\";\n\n/**\n * @since 6.0.0\n *\n * Note for the future: Once Firefox supports the `:has` selector, the\n * `leftAddon` and `rightAddon` can be removed. The styles would automatically\n * apply the padding instead:\n *\n * ```scss\n * &:has(.rmd-icon:first-child, .rmd-avatar:first-child) {\n * padding-left: $addon-left-padding;\n *\n * @include utils.rtl {\n * padding-left: $horizontal-padding;\n * padding-right; $addon-left-padding;\n * }\n * }\n *\n * $index: if(\n * not core.$interaction-mode or core.$interaction-mode == press,\n * 1,\n * 2 // last child is always the `.rmd-ripple-container`\n * );\n * &:has(.rmd-icon:nth-last-child(#{$index})) {\n * padding-right: $addon-left-padding;\n *\n * @include utils.rtl {\n * padding-left; $addon-left-padding;\n * padding-right: $horizontal-padding;\n * }\n * }\n * ```\n */\nexport interface ChipClassNameOptions {\n className?: string;\n\n /**\n * An optional className to provide only while {@link selected} is `true`.\n */\n selectedClassName?: string;\n\n /** @defaultValue `\"solid\"` */\n theme?: ChipTheme;\n\n backgroundColor?: BackgroundColor;\n\n /** @defaultValue `false` */\n disabled?: boolean;\n\n /** @defaultValue `false` */\n selected?: boolean;\n\n /** @defaultValue `false` */\n selectedThemed?: boolean;\n\n /** @defaultValue `true` */\n noninteractive?: boolean;\n\n /** @defaultValue `false` */\n leftAddon?: boolean;\n\n /** @defaultValue `false` */\n rightAddon?: boolean;\n\n /** @defaultValue `false` */\n pressed?: boolean;\n pressedClassName?: string;\n}\n\n/**\n * @since 6.0.0\n */\nexport function chip(options: ChipClassNameOptions = {}): string {\n const {\n className,\n theme = \"solid\",\n pressed = false,\n disabled = false,\n selected = false,\n selectedThemed = false,\n selectedClassName,\n noninteractive = true,\n pressedClassName,\n leftAddon = false,\n rightAddon = false,\n backgroundColor,\n } = options;\n\n return cnb(\n styles({\n themed: !disabled && selected && selectedThemed,\n selected: !disabled && selected && !selectedThemed,\n solid: theme === \"solid\",\n outline: theme === \"outline\",\n disabled,\n \"left-addon\": leftAddon,\n \"right-addon\": rightAddon,\n pressed,\n }),\n selected && selectedClassName,\n pressedClassName,\n cssUtils({\n surface: !noninteractive,\n textColor: disabled ? \"text-disabled\" : undefined,\n backgroundColor,\n }),\n className\n );\n}\n\n/**\n * @since 6.0.0\n */\nexport interface ChipContentClassNameOptions {\n className?: string;\n}\n\n/**\n * @since 6.0.0\n */\nexport function chipContent(options: ChipContentClassNameOptions = {}): string {\n const { className } = options;\n\n return cnb(styles(\"content\"), className);\n}\n"],"names":["cnb","cssUtils","bem","styles","chip","options","className","theme","pressed","disabled","selected","selectedThemed","selectedClassName","noninteractive","pressedClassName","leftAddon","rightAddon","backgroundColor","themed","solid","outline","surface","textColor","undefined","chipContent"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAA+BC,QAAQ,QAAQ,iBAAiB;AAChE,SAASC,GAAG,QAAQ,kBAAkB;AAEtC,MAAMC,SAASD,IAAI;AA8FnB;;CAEC,GACD,OAAO,SAASE,KAAKC,UAAgC,CAAC,CAAC;IACrD,MAAM,EACJC,SAAS,EACTC,QAAQ,OAAO,EACfC,UAAU,KAAK,EACfC,WAAW,KAAK,EAChBC,WAAW,KAAK,EAChBC,iBAAiB,KAAK,EACtBC,iBAAiB,EACjBC,iBAAiB,IAAI,EACrBC,gBAAgB,EAChBC,YAAY,KAAK,EACjBC,aAAa,KAAK,EAClBC,eAAe,EAChB,GAAGZ;IAEJ,OAAOL,IACLG,OAAO;QACLe,QAAQ,CAACT,YAAYC,YAAYC;QACjCD,UAAU,CAACD,YAAYC,YAAY,CAACC;QACpCQ,OAAOZ,UAAU;QACjBa,SAASb,UAAU;QACnBE;QACA,cAAcM;QACd,eAAeC;QACfR;IACF,IACAE,YAAYE,mBACZE,kBACAb,SAAS;QACPoB,SAAS,CAACR;QACVS,WAAWb,WAAW,kBAAkBc;QACxCN;IACF,IACAX;AAEJ;AASA;;CAEC,GACD,OAAO,SAASkB,YAAYnB,UAAuC,CAAC,CAAC;IACnE,MAAM,EAAEC,SAAS,EAAE,GAAGD;IAEtB,OAAOL,IAAIG,OAAO,YAAYG;AAChC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type TextFieldProps } from "../form/TextField.js";
|
|
2
|
+
import { type DateFieldOptions } from "./useDateField.js";
|
|
3
|
+
/** @since 6.3.0 */
|
|
4
|
+
export interface NativeDateFieldProps extends Omit<TextFieldProps, keyof DateFieldOptions | "value">, Omit<DateFieldOptions, "ref"> {
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The `NativeDateField` is a simple wrapper around the `TextField` using the
|
|
8
|
+
* `useDateField` hook.
|
|
9
|
+
*
|
|
10
|
+
* @example Simple Example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { NativeDateField } from "@react-md/core/datetime/NativeDateField";
|
|
13
|
+
* import { type ReactElement } from "react";
|
|
14
|
+
*
|
|
15
|
+
* function Example(): ReactElement {
|
|
16
|
+
* return <NativeDateField label="Delivery Date" name="delivery" />;
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @see {@link https://react-md.dev/components/native-time-field | NativeDateField Demos}
|
|
21
|
+
* @see {@link https://react-md.dev/components/text-field | TextField Demos}
|
|
22
|
+
* @since 6.3.0
|
|
23
|
+
*/
|
|
24
|
+
export declare const NativeDateField: import("react").ForwardRefExoticComponent<NativeDateFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { TextField } from "../form/TextField.js";
|
|
5
|
+
import { useDateField } from "./useDateField.js";
|
|
6
|
+
/**
|
|
7
|
+
* The `NativeDateField` is a simple wrapper around the `TextField` using the
|
|
8
|
+
* `useDateField` hook.
|
|
9
|
+
*
|
|
10
|
+
* @example Simple Example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { NativeDateField } from "@react-md/core/datetime/NativeDateField";
|
|
13
|
+
* import { type ReactElement } from "react";
|
|
14
|
+
*
|
|
15
|
+
* function Example(): ReactElement {
|
|
16
|
+
* return <NativeDateField label="Delivery Date" name="delivery" />;
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @see {@link https://react-md.dev/components/native-time-field | NativeDateField Demos}
|
|
21
|
+
* @see {@link https://react-md.dev/components/text-field | TextField Demos}
|
|
22
|
+
* @since 6.3.0
|
|
23
|
+
*/ export const NativeDateField = /*#__PURE__*/ forwardRef(function NativeDateField(props, ref) {
|
|
24
|
+
const { id, min, max, step, onBlur, onInvalid, onChange, helpText, required, validationType, disableMessage, errorIcon, isErrored, getErrorIcon, getErrorMessage, onErrorChange, disableReset, defaultValue, ...remaining } = props;
|
|
25
|
+
const { name, form } = props;
|
|
26
|
+
const { fieldProps } = useDateField({
|
|
27
|
+
id,
|
|
28
|
+
ref,
|
|
29
|
+
name,
|
|
30
|
+
form,
|
|
31
|
+
min,
|
|
32
|
+
max,
|
|
33
|
+
step,
|
|
34
|
+
onBlur,
|
|
35
|
+
onChange,
|
|
36
|
+
onInvalid,
|
|
37
|
+
helpText,
|
|
38
|
+
required,
|
|
39
|
+
validationType,
|
|
40
|
+
disableMessage: disableMessage ?? (!min && !max && !step && !required),
|
|
41
|
+
errorIcon,
|
|
42
|
+
isErrored,
|
|
43
|
+
getErrorIcon,
|
|
44
|
+
getErrorMessage,
|
|
45
|
+
onErrorChange,
|
|
46
|
+
disableReset,
|
|
47
|
+
defaultValue
|
|
48
|
+
});
|
|
49
|
+
let { messageProps } = remaining;
|
|
50
|
+
if (fieldProps.messageProps) {
|
|
51
|
+
messageProps = {
|
|
52
|
+
...fieldProps.messageProps,
|
|
53
|
+
...remaining.messageProps
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return /*#__PURE__*/ _jsx(TextField, {
|
|
57
|
+
...remaining,
|
|
58
|
+
...fieldProps,
|
|
59
|
+
messageProps: messageProps
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=NativeDateField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/datetime/NativeDateField.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef } from \"react\";\n\nimport { TextField, type TextFieldProps } from \"../form/TextField.js\";\nimport { type DateFieldOptions, useDateField } from \"./useDateField.js\";\n\n/** @since 6.3.0 */\nexport interface NativeDateFieldProps\n extends Omit<TextFieldProps, keyof DateFieldOptions | \"value\">,\n Omit<DateFieldOptions, \"ref\"> {}\n\n/**\n * The `NativeDateField` is a simple wrapper around the `TextField` using the\n * `useDateField` hook.\n *\n * @example Simple Example\n * ```tsx\n * import { NativeDateField } from \"@react-md/core/datetime/NativeDateField\";\n * import { type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return <NativeDateField label=\"Delivery Date\" name=\"delivery\" />;\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/native-time-field | NativeDateField Demos}\n * @see {@link https://react-md.dev/components/text-field | TextField Demos}\n * @since 6.3.0\n */\nexport const NativeDateField = forwardRef<\n HTMLInputElement,\n NativeDateFieldProps\n>(function NativeDateField(props, ref) {\n const {\n id,\n min,\n max,\n step,\n onBlur,\n onInvalid,\n onChange,\n helpText,\n required,\n validationType,\n disableMessage,\n errorIcon,\n isErrored,\n getErrorIcon,\n getErrorMessage,\n onErrorChange,\n disableReset,\n defaultValue,\n ...remaining\n } = props;\n const { name, form } = props;\n const { fieldProps } = useDateField({\n id,\n ref,\n name,\n form,\n min,\n max,\n step,\n onBlur,\n onChange,\n onInvalid,\n helpText,\n required,\n validationType,\n disableMessage: disableMessage ?? (!min && !max && !step && !required),\n errorIcon,\n isErrored,\n getErrorIcon,\n getErrorMessage,\n onErrorChange,\n disableReset,\n defaultValue,\n });\n\n let { messageProps } = remaining;\n if (fieldProps.messageProps) {\n messageProps = {\n ...fieldProps.messageProps,\n ...remaining.messageProps,\n };\n }\n\n return (\n <TextField {...remaining} {...fieldProps} messageProps={messageProps} />\n );\n});\n"],"names":["forwardRef","TextField","useDateField","NativeDateField","props","ref","id","min","max","step","onBlur","onInvalid","onChange","helpText","required","validationType","disableMessage","errorIcon","isErrored","getErrorIcon","getErrorMessage","onErrorChange","disableReset","defaultValue","remaining","name","form","fieldProps","messageProps"],"mappings":"AAAA;;AAEA,SAASA,UAAU,QAAQ,QAAQ;AAEnC,SAASC,SAAS,QAA6B,uBAAuB;AACtE,SAAgCC,YAAY,QAAQ,oBAAoB;AAOxE;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,MAAMC,gCAAkBH,WAG7B,SAASG,gBAAgBC,KAAK,EAAEC,GAAG;IACnC,MAAM,EACJC,EAAE,EACFC,GAAG,EACHC,GAAG,EACHC,IAAI,EACJC,MAAM,EACNC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,QAAQ,EACRC,cAAc,EACdC,cAAc,EACdC,SAAS,EACTC,SAAS,EACTC,YAAY,EACZC,eAAe,EACfC,aAAa,EACbC,YAAY,EACZC,YAAY,EACZ,GAAGC,WACJ,GAAGpB;IACJ,MAAM,EAAEqB,IAAI,EAAEC,IAAI,EAAE,GAAGtB;IACvB,MAAM,EAAEuB,UAAU,EAAE,GAAGzB,aAAa;QAClCI;QACAD;QACAoB;QACAC;QACAnB;QACAC;QACAC;QACAC;QACAE;QACAD;QACAE;QACAC;QACAC;QACAC,gBAAgBA,kBAAmB,CAAA,CAACT,OAAO,CAACC,OAAO,CAACC,QAAQ,CAACK,QAAO;QACpEG;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;IACF;IAEA,IAAI,EAAEK,YAAY,EAAE,GAAGJ;IACvB,IAAIG,WAAWC,YAAY,EAAE;QAC3BA,eAAe;YACb,GAAGD,WAAWC,YAAY;YAC1B,GAAGJ,UAAUI,YAAY;QAC3B;IACF;IAEA,qBACE,KAAC3B;QAAW,GAAGuB,SAAS;QAAG,GAAGG,UAAU;QAAEC,cAAcA;;AAE5D,GAAG"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type TextFieldProps } from "../form/TextField.js";
|
|
2
|
+
import { type TimeFieldOptions } from "./useTimeField.js";
|
|
3
|
+
/**
|
|
4
|
+
* @since 6.3.0
|
|
5
|
+
*/
|
|
6
|
+
export interface NativeTimeFieldProps extends Omit<TextFieldProps, keyof TimeFieldOptions | "value">, Omit<TimeFieldOptions, "ref"> {
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The `NativeTimeField` is a simple wrapper around the `TextField` using the
|
|
10
|
+
* `useTimeField` hook.
|
|
11
|
+
*
|
|
12
|
+
* @example Simple Example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* import { NativeTimeField } from "@react-md/core/datetime/NativeTimeField";
|
|
15
|
+
* import { type ReactElement } from "react";
|
|
16
|
+
*
|
|
17
|
+
* function Example(): ReactElement {
|
|
18
|
+
* return <NativeTimeField label="Time" name="appt" />;
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @see {@link https://react-md.dev/components/native-time-field | NativeTimeField Demos}
|
|
23
|
+
* @see {@link https://react-md.dev/components/text-field | TextField Demos}
|
|
24
|
+
* @since 6.3.0
|
|
25
|
+
*/
|
|
26
|
+
export declare const NativeTimeField: import("react").ForwardRefExoticComponent<NativeTimeFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { TextField } from "../form/TextField.js";
|
|
5
|
+
import { useTimeField } from "./useTimeField.js";
|
|
6
|
+
/**
|
|
7
|
+
* The `NativeTimeField` is a simple wrapper around the `TextField` using the
|
|
8
|
+
* `useTimeField` hook.
|
|
9
|
+
*
|
|
10
|
+
* @example Simple Example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { NativeTimeField } from "@react-md/core/datetime/NativeTimeField";
|
|
13
|
+
* import { type ReactElement } from "react";
|
|
14
|
+
*
|
|
15
|
+
* function Example(): ReactElement {
|
|
16
|
+
* return <NativeTimeField label="Time" name="appt" />;
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @see {@link https://react-md.dev/components/native-time-field | NativeTimeField Demos}
|
|
21
|
+
* @see {@link https://react-md.dev/components/text-field | TextField Demos}
|
|
22
|
+
* @since 6.3.0
|
|
23
|
+
*/ export const NativeTimeField = /*#__PURE__*/ forwardRef(function NativeTimeField(props, ref) {
|
|
24
|
+
const { id, min, max, step, onBlur, onInvalid, onChange, helpText, required, validationType, disableMessage, errorIcon, isErrored, getErrorIcon, getErrorMessage, onErrorChange, disableReset, defaultValue, ...remaining } = props;
|
|
25
|
+
const { name, form } = props;
|
|
26
|
+
const { fieldProps } = useTimeField({
|
|
27
|
+
id,
|
|
28
|
+
ref,
|
|
29
|
+
name,
|
|
30
|
+
form,
|
|
31
|
+
min,
|
|
32
|
+
max,
|
|
33
|
+
step,
|
|
34
|
+
onBlur,
|
|
35
|
+
onChange,
|
|
36
|
+
onInvalid,
|
|
37
|
+
helpText,
|
|
38
|
+
required,
|
|
39
|
+
validationType,
|
|
40
|
+
disableMessage: disableMessage ?? (!min && !max && !step && !required),
|
|
41
|
+
errorIcon,
|
|
42
|
+
isErrored,
|
|
43
|
+
getErrorIcon,
|
|
44
|
+
getErrorMessage,
|
|
45
|
+
onErrorChange,
|
|
46
|
+
disableReset,
|
|
47
|
+
defaultValue
|
|
48
|
+
});
|
|
49
|
+
let { messageProps } = remaining;
|
|
50
|
+
if (fieldProps.messageProps) {
|
|
51
|
+
messageProps = {
|
|
52
|
+
...fieldProps.messageProps,
|
|
53
|
+
...remaining.messageProps
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return /*#__PURE__*/ _jsx(TextField, {
|
|
57
|
+
...remaining,
|
|
58
|
+
...fieldProps,
|
|
59
|
+
messageProps: messageProps
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=NativeTimeField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/datetime/NativeTimeField.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef } from \"react\";\n\nimport { TextField, type TextFieldProps } from \"../form/TextField.js\";\nimport { type TimeFieldOptions, useTimeField } from \"./useTimeField.js\";\n\n/**\n * @since 6.3.0\n */\nexport interface NativeTimeFieldProps\n extends Omit<TextFieldProps, keyof TimeFieldOptions | \"value\">,\n Omit<TimeFieldOptions, \"ref\"> {}\n\n/**\n * The `NativeTimeField` is a simple wrapper around the `TextField` using the\n * `useTimeField` hook.\n *\n * @example Simple Example\n * ```tsx\n * import { NativeTimeField } from \"@react-md/core/datetime/NativeTimeField\";\n * import { type ReactElement } from \"react\";\n *\n * function Example(): ReactElement {\n * return <NativeTimeField label=\"Time\" name=\"appt\" />;\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/native-time-field | NativeTimeField Demos}\n * @see {@link https://react-md.dev/components/text-field | TextField Demos}\n * @since 6.3.0\n */\nexport const NativeTimeField = forwardRef<\n HTMLInputElement,\n NativeTimeFieldProps\n>(function NativeTimeField(props, ref) {\n const {\n id,\n min,\n max,\n step,\n onBlur,\n onInvalid,\n onChange,\n helpText,\n required,\n validationType,\n disableMessage,\n errorIcon,\n isErrored,\n getErrorIcon,\n getErrorMessage,\n onErrorChange,\n disableReset,\n defaultValue,\n ...remaining\n } = props;\n const { name, form } = props;\n const { fieldProps } = useTimeField({\n id,\n ref,\n name,\n form,\n min,\n max,\n step,\n onBlur,\n onChange,\n onInvalid,\n helpText,\n required,\n validationType,\n disableMessage: disableMessage ?? (!min && !max && !step && !required),\n errorIcon,\n isErrored,\n getErrorIcon,\n getErrorMessage,\n onErrorChange,\n disableReset,\n defaultValue,\n });\n\n let { messageProps } = remaining;\n if (fieldProps.messageProps) {\n messageProps = {\n ...fieldProps.messageProps,\n ...remaining.messageProps,\n };\n }\n\n return (\n <TextField {...remaining} {...fieldProps} messageProps={messageProps} />\n );\n});\n"],"names":["forwardRef","TextField","useTimeField","NativeTimeField","props","ref","id","min","max","step","onBlur","onInvalid","onChange","helpText","required","validationType","disableMessage","errorIcon","isErrored","getErrorIcon","getErrorMessage","onErrorChange","disableReset","defaultValue","remaining","name","form","fieldProps","messageProps"],"mappings":"AAAA;;AAEA,SAASA,UAAU,QAAQ,QAAQ;AAEnC,SAASC,SAAS,QAA6B,uBAAuB;AACtE,SAAgCC,YAAY,QAAQ,oBAAoB;AASxE;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,MAAMC,gCAAkBH,WAG7B,SAASG,gBAAgBC,KAAK,EAAEC,GAAG;IACnC,MAAM,EACJC,EAAE,EACFC,GAAG,EACHC,GAAG,EACHC,IAAI,EACJC,MAAM,EACNC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,QAAQ,EACRC,cAAc,EACdC,cAAc,EACdC,SAAS,EACTC,SAAS,EACTC,YAAY,EACZC,eAAe,EACfC,aAAa,EACbC,YAAY,EACZC,YAAY,EACZ,GAAGC,WACJ,GAAGpB;IACJ,MAAM,EAAEqB,IAAI,EAAEC,IAAI,EAAE,GAAGtB;IACvB,MAAM,EAAEuB,UAAU,EAAE,GAAGzB,aAAa;QAClCI;QACAD;QACAoB;QACAC;QACAnB;QACAC;QACAC;QACAC;QACAE;QACAD;QACAE;QACAC;QACAC;QACAC,gBAAgBA,kBAAmB,CAAA,CAACT,OAAO,CAACC,OAAO,CAACC,QAAQ,CAACK,QAAO;QACpEG;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;IACF;IAEA,IAAI,EAAEK,YAAY,EAAE,GAAGJ;IACvB,IAAIG,WAAWC,YAAY,EAAE;QAC3BA,eAAe;YACb,GAAGD,WAAWC,YAAY;YAC1B,GAAGJ,UAAUI,YAAY;QAC3B;IACF;IAEA,qBACE,KAAC3B;QAAW,GAAGuB,SAAS;QAAG,GAAGG,UAAU;QAAEC,cAAcA;;AAE5D,GAAG"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { type InputHTMLAttributes } from "react";
|
|
2
|
+
import { type ProvidedFormMessageProps, type ProvidedTextFieldProps, type TextFieldHookOptions, type TextFieldImplementation, type TextFieldWithMessageImplementation } from "../form/useTextField.js";
|
|
3
|
+
/**
|
|
4
|
+
* @since 6.3.0
|
|
5
|
+
*/
|
|
6
|
+
export interface DateFieldConstraints {
|
|
7
|
+
/**
|
|
8
|
+
* This **must** be in the format `yyyy-mm-dd`
|
|
9
|
+
*
|
|
10
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/date#min | min attribute}
|
|
11
|
+
*/
|
|
12
|
+
min?: string;
|
|
13
|
+
/**
|
|
14
|
+
* This **must** be in the format `yyyy-mm-dd`
|
|
15
|
+
*
|
|
16
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/date#max | max attribute}
|
|
17
|
+
*/
|
|
18
|
+
max?: string;
|
|
19
|
+
/**
|
|
20
|
+
* For date inputs, the value of step is given in days; and is treated as a
|
|
21
|
+
* number of milliseconds equal to 86,400,000 times the step value (the
|
|
22
|
+
* underlying numeric value is in milliseconds). The default value of step is
|
|
23
|
+
* 1, indicating 1 day.
|
|
24
|
+
*
|
|
25
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/date#step | step attribute}
|
|
26
|
+
*/
|
|
27
|
+
step?: number | "any";
|
|
28
|
+
}
|
|
29
|
+
/** @since 6.3.0 */
|
|
30
|
+
export interface DateFieldOptions extends Omit<TextFieldHookOptions, "isNumber" | "counter" | "pattern" | "maxLength" | "minLength" | "disableMaxLength">, DateFieldConstraints {
|
|
31
|
+
}
|
|
32
|
+
/** @since 6.3.0 */
|
|
33
|
+
export interface ProvidedDateFieldProps extends Omit<ProvidedTextFieldProps, "value">, Omit<DateFieldConstraints, "step"> {
|
|
34
|
+
type: "date";
|
|
35
|
+
step?: number | "any";
|
|
36
|
+
defaultValue: Required<InputHTMLAttributes<HTMLInputElement>>["defaultValue"];
|
|
37
|
+
}
|
|
38
|
+
/** @since 6.3.0 */
|
|
39
|
+
export interface ProvidedDateFieldMessageProps extends ProvidedDateFieldProps {
|
|
40
|
+
/**
|
|
41
|
+
* These props will be defined as long as the `disableMessage` prop is not
|
|
42
|
+
* `true` from the `useTextField` hook.
|
|
43
|
+
*/
|
|
44
|
+
messageProps: ProvidedFormMessageProps;
|
|
45
|
+
}
|
|
46
|
+
/** @since 6.3.0 */
|
|
47
|
+
export interface DateFieldImplementation extends Omit<TextFieldImplementation, "fieldProps"> {
|
|
48
|
+
fieldProps: ProvidedDateFieldProps;
|
|
49
|
+
}
|
|
50
|
+
/** @since 6.3.0 */
|
|
51
|
+
export interface DateFieldWithMessageImplementation extends Omit<TextFieldWithMessageImplementation, "fieldProps"> {
|
|
52
|
+
fieldProps: ProvidedDateFieldMessageProps;
|
|
53
|
+
}
|
|
54
|
+
/** @since 6.3.0 */
|
|
55
|
+
export interface ValidatedDateFieldImplementation extends DateFieldImplementation {
|
|
56
|
+
fieldProps: ProvidedDateFieldProps | ProvidedDateFieldMessageProps;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The `useDateField` is a small wrapper around the {@link useTextField} to be used
|
|
60
|
+
* with `<input type="date" />`. It is used in the `NativeDateField` if an example
|
|
61
|
+
* implementation would like to be seen.
|
|
62
|
+
*
|
|
63
|
+
* @example Simple Example
|
|
64
|
+
* ```tsx
|
|
65
|
+
* import { useDateField } from "@react-md/core/datetime/useDateField";
|
|
66
|
+
* import { TextField } from "@react-md/core/form/TextField";
|
|
67
|
+
* import { type ReactElement } from "react";
|
|
68
|
+
*
|
|
69
|
+
* function Example(): ReactElement {
|
|
70
|
+
* const { value, fieldProps, error, errorMessage } = useDateField({
|
|
71
|
+
* name: "delivery",
|
|
72
|
+
* required: true,
|
|
73
|
+
* min: "2025-01-01",
|
|
74
|
+
* max: "2026-01-01",
|
|
75
|
+
* disableMessage: true,
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* // value: `""` or `"yyyy-mm-dd"`
|
|
79
|
+
*
|
|
80
|
+
* return <TextField label="Delivery Date" {...fieldProps} />
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @since 6.3.0
|
|
85
|
+
* @see {@link https://react-md.dev/components/native-date-field | NativeDateField Demos}
|
|
86
|
+
* @see {@link https://react-md.dev/hooks/use-date-field | useDateField Demos}
|
|
87
|
+
*/
|
|
88
|
+
export declare function useDateField(options: DateFieldOptions & {
|
|
89
|
+
disableMessage: true;
|
|
90
|
+
}): DateFieldImplementation;
|
|
91
|
+
/**
|
|
92
|
+
* The `useDateField` is a small wrapper around the {@link useTextField} to be used
|
|
93
|
+
* with `<input type="date" />`. It is used in the `NativeDateField` if an example
|
|
94
|
+
* implementation would like to be seen.
|
|
95
|
+
*
|
|
96
|
+
* @example Simple Example
|
|
97
|
+
* ```tsx
|
|
98
|
+
* import { useDateField } from "@react-md/core/datetime/useDateField";
|
|
99
|
+
* import { TextField } from "@react-md/core/form/TextField";
|
|
100
|
+
* import { type ReactElement } from "react";
|
|
101
|
+
*
|
|
102
|
+
* function Example(): ReactElement {
|
|
103
|
+
* const { value, fieldProps } = useDateField({
|
|
104
|
+
* name: "delivery",
|
|
105
|
+
* required: true,
|
|
106
|
+
* min: "2025-01-01",
|
|
107
|
+
* max: "2026-01-01",
|
|
108
|
+
* });
|
|
109
|
+
*
|
|
110
|
+
* // value: `""` or `"yyyy-mm-dd"`
|
|
111
|
+
*
|
|
112
|
+
* return <TextField label="Delivery Date" {...fieldProps} />
|
|
113
|
+
* }
|
|
114
|
+
* ```
|
|
115
|
+
*
|
|
116
|
+
* @since 6.3.0
|
|
117
|
+
* @see {@link https://react-md.dev/components/native-date-field | NativeDateField Demos}
|
|
118
|
+
* @see {@link https://react-md.dev/hooks/use-date-field | useDateField Demos}
|
|
119
|
+
*/
|
|
120
|
+
export declare function useDateField(options: DateFieldOptions): DateFieldWithMessageImplementation;
|