react-better-html 1.1.160 → 1.1.162

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,15 +1,15 @@
1
1
  import { WebTarget } from 'styled-components';
2
2
  import * as react from 'react';
3
- import { ComponentType, ComponentProps, ReactNode } from 'react';
3
+ import { ComponentProps, ReactNode } from 'react';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
+ import * as reactRouterDomLib from 'react-router-dom';
5
6
 
6
7
  type PluginName = "alerts" | "react-router-dom" | "localStorage";
7
8
  type BetterHtmlPluginConstructor<T extends object = object> = (config?: T) => BetterHtmlPlugin<T>;
8
9
  type BetterHtmlPlugin<T = object> = {
9
10
  name: PluginName;
10
- components?: Record<string, ComponentType<any>>;
11
11
  initialize?: () => void;
12
- getConfig?: () => T;
12
+ getConfig: () => T;
13
13
  };
14
14
 
15
15
  type ComponentStyle = React.CSSProperties;
@@ -319,14 +319,17 @@ declare const Modal: typeof ModalComponent & {
319
319
  type PageHolderProps = {
320
320
  /** @default false */
321
321
  noMaxContentWidth?: boolean;
322
- backgroundColor?: string;
322
+ backgroundColor?: React.CSSProperties["backgroundColor"];
323
+ backgroundImage?: React.CSSProperties["backgroundImage"];
323
324
  children?: React.ReactNode;
324
325
  } & ComponentPaddingProps;
325
326
  type PageHolderComponentType = {
326
327
  (props: ComponentPropWithRef<HTMLDivElement, PageHolderProps>): React.ReactElement;
327
328
  center: (props: ComponentPropWithRef<HTMLDivElement, PageHolderProps & {
328
- pageBackgroundColor?: string;
329
+ pageBackgroundColor?: React.CSSProperties["backgroundColor"];
330
+ pageBackgroundImage?: React.CSSProperties["backgroundImage"];
329
331
  contentMaxWidth?: React.CSSProperties["maxWidth"];
332
+ behindComponent?: React.ReactNode;
330
333
  sideComponent?: React.ReactNode;
331
334
  /** @default "right" */
332
335
  sideComponentPosition?: "left" | "right";
@@ -1009,7 +1012,9 @@ type AlertsPluginOptions = {
1009
1012
  declare const defaultAlertsPluginOptions: Required<AlertsPluginOptions>;
1010
1013
  declare const alertsPlugin: BetterHtmlPluginConstructor<AlertsPluginOptions>;
1011
1014
 
1012
- type ReactRouterDomPluginOptions = {};
1015
+ type ReactRouterDomPluginOptions = {
1016
+ reactRouterDomLib: typeof reactRouterDomLib;
1017
+ };
1013
1018
  declare const defaultReactRouterDomPluginOptions: Required<ReactRouterDomPluginOptions>;
1014
1019
  declare const reactRouterDomPlugin: BetterHtmlPluginConstructor<ReactRouterDomPluginOptions>;
1015
1020
 
package/dist/index.d.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  import { WebTarget } from 'styled-components';
2
2
  import * as react from 'react';
3
- import { ComponentType, ComponentProps, ReactNode } from 'react';
3
+ import { ComponentProps, ReactNode } from 'react';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
+ import * as reactRouterDomLib from 'react-router-dom';
5
6
 
6
7
  type PluginName = "alerts" | "react-router-dom" | "localStorage";
7
8
  type BetterHtmlPluginConstructor<T extends object = object> = (config?: T) => BetterHtmlPlugin<T>;
8
9
  type BetterHtmlPlugin<T = object> = {
9
10
  name: PluginName;
10
- components?: Record<string, ComponentType<any>>;
11
11
  initialize?: () => void;
12
- getConfig?: () => T;
12
+ getConfig: () => T;
13
13
  };
14
14
 
15
15
  type ComponentStyle = React.CSSProperties;
@@ -319,14 +319,17 @@ declare const Modal: typeof ModalComponent & {
319
319
  type PageHolderProps = {
320
320
  /** @default false */
321
321
  noMaxContentWidth?: boolean;
322
- backgroundColor?: string;
322
+ backgroundColor?: React.CSSProperties["backgroundColor"];
323
+ backgroundImage?: React.CSSProperties["backgroundImage"];
323
324
  children?: React.ReactNode;
324
325
  } & ComponentPaddingProps;
325
326
  type PageHolderComponentType = {
326
327
  (props: ComponentPropWithRef<HTMLDivElement, PageHolderProps>): React.ReactElement;
327
328
  center: (props: ComponentPropWithRef<HTMLDivElement, PageHolderProps & {
328
- pageBackgroundColor?: string;
329
+ pageBackgroundColor?: React.CSSProperties["backgroundColor"];
330
+ pageBackgroundImage?: React.CSSProperties["backgroundImage"];
329
331
  contentMaxWidth?: React.CSSProperties["maxWidth"];
332
+ behindComponent?: React.ReactNode;
330
333
  sideComponent?: React.ReactNode;
331
334
  /** @default "right" */
332
335
  sideComponentPosition?: "left" | "right";
@@ -1009,7 +1012,9 @@ type AlertsPluginOptions = {
1009
1012
  declare const defaultAlertsPluginOptions: Required<AlertsPluginOptions>;
1010
1013
  declare const alertsPlugin: BetterHtmlPluginConstructor<AlertsPluginOptions>;
1011
1014
 
1012
- type ReactRouterDomPluginOptions = {};
1015
+ type ReactRouterDomPluginOptions = {
1016
+ reactRouterDomLib: typeof reactRouterDomLib;
1017
+ };
1013
1018
  declare const defaultReactRouterDomPluginOptions: Required<ReactRouterDomPluginOptions>;
1014
1019
  declare const reactRouterDomPlugin: BetterHtmlPluginConstructor<ReactRouterDomPluginOptions>;
1015
1020
 
package/dist/index.js CHANGED
@@ -102,7 +102,6 @@ var isMobileDevice = /Mobi|Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Op
102
102
 
103
103
  // src/utils/hooks.ts
104
104
  var import_react10 = require("react");
105
- var import_react_router_dom2 = require("react-router-dom");
106
105
 
107
106
  // src/constants/css.ts
108
107
  var cssProps = {
@@ -1640,14 +1639,12 @@ var alertsPlugin = (options) => ({
1640
1639
  });
1641
1640
 
1642
1641
  // src/plugins/reactRouterDom.ts
1643
- var import_react_router_dom = require("react-router-dom");
1644
- var defaultReactRouterDomPluginOptions = {};
1642
+ var reactRouterDomLib = __toESM(require("react-router-dom"));
1643
+ var defaultReactRouterDomPluginOptions = {
1644
+ reactRouterDomLib
1645
+ };
1645
1646
  var reactRouterDomPlugin = (options) => ({
1646
1647
  name: "react-router-dom",
1647
- components: {
1648
- Link: import_react_router_dom.Link,
1649
- NavLink: import_react_router_dom.NavLink
1650
- },
1651
1648
  initialize: () => {
1652
1649
  console.log("react-router-dom plugin initialized");
1653
1650
  },
@@ -2301,7 +2298,7 @@ function Alert2({ alert }) {
2301
2298
  const theme2 = useTheme();
2302
2299
  const alertControls2 = useAlertControls();
2303
2300
  const alertsPlugin2 = usePlugin("alerts");
2304
- const pluginConfig = alertsPlugin2?.getConfig?.() ?? {};
2301
+ const pluginConfig = alertsPlugin2?.getConfig() ?? {};
2305
2302
  const defaultAlertDurationNumber = getAlertDurationFromAuto(
2306
2303
  alert.duration ?? pluginConfig.defaultDuration ?? defaultAlertsPluginOptions.defaultDuration,
2307
2304
  alert
@@ -2463,7 +2460,7 @@ function AlertsHolder() {
2463
2460
  const theme2 = useTheme();
2464
2461
  const alertsPlugin2 = usePlugin("alerts");
2465
2462
  const { alerts } = useBetterHtmlContextInternal();
2466
- const pluginConfig = alertsPlugin2?.getConfig?.() ?? {};
2463
+ const pluginConfig = alertsPlugin2?.getConfig() ?? {};
2467
2464
  const top = pluginConfig.position === "top" ? theme2.styles.gap : void 0;
2468
2465
  const bottom = pluginConfig.position === "bottom" ? theme2.styles.gap : void 0;
2469
2466
  const left = pluginConfig.align === "left" ? theme2.styles.space : pluginConfig.align === "center" ? "50%" : void 0;
@@ -3156,14 +3153,15 @@ function useUrlQuery() {
3156
3153
  "`useUrlQuery` hook requires the `react-router-dom` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
3157
3154
  );
3158
3155
  }
3159
- const isInRouterContext = (0, import_react_router_dom2.useInRouterContext)();
3156
+ const reactRouterDomPluginConfig = reactRouterDomPlugin2.getConfig();
3157
+ const isInRouterContext = reactRouterDomPluginConfig.reactRouterDomLib.useInRouterContext();
3160
3158
  if (!isInRouterContext) {
3161
3159
  throw new Error(
3162
3160
  "`useUrlQuery` hook must be used inside a React Router context. Make sure your component is wrapped in a `<BrowserRouter>`, or another Router component."
3163
3161
  );
3164
3162
  }
3165
- const navigate = (0, import_react_router_dom2.useNavigate)();
3166
- const [searchParams] = (0, import_react_router_dom2.useSearchParams)();
3163
+ const navigate = reactRouterDomPluginConfig.reactRouterDomLib.useNavigate();
3164
+ const [searchParams] = reactRouterDomPluginConfig.reactRouterDomLib.useSearchParams();
3167
3165
  const setQuery = (0, import_react10.useCallback)(
3168
3166
  (query, keepHistory = true) => {
3169
3167
  const currentSearchParams = {};
@@ -3172,7 +3170,7 @@ function useUrlQuery() {
3172
3170
  });
3173
3171
  navigate(
3174
3172
  {
3175
- search: (0, import_react_router_dom2.createSearchParams)({
3173
+ search: reactRouterDomPluginConfig.reactRouterDomLib.createSearchParams({
3176
3174
  ...currentSearchParams,
3177
3175
  ...Object.fromEntries(Object.entries(query).map(([key, value]) => [key, value.toString()]))
3178
3176
  }).toString()
@@ -3659,7 +3657,9 @@ var PageHolderComponent = (0, import_react14.forwardRef)(function PageHolder({ n
3659
3657
  });
3660
3658
  PageHolderComponent.center = (0, import_react14.forwardRef)(function Center({
3661
3659
  pageBackgroundColor,
3660
+ pageBackgroundImage,
3662
3661
  contentMaxWidth,
3662
+ behindComponent,
3663
3663
  sideComponent,
3664
3664
  sideComponentPosition = "right",
3665
3665
  noMaxContentWidth,
@@ -3674,17 +3674,32 @@ PageHolderComponent.center = (0, import_react14.forwardRef)(function Center({
3674
3674
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
3675
3675
  Div_default.row,
3676
3676
  {
3677
+ position: "relative",
3677
3678
  width: "100%",
3678
3679
  minHeight: "100svh",
3679
3680
  alignItems: "center",
3680
3681
  justifyContent: "center",
3681
3682
  backgroundColor: pageBackgroundColor,
3683
+ backgroundImage: pageBackgroundImage,
3682
3684
  children: [
3685
+ behindComponent && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3686
+ Div_default,
3687
+ {
3688
+ position: "fixed",
3689
+ width: `${withSideComponent ? 50 : 100}%`,
3690
+ height: "100svh",
3691
+ top: 0,
3692
+ left: sideComponentPosition === "right" ? 0 : "auto",
3693
+ right: sideComponentPosition === "left" ? 0 : "auto",
3694
+ zIndex: 1,
3695
+ children: behindComponent
3696
+ }
3697
+ ),
3683
3698
  sideComponentPosition === "left" && withSideComponent && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Div_default, { width: "50%" }),
3684
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Div_default.column, { width: `${withSideComponent ? 50 : 100}%`, alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3699
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Div_default.column, { position: "relative", width: `${withSideComponent ? 50 : 100}%`, alignItems: "center", zIndex: 2, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3685
3700
  Div_default.box,
3686
3701
  {
3687
- width: `calc(100% - ${theme2.styles.space}px * 2)`,
3702
+ width: `calc(100% - ${theme2.styles.space * 2}px)`,
3688
3703
  maxWidth: !noMaxContentWidth ? contentMaxWidth ?? app.contentMaxWidth / 2 : void 0,
3689
3704
  marginInline: theme2.styles.space,
3690
3705
  marginBlock: theme2.styles.space,
@@ -5569,8 +5584,8 @@ var encryptString = (text) => {
5569
5584
  "`encryptString` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
5570
5585
  );
5571
5586
  }
5572
- const pluginConfig = localStoragePlugin2.getConfig?.() ?? {};
5573
- if (!pluginConfig?.encryption?.enabled) return text;
5587
+ const pluginConfig = localStoragePlugin2.getConfig();
5588
+ if (!pluginConfig.encryption?.enabled) return text;
5574
5589
  const encrypted = import_crypto_js.default.AES.encrypt(text, import_crypto_js.default.enc.Hex.parse(pluginConfig.encryption.secretKey), {
5575
5590
  iv: import_crypto_js.default.enc.Hex.parse(pluginConfig.encryption.iv),
5576
5591
  mode: import_crypto_js.default.mode.CBC,
@@ -5586,8 +5601,8 @@ var decryptString = (text) => {
5586
5601
  "`decryptString` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
5587
5602
  );
5588
5603
  }
5589
- const pluginConfig = localStoragePlugin2.getConfig?.() ?? {};
5590
- if (!pluginConfig?.encryption?.enabled) return text;
5604
+ const pluginConfig = localStoragePlugin2.getConfig();
5605
+ if (!pluginConfig.encryption?.enabled) return text;
5591
5606
  const decrypted = import_crypto_js.default.AES.decrypt(text, import_crypto_js.default.enc.Hex.parse(pluginConfig.encryption.secretKey), {
5592
5607
  iv: import_crypto_js.default.enc.Hex.parse(pluginConfig.encryption.iv),
5593
5608
  mode: import_crypto_js.default.mode.CBC,
@@ -9177,7 +9192,7 @@ function generateLocalStorage() {
9177
9192
  "`generateLocalStorage` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
9178
9193
  );
9179
9194
  }
9180
- const pluginConfig = localStoragePlugin2.getConfig?.() ?? {};
9195
+ const pluginConfig = localStoragePlugin2.getConfig();
9181
9196
  const encryptionEnabled = pluginConfig.encryption?.enabled ?? false;
9182
9197
  const readyName = encryptionEnabled ? encryptString(name.toString()) : name;
9183
9198
  const readyValue = encryptionEnabled ? encryptString(JSON.stringify(value)) : JSON.stringify(value);
@@ -9195,7 +9210,7 @@ function generateLocalStorage() {
9195
9210
  "`generateLocalStorage` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
9196
9211
  );
9197
9212
  }
9198
- const pluginConfig = localStoragePlugin2.getConfig?.() ?? {};
9213
+ const pluginConfig = localStoragePlugin2.getConfig();
9199
9214
  const encryptionEnabled = pluginConfig.encryption?.enabled ?? false;
9200
9215
  const readyName = encryptionEnabled ? encryptString(name.toString()) : name;
9201
9216
  const item = localStorage.getItem(readyName.toString());
@@ -9217,7 +9232,7 @@ function generateLocalStorage() {
9217
9232
  "`generateLocalStorage` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
9218
9233
  );
9219
9234
  }
9220
- const pluginConfig = localStoragePlugin2.getConfig?.() ?? {};
9235
+ const pluginConfig = localStoragePlugin2.getConfig();
9221
9236
  const encryptionEnabled = pluginConfig.encryption?.enabled ?? false;
9222
9237
  const readyName = encryptionEnabled ? encryptString(name.toString()) : name;
9223
9238
  localStorage.removeItem(readyName.toString());