Skip to content
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(conform-dom,conform-react): new list control commands #14

Merged
merged 6 commits into from
Jul 18, 2022

Conversation

edmundhung
Copy link
Owner

@edmundhung edmundhung commented Jul 16, 2022

Context

The useFieldList hook returns a FieldListControl object which can be used to configure a button that can manipulate the field list. But it only covers some basic usages. This PR updates its behaviour which:

  1. Add support of 2 new commands: replace and reorder.
  2. Accept an optional defaultValue for both append and prepend

Examples

// To append a new row with optional defaultValue
<button {...controls.append(defaultValue)}>Append</button>;

// To prepend a new row with optional defaultValue
<button {...controls.prepend(defaultValue)}>Prepend</button>;

// To remove a row by index
<button {...controls.remove(index)}>Remove</button>;

// To replace a row with another defaultValue
<button {...controls.replace(index, defaultValue)}>Replace</button>;

// To reorder a particular row to an another index
<button {...controls.reorder(fromIndex, toIndex)}>Reorder</button>;

@edmundhung edmundhung force-pushed the more-list-control-command branch from bb92330 to b6a9120 Compare July 16, 2022 11:35
@edmundhung edmundhung changed the title feat: new list control commands feat(conform-dom,conform-react): new list control commands Jul 16, 2022
@edmundhung edmundhung force-pushed the more-list-control-command branch from c62cd66 to 968e4d0 Compare July 17, 2022 15:51
@edmundhung edmundhung force-pushed the more-list-control-command branch from 20812c6 to 23f1170 Compare July 18, 2022 05:55
@edmundhung edmundhung force-pushed the more-list-control-command branch from 3d4e06c to f249164 Compare July 18, 2022 18:10
@edmundhung edmundhung marked this pull request as ready for review July 18, 2022 18:31
@edmundhung edmundhung merged commit e3d65e5 into main Jul 18, 2022
@edmundhung edmundhung deleted the more-list-control-command branch July 18, 2022 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant