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

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,13 @@
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 designSystemBaseInput = require('@mirohq/design-system-base-input');
11
+ var designSystemUseId = require('@mirohq/design-system-use-id');
9
12
 
10
13
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
14
 
@@ -17,57 +20,209 @@ const StyledForm = designSystemStitches.styled(designSystemPrimitive.Primitive.f
17
20
 
18
21
  const StyledLabel = designSystemStitches.styled(designSystemPrimitive.Primitive.label, {
19
22
  display: "block",
20
- fontSize: "$200",
21
- lineHeight: 1.5,
22
- marginBottom: "$100"
23
+ variants: {
24
+ floating: {
25
+ true: {
26
+ position: "absolute",
27
+ zIndex: 1,
28
+ top: 0,
29
+ left: "$150",
30
+ pointerEvents: "none"
31
+ },
32
+ false: {
33
+ fontSize: "$200",
34
+ lineHeight: 1.5,
35
+ marginBottom: "$100"
36
+ }
37
+ }
38
+ }
39
+ });
40
+ const StyledAsterisk = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
41
+ color: "$text-danger"
23
42
  });
24
43
 
25
- const Label = React__default["default"].forwardRef((props, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx(StyledLabel, { ...props, ref: forwardRef }));
44
+ const labelSymbol = Symbol.for("label");
45
+ const isLabelComponent = (labelComponent) => {
46
+ var _a, _b;
47
+ return Boolean(
48
+ (_b = labelComponent[labelSymbol]) != null ? _b : (
49
+ // @ts-expect-error
50
+ (_a = labelComponent == null ? void 0 : labelComponent.type) == null ? void 0 : _a[labelSymbol]
51
+ )
52
+ );
53
+ };
54
+
55
+ const Label = React__default["default"].forwardRef(
56
+ ({ floating = false, required = false, children, ...restProps }, forwardRef) => /* @__PURE__ */ jsxRuntime.jsxs(StyledLabel, { ...restProps, ref: forwardRef, floating, children: [
57
+ children,
58
+ required && /* @__PURE__ */ jsxRuntime.jsx(StyledAsterisk, { children: "*" })
59
+ ] })
60
+ );
61
+ Label[labelSymbol] = true;
62
+
63
+ const FormFieldContext = React.createContext({});
64
+ const FormFieldProvider = ({
65
+ children,
66
+ status: customStatus,
67
+ id: customId,
68
+ ...restProps
69
+ }) => {
70
+ const formElementRef = React.useRef(null);
71
+ const [status, setStatus] = React.useState(customStatus != null ? customStatus : "pristine");
72
+ const [focused, setFocused] = React.useState(false);
73
+ const autoId = designSystemUseId.useId();
74
+ const id = customId != null ? customId : autoId;
75
+ return /* @__PURE__ */ jsxRuntime.jsx(
76
+ FormFieldContext.Provider,
77
+ {
78
+ value: {
79
+ ...restProps,
80
+ id,
81
+ formElementRef,
82
+ messageId: "".concat(id, "-message"),
83
+ helperId: "".concat(id, "-helper"),
84
+ descriptionId: "".concat(id, "-description"),
85
+ status,
86
+ setStatus,
87
+ focused,
88
+ setFocused
89
+ },
90
+ children
91
+ }
92
+ );
93
+ };
94
+ const useFormFieldContext = () => React.useContext(FormFieldContext);
26
95
 
27
96
  const StyledField = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
28
- all: "unset",
29
- display: "block"
97
+ marginBottom: "$300"
30
98
  });
31
99
 
32
- const Field = React__default["default"].forwardRef((props, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx(StyledField, { ...props, ref: forwardRef }));
100
+ const Root = React__default["default"].forwardRef(
101
+ ({ children, ...restProps }, forwardRef) => {
102
+ const {
103
+ id,
104
+ status,
105
+ required,
106
+ focused,
107
+ setFocused,
108
+ disabled,
109
+ ariaDisabled,
110
+ readOnly
111
+ } = useFormFieldContext();
112
+ const label = React__default["default"].Children.toArray(children).find(
113
+ isLabelComponent
114
+ );
115
+ const floating = designSystemUtils.booleanify(label == null ? void 0 : label.props.floating);
116
+ const formattedChildren = floating ? React__default["default"].Children.map(React__default["default"].Children.toArray(children), (child) => {
117
+ if (isLabelComponent(child)) {
118
+ return null;
119
+ }
120
+ if (designSystemBaseInput.isInputComponent(child)) {
121
+ const input = child;
122
+ return React__default["default"].cloneElement(input, {
123
+ ...input.props,
124
+ label
125
+ });
126
+ }
127
+ return child;
128
+ }) : children;
129
+ return /* @__PURE__ */ jsxRuntime.jsx(
130
+ StyledField,
131
+ {
132
+ id,
133
+ "aria-disabled": ariaDisabled,
134
+ "aria-required": required,
135
+ "aria-invalid": status === "invalid",
136
+ "data-status": status,
137
+ "data-required": designSystemUtils.booleanishAttrValue(required),
138
+ "data-focused": designSystemUtils.booleanishAttrValue(focused),
139
+ "data-disabled": designSystemUtils.booleanishAttrValue(disabled),
140
+ "data-readonly": designSystemUtils.booleanishAttrValue(readOnly),
141
+ onFocus: () => setFocused == null ? void 0 : setFocused(true),
142
+ ...restProps,
143
+ ref: forwardRef,
144
+ children: formattedChildren
145
+ }
146
+ );
147
+ }
148
+ );
149
+ const Field = React__default["default"].forwardRef(
150
+ ({
151
+ id,
152
+ required,
153
+ status,
154
+ readOnly,
155
+ disabled,
156
+ "aria-disabled": ariaDisabled,
157
+ ...restProps
158
+ }, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx(
159
+ FormFieldProvider,
160
+ {
161
+ required,
162
+ status,
163
+ readOnly,
164
+ disabled,
165
+ "aria-disabled": ariaDisabled,
166
+ children: /* @__PURE__ */ jsxRuntime.jsx(Root, { ...restProps, ref: forwardRef })
167
+ }
168
+ )
169
+ );
33
170
 
34
- const StyledHelper = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
35
- display: "block",
171
+ const StyledHelper = designSystemStitches.styled(designSystemPrimitive.Primitive.p, {
36
172
  fontSize: "$150",
37
173
  lineHeight: 1.5,
38
174
  marginTop: "$50"
39
175
  });
40
176
 
41
- const Helper = React__default["default"].forwardRef((props, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx(StyledHelper, { ...props, ref: forwardRef }));
177
+ const Helper = React__default["default"].forwardRef((props, forwardRef) => {
178
+ const { helperId } = useFormFieldContext();
179
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledHelper, { id: helperId, ...props, ref: forwardRef });
180
+ });
42
181
 
43
182
  const StyledMessage = designSystemStitches.styled(Helper, {
44
183
  variants: {
45
- valid: {
46
- true: {
184
+ status: {
185
+ valid: {
47
186
  color: "$text-success"
48
187
  },
49
- false: {
188
+ invalid: {
50
189
  color: "$text-danger"
51
- }
190
+ },
191
+ dirty: {},
192
+ pristine: {},
193
+ touched: {},
194
+ pending: {}
52
195
  }
53
196
  }
54
197
  });
55
198
 
56
- const Message = React__default["default"].forwardRef((props, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx(StyledMessage, { ...props, ref: forwardRef }));
199
+ const Message = React__default["default"].forwardRef((props, forwardRef) => {
200
+ const { messageId, status } = useFormFieldContext();
201
+ return /* @__PURE__ */ jsxRuntime.jsx(
202
+ StyledMessage,
203
+ {
204
+ id: messageId,
205
+ "aria-live": "polite",
206
+ ...props,
207
+ status,
208
+ ref: forwardRef
209
+ }
210
+ );
211
+ });
57
212
 
58
213
  const StyledDescription = designSystemStitches.styled(designSystemPrimitive.Primitive.p, {
59
- all: "unset",
60
- display: "block",
61
214
  fontSize: "$175",
62
215
  lineHeight: 1.5,
216
+ margin: 0,
63
217
  marginBottom: "$150"
64
218
  });
65
219
 
66
- const Description = React__default["default"].forwardRef((props, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx(StyledDescription, { ...props, ref: forwardRef }));
220
+ const Description = React__default["default"].forwardRef((props, forwardRef) => {
221
+ const { descriptionId } = useFormFieldContext();
222
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledDescription, { id: descriptionId, ...props, ref: forwardRef });
223
+ });
67
224
 
68
- const Form = React__default["default"].forwardRef(
69
- (props, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx(StyledForm, { ...props, ref: forwardRef })
70
- );
225
+ const Form = StyledForm;
71
226
  Form.Label = Label;
72
227
  Form.Field = Field;
73
228
  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,MAAA,WAAA,GAAcD,2BAAO,CAAAC,+BAAA,CAAU,KAAO,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,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/util.ts","../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\n variants: {\n floating: {\n true: {\n position: 'absolute',\n zIndex: 1,\n top: 0,\n left: '$150',\n pointerEvents: 'none',\n },\n false: {\n fontSize: '$200',\n lineHeight: 1.5,\n marginBottom: '$100',\n },\n },\n },\n})\n\nexport const StyledAsterisk = styled(Primitive.span, {\n color: '$text-danger',\n})\n\nexport type StyledLabelProps = ComponentPropsWithRef<typeof StyledLabel>\n","export const labelSymbol: unique symbol = Symbol.for('label')\nexport type LabelReactElement = React.ReactElement & { [labelSymbol]?: boolean }\n\nexport const isLabelComponent = <T>(\n labelComponent: T & { [labelSymbol]?: boolean }\n): boolean =>\n Boolean(\n labelComponent[labelSymbol] ??\n // @ts-expect-error\n labelComponent?.type?.[labelSymbol]\n )\n","import React from 'react'\nimport type { ElementRef, ForwardRefExoticComponent } from 'react'\n\nimport { StyledAsterisk, StyledLabel } from './label.styled'\nimport type { StyledLabelProps } from './label.styled'\nimport { labelSymbol } from '../util'\n\nexport interface LabelProps extends Omit<StyledLabelProps, 'placeholder'> {\n /**\n * The content\n */\n children: React.ReactNode\n\n floating?: boolean\n\n required?: boolean\n}\n\nexport const Label = React.forwardRef<\n ElementRef<typeof StyledLabel>,\n LabelProps\n>(\n (\n { floating = false, required = false, children, ...restProps },\n forwardRef\n ) => (\n <StyledLabel {...restProps} ref={forwardRef} floating={floating}>\n {children}\n {required && <StyledAsterisk>*</StyledAsterisk>}\n </StyledLabel>\n )\n) as ForwardRefExoticComponent<LabelProps> & {\n [labelSymbol]?: boolean\n}\n\nLabel[labelSymbol] = true\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 marginBottom: '$300',\n})\n\nexport type StyledFieldProps = ComponentPropsWithRef<typeof StyledField>\n","import React from 'react'\nimport type { ElementRef } from 'react'\nimport { booleanify, booleanishAttrValue } from '@mirohq/design-system-utils'\nimport type { InputReactElement } from '@mirohq/design-system-base-input'\nimport { isInputComponent } from '@mirohq/design-system-base-input'\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'\nimport type { LabelReactElement } from '../util'\nimport { isLabelComponent } from '../util'\n\nexport interface FieldProps extends StyledFieldProps, FormFieldProviderProps {}\n\nconst Root = React.forwardRef<ElementRef<typeof StyledField>, FieldProps>(\n ({ children, ...restProps }, forwardRef) => {\n const {\n id,\n status,\n required,\n focused,\n setFocused,\n disabled,\n ariaDisabled,\n readOnly,\n } = useFormFieldContext()\n\n const label = React.Children.toArray(children).find(\n isLabelComponent\n ) as LabelReactElement\n\n const floating = booleanify(label?.props.floating)\n\n const formattedChildren = floating\n ? React.Children.map(React.Children.toArray(children), child => {\n if (isLabelComponent(child)) {\n return null\n }\n\n // includes input, select and textarea\n if (isInputComponent(child)) {\n const input = child as InputReactElement\n return React.cloneElement(input, {\n ...input.props,\n label: label,\n })\n }\n\n return child\n })\n : children\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 {...restProps}\n ref={forwardRef}\n >\n {formattedChildren}\n </StyledField>\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","React","jsxs","jsx","createContext","useRef","useState","useId","useContext","booleanify","isInputComponent","booleanishAttrValue"],"mappings":";;;;;;;;;;;;;;;;AAIa,MAAA,UAAA,GAAaA,2BAAO,CAAAC,+BAAA,CAAU,IAAM,EAAA;AAAA,EAC/C,GAAK,EAAA,OAAA;AACP,CAAC,CAAA;;ACFY,MAAA,WAAA,GAAcD,2BAAO,CAAAC,+BAAA,CAAU,KAAO,EAAA;AAA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EACV,UAAY,EAAA,GAAA;AAAA,EACZ,MAAQ,EAAA,CAAA;AAAA,EACR,YAAc,EAAA,MAAA;AAChB,CAAC,CAAA;;ACKM,MAAM,WAAc,GAAAC,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,10 @@
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 { jsxs, jsx } from 'react/jsx-runtime';
4
+ import React, { createContext, useRef, useState, useContext } from 'react';
5
+ import { booleanify, booleanishAttrValue } from '@mirohq/design-system-utils';
6
+ import { isInputComponent } from '@mirohq/design-system-base-input';
7
+ import { useId } from '@mirohq/design-system-use-id';
5
8
 
6
9
  const StyledForm = styled(Primitive.form, {
7
10
  all: "unset"
@@ -9,57 +12,209 @@ const StyledForm = styled(Primitive.form, {
9
12
 
10
13
  const StyledLabel = styled(Primitive.label, {
11
14
  display: "block",
12
- fontSize: "$200",
13
- lineHeight: 1.5,
14
- marginBottom: "$100"
15
+ variants: {
16
+ floating: {
17
+ true: {
18
+ position: "absolute",
19
+ zIndex: 1,
20
+ top: 0,
21
+ left: "$150",
22
+ pointerEvents: "none"
23
+ },
24
+ false: {
25
+ fontSize: "$200",
26
+ lineHeight: 1.5,
27
+ marginBottom: "$100"
28
+ }
29
+ }
30
+ }
15
31
  });
32
+ const StyledAsterisk = styled(Primitive.span, {
33
+ color: "$text-danger"
34
+ });
35
+
36
+ const labelSymbol = Symbol.for("label");
37
+ const isLabelComponent = (labelComponent) => {
38
+ var _a, _b;
39
+ return Boolean(
40
+ (_b = labelComponent[labelSymbol]) != null ? _b : (
41
+ // @ts-expect-error
42
+ (_a = labelComponent == null ? void 0 : labelComponent.type) == null ? void 0 : _a[labelSymbol]
43
+ )
44
+ );
45
+ };
46
+
47
+ const Label = React.forwardRef(
48
+ ({ floating = false, required = false, children, ...restProps }, forwardRef) => /* @__PURE__ */ jsxs(StyledLabel, { ...restProps, ref: forwardRef, floating, children: [
49
+ children,
50
+ required && /* @__PURE__ */ jsx(StyledAsterisk, { children: "*" })
51
+ ] })
52
+ );
53
+ Label[labelSymbol] = true;
16
54
 
17
- const Label = React.forwardRef((props, forwardRef) => /* @__PURE__ */ jsx(StyledLabel, { ...props, ref: forwardRef }));
55
+ const FormFieldContext = createContext({});
56
+ const FormFieldProvider = ({
57
+ children,
58
+ status: customStatus,
59
+ id: customId,
60
+ ...restProps
61
+ }) => {
62
+ const formElementRef = useRef(null);
63
+ const [status, setStatus] = useState(customStatus != null ? customStatus : "pristine");
64
+ const [focused, setFocused] = useState(false);
65
+ const autoId = useId();
66
+ const id = customId != null ? customId : autoId;
67
+ return /* @__PURE__ */ jsx(
68
+ FormFieldContext.Provider,
69
+ {
70
+ value: {
71
+ ...restProps,
72
+ id,
73
+ formElementRef,
74
+ messageId: "".concat(id, "-message"),
75
+ helperId: "".concat(id, "-helper"),
76
+ descriptionId: "".concat(id, "-description"),
77
+ status,
78
+ setStatus,
79
+ focused,
80
+ setFocused
81
+ },
82
+ children
83
+ }
84
+ );
85
+ };
86
+ const useFormFieldContext = () => useContext(FormFieldContext);
18
87
 
19
88
  const StyledField = styled(Primitive.div, {
20
- all: "unset",
21
- display: "block"
89
+ marginBottom: "$300"
22
90
  });
23
91
 
24
- const Field = React.forwardRef((props, forwardRef) => /* @__PURE__ */ jsx(StyledField, { ...props, ref: forwardRef }));
92
+ const Root = React.forwardRef(
93
+ ({ children, ...restProps }, forwardRef) => {
94
+ const {
95
+ id,
96
+ status,
97
+ required,
98
+ focused,
99
+ setFocused,
100
+ disabled,
101
+ ariaDisabled,
102
+ readOnly
103
+ } = useFormFieldContext();
104
+ const label = React.Children.toArray(children).find(
105
+ isLabelComponent
106
+ );
107
+ const floating = booleanify(label == null ? void 0 : label.props.floating);
108
+ const formattedChildren = floating ? React.Children.map(React.Children.toArray(children), (child) => {
109
+ if (isLabelComponent(child)) {
110
+ return null;
111
+ }
112
+ if (isInputComponent(child)) {
113
+ const input = child;
114
+ return React.cloneElement(input, {
115
+ ...input.props,
116
+ label
117
+ });
118
+ }
119
+ return child;
120
+ }) : children;
121
+ return /* @__PURE__ */ jsx(
122
+ StyledField,
123
+ {
124
+ id,
125
+ "aria-disabled": ariaDisabled,
126
+ "aria-required": required,
127
+ "aria-invalid": status === "invalid",
128
+ "data-status": status,
129
+ "data-required": booleanishAttrValue(required),
130
+ "data-focused": booleanishAttrValue(focused),
131
+ "data-disabled": booleanishAttrValue(disabled),
132
+ "data-readonly": booleanishAttrValue(readOnly),
133
+ onFocus: () => setFocused == null ? void 0 : setFocused(true),
134
+ ...restProps,
135
+ ref: forwardRef,
136
+ children: formattedChildren
137
+ }
138
+ );
139
+ }
140
+ );
141
+ const Field = React.forwardRef(
142
+ ({
143
+ id,
144
+ required,
145
+ status,
146
+ readOnly,
147
+ disabled,
148
+ "aria-disabled": ariaDisabled,
149
+ ...restProps
150
+ }, forwardRef) => /* @__PURE__ */ jsx(
151
+ FormFieldProvider,
152
+ {
153
+ required,
154
+ status,
155
+ readOnly,
156
+ disabled,
157
+ "aria-disabled": ariaDisabled,
158
+ children: /* @__PURE__ */ jsx(Root, { ...restProps, ref: forwardRef })
159
+ }
160
+ )
161
+ );
25
162
 
26
- const StyledHelper = styled(Primitive.div, {
27
- display: "block",
163
+ const StyledHelper = styled(Primitive.p, {
28
164
  fontSize: "$150",
29
165
  lineHeight: 1.5,
30
166
  marginTop: "$50"
31
167
  });
32
168
 
33
- const Helper = React.forwardRef((props, forwardRef) => /* @__PURE__ */ jsx(StyledHelper, { ...props, ref: forwardRef }));
169
+ const Helper = React.forwardRef((props, forwardRef) => {
170
+ const { helperId } = useFormFieldContext();
171
+ return /* @__PURE__ */ jsx(StyledHelper, { id: helperId, ...props, ref: forwardRef });
172
+ });
34
173
 
35
174
  const StyledMessage = styled(Helper, {
36
175
  variants: {
37
- valid: {
38
- true: {
176
+ status: {
177
+ valid: {
39
178
  color: "$text-success"
40
179
  },
41
- false: {
180
+ invalid: {
42
181
  color: "$text-danger"
43
- }
182
+ },
183
+ dirty: {},
184
+ pristine: {},
185
+ touched: {},
186
+ pending: {}
44
187
  }
45
188
  }
46
189
  });
47
190
 
48
- const Message = React.forwardRef((props, forwardRef) => /* @__PURE__ */ jsx(StyledMessage, { ...props, ref: forwardRef }));
191
+ const Message = React.forwardRef((props, forwardRef) => {
192
+ const { messageId, status } = useFormFieldContext();
193
+ return /* @__PURE__ */ jsx(
194
+ StyledMessage,
195
+ {
196
+ id: messageId,
197
+ "aria-live": "polite",
198
+ ...props,
199
+ status,
200
+ ref: forwardRef
201
+ }
202
+ );
203
+ });
49
204
 
50
205
  const StyledDescription = styled(Primitive.p, {
51
- all: "unset",
52
- display: "block",
53
206
  fontSize: "$175",
54
207
  lineHeight: 1.5,
208
+ margin: 0,
55
209
  marginBottom: "$150"
56
210
  });
57
211
 
58
- const Description = React.forwardRef((props, forwardRef) => /* @__PURE__ */ jsx(StyledDescription, { ...props, ref: forwardRef }));
212
+ const Description = React.forwardRef((props, forwardRef) => {
213
+ const { descriptionId } = useFormFieldContext();
214
+ return /* @__PURE__ */ jsx(StyledDescription, { id: descriptionId, ...props, ref: forwardRef });
215
+ });
59
216
 
60
- const Form = React.forwardRef(
61
- (props, forwardRef) => /* @__PURE__ */ jsx(StyledForm, { ...props, ref: forwardRef })
62
- );
217
+ const Form = StyledForm;
63
218
  Form.Label = Label;
64
219
  Form.Field = Field;
65
220
  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,EAA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A,EAAe,GAAG,KAAA,EAAO,GAAK,EAAA,UAAA,EAAY,CAAE,CAAA;;ACZzD,MAAA,iBAAA,GAAoB,MAAO,CAAA,SAAA,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,GAAA,KAAA,CAAM,UAG/B,CAAA,CAAC,KAAO,EAAA,UAAA,qBAAgB,GAAA,CAAA,iBAAA,EAAA,EAAmB,GAAG,KAAA,EAAO,GAAK,EAAA,UAAA,EAAY,CAAE,CAAA;;ACEnE,MAAM,OAAO,KAAM,CAAA,UAAA;AAAA,EACxB,CAAC,OAAO,UAAe,qBAAA,GAAA,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":"module.js","sources":["../src/form.styled.tsx","../src/partials/label.styled.tsx","../src/util.ts","../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\n variants: {\n floating: {\n true: {\n position: 'absolute',\n zIndex: 1,\n top: 0,\n left: '$150',\n pointerEvents: 'none',\n },\n false: {\n fontSize: '$200',\n lineHeight: 1.5,\n marginBottom: '$100',\n },\n },\n },\n})\n\nexport const StyledAsterisk = styled(Primitive.span, {\n color: '$text-danger',\n})\n\nexport type StyledLabelProps = ComponentPropsWithRef<typeof StyledLabel>\n","export const labelSymbol: unique symbol = Symbol.for('label')\nexport type LabelReactElement = React.ReactElement & { [labelSymbol]?: boolean }\n\nexport const isLabelComponent = <T>(\n labelComponent: T & { [labelSymbol]?: boolean }\n): boolean =>\n Boolean(\n labelComponent[labelSymbol] ??\n // @ts-expect-error\n labelComponent?.type?.[labelSymbol]\n )\n","import React from 'react'\nimport type { ElementRef, ForwardRefExoticComponent } from 'react'\n\nimport { StyledAsterisk, StyledLabel } from './label.styled'\nimport type { StyledLabelProps } from './label.styled'\nimport { labelSymbol } from '../util'\n\nexport interface LabelProps extends Omit<StyledLabelProps, 'placeholder'> {\n /**\n * The content\n */\n children: React.ReactNode\n\n floating?: boolean\n\n required?: boolean\n}\n\nexport const Label = React.forwardRef<\n ElementRef<typeof StyledLabel>,\n LabelProps\n>(\n (\n { floating = false, required = false, children, ...restProps },\n forwardRef\n ) => (\n <StyledLabel {...restProps} ref={forwardRef} floating={floating}>\n {children}\n {required && <StyledAsterisk>*</StyledAsterisk>}\n </StyledLabel>\n )\n) as ForwardRefExoticComponent<LabelProps> & {\n [labelSymbol]?: boolean\n}\n\nLabel[labelSymbol] = true\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 marginBottom: '$300',\n})\n\nexport type StyledFieldProps = ComponentPropsWithRef<typeof StyledField>\n","import React from 'react'\nimport type { ElementRef } from 'react'\nimport { booleanify, booleanishAttrValue } from '@mirohq/design-system-utils'\nimport type { InputReactElement } from '@mirohq/design-system-base-input'\nimport { isInputComponent } from '@mirohq/design-system-base-input'\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'\nimport type { LabelReactElement } from '../util'\nimport { isLabelComponent } from '../util'\n\nexport interface FieldProps extends StyledFieldProps, FormFieldProviderProps {}\n\nconst Root = React.forwardRef<ElementRef<typeof StyledField>, FieldProps>(\n ({ children, ...restProps }, forwardRef) => {\n const {\n id,\n status,\n required,\n focused,\n setFocused,\n disabled,\n ariaDisabled,\n readOnly,\n } = useFormFieldContext()\n\n const label = React.Children.toArray(children).find(\n isLabelComponent\n ) as LabelReactElement\n\n const floating = booleanify(label?.props.floating)\n\n const formattedChildren = floating\n ? React.Children.map(React.Children.toArray(children), child => {\n if (isLabelComponent(child)) {\n return null\n }\n\n // includes input, select and textarea\n if (isInputComponent(child)) {\n const input = child as InputReactElement\n return React.cloneElement(input, {\n ...input.props,\n label: label,\n })\n }\n\n return child\n })\n : children\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 {...restProps}\n ref={forwardRef}\n >\n {formattedChildren}\n </StyledField>\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,EAET,QAAU,EAAA;AAAA,IACR,QAAU,EAAA;AAAA,MACR,IAAM,EAAA;AAAA,QACJ,QAAU,EAAA,UAAA;AAAA,QACV,MAAQ,EAAA,CAAA;AAAA,QACR,GAAK,EAAA,CAAA;AAAA,QACL,IAAM,EAAA,MAAA;AAAA,QACN,aAAe,EAAA,MAAA;AA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,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/types.d.ts CHANGED
@@ -1,9 +1,10 @@
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 { Booleanish } from '@mirohq/design-system-types';
7
8
 
8
9
  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
10
  'border-widths': {
@@ -984,16 +985,37 @@ declare const StyledLabel: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_des
984
985
  _hover: (css: _stitches_react_types_css_util.CSSProperties) => {
985
986
  '&:hover, &[data-hovered]': _stitches_react_types_css_util.CSSProperties;
986
987
  };
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
+ }>>>, "floating"> & _stitches_react_types_styled_component.TransformProps<{
989
+ floating?: boolean | "true" | "false" | undefined;
990
+ }, {}> & _mirohq_design_system_stitches.CustomStylesProps, "ref"> & react.RefAttributes<HTMLLabelElement>> & _mirohq_design_system_stitches.StitchesInternals<react.ForwardRefExoticComponent<_mirohq_design_system_primitive.PrimitiveProps<"label">>, {
991
+ floating?: boolean | "true" | "false" | undefined;
992
+ }, {}>;
988
993
  declare type StyledLabelProps = ComponentPropsWithRef<typeof StyledLabel>;
989
994
 
990
- interface LabelProps extends StyledLabelProps {
995
+ declare const labelSymbol: unique symbol;
996
+
997
+ interface LabelProps extends Omit<StyledLabelProps, 'placeholder'> {
991
998
  /**
992
999
  * The content
993
1000
  */
994
1001
  children: react__default.ReactNode;
1002
+ floating?: boolean;
1003
+ required?: boolean;
1004
+ }
1005
+ declare const Label: react__default.ForwardRefExoticComponent<LabelProps> & {
1006
+ [labelSymbol]?: boolean | undefined;
1007
+ };
1008
+
1009
+ declare type Status = 'valid' | 'invalid' | 'dirty' | 'pristine' | 'touched' | 'pending';
1010
+ interface FormFieldProps {
1011
+ required?: boolean;
1012
+ readOnly?: boolean;
1013
+ disabled?: boolean;
1014
+ ariaDisabled?: Booleanish;
1015
+ status?: Status;
1016
+ id: string;
995
1017
  }
996
- declare const Label: react__default.ForwardRefExoticComponent<Omit<LabelProps, "ref"> & react__default.RefAttributes<HTMLLabelElement>>;
1018
+ declare type FormFieldProviderProps = Partial<FormFieldProps>;
997
1019
 
998
1020
  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
1021
  'border-widths': {
@@ -1486,15 +1508,11 @@ declare const StyledField: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_des
1486
1508
  }>>>, 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
1509
  declare type StyledFieldProps = ComponentPropsWithRef<typeof StyledField>;
1488
1510
 
1489
- interface FieldProps extends StyledFieldProps {
1490
- /**
1491
- * The content
1492
- */
1493
- children: react__default.ReactNode;
1511
+ interface FieldProps extends StyledFieldProps, FormFieldProviderProps {
1494
1512
  }
1495
1513
  declare const Field: react__default.ForwardRefExoticComponent<Omit<FieldProps, "ref"> & react__default.RefAttributes<HTMLDivElement>>;
1496
1514
 
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<{}, {
1515
+ 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
1516
  'border-widths': {
1499
1517
  readonly none: 0;
1500
1518
  readonly sm: "1px";
@@ -1982,7 +2000,7 @@ declare const StyledHelper: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_de
1982
2000
  _hover: (css: _stitches_react_types_css_util.CSSProperties) => {
1983
2001
  '&:hover, &[data-hovered]': _stitches_react_types_css_util.CSSProperties;
1984
2002
  };
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">>, {}, {}>;
2003
+ }>>>, 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
2004
  declare type StyledHelperProps = ComponentPropsWithRef<typeof StyledHelper>;
1987
2005
 
1988
2006
  interface HelperProps extends StyledHelperProps {
@@ -1991,9 +2009,9 @@ interface HelperProps extends StyledHelperProps {
1991
2009
  */
1992
2010
  children: react__default.ReactNode;
1993
2011
  }
1994
- declare const Helper: react__default.ForwardRefExoticComponent<Omit<HelperProps, "ref"> & react__default.RefAttributes<HTMLDivElement>>;
2012
+ declare const Helper: react__default.ForwardRefExoticComponent<Omit<HelperProps, "ref"> & react__default.RefAttributes<HTMLParagraphElement>>;
1995
2013
 
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<{}, {
2014
+ 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
2015
  'border-widths': {
1998
2016
  readonly none: 0;
1999
2017
  readonly sm: "1px";
@@ -2481,20 +2499,17 @@ declare const StyledMessage: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_d
2481
2499
  _hover: (css: _stitches_react_types_css_util.CSSProperties) => {
2482
2500
  '&:hover, &[data-hovered]': _stitches_react_types_css_util.CSSProperties;
2483
2501
  };
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;
2502
+ }>>>, "status"> & _stitches_react_types_styled_component.TransformProps<{
2503
+ status?: "valid" | "invalid" | "dirty" | "pristine" | "touched" | "pending" | undefined;
2504
+ }, {}> & _mirohq_design_system_stitches.CustomStylesProps, "ref"> & react.RefAttributes<HTMLParagraphElement>> & _mirohq_design_system_stitches.StitchesInternals<react.ForwardRefExoticComponent<Omit<HelperProps, "ref"> & react.RefAttributes<HTMLParagraphElement>>, {
2505
+ status?: "valid" | "invalid" | "dirty" | "pristine" | "touched" | "pending" | undefined;
2488
2506
  }, {}>;
2489
2507
  declare type StyledMessageProps = ComponentPropsWithRef<typeof StyledMessage>;
2490
2508
 
2491
- interface MessageProps extends StyledMessageProps {
2492
- /**
2493
- * The content
2494
- */
2495
- children: react__default.ReactNode;
2509
+ interface MessageProps extends Omit<StyledMessageProps, 'status'> {
2510
+ status?: Status;
2496
2511
  }
2497
- declare const Message: react__default.ForwardRefExoticComponent<Omit<MessageProps, "ref"> & react__default.RefAttributes<HTMLDivElement>>;
2512
+ declare const Message: react__default.ForwardRefExoticComponent<Omit<MessageProps, "ref"> & react__default.RefAttributes<HTMLParagraphElement>>;
2498
2513
 
2499
2514
  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
2515
  'border-widths': {
@@ -2999,9 +3014,9 @@ interface FormProps extends StyledFormProps {
2999
3014
  /**
3000
3015
  * The content
3001
3016
  */
3002
- children: react__default.ReactNode;
3017
+ children: React.ReactNode;
3003
3018
  }
3004
- declare const Form: react__default.ForwardRefExoticComponent<FormProps> & Partials;
3019
+ declare const Form: ForwardRefExoticComponent<FormProps> & Partials;
3005
3020
  interface Partials {
3006
3021
  Label: typeof Label;
3007
3022
  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.2",
4
4
  "description": "",
5
5
  "author": "Miro",
6
6
  "source": "src/index.ts",
@@ -26,8 +26,11 @@
26
26
  "react": "^16.14 || ^17 || ^18"
27
27
  },
28
28
  "dependencies": {
29
+ "@mirohq/design-system-base-input": "^0.1.0-forms.1",
29
30
  "@mirohq/design-system-primitive": "^1.1.2-forms.0",
30
- "@mirohq/design-system-stitches": "^2.6.0"
31
+ "@mirohq/design-system-stitches": "^2.6.0",
32
+ "@mirohq/design-system-use-id": "^0.1.1-forms.0",
33
+ "@mirohq/design-system-utils": "^0.15.0-forms.0"
31
34
  },
32
35
  "scripts": {
33
36
  "build": "rollup -c ../../../rollup.config.js",