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.mjs
CHANGED
|
@@ -5892,8 +5892,48 @@ InputFieldComponent.password = forwardRef11(function Password({ ...props }, ref)
|
|
|
5892
5892
|
}
|
|
5893
5893
|
);
|
|
5894
5894
|
});
|
|
5895
|
-
InputFieldComponent.search = forwardRef11(function Search({ ...props }, ref) {
|
|
5896
|
-
|
|
5895
|
+
InputFieldComponent.search = forwardRef11(function Search({ value, onChangeValue, onFocus, onBlur, ...props }, ref) {
|
|
5896
|
+
const [inputFieldValue, setInputFieldValue] = useState6(value?.toString() ?? "");
|
|
5897
|
+
const [inputFieldFocused, setInputFieldFocused] = useBooleanState();
|
|
5898
|
+
const onChangeValueElement = useCallback8(
|
|
5899
|
+
(value2) => {
|
|
5900
|
+
setInputFieldValue(value2);
|
|
5901
|
+
onChangeValue?.(value2);
|
|
5902
|
+
},
|
|
5903
|
+
[onChangeValue]
|
|
5904
|
+
);
|
|
5905
|
+
const onFocusElement = useCallback8(
|
|
5906
|
+
(event) => {
|
|
5907
|
+
setInputFieldFocused.setTrue();
|
|
5908
|
+
onFocus?.(event);
|
|
5909
|
+
},
|
|
5910
|
+
[onFocus]
|
|
5911
|
+
);
|
|
5912
|
+
const onBlurElement = useCallback8(
|
|
5913
|
+
(event) => {
|
|
5914
|
+
setTimeout(() => setInputFieldFocused.setFalse(), 0.1 * 1e3);
|
|
5915
|
+
onBlur?.(event);
|
|
5916
|
+
},
|
|
5917
|
+
[onBlur]
|
|
5918
|
+
);
|
|
5919
|
+
const onClickRightIcon = useCallback8(() => {
|
|
5920
|
+
onChangeValueElement("");
|
|
5921
|
+
}, [onChangeValueElement]);
|
|
5922
|
+
return /* @__PURE__ */ jsx15(
|
|
5923
|
+
InputFieldComponent,
|
|
5924
|
+
{
|
|
5925
|
+
leftIcon: "magnifyingGlass",
|
|
5926
|
+
placeholder: "Search...",
|
|
5927
|
+
rightIcon: inputFieldValue.length > 0 && inputFieldFocused ? "XMark" : void 0,
|
|
5928
|
+
onClickRightIcon,
|
|
5929
|
+
value: inputFieldValue,
|
|
5930
|
+
onChangeValue: onChangeValueElement,
|
|
5931
|
+
onFocus: onFocusElement,
|
|
5932
|
+
onBlur: onBlurElement,
|
|
5933
|
+
ref,
|
|
5934
|
+
...props
|
|
5935
|
+
}
|
|
5936
|
+
);
|
|
5897
5937
|
});
|
|
5898
5938
|
InputFieldComponent.phoneNumber = forwardRef11(function PhoneNumber({ label, value, onChangeValue, labelColor, id, ...props }, ref) {
|
|
5899
5939
|
const theme2 = useTheme();
|
|
@@ -6971,7 +7011,8 @@ var TableComponent = forwardRef15(function Table({
|
|
|
6971
7011
|
const filterForm = useForm({
|
|
6972
7012
|
defaultValues: {
|
|
6973
7013
|
min: void 0,
|
|
6974
|
-
max: void 0
|
|
7014
|
+
max: void 0,
|
|
7015
|
+
search: ""
|
|
6975
7016
|
},
|
|
6976
7017
|
onSubmit: (values) => {
|
|
6977
7018
|
if (!openedFilterColumn?.filter) return;
|
|
@@ -6986,10 +7027,10 @@ var TableComponent = forwardRef15(function Table({
|
|
|
6986
7027
|
type: openedFilterColumn.filter,
|
|
6987
7028
|
min: values.min,
|
|
6988
7029
|
max: values.max
|
|
6989
|
-
} : openedFilterColumn.filter === "list" ? {
|
|
7030
|
+
} : openedFilterColumn.filter === "list" ? filterListSelectedItems && filterListSelectedItems.length > 0 ? {
|
|
6990
7031
|
type: openedFilterColumn.filter,
|
|
6991
7032
|
list: filterListSelectedItems
|
|
6992
|
-
} : void 0
|
|
7033
|
+
} : void 0 : void 0
|
|
6993
7034
|
}));
|
|
6994
7035
|
filterModalRef.current?.close();
|
|
6995
7036
|
}
|
|
@@ -7235,14 +7276,19 @@ var TableComponent = forwardRef15(function Table({
|
|
|
7235
7276
|
return dataAfterFilter.slice(pageStartItemIndex, pageEndItemIndex);
|
|
7236
7277
|
}, [dataAfterFilter, pageSize, currentPage, pageCount]);
|
|
7237
7278
|
const everythingIsChecked = useMemo7(() => {
|
|
7238
|
-
return checkedItems.every((checked) => checked) && checkedItems.length === data.length;
|
|
7279
|
+
return data.length > 0 && checkedItems.every((checked) => checked) && checkedItems.length === data.length;
|
|
7239
7280
|
}, [data, checkedItems]);
|
|
7240
7281
|
const possibleFilterListValues = useMemo7(() => {
|
|
7241
7282
|
if (!openedFilterColumn) return [];
|
|
7242
7283
|
return data.reduce((previousValue, currentValue) => {
|
|
7243
7284
|
const valueFromList = openedFilterColumn.filter === "list" && openedFilterColumn.getValueForList ? openedFilterColumn.getValueForList(currentValue) : void 0;
|
|
7244
7285
|
const value = valueFromList ? valueFromList.value : openedFilterColumn.type === "text" && openedFilterColumn.keyName ? String(currentValue[openedFilterColumn.keyName]) : void 0;
|
|
7245
|
-
|
|
7286
|
+
const label = valueFromList ? valueFromList.label : value;
|
|
7287
|
+
let searchPassed = openedFilterColumn.filter === "list" && openedFilterColumn.withSearch ? false : true;
|
|
7288
|
+
if (openedFilterColumn.filter === "list" && openedFilterColumn.withSearch) {
|
|
7289
|
+
searchPassed = label?.toLowerCase().includes(filterForm.values.search.toLowerCase()) ?? false;
|
|
7290
|
+
}
|
|
7291
|
+
if (value !== void 0 && value !== null && value !== "" && searchPassed) {
|
|
7246
7292
|
if (previousValue.some((item) => item.value === value)) {
|
|
7247
7293
|
previousValue = previousValue.map(
|
|
7248
7294
|
(item) => item.value === value ? {
|
|
@@ -7252,14 +7298,14 @@ var TableComponent = forwardRef15(function Table({
|
|
|
7252
7298
|
);
|
|
7253
7299
|
} else
|
|
7254
7300
|
previousValue.push({
|
|
7255
|
-
label
|
|
7301
|
+
label,
|
|
7256
7302
|
value,
|
|
7257
7303
|
count: 1
|
|
7258
7304
|
});
|
|
7259
7305
|
}
|
|
7260
7306
|
return previousValue;
|
|
7261
7307
|
}, []);
|
|
7262
|
-
}, [data, openedFilterColumn]);
|
|
7308
|
+
}, [data, openedFilterColumn, filterForm.values.search]);
|
|
7263
7309
|
const pageCountInternal = pageCount ?? (pageSize !== void 0 ? Math.ceil(dataAfterFilter.length / pageSize) : 1);
|
|
7264
7310
|
const paginationItems = useMemo7(() => {
|
|
7265
7311
|
const halfRange = Math.floor(maximumVisiblePages / 2);
|
|
@@ -7342,6 +7388,7 @@ var TableComponent = forwardRef15(function Table({
|
|
|
7342
7388
|
ToggleInput_default.checkbox,
|
|
7343
7389
|
{
|
|
7344
7390
|
checked: everythingIsChecked,
|
|
7391
|
+
disabled: data.length === 0,
|
|
7345
7392
|
onChange: onClickAllCheckboxesElement
|
|
7346
7393
|
}
|
|
7347
7394
|
) : column.label ? /* @__PURE__ */ jsx20(Text_default, { children: column.label }) : void 0,
|
|
@@ -7529,9 +7576,10 @@ var TableComponent = forwardRef15(function Table({
|
|
|
7529
7576
|
] })
|
|
7530
7577
|
]
|
|
7531
7578
|
}
|
|
7532
|
-
) : openedFilterColumn.filter === "list" ? /* @__PURE__ */
|
|
7579
|
+
) : openedFilterColumn.filter === "list" ? /* @__PURE__ */ jsxs16(
|
|
7533
7580
|
Form_default,
|
|
7534
7581
|
{
|
|
7582
|
+
gap: theme2.styles.space,
|
|
7535
7583
|
submitButtonText: "Filter",
|
|
7536
7584
|
cancelButtonText: "Clear",
|
|
7537
7585
|
renderActionButtons: /* @__PURE__ */ jsxs16(Div_default.row, { marginRight: "auto", alignItems: "center", gap: theme2.styles.gap, children: [
|
|
@@ -7539,6 +7587,7 @@ var TableComponent = forwardRef15(function Table({
|
|
|
7539
7587
|
Button_default.secondary,
|
|
7540
7588
|
{
|
|
7541
7589
|
text: "Select All",
|
|
7590
|
+
isSmall: true,
|
|
7542
7591
|
disabled: possibleFilterListValues.length === filterListSelectedItems?.length,
|
|
7543
7592
|
onClick: onClickSelectAllFilterListItems
|
|
7544
7593
|
}
|
|
@@ -7547,6 +7596,7 @@ var TableComponent = forwardRef15(function Table({
|
|
|
7547
7596
|
Button_default.secondary,
|
|
7548
7597
|
{
|
|
7549
7598
|
text: "Deselect All",
|
|
7599
|
+
isSmall: true,
|
|
7550
7600
|
disabled: !filterListSelectedItems?.length,
|
|
7551
7601
|
onClick: onClickDeselectAllFilterListItems
|
|
7552
7602
|
}
|
|
@@ -7554,36 +7604,47 @@ var TableComponent = forwardRef15(function Table({
|
|
|
7554
7604
|
] }),
|
|
7555
7605
|
onClickCancel: openedFilterData ? onClickCancelFormFilter : void 0,
|
|
7556
7606
|
onSubmit: filterForm.onSubmit,
|
|
7557
|
-
children:
|
|
7558
|
-
/* @__PURE__ */ jsx20(
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
|
|
7607
|
+
children: [
|
|
7608
|
+
openedFilterColumn?.withSearch && /* @__PURE__ */ jsx20(FormRow_default, { oneItemOnly: true, children: /* @__PURE__ */ jsx20(
|
|
7609
|
+
InputField_default.search,
|
|
7610
|
+
{
|
|
7611
|
+
label: "Search",
|
|
7612
|
+
autoComplete: "off",
|
|
7613
|
+
...filterForm.getInputFieldProps("search")
|
|
7614
|
+
}
|
|
7615
|
+
) }),
|
|
7616
|
+
/* @__PURE__ */ jsxs16(Div_default.column, { gap: theme2.styles.gap / 2, children: [
|
|
7617
|
+
/* @__PURE__ */ jsx20(Label_default, { text: "Possible values" }),
|
|
7618
|
+
/* @__PURE__ */ jsx20(Div_default.row, { flexWrap: "wrap", gap: theme2.styles.gap, children: possibleFilterListValues.length > 0 ? possibleFilterListValues.map((value) => {
|
|
7619
|
+
const isActive = filterListSelectedItems?.includes(value.value);
|
|
7620
|
+
return /* @__PURE__ */ jsx20(
|
|
7621
|
+
Div_default.box,
|
|
7622
|
+
{
|
|
7623
|
+
isActive,
|
|
7624
|
+
value: value.value,
|
|
7625
|
+
onClickWithValue: onClickFilterListItem,
|
|
7626
|
+
children: /* @__PURE__ */ jsxs16(Div_default.row, { alignItems: "center", gap: theme2.styles.gap / 2, children: [
|
|
7627
|
+
/* @__PURE__ */ jsx20(Text_default, { children: value.label ?? value.value }),
|
|
7628
|
+
openedFilterColumn.withTotalNumber && /* @__PURE__ */ jsxs16(
|
|
7629
|
+
Text_default,
|
|
7630
|
+
{
|
|
7631
|
+
fontSize: 14,
|
|
7632
|
+
color: isActive ? theme2.colors.base + "c0" : theme2.colors.textSecondary,
|
|
7633
|
+
children: [
|
|
7634
|
+
"(",
|
|
7635
|
+
value.count,
|
|
7636
|
+
")"
|
|
7637
|
+
]
|
|
7638
|
+
}
|
|
7639
|
+
)
|
|
7640
|
+
] })
|
|
7641
|
+
},
|
|
7642
|
+
value.value
|
|
7643
|
+
);
|
|
7644
|
+
}) : /* @__PURE__ */ jsx20(Text_default.unknown, { children: "No values" }) })
|
|
7645
|
+
] }),
|
|
7646
|
+
/* @__PURE__ */ jsx20(Div_default, {})
|
|
7647
|
+
]
|
|
7587
7648
|
}
|
|
7588
7649
|
) : /* @__PURE__ */ jsx20(Text_default.unknown, { children: "Unknown filter" }) : /* @__PURE__ */ jsx20(Loader_default.box, {})
|
|
7589
7650
|
}
|