@react-md/core 6.2.1 → 6.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_base.scss +1 -1
- package/dist/app-bar/styles.d.ts +0 -2
- package/dist/app-bar/styles.js.map +1 -1
- package/dist/autocomplete/types.d.ts +12 -0
- package/dist/autocomplete/types.js.map +1 -1
- package/dist/avatar/Avatar.d.ts +0 -10
- package/dist/avatar/Avatar.js.map +1 -1
- package/dist/avatar/styles.d.ts +10 -0
- package/dist/avatar/styles.js.map +1 -1
- package/dist/badge/Badge.d.ts +11 -0
- package/dist/badge/Badge.js.map +1 -1
- package/dist/badge/styles.d.ts +0 -8
- package/dist/badge/styles.js.map +1 -1
- package/dist/box/_box.scss +8 -8
- package/dist/box/styles.d.ts +9 -0
- package/dist/box/styles.js.map +1 -1
- package/dist/button/_button.scss +4 -0
- package/dist/button/styles.d.ts +5 -1
- package/dist/button/styles.js.map +1 -1
- package/dist/card/Card.d.ts +0 -7
- package/dist/card/Card.js.map +1 -1
- package/dist/card/styles.d.ts +6 -0
- package/dist/card/styles.js +8 -8
- package/dist/card/styles.js.map +1 -1
- package/dist/chip/Chip.d.ts +6 -13
- package/dist/chip/Chip.js.map +1 -1
- package/dist/chip/styles.d.ts +26 -1
- package/dist/chip/styles.js.map +1 -1
- package/dist/datetime/NativeDateField.d.ts +24 -0
- package/dist/datetime/NativeDateField.js +63 -0
- package/dist/datetime/NativeDateField.js.map +1 -0
- package/dist/datetime/NativeTimeField.d.ts +26 -0
- package/dist/datetime/NativeTimeField.js +63 -0
- package/dist/datetime/NativeTimeField.js.map +1 -0
- package/dist/datetime/useDateField.d.ts +120 -0
- package/dist/datetime/useDateField.js +35 -0
- package/dist/datetime/useDateField.js.map +1 -0
- package/dist/datetime/useTimeField.d.ts +124 -0
- package/dist/datetime/useTimeField.js +65 -0
- package/dist/datetime/useTimeField.js.map +1 -0
- package/dist/datetime/utils.d.ts +34 -0
- package/dist/datetime/utils.js +27 -0
- package/dist/datetime/utils.js.map +1 -0
- package/dist/dialog/styles.d.ts +5 -2
- package/dist/dialog/styles.js.map +1 -1
- package/dist/divider/styles.d.ts +1 -1
- package/dist/divider/styles.js.map +1 -1
- package/dist/draggable/utils.d.ts +3 -6
- package/dist/draggable/utils.js.map +1 -1
- package/dist/error-boundary/ErrorBoundary.js.map +1 -1
- package/dist/expansion-panel/ExpansionList.js +1 -1
- package/dist/expansion-panel/ExpansionList.js.map +1 -1
- package/dist/expansion-panel/useExpansionList.d.ts +2 -7
- package/dist/expansion-panel/useExpansionList.js.map +1 -1
- package/dist/files/validation.js.map +1 -1
- package/dist/form/FormMessage.js +3 -1
- package/dist/form/FormMessage.js.map +1 -1
- package/dist/form/FormMessageContainer.d.ts +2 -1
- package/dist/form/FormMessageContainer.js +3 -2
- package/dist/form/FormMessageContainer.js.map +1 -1
- package/dist/form/FormMessageCounter.d.ts +3 -2
- package/dist/form/FormMessageCounter.js +5 -2
- package/dist/form/FormMessageCounter.js.map +1 -1
- package/dist/form/InputToggle.js.map +1 -1
- package/dist/form/Label.d.ts +0 -10
- package/dist/form/Label.js.map +1 -1
- package/dist/form/Listbox.d.ts +3 -10
- package/dist/form/Listbox.js +8 -27
- package/dist/form/Listbox.js.map +1 -1
- package/dist/form/ListboxProvider.d.ts +17 -0
- package/dist/form/ListboxProvider.js +33 -1
- package/dist/form/ListboxProvider.js.map +1 -1
- package/dist/form/NativeSelect.js +1 -0
- package/dist/form/NativeSelect.js.map +1 -1
- package/dist/form/Slider.d.ts +4 -0
- package/dist/form/Slider.js.map +1 -1
- package/dist/form/Switch.js.map +1 -1
- package/dist/form/TextArea.js +1 -0
- package/dist/form/TextArea.js.map +1 -1
- package/dist/form/TextField.js +1 -0
- package/dist/form/TextField.js.map +1 -1
- package/dist/form/TextFieldContainer.d.ts +0 -13
- package/dist/form/TextFieldContainer.js.map +1 -1
- package/dist/form/_form-message.scss +13 -0
- package/dist/form/_select.scss +5 -1
- package/dist/form/_text-area.scss +2 -1
- package/dist/form/_text-field.scss +13 -3
- package/dist/form/formMessageContainerStyles.d.ts +7 -0
- package/dist/form/formMessageContainerStyles.js +4 -2
- package/dist/form/formMessageContainerStyles.js.map +1 -1
- package/dist/form/sliderUtils.d.ts +3 -7
- package/dist/form/sliderUtils.js.map +1 -1
- package/dist/form/types.d.ts +33 -0
- package/dist/form/types.js.map +1 -1
- package/dist/form/useCombobox.d.ts +6 -2
- package/dist/form/useCombobox.js +8 -9
- package/dist/form/useCombobox.js.map +1 -1
- package/dist/form/useFormReset.d.ts +4 -1
- package/dist/form/useFormReset.js +9 -4
- package/dist/form/useFormReset.js.map +1 -1
- package/dist/form/useNumberField.d.ts +5 -5
- package/dist/form/useNumberField.js +10 -2
- package/dist/form/useNumberField.js.map +1 -1
- package/dist/form/useSelectCombobox.js +2 -2
- package/dist/form/useSelectCombobox.js.map +1 -1
- package/dist/form/useTextField.d.ts +76 -59
- package/dist/form/useTextField.js +7 -1
- package/dist/form/useTextField.js.map +1 -1
- package/dist/interaction/types.d.ts +5 -1
- package/dist/interaction/types.js.map +1 -1
- package/dist/interaction/utils.d.ts +14 -0
- package/dist/interaction/utils.js +23 -12
- package/dist/interaction/utils.js.map +1 -1
- package/dist/link/Link.d.ts +0 -7
- package/dist/link/Link.js.map +1 -1
- package/dist/link/styles.d.ts +7 -0
- package/dist/link/styles.js.map +1 -1
- package/dist/list/List.d.ts +5 -20
- package/dist/list/List.js.map +1 -1
- package/dist/list/ListItem.d.ts +4 -38
- package/dist/list/ListItem.js.map +1 -1
- package/dist/list/listItemStyles.d.ts +24 -2
- package/dist/list/listItemStyles.js.map +1 -1
- package/dist/list/listStyles.d.ts +17 -2
- package/dist/list/listStyles.js.map +1 -1
- package/dist/menu/Menu.js.map +1 -1
- package/dist/menu/MenuBar.js +1 -1
- package/dist/menu/MenuBar.js.map +1 -1
- package/dist/menu/MenuItemTextField.d.ts +1 -2
- package/dist/menu/MenuItemTextField.js.map +1 -1
- package/dist/menu/MenuWidget.js +3 -2
- package/dist/menu/MenuWidget.js.map +1 -1
- package/dist/movement/constants.d.ts +10 -0
- package/dist/movement/constants.js +20 -4
- package/dist/movement/constants.js.map +1 -1
- package/dist/movement/types.d.ts +59 -10
- package/dist/movement/types.js.map +1 -1
- package/dist/movement/useKeyboardMovementProvider.d.ts +5 -1
- package/dist/movement/useKeyboardMovementProvider.js +171 -73
- package/dist/movement/useKeyboardMovementProvider.js.map +1 -1
- package/dist/navigation/NavItem.d.ts +4 -1
- package/dist/navigation/NavItem.js.map +1 -1
- package/dist/navigation/navItemStyles.d.ts +7 -0
- package/dist/navigation/navItemStyles.js.map +1 -1
- package/dist/overlay/Overlay.d.ts +4 -23
- package/dist/overlay/Overlay.js.map +1 -1
- package/dist/overlay/styles.d.ts +26 -8
- package/dist/overlay/styles.js.map +1 -1
- package/dist/progress/LinearProgress.d.ts +4 -9
- package/dist/progress/LinearProgress.js.map +1 -1
- package/dist/progress/circularProgressStyles.d.ts +6 -0
- package/dist/progress/circularProgressStyles.js.map +1 -1
- package/dist/progress/linearProgressStyles.d.ts +20 -5
- package/dist/progress/linearProgressStyles.js.map +1 -1
- package/dist/progress/types.d.ts +0 -9
- package/dist/progress/types.js.map +1 -1
- package/dist/segmented-button/SegmentedButton.d.ts +7 -12
- package/dist/segmented-button/SegmentedButton.js.map +1 -1
- package/dist/segmented-button/segmentedButtonStyles.d.ts +26 -3
- package/dist/segmented-button/segmentedButtonStyles.js.map +1 -1
- package/dist/sheet/Sheet.d.ts +0 -12
- package/dist/sheet/Sheet.js.map +1 -1
- package/dist/sheet/styles.d.ts +12 -0
- package/dist/sheet/styles.js.map +1 -1
- package/dist/snackbar/Toast.d.ts +2 -13
- package/dist/snackbar/Toast.js.map +1 -1
- package/dist/snackbar/ToastManager.js.map +1 -1
- package/dist/snackbar/toastStyles.d.ts +17 -2
- package/dist/snackbar/toastStyles.js.map +1 -1
- package/dist/tabs/Tab.d.ts +2 -41
- package/dist/tabs/Tab.js.map +1 -1
- package/dist/tabs/tabStyles.d.ts +45 -4
- package/dist/tabs/tabStyles.js.map +1 -1
- package/dist/tabs/useTabList.js +1 -1
- package/dist/tabs/useTabList.js.map +1 -1
- package/dist/test-utils/drag.d.ts +6 -9
- package/dist/test-utils/mocks/IntersectionObserver.js.map +1 -1
- package/dist/test-utils/mocks/ResizeObserver.js.map +1 -1
- package/dist/test-utils/utils/createFileList.js.map +1 -1
- package/dist/theme/_theme.scss +0 -1
- package/dist/theme/getDerivedTheme.d.ts +0 -24
- package/dist/theme/getDerivedTheme.js.map +1 -1
- package/dist/theme/types.d.ts +25 -0
- package/dist/theme/types.js.map +1 -1
- package/dist/tooltip/Tooltip.d.ts +4 -32
- package/dist/tooltip/Tooltip.js.map +1 -1
- package/dist/tooltip/styles.d.ts +38 -1
- package/dist/tooltip/styles.js +1 -1
- package/dist/tooltip/styles.js.map +1 -1
- package/dist/transition/SkeletonPlaceholder.d.ts +0 -7
- package/dist/transition/SkeletonPlaceholder.js.map +1 -1
- package/dist/transition/Slide.js.map +1 -1
- package/dist/transition/skeletonPlaceholderUtils.d.ts +7 -0
- package/dist/transition/skeletonPlaceholderUtils.js.map +1 -1
- package/dist/transition/useCarousel.d.ts +2 -2
- package/dist/transition/useCarousel.js.map +1 -1
- package/dist/transition/useMaxWidthTransition.d.ts +14 -2
- package/dist/transition/useMaxWidthTransition.js.map +1 -1
- package/dist/transition/useSlideTransition.d.ts +5 -0
- package/dist/transition/useSlideTransition.js.map +1 -1
- package/dist/tree/Tree.d.ts +5 -9
- package/dist/tree/Tree.js +1 -1
- package/dist/tree/Tree.js.map +1 -1
- package/dist/tree/styles.d.ts +9 -1
- package/dist/tree/styles.js.map +1 -1
- package/dist/tree/useTreeMovement.d.ts +2 -1
- package/dist/tree/useTreeMovement.js +2 -1
- package/dist/tree/useTreeMovement.js.map +1 -1
- package/dist/types.d.ts +14 -0
- package/dist/types.js.map +1 -1
- package/dist/typography/Mark.d.ts +4 -1
- package/dist/typography/Mark.js.map +1 -1
- package/dist/typography/TextContainer.d.ts +0 -6
- package/dist/typography/TextContainer.js.map +1 -1
- package/dist/typography/markStyles.d.ts +5 -0
- package/dist/typography/markStyles.js.map +1 -1
- package/dist/typography/textContainerStyles.d.ts +6 -0
- package/dist/typography/textContainerStyles.js.map +1 -1
- package/dist/typography/typographyStyles.d.ts +9 -0
- package/dist/typography/typographyStyles.js.map +1 -1
- package/dist/useResizeObserver.js.map +1 -1
- package/dist/utils/getMiddleOfRange.d.ts +2 -3
- package/dist/utils/getMiddleOfRange.js.map +1 -1
- package/dist/utils/getPercentage.d.ts +2 -9
- package/dist/utils/getPercentage.js +1 -1
- package/dist/utils/getPercentage.js.map +1 -1
- package/dist/utils/getRangeSteps.d.ts +2 -3
- package/dist/utils/getRangeSteps.js +0 -3
- package/dist/utils/getRangeSteps.js.map +1 -1
- package/dist/utils/nearest.d.ts +2 -3
- package/dist/utils/nearest.js +0 -3
- package/dist/utils/nearest.js.map +1 -1
- package/dist/utils/trigonometry.d.ts +31 -0
- package/dist/utils/trigonometry.js +25 -0
- package/dist/utils/trigonometry.js.map +1 -0
- package/dist/window-splitter/WindowSplitter.d.ts +5 -19
- package/dist/window-splitter/WindowSplitter.js.map +1 -1
- package/dist/window-splitter/styles.d.ts +27 -3
- package/dist/window-splitter/styles.js.map +1 -1
- package/dist/window-splitter/useWindowSplitter.d.ts +1 -1
- package/dist/window-splitter/useWindowSplitter.js.map +1 -1
- package/package.json +8 -8
- package/src/app-bar/styles.ts +0 -2
- package/src/autocomplete/types.ts +17 -0
- package/src/avatar/Avatar.tsx +0 -11
- package/src/avatar/styles.ts +11 -0
- package/src/badge/Badge.tsx +12 -0
- package/src/badge/styles.ts +0 -9
- package/src/box/styles.ts +9 -0
- package/src/button/styles.ts +5 -1
- package/src/card/Card.tsx +0 -8
- package/src/card/styles.ts +15 -8
- package/src/chip/Chip.tsx +9 -15
- package/src/chip/styles.ts +29 -1
- package/src/datetime/NativeDateField.tsx +92 -0
- package/src/datetime/NativeTimeField.tsx +94 -0
- package/src/datetime/useDateField.ts +193 -0
- package/src/datetime/useTimeField.ts +233 -0
- package/src/datetime/utils.ts +48 -0
- package/src/dialog/styles.ts +5 -2
- package/src/divider/styles.ts +1 -1
- package/src/draggable/utils.ts +3 -6
- package/src/expansion-panel/ExpansionList.tsx +2 -1
- package/src/expansion-panel/useExpansionList.ts +6 -12
- package/src/form/FormMessage.tsx +4 -0
- package/src/form/FormMessageContainer.tsx +8 -4
- package/src/form/FormMessageCounter.tsx +17 -6
- package/src/form/InputToggle.tsx +2 -0
- package/src/form/Label.tsx +0 -11
- package/src/form/Listbox.tsx +18 -46
- package/src/form/ListboxProvider.ts +61 -1
- package/src/form/NativeSelect.tsx +1 -0
- package/src/form/Slider.tsx +6 -0
- package/src/form/Switch.tsx +2 -0
- package/src/form/TextArea.tsx +3 -0
- package/src/form/TextField.tsx +1 -0
- package/src/form/TextFieldContainer.tsx +0 -14
- package/src/form/formMessageContainerStyles.ts +10 -2
- package/src/form/sliderUtils.ts +3 -7
- package/src/form/types.ts +44 -0
- package/src/form/useCombobox.ts +15 -10
- package/src/form/useFormReset.ts +12 -5
- package/src/form/useNumberField.ts +17 -14
- package/src/form/useSelectCombobox.ts +2 -2
- package/src/form/useTextField.ts +102 -69
- package/src/interaction/types.ts +5 -1
- package/src/interaction/utils.ts +18 -20
- package/src/link/Link.tsx +0 -8
- package/src/link/styles.ts +8 -0
- package/src/list/List.tsx +7 -24
- package/src/list/ListItem.tsx +7 -43
- package/src/list/listItemStyles.ts +26 -2
- package/src/list/listStyles.ts +18 -2
- package/src/menu/Menu.tsx +2 -0
- package/src/menu/MenuBar.tsx +1 -1
- package/src/menu/MenuItemTextField.tsx +1 -3
- package/src/menu/MenuWidget.tsx +4 -2
- package/src/movement/constants.ts +26 -4
- package/src/movement/types.ts +84 -19
- package/src/movement/useKeyboardMovementProvider.ts +209 -95
- package/src/navigation/NavItem.tsx +6 -2
- package/src/navigation/navItemStyles.ts +8 -0
- package/src/overlay/Overlay.tsx +4 -26
- package/src/overlay/styles.ts +29 -10
- package/src/progress/LinearProgress.tsx +8 -10
- package/src/progress/circularProgressStyles.ts +7 -0
- package/src/progress/linearProgressStyles.ts +22 -5
- package/src/progress/types.ts +0 -10
- package/src/segmented-button/SegmentedButton.tsx +14 -15
- package/src/segmented-button/segmentedButtonStyles.ts +28 -3
- package/src/sheet/Sheet.tsx +0 -13
- package/src/sheet/styles.ts +13 -0
- package/src/snackbar/Toast.tsx +2 -15
- package/src/snackbar/toastStyles.ts +20 -2
- package/src/tabs/Tab.tsx +4 -49
- package/src/tabs/tabStyles.ts +52 -4
- package/src/tabs/useTabList.ts +1 -1
- package/src/test-utils/drag.ts +8 -12
- package/src/theme/getDerivedTheme.ts +0 -26
- package/src/theme/types.ts +26 -0
- package/src/tooltip/Tooltip.tsx +4 -36
- package/src/tooltip/styles.ts +43 -2
- package/src/transition/SkeletonPlaceholder.tsx +0 -8
- package/src/transition/Slide.tsx +2 -0
- package/src/transition/skeletonPlaceholderUtils.ts +8 -0
- package/src/transition/useCarousel.ts +2 -2
- package/src/transition/useMaxWidthTransition.ts +17 -2
- package/src/transition/useSlideTransition.ts +8 -0
- package/src/tree/Tree.tsx +6 -11
- package/src/tree/styles.ts +10 -1
- package/src/tree/useTreeMovement.ts +4 -0
- package/src/types.ts +16 -0
- package/src/typography/Mark.tsx +6 -2
- package/src/typography/TextContainer.tsx +0 -7
- package/src/typography/markStyles.ts +6 -0
- package/src/typography/textContainerStyles.ts +7 -0
- package/src/typography/typographyStyles.ts +10 -0
- package/src/utils/getMiddleOfRange.ts +2 -3
- package/src/utils/getPercentage.ts +3 -11
- package/src/utils/getRangeSteps.ts +3 -3
- package/src/utils/nearest.ts +3 -3
- package/src/utils/trigonometry.ts +46 -0
- package/src/window-splitter/WindowSplitter.tsx +9 -22
- package/src/window-splitter/styles.ts +31 -3
- package/src/window-splitter/useWindowSplitter.ts +3 -2
package/src/form/useTextField.ts
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
type FormMessageInputLengthCounterProps,
|
|
21
21
|
type FormMessageProps,
|
|
22
22
|
} from "./types.js";
|
|
23
|
+
import { useFormReset } from "./useFormReset.js";
|
|
23
24
|
import {
|
|
24
25
|
type ErrorMessageOptions,
|
|
25
26
|
type GetErrorIcon,
|
|
@@ -41,12 +42,12 @@ const noop = (): void => {
|
|
|
41
42
|
* @since 6.0.0 Added the `onInvalid` handler
|
|
42
43
|
*/
|
|
43
44
|
export type TextFieldChangeHandlers<
|
|
44
|
-
E extends HTMLInputElement | HTMLTextAreaElement,
|
|
45
|
+
E extends HTMLInputElement | HTMLTextAreaElement = HTMLInputElement,
|
|
45
46
|
> = Pick<HTMLAttributes<E>, "onBlur" | "onChange" | "onInvalid">;
|
|
46
47
|
|
|
47
48
|
/** @since 6.0.0 */
|
|
48
49
|
export interface ErrorChangeHandlerOptions<
|
|
49
|
-
E extends HTMLInputElement | HTMLTextAreaElement,
|
|
50
|
+
E extends HTMLInputElement | HTMLTextAreaElement = HTMLInputElement,
|
|
50
51
|
> {
|
|
51
52
|
/**
|
|
52
53
|
* A ref containing the `TextField` or `TextArea` if you need access to that
|
|
@@ -94,7 +95,7 @@ export interface ErrorChangeHandlerOptions<
|
|
|
94
95
|
* @since 6.0.0 Changed to object argument.
|
|
95
96
|
*/
|
|
96
97
|
export type ErrorChangeHandler<
|
|
97
|
-
E extends HTMLInputElement | HTMLTextAreaElement,
|
|
98
|
+
E extends HTMLInputElement | HTMLTextAreaElement = HTMLInputElement,
|
|
98
99
|
> = (options: ErrorChangeHandlerOptions<E>) => void;
|
|
99
100
|
|
|
100
101
|
/** @since 2.5.6 */
|
|
@@ -135,7 +136,7 @@ export interface ProvidedFormMessageProps
|
|
|
135
136
|
* @since 2.5.0
|
|
136
137
|
*/
|
|
137
138
|
export interface ProvidedTextFieldProps<
|
|
138
|
-
E extends HTMLInputElement | HTMLTextAreaElement,
|
|
139
|
+
E extends HTMLInputElement | HTMLTextAreaElement = HTMLInputElement,
|
|
139
140
|
> extends TextFieldValidationOptions,
|
|
140
141
|
TextFieldChangeHandlers<E>,
|
|
141
142
|
Required<Pick<TextFieldProps, "id" | "name" | "value" | "error">>,
|
|
@@ -153,7 +154,7 @@ export interface ProvidedTextFieldProps<
|
|
|
153
154
|
* @since 2.5.0
|
|
154
155
|
*/
|
|
155
156
|
export interface ProvidedTextFieldMessageProps<
|
|
156
|
-
E extends HTMLInputElement | HTMLTextAreaElement,
|
|
157
|
+
E extends HTMLInputElement | HTMLTextAreaElement = HTMLInputElement,
|
|
157
158
|
> extends ProvidedTextFieldProps<E> {
|
|
158
159
|
/**
|
|
159
160
|
* These props will be defined as long as the `disableMessage` prop is not
|
|
@@ -162,52 +163,30 @@ export interface ProvidedTextFieldMessageProps<
|
|
|
162
163
|
messageProps: ProvidedFormMessageProps;
|
|
163
164
|
}
|
|
164
165
|
|
|
165
|
-
/**
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
/**
|
|
167
|
+
* @since 6.3.0
|
|
168
|
+
*/
|
|
169
|
+
export interface TextFieldHookComponentOptions<
|
|
170
|
+
E extends HTMLInputElement | HTMLTextAreaElement = HTMLInputElement,
|
|
171
|
+
> {
|
|
170
172
|
/**
|
|
171
|
-
* An optional id to use for the `TextField` or `TextArea` that
|
|
172
|
-
* to create an id for the inline help/error messages.
|
|
173
|
+
* An optional id to use for the `TextField`, `Password`, or `TextArea` that
|
|
174
|
+
* is also used to create an id for the inline help/error messages.
|
|
173
175
|
*
|
|
174
176
|
* @defaultValue `"text-field-" + useId()`
|
|
175
177
|
*/
|
|
176
178
|
id?: string;
|
|
177
179
|
|
|
178
180
|
/**
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
* this hook and forwarding refs. If you need a ref to access the `<input>` or
|
|
182
|
-
* `<textarea>` DOM node, you can use the `fieldRef` returned by this hook
|
|
183
|
-
* instead.
|
|
184
|
-
*
|
|
185
|
-
* @example Accessing TextField DOM Node
|
|
186
|
-
* ```tsx
|
|
187
|
-
* import { TextField } from "@react-md/core/form/TextField";
|
|
188
|
-
* import { useTextField } from "@react-md/core/form/useTextField";
|
|
189
|
-
* import { useEffect } from "react";
|
|
190
|
-
* import type { ReactElement } from "react";
|
|
191
|
-
*
|
|
192
|
-
* function Example(): ReactElement {
|
|
193
|
-
* const { fieldRef, fieldProps } = useTextField({ name: "example" });
|
|
194
|
-
*
|
|
195
|
-
* useEffect(() => {
|
|
196
|
-
* fieldRef.current;
|
|
197
|
-
* // ^ HTMLInputElement | null
|
|
198
|
-
* }, [fieldRef]);
|
|
199
|
-
*
|
|
200
|
-
* return <TextField {...fieldProps} label="Example" />;
|
|
201
|
-
* }
|
|
202
|
-
* ```
|
|
181
|
+
* A unique name to attach to the `TextField`, `TextArea`, or `Password`
|
|
182
|
+
* component.
|
|
203
183
|
*/
|
|
204
|
-
|
|
184
|
+
name: string;
|
|
205
185
|
|
|
206
186
|
/**
|
|
207
|
-
*
|
|
208
|
-
* component.
|
|
187
|
+
* @since 6.3.0
|
|
209
188
|
*/
|
|
210
|
-
|
|
189
|
+
form?: string;
|
|
211
190
|
|
|
212
191
|
/**
|
|
213
192
|
* Boolean if the `FormMessage` should also display a counter for the
|
|
@@ -220,25 +199,6 @@ export interface TextFieldHookOptions<
|
|
|
220
199
|
*/
|
|
221
200
|
counter?: boolean;
|
|
222
201
|
|
|
223
|
-
/**
|
|
224
|
-
* This is used internally for the `useNumberField` hook and probably
|
|
225
|
-
* shouldn't be used otherwise. This is just passed into the
|
|
226
|
-
* {@link getErrorMessage} options and is used for additional validation.
|
|
227
|
-
*
|
|
228
|
-
* @defaultValue `false`
|
|
229
|
-
*/
|
|
230
|
-
isNumber?: boolean;
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* The default value to use for the `TextField` or `TextArea` one initial
|
|
234
|
-
* render. If you want to manually change the value to something else after
|
|
235
|
-
* the initial render, either change the `key` for the component containing
|
|
236
|
-
* this hook, or use the `setState` function returned from this hook.
|
|
237
|
-
*
|
|
238
|
-
* @defaultValue `""`
|
|
239
|
-
*/
|
|
240
|
-
defaultValue?: UseStateInitializer<string>;
|
|
241
|
-
|
|
242
202
|
/**
|
|
243
203
|
* An optional help text to display in the `FormMessage` component when there
|
|
244
204
|
* is not an error.
|
|
@@ -289,6 +249,15 @@ export interface TextFieldHookOptions<
|
|
|
289
249
|
*/
|
|
290
250
|
onErrorChange?: ErrorChangeHandler<E>;
|
|
291
251
|
|
|
252
|
+
/**
|
|
253
|
+
* Set to `true` to prevent the state from automatically resetting with a
|
|
254
|
+
* form's `reset` event.
|
|
255
|
+
*
|
|
256
|
+
* @defaultValue `false`
|
|
257
|
+
* @since 6.3.0
|
|
258
|
+
*/
|
|
259
|
+
disableReset?: boolean;
|
|
260
|
+
|
|
292
261
|
/**
|
|
293
262
|
* Set this to `true` to prevent the `errorMessage` from being
|
|
294
263
|
* rendered inline below the `TextField`.
|
|
@@ -316,9 +285,63 @@ export interface TextFieldHookOptions<
|
|
|
316
285
|
validationType?: TextFieldValidationType;
|
|
317
286
|
}
|
|
318
287
|
|
|
288
|
+
/** @since 2.5.6 */
|
|
289
|
+
export interface TextFieldHookOptions<
|
|
290
|
+
E extends HTMLInputElement | HTMLTextAreaElement = HTMLInputElement,
|
|
291
|
+
> extends TextFieldValidationOptions,
|
|
292
|
+
TextFieldHookComponentOptions<E>,
|
|
293
|
+
TextFieldChangeHandlers<E> {
|
|
294
|
+
/**
|
|
295
|
+
* An optional ref that should be merged with the ref returned by this hook.
|
|
296
|
+
* This should really only be used if you are making a custom component using
|
|
297
|
+
* this hook and forwarding refs. If you need a ref to access the `<input>` or
|
|
298
|
+
* `<textarea>` DOM node, you can use the `fieldRef` returned by this hook
|
|
299
|
+
* instead.
|
|
300
|
+
*
|
|
301
|
+
* @example Accessing TextField DOM Node
|
|
302
|
+
* ```tsx
|
|
303
|
+
* import { TextField } from "@react-md/core/form/TextField";
|
|
304
|
+
* import { useTextField } from "@react-md/core/form/useTextField";
|
|
305
|
+
* import { useEffect } from "react";
|
|
306
|
+
* import type { ReactElement } from "react";
|
|
307
|
+
*
|
|
308
|
+
* function Example(): ReactElement {
|
|
309
|
+
* const { fieldRef, fieldProps } = useTextField({ name: "example" });
|
|
310
|
+
*
|
|
311
|
+
* useEffect(() => {
|
|
312
|
+
* fieldRef.current;
|
|
313
|
+
* // ^ HTMLInputElement | null
|
|
314
|
+
* }, [fieldRef]);
|
|
315
|
+
*
|
|
316
|
+
* return <TextField {...fieldProps} label="Example" />;
|
|
317
|
+
* }
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
320
|
+
ref?: Ref<E>;
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* This is used internally for the `useNumberField` hook and probably
|
|
324
|
+
* shouldn't be used otherwise. This is just passed into the
|
|
325
|
+
* {@link getErrorMessage} options and is used for additional validation.
|
|
326
|
+
*
|
|
327
|
+
* @defaultValue `false`
|
|
328
|
+
*/
|
|
329
|
+
isNumber?: boolean;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* The default value to use for the `TextField` or `TextArea` one initial
|
|
333
|
+
* render. If you want to manually change the value to something else after
|
|
334
|
+
* the initial render, either change the `key` for the component containing
|
|
335
|
+
* this hook, or use the `setState` function returned from this hook.
|
|
336
|
+
*
|
|
337
|
+
* @defaultValue `""`
|
|
338
|
+
*/
|
|
339
|
+
defaultValue?: UseStateInitializer<string>;
|
|
340
|
+
}
|
|
341
|
+
|
|
319
342
|
/** @since 6.0.0 */
|
|
320
343
|
export interface TextFieldImplementation<
|
|
321
|
-
E extends HTMLInputElement | HTMLTextAreaElement,
|
|
344
|
+
E extends HTMLInputElement | HTMLTextAreaElement = HTMLInputElement,
|
|
322
345
|
> extends TextFieldHookState {
|
|
323
346
|
fieldRef: RefObject<E>;
|
|
324
347
|
reset: () => void;
|
|
@@ -328,14 +351,14 @@ export interface TextFieldImplementation<
|
|
|
328
351
|
|
|
329
352
|
/** @since 6.0.0 */
|
|
330
353
|
export interface TextFieldWithMessageImplementation<
|
|
331
|
-
E extends HTMLInputElement | HTMLTextAreaElement,
|
|
354
|
+
E extends HTMLInputElement | HTMLTextAreaElement = HTMLInputElement,
|
|
332
355
|
> extends TextFieldImplementation<E> {
|
|
333
356
|
fieldProps: ProvidedTextFieldMessageProps<E>;
|
|
334
357
|
}
|
|
335
358
|
|
|
336
359
|
/** @since 6.0.0 */
|
|
337
360
|
export interface ValidatedTextFieldImplementation<
|
|
338
|
-
E extends HTMLInputElement | HTMLTextAreaElement,
|
|
361
|
+
E extends HTMLInputElement | HTMLTextAreaElement = HTMLInputElement,
|
|
339
362
|
> extends TextFieldImplementation<E> {
|
|
340
363
|
fieldProps: ProvidedTextFieldProps<E> | ProvidedTextFieldMessageProps<E>;
|
|
341
364
|
}
|
|
@@ -365,7 +388,9 @@ export interface ValidatedTextFieldImplementation<
|
|
|
365
388
|
* @see {@link https://react-md.dev/components/text-field | TextField Demos}
|
|
366
389
|
* @see {@link https://react-md.dev/hooks/use-text-field | useTextField Demos}
|
|
367
390
|
*/
|
|
368
|
-
export function useTextField<
|
|
391
|
+
export function useTextField<
|
|
392
|
+
E extends HTMLInputElement | HTMLTextAreaElement = HTMLInputElement,
|
|
393
|
+
>(
|
|
369
394
|
options: TextFieldHookOptions<E> & { disableMessage: true }
|
|
370
395
|
): TextFieldImplementation<E>;
|
|
371
396
|
|
|
@@ -481,21 +506,22 @@ export function useTextField<E extends HTMLInputElement | HTMLTextAreaElement>(
|
|
|
481
506
|
* added the ability to display an inline counter and help text while disabling
|
|
482
507
|
* the error messaging.
|
|
483
508
|
*/
|
|
484
|
-
export function useTextField<
|
|
485
|
-
|
|
486
|
-
): TextFieldWithMessageImplementation<E>;
|
|
509
|
+
export function useTextField<
|
|
510
|
+
E extends HTMLInputElement | HTMLTextAreaElement = HTMLInputElement,
|
|
511
|
+
>(options: TextFieldHookOptions<E>): TextFieldWithMessageImplementation<E>;
|
|
487
512
|
/**
|
|
488
513
|
* @see {@link https://react-md.dev/components/text-field | TextField Demos}
|
|
489
514
|
* @see {@link https://react-md.dev/hooks/use-text-field | useTextField Demos}
|
|
490
515
|
* @since 6.0.0
|
|
491
516
|
*/
|
|
492
|
-
export function useTextField<
|
|
493
|
-
|
|
494
|
-
): ValidatedTextFieldImplementation<E> {
|
|
517
|
+
export function useTextField<
|
|
518
|
+
E extends HTMLInputElement | HTMLTextAreaElement = HTMLInputElement,
|
|
519
|
+
>(options: TextFieldHookOptions<E>): ValidatedTextFieldImplementation<E> {
|
|
495
520
|
const {
|
|
496
521
|
id: propId,
|
|
497
522
|
ref: propRef,
|
|
498
523
|
name,
|
|
524
|
+
form,
|
|
499
525
|
defaultValue = "",
|
|
500
526
|
isNumber = false,
|
|
501
527
|
required,
|
|
@@ -507,6 +533,7 @@ export function useTextField<E extends HTMLInputElement | HTMLTextAreaElement>(
|
|
|
507
533
|
onInvalid = noop,
|
|
508
534
|
counter = false,
|
|
509
535
|
helpText,
|
|
536
|
+
disableReset,
|
|
510
537
|
validationType = "recommended",
|
|
511
538
|
disableMessage = false,
|
|
512
539
|
disableMaxLength = false,
|
|
@@ -712,6 +739,12 @@ export function useTextField<E extends HTMLInputElement | HTMLTextAreaElement>(
|
|
|
712
739
|
};
|
|
713
740
|
}
|
|
714
741
|
|
|
742
|
+
useFormReset({
|
|
743
|
+
form,
|
|
744
|
+
onReset: disableReset ? undefined : reset,
|
|
745
|
+
elementRef: fieldRef,
|
|
746
|
+
});
|
|
747
|
+
|
|
715
748
|
return {
|
|
716
749
|
...state,
|
|
717
750
|
reset,
|
package/src/interaction/types.ts
CHANGED
|
@@ -8,7 +8,6 @@ import type {
|
|
|
8
8
|
|
|
9
9
|
declare module "react" {
|
|
10
10
|
interface CSSProperties {
|
|
11
|
-
"--rmd-ripple-background-color"?: string;
|
|
12
11
|
"--rmd-interaction-background-color"?: string;
|
|
13
12
|
"--rmd-hover-background-color"?: string;
|
|
14
13
|
"--rmd-focus-background-color"?: string;
|
|
@@ -16,6 +15,11 @@ declare module "react" {
|
|
|
16
15
|
"--rmd-selected-background-color"?: string;
|
|
17
16
|
"--rmd-focus-color"?: string;
|
|
18
17
|
"--rmd-focus-width"?: string | number;
|
|
18
|
+
"--rmd-ripple-inset"?: string | number;
|
|
19
|
+
"--rmd-ripple-border-radius"?: string | number;
|
|
20
|
+
"--rmd-ripple-background-color"?: string;
|
|
21
|
+
"--rmd-surface-inset"?: string | number;
|
|
22
|
+
"--rmd-surface-border-radius"?: string | number;
|
|
19
23
|
}
|
|
20
24
|
}
|
|
21
25
|
|
package/src/interaction/utils.ts
CHANGED
|
@@ -1,37 +1,35 @@
|
|
|
1
1
|
import { type KeyboardEvent, type MouseEvent, type TouchEvent } from "react";
|
|
2
2
|
|
|
3
3
|
import { findSizingContainer } from "../positioning/utils.js";
|
|
4
|
+
import { type Point } from "../types.js";
|
|
5
|
+
import { calcHypotenuse } from "../utils/trigonometry.js";
|
|
4
6
|
import {
|
|
5
7
|
type ElementInteractionState,
|
|
6
8
|
type RippleState,
|
|
7
9
|
type RippleStyle,
|
|
8
10
|
} from "./types.js";
|
|
9
11
|
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
* @since 6.3.0
|
|
15
|
+
*/
|
|
16
|
+
interface GetRadiusOptions extends Point {
|
|
17
|
+
height: number;
|
|
18
|
+
width: number;
|
|
13
19
|
}
|
|
14
20
|
|
|
15
21
|
/**
|
|
16
|
-
* Gets the current radius for a ripple based on the x and y page dimensions
|
|
17
|
-
* as well as the size of the element.
|
|
18
|
-
*
|
|
19
|
-
* This is really just in a separate file so I can easily mock this and write
|
|
20
|
-
* tests.
|
|
21
|
-
*
|
|
22
22
|
* @internal
|
|
23
|
+
* @since 6.3.0
|
|
23
24
|
*/
|
|
24
|
-
function getRadius(
|
|
25
|
-
x
|
|
26
|
-
|
|
27
|
-
offsetWidth: number,
|
|
28
|
-
offsetHeight: number
|
|
29
|
-
): number {
|
|
25
|
+
export function getRadius(options: GetRadiusOptions): number {
|
|
26
|
+
const { x, y, height, width } = options;
|
|
27
|
+
|
|
30
28
|
return Math.max(
|
|
31
|
-
calcHypotenuse(x, y),
|
|
32
|
-
calcHypotenuse(
|
|
33
|
-
calcHypotenuse(
|
|
34
|
-
calcHypotenuse(x,
|
|
29
|
+
calcHypotenuse({ x, y }),
|
|
30
|
+
calcHypotenuse({ x: width - x, y }),
|
|
31
|
+
calcHypotenuse({ x: width - x, y: height - y }),
|
|
32
|
+
calcHypotenuse({ x, y: height - y })
|
|
35
33
|
);
|
|
36
34
|
}
|
|
37
35
|
|
|
@@ -66,7 +64,7 @@ export function getRippleStyle(
|
|
|
66
64
|
y = pageY - (top + window.scrollY);
|
|
67
65
|
}
|
|
68
66
|
|
|
69
|
-
const radius = getRadius(x, y, width, height);
|
|
67
|
+
const radius = getRadius({ x, y, width, height });
|
|
70
68
|
const size = radius * 2;
|
|
71
69
|
|
|
72
70
|
return {
|
package/src/link/Link.tsx
CHANGED
|
@@ -6,14 +6,6 @@ import {
|
|
|
6
6
|
|
|
7
7
|
import { type LinkClassNameOptions, link } from "./styles.js";
|
|
8
8
|
|
|
9
|
-
declare module "react" {
|
|
10
|
-
interface CSSProperties {
|
|
11
|
-
"--rmd-link-color"?: string;
|
|
12
|
-
"--rmd-link-visited-color"?: string;
|
|
13
|
-
"--rmd-link-hover-color"?: string;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
9
|
/**
|
|
18
10
|
* @since 6.0.0
|
|
19
11
|
*/
|
package/src/link/styles.ts
CHANGED
|
@@ -4,6 +4,14 @@ import { bem } from "../utils/bem.js";
|
|
|
4
4
|
|
|
5
5
|
const styles = bem("rmd-link");
|
|
6
6
|
|
|
7
|
+
declare module "react" {
|
|
8
|
+
interface CSSProperties {
|
|
9
|
+
"--rmd-link-color"?: string;
|
|
10
|
+
"--rmd-link-visited-color"?: string;
|
|
11
|
+
"--rmd-link-hover-color"?: string;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
7
15
|
/** @since 6.0.0 */
|
|
8
16
|
export interface LinkClassNameOptions {
|
|
9
17
|
className?: string;
|
package/src/list/List.tsx
CHANGED
|
@@ -1,30 +1,20 @@
|
|
|
1
1
|
import { type HTMLAttributes, forwardRef } from "react";
|
|
2
2
|
|
|
3
|
-
import { list } from "./listStyles.js";
|
|
4
|
-
|
|
5
|
-
declare module "react" {
|
|
6
|
-
interface CSSProperties {
|
|
7
|
-
"--rmd-list-padding-h"?: string | number;
|
|
8
|
-
"--rmd-list-padding-v"?: string | number;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
3
|
+
import { type ListClassNameOptions, list } from "./listStyles.js";
|
|
11
4
|
|
|
12
5
|
export type ListElement = HTMLUListElement | HTMLOListElement;
|
|
13
6
|
|
|
14
|
-
|
|
7
|
+
/**
|
|
8
|
+
* @since 6.3.1 Extends the ListClassNameOptions
|
|
9
|
+
*/
|
|
10
|
+
export interface ListProps
|
|
11
|
+
extends HTMLAttributes<ListElement>,
|
|
12
|
+
ListClassNameOptions {
|
|
15
13
|
/**
|
|
16
14
|
* @defaultValue `"none"`
|
|
17
15
|
*/
|
|
18
16
|
role?: HTMLAttributes<ListElement>["role"];
|
|
19
17
|
|
|
20
|
-
/**
|
|
21
|
-
* Set to `true` to decrease the amount of padding and font size within the
|
|
22
|
-
* list.
|
|
23
|
-
*
|
|
24
|
-
* @defaultValue `false`
|
|
25
|
-
*/
|
|
26
|
-
dense?: boolean;
|
|
27
|
-
|
|
28
18
|
/**
|
|
29
19
|
* Set this to `true` to render as `<ol>` instead of `<ul>` when the children
|
|
30
20
|
* are in a specific order. For example: steps within a recipe.
|
|
@@ -32,13 +22,6 @@ export interface ListProps extends HTMLAttributes<ListElement> {
|
|
|
32
22
|
* @defaultValue `false`
|
|
33
23
|
*/
|
|
34
24
|
ordered?: boolean;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Set this to `true` to render horizontally instead of vertically.
|
|
38
|
-
*
|
|
39
|
-
* @defaultValue `false`
|
|
40
|
-
*/
|
|
41
|
-
horizontal?: boolean;
|
|
42
25
|
}
|
|
43
26
|
|
|
44
27
|
/**
|
package/src/list/ListItem.tsx
CHANGED
|
@@ -7,33 +7,21 @@ import { useElementInteraction } from "../interaction/useElementInteraction.js";
|
|
|
7
7
|
import { useHigherContrastChildren } from "../interaction/useHigherContrastChildren.js";
|
|
8
8
|
import { ListItemChildren } from "./ListItemChildren.js";
|
|
9
9
|
import { getListItemHeight } from "./getListItemHeight.js";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"--rmd-list-item-keyline"?: string | number;
|
|
16
|
-
"--rmd-list-item-padding-h"?: string | number;
|
|
17
|
-
"--rmd-list-item-padding-v"?: string | number;
|
|
18
|
-
"--rmd-list-item-height"?: string | number;
|
|
19
|
-
"--rmd-list-item-medium-height"?: string | number;
|
|
20
|
-
"--rmd-list-item-large-height"?: string | number;
|
|
21
|
-
"--rmd-list-item-extra-large-height"?: string | number;
|
|
22
|
-
"--rmd-list-item-multiline-clamp"?: string | number;
|
|
23
|
-
"--rmd-list-item-multiline-height"?: string | number;
|
|
24
|
-
"--rmd-list-item-media-size"?: string | number;
|
|
25
|
-
"--rmd-list-item-media-spacing"?: string | number;
|
|
26
|
-
"--rmd-list-item-text-multiline-height"?: string | number;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
10
|
+
import {
|
|
11
|
+
type BaseListItemClassNameOptions,
|
|
12
|
+
listItem,
|
|
13
|
+
} from "./listItemStyles.js";
|
|
14
|
+
import { type ListItemChildrenProps } from "./types.js";
|
|
29
15
|
|
|
30
16
|
/**
|
|
31
17
|
* @since 6.0.0 Renamed `threeLines` to `multiline` since it can
|
|
32
18
|
* support more than three lines of text.
|
|
19
|
+
* @since 6.3.1 Extends the BaseListItemClassNameOptions
|
|
33
20
|
*/
|
|
34
21
|
export interface ListItemProps
|
|
35
22
|
extends HTMLAttributes<HTMLLIElement>,
|
|
36
23
|
ListItemChildrenProps,
|
|
24
|
+
BaseListItemClassNameOptions,
|
|
37
25
|
ComponentWithRippleProps {
|
|
38
26
|
/**
|
|
39
27
|
* @defaultValue `"button"`
|
|
@@ -45,30 +33,6 @@ export interface ListItemProps
|
|
|
45
33
|
*/
|
|
46
34
|
tabIndex?: number;
|
|
47
35
|
|
|
48
|
-
/**
|
|
49
|
-
* @see {@link ListItemHeight}
|
|
50
|
-
* @defaultValue `"auto"`
|
|
51
|
-
*/
|
|
52
|
-
height?: ListItemHeight;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @defaultValue `false`
|
|
56
|
-
*/
|
|
57
|
-
multiline?: boolean;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* @defaultValue `false`
|
|
61
|
-
*/
|
|
62
|
-
disabled?: boolean;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Note: This does nothing if the `disabled` prop is not enabled.
|
|
66
|
-
*
|
|
67
|
-
* @defaultValue `false`
|
|
68
|
-
* @since 2.4.3
|
|
69
|
-
*/
|
|
70
|
-
disabledOpacity?: boolean;
|
|
71
|
-
|
|
72
36
|
/**
|
|
73
37
|
* Set this to `false` if the list item should not gain the interaction
|
|
74
38
|
* states: hover, focus, press, etc. This is kind of like being disabled
|
|
@@ -10,9 +10,27 @@ import {
|
|
|
10
10
|
|
|
11
11
|
const styles = bem("rmd-list-item");
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
declare module "react" {
|
|
14
|
+
interface CSSProperties {
|
|
15
|
+
"--rmd-list-item-keyline"?: string | number;
|
|
16
|
+
"--rmd-list-item-padding-h"?: string | number;
|
|
17
|
+
"--rmd-list-item-padding-v"?: string | number;
|
|
18
|
+
"--rmd-list-item-height"?: string | number;
|
|
19
|
+
"--rmd-list-item-medium-height"?: string | number;
|
|
20
|
+
"--rmd-list-item-large-height"?: string | number;
|
|
21
|
+
"--rmd-list-item-extra-large-height"?: string | number;
|
|
22
|
+
"--rmd-list-item-multiline-height"?: string | number;
|
|
23
|
+
"--rmd-list-item-media-size"?: string | number;
|
|
24
|
+
"--rmd-list-item-media-spacing"?: string | number;
|
|
25
|
+
"--rmd-list-item-text-multiline-height"?: string | number;
|
|
26
|
+
"--rmd-list-item-multiline-clamp"?: string | number;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** @since 6.3.1 */
|
|
31
|
+
export interface BaseListItemClassNameOptions {
|
|
15
32
|
className?: string;
|
|
33
|
+
|
|
16
34
|
/**
|
|
17
35
|
* @see {@link ListItemHeight}
|
|
18
36
|
* @defaultValue `"auto"`
|
|
@@ -25,7 +43,10 @@ export interface ListItemClassNameOptions {
|
|
|
25
43
|
multiline?: boolean;
|
|
26
44
|
|
|
27
45
|
/**
|
|
46
|
+
* Note: This does nothing if the `disabled` prop is not enabled.
|
|
47
|
+
*
|
|
28
48
|
* @defaultValue `false`
|
|
49
|
+
* @since 2.4.3
|
|
29
50
|
*/
|
|
30
51
|
disabled?: boolean;
|
|
31
52
|
|
|
@@ -36,7 +57,10 @@ export interface ListItemClassNameOptions {
|
|
|
36
57
|
* @since 2.4.3
|
|
37
58
|
*/
|
|
38
59
|
disabledOpacity?: boolean;
|
|
60
|
+
}
|
|
39
61
|
|
|
62
|
+
/** @since 6.0.0 */
|
|
63
|
+
export interface ListItemClassNameOptions extends BaseListItemClassNameOptions {
|
|
40
64
|
/**
|
|
41
65
|
* Set this to `false` if the list item should not gain the interaction
|
|
42
66
|
* states: hover, focus, press, etc. This is kind of like being disabled
|
package/src/list/listStyles.ts
CHANGED
|
@@ -4,14 +4,30 @@ import { bem } from "../utils/bem.js";
|
|
|
4
4
|
|
|
5
5
|
const styles = bem("rmd-list");
|
|
6
6
|
|
|
7
|
+
declare module "react" {
|
|
8
|
+
interface CSSProperties {
|
|
9
|
+
"--rmd-list-padding-h"?: string | number;
|
|
10
|
+
"--rmd-list-padding-v"?: string | number;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
7
14
|
/** @since 6.0.0 */
|
|
8
15
|
export interface ListClassNameOptions {
|
|
9
16
|
className?: string;
|
|
10
17
|
|
|
11
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Set to `true` to decrease the amount of padding and font size within the
|
|
20
|
+
* list.
|
|
21
|
+
*
|
|
22
|
+
* @defaultValue `false`
|
|
23
|
+
*/
|
|
12
24
|
dense?: boolean;
|
|
13
25
|
|
|
14
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Set this to `true` to render horizontally instead of vertically.
|
|
28
|
+
*
|
|
29
|
+
* @defaultValue `false`
|
|
30
|
+
*/
|
|
15
31
|
horizontal?: boolean;
|
|
16
32
|
}
|
|
17
33
|
|
package/src/menu/Menu.tsx
CHANGED
|
@@ -40,6 +40,8 @@ import { MenuWidget } from "./MenuWidget.js";
|
|
|
40
40
|
import { useMenuBarContext } from "./useMenuBarProvider.js";
|
|
41
41
|
import { getDefaultAnchor } from "./utils.js";
|
|
42
42
|
|
|
43
|
+
// NOTE: The augmentation is in this file since no types are imported from the
|
|
44
|
+
// `styles` file at this time
|
|
43
45
|
declare module "react" {
|
|
44
46
|
interface CSSProperties {
|
|
45
47
|
"--rmd-menu-background-color"?: string;
|
package/src/menu/MenuBar.tsx
CHANGED
|
@@ -89,6 +89,7 @@ export const MenuBar = forwardRef<HTMLUListElement, MenuBarProps>(
|
|
|
89
89
|
});
|
|
90
90
|
const { activeId, enableHoverMode } = menuBarContext;
|
|
91
91
|
const { movementProps, movementContext } = useKeyboardMovementProvider({
|
|
92
|
+
ref,
|
|
92
93
|
onClick,
|
|
93
94
|
onFocus,
|
|
94
95
|
onKeyDown,
|
|
@@ -110,7 +111,6 @@ export const MenuBar = forwardRef<HTMLUListElement, MenuBarProps>(
|
|
|
110
111
|
<List
|
|
111
112
|
{...remaining}
|
|
112
113
|
{...movementProps}
|
|
113
|
-
ref={ref}
|
|
114
114
|
role="menubar"
|
|
115
115
|
horizontal={horizontal}
|
|
116
116
|
>
|
|
@@ -8,15 +8,13 @@ import { type PropsWithRef } from "../types.js";
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @since 5.0.0
|
|
11
|
+
* @since 6.3.0 Removed the invalid `stretch` prop
|
|
11
12
|
*/
|
|
12
13
|
export interface MenuItemTextFieldProps extends TextFieldProps {
|
|
13
14
|
/**
|
|
14
15
|
* Any additional props or a `ref` to apply to the surrounding `<li>` element.
|
|
15
16
|
*/
|
|
16
17
|
liProps?: PropsWithRef<HTMLAttributes<HTMLLIElement>>;
|
|
17
|
-
|
|
18
|
-
/** @defaultValue `true` */
|
|
19
|
-
stretch?: boolean;
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
/**
|
package/src/menu/MenuWidget.tsx
CHANGED
|
@@ -84,6 +84,7 @@ export const MenuWidget = forwardRef<HTMLDivElement, MenuWidgetProps>(
|
|
|
84
84
|
defaultActiveId: id,
|
|
85
85
|
});
|
|
86
86
|
const { movementProps, movementContext } = useKeyboardMovementProvider({
|
|
87
|
+
ref,
|
|
87
88
|
onClick,
|
|
88
89
|
onFocus(event) {
|
|
89
90
|
onFocus(event);
|
|
@@ -110,9 +111,10 @@ export const MenuWidget = forwardRef<HTMLDivElement, MenuWidgetProps>(
|
|
|
110
111
|
<div
|
|
111
112
|
aria-orientation={horizontal ? "horizontal" : undefined}
|
|
112
113
|
{...remaining}
|
|
113
|
-
{...(isListbox
|
|
114
|
+
{...(isListbox
|
|
115
|
+
? { onClick, onFocus, onKeyDown, ref }
|
|
116
|
+
: movementProps)}
|
|
114
117
|
id={id}
|
|
115
|
-
ref={ref}
|
|
116
118
|
role={role}
|
|
117
119
|
className={menu({
|
|
118
120
|
className,
|