grommet 2.57.0 → 2.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all/stories/AllComponents.stories.js +2 -1
- package/components/Accordion/Accordion.js +2 -1
- package/components/Accordion/stories/CustomHeader.stories.js +2 -1
- package/components/AccordionPanel/AccordionPanel.js +2 -1
- package/components/Anchor/Anchor.js +2 -1
- package/components/Anchor/StyledAnchor.js +2 -1
- package/components/Avatar/Avatar.js +2 -1
- package/components/Box/Box.js +2 -1
- package/components/Box/ResponsiveContainerProvider.js +2 -1
- package/components/Box/StyledBox.js +3 -2
- package/components/Box/stories/ColorContrast.stories.js +36 -0
- package/components/Box/stories/ResponsiveContainer.stories.js +2 -1
- package/components/Button/Badge.js +2 -1
- package/components/Button/BusyAnimation.js +9 -2
- package/components/Button/Button.js +14 -4
- package/components/Button/StyledButton.js +2 -1
- package/components/Button/StyledButtonKind.js +2 -1
- package/components/Button/stories/Busy.stories.js +2 -1
- package/components/Calendar/Calendar.js +2 -1
- package/components/Calendar/StyledCalendar.js +2 -1
- package/components/Calendar/stories/ActiveDate.stories.js +2 -1
- package/components/Calendar/stories/CustomDay.stories.js +2 -1
- package/components/Calendar/stories/CustomHeader.stories.js +2 -1
- package/components/Calendar/stories/CustomThemed/CustomSizeHeading.stories.js +2 -1
- package/components/Calendar/stories/Dual.stories.js +2 -1
- package/components/Calendar/stories/HeaderLevel.stories.js +2 -1
- package/components/Calendar/stories/Multiple.stories.js +2 -1
- package/components/Calendar/stories/ShowAdjacentDays.stories.js +2 -1
- package/components/Calendar/stories/Simple.stories.js +2 -1
- package/components/Card/Card.js +2 -1
- package/components/Cards/Cards.js +2 -1
- package/components/Cards/index.d.ts +2 -16
- package/components/Carousel/Carousel.js +2 -1
- package/components/Carousel/CarouselChild.js +2 -1
- package/components/Carousel/StyledCarousel.js +2 -1
- package/components/Chart/Chart.js +2 -1
- package/components/Chart/StyledChart.js +2 -1
- package/components/Chart/stories/Rich.stories.js +2 -1
- package/components/Chart/stories/Scan.stories.js +2 -1
- package/components/Chart/stories/Window.stories.js +2 -1
- package/components/Chart/stories/Zoom.stories.js +2 -1
- package/components/CheckBox/CheckBox.js +2 -1
- package/components/CheckBox/README.md +95 -0
- package/components/CheckBox/StyledCheckBox.js +104 -16
- package/components/CheckBox/stories/CustomThemed/Appearance.stories.tsx +160 -0
- package/components/CheckBox/stories/CustomThemed/Custom.stories.js +2 -1
- package/components/CheckBox/stories/CustomThemed/CustomToggle.stories.js +2 -1
- package/components/CheckBox/stories/Indeterminate.stories.js +2 -1
- package/components/CheckBox/stories/NoLabel.stories.js +2 -1
- package/components/CheckBox/stories/Simple.stories.js +2 -1
- package/components/CheckBox/stories/WithStickyDiv.stories.js +2 -1
- package/components/CheckBoxGroup/CheckBoxGroup.js +2 -1
- package/components/CheckBoxGroup/stories/Children.stories.js +2 -1
- package/components/CheckBoxGroup/stories/InitialValues.stories.js +2 -1
- package/components/Clock/Analog.js +2 -1
- package/components/Clock/Clock.js +2 -1
- package/components/Clock/Digital.js +2 -1
- package/components/Clock/StyledClock.js +2 -1
- package/components/Collapsible/Collapsible.js +2 -1
- package/components/Data/Data.js +2 -1
- package/components/Data/DataForm.js +2 -1
- package/components/Data/stories/Infinite.stories.js +2 -1
- package/components/Data/stories/Inline.stories.js +2 -1
- package/components/Data/stories/OnSelect.stories.js +2 -1
- package/components/Data/stories/SpaceX.stories.js +2 -1
- package/components/Data/stories/StarWars.stories.js +2 -1
- package/components/DataChart/DataChart.js +2 -1
- package/components/DataChart/Detail.js +2 -1
- package/components/DataChart/Legend.js +2 -1
- package/components/DataChart/XAxis.js +2 -1
- package/components/DataChart/XGuide.js +2 -1
- package/components/DataChart/YAxis.js +2 -1
- package/components/DataChart/YGuide.js +2 -1
- package/components/DataChart/stories/Prediction.stories.js +2 -1
- package/components/DataClearFilters/DataClearFilters.js +2 -1
- package/components/DataClearFilters/stories/Simple.stories.js +2 -1
- package/components/DataFilter/DataFilter.js +2 -1
- package/components/DataFilters/DataFilters.js +2 -1
- package/components/DataSearch/DataSearch.js +2 -1
- package/components/DataSort/DataSort.js +2 -1
- package/components/DataSummary/DataSummary.js +2 -1
- package/components/DataTable/Body.js +2 -1
- package/components/DataTable/Cell.js +2 -1
- package/components/DataTable/DataTable.js +2 -1
- package/components/DataTable/ExpanderCell.js +2 -1
- package/components/DataTable/Footer.js +2 -1
- package/components/DataTable/GroupedBody.js +2 -1
- package/components/DataTable/Header.js +2 -1
- package/components/DataTable/PlaceholderBody.js +2 -1
- package/components/DataTable/Resizer.js +2 -1
- package/components/DataTable/Searcher.js +2 -1
- package/components/DataTable/StyledDataTable.js +3 -2
- package/components/DataTable/stories/ControlledGrouped.stories.js +2 -1
- package/components/DataTable/stories/OnUpdate.stories.js +2 -1
- package/components/DataTable/stories/SpaceX.stories.js +2 -1
- package/components/DataTable/stories/SpaceXUngrouped.stories.js +2 -1
- package/components/DataTable/stories/rowDetails.stories.js +2 -1
- package/components/DataTableColumns/DataTableColumns.js +2 -1
- package/components/DataTableGroupBy/DataTableGroupBy.js +2 -1
- package/components/DataView/DataView.js +2 -1
- package/components/DateInput/DateInput.js +14 -7
- package/components/DateInput/stories/FormatInline.stories.js +2 -1
- package/components/DateTimeInput/DateTimeInput.js +21 -12
- package/components/DateTimeInput/StyledDateTimeInput.js +11 -2
- package/components/Diagram/Diagram.js +2 -1
- package/components/Diagram/StyledDiagram.js +2 -1
- package/components/Diagram/stories/Animated.stories.js +2 -1
- package/components/Diagram/stories/Progressing.stories.js +2 -1
- package/components/Drop/Drop.js +2 -1
- package/components/Drop/DropContainer.js +2 -1
- package/components/Drop/StyledDrop.js +2 -1
- package/components/Drop/stories/CustomThemed/Lazy.stories.js +2 -1
- package/components/Drop/stories/CustomThemed/Themed.stories.js +2 -1
- package/components/Drop/stories/Inline.stories.js +2 -1
- package/components/Drop/stories/Meter.stories.js +2 -1
- package/components/Drop/stories/Multiple.stories.js +2 -1
- package/components/Drop/stories/Overflow.stories.js +2 -1
- package/components/Drop/stories/Plain.stories.js +2 -1
- package/components/Drop/stories/Progressive.stories.js +2 -1
- package/components/Drop/stories/Simple.stories.js +2 -1
- package/components/Drop/stories/Styled.stories.js +2 -1
- package/components/DropButton/DropButton.js +2 -1
- package/components/FileInput/FileInput.js +78 -21
- package/components/FileInput/README.md +5 -0
- package/components/FocusedContainer.js +4 -2
- package/components/Form/Form.js +2 -1
- package/components/Form/FormContext.js +2 -1
- package/components/Form/stories/ArrayOfFormFields.stories.js +2 -1
- package/components/Form/stories/Controlled.stories.js +2 -1
- package/components/Form/stories/ControlledInput.stories.js +2 -1
- package/components/Form/stories/ControlledInputLazy.stories.js +2 -1
- package/components/Form/stories/ControlledLazy.stories.js +2 -1
- package/components/Form/stories/CustomThemed/FieldBorderPosition.stories.js +2 -1
- package/components/Form/stories/CustomThemed/FieldCustomStates.stories.js +2 -1
- package/components/Form/stories/DynamicFields.stories.js +2 -1
- package/components/Form/stories/FieldStates.stories.js +2 -1
- package/components/Form/stories/SolicitedFeedback.stories.js +2 -1
- package/components/Form/stories/UnsolicitedFeedback.stories.js +2 -1
- package/components/Form/stories/ValidateOnChange.stories.js +2 -1
- package/components/Form/stories/ValidateOnMount.stories.js +2 -1
- package/components/FormField/FormField.js +235 -76
- package/components/FormField/FormFieldContext.js +12 -0
- package/components/FormField/README.md +56 -1
- package/components/FormField/stories/CustomThemed/Appearance.stories.tsx +630 -0
- package/components/FormField/stories/Simple.stories.js +2 -1
- package/components/Grid/Grid.js +2 -1
- package/components/Grid/StyledGrid.js +2 -1
- package/components/Grid/stories/ResponsiveCards.stories.js +2 -1
- package/components/Grommet/Grommet.js +6 -2
- package/components/Grommet/StyledGrommet.js +5 -4
- package/components/Grommet/index.d.ts +10 -0
- package/components/Grommet/propTypes.js +6 -1
- package/components/Header/Header.js +2 -1
- package/components/Header/stories/Sticky.stories.js +2 -1
- package/components/Heading/Heading.js +2 -1
- package/components/Heading/HeadingSkeleton.js +2 -1
- package/components/Heading/StyledHeading.js +2 -1
- package/components/Image/Image.js +2 -1
- package/components/Image/StyledImage.js +2 -1
- package/components/InfiniteScroll/InfiniteScroll.js +2 -1
- package/components/Layer/Layer.js +2 -1
- package/components/Layer/LayerContainer.js +2 -1
- package/components/Layer/StyledLayer.js +2 -1
- package/components/List/List.js +2 -1
- package/components/List/stories/Order.stories.js +2 -1
- package/components/List/stories/Pinned.stories.js +2 -1
- package/components/Markdown/Markdown.js +2 -1
- package/components/MaskedInput/MaskedInput.js +2 -1
- package/components/Menu/Menu.js +3 -2
- package/components/Meter/Bar.js +2 -1
- package/components/Meter/Circle.js +2 -1
- package/components/Meter/Meter.js +2 -1
- package/components/Meter/StyledMeter.js +2 -1
- package/components/Meter/stories/Circle.stories.js +2 -1
- package/components/Meter/stories/VerticalBarMultiple.stories.js +2 -1
- package/components/NameValueList/NameValueList.js +2 -1
- package/components/NameValuePair/NameValuePair.js +2 -1
- package/components/Nav/stories/CustomThemed/JustifySidebar.stories.js +2 -1
- package/components/Nav/stories/Sidebar.stories.js +2 -1
- package/components/Notification/Notification.js +2 -1
- package/components/Notification/stories/Global.stories.js +2 -1
- package/components/Notification/stories/Title.stories.js +2 -1
- package/components/Notification/stories/TitleAndMessage.stories.js +2 -1
- package/components/Page/Page.js +2 -1
- package/components/Page/stories/PageNotificaton.stories.js +2 -1
- package/components/PageContent/PageContent.js +2 -1
- package/components/PageHeader/PageHeader.js +2 -1
- package/components/PageHeader/stories/MultipleActions.stories.js +2 -1
- package/components/Pagination/Pagination.js +2 -1
- package/components/Pagination/PaginationStep.js +2 -1
- package/components/Pagination/PaginationSummary.js +2 -1
- package/components/Pagination/stories/Grid.stories.js +2 -1
- package/components/Paragraph/Paragraph.js +2 -1
- package/components/Paragraph/ParagraphSkeleton.js +2 -1
- package/components/Paragraph/StyledParagraph.js +2 -1
- package/components/RadioButton/README.md +93 -1
- package/components/RadioButton/RadioButton.js +13 -5
- package/components/RadioButton/StyledRadioButton.js +103 -10
- package/components/RadioButton/stories/CustomThemed/Appearance.stories.tsx +190 -0
- package/components/RadioButtonGroup/RadioButtonGroup.js +2 -1
- package/components/RadioButtonGroup/stories/Children.stories.js +2 -1
- package/components/RadioButtonGroup/stories/CustomThemed/CustomTheme.stories.js +2 -1
- package/components/RadioButtonGroup/stories/Disabled.stories.js +2 -1
- package/components/RangeInput/RangeInput.js +2 -1
- package/components/RangeInput/StyledRangeInput.js +2 -1
- package/components/RangeInput/stories/CustomThemed/Bounds.stories.js +2 -1
- package/components/RangeSelector/EdgeControl.js +2 -1
- package/components/RangeSelector/RangeSelector.js +2 -1
- package/components/RangeSelector/index.d.ts +1 -10
- package/components/RangeSelector/stories/Basic.stories.js +2 -1
- package/components/RangeSelector/stories/CustomThemed/Custom.stories.js +2 -1
- package/components/RangeSelector/stories/CustomThemed/CustomEdgeControl.stories.js +2 -1
- package/components/RangeSelector/stories/Label.stories.js +2 -1
- package/components/RangeSelector/stories/Simple.stories.js +2 -1
- package/components/RangeSelector/stories/Step.stories.js +2 -1
- package/components/RangeSelector/stories/Thin.stories.js +2 -1
- package/components/RangeSelector/stories/Vertical.stories.js +2 -1
- package/components/RoutedAnchor/RoutedAnchor.js +2 -1
- package/components/RoutedButton/RoutedButton.js +2 -1
- package/components/Select/DefaultSelectTextInput.js +2 -1
- package/components/Select/Select.js +2 -1
- package/components/Select/SelectContainer.js +4 -3
- package/components/Select/StyledSelect.js +14 -4
- package/components/Select/stories/ChildrenRender.stories.js +2 -1
- package/components/Select/stories/Clear.stories.js +2 -1
- package/components/Select/stories/Controlled.stories.js +2 -1
- package/components/Select/stories/CustomThemed/CustomSearch.stories.js +2 -1
- package/components/Select/stories/Disabled.stories.js +2 -1
- package/components/Select/stories/InsideFormField.stories.js +2 -1
- package/components/Select/stories/Multiple.stories.js +2 -1
- package/components/Select/stories/ObjectOptions.stories.js +2 -1
- package/components/Select/stories/Search.stories.js +2 -1
- package/components/Select/stories/Simple.stories.js +2 -1
- package/components/Select/stories/ValueLabel.stories.js +2 -1
- package/components/Select/stories/components/SearchBorderBox.js +2 -1
- package/components/Select/stories/components/SearchInput.js +2 -1
- package/components/Select/utils.js +2 -1
- package/components/SelectMultiple/SelectMultiple.js +10 -4
- package/components/SelectMultiple/SelectMultipleContainer.js +2 -1
- package/components/SelectMultiple/SelectMultipleValue.js +2 -1
- package/components/SelectMultiple/SelectionSummary.js +2 -1
- package/components/SelectMultiple/stories/CustomMessages.stories.js +2 -1
- package/components/SelectMultiple/stories/Default.stories.js +2 -1
- package/components/SelectMultiple/stories/Disabled.stories.js +2 -1
- package/components/SelectMultiple/stories/FormField.stories.js +2 -1
- package/components/SelectMultiple/stories/Help.stories.js +2 -1
- package/components/SelectMultiple/stories/Limited.stories.js +2 -1
- package/components/SelectMultiple/stories/ObjectOptions.stories.js +2 -1
- package/components/SelectMultiple/stories/ShowSelectedInline.stories.js +2 -1
- package/components/Skeleton/Skeleton.js +2 -1
- package/components/Skeleton/SkeletonContext.js +2 -1
- package/components/Skeleton/stories/CustomThemed/Custom.stories.js +2 -1
- package/components/Skeleton/stories/GridContainer.stories.js +2 -1
- package/components/SkipLink/SkipLink.js +2 -1
- package/components/SkipLinks/SkipLinks.js +2 -1
- package/components/Spinner/Spinner.js +2 -1
- package/components/Spinner/stories/Animation.stories.js +2 -1
- package/components/Spinner/stories/Announced.stories.js +2 -1
- package/components/Stack/Stack.js +2 -1
- package/components/Stack/StyledStack.js +2 -1
- package/components/StarRating/StarRating.js +2 -1
- package/components/Stepper/Stepper.js +138 -101
- package/components/Stepper/StepperContext.js +5 -4
- package/components/Stepper/StepperDescription.js +6 -8
- package/components/Stepper/StepperHelperText.js +13 -15
- package/components/Stepper/StepperIndicator.js +37 -34
- package/components/Stepper/StepperLabel.js +11 -23
- package/components/Stepper/StepperStep.js +139 -82
- package/components/Stepper/StyledStepper.js +168 -115
- package/components/Stepper/index.d.ts +25 -13
- package/components/Stepper/index.js +5 -1
- package/components/Stepper/propTypes.js +3 -0
- package/components/Stepper/stories/Children.stories.tsx +73 -0
- package/components/Stepper/stories/CustomThemed.stories.tsx +301 -0
- package/components/Stepper/stories/CustomThemedHpe.stories.tsx +328 -0
- package/components/Stepper/stories/DisabledSteps.stories.js +2 -1
- package/components/Stepper/stories/ErrorStates.stories.js +2 -1
- package/components/Stepper/stories/HorizontalSteps.stories.js +2 -1
- package/components/Stepper/stories/Interactive.stories.js +2 -1
- package/components/Stepper/stories/KeyboardNavigation.stories.js +2 -1
- package/components/Stepper/stories/NestedSubSteps.stories.js +2 -1
- package/components/Stepper/stories/ThemingLightDark.stories.js +2 -1
- package/components/Stepper/stories/VerticalSteps.stories.js +2 -1
- package/components/Stepper/utils.js +54 -0
- package/components/Tab/StyledTab.js +2 -1
- package/components/Tab/Tab.js +2 -1
- package/components/Table/StyledTable.js +2 -1
- package/components/Table/Table.js +2 -1
- package/components/Table/stories/InfiniteScrollInTable.stories.js +2 -1
- package/components/TableBody/TableBody.js +2 -1
- package/components/TableCell/TableCell.js +2 -1
- package/components/TableFooter/TableFooter.js +2 -1
- package/components/TableHeader/TableHeader.js +2 -1
- package/components/TableRow/TableRow.js +2 -1
- package/components/Tabs/StyledTabs.js +2 -1
- package/components/Tabs/Tabs.js +2 -1
- package/components/Tabs/stories/CustomThemed/States.stories.js +2 -1
- package/components/Tabs/stories/Responsive.stories.js +2 -1
- package/components/Tag/Tag.js +2 -1
- package/components/Text/StyledText.js +2 -1
- package/components/Text/Text.js +2 -1
- package/components/Text/TextSkeleton.js +2 -1
- package/components/TextArea/StyledTextArea.js +5 -2
- package/components/TextArea/TextArea.js +2 -1
- package/components/TextArea/stories/CustomThemed/Themed.stories.js +2 -1
- package/components/TextArea/stories/InsideFormField.stories.js +2 -1
- package/components/TextArea/stories/NonResizable.stories.js +2 -1
- package/components/TextArea/stories/Simple.stories.js +2 -1
- package/components/TextInput/CopyButton.js +24 -6
- package/components/TextInput/README.md +29 -1
- package/components/TextInput/StyledTextInput.js +34 -26
- package/components/TextInput/TextInput.js +165 -41
- package/components/TextInput/index.d.ts +14 -3
- package/components/TextInput/propTypes.js +4 -0
- package/components/TextInput/stories/Clear.stories.tsx +68 -0
- package/components/TextInput/stories/ClearFormField.stories.tsx +45 -0
- package/components/TextInput/stories/Copy.stories.tsx +42 -0
- package/components/TextInput/stories/CopySecret.stories.tsx +44 -0
- package/components/TextInput/stories/InsideFormField.stories.js +2 -1
- package/components/TimeInput/README.md +24 -1
- package/components/TimeInput/StyledTimeInput.js +102 -28
- package/components/TimeInput/TimeInput.js +189 -121
- package/components/TimeInput/TimeInputPopup.js +116 -118
- package/components/TimeInput/index.d.ts +2 -0
- package/components/TimeInput/propTypes.js +2 -0
- package/components/TimeInput/stories/Controlled.stories.tsx +2 -2
- package/components/TimeInput/stories/CustomThemed.stories.tsx +79 -0
- package/components/TimeInput/stories/CustomThemedHpe.stories.tsx +115 -0
- package/components/TimeInput/stories/Form.stories.tsx +1 -0
- package/components/TimeInput/stories/Inline.stories.tsx +28 -0
- package/components/TimeInput/stories/ShowSeconds.stories.tsx +28 -0
- package/components/TimeInput/useSectionedTimeField.js +2 -2
- package/components/TimeInput/utils.js +13 -62
- package/components/Tip/Tip.js +2 -1
- package/components/Tip/stories/HeaderActions.stories.js +2 -1
- package/components/ToggleGroup/ToggleGroup.js +2 -1
- package/components/ToggleGroup/stories/Controlled.stories.js +2 -1
- package/components/Toolbar/Toolbar.js +2 -1
- package/components/Video/StyledVideo.js +2 -1
- package/components/Video/Video.js +2 -1
- package/components/Wizard/Wizard.js +409 -212
- package/components/Wizard/WizardContent.js +63 -36
- package/components/Wizard/WizardContext.js +5 -1
- package/components/Wizard/WizardFooter.js +14 -15
- package/components/Wizard/WizardHeader.js +12 -7
- package/components/Wizard/WizardProgress.js +28 -6
- package/components/Wizard/index.d.ts +35 -4
- package/components/Wizard/propTypes.js +6 -1
- package/components/Wizard/stories/BasicLinear.stories.js +14 -11
- package/components/Wizard/stories/Branching.stories.js +2 -1
- package/components/Wizard/stories/ClickableSteps.stories.js +105 -0
- package/components/Wizard/stories/Composable.stories.js +2 -1
- package/components/Wizard/stories/Controlled.stories.js +2 -1
- package/components/Wizard/stories/ExternalForm.stories.js +115 -0
- package/components/Wizard/stories/LongContent.stories.js +2 -1
- package/components/Wizard/stories/Modal.stories.js +2 -1
- package/components/Wizard/stories/NestedSubSteps.stories.js +2 -1
- package/components/Wizard/stories/NonClosableHeader.stories.js +69 -0
- package/components/Wizard/stories/ProgressiveSubSteps.stories.tsx +209 -0
- package/components/Wizard/stories/Validation.stories.js +20 -9
- package/components/WorldMap/WorldMap.js +2 -1
- package/contexts/AnalyticsContext/AnalyticsContext.js +2 -1
- package/contexts/AnnounceContext/stories/Polite.stories.js +2 -1
- package/contexts/RootsContext.js +2 -1
- package/contexts/ThemeContext/stories/ThemeContextExtend.stories.js +2 -1
- package/es6/components/Box/StyledBox.js +1 -1
- package/es6/components/Box/stories/ColorContrast.stories.js +31 -0
- package/es6/components/Button/BusyAnimation.js +7 -1
- package/es6/components/Button/Button.js +12 -3
- package/es6/components/Cards/index.d.ts +2 -16
- package/es6/components/CheckBox/README.md +95 -0
- package/es6/components/CheckBox/StyledCheckBox.js +103 -14
- package/es6/components/CheckBox/stories/CustomThemed/Appearance.stories.tsx +160 -0
- package/es6/components/DataTable/StyledDataTable.js +2 -2
- package/es6/components/DateInput/DateInput.js +13 -6
- package/es6/components/DateTimeInput/DateTimeInput.js +19 -11
- package/es6/components/DateTimeInput/StyledDateTimeInput.js +10 -2
- package/es6/components/FileInput/FileInput.js +77 -20
- package/es6/components/FileInput/README.md +5 -0
- package/es6/components/FocusedContainer.js +2 -1
- package/es6/components/FormField/FormField.js +231 -73
- package/es6/components/FormField/FormFieldContext.js +7 -0
- package/es6/components/FormField/README.md +56 -1
- package/es6/components/FormField/stories/CustomThemed/Appearance.stories.tsx +630 -0
- package/es6/components/Grommet/Grommet.js +4 -1
- package/es6/components/Grommet/StyledGrommet.js +4 -4
- package/es6/components/Grommet/index.d.ts +10 -0
- package/es6/components/Grommet/propTypes.js +6 -1
- package/es6/components/Menu/Menu.js +1 -1
- package/es6/components/RadioButton/README.md +93 -1
- package/es6/components/RadioButton/RadioButton.js +11 -4
- package/es6/components/RadioButton/StyledRadioButton.js +102 -8
- package/es6/components/RadioButton/stories/CustomThemed/Appearance.stories.tsx +190 -0
- package/es6/components/RangeSelector/index.d.ts +1 -10
- package/es6/components/Select/SelectContainer.js +2 -2
- package/es6/components/Select/StyledSelect.js +13 -4
- package/es6/components/SelectMultiple/SelectMultiple.js +9 -3
- package/es6/components/Stepper/Stepper.js +137 -101
- package/es6/components/Stepper/StepperContext.js +5 -4
- package/es6/components/Stepper/StepperDescription.js +6 -8
- package/es6/components/Stepper/StepperHelperText.js +13 -15
- package/es6/components/Stepper/StepperIndicator.js +38 -35
- package/es6/components/Stepper/StepperLabel.js +11 -23
- package/es6/components/Stepper/StepperStep.js +137 -81
- package/es6/components/Stepper/StyledStepper.js +167 -113
- package/es6/components/Stepper/index.d.ts +25 -13
- package/es6/components/Stepper/index.js +2 -1
- package/es6/components/Stepper/propTypes.js +3 -0
- package/es6/components/Stepper/stories/Children.stories.tsx +73 -0
- package/es6/components/Stepper/stories/CustomThemed.stories.tsx +301 -0
- package/es6/components/Stepper/stories/CustomThemedHpe.stories.tsx +328 -0
- package/es6/components/Stepper/utils.js +50 -0
- package/es6/components/TextArea/StyledTextArea.js +4 -2
- package/es6/components/TextInput/CopyButton.js +22 -6
- package/es6/components/TextInput/README.md +29 -1
- package/es6/components/TextInput/StyledTextInput.js +34 -27
- package/es6/components/TextInput/TextInput.js +164 -41
- package/es6/components/TextInput/index.d.ts +14 -3
- package/es6/components/TextInput/propTypes.js +4 -0
- package/es6/components/TextInput/stories/Clear.stories.tsx +68 -0
- package/es6/components/TextInput/stories/ClearFormField.stories.tsx +45 -0
- package/es6/components/TextInput/stories/Copy.stories.tsx +42 -0
- package/es6/components/TextInput/stories/CopySecret.stories.tsx +44 -0
- package/es6/components/TimeInput/README.md +24 -1
- package/es6/components/TimeInput/StyledTimeInput.js +101 -28
- package/es6/components/TimeInput/TimeInput.js +189 -122
- package/es6/components/TimeInput/TimeInputPopup.js +115 -118
- package/es6/components/TimeInput/index.d.ts +2 -0
- package/es6/components/TimeInput/propTypes.js +2 -0
- package/es6/components/TimeInput/stories/Controlled.stories.tsx +2 -2
- package/es6/components/TimeInput/stories/CustomThemed.stories.tsx +79 -0
- package/es6/components/TimeInput/stories/CustomThemedHpe.stories.tsx +115 -0
- package/es6/components/TimeInput/stories/Form.stories.tsx +1 -0
- package/es6/components/TimeInput/stories/Inline.stories.tsx +28 -0
- package/es6/components/TimeInput/stories/ShowSeconds.stories.tsx +28 -0
- package/es6/components/TimeInput/useSectionedTimeField.js +2 -2
- package/es6/components/TimeInput/utils.js +12 -61
- package/es6/components/Wizard/Wizard.js +407 -212
- package/es6/components/Wizard/WizardContent.js +62 -36
- package/es6/components/Wizard/WizardContext.js +3 -0
- package/es6/components/Wizard/WizardFooter.js +14 -15
- package/es6/components/Wizard/WizardHeader.js +12 -7
- package/es6/components/Wizard/WizardProgress.js +28 -6
- package/es6/components/Wizard/index.d.ts +35 -4
- package/es6/components/Wizard/propTypes.js +6 -1
- package/es6/components/Wizard/stories/BasicLinear.stories.js +11 -11
- package/es6/components/Wizard/stories/ClickableSteps.stories.js +99 -0
- package/es6/components/Wizard/stories/ExternalForm.stories.js +111 -0
- package/es6/components/Wizard/stories/NonClosableHeader.stories.js +63 -0
- package/es6/components/Wizard/stories/ProgressiveSubSteps.stories.tsx +209 -0
- package/es6/components/Wizard/stories/Validation.stories.js +18 -9
- package/es6/languages/default.json +7 -1
- package/es6/themes/base.d.ts +166 -153
- package/es6/themes/base.js +263 -201
- package/es6/utils/DOM.js +10 -7
- package/es6/utils/background.js +9 -7
- package/es6/utils/border.js +7 -0
- package/es6/utils/colors.js +84 -12
- package/es6/utils/legacyColorIsDark.js +17 -0
- package/es6/utils/styles.js +157 -29
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/languages/default.json +7 -1
- package/package.json +36 -36
- package/themes/base.d.ts +166 -153
- package/themes/base.js +263 -201
- package/tools/draft-release-version-pr.js +1 -0
- package/tools/generate-release-notes.js +1 -1
- package/tools/license-header.js +1 -1
- package/tools/pack.js +1 -1
- package/tools/release-checklist.js +1 -1
- package/tools/release-notes-utils.js +1 -0
- package/tools/release-preparation.md +55 -0
- package/tools/release-stable.js +1 -1
- package/tools/release-styled-components-beta-stable.js +1 -1
- package/utils/DOM.js +10 -7
- package/utils/background.js +9 -7
- package/utils/border.js +8 -1
- package/utils/colors.js +84 -12
- package/utils/legacyColorIsDark.js +21 -0
- package/utils/styles.js +158 -32
- package/utils/useId.js +2 -1
- package/components/Stepper/StepConnector.js +0 -38
- package/es6/components/Stepper/StepConnector.js +0 -33
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
var _excluded = ["
|
|
2
|
-
|
|
1
|
+
var _excluded = ["children"],
|
|
2
|
+
_excluded2 = ["steps", "clickableSteps", "closable", "currentStep", "defaultStep", "form", "showProgress", "onStepChange", "onComplete", "onCancel", "renderStep", "title", "footer", "scrollToTop", "value", "defaultValue", "onChange", "id", "aria-label", "messages", "children"];
|
|
3
3
|
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
4
4
|
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
5
5
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
6
6
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
7
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
7
8
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
8
9
|
function _createForOfIteratorHelperLoose(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
10
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
10
11
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
11
12
|
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
12
13
|
// SPDX-License-Identifier: Apache-2.0
|
|
13
|
-
import React, { forwardRef, useCallback, useEffect, useMemo, useState } from 'react';
|
|
14
|
+
import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
15
|
+
import styled from 'styled-components';
|
|
14
16
|
import { useAnalytics } from '../../contexts';
|
|
15
17
|
import { MessageContext } from '../../contexts/MessageContext';
|
|
16
18
|
import { ResponsiveContext } from '../../contexts/ResponsiveContext';
|
|
@@ -43,20 +45,80 @@ var flattenLeaves = function flattenLeaves(steps) {
|
|
|
43
45
|
};
|
|
44
46
|
|
|
45
47
|
// Find step by id in the tree or leaf list.
|
|
46
|
-
var
|
|
48
|
+
var _findStepById = function findStepById(steps, id) {
|
|
47
49
|
// eslint-disable-next-line no-restricted-syntax
|
|
48
50
|
for (var _iterator = _createForOfIteratorHelperLoose(steps), _step; !(_step = _iterator()).done;) {
|
|
49
51
|
var step = _step.value;
|
|
50
52
|
if (step.id === id) return step;
|
|
51
53
|
if (step.children) {
|
|
52
|
-
var match = step.children
|
|
53
|
-
return child.id === id;
|
|
54
|
-
});
|
|
54
|
+
var match = _findStepById(step.children, id);
|
|
55
55
|
if (match) return match;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
return undefined;
|
|
59
59
|
};
|
|
60
|
+
var formHasErrors = function formHasErrors(result) {
|
|
61
|
+
var _result$form, _result$form2;
|
|
62
|
+
return (result == null || (_result$form = result.form) == null ? void 0 : _result$form.ok) === false || Object.keys((result == null || (_result$form2 = result.form) == null ? void 0 : _result$form2.errors) || {}).length > 0;
|
|
63
|
+
};
|
|
64
|
+
var StyledWizardProgress = styled.div.withConfig({
|
|
65
|
+
displayName: "Wizard__StyledWizardProgress",
|
|
66
|
+
componentId: "sc-uqfco5-0"
|
|
67
|
+
})(["display:", ";"], function (props) {
|
|
68
|
+
return props.$hidden ? 'none' : 'contents';
|
|
69
|
+
});
|
|
70
|
+
var statusFromStep = function statusFromStep(step, validation, completed) {
|
|
71
|
+
var _validation$step$id;
|
|
72
|
+
if (!step) return 'pending';
|
|
73
|
+
if (step.disabled) return 'disabled';
|
|
74
|
+
if (step.status) return step.status;
|
|
75
|
+
if (formHasErrors(validation[step.id]) || ((_validation$step$id = validation[step.id]) == null || (_validation$step$id = _validation$step$id.callback) == null ? void 0 : _validation$step$id.ok) === false) return 'error';
|
|
76
|
+
if (completed.has(step.id)) return 'completed';
|
|
77
|
+
return 'pending';
|
|
78
|
+
};
|
|
79
|
+
var getStepStatus = function getStepStatus(step, validation, completed) {
|
|
80
|
+
var _step$children;
|
|
81
|
+
if (step != null && step.disabled || step != null && step.status || !(step != null && (_step$children = step.children) != null && _step$children.length)) return statusFromStep(step, validation, completed);
|
|
82
|
+
var childStatuses = step.children.map(function (child) {
|
|
83
|
+
return statusFromStep(child, validation, completed);
|
|
84
|
+
});
|
|
85
|
+
if (childStatuses.some(function (status) {
|
|
86
|
+
return status === 'error';
|
|
87
|
+
})) return 'error';
|
|
88
|
+
if (childStatuses.every(function (status) {
|
|
89
|
+
return status === 'completed';
|
|
90
|
+
})) return 'completed';
|
|
91
|
+
if (childStatuses.every(function (status) {
|
|
92
|
+
return status === 'disabled';
|
|
93
|
+
})) return 'disabled';
|
|
94
|
+
return 'pending';
|
|
95
|
+
};
|
|
96
|
+
var filterCompletedSteps = function filterCompletedSteps(steps, validation, completed) {
|
|
97
|
+
var remaining = Array.from(completed).filter(function (stepId) {
|
|
98
|
+
var step = _findStepById(steps, stepId);
|
|
99
|
+
return step && getStepStatus(step, validation, completed) !== 'error';
|
|
100
|
+
});
|
|
101
|
+
return remaining.length === completed.size ? completed : new Set(remaining);
|
|
102
|
+
};
|
|
103
|
+
var resolveStepResults = function resolveStepResults(steps, validation, completed) {
|
|
104
|
+
var results = [];
|
|
105
|
+
var _walk = function walk(nodes) {
|
|
106
|
+
return nodes.forEach(function (step) {
|
|
107
|
+
var _step$errorMessage, _validation$step$id2;
|
|
108
|
+
var childSteps = step.children,
|
|
109
|
+
details = _objectWithoutPropertiesLoose(step, _excluded);
|
|
110
|
+
var status = getStepStatus(step, validation, completed);
|
|
111
|
+
var errorMessage = status === 'error' ? (_step$errorMessage = step.errorMessage) != null ? _step$errorMessage : formHasErrors(validation[step.id]) ? undefined : (_validation$step$id2 = validation[step.id]) == null || (_validation$step$id2 = _validation$step$id2.callback) == null ? void 0 : _validation$step$id2.error : undefined;
|
|
112
|
+
results.push(_extends({}, details, {
|
|
113
|
+
status: status,
|
|
114
|
+
errorMessage: errorMessage
|
|
115
|
+
}));
|
|
116
|
+
if (childSteps != null && childSteps.length) _walk(childSteps);
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
_walk(steps);
|
|
120
|
+
return results;
|
|
121
|
+
};
|
|
60
122
|
|
|
61
123
|
// Nearest scrollable ancestor for scrollToTop.
|
|
62
124
|
var findScrollableAncestor = function findScrollableAncestor(node) {
|
|
@@ -72,9 +134,16 @@ var findScrollableAncestor = function findScrollableAncestor(node) {
|
|
|
72
134
|
return undefined;
|
|
73
135
|
};
|
|
74
136
|
var Wizard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
137
|
+
var _currentValidation$ca, _currentValidation$fo, _currentValidation$ca2;
|
|
75
138
|
var steps = _ref.steps,
|
|
139
|
+
_ref$clickableSteps = _ref.clickableSteps,
|
|
140
|
+
clickableSteps = _ref$clickableSteps === void 0 ? false : _ref$clickableSteps,
|
|
141
|
+
_ref$closable = _ref.closable,
|
|
142
|
+
closable = _ref$closable === void 0 ? true : _ref$closable,
|
|
76
143
|
currentStepProp = _ref.currentStep,
|
|
77
144
|
defaultStep = _ref.defaultStep,
|
|
145
|
+
_ref$form = _ref.form,
|
|
146
|
+
form = _ref$form === void 0 ? true : _ref$form,
|
|
78
147
|
_ref$showProgress = _ref.showProgress,
|
|
79
148
|
showProgress = _ref$showProgress === void 0 ? false : _ref$showProgress,
|
|
80
149
|
onStepChange = _ref.onStepChange,
|
|
@@ -92,7 +161,7 @@ var Wizard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
92
161
|
ariaLabel = _ref['aria-label'],
|
|
93
162
|
messages = _ref.messages,
|
|
94
163
|
children = _ref.children,
|
|
95
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
164
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded2);
|
|
96
165
|
var _useThemeValue = useThemeValue(),
|
|
97
166
|
theme = _useThemeValue.theme;
|
|
98
167
|
var _React$useContext = React.useContext(MessageContext),
|
|
@@ -108,8 +177,8 @@ var Wizard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
108
177
|
|
|
109
178
|
// Only two levels supported (step > child); warn on deeper nesting.
|
|
110
179
|
var hasDeepNesting = steps.some(function (step) {
|
|
111
|
-
var _step$
|
|
112
|
-
return (_step$
|
|
180
|
+
var _step$children2;
|
|
181
|
+
return (_step$children2 = step.children) == null ? void 0 : _step$children2.some(function (child) {
|
|
113
182
|
return child.children && child.children.length > 0;
|
|
114
183
|
});
|
|
115
184
|
});
|
|
@@ -138,6 +207,33 @@ var Wizard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
138
207
|
uncontrolledStep = _useState[0],
|
|
139
208
|
setUncontrolledStep = _useState[1];
|
|
140
209
|
var currentStep = isControlled ? currentStepProp : uncontrolledStep;
|
|
210
|
+
var latest = useRef({
|
|
211
|
+
currentStep: currentStep,
|
|
212
|
+
steps: steps
|
|
213
|
+
});
|
|
214
|
+
latest.current = {
|
|
215
|
+
currentStep: currentStep,
|
|
216
|
+
steps: steps
|
|
217
|
+
};
|
|
218
|
+
var mounted = useRef(false);
|
|
219
|
+
var navigationVersion = useRef(0);
|
|
220
|
+
var validationInFlight = useRef();
|
|
221
|
+
var formValidators = useRef(new Map());
|
|
222
|
+
useLayoutEffect(function () {
|
|
223
|
+
mounted.current = true;
|
|
224
|
+
return function () {
|
|
225
|
+
mounted.current = false;
|
|
226
|
+
};
|
|
227
|
+
}, []);
|
|
228
|
+
useLayoutEffect(function () {
|
|
229
|
+
navigationVersion.current += 1;
|
|
230
|
+
}, [currentStep]);
|
|
231
|
+
var registerForm = useCallback(function (stepId, validateForm) {
|
|
232
|
+
formValidators.current.set(stepId, validateForm);
|
|
233
|
+
return function () {
|
|
234
|
+
if (formValidators.current.get(stepId) === validateForm) formValidators.current["delete"](stepId);
|
|
235
|
+
};
|
|
236
|
+
}, []);
|
|
141
237
|
var isValueControlled = valueProp !== undefined;
|
|
142
238
|
var _useState2 = useState(defaultValue || {}),
|
|
143
239
|
uncontrolledValue = _useState2[0],
|
|
@@ -150,34 +246,56 @@ var Wizard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
150
246
|
value: resolved
|
|
151
247
|
});
|
|
152
248
|
}, [formValue, isValueControlled, onChange]);
|
|
153
|
-
var _useState3 = useState(
|
|
154
|
-
visitedSteps = _useState3[0],
|
|
155
|
-
setVisitedSteps = _useState3[1];
|
|
156
|
-
var _useState4 = useState(function () {
|
|
249
|
+
var _useState3 = useState(function () {
|
|
157
250
|
return new Set();
|
|
158
251
|
}),
|
|
159
|
-
completedSteps =
|
|
160
|
-
setCompletedSteps =
|
|
161
|
-
var
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
252
|
+
completedSteps = _useState3[0],
|
|
253
|
+
setCompletedSteps = _useState3[1];
|
|
254
|
+
var stepValidationRef = useRef({});
|
|
255
|
+
var _useState4 = useState(stepValidationRef.current),
|
|
256
|
+
stepValidation = _useState4[0],
|
|
257
|
+
setStepValidation = _useState4[1];
|
|
258
|
+
var updateValidation = useCallback(function (stepId, source, result) {
|
|
259
|
+
var _extends2, _extends3;
|
|
260
|
+
if (!mounted.current || !_findStepById(latest.current.steps, stepId)) return;
|
|
261
|
+
var nextResults = _extends({}, stepValidationRef.current, (_extends3 = {}, _extends3[stepId] = _extends({}, stepValidationRef.current[stepId], (_extends2 = {}, _extends2[source] = result, _extends2)), _extends3));
|
|
262
|
+
stepValidationRef.current = nextResults;
|
|
263
|
+
setStepValidation(nextResults);
|
|
264
|
+
if (result.ok === false) {
|
|
265
|
+
setCompletedSteps(function (previousCompleted) {
|
|
266
|
+
if (!previousCompleted.has(stepId)) return previousCompleted;
|
|
267
|
+
var nextCompleted = new Set(previousCompleted);
|
|
268
|
+
nextCompleted["delete"](stepId);
|
|
269
|
+
return nextCompleted;
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
}, []);
|
|
273
|
+
var currentValidation = stepValidation[currentStep];
|
|
274
|
+
var validationError = !formHasErrors(currentValidation) && (currentValidation == null || (_currentValidation$ca = currentValidation.callback) == null ? void 0 : _currentValidation$ca.ok) === false ? currentValidation.callback.error : undefined;
|
|
275
|
+
var _useState5 = useState(false),
|
|
276
|
+
isValidating = _useState5[0],
|
|
277
|
+
setIsValidating = _useState5[1];
|
|
167
278
|
// Without `onCancel`, cancel self-closes the wizard.
|
|
168
|
-
var
|
|
169
|
-
isOpen =
|
|
170
|
-
setIsOpen =
|
|
279
|
+
var _useState6 = useState(true),
|
|
280
|
+
isOpen = _useState6[0],
|
|
281
|
+
setIsOpen = _useState6[1];
|
|
171
282
|
var hasCancelHandler = onCancel !== undefined;
|
|
172
|
-
|
|
173
|
-
// Keep visited history in sync when currentStep is externally set.
|
|
174
283
|
useEffect(function () {
|
|
175
|
-
|
|
176
|
-
|
|
284
|
+
if (validationInFlight.current && !_findStepById(steps, validationInFlight.current.stepId)) validationInFlight.current.removed = true;
|
|
285
|
+
var entries = Object.entries(stepValidationRef.current).filter(function (_ref2) {
|
|
286
|
+
var stepId = _ref2[0];
|
|
287
|
+
return _findStepById(steps, stepId);
|
|
177
288
|
});
|
|
178
|
-
|
|
289
|
+
if (entries.length !== Object.keys(stepValidationRef.current).length) {
|
|
290
|
+
stepValidationRef.current = Object.fromEntries(entries);
|
|
291
|
+
setStepValidation(stepValidationRef.current);
|
|
292
|
+
}
|
|
293
|
+
setCompletedSteps(function (previousCompleted) {
|
|
294
|
+
return filterCompletedSteps(steps, stepValidationRef.current, previousCompleted);
|
|
295
|
+
});
|
|
296
|
+
}, [steps]);
|
|
179
297
|
var currentStepObj = useMemo(function () {
|
|
180
|
-
return
|
|
298
|
+
return _findStepById(steps, currentStep);
|
|
181
299
|
}, [steps, currentStep]);
|
|
182
300
|
var currentStepIndex = useMemo(function () {
|
|
183
301
|
return flatSteps.findIndex(function (step) {
|
|
@@ -185,51 +303,21 @@ var Wizard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
185
303
|
});
|
|
186
304
|
}, [flatSteps, currentStep]);
|
|
187
305
|
var totalSteps = flatSteps.length;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
// Parent-with-children aggregate
|
|
192
|
-
var parent = steps.find(function (step) {
|
|
193
|
-
return step.id === stepId && step.children && step.children.length;
|
|
194
|
-
});
|
|
195
|
-
if (parent) {
|
|
196
|
-
var childStatuses = parent.children.map(function (child) {
|
|
197
|
-
if (child.disabled) return 'disabled';
|
|
198
|
-
if (child.id === currentStep && validationError) return 'error';
|
|
199
|
-
if (completedSteps.has(child.id)) return 'completed';
|
|
200
|
-
return 'pending';
|
|
201
|
-
});
|
|
202
|
-
if (childStatuses.some(function (status) {
|
|
203
|
-
return status === 'error';
|
|
204
|
-
})) return 'error';
|
|
205
|
-
if (childStatuses.every(function (status) {
|
|
206
|
-
return status === 'completed';
|
|
207
|
-
})) return 'completed';
|
|
208
|
-
if (childStatuses.every(function (status) {
|
|
209
|
-
return status === 'disabled';
|
|
210
|
-
})) return 'disabled';
|
|
211
|
-
return 'pending';
|
|
212
|
-
}
|
|
213
|
-
var step = findStepById(steps, stepId);
|
|
214
|
-
if (!step) return 'pending';
|
|
215
|
-
if (step.disabled) return 'disabled';
|
|
216
|
-
if (stepId === currentStep && validationError) return 'error';
|
|
217
|
-
if (completedSteps.has(stepId)) return 'completed';
|
|
218
|
-
return 'pending';
|
|
219
|
-
}, [steps, currentStep, completedSteps, validationError]);
|
|
306
|
+
var stepResults = useMemo(function () {
|
|
307
|
+
return resolveStepResults(steps, stepValidation, completedSteps);
|
|
308
|
+
}, [steps, stepValidation, completedSteps]);
|
|
220
309
|
|
|
221
310
|
// Record<id, status> for every step (top-level + children).
|
|
222
311
|
var stepStates = useMemo(function () {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}, [steps, getStepStatus]);
|
|
312
|
+
return Object.fromEntries(stepResults.map(function (step) {
|
|
313
|
+
return [step.id, step.status];
|
|
314
|
+
}));
|
|
315
|
+
}, [stepResults]);
|
|
316
|
+
var stepErrorMessages = useMemo(function () {
|
|
317
|
+
return Object.fromEntries(stepResults.map(function (step) {
|
|
318
|
+
return [step.id, step.errorMessage];
|
|
319
|
+
}));
|
|
320
|
+
}, [stepResults]);
|
|
233
321
|
|
|
234
322
|
// Emit a step change event to onStepChange.
|
|
235
323
|
var emitStepChange = useCallback(function (event) {
|
|
@@ -238,85 +326,86 @@ var Wizard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
238
326
|
|
|
239
327
|
// Resolve next step id, honoring step.nextStep(formValue) branching.
|
|
240
328
|
var resolveNextStepId = useCallback(function () {
|
|
241
|
-
var _flatSteps$nextIndex;
|
|
242
329
|
if (!currentStepObj) return undefined;
|
|
243
330
|
if (typeof currentStepObj.nextStep === 'function') {
|
|
244
331
|
var nextId = currentStepObj.nextStep(formValue);
|
|
245
332
|
if (!nextId) return undefined;
|
|
246
|
-
var match =
|
|
333
|
+
var match = _findStepById(steps, nextId);
|
|
247
334
|
if (!match) {
|
|
248
335
|
if (process.env.NODE_ENV !== 'production') {
|
|
249
336
|
console.warn("Wizard: nextStep(\"" + nextId + "\") does not match any step id. " + 'Staying on current step.');
|
|
250
337
|
}
|
|
251
338
|
return undefined;
|
|
252
339
|
}
|
|
253
|
-
return nextId;
|
|
340
|
+
return !match.disabled ? nextId : undefined;
|
|
254
341
|
}
|
|
255
342
|
var nextIndex = currentStepIndex + 1;
|
|
256
|
-
|
|
257
|
-
|
|
343
|
+
while (nextIndex < flatSteps.length) {
|
|
344
|
+
var nextStep = flatSteps[nextIndex];
|
|
345
|
+
if (!(nextStep != null && nextStep.disabled)) return nextStep.id;
|
|
346
|
+
if (nextStep != null && nextStep.disabled && (clickableSteps || nextStep != null && nextStep.skippable)) {
|
|
347
|
+
nextIndex += 1;
|
|
348
|
+
} else {
|
|
349
|
+
return undefined;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return undefined;
|
|
353
|
+
}, [clickableSteps, currentStepObj, currentStepIndex, flatSteps, formValue, steps]);
|
|
354
|
+
var resolvePreviousStepId = useCallback(function () {
|
|
355
|
+
var prevIndex = currentStepIndex - 1;
|
|
356
|
+
while (prevIndex >= 0) {
|
|
357
|
+
var prevStep = flatSteps[prevIndex];
|
|
358
|
+
if (!(prevStep != null && prevStep.disabled)) return prevStep.id;
|
|
359
|
+
prevIndex -= 1;
|
|
360
|
+
}
|
|
361
|
+
return undefined;
|
|
362
|
+
}, [currentStepIndex, flatSteps]);
|
|
258
363
|
|
|
259
364
|
// Apply a navigation transition (id, history, completion, focus).
|
|
260
365
|
var applyTransition = useCallback(function (nextId, _temp) {
|
|
261
|
-
var
|
|
262
|
-
markCompleted =
|
|
366
|
+
var _ref3 = _temp === void 0 ? {} : _temp,
|
|
367
|
+
markCompleted = _ref3.markCompleted;
|
|
263
368
|
if (!nextId) return;
|
|
369
|
+
navigationVersion.current += 1;
|
|
264
370
|
if (markCompleted && currentStep) {
|
|
265
371
|
setCompletedSteps(function (prev) {
|
|
266
372
|
var next = new Set(prev);
|
|
267
373
|
next.add(currentStep);
|
|
268
|
-
return next;
|
|
374
|
+
return filterCompletedSteps(latest.current.steps, stepValidationRef.current, next);
|
|
269
375
|
});
|
|
270
376
|
}
|
|
271
|
-
setValidationError(undefined);
|
|
272
|
-
setVisitedSteps(function (prev) {
|
|
273
|
-
return [].concat(prev, [nextId]);
|
|
274
|
-
});
|
|
275
377
|
if (!isControlled) setUncontrolledStep(nextId);
|
|
276
378
|
}, [currentStep, isControlled]);
|
|
277
379
|
|
|
278
380
|
// Run step.validate (sync or async). Returns { ok, error }.
|
|
279
|
-
var
|
|
280
|
-
var
|
|
381
|
+
var runStepValidation = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
382
|
+
var result, _t;
|
|
281
383
|
return _regenerator().w(function (_context) {
|
|
282
384
|
while (1) switch (_context.p = _context.n) {
|
|
283
385
|
case 0:
|
|
284
|
-
formElement = document.getElementById(currentStep + "-form");
|
|
285
|
-
formIsValid = (formElement == null ? void 0 : formElement.getAttribute('data-form-valid')) !== 'false';
|
|
286
|
-
if (formIsValid) {
|
|
287
|
-
_context.n = 1;
|
|
288
|
-
break;
|
|
289
|
-
}
|
|
290
|
-
return _context.a(2, {
|
|
291
|
-
ok: false,
|
|
292
|
-
error: undefined
|
|
293
|
-
});
|
|
294
|
-
case 1:
|
|
295
386
|
if (!(typeof (currentStepObj == null ? void 0 : currentStepObj.validate) !== 'function')) {
|
|
296
|
-
_context.n =
|
|
387
|
+
_context.n = 1;
|
|
297
388
|
break;
|
|
298
389
|
}
|
|
299
390
|
return _context.a(2, {
|
|
300
391
|
ok: true
|
|
301
392
|
});
|
|
302
|
-
case
|
|
303
|
-
|
|
304
|
-
_context.
|
|
305
|
-
_context.n = 4;
|
|
393
|
+
case 1:
|
|
394
|
+
_context.p = 1;
|
|
395
|
+
_context.n = 2;
|
|
306
396
|
return currentStepObj.validate(formValue);
|
|
307
|
-
case
|
|
397
|
+
case 2:
|
|
308
398
|
result = _context.v;
|
|
309
|
-
setIsValidating(false);
|
|
310
399
|
if (!(result === true || result === undefined)) {
|
|
311
|
-
_context.n =
|
|
400
|
+
_context.n = 3;
|
|
312
401
|
break;
|
|
313
402
|
}
|
|
314
403
|
return _context.a(2, {
|
|
315
404
|
ok: true
|
|
316
405
|
});
|
|
317
|
-
case
|
|
406
|
+
case 3:
|
|
318
407
|
if (!(result === false)) {
|
|
319
|
-
_context.n =
|
|
408
|
+
_context.n = 4;
|
|
320
409
|
break;
|
|
321
410
|
}
|
|
322
411
|
return _context.a(2, {
|
|
@@ -326,32 +415,31 @@ var Wizard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
326
415
|
messages: messages
|
|
327
416
|
})
|
|
328
417
|
});
|
|
329
|
-
case
|
|
418
|
+
case 4:
|
|
330
419
|
if (!(typeof result === 'string')) {
|
|
331
|
-
_context.n =
|
|
420
|
+
_context.n = 5;
|
|
332
421
|
break;
|
|
333
422
|
}
|
|
334
423
|
return _context.a(2, {
|
|
335
424
|
ok: false,
|
|
336
425
|
error: result
|
|
337
426
|
});
|
|
338
|
-
case
|
|
339
|
-
if (!(typeof result === 'object' && result.error)) {
|
|
340
|
-
_context.n =
|
|
427
|
+
case 5:
|
|
428
|
+
if (!(result && typeof result === 'object' && result.error)) {
|
|
429
|
+
_context.n = 6;
|
|
341
430
|
break;
|
|
342
431
|
}
|
|
343
432
|
return _context.a(2, {
|
|
344
433
|
ok: false,
|
|
345
434
|
error: result.error
|
|
346
435
|
});
|
|
347
|
-
case
|
|
436
|
+
case 6:
|
|
348
437
|
return _context.a(2, {
|
|
349
438
|
ok: true
|
|
350
439
|
});
|
|
351
|
-
case
|
|
352
|
-
_context.p =
|
|
440
|
+
case 7:
|
|
441
|
+
_context.p = 7;
|
|
353
442
|
_t = _context.v;
|
|
354
|
-
setIsValidating(false);
|
|
355
443
|
return _context.a(2, {
|
|
356
444
|
ok: false,
|
|
357
445
|
error: (_t == null ? void 0 : _t.message) || format({
|
|
@@ -360,18 +448,93 @@ var Wizard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
360
448
|
})
|
|
361
449
|
});
|
|
362
450
|
}
|
|
363
|
-
}, _callee, null, [[
|
|
364
|
-
})), [
|
|
365
|
-
var
|
|
366
|
-
var
|
|
451
|
+
}, _callee, null, [[1, 7]]);
|
|
452
|
+
})), [currentStepObj, formValue, format, messages]);
|
|
453
|
+
var runValidation = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
454
|
+
var attempt, isStale, validateForm, _result, result;
|
|
367
455
|
return _regenerator().w(function (_context2) {
|
|
368
|
-
while (1) switch (_context2.n) {
|
|
456
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
369
457
|
case 0:
|
|
370
|
-
if (!
|
|
458
|
+
if (!validationInFlight.current) {
|
|
371
459
|
_context2.n = 1;
|
|
372
460
|
break;
|
|
373
461
|
}
|
|
462
|
+
return _context2.a(2, {
|
|
463
|
+
cancelled: true
|
|
464
|
+
});
|
|
465
|
+
case 1:
|
|
466
|
+
attempt = {
|
|
467
|
+
stepId: currentStep,
|
|
468
|
+
version: navigationVersion.current
|
|
469
|
+
};
|
|
470
|
+
validationInFlight.current = attempt;
|
|
471
|
+
setIsValidating(true);
|
|
472
|
+
isStale = function isStale() {
|
|
473
|
+
return !mounted.current || attempt.removed || latest.current.currentStep !== attempt.stepId || navigationVersion.current !== attempt.version || !_findStepById(latest.current.steps, attempt.stepId);
|
|
474
|
+
};
|
|
475
|
+
_context2.p = 2;
|
|
476
|
+
validateForm = form && formValidators.current.get(currentStep);
|
|
477
|
+
if (!validateForm) {
|
|
478
|
+
_context2.n = 6;
|
|
479
|
+
break;
|
|
480
|
+
}
|
|
481
|
+
_context2.n = 3;
|
|
482
|
+
return validateForm();
|
|
483
|
+
case 3:
|
|
484
|
+
_result = _context2.v;
|
|
485
|
+
if (!_result.cancelled) {
|
|
486
|
+
_context2.n = 4;
|
|
487
|
+
break;
|
|
488
|
+
}
|
|
489
|
+
return _context2.a(2, {
|
|
490
|
+
cancelled: true
|
|
491
|
+
});
|
|
492
|
+
case 4:
|
|
493
|
+
if (_result.ok) {
|
|
494
|
+
_context2.n = 5;
|
|
495
|
+
break;
|
|
496
|
+
}
|
|
497
|
+
return _context2.a(2, {
|
|
498
|
+
ok: false,
|
|
499
|
+
cancelled: isStale()
|
|
500
|
+
});
|
|
501
|
+
case 5:
|
|
502
|
+
if (!isStale()) {
|
|
503
|
+
_context2.n = 6;
|
|
504
|
+
break;
|
|
505
|
+
}
|
|
506
|
+
return _context2.a(2, {
|
|
507
|
+
cancelled: true
|
|
508
|
+
});
|
|
509
|
+
case 6:
|
|
510
|
+
_context2.n = 7;
|
|
511
|
+
return runStepValidation();
|
|
512
|
+
case 7:
|
|
513
|
+
result = _context2.v;
|
|
514
|
+
if (!attempt.removed) updateValidation(attempt.stepId, 'callback', result);
|
|
515
|
+
return _context2.a(2, _extends({}, result, {
|
|
516
|
+
cancelled: isStale()
|
|
517
|
+
}));
|
|
518
|
+
case 8:
|
|
519
|
+
_context2.p = 8;
|
|
520
|
+
validationInFlight.current = undefined;
|
|
521
|
+
if (mounted.current) setIsValidating(false);
|
|
522
|
+
return _context2.f(8);
|
|
523
|
+
case 9:
|
|
374
524
|
return _context2.a(2);
|
|
525
|
+
}
|
|
526
|
+
}, _callee2, null, [[2,, 8, 9]]);
|
|
527
|
+
})), [currentStep, form, runStepValidation, updateValidation]);
|
|
528
|
+
var next = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
529
|
+
var _yield$runValidation, ok, error, cancelled, sourceStep, nextId;
|
|
530
|
+
return _regenerator().w(function (_context3) {
|
|
531
|
+
while (1) switch (_context3.n) {
|
|
532
|
+
case 0:
|
|
533
|
+
if (!(validationInFlight.current || currentStepObj != null && currentStepObj.disabled)) {
|
|
534
|
+
_context3.n = 1;
|
|
535
|
+
break;
|
|
536
|
+
}
|
|
537
|
+
return _context3.a(2);
|
|
375
538
|
case 1:
|
|
376
539
|
emitStepChange({
|
|
377
540
|
trigger: 'next',
|
|
@@ -383,25 +546,32 @@ var Wizard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
383
546
|
phase: 'validating',
|
|
384
547
|
from: currentStep
|
|
385
548
|
});
|
|
386
|
-
|
|
549
|
+
_context3.n = 2;
|
|
387
550
|
return runValidation();
|
|
388
551
|
case 2:
|
|
389
|
-
_yield$runValidation =
|
|
552
|
+
_yield$runValidation = _context3.v;
|
|
390
553
|
ok = _yield$runValidation.ok;
|
|
391
554
|
error = _yield$runValidation.error;
|
|
392
|
-
|
|
393
|
-
|
|
555
|
+
cancelled = _yield$runValidation.cancelled;
|
|
556
|
+
if (!cancelled) {
|
|
557
|
+
_context3.n = 3;
|
|
558
|
+
break;
|
|
559
|
+
}
|
|
560
|
+
return _context3.a(2);
|
|
561
|
+
case 3:
|
|
562
|
+
sourceStep = _findStepById(latest.current.steps, currentStep);
|
|
563
|
+
if (!(!ok || (sourceStep == null ? void 0 : sourceStep.status) === 'error')) {
|
|
564
|
+
_context3.n = 4;
|
|
394
565
|
break;
|
|
395
566
|
}
|
|
396
|
-
setValidationError(error);
|
|
397
567
|
emitStepChange({
|
|
398
568
|
trigger: 'next',
|
|
399
569
|
phase: 'blocked',
|
|
400
570
|
from: currentStep,
|
|
401
|
-
error: error
|
|
571
|
+
error: error != null ? error : sourceStep == null ? void 0 : sourceStep.errorMessage
|
|
402
572
|
});
|
|
403
|
-
return
|
|
404
|
-
case
|
|
573
|
+
return _context3.a(2);
|
|
574
|
+
case 4:
|
|
405
575
|
emitStepChange({
|
|
406
576
|
trigger: 'next',
|
|
407
577
|
phase: 'validated',
|
|
@@ -409,11 +579,11 @@ var Wizard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
409
579
|
});
|
|
410
580
|
nextId = resolveNextStepId();
|
|
411
581
|
if (nextId) {
|
|
412
|
-
|
|
582
|
+
_context3.n = 5;
|
|
413
583
|
break;
|
|
414
584
|
}
|
|
415
|
-
return
|
|
416
|
-
case
|
|
585
|
+
return _context3.a(2);
|
|
586
|
+
case 5:
|
|
417
587
|
applyTransition(nextId, {
|
|
418
588
|
markCompleted: true
|
|
419
589
|
});
|
|
@@ -427,22 +597,15 @@ var Wizard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
427
597
|
type: 'wizardNext',
|
|
428
598
|
element: 'Wizard'
|
|
429
599
|
});
|
|
430
|
-
case
|
|
431
|
-
return
|
|
600
|
+
case 6:
|
|
601
|
+
return _context3.a(2);
|
|
432
602
|
}
|
|
433
|
-
},
|
|
434
|
-
})), [sendAnalytics, applyTransition, currentStep,
|
|
603
|
+
}, _callee3);
|
|
604
|
+
})), [sendAnalytics, applyTransition, currentStep, currentStepObj, emitStepChange, resolveNextStepId, runValidation]);
|
|
435
605
|
var previous = useCallback(function () {
|
|
436
|
-
var
|
|
437
|
-
// History-aware; falls back to the linear predecessor.
|
|
438
|
-
var historyDest = visitedSteps.length > 1 ? visitedSteps[visitedSteps.length - 2] : undefined;
|
|
439
|
-
var fallbackDest = (_flatSteps = flatSteps[currentStepIndex - 1]) == null ? void 0 : _flatSteps.id;
|
|
440
|
-
var dest = historyDest || fallbackDest;
|
|
606
|
+
var dest = resolvePreviousStepId();
|
|
441
607
|
if (!dest) return;
|
|
442
|
-
|
|
443
|
-
return prev.slice(0, -1);
|
|
444
|
-
});
|
|
445
|
-
setValidationError(undefined);
|
|
608
|
+
navigationVersion.current += 1;
|
|
446
609
|
if (!isControlled) setUncontrolledStep(dest);
|
|
447
610
|
emitStepChange({
|
|
448
611
|
trigger: 'previous',
|
|
@@ -454,30 +617,43 @@ var Wizard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
454
617
|
type: 'wizardPrevious',
|
|
455
618
|
element: 'Wizard'
|
|
456
619
|
});
|
|
457
|
-
}, [sendAnalytics, currentStep,
|
|
620
|
+
}, [sendAnalytics, currentStep, resolvePreviousStepId, emitStepChange, isControlled]);
|
|
458
621
|
var goTo = useCallback(/*#__PURE__*/function () {
|
|
459
|
-
var
|
|
460
|
-
var target, targetIndex, forward, _yield$runValidation2, ok, error;
|
|
461
|
-
return _regenerator().w(function (
|
|
462
|
-
while (1) switch (
|
|
622
|
+
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(stepId) {
|
|
623
|
+
var target, targetIndex, forward, markCompleted, navigationError, _yield$runValidation2, ok, error, cancelled;
|
|
624
|
+
return _regenerator().w(function (_context4) {
|
|
625
|
+
while (1) switch (_context4.n) {
|
|
463
626
|
case 0:
|
|
464
627
|
if (!(!stepId || stepId === currentStep)) {
|
|
465
|
-
|
|
628
|
+
_context4.n = 1;
|
|
466
629
|
break;
|
|
467
630
|
}
|
|
468
|
-
return
|
|
631
|
+
return _context4.a(2);
|
|
469
632
|
case 1:
|
|
470
|
-
target =
|
|
633
|
+
target = _findStepById(steps, stepId);
|
|
471
634
|
if (!(!target || target.disabled)) {
|
|
472
|
-
|
|
635
|
+
_context4.n = 2;
|
|
473
636
|
break;
|
|
474
637
|
}
|
|
475
|
-
return
|
|
638
|
+
return _context4.a(2);
|
|
476
639
|
case 2:
|
|
477
640
|
targetIndex = flatSteps.findIndex(function (step) {
|
|
478
641
|
return step.id === stepId;
|
|
479
642
|
});
|
|
643
|
+
if (!(targetIndex < 0)) {
|
|
644
|
+
_context4.n = 3;
|
|
645
|
+
break;
|
|
646
|
+
}
|
|
647
|
+
return _context4.a(2);
|
|
648
|
+
case 3:
|
|
480
649
|
forward = targetIndex > currentStepIndex;
|
|
650
|
+
markCompleted = false;
|
|
651
|
+
if (!(forward && validationInFlight.current)) {
|
|
652
|
+
_context4.n = 4;
|
|
653
|
+
break;
|
|
654
|
+
}
|
|
655
|
+
return _context4.a(2);
|
|
656
|
+
case 4:
|
|
481
657
|
emitStepChange({
|
|
482
658
|
trigger: 'goTo',
|
|
483
659
|
phase: 'requested',
|
|
@@ -485,7 +661,7 @@ var Wizard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
485
661
|
to: stepId
|
|
486
662
|
});
|
|
487
663
|
if (!forward) {
|
|
488
|
-
|
|
664
|
+
_context4.n = 8;
|
|
489
665
|
break;
|
|
490
666
|
}
|
|
491
667
|
emitStepChange({
|
|
@@ -494,17 +670,23 @@ var Wizard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
494
670
|
from: currentStep,
|
|
495
671
|
to: stepId
|
|
496
672
|
});
|
|
497
|
-
|
|
673
|
+
_context4.n = 5;
|
|
498
674
|
return runValidation();
|
|
499
|
-
case
|
|
500
|
-
_yield$runValidation2 =
|
|
675
|
+
case 5:
|
|
676
|
+
_yield$runValidation2 = _context4.v;
|
|
501
677
|
ok = _yield$runValidation2.ok;
|
|
502
678
|
error = _yield$runValidation2.error;
|
|
503
|
-
|
|
504
|
-
|
|
679
|
+
cancelled = _yield$runValidation2.cancelled;
|
|
680
|
+
if (!cancelled) {
|
|
681
|
+
_context4.n = 6;
|
|
682
|
+
break;
|
|
683
|
+
}
|
|
684
|
+
return _context4.a(2);
|
|
685
|
+
case 6:
|
|
686
|
+
if (!(!ok && !(currentStepObj != null && currentStepObj.skippable))) {
|
|
687
|
+
_context4.n = 7;
|
|
505
688
|
break;
|
|
506
689
|
}
|
|
507
|
-
setValidationError(error);
|
|
508
690
|
emitStepChange({
|
|
509
691
|
trigger: 'goTo',
|
|
510
692
|
phase: 'blocked',
|
|
@@ -512,42 +694,43 @@ var Wizard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
512
694
|
to: stepId,
|
|
513
695
|
error: error
|
|
514
696
|
});
|
|
515
|
-
return
|
|
516
|
-
case
|
|
517
|
-
|
|
697
|
+
return _context4.a(2);
|
|
698
|
+
case 7:
|
|
699
|
+
markCompleted = ok;
|
|
700
|
+
navigationError = error;
|
|
701
|
+
if (ok) emitStepChange({
|
|
518
702
|
trigger: 'goTo',
|
|
519
703
|
phase: 'validated',
|
|
520
704
|
from: currentStep,
|
|
521
705
|
to: stepId
|
|
522
706
|
});
|
|
523
|
-
case
|
|
707
|
+
case 8:
|
|
524
708
|
applyTransition(stepId, {
|
|
525
|
-
markCompleted:
|
|
709
|
+
markCompleted: markCompleted
|
|
526
710
|
});
|
|
527
|
-
emitStepChange({
|
|
711
|
+
emitStepChange(_extends({
|
|
528
712
|
trigger: 'goTo',
|
|
529
713
|
phase: 'navigated',
|
|
530
714
|
from: currentStep,
|
|
531
715
|
to: stepId
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
|
|
716
|
+
}, navigationError ? {
|
|
717
|
+
error: navigationError
|
|
718
|
+
} : {}));
|
|
719
|
+
case 9:
|
|
720
|
+
return _context4.a(2);
|
|
535
721
|
}
|
|
536
|
-
},
|
|
722
|
+
}, _callee4);
|
|
537
723
|
}));
|
|
538
724
|
return function (_x) {
|
|
539
|
-
return
|
|
725
|
+
return _ref7.apply(this, arguments);
|
|
540
726
|
};
|
|
541
|
-
}(), [applyTransition, currentStep, currentStepIndex, emitStepChange, flatSteps, runValidation, steps]);
|
|
727
|
+
}(), [applyTransition, currentStep, currentStepIndex, currentStepObj, emitStepChange, flatSteps, runValidation, steps]);
|
|
542
728
|
var skip = useCallback(function () {
|
|
543
729
|
if (!(currentStepObj != null && currentStepObj.skippable)) return;
|
|
544
730
|
var nextId = resolveNextStepId();
|
|
545
731
|
if (!nextId) return;
|
|
546
732
|
// Skip: no validation, no completion.
|
|
547
|
-
|
|
548
|
-
setVisitedSteps(function (prev) {
|
|
549
|
-
return [].concat(prev, [nextId]);
|
|
550
|
-
});
|
|
733
|
+
navigationVersion.current += 1;
|
|
551
734
|
if (!isControlled) setUncontrolledStep(nextId);
|
|
552
735
|
emitStepChange({
|
|
553
736
|
trigger: 'skip',
|
|
@@ -560,16 +743,16 @@ var Wizard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
560
743
|
element: 'Wizard'
|
|
561
744
|
});
|
|
562
745
|
}, [sendAnalytics, currentStep, currentStepObj, emitStepChange, isControlled, resolveNextStepId]);
|
|
563
|
-
var complete = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
564
|
-
var _yield$runValidation3, ok, error, nextCompleted, completedStepsList;
|
|
565
|
-
return _regenerator().w(function (
|
|
566
|
-
while (1) switch (
|
|
746
|
+
var complete = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
|
|
747
|
+
var _yield$runValidation3, ok, error, cancelled, completionCandidates, nextCompleted, completedStepsList;
|
|
748
|
+
return _regenerator().w(function (_context5) {
|
|
749
|
+
while (1) switch (_context5.n) {
|
|
567
750
|
case 0:
|
|
568
|
-
if (!
|
|
569
|
-
|
|
751
|
+
if (!(validationInFlight.current || currentStepObj != null && currentStepObj.disabled)) {
|
|
752
|
+
_context5.n = 1;
|
|
570
753
|
break;
|
|
571
754
|
}
|
|
572
|
-
return
|
|
755
|
+
return _context5.a(2);
|
|
573
756
|
case 1:
|
|
574
757
|
emitStepChange({
|
|
575
758
|
trigger: 'complete',
|
|
@@ -581,35 +764,40 @@ var Wizard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
581
764
|
phase: 'validating',
|
|
582
765
|
from: currentStep
|
|
583
766
|
});
|
|
584
|
-
|
|
767
|
+
_context5.n = 2;
|
|
585
768
|
return runValidation();
|
|
586
769
|
case 2:
|
|
587
|
-
_yield$runValidation3 =
|
|
770
|
+
_yield$runValidation3 = _context5.v;
|
|
588
771
|
ok = _yield$runValidation3.ok;
|
|
589
772
|
error = _yield$runValidation3.error;
|
|
590
|
-
|
|
591
|
-
|
|
773
|
+
cancelled = _yield$runValidation3.cancelled;
|
|
774
|
+
if (!cancelled) {
|
|
775
|
+
_context5.n = 3;
|
|
776
|
+
break;
|
|
777
|
+
}
|
|
778
|
+
return _context5.a(2);
|
|
779
|
+
case 3:
|
|
780
|
+
if (!(!ok && !(currentStepObj != null && currentStepObj.skippable))) {
|
|
781
|
+
_context5.n = 4;
|
|
592
782
|
break;
|
|
593
783
|
}
|
|
594
|
-
setValidationError(error);
|
|
595
784
|
emitStepChange({
|
|
596
785
|
trigger: 'complete',
|
|
597
786
|
phase: 'blocked',
|
|
598
787
|
from: currentStep,
|
|
599
788
|
error: error
|
|
600
789
|
});
|
|
601
|
-
return
|
|
602
|
-
case
|
|
603
|
-
emitStepChange({
|
|
790
|
+
return _context5.a(2);
|
|
791
|
+
case 4:
|
|
792
|
+
if (ok) emitStepChange({
|
|
604
793
|
trigger: 'complete',
|
|
605
794
|
phase: 'validated',
|
|
606
795
|
from: currentStep
|
|
607
796
|
});
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
});
|
|
797
|
+
completionCandidates = new Set(completedSteps);
|
|
798
|
+
if (ok) completionCandidates.add(currentStep);else completionCandidates["delete"](currentStep);
|
|
799
|
+
nextCompleted = filterCompletedSteps(latest.current.steps, stepValidationRef.current, completionCandidates);
|
|
800
|
+
setCompletedSteps(nextCompleted);
|
|
613
801
|
// Emit 'completed' before invoking onComplete.
|
|
614
802
|
emitStepChange({
|
|
615
803
|
trigger: 'complete',
|
|
@@ -617,26 +805,24 @@ var Wizard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
617
805
|
from: currentStep
|
|
618
806
|
});
|
|
619
807
|
if (onComplete) {
|
|
620
|
-
// setCompletedSteps above is async; include currentStep here so the
|
|
621
|
-
// payload reflects the just-completed final step.
|
|
622
|
-
nextCompleted = new Set(completedSteps);
|
|
623
|
-
nextCompleted.add(currentStep);
|
|
624
808
|
completedStepsList = Array.from(nextCompleted);
|
|
625
809
|
onComplete({
|
|
626
810
|
value: formValue,
|
|
627
|
-
completedSteps: completedStepsList
|
|
811
|
+
completedSteps: completedStepsList,
|
|
812
|
+
steps: resolveStepResults(latest.current.steps, stepValidationRef.current, nextCompleted)
|
|
628
813
|
});
|
|
629
814
|
}
|
|
630
815
|
if (sendAnalytics) sendAnalytics({
|
|
631
816
|
type: 'wizardComplete',
|
|
632
817
|
element: 'Wizard'
|
|
633
818
|
});
|
|
634
|
-
case
|
|
635
|
-
return
|
|
819
|
+
case 5:
|
|
820
|
+
return _context5.a(2);
|
|
636
821
|
}
|
|
637
|
-
},
|
|
638
|
-
})), [sendAnalytics, completedSteps, currentStep, emitStepChange, formValue,
|
|
822
|
+
}, _callee5);
|
|
823
|
+
})), [sendAnalytics, completedSteps, currentStep, currentStepObj, emitStepChange, formValue, onComplete, runValidation]);
|
|
639
824
|
var cancel = useCallback(function () {
|
|
825
|
+
navigationVersion.current += 1;
|
|
640
826
|
emitStepChange({
|
|
641
827
|
trigger: 'cancel',
|
|
642
828
|
phase: 'cancelled',
|
|
@@ -684,17 +870,24 @@ var Wizard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
684
870
|
if (typeof window !== 'undefined') safeScrollTo(window);
|
|
685
871
|
}, [currentStep, scrollToTop, wizardRef]);
|
|
686
872
|
var canGoNext = !(currentStepObj != null && currentStepObj.disabled) && !isValidating;
|
|
687
|
-
var isBlocked =
|
|
873
|
+
var isBlocked = (currentValidation == null || (_currentValidation$fo = currentValidation.form) == null ? void 0 : _currentValidation$fo.ok) === false || (currentValidation == null || (_currentValidation$ca2 = currentValidation.callback) == null ? void 0 : _currentValidation$ca2.ok) === false;
|
|
688
874
|
var isCompleted = completedSteps.has(currentStep);
|
|
689
875
|
var contextValue = useMemo(function () {
|
|
690
876
|
return {
|
|
691
877
|
steps: steps,
|
|
692
878
|
flatSteps: flatSteps,
|
|
879
|
+
clickableSteps: clickableSteps,
|
|
880
|
+
closable: closable,
|
|
693
881
|
currentStep: currentStep,
|
|
694
882
|
currentStepIndex: currentStepIndex,
|
|
695
883
|
currentStepObj: currentStepObj,
|
|
696
884
|
totalSteps: totalSteps,
|
|
697
885
|
stepStates: stepStates,
|
|
886
|
+
stepErrorMessages: stepErrorMessages,
|
|
887
|
+
stepValidation: stepValidation,
|
|
888
|
+
updateValidation: updateValidation,
|
|
889
|
+
registerForm: registerForm,
|
|
890
|
+
form: form,
|
|
698
891
|
formValue: formValue,
|
|
699
892
|
setFormValue: setFormValue,
|
|
700
893
|
validationError: validationError,
|
|
@@ -716,7 +909,7 @@ var Wizard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
716
909
|
// (same pattern as `hasCancelHandler`).
|
|
717
910
|
messages: messages
|
|
718
911
|
};
|
|
719
|
-
}, [steps, flatSteps, currentStep, currentStepIndex, currentStepObj, totalSteps, stepStates, formValue, setFormValue, validationError, isValidating, isBlocked, isCompleted, canGoNext, next, previous, goTo, skip, complete, cancel, hasCancelHandler, effectiveShowProgress, renderStep, messages]);
|
|
912
|
+
}, [steps, flatSteps, clickableSteps, closable, currentStep, currentStepIndex, currentStepObj, totalSteps, stepStates, stepErrorMessages, stepValidation, updateValidation, registerForm, form, formValue, setFormValue, validationError, isValidating, isBlocked, isCompleted, canGoNext, next, previous, goTo, skip, complete, cancel, hasCancelHandler, effectiveShowProgress, renderStep, messages]);
|
|
720
913
|
if (!isOpen) return null;
|
|
721
914
|
|
|
722
915
|
// Custom composition: consumers supply their own tree via `children`.
|
|
@@ -746,7 +939,9 @@ var Wizard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
746
939
|
flex: "grow",
|
|
747
940
|
fill: "horizontal",
|
|
748
941
|
direction: effectiveShowProgress === 'vertical' ? 'row' : 'column'
|
|
749
|
-
},
|
|
942
|
+
}, /*#__PURE__*/React.createElement(StyledWizardProgress, {
|
|
943
|
+
$hidden: !effectiveShowProgress || responsiveSize === 'small' || responsiveSize === 'xsmall'
|
|
944
|
+
}, /*#__PURE__*/React.createElement(WizardProgress, null)), /*#__PURE__*/React.createElement(Box, {
|
|
750
945
|
flex: "grow"
|
|
751
946
|
}, /*#__PURE__*/React.createElement(WizardStepHeader, null), /*#__PURE__*/React.createElement(WizardContent, null)))), footerNode));
|
|
752
947
|
}
|