react-better-html 1.1.50 → 1.1.52

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.
@@ -9,7 +9,7 @@ export type DropdownOption<Value, Data = unknown> = {
9
9
  searchValues?: string[];
10
10
  data?: Data;
11
11
  };
12
- export type DropdownProps<Value, Data> = {
12
+ export type DropdownProps<Value, Data = unknown> = {
13
13
  label?: string;
14
14
  errorText?: string;
15
15
  infoText?: string;
@@ -12,6 +12,9 @@ type FormRowComponentType = {
12
12
  icon?: IconName | AnyOtherString;
13
13
  title?: string;
14
14
  description?: string;
15
+ withActions?: boolean;
16
+ onClickSave?: () => void;
17
+ onClickReset?: () => void;
15
18
  }>) => React.ReactElement;
16
19
  };
17
20
  declare const FormRowComponent: FormRowComponentType;
@@ -10,6 +10,7 @@ const Div_1 = __importDefault(require("./Div"));
10
10
  const Icon_1 = __importDefault(require("./Icon"));
11
11
  const Text_1 = __importDefault(require("./Text"));
12
12
  const BetterHtmlProvider_1 = require("./BetterHtmlProvider");
13
+ const Button_1 = __importDefault(require("./Button"));
13
14
  const FormRowComponent = (0, react_1.forwardRef)(function FormRow({ oneItemOnly, gap, children, ...props }, ref) {
14
15
  const theme = (0, BetterHtmlProvider_1.useTheme)();
15
16
  const mediaQuery = (0, hooks_1.useMediaQuery)();
@@ -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.jsx)(Div_1.default, { width: "100%", children: children })] }));
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;
@@ -78,7 +78,7 @@ const InputElement = styled_components_1.default.input.withConfig({
78
78
  }
79
79
  `;
80
80
  const TextareaElement = styled_components_1.default.textarea.withConfig({
81
- shouldForwardProp: (prop) => !["normalStyle", "hoverStyle"].includes(prop),
81
+ shouldForwardProp: (prop) => !["theme", "withLeftIcon", "withRightIcon", "normalStyle", "hoverStyle"].includes(prop),
82
82
  }) `
83
83
  width: 100%;
84
84
  min-height: 3lh;
@@ -92,6 +92,8 @@ const TextareaElement = styled_components_1.default.textarea.withConfig({
92
92
  border-radius: ${(props) => props.theme.styles.borderRadius}px;
93
93
  outline: none;
94
94
  padding: ${(props) => `${(props.theme.styles.gap + props.theme.styles.space) / 2}px ${props.theme.styles.space + props.theme.styles.gap}px`};
95
+ padding-left: ${(props) => props.withLeftIcon ? `${props.theme.styles.space + 16 + props.theme.styles.space - 1}px` : undefined};
96
+ padding-right: ${(props) => props.withRightIcon ? `${props.theme.styles.space + 16 + props.theme.styles.space - 1}px` : undefined};
95
97
  resize: vertical;
96
98
  transition: border-color ${(props) => props.theme.styles.transition};
97
99
 
@@ -133,9 +135,9 @@ const InputFieldComponent = (0, react_1.forwardRef)(function InputField({ label,
133
135
  return;
134
136
  onChangeValue?.(debouncedValue);
135
137
  }, [withDebounce, onChangeValue, debouncedValue]);
136
- return ((0, jsx_runtime_1.jsxs)(Div_1.default.column, { width: "100%", gap: theme.styles.gap / 2, ...styledComponentStylesWithExcluded, children: [label && (0, jsx_runtime_1.jsx)(Label_1.default, { text: label, required: required, isError: !!errorText }), (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, placeholder: placeholder ?? label, 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 }))] }));
138
+ return ((0, jsx_runtime_1.jsxs)(Div_1.default.column, { width: "100%", gap: theme.styles.gap / 2, ...styledComponentStylesWithExcluded, children: [label && (0, jsx_runtime_1.jsx)(Label_1.default, { text: label, required: required, isError: !!errorText }), (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: props.className?.includes("react-better-html-dropdown-open-late") ? 1002 : 1 })), (0, jsx_runtime_1.jsx)(InputElement, { theme: theme, withLeftIcon: leftIcon !== undefined, withRightIcon: rightIcon !== undefined, required: required, placeholder: placeholder ?? label, 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 }))] }));
137
139
  });
138
- InputFieldComponent.multiline = (0, react_1.forwardRef)(function Multiline({ label, placeholder, errorText, infoText, onChange, onChangeValue, required, ...props }, ref) {
140
+ InputFieldComponent.multiline = (0, react_1.forwardRef)(function Multiline({ label, placeholder, errorText, infoText, leftIcon, rightIcon, onChange, onChangeValue, onClickRightIcon, required, ...props }, ref) {
139
141
  const theme = (0, BetterHtmlProvider_1.useTheme)();
140
142
  const styledComponentStyles = (0, hooks_1.useStyledComponentStyles)(props, theme);
141
143
  const dataProps = (0, hooks_1.useComponentPropsWithPrefix)(props, "data");
@@ -145,7 +147,7 @@ InputFieldComponent.multiline = (0, react_1.forwardRef)(function Multiline({ lab
145
147
  onChange?.(event);
146
148
  onChangeValue?.(event.target.value);
147
149
  }, [onChange, onChangeValue]);
148
- return ((0, jsx_runtime_1.jsxs)(Div_1.default.column, { gap: theme.styles.gap / 2, children: [label && (0, jsx_runtime_1.jsx)(Label_1.default, { text: label, required: required, isError: !!errorText }), (0, jsx_runtime_1.jsx)(TextareaElement, { theme: theme, required: required, placeholder: placeholder ?? label, 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 }))] }));
150
+ return ((0, jsx_runtime_1.jsxs)(Div_1.default.column, { gap: theme.styles.gap / 2, children: [label && (0, jsx_runtime_1.jsx)(Label_1.default, { text: label, required: required, isError: !!errorText }), (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" })), (0, jsx_runtime_1.jsx)(TextareaElement, { theme: theme, withLeftIcon: leftIcon !== undefined, withRightIcon: rightIcon !== undefined, required: required, placeholder: placeholder ?? label, onChange: onChangeElement, ...styledComponentStyles, ...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] }), (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 }))] }));
149
151
  });
150
152
  InputFieldComponent.email = (0, react_1.forwardRef)(function Email({ ...props }, ref) {
151
153
  return ((0, jsx_runtime_1.jsx)(InputFieldComponent, { type: "email", placeholder: "your@email.here", autoComplete: "email", autoCorrect: "off", autoCapitalize: "off", ref: ref, ...props }));
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Div, { type DivProps } from "./components/Div";
2
- import Text, { type TextProps, TextAs } from "./components/Text";
2
+ import Text, { type TextProps, type TextAs } from "./components/Text";
3
3
  import Loader, { type LoaderProps } from "./components/Loader";
4
4
  import Icon, { type IconProps } from "./components/Icon";
5
5
  import Image, { type ImageProps } from "./components/Image";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-better-html",
3
- "version": "1.1.50",
3
+ "version": "1.1.52",
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": [