feat(autocomplete-js): enable HTML templating#920
Merged
sarahdayan merged 29 commits intonextfrom Apr 7, 2022
Merged
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 40035ff:
|
628e069 to
78a0479
Compare
74e16bf to
91940e5
Compare
sarahdayan
commented
Mar 31, 2022
91940e5 to
11c7922
Compare
sarahdayan
commented
Mar 31, 2022
sarahdayan
commented
Mar 31, 2022
sarahdayan
commented
Mar 31, 2022
Haroenv
reviewed
Apr 1, 2022
Haroenv
approved these changes
Apr 4, 2022
3742273 to
f7c51d6
Compare
Haroenv
approved these changes
Apr 6, 2022
Member
Author
|
I'll merge once the docs are ready (so we don't hog potential bug fixes if needed in the meantime). |
|
Hi @sarahdayan! I have problem like this 1209 |
|
Solution! |
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
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.
This PR introduces HTML templating to Autocomplete.
Try HTML templates in the sandbox →
Summary
The
autocomplete-jspackage is an agnostic virtual DOM renderer, to be used in JavaScript, Preact, React, or Vue projects. It expects virtual nodes to describe UIs, which means Autocomplete users are expected to provide templates as virtual node trees.Building virtual nodes can be done either with
createElement(provided in every template) or using JSX. However, none of these options are user-friendly to vanilla JavaScript users, especially those who don't have a build step.HTML templating in Autocomplete allows users to:
createElementfunction or on JSX__dangerouslySetInnerHTMLto provide HTML templatesUnder the hood,
autocomplete-jsstill uses a virtual DOM. It still works with JSX andcreateElement, and still provides the same speed and safety for all template usages.Usage
Templates now expose an
htmlfunction. This function is a tagged template, which lets users provide templates as interpolated strings. This generates a virtual node tree (just like JSX orcreateElement) while providing a simple HTML string.One benefit over classic HTML templates injected in a container is that these templates accept inline event handlers (e.g.,
onClick), just like JSX. It facilitates interactivity and garbage collection of event handlers in many situations.The
htmlfunction is also available in therenderandrenderNoresultsoptions, so users can customize the layout of their Autocomplete panel before rendering. Both options also expose arenderfunction, so there's no need to install any virtual DOM dependency at all on the user's end.IE 11 compatibility
Tagged templates aren't compatible with Internet Explorer 11, but there are ways to use the
htmlfunction in IE 11. If you need to support IE 11, please refer to the Autocomplete templates documentation to either transform your code, or use an IE 11-compatible shim.