react-better-html 1.1.171 → 1.1.173

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/README.md CHANGED
@@ -52,7 +52,7 @@ createRoot(root).render(
52
52
  );
53
53
  ```
54
54
 
55
- This is enough for the components to work with the default configurations that the library comes with. They can be overridden when passing `value` prop to the `<BetterHtmlProvider>` tag.
55
+ This is enough for the components to work with the default configurations that the library comes with. They can be overridden when passing `config` prop to the `<BetterHtmlProvider>` tag.
56
56
 
57
57
  ## Problems?
58
58
 
package/dist/index.d.mts CHANGED
@@ -321,12 +321,18 @@ type ModalComponent = {
321
321
  (props: ComponentPropWithRef<ModalRef, ModalProps>): React.ReactElement;
322
322
  confirmation: (props: ComponentPropWithRef<ModalRef, OmitProps<ModalProps, "maxWidth" | "children" | "overflow"> & {
323
323
  message?: string;
324
+ /** @default "Continue" */
325
+ continueButtonText?: string;
324
326
  continueButtonLoaderName?: LoaderName | AnyOtherString;
325
327
  onContinue?: () => void;
326
328
  onCancel?: () => void;
327
329
  }>) => React.ReactElement;
328
330
  destructive: (props: ComponentPropWithRef<ModalRef, OmitProps<ModalProps, "maxWidth" | "children" | "overflow"> & {
329
331
  message?: string;
332
+ /** @default "Delete" */
333
+ deleteButtonText?: string;
334
+ /** @default "trash" */
335
+ deleteButtonIconName?: IconName | AnyOtherString;
330
336
  deleteButtonLoaderName?: LoaderName | AnyOtherString;
331
337
  onDelete?: () => void;
332
338
  onCancel?: () => void;
@@ -750,6 +756,8 @@ type ListFilter<DataItem> = {
750
756
  };
751
757
  type TableColumn<DataItem> = {
752
758
  label?: string;
759
+ /** @requires label */
760
+ renderLabel?: (label: string) => React.ReactNode;
753
761
  width?: string | number;
754
762
  minWidth?: string | number;
755
763
  maxWidth?: string | number;
@@ -960,11 +968,11 @@ declare const useAlertControls: () => {
960
968
  };
961
969
  type BetterHtmlProviderValue = DeepPartialRecord<BetterHtmlConfig>;
962
970
  type BetterHtmlProviderProps = {
963
- value?: BetterHtmlProviderValue;
971
+ config?: BetterHtmlProviderValue;
964
972
  plugins?: BetterHtmlPlugin[];
965
973
  children?: React.ReactNode;
966
974
  };
967
- declare function BetterHtmlProvider({ value, plugins: pluginsToUse, children }: BetterHtmlProviderProps): react_jsx_runtime.JSX.Element;
975
+ declare function BetterHtmlProvider({ config, plugins, children }: BetterHtmlProviderProps): react_jsx_runtime.JSX.Element;
968
976
  declare const _default: typeof BetterHtmlProvider;
969
977
 
970
978
  type BrowserName = "firefox" | "chrome" | "safari" | "edge" | "opera";
package/dist/index.d.ts CHANGED
@@ -321,12 +321,18 @@ type ModalComponent = {
321
321
  (props: ComponentPropWithRef<ModalRef, ModalProps>): React.ReactElement;
322
322
  confirmation: (props: ComponentPropWithRef<ModalRef, OmitProps<ModalProps, "maxWidth" | "children" | "overflow"> & {
323
323
  message?: string;
324
+ /** @default "Continue" */
325
+ continueButtonText?: string;
324
326
  continueButtonLoaderName?: LoaderName | AnyOtherString;
325
327
  onContinue?: () => void;
326
328
  onCancel?: () => void;
327
329
  }>) => React.ReactElement;
328
330
  destructive: (props: ComponentPropWithRef<ModalRef, OmitProps<ModalProps, "maxWidth" | "children" | "overflow"> & {
329
331
  message?: string;
332
+ /** @default "Delete" */
333
+ deleteButtonText?: string;
334
+ /** @default "trash" */
335
+ deleteButtonIconName?: IconName | AnyOtherString;
330
336
  deleteButtonLoaderName?: LoaderName | AnyOtherString;
331
337
  onDelete?: () => void;
332
338
  onCancel?: () => void;
@@ -750,6 +756,8 @@ type ListFilter<DataItem> = {
750
756
  };
751
757
  type TableColumn<DataItem> = {
752
758
  label?: string;
759
+ /** @requires label */
760
+ renderLabel?: (label: string) => React.ReactNode;
753
761
  width?: string | number;
754
762
  minWidth?: string | number;
755
763
  maxWidth?: string | number;
@@ -960,11 +968,11 @@ declare const useAlertControls: () => {
960
968
  };
961
969
  type BetterHtmlProviderValue = DeepPartialRecord<BetterHtmlConfig>;
962
970
  type BetterHtmlProviderProps = {
963
- value?: BetterHtmlProviderValue;
971
+ config?: BetterHtmlProviderValue;
964
972
  plugins?: BetterHtmlPlugin[];
965
973
  children?: React.ReactNode;
966
974
  };
967
- declare function BetterHtmlProvider({ value, plugins: pluginsToUse, children }: BetterHtmlProviderProps): react_jsx_runtime.JSX.Element;
975
+ declare function BetterHtmlProvider({ config, plugins, children }: BetterHtmlProviderProps): react_jsx_runtime.JSX.Element;
968
976
  declare const _default: typeof BetterHtmlProvider;
969
977
 
970
978
  type BrowserName = "firefox" | "chrome" | "safari" | "edge" | "opera";
package/dist/index.js CHANGED
@@ -2622,54 +2622,53 @@ function BetterHtmlProviderContent({ children }) {
2622
2622
  alertsPlugin2 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AlertsHolder_default, {})
2623
2623
  ] });
2624
2624
  }
2625
- function BetterHtmlProvider({ value, plugins: pluginsToUse, children }) {
2625
+ function BetterHtmlProvider({ config, plugins, children }) {
2626
2626
  const [colorTheme, setColorTheme] = (0, import_react9.useState)(
2627
- localStorage.getItem("theme") === "dark" ? "dark" : value?.colorTheme ?? "light"
2627
+ localStorage.getItem("theme") === "dark" ? "dark" : config?.colorTheme ?? "light"
2628
2628
  );
2629
- const [loaders, setLoaders] = (0, import_react9.useState)(value?.loaders ?? {});
2630
- const [plugins] = (0, import_react9.useState)(pluginsToUse ?? []);
2629
+ const [loaders, setLoaders] = (0, import_react9.useState)(config?.loaders ?? {});
2631
2630
  const [alerts, setAlerts] = (0, import_react9.useState)([]);
2632
2631
  const [tabGroups, setTabGroups] = (0, import_react9.useState)([]);
2633
2632
  const [tabsWithDots, setTabsWithDots] = (0, import_react9.useState)([]);
2634
- const readyValue = (0, import_react9.useMemo)(
2633
+ const readyConfig = (0, import_react9.useMemo)(
2635
2634
  () => ({
2636
2635
  app: {
2637
2636
  ...appConfig,
2638
- ...value?.app
2637
+ ...config?.app
2639
2638
  },
2640
2639
  theme: {
2641
2640
  styles: {
2642
2641
  ...theme.styles,
2643
- ...value?.theme?.styles
2642
+ ...config?.theme?.styles
2644
2643
  },
2645
2644
  colors: {
2646
2645
  light: {
2647
2646
  ...theme.colors.light,
2648
- ...value?.theme?.colors?.light
2647
+ ...config?.theme?.colors?.light
2649
2648
  },
2650
2649
  dark: {
2651
2650
  ...theme.colors.dark,
2652
- ...value?.theme?.colors?.dark
2651
+ ...config?.theme?.colors?.dark
2653
2652
  }
2654
2653
  }
2655
2654
  },
2656
2655
  colorTheme,
2657
2656
  icons: {
2658
2657
  ...icons,
2659
- ...value?.icons
2658
+ ...config?.icons
2660
2659
  },
2661
2660
  assets: {
2662
2661
  ...assets,
2663
- ...value?.assets
2662
+ ...config?.assets
2664
2663
  },
2665
2664
  loaders,
2666
2665
  setLoaders,
2667
2666
  alerts,
2668
2667
  setAlerts,
2669
2668
  components: {
2670
- ...value?.components
2669
+ ...config?.components
2671
2670
  },
2672
- plugins,
2671
+ plugins: plugins ?? [],
2673
2672
  componentsState: {
2674
2673
  tabs: {
2675
2674
  tabGroups,
@@ -2679,20 +2678,21 @@ function BetterHtmlProvider({ value, plugins: pluginsToUse, children }) {
2679
2678
  }
2680
2679
  }
2681
2680
  }),
2682
- [value, colorTheme, loaders, alerts, plugins, tabGroups, tabsWithDots]
2681
+ [config, colorTheme, loaders, alerts, tabGroups, tabsWithDots]
2683
2682
  );
2684
2683
  (0, import_react9.useEffect)(() => {
2684
+ if (!plugins) return;
2685
2685
  plugins.forEach((plugin) => {
2686
2686
  plugin.initialize?.();
2687
2687
  });
2688
- }, [plugins]);
2688
+ }, []);
2689
2689
  (0, import_react9.useEffect)(() => {
2690
2690
  const html = document.querySelector("html");
2691
2691
  if (!html) return;
2692
2692
  const observer = new MutationObserver((mutations) => {
2693
2693
  mutations.forEach((mutation) => {
2694
2694
  if (mutation.type === "attributes") {
2695
- setColorTheme(html.getAttribute("data-theme") === "dark" ? "dark" : value?.colorTheme ?? "light");
2695
+ setColorTheme(html.getAttribute("data-theme") === "dark" ? "dark" : config?.colorTheme ?? "light");
2696
2696
  }
2697
2697
  });
2698
2698
  });
@@ -2703,8 +2703,8 @@ function BetterHtmlProvider({ value, plugins: pluginsToUse, children }) {
2703
2703
  observer.disconnect();
2704
2704
  };
2705
2705
  }, []);
2706
- externalBetterHtmlContextValue = readyValue;
2707
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(betterHtmlContext.Provider, { value: readyValue, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BetterHtmlProviderContent, { children }) });
2706
+ externalBetterHtmlContextValue = readyConfig;
2707
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(betterHtmlContext.Provider, { value: readyConfig, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BetterHtmlProviderContent, { children }) });
2708
2708
  }
2709
2709
  var BetterHtmlProvider_default = (0, import_react9.memo)(BetterHtmlProvider);
2710
2710
 
@@ -3716,7 +3716,7 @@ var ModalComponent = (0, import_react14.forwardRef)(function Modal({
3716
3716
  document.body
3717
3717
  );
3718
3718
  });
3719
- ModalComponent.confirmation = (0, import_react14.forwardRef)(function Confirmation({ message, continueButtonLoaderName, onContinue, onCancel, ...props }, ref) {
3719
+ ModalComponent.confirmation = (0, import_react14.forwardRef)(function Confirmation({ message, continueButtonText = "Continue", continueButtonLoaderName, onContinue, onCancel, ...props }, ref) {
3720
3720
  const theme2 = useTheme();
3721
3721
  const modalRef = (0, import_react14.useRef)(null);
3722
3722
  const onCancelElement = (0, import_react14.useCallback)(() => {
@@ -3739,13 +3739,21 @@ ModalComponent.confirmation = (0, import_react14.forwardRef)(function Confirmati
3739
3739
  marginTop: theme2.styles.space * 2,
3740
3740
  children: [
3741
3741
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button_default.secondary, { text: "Cancel", onClick: onCancelElement }),
3742
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button_default, { text: "Continue", loaderName: continueButtonLoaderName, onClick: onContinueElement })
3742
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button_default, { text: continueButtonText, loaderName: continueButtonLoaderName, onClick: onContinueElement })
3743
3743
  ]
3744
3744
  }
3745
3745
  )
3746
3746
  ] });
3747
3747
  });
3748
- ModalComponent.destructive = (0, import_react14.forwardRef)(function Destructive2({ message, deleteButtonLoaderName, onDelete, onCancel, ...props }, ref) {
3748
+ ModalComponent.destructive = (0, import_react14.forwardRef)(function Destructive2({
3749
+ message,
3750
+ deleteButtonText = "Delete",
3751
+ deleteButtonIconName = "trash",
3752
+ deleteButtonLoaderName,
3753
+ onDelete,
3754
+ onCancel,
3755
+ ...props
3756
+ }, ref) {
3749
3757
  const theme2 = useTheme();
3750
3758
  const modalRef = (0, import_react14.useRef)(null);
3751
3759
  const onCancelElement = (0, import_react14.useCallback)(() => {
@@ -3771,8 +3779,8 @@ ModalComponent.destructive = (0, import_react14.forwardRef)(function Destructive
3771
3779
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3772
3780
  Button_default.destructive,
3773
3781
  {
3774
- icon: "trash",
3775
- text: "Delete",
3782
+ icon: deleteButtonIconName,
3783
+ text: deleteButtonText,
3776
3784
  loaderName: deleteButtonLoaderName,
3777
3785
  onClick: onDeleteElement
3778
3786
  }
@@ -8306,7 +8314,7 @@ var TableComponent = (0, import_react25.forwardRef)(function Table({
8306
8314
  disabled: data.length === 0,
8307
8315
  onChange: onClickAllCheckboxesElement
8308
8316
  }
8309
- ) : column.label ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Text_default, { children: column.label }) : void 0,
8317
+ ) : column.label ? column.renderLabel ? column.renderLabel(column.label) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Text_default, { children: column.label }) : void 0,
8310
8318
  column.filter && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
8311
8319
  Button_default.icon,
8312
8320
  {
@@ -8446,7 +8454,7 @@ var TableComponent = (0, import_react25.forwardRef)(function Table({
8446
8454
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
8447
8455
  Modal_default,
8448
8456
  {
8449
- title: `Filter ${openedFilterColumn?.label}`,
8457
+ title: `Filter ${openedFilterColumn?.label ?? ""}`,
8450
8458
  description: openedFilterColumn?.filter === "number" ? "Enter minimum and maximum values to filter" : openedFilterColumn?.filter === "date" || openedFilterColumn?.filter === "date-time" ? "Enter minimum and maximum dates to filter" : openedFilterColumn?.filter === "list" ? "Select values to filter from the list bellow" : "",
8451
8459
  onClose: onCloseFilterModal,
8452
8460
  ref: filterModalRef,