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

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
@@ -6,9 +6,8 @@ var designSystemPrimitive = require('@mirohq/design-system-primitive');
6
6
  var designSystemStitches = require('@mirohq/design-system-stitches');
7
7
  var jsxRuntime = require('react/jsx-runtime');
8
8
  var React = require('react');
9
+ var designSystemBaseForm = require('@mirohq/design-system-base-form');
9
10
  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');
12
11
 
13
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
13
 
@@ -19,167 +18,113 @@ const StyledForm = designSystemStitches.styled(designSystemPrimitive.Primitive.f
19
18
  });
20
19
 
21
20
  const StyledLabel = designSystemStitches.styled(designSystemPrimitive.Primitive.label, {
22
- display: "block",
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
- }
21
+ fontSize: "$200",
22
+ marginBottom: "$100",
23
+ display: "block"
39
24
  });
40
25
  const StyledAsterisk = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
41
26
  color: "$text-danger"
42
27
  });
43
28
 
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
- }
29
+ const Label = React__default["default"].forwardRef(({ floating = true, children, ...restProps }, forwardRef) => {
30
+ const {
31
+ setLabel,
32
+ setIsFloatingLabel,
33
+ formElementId,
34
+ required = false
35
+ } = designSystemBaseForm.useFormFieldContext();
36
+ const label = React.useMemo(
37
+ () => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
38
+ children,
39
+ required && /* @__PURE__ */ jsxRuntime.jsx(StyledAsterisk, { children: "*" })
40
+ ] }),
41
+ [children, required]
92
42
  );
93
- };
94
- const useFormFieldContext = () => React.useContext(FormFieldContext);
43
+ React.useEffect(() => {
44
+ setLabel(label);
45
+ }, [setLabel, label]);
46
+ React.useEffect(() => setIsFloatingLabel(floating), [setIsFloatingLabel, floating]);
47
+ if (floating) {
48
+ return null;
49
+ }
50
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledLabel, { htmlFor: formElementId, ...restProps, ref: forwardRef, children: label });
51
+ });
95
52
 
96
53
  const StyledField = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
97
- marginBottom: "$300"
54
+ marginBottom: "$300",
55
+ position: "relative"
98
56
  });
99
57
 
100
58
  const Root = React__default["default"].forwardRef(
101
- ({ children, ...restProps }, forwardRef) => {
59
+ ({ onFocus, onBlur, status: statusProps, ...restProps }, forwardRef) => {
60
+ var _a;
102
61
  const {
103
62
  id,
104
- status,
63
+ status: formFieldStatus,
64
+ setStatus,
105
65
  required,
106
66
  focused,
107
67
  setFocused,
108
68
  disabled,
109
69
  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;
70
+ readOnly,
71
+ formElementRef
72
+ } = designSystemBaseForm.useFormFieldContext();
73
+ const status = statusProps != null ? statusProps : formFieldStatus;
74
+ const initialValueRef = React.useRef();
75
+ if (((_a = formElementRef.current) == null ? void 0 : _a.value) !== void 0 && initialValueRef.current === void 0) {
76
+ initialValueRef.current = formElementRef.current.value;
77
+ }
129
78
  return /* @__PURE__ */ jsxRuntime.jsx(
130
79
  StyledField,
131
80
  {
132
- id,
133
- "aria-disabled": ariaDisabled,
134
- "aria-required": required,
135
- "aria-invalid": status === "invalid",
136
81
  "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),
82
+ "data-required": designSystemUtils.booleanAttrValue(required),
83
+ "data-focused": designSystemUtils.booleanAttrValue(focused),
84
+ "data-disabled": designSystemUtils.booleanAttrValue(
85
+ disabled === true || ariaDisabled === true
86
+ ),
87
+ "data-readonly": designSystemUtils.booleanAttrValue(readOnly),
88
+ onFocus: (e) => {
89
+ setFocused(true);
90
+ onFocus == null ? void 0 : onFocus(e);
91
+ },
92
+ onBlur: (e) => {
93
+ if (statusProps === void 0) {
94
+ setStatus(
95
+ initialValueRef.current !== e.target.value ? designSystemBaseForm.FORM_FIELD_STATUS.dirty : designSystemBaseForm.FORM_FIELD_STATUS.touched
96
+ );
97
+ }
98
+ setFocused(false);
99
+ onBlur == null ? void 0 : onBlur(e);
100
+ },
142
101
  ...restProps,
143
- ref: forwardRef,
144
- children: formattedChildren
102
+ id,
103
+ ref: forwardRef
145
104
  }
146
105
  );
147
106
  }
148
107
  );
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
- );
108
+ const Field = React__default["default"].forwardRef(({ id, status, ...restProps }, forwardRef) => /* @__PURE__ */ jsxRuntime.jsx(designSystemBaseForm.FormFieldProvider, { status, id, children: /* @__PURE__ */ jsxRuntime.jsx(Root, { status, ...restProps, ref: forwardRef }) }));
170
109
 
171
- const StyledHelper = designSystemStitches.styled(designSystemPrimitive.Primitive.p, {
110
+ const StyledHelper = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
172
111
  fontSize: "$150",
173
112
  lineHeight: 1.5,
174
113
  marginTop: "$50"
175
114
  });
176
115
 
177
116
  const Helper = React__default["default"].forwardRef((props, forwardRef) => {
178
- const { helperId } = useFormFieldContext();
179
- return /* @__PURE__ */ jsxRuntime.jsx(StyledHelper, { id: helperId, ...props, ref: forwardRef });
117
+ var _a;
118
+ const { helperId, setHelperId } = designSystemBaseForm.useFormFieldContext();
119
+ const id = (_a = props.id) != null ? _a : helperId;
120
+ React.useEffect(() => setHelperId(id), [setHelperId, id]);
121
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledHelper, { ...props, id, ref: forwardRef });
180
122
  });
181
123
 
182
- const StyledMessage = designSystemStitches.styled(Helper, {
124
+ const StyledMessage = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
125
+ fontSize: "$150",
126
+ lineHeight: 1.5,
127
+ marginTop: "$50",
183
128
  variants: {
184
129
  status: {
185
130
  valid: {
@@ -190,20 +135,25 @@ const StyledMessage = designSystemStitches.styled(Helper, {
190
135
  },
191
136
  dirty: {},
192
137
  pristine: {},
193
- touched: {},
194
- pending: {}
138
+ touched: {}
195
139
  }
196
140
  }
197
141
  });
198
142
 
199
143
  const Message = React__default["default"].forwardRef((props, forwardRef) => {
200
- const { messageId, status } = useFormFieldContext();
144
+ var _a;
145
+ const { messageId, setMessageId, status } = designSystemBaseForm.useFormFieldContext();
146
+ const id = (_a = props.id) != null ? _a : messageId;
147
+ React.useEffect(() => setMessageId(id), [setMessageId, id]);
148
+ if (status !== designSystemBaseForm.FORM_FIELD_STATUS.invalid && status !== designSystemBaseForm.FORM_FIELD_STATUS.valid) {
149
+ return null;
150
+ }
201
151
  return /* @__PURE__ */ jsxRuntime.jsx(
202
152
  StyledMessage,
203
153
  {
204
- id: messageId,
205
- "aria-live": "polite",
154
+ role: "alert",
206
155
  ...props,
156
+ id,
207
157
  status,
208
158
  ref: forwardRef
209
159
  }
@@ -218,8 +168,11 @@ const StyledDescription = designSystemStitches.styled(designSystemPrimitive.Prim
218
168
  });
219
169
 
220
170
  const Description = React__default["default"].forwardRef((props, forwardRef) => {
221
- const { descriptionId } = useFormFieldContext();
222
- return /* @__PURE__ */ jsxRuntime.jsx(StyledDescription, { id: descriptionId, ...props, ref: forwardRef });
171
+ var _a;
172
+ const { descriptionId, setDescriptionId } = designSystemBaseForm.useFormFieldContext();
173
+ const id = (_a = props.id) != null ? _a : descriptionId;
174
+ React.useEffect(() => setDescriptionId(id), [setDescriptionId, id]);
175
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledDescription, { ...props, id, ref: forwardRef });
223
176
  });
224
177
 
225
178
  const Form = StyledForm;
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/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;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;AAAA,OACjB;AAAA,MACA,KAAO,EAAA;AAAA,QACL,QAAU,EAAA,MAAA;AAAA,QACV,UAAY,EAAA,GAAA;AAAA,QACZ,YAAc,EAAA,MAAA;AAAA,OAChB;AAAA,KACF;AAAA,GACF;AACF,CAAC,CAAA,CAAA;AAEY,MAAA,cAAA,GAAiBD,2BAAO,CAAAC,+BAAA,CAAU,IAAM,EAAA;AAAA,EACnD,KAAO,EAAA,cAAA;AACT,CAAC,CAAA;;AC3BY,MAAA,WAAA,GAA6B,MAAO,CAAA,GAAA,CAAI,OAAO,CAAA,CAAA;AAG/C,MAAA,gBAAA,GAAmB,CA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ources":["../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 fontSize: '$200',\n marginBottom: '$100',\n display: 'block',\n})\n\nexport const StyledAsterisk = styled(Primitive.span, {\n color: '$text-danger',\n})\n\nexport type StyledLabelProps = ComponentPropsWithRef<typeof StyledLabel>\n","import React, { useMemo, useEffect } from 'react'\nimport type { ElementRef } from 'react'\nimport { useFormFieldContext } from '@mirohq/design-system-base-form'\n\nimport { StyledAsterisk, 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 * Whether the label should float above the input\n */\n floating?: boolean\n}\n\nexport const Label = React.forwardRef<\n ElementRef<typeof StyledLabel>,\n LabelProps\n>(({ floating = true, children, ...restProps }, forwardRef) => {\n const {\n setLabel,\n setIsFloatingLabel,\n formElementId,\n required = false,\n } = useFormFieldContext()\n\n const label = useMemo(\n () => (\n <>\n {children}\n {required && <StyledAsterisk>*</StyledAsterisk>}\n </>\n ),\n [children, required]\n )\n\n useEffect(() => {\n setLabel(label)\n }, [setLabel, label])\n\n useEffect(() => setIsFloatingLabel(floating), [setIsFloatingLabel, floating])\n\n // floating labels are managed in the form elements\n if (floating) {\n return null\n }\n\n return (\n <StyledLabel htmlFor={formElementId} {...restProps} ref={forwardRef}>\n {label}\n </StyledLabel>\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 StyledField = styled(Primitive.div, {\n marginBottom: '$300',\n position: 'relative',\n})\n\nexport type StyledFieldProps = ComponentPropsWithRef<typeof StyledField>\n","import React, { useRef } from 'react'\nimport type { ElementRef } from 'react'\nimport { booleanAttrValue } from '@mirohq/design-system-utils'\nimport {\n useFormFieldContext,\n FormFieldProvider,\n FORM_FIELD_STATUS,\n} from '@mirohq/design-system-base-form'\nimport type { FormFieldProviderProps } from '@mirohq/design-system-base-form'\n\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 ({ onFocus, onBlur, status: statusProps, ...restProps }, forwardRef) => {\n const {\n id,\n status: formFieldStatus,\n setStatus,\n required,\n focused,\n setFocused,\n disabled,\n ariaDisabled,\n readOnly,\n formElementRef,\n } = useFormFieldContext()\n\n const status = statusProps ?? formFieldStatus\n const initialValueRef = useRef<string>()\n\n if (\n formElementRef.current?.value !== undefined &&\n initialValueRef.current === undefined\n ) {\n initialValueRef.current = formElementRef.current.value\n }\n\n return (\n <StyledField\n data-status={status}\n data-required={booleanAttrValue(required)}\n data-focused={booleanAttrValue(focused)}\n data-disabled={booleanAttrValue(\n disabled === true || ariaDisabled === true\n )}\n data-readonly={booleanAttrValue(readOnly)}\n onFocus={e => {\n setFocused(true)\n onFocus?.(e)\n }}\n onBlur={e => {\n if (statusProps === undefined) {\n setStatus(\n initialValueRef.current !== (e.target as HTMLInputElement).value\n ? FORM_FIELD_STATUS.dirty\n : FORM_FIELD_STATUS.touched\n )\n }\n\n setFocused(false)\n onBlur?.(e)\n }}\n {...restProps}\n id={id}\n ref={forwardRef}\n />\n )\n }\n)\n\nexport const Field = React.forwardRef<\n ElementRef<typeof StyledField>,\n FieldProps\n>(({ id, status, ...restProps }, forwardRef) => (\n <FormFieldProvider status={status} id={id}>\n {/* explicit use status as props because the provider will add a default */}\n <Root status={status} {...restProps} ref={forwardRef} />\n </FormFieldProvider>\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.div, {\n fontSize: '$150',\n lineHeight: 1.5,\n marginTop: '$50',\n})\n\nexport type StyledHelperProps = ComponentPropsWithRef<typeof StyledHelper>\n","import React, { useEffect } from 'react'\nimport type { ElementRef } from 'react'\nimport { useFormFieldContext } from '@mirohq/design-system-base-form'\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) => {\n const { helperId, setHelperId } = useFormFieldContext()\n\n const id = props.id ?? helperId\n useEffect(() => setHelperId(id), [setHelperId, id])\n\n return <StyledHelper {...props} id={id} ref={forwardRef} />\n})\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledMessage = styled(Primitive.div, {\n fontSize: '$150',\n lineHeight: 1.5,\n marginTop: '$50',\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 },\n },\n})\n\nexport type StyledMessageProps = ComponentPropsWithRef<typeof StyledMessage>\n","import React, { useEffect } from 'react'\nimport type { ElementRef } from 'react'\nimport {\n useFormFieldContext,\n FORM_FIELD_STATUS,\n} from '@mirohq/design-system-base-form'\nimport type { FormFieldStatus } from '@mirohq/design-system-base-form'\n\nimport type { StyledMessageProps } from './message.styled'\nimport { StyledMessage } from './message.styled'\n\nexport interface MessageProps extends Omit<StyledMessageProps, 'status'> {\n status?: FormFieldStatus\n chidren?: React.ReactNode\n}\n\nexport const Message = React.forwardRef<\n ElementRef<typeof StyledMessage>,\n MessageProps\n>((props, forwardRef) => {\n const { messageId, setMessageId, status } = useFormFieldContext()\n\n const id = props.id ?? messageId\n useEffect(() => setMessageId(id), [setMessageId, id])\n\n if (\n status !== FORM_FIELD_STATUS.invalid &&\n status !== FORM_FIELD_STATUS.valid\n ) {\n return null\n }\n\n return (\n <StyledMessage\n role='alert'\n {...props}\n id={id}\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, { useEffect } from 'react'\nimport type { ElementRef } from 'react'\nimport { useFormFieldContext } from '@mirohq/design-system-base-form'\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) => {\n const { descriptionId, setDescriptionId } = useFormFieldContext()\n\n const id = props.id ?? descriptionId\n useEffect(() => setDescriptionId(id), [setDescriptionId, id])\n\n return <StyledDescription {...props} id={id} 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","useFormFieldContext","useMemo","jsxs","Fragment","jsx","useEffect","useRef","booleanAttrValue","FORM_FIELD_STATUS","FormFieldProvider"],"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;AAAA,EACjD,QAAU,EAAA,MAAA;AAAA,EACV,YAAc,EAAA,MAAA;AAAA,EACd,OAAS,EAAA,OAAA;AACX,CAAC,CAAA,CAAA;AAEY,MAAA,cAAA,GAAiBD,2BAAO,CAAAC,+BAAA,CAAU,IAAM,EAAA;AAAA,EACnD,KAAO,EAAA,cAAA;AACT,CAAC,CAAA;;ACMY,MAAA,KAAA,GAAQC,yBAAM,CAAA,UAAA,CAGzB,CAAC,EAAE,QAAW,GAAA,IAAA,EAAM,QAAU,EAAA,GAAG,SAAU,EAAA,EAAG,UAAe,KAAA;AAC7D,EAAM,MAAA;AAAA,IACJ,QAAA;AAAA,IACA,kBAAA;AAAA,IACA,aAAA;AAAA,IACA,QAAW,GAAA,KAAA;AAAA,MACTC,wCAAoB,EAAA,CAAA;AAExB,EAAA,MAAM,KAAQ,GAAAC,aAAA;AAAA,IACZ,sBAEKC,eAAA,CAAAC,mBAAA,EAAA,EAAA,QAAA,EAAA;AAAA,MAAA,QAAA;AAAA,MACA,QAAA,oBAAaC,c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,CAAC,OAAO,UAAe,KAAA;AAjBzB,EAAA,IAAA,EAAA,CAAA;AAkBE,EAAA,MAAM,EAAE,aAAA,EAAe,gBAAiB,EAAA,GAAIC,wCAAoB,EAAA,CAAA;AAEhE,EAAM,MAAA,EAAA,GAAA,CAAK,EAAM,GAAA,KAAA,CAAA,EAAA,KAAN,IAAY,GAAA,EAAA,GAAA,aAAA,CAAA;AACvB,EAAAK,eAAA,CAAU,MAAM,gBAAiB,CAAA,EAAE,GAAG,CAAC,gBAAA,EAAkB,EAAE,CAAC,CAAA,CAAA;AAE5D,EAAA,sCAAQ,iBAAmB,EAAA,EAAA,GAAG,KAAO,EAAA,EAAA,EAAQ,KAAK,UAAY,EAAA,CAAA,CAAA;AAChE,CAAC,CAAA;;ACPM,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,177 +1,122 @@
1
1
  import { Primitive } from '@mirohq/design-system-primitive';
2
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';
3
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
4
+ import React, { useMemo, useEffect, useRef } from 'react';
5
+ import { useFormFieldContext, FORM_FIELD_STATUS, FormFieldProvider } from '@mirohq/design-system-base-form';
6
+ import { booleanAttrValue } from '@mirohq/design-system-utils';
8
7
 
9
8
  const StyledForm = styled(Primitive.form, {
10
9
  all: "unset"
11
10
  });
12
11
 
13
12
  const StyledLabel = styled(Primitive.label, {
14
- display: "block",
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
- }
13
+ fontSize: "$200",
14
+ marginBottom: "$100",
15
+ display: "block"
31
16
  });
32
17
  const StyledAsterisk = styled(Primitive.span, {
33
18
  color: "$text-danger"
34
19
  });
35
20
 
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;
54
-
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
- }
21
+ const Label = React.forwardRef(({ floating = true, children, ...restProps }, forwardRef) => {
22
+ const {
23
+ setLabel,
24
+ setIsFloatingLabel,
25
+ formElementId,
26
+ required = false
27
+ } = useFormFieldContext();
28
+ const label = useMemo(
29
+ () => /* @__PURE__ */ jsxs(Fragment, { children: [
30
+ children,
31
+ required && /* @__PURE__ */ jsx(StyledAsterisk, { children: "*" })
32
+ ] }),
33
+ [children, required]
84
34
  );
85
- };
86
- const useFormFieldContext = () => useContext(FormFieldContext);
35
+ useEffect(() => {
36
+ setLabel(label);
37
+ }, [setLabel, label]);
38
+ useEffect(() => setIsFloatingLabel(floating), [setIsFloatingLabel, floating]);
39
+ if (floating) {
40
+ return null;
41
+ }
42
+ return /* @__PURE__ */ jsx(StyledLabel, { htmlFor: formElementId, ...restProps, ref: forwardRef, children: label });
43
+ });
87
44
 
88
45
  const StyledField = styled(Primitive.div, {
89
- marginBottom: "$300"
46
+ marginBottom: "$300",
47
+ position: "relative"
90
48
  });
91
49
 
92
50
  const Root = React.forwardRef(
93
- ({ children, ...restProps }, forwardRef) => {
51
+ ({ onFocus, onBlur, status: statusProps, ...restProps }, forwardRef) => {
52
+ var _a;
94
53
  const {
95
54
  id,
96
- status,
55
+ status: formFieldStatus,
56
+ setStatus,
97
57
  required,
98
58
  focused,
99
59
  setFocused,
100
60
  disabled,
101
61
  ariaDisabled,
102
- readOnly
62
+ readOnly,
63
+ formElementRef
103
64
  } = 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;
65
+ const status = statusProps != null ? statusProps : formFieldStatus;
66
+ const initialValueRef = useRef();
67
+ if (((_a = formElementRef.current) == null ? void 0 : _a.value) !== void 0 && initialValueRef.current === void 0) {
68
+ initialValueRef.current = formElementRef.current.value;
69
+ }
121
70
  return /* @__PURE__ */ jsx(
122
71
  StyledField,
123
72
  {
124
- id,
125
- "aria-disabled": ariaDisabled,
126
- "aria-required": required,
127
- "aria-invalid": status === "invalid",
128
73
  "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),
74
+ "data-required": booleanAttrValue(required),
75
+ "data-focused": booleanAttrValue(focused),
76
+ "data-disabled": booleanAttrValue(
77
+ disabled === true || ariaDisabled === true
78
+ ),
79
+ "data-readonly": booleanAttrValue(readOnly),
80
+ onFocus: (e) => {
81
+ setFocused(true);
82
+ onFocus == null ? void 0 : onFocus(e);
83
+ },
84
+ onBlur: (e) => {
85
+ if (statusProps === void 0) {
86
+ setStatus(
87
+ initialValueRef.current !== e.target.value ? FORM_FIELD_STATUS.dirty : FORM_FIELD_STATUS.touched
88
+ );
89
+ }
90
+ setFocused(false);
91
+ onBlur == null ? void 0 : onBlur(e);
92
+ },
134
93
  ...restProps,
135
- ref: forwardRef,
136
- children: formattedChildren
94
+ id,
95
+ ref: forwardRef
137
96
  }
138
97
  );
139
98
  }
140
99
  );
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
- );
100
+ const Field = React.forwardRef(({ id, status, ...restProps }, forwardRef) => /* @__PURE__ */ jsx(FormFieldProvider, { status, id, children: /* @__PURE__ */ jsx(Root, { status, ...restProps, ref: forwardRef }) }));
162
101
 
163
- const StyledHelper = styled(Primitive.p, {
102
+ const StyledHelper = styled(Primitive.div, {
164
103
  fontSize: "$150",
165
104
  lineHeight: 1.5,
166
105
  marginTop: "$50"
167
106
  });
168
107
 
169
108
  const Helper = React.forwardRef((props, forwardRef) => {
170
- const { helperId } = useFormFieldContext();
171
- return /* @__PURE__ */ jsx(StyledHelper, { id: helperId, ...props, ref: forwardRef });
109
+ var _a;
110
+ const { helperId, setHelperId } = useFormFieldContext();
111
+ const id = (_a = props.id) != null ? _a : helperId;
112
+ useEffect(() => setHelperId(id), [setHelperId, id]);
113
+ return /* @__PURE__ */ jsx(StyledHelper, { ...props, id, ref: forwardRef });
172
114
  });
173
115
 
174
- const StyledMessage = styled(Helper, {
116
+ const StyledMessage = styled(Primitive.div, {
117
+ fontSize: "$150",
118
+ lineHeight: 1.5,
119
+ marginTop: "$50",
175
120
  variants: {
176
121
  status: {
177
122
  valid: {
@@ -182,20 +127,25 @@ const StyledMessage = styled(Helper, {
182
127
  },
183
128
  dirty: {},
184
129
  pristine: {},
185
- touched: {},
186
- pending: {}
130
+ touched: {}
187
131
  }
188
132
  }
189
133
  });
190
134
 
191
135
  const Message = React.forwardRef((props, forwardRef) => {
192
- const { messageId, status } = useFormFieldContext();
136
+ var _a;
137
+ const { messageId, setMessageId, status } = useFormFieldContext();
138
+ const id = (_a = props.id) != null ? _a : messageId;
139
+ useEffect(() => setMessageId(id), [setMessageId, id]);
140
+ if (status !== FORM_FIELD_STATUS.invalid && status !== FORM_FIELD_STATUS.valid) {
141
+ return null;
142
+ }
193
143
  return /* @__PURE__ */ jsx(
194
144
  StyledMessage,
195
145
  {
196
- id: messageId,
197
- "aria-live": "polite",
146
+ role: "alert",
198
147
  ...props,
148
+ id,
199
149
  status,
200
150
  ref: forwardRef
201
151
  }
@@ -210,8 +160,11 @@ const StyledDescription = styled(Primitive.p, {
210
160
  });
211
161
 
212
162
  const Description = React.forwardRef((props, forwardRef) => {
213
- const { descriptionId } = useFormFieldContext();
214
- return /* @__PURE__ */ jsx(StyledDescription, { id: descriptionId, ...props, ref: forwardRef });
163
+ var _a;
164
+ const { descriptionId, setDescriptionId } = useFormFieldContext();
165
+ const id = (_a = props.id) != null ? _a : descriptionId;
166
+ useEffect(() => setDescriptionId(id), [setDescriptionId, id]);
167
+ return /* @__PURE__ */ jsx(StyledDescription, { ...props, id, ref: forwardRef });
215
168
  });
216
169
 
217
170
  const Form = StyledForm;
@@ -1 +1 @@
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;AAAA,OACjB;AAAA,MACA,KAAO,EAAA;AAAA,QACL,QAAU,EAAA,MAAA;AAAA,QACV,UAAY,EAAA,GAAA;AAAA,QACZ,YAAc,EAAA,MAAA;AAAA,OAChB;AAAA,KACF;AAAA,GACF;AACF,CAAC,CAAA,CAAA;AAEY,MAAA,cAAA,GAAiB,MAAO,CAAA,SAAA,CAAU,IAAM,EAAA;AAAA,EACnD,KAAO,EAAA,cAAA;AACT,CAAC,CAAA;;AC3BY,MAAA,WAAA,GAA6B,MAAO,CAAA,GAAA,CAAI,OAAO,CAAA,CAAA;AAG/C,MAAA,gBAAA,GAAmB,CAC9B,cACS,KAAA;AALX,EAAA,IAAA,EAAA,EAAA,EAAA,CAAA;AAME,EAAA,OAAA,OAAA;AAAA,IACE,CAAA,EAAA,GAAA,cAAA,CAAe,WAAW,CAA1B,KAAA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AM,EAAE,SAAA,EAAW,MAAO,EAAA,GAAI,mBAAoB,EAAA,CAAA;AAClD,EACE,uBAAA,GAAA;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,GAAoB,MAAO,CAAA,SAAA,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,GAAA,KAAA,CAAM,UAG/B,CAAA,CAAC,OAAO,UAAe,KAAA;AACvB,EAAM,MAAA,EAAE,aAAc,EAAA,GAAI,mBAAoB,EAAA,CAAA;AAC9C,EAAA,2BAAQ,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;;;;"}
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 fontSize: '$200',\n marginBottom: '$100',\n display: 'block',\n})\n\nexport const StyledAsterisk = styled(Primitive.span, {\n color: '$text-danger',\n})\n\nexport type StyledLabelProps = ComponentPropsWithRef<typeof StyledLabel>\n","import React, { useMemo, useEffect } from 'react'\nimport type { ElementRef } from 'react'\nimport { useFormFieldContext } from '@mirohq/design-system-base-form'\n\nimport { StyledAsterisk, 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 * Whether the label should float above the input\n */\n floating?: boolean\n}\n\nexport const Label = React.forwardRef<\n ElementRef<typeof StyledLabel>,\n LabelProps\n>(({ floating = true, children, ...restProps }, forwardRef) => {\n const {\n setLabel,\n setIsFloatingLabel,\n formElementId,\n required = false,\n } = useFormFieldContext()\n\n const label = useMemo(\n () => (\n <>\n {children}\n {required && <StyledAsterisk>*</StyledAsterisk>}\n </>\n ),\n [children, required]\n )\n\n useEffect(() => {\n setLabel(label)\n }, [setLabel, label])\n\n useEffect(() => setIsFloatingLabel(floating), [setIsFloatingLabel, floating])\n\n // floating labels are managed in the form elements\n if (floating) {\n return null\n }\n\n return (\n <StyledLabel htmlFor={formElementId} {...restProps} ref={forwardRef}>\n {label}\n </StyledLabel>\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 StyledField = styled(Primitive.div, {\n marginBottom: '$300',\n position: 'relative',\n})\n\nexport type StyledFieldProps = ComponentPropsWithRef<typeof StyledField>\n","import React, { useRef } from 'react'\nimport type { ElementRef } from 'react'\nimport { booleanAttrValue } from '@mirohq/design-system-utils'\nimport {\n useFormFieldContext,\n FormFieldProvider,\n FORM_FIELD_STATUS,\n} from '@mirohq/design-system-base-form'\nimport type { FormFieldProviderProps } from '@mirohq/design-system-base-form'\n\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 ({ onFocus, onBlur, status: statusProps, ...restProps }, forwardRef) => {\n const {\n id,\n status: formFieldStatus,\n setStatus,\n required,\n focused,\n setFocused,\n disabled,\n ariaDisabled,\n readOnly,\n formElementRef,\n } = useFormFieldContext()\n\n const status = statusProps ?? formFieldStatus\n const initialValueRef = useRef<string>()\n\n if (\n formElementRef.current?.value !== undefined &&\n initialValueRef.current === undefined\n ) {\n initialValueRef.current = formElementRef.current.value\n }\n\n return (\n <StyledField\n data-status={status}\n data-required={booleanAttrValue(required)}\n data-focused={booleanAttrValue(focused)}\n data-disabled={booleanAttrValue(\n disabled === true || ariaDisabled === true\n )}\n data-readonly={booleanAttrValue(readOnly)}\n onFocus={e => {\n setFocused(true)\n onFocus?.(e)\n }}\n onBlur={e => {\n if (statusProps === undefined) {\n setStatus(\n initialValueRef.current !== (e.target as HTMLInputElement).value\n ? FORM_FIELD_STATUS.dirty\n : FORM_FIELD_STATUS.touched\n )\n }\n\n setFocused(false)\n onBlur?.(e)\n }}\n {...restProps}\n id={id}\n ref={forwardRef}\n />\n )\n }\n)\n\nexport const Field = React.forwardRef<\n ElementRef<typeof StyledField>,\n FieldProps\n>(({ id, status, ...restProps }, forwardRef) => (\n <FormFieldProvider status={status} id={id}>\n {/* explicit use status as props because the provider will add a default */}\n <Root status={status} {...restProps} ref={forwardRef} />\n </FormFieldProvider>\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.div, {\n fontSize: '$150',\n lineHeight: 1.5,\n marginTop: '$50',\n})\n\nexport type StyledHelperProps = ComponentPropsWithRef<typeof StyledHelper>\n","import React, { useEffect } from 'react'\nimport type { ElementRef } from 'react'\nimport { useFormFieldContext } from '@mirohq/design-system-base-form'\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) => {\n const { helperId, setHelperId } = useFormFieldContext()\n\n const id = props.id ?? helperId\n useEffect(() => setHelperId(id), [setHelperId, id])\n\n return <StyledHelper {...props} id={id} ref={forwardRef} />\n})\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledMessage = styled(Primitive.div, {\n fontSize: '$150',\n lineHeight: 1.5,\n marginTop: '$50',\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 },\n },\n})\n\nexport type StyledMessageProps = ComponentPropsWithRef<typeof StyledMessage>\n","import React, { useEffect } from 'react'\nimport type { ElementRef } from 'react'\nimport {\n useFormFieldContext,\n FORM_FIELD_STATUS,\n} from '@mirohq/design-system-base-form'\nimport type { FormFieldStatus } from '@mirohq/design-system-base-form'\n\nimport type { StyledMessageProps } from './message.styled'\nimport { StyledMessage } from './message.styled'\n\nexport interface MessageProps extends Omit<StyledMessageProps, 'status'> {\n status?: FormFieldStatus\n chidren?: React.ReactNode\n}\n\nexport const Message = React.forwardRef<\n ElementRef<typeof StyledMessage>,\n MessageProps\n>((props, forwardRef) => {\n const { messageId, setMessageId, status } = useFormFieldContext()\n\n const id = props.id ?? messageId\n useEffect(() => setMessageId(id), [setMessageId, id])\n\n if (\n status !== FORM_FIELD_STATUS.invalid &&\n status !== FORM_FIELD_STATUS.valid\n ) {\n return null\n }\n\n return (\n <StyledMessage\n role='alert'\n {...props}\n id={id}\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, { useEffect } from 'react'\nimport type { ElementRef } from 'react'\nimport { useFormFieldContext } from '@mirohq/design-system-base-form'\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) => {\n const { descriptionId, setDescriptionId } = useFormFieldContext()\n\n const id = props.id ?? descriptionId\n useEffect(() => setDescriptionId(id), [setDescriptionId, id])\n\n return <StyledDescription {...props} id={id} 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,QAAU,EAAA,MAAA;AAAA,EACV,YAAc,EAAA,MAAA;AAAA,EACd,OAAS,EAAA,OAAA;AACX,CAAC,CAAA,CAAA;AAEY,MAAA,cAAA,GAAiB,MAAO,CAAA,SAAA,CAAU,IAAM,EAAA;AAAA,EACnD,KAAO,EAAA,cAAA;AACT,CAAC,CAAA;;ACMY,MAAA,KAAA,GAAQ,KAAM,CAAA,UAAA,CAGzB,CAAC,EAAE,QAAW,GAAA,IAAA,EAAM,QAAU,EAAA,GAAG,SAAU,EAAA,EAAG,UAAe,KAAA;AAC7D,EAAM,MAAA;AAAA,IACJ,QAAA;AAAA,IACA,kBAAA;AAAA,IACA,aAAA;AAAA,IACA,QAAW,GAAA,KAAA;AAAA,MACT,mBAAoB,EAAA,CAAA;AAExB,EAAA,MAAM,KAAQ,GAAA,OAAA;AAAA,IACZ,sBAEK,IAAA,CAAA,QAAA,EAAA,EAAA,QAAA,EAAA;AAAA,MAAA,QAAA;AAAA,MACA,QAAA,oBAAa,GAAA,CAAA,cAAA,EAAA,EAAe,QAAC,EAAA,GAAA,EAAA,CAAA;AAAA,KAChC,EAAA,CAAA;AAAA,IAEF,CAAC,UAAU,QAAQ,CAAA;AAAA,GACrB,CAAA;AAEA,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,QAAA,CAAS,KAAK,CAAA,CAAA;AAAA,GACb,EAAA,CAAC,QAAU,EAAA,KAAK,CAAC,CAAA,CAAA;AAEpB,EAAA,SAAA,CAAU,MAAM,kBAAmB,CAAA,QAAQ,GAAG,CAAC,kB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G,KAAO,EAAA,EAAA,EAAQ,KAAK,UAAY,EAAA,CAAA,CAAA;AAChE,CAAC,CAAA;;ACPM,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
@@ -4,7 +4,7 @@ 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
+ import { FormFieldProviderProps, FormFieldStatus } from '@mirohq/design-system-base-form';
8
8
 
9
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<{}, {
10
10
  'border-widths': {
@@ -985,37 +985,20 @@ declare const StyledLabel: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_des
985
985
  _hover: (css: _stitches_react_types_css_util.CSSProperties) => {
986
986
  '&:hover, &[data-hovered]': _stitches_react_types_css_util.CSSProperties;
987
987
  };
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
+ }>>>, 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">>, {}, {}>;
993
989
  declare type StyledLabelProps = ComponentPropsWithRef<typeof StyledLabel>;
994
990
 
995
- declare const labelSymbol: unique symbol;
996
-
997
- interface LabelProps extends Omit<StyledLabelProps, 'placeholder'> {
991
+ interface LabelProps extends StyledLabelProps {
998
992
  /**
999
993
  * The content
1000
994
  */
1001
995
  children: react__default.ReactNode;
996
+ /**
997
+ * Whether the label should float above the input
998
+ */
1002
999
  floating?: boolean;
1003
- required?: boolean;
1004
1000
  }
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;
1017
- }
1018
- declare type FormFieldProviderProps = Partial<FormFieldProps>;
1001
+ declare const Label: react__default.ForwardRefExoticComponent<Omit<LabelProps, "ref"> & react__default.RefAttributes<HTMLLabelElement>>;
1019
1002
 
1020
1003
  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<{}, {
1021
1004
  'border-widths': {
@@ -1512,7 +1495,7 @@ interface FieldProps extends StyledFieldProps, FormFieldProviderProps {
1512
1495
  }
1513
1496
  declare const Field: react__default.ForwardRefExoticComponent<Omit<FieldProps, "ref"> & react__default.RefAttributes<HTMLDivElement>>;
1514
1497
 
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
+ 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<{}, {
1516
1499
  'border-widths': {
1517
1500
  readonly none: 0;
1518
1501
  readonly sm: "1px";
@@ -2000,7 +1983,7 @@ declare const StyledHelper: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_de
2000
1983
  _hover: (css: _stitches_react_types_css_util.CSSProperties) => {
2001
1984
  '&:hover, &[data-hovered]': _stitches_react_types_css_util.CSSProperties;
2002
1985
  };
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
+ }>>>, 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">>, {}, {}>;
2004
1987
  declare type StyledHelperProps = ComponentPropsWithRef<typeof StyledHelper>;
2005
1988
 
2006
1989
  interface HelperProps extends StyledHelperProps {
@@ -2009,9 +1992,9 @@ interface HelperProps extends StyledHelperProps {
2009
1992
  */
2010
1993
  children: react__default.ReactNode;
2011
1994
  }
2012
- declare const Helper: react__default.ForwardRefExoticComponent<Omit<HelperProps, "ref"> & react__default.RefAttributes<HTMLParagraphElement>>;
1995
+ declare const Helper: react__default.ForwardRefExoticComponent<Omit<HelperProps, "ref"> & react__default.RefAttributes<HTMLDivElement>>;
2013
1996
 
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
+ declare const StyledMessage: 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<{}, {
2015
1998
  'border-widths': {
2016
1999
  readonly none: 0;
2017
2000
  readonly sm: "1px";
@@ -2500,16 +2483,17 @@ declare const StyledMessage: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_d
2500
2483
  '&:hover, &[data-hovered]': _stitches_react_types_css_util.CSSProperties;
2501
2484
  };
2502
2485
  }>>>, "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;
2486
+ status?: "valid" | "invalid" | "dirty" | "pristine" | "touched" | undefined;
2487
+ }, {}> & _mirohq_design_system_stitches.CustomStylesProps, "ref"> & react.RefAttributes<HTMLDivElement>> & _mirohq_design_system_stitches.StitchesInternals<react.ForwardRefExoticComponent<_mirohq_design_system_primitive.PrimitiveProps<"div">>, {
2488
+ status?: "valid" | "invalid" | "dirty" | "pristine" | "touched" | undefined;
2506
2489
  }, {}>;
2507
2490
  declare type StyledMessageProps = ComponentPropsWithRef<typeof StyledMessage>;
2508
2491
 
2509
2492
  interface MessageProps extends Omit<StyledMessageProps, 'status'> {
2510
- status?: Status;
2493
+ status?: FormFieldStatus;
2494
+ chidren?: react__default.ReactNode;
2511
2495
  }
2512
- declare const Message: react__default.ForwardRefExoticComponent<Omit<MessageProps, "ref"> & react__default.RefAttributes<HTMLParagraphElement>>;
2496
+ declare const Message: react__default.ForwardRefExoticComponent<Omit<MessageProps, "ref"> & react__default.RefAttributes<HTMLDivElement>>;
2513
2497
 
2514
2498
  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<{}, {
2515
2499
  'border-widths': {
@@ -3025,4 +3009,4 @@ interface Partials {
3025
3009
  Description: typeof Description;
3026
3010
  }
3027
3011
 
3028
- export { Form, FormProps };
3012
+ export { Form, DescriptionProps as FormDescriptionProps, FieldProps as FormFieldProps, HelperProps as FormHelperProps, LabelProps as FormLabelProps, MessageProps as FormMessageProps, FormProps };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mirohq/design-system-form",
3
- "version": "0.1.0-forms.2",
3
+ "version": "0.1.0-forms.4",
4
4
  "description": "",
5
5
  "author": "Miro",
6
6
  "source": "src/index.ts",
@@ -26,10 +26,10 @@
26
26
  "react": "^16.14 || ^17 || ^18"
27
27
  },
28
28
  "dependencies": {
29
- "@mirohq/design-system-base-input": "^0.1.0-forms.1",
30
- "@mirohq/design-system-primitive": "^1.1.2-forms.0",
29
+ "@mirohq/design-system-base-form": "^0.1.0-forms.0",
31
30
  "@mirohq/design-system-stitches": "^2.6.0",
32
31
  "@mirohq/design-system-use-id": "^0.1.1-forms.0",
32
+ "@mirohq/design-system-primitive": "^1.1.2-forms.0",
33
33
  "@mirohq/design-system-utils": "^0.15.0-forms.0"
34
34
  },
35
35
  "scripts": {