({props, collection, tabsRef}: WizardInnerProps)
| 371 | } |
| 372 | |
| 373 | function WizardInner({props, collection, tabsRef}: WizardInnerProps) { |
| 374 | let { |
| 375 | className, |
| 376 | selectedKey, |
| 377 | defaultSelectedKey, |
| 378 | onSelectionChange, |
| 379 | completedKeys, |
| 380 | allowsSelectingIncompleteSteps, |
| 381 | disabledKeys, |
| 382 | ...tabsProps |
| 383 | } = props; |
| 384 | |
| 385 | let state = useWizardState({ |
| 386 | collection, |
| 387 | selectedKey, |
| 388 | defaultSelectedKey, |
| 389 | onSelectionChange, |
| 390 | completedKeys, |
| 391 | allowsSelectingIncompleteSteps, |
| 392 | disabledKeys |
| 393 | }); |
| 394 | |
| 395 | let {previousKey, nextKey} = state; |
| 396 | |
| 397 | // Like Calendar, if the previous or next button becomes disabled while it's focused, e.g. on the |
| 398 | // first or last step, focus moves to the current step (see useWizardStep). |
| 399 | let [previousFocused, setPreviousFocused] = useState(false); |
| 400 | let previousDisabled = props.isDisabled || previousKey == null; |
| 401 | if (previousDisabled && previousFocused) { |
| 402 | setPreviousFocused(false); |
| 403 | state.setFocused(true); |
| 404 | } |
| 405 | |
| 406 | let [nextFocused, setNextFocused] = useState(false); |
| 407 | let nextDisabled = props.isDisabled || nextKey == null; |
| 408 | if (nextDisabled && nextFocused) { |
| 409 | setNextFocused(false); |
| 410 | state.setFocused(true); |
| 411 | } |
| 412 | |
| 413 | // Buttons with the previous and next slots move to the previous and next steps, and are disabled |
| 414 | // when there isn't one. The slots of an outer ButtonContext, such as the close slot of a Dialog, |
| 415 | // are kept so that their buttons still work within the wizard. |
| 416 | let buttonContext = useContext(ButtonContext); |
| 417 | let outerButtonSlots = |
| 418 | buttonContext && 'slots' in buttonContext ? buttonContext.slots : undefined; |
| 419 | let buttonSlots = { |
| 420 | [DEFAULT_SLOT]: {}, |
| 421 | ...outerButtonSlots, |
| 422 | previous: { |
| 423 | isDisabled: previousDisabled, |
| 424 | onPress: () => { |
| 425 | if (previousKey != null) { |
| 426 | state.setSelectedKey(previousKey); |
| 427 | } |
| 428 | }, |
| 429 | onFocusChange: setPreviousFocused |
| 430 | }, |
nothing calls this directly
no test coverage detected