@react-md/core 6.1.0 → 6.2.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 (168) hide show
  1. package/dist/RootHtml.d.ts +1 -1
  2. package/dist/RootHtml.js.map +1 -1
  3. package/dist/autocomplete/defaults.d.ts +1 -0
  4. package/dist/autocomplete/defaults.js +2 -6
  5. package/dist/autocomplete/defaults.js.map +1 -1
  6. package/dist/autocomplete/types.d.ts +9 -9
  7. package/dist/autocomplete/types.js.map +1 -1
  8. package/dist/avatar/Avatar.d.ts +1 -1
  9. package/dist/avatar/Avatar.js +1 -1
  10. package/dist/avatar/Avatar.js.map +1 -1
  11. package/dist/avatar/styles.d.ts +29 -1
  12. package/dist/avatar/styles.js.map +1 -1
  13. package/dist/box/styles.d.ts +26 -3
  14. package/dist/box/styles.js.map +1 -1
  15. package/dist/button/AsyncButton.d.ts +2 -2
  16. package/dist/button/AsyncButton.js.map +1 -1
  17. package/dist/button/Button.d.ts +1 -1
  18. package/dist/button/Button.js.map +1 -1
  19. package/dist/card/CardHeader.d.ts +1 -1
  20. package/dist/card/CardHeader.js.map +1 -1
  21. package/dist/chip/Chip.d.ts +1 -1
  22. package/dist/chip/Chip.js.map +1 -1
  23. package/dist/dialog/Dialog.d.ts +1 -1
  24. package/dist/dialog/Dialog.js.map +1 -1
  25. package/dist/expansion-panel/ExpansionPanel.d.ts +1 -1
  26. package/dist/expansion-panel/ExpansionPanel.js.map +1 -1
  27. package/dist/expansion-panel/ExpansionPanelHeader.d.ts +1 -1
  28. package/dist/expansion-panel/ExpansionPanelHeader.js.map +1 -1
  29. package/dist/files/FileInput.d.ts +1 -1
  30. package/dist/files/FileInput.js.map +1 -1
  31. package/dist/form/FormMessageContainer.d.ts +1 -1
  32. package/dist/form/FormMessageContainer.js.map +1 -1
  33. package/dist/form/InputToggle.d.ts +2 -2
  34. package/dist/form/InputToggle.js.map +1 -1
  35. package/dist/form/NativeSelect.d.ts +1 -1
  36. package/dist/form/NativeSelect.js.map +1 -1
  37. package/dist/form/OptGroup.d.ts +1 -1
  38. package/dist/form/OptGroup.js.map +1 -1
  39. package/dist/form/Password.d.ts +1 -1
  40. package/dist/form/Password.js.map +1 -1
  41. package/dist/form/Select.d.ts +2 -2
  42. package/dist/form/Select.js.map +1 -1
  43. package/dist/form/Slider.d.ts +1 -1
  44. package/dist/form/Slider.js.map +1 -1
  45. package/dist/form/Switch.d.ts +3 -3
  46. package/dist/form/Switch.js.map +1 -1
  47. package/dist/form/SwitchTrack.d.ts +1 -1
  48. package/dist/form/SwitchTrack.js.map +1 -1
  49. package/dist/form/TextArea.d.ts +2 -2
  50. package/dist/form/TextArea.js.map +1 -1
  51. package/dist/form/TextField.d.ts +1 -1
  52. package/dist/form/TextField.js.map +1 -1
  53. package/dist/form/types.d.ts +5 -5
  54. package/dist/form/types.js.map +1 -1
  55. package/dist/layout/LayoutAppBar.d.ts +1 -1
  56. package/dist/layout/LayoutAppBar.js.map +1 -1
  57. package/dist/list/ListItemLink.d.ts +1 -1
  58. package/dist/list/ListItemLink.js.map +1 -1
  59. package/dist/list/ListItemText.d.ts +1 -1
  60. package/dist/list/ListItemText.js.map +1 -1
  61. package/dist/list/ListSubheader.d.ts +1 -1
  62. package/dist/list/ListSubheader.js.map +1 -1
  63. package/dist/list/types.d.ts +2 -2
  64. package/dist/list/types.js.map +1 -1
  65. package/dist/menu/Menu.d.ts +3 -3
  66. package/dist/menu/Menu.js.map +1 -1
  67. package/dist/menu/MenuItemInputToggle.d.ts +2 -2
  68. package/dist/menu/MenuItemInputToggle.js.map +1 -1
  69. package/dist/menu/MenuItemTextField.d.ts +1 -1
  70. package/dist/menu/MenuItemTextField.js.map +1 -1
  71. package/dist/menu/MenuSheet.d.ts +1 -1
  72. package/dist/menu/MenuSheet.js.map +1 -1
  73. package/dist/navigation/CollapsibleNavGroup.d.ts +2 -2
  74. package/dist/navigation/CollapsibleNavGroup.js.map +1 -1
  75. package/dist/navigation/NavItemLink.d.ts +1 -1
  76. package/dist/navigation/NavItemLink.js.map +1 -1
  77. package/dist/progress/CircularProgress.d.ts +2 -17
  78. package/dist/progress/CircularProgress.js +19 -23
  79. package/dist/progress/CircularProgress.js.map +1 -1
  80. package/dist/progress/LinearProgress.d.ts +5 -1
  81. package/dist/progress/LinearProgress.js +13 -25
  82. package/dist/progress/LinearProgress.js.map +1 -1
  83. package/dist/progress/circularProgressStyles.d.ts +62 -0
  84. package/dist/progress/circularProgressStyles.js +38 -0
  85. package/dist/progress/circularProgressStyles.js.map +1 -0
  86. package/dist/progress/linearProgressStyles.d.ts +38 -0
  87. package/dist/progress/linearProgressStyles.js +38 -0
  88. package/dist/progress/linearProgressStyles.js.map +1 -0
  89. package/dist/searching/caseInsensitive.d.ts +20 -4
  90. package/dist/searching/caseInsensitive.js +5 -1
  91. package/dist/searching/caseInsensitive.js.map +1 -1
  92. package/dist/searching/fuzzy.d.ts +3 -3
  93. package/dist/searching/fuzzy.js +5 -1
  94. package/dist/searching/fuzzy.js.map +1 -1
  95. package/dist/searching/utils.d.ts +2 -1
  96. package/dist/searching/utils.js +11 -2
  97. package/dist/searching/utils.js.map +1 -1
  98. package/dist/snackbar/Toast.d.ts +1 -1
  99. package/dist/snackbar/Toast.js.map +1 -1
  100. package/dist/table/TableCell.d.ts +1 -1
  101. package/dist/table/TableCell.js.map +1 -1
  102. package/dist/table/TableCheckbox.d.ts +1 -1
  103. package/dist/table/TableCheckbox.js.map +1 -1
  104. package/dist/table/TableRadio.d.ts +1 -1
  105. package/dist/table/TableRadio.js.map +1 -1
  106. package/dist/tabs/TabListScrollButton.d.ts +1 -1
  107. package/dist/tabs/TabListScrollButton.js.map +1 -1
  108. package/dist/tree/TreeItem.d.ts +2 -2
  109. package/dist/tree/TreeItem.js.map +1 -1
  110. package/dist/types.d.ts +29 -2
  111. package/dist/types.js +1 -1
  112. package/dist/types.js.map +1 -1
  113. package/dist/utils/alphaNumericSort.d.ts +9 -9
  114. package/dist/utils/alphaNumericSort.js +5 -1
  115. package/dist/utils/alphaNumericSort.js.map +1 -1
  116. package/package.json +6 -6
  117. package/src/RootHtml.tsx +1 -1
  118. package/src/autocomplete/defaults.ts +5 -12
  119. package/src/autocomplete/types.ts +9 -12
  120. package/src/avatar/Avatar.tsx +2 -2
  121. package/src/avatar/styles.ts +53 -1
  122. package/src/box/styles.ts +34 -13
  123. package/src/button/AsyncButton.tsx +2 -2
  124. package/src/button/Button.tsx +1 -1
  125. package/src/card/CardHeader.tsx +1 -1
  126. package/src/chip/Chip.tsx +1 -1
  127. package/src/dialog/Dialog.tsx +1 -4
  128. package/src/expansion-panel/ExpansionPanel.tsx +1 -1
  129. package/src/expansion-panel/ExpansionPanelHeader.tsx +1 -1
  130. package/src/files/FileInput.tsx +1 -4
  131. package/src/form/FormMessageContainer.tsx +1 -1
  132. package/src/form/InputToggle.tsx +2 -5
  133. package/src/form/NativeSelect.tsx +1 -1
  134. package/src/form/OptGroup.tsx +1 -4
  135. package/src/form/Password.tsx +1 -1
  136. package/src/form/Select.tsx +2 -3
  137. package/src/form/Slider.tsx +1 -1
  138. package/src/form/Switch.tsx +3 -3
  139. package/src/form/SwitchTrack.tsx +1 -1
  140. package/src/form/TextArea.tsx +2 -5
  141. package/src/form/TextField.tsx +1 -1
  142. package/src/form/types.ts +5 -15
  143. package/src/layout/LayoutAppBar.tsx +1 -1
  144. package/src/list/ListItemLink.tsx +1 -1
  145. package/src/list/ListItemText.tsx +1 -4
  146. package/src/list/ListSubheader.tsx +1 -1
  147. package/src/list/types.ts +2 -5
  148. package/src/menu/Menu.tsx +3 -4
  149. package/src/menu/MenuItemInputToggle.tsx +2 -2
  150. package/src/menu/MenuItemTextField.tsx +1 -1
  151. package/src/menu/MenuSheet.tsx +1 -1
  152. package/src/navigation/CollapsibleNavGroup.tsx +2 -2
  153. package/src/navigation/NavItemLink.tsx +1 -1
  154. package/src/progress/CircularProgress.tsx +31 -53
  155. package/src/progress/LinearProgress.tsx +27 -40
  156. package/src/progress/circularProgressStyles.ts +114 -0
  157. package/src/progress/linearProgressStyles.ts +90 -0
  158. package/src/searching/caseInsensitive.ts +29 -7
  159. package/src/searching/fuzzy.ts +12 -6
  160. package/src/searching/utils.ts +13 -2
  161. package/src/snackbar/Toast.tsx +1 -1
  162. package/src/table/TableCell.tsx +1 -4
  163. package/src/table/TableCheckbox.tsx +1 -1
  164. package/src/table/TableRadio.tsx +1 -1
  165. package/src/tabs/TabListScrollButton.tsx +1 -1
  166. package/src/tree/TreeItem.tsx +2 -2
  167. package/src/types.ts +44 -2
  168. package/src/utils/alphaNumericSort.ts +17 -11
@@ -43,7 +43,7 @@ export interface MenuSheetConvenienceProps {
43
43
  * />
44
44
  * ```
45
45
  */
46
- sheetProps?: PropsWithRef<MenuSheetConfigurableProps, HTMLDivElement>;
46
+ sheetProps?: PropsWithRef<MenuSheetConfigurableProps>;
47
47
 
48
48
  /**
49
49
  * Convenience prop to apply custom style to the `Sheet` component when the
@@ -25,8 +25,8 @@ const noop = (): void => {
25
25
  export interface CollapsibleNavGroupProps
26
26
  extends NavGroupProps,
27
27
  NavItemButtonRotatorProps {
28
- liProps?: PropsWithRef<LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>;
29
- buttonProps?: PropsWithRef<ButtonProps, HTMLButtonElement>;
28
+ liProps?: PropsWithRef<LiHTMLAttributes<HTMLLIElement>>;
29
+ buttonProps?: PropsWithRef<ButtonProps>;
30
30
  collapseOptions?: Omit<
31
31
  CollapseTransitionHookOptions<HTMLUListElement>,
32
32
  "nodeRef" | "className" | "transitionIn"
@@ -36,7 +36,7 @@ export interface NavItemLinkProps
36
36
  * Any additional props to provide the wrapping `<li>` element such as
37
37
  * `style`, `className`, and `ref`.
38
38
  */
39
- liProps?: PropsWithRef<LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>;
39
+ liProps?: PropsWithRef<LiHTMLAttributes<HTMLLIElement>>;
40
40
 
41
41
  /**
42
42
  * Set this to `true` if the link matches the current `pathname`. This will
@@ -1,4 +1,3 @@
1
- import { cnb } from "cnbuilder";
2
1
  import {
3
2
  type CSSProperties,
4
3
  type HTMLAttributes,
@@ -6,11 +5,15 @@ import {
6
5
  useMemo,
7
6
  } from "react";
8
7
 
9
- import { cssUtils } from "../cssUtils.js";
10
8
  import { type LabelRequiredForA11y } from "../types.js";
11
9
  import { useEnsuredId } from "../useEnsuredId.js";
12
- import { bem } from "../utils/bem.js";
13
10
  import { getPercentage } from "../utils/getPercentage.js";
11
+ import {
12
+ type CircularProgressClassNameOptions,
13
+ circularProgress,
14
+ circularProgressCircle,
15
+ circularProgressSvg,
16
+ } from "./circularProgressStyles.js";
14
17
  import { type ProgressProps } from "./types.js";
15
18
 
16
19
  /**
@@ -22,7 +25,8 @@ import { type ProgressProps } from "./types.js";
22
25
  */
23
26
  export interface CircularProgressProps
24
27
  extends Omit<HTMLAttributes<HTMLSpanElement>, "id">,
25
- ProgressProps {
28
+ ProgressProps,
29
+ CircularProgressClassNameOptions {
26
30
  /**
27
31
  * An optional style to apply to the svg within the circular progress. The
28
32
  * values of this style object will be merged with the current determinate
@@ -84,24 +88,6 @@ export interface CircularProgressProps
84
88
  */
85
89
  dashoffset?: number;
86
90
 
87
- /**
88
- * Boolean if the circular progress should be centered using left and right
89
- * margins.
90
- *
91
- * @defaultValue `false`
92
- * @since 6.0.0 Renamed from `centered`
93
- */
94
- disableCentered?: boolean;
95
-
96
- /**
97
- * Set to `true` to render as a smaller size.
98
- *
99
- * @defaultValue `false`
100
- * @since 2.3.0
101
- * @since 6.0.0 Renamed from `small`
102
- */
103
- dense?: boolean;
104
-
105
91
  /**
106
92
  * Set this to `true` to update the indeterminate behavior to only rotate
107
93
  * which will increase performance during CPU-intensive tasks or when many
@@ -113,8 +99,6 @@ export interface CircularProgressProps
113
99
  disableShrink?: boolean;
114
100
  }
115
101
 
116
- const styles = bem("rmd-circular-progress");
117
-
118
102
  /**
119
103
  * @example Indeterminate Example
120
104
  * ```tsx
@@ -160,12 +144,12 @@ export const CircularProgress = forwardRef<
160
144
  radius = 30,
161
145
  center = 33,
162
146
  viewBox = "0 0 66 66",
163
- theme = "primary",
164
- dense = false,
147
+ theme,
148
+ dense,
165
149
  dashoffset = 187,
166
- disableShrink = false,
167
- disableCentered = false,
168
- disableTransition = false,
150
+ disableShrink,
151
+ disableCentered,
152
+ disableTransition,
169
153
  ...remaining
170
154
  } = props;
171
155
 
@@ -186,8 +170,7 @@ export const CircularProgress = forwardRef<
186
170
  };
187
171
  }, [progress, propCircleStyle, dashoffset]);
188
172
 
189
- const determinate = typeof progress === "number";
190
- const indeterminate = !determinate;
173
+ const indeterminate = typeof progress !== "number";
191
174
  return (
192
175
  <span
193
176
  {...remaining}
@@ -197,35 +180,30 @@ export const CircularProgress = forwardRef<
197
180
  aria-valuemin={min}
198
181
  aria-valuemax={max}
199
182
  aria-valuenow={value}
200
- className={cnb(
201
- styles({ dense, centered: !disableCentered }),
202
- theme !== "current-color" && cssUtils({ textColor: theme }),
203
- className
204
- )}
183
+ className={circularProgress({
184
+ theme,
185
+ dense,
186
+ disableCentered,
187
+ className,
188
+ })}
205
189
  >
206
190
  <svg
207
191
  style={svgStyle}
208
- className={cnb(
209
- styles("svg", {
210
- determinate,
211
- indeterminate: indeterminate && !disableShrink,
212
- "rotate-only": indeterminate && disableShrink,
213
- }),
214
- svgClassName
215
- )}
192
+ className={circularProgressSvg({
193
+ className: svgClassName,
194
+ indeterminate,
195
+ disableShrink,
196
+ })}
216
197
  viewBox={viewBox}
217
198
  >
218
199
  <circle
219
200
  style={circleStyle}
220
- className={cnb(
221
- styles("circle", {
222
- animate: !disableTransition && determinate,
223
- determinate,
224
- indeterminate: indeterminate && !disableShrink,
225
- "rotate-only": indeterminate && disableShrink,
226
- }),
227
- circleClassName
228
- )}
201
+ className={circularProgressCircle({
202
+ className: circleClassName,
203
+ indeterminate,
204
+ disableShrink,
205
+ disableTransition,
206
+ })}
229
207
  r={radius}
230
208
  cx={center}
231
209
  cy={center}
@@ -1,4 +1,3 @@
1
- import { cnb } from "cnbuilder";
2
1
  import {
3
2
  type CSSProperties,
4
3
  type HTMLAttributes,
@@ -6,11 +5,10 @@ import {
6
5
  useMemo,
7
6
  } from "react";
8
7
 
9
- import { cssUtils } from "../cssUtils.js";
10
- import { type LabelRequiredForA11y } from "../types.js";
8
+ import { type LabelRequiredForA11y, type PropsWithRef } from "../types.js";
11
9
  import { useEnsuredId } from "../useEnsuredId.js";
12
- import { bem } from "../utils/bem.js";
13
10
  import { getPercentage } from "../utils/getPercentage.js";
11
+ import { linearProgress, linearProgressBar } from "./linearProgressStyles.js";
14
12
  import { type ProgressProps } from "./types.js";
15
13
 
16
14
  /**
@@ -31,6 +29,11 @@ export interface LinearProgressProps
31
29
  */
32
30
  barClassName?: string;
33
31
 
32
+ /**
33
+ * @since 6.1.0
34
+ */
35
+ barProps?: PropsWithRef<HTMLAttributes<HTMLSpanElement>>;
36
+
34
37
  /**
35
38
  * Boolean if the progress should be reversed. This will change the progress
36
39
  * direction from `left-to-right` to be `right-to-left`. If the current
@@ -61,8 +64,6 @@ export interface LinearProgressProps
61
64
  verticalHeight?: number | null;
62
65
  }
63
66
 
64
- const styles = bem("rmd-linear-progress");
65
-
66
67
  /**
67
68
  * @example Indeterminate Example
68
69
  * ```tsx
@@ -101,13 +102,14 @@ export const LinearProgress = forwardRef<
101
102
  className,
102
103
  barStyle: propBarStyle,
103
104
  barClassName,
105
+ barProps,
104
106
  min = 0,
105
107
  max = 100,
106
108
  value,
107
- reverse = false,
108
- theme = "primary",
109
- disableTransition = false,
110
- vertical = false,
109
+ reverse,
110
+ theme,
111
+ disableTransition,
112
+ vertical,
111
113
  verticalHeight = 240,
112
114
  ...remaining
113
115
  } = props;
@@ -140,8 +142,7 @@ export const LinearProgress = forwardRef<
140
142
  };
141
143
  }, [progress, propBarStyle, vertical]);
142
144
 
143
- const determinate = typeof progress === "number";
144
- const indeterminate = !determinate;
145
+ const indeterminate = typeof progress !== "number";
145
146
  return (
146
147
  <span
147
148
  {...remaining}
@@ -152,37 +153,23 @@ export const LinearProgress = forwardRef<
152
153
  aria-valuemin={min}
153
154
  aria-valuemax={max}
154
155
  aria-valuenow={value}
155
- className={cnb(
156
- styles({
157
- vertical,
158
- horizontal: !vertical,
159
- determinate,
160
- indeterminate,
161
- }),
162
- theme !== "current-color" && cssUtils({ textColor: theme }),
163
- className
164
- )}
156
+ className={linearProgress({
157
+ className,
158
+ theme,
159
+ vertical,
160
+ indeterminate,
161
+ })}
165
162
  >
166
163
  <span
164
+ {...barProps}
167
165
  style={barStyle}
168
- className={cnb(
169
- styles("bar", {
170
- vertical,
171
- "vertical-reverse": vertical && reverse,
172
- horizontal: !vertical,
173
- "horizontal-reverse": !vertical && reverse,
174
- animate: !disableTransition && determinate,
175
- determinate,
176
- indeterminate,
177
- "determinate-reverse": determinate && reverse && !vertical,
178
- "determinate-vertical-reverse": determinate && reverse && vertical,
179
- "indeterminate-reverse": indeterminate && reverse && !vertical,
180
- "indeterminate-vertical": indeterminate && vertical,
181
- "indeterminate-vertical-reverse":
182
- indeterminate && reverse && vertical,
183
- }),
184
- barClassName
185
- )}
166
+ className={linearProgressBar({
167
+ className: barClassName,
168
+ reverse,
169
+ vertical,
170
+ indeterminate,
171
+ disableTransition,
172
+ })}
186
173
  />
187
174
  </span>
188
175
  );
@@ -0,0 +1,114 @@
1
+ import { cnb } from "cnbuilder";
2
+
3
+ import { cssUtils } from "../cssUtils.js";
4
+ import { bem } from "../utils/bem.js";
5
+ import { type ProgressTheme } from "./types.js";
6
+
7
+ const styles = bem("rmd-circular-progress");
8
+
9
+ /**
10
+ * @since 6.2.0
11
+ */
12
+ export interface CircularProgressClassNameOptions {
13
+ className?: string;
14
+
15
+ /**
16
+ * @defaultValue `"primary"`
17
+ * @since 6.0.0
18
+ */
19
+ theme?: ProgressTheme;
20
+
21
+ /**
22
+ * Set to `true` to render as a smaller size.
23
+ *
24
+ * @defaultValue `false`
25
+ * @since 2.3.0
26
+ * @since 6.0.0 Renamed from `small`
27
+ */
28
+ dense?: boolean;
29
+
30
+ /**
31
+ * Boolean if the circular progress should be centered using left and right
32
+ * margins.
33
+ *
34
+ * @defaultValue `false`
35
+ * @since 6.0.0 Renamed from `centered`
36
+ */
37
+ disableCentered?: boolean;
38
+ }
39
+
40
+ /**
41
+ * @since 6.2.0
42
+ */
43
+ export function circularProgress(
44
+ options: CircularProgressClassNameOptions = {}
45
+ ): string {
46
+ const { className, theme = "primary", dense, disableCentered } = options;
47
+
48
+ return cnb(
49
+ styles({ dense, centered: !disableCentered }),
50
+ theme !== "current-color" && cssUtils({ textColor: theme }),
51
+ className
52
+ );
53
+ }
54
+
55
+ /**
56
+ * @since 6.2.0
57
+ */
58
+ export interface CircularProgressSvgClassNameOptions {
59
+ className?: string;
60
+ /** @defaultValue `false` */
61
+ indeterminate?: boolean;
62
+ /** @defaultValue `false` */
63
+ disableShrink?: boolean;
64
+ }
65
+
66
+ /**
67
+ * @since 6.2.0
68
+ */
69
+ export function circularProgressSvg(
70
+ options: CircularProgressSvgClassNameOptions = {}
71
+ ): string {
72
+ const { className, indeterminate, disableShrink } = options;
73
+
74
+ return cnb(
75
+ styles("svg", {
76
+ determinate: !indeterminate,
77
+ indeterminate: indeterminate && !disableShrink,
78
+ "rotate-only": indeterminate && disableShrink,
79
+ }),
80
+ className
81
+ );
82
+ }
83
+ /**
84
+ * @since 6.2.0
85
+ */
86
+ export interface CircularProgressCircleClassNameOptions {
87
+ className?: string;
88
+ /** @defaultValue `false` */
89
+ indeterminate?: boolean;
90
+ /** @defaultValue `false` */
91
+ disableShrink?: boolean;
92
+ /** @defaultValue `false` */
93
+ disableTransition?: boolean;
94
+ }
95
+
96
+ /**
97
+ * @since 6.2.0
98
+ */
99
+ export function circularProgressCircle(
100
+ options: CircularProgressCircleClassNameOptions = {}
101
+ ): string {
102
+ const { className, indeterminate, disableShrink, disableTransition } =
103
+ options;
104
+
105
+ return cnb(
106
+ styles("circle", {
107
+ animate: !disableTransition && !indeterminate,
108
+ determinate: !indeterminate,
109
+ indeterminate: indeterminate && !disableShrink,
110
+ "rotate-only": indeterminate && disableShrink,
111
+ }),
112
+ className
113
+ );
114
+ }
@@ -0,0 +1,90 @@
1
+ import { cnb } from "cnbuilder";
2
+
3
+ import { cssUtils } from "../cssUtils.js";
4
+ import { bem } from "../utils/bem.js";
5
+ import { type ProgressTheme } from "./types.js";
6
+
7
+ const styles = bem("rmd-linear-progress");
8
+
9
+ /**
10
+ * @since 6.2.0
11
+ */
12
+ export interface LinearProgressClassNameOptions {
13
+ className?: string;
14
+
15
+ /**
16
+ * @defaultValue `"primary"`
17
+ * @since 6.0.0
18
+ */
19
+ theme?: ProgressTheme;
20
+
21
+ /** @defaultValue `false` */
22
+ vertical?: boolean;
23
+
24
+ /** @defaultValue `false` */
25
+ indeterminate?: boolean;
26
+ }
27
+
28
+ /**
29
+ * @since 6.2.0
30
+ */
31
+ export function linearProgress(
32
+ options: LinearProgressClassNameOptions = {}
33
+ ): string {
34
+ const { className, theme = "primary", vertical, indeterminate } = options;
35
+
36
+ return cnb(
37
+ styles({
38
+ vertical,
39
+ horizontal: !vertical,
40
+ determinate: !indeterminate,
41
+ indeterminate,
42
+ }),
43
+ theme !== "current-color" && cssUtils({ textColor: theme }),
44
+ className
45
+ );
46
+ }
47
+
48
+ /**
49
+ * @since 6.2.0
50
+ */
51
+ export interface LinearProgressBarClassNameOptions {
52
+ className?: string;
53
+
54
+ /** @defaultValue `false` */
55
+ reverse?: boolean;
56
+ /** @defaultValue `false` */
57
+ vertical?: boolean;
58
+ /** @defaultValue `false` */
59
+ indeterminate?: boolean;
60
+ /** @defaultValue `false` */
61
+ disableTransition?: boolean;
62
+ }
63
+
64
+ /**
65
+ * @since 6.2.0
66
+ */
67
+ export function linearProgressBar(
68
+ options: LinearProgressBarClassNameOptions = {}
69
+ ): string {
70
+ const { className, reverse, vertical, indeterminate, disableTransition } =
71
+ options;
72
+
73
+ return cnb(
74
+ styles("bar", {
75
+ vertical,
76
+ "vertical-reverse": vertical && reverse,
77
+ horizontal: !vertical,
78
+ "horizontal-reverse": !vertical && reverse,
79
+ animate: !disableTransition && !indeterminate,
80
+ determinate: !indeterminate,
81
+ indeterminate,
82
+ "determinate-reverse": !indeterminate && reverse && !vertical,
83
+ "determinate-vertical-reverse": !indeterminate && reverse && vertical,
84
+ "indeterminate-reverse": indeterminate && reverse && !vertical,
85
+ "indeterminate-vertical": indeterminate && vertical,
86
+ "indeterminate-vertical-reverse": indeterminate && reverse && vertical,
87
+ }),
88
+ className
89
+ );
90
+ }
@@ -1,7 +1,13 @@
1
- import { type TextExtractor } from "../types.js";
1
+ import { type AutomaticTextExtraction, type TextExtractor } from "../types.js";
2
2
  import { type BaseSearchOptions } from "./types.js";
3
3
  import { defaultExtractor, search } from "./utils.js";
4
4
 
5
+ /**
6
+ * @since 6.2.0
7
+ * @internal
8
+ */
9
+ const DEFAULT_EXTRACTOR = defaultExtractor("caseInsensitiveSearch");
10
+
5
11
  /**
6
12
  * @since 6.0.0
7
13
  */
@@ -142,18 +148,34 @@ export interface CaseInsensitiveOptions<T>
142
148
  * caseInsensitiveSearch({
143
149
  * list: fruits,
144
150
  * query: "ap",
145
- * extractor: (item) => item.name,
146
151
  * });
147
152
  * // [{ name: "Apple", value: 0 }, { name: "Grape", value: 2 }]
148
153
  * ```
149
154
  *
155
+ * @example Objects With Custom Names
156
+ * ```ts
157
+ * const fruits = [
158
+ * { nameField: "Apple", value: 0 },
159
+ * { nameField: "Banana", value: 1 },
160
+ * { nameField: "Grape", value: 2 },
161
+ * { nameField: "Orange", value: 3 },
162
+ * ];
163
+ *
164
+ * caseInsensitiveSearch({
165
+ * list: fruits,
166
+ * query: "ap",
167
+ * extractor: (item) => item.nameField,
168
+ * });
169
+ * // [{ nameField: "Apple", value: 0 }, { nameField: "Grape", value: 2 }]
170
+ * ```
171
+ *
150
172
  * @since 6.0.0
151
173
  */
152
- export function caseInsensitiveSearch<T extends string>(
153
- options: Omit<CaseInsensitiveOptions<T>, "extractor"> & { type?: "filter" }
174
+ export function caseInsensitiveSearch<T extends AutomaticTextExtraction>(
175
+ options: CaseInsensitiveOptions<T> & { type?: "filter" }
154
176
  ): readonly T[];
155
- export function caseInsensitiveSearch<T extends string>(
156
- options: Omit<CaseInsensitiveOptions<T>, "extractor"> & { type: "search" }
177
+ export function caseInsensitiveSearch<T extends AutomaticTextExtraction>(
178
+ options: CaseInsensitiveOptions<T> & { type: "search" }
157
179
  ): T | undefined;
158
180
  export function caseInsensitiveSearch<T>(
159
181
  options: CaseInsensitiveOptions<T> & {
@@ -174,7 +196,7 @@ export function caseInsensitiveSearch<T>(
174
196
  list,
175
197
  type = "filter",
176
198
  query,
177
- extractor = defaultExtractor("caseInsensitiveSearch"),
199
+ extractor = DEFAULT_EXTRACTOR,
178
200
  startsWith,
179
201
  whitespace,
180
202
  } = options;
@@ -1,7 +1,13 @@
1
- import { type TextExtractor } from "../types.js";
1
+ import { type AutomaticTextExtraction, type TextExtractor } from "../types.js";
2
2
  import { type BaseSearchOptions } from "./types.js";
3
3
  import { defaultExtractor, search } from "./utils.js";
4
4
 
5
+ /**
6
+ * @since 6.2.0
7
+ * @internal
8
+ */
9
+ const DEFAULT_EXTRACTOR = defaultExtractor("fuzzySearch");
10
+
5
11
  /**
6
12
  * @example
7
13
  * ```tsx
@@ -126,11 +132,11 @@ export type FuzzySearchOptions<T> = BaseSearchOptions<T>;
126
132
  *
127
133
  * @since 6.0.0
128
134
  */
129
- export function fuzzySearch<T extends string>(
130
- options: Omit<FuzzySearchOptions<T>, "extractor"> & { type?: "filter" }
135
+ export function fuzzySearch<T extends AutomaticTextExtraction>(
136
+ options: FuzzySearchOptions<T> & { type?: "filter" }
131
137
  ): readonly T[];
132
- export function fuzzySearch<T extends string>(
133
- options: Omit<FuzzySearchOptions<T>, "extractor"> & { type?: "search" }
138
+ export function fuzzySearch<T extends AutomaticTextExtraction>(
139
+ options: FuzzySearchOptions<T> & { type?: "search" }
134
140
  ): T | undefined;
135
141
  export function fuzzySearch<T>(
136
142
  option: FuzzySearchOptions<T> & {
@@ -151,7 +157,7 @@ export function fuzzySearch<T>(
151
157
  list,
152
158
  type = "filter",
153
159
  query,
154
- extractor = defaultExtractor("fuzzySearch"),
160
+ extractor = DEFAULT_EXTRACTOR,
155
161
  whitespace,
156
162
  } = options;
157
163
 
@@ -4,17 +4,28 @@ import { type BaseSearchOptions } from "./types.js";
4
4
 
5
5
  /**
6
6
  * @since 6.0.0
7
+ * @since 6.2.0 Added support for `item.name` and `item.label`.
7
8
  * @internal
8
9
  */
9
10
  export const defaultExtractor =
10
- (name: string) =>
11
+ (usageName: string, propName = "extractor") =>
11
12
  (item: unknown): string => {
12
13
  if (typeof item === "string") {
13
14
  return item;
14
15
  }
15
16
 
17
+ if (item && typeof item === "object") {
18
+ if ("label" in item && typeof item.label === "string") {
19
+ return item.label;
20
+ }
21
+
22
+ if ("name" in item && typeof item.name === "string") {
23
+ return item.name;
24
+ }
25
+ }
26
+
16
27
  throw new Error(
17
- `A \`TextExtractor\` must be provided to \`${name}\` for lists that do not contain strings`
28
+ `\`${usageName}\` requires the \`${propName}\` prop for lists that do not contain strings or known object types.`
18
29
  );
19
30
  };
20
31
 
@@ -104,7 +104,7 @@ export interface ConfigurableToastProps
104
104
  * Any additional props that should be provided to the `<div>` that surrounds
105
105
  * the toast `children`.
106
106
  */
107
- contentProps?: PropsWithRef<ToastContentProps, HTMLDivElement>;
107
+ contentProps?: PropsWithRef<ToastContentProps>;
108
108
 
109
109
  /**
110
110
  * Set this to `true` if the `children` for the toast should no longer be
@@ -119,10 +119,7 @@ export interface TableCellProps extends TableCellAttributes, TableCellOptions {
119
119
  *
120
120
  * @since 6.0.0
121
121
  */
122
- contentProps?: PropsWithRef<
123
- ButtonHTMLAttributes<HTMLButtonElement>,
124
- HTMLButtonElement
125
- >;
122
+ contentProps?: PropsWithRef<ButtonHTMLAttributes<HTMLButtonElement>>;
126
123
 
127
124
  /**
128
125
  * Any additional props to pass to the `IconRotator` when the `aria-sort` prop
@@ -73,7 +73,7 @@ export interface TableCheckboxProps
73
73
  * @see {@link TableCheckboxSupportedCheckboxProps}
74
74
  * @since 6.0.0
75
75
  */
76
- checkboxProps?: PropsWithRef<CheckboxProps, HTMLInputElement>;
76
+ checkboxProps?: PropsWithRef<CheckboxProps>;
77
77
  }
78
78
 
79
79
  /**
@@ -68,7 +68,7 @@ export interface TableRadioProps
68
68
  * @see {@link TableRadioSupportedRadioProps}
69
69
  * @since 6.0.0
70
70
  */
71
- radioProps?: PropsWithRef<RadioProps, HTMLInputElement>;
71
+ radioProps?: PropsWithRef<RadioProps>;
72
72
  }
73
73
 
74
74
  /**
@@ -31,7 +31,7 @@ import {
31
31
  export interface BaseTabListScrollButtonProps
32
32
  extends HTMLAttributes<HTMLDivElement>,
33
33
  ButtonClassNameThemeOptions {
34
- buttonProps?: PropsWithRef<ButtonProps, HTMLButtonElement>;
34
+ buttonProps?: PropsWithRef<ButtonProps>;
35
35
 
36
36
  /** @defaultValue `false` */
37
37
  disableTransition?: boolean;