@itenthusiasm/custom-elements 0.9.0 → 1.0.0
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.
- package/CheckboxGroup/CheckboxGroup.js +3 -1
- package/CheckboxGroup/README.md +8 -2
- package/README.md +3 -0
- package/package.json +1 -1
|
@@ -283,7 +283,9 @@ class CheckboxGroup extends HTMLElement {
|
|
|
283
283
|
else if (rangeUnderflow) message = this.rangeUnderflowError;
|
|
284
284
|
else if (valueMissing) message = this.valueMissingError;
|
|
285
285
|
else if (rangeOverflow) message = this.rangeOverflowError;
|
|
286
|
-
|
|
286
|
+
|
|
287
|
+
const anchor = message ? /** @type {HTMLInputElement} */ (this.fieldset.elements[0]) : undefined;
|
|
288
|
+
this.#internals.setValidity({ valueMissing, rangeUnderflow, rangeOverflow, customError }, message, anchor);
|
|
287
289
|
}
|
|
288
290
|
|
|
289
291
|
/* ------------------------------ Form Control Callbacks ------------------------------ */
|
package/CheckboxGroup/README.md
CHANGED
|
@@ -147,8 +147,8 @@ Some JS frameworks (such as React) may get confused if you remove elements from
|
|
|
147
147
|
|
|
148
148
|
```tsx
|
|
149
149
|
import { useState, useEffect } from "react";
|
|
150
|
-
import type {} from "@itenthusiasm/custom-elements/react";
|
|
151
|
-
// Or import type {} from "@itenthusiasm/custom-elements/CheckboxGroup/react";
|
|
150
|
+
import type {} from "@itenthusiasm/custom-elements/types/react";
|
|
151
|
+
// Or import type {} from "@itenthusiasm/custom-elements/CheckboxGroup/types/react";
|
|
152
152
|
|
|
153
153
|
interface CheckboxGroupProps extends React.ComponentProps<"checkbox-group"> {
|
|
154
154
|
label?: string;
|
|
@@ -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.
|
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><input></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