@a-type/ui 6.0.22 → 6.0.24
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/dist/components/forms/CheckboxField.d.ts +3 -1
- package/dist/components/forms/CheckboxField.js +5 -6
- package/dist/components/forms/CheckboxField.js.map +1 -1
- package/dist/components/forms/EmojiField.d.ts +3 -1
- package/dist/components/forms/EmojiField.js +4 -5
- package/dist/components/forms/EmojiField.js.map +1 -1
- package/dist/components/forms/Field.d.ts +21 -0
- package/dist/components/forms/Field.js +71 -0
- package/dist/components/forms/Field.js.map +1 -0
- package/dist/components/forms/Field.module.css +62 -0
- package/dist/components/forms/Form.module.css +1 -1
- package/dist/components/forms/FormikForm.d.ts +2 -2
- package/dist/components/forms/FormikForm.stories.d.ts +2 -2
- package/dist/components/forms/FormikForm.stories.js +1 -1
- package/dist/components/forms/FormikForm.stories.js.map +1 -1
- package/dist/components/forms/NumberStepperField.d.ts +3 -1
- package/dist/components/forms/NumberStepperField.js +6 -9
- package/dist/components/forms/NumberStepperField.js.map +1 -1
- package/dist/components/forms/SwitchField.d.ts +3 -1
- package/dist/components/forms/SwitchField.js +5 -6
- package/dist/components/forms/SwitchField.js.map +1 -1
- package/dist/components/forms/TextField.d.ts +7 -5
- package/dist/components/forms/TextField.js +5 -7
- package/dist/components/forms/TextField.js.map +1 -1
- package/dist/components/forms/ToggleGroupField.d.ts +3 -1
- package/dist/components/forms/ToggleGroupField.js +12 -11
- package/dist/components/forms/ToggleGroupField.js.map +1 -1
- package/dist/components/forms/index.d.ts +1 -1
- package/dist/components/forms/index.js +1 -1
- package/dist/components/forms/index.js.map +1 -1
- package/dist/components/switch/Switch.module.css +1 -1
- package/package.json +1 -1
- package/src/components/forms/CheckboxField.tsx +19 -15
- package/src/components/forms/EmojiField.tsx +15 -9
- package/src/components/forms/Field.module.css +62 -0
- package/src/components/forms/Field.tsx +125 -0
- package/src/components/forms/Form.module.css +1 -1
- package/src/components/forms/FormikForm.stories.tsx +25 -5
- package/src/components/forms/NumberStepperField.tsx +19 -16
- package/src/components/forms/SwitchField.tsx +19 -15
- package/src/components/forms/TextField.tsx +37 -25
- package/src/components/forms/ToggleGroupField.tsx +27 -19
- package/src/components/forms/index.tsx +1 -1
- package/src/components/switch/Switch.module.css +1 -1
- package/dist/components/forms/FieldLabel.d.ts +0 -2
- package/dist/components/forms/FieldLabel.js +0 -5
- package/dist/components/forms/FieldLabel.js.map +0 -1
- package/dist/components/forms/FieldLabel.module.css +0 -20
- package/src/components/forms/FieldLabel.module.css +0 -20
- package/src/components/forms/FieldLabel.tsx +0 -9
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useField } from 'formik';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { useIdOrGenerated } from '../../hooks/useIdOrGenerated.js';
|
|
2
4
|
import { ToggleGroup, ToggleGroupProps } from '../toggleGroup/toggleGroup.js';
|
|
3
|
-
import {
|
|
4
|
-
import { FieldRoot } from './TextField.js';
|
|
5
|
+
import { Field } from './Field.js';
|
|
5
6
|
|
|
6
7
|
export type ToggleGroupFieldProps<Value extends string> =
|
|
7
8
|
ToggleGroupProps<Value> & {
|
|
@@ -11,6 +12,7 @@ export type ToggleGroupFieldProps<Value extends string> =
|
|
|
11
12
|
className?: string;
|
|
12
13
|
id?: string;
|
|
13
14
|
type?: 'single' | 'multiple';
|
|
15
|
+
description?: ReactNode;
|
|
14
16
|
};
|
|
15
17
|
|
|
16
18
|
function ToggleGroupFieldDefault({
|
|
@@ -20,29 +22,35 @@ function ToggleGroupFieldDefault({
|
|
|
20
22
|
className,
|
|
21
23
|
type = 'single',
|
|
22
24
|
multiple,
|
|
23
|
-
|
|
25
|
+
description,
|
|
26
|
+
id: providedId,
|
|
24
27
|
...props
|
|
25
28
|
}: ToggleGroupFieldProps<string>) {
|
|
29
|
+
const id = useIdOrGenerated(providedId);
|
|
26
30
|
const [fieldProps, _, tools] = useField({ name, required, ...props });
|
|
27
31
|
|
|
28
32
|
return (
|
|
29
|
-
<
|
|
30
|
-
{label && <
|
|
31
|
-
<
|
|
32
|
-
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
<Field id={id}>
|
|
34
|
+
{label && <Field.Label>{label}</Field.Label>}
|
|
35
|
+
<Field.Control
|
|
36
|
+
render={
|
|
37
|
+
<ToggleGroup
|
|
38
|
+
{...fieldProps}
|
|
39
|
+
onValueChange={(v) => {
|
|
40
|
+
if (multiple || type === 'multiple') {
|
|
41
|
+
tools.setValue(v);
|
|
42
|
+
} else {
|
|
43
|
+
tools.setValue(v[0]);
|
|
44
|
+
}
|
|
45
|
+
}}
|
|
46
|
+
multiple={multiple || type === 'multiple'}
|
|
47
|
+
{...props}
|
|
48
|
+
className={className}
|
|
49
|
+
/>
|
|
50
|
+
}
|
|
44
51
|
/>
|
|
45
|
-
|
|
52
|
+
{description && <Field.Description>{description}</Field.Description>}
|
|
53
|
+
</Field>
|
|
46
54
|
);
|
|
47
55
|
}
|
|
48
56
|
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
--mx-shadow-value: inset var(--m-shadow-sm);
|
|
16
16
|
|
|
17
17
|
@apply --mx-bg(var(--m-control-bg));
|
|
18
|
-
@apply --mx-borderColor(var(--m-control-
|
|
18
|
+
@apply --mx-borderColor(var(--m-control-borderColor));
|
|
19
19
|
border-radius: var(--m-radius-lg);
|
|
20
20
|
|
|
21
21
|
&[data-checked] {
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const FieldLabel: import("react").FunctionComponent<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>>;
|
|
2
|
-
export declare const HorizontalFieldLabel: import("react").FunctionComponent<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { withClassName } from '../../hooks.js';
|
|
2
|
-
import cls from './FieldLabel.module.css';
|
|
3
|
-
export const FieldLabel = withClassName('label', cls.fieldLabel);
|
|
4
|
-
export const HorizontalFieldLabel = withClassName('label', cls.horizontalFieldLabel);
|
|
5
|
-
//# sourceMappingURL=FieldLabel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FieldLabel.js","sourceRoot":"","sources":["../../../src/components/forms/FieldLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,GAAG,MAAM,yBAAyB,CAAC;AAE1C,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;AAEjE,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAChD,OAAO,EACP,GAAG,CAAC,oBAAoB,CACxB,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
.fieldLabel {
|
|
2
|
-
display: inline-flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
@apply --mx-fg(var(--m-color-neutral-ink));
|
|
5
|
-
margin-inline-start: var(--m-space-md);
|
|
6
|
-
gap: var(--m-space-xs);
|
|
7
|
-
font-size: var(--m-prose-ambient-size);
|
|
8
|
-
line-height: var(--m-prose-ambient-lineHeight);
|
|
9
|
-
font-weight: bold;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.horizontalFieldLabel {
|
|
13
|
-
display: inline-flex;
|
|
14
|
-
flex-direction: row;
|
|
15
|
-
@apply --mx-fg(var(--m-color-neutral-ink));
|
|
16
|
-
gap: var(--m-space-sm);
|
|
17
|
-
font-size: var(--m-prose-ambient-size);
|
|
18
|
-
line-height: var(--m-prose-ambient-lineHeight);
|
|
19
|
-
margin-block-start: var(--m-space-sm);
|
|
20
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
.fieldLabel {
|
|
2
|
-
display: inline-flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
@apply --mx-fg(var(--m-color-neutral-ink));
|
|
5
|
-
margin-inline-start: var(--m-space-md);
|
|
6
|
-
gap: var(--m-space-xs);
|
|
7
|
-
font-size: var(--m-prose-ambient-size);
|
|
8
|
-
line-height: var(--m-prose-ambient-lineHeight);
|
|
9
|
-
font-weight: bold;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.horizontalFieldLabel {
|
|
13
|
-
display: inline-flex;
|
|
14
|
-
flex-direction: row;
|
|
15
|
-
@apply --mx-fg(var(--m-color-neutral-ink));
|
|
16
|
-
gap: var(--m-space-sm);
|
|
17
|
-
font-size: var(--m-prose-ambient-size);
|
|
18
|
-
line-height: var(--m-prose-ambient-lineHeight);
|
|
19
|
-
margin-block-start: var(--m-space-sm);
|
|
20
|
-
}
|