@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.
Files changed (50) hide show
  1. package/dist/components/forms/CheckboxField.d.ts +3 -1
  2. package/dist/components/forms/CheckboxField.js +5 -6
  3. package/dist/components/forms/CheckboxField.js.map +1 -1
  4. package/dist/components/forms/EmojiField.d.ts +3 -1
  5. package/dist/components/forms/EmojiField.js +4 -5
  6. package/dist/components/forms/EmojiField.js.map +1 -1
  7. package/dist/components/forms/Field.d.ts +21 -0
  8. package/dist/components/forms/Field.js +71 -0
  9. package/dist/components/forms/Field.js.map +1 -0
  10. package/dist/components/forms/Field.module.css +62 -0
  11. package/dist/components/forms/Form.module.css +1 -1
  12. package/dist/components/forms/FormikForm.d.ts +2 -2
  13. package/dist/components/forms/FormikForm.stories.d.ts +2 -2
  14. package/dist/components/forms/FormikForm.stories.js +1 -1
  15. package/dist/components/forms/FormikForm.stories.js.map +1 -1
  16. package/dist/components/forms/NumberStepperField.d.ts +3 -1
  17. package/dist/components/forms/NumberStepperField.js +6 -9
  18. package/dist/components/forms/NumberStepperField.js.map +1 -1
  19. package/dist/components/forms/SwitchField.d.ts +3 -1
  20. package/dist/components/forms/SwitchField.js +5 -6
  21. package/dist/components/forms/SwitchField.js.map +1 -1
  22. package/dist/components/forms/TextField.d.ts +7 -5
  23. package/dist/components/forms/TextField.js +5 -7
  24. package/dist/components/forms/TextField.js.map +1 -1
  25. package/dist/components/forms/ToggleGroupField.d.ts +3 -1
  26. package/dist/components/forms/ToggleGroupField.js +12 -11
  27. package/dist/components/forms/ToggleGroupField.js.map +1 -1
  28. package/dist/components/forms/index.d.ts +1 -1
  29. package/dist/components/forms/index.js +1 -1
  30. package/dist/components/forms/index.js.map +1 -1
  31. package/dist/components/switch/Switch.module.css +1 -1
  32. package/package.json +1 -1
  33. package/src/components/forms/CheckboxField.tsx +19 -15
  34. package/src/components/forms/EmojiField.tsx +15 -9
  35. package/src/components/forms/Field.module.css +62 -0
  36. package/src/components/forms/Field.tsx +125 -0
  37. package/src/components/forms/Form.module.css +1 -1
  38. package/src/components/forms/FormikForm.stories.tsx +25 -5
  39. package/src/components/forms/NumberStepperField.tsx +19 -16
  40. package/src/components/forms/SwitchField.tsx +19 -15
  41. package/src/components/forms/TextField.tsx +37 -25
  42. package/src/components/forms/ToggleGroupField.tsx +27 -19
  43. package/src/components/forms/index.tsx +1 -1
  44. package/src/components/switch/Switch.module.css +1 -1
  45. package/dist/components/forms/FieldLabel.d.ts +0 -2
  46. package/dist/components/forms/FieldLabel.js +0 -5
  47. package/dist/components/forms/FieldLabel.js.map +0 -1
  48. package/dist/components/forms/FieldLabel.module.css +0 -20
  49. package/src/components/forms/FieldLabel.module.css +0 -20
  50. package/src/components/forms/FieldLabel.tsx +0 -9
@@ -1,8 +1,10 @@
1
+ import { ReactNode } from 'react';
1
2
  export interface CheckboxFieldProps {
2
3
  name: string;
3
4
  label?: string;
4
5
  required?: boolean;
5
6
  className?: string;
6
7
  id?: string;
8
+ description?: ReactNode;
7
9
  }
8
- export declare function CheckboxField({ name, label, className, required, id: providedId, ...rest }: CheckboxFieldProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function CheckboxField({ name, label, className, required, id: providedId, description, ...rest }: CheckboxFieldProps): import("react/jsx-runtime").JSX.Element;
@@ -12,15 +12,14 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { useField } from 'formik';
14
14
  import { useIdOrGenerated } from '../../hooks/useIdOrGenerated.js';
15
- import { Box } from '../box/Box.js';
16
15
  import { Checkbox } from '../checkbox/index.js';
17
- import { HorizontalFieldLabel } from './FieldLabel.js';
16
+ import { Field } from './Field.js';
18
17
  export function CheckboxField(_a) {
19
- var { name, label, className, required, id: providedId } = _a, rest = __rest(_a, ["name", "label", "className", "required", "id"]);
18
+ var { name, label, className, required, id: providedId, description } = _a, rest = __rest(_a, ["name", "label", "className", "required", "id", "description"]);
20
19
  const [props, _, tools] = useField({ name, required, type: 'checkbox' });
21
20
  const id = useIdOrGenerated(providedId);
22
- return (_jsxs(Box, { gap: "md", className: className, children: [_jsx(Checkbox, Object.assign({}, props, { checked: props.checked, onCheckedChange: (v) => {
23
- tools.setValue(!!v);
24
- }, id: id }, rest)), label && (_jsx(HorizontalFieldLabel, { htmlFor: id, children: label }))] }));
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
+ tools.setValue(!!v);
23
+ } }, rest)) }), label && _jsx(Field.Label, { children: label }), description && _jsx(Field.Description, { children: description })] }));
25
24
  }
26
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;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAUvD,MAAM,UAAU,aAAa,CAAC,EAOT;QAPS,EAC7B,IAAI,EACJ,KAAK,EACL,SAAS,EACT,QAAQ,EACR,EAAE,EAAE,UAAU,OAEM,EADjB,IAAI,cANsB,gDAO7B,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,C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O,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"}
@@ -1,8 +1,10 @@
1
+ import { ReactNode } from 'react';
1
2
  import { ButtonProps } from '../button/Button.js';
2
3
  export type EmojiFieldProps = Omit<ButtonProps, 'className'> & {
3
4
  name: string;
4
5
  label?: string;
5
6
  required?: string;
6
7
  className?: string;
8
+ description?: ReactNode;
7
9
  };
8
- export declare function EmojiField({ name, label, className, required, id: providedId, ...rest }: EmojiFieldProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function EmojiField({ name, label, className, required, id: providedId, description, ...rest }: EmojiFieldProps): import("react/jsx-runtime").JSX.Element;
@@ -13,19 +13,18 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { useField } from 'formik';
14
14
  import { useState } from 'react';
15
15
  import { useIdOrGenerated } from '../../hooks/useIdOrGenerated.js';
16
- import { Box } from '../box/Box.js';
17
16
  import { Button } from '../button/Button.js';
18
17
  import { EmojiPicker } from '../emojiPicker/EmojiPicker.js';
19
18
  import { Icon } from '../icon/Icon.js';
20
19
  import { Popover } from '../popover/Popover.js';
21
20
  import cls from './EmojiField.module.css';
22
- import { HorizontalFieldLabel } from './FieldLabel.js';
21
+ import { Field } from './Field.js';
23
22
  export function EmojiField(_a) {
24
- var { name, label, className, required, id: providedId } = _a, rest = __rest(_a, ["name", "label", "className", "required", "id"]);
23
+ var { name, label, className, required, id: providedId, description } = _a, rest = __rest(_a, ["name", "label", "className", "required", "id", "description"]);
25
24
  const [props, _, tools] = useField({ name });
26
25
  const id = useIdOrGenerated(providedId);
27
26
  const [open, setOpen] = useState(false);
28
- return (_jsxs(Box, { gap: "md", className: className, children: [_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(Popover.Trigger, { render: _jsx(Button, Object.assign({ id: id, "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) => {
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) => {
29
28
  tools.setValue(v);
30
29
  setOpen(false);
31
30
  }, onClear: required
@@ -33,6 +32,6 @@ export function EmojiField(_a) {
33
32
  : () => {
34
33
  tools.setValue('');
35
34
  setOpen(false);
36
- }, id: id }) })] }), label && (_jsx(HorizontalFieldLabel, { htmlFor: id, children: label }))] }));
35
+ }, id: id }) })] }), label && _jsx(Field.Label, { children: label }), description && _jsx(Field.Description, { children: description })] }));
37
36
  }
38
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,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,GAAG,EAAE,MAA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@ -0,0 +1,21 @@
1
+ import { ComponentProps } from 'react';
2
+ import { SlotDiv } from '../utility/SlotDiv.js';
3
+ export interface FieldRootProps extends ComponentProps<'div'> {
4
+ horizontal?: boolean;
5
+ stretch?: boolean;
6
+ reverse?: boolean;
7
+ /**
8
+ * This ID will be passed to Control, and Label will be associated.
9
+ */
10
+ id?: string;
11
+ }
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;
14
+ declare function FieldLabel({ className, ...props }: ComponentProps<'label'>): import("react/jsx-runtime").JSX.Element;
15
+ declare function FieldDescription({ className, ...props }: ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
16
+ export declare const Field: typeof FieldRoot & {
17
+ Label: typeof FieldLabel;
18
+ Description: typeof FieldDescription;
19
+ Control: typeof FieldControl;
20
+ };
21
+ export {};
@@ -0,0 +1,71 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import clsx from 'clsx';
14
+ import { createContext, useContext, useEffect, useRef, useState, } from 'react';
15
+ import useMergedRef from '../../hooks/useMergedRef.js';
16
+ import { SlotDiv } from '../utility/SlotDiv.js';
17
+ import cls from './Field.module.css';
18
+ const FieldContext = createContext({
19
+ events: new EventTarget(),
20
+ });
21
+ function FieldRoot(_a) {
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)) }));
25
+ }
26
+ function FieldControl(_a) {
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)));
49
+ }
50
+ function FieldLabel(_a) {
51
+ var { className } = _a, props = __rest(_a, ["className"]);
52
+ const { id } = useContext(FieldContext);
53
+ return (_jsx("label", Object.assign({ className: clsx(cls.label, className), htmlFor: id }, props)));
54
+ }
55
+ function FieldDescription(_a) {
56
+ var { className } = _a, props = __rest(_a, ["className"]);
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)));
65
+ }
66
+ export const Field = Object.assign(FieldRoot, {
67
+ Label: FieldLabel,
68
+ Description: FieldDescription,
69
+ Control: FieldControl,
70
+ });
71
+ //# sourceMappingURL=Field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Field.js","sourceRoot":"","sources":["../../../src/components/forms/Field.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAEN,aAAa,EACb,UAAU,EACV,SAAS,EACT,MAAM,EACN,QAAQ,GACR,MAAM,OAAO,CAAC;AACf,OAAO,YAAY,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,GAAG,MAAM,oBAAoB,CAAC;AAYrC,MAAM,YAAY,GAAG,aAAa,CAAuC;IACxE,MAAM,EAAE,IAAI,WAAW,EAAE;CACzB,CAAC,CAAC;AAEH,SAAS,SAAS,CAAC,EAOF;QAPE,EAClB,SAAS,EACT,UAAU,EACV,OAAO,EACP,OAAO,EACP,EAAE,OAEc,EADb,KAAK,cANU,uDAOlB,CADQ;IAER,MAAM,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,WAAW,EAAE,CAAC,CAAC;IACnD,OAAO,CACN,KAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,YAC3C,KAAC,OAAO,kBACP,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,qBACnB,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,kBAC9B,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,kBACxB,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,IAClC,KAAK,EACR,GACqB,CACxB,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,EAIW;Q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BAAO,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,OAAO,EAAE,EAAE,IAAM,KAAK,EAAI,CACxE,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,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"}
@@ -0,0 +1,62 @@
1
+ .root {
2
+ display: grid;
3
+ grid-template-areas: 'label' 'control' 'description';
4
+ justify-content: start;
5
+
6
+ &[data-horizontal] {
7
+ flex-direction: row;
8
+ align-items: center;
9
+ grid-template-areas: 'control label' 'description description';
10
+ grid-template-columns: auto 1fr;
11
+ &[data-reverse] {
12
+ grid-template-areas: 'label control' 'description description';
13
+ grid-template-columns: auto 1fr;
14
+ }
15
+ }
16
+
17
+ &[data-stretch] {
18
+ align-self: stretch;
19
+ justify-content: stretch;
20
+ }
21
+ }
22
+
23
+ .control {
24
+ grid-area: control;
25
+
26
+ [data-stretch] & {
27
+ align-self: stretch;
28
+ justify-content: stretch;
29
+ width: 100%;
30
+ }
31
+ }
32
+
33
+ .label {
34
+ grid-area: label;
35
+ @apply --mx-prose-ambient;
36
+ @apply --mx-fg(var(--m-color-neutral-heavy));
37
+ font-weight: var(--m-text-weight-bold);
38
+ margin-bottom: var(--m-space-xs);
39
+ margin-left: calc(var(--m-global-shape-roundness) * var(--m-space-md));
40
+
41
+ [data-horizontal] & {
42
+ @apply --mx-fg(var(--m-color-neutral-ink));
43
+ font-weight: var(--m-text-weight-normal);
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
+ }
52
+ }
53
+ }
54
+
55
+ .description {
56
+ grid-area: description;
57
+ @apply --mx-prose-ambient;
58
+ @apply --mx-fg(var(--m-color-neutral-heavy));
59
+ font-style: italic;
60
+ margin-top: var(--m-space-sm);
61
+ margin-left: calc(var(--m-global-shape-roundness) * var(--m-space-md));
62
+ }
@@ -2,5 +2,5 @@
2
2
  display: flex;
3
3
  align-items: start;
4
4
  flex-direction: column;
5
- gap: var(--m-space-md);
5
+ gap: var(--m-space-lg);
6
6
  }
@@ -11,13 +11,13 @@ export interface FormikFormProps<T extends FormikValues = FormikValues> extends
11
11
  export { FieldArray } from 'formik';
12
12
  export declare function FormikFormRoot<Values extends FormikValues>({ className, children, onSubmit, ...props }: FormikFormProps<Values>): import("react/jsx-runtime").JSX.Element;
13
13
  export declare const FormikForm: typeof FormikFormRoot & {
14
- TextField: ({ ref, name, label, className, autoFocusDelay, autoFocus, inputRef, onChange, onFocus, onBlur, id: providedId, inputClassName, ...rest }: import("./TextField.js").TextFieldProps) => import("react/jsx-runtime").JSX.Element;
14
+ TextField: ({ ref, name, label, className, autoFocusDelay, autoFocus, inputRef, onChange, onFocus, onBlur, id: providedId, inputClassName, description, ...rest }: import("./TextField.js").TextFieldProps) => import("react/jsx-runtime").JSX.Element;
15
15
  TextAreaField: typeof TextAreaField;
16
16
  NumberStepperField: typeof NumberStepperField;
17
17
  SubmitButton: typeof SubmitButton;
18
18
  CheckboxField: typeof CheckboxField;
19
19
  SwitchField: typeof SwitchField;
20
- ToggleGroupField: (({ name, label, required, className, type, multiple, 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;
@@ -8,13 +8,13 @@ import { SwitchField } from './SwitchField.js';
8
8
  declare const meta: {
9
9
  title: string;
10
10
  component: typeof import("./FormikForm.js").FormikFormRoot & {
11
- TextField: ({ ref, name, label, className, autoFocusDelay, autoFocus, inputRef, onChange, onFocus, onBlur, id: providedId, inputClassName, ...rest }: import("./TextField.js").TextFieldProps) => import("react/jsx-runtime").JSX.Element;
11
+ TextField: ({ ref, name, label, className, autoFocusDelay, autoFocus, inputRef, onChange, onFocus, onBlur, id: providedId, inputClassName, description, ...rest }: import("./TextField.js").TextFieldProps) => import("react/jsx-runtime").JSX.Element;
12
12
  TextAreaField: typeof import("./TextField.js").TextAreaField;
13
13
  NumberStepperField: typeof NumberStepperField;
14
14
  SubmitButton: typeof SubmitButton;
15
15
  CheckboxField: typeof CheckboxField;
16
16
  SwitchField: typeof SwitchField;
17
- ToggleGroupField: (({ name, label, required, className, type, multiple, 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;
@@ -43,7 +43,7 @@ export const Default = {
43
43
  newsletter: false,
44
44
  plan: 'basic',
45
45
  emoji: '',
46
- } }, args, { children: [_jsx(TextField, { name: "email", type: "email", label: "Email", placeholder: "you@example.com" }), _jsx(TextField, { name: "password", type: "password", label: "Password" }), _jsx(NumberStepperField, { name: "age", label: "Age", min: 13, max: 100 }), _jsx(CheckboxField, { name: "tos", label: "I agree" }), _jsx(SwitchField, { name: "newsletter", label: "Subscribe to newsletter" }), _jsxs(ToggleGroupField, { type: "single", name: "plan", label: "Select your plan", required: true, children: [_jsx(ToggleGroupField.Item, { value: "basic", children: "Basic" }), _jsx(ToggleGroupField.Item, { value: "pro", children: "Pro" }), _jsx(ToggleGroupField.Item, { value: "enterprise", children: "Enterprise" })] }), _jsx(EmojiField, { name: "emoji", label: "Favorite Emoji" }), _jsx(SubmitButton, { children: "Sign up" })] })));
46
+ } }, args, { children: [_jsx(TextField, { name: "email", type: "email", label: "Email", placeholder: "you@example.com" }), _jsx(TextField, { name: "password", type: "password", label: "Password", description: "Make it a good one" }), _jsx(NumberStepperField, { name: "age", label: "Age", min: 13, max: 100, description: "You can mail your government ID to us, don't worry, we're the good guys" }), _jsx(CheckboxField, { name: "tos", label: "I agree", description: "To what? Not telling." }), _jsx(SwitchField, { name: "newsletter", label: "Subscribe to newsletter", description: "Don't worry, we don't bother you much" }), _jsxs(ToggleGroupField, { type: "single", name: "plan", label: "Select your plan", required: true, description: "Please do the expensive one!!!", children: [_jsx(ToggleGroupField.Item, { value: "basic", children: "Basic" }), _jsx(ToggleGroupField.Item, { value: "pro", children: "Pro" }), _jsx(ToggleGroupField.Item, { value: "enterprise", className: "@mode-accent", children: "Enterprise" })] }), _jsx(EmojiField, { name: "emoji", label: "Favorite Emoji" }), _jsx(SubmitButton, { children: "Sign up" })] })));
47
47
  },
48
48
  };
49
49
  //# sourceMappingURL=FormikForm.stories.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FormikForm.stories.js","sourceRoot":"","sources":["../../../src/components/forms/FormikForm.stories.tsx"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,IAAI,GAAG;IACZ,KAAK,EAAE,iBAAiB;IACxB,SAAS,EAAE,UAAU;IACrB,QAAQ,EAAE,EAAE;IACZ,UAAU,EAAE;QACX,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC5B;CACiC,CAAC;AAEpC,eAAe,IAAI,CAAC;AAIpB,MAAM,CAAC,MAAM,OAAO,GAAU;IAC7B,IAAI,EAAE;QACL,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE;YACpB,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACxC,CAAC;KACD;IACD,MAAM,CAAC,EAA6B;YAA7B,EAAE,aAAa,EAAE,CAA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T,IACG,IAAI,eAER,KAAC,SAAS,IACT,IAAI,EAAC,OAAO,EACZ,IAAI,EAAC,OAAO,EACZ,KAAK,EAAC,OAAO,EACb,WAAW,EAAC,iBAAiB,GAC5B,EACF,KAAC,SAAS,IACT,IAAI,EAAC,UAAU,EACf,IAAI,EAAC,UAAU,EACf,KAAK,EAAC,UAAU,EAChB,WAAW,EAAC,oBAAoB,GAC/B,EACF,KAAC,kBAAkB,IAClB,IAAI,EAAC,KAAK,EACV,KAAK,EAAC,KAAK,EACX,GAAG,EAAE,EAAE,EACP,GAAG,EAAE,GAAG,EACR,WAAW,EAAC,yEAAyE,GACpF,EACF,KAAC,aAAa,IACb,IAAI,EAAC,KAAK,EACV,KAAK,EAAC,SAAS,EACf,WAAW,EAAC,uBAAuB,GAClC,EACF,KAAC,WAAW,IACX,IAAI,EAAC,YAAY,EACjB,KAAK,EAAC,yBAAyB,EAC/B,WAAW,EAAC,uCAAuC,GAClD,EACF,MAAC,gBAAgB,IAChB,IAAI,EAAC,QAAQ,EACb,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,kBAAkB,EACxB,QAAQ,QACR,WAAW,EAAC,gCAAgC,aAE5C,KAAC,gBAAgB,CAAC,IAAI,IAAC,KAAK,EAAC,OAAO,sBAA8B,EAClE,KAAC,gBAAgB,CAAC,IAAI,IAAC,KAAK,EAAC,KAAK,oBAA4B,EAC9D,KAAC,gBAAgB,CAAC,IAAI,IAAC,KAAK,EAAC,YAAY,EAAC,SAAS,EAAC,cAAc,2BAE1C,IACN,EACnB,KAAC,UAAU,IAAC,IAAI,EAAC,OAAO,EAAC,KAAK,EAAC,gBAAgB,GAAG,EAClD,KAAC,YAAY,0BAAuB,KACxB,CACb,CAAC;IACH,CAAC;CACD,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { ReactNode } from 'react';
1
2
  import { NumberStepperProps } from '../numberStepper/NumberStepper.js';
2
3
  export interface NumberStepperFieldProps extends Omit<NumberStepperProps, 'value' | 'onChange'> {
3
4
  name: string;
@@ -5,5 +6,6 @@ export interface NumberStepperFieldProps extends Omit<NumberStepperProps, 'value
5
6
  className?: string;
6
7
  id?: string;
7
8
  onChange?: (value: number) => void;
9
+ description?: ReactNode;
8
10
  }
9
- export declare function NumberStepperField({ name, label, className, id: providedId, onChange, ...rest }: NumberStepperFieldProps): import("react/jsx-runtime").JSX.Element;
11
+ export declare function NumberStepperField({ name, label, className, id: providedId, onChange, description, ...rest }: NumberStepperFieldProps): import("react/jsx-runtime").JSX.Element;
@@ -11,19 +11,16 @@ 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 { withClassName } from '../../hooks.js';
15
14
  import { useIdOrGenerated } from '../../hooks/useIdOrGenerated.js';
16
15
  import { NumberStepper, } from '../numberStepper/NumberStepper.js';
17
- import { FieldLabel } from './FieldLabel.js';
18
- import cls from './NumberStepperField.module.css';
16
+ import { Field } from './Field.js';
19
17
  export function NumberStepperField(_a) {
20
- var { name, label, className, id: providedId, onChange } = _a, rest = __rest(_a, ["name", "label", "className", "id", "onChange"]);
18
+ var { name, label, className, id: providedId, onChange, description } = _a, rest = __rest(_a, ["name", "label", "className", "id", "onChange", "description"]);
21
19
  const [_, field, tools] = useField({ name });
22
20
  const id = useIdOrGenerated(providedId);
23
- return (_jsxs(FieldRoot, { className: className, children: [label && _jsx(FieldLabel, { htmlFor: id, children: label }), _jsx(NumberStepper, Object.assign({ value: field.value, onChange: (v) => {
24
- tools.setValue(v);
25
- onChange === null || onChange === void 0 ? void 0 : onChange(v);
26
- }, id: id }, rest))] }));
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
+ tools.setValue(v);
23
+ onChange === null || onChange === void 0 ? void 0 : onChange(v);
24
+ } }, rest)) }), description && _jsx(Field.Description, { children: description })] }));
27
25
  }
28
- const FieldRoot = withClassName('div', cls.root);
29
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;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EACN,aAAa,GAEb,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,GAAG,MAAM,iCAAiC,CAAC;AAWlD,MAAM,UAAU,kBAAkB,CAAC,EAOT;QAPS,EAClC,IAAI,EACJ,KAAK,EACL,SAAS,EACT,EAAE,EAAE,UAAU,EACd,QAAQ,OAEiB,EADtB,IAAI,cAN2B,gDAOlC,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,SAAS,IAAC,SAAS,EAAE,SAAS,aAC7B,KAAK,IAAI,KAAC,UAAU,IAAC,OAAO,EAAE,EAAE,YAAG,KAAK,GAAc,EACvD,KAAC,aAAa,kBACb,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;oBACf,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;oBAClB,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAG,CAAC,CAAC,CAAC;gBACf,CAAC,EACD,EAAE,EAAE,EAAE,IACF,IAAI,EACP,IACS,CACZ,CAAC;AACH,CAAC;AAED,MAAM,SA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import { ReactNode } from 'react';
1
2
  export interface SwitchFieldProps {
2
3
  name: string;
3
4
  label?: string;
4
5
  required?: boolean;
5
6
  className?: string;
6
7
  id?: string;
8
+ description?: ReactNode;
7
9
  }
8
- export declare function SwitchField({ name, label, className, required, id: providedId, ...rest }: SwitchFieldProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function SwitchField({ name, label, className, required, id: providedId, description, ...rest }: SwitchFieldProps): import("react/jsx-runtime").JSX.Element;
@@ -12,15 +12,14 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { useField } from 'formik';
14
14
  import { useIdOrGenerated } from '../../hooks/useIdOrGenerated.js';
15
- import { Box } from '../box/Box.js';
16
15
  import { Switch } from '../switch/Switch.js';
17
- import { HorizontalFieldLabel } from './FieldLabel.js';
16
+ import { Field } from './Field.js';
18
17
  export function SwitchField(_a) {
19
- var { name, label, className, required, id: providedId } = _a, rest = __rest(_a, ["name", "label", "className", "required", "id"]);
18
+ var { name, label, className, required, id: providedId, description } = _a, rest = __rest(_a, ["name", "label", "className", "required", "id", "description"]);
20
19
  const [props, _, tools] = useField({ name, required, type: 'checkbox' });
21
20
  const id = useIdOrGenerated(providedId);
22
- return (_jsxs(Box, { gap: "md", className: className, children: [_jsx(Switch, Object.assign({}, props, { checked: props.checked, onCheckedChange: (v) => {
23
- tools.setValue(!!v);
24
- }, id: id }, rest)), label && (_jsx(HorizontalFieldLabel, { htmlFor: id, children: label }))] }));
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
+ tools.setValue(!!v);
23
+ } }, rest)) }), label && _jsx(Field.Label, { children: label }), description && _jsx(Field.Description, { children: description })] }));
25
24
  }
26
25
  //# sourceMappingURL=SwitchField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SwitchField.js","sourceRoot":"","sources":["../../../src/components/forms/SwitchField.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAUvD,MAAM,UAAU,WAAW,CAAC,EAOT;QAPS,EAC3B,IAAI,EACJ,KAAK,EACL,SAAS,EACT,QAAQ,EACR,EAAE,EAAE,UAAU,OAEI,EADf,IAAI,cANoB,gDAO3B,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,GAAG,IAAC,GAAG,EAAC,IAAI,EAAC,SAAS,EAAE,SAAS,aACjC,KAAC,MAAM,oBACF,KAAK,IACT,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,eAAe,EAAE,CAAC,CAAC,EAAE,EAAE;oBACtB,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACrB,CAAC,EACD,EAAE,EAAE,EAAE,IACF,IAAI,EACP,EACD,KAAK,IAAI,CACT,KAAC,oBAAoB,IAAC,OAAO,EAAE,EAAE,YAAG,KAAK,GAAwB,CACjE,IACI,CACN,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"}
@@ -1,4 +1,4 @@
1
- import { InputHTMLAttributes, Ref } from 'react';
1
+ import { InputHTMLAttributes, ReactNode, Ref } from 'react';
2
2
  import { InputProps } from '../input/Input.js';
3
3
  import { TextAreaProps } from '../textArea/TextArea.js';
4
4
  export type TextFieldProps = {
@@ -9,8 +9,9 @@ export type TextFieldProps = {
9
9
  inputRef?: Ref<HTMLInputElement>;
10
10
  inputClassName?: string;
11
11
  ref?: Ref<HTMLDivElement>;
12
+ description?: ReactNode;
12
13
  } & Omit<InputProps, 'ref'>;
13
- export declare const TextField: ({ ref, name, label, className, autoFocusDelay, autoFocus, inputRef, onChange, onFocus, onBlur, id: providedId, inputClassName, ...rest }: TextFieldProps) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const TextField: ({ ref, name, label, className, autoFocusDelay, autoFocus, inputRef, onChange, onFocus, onBlur, id: providedId, inputClassName, description, ...rest }: TextFieldProps) => import("react/jsx-runtime").JSX.Element;
14
15
  export type TextAreaFieldProps = {
15
16
  name: string;
16
17
  label?: string;
@@ -21,6 +22,7 @@ export type TextAreaFieldProps = {
21
22
  inputRef?: Ref<HTMLTextAreaElement>;
22
23
  submitOnEnter?: boolean;
23
24
  textAreaClassName?: string;
24
- } & TextAreaProps;
25
- export declare function TextAreaField({ name, label, className, inputRef, onKeyDown, submitOnEnter, id: providedId, textAreaClassName, ...rest }: TextAreaFieldProps): import("react/jsx-runtime").JSX.Element;
26
- export declare const FieldRoot: import("react").FunctionComponent<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
25
+ description?: ReactNode;
26
+ ref?: Ref<HTMLDivElement>;
27
+ } & Omit<TextAreaProps, 'ref'>;
28
+ export declare function TextAreaField({ name, label, className, inputRef, onKeyDown, submitOnEnter, id: providedId, textAreaClassName, description, ref, ...rest }: TextAreaFieldProps): import("react/jsx-runtime").JSX.Element;
@@ -13,16 +13,15 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import clsx from 'clsx';
14
14
  import { useField, useFormikContext } from 'formik';
15
15
  import { useCallback, useEffect, useRef, } from 'react';
16
- import { withClassName } from '../../hooks.js';
17
16
  import { useIdOrGenerated } from '../../hooks/useIdOrGenerated.js';
18
17
  import useMergedRef from '../../hooks/useMergedRef.js';
19
18
  import { Input } from '../input/Input.js';
20
19
  import { TextArea } from '../textArea/TextArea.js';
21
- import { FieldLabel } from './FieldLabel.js';
20
+ import { Field } from './Field.js';
22
21
  import cls from './TextField.module.css';
23
22
  const emptyRef = (() => { });
24
23
  export const TextField = function TextField(_a) {
25
- var { ref, name, label, className, autoFocusDelay, autoFocus, inputRef, onChange, onFocus, onBlur, id: providedId, inputClassName } = _a, rest = __rest(_a, ["ref", "name", "label", "className", "autoFocusDelay", "autoFocus", "inputRef", "onChange", "onFocus", "onBlur", "id", "inputClassName"]);
24
+ var { ref, name, label, className, autoFocusDelay, autoFocus, inputRef, onChange, onFocus, onBlur, id: providedId, inputClassName, description } = _a, rest = __rest(_a, ["ref", "name", "label", "className", "autoFocusDelay", "autoFocus", "inputRef", "onChange", "onFocus", "onBlur", "id", "inputClassName", "description"]);
26
25
  const [props] = useField({
27
26
  name,
28
27
  onChange,
@@ -39,10 +38,10 @@ export const TextField = function TextField(_a) {
39
38
  }, autoFocusDelay);
40
39
  }
41
40
  }, [autoFocusDelay]);
42
- return (_jsxs(FieldRoot, { className: className, ref: ref, children: [label && _jsx(FieldLabel, { htmlFor: id, children: label }), _jsx(Input, Object.assign({}, props, rest, { id: id, autoFocus: autoFocus, className: clsx(cls.input, inputClassName), ref: useMergedRef(innerInputRef, inputRef || emptyRef) }))] }));
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 })] }));
43
42
  };
44
43
  export function TextAreaField(_a) {
45
- var { name, label, className, inputRef, onKeyDown, submitOnEnter, id: providedId, textAreaClassName } = _a, rest = __rest(_a, ["name", "label", "className", "inputRef", "onKeyDown", "submitOnEnter", "id", "textAreaClassName"]);
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"]);
46
45
  const [props] = useField(name);
47
46
  const { submitForm } = useFormikContext();
48
47
  const onKeyDownInner = useCallback((e) => {
@@ -53,7 +52,6 @@ export function TextAreaField(_a) {
53
52
  onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
54
53
  }, [submitOnEnter, onKeyDown, submitForm]);
55
54
  const id = useIdOrGenerated(providedId);
56
- return (_jsxs(FieldRoot, { className: className, children: [label && _jsx(FieldLabel, { htmlFor: id, children: label }), _jsx(TextArea, Object.assign({ ref: inputRef }, props, rest, { className: clsx('layer-composed:w-full', textAreaClassName), id: id, onKeyDown: onKeyDownInner }))] }));
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 })] }));
57
56
  }
58
- export const FieldRoot = withClassName('div', cls.root);
59
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,EAIN,WAAW,EACX,SAAS,EACT,MAAM,GACN,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,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,E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BAAT,SAAS,CAAG,CAAQ,CAAC,CAAC;IACvB,CAAC,EACD,CAAC,aAAa,EAAE,SAAS,EAAE,UAAU,CAAC,CACtC,CAAC;IACF,MAAM,EAAE,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAExC,OAAO,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"}
@@ -1,3 +1,4 @@
1
+ import { ReactNode } from 'react';
1
2
  import { ToggleGroupProps } from '../toggleGroup/toggleGroup.js';
2
3
  export type ToggleGroupFieldProps<Value extends string> = ToggleGroupProps<Value> & {
3
4
  name: string;
@@ -6,8 +7,9 @@ export type ToggleGroupFieldProps<Value extends string> = ToggleGroupProps<Value
6
7
  className?: string;
7
8
  id?: string;
8
9
  type?: 'single' | 'multiple';
10
+ description?: ReactNode;
9
11
  };
10
- declare function ToggleGroupFieldDefault({ name, label, required, className, type, multiple, 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;
11
13
  export declare const ToggleGroupField: typeof ToggleGroupFieldDefault & {
12
14
  Item: import("react").FunctionComponent<import("@base-ui/react").Toggle.Props<string> & import("react").RefAttributes<HTMLButtonElement>>;
13
15
  };
@@ -11,20 +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
- import { FieldLabel } from './FieldLabel.js';
16
- import { FieldRoot } from './TextField.js';
16
+ import { Field } from './Field.js';
17
17
  function ToggleGroupFieldDefault(_a) {
18
- var { name, label, required, className, type = 'single', multiple, id } = _a, props = __rest(_a, ["name", "label", "required", "className", "type", "multiple", "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);
19
20
  const [fieldProps, _, tools] = useField(Object.assign({ name, required }, props));
20
- return (_jsxs(FieldRoot, { children: [label && _jsx(FieldLabel, { htmlFor: id, children: label }), _jsx(ToggleGroup, Object.assign({}, fieldProps, { onValueChange: (v) => {
21
- if (multiple || type === 'multiple') {
22
- tools.setValue(v);
23
- }
24
- else {
25
- tools.setValue(v[0]);
26
- }
27
- }, multiple: multiple || type === 'multiple' }, props, { id: id, className: className }))] }));
21
+ return (_jsxs(Field, { id: id, children: [label && _jsx(Field.Label, { children: label }), _jsx(Field.Control, { render: _jsx(ToggleGroup, Object.assign({}, fieldProps, { onValueChange: (v) => {
22
+ if (multiple || type === 'multiple') {
23
+ tools.setValue(v);
24
+ }
25
+ else {
26
+ tools.setValue(v[0]);
27
+ }
28
+ }, multiple: multiple || type === 'multiple' }, props, { className: className })) }), description && _jsx(Field.Description, { children: description })] }));
28
29
  }
29
30
  export const ToggleGroupField = Object.assign(ToggleGroupFieldDefault, {
30
31
  Item: ToggleGroup.Item,
@@ -1 +1 @@
1
- {"version":3,"file":"ToggleGroupField.js","sourceRoot":"","sources":["../../../src/components/forms/ToggleGro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cAAE,WAAW,GAAqB,IAC7D,CACR,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,uBAAuB,EAAE;IACtE,IAAI,EAAE,WAAW,CAAC,IAAI;CACtB,CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  export * from './CheckboxField.js';
2
- export * from './FieldLabel.js';
2
+ export * from './Field.js';
3
3
  export * from './Form.js';
4
4
  export * from './FormikForm.js';
5
5
  export * from './hooks.js';