@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.
- package/dist/RootHtml.d.ts +1 -1
- package/dist/RootHtml.js.map +1 -1
- package/dist/autocomplete/defaults.d.ts +1 -0
- package/dist/autocomplete/defaults.js +2 -6
- package/dist/autocomplete/defaults.js.map +1 -1
- package/dist/autocomplete/types.d.ts +9 -9
- package/dist/autocomplete/types.js.map +1 -1
- package/dist/avatar/Avatar.d.ts +1 -1
- package/dist/avatar/Avatar.js +1 -1
- package/dist/avatar/Avatar.js.map +1 -1
- package/dist/avatar/styles.d.ts +29 -1
- package/dist/avatar/styles.js.map +1 -1
- package/dist/box/styles.d.ts +26 -3
- package/dist/box/styles.js.map +1 -1
- package/dist/button/AsyncButton.d.ts +2 -2
- package/dist/button/AsyncButton.js.map +1 -1
- package/dist/button/Button.d.ts +1 -1
- package/dist/button/Button.js.map +1 -1
- package/dist/card/CardHeader.d.ts +1 -1
- package/dist/card/CardHeader.js.map +1 -1
- package/dist/chip/Chip.d.ts +1 -1
- package/dist/chip/Chip.js.map +1 -1
- package/dist/dialog/Dialog.d.ts +1 -1
- package/dist/dialog/Dialog.js.map +1 -1
- package/dist/expansion-panel/ExpansionPanel.d.ts +1 -1
- package/dist/expansion-panel/ExpansionPanel.js.map +1 -1
- package/dist/expansion-panel/ExpansionPanelHeader.d.ts +1 -1
- package/dist/expansion-panel/ExpansionPanelHeader.js.map +1 -1
- package/dist/files/FileInput.d.ts +1 -1
- package/dist/files/FileInput.js.map +1 -1
- package/dist/form/FormMessageContainer.d.ts +1 -1
- package/dist/form/FormMessageContainer.js.map +1 -1
- package/dist/form/InputToggle.d.ts +2 -2
- package/dist/form/InputToggle.js.map +1 -1
- package/dist/form/NativeSelect.d.ts +1 -1
- package/dist/form/NativeSelect.js.map +1 -1
- package/dist/form/OptGroup.d.ts +1 -1
- package/dist/form/OptGroup.js.map +1 -1
- package/dist/form/Password.d.ts +1 -1
- package/dist/form/Password.js.map +1 -1
- package/dist/form/Select.d.ts +2 -2
- package/dist/form/Select.js.map +1 -1
- package/dist/form/Slider.d.ts +1 -1
- package/dist/form/Slider.js.map +1 -1
- package/dist/form/Switch.d.ts +3 -3
- package/dist/form/Switch.js.map +1 -1
- package/dist/form/SwitchTrack.d.ts +1 -1
- package/dist/form/SwitchTrack.js.map +1 -1
- package/dist/form/TextArea.d.ts +2 -2
- package/dist/form/TextArea.js.map +1 -1
- package/dist/form/TextField.d.ts +1 -1
- package/dist/form/TextField.js.map +1 -1
- package/dist/form/types.d.ts +5 -5
- package/dist/form/types.js.map +1 -1
- package/dist/layout/LayoutAppBar.d.ts +1 -1
- package/dist/layout/LayoutAppBar.js.map +1 -1
- package/dist/list/ListItemLink.d.ts +1 -1
- package/dist/list/ListItemLink.js.map +1 -1
- package/dist/list/ListItemText.d.ts +1 -1
- package/dist/list/ListItemText.js.map +1 -1
- package/dist/list/ListSubheader.d.ts +1 -1
- package/dist/list/ListSubheader.js.map +1 -1
- package/dist/list/types.d.ts +2 -2
- package/dist/list/types.js.map +1 -1
- package/dist/menu/Menu.d.ts +3 -3
- package/dist/menu/Menu.js.map +1 -1
- package/dist/menu/MenuItemInputToggle.d.ts +2 -2
- package/dist/menu/MenuItemInputToggle.js.map +1 -1
- package/dist/menu/MenuItemTextField.d.ts +1 -1
- package/dist/menu/MenuItemTextField.js.map +1 -1
- package/dist/menu/MenuSheet.d.ts +1 -1
- package/dist/menu/MenuSheet.js.map +1 -1
- package/dist/navigation/CollapsibleNavGroup.d.ts +2 -2
- package/dist/navigation/CollapsibleNavGroup.js.map +1 -1
- package/dist/navigation/NavItemLink.d.ts +1 -1
- package/dist/navigation/NavItemLink.js.map +1 -1
- package/dist/progress/CircularProgress.d.ts +2 -17
- package/dist/progress/CircularProgress.js +19 -23
- package/dist/progress/CircularProgress.js.map +1 -1
- package/dist/progress/LinearProgress.d.ts +5 -1
- package/dist/progress/LinearProgress.js +13 -25
- package/dist/progress/LinearProgress.js.map +1 -1
- package/dist/progress/circularProgressStyles.d.ts +62 -0
- package/dist/progress/circularProgressStyles.js +38 -0
- package/dist/progress/circularProgressStyles.js.map +1 -0
- package/dist/progress/linearProgressStyles.d.ts +38 -0
- package/dist/progress/linearProgressStyles.js +38 -0
- package/dist/progress/linearProgressStyles.js.map +1 -0
- package/dist/searching/caseInsensitive.d.ts +20 -4
- package/dist/searching/caseInsensitive.js +5 -1
- package/dist/searching/caseInsensitive.js.map +1 -1
- package/dist/searching/fuzzy.d.ts +3 -3
- package/dist/searching/fuzzy.js +5 -1
- package/dist/searching/fuzzy.js.map +1 -1
- package/dist/searching/utils.d.ts +2 -1
- package/dist/searching/utils.js +11 -2
- package/dist/searching/utils.js.map +1 -1
- package/dist/snackbar/Toast.d.ts +1 -1
- package/dist/snackbar/Toast.js.map +1 -1
- package/dist/table/TableCell.d.ts +1 -1
- package/dist/table/TableCell.js.map +1 -1
- package/dist/table/TableCheckbox.d.ts +1 -1
- package/dist/table/TableCheckbox.js.map +1 -1
- package/dist/table/TableRadio.d.ts +1 -1
- package/dist/table/TableRadio.js.map +1 -1
- package/dist/tabs/TabListScrollButton.d.ts +1 -1
- package/dist/tabs/TabListScrollButton.js.map +1 -1
- package/dist/tree/TreeItem.d.ts +2 -2
- package/dist/tree/TreeItem.js.map +1 -1
- package/dist/types.d.ts +29 -2
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/alphaNumericSort.d.ts +9 -9
- package/dist/utils/alphaNumericSort.js +5 -1
- package/dist/utils/alphaNumericSort.js.map +1 -1
- package/package.json +6 -6
- package/src/RootHtml.tsx +1 -1
- package/src/autocomplete/defaults.ts +5 -12
- package/src/autocomplete/types.ts +9 -12
- package/src/avatar/Avatar.tsx +2 -2
- package/src/avatar/styles.ts +53 -1
- package/src/box/styles.ts +34 -13
- package/src/button/AsyncButton.tsx +2 -2
- package/src/button/Button.tsx +1 -1
- package/src/card/CardHeader.tsx +1 -1
- package/src/chip/Chip.tsx +1 -1
- package/src/dialog/Dialog.tsx +1 -4
- package/src/expansion-panel/ExpansionPanel.tsx +1 -1
- package/src/expansion-panel/ExpansionPanelHeader.tsx +1 -1
- package/src/files/FileInput.tsx +1 -4
- package/src/form/FormMessageContainer.tsx +1 -1
- package/src/form/InputToggle.tsx +2 -5
- package/src/form/NativeSelect.tsx +1 -1
- package/src/form/OptGroup.tsx +1 -4
- package/src/form/Password.tsx +1 -1
- package/src/form/Select.tsx +2 -3
- package/src/form/Slider.tsx +1 -1
- package/src/form/Switch.tsx +3 -3
- package/src/form/SwitchTrack.tsx +1 -1
- package/src/form/TextArea.tsx +2 -5
- package/src/form/TextField.tsx +1 -1
- package/src/form/types.ts +5 -15
- package/src/layout/LayoutAppBar.tsx +1 -1
- package/src/list/ListItemLink.tsx +1 -1
- package/src/list/ListItemText.tsx +1 -4
- package/src/list/ListSubheader.tsx +1 -1
- package/src/list/types.ts +2 -5
- package/src/menu/Menu.tsx +3 -4
- package/src/menu/MenuItemInputToggle.tsx +2 -2
- package/src/menu/MenuItemTextField.tsx +1 -1
- package/src/menu/MenuSheet.tsx +1 -1
- package/src/navigation/CollapsibleNavGroup.tsx +2 -2
- package/src/navigation/NavItemLink.tsx +1 -1
- package/src/progress/CircularProgress.tsx +31 -53
- package/src/progress/LinearProgress.tsx +27 -40
- package/src/progress/circularProgressStyles.ts +114 -0
- package/src/progress/linearProgressStyles.ts +90 -0
- package/src/searching/caseInsensitive.ts +29 -7
- package/src/searching/fuzzy.ts +12 -6
- package/src/searching/utils.ts +13 -2
- package/src/snackbar/Toast.tsx +1 -1
- package/src/table/TableCell.tsx +1 -4
- package/src/table/TableCheckbox.tsx +1 -1
- package/src/table/TableRadio.tsx +1 -1
- package/src/tabs/TabListScrollButton.tsx +1 -1
- package/src/tree/TreeItem.tsx +2 -2
- package/src/types.ts +44 -2
- package/src/utils/alphaNumericSort.ts +17 -11
package/src/tree/TreeItem.tsx
CHANGED
|
@@ -48,12 +48,12 @@ export interface TreeItemProps
|
|
|
48
48
|
* element. The top-level props are passed to the `<span>` or `<a>` element
|
|
49
49
|
* instead.
|
|
50
50
|
*/
|
|
51
|
-
liProps?: PropsWithRef<HTMLAttributes<HTMLLIElement
|
|
51
|
+
liProps?: PropsWithRef<HTMLAttributes<HTMLLIElement>>;
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* Any additional props to pass to the `TreeGroup` component.
|
|
55
55
|
*/
|
|
56
|
-
groupProps?: PropsWithRef<OverridableTreeGroupProps
|
|
56
|
+
groupProps?: PropsWithRef<OverridableTreeGroupProps>;
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
59
|
* This should normally be the text/content to display within the tree item
|
package/src/types.ts
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
type Dispatch,
|
|
3
|
+
type HTMLAttributes,
|
|
4
|
+
type ReactElement,
|
|
5
|
+
type Ref,
|
|
6
|
+
type SetStateAction,
|
|
7
|
+
} from "react";
|
|
2
8
|
|
|
3
9
|
/**
|
|
4
10
|
* A helper type that allows an optional `ref` to also be applied with a props
|
|
5
11
|
* object even though a `ref` isn't a real prop.
|
|
12
|
+
*
|
|
13
|
+
* @since 6.2.0 Automatically infer the `Element` type param from the provided
|
|
14
|
+
* props.
|
|
6
15
|
*/
|
|
7
16
|
export type PropsWithRef<
|
|
8
17
|
Props extends object,
|
|
9
|
-
Element extends HTMLElement
|
|
18
|
+
Element extends HTMLElement = Props extends HTMLAttributes<infer E>
|
|
19
|
+
? E extends HTMLElement
|
|
20
|
+
? E
|
|
21
|
+
: never
|
|
22
|
+
: never,
|
|
10
23
|
> = Props & {
|
|
11
24
|
/**
|
|
12
25
|
* An optional ref that can be applied.
|
|
@@ -104,6 +117,18 @@ export type HtmlTagName = keyof JSX.IntrinsicElements;
|
|
|
104
117
|
*/
|
|
105
118
|
export type TextExtractor<T> = (item: T) => string;
|
|
106
119
|
|
|
120
|
+
/**
|
|
121
|
+
* - `"some value"` -> `"some value"`
|
|
122
|
+
* - `{ label: "Hello, world", value: 300 }` -> `"Hello, world!"`
|
|
123
|
+
* - `{ name: "Hello, world", value: 300 }` -> `"Hello, world!"`
|
|
124
|
+
*
|
|
125
|
+
* @since 6.2.0
|
|
126
|
+
*/
|
|
127
|
+
export type AutomaticTextExtraction =
|
|
128
|
+
| string
|
|
129
|
+
| { label: string }
|
|
130
|
+
| { name: string };
|
|
131
|
+
|
|
107
132
|
/**
|
|
108
133
|
* @since 6.0.0
|
|
109
134
|
* @internal
|
|
@@ -201,3 +226,20 @@ export interface ElementSize {
|
|
|
201
226
|
height: number;
|
|
202
227
|
width: number;
|
|
203
228
|
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* @since 6.2.0
|
|
232
|
+
*/
|
|
233
|
+
export type OverridableStringUnion<
|
|
234
|
+
Defaults extends string,
|
|
235
|
+
Overrides extends Partial<Record<string, boolean>>,
|
|
236
|
+
> =
|
|
237
|
+
| Exclude<Defaults, { [K in keyof Overrides]: K }[keyof Overrides]>
|
|
238
|
+
| {
|
|
239
|
+
[K in keyof Overrides]: Overrides[K] extends false ? never : K;
|
|
240
|
+
}[keyof Overrides];
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* @since 6.2.0
|
|
244
|
+
*/
|
|
245
|
+
export type IsEmptyObject<T> = keyof T extends never ? true : false;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { defaultExtractor } from "../searching/utils.js";
|
|
2
|
-
import { type TextExtractor } from "../types.js";
|
|
2
|
+
import { type AutomaticTextExtraction, type TextExtractor } from "../types.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @since 6.2.0
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
const DEFAULT_EXTRACTOR = defaultExtractor("alphaNumericSort");
|
|
3
9
|
|
|
4
10
|
/** @since 6.0.0 */
|
|
5
11
|
export const DEFAULT_COLLATOR_OPTIONS = {
|
|
@@ -26,13 +32,13 @@ export interface AlphaNumericSortOptions<T> {
|
|
|
26
32
|
* @example Simple Example
|
|
27
33
|
* ```ts
|
|
28
34
|
* interface Item {
|
|
29
|
-
*
|
|
35
|
+
* nameField: string;
|
|
30
36
|
* }
|
|
31
37
|
*
|
|
32
|
-
* const items: Item[] = [{
|
|
38
|
+
* const items: Item[] = [{ nameField: 'Hello' }, { nameField: 'World' }];
|
|
33
39
|
*
|
|
34
40
|
* alphaNumericSort(items, {
|
|
35
|
-
* extractor: (item) => item.
|
|
41
|
+
* extractor: (item) => item.nameField,
|
|
36
42
|
* });
|
|
37
43
|
* ```
|
|
38
44
|
*
|
|
@@ -87,23 +93,23 @@ export interface AlphaNumericSortOptions<T> {
|
|
|
87
93
|
* @param list - The list of strings to sort
|
|
88
94
|
* @returns a new sorted list
|
|
89
95
|
*/
|
|
90
|
-
export function alphaNumericSort<T extends
|
|
96
|
+
export function alphaNumericSort<T extends AutomaticTextExtraction>(
|
|
91
97
|
list: readonly T[],
|
|
92
|
-
options?:
|
|
98
|
+
options?: AlphaNumericSortOptions<T>
|
|
93
99
|
): readonly T[];
|
|
94
100
|
/**
|
|
95
101
|
* @example Simple Example
|
|
96
102
|
* ```ts
|
|
97
103
|
* interface Item {
|
|
98
|
-
*
|
|
104
|
+
* nameField: string;
|
|
99
105
|
* }
|
|
100
106
|
*
|
|
101
|
-
* const items: Item[] = [{
|
|
107
|
+
* const items: Item[] = [{ nameField: "World" }, { nameField: "Hello" }];
|
|
102
108
|
*
|
|
103
109
|
* const sorted = alphaNumericSort(items, {
|
|
104
|
-
* extractor: (item) => item.
|
|
110
|
+
* extractor: (item) => item.nameField,
|
|
105
111
|
* });
|
|
106
|
-
* // sorted == [{
|
|
112
|
+
* // sorted == [{ nameField: "Hello" }, { nameField: "World" }]
|
|
107
113
|
* ```
|
|
108
114
|
*
|
|
109
115
|
* @param list - The list of items to sort
|
|
@@ -119,7 +125,7 @@ export function alphaNumericSort<T>(
|
|
|
119
125
|
): readonly T[] {
|
|
120
126
|
const {
|
|
121
127
|
compare = DEFAULT_COLLATOR.compare,
|
|
122
|
-
extractor =
|
|
128
|
+
extractor = DEFAULT_EXTRACTOR,
|
|
123
129
|
descending = false,
|
|
124
130
|
} = options;
|
|
125
131
|
|