Commit Graph

253 Commits

Author SHA1 Message Date
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 186a4cfcef Improve typeahead search logic (#1051)
* improve typeahead search logic

This ensures that if you have 4 items:
- Alice
- Bob
- Charlie
- Bob

And you search for `b`, then you jump to the first `Bob`, but if yuo
search again for `b` then we used to go to the very first `Bob` because
we always searched from the top. Now we will search from the active item
and onwards. Which means that we will now jump to the second `Bob`.

* update changelog
2022-01-19 13:49:57 +01:00
Robin Malfait 2dd57f1cd3 Improve controlled Tabs behaviour (#1050)
* Append tests for Tab.Group's selectedIndex.

* ensure that we correctly use the incoming selectedIndex

* update changelog

Co-authored-by: Ryoga Kitagawa <ryoga.kitagawa@gmail.com>
2022-01-19 11:13:37 +01:00
Robin Malfait a37197694f Ensure correct order when conditionally rendering Menu.Item, Listbox.Option and RadioGroup.Option (#1045)
* ensure correct order in `Menu.Item`

* Update Vue version of menu component ordering issue

* ensure correct order of `Listbox.Option`s

* add test to verify that RadioGroup.Option order is correct

* ensure correct order of `ListboxOption`s

* cleanup

* add test to verify that `RadioGroupOption` order is correct

* update changelog

* use similar a,z signature compared to other places

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2022-01-18 16:05:01 +01:00
Robin Malfait 1affad1271 Simplify and improve overall structure (#1044)
* simplify CI and make it consistent with CI of tailwindcss

* add contributing guidelines

* use correct org name

* ensure `yarn lint` is fully passing without warnings

* add subject to change message for `insiders` build
2022-01-17 15:46:18 +01:00
Robin Malfait 0ce63d8f7f Next release (#1039)
* placeholder for next release

* improve consistency of changelog
2022-01-17 14:02:00 +01:00
Robin Malfait 147963424a 1.4.3 2022-01-14 18:44:12 +01:00
Robin Malfait 1b85bc89ea update changelog 2022-01-14 18:42:32 +01:00
Robin Malfait b0d8f5f756 cleanup older changelog items 2022-01-14 18:42:13 +01:00
Robin Malfait 3bc7545169 Next release (#916)
* placeholder for next release

* Ensure portal root exists in the DOM (#950)

* ensure that the portal root is always in the DOM

When using NextJS, it happens that between page transitions the portal
root gets removed form the DOM. We will check the DOM when the `target`
updates, and if it doesn't exist anymore, then we will re-insert it in
the DOM.

* update changelog

* Allow `Tabs` to be controllable (#970)

* feat(react): Allow Tab Component to be controlled

* fix falsy bug

`selectedIndex || defaultIndex` would result in the `defaultIndex` if
`selectedIndex` is set to 0. This means that if you have this code:

```js
<Tab.Group selectedIndex={0} defaultIndex={2} />
```

That you will never be able to see the very first tab, unless you
provided a negative value like `-1`.

`selectedIndex ?? defaultIndex` fixes this, since it purely checkes for
`undefined` and `null`.

* implemented controllable Tabs for Vue

* add dedicated test to ensure changing the defaultIndex has no effect

* update changelog

Co-authored-by: ChiefORZ <seb.schaffernak@gmail.com>

* Fix missing key binding in examples (#1036)

Co-authored-by: superDragon <xkloveme@gmail.com>

* Fix slice => splice typo in Vue Tabs component (#1037)

Co-authored-by: Ryan Gossiaux <ryan.gossiaux@gmail.com>

* update changelog

* Ensure correct DOM node order when performing focus actions (#1038)

* ensure that the order of DOM nodes is correct

When we are performing actions like `focusIn(list, Focus.First)` then we
have to ensrue that we are working with the correct list that is
properly sorted.

It can happen that the list of DOM nodes is out of sync. This can happen
if you have 3 Tabs, hide the second (which triggers an unmount and an
`unregister` of the Tab), then re-add the second item in the middle.
This will re-add the item to the end of the list instead of in the middle.

We can solve this by always sorting items when we are adding / removing
items, but this is a bit more error prone because it is easy to forget.
Instead we will sort it when performing the actual keyboard action.

If we didn't provide a list but an element, then we use a
getFocusableElements(element) function, but this already gives you a
correctly sorted list so we don't need to do that for this list.

* add tests to prove the correct order when performing actions

* cleanup code just for tests

It could still happen that this internal list is not ordered correctly
but that's not really a problem we just have the list to keep track of
things.

For our tests we now use the position from the DOM directly.

* update changelog

Co-authored-by: ChiefORZ <seb.schaffernak@gmail.com>
Co-authored-by: superDragon <xkloveme@gmail.com>
Co-authored-by: Ryan Gossiaux <ryan.gossiaux@gmail.com>
2022-01-14 18:38:14 +01:00
Jonathan Reinink e9e6aded54 Tweak wording in changelog (#917) 2021-11-08 08:21:01 -05:00
Robin Malfait 2f987be5b9 bump to 1.4.2 2021-11-08 11:15:43 +01:00
Robin Malfait 0252c6136e update GitHub action name 2021-11-08 11:14:12 +01:00
Robin Malfait ff60cfaf65 update changelog 2021-11-08 11:13:00 +01:00
Robin Malfait b67729e7f6 Merge pull request #826 from tailwindlabs/develop
Next release
2021-11-08 11:10:27 +01:00
Robin Malfait 39b164647f Fix type on Tabs component Vue (#912)
* add `tabs` example to Vue

* use useResolveButtonType for Tabs

* update changelog
2021-11-05 12:57:41 +01:00
Robin Malfait a472b7bbb7 update issue templates 2021-10-30 13:05:48 +02:00
Robin Malfait 259965546b update changelog 2021-10-29 11:44:42 +02:00
Vemund Santi c57eb60a26 Enable tree shaking in Vue package (#859) 2021-10-29 11:32:16 +02:00
Dany Castillo fd4669fbf7 Rely on initial state of Transition component (#882)
The `useId` hook causes a re-render in TransitionChild immediately after mount which triggers a transition by `initial` being false in the second re-render regardless of how `appear` was set.
2021-10-29 11:27:03 +02:00
Georges KABBOUCHI 9f638c9eb7 fix: vue ssr (#867)
closes #840
2021-10-20 18:23:41 +02:00
Robin Malfait fd9a2d20b2 Ensure interactability with Popover.Panel contents in static mode (#857)
* ensure interactability with Popover.Panel contents in static mode

* update changelog
2021-10-08 15:53:24 +02:00
Robin Malfait f9e0d30795 Add automated release workflows (#853)
This commit also contains new code introduced after the PR in #853 was
merged. I just squashed it all together to prevent noisy commits to try
and fix CI.

The funny thing is that now the final commit looks fairly stupid/simple
but it wasn't that easy as I would have liked.

1. Couldn't find a proper way to execute `npm version` using yarn
   workspaces. `yarn workspaces foreach npm version` would have worked
   if we were using Yarn 2 instead of Yarn 1.
2. Introducing `version` and `publish` scripts in both packages worked,
   but then the default `version` and `publish` were also executed.
3. Once I made the scripts unique (`npm-version`,  `npm-publish`) it
   worked~ish. The registry was always set to a yarnpkg registry, even
   if we set the registry in CI and in a local .npmrc file. My guess is
   that we are executing in a nested directory and therefore it didn't
   work.
4. Next, I found the `npm workspaces` option so that we can use that in
   addition to `yarn workspaces` 🙃
5. In CI of course this didn't work, because I was not using the same
   node version...
6. After everything worked, I did cleanup of the new scripts, and
   removed the introduced .npmrc files.
2021-10-08 11:18:53 +02:00
Robin Malfait aa1a48cbfe Use watchEffect instead of immediately using an event listener on window (#817)
* use `watchEffect` instead of immediately using an event listener on `window`

* update changelog
2021-09-17 13:52:18 +02:00
Robin Malfait 91b436ae7c Allow to click on elements inside a Dialog Overlay (#816)
* allow to click on elements inside a Dialog Overlay

* update changelog
2021-09-17 13:31:31 +02:00
Robin Malfait 33c5c6e412 Merge pull request #798 from tailwindlabs/stop-propagation-on-escape
Ensure we stop the event from propagating
2021-09-12 19:08:37 +02:00
Robin Malfait 7f55847afe update changelog 2021-09-12 18:44:20 +02:00
Robin Malfait 3ad86ad498 ensure we stop the event from propagating 2021-09-12 18:42:20 +02:00
Robin Malfait 452b2c2852 bump version to 1.4.1 2021-08-30 14:23:52 +02:00
Robin Malfait 997f83238b update changelog 2021-08-30 14:23:00 +02:00
Robin Malfait bd3bc6cc42 Merge pull request #713 from tailwindlabs/develop
Next release
2021-08-30 14:20:43 +02:00
Robin Malfait 3f14839c33 Warn instead of error when there are no focusable elements (#775)
* warn instead of error when there are no focusable elements

* update changelog

Co-authored-by: Krystof Rehacek <krystofee@gmail.com>
2021-08-30 13:48:49 +02:00
Robin Malfait b59c091030 Fix broken escape key behaviour (#754)
* fix broken `escape` key behaviour

We've "fixed" an issue when we had nested Dialogs ([#430](https://github.com/tailwindlabs/headlessui/pull/430)).
The `escape` would not close the correct Dialog. The issue here was with
the logic to know whether we were the last Dialog or not. The issue was
_not_ how we implemented the `close` functionality.

To make things easier, we moved the global window event to a scoped div
(the Dialog itself). While that fixed the nested Dialog issue, it
introduced this bug where `escape` would not close if you click on a
non-focusable element like a span in the Dialog.

Since that PR we did a bunch of improvements on how the underlying
"stacking" system worked.
This PR reverts to the "global" window event listener so that we can
still catch all of the `escape` keydown events.

Fixes: #524
Fixes: #693

* update changelog
2021-08-24 11:26:19 +02:00
Robin Malfait d60d2a558f Add Vue emit types (#712)
* Add Vue emit types

* ensure value is a boolean

Even though we only use `false` for now

* add Vue emit types for Tabs component

* update changelog

Co-authored-by: henribru <6639509+henribru@users.noreply.github.com>
2021-08-02 14:37:45 +02:00
Robin Malfait c1117840fd Only add type=button for real buttons (#709)
* add `{type:'button'}` only for buttons

We will try and infer the type based on the passed in `props.as` prop or
the default tag. However, when somebody uses `as={CustomComponent}` then
we don't know what it will render. Therefore we have to pass it a ref
and check if the final result is a button or not. If it is, and it
doesn't have a `type` yet, then we can set the `type` correctly.

* update changelog
2021-08-02 13:57:58 +02:00
Robin Malfait d25f80ae9d bump version to 1.4.0 2021-07-29 12:56:11 +02:00
Robin Malfait a4036d59f2 update changelog 2021-07-29 12:55:12 +02:00
Robin Malfait 819042e9ff Merge pull request #702 from tailwindlabs/develop
Next release
2021-07-29 12:53:17 +02:00
Robin Malfait 4f3c5fa90b update changelog 2021-07-28 14:44:47 +02:00
Robin Malfait 112270d206 Change Tabs api (#698)
* Change Tabs API (React)

| Before        | After        |
| ------------- | ------------ |
| `Tabs`        | `Tab.Group`  |
| `Tabs.List`   | `Tab.List`   |
| `Tabs.Tab`    | `Tab`        |
| `Tabs.Panels` | `Tab.Panels` |
| `Tabs.Panel`  | `Tab.Panel`  |

* Change Tabs API (Vue)

| Before       | After       |
| ------------ | ----------- |
| `Tabs`       | `TabGroup`  |
| `TabsList`   | `TabList`   |
| `TabsTab`    | `Tab`       |
| `TabsPanels` | `TabPanels` |
| `TabsPanel`  | `TabPanel`  |

* change playground example for Tabs (React)

* update changelog
2021-07-28 11:30:34 +02:00
Robin Malfait ba1bd524d1 Expose close functionality via render prop (#697)
* expose a `close` function via the render prop for the `Popover` and `Popover.Panel` components (React)

* expose a `close` function via the render prop for the `Disclosure` and `Disclosure.Panel` components (React)

* expose a `close` function via the render prop for the `Popover` and `PopoverPanel` components (Vue)

* expose a `close` function via the render prop for the `Disclosure` and `DisclosurePanel` components (Vue)
2021-07-26 16:07:47 +02:00
Robin Malfait e8303382dd move manual prop to correct spot in demo 2021-07-15 13:30:18 +02:00
Robin Malfait 0cc9728694 Add aria-orientation to the Listbox component (#683)
* add `aria-orientation` to the Listbox component

By default the `Listbox` will have an orientation of `vertical`. When
you pass the `horizontal` prop to the `Listbox` component then the
`aria-orientation` will be set to `horizontal`.

Additionally, we swap the previous/next keys:

- Vertical: ArrowUp/ArrowDown
- Horizontal: ArrowLeft/ArrowRight

* update changelog
2021-07-13 23:36:15 +02:00
Robin Malfait 10110a928f Add ability to use Disclosure.Button inside a Disclosure.Panel (#682)
* add ability to use `Disclosure.Button` inside a `Disclosure.Panel`

If you do it this way, then the `Disclosure.Button` will function as a
`close` button.

This will make it consistent with the `Popover.Button` inside the
`Popover.Panel` funcitonality.

* update changelog
2021-07-13 19:29:29 +02:00
Robin Malfait 9af04a0a7e add Tabs component (#674)
* add `Tabs` component (React)

* expose `Tabs` component (React)

* add `Tabs` example (React)

* add `Tabs` component (Vue)

* expose `Tabs` component (Vue)

* update changelog
2021-07-13 19:23:55 +02:00
Robin Malfait b961a189d5 improve changelog 2021-06-22 12:29:59 +02:00
Robin Malfait 1ec5e74689 improve changelog 2021-06-22 12:29:39 +02:00
Robin Malfait da314b6b79 bump version to 1.3.0 2021-06-21 11:47:06 +02:00