@mui/base
Advanced tools
Comparing version 5.0.0-alpha.74 to 5.0.0-alpha.75
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; | ||
const _excluded = ["anchorOrigin", "classes", "badgeContent", "component", "children", "className", "components", "componentsProps", "invisible", "max", "showZero", "variant"]; | ||
const _excluded = ["badgeContent", "component", "children", "className", "components", "componentsProps", "invisible", "max", "showZero"]; | ||
import * as React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import clsx from 'clsx'; | ||
import { unstable_capitalize as capitalize } from '@mui/utils'; | ||
import composeClasses from '../composeClasses'; | ||
@@ -17,12 +16,9 @@ import appendOwnerState from '../utils/appendOwnerState'; | ||
const { | ||
variant, | ||
anchorOrigin, | ||
invisible, | ||
classes | ||
invisible | ||
} = ownerState; | ||
const slots = { | ||
root: ['root'], | ||
badge: ['badge', variant, `anchorOrigin${capitalize(anchorOrigin.vertical)}${capitalize(anchorOrigin.horizontal)}`, invisible && 'invisible'] | ||
badge: ['badge', invisible && 'invisible'] | ||
}; | ||
return composeClasses(slots, getBadgeUtilityClass, classes); | ||
return composeClasses(slots, getBadgeUtilityClass, undefined); | ||
}; | ||
@@ -32,7 +28,2 @@ | ||
const { | ||
anchorOrigin: anchorOriginProp = { | ||
vertical: 'top', | ||
horizontal: 'right' | ||
}, | ||
classes: classesProp, | ||
component, | ||
@@ -44,4 +35,3 @@ children, | ||
max: maxProp = 99, | ||
showZero = false, | ||
variant: variantProp = 'standard' | ||
showZero = false | ||
} = props, | ||
@@ -51,21 +41,14 @@ other = _objectWithoutPropertiesLoose(props, _excluded); | ||
const { | ||
anchorOrigin, | ||
badgeContent, | ||
max, | ||
variant, | ||
displayValue, | ||
invisible | ||
} = useBadge(_extends({}, props, { | ||
anchorOrigin: anchorOriginProp, | ||
max: maxProp, | ||
variant: variantProp | ||
max: maxProp | ||
})); | ||
const ownerState = _extends({}, props, { | ||
anchorOrigin, | ||
badgeContent, | ||
classes: classesProp, | ||
invisible, | ||
max, | ||
variant, | ||
showZero | ||
@@ -98,14 +81,2 @@ }); | ||
/** | ||
* The anchor of the badge. | ||
* @default { | ||
* vertical: 'top', | ||
* horizontal: 'right', | ||
* } | ||
*/ | ||
anchorOrigin: PropTypes.shape({ | ||
horizontal: PropTypes.oneOf(['left', 'right']).isRequired, | ||
vertical: PropTypes.oneOf(['bottom', 'top']).isRequired | ||
}), | ||
/** | ||
* The content rendered within the badge. | ||
@@ -121,7 +92,2 @@ */ | ||
/** | ||
* Override or extend the styles applied to the component. | ||
*/ | ||
classes: PropTypes.object, | ||
/** | ||
* @ignore | ||
@@ -172,10 +138,4 @@ */ | ||
*/ | ||
showZero: PropTypes.bool, | ||
/** | ||
* The variant to use. | ||
* @default 'standard' | ||
*/ | ||
variant: PropTypes.string | ||
showZero: PropTypes.bool | ||
} : void 0; | ||
export default BadgeUnstyled; |
@@ -6,14 +6,2 @@ export interface BadgeUnstyledClasses { | ||
badge: string; | ||
/** Class name applied to the badge `span` element if `variant="dot"`. */ | ||
dot: string; | ||
/** Class name applied to the badge `span` element if `variant="standard"`. */ | ||
standard: string; | ||
/** Class name applied to the badge `span` element if `anchorOrigin={{ 'top', 'right' }}`. */ | ||
anchorOriginTopRight: string; | ||
/** Class name applied to the badge `span` element if `anchorOrigin={{ 'bottom', 'right' }}`. */ | ||
anchorOriginBottomRight: string; | ||
/** Class name applied to the badge `span` element if `anchorOrigin={{ 'top', 'left' }}`. */ | ||
anchorOriginTopLeft: string; | ||
/** Class name applied to the badge `span` element if `anchorOrigin={{ 'bottom', 'left' }}`. */ | ||
anchorOriginBottomLeft: string; | ||
/** State class applied to the badge `span` element if `invisible={true}`. */ | ||
@@ -20,0 +8,0 @@ invisible: string; |
import generateUtilityClasses from '../generateUtilityClasses'; | ||
import generateUtilityClass from '../generateUtilityClass'; | ||
export function getBadgeUtilityClass(slot) { | ||
return generateUtilityClass('MuiBadge', slot); | ||
return generateUtilityClass('BaseBadge', slot); | ||
} | ||
const badgeUnstyledClasses = generateUtilityClasses('MuiBadge', ['root', 'badge', 'dot', 'standard', 'anchorOriginTopLeft', 'anchorOriginTopRight', 'anchorOriginBottomLeft', 'anchorOriginBottomRight', 'invisible']); | ||
const badgeUnstyledClasses = generateUtilityClasses('BaseBadge', ['root', 'badge', 'invisible']); | ||
export default badgeUnstyledClasses; |
import * as React from 'react'; | ||
import { OverrideProps, OverridableTypeMap } from '@mui/types'; | ||
import { BadgeUnstyledClasses } from './badgeUnstyledClasses'; | ||
export interface BadgeOrigin { | ||
vertical: 'top' | 'bottom'; | ||
horizontal: 'left' | 'right'; | ||
} | ||
export interface BadgeUnstyledComponentsPropsOverrides { | ||
@@ -13,10 +8,2 @@ } | ||
/** | ||
* The anchor of the badge. | ||
* @default { | ||
* vertical: 'top', | ||
* horizontal: 'right', | ||
* } | ||
*/ | ||
anchorOrigin?: BadgeOrigin; | ||
/** | ||
* The components used for each slot inside the Badge. | ||
@@ -47,6 +34,2 @@ * Either a string to use a HTML element or a component. | ||
/** | ||
* Override or extend the styles applied to the component. | ||
*/ | ||
classes?: Partial<BadgeUnstyledClasses>; | ||
/** | ||
* If `true`, the badge is invisible. | ||
@@ -66,7 +49,2 @@ * @default false | ||
showZero?: boolean; | ||
/** | ||
* The variant to use. | ||
* @default 'standard' | ||
*/ | ||
variant?: string; | ||
}; | ||
@@ -73,0 +51,0 @@ defaultComponent: D; |
import * as React from 'react'; | ||
import BadgeUnstyledProps from './BadgeUnstyledProps'; | ||
export interface UseBadgeProps { | ||
anchorOrigin: BadgeUnstyledProps['anchorOrigin']; | ||
badgeContent: BadgeUnstyledProps['badgeContent']; | ||
@@ -9,11 +8,8 @@ invisible: BadgeUnstyledProps['invisible']; | ||
showZero: BadgeUnstyledProps['showZero']; | ||
variant: BadgeUnstyledProps['variant']; | ||
} | ||
export default function useBadge(props: UseBadgeProps): { | ||
anchorOrigin: import("./BadgeUnstyledProps").BadgeOrigin; | ||
badgeContent: React.ReactNode; | ||
invisible: boolean; | ||
max: number; | ||
variant: string; | ||
displayValue: React.ReactNode; | ||
}; |
import { usePreviousProps } from '@mui/utils'; | ||
export default function useBadge(props) { | ||
const { | ||
anchorOrigin: anchorOriginProp = { | ||
vertical: 'top', | ||
horizontal: 'right' | ||
}, | ||
badgeContent: badgeContentProp, | ||
invisible: invisibleProp = false, | ||
max: maxProp = 99, | ||
showZero = false, | ||
variant: variantProp = 'standard' | ||
showZero = false | ||
} = props; | ||
const prevProps = usePreviousProps({ | ||
anchorOrigin: anchorOriginProp, | ||
badgeContent: badgeContentProp, | ||
max: maxProp, | ||
variant: variantProp | ||
max: maxProp | ||
}); | ||
let invisible = invisibleProp; | ||
if (invisibleProp === false && (badgeContentProp === 0 && !showZero || badgeContentProp == null && variantProp !== 'dot')) { | ||
if (invisibleProp === false && badgeContentProp === 0 && !showZero) { | ||
invisible = true; | ||
@@ -27,21 +20,12 @@ } | ||
const { | ||
anchorOrigin = anchorOriginProp, | ||
badgeContent, | ||
max = maxProp, | ||
variant = variantProp | ||
max = maxProp | ||
} = invisible ? prevProps : props; | ||
let displayValue = ''; | ||
if (variant !== 'dot') { | ||
displayValue = badgeContent && Number(badgeContent) > max ? `${max}+` : badgeContent; | ||
} | ||
const displayValue = badgeContent && Number(badgeContent) > max ? `${max}+` : badgeContent; | ||
return { | ||
anchorOrigin, | ||
badgeContent, | ||
invisible, | ||
max, | ||
variant, | ||
displayValue | ||
}; | ||
} |
@@ -0,0 +0,0 @@ import * as React from 'react'; |
@@ -0,0 +0,0 @@ import React from 'react'; |
@@ -0,0 +0,0 @@ export interface ButtonUnstyledClasses { |
@@ -0,0 +0,0 @@ export { default } from './ButtonUnstyled'; |
@@ -0,0 +0,0 @@ import * as React from 'react'; |
@@ -0,0 +0,0 @@ import * as React from 'react'; |
@@ -0,0 +0,0 @@ declare const ClassNameGenerator: { |
export { default as unstable_ClassNameGenerator } from './ClassNameGenerator'; |
@@ -36,5 +36,3 @@ import * as React from 'react'; | ||
* | ||
* - [Click Away Listener](https://mui.com/base/components/click-away-listener/) | ||
* - [Click Away Listener](https://mui.com/material-ui/react-click-away-listener/) | ||
* - [Menus](https://mui.com/material-ui/react-menu/) | ||
* - [Click Away Listener](https://mui.com/base/react-click-away-listener/) | ||
* | ||
@@ -41,0 +39,0 @@ * API: |
@@ -21,5 +21,3 @@ import * as React from 'react'; | ||
* | ||
* - [Click Away Listener](https://mui.com/base/components/click-away-listener/) | ||
* - [Click Away Listener](https://mui.com/material-ui/react-click-away-listener/) | ||
* - [Menus](https://mui.com/material-ui/react-menu/) | ||
* - [Click Away Listener](https://mui.com/base/react-click-away-listener/) | ||
* | ||
@@ -26,0 +24,0 @@ * API: |
export { default } from './ClickAwayListener'; | ||
export * from './ClickAwayListener'; |
export default function composeClasses<ClassKey extends string>(slots: Record<ClassKey, ReadonlyArray<string | false | undefined | null>>, getUtilityClass: (slot: string) => string, classes: Record<string, string> | undefined): Record<ClassKey, string>; |
export { default } from './composeClasses'; |
@@ -0,0 +0,0 @@ import * as React from 'react'; |
@@ -33,2 +33,3 @@ import { OverridableComponent } from '@mui/types'; | ||
* | ||
* - [Form Control](https://mui.com/components/form-control/) | ||
* - [Text Fields](https://mui.com/components/text-fields/) | ||
@@ -35,0 +36,0 @@ * |
@@ -43,2 +43,3 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Form Control](https://mui.com/components/form-control/) | ||
* - [Text Fields](https://mui.com/components/text-fields/) | ||
@@ -45,0 +46,0 @@ * |
@@ -0,0 +0,0 @@ export interface FormControlUnstyledClasses { |
@@ -38,7 +38,2 @@ import { OverrideProps } from '@mui/types'; | ||
/** | ||
* Extra properties to be placed on the FormControlContext. | ||
* @default {} | ||
*/ | ||
extraContextProperties?: object; | ||
/** | ||
* If `true`, the component is displayed in focused state. | ||
@@ -45,0 +40,0 @@ * @default false |
@@ -0,0 +0,0 @@ export { default } from './FormControlUnstyled'; |
export default function useFormControlUnstyled(): import("./FormControlContext").FormControlUnstyledState | undefined; |
export declare type GlobalStateSlot = 'active' | 'checked' | 'completed' | 'disabled' | 'error' | 'expanded' | 'focused' | 'focusVisible' | 'required' | 'selected'; | ||
export default function generateUtilityClass(componentName: string, slot: string): string; |
export { default } from './generateUtilityClass'; | ||
export * from './generateUtilityClass'; |
export default function generateUtilityClasses<T extends string>(componentName: string, slots: T[]): Record<T, string>; |
export { default } from './generateUtilityClasses'; |
@@ -1,2 +0,2 @@ | ||
/** @license MUI v5.0.0-alpha.74 | ||
/** @license MUI v5.0.0-alpha.75 | ||
* | ||
@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the |
@@ -0,0 +0,0 @@ export { default } from './InputUnstyled'; |
@@ -0,0 +0,0 @@ import { OverridableComponent } from '@mui/types'; |
@@ -0,0 +0,0 @@ export interface InputUnstyledClasses { |
@@ -0,0 +0,0 @@ import React from 'react'; |
@@ -0,0 +0,0 @@ import * as React from 'react'; |
@@ -6,3 +6,2 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import clsx from 'clsx'; | ||
import { unstable_capitalize as capitalize } from '@mui/utils'; | ||
import composeClasses from '../composeClasses'; | ||
@@ -16,21 +15,12 @@ import appendOwnerState from '../utils/appendOwnerState'; | ||
var useUtilityClasses = function useUtilityClasses(ownerState) { | ||
var variant = ownerState.variant, | ||
anchorOrigin = ownerState.anchorOrigin, | ||
invisible = ownerState.invisible, | ||
classes = ownerState.classes; | ||
var invisible = ownerState.invisible; | ||
var slots = { | ||
root: ['root'], | ||
badge: ['badge', variant, "anchorOrigin".concat(capitalize(anchorOrigin.vertical)).concat(capitalize(anchorOrigin.horizontal)), invisible && 'invisible'] | ||
badge: ['badge', invisible && 'invisible'] | ||
}; | ||
return composeClasses(slots, getBadgeUtilityClass, classes); | ||
return composeClasses(slots, getBadgeUtilityClass, undefined); | ||
}; | ||
var BadgeUnstyled = /*#__PURE__*/React.forwardRef(function BadgeUnstyled(props, ref) { | ||
var _props$anchorOrigin = props.anchorOrigin, | ||
anchorOriginProp = _props$anchorOrigin === void 0 ? { | ||
vertical: 'top', | ||
horizontal: 'right' | ||
} : _props$anchorOrigin, | ||
classesProp = props.classes, | ||
badgeContentProp = props.badgeContent, | ||
var badgeContentProp = props.badgeContent, | ||
component = props.component, | ||
@@ -48,15 +38,9 @@ children = props.children, | ||
showZero = _props$showZero === void 0 ? false : _props$showZero, | ||
_props$variant = props.variant, | ||
variantProp = _props$variant === void 0 ? 'standard' : _props$variant, | ||
other = _objectWithoutProperties(props, ["anchorOrigin", "classes", "badgeContent", "component", "children", "className", "components", "componentsProps", "invisible", "max", "showZero", "variant"]); | ||
other = _objectWithoutProperties(props, ["badgeContent", "component", "children", "className", "components", "componentsProps", "invisible", "max", "showZero"]); | ||
var _useBadge = useBadge(_extends({}, props, { | ||
anchorOrigin: anchorOriginProp, | ||
max: maxProp, | ||
variant: variantProp | ||
max: maxProp | ||
})), | ||
anchorOrigin = _useBadge.anchorOrigin, | ||
badgeContent = _useBadge.badgeContent, | ||
max = _useBadge.max, | ||
variant = _useBadge.variant, | ||
displayValue = _useBadge.displayValue, | ||
@@ -66,8 +50,5 @@ invisible = _useBadge.invisible; | ||
var ownerState = _extends({}, props, { | ||
anchorOrigin: anchorOrigin, | ||
badgeContent: badgeContent, | ||
classes: classesProp, | ||
invisible: invisible, | ||
max: max, | ||
variant: variant, | ||
showZero: showZero | ||
@@ -100,14 +81,2 @@ }); | ||
/** | ||
* The anchor of the badge. | ||
* @default { | ||
* vertical: 'top', | ||
* horizontal: 'right', | ||
* } | ||
*/ | ||
anchorOrigin: PropTypes.shape({ | ||
horizontal: PropTypes.oneOf(['left', 'right']).isRequired, | ||
vertical: PropTypes.oneOf(['bottom', 'top']).isRequired | ||
}), | ||
/** | ||
* The content rendered within the badge. | ||
@@ -123,7 +92,2 @@ */ | ||
/** | ||
* Override or extend the styles applied to the component. | ||
*/ | ||
classes: PropTypes.object, | ||
/** | ||
* @ignore | ||
@@ -174,10 +138,4 @@ */ | ||
*/ | ||
showZero: PropTypes.bool, | ||
/** | ||
* The variant to use. | ||
* @default 'standard' | ||
*/ | ||
variant: PropTypes.string | ||
showZero: PropTypes.bool | ||
} : void 0; | ||
export default BadgeUnstyled; |
import generateUtilityClasses from '../generateUtilityClasses'; | ||
import generateUtilityClass from '../generateUtilityClass'; | ||
export function getBadgeUtilityClass(slot) { | ||
return generateUtilityClass('MuiBadge', slot); | ||
return generateUtilityClass('BaseBadge', slot); | ||
} | ||
var badgeUnstyledClasses = generateUtilityClasses('MuiBadge', ['root', 'badge', 'dot', 'standard', 'anchorOriginTopLeft', 'anchorOriginTopRight', 'anchorOriginBottomLeft', 'anchorOriginBottomRight', 'invisible']); | ||
var badgeUnstyledClasses = generateUtilityClasses('BaseBadge', ['root', 'badge', 'invisible']); | ||
export default badgeUnstyledClasses; |
import { usePreviousProps } from '@mui/utils'; | ||
export default function useBadge(props) { | ||
var _props$anchorOrigin = props.anchorOrigin, | ||
anchorOriginProp = _props$anchorOrigin === void 0 ? { | ||
vertical: 'top', | ||
horizontal: 'right' | ||
} : _props$anchorOrigin, | ||
badgeContentProp = props.badgeContent, | ||
var badgeContentProp = props.badgeContent, | ||
_props$invisible = props.invisible, | ||
@@ -14,14 +9,10 @@ invisibleProp = _props$invisible === void 0 ? false : _props$invisible, | ||
_props$showZero = props.showZero, | ||
showZero = _props$showZero === void 0 ? false : _props$showZero, | ||
_props$variant = props.variant, | ||
variantProp = _props$variant === void 0 ? 'standard' : _props$variant; | ||
showZero = _props$showZero === void 0 ? false : _props$showZero; | ||
var prevProps = usePreviousProps({ | ||
anchorOrigin: anchorOriginProp, | ||
badgeContent: badgeContentProp, | ||
max: maxProp, | ||
variant: variantProp | ||
max: maxProp | ||
}); | ||
var invisible = invisibleProp; | ||
if (invisibleProp === false && (badgeContentProp === 0 && !showZero || badgeContentProp == null && variantProp !== 'dot')) { | ||
if (invisibleProp === false && badgeContentProp === 0 && !showZero) { | ||
invisible = true; | ||
@@ -31,24 +22,13 @@ } | ||
var _ref = invisible ? prevProps : props, | ||
_ref$anchorOrigin = _ref.anchorOrigin, | ||
anchorOrigin = _ref$anchorOrigin === void 0 ? anchorOriginProp : _ref$anchorOrigin, | ||
badgeContent = _ref.badgeContent, | ||
_ref$max = _ref.max, | ||
max = _ref$max === void 0 ? maxProp : _ref$max, | ||
_ref$variant = _ref.variant, | ||
variant = _ref$variant === void 0 ? variantProp : _ref$variant; | ||
max = _ref$max === void 0 ? maxProp : _ref$max; | ||
var displayValue = ''; | ||
if (variant !== 'dot') { | ||
displayValue = badgeContent && Number(badgeContent) > max ? "".concat(max, "+") : badgeContent; | ||
} | ||
var displayValue = badgeContent && Number(badgeContent) > max ? "".concat(max, "+") : badgeContent; | ||
return { | ||
anchorOrigin: anchorOrigin, | ||
badgeContent: badgeContent, | ||
invisible: invisible, | ||
max: max, | ||
variant: variant, | ||
displayValue: displayValue | ||
}; | ||
} |
@@ -21,5 +21,3 @@ import * as React from 'react'; | ||
* | ||
* - [Click Away Listener](https://mui.com/base/components/click-away-listener/) | ||
* - [Click Away Listener](https://mui.com/material-ui/react-click-away-listener/) | ||
* - [Menus](https://mui.com/material-ui/react-menu/) | ||
* - [Click Away Listener](https://mui.com/base/react-click-away-listener/) | ||
* | ||
@@ -26,0 +24,0 @@ * API: |
@@ -43,2 +43,3 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Form Control](https://mui.com/components/form-control/) | ||
* - [Text Fields](https://mui.com/components/text-fields/) | ||
@@ -45,0 +46,0 @@ * |
@@ -1,2 +0,2 @@ | ||
/** @license MUI v5.0.0-alpha.74 | ||
/** @license MUI v5.0.0-alpha.75 | ||
* | ||
@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the |
@@ -189,2 +189,53 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
var textCriteriaMatches = function textCriteriaMatches(nextFocus, searchString, stringifyOption) { | ||
var _stringifyOption; | ||
var text = (_stringifyOption = stringifyOption(nextFocus)) == null ? void 0 : _stringifyOption.trim().toLowerCase(); | ||
if (!text || text.length === 0) { | ||
// Make option not navigable if stringification fails or results in empty string. | ||
return false; | ||
} | ||
return text.indexOf(searchString) === 0; | ||
}; | ||
function handleTextNavigation(state, searchString, props) { | ||
var options = props.options, | ||
isOptionDisabled = props.isOptionDisabled, | ||
disableListWrap = props.disableListWrap, | ||
disabledItemsFocusable = props.disabledItemsFocusable, | ||
optionComparer = props.optionComparer, | ||
optionStringifier = props.optionStringifier; | ||
var moveHighlight = function moveHighlight(previouslyHighlightedOption) { | ||
return getNewHighlightedOption(options, previouslyHighlightedOption, 1, 'next', disabledItemsFocusable != null ? disabledItemsFocusable : false, isOptionDisabled != null ? isOptionDisabled : function () { | ||
return false; | ||
}, !(disableListWrap != null ? disableListWrap : false), optionComparer); | ||
}; | ||
var startWithCurrentOption = searchString.length > 1; | ||
var nextOption = startWithCurrentOption ? state.highlightedValue : moveHighlight(state.highlightedValue); // use `for` instead of `while` prevent infinite loop | ||
for (var _index = 0; _index < options.length; _index += 1) { | ||
// Return un-mutated state if looped back to the currently highlighted value | ||
if (!nextOption || !startWithCurrentOption && state.highlightedValue === nextOption) { | ||
return state; | ||
} | ||
if (textCriteriaMatches(nextOption, searchString, optionStringifier) && (!isOptionDisabled(nextOption, options.indexOf(nextOption)) || disabledItemsFocusable)) { | ||
// The nextOption is the element to be highlighted | ||
return _extends({}, state, { | ||
highlightedValue: nextOption | ||
}); | ||
} // Move to the next element. | ||
nextOption = moveHighlight(nextOption); | ||
} // No option match text search criteria | ||
return state; | ||
} | ||
function handleOptionsChange(options, previousOptions, state, props) { | ||
@@ -247,2 +298,5 @@ var _options$find, _options$find2; | ||
case ActionTypes.textNavigation: | ||
return handleTextNavigation(state, action.searchString, action.props); | ||
case ActionTypes.optionsChange: | ||
@@ -249,0 +303,0 @@ return handleOptionsChange(action.options, action.previousOptions, state, action.props); |
@@ -9,2 +9,3 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; | ||
import areArraysEqual from '../utils/areArraysEqual'; | ||
var TEXT_NAVIGATION_RESET_TIMEOUT = 500; // milliseconds | ||
@@ -19,2 +20,6 @@ var defaultOptionComparer = function defaultOptionComparer(optionA, optionB) { | ||
var defaultOptionStringifier = function defaultOptionStringifier(option) { | ||
return typeof option === 'string' ? option : String(option); | ||
}; | ||
export default function useListbox(props) { | ||
@@ -37,2 +42,4 @@ var _props$optionIdGenera, _options$highlightedI; | ||
optionComparer = _props$optionComparer === void 0 ? defaultOptionComparer : _props$optionComparer, | ||
_props$optionStringif = props.optionStringifier, | ||
optionStringifier = _props$optionStringif === void 0 ? defaultOptionStringifier : _props$optionStringif, | ||
options = props.options, | ||
@@ -54,3 +61,4 @@ externalReducer = props.stateReducer; | ||
multiple: multiple, | ||
optionComparer: optionComparer | ||
optionComparer: optionComparer, | ||
optionStringifier: optionStringifier | ||
}); | ||
@@ -60,2 +68,6 @@ | ||
var handleRef = useForkRef(externalListboxRef, listboxRef); | ||
var textCriteriaRef = React.useRef({ | ||
searchString: '', | ||
lastTime: null | ||
}); | ||
@@ -161,3 +173,23 @@ var _useControllableReduc = useControllableReducer(defaultReducer, externalReducer, propsWithDefaults), | ||
props: propsWithDefaults | ||
}); | ||
}); // Handle text navigation | ||
if (event.key.length === 1) { | ||
var textCriteria = textCriteriaRef.current; | ||
var lowerKey = event.key.toLowerCase(); | ||
var currentTime = performance.now(); | ||
if (textCriteria.searchString.length > 0 && textCriteria.lastTime && currentTime - textCriteria.lastTime > TEXT_NAVIGATION_RESET_TIMEOUT) { | ||
textCriteria.searchString = lowerKey; | ||
} else if (textCriteria.searchString.length !== 1 || lowerKey !== textCriteria.searchString) { | ||
// If there is just one character in the buffer and the key is the same, do not append | ||
textCriteria.searchString += lowerKey; | ||
} | ||
textCriteria.lastTime = currentTime; | ||
dispatch({ | ||
type: ActionTypes.textNavigation, | ||
searchString: textCriteria.searchString, | ||
props: propsWithDefaults | ||
}); | ||
} | ||
}; | ||
@@ -164,0 +196,0 @@ }; |
@@ -12,4 +12,5 @@ var ActionTypes; // split declaration and export due to https://github.com/codesandbox/codesandbox-client/issues/6435 | ||
ActionTypes["setHighlight"] = "setHighlight"; | ||
ActionTypes["textNavigation"] = "textNagivation"; | ||
})(ActionTypes || (ActionTypes = {})); | ||
export { ActionTypes }; |
@@ -44,3 +44,4 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
componentsProps = _props$componentsProp === void 0 ? {} : _props$componentsProp, | ||
other = _objectWithoutProperties(props, ["children", "className", "disabled", "component", "components", "componentsProps"]); | ||
label = props.label, | ||
other = _objectWithoutProperties(props, ["children", "className", "disabled", "component", "components", "componentsProps", "label"]); | ||
@@ -52,3 +53,4 @@ var Root = (_ref = component != null ? component : components.Root) != null ? _ref : 'li'; | ||
disabled: disabled, | ||
ref: ref | ||
ref: ref, | ||
label: label | ||
}), | ||
@@ -116,4 +118,10 @@ getRootProps = _useMenuItem.getRootProps, | ||
*/ | ||
disabled: PropTypes.bool | ||
disabled: PropTypes.bool, | ||
/** | ||
* A text representation of the menu item's content. | ||
* Used for keyboard text navigation matching. | ||
*/ | ||
label: PropTypes.string | ||
} : void 0; | ||
export default MenuItemUnstyled; |
@@ -10,3 +10,4 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
disabled = _props$disabled === void 0 ? false : _props$disabled, | ||
ref = props.ref; | ||
ref = props.ref, | ||
label = props.label; | ||
var id = useId(); | ||
@@ -32,3 +33,4 @@ var menuContext = React.useContext(MenuUnstyledContext); | ||
id: id, | ||
ref: itemRef | ||
ref: itemRef, | ||
label: label | ||
}); | ||
@@ -38,3 +40,3 @@ return function () { | ||
}; | ||
}, [id, registerItem, unregisterItem, disabled, ref]); | ||
}, [id, registerItem, unregisterItem, disabled, ref, label]); | ||
@@ -65,3 +67,4 @@ var _useButton = useButton({ | ||
id: id, | ||
disabled: disabled | ||
disabled: disabled, | ||
label: label | ||
}); | ||
@@ -68,0 +71,0 @@ var itemState = menuContext.getItemState(id != null ? id : ''); |
@@ -54,2 +54,7 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
options: Object.keys(menuItems), | ||
optionStringifier: function optionStringifier(id) { | ||
var _menuItems$id$ref$cur; | ||
return menuItems[id].label || ((_menuItems$id$ref$cur = menuItems[id].ref.current) == null ? void 0 : _menuItems$id$ref$cur.innerText); | ||
}, | ||
isOptionDisabled: function isOptionDisabled(id) { | ||
@@ -56,0 +61,0 @@ var _menuItems$id; |
@@ -300,9 +300,9 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Selects](https://mui.com/components/selects/) | ||
* - [Select](https://mui.com/base/react-select/) | ||
* | ||
* API: | ||
* | ||
* - [MultiSelectUnstyled API](https://mui.com/api/multi-select-unstyled/) | ||
* - [MultiSelectUnstyled API](https://mui.com/base/api/multi-select-unstyled/) | ||
*/ | ||
export default MultiSelectUnstyled; |
@@ -24,7 +24,7 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Selects](https://mui.com/components/selects/) | ||
* - [Select](https://mui.com/base/react-select/) | ||
* | ||
* API: | ||
* | ||
* - [OptionGroupUnstyled API](https://mui.com/api/option-group-unstyled/) | ||
* - [OptionGroupUnstyled API](https://mui.com/base/api/option-group-unstyled/) | ||
*/ | ||
@@ -31,0 +31,0 @@ |
@@ -39,3 +39,4 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
value = props.value, | ||
other = _objectWithoutProperties(props, ["children", "className", "component", "components", "componentsProps", "disabled", "value"]); | ||
label = props.label, | ||
other = _objectWithoutProperties(props, ["children", "className", "component", "components", "componentsProps", "disabled", "value", "label"]); | ||
@@ -51,3 +52,3 @@ var selectContext = React.useContext(SelectUnstyledContext); | ||
value: value, | ||
label: children, | ||
label: label || children, | ||
disabled: disabled | ||
@@ -139,2 +140,8 @@ }; | ||
/** | ||
* A text representation of the option's content. | ||
* Used for keyboard text navigation matching. | ||
*/ | ||
label: PropTypes.string, | ||
/** | ||
* The value of the option. | ||
@@ -149,9 +156,9 @@ */ | ||
* | ||
* - [Selects](https://mui.com/components/selects/) | ||
* - [Select](https://mui.com/base/react-select/) | ||
* | ||
* API: | ||
* | ||
* - [OptionUnstyled API](https://mui.com/api/option-unstyled/) | ||
* - [OptionUnstyled API](https://mui.com/base/api/option-unstyled/) | ||
*/ | ||
export default /*#__PURE__*/React.memo(OptionUnstyled); |
@@ -297,9 +297,9 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Selects](https://mui.com/components/selects/) | ||
* - [Select](https://mui.com/base/react-select/) | ||
* | ||
* API: | ||
* | ||
* - [SelectUnstyled API](https://mui.com/api/select-unstyled/) | ||
* - [SelectUnstyled API](https://mui.com/base/api/select-unstyled/) | ||
*/ | ||
export default SelectUnstyled; |
@@ -8,2 +8,18 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
var defaultOptionStringifier = function defaultOptionStringifier(option) { | ||
var label = option.label, | ||
value = option.value; | ||
if (typeof label === 'string') { | ||
return label; | ||
} | ||
if (typeof value === 'string') { | ||
return value; | ||
} // Fall back string representation | ||
return String(option); | ||
}; | ||
function useSelect(props) { | ||
@@ -24,2 +40,4 @@ var buttonComponent = props.buttonComponent, | ||
options = props.options, | ||
_props$optionStringif = props.optionStringifier, | ||
optionStringifier = _props$optionStringif === void 0 ? defaultOptionStringifier : _props$optionStringif, | ||
valueProp = props.value; | ||
@@ -228,2 +246,3 @@ var buttonRef = React.useRef(null); | ||
options: options, | ||
optionStringifier: optionStringifier, | ||
value: selectedOption | ||
@@ -251,2 +270,3 @@ }; | ||
options: options, | ||
optionStringifier: optionStringifier, | ||
stateReducer: listboxReducer, | ||
@@ -253,0 +273,0 @@ value: selectedOption |
@@ -37,3 +37,3 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
value: element.props.value, | ||
label: element.props.children, | ||
label: element.props.label || element.props.children, | ||
disabled: (_element$props$disabl2 = element.props.disabled) != null ? _element$props$disabl2 : false | ||
@@ -40,0 +40,0 @@ }; |
@@ -17,7 +17,7 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Switches](https://mui.com/components/switches/) | ||
* - [Switch](https://mui.com/base/react-switch/) | ||
* | ||
* API: | ||
* | ||
* - [SwitchUnstyled API](https://mui.com/api/switch-unstyled/) | ||
* - [SwitchUnstyled API](https://mui.com/base/api/switch-unstyled/) | ||
*/ | ||
@@ -24,0 +24,0 @@ var SwitchUnstyled = /*#__PURE__*/React.forwardRef(function SwitchUnstyled(props, ref) { |
@@ -47,7 +47,7 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Tables](https://mui.com/components/tables/) | ||
* - [Table Pagination](https://mui.com/base/react-table-pagination/) | ||
* | ||
* API: | ||
* | ||
* - [TablePaginationUnstyled API](https://mui.com/api/table-pagination-unstyled/) | ||
* - [TablePaginationUnstyled API](https://mui.com/base/api/table-pagination-unstyled/) | ||
*/ | ||
@@ -54,0 +54,0 @@ |
@@ -23,7 +23,7 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Tabs](https://mui.com/components/tabs/) | ||
* - [Tabs](https://mui.com/base/react-tabs/) | ||
* | ||
* API: | ||
* | ||
* - [TabPanelUnstyled API](https://mui.com/api/tab-panel-unstyled/) | ||
* - [TabPanelUnstyled API](https://mui.com/base/api/tab-panel-unstyled/) | ||
*/ | ||
@@ -30,0 +30,0 @@ |
@@ -23,7 +23,7 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Tabs](https://mui.com/components/tabs/) | ||
* - [Tabs](https://mui.com/base/react-tabs/) | ||
* | ||
* API: | ||
* | ||
* - [TabsListUnstyled API](https://mui.com/api/tabs-list-unstyled/) | ||
* - [TabsListUnstyled API](https://mui.com/base/api/tabs-list-unstyled/) | ||
*/ | ||
@@ -30,0 +30,0 @@ |
@@ -24,7 +24,7 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Tabs](https://mui.com/components/tabs/) | ||
* - [Tabs](https://mui.com/base/react-tabs/) | ||
* | ||
* API: | ||
* | ||
* - [TabsUnstyled API](https://mui.com/api/tabs-unstyled/) | ||
* - [TabsUnstyled API](https://mui.com/base/api/tabs-unstyled/) | ||
*/ | ||
@@ -31,0 +31,0 @@ |
@@ -25,7 +25,7 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Tabs](https://mui.com/components/tabs/) | ||
* - [Tabs](https://mui.com/base/react-tabs/) | ||
* | ||
* API: | ||
* | ||
* - [TabUnstyled API](https://mui.com/api/tab-unstyled/) | ||
* - [TabUnstyled API](https://mui.com/base/api/tab-unstyled/) | ||
*/ | ||
@@ -32,0 +32,0 @@ |
import { ListboxState, ListboxAction } from './useListbox.types'; | ||
export default function defaultListboxReducer<TOption>(state: Readonly<ListboxState<TOption>>, action: ListboxAction<TOption>): Readonly<ListboxState<TOption>>; |
@@ -178,2 +178,53 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
const textCriteriaMatches = (nextFocus, searchString, stringifyOption) => { | ||
var _stringifyOption; | ||
const text = (_stringifyOption = stringifyOption(nextFocus)) == null ? void 0 : _stringifyOption.trim().toLowerCase(); | ||
if (!text || text.length === 0) { | ||
// Make option not navigable if stringification fails or results in empty string. | ||
return false; | ||
} | ||
return text.indexOf(searchString) === 0; | ||
}; | ||
function handleTextNavigation(state, searchString, props) { | ||
const { | ||
options, | ||
isOptionDisabled, | ||
disableListWrap, | ||
disabledItemsFocusable, | ||
optionComparer, | ||
optionStringifier | ||
} = props; | ||
const moveHighlight = previouslyHighlightedOption => { | ||
return getNewHighlightedOption(options, previouslyHighlightedOption, 1, 'next', disabledItemsFocusable != null ? disabledItemsFocusable : false, isOptionDisabled != null ? isOptionDisabled : () => false, !(disableListWrap != null ? disableListWrap : false), optionComparer); | ||
}; | ||
const startWithCurrentOption = searchString.length > 1; | ||
let nextOption = startWithCurrentOption ? state.highlightedValue : moveHighlight(state.highlightedValue); // use `for` instead of `while` prevent infinite loop | ||
for (let index = 0; index < options.length; index += 1) { | ||
// Return un-mutated state if looped back to the currently highlighted value | ||
if (!nextOption || !startWithCurrentOption && state.highlightedValue === nextOption) { | ||
return state; | ||
} | ||
if (textCriteriaMatches(nextOption, searchString, optionStringifier) && (!isOptionDisabled(nextOption, options.indexOf(nextOption)) || disabledItemsFocusable)) { | ||
// The nextOption is the element to be highlighted | ||
return _extends({}, state, { | ||
highlightedValue: nextOption | ||
}); | ||
} // Move to the next element. | ||
nextOption = moveHighlight(nextOption); | ||
} // No option match text search criteria | ||
return state; | ||
} | ||
function handleOptionsChange(options, previousOptions, state, props) { | ||
@@ -232,2 +283,5 @@ var _options$find, _options$find2; | ||
case ActionTypes.textNavigation: | ||
return handleTextNavigation(state, action.searchString, action.props); | ||
case ActionTypes.optionsChange: | ||
@@ -234,0 +288,0 @@ return handleOptionsChange(action.options, action.previousOptions, state, action.props); |
export { default as useListbox } from './useListbox'; | ||
export { default as defaultListboxReducer } from './defaultListboxReducer'; | ||
export * from './useListbox.types'; |
import { ListboxAction, ListboxReducer, ListboxState, UseListboxStrictProps } from './useListbox.types'; | ||
export default function useControllableReducer<TOption>(internalReducer: ListboxReducer<TOption>, externalReducer: ListboxReducer<TOption> | undefined, props: UseListboxStrictProps<TOption>): [ListboxState<TOption>, (action: ListboxAction<TOption>) => void]; |
@@ -0,0 +0,0 @@ import { UseListboxParameters, OptionState, UseListboxOptionSlotProps, UseListboxRootSlotProps } from './useListbox.types'; |
@@ -8,2 +8,3 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import areArraysEqual from '../utils/areArraysEqual'; | ||
const TEXT_NAVIGATION_RESET_TIMEOUT = 500; // milliseconds | ||
@@ -14,2 +15,4 @@ const defaultOptionComparer = (optionA, optionB) => optionA === optionB; | ||
const defaultOptionStringifier = option => typeof option === 'string' ? option : String(option); | ||
export default function useListbox(props) { | ||
@@ -27,2 +30,3 @@ var _props$optionIdGenera, _options$highlightedI; | ||
optionComparer = defaultOptionComparer, | ||
optionStringifier = defaultOptionStringifier, | ||
options, | ||
@@ -45,3 +49,4 @@ stateReducer: externalReducer | ||
multiple, | ||
optionComparer | ||
optionComparer, | ||
optionStringifier | ||
}); | ||
@@ -51,2 +56,6 @@ | ||
const handleRef = useForkRef(externalListboxRef, listboxRef); | ||
const textCriteriaRef = React.useRef({ | ||
searchString: '', | ||
lastTime: null | ||
}); | ||
const [{ | ||
@@ -141,3 +150,23 @@ highlightedValue, | ||
props: propsWithDefaults | ||
}); | ||
}); // Handle text navigation | ||
if (event.key.length === 1) { | ||
const textCriteria = textCriteriaRef.current; | ||
const lowerKey = event.key.toLowerCase(); | ||
const currentTime = performance.now(); | ||
if (textCriteria.searchString.length > 0 && textCriteria.lastTime && currentTime - textCriteria.lastTime > TEXT_NAVIGATION_RESET_TIMEOUT) { | ||
textCriteria.searchString = lowerKey; | ||
} else if (textCriteria.searchString.length !== 1 || lowerKey !== textCriteria.searchString) { | ||
// If there is just one character in the buffer and the key is the same, do not append | ||
textCriteria.searchString += lowerKey; | ||
} | ||
textCriteria.lastTime = currentTime; | ||
dispatch({ | ||
type: ActionTypes.textNavigation, | ||
searchString: textCriteria.searchString, | ||
props: propsWithDefaults | ||
}); | ||
} | ||
}; | ||
@@ -144,0 +173,0 @@ |
import * as React from 'react'; | ||
declare type UseListboxStrictPropsRequiredKeys = 'isOptionDisabled' | 'disableListWrap' | 'disabledItemsFocusable' | 'optionComparer' | 'multiple'; | ||
declare type UseListboxStrictPropsRequiredKeys = 'isOptionDisabled' | 'disableListWrap' | 'disabledItemsFocusable' | 'optionComparer' | 'optionStringifier' | 'multiple'; | ||
export declare type UseListboxStrictProps<TOption> = Omit<UseListboxParameters<TOption>, UseListboxStrictPropsRequiredKeys> & Required<Pick<UseListboxParameters<TOption>, UseListboxStrictPropsRequiredKeys>>; | ||
@@ -13,3 +13,4 @@ export declare type FocusManagementType = 'DOM' | 'activeDescendant'; | ||
setValue = "setValue", | ||
setHighlight = "setHighlight" | ||
setHighlight = "setHighlight", | ||
textNavigation = "textNagivation" | ||
} | ||
@@ -52,2 +53,7 @@ export { ActionTypes }; | ||
} | ||
interface TextNavigationAction<TOption> { | ||
type: ActionTypes.textNavigation; | ||
searchString: string; | ||
props: UseListboxStrictProps<TOption>; | ||
} | ||
interface OptionsChangeAction<TOption> { | ||
@@ -59,3 +65,3 @@ type: ActionTypes.optionsChange; | ||
} | ||
export declare type ListboxAction<TOption> = OptionClickAction<TOption> | OptionHoverAction<TOption> | FocusAction<TOption> | BlurAction<TOption> | KeyDownAction<TOption> | SetHighlightAction<TOption> | SetValueAction<TOption> | OptionsChangeAction<TOption>; | ||
export declare type ListboxAction<TOption> = OptionClickAction<TOption> | OptionHoverAction<TOption> | FocusAction<TOption> | BlurAction<TOption> | KeyDownAction<TOption> | SetHighlightAction<TOption> | TextNavigationAction<TOption> | SetValueAction<TOption> | OptionsChangeAction<TOption>; | ||
export interface ListboxState<TOption> { | ||
@@ -105,2 +111,7 @@ highlightedValue: TOption | null; | ||
/** | ||
* A function that converts an object to its string representation | ||
* @default (o) => o | ||
*/ | ||
optionStringifier?: (option: TOption) => string | undefined; | ||
/** | ||
* Array of options to be rendered in the list. | ||
@@ -107,0 +118,0 @@ */ |
@@ -12,4 +12,5 @@ var ActionTypes; // split declaration and export due to https://github.com/codesandbox/codesandbox-client/issues/6435 | ||
ActionTypes["setHighlight"] = "setHighlight"; | ||
ActionTypes["textNavigation"] = "textNagivation"; | ||
})(ActionTypes || (ActionTypes = {})); | ||
export { ActionTypes }; |
@@ -0,0 +0,0 @@ export { default } from './MenuItemUnstyled'; |
@@ -0,0 +0,0 @@ import * as React from 'react'; |
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; | ||
const _excluded = ["children", "className", "disabled", "component", "components", "componentsProps"]; | ||
const _excluded = ["children", "className", "disabled", "component", "components", "componentsProps", "label"]; | ||
import * as React from 'react'; | ||
@@ -44,3 +44,4 @@ import PropTypes from 'prop-types'; | ||
components = {}, | ||
componentsProps = {} | ||
componentsProps = {}, | ||
label | ||
} = props, | ||
@@ -57,3 +58,4 @@ other = _objectWithoutPropertiesLoose(props, _excluded); | ||
disabled, | ||
ref | ||
ref, | ||
label | ||
}); | ||
@@ -118,4 +120,10 @@ | ||
*/ | ||
disabled: PropTypes.bool | ||
disabled: PropTypes.bool, | ||
/** | ||
* A text representation of the menu item's content. | ||
* Used for keyboard text navigation matching. | ||
*/ | ||
label: PropTypes.string | ||
} : void 0; | ||
export default MenuItemUnstyled; |
@@ -24,2 +24,7 @@ import * as React from 'react'; | ||
}; | ||
/** | ||
* A text representation of the menu item's content. | ||
* Used for keyboard text navigation matching. | ||
*/ | ||
label?: string; | ||
} |
@@ -0,0 +0,0 @@ export interface MenuItemUnstyledClasses { |
@@ -0,0 +0,0 @@ import * as React from 'react'; |
@@ -10,3 +10,4 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
disabled = false, | ||
ref | ||
ref, | ||
label | ||
} = props; | ||
@@ -35,6 +36,7 @@ const id = useId(); | ||
id, | ||
ref: itemRef | ||
ref: itemRef, | ||
label | ||
}); | ||
return () => unregisterItem(id); | ||
}, [id, registerItem, unregisterItem, disabled, ref]); | ||
}, [id, registerItem, unregisterItem, disabled, ref, label]); | ||
const { | ||
@@ -61,3 +63,4 @@ getRootProps: getButtonProps, | ||
id, | ||
disabled | ||
disabled, | ||
label | ||
}); | ||
@@ -64,0 +67,0 @@ const itemState = menuContext.getItemState(id != null ? id : ''); |
@@ -7,2 +7,3 @@ /// <reference types="react" /> | ||
ref: React.Ref<any>; | ||
label?: string; | ||
} |
@@ -0,0 +0,0 @@ export { default } from './MenuUnstyled'; |
@@ -0,0 +0,0 @@ import * as React from 'react'; |
@@ -0,0 +0,0 @@ import React from 'react'; |
@@ -0,0 +0,0 @@ export interface MenuUnstyledClasses { |
@@ -0,0 +0,0 @@ import * as React from 'react'; |
@@ -0,0 +0,0 @@ import * as React from 'react'; |
@@ -56,2 +56,7 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
options: Object.keys(menuItems), | ||
optionStringifier: id => { | ||
var _menuItems$id$ref$cur; | ||
return menuItems[id].label || ((_menuItems$id$ref$cur = menuItems[id].ref.current) == null ? void 0 : _menuItems$id$ref$cur.innerText); | ||
}, | ||
isOptionDisabled: id => { | ||
@@ -58,0 +63,0 @@ var _menuItems$id; |
@@ -7,2 +7,3 @@ import * as React from 'react'; | ||
ref: React.RefObject<HTMLElement>; | ||
label?: string; | ||
} | ||
@@ -9,0 +10,0 @@ export interface MenuItemState { |
@@ -0,0 +0,0 @@ export interface ManagedModalProps { |
@@ -0,0 +0,0 @@ export interface ModalUnstyledClasses { |
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; | ||
const _excluded = ["anchorOrigin", "classes", "badgeContent", "component", "children", "className", "components", "componentsProps", "invisible", "max", "showZero", "variant"]; | ||
const _excluded = ["badgeContent", "component", "children", "className", "components", "componentsProps", "invisible", "max", "showZero"]; | ||
import * as React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import clsx from 'clsx'; | ||
import { unstable_capitalize as capitalize } from '@mui/utils'; | ||
import composeClasses from '../composeClasses'; | ||
@@ -17,12 +16,9 @@ import appendOwnerState from '../utils/appendOwnerState'; | ||
const { | ||
variant, | ||
anchorOrigin, | ||
invisible, | ||
classes | ||
invisible | ||
} = ownerState; | ||
const slots = { | ||
root: ['root'], | ||
badge: ['badge', variant, `anchorOrigin${capitalize(anchorOrigin.vertical)}${capitalize(anchorOrigin.horizontal)}`, invisible && 'invisible'] | ||
badge: ['badge', invisible && 'invisible'] | ||
}; | ||
return composeClasses(slots, getBadgeUtilityClass, classes); | ||
return composeClasses(slots, getBadgeUtilityClass, undefined); | ||
}; | ||
@@ -32,7 +28,2 @@ | ||
const { | ||
anchorOrigin: anchorOriginProp = { | ||
vertical: 'top', | ||
horizontal: 'right' | ||
}, | ||
classes: classesProp, | ||
component, | ||
@@ -44,4 +35,3 @@ children, | ||
max: maxProp = 99, | ||
showZero = false, | ||
variant: variantProp = 'standard' | ||
showZero = false | ||
} = props, | ||
@@ -51,21 +41,14 @@ other = _objectWithoutPropertiesLoose(props, _excluded); | ||
const { | ||
anchorOrigin, | ||
badgeContent, | ||
max, | ||
variant, | ||
displayValue, | ||
invisible | ||
} = useBadge(_extends({}, props, { | ||
anchorOrigin: anchorOriginProp, | ||
max: maxProp, | ||
variant: variantProp | ||
max: maxProp | ||
})); | ||
const ownerState = _extends({}, props, { | ||
anchorOrigin, | ||
badgeContent, | ||
classes: classesProp, | ||
invisible, | ||
max, | ||
variant, | ||
showZero | ||
@@ -98,14 +81,2 @@ }); | ||
/** | ||
* The anchor of the badge. | ||
* @default { | ||
* vertical: 'top', | ||
* horizontal: 'right', | ||
* } | ||
*/ | ||
anchorOrigin: PropTypes.shape({ | ||
horizontal: PropTypes.oneOf(['left', 'right']).isRequired, | ||
vertical: PropTypes.oneOf(['bottom', 'top']).isRequired | ||
}), | ||
/** | ||
* The content rendered within the badge. | ||
@@ -121,7 +92,2 @@ */ | ||
/** | ||
* Override or extend the styles applied to the component. | ||
*/ | ||
classes: PropTypes.object, | ||
/** | ||
* @ignore | ||
@@ -172,10 +138,4 @@ */ | ||
*/ | ||
showZero: PropTypes.bool, | ||
/** | ||
* The variant to use. | ||
* @default 'standard' | ||
*/ | ||
variant: PropTypes.string | ||
showZero: PropTypes.bool | ||
} : void 0; | ||
export default BadgeUnstyled; |
import generateUtilityClasses from '../generateUtilityClasses'; | ||
import generateUtilityClass from '../generateUtilityClass'; | ||
export function getBadgeUtilityClass(slot) { | ||
return generateUtilityClass('MuiBadge', slot); | ||
return generateUtilityClass('BaseBadge', slot); | ||
} | ||
const badgeUnstyledClasses = generateUtilityClasses('MuiBadge', ['root', 'badge', 'dot', 'standard', 'anchorOriginTopLeft', 'anchorOriginTopRight', 'anchorOriginBottomLeft', 'anchorOriginBottomRight', 'invisible']); | ||
const badgeUnstyledClasses = generateUtilityClasses('BaseBadge', ['root', 'badge', 'invisible']); | ||
export default badgeUnstyledClasses; |
import { usePreviousProps } from '@mui/utils'; | ||
export default function useBadge(props) { | ||
const { | ||
anchorOrigin: anchorOriginProp = { | ||
vertical: 'top', | ||
horizontal: 'right' | ||
}, | ||
badgeContent: badgeContentProp, | ||
invisible: invisibleProp = false, | ||
max: maxProp = 99, | ||
showZero = false, | ||
variant: variantProp = 'standard' | ||
showZero = false | ||
} = props; | ||
const prevProps = usePreviousProps({ | ||
anchorOrigin: anchorOriginProp, | ||
badgeContent: badgeContentProp, | ||
max: maxProp, | ||
variant: variantProp | ||
max: maxProp | ||
}); | ||
let invisible = invisibleProp; | ||
if (invisibleProp === false && (badgeContentProp === 0 && !showZero || badgeContentProp == null && variantProp !== 'dot')) { | ||
if (invisibleProp === false && badgeContentProp === 0 && !showZero) { | ||
invisible = true; | ||
@@ -27,21 +20,12 @@ } | ||
const { | ||
anchorOrigin = anchorOriginProp, | ||
badgeContent, | ||
max = maxProp, | ||
variant = variantProp | ||
max = maxProp | ||
} = invisible ? prevProps : props; | ||
let displayValue = ''; | ||
if (variant !== 'dot') { | ||
displayValue = badgeContent && Number(badgeContent) > max ? `${max}+` : badgeContent; | ||
} | ||
const displayValue = badgeContent && Number(badgeContent) > max ? `${max}+` : badgeContent; | ||
return { | ||
anchorOrigin, | ||
badgeContent, | ||
invisible, | ||
max, | ||
variant, | ||
displayValue | ||
}; | ||
} |
@@ -21,5 +21,3 @@ import * as React from 'react'; | ||
* | ||
* - [Click Away Listener](https://mui.com/base/components/click-away-listener/) | ||
* - [Click Away Listener](https://mui.com/material-ui/react-click-away-listener/) | ||
* - [Menus](https://mui.com/material-ui/react-menu/) | ||
* - [Click Away Listener](https://mui.com/base/react-click-away-listener/) | ||
* | ||
@@ -26,0 +24,0 @@ * API: |
@@ -43,2 +43,3 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Form Control](https://mui.com/components/form-control/) | ||
* - [Text Fields](https://mui.com/components/text-fields/) | ||
@@ -45,0 +46,0 @@ * |
@@ -1,2 +0,2 @@ | ||
/** @license MUI v5.0.0-alpha.74 | ||
/** @license MUI v5.0.0-alpha.75 | ||
* | ||
@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the |
@@ -172,2 +172,51 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
const textCriteriaMatches = (nextFocus, searchString, stringifyOption) => { | ||
const text = stringifyOption(nextFocus)?.trim().toLowerCase(); | ||
if (!text || text.length === 0) { | ||
// Make option not navigable if stringification fails or results in empty string. | ||
return false; | ||
} | ||
return text.indexOf(searchString) === 0; | ||
}; | ||
function handleTextNavigation(state, searchString, props) { | ||
const { | ||
options, | ||
isOptionDisabled, | ||
disableListWrap, | ||
disabledItemsFocusable, | ||
optionComparer, | ||
optionStringifier | ||
} = props; | ||
const moveHighlight = previouslyHighlightedOption => { | ||
return getNewHighlightedOption(options, previouslyHighlightedOption, 1, 'next', disabledItemsFocusable ?? false, isOptionDisabled ?? (() => false), !(disableListWrap ?? false), optionComparer); | ||
}; | ||
const startWithCurrentOption = searchString.length > 1; | ||
let nextOption = startWithCurrentOption ? state.highlightedValue : moveHighlight(state.highlightedValue); // use `for` instead of `while` prevent infinite loop | ||
for (let index = 0; index < options.length; index += 1) { | ||
// Return un-mutated state if looped back to the currently highlighted value | ||
if (!nextOption || !startWithCurrentOption && state.highlightedValue === nextOption) { | ||
return state; | ||
} | ||
if (textCriteriaMatches(nextOption, searchString, optionStringifier) && (!isOptionDisabled(nextOption, options.indexOf(nextOption)) || disabledItemsFocusable)) { | ||
// The nextOption is the element to be highlighted | ||
return _extends({}, state, { | ||
highlightedValue: nextOption | ||
}); | ||
} // Move to the next element. | ||
nextOption = moveHighlight(nextOption); | ||
} // No option match text search criteria | ||
return state; | ||
} | ||
function handleOptionsChange(options, previousOptions, state, props) { | ||
@@ -222,2 +271,5 @@ const { | ||
case ActionTypes.textNavigation: | ||
return handleTextNavigation(state, action.searchString, action.props); | ||
case ActionTypes.optionsChange: | ||
@@ -224,0 +276,0 @@ return handleOptionsChange(action.options, action.previousOptions, state, action.props); |
@@ -8,2 +8,3 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import areArraysEqual from '../utils/areArraysEqual'; | ||
const TEXT_NAVIGATION_RESET_TIMEOUT = 500; // milliseconds | ||
@@ -14,2 +15,4 @@ const defaultOptionComparer = (optionA, optionB) => optionA === optionB; | ||
const defaultOptionStringifier = option => typeof option === 'string' ? option : String(option); | ||
export default function useListbox(props) { | ||
@@ -25,2 +28,3 @@ const { | ||
optionComparer = defaultOptionComparer, | ||
optionStringifier = defaultOptionStringifier, | ||
options, | ||
@@ -43,3 +47,4 @@ stateReducer: externalReducer | ||
multiple, | ||
optionComparer | ||
optionComparer, | ||
optionStringifier | ||
}); | ||
@@ -49,2 +54,6 @@ | ||
const handleRef = useForkRef(externalListboxRef, listboxRef); | ||
const textCriteriaRef = React.useRef({ | ||
searchString: '', | ||
lastTime: null | ||
}); | ||
const [{ | ||
@@ -133,3 +142,23 @@ highlightedValue, | ||
props: propsWithDefaults | ||
}); | ||
}); // Handle text navigation | ||
if (event.key.length === 1) { | ||
const textCriteria = textCriteriaRef.current; | ||
const lowerKey = event.key.toLowerCase(); | ||
const currentTime = performance.now(); | ||
if (textCriteria.searchString.length > 0 && textCriteria.lastTime && currentTime - textCriteria.lastTime > TEXT_NAVIGATION_RESET_TIMEOUT) { | ||
textCriteria.searchString = lowerKey; | ||
} else if (textCriteria.searchString.length !== 1 || lowerKey !== textCriteria.searchString) { | ||
// If there is just one character in the buffer and the key is the same, do not append | ||
textCriteria.searchString += lowerKey; | ||
} | ||
textCriteria.lastTime = currentTime; | ||
dispatch({ | ||
type: ActionTypes.textNavigation, | ||
searchString: textCriteria.searchString, | ||
props: propsWithDefaults | ||
}); | ||
} | ||
}; | ||
@@ -136,0 +165,0 @@ |
@@ -12,4 +12,5 @@ var ActionTypes; // split declaration and export due to https://github.com/codesandbox/codesandbox-client/issues/6435 | ||
ActionTypes["setHighlight"] = "setHighlight"; | ||
ActionTypes["textNavigation"] = "textNagivation"; | ||
})(ActionTypes || (ActionTypes = {})); | ||
export { ActionTypes }; |
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; | ||
const _excluded = ["children", "className", "disabled", "component", "components", "componentsProps"]; | ||
const _excluded = ["children", "className", "disabled", "component", "components", "componentsProps", "label"]; | ||
import * as React from 'react'; | ||
@@ -42,3 +42,4 @@ import PropTypes from 'prop-types'; | ||
components = {}, | ||
componentsProps = {} | ||
componentsProps = {}, | ||
label | ||
} = props, | ||
@@ -55,3 +56,4 @@ other = _objectWithoutPropertiesLoose(props, _excluded); | ||
disabled, | ||
ref | ||
ref, | ||
label | ||
}); | ||
@@ -116,4 +118,10 @@ | ||
*/ | ||
disabled: PropTypes.bool | ||
disabled: PropTypes.bool, | ||
/** | ||
* A text representation of the menu item's content. | ||
* Used for keyboard text navigation matching. | ||
*/ | ||
label: PropTypes.string | ||
} : void 0; | ||
export default MenuItemUnstyled; |
@@ -10,3 +10,4 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
disabled = false, | ||
ref | ||
ref, | ||
label | ||
} = props; | ||
@@ -35,6 +36,7 @@ const id = useId(); | ||
id, | ||
ref: itemRef | ||
ref: itemRef, | ||
label | ||
}); | ||
return () => unregisterItem(id); | ||
}, [id, registerItem, unregisterItem, disabled, ref]); | ||
}, [id, registerItem, unregisterItem, disabled, ref, label]); | ||
const { | ||
@@ -61,3 +63,4 @@ getRootProps: getButtonProps, | ||
id, | ||
disabled | ||
disabled, | ||
label | ||
}); | ||
@@ -64,0 +67,0 @@ const itemState = menuContext.getItemState(id ?? ''); |
@@ -56,2 +56,3 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
options: Object.keys(menuItems), | ||
optionStringifier: id => menuItems[id].label || menuItems[id].ref.current?.innerText, | ||
isOptionDisabled: id => menuItems?.[id]?.disabled || false, | ||
@@ -58,0 +59,0 @@ listboxRef: handleRef, |
@@ -280,9 +280,9 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Selects](https://mui.com/components/selects/) | ||
* - [Select](https://mui.com/base/react-select/) | ||
* | ||
* API: | ||
* | ||
* - [MultiSelectUnstyled API](https://mui.com/api/multi-select-unstyled/) | ||
* - [MultiSelectUnstyled API](https://mui.com/base/api/multi-select-unstyled/) | ||
*/ | ||
export default MultiSelectUnstyled; |
@@ -25,7 +25,7 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Selects](https://mui.com/components/selects/) | ||
* - [Select](https://mui.com/base/react-select/) | ||
* | ||
* API: | ||
* | ||
* - [OptionGroupUnstyled API](https://mui.com/api/option-group-unstyled/) | ||
* - [OptionGroupUnstyled API](https://mui.com/base/api/option-group-unstyled/) | ||
*/ | ||
@@ -32,0 +32,0 @@ |
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; | ||
const _excluded = ["children", "className", "component", "components", "componentsProps", "disabled", "value"]; | ||
const _excluded = ["children", "className", "component", "components", "componentsProps", "disabled", "value", "label"]; | ||
import React from 'react'; | ||
@@ -38,3 +38,4 @@ import clsx from 'clsx'; | ||
disabled, | ||
value | ||
value, | ||
label | ||
} = props, | ||
@@ -52,3 +53,3 @@ other = _objectWithoutPropertiesLoose(props, _excluded); | ||
value, | ||
label: children, | ||
label: label || children, | ||
disabled | ||
@@ -140,2 +141,8 @@ }; | ||
/** | ||
* A text representation of the option's content. | ||
* Used for keyboard text navigation matching. | ||
*/ | ||
label: PropTypes.string, | ||
/** | ||
* The value of the option. | ||
@@ -150,9 +157,9 @@ */ | ||
* | ||
* - [Selects](https://mui.com/components/selects/) | ||
* - [Select](https://mui.com/base/react-select/) | ||
* | ||
* API: | ||
* | ||
* - [OptionUnstyled API](https://mui.com/api/option-unstyled/) | ||
* - [OptionUnstyled API](https://mui.com/base/api/option-unstyled/) | ||
*/ | ||
export default /*#__PURE__*/React.memo(OptionUnstyled); |
@@ -278,9 +278,9 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Selects](https://mui.com/components/selects/) | ||
* - [Select](https://mui.com/base/react-select/) | ||
* | ||
* API: | ||
* | ||
* - [SelectUnstyled API](https://mui.com/api/select-unstyled/) | ||
* - [SelectUnstyled API](https://mui.com/base/api/select-unstyled/) | ||
*/ | ||
export default SelectUnstyled; |
@@ -7,2 +7,20 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
const defaultOptionStringifier = option => { | ||
const { | ||
label, | ||
value | ||
} = option; | ||
if (typeof label === 'string') { | ||
return label; | ||
} | ||
if (typeof value === 'string') { | ||
return value; | ||
} // Fall back string representation | ||
return String(option); | ||
}; | ||
function useSelect(props) { | ||
@@ -21,2 +39,3 @@ const { | ||
options, | ||
optionStringifier = defaultOptionStringifier, | ||
value: valueProp | ||
@@ -174,2 +193,3 @@ } = props; | ||
options, | ||
optionStringifier, | ||
value: selectedOption | ||
@@ -189,2 +209,3 @@ }; | ||
options, | ||
optionStringifier, | ||
stateReducer: listboxReducer, | ||
@@ -191,0 +212,0 @@ value: selectedOption |
@@ -33,3 +33,3 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
value: element.props.value, | ||
label: element.props.children, | ||
label: element.props.label || element.props.children, | ||
disabled: element.props.disabled ?? false | ||
@@ -36,0 +36,0 @@ }; |
@@ -18,7 +18,7 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Switches](https://mui.com/components/switches/) | ||
* - [Switch](https://mui.com/base/react-switch/) | ||
* | ||
* API: | ||
* | ||
* - [SwitchUnstyled API](https://mui.com/api/switch-unstyled/) | ||
* - [SwitchUnstyled API](https://mui.com/base/api/switch-unstyled/) | ||
*/ | ||
@@ -25,0 +25,0 @@ const SwitchUnstyled = /*#__PURE__*/React.forwardRef(function SwitchUnstyled(props, ref) { |
@@ -49,7 +49,7 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Tables](https://mui.com/components/tables/) | ||
* - [Table Pagination](https://mui.com/base/react-table-pagination/) | ||
* | ||
* API: | ||
* | ||
* - [TablePaginationUnstyled API](https://mui.com/api/table-pagination-unstyled/) | ||
* - [TablePaginationUnstyled API](https://mui.com/base/api/table-pagination-unstyled/) | ||
*/ | ||
@@ -56,0 +56,0 @@ |
@@ -26,7 +26,7 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Tabs](https://mui.com/components/tabs/) | ||
* - [Tabs](https://mui.com/base/react-tabs/) | ||
* | ||
* API: | ||
* | ||
* - [TabPanelUnstyled API](https://mui.com/api/tab-panel-unstyled/) | ||
* - [TabPanelUnstyled API](https://mui.com/base/api/tab-panel-unstyled/) | ||
*/ | ||
@@ -33,0 +33,0 @@ |
@@ -26,7 +26,7 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Tabs](https://mui.com/components/tabs/) | ||
* - [Tabs](https://mui.com/base/react-tabs/) | ||
* | ||
* API: | ||
* | ||
* - [TabsListUnstyled API](https://mui.com/api/tabs-list-unstyled/) | ||
* - [TabsListUnstyled API](https://mui.com/base/api/tabs-list-unstyled/) | ||
*/ | ||
@@ -33,0 +33,0 @@ |
@@ -27,7 +27,7 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Tabs](https://mui.com/components/tabs/) | ||
* - [Tabs](https://mui.com/base/react-tabs/) | ||
* | ||
* API: | ||
* | ||
* - [TabsUnstyled API](https://mui.com/api/tabs-unstyled/) | ||
* - [TabsUnstyled API](https://mui.com/base/api/tabs-unstyled/) | ||
*/ | ||
@@ -34,0 +34,0 @@ |
@@ -28,7 +28,7 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Tabs](https://mui.com/components/tabs/) | ||
* - [Tabs](https://mui.com/base/react-tabs/) | ||
* | ||
* API: | ||
* | ||
* - [TabUnstyled API](https://mui.com/api/tab-unstyled/) | ||
* - [TabUnstyled API](https://mui.com/base/api/tab-unstyled/) | ||
*/ | ||
@@ -35,0 +35,0 @@ |
export { default } from './MultiSelectUnstyled'; | ||
export * from './MultiSelectUnstyled.types'; |
@@ -9,8 +9,8 @@ import * as React from 'react'; | ||
* | ||
* - [Selects](https://mui.com/components/selects/) | ||
* - [Select](https://mui.com/base/react-select/) | ||
* | ||
* API: | ||
* | ||
* - [MultiSelectUnstyled API](https://mui.com/api/multi-select-unstyled/) | ||
* - [MultiSelectUnstyled API](https://mui.com/base/api/multi-select-unstyled/) | ||
*/ | ||
export default _default; |
@@ -282,9 +282,9 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Selects](https://mui.com/components/selects/) | ||
* - [Select](https://mui.com/base/react-select/) | ||
* | ||
* API: | ||
* | ||
* - [MultiSelectUnstyled API](https://mui.com/api/multi-select-unstyled/) | ||
* - [MultiSelectUnstyled API](https://mui.com/base/api/multi-select-unstyled/) | ||
*/ | ||
export default MultiSelectUnstyled; |
@@ -0,0 +0,0 @@ import * as React from 'react'; |
@@ -20,4 +20,2 @@ "use strict"; | ||
var _utils = require("@mui/utils"); | ||
var _composeClasses = _interopRequireDefault(require("../composeClasses")); | ||
@@ -33,3 +31,3 @@ | ||
const _excluded = ["anchorOrigin", "classes", "badgeContent", "component", "children", "className", "components", "componentsProps", "invisible", "max", "showZero", "variant"]; | ||
const _excluded = ["badgeContent", "component", "children", "className", "components", "componentsProps", "invisible", "max", "showZero"]; | ||
@@ -42,12 +40,9 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
const { | ||
variant, | ||
anchorOrigin, | ||
invisible, | ||
classes | ||
invisible | ||
} = ownerState; | ||
const slots = { | ||
root: ['root'], | ||
badge: ['badge', variant, `anchorOrigin${(0, _utils.unstable_capitalize)(anchorOrigin.vertical)}${(0, _utils.unstable_capitalize)(anchorOrigin.horizontal)}`, invisible && 'invisible'] | ||
badge: ['badge', invisible && 'invisible'] | ||
}; | ||
return (0, _composeClasses.default)(slots, _badgeUnstyledClasses.getBadgeUtilityClass, classes); | ||
return (0, _composeClasses.default)(slots, _badgeUnstyledClasses.getBadgeUtilityClass, undefined); | ||
}; | ||
@@ -57,7 +52,2 @@ | ||
const { | ||
anchorOrigin: anchorOriginProp = { | ||
vertical: 'top', | ||
horizontal: 'right' | ||
}, | ||
classes: classesProp, | ||
component, | ||
@@ -69,25 +59,17 @@ children, | ||
max: maxProp = 99, | ||
showZero = false, | ||
variant: variantProp = 'standard' | ||
showZero = false | ||
} = props, | ||
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded); | ||
const { | ||
anchorOrigin, | ||
badgeContent, | ||
max, | ||
variant, | ||
displayValue, | ||
invisible | ||
} = (0, _useBadge.default)((0, _extends2.default)({}, props, { | ||
anchorOrigin: anchorOriginProp, | ||
max: maxProp, | ||
variant: variantProp | ||
max: maxProp | ||
})); | ||
const ownerState = (0, _extends2.default)({}, props, { | ||
anchorOrigin, | ||
badgeContent, | ||
classes: classesProp, | ||
invisible, | ||
max, | ||
variant, | ||
showZero | ||
@@ -119,14 +101,2 @@ }); | ||
/** | ||
* The anchor of the badge. | ||
* @default { | ||
* vertical: 'top', | ||
* horizontal: 'right', | ||
* } | ||
*/ | ||
anchorOrigin: _propTypes.default.shape({ | ||
horizontal: _propTypes.default.oneOf(['left', 'right']).isRequired, | ||
vertical: _propTypes.default.oneOf(['bottom', 'top']).isRequired | ||
}), | ||
/** | ||
* The content rendered within the badge. | ||
@@ -142,7 +112,2 @@ */ | ||
/** | ||
* Override or extend the styles applied to the component. | ||
*/ | ||
classes: _propTypes.default.object, | ||
/** | ||
* @ignore | ||
@@ -193,11 +158,5 @@ */ | ||
*/ | ||
showZero: _propTypes.default.bool, | ||
/** | ||
* The variant to use. | ||
* @default 'standard' | ||
*/ | ||
variant: _propTypes.default.string | ||
showZero: _propTypes.default.bool | ||
} : void 0; | ||
var _default = BadgeUnstyled; | ||
exports.default = _default; |
@@ -16,7 +16,7 @@ "use strict"; | ||
function getBadgeUtilityClass(slot) { | ||
return (0, _generateUtilityClass.default)('MuiBadge', slot); | ||
return (0, _generateUtilityClass.default)('BaseBadge', slot); | ||
} | ||
const badgeUnstyledClasses = (0, _generateUtilityClasses.default)('MuiBadge', ['root', 'badge', 'dot', 'standard', 'anchorOriginTopLeft', 'anchorOriginTopRight', 'anchorOriginBottomLeft', 'anchorOriginBottomRight', 'invisible']); | ||
const badgeUnstyledClasses = (0, _generateUtilityClasses.default)('BaseBadge', ['root', 'badge', 'invisible']); | ||
var _default = badgeUnstyledClasses; | ||
exports.default = _default; |
@@ -12,21 +12,14 @@ "use strict"; | ||
const { | ||
anchorOrigin: anchorOriginProp = { | ||
vertical: 'top', | ||
horizontal: 'right' | ||
}, | ||
badgeContent: badgeContentProp, | ||
invisible: invisibleProp = false, | ||
max: maxProp = 99, | ||
showZero = false, | ||
variant: variantProp = 'standard' | ||
showZero = false | ||
} = props; | ||
const prevProps = (0, _utils.usePreviousProps)({ | ||
anchorOrigin: anchorOriginProp, | ||
badgeContent: badgeContentProp, | ||
max: maxProp, | ||
variant: variantProp | ||
max: maxProp | ||
}); | ||
let invisible = invisibleProp; | ||
if (invisibleProp === false && (badgeContentProp === 0 && !showZero || badgeContentProp == null && variantProp !== 'dot')) { | ||
if (invisibleProp === false && badgeContentProp === 0 && !showZero) { | ||
invisible = true; | ||
@@ -36,21 +29,12 @@ } | ||
const { | ||
anchorOrigin = anchorOriginProp, | ||
badgeContent, | ||
max = maxProp, | ||
variant = variantProp | ||
max = maxProp | ||
} = invisible ? prevProps : props; | ||
let displayValue = ''; | ||
if (variant !== 'dot') { | ||
displayValue = badgeContent && Number(badgeContent) > max ? `${max}+` : badgeContent; | ||
} | ||
const displayValue = badgeContent && Number(badgeContent) > max ? `${max}+` : badgeContent; | ||
return { | ||
anchorOrigin, | ||
badgeContent, | ||
invisible, | ||
max, | ||
variant, | ||
displayValue | ||
}; | ||
} |
@@ -37,5 +37,3 @@ "use strict"; | ||
* | ||
* - [Click Away Listener](https://mui.com/base/components/click-away-listener/) | ||
* - [Click Away Listener](https://mui.com/material-ui/react-click-away-listener/) | ||
* - [Menus](https://mui.com/material-ui/react-menu/) | ||
* - [Click Away Listener](https://mui.com/base/react-click-away-listener/) | ||
* | ||
@@ -42,0 +40,0 @@ * API: |
@@ -66,2 +66,3 @@ "use strict"; | ||
* | ||
* - [Form Control](https://mui.com/components/form-control/) | ||
* - [Text Fields](https://mui.com/components/text-fields/) | ||
@@ -68,0 +69,0 @@ * |
@@ -1,2 +0,2 @@ | ||
/** @license MUI v5.0.0-alpha.74 | ||
/** @license MUI v5.0.0-alpha.75 | ||
* | ||
@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the |
@@ -189,2 +189,53 @@ "use strict"; | ||
const textCriteriaMatches = (nextFocus, searchString, stringifyOption) => { | ||
var _stringifyOption; | ||
const text = (_stringifyOption = stringifyOption(nextFocus)) == null ? void 0 : _stringifyOption.trim().toLowerCase(); | ||
if (!text || text.length === 0) { | ||
// Make option not navigable if stringification fails or results in empty string. | ||
return false; | ||
} | ||
return text.indexOf(searchString) === 0; | ||
}; | ||
function handleTextNavigation(state, searchString, props) { | ||
const { | ||
options, | ||
isOptionDisabled, | ||
disableListWrap, | ||
disabledItemsFocusable, | ||
optionComparer, | ||
optionStringifier | ||
} = props; | ||
const moveHighlight = previouslyHighlightedOption => { | ||
return getNewHighlightedOption(options, previouslyHighlightedOption, 1, 'next', disabledItemsFocusable != null ? disabledItemsFocusable : false, isOptionDisabled != null ? isOptionDisabled : () => false, !(disableListWrap != null ? disableListWrap : false), optionComparer); | ||
}; | ||
const startWithCurrentOption = searchString.length > 1; | ||
let nextOption = startWithCurrentOption ? state.highlightedValue : moveHighlight(state.highlightedValue); // use `for` instead of `while` prevent infinite loop | ||
for (let index = 0; index < options.length; index += 1) { | ||
// Return un-mutated state if looped back to the currently highlighted value | ||
if (!nextOption || !startWithCurrentOption && state.highlightedValue === nextOption) { | ||
return state; | ||
} | ||
if (textCriteriaMatches(nextOption, searchString, optionStringifier) && (!isOptionDisabled(nextOption, options.indexOf(nextOption)) || disabledItemsFocusable)) { | ||
// The nextOption is the element to be highlighted | ||
return (0, _extends2.default)({}, state, { | ||
highlightedValue: nextOption | ||
}); | ||
} // Move to the next element. | ||
nextOption = moveHighlight(nextOption); | ||
} // No option match text search criteria | ||
return state; | ||
} | ||
function handleOptionsChange(options, previousOptions, state, props) { | ||
@@ -243,2 +294,5 @@ var _options$find, _options$find2; | ||
case _useListbox.ActionTypes.textNavigation: | ||
return handleTextNavigation(state, action.searchString, action.props); | ||
case _useListbox.ActionTypes.optionsChange: | ||
@@ -245,0 +299,0 @@ return handleOptionsChange(action.options, action.previousOptions, state, action.props); |
@@ -28,2 +28,4 @@ "use strict"; | ||
const TEXT_NAVIGATION_RESET_TIMEOUT = 500; // milliseconds | ||
const defaultOptionComparer = (optionA, optionB) => optionA === optionB; | ||
@@ -33,2 +35,4 @@ | ||
const defaultOptionStringifier = option => typeof option === 'string' ? option : String(option); | ||
function useListbox(props) { | ||
@@ -46,2 +50,3 @@ var _props$optionIdGenera, _options$highlightedI; | ||
optionComparer = defaultOptionComparer, | ||
optionStringifier = defaultOptionStringifier, | ||
options, | ||
@@ -63,6 +68,11 @@ stateReducer: externalReducer | ||
multiple, | ||
optionComparer | ||
optionComparer, | ||
optionStringifier | ||
}); | ||
const listboxRef = React.useRef(null); | ||
const handleRef = (0, _utils.unstable_useForkRef)(externalListboxRef, listboxRef); | ||
const textCriteriaRef = React.useRef({ | ||
searchString: '', | ||
lastTime: null | ||
}); | ||
const [{ | ||
@@ -157,3 +167,23 @@ highlightedValue, | ||
props: propsWithDefaults | ||
}); | ||
}); // Handle text navigation | ||
if (event.key.length === 1) { | ||
const textCriteria = textCriteriaRef.current; | ||
const lowerKey = event.key.toLowerCase(); | ||
const currentTime = performance.now(); | ||
if (textCriteria.searchString.length > 0 && textCriteria.lastTime && currentTime - textCriteria.lastTime > TEXT_NAVIGATION_RESET_TIMEOUT) { | ||
textCriteria.searchString = lowerKey; | ||
} else if (textCriteria.searchString.length !== 1 || lowerKey !== textCriteria.searchString) { | ||
// If there is just one character in the buffer and the key is the same, do not append | ||
textCriteria.searchString += lowerKey; | ||
} | ||
textCriteria.lastTime = currentTime; | ||
dispatch({ | ||
type: _useListbox.ActionTypes.textNavigation, | ||
searchString: textCriteria.searchString, | ||
props: propsWithDefaults | ||
}); | ||
} | ||
}; | ||
@@ -160,0 +190,0 @@ |
@@ -20,2 +20,3 @@ "use strict"; | ||
ActionTypes["setHighlight"] = "setHighlight"; | ||
ActionTypes["textNavigation"] = "textNagivation"; | ||
})(ActionTypes || (exports.ActionTypes = ActionTypes = {})); |
@@ -30,3 +30,3 @@ "use strict"; | ||
const _excluded = ["children", "className", "disabled", "component", "components", "componentsProps"]; | ||
const _excluded = ["children", "className", "disabled", "component", "components", "componentsProps", "label"]; | ||
@@ -68,3 +68,4 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
components = {}, | ||
componentsProps = {} | ||
componentsProps = {}, | ||
label | ||
} = props, | ||
@@ -80,3 +81,4 @@ other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded); | ||
disabled, | ||
ref | ||
ref, | ||
label | ||
}); | ||
@@ -140,5 +142,11 @@ | ||
*/ | ||
disabled: _propTypes.default.bool | ||
disabled: _propTypes.default.bool, | ||
/** | ||
* A text representation of the menu item's content. | ||
* Used for keyboard text navigation matching. | ||
*/ | ||
label: _propTypes.default.string | ||
} : void 0; | ||
var _default = MenuItemUnstyled; | ||
exports.default = _default; |
@@ -28,3 +28,4 @@ "use strict"; | ||
disabled = false, | ||
ref | ||
ref, | ||
label | ||
} = props; | ||
@@ -53,6 +54,7 @@ const id = (0, _utils.unstable_useId)(); | ||
id, | ||
ref: itemRef | ||
ref: itemRef, | ||
label | ||
}); | ||
return () => unregisterItem(id); | ||
}, [id, registerItem, unregisterItem, disabled, ref]); | ||
}, [id, registerItem, unregisterItem, disabled, ref, label]); | ||
const { | ||
@@ -79,3 +81,4 @@ getRootProps: getButtonProps, | ||
id, | ||
disabled | ||
disabled, | ||
label | ||
}); | ||
@@ -82,0 +85,0 @@ const itemState = menuContext.getItemState(id != null ? id : ''); |
@@ -70,2 +70,7 @@ "use strict"; | ||
options: Object.keys(menuItems), | ||
optionStringifier: id => { | ||
var _menuItems$id$ref$cur; | ||
return menuItems[id].label || ((_menuItems$id$ref$cur = menuItems[id].ref.current) == null ? void 0 : _menuItems$id$ref$cur.innerText); | ||
}, | ||
isOptionDisabled: id => { | ||
@@ -72,0 +77,0 @@ var _menuItems$id; |
@@ -305,7 +305,7 @@ "use strict"; | ||
* | ||
* - [Selects](https://mui.com/components/selects/) | ||
* - [Select](https://mui.com/base/react-select/) | ||
* | ||
* API: | ||
* | ||
* - [MultiSelectUnstyled API](https://mui.com/api/multi-select-unstyled/) | ||
* - [MultiSelectUnstyled API](https://mui.com/base/api/multi-select-unstyled/) | ||
*/ | ||
@@ -312,0 +312,0 @@ |
@@ -41,7 +41,7 @@ "use strict"; | ||
* | ||
* - [Selects](https://mui.com/components/selects/) | ||
* - [Select](https://mui.com/base/react-select/) | ||
* | ||
* API: | ||
* | ||
* - [OptionGroupUnstyled API](https://mui.com/api/option-group-unstyled/) | ||
* - [OptionGroupUnstyled API](https://mui.com/base/api/option-group-unstyled/) | ||
*/ | ||
@@ -48,0 +48,0 @@ |
@@ -32,3 +32,3 @@ "use strict"; | ||
const _excluded = ["children", "className", "component", "components", "componentsProps", "disabled", "value"]; | ||
const _excluded = ["children", "className", "component", "components", "componentsProps", "disabled", "value", "label"]; | ||
@@ -61,3 +61,4 @@ function useUtilityClasses(ownerState) { | ||
disabled, | ||
value | ||
value, | ||
label | ||
} = props, | ||
@@ -75,3 +76,3 @@ other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded); | ||
value, | ||
label: children, | ||
label: label || children, | ||
disabled | ||
@@ -166,2 +167,8 @@ }; | ||
/** | ||
* A text representation of the option's content. | ||
* Used for keyboard text navigation matching. | ||
*/ | ||
label: _propTypes.default.string, | ||
/** | ||
* The value of the option. | ||
@@ -176,7 +183,7 @@ */ | ||
* | ||
* - [Selects](https://mui.com/components/selects/) | ||
* - [Select](https://mui.com/base/react-select/) | ||
* | ||
* API: | ||
* | ||
* - [OptionUnstyled API](https://mui.com/api/option-unstyled/) | ||
* - [OptionUnstyled API](https://mui.com/base/api/option-unstyled/) | ||
*/ | ||
@@ -183,0 +190,0 @@ |
@@ -305,7 +305,7 @@ "use strict"; | ||
* | ||
* - [Selects](https://mui.com/components/selects/) | ||
* - [Select](https://mui.com/base/react-select/) | ||
* | ||
* API: | ||
* | ||
* - [SelectUnstyled API](https://mui.com/api/select-unstyled/) | ||
* - [SelectUnstyled API](https://mui.com/base/api/select-unstyled/) | ||
*/ | ||
@@ -312,0 +312,0 @@ |
@@ -24,2 +24,20 @@ "use strict"; | ||
const defaultOptionStringifier = option => { | ||
const { | ||
label, | ||
value | ||
} = option; | ||
if (typeof label === 'string') { | ||
return label; | ||
} | ||
if (typeof value === 'string') { | ||
return value; | ||
} // Fall back string representation | ||
return String(option); | ||
}; | ||
function useSelect(props) { | ||
@@ -38,2 +56,3 @@ const { | ||
options, | ||
optionStringifier = defaultOptionStringifier, | ||
value: valueProp | ||
@@ -213,2 +232,3 @@ } = props; | ||
options, | ||
optionStringifier, | ||
value: selectedOption | ||
@@ -234,2 +254,3 @@ }; | ||
options, | ||
optionStringifier, | ||
stateReducer: listboxReducer, | ||
@@ -236,0 +257,0 @@ value: selectedOption |
@@ -53,3 +53,3 @@ "use strict"; | ||
value: element.props.value, | ||
label: element.props.children, | ||
label: element.props.label || element.props.children, | ||
disabled: (_element$props$disabl2 = element.props.disabled) != null ? _element$props$disabl2 : false | ||
@@ -56,0 +56,0 @@ }; |
@@ -39,7 +39,7 @@ "use strict"; | ||
* | ||
* - [Switches](https://mui.com/components/switches/) | ||
* - [Switch](https://mui.com/base/react-switch/) | ||
* | ||
* API: | ||
* | ||
* - [SwitchUnstyled API](https://mui.com/api/switch-unstyled/) | ||
* - [SwitchUnstyled API](https://mui.com/base/api/switch-unstyled/) | ||
*/ | ||
@@ -46,0 +46,0 @@ const SwitchUnstyled = /*#__PURE__*/React.forwardRef(function SwitchUnstyled(props, ref) { |
@@ -72,7 +72,7 @@ "use strict"; | ||
* | ||
* - [Tables](https://mui.com/components/tables/) | ||
* - [Table Pagination](https://mui.com/base/react-table-pagination/) | ||
* | ||
* API: | ||
* | ||
* - [TablePaginationUnstyled API](https://mui.com/api/table-pagination-unstyled/) | ||
* - [TablePaginationUnstyled API](https://mui.com/base/api/table-pagination-unstyled/) | ||
*/ | ||
@@ -79,0 +79,0 @@ |
@@ -49,7 +49,7 @@ "use strict"; | ||
* | ||
* - [Tabs](https://mui.com/components/tabs/) | ||
* - [Tabs](https://mui.com/base/react-tabs/) | ||
* | ||
* API: | ||
* | ||
* - [TabPanelUnstyled API](https://mui.com/api/tab-panel-unstyled/) | ||
* - [TabPanelUnstyled API](https://mui.com/base/api/tab-panel-unstyled/) | ||
*/ | ||
@@ -56,0 +56,0 @@ |
@@ -49,7 +49,7 @@ "use strict"; | ||
* | ||
* - [Tabs](https://mui.com/components/tabs/) | ||
* - [Tabs](https://mui.com/base/react-tabs/) | ||
* | ||
* API: | ||
* | ||
* - [TabsListUnstyled API](https://mui.com/api/tabs-list-unstyled/) | ||
* - [TabsListUnstyled API](https://mui.com/base/api/tabs-list-unstyled/) | ||
*/ | ||
@@ -56,0 +56,0 @@ |
@@ -51,7 +51,7 @@ "use strict"; | ||
* | ||
* - [Tabs](https://mui.com/components/tabs/) | ||
* - [Tabs](https://mui.com/base/react-tabs/) | ||
* | ||
* API: | ||
* | ||
* - [TabsUnstyled API](https://mui.com/api/tabs-unstyled/) | ||
* - [TabsUnstyled API](https://mui.com/base/api/tabs-unstyled/) | ||
*/ | ||
@@ -58,0 +58,0 @@ |
@@ -52,7 +52,7 @@ "use strict"; | ||
* | ||
* - [Tabs](https://mui.com/components/tabs/) | ||
* - [Tabs](https://mui.com/base/react-tabs/) | ||
* | ||
* API: | ||
* | ||
* - [TabUnstyled API](https://mui.com/api/tab-unstyled/) | ||
* - [TabUnstyled API](https://mui.com/base/api/tab-unstyled/) | ||
*/ | ||
@@ -59,0 +59,0 @@ |
@@ -33,4 +33,3 @@ import * as React from 'react'; | ||
* | ||
* - [No Ssr](https://mui.com/base/components/no-ssr/) | ||
* - [No Ssr](https://mui.com/material-ui/react-no-ssr/) | ||
* - [No Ssr](https://mui.com/base/react-no-ssr/) | ||
* | ||
@@ -37,0 +36,0 @@ * API: |
@@ -0,0 +0,0 @@ export { default } from './OptionGroupUnstyled'; |
@@ -8,9 +8,9 @@ import React from 'react'; | ||
* | ||
* - [Selects](https://mui.com/components/selects/) | ||
* - [Select](https://mui.com/base/react-select/) | ||
* | ||
* API: | ||
* | ||
* - [OptionGroupUnstyled API](https://mui.com/api/option-group-unstyled/) | ||
* - [OptionGroupUnstyled API](https://mui.com/base/api/option-group-unstyled/) | ||
*/ | ||
declare const OptionGroupUnstyled: React.ForwardRefExoticComponent<OptionGroupUnstyledProps & React.RefAttributes<HTMLLIElement>>; | ||
export default OptionGroupUnstyled; |
@@ -25,7 +25,7 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Selects](https://mui.com/components/selects/) | ||
* - [Select](https://mui.com/base/react-select/) | ||
* | ||
* API: | ||
* | ||
* - [OptionGroupUnstyled API](https://mui.com/api/option-group-unstyled/) | ||
* - [OptionGroupUnstyled API](https://mui.com/base/api/option-group-unstyled/) | ||
*/ | ||
@@ -32,0 +32,0 @@ |
@@ -0,0 +0,0 @@ export interface OptionGroupUnstyledClasses { |
@@ -0,0 +0,0 @@ import React from 'react'; |
@@ -0,0 +0,0 @@ export { default } from './OptionUnstyled'; |
@@ -9,8 +9,8 @@ import React from 'react'; | ||
* | ||
* - [Selects](https://mui.com/components/selects/) | ||
* - [Select](https://mui.com/base/react-select/) | ||
* | ||
* API: | ||
* | ||
* - [OptionUnstyled API](https://mui.com/api/option-unstyled/) | ||
* - [OptionUnstyled API](https://mui.com/base/api/option-unstyled/) | ||
*/ | ||
export default _default; |
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; | ||
const _excluded = ["children", "className", "component", "components", "componentsProps", "disabled", "value"]; | ||
const _excluded = ["children", "className", "component", "components", "componentsProps", "disabled", "value", "label"]; | ||
import React from 'react'; | ||
@@ -40,3 +40,4 @@ import clsx from 'clsx'; | ||
disabled, | ||
value | ||
value, | ||
label | ||
} = props, | ||
@@ -54,3 +55,3 @@ other = _objectWithoutPropertiesLoose(props, _excluded); | ||
value, | ||
label: children, | ||
label: label || children, | ||
disabled | ||
@@ -142,2 +143,8 @@ }; | ||
/** | ||
* A text representation of the option's content. | ||
* Used for keyboard text navigation matching. | ||
*/ | ||
label: PropTypes.string, | ||
/** | ||
* The value of the option. | ||
@@ -152,9 +159,9 @@ */ | ||
* | ||
* - [Selects](https://mui.com/components/selects/) | ||
* - [Select](https://mui.com/base/react-select/) | ||
* | ||
* API: | ||
* | ||
* - [OptionUnstyled API](https://mui.com/api/option-unstyled/) | ||
* - [OptionUnstyled API](https://mui.com/base/api/option-unstyled/) | ||
*/ | ||
export default /*#__PURE__*/React.memo(OptionUnstyled); |
@@ -0,0 +0,0 @@ export interface OptionUnstyledClasses { |
@@ -39,3 +39,8 @@ import React from 'react'; | ||
}; | ||
/** | ||
* A text representation of the option's content. | ||
* Used for keyboard text navigation matching. | ||
*/ | ||
label?: string; | ||
} | ||
export declare type OptionUnstyledOwnerState<TValue> = OptionUnstyledProps<TValue> & OptionState; |
{ | ||
"name": "@mui/base", | ||
"version": "5.0.0-alpha.74", | ||
"version": "5.0.0-alpha.75", | ||
"private": false, | ||
@@ -30,5 +30,5 @@ "author": "MUI Team", | ||
"peerDependencies": { | ||
"@types/react": "^16.8.6 || ^17.0.0", | ||
"react": "^17.0.0", | ||
"react-dom": "^17.0.0" | ||
"@types/react": "^16.8.6 || ^17.0.0 || ^18.0.0", | ||
"react": "^17.0.0 || ^18.0.0", | ||
"react-dom": "^17.0.0 || ^18.0.0" | ||
}, | ||
@@ -44,3 +44,3 @@ "peerDependenciesMeta": { | ||
"@mui/types": "^7.1.3", | ||
"@mui/utils": "^5.5.3", | ||
"@mui/utils": "^5.6.0", | ||
"@popperjs/core": "^2.11.4", | ||
@@ -47,0 +47,0 @@ "clsx": "^1.1.1", |
@@ -95,8 +95,8 @@ import * as React from 'react'; | ||
* | ||
* - [Popper](https://mui.com/components/popper/) | ||
* - [Popper](https://mui.com/base/react-popper/) | ||
* | ||
* API: | ||
* | ||
* - [PopperUnstyled API](https://mui.com/api/popper-unstyled/) | ||
* - [PopperUnstyled API](https://mui.com/base/api/popper-unstyled/) | ||
*/ | ||
export default function PopperUnstyled(props: PopperUnstyledProps): JSX.Element; |
@@ -30,3 +30,2 @@ import * as React from 'react'; | ||
* - [Portal](https://mui.com/base/react-portal/) | ||
* - [Portal](https://mui.com/material/react-portal/) | ||
* | ||
@@ -33,0 +32,0 @@ * API: |
@@ -0,0 +0,0 @@ export { default } from './SelectUnstyled'; |
@@ -9,8 +9,8 @@ import * as React from 'react'; | ||
* | ||
* - [Selects](https://mui.com/components/selects/) | ||
* - [Select](https://mui.com/base/react-select/) | ||
* | ||
* API: | ||
* | ||
* - [SelectUnstyled API](https://mui.com/api/select-unstyled/) | ||
* - [SelectUnstyled API](https://mui.com/base/api/select-unstyled/) | ||
*/ | ||
export default _default; |
@@ -282,9 +282,9 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Selects](https://mui.com/components/selects/) | ||
* - [Select](https://mui.com/base/react-select/) | ||
* | ||
* API: | ||
* | ||
* - [SelectUnstyled API](https://mui.com/api/select-unstyled/) | ||
* - [SelectUnstyled API](https://mui.com/base/api/select-unstyled/) | ||
*/ | ||
export default SelectUnstyled; |
@@ -0,0 +0,0 @@ import * as React from 'react'; |
@@ -0,0 +0,0 @@ export interface SelectUnstyledClasses { |
@@ -0,0 +0,0 @@ import * as React from 'react'; |
@@ -0,0 +0,0 @@ import { UseSelectMultiParameters, UseSelectMultiResult, UseSelectSingleParameters, UseSelectSingleResult } from './useSelect.types'; |
@@ -7,2 +7,20 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
const defaultOptionStringifier = option => { | ||
const { | ||
label, | ||
value | ||
} = option; | ||
if (typeof label === 'string') { | ||
return label; | ||
} | ||
if (typeof value === 'string') { | ||
return value; | ||
} // Fall back string representation | ||
return String(option); | ||
}; | ||
function useSelect(props) { | ||
@@ -21,2 +39,3 @@ const { | ||
options, | ||
optionStringifier = defaultOptionStringifier, | ||
value: valueProp | ||
@@ -196,2 +215,3 @@ } = props; | ||
options, | ||
optionStringifier, | ||
value: selectedOption | ||
@@ -217,2 +237,3 @@ }; | ||
options, | ||
optionStringifier, | ||
stateReducer: listboxReducer, | ||
@@ -219,0 +240,0 @@ value: selectedOption |
@@ -26,2 +26,3 @@ import React from 'react'; | ||
options: SelectOption<TValue>[]; | ||
optionStringifier?: (option: SelectOption<TValue>) => string; | ||
} | ||
@@ -28,0 +29,0 @@ export interface UseSelectSingleParameters<TValue> extends UseSelectCommonProps<TValue> { |
@@ -0,0 +0,0 @@ import React from 'react'; |
@@ -37,3 +37,3 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
value: element.props.value, | ||
label: element.props.children, | ||
label: element.props.label || element.props.children, | ||
disabled: (_element$props$disabl2 = element.props.disabled) != null ? _element$props$disabl2 : false | ||
@@ -40,0 +40,0 @@ }; |
@@ -8,7 +8,7 @@ import { OverridableComponent } from '@mui/types'; | ||
* | ||
* - [Slider](https://mui.com/components/slider/) | ||
* - [Slider](https://mui.com/base/react-slider/) | ||
* | ||
* API: | ||
* | ||
* - [SliderUnstyled API](https://mui.com/api/slider-unstyled/) | ||
* - [SliderUnstyled API](https://mui.com/base/api/slider-unstyled/) | ||
*/ | ||
@@ -15,0 +15,0 @@ declare const SliderUnstyled: OverridableComponent<SliderUnstyledTypeMap>; |
@@ -0,0 +0,0 @@ export interface SliderUnstyledClasses { |
@@ -0,0 +0,0 @@ /// <reference types="react" /> |
@@ -0,0 +0,0 @@ export { default } from './SwitchUnstyled'; |
@@ -43,9 +43,9 @@ import * as React from 'react'; | ||
* | ||
* - [Switches](https://mui.com/components/switches/) | ||
* - [Switch](https://mui.com/base/react-switch/) | ||
* | ||
* API: | ||
* | ||
* - [SwitchUnstyled API](https://mui.com/api/switch-unstyled/) | ||
* - [SwitchUnstyled API](https://mui.com/base/api/switch-unstyled/) | ||
*/ | ||
declare const SwitchUnstyled: React.ForwardRefExoticComponent<SwitchUnstyledProps & React.RefAttributes<any>>; | ||
export default SwitchUnstyled; |
@@ -18,7 +18,7 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Switches](https://mui.com/components/switches/) | ||
* - [Switch](https://mui.com/base/react-switch/) | ||
* | ||
* API: | ||
* | ||
* - [SwitchUnstyled API](https://mui.com/api/switch-unstyled/) | ||
* - [SwitchUnstyled API](https://mui.com/base/api/switch-unstyled/) | ||
*/ | ||
@@ -25,0 +25,0 @@ const SwitchUnstyled = /*#__PURE__*/React.forwardRef(function SwitchUnstyled(props, ref) { |
@@ -0,0 +0,0 @@ export interface SwitchUnstyledClasses { |
@@ -0,0 +0,0 @@ import * as React from 'react'; |
@@ -0,0 +0,0 @@ export { default } from './TablePaginationUnstyled'; |
@@ -0,0 +0,0 @@ import { OverridableComponent } from '@mui/types'; |
@@ -0,0 +0,0 @@ import * as React from 'react'; |
@@ -8,9 +8,9 @@ import { OverridableComponent } from '@mui/types'; | ||
* | ||
* - [Tables](https://mui.com/components/tables/) | ||
* - [Table Pagination](https://mui.com/base/react-table-pagination/) | ||
* | ||
* API: | ||
* | ||
* - [TablePaginationUnstyled API](https://mui.com/api/table-pagination-unstyled/) | ||
* - [TablePaginationUnstyled API](https://mui.com/base/api/table-pagination-unstyled/) | ||
*/ | ||
declare const TablePaginationUnstyled: OverridableComponent<TablePaginationUnstyledTypeMap<{}, "td">>; | ||
export default TablePaginationUnstyled; |
@@ -49,7 +49,7 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Tables](https://mui.com/components/tables/) | ||
* - [Table Pagination](https://mui.com/base/react-table-pagination/) | ||
* | ||
* API: | ||
* | ||
* - [TablePaginationUnstyled API](https://mui.com/api/table-pagination-unstyled/) | ||
* - [TablePaginationUnstyled API](https://mui.com/base/api/table-pagination-unstyled/) | ||
*/ | ||
@@ -56,0 +56,0 @@ |
@@ -0,0 +0,0 @@ export interface TablePaginationUnstyledClasses { |
@@ -0,0 +0,0 @@ import * as React from 'react'; |
@@ -0,0 +0,0 @@ export { default } from './TabPanelUnstyled'; |
@@ -7,9 +7,9 @@ import { OverridableComponent } from '@mui/types'; | ||
* | ||
* - [Tabs](https://mui.com/components/tabs/) | ||
* - [Tabs](https://mui.com/base/react-tabs/) | ||
* | ||
* API: | ||
* | ||
* - [TabPanelUnstyled API](https://mui.com/api/tab-panel-unstyled/) | ||
* - [TabPanelUnstyled API](https://mui.com/base/api/tab-panel-unstyled/) | ||
*/ | ||
declare const TabPanelUnstyled: OverridableComponent<TabPanelUnstyledTypeMap<{}, "div">>; | ||
export default TabPanelUnstyled; |
@@ -26,7 +26,7 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Tabs](https://mui.com/components/tabs/) | ||
* - [Tabs](https://mui.com/base/react-tabs/) | ||
* | ||
* API: | ||
* | ||
* - [TabPanelUnstyled API](https://mui.com/api/tab-panel-unstyled/) | ||
* - [TabPanelUnstyled API](https://mui.com/base/api/tab-panel-unstyled/) | ||
*/ | ||
@@ -33,0 +33,0 @@ |
@@ -0,0 +0,0 @@ export interface TabPanelUnstyledClasses { |
@@ -0,0 +0,0 @@ import React from 'react'; |
@@ -0,0 +0,0 @@ export interface UseTabPanelProps { |
@@ -0,0 +0,0 @@ export { default } from './TabsListUnstyled'; |
@@ -7,9 +7,9 @@ import { OverridableComponent } from '@mui/types'; | ||
* | ||
* - [Tabs](https://mui.com/components/tabs/) | ||
* - [Tabs](https://mui.com/base/react-tabs/) | ||
* | ||
* API: | ||
* | ||
* - [TabsListUnstyled API](https://mui.com/api/tabs-list-unstyled/) | ||
* - [TabsListUnstyled API](https://mui.com/base/api/tabs-list-unstyled/) | ||
*/ | ||
declare const TabsListUnstyled: OverridableComponent<TabsListUnstyledTypeMap<{}, "div">>; | ||
export default TabsListUnstyled; |
@@ -26,7 +26,7 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Tabs](https://mui.com/components/tabs/) | ||
* - [Tabs](https://mui.com/base/react-tabs/) | ||
* | ||
* API: | ||
* | ||
* - [TabsListUnstyled API](https://mui.com/api/tabs-list-unstyled/) | ||
* - [TabsListUnstyled API](https://mui.com/base/api/tabs-list-unstyled/) | ||
*/ | ||
@@ -33,0 +33,0 @@ |
@@ -0,0 +0,0 @@ export interface TabsListUnstyledClasses { |
@@ -0,0 +0,0 @@ import React from 'react'; |
@@ -0,0 +0,0 @@ import * as React from 'react'; |
@@ -0,0 +0,0 @@ export { default } from './TabsUnstyled'; |
@@ -0,0 +0,0 @@ import * as React from 'react'; |
@@ -7,9 +7,9 @@ import { OverridableComponent } from '@mui/types'; | ||
* | ||
* - [Tabs](https://mui.com/components/tabs/) | ||
* - [Tabs](https://mui.com/base/react-tabs/) | ||
* | ||
* API: | ||
* | ||
* - [TabsUnstyled API](https://mui.com/api/tabs-unstyled/) | ||
* - [TabsUnstyled API](https://mui.com/base/api/tabs-unstyled/) | ||
*/ | ||
declare const TabsUnstyled: OverridableComponent<TabsUnstyledTypeMap<{}, "div">>; | ||
export default TabsUnstyled; |
@@ -27,7 +27,7 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Tabs](https://mui.com/components/tabs/) | ||
* - [Tabs](https://mui.com/base/react-tabs/) | ||
* | ||
* API: | ||
* | ||
* - [TabsUnstyled API](https://mui.com/api/tabs-unstyled/) | ||
* - [TabsUnstyled API](https://mui.com/base/api/tabs-unstyled/) | ||
*/ | ||
@@ -34,0 +34,0 @@ |
@@ -0,0 +0,0 @@ export interface TabsUnstyledClasses { |
@@ -0,0 +0,0 @@ import React from 'react'; |
@@ -0,0 +0,0 @@ import * as React from 'react'; |
@@ -0,0 +0,0 @@ export { default } from './TabUnstyled'; |
@@ -7,9 +7,9 @@ import { OverridableComponent } from '@mui/types'; | ||
* | ||
* - [Tabs](https://mui.com/components/tabs/) | ||
* - [Tabs](https://mui.com/base/react-tabs/) | ||
* | ||
* API: | ||
* | ||
* - [TabUnstyled API](https://mui.com/api/tab-unstyled/) | ||
* - [TabUnstyled API](https://mui.com/base/api/tab-unstyled/) | ||
*/ | ||
declare const TabUnstyled: OverridableComponent<TabUnstyledTypeMap<{}, "button">>; | ||
export default TabUnstyled; |
@@ -28,7 +28,7 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
* | ||
* - [Tabs](https://mui.com/components/tabs/) | ||
* - [Tabs](https://mui.com/base/react-tabs/) | ||
* | ||
* API: | ||
* | ||
* - [TabUnstyled API](https://mui.com/api/tab-unstyled/) | ||
* - [TabUnstyled API](https://mui.com/base/api/tab-unstyled/) | ||
*/ | ||
@@ -35,0 +35,0 @@ |
@@ -0,0 +0,0 @@ export interface TabUnstyledClasses { |
@@ -0,0 +0,0 @@ /// <reference types="react" /> |
@@ -0,0 +0,0 @@ /// <reference types="react" /> |
@@ -59,3 +59,3 @@ import * as React from 'react'; | ||
* | ||
* - [Trap Focus](https://mui.com/base/components/trap-focus/) | ||
* - [Trap Focus](https://mui.com/base/react-trap-focus/) | ||
* | ||
@@ -62,0 +62,0 @@ * API: |
@@ -0,0 +0,0 @@ /// <reference types="react" /> |
declare type ItemComparer<T> = (a: T, b: T) => boolean; | ||
export default function areArraysEqual<T>(array1: T[], array2: T[], itemComparer?: ItemComparer<T>): boolean; | ||
export {}; |
@@ -0,0 +0,0 @@ import { EventHandlers } from './types'; |
@@ -0,0 +0,0 @@ export { default as appendOwnerState } from './appendOwnerState'; |
@@ -0,0 +0,0 @@ import React from 'react'; |
@@ -0,0 +0,0 @@ /// <reference types="react" /> |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2048387
41147
190
+ Added@types/react@18.3.6(transitive)
+ Addedreact@18.3.1(transitive)
+ Addedreact-dom@18.3.1(transitive)
+ Addedscheduler@0.23.2(transitive)
- Removed@types/react@17.0.81(transitive)
- Removed@types/scheduler@0.16.8(transitive)
- Removedreact@17.0.2(transitive)
- Removedreact-dom@17.0.2(transitive)
- Removedscheduler@0.20.2(transitive)
Updated@mui/utils@^5.6.0