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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readFileSync,writeFileSync,appendFileSync}from"fs";const NOTES_PATH="RELEASE_NOTES_DRAFT.md",CHECKLIST_PATH="RELEASE_CHECKLIST.md",PACKAGE_PATH="package.json",CHANGELOG_PATH="CHANGELOG.md";function suggestBump(e){const t=e.match(/── Suggested semver bump ─+\n\n(MAJOR|MINOR|PATCH)\b/);if(!t)throw new Error("Could not find a suggested semver bump in RELEASE_CHECKLIST.md");return t[1].toLowerCase()}function bumpVersion(e,t){const[n,s,r]=e.split(".").map(Number);return"major"===t?`${n+1}.0.0`:"minor"===t?`${n}.${s+1}.0`:`${n}.${s}.${r+1}`}function setGithubOutput(e,t){const n=process.env.GITHUB_OUTPUT;n&&appendFileSync(n,`${e}=${t}\n`)}const notes=readFileSync(NOTES_PATH,"utf8").trim(),checklist=readFileSync(CHECKLIST_PATH,"utf8"),bump=process.env.BUMP_OVERRIDE;if("true"!==process.env.CHECKLIST_REVIEWED)throw new Error("Review the release checklist before creating a release PR.");if(!["patch","minor","major"].includes(bump))throw new Error("Explicitly select patch, minor, or major after review.");const suggested=suggestBump(checklist);if(!notes||!/^[-*] /m.test(notes))throw new Error("Release notes must contain reviewed change entries.");const pkg=JSON.parse(readFileSync(PACKAGE_PATH,"utf8"));if(!/^\d+\.\d+\.\d+$/.test(pkg.version))throw new Error("Expected a stable package version in package.json.");const nextVersion=bumpVersion(pkg.version,bump);pkg.version=nextVersion,writeFileSync(PACKAGE_PATH,`${JSON.stringify(pkg,null,2)}\n`,"utf8");const changelog=readFileSync("CHANGELOG.md","utf8"),entry=`# ${nextVersion}\n\n${notes}\n\n`;writeFileSync("CHANGELOG.md",entry+changelog,"utf8"),console.log(`Checklist suggestion: ${suggested}; selected: ${bump} -> v${nextVersion}`),setGithubOutput("version",nextVersion),setGithubOutput("bump",bump);const template=readFileSync(".github/PULL_REQUEST_TEMPLATE.md","utf8"),answers={"What does this PR do?":`Prepares Grommet v${nextVersion} with a maintainer-selected ${bump} bump.\n\nCopies the reviewed release-note draft unchanged into CHANGELOG.md.`,"Where should the reviewer start?":`Review package.json and the new CHANGELOG.md section.\n\nChecklist suggestion: **${suggested}**; selected bump: **${bump}**.\n\n- Patch: backwards-compatible bug fixes.\n- Minor: new components, props, or compatible functionality.\n- Major: incompatible public API or behavior changes.\n\nConfirm the version, PR title/branch, and changelog heading agree.`,"What testing has been done on this PR?":"The release checklist completed for the reviewed commit. Its findings were acknowledged before creating this PR. This is not a test coverage guarantee.\n\nReview PR CI results separately; no build or browser QA is claimed here.","How should this be manually tested?":"- [ ] Confirm version scope and release-note wording.\n- [ ] Resolve or explicitly accept missing-test findings.\n- [ ] Complete the listed component QA in Chrome, Firefox, and Safari.\n- [ ] Wait for required CI checks before merging.","Do Jest tests follow these best practices?":"Not applicable to this version/changelog PR; template checklist follows.","Any background context you want to provide?":`Merging triggers tag creation after merge-commit CI, then package build and npm staging. Public npm publication requires manual approval.\n\n<details><summary>Reviewed release checklist</summary>\n\n\`\`\`text\n${checklist.trim()}\n\`\`\`\n\n</details>`,"What are the relevant issues?":"See the linked PRs in the release notes.","Screenshots (if appropriate)":"Not applicable.","Do the grommet docs need to be updated?":"Review documentation requirements for the included changes.","Should this PR be mentioned in the release notes?":"No. This PR only prepares the version and changelog.","Is this change backwards compatible or is it a breaking change?":"major"===bump?"Major release selected; review the documented breaking changes.":"Backwards-compatible release selected; confirm during final review."},body=template.replace(/^#### (.+)$/gm,(e,t)=>answers[t]?`${e}\n\n${answers[t]}`:e);writeFileSync("PR_BODY.md",body,"utf8");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync,readdirSync,readFileSync,statSync,writeFileSync}from"fs";import{join}from"path";const OWNER="grommet",REPO="grommet",API=`https://api.github.com/repos/${OWNER}/${REPO}`,GH_PR_URL=`https://github.com/${OWNER}/${REPO}/pull`,GH_RELEASE_URL=`https://github.com/${OWNER}/${REPO}/releases/tag`,GH_COMPARE_URL=`https://github.com/${OWNER}/${REPO}/compare`,DEFAULT_CHANGELOG_FILE="CHANGELOG.md",PLACEHOLDER_VERSION="X.X.X",LABEL_SECTION_MAP=new Map([["DataTable","DataTable"],["DateInput","DateInput"],["DateTimeInput","DateTimeInput"],["TimeInput","TimeInput"],["FileInput","FileInput"],["Select","Select / SelectMultiple"],["SelectMultiple","Select / SelectMultiple"],["List","List"],["RadioButton","RadioButton / RadioButtonGroup"],["RadioButtonGroup","RadioButton / RadioButtonGroup"],["RangeSelector","RangeSelector"],["TypeScript","TypeScript"],["typescript","TypeScript"],["Beta","Beta"],["beta","Beta"],["Calendar","Calendar"],["TextInput","TextInput"],["MaskedInput","MaskedInput"],["Notification","Notification"],["Layer","Layer"],["Button","Button"],["Form","Form"],["FormField","FormField"],["Stepper","Stepper"],["Wizard","Wizard"],["Tabs","Tabs"],["Pagination","Pagination"],["Menu","Menu"],["Anchor","Anchor"],["CheckBox","CheckBox / CheckBoxGroup"],["CheckBoxGroup","CheckBoxGroup / CheckBox"],["Data","Data"],["DataChart","Chart / DataChart"],["Chart","Chart / DataChart"],["DataFilter","DataFilter"]]),SECTION_ORDER=["General","Anchor","Button","Calendar","Chart / DataChart","CheckBox","Data","DataFilter","DataTable","DateInput","DateTimeInput","FileInput","Form","FormField","Layer","List","MaskedInput","Menu","Notification","Pagination","RadioButton / RadioButtonGroup","RangeSelector","Select / SelectMultiple","Stepper","Tabs","TextInput","TimeInput","TypeScript","Beta"],SKIP_LABELS=new Set(["skip-release-notes","no-release-notes","internal","dependencies","chore","ci","documentation"]),BETA_LABELS=new Set(["beta","Beta"]),DEFAULT_BETA_COMPONENT_SECTIONS=new Set(["DateTimeInput","Stepper","TimeInput","Wizard"]),MIN_COMPONENT_SECTION_SIZE=3,BETA_WARNING_PATTERN=/currently in beta[\s\S]*api is subject\s+to\s+change/i;function getSourceBetaComponentSections(){const e=join(process.cwd(),"src","js","components");if(!existsSync(e))return new Set;const t=new Set,n=readdirSync(e);for(const o of n){const n=join(e,o);if(!statSync(n).isDirectory())continue;const r=join(n,`${o}.js`);if(existsSync(r))try{const e=readFileSync(r,"utf8");BETA_WARNING_PATTERN.test(e)&&t.add(o)}catch{}}return t}const BETA_COMPONENT_SECTIONS=new Set([...Array.from(DEFAULT_BETA_COMPONENT_SECTIONS),...Array.from(getSourceBetaComponentSections())]);function parseArgs(){const e=process.argv.slice(2),t={from:null,to:null,format:(process.argv[1]||"").includes("announcement")?"announcement":"release-notes",output:null,changelog:null,version:null,token:process.env.GH_TOKEN||null};for(let n=0;n<e.length;n++){const o=e[n];if("--from"===o)t.from=e[++n];else if("--to"===o)t.to=e[++n];else if("--format"===o)t.format=e[++n];else if("--output"===o)t.output=e[++n];else if("--changelog"===o){const o=e[n+1];t.changelog=o&&!o.startsWith("--")?e[++n]:"CHANGELOG.md"}else"--no-changelog"===o?t.changelog=!1:"--version"===o?t.version=e[++n]:"--token"===o?t.token=e[++n]:o.startsWith("--")||t.from?o.startsWith("--")||t.to||(t.to=o):t.from=o}return t}function getRequestHeaders(e){return{...e?{Authorization:`Bearer ${e}`}:{},Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"}}async function ghGet(e,t){const n=await fetch(e,{headers:getRequestHeaders(t)});if(!n.ok){const t=await n.text();if(403===n.status&&t.includes("API rate limit exceeded"))throw new Error("GitHub API rate limit exceeded. Set GH_TOKEN or pass --token to generate release output.");throw new Error(`GitHub API ${n.status} at ${e}:\n${t}`)}return n.json()}async function resolveRef(e,t){if(!e||"HEAD"===e){const e=await ghGet(`${API}`,t),n=await ghGet(`${API}/branches/${e.default_branch}`,t);return{sha:n.commit.sha,date:n.commit.commit.committer.date}}try{const n=await ghGet(`${API}/git/refs/tags/${e}`,t);let{sha:o}=n.object;return"tag"===n.object.type&&(o=(await ghGet(`${API}/git/tags/${o}`,t)).object.sha),{sha:o,date:(await ghGet(`${API}/commits/${o}`,t)).commit.committer.date}}catch{const n=await ghGet(`${API}/commits/${e}`,t);return{sha:n.sha,date:n.commit.committer.date}}}async function getLatestTag(e){const t=await ghGet(`${API}/tags?per_page=5`,e);if(!t.length)throw new Error("No tags found in repository.");return t[0].name}function includeByBody(e){if(!e)return!0;const t=e.toLowerCase().indexOf("should this pr be mentioned in the release notes?");if(-1===t)return!0;const n=e.slice(t+49),o=n.indexOf("####"),r=(-1===o?n:n.slice(0,o)).trim().split("\n")[0].trim().toLowerCase().replace(/[.!?]+$/,"");return!r||!new Set(["no","n","n/a","na","-","nope","false"]).has(r)}function shouldSkipByContent(e){const t=(e.title||"").toLowerCase(),n=(e.body||"").toLowerCase(),o=`${t}\n${n}`;return[/\bupdate\b.*\bdependenc(y|ies)\b/,/\bdependenc(y|ies)\b.*\bupdate\b/,/\bupdate styled components\b/,/\bbump\b.*\b(dependency|dependencies)\b/,/\bupgrade\b.*\b(dependency|dependencies|styled-components)\b/].some((e=>e.test(o)))?{skip:!0,reason:"dependency"}:[/\bchore\s*[:(]/,/^new chore\b/].some((e=>e.test(t)))?{skip:!0,reason:"chore"}:[/\bstorybook\b/,/\bchromatic\b/,/\bstories\b/].some((e=>e.test(t)))?{skip:!0,reason:"storybook"}:{skip:!1,reason:null}}function getSection(e){const t=e.labels.map((e=>e.name));if(t.some((e=>BETA_LABELS.has(e))))return"Beta";if(t.some((e=>"TypeScript"===e||"typescript"===e)))return"TypeScript";for(const e of t){const t=LABEL_SECTION_MAP.get(e);if(t)return t}const n=e.title.match(/^[A-Za-z]+\(([^)]+)\):/);if(n){const e=n[1].trim();for(const[t,n]of LABEL_SECTION_MAP)if(t.toLowerCase()===e.toLowerCase())return n}const o=e.title.toLowerCase();for(const[e,t]of LABEL_SECTION_MAP){const n=e.toLowerCase();if(o.startsWith(`${n} `)||o.startsWith(`${n}:`)||o.startsWith(`${n}-`)||o.startsWith(`${n},`))return t}return"General"}function formatEntry(e){return`- ${formatReleaseSentence(e).replace(/[.!?]+$/,"")}. [#${e.number}](${GH_PR_URL}/${e.number})`}function lowerFirst(e){return e?e.charAt(0).toLowerCase()+e.slice(1):e}function formatReleaseSentence(e){const t=e.title.trim().replace(/[.!?]+$/,""),n=t.match(/^fix\(([^)]+)\):\s*(.+)$/i);if(n){const[,e,t]=n;return`Fixed ${e} ${lowerFirst(t)}`}const o=t.match(/^feat\(([^)]+)\):\s*(.+)$/i);if(o){const[,e,t]=o;return`Added ${e} ${lowerFirst(t)}`}const r=t.match(/^(enhance|enhanced|improve|improved)\(([^)]+)\):\s*(.+)$/i);if(r){const[,,e,t]=r;return`Enhanced ${e} ${lowerFirst(t)}`}const s=t.match(/^([A-Za-z][A-Za-z0-9/\s-]*)\s*-\s*(fix|feat|add|improve|enhance)\s*(.+)$/i);if(s){const[,e,t,n]=s;return/fix/i.test(t)?`Fixed ${e.trim()} ${n.trim()}`:/feat|add/i.test(t)?`Added ${e.trim()} ${n.trim()}`:`Enhanced ${e.trim()} ${n.trim()}`}return/^fix\b/i.test(t)?`Fixed ${t.replace(/^fix\b[:\s-]*/i,"")}`:/^feat\b/i.test(t)?`Added ${t.replace(/^feat\b[:\s-]*/i,"")}`:/^(add|added)\b/i.test(t)?`Added ${t.replace(/^(add|added)\b[:\s-]*/i,"")}`:/^(improve|improved|enhance|enhanced)\b/i.test(t)?`Enhanced ${t.replace(/^(improve|improved|enhance|enhanced)\b[:\s-]*/i,"")}`:t.charAt(0).toUpperCase()+t.slice(1)}function formatTitlePhrase(e){const t=e.trim().replace(/[.!?]+$/,"");return t.charAt(0).toLowerCase()+t.slice(1)}function humanJoin(e){return 0===e.length?"":1===e.length?e[0]:2===e.length?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(", ")}, and ${e[e.length-1]}`}function unique(e){return e.filter(((t,n)=>t&&e.indexOf(t)===n))}function getAnnouncementHighlights(e){const t=[/^added\b/i,/^enhanced\b/i,/^improved\b/i];return e.filter((e=>t.some((t=>t.test(e.title))))).slice(0,2).map((e=>formatTitlePhrase(e.title)))}function getFixSummary(e){const t=unique(e.filter((e=>/^fixed\b/i.test(e.title))).map((e=>e.section)).filter((e=>e&&"General"!==e&&"Beta"!==e)));if(0===t.length)return null;const n=t.slice(0,5),o=t.length>5?", and more":"";return`There are also fixes across ${humanJoin(n)}${o}.`}function formatContributors(e){const t=unique(e.map((e=>e.user?.login)).filter((e=>e&&"app/dependabot"!==e)));return 0===t.length?null:`Thank you to everyone who contributed to this release ${humanJoin(t.map((e=>`<https://github.com/${e}|${e}>`)))}!`}function inferNextReleaseTag(e,t){if(t&&/^v\d+\.\d+\.\d+$/i.test(t))return t;const n=(e||"").match(/^v(\d+)\./i);return n?`v${n[1]}.x.x`:"v2.x.x"}function extractComponentName(e){const t=(e.title||"").trim(),n=t.match(/^[A-Za-z]+\(([^)]+)\):/);if(n)return n[1].trim();const o=t.match(/^([A-Za-z][A-Za-z0-9]+)/);return o?o[1].trim():null}function inferComponentFromText(e){const t=e.title||"";for(const[e,n]of LABEL_SECTION_MAP)if(new RegExp(`\\b${e}\\b`,"i").test(t))return n;return null}function resolveHighlightComponent(e){return e.section&&"General"!==e.section?e.section:extractComponentName(e)||inferComponentFromText(e)||e.section}function getFixComponents(e){const t=[];for(const n of e){const e=(n.title||"").toLowerCase();if(!/\bfix(e[ds])?\b/.test(e))continue;const o=resolveHighlightComponent(n);o&&"General"!==o&&"Beta"!==o&&(t.includes(o)||t.push(o))}return t}function getEnhancementComponents(e){const t=[];for(const n of e){const e=(n.title||"").toLowerCase();if(/\bfix(e[ds])?\b/.test(e))continue;const o=resolveHighlightComponent(n);o&&"General"!==o&&"Beta"!==o&&(t.includes(o)||t.push(o))}return t}function formatBetaDescription(e){const t=(e.title||"").trim().replace(/[.!?]+$/,"").toLowerCase(),n=extractComponentName(e)||"Component";return/feat\(|\badd\b/.test(t)?`${n} - allows you to guide users through multi-step forms.`:/fix/.test(t)?`${n} - includes important bug fixes.`:`${n} - includes beta updates.`}function getNewBetaComponentLines(e){const t=e.filter((e=>{const t=(e.title||"").toLowerCase();return!("Beta"!==e.section||!t.startsWith("feat(")&&(!t.startsWith("add")||!t.includes("component")))})),n=new Set,o=[];for(const e of t){const t=extractComponentName(e);t&&!n.has(t.toLowerCase())&&(n.add(t.toLowerCase()),o.push(`- **${t}** - allows you to guide users through multi-step forms.`))}return o}function normalizeSection(e){return BETA_COMPONENT_SECTIONS.has(e)?"Beta":e}function mentionsBetaComponent(e){const t=`${e.title||""}\n${e.body||""}`.toLowerCase();return Array.from(BETA_COMPONENT_SECTIONS).some((e=>t.includes(e.toLowerCase())))}function shouldForceIncludeAsBeta(e){return!!mentionsBetaComponent(e)||"Beta"===normalizeSection(getSection(e))}function buildReleaseSections(e){const t=new Map(SECTION_ORDER.map((e=>[e,[]]))),n=new Map;for(const t of e){const e=normalizeSection(t.section);n.set(e,(n.get(e)||0)+1)}for(const o of e){const e=normalizeSection(o.section);let r=e;!("General"===e||"Beta"===e||"TypeScript"===e)&&(n.get(e)||0)<3&&(r="General"),t.has(r)||t.set(r,[]),t.get(r).push(formatEntry(o))}return t}function buildSectionOrder(e){const t=new Set(SECTION_ORDER),n=Array.from(e.keys()).filter((e=>!t.has(e))).sort();return[...SECTION_ORDER.slice(0,-2),...n,...SECTION_ORDER.slice(-2)]}function formatReleaseNotes(e){const t=buildSectionOrder(e),n=[];for(const o of t){const t=e.get(o);if(!t||0===t.length)continue;const r="Beta"===o?"Beta - APIs are subject to change:":`${o}:`;n.push({heading:r,entries:t})}const o=[];if(1===n.length&&"General:"===n[0].heading)for(const e of n[0].entries)o.push(e);else for(const{heading:e,entries:t}of n){o.push(e),o.push("");for(const e of t)o.push(e);o.push("")}return o.join("\n").trim()}function normalizeVersionHeading(e){return String(e).trim().replace(/^v/i,"")}function updateChangelog(e,t,n){const o=`# ${normalizeVersionHeading(t)}`,r=`${o}\n\n${n}\n`,s=existsSync(e)?readFileSync(e,"utf8"):"",i=s.split("\n"),a=i.findIndex((e=>e.trim()===o));let c;if(-1===a)c=`${r}\n${s}`;else{let e=a+1;for(;e<i.length&&!/^# /.test(i[e]);)e+=1;const t=i.slice(0,a).join("\n");c=`${t&&!t.endsWith("\n")?`${t}\n`:t}${r}\n${i.slice(e).join("\n")}`}writeFileSync(e,c,"utf8"),console.error(`Changelog updated at ${e} under "${o}".`)}function describeHighlightGroup(e,t,n,o){return 0===e.length?null:1===e.length?`${o} ${t} to ${e[0]}`:`${n} to ${humanJoin(e)}`}function formatAnnouncement(e){const t=getFixComponents(e.prs),n=getEnhancementComponents(e.prs),o=getNewBetaComponentLines(e.prs),r=[describeHighlightGroup(t,"fix","fixes","a"),describeHighlightGroup(n,"enhancement","enhancements","an")].filter(Boolean),s=r.length>0?`This release included ${r.join(" as well as ")}. Check out the full <${e.releaseUrl}|release notes> for details.`:`Check out the full <${e.releaseUrl}|release notes> for details.`,i=[`Grommet ${e.releaseLabel} is released`,"",s];return o.length>0&&(i.push(""),i.push("**New BETA components** *(APIs are subject to change)*:"),i.push(""),i.push(...o)),i.join("\n").trim()}const args=parseArgs();(async()=>{let e=args.from;e||(e=await getLatestTag(args.token),console.error(`Auto-detected --from: ${e}`));const t=args.to||"HEAD";console.error(`Resolving refs: ${e} → ${t}`);const n=await resolveRef(e,args.token),o=await resolveRef(t,args.token);console.error(`Fetching commits between ${e} and ${t}...`);const r=await ghGet(`${API}/compare/${n.sha}...${o.sha}`,args.token);if(r.total_commits>r.commits.length)throw new Error(`Compare API returned only ${r.commits.length} of ${r.total_commits} commits. The release range is too large; please choose a smaller range or switch to a paginated strategy.`);const s=new Set;for(const e of r.commits){const t=e.commit.message.matchAll(/#(\d+)/g);for(const e of t)s.add(Number(e[1]))}0===s.size?console.error("No PR references found in commits. Output will be empty."):console.error(`Found ${s.size} PR reference(s) in commits.`);const i=Array.from(s),a=[],c=[];for(let e=0;e<i.length;e+=5){const t=i.slice(e,e+5),n=await Promise.all(t.map((e=>ghGet(`${API}/pulls/${e}`,args.token).then((e=>({pr:e}))).catch((t=>({error:t,number:e}))))));a.push(...n.filter((e=>e.pr)).map((e=>e.pr))),c.push(...n.filter((e=>e.error)).map((e=>e.error)))}if(0===a.length&&c.length>0)throw c[0];c.length>0&&console.error(`Warning: failed to fetch ${c.length} PR(s).`);const l=[];let u=0,m=0;for(const e of a){if(e.labels.map((e=>e.name)).some((e=>SKIP_LABELS.has(e)))){console.error(` skip [label] #${e.number}: ${e.title}`),m++;continue}const t=shouldForceIncludeAsBeta(e);if(!t&&!includeByBody(e.body)){console.error(` skip [body] #${e.number}: ${e.title}`),m++;continue}const n=shouldSkipByContent(e);if(n.skip){console.error(` skip [${n.reason}] #${e.number}: ${e.title}`),m++;continue}t&&!includeByBody(e.body)&&console.error(` include [beta-override] #${e.number}: ${e.title}`);const o=t?"Beta":getSection(e);console.error(` include [${o}] #${e.number}: ${e.title}`),l.push({...e,section:o}),u++}const p=buildReleaseSections(l);console.error(`\nSummary: ${u} included, ${m} skipped.\n`);const h=inferNextReleaseTag(e,t),d="HEAD"!==t&&/^v\d/.test(t)?t:h||`changes through ${t}`,f="HEAD"!==t&&/^v\d/.test(t)?`${GH_RELEASE_URL}/${t}`:`${GH_COMPARE_URL}/${e}...${o.sha}`,g="announcement"===args.format?formatAnnouncement({prs:l,releaseLabel:d,releaseUrl:f,sections:p}):formatReleaseNotes(p);args.output?(writeFileSync(args.output,`${g}\n`,"utf8"),console.error(`Release notes written to ${args.output}`)):process.stdout.write(`${g}\n`);const $=!1===args.changelog||"announcement"===args.format?null:args.changelog||(args.output?null:"CHANGELOG.md");$&&updateChangelog($,args.version||(/^v?\d+\.\d+\.\d+$/i.test(t)?t:"X.X.X"),g)})().catch((e=>{console.error(e.message||e),process.exit(1)}));
|
|
1
|
+
import{existsSync,readdirSync,readFileSync,statSync,writeFileSync}from"fs";import{join}from"path";import{formatReleaseSentence,getSkipReason,isTypeScriptChange}from"./release-notes-utils";const OWNER="grommet",REPO="grommet",API=`https://api.github.com/repos/${OWNER}/${REPO}`,GH_PR_URL=`https://github.com/${OWNER}/${REPO}/pull`,GH_RELEASE_URL=`https://github.com/${OWNER}/${REPO}/releases/tag`,GH_COMPARE_URL=`https://github.com/${OWNER}/${REPO}/compare`,DEFAULT_CHANGELOG_FILE="CHANGELOG.md",PLACEHOLDER_VERSION="X.X.X",LABEL_SECTION_MAP=new Map([["DataTable","DataTable"],["DateInput","DateInput"],["DateTimeInput","DateTimeInput"],["TimeInput","TimeInput"],["FileInput","FileInput"],["Select","Select / SelectMultiple"],["SelectMultiple","Select / SelectMultiple"],["List","List"],["RadioButton","RadioButton / RadioButtonGroup"],["RadioButtonGroup","RadioButton / RadioButtonGroup"],["RangeSelector","RangeSelector"],["TypeScript","TypeScript"],["typescript","TypeScript"],["Beta","Beta"],["beta","Beta"],["Calendar","Calendar"],["TextInput","TextInput"],["MaskedInput","MaskedInput"],["Notification","Notification"],["Layer","Layer"],["Button","Button"],["Form","Form"],["FormField","FormField"],["Stepper","Stepper"],["Wizard","Wizard"],["Tabs","Tabs"],["Pagination","Pagination"],["Menu","Menu"],["Anchor","Anchor"],["CheckBox","CheckBox / CheckBoxGroup"],["CheckBoxGroup","CheckBoxGroup / CheckBox"],["Data","Data"],["DataChart","Chart / DataChart"],["Chart","Chart / DataChart"],["DataFilter","DataFilter"]]),SECTION_ORDER=["General","Anchor","Button","Calendar","Chart / DataChart","CheckBox","Data","DataFilter","DataTable","DateInput","DateTimeInput","FileInput","Form","FormField","Layer","List","MaskedInput","Menu","Notification","Pagination","RadioButton / RadioButtonGroup","RangeSelector","Select / SelectMultiple","Stepper","Tabs","TextInput","TimeInput","TypeScript","Beta"],BETA_LABELS=new Set(["beta","Beta"]),DEFAULT_BETA_COMPONENT_SECTIONS=new Set(["DateTimeInput","Stepper","TimeInput","Wizard"]),MIN_COMPONENT_SECTION_SIZE=3,BETA_WARNING_PATTERN=/currently in beta[\s\S]*api is subject\s+to\s+change/i;function getSourceBetaComponentSections(){const e=join(process.cwd(),"src","js","components");if(!existsSync(e))return new Set;const t=new Set,n=readdirSync(e);for(const o of n){const n=join(e,o);if(!statSync(n).isDirectory())continue;const r=join(n,`${o}.js`);if(existsSync(r))try{const e=readFileSync(r,"utf8");BETA_WARNING_PATTERN.test(e)&&t.add(o)}catch{}}return t}const BETA_COMPONENT_SECTIONS=new Set([...Array.from(DEFAULT_BETA_COMPONENT_SECTIONS),...Array.from(getSourceBetaComponentSections())]);function parseArgs(){const e=process.argv.slice(2),t={from:null,to:null,format:(process.argv[1]||"").includes("announcement")?"announcement":"release-notes",output:null,changelog:null,version:null,token:process.env.GH_TOKEN||null};for(let n=0;n<e.length;n++){const o=e[n];if("--from"===o)t.from=e[++n];else if("--to"===o)t.to=e[++n];else if("--format"===o)t.format=e[++n];else if("--output"===o)t.output=e[++n];else if("--changelog"===o){const o=e[n+1];t.changelog=o&&!o.startsWith("--")?e[++n]:"CHANGELOG.md"}else"--no-changelog"===o?t.changelog=!1:"--version"===o?t.version=e[++n]:"--token"===o?t.token=e[++n]:o.startsWith("--")||t.from?o.startsWith("--")||t.to||(t.to=o):t.from=o}return t}function getRequestHeaders(e){return{...e?{Authorization:`Bearer ${e}`}:{},Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"}}async function ghGet(e,t){const n=await fetch(e,{headers:getRequestHeaders(t)});if(!n.ok){const t=await n.text();if(403===n.status&&t.includes("API rate limit exceeded"))throw new Error("GitHub API rate limit exceeded. Set GH_TOKEN or pass --token to generate release output.");throw new Error(`GitHub API ${n.status} at ${e}:\n${t}`)}return n.json()}async function resolveRef(e,t){if(!e||"HEAD"===e){const e=await ghGet(`${API}`,t),n=await ghGet(`${API}/branches/${e.default_branch}`,t);return{sha:n.commit.sha,date:n.commit.commit.committer.date}}try{const n=await ghGet(`${API}/git/refs/tags/${e}`,t);let{sha:o}=n.object;return"tag"===n.object.type&&(o=(await ghGet(`${API}/git/tags/${o}`,t)).object.sha),{sha:o,date:(await ghGet(`${API}/commits/${o}`,t)).commit.committer.date}}catch{const n=await ghGet(`${API}/commits/${e}`,t);return{sha:n.sha,date:n.commit.committer.date}}}async function getLatestTag(e){const t=await ghGet(`${API}/tags?per_page=5`,e);if(!t.length)throw new Error("No tags found in repository.");return t[0].name}function getSection(e){const t=e.labels.map(e=>e.name);if(isTypeScriptChange(e))return"TypeScript";if(t.some(e=>BETA_LABELS.has(e)))return"Beta";for(const e of t){const t=LABEL_SECTION_MAP.get(e);if(t)return t}const n=e.title.match(/^[A-Za-z]+\(([^)]+)\):/);if(n){const e=n[1].trim();for(const[t,n]of LABEL_SECTION_MAP)if(t.toLowerCase()===e.toLowerCase())return n}const o=e.title.toLowerCase();for(const[e,t]of LABEL_SECTION_MAP){const n=e.toLowerCase();if(o.startsWith(`${n} `)||o.startsWith(`${n}:`)||o.startsWith(`${n}-`)||o.startsWith(`${n},`))return t}return"General"}function formatEntry(e){return`- ${formatReleaseSentence(e).replace(/[.!?]+$/,"")}. ([#${e.number}](${GH_PR_URL}/${e.number}))`}function formatTitlePhrase(e){const t=e.trim().replace(/[.!?]+$/,"");return t.charAt(0).toLowerCase()+t.slice(1)}function humanJoin(e){return 0===e.length?"":1===e.length?e[0]:2===e.length?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(", ")}, and ${e[e.length-1]}`}function unique(e){return e.filter((t,n)=>t&&e.indexOf(t)===n)}function getAnnouncementHighlights(e){const t=[/^added\b/i,/^enhanced\b/i,/^improved\b/i];return e.filter(e=>t.some(t=>t.test(e.title))).slice(0,2).map(e=>formatTitlePhrase(e.title))}function getFixSummary(e){const t=unique(e.filter(e=>/^fixed\b/i.test(e.title)).map(e=>e.section).filter(e=>e&&"General"!==e&&"Beta"!==e));if(0===t.length)return null;const n=t.slice(0,5),o=t.length>5?", and more":"";return`There are also fixes across ${humanJoin(n)}${o}.`}function formatContributors(e){const t=unique(e.map(e=>e.user?.login).filter(e=>e&&"app/dependabot"!==e));return 0===t.length?null:`Thank you to everyone who contributed to this release ${humanJoin(t.map(e=>`<https://github.com/${e}|${e}>`))}!`}function inferNextReleaseTag(e,t){if(t&&/^v\d+\.\d+\.\d+$/i.test(t))return t;const n=(e||"").match(/^v(\d+)\./i);return n?`v${n[1]}.x.x`:"v2.x.x"}function extractComponentName(e){const t=(e.title||"").trim(),n=t.match(/^[A-Za-z]+\(([^)]+)\):/);if(n)return n[1].trim();const o=t.match(/^([A-Za-z][A-Za-z0-9]+)/);return o?o[1].trim():null}function inferComponentFromText(e){const t=e.title||"";for(const[e,n]of LABEL_SECTION_MAP)if(new RegExp(`\\b${e}\\b`,"i").test(t))return n;return null}function resolveHighlightComponent(e){return e.section&&"General"!==e.section?e.section:extractComponentName(e)||inferComponentFromText(e)||e.section}function getFixComponents(e){const t=[];for(const n of e){const e=(n.title||"").toLowerCase();if(!/\bfix(e[ds])?\b/.test(e))continue;const o=resolveHighlightComponent(n);o&&"General"!==o&&"Beta"!==o&&(t.includes(o)||t.push(o))}return t}function getEnhancementComponents(e){const t=[];for(const n of e){const e=(n.title||"").toLowerCase();if(/\bfix(e[ds])?\b/.test(e))continue;const o=resolveHighlightComponent(n);o&&"General"!==o&&"Beta"!==o&&(t.includes(o)||t.push(o))}return t}function formatBetaDescription(e){const t=(e.title||"").trim().replace(/[.!?]+$/,"").toLowerCase(),n=extractComponentName(e)||"Component";return/feat\(|\badd\b/.test(t)?`${n} - allows you to guide users through multi-step forms.`:/fix/.test(t)?`${n} - includes important bug fixes.`:`${n} - includes beta updates.`}function getNewBetaComponentLines(e){const t=e.filter(e=>{const t=(e.title||"").toLowerCase();return!("Beta"!==e.section||!t.startsWith("feat(")&&(!t.startsWith("add")||!t.includes("component")))}),n=new Set,o=[];for(const e of t){const t=extractComponentName(e);t&&!n.has(t.toLowerCase())&&(n.add(t.toLowerCase()),o.push(`- **${t}** - allows you to guide users through multi-step forms.`))}return o}function normalizeSection(e){return BETA_COMPONENT_SECTIONS.has(e)?"Beta":e}function mentionsBetaComponent(e){const t=`${e.title||""}\n${e.body||""}`.toLowerCase();return Array.from(BETA_COMPONENT_SECTIONS).some(e=>t.includes(e.toLowerCase()))}function shouldForceIncludeAsBeta(e){return!isTypeScriptChange(e)&&(!!mentionsBetaComponent(e)||"Beta"===normalizeSection(getSection(e)))}function buildReleaseSections(e){const t=new Map(SECTION_ORDER.map(e=>[e,[]])),n=new Map;for(const t of e){const e=normalizeSection(t.section);n.set(e,(n.get(e)||0)+1)}for(const o of e){const e=normalizeSection(o.section);let r=e;!("General"===e||"Beta"===e||"TypeScript"===e)&&(n.get(e)||0)<3&&(r="General"),t.has(r)||t.set(r,[]),t.get(r).push(formatEntry(o))}return t}function buildSectionOrder(e){const t=new Set(SECTION_ORDER),n=Array.from(e.keys()).filter(e=>!t.has(e)).sort();return[...SECTION_ORDER.slice(0,-2),...n,...SECTION_ORDER.slice(-2)]}function formatReleaseNotes(e){const t=buildSectionOrder(e),n=[];for(const o of t){const t=e.get(o);if(!t||0===t.length)continue;const r="Beta"===o?"Beta - APIs are subject to change:":`${o}:`;n.push({heading:r,entries:t})}const o=[];if(1===n.length&&"General:"===n[0].heading)for(const e of n[0].entries)o.push(e);else for(const{heading:e,entries:t}of n){o.push(e),o.push("");for(const e of t)o.push(e);o.push("")}return o.join("\n").trim()}function normalizeVersionHeading(e){return String(e).trim().replace(/^v/i,"")}function updateChangelog(e,t,n){const o=`# ${normalizeVersionHeading(t)}`,r=`${o}\n\n${n}\n`,s=existsSync(e)?readFileSync(e,"utf8"):"",a=s.split("\n"),i=a.findIndex(e=>e.trim()===o);let c;if(-1===i)c=`${r}\n${s}`;else{let e=i+1;for(;e<a.length&&!/^# /.test(a[e]);)e+=1;const t=a.slice(0,i).join("\n");c=`${t&&!t.endsWith("\n")?`${t}\n`:t}${r}\n${a.slice(e).join("\n")}`}writeFileSync(e,c,"utf8"),console.error(`Changelog updated at ${e} under "${o}".`)}function describeHighlightGroup(e,t,n,o){return 0===e.length?null:1===e.length?`${o} ${t} to ${e[0]}`:`${n} to ${humanJoin(e)}`}function formatAnnouncement(e){const t=getFixComponents(e.prs),n=getEnhancementComponents(e.prs),o=getNewBetaComponentLines(e.prs),r=[describeHighlightGroup(t,"fix","fixes","a"),describeHighlightGroup(n,"enhancement","enhancements","an")].filter(Boolean),s=r.length>0?`This release included ${r.join(" as well as ")}. Check out the full <${e.releaseUrl}|release notes> for details.`:`Check out the full <${e.releaseUrl}|release notes> for details.`,a=[`Grommet ${e.releaseLabel} is released`,"",s];return o.length>0&&(a.push(""),a.push("**New BETA components** *(APIs are subject to change)*:"),a.push(""),a.push(...o)),a.join("\n").trim()}const args=parseArgs();(async()=>{let e=args.from;e||(e=await getLatestTag(args.token),console.error(`Auto-detected --from: ${e}`));const t=args.to||"HEAD";console.error(`Resolving refs: ${e} → ${t}`);const n=await resolveRef(e,args.token),o=await resolveRef(t,args.token);console.error(`Fetching commits between ${e} and ${t}...`);const r=await ghGet(`${API}/compare/${n.sha}...${o.sha}`,args.token);if(r.total_commits>r.commits.length)throw new Error(`Compare API returned only ${r.commits.length} of ${r.total_commits} commits. The release range is too large; please choose a smaller range or switch to a paginated strategy.`);const s=new Set;for(const e of r.commits){const t=e.commit.message.matchAll(/#(\d+)/g);for(const e of t)s.add(Number(e[1]))}0===s.size?console.error("No PR references found in commits. Output will be empty."):console.error(`Found ${s.size} PR reference(s) in commits.`);const a=Array.from(s),i=[],c=[];for(let e=0;e<a.length;e+=5){const t=a.slice(e,e+5),n=await Promise.all(t.map(e=>ghGet(`${API}/pulls/${e}`,args.token).then(e=>({pr:e})).catch(t=>({error:t,number:e}))));i.push(...n.filter(e=>e.pr).map(e=>e.pr)),c.push(...n.filter(e=>e.error).map(e=>e.error))}if(0===i.length&&c.length>0)throw c[0];c.length>0&&console.error(`Warning: failed to fetch ${c.length} PR(s).`);const l=[];let u=0,m=0;for(const e of i){const t=getSkipReason(e);if(t){console.error(` skip [${t}] #${e.number}: ${e.title}`),m++;continue}const n=shouldForceIncludeAsBeta(e)?"Beta":getSection(e);console.error(` include [${n}] #${e.number}: ${e.title}`),l.push({...e,section:n}),u++}const h=buildReleaseSections(l);console.error(`\nSummary: ${u} included, ${m} skipped.\n`);const p=inferNextReleaseTag(e,t),f="HEAD"!==t&&/^v\d/.test(t)?t:p||`changes through ${t}`,g="HEAD"!==t&&/^v\d/.test(t)?`${GH_RELEASE_URL}/${t}`:`${GH_COMPARE_URL}/${e}...${o.sha}`,d="announcement"===args.format?formatAnnouncement({prs:l,releaseLabel:f,releaseUrl:g,sections:h}):formatReleaseNotes(h);args.output?(writeFileSync(args.output,`${d}\n`,"utf8"),console.error(`Release notes written to ${args.output}`)):process.stdout.write(`${d}\n`);const $=!1===args.changelog||"announcement"===args.format?null:args.changelog||(args.output?null:"CHANGELOG.md");$&&updateChangelog($,args.version||(/^v?\d+\.\d+\.\d+$/i.test(t)?t:"X.X.X"),d)})().catch(e=>{console.error(e.message||e),process.exit(1)});
|
package/tools/license-header.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const fs=require("fs"),path=require("path"),{execFileSync}=require("child_process"),HEADER="// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP\n// SPDX-License-Identifier: Apache-2.0\n",ROOTS=["src","e2e","storybook","tools"],EXTENSIONS=new Set([".js",".jsx",".ts",".tsx",".mjs",".cjs"]),EXCLUDED_DIRS=new Set(["node_modules","dist","coverage",".git",".yarn","storybook-static","__snapshots__"]);function isIncluded(e){return!e.endsWith(".snap")&&EXTENSIONS.has(path.extname(e))}function collectStagedFiles(){return execFileSync("git",["diff","--cached","--name-only","--diff-filter=ACMR"],{encoding:"utf8"}).split("\n").map(
|
|
2
|
+
const fs=require("fs"),path=require("path"),{execFileSync}=require("child_process"),HEADER="// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP\n// SPDX-License-Identifier: Apache-2.0\n",ROOTS=["src","e2e","storybook","tools"],EXTENSIONS=new Set([".js",".jsx",".ts",".tsx",".mjs",".cjs"]),EXCLUDED_DIRS=new Set(["node_modules","dist","coverage",".git",".yarn","storybook-static","__snapshots__"]);function isIncluded(e){return!e.endsWith(".snap")&&EXTENSIONS.has(path.extname(e))}function collectStagedFiles(){return execFileSync("git",["diff","--cached","--name-only","--diff-filter=ACMR"],{encoding:"utf8"}).split("\n").map(e=>e.trim()).filter(Boolean).filter(e=>ROOTS.some(t=>e===t||e.startsWith(`${t}/`))).filter(e=>isIncluded(e)).filter(e=>fs.existsSync(e))}function collectFiles(e,t){if(!fs.existsSync(e))return;const s=fs.statSync(e);s.isDirectory()?fs.readdirSync(e,{withFileTypes:!0}).forEach(s=>{s.isDirectory()&&EXCLUDED_DIRS.has(s.name)||collectFiles(path.join(e,s.name),t)}):s.isFile()&&isIncluded(e)&&t.push(e)}function buildExpected(e){let t="",s=e;if(e.startsWith("#!")){const i=e.indexOf("\n");t=-1===i?`${e}\n`:e.slice(0,i+1),s=-1===i?"":e.slice(i+1)}const i=s.split("\n");let n=0;for(;n<i.length&&/^\/\/\s*SPDX-/i.test(i[n]);)n+=1;n>0&&""===i[n]?.trim()&&(n+=1);const c=i.slice(n),l=/^\s*(['"])use [\w-]+\1;?\s*$/.test(c[0]??"");return`${t}${HEADER}${l?"\n":""}${c.join("\n")}`}function main(){const e=process.argv.slice(2),t=e.includes("--check"),s=e.includes("--staged"),i=e.filter(e=>!e.startsWith("--"));let n;if(s)n=collectStagedFiles();else{const e=i.length>0?i:ROOTS;n=[],e.forEach(e=>collectFiles(e,n))}const c=[];if(n.forEach(e=>{const s=fs.readFileSync(e,"utf8"),i=buildExpected(s);i!==s&&(c.push(e),t||fs.writeFileSync(e,i))}),s&&!t&&c.length>0&&execFileSync("git",["add","--",...c]),t)return c.length>0&&(console.error(`License header check failed: ${c.length} file(s) missing or with an incorrect SPDX header.`),c.forEach(e=>console.error(` ${e}`)),console.error('\nRun "yarn license" to fix the headers.'),process.exit(1)),void console.log(`License header check passed (${n.length} file(s)).`);c.length>0?console.log(`Updated SPDX header in ${c.length} file(s).`):console.log(`All ${n.length} file(s) already compliant.`)}main();
|
package/tools/pack.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import path from"path";import del from"del";import fs from"fs";import cp from"child_process";import tarball from"tarball-extract";const packageJSON=path.resolve(__dirname,"../package.json"),packageJSONAsString=fs.readFileSync(packageJSON),json=JSON.parse(packageJSONAsString);json.dependencies&&(json.bundledDependencies=Object.keys(json.dependencies),fs.writeFileSync(packageJSON,JSON.stringify(json,null,2)));try{cp.exec("npm pack",
|
|
1
|
+
import path from"path";import del from"del";import fs from"fs";import cp from"child_process";import tarball from"tarball-extract";const packageJSON=path.resolve(__dirname,"../package.json"),packageJSONAsString=fs.readFileSync(packageJSON),json=JSON.parse(packageJSONAsString);json.dependencies&&(json.bundledDependencies=Object.keys(json.dependencies),fs.writeFileSync(packageJSON,JSON.stringify(json,null,2)));try{cp.exec("npm pack",e=>{if(e)throw e;const n={name:json.name,version:json.version,dependencies:{licenseNotFound:[]}},s=`${json.name}-${json.version}.tgz`;tarball.extractTarball(s,"./tmp",e=>{if(e)throw e;fs.renameSync(path.resolve(__dirname,`../${s}`),path.resolve(__dirname,`../${json.name}-${json.version}-src-with-dependecies.tgz`)),fs.readdirSync(path.resolve(__dirname,"../tmp/package/node_modules")).forEach(e=>{const s=path.resolve(__dirname,`../node_modules/${e}/package.json`);if(fs.existsSync(s)){const a=fs.readFileSync(s),r=JSON.parse(a);let i=r.license;!i&&r.licenses&&(i=r.licenses[0]),i?i.type?n.dependencies[e]=i.type:n.dependencies[e]=i:n.dependencies.licenseNotFound.push(e)}});const a=path.resolve(__dirname,`../${json.name}-${json.version}-licenses.json`);fs.writeFileSync(a,JSON.stringify(n,null,2)),fs.writeFileSync(packageJSON,`${JSON.stringify(JSON.parse(packageJSONAsString),null,2)}\n`),del.sync(["./tmp"])})})}catch(e){console.log(e),fs.writeFileSync(packageJSON,`${JSON.stringify(JSON.parse(packageJSONAsString),null,2)}\n`)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{execSync}from"child_process";const OWNER="grommet",REPO="grommet",API=`https://api.github.com/repos/${OWNER}/${REPO}`,GH_PR_URL=`https://github.com/${OWNER}/${REPO}/pull`,NON_CODE_LABELS=new Set(["dependencies","chore","ci","documentation"]);function parseArgs(){const e=process.argv.slice(2),t={from:null,to:null,token:process.env.GH_TOKEN||null};for(let o=0;o<e.length;o++){const n=e[o];"--from"===n?t.from=e[++o]:"--to"===n?t.to=e[++o]:"--token"===n?t.token=e[++o]:n.startsWith("--")||t.from?n.startsWith("--")||t.to||(t.to=n):t.from=n}return t}function getRequestHeaders(e){return{...e?{Authorization:`Bearer ${e}`}:{},Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"}}async function ghGet(e,t){const o=await fetch(e,{headers:getRequestHeaders(t)});if(!o.ok){const t=await o.text();if(403===o.status&&t.includes("API rate limit exceeded"))throw new Error("GitHub API rate limit exceeded. Set GH_TOKEN or pass --token.");throw new Error(`GitHub API ${o.status} at ${e}:\n${t}`)}return o.json()}async function resolveRef(e,t){if(!e||"HEAD"===e){const e=await ghGet(`${API}`,t),o=await ghGet(`${API}/branches/${e.default_branch}`,t);return{sha:o.commit.sha,date:o.commit.commit.committer.date}}try{const o=await ghGet(`${API}/git/refs/tags/${e}`,t);let{sha:n}=o.object;return"tag"===o.object.type&&(n=(await ghGet(`${API}/git/tags/${n}`,t)).object.sha),{sha:n,date:(await ghGet(`${API}/commits/${n}`,t)).commit.committer.date}}catch{const o=await ghGet(`${API}/commits/${e}`,t);return{sha:o.sha,date:o.commit.committer.date}}}async function getLatestTag(e){const t=await ghGet(`${API}/tags?per_page=5`,e);if(!t.length)throw new Error("No tags found in repository.");return t[0].name}async function getPrFiles(e,t){const o=[];let n=1;for(;;){const s=await ghGet(`${API}/pulls/${e}/files?per_page=100&page=${n}`,t);if(o.push(...s),s.length<100)break;n++}return o}const TEST_FILE_PATTERN=/(^|\/)__tests__\/|[-.]test\.[jt]sx?$/i,STORY_FILE_PATTERN=/\.stories\.[jt]sx?$|(^|\/)stories\//i,COMPONENT_FILE_PATTERN=/^src\/js\/components\/([^/]+)\//,NON_CODE_ONLY_PATTERN=/\.(md|snap)$|\.d\.ts$|^(package\.json|yarn\.lock)$/i,SWEEP_COMPONENT_THRESHOLD=8;function classifyPrFiles(e){const t=new Set;let o=!1,n=!1;for(const s of e){const{filename:e}=s;if(TEST_FILE_PATTERN.test(e)){o=!0;continue}if(STORY_FILE_PATTERN.test(e))continue;NON_CODE_ONLY_PATTERN.test(e)||(n=!0);const r=e.match(COMPONENT_FILE_PATTERN);r&&t.add(r[1])}return{touchedComponents:t,hasTestChange:o,hasCodeChange:n}}function isMarkedBreaking(e){if(!e)return!1;const t=e.toLowerCase().indexOf("is this change backwards compatible or is it a breaking change?");if(-1===t)return!1;const o=e.slice(t+63),n=o.indexOf("####"),s=(-1===n?o:o.slice(0,n)).trim().toLowerCase();return/breaking/.test(s)&&!/backwards compatible/.test(s)}function suggestBump(e){const t=e.filter(
|
|
1
|
+
import{execSync}from"child_process";import{getDescription}from"./release-notes-utils";const OWNER="grommet",REPO="grommet",API=`https://api.github.com/repos/${OWNER}/${REPO}`,GH_PR_URL=`https://github.com/${OWNER}/${REPO}/pull`,NON_CODE_LABELS=new Set(["dependencies","chore","ci","documentation"]);function parseArgs(){const e=process.argv.slice(2),t={from:null,to:null,token:process.env.GH_TOKEN||null};for(let o=0;o<e.length;o++){const n=e[o];"--from"===n?t.from=e[++o]:"--to"===n?t.to=e[++o]:"--token"===n?t.token=e[++o]:n.startsWith("--")||t.from?n.startsWith("--")||t.to||(t.to=n):t.from=n}return t}function getRequestHeaders(e){return{...e?{Authorization:`Bearer ${e}`}:{},Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"}}async function ghGet(e,t){const o=await fetch(e,{headers:getRequestHeaders(t)});if(!o.ok){const t=await o.text();if(403===o.status&&t.includes("API rate limit exceeded"))throw new Error("GitHub API rate limit exceeded. Set GH_TOKEN or pass --token.");throw new Error(`GitHub API ${o.status} at ${e}:\n${t}`)}return o.json()}async function resolveRef(e,t){if(!e||"HEAD"===e){const e=await ghGet(`${API}`,t),o=await ghGet(`${API}/branches/${e.default_branch}`,t);return{sha:o.commit.sha,date:o.commit.commit.committer.date}}try{const o=await ghGet(`${API}/git/refs/tags/${e}`,t);let{sha:n}=o.object;return"tag"===o.object.type&&(n=(await ghGet(`${API}/git/tags/${n}`,t)).object.sha),{sha:n,date:(await ghGet(`${API}/commits/${n}`,t)).commit.committer.date}}catch{const o=await ghGet(`${API}/commits/${e}`,t);return{sha:o.sha,date:o.commit.committer.date}}}async function getLatestTag(e){const t=await ghGet(`${API}/tags?per_page=5`,e);if(!t.length)throw new Error("No tags found in repository.");return t[0].name}async function getPrFiles(e,t){const o=[];let n=1;for(;;){const s=await ghGet(`${API}/pulls/${e}/files?per_page=100&page=${n}`,t);if(o.push(...s),s.length<100)break;n++}return o}const TEST_FILE_PATTERN=/(^|\/)__tests__\/|[-.]test\.[jt]sx?$/i,STORY_FILE_PATTERN=/\.stories\.[jt]sx?$|(^|\/)stories\//i,COMPONENT_FILE_PATTERN=/^src\/js\/components\/([^/]+)\//,NON_CODE_ONLY_PATTERN=/\.(md|snap)$|\.d\.ts$|^(package\.json|yarn\.lock)$/i,SWEEP_COMPONENT_THRESHOLD=8;function classifyPrFiles(e){const t=new Set;let o=!1,n=!1;for(const s of e){const{filename:e}=s;if(TEST_FILE_PATTERN.test(e)){o=!0;continue}if(STORY_FILE_PATTERN.test(e))continue;NON_CODE_ONLY_PATTERN.test(e)||(n=!0);const r=e.match(COMPONENT_FILE_PATTERN);r&&t.add(r[1])}return{touchedComponents:t,hasTestChange:o,hasCodeChange:n}}function isMarkedBreaking(e){if(!e)return!1;const t=e.toLowerCase().indexOf("is this change backwards compatible or is it a breaking change?");if(-1===t)return!1;const o=e.slice(t+63),n=o.indexOf("####"),s=(-1===n?o:o.slice(0,n)).trim().toLowerCase();return/breaking/.test(s)&&!/backwards compatible/.test(s)}function suggestBump(e){const t=e.filter(e=>e.labels.some(e=>/^(major|breaking)/i.test(e.name))||isMarkedBreaking(e.body));if(t.length>0)return{level:"MAJOR",reason:"a breaking-change label or note was found on:",prs:t};const o=e.filter(e=>e.labels.some(e=>/^(minor|feature|new component)/i.test(e.name))||/^feat(\(|:)/i.test(e.title||"")||/\bnew component\b|\badd(?:ed|s)?\b.*\b(?:props?|support|components?|options?|capabilit(?:y|ies)|features?|theme)\b/i.test(e.title||"")||/\b(?:adds?|introduces?)\b.*\b(?:props?|support|components?|options?|capabilit(?:y|ies)|features?|theme)\b/i.test(getDescription(e.body)));return o.length>0?{level:"MINOR",reason:"new, notable, backwards-compatible features found on:",prs:o}:{level:"PATCH",reason:"only fixes/minor enhancements detected (verify manually).",prs:[]}}function findDesignerCandidates(e){return e.filter(e=>/new component/i.test(e.title)||/^feat(\(|:)/i.test(e.title)||e.labels.some(e=>/^(new component|feature)$/i.test(e.name)))}function checkGitStatus(){const e=[];try{const t=execSync("git rev-parse --abbrev-ref HEAD").toString().trim();"master"!==t&&e.push(`Not on master (currently on "${t}").`),execSync("git status --porcelain").toString().trim()&&e.push("Working tree has local/uncommitted changes."),execSync("git fetch origin master --quiet");execSync("git rev-parse master").toString().trim()!==execSync("git rev-parse origin/master").toString().trim()&&e.push("Local master is not in sync with origin/master (run `git pull`).")}catch(t){e.push(`Unable to fully verify git state: ${t.message}`)}return e}const args=parseArgs();(async()=>{console.log("── Git sanity check ──────────────────────────────────────\n");const e=checkGitStatus();0===e.length?console.log("OK: on master, clean tree, in sync with origin.\n"):(e.forEach(e=>console.log(`WARNING: ${e}`)),console.log(""));let t=args.from;t||(t=await getLatestTag(args.token),console.log(`Auto-detected --from: ${t}`));const o=args.to||"HEAD";console.log(`Comparing ${t} → ${o}\n`);const n=await resolveRef(t,args.token),s=await resolveRef(o,args.token),r=await ghGet(`${API}/compare/${n.sha}...${s.sha}`,args.token);if(r.total_commits>r.commits.length)throw new Error(`Compare API returned only ${r.commits.length} of ${r.total_commits} commits. Choose a smaller range.`);const a=new Set;for(const e of r.commits){const t=e.commit.message.split("\n")[0],o=t.match(/\(#(\d+)\)$/)||t.match(/^Merge pull request #(\d+)\b/);o&&a.add(Number(o[1]))}if(0===a.size)return void console.log("No PR references found in commits between these refs.");const i=Array.from(a),c=[];for(let e=0;e<i.length;e+=5){const t=i.slice(e,e+5),o=await Promise.all(t.map(e=>ghGet(`${API}/pulls/${e}`,args.token)));c.push(...o.filter(Boolean))}const l=c.filter(e=>!e.labels.some(e=>NON_CODE_LABELS.has(e.name))),m=new Map;for(let e=0;e<l.length;e+=5){const t=l.slice(e,e+5);(await Promise.all(t.map(e=>getPrFiles(e.number,args.token).then(t=>({number:e.number,files:t}))))).forEach(({number:e,files:t})=>m.set(e,t))}const g=new Set,u=[],h=[];for(const e of l){const t=m.get(e.number)||[],{touchedComponents:o,hasTestChange:n,hasCodeChange:s}=classifyPrFiles(t);o.size>8?h.push({pr:e,count:o.size}):o.forEach(e=>g.add(e)),s&&!n&&u.push(e)}console.log("── Components touched (manually verify in Storybook) ────\n"),0===g.size?console.log("No component source changes found."):Array.from(g).sort().forEach(e=>console.log(`[ ] ${e}`)),console.log("\nInteract with each above in Storybook across Firefox, Safari, and Chrome.\n"),console.log("── Bulk/sweep PRs (spot-check only) ──────────────────────\n"),0===h.length?console.log("None found."):(h.forEach(({pr:e,count:t})=>console.log(`[ ] #${e.number} ${e.title} — touched ${t} components (${GH_PR_URL}/${e.number})`)),console.log("\nThese touch many components at once (likely a codemod/lint/formatting pass) and were excluded from the per-component list above. Spot-check a couple of affected components instead of testing all of them individually.")),console.log(""),console.log("── PRs missing jest test changes ─────────────────────────\n"),0===u.length?console.log("None found — every code PR touched a test file."):u.forEach(e=>console.log(`[ ] #${e.number} ${e.title} (${GH_PR_URL}/${e.number})`)),console.log(""),console.log("── Suggested semver bump ──────────────────────────────────\n");const f=suggestBump(l);console.log(`${f.level} — ${f.reason}`),f.prs.forEach(e=>console.log(` #${e.number} ${e.title} (${GH_PR_URL}/${e.number})`)),console.log(""),console.log("── grommet-designer update candidates ────────────────────\n");const p=findDesignerCandidates(l);0===p.length?console.log("None found."):p.forEach(e=>console.log(`[ ] #${e.number} ${e.title} (${GH_PR_URL}/${e.number})`)),console.log("")})().catch(e=>{console.error(e.message),process.exitCode=1});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const EXCLUDED_LABELS=new Map([["dependencies","dependency"],["dependency","dependency"],["storybook","storybook"],["chromatic","storybook"],["ci","automation"],["ci/cd","automation"],["automation","automation"],["release automation","automation"]]);export function getDescription(e){let t,s=e||"";do{t=s,s=s.replace(/<!--[\s\S]*?-->/g,"")}while(s!==t);s=s.replace(/\r\n/g,"\n").trim();const i=s.split(/^#{1,6}\s+(.+?)\s*#*\s*$/m);let o=i[0];for(let e=1;e<i.length;e+=2)if(/^(what does this pr do\??|summary|description)\s*$/i.test(i[e])){o=i[e+1];break}return o.replace(/```[\s\S]*?```/g,"").replace(/!\[[^\]]*\]\([^)]*\)/g,"").split("\n").filter(e=>!/^\s*[-*]\s+\[[ x]\]/i.test(e)).map(e=>e.replace(/^\s*(?:[-*+]\s+|\d+\.\s+)/,"").trim()).filter(Boolean).join(" ").trim()}export function isTypeScriptChange(e){if((e.labels||[]).some(e=>/^typescript$/i.test(e.name)))return!0;const t=e.title||"";return/\b(?:typescript|type declarations?|type definitions?|type errors?|typings)\b|\b[\w-]+\.d\.ts\b/i.test(t)||/\b(?:add(?:ed)?|fix(?:ed)?|update(?:d)?)\b.*\btypes\b/i.test(t)}export function formatReleaseSentence(e){let t=(getDescription(e.body)||e.title||"").trim().replace(/[.!?]+$/,"");t=t.replace(/^(fix|feat|add|enhance|improve)\(([^)]+)\):\s*(.+)$/i,"$1 $2 $3"),t=t.replace(/^\[(?:fix|feat|enhancement)\]\s*/i,"").replace(/^this (?:pr|pull request)\s+/i,"").replace(/^([A-Z][A-Za-z0-9]*)\s*[:-]\s*(fix(?:es|ed)?|add(?:s|ed)?|enhance(?:s|d)?|improve(?:s|d)?)\s+/i,"$2 $1 ");const s=[["Fixed",/^(?:fix(?:es|ed)?|correct(?:s|ed)?|resolv(?:e|es|ed)|prevent(?:s|ed)?)\b[:\s-]*/i],["Added",/^(?:add(?:s|ed)?|feat|introduc(?:e|es|ed))\b[:\s-]*/i],["Enhanced",/^(?:enhance(?:s|d)?|improv(?:e|es|ed)|updat(?:e|es|ed)|refactor(?:s|ed)?|simplif(?:y|ies|ied)|remove(?:s|d)?)\b[:\s-]*/i]].find(([,e])=>e.test(t));if(s)return/^remove(?:s|d)?\b/i.test(t)?`Enhanced implementation by removing ${t.replace(s[1],"")}`:`${s[0]} ${t.replace(s[1],"")}`;const i=e.title||"";let o="Enhanced";return/\bfix(?:es|ed)?\b|\bbug\b/i.test(i)?o="Fixed":/\b(?:feat|add(?:ed)?|introduc(?:e|es|ed))\b/i.test(i)&&(o="Added"),`${o} ${t}`}export function getSkipReason(e){const t=e.user||{};if("Bot"===t.type||/\[bot\]$/i.test(t.login||"")||/^app\//i.test(t.login||""))return"bot";const s=(e.labels||[]).map(e=>e.name.toLowerCase()).find(e=>EXCLUDED_LABELS.has(e));if(s)return EXCLUDED_LABELS.get(s);const i=[e.title||"",getDescription(e.body)],o=[/\b(?:update|upgrade|bump)\b.*\b(?:dependenc(?:y|ies)|styled[- ]components)\b/i,/\bdependenc(?:y|ies)\b.*\b(?:update|upgrade|bump)\b/i,/^(?:chore(?:\([^)]*\))?:\s*)?bump\s+\S+\s+from\s+\S+\s+to\s+/i,/^(?:build|chore)\(deps(?:-dev)?\):/i,/^(?:update|upgrade|bump)\s+\S+\s+(?:to\s+)?(?:v|\^|~)?\d+\.\d+/i];if(i.some(e=>o.some(t=>t.test(e))))return"dependency";if(/\b(?:storybook|stories|chromatic)\b/i.test(e.title||"")||/^(?:(?:fix|feat|chore|docs|build)\((?:storybook|stories|chromatic)\):|(?:storybook|stories|chromatic)\b|(?:fix(?:ed|es)?|update[sd]?|improve[sd]?|enhance[sd]?|add(?:ed|s)?|upgrade[sd]?)\s+(?:the\s+)?(?:storybook|stories|chromatic)\b)/i.test(i[1]))return"storybook";const r=[/^(?:ci(?:\([^)]*\))?:|(?:build|chore|fix|feat)\((?:ci|release|automation|github-actions)\):)/i,/\b(?:ci|continuous integration|github actions?|release automation|release workflow|release pipeline|automated releases?)\b/i,/^(?:automate|automating)\b.*\brelease\b/i,/^release\s+v?\d+\.\d+\.\d+\b/i];return i.some(e=>r.some(t=>t.test(e)))?"automation":null}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Release preparation and review
|
|
2
|
+
|
|
3
|
+
The **Draft release version PR** workflow has two phases. Neither phase tags,
|
|
4
|
+
stages, or publishes a package.
|
|
5
|
+
|
|
6
|
+
## 1. Prepare a review candidate
|
|
7
|
+
|
|
8
|
+
Run the workflow from `master`, leaving `reviewed_run_id` empty and the version
|
|
9
|
+
choice set to `review`.
|
|
10
|
+
|
|
11
|
+
The workflow resolves the release range to commit SHAs, runs
|
|
12
|
+
`yarn release-checklist` before generating drafts, and uploads a
|
|
13
|
+
`release-notes-draft` artifact. No version/changelog PR is opened yet.
|
|
14
|
+
|
|
15
|
+
Review the workflow summary and artifact:
|
|
16
|
+
|
|
17
|
+
- Inspect components needing manual QA and PRs without test-file changes.
|
|
18
|
+
- Resolve or explicitly accept the findings. A changed test file does not prove
|
|
19
|
+
adequate coverage, and the checklist does not perform browser QA.
|
|
20
|
+
- Review the release-note grouping and wording.
|
|
21
|
+
- Choose a version scope:
|
|
22
|
+
- **Patch:** backwards-compatible bug fixes.
|
|
23
|
+
- **Minor:** new compatible functionality, including components, props, and
|
|
24
|
+
theme capabilities. Do not rely on a PR title having a `feat:` prefix.
|
|
25
|
+
- **Major:** incompatible public API or behavior changes.
|
|
26
|
+
|
|
27
|
+
Checklist suggestions are advisory. A maintainer makes the final version choice.
|
|
28
|
+
API failures abort the checklist instead of silently treating PRs as covered.
|
|
29
|
+
|
|
30
|
+
## 2. Create the release PR
|
|
31
|
+
|
|
32
|
+
Run the same workflow again from `master` with:
|
|
33
|
+
|
|
34
|
+
- `reviewed_run_id`: the successful candidate review run ID.
|
|
35
|
+
- `checklist_reviewed`: checked after completing the review above.
|
|
36
|
+
- `bump_override`: explicitly `patch`, `minor`, or `major`.
|
|
37
|
+
|
|
38
|
+
The run must come from this workflow on `master`, and its candidate must still
|
|
39
|
+
match current `master`. If the branch advanced, prepare and review a fresh
|
|
40
|
+
candidate. Range inputs are used only in phase 1.
|
|
41
|
+
|
|
42
|
+
The workflow downloads the reviewed artifacts instead of regenerating the notes.
|
|
43
|
+
It copies the release-note body unchanged under the new changelog version heading
|
|
44
|
+
and fills the standard Grommet PR template. Package version, title, and branch are
|
|
45
|
+
derived from the same explicit version decision.
|
|
46
|
+
|
|
47
|
+
The acknowledgment is a maintainer attestation, not automated proof of readiness.
|
|
48
|
+
Final note edits, required CI, version approval, and browser QA remain release PR
|
|
49
|
+
review gates. Make editorial changes in the changelog section; the tagged release
|
|
50
|
+
workflow reads that exact section for GitHub Release notes. The Slack announcement
|
|
51
|
+
is a separate summary and does not define changelog content.
|
|
52
|
+
|
|
53
|
+
After approval, merging the release PR triggers tag creation, merge-commit CI
|
|
54
|
+
checks, and the build/staging workflow. Public npm publication still requires
|
|
55
|
+
manual approval of the staged package.
|
package/tools/release-stable.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import del from"del";import fs from"fs-extra";import git from"simple-git";import path from"path";const repoURL=`https://${process.env.GH_TOKEN}@github.com/grommet/grommet.git`,localFolder=path.resolve(".tmp/grommet"),localDist=path.resolve("dist");process.env.CI?del(localFolder).then((
|
|
1
|
+
import del from"del";import fs from"fs-extra";import git from"simple-git";import path from"path";const repoURL=`https://${process.env.GH_TOKEN}@github.com/grommet/grommet.git`,localFolder=path.resolve(".tmp/grommet"),localDist=path.resolve("dist");process.env.CI?del(localFolder).then(()=>{git().clone(repoURL,localFolder).then(()=>git(localFolder).checkout("stable")).then(()=>del([`${localFolder}/**/*`])).then(()=>fs.copy(localDist,localFolder)).then(()=>git(localFolder).add(["--all","."])).then(()=>git(localFolder).commit("stable updated")).then(()=>git(localFolder).push("origin","stable")).catch(e=>console.error("failed: ",e))}):console.warn("Skipping release. Release:stable task should be executed by CI only.");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import del from"del";import fs from"fs-extra";import git from"simple-git";import path from"path";const repoURL=`https://${process.env.GH_TOKEN}@github.com/grommet/grommet.git`,localFolder=path.resolve(".tmp/grommet"),localDist=path.resolve("dist");process.env.CI?del(localFolder).then((
|
|
1
|
+
import del from"del";import fs from"fs-extra";import git from"simple-git";import path from"path";const repoURL=`https://${process.env.GH_TOKEN}@github.com/grommet/grommet.git`,localFolder=path.resolve(".tmp/grommet"),localDist=path.resolve("dist");process.env.CI?del(localFolder).then(()=>{git().silent(!1).clone(repoURL,localFolder).then(()=>git(localFolder).checkout("styled-components-beta-stable")).then(()=>del([`${localFolder}/**/*`])).then(()=>fs.copy(localDist,localFolder)).then(()=>git(localFolder).add(["--all","."])).then(()=>git(localFolder).commit("styled-components-beta-stable updated")).then(()=>git(localFolder).push("origin","styled-components-beta-stable")).catch(e=>console.error("failed: ",e))}):console.warn("Skipping release. Release:styled-components-beta-stable task \n should be executed by CI only.");
|
package/utils/DOM.js
CHANGED
|
@@ -82,17 +82,20 @@ var withinDropPortal = exports.withinDropPortal = function withinDropPortal(node
|
|
|
82
82
|
return true;
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
//
|
|
86
|
-
//
|
|
87
|
-
//
|
|
88
|
-
//
|
|
89
|
-
var isFocusable = exports.isFocusable = function isFocusable(element) {
|
|
85
|
+
// FormField focus-styling predicate, not a general DOM focusability check.
|
|
86
|
+
// Excludes buttons and links so they retain their own focus indicators.
|
|
87
|
+
// Include negative tabIndex when checking an already-focused element;
|
|
88
|
+
// descendant discovery requires a non-negative tabIndex.
|
|
89
|
+
var isFocusable = exports.isFocusable = function isFocusable(element, includeNegativeTabIndex) {
|
|
90
|
+
if (includeNegativeTabIndex === void 0) {
|
|
91
|
+
includeNegativeTabIndex = false;
|
|
92
|
+
}
|
|
90
93
|
if (!element || element.disabled) return false;
|
|
91
94
|
var tagName = element.tagName.toLowerCase();
|
|
92
95
|
if (tagName === 'input' || tagName === 'select' || tagName === 'textarea') return true;
|
|
93
96
|
// Only non-native-interactive elements with an explicit tabindex attribute
|
|
94
97
|
var isNativeInteractive = tagName === 'button' || tagName === 'a';
|
|
95
|
-
return !isNativeInteractive && element.tabIndex >= 0 && element.hasAttribute('tabindex');
|
|
98
|
+
return !isNativeInteractive && (includeNegativeTabIndex || element.tabIndex >= 0) && element.hasAttribute('tabindex');
|
|
96
99
|
};
|
|
97
100
|
|
|
98
101
|
// Get the first element that can receive focus
|
|
@@ -108,7 +111,7 @@ var getFirstFocusableDescendant = exports.getFirstFocusableDescendant = function
|
|
|
108
111
|
};
|
|
109
112
|
var shouldKeepFocus = exports.shouldKeepFocus = function shouldKeepFocus(root) {
|
|
110
113
|
var element = root.activeElement;
|
|
111
|
-
if (isFocusable(element)) return true;
|
|
114
|
+
if (isFocusable(element, true)) return true;
|
|
112
115
|
return !!getFirstFocusableDescendant(element);
|
|
113
116
|
};
|
|
114
117
|
var getNewContainer = exports.getNewContainer = function getNewContainer(target, targetChildPosition) {
|
package/utils/background.js
CHANGED
|
@@ -79,20 +79,20 @@ var backgroundIsDark = exports.backgroundIsDark = function backgroundIsDark(back
|
|
|
79
79
|
!opacity || opacity !== 'weak')) {
|
|
80
80
|
var backgroundColor = (0, _colors.normalizeColor)(background.color, theme);
|
|
81
81
|
if (backgroundColor) {
|
|
82
|
-
result = (0, _colors.colorIsDark)(backgroundColor);
|
|
82
|
+
result = (0, _colors.colorIsDark)(backgroundColor, theme);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
} else {
|
|
86
86
|
var _color = (0, _colors.normalizeColor)(background, theme);
|
|
87
87
|
if (_color) {
|
|
88
|
-
result = (0, _colors.colorIsDark)(_color);
|
|
88
|
+
result = (0, _colors.colorIsDark)(_color, theme);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
return result;
|
|
93
93
|
};
|
|
94
|
-
var darkContext = function darkContext(backgroundColor) {
|
|
95
|
-
var isDark = (0, _colors.colorIsDark)(backgroundColor);
|
|
94
|
+
var darkContext = function darkContext(backgroundColor, theme, text) {
|
|
95
|
+
var isDark = (0, _colors.colorIsDark)(backgroundColor, theme, text);
|
|
96
96
|
if (isDark === undefined) return undefined;
|
|
97
97
|
return isDark ? 'dark' : 'light';
|
|
98
98
|
};
|
|
@@ -122,13 +122,15 @@ var backgroundAndTextColors = exports.backgroundAndTextColors = function backgro
|
|
|
122
122
|
// set the textColor to have the best contrast against the background
|
|
123
123
|
// color.
|
|
124
124
|
if (!textColor && (opacity === undefined || opacity > 0.3)) {
|
|
125
|
-
var shade = darkContext(backgroundColor, theme);
|
|
126
|
-
|
|
125
|
+
var shade = darkContext(backgroundColor, theme, text);
|
|
126
|
+
// preserve undefined (unknown shade) so normalizeColor falls back
|
|
127
|
+
// to the ambient theme.dark instead of forcing the light side
|
|
128
|
+
textColor = (0, _colors.normalizeColor)(shade && text[shade] || text, theme, shade === undefined ? undefined : shade === 'dark');
|
|
127
129
|
}
|
|
128
130
|
}
|
|
129
131
|
} else {
|
|
130
132
|
backgroundColor = normalizeBackgroundColor(background, theme);
|
|
131
|
-
var _shade = darkContext(backgroundColor, theme);
|
|
133
|
+
var _shade = darkContext(backgroundColor, theme, text);
|
|
132
134
|
var transparent;
|
|
133
135
|
if (backgroundColor && (0, _colors.canExtractRGBArray)(backgroundColor)) {
|
|
134
136
|
var colorArray = (0, _colors.getRGBArray)(backgroundColor);
|
package/utils/border.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.responsiveBorderStyle = exports.borderStyle = void 0;
|
|
4
|
+
exports.responsiveBorderStyle = exports.hasSideSpecificBorder = exports.borderStyle = void 0;
|
|
5
5
|
var _styledComponents = require("styled-components");
|
|
6
6
|
var _colors = require("./colors");
|
|
7
7
|
var _mixins = require("./mixins");
|
|
8
8
|
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
9
9
|
// SPDX-License-Identifier: Apache-2.0
|
|
10
10
|
|
|
11
|
+
var hasSideSpecificBorder = exports.hasSideSpecificBorder = function hasSideSpecificBorder(borderData) {
|
|
12
|
+
var borders = Array.isArray(borderData) ? borderData : [borderData];
|
|
13
|
+
return borders.some(function (data) {
|
|
14
|
+
var side = typeof data === 'string' ? data : data == null ? void 0 : data.side;
|
|
15
|
+
return side !== undefined && side !== 'all';
|
|
16
|
+
});
|
|
17
|
+
};
|
|
11
18
|
var responsiveBorderStyle = exports.responsiveBorderStyle = function responsiveBorderStyle(data, theme) {
|
|
12
19
|
var color = (0, _colors.normalizeColor)(data.color || 'border', theme);
|
|
13
20
|
var borderSize = data.size || 'xsmall';
|
package/utils/colors.js
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.normalizeColor = exports.getRGBArray = exports.getRGBA = exports.colorIsDark = exports.canExtractRGBArray = void 0;
|
|
5
|
+
var _legacyColorIsDark = require("./legacyColorIsDark");
|
|
5
6
|
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
6
7
|
// SPDX-License-Identifier: Apache-2.0
|
|
8
|
+
|
|
7
9
|
// Track which deprecated colors have already been warned about
|
|
8
10
|
var warnedColors = new Set();
|
|
9
11
|
var checkColorDeprecation = function checkColorDeprecation(color, theme, dark) {
|
|
@@ -139,29 +141,99 @@ var getRGBArray = exports.getRGBArray = function getRGBArray(color) {
|
|
|
139
141
|
}
|
|
140
142
|
return color;
|
|
141
143
|
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
144
|
+
|
|
145
|
+
// sRGB-to-linear conversion constants.
|
|
146
|
+
// https://www.w3.org/TR/WCAG22/#dfn-relative-luminance
|
|
147
|
+
var SRGB_LINEAR_THRESHOLD = 0.04045;
|
|
148
|
+
var SRGB_LINEAR_DIVISOR = 12.92;
|
|
149
|
+
var SRGB_GAMMA_OFFSET = 0.055;
|
|
150
|
+
var SRGB_GAMMA_DIVISOR = 1.055;
|
|
151
|
+
var SRGB_GAMMA_EXPONENT = 2.4;
|
|
152
|
+
|
|
153
|
+
// Linearizes an sRGB channel (0-255) per the WCAG relative luminance spec.
|
|
154
|
+
// https://www.w3.org/TR/WCAG22/#dfn-relative-luminance
|
|
155
|
+
var linearizeChannel = function linearizeChannel(value) {
|
|
156
|
+
var c = value / 255;
|
|
157
|
+
return c <= SRGB_LINEAR_THRESHOLD ? c / SRGB_LINEAR_DIVISOR : Math.pow((c + SRGB_GAMMA_OFFSET) / SRGB_GAMMA_DIVISOR, SRGB_GAMMA_EXPONENT);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
// WCAG relative luminance coefficients for linearized sRGB channels.
|
|
161
|
+
// https://www.w3.org/TR/WCAG22/#dfn-relative-luminance
|
|
162
|
+
var RED_LUMINANCE_COEFFICIENT = 0.2126;
|
|
163
|
+
var GREEN_LUMINANCE_COEFFICIENT = 0.7152;
|
|
164
|
+
var BLUE_LUMINANCE_COEFFICIENT = 0.0722;
|
|
165
|
+
var relativeLuminance = function relativeLuminance(red, green, blue) {
|
|
166
|
+
return RED_LUMINANCE_COEFFICIENT * linearizeChannel(red) + GREEN_LUMINANCE_COEFFICIENT * linearizeChannel(green) + BLUE_LUMINANCE_COEFFICIENT * linearizeChannel(blue);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// Offset added to luminance values in the WCAG contrast ratio formula:
|
|
170
|
+
// (L1 + 0.05) / (L2 + 0.05). https://www.w3.org/TR/WCAG22/#dfn-contrast-ratio
|
|
171
|
+
var WCAG_CONTRAST_OFFSET = 0.05;
|
|
172
|
+
|
|
173
|
+
// Luminance at which black and white text have equal WCAG contrast ratios
|
|
174
|
+
// against the background: solving (1.05 / (L+0.05)) = ((L+0.05) / 0.05).
|
|
175
|
+
var EQUAL_CONTRAST_LUMINANCE = 0.179;
|
|
176
|
+
var luminanceOf = function luminanceOf(color, theme, dark) {
|
|
177
|
+
var resolved = theme && _normalizeColor(color, theme, dark) || color;
|
|
178
|
+
if (resolved && canExtractRGBArray(resolved)) {
|
|
179
|
+
var _getRGBArray = getRGBArray(resolved),
|
|
145
180
|
red = _getRGBArray[0],
|
|
146
181
|
green = _getRGBArray[1],
|
|
147
|
-
blue = _getRGBArray[2]
|
|
148
|
-
|
|
149
|
-
// if there is an alpha and it's greater than 50%, we can't really tell
|
|
150
|
-
if (alpha < 0.5) return undefined;
|
|
151
|
-
var brightness = (299 * red + 587 * green + 114 * blue) / 1000;
|
|
152
|
-
// From: http://www.had2know.com/technology/color-contrast-calculator-web-design.html
|
|
153
|
-
// Above domain is no longer registered.
|
|
154
|
-
return brightness < 125;
|
|
182
|
+
blue = _getRGBArray[2];
|
|
183
|
+
return relativeLuminance(red, green, blue);
|
|
155
184
|
}
|
|
156
185
|
return undefined;
|
|
157
186
|
};
|
|
158
|
-
|
|
187
|
+
|
|
188
|
+
// Luminance at which a pair of light/dark text colors have equal WCAG
|
|
189
|
+
// contrast against the background. text.light is the (typically darker)
|
|
190
|
+
// text used against light backgrounds and text.dark is the (typically
|
|
191
|
+
// lighter) text used against dark backgrounds. text defaults to
|
|
192
|
+
// theme.global.colors.text so callers that select an alternate text color
|
|
193
|
+
// pair (e.g. Button's explicit color prop) can pass it in and get a
|
|
194
|
+
// threshold that matches what will actually be selected. Falls back to the
|
|
195
|
+
// black/white derived EQUAL_CONTRAST_LUMINANCE when no usable text colors
|
|
196
|
+
// are available, preserving prior behavior for callers that don't pass one.
|
|
197
|
+
var equalContrastLuminance = function equalContrastLuminance(theme, text) {
|
|
198
|
+
if (text === void 0) {
|
|
199
|
+
var _theme$global;
|
|
200
|
+
text = theme == null || (_theme$global = theme.global) == null || (_theme$global = _theme$global.colors) == null ? void 0 : _theme$global.text;
|
|
201
|
+
}
|
|
202
|
+
if (!text) return EQUAL_CONTRAST_LUMINANCE;
|
|
203
|
+
// resolve both sides directly from text (a color name, a raw color, or a
|
|
204
|
+
// { dark, light } pair) with explicit dark args, so named theme colors
|
|
205
|
+
// (e.g. 'text') and aliases (e.g. text.dark: 'text-strong') resolve to
|
|
206
|
+
// the intended side rather than the theme's current mode
|
|
207
|
+
var darkTextLuminance = luminanceOf(text, theme, false);
|
|
208
|
+
var lightTextLuminance = luminanceOf(text, theme, true);
|
|
209
|
+
if (darkTextLuminance === undefined || lightTextLuminance === undefined) {
|
|
210
|
+
return EQUAL_CONTRAST_LUMINANCE;
|
|
211
|
+
}
|
|
212
|
+
return Math.sqrt((darkTextLuminance + WCAG_CONTRAST_OFFSET) * (lightTextLuminance + WCAG_CONTRAST_OFFSET)) - WCAG_CONTRAST_OFFSET;
|
|
213
|
+
};
|
|
214
|
+
var colorIsDark = exports.colorIsDark = function colorIsDark(color, theme, text) {
|
|
159
215
|
if (color && canExtractRGBArray(color)) {
|
|
160
216
|
var _getRGBArray2 = getRGBArray(color),
|
|
161
217
|
red = _getRGBArray2[0],
|
|
162
218
|
green = _getRGBArray2[1],
|
|
163
219
|
blue = _getRGBArray2[2],
|
|
164
220
|
alpha = _getRGBArray2[3];
|
|
221
|
+
// if there is an alpha and it's greater than 50%, we can't really tell
|
|
222
|
+
if (alpha < 0.5) return undefined;
|
|
223
|
+
if (theme != null && theme[_legacyColorIsDark.LEGACY_COLOR_IS_DARK]) {
|
|
224
|
+
return (0, _legacyColorIsDark.legacyColorIsDark)(red, green, blue);
|
|
225
|
+
}
|
|
226
|
+
return relativeLuminance(red, green, blue) < equalContrastLuminance(theme, text);
|
|
227
|
+
}
|
|
228
|
+
return undefined;
|
|
229
|
+
};
|
|
230
|
+
var getRGBA = exports.getRGBA = function getRGBA(color, opacity) {
|
|
231
|
+
if (color && canExtractRGBArray(color)) {
|
|
232
|
+
var _getRGBArray3 = getRGBArray(color),
|
|
233
|
+
red = _getRGBArray3[0],
|
|
234
|
+
green = _getRGBArray3[1],
|
|
235
|
+
blue = _getRGBArray3[2],
|
|
236
|
+
alpha = _getRGBArray3[3];
|
|
165
237
|
var normalizedAlpha;
|
|
166
238
|
if (opacity !== undefined) {
|
|
167
239
|
normalizedAlpha = opacity;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.legacyColorIsDark = exports.LEGACY_COLOR_IS_DARK = void 0;
|
|
5
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
6
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
var LEGACY_COLOR_IS_DARK = exports.LEGACY_COLOR_IS_DARK = Symbol('legacyColorIsDark');
|
|
8
|
+
|
|
9
|
+
// Brightness weights documented by Had2Know's legacy contrast calculator.
|
|
10
|
+
// https://www.had2know.org/technology/color-contrast-calculator-web-design.html
|
|
11
|
+
var RED_BRIGHTNESS_COEFFICIENT = 299;
|
|
12
|
+
var GREEN_BRIGHTNESS_COEFFICIENT = 587;
|
|
13
|
+
var BLUE_BRIGHTNESS_COEFFICIENT = 114;
|
|
14
|
+
var BRIGHTNESS_COEFFICIENT_DIVISOR = 1000;
|
|
15
|
+
|
|
16
|
+
// Legacy cutoff; the source's 125 threshold is for color-pair difference.
|
|
17
|
+
var DARK_BRIGHTNESS_THRESHOLD = 125;
|
|
18
|
+
var legacyColorIsDark = exports.legacyColorIsDark = function legacyColorIsDark(red, green, blue) {
|
|
19
|
+
var brightness = (RED_BRIGHTNESS_COEFFICIENT * red + GREEN_BRIGHTNESS_COEFFICIENT * green + BLUE_BRIGHTNESS_COEFFICIENT * blue) / BRIGHTNESS_COEFFICIENT_DIVISOR;
|
|
20
|
+
return brightness < DARK_BRIGHTNESS_THRESHOLD;
|
|
21
|
+
};
|