Skip to content

Commit

Permalink
Merge branch 'main' into replace-use-combined-refs
Browse files Browse the repository at this point in the history
  • Loading branch information
iansan5653 authored Aug 2, 2022
2 parents 36f2542 + b78170c commit ff8e1c1
Show file tree
Hide file tree
Showing 24 changed files with 2,006 additions and 187 deletions.
5 changes: 5 additions & 0 deletions .changeset/cuddly-bags-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

Add `InlineAutocomplete` component, `useCombobox` hook, and `useSyntheticChange` hook to drafts
5 changes: 5 additions & 0 deletions .changeset/funny-roses-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": minor
---

Add `padding` prop to `PageLayout.Header`, `PageLayout.Content`, `PageLayout.Pane`, and `PageLayout.Footer`
Empty file added @types/@koddsson/index.d.ts
Empty file.
11 changes: 11 additions & 0 deletions @types/@koddsson/textarea-caret/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
declare module '@koddsson/textarea-caret' {
export interface CaretCoordinates {
top: number
left: number
height: number
}
export default function getCaretCoordinates(
input: HTMLTextAreaElement | HTMLInputElement,
index: number
): CaretCoordinates
}
65 changes: 58 additions & 7 deletions docs/content/PageLayout.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ See [storybook](https://primer.style/react/storybook?path=/story/layout-pagelayo
</PageLayout>
```

### With connected dividers

```jsx live
<PageLayout padding="none" rowGap="none" columnGap="none">
<PageLayout.Header padding="normal" divider="line">
<Placeholder label="Header" height={64} />
</PageLayout.Header>
<PageLayout.Content padding="normal">
<Placeholder label="Content" height={240} />
</PageLayout.Content>
<PageLayout.Pane padding="normal" divider="line">
<Placeholder label="Pane" height={120} />
</PageLayout.Pane>
<PageLayout.Footer padding="normal" divider="line">
<Placeholder label="Footer" height={64} />
</PageLayout.Footer>
</PageLayout>
```

### With pane on left

```jsx live
Expand Down Expand Up @@ -139,29 +158,29 @@ See [storybook](https://primer.style/react/storybook?path=/story/layout-pagelayo
| 'medium'
| 'large'
| 'xlarge'`}
defaultValue="'full'"
defaultValue="'xlarge'"
description="The maximum width of the page container."
/>
<PropsTableRow
name="padding"
type={`| 'none'
| 'normal'
| 'condensed'`}
| 'condensed'
| 'normal'`}
defaultValue="'normal'"
description="The spacing between the outer edges of the page container and the viewport"
/>
<PropsTableRow
name="columnGap"
type={`| 'none'
| 'normal'
| 'condensed'`}
| 'condensed'
| 'normal'`}
defaultValue="'normal'"
/>
<PropsTableRow
name="rowGap"
type={`| 'none'
| 'normal'
| 'condensed'`}
| 'condensed'
| 'normal'`}
defaultValue="'normal'"
/>
<PropsTableSxRow />
Expand All @@ -170,6 +189,14 @@ See [storybook](https://primer.style/react/storybook?path=/story/layout-pagelayo
### PageLayout.Header

<PropsTable>
<PropsTableRow
name="padding"
type={`| 'none'
| 'condensed'
| 'normal'`}
defaultValue="'normal'"
description="The amount of padding inside the header."
/>
<PropsTableRow
name="divider"
type={`| 'none'
Expand Down Expand Up @@ -224,6 +251,14 @@ See [storybook](https://primer.style/react/storybook?path=/story/layout-pagelayo
defaultValue="'full'"
description="The maximum width of the content region."
/>
<PropsTableRow
name="padding"
type={`| 'none'
| 'condensed'
| 'normal'`}
defaultValue="'normal'"
description="The amount of padding inside the content."
/>
<PropsTableRow
name="hidden"
type={`| boolean
Expand Down Expand Up @@ -275,6 +310,14 @@ See [storybook](https://primer.style/react/storybook?path=/story/layout-pagelayo
defaultValue="'medium'"
description="The width of the pane."
/>
<PropsTableRow
name="padding"
type={`| 'none'
| 'condensed'
| 'normal'`}
defaultValue="'normal'"
description="The amount of padding inside the pane."
/>
<PropsTableRow
name="divider"
type={`| 'none'
Expand Down Expand Up @@ -320,6 +363,14 @@ See [storybook](https://primer.style/react/storybook?path=/story/layout-pagelayo
### PageLayout.Footer

<PropsTable>
<PropsTableRow
name="padding"
type={`| 'none'
| 'condensed'
| 'normal'`}
defaultValue="'normal'"
description="The amount of padding inside the footer."
/>
<PropsTableRow
name="divider"
type={`| 'none'
Expand Down
162 changes: 162 additions & 0 deletions docs/content/drafts/InlineAutocomplete.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
---
title: InlineAutocomplete
componentId: inline_autocomplete
status: Draft
description: Provides inline auto completion suggestions for an input or textarea.
source: https://github.com/primer/react/tree/main/src/InlineAutocomplete
storybook: '/react/storybook?path=/story/forms-inlineautocomplete--default'
---

```js
import {InlineAutocomplete} from '@primer/react/drafts'
```

The `InlineAutocomplete` component extends an `Input` or `Textarea` component to provide inline suggestions, similar to those provided by a code editor.

## Examples

<Note variant="warning">

Input components **must always** be accompanied by a corresponding label to improve support for assistive
technologies. Examples below are provided for conciseness and may not reflect accessibility best practices.

`InlineAutocomplete` can be used with the [`FormControl`](/FormControl) component to render a corresponding label.

</Note>

### Multi-line input

Try typing a `#` symbol to see suggestions. Use `Enter` or click to apply a suggestion.

```javascript live noinline drafts
const options = ['javascript', 'typescript', 'css', 'html', 'webassembly']

const SimpleExample = () => {
const [suggestions, setSuggestions] = React.useState([])

return (
<InlineAutocomplete
triggers={[{triggerChar: '#'}]}
suggestions={suggestions}
onShowSuggestions={({query}) => setSuggestions(options.filter(tag => tag.includes(query)))}
onHideSuggestions={() => setSuggestions([])}
>
<Textarea />
</InlineAutocomplete>
)
}

render(SimpleExample)
```

### Single-line input

```javascript live noinline drafts
const options = ['javascript', 'typescript', 'css', 'html', 'webassembly']

const SimpleExample = () => {
const [suggestions, setSuggestions] = React.useState([])

return (
<InlineAutocomplete
triggers={[{triggerChar: '#'}]}
suggestions={suggestions}
onShowSuggestions={({query}) => setSuggestions(options.filter(tag => tag.includes(query)))}
onHideSuggestions={() => setSuggestions([])}
>
<TextInput />
</InlineAutocomplete>
)
}

render(SimpleExample)
```

### Labelled

```javascript live noinline drafts
const options = ['javascript', 'typescript', 'css', 'html', 'webassembly']

const SimpleExample = () => {
const [suggestions, setSuggestions] = React.useState([])

return (
<FormControl>
<FormControl.Label>Example</FormControl.Label>
<InlineAutocomplete
triggers={[{triggerChar: '#'}]}
suggestions={suggestions}
onShowSuggestions={({query}) => setSuggestions(options.filter(tag => tag.includes(query)))}
onHideSuggestions={() => setSuggestions([])}
>
<Textarea />
</InlineAutocomplete>
</FormControl>
)
}

render(SimpleExample)
```

## Props

<PropsTable>
<PropsTableRow
name="children"
required
type="React.ReactNode"
description="An `input` or `textarea` compatible component to extend. A compatible component is any component that forwards a ref and props to an underlying `input` or `textarea` element, including but not limited to `Input`, `TextArea`, `input`, `textarea`, `styled.input`, and `styled.textarea`. If the child is not compatible, a runtime `TypeError` will be thrown."
/>
<PropsTableRow
name="triggers"
required
type="Array<Trigger>"
description="Register the triggers that can cause suggestions to appear."
/>
<PropsTableRow
name="onShowSuggestions"
type="(event: ShowSuggestionsEvent) => void"
required
description="Called when a valid suggestion query is updated. This should be handled by setting the `suggestions` prop accordingly."
/>
<PropsTableRow
name="onShowSuggestions"
type="() => void"
required
description="Called when suggestions should be hidden. Set `suggestions` to `null` or an empty array in this case."
/>
<PropsTableRow
name="suggestions"
type="Suggestion[] | null | 'loading'"
required
description="The currently visible list of suggestions. If `loading`, a loading indicator will be shown. If `null` or empty, the list will be hidden. Suggestion sort will be preserved. Typically, this should not contain more than five or so suggestions."
/>
<PropsTableRow
name="tabInsertsSuggestions"
type="boolean"
defaultValue="false"
description="If `true`, suggestions will be applied with both `Tab` and `Enter`, instead of just `Enter`. This may be expected behavior for users used to IDEs, but use caution when hijacking browser tabbing capability."
/>
<PropsTableSxRow />
</PropsTable>

## Status

<ComponentChecklist
items={{
propsDocumented: false,
noUnnecessaryDeps: true,
adaptsToThemes: true,
adaptsToScreenSizes: true,
fullTestCoverage: false,
usedInProduction: true,
usageExamplesDocumented: false,
hasStorybookStories: false,
designReviewed: false,
a11yReviewed: false,
stableApi: false,
addressedApiFeedback: false,
hasDesignGuidelines: false,
hasFigmaComponent: false
}}
/>
Loading

0 comments on commit ff8e1c1

Please sign in to comment.