@primer/components 30.3.0-rc.2010c7d4 → 31.0.0-rc.15aa0a10
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/.eslintrc.json +2 -1
- package/.storybook/preview.js +4 -4
- package/CHANGELOG.md +12 -2
- package/codemods/deprecateUtilityComponents.js +1 -1
- package/contributor-docs/adrs/adr-003-prop-norms.md +72 -0
- package/dist/browser.esm.js +798 -794
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +801 -797
- package/dist/browser.umd.js.map +1 -1
- package/docs/content/Autocomplete.mdx +627 -0
- package/docs/content/TextInputTokens.mdx +89 -0
- package/docs/content/getting-started.md +1 -1
- package/docs/content/overriding-styles.mdx +7 -6
- package/docs/content/theming.md +5 -5
- package/docs/package-lock.json +288 -511
- package/docs/package.json +1 -1
- package/docs/src/@primer/gatsby-theme-doctocat/components/hero.js +14 -12
- package/docs/src/@primer/gatsby-theme-doctocat/nav.yml +2 -0
- package/docs/src/@primer/gatsby-theme-doctocat/primer-components-hero.svg +7 -7
- package/lib/ActionList/Item.js +1 -1
- package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +2 -1
- package/lib/AnchoredOverlay/AnchoredOverlay.js +11 -3
- package/lib/Autocomplete/Autocomplete.d.ts +304 -0
- package/lib/Autocomplete/Autocomplete.js +145 -0
- package/lib/Autocomplete/AutocompleteContext.d.ts +17 -0
- package/lib/Autocomplete/AutocompleteContext.js +11 -0
- package/lib/Autocomplete/AutocompleteInput.d.ts +292 -0
- package/lib/Autocomplete/AutocompleteInput.js +157 -0
- package/lib/Autocomplete/AutocompleteMenu.d.ts +72 -0
- package/lib/Autocomplete/AutocompleteMenu.js +224 -0
- package/lib/Autocomplete/AutocompleteOverlay.d.ts +20 -0
- package/lib/Autocomplete/AutocompleteOverlay.js +80 -0
- package/lib/Autocomplete/index.d.ts +2 -0
- package/lib/Autocomplete/index.js +15 -0
- package/lib/BaseStyles.js +1 -1
- package/lib/BorderBox.js +1 -1
- package/lib/Button/ButtonInvisible.js +1 -1
- package/lib/Caret.js +2 -2
- package/lib/Dialog.js +1 -1
- package/lib/FilteredActionList/FilteredActionList.js +5 -31
- package/lib/Flash.js +16 -16
- package/lib/Label.js +1 -1
- package/lib/Overlay.d.ts +1 -0
- package/lib/Overlay.js +3 -1
- package/lib/ProgressBar.js +1 -1
- package/lib/StateLabel.js +13 -19
- package/lib/Token/_RemoveTokenButton.js +1 -1
- package/lib/__tests__/Autocomplete.test.d.ts +1 -0
- package/lib/__tests__/Autocomplete.test.js +528 -0
- package/lib/__tests__/BorderBox.test.js +1 -1
- package/lib/__tests__/CircleOcticon.test.js +1 -1
- package/lib/__tests__/CounterLabel.test.js +4 -4
- package/lib/__tests__/Flash.test.js +4 -4
- package/lib/__tests__/Link.test.js +1 -1
- package/lib/__tests__/behaviors/scrollIntoViewingArea.test.d.ts +1 -0
- package/lib/__tests__/behaviors/scrollIntoViewingArea.test.js +226 -0
- package/lib/behaviors/scrollIntoViewingArea.d.ts +1 -0
- package/lib/behaviors/scrollIntoViewingArea.js +39 -0
- package/lib/hooks/useOpenAndCloseFocus.d.ts +2 -1
- package/lib/hooks/useOpenAndCloseFocus.js +7 -2
- package/lib/hooks/useOverlay.d.ts +2 -1
- package/lib/hooks/useOverlay.js +4 -2
- package/lib/index.d.ts +2 -0
- package/lib/index.js +8 -0
- package/lib/stories/Autocomplete.stories.js +608 -0
- package/lib/stories/Dialog.stories.js +3 -3
- package/lib/stories/IssueLabelToken.stories.js +1 -1
- package/lib/stories/ProfileToken.stories.js +1 -1
- package/lib/theme-preval.js +370 -3100
- package/lib/utils/testing.d.ts +50 -493
- package/lib/utils/types/MandateProps.d.ts +3 -0
- package/lib/utils/types/MandateProps.js +1 -0
- package/lib/utils/types/index.d.ts +1 -0
- package/lib/utils/types/index.js +13 -0
- package/lib-esm/ActionList/Item.js +1 -1
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +2 -1
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.js +11 -3
- package/lib-esm/Autocomplete/Autocomplete.d.ts +304 -0
- package/lib-esm/Autocomplete/Autocomplete.js +123 -0
- package/lib-esm/Autocomplete/AutocompleteContext.d.ts +17 -0
- package/lib-esm/Autocomplete/AutocompleteContext.js +2 -0
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +292 -0
- package/lib-esm/Autocomplete/AutocompleteInput.js +138 -0
- package/lib-esm/Autocomplete/AutocompleteMenu.d.ts +72 -0
- package/lib-esm/Autocomplete/AutocompleteMenu.js +205 -0
- package/lib-esm/Autocomplete/AutocompleteOverlay.d.ts +20 -0
- package/lib-esm/Autocomplete/AutocompleteOverlay.js +62 -0
- package/lib-esm/Autocomplete/index.d.ts +2 -0
- package/lib-esm/Autocomplete/index.js +1 -0
- package/lib-esm/BaseStyles.js +1 -1
- package/lib-esm/BorderBox.js +1 -1
- package/lib-esm/Button/ButtonInvisible.js +1 -1
- package/lib-esm/Caret.js +2 -2
- package/lib-esm/Dialog.js +1 -1
- package/lib-esm/FilteredActionList/FilteredActionList.js +3 -31
- package/lib-esm/Flash.js +16 -16
- package/lib-esm/Label.js +1 -1
- package/lib-esm/Overlay.d.ts +1 -0
- package/lib-esm/Overlay.js +3 -1
- package/lib-esm/ProgressBar.js +1 -1
- package/lib-esm/StateLabel.js +13 -19
- package/lib-esm/Token/_RemoveTokenButton.js +1 -1
- package/lib-esm/__tests__/Autocomplete.test.d.ts +1 -0
- package/lib-esm/__tests__/Autocomplete.test.js +494 -0
- package/lib-esm/__tests__/BorderBox.test.js +1 -1
- package/lib-esm/__tests__/CircleOcticon.test.js +1 -1
- package/lib-esm/__tests__/CounterLabel.test.js +4 -4
- package/lib-esm/__tests__/Flash.test.js +4 -4
- package/lib-esm/__tests__/Link.test.js +1 -1
- package/lib-esm/__tests__/behaviors/scrollIntoViewingArea.test.d.ts +1 -0
- package/lib-esm/__tests__/behaviors/scrollIntoViewingArea.test.js +224 -0
- package/lib-esm/behaviors/scrollIntoViewingArea.d.ts +1 -0
- package/lib-esm/behaviors/scrollIntoViewingArea.js +30 -0
- package/lib-esm/hooks/useOpenAndCloseFocus.d.ts +2 -1
- package/lib-esm/hooks/useOpenAndCloseFocus.js +7 -2
- package/lib-esm/hooks/useOverlay.d.ts +2 -1
- package/lib-esm/hooks/useOverlay.js +4 -2
- package/lib-esm/index.d.ts +2 -0
- package/lib-esm/index.js +1 -0
- package/lib-esm/stories/Autocomplete.stories.js +549 -0
- package/lib-esm/stories/Dialog.stories.js +3 -3
- package/lib-esm/stories/IssueLabelToken.stories.js +1 -1
- package/lib-esm/stories/ProfileToken.stories.js +1 -1
- package/lib-esm/theme-preval.js +370 -3100
- package/lib-esm/utils/testing.d.ts +50 -493
- package/lib-esm/utils/types/MandateProps.d.ts +3 -0
- package/lib-esm/utils/types/MandateProps.js +1 -0
- package/lib-esm/utils/types/index.d.ts +1 -0
- package/lib-esm/utils/types/index.js +2 -1
- package/package-lock.json +11 -8
- package/package.json +3 -3
- package/src/ActionList/Item.tsx +1 -1
- package/src/AnchoredOverlay/AnchoredOverlay.tsx +14 -3
- package/src/Autocomplete/Autocomplete.tsx +103 -0
- package/src/Autocomplete/AutocompleteContext.tsx +19 -0
- package/src/Autocomplete/AutocompleteInput.tsx +179 -0
- package/src/Autocomplete/AutocompleteMenu.tsx +341 -0
- package/src/Autocomplete/AutocompleteOverlay.tsx +68 -0
- package/src/Autocomplete/index.ts +2 -0
- package/src/BaseStyles.tsx +1 -1
- package/src/BorderBox.tsx +1 -1
- package/src/Button/ButtonInvisible.tsx +7 -2
- package/src/Caret.tsx +2 -2
- package/src/Dialog.tsx +1 -1
- package/src/FilteredActionList/FilteredActionList.tsx +10 -25
- package/src/Flash.tsx +16 -16
- package/src/Label.tsx +1 -1
- package/src/Overlay.tsx +4 -1
- package/src/ProgressBar.tsx +1 -1
- package/src/StateLabel.tsx +12 -20
- package/src/Token/_RemoveTokenButton.tsx +4 -2
- package/src/__tests__/Autocomplete.test.tsx +444 -0
- package/src/__tests__/BorderBox.test.tsx +1 -1
- package/src/__tests__/CircleOcticon.test.tsx +1 -1
- package/src/__tests__/CounterLabel.test.tsx +4 -4
- package/src/__tests__/Flash.test.tsx +4 -4
- package/src/__tests__/Link.test.tsx +1 -1
- package/src/__tests__/__snapshots__/AnchoredOverlay.test.tsx.snap +3 -3
- package/src/__tests__/__snapshots__/Autocomplete.test.tsx.snap +3414 -0
- package/src/__tests__/__snapshots__/Button.test.tsx.snap +9 -1
- package/src/__tests__/__snapshots__/ConfirmationDialog.test.tsx.snap +1 -1
- package/src/__tests__/__snapshots__/SelectPanel.test.tsx.snap +1 -1
- package/src/__tests__/__snapshots__/StateLabel.test.tsx.snap +0 -21
- package/src/__tests__/__snapshots__/TextInputWithTokens.test.tsx.snap +16 -16
- package/src/__tests__/__snapshots__/Token.test.tsx.snap +34 -34
- package/src/__tests__/behaviors/scrollIntoViewingArea.test.ts +195 -0
- package/src/behaviors/scrollIntoViewingArea.ts +27 -0
- package/src/hooks/useOpenAndCloseFocus.ts +7 -2
- package/src/hooks/useOverlay.tsx +4 -2
- package/src/index.ts +2 -0
- package/src/stories/Autocomplete.stories.tsx +572 -0
- package/src/stories/Dialog.stories.tsx +3 -3
- package/src/stories/IssueLabelToken.stories.tsx +1 -1
- package/src/stories/ProfileToken.stories.tsx +1 -1
- package/src/utils/types/MandateProps.ts +19 -0
- package/src/utils/types/index.ts +1 -0
- package/stats.html +1 -1
- package/docs/src/@primer/gatsby-theme-doctocat/components/live-code.js +0 -84
- package/docs/src/@primer/gatsby-theme-doctocat/components/nav-dropdown.js +0 -48
- package/docs/src/@primer/gatsby-theme-doctocat/components/wrap-page-element.js +0 -25
package/.eslintrc.json
CHANGED
package/.storybook/preview.js
CHANGED
@@ -5,8 +5,8 @@ import styled, {createGlobalStyle} from 'styled-components'
|
|
5
5
|
// set global theme styles for each story
|
6
6
|
const GlobalStyle = createGlobalStyle`
|
7
7
|
body {
|
8
|
-
background-color: ${themeGet('colors.
|
9
|
-
color: ${themeGet('colors.
|
8
|
+
background-color: ${themeGet('colors.canvas.default')};
|
9
|
+
color: ${themeGet('colors.fg.default')};
|
10
10
|
}
|
11
11
|
`
|
12
12
|
|
@@ -26,8 +26,8 @@ const Wrapper = styled.div`
|
|
26
26
|
|
27
27
|
// instead of global theme, only theme wrapper for each story
|
28
28
|
const ThemedSectionStyle = styled.div`
|
29
|
-
background-color: ${themeGet('colors.
|
30
|
-
color: ${themeGet('colors.
|
29
|
+
background-color: ${themeGet('colors.canvas.default')};
|
30
|
+
color: ${themeGet('colors.fg.default')};
|
31
31
|
padding: 1rem;
|
32
32
|
`
|
33
33
|
|
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,22 @@
|
|
1
1
|
# @primer/components
|
2
2
|
|
3
|
+
## 31.0.0
|
4
|
+
|
5
|
+
### Major Changes
|
6
|
+
|
7
|
+
- [#1514](https://github.com/primer/react/pull/1514) [`dc789025`](https://github.com/primer/react/commit/dc789025d4976e2f0863e1f377c4a834aab88e3a) Thanks [@colebemis](https://github.com/colebemis)! - Remove deprecated color variables by upgrading to @primer/primitives [v5](https://github.com/primer/primitives/pull/251)
|
8
|
+
|
9
|
+
**Note:** Install [`eslint-plugin-primer-react`](https://primer.style/react/linting) to ensure that you're not using any deprecated or removed color variables.
|
10
|
+
|
3
11
|
## 30.3.0
|
4
12
|
|
5
13
|
### Minor Changes
|
6
14
|
|
7
|
-
- [#
|
15
|
+
- [#1490](https://github.com/primer/react/pull/1490) [`c156b07a`](https://github.com/primer/react/commit/c156b07ab6f2f5ad6d35d1c4f89d8a7f37ad1cef) Thanks [@mperrotti](https://github.com/mperrotti)! - Adds `Autocomplete`, `AutocompleteMenu`, `AutocompleteInput`, and `AutocompleteOverlay` components
|
16
|
+
|
17
|
+
* [#1489](https://github.com/primer/react/pull/1489) [`273ef29d`](https://github.com/primer/react/commit/273ef29d1d8f28bb856faba4da803e7ad0892c6e) Thanks [@mperrotti](https://github.com/mperrotti)! - Add alpha `TextInputWithTokens` component
|
8
18
|
|
9
|
-
|
19
|
+
- [#1488](https://github.com/primer/react/pull/1488) [`05ac5aab`](https://github.com/primer/react/commit/05ac5aabb6bf39150557732605f9ce0fb3b9d1ec) Thanks [@mperrotti](https://github.com/mperrotti)! - Add alpha `Token`, `AvatarToken`, `IssueLabelToken` components
|
10
20
|
|
11
21
|
## 30.2.1
|
12
22
|
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# ADR 003: Prop norms in Primer React Components
|
2
|
+
|
3
|
+
## Status
|
4
|
+
|
5
|
+
Proposed
|
6
|
+
|
7
|
+
## Context
|
8
|
+
|
9
|
+
Today our component prop APIs have:
|
10
|
+
|
11
|
+
- Implicit conventions not documented anywhere but consistently reflected in our code (e.g., the type of the `sx` prop)
|
12
|
+
- Explicit plans to change some of those (e.g., the deprecation of Styled System props)
|
13
|
+
- Inconsistencies in our implementation (e.g., when components accept a `ref` prop)
|
14
|
+
|
15
|
+
This ADR aims to unify some of these conversations about prop APIs, codify our decisions, and sequence the work to get there.
|
16
|
+
|
17
|
+
## Decision
|
18
|
+
|
19
|
+
### 🟢 `sx`
|
20
|
+
|
21
|
+
All components that ultimately render to the DOM should accept an `sx` prop.
|
22
|
+
|
23
|
+
The `sx` prop (of type `SystemStyleObject`) should generally set styles for the root HTML element rendered by the component. An exception would be components like `<Dialog>`, whose outermost HTML element is a backdrop. In that case, it would be appropriate for `sx` styles to apply to child of the backdrop that is more likely to need styling overrides.
|
24
|
+
|
25
|
+
### 🟢 `ref`
|
26
|
+
|
27
|
+
All components that ultimately render to the DOM should accept a `ref` prop. That `ref` prop should most often be passed to the root HTMLElement rendered by the component, although occasionally a different descendent node may make more sense.
|
28
|
+
|
29
|
+
See also: [Discussion on `ref` props (internal)](https://github.com/github/primer/discussions/131)
|
30
|
+
|
31
|
+
### 🟡 `as`
|
32
|
+
|
33
|
+
Only components with a clear need for polymorphism should accept an `as` prop. Reasonable cases include:
|
34
|
+
|
35
|
+
- Components that need functionality from the component passed to the `as` prop, like a `<Button>` that renders a React Router link.
|
36
|
+
- Components whose accessibility are improved by using semantically appropriate HTML elements, like an ActionList
|
37
|
+
|
38
|
+
When a Primer component user passes an `as` prop to a component, it should be done in a way that is consistent with the component’s intended use. In some situations we can enforce that with a narrowed type for our `as` prop.
|
39
|
+
|
40
|
+
See also: [Discussion on `as` props (internal)](https://github.com/github/primer/discussions/130)
|
41
|
+
|
42
|
+
### 🟡 DOM props: Limited
|
43
|
+
|
44
|
+
All components that accept an `as` prop should accept props en masse for the element specified by the `as` prop (excluding props of the same name already used by the component). _Additionally_, some other elements that do _not_ accept an `as` prop should accept the props for their root HTML element when those props are fundamental to the component’s function (e.g., `<TextInput>` should accept DOM props for its underlying `<input>`).
|
45
|
+
|
46
|
+
### 🔴 Styled System props
|
47
|
+
|
48
|
+
Components should not accept Styled System props (except our utility components: `Box` and `Type`)
|
49
|
+
|
50
|
+
_Reasoning:_ Utility components are meant to provide a convenient API for writing styles (including styles that reference theme and other context managed within Primer). Non-utility components implement specific design patterns where additional styling is available for exceptional cases.
|
51
|
+
|
52
|
+
See also: [Discussion on the deprecation of styled-system props (internal)](https://github.com/github/primer/discussions/132)
|
53
|
+
|
54
|
+
### 🔴 `theme`
|
55
|
+
|
56
|
+
Components should not accept a `theme` prop (with the exception of `ThemeProvider`).
|
57
|
+
|
58
|
+
_Reasoning:_ The `theme` prop doesn't enable anything that can't be done with `<ThemeProvider>`, and promotes the anti-pattern of per-component theme overrides.
|
59
|
+
|
60
|
+
### `children`
|
61
|
+
|
62
|
+
I'm intentionally withholding advocacy about `children` prop types because I expect that topic will be covered by a future ADR.
|
63
|
+
|
64
|
+
### Sequencing
|
65
|
+
|
66
|
+
1. Deprecate remaining unwanted Styled System props (should be done? Let's verify.)
|
67
|
+
1. Release an eslint rule to disallow Styled System props
|
68
|
+
1. Release an eslint rule to disallow `theme`
|
69
|
+
1. Migrate all usage within PRC
|
70
|
+
1. Assist GitHub projects with migration
|
71
|
+
1. Remove support for unwanted props
|
72
|
+
1. Update docs to reflect the standards in this ADR
|