-
Notifications
You must be signed in to change notification settings - Fork 11
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
Typescript #47
Open
pjm17971
wants to merge
27
commits into
master
Choose a base branch
from
typescript
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Typescript #47
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
Still lots to do as this only includes and has storybook stuff for the textedit control. But the main code base (Form, List, etc) now builds in Typescript. Uses rollup for the build. Updates everything to latest versions.
Note that I had to fix the storybook version because the next patch version is currently broken. "@storybook/react": "5.3.10"
…he user For example, the user would add a TextEdit control to a form, but when that is rendered it has a set of props added to it. At that point it becomes a TextEditControl (wrapped in a formGroup). This lets us be clearer about types. Also added a ChooserControl etc. Still some work to do on that, it's just the most basic implementation with the new react-select api.
Adds displayView prop which can either be a string or a function that returns a React Element. Like the previous view prop, this is used to show specialized rendering for the chooser when data is not loaded yet. Added an example of the chooser async loading data when the inline editing is triggered and then selecting by search from a large list.
DateEditControl can now constain choice to specific date ranges. It can also select a time along side the date. Finally there's an option to select just a month.
Also start filling out form examples
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.
DO NOT MERGE
TODO Checklist
Transition Guide
displayView
rather thanview
. ForChooser
s with async loading it is necessary to implementdisplayView
to return the current item label because the Chooser will not know the item label until the list of items is loaded.Chooser
is implemented on react-select 2.x. Some props have been aligned to this API:isDisabled
replacesdisabled
,isSearchable
replacesdisableSearch
andisClearable
replacesallowSingleDeselect
.Async Chooser
This PR adds Async Chooser functionality, allowing the Chooser to request data when it is displayed. The most likely use for this would be for inline editing. The Chooser would display a text value for the selected item until the user opted to edit it. At that point the user would see a spinner within the Chooser and the component would request data. When the data is loaded the user can then select from the list as usual.
Here is a Chooser that would be nested inside a Form:
Note two special things here: the use of
choiceLoader
and the use ofdisplayView
.The
choiceLoader
is a function:Here we're using a
setTimeout
to simulate an async fetch operation. Note that this function will be called whenever the filter (search string) is changed, so this means you can either fetch based on that filter if the backend supports that, or cache the full list so you can return just the filtered set derived from the cache rather than repeatedly fetching.The other things to keep in mind with async chooser fetching is that the Chooser will not know what label to display for an item in the list that isn't loaded yet. Therefore you need to use
displayView
to provide that. In this case we grab it from the original list, but ideally you'd load that as part of the form initial state.Help facility
You can now specify a help string in the Schema that will be displayed along side each field. An icon indicates the presence of help. Hovering over the icon will display the help text. Help text can be markdown.
Switch control
For boolean values (on/off) you can use the new Switch control. The value passed to the switch control will be 0 or 1. The control will show a label next to both states that defaults to On and Off. You can customize that by passing
options
to the switch, which is a two element array ["deactivated", "activated"] and these labels will be shown instead. When the control is in view only mode these labels will also be used for the display text. As with other controls you can pass in adisplayView
prop to customize this, either with alternative text or with a function.Date edit control
The DateEdit control has been updated to the latest version of react-datepicker, which is considerably more robust than previous versions. As part of that change you can now specify
minDate
andmaxDate
props to constrain the picker. You can also select both a Date and Time using thetimePicker
bool prop. Finally you can select just a month with themonthPicker
prop.