react-better-html 1.1.67 → 1.1.69
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/InputField.js +3 -3
- package/dist/components/PageHeader.js +2 -1
- package/dist/components/Table.d.ts +8 -7
- package/dist/components/Table.js +22 -17
- package/dist/components/ToggleInput.js +2 -2
- package/dist/constants/theme.js +6 -2
- package/dist/types/theme.d.ts +1 -1
- package/package.json +1 -1
|
@@ -153,7 +153,7 @@ const InputFieldComponent = (0, react_1.forwardRef)(function InputField({ label,
|
|
|
153
153
|
return;
|
|
154
154
|
onChangeValue?.(debouncedValue);
|
|
155
155
|
}, [withDebounce, onChangeValue, debouncedValue]);
|
|
156
|
-
return ((0, jsx_runtime_1.jsxs)(Div_1.default.column, { width: "100%", gap: theme.styles.gap
|
|
156
|
+
return ((0, jsx_runtime_1.jsxs)(Div_1.default.column, { width: "100%", gap: theme.styles.gap, ...styledComponentStylesWithExcluded, ref: holderRef, children: [label && (0, jsx_runtime_1.jsx)(Label_1.default, { text: label, color: labelColor, 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 : labelColor ?? theme.colors.textSecondary, children: errorText || infoText }))] }));
|
|
157
157
|
});
|
|
158
158
|
InputFieldComponent.multiline = (0, react_1.forwardRef)(function Multiline({ label, placeholder, errorText, infoText, leftIcon, rightIcon, onChange, onChangeValue, onClickRightIcon, required, ...props }, ref) {
|
|
159
159
|
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
@@ -165,7 +165,7 @@ InputFieldComponent.multiline = (0, react_1.forwardRef)(function Multiline({ lab
|
|
|
165
165
|
onChange?.(event);
|
|
166
166
|
onChangeValue?.(event.target.value);
|
|
167
167
|
}, [onChange, onChangeValue]);
|
|
168
|
-
return ((0, jsx_runtime_1.jsxs)(Div_1.default.column, { gap: theme.styles.gap
|
|
168
|
+
return ((0, jsx_runtime_1.jsxs)(Div_1.default.column, { gap: theme.styles.gap, 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 : props.labelColor ?? theme.colors.textSecondary, fontSize: 14, children: errorText || infoText }))] }));
|
|
169
169
|
});
|
|
170
170
|
InputFieldComponent.email = (0, react_1.forwardRef)(function Email({ ...props }, ref) {
|
|
171
171
|
return ((0, jsx_runtime_1.jsx)(InputFieldComponent, { type: "email", placeholder: "your@email.here", autoComplete: "email", autoCorrect: "off", autoCapitalize: "off", ref: ref, ...props }));
|
|
@@ -211,7 +211,7 @@ InputFieldComponent.phoneNumber = (0, react_1.forwardRef)(function PhoneNumber({
|
|
|
211
211
|
setDropdownValue(country.phoneNumberExtension);
|
|
212
212
|
setInputFieldValue(newValue.slice(country?.phoneNumberExtension.length + 1));
|
|
213
213
|
}, [value]);
|
|
214
|
-
return ((0, jsx_runtime_1.jsxs)(Div_1.default, { width: "100%", children: [label && (0, jsx_runtime_1.jsx)(Label_1.default, { text: label, color: labelColor, required: props.required, isError: !!props.errorText }), (0, jsx_runtime_1.jsxs)(Div_1.default.row, { children: [(0, jsx_runtime_1.jsx)(Dropdown_1.default, { options: options, renderOption: renderOption, width: 130, minWidth: 116, withSearch: true, placeholder: "+00", inputFieldClassName: "react-better-html-phone-number-holder", defaultValue: defaultValue, value: dropdownValue, onChange: setDropdownValue, withoutClearButton: true }), (0, jsx_runtime_1.jsx)(InputFieldComponent, { placeholder: label ?? "Phone number", className: "react-better-html-phone-number", value: inputFieldValue, onChangeValue: onChangeValueElement, ref: ref, ...props })] })] }));
|
|
214
|
+
return ((0, jsx_runtime_1.jsxs)(Div_1.default.column, { width: "100%", gap: theme.styles.gap, children: [label && (0, jsx_runtime_1.jsx)(Label_1.default, { text: label, color: labelColor, required: props.required, isError: !!props.errorText }), (0, jsx_runtime_1.jsxs)(Div_1.default.row, { children: [(0, jsx_runtime_1.jsx)(Dropdown_1.default, { options: options, renderOption: renderOption, width: 130, minWidth: 116, withSearch: true, placeholder: "+00", inputFieldClassName: "react-better-html-phone-number-holder", defaultValue: defaultValue, value: dropdownValue, onChange: setDropdownValue, withoutClearButton: true }), (0, jsx_runtime_1.jsx)(InputFieldComponent, { placeholder: label ?? "Phone number", className: "react-better-html-phone-number", value: inputFieldValue, onChangeValue: onChangeValueElement, ref: ref, ...props })] })] }));
|
|
215
215
|
});
|
|
216
216
|
InputFieldComponent.date = (0, react_1.forwardRef)(function Date({ className, onFocus, onBlur, ...props }, ref) {
|
|
217
217
|
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
@@ -12,7 +12,8 @@ const Image_1 = __importDefault(require("./Image"));
|
|
|
12
12
|
const BetterHtmlProvider_1 = require("./BetterHtmlProvider");
|
|
13
13
|
function PageHeader({ imageUrl, imageSize = 60, title, titleAs, titleRightElement, description, textAlign, rightElement, lightMode, marginBottom, }) {
|
|
14
14
|
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
15
|
+
const { app } = (0, BetterHtmlProvider_1.useBetterHtmlContext)();
|
|
15
16
|
const mediaQuery = (0, hooks_1.useMediaQuery)();
|
|
16
|
-
return ((0, jsx_runtime_1.jsxs)(Div_1.default.row, { alignItems: "center", gap: theme.styles.space, marginBottom: marginBottom ?? theme.styles.space * 2, children: [imageUrl && (0, jsx_runtime_1.jsx)(Image_1.default.profileImage, { src: imageUrl, size: imageSize ?? (mediaQuery.size600 ? 46 : 60) }), (0, jsx_runtime_1.jsxs)(Div_1.default.column, { flex: 1, gap: theme.styles.gap / 2, children: [(0, jsx_runtime_1.jsxs)(Div_1.default.row, { alignItems: "center", justifyContent: textAlign === "center" ? "center" : textAlign === "right" ? "flex-end" : undefined, gap: theme.styles.space, children: [(0, jsx_runtime_1.jsx)(Text_1.default, { as: titleAs ?? "h1", textAlign: textAlign, color: lightMode ? theme.colors.base : theme.colors.textPrimary, children: title }), titleRightElement] }), (0, jsx_runtime_1.jsx)(Text_1.default, { textAlign: textAlign, color: lightMode ? theme.colors.base : theme.colors.textSecondary, opacity: lightMode ? 0.7 : undefined, children: description })] }), rightElement] }));
|
|
17
|
+
return ((0, jsx_runtime_1.jsxs)(Div_1.default.row, { alignItems: "center", gap: theme.styles.space, marginBottom: marginBottom ?? theme.styles.space * 2, children: [imageUrl && (0, jsx_runtime_1.jsx)(Image_1.default.profileImage, { src: imageUrl, size: imageSize ?? (mediaQuery.size600 ? 46 : 60) }), (0, jsx_runtime_1.jsxs)(Div_1.default.column, { justifyContent: textAlign === "center" ? "center" : textAlign === "right" ? "flex-end" : undefined, flex: 1, gap: theme.styles.gap / 2, children: [(0, jsx_runtime_1.jsxs)(Div_1.default.row, { alignItems: "center", justifyContent: textAlign === "center" ? "center" : textAlign === "right" ? "flex-end" : undefined, gap: theme.styles.space, children: [(0, jsx_runtime_1.jsx)(Text_1.default, { as: titleAs ?? "h1", textAlign: textAlign, color: lightMode ? theme.colors.base : theme.colors.textPrimary, children: title }), titleRightElement] }), description && ((0, jsx_runtime_1.jsx)(Text_1.default, { maxWidth: !mediaQuery.size600 ? app.contentMaxWidth * 0.6 : undefined, textAlign: textAlign, color: lightMode ? theme.colors.base : theme.colors.textSecondary, opacity: lightMode ? 0.7 : undefined, children: description }))] }), rightElement] }));
|
|
17
18
|
}
|
|
18
19
|
exports.default = (0, react_1.memo)(PageHeader);
|
|
@@ -4,26 +4,27 @@ import { ToggleInputProps } from "./ToggleInput";
|
|
|
4
4
|
import { ImageProps } from "./Image";
|
|
5
5
|
type TextColumn<DataItem> = {
|
|
6
6
|
type: "text";
|
|
7
|
-
keyName
|
|
8
|
-
format?: (
|
|
7
|
+
keyName?: keyof DataItem;
|
|
8
|
+
format?: (item: DataItem, index: number) => string;
|
|
9
9
|
};
|
|
10
10
|
type ElementColumn<DataItem> = {
|
|
11
11
|
type: "element";
|
|
12
|
-
render
|
|
12
|
+
render?: (item: DataItem, index: number) => ReactNode;
|
|
13
13
|
};
|
|
14
14
|
type ImageColumn<DataItem> = {
|
|
15
15
|
type: "image";
|
|
16
16
|
keyName?: keyof DataItem;
|
|
17
17
|
} & ImageProps;
|
|
18
|
-
type CheckboxColumn
|
|
18
|
+
type CheckboxColumn = {
|
|
19
19
|
type: "checkbox";
|
|
20
|
-
keyName?: keyof DataItem;
|
|
21
20
|
} & ToggleInputProps<boolean>;
|
|
22
21
|
export type TableColumn<DataItem> = {
|
|
23
22
|
label?: string;
|
|
24
23
|
width?: string | number;
|
|
24
|
+
minWidth?: string | number;
|
|
25
|
+
maxWidth?: string | number;
|
|
25
26
|
align?: "left" | "center" | "right";
|
|
26
|
-
} & (TextColumn<DataItem> | ElementColumn<DataItem> | ImageColumn<DataItem> | CheckboxColumn
|
|
27
|
+
} & (TextColumn<DataItem> | ElementColumn<DataItem> | ImageColumn<DataItem> | CheckboxColumn);
|
|
27
28
|
export type TableProps<DataItem> = {
|
|
28
29
|
columns: TableColumn<DataItem>[];
|
|
29
30
|
data: DataItem[];
|
|
@@ -34,7 +35,7 @@ export type TableProps<DataItem> = {
|
|
|
34
35
|
/** @default "No data available" */
|
|
35
36
|
noDataItemsMessage?: string;
|
|
36
37
|
onClickRow?: (item: DataItem, index: number) => void;
|
|
37
|
-
onClickAllCheckboxes?: () => void;
|
|
38
|
+
onClickAllCheckboxes?: (checked: boolean) => void;
|
|
38
39
|
} & ComponentMarginProps;
|
|
39
40
|
type TableComponentType = {
|
|
40
41
|
<DataItem>(props: ComponentPropWithRef<HTMLDivElement, TableProps<DataItem>>): React.ReactElement;
|
package/dist/components/Table.js
CHANGED
|
@@ -100,9 +100,11 @@ const TableStyledComponent = styled_components_1.default.table.withConfig({
|
|
|
100
100
|
}
|
|
101
101
|
`;
|
|
102
102
|
const ThStyledComponent = styled_components_1.default.th.withConfig({
|
|
103
|
-
shouldForwardProp: (prop) => !["width", "textAlign"].includes(prop),
|
|
103
|
+
shouldForwardProp: (prop) => !["width", "minWidth", "maxWidth", "textAlign"].includes(prop),
|
|
104
104
|
}) `
|
|
105
105
|
${(props) => (props.width ? `width: ${props.width}px;` : "")}
|
|
106
|
+
${(props) => (props.minWidth ? `min-width: ${props.minWidth}px;` : "")}
|
|
107
|
+
${(props) => (props.maxWidth ? `max-width: ${props.maxWidth}px;` : "")}
|
|
106
108
|
${(props) => (props.textAlign ? `text-align: ${props.textAlign} !important;` : "")}
|
|
107
109
|
`;
|
|
108
110
|
const TdStyledComponent = styled_components_1.default.td.withConfig({
|
|
@@ -112,14 +114,15 @@ const TdStyledComponent = styled_components_1.default.td.withConfig({
|
|
|
112
114
|
`;
|
|
113
115
|
const TableComponent = (0, react_1.forwardRef)(function Table({ columns, data, isStriped, withStickyHeader, noDataItemsMessage = "No data available", onClickRow, onClickAllCheckboxes, ...props }, ref) {
|
|
114
116
|
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
117
|
+
const [checkedItems, setCheckedItems] = (0, react_1.useState)([]);
|
|
115
118
|
const renderCellContent = (0, react_1.useCallback)((column, item, index) => {
|
|
116
119
|
switch (column.type) {
|
|
117
120
|
case "text": {
|
|
118
|
-
const value = item[column.keyName];
|
|
119
|
-
return column.format ? column.format(
|
|
121
|
+
const value = column.keyName ? item[column.keyName] : undefined;
|
|
122
|
+
return column.format ? column.format(item, index) : String(value ?? "");
|
|
120
123
|
}
|
|
121
124
|
case "element": {
|
|
122
|
-
return column.render(item, index);
|
|
125
|
+
return column.render?.(item, index) ?? (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
|
|
123
126
|
}
|
|
124
127
|
case "image": {
|
|
125
128
|
const { type, keyName, ...props } = column;
|
|
@@ -127,28 +130,30 @@ const TableComponent = (0, react_1.forwardRef)(function Table({ columns, data, i
|
|
|
127
130
|
return ((0, jsx_runtime_1.jsx)(Image_1.default, { src: src, width: defaultImageWidth, borderRadius: theme.styles.borderRadius / 2, ...props }));
|
|
128
131
|
}
|
|
129
132
|
case "checkbox": {
|
|
130
|
-
const { type,
|
|
131
|
-
const
|
|
132
|
-
return (0, jsx_runtime_1.jsx)(ToggleInput_1.default.checkbox, { checked: checked,
|
|
133
|
+
const { type, onChange, ...props } = column;
|
|
134
|
+
const checkedValue = checkedItems[index];
|
|
135
|
+
return ((0, jsx_runtime_1.jsx)(ToggleInput_1.default.checkbox, { checked: checkedValue, onChange: (checked, value) => {
|
|
136
|
+
setCheckedItems((oldValue) => oldValue.map((isChecked, internalIndex) => (internalIndex === index ? checked : isChecked)));
|
|
137
|
+
onChange?.(checked, value);
|
|
138
|
+
}, ...props }));
|
|
133
139
|
}
|
|
134
140
|
default: {
|
|
135
141
|
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
|
|
136
142
|
}
|
|
137
143
|
}
|
|
138
|
-
}, [theme]);
|
|
144
|
+
}, [theme, checkedItems]);
|
|
139
145
|
const onClickRowElement = (0, react_1.useCallback)((item, index) => {
|
|
140
146
|
onClickRow?.(item, index);
|
|
141
147
|
}, [onClickRow]);
|
|
148
|
+
const onClickAllCheckboxesElement = (0, react_1.useCallback)((checked) => {
|
|
149
|
+
onClickAllCheckboxes?.(checked);
|
|
150
|
+
setCheckedItems(data.map(() => checked));
|
|
151
|
+
}, [onClickAllCheckboxes, data]);
|
|
142
152
|
const everythingIsChecked = (0, react_1.useMemo)(() => {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return false;
|
|
148
|
-
return data.every((item) => item[keyName]);
|
|
149
|
-
}, [data]);
|
|
150
|
-
return ((0, jsx_runtime_1.jsx)(Div_1.default, { border: `1px solid ${theme.colors.border}`, borderRadius: theme.styles.borderRadius * 2, overflow: "auto", ...props, ref: ref, children: (0, jsx_runtime_1.jsxs)(TableStyledComponent, { isStriped: isStriped, withHover: onClickRow !== undefined, withStickyHeader: withStickyHeader, theme: theme, children: [(0, jsx_runtime_1.jsx)("thead", { children: (0, jsx_runtime_1.jsx)("tr", { className: "isHeader", children: columns.map((column, index) => ((0, jsx_runtime_1.jsx)(ThStyledComponent, { width: column.type === "image" ? defaultImageWidth : column.type === "checkbox" ? 26 : column.width, textAlign: column.align, children: column.label ??
|
|
151
|
-
(column.type === "checkbox" && onClickAllCheckboxes ? ((0, jsx_runtime_1.jsx)(ToggleInput_1.default.checkbox, { checked: everythingIsChecked, onChange: onClickAllCheckboxes })) : ("")) }, column.type + column.label + index))) }) }), (0, jsx_runtime_1.jsx)("tbody", { children: data.length > 0 ? (data.map((item, rowIndex) => ((0, jsx_runtime_1.jsx)("tr", { className: onClickRow ? "isClickable" : undefined, onClick: () => onClickRowElement(item, rowIndex), children: columns.map((column, colIndex) => ((0, jsx_runtime_1.jsx)(TdStyledComponent, { textAlign: column.align, children: renderCellContent(column, item, rowIndex) }, column.type + column.label + colIndex))) }, JSON.stringify(item) + rowIndex)))) : ((0, jsx_runtime_1.jsx)("tr", { children: (0, jsx_runtime_1.jsx)("td", { className: "noData", colSpan: columns.length, children: (0, jsx_runtime_1.jsx)(Text_1.default.unknown, { children: noDataItemsMessage }) }) })) })] }) }));
|
|
153
|
+
return checkedItems.every((checked) => checked) && checkedItems.length === data.length;
|
|
154
|
+
}, [data, checkedItems]);
|
|
155
|
+
return ((0, jsx_runtime_1.jsx)(Div_1.default, { border: `1px solid ${theme.colors.border}`, borderRadius: theme.styles.borderRadius * 2, overflow: "auto", ...props, ref: ref, children: (0, jsx_runtime_1.jsxs)(TableStyledComponent, { isStriped: isStriped, withHover: onClickRow !== undefined, withStickyHeader: withStickyHeader, theme: theme, children: [(0, jsx_runtime_1.jsx)("thead", { children: (0, jsx_runtime_1.jsx)("tr", { className: "isHeader", children: columns.map((column, index) => ((0, jsx_runtime_1.jsx)(ThStyledComponent, { width: column.type === "image" ? defaultImageWidth : column.type === "checkbox" ? 26 : column.width, minWidth: column.minWidth, maxWidth: column.maxWidth, textAlign: column.align, children: column.label ??
|
|
156
|
+
(column.type === "checkbox" && onClickAllCheckboxes ? ((0, jsx_runtime_1.jsx)(ToggleInput_1.default.checkbox, { checked: everythingIsChecked, onChange: onClickAllCheckboxesElement })) : ("")) }, column.type + column.label + index))) }) }), (0, jsx_runtime_1.jsx)("tbody", { children: data.length > 0 ? (data.map((item, rowIndex) => ((0, jsx_runtime_1.jsx)("tr", { className: onClickRow ? "isClickable" : undefined, onClick: () => onClickRowElement(item, rowIndex), children: columns.map((column, colIndex) => ((0, jsx_runtime_1.jsx)(TdStyledComponent, { textAlign: column.align, children: renderCellContent(column, item, rowIndex) }, column.type + column.label + colIndex))) }, JSON.stringify(item) + rowIndex)))) : ((0, jsx_runtime_1.jsx)("tr", { children: (0, jsx_runtime_1.jsx)("td", { className: "noData", colSpan: columns.length, children: (0, jsx_runtime_1.jsx)(Text_1.default.unknown, { children: noDataItemsMessage }) }) })) })] }) }));
|
|
152
157
|
});
|
|
153
158
|
const Table = (0, react_1.memo)(TableComponent);
|
|
154
159
|
exports.default = Table;
|
|
@@ -129,7 +129,7 @@ const ToggleInputComponent = (0, react_1.forwardRef)(function ToggleInput({ labe
|
|
|
129
129
|
setInternalChecked(newIsChecked);
|
|
130
130
|
onChange?.(newIsChecked, value);
|
|
131
131
|
}, [checked, controlledChecked, onChange, value]);
|
|
132
|
-
return ((0, jsx_runtime_1.jsxs)(Div_1.default.column, { width: "100%", gap: theme.styles.gap
|
|
132
|
+
return ((0, jsx_runtime_1.jsxs)(Div_1.default.column, { width: "100%", gap: theme.styles.gap, ...styledComponentStylesWithExcluded, children: [label && (0, jsx_runtime_1.jsx)(Label_1.default, { text: label, color: labelColor, required: required, isError: !!errorText }), (0, jsx_runtime_1.jsxs)(Div_1.default.row, { alignItems: "center", gap: theme.styles.gap, children: [(0, jsx_runtime_1.jsxs)(Div_1.default.row, { position: "relative", alignItems: "center", children: [(0, jsx_runtime_1.jsx)(InputElement, { theme: theme, type: props.type ?? "checkbox", checked: checked, onChange: onChangeElement, ...styledComponentStyles, ...dataProps, ...ariaProps, ...restProps }), props.type === "checkbox" ? ((0, jsx_runtime_1.jsx)(Icon_1.default, { name: "check", position: "absolute", top: "50%", left: "50%", color: theme.colors.base, size: 14, transform: `translate(-50%, -50%)${checked ? "" : " scale(0.4)"}`, opacity: checked ? 1 : 0, pointerEvents: "none", transition: theme.styles.transition })) : props.type === "radio" ? ((0, jsx_runtime_1.jsx)(Div_1.default, { position: "absolute", width: 10, height: 10, top: "50%", left: "50%", backgroundColor: theme.colors.base, borderRadius: 999, transform: `translate(-50%, -50%)${checked ? "" : " scale(0.4)"}`, opacity: checked ? 1 : 0, pointerEvents: "none" })) : undefined] }), text && ((0, jsx_runtime_1.jsxs)(Text_1.default, { color: color, userSelect: "none", cursor: "pointer", onClick: onClickText, children: [text, required && !label && ((0, jsx_runtime_1.jsxs)(Text_1.default, { as: "span", fontSize: 16, color: theme.colors.error, children: [" ", "*"] }))] }))] }), (errorText || infoText) && ((0, jsx_runtime_1.jsx)(Text_1.default, { as: "span", display: "block", fontSize: 14, color: errorText ? theme.colors.error : labelColor ?? theme.colors.textSecondary, children: errorText || infoText }))] }));
|
|
133
133
|
});
|
|
134
134
|
exports.default = {
|
|
135
135
|
checkbox: (0, react_1.forwardRef)(function Checkbox(props, ref) {
|
|
@@ -156,6 +156,6 @@ exports.default = {
|
|
|
156
156
|
setInternalChecked.setState(newIsChecked);
|
|
157
157
|
onChange?.(newIsChecked, value);
|
|
158
158
|
}, [disabled, checked, onChange, controlledChecked, value]);
|
|
159
|
-
return ((0, jsx_runtime_1.jsxs)(Div_1.default.column, { width: "fit-content", gap: theme.styles.gap
|
|
159
|
+
return ((0, jsx_runtime_1.jsxs)(Div_1.default.column, { width: "fit-content", gap: theme.styles.gap, ...styledComponentStylesWithExcluded, children: [label && (0, jsx_runtime_1.jsx)(Label_1.default, { text: label, color: labelColor, required: required, isError: !!errorText }), (0, jsx_runtime_1.jsx)(Div_1.default.row, { alignItems: "center", gap: theme.styles.gap, onMouseDown: setIsMouseDown.setTrue, onMouseUp: setIsMouseDown.setFalse, onMouseOut: setIsMouseDown.setFalse, onTouchStart: setIsMouseDown.setTrue, onTouchEnd: setIsMouseDown.setFalse, onTouchCancel: setIsMouseDown.setFalse, children: (0, jsx_runtime_1.jsx)(SwitchElement, { theme: theme, checked: checked, disabled: disabled ?? false, isMouseDown: isMouseDown, onClick: onClickElement, ...styledComponentStyles, ...dataProps, ...ariaProps, ...restProps }) }), (errorText || infoText) && ((0, jsx_runtime_1.jsx)(Text_1.default, { as: "span", display: "block", fontSize: 14, color: errorText ? theme.colors.error : labelColor ?? theme.colors.textSecondary, children: errorText || infoText }))] }));
|
|
160
160
|
}),
|
|
161
161
|
};
|
package/dist/constants/theme.js
CHANGED
|
@@ -13,11 +13,13 @@ exports.theme = {
|
|
|
13
13
|
light: {
|
|
14
14
|
textPrimary: "#111111",
|
|
15
15
|
textSecondary: "#777777",
|
|
16
|
+
textLink: "#0894ff",
|
|
16
17
|
label: "#111111",
|
|
17
18
|
primary: "#6d466b",
|
|
18
19
|
secondary: "#412234",
|
|
20
|
+
accent: "#16d7ed",
|
|
19
21
|
success: "#28a745",
|
|
20
|
-
info: "#
|
|
22
|
+
info: "#0fa0da",
|
|
21
23
|
warn: "#ffc107",
|
|
22
24
|
error: "#dc3545",
|
|
23
25
|
base: "#f8f8f8",
|
|
@@ -29,11 +31,13 @@ exports.theme = {
|
|
|
29
31
|
dark: {
|
|
30
32
|
textPrimary: "#f8f8f8",
|
|
31
33
|
textSecondary: "#e8e8e8",
|
|
34
|
+
textLink: "#0894ff",
|
|
32
35
|
label: "#111111",
|
|
33
36
|
primary: "#9b6499",
|
|
34
37
|
secondary: "#6c466b",
|
|
38
|
+
accent: "#16d7ed",
|
|
35
39
|
success: "#28a745",
|
|
36
|
-
info: "#
|
|
40
|
+
info: "#0fa0da",
|
|
37
41
|
warn: "#ffc107",
|
|
38
42
|
error: "#dc3545",
|
|
39
43
|
base: "#f8f8f8",
|
package/dist/types/theme.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type Color = `#${string}` | "transparent";
|
|
2
|
-
export type ColorName = "textPrimary" | "textSecondary" | "label" | "primary" | "secondary" | "success" | "info" | "warn" | "error" | "base" | "backgroundBase" | "backgroundSecondary" | "backgroundContent" | "border";
|
|
2
|
+
export type ColorName = "textPrimary" | "textSecondary" | "textLink" | "label" | "primary" | "secondary" | "accent" | "success" | "info" | "warn" | "error" | "base" | "backgroundBase" | "backgroundSecondary" | "backgroundContent" | "border";
|
|
3
3
|
export type ColorTheme = "light" | "dark";
|
|
4
4
|
export type Styles = {
|
|
5
5
|
space: number;
|