@mirohq/design-system-form 0.1.0-forms.1 → 0.1.0-forms.3
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 +62 -8
- package/dist/main.js.map +1 -1
- package/dist/module.js +64 -10
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +22 -4
- package/package.json +4 -3
package/dist/main.js
CHANGED
|
@@ -7,6 +7,7 @@ var designSystemStitches = require('@mirohq/design-system-stitches');
|
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
var React = require('react');
|
|
9
9
|
var designSystemUtils = require('@mirohq/design-system-utils');
|
|
10
|
+
var designSystemBaseInput = require('@mirohq/design-system-base-input');
|
|
10
11
|
var designSystemUseId = require('@mirohq/design-system-use-id');
|
|
11
12
|
|
|
12
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -19,12 +20,45 @@ const StyledForm = designSystemStitches.styled(designSystemPrimitive.Primitive.f
|
|
|
19
20
|
|
|
20
21
|
const StyledLabel = designSystemStitches.styled(designSystemPrimitive.Primitive.label, {
|
|
21
22
|
display: "block",
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
+
}
|
|
25
39
|
});
|
|
40
|
+
const StyledAsterisk = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
|
|
41
|
+
color: "$text-danger"
|
|
42
|
+
});
|
|
43
|
+
|
|
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
|
+
};
|
|
26
54
|
|
|
27
|
-
const Label =
|
|
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;
|
|
28
62
|
|
|
29
63
|
const FormFieldContext = React.createContext({});
|
|
30
64
|
const FormFieldProvider = ({
|
|
@@ -59,10 +93,12 @@ const FormFieldProvider = ({
|
|
|
59
93
|
};
|
|
60
94
|
const useFormFieldContext = () => React.useContext(FormFieldContext);
|
|
61
95
|
|
|
62
|
-
const StyledField = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
|
|
96
|
+
const StyledField = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
|
|
97
|
+
marginBottom: "$300"
|
|
98
|
+
});
|
|
63
99
|
|
|
64
100
|
const Root = React__default["default"].forwardRef(
|
|
65
|
-
(
|
|
101
|
+
({ children, ...restProps }, forwardRef) => {
|
|
66
102
|
const {
|
|
67
103
|
id,
|
|
68
104
|
status,
|
|
@@ -73,6 +109,23 @@ const Root = React__default["default"].forwardRef(
|
|
|
73
109
|
ariaDisabled,
|
|
74
110
|
readOnly
|
|
75
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;
|
|
76
129
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
77
130
|
StyledField,
|
|
78
131
|
{
|
|
@@ -86,8 +139,9 @@ const Root = React__default["default"].forwardRef(
|
|
|
86
139
|
"data-disabled": designSystemUtils.booleanishAttrValue(disabled),
|
|
87
140
|
"data-readonly": designSystemUtils.booleanishAttrValue(readOnly),
|
|
88
141
|
onFocus: () => setFocused == null ? void 0 : setFocused(true),
|
|
89
|
-
...
|
|
90
|
-
ref: forwardRef
|
|
142
|
+
...restProps,
|
|
143
|
+
ref: forwardRef,
|
|
144
|
+
children: formattedChildren
|
|
91
145
|
}
|
|
92
146
|
);
|
|
93
147
|
}
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sources":["../src/form.styled.tsx","../src/partials/label.styled.tsx","../src/partials/label.tsx","../src/hooks/use-form-field-context.tsx","../src/partials/field.styled.tsx","../src/partials/field.tsx","../src/partials/helper.styled.tsx","../src/partials/helper.tsx","../src/partials/message.styled.tsx","../src/partials/message.tsx","../src/partials/description.styled.tsx","../src/partials/description.tsx","../src/form.tsx"],"sourcesContent":["import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledForm = styled(Primitive.form, {\n all: 'unset',\n})\n\nexport type StyledFormProps = ComponentPropsWithRef<typeof StyledForm>\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledLabel = styled(Primitive.label, {\n display: 'block',\n fontSize: '$200',\n lineHeight: 1.5,\n marginBottom: '$100',\n})\n\nexport type StyledLabelProps = ComponentPropsWithRef<typeof StyledLabel>\n","import { StyledLabel } from './label.styled'\nimport type { StyledLabelProps } from './label.styled'\n\nexport interface LabelProps extends StyledLabelProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Label = StyledLabel\n","import React, { createContext, useContext, useState, useRef } from 'react'\nimport type { PropsWithChildren } from 'react'\nimport type { Booleanish } from '@mirohq/design-system-types'\nimport { useId } from '@mirohq/design-system-use-id'\n\nexport type Status =\n | 'valid'\n | 'invalid'\n | 'dirty'\n | 'pristine'\n | 'touched'\n | 'pending'\n\ninterface FormFieldProps {\n required?: boolean\n readOnly?: boolean\n disabled?: boolean\n ariaDisabled?: Booleanish\n status?: Status\n id: string\n}\n\ninterface FormFieldContextProps extends FormFieldProps {\n setStatus: React.Dispatch<React.SetStateAction<Status>>\n focused: boolean\n setFocused: React.Dispatch<React.SetStateAction<boolean>>\n helperId: string\n messageId: string\n descriptionId: string\n formElementRef: React.RefObject<HTMLInputElement>\n}\n\nexport type FormFieldProviderProps = Partial<FormFieldProps>\n\nconst FormFieldContext = createContext<FormFieldContextProps>({} as any)\n\nexport const FormFieldProvider = ({\n children,\n status: customStatus,\n id: customId,\n ...restProps\n}: PropsWithChildren<FormFieldProviderProps>): JSX.Element => {\n const formElementRef = useRef<HTMLInputElement>(null)\n const [status, setStatus] = useState<Status>(customStatus ?? 'pristine')\n const [focused, setFocused] = useState(false)\n\n const autoId = useId()\n const id = customId ?? autoId\n\n return (\n <FormFieldContext.Provider\n value={{\n ...restProps,\n id,\n formElementRef,\n messageId: `${id}-message`,\n helperId: `${id}-helper`,\n descriptionId: `${id}-description`,\n status,\n setStatus,\n focused,\n setFocused,\n }}\n >\n {children}\n </FormFieldContext.Provider>\n )\n}\n\nexport const useFormFieldContext = (): FormFieldContextProps =>\n useContext(FormFieldContext)\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledField = styled(Primitive.div, {})\n\nexport type StyledFieldProps = ComponentPropsWithRef<typeof StyledField>\n","import React from 'react'\nimport type { ElementRef } from 'react'\nimport { booleanishAttrValue } from '@mirohq/design-system-utils'\n\nimport {\n useFormFieldContext,\n FormFieldProvider,\n} from '../hooks/use-form-field-context'\nimport type { FormFieldProviderProps } from '../hooks/use-form-field-context'\nimport type { StyledFieldProps } from './field.styled'\nimport { StyledField } from './field.styled'\n\nexport interface FieldProps extends StyledFieldProps, FormFieldProviderProps {}\n\nconst Root = React.forwardRef<ElementRef<typeof StyledField>, FieldProps>(\n (props, forwardRef) => {\n const {\n id,\n status,\n required,\n focused,\n setFocused,\n disabled,\n ariaDisabled,\n readOnly,\n } = useFormFieldContext()\n\n return (\n <StyledField\n id={id}\n aria-disabled={ariaDisabled}\n aria-required={required}\n aria-invalid={status === 'invalid'}\n data-status={status}\n data-required={booleanishAttrValue(required)}\n data-focused={booleanishAttrValue(focused)}\n data-disabled={booleanishAttrValue(disabled)}\n data-readonly={booleanishAttrValue(readOnly)}\n onFocus={() => setFocused?.(true)}\n {...props}\n ref={forwardRef}\n />\n )\n }\n)\n\nexport const Field = React.forwardRef<\n ElementRef<typeof StyledField>,\n FieldProps\n>(\n (\n {\n id,\n required,\n status,\n readOnly,\n disabled,\n 'aria-disabled': ariaDisabled,\n ...restProps\n },\n forwardRef\n ) => (\n <FormFieldProvider\n required={required}\n status={status}\n readOnly={readOnly}\n disabled={disabled}\n aria-disabled={ariaDisabled}\n >\n <Root {...restProps} ref={forwardRef} />\n </FormFieldProvider>\n )\n)\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledHelper = styled(Primitive.p, {\n fontSize: '$150',\n lineHeight: 1.5,\n marginTop: '$50',\n})\n\nexport type StyledHelperProps = ComponentPropsWithRef<typeof StyledHelper>\n","import React from 'react'\nimport type { ElementRef } from 'react'\n\nimport { useFormFieldContext } from '../hooks/use-form-field-context'\nimport type { StyledHelperProps } from './helper.styled'\nimport { StyledHelper } from './helper.styled'\n\nexport interface HelperProps extends StyledHelperProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Helper = React.forwardRef<\n ElementRef<typeof StyledHelper>,\n HelperProps\n>((props, forwardRef) => {\n const { helperId } = useFormFieldContext()\n return <StyledHelper id={helperId} {...props} ref={forwardRef} />\n})\n","import type { ComponentPropsWithRef } from 'react'\nimport { styled } from '@mirohq/design-system-stitches'\n\nimport { Helper } from './helper'\n\nexport const StyledMessage = styled(Helper, {\n variants: {\n status: {\n valid: {\n color: '$text-success',\n },\n invalid: {\n color: '$text-danger',\n },\n dirty: {},\n pristine: {},\n touched: {},\n pending: {},\n },\n },\n})\n\nexport type StyledMessageProps = ComponentPropsWithRef<typeof StyledMessage>\n","import React from 'react'\nimport type { ElementRef } from 'react'\n\nimport { useFormFieldContext } from '../hooks/use-form-field-context'\nimport type { Status } from '../hooks/use-form-field-context'\nimport type { StyledMessageProps } from './message.styled'\nimport { StyledMessage } from './message.styled'\n\nexport interface MessageProps extends Omit<StyledMessageProps, 'status'> {\n status?: Status\n}\n\nexport const Message = React.forwardRef<\n ElementRef<typeof StyledMessage>,\n MessageProps\n>((props, forwardRef) => {\n const { messageId, status } = useFormFieldContext()\n return (\n <StyledMessage\n id={messageId}\n aria-live='polite'\n {...props}\n status={status}\n ref={forwardRef}\n />\n )\n})\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledDescription = styled(Primitive.p, {\n fontSize: '$175',\n lineHeight: 1.5,\n margin: 0,\n marginBottom: '$150',\n})\n\nexport type StyledDescriptionProps = ComponentPropsWithRef<\n typeof StyledDescription\n>\n","import React from 'react'\nimport type { ElementRef } from 'react'\n\nimport { useFormFieldContext } from '../hooks/use-form-field-context'\nimport type { StyledDescriptionProps } from './description.styled'\nimport { StyledDescription } from './description.styled'\n\nexport interface DescriptionProps extends StyledDescriptionProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Description = React.forwardRef<\n ElementRef<typeof StyledDescription>,\n DescriptionProps\n>((props, forwardRef) => {\n const { descriptionId } = useFormFieldContext()\n return <StyledDescription id={descriptionId} {...props} ref={forwardRef} />\n})\n","import type { ForwardRefExoticComponent } from 'react'\n\nimport { StyledForm } from './form.styled'\nimport type { StyledFormProps } from './form.styled'\nimport { Label } from './partials/label'\nimport { Field } from './partials/field'\nimport { Helper } from './partials/helper'\nimport { Message } from './partials/message'\nimport { Description } from './partials/description'\n\nexport interface FormProps extends StyledFormProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Form = StyledForm as any as ForwardRefExoticComponent<FormProps> &\n Partials\n\n// Partials\n// -----------------------------------------------------------------------------\n\nexport interface Partials {\n Label: typeof Label\n Field: typeof Field\n Helper: typeof Helper\n Message: typeof Message\n Description: typeof Description\n}\n\nForm.Label = Label\nForm.Field = Field\nForm.Helper = Helper\nForm.Message = Message\nForm.Description = Description\n"],"names":["styled","Primitive","createContext","useRef","useState","useId","jsx","useContext","React","booleanishAttrValue"],"mappings":";;;;;;;;;;;;;;;AAIa,MAAA,UAAA,GAAaA,2BAAO,CAAAC,+BAAA,CAAU,IAAM,EAAA;AAAA,EAC/C,GAAK,EAAA,OAAA;AACP,CAAC,CAAA;;ACFY,MAAA,WAAA,GAAcD,2BAAO,CAAAC,+BAAA,CAAU,KAAO,EAAA;AAAA,EACjD,OAAS,EAAA,OAAA;AAAA,EACT,QAAU,EAAA,MAAA;AAAA,EAC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,QAAA;AAAA,MACT,GAAG,KAAA;AAAA,MACJ,MAAA;AAAA,MACA,GAAK,EAAA,UAAA;AAAA,KAAA;AAAA,GACP,CAAA;AAEJ,CAAC,CAAA;;ACtBY,MAAA,iBAAA,GAAoBN,2BAAO,CAAAC,+BAAA,CAAU,CAAG,EAAA;AAAA,EACnD,QAAU,EAAA,MAAA;AAAA,EACV,UAAY,EAAA,GAAA;AAAA,EACZ,MAAQ,EAAA,CAAA;AAAA,EACR,YAAc,EAAA,MAAA;AAChB,CAAC,CAAA;;ACKM,MAAM,WAAc,GAAAO,yBAAA,CAAM,UAG/B,CAAA,CAAC,OAAO,UAAe,KAAA;AACvB,EAAM,MAAA,EAAE,aAAc,EAAA,GAAI,mBAAoB,EAAA,CAAA;AAC9C,EAAA,sCAAQ,iBAAkB,EAAA,EAAA,EAAA,EAAI,eAAgB,GAAG,KAAA,EAAO,KAAK,UAAY,EAAA,CAAA,CAAA;AAC3E,CAAC,CAAA;;ACHM,MAAM,IAAO,GAAA,WAAA;AAcpB,IAAA,CAAK,KAAQ,GAAA,KAAA,CAAA;AACb,IAAA,CAAK,KAAQ,GAAA,KAAA,CAAA;AACb,IAAA,CAAK,MAAS,GAAA,MAAA,CAAA;AACd,IAAA,CAAK,OAAU,GAAA,OAAA,CAAA;AACf,IAAA,CAAK,WAAc,GAAA,WAAA;;;;"}
|
|
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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AC,yBAAA,CAAM,UAG/B,CAAA,CAAC,OAAO,UAAe,KAAA;AACvB,EAAM,MAAA,EAAE,aAAc,EAAA,GAAI,mBAAoB,EAAA,CAAA;AAC9C,EAAA,sCAAQ,iBAAkB,EAAA,EAAA,EAAA,EAAI,eAAgB,GAAG,KAAA,EAAO,KAAK,UAAY,EAAA,CAAA,CAAA;AAC3E,CAAC,CAAA;;ACHM,MAAM,IAAO,GAAA,WAAA;AAcpB,IAAA,CAAK,KAAQ,GAAA,KAAA,CAAA;AACb,IAAA,CAAK,KAAQ,GAAA,KAAA,CAAA;AACb,IAAA,CAAK,MAAS,GAAA,MAAA,CAAA;AACd,IAAA,CAAK,OAAU,GAAA,OAAA,CAAA;AACf,IAAA,CAAK,WAAc,GAAA,WAAA;;;;"}
|
package/dist/module.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Primitive } from '@mirohq/design-system-primitive';
|
|
2
2
|
import { styled } from '@mirohq/design-system-stitches';
|
|
3
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
4
|
import React, { createContext, useRef, useState, useContext } from 'react';
|
|
5
|
-
import { booleanishAttrValue } from '@mirohq/design-system-utils';
|
|
5
|
+
import { booleanify, booleanishAttrValue } from '@mirohq/design-system-utils';
|
|
6
|
+
import { isInputComponent } from '@mirohq/design-system-base-input';
|
|
6
7
|
import { useId } from '@mirohq/design-system-use-id';
|
|
7
8
|
|
|
8
9
|
const StyledForm = styled(Primitive.form, {
|
|
@@ -11,12 +12,45 @@ const StyledForm = styled(Primitive.form, {
|
|
|
11
12
|
|
|
12
13
|
const StyledLabel = styled(Primitive.label, {
|
|
13
14
|
display: "block",
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
+
}
|
|
17
31
|
});
|
|
32
|
+
const StyledAsterisk = styled(Primitive.span, {
|
|
33
|
+
color: "$text-danger"
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const labelSymbol = Symbol.for("label");
|
|
37
|
+
const isLabelComponent = (labelComponent) => {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
return Boolean(
|
|
40
|
+
(_b = labelComponent[labelSymbol]) != null ? _b : (
|
|
41
|
+
// @ts-expect-error
|
|
42
|
+
(_a = labelComponent == null ? void 0 : labelComponent.type) == null ? void 0 : _a[labelSymbol]
|
|
43
|
+
)
|
|
44
|
+
);
|
|
45
|
+
};
|
|
18
46
|
|
|
19
|
-
const Label =
|
|
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;
|
|
20
54
|
|
|
21
55
|
const FormFieldContext = createContext({});
|
|
22
56
|
const FormFieldProvider = ({
|
|
@@ -51,10 +85,12 @@ const FormFieldProvider = ({
|
|
|
51
85
|
};
|
|
52
86
|
const useFormFieldContext = () => useContext(FormFieldContext);
|
|
53
87
|
|
|
54
|
-
const StyledField = styled(Primitive.div, {
|
|
88
|
+
const StyledField = styled(Primitive.div, {
|
|
89
|
+
marginBottom: "$300"
|
|
90
|
+
});
|
|
55
91
|
|
|
56
92
|
const Root = React.forwardRef(
|
|
57
|
-
(
|
|
93
|
+
({ children, ...restProps }, forwardRef) => {
|
|
58
94
|
const {
|
|
59
95
|
id,
|
|
60
96
|
status,
|
|
@@ -65,6 +101,23 @@ const Root = React.forwardRef(
|
|
|
65
101
|
ariaDisabled,
|
|
66
102
|
readOnly
|
|
67
103
|
} = useFormFieldContext();
|
|
104
|
+
const label = React.Children.toArray(children).find(
|
|
105
|
+
isLabelComponent
|
|
106
|
+
);
|
|
107
|
+
const floating = booleanify(label == null ? void 0 : label.props.floating);
|
|
108
|
+
const formattedChildren = floating ? React.Children.map(React.Children.toArray(children), (child) => {
|
|
109
|
+
if (isLabelComponent(child)) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
if (isInputComponent(child)) {
|
|
113
|
+
const input = child;
|
|
114
|
+
return React.cloneElement(input, {
|
|
115
|
+
...input.props,
|
|
116
|
+
label
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return child;
|
|
120
|
+
}) : children;
|
|
68
121
|
return /* @__PURE__ */ jsx(
|
|
69
122
|
StyledField,
|
|
70
123
|
{
|
|
@@ -78,8 +131,9 @@ const Root = React.forwardRef(
|
|
|
78
131
|
"data-disabled": booleanishAttrValue(disabled),
|
|
79
132
|
"data-readonly": booleanishAttrValue(readOnly),
|
|
80
133
|
onFocus: () => setFocused == null ? void 0 : setFocused(true),
|
|
81
|
-
...
|
|
82
|
-
ref: forwardRef
|
|
134
|
+
...restProps,
|
|
135
|
+
ref: forwardRef,
|
|
136
|
+
children: formattedChildren
|
|
83
137
|
}
|
|
84
138
|
);
|
|
85
139
|
}
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sources":["../src/form.styled.tsx","../src/partials/label.styled.tsx","../src/partials/label.tsx","../src/hooks/use-form-field-context.tsx","../src/partials/field.styled.tsx","../src/partials/field.tsx","../src/partials/helper.styled.tsx","../src/partials/helper.tsx","../src/partials/message.styled.tsx","../src/partials/message.tsx","../src/partials/description.styled.tsx","../src/partials/description.tsx","../src/form.tsx"],"sourcesContent":["import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledForm = styled(Primitive.form, {\n all: 'unset',\n})\n\nexport type StyledFormProps = ComponentPropsWithRef<typeof StyledForm>\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledLabel = styled(Primitive.label, {\n display: 'block',\n fontSize: '$200',\n lineHeight: 1.5,\n marginBottom: '$100',\n})\n\nexport type StyledLabelProps = ComponentPropsWithRef<typeof StyledLabel>\n","import { StyledLabel } from './label.styled'\nimport type { StyledLabelProps } from './label.styled'\n\nexport interface LabelProps extends StyledLabelProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Label = StyledLabel\n","import React, { createContext, useContext, useState, useRef } from 'react'\nimport type { PropsWithChildren } from 'react'\nimport type { Booleanish } from '@mirohq/design-system-types'\nimport { useId } from '@mirohq/design-system-use-id'\n\nexport type Status =\n | 'valid'\n | 'invalid'\n | 'dirty'\n | 'pristine'\n | 'touched'\n | 'pending'\n\ninterface FormFieldProps {\n required?: boolean\n readOnly?: boolean\n disabled?: boolean\n ariaDisabled?: Booleanish\n status?: Status\n id: string\n}\n\ninterface FormFieldContextProps extends FormFieldProps {\n setStatus: React.Dispatch<React.SetStateAction<Status>>\n focused: boolean\n setFocused: React.Dispatch<React.SetStateAction<boolean>>\n helperId: string\n messageId: string\n descriptionId: string\n formElementRef: React.RefObject<HTMLInputElement>\n}\n\nexport type FormFieldProviderProps = Partial<FormFieldProps>\n\nconst FormFieldContext = createContext<FormFieldContextProps>({} as any)\n\nexport const FormFieldProvider = ({\n children,\n status: customStatus,\n id: customId,\n ...restProps\n}: PropsWithChildren<FormFieldProviderProps>): JSX.Element => {\n const formElementRef = useRef<HTMLInputElement>(null)\n const [status, setStatus] = useState<Status>(customStatus ?? 'pristine')\n const [focused, setFocused] = useState(false)\n\n const autoId = useId()\n const id = customId ?? autoId\n\n return (\n <FormFieldContext.Provider\n value={{\n ...restProps,\n id,\n formElementRef,\n messageId: `${id}-message`,\n helperId: `${id}-helper`,\n descriptionId: `${id}-description`,\n status,\n setStatus,\n focused,\n setFocused,\n }}\n >\n {children}\n </FormFieldContext.Provider>\n )\n}\n\nexport const useFormFieldContext = (): FormFieldContextProps =>\n useContext(FormFieldContext)\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledField = styled(Primitive.div, {})\n\nexport type StyledFieldProps = ComponentPropsWithRef<typeof StyledField>\n","import React from 'react'\nimport type { ElementRef } from 'react'\nimport { booleanishAttrValue } from '@mirohq/design-system-utils'\n\nimport {\n useFormFieldContext,\n FormFieldProvider,\n} from '../hooks/use-form-field-context'\nimport type { FormFieldProviderProps } from '../hooks/use-form-field-context'\nimport type { StyledFieldProps } from './field.styled'\nimport { StyledField } from './field.styled'\n\nexport interface FieldProps extends StyledFieldProps, FormFieldProviderProps {}\n\nconst Root = React.forwardRef<ElementRef<typeof StyledField>, FieldProps>(\n (props, forwardRef) => {\n const {\n id,\n status,\n required,\n focused,\n setFocused,\n disabled,\n ariaDisabled,\n readOnly,\n } = useFormFieldContext()\n\n return (\n <StyledField\n id={id}\n aria-disabled={ariaDisabled}\n aria-required={required}\n aria-invalid={status === 'invalid'}\n data-status={status}\n data-required={booleanishAttrValue(required)}\n data-focused={booleanishAttrValue(focused)}\n data-disabled={booleanishAttrValue(disabled)}\n data-readonly={booleanishAttrValue(readOnly)}\n onFocus={() => setFocused?.(true)}\n {...props}\n ref={forwardRef}\n />\n )\n }\n)\n\nexport const Field = React.forwardRef<\n ElementRef<typeof StyledField>,\n FieldProps\n>(\n (\n {\n id,\n required,\n status,\n readOnly,\n disabled,\n 'aria-disabled': ariaDisabled,\n ...restProps\n },\n forwardRef\n ) => (\n <FormFieldProvider\n required={required}\n status={status}\n readOnly={readOnly}\n disabled={disabled}\n aria-disabled={ariaDisabled}\n >\n <Root {...restProps} ref={forwardRef} />\n </FormFieldProvider>\n )\n)\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledHelper = styled(Primitive.p, {\n fontSize: '$150',\n lineHeight: 1.5,\n marginTop: '$50',\n})\n\nexport type StyledHelperProps = ComponentPropsWithRef<typeof StyledHelper>\n","import React from 'react'\nimport type { ElementRef } from 'react'\n\nimport { useFormFieldContext } from '../hooks/use-form-field-context'\nimport type { StyledHelperProps } from './helper.styled'\nimport { StyledHelper } from './helper.styled'\n\nexport interface HelperProps extends StyledHelperProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Helper = React.forwardRef<\n ElementRef<typeof StyledHelper>,\n HelperProps\n>((props, forwardRef) => {\n const { helperId } = useFormFieldContext()\n return <StyledHelper id={helperId} {...props} ref={forwardRef} />\n})\n","import type { ComponentPropsWithRef } from 'react'\nimport { styled } from '@mirohq/design-system-stitches'\n\nimport { Helper } from './helper'\n\nexport const StyledMessage = styled(Helper, {\n variants: {\n status: {\n valid: {\n color: '$text-success',\n },\n invalid: {\n color: '$text-danger',\n },\n dirty: {},\n pristine: {},\n touched: {},\n pending: {},\n },\n },\n})\n\nexport type StyledMessageProps = ComponentPropsWithRef<typeof StyledMessage>\n","import React from 'react'\nimport type { ElementRef } from 'react'\n\nimport { useFormFieldContext } from '../hooks/use-form-field-context'\nimport type { Status } from '../hooks/use-form-field-context'\nimport type { StyledMessageProps } from './message.styled'\nimport { StyledMessage } from './message.styled'\n\nexport interface MessageProps extends Omit<StyledMessageProps, 'status'> {\n status?: Status\n}\n\nexport const Message = React.forwardRef<\n ElementRef<typeof StyledMessage>,\n MessageProps\n>((props, forwardRef) => {\n const { messageId, status } = useFormFieldContext()\n return (\n <StyledMessage\n id={messageId}\n aria-live='polite'\n {...props}\n status={status}\n ref={forwardRef}\n />\n )\n})\n","import type { ComponentPropsWithRef } from 'react'\nimport { Primitive } from '@mirohq/design-system-primitive'\nimport { styled } from '@mirohq/design-system-stitches'\n\nexport const StyledDescription = styled(Primitive.p, {\n fontSize: '$175',\n lineHeight: 1.5,\n margin: 0,\n marginBottom: '$150',\n})\n\nexport type StyledDescriptionProps = ComponentPropsWithRef<\n typeof StyledDescription\n>\n","import React from 'react'\nimport type { ElementRef } from 'react'\n\nimport { useFormFieldContext } from '../hooks/use-form-field-context'\nimport type { StyledDescriptionProps } from './description.styled'\nimport { StyledDescription } from './description.styled'\n\nexport interface DescriptionProps extends StyledDescriptionProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Description = React.forwardRef<\n ElementRef<typeof StyledDescription>,\n DescriptionProps\n>((props, forwardRef) => {\n const { descriptionId } = useFormFieldContext()\n return <StyledDescription id={descriptionId} {...props} ref={forwardRef} />\n})\n","import type { ForwardRefExoticComponent } from 'react'\n\nimport { StyledForm } from './form.styled'\nimport type { StyledFormProps } from './form.styled'\nimport { Label } from './partials/label'\nimport { Field } from './partials/field'\nimport { Helper } from './partials/helper'\nimport { Message } from './partials/message'\nimport { Description } from './partials/description'\n\nexport interface FormProps extends StyledFormProps {\n /**\n * The content\n */\n children: React.ReactNode\n}\n\nexport const Form = StyledForm as any as ForwardRefExoticComponent<FormProps> &\n Partials\n\n// Partials\n// -----------------------------------------------------------------------------\n\nexport interface Partials {\n Label: typeof Label\n Field: typeof Field\n Helper: typeof Helper\n Message: typeof Message\n Description: typeof Description\n}\n\nForm.Label = Label\nForm.Field = Field\nForm.Helper = Helper\nForm.Message = Message\nForm.Description = Description\n"],"names":[],"mappings":";;;;;;;AAIa,MAAA,UAAA,GAAa,MAAO,CAAA,SAAA,CAAU,IAAM,EAAA;AAAA,EAC/C,GAAK,EAAA,OAAA;AACP,CAAC,CAAA;;ACFY,MAAA,WAAA,GAAc,MAAO,CAAA,SAAA,CAAU,KAAO,E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,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/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,Q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AkB,EAAA,EAAA,EAAA,EAAI,eAAgB,GAAG,KAAA,EAAO,KAAK,UAAY,EAAA,CAAA,CAAA;AAC3E,CAAC,CAAA;;ACHM,MAAM,IAAO,GAAA,WAAA;AAcpB,IAAA,CAAK,KAAQ,GAAA,KAAA,CAAA;AACb,IAAA,CAAK,KAAQ,GAAA,KAAA,CAAA;AACb,IAAA,CAAK,MAAS,GAAA,MAAA,CAAA;AACd,IAAA,CAAK,OAAU,GAAA,OAAA,CAAA;AACf,IAAA,CAAK,WAAc,GAAA,WAAA;;;;"}
|
package/dist/types.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ import * as _mirohq_design_system_stitches from '@mirohq/design-system-stitches'
|
|
|
4
4
|
import * as _stitches_react_types_styled_component from '@stitches/react/types/styled-component';
|
|
5
5
|
import * as _stitches_react_types_css_util from '@stitches/react/types/css-util';
|
|
6
6
|
import * as _mirohq_design_system_primitive from '@mirohq/design-system-primitive';
|
|
7
|
-
import * as _mirohq_design_system_components_primitive from '@mirohq/design-system-components/primitive';
|
|
8
7
|
import { Booleanish } from '@mirohq/design-system-types';
|
|
9
8
|
|
|
10
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<{}, {
|
|
@@ -498,7 +497,7 @@ declare const StyledForm: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_desi
|
|
|
498
497
|
}>>>, never> & _stitches_react_types_styled_component.TransformProps<{}, {}> & _mirohq_design_system_stitches.CustomStylesProps, "ref"> & react.RefAttributes<HTMLFormElement>> & _mirohq_design_system_stitches.StitchesInternals<react.ForwardRefExoticComponent<_mirohq_design_system_primitive.PrimitiveProps<"form">>, {}, {}>;
|
|
499
498
|
declare type StyledFormProps = ComponentPropsWithRef<typeof StyledForm>;
|
|
500
499
|
|
|
501
|
-
declare const
|
|
500
|
+
declare const StyledLabel: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_design_system_stitches.StyledComponentProps<_stitches_react_types_styled_component.StyledComponent<react.ForwardRefExoticComponent<_mirohq_design_system_primitive.PrimitiveProps<"label">>, {}, {}, _stitches_react_types_css_util.CSS<{}, {
|
|
502
501
|
'border-widths': {
|
|
503
502
|
readonly none: 0;
|
|
504
503
|
readonly sm: "1px";
|
|
@@ -986,7 +985,26 @@ declare const Label: react.ForwardRefExoticComponent<Omit<Omit<_mirohq_design_sy
|
|
|
986
985
|
_hover: (css: _stitches_react_types_css_util.CSSProperties) => {
|
|
987
986
|
'&:hover, &[data-hovered]': _stitches_react_types_css_util.CSSProperties;
|
|
988
987
|
};
|
|
989
|
-
}>>>,
|
|
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
|
+
}, {}>;
|
|
993
|
+
declare type StyledLabelProps = ComponentPropsWithRef<typeof StyledLabel>;
|
|
994
|
+
|
|
995
|
+
declare const labelSymbol: unique symbol;
|
|
996
|
+
|
|
997
|
+
interface LabelProps extends Omit<StyledLabelProps, 'placeholder'> {
|
|
998
|
+
/**
|
|
999
|
+
* The content
|
|
1000
|
+
*/
|
|
1001
|
+
children: react__default.ReactNode;
|
|
1002
|
+
floating?: boolean;
|
|
1003
|
+
required?: boolean;
|
|
1004
|
+
}
|
|
1005
|
+
declare const Label: react__default.ForwardRefExoticComponent<LabelProps> & {
|
|
1006
|
+
[labelSymbol]?: boolean | undefined;
|
|
1007
|
+
};
|
|
990
1008
|
|
|
991
1009
|
declare type Status = 'valid' | 'invalid' | 'dirty' | 'pristine' | 'touched' | 'pending';
|
|
992
1010
|
interface FormFieldProps {
|
|
@@ -3007,4 +3025,4 @@ interface Partials {
|
|
|
3007
3025
|
Description: typeof Description;
|
|
3008
3026
|
}
|
|
3009
3027
|
|
|
3010
|
-
export { Form, FormProps };
|
|
3028
|
+
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.
|
|
3
|
+
"version": "0.1.0-forms.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Miro",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -26,10 +26,11 @@
|
|
|
26
26
|
"react": "^16.14 || ^17 || ^18"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
+
"@mirohq/design-system-base-input": "^0.1.0-forms.1",
|
|
29
30
|
"@mirohq/design-system-primitive": "^1.1.2-forms.0",
|
|
30
|
-
"@mirohq/design-system-
|
|
31
|
+
"@mirohq/design-system-use-id": "^0.1.1-forms.0",
|
|
31
32
|
"@mirohq/design-system-utils": "^0.15.0-forms.0",
|
|
32
|
-
"@mirohq/design-system-
|
|
33
|
+
"@mirohq/design-system-stitches": "^2.6.0"
|
|
33
34
|
},
|
|
34
35
|
"scripts": {
|
|
35
36
|
"build": "rollup -c ../../../rollup.config.js",
|