@itenthusiasm/custom-elements 0.9.1 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -172,6 +172,8 @@ export default function CheckboxGroup({ label, children, ...rest }: CheckboxGrou
172
172
 
173
173
  Notice the [`manual`](#attributes-manual) attribute that was applied to the `<checkbox-group>`. This tells the component _not_ to remove or add any children on its own, giving developers the freedom to make such modifications themselves. Note that the `CheckboxGroup` will still perform other automated actions unrelated to DOM insertion/removal in this mode, such as altering the `name` and `form` attributes of every `checkbox` inserted into it. These other actions are all safe for JS frameworks.
174
174
 
175
+ If your application is a SPA, then you don't need to be concerned about progressive enhancement, and you can just structure your code in a manner similar to what was shown at the [beginning](#quickstart) of this document.
176
+
175
177
  ## TypeScript Usage in JS Frameworks
176
178
 
177
179
  Many JS frameworks, such as Svelte and React, often define their own "Element Namespaces". Because of this, most frameworks are not able (on their own) to recognize the correct attributes, properties, and event listeners that belong to the Custom Elements which you use. Thankfully, our library ships with TypeScript types that tell the various JS Frameworks about the existence and shape of our Custom Elements. To define _all_ of our library's Custom Elements within a Framework's "Element Namespace", simply import the appropriate type definition file:
@@ -544,3 +546,7 @@ As a Custom Element, the <code>CheckboxGroup</code> supports all of the events f
544
546
  <p>Identical to the <a href="#events-input"><code>input</code></a> event, but fired <em>after</em> the <code>input</code> event.</p>
545
547
  </dd>
546
548
  </dl>
549
+
550
+ ## What's Next?
551
+
552
+ You've learned everything that you need to know about the `CheckboxGroup` component. Now, it's time for you to try it out in one of your own applications! We've provided a [StackBlitz Demo](https://stackblitz.com/edit/custom-elements-checkbox-group?file=register-custom-elements.js,index.html) to help you get more familiar with the component as well if needed.
@@ -1185,9 +1185,11 @@ class ComboboxField extends HTMLElement {
1185
1185
  const mutation = mutations[i];
1186
1186
 
1187
1187
  // Handle added nodes first. This keeps us from running redundant Deselect Logic if a newly-added node is `selected`.
1188
- mutation.addedNodes.forEach((node, j) => {
1189
- if (!(node instanceof ComboboxOption)) return node.parentNode?.removeChild(node);
1188
+ mutation.addedNodes.forEach((n, j) => {
1189
+ if (!(n instanceof ComboboxOption) && n instanceof Element) return n.parentNode?.removeChild(n);
1190
1190
 
1191
+ // TODO: TypeScript fails to derive the correct type from the above check. Open a GitHub Issue.
1192
+ const node = /** @type {ComboboxOption} */ (n);
1191
1193
  if (node.defaultSelected) this.value = node.value;
1192
1194
  else if (nullable && this.#value === null && j === 0) {
1193
1195
  if (this.valueIs !== "clearable") this.value = node.value;
package/README.md CHANGED
@@ -44,5 +44,8 @@ Below are the components that this library currently provides. Each component ha
44
44
  <p>
45
45
  Wraps a semantic group of checkbox <code>&lt;input&gt;</code> elements, progressively enhancing them with convenient features like group-level form validation and value management. The <code>CheckboxGroup</code> component behaves just like the native form controls, meaning that it dispatches the standard <code>input</code>/<code>change</code> events, is <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/elements">associated</a> with its owning form, and automatically participates in all form activity, <a href="https://web.dev/articles/more-capable-form-controls">including form submission</a>.
46
46
  </p>
47
+ <p>
48
+ <a href="https://stackblitz.com/edit/custom-elements-checkbox-group?file=register-custom-elements.js,index.html">Stackblitz Demo</a>
49
+ </p>
47
50
  </dd>
48
51
  </dl>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@itenthusiasm/custom-elements",
3
3
  "type": "module",
4
- "version": "0.9.1",
4
+ "version": "1.0.1",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",
7
7
  "description": "Robust, accessible, and progressively-enhanceable Web Components for common developer needs",