@a-type/ui 6.0.23 → 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.
Files changed (28) hide show
  1. package/dist/components/forms/CheckboxField.js +2 -2
  2. package/dist/components/forms/CheckboxField.js.map +1 -1
  3. package/dist/components/forms/EmojiField.js +8 -8
  4. package/dist/components/forms/EmojiField.js.map +1 -1
  5. package/dist/components/forms/Field.d.ts +7 -2
  6. package/dist/components/forms/Field.js +40 -6
  7. package/dist/components/forms/Field.js.map +1 -1
  8. package/dist/components/forms/Field.module.css +17 -6
  9. package/dist/components/forms/FormikForm.d.ts +1 -1
  10. package/dist/components/forms/FormikForm.stories.d.ts +1 -1
  11. package/dist/components/forms/NumberStepperField.js +2 -2
  12. package/dist/components/forms/NumberStepperField.js.map +1 -1
  13. package/dist/components/forms/SwitchField.js +2 -2
  14. package/dist/components/forms/SwitchField.js.map +1 -1
  15. package/dist/components/forms/TextField.js +2 -2
  16. package/dist/components/forms/TextField.js.map +1 -1
  17. package/dist/components/forms/ToggleGroupField.d.ts +1 -1
  18. package/dist/components/forms/ToggleGroupField.js +5 -3
  19. package/dist/components/forms/ToggleGroupField.js.map +1 -1
  20. package/package.json +1 -1
  21. package/src/components/forms/CheckboxField.tsx +15 -19
  22. package/src/components/forms/EmojiField.tsx +35 -46
  23. package/src/components/forms/Field.module.css +17 -6
  24. package/src/components/forms/Field.tsx +92 -10
  25. package/src/components/forms/NumberStepperField.tsx +15 -19
  26. package/src/components/forms/SwitchField.tsx +15 -19
  27. package/src/components/forms/TextField.tsx +6 -18
  28. package/src/components/forms/ToggleGroupField.tsx +23 -25
@@ -18,8 +18,8 @@ export function CheckboxField(_a) {
18
18
  var { name, label, className, required, id: providedId, description } = _a, rest = __rest(_a, ["name", "label", "className", "required", "id", "description"]);
19
19
  const [props, _, tools] = useField({ name, required, type: 'checkbox' });
20
20
  const id = useIdOrGenerated(providedId);
21
- return (_jsxs(Field, { horizontal: true, className: className, children: [_jsx(Field.Control, { children: _jsx(Checkbox, Object.assign({}, props, { checked: props.checked, onCheckedChange: (v) => {
21
+ return (_jsxs(Field, { horizontal: true, className: className, id: id, children: [_jsx(Field.Control, { render: _jsx(Checkbox, Object.assign({}, props, { checked: props.checked, onCheckedChange: (v) => {
22
22
  tools.setValue(!!v);
23
- }, id: id, "aria-describedby": description ? `${id}-description` : undefined }, rest)) }), label && _jsx(Field.Label, { htmlFor: id, children: label }), description && (_jsx(Field.Description, { id: `${id}-description`, children: description }))] }));
23
+ } }, rest)) }), label && _jsx(Field.Label, { children: label }), description && _jsx(Field.Description, { children: description })] }));
24
24
  }
25
25
  //# sourceMappingURL=CheckboxField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CheckboxField.js","sourceRoot":"","sources":["../../../src/components/forms/CheckboxField.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAWnC,MAAM,UAAU,aAAa,CAAC,EAQT;QARS,EAC7B,IAAI,EACJ,KAAK,EACL,SAAS,EACT,QAAQ,EACR,EAAE,EAAE,UAAU,EACd,WAAW,OAES,EADjB,IAAI,cAPsB,+DAQ7B,CADO;IAEP,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,GAAG,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;IACzE,MAAM,EAAE,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxC,OAAO,CACN,MAAC,KAAK,IAAC,UAAU,QAAC,SAAS,EAAE,SAAS,aACrC,KAAC,KAAK,CAAC,OAAO,cACb,KAAC,QAAQ,oBACJ,KAAK,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AAE,aAC7C,KAAC,KAAK,CAAC,OAAO,IACb,MAAM,EACL,KAAC,QAAQ,oBACJ,KAAK,IACT,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,eAAe,EAAE,CAAC,CAAC,EAAE,EAAE;wBACtB,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBACrB,CAAC,IACG,IAAI,EACP,GAEF,EACD,KAAK,IAAI,KAAC,KAAK,CAAC,KAAK,cAAE,KAAK,GAAe,EAC3C,WAAW,IAAI,KAAC,KAAK,CAAC,WAAW,cAAE,WAAW,GAAqB,IAC7D,CACR,CAAC;AACH,CAAC"}
@@ -24,14 +24,14 @@ export function EmojiField(_a) {
24
24
  const [props, _, tools] = useField({ name });
25
25
  const id = useIdOrGenerated(providedId);
26
26
  const [open, setOpen] = useState(false);
27
- return (_jsxs(Field, { horizontal: true, className: className, children: [_jsx(Field.Control, { children: _jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx("input", Object.assign({ type: "hidden" }, props, { id: id, "aria-describedby": description ? `${id}-description` : undefined })), _jsx(Popover.Trigger, { render: _jsx(Button, Object.assign({ id: `${id}-trigger`, "aria-label": "Select emoji", size: "wrapper" }, rest, { children: _jsx(Button.Icon, { className: cls.triggerIcon, children: props.value || _jsx(Icon, { name: "smile" }) }) })) }), _jsx(Popover.Content, { children: _jsx(EmojiPicker, { onValueChange: (v) => {
28
- tools.setValue(v);
27
+ return (_jsxs(Field, { horizontal: true, className: className, id: id, children: [_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(Field.Control, { render: _jsx("input", Object.assign({ type: "hidden" }, props)) }), _jsx(Popover.Trigger, { render: _jsx(Button, Object.assign({ id: `${id}-trigger`, "aria-label": "Select emoji", size: "wrapper" }, rest, { children: _jsx(Button.Icon, { className: cls.triggerIcon, children: props.value || _jsx(Icon, { name: "smile" }) }) })) }), _jsx(Popover.Content, { children: _jsx(EmojiPicker, { onValueChange: (v) => {
28
+ tools.setValue(v);
29
+ setOpen(false);
30
+ }, onClear: required
31
+ ? undefined
32
+ : () => {
33
+ tools.setValue('');
29
34
  setOpen(false);
30
- }, onClear: required
31
- ? undefined
32
- : () => {
33
- tools.setValue('');
34
- setOpen(false);
35
- }, id: id }) })] }) }), label && _jsx(Field.Label, { htmlFor: id, children: label }), description && (_jsx(Field.Description, { id: `${id}-description`, children: description }))] }));
35
+ }, id: id }) })] }), label && _jsx(Field.Label, { children: label }), description && _jsx(Field.Description, { children: description })] }));
36
36
  }
37
37
  //# sourceMappingURL=EmojiField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EmojiField.js","sourceRoot":"","sources":["../../../src/components/forms/EmojiField.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAa,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,GAAG,MAAM,yBAAyB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAUnC,MAAM,UAAU,UAAU,CAAC,EAQT;QARS,EAC1B,IAAI,EACJ,KAAK,EACL,SAAS,EACT,QAAQ,EACR,EAAE,EAAE,UAAU,EACd,WAAW,OAEM,EADd,IAAI,cAPmB,+DAQ1B,CADO;IAEP,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,GAAG,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,MAAM,EAAE,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACx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QAAQ,IAAK,KAAK,EAAI,GAAI,EAC7D,KAAC,OAAO,CAAC,OAAO,IACf,MAAM,EACL,KAAC,MAAM,kBACN,EAAE,EAAE,GAAG,EAAE,UAAU,gBACR,cAAc,EACzB,IAAI,EAAC,SAAS,IACV,IAAI,cAER,KAAC,MAAM,CAAC,IAAI,IAAC,SAAS,EAAE,GAAG,CAAC,WAAW,YACrC,KAAK,CAAC,KAAK,IAAI,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,GAAG,GACxB,IACN,GAET,EACF,KAAC,OAAO,CAAC,OAAO,cACf,KAAC,WAAW,IACX,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE;gCACpB,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;gCAClB,OAAO,CAAC,KAAK,CAAC,CAAC;4BAChB,CAAC,EACD,OAAO,EACN,QAAQ;gCACP,CAAC,CAAC,SAAS;gCACX,CAAC,CAAC,GAAG,EAAE;oCACL,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;oCACnB,OAAO,CAAC,KAAK,CAAC,CAAC;gCACf,CAAC,EAEL,EAAE,EAAE,EAAE,GACL,GACe,IACT,EACT,KAAK,IAAI,KAAC,KAAK,CAAC,KAAK,cAAE,KAAK,GAAe,EAC3C,WAAW,IAAI,KAAC,KAAK,CAAC,WAAW,cAAE,WAAW,GAAqB,IAC7D,CACR,CAAC;AACH,CAAC"}
@@ -3,9 +3,14 @@ import { SlotDiv } from '../utility/SlotDiv.js';
3
3
  export interface FieldRootProps extends ComponentProps<'div'> {
4
4
  horizontal?: boolean;
5
5
  stretch?: boolean;
6
+ reverse?: boolean;
7
+ /**
8
+ * This ID will be passed to Control, and Label will be associated.
9
+ */
10
+ id?: string;
6
11
  }
7
- declare function FieldRoot({ className, horizontal, ...props }: FieldRootProps): import("react/jsx-runtime").JSX.Element;
8
- declare function FieldControl({ className, ...props }: ComponentProps<typeof SlotDiv>): import("react/jsx-runtime").JSX.Element;
12
+ declare function FieldRoot({ className, horizontal, stretch, reverse, id, ...props }: FieldRootProps): import("react/jsx-runtime").JSX.Element;
13
+ declare function FieldControl({ className, ref, ...props }: ComponentProps<typeof SlotDiv>): import("react/jsx-runtime").JSX.Element;
9
14
  declare function FieldLabel({ className, ...props }: ComponentProps<'label'>): import("react/jsx-runtime").JSX.Element;
10
15
  declare function FieldDescription({ className, ...props }: ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
11
16
  export declare const Field: typeof FieldRoot & {
@@ -11,23 +11,57 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import clsx from 'clsx';
14
+ import { createContext, useContext, useEffect, useRef, useState, } from 'react';
15
+ import useMergedRef from '../../hooks/useMergedRef.js';
14
16
  import { SlotDiv } from '../utility/SlotDiv.js';
15
17
  import cls from './Field.module.css';
18
+ const FieldContext = createContext({
19
+ events: new EventTarget(),
20
+ });
16
21
  function FieldRoot(_a) {
17
- var { className, horizontal } = _a, props = __rest(_a, ["className", "horizontal"]);
18
- return (_jsx(SlotDiv, Object.assign({ className: clsx(cls.root, className), "data-horizontal": horizontal ? '' : undefined, "data-stretch": props.stretch ? '' : undefined }, props)));
22
+ var { className, horizontal, stretch, reverse, id } = _a, props = __rest(_a, ["className", "horizontal", "stretch", "reverse", "id"]);
23
+ const [events] = useState(() => new EventTarget());
24
+ return (_jsx(FieldContext.Provider, { value: { id, events }, children: _jsx(SlotDiv, Object.assign({ className: clsx(cls.root, className), "data-horizontal": horizontal ? '' : undefined, "data-stretch": stretch ? '' : undefined, "data-reverse": reverse ? '' : undefined }, props)) }));
19
25
  }
20
26
  function FieldControl(_a) {
21
- var { className } = _a, props = __rest(_a, ["className"]);
22
- return _jsx(SlotDiv, Object.assign({ className: clsx(cls.control, className) }, props));
27
+ var { className, ref } = _a, props = __rest(_a, ["className", "ref"]);
28
+ const innerRef = useRef(null);
29
+ const finalRef = useMergedRef(ref, innerRef);
30
+ const { id, events } = useContext(FieldContext);
31
+ useEffect(() => {
32
+ if (!id)
33
+ return;
34
+ function onDescriptionVisible(event) {
35
+ var _a, _b;
36
+ if (event.detail === true) {
37
+ (_a = innerRef.current) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-describedby', `${id}-description`);
38
+ }
39
+ else {
40
+ (_b = innerRef.current) === null || _b === void 0 ? void 0 : _b.removeAttribute('aria-describedby');
41
+ }
42
+ }
43
+ events.addEventListener('description-visible', onDescriptionVisible);
44
+ return () => {
45
+ events.removeEventListener('description-visible', onDescriptionVisible);
46
+ };
47
+ }, [events, id]);
48
+ return (_jsx(SlotDiv, Object.assign({ className: clsx(cls.control, className), id: id, ref: finalRef }, props)));
23
49
  }
24
50
  function FieldLabel(_a) {
25
51
  var { className } = _a, props = __rest(_a, ["className"]);
26
- return _jsx("label", Object.assign({ className: clsx(cls.label, className) }, props));
52
+ const { id } = useContext(FieldContext);
53
+ return (_jsx("label", Object.assign({ className: clsx(cls.label, className), htmlFor: id }, props)));
27
54
  }
28
55
  function FieldDescription(_a) {
29
56
  var { className } = _a, props = __rest(_a, ["className"]);
30
- return (_jsx("div", Object.assign({ className: clsx('@mode-dense', cls.description, className) }, props)));
57
+ const { id, events } = useContext(FieldContext);
58
+ useEffect(() => {
59
+ events.dispatchEvent(new CustomEvent('description-visible', { detail: true }));
60
+ return () => {
61
+ events.dispatchEvent(new CustomEvent('description-visible', { detail: false }));
62
+ };
63
+ }, [events]);
64
+ return (_jsx("div", Object.assign({ className: clsx('@mode-dense', cls.description, className), id: id ? `${id}-description` : undefined }, props)));
31
65
  }
32
66
  export const Field = Object.assign(FieldRoot, {
33
67
  Label: FieldLabel,
@@ -1 +1 @@
1
- {"version":3,"file":"Field.js","sourceRoot":"","sources":["../../../src/components/forms/Field.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,GA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C,EAA8C;QAA9C,EAAE,SAAS,OAAmC,EAA9B,KAAK,cAArB,aAAuB,CAAF;IAC9C,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IAEhD,SAAS,CAAC,GAAG,EAAE;QACd,MAAM,CAAC,aAAa,CACnB,IAAI,WAAW,CAAC,qBAAqB,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CACxD,CAAC;QACF,OAAO,GAAG,EAAE;YACX,MAAM,CAAC,aAAa,CACnB,IAAI,WAAW,CAAC,qBAAqB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CACzD,CAAC;QACH,CAAC,CAAC;IACH,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IACb,OAAO,CACN,4BACC,SAAS,EAAE,IAAI,CAAC,aAAa,EAAE,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,EAC1D,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC,SAAS,IACpC,KAAK,EACR,CACF,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE;IAC7C,KAAK,EAAE,UAAU;IACjB,WAAW,EAAE,gBAAgB;IAC7B,OAAO,EAAE,YAAY;CACrB,CAAC,CAAC"}
@@ -8,6 +8,10 @@
8
8
  align-items: center;
9
9
  grid-template-areas: 'control label' 'description description';
10
10
  grid-template-columns: auto 1fr;
11
+ &[data-reverse] {
12
+ grid-template-areas: 'label control' 'description description';
13
+ grid-template-columns: auto 1fr;
14
+ }
11
15
  }
12
16
 
13
17
  &[data-stretch] {
@@ -18,12 +22,12 @@
18
22
 
19
23
  .control {
20
24
  grid-area: control;
21
- }
22
- :where(.control) {
23
- display: flex;
24
- flex-direction: column;
25
- align-items: center;
26
- gap: var(--m-space-sm);
25
+
26
+ [data-stretch] & {
27
+ align-self: stretch;
28
+ justify-content: stretch;
29
+ width: 100%;
30
+ }
27
31
  }
28
32
 
29
33
  .label {
@@ -38,6 +42,13 @@
38
42
  @apply --mx-fg(var(--m-color-neutral-ink));
39
43
  font-weight: var(--m-text-weight-normal);
40
44
  margin-block-start: --fn-literal(5px);
45
+
46
+ [data-reverse] & {
47
+ margin-inline-start: 0;
48
+ margin-inline-end: calc(
49
+ var(--m-global-shape-roundness) * var(--m-space-md)
50
+ );
51
+ }
41
52
  }
42
53
  }
43
54
 
@@ -17,7 +17,7 @@ export declare const FormikForm: typeof FormikFormRoot & {
17
17
  SubmitButton: typeof SubmitButton;
18
18
  CheckboxField: typeof CheckboxField;
19
19
  SwitchField: typeof SwitchField;
20
- ToggleGroupField: (({ name, label, required, className, type, multiple, description, id, ...props }: import("./ToggleGroupField.js").ToggleGroupFieldProps<string>) => import("react/jsx-runtime").JSX.Element) & {
20
+ ToggleGroupField: (({ name, label, required, className, type, multiple, description, id: providedId, ...props }: import("./ToggleGroupField.js").ToggleGroupFieldProps<string>) => import("react/jsx-runtime").JSX.Element) & {
21
21
  Item: import("react").FunctionComponent<import("@base-ui/react").Toggle.Props<string> & import("react").RefAttributes<HTMLButtonElement>>;
22
22
  };
23
23
  EmojiField: typeof EmojiField;
@@ -14,7 +14,7 @@ declare const meta: {
14
14
  SubmitButton: typeof SubmitButton;
15
15
  CheckboxField: typeof CheckboxField;
16
16
  SwitchField: typeof SwitchField;
17
- ToggleGroupField: (({ name, label, required, className, type, multiple, description, id, ...props }: import("./ToggleGroupField.js").ToggleGroupFieldProps<string>) => import("react/jsx-runtime").JSX.Element) & {
17
+ ToggleGroupField: (({ name, label, required, className, type, multiple, description, id: providedId, ...props }: import("./ToggleGroupField.js").ToggleGroupFieldProps<string>) => import("react/jsx-runtime").JSX.Element) & {
18
18
  Item: import("react").FunctionComponent<import("@base-ui/react").Toggle.Props<string> & import("react").RefAttributes<HTMLButtonElement>>;
19
19
  };
20
20
  EmojiField: typeof EmojiField;
@@ -18,9 +18,9 @@ export function NumberStepperField(_a) {
18
18
  var { name, label, className, id: providedId, onChange, description } = _a, rest = __rest(_a, ["name", "label", "className", "id", "onChange", "description"]);
19
19
  const [_, field, tools] = useField({ name });
20
20
  const id = useIdOrGenerated(providedId);
21
- return (_jsxs(Field, { className: className, horizontal: true, children: [label && _jsx(Field.Label, { htmlFor: id, children: label }), _jsx(Field.Control, { children: _jsx(NumberStepper, Object.assign({ value: field.value, onChange: (v) => {
21
+ return (_jsxs(Field, { className: className, id: id, children: [label && _jsx(Field.Label, { children: label }), _jsx(Field.Control, { render: _jsx(NumberStepper, Object.assign({ value: field.value, onChange: (v) => {
22
22
  tools.setValue(v);
23
23
  onChange === null || onChange === void 0 ? void 0 : onChange(v);
24
- }, id: id, "aria-describedby": description ? `${id}-description` : undefined }, rest)) }), description && (_jsx(Field.Description, { id: `${id}-description`, children: description }))] }));
24
+ } }, rest)) }), description && _jsx(Field.Description, { children: description })] }));
25
25
  }
26
26
  //# sourceMappingURL=NumberStepperField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NumberStepperField.js","sourceRoot":"","sources":["../../../src/components/forms/NumberStepperField.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EACN,aAAa,GAEb,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAYnC,MAAM,UAAU,kBAAkB,CAAC,EAQT;QARS,EAClC,IAAI,EACJ,KAAK,EACL,SAAS,EACT,EAAE,EAAE,UAAU,EACd,QAAQ,EACR,WAAW,OAEc,EADtB,IAAI,cAP2B,+DAQlC,CADO;IAEP,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,MAAM,EAAE,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxC,OAAO,CACN,MAAC,KAAK,IAAC,SAAS,EAAE,SAAS,EAAE,UAAU,mBACrC,KAAK,IAAI,KAAC,KAAK,CAAC,KAAK,IAAC,OAAO,EAAE,EAAE,YAAG,KAAK,GAAe,EACzD,KAAC,KAAK,CAAC,OAAO,cACb,KAAC,aAAa,kBACb,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;wBACf,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;wBAClB,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAG,CAAC,CAAC,CAAC;oBACf,CAAC,EACD,EAAE,EAAE,EAAE,sBACY,WAAW,CAAC,CAAC,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC,SAAS,IAC3D,IAAI,EACP,GACa,EACf,WAAW,IAAI,CACf,KAAC,KAAK,CAAC,WAAW,IAAC,EAAE,EAAE,GAAG,EAAE,cAAc,YACxC,WAAW,GACO,CACpB,IACM,CACR,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"NumberStepperField.js","sourceRoot":"","sources":["../../../src/components/forms/NumberStepperField.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EACN,aAAa,GAEb,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAYnC,MAAM,UAAU,kBAAkB,CAAC,EAQT;QARS,EAClC,IAAI,EACJ,KAAK,EACL,SAAS,EACT,EAAE,EAAE,UAAU,EACd,QAAQ,EACR,WAAW,OAEc,EADtB,IAAI,cAP2B,+DAQlC,CADO;IAEP,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,MAAM,EAAE,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxC,OAAO,CACN,MAAC,KAAK,IAAC,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,aACjC,KAAK,IAAI,KAAC,KAAK,CAAC,KAAK,cAAE,KAAK,GAAe,EAC5C,KAAC,KAAK,CAAC,OAAO,IACb,MAAM,EACL,KAAC,aAAa,kBACb,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;wBACf,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;wBAClB,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAG,CAAC,CAAC,CAAC;oBACf,CAAC,IACG,IAAI,EACP,GAEF,EACD,WAAW,IAAI,KAAC,KAAK,CAAC,WAAW,cAAE,WAAW,GAAqB,IAC7D,CACR,CAAC;AACH,CAAC"}
@@ -18,8 +18,8 @@ export function SwitchField(_a) {
18
18
  var { name, label, className, required, id: providedId, description } = _a, rest = __rest(_a, ["name", "label", "className", "required", "id", "description"]);
19
19
  const [props, _, tools] = useField({ name, required, type: 'checkbox' });
20
20
  const id = useIdOrGenerated(providedId);
21
- return (_jsxs(Field, { horizontal: true, className: className, children: [_jsx(Field.Control, { children: _jsx(Switch, Object.assign({}, props, { checked: props.checked, onCheckedChange: (v) => {
21
+ return (_jsxs(Field, { horizontal: true, className: className, id: id, children: [_jsx(Field.Control, { render: _jsx(Switch, Object.assign({}, props, { checked: props.checked, onCheckedChange: (v) => {
22
22
  tools.setValue(!!v);
23
- }, id: id, "aria-describedby": description ? `${id}-description` : undefined }, rest)) }), label && _jsx(Field.Label, { htmlFor: id, children: label }), description && (_jsx(Field.Description, { id: `${id}-description`, children: description }))] }));
23
+ } }, rest)) }), label && _jsx(Field.Label, { children: label }), description && _jsx(Field.Description, { children: description })] }));
24
24
  }
25
25
  //# sourceMappingURL=SwitchField.js.map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YACxC,WAAW,GACO,CACpB,IACM,CACR,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"SwitchField.js","sourceRoot":"","sources":["../../../src/components/forms/SwitchField.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAWnC,MAAM,UAAU,WAAW,CAAC,EAQT;QARS,EAC3B,IAAI,EACJ,KAAK,EACL,SAAS,EACT,QAAQ,EACR,EAAE,EAAE,UAAU,EACd,WAAW,OAEO,EADf,IAAI,cAPoB,+DAQ3B,CADO;IAEP,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,GAAG,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;IACzE,MAAM,EAAE,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxC,OAAO,CACN,MAAC,KAAK,IAAC,UAAU,QAAC,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,aAC7C,KAAC,KAAK,CAAC,OAAO,IACb,MAAM,EACL,KAAC,MAAM,oBACF,KAAK,IACT,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,eAAe,EAAE,CAAC,CAAC,EAAE,EAAE;wBACtB,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBACrB,CAAC,IACG,IAAI,EACP,GAEF,EACD,KAAK,IAAI,KAAC,KAAK,CAAC,KAAK,cAAE,KAAK,GAAe,EAC3C,WAAW,IAAI,KAAC,KAAK,CAAC,WAAW,cAAE,WAAW,GAAqB,IAC7D,CACR,CAAC;AACH,CAAC"}
@@ -38,7 +38,7 @@ export const TextField = function TextField(_a) {
38
38
  }, autoFocusDelay);
39
39
  }
40
40
  }, [autoFocusDelay]);
41
- return (_jsxs(Field, { className: className, stretch: true, ref: ref, children: [label && _jsx(Field.Label, { htmlFor: id, children: label }), _jsx(Field.Control, { render: _jsx(Input, Object.assign({}, props, rest, { id: id, autoFocus: autoFocus, className: clsx(cls.input, inputClassName), ref: useMergedRef(innerInputRef, inputRef || emptyRef), "aria-describedby": description ? `${id}-description` : undefined })) }), description && (_jsx(Field.Description, { id: `${id}-description`, children: description }))] }));
41
+ return (_jsxs(Field, { className: className, stretch: true, ref: ref, id: id, children: [label && _jsx(Field.Label, { children: label }), _jsx(Field.Control, { render: _jsx(Input, Object.assign({}, props, rest, { autoFocus: autoFocus, className: clsx(cls.input, inputClassName), ref: useMergedRef(innerInputRef, inputRef || emptyRef) })) }), description && _jsx(Field.Description, { children: description })] }));
42
42
  };
43
43
  export function TextAreaField(_a) {
44
44
  var { name, label, className, inputRef, onKeyDown, submitOnEnter, id: providedId, textAreaClassName, description, ref } = _a, rest = __rest(_a, ["name", "label", "className", "inputRef", "onKeyDown", "submitOnEnter", "id", "textAreaClassName", "description", "ref"]);
@@ -52,6 +52,6 @@ export function TextAreaField(_a) {
52
52
  onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
53
53
  }, [submitOnEnter, onKeyDown, submitForm]);
54
54
  const id = useIdOrGenerated(providedId);
55
- return (_jsxs(Field, { stretch: true, className: className, ref: ref, children: [label && _jsx(Field.Label, { htmlFor: id, children: label }), _jsx(Field.Control, { render: _jsx(TextArea, Object.assign({ ref: inputRef }, props, rest, { className: clsx(cls.input, textAreaClassName), id: id, onKeyDown: onKeyDownInner, "aria-describedby": description ? `${id}-description` : undefined })) }), description && (_jsx(Field.Description, { id: `${id}-description`, children: description }))] }));
55
+ return (_jsxs(Field, { stretch: true, className: className, ref: ref, id: id, children: [label && _jsx(Field.Label, { children: label }), _jsx(Field.Control, { render: _jsx(TextArea, Object.assign({ ref: inputRef }, props, rest, { className: clsx(cls.input, textAreaClassName), onKeyDown: onKeyDownInner })) }), description && _jsx(Field.Description, { children: description })] }));
56
56
  }
57
57
  //# sourceMappingURL=TextField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TextField.js","sourceRoot":"","sources":["../../../src/components/forms/TextField.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,EAKN,WAAW,EACX,SAAS,EACT,MAAM,GACN,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,YAAY,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,KAAK,EAAc,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAiB,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,GAAG,MAAM,wBAAwB,CAAC;AAazC,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,GAAE,CAAC,CAAQ,CAAC;AAEnC,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,SAAS,CAAC,EAe3B;QAf2B,EAC3C,GAAG,EACH,IAAI,EACJ,KAAK,EACL,SAAS,EACT,cAAc,EACd,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,MAAM,EACN,EAAE,EAAE,UAAU,EACd,cAAc,EACd,WAAW,OAEK,EADb,IAAI,cAdoC,wJAe3C,CADO;IAEP,MAAM,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC;QACxB,IAAI;QACJ,QAAQ;QACR,OAAO;QACP,MAAM;KACN,CAAC,CAAC;IACH,MAAM,aAAa,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IACrD,MAAM,EAAE,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAExC,SAAS,CA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AO,CACN,MAAC,KAAK,IAAC,OAAO,QAAC,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,aACnD,KAAK,IAAI,KAAC,KAAK,CAAC,KAAK,cAAE,KAAK,GAAe,EAC5C,KAAC,KAAK,CAAC,OAAO,IACb,MAAM,EACL,KAAC,QAAQ,kBACR,GAAG,EAAE,QAAe,IAChB,KAAK,EACL,IAAI,IACR,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,iBAAiB,CAAC,EAC7C,SAAS,EAAE,cAAc,IACxB,GAEF,EACD,WAAW,IAAI,KAAC,KAAK,CAAC,WAAW,cAAE,WAAW,GAAqB,IAC7D,CACR,CAAC;AACH,CAAC"}
@@ -9,7 +9,7 @@ export type ToggleGroupFieldProps<Value extends string> = ToggleGroupProps<Value
9
9
  type?: 'single' | 'multiple';
10
10
  description?: ReactNode;
11
11
  };
12
- declare function ToggleGroupFieldDefault({ name, label, required, className, type, multiple, description, id, ...props }: ToggleGroupFieldProps<string>): import("react/jsx-runtime").JSX.Element;
12
+ declare function ToggleGroupFieldDefault({ name, label, required, className, type, multiple, description, id: providedId, ...props }: ToggleGroupFieldProps<string>): import("react/jsx-runtime").JSX.Element;
13
13
  export declare const ToggleGroupField: typeof ToggleGroupFieldDefault & {
14
14
  Item: import("react").FunctionComponent<import("@base-ui/react").Toggle.Props<string> & import("react").RefAttributes<HTMLButtonElement>>;
15
15
  };
@@ -11,19 +11,21 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { useField } from 'formik';
14
+ import { useIdOrGenerated } from '../../hooks/useIdOrGenerated.js';
14
15
  import { ToggleGroup } from '../toggleGroup/toggleGroup.js';
15
16
  import { Field } from './Field.js';
16
17
  function ToggleGroupFieldDefault(_a) {
17
- var { name, label, required, className, type = 'single', multiple, description, id } = _a, props = __rest(_a, ["name", "label", "required", "className", "type", "multiple", "description", "id"]);
18
+ var { name, label, required, className, type = 'single', multiple, description, id: providedId } = _a, props = __rest(_a, ["name", "label", "required", "className", "type", "multiple", "description", "id"]);
19
+ const id = useIdOrGenerated(providedId);
18
20
  const [fieldProps, _, tools] = useField(Object.assign({ name, required }, props));
19
- return (_jsxs(Field, { children: [label && _jsx(Field.Label, { htmlFor: id, children: label }), _jsx(Field.Control, { children: _jsx(ToggleGroup, Object.assign({}, fieldProps, { onValueChange: (v) => {
21
+ return (_jsxs(Field, { id: id, children: [label && _jsx(Field.Label, { children: label }), _jsx(Field.Control, { render: _jsx(ToggleGroup, Object.assign({}, fieldProps, { onValueChange: (v) => {
20
22
  if (multiple || type === 'multiple') {
21
23
  tools.setValue(v);
22
24
  }
23
25
  else {
24
26
  tools.setValue(v[0]);
25
27
  }
26
- }, multiple: multiple || type === 'multiple' }, props, { id: id, className: className, "aria-describedby": description ? `${id}-description` : undefined })) }), description && (_jsx(Field.Description, { id: `${id}-description`, children: description }))] }));
28
+ }, multiple: multiple || type === 'multiple' }, props, { className: className })) }), description && _jsx(Field.Description, { children: description })] }));
27
29
  }
28
30
  export const ToggleGroupField = Object.assign(ToggleGroupFieldDefault, {
29
31
  Item: ToggleGroup.Item,
@@ -1 +1 @@
1
- {"version":3,"file":"ToggleGroupField.js","sourceRoot":"","sources":["../../../src/components/forms/ToggleGroupField.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EAAE,WAAW,EAAoB,MAAM,+BAA+B,CAAC;AAC9E,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAanC,SAAS,uBAAuB,CAAC,EAUD;QAVC,EAChC,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,SAAS,EACT,IAAI,GAAG,QAAQ,EACf,QAAQ,EACR,WAAW,EACX,EAAE,OAE6B,EAD5B,KAAK,cATwB,mFAUhC,CADQ;IAER,MAAM,C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6 +1,6 @@
1
1
  {
2
2
  "name": "@a-type/ui",
3
- "version": "6.0.23",
3
+ "version": "6.0.24",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "url": "https://github.com/a-type/ui"
@@ -25,25 +25,21 @@ export function CheckboxField({
25
25
  const [props, _, tools] = useField({ name, required, type: 'checkbox' });
26
26
  const id = useIdOrGenerated(providedId);
27
27
  return (
28
- <Field horizontal className={className}>
29
- <Field.Control>
30
- <Checkbox
31
- {...props}
32
- checked={props.checked}
33
- onCheckedChange={(v) => {
34
- tools.setValue(!!v);
35
- }}
36
- id={id}
37
- aria-describedby={description ? `${id}-description` : undefined}
38
- {...rest}
39
- />
40
- </Field.Control>
41
- {label && <Field.Label htmlFor={id}>{label}</Field.Label>}
42
- {description && (
43
- <Field.Description id={`${id}-description`}>
44
- {description}
45
- </Field.Description>
46
- )}
28
+ <Field horizontal className={className} id={id}>
29
+ <Field.Control
30
+ render={
31
+ <Checkbox
32
+ {...props}
33
+ checked={props.checked}
34
+ onCheckedChange={(v) => {
35
+ tools.setValue(!!v);
36
+ }}
37
+ {...rest}
38
+ />
39
+ }
40
+ />
41
+ {label && <Field.Label>{label}</Field.Label>}
42
+ {description && <Field.Description>{description}</Field.Description>}
47
43
  </Field>
48
44
  );
49
45
  }
@@ -29,54 +29,43 @@ export function EmojiField({
29
29
  const id = useIdOrGenerated(providedId);
30
30
  const [open, setOpen] = useState(false);
31
31
  return (
32
- <Field horizontal className={className}>
33
- <Field.Control>
34
- <Popover open={open} onOpenChange={setOpen}>
35
- <input
36
- type="hidden"
37
- {...props}
38
- id={id}
39
- aria-describedby={description ? `${id}-description` : undefined}
40
- />
41
- <Popover.Trigger
42
- render={
43
- <Button
44
- id={`${id}-trigger`}
45
- aria-label="Select emoji"
46
- size="wrapper"
47
- {...rest}
48
- >
49
- <Button.Icon className={cls.triggerIcon}>
50
- {props.value || <Icon name="smile" />}
51
- </Button.Icon>
52
- </Button>
32
+ <Field horizontal className={className} id={id}>
33
+ <Popover open={open} onOpenChange={setOpen}>
34
+ <Field.Control render={<input type="hidden" {...props} />} />
35
+ <Popover.Trigger
36
+ render={
37
+ <Button
38
+ id={`${id}-trigger`}
39
+ aria-label="Select emoji"
40
+ size="wrapper"
41
+ {...rest}
42
+ >
43
+ <Button.Icon className={cls.triggerIcon}>
44
+ {props.value || <Icon name="smile" />}
45
+ </Button.Icon>
46
+ </Button>
47
+ }
48
+ />
49
+ <Popover.Content>
50
+ <EmojiPicker
51
+ onValueChange={(v) => {
52
+ tools.setValue(v);
53
+ setOpen(false);
54
+ }}
55
+ onClear={
56
+ required
57
+ ? undefined
58
+ : () => {
59
+ tools.setValue('');
60
+ setOpen(false);
61
+ }
53
62
  }
63
+ id={id}
54
64
  />
55
- <Popover.Content>
56
- <EmojiPicker
57
- onValueChange={(v) => {
58
- tools.setValue(v);
59
- setOpen(false);
60
- }}
61
- onClear={
62
- required
63
- ? undefined
64
- : () => {
65
- tools.setValue('');
66
- setOpen(false);
67
- }
68
- }
69
- id={id}
70
- />
71
- </Popover.Content>
72
- </Popover>
73
- </Field.Control>
74
- {label && <Field.Label htmlFor={id}>{label}</Field.Label>}
75
- {description && (
76
- <Field.Description id={`${id}-description`}>
77
- {description}
78
- </Field.Description>
79
- )}
65
+ </Popover.Content>
66
+ </Popover>
67
+ {label && <Field.Label>{label}</Field.Label>}
68
+ {description && <Field.Description>{description}</Field.Description>}
80
69
  </Field>
81
70
  );
82
71
  }
@@ -8,6 +8,10 @@
8
8
  align-items: center;
9
9
  grid-template-areas: 'control label' 'description description';
10
10
  grid-template-columns: auto 1fr;
11
+ &[data-reverse] {
12
+ grid-template-areas: 'label control' 'description description';
13
+ grid-template-columns: auto 1fr;
14
+ }
11
15
  }
12
16
 
13
17
  &[data-stretch] {
@@ -18,12 +22,12 @@
18
22
 
19
23
  .control {
20
24
  grid-area: control;
21
- }
22
- :where(.control) {
23
- display: flex;
24
- flex-direction: column;
25
- align-items: center;
26
- gap: var(--m-space-sm);
25
+
26
+ [data-stretch] & {
27
+ align-self: stretch;
28
+ justify-content: stretch;
29
+ width: 100%;
30
+ }
27
31
  }
28
32
 
29
33
  .label {
@@ -38,6 +42,13 @@
38
42
  @apply --mx-fg(var(--m-color-neutral-ink));
39
43
  font-weight: var(--m-text-weight-normal);
40
44
  margin-block-start: --fn-literal(5px);
45
+
46
+ [data-reverse] & {
47
+ margin-inline-start: 0;
48
+ margin-inline-end: calc(
49
+ var(--m-global-shape-roundness) * var(--m-space-md)
50
+ );
51
+ }
41
52
  }
42
53
  }
43
54
 
@@ -1,36 +1,118 @@
1
1
  import clsx from 'clsx';
2
- import { ComponentProps } from 'react';
2
+ import {
3
+ ComponentProps,
4
+ createContext,
5
+ useContext,
6
+ useEffect,
7
+ useRef,
8
+ useState,
9
+ } from 'react';
10
+ import useMergedRef from '../../hooks/useMergedRef.js';
3
11
  import { SlotDiv } from '../utility/SlotDiv.js';
4
12
  import cls from './Field.module.css';
5
13
 
6
14
  export interface FieldRootProps extends ComponentProps<'div'> {
7
15
  horizontal?: boolean;
8
16
  stretch?: boolean;
17
+ reverse?: boolean;
18
+ /**
19
+ * This ID will be passed to Control, and Label will be associated.
20
+ */
21
+ id?: string;
9
22
  }
10
23
 
11
- function FieldRoot({ className, horizontal, ...props }: FieldRootProps) {
24
+ const FieldContext = createContext<{ id?: string; events: EventTarget }>({
25
+ events: new EventTarget(),
26
+ });
27
+
28
+ function FieldRoot({
29
+ className,
30
+ horizontal,
31
+ stretch,
32
+ reverse,
33
+ id,
34
+ ...props
35
+ }: FieldRootProps) {
36
+ const [events] = useState(() => new EventTarget());
37
+ return (
38
+ <FieldContext.Provider value={{ id, events }}>
39
+ <SlotDiv
40
+ className={clsx(cls.root, className)}
41
+ data-horizontal={horizontal ? '' : undefined}
42
+ data-stretch={stretch ? '' : undefined}
43
+ data-reverse={reverse ? '' : undefined}
44
+ {...props}
45
+ />
46
+ </FieldContext.Provider>
47
+ );
48
+ }
49
+
50
+ function FieldControl({
51
+ className,
52
+ ref,
53
+ ...props
54
+ }: ComponentProps<typeof SlotDiv>) {
55
+ const innerRef = useRef<HTMLElement>(null);
56
+ const finalRef = useMergedRef(ref, innerRef);
57
+ const { id, events } = useContext(FieldContext);
58
+
59
+ useEffect(() => {
60
+ if (!id) return;
61
+
62
+ function onDescriptionVisible(event: CustomEvent) {
63
+ if (event.detail === true) {
64
+ innerRef.current?.setAttribute('aria-describedby', `${id}-description`);
65
+ } else {
66
+ innerRef.current?.removeAttribute('aria-describedby');
67
+ }
68
+ }
69
+
70
+ events.addEventListener(
71
+ 'description-visible',
72
+ onDescriptionVisible as EventListener,
73
+ );
74
+ return () => {
75
+ events.removeEventListener(
76
+ 'description-visible',
77
+ onDescriptionVisible as EventListener,
78
+ );
79
+ };
80
+ }, [events, id]);
81
+
12
82
  return (
13
83
  <SlotDiv
14
- className={clsx(cls.root, className)}
15
- data-horizontal={horizontal ? '' : undefined}
16
- data-stretch={props.stretch ? '' : undefined}
84
+ className={clsx(cls.control, className)}
85
+ id={id}
86
+ ref={finalRef}
17
87
  {...props}
18
88
  />
19
89
  );
20
90
  }
21
91
 
22
- function FieldControl({ className, ...props }: ComponentProps<typeof SlotDiv>) {
23
- return <SlotDiv className={clsx(cls.control, className)} {...props} />;
24
- }
25
-
26
92
  function FieldLabel({ className, ...props }: ComponentProps<'label'>) {
27
- return <label className={clsx(cls.label, className)} {...props} />;
93
+ const { id } = useContext(FieldContext);
94
+ return (
95
+ <label className={clsx(cls.label, className)} htmlFor={id} {...props} />
96
+ );
28
97
  }
29
98
 
30
99
  function FieldDescription({ className, ...props }: ComponentProps<'div'>) {
100
+ const { id, events } = useContext(FieldContext);
101
+
102
+ useEffect(() => {
103
+ events.dispatchEvent(
104
+ new CustomEvent('description-visible', { detail: true }),
105
+ );
106
+ return () => {
107
+ events.dispatchEvent(
108
+ new CustomEvent('description-visible', { detail: false }),
109
+ );
110
+ };
111
+ }, [events]);
31
112
  return (
32
113
  <div
33
114
  className={clsx('@mode-dense', cls.description, className)}
115
+ id={id ? `${id}-description` : undefined}
34
116
  {...props}
35
117
  />
36
118
  );
@@ -29,25 +29,21 @@ export function NumberStepperField({
29
29
  const [_, field, tools] = useField({ name });
30
30
  const id = useIdOrGenerated(providedId);
31
31
  return (
32
- <Field className={className} horizontal>
33
- {label && <Field.Label htmlFor={id}>{label}</Field.Label>}
34
- <Field.Control>
35
- <NumberStepper
36
- value={field.value}
37
- onChange={(v) => {
38
- tools.setValue(v);
39
- onChange?.(v);
40
- }}
41
- id={id}
42
- aria-describedby={description ? `${id}-description` : undefined}
43
- {...rest}
44
- />
45
- </Field.Control>
46
- {description && (
47
- <Field.Description id={`${id}-description`}>
48
- {description}
49
- </Field.Description>
50
- )}
32
+ <Field className={className} id={id}>
33
+ {label && <Field.Label>{label}</Field.Label>}
34
+ <Field.Control
35
+ render={
36
+ <NumberStepper
37
+ value={field.value}
38
+ onChange={(v) => {
39
+ tools.setValue(v);
40
+ onChange?.(v);
41
+ }}
42
+ {...rest}
43
+ />
44
+ }
45
+ />
46
+ {description && <Field.Description>{description}</Field.Description>}
51
47
  </Field>
52
48
  );
53
49
  }
@@ -25,25 +25,21 @@ export function SwitchField({
25
25
  const [props, _, tools] = useField({ name, required, type: 'checkbox' });
26
26
  const id = useIdOrGenerated(providedId);
27
27
  return (
28
- <Field horizontal className={className}>
29
- <Field.Control>
30
- <Switch
31
- {...props}
32
- checked={props.checked}
33
- onCheckedChange={(v) => {
34
- tools.setValue(!!v);
35
- }}
36
- id={id}
37
- aria-describedby={description ? `${id}-description` : undefined}
38
- {...rest}
39
- />
40
- </Field.Control>
41
- {label && <Field.Label htmlFor={id}>{label}</Field.Label>}
42
- {description && (
43
- <Field.Description id={`${id}-description`}>
44
- {description}
45
- </Field.Description>
46
- )}
28
+ <Field horizontal className={className} id={id}>
29
+ <Field.Control
30
+ render={
31
+ <Switch
32
+ {...props}
33
+ checked={props.checked}
34
+ onCheckedChange={(v) => {
35
+ tools.setValue(!!v);
36
+ }}
37
+ {...rest}
38
+ />
39
+ }
40
+ />
41
+ {label && <Field.Label>{label}</Field.Label>}
42
+ {description && <Field.Description>{description}</Field.Description>}
47
43
  </Field>
48
44
  );
49
45
  }
@@ -63,26 +63,20 @@ export const TextField = function TextField({
63
63
  }, [autoFocusDelay]);
64
64
 
65
65
  return (
66
- <Field className={className} stretch ref={ref}>
67
- {label && <Field.Label htmlFor={id}>{label}</Field.Label>}
66
+ <Field className={className} stretch ref={ref} id={id}>
67
+ {label && <Field.Label>{label}</Field.Label>}
68
68
  <Field.Control
69
69
  render={
70
70
  <Input
71
71
  {...props}
72
72
  {...rest}
73
- id={id}
74
73
  autoFocus={autoFocus}
75
74
  className={clsx(cls.input, inputClassName)}
76
75
  ref={useMergedRef(innerInputRef, inputRef || emptyRef)}
77
- aria-describedby={description ? `${id}-description` : undefined}
78
76
  />
79
77
  }
80
78
  />
81
- {description && (
82
- <Field.Description id={`${id}-description`}>
83
- {description}
84
- </Field.Description>
85
- )}
79
+ {description && <Field.Description>{description}</Field.Description>}
86
80
  </Field>
87
81
  );
88
82
  };
@@ -129,8 +123,8 @@ export function TextAreaField({
129
123
  const id = useIdOrGenerated(providedId);
130
124
 
131
125
  return (
132
- <Field stretch className={className} ref={ref}>
133
- {label && <Field.Label htmlFor={id}>{label}</Field.Label>}
126
+ <Field stretch className={className} ref={ref} id={id}>
127
+ {label && <Field.Label>{label}</Field.Label>}
134
128
  <Field.Control
135
129
  render={
136
130
  <TextArea
@@ -138,17 +132,11 @@ export function TextAreaField({
138
132
  {...props}
139
133
  {...rest}
140
134
  className={clsx(cls.input, textAreaClassName)}
141
- id={id}
142
135
  onKeyDown={onKeyDownInner}
143
- aria-describedby={description ? `${id}-description` : undefined}
144
136
  />
145
137
  }
146
138
  />
147
- {description && (
148
- <Field.Description id={`${id}-description`}>
149
- {description}
150
- </Field.Description>
151
- )}
139
+ {description && <Field.Description>{description}</Field.Description>}
152
140
  </Field>
153
141
  );
154
142
  }
@@ -1,5 +1,6 @@
1
1
  import { useField } from 'formik';
2
2
  import { ReactNode } from 'react';
3
+ import { useIdOrGenerated } from '../../hooks/useIdOrGenerated.js';
3
4
  import { ToggleGroup, ToggleGroupProps } from '../toggleGroup/toggleGroup.js';
4
5
  import { Field } from './Field.js';
5
6
 
@@ -22,36 +23,33 @@ function ToggleGroupFieldDefault({
22
23
  type = 'single',
23
24
  multiple,
24
25
  description,
25
- id,
26
+ id: providedId,
26
27
  ...props
27
28
  }: ToggleGroupFieldProps<string>) {
29
+ const id = useIdOrGenerated(providedId);
28
30
  const [fieldProps, _, tools] = useField({ name, required, ...props });
29
31
 
30
32
  return (
31
- <Field>
32
- {label && <Field.Label htmlFor={id}>{label}</Field.Label>}
33
- <Field.Control>
34
- <ToggleGroup
35
- {...fieldProps}
36
- onValueChange={(v) => {
37
- if (multiple || type === 'multiple') {
38
- tools.setValue(v);
39
- } else {
40
- tools.setValue(v[0]);
41
- }
42
- }}
43
- multiple={multiple || type === 'multiple'}
44
- {...props}
45
- id={id}
46
- className={className}
47
- aria-describedby={description ? `${id}-description` : undefined}
48
- />
49
- </Field.Control>
50
- {description && (
51
- <Field.Description id={`${id}-description`}>
52
- {description}
53
- </Field.Description>
54
- )}
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
+ }
51
+ />
52
+ {description && <Field.Description>{description}</Field.Description>}
55
53
  </Field>
56
54
  );
57
55
  }