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
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.Wizard = void 0;
|
|
5
5
|
var _react = _interopRequireWildcard(require("react"));
|
|
6
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
6
7
|
var _contexts = require("../../contexts");
|
|
7
8
|
var _MessageContext = require("../../contexts/MessageContext");
|
|
8
9
|
var _ResponsiveContext = require("../../contexts/ResponsiveContext");
|
|
@@ -17,13 +18,16 @@ var _WizardStepHeader = require("./WizardStepHeader");
|
|
|
17
18
|
var _WizardContent = require("./WizardContent");
|
|
18
19
|
var _WizardFooter = require("./WizardFooter");
|
|
19
20
|
var _propTypes = require("./propTypes");
|
|
20
|
-
var _excluded = ["
|
|
21
|
-
|
|
22
|
-
function
|
|
21
|
+
var _excluded = ["children"],
|
|
22
|
+
_excluded2 = ["steps", "clickableSteps", "closable", "currentStep", "defaultStep", "form", "showProgress", "onStepChange", "onComplete", "onCancel", "renderStep", "title", "footer", "scrollToTop", "value", "defaultValue", "onChange", "id", "aria-label", "messages", "children"];
|
|
23
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
24
|
+
var cache;
|
|
25
|
+
function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var r, c, a = Object.defineProperty, n = { __proto__: null, "default": e }; if (Object(e) !== e) return n; if (cache || "function" != typeof WeakMap || (cache = new WeakMap()), cache) { if (cache.has(e)) return cache.get(e); cache.set(e, n); } for (c in e) "default" !== c && {}.hasOwnProperty.call(e, c) && ((r = a && Object.getOwnPropertyDescriptor(e, c)) && (r.get || r.set) ? a(n, c, r) : n[c] = e[c]); return n; }
|
|
23
26
|
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 }; })(); }
|
|
24
27
|
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); }
|
|
25
28
|
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); }
|
|
26
29
|
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); }); }; }
|
|
30
|
+
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); }
|
|
27
31
|
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; }
|
|
28
32
|
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."); }
|
|
29
33
|
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; } }
|
|
@@ -46,20 +50,80 @@ var flattenLeaves = function flattenLeaves(steps) {
|
|
|
46
50
|
};
|
|
47
51
|
|
|
48
52
|
// Find step by id in the tree or leaf list.
|
|
49
|
-
var
|
|
53
|
+
var _findStepById = function findStepById(steps, id) {
|
|
50
54
|
// eslint-disable-next-line no-restricted-syntax
|
|
51
55
|
for (var _iterator = _createForOfIteratorHelperLoose(steps), _step; !(_step = _iterator()).done;) {
|
|
52
56
|
var step = _step.value;
|
|
53
57
|
if (step.id === id) return step;
|
|
54
58
|
if (step.children) {
|
|
55
|
-
var match = step.children
|
|
56
|
-
return child.id === id;
|
|
57
|
-
});
|
|
59
|
+
var match = _findStepById(step.children, id);
|
|
58
60
|
if (match) return match;
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
63
|
return undefined;
|
|
62
64
|
};
|
|
65
|
+
var formHasErrors = function formHasErrors(result) {
|
|
66
|
+
var _result$form, _result$form2;
|
|
67
|
+
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;
|
|
68
|
+
};
|
|
69
|
+
var StyledWizardProgress = _styledComponents["default"].div.withConfig({
|
|
70
|
+
displayName: "Wizard__StyledWizardProgress",
|
|
71
|
+
componentId: "sc-uqfco5-0"
|
|
72
|
+
})(["display:", ";"], function (props) {
|
|
73
|
+
return props.$hidden ? 'none' : 'contents';
|
|
74
|
+
});
|
|
75
|
+
var statusFromStep = function statusFromStep(step, validation, completed) {
|
|
76
|
+
var _validation$step$id;
|
|
77
|
+
if (!step) return 'pending';
|
|
78
|
+
if (step.disabled) return 'disabled';
|
|
79
|
+
if (step.status) return step.status;
|
|
80
|
+
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';
|
|
81
|
+
if (completed.has(step.id)) return 'completed';
|
|
82
|
+
return 'pending';
|
|
83
|
+
};
|
|
84
|
+
var getStepStatus = function getStepStatus(step, validation, completed) {
|
|
85
|
+
var _step$children;
|
|
86
|
+
if (step != null && step.disabled || step != null && step.status || !(step != null && (_step$children = step.children) != null && _step$children.length)) return statusFromStep(step, validation, completed);
|
|
87
|
+
var childStatuses = step.children.map(function (child) {
|
|
88
|
+
return statusFromStep(child, validation, completed);
|
|
89
|
+
});
|
|
90
|
+
if (childStatuses.some(function (status) {
|
|
91
|
+
return status === 'error';
|
|
92
|
+
})) return 'error';
|
|
93
|
+
if (childStatuses.every(function (status) {
|
|
94
|
+
return status === 'completed';
|
|
95
|
+
})) return 'completed';
|
|
96
|
+
if (childStatuses.every(function (status) {
|
|
97
|
+
return status === 'disabled';
|
|
98
|
+
})) return 'disabled';
|
|
99
|
+
return 'pending';
|
|
100
|
+
};
|
|
101
|
+
var filterCompletedSteps = function filterCompletedSteps(steps, validation, completed) {
|
|
102
|
+
var remaining = Array.from(completed).filter(function (stepId) {
|
|
103
|
+
var step = _findStepById(steps, stepId);
|
|
104
|
+
return step && getStepStatus(step, validation, completed) !== 'error';
|
|
105
|
+
});
|
|
106
|
+
return remaining.length === completed.size ? completed : new Set(remaining);
|
|
107
|
+
};
|
|
108
|
+
var resolveStepResults = function resolveStepResults(steps, validation, completed) {
|
|
109
|
+
var results = [];
|
|
110
|
+
var _walk = function walk(nodes) {
|
|
111
|
+
return nodes.forEach(function (step) {
|
|
112
|
+
var _step$errorMessage, _validation$step$id2;
|
|
113
|
+
var childSteps = step.children,
|
|
114
|
+
details = _objectWithoutPropertiesLoose(step, _excluded);
|
|
115
|
+
var status = getStepStatus(step, validation, completed);
|
|
116
|
+
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;
|
|
117
|
+
results.push(_extends({}, details, {
|
|
118
|
+
status: status,
|
|
119
|
+
errorMessage: errorMessage
|
|
120
|
+
}));
|
|
121
|
+
if (childSteps != null && childSteps.length) _walk(childSteps);
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
_walk(steps);
|
|
125
|
+
return results;
|
|
126
|
+
};
|
|
63
127
|
|
|
64
128
|
// Nearest scrollable ancestor for scrollToTop.
|
|
65
129
|
var findScrollableAncestor = function findScrollableAncestor(node) {
|
|
@@ -75,9 +139,16 @@ var findScrollableAncestor = function findScrollableAncestor(node) {
|
|
|
75
139
|
return undefined;
|
|
76
140
|
};
|
|
77
141
|
var Wizard = exports.Wizard = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
142
|
+
var _currentValidation$ca, _currentValidation$fo, _currentValidation$ca2;
|
|
78
143
|
var steps = _ref.steps,
|
|
144
|
+
_ref$clickableSteps = _ref.clickableSteps,
|
|
145
|
+
clickableSteps = _ref$clickableSteps === void 0 ? false : _ref$clickableSteps,
|
|
146
|
+
_ref$closable = _ref.closable,
|
|
147
|
+
closable = _ref$closable === void 0 ? true : _ref$closable,
|
|
79
148
|
currentStepProp = _ref.currentStep,
|
|
80
149
|
defaultStep = _ref.defaultStep,
|
|
150
|
+
_ref$form = _ref.form,
|
|
151
|
+
form = _ref$form === void 0 ? true : _ref$form,
|
|
81
152
|
_ref$showProgress = _ref.showProgress,
|
|
82
153
|
showProgress = _ref$showProgress === void 0 ? false : _ref$showProgress,
|
|
83
154
|
onStepChange = _ref.onStepChange,
|
|
@@ -95,7 +166,7 @@ var Wizard = exports.Wizard = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
95
166
|
ariaLabel = _ref['aria-label'],
|
|
96
167
|
messages = _ref.messages,
|
|
97
168
|
children = _ref.children,
|
|
98
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
169
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded2);
|
|
99
170
|
var _useThemeValue = (0, _useThemeValue2.useThemeValue)(),
|
|
100
171
|
theme = _useThemeValue.theme;
|
|
101
172
|
var _React$useContext = _react["default"].useContext(_MessageContext.MessageContext),
|
|
@@ -111,8 +182,8 @@ var Wizard = exports.Wizard = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
111
182
|
|
|
112
183
|
// Only two levels supported (step > child); warn on deeper nesting.
|
|
113
184
|
var hasDeepNesting = steps.some(function (step) {
|
|
114
|
-
var _step$
|
|
115
|
-
return (_step$
|
|
185
|
+
var _step$children2;
|
|
186
|
+
return (_step$children2 = step.children) == null ? void 0 : _step$children2.some(function (child) {
|
|
116
187
|
return child.children && child.children.length > 0;
|
|
117
188
|
});
|
|
118
189
|
});
|
|
@@ -141,6 +212,33 @@ var Wizard = exports.Wizard = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
141
212
|
uncontrolledStep = _useState[0],
|
|
142
213
|
setUncontrolledStep = _useState[1];
|
|
143
214
|
var currentStep = isControlled ? currentStepProp : uncontrolledStep;
|
|
215
|
+
var latest = (0, _react.useRef)({
|
|
216
|
+
currentStep: currentStep,
|
|
217
|
+
steps: steps
|
|
218
|
+
});
|
|
219
|
+
latest.current = {
|
|
220
|
+
currentStep: currentStep,
|
|
221
|
+
steps: steps
|
|
222
|
+
};
|
|
223
|
+
var mounted = (0, _react.useRef)(false);
|
|
224
|
+
var navigationVersion = (0, _react.useRef)(0);
|
|
225
|
+
var validationInFlight = (0, _react.useRef)();
|
|
226
|
+
var formValidators = (0, _react.useRef)(new Map());
|
|
227
|
+
(0, _useIsomorphicLayoutEffect.useLayoutEffect)(function () {
|
|
228
|
+
mounted.current = true;
|
|
229
|
+
return function () {
|
|
230
|
+
mounted.current = false;
|
|
231
|
+
};
|
|
232
|
+
}, []);
|
|
233
|
+
(0, _useIsomorphicLayoutEffect.useLayoutEffect)(function () {
|
|
234
|
+
navigationVersion.current += 1;
|
|
235
|
+
}, [currentStep]);
|
|
236
|
+
var registerForm = (0, _react.useCallback)(function (stepId, validateForm) {
|
|
237
|
+
formValidators.current.set(stepId, validateForm);
|
|
238
|
+
return function () {
|
|
239
|
+
if (formValidators.current.get(stepId) === validateForm) formValidators.current["delete"](stepId);
|
|
240
|
+
};
|
|
241
|
+
}, []);
|
|
144
242
|
var isValueControlled = valueProp !== undefined;
|
|
145
243
|
var _useState2 = (0, _react.useState)(defaultValue || {}),
|
|
146
244
|
uncontrolledValue = _useState2[0],
|
|
@@ -153,34 +251,56 @@ var Wizard = exports.Wizard = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
153
251
|
value: resolved
|
|
154
252
|
});
|
|
155
253
|
}, [formValue, isValueControlled, onChange]);
|
|
156
|
-
var _useState3 = (0, _react.useState)(
|
|
157
|
-
visitedSteps = _useState3[0],
|
|
158
|
-
setVisitedSteps = _useState3[1];
|
|
159
|
-
var _useState4 = (0, _react.useState)(function () {
|
|
254
|
+
var _useState3 = (0, _react.useState)(function () {
|
|
160
255
|
return new Set();
|
|
161
256
|
}),
|
|
162
|
-
completedSteps =
|
|
163
|
-
setCompletedSteps =
|
|
164
|
-
var
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
257
|
+
completedSteps = _useState3[0],
|
|
258
|
+
setCompletedSteps = _useState3[1];
|
|
259
|
+
var stepValidationRef = (0, _react.useRef)({});
|
|
260
|
+
var _useState4 = (0, _react.useState)(stepValidationRef.current),
|
|
261
|
+
stepValidation = _useState4[0],
|
|
262
|
+
setStepValidation = _useState4[1];
|
|
263
|
+
var updateValidation = (0, _react.useCallback)(function (stepId, source, result) {
|
|
264
|
+
var _extends2, _extends3;
|
|
265
|
+
if (!mounted.current || !_findStepById(latest.current.steps, stepId)) return;
|
|
266
|
+
var nextResults = _extends({}, stepValidationRef.current, (_extends3 = {}, _extends3[stepId] = _extends({}, stepValidationRef.current[stepId], (_extends2 = {}, _extends2[source] = result, _extends2)), _extends3));
|
|
267
|
+
stepValidationRef.current = nextResults;
|
|
268
|
+
setStepValidation(nextResults);
|
|
269
|
+
if (result.ok === false) {
|
|
270
|
+
setCompletedSteps(function (previousCompleted) {
|
|
271
|
+
if (!previousCompleted.has(stepId)) return previousCompleted;
|
|
272
|
+
var nextCompleted = new Set(previousCompleted);
|
|
273
|
+
nextCompleted["delete"](stepId);
|
|
274
|
+
return nextCompleted;
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}, []);
|
|
278
|
+
var currentValidation = stepValidation[currentStep];
|
|
279
|
+
var validationError = !formHasErrors(currentValidation) && (currentValidation == null || (_currentValidation$ca = currentValidation.callback) == null ? void 0 : _currentValidation$ca.ok) === false ? currentValidation.callback.error : undefined;
|
|
280
|
+
var _useState5 = (0, _react.useState)(false),
|
|
281
|
+
isValidating = _useState5[0],
|
|
282
|
+
setIsValidating = _useState5[1];
|
|
170
283
|
// Without `onCancel`, cancel self-closes the wizard.
|
|
171
|
-
var
|
|
172
|
-
isOpen =
|
|
173
|
-
setIsOpen =
|
|
284
|
+
var _useState6 = (0, _react.useState)(true),
|
|
285
|
+
isOpen = _useState6[0],
|
|
286
|
+
setIsOpen = _useState6[1];
|
|
174
287
|
var hasCancelHandler = onCancel !== undefined;
|
|
175
|
-
|
|
176
|
-
// Keep visited history in sync when currentStep is externally set.
|
|
177
288
|
(0, _react.useEffect)(function () {
|
|
178
|
-
|
|
179
|
-
|
|
289
|
+
if (validationInFlight.current && !_findStepById(steps, validationInFlight.current.stepId)) validationInFlight.current.removed = true;
|
|
290
|
+
var entries = Object.entries(stepValidationRef.current).filter(function (_ref2) {
|
|
291
|
+
var stepId = _ref2[0];
|
|
292
|
+
return _findStepById(steps, stepId);
|
|
180
293
|
});
|
|
181
|
-
|
|
294
|
+
if (entries.length !== Object.keys(stepValidationRef.current).length) {
|
|
295
|
+
stepValidationRef.current = Object.fromEntries(entries);
|
|
296
|
+
setStepValidation(stepValidationRef.current);
|
|
297
|
+
}
|
|
298
|
+
setCompletedSteps(function (previousCompleted) {
|
|
299
|
+
return filterCompletedSteps(steps, stepValidationRef.current, previousCompleted);
|
|
300
|
+
});
|
|
301
|
+
}, [steps]);
|
|
182
302
|
var currentStepObj = (0, _react.useMemo)(function () {
|
|
183
|
-
return
|
|
303
|
+
return _findStepById(steps, currentStep);
|
|
184
304
|
}, [steps, currentStep]);
|
|
185
305
|
var currentStepIndex = (0, _react.useMemo)(function () {
|
|
186
306
|
return flatSteps.findIndex(function (step) {
|
|
@@ -188,51 +308,21 @@ var Wizard = exports.Wizard = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
188
308
|
});
|
|
189
309
|
}, [flatSteps, currentStep]);
|
|
190
310
|
var totalSteps = flatSteps.length;
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
// Parent-with-children aggregate
|
|
195
|
-
var parent = steps.find(function (step) {
|
|
196
|
-
return step.id === stepId && step.children && step.children.length;
|
|
197
|
-
});
|
|
198
|
-
if (parent) {
|
|
199
|
-
var childStatuses = parent.children.map(function (child) {
|
|
200
|
-
if (child.disabled) return 'disabled';
|
|
201
|
-
if (child.id === currentStep && validationError) return 'error';
|
|
202
|
-
if (completedSteps.has(child.id)) return 'completed';
|
|
203
|
-
return 'pending';
|
|
204
|
-
});
|
|
205
|
-
if (childStatuses.some(function (status) {
|
|
206
|
-
return status === 'error';
|
|
207
|
-
})) return 'error';
|
|
208
|
-
if (childStatuses.every(function (status) {
|
|
209
|
-
return status === 'completed';
|
|
210
|
-
})) return 'completed';
|
|
211
|
-
if (childStatuses.every(function (status) {
|
|
212
|
-
return status === 'disabled';
|
|
213
|
-
})) return 'disabled';
|
|
214
|
-
return 'pending';
|
|
215
|
-
}
|
|
216
|
-
var step = findStepById(steps, stepId);
|
|
217
|
-
if (!step) return 'pending';
|
|
218
|
-
if (step.disabled) return 'disabled';
|
|
219
|
-
if (stepId === currentStep && validationError) return 'error';
|
|
220
|
-
if (completedSteps.has(stepId)) return 'completed';
|
|
221
|
-
return 'pending';
|
|
222
|
-
}, [steps, currentStep, completedSteps, validationError]);
|
|
311
|
+
var stepResults = (0, _react.useMemo)(function () {
|
|
312
|
+
return resolveStepResults(steps, stepValidation, completedSteps);
|
|
313
|
+
}, [steps, stepValidation, completedSteps]);
|
|
223
314
|
|
|
224
315
|
// Record<id, status> for every step (top-level + children).
|
|
225
316
|
var stepStates = (0, _react.useMemo)(function () {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}, [steps, getStepStatus]);
|
|
317
|
+
return Object.fromEntries(stepResults.map(function (step) {
|
|
318
|
+
return [step.id, step.status];
|
|
319
|
+
}));
|
|
320
|
+
}, [stepResults]);
|
|
321
|
+
var stepErrorMessages = (0, _react.useMemo)(function () {
|
|
322
|
+
return Object.fromEntries(stepResults.map(function (step) {
|
|
323
|
+
return [step.id, step.errorMessage];
|
|
324
|
+
}));
|
|
325
|
+
}, [stepResults]);
|
|
236
326
|
|
|
237
327
|
// Emit a step change event to onStepChange.
|
|
238
328
|
var emitStepChange = (0, _react.useCallback)(function (event) {
|
|
@@ -241,85 +331,86 @@ var Wizard = exports.Wizard = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
241
331
|
|
|
242
332
|
// Resolve next step id, honoring step.nextStep(formValue) branching.
|
|
243
333
|
var resolveNextStepId = (0, _react.useCallback)(function () {
|
|
244
|
-
var _flatSteps$nextIndex;
|
|
245
334
|
if (!currentStepObj) return undefined;
|
|
246
335
|
if (typeof currentStepObj.nextStep === 'function') {
|
|
247
336
|
var nextId = currentStepObj.nextStep(formValue);
|
|
248
337
|
if (!nextId) return undefined;
|
|
249
|
-
var match =
|
|
338
|
+
var match = _findStepById(steps, nextId);
|
|
250
339
|
if (!match) {
|
|
251
340
|
if (process.env.NODE_ENV !== 'production') {
|
|
252
341
|
console.warn("Wizard: nextStep(\"" + nextId + "\") does not match any step id. " + 'Staying on current step.');
|
|
253
342
|
}
|
|
254
343
|
return undefined;
|
|
255
344
|
}
|
|
256
|
-
return nextId;
|
|
345
|
+
return !match.disabled ? nextId : undefined;
|
|
257
346
|
}
|
|
258
347
|
var nextIndex = currentStepIndex + 1;
|
|
259
|
-
|
|
260
|
-
|
|
348
|
+
while (nextIndex < flatSteps.length) {
|
|
349
|
+
var nextStep = flatSteps[nextIndex];
|
|
350
|
+
if (!(nextStep != null && nextStep.disabled)) return nextStep.id;
|
|
351
|
+
if (nextStep != null && nextStep.disabled && (clickableSteps || nextStep != null && nextStep.skippable)) {
|
|
352
|
+
nextIndex += 1;
|
|
353
|
+
} else {
|
|
354
|
+
return undefined;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return undefined;
|
|
358
|
+
}, [clickableSteps, currentStepObj, currentStepIndex, flatSteps, formValue, steps]);
|
|
359
|
+
var resolvePreviousStepId = (0, _react.useCallback)(function () {
|
|
360
|
+
var prevIndex = currentStepIndex - 1;
|
|
361
|
+
while (prevIndex >= 0) {
|
|
362
|
+
var prevStep = flatSteps[prevIndex];
|
|
363
|
+
if (!(prevStep != null && prevStep.disabled)) return prevStep.id;
|
|
364
|
+
prevIndex -= 1;
|
|
365
|
+
}
|
|
366
|
+
return undefined;
|
|
367
|
+
}, [currentStepIndex, flatSteps]);
|
|
261
368
|
|
|
262
369
|
// Apply a navigation transition (id, history, completion, focus).
|
|
263
370
|
var applyTransition = (0, _react.useCallback)(function (nextId, _temp) {
|
|
264
|
-
var
|
|
265
|
-
markCompleted =
|
|
371
|
+
var _ref3 = _temp === void 0 ? {} : _temp,
|
|
372
|
+
markCompleted = _ref3.markCompleted;
|
|
266
373
|
if (!nextId) return;
|
|
374
|
+
navigationVersion.current += 1;
|
|
267
375
|
if (markCompleted && currentStep) {
|
|
268
376
|
setCompletedSteps(function (prev) {
|
|
269
377
|
var next = new Set(prev);
|
|
270
378
|
next.add(currentStep);
|
|
271
|
-
return next;
|
|
379
|
+
return filterCompletedSteps(latest.current.steps, stepValidationRef.current, next);
|
|
272
380
|
});
|
|
273
381
|
}
|
|
274
|
-
setValidationError(undefined);
|
|
275
|
-
setVisitedSteps(function (prev) {
|
|
276
|
-
return [].concat(prev, [nextId]);
|
|
277
|
-
});
|
|
278
382
|
if (!isControlled) setUncontrolledStep(nextId);
|
|
279
383
|
}, [currentStep, isControlled]);
|
|
280
384
|
|
|
281
385
|
// Run step.validate (sync or async). Returns { ok, error }.
|
|
282
|
-
var
|
|
283
|
-
var
|
|
386
|
+
var runStepValidation = (0, _react.useCallback)(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
387
|
+
var result, _t;
|
|
284
388
|
return _regenerator().w(function (_context) {
|
|
285
389
|
while (1) switch (_context.p = _context.n) {
|
|
286
390
|
case 0:
|
|
287
|
-
formElement = document.getElementById(currentStep + "-form");
|
|
288
|
-
formIsValid = (formElement == null ? void 0 : formElement.getAttribute('data-form-valid')) !== 'false';
|
|
289
|
-
if (formIsValid) {
|
|
290
|
-
_context.n = 1;
|
|
291
|
-
break;
|
|
292
|
-
}
|
|
293
|
-
return _context.a(2, {
|
|
294
|
-
ok: false,
|
|
295
|
-
error: undefined
|
|
296
|
-
});
|
|
297
|
-
case 1:
|
|
298
391
|
if (!(typeof (currentStepObj == null ? void 0 : currentStepObj.validate) !== 'function')) {
|
|
299
|
-
_context.n =
|
|
392
|
+
_context.n = 1;
|
|
300
393
|
break;
|
|
301
394
|
}
|
|
302
395
|
return _context.a(2, {
|
|
303
396
|
ok: true
|
|
304
397
|
});
|
|
305
|
-
case
|
|
306
|
-
|
|
307
|
-
_context.
|
|
308
|
-
_context.n = 4;
|
|
398
|
+
case 1:
|
|
399
|
+
_context.p = 1;
|
|
400
|
+
_context.n = 2;
|
|
309
401
|
return currentStepObj.validate(formValue);
|
|
310
|
-
case
|
|
402
|
+
case 2:
|
|
311
403
|
result = _context.v;
|
|
312
|
-
setIsValidating(false);
|
|
313
404
|
if (!(result === true || result === undefined)) {
|
|
314
|
-
_context.n =
|
|
405
|
+
_context.n = 3;
|
|
315
406
|
break;
|
|
316
407
|
}
|
|
317
408
|
return _context.a(2, {
|
|
318
409
|
ok: true
|
|
319
410
|
});
|
|
320
|
-
case
|
|
411
|
+
case 3:
|
|
321
412
|
if (!(result === false)) {
|
|
322
|
-
_context.n =
|
|
413
|
+
_context.n = 4;
|
|
323
414
|
break;
|
|
324
415
|
}
|
|
325
416
|
return _context.a(2, {
|
|
@@ -329,32 +420,31 @@ var Wizard = exports.Wizard = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
329
420
|
messages: messages
|
|
330
421
|
})
|
|
331
422
|
});
|
|
332
|
-
case
|
|
423
|
+
case 4:
|
|
333
424
|
if (!(typeof result === 'string')) {
|
|
334
|
-
_context.n =
|
|
425
|
+
_context.n = 5;
|
|
335
426
|
break;
|
|
336
427
|
}
|
|
337
428
|
return _context.a(2, {
|
|
338
429
|
ok: false,
|
|
339
430
|
error: result
|
|
340
431
|
});
|
|
341
|
-
case
|
|
342
|
-
if (!(typeof result === 'object' && result.error)) {
|
|
343
|
-
_context.n =
|
|
432
|
+
case 5:
|
|
433
|
+
if (!(result && typeof result === 'object' && result.error)) {
|
|
434
|
+
_context.n = 6;
|
|
344
435
|
break;
|
|
345
436
|
}
|
|
346
437
|
return _context.a(2, {
|
|
347
438
|
ok: false,
|
|
348
439
|
error: result.error
|
|
349
440
|
});
|
|
350
|
-
case
|
|
441
|
+
case 6:
|
|
351
442
|
return _context.a(2, {
|
|
352
443
|
ok: true
|
|
353
444
|
});
|
|
354
|
-
case
|
|
355
|
-
_context.p =
|
|
445
|
+
case 7:
|
|
446
|
+
_context.p = 7;
|
|
356
447
|
_t = _context.v;
|
|
357
|
-
setIsValidating(false);
|
|
358
448
|
return _context.a(2, {
|
|
359
449
|
ok: false,
|
|
360
450
|
error: (_t == null ? void 0 : _t.message) || format({
|
|
@@ -363,18 +453,93 @@ var Wizard = exports.Wizard = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
363
453
|
})
|
|
364
454
|
});
|
|
365
455
|
}
|
|
366
|
-
}, _callee, null, [[
|
|
367
|
-
})), [
|
|
368
|
-
var
|
|
369
|
-
var
|
|
456
|
+
}, _callee, null, [[1, 7]]);
|
|
457
|
+
})), [currentStepObj, formValue, format, messages]);
|
|
458
|
+
var runValidation = (0, _react.useCallback)(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
459
|
+
var attempt, isStale, validateForm, _result, result;
|
|
370
460
|
return _regenerator().w(function (_context2) {
|
|
371
|
-
while (1) switch (_context2.n) {
|
|
461
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
372
462
|
case 0:
|
|
373
|
-
if (!
|
|
463
|
+
if (!validationInFlight.current) {
|
|
374
464
|
_context2.n = 1;
|
|
375
465
|
break;
|
|
376
466
|
}
|
|
467
|
+
return _context2.a(2, {
|
|
468
|
+
cancelled: true
|
|
469
|
+
});
|
|
470
|
+
case 1:
|
|
471
|
+
attempt = {
|
|
472
|
+
stepId: currentStep,
|
|
473
|
+
version: navigationVersion.current
|
|
474
|
+
};
|
|
475
|
+
validationInFlight.current = attempt;
|
|
476
|
+
setIsValidating(true);
|
|
477
|
+
isStale = function isStale() {
|
|
478
|
+
return !mounted.current || attempt.removed || latest.current.currentStep !== attempt.stepId || navigationVersion.current !== attempt.version || !_findStepById(latest.current.steps, attempt.stepId);
|
|
479
|
+
};
|
|
480
|
+
_context2.p = 2;
|
|
481
|
+
validateForm = form && formValidators.current.get(currentStep);
|
|
482
|
+
if (!validateForm) {
|
|
483
|
+
_context2.n = 6;
|
|
484
|
+
break;
|
|
485
|
+
}
|
|
486
|
+
_context2.n = 3;
|
|
487
|
+
return validateForm();
|
|
488
|
+
case 3:
|
|
489
|
+
_result = _context2.v;
|
|
490
|
+
if (!_result.cancelled) {
|
|
491
|
+
_context2.n = 4;
|
|
492
|
+
break;
|
|
493
|
+
}
|
|
494
|
+
return _context2.a(2, {
|
|
495
|
+
cancelled: true
|
|
496
|
+
});
|
|
497
|
+
case 4:
|
|
498
|
+
if (_result.ok) {
|
|
499
|
+
_context2.n = 5;
|
|
500
|
+
break;
|
|
501
|
+
}
|
|
502
|
+
return _context2.a(2, {
|
|
503
|
+
ok: false,
|
|
504
|
+
cancelled: isStale()
|
|
505
|
+
});
|
|
506
|
+
case 5:
|
|
507
|
+
if (!isStale()) {
|
|
508
|
+
_context2.n = 6;
|
|
509
|
+
break;
|
|
510
|
+
}
|
|
511
|
+
return _context2.a(2, {
|
|
512
|
+
cancelled: true
|
|
513
|
+
});
|
|
514
|
+
case 6:
|
|
515
|
+
_context2.n = 7;
|
|
516
|
+
return runStepValidation();
|
|
517
|
+
case 7:
|
|
518
|
+
result = _context2.v;
|
|
519
|
+
if (!attempt.removed) updateValidation(attempt.stepId, 'callback', result);
|
|
520
|
+
return _context2.a(2, _extends({}, result, {
|
|
521
|
+
cancelled: isStale()
|
|
522
|
+
}));
|
|
523
|
+
case 8:
|
|
524
|
+
_context2.p = 8;
|
|
525
|
+
validationInFlight.current = undefined;
|
|
526
|
+
if (mounted.current) setIsValidating(false);
|
|
527
|
+
return _context2.f(8);
|
|
528
|
+
case 9:
|
|
377
529
|
return _context2.a(2);
|
|
530
|
+
}
|
|
531
|
+
}, _callee2, null, [[2,, 8, 9]]);
|
|
532
|
+
})), [currentStep, form, runStepValidation, updateValidation]);
|
|
533
|
+
var next = (0, _react.useCallback)(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
534
|
+
var _yield$runValidation, ok, error, cancelled, sourceStep, nextId;
|
|
535
|
+
return _regenerator().w(function (_context3) {
|
|
536
|
+
while (1) switch (_context3.n) {
|
|
537
|
+
case 0:
|
|
538
|
+
if (!(validationInFlight.current || currentStepObj != null && currentStepObj.disabled)) {
|
|
539
|
+
_context3.n = 1;
|
|
540
|
+
break;
|
|
541
|
+
}
|
|
542
|
+
return _context3.a(2);
|
|
378
543
|
case 1:
|
|
379
544
|
emitStepChange({
|
|
380
545
|
trigger: 'next',
|
|
@@ -386,25 +551,32 @@ var Wizard = exports.Wizard = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
386
551
|
phase: 'validating',
|
|
387
552
|
from: currentStep
|
|
388
553
|
});
|
|
389
|
-
|
|
554
|
+
_context3.n = 2;
|
|
390
555
|
return runValidation();
|
|
391
556
|
case 2:
|
|
392
|
-
_yield$runValidation =
|
|
557
|
+
_yield$runValidation = _context3.v;
|
|
393
558
|
ok = _yield$runValidation.ok;
|
|
394
559
|
error = _yield$runValidation.error;
|
|
395
|
-
|
|
396
|
-
|
|
560
|
+
cancelled = _yield$runValidation.cancelled;
|
|
561
|
+
if (!cancelled) {
|
|
562
|
+
_context3.n = 3;
|
|
563
|
+
break;
|
|
564
|
+
}
|
|
565
|
+
return _context3.a(2);
|
|
566
|
+
case 3:
|
|
567
|
+
sourceStep = _findStepById(latest.current.steps, currentStep);
|
|
568
|
+
if (!(!ok || (sourceStep == null ? void 0 : sourceStep.status) === 'error')) {
|
|
569
|
+
_context3.n = 4;
|
|
397
570
|
break;
|
|
398
571
|
}
|
|
399
|
-
setValidationError(error);
|
|
400
572
|
emitStepChange({
|
|
401
573
|
trigger: 'next',
|
|
402
574
|
phase: 'blocked',
|
|
403
575
|
from: currentStep,
|
|
404
|
-
error: error
|
|
576
|
+
error: error != null ? error : sourceStep == null ? void 0 : sourceStep.errorMessage
|
|
405
577
|
});
|
|
406
|
-
return
|
|
407
|
-
case
|
|
578
|
+
return _context3.a(2);
|
|
579
|
+
case 4:
|
|
408
580
|
emitStepChange({
|
|
409
581
|
trigger: 'next',
|
|
410
582
|
phase: 'validated',
|
|
@@ -412,11 +584,11 @@ var Wizard = exports.Wizard = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
412
584
|
});
|
|
413
585
|
nextId = resolveNextStepId();
|
|
414
586
|
if (nextId) {
|
|
415
|
-
|
|
587
|
+
_context3.n = 5;
|
|
416
588
|
break;
|
|
417
589
|
}
|
|
418
|
-
return
|
|
419
|
-
case
|
|
590
|
+
return _context3.a(2);
|
|
591
|
+
case 5:
|
|
420
592
|
applyTransition(nextId, {
|
|
421
593
|
markCompleted: true
|
|
422
594
|
});
|
|
@@ -430,22 +602,15 @@ var Wizard = exports.Wizard = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
430
602
|
type: 'wizardNext',
|
|
431
603
|
element: 'Wizard'
|
|
432
604
|
});
|
|
433
|
-
case
|
|
434
|
-
return
|
|
605
|
+
case 6:
|
|
606
|
+
return _context3.a(2);
|
|
435
607
|
}
|
|
436
|
-
},
|
|
437
|
-
})), [sendAnalytics, applyTransition, currentStep,
|
|
608
|
+
}, _callee3);
|
|
609
|
+
})), [sendAnalytics, applyTransition, currentStep, currentStepObj, emitStepChange, resolveNextStepId, runValidation]);
|
|
438
610
|
var previous = (0, _react.useCallback)(function () {
|
|
439
|
-
var
|
|
440
|
-
// History-aware; falls back to the linear predecessor.
|
|
441
|
-
var historyDest = visitedSteps.length > 1 ? visitedSteps[visitedSteps.length - 2] : undefined;
|
|
442
|
-
var fallbackDest = (_flatSteps = flatSteps[currentStepIndex - 1]) == null ? void 0 : _flatSteps.id;
|
|
443
|
-
var dest = historyDest || fallbackDest;
|
|
611
|
+
var dest = resolvePreviousStepId();
|
|
444
612
|
if (!dest) return;
|
|
445
|
-
|
|
446
|
-
return prev.slice(0, -1);
|
|
447
|
-
});
|
|
448
|
-
setValidationError(undefined);
|
|
613
|
+
navigationVersion.current += 1;
|
|
449
614
|
if (!isControlled) setUncontrolledStep(dest);
|
|
450
615
|
emitStepChange({
|
|
451
616
|
trigger: 'previous',
|
|
@@ -457,30 +622,43 @@ var Wizard = exports.Wizard = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
457
622
|
type: 'wizardPrevious',
|
|
458
623
|
element: 'Wizard'
|
|
459
624
|
});
|
|
460
|
-
}, [sendAnalytics, currentStep,
|
|
625
|
+
}, [sendAnalytics, currentStep, resolvePreviousStepId, emitStepChange, isControlled]);
|
|
461
626
|
var goTo = (0, _react.useCallback)(/*#__PURE__*/function () {
|
|
462
|
-
var
|
|
463
|
-
var target, targetIndex, forward, _yield$runValidation2, ok, error;
|
|
464
|
-
return _regenerator().w(function (
|
|
465
|
-
while (1) switch (
|
|
627
|
+
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(stepId) {
|
|
628
|
+
var target, targetIndex, forward, markCompleted, navigationError, _yield$runValidation2, ok, error, cancelled;
|
|
629
|
+
return _regenerator().w(function (_context4) {
|
|
630
|
+
while (1) switch (_context4.n) {
|
|
466
631
|
case 0:
|
|
467
632
|
if (!(!stepId || stepId === currentStep)) {
|
|
468
|
-
|
|
633
|
+
_context4.n = 1;
|
|
469
634
|
break;
|
|
470
635
|
}
|
|
471
|
-
return
|
|
636
|
+
return _context4.a(2);
|
|
472
637
|
case 1:
|
|
473
|
-
target =
|
|
638
|
+
target = _findStepById(steps, stepId);
|
|
474
639
|
if (!(!target || target.disabled)) {
|
|
475
|
-
|
|
640
|
+
_context4.n = 2;
|
|
476
641
|
break;
|
|
477
642
|
}
|
|
478
|
-
return
|
|
643
|
+
return _context4.a(2);
|
|
479
644
|
case 2:
|
|
480
645
|
targetIndex = flatSteps.findIndex(function (step) {
|
|
481
646
|
return step.id === stepId;
|
|
482
647
|
});
|
|
648
|
+
if (!(targetIndex < 0)) {
|
|
649
|
+
_context4.n = 3;
|
|
650
|
+
break;
|
|
651
|
+
}
|
|
652
|
+
return _context4.a(2);
|
|
653
|
+
case 3:
|
|
483
654
|
forward = targetIndex > currentStepIndex;
|
|
655
|
+
markCompleted = false;
|
|
656
|
+
if (!(forward && validationInFlight.current)) {
|
|
657
|
+
_context4.n = 4;
|
|
658
|
+
break;
|
|
659
|
+
}
|
|
660
|
+
return _context4.a(2);
|
|
661
|
+
case 4:
|
|
484
662
|
emitStepChange({
|
|
485
663
|
trigger: 'goTo',
|
|
486
664
|
phase: 'requested',
|
|
@@ -488,7 +666,7 @@ var Wizard = exports.Wizard = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
488
666
|
to: stepId
|
|
489
667
|
});
|
|
490
668
|
if (!forward) {
|
|
491
|
-
|
|
669
|
+
_context4.n = 8;
|
|
492
670
|
break;
|
|
493
671
|
}
|
|
494
672
|
emitStepChange({
|
|
@@ -497,17 +675,23 @@ var Wizard = exports.Wizard = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
497
675
|
from: currentStep,
|
|
498
676
|
to: stepId
|
|
499
677
|
});
|
|
500
|
-
|
|
678
|
+
_context4.n = 5;
|
|
501
679
|
return runValidation();
|
|
502
|
-
case
|
|
503
|
-
_yield$runValidation2 =
|
|
680
|
+
case 5:
|
|
681
|
+
_yield$runValidation2 = _context4.v;
|
|
504
682
|
ok = _yield$runValidation2.ok;
|
|
505
683
|
error = _yield$runValidation2.error;
|
|
506
|
-
|
|
507
|
-
|
|
684
|
+
cancelled = _yield$runValidation2.cancelled;
|
|
685
|
+
if (!cancelled) {
|
|
686
|
+
_context4.n = 6;
|
|
687
|
+
break;
|
|
688
|
+
}
|
|
689
|
+
return _context4.a(2);
|
|
690
|
+
case 6:
|
|
691
|
+
if (!(!ok && !(currentStepObj != null && currentStepObj.skippable))) {
|
|
692
|
+
_context4.n = 7;
|
|
508
693
|
break;
|
|
509
694
|
}
|
|
510
|
-
setValidationError(error);
|
|
511
695
|
emitStepChange({
|
|
512
696
|
trigger: 'goTo',
|
|
513
697
|
phase: 'blocked',
|
|
@@ -515,42 +699,43 @@ var Wizard = exports.Wizard = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
515
699
|
to: stepId,
|
|
516
700
|
error: error
|
|
517
701
|
});
|
|
518
|
-
return
|
|
519
|
-
case
|
|
520
|
-
|
|
702
|
+
return _context4.a(2);
|
|
703
|
+
case 7:
|
|
704
|
+
markCompleted = ok;
|
|
705
|
+
navigationError = error;
|
|
706
|
+
if (ok) emitStepChange({
|
|
521
707
|
trigger: 'goTo',
|
|
522
708
|
phase: 'validated',
|
|
523
709
|
from: currentStep,
|
|
524
710
|
to: stepId
|
|
525
711
|
});
|
|
526
|
-
case
|
|
712
|
+
case 8:
|
|
527
713
|
applyTransition(stepId, {
|
|
528
|
-
markCompleted:
|
|
714
|
+
markCompleted: markCompleted
|
|
529
715
|
});
|
|
530
|
-
emitStepChange({
|
|
716
|
+
emitStepChange(_extends({
|
|
531
717
|
trigger: 'goTo',
|
|
532
718
|
phase: 'navigated',
|
|
533
719
|
from: currentStep,
|
|
534
720
|
to: stepId
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
|
|
721
|
+
}, navigationError ? {
|
|
722
|
+
error: navigationError
|
|
723
|
+
} : {}));
|
|
724
|
+
case 9:
|
|
725
|
+
return _context4.a(2);
|
|
538
726
|
}
|
|
539
|
-
},
|
|
727
|
+
}, _callee4);
|
|
540
728
|
}));
|
|
541
729
|
return function (_x) {
|
|
542
|
-
return
|
|
730
|
+
return _ref7.apply(this, arguments);
|
|
543
731
|
};
|
|
544
|
-
}(), [applyTransition, currentStep, currentStepIndex, emitStepChange, flatSteps, runValidation, steps]);
|
|
732
|
+
}(), [applyTransition, currentStep, currentStepIndex, currentStepObj, emitStepChange, flatSteps, runValidation, steps]);
|
|
545
733
|
var skip = (0, _react.useCallback)(function () {
|
|
546
734
|
if (!(currentStepObj != null && currentStepObj.skippable)) return;
|
|
547
735
|
var nextId = resolveNextStepId();
|
|
548
736
|
if (!nextId) return;
|
|
549
737
|
// Skip: no validation, no completion.
|
|
550
|
-
|
|
551
|
-
setVisitedSteps(function (prev) {
|
|
552
|
-
return [].concat(prev, [nextId]);
|
|
553
|
-
});
|
|
738
|
+
navigationVersion.current += 1;
|
|
554
739
|
if (!isControlled) setUncontrolledStep(nextId);
|
|
555
740
|
emitStepChange({
|
|
556
741
|
trigger: 'skip',
|
|
@@ -563,16 +748,16 @@ var Wizard = exports.Wizard = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
563
748
|
element: 'Wizard'
|
|
564
749
|
});
|
|
565
750
|
}, [sendAnalytics, currentStep, currentStepObj, emitStepChange, isControlled, resolveNextStepId]);
|
|
566
|
-
var complete = (0, _react.useCallback)(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
567
|
-
var _yield$runValidation3, ok, error, nextCompleted, completedStepsList;
|
|
568
|
-
return _regenerator().w(function (
|
|
569
|
-
while (1) switch (
|
|
751
|
+
var complete = (0, _react.useCallback)(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
|
|
752
|
+
var _yield$runValidation3, ok, error, cancelled, completionCandidates, nextCompleted, completedStepsList;
|
|
753
|
+
return _regenerator().w(function (_context5) {
|
|
754
|
+
while (1) switch (_context5.n) {
|
|
570
755
|
case 0:
|
|
571
|
-
if (!
|
|
572
|
-
|
|
756
|
+
if (!(validationInFlight.current || currentStepObj != null && currentStepObj.disabled)) {
|
|
757
|
+
_context5.n = 1;
|
|
573
758
|
break;
|
|
574
759
|
}
|
|
575
|
-
return
|
|
760
|
+
return _context5.a(2);
|
|
576
761
|
case 1:
|
|
577
762
|
emitStepChange({
|
|
578
763
|
trigger: 'complete',
|
|
@@ -584,35 +769,40 @@ var Wizard = exports.Wizard = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
584
769
|
phase: 'validating',
|
|
585
770
|
from: currentStep
|
|
586
771
|
});
|
|
587
|
-
|
|
772
|
+
_context5.n = 2;
|
|
588
773
|
return runValidation();
|
|
589
774
|
case 2:
|
|
590
|
-
_yield$runValidation3 =
|
|
775
|
+
_yield$runValidation3 = _context5.v;
|
|
591
776
|
ok = _yield$runValidation3.ok;
|
|
592
777
|
error = _yield$runValidation3.error;
|
|
593
|
-
|
|
594
|
-
|
|
778
|
+
cancelled = _yield$runValidation3.cancelled;
|
|
779
|
+
if (!cancelled) {
|
|
780
|
+
_context5.n = 3;
|
|
781
|
+
break;
|
|
782
|
+
}
|
|
783
|
+
return _context5.a(2);
|
|
784
|
+
case 3:
|
|
785
|
+
if (!(!ok && !(currentStepObj != null && currentStepObj.skippable))) {
|
|
786
|
+
_context5.n = 4;
|
|
595
787
|
break;
|
|
596
788
|
}
|
|
597
|
-
setValidationError(error);
|
|
598
789
|
emitStepChange({
|
|
599
790
|
trigger: 'complete',
|
|
600
791
|
phase: 'blocked',
|
|
601
792
|
from: currentStep,
|
|
602
793
|
error: error
|
|
603
794
|
});
|
|
604
|
-
return
|
|
605
|
-
case
|
|
606
|
-
emitStepChange({
|
|
795
|
+
return _context5.a(2);
|
|
796
|
+
case 4:
|
|
797
|
+
if (ok) emitStepChange({
|
|
607
798
|
trigger: 'complete',
|
|
608
799
|
phase: 'validated',
|
|
609
800
|
from: currentStep
|
|
610
801
|
});
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
});
|
|
802
|
+
completionCandidates = new Set(completedSteps);
|
|
803
|
+
if (ok) completionCandidates.add(currentStep);else completionCandidates["delete"](currentStep);
|
|
804
|
+
nextCompleted = filterCompletedSteps(latest.current.steps, stepValidationRef.current, completionCandidates);
|
|
805
|
+
setCompletedSteps(nextCompleted);
|
|
616
806
|
// Emit 'completed' before invoking onComplete.
|
|
617
807
|
emitStepChange({
|
|
618
808
|
trigger: 'complete',
|
|
@@ -620,26 +810,24 @@ var Wizard = exports.Wizard = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
620
810
|
from: currentStep
|
|
621
811
|
});
|
|
622
812
|
if (onComplete) {
|
|
623
|
-
// setCompletedSteps above is async; include currentStep here so the
|
|
624
|
-
// payload reflects the just-completed final step.
|
|
625
|
-
nextCompleted = new Set(completedSteps);
|
|
626
|
-
nextCompleted.add(currentStep);
|
|
627
813
|
completedStepsList = Array.from(nextCompleted);
|
|
628
814
|
onComplete({
|
|
629
815
|
value: formValue,
|
|
630
|
-
completedSteps: completedStepsList
|
|
816
|
+
completedSteps: completedStepsList,
|
|
817
|
+
steps: resolveStepResults(latest.current.steps, stepValidationRef.current, nextCompleted)
|
|
631
818
|
});
|
|
632
819
|
}
|
|
633
820
|
if (sendAnalytics) sendAnalytics({
|
|
634
821
|
type: 'wizardComplete',
|
|
635
822
|
element: 'Wizard'
|
|
636
823
|
});
|
|
637
|
-
case
|
|
638
|
-
return
|
|
824
|
+
case 5:
|
|
825
|
+
return _context5.a(2);
|
|
639
826
|
}
|
|
640
|
-
},
|
|
641
|
-
})), [sendAnalytics, completedSteps, currentStep, emitStepChange, formValue,
|
|
827
|
+
}, _callee5);
|
|
828
|
+
})), [sendAnalytics, completedSteps, currentStep, currentStepObj, emitStepChange, formValue, onComplete, runValidation]);
|
|
642
829
|
var cancel = (0, _react.useCallback)(function () {
|
|
830
|
+
navigationVersion.current += 1;
|
|
643
831
|
emitStepChange({
|
|
644
832
|
trigger: 'cancel',
|
|
645
833
|
phase: 'cancelled',
|
|
@@ -687,17 +875,24 @@ var Wizard = exports.Wizard = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
687
875
|
if (typeof window !== 'undefined') safeScrollTo(window);
|
|
688
876
|
}, [currentStep, scrollToTop, wizardRef]);
|
|
689
877
|
var canGoNext = !(currentStepObj != null && currentStepObj.disabled) && !isValidating;
|
|
690
|
-
var isBlocked =
|
|
878
|
+
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;
|
|
691
879
|
var isCompleted = completedSteps.has(currentStep);
|
|
692
880
|
var contextValue = (0, _react.useMemo)(function () {
|
|
693
881
|
return {
|
|
694
882
|
steps: steps,
|
|
695
883
|
flatSteps: flatSteps,
|
|
884
|
+
clickableSteps: clickableSteps,
|
|
885
|
+
closable: closable,
|
|
696
886
|
currentStep: currentStep,
|
|
697
887
|
currentStepIndex: currentStepIndex,
|
|
698
888
|
currentStepObj: currentStepObj,
|
|
699
889
|
totalSteps: totalSteps,
|
|
700
890
|
stepStates: stepStates,
|
|
891
|
+
stepErrorMessages: stepErrorMessages,
|
|
892
|
+
stepValidation: stepValidation,
|
|
893
|
+
updateValidation: updateValidation,
|
|
894
|
+
registerForm: registerForm,
|
|
895
|
+
form: form,
|
|
701
896
|
formValue: formValue,
|
|
702
897
|
setFormValue: setFormValue,
|
|
703
898
|
validationError: validationError,
|
|
@@ -719,7 +914,7 @@ var Wizard = exports.Wizard = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
719
914
|
// (same pattern as `hasCancelHandler`).
|
|
720
915
|
messages: messages
|
|
721
916
|
};
|
|
722
|
-
}, [steps, flatSteps, currentStep, currentStepIndex, currentStepObj, totalSteps, stepStates, formValue, setFormValue, validationError, isValidating, isBlocked, isCompleted, canGoNext, next, previous, goTo, skip, complete, cancel, hasCancelHandler, effectiveShowProgress, renderStep, messages]);
|
|
917
|
+
}, [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]);
|
|
723
918
|
if (!isOpen) return null;
|
|
724
919
|
|
|
725
920
|
// Custom composition: consumers supply their own tree via `children`.
|
|
@@ -749,7 +944,9 @@ var Wizard = exports.Wizard = /*#__PURE__*/(0, _react.forwardRef)(function (_ref
|
|
|
749
944
|
flex: "grow",
|
|
750
945
|
fill: "horizontal",
|
|
751
946
|
direction: effectiveShowProgress === 'vertical' ? 'row' : 'column'
|
|
752
|
-
},
|
|
947
|
+
}, /*#__PURE__*/_react["default"].createElement(StyledWizardProgress, {
|
|
948
|
+
$hidden: !effectiveShowProgress || responsiveSize === 'small' || responsiveSize === 'xsmall'
|
|
949
|
+
}, /*#__PURE__*/_react["default"].createElement(_WizardProgress.WizardProgress, null)), /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
753
950
|
flex: "grow"
|
|
754
951
|
}, /*#__PURE__*/_react["default"].createElement(_WizardStepHeader.WizardStepHeader, null), /*#__PURE__*/_react["default"].createElement(_WizardContent.WizardContent, null)))), footerNode));
|
|
755
952
|
}
|