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.mjs CHANGED
@@ -9,7 +9,6 @@ var isMobileDevice = /Mobi|Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Op
9
9
 
10
10
  // src/utils/hooks.ts
11
11
  import { useCallback as useCallback4, useEffect as useEffect5, useMemo as useMemo3, useRef as useRef2, useState as useState3 } from "react";
12
- import { createSearchParams, useInRouterContext, useNavigate, useSearchParams } from "react-router-dom";
13
12
 
14
13
  // src/constants/css.ts
15
14
  var cssProps = {
@@ -1547,14 +1546,12 @@ var alertsPlugin = (options) => ({
1547
1546
  });
1548
1547
 
1549
1548
  // src/plugins/reactRouterDom.ts
1550
- import { Link as RouterLink, NavLink as RouterNavLink } from "react-router-dom";
1551
- var defaultReactRouterDomPluginOptions = {};
1549
+ import * as reactRouterDomLib from "react-router-dom";
1550
+ var defaultReactRouterDomPluginOptions = {
1551
+ reactRouterDomLib
1552
+ };
1552
1553
  var reactRouterDomPlugin = (options) => ({
1553
1554
  name: "react-router-dom",
1554
- components: {
1555
- Link: RouterLink,
1556
- NavLink: RouterNavLink
1557
- },
1558
1555
  initialize: () => {
1559
1556
  console.log("react-router-dom plugin initialized");
1560
1557
  },
@@ -2208,7 +2205,7 @@ function Alert2({ alert }) {
2208
2205
  const theme2 = useTheme();
2209
2206
  const alertControls2 = useAlertControls();
2210
2207
  const alertsPlugin2 = usePlugin("alerts");
2211
- const pluginConfig = alertsPlugin2?.getConfig?.() ?? {};
2208
+ const pluginConfig = alertsPlugin2?.getConfig() ?? {};
2212
2209
  const defaultAlertDurationNumber = getAlertDurationFromAuto(
2213
2210
  alert.duration ?? pluginConfig.defaultDuration ?? defaultAlertsPluginOptions.defaultDuration,
2214
2211
  alert
@@ -2370,7 +2367,7 @@ function AlertsHolder() {
2370
2367
  const theme2 = useTheme();
2371
2368
  const alertsPlugin2 = usePlugin("alerts");
2372
2369
  const { alerts } = useBetterHtmlContextInternal();
2373
- const pluginConfig = alertsPlugin2?.getConfig?.() ?? {};
2370
+ const pluginConfig = alertsPlugin2?.getConfig() ?? {};
2374
2371
  const top = pluginConfig.position === "top" ? theme2.styles.gap : void 0;
2375
2372
  const bottom = pluginConfig.position === "bottom" ? theme2.styles.gap : void 0;
2376
2373
  const left = pluginConfig.align === "left" ? theme2.styles.space : pluginConfig.align === "center" ? "50%" : void 0;
@@ -3063,14 +3060,15 @@ function useUrlQuery() {
3063
3060
  "`useUrlQuery` hook requires the `react-router-dom` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
3064
3061
  );
3065
3062
  }
3066
- const isInRouterContext = useInRouterContext();
3063
+ const reactRouterDomPluginConfig = reactRouterDomPlugin2.getConfig();
3064
+ const isInRouterContext = reactRouterDomPluginConfig.reactRouterDomLib.useInRouterContext();
3067
3065
  if (!isInRouterContext) {
3068
3066
  throw new Error(
3069
3067
  "`useUrlQuery` hook must be used inside a React Router context. Make sure your component is wrapped in a `<BrowserRouter>`, or another Router component."
3070
3068
  );
3071
3069
  }
3072
- const navigate = useNavigate();
3073
- const [searchParams] = useSearchParams();
3070
+ const navigate = reactRouterDomPluginConfig.reactRouterDomLib.useNavigate();
3071
+ const [searchParams] = reactRouterDomPluginConfig.reactRouterDomLib.useSearchParams();
3074
3072
  const setQuery = useCallback4(
3075
3073
  (query, keepHistory = true) => {
3076
3074
  const currentSearchParams = {};
@@ -3079,7 +3077,7 @@ function useUrlQuery() {
3079
3077
  });
3080
3078
  navigate(
3081
3079
  {
3082
- search: createSearchParams({
3080
+ search: reactRouterDomPluginConfig.reactRouterDomLib.createSearchParams({
3083
3081
  ...currentSearchParams,
3084
3082
  ...Object.fromEntries(Object.entries(query).map(([key, value]) => [key, value.toString()]))
3085
3083
  }).toString()
@@ -5493,8 +5491,8 @@ var encryptString = (text) => {
5493
5491
  "`encryptString` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
5494
5492
  );
5495
5493
  }
5496
- const pluginConfig = localStoragePlugin2.getConfig?.() ?? {};
5497
- if (!pluginConfig?.encryption?.enabled) return text;
5494
+ const pluginConfig = localStoragePlugin2.getConfig();
5495
+ if (!pluginConfig.encryption?.enabled) return text;
5498
5496
  const encrypted = CryptoJS.AES.encrypt(text, CryptoJS.enc.Hex.parse(pluginConfig.encryption.secretKey), {
5499
5497
  iv: CryptoJS.enc.Hex.parse(pluginConfig.encryption.iv),
5500
5498
  mode: CryptoJS.mode.CBC,
@@ -5510,8 +5508,8 @@ var decryptString = (text) => {
5510
5508
  "`decryptString` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
5511
5509
  );
5512
5510
  }
5513
- const pluginConfig = localStoragePlugin2.getConfig?.() ?? {};
5514
- if (!pluginConfig?.encryption?.enabled) return text;
5511
+ const pluginConfig = localStoragePlugin2.getConfig();
5512
+ if (!pluginConfig.encryption?.enabled) return text;
5515
5513
  const decrypted = CryptoJS.AES.decrypt(text, CryptoJS.enc.Hex.parse(pluginConfig.encryption.secretKey), {
5516
5514
  iv: CryptoJS.enc.Hex.parse(pluginConfig.encryption.iv),
5517
5515
  mode: CryptoJS.mode.CBC,
@@ -9111,7 +9109,7 @@ function generateLocalStorage() {
9111
9109
  "`generateLocalStorage` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
9112
9110
  );
9113
9111
  }
9114
- const pluginConfig = localStoragePlugin2.getConfig?.() ?? {};
9112
+ const pluginConfig = localStoragePlugin2.getConfig();
9115
9113
  const encryptionEnabled = pluginConfig.encryption?.enabled ?? false;
9116
9114
  const readyName = encryptionEnabled ? encryptString(name.toString()) : name;
9117
9115
  const readyValue = encryptionEnabled ? encryptString(JSON.stringify(value)) : JSON.stringify(value);
@@ -9129,7 +9127,7 @@ function generateLocalStorage() {
9129
9127
  "`generateLocalStorage` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
9130
9128
  );
9131
9129
  }
9132
- const pluginConfig = localStoragePlugin2.getConfig?.() ?? {};
9130
+ const pluginConfig = localStoragePlugin2.getConfig();
9133
9131
  const encryptionEnabled = pluginConfig.encryption?.enabled ?? false;
9134
9132
  const readyName = encryptionEnabled ? encryptString(name.toString()) : name;
9135
9133
  const item = localStorage.getItem(readyName.toString());
@@ -9151,7 +9149,7 @@ function generateLocalStorage() {
9151
9149
  "`generateLocalStorage` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
9152
9150
  );
9153
9151
  }
9154
- const pluginConfig = localStoragePlugin2.getConfig?.() ?? {};
9152
+ const pluginConfig = localStoragePlugin2.getConfig();
9155
9153
  const encryptionEnabled = pluginConfig.encryption?.enabled ?? false;
9156
9154
  const readyName = encryptionEnabled ? encryptString(name.toString()) : name;
9157
9155
  localStorage.removeItem(readyName.toString());