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

Function DurationControl

packages/dev/s2-docs/src/VisualExampleClient.tsx:1349–1374  ·  view source on GitHub ↗
({control, value, onChange}: ControlProps)

Source from the content-addressed store, hash-verified

1347}
1348
1349function DurationControl({control, value, onChange}: ControlProps) {
1350 let key = Object.keys(value)[0];
1351 return (
1352 <Wrapper control={control} styles={style({gridColumnStart: 1, gridColumnEnd: -1})}>
1353 <div
1354 className={style({display: 'flex', flexDirection: 'column', gap: 4, width: controlWidth})}>
1355 <NumberField
1356 aria-label={control.name}
1357 placeholder="–"
1358 contextualHelp={<PropContextualHelp control={control} />}
1359 value={value[key]}
1360 minValue={1}
1361 onChange={value => onChange({[key]: value})}
1362 />
1363 <Picker
1364 aria-label={`${control.name} unit`}
1365 value={key}
1366 onChange={k => onChange({[String(k)]: value[key]})}>
1367 <PickerItem id="days">Days</PickerItem>
1368 <PickerItem id="weeks">Weeks</PickerItem>
1369 <PickerItem id="months">Months</PickerItem>
1370 </Picker>
1371 </div>
1372 </Wrapper>
1373 );
1374}
1375
1376function ChannelControl({control, value, onChange}) {
1377 let {props} = useContext(Context);

Callers

nothing calls this directly

Calls 1

onChangeFunction · 0.70

Tested by

no test coverage detected