@mirohq/design-system-form 0.1.0-forms.3 → 0.1.0-forms.5

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,131 @@ 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
+ lineHeight: 1.5,
23
+ marginBottom: "$100",
24
+ display: "block"
39
25
  });
40
26
  const StyledAsterisk = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
41
27
  color: "$text-danger"
42
28
  });
43
29
 
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
- )
30
+ const Label = React__default["default"].forwardRef(({ floating = true, children, ...restProps }, forwardRef) => {
31
+ const {
32
+ setLabel,
33
+ setIsFloatingLabel,
34
+ formElementId,
35
+ required = false
36
+ } = designSystemBaseForm.useFormFieldContext();
37
+ const label = React.useMemo(
38
+ () => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
39
+ children,
40
+ required && /* @__PURE__ */ jsxRuntime.jsx(StyledAsterisk, { children: "*" })
41
+ ] }),
42
+ [children, required]
52
43
  );
53
- };
44
+ React.useEffect(() => {
45
+ setLabel(label);
46
+ }, [setLabel, label]);
47
+ React.useEffect(() => setIsFloatingLabel(floating), [setIsFloatingLabel, floating]);
48
+ if (floating) {
49
+ return null;
50
+ }
51
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledLabel, { htmlFor: formElementId, ...restProps, ref: forwardRef, children: label });
52
+ });
54
53
 
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);
54
+ const StyledDescription = designSystemStitches.styled(designSystemPrimitive.Primitive.p, {
55
+ fontSize: "$175",
56
+ lineHeight: 1.5,
57
+ margin: 0,
58
+ marginBottom: "$150"
59
+ });
60
+
61
+ const StyledHelper = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
62
+ fontSize: "$150",
63
+ lineHeight: 1.5,
64
+ marginTop: "$50"
65
+ });
95
66
 
96
67
  const StyledField = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
97
- marginBottom: "$300"
68
+ marginBottom: "$300",
69
+ position: "relative",
70
+ "&[data-disabled]": {
71
+ ["".concat(StyledLabel, ", ").concat(StyledDescription, ", ").concat(StyledHelper)]: {
72
+ color: "$text-neutrals-disabled"
73
+ }
74
+ },
75
+ "&[data-readonly]": {
76
+ ["".concat(StyledLabel, ", ").concat(StyledDescription, ", ").concat(StyledHelper)]: {
77
+ color: "$text-neutrals-subtle"
78
+ }
79
+ }
98
80
  });
99
81
 
100
82
  const Root = React__default["default"].forwardRef(
101
- ({ children, ...restProps }, forwardRef) => {
83
+ ({ onFocus, onBlur, status: statusProps, ...restProps }, forwardRef) => {
84
+ var _a;
102
85
  const {
103
86
  id,
104
- status,
87
+ status: formFieldStatus,
88
+ setStatus,
105
89
  required,
106
90
  focused,
107
91
  setFocused,
108
92
  disabled,
109
93
  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;
94
+ readOnly,
95
+ formElementRef
96
+ } = designSystemBaseForm.useFormFieldContext();
97
+ const status = statusProps != null ? statusProps : formFieldStatus;
98
+ const initialValueRef = React.useRef();
99
+ if (((_a = formElementRef.current) == null ? void 0 : _a.value) !== void 0 && initialValueRef.current === void 0) {
100
+ initialValueRef.current = formElementRef.current.value;
101
+ }
129
102
  return /* @__PURE__ */ jsxRuntime.jsx(
130
103
  StyledField,
131
104
  {
132
- id,
133
- "aria-disabled": ariaDisabled,
134
- "aria-required": required,
135
- "aria-invalid": status === "invalid",
136
105
  "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),
106
+ "data-required": designSystemUtils.booleanAttrValue(required),
107
+ "data-focused": designSystemUtils.booleanAttrValue(focused),
108
+ "data-disabled": designSystemUtils.booleanAttrValue(
109
+ disabled === true || ariaDisabled === true
110
+ ),
111
+ "data-readonly": designSystemUtils.booleanAttrValue(readOnly),
112
+ onFocus: (e) => {
113
+ setFocused(true);
114
+ onFocus == null ? void 0 : onFocus(e);
115
+ },
116
+ onBlur: (e) => {
117
+ if (statusProps === void 0) {
118
+ setStatus(
119
+ initialValueRef.current !== e.target.value ? designSystemBaseForm.FORM_FIELD_STATUS.dirty : designSystemBaseForm.FORM_FIELD_STATUS.touched
120
+ );
121
+ }
122
+ setFocused(false);
123
+ onBlur == null ? void 0 : onBlur(e);
124
+ },
142
125
  ...restProps,
143
- ref: forwardRef,
144
- children: formattedChildren
126
+ id,
127
+ ref: forwardRef
145
128
  }
146
129
  );
147
130
  }
148
131
  );
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
- );
170
-
171
- const StyledHelper = designSystemStitches.styled(designSystemPrimitive.Primitive.p, {
172
- fontSize: "$150",
173
- lineHeight: 1.5,
174
- marginTop: "$50"
175
- });
132
+ 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 }) }));
176
133
 
177
134
  const Helper = React__default["default"].forwardRef((props, forwardRef) => {
178
- const { helperId } = useFormFieldContext();
179
- return /* @__PURE__ */ jsxRuntime.jsx(StyledHelper, { id: helperId, ...props, ref: forwardRef });
135
+ var _a;
136
+ const { helperId, setHelperId } = designSystemBaseForm.useFormFieldContext();
137
+ const id = (_a = props.id) != null ? _a : helperId;
138
+ React.useEffect(() => setHelperId(id), [setHelperId, id]);
139
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledHelper, { ...props, id, ref: forwardRef });
180
140
  });
181
141
 
182
- const StyledMessage = designSystemStitches.styled(Helper, {
142
+ const StyledMessage = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
143
+ fontSize: "$150",
144
+ lineHeight: 1.5,
145
+ marginTop: "$50",
183
146
  variants: {
184
147
  status: {
185
148
  valid: {
@@ -190,36 +153,37 @@ const StyledMessage = designSystemStitches.styled(Helper, {
190
153
  },
191
154
  dirty: {},
192
155
  pristine: {},
193
- touched: {},
194
- pending: {}
156
+ touched: {}
195
157
  }
196
158
  }
197
159
  });
198
160
 
199
161
  const Message = React__default["default"].forwardRef((props, forwardRef) => {
200
- const { messageId, status } = useFormFieldContext();
162
+ var _a;
163
+ const { messageId, setMessageId, status } = designSystemBaseForm.useFormFieldContext();
164
+ const id = (_a = props.id) != null ? _a : messageId;
165
+ React.useEffect(() => setMessageId(id), [setMessageId, id]);
166
+ if (status !== designSystemBaseForm.FORM_FIELD_STATUS.invalid && status !== designSystemBaseForm.FORM_FIELD_STATUS.valid) {
167
+ return null;
168
+ }
201
169
  return /* @__PURE__ */ jsxRuntime.jsx(
202
170
  StyledMessage,
203
171
  {
204
- id: messageId,
205
- "aria-live": "polite",
172
+ role: "alert",
206
173
  ...props,
174
+ id,
207
175
  status,
208
176
  ref: forwardRef
209
177
  }
210
178
  );
211
179
  });
212
180
 
213
- const StyledDescription = designSystemStitches.styled(designSystemPrimitive.Primitive.p, {
214
- fontSize: "$175",
215
- lineHeight: 1.5,
216
- margin: 0,
217
- marginBottom: "$150"
218
- });
219
-
220
181
  const Description = React__default["default"].forwardRef((props, forwardRef) => {
221
- const { descriptionId } = useFormFieldContext();
222
- return /* @__PURE__ */ jsxRuntime.jsx(StyledDescription, { id: descriptionId, ...props, ref: forwardRef });
182
+ var _a;
183
+ const { descriptionId, setDescriptionId } = designSystemBaseForm.useFormFieldContext();
184
+ const id = (_a = props.id) != null ? _a : descriptionId;
185
+ React.useEffect(() => setDescriptionId(id), [setDescriptionId, id]);
186
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledDescription, { ...props, id, ref: forwardRef });
223
187
  });
224
188
 
225
189
  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;AAA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BAAA,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;;;;"}
1
+ {"version":3,"file":"main.js","sources":["../src/form.styled.tsx","../src/partials/label.styled.tsx","../src/partials/label.tsx","../src/partials/description.styled.tsx","../src/partials/helper.styled.tsx","../src/partials/field.styled.tsx","../src/partials/field.tsx","../src/partials/helper.tsx","../src/partials/message.styled.tsx","../src/partials/message.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 lineHeight: 1.5,\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 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 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 type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nimport { StyledLabel } from './label.styled'\nimport { StyledDescription } from './description.styled'\nimport { StyledHelper } from './helper.styled'\n\nexport const StyledField = styled(Primitive.div, {\n marginBottom: '$300',\n position: 'relative',\n '&[data-disabled]': {\n [`${StyledLabel}, ${StyledDescription}, ${StyledHelper}`]: {\n color: '$text-neutrals-disabled',\n },\n },\n '&[data-readonly]': {\n [`${StyledLabel}, ${StyledDescription}, ${StyledHelper}`]: {\n color: '$text-neutrals-subtle',\n },\n },\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 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 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,IA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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,140 @@
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
+ lineHeight: 1.5,
15
+ marginBottom: "$100",
16
+ display: "block"
31
17
  });
32
18
  const StyledAsterisk = styled(Primitive.span, {
33
19
  color: "$text-danger"
34
20
  });
35
21
 
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
- )
22
+ const Label = React.forwardRef(({ floating = true, children, ...restProps }, forwardRef) => {
23
+ const {
24
+ setLabel,
25
+ setIsFloatingLabel,
26
+ formElementId,
27
+ required = false
28
+ } = useFormFieldContext();
29
+ const label = useMemo(
30
+ () => /* @__PURE__ */ jsxs(Fragment, { children: [
31
+ children,
32
+ required && /* @__PURE__ */ jsx(StyledAsterisk, { children: "*" })
33
+ ] }),
34
+ [children, required]
44
35
  );
45
- };
36
+ useEffect(() => {
37
+ setLabel(label);
38
+ }, [setLabel, label]);
39
+ useEffect(() => setIsFloatingLabel(floating), [setIsFloatingLabel, floating]);
40
+ if (floating) {
41
+ return null;
42
+ }
43
+ return /* @__PURE__ */ jsx(StyledLabel, { htmlFor: formElementId, ...restProps, ref: forwardRef, children: label });
44
+ });
46
45
 
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;
46
+ const StyledDescription = styled(Primitive.p, {
47
+ fontSize: "$175",
48
+ lineHeight: 1.5,
49
+ margin: 0,
50
+ marginBottom: "$150"
51
+ });
54
52
 
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);
53
+ const StyledHelper = styled(Primitive.div, {
54
+ fontSize: "$150",
55
+ lineHeight: 1.5,
56
+ marginTop: "$50"
57
+ });
87
58
 
88
59
  const StyledField = styled(Primitive.div, {
89
- marginBottom: "$300"
60
+ marginBottom: "$300",
61
+ position: "relative",
62
+ "&[data-disabled]": {
63
+ ["".concat(StyledLabel, ", ").concat(StyledDescription, ", ").concat(StyledHelper)]: {
64
+ color: "$text-neutrals-disabled"
65
+ }
66
+ },
67
+ "&[data-readonly]": {
68
+ ["".concat(StyledLabel, ", ").concat(StyledDescription, ", ").concat(StyledHelper)]: {
69
+ color: "$text-neutrals-subtle"
70
+ }
71
+ }
90
72
  });
91
73
 
92
74
  const Root = React.forwardRef(
93
- ({ children, ...restProps }, forwardRef) => {
75
+ ({ onFocus, onBlur, status: statusProps, ...restProps }, forwardRef) => {
76
+ var _a;
94
77
  const {
95
78
  id,
96
- status,
79
+ status: formFieldStatus,
80
+ setStatus,
97
81
  required,
98
82
  focused,
99
83
  setFocused,
100
84
  disabled,
101
85
  ariaDisabled,
102
- readOnly
86
+ readOnly,
87
+ formElementRef
103
88
  } = 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;
89
+ const status = statusProps != null ? statusProps : formFieldStatus;
90
+ const initialValueRef = useRef();
91
+ if (((_a = formElementRef.current) == null ? void 0 : _a.value) !== void 0 && initialValueRef.current === void 0) {
92
+ initialValueRef.current = formElementRef.current.value;
93
+ }
121
94
  return /* @__PURE__ */ jsx(
122
95
  StyledField,
123
96
  {
124
- id,
125
- "aria-disabled": ariaDisabled,
126
- "aria-required": required,
127
- "aria-invalid": status === "invalid",
128
97
  "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),
98
+ "data-required": booleanAttrValue(required),
99
+ "data-focused": booleanAttrValue(focused),
100
+ "data-disabled": booleanAttrValue(
101
+ disabled === true || ariaDisabled === true
102
+ ),
103
+ "data-readonly": booleanAttrValue(readOnly),
104
+ onFocus: (e) => {
105
+ setFocused(true);
106
+ onFocus == null ? void 0 : onFocus(e);
107
+ },
108
+ onBlur: (e) => {
109
+ if (statusProps === void 0) {
110
+ setStatus(
111
+ initialValueRef.current !== e.target.value ? FORM_FIELD_STATUS.dirty : FORM_FIELD_STATUS.touched
112
+ );
113
+ }
114
+ setFocused(false);
115
+ onBlur == null ? void 0 : onBlur(e);
116
+ },
134
117
  ...restProps,
135
- ref: forwardRef,
136
- children: formattedChildren
118
+ id,
119
+ ref: forwardRef
137
120
  }
138
121
  );
139
122
  }
140
123
  );
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
- );
162
-
163
- const StyledHelper = styled(Primitive.p, {
164
- fontSize: "$150",
165
- lineHeight: 1.5,
166
- marginTop: "$50"
167
- });
124
+ const Field = React.forwardRef(({ id, status, ...restProps }, forwardRef) => /* @__PURE__ */ jsx(FormFieldProvider, { status, id, children: /* @__PURE__ */ jsx(Root, { status, ...restProps, ref: forwardRef }) }));
168
125
 
169
126
  const Helper = React.forwardRef((props, forwardRef) => {
170
- const { helperId } = useFormFieldContext();
171
- return /* @__PURE__ */ jsx(StyledHelper, { id: helperId, ...props, ref: forwardRef });
127
+ var _a;
128
+ const { helperId, setHelperId } = useFormFieldContext();
129
+ const id = (_a = props.id) != null ? _a : helperId;
130
+ useEffect(() => setHelperId(id), [setHelperId, id]);
131
+ return /* @__PURE__ */ jsx(StyledHelper, { ...props, id, ref: forwardRef });
172
132
  });
173
133
 
174
- const StyledMessage = styled(Helper, {
134
+ const StyledMessage = styled(Primitive.div, {
135
+ fontSize: "$150",
136
+ lineHeight: 1.5,
137
+ marginTop: "$50",
175
138
  variants: {
176
139
  status: {
177
140
  valid: {
@@ -182,36 +145,37 @@ const StyledMessage = styled(Helper, {
182
145
  },
183
146
  dirty: {},
184
147
  pristine: {},
185
- touched: {},
186
- pending: {}
148
+ touched: {}
187
149
  }
188
150
  }
189
151
  });
190
152
 
191
153
  const Message = React.forwardRef((props, forwardRef) => {
192
- const { messageId, status } = useFormFieldContext();
154
+ var _a;
155
+ const { messageId, setMessageId, status } = useFormFieldContext();
156
+ const id = (_a = props.id) != null ? _a : messageId;
157
+ useEffect(() => setMessageId(id), [setMessageId, id]);
158
+ if (status !== FORM_FIELD_STATUS.invalid && status !== FORM_FIELD_STATUS.valid) {
159
+ return null;
160
+ }
193
161
  return /* @__PURE__ */ jsx(
194
162
  StyledMessage,
195
163
  {
196
- id: messageId,
197
- "aria-live": "polite",
164
+ role: "alert",
198
165
  ...props,
166
+ id,
199
167
  status,
200
168
  ref: forwardRef
201
169
  }
202
170
  );
203
171
  });
204
172
 
205
- const StyledDescription = styled(Primitive.p, {
206
- fontSize: "$175",
207
- lineHeight: 1.5,
208
- margin: 0,
209
- marginBottom: "$150"
210
- });
211
-
212
173
  const Description = React.forwardRef((props, forwardRef) => {
213
- const { descriptionId } = useFormFieldContext();
214
- return /* @__PURE__ */ jsx(StyledDescription, { id: descriptionId, ...props, ref: forwardRef });
174
+ var _a;
175
+ const { descriptionId, setDescriptionId } = useFormFieldContext();
176
+ const id = (_a = props.id) != null ? _a : descriptionId;
177
+ useEffect(() => setDescriptionId(id), [setDescriptionId, id]);
178
+ return /* @__PURE__ */ jsx(StyledDescription, { ...props, id, ref: forwardRef });
215
179
  });
216
180
 
217
181
  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;AAA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,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/description.styled.tsx","../src/partials/helper.styled.tsx","../src/partials/field.styled.tsx","../src/partials/field.tsx","../src/partials/helper.tsx","../src/partials/message.styled.tsx","../src/partials/message.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 lineHeight: 1.5,\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 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 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 type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nimport { StyledLabel } from './label.styled'\nimport { StyledDescription } from './description.styled'\nimport { StyledHelper } from './helper.styled'\n\nexport const StyledField = styled(Primitive.div, {\n marginBottom: '$300',\n position: 'relative',\n '&[data-disabled]': {\n [`${StyledLabel}, ${StyledDescription}, ${StyledHelper}`]: {\n color: '$text-neutrals-disabled',\n },\n },\n '&[data-readonly]': {\n [`${StyledLabel}, ${StyledDescription}, ${StyledHelper}`]: {\n color: '$text-neutrals-subtle',\n },\n },\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 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 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,UAAY,EAAA,GAAA;AAAA,EACZ,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;;ACKY,MAAA,KAAA,GAAQ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AAK,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': {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mirohq/design-system-form",
3
- "version": "0.1.0-forms.3",
3
+ "version": "0.1.0-forms.5",
4
4
  "description": "",
5
5
  "author": "Miro",
6
6
  "source": "src/index.ts",
@@ -26,11 +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
+ "@mirohq/design-system-base-form": "^0.1.0-forms.1",
30
30
  "@mirohq/design-system-primitive": "^1.1.2-forms.0",
31
31
  "@mirohq/design-system-use-id": "^0.1.1-forms.0",
32
- "@mirohq/design-system-utils": "^0.15.0-forms.0",
33
- "@mirohq/design-system-stitches": "^2.6.0"
32
+ "@mirohq/design-system-stitches": "^2.6.0",
33
+ "@mirohq/design-system-utils": "^0.15.0-forms.1"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "rollup -c ../../../rollup.config.js",