@react-md/core 6.0.2 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/_base.scss +6 -2
  2. package/dist/_border-radius.scss +92 -0
  3. package/dist/_core.scss +2 -0
  4. package/dist/_spacing.scss +86 -0
  5. package/dist/app-bar/_app-bar.scss +9 -7
  6. package/dist/app-bar/styles.js +1 -1
  7. package/dist/app-bar/styles.js.map +1 -1
  8. package/dist/avatar/_avatar.scss +3 -3
  9. package/dist/badge/_badge.scss +10 -2
  10. package/dist/box/_box.scss +78 -11
  11. package/dist/button/_button.scss +21 -11
  12. package/dist/card/_card.scss +9 -7
  13. package/dist/chip/_chip.scss +9 -7
  14. package/dist/dialog/_dialog.scss +7 -6
  15. package/dist/divider/_divider.scss +3 -2
  16. package/dist/expansion-panel/_expansion-panel.scss +4 -3
  17. package/dist/form/TextArea.js +1 -1
  18. package/dist/form/TextArea.js.map +1 -1
  19. package/dist/form/_form-message.scss +4 -3
  20. package/dist/form/_input-toggle.scss +2 -1
  21. package/dist/form/_label.scss +3 -2
  22. package/dist/form/_password.scss +2 -1
  23. package/dist/form/_select.scss +4 -4
  24. package/dist/form/_slider.scss +4 -3
  25. package/dist/form/_switch.scss +2 -1
  26. package/dist/form/_text-area.scss +3 -2
  27. package/dist/form/_text-field.scss +20 -16
  28. package/dist/form/utils.js +1 -0
  29. package/dist/form/utils.js.map +1 -1
  30. package/dist/icon/_icon.scss +2 -1
  31. package/dist/interaction/useElementInteraction.js +1 -1
  32. package/dist/interaction/useElementInteraction.js.map +1 -1
  33. package/dist/layout/LayoutNav.js +1 -1
  34. package/dist/layout/LayoutNav.js.map +1 -1
  35. package/dist/layout/useMainTabIndex.js +1 -0
  36. package/dist/layout/useMainTabIndex.js.map +1 -1
  37. package/dist/link/_link.scss +3 -2
  38. package/dist/list/_list.scss +7 -6
  39. package/dist/menu/_menu.scss +2 -1
  40. package/dist/navigation/_navigation.scss +5 -3
  41. package/dist/responsive-item/_responsive-item.scss +2 -1
  42. package/dist/segmented-button/_segmented-button.scss +20 -13
  43. package/dist/sheet/_sheet.scss +2 -1
  44. package/dist/snackbar/_snackbar.scss +12 -10
  45. package/dist/table/_table.scss +5 -4
  46. package/dist/tabs/_tabs.scss +7 -4
  47. package/dist/theme/utils.js +2 -2
  48. package/dist/theme/utils.js.map +1 -1
  49. package/dist/tooltip/_tooltip.scss +52 -25
  50. package/dist/transition/_transition.scss +2 -1
  51. package/dist/tree/_tree.scss +1 -1
  52. package/dist/utils/bem.js +1 -1
  53. package/dist/utils/bem.js.map +1 -1
  54. package/dist/utils/parseCssLengthUnit.js +3 -0
  55. package/dist/utils/parseCssLengthUnit.js.map +1 -1
  56. package/package.json +10 -10
  57. package/src/app-bar/styles.ts +1 -1
  58. package/src/form/TextArea.tsx +1 -1
  59. package/src/form/utils.ts +1 -0
  60. package/src/interaction/useElementInteraction.tsx +1 -1
  61. package/src/layout/LayoutNav.tsx +1 -1
  62. package/src/layout/useMainTabIndex.ts +1 -0
  63. package/src/theme/utils.ts +2 -1
  64. package/src/utils/bem.ts +1 -1
  65. package/src/utils/parseCssLengthUnit.ts +4 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/theme/utils.ts"],"sourcesContent":["import { black, white } from \"./colors.js\";\n\nconst RGB_REGEX = /^rgb\\(((\\b([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\b),?){3}\\)$/;\nconst SHORTHAND_REGEX = /^#?([a-f\\d])([a-f\\d])([a-f\\d])$/i;\nconst VERBOSE_REGEX = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i;\n\nexport type RGB = readonly [red: number, green: number, blue: number];\n\n/**\n * Converts a hex string into an rgb value. This is useful for detecting color\n * contrast ratios and other stuff.\n *\n * @param hex - The hex string to convert\n * @returns an object containing the r, g, b values for the color.\n */\nexport function hexToRGB(hex: string): RGB {\n if (\n process.env.NODE_ENV !== \"production\" &&\n !SHORTHAND_REGEX.test(hex) &&\n !VERBOSE_REGEX.test(hex)\n ) {\n throw new TypeError(\"Invalid color string.\");\n }\n\n hex = hex.replace(\n SHORTHAND_REGEX,\n (_m, r, g, b) => `${r}${r}${g}${g}${b}${b}`\n );\n\n const result = hex.match(VERBOSE_REGEX) || [];\n const r = parseInt(result[1] || \"\", 16) || 0;\n const g = parseInt(result[2] || \"\", 16) || 0;\n const b = parseInt(result[3] || \"\", 16) || 0;\n\n return [r, g, b];\n}\n\nexport function getRGB(color: string): RGB {\n // chrome 102.0.50005.63 apparently has whitespace when calling `window.getComputedStyle(element)`\n // remove whitepsace to make it easy for supporting rgb or hex\n color = color.replace(/\\s/g, \"\");\n const rgbMatches = color.match(RGB_REGEX);\n if (rgbMatches) {\n const r = parseInt(rgbMatches[1] || \"\", 16) || 0;\n const g = parseInt(rgbMatches[2] || \"\", 16) || 0;\n const b = parseInt(rgbMatches[3] || \"\", 16) || 0;\n\n return [r, g, b];\n }\n\n return hexToRGB(color);\n}\n\nconst RED_MULTIPLIER = 0.2126;\nconst GREEN_MULTIPLIER = 0.7152;\nconst BLUE_MULTIPLIER = 0.0722;\n\n/**\n * I really couldn't figure out how to name these \"magic\" numbers since the\n * formula doesn't really describe it much:\n *\n * @see https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests\n * @internal\n */\nfunction get8BitColor(color: number): number {\n color /= 255;\n\n if (color <= 0.03928) {\n return color / 12.92;\n }\n\n return ((color + 0.055) / 1.055) ** 2.4;\n}\n\n/**\n * A number closest to 0 should be closest to black while a number closest to 1\n * should be closest to white.\n *\n * @see https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests\n * @internal\n */\nexport function getLuminance(color: string): number {\n const [r, g, b] = getRGB(color);\n\n const red = get8BitColor(r) * RED_MULTIPLIER;\n const green = get8BitColor(g) * GREEN_MULTIPLIER;\n const blue = get8BitColor(b) * BLUE_MULTIPLIER;\n\n return red + green + blue;\n}\n\n/**\n * Gets the contrast ratio between a background color and a foreground color.\n *\n * @see https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests\n *\n * @param background - The background color\n * @param foreground - The foreground color. This is normally the `color` css\n * value.\n * @returns the contrast ratio between the background and foreground colors.\n */\nexport function getContrastRatio(\n background: string,\n foreground: string\n): number {\n const backgroundLuminance = getLuminance(background) + 0.05;\n const foregroundLuminance = getLuminance(foreground) + 0.05;\n\n return (\n Math.max(backgroundLuminance, foregroundLuminance) /\n Math.min(backgroundLuminance, foregroundLuminance)\n );\n}\n\n/**\n * The type of contrast ratio compliance to confirm to. The ratios in order are:\n * - 3:1 for large text (18pt normal or 14pt bold)\n * - 4.5:1 for normal text\n * - 7:1 for Level AAA requirements.\n *\n * @see https://www.w3.org/TR/WCAG20/#visual-audio-contrast\n * @see https://www.w3.org/TR/WCAG20/#larger-scaledef\n */\nexport type ContrastRatioCompliance = \"large\" | \"normal\" | \"AAA\";\n\n/**\n * The contrast ratio that can be used for large text where large text is\n * considered 18pt or 14pt bold.\n */\nexport const LARGE_TEXT_CONTRAST_RATIO = 3;\n\n/**\n * The contrast ratio that can be used for normal text.\n */\nexport const NORMAL_TEXT_CONTRAST_RATIO = 4.5;\n\n/**\n * The AAA contrast ratio for passing WGAC 2.0 color contrast ratios.\n */\nexport const AAA_CONTRAST_RATIO = 7;\n\n/**\n * Checks if there is an acceptable contrast ratio between the background and\n * foreground colors based on the provided compliance level.\n *\n * @param background - The background color to check against\n * @param foreground - The foreground color to check against\n * @param compliance - The compliance level to use or a custom number as a\n * ratio.\n * @returns true if there is enough contrast between the foreground and\n * background colors for the provided compliance level.\n */\nexport function isContrastCompliant(\n background: string,\n foreground: string,\n compliance: ContrastRatioCompliance | number = \"normal\"\n): boolean {\n let ratio: number;\n switch (compliance) {\n case \"large\":\n ratio = LARGE_TEXT_CONTRAST_RATIO;\n break;\n case \"normal\":\n ratio = NORMAL_TEXT_CONTRAST_RATIO;\n break;\n case \"AAA\":\n ratio = AAA_CONTRAST_RATIO;\n break;\n default:\n ratio = compliance;\n }\n\n return getContrastRatio(background, foreground) >= ratio;\n}\n\n/**\n * Returns the highest contrast color to the provided `backgroundColor`. This is\n * normally used to ensure that a new background color can use an accessible text\n * color of either `#000` or `#fff`.\n *\n * This is pretty much a javascript implementation as the `contrast-color` Sass\n * function.\n *\n * @since 6.0.0\n */\nexport function contrastColor(\n backgroundColor: string,\n lightColor = white,\n darkColor = black\n): string {\n const lightContrast = getContrastRatio(backgroundColor, lightColor);\n const darkContrast = getContrastRatio(backgroundColor, darkColor);\n\n return lightContrast > darkContrast ? lightColor : darkColor;\n}\n"],"names":["black","white","RGB_REGEX","SHORTHAND_REGEX","VERBOSE_REGEX","hexToRGB","hex","process","env","NODE_ENV","test","TypeError","replace","_m","r","g","b","result","match","parseInt","getRGB","color","rgbMatches","RED_MULTIPLIER","GREEN_MULTIPLIER","BLUE_MULTIPLIER","get8BitColor","getLuminance","red","green","blue","getContrastRatio","background","foreground","backgroundLuminance","foregroundLuminance","Math","max","min","LARGE_TEXT_CONTRAST_RATIO","NORMAL_TEXT_CONTRAST_RATIO","AAA_CONTRAST_RATIO","isContrastCompliant","compliance","ratio","contrastColor","backgroundColor","lightColor","darkColor","lightContrast","darkContrast"],"mappings":"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"}
1
+ {"version":3,"sources":["../../src/theme/utils.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport { black, white } from \"./colors.js\";\n\nconst RGB_REGEX = /^rgb\\(((\\b([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\b),?){3}\\)$/;\nconst SHORTHAND_REGEX = /^#?([a-f\\d])([a-f\\d])([a-f\\d])$/i;\nconst VERBOSE_REGEX = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i;\n\nexport type RGB = readonly [red: number, green: number, blue: number];\n\n/**\n * Converts a hex string into an rgb value. This is useful for detecting color\n * contrast ratios and other stuff.\n *\n * @param hex - The hex string to convert\n * @returns an object containing the r, g, b values for the color.\n */\nexport function hexToRGB(hex: string): RGB {\n if (\n process.env.NODE_ENV !== \"production\" &&\n !SHORTHAND_REGEX.test(hex) &&\n !VERBOSE_REGEX.test(hex)\n ) {\n throw new TypeError(\"Invalid color string.\");\n }\n\n hex = hex.replace(\n SHORTHAND_REGEX,\n (_m, r, g, b) => `${r}${r}${g}${g}${b}${b}`\n );\n\n const result = hex.match(VERBOSE_REGEX) || [];\n const r = parseInt(result[1] || \"\", 16) || 0;\n const g = parseInt(result[2] || \"\", 16) || 0;\n const b = parseInt(result[3] || \"\", 16) || 0;\n\n return [r, g, b];\n}\n\nexport function getRGB(color: string): RGB {\n // chrome 102.0.50005.63 apparently has whitespace when calling `window.getComputedStyle(element)`\n // remove whitespace to make it easy for supporting rgb or hex\n color = color.replace(/\\s/g, \"\");\n const rgbMatches = color.match(RGB_REGEX);\n if (rgbMatches) {\n const r = parseInt(rgbMatches[1] || \"\", 16) || 0;\n const g = parseInt(rgbMatches[2] || \"\", 16) || 0;\n const b = parseInt(rgbMatches[3] || \"\", 16) || 0;\n\n return [r, g, b];\n }\n\n return hexToRGB(color);\n}\n\nconst RED_MULTIPLIER = 0.2126;\nconst GREEN_MULTIPLIER = 0.7152;\nconst BLUE_MULTIPLIER = 0.0722;\n\n/**\n * I really couldn't figure out how to name these \"magic\" numbers since the\n * formula doesn't really describe it much:\n *\n * @see https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests\n * @internal\n */\nfunction get8BitColor(color: number): number {\n color /= 255;\n\n if (color <= 0.03928) {\n return color / 12.92;\n }\n\n return ((color + 0.055) / 1.055) ** 2.4;\n}\n\n/**\n * A number closest to 0 should be closest to black while a number closest to 1\n * should be closest to white.\n *\n * @see https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests\n * @internal\n */\nexport function getLuminance(color: string): number {\n const [r, g, b] = getRGB(color);\n\n const red = get8BitColor(r) * RED_MULTIPLIER;\n const green = get8BitColor(g) * GREEN_MULTIPLIER;\n const blue = get8BitColor(b) * BLUE_MULTIPLIER;\n\n return red + green + blue;\n}\n\n/**\n * Gets the contrast ratio between a background color and a foreground color.\n *\n * @see https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests\n *\n * @param background - The background color\n * @param foreground - The foreground color. This is normally the `color` css\n * value.\n * @returns the contrast ratio between the background and foreground colors.\n */\nexport function getContrastRatio(\n background: string,\n foreground: string\n): number {\n const backgroundLuminance = getLuminance(background) + 0.05;\n const foregroundLuminance = getLuminance(foreground) + 0.05;\n\n return (\n Math.max(backgroundLuminance, foregroundLuminance) /\n Math.min(backgroundLuminance, foregroundLuminance)\n );\n}\n\n/**\n * The type of contrast ratio compliance to confirm to. The ratios in order are:\n * - 3:1 for large text (18pt normal or 14pt bold)\n * - 4.5:1 for normal text\n * - 7:1 for Level AAA requirements.\n *\n * @see https://www.w3.org/TR/WCAG20/#visual-audio-contrast\n * @see https://www.w3.org/TR/WCAG20/#larger-scaledef\n */\nexport type ContrastRatioCompliance = \"large\" | \"normal\" | \"AAA\";\n\n/**\n * The contrast ratio that can be used for large text where large text is\n * considered 18pt or 14pt bold.\n */\nexport const LARGE_TEXT_CONTRAST_RATIO = 3;\n\n/**\n * The contrast ratio that can be used for normal text.\n */\nexport const NORMAL_TEXT_CONTRAST_RATIO = 4.5;\n\n/**\n * The AAA contrast ratio for passing WGAC 2.0 color contrast ratios.\n */\nexport const AAA_CONTRAST_RATIO = 7;\n\n/**\n * Checks if there is an acceptable contrast ratio between the background and\n * foreground colors based on the provided compliance level.\n *\n * @param background - The background color to check against\n * @param foreground - The foreground color to check against\n * @param compliance - The compliance level to use or a custom number as a\n * ratio.\n * @returns true if there is enough contrast between the foreground and\n * background colors for the provided compliance level.\n */\nexport function isContrastCompliant(\n background: string,\n foreground: string,\n compliance: ContrastRatioCompliance | number = \"normal\"\n): boolean {\n let ratio: number;\n switch (compliance) {\n case \"large\":\n ratio = LARGE_TEXT_CONTRAST_RATIO;\n break;\n case \"normal\":\n ratio = NORMAL_TEXT_CONTRAST_RATIO;\n break;\n case \"AAA\":\n ratio = AAA_CONTRAST_RATIO;\n break;\n default:\n ratio = compliance;\n }\n\n return getContrastRatio(background, foreground) >= ratio;\n}\n\n/**\n * Returns the highest contrast color to the provided `backgroundColor`. This is\n * normally used to ensure that a new background color can use an accessible text\n * color of either `#000` or `#fff`.\n *\n * This is pretty much a javascript implementation as the `contrast-color` Sass\n * function.\n *\n * @since 6.0.0\n */\nexport function contrastColor(\n backgroundColor: string,\n lightColor = white,\n darkColor = black\n): string {\n const lightContrast = getContrastRatio(backgroundColor, lightColor);\n const darkContrast = getContrastRatio(backgroundColor, darkColor);\n\n return lightContrast > darkContrast ? lightColor : darkColor;\n}\n"],"names":["black","white","RGB_REGEX","SHORTHAND_REGEX","VERBOSE_REGEX","hexToRGB","hex","process","env","NODE_ENV","test","TypeError","replace","_m","r","g","b","result","match","parseInt","getRGB","color","rgbMatches","RED_MULTIPLIER","GREEN_MULTIPLIER","BLUE_MULTIPLIER","get8BitColor","getLuminance","red","green","blue","getContrastRatio","background","foreground","backgroundLuminance","foregroundLuminance","Math","max","min","LARGE_TEXT_CONTRAST_RATIO","NORMAL_TEXT_CONTRAST_RATIO","AAA_CONTRAST_RATIO","isContrastCompliant","compliance","ratio","contrastColor","backgroundColor","lightColor","darkColor","lightContrast","darkContrast"],"mappings":"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"}
@@ -4,6 +4,8 @@
4
4
 
5
5
  @use "sass:map";
6
6
  @use "../utils";
7
+ @use "../border-radius";
8
+ @use "../spacing";
7
9
  @use "../theme/a11y";
8
10
  @use "../theme/colors";
9
11
  @use "../transition/transition";
@@ -69,27 +71,27 @@ $dense-typography: (
69
71
 
70
72
  /// The default `Tooltip` border radius.
71
73
  /// @type Number
72
- $border-radius: 0.25rem !default;
74
+ $border-radius: border-radius.get-var(xs) !default;
73
75
 
74
76
  /// The default `Tooltip` z-index.
75
77
  /// @type Number
76
78
  $z-index: utils.$temporary-element-z-index + 20 !default;
77
79
 
78
- /// The default `max-width` for a `Tooltip`>
80
+ /// The default `max-width` for a `Tooltip`.
79
81
  /// @type Number
80
82
  $max-width: 15rem !default;
81
83
 
82
- /// The default `min-height` for a `Tooltip`>
84
+ /// The default `min-height` for a `Tooltip`.
83
85
  /// @type Number
84
86
  $min-height: 2rem !default;
85
87
 
86
- /// The default horizontal padding for a `Tooltip`>
88
+ /// The default horizontal padding for a `Tooltip`.
87
89
  /// @type Number
88
- $horizontal-padding: 1rem !default;
90
+ $horizontal-padding: spacing.get-var(md) !default;
89
91
 
90
- /// The default vertical padding for a `Tooltip`>
92
+ /// The default vertical padding for a `Tooltip`
91
93
  /// @type Number
92
- $vertical-padding: 0.5625rem !default;
94
+ $vertical-padding: calc(spacing.get-var(sm) * 1.25) !default;
93
95
 
94
96
  /// The default spacing between a tooltipped element and the `Tooltip`.
95
97
  /// @type Number
@@ -105,11 +107,11 @@ $dense-min-height: 1.375rem !default;
105
107
 
106
108
  /// The default horizontal padding for a dense `Tooltip`.
107
109
  /// @type Number
108
- $dense-horizontal-padding: 0.5rem !default;
110
+ $dense-horizontal-padding: spacing.get-var(sm) !default;
109
111
 
110
112
  /// The default vertical padding for a dense `Tooltip`.
111
113
  /// @type Number
112
- $dense-vertical-padding: 0.375rem !default;
114
+ $dense-vertical-padding: calc(spacing.get-var(xs) * 1.25) !default;
113
115
 
114
116
  /// The default `Tooltip` enter transition duration.
115
117
  /// @type Number
@@ -127,9 +129,9 @@ $leave-duration: transition.$linear-duration !default;
127
129
  /// @type Number
128
130
  $leave-timing-function: transition.$acceleration-timing-function !default;
129
131
 
130
- /// The default `Tooltip` /nter/leave animation distance.
132
+ /// The default `Tooltip` enter/leave animation distance.
131
133
  /// @type Number
132
- $transition-distance: 0.5rem !default;
134
+ $transition-distance: spacing.get-var(sm) !default;
133
135
 
134
136
  /// The available configurable css variables and mostly used internally for the
135
137
  /// `get-var`, `set-var`, and `use-var` utils.
@@ -176,6 +178,22 @@ $variables: (
176
178
  /// @param {any} fallback [null] - An optional fallback value if the variable
177
179
  /// has not been set
178
180
  @mixin use-var($property, $name: $property, $fallback: null) {
181
+ @if not $fallback {
182
+ @if name == border-radius {
183
+ $fallbacK: $border-radius;
184
+ } @else if name == horizontal-padding {
185
+ $fallback: $horizontal-padding;
186
+ } @else if name == vertical-padding {
187
+ $fallback: $vertical-padding;
188
+ }
189
+ } @else if name == dense-horizontal-padding {
190
+ $fallback: $dense-horizontal-padding;
191
+ } @else if name == dense-vertical-padding {
192
+ $fallback: $dense-vertical-padding;
193
+ } @else if name == transition-distance {
194
+ $fallback: $transition-distance;
195
+ }
196
+
179
197
  #{$property}: get-var($name, $fallback);
180
198
  }
181
199
 
@@ -186,17 +204,11 @@ $variables: (
186
204
 
187
205
  @include set-var(background-color, $background-color);
188
206
  @include set-var(color, $color);
189
- @include set-var(border-radius, $border-radius);
190
- @include set-var(horizontal-padding, $horizontal-padding);
191
- @include set-var(vertical-padding, $vertical-padding);
192
207
  @include set-var(max-width, $max-width);
193
208
  @include set-var(min-height, $min-height);
194
- @include set-var(transition-distance, $transition-distance);
195
209
  @include set-var(z-index, $z-index);
196
210
 
197
211
  @if not $disable-dense {
198
- @include set-var(dense-horizontal-padding, $dense-horizontal-padding);
199
- @include set-var(dense-vertical-padding, $dense-vertical-padding);
200
212
  @include set-var(dense-min-height, $dense-min-height);
201
213
  }
202
214
  }
@@ -206,8 +218,14 @@ $variables: (
206
218
  @if not $disable-everything {
207
219
  @include set-var(spacing, $dense-spacing);
208
220
  @include set-var(min-height, get-var(dense-min-height));
209
- @include set-var(horizontal-padding, get-var(dense-horizontal-padding));
210
- @include set-var(vertical-padding, get-var(dense-vertical-padding));
221
+ @include set-var(
222
+ horizontal-padding,
223
+ get-var(dense-horizontal-padding, $dense-horizontal-padding)
224
+ );
225
+ @include set-var(
226
+ vertical-padding,
227
+ get-var(dense-vertical-padding, $dense-vertical-padding)
228
+ );
211
229
  }
212
230
  }
213
231
 
@@ -222,7 +240,7 @@ $variables: (
222
240
  @include utils.map-to-styles($typography);
223
241
  @include use-var(background-color);
224
242
  @include use-var(color);
225
- @include use-var(border-radius);
243
+ @include use-var(border-radius, $fallback: $border-radius);
226
244
  @include use-var(max-width);
227
245
  @include use-var(min-height);
228
246
  @include use-var(z-index);
@@ -230,7 +248,8 @@ $variables: (
230
248
  opacity: 0;
231
249
  overflow: hidden;
232
250
  overflow-wrap: anywhere;
233
- padding: get-var(vertical-padding) get-var(horizontal-padding);
251
+ padding: get-var(vertical-padding, $vertical-padding)
252
+ get-var(horizontal-padding, $horizontal-padding);
234
253
  pointer-events: none;
235
254
  position: fixed;
236
255
  text-transform: none;
@@ -246,28 +265,36 @@ $variables: (
246
265
  @if not $disable-above {
247
266
  &--above {
248
267
  transform: translateY(
249
- #{utils.negate-var(get-var(transition-distance))}
268
+ #{utils.negate-var(
269
+ get-var(transition-distance, $transition-distance)
270
+ )}
250
271
  );
251
272
  }
252
273
  }
253
274
 
254
275
  @if not $disable-below {
255
276
  &--below {
256
- transform: translateY(#{get-var(transition-distance)});
277
+ transform: translateY(
278
+ #{get-var(transition-distance, $transition-distance)}
279
+ );
257
280
  }
258
281
  }
259
282
 
260
283
  @if not $disable-left {
261
284
  &--left {
262
285
  transform: translateX(
263
- #{utils.negate-var(get-var(transition-distance))}
286
+ #{utils.negate-var(
287
+ get-var(transition-distance, $transition-distance)
288
+ )}
264
289
  );
265
290
  }
266
291
  }
267
292
 
268
293
  @if not $disable-right {
269
294
  &--right {
270
- transform: translateX(#{get-var(transition-distance)});
295
+ transform: translateX(
296
+ #{get-var(transition-distance, $transition-distance)}
297
+ );
271
298
  }
272
299
  }
273
300
 
@@ -5,6 +5,7 @@
5
5
  @use "sass:color";
6
6
  @use "sass:map";
7
7
  @use "../utils";
8
+ @use "../border-radius";
8
9
  @use "../theme/colors";
9
10
  @use "../theme/theme";
10
11
 
@@ -112,7 +113,7 @@ $skeleton-placeholder-width: 43% !default;
112
113
 
113
114
  /// The default skeleton placeholder border-radius.
114
115
  /// @type Number
115
- $skeleton-placeholder-border-radius: 0.25rem !default;
116
+ $skeleton-placeholder-border-radius: border-radius.get-var(xs) !default;
116
117
 
117
118
  /// The default light theme skeleton placeholder background color.
118
119
  /// @type Color
@@ -43,7 +43,7 @@ $item-padding-base: list.$item-horizontal-padding !default;
43
43
  ///
44
44
  /// @see $item-padding
45
45
  /// @type Number
46
- $item-padding-incrementor: list.$item-horizontal-padding * 1.5 !default;
46
+ $item-padding-incrementor: calc(list.$item-horizontal-padding * 1.5) !default;
47
47
 
48
48
  /// The default `TreeItemExpander` rotation starting position when rendered as
49
49
  /// a `rightAddon`.
package/dist/utils/bem.js CHANGED
@@ -5,7 +5,7 @@ function modify(base, modifier) {
5
5
  const hasOwn = Object.prototype.hasOwnProperty;
6
6
  return Object.keys(modifier).reduce((s, mod)=>{
7
7
  if (hasOwn.call(modifier, mod) && modifier[mod]) {
8
- s = `${s} ${base}--${mod}`;
8
+ return `${s} ${base}--${mod}`;
9
9
  }
10
10
  return s;
11
11
  }, base);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/bem.ts"],"sourcesContent":["export type BEMModifier = Record<string, unknown>;\n\nfunction modify(base: string, modifier?: BEMModifier): string {\n if (!modifier) {\n return base;\n }\n\n const hasOwn = Object.prototype.hasOwnProperty;\n return Object.keys(modifier).reduce((s, mod) => {\n if (hasOwn.call(modifier, mod) && modifier[mod]) {\n s = `${s} ${base}--${mod}`;\n }\n\n return s;\n }, base);\n}\n\n/**\n * Creates the full class name from the base block name. This can be called\n * without any arguments which will just return the base block name (kind of\n * worthless), or you can provide a child element name and modifiers.\n *\n * @since 6.0.0 Converted to an interface that supports the `base` attribute.\n */\nexport interface BEMResult {\n /**\n * @example Simple Example\n * ```ts\n * const styles = bem(\"root\");\n *\n * styles(\"child\"); // \"root__child\"\n * styles(\"child\", {\n * modifier1: true,\n * modifier2: false,\n * }); // \"root__child root__child--modifier-1\"\n * ```\n * @param element - The child element to be prefixed before any modifiers.\n * @param modifier - Any optional modifiers to apply to the block and optional\n * element.\n * @returns the full class name\n */\n (element: string, modifier?: BEMModifier): string;\n\n /**\n * @example Simple Example\n * ```ts\n * const styles = bem(\"root\");\n *\n * styles() // \"root\"\n * styles({\n * modifier1: true,\n * modifier2: false,\n * }); // \"root--modifier-1\"\n * ```\n * @param modifier - Any optional modifiers to apply to the block and optional\n * element.\n * @returns the full class name\n */\n (modifier?: BEMModifier): string;\n\n /**\n * The base class name\n */\n base: string;\n}\n\n/**\n * Applies the BEM styled class name to an element.\n *\n * @example Simple Example\n * ```tsx\n * import { bem } from \"@react-md/core/utils/bem\":\n *\n * const styles = bem(\"my-component\"):\n *\n * export function MyComponent(props) {\n * const className = styles({\n * always: true,\n * never: false,\n * \"some-condition\": props.something,\n * }):\n * const childClassName = styles('child', {\n * always: true,\n * never: false,\n * \"some-condition\": props.something,\n * });\n *\n * // With a false-like `props.something`\n * // className === \"my-component__child my-component__child--always\"\n * // childClassName === \"my-component my-component--always\"\n * // With a truthy `props.something`\n * // className === \"my-component my-component--always my-component--some-condition\"\n * // childClassName === \"my-component__child my-component__child--always my-component__child--some-condition\"\n *\n * return (\n * <div className={className}>\n * <div className={childClassName} />\n * </div>\n * ):\n * }\n * ```\n *\n * @see https://en.bem.info/methodology/css/\n * @param base - The base class to use\n * @returns a function to call that generates the full class name\n */\nexport function bem(base: string): BEMResult {\n if (process.env.NODE_ENV !== \"production\") {\n if (!base) {\n throw new Error(\n \"bem requires a base block class but none were provided.\"\n );\n }\n }\n\n function block(\n elementOrModifier?: BEMModifier | string,\n modifier?: BEMModifier\n ): string {\n if (process.env.NODE_ENV !== \"production\") {\n if (typeof elementOrModifier !== \"string\" && modifier) {\n throw new TypeError(\n \"bem does not support having two modifier arguments.\"\n );\n }\n }\n\n if (!elementOrModifier) {\n return base;\n }\n\n if (typeof elementOrModifier !== \"string\") {\n return modify(base, elementOrModifier);\n }\n\n return modify(`${base}__${elementOrModifier}`, modifier);\n }\n block.base = base;\n return block;\n}\n"],"names":["modify","base","modifier","hasOwn","Object","prototype","hasOwnProperty","keys","reduce","s","mod","call","bem","process","env","NODE_ENV","Error","block","elementOrModifier","TypeError"],"mappings":"AAEA,SAASA,OAAOC,IAAY,EAAEC,QAAsB;IAClD,IAAI,CAACA,UAAU;QACb,OAAOD;IACT;IAEA,MAAME,SAASC,OAAOC,SAAS,CAACC,cAAc;IAC9C,OAAOF,OAAOG,IAAI,CAACL,UAAUM,MAAM,CAAC,CAACC,GAAGC;QACtC,IAAIP,OAAOQ,IAAI,CAACT,UAAUQ,QAAQR,QAAQ,CAACQ,IAAI,EAAE;YAC/CD,IAAI,GAAGA,EAAE,CAAC,EAAER,KAAK,EAAE,EAAES,KAAK;QAC5B;QAEA,OAAOD;IACT,GAAGR;AACL;AAmDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCC,GACD,OAAO,SAASW,IAAIX,IAAY;IAC9B,IAAIY,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,IAAI,CAACd,MAAM;YACT,MAAM,IAAIe,MACR;QAEJ;IACF;IAEA,SAASC,MACPC,iBAAwC,EACxChB,QAAsB;QAEtB,IAAIW,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;YACzC,IAAI,OAAOG,sBAAsB,YAAYhB,UAAU;gBACrD,MAAM,IAAIiB,UACR;YAEJ;QACF;QAEA,IAAI,CAACD,mBAAmB;YACtB,OAAOjB;QACT;QAEA,IAAI,OAAOiB,sBAAsB,UAAU;YACzC,OAAOlB,OAAOC,MAAMiB;QACtB;QAEA,OAAOlB,OAAO,GAAGC,KAAK,EAAE,EAAEiB,mBAAmB,EAAEhB;IACjD;IACAe,MAAMhB,IAAI,GAAGA;IACb,OAAOgB;AACT"}
1
+ {"version":3,"sources":["../../src/utils/bem.ts"],"sourcesContent":["export type BEMModifier = Record<string, unknown>;\n\nfunction modify(base: string, modifier?: BEMModifier): string {\n if (!modifier) {\n return base;\n }\n\n const hasOwn = Object.prototype.hasOwnProperty;\n return Object.keys(modifier).reduce((s, mod) => {\n if (hasOwn.call(modifier, mod) && modifier[mod]) {\n return `${s} ${base}--${mod}`;\n }\n\n return s;\n }, base);\n}\n\n/**\n * Creates the full class name from the base block name. This can be called\n * without any arguments which will just return the base block name (kind of\n * worthless), or you can provide a child element name and modifiers.\n *\n * @since 6.0.0 Converted to an interface that supports the `base` attribute.\n */\nexport interface BEMResult {\n /**\n * @example Simple Example\n * ```ts\n * const styles = bem(\"root\");\n *\n * styles(\"child\"); // \"root__child\"\n * styles(\"child\", {\n * modifier1: true,\n * modifier2: false,\n * }); // \"root__child root__child--modifier-1\"\n * ```\n * @param element - The child element to be prefixed before any modifiers.\n * @param modifier - Any optional modifiers to apply to the block and optional\n * element.\n * @returns the full class name\n */\n (element: string, modifier?: BEMModifier): string;\n\n /**\n * @example Simple Example\n * ```ts\n * const styles = bem(\"root\");\n *\n * styles() // \"root\"\n * styles({\n * modifier1: true,\n * modifier2: false,\n * }); // \"root--modifier-1\"\n * ```\n * @param modifier - Any optional modifiers to apply to the block and optional\n * element.\n * @returns the full class name\n */\n (modifier?: BEMModifier): string;\n\n /**\n * The base class name\n */\n base: string;\n}\n\n/**\n * Applies the BEM styled class name to an element.\n *\n * @example Simple Example\n * ```tsx\n * import { bem } from \"@react-md/core/utils/bem\":\n *\n * const styles = bem(\"my-component\"):\n *\n * export function MyComponent(props) {\n * const className = styles({\n * always: true,\n * never: false,\n * \"some-condition\": props.something,\n * }):\n * const childClassName = styles('child', {\n * always: true,\n * never: false,\n * \"some-condition\": props.something,\n * });\n *\n * // With a false-like `props.something`\n * // className === \"my-component__child my-component__child--always\"\n * // childClassName === \"my-component my-component--always\"\n * // With a truthy `props.something`\n * // className === \"my-component my-component--always my-component--some-condition\"\n * // childClassName === \"my-component__child my-component__child--always my-component__child--some-condition\"\n *\n * return (\n * <div className={className}>\n * <div className={childClassName} />\n * </div>\n * ):\n * }\n * ```\n *\n * @see https://en.bem.info/methodology/css/\n * @param base - The base class to use\n * @returns a function to call that generates the full class name\n */\nexport function bem(base: string): BEMResult {\n if (process.env.NODE_ENV !== \"production\") {\n if (!base) {\n throw new Error(\n \"bem requires a base block class but none were provided.\"\n );\n }\n }\n\n function block(\n elementOrModifier?: BEMModifier | string,\n modifier?: BEMModifier\n ): string {\n if (process.env.NODE_ENV !== \"production\") {\n if (typeof elementOrModifier !== \"string\" && modifier) {\n throw new TypeError(\n \"bem does not support having two modifier arguments.\"\n );\n }\n }\n\n if (!elementOrModifier) {\n return base;\n }\n\n if (typeof elementOrModifier !== \"string\") {\n return modify(base, elementOrModifier);\n }\n\n return modify(`${base}__${elementOrModifier}`, modifier);\n }\n block.base = base;\n return block;\n}\n"],"names":["modify","base","modifier","hasOwn","Object","prototype","hasOwnProperty","keys","reduce","s","mod","call","bem","process","env","NODE_ENV","Error","block","elementOrModifier","TypeError"],"mappings":"AAEA,SAASA,OAAOC,IAAY,EAAEC,QAAsB;IAClD,IAAI,CAACA,UAAU;QACb,OAAOD;IACT;IAEA,MAAME,SAASC,OAAOC,SAAS,CAACC,cAAc;IAC9C,OAAOF,OAAOG,IAAI,CAACL,UAAUM,MAAM,CAAC,CAACC,GAAGC;QACtC,IAAIP,OAAOQ,IAAI,CAACT,UAAUQ,QAAQR,QAAQ,CAACQ,IAAI,EAAE;YAC/C,OAAO,GAAGD,EAAE,CAAC,EAAER,KAAK,EAAE,EAAES,KAAK;QAC/B;QAEA,OAAOD;IACT,GAAGR;AACL;AAmDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCC,GACD,OAAO,SAASW,IAAIX,IAAY;IAC9B,IAAIY,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,IAAI,CAACd,MAAM;YACT,MAAM,IAAIe,MACR;QAEJ;IACF;IAEA,SAASC,MACPC,iBAAwC,EACxChB,QAAsB;QAEtB,IAAIW,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;YACzC,IAAI,OAAOG,sBAAsB,YAAYhB,UAAU;gBACrD,MAAM,IAAIiB,UACR;YAEJ;QACF;QAEA,IAAI,CAACD,mBAAmB;YACtB,OAAOjB;QACT;QAEA,IAAI,OAAOiB,sBAAsB,UAAU;YACzC,OAAOlB,OAAOC,MAAMiB;QACtB;QAEA,OAAOlB,OAAO,GAAGC,KAAK,EAAE,EAAEiB,mBAAmB,EAAEhB;IACjD;IACAe,MAAMhB,IAAI,GAAGA;IACb,OAAOgB;AACT"}
@@ -22,6 +22,9 @@
22
22
  if (typeof value === "number") {
23
23
  return value;
24
24
  }
25
+ if (value.includes("calc")) {
26
+ throw new Error(`Unable to parse a unit with \`calc\`: "${value}"`);
27
+ }
25
28
  const parsed = parseFloat(value);
26
29
  if (/px$/i.test(value)) {
27
30
  return parsed;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/parseCssLengthUnit.ts"],"sourcesContent":["/** @internal */\nexport interface ParseCssLengthUnitOptions {\n /**\n * The css unit to convert to a numeric value.\n */\n value: number | string;\n\n /**\n * @defaultValue `16`\n */\n fallbackFontSize?: number;\n\n /**\n * @defaultValue `document.documentElement`\n */\n container?: Element | null;\n}\n\n/**\n * This is used to convert CSS length units into a number. At this time, it really only supports\n * - `px`\n * - `rem`\n * - `em` (if {@link ParseCssLengthUnitOptions.container} is provided)\n *\n * @example Simple Example\n * ```ts\n * parseCssLengthUnit({ value: \"24px\" }) // 24\n * parseCssLengthUnit({ value: \"3.5rem\" }) // 56\n * parseCssLengthUnit({\n * value: \"3em\",\n * container: document.querySelector(SOME_QUERY),\n * }); // container's computed fontSize * 3\n * ```\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units#lengths}\n * @internal\n * @since 6.0.0 This was renamed from `unitToNumber`\n */\nexport function parseCssLengthUnit(options: ParseCssLengthUnitOptions): number {\n const { value, container, fallbackFontSize = 16 } = options;\n\n if (typeof value === \"number\") {\n return value;\n }\n\n const parsed = parseFloat(value);\n if (/px$/i.test(value)) {\n return parsed;\n }\n\n if (typeof window === \"undefined\") {\n return parsed * fallbackFontSize;\n }\n\n const styleContainer =\n !container || /rem$/i.test(value) ? document.documentElement : container;\n\n const fontSize = parseFloat(\n window.getComputedStyle(styleContainer).fontSize || `${fallbackFontSize}px`\n );\n\n return parsed * fontSize;\n}\n"],"names":["parseCssLengthUnit","options","value","container","fallbackFontSize","parsed","parseFloat","test","window","styleContainer","document","documentElement","fontSize","getComputedStyle"],"mappings":"AAAA,cAAc,GAkBd;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,SAASA,mBAAmBC,OAAkC;IACnE,MAAM,EAAEC,KAAK,EAAEC,SAAS,EAAEC,mBAAmB,EAAE,EAAE,GAAGH;IAEpD,IAAI,OAAOC,UAAU,UAAU;QAC7B,OAAOA;IACT;IAEA,MAAMG,SAASC,WAAWJ;IAC1B,IAAI,OAAOK,IAAI,CAACL,QAAQ;QACtB,OAAOG;IACT;IAEA,IAAI,OAAOG,WAAW,aAAa;QACjC,OAAOH,SAASD;IAClB;IAEA,MAAMK,iBACJ,CAACN,aAAa,QAAQI,IAAI,CAACL,SAASQ,SAASC,eAAe,GAAGR;IAEjE,MAAMS,WAAWN,WACfE,OAAOK,gBAAgB,CAACJ,gBAAgBG,QAAQ,IAAI,GAAGR,iBAAiB,EAAE,CAAC;IAG7E,OAAOC,SAASO;AAClB"}
1
+ {"version":3,"sources":["../../src/utils/parseCssLengthUnit.ts"],"sourcesContent":["/** @internal */\nexport interface ParseCssLengthUnitOptions {\n /**\n * The css unit to convert to a numeric value.\n */\n value: number | string;\n\n /**\n * @defaultValue `16`\n */\n fallbackFontSize?: number;\n\n /**\n * @defaultValue `document.documentElement`\n */\n container?: Element | null;\n}\n\n/**\n * This is used to convert CSS length units into a number. At this time, it really only supports\n * - `px`\n * - `rem`\n * - `em` (if {@link ParseCssLengthUnitOptions.container} is provided)\n *\n * @example Simple Example\n * ```ts\n * parseCssLengthUnit({ value: \"24px\" }) // 24\n * parseCssLengthUnit({ value: \"3.5rem\" }) // 56\n * parseCssLengthUnit({\n * value: \"3em\",\n * container: document.querySelector(SOME_QUERY),\n * }); // container's computed fontSize * 3\n * ```\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units#lengths}\n * @internal\n * @since 6.0.0 This was renamed from `unitToNumber`\n */\nexport function parseCssLengthUnit(options: ParseCssLengthUnitOptions): number {\n const { value, container, fallbackFontSize = 16 } = options;\n\n if (typeof value === \"number\") {\n return value;\n }\n\n if (value.includes(\"calc\")) {\n throw new Error(`Unable to parse a unit with \\`calc\\`: \"${value}\"`);\n }\n\n const parsed = parseFloat(value);\n if (/px$/i.test(value)) {\n return parsed;\n }\n\n if (typeof window === \"undefined\") {\n return parsed * fallbackFontSize;\n }\n\n const styleContainer =\n !container || /rem$/i.test(value) ? document.documentElement : container;\n\n const fontSize = parseFloat(\n window.getComputedStyle(styleContainer).fontSize || `${fallbackFontSize}px`\n );\n\n return parsed * fontSize;\n}\n"],"names":["parseCssLengthUnit","options","value","container","fallbackFontSize","includes","Error","parsed","parseFloat","test","window","styleContainer","document","documentElement","fontSize","getComputedStyle"],"mappings":"AAAA,cAAc,GAkBd;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,SAASA,mBAAmBC,OAAkC;IACnE,MAAM,EAAEC,KAAK,EAAEC,SAAS,EAAEC,mBAAmB,EAAE,EAAE,GAAGH;IAEpD,IAAI,OAAOC,UAAU,UAAU;QAC7B,OAAOA;IACT;IAEA,IAAIA,MAAMG,QAAQ,CAAC,SAAS;QAC1B,MAAM,IAAIC,MAAM,CAAC,uCAAuC,EAAEJ,MAAM,CAAC,CAAC;IACpE;IAEA,MAAMK,SAASC,WAAWN;IAC1B,IAAI,OAAOO,IAAI,CAACP,QAAQ;QACtB,OAAOK;IACT;IAEA,IAAI,OAAOG,WAAW,aAAa;QACjC,OAAOH,SAASH;IAClB;IAEA,MAAMO,iBACJ,CAACR,aAAa,QAAQM,IAAI,CAACP,SAASU,SAASC,eAAe,GAAGV;IAEjE,MAAMW,WAAWN,WACfE,OAAOK,gBAAgB,CAACJ,gBAAgBG,QAAQ,IAAI,GAAGV,iBAAiB,EAAE,CAAC;IAG7E,OAAOG,SAASO;AAClB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-md/core",
3
- "version": "6.0.2",
3
+ "version": "6.1.0",
4
4
  "description": "The core components and functionality for react-md.",
5
5
  "type": "module",
6
6
  "sass": "./dist/_core.scss",
@@ -82,21 +82,21 @@
82
82
  "@jest/globals": "^29.7.0",
83
83
  "@jest/types": "^29.6.3",
84
84
  "@microsoft/api-extractor": "^7.52.8",
85
- "@mlaursen/eslint-config": "^8.0.0",
85
+ "@mlaursen/eslint-config": "^8.0.1",
86
86
  "@swc/cli": "^0.6.0",
87
- "@swc/core": "^1.11.22",
87
+ "@swc/core": "^1.11.29",
88
88
  "@swc/jest": "^0.2.38",
89
89
  "@testing-library/dom": "^10.4.0",
90
90
  "@testing-library/jest-dom": "^6.6.3",
91
91
  "@testing-library/react": "^16.3.0",
92
92
  "@testing-library/user-event": "^14.6.1",
93
93
  "@trivago/prettier-plugin-sort-imports": "^5.2.2",
94
- "@types/lodash": "^4.17.16",
95
- "@types/node": "^22.15.18",
94
+ "@types/lodash": "^4.17.17",
95
+ "@types/node": "^22.15.29",
96
96
  "@types/react": "^18.3.12",
97
97
  "@types/react-dom": "^18.3.1",
98
98
  "chokidar": "^4.0.3",
99
- "eslint": "^9.26.0",
99
+ "eslint": "^9.28.0",
100
100
  "filesize": "^10.1.6",
101
101
  "glob": "11.0.2",
102
102
  "jest": "^29.7.0",
@@ -106,16 +106,16 @@
106
106
  "lz-string": "^1.5.0",
107
107
  "npm-run-all": "^4.1.5",
108
108
  "prettier": "^3.5.3",
109
- "stylelint": "^16.19.1",
109
+ "stylelint": "^16.20.0",
110
110
  "stylelint-config-prettier-scss": "^1.0.0",
111
- "stylelint-config-recommended-scss": "^15.0.0",
111
+ "stylelint-config-recommended-scss": "^15.0.1",
112
112
  "stylelint-order": "^7.0.0",
113
113
  "stylelint-scss": "^6.12.0",
114
- "ts-morph": "^25.0.1",
114
+ "ts-morph": "^26.0.0",
115
115
  "ts-node": "^10.9.2",
116
116
  "tsx": "^4.19.4",
117
117
  "typescript": "^5.8.3",
118
- "vitest": "^3.1.3"
118
+ "vitest": "^3.1.4"
119
119
  },
120
120
  "peerDependencies": {
121
121
  "@jest/globals": "^29.7.0",
@@ -199,7 +199,7 @@ export function appBarTitle(options: AppBarTitleClassNameOptions = {}): string {
199
199
  const { className, keyline = "small" } = options;
200
200
  return cnb(
201
201
  titleStyles({
202
- keyline: keyline == "list",
202
+ keyline: keyline === "list",
203
203
  "nav-keyline": keyline === "nav",
204
204
  }),
205
205
  className
@@ -264,7 +264,7 @@ export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
264
264
  "--rmd-text-area-height": height,
265
265
  }}
266
266
  className={textAreaContainer({
267
- animate: !disableTransition && resize == "auto",
267
+ animate: !disableTransition && resize === "auto",
268
268
  disabled,
269
269
  height: !!height,
270
270
  underlineLabelled:
package/src/form/utils.ts CHANGED
@@ -38,6 +38,7 @@ export function tryToSubmitRelatedForm<E extends HTMLElement>(
38
38
  return;
39
39
  }
40
40
 
41
+ // eslint-disable-next-line no-param-reassign
41
42
  formId = formId || form.id;
42
43
  let submit = form.querySelector<HTMLButtonElement>('[type="submit"]');
43
44
  if (!submit && formId) {
@@ -249,7 +249,7 @@ export function useElementInteraction<E extends HTMLElement>(
249
249
  const { pressed } = state;
250
250
 
251
251
  let ripples: ReactElement | undefined;
252
- if (mode == "ripple") {
252
+ if (mode === "ripple") {
253
253
  ripples = (
254
254
  <RippleContainer
255
255
  ripples={state.ripples}
@@ -140,7 +140,7 @@ export const LayoutNav = forwardRef<HTMLDivElement, LayoutNavProps>(
140
140
  const {
141
141
  as: Component = "nav",
142
142
  "aria-labelledby": ariaLabelledBy,
143
- "aria-label": ariaLabel = Component == "nav" && !ariaLabelledBy
143
+ "aria-label": ariaLabel = Component === "nav" && !ariaLabelledBy
144
144
  ? "Navigation"
145
145
  : undefined,
146
146
  expanded,
@@ -11,6 +11,7 @@ import { useUserInteractionMode } from "../interaction/UserInteractionModeProvid
11
11
  export function useMainTabIndex(tabIndex?: number): number | undefined {
12
12
  const keyboard = useUserInteractionMode() === "keyboard";
13
13
  if (keyboard && typeof tabIndex === "undefined") {
14
+ // eslint-disable-next-line no-param-reassign
14
15
  tabIndex = -1;
15
16
  }
16
17
 
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-param-reassign */
1
2
  import { black, white } from "./colors.js";
2
3
 
3
4
  const RGB_REGEX = /^rgb\(((\b([01]?\d\d?|2[0-4]\d|25[0-5])\b),?){3}\)$/;
@@ -37,7 +38,7 @@ export function hexToRGB(hex: string): RGB {
37
38
 
38
39
  export function getRGB(color: string): RGB {
39
40
  // chrome 102.0.50005.63 apparently has whitespace when calling `window.getComputedStyle(element)`
40
- // remove whitepsace to make it easy for supporting rgb or hex
41
+ // remove whitespace to make it easy for supporting rgb or hex
41
42
  color = color.replace(/\s/g, "");
42
43
  const rgbMatches = color.match(RGB_REGEX);
43
44
  if (rgbMatches) {
package/src/utils/bem.ts CHANGED
@@ -8,7 +8,7 @@ function modify(base: string, modifier?: BEMModifier): string {
8
8
  const hasOwn = Object.prototype.hasOwnProperty;
9
9
  return Object.keys(modifier).reduce((s, mod) => {
10
10
  if (hasOwn.call(modifier, mod) && modifier[mod]) {
11
- s = `${s} ${base}--${mod}`;
11
+ return `${s} ${base}--${mod}`;
12
12
  }
13
13
 
14
14
  return s;
@@ -43,6 +43,10 @@ export function parseCssLengthUnit(options: ParseCssLengthUnitOptions): number {
43
43
  return value;
44
44
  }
45
45
 
46
+ if (value.includes("calc")) {
47
+ throw new Error(`Unable to parse a unit with \`calc\`: "${value}"`);
48
+ }
49
+
46
50
  const parsed = parseFloat(value);
47
51
  if (/px$/i.test(value)) {
48
52
  return parsed;