@mirohq/design-system-form 0.1.0-forms.0 → 0.1.0-forms.1

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/main.js CHANGED
@@ -2,10 +2,12 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var jsxRuntime = require('react/jsx-runtime');
6
- var React = require('react');
7
5
  var designSystemPrimitive = require('@mirohq/design-system-primitive');
8
6
  var designSystemStitches = require('@mirohq/design-system-stitches');
7
+ var jsxRuntime = require('react/jsx-runtime');
8
+ var React = require('react');
9
+ var designSystemUtils = require('@mirohq/design-system-utils');
10
+ var designSystemUseId = require('@mirohq/design-system-use-id');
9
11
 
10
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
13
 
@@ -22,52 +24,151 @@ const StyledLabel = designSystemStitches.styled(designSystemPrimitive.Primitive.
22
24
  marginBottom: "$100"
23
25
  });
24
26
 
25
- const Label = React__default["default"].forwardRef((props, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx(StyledLabel, { ...props, ref: forwardRef }));
26
-
27
- const StyledField = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
28
- all: "unset",
29
- display: "block"
30
- });
31
-
32
- const Field = React__default["default"].forwardRef((props, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx(StyledField, { ...props, ref: forwardRef }));
27
+ const Label = StyledLabel;
28
+
29
+ const FormFieldContext = React.createContext({});
30
+ const FormFieldProvider = ({
31
+ children,
32
+ status: customStatus,
33
+ id: customId,
34
+ ...restProps
35
+ }) => {
36
+ const formElementRef = React.useRef(null);
37
+ const [status, setStatus] = React.useState(customStatus != null ? customStatus : "pristine");
38
+ const [focused, setFocused] = React.useState(false);
39
+ const autoId = designSystemUseId.useId();
40
+ const id = customId != null ? customId : autoId;
41
+ return /* @__PURE__ */ jsxRuntime.jsx(
42
+ FormFieldContext.Provider,
43
+ {
44
+ value: {
45
+ ...restProps,
46
+ id,
47
+ formElementRef,
48
+ messageId: "".concat(id, "-message"),
49
+ helperId: "".concat(id, "-helper"),
50
+ descriptionId: "".concat(id, "-description"),
51
+ status,
52
+ setStatus,
53
+ focused,
54
+ setFocused
55
+ },
56
+ children
57
+ }
58
+ );
59
+ };
60
+ const useFormFieldContext = () => React.useContext(FormFieldContext);
61
+
62
+ const StyledField = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {});
63
+
64
+ const Root = React__default["default"].forwardRef(
65
+ (props, forwardRef) => {
66
+ const {
67
+ id,
68
+ status,
69
+ required,
70
+ focused,
71
+ setFocused,
72
+ disabled,
73
+ ariaDisabled,
74
+ readOnly
75
+ } = useFormFieldContext();
76
+ return /* @__PURE__ */ jsxRuntime.jsx(
77
+ StyledField,
78
+ {
79
+ id,
80
+ "aria-disabled": ariaDisabled,
81
+ "aria-required": required,
82
+ "aria-invalid": status === "invalid",
83
+ "data-status": status,
84
+ "data-required": designSystemUtils.booleanishAttrValue(required),
85
+ "data-focused": designSystemUtils.booleanishAttrValue(focused),
86
+ "data-disabled": designSystemUtils.booleanishAttrValue(disabled),
87
+ "data-readonly": designSystemUtils.booleanishAttrValue(readOnly),
88
+ onFocus: () => setFocused == null ? void 0 : setFocused(true),
89
+ ...props,
90
+ ref: forwardRef
91
+ }
92
+ );
93
+ }
94
+ );
95
+ const Field = React__default["default"].forwardRef(
96
+ ({
97
+ id,
98
+ required,
99
+ status,
100
+ readOnly,
101
+ disabled,
102
+ "aria-disabled": ariaDisabled,
103
+ ...restProps
104
+ }, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx(
105
+ FormFieldProvider,
106
+ {
107
+ required,
108
+ status,
109
+ readOnly,
110
+ disabled,
111
+ "aria-disabled": ariaDisabled,
112
+ children: /* @__PURE__ */ jsxRuntime.jsx(Root, { ...restProps, ref: forwardRef })
113
+ }
114
+ )
115
+ );
33
116
 
34
- const StyledHelper = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
35
- display: "block",
117
+ const StyledHelper = designSystemStitches.styled(designSystemPrimitive.Primitive.p, {
36
118
  fontSize: "$150",
37
119
  lineHeight: 1.5,
38
120
  marginTop: "$50"
39
121
  });
40
122
 
41
- const Helper = React__default["default"].forwardRef((props, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx(StyledHelper, { ...props, ref: forwardRef }));
123
+ const Helper = React__default["default"].forwardRef((props, forwardRef) => {
124
+ const { helperId } = useFormFieldContext();
125
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledHelper, { id: helperId, ...props, ref: forwardRef });
126
+ });
42
127
 
43
128
  const StyledMessage = designSystemStitches.styled(Helper, {
44
129
  variants: {
45
- valid: {
46
- true: {
130
+ status: {
131
+ valid: {
47
132
  color: "$text-success"
48
133
  },
49
- false: {
134
+ invalid: {
50
135
  color: "$text-danger"
51
- }
136
+ },
137
+ dirty: {},
138
+ pristine: {},
139
+ touched: {},
140
+ pending: {}
52
141
  }
53
142
  }
54
143
  });
55
144
 
56
- const Message = React__default["default"].forwardRef((props, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx(StyledMessage, { ...props, ref: forwardRef }));
145
+ const Message = React__default["default"].forwardRef((props, forwardRef) => {
146
+ const { messageId, status } = useFormFieldContext();
147
+ return /* @__PURE__ */ jsxRuntime.jsx(
148
+ StyledMessage,
149
+ {
150
+ id: messageId,
151
+ "aria-live": "polite",
152
+ ...props,
153
+ status,
154
+ ref: forwardRef
155
+ }
156
+ );
157
+ });
57
158
 
58
159
  const StyledDescription = designSystemStitches.styled(designSystemPrimitive.Primitive.p, {
59
- all: "unset",
60
- display: "block",
61
160
  fontSize: "$175",
62
161
  lineHeight: 1.5,
162
+ margin: 0,
63
163
  marginBottom: "$150"
64
164
  });
65
165
 
66
- const Description = React__default["default"].forwardRef((props, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx(StyledDescription, { ...props, ref: forwardRef }));
166
+ const Description = React__default["default"].forwardRef((props, forwardRef) => {
167
+ const { descriptionId } = useFormFieldContext();
168
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledDescription, { id: descriptionId, ...props, ref: forwardRef });
169
+ });
67
170
 
68
- const Form = React__default["default"].forwardRef(
69
- (props, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx(StyledForm, { ...props, ref: forwardRef })
70
- );
171
+ const Form = StyledForm;
71
172
  Form.Label = Label;
72
173
  Form.Field = Field;
73
174
  Form.Helper = Helper;
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sources":["../src/form.styled.tsx","../src/partials/label.styled.tsx","../src/partials/label.tsx","../src/partials/field.styled.tsx","../src/partials/field.tsx","../src/partials/helper.styled.tsx","../src/partials/helper.tsx","../src/partials/message.styled.tsx","../src/partials/message.tsx","../src/partials/description.styled.tsx","../src/partials/description.tsx","../src/form.tsx"],"sourcesContent":["import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledForm = styled(Primitive.form, {\n all: 'unset',\n})\n\nexport type StyledFormProps = ComponentPropsWithRef<typeof StyledForm>\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledLabel = styled(Primitive.label, {\n display: 'block',\n fontSize: '$200',\n lineHeight: 1.5,\n marginBottom: '$100',\n})\n\nexport type StyledLabelProps = ComponentPropsWithRef<typeof StyledLabel>\n","import React from 'react'\nimport type { ElementRef } from 'react'\n\nimport { StyledLabel } from './label.styled'\nimport type { StyledLabelProps } from './label.styled'\n\nexport interface LabelProps extends StyledLabelProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Label = React.forwardRef<\n ElementRef<typeof StyledLabel>,\n LabelProps\n>((props, forwardRef) => <StyledLabel {...props} ref={forwardRef} />)\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledField = styled(Primitive.div, {\n all: 'unset',\n display: 'block',\n})\n\nexport type StyledFieldProps = ComponentPropsWithRef<typeof StyledField>\n","import React from 'react'\nimport type { ElementRef } from 'react'\n\nimport type { StyledFieldProps } from './field.styled'\nimport { StyledField } from './field.styled'\n\nexport interface FieldProps extends StyledFieldProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Field = React.forwardRef<\n ElementRef<typeof StyledField>,\n FieldProps\n>((props, forwardRef) => <StyledField {...props} ref={forwardRef} />)\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledHelper = styled(Primitive.div, {\n display: 'block',\n fontSize: '$150',\n lineHeight: 1.5,\n marginTop: '$50',\n})\n\nexport type StyledHelperProps = ComponentPropsWithRef<typeof StyledHelper>\n","import React from 'react'\nimport type { ElementRef } from 'react'\n\nimport type { StyledHelperProps } from './helper.styled'\nimport { StyledHelper } from './helper.styled'\n\nexport interface HelperProps extends StyledHelperProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Helper = React.forwardRef<\n ElementRef<typeof StyledHelper>,\n HelperProps\n>((props, forwardRef) => <StyledHelper {...props} ref={forwardRef} />)\n","import type { ComponentPropsWithRef } from 'react'\nimport { styled } from '@mirohq/design-system-stitches'\n\nimport { Helper } from './helper'\n\nexport const StyledMessage = styled(Helper, {\n variants: {\n valid: {\n true: {\n color: '$text-success',\n },\n false: {\n color: '$text-danger',\n },\n },\n },\n})\n\nexport type StyledMessageProps = ComponentPropsWithRef<typeof StyledMessage>\n","import React from 'react'\nimport type { ElementRef } from 'react'\n\nimport type { StyledMessageProps } from './message.styled'\nimport { StyledMessage } from './message.styled'\n\nexport interface MessageProps extends StyledMessageProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Message = React.forwardRef<\n ElementRef<typeof StyledMessage>,\n MessageProps\n>((props, forwardRef) => <StyledMessage {...props} ref={forwardRef} />)\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledDescription = styled(Primitive.p, {\n all: 'unset',\n display: 'block',\n fontSize: '$175',\n lineHeight: 1.5,\n marginBottom: '$150',\n})\n\nexport type StyledDescriptionProps = ComponentPropsWithRef<\n typeof StyledDescription\n>\n","import React from 'react'\nimport type { ElementRef } from 'react'\n\nimport type { StyledDescriptionProps } from './description.styled'\nimport { StyledDescription } from './description.styled'\n\nexport interface DescriptionProps extends StyledDescriptionProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Description = React.forwardRef<\n ElementRef<typeof StyledDescription>,\n DescriptionProps\n>((props, forwardRef) => <StyledDescription {...props} ref={forwardRef} />)\n","import React from 'react'\nimport type { ElementRef, ForwardRefExoticComponent } from 'react'\n\nimport { StyledForm } from './form.styled'\nimport type { StyledFormProps } from './form.styled'\nimport { Label } from './partials/label'\nimport { Field } from './partials/field'\nimport { Helper } from './partials/helper'\nimport { Message } from './partials/message'\nimport { Description } from './partials/description'\n\nexport interface FormProps extends StyledFormProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Form = React.forwardRef<ElementRef<typeof StyledForm>, FormProps>(\n (props, forwardRef) => <StyledForm {...props} ref={forwardRef} />\n) as ForwardRefExoticComponent<FormProps> & Partials\n\n// Partials\n// -----------------------------------------------------------------------------\n\nexport interface Partials {\n Label: typeof Label\n Field: typeof Field\n Helper: typeof Helper\n Message: typeof Message\n Description: typeof Description\n}\n\nForm.Label = Label\nForm.Field = Field\nForm.Helper = Helper\nForm.Message = Message\nForm.Description = Description\n"],"names":["styled","Primitive","React","jsx"],"mappings":";;;;;;;;;;;;;AAIa,MAAA,UAAA,GAAaA,2BAAO,CAAAC,+BAAA,CAAU,IAAM,EAAA;AAAA,EAC/C,GAAK,EAAA,OAAA;AACP,CAAC,CAAA;;ACFY,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O,EAAA;AAAA,QACL,KAAO,EAAA,cAAA;AAAA,OACT;AAAA,KACF;AAAA,GACF;AACF,CAAC,CAAA;;ACHM,MAAM,OAAU,GAAAE,yBAAA,CAAM,UAG3B,CAAA,CAAC,KAAO,EAAA,UAAA,qBAAgBC,cAAA,CAAA,aAAA,EAAA,EAAe,GAAG,KAAA,EAAO,GAAK,EAAA,UAAA,EAAY,CAAE,CAAA;;ACZzD,MAAA,iBAAA,GAAoBH,2BAAO,CAAAC,+BAAA,CAAU,CAAG,EAAA;AAAA,EACnD,GAAK,EAAA,OAAA;AAAA,EACL,OAAS,EAAA,OAAA;AAAA,EACT,QAAU,EAAA,MAAA;AAAA,EACV,UAAY,EAAA,GAAA;AAAA,EACZ,YAAc,EAAA,MAAA;AAChB,CAAC,CAAA;;ACGM,MAAM,WAAc,GAAAC,yBAAA,CAAM,UAG/B,CAAA,CAAC,KAAO,EAAA,UAAA,qBAAgBC,cAAA,CAAA,iBAAA,EAAA,EAAmB,GAAG,KAAA,EAAO,GAAK,EAAA,UAAA,EAAY,CAAE,CAAA;;ACEnE,MAAM,OAAOD,yBAAM,CAAA,UAAA;AAAA,EACxB,CAAC,OAAO,UAAe,qBAAAC,cAAA,CAAC,cAAY,GAAG,KAAA,EAAO,KAAK,UAAY,EAAA,CAAA;AACjE,EAAA;AAaA,IAAA,CAAK,KAAQ,GAAA,KAAA,CAAA;AACb,IAAA,CAAK,KAAQ,GAAA,KAAA,CAAA;AACb,IAAA,CAAK,MAAS,GAAA,MAAA,CAAA;AACd,IAAA,CAAK,OAAU,GAAA,OAAA,CAAA;AACf,IAAA,CAAK,WAAc,GAAA,WAAA;;;;"}
1
+ {"version":3,"file":"main.js","sources":["../src/form.styled.tsx","../src/partials/label.styled.tsx","../src/partials/label.tsx","../src/hooks/use-form-field-context.tsx","../src/partials/field.styled.tsx","../src/partials/field.tsx","../src/partials/helper.styled.tsx","../src/partials/helper.tsx","../src/partials/message.styled.tsx","../src/partials/message.tsx","../src/partials/description.styled.tsx","../src/partials/description.tsx","../src/form.tsx"],"sourcesContent":["import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledForm = styled(Primitive.form, {\n all: 'unset',\n})\n\nexport type StyledFormProps = ComponentPropsWithRef<typeof StyledForm>\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledLabel = styled(Primitive.label, {\n display: 'block',\n fontSize: '$200',\n lineHeight: 1.5,\n marginBottom: '$100',\n})\n\nexport type StyledLabelProps = ComponentPropsWithRef<typeof StyledLabel>\n","import { StyledLabel } from './label.styled'\nimport type { StyledLabelProps } from './label.styled'\n\nexport interface LabelProps extends StyledLabelProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Label = StyledLabel\n","import React, { createContext, useContext, useState, useRef } from 'react'\nimport type { PropsWithChildren } from 'react'\nimport type { Booleanish } from '@mirohq/design-system-types'\nimport { useId } from '@mirohq/design-system-use-id'\n\nexport type Status =\n | 'valid'\n | 'invalid'\n | 'dirty'\n | 'pristine'\n | 'touched'\n | 'pending'\n\ninterface FormFieldProps {\n required?: boolean\n readOnly?: boolean\n disabled?: boolean\n ariaDisabled?: Booleanish\n status?: Status\n id: string\n}\n\ninterface FormFieldContextProps extends FormFieldProps {\n setStatus: React.Dispatch<React.SetStateAction<Status>>\n focused: boolean\n setFocused: React.Dispatch<React.SetStateAction<boolean>>\n helperId: string\n messageId: string\n descriptionId: string\n formElementRef: React.RefObject<HTMLInputElement>\n}\n\nexport type FormFieldProviderProps = Partial<FormFieldProps>\n\nconst FormFieldContext = createContext<FormFieldContextProps>({} as any)\n\nexport const FormFieldProvider = ({\n children,\n status: customStatus,\n id: customId,\n ...restProps\n}: PropsWithChildren<FormFieldProviderProps>): JSX.Element => {\n const formElementRef = useRef<HTMLInputElement>(null)\n const [status, setStatus] = useState<Status>(customStatus ?? 'pristine')\n const [focused, setFocused] = useState(false)\n\n const autoId = useId()\n const id = customId ?? autoId\n\n return (\n <FormFieldContext.Provider\n value={{\n ...restProps,\n id,\n formElementRef,\n messageId: `${id}-message`,\n helperId: `${id}-helper`,\n descriptionId: `${id}-description`,\n status,\n setStatus,\n focused,\n setFocused,\n }}\n >\n {children}\n </FormFieldContext.Provider>\n )\n}\n\nexport const useFormFieldContext = (): FormFieldContextProps =>\n useContext(FormFieldContext)\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledField = styled(Primitive.div, {})\n\nexport type StyledFieldProps = ComponentPropsWithRef<typeof StyledField>\n","import React from 'react'\nimport type { ElementRef } from 'react'\nimport { booleanishAttrValue } from '@mirohq/design-system-utils'\n\nimport {\n useFormFieldContext,\n FormFieldProvider,\n} from '../hooks/use-form-field-context'\nimport type { FormFieldProviderProps } from '../hooks/use-form-field-context'\nimport type { StyledFieldProps } from './field.styled'\nimport { StyledField } from './field.styled'\n\nexport interface FieldProps extends StyledFieldProps, FormFieldProviderProps {}\n\nconst Root = React.forwardRef<ElementRef<typeof StyledField>, FieldProps>(\n (props, forwardRef) => {\n const {\n id,\n status,\n required,\n focused,\n setFocused,\n disabled,\n ariaDisabled,\n readOnly,\n } = useFormFieldContext()\n\n return (\n <StyledField\n id={id}\n aria-disabled={ariaDisabled}\n aria-required={required}\n aria-invalid={status === 'invalid'}\n data-status={status}\n data-required={booleanishAttrValue(required)}\n data-focused={booleanishAttrValue(focused)}\n data-disabled={booleanishAttrValue(disabled)}\n data-readonly={booleanishAttrValue(readOnly)}\n onFocus={() => setFocused?.(true)}\n {...props}\n ref={forwardRef}\n />\n )\n }\n)\n\nexport const Field = React.forwardRef<\n ElementRef<typeof StyledField>,\n FieldProps\n>(\n (\n {\n id,\n required,\n status,\n readOnly,\n disabled,\n 'aria-disabled': ariaDisabled,\n ...restProps\n },\n forwardRef\n ) => (\n <FormFieldProvider\n required={required}\n status={status}\n readOnly={readOnly}\n disabled={disabled}\n aria-disabled={ariaDisabled}\n >\n <Root {...restProps} ref={forwardRef} />\n </FormFieldProvider>\n )\n)\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledHelper = styled(Primitive.p, {\n fontSize: '$150',\n lineHeight: 1.5,\n marginTop: '$50',\n})\n\nexport type StyledHelperProps = ComponentPropsWithRef<typeof StyledHelper>\n","import React from 'react'\nimport type { ElementRef } from 'react'\n\nimport { useFormFieldContext } from '../hooks/use-form-field-context'\nimport type { StyledHelperProps } from './helper.styled'\nimport { StyledHelper } from './helper.styled'\n\nexport interface HelperProps extends StyledHelperProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Helper = React.forwardRef<\n ElementRef<typeof StyledHelper>,\n HelperProps\n>((props, forwardRef) => {\n const { helperId } = useFormFieldContext()\n return <StyledHelper id={helperId} {...props} ref={forwardRef} />\n})\n","import type { ComponentPropsWithRef } from 'react'\nimport { styled } from '@mirohq/design-system-stitches'\n\nimport { Helper } from './helper'\n\nexport const StyledMessage = styled(Helper, {\n variants: {\n status: {\n valid: {\n color: '$text-success',\n },\n invalid: {\n color: '$text-danger',\n },\n dirty: {},\n pristine: {},\n touched: {},\n pending: {},\n },\n },\n})\n\nexport type StyledMessageProps = ComponentPropsWithRef<typeof StyledMessage>\n","import React from 'react'\nimport type { ElementRef } from 'react'\n\nimport { useFormFieldContext } from '../hooks/use-form-field-context'\nimport type { Status } from '../hooks/use-form-field-context'\nimport type { StyledMessageProps } from './message.styled'\nimport { StyledMessage } from './message.styled'\n\nexport interface MessageProps extends Omit<StyledMessageProps, 'status'> {\n status?: Status\n}\n\nexport const Message = React.forwardRef<\n ElementRef<typeof StyledMessage>,\n MessageProps\n>((props, forwardRef) => {\n const { messageId, status } = useFormFieldContext()\n return (\n <StyledMessage\n id={messageId}\n aria-live='polite'\n {...props}\n status={status}\n ref={forwardRef}\n />\n )\n})\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledDescription = styled(Primitive.p, {\n fontSize: '$175',\n lineHeight: 1.5,\n margin: 0,\n marginBottom: '$150',\n})\n\nexport type StyledDescriptionProps = ComponentPropsWithRef<\n typeof StyledDescription\n>\n","import React from 'react'\nimport type { ElementRef } from 'react'\n\nimport { useFormFieldContext } from '../hooks/use-form-field-context'\nimport type { StyledDescriptionProps } from './description.styled'\nimport { StyledDescription } from './description.styled'\n\nexport interface DescriptionProps extends StyledDescriptionProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Description = React.forwardRef<\n ElementRef<typeof StyledDescription>,\n DescriptionProps\n>((props, forwardRef) => {\n const { descriptionId } = useFormFieldContext()\n return <StyledDescription id={descriptionId} {...props} ref={forwardRef} />\n})\n","import type { ForwardRefExoticComponent } from 'react'\n\nimport { StyledForm } from './form.styled'\nimport type { StyledFormProps } from './form.styled'\nimport { Label } from './partials/label'\nimport { Field } from './partials/field'\nimport { Helper } from './partials/helper'\nimport { Message } from './partials/message'\nimport { Description } from './partials/description'\n\nexport interface FormProps extends StyledFormProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Form = StyledForm as any as ForwardRefExoticComponent<FormProps> &\n Partials\n\n// Partials\n// -----------------------------------------------------------------------------\n\nexport interface Partials {\n Label: typeof Label\n Field: typeof Field\n Helper: typeof Helper\n Message: typeof Message\n Description: typeof Description\n}\n\nForm.Label = Label\nForm.Field = Field\nForm.Helper = Helper\nForm.Message = Message\nForm.Description = Description\n"],"names":["styled","Primitive","createContext","useRef","useState","useId","jsx","useContext","React","booleanishAttrValue"],"mappings":";;;;;;;;;;;;;;;AAIa,MAAA,UAAA,GAAaA,2BAAO,CAAAC,+BAAA,CAAU,IAAM,EAAA;AAAA,EAC/C,GAAK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EAAE,SAAA,EAAW,MAAO,EAAA,GAAI,mBAAoB,EAAA,CAAA;AAClD,EACE,uBAAAF,cAAA;AAAA,IAAC,aAAA;AAAA,IAAA;AAAA,MACC,EAAI,EAAA,SAAA;AAAA,MACJ,WAAU,EAAA,QAAA;AAAA,MACT,GAAG,KAAA;AAAA,MACJ,MAAA;AAAA,MACA,GAAK,EAAA,UAAA;AAAA,KAAA;AAAA,GACP,CAAA;AAEJ,CAAC,CAAA;;ACtBY,MAAA,iBAAA,GAAoBN,2BAAO,CAAAC,+BAAA,CAAU,CAAG,EAAA;AAAA,EACnD,QAAU,EAAA,MAAA;AAAA,EACV,UAAY,EAAA,GAAA;AAAA,EACZ,MAAQ,EAAA,CAAA;AAAA,EACR,YAAc,EAAA,MAAA;AAChB,CAAC,CAAA;;ACKM,MAAM,WAAc,GAAAO,yBAAA,CAAM,UAG/B,CAAA,CAAC,OAAO,UAAe,KAAA;AACvB,EAAM,MAAA,EAAE,aAAc,EAAA,GAAI,mBAAoB,EAAA,CAAA;AAC9C,EAAA,sCAAQ,iBAAkB,EAAA,EAAA,EAAA,EAAI,eAAgB,GAAG,KAAA,EAAO,KAAK,UAAY,EAAA,CAAA,CAAA;AAC3E,CAAC,CAAA;;ACHM,MAAM,IAAO,GAAA,WAAA;AAcpB,IAAA,CAAK,KAAQ,GAAA,KAAA,CAAA;AACb,IAAA,CAAK,KAAQ,GAAA,KAAA,CAAA;AACb,IAAA,CAAK,MAAS,GAAA,MAAA,CAAA;AACd,IAAA,CAAK,OAAU,GAAA,OAAA,CAAA;AACf,IAAA,CAAK,WAAc,GAAA,WAAA;;;;"}
package/dist/module.js CHANGED
@@ -1,7 +1,9 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import React from 'react';
3
1
  import { Primitive } from '@mirohq/design-system-primitive';
4
2
  import { styled } from '@mirohq/design-system-stitches';
3
+ import { jsx } from 'react/jsx-runtime';
4
+ import React, { createContext, useRef, useState, useContext } from 'react';
5
+ import { booleanishAttrValue } from '@mirohq/design-system-utils';
6
+ import { useId } from '@mirohq/design-system-use-id';
5
7
 
6
8
  const StyledForm = styled(Primitive.form, {
7
9
  all: "unset"
@@ -14,52 +16,151 @@ const StyledLabel = styled(Primitive.label, {
14
16
  marginBottom: "$100"
15
17
  });
16
18
 
17
- const Label = React.forwardRef((props, forwardRef) => /* @__PURE__ */ jsx(StyledLabel, { ...props, ref: forwardRef }));
19
+ const Label = StyledLabel;
18
20
 
19
- const StyledField = styled(Primitive.div, {
20
- all: "unset",
21
- display: "block"
22
- });
21
+ const FormFieldContext = createContext({});
22
+ const FormFieldProvider = ({
23
+ children,
24
+ status: customStatus,
25
+ id: customId,
26
+ ...restProps
27
+ }) => {
28
+ const formElementRef = useRef(null);
29
+ const [status, setStatus] = useState(customStatus != null ? customStatus : "pristine");
30
+ const [focused, setFocused] = useState(false);
31
+ const autoId = useId();
32
+ const id = customId != null ? customId : autoId;
33
+ return /* @__PURE__ */ jsx(
34
+ FormFieldContext.Provider,
35
+ {
36
+ value: {
37
+ ...restProps,
38
+ id,
39
+ formElementRef,
40
+ messageId: "".concat(id, "-message"),
41
+ helperId: "".concat(id, "-helper"),
42
+ descriptionId: "".concat(id, "-description"),
43
+ status,
44
+ setStatus,
45
+ focused,
46
+ setFocused
47
+ },
48
+ children
49
+ }
50
+ );
51
+ };
52
+ const useFormFieldContext = () => useContext(FormFieldContext);
23
53
 
24
- const Field = React.forwardRef((props, forwardRef) => /* @__PURE__ */ jsx(StyledField, { ...props, ref: forwardRef }));
54
+ const StyledField = styled(Primitive.div, {});
25
55
 
26
- const StyledHelper = styled(Primitive.div, {
27
- display: "block",
56
+ const Root = React.forwardRef(
57
+ (props, forwardRef) => {
58
+ const {
59
+ id,
60
+ status,
61
+ required,
62
+ focused,
63
+ setFocused,
64
+ disabled,
65
+ ariaDisabled,
66
+ readOnly
67
+ } = useFormFieldContext();
68
+ return /* @__PURE__ */ jsx(
69
+ StyledField,
70
+ {
71
+ id,
72
+ "aria-disabled": ariaDisabled,
73
+ "aria-required": required,
74
+ "aria-invalid": status === "invalid",
75
+ "data-status": status,
76
+ "data-required": booleanishAttrValue(required),
77
+ "data-focused": booleanishAttrValue(focused),
78
+ "data-disabled": booleanishAttrValue(disabled),
79
+ "data-readonly": booleanishAttrValue(readOnly),
80
+ onFocus: () => setFocused == null ? void 0 : setFocused(true),
81
+ ...props,
82
+ ref: forwardRef
83
+ }
84
+ );
85
+ }
86
+ );
87
+ const Field = React.forwardRef(
88
+ ({
89
+ id,
90
+ required,
91
+ status,
92
+ readOnly,
93
+ disabled,
94
+ "aria-disabled": ariaDisabled,
95
+ ...restProps
96
+ }, forwardRef) => /* @__PURE__ */ jsx(
97
+ FormFieldProvider,
98
+ {
99
+ required,
100
+ status,
101
+ readOnly,
102
+ disabled,
103
+ "aria-disabled": ariaDisabled,
104
+ children: /* @__PURE__ */ jsx(Root, { ...restProps, ref: forwardRef })
105
+ }
106
+ )
107
+ );
108
+
109
+ const StyledHelper = styled(Primitive.p, {
28
110
  fontSize: "$150",
29
111
  lineHeight: 1.5,
30
112
  marginTop: "$50"
31
113
  });
32
114
 
33
- const Helper = React.forwardRef((props, forwardRef) => /* @__PURE__ */ jsx(StyledHelper, { ...props, ref: forwardRef }));
115
+ const Helper = React.forwardRef((props, forwardRef) => {
116
+ const { helperId } = useFormFieldContext();
117
+ return /* @__PURE__ */ jsx(StyledHelper, { id: helperId, ...props, ref: forwardRef });
118
+ });
34
119
 
35
120
  const StyledMessage = styled(Helper, {
36
121
  variants: {
37
- valid: {
38
- true: {
122
+ status: {
123
+ valid: {
39
124
  color: "$text-success"
40
125
  },
41
- false: {
126
+ invalid: {
42
127
  color: "$text-danger"
43
- }
128
+ },
129
+ dirty: {},
130
+ pristine: {},
131
+ touched: {},
132
+ pending: {}
44
133
  }
45
134
  }
46
135
  });
47
136
 
48
- const Message = React.forwardRef((props, forwardRef) => /* @__PURE__ */ jsx(StyledMessage, { ...props, ref: forwardRef }));
137
+ const Message = React.forwardRef((props, forwardRef) => {
138
+ const { messageId, status } = useFormFieldContext();
139
+ return /* @__PURE__ */ jsx(
140
+ StyledMessage,
141
+ {
142
+ id: messageId,
143
+ "aria-live": "polite",
144
+ ...props,
145
+ status,
146
+ ref: forwardRef
147
+ }
148
+ );
149
+ });
49
150
 
50
151
  const StyledDescription = styled(Primitive.p, {
51
- all: "unset",
52
- display: "block",
53
152
  fontSize: "$175",
54
153
  lineHeight: 1.5,
154
+ margin: 0,
55
155
  marginBottom: "$150"
56
156
  });
57
157
 
58
- const Description = React.forwardRef((props, forwardRef) => /* @__PURE__ */ jsx(StyledDescription, { ...props, ref: forwardRef }));
158
+ const Description = React.forwardRef((props, forwardRef) => {
159
+ const { descriptionId } = useFormFieldContext();
160
+ return /* @__PURE__ */ jsx(StyledDescription, { id: descriptionId, ...props, ref: forwardRef });
161
+ });
59
162
 
60
- const Form = React.forwardRef(
61
- (props, forwardRef) => /* @__PURE__ */ jsx(StyledForm, { ...props, ref: forwardRef })
62
- );
163
+ const Form = StyledForm;
63
164
  Form.Label = Label;
64
165
  Form.Field = Field;
65
166
  Form.Helper = Helper;
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","sources":["../src/form.styled.tsx","../src/partials/label.styled.tsx","../src/partials/label.tsx","../src/partials/field.styled.tsx","../src/partials/field.tsx","../src/partials/helper.styled.tsx","../src/partials/helper.tsx","../src/partials/message.styled.tsx","../src/partials/message.tsx","../src/partials/description.styled.tsx","../src/partials/description.tsx","../src/form.tsx"],"sourcesContent":["import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledForm = styled(Primitive.form, {\n all: 'unset',\n})\n\nexport type StyledFormProps = ComponentPropsWithRef<typeof StyledForm>\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledLabel = styled(Primitive.label, {\n display: 'block',\n fontSize: '$200',\n lineHeight: 1.5,\n marginBottom: '$100',\n})\n\nexport type StyledLabelProps = ComponentPropsWithRef<typeof StyledLabel>\n","import React from 'react'\nimport type { ElementRef } from 'react'\n\nimport { StyledLabel } from './label.styled'\nimport type { StyledLabelProps } from './label.styled'\n\nexport interface LabelProps extends StyledLabelProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Label = React.forwardRef<\n ElementRef<typeof StyledLabel>,\n LabelProps\n>((props, forwardRef) => <StyledLabel {...props} ref={forwardRef} />)\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledField = styled(Primitive.div, {\n all: 'unset',\n display: 'block',\n})\n\nexport type StyledFieldProps = ComponentPropsWithRef<typeof StyledField>\n","import React from 'react'\nimport type { ElementRef } from 'react'\n\nimport type { StyledFieldProps } from './field.styled'\nimport { StyledField } from './field.styled'\n\nexport interface FieldProps extends StyledFieldProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Field = React.forwardRef<\n ElementRef<typeof StyledField>,\n FieldProps\n>((props, forwardRef) => <StyledField {...props} ref={forwardRef} />)\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledHelper = styled(Primitive.div, {\n display: 'block',\n fontSize: '$150',\n lineHeight: 1.5,\n marginTop: '$50',\n})\n\nexport type StyledHelperProps = ComponentPropsWithRef<typeof StyledHelper>\n","import React from 'react'\nimport type { ElementRef } from 'react'\n\nimport type { StyledHelperProps } from './helper.styled'\nimport { StyledHelper } from './helper.styled'\n\nexport interface HelperProps extends StyledHelperProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Helper = React.forwardRef<\n ElementRef<typeof StyledHelper>,\n HelperProps\n>((props, forwardRef) => <StyledHelper {...props} ref={forwardRef} />)\n","import type { ComponentPropsWithRef } from 'react'\nimport { styled } from '@mirohq/design-system-stitches'\n\nimport { Helper } from './helper'\n\nexport const StyledMessage = styled(Helper, {\n variants: {\n valid: {\n true: {\n color: '$text-success',\n },\n false: {\n color: '$text-danger',\n },\n },\n },\n})\n\nexport type StyledMessageProps = ComponentPropsWithRef<typeof StyledMessage>\n","import React from 'react'\nimport type { ElementRef } from 'react'\n\nimport type { StyledMessageProps } from './message.styled'\nimport { StyledMessage } from './message.styled'\n\nexport interface MessageProps extends StyledMessageProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Message = React.forwardRef<\n ElementRef<typeof StyledMessage>,\n MessageProps\n>((props, forwardRef) => <StyledMessage {...props} ref={forwardRef} />)\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledDescription = styled(Primitive.p, {\n all: 'unset',\n display: 'block',\n fontSize: '$175',\n lineHeight: 1.5,\n marginBottom: '$150',\n})\n\nexport type StyledDescriptionProps = ComponentPropsWithRef<\n typeof StyledDescription\n>\n","import React from 'react'\nimport type { ElementRef } from 'react'\n\nimport type { StyledDescriptionProps } from './description.styled'\nimport { StyledDescription } from './description.styled'\n\nexport interface DescriptionProps extends StyledDescriptionProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Description = React.forwardRef<\n ElementRef<typeof StyledDescription>,\n DescriptionProps\n>((props, forwardRef) => <StyledDescription {...props} ref={forwardRef} />)\n","import React from 'react'\nimport type { ElementRef, ForwardRefExoticComponent } from 'react'\n\nimport { StyledForm } from './form.styled'\nimport type { StyledFormProps } from './form.styled'\nimport { Label } from './partials/label'\nimport { Field } from './partials/field'\nimport { Helper } from './partials/helper'\nimport { Message } from './partials/message'\nimport { Description } from './partials/description'\n\nexport interface FormProps extends StyledFormProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Form = React.forwardRef<ElementRef<typeof StyledForm>, FormProps>(\n (props, forwardRef) => <StyledForm {...props} ref={forwardRef} />\n) as ForwardRefExoticComponent<FormProps> & Partials\n\n// Partials\n// -----------------------------------------------------------------------------\n\nexport interface Partials {\n Label: typeof Label\n Field: typeof Field\n Helper: typeof Helper\n Message: typeof Message\n Description: typeof Description\n}\n\nForm.Label = Label\nForm.Field = Field\nForm.Helper = Helper\nForm.Message = Message\nForm.Description = Description\n"],"names":[],"mappings":";;;;;AAIa,MAAA,UAAA,GAAa,MAAO,CAAA,SAAA,CAAU,IAAM,EAAA;AAAA,EAC/C,GAAK,EAAA,OAAA;AACP,CAAC,CAAA;;ACFY,MAAA,WAAA,GAAc,MAAO,CAAA,SAAA,CAAU,KAAO,EAAA;AAAA,EACjD,OAAS,EAAA,OAAA;AAAA,EACT,QAAU,EAAA,MAAA;AAAA,EACV,UAAY,EAAA,GAAA;AAAA,EACZ,YAAc,EAAA,MAAA;AAChB,CAAC,CAAA;;ACIM,MAAM,KAAQ,GAAA,KAAA,CAAM,UAGzB,CAAA,CAAC,KAAO,EAAA,UAAA,qBAAgB,GAAA,CAAA,WAAA,EAAA,EAAa,GAAG,KAAA,EAAO,GAAK,EAAA,UAAA,EAAY,CAAE,CAAA;;ACZvD,MAAA,WAAA,GAAc,MAAO,CAAA,SAAA,CAAU,GAAK,EAAA;AAAA,EAC/C,GAAK,EAAA,OAAA;AAAA,EACL,OAAS,EAAA,OAAA;AACX,CAAC,CAAA;;ACMM,MAAM,KAAQ,GAAA,KAAA,CAAM,UAGzB,CAAA,CAAC,KAAO,EAAA,UAAA,qBAAgB,GAAA,CAAA,WAAA,EAAA,EAAa,GAAG,KAAA,EAAO,GAAK,EAAA,UAAA,EAAY,CAAE,CAAA;;ACZvD,MAAA,YAAA,GAAe,MAAO,CAAA,SAAA,CAAU,GAAK,EAAA;AAAA,EAChD,OAAS,EAAA,OAAA;AAAA,EACT,QAAU,EAAA,MAAA;AAAA,EACV,UAAY,EAAA,GAAA;AAAA,EACZ,SAAW,EAAA,KAAA;AACb,CAAC,CAAA;;ACI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,CAAK,MAAS,GAAA,MAAA,CAAA;AACd,IAAA,CAAK,OAAU,GAAA,OAAA,CAAA;AACf,IAAA,CAAK,WAAc,GAAA,WAAA;;;;"}
1
+ {"version":3,"file":"module.js","sources":["../src/form.styled.tsx","../src/partials/label.styled.tsx","../src/partials/label.tsx","../src/hooks/use-form-field-context.tsx","../src/partials/field.styled.tsx","../src/partials/field.tsx","../src/partials/helper.styled.tsx","../src/partials/helper.tsx","../src/partials/message.styled.tsx","../src/partials/message.tsx","../src/partials/description.styled.tsx","../src/partials/description.tsx","../src/form.tsx"],"sourcesContent":["import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledForm = styled(Primitive.form, {\n all: 'unset',\n})\n\nexport type StyledFormProps = ComponentPropsWithRef<typeof StyledForm>\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledLabel = styled(Primitive.label, {\n display: 'block',\n fontSize: '$200',\n lineHeight: 1.5,\n marginBottom: '$100',\n})\n\nexport type StyledLabelProps = ComponentPropsWithRef<typeof StyledLabel>\n","import { StyledLabel } from './label.styled'\nimport type { StyledLabelProps } from './label.styled'\n\nexport interface LabelProps extends StyledLabelProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Label = StyledLabel\n","import React, { createContext, useContext, useState, useRef } from 'react'\nimport type { PropsWithChildren } from 'react'\nimport type { Booleanish } from '@mirohq/design-system-types'\nimport { useId } from '@mirohq/design-system-use-id'\n\nexport type Status =\n | 'valid'\n | 'invalid'\n | 'dirty'\n | 'pristine'\n | 'touched'\n | 'pending'\n\ninterface FormFieldProps {\n required?: boolean\n readOnly?: boolean\n disabled?: boolean\n ariaDisabled?: Booleanish\n status?: Status\n id: string\n}\n\ninterface FormFieldContextProps extends FormFieldProps {\n setStatus: React.Dispatch<React.SetStateAction<Status>>\n focused: boolean\n setFocused: React.Dispatch<React.SetStateAction<boolean>>\n helperId: string\n messageId: string\n descriptionId: string\n formElementRef: React.RefObject<HTMLInputElement>\n}\n\nexport type FormFieldProviderProps = Partial<FormFieldProps>\n\nconst FormFieldContext = createContext<FormFieldContextProps>({} as any)\n\nexport const FormFieldProvider = ({\n children,\n status: customStatus,\n id: customId,\n ...restProps\n}: PropsWithChildren<FormFieldProviderProps>): JSX.Element => {\n const formElementRef = useRef<HTMLInputElement>(null)\n const [status, setStatus] = useState<Status>(customStatus ?? 'pristine')\n const [focused, setFocused] = useState(false)\n\n const autoId = useId()\n const id = customId ?? autoId\n\n return (\n <FormFieldContext.Provider\n value={{\n ...restProps,\n id,\n formElementRef,\n messageId: `${id}-message`,\n helperId: `${id}-helper`,\n descriptionId: `${id}-description`,\n status,\n setStatus,\n focused,\n setFocused,\n }}\n >\n {children}\n </FormFieldContext.Provider>\n )\n}\n\nexport const useFormFieldContext = (): FormFieldContextProps =>\n useContext(FormFieldContext)\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledField = styled(Primitive.div, {})\n\nexport type StyledFieldProps = ComponentPropsWithRef<typeof StyledField>\n","import React from 'react'\nimport type { ElementRef } from 'react'\nimport { booleanishAttrValue } from '@mirohq/design-system-utils'\n\nimport {\n useFormFieldContext,\n FormFieldProvider,\n} from '../hooks/use-form-field-context'\nimport type { FormFieldProviderProps } from '../hooks/use-form-field-context'\nimport type { StyledFieldProps } from './field.styled'\nimport { StyledField } from './field.styled'\n\nexport interface FieldProps extends StyledFieldProps, FormFieldProviderProps {}\n\nconst Root = React.forwardRef<ElementRef<typeof StyledField>, FieldProps>(\n (props, forwardRef) => {\n const {\n id,\n status,\n required,\n focused,\n setFocused,\n disabled,\n ariaDisabled,\n readOnly,\n } = useFormFieldContext()\n\n return (\n <StyledField\n id={id}\n aria-disabled={ariaDisabled}\n aria-required={required}\n aria-invalid={status === 'invalid'}\n data-status={status}\n data-required={booleanishAttrValue(required)}\n data-focused={booleanishAttrValue(focused)}\n data-disabled={booleanishAttrValue(disabled)}\n data-readonly={booleanishAttrValue(readOnly)}\n onFocus={() => setFocused?.(true)}\n {...props}\n ref={forwardRef}\n />\n )\n }\n)\n\nexport const Field = React.forwardRef<\n ElementRef<typeof StyledField>,\n FieldProps\n>(\n (\n {\n id,\n required,\n status,\n readOnly,\n disabled,\n 'aria-disabled': ariaDisabled,\n ...restProps\n },\n forwardRef\n ) => (\n <FormFieldProvider\n required={required}\n status={status}\n readOnly={readOnly}\n disabled={disabled}\n aria-disabled={ariaDisabled}\n >\n <Root {...restProps} ref={forwardRef} />\n </FormFieldProvider>\n )\n)\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledHelper = styled(Primitive.p, {\n fontSize: '$150',\n lineHeight: 1.5,\n marginTop: '$50',\n})\n\nexport type StyledHelperProps = ComponentPropsWithRef<typeof StyledHelper>\n","import React from 'react'\nimport type { ElementRef } from 'react'\n\nimport { useFormFieldContext } from '../hooks/use-form-field-context'\nimport type { StyledHelperProps } from './helper.styled'\nimport { StyledHelper } from './helper.styled'\n\nexport interface HelperProps extends StyledHelperProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Helper = React.forwardRef<\n ElementRef<typeof StyledHelper>,\n HelperProps\n>((props, forwardRef) => {\n const { helperId } = useFormFieldContext()\n return <StyledHelper id={helperId} {...props} ref={forwardRef} />\n})\n","import type { ComponentPropsWithRef } from 'react'\nimport { styled } from '@mirohq/design-system-stitches'\n\nimport { Helper } from './helper'\n\nexport const StyledMessage = styled(Helper, {\n variants: {\n status: {\n valid: {\n color: '$text-success',\n },\n invalid: {\n color: '$text-danger',\n },\n dirty: {},\n pristine: {},\n touched: {},\n pending: {},\n },\n },\n})\n\nexport type StyledMessageProps = ComponentPropsWithRef<typeof StyledMessage>\n","import React from 'react'\nimport type { ElementRef } from 'react'\n\nimport { useFormFieldContext } from '../hooks/use-form-field-context'\nimport type { Status } from '../hooks/use-form-field-context'\nimport type { StyledMessageProps } from './message.styled'\nimport { StyledMessage } from './message.styled'\n\nexport interface MessageProps extends Omit<StyledMessageProps, 'status'> {\n status?: Status\n}\n\nexport const Message = React.forwardRef<\n ElementRef<typeof StyledMessage>,\n MessageProps\n>((props, forwardRef) => {\n const { messageId, status } = useFormFieldContext()\n return (\n <StyledMessage\n id={messageId}\n aria-live='polite'\n {...props}\n status={status}\n ref={forwardRef}\n />\n )\n})\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledDescription = styled(Primitive.p, {\n fontSize: '$175',\n lineHeight: 1.5,\n margin: 0,\n marginBottom: '$150',\n})\n\nexport type StyledDescriptionProps = ComponentPropsWithRef<\n typeof StyledDescription\n>\n","import React from 'react'\nimport type { ElementRef } from 'react'\n\nimport { useFormFieldContext } from '../hooks/use-form-field-context'\nimport type { StyledDescriptionProps } from './description.styled'\nimport { StyledDescription } from './description.styled'\n\nexport interface DescriptionProps extends StyledDescriptionProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Description = React.forwardRef<\n ElementRef<typeof StyledDescription>,\n DescriptionProps\n>((props, forwardRef) => {\n const { descriptionId } = useFormFieldContext()\n return <StyledDescription id={descriptionId} {...props} ref={forwardRef} />\n})\n","import type { ForwardRefExoticComponent } from 'react'\n\nimport { StyledForm } from './form.styled'\nimport type { StyledFormProps } from './form.styled'\nimport { Label } from './partials/label'\nimport { Field } from './partials/field'\nimport { Helper } from './partials/helper'\nimport { Message } from './partials/message'\nimport { Description } from './partials/description'\n\nexport interface FormProps extends StyledFormProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Form = StyledForm as any as ForwardRefExoticComponent<FormProps> &\n Partials\n\n// Partials\n// -----------------------------------------------------------------------------\n\nexport interface Partials {\n Label: typeof Label\n Field: typeof Field\n Helper: typeof Helper\n Message: typeof Message\n Description: typeof Description\n}\n\nForm.Label = Label\nForm.Field = Field\nForm.Helper = Helper\nForm.Message = Message\nForm.Description = Description\n"],"names":[],"mappings":";;;;;;;AAIa,MAAA,UAAA,GAAa,MAAO,CAAA,SAAA,CAAU,IAAM,EAAA;AAAA,EAC/C,GAAK,EAAA,OAAA;AACP,CAAC,CAAA;;ACFY,MAAA,WAAA,GAAc,MAAO,CAAA,SAAA,CAAU,KAAO,EAAA;AAAA,EACjD,OAAS,EAAA,OAAA;AAAA,EACT,QAAU,EAAA,MAAA;AAAA,EACV,UAAY,EAAA,GAAA;AAAA,EACZ,YAAc,EAAA,MAAA;AAChB,CAAC,CAAA;;ACCM,MAAM,KAAQ,GAAA,WAAA;;ACwBrB,MAAM,gBAAA,GAAmB,aAAqC,CAAA,EAAS,CAAA,CAAA;AAEhE,MAAM,oBAAoB,CAAC;AAAA,EAChC,QAAA;AAAA,EACA,MAAQ,EAAA,YAAA;AAAA,EACR,EAAI,EAAA,QAAA;AAAA,EACJ,GAAG,SAAA;AACL,CAA8D,KAAA;AAC5D,EAAM,MAAA,cAAA,GAAiB,OAAyB,IAAI,CAAA,CAAA;AACpD,EAAA,MAAM,CAAC,MAAQ,EAAA,SAAS,CAAI,GAAA,QAAA,CAAiB,sCAAgB,UAAU,CAAA,CAAA;AACvE,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,SAAS,KAAK,CAAA,CAAA;AAE5C,EAAA,MAAM,SAAS,KAAM,EAAA,CAAA;AACrB,EAAA,MAAM,KAAK,QAAY,IAAA,IAAA,GAAA,QAAA,GAAA,MAAA,CAAA;AAEvB,EACE,uBAAA,GAAA;AAAA,IAAC,gBAAiB,CAAA,QAAA;AAAA,IAAjB;AAAA,MACC,KAAO,EAAA;AAAA,QACL,GAAG,SAAA;AAAA,QACH,EAAA;AAAA,QACA,cAAA;AAAA,QACA,S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1,9 +1,11 @@
1
1
  import * as react from 'react';
2
- import react__default, { ComponentPropsWithRef } from 'react';
2
+ import react__default, { ComponentPropsWithRef, ForwardRefExoticComponent } from 'react';
3
3
  import * as _mirohq_design_system_stitches from '@mirohq/design-system-stitches';
4
4
  import * as _stitches_react_types_styled_component from '@stitches/react/types/styled-component';
5
5
  import * as _stitches_react_types_css_util from '@stitches/react/types/css-util';
6
6
  import * as _mirohq_design_system_primitive from '@mirohq/design-system-primitive';
7
+ import * as _mirohq_design_system_components_primitive from '@mirohq/design-system-components/primitive';
8
+ import { Booleanish } from '@mirohq/design-system-types';
7
9
 
8
10
  declare const StyledForm: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_design_system_stitches.StyledComponentProps<_stitches_react_types_styled_component.StyledComponent<react.ForwardRefExoticComponent<_mirohq_design_system_primitive.PrimitiveProps<"form">>, {}, {}, _stitches_react_types_css_util.CSS<{}, {
9
11
  'border-widths': {
@@ -496,7 +498,7 @@ declare const StyledForm: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_desi
496
498
  }>>>, never> & _stitches_react_types_styled_component.TransformProps<{}, {}> & _mirohq_design_system_stitches.CustomStylesProps, "ref"> & react.RefAttributes<HTMLFormElement>> & _mirohq_design_system_stitches.StitchesInternals<react.ForwardRefExoticComponent<_mirohq_design_system_primitive.PrimitiveProps<"form">>, {}, {}>;
497
499
  declare type StyledFormProps = ComponentPropsWithRef<typeof StyledForm>;
498
500
 
499
- declare const StyledLabel: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_design_system_stitches.StyledComponentProps<_stitches_react_types_styled_component.StyledComponent<react.ForwardRefExoticComponent<_mirohq_design_system_primitive.PrimitiveProps<"label">>, {}, {}, _stitches_react_types_css_util.CSS<{}, {
501
+ declare const Label: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_design_system_stitches.StyledComponentProps<_stitches_react_types_styled_component.StyledComponent<react.ForwardRefExoticComponent<_mirohq_design_system_components_primitive.PrimitiveProps<"label">>, {}, {}, _stitches_react_types_css_util.CSS<{}, {
500
502
  'border-widths': {
501
503
  readonly none: 0;
502
504
  readonly sm: "1px";
@@ -984,16 +986,18 @@ declare const StyledLabel: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_des
984
986
  _hover: (css: _stitches_react_types_css_util.CSSProperties) => {
985
987
  '&:hover, &[data-hovered]': _stitches_react_types_css_util.CSSProperties;
986
988
  };
987
- }>>>, never> & _stitches_react_types_styled_component.TransformProps<{}, {}> & _mirohq_design_system_stitches.CustomStylesProps, "ref"> & react.RefAttributes<HTMLLabelElement>> & _mirohq_design_system_stitches.StitchesInternals<react.ForwardRefExoticComponent<_mirohq_design_system_primitive.PrimitiveProps<"label">>, {}, {}>;
988
- declare type StyledLabelProps = ComponentPropsWithRef<typeof StyledLabel>;
989
+ }>>>, never> & _stitches_react_types_styled_component.TransformProps<{}, {}> & _mirohq_design_system_stitches.CustomStylesProps, "ref"> & react.RefAttributes<HTMLLabelElement>> & _mirohq_design_system_stitches.StitchesInternals<react.ForwardRefExoticComponent<_mirohq_design_system_components_primitive.PrimitiveProps<"label">>, {}, {}>;
989
990
 
990
- interface LabelProps extends StyledLabelProps {
991
- /**
992
- * The content
993
- */
994
- children: react__default.ReactNode;
991
+ declare type Status = 'valid' | 'invalid' | 'dirty' | 'pristine' | 'touched' | 'pending';
992
+ interface FormFieldProps {
993
+ required?: boolean;
994
+ readOnly?: boolean;
995
+ disabled?: boolean;
996
+ ariaDisabled?: Booleanish;
997
+ status?: Status;
998
+ id: string;
995
999
  }
996
- declare const Label: react__default.ForwardRefExoticComponent<Omit<LabelProps, "ref"> & react__default.RefAttributes<HTMLLabelElement>>;
1000
+ declare type FormFieldProviderProps = Partial<FormFieldProps>;
997
1001
 
998
1002
  declare const StyledField: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_design_system_stitches.StyledComponentProps<_stitches_react_types_styled_component.StyledComponent<react.ForwardRefExoticComponent<_mirohq_design_system_primitive.PrimitiveProps<"div">>, {}, {}, _stitches_react_types_css_util.CSS<{}, {
999
1003
  'border-widths': {
@@ -1486,15 +1490,11 @@ declare const StyledField: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_des
1486
1490
  }>>>, never> & _stitches_react_types_styled_component.TransformProps<{}, {}> & _mirohq_design_system_stitches.CustomStylesProps, "ref"> & react.RefAttributes<HTMLDivElement>> & _mirohq_design_system_stitches.StitchesInternals<react.ForwardRefExoticComponent<_mirohq_design_system_primitive.PrimitiveProps<"div">>, {}, {}>;
1487
1491
  declare type StyledFieldProps = ComponentPropsWithRef<typeof StyledField>;
1488
1492
 
1489
- interface FieldProps extends StyledFieldProps {
1490
- /**
1491
- * The content
1492
- */
1493
- children: react__default.ReactNode;
1493
+ interface FieldProps extends StyledFieldProps, FormFieldProviderProps {
1494
1494
  }
1495
1495
  declare const Field: react__default.ForwardRefExoticComponent<Omit<FieldProps, "ref"> & react__default.RefAttributes<HTMLDivElement>>;
1496
1496
 
1497
- declare const StyledHelper: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_design_system_stitches.StyledComponentProps<_stitches_react_types_styled_component.StyledComponent<react.ForwardRefExoticComponent<_mirohq_design_system_primitive.PrimitiveProps<"div">>, {}, {}, _stitches_react_types_css_util.CSS<{}, {
1497
+ declare const StyledHelper: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_design_system_stitches.StyledComponentProps<_stitches_react_types_styled_component.StyledComponent<react.ForwardRefExoticComponent<_mirohq_design_system_primitive.PrimitiveProps<"p">>, {}, {}, _stitches_react_types_css_util.CSS<{}, {
1498
1498
  'border-widths': {
1499
1499
  readonly none: 0;
1500
1500
  readonly sm: "1px";
@@ -1982,7 +1982,7 @@ declare const StyledHelper: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_de
1982
1982
  _hover: (css: _stitches_react_types_css_util.CSSProperties) => {
1983
1983
  '&:hover, &[data-hovered]': _stitches_react_types_css_util.CSSProperties;
1984
1984
  };
1985
- }>>>, never> & _stitches_react_types_styled_component.TransformProps<{}, {}> & _mirohq_design_system_stitches.CustomStylesProps, "ref"> & react.RefAttributes<HTMLDivElement>> & _mirohq_design_system_stitches.StitchesInternals<react.ForwardRefExoticComponent<_mirohq_design_system_primitive.PrimitiveProps<"div">>, {}, {}>;
1985
+ }>>>, never> & _stitches_react_types_styled_component.TransformProps<{}, {}> & _mirohq_design_system_stitches.CustomStylesProps, "ref"> & react.RefAttributes<HTMLParagraphElement>> & _mirohq_design_system_stitches.StitchesInternals<react.ForwardRefExoticComponent<_mirohq_design_system_primitive.PrimitiveProps<"p">>, {}, {}>;
1986
1986
  declare type StyledHelperProps = ComponentPropsWithRef<typeof StyledHelper>;
1987
1987
 
1988
1988
  interface HelperProps extends StyledHelperProps {
@@ -1991,9 +1991,9 @@ interface HelperProps extends StyledHelperProps {
1991
1991
  */
1992
1992
  children: react__default.ReactNode;
1993
1993
  }
1994
- declare const Helper: react__default.ForwardRefExoticComponent<Omit<HelperProps, "ref"> & react__default.RefAttributes<HTMLDivElement>>;
1994
+ declare const Helper: react__default.ForwardRefExoticComponent<Omit<HelperProps, "ref"> & react__default.RefAttributes<HTMLParagraphElement>>;
1995
1995
 
1996
- declare const StyledMessage: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_design_system_stitches.StyledComponentProps<_stitches_react_types_styled_component.StyledComponent<react.ForwardRefExoticComponent<Omit<HelperProps, "ref"> & react.RefAttributes<HTMLDivElement>>, {}, {}, _stitches_react_types_css_util.CSS<{}, {
1996
+ declare const StyledMessage: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_design_system_stitches.StyledComponentProps<_stitches_react_types_styled_component.StyledComponent<react.ForwardRefExoticComponent<Omit<HelperProps, "ref"> & react.RefAttributes<HTMLParagraphElement>>, {}, {}, _stitches_react_types_css_util.CSS<{}, {
1997
1997
  'border-widths': {
1998
1998
  readonly none: 0;
1999
1999
  readonly sm: "1px";
@@ -2481,20 +2481,17 @@ declare const StyledMessage: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_d
2481
2481
  _hover: (css: _stitches_react_types_css_util.CSSProperties) => {
2482
2482
  '&:hover, &[data-hovered]': _stitches_react_types_css_util.CSSProperties;
2483
2483
  };
2484
- }>>>, "valid"> & _stitches_react_types_styled_component.TransformProps<{
2485
- valid?: boolean | "true" | "false" | undefined;
2486
- }, {}> & _mirohq_design_system_stitches.CustomStylesProps, "ref"> & react.RefAttributes<HTMLDivElement>> & _mirohq_design_system_stitches.StitchesInternals<react.ForwardRefExoticComponent<Omit<HelperProps, "ref"> & react.RefAttributes<HTMLDivElement>>, {
2487
- valid?: boolean | "true" | "false" | undefined;
2484
+ }>>>, "status"> & _stitches_react_types_styled_component.TransformProps<{
2485
+ status?: "valid" | "invalid" | "dirty" | "pristine" | "touched" | "pending" | undefined;
2486
+ }, {}> & _mirohq_design_system_stitches.CustomStylesProps, "ref"> & react.RefAttributes<HTMLParagraphElement>> & _mirohq_design_system_stitches.StitchesInternals<react.ForwardRefExoticComponent<Omit<HelperProps, "ref"> & react.RefAttributes<HTMLParagraphElement>>, {
2487
+ status?: "valid" | "invalid" | "dirty" | "pristine" | "touched" | "pending" | undefined;
2488
2488
  }, {}>;
2489
2489
  declare type StyledMessageProps = ComponentPropsWithRef<typeof StyledMessage>;
2490
2490
 
2491
- interface MessageProps extends StyledMessageProps {
2492
- /**
2493
- * The content
2494
- */
2495
- children: react__default.ReactNode;
2491
+ interface MessageProps extends Omit<StyledMessageProps, 'status'> {
2492
+ status?: Status;
2496
2493
  }
2497
- declare const Message: react__default.ForwardRefExoticComponent<Omit<MessageProps, "ref"> & react__default.RefAttributes<HTMLDivElement>>;
2494
+ declare const Message: react__default.ForwardRefExoticComponent<Omit<MessageProps, "ref"> & react__default.RefAttributes<HTMLParagraphElement>>;
2498
2495
 
2499
2496
  declare const StyledDescription: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_design_system_stitches.StyledComponentProps<_stitches_react_types_styled_component.StyledComponent<react.ForwardRefExoticComponent<_mirohq_design_system_primitive.PrimitiveProps<"p">>, {}, {}, _stitches_react_types_css_util.CSS<{}, {
2500
2497
  'border-widths': {
@@ -2999,9 +2996,9 @@ interface FormProps extends StyledFormProps {
2999
2996
  /**
3000
2997
  * The content
3001
2998
  */
3002
- children: react__default.ReactNode;
2999
+ children: React.ReactNode;
3003
3000
  }
3004
- declare const Form: react__default.ForwardRefExoticComponent<FormProps> & Partials;
3001
+ declare const Form: ForwardRefExoticComponent<FormProps> & Partials;
3005
3002
  interface Partials {
3006
3003
  Label: typeof Label;
3007
3004
  Field: typeof Field;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mirohq/design-system-form",
3
- "version": "0.1.0-forms.0",
3
+ "version": "0.1.0-forms.1",
4
4
  "description": "",
5
5
  "author": "Miro",
6
6
  "source": "src/index.ts",
@@ -27,7 +27,9 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@mirohq/design-system-primitive": "^1.1.2-forms.0",
30
- "@mirohq/design-system-stitches": "^2.6.0"
30
+ "@mirohq/design-system-stitches": "^2.6.0",
31
+ "@mirohq/design-system-utils": "^0.15.0-forms.0",
32
+ "@mirohq/design-system-use-id": "^0.1.1-forms.0"
31
33
  },
32
34
  "scripts": {
33
35
  "build": "rollup -c ../../../rollup.config.js",