@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,9 +1,24 @@
1
1
  import { type BackgroundColor } from "../cssUtils.js";
2
- /** @since 6.0.0 */
3
- export interface ToastClassNameOptions {
2
+ declare module "react" {
3
+ interface CSSProperties {
4
+ "--rmd-toast-color"?: string;
5
+ "--rmd-toast-background-color"?: string;
6
+ "--rmd-toast-offset"?: string | number;
7
+ }
8
+ }
9
+ /**
10
+ * @since 6.3.1
11
+ */
12
+ export interface BaseToastClasNameOptions {
4
13
  className?: string;
5
14
  /** @defaultValue `"surface"` */
6
15
  theme?: BackgroundColor;
16
+ }
17
+ /**
18
+ * @since 6.0.0
19
+ * @since 6.3.1 Extends BaseToastClasNameOptions
20
+ */
21
+ export interface ToastClassNameOptions extends BaseToastClasNameOptions {
7
22
  /** @defaultValue `false` */
8
23
  action?: boolean;
9
24
  /** @defaultValue `false` */
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/snackbar/toastStyles.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-toast\");\n\n/** @since 6.0.0 */\nexport interface ToastClassNameOptions {\n className?: string;\n /** @defaultValue `\"surface\"` */\n theme?: BackgroundColor;\n /** @defaultValue `false` */\n action?: boolean;\n /** @defaultValue `false` */\n paused?: boolean;\n /** @defaultValue `false` */\n stacked?: boolean;\n /** @defaultValue `false` */\n reordered?: boolean;\n /** @defaultValue `false` */\n closeButton?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function toast(options: ToastClassNameOptions = {}): string {\n const {\n className,\n theme = \"surface\",\n action,\n paused,\n stacked,\n reordered,\n closeButton,\n } = options;\n\n return cnb(\n styles({\n x: closeButton,\n action,\n paused,\n \"small-gap\": closeButton && action,\n stacked,\n reordered: stacked && reordered,\n }),\n cssUtils({\n backgroundColor:\n theme !== \"surface\" && theme !== \"current-color\" ? theme : undefined,\n }),\n className\n );\n}\n"],"names":["cnb","cssUtils","bem","styles","toast","options","className","theme","action","paused","stacked","reordered","closeButton","x","backgroundColor","undefined"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAA+BC,QAAQ,QAAQ,iBAAiB;AAChE,SAASC,GAAG,QAAQ,kBAAkB;AAEtC,MAAMC,SAASD,IAAI;AAmBnB;;CAEC,GACD,OAAO,SAASE,MAAMC,UAAiC,CAAC,CAAC;IACvD,MAAM,EACJC,SAAS,EACTC,QAAQ,SAAS,EACjBC,MAAM,EACNC,MAAM,EACNC,OAAO,EACPC,SAAS,EACTC,WAAW,EACZ,GAAGP;IAEJ,OAAOL,IACLG,OAAO;QACLU,GAAGD;QACHJ;QACAC;QACA,aAAaG,eAAeJ;QAC5BE;QACAC,WAAWD,WAAWC;IACxB,IACAV,SAAS;QACPa,iBACEP,UAAU,aAAaA,UAAU,kBAAkBA,QAAQQ;IAC/D,IACAT;AAEJ"}
1
+ {"version":3,"sources":["../../src/snackbar/toastStyles.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-toast\");\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-toast-color\"?: string;\n \"--rmd-toast-background-color\"?: string;\n \"--rmd-toast-offset\"?: string | number;\n }\n}\n\n/**\n * @since 6.3.1\n */\nexport interface BaseToastClasNameOptions {\n className?: string;\n\n /** @defaultValue `\"surface\"` */\n theme?: BackgroundColor;\n}\n\n/**\n * @since 6.0.0\n * @since 6.3.1 Extends BaseToastClasNameOptions\n */\nexport interface ToastClassNameOptions extends BaseToastClasNameOptions {\n /** @defaultValue `false` */\n action?: boolean;\n /** @defaultValue `false` */\n paused?: boolean;\n /** @defaultValue `false` */\n stacked?: boolean;\n /** @defaultValue `false` */\n reordered?: boolean;\n /** @defaultValue `false` */\n closeButton?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function toast(options: ToastClassNameOptions = {}): string {\n const {\n className,\n theme = \"surface\",\n action,\n paused,\n stacked,\n reordered,\n closeButton,\n } = options;\n\n return cnb(\n styles({\n x: closeButton,\n action,\n paused,\n \"small-gap\": closeButton && action,\n stacked,\n reordered: stacked && reordered,\n }),\n cssUtils({\n backgroundColor:\n theme !== \"surface\" && theme !== \"current-color\" ? theme : undefined,\n }),\n className\n );\n}\n"],"names":["cnb","cssUtils","bem","styles","toast","options","className","theme","action","paused","stacked","reordered","closeButton","x","backgroundColor","undefined"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAA+BC,QAAQ,QAAQ,iBAAiB;AAChE,SAASC,GAAG,QAAQ,kBAAkB;AAEtC,MAAMC,SAASD,IAAI;AAqCnB;;CAEC,GACD,OAAO,SAASE,MAAMC,UAAiC,CAAC,CAAC;IACvD,MAAM,EACJC,SAAS,EACTC,QAAQ,SAAS,EACjBC,MAAM,EACNC,MAAM,EACNC,OAAO,EACPC,SAAS,EACTC,WAAW,EACZ,GAAGP;IAEJ,OAAOL,IACLG,OAAO;QACLU,GAAGD;QACHJ;QACAC;QACA,aAAaG,eAAeJ;QAC5BE;QACAC,WAAWD,WAAWC;IACxB,IACAV,SAAS;QACPa,iBACEP,UAAU,aAAaA,UAAU,kBAAkBA,QAAQQ;IAC/D,IACAT;AAEJ"}
@@ -1,49 +1,17 @@
1
1
  import { type AnchorHTMLAttributes, type ButtonHTMLAttributes, type ReactElement, type ReactNode } from "react";
2
2
  import { type ComponentWithRippleProps } from "../interaction/types.js";
3
3
  import { type CustomLinkComponent } from "../link/Link.js";
4
- declare module "react" {
5
- interface CSSProperties {
6
- "--rmd-tab-color"?: string;
7
- "--rmd-tab-active-color"?: string;
8
- "--rmd-tab-inactive-color"?: string;
9
- "--rmd-tab-disabled-color"?: string;
10
- "--rmd-tab-size"?: string;
11
- "--rmd-tab-offset"?: string | number;
12
- "--rmd-tab-min-width"?: string;
13
- "--rmd-tab-max-width"?: string;
14
- "--rmd-tab-min-height"?: string;
15
- "--rmd-tab-stacked-height"?: string;
16
- "--rmd-tab-stacked-width"?: string;
17
- "--rmd-tab-padding"?: string | number;
18
- "--rmd-tab-stacked-padding"?: string | number;
19
- "--rmd-tab-indicator-background"?: string;
20
- }
21
- }
4
+ import { type BaseTabClassNameOptions } from "./tabStyles.js";
22
5
  /**
23
6
  * @since 6.0.0
24
7
  */
25
- export interface BaseTabProps extends ComponentWithRippleProps {
8
+ export interface BaseTabProps extends ComponentWithRippleProps, BaseTabClassNameOptions {
26
9
  /**
27
10
  * Set this to `true` if the tab is currently active.
28
11
  *
29
12
  * This is normally provided by the {@link useTabs} hook.
30
13
  */
31
14
  active: boolean;
32
- /**
33
- * Set this to `true` if the {@link TabListProps.disableTransition} prop has
34
- * also been set to `true` to disable an active indicator below the tab when
35
- * {@link active} is `true`.
36
- *
37
- * @defaultValue `false`
38
- */
39
- activeIndicator?: boolean;
40
- /**
41
- * Set this to `true` when rendering the tabs vertically and
42
- * {@link activeIndicator} has been enabled.
43
- *
44
- * @defaultValue !false
45
- */
46
- verticalActiveIndicator?: boolean;
47
15
  /**
48
16
  * An optional icon to render with the with the {@link children}. The default
49
17
  * behavior will render this icon before the children.
@@ -58,13 +26,6 @@ export interface BaseTabProps extends ComponentWithRippleProps {
58
26
  * @defaultValue `false`
59
27
  */
60
28
  iconAfter?: boolean;
61
- /**
62
- * Set this to `true` to render the {@link icon} and {@link children} stacked
63
- * instead of horizontally.
64
- *
65
- * @defaultValue `false`
66
- */
67
- stacked?: boolean;
68
29
  }
69
30
  /**
70
31
  * @since 6.0.0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/tabs/Tab.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type AnchorHTMLAttributes,\n type ButtonHTMLAttributes,\n type ReactElement,\n type ReactNode,\n} from \"react\";\n\nimport { type ComponentWithRippleProps } from \"../interaction/types.js\";\nimport { useElementInteraction } from \"../interaction/useElementInteraction.js\";\nimport { useHigherContrastChildren } from \"../interaction/useHigherContrastChildren.js\";\nimport { type CustomLinkComponent } from \"../link/Link.js\";\nimport { useKeyboardMovementContext } from \"../movement/useKeyboardMovementProvider.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type TabListProps } from \"./TabList.js\";\nimport { tab } from \"./tabStyles.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type useTabs } from \"./useTabs.js\";\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-tab-color\"?: string;\n \"--rmd-tab-active-color\"?: string;\n \"--rmd-tab-inactive-color\"?: string;\n \"--rmd-tab-disabled-color\"?: string;\n\n \"--rmd-tab-size\"?: string;\n \"--rmd-tab-offset\"?: string | number;\n \"--rmd-tab-min-width\"?: string;\n \"--rmd-tab-max-width\"?: string;\n \"--rmd-tab-min-height\"?: string;\n \"--rmd-tab-stacked-height\"?: string;\n \"--rmd-tab-stacked-width\"?: string;\n \"--rmd-tab-padding\"?: string | number;\n \"--rmd-tab-stacked-padding\"?: string | number;\n \"--rmd-tab-indicator-background\"?: string;\n }\n}\n\n/**\n * @since 6.0.0\n */\nexport interface BaseTabProps extends ComponentWithRippleProps {\n /**\n * Set this to `true` if the tab is currently active.\n *\n * This is normally provided by the {@link useTabs} hook.\n */\n active: boolean;\n\n /**\n * Set this to `true` if the {@link TabListProps.disableTransition} prop has\n * also been set to `true` to disable an active indicator below the tab when\n * {@link active} is `true`.\n *\n * @defaultValue `false`\n */\n activeIndicator?: boolean;\n\n /**\n * Set this to `true` when rendering the tabs vertically and\n * {@link activeIndicator} has been enabled.\n *\n * @defaultValue !false\n */\n verticalActiveIndicator?: boolean;\n\n /**\n * An optional icon to render with the with the {@link children}. The default\n * behavior will render this icon before the children.\n *\n * @see {@link iconAfter}\n * @see {@link stacked}\n */\n icon?: ReactNode;\n\n /**\n * Set this to `true` to render the {@link icon} after the {@link children}.\n *\n * @defaultValue `false`\n */\n iconAfter?: boolean;\n\n /**\n * Set this to `true` to render the {@link icon} and {@link children} stacked\n * instead of horizontally.\n *\n * @defaultValue `false`\n */\n stacked?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface TabButtonProps\n extends BaseTabProps,\n ButtonHTMLAttributes<HTMLButtonElement> {\n as?: \"button\";\n}\n\n/**\n * @since 6.0.0\n */\nexport interface TabLinkProps\n extends BaseTabProps,\n AnchorHTMLAttributes<HTMLAnchorElement> {\n as: CustomLinkComponent;\n}\n\n/**\n * @since 6.0.0\n */\nexport type TabProps = TabButtonProps | TabLinkProps;\n\n/**\n * **Client Component**\n *\n * This component should usually be used with the `TabsList` component and\n * `useTabs` hook.\n *\n * @see {@link https://react-md.dev/components/tabs | Tabs Demos}\n * @see {@link useTabs}\n * @since 6.0.0\n */\nexport function Tab(props: TabProps): ReactElement {\n const {\n id: propId,\n as: Component = \"button\",\n active,\n activeIndicator,\n verticalActiveIndicator,\n icon,\n iconAfter,\n stacked,\n className,\n children: propChildren,\n onBlur,\n onClick,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onMouseLeave,\n onDragStart,\n onTouchStart,\n onTouchEnd,\n onTouchMove,\n disableRipple,\n ...remaining\n } = props as TabButtonProps;\n const { disabled } = props as TabButtonProps;\n\n const id = useEnsuredId(propId, \"tab\");\n const { activeDescendantId } = useKeyboardMovementContext();\n const { ripples, handlers } = useElementInteraction({\n mode: disableRipple ? \"none\" : undefined,\n onBlur,\n onClick,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onMouseLeave,\n onDragStart,\n onTouchStart,\n onTouchEnd,\n onTouchMove,\n disabled,\n });\n\n const isLink = Component !== \"button\";\n const children = useHigherContrastChildren(propChildren);\n let buttonOnlyProps: Record<string, unknown> | undefined;\n if (!isLink) {\n buttonOnlyProps = { type: \"button\" };\n }\n\n return (\n <Component\n {...remaining}\n {...buttonOnlyProps}\n {...handlers}\n aria-selected={active}\n id={id}\n role=\"tab\"\n tabIndex={id === activeDescendantId ? 0 : -1}\n className={tab({\n className,\n active,\n isLink,\n stacked: !!icon && stacked,\n disabled,\n reversed: !!icon && iconAfter,\n activeIndicator,\n verticalActiveIndicator,\n })}\n >\n {icon}\n {children}\n {ripples}\n </Component>\n );\n}\n"],"names":["useElementInteraction","useHigherContrastChildren","useKeyboardMovementContext","useEnsuredId","tab","Tab","props","id","propId","as","Component","active","activeIndicator","verticalActiveIndicator","icon","iconAfter","stacked","className","children","propChildren","onBlur","onClick","onKeyDown","onKeyUp","onMouseDown","onMouseUp","onMouseLeave","onDragStart","onTouchStart","onTouchEnd","onTouchMove","disableRipple","remaining","disabled","activeDescendantId","ripples","handlers","mode","undefined","isLink","buttonOnlyProps","type","aria-selected","role","tabIndex","reversed"],"mappings":"AAAA;;AAUA,SAASA,qBAAqB,QAAQ,0CAA0C;AAChF,SAASC,yBAAyB,QAAQ,8CAA8C;AAExF,SAASC,0BAA0B,QAAQ,6CAA6C;AACxF,SAASC,YAAY,QAAQ,qBAAqB;AAGlD,SAASC,GAAG,QAAQ,iBAAiB;AAoGrC;;;;;;;;;CASC,GACD,OAAO,SAASC,IAAIC,KAAe;IACjC,MAAM,EACJC,IAAIC,MAAM,EACVC,IAAIC,YAAY,QAAQ,EACxBC,MAAM,EACNC,eAAe,EACfC,uBAAuB,EACvBC,IAAI,EACJC,SAAS,EACTC,OAAO,EACPC,SAAS,EACTC,UAAUC,YAAY,EACtBC,MAAM,EACNC,OAAO,EACPC,SAAS,EACTC,OAAO,EACPC,WAAW,EACXC,SAAS,EACTC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,UAAU,EACVC,WAAW,EACXC,aAAa,EACb,GAAGC,WACJ,GAAG1B;IACJ,MAAM,EAAE2B,QAAQ,EAAE,GAAG3B;IAErB,MAAMC,KAAKJ,aAAaK,QAAQ;IAChC,MAAM,EAAE0B,kBAAkB,EAAE,GAAGhC;IAC/B,MAAM,EAAEiC,OAAO,EAAEC,QAAQ,EAAE,GAAGpC,sBAAsB;QAClDqC,MAAMN,gBAAgB,SAASO;QAC/BlB;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAG;IACF;IAEA,MAAMM,SAAS7B,cAAc;IAC7B,MAAMQ,WAAWjB,0BAA0BkB;IAC3C,IAAIqB;IACJ,IAAI,CAACD,QAAQ;QACXC,kBAAkB;YAAEC,MAAM;QAAS;IACrC;IAEA,qBACE,MAAC/B;QACE,GAAGsB,SAAS;QACZ,GAAGQ,eAAe;QAClB,GAAGJ,QAAQ;QACZM,iBAAe/B;QACfJ,IAAIA;QACJoC,MAAK;QACLC,UAAUrC,OAAO2B,qBAAqB,IAAI,CAAC;QAC3CjB,WAAWb,IAAI;YACba;YACAN;YACA4B;YACAvB,SAAS,CAAC,CAACF,QAAQE;YACnBiB;YACAY,UAAU,CAAC,CAAC/B,QAAQC;YACpBH;YACAC;QACF;;YAECC;YACAI;YACAiB;;;AAGP"}
1
+ {"version":3,"sources":["../../src/tabs/Tab.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type AnchorHTMLAttributes,\n type ButtonHTMLAttributes,\n type ReactElement,\n type ReactNode,\n} from \"react\";\n\nimport { type ComponentWithRippleProps } from \"../interaction/types.js\";\nimport { useElementInteraction } from \"../interaction/useElementInteraction.js\";\nimport { useHigherContrastChildren } from \"../interaction/useHigherContrastChildren.js\";\nimport { type CustomLinkComponent } from \"../link/Link.js\";\nimport { useKeyboardMovementContext } from \"../movement/useKeyboardMovementProvider.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport { type BaseTabClassNameOptions, tab } from \"./tabStyles.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type useTabs } from \"./useTabs.js\";\n\n/**\n * @since 6.0.0\n */\nexport interface BaseTabProps\n extends ComponentWithRippleProps,\n BaseTabClassNameOptions {\n /**\n * Set this to `true` if the tab is currently active.\n *\n * This is normally provided by the {@link useTabs} hook.\n */\n active: boolean;\n\n /**\n * An optional icon to render with the with the {@link children}. The default\n * behavior will render this icon before the children.\n *\n * @see {@link iconAfter}\n * @see {@link stacked}\n */\n icon?: ReactNode;\n\n /**\n * Set this to `true` to render the {@link icon} after the {@link children}.\n *\n * @defaultValue `false`\n */\n iconAfter?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport interface TabButtonProps\n extends BaseTabProps,\n ButtonHTMLAttributes<HTMLButtonElement> {\n as?: \"button\";\n}\n\n/**\n * @since 6.0.0\n */\nexport interface TabLinkProps\n extends BaseTabProps,\n AnchorHTMLAttributes<HTMLAnchorElement> {\n as: CustomLinkComponent;\n}\n\n/**\n * @since 6.0.0\n */\nexport type TabProps = TabButtonProps | TabLinkProps;\n\n/**\n * **Client Component**\n *\n * This component should usually be used with the `TabsList` component and\n * `useTabs` hook.\n *\n * @see {@link https://react-md.dev/components/tabs | Tabs Demos}\n * @see {@link useTabs}\n * @since 6.0.0\n */\nexport function Tab(props: TabProps): ReactElement {\n const {\n id: propId,\n as: Component = \"button\",\n active,\n activeIndicator,\n verticalActiveIndicator,\n icon,\n iconAfter,\n stacked,\n className,\n children: propChildren,\n onBlur,\n onClick,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onMouseLeave,\n onDragStart,\n onTouchStart,\n onTouchEnd,\n onTouchMove,\n disableRipple,\n ...remaining\n } = props as TabButtonProps;\n const { disabled } = props as TabButtonProps;\n\n const id = useEnsuredId(propId, \"tab\");\n const { activeDescendantId } = useKeyboardMovementContext();\n const { ripples, handlers } = useElementInteraction({\n mode: disableRipple ? \"none\" : undefined,\n onBlur,\n onClick,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onMouseLeave,\n onDragStart,\n onTouchStart,\n onTouchEnd,\n onTouchMove,\n disabled,\n });\n\n const isLink = Component !== \"button\";\n const children = useHigherContrastChildren(propChildren);\n let buttonOnlyProps: Record<string, unknown> | undefined;\n if (!isLink) {\n buttonOnlyProps = { type: \"button\" };\n }\n\n return (\n <Component\n {...remaining}\n {...buttonOnlyProps}\n {...handlers}\n aria-selected={active}\n id={id}\n role=\"tab\"\n tabIndex={id === activeDescendantId ? 0 : -1}\n className={tab({\n className,\n active,\n isLink,\n stacked: !!icon && stacked,\n disabled,\n reversed: !!icon && iconAfter,\n activeIndicator,\n verticalActiveIndicator,\n })}\n >\n {icon}\n {children}\n {ripples}\n </Component>\n );\n}\n"],"names":["useElementInteraction","useHigherContrastChildren","useKeyboardMovementContext","useEnsuredId","tab","Tab","props","id","propId","as","Component","active","activeIndicator","verticalActiveIndicator","icon","iconAfter","stacked","className","children","propChildren","onBlur","onClick","onKeyDown","onKeyUp","onMouseDown","onMouseUp","onMouseLeave","onDragStart","onTouchStart","onTouchEnd","onTouchMove","disableRipple","remaining","disabled","activeDescendantId","ripples","handlers","mode","undefined","isLink","buttonOnlyProps","type","aria-selected","role","tabIndex","reversed"],"mappings":"AAAA;;AAUA,SAASA,qBAAqB,QAAQ,0CAA0C;AAChF,SAASC,yBAAyB,QAAQ,8CAA8C;AAExF,SAASC,0BAA0B,QAAQ,6CAA6C;AACxF,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAAuCC,GAAG,QAAQ,iBAAiB;AAyDnE;;;;;;;;;CASC,GACD,OAAO,SAASC,IAAIC,KAAe;IACjC,MAAM,EACJC,IAAIC,MAAM,EACVC,IAAIC,YAAY,QAAQ,EACxBC,MAAM,EACNC,eAAe,EACfC,uBAAuB,EACvBC,IAAI,EACJC,SAAS,EACTC,OAAO,EACPC,SAAS,EACTC,UAAUC,YAAY,EACtBC,MAAM,EACNC,OAAO,EACPC,SAAS,EACTC,OAAO,EACPC,WAAW,EACXC,SAAS,EACTC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,UAAU,EACVC,WAAW,EACXC,aAAa,EACb,GAAGC,WACJ,GAAG1B;IACJ,MAAM,EAAE2B,QAAQ,EAAE,GAAG3B;IAErB,MAAMC,KAAKJ,aAAaK,QAAQ;IAChC,MAAM,EAAE0B,kBAAkB,EAAE,GAAGhC;IAC/B,MAAM,EAAEiC,OAAO,EAAEC,QAAQ,EAAE,GAAGpC,sBAAsB;QAClDqC,MAAMN,gBAAgB,SAASO;QAC/BlB;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAG;IACF;IAEA,MAAMM,SAAS7B,cAAc;IAC7B,MAAMQ,WAAWjB,0BAA0BkB;IAC3C,IAAIqB;IACJ,IAAI,CAACD,QAAQ;QACXC,kBAAkB;YAAEC,MAAM;QAAS;IACrC;IAEA,qBACE,MAAC/B;QACE,GAAGsB,SAAS;QACZ,GAAGQ,eAAe;QAClB,GAAGJ,QAAQ;QACZM,iBAAe/B;QACfJ,IAAIA;QACJoC,MAAK;QACLC,UAAUrC,OAAO2B,qBAAqB,IAAI,CAAC;QAC3CjB,WAAWb,IAAI;YACba;YACAN;YACA4B;YACAvB,SAAS,CAAC,CAACF,QAAQE;YACnBiB;YACAY,UAAU,CAAC,CAAC/B,QAAQC;YACpBH;YACAC;QACF;;YAECC;YACAI;YACAiB;;;AAGP"}
@@ -1,13 +1,54 @@
1
+ declare module "react" {
2
+ interface CSSProperties {
3
+ "--rmd-tab-color"?: string;
4
+ "--rmd-tab-active-color"?: string;
5
+ "--rmd-tab-inactive-color"?: string;
6
+ "--rmd-tab-disabled-color"?: string;
7
+ "--rmd-tab-indicator-background"?: string;
8
+ "--rmd-tab-min-height"?: string;
9
+ "--rmd-tab-min-width"?: string;
10
+ "--rmd-tab-max-width"?: string;
11
+ "--rmd-tab-stacked-height"?: string;
12
+ "--rmd-tab-stacked-width"?: string;
13
+ "--rmd-tab-padding"?: string | number;
14
+ "--rmd-tab-stacked-padding"?: string | number;
15
+ }
16
+ }
1
17
  /**
2
- * @since 6.0.0
18
+ * @since 6.3.1
3
19
  */
4
- export interface TabClassNameOptions {
20
+ export interface BaseTabClassNameOptions {
5
21
  className?: string;
6
- active?: boolean;
7
- isLink?: boolean;
22
+ /**
23
+ * Set this to `true` if the {@link TabListProps.disableTransition} prop has
24
+ * also been set to `true` to disable an active indicator below the tab when
25
+ * {@link active} is `true`.
26
+ *
27
+ * @defaultValue `false`
28
+ */
8
29
  activeIndicator?: boolean;
30
+ /**
31
+ * Set this to `true` when rendering the tabs vertically and
32
+ * {@link activeIndicator} has been enabled.
33
+ *
34
+ * @defaultValue !false
35
+ */
9
36
  verticalActiveIndicator?: boolean;
37
+ /**
38
+ * Set this to `true` to render the {@link icon} and {@link children} stacked
39
+ * instead of horizontally.
40
+ *
41
+ * @defaultValue `false`
42
+ */
10
43
  stacked?: boolean;
44
+ }
45
+ /**
46
+ * @since 6.0.0
47
+ * @since 6.3.1 Extends BaseTabClassNameOptions
48
+ */
49
+ export interface TabClassNameOptions extends BaseTabClassNameOptions {
50
+ active?: boolean;
51
+ isLink?: boolean;
11
52
  reversed?: boolean;
12
53
  disabled?: boolean;
13
54
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/tabs/tabStyles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { cssUtils } from \"../cssUtils.js\";\nimport { bem } from \"../utils/bem.js\";\nimport { tabIndicator } from \"./tabIndicatorStyles.js\";\n\nconst styles = bem(\"rmd-tab\");\n\n/**\n * @since 6.0.0\n */\nexport interface TabClassNameOptions {\n className?: string;\n active?: boolean;\n isLink?: boolean;\n activeIndicator?: boolean;\n verticalActiveIndicator?: boolean;\n stacked?: boolean;\n reversed?: boolean;\n disabled?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function tab(options: TabClassNameOptions = {}): string {\n const {\n className,\n active,\n isLink,\n stacked,\n reversed,\n disabled,\n activeIndicator,\n verticalActiveIndicator,\n } = options;\n\n return cnb(\n styles({\n active,\n reversed: reversed && !stacked,\n stacked,\n \"stacked-reversed\": stacked && reversed,\n disabled,\n }),\n active &&\n activeIndicator &&\n tabIndicator({ vertical: verticalActiveIndicator }),\n cssUtils({ surface: true, textDecoration: isLink ? \"none\" : undefined }),\n className\n );\n}\n"],"names":["cnb","cssUtils","bem","tabIndicator","styles","tab","options","className","active","isLink","stacked","reversed","disabled","activeIndicator","verticalActiveIndicator","vertical","surface","textDecoration","undefined"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,SAASC,GAAG,QAAQ,kBAAkB;AACtC,SAASC,YAAY,QAAQ,0BAA0B;AAEvD,MAAMC,SAASF,IAAI;AAgBnB;;CAEC,GACD,OAAO,SAASG,IAAIC,UAA+B,CAAC,CAAC;IACnD,MAAM,EACJC,SAAS,EACTC,MAAM,EACNC,MAAM,EACNC,OAAO,EACPC,QAAQ,EACRC,QAAQ,EACRC,eAAe,EACfC,uBAAuB,EACxB,GAAGR;IAEJ,OAAON,IACLI,OAAO;QACLI;QACAG,UAAUA,YAAY,CAACD;QACvBA;QACA,oBAAoBA,WAAWC;QAC/BC;IACF,IACAJ,UACEK,mBACAV,aAAa;QAAEY,UAAUD;IAAwB,IACnDb,SAAS;QAAEe,SAAS;QAAMC,gBAAgBR,SAAS,SAASS;IAAU,IACtEX;AAEJ"}
1
+ {"version":3,"sources":["../../src/tabs/tabStyles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { cssUtils } from \"../cssUtils.js\";\nimport { bem } from \"../utils/bem.js\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type TabListProps } from \"./TabList.js\";\nimport { tabIndicator } from \"./tabIndicatorStyles.js\";\n\nconst styles = bem(\"rmd-tab\");\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-tab-color\"?: string;\n \"--rmd-tab-active-color\"?: string;\n \"--rmd-tab-inactive-color\"?: string;\n \"--rmd-tab-disabled-color\"?: string;\n \"--rmd-tab-indicator-background\"?: string;\n \"--rmd-tab-min-height\"?: string;\n \"--rmd-tab-min-width\"?: string;\n \"--rmd-tab-max-width\"?: string;\n \"--rmd-tab-stacked-height\"?: string;\n \"--rmd-tab-stacked-width\"?: string;\n \"--rmd-tab-padding\"?: string | number;\n \"--rmd-tab-stacked-padding\"?: string | number;\n }\n}\n\n/**\n * @since 6.3.1\n */\nexport interface BaseTabClassNameOptions {\n className?: string;\n\n /**\n * Set this to `true` if the {@link TabListProps.disableTransition} prop has\n * also been set to `true` to disable an active indicator below the tab when\n * {@link active} is `true`.\n *\n * @defaultValue `false`\n */\n activeIndicator?: boolean;\n\n /**\n * Set this to `true` when rendering the tabs vertically and\n * {@link activeIndicator} has been enabled.\n *\n * @defaultValue !false\n */\n verticalActiveIndicator?: boolean;\n\n /**\n * Set this to `true` to render the {@link icon} and {@link children} stacked\n * instead of horizontally.\n *\n * @defaultValue `false`\n */\n stacked?: boolean;\n}\n\n/**\n * @since 6.0.0\n * @since 6.3.1 Extends BaseTabClassNameOptions\n */\nexport interface TabClassNameOptions extends BaseTabClassNameOptions {\n active?: boolean;\n isLink?: boolean;\n reversed?: boolean;\n disabled?: boolean;\n}\n\n/**\n * @since 6.0.0\n */\nexport function tab(options: TabClassNameOptions = {}): string {\n const {\n className,\n active,\n isLink,\n stacked,\n reversed,\n disabled,\n activeIndicator,\n verticalActiveIndicator,\n } = options;\n\n return cnb(\n styles({\n active,\n reversed: reversed && !stacked,\n stacked,\n \"stacked-reversed\": stacked && reversed,\n disabled,\n }),\n active &&\n activeIndicator &&\n tabIndicator({ vertical: verticalActiveIndicator }),\n cssUtils({ surface: true, textDecoration: isLink ? \"none\" : undefined }),\n className\n );\n}\n"],"names":["cnb","cssUtils","bem","tabIndicator","styles","tab","options","className","active","isLink","stacked","reversed","disabled","activeIndicator","verticalActiveIndicator","vertical","surface","textDecoration","undefined"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,SAASC,GAAG,QAAQ,kBAAkB;AAGtC,SAASC,YAAY,QAAQ,0BAA0B;AAEvD,MAAMC,SAASF,IAAI;AA8DnB;;CAEC,GACD,OAAO,SAASG,IAAIC,UAA+B,CAAC,CAAC;IACnD,MAAM,EACJC,SAAS,EACTC,MAAM,EACNC,MAAM,EACNC,OAAO,EACPC,QAAQ,EACRC,QAAQ,EACRC,eAAe,EACfC,uBAAuB,EACxB,GAAGR;IAEJ,OAAON,IACLI,OAAO;QACLI;QACAG,UAAUA,YAAY,CAACD;QACvBA;QACA,oBAAoBA,WAAWC;QAC/BC;IACF,IACAJ,UACEK,mBACAV,aAAa;QAAEY,UAAUD;IAAwB,IACnDb,SAAS;QAAEe,SAAS;QAAMC,gBAAgBR,SAAS,SAASS;IAAU,IACtEX;AAEJ"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/test-utils/mocks/IntersectionObserver.ts"],"sourcesContent":["export class IntersectionObserverMock implements IntersectionObserver {\n root: Document | Element | null;\n rootMargin: string;\n thresholds: readonly number[];\n\n elements: Set<Element>;\n\n constructor(\n public callback: IntersectionObserverCallback,\n options: IntersectionObserverInit = {}\n ) {\n this.root = options.root || null;\n this.rootMargin = options.rootMargin || \"\";\n this.thresholds =\n typeof options.threshold === \"number\"\n ? [options.threshold]\n : (options.threshold ?? []);\n\n this.elements = new Set();\n }\n\n observe(target: Element): void {\n this.elements.add(target);\n\n this.callback(this.takeRecords(), this);\n }\n\n unobserve(target: Element): void {\n this.elements.delete(target);\n }\n\n takeRecords(): IntersectionObserverEntry[] {\n return [...this.elements].map<IntersectionObserverEntry>((target) => ({\n time: Date.now(),\n target,\n boundingClientRect: target.getBoundingClientRect(),\n intersectionRatio: 0,\n intersectionRect: target.getBoundingClientRect(),\n isIntersecting: false,\n rootBounds:\n this.root && \"getBoundingClientRect\" in this.root\n ? this.root.getBoundingClientRect()\n : null,\n }));\n }\n\n disconnect(): void {\n this.elements.clear();\n }\n}\n"],"names":["IntersectionObserverMock","observe","target","elements","add","callback","takeRecords","unobserve","delete","map","time","Date","now","boundingClientRect","getBoundingClientRect","intersectionRatio","intersectionRect","isIntersecting","rootBounds","root","disconnect","clear","constructor","options","rootMargin","thresholds","threshold","Set"],"mappings":";;;;;;;;;;;;;AAAA,OAAO,MAAMA;IAqBXC,QAAQC,MAAe,EAAQ;QAC7B,IAAI,CAACC,QAAQ,CAACC,GAAG,CAACF;QAElB,IAAI,CAACG,QAAQ,CAAC,IAAI,CAACC,WAAW,IAAI,IAAI;IACxC;IAEAC,UAAUL,MAAe,EAAQ;QAC/B,IAAI,CAACC,QAAQ,CAACK,MAAM,CAACN;IACvB;IAEAI,cAA2C;QACzC,OAAO;eAAI,IAAI,CAACH,QAAQ;SAAC,CAACM,GAAG,CAA4B,CAACP,SAAY,CAAA;gBACpEQ,MAAMC,KAAKC,GAAG;gBACdV;gBACAW,oBAAoBX,OAAOY,qBAAqB;gBAChDC,mBAAmB;gBACnBC,kBAAkBd,OAAOY,qBAAqB;gBAC9CG,gBAAgB;gBAChBC,YACE,IAAI,CAACC,IAAI,IAAI,2BAA2B,IAAI,CAACA,IAAI,GAC7C,IAAI,CAACA,IAAI,CAACL,qBAAqB,KAC/B;YACR,CAAA;IACF;IAEAM,aAAmB;QACjB,IAAI,CAACjB,QAAQ,CAACkB,KAAK;IACrB;IAzCAC,YACE,AAAOjB,QAAsC,EAC7CkB,UAAoC,CAAC,CAAC,CACtC;;QATFJ,uBAAAA,QAAAA,KAAAA;QACAK,uBAAAA,cAAAA,KAAAA;QACAC,uBAAAA,cAAAA,KAAAA;QAEAtB,uBAAAA,YAAAA,KAAAA;aAGSE,WAAAA;QAGP,IAAI,CAACc,IAAI,GAAGI,QAAQJ,IAAI,IAAI;QAC5B,IAAI,CAACK,UAAU,GAAGD,QAAQC,UAAU,IAAI;QACxC,IAAI,CAACC,UAAU,GACb,OAAOF,QAAQG,SAAS,KAAK,WACzB;YAACH,QAAQG,SAAS;SAAC,GAClBH,QAAQG,SAAS,IAAI,EAAE;QAE9B,IAAI,CAACvB,QAAQ,GAAG,IAAIwB;IACtB;AA8BF"}
1
+ {"version":3,"sources":["../../../src/test-utils/mocks/IntersectionObserver.ts"],"sourcesContent":["export class IntersectionObserverMock implements IntersectionObserver {\n root: Document | Element | null;\n rootMargin: string;\n thresholds: readonly number[];\n\n elements: Set<Element>;\n\n constructor(\n public callback: IntersectionObserverCallback,\n options: IntersectionObserverInit = {}\n ) {\n this.root = options.root || null;\n this.rootMargin = options.rootMargin || \"\";\n this.thresholds =\n typeof options.threshold === \"number\"\n ? [options.threshold]\n : (options.threshold ?? []);\n\n this.elements = new Set();\n }\n\n observe(target: Element): void {\n this.elements.add(target);\n\n this.callback(this.takeRecords(), this);\n }\n\n unobserve(target: Element): void {\n this.elements.delete(target);\n }\n\n takeRecords(): IntersectionObserverEntry[] {\n return [...this.elements].map<IntersectionObserverEntry>((target) => ({\n time: Date.now(),\n target,\n boundingClientRect: target.getBoundingClientRect(),\n intersectionRatio: 0,\n intersectionRect: target.getBoundingClientRect(),\n isIntersecting: false,\n rootBounds:\n this.root && \"getBoundingClientRect\" in this.root\n ? this.root.getBoundingClientRect()\n : null,\n }));\n }\n\n disconnect(): void {\n this.elements.clear();\n }\n}\n"],"names":["IntersectionObserverMock","observe","target","elements","add","callback","takeRecords","unobserve","delete","map","time","Date","now","boundingClientRect","getBoundingClientRect","intersectionRatio","intersectionRect","isIntersecting","rootBounds","root","disconnect","clear","options","rootMargin","thresholds","threshold","Set"],"mappings":";;;;;;;;;;;;;AAAA,OAAO,MAAMA;IAqBXC,QAAQC,MAAe,EAAQ;QAC7B,IAAI,CAACC,QAAQ,CAACC,GAAG,CAACF;QAElB,IAAI,CAACG,QAAQ,CAAC,IAAI,CAACC,WAAW,IAAI,IAAI;IACxC;IAEAC,UAAUL,MAAe,EAAQ;QAC/B,IAAI,CAACC,QAAQ,CAACK,MAAM,CAACN;IACvB;IAEAI,cAA2C;QACzC,OAAO;eAAI,IAAI,CAACH,QAAQ;SAAC,CAACM,GAAG,CAA4B,CAACP,SAAY,CAAA;gBACpEQ,MAAMC,KAAKC,GAAG;gBACdV;gBACAW,oBAAoBX,OAAOY,qBAAqB;gBAChDC,mBAAmB;gBACnBC,kBAAkBd,OAAOY,qBAAqB;gBAC9CG,gBAAgB;gBAChBC,YACE,IAAI,CAACC,IAAI,IAAI,2BAA2B,IAAI,CAACA,IAAI,GAC7C,IAAI,CAACA,IAAI,CAACL,qBAAqB,KAC/B;YACR,CAAA;IACF;IAEAM,aAAmB;QACjB,IAAI,CAACjB,QAAQ,CAACkB,KAAK;IACrB;IAzCA,YACE,AAAOhB,QAAsC,EAC7CiB,UAAoC,CAAC,CAAC,CACtC;;QATFH,uBAAAA,QAAAA,KAAAA;QACAI,uBAAAA,cAAAA,KAAAA;QACAC,uBAAAA,cAAAA,KAAAA;QAEArB,uBAAAA,YAAAA,KAAAA;aAGSE,WAAAA;QAGP,IAAI,CAACc,IAAI,GAAGG,QAAQH,IAAI,IAAI;QAC5B,IAAI,CAACI,UAAU,GAAGD,QAAQC,UAAU,IAAI;QACxC,IAAI,CAACC,UAAU,GACb,OAAOF,QAAQG,SAAS,KAAK,WACzB;YAACH,QAAQG,SAAS;SAAC,GAClBH,QAAQG,SAAS,IAAI,EAAE;QAE9B,IAAI,CAACtB,QAAQ,GAAG,IAAIuB;IACtB;AA8BF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/test-utils/mocks/ResizeObserver.ts"],"sourcesContent":["import {\n type ResizeObserverManager,\n resizeObserverManager,\n} from \"../../useResizeObserver.js\";\nimport {\n type GetResizeObserverEntryMock,\n type ResizeObserverEntrySize,\n createResizeObserverEntry,\n} from \"../utils/createResizeObserverEntry.js\";\n\n/**\n * This is the default ResizeObserver implementation if it does not already\n * exist in jsdom. You normally should not use this directly and instead use the\n * {@link setupResizeObserverMock} instead.\n *\n * @since 6.0.0\n */\nexport class ResizeObserverMock implements ResizeObserver {\n elements: Set<Element>;\n\n constructor(public callback: ResizeObserverCallback) {\n this.elements = new Set();\n }\n\n observe = (target: Element): void => {\n this.elements.add(target);\n this.resizeAllElements(createResizeObserverEntry);\n };\n\n unobserve = (target: Element): void => {\n this.elements.delete(target);\n };\n\n disconnect = (): void => {\n this.elements.clear();\n };\n\n /**\n * Triggers the resize event for a specific element. This must be wrapped in\n * `act`.\n *\n * @example Main Usage\n * ```tsx\n * import {\n * setupResizeObserverMock,\n * } from \"@react-md/core/test-utils\";\n * import { useResizeObserver } from \"@react-md/core/useResizeObserver\";\n * import { ExampleComponent } from \"../ExampleComponent.js\";\n *\n * // choose your test framework\n * import { afterEach, cleanupResizeObserverAfterEach, jest } from \"@jest/globals\";\n * cleanupResizeObserverAfterEach();\n *\n * import { afterEach, cleanupResizeObserverAfterEach, vitest } from \"vitest\";\n * cleanupResizeObserverAfterEach();\n *\n * describe(\"ExampleComponent\", () => {\n * it(\"should do stuff\", () => {\n * const observer = setupResizeObserverMock();\n * render(<ExampleComponent />)\n *\n * const resizeTarget = screen.getByTestId(\"resize-target\")\n *\n * // you can trigger with a custom change\n * act(() => {\n * observer.resizeElement(resizeTarget, { height: 100, width: 100 });\n * });\n * // expect resize changes\n * });\n * })\n * ```\n */\n resizeElement = (\n target: Element,\n changesOrGetEntry:\n | GetResizeObserverEntryMock\n | ResizeObserverEntrySize\n | ResizeObserverEntry = createResizeObserverEntry\n ): void => {\n if (!this.elements.has(target)) {\n throw new Error(\n \"The `ResizeObserverMock` is not watching the target element and cannot be resized\"\n );\n }\n\n let entry: ResizeObserverEntry;\n if (typeof changesOrGetEntry === \"function\") {\n entry = changesOrGetEntry(target);\n } else if (!(\"contentRect\" in changesOrGetEntry)) {\n entry = createResizeObserverEntry(target, changesOrGetEntry);\n } else {\n entry = changesOrGetEntry;\n }\n\n this.callback([entry], this);\n };\n\n /**\n * You'll normally want to use {@link resizeElement} instead, but this can be\n * used to resize all the watched elements at once.\n *\n * @example\n * ```tsx\n * import {\n * act,\n * createResizeObserverEntry,\n * render,\n * screen,\n * setupResizeObserverMock,\n * } from \"@react-md/core/test-utils\";\n *\n * const observer = setupResizeObserverMock();\n * const { container } = render(<Test />)\n * expect(container).toMatchSnapshot()\n *\n * const target1 = screen.getByTestId('target-1');\n * const target2 = screen.getByTestId('target-2');\n * const target3 = screen.getByTestId('target-3');\n *\n * act(() => {\n * observer.resizeAllElements((element) => {\n * let height: number | undefined;\n * let width: number | undefined;\n * switch (element) {\n * case target1:\n * height = 400;\n * width = 250;\n * break;\n * case target2:\n * height = 100;\n * width = 380;\n * break;\n * case target3:\n * height = 24;\n * width = 24;\n * break;\n * }\n *\n * return createResizeObserverEntry(element, { height, width });\n * });\n * });\n * expect(container).toMatchSnapshot()\n * ```\n */\n resizeAllElements = (getEntry = createResizeObserverEntry): void => {\n const entries = [...this.elements].map((element) => getEntry(element));\n this.callback(entries, this);\n };\n}\n\n/**\n * @since 6.0.0\n */\nexport interface SetupResizeObserverMockOptions {\n /**\n * Set this to `true` to mimic the real `ResizeObserver` behavior where the\n * updates occur after an animation frame instead of invoking immediately.\n *\n * Keeping this as `false` is recommended since this option was only added to\n * make testing this function itself easier.\n *\n * @defaultValue `false`\n */\n raf?: boolean;\n\n /**\n * Keeping this as the `resizeObserverManager` is recommended since this\n * option was only added to make testing this function easier itself.\n *\n * @defaultValue `resizeObserverManager`\n */\n manager?: ResizeObserverManager;\n}\n\n/**\n * Initializes the `ResizeObserverMock` to be used for tests.\n *\n * @example Main Usage\n * ```tsx\n * import {\n * cleanupResizeObserverAfterEach,\n * render,\n * screen,\n * setupResizeObserverMock,\n * } from \"@react-md/core/test-utils\";\n * import { useResizeObserver } from \"@react-md/core/useResizeObserver\";\n * import { useCallback, useState } from \"react\";\n *\n * // choose your test framework\n * import { afterEach, jest } from \"@jest/globals\";\n * cleanupResizeObserverAfterEach(afterEach, jest.restoreAllMocks);\n *\n * import { afterEach, vitest } from \"vitest\";\n * cleanupResizeObserverAfterEach(afterEach, vitest.restoreAllMocks);\n *\n * function ExampleComponent() {\n * const [size, setSize] = useState({ height: 0, width: 0 });\n * const ref = useResizeObserver({\n * onUpdate: useCallback((entry) => {\n * setSize({\n * height: entry.contentRect.height,\n * width: entry.contentRect.width,\n * });\n * }, []),\n * });\n *\n * return (\n * <>\n * <div data-testid=\"size\">{JSON.stringify(size)}</div>\n * <div data-testid=\"resize-target\" ref={ref} />\n * </>\n * );\n * }\n *\n * describe(\"ExampleComponent\", () => {\n * it(\"should do stuff\", () => {\n * const observer = setupResizeObserverMock();\n * render(<ExampleComponent />);\n *\n * const size = screen.getByTestId(\"size\");\n * const resizeTarget = screen.getByTestId(\"resize-target\");\n *\n * // jsdom sets all element sizes to 0 by default\n * expect(size).toHaveTextContent(JSON.stringify({ height: 0, width: 0 }));\n *\n * // you can trigger with a custom change\n * act(() => {\n * observer.resizeElement(resizeTarget, { height: 100, width: 100 });\n * });\n * expect(size).toHaveTextContent(JSON.stringify({ height: 100, width: 100 }));\n *\n * // or you can mock the `getBoundingClientRect` result\n * jest.spyOn(resizeTarget, \"getBoundingClientRect\").mockReturnValue({\n * ...document.body.getBoundingClientRect(),\n * height: 200,\n * width: 200,\n * });\n *\n * act(() => {\n * observer.resizeElement(resizeTarget);\n * });\n * expect(size).toHaveTextContent(JSON.stringify({ height: 200, width: 200 }));\n * });\n * });\n * ```\n *\n * @since 6.0.0\n */\nexport function setupResizeObserverMock(\n options: SetupResizeObserverMockOptions = {}\n): ResizeObserverMock {\n const { raf, manager = resizeObserverManager } = options;\n\n const resizeObserver = new ResizeObserverMock((entries) => {\n if (raf) {\n window.cancelAnimationFrame(manager.frame);\n manager.frame = window.requestAnimationFrame(() => {\n manager.handleResizeEntries(entries);\n });\n } else {\n manager.handleResizeEntries(entries);\n }\n });\n manager.sharedObserver = resizeObserver;\n return resizeObserver;\n}\n\n/**\n * @see {@link setupResizeObserverMock}\n * @since 6.0.0\n * @internal\n */\nexport function cleanupRO(\n afterEach: (callback: () => void) => void,\n restoreAllMocks: () => void = () => {}\n): void {\n afterEach(() => {\n resizeObserverManager.frame = 0;\n resizeObserverManager.subscriptions = new Map();\n resizeObserverManager.sharedObserver = undefined;\n restoreAllMocks();\n });\n}\n"],"names":["resizeObserverManager","createResizeObserverEntry","ResizeObserverMock","constructor","callback","elements","observe","unobserve","disconnect","resizeElement","resizeAllElements","target","add","delete","clear","changesOrGetEntry","has","Error","entry","getEntry","entries","map","element","Set","setupResizeObserverMock","options","raf","manager","resizeObserver","window","cancelAnimationFrame","frame","requestAnimationFrame","handleResizeEntries","sharedObserver","cleanupRO","afterEach","restoreAllMocks","subscriptions","Map","undefined"],"mappings":";;;;;;;;;;;;;AAAA,SAEEA,qBAAqB,QAChB,6BAA6B;AACpC,SAGEC,yBAAyB,QACpB,wCAAwC;AAE/C;;;;;;CAMC,GACD,OAAO,MAAMC;IAGXC,YAAY,AAAOC,QAAgC,CAAE;;QAFrDC,uBAAAA,YAAAA,KAAAA;QAMAC,uBAAAA,WAAAA,KAAAA;QAKAC,uBAAAA,aAAAA,KAAAA;QAIAC,uBAAAA,cAAAA,KAAAA;QAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCC,GACDC,uBAAAA,iBAAAA,KAAAA;QAyBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CC,GACDC,uBAAAA,qBAAAA,KAAAA;aA5HmBN,WAAAA;aAInBE,UAAU,CAACK;YACT,IAAI,CAACN,QAAQ,CAACO,GAAG,CAACD;YAClB,IAAI,CAACD,iBAAiB,CAACT;QACzB;aAEAM,YAAY,CAACI;YACX,IAAI,CAACN,QAAQ,CAACQ,MAAM,CAACF;QACvB;aAEAH,aAAa;YACX,IAAI,CAACH,QAAQ,CAACS,KAAK;QACrB;aAqCAL,gBAAgB,CACdE,QACAI,oBAG0Bd,yBAAyB;YAEnD,IAAI,CAAC,IAAI,CAACI,QAAQ,CAACW,GAAG,CAACL,SAAS;gBAC9B,MAAM,IAAIM,MACR;YAEJ;YAEA,IAAIC;YACJ,IAAI,OAAOH,sBAAsB,YAAY;gBAC3CG,QAAQH,kBAAkBJ;YAC5B,OAAO,IAAI,CAAE,CAAA,iBAAiBI,iBAAgB,GAAI;gBAChDG,QAAQjB,0BAA0BU,QAAQI;YAC5C,OAAO;gBACLG,QAAQH;YACV;YAEA,IAAI,CAACX,QAAQ,CAAC;gBAACc;aAAM,EAAE,IAAI;QAC7B;aAiDAR,oBAAoB,CAACS,WAAWlB,yBAAyB;YACvD,MAAMmB,UAAU;mBAAI,IAAI,CAACf,QAAQ;aAAC,CAACgB,GAAG,CAAC,CAACC,UAAYH,SAASG;YAC7D,IAAI,CAAClB,QAAQ,CAACgB,SAAS,IAAI;QAC7B;QA9HE,IAAI,CAACf,QAAQ,GAAG,IAAIkB;IACtB;AA8HF;AA0BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyEC,GACD,OAAO,SAASC,wBACdC,UAA0C,CAAC,CAAC;IAE5C,MAAM,EAAEC,GAAG,EAAEC,UAAU3B,qBAAqB,EAAE,GAAGyB;IAEjD,MAAMG,iBAAiB,IAAI1B,mBAAmB,CAACkB;QAC7C,IAAIM,KAAK;YACPG,OAAOC,oBAAoB,CAACH,QAAQI,KAAK;YACzCJ,QAAQI,KAAK,GAAGF,OAAOG,qBAAqB,CAAC;gBAC3CL,QAAQM,mBAAmB,CAACb;YAC9B;QACF,OAAO;YACLO,QAAQM,mBAAmB,CAACb;QAC9B;IACF;IACAO,QAAQO,cAAc,GAAGN;IACzB,OAAOA;AACT;AAEA;;;;CAIC,GACD,OAAO,SAASO,UACdC,SAAyC,EACzCC,kBAA8B,KAAO,CAAC;IAEtCD,UAAU;QACRpC,sBAAsB+B,KAAK,GAAG;QAC9B/B,sBAAsBsC,aAAa,GAAG,IAAIC;QAC1CvC,sBAAsBkC,cAAc,GAAGM;QACvCH;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/test-utils/mocks/ResizeObserver.ts"],"sourcesContent":["import {\n type ResizeObserverManager,\n resizeObserverManager,\n} from \"../../useResizeObserver.js\";\nimport {\n type GetResizeObserverEntryMock,\n type ResizeObserverEntrySize,\n createResizeObserverEntry,\n} from \"../utils/createResizeObserverEntry.js\";\n\n/**\n * This is the default ResizeObserver implementation if it does not already\n * exist in jsdom. You normally should not use this directly and instead use the\n * {@link setupResizeObserverMock} instead.\n *\n * @since 6.0.0\n */\nexport class ResizeObserverMock implements ResizeObserver {\n elements: Set<Element>;\n\n constructor(public callback: ResizeObserverCallback) {\n this.elements = new Set();\n }\n\n observe = (target: Element): void => {\n this.elements.add(target);\n this.resizeAllElements(createResizeObserverEntry);\n };\n\n unobserve = (target: Element): void => {\n this.elements.delete(target);\n };\n\n disconnect = (): void => {\n this.elements.clear();\n };\n\n /**\n * Triggers the resize event for a specific element. This must be wrapped in\n * `act`.\n *\n * @example Main Usage\n * ```tsx\n * import {\n * setupResizeObserverMock,\n * } from \"@react-md/core/test-utils\";\n * import { useResizeObserver } from \"@react-md/core/useResizeObserver\";\n * import { ExampleComponent } from \"../ExampleComponent.js\";\n *\n * // choose your test framework\n * import { afterEach, cleanupResizeObserverAfterEach, jest } from \"@jest/globals\";\n * cleanupResizeObserverAfterEach();\n *\n * import { afterEach, cleanupResizeObserverAfterEach, vitest } from \"vitest\";\n * cleanupResizeObserverAfterEach();\n *\n * describe(\"ExampleComponent\", () => {\n * it(\"should do stuff\", () => {\n * const observer = setupResizeObserverMock();\n * render(<ExampleComponent />)\n *\n * const resizeTarget = screen.getByTestId(\"resize-target\")\n *\n * // you can trigger with a custom change\n * act(() => {\n * observer.resizeElement(resizeTarget, { height: 100, width: 100 });\n * });\n * // expect resize changes\n * });\n * })\n * ```\n */\n resizeElement = (\n target: Element,\n changesOrGetEntry:\n | GetResizeObserverEntryMock\n | ResizeObserverEntrySize\n | ResizeObserverEntry = createResizeObserverEntry\n ): void => {\n if (!this.elements.has(target)) {\n throw new Error(\n \"The `ResizeObserverMock` is not watching the target element and cannot be resized\"\n );\n }\n\n let entry: ResizeObserverEntry;\n if (typeof changesOrGetEntry === \"function\") {\n entry = changesOrGetEntry(target);\n } else if (!(\"contentRect\" in changesOrGetEntry)) {\n entry = createResizeObserverEntry(target, changesOrGetEntry);\n } else {\n entry = changesOrGetEntry;\n }\n\n this.callback([entry], this);\n };\n\n /**\n * You'll normally want to use {@link resizeElement} instead, but this can be\n * used to resize all the watched elements at once.\n *\n * @example\n * ```tsx\n * import {\n * act,\n * createResizeObserverEntry,\n * render,\n * screen,\n * setupResizeObserverMock,\n * } from \"@react-md/core/test-utils\";\n *\n * const observer = setupResizeObserverMock();\n * const { container } = render(<Test />)\n * expect(container).toMatchSnapshot()\n *\n * const target1 = screen.getByTestId('target-1');\n * const target2 = screen.getByTestId('target-2');\n * const target3 = screen.getByTestId('target-3');\n *\n * act(() => {\n * observer.resizeAllElements((element) => {\n * let height: number | undefined;\n * let width: number | undefined;\n * switch (element) {\n * case target1:\n * height = 400;\n * width = 250;\n * break;\n * case target2:\n * height = 100;\n * width = 380;\n * break;\n * case target3:\n * height = 24;\n * width = 24;\n * break;\n * }\n *\n * return createResizeObserverEntry(element, { height, width });\n * });\n * });\n * expect(container).toMatchSnapshot()\n * ```\n */\n resizeAllElements = (getEntry = createResizeObserverEntry): void => {\n const entries = [...this.elements].map((element) => getEntry(element));\n this.callback(entries, this);\n };\n}\n\n/**\n * @since 6.0.0\n */\nexport interface SetupResizeObserverMockOptions {\n /**\n * Set this to `true` to mimic the real `ResizeObserver` behavior where the\n * updates occur after an animation frame instead of invoking immediately.\n *\n * Keeping this as `false` is recommended since this option was only added to\n * make testing this function itself easier.\n *\n * @defaultValue `false`\n */\n raf?: boolean;\n\n /**\n * Keeping this as the `resizeObserverManager` is recommended since this\n * option was only added to make testing this function easier itself.\n *\n * @defaultValue `resizeObserverManager`\n */\n manager?: ResizeObserverManager;\n}\n\n/**\n * Initializes the `ResizeObserverMock` to be used for tests.\n *\n * @example Main Usage\n * ```tsx\n * import {\n * cleanupResizeObserverAfterEach,\n * render,\n * screen,\n * setupResizeObserverMock,\n * } from \"@react-md/core/test-utils\";\n * import { useResizeObserver } from \"@react-md/core/useResizeObserver\";\n * import { useCallback, useState } from \"react\";\n *\n * // choose your test framework\n * import { afterEach, jest } from \"@jest/globals\";\n * cleanupResizeObserverAfterEach(afterEach, jest.restoreAllMocks);\n *\n * import { afterEach, vitest } from \"vitest\";\n * cleanupResizeObserverAfterEach(afterEach, vitest.restoreAllMocks);\n *\n * function ExampleComponent() {\n * const [size, setSize] = useState({ height: 0, width: 0 });\n * const ref = useResizeObserver({\n * onUpdate: useCallback((entry) => {\n * setSize({\n * height: entry.contentRect.height,\n * width: entry.contentRect.width,\n * });\n * }, []),\n * });\n *\n * return (\n * <>\n * <div data-testid=\"size\">{JSON.stringify(size)}</div>\n * <div data-testid=\"resize-target\" ref={ref} />\n * </>\n * );\n * }\n *\n * describe(\"ExampleComponent\", () => {\n * it(\"should do stuff\", () => {\n * const observer = setupResizeObserverMock();\n * render(<ExampleComponent />);\n *\n * const size = screen.getByTestId(\"size\");\n * const resizeTarget = screen.getByTestId(\"resize-target\");\n *\n * // jsdom sets all element sizes to 0 by default\n * expect(size).toHaveTextContent(JSON.stringify({ height: 0, width: 0 }));\n *\n * // you can trigger with a custom change\n * act(() => {\n * observer.resizeElement(resizeTarget, { height: 100, width: 100 });\n * });\n * expect(size).toHaveTextContent(JSON.stringify({ height: 100, width: 100 }));\n *\n * // or you can mock the `getBoundingClientRect` result\n * jest.spyOn(resizeTarget, \"getBoundingClientRect\").mockReturnValue({\n * ...document.body.getBoundingClientRect(),\n * height: 200,\n * width: 200,\n * });\n *\n * act(() => {\n * observer.resizeElement(resizeTarget);\n * });\n * expect(size).toHaveTextContent(JSON.stringify({ height: 200, width: 200 }));\n * });\n * });\n * ```\n *\n * @since 6.0.0\n */\nexport function setupResizeObserverMock(\n options: SetupResizeObserverMockOptions = {}\n): ResizeObserverMock {\n const { raf, manager = resizeObserverManager } = options;\n\n const resizeObserver = new ResizeObserverMock((entries) => {\n if (raf) {\n window.cancelAnimationFrame(manager.frame);\n manager.frame = window.requestAnimationFrame(() => {\n manager.handleResizeEntries(entries);\n });\n } else {\n manager.handleResizeEntries(entries);\n }\n });\n manager.sharedObserver = resizeObserver;\n return resizeObserver;\n}\n\n/**\n * @see {@link setupResizeObserverMock}\n * @since 6.0.0\n * @internal\n */\nexport function cleanupRO(\n afterEach: (callback: () => void) => void,\n restoreAllMocks: () => void = () => {}\n): void {\n afterEach(() => {\n resizeObserverManager.frame = 0;\n resizeObserverManager.subscriptions = new Map();\n resizeObserverManager.sharedObserver = undefined;\n restoreAllMocks();\n });\n}\n"],"names":["resizeObserverManager","createResizeObserverEntry","ResizeObserverMock","callback","elements","observe","unobserve","disconnect","resizeElement","resizeAllElements","target","add","delete","clear","changesOrGetEntry","has","Error","entry","getEntry","entries","map","element","Set","setupResizeObserverMock","options","raf","manager","resizeObserver","window","cancelAnimationFrame","frame","requestAnimationFrame","handleResizeEntries","sharedObserver","cleanupRO","afterEach","restoreAllMocks","subscriptions","Map","undefined"],"mappings":";;;;;;;;;;;;;AAAA,SAEEA,qBAAqB,QAChB,6BAA6B;AACpC,SAGEC,yBAAyB,QACpB,wCAAwC;AAE/C;;;;;;CAMC,GACD,OAAO,MAAMC;IAGX,YAAY,AAAOC,QAAgC,CAAE;;QAFrDC,uBAAAA,YAAAA,KAAAA;QAMAC,uBAAAA,WAAAA,KAAAA;QAKAC,uBAAAA,aAAAA,KAAAA;QAIAC,uBAAAA,cAAAA,KAAAA;QAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCC,GACDC,uBAAAA,iBAAAA,KAAAA;QAyBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CC,GACDC,uBAAAA,qBAAAA,KAAAA;aA5HmBN,WAAAA;aAInBE,UAAU,CAACK;YACT,IAAI,CAACN,QAAQ,CAACO,GAAG,CAACD;YAClB,IAAI,CAACD,iBAAiB,CAACR;QACzB;aAEAK,YAAY,CAACI;YACX,IAAI,CAACN,QAAQ,CAACQ,MAAM,CAACF;QACvB;aAEAH,aAAa;YACX,IAAI,CAACH,QAAQ,CAACS,KAAK;QACrB;aAqCAL,gBAAgB,CACdE,QACAI,oBAG0Bb,yBAAyB;YAEnD,IAAI,CAAC,IAAI,CAACG,QAAQ,CAACW,GAAG,CAACL,SAAS;gBAC9B,MAAM,IAAIM,MACR;YAEJ;YAEA,IAAIC;YACJ,IAAI,OAAOH,sBAAsB,YAAY;gBAC3CG,QAAQH,kBAAkBJ;YAC5B,OAAO,IAAI,CAAE,CAAA,iBAAiBI,iBAAgB,GAAI;gBAChDG,QAAQhB,0BAA0BS,QAAQI;YAC5C,OAAO;gBACLG,QAAQH;YACV;YAEA,IAAI,CAACX,QAAQ,CAAC;gBAACc;aAAM,EAAE,IAAI;QAC7B;aAiDAR,oBAAoB,CAACS,WAAWjB,yBAAyB;YACvD,MAAMkB,UAAU;mBAAI,IAAI,CAACf,QAAQ;aAAC,CAACgB,GAAG,CAAC,CAACC,UAAYH,SAASG;YAC7D,IAAI,CAAClB,QAAQ,CAACgB,SAAS,IAAI;QAC7B;QA9HE,IAAI,CAACf,QAAQ,GAAG,IAAIkB;IACtB;AA8HF;AA0BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyEC,GACD,OAAO,SAASC,wBACdC,UAA0C,CAAC,CAAC;IAE5C,MAAM,EAAEC,GAAG,EAAEC,UAAU1B,qBAAqB,EAAE,GAAGwB;IAEjD,MAAMG,iBAAiB,IAAIzB,mBAAmB,CAACiB;QAC7C,IAAIM,KAAK;YACPG,OAAOC,oBAAoB,CAACH,QAAQI,KAAK;YACzCJ,QAAQI,KAAK,GAAGF,OAAOG,qBAAqB,CAAC;gBAC3CL,QAAQM,mBAAmB,CAACb;YAC9B;QACF,OAAO;YACLO,QAAQM,mBAAmB,CAACb;QAC9B;IACF;IACAO,QAAQO,cAAc,GAAGN;IACzB,OAAOA;AACT;AAEA;;;;CAIC,GACD,OAAO,SAASO,UACdC,SAAyC,EACzCC,kBAA8B,KAAO,CAAC;IAEtCD,UAAU;QACRnC,sBAAsB8B,KAAK,GAAG;QAC9B9B,sBAAsBqC,aAAa,GAAG,IAAIC;QAC1CtC,sBAAsBiC,cAAc,GAAGM;QACvCH;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/test-utils/utils/createFileList.ts"],"sourcesContent":["/**\n * @see https://github.com/testing-library/user-event/blob/d42954be66484bcf78486a298cc37f8a7c9e4bea/src/utils/dataTransfer/FileList.ts\n */\nexport function createFileList(\n window: Window & typeof globalThis,\n fileOrFiles: File | readonly File[]\n): FileList & Iterable<File> {\n const files = Array.isArray(fileOrFiles) ? fileOrFiles : [fileOrFiles];\n const fileList: FileList & Iterable<File> = {\n ...files,\n length: files.length,\n item: (index) => fileList[index],\n // needs to be `any` to match the FileList definition\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [Symbol.iterator]: function* nextFile(): Generator<File, any, any> {\n for (let i = 0; i < fileList.length; i++) {\n yield fileList[i];\n }\n },\n };\n fileList.constructor = window.FileList;\n if (window.FileList) {\n Object.setPrototypeOf(fileList, window.FileList.prototype);\n }\n Object.freeze(fileList);\n return fileList;\n}\n"],"names":["createFileList","window","fileOrFiles","files","Array","isArray","fileList","length","item","index","Symbol","iterator","nextFile","i","constructor","FileList","Object","setPrototypeOf","prototype","freeze"],"mappings":"AAAA;;CAEC,GACD,OAAO,SAASA,eACdC,MAAkC,EAClCC,WAAmC;IAEnC,MAAMC,QAAQC,MAAMC,OAAO,CAACH,eAAeA,cAAc;QAACA;KAAY;IACtE,MAAMI,WAAsC;QAC1C,GAAGH,KAAK;QACRI,QAAQJ,MAAMI,MAAM;QACpBC,MAAM,CAACC,QAAUH,QAAQ,CAACG,MAAM;QAChC,qDAAqD;QACrD,8DAA8D;QAC9D,CAACC,OAAOC,QAAQ,CAAC,EAAE,UAAUC;YAC3B,IAAK,IAAIC,IAAI,GAAGA,IAAIP,SAASC,MAAM,EAAEM,IAAK;gBACxC,MAAMP,QAAQ,CAACO,EAAE;YACnB;QACF;IACF;IACAP,SAASQ,WAAW,GAAGb,OAAOc,QAAQ;IACtC,IAAId,OAAOc,QAAQ,EAAE;QACnBC,OAAOC,cAAc,CAACX,UAAUL,OAAOc,QAAQ,CAACG,SAAS;IAC3D;IACAF,OAAOG,MAAM,CAACb;IACd,OAAOA;AACT"}
1
+ {"version":3,"sources":["../../../src/test-utils/utils/createFileList.ts"],"sourcesContent":["/**\n * @see https://github.com/testing-library/user-event/blob/d42954be66484bcf78486a298cc37f8a7c9e4bea/src/utils/dataTransfer/FileList.ts\n */\nexport function createFileList(\n window: Window & typeof globalThis,\n fileOrFiles: File | readonly File[]\n): FileList & Iterable<File> {\n const files = Array.isArray(fileOrFiles) ? fileOrFiles : [fileOrFiles];\n const fileList: FileList & Iterable<File> = {\n ...files,\n length: files.length,\n item: (index) => fileList[index],\n // needs to be `any` to match the FileList definition\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [Symbol.iterator]: function* nextFile(): Generator<File, any, any> {\n for (let i = 0; i < fileList.length; i++) {\n yield fileList[i];\n }\n },\n };\n fileList.constructor = window.FileList;\n if (window.FileList) {\n Object.setPrototypeOf(fileList, window.FileList.prototype);\n }\n Object.freeze(fileList);\n return fileList;\n}\n"],"names":["createFileList","window","fileOrFiles","files","Array","isArray","fileList","length","item","index","Symbol","iterator","nextFile","i","FileList","Object","setPrototypeOf","prototype","freeze"],"mappings":"AAAA;;CAEC,GACD,OAAO,SAASA,eACdC,MAAkC,EAClCC,WAAmC;IAEnC,MAAMC,QAAQC,MAAMC,OAAO,CAACH,eAAeA,cAAc;QAACA;KAAY;IACtE,MAAMI,WAAsC;QAC1C,GAAGH,KAAK;QACRI,QAAQJ,MAAMI,MAAM;QACpBC,MAAM,CAACC,QAAUH,QAAQ,CAACG,MAAM;QAChC,qDAAqD;QACrD,8DAA8D;QAC9D,CAACC,OAAOC,QAAQ,CAAC,EAAE,UAAUC;YAC3B,IAAK,IAAIC,IAAI,GAAGA,IAAIP,SAASC,MAAM,EAAEM,IAAK;gBACxC,MAAMP,QAAQ,CAACO,EAAE;YACnB;QACF;IACF;IACAP,SAAS,WAAW,GAAGL,OAAOa,QAAQ;IACtC,IAAIb,OAAOa,QAAQ,EAAE;QACnBC,OAAOC,cAAc,CAACV,UAAUL,OAAOa,QAAQ,CAACG,SAAS;IAC3D;IACAF,OAAOG,MAAM,CAACZ;IACd,OAAOA;AACT"}
@@ -396,7 +396,6 @@ $_validated_color_scheme: utils.validate(
396
396
  /// `get-var`, `set-var`, and `use-var` utils.
397
397
  /// @type List
398
398
  $theme-variables: (
399
- inverse-color,
400
399
  background-color,
401
400
  on-background-color,
402
401
  surface-color,
@@ -1,27 +1,3 @@
1
1
  import { type ConfigurableThemeColors } from "./types.js";
2
- declare module "react" {
3
- interface CSSProperties {
4
- "--rmd-background-color"?: string;
5
- "--rmd-on-background-color"?: string;
6
- "--rmd-surface-color"?: string;
7
- "--rmd-primary-color"?: string;
8
- "--rmd-on-primary-color"?: string;
9
- "--rmd-secondary-color"?: string;
10
- "--rmd-on-secondary-color"?: string;
11
- "--rmd-warning-color"?: string;
12
- "--rmd-on-warning-color"?: string;
13
- "--rmd-error-color"?: string;
14
- "--rmd-on-error-color"?: string;
15
- "--rmd-success-color"?: string;
16
- "--rmd-on-success-color"?: string;
17
- "--rmd-text-primary-color"?: string;
18
- "--rmd-text-secondary-color"?: string;
19
- "--rmd-text-hint-color"?: string;
20
- "--rmd-text-disabled-color"?: string;
21
- "--rmd-outline-width"?: string | number;
22
- "--rmd-outline-color"?: string;
23
- "--rmd-outline-grey-color"?: string;
24
- }
25
- }
26
2
  /** @since 6.0.0 */
27
3
  export declare const getDerivedTheme: (container?: Element) => Readonly<ConfigurableThemeColors>;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/theme/getDerivedTheme.ts"],"sourcesContent":["import {\n backgroundColorVar,\n errorColorVar,\n onErrorColorVar,\n onPrimaryColorVar,\n onSecondaryColorVar,\n onSuccessColorVar,\n onWarningColorVar,\n primaryColorVar,\n secondaryColorVar,\n successColorVar,\n textDisabledColorVar,\n textHintColorVar,\n textPrimaryColorVar,\n textSecondaryColorVar,\n warningColorVar,\n} from \"./cssVars.js\";\nimport { type ConfigurableThemeColors } from \"./types.js\";\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-background-color\"?: string;\n \"--rmd-on-background-color\"?: string;\n \"--rmd-surface-color\"?: string;\n \"--rmd-primary-color\"?: string;\n \"--rmd-on-primary-color\"?: string;\n \"--rmd-secondary-color\"?: string;\n \"--rmd-on-secondary-color\"?: string;\n \"--rmd-warning-color\"?: string;\n \"--rmd-on-warning-color\"?: string;\n \"--rmd-error-color\"?: string;\n \"--rmd-on-error-color\"?: string;\n \"--rmd-success-color\"?: string;\n \"--rmd-on-success-color\"?: string;\n \"--rmd-text-primary-color\"?: string;\n \"--rmd-text-secondary-color\"?: string;\n \"--rmd-text-hint-color\"?: string;\n \"--rmd-text-disabled-color\"?: string;\n\n \"--rmd-outline-width\"?: string | number;\n \"--rmd-outline-color\"?: string;\n \"--rmd-outline-grey-color\"?: string;\n }\n}\n\n/** @since 6.0.0 */\nexport const getDerivedTheme = (\n container: Element = document.documentElement\n): Readonly<ConfigurableThemeColors> => {\n const rootStyles = window.getComputedStyle(container);\n const backgroundColor = rootStyles.getPropertyValue(backgroundColorVar);\n const primaryColor = rootStyles.getPropertyValue(primaryColorVar);\n const onPrimaryColor = rootStyles.getPropertyValue(onPrimaryColorVar);\n const secondaryColor = rootStyles.getPropertyValue(secondaryColorVar);\n const onSecondaryColor = rootStyles.getPropertyValue(onSecondaryColorVar);\n const warningColor = rootStyles.getPropertyValue(warningColorVar);\n const onWarningColor = rootStyles.getPropertyValue(onWarningColorVar);\n const errorColor = rootStyles.getPropertyValue(errorColorVar);\n const onErrorColor = rootStyles.getPropertyValue(onErrorColorVar);\n const successColor = rootStyles.getPropertyValue(successColorVar);\n const onSuccessColor = rootStyles.getPropertyValue(onSuccessColorVar);\n const textPrimaryColor = rootStyles.getPropertyValue(textPrimaryColorVar);\n const textSecondaryColor = rootStyles.getPropertyValue(textSecondaryColorVar);\n const textHintColor = rootStyles.getPropertyValue(textHintColorVar);\n const textDisabledColor = rootStyles.getPropertyValue(textDisabledColorVar);\n\n return {\n backgroundColor,\n primaryColor,\n onPrimaryColor,\n secondaryColor,\n onSecondaryColor,\n warningColor,\n onWarningColor,\n errorColor,\n onErrorColor,\n successColor,\n onSuccessColor,\n textPrimaryColor,\n textSecondaryColor,\n textHintColor,\n textDisabledColor,\n };\n};\n"],"names":["backgroundColorVar","errorColorVar","onErrorColorVar","onPrimaryColorVar","onSecondaryColorVar","onSuccessColorVar","onWarningColorVar","primaryColorVar","secondaryColorVar","successColorVar","textDisabledColorVar","textHintColorVar","textPrimaryColorVar","textSecondaryColorVar","warningColorVar","getDerivedTheme","container","document","documentElement","rootStyles","window","getComputedStyle","backgroundColor","getPropertyValue","primaryColor","onPrimaryColor","secondaryColor","onSecondaryColor","warningColor","onWarningColor","errorColor","onErrorColor","successColor","onSuccessColor","textPrimaryColor","textSecondaryColor","textHintColor","textDisabledColor"],"mappings":"AAAA,SACEA,kBAAkB,EAClBC,aAAa,EACbC,eAAe,EACfC,iBAAiB,EACjBC,mBAAmB,EACnBC,iBAAiB,EACjBC,iBAAiB,EACjBC,eAAe,EACfC,iBAAiB,EACjBC,eAAe,EACfC,oBAAoB,EACpBC,gBAAgB,EAChBC,mBAAmB,EACnBC,qBAAqB,EACrBC,eAAe,QACV,eAAe;AA6BtB,iBAAiB,GACjB,OAAO,MAAMC,kBAAkB,CAC7BC,YAAqBC,SAASC,eAAe;IAE7C,MAAMC,aAAaC,OAAOC,gBAAgB,CAACL;IAC3C,MAAMM,kBAAkBH,WAAWI,gBAAgB,CAACvB;IACpD,MAAMwB,eAAeL,WAAWI,gBAAgB,CAAChB;IACjD,MAAMkB,iBAAiBN,WAAWI,gBAAgB,CAACpB;IACnD,MAAMuB,iBAAiBP,WAAWI,gBAAgB,CAACf;IACnD,MAAMmB,mBAAmBR,WAAWI,gBAAgB,CAACnB;IACrD,MAAMwB,eAAeT,WAAWI,gBAAgB,CAACT;IACjD,MAAMe,iBAAiBV,WAAWI,gBAAgB,CAACjB;IACnD,MAAMwB,aAAaX,WAAWI,gBAAgB,CAACtB;IAC/C,MAAM8B,eAAeZ,WAAWI,gBAAgB,CAACrB;IACjD,MAAM8B,eAAeb,WAAWI,gBAAgB,CAACd;IACjD,MAAMwB,iBAAiBd,WAAWI,gBAAgB,CAAClB;IACnD,MAAM6B,mBAAmBf,WAAWI,gBAAgB,CAACX;IACrD,MAAMuB,qBAAqBhB,WAAWI,gBAAgB,CAACV;IACvD,MAAMuB,gBAAgBjB,WAAWI,gBAAgB,CAACZ;IAClD,MAAM0B,oBAAoBlB,WAAWI,gBAAgB,CAACb;IAEtD,OAAO;QACLY;QACAE;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;IACF;AACF,EAAE"}
1
+ {"version":3,"sources":["../../src/theme/getDerivedTheme.ts"],"sourcesContent":["import {\n backgroundColorVar,\n errorColorVar,\n onErrorColorVar,\n onPrimaryColorVar,\n onSecondaryColorVar,\n onSuccessColorVar,\n onWarningColorVar,\n primaryColorVar,\n secondaryColorVar,\n successColorVar,\n textDisabledColorVar,\n textHintColorVar,\n textPrimaryColorVar,\n textSecondaryColorVar,\n warningColorVar,\n} from \"./cssVars.js\";\nimport { type ConfigurableThemeColors } from \"./types.js\";\n\n/** @since 6.0.0 */\nexport const getDerivedTheme = (\n container: Element = document.documentElement\n): Readonly<ConfigurableThemeColors> => {\n const rootStyles = window.getComputedStyle(container);\n const backgroundColor = rootStyles.getPropertyValue(backgroundColorVar);\n const primaryColor = rootStyles.getPropertyValue(primaryColorVar);\n const onPrimaryColor = rootStyles.getPropertyValue(onPrimaryColorVar);\n const secondaryColor = rootStyles.getPropertyValue(secondaryColorVar);\n const onSecondaryColor = rootStyles.getPropertyValue(onSecondaryColorVar);\n const warningColor = rootStyles.getPropertyValue(warningColorVar);\n const onWarningColor = rootStyles.getPropertyValue(onWarningColorVar);\n const errorColor = rootStyles.getPropertyValue(errorColorVar);\n const onErrorColor = rootStyles.getPropertyValue(onErrorColorVar);\n const successColor = rootStyles.getPropertyValue(successColorVar);\n const onSuccessColor = rootStyles.getPropertyValue(onSuccessColorVar);\n const textPrimaryColor = rootStyles.getPropertyValue(textPrimaryColorVar);\n const textSecondaryColor = rootStyles.getPropertyValue(textSecondaryColorVar);\n const textHintColor = rootStyles.getPropertyValue(textHintColorVar);\n const textDisabledColor = rootStyles.getPropertyValue(textDisabledColorVar);\n\n return {\n backgroundColor,\n primaryColor,\n onPrimaryColor,\n secondaryColor,\n onSecondaryColor,\n warningColor,\n onWarningColor,\n errorColor,\n onErrorColor,\n successColor,\n onSuccessColor,\n textPrimaryColor,\n textSecondaryColor,\n textHintColor,\n textDisabledColor,\n };\n};\n"],"names":["backgroundColorVar","errorColorVar","onErrorColorVar","onPrimaryColorVar","onSecondaryColorVar","onSuccessColorVar","onWarningColorVar","primaryColorVar","secondaryColorVar","successColorVar","textDisabledColorVar","textHintColorVar","textPrimaryColorVar","textSecondaryColorVar","warningColorVar","getDerivedTheme","container","document","documentElement","rootStyles","window","getComputedStyle","backgroundColor","getPropertyValue","primaryColor","onPrimaryColor","secondaryColor","onSecondaryColor","warningColor","onWarningColor","errorColor","onErrorColor","successColor","onSuccessColor","textPrimaryColor","textSecondaryColor","textHintColor","textDisabledColor"],"mappings":"AAAA,SACEA,kBAAkB,EAClBC,aAAa,EACbC,eAAe,EACfC,iBAAiB,EACjBC,mBAAmB,EACnBC,iBAAiB,EACjBC,iBAAiB,EACjBC,eAAe,EACfC,iBAAiB,EACjBC,eAAe,EACfC,oBAAoB,EACpBC,gBAAgB,EAChBC,mBAAmB,EACnBC,qBAAqB,EACrBC,eAAe,QACV,eAAe;AAGtB,iBAAiB,GACjB,OAAO,MAAMC,kBAAkB,CAC7BC,YAAqBC,SAASC,eAAe;IAE7C,MAAMC,aAAaC,OAAOC,gBAAgB,CAACL;IAC3C,MAAMM,kBAAkBH,WAAWI,gBAAgB,CAACvB;IACpD,MAAMwB,eAAeL,WAAWI,gBAAgB,CAAChB;IACjD,MAAMkB,iBAAiBN,WAAWI,gBAAgB,CAACpB;IACnD,MAAMuB,iBAAiBP,WAAWI,gBAAgB,CAACf;IACnD,MAAMmB,mBAAmBR,WAAWI,gBAAgB,CAACnB;IACrD,MAAMwB,eAAeT,WAAWI,gBAAgB,CAACT;IACjD,MAAMe,iBAAiBV,WAAWI,gBAAgB,CAACjB;IACnD,MAAMwB,aAAaX,WAAWI,gBAAgB,CAACtB;IAC/C,MAAM8B,eAAeZ,WAAWI,gBAAgB,CAACrB;IACjD,MAAM8B,eAAeb,WAAWI,gBAAgB,CAACd;IACjD,MAAMwB,iBAAiBd,WAAWI,gBAAgB,CAAClB;IACnD,MAAM6B,mBAAmBf,WAAWI,gBAAgB,CAACX;IACrD,MAAMuB,qBAAqBhB,WAAWI,gBAAgB,CAACV;IACvD,MAAMuB,gBAAgBjB,WAAWI,gBAAgB,CAACZ;IAClD,MAAM0B,oBAAoBlB,WAAWI,gBAAgB,CAACb;IAEtD,OAAO;QACLY;QACAE;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;IACF;AACF,EAAE"}
@@ -1,5 +1,30 @@
1
1
  import { type CSSProperties } from "react";
2
2
  import { type UseStateSetter } from "../types.js";
3
+ declare module "react" {
4
+ interface CSSProperties {
5
+ "--rmd-background-color"?: string;
6
+ "--rmd-on-background-color"?: string;
7
+ "--rmd-surface-color"?: string;
8
+ "--rmd-primary-color"?: string;
9
+ "--rmd-on-primary-color"?: string;
10
+ "--rmd-secondary-color"?: string;
11
+ "--rmd-on-secondary-color"?: string;
12
+ "--rmd-success-color"?: string;
13
+ "--rmd-on-success-color"?: string;
14
+ "--rmd-warning-color"?: string;
15
+ "--rmd-on-warning-color"?: string;
16
+ "--rmd-error-color"?: string;
17
+ "--rmd-on-error-color"?: string;
18
+ "--rmd-text-primary-color"?: string;
19
+ "--rmd-text-secondary-color"?: string;
20
+ "--rmd-text-hint-color"?: string;
21
+ "--rmd-text-disabled-color"?: string;
22
+ "--rmd-outline-width"?: string | number;
23
+ "--rmd-outline-color"?: string;
24
+ "--rmd-outline-grey-color"?: string;
25
+ "--rmd-inverse-color"?: string;
26
+ }
27
+ }
3
28
  /**
4
29
  * @since 6.0.0
5
30
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/theme/types.ts"],"sourcesContent":["import { type CSSProperties } from \"react\";\n\nimport { type UseStateSetter } from \"../types.js\";\n\n/**\n * @since 6.0.0\n */\nexport type CSSVariableName = `--${string}`;\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport type DefinedCustomProperty<Property = keyof CSSProperties> =\n Property extends CSSVariableName ? Property : never;\n\n/**\n * This is a utility type that can be used to auto-complete and type-check css\n * variables that are defined through module augmentation.\n *\n * ```ts\n * declare module \"react\" {\n * interface CSSProperties {\n * \"--custom-property\"?: number | string;\n * }\n * }\n *\n * // will no longer throw a type error. also the `--custom-property` will\n * // appear as an auto-complete item\n * const style: CSSProperties = {\n * \"--custom-property\": \"red\",\n * };\n *\n * // `DefinedCSSVariableName` will also include `--custom-property` with all\n * // defined react-md custom properties\n * ```\n *\n * @since 6.0.0\n */\nexport type DefinedCSSVariableName = DefinedCustomProperty;\n\n/**\n * @since 6.0.0\n */\nexport interface CSSVariable<\n Name extends CSSVariableName = DefinedCSSVariableName,\n> {\n name: Name;\n value: string | number;\n}\n\n/**\n * @since 6.0.0\n */\nexport type CSSVariablesProperties<\n Name extends CSSVariableName = DefinedCSSVariableName,\n> = {\n [key in Name]?: string | number;\n};\n\n/**\n * @since 6.0.0\n */\nexport type ReadonlyCSSVariableList<\n Name extends CSSVariableName = DefinedCSSVariableName,\n> = readonly Readonly<CSSVariable<Name>>[];\n\n/** @since 6.0.0 */\nexport type LightDarkColorScheme = \"light\" | \"dark\";\n\n/** @since 6.0.0 */\nexport type ColorScheme = LightDarkColorScheme | \"system\";\n\n/**\n * @since 6.0.0\n */\nexport interface ColorSchemeState {\n /**\n * The defined color scheme for the app that should match the `$color-scheme`\n * SCSS variable.\n */\n colorScheme: ColorScheme;\n setColorScheme: UseStateSetter<ColorScheme>;\n}\n\n/** @since 6.0.0 */\nexport interface ColorSchemeContext extends ColorSchemeState {\n /**\n * When the {@link colorScheme} is set to `\"system\"`, this can be used to\n * determine if the user prefers the `\"light\"` or `\"dark\"` color scheme so\n * that custom styles can be set for that preference.\n */\n currentColor: LightDarkColorScheme;\n}\n\n/** @since 6.0.0 */\nexport interface ThemeColors {\n primaryColor: string;\n onPrimaryColor: string;\n secondaryColor: string;\n onSecondaryColor: string;\n warningColor: string;\n onWarningColor: string;\n errorColor: string;\n onErrorColor: string;\n successColor: string;\n onSuccessColor: string;\n}\n\n/** @since 6.0.0 */\nexport interface ThemeTextColors {\n textPrimaryColor: string;\n textSecondaryColor: string;\n textHintColor: string;\n textDisabledColor: string;\n}\n\n/** @since 6.0.0 */\nexport interface ConfigurableThemeColors extends ThemeColors, ThemeTextColors {\n backgroundColor: string;\n}\n\n/** @since 6.0.0 */\nexport type ConfigurableThemeColorsName = keyof ConfigurableThemeColors;\n\n/** @since 6.0.0 */\nexport interface ThemeContext extends ConfigurableThemeColors {\n /**\n * This will be `true` if a `theme` was not provided to the {@link ThemeProvider}\n */\n derived: boolean;\n\n /**\n * @example Simple Example\n * ```tsx\n * import { getDerivedTheme } from \"@react-md/core/theme/getDerivedTheme\"\n * import { useTheme } from \"@react-md/core/theme/ThemeProvider\";\n * import { useHtmlClassName } from \"@react-md/core/useHtmlClassName\";\n * import { useEffect } from \"react\";\n *\n * import styles from \"./LightTheme.module.scss\";\n *\n * let loadedOnce = false;\n *\n * export default function LightTheme(): null {\n * useHtmlClassName(styles.container);\n * const { setDerivedTheme } = useTheme();\n * useEffect(() => {\n * if (loadedOnce) {\n * return;\n * }\n *\n * loadedOnce = true;\n * setDerivedTheme(getDerivedTheme());\n * }, [setDerivedTheme]);\n * return null;\n * }\n * ```\n */\n setDerivedTheme: UseStateSetter<Readonly<ConfigurableThemeColors>>;\n}\n"],"names":[],"mappings":"AA6HA,iBAAiB,GACjB,WAkCC"}
1
+ {"version":3,"sources":["../../src/theme/types.ts"],"sourcesContent":["import { type CSSProperties } from \"react\";\n\nimport { type UseStateSetter } from \"../types.js\";\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-background-color\"?: string;\n \"--rmd-on-background-color\"?: string;\n \"--rmd-surface-color\"?: string;\n \"--rmd-primary-color\"?: string;\n \"--rmd-on-primary-color\"?: string;\n \"--rmd-secondary-color\"?: string;\n \"--rmd-on-secondary-color\"?: string;\n \"--rmd-success-color\"?: string;\n \"--rmd-on-success-color\"?: string;\n \"--rmd-warning-color\"?: string;\n \"--rmd-on-warning-color\"?: string;\n \"--rmd-error-color\"?: string;\n \"--rmd-on-error-color\"?: string;\n \"--rmd-text-primary-color\"?: string;\n \"--rmd-text-secondary-color\"?: string;\n \"--rmd-text-hint-color\"?: string;\n \"--rmd-text-disabled-color\"?: string;\n \"--rmd-outline-width\"?: string | number;\n \"--rmd-outline-color\"?: string;\n \"--rmd-outline-grey-color\"?: string;\n \"--rmd-inverse-color\"?: string;\n }\n}\n\n/**\n * @since 6.0.0\n */\nexport type CSSVariableName = `--${string}`;\n\n/**\n * @internal\n * @since 6.0.0\n */\nexport type DefinedCustomProperty<Property = keyof CSSProperties> =\n Property extends CSSVariableName ? Property : never;\n\n/**\n * This is a utility type that can be used to auto-complete and type-check css\n * variables that are defined through module augmentation.\n *\n * ```ts\n * declare module \"react\" {\n * interface CSSProperties {\n * \"--custom-property\"?: number | string;\n * }\n * }\n *\n * // will no longer throw a type error. also the `--custom-property` will\n * // appear as an auto-complete item\n * const style: CSSProperties = {\n * \"--custom-property\": \"red\",\n * };\n *\n * // `DefinedCSSVariableName` will also include `--custom-property` with all\n * // defined react-md custom properties\n * ```\n *\n * @since 6.0.0\n */\nexport type DefinedCSSVariableName = DefinedCustomProperty;\n\n/**\n * @since 6.0.0\n */\nexport interface CSSVariable<\n Name extends CSSVariableName = DefinedCSSVariableName,\n> {\n name: Name;\n value: string | number;\n}\n\n/**\n * @since 6.0.0\n */\nexport type CSSVariablesProperties<\n Name extends CSSVariableName = DefinedCSSVariableName,\n> = {\n [key in Name]?: string | number;\n};\n\n/**\n * @since 6.0.0\n */\nexport type ReadonlyCSSVariableList<\n Name extends CSSVariableName = DefinedCSSVariableName,\n> = readonly Readonly<CSSVariable<Name>>[];\n\n/** @since 6.0.0 */\nexport type LightDarkColorScheme = \"light\" | \"dark\";\n\n/** @since 6.0.0 */\nexport type ColorScheme = LightDarkColorScheme | \"system\";\n\n/**\n * @since 6.0.0\n */\nexport interface ColorSchemeState {\n /**\n * The defined color scheme for the app that should match the `$color-scheme`\n * SCSS variable.\n */\n colorScheme: ColorScheme;\n setColorScheme: UseStateSetter<ColorScheme>;\n}\n\n/** @since 6.0.0 */\nexport interface ColorSchemeContext extends ColorSchemeState {\n /**\n * When the {@link colorScheme} is set to `\"system\"`, this can be used to\n * determine if the user prefers the `\"light\"` or `\"dark\"` color scheme so\n * that custom styles can be set for that preference.\n */\n currentColor: LightDarkColorScheme;\n}\n\n/** @since 6.0.0 */\nexport interface ThemeColors {\n primaryColor: string;\n onPrimaryColor: string;\n secondaryColor: string;\n onSecondaryColor: string;\n warningColor: string;\n onWarningColor: string;\n errorColor: string;\n onErrorColor: string;\n successColor: string;\n onSuccessColor: string;\n}\n\n/** @since 6.0.0 */\nexport interface ThemeTextColors {\n textPrimaryColor: string;\n textSecondaryColor: string;\n textHintColor: string;\n textDisabledColor: string;\n}\n\n/** @since 6.0.0 */\nexport interface ConfigurableThemeColors extends ThemeColors, ThemeTextColors {\n backgroundColor: string;\n}\n\n/** @since 6.0.0 */\nexport type ConfigurableThemeColorsName = keyof ConfigurableThemeColors;\n\n/** @since 6.0.0 */\nexport interface ThemeContext extends ConfigurableThemeColors {\n /**\n * This will be `true` if a `theme` was not provided to the {@link ThemeProvider}\n */\n derived: boolean;\n\n /**\n * @example Simple Example\n * ```tsx\n * import { getDerivedTheme } from \"@react-md/core/theme/getDerivedTheme\"\n * import { useTheme } from \"@react-md/core/theme/ThemeProvider\";\n * import { useHtmlClassName } from \"@react-md/core/useHtmlClassName\";\n * import { useEffect } from \"react\";\n *\n * import styles from \"./LightTheme.module.scss\";\n *\n * let loadedOnce = false;\n *\n * export default function LightTheme(): null {\n * useHtmlClassName(styles.container);\n * const { setDerivedTheme } = useTheme();\n * useEffect(() => {\n * if (loadedOnce) {\n * return;\n * }\n *\n * loadedOnce = true;\n * setDerivedTheme(getDerivedTheme());\n * }, [setDerivedTheme]);\n * return null;\n * }\n * ```\n */\n setDerivedTheme: UseStateSetter<Readonly<ConfigurableThemeColors>>;\n}\n"],"names":[],"mappings":"AAuJA,iBAAiB,GACjB,WAkCC"}
@@ -1,14 +1,6 @@
1
1
  import { type HTMLAttributes } from "react";
2
- import { type TextOverflow } from "../cssUtils.js";
3
- import { type SimplePosition } from "../positioning/types.js";
4
2
  import { type CSSTransitionClassNames, type CSSTransitionComponentProps, type SSRTransitionOptions, type TransitionActions, type TransitionTimeout } from "../transition/types.js";
5
- declare module "react" {
6
- interface CSSProperties {
7
- "--rmd-tooltip-background-color"?: string;
8
- "--rmd-tooltip-color"?: string;
9
- "--rmd-tooltip-spacing"?: string | number;
10
- }
11
- }
3
+ import { type TooltipClassNameOptions } from "./styles.js";
12
4
  /**
13
5
  * The base props for the `Tooltip` component. This can be extended when
14
6
  * creating custom tooltip implementations.
@@ -18,36 +10,16 @@ declare module "react" {
18
10
  * @since 6.0.0 Removed `lineWrap` for `textOverflow`
19
11
  * @since 6.0.0 No longer supports the `RenderConditionalPortalProps` other than
20
12
  * `portal` with the `disablePortal` prop.
13
+ * @since 6.3.1 Extends TooltipClassNameOptions for CSSProperties module
14
+ * augmentation.
21
15
  */
22
- export interface TooltipProps extends HTMLAttributes<HTMLSpanElement>, CSSTransitionComponentProps, SSRTransitionOptions, TransitionActions {
16
+ export interface TooltipProps extends HTMLAttributes<HTMLSpanElement>, TooltipClassNameOptions, CSSTransitionComponentProps, SSRTransitionOptions, TransitionActions {
23
17
  visible: boolean;
24
- /**
25
- * Set this to `true` to use a smaller font size and padding on the tooltip
26
- * and a smaller gap between the tooltip and tooltipped element.
27
- *
28
- * @defaultValue `false`
29
- */
30
- dense?: boolean;
31
- /**
32
- * @defaultValue `"below"`
33
- */
34
- position?: SimplePosition;
35
18
  /**
36
19
  * @see {@link CSSTransitionComponentProps.temporary}
37
20
  * @defaultValue `true`
38
21
  */
39
22
  temporary?: boolean;
40
- /**
41
- * Set this to `"nowrap"` for tooltips that are positioned near the edge of
42
- * the viewport that have a position of `"above"` or `"below"` so that the
43
- * tooltip no longer aligns to the center of the tooltipped element.
44
- *
45
- * Set this to `"ellipsis"` if the tooltip should only show a single line of
46
- * text and ellipsis once it has reached the max tooltip width.
47
- *
48
- * @defaultValue `"allow"`
49
- */
50
- textOverflow?: TextOverflow;
51
23
  /**
52
24
  * @see {@link CSSTransitionComponentProps.timeout}
53
25
  * @defaultValue `DEFAULT_TOOLTIP_TIMEOUT`
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/tooltip/Tooltip.tsx"],"sourcesContent":["\"use client\";\n\nimport { type HTMLAttributes, forwardRef } from \"react\";\n\nimport { type TextOverflow } from \"../cssUtils.js\";\nimport { Portal } from \"../portal/Portal.js\";\nimport { type SimplePosition } from \"../positioning/types.js\";\nimport {\n type CSSTransitionClassNames,\n type CSSTransitionComponentProps,\n type SSRTransitionOptions,\n type TransitionActions,\n type TransitionTimeout,\n} from \"../transition/types.js\";\nimport { useCSSTransition } from \"../transition/useCSSTransition.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport {\n DEFAULT_TOOLTIP_CLASSNAMES,\n DEFAULT_TOOLTIP_POSITION,\n DEFAULT_TOOLTIP_TIMEOUT,\n} from \"./constants.js\";\nimport { tooltip } from \"./styles.js\";\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-tooltip-background-color\"?: string;\n \"--rmd-tooltip-color\"?: string;\n \"--rmd-tooltip-spacing\"?: string | number;\n }\n}\n\n/**\n * The base props for the `Tooltip` component. This can be extended when\n * creating custom tooltip implementations.\n *\n * @since 2.8.0 Supports the `RenderConditionalPortalProps`\n * @since 6.0.0 The `id` prop is optional.\n * @since 6.0.0 Removed `lineWrap` for `textOverflow`\n * @since 6.0.0 No longer supports the `RenderConditionalPortalProps` other than\n * `portal` with the `disablePortal` prop.\n */\nexport interface TooltipProps\n extends HTMLAttributes<HTMLSpanElement>,\n CSSTransitionComponentProps,\n SSRTransitionOptions,\n TransitionActions {\n visible: boolean;\n\n /**\n * Set this to `true` to use a smaller font size and padding on the tooltip\n * and a smaller gap between the tooltip and tooltipped element.\n *\n * @defaultValue `false`\n */\n dense?: boolean;\n\n /**\n * @defaultValue `\"below\"`\n */\n position?: SimplePosition;\n\n /**\n * @see {@link CSSTransitionComponentProps.temporary}\n * @defaultValue `true`\n */\n temporary?: boolean;\n\n /**\n * Set this to `\"nowrap\"` for tooltips that are positioned near the edge of\n * the viewport that have a position of `\"above\"` or `\"below\"` so that the\n * tooltip no longer aligns to the center of the tooltipped element.\n *\n * Set this to `\"ellipsis\"` if the tooltip should only show a single line of\n * text and ellipsis once it has reached the max tooltip width.\n *\n * @defaultValue `\"allow\"`\n */\n textOverflow?: TextOverflow;\n\n /**\n * @see {@link CSSTransitionComponentProps.timeout}\n * @defaultValue `DEFAULT_TOOLTIP_TIMEOUT`\n */\n timeout?: TransitionTimeout;\n\n /**\n * @see {@link CSSTransitionComponentProps.classNames}\n * @defaultValue `DEFAULT_TOOLTIP_CLASSNAMES`\n */\n classNames?: CSSTransitionClassNames;\n}\n\n/**\n * **Client Component**\n *\n * This is the base tooltip component that can only be used to render a tooltip\n * with an animation when the visibility changes. If this component is used, you\n * will need to manually add all the event listeners and triggers to change the\n * `visible` prop.\n *\n * @example Simple Usage\n * ```tsx\n * import { Button } from \"@react-md/core/button/Button\";\n * import { Tooltip } from \"@react-md/core/tooltip/Tooltip\";\n * import { useTooltip } from \"@react-md/core/tooltip/useTooltip\";\n *\n * function Example() {\n * const { elementProps, tooltipProps } = useTooltip();\n *\n * return (\n * <>\n * <Button {...elementProps}>Button</Button>\n * <Tooltip {...tooltipProps}>\n * Tooltip Content\n * </Tooltip>\n * </>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/tooltip | Tooltip Demos}\n */\nexport const Tooltip = forwardRef<HTMLSpanElement, TooltipProps>(\n function Tooltip(props, nodeRef) {\n const {\n id: propId,\n dense,\n visible,\n children,\n appear,\n enter,\n exit,\n onEnter,\n onEntering,\n onEntered,\n onExit,\n onExiting,\n onExited,\n timeout = DEFAULT_TOOLTIP_TIMEOUT,\n classNames = DEFAULT_TOOLTIP_CLASSNAMES,\n className,\n position = DEFAULT_TOOLTIP_POSITION,\n temporary = true,\n exitedHidden = !temporary,\n textOverflow,\n disablePortal: propDisablePortal,\n ...remaining\n } = props;\n const id = useEnsuredId(propId, \"tooltip\");\n\n const { rendered, elementProps, disablePortal } = useCSSTransition({\n nodeRef,\n appear,\n enter,\n exit,\n transitionIn: visible,\n timeout,\n classNames,\n className: tooltip({\n dense,\n position,\n className,\n textOverflow,\n }),\n onEnter,\n onEntering,\n onEntered,\n onExit,\n onExiting,\n onExited,\n temporary,\n exitedHidden,\n disablePortal: propDisablePortal,\n });\n\n return (\n <Portal disabled={disablePortal}>\n {rendered && (\n <span {...remaining} {...elementProps} id={id} role=\"tooltip\">\n {children}\n </span>\n )}\n </Portal>\n );\n }\n);\n"],"names":["forwardRef","Portal","useCSSTransition","useEnsuredId","DEFAULT_TOOLTIP_CLASSNAMES","DEFAULT_TOOLTIP_POSITION","DEFAULT_TOOLTIP_TIMEOUT","tooltip","Tooltip","props","nodeRef","id","propId","dense","visible","children","appear","enter","exit","onEnter","onEntering","onEntered","onExit","onExiting","onExited","timeout","classNames","className","position","temporary","exitedHidden","textOverflow","disablePortal","propDisablePortal","remaining","rendered","elementProps","transitionIn","disabled","span","role"],"mappings":"AAAA;;AAEA,SAA8BA,UAAU,QAAQ,QAAQ;AAGxD,SAASC,MAAM,QAAQ,sBAAsB;AAS7C,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SACEC,0BAA0B,EAC1BC,wBAAwB,EACxBC,uBAAuB,QAClB,iBAAiB;AACxB,SAASC,OAAO,QAAQ,cAAc;AAuEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BC,GACD,OAAO,MAAMC,wBAAUR,WACrB,SAASQ,QAAQC,KAAK,EAAEC,OAAO;IAC7B,MAAM,EACJC,IAAIC,MAAM,EACVC,KAAK,EACLC,OAAO,EACPC,QAAQ,EACRC,MAAM,EACNC,KAAK,EACLC,IAAI,EACJC,OAAO,EACPC,UAAU,EACVC,SAAS,EACTC,MAAM,EACNC,SAAS,EACTC,QAAQ,EACRC,UAAUnB,uBAAuB,EACjCoB,aAAatB,0BAA0B,EACvCuB,SAAS,EACTC,WAAWvB,wBAAwB,EACnCwB,YAAY,IAAI,EAChBC,eAAe,CAACD,SAAS,EACzBE,YAAY,EACZC,eAAeC,iBAAiB,EAChC,GAAGC,WACJ,GAAGzB;IACJ,MAAME,KAAKR,aAAaS,QAAQ;IAEhC,MAAM,EAAEuB,QAAQ,EAAEC,YAAY,EAAEJ,aAAa,EAAE,GAAG9B,iBAAiB;QACjEQ;QACAM;QACAC;QACAC;QACAmB,cAAcvB;QACdW;QACAC;QACAC,WAAWpB,QAAQ;YACjBM;YACAe;YACAD;YACAI;QACF;QACAZ;QACAC;QACAC;QACAC;QACAC;QACAC;QACAK;QACAC;QACAE,eAAeC;IACjB;IAEA,qBACE,KAAChC;QAAOqC,UAAUN;kBACfG,0BACC,KAACI;YAAM,GAAGL,SAAS;YAAG,GAAGE,YAAY;YAAEzB,IAAIA;YAAI6B,MAAK;sBACjDzB;;;AAKX,GACA"}
1
+ {"version":3,"sources":["../../src/tooltip/Tooltip.tsx"],"sourcesContent":["\"use client\";\n\nimport { type HTMLAttributes, forwardRef } from \"react\";\n\nimport { Portal } from \"../portal/Portal.js\";\nimport {\n type CSSTransitionClassNames,\n type CSSTransitionComponentProps,\n type SSRTransitionOptions,\n type TransitionActions,\n type TransitionTimeout,\n} from \"../transition/types.js\";\nimport { useCSSTransition } from \"../transition/useCSSTransition.js\";\nimport { useEnsuredId } from \"../useEnsuredId.js\";\nimport {\n DEFAULT_TOOLTIP_CLASSNAMES,\n DEFAULT_TOOLTIP_POSITION,\n DEFAULT_TOOLTIP_TIMEOUT,\n} from \"./constants.js\";\nimport { type TooltipClassNameOptions, tooltip } from \"./styles.js\";\n\n/**\n * The base props for the `Tooltip` component. This can be extended when\n * creating custom tooltip implementations.\n *\n * @since 2.8.0 Supports the `RenderConditionalPortalProps`\n * @since 6.0.0 The `id` prop is optional.\n * @since 6.0.0 Removed `lineWrap` for `textOverflow`\n * @since 6.0.0 No longer supports the `RenderConditionalPortalProps` other than\n * `portal` with the `disablePortal` prop.\n * @since 6.3.1 Extends TooltipClassNameOptions for CSSProperties module\n * augmentation.\n */\nexport interface TooltipProps\n extends HTMLAttributes<HTMLSpanElement>,\n TooltipClassNameOptions,\n CSSTransitionComponentProps,\n SSRTransitionOptions,\n TransitionActions {\n visible: boolean;\n\n /**\n * @see {@link CSSTransitionComponentProps.temporary}\n * @defaultValue `true`\n */\n temporary?: boolean;\n\n /**\n * @see {@link CSSTransitionComponentProps.timeout}\n * @defaultValue `DEFAULT_TOOLTIP_TIMEOUT`\n */\n timeout?: TransitionTimeout;\n\n /**\n * @see {@link CSSTransitionComponentProps.classNames}\n * @defaultValue `DEFAULT_TOOLTIP_CLASSNAMES`\n */\n classNames?: CSSTransitionClassNames;\n}\n\n/**\n * **Client Component**\n *\n * This is the base tooltip component that can only be used to render a tooltip\n * with an animation when the visibility changes. If this component is used, you\n * will need to manually add all the event listeners and triggers to change the\n * `visible` prop.\n *\n * @example Simple Usage\n * ```tsx\n * import { Button } from \"@react-md/core/button/Button\";\n * import { Tooltip } from \"@react-md/core/tooltip/Tooltip\";\n * import { useTooltip } from \"@react-md/core/tooltip/useTooltip\";\n *\n * function Example() {\n * const { elementProps, tooltipProps } = useTooltip();\n *\n * return (\n * <>\n * <Button {...elementProps}>Button</Button>\n * <Tooltip {...tooltipProps}>\n * Tooltip Content\n * </Tooltip>\n * </>\n * );\n * }\n * ```\n *\n * @see {@link https://react-md.dev/components/tooltip | Tooltip Demos}\n */\nexport const Tooltip = forwardRef<HTMLSpanElement, TooltipProps>(\n function Tooltip(props, nodeRef) {\n const {\n id: propId,\n dense,\n visible,\n children,\n appear,\n enter,\n exit,\n onEnter,\n onEntering,\n onEntered,\n onExit,\n onExiting,\n onExited,\n timeout = DEFAULT_TOOLTIP_TIMEOUT,\n classNames = DEFAULT_TOOLTIP_CLASSNAMES,\n className,\n position = DEFAULT_TOOLTIP_POSITION,\n temporary = true,\n exitedHidden = !temporary,\n textOverflow,\n disablePortal: propDisablePortal,\n ...remaining\n } = props;\n const id = useEnsuredId(propId, \"tooltip\");\n\n const { rendered, elementProps, disablePortal } = useCSSTransition({\n nodeRef,\n appear,\n enter,\n exit,\n transitionIn: visible,\n timeout,\n classNames,\n className: tooltip({\n dense,\n position,\n className,\n textOverflow,\n }),\n onEnter,\n onEntering,\n onEntered,\n onExit,\n onExiting,\n onExited,\n temporary,\n exitedHidden,\n disablePortal: propDisablePortal,\n });\n\n return (\n <Portal disabled={disablePortal}>\n {rendered && (\n <span {...remaining} {...elementProps} id={id} role=\"tooltip\">\n {children}\n </span>\n )}\n </Portal>\n );\n }\n);\n"],"names":["forwardRef","Portal","useCSSTransition","useEnsuredId","DEFAULT_TOOLTIP_CLASSNAMES","DEFAULT_TOOLTIP_POSITION","DEFAULT_TOOLTIP_TIMEOUT","tooltip","Tooltip","props","nodeRef","id","propId","dense","visible","children","appear","enter","exit","onEnter","onEntering","onEntered","onExit","onExiting","onExited","timeout","classNames","className","position","temporary","exitedHidden","textOverflow","disablePortal","propDisablePortal","remaining","rendered","elementProps","transitionIn","disabled","span","role"],"mappings":"AAAA;;AAEA,SAA8BA,UAAU,QAAQ,QAAQ;AAExD,SAASC,MAAM,QAAQ,sBAAsB;AAQ7C,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SACEC,0BAA0B,EAC1BC,wBAAwB,EACxBC,uBAAuB,QAClB,iBAAiB;AACxB,SAAuCC,OAAO,QAAQ,cAAc;AAyCpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BC,GACD,OAAO,MAAMC,wBAAUR,WACrB,SAASQ,QAAQC,KAAK,EAAEC,OAAO;IAC7B,MAAM,EACJC,IAAIC,MAAM,EACVC,KAAK,EACLC,OAAO,EACPC,QAAQ,EACRC,MAAM,EACNC,KAAK,EACLC,IAAI,EACJC,OAAO,EACPC,UAAU,EACVC,SAAS,EACTC,MAAM,EACNC,SAAS,EACTC,QAAQ,EACRC,UAAUnB,uBAAuB,EACjCoB,aAAatB,0BAA0B,EACvCuB,SAAS,EACTC,WAAWvB,wBAAwB,EACnCwB,YAAY,IAAI,EAChBC,eAAe,CAACD,SAAS,EACzBE,YAAY,EACZC,eAAeC,iBAAiB,EAChC,GAAGC,WACJ,GAAGzB;IACJ,MAAME,KAAKR,aAAaS,QAAQ;IAEhC,MAAM,EAAEuB,QAAQ,EAAEC,YAAY,EAAEJ,aAAa,EAAE,GAAG9B,iBAAiB;QACjEQ;QACAM;QACAC;QACAC;QACAmB,cAAcvB;QACdW;QACAC;QACAC,WAAWpB,QAAQ;YACjBM;YACAe;YACAD;YACAI;QACF;QACAZ;QACAC;QACAC;QACAC;QACAC;QACAC;QACAK;QACAC;QACAE,eAAeC;IACjB;IAEA,qBACE,KAAChC;QAAOqC,UAAUN;kBACfG,0BACC,KAACI;YAAM,GAAGL,SAAS;YAAG,GAAGE,YAAY;YAAEzB,IAAIA;YAAI6B,MAAK;sBACjDzB;;;AAKX,GACA"}
@@ -1,12 +1,49 @@
1
1
  import { type TextOverflow } from "../cssUtils.js";
2
2
  import { type SimplePosition } from "../positioning/types.js";
3
+ declare module "react" {
4
+ interface CSSProperties {
5
+ "--rmd-tooltip-background-color"?: string;
6
+ "--rmd-tooltip-border-radius"?: string | number;
7
+ "--rmd-tooltip-color"?: string;
8
+ "--rmd-tooltip-spacing"?: string | number;
9
+ "--rmd-tooltip-z-index"?: string | number;
10
+ "--rmd-tooltip-horizontal-padding"?: string | number;
11
+ "--rmd-tooltip-vertical-padding"?: string | number;
12
+ "--rmd-tooltip-min-height"?: string | number;
13
+ "--rmd-tooltip-max-width"?: string | number;
14
+ "--rmd-tooltip-dense-horizontal-padding"?: string | number;
15
+ "--rmd-tooltip-dense-vertical-padding"?: string | number;
16
+ "--rmd-tooltip-dense-min-height"?: string | number;
17
+ "--rmd-tooltip-transition-distance"?: string | number;
18
+ }
19
+ }
3
20
  /**
4
21
  * @since 6.0.0
22
+ * @since 6.3.1 Allow `position` to be optional
5
23
  */
6
24
  export interface TooltipClassNameOptions {
7
25
  className?: string;
26
+ /**
27
+ * Set this to `true` to use a smaller font size and padding on the tooltip
28
+ * and a smaller gap between the tooltip and tooltipped element.
29
+ *
30
+ * @defaultValue `false`
31
+ */
8
32
  dense?: boolean;
9
- position: SimplePosition;
33
+ /**
34
+ * @defaultValue `"below"`
35
+ */
36
+ position?: SimplePosition;
37
+ /**
38
+ * Set this to `"nowrap"` for tooltips that are positioned near the edge of
39
+ * the viewport that have a position of `"above"` or `"below"` so that the
40
+ * tooltip no longer aligns to the center of the tooltipped element.
41
+ *
42
+ * Set this to `"ellipsis"` if the tooltip should only show a single line of
43
+ * text and ellipsis once it has reached the max tooltip width.
44
+ *
45
+ * @defaultValue `"allow"`
46
+ */
10
47
  textOverflow?: TextOverflow;
11
48
  }
12
49
  /**
@@ -5,7 +5,7 @@ const styles = bem("rmd-tooltip");
5
5
  /**
6
6
  * @since 6.0.0
7
7
  */ export function tooltip(options) {
8
- const { dense, position, className, textOverflow } = options;
8
+ const { dense, position = "below", className, textOverflow } = options;
9
9
  return cnb(styles({
10
10
  dense,
11
11
  [position]: true
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/tooltip/styles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { type TextOverflow, cssUtils } from \"../cssUtils.js\";\nimport { type SimplePosition } from \"../positioning/types.js\";\nimport { bem } from \"../utils/bem.js\";\n\nconst styles = bem(\"rmd-tooltip\");\n\n/**\n * @since 6.0.0\n */\nexport interface TooltipClassNameOptions {\n className?: string;\n dense?: boolean;\n position: SimplePosition;\n textOverflow?: TextOverflow;\n}\n\n/**\n * @since 6.0.0\n */\nexport function tooltip(options: TooltipClassNameOptions): string {\n const { dense, position, className, textOverflow } = options;\n\n return cnb(\n styles({\n dense,\n [position]: true,\n }),\n cssUtils({ textOverflow }),\n className\n );\n}\n"],"names":["cnb","cssUtils","bem","styles","tooltip","options","dense","position","className","textOverflow"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAA4BC,QAAQ,QAAQ,iBAAiB;AAE7D,SAASC,GAAG,QAAQ,kBAAkB;AAEtC,MAAMC,SAASD,IAAI;AAYnB;;CAEC,GACD,OAAO,SAASE,QAAQC,OAAgC;IACtD,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,YAAY,EAAE,GAAGJ;IAErD,OAAOL,IACLG,OAAO;QACLG;QACA,CAACC,SAAS,EAAE;IACd,IACAN,SAAS;QAAEQ;IAAa,IACxBD;AAEJ"}
1
+ {"version":3,"sources":["../../src/tooltip/styles.ts"],"sourcesContent":["import { cnb } from \"cnbuilder\";\n\nimport { type TextOverflow, cssUtils } from \"../cssUtils.js\";\nimport { type SimplePosition } from \"../positioning/types.js\";\nimport { bem } from \"../utils/bem.js\";\n\nconst styles = bem(\"rmd-tooltip\");\n\ndeclare module \"react\" {\n interface CSSProperties {\n \"--rmd-tooltip-background-color\"?: string;\n \"--rmd-tooltip-border-radius\"?: string | number;\n \"--rmd-tooltip-color\"?: string;\n \"--rmd-tooltip-spacing\"?: string | number;\n \"--rmd-tooltip-z-index\"?: string | number;\n \"--rmd-tooltip-horizontal-padding\"?: string | number;\n \"--rmd-tooltip-vertical-padding\"?: string | number;\n \"--rmd-tooltip-min-height\"?: string | number;\n \"--rmd-tooltip-max-width\"?: string | number;\n \"--rmd-tooltip-dense-horizontal-padding\"?: string | number;\n \"--rmd-tooltip-dense-vertical-padding\"?: string | number;\n \"--rmd-tooltip-dense-min-height\"?: string | number;\n \"--rmd-tooltip-transition-distance\"?: string | number;\n }\n}\n\n/**\n * @since 6.0.0\n * @since 6.3.1 Allow `position` to be optional\n */\nexport interface TooltipClassNameOptions {\n className?: string;\n\n /**\n * Set this to `true` to use a smaller font size and padding on the tooltip\n * and a smaller gap between the tooltip and tooltipped element.\n *\n * @defaultValue `false`\n */\n dense?: boolean;\n\n /**\n * @defaultValue `\"below\"`\n */\n position?: SimplePosition;\n\n /**\n * Set this to `\"nowrap\"` for tooltips that are positioned near the edge of\n * the viewport that have a position of `\"above\"` or `\"below\"` so that the\n * tooltip no longer aligns to the center of the tooltipped element.\n *\n * Set this to `\"ellipsis\"` if the tooltip should only show a single line of\n * text and ellipsis once it has reached the max tooltip width.\n *\n * @defaultValue `\"allow\"`\n */\n textOverflow?: TextOverflow;\n}\n\n/**\n * @since 6.0.0\n */\nexport function tooltip(options: TooltipClassNameOptions): string {\n const { dense, position = \"below\", className, textOverflow } = options;\n\n return cnb(\n styles({\n dense,\n [position]: true,\n }),\n cssUtils({ textOverflow }),\n className\n );\n}\n"],"names":["cnb","cssUtils","bem","styles","tooltip","options","dense","position","className","textOverflow"],"mappings":"AAAA,SAASA,GAAG,QAAQ,YAAY;AAEhC,SAA4BC,QAAQ,QAAQ,iBAAiB;AAE7D,SAASC,GAAG,QAAQ,kBAAkB;AAEtC,MAAMC,SAASD,IAAI;AAqDnB;;CAEC,GACD,OAAO,SAASE,QAAQC,OAAgC;IACtD,MAAM,EAAEC,KAAK,EAAEC,WAAW,OAAO,EAAEC,SAAS,EAAEC,YAAY,EAAE,GAAGJ;IAE/D,OAAOL,IACLG,OAAO;QACLG;QACA,CAACC,SAAS,EAAE;IACd,IACAN,SAAS;QAAEQ;IAAa,IACxBD;AAEJ"}
@@ -1,12 +1,5 @@
1
1
  import { type HTMLAttributes, type ReactNode } from "react";
2
2
  import { type SkeletonPlaceholderOptions } from "./useSkeletonPlaceholder.js";
3
- declare module "react" {
4
- interface CSSProperties {
5
- "--rmd-skeleton-placeholder-background-color"?: string;
6
- "--rmd-skeleton-placeholder-height"?: string | number;
7
- "--rmd-skeleton-placeholder-width"?: string | number;
8
- }
9
- }
10
3
  /** @since 6.0.0 */
11
4
  export interface SkeletonPlaceholderProps extends HTMLAttributes<HTMLDivElement>, SkeletonPlaceholderOptions {
12
5
  /**