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.d.mts CHANGED
@@ -178,6 +178,9 @@ declare const Text: typeof TextComponent & {
178
178
 
179
179
  type PageHeaderProps = {
180
180
  icon?: IconName | AnyOtherString;
181
+ iconColor?: React.CSSProperties["color"];
182
+ /** @default 20 */
183
+ iconSize?: number;
181
184
  image?: AssetName | AnyOtherString;
182
185
  imageUrl?: string;
183
186
  imageSize?: number;
@@ -503,7 +506,7 @@ type Tab = {
503
506
  };
504
507
  type TabGroup = {
505
508
  name: string;
506
- selectedTab: string;
509
+ selectedTab: Tab["id"];
507
510
  };
508
511
  type TabsProps = {
509
512
  tabs: Tab[];
@@ -514,7 +517,7 @@ type TabsProps = {
514
517
  children?: React.ReactNode;
515
518
  } & ComponentMarginProps;
516
519
  type TabsRef = {
517
- selectedTab: string;
520
+ selectedTab: Tab["id"];
518
521
  selectTab: (tab: Tab) => void;
519
522
  };
520
523
  type TabsComponent = {
@@ -523,7 +526,7 @@ type TabsComponent = {
523
526
  };
524
527
  declare const TabsComponent: TabsComponent;
525
528
  type TabsContentProps = {
526
- tab: string;
529
+ tabId: Tab["id"];
527
530
  tabWithDot?: boolean;
528
531
  tabsGroupName?: string;
529
532
  isInitialTab?: boolean;
@@ -636,8 +639,11 @@ declare const filterHover: () => Record<"z05" | "z1" | "z2" | "z3", React.CSSPro
636
639
  declare function generateLocalStorage<LocalStorage extends object>(): {
637
640
  setItem: <StorageName extends keyof LocalStorage>(name: StorageName, value: LocalStorage[StorageName]) => void;
638
641
  getItem: <StorageName extends keyof LocalStorage>(name: StorageName) => LocalStorage[StorageName] | undefined;
642
+ getAllItems: () => Partial<LocalStorage>;
639
643
  removeItem: (name: keyof LocalStorage) => void;
640
- removeAllItems: () => void;
644
+ removeAllItems: (config?: {
645
+ keepValues?: (keyof LocalStorage)[];
646
+ }) => void;
641
647
  };
642
648
 
643
649
  type LoaderProps = {
package/dist/index.d.ts CHANGED
@@ -178,6 +178,9 @@ declare const Text: typeof TextComponent & {
178
178
 
179
179
  type PageHeaderProps = {
180
180
  icon?: IconName | AnyOtherString;
181
+ iconColor?: React.CSSProperties["color"];
182
+ /** @default 20 */
183
+ iconSize?: number;
181
184
  image?: AssetName | AnyOtherString;
182
185
  imageUrl?: string;
183
186
  imageSize?: number;
@@ -503,7 +506,7 @@ type Tab = {
503
506
  };
504
507
  type TabGroup = {
505
508
  name: string;
506
- selectedTab: string;
509
+ selectedTab: Tab["id"];
507
510
  };
508
511
  type TabsProps = {
509
512
  tabs: Tab[];
@@ -514,7 +517,7 @@ type TabsProps = {
514
517
  children?: React.ReactNode;
515
518
  } & ComponentMarginProps;
516
519
  type TabsRef = {
517
- selectedTab: string;
520
+ selectedTab: Tab["id"];
518
521
  selectTab: (tab: Tab) => void;
519
522
  };
520
523
  type TabsComponent = {
@@ -523,7 +526,7 @@ type TabsComponent = {
523
526
  };
524
527
  declare const TabsComponent: TabsComponent;
525
528
  type TabsContentProps = {
526
- tab: string;
529
+ tabId: Tab["id"];
527
530
  tabWithDot?: boolean;
528
531
  tabsGroupName?: string;
529
532
  isInitialTab?: boolean;
@@ -636,8 +639,11 @@ declare const filterHover: () => Record<"z05" | "z1" | "z2" | "z3", React.CSSPro
636
639
  declare function generateLocalStorage<LocalStorage extends object>(): {
637
640
  setItem: <StorageName extends keyof LocalStorage>(name: StorageName, value: LocalStorage[StorageName]) => void;
638
641
  getItem: <StorageName extends keyof LocalStorage>(name: StorageName) => LocalStorage[StorageName] | undefined;
642
+ getAllItems: () => Partial<LocalStorage>;
639
643
  removeItem: (name: keyof LocalStorage) => void;
640
- removeAllItems: () => void;
644
+ removeAllItems: (config?: {
645
+ keepValues?: (keyof LocalStorage)[];
646
+ }) => void;
641
647
  };
642
648
 
643
649
  type LoaderProps = {
package/dist/index.js CHANGED
@@ -1651,6 +1651,8 @@ var Icon_default = { Icon: MemoizedIcon }.Icon;
1651
1651
  var import_jsx_runtime5 = require("react/jsx-runtime");
1652
1652
  var PageHeaderComponent = (0, import_react7.forwardRef)(function PageHeader({
1653
1653
  icon,
1654
+ iconColor,
1655
+ iconSize = 20,
1654
1656
  image,
1655
1657
  imageUrl,
1656
1658
  imageSize = 60,
@@ -1681,7 +1683,7 @@ var PageHeaderComponent = (0, import_react7.forwardRef)(function PageHeader({
1681
1683
  marginBottom: marginBottom ?? theme2.styles.space * 2,
1682
1684
  ref,
1683
1685
  children: [
1684
- icon && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon_default, { name: icon, size: 20, flexShrink: 0 }),
1686
+ icon && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon_default, { name: icon, size: iconSize, color: iconColor, flexShrink: 0 }),
1685
1687
  (image || imageUrl) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1686
1688
  ImageTag,
1687
1689
  {
@@ -3349,25 +3351,53 @@ function findClosestNumber(numbers, target) {
3349
3351
 
3350
3352
  // src/utils/localStorage.ts
3351
3353
  function generateLocalStorage() {
3352
- return {
3353
- setItem: (name, value) => {
3354
- if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "generateLocalStorage.setItem"))
3355
- return void 0;
3356
- const localStoragePlugin2 = externalBetterHtmlContextValue.plugins.find(
3357
- (plugin) => plugin.name === "localStorage"
3354
+ const setItem = (name, value) => {
3355
+ if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "generateLocalStorage.setItem"))
3356
+ return void 0;
3357
+ const localStoragePlugin2 = externalBetterHtmlContextValue.plugins.find(
3358
+ (plugin) => plugin.name === "localStorage"
3359
+ );
3360
+ if (!localStoragePlugin2) {
3361
+ throw new Error(
3362
+ "`generateLocalStorage.setItem` function requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
3358
3363
  );
3359
- if (!localStoragePlugin2) {
3360
- throw new Error(
3361
- "`generateLocalStorage.setItem` function requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
3362
- );
3363
- }
3364
- const pluginConfig = localStoragePlugin2.getConfig();
3365
- const encryptionEnabled = pluginConfig.encryption?.enabled ?? false;
3366
- const readyName = encryptionEnabled ? encryptString(name.toString()) : name;
3367
- const readyValue = encryptionEnabled ? encryptString(JSON.stringify(value)) : JSON.stringify(value);
3368
- if (value) localStorage.setItem(readyName.toString(), readyValue);
3369
- else localStorage.removeItem(readyName.toString());
3370
- },
3364
+ }
3365
+ const pluginConfig = localStoragePlugin2.getConfig();
3366
+ const encryptionEnabled = pluginConfig.encryption?.enabled ?? false;
3367
+ const readyName = encryptionEnabled ? encryptString(name.toString()) : name;
3368
+ const readyValue = encryptionEnabled ? encryptString(JSON.stringify(value)) : JSON.stringify(value);
3369
+ if (value) localStorage.setItem(readyName.toString(), readyValue);
3370
+ else localStorage.removeItem(readyName.toString());
3371
+ };
3372
+ const getAllItems = () => {
3373
+ if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "generateLocalStorage.getAllItems"))
3374
+ return void 0;
3375
+ const localStoragePlugin2 = externalBetterHtmlContextValue.plugins.find(
3376
+ (plugin) => plugin.name === "localStorage"
3377
+ );
3378
+ if (!localStoragePlugin2) {
3379
+ throw new Error(
3380
+ "`generateLocalStorage.getAllItems` function requires the `localStorage` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`."
3381
+ );
3382
+ }
3383
+ const pluginConfig = localStoragePlugin2.getConfig();
3384
+ const encryptionEnabled = pluginConfig.encryption?.enabled ?? false;
3385
+ const items = {
3386
+ ...localStorage
3387
+ };
3388
+ try {
3389
+ return encryptionEnabled ? Object.entries(items).reduce((previousValue, currentValue) => {
3390
+ const readyName = encryptString(currentValue[0]);
3391
+ const item = JSON.parse(decryptString(currentValue[1]));
3392
+ previousValue[readyName] = item;
3393
+ return previousValue;
3394
+ }, {}) : items;
3395
+ } catch (error) {
3396
+ return void 0;
3397
+ }
3398
+ };
3399
+ return {
3400
+ setItem,
3371
3401
  getItem: (name) => {
3372
3402
  if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "generateLocalStorage.getItem"))
3373
3403
  return void 0;
@@ -3390,6 +3420,7 @@ function generateLocalStorage() {
3390
3420
  return void 0;
3391
3421
  }
3392
3422
  },
3423
+ getAllItems,
3393
3424
  removeItem: (name) => {
3394
3425
  if (!checkBetterHtmlContextValue(externalBetterHtmlContextValue, "generateLocalStorage.removeItem"))
3395
3426
  return void 0;
@@ -3406,8 +3437,14 @@ function generateLocalStorage() {
3406
3437
  const readyName = encryptionEnabled ? encryptString(name.toString()) : name;
3407
3438
  localStorage.removeItem(readyName.toString());
3408
3439
  },
3409
- removeAllItems: () => {
3440
+ removeAllItems: (config) => {
3441
+ const allItems = getAllItems();
3410
3442
  localStorage.clear();
3443
+ if (config?.keepValues) {
3444
+ config.keepValues.forEach((key) => {
3445
+ setItem(key, allItems[key]);
3446
+ });
3447
+ }
3411
3448
  }
3412
3449
  };
3413
3450
  }
@@ -7556,7 +7593,7 @@ var TabsComponent = (0, import_react29.forwardRef)(function Tabs({ tabs, name, a
7556
7593
  children && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Div_default, { width: "100%", children })
7557
7594
  ] });
7558
7595
  });
7559
- TabsComponent.content = function Content({ tab, tabWithDot, tabsGroupName, isInitialTab, children }) {
7596
+ TabsComponent.content = function Content({ tabId, tabWithDot, tabsGroupName, isInitialTab, children }) {
7560
7597
  const { componentsState } = useBetterHtmlContextInternal();
7561
7598
  const thisTabGroupData = (0, import_react29.useMemo)(
7562
7599
  () => componentsState.tabs.tabGroups.find((item) => item.name === (tabsGroupName ?? defaultTabName)),
@@ -7564,14 +7601,16 @@ TabsComponent.content = function Content({ tab, tabWithDot, tabsGroupName, isIni
7564
7601
  );
7565
7602
  (0, import_react29.useEffect)(() => {
7566
7603
  if (tabWithDot) {
7567
- componentsState.tabs.setTabsWithDots?.((oldValue) => oldValue.includes(tab) ? oldValue : [...oldValue, tab]);
7604
+ componentsState.tabs.setTabsWithDots?.(
7605
+ (oldValue) => oldValue.includes(tabId) ? oldValue : [...oldValue, tabId]
7606
+ );
7568
7607
  } else {
7569
7608
  componentsState.tabs.setTabsWithDots?.(
7570
- (oldValue) => oldValue.includes(tab) ? oldValue.filter((tab2) => tab2 !== tab2) : oldValue
7609
+ (oldValue) => oldValue.includes(tabId) ? oldValue.filter((tab) => tab !== tabId) : oldValue
7571
7610
  );
7572
7611
  }
7573
7612
  }, [tabWithDot]);
7574
- return (thisTabGroupData ? thisTabGroupData.selectedTab === tab : isInitialTab) ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Div_default, { width: "100%", children }) : void 0;
7613
+ return (thisTabGroupData ? thisTabGroupData.selectedTab === tabId : isInitialTab) ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Div_default, { width: "100%", children }) : void 0;
7575
7614
  };
7576
7615
  var Tabs2 = (0, import_react29.memo)(TabsComponent);
7577
7616
  Tabs2.content = TabsComponent.content;