react-better-html 1.1.161 → 1.1.163
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 +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +14 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { WebTarget } from 'styled-components';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { ComponentProps, ReactNode } from 'react';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
6
|
type PluginName = "alerts" | "react-router-dom" | "localStorage";
|
|
7
7
|
type BetterHtmlPluginConstructor<T extends object = object> = (config?: T) => BetterHtmlPlugin<T>;
|
|
8
8
|
type BetterHtmlPlugin<T = object> = {
|
|
9
9
|
name: PluginName;
|
|
10
|
-
components?: Record<string, ComponentType<any>>;
|
|
11
10
|
initialize?: () => void;
|
|
12
|
-
getConfig
|
|
11
|
+
getConfig: () => T;
|
|
13
12
|
};
|
|
14
13
|
|
|
15
14
|
type ComponentStyle = React.CSSProperties;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { WebTarget } from 'styled-components';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { ComponentProps, ReactNode } from 'react';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
6
|
type PluginName = "alerts" | "react-router-dom" | "localStorage";
|
|
7
7
|
type BetterHtmlPluginConstructor<T extends object = object> = (config?: T) => BetterHtmlPlugin<T>;
|
|
8
8
|
type BetterHtmlPlugin<T = object> = {
|
|
9
9
|
name: PluginName;
|
|
10
|
-
components?: Record<string, ComponentType<any>>;
|
|
11
10
|
initialize?: () => void;
|
|
12
|
-
getConfig
|
|
11
|
+
getConfig: () => T;
|
|
13
12
|
};
|
|
14
13
|
|
|
15
14
|
type ComponentStyle = React.CSSProperties;
|
package/dist/index.js
CHANGED
|
@@ -102,7 +102,7 @@ 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
|
|
105
|
+
var import_react_router_dom = require("react-router-dom");
|
|
106
106
|
|
|
107
107
|
// src/constants/css.ts
|
|
108
108
|
var cssProps = {
|
|
@@ -1640,14 +1640,9 @@ var alertsPlugin = (options) => ({
|
|
|
1640
1640
|
});
|
|
1641
1641
|
|
|
1642
1642
|
// src/plugins/reactRouterDom.ts
|
|
1643
|
-
var import_react_router_dom = require("react-router-dom");
|
|
1644
1643
|
var defaultReactRouterDomPluginOptions = {};
|
|
1645
1644
|
var reactRouterDomPlugin = (options) => ({
|
|
1646
1645
|
name: "react-router-dom",
|
|
1647
|
-
components: {
|
|
1648
|
-
Link: import_react_router_dom.Link,
|
|
1649
|
-
NavLink: import_react_router_dom.NavLink
|
|
1650
|
-
},
|
|
1651
1646
|
initialize: () => {
|
|
1652
1647
|
console.log("react-router-dom plugin initialized");
|
|
1653
1648
|
},
|
|
@@ -2301,7 +2296,7 @@ function Alert2({ alert }) {
|
|
|
2301
2296
|
const theme2 = useTheme();
|
|
2302
2297
|
const alertControls2 = useAlertControls();
|
|
2303
2298
|
const alertsPlugin2 = usePlugin("alerts");
|
|
2304
|
-
const pluginConfig = alertsPlugin2?.getConfig
|
|
2299
|
+
const pluginConfig = alertsPlugin2?.getConfig() ?? {};
|
|
2305
2300
|
const defaultAlertDurationNumber = getAlertDurationFromAuto(
|
|
2306
2301
|
alert.duration ?? pluginConfig.defaultDuration ?? defaultAlertsPluginOptions.defaultDuration,
|
|
2307
2302
|
alert
|
|
@@ -2463,7 +2458,7 @@ function AlertsHolder() {
|
|
|
2463
2458
|
const theme2 = useTheme();
|
|
2464
2459
|
const alertsPlugin2 = usePlugin("alerts");
|
|
2465
2460
|
const { alerts } = useBetterHtmlContextInternal();
|
|
2466
|
-
const pluginConfig = alertsPlugin2?.getConfig
|
|
2461
|
+
const pluginConfig = alertsPlugin2?.getConfig() ?? {};
|
|
2467
2462
|
const top = pluginConfig.position === "top" ? theme2.styles.gap : void 0;
|
|
2468
2463
|
const bottom = pluginConfig.position === "bottom" ? theme2.styles.gap : void 0;
|
|
2469
2464
|
const left = pluginConfig.align === "left" ? theme2.styles.space : pluginConfig.align === "center" ? "50%" : void 0;
|
|
@@ -3156,14 +3151,14 @@ function useUrlQuery() {
|
|
|
3156
3151
|
"`useUrlQuery` hook requires the `react-router-dom` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
|
|
3157
3152
|
);
|
|
3158
3153
|
}
|
|
3159
|
-
const isInRouterContext = (0,
|
|
3154
|
+
const isInRouterContext = (0, import_react_router_dom.useInRouterContext)();
|
|
3160
3155
|
if (!isInRouterContext) {
|
|
3161
3156
|
throw new Error(
|
|
3162
3157
|
"`useUrlQuery` hook must be used inside a React Router context. Make sure your component is wrapped in a `<BrowserRouter>`, or another Router component."
|
|
3163
3158
|
);
|
|
3164
3159
|
}
|
|
3165
|
-
const navigate = (0,
|
|
3166
|
-
const [searchParams] = (0,
|
|
3160
|
+
const navigate = (0, import_react_router_dom.useNavigate)();
|
|
3161
|
+
const [searchParams] = (0, import_react_router_dom.useSearchParams)();
|
|
3167
3162
|
const setQuery = (0, import_react10.useCallback)(
|
|
3168
3163
|
(query, keepHistory = true) => {
|
|
3169
3164
|
const currentSearchParams = {};
|
|
@@ -3172,7 +3167,7 @@ function useUrlQuery() {
|
|
|
3172
3167
|
});
|
|
3173
3168
|
navigate(
|
|
3174
3169
|
{
|
|
3175
|
-
search: (0,
|
|
3170
|
+
search: (0, import_react_router_dom.createSearchParams)({
|
|
3176
3171
|
...currentSearchParams,
|
|
3177
3172
|
...Object.fromEntries(Object.entries(query).map(([key, value]) => [key, value.toString()]))
|
|
3178
3173
|
}).toString()
|
|
@@ -5586,8 +5581,8 @@ var encryptString = (text) => {
|
|
|
5586
5581
|
"`encryptString` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
|
|
5587
5582
|
);
|
|
5588
5583
|
}
|
|
5589
|
-
const pluginConfig = localStoragePlugin2.getConfig
|
|
5590
|
-
if (!pluginConfig
|
|
5584
|
+
const pluginConfig = localStoragePlugin2.getConfig();
|
|
5585
|
+
if (!pluginConfig.encryption?.enabled) return text;
|
|
5591
5586
|
const encrypted = import_crypto_js.default.AES.encrypt(text, import_crypto_js.default.enc.Hex.parse(pluginConfig.encryption.secretKey), {
|
|
5592
5587
|
iv: import_crypto_js.default.enc.Hex.parse(pluginConfig.encryption.iv),
|
|
5593
5588
|
mode: import_crypto_js.default.mode.CBC,
|
|
@@ -5603,8 +5598,8 @@ var decryptString = (text) => {
|
|
|
5603
5598
|
"`decryptString` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
|
|
5604
5599
|
);
|
|
5605
5600
|
}
|
|
5606
|
-
const pluginConfig = localStoragePlugin2.getConfig
|
|
5607
|
-
if (!pluginConfig
|
|
5601
|
+
const pluginConfig = localStoragePlugin2.getConfig();
|
|
5602
|
+
if (!pluginConfig.encryption?.enabled) return text;
|
|
5608
5603
|
const decrypted = import_crypto_js.default.AES.decrypt(text, import_crypto_js.default.enc.Hex.parse(pluginConfig.encryption.secretKey), {
|
|
5609
5604
|
iv: import_crypto_js.default.enc.Hex.parse(pluginConfig.encryption.iv),
|
|
5610
5605
|
mode: import_crypto_js.default.mode.CBC,
|
|
@@ -9194,7 +9189,7 @@ function generateLocalStorage() {
|
|
|
9194
9189
|
"`generateLocalStorage` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
|
|
9195
9190
|
);
|
|
9196
9191
|
}
|
|
9197
|
-
const pluginConfig = localStoragePlugin2.getConfig
|
|
9192
|
+
const pluginConfig = localStoragePlugin2.getConfig();
|
|
9198
9193
|
const encryptionEnabled = pluginConfig.encryption?.enabled ?? false;
|
|
9199
9194
|
const readyName = encryptionEnabled ? encryptString(name.toString()) : name;
|
|
9200
9195
|
const readyValue = encryptionEnabled ? encryptString(JSON.stringify(value)) : JSON.stringify(value);
|
|
@@ -9212,7 +9207,7 @@ function generateLocalStorage() {
|
|
|
9212
9207
|
"`generateLocalStorage` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
|
|
9213
9208
|
);
|
|
9214
9209
|
}
|
|
9215
|
-
const pluginConfig = localStoragePlugin2.getConfig
|
|
9210
|
+
const pluginConfig = localStoragePlugin2.getConfig();
|
|
9216
9211
|
const encryptionEnabled = pluginConfig.encryption?.enabled ?? false;
|
|
9217
9212
|
const readyName = encryptionEnabled ? encryptString(name.toString()) : name;
|
|
9218
9213
|
const item = localStorage.getItem(readyName.toString());
|
|
@@ -9234,7 +9229,7 @@ function generateLocalStorage() {
|
|
|
9234
9229
|
"`generateLocalStorage` hook requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
|
|
9235
9230
|
);
|
|
9236
9231
|
}
|
|
9237
|
-
const pluginConfig = localStoragePlugin2.getConfig
|
|
9232
|
+
const pluginConfig = localStoragePlugin2.getConfig();
|
|
9238
9233
|
const encryptionEnabled = pluginConfig.encryption?.enabled ?? false;
|
|
9239
9234
|
const readyName = encryptionEnabled ? encryptString(name.toString()) : name;
|
|
9240
9235
|
localStorage.removeItem(readyName.toString());
|