@react-md/core 7.0.1 → 7.0.3
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/_base.scss +10 -4
- package/dist/form/Select.js +1 -2
- package/dist/form/Select.js.map +1 -1
- package/dist/form/utils.js +1 -1
- package/dist/form/utils.js.map +1 -1
- package/dist/icon/_icon.scss +19 -0
- package/dist/icon/configureMaterialSymbols.d.ts +1 -0
- package/dist/icon/configureMaterialSymbols.js +64 -0
- package/dist/icon/configureMaterialSymbols.js.map +1 -0
- package/dist/icon/getMaterialSymbolOption.d.ts +6 -0
- package/dist/icon/getMaterialSymbolOption.js +14 -0
- package/dist/icon/getMaterialSymbolOption.js.map +1 -0
- package/dist/icon/getMaterialSymbolsUrl.d.ts +58 -0
- package/dist/icon/getMaterialSymbolsUrl.js +32 -0
- package/dist/icon/getMaterialSymbolsUrl.js.map +1 -0
- package/dist/icon/symbols.d.ts +4 -0
- package/dist/icon/symbols.js +25 -0
- package/dist/icon/symbols.js.map +1 -0
- package/dist/layout/useExpandableLayout.d.ts +2 -2
- package/dist/layout/useExpandableLayout.js.map +1 -1
- package/dist/menu/MenuItemButton.js +1 -0
- package/dist/menu/MenuItemButton.js.map +1 -1
- package/dist/menu/MenuItemFileInput.js +1 -2
- package/dist/menu/MenuItemFileInput.js.map +1 -1
- package/dist/menu/MenuItemInputToggle.js +1 -1
- package/dist/menu/MenuItemInputToggle.js.map +1 -1
- package/dist/positioning/utils.js +0 -4
- package/dist/positioning/utils.js.map +1 -1
- package/dist/theme/_theme.scss +42 -3
- package/dist/transition/useMaxWidthTransition.d.ts +1 -1
- package/dist/transition/useMaxWidthTransition.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.js.map +1 -1
- package/dist/window-splitter/styles.d.ts +2 -2
- package/dist/window-splitter/styles.js.map +1 -1
- package/package.json +51 -42
- package/src/form/Select.tsx +1 -2
- package/src/form/utils.ts +1 -1
- package/src/icon/configureMaterialSymbols.tsx +25 -0
- package/src/icon/getMaterialSymbolOption.ts +20 -0
- package/src/icon/getMaterialSymbolsUrl.ts +112 -0
- package/src/icon/symbols.ts +26 -0
- package/src/layout/useExpandableLayout.ts +6 -2
- package/src/menu/MenuItemButton.tsx +1 -0
- package/src/menu/MenuItemFileInput.tsx +1 -2
- package/src/menu/MenuItemInputToggle.tsx +1 -1
- package/src/positioning/utils.ts +0 -4
- package/src/transition/useMaxWidthTransition.ts +1 -1
- package/src/types.ts +6 -0
- package/src/window-splitter/styles.ts +2 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type GoogleFontsAPIValueOrRange } from "./getMaterialSymbolsUrl.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
* @since 7.1.0
|
|
6
|
+
*/
|
|
7
|
+
export function getMaterialSymbolOption<T extends number>(
|
|
8
|
+
value: GoogleFontsAPIValueOrRange<T> | undefined,
|
|
9
|
+
fallback: T
|
|
10
|
+
): string {
|
|
11
|
+
if (!value) {
|
|
12
|
+
return `${fallback}`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (typeof value === "number") {
|
|
16
|
+
return `${value}`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return `${value.min}..${value.max}`;
|
|
20
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { alphaNumericSort } from "../utils/alphaNumericSort.js";
|
|
2
|
+
import { getMaterialSymbolOption } from "./getMaterialSymbolOption.js";
|
|
3
|
+
import {
|
|
4
|
+
type MaterialSymbolFamily,
|
|
5
|
+
type MaterialSymbolName,
|
|
6
|
+
} from "./material.js";
|
|
7
|
+
import {
|
|
8
|
+
MATERIAL_CONFIG,
|
|
9
|
+
type MaterialSymbolFill,
|
|
10
|
+
type MaterialSymbolGrade,
|
|
11
|
+
type MaterialSymbolOpticalSize,
|
|
12
|
+
type MaterialSymbolWeight,
|
|
13
|
+
} from "./materialConfig.js";
|
|
14
|
+
import { DEFAULT_MATERIAL_SYMBOL_NAMES } from "./symbols.js";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @since 7.1.0
|
|
18
|
+
*/
|
|
19
|
+
export type GoogleFontsAPIValueOrRange<T extends number> =
|
|
20
|
+
| T
|
|
21
|
+
| { min: T; max: T };
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @since 7.1.0
|
|
25
|
+
*/
|
|
26
|
+
export interface MaterialSymbolsGoogleFontUrlOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Provide this value if the `MATERIAL_CONFIG.family` is not the default.
|
|
29
|
+
*
|
|
30
|
+
* @defaultValue `"outlined"`
|
|
31
|
+
*/
|
|
32
|
+
family?: MaterialSymbolFamily | readonly MaterialSymbolFamily[];
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Provide this value if the `MATERIAL_CONFIG.fill` is not the default.
|
|
36
|
+
*
|
|
37
|
+
* @defaultValue `0`
|
|
38
|
+
*/
|
|
39
|
+
fill?: GoogleFontsAPIValueOrRange<MaterialSymbolFill>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Provide this value if the `MATERIAL_CONFIG.grade` is not the default.
|
|
43
|
+
*
|
|
44
|
+
* @defaultValue `0`
|
|
45
|
+
*/
|
|
46
|
+
grade?: GoogleFontsAPIValueOrRange<MaterialSymbolGrade>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Provide this value if the `MATERIAL_CONFIG.weight` is not the default.
|
|
50
|
+
*
|
|
51
|
+
* @defaultValue `400`
|
|
52
|
+
*/
|
|
53
|
+
weight?: GoogleFontsAPIValueOrRange<MaterialSymbolWeight>;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Provide this value if the `MATERIAL_CONFIG.opticalSize` is not the default.
|
|
57
|
+
*
|
|
58
|
+
* @defaultValue `48`
|
|
59
|
+
*/
|
|
60
|
+
opticalSize?: GoogleFontsAPIValueOrRange<MaterialSymbolOpticalSize>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @since 7.1.0
|
|
65
|
+
*/
|
|
66
|
+
export interface MaterialSymbolsUrlOptions extends MaterialSymbolsGoogleFontUrlOptions {
|
|
67
|
+
/**
|
|
68
|
+
* @see {@link DEFAULT_MATERIAL_SYMBOL_NAMES}
|
|
69
|
+
* @defaultValue `DEFAULT_MATERIAL_SYMBOL_NAMES`
|
|
70
|
+
*/
|
|
71
|
+
names?: readonly MaterialSymbolName[];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @since 7.1.0
|
|
76
|
+
*/
|
|
77
|
+
export function getMaterialSymbolsUrl(
|
|
78
|
+
options: MaterialSymbolsUrlOptions = {}
|
|
79
|
+
): string {
|
|
80
|
+
// the names have to be sorted for the google fonts api
|
|
81
|
+
const names = alphaNumericSort([
|
|
82
|
+
...new Set(options.names ?? DEFAULT_MATERIAL_SYMBOL_NAMES),
|
|
83
|
+
]);
|
|
84
|
+
const fill = getMaterialSymbolOption(options.fill, MATERIAL_CONFIG.fill);
|
|
85
|
+
const grade = getMaterialSymbolOption(options.grade, MATERIAL_CONFIG.grade);
|
|
86
|
+
const weight = getMaterialSymbolOption(
|
|
87
|
+
options.weight,
|
|
88
|
+
MATERIAL_CONFIG.weight
|
|
89
|
+
);
|
|
90
|
+
const opticalSize = getMaterialSymbolOption(
|
|
91
|
+
options.opticalSize,
|
|
92
|
+
MATERIAL_CONFIG.opticalSize
|
|
93
|
+
);
|
|
94
|
+
const specs = `:opsz,wght,FILL,GRAD@${opticalSize},${weight},${fill},${grade}`;
|
|
95
|
+
|
|
96
|
+
const families =
|
|
97
|
+
typeof options.family === "string" || options.family === undefined
|
|
98
|
+
? [options.family ?? MATERIAL_CONFIG.family]
|
|
99
|
+
: options.family;
|
|
100
|
+
let familiesQs = "";
|
|
101
|
+
for (const [i, family] of families.entries()) {
|
|
102
|
+
const variant = family.charAt(0).toUpperCase() + family.slice(1);
|
|
103
|
+
familiesQs += (i === 0 ? "" : "&") + "family=Material+Symbols+" + variant;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
let iconNames = "";
|
|
107
|
+
if (names.length > 0) {
|
|
108
|
+
iconNames = `&icon_names=${names.join(",")}`;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return `https://fonts.googleapis.com/css2?${familiesQs}${specs}${iconNames}`;
|
|
112
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type MaterialSymbolName } from "./material.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @since 7.1.0
|
|
5
|
+
*/
|
|
6
|
+
export const DEFAULT_MATERIAL_SYMBOL_NAMES = [
|
|
7
|
+
"keyboard_arrow_left",
|
|
8
|
+
"close_small",
|
|
9
|
+
"close",
|
|
10
|
+
"check_box_outline_blank",
|
|
11
|
+
"check_box",
|
|
12
|
+
"indeterminate_check_box",
|
|
13
|
+
"arrow_drop_down",
|
|
14
|
+
"error",
|
|
15
|
+
"keyboard_arrow_down",
|
|
16
|
+
"keyboard_arrow_right",
|
|
17
|
+
"menu",
|
|
18
|
+
"notifications",
|
|
19
|
+
"visibility",
|
|
20
|
+
"radio_button_unchecked",
|
|
21
|
+
"radio_button_checked",
|
|
22
|
+
"cancel",
|
|
23
|
+
"check",
|
|
24
|
+
"arrow_upward",
|
|
25
|
+
"upload",
|
|
26
|
+
] satisfies readonly MaterialSymbolName[];
|
|
@@ -9,7 +9,11 @@ import { type AppSize } from "../media-queries/appSize.js";
|
|
|
9
9
|
import { MEDIA_QUERY_CONFIG } from "../media-queries/config.js";
|
|
10
10
|
import { useMediaQuery } from "../media-queries/useMediaQuery.js";
|
|
11
11
|
import { type CSSTransitionElementProps } from "../transition/types.js";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
type CssPosition,
|
|
14
|
+
type LiteralStringUnion,
|
|
15
|
+
type UseStateInitializer,
|
|
16
|
+
} from "../types.js";
|
|
13
17
|
import { useToggle } from "../useToggle.js";
|
|
14
18
|
import { useDevEffect } from "../utils/useDevEffect.js";
|
|
15
19
|
import { type LayoutNavProps } from "./LayoutNav.js";
|
|
@@ -75,7 +79,7 @@ export interface ExpandableLayoutOptions extends TemporaryLayoutOptions {
|
|
|
75
79
|
*
|
|
76
80
|
* @defaultValue `"tablet"`
|
|
77
81
|
*/
|
|
78
|
-
temporaryUntil?: "tablet" | "desktop"
|
|
82
|
+
temporaryUntil?: LiteralStringUnion<"tablet" | "desktop">;
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
/**
|
|
@@ -98,7 +98,7 @@ export function MenuItemFileInput(props: MenuItemFileInputProps): ReactElement {
|
|
|
98
98
|
// elements to be removed from the DOM, a normal `<input type="file" />`
|
|
99
99
|
// can't be used. Instead, create a temporary file input element and
|
|
100
100
|
// click it to trigger the file upload behavior.
|
|
101
|
-
|
|
101
|
+
const input = document.createElement("input");
|
|
102
102
|
input.type = "file";
|
|
103
103
|
if (accept) {
|
|
104
104
|
input.accept = accept;
|
|
@@ -114,7 +114,6 @@ export function MenuItemFileInput(props: MenuItemFileInputProps): ReactElement {
|
|
|
114
114
|
// @ts-expect-error
|
|
115
115
|
input.addEventListener("change", onChange);
|
|
116
116
|
input.click();
|
|
117
|
-
input = null;
|
|
118
117
|
}}
|
|
119
118
|
>
|
|
120
119
|
{children}
|
|
@@ -181,7 +181,7 @@ export function MenuItemInputToggle(
|
|
|
181
181
|
MenuItemCheckboxProps & { type: "checkbox" | "radio" | "switch" };
|
|
182
182
|
const id = useEnsuredId(propId, "menu-item");
|
|
183
183
|
|
|
184
|
-
let icon
|
|
184
|
+
let icon: ReactElement;
|
|
185
185
|
if (type === "switch") {
|
|
186
186
|
icon = (
|
|
187
187
|
<SwitchTrack
|
package/src/positioning/utils.ts
CHANGED
|
@@ -228,8 +228,6 @@ export function getTransformOrigin(options: TransformOriginOptions): string {
|
|
|
228
228
|
case "inner-right":
|
|
229
229
|
x = "100%";
|
|
230
230
|
break;
|
|
231
|
-
default:
|
|
232
|
-
x = "0";
|
|
233
231
|
}
|
|
234
232
|
|
|
235
233
|
let y = "0";
|
|
@@ -248,8 +246,6 @@ export function getTransformOrigin(options: TransformOriginOptions): string {
|
|
|
248
246
|
case "top":
|
|
249
247
|
y = "0";
|
|
250
248
|
break;
|
|
251
|
-
default:
|
|
252
|
-
y = "0";
|
|
253
249
|
}
|
|
254
250
|
}
|
|
255
251
|
|
|
@@ -7,7 +7,7 @@ import { Children, cloneElement, isValidElement } from "react";
|
|
|
7
7
|
import { maxWidthTransition } from "./maxWidthTransition.js";
|
|
8
8
|
|
|
9
9
|
declare module "react" {
|
|
10
|
-
interface
|
|
10
|
+
interface CSSProperties {
|
|
11
11
|
"--rmd-max-width"?: string | number;
|
|
12
12
|
"--rmd-max-width-gap"?: string | number;
|
|
13
13
|
}
|
package/src/types.ts
CHANGED
|
@@ -240,6 +240,12 @@ export type OverridableStringUnion<
|
|
|
240
240
|
[K in keyof Overrides]: Overrides[K] extends false ? never : K;
|
|
241
241
|
}[keyof Overrides];
|
|
242
242
|
|
|
243
|
+
/**
|
|
244
|
+
* @see https://github.com/microsoft/TypeScript/issues/29729#issuecomment-471566609
|
|
245
|
+
* @since 7.1.0
|
|
246
|
+
*/
|
|
247
|
+
export type LiteralStringUnion<T extends U, U = string> = T | (U & {});
|
|
248
|
+
|
|
243
249
|
/**
|
|
244
250
|
* @since 6.2.0
|
|
245
251
|
*/
|
|
@@ -12,8 +12,8 @@ declare module "react" {
|
|
|
12
12
|
"--rmd-window-splitter-y"?: string | number;
|
|
13
13
|
"--rmd-window-splitter-z"?: string | number;
|
|
14
14
|
"--rmd-window-splitter-position"?: string | number;
|
|
15
|
-
"--rmd-window-splitter-
|
|
16
|
-
"--rmd-window-splitter-inactive-
|
|
15
|
+
"--rmd-window-splitter-background-color"?: string;
|
|
16
|
+
"--rmd-window-splitter-inactive-background-color"?: string;
|
|
17
17
|
"--rmd-window-splitter-opacity"?: string | number;
|
|
18
18
|
}
|
|
19
19
|
}
|