forked from megafetis/vue3-treeselect
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add defineExpose to Treeselect component #2
Open
elizabeth011685
wants to merge
1
commit into
r2rka1:main
Choose a base branch
from
elizabeth011685:feature/expose-clear-method
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
Add defineExpose to Treeselect component #2
elizabeth011685
wants to merge
1
commit into
r2rka1:main
from
elizabeth011685:feature/expose-clear-method
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
Integrated defineExpose to the Treeselect component to expose the clear method. This change facilitates external access to the method, improving component flexibility and reusability.
@elizabeth011685 const instance = computed(() => ({
name: props.name || 'vue-treeselect',
hasValue: hasValue,
trigger: state.trigger,
forest: state.forest,
localSearch: state.localSearch,
remoteSearch: state.remoteSearch,
isReady: state.isReady,
rootOptionsStates: state.rootOptionsStates,
internalValue: internalValue,
selectedNodes: selectedNodes,
$slots: slots,
$refs: {
control: control.value,
wrapper: wrapper.value,
portal: portal.value,
menu: rmenu.value,
},
menu: state.menu,
single: single,
verifyProps,
resetFlags,
initialize,
getInstanceId,
getValue,
getNode,
createFallbackNode,
extractCheckedNodeIdsFromValue,
extractNodeFromValue,
fixSelectedNodeIds,
keepDataOfSelectedNodes,
isSelected,
traverseDescendantsBFS,
traverseDescendantsDFS,
traverseAllNodesDFS,
traverseAllNodesByIndex,
toggleClickOutsideEvent,
getValueContainer,
getInput,
focusInput,
blurInput,
handleMouseDown,
handleClickOutside,
handleLocalSearch,
getRemoteSearchEntry,
shouldExpand,
shouldOptionBeIncludedInSearchResult,
shouldShowOptionInMenu,
getControl,
getMenu,
setCurrentHighlightedOption,
resetHighlightedOptionWhenNecessary,
highlightFirstOption,
highlightPrevOption,
highlightNextOption,
highlightLastOption,
resetSearchQuery,
closeMenu,
openMenu,
toggleMenu,
toggleExpanded,
buildForestState,
enhancedNormalizer,
normalize,
loadRootOptions,
loadChildrenOptions,
callLoadOptionsProp,
checkDuplication,
verifyNodeShape,
select,
clear,
_selectNode,
_deselectNode,
addValue,
removeValue,
removeLastValue,
saveMenuScrollPosition,
restoreMenuScrollPosition,
handleRemoteSearch,
allowClearingDisabled: props.allowClearingDisabled,
allowSelectingDisabledDescendants: props.allowSelectingDisabledDescendants,
alwaysOpen: props.alwaysOpen,
appendToBody: props.appendToBody,
async: props.async,
autoFocus: props.autoFocus,
autoLoadRootOptions: props.autoLoadRootOptions,
autoDeselectAncestors: props.autoDeselectAncestors,
autoDeselectDescendants: props.autoDeselectDescendants,
autoSelectAncestors: props.autoSelectAncestors,
autoSelectDescendants: props.autoSelectDescendants,
backspaceRemoves: props.backspaceRemoves,
beforeClearAll: props.beforeClearAll,
branchNodesFirst: props.branchNodesFirst,
cacheOptions: props.cacheOptions,
clearable: props.clearable,
clearAllText: props.clearAllText,
clearOnSelect: props.clearOnSelect,
clearValueText: props.clearValueText,
closeOnSelect: props.closeOnSelect,
defaultExpandLevel: props.defaultExpandLevel,
defaultOptions: props.defaultOptions,
deleteRemoves: props.deleteRemoves,
delimiter: props.delimiter,
flattenSearchResults: props.flattenSearchResults,
disableBranchNodes: props.disableBranchNodes,
disabled: props.disabled,
disableFuzzyMatching: props.disableFuzzyMatching,
flat: props.flat,
instanceId: instanceId,
joinValues: props.joinValues,
limit: props.limit,
limitText: props.limitText,
loadingText: props.loadingText,
loadOptions: props.loadOptions,
matchKeys: props.matchKeys,
maxHeight: props.maxHeight,
multiple: props.multiple,
noChildrenText: props.noChildrenText,
noOptionsText: props.noOptionsText,
noResultsText: props.noResultsText,
normalizer: props.normalizer,
openDirection: props.openDirection,
openOnClick: props.openOnClick,
openOnFocus: props.openOnFocus,
options: props.options,
})) |
I think we should look for a better way to expose API. For instance - one possible solution would be to return an API object on @ready event. @elizabeth011685 @Alexbrazdasilva <tree-select @ready="handleOnReady" />
// ...
const treeselectApi = ref(null);
const handleOnReady = (api) => {
treeselectApi.value = api
}
// ...
const myMethod = () => {
// ...
treeselectApi.value.clear()
} |
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.
Integrated defineExpose to the Treeselect component to expose the clear method. This change facilitates external access to the method, improving component flexibility and reusability.