Commit Graph

67 Commits

Author SHA1 Message Date
Robin Malfait f016dc51db Add virtual prop to Combobox component (#2740)
* type timezones in playground data

* add `@tanstack/react-virtual` and `@tanstack/vue-virtual`

* use latest stable Tailwind CSS version

* add Combobox with virtual prop example

* add `virtual` prop to `Combobox`

Co-authored-by: Jordan Pittman <jordan@cryptica.me>

* add tests for `virtual` prop

- Also wrap `click` helpers in `act` for React (use `rawClick` without
  `act` in tests related to `Transition`)

* update changelog

---------

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2023-09-15 14:29:18 +02:00
Jordan Pittman 0b8bd32865 1.7.17 - @headlessui/react 2023-08-17 10:58:55 -04:00
Robin Malfait 0501475575 1.7.16 - @headlessui/react 2023-07-27 16:23:46 +02:00
Robin Malfait a1d7c69b69 1.7.15 - @headlessui/react 2023-06-01 12:40:00 +02:00
Mateusz Burzyński 0505e92b83 Move types condition to the front (#2469)
* move `types` condition to the front

* Update changelog

---------

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2023-05-01 12:21:28 -04:00
Robin Malfait c5d2e3b053 1.7.14 - @headlessui/react 2023-04-12 19:05:04 +02:00
Robin Malfait df61edcf3e 1.7.13 - @headlessui/react 2023-03-03 21:09:06 +01:00
Robin Malfait 885f446e4e 1.7.12 - @headlessui/react 2023-02-24 16:29:14 +01:00
Robin Malfait 2c2a22bd4f 1.7.11 - @headlessui/react 2023-02-15 15:10:39 +01:00
Robin Malfait 597256bd9e 1.7.10 - @headlessui/react 2023-02-06 12:33:23 +01:00
Robin Malfait 885fa6aedd 1.7.9 - @headlessui/react 2023-02-03 17:40:08 +01:00
Robin Malfait b3a0ccb2f8 1.7.8 - @headlessui/react 2023-01-27 17:24:04 +01:00
Robin Malfait b7c9e57343 1.7.7 - @headlessui/react 2022-12-16 17:38:32 +01:00
Robin Malfait 92e9302020 1.7.6 - @headlessui/react 2022-12-15 17:35:18 +01:00
Robin Malfait 326a43f73f 1.7.5 - @headlessui/react 2022-12-08 23:17:01 +01:00
Robin Malfait 74e7b43781 1.7.4 2022-11-03 16:21:15 +01:00
Robin Malfait f424aa20db Add client-only to mark everything as client components (#1981)
* add `client-only` to mark everything as client components

This should improve the error messages when using Headless UI in a
Next.js 13+ repo instead of getting a cryptic error message that
`createContext` doesn't exist.

* update changelog
2022-11-03 16:17:22 +01:00
Jordan Pittman fdccf0767a 1.7.3 2022-09-30 11:54:08 -04:00
Robin Malfait dd2feefb9e 1.7.2 2022-09-15 18:31:27 +02:00
Robin Malfait e926d693c5 1.7.1 2022-09-12 21:09:38 +02:00
Robin Malfait b93b7463bc 1.7.0 2022-09-06 16:22:42 +02:00
Robin Malfait 3799d6f438 1.6.6 2022-07-07 23:02:52 +02:00
Robin Malfait f4d1acb5d7 1.6.5 2022-06-20 17:57:56 +02:00
Robin Malfait 655107962f 1.6.4 2022-05-29 14:54:44 +02:00
Robin Malfait 3c32369851 1.6.3 2022-05-25 15:18:01 +02:00
Robin Malfait 46aab52ba5 1.6.2 - @headlessui/react 2022-05-19 16:33:21 +02:00
Robin Malfait 695bf299ed 1.6.1 - @headlessui/react 2022-05-03 13:19:16 +02:00
Robin Malfait 1e14d5159c 1.6.0 2022-04-25 15:58:55 +02:00
Robin Malfait 0162c57d88 add React 18 compatibility (#1326)
* bump dev dependencies to React 18

* setup Jest to include `IS_REACT_ACT_ENVIRONMENT`

* prefer `useId` from React 18 if it exists

In React 16 & 17, where `useId` doesn't exist, we will fallback to our
implementation we have been using up until now.

The `useId` exposed by React 18, ensures stable references even in SSR
environments.

* update expected events

React 18 now uses the proper events:
- `blur` -> `focusout`
- `focus` -> `focusin`

* ensure to wait a bit longer

This is a bit unfortunate, but since React 18 now does an extra
unmount/remount in `StrictMode` to ensure that your code is
ConcurrentMode ready, it takes a bit longer to settle what the DOM sees.

That said, this is a temporary "hack". We are going to experiment with
using tools like Puppeteer/Playwright to run our tests in an actual
browser instead to eliminate all the weird details that we have to keep
in mind.

* prefer `.focus()` over `fireEvent.focus(el)`

* abstract `microTask` polyfill code

* prefer our `focus(el)` function over `el.focus()`

Internally we would still use `el.focus()`, but this allows us to have
more control over that `focus` function.

* add React 18 to the React Playground

* improve hooks for React 18

- Improving the cleanup of useEffect hooks
- useIsoMorphicEffect instead of normal useEffect, so that we can use
  useLayoutEffect to be a bit quicker.

* improve disposables

- This allows us to add event listeners on a node, and get automatic
  cleanup once `dispose` gets called.
- We also return all the `d.add` calls, so that we can cleanup specific
  parts only instead of everything or nothing.

* reimplement the Transition component to be React 18 ready

* wait an additional frame for everything to settle

* update playground examples

* suppressConsoleLogs for RadioGroup components

* update changelog

* keep the `to` classes for a smoother transition

In the next transition we will remove _all_ classes provided and re-add
the once we need.

---

Some extra special thanks:

- Thanks @silvenon for your initial work on the `transition` events in #926
- Thanks @thecrypticace for doing late-night debugging sessions

Co-authored-by: =?UTF-8?q?Matija=20Marohni=C4=87?= <matija.marohnic@gmail.com>
Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2022-04-13 22:07:01 +02:00
Robin Malfait 40fee45afe Add multi value support for Listbox & Combobox (#1243)
* First attempt at a multi-listbox

* implement `multiple` mode on Listbox

* add multiple Listbox example to playground

* implement `multiple` mode on Combobox

* make sure groupContext is not undefined or null

On vercel, getting a strange issue like `TypeError: undefined is not an
object (evaluating 'r.resolveTarget')` which doesn't happen locally or
once published. Would expect it to be `null` since we default to `null`.
Hopefully this fixes things.

* bump all the dependencies

* make sure that `@types/react` use set to the correct version

`@types/react-dom` hardcoded the `@types/react` to version `16.14.21`
instead of using the latest `16.14.24` resulting in type mismatches.

*cries in inconsistency*

* update changelog

* add multiple Combobox example to playground

* refactor Combobox, use actions

* use combobox data

This is a first step in refactoring everything where we use dedicated
actions and data instead of accessing the reducer state directly.

It also allows us to get rid of mutations in render where we updated
some values in render directly which is not ideal.

Co-authored-by: pvanliefland <pierre.vanliefland@gmail.com>
2022-03-16 15:14:47 +01:00
Robin Malfait ead5ff851a 1.5.0 2022-02-17 21:51:15 +01:00
Robin Malfait c65b87ee68 improve build files
Based on: https://nodejs.org/api/packages.html#conditional-exports
2022-01-31 00:10:06 +01:00
Robin Malfait fdd2629795 Improve overal codebase, use modern tech like esbuild and TypeScript 4! (#1055)
* use esbuild for React instead of tsdx

* remove tsdx from Vue

* use consistent names

* add jest and prettier

* update scripts

* ignore some folders for prettier

* run lint script instead of tsdx lint

* run prettier en-masse

This has a few changes because of the new prettier version.

* bump typescript to latest version

* make typescript happy

* cleanup playground package.json

* make esbuild a dev dependency

* make scripts consistent

* fix husky hooks

* add dedicated watch script

* add `yarn playground-react` and `yarn react-playground` (alias)

This will make sure to run a watcher for the actual @headlessui/react
package, and start a development server in the playground-react package.

* ignore formatting in the .next folder

* run prettier on playground-react package

* setup playground-vue

Still not 100% working, but getting there!

* add playground aliases in @headlessui/vue and @headlessui/react

This allows you to run `yarn react playground` or `yarn vue playground`
from the root.

* add `clean` script

* move examples folder in playground-vue to root

* ensure new lines for consistency in scripts

* fix typescript issue

* fix typescript issues in playgrounds

* make sure to run prettier on everything it can

* run prettier on all files

* improve error output

If you minify the code, then it could happen that the errors are a bit
obscure. This will hardcode the component name to improve errors.

* add the `prettier-plugin-tailwindcss` plugin, party!

* update changelog
2022-01-27 17:07:38 +01:00
Robin Malfait ea26870480 Add Combobox component (#1047)
* start of combobox

* start with a copy of the Listbox

* WIP

* Add Vue Combobox

* Update Vue version of combobox

* Update tests

* Fix typescript errors in combobox test

* Fix input label

The spec says that the combobox itself is labelled directly by the associated label. The button can however be labelled by the label or itself.

* Add active descendant to combobox/input

* Add listbox role to comobox options

Right now the option list *is* just a listbox. If we were to allow other types in the future this will need to be changable

* Update tests

* move React playground to dedicated package

* add react playground script to root

* ensure we only open/close the combobox when necessary

* ensure export order is correct

* remove leftover pages directory from React package

* Only add aria controls when combobox is open

* add missing next commands

* make typescript happy

* build @headlessui/react before building playground-react

* add empty public folder

This makes vercel happy

* wip

* Add todo

* Update tests

Still more updates to do but some are blocked on implementation

* change default combobox example slightly

* ensure that we sync the input with new state

When the <Combobox value={...} /> changes, then the input should change
as well.

* only sync the value with the input in a single spot

* WIP: object value to string

* WIP

* WIP

* WIP groups

* Add static search filtering to combobox

* Move mouse leave event to combobox

* Fix use in fragments

* Update

* WIP

* make all tests pass for the combobox in React

* remove unnecessary playground item

* remove listbox wip

* only fire change event on inputs

Potentially we also have to do this for all kinds of form inputs. But
this will do for now.

* disable combobox vue tests

* Fix vue typescript errors

* Vue tests WIP

* improve combobox playgrounds a tiny bit

* ensure to lookup the correct value

* make sure that we are using a div instead of a Fragment

* expose `activeItem`

This will be similar to `yourData[activeIndex]`, but in this case the
active option's data. Can probably rename this if necessary!

* Update comments

* Port react tests to Vue

* Vue tests WIP

* WIP

* Rename activeItem to activeOption

* Move display value to input

* Update playgrounds

* Remove static filtering

* Add tests for display value

* WIP Vue Tests

* WIP

* unfocus suite

* Cleanup react accessibility assertions code

* Vue WIP

* Cleanup errors in react interactions test utils

* Update vue implementation

closer :D

* Fix searching

* Update

* Add display value stubs

* Update tests

* move `<Combobox onSearch={} />` to `<Combobox.Input onChange={} />`

* use `useLatestValue` hook

* make `onChange` explicitly required

* remove unused variables

* move `<Combobox @search="" />` to `<ComboboxInput @change="" />`

* use correct event

* use `let` for consistency

* remove unnecessary hidden check

* implement displayValue for Vue

* update playground to reflect changes

* make sure that the activeOptionIndex stays correct

* update changelog

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2022-01-27 16:42:47 +01:00
Robin Malfait cae976a18b Remove playground (#1053)
* remove local testing playgrounds

* bump outdated packages
2022-01-19 16:51:09 +01:00
Robin Malfait 147963424a 1.4.3 2022-01-14 18:44:12 +01:00
Robin Malfait 2f987be5b9 bump to 1.4.2 2021-11-08 11:15:43 +01:00
Robin Malfait 452b2c2852 bump version to 1.4.1 2021-08-30 14:23:52 +02:00
Robin Malfait d25f80ae9d bump version to 1.4.0 2021-07-29 12:56:11 +02:00
Robin Malfait da314b6b79 bump version to 1.3.0 2021-06-21 11:47:06 +02:00
Robin Malfait e56dd07e16 Improve react peer deps (#622)
* ensure react-dom is also a peer dependency

Co-authored-by: =?UTF-8?q?S=C3=A9bastien=20Vanvelthem?= <belgattitude@gmail.com>

* prepare peer dependencies for React 18

* update changelog

Co-authored-by: =?UTF-8?q?S=C3=A9bastien=20Vanvelthem?= <belgattitude@gmail.com>
2021-06-15 17:48:41 +02:00
Dmitry Ishkov abe3e1b988 Support tree-shaking by enabling preserveModules (#602) 2021-06-15 11:55:13 +02:00
Robin Malfait d0e27ff25c Update react peer dependency version range (#544)
* update react peer dependency version range

* update changelog
2021-05-19 12:30:52 +02:00
Robin Malfait a8bbd0ecee bump versions 2021-05-10 12:08:05 +02:00
Robin Malfait 7d517f6413 bump versions 2021-04-28 10:34:50 +02:00
Robin Malfait 719db69123 bump version to 1.1.0 2021-04-26 15:47:43 +02:00
Robin Malfait 6722e9e79f bump version to 1.0! 2021-04-14 17:42:58 +02:00
Robin Malfait c88b53eac1 provide description in package.json
Also making sure that the README is being published.
2021-04-14 17:41:48 +02:00
Robin Malfait 67d09e1c27 bump versions 2021-04-02 15:22:35 +02:00
Robin Malfait 71730fea12 bump version 2021-02-11 19:39:44 +01:00