react-better-html 1.1.51 → 1.1.53
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,6 +1,7 @@
|
|
|
1
1
|
import { IconName } from "../types/icon";
|
|
2
2
|
import { AnyOtherString } from "../types/app";
|
|
3
3
|
import { ComponentMarginProps, ComponentPropWithRef } from "../types/components";
|
|
4
|
+
import { LoaderName } from "../types/loader";
|
|
4
5
|
export type FormRowProps = {
|
|
5
6
|
oneItemOnly?: boolean;
|
|
6
7
|
gap?: React.CSSProperties["gap"];
|
|
@@ -12,6 +13,10 @@ type FormRowComponentType = {
|
|
|
12
13
|
icon?: IconName | AnyOtherString;
|
|
13
14
|
title?: string;
|
|
14
15
|
description?: string;
|
|
16
|
+
withActions?: boolean;
|
|
17
|
+
saveButtonLoaderName?: LoaderName | AnyOtherString;
|
|
18
|
+
onClickSave?: () => void;
|
|
19
|
+
onClickReset?: () => void;
|
|
15
20
|
}>) => React.ReactElement;
|
|
16
21
|
};
|
|
17
22
|
declare const FormRowComponent: FormRowComponentType;
|
|
@@ -9,6 +9,7 @@ const hooks_1 = require("../utils/hooks");
|
|
|
9
9
|
const Div_1 = __importDefault(require("./Div"));
|
|
10
10
|
const Icon_1 = __importDefault(require("./Icon"));
|
|
11
11
|
const Text_1 = __importDefault(require("./Text"));
|
|
12
|
+
const Button_1 = __importDefault(require("./Button"));
|
|
12
13
|
const BetterHtmlProvider_1 = require("./BetterHtmlProvider");
|
|
13
14
|
const FormRowComponent = (0, react_1.forwardRef)(function FormRow({ oneItemOnly, gap, children, ...props }, ref) {
|
|
14
15
|
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
@@ -17,9 +18,9 @@ const FormRowComponent = (0, react_1.forwardRef)(function FormRow({ oneItemOnly,
|
|
|
17
18
|
const readyGap = breakingPoint ? theme.styles.gap : theme.styles.space * 2;
|
|
18
19
|
return ((0, jsx_runtime_1.jsxs)(Div_1.default.row, { alignItems: "center", gap: gap ?? readyGap, invertFlexDirection: breakingPoint, ...props, ref: ref, children: [children, oneItemOnly && (0, jsx_runtime_1.jsx)(Div_1.default, { width: "100%" })] }));
|
|
19
20
|
});
|
|
20
|
-
FormRowComponent.withTitle = (0, react_1.forwardRef)(function WithTitle({ icon, title, description, children, ...props }, ref) {
|
|
21
|
+
FormRowComponent.withTitle = (0, react_1.forwardRef)(function WithTitle({ icon, title, description, withActions, onClickSave, onClickReset, children, ...props }, ref) {
|
|
21
22
|
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
22
|
-
return ((0, jsx_runtime_1.jsxs)(FormRowComponent, { ...props, ref: ref, children: [(0, jsx_runtime_1.jsxs)(Div_1.default.row, { width: "100%", alignItems: "center", gap: theme.styles.space, children: [icon && (0, jsx_runtime_1.jsx)(Icon_1.default, { name: icon }), (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: "h3", children: title }), description && (0, jsx_runtime_1.jsx)(Text_1.default, { color: theme.colors.textSecondary, children: description })] })] }), (0, jsx_runtime_1.
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)(FormRowComponent, { ...props, ref: ref, children: [(0, jsx_runtime_1.jsxs)(Div_1.default.row, { width: "100%", alignItems: "center", gap: theme.styles.space, children: [icon && (0, jsx_runtime_1.jsx)(Icon_1.default, { name: icon }), (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: "h3", children: title }), description && (0, jsx_runtime_1.jsx)(Text_1.default, { color: theme.colors.textSecondary, children: description })] })] }), (0, jsx_runtime_1.jsxs)(Div_1.default.row, { width: "100%", alignItems: "center", gap: theme.styles.gap, children: [children, withActions && ((0, jsx_runtime_1.jsxs)(Div_1.default.row, { alignItems: "center", gap: theme.styles.gap, children: [onClickReset && (0, jsx_runtime_1.jsx)(Button_1.default.icon, { icon: "XMark", onClick: onClickReset }), (0, jsx_runtime_1.jsx)(Button_1.default.icon, { icon: "check", onClick: onClickSave })] }))] })] }));
|
|
23
24
|
});
|
|
24
25
|
const FormRow = (0, react_1.memo)(FormRowComponent);
|
|
25
26
|
FormRow.withTitle = FormRowComponent.withTitle;
|