d03fbb19f5
* remove `nullable` prop
* prevent selecting active option on blur
+ cleanup and adjust comments
* remove nullable from comments
* bump TypeScript to 5.4
This gives us `NoInfer<T>`!
* simplify types of `Combobox`
Now that `nullable` is gone, we can take another look at the type
definition. This in combination with the new `NoInfer` type makes types
drastically simpler and more correct.
* re-add `nullable` to prevent type issues
But let's mark it as deprecated to hint that something changed.
* update changelog
* improve `ByComparator` type
If we are just checking for `T extends null`, then
`{id:1,name:string}|null` will also be true and therefore we would
eventually return `string` instead of `"id" | "name"`.
To solve this, we first check if `NonNullable<T> extends never`, this
would be the case if `T` is `null`.
Otherwise, we know it's not just `null` but it can be something else
with or without `null`. To be sure, we use `keyof NonNullable<null>` to
get rid of the `null` part and to only keep the rest of the object (if
it's an object).
* ensure the `by` prop type handles `multiple` values correctly
This way the `by` prop will still compare single values that are present
inside the array.
This now also solves a pending TypeScript issue that we used to `//
@ts-expect-error` before.
* type uncontrolled `Combobox` components correctly
We have some tests that use uncontrolled components which means that we
can't infer the type from the `value` type.
* simplify `onChange` calls
Now that we don't infer the type when using the generic inside of
`onChange`, it means that we can use `onChange={setValue}` directly
because we don't have to worry about the updater function of `setValue`
anymore.
* correctly type `onChange`, by adding `null`
If you are in single value mode, then the `onChange` can (and will)
receive `null` as a value (when you clear the input field). We never
properly typed it so this fixes that.
In multiple value mode this won't happen, if anything the value will be
`[]` but not `null`.
* remove `nullable` prop from playground
* drop `nullable` mentions in tests
69 lines
2.0 KiB
JSON
69 lines
2.0 KiB
JSON
{
|
|
"name": "headlessui",
|
|
"version": "0.0.0",
|
|
"description": "Headless UI components for various libraries like React and Vue",
|
|
"main": "index.js",
|
|
"repository": "https://github.com/tailwindlabs/headlessui",
|
|
"license": "MIT",
|
|
"private": true,
|
|
"workspaces": [
|
|
"packages/*",
|
|
"playgrounds/*"
|
|
],
|
|
"scripts": {
|
|
"react": "npm run --workspace=@headlessui/react",
|
|
"react-playground": "npm run --workspace=playground-react dev",
|
|
"playground-react": "npm run --workspace=playground-react dev",
|
|
"vue": "npm run --workspace=@headlessui/vue",
|
|
"playground-vue": "npm run --workspace=playground-vue dev",
|
|
"vue-playground": "npm run --workspace=playground-vue dev",
|
|
"clean": "npm run clean --workspaces --if-present",
|
|
"build": "npm-run-all -p 'react build' 'vue build'",
|
|
"test": "./scripts/test.sh",
|
|
"lint": "./scripts/lint.sh",
|
|
"lint-check": "CI=true ./scripts/lint.sh",
|
|
"lint-types": "CI=true npm run lint-types --workspaces --if-present",
|
|
"release-channel": "node ./scripts/release-channel.js",
|
|
"release-notes": "node ./scripts/release-notes.js",
|
|
"package-path": "node ./scripts/package-path.js"
|
|
},
|
|
"husky": {
|
|
"hooks": {
|
|
"pre-commit": "lint-staged"
|
|
}
|
|
},
|
|
"lint-staged": {
|
|
"*": "npm run lint"
|
|
},
|
|
"prettier": {
|
|
"printWidth": 100,
|
|
"semi": false,
|
|
"singleQuote": true,
|
|
"trailingComma": "es5",
|
|
"plugins": [
|
|
"prettier-plugin-organize-imports",
|
|
"prettier-plugin-tailwindcss"
|
|
]
|
|
},
|
|
"devDependencies": {
|
|
"@arethetypeswrong/cli": "^0.13.3",
|
|
"@swc-node/register": "^1.6.8",
|
|
"@swc/core": "^1.2.131",
|
|
"@swc/jest": "^0.2.17",
|
|
"@testing-library/jest-dom": "^5.16.4",
|
|
"@types/node": "^14.14.22",
|
|
"esbuild": "^0.17.8",
|
|
"fast-glob": "^3.2.11",
|
|
"husky": "^4.3.8",
|
|
"jest": "26",
|
|
"lint-staged": "^12.2.1",
|
|
"npm-run-all": "^4.1.5",
|
|
"prettier": "^3.1.0",
|
|
"prettier-plugin-organize-imports": "^3.2.4",
|
|
"prettier-plugin-tailwindcss": "^0.5.7",
|
|
"rimraf": "^3.0.2",
|
|
"tslib": "^2.3.1",
|
|
"typescript": "^5.4.3"
|
|
}
|
|
}
|