Skip to content

Commit

Permalink
refactor: redesign select and combobox (#826)
Browse files Browse the repository at this point in the history
  • Loading branch information
segunadebayo authored Sep 5, 2023
1 parent 8676fec commit 224cbbb
Show file tree
Hide file tree
Showing 75 changed files with 3,124 additions and 1,926 deletions.
3 changes: 0 additions & 3 deletions .changeset/large-books-own.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
---
"@zag-js/combobox": patch
"@zag-js/dom-event": patch
"@zag-js/shared": patch
"website": patch
---

Add support for `closeOnSelect`
33 changes: 33 additions & 0 deletions .changeset/thick-forks-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
"@zag-js/select": minor
"@zag-js/combobox": minor
"@zag-js/utils": minor
---

> Breaking Changes 💥
Redesign select and combobox API to allow passing value as `string` and `collection`

Prior to this change, Zag computes the label and value from the DOM element. While this worked, it makes it challenging
to manage complex objects that don't match the `label` and `value` convention.

```jsx
// Create the collection
const collection = select.collection({
items: [],
itemToString(item) {
return item.label
},
itemToValue(item) {
return item.value
},
})

// Pass the collection to the select machine
const [state, send] = useMachine(
select.machine({
collection,
id: useId(),
}),
)
```
Loading

4 comments on commit 224cbbb

@vercel
Copy link

@vercel vercel bot commented on 224cbbb Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 224cbbb Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

zag-solid – ./examples/solid-ts

zag-solid-chakra-ui.vercel.app
zag-solid-git-main-chakra-ui.vercel.app
zag-solid.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 224cbbb Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

zag-vue – ./examples/vue-ts

zag-vue-git-main-chakra-ui.vercel.app
zag-vue.vercel.app
zag-vue-chakra-ui.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 224cbbb Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

zag-nextjs – ./examples/next-ts

zag-nextjs-git-main-chakra-ui.vercel.app
zag-two.vercel.app
zag-nextjs-chakra-ui.vercel.app

Please sign in to comment.