react-better-html 1.1.71 → 1.1.73
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/index.d.mts +686 -0
- package/dist/index.d.ts +686 -34
- package/dist/index.js +6302 -101
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +6231 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +5 -5
- package/dist/components/BetterHtmlProvider.d.ts +0 -29
- package/dist/components/BetterHtmlProvider.js +0 -161
- package/dist/components/Button.d.ts +0 -65
- package/dist/components/Button.js +0 -166
- package/dist/components/Chip.d.ts +0 -20
- package/dist/components/Chip.js +0 -20
- package/dist/components/ColorThemeSwitch.d.ts +0 -15
- package/dist/components/ColorThemeSwitch.js +0 -54
- package/dist/components/Div.d.ts +0 -30
- package/dist/components/Div.js +0 -60
- package/dist/components/Divider.d.ts +0 -21
- package/dist/components/Divider.js +0 -20
- package/dist/components/Dropdown.d.ts +0 -48
- package/dist/components/Dropdown.js +0 -160
- package/dist/components/ExampleComponent.d.ts +0 -5
- package/dist/components/ExampleComponent.js +0 -10
- package/dist/components/Form.d.ts +0 -25
- package/dist/components/Form.js +0 -27
- package/dist/components/FormRow.d.ts +0 -32
- package/dist/components/FormRow.js +0 -28
- package/dist/components/Icon.d.ts +0 -13
- package/dist/components/Icon.js +0 -36
- package/dist/components/Image.d.ts +0 -18
- package/dist/components/Image.js +0 -44
- package/dist/components/InputField.d.ts +0 -44
- package/dist/components/InputField.js +0 -270
- package/dist/components/Label.d.ts +0 -11
- package/dist/components/Label.js +0 -14
- package/dist/components/Loader.d.ts +0 -34
- package/dist/components/Loader.js +0 -43
- package/dist/components/Modal.d.ts +0 -46
- package/dist/components/Modal.js +0 -123
- package/dist/components/PageHeader.d.ts +0 -18
- package/dist/components/PageHeader.js +0 -19
- package/dist/components/PageHolder.d.ts +0 -8
- package/dist/components/PageHolder.js +0 -15
- package/dist/components/Table.d.ts +0 -45
- package/dist/components/Table.js +0 -159
- package/dist/components/Text.d.ts +0 -18
- package/dist/components/Text.js +0 -38
- package/dist/components/ToggleInput.d.ts +0 -20
- package/dist/components/ToggleInput.js +0 -161
- package/dist/constants/app.d.ts +0 -2
- package/dist/constants/app.js +0 -6
- package/dist/constants/assets.d.ts +0 -2
- package/dist/constants/assets.js +0 -6
- package/dist/constants/countries.d.ts +0 -2
- package/dist/constants/countries.js +0 -1482
- package/dist/constants/css.d.ts +0 -1
- package/dist/constants/css.js +0 -1291
- package/dist/constants/icons.d.ts +0 -2
- package/dist/constants/icons.js +0 -85
- package/dist/constants/theme.d.ts +0 -2
- package/dist/constants/theme.js +0 -50
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +0 -4
- package/dist/plugins/index.d.ts +0 -1
- package/dist/plugins/index.js +0 -17
- package/dist/plugins/react-router-dom.d.ts +0 -2
- package/dist/plugins/react-router-dom.js +0 -14
- package/dist/types/app.d.ts +0 -15
- package/dist/types/app.js +0 -2
- package/dist/types/asset.d.ts +0 -4
- package/dist/types/asset.js +0 -2
- package/dist/types/components.d.ts +0 -13
- package/dist/types/components.js +0 -2
- package/dist/types/config.d.ts +0 -23
- package/dist/types/config.js +0 -2
- package/dist/types/countries.d.ts +0 -7
- package/dist/types/countries.js +0 -2
- package/dist/types/icon.d.ts +0 -11
- package/dist/types/icon.js +0 -2
- package/dist/types/loader.d.ts +0 -4
- package/dist/types/loader.js +0 -2
- package/dist/types/other.d.ts +0 -1
- package/dist/types/other.js +0 -2
- package/dist/types/plugin.d.ts +0 -7
- package/dist/types/plugin.js +0 -2
- package/dist/types/theme.d.ts +0 -19
- package/dist/types/theme.js +0 -2
- package/dist/utils/functions.d.ts +0 -16
- package/dist/utils/functions.js +0 -77
- package/dist/utils/hooks.d.ts +0 -86
- package/dist/utils/hooks.js +0 -450
- package/dist/utils/logger.d.ts +0 -41
- package/dist/utils/logger.js +0 -66
- package/dist/utils/variableFunctions.d.ts +0 -6
- package/dist/utils/variableFunctions.js +0 -28
- package/dist/utils/withPlugin.d.ts +0 -4
- package/dist/utils/withPlugin.js +0 -15
|
@@ -1,270 +0,0 @@
|
|
|
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 styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
-
const countries_1 = require("../constants/countries");
|
|
10
|
-
const hooks_1 = require("../utils/hooks");
|
|
11
|
-
const Text_1 = __importDefault(require("./Text"));
|
|
12
|
-
const Div_1 = __importDefault(require("./Div"));
|
|
13
|
-
const Icon_1 = __importDefault(require("./Icon"));
|
|
14
|
-
const Button_1 = __importDefault(require("./Button"));
|
|
15
|
-
const Label_1 = __importDefault(require("./Label"));
|
|
16
|
-
const Dropdown_1 = __importDefault(require("./Dropdown"));
|
|
17
|
-
const Image_1 = __importDefault(require("./Image"));
|
|
18
|
-
const BetterHtmlProvider_1 = require("./BetterHtmlProvider");
|
|
19
|
-
const InputElement = styled_components_1.default.input.withConfig({
|
|
20
|
-
shouldForwardProp: (prop) => !["theme", "withLeftIcon", "withRightIcon", "normalStyle", "hoverStyle"].includes(prop),
|
|
21
|
-
}) `
|
|
22
|
-
position: relative;
|
|
23
|
-
width: 100%;
|
|
24
|
-
font-family: ${(props) => props.theme.styles.fontFamily};
|
|
25
|
-
font-size: 16px;
|
|
26
|
-
line-height: 20px;
|
|
27
|
-
color: ${(props) => props.theme.colors.textPrimary};
|
|
28
|
-
background: ${(props) => props.theme.colors.backgroundContent};
|
|
29
|
-
border: 1px solid ${(props) => props.theme.colors.border};
|
|
30
|
-
border-radius: ${(props) => props.theme.styles.borderRadius}px;
|
|
31
|
-
outline: none;
|
|
32
|
-
padding: ${(props) => `${(props.theme.styles.space + props.theme.styles.gap) / 2}px ${props.theme.styles.space + props.theme.styles.gap}px`};
|
|
33
|
-
padding-left: ${(props) => props.withLeftIcon ? `${props.theme.styles.space + 16 + props.theme.styles.space - 1}px` : undefined};
|
|
34
|
-
padding-right: ${(props) => props.withRightIcon ? `${props.theme.styles.space + 16 + props.theme.styles.space - 1}px` : undefined};
|
|
35
|
-
transition: ${(props) => props.theme.styles.transition};
|
|
36
|
-
|
|
37
|
-
&::placeholder {
|
|
38
|
-
color: ${(props) => props.theme.colors.textSecondary}80;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
&:focus {
|
|
42
|
-
border-color: ${(props) => props.theme.colors.primary};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
&:disabled {
|
|
46
|
-
filter: brightness(0.9);
|
|
47
|
-
cursor: not-allowed;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
&[type="date"]::-webkit-calendar-picker-indicator,
|
|
51
|
-
&[type="datetime-local"]::-webkit-calendar-picker-indicator,
|
|
52
|
-
&[type="time"]::-webkit-calendar-picker-indicator {
|
|
53
|
-
display: none;
|
|
54
|
-
-webkit-appearance: none;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
&.react-better-html-phone-number-holder {
|
|
58
|
-
border-right: none;
|
|
59
|
-
border-top-right-radius: 0px;
|
|
60
|
-
border-bottom-right-radius: 0px;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
&.react-better-html-phone-number {
|
|
64
|
-
border-top-left-radius: 0px;
|
|
65
|
-
border-bottom-left-radius: 0px;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
&.react-better-html-dropdown {
|
|
69
|
-
padding-right: ${(props) => props.theme.styles.space + 16 + props.theme.styles.space - 1}px;
|
|
70
|
-
|
|
71
|
-
&.react-better-html-dropdown-open {
|
|
72
|
-
border-bottom-left-radius: 0px;
|
|
73
|
-
border-bottom-right-radius: 0px;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
&.react-better-html-dropdown-open-late {
|
|
77
|
-
z-index: 1001;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
&.react-better-html-inputField-dateTime-opened {
|
|
82
|
-
border-bottom-left-radius: 0px;
|
|
83
|
-
border-bottom-right-radius: 0px;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
&.react-better-html-inputField-dateTime-opened-late {
|
|
87
|
-
z-index: 1001;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
${(props) => props.normalStyle}
|
|
91
|
-
|
|
92
|
-
&:hover {
|
|
93
|
-
${(props) => props.hoverStyle}
|
|
94
|
-
}
|
|
95
|
-
`;
|
|
96
|
-
const TextareaElement = styled_components_1.default.textarea.withConfig({
|
|
97
|
-
shouldForwardProp: (prop) => !["theme", "withLeftIcon", "withRightIcon", "normalStyle", "hoverStyle"].includes(prop),
|
|
98
|
-
}) `
|
|
99
|
-
width: 100%;
|
|
100
|
-
min-height: 3lh;
|
|
101
|
-
max-height: 8lh;
|
|
102
|
-
font-family: ${(props) => props.theme.styles.fontFamily};
|
|
103
|
-
font-size: 16px;
|
|
104
|
-
line-height: 20px;
|
|
105
|
-
color: ${(props) => props.theme.colors.textPrimary};
|
|
106
|
-
background: ${(props) => props.theme.colors.backgroundContent};
|
|
107
|
-
border: 1px solid ${(props) => props.theme.colors.border};
|
|
108
|
-
border-radius: ${(props) => props.theme.styles.borderRadius}px;
|
|
109
|
-
outline: none;
|
|
110
|
-
padding: ${(props) => `${(props.theme.styles.gap + props.theme.styles.space) / 2}px ${props.theme.styles.space + props.theme.styles.gap}px`};
|
|
111
|
-
padding-left: ${(props) => props.withLeftIcon ? `${props.theme.styles.space + 16 + props.theme.styles.space - 1}px` : undefined};
|
|
112
|
-
padding-right: ${(props) => props.withRightIcon ? `${props.theme.styles.space + 16 + props.theme.styles.space - 1}px` : undefined};
|
|
113
|
-
resize: vertical;
|
|
114
|
-
transition: border-color ${(props) => props.theme.styles.transition};
|
|
115
|
-
|
|
116
|
-
&::placeholder {
|
|
117
|
-
color: ${(props) => props.theme.colors.textSecondary}80;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
&:focus {
|
|
121
|
-
border-color: ${(props) => props.theme.colors.primary};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
${(props) => props.normalStyle}
|
|
125
|
-
|
|
126
|
-
&:hover {
|
|
127
|
-
${(props) => props.hoverStyle}
|
|
128
|
-
}
|
|
129
|
-
`;
|
|
130
|
-
const hours = Array.from({ length: 24 }, (_, index) => index);
|
|
131
|
-
const minutes = Array.from({ length: 60 }, (_, index) => index);
|
|
132
|
-
const InputFieldComponent = (0, react_1.forwardRef)(function InputField({ label, labelColor, errorText, infoText, leftIcon, rightIcon, insideInputFieldComponent, withDebounce, debounceDelay = 0.5, onChange, onChangeValue, onClickRightIcon, holderRef, required, placeholder, ...props }, ref) {
|
|
133
|
-
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
134
|
-
const [_, debouncedValue, setDebouncedValue] = (0, hooks_1.useDebounceState)(props.value?.toString() ?? "", debounceDelay);
|
|
135
|
-
const styledComponentStylesWithoutExcluded = (0, hooks_1.useStyledComponentStyles)(props, theme, true);
|
|
136
|
-
const styledComponentStylesWithExcluded = (0, hooks_1.useComponentPropsWithExcludedStyle)(props);
|
|
137
|
-
const dataProps = (0, hooks_1.useComponentPropsWithPrefix)(props, "data");
|
|
138
|
-
const ariaProps = (0, hooks_1.useComponentPropsWithPrefix)(props, "aria");
|
|
139
|
-
const restProps = (0, hooks_1.useComponentPropsWithoutStyle)(props);
|
|
140
|
-
const onChangeElement = (0, react_1.useCallback)((event) => {
|
|
141
|
-
const newValue = event.target.value;
|
|
142
|
-
if (withDebounce) {
|
|
143
|
-
onChange?.(event);
|
|
144
|
-
setDebouncedValue(newValue);
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
onChange?.(event);
|
|
148
|
-
onChangeValue?.(newValue);
|
|
149
|
-
}
|
|
150
|
-
}, [onChange, onChangeValue, withDebounce]);
|
|
151
|
-
(0, react_1.useEffect)(() => {
|
|
152
|
-
if (!withDebounce)
|
|
153
|
-
return;
|
|
154
|
-
onChangeValue?.(debouncedValue);
|
|
155
|
-
}, [withDebounce, onChangeValue, debouncedValue]);
|
|
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
|
-
});
|
|
158
|
-
InputFieldComponent.multiline = (0, react_1.forwardRef)(function Multiline({ label, placeholder, errorText, infoText, leftIcon, rightIcon, onChange, onChangeValue, onClickRightIcon, required, ...props }, ref) {
|
|
159
|
-
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
160
|
-
const styledComponentStyles = (0, hooks_1.useStyledComponentStyles)(props, theme);
|
|
161
|
-
const dataProps = (0, hooks_1.useComponentPropsWithPrefix)(props, "data");
|
|
162
|
-
const ariaProps = (0, hooks_1.useComponentPropsWithPrefix)(props, "aria");
|
|
163
|
-
const restProps = (0, hooks_1.useComponentPropsWithoutStyle)(props);
|
|
164
|
-
const onChangeElement = (0, react_1.useCallback)((event) => {
|
|
165
|
-
onChange?.(event);
|
|
166
|
-
onChangeValue?.(event.target.value);
|
|
167
|
-
}, [onChange, onChangeValue]);
|
|
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
|
-
});
|
|
170
|
-
InputFieldComponent.email = (0, react_1.forwardRef)(function Email({ ...props }, ref) {
|
|
171
|
-
return ((0, jsx_runtime_1.jsx)(InputFieldComponent, { type: "email", placeholder: "your@email.here", autoComplete: "email", autoCorrect: "off", autoCapitalize: "off", ref: ref, ...props }));
|
|
172
|
-
});
|
|
173
|
-
InputFieldComponent.password = (0, react_1.forwardRef)(function Password({ ...props }, ref) {
|
|
174
|
-
const [isPassword, setIsPassword] = (0, hooks_1.useBooleanState)(true);
|
|
175
|
-
return ((0, jsx_runtime_1.jsx)(InputFieldComponent, { type: isPassword ? "password" : "text", placeholder: "******", rightIcon: isPassword ? "eye" : "eyeDashed", onClickRightIcon: setIsPassword.toggle, autoComplete: "current-password", autoCorrect: "off", autoCapitalize: "off", ref: ref, ...props }));
|
|
176
|
-
});
|
|
177
|
-
InputFieldComponent.search = (0, react_1.forwardRef)(function Search({ ...props }, ref) {
|
|
178
|
-
return (0, jsx_runtime_1.jsx)(InputFieldComponent, { leftIcon: "magnifyingGlass", placeholder: "Search...", ref: ref, ...props });
|
|
179
|
-
});
|
|
180
|
-
InputFieldComponent.phoneNumber = (0, react_1.forwardRef)(function PhoneNumber({ label, value, onChangeValue, labelColor, ...props }, ref) {
|
|
181
|
-
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
182
|
-
const [dropdownValue, setDropdownValue] = (0, react_1.useState)();
|
|
183
|
-
const [inputFieldValue, setInputFieldValue] = (0, react_1.useState)(value?.toString() ?? "");
|
|
184
|
-
const renderOption = (0, react_1.useCallback)((option, index, isSelected) => ((0, jsx_runtime_1.jsxs)(Div_1.default.row, { alignItems: "center", gap: theme.styles.gap, children: [(0, jsx_runtime_1.jsx)(Image_1.default, { src: `https://flagcdn.com/w80/${option.data?.code.toString().toLowerCase()}.webp`, width: 20 }), (0, jsx_runtime_1.jsx)(Text_1.default, { children: option.label })] })), []);
|
|
185
|
-
const onChangeValueElement = (0, react_1.useCallback)((value) => {
|
|
186
|
-
const readyValue = value.replace(/\D/g, "");
|
|
187
|
-
setInputFieldValue(readyValue);
|
|
188
|
-
onChangeValue?.(dropdownValue ? `+${dropdownValue}${readyValue}` : readyValue);
|
|
189
|
-
}, [onChangeValue, dropdownValue]);
|
|
190
|
-
const options = (0, react_1.useMemo)(() => countries_1.countries.map((country) => ({
|
|
191
|
-
value: country.phoneNumberExtension,
|
|
192
|
-
label: `+${country.phoneNumberExtension}`,
|
|
193
|
-
data: country,
|
|
194
|
-
})), []);
|
|
195
|
-
const defaultValue = (0, react_1.useMemo)(() => {
|
|
196
|
-
const thisTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
197
|
-
const initialDefaultValue = options.find((option) => option.data?.timeZone === thisTimeZone)?.value ?? "";
|
|
198
|
-
setDropdownValue(initialDefaultValue);
|
|
199
|
-
return initialDefaultValue;
|
|
200
|
-
}, [options]);
|
|
201
|
-
(0, react_1.useEffect)(() => {
|
|
202
|
-
if (value === undefined || value === null)
|
|
203
|
-
return;
|
|
204
|
-
const newValue = value.toString();
|
|
205
|
-
const country = countries_1.countries.find((country) => country.phoneNumberExtension ===
|
|
206
|
-
newValue.slice(newValue.startsWith("+") ? 1 : 0, country.phoneNumberExtension.length + (newValue.startsWith("+") ? 1 : 0)));
|
|
207
|
-
if (!country) {
|
|
208
|
-
setInputFieldValue(newValue);
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
setDropdownValue(country.phoneNumberExtension);
|
|
212
|
-
setInputFieldValue(newValue.slice(country?.phoneNumberExtension.length + 1));
|
|
213
|
-
}, [value]);
|
|
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
|
-
});
|
|
216
|
-
InputFieldComponent.date = (0, react_1.forwardRef)(function Date({ className, onFocus, onBlur, ...props }, ref) {
|
|
217
|
-
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
218
|
-
const holderRef = (0, react_1.useRef)(null);
|
|
219
|
-
const { internalValue, setInternalValue, inputFieldProps, insideInputFieldComponentProps } = (0, hooks_1.useComponentInputFieldDateProps)(props, holderRef);
|
|
220
|
-
return ((0, jsx_runtime_1.jsx)(InputFieldComponent, { type: "date", insideInputFieldComponent: (0, jsx_runtime_1.jsx)(Div_1.default, { position: "absolute", top: "100%", left: 0, width: "100%", maxHeight: 300, backgroundColor: theme.colors.backgroundContent, borderBottomLeftRadius: theme.styles.borderRadius, borderBottomRightRadius: theme.styles.borderRadius, boxShadow: "0px 10px 20px #00000020", overflowY: "auto", ...insideInputFieldComponentProps, children: "Hello there" }), holderRef: holderRef, ref: ref, ...props, ...inputFieldProps }));
|
|
221
|
-
});
|
|
222
|
-
InputFieldComponent.dateTime = (0, react_1.forwardRef)(function DateTime({ className, onFocus, onBlur, ...props }, ref) {
|
|
223
|
-
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
224
|
-
const holderRef = (0, react_1.useRef)(null);
|
|
225
|
-
const { internalValue, setInternalValue, inputFieldProps, insideInputFieldComponentProps } = (0, hooks_1.useComponentInputFieldDateProps)(props, holderRef);
|
|
226
|
-
return ((0, jsx_runtime_1.jsx)(InputFieldComponent, { type: "datetime-local", insideInputFieldComponent: (0, jsx_runtime_1.jsx)(Div_1.default, { position: "absolute", top: "100%", left: 0, width: "100%", maxHeight: 300, backgroundColor: theme.colors.backgroundContent, borderBottomLeftRadius: theme.styles.borderRadius, borderBottomRightRadius: theme.styles.borderRadius, boxShadow: "0px 10px 20px #00000020", overflowY: "auto", ...insideInputFieldComponentProps, children: "Hello there" }), holderRef: holderRef, ref: ref, ...props, ...inputFieldProps }));
|
|
227
|
-
});
|
|
228
|
-
InputFieldComponent.time = (0, react_1.forwardRef)(function Time({ ...props }, ref) {
|
|
229
|
-
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
230
|
-
const holderRef = (0, react_1.useRef)(null);
|
|
231
|
-
const selectedHourRef = (0, react_1.useRef)(null);
|
|
232
|
-
const selectedMinuteRef = (0, react_1.useRef)(null);
|
|
233
|
-
const { internalValue, setInternalValue, inputFieldProps, insideInputFieldComponentProps, isOpen } = (0, hooks_1.useComponentInputFieldDateProps)(props, holderRef);
|
|
234
|
-
const onClickHour = (0, react_1.useCallback)((hour) => {
|
|
235
|
-
const value = `${hour.toString().padStart(2, "0")}:${internalValue?.toString().split(":")[1] || "00"}`;
|
|
236
|
-
inputFieldProps.onChangeValue?.(value);
|
|
237
|
-
setInternalValue(value);
|
|
238
|
-
}, [internalValue, inputFieldProps.onChangeValue]);
|
|
239
|
-
const onClickMinute = (0, react_1.useCallback)((minute) => {
|
|
240
|
-
const value = `${internalValue?.toString().split(":")[0] || "00"}:${minute.toString().padStart(2, "0")}`;
|
|
241
|
-
inputFieldProps.onChangeValue?.(value);
|
|
242
|
-
setInternalValue(value);
|
|
243
|
-
}, [internalValue, inputFieldProps.onChangeValue]);
|
|
244
|
-
(0, react_1.useEffect)(() => {
|
|
245
|
-
if (isOpen && selectedHourRef.current)
|
|
246
|
-
selectedHourRef.current.scrollIntoView({ block: "nearest", behavior: "instant" });
|
|
247
|
-
if (isOpen && selectedMinuteRef.current)
|
|
248
|
-
selectedMinuteRef.current.scrollIntoView({ block: "nearest", behavior: "instant" });
|
|
249
|
-
}, [isOpen]);
|
|
250
|
-
const valueHour = parseInt(internalValue?.toString().split(":")?.[0]).toString();
|
|
251
|
-
const valueMinute = parseInt(internalValue?.toString().split(":")?.[1]).toString();
|
|
252
|
-
const buttonWidth = 50;
|
|
253
|
-
return ((0, jsx_runtime_1.jsx)(InputFieldComponent, { type: "time", insideInputFieldComponent: (0, jsx_runtime_1.jsx)(Div_1.default, { position: "absolute", top: "100%", left: 0, width: buttonWidth * 2 + 2, height: 300, backgroundColor: theme.colors.backgroundContent, borderBottomLeftRadius: theme.styles.borderRadius, borderBottomRightRadius: theme.styles.borderRadius, boxShadow: "0px 10px 20px #00000020", overflowY: "auto", ...insideInputFieldComponentProps, children: (0, jsx_runtime_1.jsxs)(Div_1.default.row, { height: "100%", children: [(0, jsx_runtime_1.jsx)(Div_1.default, { className: "react-better-html-no-scrollbar", width: buttonWidth, height: "100%", overflowY: "auto", children: hours.map((hour) => {
|
|
254
|
-
const isSelected = hour.toString() === valueHour;
|
|
255
|
-
return ((0, jsx_runtime_1.jsx)(Div_1.default.row, { alignItems: "center", justifyContent: "center", color: isSelected ? theme.colors.base : theme.colors.textPrimary, backgroundColor: isSelected ? theme.colors.primary : theme.colors.backgroundContent, filterHover: "brightness(0.9)", cursor: "pointer", padding: `${theme.styles.space / 2}px ${theme.styles.space + theme.styles.gap}px`, value: hour, onClickWithValue: onClickHour, ref: isSelected ? selectedHourRef : undefined, children: (0, jsx_runtime_1.jsx)(Text_1.default, { textAlign: "center", children: hour.toString().padStart(2, "0") }) }, hour));
|
|
256
|
-
}) }), (0, jsx_runtime_1.jsx)(Div_1.default, { className: "react-better-html-no-scrollbar", width: buttonWidth, height: "100%", overflowY: "auto", children: minutes.map((minute) => {
|
|
257
|
-
const isSelected = minute.toString() === valueMinute;
|
|
258
|
-
return ((0, jsx_runtime_1.jsx)(Div_1.default.row, { alignItems: "center", justifyContent: "center", color: isSelected ? theme.colors.base : theme.colors.textPrimary, backgroundColor: isSelected ? theme.colors.primary : theme.colors.backgroundContent, filterHover: "brightness(0.9)", cursor: "pointer", padding: `${theme.styles.space / 2}px ${theme.styles.space + theme.styles.gap}px`, value: minute, onClickWithValue: onClickMinute, ref: isSelected ? selectedMinuteRef : undefined, children: (0, jsx_runtime_1.jsx)(Text_1.default, { textAlign: "center", children: minute.toString().padStart(2, "0") }) }, minute));
|
|
259
|
-
}) })] }) }), holderRef: holderRef, ref: ref, ...props, ...inputFieldProps, minWidth: buttonWidth * 2 + 2 }));
|
|
260
|
-
});
|
|
261
|
-
const InputField = (0, react_1.memo)(InputFieldComponent);
|
|
262
|
-
InputField.multiline = InputFieldComponent.multiline;
|
|
263
|
-
InputField.email = InputFieldComponent.email;
|
|
264
|
-
InputField.password = InputFieldComponent.password;
|
|
265
|
-
InputField.search = InputFieldComponent.search;
|
|
266
|
-
InputField.phoneNumber = InputFieldComponent.phoneNumber;
|
|
267
|
-
InputField.date = InputFieldComponent.date;
|
|
268
|
-
InputField.dateTime = InputFieldComponent.dateTime;
|
|
269
|
-
InputField.time = InputFieldComponent.time;
|
|
270
|
-
exports.default = InputField;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type LabelProps = {
|
|
2
|
-
text?: string;
|
|
3
|
-
/** @default false */
|
|
4
|
-
required?: boolean;
|
|
5
|
-
/** @default false */
|
|
6
|
-
isError?: boolean;
|
|
7
|
-
color?: string;
|
|
8
|
-
};
|
|
9
|
-
declare function Label({ text, required, isError, color }: LabelProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
declare const _default: import("react").MemoExoticComponent<typeof Label>;
|
|
11
|
-
export default _default;
|
package/dist/components/Label.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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 Text_1 = __importDefault(require("./Text"));
|
|
9
|
-
const BetterHtmlProvider_1 = require("./BetterHtmlProvider");
|
|
10
|
-
function Label({ text, required, isError, color }) {
|
|
11
|
-
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
12
|
-
return ((0, jsx_runtime_1.jsxs)(Text_1.default, { as: "label", height: 16, fontSize: 14, color: isError ? theme.colors.error : color ?? theme.colors.textSecondary, children: [text, required && ((0, jsx_runtime_1.jsxs)(Text_1.default, { as: "span", fontSize: 16, color: theme.colors.error, children: [" ", "*"] }))] }));
|
|
13
|
-
}
|
|
14
|
-
exports.default = (0, react_1.memo)(Label);
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Color } from "../types/theme";
|
|
2
|
-
import { OmitProps } from "../types/app";
|
|
3
|
-
import { DivProps } from "./Div";
|
|
4
|
-
export type LoaderProps = {
|
|
5
|
-
/** @default textPrimary */
|
|
6
|
-
color?: Color;
|
|
7
|
-
/** @default 16 */
|
|
8
|
-
size?: number;
|
|
9
|
-
/** @default 5 */
|
|
10
|
-
width?: number;
|
|
11
|
-
/** @default false */
|
|
12
|
-
disabled?: boolean;
|
|
13
|
-
} & OmitProps<DivProps<unknown>, "width" | "height" | "color" | "background" | "borderRadius" | "mask" | "WebkitMask" | "padding" | "animation" | "animationName">;
|
|
14
|
-
type LoaderComponentType = {
|
|
15
|
-
(props: LoaderProps): React.ReactElement;
|
|
16
|
-
box: (props: OmitProps<LoaderProps, "size"> & {
|
|
17
|
-
/** @default "Loading..." */
|
|
18
|
-
text?: string;
|
|
19
|
-
/** @default 20 */
|
|
20
|
-
size?: number;
|
|
21
|
-
}) => React.ReactElement;
|
|
22
|
-
text: (props: OmitProps<LoaderProps, "size"> & {
|
|
23
|
-
/** @default "Loading..." */
|
|
24
|
-
text?: string;
|
|
25
|
-
/** @default 14 */
|
|
26
|
-
size?: number;
|
|
27
|
-
}) => React.ReactElement;
|
|
28
|
-
};
|
|
29
|
-
declare const LoaderComponent: LoaderComponentType;
|
|
30
|
-
declare const Loader: typeof LoaderComponent & {
|
|
31
|
-
box: typeof LoaderComponent.box;
|
|
32
|
-
text: typeof LoaderComponent.text;
|
|
33
|
-
};
|
|
34
|
-
export default Loader;
|
|
@@ -1,43 +0,0 @@
|
|
|
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 styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
-
const Div_1 = __importDefault(require("./Div"));
|
|
10
|
-
const Text_1 = __importDefault(require("./Text"));
|
|
11
|
-
const BetterHtmlProvider_1 = require("./BetterHtmlProvider");
|
|
12
|
-
const StyledDiv = (0, styled_components_1.default)(Div_1.default) `
|
|
13
|
-
@keyframes loaderAnimation {
|
|
14
|
-
to {
|
|
15
|
-
transform: rotate(360deg);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@keyframes textLoaderAnimation {
|
|
20
|
-
to {
|
|
21
|
-
clip-path: inset(0 -1ch 0 0);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
`;
|
|
25
|
-
const LoaderComponent = function Loader({ color, size = 16, width, disabled, ...props }) {
|
|
26
|
-
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
27
|
-
const readyColor = color ?? theme.colors.textPrimary;
|
|
28
|
-
const readyWidth = width ?? size / 3;
|
|
29
|
-
const mask = `radial-gradient(farthest-side, #0000 calc(100% - ${readyWidth}px), #000 0)`;
|
|
30
|
-
return ((0, jsx_runtime_1.jsx)(StyledDiv, { width: size + readyWidth * 2, height: size + readyWidth * 2, background: `radial-gradient(farthest-side, ${readyColor} 94%, #0000) top/${readyWidth}px ${readyWidth}px no-repeat, conic-gradient(#0000 30%, ${readyColor})`, borderRadius: 999, mask: mask, WebkitMask: mask, padding: readyWidth, animation: !disabled ? "loaderAnimation .6s infinite linear" : undefined, ...props }));
|
|
31
|
-
};
|
|
32
|
-
LoaderComponent.box = function Box({ text = "Loading...", size = 20, ...props }) {
|
|
33
|
-
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
34
|
-
return ((0, jsx_runtime_1.jsxs)(Div_1.default.column, { width: "100%", alignItems: "center", gap: theme.styles.gap, children: [(0, jsx_runtime_1.jsx)(Loader, { size: size, ...props }), text && ((0, jsx_runtime_1.jsx)(Text_1.default, { textAlign: "center", color: props.color ?? theme.colors.textSecondary, children: text }))] }));
|
|
35
|
-
};
|
|
36
|
-
LoaderComponent.text = function LoaderText({ text = "Loading...", size = 14, ...props }) {
|
|
37
|
-
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
38
|
-
return ((0, jsx_runtime_1.jsxs)(Div_1.default.row, { alignItems: "center", gap: theme.styles.gap, children: [(0, jsx_runtime_1.jsx)(Loader, { size: size, ...props }), text && ((0, jsx_runtime_1.jsx)(Text_1.default, { textAlign: "center", color: props.color ?? theme.colors.textSecondary, children: text }))] }));
|
|
39
|
-
};
|
|
40
|
-
const Loader = (0, react_1.memo)(LoaderComponent);
|
|
41
|
-
Loader.box = LoaderComponent.box;
|
|
42
|
-
Loader.text = LoaderComponent.text;
|
|
43
|
-
exports.default = Loader;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { ComponentPropWithRef } from "../types/components";
|
|
2
|
-
import { AnyOtherString, OmitProps } from "../types/app";
|
|
3
|
-
import { LoaderName } from "../types/loader";
|
|
4
|
-
export type ModalProps = {
|
|
5
|
-
/**
|
|
6
|
-
* If you want to have a small modal, you can use 660px as it looks good on most screens.
|
|
7
|
-
*
|
|
8
|
-
* @default 30% smaller than app.contentMaxWidth
|
|
9
|
-
* */
|
|
10
|
-
maxWidth?: number;
|
|
11
|
-
title?: string;
|
|
12
|
-
titleColor?: string;
|
|
13
|
-
description?: string;
|
|
14
|
-
descriptionColor?: string;
|
|
15
|
-
headerBackgroundColor?: string;
|
|
16
|
-
/** @requires ReactRouterDomPlugin */
|
|
17
|
-
name?: string;
|
|
18
|
-
overflow?: React.CSSProperties["overflow"];
|
|
19
|
-
onOpen?: () => void;
|
|
20
|
-
onClose?: () => void;
|
|
21
|
-
children?: React.ReactNode;
|
|
22
|
-
};
|
|
23
|
-
export type ModalRef = {
|
|
24
|
-
open: () => void;
|
|
25
|
-
close: () => void;
|
|
26
|
-
isOpened: boolean;
|
|
27
|
-
};
|
|
28
|
-
type ModalComponent = {
|
|
29
|
-
(props: ComponentPropWithRef<ModalRef, ModalProps>): React.ReactElement;
|
|
30
|
-
confirmation: (props: ComponentPropWithRef<ModalRef, OmitProps<ModalProps, "maxWidth" | "children" | "overflow"> & {
|
|
31
|
-
continueButtonLoaderName?: LoaderName | AnyOtherString;
|
|
32
|
-
onContinue?: () => void;
|
|
33
|
-
onCancel?: () => void;
|
|
34
|
-
}>) => React.ReactElement;
|
|
35
|
-
destructive: (props: ComponentPropWithRef<ModalRef, OmitProps<ModalProps, "maxWidth" | "children" | "overflow"> & {
|
|
36
|
-
deleteButtonLoaderName?: LoaderName | AnyOtherString;
|
|
37
|
-
onDelete?: () => void;
|
|
38
|
-
onCancel?: () => void;
|
|
39
|
-
}>) => React.ReactElement;
|
|
40
|
-
};
|
|
41
|
-
declare const ModalComponent: ModalComponent;
|
|
42
|
-
declare const Modal: typeof ModalComponent & {
|
|
43
|
-
confirmation: typeof ModalComponent.confirmation;
|
|
44
|
-
destructive: typeof ModalComponent.destructive;
|
|
45
|
-
};
|
|
46
|
-
export default Modal;
|
package/dist/components/Modal.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
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 styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
-
const hooks_1 = require("../utils/hooks");
|
|
10
|
-
const Div_1 = __importDefault(require("./Div"));
|
|
11
|
-
const Button_1 = __importDefault(require("./Button"));
|
|
12
|
-
const Text_1 = __importDefault(require("./Text"));
|
|
13
|
-
const Divider_1 = __importDefault(require("./Divider"));
|
|
14
|
-
const BetterHtmlProvider_1 = require("./BetterHtmlProvider");
|
|
15
|
-
const DialogStylesElement = styled_components_1.default.dialog.withConfig({
|
|
16
|
-
shouldForwardProp: (prop) => !["theme", "colorTheme", "opacity"].includes(prop),
|
|
17
|
-
}) `
|
|
18
|
-
width: 100%;
|
|
19
|
-
max-width: none;
|
|
20
|
-
height: 100%;
|
|
21
|
-
max-height: none;
|
|
22
|
-
color: ${(props) => props.theme.colors.textPrimary};
|
|
23
|
-
border: none;
|
|
24
|
-
outline: none;
|
|
25
|
-
background-color: transparent;
|
|
26
|
-
margin: auto auto;
|
|
27
|
-
padding-inline: ${(props) => props.theme.styles.gap}px;
|
|
28
|
-
opacity: ${(props) => props.opacity};
|
|
29
|
-
transition: ${(props) => props.theme.styles.transition};
|
|
30
|
-
|
|
31
|
-
&::backdrop {
|
|
32
|
-
background-color: ${(props) => (props.colorTheme === "light" ? "#000000a0" : "#222222e0")};
|
|
33
|
-
opacity: ${(props) => props.opacity};
|
|
34
|
-
transition: ${(props) => props.theme.styles.transition};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
@keyframes fadeInAnimation {
|
|
38
|
-
from {
|
|
39
|
-
transform: translateY(${(props) => props.theme.styles.space}px);
|
|
40
|
-
}
|
|
41
|
-
to {
|
|
42
|
-
transform: translateY(0px);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
@keyframes fadeOutAnimation {
|
|
47
|
-
from {
|
|
48
|
-
transform: translateY(0px);
|
|
49
|
-
}
|
|
50
|
-
to {
|
|
51
|
-
transform: translateY(${(props) => props.theme.styles.space}px);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
`;
|
|
55
|
-
const ModalComponent = (0, react_1.forwardRef)(function Modal({ maxWidth, title, titleColor, description, descriptionColor, headerBackgroundColor, name, overflow, onOpen, onClose, children, }, ref) {
|
|
56
|
-
const reactRouterDomPlugin = (0, BetterHtmlProvider_1.usePlugin)("react-router-dom");
|
|
57
|
-
const urlQuery = reactRouterDomPlugin ? (0, hooks_1.useUrlQuery)() : undefined;
|
|
58
|
-
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
59
|
-
const { app, colorTheme } = (0, BetterHtmlProvider_1.useBetterHtmlContext)();
|
|
60
|
-
const dialogRef = (0, react_1.useRef)(null);
|
|
61
|
-
const [isOpened, setIsOpened] = (0, react_1.useState)(false);
|
|
62
|
-
const [isOpenedLate, setIsOpenedLate] = (0, react_1.useState)(false);
|
|
63
|
-
const onClickOpen = (0, react_1.useCallback)(() => {
|
|
64
|
-
dialogRef.current?.showModal();
|
|
65
|
-
setIsOpened(true);
|
|
66
|
-
setIsOpenedLate(true);
|
|
67
|
-
if (urlQuery && name)
|
|
68
|
-
urlQuery.setQuery({
|
|
69
|
-
[`${name}-modal`]: "opened",
|
|
70
|
-
}, false);
|
|
71
|
-
onOpen?.();
|
|
72
|
-
}, [onOpen, urlQuery, name]);
|
|
73
|
-
const onClickClose = (0, react_1.useCallback)(() => {
|
|
74
|
-
setIsOpened(false);
|
|
75
|
-
onClose?.();
|
|
76
|
-
if (urlQuery && name)
|
|
77
|
-
urlQuery.removeQuery(`${name}-modal`, false);
|
|
78
|
-
setTimeout(() => {
|
|
79
|
-
dialogRef.current?.close();
|
|
80
|
-
setIsOpenedLate(false);
|
|
81
|
-
}, 0.2 * 1000);
|
|
82
|
-
}, [onClose, urlQuery, name]);
|
|
83
|
-
(0, react_1.useImperativeHandle)(ref, () => {
|
|
84
|
-
return {
|
|
85
|
-
open: onClickOpen,
|
|
86
|
-
close: onClickClose,
|
|
87
|
-
isOpened,
|
|
88
|
-
};
|
|
89
|
-
}, [onClickOpen, onClickClose, isOpened]);
|
|
90
|
-
return ((0, jsx_runtime_1.jsx)(DialogStylesElement, { theme: theme, colorTheme: colorTheme, 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 - 1, borderTopRightRadius: theme.styles.borderRadius * 2 - 1, paddingInline: theme.styles.space + theme.styles.gap, paddingBlock: theme.styles.space, transition: theme.styles.transition, 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, transition: theme.styles.transition, children: title }), description && ((0, jsx_runtime_1.jsx)(Text_1.default, { color: descriptionColor ?? theme.colors.textSecondary, transition: theme.styles.transition, children: description }))] }), (0, jsx_runtime_1.jsx)(Button_1.default.icon, { icon: "XMark", marginTop: 1, iconColor: titleColor, onClick: onClickClose, transition: theme.styles.transition })] }), (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 }));
|
|
91
|
-
});
|
|
92
|
-
ModalComponent.confirmation = (0, react_1.forwardRef)(function Confirmation({ continueButtonLoaderName, onContinue, onCancel, ...props }, ref) {
|
|
93
|
-
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
94
|
-
const modalRef = (0, react_1.useRef)(null);
|
|
95
|
-
const onCancelElement = (0, react_1.useCallback)(() => {
|
|
96
|
-
onCancel?.();
|
|
97
|
-
modalRef.current?.close();
|
|
98
|
-
}, [onCancel]);
|
|
99
|
-
const onContinueElement = (0, react_1.useCallback)(() => {
|
|
100
|
-
onContinue?.();
|
|
101
|
-
modalRef.current?.close();
|
|
102
|
-
}, [onContinue]);
|
|
103
|
-
(0, react_1.useImperativeHandle)(ref, () => modalRef.current, []);
|
|
104
|
-
return ((0, jsx_runtime_1.jsxs)(Modal, { title: "Are you sure?", maxWidth: 660, ...props, ref: modalRef, children: [(0, jsx_runtime_1.jsx)(Text_1.default, { color: theme.colors.textSecondary, children: "Do you really want to continue? This action may be irreversible." }), (0, jsx_runtime_1.jsxs)(Div_1.default.row, { alignItems: "center", justifyContent: "flex-end", gap: theme.styles.gap, marginTop: theme.styles.space * 2, children: [(0, jsx_runtime_1.jsx)(Button_1.default.secondary, { text: "Cancel", onClick: onCancelElement }), (0, jsx_runtime_1.jsx)(Button_1.default, { text: "Continue", loaderName: continueButtonLoaderName, onClick: onContinueElement })] })] }));
|
|
105
|
-
});
|
|
106
|
-
ModalComponent.destructive = (0, react_1.forwardRef)(function Destructive({ deleteButtonLoaderName, onDelete, onCancel, ...props }, ref) {
|
|
107
|
-
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
108
|
-
const modalRef = (0, react_1.useRef)(null);
|
|
109
|
-
const onCancelElement = (0, react_1.useCallback)(() => {
|
|
110
|
-
onCancel?.();
|
|
111
|
-
modalRef.current?.close();
|
|
112
|
-
}, [onCancel]);
|
|
113
|
-
const onDeleteElement = (0, react_1.useCallback)(() => {
|
|
114
|
-
onDelete?.();
|
|
115
|
-
modalRef.current?.close();
|
|
116
|
-
}, [onDelete]);
|
|
117
|
-
(0, react_1.useImperativeHandle)(ref, () => modalRef.current, []);
|
|
118
|
-
return ((0, jsx_runtime_1.jsxs)(Modal, { title: "Are you sure?", maxWidth: 660, ...props, ref: modalRef, children: [(0, jsx_runtime_1.jsx)(Text_1.default, { color: theme.colors.textSecondary, children: "Do you really want to continue with the deleting of the item? This action may be irreversible." }), (0, jsx_runtime_1.jsxs)(Div_1.default.row, { alignItems: "center", justifyContent: "flex-end", gap: theme.styles.gap, marginTop: theme.styles.space * 2, children: [(0, jsx_runtime_1.jsx)(Button_1.default.secondary, { text: "Cancel", onClick: onCancelElement }), (0, jsx_runtime_1.jsx)(Button_1.default.destructive, { icon: "trash", text: "Delete", loaderName: deleteButtonLoaderName, onClick: onDeleteElement })] })] }));
|
|
119
|
-
});
|
|
120
|
-
const Modal = (0, react_1.memo)(ModalComponent);
|
|
121
|
-
Modal.confirmation = ModalComponent.confirmation;
|
|
122
|
-
Modal.destructive = ModalComponent.destructive;
|
|
123
|
-
exports.default = Modal;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ComponentMarginProps } from "../types/components";
|
|
3
|
-
import { TextAs } from "./Text";
|
|
4
|
-
export type PageHeaderProps = {
|
|
5
|
-
imageUrl?: string;
|
|
6
|
-
imageSize?: number;
|
|
7
|
-
title?: string;
|
|
8
|
-
titleAs?: TextAs;
|
|
9
|
-
titleRightElement?: React.ReactNode;
|
|
10
|
-
description?: string;
|
|
11
|
-
textAlign?: React.CSSProperties["textAlign"];
|
|
12
|
-
rightElement?: React.ReactNode;
|
|
13
|
-
/** @default false */
|
|
14
|
-
lightMode?: boolean;
|
|
15
|
-
} & Pick<ComponentMarginProps, "marginBottom">;
|
|
16
|
-
declare function PageHeader({ imageUrl, imageSize, title, titleAs, titleRightElement, description, textAlign, rightElement, lightMode, marginBottom, }: PageHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
-
declare const _default: React.MemoExoticComponent<typeof PageHeader>;
|
|
18
|
-
export default _default;
|
|
@@ -1,19 +0,0 @@
|
|
|
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 hooks_1 = require("../utils/hooks");
|
|
9
|
-
const Div_1 = __importDefault(require("./Div"));
|
|
10
|
-
const Text_1 = __importDefault(require("./Text"));
|
|
11
|
-
const Image_1 = __importDefault(require("./Image"));
|
|
12
|
-
const BetterHtmlProvider_1 = require("./BetterHtmlProvider");
|
|
13
|
-
function PageHeader({ imageUrl, imageSize = 60, title, titleAs, titleRightElement, description, textAlign, rightElement, lightMode, marginBottom, }) {
|
|
14
|
-
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
15
|
-
const { app } = (0, BetterHtmlProvider_1.useBetterHtmlContext)();
|
|
16
|
-
const mediaQuery = (0, hooks_1.useMediaQuery)();
|
|
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] }));
|
|
18
|
-
}
|
|
19
|
-
exports.default = (0, react_1.memo)(PageHeader);
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export type PageHolderProps = {
|
|
2
|
-
/** @default false */
|
|
3
|
-
noMaxContentWidth?: boolean;
|
|
4
|
-
children?: React.ReactNode;
|
|
5
|
-
};
|
|
6
|
-
declare function PageHolder({ noMaxContentWidth, children }: PageHolderProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
declare const _default: import("react").MemoExoticComponent<typeof PageHolder>;
|
|
8
|
-
export default _default;
|
|
@@ -1,15 +0,0 @@
|
|
|
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 BetterHtmlProvider_1 = require("./BetterHtmlProvider");
|
|
10
|
-
function PageHolder({ noMaxContentWidth, children }) {
|
|
11
|
-
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
12
|
-
const { app } = (0, BetterHtmlProvider_1.useBetterHtmlContext)();
|
|
13
|
-
return ((0, jsx_runtime_1.jsx)(Div_1.default, { as: "main", width: "100%", maxWidth: !noMaxContentWidth ? app.contentMaxWidth : undefined, margin: "0px auto", padding: theme.styles.space, children: children }));
|
|
14
|
-
}
|
|
15
|
-
exports.default = (0, react_1.memo)(PageHolder);
|