MCPcopy Create free account
hub / github.com/adobe/react-spectrum / setValue

Function setValue

packages/react-stately/src/calendar/useCalendarState.ts:251–267  ·  view source on GitHub ↗
(newValue: CalendarDate | CalendarDate[] | null)

Source from the content-addressed store, hash-verified

249 }
250
251 function setValue(newValue: CalendarDate | CalendarDate[] | null) {
252 if (!props.isDisabled && !props.isReadOnly) {
253 if (newValue === null) {
254 setControlledValue(selectionMode === 'multiple' ? [] : null);
255 return;
256 }
257
258 if (Array.isArray(newValue)) {
259 setControlledValue(newValue.map(normalizeValue).filter(Boolean) as any);
260 } else {
261 let localValue = normalizeValue(newValue);
262 if (localValue) {
263 setControlledValue(localValue as any);
264 }
265 }
266 }
267 }
268
269 let isUnavailable = useMemo(() => {
270 if (!calendarDateValue) {

Callers 3

selectDateFunction · 0.70
selectDateFunction · 0.70
clearSelectionFunction · 0.70

Calls 2

normalizeValueFunction · 0.85
filterMethod · 0.65

Tested by

no test coverage detected