react-better-html 1.1.10 → 1.1.12

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 (48) hide show
  1. package/README.md +28 -1
  2. package/dist/components/BetterHtmlProvider.d.ts +13 -3
  3. package/dist/components/BetterHtmlProvider.js +103 -24
  4. package/dist/components/Button.d.ts +63 -0
  5. package/dist/components/Button.js +157 -0
  6. package/dist/components/Chip.d.ts +20 -0
  7. package/dist/components/Chip.js +20 -0
  8. package/dist/components/Div.d.ts +9 -17
  9. package/dist/components/Div.js +2 -2
  10. package/dist/components/Divider.d.ts +21 -0
  11. package/dist/components/Divider.js +20 -0
  12. package/dist/components/Dropdown.d.ts +36 -0
  13. package/dist/components/Dropdown.js +157 -0
  14. package/dist/components/Icon.d.ts +13 -0
  15. package/dist/components/Icon.js +36 -0
  16. package/dist/components/Image.d.ts +18 -0
  17. package/dist/components/Image.js +44 -0
  18. package/dist/components/InputField.d.ts +33 -0
  19. package/dist/components/InputField.js +146 -0
  20. package/dist/components/Loader.d.ts +16 -1
  21. package/dist/components/Loader.js +11 -0
  22. package/dist/components/Modal.d.ts +41 -0
  23. package/dist/components/Modal.js +93 -0
  24. package/dist/components/PageHolder.d.ts +8 -0
  25. package/dist/components/PageHolder.js +15 -0
  26. package/dist/components/Text.d.ts +5 -11
  27. package/dist/components/ToggleInput.d.ts +19 -0
  28. package/dist/components/ToggleInput.js +122 -0
  29. package/dist/constants/app.d.ts +2 -0
  30. package/dist/constants/app.js +6 -0
  31. package/dist/constants/assets.d.ts +2 -0
  32. package/dist/constants/assets.js +10 -0
  33. package/dist/constants/icons.d.ts +2 -0
  34. package/dist/constants/icons.js +85 -0
  35. package/dist/constants/theme.d.ts +2 -0
  36. package/dist/constants/theme.js +46 -0
  37. package/dist/index.d.ts +13 -1
  38. package/dist/index.js +29 -1
  39. package/dist/types/app.d.ts +1 -0
  40. package/dist/types/asset.d.ts +4 -2
  41. package/dist/types/components.d.ts +3 -0
  42. package/dist/types/config.d.ts +8 -7
  43. package/dist/types/icon.d.ts +6 -3
  44. package/dist/types/loader.d.ts +3 -0
  45. package/dist/types/theme.d.ts +7 -5
  46. package/dist/utils/hooks.d.ts +34 -1
  47. package/dist/utils/hooks.js +107 -3
  48. package/package.json +1 -1
@@ -0,0 +1,8 @@
1
+ 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;
@@ -0,0 +1,15 @@
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", paddingBlock: theme.styles.gap, paddingInline: theme.styles.space, children: children }));
14
+ }
15
+ exports.default = (0, react_1.memo)(PageHolder);
@@ -1,19 +1,13 @@
1
- import { ComponentHoverStyle, ComponentStyle } from "../types/components";
1
+ import { ComponentHoverStyle, ComponentPropWithRef, ComponentStyle } from "../types/components";
2
2
  import { OmitProps } from "../types/app";
3
3
  export type TextProps = {
4
4
  /** @default "p" */
5
5
  as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span" | "label";
6
- } & OmitProps<React.ComponentProps<"div">, "style"> & ComponentStyle & ComponentHoverStyle;
6
+ } & OmitProps<React.ComponentProps<"p">, "style"> & ComponentStyle & ComponentHoverStyle;
7
7
  type TextComponentType = {
8
- (props: TextProps & {
9
- ref?: React.Ref<HTMLDivElement>;
10
- }): React.ReactElement;
11
- unknown: (props: TextProps & {
12
- ref?: React.Ref<HTMLDivElement>;
13
- }) => React.ReactElement;
14
- oneLine: (props: TextProps & {
15
- ref?: React.Ref<HTMLDivElement>;
16
- }) => React.ReactElement;
8
+ (props: ComponentPropWithRef<HTMLParagraphElement, TextProps>): React.ReactElement;
9
+ unknown: (props: ComponentPropWithRef<HTMLParagraphElement, TextProps>) => React.ReactElement;
10
+ oneLine: (props: ComponentPropWithRef<HTMLParagraphElement, TextProps>) => React.ReactElement;
17
11
  };
18
12
  declare const TextComponent: TextComponentType;
19
13
  declare const Text: typeof TextComponent & {
@@ -0,0 +1,19 @@
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
+ text?: string;
7
+ errorText?: string;
8
+ infoText?: string;
9
+ value?: Value;
10
+ onChange?: (checked: boolean, value?: Value) => void;
11
+ } & OmitProps<React.ComponentProps<"input">, "style" | "value" | "ref" | "onChange" | "name"> & ComponentStyle & ComponentHoverStyle;
12
+ type ToggleInputProps<Value> = ComponentPropWithRef<ToggleInputRef, OmitProps<InternalToggleInputProps<Value>, "type">>;
13
+ type ToggleInputComponentType = <Value>(props: ToggleInputProps<Value>) => React.ReactElement;
14
+ declare const _default: {
15
+ checkbox: ToggleInputComponentType;
16
+ radiobutton: ToggleInputComponentType;
17
+ switch: ToggleInputComponentType;
18
+ };
19
+ export default _default;
@@ -0,0 +1,122 @@
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 BetterHtmlProvider_1 = require("./BetterHtmlProvider");
14
+ const InputElement = styled_components_1.default.input.withConfig({
15
+ shouldForwardProp: (prop) => !["theme", "normalStyle", "hoverStyle"].includes(prop),
16
+ }) `
17
+ position: relative;
18
+ appearance: none;
19
+ width: 24px;
20
+ height: 24px;
21
+ background-color: ${(props) => props.theme.colors.backgroundContent};
22
+ border: 1px solid ${(props) => props.theme.colors.border};
23
+ border-radius: ${(props) => props.theme.styles.borderRadius / 2}px;
24
+ cursor: pointer;
25
+ transition: ${(props) => props.theme.styles.transition};
26
+ flex-shrink: 0;
27
+
28
+ &[type="radio"] {
29
+ border-radius: 999px;
30
+ }
31
+
32
+ &:checked {
33
+ background-color: ${(props) => props.theme.colors.primary};
34
+ border-color: ${(props) => props.theme.colors.primary};
35
+ }
36
+
37
+ &:disabled {
38
+ filter: brightness(0.9);
39
+ cursor: not-allowed;
40
+ }
41
+
42
+ ${(props) => props.normalStyle}
43
+
44
+ &:hover {
45
+ ${(props) => props.hoverStyle}
46
+ }
47
+ `;
48
+ const SwitchElement = styled_components_1.default.div.withConfig({
49
+ shouldForwardProp: (prop) => !["theme", "checked", "disabled", "normalStyle", "hoverStyle"].includes(prop),
50
+ }) `
51
+ position: relative;
52
+ width: 36px;
53
+ height: 20px;
54
+ background-color: ${(props) => (props.checked ? props.theme.colors.primary : props.theme.colors.border)};
55
+ border-radius: 10px;
56
+ cursor: ${(props) => (props.disabled ? "not-allowed" : "pointer")};
57
+ opacity: ${(props) => (props.disabled ? 0.5 : 1)};
58
+ transition: ${(props) => props.theme.styles.transition};
59
+
60
+ &::before {
61
+ content: "";
62
+ position: absolute;
63
+ width: 16px;
64
+ height: 16px;
65
+ background-color: white;
66
+ border-radius: 50%;
67
+ top: 2px;
68
+ left: 2px;
69
+ transition: ${(props) => props.theme.styles.transition};
70
+ transform: translateX(${(props) => (props.checked ? "16px" : "0")});
71
+ }
72
+
73
+ ${(props) => props.normalStyle}
74
+
75
+ &:hover {
76
+ ${(props) => props.hoverStyle}
77
+ }
78
+ `;
79
+ const ToggleInputComponent = (0, react_1.forwardRef)(function ToggleInput({ label, text, errorText, infoText, value, onChange, checked: controlledChecked, required, ...props }, ref) {
80
+ const theme = (0, BetterHtmlProvider_1.useTheme)();
81
+ const styledComponentStyles = (0, hooks_1.useStyledComponentStyles)(props, theme, true);
82
+ const styledComponentStylesWithExcluded = (0, hooks_1.useComponentPropsWithExcludedStyle)(props);
83
+ const dataProps = (0, hooks_1.useComponentPropsWithPrefix)(props, "data");
84
+ const ariaProps = (0, hooks_1.useComponentPropsWithPrefix)(props, "aria");
85
+ const restProps = (0, hooks_1.useComponentPropsWithoutStyle)(props);
86
+ const [internalChecked, setInternalChecked] = (0, react_1.useState)(false);
87
+ const onChangeElement = (0, react_1.useCallback)((event) => {
88
+ const newValue = event.target.checked;
89
+ if (controlledChecked === undefined)
90
+ setInternalChecked(newValue);
91
+ onChange?.(newValue, value);
92
+ }, [onChange, controlledChecked, value, props.type]);
93
+ const checked = controlledChecked ?? internalChecked;
94
+ return ((0, jsx_runtime_1.jsxs)(Div_1.default.column, { width: "100%", gap: theme.styles.gap / 2, ...styledComponentStylesWithExcluded, children: [label && ((0, jsx_runtime_1.jsxs)(Text_1.default, { as: "label", height: 16, fontSize: 14, color: errorText ? theme.colors.error : theme.colors.textSecondary, children: [label, required && ((0, jsx_runtime_1.jsxs)(Text_1.default, { as: "span", fontSize: 16, color: theme.colors.error, children: [" ", "*"] }))] })), (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.jsx)(Text_1.default, { children: text })] }), (errorText || infoText) && ((0, jsx_runtime_1.jsx)(Text_1.default, { as: "span", display: "block", fontSize: 14, color: errorText ? theme.colors.error : theme.colors.textSecondary, children: errorText || infoText }))] }));
95
+ });
96
+ exports.default = {
97
+ checkbox: (0, react_1.forwardRef)(function Checkbox(props, ref) {
98
+ return (0, jsx_runtime_1.jsx)(ToggleInputComponent, { type: "checkbox", ref: ref, ...props });
99
+ }),
100
+ radiobutton: (0, react_1.forwardRef)(function RadioButton(props, ref) {
101
+ return (0, jsx_runtime_1.jsx)(ToggleInputComponent, { type: "radio", ref: ref, ...props });
102
+ }),
103
+ switch: (0, react_1.forwardRef)(function Switch({ label, errorText, infoText, disabled, onChange, checked: controlledChecked, required, ...props }, ref) {
104
+ const theme = (0, BetterHtmlProvider_1.useTheme)();
105
+ const styledComponentStyles = (0, hooks_1.useStyledComponentStyles)(props, theme, true);
106
+ const styledComponentStylesWithExcluded = (0, hooks_1.useComponentPropsWithExcludedStyle)(props);
107
+ const dataProps = (0, hooks_1.useComponentPropsWithPrefix)(props, "data");
108
+ const ariaProps = (0, hooks_1.useComponentPropsWithPrefix)(props, "aria");
109
+ const restProps = (0, hooks_1.useComponentPropsWithoutStyle)(props);
110
+ const [internalChecked, setInternalChecked] = (0, hooks_1.useBooleanState)();
111
+ const checked = controlledChecked ?? internalChecked;
112
+ const onClickElement = (0, react_1.useCallback)(() => {
113
+ if (disabled)
114
+ return;
115
+ const newValue = !checked;
116
+ if (controlledChecked === undefined)
117
+ setInternalChecked.setState(newValue);
118
+ onChange?.(newValue);
119
+ }, [disabled, checked, onChange, controlledChecked]);
120
+ return ((0, jsx_runtime_1.jsxs)(Div_1.default.column, { width: "100%", gap: theme.styles.gap / 2, ...styledComponentStylesWithExcluded, children: [label && ((0, jsx_runtime_1.jsxs)(Text_1.default, { as: "label", height: 16, fontSize: 14, color: errorText ? theme.colors.error : theme.colors.textSecondary, children: [label, required && ((0, jsx_runtime_1.jsxs)(Text_1.default, { as: "span", fontSize: 16, color: theme.colors.error, children: [" ", "*"] }))] })), (0, jsx_runtime_1.jsx)(Div_1.default.row, { alignItems: "center", gap: theme.styles.gap, children: (0, jsx_runtime_1.jsx)(SwitchElement, { theme: theme, checked: checked, disabled: disabled ?? false, 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 : theme.colors.textSecondary, children: errorText || infoText }))] }));
121
+ }),
122
+ };
@@ -0,0 +1,2 @@
1
+ import { AppConfig } from "../types/config";
2
+ export declare const appConfig: AppConfig;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.appConfig = void 0;
4
+ exports.appConfig = {
5
+ contentMaxWidth: 1100,
6
+ };
@@ -0,0 +1,2 @@
1
+ import { AssetsConfig } from "../types/asset";
2
+ export declare const assets: AssetsConfig;
@@ -0,0 +1,10 @@
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
+ exports.assets = void 0;
7
+ const logo_svg_1 = __importDefault(require("../assets/logo.svg"));
8
+ exports.assets = {
9
+ logo: logo_svg_1.default,
10
+ };
@@ -0,0 +1,2 @@
1
+ import { IconsConfig } from "../types/icon";
2
+ export declare const icons: IconsConfig;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.icons = void 0;
4
+ exports.icons = {
5
+ XMark: {
6
+ width: 384,
7
+ height: 512,
8
+ paths: [
9
+ {
10
+ d: "M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z",
11
+ type: "fill",
12
+ },
13
+ ],
14
+ },
15
+ uploadCloud: {
16
+ width: 640,
17
+ height: 512,
18
+ paths: [
19
+ {
20
+ d: "M144 480C64.5 480 0 415.5 0 336c0-62.8 40.2-116.2 96.2-135.9c-.1-2.7-.2-5.4-.2-8.1c0-88.4 71.6-160 160-160c59.3 0 111 32.2 138.7 80.2C409.9 102 428.3 96 448 96c53 0 96 43 96 96c0 12.2-2.3 23.8-6.4 34.6C596 238.4 640 290.1 640 352c0 70.7-57.3 128-128 128l-368 0zm79-217c-9.4 9.4-9.4 24.6 0 33.9s24.6 9.4 33.9 0l39-39L296 392c0 13.3 10.7 24 24 24s24-10.7 24-24l0-134.1 39 39c9.4 9.4 24.6 9.4 33.9 0s9.4-24.6 0-33.9l-80-80c-9.4-9.4-24.6-9.4-33.9 0l-80 80z",
21
+ type: "fill",
22
+ },
23
+ ],
24
+ },
25
+ trash: {
26
+ width: 448,
27
+ height: 512,
28
+ paths: [
29
+ {
30
+ d: "M135.2 17.7C140.6 6.8 151.7 0 163.8 0L284.2 0c12.1 0 23.2 6.8 28.6 17.7L320 32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 96C14.3 96 0 81.7 0 64S14.3 32 32 32l96 0 7.2-14.3zM32 128l384 0 0 320c0 35.3-28.7 64-64 64L96 512c-35.3 0-64-28.7-64-64l0-320zm96 64c-8.8 0-16 7.2-16 16l0 224c0 8.8 7.2 16 16 16s16-7.2 16-16l0-224c0-8.8-7.2-16-16-16zm96 0c-8.8 0-16 7.2-16 16l0 224c0 8.8 7.2 16 16 16s16-7.2 16-16l0-224c0-8.8-7.2-16-16-16zm96 0c-8.8 0-16 7.2-16 16l0 224c0 8.8 7.2 16 16 16s16-7.2 16-16l0-224c0-8.8-7.2-16-16-16z",
31
+ type: "fill",
32
+ },
33
+ ],
34
+ },
35
+ chevronDown: {
36
+ width: 512,
37
+ height: 512,
38
+ paths: [
39
+ {
40
+ d: "M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z",
41
+ type: "fill",
42
+ },
43
+ ],
44
+ },
45
+ eye: {
46
+ width: 576,
47
+ height: 512,
48
+ paths: [
49
+ {
50
+ d: "M288 32c-80.8 0-145.5 36.8-192.6 80.6C48.6 156 17.3 208 2.5 243.7c-3.3 7.9-3.3 16.7 0 24.6C17.3 304 48.6 356 95.4 399.4C142.5 443.2 207.2 480 288 480s145.5-36.8 192.6-80.6c46.8-43.5 78.1-95.4 93-131.1c3.3-7.9 3.3-16.7 0-24.6c-14.9-35.7-46.2-87.7-93-131.1C433.5 68.8 368.8 32 288 32zM144 256a144 144 0 1 1 288 0 144 144 0 1 1 -288 0zm144-64c0 35.3-28.7 64-64 64c-7.1 0-13.9-1.2-20.3-3.3c-5.5-1.8-11.9 1.6-11.7 7.4c.3 6.9 1.3 13.8 3.2 20.7c13.7 51.2 66.4 81.6 117.6 67.9s81.6-66.4 67.9-117.6c-11.1-41.5-47.8-69.4-88.6-71.1c-5.8-.2-9.2 6.1-7.4 11.7c2.1 6.4 3.3 13.2 3.3 20.3z",
51
+ type: "fill",
52
+ },
53
+ ],
54
+ },
55
+ eyeDashed: {
56
+ width: 640,
57
+ height: 512,
58
+ paths: [
59
+ {
60
+ d: "M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L525.6 386.7c39.6-40.6 66.4-86.1 79.9-118.4c3.3-7.9 3.3-16.7 0-24.6c-14.9-35.7-46.2-87.7-93-131.1C465.5 68.8 400.8 32 320 32c-68.2 0-125 26.3-169.3 60.8L38.8 5.1zM223.1 149.5C248.6 126.2 282.7 112 320 112c79.5 0 144 64.5 144 144c0 24.9-6.3 48.3-17.4 68.7L408 294.5c8.4-19.3 10.6-41.4 4.8-63.3c-11.1-41.5-47.8-69.4-88.6-71.1c-5.8-.2-9.2 6.1-7.4 11.7c2.1 6.4 3.3 13.2 3.3 20.3c0 10.2-2.4 19.8-6.6 28.3l-90.3-70.8zM373 389.9c-16.4 6.5-34.3 10.1-53 10.1c-79.5 0-144-64.5-144-144c0-6.9 .5-13.6 1.4-20.2L83.1 161.5C60.3 191.2 44 220.8 34.5 243.7c-3.3 7.9-3.3 16.7 0 24.6c14.9 35.7 46.2 87.7 93 131.1C174.5 443.2 239.2 480 320 480c47.8 0 89.9-12.9 126.2-32.5L373 389.9z",
61
+ type: "fill",
62
+ },
63
+ ],
64
+ },
65
+ magnifyingGlass: {
66
+ width: 512,
67
+ height: 512,
68
+ paths: [
69
+ {
70
+ d: "M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z",
71
+ type: "fill",
72
+ },
73
+ ],
74
+ },
75
+ check: {
76
+ width: 448,
77
+ height: 512,
78
+ paths: [
79
+ {
80
+ d: "M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z",
81
+ type: "fill",
82
+ },
83
+ ],
84
+ },
85
+ };
@@ -0,0 +1,2 @@
1
+ import { ThemeConfig } from "../types/theme";
2
+ export declare const theme: ThemeConfig;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.theme = void 0;
4
+ exports.theme = {
5
+ styles: {
6
+ space: 16,
7
+ gap: 8,
8
+ borderRadius: 10,
9
+ fontFamily: "Arial, sans-serif",
10
+ transition: "ease 0.2s",
11
+ },
12
+ colors: {
13
+ light: {
14
+ textPrimary: "#111111",
15
+ textSecondary: "#777777",
16
+ label: "#111111",
17
+ primary: "#6d466b",
18
+ secondary: "#412234",
19
+ success: "#28a745",
20
+ info: "#17a2b8",
21
+ warn: "#ffc107",
22
+ error: "#dc3545",
23
+ base: "#f8f8f8",
24
+ backgroundBase: "#f8f8f8",
25
+ backgroundSecondary: "#e8e8e8",
26
+ backgroundContent: "#ffffff",
27
+ border: "#ced4da",
28
+ },
29
+ dark: {
30
+ textPrimary: "#f8f8f8",
31
+ textSecondary: "#e8e8e8",
32
+ label: "#111111",
33
+ primary: "#9b6499",
34
+ secondary: "#6c466b",
35
+ success: "#28a745",
36
+ info: "#17a2b8",
37
+ warn: "#ffc107",
38
+ error: "#dc3545",
39
+ base: "#f8f8f8",
40
+ backgroundBase: "#111111",
41
+ backgroundSecondary: "#222222",
42
+ backgroundContent: "#333333",
43
+ border: "#777777",
44
+ },
45
+ },
46
+ };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,16 @@
1
1
  import Div from "./components/Div";
2
2
  import Text from "./components/Text";
3
3
  import Loader from "./components/Loader";
4
- export { Div, Text, Loader };
4
+ import Icon from "./components/Icon";
5
+ import Image from "./components/Image";
6
+ import Button from "./components/Button";
7
+ import Divider from "./components/Divider";
8
+ import Modal, { type ModalRef } from "./components/Modal";
9
+ import PageHolder from "./components/PageHolder";
10
+ import Chip from "./components/Chip";
11
+ import InputField from "./components/InputField";
12
+ import Dropdown from "./components/Dropdown";
13
+ import ToggleInput from "./components/ToggleInput";
14
+ import { useBetterHtmlContext, useTheme, useLoader, useLoaderControls } from "./components/BetterHtmlProvider";
15
+ import { usePageResize, useMediaQuery } from "./utils/hooks";
16
+ export { Div, Text, Loader, Icon, Image, Button, Divider, Modal, ModalRef, PageHolder, Chip, InputField, Dropdown, ToggleInput, useBetterHtmlContext, useTheme, useLoader, useLoaderControls, usePageResize, useMediaQuery, };
package/dist/index.js CHANGED
@@ -3,10 +3,38 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Loader = exports.Text = exports.Div = void 0;
6
+ exports.useMediaQuery = exports.usePageResize = exports.useLoaderControls = exports.useLoader = exports.useTheme = exports.useBetterHtmlContext = exports.ToggleInput = exports.Dropdown = exports.InputField = exports.Chip = exports.PageHolder = exports.Modal = exports.Divider = exports.Button = exports.Image = exports.Icon = exports.Loader = exports.Text = exports.Div = void 0;
7
7
  const Div_1 = __importDefault(require("./components/Div"));
8
8
  exports.Div = Div_1.default;
9
9
  const Text_1 = __importDefault(require("./components/Text"));
10
10
  exports.Text = Text_1.default;
11
11
  const Loader_1 = __importDefault(require("./components/Loader"));
12
12
  exports.Loader = Loader_1.default;
13
+ const Icon_1 = __importDefault(require("./components/Icon"));
14
+ exports.Icon = Icon_1.default;
15
+ const Image_1 = __importDefault(require("./components/Image"));
16
+ exports.Image = Image_1.default;
17
+ const Button_1 = __importDefault(require("./components/Button"));
18
+ exports.Button = Button_1.default;
19
+ const Divider_1 = __importDefault(require("./components/Divider"));
20
+ exports.Divider = Divider_1.default;
21
+ const Modal_1 = __importDefault(require("./components/Modal"));
22
+ exports.Modal = Modal_1.default;
23
+ const PageHolder_1 = __importDefault(require("./components/PageHolder"));
24
+ exports.PageHolder = PageHolder_1.default;
25
+ const Chip_1 = __importDefault(require("./components/Chip"));
26
+ exports.Chip = Chip_1.default;
27
+ const InputField_1 = __importDefault(require("./components/InputField"));
28
+ exports.InputField = InputField_1.default;
29
+ const Dropdown_1 = __importDefault(require("./components/Dropdown"));
30
+ exports.Dropdown = Dropdown_1.default;
31
+ const ToggleInput_1 = __importDefault(require("./components/ToggleInput"));
32
+ exports.ToggleInput = ToggleInput_1.default;
33
+ const BetterHtmlProvider_1 = require("./components/BetterHtmlProvider");
34
+ Object.defineProperty(exports, "useBetterHtmlContext", { enumerable: true, get: function () { return BetterHtmlProvider_1.useBetterHtmlContext; } });
35
+ Object.defineProperty(exports, "useTheme", { enumerable: true, get: function () { return BetterHtmlProvider_1.useTheme; } });
36
+ Object.defineProperty(exports, "useLoader", { enumerable: true, get: function () { return BetterHtmlProvider_1.useLoader; } });
37
+ Object.defineProperty(exports, "useLoaderControls", { enumerable: true, get: function () { return BetterHtmlProvider_1.useLoaderControls; } });
38
+ const hooks_1 = require("./utils/hooks");
39
+ Object.defineProperty(exports, "usePageResize", { enumerable: true, get: function () { return hooks_1.usePageResize; } });
40
+ Object.defineProperty(exports, "useMediaQuery", { enumerable: true, get: function () { return hooks_1.useMediaQuery; } });
@@ -12,3 +12,4 @@ export type DeepPartialRecord<T> = {
12
12
  };
13
13
  /** returns only the required props */
14
14
  export type PickAllRequired<T, K extends keyof T> = Required<Pick<T, K>>;
15
+ export type AnyOtherString = Omit<string & {}, "">;
@@ -1,2 +1,4 @@
1
- export type AssetsConfig = Record<AssetName, string>;
2
- export type AssetName = "";
1
+ export type AssetName = "logo";
2
+ export type AssetsConfig = Record<AssetName, string> & {
3
+ [key: string]: string;
4
+ };
@@ -4,3 +4,6 @@ export type ComponentHoverStyle = {
4
4
  };
5
5
  export type ComponentMarginProps = Pick<ComponentStyle, "margin" | "marginTop" | "marginBottom" | "marginLeft" | "marginRight" | "marginBlock" | "marginInline">;
6
6
  export type ComponentPaddingProps = Pick<ComponentStyle, "padding" | "paddingTop" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingBlock" | "paddingInline">;
7
+ export type ComponentPropWithRef<ComponentRef, ComponentProps> = ComponentProps & {
8
+ ref?: React.Ref<ComponentRef>;
9
+ };
@@ -1,13 +1,14 @@
1
- import { PartialTheme, Theme } from "./theme";
1
+ import { ThemeConfig } from "./theme";
2
2
  import { AssetsConfig } from "./asset";
3
3
  import { IconsConfig } from "./icon";
4
+ import { LoaderConfig } from "./loader";
5
+ export type AppConfig = {
6
+ contentMaxWidth: number;
7
+ };
4
8
  export type BetterHtmlConfig = {
5
- theme: Theme;
9
+ app: AppConfig;
10
+ theme: ThemeConfig;
6
11
  icons: Partial<IconsConfig>;
7
12
  assets: Partial<AssetsConfig>;
8
- };
9
- export type PartialBetterHtmlConfig = {
10
- theme?: PartialTheme;
11
- icons?: Partial<IconsConfig>;
12
- assets?: Partial<AssetsConfig>;
13
+ loaders: Partial<LoaderConfig>;
13
14
  };
@@ -1,8 +1,11 @@
1
- export type IconsConfig = Record<IconName, {
1
+ export type IconName = "XMark" | "uploadCloud" | "trash" | "chevronDown" | "eye" | "eyeDashed" | "magnifyingGlass" | "check";
2
+ export type IconData = {
2
3
  width: number;
3
4
  height: number;
4
5
  paths: (React.ComponentProps<"path"> & {
5
6
  type: "fill" | "stroke";
6
7
  })[];
7
- }>;
8
- export type IconName = "";
8
+ };
9
+ export type IconsConfig = Record<IconName, IconData> & {
10
+ [key: string]: IconData;
11
+ };
@@ -1 +1,4 @@
1
1
  export type LoaderName = "";
2
+ export type LoaderConfig = Record<LoaderName, boolean | undefined> & {
3
+ [key: string]: boolean | undefined;
4
+ };
@@ -1,3 +1,6 @@
1
+ export type Color = `#${string}` | "transparent";
2
+ export type ColorName = "textPrimary" | "textSecondary" | "label" | "primary" | "secondary" | "success" | "info" | "warn" | "error" | "base" | "backgroundBase" | "backgroundSecondary" | "backgroundContent" | "border";
3
+ export type ColorTheme = "light" | "dark";
1
4
  export type Styles = {
2
5
  space: number;
3
6
  gap: number;
@@ -5,13 +8,12 @@ export type Styles = {
5
8
  fontFamily: string;
6
9
  transition: string;
7
10
  };
8
- export type Color = `#${string}` | "transparent";
9
- export type Colors = Record<"textPrimary" | "textSecondary" | "label" | "primary" | "secondary" | "success" | "info" | "warn" | "error" | "backgroundBase" | "backgroundSecondary" | "backgroundContent" | "border", Color>;
11
+ export type Colors = Record<ColorName, Color>;
10
12
  export type Theme = {
11
13
  styles: Styles;
12
14
  colors: Colors;
13
15
  };
14
- export type PartialTheme = {
15
- styles?: Partial<Styles>;
16
- colors?: Partial<Colors>;
16
+ export type ThemeConfig = {
17
+ styles: Styles;
18
+ colors: Record<ColorTheme, Colors>;
17
19
  };
@@ -1,8 +1,41 @@
1
1
  import { ComponentHoverStyle, ComponentStyle } from "../types/components";
2
2
  import { Theme } from "../types/theme";
3
- export declare function useStyledComponentStyles(props: ComponentStyle & ComponentHoverStyle, theme?: Theme): {
3
+ export declare function useStyledComponentStyles(props: ComponentStyle & ComponentHoverStyle, theme?: Theme,
4
+ /** @default false */
5
+ excludeProps?: boolean): {
4
6
  normalStyle: ComponentStyle;
5
7
  hoverStyle: ComponentStyle;
6
8
  };
7
9
  export declare function useComponentPropsWithPrefix<Props extends Record<string, any>, Prefix extends string>(props: Props, prefix: Prefix): Record<`${Prefix}-${string}`, any>;
10
+ export declare function useComponentPropsWithExcludedStyle<Props extends Record<string, any>>(props: Props): Partial<Props>;
8
11
  export declare function useComponentPropsWithoutStyle<Props extends Record<string, any>>(props: Props): Partial<Props>;
12
+ export declare function usePageResize(): {
13
+ width: number;
14
+ height: number;
15
+ };
16
+ export declare function useMediaQuery(): {
17
+ size320: boolean;
18
+ size400: boolean;
19
+ size500: boolean;
20
+ size600: boolean;
21
+ size700: boolean;
22
+ size800: boolean;
23
+ size900: boolean;
24
+ size1000: boolean;
25
+ size1100: boolean;
26
+ size1200: boolean;
27
+ size1300: boolean;
28
+ size1400: boolean;
29
+ size1500: boolean;
30
+ size1600: boolean;
31
+ };
32
+ export declare function useBooleanState(initialValue?: boolean): [
33
+ state: boolean,
34
+ actions: {
35
+ setState: React.Dispatch<React.SetStateAction<boolean>>;
36
+ setTrue: () => void;
37
+ setFalse: () => void;
38
+ toggle: () => void;
39
+ }
40
+ ];
41
+ export declare function useDebounceState<Value>(initialValue: Value, delay?: number): [value: Value, debouncedValue: Value, setValue: React.Dispatch<React.SetStateAction<Value>>, isLoading: boolean];