Skip to content

Commit

Permalink
add shortcuts key
Browse files Browse the repository at this point in the history
  • Loading branch information
noraleonte committed May 2, 2024
1 parent 75f63c3 commit 5d44a4d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/pages/x/api/date-pickers/pickers-shortcuts.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"items": {
"type": {
"name": "arrayOf",
"description": "Array<{ getValue: func, label: string }>"
"description": "Array<{ getValue: func, key?: string, label: string }>"
},
"default": "[]"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface PickersShortcutsItemGetValueParams<TValue> {
export interface PickersShortcutsItem<TValue> {
label: string;
getValue: (params: PickersShortcutsItemGetValueParams<TValue>) => TValue;
key?: string;
}

export type PickersShortcutsItemContext = Omit<PickersShortcutsItem<unknown>, 'getValue'>;
Expand Down Expand Up @@ -64,6 +65,7 @@ function PickersShortcuts<TValue>(props: PickersShortcutsProps<TValue>) {
const newValue = getValue({ isValid });

return {
key: item?.key || item.label,
label: item.label,
onClick: () => {
onChange(newValue, changeImportance, item);
Expand Down Expand Up @@ -132,6 +134,7 @@ PickersShortcuts.propTypes = {
items: PropTypes.arrayOf(
PropTypes.shape({
getValue: PropTypes.func.isRequired,
key: PropTypes.string,
label: PropTypes.string.isRequired,
}),
),
Expand Down

0 comments on commit 5d44a4d

Please sign in to comment.