Skip to content

Commit

Permalink
proptypes
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldudak committed Jul 26, 2023
1 parent d1c2433 commit 4a74014
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 56 deletions.
52 changes: 29 additions & 23 deletions docs/pages/base-ui/api/use-autocomplete.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"parameters": {
"options": {
"type": { "name": "ReadonlyArray<T>", "description": "ReadonlyArray<T>" },
"type": { "name": "ReadonlyArray<Value>", "description": "ReadonlyArray<Value>" },
"required": true
},
"autoComplete": { "type": { "name": "boolean", "description": "boolean" }, "default": "false" },
Expand All @@ -28,8 +28,8 @@
"componentName": { "type": { "name": "string", "description": "string" } },
"defaultValue": {
"type": {
"name": "AutocompleteValue<T, Multiple, DisableClearable, FreeSolo>",
"description": "AutocompleteValue<T, Multiple, DisableClearable, FreeSolo>"
"name": "AutocompleteValue<Value, Multiple, DisableClearable, FreeSolo>",
"description": "AutocompleteValue<Value, Multiple, DisableClearable, FreeSolo>"
},
"default": "props.multiple ? [] : null"
},
Expand All @@ -52,8 +52,8 @@
},
"filterOptions": {
"type": {
"name": "(options: T[], state: FilterOptionsState<T>) => T[]",
"description": "(options: T[], state: FilterOptionsState<T>) => T[]"
"name": "(options: Value[], state: FilterOptionsState<Value>) => Value[]",
"description": "(options: Value[], state: FilterOptionsState<Value>) => Value[]"
},
"default": "createFilterOptions()"
},
Expand All @@ -63,17 +63,23 @@
},
"freeSolo": { "type": { "name": "FreeSolo", "description": "FreeSolo" }, "default": "false" },
"getOptionDisabled": {
"type": { "name": "(option: T) => boolean", "description": "(option: T) => boolean" }
"type": {
"name": "(option: Value) => boolean",
"description": "(option: Value) => boolean"
}
},
"getOptionLabel": {
"type": {
"name": "(option: T | AutocompleteFreeSoloValueMapping<FreeSolo>) => string",
"description": "(option: T | AutocompleteFreeSoloValueMapping<FreeSolo>) => string"
"name": "(option: Value | AutocompleteFreeSoloValueMapping<FreeSolo>) => string",
"description": "(option: Value | AutocompleteFreeSoloValueMapping<FreeSolo>) => string"
},
"default": "(option) => option.label ?? option"
},
"groupBy": {
"type": { "name": "(option: T) => string", "description": "(option: T) => string" }
"type": {
"name": "(option: Value) => string",
"description": "(option: Value) => string"
}
},
"handleHomeEndKeys": {
"type": { "name": "boolean", "description": "boolean" },
Expand All @@ -87,15 +93,15 @@
"inputValue": { "type": { "name": "string", "description": "string" } },
"isOptionEqualToValue": {
"type": {
"name": "(option: T, value: T) => boolean",
"description": "(option: T, value: T) => boolean"
"name": "(option: Value, value: Value) => boolean",
"description": "(option: Value, value: Value) => boolean"
}
},
"multiple": { "type": { "name": "Multiple", "description": "Multiple" }, "default": "false" },
"onChange": {
"type": {
"name": "(event: React.SyntheticEvent, value: AutocompleteValue<T, Multiple, DisableClearable, FreeSolo>, reason: AutocompleteChangeReason, details?: AutocompleteChangeDetails<T>) => void",
"description": "(event: React.SyntheticEvent, value: AutocompleteValue<T, Multiple, DisableClearable, FreeSolo>, reason: AutocompleteChangeReason, details?: AutocompleteChangeDetails<T>) => void"
"name": "(event: React.SyntheticEvent, value: AutocompleteValue<Value, Multiple, DisableClearable, FreeSolo>, reason: AutocompleteChangeReason, details?: AutocompleteChangeDetails<Value>) => void",
"description": "(event: React.SyntheticEvent, value: AutocompleteValue<Value, Multiple, DisableClearable, FreeSolo>, reason: AutocompleteChangeReason, details?: AutocompleteChangeDetails<Value>) => void"
}
},
"onClose": {
Expand All @@ -106,8 +112,8 @@
},
"onHighlightChange": {
"type": {
"name": "(event: React.SyntheticEvent, option: T | null, reason: AutocompleteHighlightChangeReason) => void",
"description": "(event: React.SyntheticEvent, option: T | null, reason: AutocompleteHighlightChangeReason) => void"
"name": "(event: React.SyntheticEvent, option: Value | null, reason: AutocompleteHighlightChangeReason) => void",
"description": "(event: React.SyntheticEvent, option: Value | null, reason: AutocompleteHighlightChangeReason) => void"
}
},
"onInputChange": {
Expand Down Expand Up @@ -141,8 +147,8 @@
},
"value": {
"type": {
"name": "AutocompleteValue<T, Multiple, DisableClearable, FreeSolo>",
"description": "AutocompleteValue<T, Multiple, DisableClearable, FreeSolo>"
"name": "AutocompleteValue<Value, Multiple, DisableClearable, FreeSolo>",
"description": "AutocompleteValue<Value, Multiple, DisableClearable, FreeSolo>"
}
}
},
Expand Down Expand Up @@ -185,8 +191,8 @@
},
"getOptionProps": {
"type": {
"name": "(renderedOption: UseAutocompleteRenderedOption<T>) => React.HTMLAttributes<HTMLLIElement>",
"description": "(renderedOption: UseAutocompleteRenderedOption<T>) => React.HTMLAttributes<HTMLLIElement>"
"name": "(renderedOption: UseAutocompleteRenderedOption<Value>) => React.HTMLAttributes<HTMLLIElement>",
"description": "(renderedOption: UseAutocompleteRenderedOption<Value>) => React.HTMLAttributes<HTMLLIElement>"
},
"required": true
},
Expand All @@ -210,8 +216,8 @@
},
"groupedOptions": {
"type": {
"name": "T[] | Array<AutocompleteGroupedOption<T>>",
"description": "T[] | Array<AutocompleteGroupedOption<T>>"
"name": "Value[] | Array<AutocompleteGroupedOption<Value>>",
"description": "Value[] | Array<AutocompleteGroupedOption<Value>>"
},
"required": true
},
Expand All @@ -224,8 +230,8 @@
},
"value": {
"type": {
"name": "AutocompleteValue<T, Multiple, DisableClearable, FreeSolo>",
"description": "AutocompleteValue<T, Multiple, DisableClearable, FreeSolo>"
"name": "AutocompleteValue<Value, Multiple, DisableClearable, FreeSolo>",
"description": "AutocompleteValue<Value, Multiple, DisableClearable, FreeSolo>"
},
"required": true
}
Expand Down
14 changes: 7 additions & 7 deletions docs/pages/joy-ui/api/autocomplete.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"type": { "name": "func" },
"default": "createFilterOptions()",
"signature": {
"type": "function(options: Array<T>, state: object) => Array<T>",
"type": "function(options: Array<Value>, state: object) => Array<Value>",
"describedArgs": ["options", "state"]
}
},
Expand All @@ -47,23 +47,23 @@
},
"getOptionDisabled": {
"type": { "name": "func" },
"signature": { "type": "function(option: T) => boolean", "describedArgs": ["option"] }
"signature": { "type": "function(option: Value) => boolean", "describedArgs": ["option"] }
},
"getOptionLabel": {
"type": { "name": "func" },
"default": "(option) => option.label ?? option",
"signature": { "type": "function(option: T) => string", "describedArgs": [] }
"signature": { "type": "function(option: Value) => string", "describedArgs": [] }
},
"groupBy": {
"type": { "name": "func" },
"signature": { "type": "function(options: T) => string", "describedArgs": ["options"] }
"signature": { "type": "function(options: Value) => string", "describedArgs": ["options"] }
},
"id": { "type": { "name": "string" } },
"inputValue": { "type": { "name": "string" } },
"isOptionEqualToValue": {
"type": { "name": "func" },
"signature": {
"type": "function(option: T, value: T) => boolean",
"type": "function(option: Value, value: Value) => boolean",
"describedArgs": ["option", "value"]
}
},
Expand All @@ -76,7 +76,7 @@
"onChange": {
"type": { "name": "func" },
"signature": {
"type": "function(event: React.SyntheticEvent, value: T | Array<T>, reason: string, details?: string) => void",
"type": "function(event: React.SyntheticEvent, value: Value | Array<Value>, reason: string, details?: string) => void",
"describedArgs": ["event", "value", "reason"]
}
},
Expand All @@ -90,7 +90,7 @@
"onHighlightChange": {
"type": { "name": "func" },
"signature": {
"type": "function(event: React.SyntheticEvent, option: T, reason: string) => void",
"type": "function(event: React.SyntheticEvent, option: Value, reason: string) => void",
"describedArgs": ["event", "option", "reason"]
}
},
Expand Down
14 changes: 7 additions & 7 deletions docs/pages/material-ui/api/autocomplete.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"type": { "name": "func" },
"default": "createFilterOptions()",
"signature": {
"type": "function(options: Array<T>, state: object) => Array<T>",
"type": "function(options: Array<Value>, state: object) => Array<Value>",
"describedArgs": ["options", "state"]
}
},
Expand All @@ -62,16 +62,16 @@
},
"getOptionDisabled": {
"type": { "name": "func" },
"signature": { "type": "function(option: T) => boolean", "describedArgs": ["option"] }
"signature": { "type": "function(option: Value) => boolean", "describedArgs": ["option"] }
},
"getOptionLabel": {
"type": { "name": "func" },
"default": "(option) => option.label ?? option",
"signature": { "type": "function(option: T) => string", "describedArgs": [] }
"signature": { "type": "function(option: Value) => string", "describedArgs": [] }
},
"groupBy": {
"type": { "name": "func" },
"signature": { "type": "function(options: T) => string", "describedArgs": ["options"] }
"signature": { "type": "function(options: Value) => string", "describedArgs": ["options"] }
},
"handleHomeEndKeys": { "type": { "name": "bool" }, "default": "!props.freeSolo" },
"id": { "type": { "name": "string" } },
Expand All @@ -80,7 +80,7 @@
"isOptionEqualToValue": {
"type": { "name": "func" },
"signature": {
"type": "function(option: T, value: T) => boolean",
"type": "function(option: Value, value: Value) => boolean",
"describedArgs": ["option", "value"]
}
},
Expand All @@ -94,7 +94,7 @@
"onChange": {
"type": { "name": "func" },
"signature": {
"type": "function(event: React.SyntheticEvent, value: T | Array<T>, reason: string, details?: string) => void",
"type": "function(event: React.SyntheticEvent, value: Value | Array<Value>, reason: string, details?: string) => void",
"describedArgs": ["event", "value", "reason"]
}
},
Expand All @@ -108,7 +108,7 @@
"onHighlightChange": {
"type": { "name": "func" },
"signature": {
"type": "function(event: React.SyntheticEvent, option: T, reason: string) => void",
"type": "function(event: React.SyntheticEvent, option: Value, reason: string) => void",
"describedArgs": ["event", "option", "reason"]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"getRootProps": { "description": "Resolver for the root slot&#39;s props." },
"getTagProps": { "description": "A tag props getter." },
"groupedOptions": {
"description": "The options to render. It&#39;s either <code>T[]</code> or <code>AutocompleteGroupedOption&lt;T&gt;[]</code> if the groupBy prop is provided."
"description": "The options to render. It&#39;s either <code>Value[]</code> or <code>AutocompleteGroupedOption&lt;Value&gt;[]</code> if the groupBy prop is provided."
},
"id": { "description": "Id for the Autocomplete." },
"inputValue": { "description": "The input value." },
Expand Down
18 changes: 9 additions & 9 deletions packages/mui-joy/src/Autocomplete/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -849,9 +849,9 @@ Autocomplete.propTypes /* remove-proptypes */ = {
* A function that determines the filtered options to be rendered on search.
*
* @default createFilterOptions()
* @param {T[]} options The options to render.
* @param {Value[]} options The options to render.
* @param {object} state The state of the component.
* @returns {T[]}
* @returns {Value[]}
*/
filterOptions: PropTypes.func,
/**
Expand All @@ -875,7 +875,7 @@ Autocomplete.propTypes /* remove-proptypes */ = {
/**
* Used to determine the disabled state for a given option.
*
* @param {T} option The option to test.
* @param {Value} option The option to test.
* @returns {boolean}
*/
getOptionDisabled: PropTypes.func,
Expand All @@ -885,7 +885,7 @@ Autocomplete.propTypes /* remove-proptypes */ = {
*
* If used in free solo mode, it must accept both the type of the options and a string.
*
* @param {T} option
* @param {Value} option
* @returns {string}
* @default (option) => option.label ?? option
*/
Expand All @@ -894,7 +894,7 @@ Autocomplete.propTypes /* remove-proptypes */ = {
* If provided, the options will be grouped under the returned string.
* The groupBy value is also used as the text for group headings when `renderGroup` is not provided.
*
* @param {T} options The options to group.
* @param {Value} options The options to group.
* @returns {string}
*/
groupBy: PropTypes.func,
Expand All @@ -912,8 +912,8 @@ Autocomplete.propTypes /* remove-proptypes */ = {
* Uses strict equality by default.
* ⚠️ Both arguments need to be handled, an option can only match with one value.
*
* @param {T} option The option to test.
* @param {T} value The value to test against.
* @param {Value} option The option to test.
* @param {Value} value The value to test against.
* @returns {boolean}
*/
isOptionEqualToValue: PropTypes.func,
Expand Down Expand Up @@ -956,7 +956,7 @@ Autocomplete.propTypes /* remove-proptypes */ = {
* Callback fired when the value changes.
*
* @param {React.SyntheticEvent} event The event source of the callback.
* @param {T|T[]} value The new value of the component.
* @param {Value|Value[]} value The new value of the component.
* @param {string} reason One of "createOption", "selectOption", "removeOption", "blur" or "clear".
* @param {string} [details]
*/
Expand All @@ -973,7 +973,7 @@ Autocomplete.propTypes /* remove-proptypes */ = {
* Callback fired when the highlight option changes.
*
* @param {React.SyntheticEvent} event The event source of the callback.
* @param {T} option The highlighted option.
* @param {Value} option The highlighted option.
* @param {string} reason Can be: `"keyboard"`, `"auto"`, `"mouse"`, `"touch"`.
*/
onHighlightChange: PropTypes.func,
Expand Down
18 changes: 9 additions & 9 deletions packages/mui-material/src/Autocomplete/Autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -842,9 +842,9 @@ Autocomplete.propTypes /* remove-proptypes */ = {
* A function that determines the filtered options to be rendered on search.
*
* @default createFilterOptions()
* @param {T[]} options The options to render.
* @param {Value[]} options The options to render.
* @param {object} state The state of the component.
* @returns {T[]}
* @returns {Value[]}
*/
filterOptions: PropTypes.func,
/**
Expand Down Expand Up @@ -878,7 +878,7 @@ Autocomplete.propTypes /* remove-proptypes */ = {
/**
* Used to determine the disabled state for a given option.
*
* @param {T} option The option to test.
* @param {Value} option The option to test.
* @returns {boolean}
*/
getOptionDisabled: PropTypes.func,
Expand All @@ -888,7 +888,7 @@ Autocomplete.propTypes /* remove-proptypes */ = {
*
* If used in free solo mode, it must accept both the type of the options and a string.
*
* @param {T} option
* @param {Value} option
* @returns {string}
* @default (option) => option.label ?? option
*/
Expand All @@ -897,7 +897,7 @@ Autocomplete.propTypes /* remove-proptypes */ = {
* If provided, the options will be grouped under the returned string.
* The groupBy value is also used as the text for group headings when `renderGroup` is not provided.
*
* @param {T} options The options to group.
* @param {Value} options The options to group.
* @returns {string}
*/
groupBy: PropTypes.func,
Expand Down Expand Up @@ -926,8 +926,8 @@ Autocomplete.propTypes /* remove-proptypes */ = {
* Uses strict equality by default.
* ⚠️ Both arguments need to be handled, an option can only match with one value.
*
* @param {T} option The option to test.
* @param {T} value The value to test against.
* @param {Value} option The option to test.
* @param {Value} value The value to test against.
* @returns {boolean}
*/
isOptionEqualToValue: PropTypes.func,
Expand Down Expand Up @@ -975,7 +975,7 @@ Autocomplete.propTypes /* remove-proptypes */ = {
* Callback fired when the value changes.
*
* @param {React.SyntheticEvent} event The event source of the callback.
* @param {T|T[]} value The new value of the component.
* @param {Value|Value[]} value The new value of the component.
* @param {string} reason One of "createOption", "selectOption", "removeOption", "blur" or "clear".
* @param {string} [details]
*/
Expand All @@ -992,7 +992,7 @@ Autocomplete.propTypes /* remove-proptypes */ = {
* Callback fired when the highlight option changes.
*
* @param {React.SyntheticEvent} event The event source of the callback.
* @param {T} option The highlighted option.
* @param {Value} option The highlighted option.
* @param {string} reason Can be: `"keyboard"`, `"auto"`, `"mouse"`, `"touch"`.
*/
onHighlightChange: PropTypes.func,
Expand Down

0 comments on commit 4a74014

Please sign in to comment.