Skip to content

Commit

Permalink
add dropdown primitive
Browse files Browse the repository at this point in the history
Release 17.0.0-0

add dropdown primitive ctd

Release 17.0.0-1

update changelog

add dropdown primitive ctd

Release 17.0.0-2

add dropdown primitive ctd

Release 17.0.0-3

add dropdown primitive ctd

Release 17.0.0-4

add dropdown primitive ctd

Release 17.0.0-5

add dropdown primitive ctd

Release 17.0.0-6

add dropdown primitive ctd

Release 17.0.0-8

add dropdown primitive ctd

Release 17.0.0-9
  • Loading branch information
amk221 committed Dec 12, 2024
1 parent 51f8769 commit df648b3
Show file tree
Hide file tree
Showing 85 changed files with 4,197 additions and 2,613 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 17.0.0

- Add dropdown primitive

## 16.4.0

- Don't allow focus to move to listbox, when in a combbox
Expand Down
101 changes: 60 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ https://zestia.github.io/ember-select-box
- Full control at all times with the API ✔︎
- No configuration options ✔︎
- Very few issues over many years of Ember! ✔︎
- Dropdown primitive ✔︎
- Customisable filtering built in ✔︎

## Notes
Expand All @@ -52,14 +53,18 @@ This addon intentionally...

```handlebars
<SelectBox @value='Foo' @onChange={{this.handleChange}} as |sb|>
<sb.Trigger>
{{sb.value}}
</sb.Trigger>
<sb.Options>
<sb.Option @value='Foo'>
Foo
</sb.Option>
</sb.Options>
<sb.Dropdown>
<sb.Trigger>
{{sb.value}}
</sb.Trigger>
<sb.Content>
<sb.Options>
<sb.Option @value='Foo'>
Foo
</sb.Option>
</sb.Options>
</sb.Content>
</sb.Dropdown>
</SelectBox>
```

Expand Down Expand Up @@ -140,18 +145,6 @@ Optional. If `true`, `@value` is expected to be an array. If an option's value i

Optional. Fired whenever a selection is made. This function receives the values most recently selected, and the previously selected values. The return value is then used as the final selection. This is primarily used to customise select boxes where `@multiple` is `true` - because the behaviour for a selection is undefined and totally depends on your use-case.

#### `@open`

Optional. Whether or not the select box should be in an open state initially.

#### `@onOpen`

Optional. Fired when the select box is opened

#### `@onClose`

Optional. Fired when the select box is closed

#### `@onActivate`

Optional. Fired when an option is moused over or focused via the keyboard controls
Expand All @@ -166,18 +159,6 @@ Mimics the user making a selection, and so `@onChange` may fire.

Updates the select box with a new value(s). `@onChange` will not fire.

#### `open`

Opens the select box.

#### `toggle`

Opens or closes the select box

#### `close`

Closes the select box

#### `element`

The element of the select box
Expand All @@ -190,10 +171,6 @@ The selected value(s) of the select box

True if the select box is waiting for a search to finish

#### `isOpen`

Whether the select box is open

#### `query`

The query used to produce the latest search results. (This may be different to the current value in the text input).
Expand Down Expand Up @@ -241,6 +218,10 @@ Whether or not the option is currently disabled

Whether or not the option is currently selected

## `Options`

A listbox container element to house each option

## `Group`

### Arguments
Expand All @@ -249,17 +230,55 @@ Whether or not the option is currently selected

Required. The group label (similar to the native `optgroup`)

## `Options`

A container element to house each option. If no `Trigger` or `Input` is rendered, then this will be a Listbox.

## `Input`

A combobox, which by default filters down the available `@options`. Customise this behaviour by providing `@onSearch`.

## `Trigger`

A combobox, which toggles the select box open/closed.
A combobox, which toggles the select box's dropdown open/closed.

## `Content`

An element to house the content that displays when the dropdown is opened

## `Dropdown`

### Arguments

#### `@open`

Optional. Whether or not the select box's dropdown should be in an open state initially.

#### `@onOpen`

Optional. Fired when the select box's dropdown is opened

#### `@onClose`

Optional. Fired when the select box's dropdown is closed

### API

#### `isOpen`

Whether the select box's dropdown is open

#### `open`

Opens the select box's dropdown

#### `toggle`

Opens or closes the select box's dropdown

#### `close`

Closes the select box's dropdown

#### `element`

The element of the select box's dropdown

# Filtering

Expand Down
13 changes: 13 additions & 0 deletions addon/components/dropdown/content.gjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import lifecycle from '@zestia/ember-select-box/modifiers/lifecycle';

<template>
{{! template-lint-disable no-positive-tabindex }}
<div
class="dropdown__content"
tabindex={{@tabindex}}
{{lifecycle onInsert=@onInsert onDestroy=@onDestroy}}
...attributes
>
{{yield}}
</div>
</template>
Loading

0 comments on commit df648b3

Please sign in to comment.