react-better-html 1.1.123 → 1.1.125
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +101 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +101 -40
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -699,6 +699,7 @@ type DateFilter<DataItem> = {
|
|
|
699
699
|
type ListFilter<DataItem> = {
|
|
700
700
|
filter?: "list";
|
|
701
701
|
withTotalNumber?: boolean;
|
|
702
|
+
withSearch?: boolean;
|
|
702
703
|
getValueForList?: (item: DataItem) => OmitProps<ListFilterValue, "count">;
|
|
703
704
|
};
|
|
704
705
|
type TableColumn<DataItem> = {
|
package/dist/index.d.ts
CHANGED
|
@@ -699,6 +699,7 @@ type DateFilter<DataItem> = {
|
|
|
699
699
|
type ListFilter<DataItem> = {
|
|
700
700
|
filter?: "list";
|
|
701
701
|
withTotalNumber?: boolean;
|
|
702
|
+
withSearch?: boolean;
|
|
702
703
|
getValueForList?: (item: DataItem) => OmitProps<ListFilterValue, "count">;
|
|
703
704
|
};
|
|
704
705
|
type TableColumn<DataItem> = {
|
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
|
}
|
|
@@ -7307,14 +7348,19 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
7307
7348
|
return dataAfterFilter.slice(pageStartItemIndex, pageEndItemIndex);
|
|
7308
7349
|
}, [dataAfterFilter, pageSize, currentPage, pageCount]);
|
|
7309
7350
|
const everythingIsChecked = (0, import_react23.useMemo)(() => {
|
|
7310
|
-
return checkedItems.every((checked) => checked) && checkedItems.length === data.length;
|
|
7351
|
+
return data.length > 0 && checkedItems.every((checked) => checked) && checkedItems.length === data.length;
|
|
7311
7352
|
}, [data, checkedItems]);
|
|
7312
7353
|
const possibleFilterListValues = (0, import_react23.useMemo)(() => {
|
|
7313
7354
|
if (!openedFilterColumn) return [];
|
|
7314
7355
|
return data.reduce((previousValue, currentValue) => {
|
|
7315
7356
|
const valueFromList = openedFilterColumn.filter === "list" && openedFilterColumn.getValueForList ? openedFilterColumn.getValueForList(currentValue) : void 0;
|
|
7316
7357
|
const value = valueFromList ? valueFromList.value : openedFilterColumn.type === "text" && openedFilterColumn.keyName ? String(currentValue[openedFilterColumn.keyName]) : void 0;
|
|
7317
|
-
|
|
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) {
|
|
7318
7364
|
if (previousValue.some((item) => item.value === value)) {
|
|
7319
7365
|
previousValue = previousValue.map(
|
|
7320
7366
|
(item) => item.value === value ? {
|
|
@@ -7324,14 +7370,14 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
7324
7370
|
);
|
|
7325
7371
|
} else
|
|
7326
7372
|
previousValue.push({
|
|
7327
|
-
label
|
|
7373
|
+
label,
|
|
7328
7374
|
value,
|
|
7329
7375
|
count: 1
|
|
7330
7376
|
});
|
|
7331
7377
|
}
|
|
7332
7378
|
return previousValue;
|
|
7333
7379
|
}, []);
|
|
7334
|
-
}, [data, openedFilterColumn]);
|
|
7380
|
+
}, [data, openedFilterColumn, filterForm.values.search]);
|
|
7335
7381
|
const pageCountInternal = pageCount ?? (pageSize !== void 0 ? Math.ceil(dataAfterFilter.length / pageSize) : 1);
|
|
7336
7382
|
const paginationItems = (0, import_react23.useMemo)(() => {
|
|
7337
7383
|
const halfRange = Math.floor(maximumVisiblePages / 2);
|
|
@@ -7414,6 +7460,7 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
7414
7460
|
ToggleInput_default.checkbox,
|
|
7415
7461
|
{
|
|
7416
7462
|
checked: everythingIsChecked,
|
|
7463
|
+
disabled: data.length === 0,
|
|
7417
7464
|
onChange: onClickAllCheckboxesElement
|
|
7418
7465
|
}
|
|
7419
7466
|
) : column.label ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Text_default, { children: column.label }) : void 0,
|
|
@@ -7601,9 +7648,10 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
7601
7648
|
] })
|
|
7602
7649
|
]
|
|
7603
7650
|
}
|
|
7604
|
-
) : openedFilterColumn.filter === "list" ? /* @__PURE__ */ (0, import_jsx_runtime21.
|
|
7651
|
+
) : openedFilterColumn.filter === "list" ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
7605
7652
|
Form_default,
|
|
7606
7653
|
{
|
|
7654
|
+
gap: theme2.styles.space,
|
|
7607
7655
|
submitButtonText: "Filter",
|
|
7608
7656
|
cancelButtonText: "Clear",
|
|
7609
7657
|
renderActionButtons: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(Div_default.row, { marginRight: "auto", alignItems: "center", gap: theme2.styles.gap, children: [
|
|
@@ -7611,6 +7659,7 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
7611
7659
|
Button_default.secondary,
|
|
7612
7660
|
{
|
|
7613
7661
|
text: "Select All",
|
|
7662
|
+
isSmall: true,
|
|
7614
7663
|
disabled: possibleFilterListValues.length === filterListSelectedItems?.length,
|
|
7615
7664
|
onClick: onClickSelectAllFilterListItems
|
|
7616
7665
|
}
|
|
@@ -7619,6 +7668,7 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
7619
7668
|
Button_default.secondary,
|
|
7620
7669
|
{
|
|
7621
7670
|
text: "Deselect All",
|
|
7671
|
+
isSmall: true,
|
|
7622
7672
|
disabled: !filterListSelectedItems?.length,
|
|
7623
7673
|
onClick: onClickDeselectAllFilterListItems
|
|
7624
7674
|
}
|
|
@@ -7626,36 +7676,47 @@ var TableComponent = (0, import_react23.forwardRef)(function Table({
|
|
|
7626
7676
|
] }),
|
|
7627
7677
|
onClickCancel: openedFilterData ? onClickCancelFormFilter : void 0,
|
|
7628
7678
|
onSubmit: filterForm.onSubmit,
|
|
7629
|
-
children:
|
|
7630
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
7631
|
-
|
|
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
|
-
|
|
7679
|
+
children: [
|
|
7680
|
+
openedFilterColumn?.withSearch && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(FormRow_default, { oneItemOnly: true, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
7681
|
+
InputField_default.search,
|
|
7682
|
+
{
|
|
7683
|
+
label: "Search",
|
|
7684
|
+
autoComplete: "off",
|
|
7685
|
+
...filterForm.getInputFieldProps("search")
|
|
7686
|
+
}
|
|
7687
|
+
) }),
|
|
7688
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(Div_default.column, { gap: theme2.styles.gap / 2, children: [
|
|
7689
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Label_default, { text: "Possible values" }),
|
|
7690
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Div_default.row, { flexWrap: "wrap", gap: theme2.styles.gap, children: possibleFilterListValues.length > 0 ? possibleFilterListValues.map((value) => {
|
|
7691
|
+
const isActive = filterListSelectedItems?.includes(value.value);
|
|
7692
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
7693
|
+
Div_default.box,
|
|
7694
|
+
{
|
|
7695
|
+
isActive,
|
|
7696
|
+
value: value.value,
|
|
7697
|
+
onClickWithValue: onClickFilterListItem,
|
|
7698
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(Div_default.row, { alignItems: "center", gap: theme2.styles.gap / 2, children: [
|
|
7699
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Text_default, { children: value.label ?? value.value }),
|
|
7700
|
+
openedFilterColumn.withTotalNumber && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
7701
|
+
Text_default,
|
|
7702
|
+
{
|
|
7703
|
+
fontSize: 14,
|
|
7704
|
+
color: isActive ? theme2.colors.base + "c0" : theme2.colors.textSecondary,
|
|
7705
|
+
children: [
|
|
7706
|
+
"(",
|
|
7707
|
+
value.count,
|
|
7708
|
+
")"
|
|
7709
|
+
]
|
|
7710
|
+
}
|
|
7711
|
+
)
|
|
7712
|
+
] })
|
|
7713
|
+
},
|
|
7714
|
+
value.value
|
|
7715
|
+
);
|
|
7716
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Text_default.unknown, { children: "No values" }) })
|
|
7717
|
+
] }),
|
|
7718
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Div_default, {})
|
|
7719
|
+
]
|
|
7659
7720
|
}
|
|
7660
7721
|
) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Text_default.unknown, { children: "Unknown filter" }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Loader_default.box, {})
|
|
7661
7722
|
}
|