react-better-html 1.1.17 → 1.1.19
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/components/Dropdown.d.ts +1 -1
- package/dist/components/Dropdown.js +2 -3
- package/dist/components/Form.d.ts +18 -0
- package/dist/components/Form.js +29 -0
- package/dist/components/InputField.d.ts +2 -2
- package/dist/components/InputField.js +2 -2
- package/dist/constants/css.d.ts +1 -0
- package/dist/constants/css.js +1291 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +4 -1
- package/dist/utils/hooks.d.ts +19 -1
- package/dist/utils/hooks.js +86 -7
- package/package.json +1 -1
|
@@ -88,14 +88,13 @@ const DropdownComponent = (0, react_1.forwardRef)(function Dropdown({ label, err
|
|
|
88
88
|
}, [onChange, controlledValue]);
|
|
89
89
|
const onClickClearButton = (0, react_1.useCallback)((event) => {
|
|
90
90
|
event.stopPropagation();
|
|
91
|
-
|
|
92
|
-
setInternalValue(undefined);
|
|
91
|
+
setInternalValue(undefined);
|
|
93
92
|
onChange?.(undefined);
|
|
94
93
|
setIsOpen.setFalse();
|
|
95
94
|
inputRef.current?.blur();
|
|
96
95
|
setSearchQuery("");
|
|
97
96
|
setFocusedOptionIndex(undefined);
|
|
98
|
-
}, [
|
|
97
|
+
}, [onChange]);
|
|
99
98
|
const onChangeValue = (0, react_1.useCallback)((newValue) => {
|
|
100
99
|
setSearchQuery(newValue);
|
|
101
100
|
if (withDebounce)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ComponentMarginProps } from "../types/components";
|
|
2
|
+
import { LoaderName } from "../types/loader";
|
|
3
|
+
import { AnyOtherString } from "../types/app";
|
|
4
|
+
type FormType = "default" | "submit" | "save" | "create" | "delete" | "update" | "edit";
|
|
5
|
+
type FormProps = {
|
|
6
|
+
/** @default "default" */
|
|
7
|
+
type?: FormType;
|
|
8
|
+
/** @default "right" */
|
|
9
|
+
actionButtonsLocation?: "left" | "center" | "right";
|
|
10
|
+
actionButtonLoaderName?: LoaderName | AnyOtherString;
|
|
11
|
+
gap?: React.CSSProperties["gap"];
|
|
12
|
+
onClickCancel?: () => void;
|
|
13
|
+
onSubmit?: (value: React.FormEvent<HTMLFormElement>) => void;
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
} & ComponentMarginProps;
|
|
16
|
+
declare function Form({ type, actionButtonsLocation, actionButtonLoaderName, gap, onClickCancel, onSubmit, children, ...props }: FormProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
declare const _default: import("react").MemoExoticComponent<typeof Form>;
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const Div_1 = __importDefault(require("./Div"));
|
|
9
|
+
const Button_1 = __importDefault(require("./Button"));
|
|
10
|
+
const BetterHtmlProvider_1 = require("./BetterHtmlProvider");
|
|
11
|
+
const formTypesText = {
|
|
12
|
+
default: "Default",
|
|
13
|
+
submit: "Submit",
|
|
14
|
+
save: "Save",
|
|
15
|
+
create: "Create",
|
|
16
|
+
delete: "Delete",
|
|
17
|
+
update: "Update",
|
|
18
|
+
edit: "Edit",
|
|
19
|
+
};
|
|
20
|
+
function Form({ type = "default", actionButtonsLocation = "right", actionButtonLoaderName, gap, onClickCancel, onSubmit, children, ...props }) {
|
|
21
|
+
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
22
|
+
const SubmitButtonTag = type === "delete" ? Button_1.default.destructive : Button_1.default;
|
|
23
|
+
return ((0, jsx_runtime_1.jsx)(Div_1.default, { ...props, children: (0, jsx_runtime_1.jsxs)("form", { onSubmit: onSubmit, children: [gap !== undefined ? (0, jsx_runtime_1.jsx)(Div_1.default.column, { gap: gap, children: children }) : children, type !== "default" && ((0, jsx_runtime_1.jsxs)(Div_1.default.row, { alignItems: "center", justifyContent: actionButtonsLocation === "left"
|
|
24
|
+
? "flex-start"
|
|
25
|
+
: actionButtonsLocation === "center"
|
|
26
|
+
? "center"
|
|
27
|
+
: "flex-end", gap: theme.styles.gap, marginTop: theme.styles.space, children: [onClickCancel && (0, jsx_runtime_1.jsx)(Button_1.default.secondary, { text: "Cancel", onClick: onClickCancel }), (0, jsx_runtime_1.jsx)(SubmitButtonTag, { text: formTypesText[type], loaderName: actionButtonLoaderName, isSubmit: true })] }))] }) }));
|
|
28
|
+
}
|
|
29
|
+
exports.default = (0, react_1.memo)(Form);
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { ComponentHoverStyle, ComponentPropWithRef, ComponentStyle } from "../types/components";
|
|
3
3
|
import { AnyOtherString, OmitProps } from "../types/app";
|
|
4
4
|
import { IconName } from "../types/icon";
|
|
5
|
-
type InputFieldProps = {
|
|
5
|
+
export type InputFieldProps = {
|
|
6
6
|
label?: string;
|
|
7
7
|
errorText?: string;
|
|
8
8
|
infoText?: string;
|
|
@@ -14,7 +14,7 @@ type InputFieldProps = {
|
|
|
14
14
|
debounceDelay?: number;
|
|
15
15
|
onChangeValue?: (value: string) => void;
|
|
16
16
|
onClickRightIcon?: () => void;
|
|
17
|
-
} & OmitProps<React.ComponentProps<"input">, "style"> & ComponentStyle & ComponentHoverStyle;
|
|
17
|
+
} & OmitProps<React.ComponentProps<"input">, "style" | "ref"> & ComponentStyle & ComponentHoverStyle;
|
|
18
18
|
type InputFieldComponentType = {
|
|
19
19
|
(props: ComponentPropWithRef<HTMLInputElement, InputFieldProps>): React.ReactElement;
|
|
20
20
|
multiline: (props: ComponentPropWithRef<HTMLTextAreaElement, TextareaFieldProps>) => React.ReactElement;
|
|
@@ -114,7 +114,7 @@ const InputFieldComponent = (0, react_1.forwardRef)(function InputField({ label,
|
|
|
114
114
|
return;
|
|
115
115
|
onChangeValue?.(debouncedValue);
|
|
116
116
|
}, [withDebounce, onChangeValue, debouncedValue]);
|
|
117
|
-
return ((0, jsx_runtime_1.jsxs)(Div_1.default.column, { width: "100%", gap: theme.styles.gap / 2, ...styledComponentStylesWithExcluded, children: [label && ((0, jsx_runtime_1.jsxs)(Text_1.default, { as: "label", height: 16, fontSize: 14, color: errorText ? theme.colors.error : theme.colors.textSecondary, children: [label, required && ((0, jsx_runtime_1.jsxs)(Text_1.default, { as: "span", fontSize: 16, color: theme.colors.error, children: [" ", "*"] }))] })), (0, jsx_runtime_1.jsxs)(Div_1.default, { position: "relative", width: "100%", children: [leftIcon && ((0, jsx_runtime_1.jsx)(Icon_1.default, { name: leftIcon, position: "absolute", top: 46 / 2, left: theme.styles.space + 1, transform: "translateY(-50%)", pointerEvents: "none", zIndex: 1002 })), (0, jsx_runtime_1.jsx)(InputElement, { theme: theme, withLeftIcon: leftIcon !== undefined, withRightIcon: rightIcon !== undefined, onChange: onChangeElement, ...styledComponentStylesWithoutExcluded, ...dataProps, ...ariaProps, ...restProps, ref: ref }), rightIcon ? (onClickRightIcon ? ((0, jsx_runtime_1.jsx)(Button_1.default.icon, { icon: rightIcon, position: "absolute", top: 46 / 2, right: theme.styles.space + 1 - theme.styles.space / 2, transform: "translateY(-50%)", onClick: onClickRightIcon })) : ((0, jsx_runtime_1.jsx)(Icon_1.default, { name: rightIcon, position: "absolute", top: 46 / 2, right: theme.styles.space + 1, transform: "translateY(-50%)", pointerEvents: "none" }))) : undefined, insideInputFieldComponent] }), (errorText || infoText) && ((0, jsx_runtime_1.jsx)(Text_1.default, { as: "span", display: "block", fontSize: 14, color: errorText ? theme.colors.error : theme.colors.textSecondary, children: errorText || infoText }))] }));
|
|
117
|
+
return ((0, jsx_runtime_1.jsxs)(Div_1.default.column, { width: "100%", gap: theme.styles.gap / 2, ...styledComponentStylesWithExcluded, children: [label && ((0, jsx_runtime_1.jsxs)(Text_1.default, { as: "label", height: 16, fontSize: 14, color: errorText ? theme.colors.error : theme.colors.textSecondary, children: [label, required && ((0, jsx_runtime_1.jsxs)(Text_1.default, { as: "span", fontSize: 16, color: theme.colors.error, children: [" ", "*"] }))] })), (0, jsx_runtime_1.jsxs)(Div_1.default, { position: "relative", width: "100%", children: [leftIcon && ((0, jsx_runtime_1.jsx)(Icon_1.default, { name: leftIcon, position: "absolute", top: 46 / 2, left: theme.styles.space + 1, transform: "translateY(-50%)", pointerEvents: "none", zIndex: 1002 })), (0, jsx_runtime_1.jsx)(InputElement, { theme: theme, withLeftIcon: leftIcon !== undefined, withRightIcon: rightIcon !== undefined, required: required, onChange: onChangeElement, ...styledComponentStylesWithoutExcluded, ...dataProps, ...ariaProps, ...restProps, ref: ref }), rightIcon ? (onClickRightIcon ? ((0, jsx_runtime_1.jsx)(Button_1.default.icon, { icon: rightIcon, position: "absolute", top: 46 / 2, right: theme.styles.space + 1 - theme.styles.space / 2, transform: "translateY(-50%)", onClick: onClickRightIcon })) : ((0, jsx_runtime_1.jsx)(Icon_1.default, { name: rightIcon, position: "absolute", top: 46 / 2, right: theme.styles.space + 1, transform: "translateY(-50%)", pointerEvents: "none" }))) : undefined, insideInputFieldComponent] }), (errorText || infoText) && ((0, jsx_runtime_1.jsx)(Text_1.default, { as: "span", display: "block", fontSize: 14, color: errorText ? theme.colors.error : theme.colors.textSecondary, children: errorText || infoText }))] }));
|
|
118
118
|
});
|
|
119
119
|
InputFieldComponent.multiline = (0, react_1.forwardRef)(function Textarea({ label, errorText, infoText, onChange, onChangeValue, required, ...props }, ref) {
|
|
120
120
|
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
@@ -126,7 +126,7 @@ InputFieldComponent.multiline = (0, react_1.forwardRef)(function Textarea({ labe
|
|
|
126
126
|
onChange?.(event);
|
|
127
127
|
onChangeValue?.(event.target.value);
|
|
128
128
|
}, [onChange, onChangeValue]);
|
|
129
|
-
return ((0, jsx_runtime_1.jsxs)(Div_1.default.column, { gap: theme.styles.gap / 2, children: [label && ((0, jsx_runtime_1.jsxs)(Text_1.default, { as: "label", fontSize: 14, color: errorText ? theme.colors.error : theme.colors.textSecondary, children: [label, required && ((0, jsx_runtime_1.jsxs)(Text_1.default, { as: "span", fontSize: 16, color: theme.colors.error, children: [" ", "*"] }))] })), (0, jsx_runtime_1.jsx)(TextareaElement, { theme: theme, onChange: onChangeElement, ...styledComponentStyles, ...dataProps, ...ariaProps, ...restProps, ref: ref }), (errorText || infoText) && ((0, jsx_runtime_1.jsx)(Text_1.default, { as: "span", display: "block", marginTop: theme.styles.gap / 2, color: errorText ? theme.colors.error : theme.colors.textSecondary, fontSize: 14, children: errorText || infoText }))] }));
|
|
129
|
+
return ((0, jsx_runtime_1.jsxs)(Div_1.default.column, { gap: theme.styles.gap / 2, children: [label && ((0, jsx_runtime_1.jsxs)(Text_1.default, { as: "label", fontSize: 14, color: errorText ? theme.colors.error : theme.colors.textSecondary, children: [label, required && ((0, jsx_runtime_1.jsxs)(Text_1.default, { as: "span", fontSize: 16, color: theme.colors.error, children: [" ", "*"] }))] })), (0, jsx_runtime_1.jsx)(TextareaElement, { theme: theme, required: required, onChange: onChangeElement, ...styledComponentStyles, ...dataProps, ...ariaProps, ...restProps, ref: ref }), (errorText || infoText) && ((0, jsx_runtime_1.jsx)(Text_1.default, { as: "span", display: "block", marginTop: theme.styles.gap / 2, color: errorText ? theme.colors.error : theme.colors.textSecondary, fontSize: 14, children: errorText || infoText }))] }));
|
|
130
130
|
});
|
|
131
131
|
InputFieldComponent.email = (0, react_1.forwardRef)(function Email({ ...props }, ref) {
|
|
132
132
|
return ((0, jsx_runtime_1.jsx)(InputFieldComponent, { type: "email", placeholder: "your@email.here", autoComplete: "email", autoCorrect: "off", autoCapitalize: "off", ref: ref, ...props }));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const cssProps: Record<string, boolean>;
|