@react-md/core 6.3.0 → 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.
Files changed (201) hide show
  1. package/dist/_base.scss +1 -1
  2. package/dist/app-bar/styles.d.ts +0 -2
  3. package/dist/app-bar/styles.js.map +1 -1
  4. package/dist/autocomplete/types.d.ts +12 -0
  5. package/dist/autocomplete/types.js.map +1 -1
  6. package/dist/avatar/Avatar.d.ts +0 -10
  7. package/dist/avatar/Avatar.js.map +1 -1
  8. package/dist/avatar/styles.d.ts +10 -0
  9. package/dist/avatar/styles.js.map +1 -1
  10. package/dist/badge/Badge.d.ts +11 -0
  11. package/dist/badge/Badge.js.map +1 -1
  12. package/dist/badge/styles.d.ts +0 -8
  13. package/dist/badge/styles.js.map +1 -1
  14. package/dist/box/_box.scss +8 -8
  15. package/dist/box/styles.d.ts +9 -0
  16. package/dist/box/styles.js.map +1 -1
  17. package/dist/button/_button.scss +4 -0
  18. package/dist/button/styles.d.ts +5 -1
  19. package/dist/button/styles.js.map +1 -1
  20. package/dist/card/Card.d.ts +0 -7
  21. package/dist/card/Card.js.map +1 -1
  22. package/dist/card/styles.d.ts +6 -0
  23. package/dist/card/styles.js +8 -8
  24. package/dist/card/styles.js.map +1 -1
  25. package/dist/chip/Chip.d.ts +6 -13
  26. package/dist/chip/Chip.js.map +1 -1
  27. package/dist/chip/styles.d.ts +26 -1
  28. package/dist/chip/styles.js.map +1 -1
  29. package/dist/dialog/styles.d.ts +5 -2
  30. package/dist/dialog/styles.js.map +1 -1
  31. package/dist/divider/styles.d.ts +1 -1
  32. package/dist/divider/styles.js.map +1 -1
  33. package/dist/error-boundary/ErrorBoundary.js.map +1 -1
  34. package/dist/files/validation.js.map +1 -1
  35. package/dist/form/InputToggle.js.map +1 -1
  36. package/dist/form/Label.d.ts +0 -10
  37. package/dist/form/Label.js.map +1 -1
  38. package/dist/form/Slider.d.ts +4 -0
  39. package/dist/form/Slider.js.map +1 -1
  40. package/dist/form/Switch.js.map +1 -1
  41. package/dist/form/TextArea.js.map +1 -1
  42. package/dist/form/TextFieldContainer.d.ts +0 -13
  43. package/dist/form/TextFieldContainer.js.map +1 -1
  44. package/dist/form/_select.scss +5 -1
  45. package/dist/form/_text-area.scss +2 -1
  46. package/dist/form/_text-field.scss +1 -0
  47. package/dist/form/types.d.ts +20 -0
  48. package/dist/form/types.js.map +1 -1
  49. package/dist/interaction/types.d.ts +5 -1
  50. package/dist/interaction/types.js.map +1 -1
  51. package/dist/link/Link.d.ts +0 -7
  52. package/dist/link/Link.js.map +1 -1
  53. package/dist/link/styles.d.ts +7 -0
  54. package/dist/link/styles.js.map +1 -1
  55. package/dist/list/List.d.ts +5 -20
  56. package/dist/list/List.js.map +1 -1
  57. package/dist/list/ListItem.d.ts +4 -38
  58. package/dist/list/ListItem.js.map +1 -1
  59. package/dist/list/listItemStyles.d.ts +24 -2
  60. package/dist/list/listItemStyles.js.map +1 -1
  61. package/dist/list/listStyles.d.ts +17 -2
  62. package/dist/list/listStyles.js.map +1 -1
  63. package/dist/menu/Menu.js.map +1 -1
  64. package/dist/navigation/NavItem.d.ts +4 -1
  65. package/dist/navigation/NavItem.js.map +1 -1
  66. package/dist/navigation/navItemStyles.d.ts +7 -0
  67. package/dist/navigation/navItemStyles.js.map +1 -1
  68. package/dist/overlay/Overlay.d.ts +4 -23
  69. package/dist/overlay/Overlay.js.map +1 -1
  70. package/dist/overlay/styles.d.ts +26 -8
  71. package/dist/overlay/styles.js.map +1 -1
  72. package/dist/progress/LinearProgress.d.ts +4 -9
  73. package/dist/progress/LinearProgress.js.map +1 -1
  74. package/dist/progress/circularProgressStyles.d.ts +6 -0
  75. package/dist/progress/circularProgressStyles.js.map +1 -1
  76. package/dist/progress/linearProgressStyles.d.ts +20 -5
  77. package/dist/progress/linearProgressStyles.js.map +1 -1
  78. package/dist/progress/types.d.ts +0 -9
  79. package/dist/progress/types.js.map +1 -1
  80. package/dist/segmented-button/SegmentedButton.d.ts +7 -12
  81. package/dist/segmented-button/SegmentedButton.js.map +1 -1
  82. package/dist/segmented-button/segmentedButtonStyles.d.ts +26 -3
  83. package/dist/segmented-button/segmentedButtonStyles.js.map +1 -1
  84. package/dist/sheet/Sheet.d.ts +0 -12
  85. package/dist/sheet/Sheet.js.map +1 -1
  86. package/dist/sheet/styles.d.ts +12 -0
  87. package/dist/sheet/styles.js.map +1 -1
  88. package/dist/snackbar/Toast.d.ts +2 -13
  89. package/dist/snackbar/Toast.js.map +1 -1
  90. package/dist/snackbar/ToastManager.js.map +1 -1
  91. package/dist/snackbar/toastStyles.d.ts +17 -2
  92. package/dist/snackbar/toastStyles.js.map +1 -1
  93. package/dist/tabs/Tab.d.ts +2 -41
  94. package/dist/tabs/Tab.js.map +1 -1
  95. package/dist/tabs/tabStyles.d.ts +45 -4
  96. package/dist/tabs/tabStyles.js.map +1 -1
  97. package/dist/test-utils/mocks/IntersectionObserver.js.map +1 -1
  98. package/dist/test-utils/mocks/ResizeObserver.js.map +1 -1
  99. package/dist/test-utils/utils/createFileList.js.map +1 -1
  100. package/dist/theme/_theme.scss +0 -1
  101. package/dist/theme/getDerivedTheme.d.ts +0 -24
  102. package/dist/theme/getDerivedTheme.js.map +1 -1
  103. package/dist/theme/types.d.ts +25 -0
  104. package/dist/theme/types.js.map +1 -1
  105. package/dist/tooltip/Tooltip.d.ts +4 -32
  106. package/dist/tooltip/Tooltip.js.map +1 -1
  107. package/dist/tooltip/styles.d.ts +38 -1
  108. package/dist/tooltip/styles.js +1 -1
  109. package/dist/tooltip/styles.js.map +1 -1
  110. package/dist/transition/SkeletonPlaceholder.d.ts +0 -7
  111. package/dist/transition/SkeletonPlaceholder.js.map +1 -1
  112. package/dist/transition/Slide.js.map +1 -1
  113. package/dist/transition/skeletonPlaceholderUtils.d.ts +7 -0
  114. package/dist/transition/skeletonPlaceholderUtils.js.map +1 -1
  115. package/dist/transition/useMaxWidthTransition.d.ts +14 -2
  116. package/dist/transition/useMaxWidthTransition.js.map +1 -1
  117. package/dist/transition/useSlideTransition.d.ts +5 -0
  118. package/dist/transition/useSlideTransition.js.map +1 -1
  119. package/dist/tree/Tree.d.ts +5 -9
  120. package/dist/tree/Tree.js.map +1 -1
  121. package/dist/tree/styles.d.ts +9 -1
  122. package/dist/tree/styles.js.map +1 -1
  123. package/dist/typography/Mark.d.ts +4 -1
  124. package/dist/typography/Mark.js.map +1 -1
  125. package/dist/typography/TextContainer.d.ts +0 -6
  126. package/dist/typography/TextContainer.js.map +1 -1
  127. package/dist/typography/markStyles.d.ts +5 -0
  128. package/dist/typography/markStyles.js.map +1 -1
  129. package/dist/typography/textContainerStyles.d.ts +6 -0
  130. package/dist/typography/textContainerStyles.js.map +1 -1
  131. package/dist/typography/typographyStyles.d.ts +9 -0
  132. package/dist/typography/typographyStyles.js.map +1 -1
  133. package/dist/useResizeObserver.js.map +1 -1
  134. package/dist/window-splitter/WindowSplitter.d.ts +5 -19
  135. package/dist/window-splitter/WindowSplitter.js.map +1 -1
  136. package/dist/window-splitter/styles.d.ts +27 -3
  137. package/dist/window-splitter/styles.js.map +1 -1
  138. package/package.json +8 -8
  139. package/src/app-bar/styles.ts +0 -2
  140. package/src/autocomplete/types.ts +17 -0
  141. package/src/avatar/Avatar.tsx +0 -11
  142. package/src/avatar/styles.ts +11 -0
  143. package/src/badge/Badge.tsx +12 -0
  144. package/src/badge/styles.ts +0 -9
  145. package/src/box/styles.ts +9 -0
  146. package/src/button/styles.ts +5 -1
  147. package/src/card/Card.tsx +0 -8
  148. package/src/card/styles.ts +15 -8
  149. package/src/chip/Chip.tsx +9 -15
  150. package/src/chip/styles.ts +29 -1
  151. package/src/dialog/styles.ts +5 -2
  152. package/src/divider/styles.ts +1 -1
  153. package/src/form/InputToggle.tsx +2 -0
  154. package/src/form/Label.tsx +0 -11
  155. package/src/form/Slider.tsx +6 -0
  156. package/src/form/Switch.tsx +2 -0
  157. package/src/form/TextArea.tsx +2 -0
  158. package/src/form/TextFieldContainer.tsx +0 -14
  159. package/src/form/types.ts +29 -0
  160. package/src/interaction/types.ts +5 -1
  161. package/src/link/Link.tsx +0 -8
  162. package/src/link/styles.ts +8 -0
  163. package/src/list/List.tsx +7 -24
  164. package/src/list/ListItem.tsx +7 -43
  165. package/src/list/listItemStyles.ts +26 -2
  166. package/src/list/listStyles.ts +18 -2
  167. package/src/menu/Menu.tsx +2 -0
  168. package/src/navigation/NavItem.tsx +6 -2
  169. package/src/navigation/navItemStyles.ts +8 -0
  170. package/src/overlay/Overlay.tsx +4 -26
  171. package/src/overlay/styles.ts +29 -10
  172. package/src/progress/LinearProgress.tsx +8 -10
  173. package/src/progress/circularProgressStyles.ts +7 -0
  174. package/src/progress/linearProgressStyles.ts +22 -5
  175. package/src/progress/types.ts +0 -10
  176. package/src/segmented-button/SegmentedButton.tsx +14 -15
  177. package/src/segmented-button/segmentedButtonStyles.ts +28 -3
  178. package/src/sheet/Sheet.tsx +0 -13
  179. package/src/sheet/styles.ts +13 -0
  180. package/src/snackbar/Toast.tsx +2 -15
  181. package/src/snackbar/toastStyles.ts +20 -2
  182. package/src/tabs/Tab.tsx +4 -49
  183. package/src/tabs/tabStyles.ts +52 -4
  184. package/src/theme/getDerivedTheme.ts +0 -26
  185. package/src/theme/types.ts +26 -0
  186. package/src/tooltip/Tooltip.tsx +4 -36
  187. package/src/tooltip/styles.ts +43 -2
  188. package/src/transition/SkeletonPlaceholder.tsx +0 -8
  189. package/src/transition/Slide.tsx +2 -0
  190. package/src/transition/skeletonPlaceholderUtils.ts +8 -0
  191. package/src/transition/useMaxWidthTransition.ts +17 -2
  192. package/src/transition/useSlideTransition.ts +8 -0
  193. package/src/tree/Tree.tsx +5 -10
  194. package/src/tree/styles.ts +10 -1
  195. package/src/typography/Mark.tsx +6 -2
  196. package/src/typography/TextContainer.tsx +0 -7
  197. package/src/typography/markStyles.ts +6 -0
  198. package/src/typography/textContainerStyles.ts +7 -0
  199. package/src/typography/typographyStyles.ts +10 -0
  200. package/src/window-splitter/WindowSplitter.tsx +9 -22
  201. package/src/window-splitter/styles.ts +31 -3
@@ -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\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-card-background-color\"?: string;\n \"--rmd-card-color\"?: string;\n \"--rmd-card-secondary-color\"?: string;\n }\n}\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;AAyB9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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"}
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"}
@@ -1,3 +1,9 @@
1
+ declare module "react" {
2
+ interface CSSProperties {
3
+ "--rmd-card-background-color"?: string;
4
+ "--rmd-card-color"?: string;
5
+ }
6
+ }
1
7
  /** @since 6.0.0 */
2
8
  export interface CardClassNameOptions {
3
9
  className?: string;
@@ -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 cardStyles = bem("rmd-card");
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(cardStyles({
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(cardStyles("header", {
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(cardStyles("header-content"), className);
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(cardStyles("title"), className);
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(cardStyles("subtitle"), className);
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(cardStyles("content", {
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(cardStyles("footer"), className);
59
+ return cnb(styles("footer"), className);
60
60
  }
61
61
 
62
62
  //# sourceMappingURL=styles.js.map
@@ -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 cardStyles = bem(\"rmd-card\");\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 cardStyles({\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 cardStyles(\"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(cardStyles(\"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(cardStyles(\"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(cardStyles(\"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 cardStyles(\"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(cardStyles(\"footer\"), className);\n}\n"],"names":["cnb","cssUtils","bem","cardStyles","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,aAAaD,IAAI;AAgCvB;;CAEC,GACD,OAAO,SAASE,KAAKC,UAAgC,CAAC,CAAC;IACrD,MAAM,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,YAAY,EAAE,GAAGJ;IAExD,OAAOL,IACLG,WAAW;QACTI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nbuilder\";\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,iBA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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"}
@@ -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
- declare module "react" {
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?: "outline" | "solid";
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.
@@ -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":"AAAA;;AAEA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAKEC,UAAU,QACL,QAAQ;AAGf,SAASC,OAAO,QAAQ,oBAAoB;AAE5C,SAASC,qBAAqB,QAAQ,0CAA0C;AAChF,SAASC,yBAAyB,QAAQ,8CAA8C;AACxF,SAASC,qBAAqB,QAAQ,yCAAyC;AAE/E,SAASC,IAAI,EAAEC,WAAW,QAAQ,cAAc;AAgJhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+CC,GACD,OAAO,MAAMC,qBAAOP,WAClB,SAASO,KAAKC,KAAK,EAAEC,GAAG;IACtB,MAAM,EACJ,gBAAgBC,WAAW,EAC3BC,QAAQ,OAAO,EACfC,SAAS,EACTC,WAAW,KAAK,EAChBC,WAAW,KAAK,EAChBC,QAAQ,EACRC,iBAAiB,KAAK,EACtBC,iBAAiB,EACjBC,cAAcC,gBAAgB,EAC9BC,oBAAoB,KAAK,EACzBC,eAAe,EACfC,iBAAiB,KAAK,EACtBC,aAAa,EACbC,wBAAwB,KAAK,EAC7BC,UAAUC,YAAY,EACtBC,OAAO,EACPC,SAAS,EACTC,OAAO,EACPC,WAAW,EACXC,SAAS,EACTC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,UAAU,EACVC,WAAW,EACXC,WAAWC,aAAa,EACxBC,YAAYC,cAAc,EAC1BC,YAAY,EACZC,YAAY,EACZC,gBAAgB,EAChBC,qBAAqB,KAAK,EAC1B,GAAGC,WACJ,GAAGrC;IAEJ,IAAIsC;IACJ,IAAI,CAACxB,gBAAgB;QACnBwB,cAAc;YACZ,gBAAgBpC,eAAgB,CAAA,CAAC,CAACK,YAAYgC,SAAQ;YACtDC,MAAM;YACNlC;QACF;IACF;IAEA,IAAImC,UAAUvB;IACd,IAAI,CAACkB,oBAAoB;QACvBK,wBACE,KAACC;YACCC,OAAOT;YACN,GAAGD,YAAY;YAChB7B,WAAWb,IACTO,YAAY;gBAAEM,WAAW+B;YAAiB,IAC1CF,cAAc7B;sBAGfc;;IAGP;IAEA,IAAIW,YAAYC;IAChB,IAAIC,aAAaC;IACjB,MAAMY,mBAAmBnD,QAAQ,YAAYkB;IAC7C,MAAMkC,mBACJ,CAACrC,kBACD,OAAOD,aAAa,aACpB,OAAQK,CAAAA,oBAAoBoB,iBAAiBF,aAAY,MACvD;IACJ,MAAMpB,eAAed,sBAAsB;QACzCkD,SAASF;QACTG,cAAc,CAAC,CAACxC;QAChBD,UAAU,CAACuC;QACXG,mBAAmBhC;IACrB;IACA,IAAI6B,kBAAkB;QACpB,IAAIjC,mBAAmB;YACrBmB,aAAarB;QACf,OAAO;YACLmB,YAAYnB;QACd;IACF;IAEA,MAAM,EAAEuC,OAAO,EAAEC,gBAAgB,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GACpD1D,sBAAsB;QACpB2D,MAAMtC,gBAAgB,SAASwB;QAC/BpB;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAtB,UAAUA,YAAYQ;IACxB;IACF,MAAMG,WAAWtB,0BAA0B8C;IAC3C,MAAMa,YAAYxC,iBAAiB,SAAS;IAE5C,qBACE,MAACwC;QACE,GAAGjB,SAAS;QACZ,GAAGC,WAAW;QACd,GAAGc,QAAQ;QACZhD,WAAWP,KAAK;YACdO;YACAD;YACA8C,SAAS5C,YAAY4C;YACrB3C;YACAC;YACAC;YACAC;YACAK;YACAD;YACAqC;YACArB,WAAW,CAAC,CAACA,aAAcjB,CAAAA,qBAAqBL,aAAa,KAAI;YACjEwB,YACE,CAAC,CAACA,cAAe,CAAA,CAACnB,qBAAqBL,aAAa,KAAI;QAC5D;QACAN,KAAKA;;YAEJ4B;YACAZ;YACAc;YACAoB;;;AAGP,GACA"}
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":"AAAA;;AAEA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAKEC,UA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C;IAChB,IAAIC,aAAaC;IACjB,MAAMY,mBAAmBnD,QAAQ,YAAYkB;IAC7C,MAAMkC,mBACJ,CAACrC,kBACD,OAAOD,aAAa,aACpB,OAAQK,CAAAA,oBAAoBoB,iBAAiBF,aAAY,MACvD;IACJ,MAAMpB,eAAed,sBAAsB;QACzCkD,SAASF;QACTG,cAAc,CAAC,CAACxC;QAChBD,UAAU,CAACuC;QACXG,mBAAmBhC;IACrB;IACA,IAAI6B,kBAAkB;QACpB,IAAIjC,mBAAmB;YACrBmB,aAAarB;QACf,OAAO;YACLmB,YAAYnB;QACd;IACF;IAEA,MAAM,EAAEuC,OAAO,EAAEC,gBAAgB,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GACpD1D,sBAAsB;QACpB2D,MAAMtC,gBAAgB,SAASwB;QAC/BpB;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAtB,UAAUA,YAAYQ;IACxB;IACF,MAAMG,WAAWtB,0BAA0B8C;IAC3C,MAAMa,YAAYxC,iBAAiB,SAAS;IAE5C,qBACE,MAACwC;QACE,GAAGjB,SAAS;QACZ,GAAGC,WAAW;QACd,GAAGc,QAAQ;QACZhD,WAAWP,KAAK;YACdO;YACAD;YACA8C,SAAS5C,YAAY4C;YACrB3C;YACAC;YACAC;YACAC;YACAK;YACAD;YACAqC;YACArB,WAAW,CAAC,CAACA,aAAcjB,CAAAA,qBAAqBL,aAAa,KAAI;YACjEwB,YACE,CAAC,CAACA,cAAe,CAAA,CAACnB,qBAAqBL,aAAa,KAAI;QAC5D;QACAN,KAAKA;;YAEJ4B;YACAZ;YACAc;YACAoB;;;AAGP,GACA"}
@@ -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?: "outline" | "solid";
63
+ theme?: ChipTheme;
39
64
  backgroundColor?: BackgroundColor;
40
65
  /** @defaultValue `false` */
41
66
  disabled?: boolean;
@@ -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?: \"outline\" | \"solid\";\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;AAkEnB;;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"}
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"}
@@ -1,7 +1,5 @@
1
1
  declare module "react" {
2
2
  interface CSSProperties {
3
- "--rmd-dialog-background-color"?: string;
4
- "--rmd-dialog-color"?: string;
5
3
  "--rmd-dialog-min-width"?: string | number;
6
4
  "--rmd-dialog-horizontal-margin"?: string | number;
7
5
  "--rmd-dialog-vertical-margin"?: string | number;
@@ -10,6 +8,11 @@ declare module "react" {
10
8
  "--rmd-dialog-header-padding-bottom"?: string | number;
11
9
  "--rmd-dialog-content-padding"?: string | number;
12
10
  "--rmd-dialog-footer-padding"?: string | number;
11
+ "--rmd-dialog-width"?: string | number;
12
+ "--rmd-dialog-small-width"?: string | number;
13
+ "--rmd-dialog-medium-width"?: string | number;
14
+ "--rmd-dialog-large-width"?: string | number;
15
+ "--rmd-dialog-extra-large-width"?: string | number;
13
16
  }
14
17
  }
15
18
  export type DialogType = "full-page" | "centered" | "custom";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/dialog/styles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport {\n type CSSTransitionClassNames,\n type TransitionTimeout,\n} from \"../transition/types.js\";\nimport { bem } from \"../utils/bem.js\";\nimport { DISPLAY_NONE_CLASS } from \"../utils/isElementVisible.js\";\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-dialog-background-color\"?: string;\n \"--rmd-dialog-color\"?: string;\n \"--rmd-dialog-min-width\"?: string | number;\n \"--rmd-dialog-horizontal-margin\"?: string | number;\n \"--rmd-dialog-vertical-margin\"?: string | number;\n \"--rmd-dialog-z-index\"?: string | number;\n \"--rmd-dialog-header-padding\"?: string | number;\n \"--rmd-dialog-header-padding-bottom\"?: string | number;\n \"--rmd-dialog-content-padding\"?: string | number;\n \"--rmd-dialog-footer-padding\"?: string | number;\n }\n}\n\nconst styles = bem(\"rmd-dialog\");\nconst containerStyles = bem(\"rmd-dialog-container\");\n\nexport type DialogType = \"full-page\" | \"centered\" | \"custom\";\n\n/**\n * This can be used to enforce a specific width for dialogs instead of relying\n * on the size of the content to determine the width. The width will also ensure\n * that it does not overflow based on the viewport width and margins applied.\n *\n * For example: if the `width=\"extra-large\"` and the total viewport size is\n * `600px`, the dialog width would be `420px` since there is a default `80px`\n * margin to the left and right of the dialog. If the user expands the browser,\n * the dialog width will continue to grow until it reaches the `extra-large`\n * width and stop growing from that point.\n *\n * @since 6.0.0\n */\nexport type DialogWidth = \"auto\" | \"small\" | \"medium\" | \"large\" | \"extra-large\";\n\n/**\n * @since 6.0.0\n */\nexport interface DialogContainerClassNameOptions {\n className?: string;\n\n centered?: boolean;\n displayNone?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function dialogContainer(\n options: DialogContainerClassNameOptions = {}\n): string {\n const { className, centered, displayNone } = options;\n\n return cnb(\n containerStyles({ centered }),\n displayNone && DISPLAY_NONE_CLASS,\n className\n );\n}\n\n/** @since 6.0.0 */\nexport interface DialogClassNameOptions {\n className?: string;\n\n /**\n * @defaultValue `\"centered\"`\n */\n type?: DialogType;\n\n /**\n * @defaultValue `\"auto\"`\n */\n width?: DialogWidth;\n\n /**\n * @defaultValue `false`\n */\n fixed?: boolean;\n\n /**\n * @defaultValue `type === \"full-page\"`\n */\n outline?: boolean;\n\n /**\n * This is mostly used for handling nested dialogs and removes any box shadow\n * on a dialog that has a child visible.\n *\n * @defaultValue `false`\n */\n disableBoxShadow?: boolean;\n}\n\n/** @since 6.0.0 */\nexport function dialog(options: DialogClassNameOptions = {}): string {\n const {\n type = \"centered\",\n width,\n fixed = false,\n outline = type === \"full-page\",\n disableBoxShadow,\n className,\n } = options;\n\n return cnb(\n styles({\n fixed,\n outline,\n centered: type === \"centered\",\n \"full-page\": type === \"full-page\",\n \"no-box-shadow\": type === \"centered\" && disableBoxShadow,\n \"s-width\": width === \"small\",\n \"m-width\": width === \"medium\",\n \"l-width\": width === \"large\",\n \"xl-width\": width === \"extra-large\",\n }),\n className\n );\n}\n\n/** @since 6.0.0 */\nexport interface DialogHeaderClassNameOptions {\n className?: string;\n}\n\n/**\n * NOTE: The default `DialogHeader` component uses the `Box` component so the\n * `box` class name utility function or `Box` component will probably be\n * required if using this util\n *\n * @since 6.0.0\n */\nexport function dialogHeader(\n options: DialogHeaderClassNameOptions = {}\n): string {\n const { className } = options;\n\n return cnb(styles(\"header\"), className);\n}\n\n/** @since 6.0.0 */\nexport interface DialogContentClassNameOptions {\n className?: string;\n\n /** @defaultValue `false` */\n disablePadding?: boolean;\n}\n\n/** @since 6.0.0 */\nexport function dialogContent(\n options: DialogContentClassNameOptions = {}\n): string {\n const { className, disablePadding = false } = options;\n\n return cnb(styles(\"content\", { padded: !disablePadding }), className);\n}\n\n/**\n * An optional alignment for the content within the footer. Since the majority\n * of dialog footers are used to contain action buttons, the default alignment\n * is near the end.\n *\n * @since 3.1.0\n */\nexport type DialogFooterAlignment =\n | \"none\"\n | \"start\"\n | \"end\"\n | \"between\"\n | \"stacked-start\"\n | \"stacked-end\";\n\n/** @since 6.0.0 */\nexport interface DialogFooterClassNameOptions {\n className?: string;\n\n /** @defaultValue `\"end\"` */\n align?: DialogFooterAlignment;\n}\n\n/** @since 6.0.0 */\nexport function dialogFooter(\n options: DialogFooterClassNameOptions = {}\n): string {\n const { align = \"end\", className } = options;\n\n return cnb(\n styles(\"footer\", {\n flex: align !== \"none\",\n \"flex-v\": align === \"stacked-start\" || align === \"stacked-end\",\n start: align === \"start\" || align === \"stacked-start\",\n between: align === \"between\",\n end: align === \"end\" || align === \"stacked-end\",\n }),\n className\n );\n}\n\n/** @since 4.0.0 */\nexport const DEFAULT_DIALOG_TIMEOUT = {\n enter: 200,\n exit: 150,\n} as const satisfies TransitionTimeout;\n\n/** @since 4.0.0 */\nexport const DEFAULT_DIALOG_CLASSNAMES = {\n appear: \"rmd-dialog--enter\",\n appearActive: \"rmd-dialog--enter-active\",\n enter: \"rmd-dialog--enter\",\n enterActive: \"rmd-dialog--enter-active\",\n exit: \"rmd-dialog--exit\",\n exitActive: \"rmd-dialog--exit-active\",\n} as const satisfies CSSTransitionClassNames;\n"],"names":["cnb","bem","DISPLAY_NONE_CLASS","styles","containerStyles","dialogContainer","options","className","centered","displayNone","dialog","type","width","fixed","outline","disableBoxShadow","dialogHeader","dialogContent","disablePadding","padded","dialogFooter","align","flex","start","between","end","DEFAULT_DIALOG_TIMEOUT","enter","exit","DEFAULT_DIALOG_CLASSNAMES","appear","appearActive","enterActive","exitActive"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAMhC,SAASC,GAAG,QAAQ,kBAAkB;AACtC,SAASC,kBAAkB,QAAQ,+BAA+B;AAiBlE,MAAMC,SAASF,IAAI;AACnB,MAAMG,kBAAkBH,IAAI;AA6B5B;;CAEC,GACD,OAAO,SAASI,gBACdC,UAA2C,CAAC,CAAC;IAE7C,MAAM,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,WAAW,EAAE,GAAGH;IAE7C,OAAON,IACLI,gBAAgB;QAAEI;IAAS,IAC3BC,eAAeP,oBACfK;AAEJ;AAmCA,iBAAiB,GACjB,OAAO,SAASG,OAAOJ,UAAkC,CAAC,CAAC;IACzD,MAAM,EACJK,OAAO,UAAU,EACjBC,KAAK,EACLC,QAAQ,KAAK,EACbC,UAAUH,SAAS,WAAW,EAC9BI,gBAAgB,EAChBR,SAAS,EACV,GAAGD;IAEJ,OAAON,IACLG,OAAO;QACLU;QACAC;QACAN,UAAUG,SAAS;QACnB,aAAaA,SAAS;QACtB,iBAAiBA,SAAS,cAAcI;QACxC,WAAWH,UAAU;QACrB,WAAWA,UAAU;QACrB,WAAWA,UAAU;QACrB,YAAYA,UAAU;IACxB,IACAL;AAEJ;AAOA;;;;;;CAMC,GACD,OAAO,SAASS,aACdV,UAAwC,CAAC,CAAC;IAE1C,MAAM,EAAEC,SAAS,EAAE,GAAGD;IAEtB,OAAON,IAAIG,OAAO,WAAWI;AAC/B;AAUA,iBAAiB,GACjB,OAAO,SAASU,cACdX,UAAyC,CAAC,CAAC;IAE3C,MAAM,EAAEC,SAAS,EAAEW,iBAAiB,KAAK,EAAE,GAAGZ;IAE9C,OAAON,IAAIG,OAAO,WAAW;QAAEgB,QAAQ,CAACD;IAAe,IAAIX;AAC7D;AAyBA,iBAAiB,GACjB,OAAO,SAASa,aACdd,UAAwC,CAAC,CAAC;IAE1C,MAAM,EAAEe,QAAQ,KAAK,EAAEd,SAAS,EAAE,GAAGD;IAErC,OAAON,IACLG,OAAO,UAAU;QACfmB,MAAMD,UAAU;QAChB,UAAUA,UAAU,mBAAmBA,UAAU;QACjDE,OAAOF,UAAU,WAAWA,UAAU;QACtCG,SAASH,UAAU;QACnBI,KAAKJ,UAAU,SAASA,UAAU;IACpC,IACAd;AAEJ;AAEA,iBAAiB,GACjB,OAAO,MAAMmB,yBAAyB;IACpCC,OAAO;IACPC,MAAM;AACR,EAAuC;AAEvC,iBAAiB,GACjB,OAAO,MAAMC,4BAA4B;IACvCC,QAAQ;IACRC,cAAc;IACdJ,OAAO;IACPK,aAAa;IACbJ,MAAM;IACNK,YAAY;AACd,EAA6C"}
1
+ {"version":3,"sources":["../../src/dialog/styles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport {\n type CSSTransitionClassNames,\n type TransitionTimeout,\n} from \"../transition/types.js\";\nimport { bem } from \"../utils/bem.js\";\nimport { DISPLAY_NONE_CLASS } from \"../utils/isElementVisible.js\";\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-dialog-min-width\"?: string | number;\n \"--rmd-dialog-horizontal-margin\"?: string | number;\n \"--rmd-dialog-vertical-margin\"?: string | number;\n \"--rmd-dialog-z-index\"?: string | number;\n \"--rmd-dialog-header-padding\"?: string | number;\n \"--rmd-dialog-header-padding-bottom\"?: string | number;\n \"--rmd-dialog-content-padding\"?: string | number;\n \"--rmd-dialog-footer-padding\"?: string | number;\n \"--rmd-dialog-width\"?: string | number;\n \"--rmd-dialog-small-width\"?: string | number;\n \"--rmd-dialog-medium-width\"?: string | number;\n \"--rmd-dialog-large-width\"?: string | number;\n \"--rmd-dialog-extra-large-width\"?: string | number;\n }\n}\n\nconst styles = bem(\"rmd-dialog\");\nconst containerStyles = bem(\"rmd-dialog-container\");\n\nexport type DialogType = \"full-page\" | \"centered\" | \"custom\";\n\n/**\n * This can be used to enforce a specific width for dialogs instead of relying\n * on the size of the content to determine the width. The width will also ensure\n * that it does not overflow based on the viewport width and margins applied.\n *\n * For example: if the `width=\"extra-large\"` and the total viewport size is\n * `600px`, the dialog width would be `420px` since there is a default `80px`\n * margin to the left and right of the dialog. If the user expands the browser,\n * the dialog width will continue to grow until it reaches the `extra-large`\n * width and stop growing from that point.\n *\n * @since 6.0.0\n */\nexport type DialogWidth = \"auto\" | \"small\" | \"medium\" | \"large\" | \"extra-large\";\n\n/**\n * @since 6.0.0\n */\nexport interface DialogContainerClassNameOptions {\n className?: string;\n\n centered?: boolean;\n displayNone?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function dialogContainer(\n options: DialogContainerClassNameOptions = {}\n): string {\n const { className, centered, displayNone } = options;\n\n return cnb(\n containerStyles({ centered }),\n displayNone && DISPLAY_NONE_CLASS,\n className\n );\n}\n\n/** @since 6.0.0 */\nexport interface DialogClassNameOptions {\n className?: string;\n\n /**\n * @defaultValue `\"centered\"`\n */\n type?: DialogType;\n\n /**\n * @defaultValue `\"auto\"`\n */\n width?: DialogWidth;\n\n /**\n * @defaultValue `false`\n */\n fixed?: boolean;\n\n /**\n * @defaultValue `type === \"full-page\"`\n */\n outline?: boolean;\n\n /**\n * This is mostly used for handling nested dialogs and removes any box shadow\n * on a dialog that has a child visible.\n *\n * @defaultValue `false`\n */\n disableBoxShadow?: boolean;\n}\n\n/** @since 6.0.0 */\nexport function dialog(options: DialogClassNameOptions = {}): string {\n const {\n type = \"centered\",\n width,\n fixed = false,\n outline = type === \"full-page\",\n disableBoxShadow,\n className,\n } = options;\n\n return cnb(\n styles({\n fixed,\n outline,\n centered: type === \"centered\",\n \"full-page\": type === \"full-page\",\n \"no-box-shadow\": type === \"centered\" && disableBoxShadow,\n \"s-width\": width === \"small\",\n \"m-width\": width === \"medium\",\n \"l-width\": width === \"large\",\n \"xl-width\": width === \"extra-large\",\n }),\n className\n );\n}\n\n/** @since 6.0.0 */\nexport interface DialogHeaderClassNameOptions {\n className?: string;\n}\n\n/**\n * NOTE: The default `DialogHeader` component uses the `Box` component so the\n * `box` class name utility function or `Box` component will probably be\n * required if using this util\n *\n * @since 6.0.0\n */\nexport function dialogHeader(\n options: DialogHeaderClassNameOptions = {}\n): string {\n const { className } = options;\n\n return cnb(styles(\"header\"), className);\n}\n\n/** @since 6.0.0 */\nexport interface DialogContentClassNameOptions {\n className?: string;\n\n /** @defaultValue `false` */\n disablePadding?: boolean;\n}\n\n/** @since 6.0.0 */\nexport function dialogContent(\n options: DialogContentClassNameOptions = {}\n): string {\n const { className, disablePadding = false } = options;\n\n return cnb(styles(\"content\", { padded: !disablePadding }), className);\n}\n\n/**\n * An optional alignment for the content within the footer. Since the majority\n * of dialog footers are used to contain action buttons, the default alignment\n * is near the end.\n *\n * @since 3.1.0\n */\nexport type DialogFooterAlignment =\n | \"none\"\n | \"start\"\n | \"end\"\n | \"between\"\n | \"stacked-start\"\n | \"stacked-end\";\n\n/** @since 6.0.0 */\nexport interface DialogFooterClassNameOptions {\n className?: string;\n\n /** @defaultValue `\"end\"` */\n align?: DialogFooterAlignment;\n}\n\n/** @since 6.0.0 */\nexport function dialogFooter(\n options: DialogFooterClassNameOptions = {}\n): string {\n const { align = \"end\", className } = options;\n\n return cnb(\n styles(\"footer\", {\n flex: align !== \"none\",\n \"flex-v\": align === \"stacked-start\" || align === \"stacked-end\",\n start: align === \"start\" || align === \"stacked-start\",\n between: align === \"between\",\n end: align === \"end\" || align === \"stacked-end\",\n }),\n className\n );\n}\n\n/** @since 4.0.0 */\nexport const DEFAULT_DIALOG_TIMEOUT = {\n enter: 200,\n exit: 150,\n} as const satisfies TransitionTimeout;\n\n/** @since 4.0.0 */\nexport const DEFAULT_DIALOG_CLASSNAMES = {\n appear: \"rmd-dialog--enter\",\n appearActive: \"rmd-dialog--enter-active\",\n enter: \"rmd-dialog--enter\",\n enterActive: \"rmd-dialog--enter-active\",\n exit: \"rmd-dialog--exit\",\n exitActive: \"rmd-dialog--exit-active\",\n} as const satisfies CSSTransitionClassNames;\n"],"names":["cnb","bem","DISPLAY_NONE_CLASS","styles","containerStyles","dialogContainer","options","className","centered","displayNone","dialog","type","width","fixed","outline","disableBoxShadow","dialogHeader","dialogContent","disablePadding","padded","dialogFooter","align","flex","start","between","end","DEFAULT_DIALOG_TIMEOUT","enter","exit","DEFAULT_DIALOG_CLASSNAMES","appear","appearActive","enterActive","exitActive"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAMhC,SAASC,GAAG,QAAQ,kBAAkB;AACtC,SAASC,kBAAkB,QAAQ,+BAA+B;AAoBlE,MAAMC,SAASF,IAAI;AACnB,MAAMG,kBAAkBH,IAAI;AA6B5B;;CAEC,GACD,OAAO,SAASI,gBACdC,UAA2C,CAAC,CAAC;IAE7C,MAAM,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,WAAW,EAAE,GAAGH;IAE7C,OAAON,IACLI,gBAAgB;QAAEI;IAAS,IAC3BC,eAAeP,oBACfK;AAEJ;AAmCA,iBAAiB,GACjB,OAAO,SAASG,OAAOJ,UAAkC,CAAC,CAAC;IACzD,MAAM,EACJK,OAAO,UAAU,EACjBC,KAAK,EACLC,QAAQ,KAAK,EACbC,UAAUH,SAAS,WAAW,EAC9BI,gBAAgB,EAChBR,SAAS,EACV,GAAGD;IAEJ,OAAON,IACLG,OAAO;QACLU;QACAC;QACAN,UAAUG,SAAS;QACnB,aAAaA,SAAS;QACtB,iBAAiBA,SAAS,cAAcI;QACxC,WAAWH,UAAU;QACrB,WAAWA,UAAU;QACrB,WAAWA,UAAU;QACrB,YAAYA,UAAU;IACxB,IACAL;AAEJ;AAOA;;;;;;CAMC,GACD,OAAO,SAASS,aACdV,UAAwC,CAAC,CAAC;IAE1C,MAAM,EAAEC,SAAS,EAAE,GAAGD;IAEtB,OAAON,IAAIG,OAAO,WAAWI;AAC/B;AAUA,iBAAiB,GACjB,OAAO,SAASU,cACdX,UAAyC,CAAC,CAAC;IAE3C,MAAM,EAAEC,SAAS,EAAEW,iBAAiB,KAAK,EAAE,GAAGZ;IAE9C,OAAON,IAAIG,OAAO,WAAW;QAAEgB,QAAQ,CAACD;IAAe,IAAIX;AAC7D;AAyBA,iBAAiB,GACjB,OAAO,SAASa,aACdd,UAAwC,CAAC,CAAC;IAE1C,MAAM,EAAEe,QAAQ,KAAK,EAAEd,SAAS,EAAE,GAAGD;IAErC,OAAON,IACLG,OAAO,UAAU;QACfmB,MAAMD,UAAU;QAChB,UAAUA,UAAU,mBAAmBA,UAAU;QACjDE,OAAOF,UAAU,WAAWA,UAAU;QACtCG,SAASH,UAAU;QACnBI,KAAKJ,UAAU,SAASA,UAAU;IACpC,IACAd;AAEJ;AAEA,iBAAiB,GACjB,OAAO,MAAMmB,yBAAyB;IACpCC,OAAO;IACPC,MAAM;AACR,EAAuC;AAEvC,iBAAiB,GACjB,OAAO,MAAMC,4BAA4B;IACvCC,QAAQ;IACRC,cAAc;IACdJ,OAAO;IACPK,aAAa;IACbJ,MAAM;IACNK,YAAY;AACd,EAA6C"}
@@ -1,7 +1,7 @@
1
1
  declare module "react" {
2
2
  interface CSSProperties {
3
3
  "--rmd-divider-size"?: string | number;
4
- "--rmd-divider-vertical-size"?: string | number;
4
+ "--rmd-divider-border-size"?: string | number;
5
5
  "--rmd-divider-color"?: string;
6
6
  "--rmd-divider-spacing"?: string | number;
7
7
  "--rmd-divider-vertical-spacing"?: string | number;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/divider/styles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { bem } from \"../utils/bem.js\";\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-divider-size\"?: string | number;\n \"--rmd-divider-vertical-size\"?: string | number;\n \"--rmd-divider-color\"?: string;\n \"--rmd-divider-spacing\"?: string | number;\n \"--rmd-divider-vertical-spacing\"?: string | number;\n \"--rmd-divider-inset\"?: string | number;\n \"--rmd-divider-max-size\"?: string | number;\n }\n}\n\nconst styles = bem(\"rmd-divider\");\n\n/** @since 6.0.0 */\nexport interface DividerClassNameOptions {\n className?: string;\n\n /**\n * Boolean if the divider should appear inset instead of full width. This\n * really just applied a margin-left (or margin-right when dir=\"rtl\").\n *\n * If you want to create a divider that is centered, you most likely want to\n * use the `rmd-divider-theme-update-var` mixin instead to update the\n * `max-size` of the divider.\n *\n * @defaultValue `false`\n */\n inset?: boolean;\n\n /**\n * Boolean if the divider should be vertical instead of horizontal. This will\n * change the divider to be rendered as a `<div>` instead of an `<hr>`.\n *\n * Note: If your parent element of the divider does not have a static height\n * set, you **must** manually set the height of the divider to a static\n * non-percentage number OR use the `VerticalDivider` component instead to\n * automagically create a valid percentage height.\n *\n * @defaultValue `false`\n */\n vertical?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function divider(options: DividerClassNameOptions = {}): string {\n const { inset = false, vertical = false, className } = options;\n\n return cnb(\n styles({\n inset: inset && !vertical,\n vertical,\n }),\n className\n );\n}\n"],"names":["cnb","bem","styles","divider","options","inset","vertical","className"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAASC,GAAG,QAAQ,kBAAkB;AActC,MAAMC,SAASD,IAAI;AAgCnB;;CAEC,GACD,OAAO,SAASE,QAAQC,UAAmC,CAAC,CAAC;IAC3D,MAAM,EAAEC,QAAQ,KAAK,EAAEC,WAAW,KAAK,EAAEC,SAAS,EAAE,GAAGH;IAEvD,OAAOJ,IACLE,OAAO;QACLG,OAAOA,SAAS,CAACC;QACjBA;IACF,IACAC;AAEJ"}
1
+ {"version":3,"sources":["../../src/divider/styles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { bem } from \"../utils/bem.js\";\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-divider-size\"?: string | number;\n \"--rmd-divider-border-size\"?: string | number;\n \"--rmd-divider-color\"?: string;\n \"--rmd-divider-spacing\"?: string | number;\n \"--rmd-divider-vertical-spacing\"?: string | number;\n \"--rmd-divider-inset\"?: string | number;\n \"--rmd-divider-max-size\"?: string | number;\n }\n}\n\nconst styles = bem(\"rmd-divider\");\n\n/** @since 6.0.0 */\nexport interface DividerClassNameOptions {\n className?: string;\n\n /**\n * Boolean if the divider should appear inset instead of full width. This\n * really just applied a margin-left (or margin-right when dir=\"rtl\").\n *\n * If you want to create a divider that is centered, you most likely want to\n * use the `rmd-divider-theme-update-var` mixin instead to update the\n * `max-size` of the divider.\n *\n * @defaultValue `false`\n */\n inset?: boolean;\n\n /**\n * Boolean if the divider should be vertical instead of horizontal. This will\n * change the divider to be rendered as a `<div>` instead of an `<hr>`.\n *\n * Note: If your parent element of the divider does not have a static height\n * set, you **must** manually set the height of the divider to a static\n * non-percentage number OR use the `VerticalDivider` component instead to\n * automagically create a valid percentage height.\n *\n * @defaultValue `false`\n */\n vertical?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function divider(options: DividerClassNameOptions = {}): string {\n const { inset = false, vertical = false, className } = options;\n\n return cnb(\n styles({\n inset: inset && !vertical,\n vertical,\n }),\n className\n );\n}\n"],"names":["cnb","bem","styles","divider","options","inset","vertical","className"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAASC,GAAG,QAAQ,kBAAkB;AActC,MAAMC,SAASD,IAAI;AAgCnB;;CAEC,GACD,OAAO,SAASE,QAAQC,UAAmC,CAAC,CAAC;IAC3D,MAAM,EAAEC,QAAQ,KAAK,EAAEC,WAAW,KAAK,EAAEC,SAAS,EAAE,GAAGH;IAEvD,OAAOJ,IACLE,OAAO;QACLG,OAAOA,SAAS,CAACC;QACjBA;IACF,IACAC;AAEJ"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/error-boundary/ErrorBoundary.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n Component,\n type ErrorInfo,\n type ReactElement,\n type ReactNode,\n} from \"react\";\n\nimport { Provider } from \"./context.js\";\nimport { type ErrorBoundaryContext, type ErrorBoundaryState } from \"./types.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface ErrorBoundaryProps {\n onError?: (error: Error, errorInfo: ErrorInfo) => void;\n fallback: ReactNode;\n children: ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * This is a minimal fork of the `react-error-boundary` package from\n * {@link https://github.com/bvaughn/react-error-boundary/tree/5.0.0}\n * that only includes things I consider useful. Use the `react-error-boundary`\n * if more complex behavior is required.\n *\n * @example Main Use Case\n * ```tsx\n * import { Button } from \"@react-md/core/button/Button\";\n * import { ErrorBoundary } from \"@react-md/core/error-boundary/ErrorBoundary\";\n * import { useErrorBoundary } from \"@react-md/core/error-boundary/useErrorBoundary\";\n * import { Typography } from \"@react-md/core/typography/Typography\";\n *\n * function Example() {\n * return (\n * <ErrorBoundary\n * fallback={<SomeFallbackComponent />}\n * >\n * <SomeComponentThatMightError />\n * </ErrorBoundary>\n * );\n * }\n *\n * \"use client\";\n *\n * function SomeFallbackComponent() {\n * const { error, errored, reset } = useErrorBoundary();\n *\n * return (\n * <>\n * <Typography>Uh oh, something broke!</Typography>\n * <Button onClick={reset}>Try Again?</Button>\n * </>\n * );\n * }\n * ```\n *\n * @since 6.0.0\n */\nexport class ErrorBoundary extends Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n\n this.state = { error: null, errored: false };\n }\n\n static getDerivedStateFromError(error: Error): ErrorBoundaryState {\n return { error, errored: true };\n }\n\n componentDidCatch(error: Error, errorInfo: ErrorInfo): void {\n this.props.onError?.(error, errorInfo);\n }\n\n reset = (): void => {\n this.setState({ error: null, errored: false });\n };\n\n render(): ReactElement {\n const { fallback } = this.props;\n const { error, errored } = this.state;\n\n let { children } = this.props;\n if (errored) {\n children = fallback;\n }\n\n return (\n <Provider\n // should always match\n value={{ error, errored, reset: this.reset } as ErrorBoundaryContext}\n >\n {children}\n </Provider>\n );\n }\n}\n"],"names":["Component","Provider","ErrorBoundary","getDerivedStateFromError","error","errored","componentDidCatch","errorInfo","props","onError","render","fallback","state","children","value","reset","constructor","setState"],"mappings":"AAAA;;;;;;;;;;;;;;;AAEA,SACEA,SAAS,QAIJ,QAAQ;AAEf,SAASC,QAAQ,QAAQ,eAAe;AAYxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCC,GACD,OAAO,MAAMC,sBAAsBF;IAUjC,OAAOG,yBAAyBC,KAAY,EAAsB;QAChE,OAAO;YAAEA;YAAOC,SAAS;QAAK;IAChC;IAEAC,kBAAkBF,KAAY,EAAEG,SAAoB,EAAQ;QAC1D,IAAI,CAACC,KAAK,CAACC,OAAO,GAAGL,OAAOG;IAC9B;IAMAG,SAAuB;QACrB,MAAM,EAAEC,QAAQ,EAAE,GAAG,IAAI,CAACH,KAAK;QAC/B,MAAM,EAAEJ,KAAK,EAAEC,OAAO,EAAE,GAAG,IAAI,CAACO,KAAK;QAErC,IAAI,EAAEC,QAAQ,EAAE,GAAG,IAAI,CAACL,KAAK;QAC7B,IAAIH,SAAS;YACXQ,WAAWF;QACb;QAEA,qBACE,KAACV;YACC,sBAAsB;YACtBa,OAAO;gBAAEV;gBAAOC;gBAASU,OAAO,IAAI,CAACA,KAAK;YAAC;sBAE1CF;;IAGP;IAnCAG,YAAYR,KAAyB,CAAE;QACrC,KAAK,CAACA,QAaRO,uBAAAA,SAAQ;YACN,IAAI,CAACE,QAAQ,CAAC;gBAAEb,OAAO;gBAAMC,SAAS;YAAM;QAC9C;QAbE,IAAI,CAACO,KAAK,GAAG;YAAER,OAAO;YAAMC,SAAS;QAAM;IAC7C;AAgCF"}
1
+ {"version":3,"sources":["../../src/error-boundary/ErrorBoundary.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n Component,\n type ErrorInfo,\n type ReactElement,\n type ReactNode,\n} from \"react\";\n\nimport { Provider } from \"./context.js\";\nimport { type ErrorBoundaryContext, type ErrorBoundaryState } from \"./types.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface ErrorBoundaryProps {\n onError?: (error: Error, errorInfo: ErrorInfo) => void;\n fallback: ReactNode;\n children: ReactNode;\n}\n\n/**\n * **Client Component**\n *\n * This is a minimal fork of the `react-error-boundary` package from\n * {@link https://github.com/bvaughn/react-error-boundary/tree/5.0.0}\n * that only includes things I consider useful. Use the `react-error-boundary`\n * if more complex behavior is required.\n *\n * @example Main Use Case\n * ```tsx\n * import { Button } from \"@react-md/core/button/Button\";\n * import { ErrorBoundary } from \"@react-md/core/error-boundary/ErrorBoundary\";\n * import { useErrorBoundary } from \"@react-md/core/error-boundary/useErrorBoundary\";\n * import { Typography } from \"@react-md/core/typography/Typography\";\n *\n * function Example() {\n * return (\n * <ErrorBoundary\n * fallback={<SomeFallbackComponent />}\n * >\n * <SomeComponentThatMightError />\n * </ErrorBoundary>\n * );\n * }\n *\n * \"use client\";\n *\n * function SomeFallbackComponent() {\n * const { error, errored, reset } = useErrorBoundary();\n *\n * return (\n * <>\n * <Typography>Uh oh, something broke!</Typography>\n * <Button onClick={reset}>Try Again?</Button>\n * </>\n * );\n * }\n * ```\n *\n * @since 6.0.0\n */\nexport class ErrorBoundary extends Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n\n this.state = { error: null, errored: false };\n }\n\n static getDerivedStateFromError(error: Error): ErrorBoundaryState {\n return { error, errored: true };\n }\n\n componentDidCatch(error: Error, errorInfo: ErrorInfo): void {\n this.props.onError?.(error, errorInfo);\n }\n\n reset = (): void => {\n this.setState({ error: null, errored: false });\n };\n\n render(): ReactElement {\n const { fallback } = this.props;\n const { error, errored } = this.state;\n\n let { children } = this.props;\n if (errored) {\n children = fallback;\n }\n\n return (\n <Provider\n // should always match\n value={{ error, errored, reset: this.reset } as ErrorBoundaryContext}\n >\n {children}\n </Provider>\n );\n }\n}\n"],"names":["Component","Provider","ErrorBoundary","getDerivedStateFromError","error","errored","componentDidCatch","errorInfo","props","onError","render","fallback","state","children","value","reset","setState"],"mappings":"AAAA;;;;;;;;;;;;;;;AAEA,SACEA,SAAS,QAIJ,QAAQ;AAEf,SAASC,QAAQ,QAAQ,eAAe;AAYxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCC,GACD,OAAO,MAAMC,sBAAsBF;IAUjC,OAAOG,yBAAyBC,KAAY,EAAsB;QAChE,OAAO;YAAEA;YAAOC,SAAS;QAAK;IAChC;IAEAC,kBAAkBF,KAAY,EAAEG,SAAoB,EAAQ;QAC1D,IAAI,CAACC,KAAK,CAACC,OAAO,GAAGL,OAAOG;IAC9B;IAMAG,SAAuB;QACrB,MAAM,EAAEC,QAAQ,EAAE,GAAG,IAAI,CAACH,KAAK;QAC/B,MAAM,EAAEJ,KAAK,EAAEC,OAAO,EAAE,GAAG,IAAI,CAACO,KAAK;QAErC,IAAI,EAAEC,QAAQ,EAAE,GAAG,IAAI,CAACL,KAAK;QAC7B,IAAIH,SAAS;YACXQ,WAAWF;QACb;QAEA,qBACE,KAACV;YACC,sBAAsB;YACtBa,OAAO;gBAAEV;gBAAOC;gBAASU,OAAO,IAAI,CAACA,KAAK;YAAC;sBAE1CF;;IAGP;IAnCA,YAAYL,KAAyB,CAAE;QACrC,KAAK,CAACA,QAaRO,uBAAAA,SAAQ;YACN,IAAI,CAACC,QAAQ,CAAC;gBAAEZ,OAAO;gBAAMC,SAAS;YAAM;QAC9C;QAbE,IAAI,CAACO,KAAK,GAAG;YAAER,OAAO;YAAMC,SAAS;QAAM;IAC7C;AAgCF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/files/validation.ts"],"sourcesContent":["import { nanoid } from \"nanoid\";\n\n/**\n * An error that will be created if a user tries dragging and dropping files\n * from a shared directory that they do not have access to. This error will not\n * occur much.\n *\n * @since 2.9.0\n */\nexport class FileAccessError extends Error {\n /**\n * A unique key generated by `nanoid` that can be used as a `React` key\n */\n public key: string;\n\n /**\n *\n * @param message - An optional message for the error.\n */\n constructor(message?: string) {\n super(message);\n this.key = nanoid();\n this.name = \"FileAccessError\";\n }\n}\n\n/**\n * An error that just requires a `File` to be passed as the first argument.\n *\n * @since 2.9.0\n */\nexport class GenericFileError extends Error {\n /**\n * A unique key generated by `nanoid` that can be used as a `React` key\n */\n public key: string;\n\n /**\n *\n * @param files - A list of files that caused the error.\n * @param reason - An optional reason for the error\n */\n constructor(\n public files: readonly File[],\n public reason?: string\n ) {\n super(\"Invalid files\");\n this.key = nanoid();\n this.name = \"GenericFileError\";\n }\n}\n\n/**\n * An error that is created during the upload process if the number of files\n * exceeds the {@link FileUploadOptions.maxFiles} amount.\n *\n * @since 2.9.0\n */\nexport class TooManyFilesError extends GenericFileError {\n /**\n *\n * @param files - The list of files that could not be uploaded due to the file\n * limit defined.\n * @param limit - The max limit of files allowed.\n */\n constructor(\n files: readonly File[],\n public limit: number\n ) {\n super(files, \"file limit\");\n this.name = \"TooManyFilesError\";\n }\n}\n\n/**\n * An error that will be created if a user tries to upload a file that\n * is either:\n * - less than the {@link FileValidationOptions.minFileSize}\n * - greater than the {@link FileValidationOptions.maxFileSize}\n * - including the file would be greater than the {@link FileValidationOptions.totalFileSize}\n *\n * @since 2.9.0\n */\nexport class FileSizeError extends GenericFileError {\n /**\n *\n * @param files - The list of files that have the file size error\n * @param type - The file size error type\n * @param limit - The number of bytes allowed based on the type\n */\n constructor(\n files: readonly File[],\n public type: \"min\" | \"max\" | \"total\",\n public limit: number\n ) {\n super(files, \"file size\");\n this.name = \"FileSizeError\";\n }\n}\n\n/**\n * An error that will be created if a user tries to upload a file that does not\n * end with one of the {@link FileValidationOptions.extensions}.\n *\n * @since 2.9.0\n */\nexport class FileExtensionError extends GenericFileError {\n /**\n *\n * @param files - The file that caused the error\n * @param extensions - The allowed list of file extensions\n */\n constructor(\n files: readonly File[],\n public extensions: readonly string[]\n ) {\n super(files, \"extension\");\n this.name = \"FileExtensionError\";\n }\n}\n\n/**\n * Mostly an internal type that is used to allow custom validation errors\n *\n * @since 2.9.0\n */\nexport type FileValidationError<E = GenericFileError> =\n | FileAccessError\n | TooManyFilesError\n | FileSizeError\n | FileExtensionError\n | E;\n\n/**\n * A simple type-guard that can be used to check if the\n * {@link FileValidationError} is the {@link GenericFileError} which can be\n * useful when displaying the errors to the user.\n *\n * @param error - The error to check\n * @returns true if the error is a {@link FileAccessError}\n */\nexport function isGenericFileError<CustomError extends object>(\n error: FileValidationError<CustomError>\n): error is GenericFileError {\n return \"name\" in error && error.name === \"GenericFileError\";\n}\n\n/**\n * A simple type-guard that can be used to check if the\n * {@link FileValidationError} is the {@link FileAccessError} which can be\n * useful when displaying the errors to the user.\n *\n * @param error - The error to check\n * @returns true if the error is a {@link FileAccessError}\n */\nexport function isFileAccessError<CustomError extends object>(\n error: FileValidationError<CustomError>\n): error is FileAccessError {\n return \"name\" in error && error.name === \"FileAccessError\";\n}\n\n/**\n * A simple type-guard that can be used to check if the\n * {@link FileValidationError} is the {@link TooManyFilesError} which can be\n * useful when displaying the errors to the user.\n *\n * @param error - The error to check\n * @returns true if the error is a {@link TooManyFilesError}\n */\nexport function isTooManyFilesError<CustomError extends object>(\n error: FileValidationError<CustomError>\n): error is TooManyFilesError {\n return \"name\" in error && error.name === \"TooManyFilesError\";\n}\n\n/**\n * A simple type-guard that can be used to check if the\n * {@link FileValidationError} is the {@link FileSizeError} which can be\n * useful when displaying the errors to the user.\n *\n * @param error - The error to check\n * @returns true if the error is a {@link FileSizeError}\n */\nexport function isFileSizeError<CustomError extends object>(\n error: FileValidationError<CustomError>\n): error is FileSizeError {\n return \"name\" in error && error.name === \"FileSizeError\";\n}\n\n/**\n * A simple type-guard that can be used to check if the\n * {@link FileValidationError} is the {@link FileExtensionError} which can be\n * useful when displaying the errors to the user.\n *\n * @param error - The error to check\n * @returns true if the error is a {@link FileExtensionError}\n */\nexport function isFileExtensionError<CustomError extends object>(\n error: FileValidationError<CustomError>\n): error is FileExtensionError {\n return \"name\" in error && error.name === \"FileExtensionError\";\n}\n\n/**\n * This function is used to determine if a file should be added to the\n * {@link FileExtensionError}. The default implementation should work for most\n * use cases except when files that do not have extensions can be uploaded. i.e.\n * LICENSE files.\n *\n * @param file - The file being checked\n * @param extensionRegExp - A regex that will only be defined if the\n * `extensions` list had at least one value.\n * @param extensions - The list of extensions allowed\n * @returns true if the file has a valid name.\n * @since 3.1.0\n */\nexport type IsValidFileName = (\n file: File,\n extensionRegExp: RegExp | undefined,\n extensions: readonly string[]\n) => boolean;\n\n/**\n *\n * @defaultValue `matcher?.test(file.name) ?? true`\n * @since 3.1.0\n */\nexport const isValidFileName: IsValidFileName = (file, matcher) =>\n matcher?.test(file.name) ?? true;\n\n/** @since 2.9.0 */\nexport interface FileValidationOptions {\n /**\n * If the number of files should be limited, set this value to a number\n * greater than `0`.\n *\n * Note: This still allows \"infinite\" files when set to `0` since the\n * `<input>` element should normally be set to `disabled` if files should not\n * be able to be uploaded.\n *\n * @defaultValue `-1`\n */\n maxFiles?: number;\n\n /**\n * An optional minimum file size to enforce for each file. This will only be\n * used when it is greater than `0`.\n *\n * @defaultValue `-1`\n */\n minFileSize?: number;\n\n /**\n * An optional maximum file size to enforce for each file. This will only be\n * used when it is greater than `0`.\n *\n * @defaultValue `-1`\n */\n maxFileSize?: number;\n\n /**\n * An optional list of extensions to enforce when uploading files.\n *\n * Note: The extensions and file names will be compared ignoring case.\n *\n * @example Only Allow Images\n * ```ts\n * const extensions = [\"png\", \"jpeg\", \"jpg\", \"gif\"];\n * ```\n */\n extensions?: readonly string[];\n\n /** {@inheritDoc IsValidFileName} */\n isValidFileName?: IsValidFileName;\n\n /**\n * An optional total file size to enforce when the {@link maxFiles} option is\n * not set to `1`.\n *\n * @defaultValue `-1`\n */\n totalFileSize?: number;\n}\n\n/** @since 2.9.0 */\nexport interface FilesValidationOptions\n extends Required<FileValidationOptions> {\n /**\n * The total number of bytes in the {@link FileUploadHookReturnValue.stats}\n * list. This is really just:\n *\n * ```ts\n * const totalBytes = stats.reduce((total, stat) => total + stat.file.size, 0);\n * ```\n */\n totalBytes: number;\n\n /**\n * The total number of files in the {@link FileUploadHookReturnValue.stats}.\n */\n totalFiles: number;\n}\n\n/**\n * @since 2.9.0\n */\nexport interface ValidatedFilesResult<CustomError> {\n /**\n * A filtered list of files that have been validated and can be queued for the\n * upload process.\n */\n pending: readonly File[];\n\n /**\n * A list of {@link FileValidationError} that occurred during the validation\n * step.\n *\n * Note: If an error has occurred, the file **should not** be added to the\n * {@link pending} list of files.\n */\n errors: readonly FileValidationError<CustomError>[];\n}\n\n/**\n * This function will be called whenever a file has been uploaded by the user\n * either through an `<input type=\"file\">` or drag and drop behavior.\n *\n * @example Simple Example\n * ```ts\n * const validateFiles: FilesValidator = (files, options) => {\n * const invalid: File[] = [];\n * const pending: File[] = [];\n * for (const file of files) {\n * if (!/\\.(jpe?g|svg|png)$/i.test(name)) {\n * invalid.push(file);\n * } else {\n * pending.push(file);\n * }\n * }\n *\n * const errors: FileValidationError[] = [];\n * if (invalid.length) {\n * errors.push(new GenericFileError(invalid))\n * }\n *\n * return { pending, errors };\n * };\n * ```\n *\n * @typeParam E - An optional custom file validation error.\n * @param files - The list of files to check\n * @param options - The {@link FilesValidationOptions}\n * @returns the {@link ValidatedFilesResult}\n * @see {@link validateFiles} for the default implementation\n * @since 2.9.0\n */\nexport type FilesValidator<CustomError = never> = (\n files: readonly File[],\n options: FilesValidationOptions\n) => ValidatedFilesResult<CustomError>;\n\n/**\n * A pretty decent default implementation for validating files with the\n * {@link useFileUpload} that ensures the {@link FilesValidationOptions} are\n * enforced before allowing a file to be uploaded.\n *\n * @typeParam E - An optional custom file validation error.\n * @param files - The list of files to check\n * @param options - The {@link FilesValidationOptions}\n * @returns the {@link ValidatedFilesResult}\n * @since 2.9.0\n */\nexport function validateFiles<CustomError>(\n files: readonly File[],\n options: FilesValidationOptions\n): ValidatedFilesResult<CustomError> {\n const {\n maxFiles,\n extensions,\n minFileSize,\n maxFileSize,\n totalBytes,\n totalFiles,\n totalFileSize,\n isValidFileName,\n } = options;\n\n const errors: FileValidationError<CustomError>[] = [];\n const pending: File[] = [];\n const extraFiles: File[] = [];\n const extensionRegExp =\n extensions.length > 0\n ? new RegExp(`\\\\.(${extensions.join(\"|\")})$`, \"i\")\n : undefined;\n\n let maxFilesReached = maxFiles > 0 && totalFiles >= maxFiles;\n let remainingBytes = totalFileSize - totalBytes;\n const extensionErrors: File[] = [];\n const minErrors: File[] = [];\n const maxErrors: File[] = [];\n const totalSizeErrors: File[] = [];\n for (let i = 0; i < files.length; i += 1) {\n const file = files[i];\n\n let valid = true;\n const { size } = file;\n if (!isValidFileName(file, extensionRegExp, extensions)) {\n valid = false;\n extensionErrors.push(file);\n }\n\n if (minFileSize > 0 && size < minFileSize) {\n valid = false;\n minErrors.push(file);\n }\n\n if (maxFileSize > 0 && size > maxFileSize) {\n valid = false;\n maxErrors.push(file);\n } else if (totalFileSize > 0 && remainingBytes - file.size < 0) {\n // don't want both errors displaying\n valid = false;\n totalSizeErrors.push(file);\n }\n\n if (maxFilesReached && valid) {\n extraFiles.push(file);\n } else if (!maxFilesReached && valid) {\n pending.push(file);\n remainingBytes -= file.size;\n maxFilesReached =\n maxFilesReached ||\n (maxFiles > 0 && totalFiles + pending.length >= maxFiles);\n }\n }\n\n if (extensionErrors.length) {\n errors.push(new FileExtensionError(extensionErrors, extensions));\n }\n\n if (minErrors.length) {\n errors.push(new FileSizeError(minErrors, \"min\", minFileSize));\n }\n\n if (maxErrors.length) {\n errors.push(new FileSizeError(maxErrors, \"max\", maxFileSize));\n }\n\n if (totalSizeErrors.length) {\n errors.push(new FileSizeError(totalSizeErrors, \"total\", totalFileSize));\n }\n\n if (extraFiles.length) {\n errors.push(new TooManyFilesError(extraFiles, maxFiles));\n }\n\n return { pending, errors };\n}\n"],"names":["nanoid","FileAccessError","Error","constructor","message","key","name","GenericFileError","files","reason","TooManyFilesError","limit","FileSizeError","type","FileExtensionError","extensions","isGenericFileError","error","isFileAccessError","isTooManyFilesError","isFileSizeError","isFileExtensionError","isValidFileName","file","matcher","test","validateFiles","options","maxFiles","minFileSize","maxFileSize","totalBytes","totalFiles","totalFileSize","errors","pending","extraFiles","extensionRegExp","length","RegExp","join","undefined","maxFilesReached","remainingBytes","extensionErrors","minErrors","maxErrors","totalSizeErrors","i","valid","size","push"],"mappings":";;;;;;;;;;;;;AAAA,SAASA,MAAM,QAAQ,SAAS;AAEhC;;;;;;CAMC,GACD,OAAO,MAAMC,wBAAwBC;IAMnC;;;GAGC,GACDC,YAAYC,OAAgB,CAAE;QAC5B,KAAK,CAACA,UAVR;;GAEC,GACD,uBAAOC,OAAP,KAAA;QAQE,IAAI,CAACA,GAAG,GAAGL;QACX,IAAI,CAACM,IAAI,GAAG;IACd;AACF;AAEA;;;;CAIC,GACD,OAAO,MAAMC,yBAAyBL;IAMpC;;;;GAIC,GACDC,YACE,AAAOK,KAAsB,EAC7B,AAAOC,MAAe,CACtB;QACA,KAAK,CAAC,qGAdR;;GAEC,GACD,uBAAOJ,OAAP,KAAA,SAQSG,QAAAA,YACAC,SAAAA;QAGP,IAAI,CAACJ,GAAG,GAAGL;QACX,IAAI,CAACM,IAAI,GAAG;IACd;AACF;AAEA;;;;;CAKC,GACD,OAAO,MAAMI,0BAA0BH;IACrC;;;;;GAKC,GACDJ,YACEK,KAAsB,EACtB,AAAOG,KAAa,CACpB;QACA,KAAK,CAACH,OAAO,6DAFNG,QAAA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AKI,aAAaG,QAAQG,MAAM,IAAIV;QACpD;IACF;IAEA,IAAIgB,gBAAgBN,MAAM,EAAE;QAC1BJ,OAAOiB,IAAI,CAAC,IAAIrC,mBAAmB8B,iBAAiB7B;IACtD;IAEA,IAAI8B,UAAUP,MAAM,EAAE;QACpBJ,OAAOiB,IAAI,CAAC,IAAIvC,cAAciC,WAAW,OAAOhB;IAClD;IAEA,IAAIiB,UAAUR,MAAM,EAAE;QACpBJ,OAAOiB,IAAI,CAAC,IAAIvC,cAAckC,WAAW,OAAOhB;IAClD;IAEA,IAAIiB,gBAAgBT,MAAM,EAAE;QAC1BJ,OAAOiB,IAAI,CAAC,IAAIvC,cAAcmC,iBAAiB,SAASd;IAC1D;IAEA,IAAIG,WAAWE,MAAM,EAAE;QACrBJ,OAAOiB,IAAI,CAAC,IAAIzC,kBAAkB0B,YAAYR;IAChD;IAEA,OAAO;QAAEO;QAASD;IAAO;AAC3B"}
1
+ {"version":3,"sources":["../../src/files/validation.ts"],"sourcesContent":["import { nanoid } from \"nanoid\";\n\n/**\n * An error that will be created if a user tries dragging and dropping files\n * from a shared directory that they do not have access to. This error will not\n * occur much.\n *\n * @since 2.9.0\n */\nexport class FileAccessError extends Error {\n /**\n * A unique key generated by `nanoid` that can be used as a `React` key\n */\n public key: string;\n\n /**\n *\n * @param message - An optional message for the error.\n */\n constructor(message?: string) {\n super(message);\n this.key = nanoid();\n this.name = \"FileAccessError\";\n }\n}\n\n/**\n * An error that just requires a `File` to be passed as the first argument.\n *\n * @since 2.9.0\n */\nexport class GenericFileError extends Error {\n /**\n * A unique key generated by `nanoid` that can be used as a `React` key\n */\n public key: string;\n\n /**\n *\n * @param files - A list of files that caused the error.\n * @param reason - An optional reason for the error\n */\n constructor(\n public files: readonly File[],\n public reason?: string\n ) {\n super(\"Invalid files\");\n this.key = nanoid();\n this.name = \"GenericFileError\";\n }\n}\n\n/**\n * An error that is created during the upload process if the number of files\n * exceeds the {@link FileUploadOptions.maxFiles} amount.\n *\n * @since 2.9.0\n */\nexport class TooManyFilesError extends GenericFileError {\n /**\n *\n * @param files - The list of files that could not be uploaded due to the file\n * limit defined.\n * @param limit - The max limit of files allowed.\n */\n constructor(\n files: readonly File[],\n public limit: number\n ) {\n super(files, \"file limit\");\n this.name = \"TooManyFilesError\";\n }\n}\n\n/**\n * An error that will be created if a user tries to upload a file that\n * is either:\n * - less than the {@link FileValidationOptions.minFileSize}\n * - greater than the {@link FileValidationOptions.maxFileSize}\n * - including the file would be greater than the {@link FileValidationOptions.totalFileSize}\n *\n * @since 2.9.0\n */\nexport class FileSizeError extends GenericFileError {\n /**\n *\n * @param files - The list of files that have the file size error\n * @param type - The file size error type\n * @param limit - The number of bytes allowed based on the type\n */\n constructor(\n files: readonly File[],\n public type: \"min\" | \"max\" | \"total\",\n public limit: number\n ) {\n super(files, \"file size\");\n this.name = \"FileSizeError\";\n }\n}\n\n/**\n * An error that will be created if a user tries to upload a file that does not\n * end with one of the {@link FileValidationOptions.extensions}.\n *\n * @since 2.9.0\n */\nexport class FileExtensionError extends GenericFileError {\n /**\n *\n * @param files - The file that caused the error\n * @param extensions - The allowed list of file extensions\n */\n constructor(\n files: readonly File[],\n public extensions: readonly string[]\n ) {\n super(files, \"extension\");\n this.name = \"FileExtensionError\";\n }\n}\n\n/**\n * Mostly an internal type that is used to allow custom validation errors\n *\n * @since 2.9.0\n */\nexport type FileValidationError<E = GenericFileError> =\n | FileAccessError\n | TooManyFilesError\n | FileSizeError\n | FileExtensionError\n | E;\n\n/**\n * A simple type-guard that can be used to check if the\n * {@link FileValidationError} is the {@link GenericFileError} which can be\n * useful when displaying the errors to the user.\n *\n * @param error - The error to check\n * @returns true if the error is a {@link FileAccessError}\n */\nexport function isGenericFileError<CustomError extends object>(\n error: FileValidationError<CustomError>\n): error is GenericFileError {\n return \"name\" in error && error.name === \"GenericFileError\";\n}\n\n/**\n * A simple type-guard that can be used to check if the\n * {@link FileValidationError} is the {@link FileAccessError} which can be\n * useful when displaying the errors to the user.\n *\n * @param error - The error to check\n * @returns true if the error is a {@link FileAccessError}\n */\nexport function isFileAccessError<CustomError extends object>(\n error: FileValidationError<CustomError>\n): error is FileAccessError {\n return \"name\" in error && error.name === \"FileAccessError\";\n}\n\n/**\n * A simple type-guard that can be used to check if the\n * {@link FileValidationError} is the {@link TooManyFilesError} which can be\n * useful when displaying the errors to the user.\n *\n * @param error - The error to check\n * @returns true if the error is a {@link TooManyFilesError}\n */\nexport function isTooManyFilesError<CustomError extends object>(\n error: FileValidationError<CustomError>\n): error is TooManyFilesError {\n return \"name\" in error && error.name === \"TooManyFilesError\";\n}\n\n/**\n * A simple type-guard that can be used to check if the\n * {@link FileValidationError} is the {@link FileSizeError} which can be\n * useful when displaying the errors to the user.\n *\n * @param error - The error to check\n * @returns true if the error is a {@link FileSizeError}\n */\nexport function isFileSizeError<CustomError extends object>(\n error: FileValidationError<CustomError>\n): error is FileSizeError {\n return \"name\" in error && error.name === \"FileSizeError\";\n}\n\n/**\n * A simple type-guard that can be used to check if the\n * {@link FileValidationError} is the {@link FileExtensionError} which can be\n * useful when displaying the errors to the user.\n *\n * @param error - The error to check\n * @returns true if the error is a {@link FileExtensionError}\n */\nexport function isFileExtensionError<CustomError extends object>(\n error: FileValidationError<CustomError>\n): error is FileExtensionError {\n return \"name\" in error && error.name === \"FileExtensionError\";\n}\n\n/**\n * This function is used to determine if a file should be added to the\n * {@link FileExtensionError}. The default implementation should work for most\n * use cases except when files that do not have extensions can be uploaded. i.e.\n * LICENSE files.\n *\n * @param file - The file being checked\n * @param extensionRegExp - A regex that will only be defined if the\n * `extensions` list had at least one value.\n * @param extensions - The list of extensions allowed\n * @returns true if the file has a valid name.\n * @since 3.1.0\n */\nexport type IsValidFileName = (\n file: File,\n extensionRegExp: RegExp | undefined,\n extensions: readonly string[]\n) => boolean;\n\n/**\n *\n * @defaultValue `matcher?.test(file.name) ?? true`\n * @since 3.1.0\n */\nexport const isValidFileName: IsValidFileName = (file, matcher) =>\n matcher?.test(file.name) ?? true;\n\n/** @since 2.9.0 */\nexport interface FileValidationOptions {\n /**\n * If the number of files should be limited, set this value to a number\n * greater than `0`.\n *\n * Note: This still allows \"infinite\" files when set to `0` since the\n * `<input>` element should normally be set to `disabled` if files should not\n * be able to be uploaded.\n *\n * @defaultValue `-1`\n */\n maxFiles?: number;\n\n /**\n * An optional minimum file size to enforce for each file. This will only be\n * used when it is greater than `0`.\n *\n * @defaultValue `-1`\n */\n minFileSize?: number;\n\n /**\n * An optional maximum file size to enforce for each file. This will only be\n * used when it is greater than `0`.\n *\n * @defaultValue `-1`\n */\n maxFileSize?: number;\n\n /**\n * An optional list of extensions to enforce when uploading files.\n *\n * Note: The extensions and file names will be compared ignoring case.\n *\n * @example Only Allow Images\n * ```ts\n * const extensions = [\"png\", \"jpeg\", \"jpg\", \"gif\"];\n * ```\n */\n extensions?: readonly string[];\n\n /** {@inheritDoc IsValidFileName} */\n isValidFileName?: IsValidFileName;\n\n /**\n * An optional total file size to enforce when the {@link maxFiles} option is\n * not set to `1`.\n *\n * @defaultValue `-1`\n */\n totalFileSize?: number;\n}\n\n/** @since 2.9.0 */\nexport interface FilesValidationOptions\n extends Required<FileValidationOptions> {\n /**\n * The total number of bytes in the {@link FileUploadHookReturnValue.stats}\n * list. This is really just:\n *\n * ```ts\n * const totalBytes = stats.reduce((total, stat) => total + stat.file.size, 0);\n * ```\n */\n totalBytes: number;\n\n /**\n * The total number of files in the {@link FileUploadHookReturnValue.stats}.\n */\n totalFiles: number;\n}\n\n/**\n * @since 2.9.0\n */\nexport interface ValidatedFilesResult<CustomError> {\n /**\n * A filtered list of files that have been validated and can be queued for the\n * upload process.\n */\n pending: readonly File[];\n\n /**\n * A list of {@link FileValidationError} that occurred during the validation\n * step.\n *\n * Note: If an error has occurred, the file **should not** be added to the\n * {@link pending} list of files.\n */\n errors: readonly FileValidationError<CustomError>[];\n}\n\n/**\n * This function will be called whenever a file has been uploaded by the user\n * either through an `<input type=\"file\">` or drag and drop behavior.\n *\n * @example Simple Example\n * ```ts\n * const validateFiles: FilesValidator = (files, options) => {\n * const invalid: File[] = [];\n * const pending: File[] = [];\n * for (const file of files) {\n * if (!/\\.(jpe?g|svg|png)$/i.test(name)) {\n * invalid.push(file);\n * } else {\n * pending.push(file);\n * }\n * }\n *\n * const errors: FileValidationError[] = [];\n * if (invalid.length) {\n * errors.push(new GenericFileError(invalid))\n * }\n *\n * return { pending, errors };\n * };\n * ```\n *\n * @typeParam E - An optional custom file validation error.\n * @param files - The list of files to check\n * @param options - The {@link FilesValidationOptions}\n * @returns the {@link ValidatedFilesResult}\n * @see {@link validateFiles} for the default implementation\n * @since 2.9.0\n */\nexport type FilesValidator<CustomError = never> = (\n files: readonly File[],\n options: FilesValidationOptions\n) => ValidatedFilesResult<CustomError>;\n\n/**\n * A pretty decent default implementation for validating files with the\n * {@link useFileUpload} that ensures the {@link FilesValidationOptions} are\n * enforced before allowing a file to be uploaded.\n *\n * @typeParam E - An optional custom file validation error.\n * @param files - The list of files to check\n * @param options - The {@link FilesValidationOptions}\n * @returns the {@link ValidatedFilesResult}\n * @since 2.9.0\n */\nexport function validateFiles<CustomError>(\n files: readonly File[],\n options: FilesValidationOptions\n): ValidatedFilesResult<CustomError> {\n const {\n maxFiles,\n extensions,\n minFileSize,\n maxFileSize,\n totalBytes,\n totalFiles,\n totalFileSize,\n isValidFileName,\n } = options;\n\n const errors: FileValidationError<CustomError>[] = [];\n const pending: File[] = [];\n const extraFiles: File[] = [];\n const extensionRegExp =\n extensions.length > 0\n ? new RegExp(`\\\\.(${extensions.join(\"|\")})$`, \"i\")\n : undefined;\n\n let maxFilesReached = maxFiles > 0 && totalFiles >= maxFiles;\n let remainingBytes = totalFileSize - totalBytes;\n const extensionErrors: File[] = [];\n const minErrors: File[] = [];\n const maxErrors: File[] = [];\n const totalSizeErrors: File[] = [];\n for (let i = 0; i < files.length; i += 1) {\n const file = files[i];\n\n let valid = true;\n const { size } = file;\n if (!isValidFileName(file, extensionRegExp, extensions)) {\n valid = false;\n extensionErrors.push(file);\n }\n\n if (minFileSize > 0 && size < minFileSize) {\n valid = false;\n minErrors.push(file);\n }\n\n if (maxFileSize > 0 && size > maxFileSize) {\n valid = false;\n maxErrors.push(file);\n } else if (totalFileSize > 0 && remainingBytes - file.size < 0) {\n // don't want both errors displaying\n valid = false;\n totalSizeErrors.push(file);\n }\n\n if (maxFilesReached && valid) {\n extraFiles.push(file);\n } else if (!maxFilesReached && valid) {\n pending.push(file);\n remainingBytes -= file.size;\n maxFilesReached =\n maxFilesReached ||\n (maxFiles > 0 && totalFiles + pending.length >= maxFiles);\n }\n }\n\n if (extensionErrors.length) {\n errors.push(new FileExtensionError(extensionErrors, extensions));\n }\n\n if (minErrors.length) {\n errors.push(new FileSizeError(minErrors, \"min\", minFileSize));\n }\n\n if (maxErrors.length) {\n errors.push(new FileSizeError(maxErrors, \"max\", maxFileSize));\n }\n\n if (totalSizeErrors.length) {\n errors.push(new FileSizeError(totalSizeErrors, \"total\", totalFileSize));\n }\n\n if (extraFiles.length) {\n errors.push(new TooManyFilesError(extraFiles, maxFiles));\n }\n\n return { pending, errors };\n}\n"],"names":["nanoid","FileAccessError","Error","message","key","name","GenericFileError","files","reason","TooManyFilesError","limit","FileSizeError","type","FileExtensionError","extensions","isGenericFileError","error","isFileAccessError","isTooManyFilesError","isFileSizeError","isFileExtensionError","isValidFileName","file","matcher","test","validateFiles","options","maxFiles","minFileSize","maxFileSize","totalBytes","totalFiles","totalFileSize","errors","pending","extraFiles","extensionRegExp","length","RegExp","join","undefined","maxFilesReached","remainingBytes","extensionErrors","minErrors","maxErrors","totalSizeErrors","i","valid","size","push"],"mappings":";;;;;;;;;;;;;AAAA,SAASA,MAAM,QAAQ,SAAS;AAEhC;;;;;;CAMC,GACD,OAAO,MAAMC,wBAAwBC;IAMnC;;;GAGC,GACD,YAAYC,OAAgB,CAAE;QAC5B,KAAK,CAACA,UAVR;;GAEC,GACD,uBAAOC,OAAP,KAAA;QAQE,IAAI,CAACA,GAAG,G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ACRJ,UAAUM,IAAI,CAAC5B;QACjB;QAEA,IAAIO,cAAc,KAAKoB,OAAOpB,aAAa;YACzCmB,QAAQ;YACRH,UAAUK,IAAI,CAAC5B;QACjB,OAAO,IAAIU,gBAAgB,KAAKU,iBAAiBpB,KAAK2B,IAAI,GAAG,GAAG;YAC9D,oCAAoC;YACpCD,QAAQ;YACRF,gBAAgBI,IAAI,CAAC5B;QACvB;QAEA,IAAImB,mBAAmBO,OAAO;YAC5Bb,WAAWe,IAAI,CAAC5B;QAClB,OAAO,IAAI,CAACmB,mBAAmBO,OAAO;YACpCd,QAAQgB,IAAI,CAAC5B;YACboB,kBAAkBpB,KAAK2B,IAAI;YAC3BR,kBACEA,mBACCd,WAAW,KAAKI,aAAaG,QAAQG,MAAM,IAAIV;QACpD;IACF;IAEA,IAAIgB,gBAAgBN,MAAM,EAAE;QAC1BJ,OAAOiB,IAAI,CAAC,IAAIrC,mBAAmB8B,iBAAiB7B;IACtD;IAEA,IAAI8B,UAAUP,MAAM,EAAE;QACpBJ,OAAOiB,IAAI,CAAC,IAAIvC,cAAciC,WAAW,OAAOhB;IAClD;IAEA,IAAIiB,UAAUR,MAAM,EAAE;QACpBJ,OAAOiB,IAAI,CAAC,IAAIvC,cAAckC,WAAW,OAAOhB;IAClD;IAEA,IAAIiB,gBAAgBT,MAAM,EAAE;QAC1BJ,OAAOiB,IAAI,CAAC,IAAIvC,cAAcmC,iBAAiB,SAASd;IAC1D;IAEA,IAAIG,WAAWE,MAAM,EAAE;QACrBJ,OAAOiB,IAAI,CAAC,IAAIzC,kBAAkB0B,YAAYR;IAChD;IAEA,OAAO;QAAEO;QAASD;IAAO;AAC3B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/form/InputToggle.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport {\n type CSSProperties,\n type HTMLAttributes,\n type InputHTMLAttributes,\n type LabelHTMLAttributes,\n type ReactNode,\n forwardRef,\n} from \"react\";\n\nimport { type ComponentWithRippleProps } from \"../interaction/types.js\";\nimport { useElementInteraction } from \"../interaction/useElementInteraction.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { FormMessageContainer } from \"./FormMessageContainer.js\";\nimport { InputToggleIcon } from \"./InputToggleIcon.js\";\nimport { Label } from \"./Label.js\";\nimport { type InputToggleSize } from \"./inputToggleStyles.js\";\nimport {\n type FormComponentStates,\n type FormMessageContainerExtension,\n} from \"./types.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface ConfigurableInputToggleIconProps {\n /**\n * @see {@link InputToggleSize}\n * @defaultValue `\"normal\"`\n */\n size?: InputToggleSize;\n\n /**\n * The icon to use while unchecked. This defaults to the unchecked\n * checkbox/radio icon from the `ICON_CONFIG`.\n *\n * @defaultValue `getIcon(props.type)`\n */\n icon?: ReactNode;\n\n /**\n * The icon to use while unchecked. This defaults to the unchecked\n * checkbox/radio icon from the `ICON_CONFIG`.\n *\n * @defaultValue `getIcon(``${props.type}Checked``)`\n */\n checkedIcon?: ReactNode;\n\n /**\n * Any props that should be passed to the `<span>` that surrounds the current\n * icon element.\n */\n iconProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n\n /**\n * Optional style to set on the `<span>` that surrounds the current icon\n * element.\n */\n iconStyle?: CSSProperties;\n\n /**\n * Optional className to set on the `<span>` that surrounds the current icon\n * element.\n */\n iconClassName?: string;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface InputToggleLabelProps {\n /**\n * An optional label to display with the checkbox. If this is omitted, it is\n * recommended to provide an `aria-label` for accessibility.\n */\n label?: ReactNode;\n\n /**\n * Any props that should be passed to the `<Label>` component.\n *\n * Note: If `style` or `className` are provided in this object, they will be\n * ignored. Use the top-level `style` and `className` props instead.\n *\n * @example\n * ```\n * // bad\n * labelProps={{\n * \"aria-label\": \"checkbox\",\n * style: { color: \"red\" },\n * className: \"custom\"\n * }}\n *\n * // good\n * style={{ color: \"red\" }}\n * className=\"custom\"\n * labelProps={{\n * \"aria-label\": \"checkbox\",\n * }}\n * ```\n */\n labelProps?: PropsWithRef<LabelHTMLAttributes<HTMLLabelElement>>;\n\n /**\n * @see {@link LabelClassNameOptions.gap}\n * @defaultValue `false`\n */\n disableLabelGap?: boolean;\n\n /**\n * Set this to `true` to swap the position of the {@link label} and the current\n * icon. This prop can be used with the {@link stacked} prop to change the\n * position if the icon and label:\n *\n * ____________________________________\n * | stacked | iconAfter | position |\n * ____________________________________\n * | | | icon label |\n * ____________________________________\n * | | X | label icon |\n * ____________________________________\n * | X | | icon |\n * | | | label |\n * ____________________________________\n * | X | X | label |\n * | | | icon |\n * ____________________________________\n *\n *\n * @defaultValue `false`\n */\n iconAfter?: boolean;\n\n /**\n * Set this to `true` if the label should be stacked instead of inline with\n * the current icon.\n *\n * @see {@link iconAfter}\n * @defaultValue `false`\n */\n stacked?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface BaseInputToggleProps\n extends Omit<InputHTMLAttributes<HTMLInputElement>, \"size\">,\n FormMessageContainerExtension,\n FormComponentStates,\n ConfigurableInputToggleIconProps,\n InputToggleLabelProps,\n ComponentWithRippleProps {\n /**\n * @see https://stackoverflow.com/questions/5985839/bug-with-firefox-disabled-attribute-of-input-not-resetting-when-refreshing\n * @defaultValue `type === \"checkbox\" ? \"off\" : undefined`\n */\n autoComplete?: string;\n}\n\n/**\n * @since 2.8.5\n * @since 6.0.0 Removed the `aria-controls` prop and added the\n * `indeterminateIcon` prop.\n */\nexport interface IndeterminateCheckboxProps {\n /**\n * Set this value to `true` if the checkbox is in an \"indeterminate\" state:\n *\n * - this checkbox controls the select all/select none behavior of other\n * checkboxes in a group\n * - at least one of the checkboxes have been checked\n * - the `checked` prop for this Checkbox should also be `true`\n *\n * You should normally use the `useCheckboxGroup` hook to handle this\n * behavior.\n *\n * @defaultValue `false`\n */\n indeterminate?: boolean;\n\n /**\n * The icon to display when the checkbox is checked and the\n * {@link indeterminate} prop is `true`.\n *\n * @defaultValue `getIcon(\"checkboxIndeterminate\")`\n * @since 6.0.0\n */\n indeterminateIcon?: ReactNode;\n}\n\nexport interface CheckboxProps\n extends BaseInputToggleProps,\n IndeterminateCheckboxProps {}\n\n/** @since 6.0.0 */\nexport interface CheckboxInputToggleProps extends CheckboxProps {\n type: \"checkbox\";\n}\n\nexport interface RadioProps extends BaseInputToggleProps {\n /**\n * The value for the radio button.\n *\n * @since 6.0.0 This is now optional and no longer supports\n * `string[]` since there isn't much of a use case for array values.\n */\n value?: string | number;\n}\n\n/** @since 6.0.0 */\nexport interface RadioInputToggleProps extends RadioProps {\n type: \"radio\";\n}\n\n/**\n * @since 6.0.0 Updated to be a union between\n * `CheckboxInputToggleProps` and `RadioInputToggleProps`\n */\nexport type InputToggleProps = CheckboxInputToggleProps | RadioInputToggleProps;\n\n/**\n * **Client Component**\n *\n * @see {@link https://react-md.dev/components/checkbox | Checkbox Demos}\n * @see {@link https://react-md.dev/components/radio | Radio Demos}\n * @since 6.0.0 Now supports the `FormMessage` behavior and requires\n * different icons for each checked state.\n */\nexport const InputToggle = forwardRef<HTMLInputElement, InputToggleProps>(\n function InputToggle(props, ref) {\n const {\n id: propId,\n type,\n label,\n labelProps,\n style,\n className,\n autoComplete = type === \"checkbox\" ? \"off\" : undefined,\n disableLabelGap = false,\n stacked = false,\n iconAfter = false,\n size = \"normal\",\n error = false,\n active = false,\n indeterminate = false,\n messageProps,\n messageContainerProps,\n icon,\n checkedIcon,\n indeterminateIcon,\n iconProps,\n iconStyle,\n iconClassName,\n onBlur,\n onClick,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseLeave,\n onDragStart,\n onMouseUp,\n onTouchEnd,\n onTouchMove,\n onTouchStart,\n disableRipple,\n ...remaining\n } = props as CheckboxInputToggleProps;\n const { disabled = false, checked } = props;\n\n const id = useEnsuredId(propId, type);\n const { pressedClassName, ripples, handlers } = useElementInteraction({\n mode: disableRipple ? \"none\" : undefined,\n disabled,\n onBlur,\n onClick,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseLeave,\n onDragStart,\n onMouseUp,\n onTouchEnd,\n onTouchMove,\n onTouchStart,\n });\n\n // set on the `remaining` object to bypass the eslint rule about\n // aria-checked not being valid for textbox role\n remaining[\"aria-checked\"] =\n (remaining[\"aria-checked\"] ?? indeterminate) ? \"mixed\" : undefined;\n\n return (\n <FormMessageContainer\n {...messageContainerProps}\n messageProps={messageProps}\n >\n <Label\n {...labelProps}\n gap={!disableLabelGap}\n style={style}\n stacked={stacked}\n reversed={!iconAfter}\n active={active}\n error={error}\n disabled={disabled}\n className={className}\n >\n {label}\n <InputToggleIcon\n style={iconStyle}\n {...iconProps}\n className={cnb(\n pressedClassName,\n iconClassName,\n iconProps?.className\n )}\n error={error}\n checked={checked}\n disabled={disabled}\n size={size}\n type={type}\n icon={icon}\n checkedIcon={checkedIcon}\n indeterminate={indeterminate}\n indeterminateIcon={indeterminateIcon}\n >\n <input\n {...remaining}\n {...handlers}\n autoComplete={autoComplete}\n id={id}\n ref={ref}\n type={type}\n className=\"rmd-hidden-input\"\n />\n {ripples}\n </InputToggleIcon>\n </Label>\n </FormMessageContainer>\n );\n }\n);\n"],"names":["cnb","forwardRef","useElementInteraction","useEnsuredId","FormMessageContainer","InputToggleIcon","Label","InputToggle","props","ref","id","propId","type","label","labelProps","style","className","autoComplete","undefined","disableLabelGap","stacked","iconAfter","size","error","active","indeterminate","messageProps","messageContainerProps","icon","checkedIcon","indeterminateIcon","iconProps","iconStyle","iconClassName","onBlur","onClick","onKeyDown","onKeyUp","onMouseDown","onMouseLeave","onDragStart","onMouseUp","onTouchEnd","onTouchMove","onTouchStart","disableRipple","remaining","disabled","checked","pressedClassName","ripples","handlers","mode","gap","reversed","input"],"mappings":"AAAA;;AAEA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAMEC,UAAU,QACL,QAAQ;AAGf,SAASC,qBAAqB,QAAQ,0CAA0C;AAEhF,SAASC,YAAY,QAAQ,qBAAqB;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AK,CAAClC;YACNJ,OAAOA;YACPK,SAASA;YACTkC,UAAU,CAACjC;YACXG,QAAQA;YACRD,OAAOA;YACPwB,UAAUA;YACV/B,WAAWA;;gBAEVH;8BACD,MAACR;oBACCU,OAAOiB;oBACN,GAAGD,SAAS;oBACbf,WAAWhB,IACTiD,kBACAhB,eACAF,WAAWf;oBAEbO,OAAOA;oBACPyB,SAASA;oBACTD,UAAUA;oBACVzB,MAAMA;oBACNV,MAAMA;oBACNgB,MAAMA;oBACNC,aAAaA;oBACbJ,eAAeA;oBACfK,mBAAmBA;;sCAEnB,KAACyB;4BACE,GAAGT,SAAS;4BACZ,GAAGK,QAAQ;4BACZlC,cAAcA;4BACdP,IAAIA;4BACJD,KAAKA;4BACLG,MAAMA;4BACNI,WAAU;;wBAEXkC;;;;;;AAKX,GACA"}
1
+ {"version":3,"sources":["../../src/form/InputToggle.tsx"],"sourcesContent":["\"use client\";\n\nimport { cnb } from \"cnbuilder\";\nimport {\n type CSSProperties,\n type HTMLAttributes,\n type InputHTMLAttributes,\n type LabelHTMLAttributes,\n type ReactNode,\n forwardRef,\n} from \"react\";\n\nimport { type ComponentWithRippleProps } from \"../interaction/types.js\";\nimport { useElementInteraction } from \"../interaction/useElementInteraction.js\";\nimport { type PropsWithRef } from \"../types.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { FormMessageContainer } from \"./FormMessageContainer.js\";\nimport { InputToggleIcon } from \"./InputToggleIcon.js\";\nimport { Label } from \"./Label.js\";\nimport { type InputToggleSize } from \"./inputToggleStyles.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type LabelClassNameOptions } from \"./types.js\";\nimport {\n type FormComponentStates,\n type FormMessageContainerExtension,\n} from \"./types.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface ConfigurableInputToggleIconProps {\n /**\n * @see {@link InputToggleSize}\n * @defaultValue `\"normal\"`\n */\n size?: InputToggleSize;\n\n /**\n * The icon to use while unchecked. This defaults to the unchecked\n * checkbox/radio icon from the `ICON_CONFIG`.\n *\n * @defaultValue `getIcon(props.type)`\n */\n icon?: ReactNode;\n\n /**\n * The icon to use while unchecked. This defaults to the unchecked\n * checkbox/radio icon from the `ICON_CONFIG`.\n *\n * @defaultValue `getIcon(``${props.type}Checked``)`\n */\n checkedIcon?: ReactNode;\n\n /**\n * Any props that should be passed to the `<span>` that surrounds the current\n * icon element.\n */\n iconProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;\n\n /**\n * Optional style to set on the `<span>` that surrounds the current icon\n * element.\n */\n iconStyle?: CSSProperties;\n\n /**\n * Optional className to set on the `<span>` that surrounds the current icon\n * element.\n */\n iconClassName?: string;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface InputToggleLabelProps {\n /**\n * An optional label to display with the checkbox. If this is omitted, it is\n * recommended to provide an `aria-label` for accessibility.\n */\n label?: ReactNode;\n\n /**\n * Any props that should be passed to the `<Label>` component.\n *\n * Note: If `style` or `className` are provided in this object, they will be\n * ignored. Use the top-level `style` and `className` props instead.\n *\n * @example\n * ```\n * // bad\n * labelProps={{\n * \"aria-label\": \"checkbox\",\n * style: { color: \"red\" },\n * className: \"custom\"\n * }}\n *\n * // good\n * style={{ color: \"red\" }}\n * className=\"custom\"\n * labelProps={{\n * \"aria-label\": \"checkbox\",\n * }}\n * ```\n */\n labelProps?: PropsWithRef<LabelHTMLAttributes<HTMLLabelElement>>;\n\n /**\n * @see {@link LabelClassNameOptions.gap}\n * @defaultValue `false`\n */\n disableLabelGap?: boolean;\n\n /**\n * Set this to `true` to swap the position of the {@link label} and the current\n * icon. This prop can be used with the {@link stacked} prop to change the\n * position if the icon and label:\n *\n * ____________________________________\n * | stacked | iconAfter | position |\n * ____________________________________\n * | | | icon label |\n * ____________________________________\n * | | X | label icon |\n * ____________________________________\n * | X | | icon |\n * | | | label |\n * ____________________________________\n * | X | X | label |\n * | | | icon |\n * ____________________________________\n *\n *\n * @defaultValue `false`\n */\n iconAfter?: boolean;\n\n /**\n * Set this to `true` if the label should be stacked instead of inline with\n * the current icon.\n *\n * @see {@link iconAfter}\n * @defaultValue `false`\n */\n stacked?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface BaseInputToggleProps\n extends Omit<InputHTMLAttributes<HTMLInputElement>, \"size\">,\n FormMessageContainerExtension,\n FormComponentStates,\n ConfigurableInputToggleIconProps,\n InputToggleLabelProps,\n ComponentWithRippleProps {\n /**\n * @see https://stackoverflow.com/questions/5985839/bug-with-firefox-disabled-attribute-of-input-not-resetting-when-refreshing\n * @defaultValue `type === \"checkbox\" ? \"off\" : undefined`\n */\n autoComplete?: string;\n}\n\n/**\n * @since 2.8.5\n * @since 6.0.0 Removed the `aria-controls` prop and added the\n * `indeterminateIcon` prop.\n */\nexport interface IndeterminateCheckboxProps {\n /**\n * Set this value to `true` if the checkbox is in an \"indeterminate\" state:\n *\n * - this checkbox controls the select all/select none behavior of other\n * checkboxes in a group\n * - at least one of the checkboxes have been checked\n * - the `checked` prop for this Checkbox should also be `true`\n *\n * You should normally use the `useCheckboxGroup` hook to handle this\n * behavior.\n *\n * @defaultValue `false`\n */\n indeterminate?: boolean;\n\n /**\n * The icon to display when the checkbox is checked and the\n * {@link indeterminate} prop is `true`.\n *\n * @defaultValue `getIcon(\"checkboxIndeterminate\")`\n * @since 6.0.0\n */\n indeterminateIcon?: ReactNode;\n}\n\nexport interface CheckboxProps\n extends BaseInputToggleProps,\n IndeterminateCheckboxProps {}\n\n/** @since 6.0.0 */\nexport interface CheckboxInputToggleProps extends CheckboxProps {\n type: \"checkbox\";\n}\n\nexport interface RadioProps extends BaseInputToggleProps {\n /**\n * The value for the radio button.\n *\n * @since 6.0.0 This is now optional and no longer supports\n * `string[]` since there isn't much of a use case for array values.\n */\n value?: string | number;\n}\n\n/** @since 6.0.0 */\nexport interface RadioInputToggleProps extends RadioProps {\n type: \"radio\";\n}\n\n/**\n * @since 6.0.0 Updated to be a union between\n * `CheckboxInputToggleProps` and `RadioInputToggleProps`\n */\nexport type InputToggleProps = CheckboxInputToggleProps | RadioInputToggleProps;\n\n/**\n * **Client Component**\n *\n * @see {@link https://react-md.dev/components/checkbox | Checkbox Demos}\n * @see {@link https://react-md.dev/components/radio | Radio Demos}\n * @since 6.0.0 Now supports the `FormMessage` behavior and requires\n * different icons for each checked state.\n */\nexport const InputToggle = forwardRef<HTMLInputElement, InputToggleProps>(\n function InputToggle(props, ref) {\n const {\n id: propId,\n type,\n label,\n labelProps,\n style,\n className,\n autoComplete = type === \"checkbox\" ? \"off\" : undefined,\n disableLabelGap = false,\n stacked = false,\n iconAfter = false,\n size = \"normal\",\n error = false,\n active = false,\n indeterminate = false,\n messageProps,\n messageContainerProps,\n icon,\n checkedIcon,\n indeterminateIcon,\n iconProps,\n iconStyle,\n iconClassName,\n onBlur,\n onClick,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseLeave,\n onDragStart,\n onMouseUp,\n onTouchEnd,\n onTouchMove,\n onTouchStart,\n disableRipple,\n ...remaining\n } = props as CheckboxInputToggleProps;\n const { disabled = false, checked } = props;\n\n const id = useEnsuredId(propId, type);\n const { pressedClassName, ripples, handlers } = useElementInteraction({\n mode: disableRipple ? \"none\" : undefined,\n disabled,\n onBlur,\n onClick,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseLeave,\n onDragStart,\n onMouseUp,\n onTouchEnd,\n onTouchMove,\n onTouchStart,\n });\n\n // set on the `remaining` object to bypass the eslint rule about\n // aria-checked not being valid for textbox role\n remaining[\"aria-checked\"] =\n (remaining[\"aria-checked\"] ?? indeterminate) ? \"mixed\" : undefined;\n\n return (\n <FormMessageContainer\n {...messageContainerProps}\n messageProps={messageProps}\n >\n <Label\n {...labelProps}\n gap={!disableLabelGap}\n style={style}\n stacked={stacked}\n reversed={!iconAfter}\n active={active}\n error={error}\n disabled={disabled}\n className={className}\n >\n {label}\n <InputToggleIcon\n style={iconStyle}\n {...iconProps}\n className={cnb(\n pressedClassName,\n iconClassName,\n iconProps?.className\n )}\n error={error}\n checked={checked}\n disabled={disabled}\n size={size}\n type={type}\n icon={icon}\n checkedIcon={checkedIcon}\n indeterminate={indeterminate}\n indeterminateIcon={indeterminateIcon}\n >\n <input\n {...remaining}\n {...handlers}\n autoComplete={autoComplete}\n id={id}\n ref={ref}\n type={type}\n className=\"rmd-hidden-input\"\n />\n {ripples}\n </InputToggleIcon>\n </Label>\n </FormMessageContainer>\n );\n }\n);\n"],"names":["cnb","forwardRef","useElementInteraction","useEnsuredId","FormMessageContainer","InputToggleIcon","Label","InputToggle","props","ref","id","propId","type","label","labelProps","style","className","autoComplete","undefined","disableLabelGap","stacked","iconAfter","size","error","active","indeterminate","messageProps","messageContainerProps","icon","checkedIcon","indeterminateIcon","iconProps","iconStyle","iconClassName","onBlur","onClick","onKeyDown","onKeyUp","onMouseDown","onMouseLeave","onDragStart","onMouseUp","onTouchEnd","onTouchMove","onTouchStart","disableRipple","remaining","disabled","checked","pressedClassName","ripples","handlers","mode","gap","reversed","input"],"mappings":"AAAA;;AAEA,SAASA,GAAG,QAAQ,YAAY;AAChC,SAMEC,UAAU,QACL,QAAQ;AAGf,SAASC,qBAAqB,QAAQ,0CAA0C;AAEhF,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,oBAAoB,QAAQ,4BAA4B;AACjE,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,KAAK,QAAQ,aAAa;AA+MnC;;;;;;;CAOC,GACD,OAAO,MAAMC,4BAAcN,WACzB,SAASM,YAAYC,KAAK,EAAEC,GAAG;IAC7B,MAAM,EACJC,IAAIC,MAAM,EACVC,IAAI,EACJC,KAAK,EACLC,UAAU,EACVC,KAAK,EACLC,SAAS,EACTC,eAAeL,SAAS,aAAa,QAAQM,SAAS,EACtDC,kBAAkB,KAAK,EACvBC,UAAU,KAAK,EACfC,YAAY,KAAK,EACjBC,OAAO,QAAQ,EACfC,QAAQ,KAAK,EACbC,SAAS,KAAK,EACdC,gBAAgB,KAAK,EACrBC,YAAY,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BACNI,WAAU;;wBAEXkC;;;;;;AAKX,GACA"}
@@ -1,14 +1,4 @@
1
1
  import { type LabelProps } from "./types.js";
2
- declare module "react" {
3
- interface CSSProperties {
4
- "--rmd-label-floating-x"?: string | number;
5
- "--rmd-label-floating-y"?: string | number;
6
- "--rmd-label-floating-active-x"?: string | number;
7
- "--rmd-label-floating-active-y"?: string | number;
8
- "--rmd-label-active-padding"?: string | number;
9
- "--rmd-label-active-background-color"?: string;
10
- }
11
- }
12
2
  /**
13
3
  * Most of the form components already use this `Label` internally when a
14
4
  * `label` prop has been provided. You should generally use this component if
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/form/Label.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\n\nimport { label } from \"./labelStyles.js\";\nimport { type LabelProps } from \"./types.js\";\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-label-floating-x\"?: string | number;\n \"--rmd-label-floating-y\"?: string | number;\n \"--rmd-label-floating-active-x\"?: string | number;\n \"--rmd-label-floating-active-y\"?: string | number;\n \"--rmd-label-active-padding\"?: string | number;\n \"--rmd-label-active-background-color\"?: string;\n }\n}\n\n/**\n * Most of the form components already use this `Label` internally when a\n * `label` prop has been provided. You should generally use this component if\n * you need to separate the label from an existing form component or you need to\n * create a custom implementation of a form component.\n *\n * @see {@link https://react-md.dev/components/select | Select Demos}\n * @see {@link https://react-md.dev/components/text-field | TextField Demos}\n * @see {@link https://react-md.dev/components/text-field#simple-textarea | TextArea Demos}\n * @since 6.0.0 Updated to be usable externally and combines the\n * floating label styles instead of having separate components.\n */\nexport const Label = forwardRef<HTMLLabelElement, LabelProps>(\n function Label(props, ref) {\n const {\n gap,\n error,\n dense,\n active,\n stacked,\n reversed,\n disabled,\n floating,\n inactive,\n floatingActive = active,\n className,\n children,\n ...remaining\n } = props;\n\n return (\n <label\n ref={ref}\n {...remaining}\n className={label({\n gap,\n error,\n dense,\n active,\n stacked,\n reversed,\n disabled,\n floating,\n floatingActive,\n inactive,\n className,\n })}\n >\n {children}\n </label>\n );\n }\n);\n"],"names":["forwardRef","label","Label","props","ref","gap","error","dense","active","stacked","reversed","disabled","floating","inactive","floatingActive","className","children","remaining"],"mappings":";AAAA,SAASA,UAAU,QAAQ,QAAQ;AAEnC,SAASC,KAAK,QAAQ,mBAAmB;AAczC;;;;;;;;;;;CAWC,GACD,OAAO,MAAMC,sBAAQF,WACnB,SAASE,MAAMC,KAAK,EAAEC,GAAG;IACvB,MAAM,EACJC,GAAG,EACHC,KAAK,EACLC,KAAK,EACLC,MAAM,EACNC,OAAO,EACPC,QAAQ,EACRC,QAAQ,EACRC,QAAQ,EACRC,QAAQ,EACRC,iBAAiBN,MAAM,EACvBO,SAAS,EACTC,QAAQ,EACR,GAAGC,WACJ,GAAGd;IAEJ,qBACE,KAACF;QACCG,KAAKA;QACJ,GAAGa,SAAS;QACbF,WAAWd,MAAM;YACfI;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAE;YACAD;YACAE;QACF;kBAECC;;AAGP,GACA"}
1
+ {"version":3,"sources":["../../src/form/Label.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\n\nimport { label } from \"./labelStyles.js\";\nimport { type LabelProps } from \"./types.js\";\n\n/**\n * Most of the form components already use this `Label` internally when a\n * `label` prop has been provided. You should generally use this component if\n * you need to separate the label from an existing form component or you need to\n * create a custom implementation of a form component.\n *\n * @see {@link https://react-md.dev/components/select | Select Demos}\n * @see {@link https://react-md.dev/components/text-field | TextField Demos}\n * @see {@link https://react-md.dev/components/text-field#simple-textarea | TextArea Demos}\n * @since 6.0.0 Updated to be usable externally and combines the\n * floating label styles instead of having separate components.\n */\nexport const Label = forwardRef<HTMLLabelElement, LabelProps>(\n function Label(props, ref) {\n const {\n gap,\n error,\n dense,\n active,\n stacked,\n reversed,\n disabled,\n floating,\n inactive,\n floatingActive = active,\n className,\n children,\n ...remaining\n } = props;\n\n return (\n <label\n ref={ref}\n {...remaining}\n className={label({\n gap,\n error,\n dense,\n active,\n stacked,\n reversed,\n disabled,\n floating,\n floatingActive,\n inactive,\n className,\n })}\n >\n {children}\n </label>\n );\n }\n);\n"],"names":["forwardRef","label","Label","props","ref","gap","error","dense","active","stacked","reversed","disabled","floating","inactive","floatingActive","className","children","remaining"],"mappings":";AAAA,SAASA,UAAU,QAAQ,QAAQ;AAEnC,SAASC,KAAK,QAAQ,mBAAmB;AAGzC;;;;;;;;;;;CAWC,GACD,OAAO,MAAMC,sBAAQF,WACnB,SAASE,MAAMC,KAAK,EAAEC,GAAG;IACvB,MAAM,EACJC,GAAG,EACHC,KAAK,EACLC,KAAK,EACLC,MAAM,EACNC,OAAO,EACPC,QAAQ,EACRC,QAAQ,EACRC,QAAQ,EACRC,QAAQ,EACRC,iBAAiBN,MAAM,EACvBO,SAAS,EACTC,QAAQ,EACR,GAAGC,WACJ,GAAGd;IAEJ,qBACE,KAACF;QACCG,KAAKA;QACJ,GAAGa,SAAS;QACbF,WAAWd,MAAM;YACfI;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAE;YACAD;YACAE;QACF;kBAECC;;AAGP,GACA"}