bc518174
王天杨
提交两个项目文件
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
import * as React from 'react';
import { SxProps } from '@mui/system';
import { OverridableStringUnion } from '@mui/types';
import { Theme } from "../styles/index.js";
import { RatingClasses } from "./ratingClasses.js";
import { OverridableComponent, OverrideProps } from "../OverridableComponent/index.js";
import { CreateSlotsAndSlotProps, SlotProps } from "../utils/types.js";
export interface IconContainerProps extends React.HTMLAttributes<HTMLSpanElement> {
value: number;
}
export interface RatingPropsSizeOverrides {}
export interface RatingRootSlotPropsOverrides {}
export interface RatingLabelSlotPropsOverrides {}
export interface RatingIconSlotPropsOverrides {}
export interface RatingDecimalSlotPropsOverrides {}
export interface RatingSlots {
/**
* The component used for the root slot.
* @default 'span'
*/
root: React.ElementType;
/**
* The component used for the label slot.
* @default 'label'
*/
label: React.ElementType;
/**
* The component used for the icon slot.
* @default 'span'
*/
icon: React.ElementType;
/**
* The component used for the decimal slot.
* @default 'span'
*/
decimal: React.ElementType;
}
export type RatingSlotsAndSlotProps = CreateSlotsAndSlotProps<RatingSlots, {
/**
* Props forwarded to the root slot.
* By default, the available props are based on the span element.
*/
root: SlotProps<'span', RatingRootSlotPropsOverrides, RatingOwnerState>;
/**
* Props forwarded to the label slot.
* By default, the available props are based on the label element.
*/
label: SlotProps<'label', RatingLabelSlotPropsOverrides, RatingOwnerState>;
/**
* Props forwarded to the icon slot.
* By default, the available props are based on the span element.
*/
icon: SlotProps<'span', RatingIconSlotPropsOverrides, RatingOwnerState>;
/**
* Props forwarded to the decimal slot.
* By default, the available props are based on the span element.
*/
decimal: SlotProps<'span', RatingDecimalSlotPropsOverrides, RatingOwnerState>;
}>;
export interface RatingOwnProps extends RatingSlotsAndSlotProps {
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<RatingClasses>;
/**
* The default value. Use when the component is not controlled.
* @default null
*/
defaultValue?: number;
/**
* If `true`, the component is disabled.
* @default false
*/
disabled?: boolean;
/**
* The icon to display when empty.
* @default <StarBorder fontSize="inherit" />
*/
emptyIcon?: React.ReactNode;
/**
* The label read when the rating input is empty.
* @default 'Empty'
*/
emptyLabelText?: React.ReactNode;
/**
* Accepts a function which returns a string value that provides a user-friendly name for the current value of the rating.
* This is important for screen reader users.
*
* For localization purposes, you can use the provided [translations](https://mui.com/material-ui/guides/localization/).
* @param {number} value The rating label's value to format.
* @returns {string}
* @default function defaultLabelText(value) {
* return `${value || '0'} Star${value !== 1 ? 's' : ''}`;
* }
*/
getLabelText?: (value: number) => string;
/**
* If `true`, only the selected icon will be highlighted.
* @default false
*/
highlightSelectedOnly?: boolean;
/**
* The icon to display.
* @default <Star fontSize="inherit" />
*/
icon?: React.ReactNode;
/**
* The component containing the icon.
* @deprecated Use `slotProps.icon.component` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
* @default function IconContainer(props) {
* const { value, ...other } = props;
* return <span {...other} />;
* }
*/
IconContainerComponent?: React.ElementType<IconContainerProps>;
/**
* Maximum rating.
* @default 5
*/
max?: number;
/**
* The name attribute of the radio `input` elements.
* This input `name` should be unique within the page.
* Being unique within a form is insufficient since the `name` is used to generate IDs.
*/
name?: string;
/**
* Callback fired when the value changes.
* @param {React.SyntheticEvent} event The event source of the callback.
* @param {number|null} value The new value.
*/
onChange?: (event: React.SyntheticEvent, value: number | null) => void;
/**
* Callback function that is fired when the hover state changes.
* @param {React.SyntheticEvent} event The event source of the callback.
* @param {number} value The new value.
*/
onChangeActive?: (event: React.SyntheticEvent, value: number) => void;
/**
* The minimum increment value change allowed.
* @default 1
*/
precision?: number;
/**
* Removes all hover effects and pointer events.
* @default false
*/
readOnly?: boolean;
/**
* The size of the component.
* @default 'medium'
*/
size?: OverridableStringUnion<'small' | 'medium' | 'large', RatingPropsSizeOverrides>;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme>;
/**
* The rating value.
*/
value?: number | null;
}
export interface RatingOwnerState extends Omit<RatingProps, 'slots' | 'slotProps'> {}
export type RatingTypeMap<AdditionalProps = {}, RootComponent extends React.ElementType = 'span'> = {
props: AdditionalProps & RatingOwnProps;
defaultComponent: RootComponent;
};
/**
*
* Demos:
*
* - [Rating](https://mui.com/material-ui/react-rating/)
*
* API:
*
* - [Rating API](https://mui.com/material-ui/api/rating/)
*/
declare const Rating: OverridableComponent<RatingTypeMap>;
export type RatingProps<RootComponent extends React.ElementType = RatingTypeMap['defaultComponent'], AdditionalProps = {}> = OverrideProps<RatingTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
component?: React.ElementType;
};
export default Rating;
|