react-better-html 1.1.122 → 1.1.124
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 +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +118 -59
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +118 -59
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -647,6 +647,11 @@ declare const ColorThemeSwitch: typeof ColorThemeSwitchComponent & {
|
|
|
647
647
|
};
|
|
648
648
|
|
|
649
649
|
type FilterPreset = "today" | "yesterday" | "tomorrow" | "thisWeek" | "thisMonth" | "thisYear" | "lastWeek" | "lastMonth" | "lastYear" | "nextWeek" | "nextMonth" | "nextYear";
|
|
650
|
+
type ListFilterValue = {
|
|
651
|
+
label?: string;
|
|
652
|
+
value: string;
|
|
653
|
+
count: number;
|
|
654
|
+
};
|
|
650
655
|
type TableFilterData = {
|
|
651
656
|
type: "number";
|
|
652
657
|
min?: number;
|
|
@@ -694,7 +699,8 @@ type DateFilter<DataItem> = {
|
|
|
694
699
|
type ListFilter<DataItem> = {
|
|
695
700
|
filter?: "list";
|
|
696
701
|
withTotalNumber?: boolean;
|
|
697
|
-
|
|
702
|
+
withSearch?: boolean;
|
|
703
|
+
getValueForList?: (item: DataItem) => OmitProps<ListFilterValue, "count">;
|
|
698
704
|
};
|
|
699
705
|
type TableColumn<DataItem> = {
|
|
700
706
|
label?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -647,6 +647,11 @@ declare const ColorThemeSwitch: typeof ColorThemeSwitchComponent & {
|
|
|
647
647
|
};
|
|
648
648
|
|
|
649
649
|
type FilterPreset = "today" | "yesterday" | "tomorrow" | "thisWeek" | "thisMonth" | "thisYear" | "lastWeek" | "lastMonth" | "lastYear" | "nextWeek" | "nextMonth" | "nextYear";
|
|
650
|
+
type ListFilterValue = {
|
|
651
|
+
label?: string;
|
|
652
|
+
value: string;
|
|
653
|
+
count: number;
|
|
654
|
+
};
|
|
650
655
|
type TableFilterData = {
|
|
651
656
|
type: "number";
|
|
652
657
|
min?: number;
|
|
@@ -694,7 +699,8 @@ type DateFilter<DataItem> = {
|
|
|
694
699
|
type ListFilter<DataItem> = {
|
|
695
700
|
filter?: "list";
|
|
696
701
|
withTotalNumber?: boolean;
|
|
697
|
-
|
|
702
|
+
withSearch?: boolean;
|
|
703
|
+
getValueForList?: (item: DataItem) => OmitProps<ListFilterValue, "count">;
|
|
698
704
|
};
|
|
699
705
|
type TableColumn<DataItem> = {
|
|
700
706
|
label?: string;
|
package/dist/index.js
CHANGED
|
@@ -5974,8 +5974,48 @@ InputFieldComponent.password = (0, import_react18.forwardRef)(function Password(
|
|
|
5974
5974
|
}
|
|
5975
5975
|
);
|
|
5976
5976
|
});
|
|
5977
|
-
InputFieldComponent.search = (0, import_react18.forwardRef)(function Search({ ...props }, ref) {
|
|
5978
|
-
|
|
5977
|
+
InputFieldComponent.search = (0, import_react18.forwardRef)(function Search({ value, onChangeValue, onFocus, onBlur, ...props }, ref) {
|
|
5978
|
+
const [inputFieldValue, setInputFieldValue] = (0, import_react18.useState)(value?.toString() ?? "");
|
|
5979
|
+
const [inputFieldFocused, setInputFieldFocused] = useBooleanState();
|
|
5980
|
+
const onChangeValueElement = (0, import_react18.useCallback)(
|
|
5981
|
+
(value2) => {
|
|
5982
|
+
setInputFieldValue(value2);
|
|
5983
|
+
onChangeValue?.(value2);
|
|
5984
|
+
},
|
|
5985
|
+
[onChangeValue]
|
|
5986
|
+
);
|
|
5987
|
+
const onFocusElement = (0, import_react18.useCallback)(
|
|
5988
|
+
(event) => {
|
|
5989
|
+
setInputFieldFocused.setTrue();
|
|
5990
|
+
onFocus?.(event);
|
|
5991
|
+
},
|
|
5992
|
+
[onFocus]
|
|
5993
|
+
);
|
|
5994
|
+
const onBlurElement = (0, import_react18.useCallback)(
|
|
5995
|
+
(event) => {
|
|
5996
|
+
setTimeout(() => setInputFieldFocused.setFalse(), 0.1 * 1e3);
|
|
5997
|
+
onBlur?.(event);
|
|
5998
|
+
},
|
|
5999
|
+
[onBlur]
|
|
6000
|
+
);
|
|
6001
|
+
const onClickRightIcon = (0, import_react18.useCallback)(() => {
|
|
6002
|
+
onChangeValueElement("");
|
|
6003
|
+
}, [onChangeValueElement]);
|
|
6004
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
6005
|
+
InputFieldComponent,
|
|
6006
|
+
{
|
|
6007
|
+
leftIcon: "magnifyingGlass",
|
|
6008
|
+
placeholder: "Search...",
|
|
6009
|
+
rightIcon: inputFieldValue.length > 0 && inputFieldFocused ? "XMark" : void 0,
|
|
6010
|
+
onClickRightIcon,
|
|
6011
|
+
value: inputFieldValue,
|
|
6012
|
+
onChangeValue: onChangeValueElement,
|
|
6013
|
+
onFocus: onFocusElement,
|
|
6014
|
+
onBlur: onBlurElement,
|
|
6015
|
+
ref,
|
|
6016
|
+
...props
|
|
6017
|
+
}
|
|
6018
|
+
);
|
|
5979
6019
|
});
|
|
5980
6020
|
InputFieldComponent.phoneNumber = (0, import_react18.forwardRef)(function PhoneNumber({ label, value, onChangeValue, labelColor, id, ...props }, ref) {
|
|
5981
6021
|
const theme2 = useTheme();
|
|
@@ -7043,7 +7083,8 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
7043
7083
|
const filterForm = useForm({
|
|
7044
7084
|
defaultValues: {
|
|
7045
7085
|
min: void 0,
|
|
7046
|
-
max: void 0
|
|
7086
|
+
max: void 0,
|
|
7087
|
+
search: ""
|
|
7047
7088
|
},
|
|
7048
7089
|
onSubmit: (values) => {
|
|
7049
7090
|
if (!openedFilterColumn?.filter) return;
|
|
@@ -7058,10 +7099,10 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
7058
7099
|
type: openedFilterColumn.filter,
|
|
7059
7100
|
min: values.min,
|
|
7060
7101
|
max: values.max
|
|
7061
|
-
} : openedFilterColumn.filter === "list" ? {
|
|
7102
|
+
} : openedFilterColumn.filter === "list" ? filterListSelectedItems && filterListSelectedItems.length > 0 ? {
|
|
7062
7103
|
type: openedFilterColumn.filter,
|
|
7063
7104
|
list: filterListSelectedItems
|
|
7064
|
-
} : void 0
|
|
7105
|
+
} : void 0 : void 0
|
|
7065
7106
|
}));
|
|
7066
7107
|
filterModalRef.current?.close();
|
|
7067
7108
|
}
|
|
@@ -7291,7 +7332,7 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
7291
7332
|
if (filter.min !== void 0 && minDate && itemValue < minDate) return false;
|
|
7292
7333
|
if (filter.max !== void 0 && maxDate && itemValue > maxDate) return false;
|
|
7293
7334
|
} else if (column.filter === "list" && filter.type === "list") {
|
|
7294
|
-
const itemValue = column.getValueForList?.(item) ?? (column.type === "text" && column.keyName ? String(item[column.keyName]) : "");
|
|
7335
|
+
const itemValue = column.getValueForList?.(item).value ?? (column.type === "text" && column.keyName ? String(item[column.keyName]) : "");
|
|
7295
7336
|
if (!filter.list?.includes(itemValue)) return false;
|
|
7296
7337
|
}
|
|
7297
7338
|
return true;
|
|
@@ -7311,28 +7352,32 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
7311
7352
|
}, [data, checkedItems]);
|
|
7312
7353
|
const possibleFilterListValues = (0, import_react23.useMemo)(() => {
|
|
7313
7354
|
if (!openedFilterColumn) return [];
|
|
7314
|
-
return data.reduce(
|
|
7315
|
-
(
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
|
|
7330
|
-
}
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7355
|
+
return data.reduce((previousValue, currentValue) => {
|
|
7356
|
+
const valueFromList = openedFilterColumn.filter === "list" && openedFilterColumn.getValueForList ? openedFilterColumn.getValueForList(currentValue) : void 0;
|
|
7357
|
+
const value = valueFromList ? valueFromList.value : openedFilterColumn.type === "text" && openedFilterColumn.keyName ? String(currentValue[openedFilterColumn.keyName]) : void 0;
|
|
7358
|
+
const label = valueFromList ? valueFromList.label : value;
|
|
7359
|
+
let searchPassed = openedFilterColumn.filter === "list" && openedFilterColumn.withSearch ? false : true;
|
|
7360
|
+
if (openedFilterColumn.filter === "list" && openedFilterColumn.withSearch) {
|
|
7361
|
+
searchPassed = label?.toLowerCase().includes(filterForm.values.search.toLowerCase()) ?? false;
|
|
7362
|
+
}
|
|
7363
|
+
if (value !== void 0 && value !== null && value !== "" && searchPassed) {
|
|
7364
|
+
if (previousValue.some((item) => item.value === value)) {
|
|
7365
|
+
previousValue = previousValue.map(
|
|
7366
|
+
(item) => item.value === value ? {
|
|
7367
|
+
...item,
|
|
7368
|
+
count: item.count + 1
|
|
7369
|
+
} : item
|
|
7370
|
+
);
|
|
7371
|
+
} else
|
|
7372
|
+
previousValue.push({
|
|
7373
|
+
label,
|
|
7374
|
+
value,
|
|
7375
|
+
count: 1
|
|
7376
|
+
});
|
|
7377
|
+
}
|
|
7378
|
+
return previousValue;
|
|
7379
|
+
}, []);
|
|
7380
|
+
}, [data, openedFilterColumn, filterForm.values.search]);
|
|
7336
7381
|
const pageCountInternal = pageCount ?? (pageSize !== void 0 ? Math.ceil(dataAfterFilter.length / pageSize) : 1);
|
|
7337
7382
|
const paginationItems = (0, import_react23.useMemo)(() => {
|
|
7338
7383
|
const halfRange = Math.floor(maximumVisiblePages / 2);
|
|
@@ -7602,9 +7647,10 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
7602
7647
|
] })
|
|
7603
7648
|
]
|
|
7604
7649
|
}
|
|
7605
|
-
) : openedFilterColumn.filter === "list" ? /* @__PURE__ */ (0, import_jsx_runtime21.
|
|
7650
|
+
) : openedFilterColumn.filter === "list" ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
7606
7651
|
Form_default,
|
|
7607
7652
|
{
|
|
7653
|
+
gap: theme2.styles.space,
|
|
7608
7654
|
submitButtonText: "Filter",
|
|
7609
7655
|
cancelButtonText: "Clear",
|
|
7610
7656
|
renderActionButtons: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(Div_default.row, { marginRight: "auto", alignItems: "center", gap: theme2.styles.gap, children: [
|
|
@@ -7612,6 +7658,7 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
7612
7658
|
Button_default.secondary,
|
|
7613
7659
|
{
|
|
7614
7660
|
text: "Select All",
|
|
7661
|
+
isSmall: true,
|
|
7615
7662
|
disabled: possibleFilterListValues.length === filterListSelectedItems?.length,
|
|
7616
7663
|
onClick: onClickSelectAllFilterListItems
|
|
7617
7664
|
}
|
|
@@ -7620,6 +7667,7 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
7620
7667
|
Button_default.secondary,
|
|
7621
7668
|
{
|
|
7622
7669
|
text: "Deselect All",
|
|
7670
|
+
isSmall: true,
|
|
7623
7671
|
disabled: !filterListSelectedItems?.length,
|
|
7624
7672
|
onClick: onClickDeselectAllFilterListItems
|
|
7625
7673
|
}
|
|
@@ -7627,36 +7675,47 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
7627
7675
|
] }),
|
|
7628
7676
|
onClickCancel: openedFilterData ? onClickCancelFormFilter : void 0,
|
|
7629
7677
|
onSubmit: filterForm.onSubmit,
|
|
7630
|
-
children:
|
|
7631
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
|
|
7648
|
-
|
|
7649
|
-
|
|
7650
|
-
|
|
7651
|
-
|
|
7652
|
-
|
|
7653
|
-
|
|
7654
|
-
|
|
7655
|
-
|
|
7656
|
-
|
|
7657
|
-
|
|
7658
|
-
|
|
7659
|
-
|
|
7678
|
+
children: [
|
|
7679
|
+
openedFilterColumn?.withSearch && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(FormRow_default, { oneItemOnly: true, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
7680
|
+
InputField_default.search,
|
|
7681
|
+
{
|
|
7682
|
+
label: "Search",
|
|
7683
|
+
autoComplete: "off",
|
|
7684
|
+
...filterForm.getInputFieldProps("search")
|
|
7685
|
+
}
|
|
7686
|
+
) }),
|
|
7687
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(Div_default.column, { gap: theme2.styles.gap / 2, children: [
|
|
7688
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Label_default, { text: "Possible values" }),
|
|
7689
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Div_default.row, { flexWrap: "wrap", gap: theme2.styles.gap, children: possibleFilterListValues.length > 0 ? possibleFilterListValues.map((value) => {
|
|
7690
|
+
const isActive = filterListSelectedItems?.includes(value.value);
|
|
7691
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
7692
|
+
Div_default.box,
|
|
7693
|
+
{
|
|
7694
|
+
isActive,
|
|
7695
|
+
value: value.value,
|
|
7696
|
+
onClickWithValue: onClickFilterListItem,
|
|
7697
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(Div_default.row, { alignItems: "center", gap: theme2.styles.gap / 2, children: [
|
|
7698
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Text_default, { children: value.label ?? value.value }),
|
|
7699
|
+
openedFilterColumn.withTotalNumber && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
7700
|
+
Text_default,
|
|
7701
|
+
{
|
|
7702
|
+
fontSize: 14,
|
|
7703
|
+
color: isActive ? theme2.colors.base + "c0" : theme2.colors.textSecondary,
|
|
7704
|
+
children: [
|
|
7705
|
+
"(",
|
|
7706
|
+
value.count,
|
|
7707
|
+
")"
|
|
7708
|
+
]
|
|
7709
|
+
}
|
|
7710
|
+
)
|
|
7711
|
+
] })
|
|
7712
|
+
},
|
|
7713
|
+
value.value
|
|
7714
|
+
);
|
|
7715
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Text_default.unknown, { children: "No values" }) })
|
|
7716
|
+
] }),
|
|
7717
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Div_default, {})
|
|
7718
|
+
]
|
|
7660
7719
|
}
|
|
7661
7720
|
) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Text_default.unknown, { children: "Unknown filter" }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Loader_default.box, {})
|
|
7662
7721
|
}
|