react-better-html 1.1.172 → 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 +1 -1
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +20 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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 `
|
|
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
|
@@ -756,6 +756,8 @@ type ListFilter<DataItem> = {
|
|
|
756
756
|
};
|
|
757
757
|
type TableColumn<DataItem> = {
|
|
758
758
|
label?: string;
|
|
759
|
+
/** @requires label */
|
|
760
|
+
renderLabel?: (label: string) => React.ReactNode;
|
|
759
761
|
width?: string | number;
|
|
760
762
|
minWidth?: string | number;
|
|
761
763
|
maxWidth?: string | number;
|
|
@@ -966,11 +968,11 @@ declare const useAlertControls: () => {
|
|
|
966
968
|
};
|
|
967
969
|
type BetterHtmlProviderValue = DeepPartialRecord<BetterHtmlConfig>;
|
|
968
970
|
type BetterHtmlProviderProps = {
|
|
969
|
-
|
|
971
|
+
config?: BetterHtmlProviderValue;
|
|
970
972
|
plugins?: BetterHtmlPlugin[];
|
|
971
973
|
children?: React.ReactNode;
|
|
972
974
|
};
|
|
973
|
-
declare function BetterHtmlProvider({
|
|
975
|
+
declare function BetterHtmlProvider({ config, plugins, children }: BetterHtmlProviderProps): react_jsx_runtime.JSX.Element;
|
|
974
976
|
declare const _default: typeof BetterHtmlProvider;
|
|
975
977
|
|
|
976
978
|
type BrowserName = "firefox" | "chrome" | "safari" | "edge" | "opera";
|
package/dist/index.d.ts
CHANGED
|
@@ -756,6 +756,8 @@ type ListFilter<DataItem> = {
|
|
|
756
756
|
};
|
|
757
757
|
type TableColumn<DataItem> = {
|
|
758
758
|
label?: string;
|
|
759
|
+
/** @requires label */
|
|
760
|
+
renderLabel?: (label: string) => React.ReactNode;
|
|
759
761
|
width?: string | number;
|
|
760
762
|
minWidth?: string | number;
|
|
761
763
|
maxWidth?: string | number;
|
|
@@ -966,11 +968,11 @@ declare const useAlertControls: () => {
|
|
|
966
968
|
};
|
|
967
969
|
type BetterHtmlProviderValue = DeepPartialRecord<BetterHtmlConfig>;
|
|
968
970
|
type BetterHtmlProviderProps = {
|
|
969
|
-
|
|
971
|
+
config?: BetterHtmlProviderValue;
|
|
970
972
|
plugins?: BetterHtmlPlugin[];
|
|
971
973
|
children?: React.ReactNode;
|
|
972
974
|
};
|
|
973
|
-
declare function BetterHtmlProvider({
|
|
975
|
+
declare function BetterHtmlProvider({ config, plugins, children }: BetterHtmlProviderProps): react_jsx_runtime.JSX.Element;
|
|
974
976
|
declare const _default: typeof BetterHtmlProvider;
|
|
975
977
|
|
|
976
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({
|
|
2625
|
+
function BetterHtmlProvider({ config, plugins, children }) {
|
|
2626
2626
|
const [colorTheme, setColorTheme] = (0, import_react9.useState)(
|
|
2627
|
-
localStorage.getItem("theme") === "dark" ? "dark" :
|
|
2627
|
+
localStorage.getItem("theme") === "dark" ? "dark" : config?.colorTheme ?? "light"
|
|
2628
2628
|
);
|
|
2629
|
-
const [loaders, setLoaders] = (0, import_react9.useState)(
|
|
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
|
|
2633
|
+
const readyConfig = (0, import_react9.useMemo)(
|
|
2635
2634
|
() => ({
|
|
2636
2635
|
app: {
|
|
2637
2636
|
...appConfig,
|
|
2638
|
-
...
|
|
2637
|
+
...config?.app
|
|
2639
2638
|
},
|
|
2640
2639
|
theme: {
|
|
2641
2640
|
styles: {
|
|
2642
2641
|
...theme.styles,
|
|
2643
|
-
...
|
|
2642
|
+
...config?.theme?.styles
|
|
2644
2643
|
},
|
|
2645
2644
|
colors: {
|
|
2646
2645
|
light: {
|
|
2647
2646
|
...theme.colors.light,
|
|
2648
|
-
...
|
|
2647
|
+
...config?.theme?.colors?.light
|
|
2649
2648
|
},
|
|
2650
2649
|
dark: {
|
|
2651
2650
|
...theme.colors.dark,
|
|
2652
|
-
...
|
|
2651
|
+
...config?.theme?.colors?.dark
|
|
2653
2652
|
}
|
|
2654
2653
|
}
|
|
2655
2654
|
},
|
|
2656
2655
|
colorTheme,
|
|
2657
2656
|
icons: {
|
|
2658
2657
|
...icons,
|
|
2659
|
-
...
|
|
2658
|
+
...config?.icons
|
|
2660
2659
|
},
|
|
2661
2660
|
assets: {
|
|
2662
2661
|
...assets,
|
|
2663
|
-
...
|
|
2662
|
+
...config?.assets
|
|
2664
2663
|
},
|
|
2665
2664
|
loaders,
|
|
2666
2665
|
setLoaders,
|
|
2667
2666
|
alerts,
|
|
2668
2667
|
setAlerts,
|
|
2669
2668
|
components: {
|
|
2670
|
-
...
|
|
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
|
-
[
|
|
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
|
-
}, [
|
|
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" :
|
|
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 =
|
|
2707
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(betterHtmlContext.Provider, { value:
|
|
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
|
|
|
@@ -8314,7 +8314,7 @@ var TableComponent = (0, import_react25.forwardRef)(function Table({
|
|
|
8314
8314
|
disabled: data.length === 0,
|
|
8315
8315
|
onChange: onClickAllCheckboxesElement
|
|
8316
8316
|
}
|
|
8317
|
-
) : 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,
|
|
8318
8318
|
column.filter && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
8319
8319
|
Button_default.icon,
|
|
8320
8320
|
{
|
|
@@ -8454,7 +8454,7 @@ var TableComponent = (0, import_react25.forwardRef)(function Table({
|
|
|
8454
8454
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
8455
8455
|
Modal_default,
|
|
8456
8456
|
{
|
|
8457
|
-
title: `Filter ${openedFilterColumn?.label}`,
|
|
8457
|
+
title: `Filter ${openedFilterColumn?.label ?? ""}`,
|
|
8458
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" : "",
|
|
8459
8459
|
onClose: onCloseFilterModal,
|
|
8460
8460
|
ref: filterModalRef,
|