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.
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 +5 -5
  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,45 +0,0 @@
1
- import { ReactNode } from "react";
2
- import { ComponentMarginProps, ComponentPropWithRef } from "../types/components";
3
- import { ToggleInputProps } from "./ToggleInput";
4
- import { ImageProps } from "./Image";
5
- type TextColumn<DataItem> = {
6
- type: "text";
7
- keyName?: keyof DataItem;
8
- format?: (item: DataItem, index: number) => string;
9
- };
10
- type ElementColumn<DataItem> = {
11
- type: "element";
12
- render?: (item: DataItem, index: number) => ReactNode;
13
- };
14
- type ImageColumn<DataItem> = {
15
- type: "image";
16
- keyName?: keyof DataItem;
17
- } & ImageProps;
18
- type CheckboxColumn = {
19
- type: "checkbox";
20
- } & ToggleInputProps<boolean>;
21
- export type TableColumn<DataItem> = {
22
- label?: string;
23
- width?: string | number;
24
- minWidth?: string | number;
25
- maxWidth?: string | number;
26
- align?: "left" | "center" | "right";
27
- } & (TextColumn<DataItem> | ElementColumn<DataItem> | ImageColumn<DataItem> | CheckboxColumn);
28
- export type TableProps<DataItem> = {
29
- columns: TableColumn<DataItem>[];
30
- data: DataItem[];
31
- /** @default false */
32
- isStriped?: boolean;
33
- /** @default false */
34
- withStickyHeader?: boolean;
35
- /** @default "No data available" */
36
- noDataItemsMessage?: string;
37
- onClickRow?: (item: DataItem, index: number) => void;
38
- onClickAllCheckboxes?: (checked: boolean) => void;
39
- } & ComponentMarginProps;
40
- type TableComponentType = {
41
- <DataItem>(props: ComponentPropWithRef<HTMLDivElement, TableProps<DataItem>>): React.ReactElement;
42
- };
43
- declare const TableComponent: TableComponentType;
44
- declare const Table: typeof TableComponent;
45
- export default Table;
@@ -1,159 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- const jsx_runtime_1 = require("react/jsx-runtime");
40
- const react_1 = require("react");
41
- const styled_components_1 = __importStar(require("styled-components"));
42
- const Div_1 = __importDefault(require("./Div"));
43
- const ToggleInput_1 = __importDefault(require("./ToggleInput"));
44
- const Image_1 = __importDefault(require("./Image"));
45
- const BetterHtmlProvider_1 = require("./BetterHtmlProvider");
46
- const Text_1 = __importDefault(require("./Text"));
47
- const defaultImageWidth = 120;
48
- const TableStyledComponent = styled_components_1.default.table.withConfig({
49
- shouldForwardProp: (prop) => !["isStriped", "withHover", "withStickyHeader", "theme"].includes(prop),
50
- }) `
51
- width: 100%;
52
- border-collapse: collapse;
53
- border-spacing: 0;
54
-
55
- tr {
56
- background-color: ${(props) => props.theme.colors.backgroundContent};
57
-
58
- &.isHeader {
59
- background-color: ${(props) => props.theme.colors.backgroundSecondary};
60
- font-weight: 700;
61
- }
62
-
63
- &.isClickable {
64
- cursor: pointer;
65
- }
66
-
67
- ${(props) => props.isStriped
68
- ? (0, styled_components_1.css) `
69
- &:nth-child(even) {
70
- background-color: ${props.theme.colors.backgroundSecondary};
71
- }
72
- `
73
- : ""}
74
-
75
- ${(props) => props.withHover
76
- ? (0, styled_components_1.css) `
77
- transition: ${props.theme.styles.transition};
78
-
79
- &:not(.isHeader):hover {
80
- background-color: ${props.theme.colors.backgroundSecondary}20;
81
- }
82
- `
83
- : ""}
84
-
85
- th {
86
- font-size: 18px;
87
- text-align: left;
88
- padding: ${(props) => props.theme.styles.space}px;
89
- }
90
-
91
- td {
92
- border-top: 1px solid ${(props) => props.theme.colors.border}60;
93
- padding: ${(props) => props.theme.styles.gap}px ${(props) => props.theme.styles.space}px;
94
-
95
- &.noData {
96
- text-align: center;
97
- padding: ${(props) => props.theme.styles.space}px;
98
- }
99
- }
100
- }
101
- `;
102
- const ThStyledComponent = styled_components_1.default.th.withConfig({
103
- shouldForwardProp: (prop) => !["width", "minWidth", "maxWidth", "textAlign"].includes(prop),
104
- }) `
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;` : "")}
108
- ${(props) => (props.textAlign ? `text-align: ${props.textAlign} !important;` : "")}
109
- `;
110
- const TdStyledComponent = styled_components_1.default.td.withConfig({
111
- shouldForwardProp: (prop) => !["width", "textAlign"].includes(prop),
112
- }) `
113
- ${(props) => (props.textAlign ? `text-align: ${props.textAlign} !important;` : "")}
114
- `;
115
- const TableComponent = (0, react_1.forwardRef)(function Table({ columns, data, isStriped, withStickyHeader, noDataItemsMessage = "No data available", onClickRow, onClickAllCheckboxes, ...props }, ref) {
116
- const theme = (0, BetterHtmlProvider_1.useTheme)();
117
- const [checkedItems, setCheckedItems] = (0, react_1.useState)([]);
118
- const renderCellContent = (0, react_1.useCallback)((column, item, index) => {
119
- switch (column.type) {
120
- case "text": {
121
- const value = column.keyName ? item[column.keyName] : undefined;
122
- return column.format ? column.format(item, index) : String(value ?? "");
123
- }
124
- case "element": {
125
- return column.render?.(item, index) ?? (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
126
- }
127
- case "image": {
128
- const { type, keyName, ...props } = column;
129
- const src = keyName ? item[keyName] : undefined;
130
- return ((0, jsx_runtime_1.jsx)(Image_1.default, { src: src, width: defaultImageWidth, borderRadius: theme.styles.borderRadius / 2, ...props }));
131
- }
132
- case "checkbox": {
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 }));
139
- }
140
- default: {
141
- return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
142
- }
143
- }
144
- }, [theme, checkedItems]);
145
- const onClickRowElement = (0, react_1.useCallback)((item, index) => {
146
- onClickRow?.(item, index);
147
- }, [onClickRow]);
148
- const onClickAllCheckboxesElement = (0, react_1.useCallback)((checked) => {
149
- onClickAllCheckboxes?.(checked);
150
- setCheckedItems(data.map(() => checked));
151
- }, [onClickAllCheckboxes, data]);
152
- const everythingIsChecked = (0, react_1.useMemo)(() => {
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 }) }) })) })] }) }));
157
- });
158
- const Table = (0, react_1.memo)(TableComponent);
159
- exports.default = Table;
@@ -1,18 +0,0 @@
1
- import { ComponentHoverStyle, ComponentPropWithRef, ComponentStyle } from "../types/components";
2
- import { OmitProps } from "../types/app";
3
- export type TextAs = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span" | "label";
4
- export type TextProps = {
5
- /** @default "p" */
6
- as?: TextAs;
7
- } & OmitProps<React.ComponentProps<"p">, "style"> & ComponentStyle & ComponentHoverStyle;
8
- type TextComponentType = {
9
- (props: ComponentPropWithRef<HTMLParagraphElement, TextProps>): React.ReactElement;
10
- unknown: (props: ComponentPropWithRef<HTMLParagraphElement, TextProps>) => React.ReactElement;
11
- oneLine: (props: ComponentPropWithRef<HTMLParagraphElement, TextProps>) => React.ReactElement;
12
- };
13
- declare const TextComponent: TextComponentType;
14
- declare const Text: typeof TextComponent & {
15
- unknown: typeof TextComponent.unknown;
16
- oneLine: typeof TextComponent.oneLine;
17
- };
18
- export default Text;
@@ -1,38 +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 BetterHtmlProvider_1 = require("./BetterHtmlProvider");
11
- const TextStyledComponent = styled_components_1.default.div.withConfig({
12
- shouldForwardProp: (prop) => !["normalStyle", "hoverStyle"].includes(prop),
13
- }) `
14
- ${(props) => props.normalStyle}
15
-
16
- &:hover {
17
- ${(props) => props.hoverStyle}
18
- }
19
- `;
20
- const TextComponent = (0, react_1.forwardRef)(function Text({ as = "p", children, ...props }, ref) {
21
- const theme = (0, BetterHtmlProvider_1.useTheme)();
22
- const styledComponentStyles = (0, hooks_1.useStyledComponentStyles)(props, theme);
23
- const dataProps = (0, hooks_1.useComponentPropsWithPrefix)(props, "data");
24
- const ariaProps = (0, hooks_1.useComponentPropsWithPrefix)(props, "aria");
25
- const restProps = (0, hooks_1.useComponentPropsWithoutStyle)(props);
26
- return ((0, jsx_runtime_1.jsx)(TextStyledComponent, { as: as, ...styledComponentStyles, ...dataProps, ...ariaProps, ...restProps, ref: ref, children: children }));
27
- });
28
- TextComponent.unknown = (0, react_1.forwardRef)(function Unknown(props, ref) {
29
- const theme = (0, BetterHtmlProvider_1.useTheme)();
30
- return ((0, jsx_runtime_1.jsx)(TextComponent, { fontStyle: "italic", textAlign: "center", color: theme.colors.textSecondary, ref: ref, ...props }));
31
- });
32
- TextComponent.oneLine = (0, react_1.forwardRef)(function OneLine(props, ref) {
33
- return (0, jsx_runtime_1.jsx)(TextComponent, { textOverflow: "ellipsis", whiteSpace: "nowrap", overflow: "hidden", ref: ref, ...props });
34
- });
35
- const Text = (0, react_1.memo)(TextComponent);
36
- Text.unknown = TextComponent.unknown;
37
- Text.oneLine = TextComponent.oneLine;
38
- exports.default = Text;
@@ -1,20 +0,0 @@
1
- import { ComponentHoverStyle, ComponentPropWithRef, ComponentStyle } from "../types/components";
2
- import { OmitProps } from "../types/app";
3
- export type ToggleInputRef = {};
4
- type InternalToggleInputProps<Value> = {
5
- label?: string;
6
- labelColor?: string;
7
- text?: string;
8
- errorText?: string;
9
- infoText?: string;
10
- value?: Value;
11
- onChange?: (checked: boolean, value?: Value) => void;
12
- } & OmitProps<React.ComponentProps<"input">, "style" | "value" | "ref" | "onChange"> & ComponentStyle & ComponentHoverStyle;
13
- export type ToggleInputProps<Value> = ComponentPropWithRef<ToggleInputRef, OmitProps<InternalToggleInputProps<Value>, "type">>;
14
- type ToggleInputComponentType = <Value>(props: ToggleInputProps<Value>) => React.ReactElement;
15
- declare const _default: {
16
- checkbox: ToggleInputComponentType;
17
- radiobutton: ToggleInputComponentType;
18
- switch: ToggleInputComponentType;
19
- };
20
- export default _default;
@@ -1,161 +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 Text_1 = __importDefault(require("./Text"));
11
- const Div_1 = __importDefault(require("./Div"));
12
- const Icon_1 = __importDefault(require("./Icon"));
13
- const Label_1 = __importDefault(require("./Label"));
14
- const BetterHtmlProvider_1 = require("./BetterHtmlProvider");
15
- const componentSize = 26;
16
- const switchComponentBallGap = 3;
17
- const switchComponentMouseDownDifference = 4;
18
- const InputElement = styled_components_1.default.input.withConfig({
19
- shouldForwardProp: (prop) => !["theme", "normalStyle", "hoverStyle"].includes(prop),
20
- }) `
21
- position: relative;
22
- appearance: none;
23
- width: ${componentSize}px;
24
- height: ${componentSize}px;
25
- background-color: ${(props) => props.theme.colors.backgroundContent};
26
- border: 1px solid ${(props) => props.theme.colors.border};
27
- border-radius: ${(props) => props.theme.styles.borderRadius / 2}px;
28
- cursor: pointer;
29
- transition: ${(props) => props.theme.styles.transition};
30
- flex-shrink: 0;
31
-
32
- &[type="radio"] {
33
- border-radius: 999px;
34
- }
35
-
36
- &:checked {
37
- background-color: ${(props) => props.theme.colors.primary};
38
- border-color: ${(props) => props.theme.colors.primary};
39
- }
40
-
41
- &:disabled {
42
- filter: brightness(0.9);
43
- cursor: not-allowed;
44
- }
45
-
46
- ${(props) => props.normalStyle}
47
-
48
- &:hover {
49
- ${(props) => props.hoverStyle}
50
- }
51
- `;
52
- const SwitchElement = styled_components_1.default.div.withConfig({
53
- shouldForwardProp: (prop) => !["theme", "checked", "disabled", "isMouseDown", "normalStyle", "hoverStyle"].includes(prop),
54
- }) `
55
- --width: ${(props) => componentSize * 2 - props.theme.styles.gap / 2}px;
56
- --ball-size: ${componentSize - switchComponentBallGap * 2}px;
57
-
58
- position: relative;
59
- width: var(--width);
60
- height: ${componentSize}px;
61
- background-color: ${(props) => (props.checked ? props.theme.colors.primary : props.theme.colors.border)};
62
- border-radius: 999px;
63
- cursor: ${(props) => (props.disabled ? "not-allowed" : "pointer")};
64
- opacity: ${(props) => (props.disabled ? 0.5 : 1)};
65
- transition: ${(props) => props.theme.styles.transition};
66
-
67
- &::before {
68
- content: "";
69
- position: absolute;
70
- width: ${(props) => componentSize - switchComponentBallGap * 2 + (props.isMouseDown ? switchComponentMouseDownDifference : 0)}px;
71
- height: ${componentSize - switchComponentBallGap * 2}px;
72
- background-color: ${(props) => props.theme.colors.base};
73
- border-radius: 999px;
74
- top: ${switchComponentBallGap}px;
75
- left: ${switchComponentBallGap}px;
76
- transform: translateX(
77
- ${(props) => props.checked
78
- ? `calc(var(--width) - ${componentSize + (props.isMouseDown ? switchComponentMouseDownDifference : 0)}px)`
79
- : "0px"}
80
- );
81
- transition: ${(props) => props.theme.styles.transition};
82
- }
83
-
84
- &.react-better-html-color-theme-switch-with-moon {
85
- &::after {
86
- content: "";
87
- position: absolute;
88
- width: ${(props) => componentSize -
89
- switchComponentBallGap * 2 +
90
- (props.isMouseDown ? switchComponentMouseDownDifference : 0)}px;
91
- height: ${componentSize - switchComponentBallGap * 2}px;
92
- background-color: ${(props) => (props.checked ? props.theme.colors.primary : "transparent")};
93
- border-radius: 999px;
94
- top: ${switchComponentBallGap}px;
95
- left: ${switchComponentBallGap}px;
96
- transform: translateX(
97
- ${(props) => props.checked
98
- ? `calc(var(--width) - ${componentSize + (props.isMouseDown ? switchComponentMouseDownDifference * 2 : 0)}px - calc(var(--ball-size) / 3))`
99
- : "0px"}
100
- );
101
- transition: ${(props) => props.theme.styles.transition};
102
- }
103
- }
104
-
105
- ${(props) => props.normalStyle}
106
-
107
- &:hover {
108
- ${(props) => props.hoverStyle}
109
- }
110
- `;
111
- const ToggleInputComponent = (0, react_1.forwardRef)(function ToggleInput({ label, labelColor, text, errorText, infoText, value, onChange, checked: controlledChecked, color, required, ...props }, ref) {
112
- const theme = (0, BetterHtmlProvider_1.useTheme)();
113
- const styledComponentStyles = (0, hooks_1.useStyledComponentStyles)(props, theme, true);
114
- const styledComponentStylesWithExcluded = (0, hooks_1.useComponentPropsWithExcludedStyle)(props);
115
- const dataProps = (0, hooks_1.useComponentPropsWithPrefix)(props, "data");
116
- const ariaProps = (0, hooks_1.useComponentPropsWithPrefix)(props, "aria");
117
- const restProps = (0, hooks_1.useComponentPropsWithoutStyle)(props);
118
- const [internalChecked, setInternalChecked] = (0, react_1.useState)(false);
119
- const onChangeElement = (0, react_1.useCallback)((event) => {
120
- const newIsChecked = event.target.checked;
121
- if (controlledChecked === undefined)
122
- setInternalChecked(newIsChecked);
123
- onChange?.(newIsChecked, value);
124
- }, [onChange, controlledChecked, value]);
125
- const checked = controlledChecked ?? internalChecked;
126
- const onClickText = (0, react_1.useCallback)(() => {
127
- const newIsChecked = !checked;
128
- if (controlledChecked === undefined)
129
- setInternalChecked(newIsChecked);
130
- onChange?.(newIsChecked, value);
131
- }, [checked, controlledChecked, onChange, value]);
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
- });
134
- exports.default = {
135
- checkbox: (0, react_1.forwardRef)(function Checkbox(props, ref) {
136
- return (0, jsx_runtime_1.jsx)(ToggleInputComponent, { type: "checkbox", ref: ref, ...props });
137
- }),
138
- radiobutton: (0, react_1.forwardRef)(function RadioButton(props, ref) {
139
- return (0, jsx_runtime_1.jsx)(ToggleInputComponent, { type: "radio", ref: ref, ...props });
140
- }),
141
- switch: (0, react_1.forwardRef)(function Switch({ label, labelColor, errorText, infoText, disabled, value, onChange, checked: controlledChecked, required, ...props }, ref) {
142
- const theme = (0, BetterHtmlProvider_1.useTheme)();
143
- const styledComponentStyles = (0, hooks_1.useStyledComponentStyles)(props, theme, true);
144
- const styledComponentStylesWithExcluded = (0, hooks_1.useComponentPropsWithExcludedStyle)(props);
145
- const dataProps = (0, hooks_1.useComponentPropsWithPrefix)(props, "data");
146
- const ariaProps = (0, hooks_1.useComponentPropsWithPrefix)(props, "aria");
147
- const restProps = (0, hooks_1.useComponentPropsWithoutStyle)(props);
148
- const [internalChecked, setInternalChecked] = (0, hooks_1.useBooleanState)();
149
- const [isMouseDown, setIsMouseDown] = (0, hooks_1.useBooleanState)();
150
- const checked = controlledChecked ?? internalChecked;
151
- const onClickElement = (0, react_1.useCallback)(() => {
152
- if (disabled)
153
- return;
154
- const newIsChecked = !checked;
155
- if (controlledChecked === undefined)
156
- setInternalChecked.setState(newIsChecked);
157
- onChange?.(newIsChecked, value);
158
- }, [disabled, checked, onChange, controlledChecked, value]);
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
- }),
161
- };
@@ -1,2 +0,0 @@
1
- import { AppConfig } from "../types/config";
2
- export declare const appConfig: AppConfig;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.appConfig = void 0;
4
- exports.appConfig = {
5
- contentMaxWidth: 1100,
6
- };
@@ -1,2 +0,0 @@
1
- import { AssetsConfig } from "../types/asset";
2
- export declare const assets: AssetsConfig;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assets = void 0;
4
- exports.assets = {
5
- logo: "",
6
- };
@@ -1,2 +0,0 @@
1
- import { Country } from "../types/countries";
2
- export declare const countries: Country[];