-
Notifications
You must be signed in to change notification settings - Fork 269
feat: Prefix instance id when custom node id is passed #325
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
Open
mrchief
wants to merge
8
commits into
main
Choose a base branch
from
feat/prefix-clientId-on-custom-id
base: main
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
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f4ce73c
fix: Backspace doesn't raise onTagRemove event
mrchief a100034
fix: Prefix instance id in case of custom node id
mrchief c604dc8
Merge branch 'develop' into feat/prefix-clientId-on-custom-id
mrchief 2570381
Merge branch 'develop' into feat/prefix-clientId-on-custom-id
mrchief e657735
Merge branch 'develop' into feat/prefix-clientId-on-custom-id
mrchief 51ecdb7
Merge branch 'develop' into feat/prefix-clientId-on-custom-id
mrchief a4ecace
Merge branch 'develop' into feat/prefix-clientId-on-custom-id
mrchief 588d40c
Merge branch 'develop' into feat/prefix-clientId-on-custom-id
mrchief File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Represents a tree node (not DOM node) in the data tree. | ||
* It can have the following properties: | ||
* | ||
* id {string|optional} User defined id, comes from `data` passed to the component. | ||
* _id {string} Internal id, auto generated if `id` is not defined, otherwise set to `id`. | ||
* rootPrefixId {string} The id of the component's instance. | ||
* parent {Node} Parent node, if a child. | ||
* label {string|required} Checkbox label | ||
* value {string|required} Checkbox value | ||
* children {array<node>|optional} Array of child nodes | ||
* checked {bool|optional} Initial state of checkbox. if true, checkbox is selected and corresponding pill is rendered. | ||
* disabled {bool|optional} Selectable state of checkbox. if true, the checkbox is disabled and the node is not selectable. | ||
* expanded {bool|optional} If true, the node is expanded (children of children nodes are not expanded by default unless children nodes also have expanded: true). | ||
* className {string|optional} Additional css class for the node. This is helpful to style the nodes your way | ||
* tagClassName {string|optional} Css class for the corresponding tag. Use this to add custom style the pill corresponding to the node. | ||
* actions {array<object>|optional} An array of extra action on the node (such as displaying an info icon or any custom icons/elements) | ||
* dataset {object|optional} Allows data-* attributes to be set on the node and tag elements | ||
* isDefaultValue {bool|optional} Indicate if a node is a default value. When true, the dropdown will automatically select the node(s) when there is no other selected node. Can be used on more than one node. | ||
* | ||
*/ | ||
export default class Node { | ||
constructor({ depth, rootPrefixId, parent, index, ...dataProps }) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function |
||
// first copy all props coming from data | ||
Object.assign(this, dataProps) | ||
|
||
// then assign basic ones | ||
this._depth = depth | ||
this.rootPrefixId = rootPrefixId | ||
|
||
if (parent) { | ||
this._id = this.id || `${parent._id}-${index}` | ||
this._parent = parent._id | ||
parent._children.push(this._id) | ||
} else { | ||
this._id = this.id || `${rootPrefixId ? `${rootPrefixId}-${index}` : index}` | ||
} | ||
} | ||
|
||
/** | ||
* Given an element, generate a DOM Id that's unique across instances | ||
*/ | ||
getDOMId = element => { | ||
// if user has defined id, then ensure it's unique across instances | ||
if (this.id) return `${this.rootPrefixId}_${this.id}_${element}` | ||
return `${this._id}_${element}` | ||
} | ||
} |
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.