react-better-html 1.1.72 → 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.
Files changed (97) hide show
  1. package/dist/index.d.mts +686 -0
  2. package/dist/index.d.ts +686 -34
  3. package/dist/index.js +6302 -101
  4. package/dist/index.js.map +1 -0
  5. package/dist/index.mjs +6231 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/package.json +4 -3
  8. package/dist/components/BetterHtmlProvider.d.ts +0 -29
  9. package/dist/components/BetterHtmlProvider.js +0 -161
  10. package/dist/components/Button.d.ts +0 -65
  11. package/dist/components/Button.js +0 -166
  12. package/dist/components/Chip.d.ts +0 -20
  13. package/dist/components/Chip.js +0 -20
  14. package/dist/components/ColorThemeSwitch.d.ts +0 -15
  15. package/dist/components/ColorThemeSwitch.js +0 -54
  16. package/dist/components/Div.d.ts +0 -30
  17. package/dist/components/Div.js +0 -60
  18. package/dist/components/Divider.d.ts +0 -21
  19. package/dist/components/Divider.js +0 -20
  20. package/dist/components/Dropdown.d.ts +0 -48
  21. package/dist/components/Dropdown.js +0 -160
  22. package/dist/components/ExampleComponent.d.ts +0 -5
  23. package/dist/components/ExampleComponent.js +0 -10
  24. package/dist/components/Form.d.ts +0 -25
  25. package/dist/components/Form.js +0 -27
  26. package/dist/components/FormRow.d.ts +0 -32
  27. package/dist/components/FormRow.js +0 -28
  28. package/dist/components/Icon.d.ts +0 -13
  29. package/dist/components/Icon.js +0 -36
  30. package/dist/components/Image.d.ts +0 -18
  31. package/dist/components/Image.js +0 -44
  32. package/dist/components/InputField.d.ts +0 -44
  33. package/dist/components/InputField.js +0 -270
  34. package/dist/components/Label.d.ts +0 -11
  35. package/dist/components/Label.js +0 -14
  36. package/dist/components/Loader.d.ts +0 -34
  37. package/dist/components/Loader.js +0 -43
  38. package/dist/components/Modal.d.ts +0 -46
  39. package/dist/components/Modal.js +0 -123
  40. package/dist/components/PageHeader.d.ts +0 -18
  41. package/dist/components/PageHeader.js +0 -19
  42. package/dist/components/PageHolder.d.ts +0 -8
  43. package/dist/components/PageHolder.js +0 -15
  44. package/dist/components/Table.d.ts +0 -45
  45. package/dist/components/Table.js +0 -159
  46. package/dist/components/Text.d.ts +0 -18
  47. package/dist/components/Text.js +0 -38
  48. package/dist/components/ToggleInput.d.ts +0 -20
  49. package/dist/components/ToggleInput.js +0 -161
  50. package/dist/constants/app.d.ts +0 -2
  51. package/dist/constants/app.js +0 -6
  52. package/dist/constants/assets.d.ts +0 -2
  53. package/dist/constants/assets.js +0 -6
  54. package/dist/constants/countries.d.ts +0 -2
  55. package/dist/constants/countries.js +0 -1482
  56. package/dist/constants/css.d.ts +0 -1
  57. package/dist/constants/css.js +0 -1291
  58. package/dist/constants/icons.d.ts +0 -2
  59. package/dist/constants/icons.js +0 -85
  60. package/dist/constants/theme.d.ts +0 -2
  61. package/dist/constants/theme.js +0 -50
  62. package/dist/constants.d.ts +0 -1
  63. package/dist/constants.js +0 -4
  64. package/dist/plugins/index.d.ts +0 -1
  65. package/dist/plugins/index.js +0 -17
  66. package/dist/plugins/react-router-dom.d.ts +0 -2
  67. package/dist/plugins/react-router-dom.js +0 -14
  68. package/dist/types/app.d.ts +0 -15
  69. package/dist/types/app.js +0 -2
  70. package/dist/types/asset.d.ts +0 -4
  71. package/dist/types/asset.js +0 -2
  72. package/dist/types/components.d.ts +0 -13
  73. package/dist/types/components.js +0 -2
  74. package/dist/types/config.d.ts +0 -23
  75. package/dist/types/config.js +0 -2
  76. package/dist/types/countries.d.ts +0 -7
  77. package/dist/types/countries.js +0 -2
  78. package/dist/types/icon.d.ts +0 -11
  79. package/dist/types/icon.js +0 -2
  80. package/dist/types/loader.d.ts +0 -4
  81. package/dist/types/loader.js +0 -2
  82. package/dist/types/other.d.ts +0 -1
  83. package/dist/types/other.js +0 -2
  84. package/dist/types/plugin.d.ts +0 -7
  85. package/dist/types/plugin.js +0 -2
  86. package/dist/types/theme.d.ts +0 -19
  87. package/dist/types/theme.js +0 -2
  88. package/dist/utils/functions.d.ts +0 -16
  89. package/dist/utils/functions.js +0 -77
  90. package/dist/utils/hooks.d.ts +0 -86
  91. package/dist/utils/hooks.js +0 -450
  92. package/dist/utils/logger.d.ts +0 -41
  93. package/dist/utils/logger.js +0 -66
  94. package/dist/utils/variableFunctions.d.ts +0 -6
  95. package/dist/utils/variableFunctions.js +0 -28
  96. package/dist/utils/withPlugin.d.ts +0 -4
  97. package/dist/utils/withPlugin.js +0 -15
@@ -1,21 +0,0 @@
1
- import { ComponentMarginProps } from "../types/components";
2
- type DividerProps = {
3
- /** @default 1 */
4
- width?: number;
5
- /** @default border */
6
- backgroundColor?: string;
7
- } & ComponentMarginProps;
8
- export type VerticalDividerProps = DividerProps & {
9
- /** @default "100%" */
10
- height?: number;
11
- };
12
- export type HorizontalDividerProps = DividerProps & {
13
- text?: string;
14
- /** @default textSecondary */
15
- textColor?: string;
16
- };
17
- declare const _default: {
18
- vertical: import("react").NamedExoticComponent<VerticalDividerProps>;
19
- horizontal: import("react").NamedExoticComponent<HorizontalDividerProps>;
20
- };
21
- export default _default;
@@ -1,20 +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 Text_1 = __importDefault(require("./Text"));
10
- const BetterHtmlProvider_1 = require("./BetterHtmlProvider");
11
- exports.default = {
12
- vertical: (0, react_1.memo)(function Divider({ width = 1, backgroundColor, height, ...props }) {
13
- const theme = (0, BetterHtmlProvider_1.useTheme)();
14
- return ((0, jsx_runtime_1.jsx)(Div_1.default, { width: width, height: height ?? "100%", flexShrink: 0, backgroundColor: backgroundColor ?? theme.colors.border, ...props }));
15
- }),
16
- horizontal: (0, react_1.memo)(function Divider({ width = 1, backgroundColor, text, textColor, ...props }) {
17
- const theme = (0, BetterHtmlProvider_1.useTheme)();
18
- return ((0, jsx_runtime_1.jsxs)(Div_1.default.row, { width: "100%", alignItems: "center", gap: text ? theme.styles.space : undefined, ...props, children: [(0, jsx_runtime_1.jsx)(Div_1.default, { flex: 1, height: width, flexShrink: 0, backgroundColor: backgroundColor ?? theme.colors.border }), text && (0, jsx_runtime_1.jsx)(Text_1.default, { color: textColor ?? theme.colors.textSecondary, children: text }), (0, jsx_runtime_1.jsx)(Div_1.default, { flex: 1, height: width, flexShrink: 0, backgroundColor: backgroundColor ?? theme.colors.border })] }));
19
- }),
20
- };
@@ -1,48 +0,0 @@
1
- import { ComponentPropWithRef } from "../types/components";
2
- import { AnyOtherString, OmitProps } from "../types/app";
3
- import { IconName } from "../types/icon";
4
- import { DivProps } from "./Div";
5
- export type DropdownOption<Value, Data = unknown> = {
6
- value: Value;
7
- label: string;
8
- /** @default false */
9
- disabled?: boolean;
10
- searchValues?: string[];
11
- data?: Data;
12
- };
13
- export type DropdownProps<Value, Data = unknown> = {
14
- label?: string;
15
- labelColor?: string;
16
- errorText?: string;
17
- infoText?: string;
18
- /** @default false */
19
- required?: boolean;
20
- /** @default false */
21
- disabled?: boolean;
22
- options: DropdownOption<Value, Data>[];
23
- value?: Value;
24
- defaultValue?: Value;
25
- placeholder?: string;
26
- leftIcon?: IconName | AnyOtherString;
27
- inputFieldClassName?: string;
28
- /** @default false */
29
- withSearch?: boolean;
30
- /** @default false */
31
- withDebounce?: boolean;
32
- /** @default 0.5s */
33
- debounceDelay?: number;
34
- /** @default false */
35
- debounceIsLoading?: boolean;
36
- debounceMinimumSymbolsRequired?: number;
37
- /** @default false */
38
- withoutClearButton?: boolean;
39
- onChange?: (value: Value | undefined) => void;
40
- onChangeSearch?: (query: string) => void;
41
- renderOption?: (option: DropdownOption<Value, Data>, index: number, isSelected: boolean) => React.ReactNode;
42
- } & OmitProps<DivProps<unknown>, "onChange" | "defaultChecked">;
43
- type DropdownComponentType = {
44
- <Value, Data>(props: ComponentPropWithRef<HTMLDivElement, DropdownProps<Value, Data>>): React.ReactElement;
45
- };
46
- declare const DropdownComponent: DropdownComponentType;
47
- declare const Dropdown: typeof DropdownComponent & {};
48
- export default Dropdown;
@@ -1,160 +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 hooks_2 = require("../utils/hooks");
10
- const Text_1 = __importDefault(require("./Text"));
11
- const Div_1 = __importDefault(require("./Div"));
12
- const InputField_1 = __importDefault(require("./InputField"));
13
- const Icon_1 = __importDefault(require("./Icon"));
14
- const Button_1 = __importDefault(require("./Button"));
15
- const Loader_1 = __importDefault(require("./Loader"));
16
- const BetterHtmlProvider_1 = require("./BetterHtmlProvider");
17
- const DropdownComponent = (0, react_1.forwardRef)(function Dropdown({ label, labelColor, errorText, infoText, required, disabled, options, value: controlledValue, defaultValue, placeholder, leftIcon, inputFieldClassName, withSearch, withDebounce, debounceDelay = 0.5, debounceIsLoading, debounceMinimumSymbolsRequired, withoutClearButton, onChange, onChangeSearch, renderOption, ...props }, ref) {
18
- const theme = (0, BetterHtmlProvider_1.useTheme)();
19
- const dropdownHolderRef = (0, react_1.useRef)(null);
20
- const inputRef = (0, react_1.useRef)(null);
21
- const [isOpen, setIsOpen] = (0, hooks_1.useBooleanState)();
22
- const [isOpenLate, setIsOpenLate] = (0, hooks_1.useBooleanState)();
23
- const [isFocused, setIsFocused] = (0, hooks_1.useBooleanState)();
24
- const [searchQuery, setSearchQuery] = (0, react_1.useState)("");
25
- const [_, debouncedSearchQuery, setDebouncedSearchQuery, isLoadingDebouncedSearchQuery] = (0, hooks_2.useDebounceState)("", debounceDelay);
26
- const [focusedOptionIndex, setFocusedOptionIndex] = (0, react_1.useState)();
27
- const [internalValue, setInternalValue] = (0, react_1.useState)(defaultValue);
28
- const value = controlledValue ?? internalValue;
29
- const filteredOptions = (0, react_1.useMemo)(() => {
30
- if (!searchQuery)
31
- return options;
32
- const query = searchQuery.toLowerCase();
33
- return options.filter((option) => option.label.toLowerCase().includes(query) ||
34
- option.searchValues?.some((value) => value.toLowerCase().includes(query)));
35
- }, [options, searchQuery]);
36
- const onKeyDownInputField = (0, react_1.useCallback)((event) => {
37
- if (event.key === "Enter" || (!withSearch && event.key === " ")) {
38
- event.preventDefault();
39
- if (!disabled) {
40
- setIsOpen.toggle();
41
- if (isOpen && filteredOptions.length > 0 && focusedOptionIndex !== undefined) {
42
- const option = filteredOptions[focusedOptionIndex];
43
- if (!option.disabled) {
44
- if (controlledValue === undefined)
45
- setInternalValue(option.value);
46
- onChange?.(option.value);
47
- setIsOpen.setFalse();
48
- inputRef.current?.blur();
49
- setSearchQuery("");
50
- setFocusedOptionIndex(undefined);
51
- }
52
- }
53
- }
54
- }
55
- else if (event.key === "Escape") {
56
- setIsOpen.setFalse();
57
- setFocusedOptionIndex(undefined);
58
- }
59
- else if (event.key === "ArrowDown") {
60
- event.preventDefault();
61
- if (!isOpen)
62
- setIsOpen.setTrue();
63
- if (filteredOptions.length > 0) {
64
- setFocusedOptionIndex((oldValue) => oldValue === undefined ? 0 : (oldValue + 1) % filteredOptions.length);
65
- }
66
- }
67
- else if (event.key === "ArrowUp") {
68
- event.preventDefault();
69
- if (!isOpen)
70
- setIsOpen.setTrue();
71
- if (filteredOptions.length > 0) {
72
- setFocusedOptionIndex((oldValue) => oldValue === undefined
73
- ? filteredOptions.length - 1
74
- : (oldValue - 1 + filteredOptions.length) % filteredOptions.length);
75
- }
76
- }
77
- }, [disabled, withSearch, isOpen, filteredOptions, focusedOptionIndex, controlledValue, onChange]);
78
- const onClickOption = (0, react_1.useCallback)((option) => {
79
- if (!option.disabled) {
80
- if (controlledValue === undefined)
81
- setInternalValue(option.value);
82
- onChange?.(option.value);
83
- setIsOpen.setFalse();
84
- inputRef.current?.blur();
85
- setSearchQuery("");
86
- setFocusedOptionIndex(undefined);
87
- }
88
- }, [onChange, controlledValue]);
89
- const onClickClearButton = (0, react_1.useCallback)((event) => {
90
- event.stopPropagation();
91
- setInternalValue(undefined);
92
- onChange?.(undefined);
93
- setIsOpen.setFalse();
94
- inputRef.current?.blur();
95
- setSearchQuery("");
96
- setFocusedOptionIndex(undefined);
97
- }, [onChange]);
98
- const onChangeValue = (0, react_1.useCallback)((newValue) => {
99
- setSearchQuery(newValue);
100
- if (withDebounce)
101
- setDebouncedSearchQuery(newValue);
102
- else
103
- onChangeSearch?.(newValue);
104
- }, [withDebounce, onChangeSearch]);
105
- const selectedOption = (0, react_1.useMemo)(() => options.find((option) => option.value === value), [options, value]);
106
- (0, react_1.useEffect)(() => {
107
- if (isOpen) {
108
- setIsOpenLate.setTrue();
109
- if (withSearch && inputRef.current)
110
- inputRef.current.focus();
111
- }
112
- else {
113
- const timeout = setTimeout(setIsOpenLate.setFalse, 0.2 * 1000);
114
- return () => {
115
- clearTimeout(timeout);
116
- };
117
- }
118
- }, [isOpen, withSearch]);
119
- (0, react_1.useEffect)(() => {
120
- setFocusedOptionIndex(undefined);
121
- }, [filteredOptions]);
122
- (0, react_1.useEffect)(() => {
123
- const handleClickOutside = (event) => {
124
- if (dropdownHolderRef.current && !dropdownHolderRef.current.contains(event.target)) {
125
- setIsOpen.setFalse();
126
- setSearchQuery("");
127
- setFocusedOptionIndex(undefined);
128
- }
129
- };
130
- if (isOpen) {
131
- document.addEventListener("mousedown", handleClickOutside);
132
- }
133
- return () => {
134
- document.removeEventListener("mousedown", handleClickOutside);
135
- };
136
- }, [isOpen]);
137
- (0, react_1.useEffect)(() => {
138
- if (!withDebounce)
139
- return;
140
- onChangeSearch?.(debouncedSearchQuery);
141
- }, [withDebounce, onChangeSearch, debouncedSearchQuery]);
142
- const displayValue = withSearch && isFocused ? searchQuery : selectedOption?.label ?? "";
143
- const withClearButton = isOpen && selectedOption;
144
- const readyPlaceholder = placeholder ? placeholder : `Select an ${label?.toLowerCase() ?? "option"}`;
145
- return ((0, jsx_runtime_1.jsx)(Div_1.default.column, { width: "100%", position: "relative", userSelect: "none", ...props, ref: dropdownHolderRef, children: (0, jsx_runtime_1.jsxs)(Div_1.default.row, { position: "relative", width: "100%", children: [(0, jsx_runtime_1.jsx)(InputField_1.default, { label: label, labelColor: labelColor, errorText: errorText, infoText: infoText, required: required, disabled: disabled, readOnly: !withSearch, value: displayValue, cursor: !withSearch ? "pointer" : undefined, placeholder: withSearch ? (selectedOption ? selectedOption.label : readyPlaceholder) : readyPlaceholder, leftIcon: leftIcon, className: `react-better-html-dropdown${isOpen ? " react-better-html-dropdown-open" : ""}${isOpenLate ? " react-better-html-dropdown-open-late" : ""}${inputFieldClassName ? ` ${inputFieldClassName}` : ""}`, onClick: !disabled ? setIsOpen.toggle : undefined, onFocus: setIsFocused.setTrue, onBlur: setIsFocused.setFalse, onKeyDown: onKeyDownInputField, onChangeValue: withSearch ? onChangeValue : undefined, insideInputFieldComponent: (0, jsx_runtime_1.jsx)(Div_1.default, { position: "absolute", top: "100%", left: 0, width: "100%", maxHeight: 300, backgroundColor: theme.colors.backgroundContent, border: `1px solid ${isFocused ? theme.colors.primary : theme.colors.border}`, borderTop: "none", borderBottomLeftRadius: theme.styles.borderRadius, borderBottomRightRadius: theme.styles.borderRadius, boxShadow: "0px 10px 20px #00000020", zIndex: 1000, overflowY: "auto", opacity: !isOpen ? 0 : undefined, pointerEvents: !isOpen ? "none" : undefined, transform: `translateY(${!isOpen ? -10 : 0}px)`, transition: theme.styles.transition, role: "listbox", "aria-label": label, children: isLoadingDebouncedSearchQuery || debounceIsLoading ? ((0, jsx_runtime_1.jsx)(Div_1.default, { padding: `${theme.styles.space / 2}px ${theme.styles.space + theme.styles.gap}px`, children: (0, jsx_runtime_1.jsx)(Loader_1.default.text, {}) })) : filteredOptions.length ? (filteredOptions.map((option, index) => {
146
- const isSelected = option.value === value;
147
- const isDisabled = option.disabled;
148
- const isFocused = index === focusedOptionIndex;
149
- return ((0, jsx_runtime_1.jsx)(Div_1.default, { color: isDisabled
150
- ? theme.colors.textSecondary + "80"
151
- : isSelected
152
- ? theme.colors.base
153
- : theme.colors.textPrimary, backgroundColor: isSelected ? theme.colors.primary : theme.colors.backgroundContent, filter: isFocused ? (isDisabled ? "brightness(0.95)" : "brightness(0.9)") : undefined, filterHover: focusedOptionIndex === undefined && !isDisabled ? "brightness(0.9)" : undefined, cursor: isDisabled ? "not-allowed" : "pointer", padding: `${theme.styles.space / 2}px ${theme.styles.space + theme.styles.gap}px`, value: option, onClickWithValue: onClickOption, onMouseMove: () => setFocusedOptionIndex(undefined), role: "option", "aria-selected": isSelected, "aria-disabled": isDisabled, children: renderOption ? renderOption(option, index, isSelected) : (0, jsx_runtime_1.jsx)(Text_1.default, { children: option.label }) }, JSON.stringify(option)));
154
- })) : ((0, jsx_runtime_1.jsx)(Div_1.default, { padding: `${theme.styles.space / 2}px ${theme.styles.space + theme.styles.gap}px`, children: (0, jsx_runtime_1.jsx)(Text_1.default.unknown, { textAlign: "left", children: debounceMinimumSymbolsRequired !== undefined &&
155
- searchQuery.length < debounceMinimumSymbolsRequired
156
- ? `Enter at least ${debounceMinimumSymbolsRequired} characters`
157
- : "No options" }) })) }), role: "combobox", "aria-expanded": isOpen, "aria-controls": "dropdown-list", "aria-haspopup": "listbox", "aria-label": label, ref: inputRef }), (0, jsx_runtime_1.jsxs)(Div_1.default.row, { position: "absolute", top: 46 / 2 + (label ? 16 + theme.styles.gap / 2 : 0), right: theme.styles.space + 1, alignItems: "center", gap: theme.styles.gap, transform: "translateY(-50%)", pointerEvents: "none", filter: disabled ? "brightness(0.9)" : undefined, opacity: disabled ? 0.6 : undefined, zIndex: isOpen || isOpenLate ? 1001 : undefined, children: [!withoutClearButton && ((0, jsx_runtime_1.jsx)(Button_1.default.icon, { icon: "XMark", position: "relative", size: 10, iconSize: 14, opacity: !withClearButton ? 0 : undefined, pointerEvents: withClearButton ? "all" : undefined, onClick: onClickClearButton, disabled: !withClearButton })), (0, jsx_runtime_1.jsx)(Icon_1.default, { name: "chevronDown", position: "relative", size: 16, color: theme.colors.textSecondary, transform: `rotate(${isOpen ? 180 : 0}deg)`, transition: theme.styles.transition, pointerEvents: "none" })] })] }) }));
158
- });
159
- const Dropdown = (0, react_1.memo)(DropdownComponent);
160
- exports.default = Dropdown;
@@ -1,5 +0,0 @@
1
- type ExampleComponentProps = {
2
- test?: string;
3
- };
4
- declare const _default: import("react").MemoExoticComponent<import("react").ComponentType<ExampleComponentProps>>;
5
- export default _default;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const jsx_runtime_1 = require("react/jsx-runtime");
4
- const react_1 = require("react");
5
- const withPlugin_1 = require("../utils/withPlugin");
6
- function ExampleComponent({ test, plugin }) {
7
- const { Link } = plugin.components || {};
8
- return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("h1", { children: ["Example Component with Router Plugin: ", test] }), (0, jsx_runtime_1.jsx)(Link, { to: "/", children: "Go to Home Page" })] }));
9
- }
10
- exports.default = (0, react_1.memo)((0, withPlugin_1.withPlugin)("react-router-dom", ExampleComponent));
@@ -1,25 +0,0 @@
1
- import { ComponentMarginProps } from "../types/components";
2
- import { LoaderName } from "../types/loader";
3
- import { AnyOtherString, OmitProps } from "../types/app";
4
- import { useForm } from "../utils/hooks";
5
- export type FormProps = {
6
- form?: OmitProps<ReturnType<typeof useForm>, "focusField">;
7
- submitButtonText?: string;
8
- submitButtonLoaderName?: LoaderName | AnyOtherString;
9
- submitButtonId?: string;
10
- /** @default false */
11
- submitButtonIsDisabled?: boolean;
12
- /** @default "right" */
13
- actionButtonsLocation?: "left" | "center" | "right";
14
- gap?: React.CSSProperties["gap"];
15
- /** @default false */
16
- isSubmitting?: boolean;
17
- /** @default false */
18
- isDestructive?: boolean;
19
- onClickCancel?: () => void;
20
- onSubmit?: (value: React.FormEvent<HTMLFormElement>) => void;
21
- children?: React.ReactNode;
22
- } & ComponentMarginProps;
23
- declare function Form({ form, submitButtonText, submitButtonLoaderName, submitButtonId, submitButtonIsDisabled, actionButtonsLocation, gap, isSubmitting, isDestructive, onClickCancel, onSubmit, children, ...props }: FormProps): import("react/jsx-runtime").JSX.Element;
24
- declare const _default: import("react").MemoExoticComponent<typeof Form>;
25
- export default _default;
@@ -1,27 +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 Button_1 = __importDefault(require("./Button"));
10
- const BetterHtmlProvider_1 = require("./BetterHtmlProvider");
11
- function Form({ form, submitButtonText, submitButtonLoaderName, submitButtonId, submitButtonIsDisabled, actionButtonsLocation = "right", gap, isSubmitting, isDestructive, onClickCancel, onSubmit, children, ...props }) {
12
- const theme = (0, BetterHtmlProvider_1.useTheme)();
13
- const submitButtonIsDisabledInternal = (0, react_1.useMemo)(() => {
14
- if (!form || !form.requiredFields)
15
- return false;
16
- return Object.entries(form.values).some(([key, value]) => form.requiredFields?.includes(key) &&
17
- (value === undefined || value === null || value?.toString().trim() === ""));
18
- }, [form]);
19
- const SubmitButtonTag = isDestructive ? Button_1.default.destructive : Button_1.default;
20
- const submitButtonIsDisabledFinal = submitButtonIsDisabled || submitButtonIsDisabledInternal;
21
- return ((0, jsx_runtime_1.jsx)(Div_1.default, { width: "100%", ...props, children: (0, jsx_runtime_1.jsxs)("form", { onSubmit: onSubmit ?? form?.onSubmit, children: [gap !== undefined ? (0, jsx_runtime_1.jsx)(Div_1.default.column, { gap: gap, children: children }) : children, submitButtonText && ((0, jsx_runtime_1.jsxs)(Div_1.default.row, { alignItems: "center", justifyContent: actionButtonsLocation === "left"
22
- ? "flex-start"
23
- : actionButtonsLocation === "center"
24
- ? "center"
25
- : "flex-end", gap: theme.styles.gap, marginTop: theme.styles.space, children: [onClickCancel && (0, jsx_runtime_1.jsx)(Button_1.default.secondary, { text: "Cancel", onClick: onClickCancel }), (0, jsx_runtime_1.jsx)(SubmitButtonTag, { text: submitButtonText, isLoading: isSubmitting || form?.isSubmitting, loaderName: submitButtonLoaderName, disabled: submitButtonIsDisabledFinal, id: submitButtonId, isSubmit: true })] }))] }) }));
26
- }
27
- exports.default = (0, react_1.memo)(Form);
@@ -1,32 +0,0 @@
1
- import { IconName } from "../types/icon";
2
- import { AnyOtherString } from "../types/app";
3
- import { ComponentMarginProps, ComponentPropWithRef } from "../types/components";
4
- import { LoaderName } from "../types/loader";
5
- export type FormRowProps = {
6
- oneItemOnly?: boolean;
7
- /**
8
- * @description Weather to break the two items into two separate lines on mobile or not
9
- * @default false
10
- */
11
- noBreakingPoint?: boolean;
12
- gap?: React.CSSProperties["gap"];
13
- children?: React.ReactNode;
14
- } & ComponentMarginProps;
15
- type FormRowComponentType = {
16
- (props: ComponentPropWithRef<HTMLDivElement, FormRowProps>): React.ReactElement;
17
- withTitle: (props: ComponentPropWithRef<HTMLDivElement, FormRowProps & {
18
- icon?: IconName | AnyOtherString;
19
- title?: string;
20
- description?: string;
21
- withActions?: boolean;
22
- saveButtonLoaderName?: LoaderName | AnyOtherString;
23
- resetButtonLoaderName?: LoaderName | AnyOtherString;
24
- onClickSave?: () => void;
25
- onClickReset?: () => void;
26
- }>) => React.ReactElement;
27
- };
28
- declare const FormRowComponent: FormRowComponentType;
29
- declare const FormRow: typeof FormRowComponent & {
30
- withTitle: typeof FormRowComponent.withTitle;
31
- };
32
- export default FormRow;
@@ -1,28 +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 Icon_1 = __importDefault(require("./Icon"));
11
- const Text_1 = __importDefault(require("./Text"));
12
- const Button_1 = __importDefault(require("./Button"));
13
- const BetterHtmlProvider_1 = require("./BetterHtmlProvider");
14
- const FormRowComponent = (0, react_1.forwardRef)(function FormRow({ oneItemOnly, noBreakingPoint, gap, children, ...props }, ref) {
15
- const theme = (0, BetterHtmlProvider_1.useTheme)();
16
- const mediaQuery = (0, hooks_1.useMediaQuery)();
17
- const breakingPoint = !noBreakingPoint ? mediaQuery.size900 : false;
18
- const readyGap = breakingPoint || (noBreakingPoint && mediaQuery.size900) ? theme.styles.gap : theme.styles.space * 2;
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%" })] }));
20
- });
21
- FormRowComponent.withTitle = (0, react_1.forwardRef)(function WithTitle({ icon, title, description, withActions, saveButtonLoaderName, resetButtonLoaderName, onClickSave, onClickReset, children, ...props }, ref) {
22
- const theme = (0, BetterHtmlProvider_1.useTheme)();
23
- const mediaQuery = (0, hooks_1.useMediaQuery)();
24
- 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: props.noBreakingPoint && mediaQuery.size900 ? undefined : "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", loaderName: resetButtonLoaderName, onClick: onClickReset })), (0, jsx_runtime_1.jsx)(Button_1.default.icon, { icon: "check", loaderName: saveButtonLoaderName, onClick: onClickSave })] }))] })] }));
25
- });
26
- const FormRow = (0, react_1.memo)(FormRowComponent);
27
- FormRow.withTitle = FormRowComponent.withTitle;
28
- exports.default = FormRow;
@@ -1,13 +0,0 @@
1
- import { AnyOtherString, OmitProps } from "../types/app";
2
- import { ComponentHoverStyle, ComponentPropWithRef, ComponentStyle } from "../types/components";
3
- import { IconName } from "../types/icon";
4
- export type IconProps = {
5
- name: IconName | AnyOtherString;
6
- /** @default 16 */
7
- size?: number;
8
- } & OmitProps<React.ComponentProps<"svg">, "style" | "width" | "height" | "viewBox" | "fill" | "xmlns" | "name"> & ComponentStyle & ComponentHoverStyle;
9
- type IconComponent = {
10
- (props: ComponentPropWithRef<SVGSVGElement, IconProps>): React.ReactElement;
11
- };
12
- declare const _default: IconComponent;
13
- export default _default;
@@ -1,36 +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 react_2 = require("react");
9
- const styled_components_1 = __importDefault(require("styled-components"));
10
- const hooks_1 = require("../utils/hooks");
11
- const BetterHtmlProvider_1 = require("./BetterHtmlProvider");
12
- const IconElement = styled_components_1.default.svg.withConfig({
13
- shouldForwardProp: (prop) => !["normalStyle", "hoverStyle"].includes(prop),
14
- }) `
15
- ${(props) => props.normalStyle}
16
-
17
- &:hover {
18
- ${(props) => props.hoverStyle}
19
- }
20
- `;
21
- const Icon = (0, react_2.forwardRef)(function Icon({ name, size = 16, ...props }, ref) {
22
- const theme = (0, BetterHtmlProvider_1.useTheme)();
23
- const { icons } = (0, BetterHtmlProvider_1.useBetterHtmlContext)();
24
- const styledComponentStyles = (0, hooks_1.useStyledComponentStyles)(props, theme);
25
- const dataProps = (0, hooks_1.useComponentPropsWithPrefix)(props, "data");
26
- const ariaProps = (0, hooks_1.useComponentPropsWithPrefix)(props, "aria");
27
- const restProps = (0, hooks_1.useComponentPropsWithoutStyle)(props);
28
- const svgColor = props.color ?? theme.colors.textPrimary;
29
- (0, react_2.useEffect)(() => {
30
- if (!icons[name.toString()])
31
- console.warn(`The icon \`${name}\` you are trying to use does not exist. Make sure to add it to the \`icons\` object in \`<BetterHtmlProvider>\` config value prop.`);
32
- }, [icons, name]);
33
- return ((0, jsx_runtime_1.jsx)(IconElement, { width: size, height: size, viewBox: `0 0 ${icons[name.toString()]?.width ?? 0} ${icons[name.toString()]?.height ?? 0}`, fill: "none", xmlns: "http://www.w3.org/2000/svg", ...styledComponentStyles, ...dataProps, ...ariaProps, ...restProps, ref: ref, children: icons[name.toString()]?.paths.map((path) => ((0, react_1.createElement)("path", { ...path, fill: path.type === "fill" ? svgColor : undefined, stroke: path.type === "stroke" ? svgColor : undefined, key: path.d }))) }));
34
- });
35
- const MemoizedIcon = (0, react_2.memo)(Icon);
36
- exports.default = { Icon: MemoizedIcon }.Icon;
@@ -1,18 +0,0 @@
1
- import { AnyOtherString, OmitProps } from "../types/app";
2
- import { ComponentHoverStyle, ComponentPropWithRef, ComponentStyle } from "../types/components";
3
- import { AssetName } from "../types/asset";
4
- export type ImageProps = {
5
- name?: AssetName | AnyOtherString;
6
- } & OmitProps<React.ComponentProps<"img">, "style"> & ComponentStyle & ComponentHoverStyle;
7
- type ImageComponent = {
8
- (props: ComponentPropWithRef<HTMLImageElement, ImageProps>): React.ReactElement;
9
- profileImage: (props: ComponentPropWithRef<HTMLImageElement, OmitProps<ImageProps, "width" | "height"> & {
10
- /** @default 40 */
11
- size?: number;
12
- }>) => React.ReactElement;
13
- };
14
- declare const Image: ImageComponent;
15
- declare const _default: ImageComponent & {
16
- profileImage: typeof Image.profileImage;
17
- };
18
- export default _default;
@@ -1,44 +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 BetterHtmlProvider_1 = require("./BetterHtmlProvider");
10
- const hooks_1 = require("../utils/hooks");
11
- const ImageElement = styled_components_1.default.img.withConfig({
12
- shouldForwardProp: (prop) => !["normalStyle", "hoverStyle"].includes(prop),
13
- }) `
14
- display: block;
15
- user-select: none;
16
- -webkit-user-drag: none;
17
-
18
- ${(props) => props.normalStyle}
19
-
20
- &:hover {
21
- ${(props) => props.hoverStyle}
22
- }
23
- `;
24
- const Image = (0, react_1.forwardRef)(function Image({ name, src, ...props }, ref) {
25
- const theme = (0, BetterHtmlProvider_1.useTheme)();
26
- const { assets } = (0, BetterHtmlProvider_1.useBetterHtmlContext)();
27
- const styledComponentStyles = (0, hooks_1.useStyledComponentStyles)(props, theme);
28
- const dataProps = (0, hooks_1.useComponentPropsWithPrefix)(props, "data");
29
- const ariaProps = (0, hooks_1.useComponentPropsWithPrefix)(props, "aria");
30
- const restProps = (0, hooks_1.useComponentPropsWithoutStyle)(props);
31
- (0, react_1.useEffect)(() => {
32
- if (!name)
33
- return;
34
- if (!assets[name.toString()])
35
- console.warn(`The asset \`${name}\` you are trying to use does not exist. Make sure to add it to the \`assets\` object in \`<BetterHtmlProvider>\` config value prop.`);
36
- }, [assets, name]);
37
- return ((0, jsx_runtime_1.jsx)(ImageElement, { ...styledComponentStyles, src: name ? assets[name.toString()] : src, ...styledComponentStyles, ...dataProps, ...ariaProps, ...restProps, ref: ref }));
38
- });
39
- Image.profileImage = (0, react_1.forwardRef)(function ProfileImage({ size = 40, ...props }, ref) {
40
- return (0, jsx_runtime_1.jsx)(Image, { width: size, height: size, borderRadius: "50%", objectFit: "cover", ref: ref, ...props });
41
- });
42
- const MemoizedImage = (0, react_1.memo)(Image);
43
- MemoizedImage.profileImage = Image.profileImage;
44
- exports.default = { Image: MemoizedImage }.Image;
@@ -1,44 +0,0 @@
1
- import React from "react";
2
- import { ComponentHoverStyle, ComponentPropWithRef, ComponentStyle } from "../types/components";
3
- import { AnyOtherString, OmitProps } from "../types/app";
4
- import { IconName } from "../types/icon";
5
- export type InputFieldProps = {
6
- label?: string;
7
- labelColor?: string;
8
- errorText?: string;
9
- infoText?: string;
10
- leftIcon?: IconName | AnyOtherString;
11
- rightIcon?: IconName | AnyOtherString;
12
- insideInputFieldComponent?: React.ReactNode;
13
- /** @default false */
14
- withDebounce?: boolean;
15
- /** @default 0.5s */
16
- debounceDelay?: number;
17
- onChangeValue?: (value: string) => void;
18
- onClickRightIcon?: () => void;
19
- holderRef?: React.ForwardedRef<HTMLDivElement>;
20
- } & OmitProps<React.ComponentProps<"input">, "style" | "ref"> & ComponentStyle & ComponentHoverStyle;
21
- export type TextareaFieldProps = OmitProps<InputFieldProps, "type"> & OmitProps<React.ComponentProps<"textarea">, "style" | "ref">;
22
- type InputFieldComponentType = {
23
- (props: ComponentPropWithRef<HTMLInputElement, InputFieldProps>): React.ReactElement;
24
- multiline: (props: ComponentPropWithRef<HTMLTextAreaElement, TextareaFieldProps>) => React.ReactElement;
25
- email: (props: ComponentPropWithRef<HTMLInputElement, InputFieldProps>) => React.ReactElement;
26
- password: (props: ComponentPropWithRef<HTMLInputElement, InputFieldProps>) => React.ReactElement;
27
- search: (props: ComponentPropWithRef<HTMLInputElement, InputFieldProps>) => React.ReactElement;
28
- phoneNumber: (props: ComponentPropWithRef<HTMLInputElement, OmitProps<InputFieldProps, "type">>) => React.ReactElement;
29
- date: (props: ComponentPropWithRef<HTMLInputElement, InputFieldProps>) => React.ReactElement;
30
- dateTime: (props: ComponentPropWithRef<HTMLInputElement, InputFieldProps>) => React.ReactElement;
31
- time: (props: ComponentPropWithRef<HTMLInputElement, InputFieldProps>) => React.ReactElement;
32
- };
33
- declare const InputFieldComponent: InputFieldComponentType;
34
- declare const InputField: typeof InputFieldComponent & {
35
- multiline: typeof InputFieldComponent.multiline;
36
- email: typeof InputFieldComponent.email;
37
- password: typeof InputFieldComponent.password;
38
- search: typeof InputFieldComponent.search;
39
- phoneNumber: typeof InputFieldComponent.phoneNumber;
40
- date: typeof InputFieldComponent.date;
41
- dateTime: typeof InputFieldComponent.dateTime;
42
- time: typeof InputFieldComponent.time;
43
- };
44
- export default InputField;