react-better-html 1.1.172 → 1.1.174
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 +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +23 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -22
- 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;
|
|
@@ -964,13 +966,13 @@ declare const useAlertControls: () => {
|
|
|
964
966
|
createAlert: (alert: OmitProps<Alert, "id">) => Alert;
|
|
965
967
|
removeAlert: (alertId: string) => void;
|
|
966
968
|
};
|
|
967
|
-
type
|
|
969
|
+
type BetterHtmlProviderConfig = DeepPartialRecord<BetterHtmlConfig>;
|
|
968
970
|
type BetterHtmlProviderProps = {
|
|
969
|
-
|
|
971
|
+
config?: BetterHtmlProviderConfig;
|
|
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";
|
|
@@ -1056,4 +1058,4 @@ type LocalStoragePluginOptions = {
|
|
|
1056
1058
|
declare const defaultLocalStoragePluginOptions: Required<LocalStoragePluginOptions>;
|
|
1057
1059
|
declare const localStoragePlugin: BetterHtmlPluginConstructor<LocalStoragePluginOptions>;
|
|
1058
1060
|
|
|
1059
|
-
export { type Alert, type AlertType, type AlertsPluginOptions, type AppConfig, type AssetName, type AssetsConfig, type BetterHtmlConfig, type BetterHtmlPlugin, _default as BetterHtmlProvider, type
|
|
1061
|
+
export { type Alert, type AlertType, type AlertsPluginOptions, type AppConfig, type AssetName, type AssetsConfig, type BetterHtmlConfig, type BetterHtmlPlugin, _default as BetterHtmlProvider, type BetterHtmlProviderConfig, type BrowserName, Button, type ButtonProps, Chip, type ChipProps, type Color, type ColorName, type ColorTheme, ColorThemeSwitch, type ColorThemeSwitchProps, type Colors, type ComponentHoverStyle, type ComponentMarginProps, type ComponentPaddingProps, type DeepPartialRecord, Div, type DivProps, _default$3 as Divider, Dropdown, type DropdownOption, type DropdownProps, type ExcludeOptions, Foldable, type FoldableProps, type FoldableRef, Form, type FormProps, FormRow, type FormRowProps, type HorizontalDividerProps, _default$5 as Icon, type IconName, type IconProps, type IconsConfig, _default$4 as Image, type ImageProps, InputField, type InputFieldProps, _default$1 as Label, type LabelProps, Loader, type LoaderConfig, type LoaderName, type LoaderProps, type LocalStoragePluginOptions, Modal, type ModalProps, type ModalRef, type OmitProps, PageHeader, type PageHeaderProps, PageHolder, type PageHolderProps, type PartialRecord, type PickAllRequired, type PickValue, type PluginName, type ReactRouterDomPluginOptions, type Styles, type TabGroup, Table, type TableColumn, type TableProps, type TableRef, Tabs, type TabsProps, type TabsRef, Text, type TextAs, type TextProps, type TextareaFieldProps, type Theme, type ThemeConfig, _default$2 as ToggleInput, type ToggleInputProps, type ToggleInputRef, Tooltip, type TooltipProps, type TooltipRef, type VerticalDividerProps, alertControls, alertsPlugin, colorThemeControls, countries, darkenColor, defaultAlertsPluginOptions, defaultLocalStoragePluginOptions, defaultReactRouterDomPluginOptions, desaturateColor, eventPreventDefault, eventPreventStop, eventStopPropagation, filterHover, formatPhoneNumber, generateLocalStorage, generateRandomString, getBrowser, getFormErrorObject, isMobileDevice, lightenColor, loaderControls, localStoragePlugin, reactRouterDomPlugin, saturateColor, useAlertControls, useBetterHtmlContext, useBooleanState, useDebounceState, useForm, useLoader, useLoaderControls, useMediaQuery, usePageResize, usePageScroll, useTheme, useUrlQuery };
|
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;
|
|
@@ -964,13 +966,13 @@ declare const useAlertControls: () => {
|
|
|
964
966
|
createAlert: (alert: OmitProps<Alert, "id">) => Alert;
|
|
965
967
|
removeAlert: (alertId: string) => void;
|
|
966
968
|
};
|
|
967
|
-
type
|
|
969
|
+
type BetterHtmlProviderConfig = DeepPartialRecord<BetterHtmlConfig>;
|
|
968
970
|
type BetterHtmlProviderProps = {
|
|
969
|
-
|
|
971
|
+
config?: BetterHtmlProviderConfig;
|
|
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";
|
|
@@ -1056,4 +1058,4 @@ type LocalStoragePluginOptions = {
|
|
|
1056
1058
|
declare const defaultLocalStoragePluginOptions: Required<LocalStoragePluginOptions>;
|
|
1057
1059
|
declare const localStoragePlugin: BetterHtmlPluginConstructor<LocalStoragePluginOptions>;
|
|
1058
1060
|
|
|
1059
|
-
export { type Alert, type AlertType, type AlertsPluginOptions, type AppConfig, type AssetName, type AssetsConfig, type BetterHtmlConfig, type BetterHtmlPlugin, _default as BetterHtmlProvider, type
|
|
1061
|
+
export { type Alert, type AlertType, type AlertsPluginOptions, type AppConfig, type AssetName, type AssetsConfig, type BetterHtmlConfig, type BetterHtmlPlugin, _default as BetterHtmlProvider, type BetterHtmlProviderConfig, type BrowserName, Button, type ButtonProps, Chip, type ChipProps, type Color, type ColorName, type ColorTheme, ColorThemeSwitch, type ColorThemeSwitchProps, type Colors, type ComponentHoverStyle, type ComponentMarginProps, type ComponentPaddingProps, type DeepPartialRecord, Div, type DivProps, _default$3 as Divider, Dropdown, type DropdownOption, type DropdownProps, type ExcludeOptions, Foldable, type FoldableProps, type FoldableRef, Form, type FormProps, FormRow, type FormRowProps, type HorizontalDividerProps, _default$5 as Icon, type IconName, type IconProps, type IconsConfig, _default$4 as Image, type ImageProps, InputField, type InputFieldProps, _default$1 as Label, type LabelProps, Loader, type LoaderConfig, type LoaderName, type LoaderProps, type LocalStoragePluginOptions, Modal, type ModalProps, type ModalRef, type OmitProps, PageHeader, type PageHeaderProps, PageHolder, type PageHolderProps, type PartialRecord, type PickAllRequired, type PickValue, type PluginName, type ReactRouterDomPluginOptions, type Styles, type TabGroup, Table, type TableColumn, type TableProps, type TableRef, Tabs, type TabsProps, type TabsRef, Text, type TextAs, type TextProps, type TextareaFieldProps, type Theme, type ThemeConfig, _default$2 as ToggleInput, type ToggleInputProps, type ToggleInputRef, Tooltip, type TooltipProps, type TooltipRef, type VerticalDividerProps, alertControls, alertsPlugin, colorThemeControls, countries, darkenColor, defaultAlertsPluginOptions, defaultLocalStoragePluginOptions, defaultReactRouterDomPluginOptions, desaturateColor, eventPreventDefault, eventPreventStop, eventStopPropagation, filterHover, formatPhoneNumber, generateLocalStorage, generateRandomString, getBrowser, getFormErrorObject, isMobileDevice, lightenColor, loaderControls, localStoragePlugin, reactRouterDomPlugin, saturateColor, useAlertControls, useBetterHtmlContext, useBooleanState, useDebounceState, useForm, useLoader, useLoaderControls, useMediaQuery, usePageResize, usePageScroll, useTheme, useUrlQuery };
|
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
|
|
|
@@ -3697,14 +3697,15 @@ var ModalComponent = (0, import_react14.forwardRef)(function Modal({
|
|
|
3697
3697
|
marginTop: 1,
|
|
3698
3698
|
iconColor: titleColor,
|
|
3699
3699
|
onClick: onClickClose,
|
|
3700
|
-
transition: theme2.styles.transition
|
|
3700
|
+
transition: theme2.styles.transition,
|
|
3701
|
+
zIndex: 10
|
|
3701
3702
|
}
|
|
3702
3703
|
)
|
|
3703
3704
|
]
|
|
3704
3705
|
}
|
|
3705
3706
|
),
|
|
3706
3707
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Divider_default.horizontal, {})
|
|
3707
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: !withoutCloseButton && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Div_default, { position: "absolute", top: theme2.styles.space, right: theme2.styles.space, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button_default.icon, { icon: "XMark", onClick: onClickClose }) }) }),
|
|
3708
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: !withoutCloseButton && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Div_default, { position: "absolute", top: theme2.styles.space, right: theme2.styles.space, zIndex: 10, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button_default.icon, { icon: "XMark", onClick: onClickClose }) }) }),
|
|
3708
3709
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Div_default, { padding: title ? theme2.styles.space : void 0, children })
|
|
3709
3710
|
]
|
|
3710
3711
|
}
|
|
@@ -8314,7 +8315,7 @@ var TableComponent = (0, import_react25.forwardRef)(function Table({
|
|
|
8314
8315
|
disabled: data.length === 0,
|
|
8315
8316
|
onChange: onClickAllCheckboxesElement
|
|
8316
8317
|
}
|
|
8317
|
-
) : column.label ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Text_default, { children: column.label }) : void 0,
|
|
8318
|
+
) : column.label ? column.renderLabel ? column.renderLabel(column.label) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Text_default, { children: column.label }) : void 0,
|
|
8318
8319
|
column.filter && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
8319
8320
|
Button_default.icon,
|
|
8320
8321
|
{
|
|
@@ -8454,7 +8455,7 @@ var TableComponent = (0, import_react25.forwardRef)(function Table({
|
|
|
8454
8455
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
8455
8456
|
Modal_default,
|
|
8456
8457
|
{
|
|
8457
|
-
title: `Filter ${openedFilterColumn?.label}`,
|
|
8458
|
+
title: `Filter ${openedFilterColumn?.label ?? ""}`,
|
|
8458
8459
|
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
8460
|
onClose: onCloseFilterModal,
|
|
8460
8461
|
ref: filterModalRef,
|