generated from neoncitylights/typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add type definitions for @observablehq/inputs #12
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- adds unit tests for format function utils, button(), and checkbox() - fixes formatting functions to accept locales, and return a function that returns a string, instead of directly returning a string - fix OhqInputFormatFn to also accept an optional index (2nd argument) and an optional array (3rd argument)
neoncitylights
changed the title
feat: add type declarations for @observablehq/inputs
feat: add type definitions for @observablehq/inputs
Jul 22, 2023
- make types properly use generics for `OhqInputSort<T>` and `OhqInputFormatFn<T>` - allow button to also accept `HTMLElement` type for content - add method overloading for the following methods: `form()`, `button()`, and `checkbox()`, `radio()`, `select()`. This allows for accepting arrays and Map instances. - rename `button.test.ts` to `buttons.test.ts` - add unit tests for checkbox, date/datetime, form, radio, and number inputs - move form unit tests outside of utility unit tests
Instances of
Instances of
|
Other fixes: - `OhqInputSearchOptions<T>` - fixes `query` property to only be a `string` instead of `string|string[]` - fixes `filter` property to not be unknown anymore, to match function signature of `searchFilter<T>()` - `OhqInputTableOptions<T>`: fixes `header` property, where the key value itself can either be a `string` or `HTMLElement`
This adds higher-level support to the `multiple` property. Some other property types change or are only accessible based on the value of the `multiple` property. For example: - It is only possible to set `size` as a number if `multiple` is true - It is only possible to set `value` as an array of strings if `multiple` is true or a number
- `OhqInputToggleOptions<T>`: Fix `values` property to only accept a 2-tuple of the same type - `OhqInputRadioOptions<T>`: Fix any usage in `value` property - `OhqInputSearchOptions<T>`: Fix any usage in `datalist` property - `OhqTableOptions<T>`: Fix unknown usage in `value` property - `OhqInputTextOptions`: Fix unknown usage in `datalist` property
See: - https://html.spec.whatwg.org/multipage/input.html#the-min-and-max-attributes - https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/min - https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/max While this type is constrained by the value of `type`, support for typing this through a discriminated union will be added in the future.
Type fix for `OhqInputTextOptions<T>` - now can only use a certain data type for `min`/`max` depending of the `type` value.
WOOHOO, last on the checklist
19 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #32
date()
anddatetime()
inputsfileOf()
searchFilter()
textarea()
OhqInputSelectOptions
withmultiple
,size
, andvalue
propertiesOhqInputTextOptions
withtype
andmin
/max
autocapitalize
property inOhqInputTextOptions
,OhqInputSearchOptions
autocomplete
property inOhqInputTextOptions
,OhqInputSearchOptions
unknown
type where possibleany
type where possible