@yamada-ui/form-control
Advanced tools
Comparing version 0.0.0-dev-20230625235915 to 0.0.0-dev-20230701130255
@@ -8,11 +8,45 @@ import * as react from 'react'; | ||
type FormControlOptions = { | ||
/** | ||
* If `true`, the form control will be required. | ||
* | ||
* @default false | ||
*/ | ||
isRequired?: boolean; | ||
/** | ||
* If `true`, the form control will be disabled. | ||
* | ||
* @default false | ||
*/ | ||
isDisabled?: boolean; | ||
/** | ||
* If `true`, the form control will be invalid. | ||
* | ||
* @default false | ||
*/ | ||
isInvalid?: boolean; | ||
/** | ||
* If `true`, the form control will be readonly. | ||
* | ||
* @default false | ||
*/ | ||
isReadOnly?: boolean; | ||
}; | ||
type FormControlAdditionalOptions = LabelOptions & { | ||
/** | ||
* If `true`, switch between helper message and error message using isInvalid. | ||
* | ||
* @default true | ||
*/ | ||
isReplace?: boolean; | ||
/** | ||
* The form control label to use. | ||
*/ | ||
label?: ReactNode; | ||
/** | ||
* The form control helper message to use. | ||
*/ | ||
helperMessage?: ReactNode; | ||
/** | ||
* The form control error message to use. | ||
*/ | ||
errorMessage?: ReactNode; | ||
@@ -22,3 +56,3 @@ }; | ||
declare const FormControl: _yamada_ui_core.Component<"div", FormControlProps>; | ||
type UseFormControl = FormControlOptions & { | ||
declare const useFormControl: (props: FormControlOptions & { | ||
id?: string; | ||
@@ -28,4 +62,3 @@ disabled?: boolean; | ||
required?: boolean; | ||
}; | ||
declare const useFormControl: (props: UseFormControl) => { | ||
}) => { | ||
id: string | undefined; | ||
@@ -83,7 +116,7 @@ isDisabled: boolean | undefined; | ||
declare const Label: _yamada_ui_core.Component<"label", LabelProps>; | ||
type HelpTextProps = HTMLUIProps<'div'>; | ||
declare const HelperMessage: _yamada_ui_core.Component<"div", HelpTextProps>; | ||
type HelperMessageProps = HTMLUIProps<'div'>; | ||
declare const HelperMessage: _yamada_ui_core.Component<"div", HelperMessageProps>; | ||
type ErrorMessageProps = HTMLUIProps<'div'>; | ||
declare const ErrorMessage: _yamada_ui_core.Component<"div", ErrorMessageProps>; | ||
export { ErrorMessage, ErrorMessageProps, FormControl, FormControlOptions, FormControlProps, HelpTextProps, HelperMessage, Label, LabelProps, UseFormControl, UseFormControlProps, formControlProperties, useFormControl, useFormControlProps }; | ||
export { ErrorMessage, ErrorMessageProps, FormControl, FormControlOptions, FormControlProps, HelperMessage, HelperMessageProps, Label, LabelProps, UseFormControlProps, formControlProperties, useFormControl, useFormControlProps }; |
@@ -238,11 +238,13 @@ "use strict"; | ||
); | ||
var HelperMessage = (0, import_core.forwardRef)(({ className, ...rest }, ref) => { | ||
var _a, _b; | ||
const { isInvalid, isReplace } = (_a = useFormControlContext()) != null ? _a : {}; | ||
const styles = (_b = useFormControlStyles()) != null ? _b : {}; | ||
if (isReplace && isInvalid) | ||
return null; | ||
const css = { ...styles.helperMessage }; | ||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.ui.div, { ref, className: (0, import_utils.cx)("ui-form-helper-message", className), __css: css, ...rest }); | ||
}); | ||
var HelperMessage = (0, import_core.forwardRef)( | ||
({ className, ...rest }, ref) => { | ||
var _a, _b; | ||
const { isInvalid, isReplace } = (_a = useFormControlContext()) != null ? _a : {}; | ||
const styles = (_b = useFormControlStyles()) != null ? _b : {}; | ||
if (isReplace && isInvalid) | ||
return null; | ||
const css = { ...styles.helperMessage }; | ||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.ui.div, { ref, className: (0, import_utils.cx)("ui-form-helper-message", className), __css: css, ...rest }); | ||
} | ||
); | ||
var ErrorMessage = (0, import_core.forwardRef)(({ className, ...rest }, ref) => { | ||
@@ -249,0 +251,0 @@ var _a, _b; |
@@ -1,4 +0,4 @@ | ||
export { ErrorMessage, ErrorMessageProps, FormControl, FormControlOptions, FormControlProps, HelpTextProps, HelperMessage, Label, LabelProps, UseFormControl, UseFormControlProps, formControlProperties, useFormControl, useFormControlProps } from './form-control.js'; | ||
export { ErrorMessage, ErrorMessageProps, FormControl, FormControlOptions, FormControlProps, HelperMessage, HelperMessageProps, Label, LabelProps, UseFormControlProps, formControlProperties, useFormControl, useFormControlProps } from './form-control.js'; | ||
import 'react'; | ||
import '@yamada-ui/core'; | ||
import '@yamada-ui/utils'; |
@@ -240,11 +240,13 @@ "use strict"; | ||
); | ||
var HelperMessage = (0, import_core.forwardRef)(({ className, ...rest }, ref) => { | ||
var _a, _b; | ||
const { isInvalid, isReplace } = (_a = useFormControlContext()) != null ? _a : {}; | ||
const styles = (_b = useFormControlStyles()) != null ? _b : {}; | ||
if (isReplace && isInvalid) | ||
return null; | ||
const css = { ...styles.helperMessage }; | ||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.ui.div, { ref, className: (0, import_utils.cx)("ui-form-helper-message", className), __css: css, ...rest }); | ||
}); | ||
var HelperMessage = (0, import_core.forwardRef)( | ||
({ className, ...rest }, ref) => { | ||
var _a, _b; | ||
const { isInvalid, isReplace } = (_a = useFormControlContext()) != null ? _a : {}; | ||
const styles = (_b = useFormControlStyles()) != null ? _b : {}; | ||
if (isReplace && isInvalid) | ||
return null; | ||
const css = { ...styles.helperMessage }; | ||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.ui.div, { ref, className: (0, import_utils.cx)("ui-form-helper-message", className), __css: css, ...rest }); | ||
} | ||
); | ||
var ErrorMessage = (0, import_core.forwardRef)(({ className, ...rest }, ref) => { | ||
@@ -251,0 +253,0 @@ var _a, _b; |
{ | ||
"name": "@yamada-ui/form-control", | ||
"version": "0.0.0-dev-20230625235915", | ||
"version": "0.0.0-dev-20230701130255", | ||
"description": "Yamada UI form control component", | ||
@@ -38,3 +38,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@yamada-ui/core": "0.0.0-dev-20230625235915", | ||
"@yamada-ui/core": "0.0.0-dev-20230701130255", | ||
"@yamada-ui/utils": "0.1.1" | ||
@@ -74,4 +74,4 @@ }, | ||
"typecheck": "tsc --noEmit", | ||
"gen:types": "tsx ../../../scripts/generate-types" | ||
"gen:docs": "tsx ../../../scripts/generate-docs" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35711
965
+ Added@yamada-ui/core@0.0.0-dev-20230701130255(transitive)
+ Added@yamada-ui/portal@0.0.0-dev-20230701130255(transitive)
- Removed@yamada-ui/core@0.0.0-dev-20230625235915(transitive)
- Removed@yamada-ui/portal@0.1.2(transitive)