react-better-html 1.1.161 → 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;
@@ -1012,7 +1012,9 @@ type AlertsPluginOptions = {
1012
1012
  declare const defaultAlertsPluginOptions: Required<AlertsPluginOptions>;
1013
1013
  declare const alertsPlugin: BetterHtmlPluginConstructor<AlertsPluginOptions>;
1014
1014
 
1015
- type ReactRouterDomPluginOptions = {};
1015
+ type ReactRouterDomPluginOptions = {
1016
+ reactRouterDomLib: typeof reactRouterDomLib;
1017
+ };
1016
1018
  declare const defaultReactRouterDomPluginOptions: Required<ReactRouterDomPluginOptions>;
1017
1019
  declare const reactRouterDomPlugin: BetterHtmlPluginConstructor<ReactRouterDomPluginOptions>;
1018
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;
@@ -1012,7 +1012,9 @@ type AlertsPluginOptions = {
1012
1012
  declare const defaultAlertsPluginOptions: Required<AlertsPluginOptions>;
1013
1013
  declare const alertsPlugin: BetterHtmlPluginConstructor<AlertsPluginOptions>;
1014
1014
 
1015
- type ReactRouterDomPluginOptions = {};
1015
+ type ReactRouterDomPluginOptions = {
1016
+ reactRouterDomLib: typeof reactRouterDomLib;
1017
+ };
1016
1018
  declare const defaultReactRouterDomPluginOptions: Required<ReactRouterDomPluginOptions>;
1017
1019
  declare const reactRouterDomPlugin: BetterHtmlPluginConstructor<ReactRouterDomPluginOptions>;
1018
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()
@@ -5586,8 +5584,8 @@ var encryptString = (text) => {
5586
5584
  "`encryptString` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
5587
5585
  );
5588
5586
  }
5589
- const pluginConfig = localStoragePlugin2.getConfig?.() ?? {};
5590
- if (!pluginConfig?.encryption?.enabled) return text;
5587
+ const pluginConfig = localStoragePlugin2.getConfig();
5588
+ if (!pluginConfig.encryption?.enabled) return text;
5591
5589
  const encrypted = import_crypto_js.default.AES.encrypt(text, import_crypto_js.default.enc.Hex.parse(pluginConfig.encryption.secretKey), {
5592
5590
  iv: import_crypto_js.default.enc.Hex.parse(pluginConfig.encryption.iv),
5593
5591
  mode: import_crypto_js.default.mode.CBC,
@@ -5603,8 +5601,8 @@ var decryptString = (text) => {
5603
5601
  "`decryptString` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
5604
5602
  );
5605
5603
  }
5606
- const pluginConfig = localStoragePlugin2.getConfig?.() ?? {};
5607
- if (!pluginConfig?.encryption?.enabled) return text;
5604
+ const pluginConfig = localStoragePlugin2.getConfig();
5605
+ if (!pluginConfig.encryption?.enabled) return text;
5608
5606
  const decrypted = import_crypto_js.default.AES.decrypt(text, import_crypto_js.default.enc.Hex.parse(pluginConfig.encryption.secretKey), {
5609
5607
  iv: import_crypto_js.default.enc.Hex.parse(pluginConfig.encryption.iv),
5610
5608
  mode: import_crypto_js.default.mode.CBC,
@@ -9194,7 +9192,7 @@ function generateLocalStorage() {
9194
9192
  "`generateLocalStorage` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
9195
9193
  );
9196
9194
  }
9197
- const pluginConfig = localStoragePlugin2.getConfig?.() ?? {};
9195
+ const pluginConfig = localStoragePlugin2.getConfig();
9198
9196
  const encryptionEnabled = pluginConfig.encryption?.enabled ?? false;
9199
9197
  const readyName = encryptionEnabled ? encryptString(name.toString()) : name;
9200
9198
  const readyValue = encryptionEnabled ? encryptString(JSON.stringify(value)) : JSON.stringify(value);
@@ -9212,7 +9210,7 @@ function generateLocalStorage() {
9212
9210
  "`generateLocalStorage` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
9213
9211
  );
9214
9212
  }
9215
- const pluginConfig = localStoragePlugin2.getConfig?.() ?? {};
9213
+ const pluginConfig = localStoragePlugin2.getConfig();
9216
9214
  const encryptionEnabled = pluginConfig.encryption?.enabled ?? false;
9217
9215
  const readyName = encryptionEnabled ? encryptString(name.toString()) : name;
9218
9216
  const item = localStorage.getItem(readyName.toString());
@@ -9234,7 +9232,7 @@ function generateLocalStorage() {
9234
9232
  "`generateLocalStorage` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
9235
9233
  );
9236
9234
  }
9237
- const pluginConfig = localStoragePlugin2.getConfig?.() ?? {};
9235
+ const pluginConfig = localStoragePlugin2.getConfig();
9238
9236
  const encryptionEnabled = pluginConfig.encryption?.enabled ?? false;
9239
9237
  const readyName = encryptionEnabled ? encryptString(name.toString()) : name;
9240
9238
  localStorage.removeItem(readyName.toString());