react-better-html 1.1.47 → 1.1.49

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.
@@ -1,5 +1,5 @@
1
1
  import { BetterHtmlConfig } from "../types/config";
2
- import { AnyOtherString, DeepPartialRecord } from "../types/app";
2
+ import { AnyOtherString, DeepPartialRecord, OmitProps } from "../types/app";
3
3
  import { LoaderName } from "../types/loader";
4
4
  import { BetterHtmlPlugin, PluginName } from "../types/plugin";
5
5
  export declare const useBetterHtmlContext: () => BetterHtmlConfig;
@@ -13,8 +13,9 @@ export declare const useLoaderControls: () => {
13
13
  stopLoading: (loaderName: LoaderName | AnyOtherString) => void;
14
14
  };
15
15
  export declare const usePlugin: (pluginName: PluginName) => BetterHtmlPlugin | undefined;
16
+ export type BetterHtmlProviderValue = DeepPartialRecord<OmitProps<BetterHtmlConfig, "colorTheme">>;
16
17
  type BetterHtmlProviderProps = {
17
- value?: DeepPartialRecord<BetterHtmlConfig>;
18
+ value?: BetterHtmlProviderValue;
18
19
  plugins?: BetterHtmlPlugin[];
19
20
  children?: React.ReactNode;
20
21
  };
@@ -32,7 +32,7 @@ const useBetterHtmlContext = () => {
32
32
  const context = (0, react_1.useContext)(betterHtmlContext);
33
33
  if (context === undefined)
34
34
  throw new Error("`useBetterHtmlContext()` must be used within a `<BetterHtmlProvider>`. Make sure to add one at the root of your component tree.");
35
- const { setLoaders, ...rest } = context;
35
+ const { setLoaders, plugins, ...rest } = context;
36
36
  return rest;
37
37
  };
38
38
  exports.useBetterHtmlContext = useBetterHtmlContext;
@@ -13,12 +13,13 @@ const Text_1 = __importDefault(require("./Text"));
13
13
  const Divider_1 = __importDefault(require("./Divider"));
14
14
  const BetterHtmlProvider_1 = require("./BetterHtmlProvider");
15
15
  const DialogStylesElement = styled_components_1.default.dialog.withConfig({
16
- shouldForwardProp: (prop) => !["theme", "opacity"].includes(prop),
16
+ shouldForwardProp: (prop) => !["theme", "colorTheme", "opacity"].includes(prop),
17
17
  }) `
18
18
  width: 100%;
19
19
  max-width: none;
20
20
  height: 100%;
21
21
  max-height: none;
22
+ color: ${(props) => props.theme.colors.textPrimary};
22
23
  border: none;
23
24
  outline: none;
24
25
  background-color: transparent;
@@ -28,7 +29,7 @@ const DialogStylesElement = styled_components_1.default.dialog.withConfig({
28
29
  transition: ${(props) => props.theme.styles.transition};
29
30
 
30
31
  &::backdrop {
31
- background-color: #000000a0;
32
+ background-color: ${(props) => (props.colorTheme === "light" ? "#000000a0" : "#000000e0")};
32
33
  opacity: ${(props) => props.opacity};
33
34
  transition: ${(props) => props.theme.styles.transition};
34
35
  }
@@ -55,7 +56,7 @@ const ModalComponent = (0, react_1.forwardRef)(function Modal({ maxWidth, title,
55
56
  const reactRouterDomPlugin = (0, BetterHtmlProvider_1.usePlugin)("react-router-dom");
56
57
  const urlQuery = reactRouterDomPlugin ? (0, hooks_1.useUrlQuery)() : undefined;
57
58
  const theme = (0, BetterHtmlProvider_1.useTheme)();
58
- const { app } = (0, BetterHtmlProvider_1.useBetterHtmlContext)();
59
+ const { app, colorTheme } = (0, BetterHtmlProvider_1.useBetterHtmlContext)();
59
60
  const dialogRef = (0, react_1.useRef)(null);
60
61
  const [isOpened, setIsOpened] = (0, react_1.useState)(false);
61
62
  const [isOpenedLate, setIsOpenedLate] = (0, react_1.useState)(false);
@@ -86,7 +87,7 @@ const ModalComponent = (0, react_1.forwardRef)(function Modal({ maxWidth, title,
86
87
  isOpened,
87
88
  };
88
89
  }, [onClickOpen, onClickClose, isOpened]);
89
- return ((0, jsx_runtime_1.jsx)(DialogStylesElement, { theme: theme, opacity: !isOpened ? 0 : 1, onClose: onClickClose, ref: dialogRef, children: isOpenedLate ? ((0, jsx_runtime_1.jsx)(Div_1.default.column, { position: "relative", width: "100%", maxWidth: maxWidth ?? app.contentMaxWidth / 1.3, minHeight: `calc(100% - ${theme.styles.space * 2}px)`, alignItems: "center", justifyContent: "center", marginBlock: theme.styles.space, marginInline: "auto", transform: `translateY(${theme.styles.space}px)`, transition: theme.styles.transition, animation: isOpened ? "fadeInAnimation 0.2s ease forwards" : "fadeOutAnimation 0.2s ease forwards", children: (0, jsx_runtime_1.jsxs)(Div_1.default, { position: "relative", width: "100%", minHeight: 32 + theme.styles.space * 2, backgroundColor: theme.colors.backgroundBase, borderRadius: theme.styles.borderRadius * 2, paddingInline: !title ? theme.styles.space + theme.styles.gap : undefined, paddingBlock: !title ? theme.styles.space : undefined, overflow: overflow, children: [title ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(Div_1.default.row, { alignItems: "center", gap: theme.styles.gap, backgroundColor: headerBackgroundColor, borderTopLeftRadius: theme.styles.borderRadius * 2, borderTopRightRadius: theme.styles.borderRadius * 2, paddingInline: theme.styles.space + theme.styles.gap, paddingBlock: theme.styles.space, children: [(0, jsx_runtime_1.jsxs)(Div_1.default.column, { flex: 1, gap: theme.styles.gap / 2, children: [(0, jsx_runtime_1.jsx)(Text_1.default, { as: "h1", color: titleColor ?? theme.colors.textPrimary, children: title }), description && ((0, jsx_runtime_1.jsx)(Text_1.default, { color: descriptionColor ?? theme.colors.textSecondary, children: description }))] }), (0, jsx_runtime_1.jsx)(Button_1.default.icon, { icon: "XMark", marginTop: 1, iconColor: titleColor, onClick: onClickClose })] }), (0, jsx_runtime_1.jsx)(Divider_1.default.horizontal, {})] })) : ((0, jsx_runtime_1.jsx)(Div_1.default, { position: "absolute", top: theme.styles.space, right: theme.styles.space, children: (0, jsx_runtime_1.jsx)(Button_1.default.icon, { icon: "XMark", onClick: onClickClose }) })), (0, jsx_runtime_1.jsx)(Div_1.default, { paddingInline: title ? theme.styles.space + theme.styles.gap : undefined, paddingBlock: title ? theme.styles.space : undefined, children: children })] }) })) : undefined }));
90
+ return ((0, jsx_runtime_1.jsx)(DialogStylesElement, { theme: theme, colorTheme: colorTheme, opacity: !isOpened ? 0 : 1, onClose: onClickClose, ref: dialogRef, children: isOpenedLate ? ((0, jsx_runtime_1.jsx)(Div_1.default.column, { position: "relative", width: "100%", maxWidth: maxWidth ?? app.contentMaxWidth / 1.3, minHeight: `calc(100% - ${theme.styles.space * 2}px)`, alignItems: "center", justifyContent: "center", marginBlock: theme.styles.space, marginInline: "auto", transform: `translateY(${theme.styles.space}px)`, transition: theme.styles.transition, animation: isOpened ? "fadeInAnimation 0.2s ease forwards" : "fadeOutAnimation 0.2s ease forwards", children: (0, jsx_runtime_1.jsxs)(Div_1.default, { position: "relative", width: "100%", minHeight: 32 + theme.styles.space * 2, backgroundColor: theme.colors.backgroundBase, borderRadius: theme.styles.borderRadius * 2, paddingInline: !title ? theme.styles.space + theme.styles.gap : undefined, paddingBlock: !title ? theme.styles.space : undefined, overflow: overflow, children: [title ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(Div_1.default.row, { alignItems: "center", gap: theme.styles.gap, backgroundColor: headerBackgroundColor, borderTopLeftRadius: theme.styles.borderRadius * 2, borderTopRightRadius: theme.styles.borderRadius * 2, paddingInline: theme.styles.space + theme.styles.gap, paddingBlock: theme.styles.space, children: [(0, jsx_runtime_1.jsxs)(Div_1.default.column, { flex: 1, gap: theme.styles.gap / 2, children: [(0, jsx_runtime_1.jsx)(Text_1.default, { as: "h1", color: titleColor ?? theme.colors.textPrimary, children: title }), description && ((0, jsx_runtime_1.jsx)(Text_1.default, { color: descriptionColor ?? theme.colors.textSecondary, children: description }))] }), (0, jsx_runtime_1.jsx)(Button_1.default.icon, { icon: "XMark", marginTop: 1, iconColor: titleColor, onClick: onClickClose })] }), (0, jsx_runtime_1.jsx)(Divider_1.default.horizontal, {})] })) : ((0, jsx_runtime_1.jsx)(Div_1.default, { position: "absolute", top: theme.styles.space, right: theme.styles.space, children: (0, jsx_runtime_1.jsx)(Button_1.default.icon, { icon: "XMark", onClick: onClickClose }) })), (0, jsx_runtime_1.jsx)(Div_1.default, { paddingInline: title ? theme.styles.space + theme.styles.gap : undefined, paddingBlock: title ? theme.styles.space : undefined, children: children })] }) })) : undefined }));
90
91
  });
91
92
  ModalComponent.confirmation = (0, react_1.forwardRef)(function Confirmation({ continueButtonLoaderName, onContinue, onCancel, ...props }, ref) {
92
93
  const theme = (0, BetterHtmlProvider_1.useTheme)();
package/dist/index.d.ts CHANGED
@@ -16,7 +16,7 @@ import Form from "./components/Form";
16
16
  import Label from "./components/Label";
17
17
  import FormRow from "./components/FormRow";
18
18
  import ColorThemeSwitch from "./components/ColorThemeSwitch";
19
- import BetterHtmlProvider, { useBetterHtmlContext, useTheme, useLoader, useLoaderControls } from "./components/BetterHtmlProvider";
19
+ import BetterHtmlProvider, { useBetterHtmlContext, useTheme, useLoader, useLoaderControls, type BetterHtmlProviderValue } from "./components/BetterHtmlProvider";
20
20
  import { usePageResize, usePageScroll, useMediaQuery, useBooleanState, useDebounceState, useForm, useUrlQuery } from "./utils/hooks";
21
21
  import { generateRandomString, getBrowser, formatPhoneNumber, getFormErrorObject } from "./utils/functions";
22
22
  import { type OmitProps, type ExcludeOptions, type PickValue, type PartialRecord, type DeepPartialRecord, type PickAllRequired } from "./types/app";
@@ -29,4 +29,4 @@ import { type Color, type ColorName, type ColorTheme, type Colors, type Styles,
29
29
  import { type BrowserName } from "./types/other";
30
30
  import { isMobileDevice } from "./constants";
31
31
  export * from "./plugins";
32
- export { BetterHtmlProvider, Div, Text, Loader, Icon, Image, Button, Divider, Modal, ModalRef, PageHolder, PageHeader, Chip, InputField, Dropdown, DropdownOption, ToggleInput, Form, Label, FormRow, ColorThemeSwitch, useBetterHtmlContext, useTheme, useLoader, useLoaderControls, usePageResize, usePageScroll, useMediaQuery, useBooleanState, useDebounceState, useForm, useUrlQuery, generateRandomString, getBrowser, formatPhoneNumber, getFormErrorObject, OmitProps, ExcludeOptions, PickValue, PartialRecord, DeepPartialRecord, PickAllRequired, AppConfig, BetterHtmlConfig, AssetName, AssetsConfig, IconName, IconsConfig, LoaderName, PluginName, BetterHtmlPlugin, LoaderConfig, Color, ColorName, ColorTheme, Colors, Styles, Theme, ThemeConfig, BrowserName, isMobileDevice, };
32
+ export { BetterHtmlProvider, BetterHtmlProviderValue, Div, Text, Loader, Icon, Image, Button, Divider, Modal, ModalRef, PageHolder, PageHeader, Chip, InputField, Dropdown, DropdownOption, ToggleInput, Form, Label, FormRow, ColorThemeSwitch, useBetterHtmlContext, useTheme, useLoader, useLoaderControls, usePageResize, usePageScroll, useMediaQuery, useBooleanState, useDebounceState, useForm, useUrlQuery, generateRandomString, getBrowser, formatPhoneNumber, getFormErrorObject, OmitProps, ExcludeOptions, PickValue, PartialRecord, DeepPartialRecord, PickAllRequired, AppConfig, BetterHtmlConfig, AssetName, AssetsConfig, IconName, IconsConfig, LoaderName, PluginName, BetterHtmlPlugin, LoaderConfig, Color, ColorName, ColorTheme, Colors, Styles, Theme, ThemeConfig, BrowserName, isMobileDevice, };
@@ -1,4 +1,4 @@
1
- import { ThemeConfig } from "./theme";
1
+ import { ColorTheme, ThemeConfig } from "./theme";
2
2
  import { AssetsConfig } from "./asset";
3
3
  import { IconsConfig } from "./icon";
4
4
  import { LoaderConfig } from "./loader";
@@ -12,6 +12,7 @@ type ComponentConfig<Subcomponents extends string> = {
12
12
  export type BetterHtmlConfig = {
13
13
  app: AppConfig;
14
14
  theme: ThemeConfig;
15
+ colorTheme: ColorTheme;
15
16
  icons: Partial<IconsConfig>;
16
17
  assets: Partial<AssetsConfig>;
17
18
  loaders: Partial<LoaderConfig>;
@@ -47,7 +47,7 @@ export declare function useBooleanState(initialValue?: boolean): [
47
47
  }
48
48
  ];
49
49
  export declare function useDebounceState<Value>(initialValue: Value, delay?: number): [value: Value, debouncedValue: Value, setValue: React.Dispatch<React.SetStateAction<Value>>, isLoading: boolean];
50
- export declare function useForm<FormFields extends Record<string, string | number | boolean | undefined>>(options: {
50
+ export declare function useForm<FormFields extends Record<string | number, string | number | boolean | undefined>>(options: {
51
51
  defaultValues: FormFields;
52
52
  requiredFields?: (keyof FormFields)[];
53
53
  onSubmit?: (values: FormFields) => void | Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-better-html",
3
- "version": "1.1.47",
3
+ "version": "1.1.49",
4
4
  "description": "A component library for react that is as close to plane html as possible",
5
5
  "main": "dist/index.js",
6
6
  "files": [