react-better-html 1.1.248 → 1.1.249

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
@@ -1580,6 +1580,8 @@ var Icon_default = { Icon: MemoizedIcon }.Icon;
1580
1580
  import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
1581
1581
  var PageHeaderComponent = forwardRef5(function PageHeader({
1582
1582
  icon,
1583
+ iconColor,
1584
+ iconSize = 20,
1583
1585
  image,
1584
1586
  imageUrl,
1585
1587
  imageSize = 60,
@@ -1610,7 +1612,7 @@ var PageHeaderComponent = forwardRef5(function PageHeader({
1610
1612
  marginBottom: marginBottom ?? theme2.styles.space * 2,
1611
1613
  ref,
1612
1614
  children: [
1613
- icon && /* @__PURE__ */ jsx5(Icon_default, { name: icon, size: 20, flexShrink: 0 }),
1615
+ icon && /* @__PURE__ */ jsx5(Icon_default, { name: icon, size: iconSize, color: iconColor, flexShrink: 0 }),
1614
1616
  (image || imageUrl) && /* @__PURE__ */ jsx5(
1615
1617
  ImageTag,
1616
1618
  {
@@ -3286,25 +3288,53 @@ function findClosestNumber(numbers, target) {
3286
3288
 
3287
3289
  // src/utils/localStorage.ts
3288
3290
  function generateLocalStorage() {
3289
- return {
3290
- setItem: (name, value) => {
3291
- if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "generateLocalStorage.setItem"))
3292
- return void 0;
3293
- const localStoragePlugin2 = externalBetterHtmlContextValue.plugins.find(
3294
- (plugin) => plugin.name === "localStorage"
3291
+ const setItem = (name, value) => {
3292
+ if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "generateLocalStorage.setItem"))
3293
+ return void 0;
3294
+ const localStoragePlugin2 = externalBetterHtmlContextValue.plugins.find(
3295
+ (plugin) => plugin.name === "localStorage"
3296
+ );
3297
+ if (!localStoragePlugin2) {
3298
+ throw new Error(
3299
+ "`generateLocalStorage.setItem` function requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
3295
3300
  );
3296
- if (!localStoragePlugin2) {
3297
- throw new Error(
3298
- "`generateLocalStorage.setItem` function requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
3299
- );
3300
- }
3301
- const pluginConfig = localStoragePlugin2.getConfig();
3302
- const encryptionEnabled = pluginConfig.encryption?.enabled ?? false;
3303
- const readyName = encryptionEnabled ? encryptString(name.toString()) : name;
3304
- const readyValue = encryptionEnabled ? encryptString(JSON.stringify(value)) : JSON.stringify(value);
3305
- if (value) localStorage.setItem(readyName.toString(), readyValue);
3306
- else localStorage.removeItem(readyName.toString());
3307
- },
3301
+ }
3302
+ const pluginConfig = localStoragePlugin2.getConfig();
3303
+ const encryptionEnabled = pluginConfig.encryption?.enabled ?? false;
3304
+ const readyName = encryptionEnabled ? encryptString(name.toString()) : name;
3305
+ const readyValue = encryptionEnabled ? encryptString(JSON.stringify(value)) : JSON.stringify(value);
3306
+ if (value) localStorage.setItem(readyName.toString(), readyValue);
3307
+ else localStorage.removeItem(readyName.toString());
3308
+ };
3309
+ const getAllItems = () => {
3310
+ if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "generateLocalStorage.getAllItems"))
3311
+ return void 0;
3312
+ const localStoragePlugin2 = externalBetterHtmlContextValue.plugins.find(
3313
+ (plugin) => plugin.name === "localStorage"
3314
+ );
3315
+ if (!localStoragePlugin2) {
3316
+ throw new Error(
3317
+ "`generateLocalStorage.getAllItems` function requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
3318
+ );
3319
+ }
3320
+ const pluginConfig = localStoragePlugin2.getConfig();
3321
+ const encryptionEnabled = pluginConfig.encryption?.enabled ?? false;
3322
+ const items = {
3323
+ ...localStorage
3324
+ };
3325
+ try {
3326
+ return encryptionEnabled ? Object.entries(items).reduce((previousValue, currentValue) => {
3327
+ const readyName = encryptString(currentValue[0]);
3328
+ const item = JSON.parse(decryptString(currentValue[1]));
3329
+ previousValue[readyName] = item;
3330
+ return previousValue;
3331
+ }, {}) : items;
3332
+ } catch (error) {
3333
+ return void 0;
3334
+ }
3335
+ };
3336
+ return {
3337
+ setItem,
3308
3338
  getItem: (name) => {
3309
3339
  if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "generateLocalStorage.getItem"))
3310
3340
  return void 0;
@@ -3327,6 +3357,7 @@ function generateLocalStorage() {
3327
3357
  return void 0;
3328
3358
  }
3329
3359
  },
3360
+ getAllItems,
3330
3361
  removeItem: (name) => {
3331
3362
  if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "generateLocalStorage.removeItem"))
3332
3363
  return void 0;
@@ -3343,8 +3374,14 @@ function generateLocalStorage() {
3343
3374
  const readyName = encryptionEnabled ? encryptString(name.toString()) : name;
3344
3375
  localStorage.removeItem(readyName.toString());
3345
3376
  },
3346
- removeAllItems: () => {
3377
+ removeAllItems: (config) => {
3378
+ const allItems = getAllItems();
3347
3379
  localStorage.clear();
3380
+ if (config?.keepValues) {
3381
+ config.keepValues.forEach((key) => {
3382
+ setItem(key, allItems[key]);
3383
+ });
3384
+ }
3348
3385
  }
3349
3386
  };
3350
3387
  }
@@ -7517,7 +7554,7 @@ var TabsComponent = forwardRef17(function Tabs({ tabs, name, accentColor, style
7517
7554
  children && /* @__PURE__ */ jsx25(Div_default, { width: "100%", children })
7518
7555
  ] });
7519
7556
  });
7520
- TabsComponent.content = function Content({ tab, tabWithDot, tabsGroupName, isInitialTab, children }) {
7557
+ TabsComponent.content = function Content({ tabId, tabWithDot, tabsGroupName, isInitialTab, children }) {
7521
7558
  const { componentsState } = useBetterHtmlContextInternal();
7522
7559
  const thisTabGroupData = useMemo11(
7523
7560
  () => componentsState.tabs.tabGroups.find((item) => item.name === (tabsGroupName ?? defaultTabName)),
@@ -7525,14 +7562,16 @@ TabsComponent.content = function Content({ tab, tabWithDot, tabsGroupName, isIni
7525
7562
  );
7526
7563
  useEffect14(() => {
7527
7564
  if (tabWithDot) {
7528
- componentsState.tabs.setTabsWithDots?.((oldValue) => oldValue.includes(tab) ? oldValue : [...oldValue, tab]);
7565
+ componentsState.tabs.setTabsWithDots?.(
7566
+ (oldValue) => oldValue.includes(tabId) ? oldValue : [...oldValue, tabId]
7567
+ );
7529
7568
  } else {
7530
7569
  componentsState.tabs.setTabsWithDots?.(
7531
- (oldValue) => oldValue.includes(tab) ? oldValue.filter((tab2) => tab2 !== tab2) : oldValue
7570
+ (oldValue) => oldValue.includes(tabId) ? oldValue.filter((tab) => tab !== tabId) : oldValue
7532
7571
  );
7533
7572
  }
7534
7573
  }, [tabWithDot]);
7535
- return (thisTabGroupData ? thisTabGroupData.selectedTab === tab : isInitialTab) ? /* @__PURE__ */ jsx25(Div_default, { width: "100%", children }) : void 0;
7574
+ return (thisTabGroupData ? thisTabGroupData.selectedTab === tabId : isInitialTab) ? /* @__PURE__ */ jsx25(Div_default, { width: "100%", children }) : void 0;
7536
7575
  };
7537
7576
  var Tabs2 = memo25(TabsComponent);
7538
7577
  Tabs2.content = TabsComponent.content;