react-better-html 1.1.22 → 1.1.24

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.
@@ -1,19 +1,19 @@
1
1
  import { ComponentMarginProps } from "../types/components";
2
2
  import { LoaderName } from "../types/loader";
3
3
  import { AnyOtherString } from "../types/app";
4
- type FormType = "default" | "submit" | "save" | "create" | "delete" | "update" | "edit";
5
4
  type FormProps = {
6
- /** @default "default" */
7
- type?: FormType;
5
+ submitButtonText?: string;
6
+ submitButtonLoaderName?: LoaderName | AnyOtherString;
7
+ submitButtonId?: string;
8
8
  /** @default "right" */
9
9
  actionButtonsLocation?: "left" | "center" | "right";
10
- actionButtonLoaderName?: LoaderName | AnyOtherString;
11
10
  gap?: React.CSSProperties["gap"];
12
11
  isSubmitting?: boolean;
12
+ isDestructive?: boolean;
13
13
  onClickCancel?: () => void;
14
14
  onSubmit?: (value: React.FormEvent<HTMLFormElement>) => void;
15
15
  children?: React.ReactNode;
16
16
  } & ComponentMarginProps;
17
- declare function Form({ type, actionButtonsLocation, actionButtonLoaderName, gap, isSubmitting, onClickCancel, onSubmit, children, ...props }: FormProps): import("react/jsx-runtime").JSX.Element;
17
+ declare function Form({ submitButtonText, submitButtonLoaderName, submitButtonId, actionButtonsLocation, gap, isSubmitting, isDestructive, onClickCancel, onSubmit, children, ...props }: FormProps): import("react/jsx-runtime").JSX.Element;
18
18
  declare const _default: import("react").MemoExoticComponent<typeof Form>;
19
19
  export default _default;
@@ -8,22 +8,13 @@ const react_1 = require("react");
8
8
  const Div_1 = __importDefault(require("./Div"));
9
9
  const Button_1 = __importDefault(require("./Button"));
10
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, isSubmitting, onClickCancel, onSubmit, children, ...props }) {
11
+ function Form({ submitButtonText, submitButtonLoaderName, submitButtonId, actionButtonsLocation = "right", gap, isSubmitting, isDestructive, onClickCancel, onSubmit, children, ...props }) {
21
12
  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"
13
+ const SubmitButtonTag = isDestructive ? Button_1.default.destructive : Button_1.default;
14
+ 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, submitButtonText && ((0, jsx_runtime_1.jsxs)(Div_1.default.row, { alignItems: "center", justifyContent: actionButtonsLocation === "left"
24
15
  ? "flex-start"
25
16
  : actionButtonsLocation === "center"
26
17
  ? "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], isLoading: isSubmitting, loaderName: actionButtonLoaderName, isSubmit: true })] }))] }) }));
18
+ : "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: submitButtonText, isLoading: isSubmitting, loaderName: submitButtonLoaderName, id: submitButtonId, isSubmit: true })] }))] }) }));
28
19
  }
29
20
  exports.default = (0, react_1.memo)(Form);
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const jsx_runtime_1 = require("react/jsx-runtime");
7
7
  const react_1 = require("react");
8
8
  const styled_components_1 = __importDefault(require("styled-components"));
9
+ const hooks_1 = require("../utils/hooks");
9
10
  const Div_1 = __importDefault(require("./Div"));
10
11
  const Button_1 = __importDefault(require("./Button"));
11
12
  const Text_1 = __importDefault(require("./Text"));
12
13
  const Divider_1 = __importDefault(require("./Divider"));
13
14
  const BetterHtmlProvider_1 = require("./BetterHtmlProvider");
14
- const hooks_1 = require("../utils/hooks");
15
15
  const DialogStylesElement = styled_components_1.default.dialog.withConfig({
16
16
  shouldForwardProp: (prop) => !["theme", "opacity"].includes(prop),
17
17
  }) `
@@ -86,7 +86,7 @@ const ModalComponent = (0, react_1.forwardRef)(function Modal({ maxWidth, title,
86
86
  isOpened,
87
87
  };
88
88
  }, [onClickOpen, onClickClose, isOpened]);
89
- return ((0, jsx_runtime_1.jsx)(DialogStylesElement, { theme: theme, opacity: !isOpened ? 0 : 1, onClose: onClickClose, ref: dialogRef, children: isOpenedLate ? ((0, jsx_runtime_1.jsx)(Div_1.default.column, { position: "relative", width: "100%", maxWidth: maxWidth ?? app.contentMaxWidth / 1.3, minHeight: `calc(100% - ${theme.styles.space * 2}px)`, alignItems: "center", justifyContent: "center", marginBlock: theme.styles.space, marginInline: "auto", transform: `translateY(${theme.styles.space}px)`, transition: theme.styles.transition, animation: isOpened ? "fadeInAnimation 0.2s ease forwards" : "fadeOutAnimation 0.2s ease forwards", children: (0, jsx_runtime_1.jsxs)(Div_1.default, { position: "relative", width: "100%", minHeight: 32 + theme.styles.space * 2, backgroundColor: theme.colors.backgroundBase, borderRadius: theme.styles.borderRadius * 2, paddingInline: !title ? theme.styles.space : undefined, paddingBlock: !title ? theme.styles.gap : undefined, overflow: overflow, children: [title ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(Div_1.default.row, { alignItems: "center", gap: theme.styles.gap, backgroundColor: headerBackgroundColor, borderTopLeftRadius: theme.styles.borderRadius * 2, borderTopRightRadius: theme.styles.borderRadius * 2, paddingInline: theme.styles.space, paddingBlock: theme.styles.gap, children: [(0, jsx_runtime_1.jsxs)(Div_1.default.column, { flex: 1, gap: theme.styles.gap / 2, children: [(0, jsx_runtime_1.jsx)(Text_1.default, { as: "h1", color: titleColor ?? theme.colors.textPrimary, children: title }), description && ((0, jsx_runtime_1.jsx)(Text_1.default, { color: descriptionColor ?? theme.colors.textSecondary, children: description }))] }), (0, jsx_runtime_1.jsx)(Button_1.default.icon, { icon: "XMark", marginTop: 1, iconColor: titleColor, onClick: onClickClose })] }), (0, jsx_runtime_1.jsx)(Divider_1.default.horizontal, {})] })) : ((0, jsx_runtime_1.jsx)(Div_1.default, { position: "absolute", top: theme.styles.space, right: theme.styles.space, children: (0, jsx_runtime_1.jsx)(Button_1.default.icon, { icon: "XMark", onClick: onClickClose }) })), (0, jsx_runtime_1.jsx)(Div_1.default, { paddingInline: title ? theme.styles.space : undefined, paddingBlock: title ? theme.styles.gap : undefined, children: children })] }) })) : undefined }));
89
+ return ((0, jsx_runtime_1.jsx)(DialogStylesElement, { theme: theme, opacity: !isOpened ? 0 : 1, onClose: onClickClose, ref: dialogRef, children: isOpenedLate ? ((0, jsx_runtime_1.jsx)(Div_1.default.column, { position: "relative", width: "100%", maxWidth: maxWidth ?? app.contentMaxWidth / 1.3, minHeight: `calc(100% - ${theme.styles.space * 2}px)`, alignItems: "center", justifyContent: "center", marginBlock: theme.styles.space, marginInline: "auto", transform: `translateY(${theme.styles.space}px)`, transition: theme.styles.transition, animation: isOpened ? "fadeInAnimation 0.2s ease forwards" : "fadeOutAnimation 0.2s ease forwards", children: (0, jsx_runtime_1.jsxs)(Div_1.default, { position: "relative", width: "100%", minHeight: 32 + theme.styles.space * 2, backgroundColor: theme.colors.backgroundBase, borderRadius: theme.styles.borderRadius * 2, paddingInline: !title ? theme.styles.space + theme.styles.gap : undefined, paddingBlock: !title ? theme.styles.space : undefined, overflow: overflow, children: [title ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(Div_1.default.row, { alignItems: "center", gap: theme.styles.gap, backgroundColor: headerBackgroundColor, borderTopLeftRadius: theme.styles.borderRadius * 2, borderTopRightRadius: theme.styles.borderRadius * 2, paddingInline: theme.styles.space + theme.styles.gap, paddingBlock: theme.styles.space, children: [(0, jsx_runtime_1.jsxs)(Div_1.default.column, { flex: 1, gap: theme.styles.gap / 2, children: [(0, jsx_runtime_1.jsx)(Text_1.default, { as: "h1", color: titleColor ?? theme.colors.textPrimary, children: title }), description && ((0, jsx_runtime_1.jsx)(Text_1.default, { color: descriptionColor ?? theme.colors.textSecondary, children: description }))] }), (0, jsx_runtime_1.jsx)(Button_1.default.icon, { icon: "XMark", marginTop: 1, iconColor: titleColor, onClick: onClickClose })] }), (0, jsx_runtime_1.jsx)(Divider_1.default.horizontal, {})] })) : ((0, jsx_runtime_1.jsx)(Div_1.default, { position: "absolute", top: theme.styles.space, right: theme.styles.space, children: (0, jsx_runtime_1.jsx)(Button_1.default.icon, { icon: "XMark", onClick: onClickClose }) })), (0, jsx_runtime_1.jsx)(Div_1.default, { paddingInline: title ? theme.styles.space + theme.styles.gap : undefined, paddingBlock: title ? theme.styles.space : undefined, children: children })] }) })) : undefined }));
90
90
  });
91
91
  ModalComponent.confirmation = (0, react_1.forwardRef)(function Confirmation({ onConfirm, onCancel, ...props }, ref) {
92
92
  const theme = (0, BetterHtmlProvider_1.useTheme)();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-better-html",
3
- "version": "1.1.22",
3
+ "version": "1.1.24",
4
4
  "description": "A component library for react that is as close to plane html as possible",
5
5
  "main": "dist/index.js",
6
6
  "files": [