Skip to content

Commit c0b8d13

Browse files
authored
Merge pull request #200 from CrowdStrike/add-select-component-tony
Add Combobox component to Toucan Core & Toucan Form
2 parents 8bb08f0 + 212cd77 commit c0b8d13

File tree

39 files changed

+3593
-30
lines changed

39 files changed

+3593
-30
lines changed

.changeset/twelve-gifts-camp.md

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
'@crowdstrike/ember-toucan-core': patch
3+
'@crowdstrike/ember-toucan-form': patch
4+
---
5+
6+
Added a `Combobox` component to both core and form packages.
7+
8+
If you're using `toucan-core`, the control and field components are exposed:
9+
10+
```hbs
11+
<Form::Controls::Combobox
12+
@onChange={{this.onChange}}
13+
@options={{this.options}}
14+
@contentClass='z-10'
15+
@selected={{this.selected}}
16+
@optionKey='label'
17+
@noResultsText='No results'
18+
placeholder='Colors'
19+
as |combobox|
20+
>
21+
<combobox.Option>
22+
{{combobox.option.label}}
23+
</combobox.Option>
24+
</Form::Controls::Combobox>
25+
26+
<Form::Fields::Combobox
27+
@contentClass='z-10'
28+
@error={{this.errorMessage}}
29+
@hint='Type "blue" into the field'
30+
@label='Label'
31+
@noResultsText='No results'
32+
@onChange={{this.onChange}}
33+
@optionKey='label'
34+
@options={{this.options}}
35+
@selected={{this.selected}}
36+
placeholder='Colors'
37+
as |combobox|
38+
>
39+
<combobox.Option>
40+
{{combobox.option.label}}
41+
</combobox.Option>
42+
</Form::Fields::Combobox>
43+
```
44+
45+
If you're using `toucan-form`, the component is exposed via:
46+
47+
```hbs
48+
<ToucanForm as |form|>
49+
<form.Combobox
50+
@label='Combobox'
51+
@name='combobox'
52+
@options={{options}}
53+
data-combobox
54+
as |combobox|
55+
>
56+
<combobox.Option data-option>{{combobox.option}}</combobox.Option>
57+
</form.Combobox>
58+
</ToucanForm>
59+
```
60+
61+
For more information on using these components, view [the docs](https://ember-toucan-core.pages.dev/docs/components/combobox).

.github/workflows/ci.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ jobs:
118118
- ember-release
119119
- ember-beta
120120
- ember-canary
121-
- "'ember-release + embroider-optimized'"
122-
- "'ember-lts-4.8 + embroider-optimized'"
121+
# @todo Temporarily disabling embroider optimized tests due to https://github.com/CrowdStrike/ember-toucan-core/issues/210
122+
# - "'ember-release + embroider-optimized'"
123+
# - "'ember-lts-4.8 + embroider-optimized'"
123124

124125
steps:
125126
- uses: actions/checkout@v3

docs-app/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135
"ember-browser-services": "^4.0.4",
136136
"ember-modifier": "^4.1.0",
137137
"ember-resources": "^6.0.0",
138+
"ember-velcro": "^2.1.0",
138139
"highlight.js": "^11.6.0",
139140
"highlightjs-glimmer": "^2.0.0",
140141
"tracked-built-ins": "^3.1.0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
```hbs template
2+
<Form::Fields::Combobox
3+
@contentClass='z-10'
4+
@error={{this.errorMessage}}
5+
@hint='Type "blue" into the field'
6+
@label='Label'
7+
@noResultsText='No results'
8+
@onChange={{this.onChange}}
9+
@optionKey='label'
10+
@options={{this.options}}
11+
@selected={{this.selected}}
12+
placeholder='Colors'
13+
as |combobox|
14+
>
15+
<combobox.Option>
16+
{{combobox.option.label}}
17+
</combobox.Option>
18+
</Form::Fields::Combobox>
19+
```
20+
21+
```js component
22+
import Component from '@glimmer/component';
23+
import { action } from '@ember/object';
24+
import { tracked } from '@glimmer/tracking';
25+
26+
export default class extends Component {
27+
@tracked selected;
28+
@tracked errorMessage;
29+
30+
options = [
31+
{
32+
label: 'Blue',
33+
name: 'blue',
34+
},
35+
{
36+
label: 'Green',
37+
name: 'green',
38+
},
39+
{
40+
label: 'Yellow',
41+
name: 'yellow',
42+
},
43+
{
44+
label: 'Orange',
45+
name: 'orange',
46+
},
47+
{
48+
label: 'Red',
49+
name: 'red',
50+
},
51+
{
52+
label: 'Purple',
53+
name: 'purple',
54+
},
55+
{
56+
label: 'Teal',
57+
name: 'teal',
58+
},
59+
];
60+
61+
@action
62+
onChange(option) {
63+
this.selected = option;
64+
console.log(option);
65+
66+
if (option.label !== 'Blue') {
67+
this.errorMessage = 'Please select "Blue"';
68+
return;
69+
}
70+
71+
this.errorMessage = null;
72+
}
73+
}
74+
```

0 commit comments

Comments
 (0)