@leve-ui/field 0.1.0 → 0.2.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/lib/field-error-message.qwik.cjs +1 -0
- package/lib/field-error-message.qwik.mjs +1 -0
- package/lib/field-input.qwik.cjs +2 -1
- package/lib/field-input.qwik.mjs +2 -1
- package/lib/field-root.qwik.cjs +2 -1
- package/lib/field-root.qwik.mjs +3 -2
- package/lib/field-textarea.qwik.cjs +2 -1
- package/lib/field-textarea.qwik.mjs +2 -1
- package/lib-types/field-error-message.d.ts +5 -0
- package/lib-types/field-input.d.ts +8 -2
- package/lib-types/field-root.d.ts +18 -2
- package/lib-types/field-textarea.d.ts +7 -1
- package/package.json +2 -2
package/lib/field-input.qwik.cjs
CHANGED
|
@@ -5,8 +5,9 @@ const qwik = require("@builder.io/qwik");
|
|
|
5
5
|
const utils = require("@leve-ui/utils");
|
|
6
6
|
const FieldInput = qwik.component$(({ "bind:value": bindValue, "bind:checked": bindChecked, ...props }) => {
|
|
7
7
|
const control = utils.useFieldControl(props);
|
|
8
|
+
const { invalid: _invalid, ...elementProps } = props;
|
|
8
9
|
const commonProps = {
|
|
9
|
-
...
|
|
10
|
+
...elementProps,
|
|
10
11
|
id: control.value.id,
|
|
11
12
|
"aria-describedby": control.value.describedBy,
|
|
12
13
|
"aria-invalid": control.value.invalid ? "true" : void 0,
|
package/lib/field-input.qwik.mjs
CHANGED
|
@@ -3,8 +3,9 @@ import { component$ } from "@builder.io/qwik";
|
|
|
3
3
|
import { useFieldControl, dataAttr } from "@leve-ui/utils";
|
|
4
4
|
const FieldInput = component$(({ "bind:value": bindValue, "bind:checked": bindChecked, ...props }) => {
|
|
5
5
|
const control = useFieldControl(props);
|
|
6
|
+
const { invalid: _invalid, ...elementProps } = props;
|
|
6
7
|
const commonProps = {
|
|
7
|
-
...
|
|
8
|
+
...elementProps,
|
|
8
9
|
id: control.value.id,
|
|
9
10
|
"aria-describedby": control.value.describedBy,
|
|
10
11
|
"aria-invalid": control.value.invalid ? "true" : void 0,
|
package/lib/field-root.qwik.cjs
CHANGED
|
@@ -5,7 +5,8 @@ const qwik = require("@builder.io/qwik");
|
|
|
5
5
|
const utils = require("@leve-ui/utils");
|
|
6
6
|
const FieldRoot = qwik.component$(({ ids, invalid, disabled, required, hasDescription, ...props }) => {
|
|
7
7
|
const invalidSignal = qwik.useComputed$(() => !!invalid);
|
|
8
|
-
const
|
|
8
|
+
const fieldset = utils.useFieldsetContext();
|
|
9
|
+
const disabledSignal = qwik.useComputed$(() => !!disabled || !!fieldset?.disabled.value);
|
|
9
10
|
const requiredSignal = qwik.useComputed$(() => !!required);
|
|
10
11
|
const hasDescriptionSignal = qwik.useComputed$(() => !!hasDescription);
|
|
11
12
|
const context = utils.useFieldProvider({
|
package/lib/field-root.qwik.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx } from "@builder.io/qwik/jsx-runtime";
|
|
2
2
|
import { component$, useComputed$, Slot } from "@builder.io/qwik";
|
|
3
|
-
import { useFieldProvider, dataAttr } from "@leve-ui/utils";
|
|
3
|
+
import { useFieldsetContext, useFieldProvider, dataAttr } from "@leve-ui/utils";
|
|
4
4
|
const FieldRoot = component$(({ ids, invalid, disabled, required, hasDescription, ...props }) => {
|
|
5
5
|
const invalidSignal = useComputed$(() => !!invalid);
|
|
6
|
-
const
|
|
6
|
+
const fieldset = useFieldsetContext();
|
|
7
|
+
const disabledSignal = useComputed$(() => !!disabled || !!fieldset?.disabled.value);
|
|
7
8
|
const requiredSignal = useComputed$(() => !!required);
|
|
8
9
|
const hasDescriptionSignal = useComputed$(() => !!hasDescription);
|
|
9
10
|
const context = useFieldProvider({
|
|
@@ -5,8 +5,9 @@ const qwik = require("@builder.io/qwik");
|
|
|
5
5
|
const utils = require("@leve-ui/utils");
|
|
6
6
|
const FieldTextarea = qwik.component$(({ "bind:value": bindValue, ...props }) => {
|
|
7
7
|
const control = utils.useFieldControl(props);
|
|
8
|
+
const { invalid: _invalid, ...elementProps } = props;
|
|
8
9
|
const commonProps = {
|
|
9
|
-
...
|
|
10
|
+
...elementProps,
|
|
10
11
|
id: control.value.id,
|
|
11
12
|
"aria-describedby": control.value.describedBy,
|
|
12
13
|
"aria-invalid": control.value.invalid ? "true" : void 0,
|
|
@@ -3,8 +3,9 @@ import { component$ } from "@builder.io/qwik";
|
|
|
3
3
|
import { useFieldControl, dataAttr } from "@leve-ui/utils";
|
|
4
4
|
const FieldTextarea = component$(({ "bind:value": bindValue, ...props }) => {
|
|
5
5
|
const control = useFieldControl(props);
|
|
6
|
+
const { invalid: _invalid, ...elementProps } = props;
|
|
6
7
|
const commonProps = {
|
|
7
|
-
...
|
|
8
|
+
...elementProps,
|
|
8
9
|
id: control.value.id,
|
|
9
10
|
"aria-describedby": control.value.describedBy,
|
|
10
11
|
"aria-invalid": control.value.invalid ? "true" : void 0,
|
|
@@ -5,6 +5,11 @@ export type FieldErrorMessageProps = PropsOf<'div'>;
|
|
|
5
5
|
*
|
|
6
6
|
* 該当する APG パターンはないため、ネイティブの `<div>` を使用します。
|
|
7
7
|
* `Field.Root` が `invalid` の場合のみ描画されます。
|
|
8
|
+
*
|
|
9
|
+
* 表示されたときにスクリーンリーダーが読み上げるよう、`role="alert"` を出力します
|
|
10
|
+
* (WCAG 4.1.3 Status Messages)。要素ごと挿入されるため、挿入後に内容が変わることを
|
|
11
|
+
* 前提とする `aria-live` ではなく、挿入時に読み上げられる `alert` を使います。
|
|
12
|
+
* 割り込まずに読み上げたい場合は `role="status"` を渡して上書きできます。
|
|
8
13
|
*/
|
|
9
14
|
export declare const FieldErrorMessage: import("@builder.io/qwik").Component<{
|
|
10
15
|
align?: string | undefined;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { type PropsOf, type Signal } from '@builder.io/qwik';
|
|
2
2
|
export type FieldInputProps = PropsOf<'input'> & {
|
|
3
|
-
/**
|
|
3
|
+
/** A signal synced two-way with the input value. */
|
|
4
4
|
'bind:value'?: Signal<string>;
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Marks the control as invalid (`aria-invalid="true"`, `data-invalid`). Inside a
|
|
7
|
+
* Field, the control is also invalid while the Field is.
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
10
|
+
invalid?: boolean;
|
|
11
|
+
/** A signal synced two-way with the checked state (for checkbox and radio inputs). */
|
|
6
12
|
'bind:checked'?: Signal<boolean>;
|
|
7
13
|
};
|
|
8
14
|
/**
|
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
import { type PropsOf } from '@builder.io/qwik';
|
|
2
2
|
import { type FieldIds } from '@leve-ui/utils';
|
|
3
3
|
export type FieldRootProps = PropsOf<'div'> & {
|
|
4
|
-
/**
|
|
4
|
+
/** Overrides the element IDs of the parts. IDs can only be overridden here (adr/0024). */
|
|
5
5
|
ids?: Partial<FieldIds>;
|
|
6
|
+
/**
|
|
7
|
+
* Marks the control as invalid (`aria-invalid`) and shows the ErrorMessage.
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
6
10
|
invalid?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Disables the control.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
7
15
|
disabled?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Marks the control as required.
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
8
20
|
required?: boolean;
|
|
9
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Set to `true` when a `Field.Description` is rendered, so that the control is
|
|
23
|
+
* described by it (`aria-describedby`).
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
10
26
|
hasDescription?: boolean;
|
|
11
27
|
};
|
|
12
28
|
/**
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { type PropsOf, type Signal } from '@builder.io/qwik';
|
|
2
2
|
export type FieldTextareaProps = PropsOf<'textarea'> & {
|
|
3
|
-
/**
|
|
3
|
+
/** A signal synced two-way with the textarea value. */
|
|
4
4
|
'bind:value'?: Signal<string>;
|
|
5
|
+
/**
|
|
6
|
+
* Marks the control as invalid (`aria-invalid="true"`, `data-invalid`). Inside a
|
|
7
|
+
* Field, the control is also invalid while the Field is.
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
10
|
+
invalid?: boolean;
|
|
5
11
|
};
|
|
6
12
|
/**
|
|
7
13
|
* 複数行のテキスト入力フォームコントロールです。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leve-ui/field",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Headless, WAI-ARIA compliant Field component for Qwik. Bring your own styles.",
|
|
5
5
|
"homepage": "https://github.com/leve-ui/leve-ui#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"field"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@leve-ui/utils": "0.
|
|
41
|
+
"@leve-ui/utils": "0.2.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@builder.io/qwik": "^1.20.4"
|